From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 16 Jan 2017 20:42:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,242,1477983600"; d="scan'208";a="809725208" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 16 Jan 2017 20:42:52 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 16 Jan 2017 20:42:52 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 16 Jan 2017 20:42:51 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Tue, 17 Jan 2017 12:42:49 +0800 From: "Tan, Jianfeng" To: Jan Blunck , "dev@dpdk.org" CC: "shreyansh.jain@nxp.com" , "david.marchand@6wind.com" , "stephen@networkplumber.org" Thread-Topic: [dpdk-dev] [PATCH v5 02/20] eal: Allow passing const rte_intr_handle Thread-Index: AQHSXTWD6t0BsjBFH0m82DNYZWRdIaE8K3SQ 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> In-Reply-To: <1482508691-11408-3-git-send-email-jblunck@infradead.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 02/20] eal: Allow passing const rte_intr_handle X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jan 2017 04:42:54 -0000 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