[dpdk-dev] [PATCH v5 02/20] eal: Allow passing const rte_intr_handle
Tan, Jianfeng
jianfeng.tan at intel.com
Tue Jan 17 05:42:48 CET 2017
Hi Jan,
> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jan Blunck
> Sent: Friday, December 23, 2016 11:58 PM
> To: dev at dpdk.org
> Cc: shreyansh.jain at nxp.com; david.marchand at 6wind.com;
> stephen at networkplumber.org
> Subject: [dpdk-dev] [PATCH v5 02/20] eal: Allow passing const
> rte_intr_handle
>
> Both register/unregister and enable/disable don't necessarily require the
> rte_intr_handle to be modifiable. Therefore lets constify it.
>
> Signed-off-by: Jan Blunck <jblunck at infradead.org>
> ---
> 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(-)
>
> 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"
>
[...]
>
> +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 != intr_handle->fd)
> + continue;
> +
> + if (!src->intr_handle.max_intr)
> + src->intr_handle.max_intr = 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 usually changed as calling rte_intr_efd_enable() after that. How to make sure max_intr in "src" is valid? And, why shall we use src instead of intr_handle here?
Thanks,
Jianfeng
> + src->intr_handle.max_intr
> + = 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) {
>
> irq_set = (struct vfio_irq_set *) irq_set_buf;
> irq_set->argsz = len;
> - if (!intr_handle->max_intr)
> - intr_handle->max_intr = 1;
> - else if (intr_handle->max_intr > RTE_MAX_RXTX_INTR_VEC_ID)
> - intr_handle->max_intr = RTE_MAX_RXTX_INTR_VEC_ID + 1;
>
> - irq_set->count = intr_handle->max_intr;
> + ret = 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 = ret;
> irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD |
> VFIO_IRQ_SET_ACTION_TRIGGER;
> irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
> irq_set->start = 0;
> @@ -318,7 +342,7 @@ vfio_enable_msix(struct rte_intr_handle
> *intr_handle) {
>
More information about the dev
mailing list