From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Tan, Jianfeng" Subject: Re: [PATCH v5 02/20] eal: Allow passing const rte_intr_handle Date: Tue, 17 Jan 2017 04:42:48 +0000 Message-ID: References: <1482332986-7599-1-git-send-email-jblunck@infradead.org> <1482508691-11408-3-git-send-email-jblunck@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "shreyansh.jain@nxp.com" , "david.marchand@6wind.com" , "stephen@networkplumber.org" To: Jan Blunck , "dev@dpdk.org" Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7F71D2B99 for ; Tue, 17 Jan 2017 05:42:53 +0100 (CET) In-Reply-To: <1482508691-11408-3-git-send-email-jblunck@infradead.org> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Jan, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jan Blunck > Sent: Friday, December 23, 2016 11:58 PM > To: dev@dpdk.org > Cc: shreyansh.jain@nxp.com; david.marchand@6wind.com; > stephen@networkplumber.org > Subject: [dpdk-dev] [PATCH v5 02/20] eal: Allow passing const > rte_intr_handle >=20 > Both register/unregister and enable/disable don't necessarily require the > rte_intr_handle to be modifiable. Therefore lets constify it. >=20 > Signed-off-by: Jan Blunck > --- > lib/librte_eal/bsdapp/eal/eal_interrupts.c | 24 ++++++---- > lib/librte_eal/common/include/rte_interrupts.h | 8 ++-- > lib/librte_eal/linuxapp/eal/eal_interrupts.c | 62 ++++++++++++++++++--= -- > ---- > 3 files changed, 63 insertions(+), 31 deletions(-) >=20 > diff --git a/lib/librte_eal/bsdapp/eal/eal_interrupts.c > b/lib/librte_eal/bsdapp/eal/eal_interrupts.c > index 836e483..ea2afff 100644 > --- a/lib/librte_eal/bsdapp/eal/eal_interrupts.c > +++ b/lib/librte_eal/bsdapp/eal/eal_interrupts.c > @@ -36,29 +36,37 @@ > #include "eal_private.h" >=20 [...] >=20 > +static int > +get_max_intr(const struct rte_intr_handle *intr_handle) > +{ > + struct rte_intr_source *src; > + > + TAILQ_FOREACH(src, &intr_sources, next) { > + if (src->intr_handle.fd !=3D intr_handle->fd) > + continue; > + > + if (!src->intr_handle.max_intr) > + src->intr_handle.max_intr =3D 1; > + else if (src->intr_handle.max_intr > > RTE_MAX_RXTX_INTR_VEC_ID) See "src" instead of intr_handle is used here. "src" is only initialized as= calling rte_intr_callback_register at device init phase. But max_intr is u= sually changed as calling rte_intr_efd_enable() after that. How to make sur= e max_intr in "src" is valid? And, why shall we use src instead of intr_han= dle here? Thanks, Jianfeng > + src->intr_handle.max_intr > + =3D RTE_MAX_RXTX_INTR_VEC_ID + 1; > + > + return src->intr_handle.max_intr; > + } > + > + return -1; > +} > + > /* enable MSI-X interrupts */ > static int > -vfio_enable_msix(struct rte_intr_handle *intr_handle) { > +vfio_enable_msix(const struct rte_intr_handle *intr_handle) { > int len, ret; > char irq_set_buf[MSIX_IRQ_SET_BUF_LEN]; > struct vfio_irq_set *irq_set; > @@ -290,12 +311,15 @@ vfio_enable_msix(struct rte_intr_handle > *intr_handle) { >=20 > irq_set =3D (struct vfio_irq_set *) irq_set_buf; > irq_set->argsz =3D len; > - if (!intr_handle->max_intr) > - intr_handle->max_intr =3D 1; > - else if (intr_handle->max_intr > RTE_MAX_RXTX_INTR_VEC_ID) > - intr_handle->max_intr =3D RTE_MAX_RXTX_INTR_VEC_ID + 1; >=20 > - irq_set->count =3D intr_handle->max_intr; > + ret =3D get_max_intr(intr_handle); > + if (ret < 0) { > + RTE_LOG(ERR, EAL, "Invalid number of MSI-X irqs for > fd %d\n", > + intr_handle->fd); > + return -1; > + } > + > + irq_set->count =3D ret; > irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | > VFIO_IRQ_SET_ACTION_TRIGGER; > irq_set->index =3D VFIO_PCI_MSIX_IRQ_INDEX; > irq_set->start =3D 0; > @@ -318,7 +342,7 @@ vfio_enable_msix(struct rte_intr_handle > *intr_handle) { >=20