make rte_intr_handle internal
Subsystems (6)
cover make rte_intr_handle internal
Moving struct rte_intr_handle as an internal structure to avoid any ABI breakages in future. Since this structure defines some static arrays and changing respective macros breaks the ABI. Eg:
Currently RTE_MAX_RXTX_INTR_VEC_ID imposes a limit of maximum 512 MSI-X interrupts that can be defined for a PCI device, while PCI specification allows maximum 2048 MSI-X interrupts that can be used. If some PCI device requires more than 512 vectors, either change the RTE_MAX_RXTX_INTR_VEC_ID limit or dynamically allocate based on PCI device MSI-X size on probe time. Either way its an ABI breakage.
Change already included in 21.11 ABI improvement spreadsheet (item 42):
https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.google.com_s
preadsheets_d_1betlC000ua5SsSiJIcC54mCCCJnW6voH5Dqv9UxeyfE_edit-23gid- 3D0&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=5ESHPj7V-7JdkxT_Z_SU6RrS37ys4U XudBQ_rrS5LRo&m=7dl3OmXU7QHMmWYB6V1hYJtq1cUkjfhXUwze2Si_48c&s=lh6DEGhR Bg1shODpAy3RQk-H-0uQx5icRfUBf9dtCp4&e=
This series makes struct rte_intr_handle totally opaque to the outside world by wrapping it inside a .c file and providing get set wrapper APIs to read or manipulate its fields.. Any changes to be made to any of the fields should be done via these get set APIs.
Introduced a new eal_common_interrupts.c where all these APIs are defined and also hides struct rte_intr_handle definition.
Details on each patch of the series:
Patch 1: eal: interrupt handle API prototypes
This patch provides prototypes of all the new get set APIs, and also rearranges the headers related to interrupt framework. Epoll related definitions prototypes are moved into a new header i.e. rte_epoll.h and APIs defined in rte_eal_interrupts.h which were driver specific are moved to rte_interrupts.h (as anyways it was accessible and used outside DPDK library. Later in the series rte_eal_interrupts.h is removed.
Patch 2: eal/interrupts: implement get set APIs
Implementing all get, set and alloc APIs. Alloc APIs are implemented to allocate memory for interrupt handle instance. Currently most of the drivers defines interrupt handle instance as static but now it cant be static as size of rte_intr_handle is unknown to all the drivers. Drivers are expected to allocate interrupt instances during initialization and free these instances during cleanup phase.
Patch 3: eal/interrupts: avoid direct access to interrupt handle Modifying the interrupt framework for linux and freebsd to use these get set alloc APIs as per requirement and avoid accessing the fields directly.
Patch 4: test/interrupt: apply get set interrupt handle APIs Updating interrupt test suite to use interrupt handle APIs.
Patch 5: drivers: remove direct access to interrupt handle fields Modifying all the drivers and libraries which are currently directly accessing the interrupt handle fields. Drivers are expected to allocated the interrupt instance, use get set APIs with the allocated interrupt handle and free it on cleanup.
Patch 6: eal/interrupts: make interrupt handle structure opaque In this patch rte_eal_interrupt.h is removed, struct rte_intr_handle definition is moved to c file to make it completely opaque. As part of interrupt handle allocation, array like efds and elist(which are currently static) are dynamically allocated with default size (RTE_MAX_RXTX_INTR_VEC_ID). Later these arrays can be reallocated as per device requirement using new API rte_intr_handle_event_list_update(). Eg, on PCI device probing MSIX size can be queried and these arrays can be reallocated accordingly.
Patch 7: eal/alarm: introduce alarm fini routine
Introducing alarm fini routine, as the memory allocated for alarm interrupt instance can be freed in alarm fini.
Testing performed:
1. Validated the series by running interrupts and alarm test suite.
2. Validate l3fwd power functionality with octeontx2 and i40e intel cards, where interrupts are expected on packet arrival.
Harman Kalra (7):
eal: interrupt handle API prototypes eal/interrupts: implement get set APIs eal/interrupts: avoid direct access to interrupt handle test/interrupt: apply get set interrupt handle APIs
drivers: remove direct access to interrupt handle fields eal/interrupts: make interrupt handle structure opaque eal/alarm: introduce alarm fini routine
MAINTAINERS | 1 + app/test/test_interrupts.c | 237 +++--- drivers/baseband/acc100/rte_acc100_pmd.c | 18 +- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 13 +- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 14 +- drivers/bus/auxiliary/auxiliary_common.c | 2 + drivers/bus/auxiliary/linux/auxiliary.c | 11 + drivers/bus/auxiliary/rte_bus_auxiliary.h | 2 +- drivers/bus/dpaa/dpaa_bus.c | 28 +- drivers/bus/dpaa/rte_dpaa_bus.h | 2 +- drivers/bus/fslmc/fslmc_bus.c | 17 +- drivers/bus/fslmc/fslmc_vfio.c | 32 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 21 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- drivers/bus/fslmc/rte_fslmc.h | 2 +- drivers/bus/ifpga/ifpga_bus.c | 16 +- drivers/bus/ifpga/rte_bus_ifpga.h | 2 +- drivers/bus/pci/linux/pci.c | 4 +- drivers/bus/pci/linux/pci_uio.c | 73 +- drivers/bus/pci/linux/pci_vfio.c | 115 ++- drivers/bus/pci/pci_common.c | 29 +- drivers/bus/pci/pci_common_uio.c | 21 +- drivers/bus/pci/rte_bus_pci.h | 4 +- drivers/bus/vmbus/linux/vmbus_bus.c | 7 + drivers/bus/vmbus/linux/vmbus_uio.c | 37 +- drivers/bus/vmbus/rte_bus_vmbus.h | 2 +- drivers/bus/vmbus/vmbus_common_uio.c | 24 +- drivers/common/cnxk/roc_cpt.c | 8 +- drivers/common/cnxk/roc_dev.c | 14 +- drivers/common/cnxk/roc_irq.c | 106 +-- drivers/common/cnxk/roc_nix_irq.c | 37 +- drivers/common/cnxk/roc_npa.c | 2 +- drivers/common/cnxk/roc_platform.h | 34 + drivers/common/cnxk/roc_sso.c | 4 +- drivers/common/cnxk/roc_tim.c | 4 +- drivers/common/octeontx2/otx2_dev.c | 14 +- drivers/common/octeontx2/otx2_irq.c | 117 +-- .../octeontx2/otx2_cryptodev_hw_access.c | 4 +- drivers/event/octeontx2/otx2_evdev_irq.c | 12 +- drivers/mempool/octeontx2/otx2_mempool.c | 2 +- drivers/net/atlantic/atl_ethdev.c | 22 +- drivers/net/avp/avp_ethdev.c | 8 +- drivers/net/axgbe/axgbe_ethdev.c | 12 +- drivers/net/axgbe/axgbe_mdio.c | 6 +- drivers/net/bnx2x/bnx2x_ethdev.c | 10 +- drivers/net/bnxt/bnxt_ethdev.c | 32 +- drivers/net/bnxt/bnxt_irq.c | 4 +- drivers/net/dpaa/dpaa_ethdev.c | 47 +- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +- drivers/net/e1000/em_ethdev.c | 24 +- drivers/net/e1000/igb_ethdev.c | 84 ++- drivers/net/ena/ena_ethdev.c | 36 +- drivers/net/enic/enic_main.c | 27 +- drivers/net/failsafe/failsafe.c | 24 +- drivers/net/failsafe/failsafe_intr.c | 45 +- drivers/net/failsafe/failsafe_ops.c | 23 +- drivers/net/failsafe/failsafe_private.h | 2 +- drivers/net/fm10k/fm10k_ethdev.c | 32 +- drivers/net/hinic/hinic_pmd_ethdev.c | 10 +- drivers/net/hns3/hns3_ethdev.c | 50 +- drivers/net/hns3/hns3_ethdev_vf.c | 57 +- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/i40e/i40e_ethdev.c | 55 +- drivers/net/i40e/i40e_ethdev_vf.c | 43 +- drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_vchnl.c | 4 +- drivers/net/ice/ice_dcf.c | 10 +- drivers/net/ice/ice_dcf_ethdev.c | 23 +- drivers/net/ice/ice_ethdev.c | 51 +- drivers/net/igc/igc_ethdev.c | 47 +- drivers/net/ionic/ionic_ethdev.c | 12 +- drivers/net/ixgbe/ixgbe_ethdev.c | 70 +- drivers/net/memif/memif_socket.c | 99 ++- drivers/net/memif/memif_socket.h | 4 +- drivers/net/memif/rte_eth_memif.c | 63 +- drivers/net/memif/rte_eth_memif.h | 2 +- drivers/net/mlx4/mlx4.c | 20 +- drivers/net/mlx4/mlx4.h | 2 +- drivers/net/mlx4/mlx4_intr.c | 48 +- drivers/net/mlx5/linux/mlx5_os.c | 56 +- drivers/net/mlx5/linux/mlx5_socket.c | 26 +- drivers/net/mlx5/mlx5.h | 6 +- drivers/net/mlx5/mlx5_rxq.c | 43 +- drivers/net/mlx5/mlx5_trigger.c | 4 +- drivers/net/mlx5/mlx5_txpp.c | 27 +- drivers/net/netvsc/hn_ethdev.c | 4 +- drivers/net/nfp/nfp_net.c | 42 +- drivers/net/ngbe/ngbe_ethdev.c | 31 +- drivers/net/octeontx2/otx2_ethdev_irq.c | 35 +- drivers/net/qede/qede_ethdev.c | 16 +- drivers/net/sfc/sfc_intr.c | 29 +- drivers/net/tap/rte_eth_tap.c | 37 +- drivers/net/tap/rte_eth_tap.h | 2 +- drivers/net/tap/tap_intr.c | 33 +- drivers/net/thunderx/nicvf_ethdev.c | 13 + drivers/net/thunderx/nicvf_struct.h | 2 +- drivers/net/txgbe/txgbe_ethdev.c | 36 +- drivers/net/txgbe/txgbe_ethdev_vf.c | 35 +- drivers/net/vhost/rte_eth_vhost.c | 78 +- drivers/net/virtio/virtio_ethdev.c | 17 +- .../net/virtio/virtio_user/virtio_user_dev.c | 53 +- drivers/net/vmxnet3/vmxnet3_ethdev.c | 45 +- drivers/raw/ifpga/ifpga_rawdev.c | 42 +- drivers/raw/ntb/ntb.c | 10 +- .../regex/octeontx2/otx2_regexdev_hw_access.c | 4 +- drivers/vdpa/ifc/ifcvf_vdpa.c | 5 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 11 + drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 22 +- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 46 +- lib/bbdev/rte_bbdev.c | 4 +- lib/eal/common/eal_common_interrupts.c | 668 +++++++++++++++++ lib/eal/common/eal_private.h | 11 + lib/eal/common/meson.build | 2 + lib/eal/freebsd/eal.c | 1 + lib/eal/freebsd/eal_alarm.c | 57 +- lib/eal/freebsd/eal_interrupts.c | 93 ++- lib/eal/include/meson.build | 2 +- lib/eal/include/rte_eal_interrupts.h | 269 ------- lib/eal/include/rte_eal_trace.h | 24 +- lib/eal/include/rte_epoll.h | 117 +++ lib/eal/include/rte_interrupts.h | 673 +++++++++++++++++- lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_alarm.c | 39 +- lib/eal/linux/eal_dev.c | 65 +- lib/eal/linux/eal_interrupts.c | 294 +++++--- lib/eal/version.map | 30 + lib/ethdev/ethdev_pci.h | 2 +- lib/ethdev/rte_ethdev.c | 14 +- 129 files changed, 3763 insertions(+), 1672 deletions(-) create mode 100644 lib/eal/common/eal_common_interrupts.c delete mode 100644 lib/eal/include/rte_eal_interrupts.h create mode 100644 lib/eal/include/rte_epoll.h
Signature · 1 line
2.18.0
RFC 1/7 eal: interrupt handle API prototypes
Defining protypes of get/set APIs for accessing/manipulating interrupt handle fields.
Internal interrupt header i.e. rte_eal_interrupt.h is rearranged, as APIs defined are moved to rte_interrupts.h and epoll specific definitions are moved to a new header rte_epoll.h. Later in the series rte_eal_interrupt.h will be removed.
--- MAINTAINERS | 1 + lib/eal/include/meson.build | 1 + lib/eal/include/rte_eal_interrupts.h | 201 --------- lib/eal/include/rte_epoll.h | 116 +++++ lib/eal/include/rte_interrupts.h | 653 ++++++++++++++++++++++++++- 5 files changed, 769 insertions(+), 203 deletions(-) create mode 100644 lib/eal/include/rte_epoll.h
MAINTAINERS +1 -0
@@ -208,6 +208,7 @@ F: app/test/test_memzone.c Interrupt Subsystem M: Harman Kalra <[email protected]> +F: lib/eal/include/rte_epoll.h F: lib/eal/*/*interrupts.* F: app/test/test_interrupts.c
lib/eal/include/meson.build +1 -0
@@ -19,6 +19,7 @@ headers += files( 'rte_eal_memconfig.h', 'rte_eal_trace.h', 'rte_errno.h', + 'rte_epoll.h', 'rte_fbarray.h', 'rte_hexdump.h', 'rte_hypervisor.h',
lib/eal/include/rte_eal_interrupts.h +0 -201
211 lines not on this page · raw message
lib/eal/include/rte_epoll.h new file +116 -0
116 lines not on this page · raw message
lib/eal/include/rte_interrupts.h +651 -2
679 lines not on this page · raw message
Signature · 1 line
2.18.0
Re: [dpdk-dev] [RFC 1/7] eal: interrupt handle API prototypes
Quoted 9 lines · Harman Kalra
Defining protypes of get/set APIs for accessing/manipulating interrupt handle fields.
Internal interrupt header i.e.
rte_eal_interrupt.his rearranged, as APIs defined are moved torte_interrupts.hand epoll specific definitions are moved to a new headerrte_epoll.h. Later in the seriesrte_eal_interrupt.hwill be removed.Signed-off-by Harman Kalra <[email protected]>
Quoted 9 lines
--- MAINTAINERS | 1 + lib/eal/include/meson.build | 1 + lib/eal/include/rte_eal_interrupts.h | 201 --------- lib/eal/include/rte_epoll.h | 116 +++++ lib/eal/include/rte_interrupts.h | 653 ++++++++++++++++++++++++++- 5 files changed, 769 insertions(+), 203 deletions(-) create mode 100644 lib/eal/include/rte_epoll.h
Seems strange putting the API changes as a separate patch?
RFC 2/7 eal/interrupts: implement get set APIs
In reply to Harman KalraImplementing get set APIs for interrupt handle fields. To make any change to the interrupt handle fields, one should make use of these APIs.
--- lib/eal/common/eal_common_interrupts.c | 506 +++++++++++++++++++++++++ lib/eal/common/meson.build | 2 + lib/eal/include/rte_eal_interrupts.h | 6 +- lib/eal/version.map | 30 ++ 4 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 lib/eal/common/eal_common_interrupts.c
lib/eal/common/eal_common_interrupts.c new file +506 -0
@@ -0,0 +1,506 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2021 Marvell. +*/ + +#include <stdlib.h> +#include <string.h> + +#include <rte_errno.h> +#include <rte_log.h> +#include <rte_malloc.h> + +#include <rte_interrupts.h> + + +struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool from_hugepage) +{ +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct rte_intr_handle )); +if (!intr_handle) { +RTE_LOG (ERR ,EAL ,"Fail to allocate intr_handle\n" ); + rte_errno =ENOMEM ; +return NULL ; + } + +for (i =0 ; i < size; i++) { + intr_handle[i].nb_intr =RTE_MAX_RXTX_INTR_VEC_ID ; + intr_handle[i].alloc_from_hugepage = from_hugepage; + } + +return intr_handle; +} + +struct rte_intr_handle *rte_intr_handle_instance_index_get ( +struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOMEM ; +return NULL ; + } + +return &intr_handle[index]; +} + +int rte_intr_handle_instance_index_set (struct rte_intr_handle *intr_handle, +const struct rte_intr_handle *src, +int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (src ==NULL ) { +RTE_LOG (ERR ,EAL ,"Source interrupt instance unallocated\n" ); + rte_errno =EINVAL ; + goto fail; + } + +if (index <0 ) { +RTE_LOG (ERR ,EAL ,"Index cany be negative" ); + rte_errno =EINVAL ; + goto fail; + } + + intr_handle[index].fd = src->fd; + intr_handle[index].vfio_dev_fd = src->vfio_dev_fd; + intr_handle[index].type = src->type; + intr_handle[index].max_intr = src->max_intr; + intr_handle[index].nb_efd = src->nb_efd; + intr_handle[index].efd_counter_size = src->efd_counter_size; + +memcpy (intr_handle[index].efds, src->efds, src->nb_intr); +memcpy (intr_handle[index].elist, src->elist, src->nb_intr); + +return 0 ; +fail: +return rte_errno; +} + +void rte_intr_handle_instance_free (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + } + +if (intr_handle->alloc_from_hugepage) +rte_free (intr_handle); +else +free (intr_handle); +} + +int rte_intr_handle_fd_set (struct rte_intr_handle *intr_handle,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->fd = fd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_fd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->fd; +fail: +return rte_errno; +} + +int rte_intr_handle_type_set (struct rte_intr_handle *intr_handle, +enum rte_intr_handle_type type) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->type = type; + +return 0 ; +fail: +return rte_errno; +} + +enum rte_intr_handle_type rte_intr_handle_type_get ( +const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; +return RTE_INTR_HANDLE_UNKNOWN ; + } + +return intr_handle->type; +} + +int rte_intr_handle_dev_fd_set (struct rte_intr_handle *intr_handle,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->vfio_dev_fd = fd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_dev_fd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->vfio_dev_fd; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (max_intr > intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Max_intr=%d greater than PLT_MAX_RXTX_INTR_VEC_ID=%d" , + max_intr, intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->max_intr = max_intr; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->max_intr; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_efd_set (struct rte_intr_handle *intr_handle, +int nb_efd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->nb_efd = nb_efd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_efd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->nb_efd; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_intr_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->nb_intr; +fail: +return rte_errno; +} + +int rte_intr_handle_efd_counter_size_set (struct rte_intr_handle *intr_handle, +uint8_t efd_counter_size) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->efd_counter_size = efd_counter_size; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_efd_counter_size_get ( +const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->efd_counter_size; +fail: +return rte_errno; +} + +int *rte_intr_handle_efds_base (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->efds; +fail: +return NULL ; +} + +int rte_intr_handle_efds_index_get (const struct rte_intr_handle *intr_handle, +int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =EINVAL ; + goto fail; + } + +return intr_handle->efds[index]; +fail: +return rte_errno; +} + +int rte_intr_handle_efds_index_set (struct rte_intr_handle *intr_handle, +int index,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->efds[index] = fd; + +return 0 ; +fail: +return rte_errno; +} + +struct rte_epoll_event *rte_intr_handle_elist_index_get ( +struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + +return &intr_handle->elist[index]; +fail: +return NULL ; +} + +int rte_intr_handle_elist_index_set (struct rte_intr_handle *intr_handle, +int index,struct rte_epoll_event elist) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->elist[index] = elist; + +return 0 ; +fail: +return rte_errno; +} + +int *rte_intr_handle_vec_list_base (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; +return NULL ; + } + +return intr_handle->intr_vec; +} + +int rte_intr_handle_vec_list_alloc (struct rte_intr_handle *intr_handle, +const char *name,int size) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +/* Vector list already allocated */ +if (intr_handle->intr_vec) +return 0 ; + +if (size > intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , size, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->intr_vec =rte_zmalloc (name, size *sizeof (int ),0 ); +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Failed to allocate %d intr_vec" , size); + rte_errno =ENOMEM ; + goto fail; + } + + intr_handle->vec_list_size = size; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_vec_list_index_get ( +const struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Intr vector list not allocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index > intr_handle->vec_list_size) { +RTE_LOG (ERR ,EAL ,"Index %d greater than vec list size %d\n" , + index, intr_handle->vec_list_size); + rte_errno =ERANGE ; + goto fail; + } + +return intr_handle->intr_vec[index]; +fail: +return rte_errno; +} + +int rte_intr_handle_vec_list_index_set (struct rte_intr_handle *intr_handle, +int index,int vec) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Intr vector list not allocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index > intr_handle->vec_list_size) { +RTE_LOG (ERR ,EAL ,"Index %d greater than vec list size %d\n" , + index, intr_handle->vec_list_size); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->intr_vec[index] = vec; + +return 0 ; +fail: +return rte_errno; +} + +void rte_intr_handle_vec_list_free (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + } + +rte_free (intr_handle->intr_vec); + intr_handle->intr_vec =NULL ; +}
lib/eal/common/meson.build +2 -0
@@ -17,6 +17,7 @@ if is_windows 'eal_common_errno.c', 'eal_common_fbarray.c', 'eal_common_hexdump.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',
@@ -53,6 +54,7 @@ sources += files( 'eal_common_fbarray.c', 'eal_common_hexdump.c', 'eal_common_hypervisor.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',
lib/eal/include/rte_eal_interrupts.h +5 -1
@@ -55,13 +55,17 @@ struct rte_intr_handle { };void *handle;/**< device driver handle (Windows) */ }; +bool alloc_from_hugepage;enum rte_intr_handle_type type;/**< handle type */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */ +uint16_t nb_intr; +/**< Max vector count, default RTE_MAX_RXTX_INTR_VEC_ID */ int efds[RTE_MAX_RXTX_INTR_VEC_ID ];/**< intr vectors/efds mapping */ struct rte_epoll_event elist[RTE_MAX_RXTX_INTR_VEC_ID ]; -/**< intr vector epoll event */ +/**< intr vector epoll event */ +uint16_t vec_list_size;int *intr_vec;/**< intr vector number array */ };
lib/eal/version.map +30 -0
@@ -426,6 +426,36 @@ EXPERIMENTAL { # added in 21.08 rte_power_monitor_multi; # WINDOWS_NO_EXPORT + + # added in 21.11 + rte_intr_handle_fd_set; + rte_intr_handle_fd_get; + rte_intr_handle_dev_fd_set; + rte_intr_handle_dev_fd_get; + rte_intr_handle_type_set; + rte_intr_handle_type_get; + rte_intr_handle_instance_alloc; + rte_intr_handle_instance_index_get; + rte_intr_handle_instance_free; + rte_intr_handle_instance_index_set; + rte_intr_handle_event_list_update; + rte_intr_handle_max_intr_set; + rte_intr_handle_max_intr_get; + rte_intr_handle_nb_efd_set; + rte_intr_handle_nb_efd_get; + rte_intr_handle_nb_intr_get; + rte_intr_handle_efds_index_set; + rte_intr_handle_efds_index_get; + rte_intr_handle_efds_base; + rte_intr_handle_elist_index_set; + rte_intr_handle_elist_index_get; + rte_intr_handle_efd_counter_size_set; + rte_intr_handle_efd_counter_size_get; + rte_intr_handle_vec_list_alloc; + rte_intr_handle_vec_list_index_set; + rte_intr_handle_vec_list_index_get; + rte_intr_handle_vec_list_free; + rte_intr_handle_vec_list_base; }; INTERNAL {
Signature · 1 line
2.18.0
Re: [dpdk-dev] [RFC 2/7] eal/interrupts: implement get set APIs
Quoted 4 lines · Harman Kalra
Implementing get set APIs for interrupt handle fields. To make any change to the interrupt handle fields, one should make use of these APIs.
Quoted 9 lines
Signed-off-by Harman Kalra <[email protected]>--- lib/eal/common/eal_common_interrupts.c | 506 +++++++++++++++++++++++++ lib/eal/common/meson.build | 2 + lib/eal/include/rte_eal_interrupts.h | 6 +- lib/eal/version.map | 30 ++ 4 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 lib/eal/common/eal_common_interrupts.c
Seems strange putting the API changes as a separate patch?
RFC 3/7 eal/interrupts: avoid direct access to interrupt handle
In reply to Harman KalraMaking changes to the interrupt framework to use interrupt handle APIs to get/set any field. Direct access to any of the fields should be avoided to avoid any ABI breakage in future.
--- lib/eal/freebsd/eal_interrupts.c | 93 ++++++---- lib/eal/linux/eal_interrupts.c | 294 +++++++++++++++++++------------ 2 files changed, 241 insertions(+), 146 deletions(-)
lib/eal/freebsd/eal_interrupts.c +59 -34
@@ -40,7 +40,7 @@ struct rte_intr_callback {struct rte_intr_source {TAILQ_ENTRY (rte_intr_source) next; -struct rte_intr_handle intr_handle;/**< interrupt handle */ +struct rte_intr_handle *intr_handle;/**< interrupt handle */ struct rte_intr_cb_list callbacks;/**< user callbacks */ uint32_t active; };
@@ -60,7 +60,7 @@ static int intr_source_to_kevent(const struct rte_intr_handle *ih, struct kevent *ke) {/* alarm callbacks are special case */ -if (ih->type ==RTE_INTR_HANDLE_ALARM ) { +if (rte_intr_handle_type_get (ih) ==RTE_INTR_HANDLE_ALARM ) {uint64_t timeout_ns;/* get soonest alarm timeout */
@@ -89,7 +89,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,int ret =0 , add_event =0 ;/* first do parameter checking */ -if (intr_handle ==NULL || intr_handle->fd <0 || cb ==NULL ) { +if (intr_handle ==NULL ||rte_intr_handle_fd_get (intr_handle) <0 || + cb ==NULL ) {RTE_LOG (ERR ,EAL ,"Registering with invalid input parameter\n" );return -EINVAL ;
@@ -103,7 +104,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,/* find the source for this intr_handle */ TAILQ_FOREACH(src, &intr_sources, next) { -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_handle_fd_get (src->intr_handle) == +rte_intr_handle_fd_get (intr_handle))break ; }
@@ -112,8 +114,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,* thing on the list should be eal_alarm_callback() and we may * be called just to reset the timer. */ -if (src !=NULL && src->intr_handle.type ==RTE_INTR_HANDLE_ALARM && - !TAILQ_EMPTY (&src->callbacks)) { +if (src !=NULL &&rte_intr_handle_type_get (src->intr_handle) == +RTE_INTR_HANDLE_ALARM && !TAILQ_EMPTY (&src->callbacks)) { callback =NULL ; }else {/* allocate a new interrupt callback entity */
@@ -135,10 +137,20 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle, ret = -ENOMEM ; goto fail; }else { - src->intr_handle = *intr_handle; -TAILQ_INIT (&src->callbacks); -TAILQ_INSERT_TAIL (&intr_sources, src, next); - } + src->intr_handle = +rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (src->intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Can not create intr instance\n" ); +free (callback); + ret = -ENOMEM ; + }else { +rte_intr_handle_instance_index_set ( + src->intr_handle, intr_handle,0 ); +TAILQ_INIT (&src->callbacks); +TAILQ_INSERT_TAIL (&intr_sources, src, + next); + } }/* we had no interrupts for this */
@@ -151,7 +163,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,/* add events to the queue. timer events are special as we need to * re-set the timer. */ -if (add_event || src->intr_handle.type ==RTE_INTR_HANDLE_ALARM ) { +if (add_event ||rte_intr_handle_type_get (src->intr_handle) == +RTE_INTR_HANDLE_ALARM ) {struct kevent ke;memset (&ke,0 ,sizeof (ke));
@@ -173,12 +186,13 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,*/ if (errno ==ENODEV )RTE_LOG (DEBUG ,EAL ,"Interrupt handle %d not supported\n" , - src->intr_handle.fd); +rte_intr_handle_fd_get (src->intr_handle));else RTE_LOG (ERR ,EAL ,"Error adding fd %d " -"kevent, %s\n" , - src->intr_handle.fd, -strerror (errno)); +"kevent, %s\n" , +rte_intr_handle_fd_get ( + src->intr_handle), +strerror (errno)); ret = -errno; goto fail; }
@@ -213,7 +227,7 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,struct rte_intr_callback *cb, *next;/* do parameter checking first */ -if (intr_handle ==NULL || intr_handle->fd <0 ) { +if (intr_handle ==NULL ||rte_intr_handle_fd_get (intr_handle) <0 ) {RTE_LOG (ERR ,EAL ,"Unregistering with invalid input parameter\n" );return -EINVAL ;
@@ -228,7 +242,8 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,/* check if the insterrupt source for the fd is existent */ TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_handle_fd_get (src->intr_handle) == +rte_intr_handle_fd_get (intr_handle))break ;/* No interrupt source registered for the fd */
@@ -268,7 +283,7 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,struct rte_intr_callback *cb, *next;/* do parameter checking first */ -if (intr_handle ==NULL || intr_handle->fd <0 ) { +if (intr_handle ==NULL ||rte_intr_handle_fd_get (intr_handle) <0 ) {RTE_LOG (ERR ,EAL ,"Unregistering with invalid input parameter\n" );return -EINVAL ;
@@ -282,7 +297,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,/* check if the insterrupt source for the fd is existent */ TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_handle_fd_get (src->intr_handle) == +rte_intr_handle_fd_get (intr_handle))break ;/* No interrupt source registered for the fd */
@@ -314,7 +330,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,*/ if (kevent (kq, &ke,1 ,NULL ,0 ,NULL ) <0 ) {RTE_LOG (ERR ,EAL ,"Error removing fd %d kevent, %s\n" , - src->intr_handle.fd,strerror (errno)); +rte_intr_handle_fd_get (src->intr_handle), +strerror (errno));/* removing non-existent even is an expected condition * in some circumstances (e.g. oneshot events). */
@@ -365,17 +382,18 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)if (intr_handle ==NULL )return -1 ; -if (intr_handle->type ==RTE_INTR_HANDLE_VDEV ) { +if (rte_intr_handle_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV ) { rc =0 ; goto out; } -if (intr_handle->fd <0 || intr_handle->uio_cfg_fd <0 ) { +if (rte_intr_handle_fd_get (intr_handle) <0 || +rte_intr_handle_dev_fd_get (intr_handle) <0 ) { rc =-1 ; goto out; } -switch (intr_handle->type) { +switch (rte_intr_handle_type_get (intr_handle)) {/* not used at this moment */ case RTE_INTR_HANDLE_ALARM : rc =-1 ;
@@ -388,7 +406,7 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)default :RTE_LOG (ERR ,EAL ,"Unknown handle type of fd %d\n" , - intr_handle->fd); +rte_intr_handle_fd_get (intr_handle)); rc =-1 ;break ; }
@@ -406,17 +424,18 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)if (intr_handle ==NULL )return -1 ; -if (intr_handle->type ==RTE_INTR_HANDLE_VDEV ) { +if (rte_intr_handle_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV ) { rc =0 ; goto out; } -if (intr_handle->fd <0 || intr_handle->uio_cfg_fd <0 ) { +if (rte_intr_handle_fd_get (intr_handle) <0 || +rte_intr_handle_dev_fd_get (intr_handle) <0 ) { rc =-1 ; goto out; } -switch (intr_handle->type) { +switch (rte_intr_handle_type_get (intr_handle)) {/* not used at this moment */ case RTE_INTR_HANDLE_ALARM : rc =-1 ;
@@ -429,7 +448,7 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)default :RTE_LOG (ERR ,EAL ,"Unknown handle type of fd %d\n" , - intr_handle->fd); +rte_intr_handle_fd_get (intr_handle)); rc =-1 ;break ; }
@@ -441,7 +460,8 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)int rte_intr_ack (const struct rte_intr_handle *intr_handle) { -if (intr_handle && intr_handle->type ==RTE_INTR_HANDLE_VDEV ) +if (intr_handle && +rte_intr_handle_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV )return 0 ;return -1 ;
@@ -463,7 +483,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)rte_spinlock_lock (&intr_lock); TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == event_fd) +if (rte_intr_handle_fd_get (src->intr_handle) == + event_fd)break ;if (src ==NULL ) {rte_spinlock_unlock (&intr_lock);
@@ -475,7 +496,7 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)rte_spinlock_unlock (&intr_lock);/* set the length to be read dor different handle type */ -switch (src->intr_handle.type) { +switch (rte_intr_handle_type_get (src->intr_handle)) {case RTE_INTR_HANDLE_ALARM : bytes_read =0 ; call = true;
@@ -546,7 +567,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)/* mark for deletion from the queue */ ke.flags =EV_DELETE ; -if (intr_source_to_kevent (&src->intr_handle, &ke) <0 ) { +if (intr_source_to_kevent (src->intr_handle, + &ke) <0 ) {RTE_LOG (ERR ,EAL ,"Cannot convert to kevent\n" );rte_spinlock_unlock (&intr_lock);return ;
@@ -557,7 +579,9 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)*/ if (kevent (kq, &ke,1 ,NULL ,0 ,NULL ) <0 ) {RTE_LOG (ERR ,EAL ,"Error removing fd %d kevent, " -"%s\n" , src->intr_handle.fd, +"%s\n" , +rte_intr_handle_fd_get ( + src->intr_handle),strerror (errno));/* removing non-existent even is an expected * condition in some circumstances
@@ -567,7 +591,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)TAILQ_REMOVE (&src->callbacks, cb, next);if (cb->ucb_fn) - cb->ucb_fn (&src->intr_handle, cb->cb_arg); + cb->ucb_fn (src->intr_handle, + cb->cb_arg);free (cb); } }
lib/eal/linux/eal_interrupts.c +182 -112
754 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC 4/7 test/interrupt: apply get set interrupt handle APIs
In reply to Harman KalraUpdating the interrupt testsuite to make use of interrupt handle get set APIs.
--- app/test/test_interrupts.c | 237 ++++++++++++++++++++++++------------- 1 file changed, 152 insertions(+), 85 deletions(-)
app/test/test_interrupts.c +152 -85
@@ -27,7 +27,7 @@ enum test_interrupt_handle_type {/* flag of if callback is called */ static volatile int flag; -static struct rte_intr_handle intr_handles[TEST_INTERRUPT_HANDLE_MAX ]; +static struct rte_intr_handle *intr_handles;static enum test_interrupt_handle_type test_intr_type =TEST_INTERRUPT_HANDLE_MAX ;
@@ -50,7 +50,7 @@ static union intr_pipefds pfds;static inline int test_interrupt_handle_sanity_check (struct rte_intr_handle *intr_handle) { -if (!intr_handle || intr_handle->fd <0 ) +if (!intr_handle ||rte_intr_handle_fd_get (intr_handle) <0 )return -1 ;return 0 ;
@@ -62,31 +62,70 @@ test_interrupt_handle_sanity_check(struct rte_intr_handle *intr_handle)static int test_interrupt_init (void ) { +struct rte_intr_handle *test_intr_handle; +if (pipe (pfds.pipefd) <0 )return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_INVALID ].fd =-1 ; - intr_handles[TEST_INTERRUPT_HANDLE_INVALID ].type = -RTE_INTR_HANDLE_UNKNOWN ; + intr_handles =rte_intr_handle_instance_alloc (TEST_INTERRUPT_HANDLE_MAX , + false); +if (!intr_handles) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID ].type = -RTE_INTR_HANDLE_UNKNOWN ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle,-1 )) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_UNKNOWN )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ].type = -RTE_INTR_HANDLE_UIO ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_UNKNOWN )) +return -1 ; + + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_UIO ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_UIO )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ].type = -RTE_INTR_HANDLE_ALARM ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_ALARM ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_ALARM )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ].type = -RTE_INTR_HANDLE_DEV_EVENT ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle, +RTE_INTR_HANDLE_DEV_EVENT )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ].fd = pfds.writefd; - intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ].type =RTE_INTR_HANDLE_UIO ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_CASE1 ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.writefd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_UIO )) +return -1 ;return 0 ; }
@@ -97,6 +136,7 @@ test_interrupt_init(void)static int test_interrupt_deinit (void ) { +rte_intr_handle_instance_free (intr_handles);close (pfds.pipefd[0 ]);close (pfds.pipefd[1 ]);
@@ -125,8 +165,10 @@ test_interrupt_handle_compare(struct rte_intr_handle *intr_handle_l,if (!intr_handle_l || !intr_handle_r)return -1 ; -if (intr_handle_l->fd != intr_handle_r->fd || - intr_handle_l->type != intr_handle_r->type) +if (rte_intr_handle_fd_get (intr_handle_l) != +rte_intr_handle_fd_get (intr_handle_r) || +rte_intr_handle_type_get (intr_handle_l) != +rte_intr_handle_type_get (intr_handle_r))return -1 ;return 0 ;
@@ -178,6 +220,8 @@ static void test_interrupt_callback(void *arg) {struct rte_intr_handle *intr_handle = arg; +struct rte_intr_handle *test_intr_handle; +if (test_intr_type >=TEST_INTERRUPT_HANDLE_MAX ) {printf ("invalid interrupt type\n" ); flag =-1 ;
@@ -198,8 +242,9 @@ test_interrupt_callback(void *arg)return ; } -if (test_interrupt_handle_compare (intr_handle, - &(intr_handles[test_intr_type])) ==0 ) + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, + test_intr_type); +if (test_interrupt_handle_compare (intr_handle, test_intr_handle) ==0 ) flag =1 ; }
@@ -223,7 +268,7 @@ test_interrupt_callback_1(void *arg)static int test_interrupt_enable (void ) { -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;/* check with null intr_handle */ if (rte_intr_enable (NULL ) ==0 ) {
@@ -232,46 +277,52 @@ test_interrupt_enable(void) }/* check with invalid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable invalid intr_handle " "successfully\n" );return -1 ; }/* check with valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ; }/* check with specific valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_ALARM ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ; }/* check with specific valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ; }/* check with valid handler and its type */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ]; -if (rte_intr_enable (&test_intr_handle) <0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_CASE1 ); +if (rte_intr_enable (test_intr_handle) <0 ) {printf ("fail to enable interrupt on a simulated handler\n" );return -1 ; } - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_UIO ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ;
@@ -286,7 +337,7 @@ test_interrupt_enable(void)static int test_interrupt_disable (void ) { -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;/* check with null intr_handle */ if (rte_intr_disable (NULL ) ==0 ) {
@@ -296,46 +347,52 @@ test_interrupt_disable(void) }/* check with invalid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable invalid intr_handle " "successfully\n" );return -1 ; }/* check with valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ; }/* check with specific valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_ALARM ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ; }/* check with specific valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ; }/* check with valid handler and its type */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ]; -if (rte_intr_disable (&test_intr_handle) <0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_CASE1 ); +if (rte_intr_disable (test_intr_handle) <0 ) {printf ("fail to disable interrupt on a simulated handler\n" );return -1 ; } - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_UIO ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ;
@@ -351,13 +408,14 @@ static int test_interrupt_full_path_check(enum test_interrupt_handle_type intr_type) {int count; -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle; flag =0 ; - test_intr_handle = intr_handles[intr_type]; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, + intr_type); test_intr_type = intr_type; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <0 ) { +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) <0 ) {printf ("fail to register callback\n" );return -1 ; }
@@ -371,9 +429,9 @@ test_interrupt_full_path_check(enum test_interrupt_handle_type intr_type)rte_delay_ms (TEST_INTERRUPT_CHECK_INTERVAL );while ((count = -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, - &test_intr_handle)) <0 ) { + test_intr_handle)) <0 ) {if (count != -EAGAIN )return -1 ; }
@@ -396,7 +454,7 @@ static inttest_interrupt (void) {int ret =-1 ; -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;if (test_interrupt_init () <0 ) {printf ("fail to initialize for testing interrupt\n" );
@@ -444,17 +502,20 @@ test_interrupt(void) }/* check if it will fail to register cb with invalid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) ==0 ) {printf ("unexpectedly register successfully with invalid " "intr_handle\n" ); goto out; }/* check if it will fail to register without callback */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_callback_register (&test_intr_handle,NULL , &test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (rte_intr_callback_register (test_intr_handle,NULL , + test_intr_handle) ==0 ) {printf ("unexpectedly register successfully with " "null callback\n" ); goto out;
@@ -469,39 +530,41 @@ test_interrupt(void) }/* check if it will fail to unregister cb with invalid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_callback_unregister (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) >0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (rte_intr_callback_unregister (test_intr_handle, + test_interrupt_callback, test_intr_handle) >0 ) {printf ("unexpectedly unregister successfully with " "invalid intr_handle\n" ); goto out; }/* check if it is ok to register the same intr_handle twice */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) <0 ) {printf ("it fails to register test_interrupt_callback\n" ); goto out; } -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback_1, &test_intr_handle) <0 ) { +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback_1, test_intr_handle) <0 ) {printf ("it fails to register test_interrupt_callback_1\n" ); goto out; }/* check if it will fail to unregister with invalid parameter */ -if (rte_intr_callback_unregister (&test_intr_handle, +if (rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)0xff ) !=0 ) {printf ("unexpectedly unregisters successfully with " "invalid arg\n" ); goto out; } -if (rte_intr_callback_unregister (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <=0 ) { +if (rte_intr_callback_unregister (test_intr_handle, + test_interrupt_callback, test_intr_handle) <=0 ) {printf ("it fails to unregister test_interrupt_callback\n" ); goto out; } -if (rte_intr_callback_unregister (&test_intr_handle, +if (rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ) <=0 ) {printf ("it fails to unregister test_interrupt_callback_1 " "for all\n" );
@@ -528,28 +591,32 @@ test_interrupt(void) out:printf ("Clearing for interrupt tests\n" );/* clear registered callbacks */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -rte_intr_callback_unregister (&test_intr_handle, + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -rte_intr_callback_unregister (&test_intr_handle, + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_UIO ); +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -rte_intr_callback_unregister (&test_intr_handle, + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_ALARM ); +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -rte_intr_callback_unregister (&test_intr_handle, + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ); +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 );rte_delay_ms (2 *TEST_INTERRUPT_CHECK_INTERVAL );
Signature · 1 line
2.18.0
RFC 5/7 drivers: remove direct access to interrupt handle fields
In reply to Harman KalraRemoving direct access to interrupt handle structure fields, rather use respective get set APIs for the same. Making changes to all the drivers and libraries access the interrupt handle fields.
--- drivers/baseband/acc100/rte_acc100_pmd.c | 18 +-- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 13 +- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 14 ++- drivers/bus/auxiliary/auxiliary_common.c | 2 + drivers/bus/auxiliary/linux/auxiliary.c | 11 ++ drivers/bus/auxiliary/rte_bus_auxiliary.h | 2 +- drivers/bus/dpaa/dpaa_bus.c | 28 ++++- drivers/bus/dpaa/rte_dpaa_bus.h | 2 +- drivers/bus/fslmc/fslmc_bus.c | 17 ++- drivers/bus/fslmc/fslmc_vfio.c | 32 +++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 21 +++- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- drivers/bus/fslmc/rte_fslmc.h | 2 +- drivers/bus/ifpga/ifpga_bus.c | 16 ++- drivers/bus/ifpga/rte_bus_ifpga.h | 2 +- drivers/bus/pci/linux/pci.c | 4 +- drivers/bus/pci/linux/pci_uio.c | 73 +++++++---- drivers/bus/pci/linux/pci_vfio.c | 108 ++++++++++------ drivers/bus/pci/pci_common.c | 29 ++++- drivers/bus/pci/pci_common_uio.c | 21 ++-- drivers/bus/pci/rte_bus_pci.h | 4 +- drivers/bus/vmbus/linux/vmbus_bus.c | 7 ++ drivers/bus/vmbus/linux/vmbus_uio.c | 37 ++++-- drivers/bus/vmbus/rte_bus_vmbus.h | 2 +- drivers/bus/vmbus/vmbus_common_uio.c | 24 ++-- drivers/common/cnxk/roc_cpt.c | 8 +- drivers/common/cnxk/roc_dev.c | 14 +-- drivers/common/cnxk/roc_irq.c | 106 +++++++++------- drivers/common/cnxk/roc_nix_irq.c | 37 +++--- drivers/common/cnxk/roc_npa.c | 2 +- drivers/common/cnxk/roc_platform.h | 34 +++++ drivers/common/cnxk/roc_sso.c | 4 +- drivers/common/cnxk/roc_tim.c | 4 +- drivers/common/octeontx2/otx2_dev.c | 14 +-- drivers/common/octeontx2/otx2_irq.c | 117 ++++++++++-------- .../octeontx2/otx2_cryptodev_hw_access.c | 4 +- drivers/event/octeontx2/otx2_evdev_irq.c | 12 +- drivers/mempool/octeontx2/otx2_mempool.c | 2 +- drivers/net/atlantic/atl_ethdev.c | 22 ++-- drivers/net/avp/avp_ethdev.c | 8 +- drivers/net/axgbe/axgbe_ethdev.c | 12 +- drivers/net/axgbe/axgbe_mdio.c | 6 +- drivers/net/bnx2x/bnx2x_ethdev.c | 10 +- drivers/net/bnxt/bnxt_ethdev.c | 32 +++-- drivers/net/bnxt/bnxt_irq.c | 4 +- drivers/net/dpaa/dpaa_ethdev.c | 47 ++++--- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +- drivers/net/e1000/em_ethdev.c | 24 ++-- drivers/net/e1000/igb_ethdev.c | 84 ++++++------- drivers/net/ena/ena_ethdev.c | 36 +++--- drivers/net/enic/enic_main.c | 27 ++-- drivers/net/failsafe/failsafe.c | 24 +++- drivers/net/failsafe/failsafe_intr.c | 45 ++++--- drivers/net/failsafe/failsafe_ops.c | 23 +++- drivers/net/failsafe/failsafe_private.h | 2 +- drivers/net/fm10k/fm10k_ethdev.c | 32 ++--- drivers/net/hinic/hinic_pmd_ethdev.c | 10 +- drivers/net/hns3/hns3_ethdev.c | 50 ++++---- drivers/net/hns3/hns3_ethdev_vf.c | 57 +++++---- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/i40e/i40e_ethdev.c | 55 ++++---- drivers/net/i40e/i40e_ethdev_vf.c | 43 +++---- drivers/net/iavf/iavf_ethdev.c | 41 +++--- drivers/net/iavf/iavf_vchnl.c | 4 +- drivers/net/ice/ice_dcf.c | 10 +- drivers/net/ice/ice_dcf_ethdev.c | 23 ++-- drivers/net/ice/ice_ethdev.c | 51 ++++---- drivers/net/igc/igc_ethdev.c | 47 ++++--- drivers/net/ionic/ionic_ethdev.c | 12 +- drivers/net/ixgbe/ixgbe_ethdev.c | 70 +++++------ drivers/net/memif/memif_socket.c | 99 ++++++++++----- drivers/net/memif/memif_socket.h | 4 +- drivers/net/memif/rte_eth_memif.c | 63 ++++++++-- drivers/net/memif/rte_eth_memif.h | 2 +- drivers/net/mlx4/mlx4.c | 20 ++- drivers/net/mlx4/mlx4.h | 2 +- drivers/net/mlx4/mlx4_intr.c | 48 ++++--- drivers/net/mlx5/linux/mlx5_os.c | 56 ++++++--- drivers/net/mlx5/linux/mlx5_socket.c | 26 ++-- drivers/net/mlx5/mlx5.h | 6 +- drivers/net/mlx5/mlx5_rxq.c | 43 ++++--- drivers/net/mlx5/mlx5_trigger.c | 4 +- drivers/net/mlx5/mlx5_txpp.c | 27 ++-- drivers/net/netvsc/hn_ethdev.c | 4 +- drivers/net/nfp/nfp_net.c | 42 ++++--- drivers/net/ngbe/ngbe_ethdev.c | 31 +++-- drivers/net/octeontx2/otx2_ethdev_irq.c | 35 +++--- drivers/net/qede/qede_ethdev.c | 16 +-- drivers/net/sfc/sfc_intr.c | 29 ++--- drivers/net/tap/rte_eth_tap.c | 37 ++++-- drivers/net/tap/rte_eth_tap.h | 2 +- drivers/net/tap/tap_intr.c | 33 +++-- drivers/net/thunderx/nicvf_ethdev.c | 13 ++ drivers/net/thunderx/nicvf_struct.h | 2 +- drivers/net/txgbe/txgbe_ethdev.c | 36 +++--- drivers/net/txgbe/txgbe_ethdev_vf.c | 35 +++--- drivers/net/vhost/rte_eth_vhost.c | 78 +++++++----- drivers/net/virtio/virtio_ethdev.c | 17 +-- .../net/virtio/virtio_user/virtio_user_dev.c | 53 +++++--- drivers/net/vmxnet3/vmxnet3_ethdev.c | 45 ++++--- drivers/raw/ifpga/ifpga_rawdev.c | 42 +++++-- drivers/raw/ntb/ntb.c | 10 +- .../regex/octeontx2/otx2_regexdev_hw_access.c | 4 +- drivers/vdpa/ifc/ifcvf_vdpa.c | 5 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 11 ++ drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 22 ++-- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 46 ++++--- lib/bbdev/rte_bbdev.c | 4 +- lib/eal/freebsd/eal_alarm.c | 7 ++ lib/eal/include/rte_eal_trace.h | 24 +--- lib/eal/linux/eal_alarm.c | 31 +++-- lib/eal/linux/eal_dev.c | 65 ++++++---- lib/ethdev/ethdev_pci.h | 2 +- lib/ethdev/rte_ethdev.c | 14 +-- 115 files changed, 1808 insertions(+), 1163 deletions(-)
drivers/baseband/acc100/rte_acc100_pmd.c +11 -7
@@ -720,8 +720,10 @@ acc100_intr_enable(struct rte_bbdev *dev)struct acc100_device *d = dev->data->dev_private;/* Only MSI are currently supported */ -if (dev->intr_handle->type ==RTE_INTR_HANDLE_VFIO_MSI || - dev->intr_handle->type ==RTE_INTR_HANDLE_UIO ) { +if (rte_intr_handle_type_get (dev->intr_handle) == +RTE_INTR_HANDLE_VFIO_MSI || +rte_intr_handle_type_get (dev->intr_handle) == +RTE_INTR_HANDLE_UIO ) { ret =allocate_info_ring (dev);if (ret <0 ) {
@@ -1096,8 +1098,9 @@ acc100_queue_intr_enable(struct rte_bbdev *dev, uint16_t queue_id) {struct acc100_queue *q = dev->data->queues[queue_id].queue_private; -if (dev->intr_handle->type !=RTE_INTR_HANDLE_VFIO_MSI && - dev->intr_handle->type !=RTE_INTR_HANDLE_UIO ) +if (rte_intr_handle_type_get (dev->intr_handle) != +RTE_INTR_HANDLE_VFIO_MSI && +rte_intr_handle_type_get (dev->intr_handle) !=RTE_INTR_HANDLE_UIO )return -ENOTSUP ; q->irq_enable =1 ;
@@ -1109,8 +1112,9 @@ acc100_queue_intr_disable(struct rte_bbdev *dev, uint16_t queue_id) {struct acc100_queue *q = dev->data->queues[queue_id].queue_private; -if (dev->intr_handle->type !=RTE_INTR_HANDLE_VFIO_MSI && - dev->intr_handle->type !=RTE_INTR_HANDLE_UIO ) +if (rte_intr_handle_type_get (dev->intr_handle) != +RTE_INTR_HANDLE_VFIO_MSI && +rte_intr_handle_type_get (dev->intr_handle) !=RTE_INTR_HANDLE_UIO )return -ENOTSUP ; q->irq_enable =0 ;
@@ -4178,7 +4182,7 @@ static int acc100_pci_probe(struct rte_pci_driver *pci_drv,/* Fill HW specific part of device structure */ bbdev->device = &pci_dev->device; - bbdev->intr_handle = &pci_dev->intr_handle; + bbdev->intr_handle = pci_dev->intr_handle; bbdev->data->socket_id = pci_dev->device.numa_node;/* Invoke ACC100 device initialization function */
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +7 -6
@@ -743,12 +743,13 @@ fpga_intr_enable(struct rte_bbdev *dev)* invoked when any FPGA queue issues interrupt. */ for (i =0 ; i <FPGA_NUM_INTR_VEC ; ++i) - dev->intr_handle->efds[i] = dev->intr_handle->fd; +if (rte_intr_handle_efds_index_set (dev->intr_handle, i, +rte_intr_handle_fd_get (dev->intr_handle))) +return -rte_errno; -if (!dev->intr_handle->intr_vec) { - dev->intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->num_queues *sizeof (int ),0 ); -if (!dev->intr_handle->intr_vec) { +if (!rte_intr_handle_vec_list_base (dev->intr_handle)) { +if (rte_intr_handle_vec_list_alloc (dev->intr_handle,"intr_vec" , + dev->data->num_queues)) {rte_bbdev_log (ERR ,"Failed to allocate %u vectors" , dev->data->num_queues);return -ENOMEM ;
@@ -1879,7 +1880,7 @@ fpga_5gnr_fec_probe(struct rte_pci_driver *pci_drv,/* Fill HW specific part of device structure */ bbdev->device = &pci_dev->device; - bbdev->intr_handle = &pci_dev->intr_handle; + bbdev->intr_handle = pci_dev->intr_handle; bbdev->data->socket_id = pci_dev->device.numa_node;/* Invoke FEC FPGA device initialization function */
drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +8 -6
@@ -1014,18 +1014,20 @@ fpga_intr_enable(struct rte_bbdev *dev)* invoked when any FPGA queue issues interrupt. */ for (i =0 ; i <FPGA_NUM_INTR_VEC ; ++i) - dev->intr_handle->efds[i] = dev->intr_handle->fd; +if (rte_intr_handle_efds_index_set (dev->intr_handle, i, +rte_intr_handle_fd_get (dev->intr_handle))) +return -rte_errno; -if (!dev->intr_handle->intr_vec) { - dev->intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->num_queues *sizeof (int ),0 ); -if (!dev->intr_handle->intr_vec) { +if (!rte_intr_handle_vec_list_base (dev->intr_handle)) { +if (rte_intr_handle_vec_list_alloc (dev->intr_handle,"intr_vec" , + dev->data->num_queues)) {rte_bbdev_log (ERR ,"Failed to allocate %u vectors" , dev->data->num_queues);return -ENOMEM ; } } + ret =rte_intr_enable (dev->intr_handle);if (ret <0 ) { rte_bbdev_log(ERR,
@@ -2369,7 +2371,7 @@ fpga_lte_fec_probe(struct rte_pci_driver *pci_drv,/* Fill HW specific part of device structure */ bbdev->device = &pci_dev->device; - bbdev->intr_handle = &pci_dev->intr_handle; + bbdev->intr_handle = pci_dev->intr_handle; bbdev->data->socket_id = pci_dev->device.numa_node;/* Invoke FEC FPGA device initialization function */
drivers/bus/auxiliary/auxiliary_common.c +2 -0
@@ -320,6 +320,8 @@ auxiliary_unplug(struct rte_device *dev)if (ret ==0 ) {rte_auxiliary_remove_device (adev);rte_devargs_remove (dev->devargs); +if (adev->intr_handle) +rte_intr_handle_instance_free (adev->intr_handle);free (adev); }return ret;
drivers/bus/auxiliary/linux/auxiliary.c +11 -0
@@ -39,6 +39,15 @@ auxiliary_scan_one(const char *dirname, const char *name) dev->device.name = dev->name; dev->device.bus = &auxiliary_bus.bus; +/* Allocate interrupt instance */ + dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!dev->intr_handle) { +free (dev); +return -1 ; + } +/* Get NUMA node, default to 0 if not present */ snprintf (filename,sizeof (filename),"%s/%s/numa_node" , dirname, name);
@@ -67,6 +76,8 @@ auxiliary_scan_one(const char *dirname, const char *name)rte_devargs_remove (dev2->device.devargs);auxiliary_on_scan (dev2); } +if (dev->intr_handle) +rte_intr_handle_instance_free (dev->intr_handle);free (dev); }return 0 ;
drivers/bus/auxiliary/rte_bus_auxiliary.h +1 -1
@@ -116,7 +116,7 @@ struct rte_auxiliary_device {TAILQ_ENTRY (rte_auxiliary_device) next;/**< Next probed device. */ struct rte_device device;/**< Inherit core device */ char name[RTE_DEV_NAME_MAX_LEN +1 ];/**< ASCII device name */ -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_auxiliary_driver *driver;/**< Device driver */ };
drivers/bus/dpaa/dpaa_bus.c +25 -3
@@ -172,6 +172,15 @@ dpaa_create_device_list(void) dev->device.bus = &rte_dpaa_bus.bus; +/* Allocate interrupt handle instance */ + dev->intr_handle =rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (!dev->intr_handle) { +DPAA_BUS_LOG (ERR ,"Failed to allocate intr handle" ); + ret = -ENOMEM ; + goto cleanup; + } + cfg = &dpaa_netcfg->port_cfg[i]; fman_intf = cfg->fman_if;
@@ -214,6 +223,15 @@ dpaa_create_device_list(void) goto cleanup; } +/* Allocate interrupt handle instance */ + dev->intr_handle =rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (!dev->intr_handle) { +DPAA_BUS_LOG (ERR ,"Failed to allocate intr handle" ); + ret = -ENOMEM ; + goto cleanup; + } + dev->device_type =FSL_DPAA_CRYPTO ; dev->id.dev_id = rte_dpaa_bus.device_count + i;
@@ -247,6 +265,7 @@ dpaa_clean_device_list(void) TAILQ_FOREACH_SAFE(dev, &rte_dpaa_bus.device_list, next, tdev) {TAILQ_REMOVE (&rte_dpaa_bus.device_list, dev, next); +rte_intr_handle_instance_free (dev->intr_handle);free (dev); dev =NULL ; }
@@ -559,8 +578,11 @@ static int rte_dpaa_setup_intr(struct rte_intr_handle *intr_handle)return errno; } - intr_handle->fd = fd; - intr_handle->type =RTE_INTR_HANDLE_EXT ; +if (rte_intr_handle_fd_set (intr_handle, fd)) +return -rte_errno; + +if (rte_intr_handle_type_set (intr_handle,RTE_INTR_HANDLE_EXT )) +return -rte_errno;return 0 ; }
@@ -612,7 +634,7 @@ rte_dpaa_bus_probe(void) TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) {if (dev->device_type ==FSL_DPAA_ETH ) { - ret =rte_dpaa_setup_intr (&dev->intr_handle); + ret =rte_dpaa_setup_intr (dev->intr_handle);if (ret)DPAA_BUS_ERR ("Error setting up interrupt.\n" ); }
drivers/bus/dpaa/rte_dpaa_bus.h +1 -1
@@ -101,7 +101,7 @@ struct rte_dpaa_device { };struct rte_dpaa_driver *driver;struct dpaa_device_id id; -struct rte_intr_handle intr_handle; +struct rte_intr_handle *intr_handle;enum rte_dpaa_type device_type;/**< Ethernet or crypto type device */ char name[RTE_ETH_NAME_MAX_LEN ]; };
drivers/bus/fslmc/fslmc_bus.c +16 -1
@@ -47,6 +47,8 @@ cleanup_fslmc_device_list(void) TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, t_dev) {TAILQ_REMOVE (&rte_fslmc_bus.device_list, dev, next); +if (dev->intr_handle) +rte_intr_handle_instance_free (dev->intr_handle);free (dev); dev =NULL ; }
@@ -160,6 +162,16 @@ scan_one_fslmc_device(char *dev_name) dev->device.bus = &rte_fslmc_bus.bus; +/* Allocate interrupt instance */ + dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!dev->intr_handle) { +DPAA2_BUS_ERR ("Failed to allocate intr handle" ); + ret = -ENOMEM ; + goto cleanup; + } +/* Parse the device name and ID */ t_ptr =strtok (dup_dev_name,"." );if (!t_ptr) {
@@ -220,8 +232,11 @@ scan_one_fslmc_device(char *dev_name) cleanup:if (dup_dev_name)free (dup_dev_name); -if (dev) +if (dev) { +if (dev->intr_handle) +rte_intr_handle_instance_free (dev->intr_handle);free (dev); + }return ret; }
drivers/bus/fslmc/fslmc_vfio.c +21 -11
@@ -599,7 +599,7 @@ int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index)int len, ret;char irq_set_buf[IRQ_SET_BUF_LEN ];struct vfio_irq_set *irq_set; -int *fd_ptr; +int *fd_ptr, vfio_dev_fd; len =sizeof (irq_set_buf);
@@ -611,12 +611,14 @@ int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index) irq_set->index = index; irq_set->start =0 ; fd_ptr = (int *)&irq_set->data; - *fd_ptr = intr_handle->fd; + *fd_ptr =rte_intr_handle_fd_get (intr_handle); - ret =ioctl (intr_handle->vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set); + vfio_dev_fd =rte_intr_handle_dev_fd_get (intr_handle); + ret =ioctl (vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set);if (ret) {DPAA2_BUS_ERR ("Error:dpaa2 SET IRQs fd=%d, err = %d(%s)" , - intr_handle->fd, errno,strerror (errno)); +rte_intr_handle_fd_get (intr_handle), errno, +strerror (errno));return ret; }
@@ -627,7 +629,7 @@ int rte_dpaa2_intr_disable(struct rte_intr_handle *intr_handle, int index) {struct vfio_irq_set *irq_set;char irq_set_buf[IRQ_SET_BUF_LEN ]; -int len, ret; +int len, ret, vfio_dev_fd; len =sizeof (struct vfio_irq_set );
@@ -638,11 +640,12 @@ int rte_dpaa2_intr_disable(struct rte_intr_handle *intr_handle, int index) irq_set->start =0 ; irq_set->count =0 ; - ret =ioctl (intr_handle->vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set); + vfio_dev_fd =rte_intr_handle_dev_fd_get (intr_handle); + ret =ioctl (vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set);if (ret)DPAA2_BUS_ERR ("Error disabling dpaa2 interrupts for fd %d" , - intr_handle->fd); +rte_intr_handle_fd_get (intr_handle));return ret; }
@@ -684,9 +687,16 @@ rte_dpaa2_vfio_setup_intr(struct rte_intr_handle *intr_handle,return -1 ; } - intr_handle->fd = fd; - intr_handle->type =RTE_INTR_HANDLE_VFIO_MSI ; - intr_handle->vfio_dev_fd = vfio_dev_fd; +if (rte_intr_handle_fd_set (intr_handle, fd)) +return -rte_errno; + +if (rte_intr_handle_type_set (intr_handle, +RTE_INTR_HANDLE_VFIO_MSI )) +return -rte_errno; + +if (rte_intr_handle_dev_fd_set (intr_handle, vfio_dev_fd)) +return -rte_errno; +return 0 ; }
@@ -711,7 +721,7 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev)switch (dev->dev_type) {case DPAA2_ETH : -rte_dpaa2_vfio_setup_intr (&dev->intr_handle, dev_fd, +rte_dpaa2_vfio_setup_intr (dev->intr_handle, dev_fd, device_info.num_irqs);break ;case DPAA2_CON :
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +17 -4
@@ -176,7 +176,7 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)int threshold =0x3 , timeout =0xFF ; dpio_epoll_fd =epoll_create (1 ); - ret =rte_dpaa2_intr_enable (&dpio_dev->intr_handle,0 ); + ret =rte_dpaa2_intr_enable (dpio_dev->intr_handle,0 );if (ret) {DPAA2_BUS_ERR ("Interrupt registeration failed" );return -1 ;
@@ -195,7 +195,7 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)qbman_swp_dqrr_thrshld_write (dpio_dev->sw_portal, threshold);qbman_swp_intr_timeout_write (dpio_dev->sw_portal, timeout); - eventfd = dpio_dev->intr_handle.fd; + eventfd =rte_intr_handle_fd_get (dpio_dev->intr_handle); epoll_ev.events =EPOLLIN |EPOLLPRI |EPOLLET ; epoll_ev.data.fd = eventfd;
@@ -213,7 +213,7 @@ static void dpaa2_dpio_intr_deinit(struct dpaa2_dpio_dev *dpio_dev) {int ret; - ret =rte_dpaa2_intr_disable (&dpio_dev->intr_handle,0 ); + ret =rte_dpaa2_intr_disable (dpio_dev->intr_handle,0 );if (ret)DPAA2_BUS_ERR ("DPIO interrupt disable failed" );
@@ -388,6 +388,15 @@ dpaa2_create_dpio_device(int vdev_fd,/* Using single portal for all devices */ dpio_dev->mc_portal =dpaa2_get_mcp_ptr (MC_PORTAL_INDEX ); +/* Allocate interrupt instance */ + dpio_dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + true); +if (!dpio_dev->intr_handle) { +DPAA2_BUS_ERR ("Failed to allocate intr handle" ); + goto err; + } + dpio_dev->dpio =rte_zmalloc (NULL ,sizeof (struct fsl_mc_io ),RTE_CACHE_LINE_SIZE );if (!dpio_dev->dpio) {
@@ -490,7 +499,7 @@ dpaa2_create_dpio_device(int vdev_fd, io_space_count++; dpio_dev->index = io_space_count; -if (rte_dpaa2_vfio_setup_intr (&dpio_dev->intr_handle, vdev_fd,1 )) { +if (rte_dpaa2_vfio_setup_intr (dpio_dev->intr_handle, vdev_fd,1 )) {DPAA2_BUS_ERR ("Fail to setup interrupt for %d" , dpio_dev->hw_id); goto err;
@@ -538,6 +547,8 @@ dpaa2_create_dpio_device(int vdev_fd,rte_free (dpio_dev->dpio); } +if (dpio_dev->intr_handle) +rte_intr_handle_instance_free (dpio_dev->intr_handle);rte_free (dpio_dev);/* For each element in the list, cleanup */
@@ -549,6 +560,8 @@ dpaa2_create_dpio_device(int vdev_fd, dpio_dev->token);rte_free (dpio_dev->dpio); } +if (dpio_dev->intr_handle) +rte_intr_handle_instance_free (dpio_dev->intr_handle);rte_free (dpio_dev); }
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -1
@@ -116,7 +116,7 @@ struct dpaa2_dpio_dev {uintptr_t qbman_portal_ci_paddr;/**< Physical address of Cache Inhibit Area */ uintptr_t ci_size;/**< Size of the CI region */ -struct rte_intr_handle intr_handle;/* Interrupt related info */ +struct rte_intr_handle *intr_handle;/* Interrupt related info */ int32_t epoll_fd;/**< File descriptor created for interrupt polling */ int32_t hw_id;/**< An unique ID of this DPIO device instance */ struct dpaa2_portal_dqrr dpaa2_held_bufs;
drivers/bus/fslmc/rte_fslmc.h +1 -1
@@ -125,7 +125,7 @@ struct rte_dpaa2_device { };enum rte_dpaa2_dev_type dev_type;/**< Device Type */ uint16_t object_id;/**< DPAA2 Object ID */ -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_dpaa2_driver *driver;/**< Associated driver */ char name[FSLMC_OBJECT_MAX_LEN ];/**< DPAA2 Object name*/ };
drivers/bus/ifpga/ifpga_bus.c +15 -1
@@ -161,6 +161,15 @@ ifpga_scan_one(struct rte_rawdev *rawdev, afu_dev->id.uuid.uuid_high =0 ; afu_dev->id.port = afu_pr_conf.afu_id.port; +/* Allocate interrupt instance */ + afu_dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!afu_dev->intr_handle) { +IFPGA_BUS_ERR ("Failed to allocate intr handle" ); + goto end; + } +if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get) rawdev->dev_ops->dev_info_get (rawdev, afu_dev,sizeof (*afu_dev));
@@ -189,8 +198,11 @@ ifpga_scan_one(struct rte_rawdev *rawdev,rte_kvargs_free (kvlist);if (path)free (path); -if (afu_dev) +if (afu_dev) { +if (afu_dev->intr_handle) +rte_intr_handle_instance_free (afu_dev->intr_handle);free (afu_dev); + }return NULL ; }
@@ -396,6 +408,8 @@ ifpga_unplug(struct rte_device *dev)TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next);rte_devargs_remove (dev->devargs); +if (afu_dev->intr_handle) +rte_intr_handle_instance_free (afu_dev->intr_handle);free (afu_dev);return 0 ;
drivers/bus/ifpga/rte_bus_ifpga.h +1 -1
@@ -79,7 +79,7 @@ struct rte_afu_device {struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ];/**< AFU Memory Resource */ struct rte_afu_shared shared; -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_afu_driver *driver;/**< Associated driver */ char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; } __rte_packed;
drivers/bus/pci/linux/pci.c +2 -2
@@ -645,7 +645,7 @@ int rte_pci_read_config(const struct rte_pci_device *device, void *buf, size_t len, off_t offset) { char devname[RTE_DEV_NAME_MAX_LEN] = ""; -const struct rte_intr_handle *intr_handle = &device->intr_handle; +const struct rte_intr_handle *intr_handle = device->intr_handle;switch (device->kdrv) {case RTE_PCI_KDRV_IGB_UIO :
@@ -669,7 +669,7 @@ int rte_pci_write_config(const struct rte_pci_device *device, const void *buf, size_t len, off_t offset) { char devname[RTE_DEV_NAME_MAX_LEN] = ""; -const struct rte_intr_handle *intr_handle = &device->intr_handle; +const struct rte_intr_handle *intr_handle = device->intr_handle;switch (device->kdrv) {case RTE_PCI_KDRV_IGB_UIO :
drivers/bus/pci/linux/pci_uio.c +49 -24
142 lines not on this page · raw message
drivers/bus/pci/linux/pci_vfio.c +70 -38
245 lines not on this page · raw message
drivers/bus/pci/pci_common.c +27 -2
@@ -230,6 +230,24 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, }if (!already_probed && (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING )) { +/* Allocate interrupt instance for pci device */ + dev->intr_handle =rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (!dev->intr_handle) { +RTE_LOG (ERR ,EAL , +"Failed to create interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + } + + dev->vfio_req_intr_handle =rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (!dev->vfio_req_intr_handle) { +RTE_LOG (ERR ,EAL , +"Failed to create vfio req interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + }/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) {
@@ -253,8 +271,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver needs mapped resources. */ !(ret > 0 && - (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES))) + (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES))) {rte_pci_unmap_device (dev); +rte_intr_handle_instance_free (dev->intr_handle); +rte_intr_handle_instance_free ( + dev->vfio_req_intr_handle); + } }else { dev->device.driver = &dr->driver; }
@@ -296,9 +318,12 @@ rte_pci_detach_dev(struct rte_pci_device *dev) dev->driver =NULL ; dev->device.driver =NULL ; -if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) +if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) {/* unmap resources for devices that use igb_uio */ rte_pci_unmap_device (dev); +rte_intr_handle_instance_free (dev->intr_handle); +rte_intr_handle_instance_free (dev->vfio_req_intr_handle); + }return 0 ; }
drivers/bus/pci/pci_common_uio.c +13 -8
@@ -90,8 +90,11 @@ pci_uio_map_resource(struct rte_pci_device *dev)struct mapped_pci_res_list *uio_res_list =RTE_TAILQ_CAST (rte_uio_tailq.head, mapped_pci_res_list); - dev->intr_handle.fd =-1 ; - dev->intr_handle.uio_cfg_fd =-1 ; +if (rte_intr_handle_fd_set (dev->intr_handle,-1 )) +return -1 ; + +if (rte_intr_handle_dev_fd_set (dev->intr_handle,-1 )) +return -1 ;/* secondary processes - use already recorded details */ if (rte_eal_process_type () !=RTE_PROC_PRIMARY )
@@ -207,6 +210,7 @@ pci_uio_unmap_resource(struct rte_pci_device *dev)struct mapped_pci_resource *uio_res;struct mapped_pci_res_list *uio_res_list =RTE_TAILQ_CAST (rte_uio_tailq.head, mapped_pci_res_list); +int uio_cfg_fd;if (dev ==NULL )return ;
@@ -229,12 +233,13 @@ pci_uio_unmap_resource(struct rte_pci_device *dev)rte_free (uio_res);/* close fd if in primary process */ -close (dev->intr_handle.fd); -if (dev->intr_handle.uio_cfg_fd >=0 ) { -close (dev->intr_handle.uio_cfg_fd); - dev->intr_handle.uio_cfg_fd =-1 ; +close (rte_intr_handle_fd_get (dev->intr_handle)); + uio_cfg_fd =rte_intr_handle_dev_fd_get (dev->intr_handle); +if (uio_cfg_fd >=0 ) { +close (uio_cfg_fd); +rte_intr_handle_dev_fd_set (dev->intr_handle,-1 ); } - dev->intr_handle.fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +rte_intr_handle_fd_set (dev->intr_handle,-1 ); +rte_intr_handle_type_set (dev->intr_handle,RTE_INTR_HANDLE_UNKNOWN ); }
drivers/bus/pci/rte_bus_pci.h +2 -2
@@ -70,12 +70,12 @@ struct rte_pci_device {struct rte_pci_id id;/**< PCI ID. */ struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ];/**< PCI Memory Resource */ -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_pci_driver *driver;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_pci_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */ -struct rte_intr_handle vfio_req_intr_handle; +struct rte_intr_handle *vfio_req_intr_handle;/**< Handler of VFIO request interrupt */ };
drivers/bus/vmbus/linux/vmbus_bus.c +7 -0
@@ -297,6 +297,13 @@ vmbus_scan_one(const char *name) dev->device.devargs =vmbus_devargs_lookup (dev); +/* Allocate interrupt handle instance */ + dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!dev->intr_handle) + goto error; +/* device is valid, add in list (sorted) */ VMBUS_LOG (DEBUG ,"Adding vmbus device %s" , name);
drivers/bus/vmbus/linux/vmbus_uio.c +24 -13
@@ -29,9 +29,11 @@ static void *vmbus_map_addr;/* Control interrupts */ void vmbus_uio_irq_control (struct rte_vmbus_device *dev,int32_t onoff) { -if (write (dev->intr_handle.fd, &onoff,sizeof (onoff)) <0 ) { +if (write (rte_intr_handle_fd_get (dev->intr_handle), &onoff, +sizeof (onoff)) <0 ) {VMBUS_LOG (ERR ,"cannot write to %d:%s" , - dev->intr_handle.fd,strerror (errno)); +rte_intr_handle_fd_get (dev->intr_handle), +strerror (errno)); } }
@@ -40,7 +42,8 @@ int vmbus_uio_irq_read(struct rte_vmbus_device *dev)int32_t count;int cc; - cc =read (dev->intr_handle.fd, &count,sizeof (count)); + cc =read (rte_intr_handle_fd_get (dev->intr_handle), &count, +sizeof (count));if (cc < (int )sizeof (count)) {if (cc <0 ) { VMBUS_LOG(ERR, "IRQ read failed %s",
@@ -60,15 +63,16 @@ vmbus_uio_free_resource(struct rte_vmbus_device *dev, {rte_free (uio_res); -if (dev->intr_handle.uio_cfg_fd >=0 ) { -close (dev->intr_handle.uio_cfg_fd); - dev->intr_handle.uio_cfg_fd =-1 ; +if (rte_intr_handle_dev_fd_get (dev->intr_handle) >=0 ) { +close (rte_intr_handle_dev_fd_get (dev->intr_handle)); +rte_intr_handle_dev_fd_set (dev->intr_handle,-1 ); } -if (dev->intr_handle.fd >=0 ) { -close (dev->intr_handle.fd); - dev->intr_handle.fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +if (rte_intr_handle_fd_get (dev->intr_handle) >=0 ) { +close (rte_intr_handle_fd_get (dev->intr_handle)); +rte_intr_handle_fd_set (dev->intr_handle,-1 ); +rte_intr_handle_type_set (dev->intr_handle, +RTE_INTR_HANDLE_UNKNOWN ); } }
@@ -77,16 +81,23 @@ vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, struct mapped_vmbus_resource **uio_res) {char devname[PATH_MAX ];/* contains the /dev/uioX */ +int fd;/* save fd if in primary process */ snprintf (devname,sizeof (devname),"/dev/uio%u" , dev->uio_num); - dev->intr_handle.fd =open (devname,O_RDWR ); -if (dev->intr_handle.fd <0 ) { + fd =open (devname,O_RDWR ); +if (fd <0 ) {VMBUS_LOG (ERR ,"Cannot open %s: %s" , devname,strerror (errno)); goto error; } - dev->intr_handle.type =RTE_INTR_HANDLE_UIO_INTX ; + +if (rte_intr_handle_fd_set (dev->intr_handle, fd)) + goto error; + +if (rte_intr_handle_type_set (dev->intr_handle, +RTE_INTR_HANDLE_UIO_INTX )) + goto error;/* allocate the mapping details for secondary processes*/ *uio_res =rte_zmalloc ("UIO_RES" ,sizeof (**uio_res),0 );
drivers/bus/vmbus/rte_bus_vmbus.h +1 -1
@@ -74,7 +74,7 @@ struct rte_vmbus_device {struct vmbus_channel *primary;/**< VMBUS primary channel */ struct vmbus_mon_page *monitor_page;/**< VMBUS monitor page */ -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_mem_resource resource[VMBUS_MAX_RESOURCE ]; };
drivers/bus/vmbus/vmbus_common_uio.c +15 -9
@@ -149,9 +149,15 @@ vmbus_uio_map_resource(struct rte_vmbus_device *dev)int ret;/* TODO: handle rescind */ - dev->intr_handle.fd =-1 ; - dev->intr_handle.uio_cfg_fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +if (rte_intr_handle_fd_set (dev->intr_handle,-1 )) +return -1 ; + +if (rte_intr_handle_dev_fd_set (dev->intr_handle,-1 )) +return -1 ; + +if (rte_intr_handle_type_set (dev->intr_handle, +RTE_INTR_HANDLE_UNKNOWN )) +return -1 ;/* secondary processes - use already recorded details */ if (rte_eal_process_type () !=RTE_PROC_PRIMARY )
@@ -223,12 +229,12 @@ vmbus_uio_unmap_resource(struct rte_vmbus_device *dev)rte_free (uio_res);/* close fd if in primary process */ -close (dev->intr_handle.fd); -if (dev->intr_handle.uio_cfg_fd >=0 ) { -close (dev->intr_handle.uio_cfg_fd); - dev->intr_handle.uio_cfg_fd =-1 ; +close (rte_intr_handle_fd_get (dev->intr_handle)); +if (rte_intr_handle_dev_fd_get (dev->intr_handle) >=0 ) { +close (rte_intr_handle_dev_fd_get (dev->intr_handle)); +rte_intr_handle_dev_fd_set (dev->intr_handle,-1 ); } - dev->intr_handle.fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +rte_intr_handle_fd_set (dev->intr_handle,-1 ); +rte_intr_handle_type_set (dev->intr_handle,RTE_INTR_HANDLE_UNKNOWN ); }
drivers/common/cnxk/roc_cpt.c +4 -4
@@ -62,7 +62,7 @@ cpt_lf_register_misc_irq(struct roc_cpt_lf *lf)struct plt_intr_handle *handle;int rc, vec; - handle = &pci_dev->intr_handle; + handle = pci_dev->intr_handle; vec = lf->msixoff +CPT_LF_INT_VEC_MISC ;/* Clear err interrupt */
@@ -82,7 +82,7 @@ cpt_lf_unregister_misc_irq(struct roc_cpt_lf *lf)struct plt_intr_handle *handle;int vec; - handle = &pci_dev->intr_handle; + handle = pci_dev->intr_handle; vec = lf->msixoff +CPT_LF_INT_VEC_MISC ;/* Clear err interrupt */
@@ -126,7 +126,7 @@ cpt_lf_register_done_irq(struct roc_cpt_lf *lf)struct plt_intr_handle *handle;int rc, vec; - handle = &pci_dev->intr_handle; + handle = pci_dev->intr_handle; vec = lf->msixoff +CPT_LF_INT_VEC_DONE ;
@@ -149,7 +149,7 @@ cpt_lf_unregister_done_irq(struct roc_cpt_lf *lf)struct plt_intr_handle *handle;int vec; - handle = &pci_dev->intr_handle; + handle = pci_dev->intr_handle; vec = lf->msixoff +CPT_LF_INT_VEC_DONE ;
drivers/common/cnxk/roc_dev.c +7 -7
@@ -608,7 +608,7 @@ roc_af_pf_mbox_irq(void *param)static int mbox_register_pf_irq (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;int i, rc;/* HW clear irq */
@@ -658,7 +658,7 @@ mbox_register_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev)static int mbox_register_vf_irq (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;int rc;/* Clear irq */
@@ -691,7 +691,7 @@ mbox_register_irq(struct plt_pci_device *pci_dev, struct dev *dev)static void mbox_unregister_pf_irq (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;int i;/* HW clear irq */
@@ -722,7 +722,7 @@ mbox_unregister_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev)static void mbox_unregister_vf_irq (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;/* Clear irq */ plt_write64 (~0ull , dev->bar2 +RVU_VF_INT_ENA_W1C );
@@ -806,7 +806,7 @@ roc_pf_vf_flr_irq(void *param)static int vf_flr_unregister_irqs (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;int i;plt_base_dbg ("Unregister VF FLR interrupts for %s" , pci_dev->name);
@@ -827,7 +827,7 @@ vf_flr_unregister_irqs(struct plt_pci_device *pci_dev, struct dev *dev)static int vf_flr_register_irqs (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *handle = &pci_dev->intr_handle; +struct plt_intr_handle *handle = pci_dev->intr_handle;int i, rc;plt_base_dbg ("Register VF FLR interrupts for %s" , pci_dev->name);
@@ -1143,7 +1143,7 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)int dev_fini (struct dev *dev,struct plt_pci_device *pci_dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;struct mbox *mbox;/* Check if this dev hosts npalf and has 1+ refs */
drivers/common/cnxk/roc_irq.c +63 -43
219 lines not on this page · raw message
drivers/common/cnxk/roc_nix_irq.c +21 -16
@@ -82,7 +82,7 @@ nix_lf_err_irq(void *param)static int nix_lf_register_err_irq (struct nix *nix) { -struct plt_intr_handle *handle = &nix->pci_dev->intr_handle; +struct plt_intr_handle *handle = nix->pci_dev->intr_handle;int rc, vec; vec = nix->msixoff +NIX_LF_INT_VEC_ERR_INT ;
@@ -99,7 +99,7 @@ nix_lf_register_err_irq(struct nix *nix)static void nix_lf_unregister_err_irq (struct nix *nix) { -struct plt_intr_handle *handle = &nix->pci_dev->intr_handle; +struct plt_intr_handle *handle = nix->pci_dev->intr_handle;int vec; vec = nix->msixoff +NIX_LF_INT_VEC_ERR_INT ;
@@ -131,7 +131,7 @@ nix_lf_ras_irq(void *param)static int nix_lf_register_ras_irq (struct nix *nix) { -struct plt_intr_handle *handle = &nix->pci_dev->intr_handle; +struct plt_intr_handle *handle = nix->pci_dev->intr_handle;int rc, vec; vec = nix->msixoff +NIX_LF_INT_VEC_POISON ;
@@ -148,7 +148,7 @@ nix_lf_register_ras_irq(struct nix *nix)static void nix_lf_unregister_ras_irq (struct nix *nix) { -struct plt_intr_handle *handle = &nix->pci_dev->intr_handle; +struct plt_intr_handle *handle = nix->pci_dev->intr_handle;int vec; vec = nix->msixoff +NIX_LF_INT_VEC_POISON ;
@@ -300,7 +300,7 @@ roc_nix_register_queue_irqs(struct roc_nix *roc_nix)struct nix *nix; nix =roc_nix_to_nix_priv (roc_nix); - handle = &nix->pci_dev->intr_handle; + handle = nix->pci_dev->intr_handle;/* Figure out max qintx required */ rqs =PLT_MIN (nix->qints, nix->nb_rx_queues);
@@ -352,7 +352,7 @@ roc_nix_unregister_queue_irqs(struct roc_nix *roc_nix)int vec, q; nix =roc_nix_to_nix_priv (roc_nix); - handle = &nix->pci_dev->intr_handle; + handle = nix->pci_dev->intr_handle;for (q =0 ; q < nix->configured_qints; q++) { vec = nix->msixoff +NIX_LF_INT_VEC_QINT_START + q;
@@ -382,7 +382,7 @@ roc_nix_register_cq_irqs(struct roc_nix *roc_nix)struct nix *nix; nix =roc_nix_to_nix_priv (roc_nix); - handle = &nix->pci_dev->intr_handle; + handle = nix->pci_dev->intr_handle; nix->configured_cints =PLT_MIN (nix->cints, nix->nb_rx_queues);
@@ -414,19 +414,21 @@ roc_nix_register_cq_irqs(struct roc_nix *roc_nix)return rc; } -if (!handle->intr_vec) { - handle->intr_vec =plt_zmalloc ( - nix->configured_cints *sizeof (int ),0 ); -if (!handle->intr_vec) { -plt_err ("Failed to allocate %d rx intr_vec" , - nix->configured_cints); -return -ENOMEM ; +if (!plt_intr_handle_vec_list_base (handle)) { + rc =plt_intr_handle_vec_list_alloc (handle,"cnxk" , + nix->configured_cints); +if (rc) { +plt_err ("Fail to allocate intr vec list, rc=%d" , + rc); +return rc; } }/* VFIO vector zero is resereved for misc interrupt so * doing required adjustment. (b13bfab4cd) */ - handle->intr_vec[q] =PLT_INTR_VEC_RXTX_OFFSET + vec; +if (plt_intr_handle_vec_list_index_set (handle, q, +PLT_INTR_VEC_RXTX_OFFSET + vec)) +return -1 ;/* Configure CQE interrupt coalescing parameters */ plt_write64(((CQ_CQE_THRESH_DEFAULT) |
@@ -450,7 +452,7 @@ roc_nix_unregister_cq_irqs(struct roc_nix *roc_nix)int vec, q; nix =roc_nix_to_nix_priv (roc_nix); - handle = &nix->pci_dev->intr_handle; + handle = nix->pci_dev->intr_handle;for (q =0 ; q < nix->configured_cints; q++) { vec = nix->msixoff +NIX_LF_INT_VEC_CINT_START + q;
@@ -465,6 +467,9 @@ roc_nix_unregister_cq_irqs(struct roc_nix *roc_nix)dev_irq_unregister (handle, nix_lf_cq_irq, &nix->cints_mem[q], vec); } + +if (plt_intr_handle_vec_list_base (handle)) +plt_intr_handle_vec_list_free (handle);plt_free (nix->cints_mem); }
drivers/common/cnxk/roc_npa.c +1 -1
@@ -710,7 +710,7 @@ npa_lf_init(struct dev *dev, struct plt_pci_device *pci_dev) lf->pf_func = dev->pf_func; lf->npa_msixoff = npa_msixoff; - lf->intr_handle = &pci_dev->intr_handle; + lf->intr_handle = pci_dev->intr_handle; lf->pci_dev = pci_dev; idev->npa_pf_func = dev->pf_func;
drivers/common/cnxk/roc_platform.h +34 -0
@@ -101,6 +101,40 @@#define plt_thread_is_intr rte_thread_is_intr#define plt_intr_callback_fn rte_intr_callback_fn +#define plt_intr_handle_efd_counter_size_get \ + rte_intr_handle_efd_counter_size_get +#define plt_intr_handle_efd_counter_size_set \ + rte_intr_handle_efd_counter_size_set +#define plt_intr_handle_vec_list_index_get rte_intr_handle_vec_list_index_get +#define plt_intr_handle_vec_list_index_set rte_intr_handle_vec_list_index_set +#define plt_intr_handle_vec_list_base rte_intr_handle_vec_list_base +#define plt_intr_handle_vec_list_alloc rte_intr_handle_vec_list_alloc +#define plt_intr_handle_vec_list_free rte_intr_handle_vec_list_free +#define plt_intr_handle_vec_list_base rte_intr_handle_vec_list_base +#define plt_intr_handle_vec_list_base rte_intr_handle_vec_list_base +#define plt_intr_handle_fd_set rte_intr_handle_fd_set +#define plt_intr_handle_fd_get rte_intr_handle_fd_get +#define plt_intr_handle_dev_fd_get rte_intr_handle_dev_fd_get +#define plt_intr_handle_dev_fd_set rte_intr_handle_dev_fd_set +#define plt_intr_handle_type_get rte_intr_handle_type_get +#define plt_intr_handle_type_set rte_intr_handle_type_set +#define plt_intr_handle_instance_alloc rte_intr_handle_instance_alloc +#define plt_intr_handle_instance_index_get rte_intr_handle_instance_index_get +#define plt_intr_handle_instance_index_set rte_intr_handle_instance_index_set +#define plt_intr_handle_instance_free rte_intr_handle_instance_free +#define plt_intr_handle_event_list_update rte_intr_handle_event_list_update +#define plt_intr_handle_max_intr_get rte_intr_handle_max_intr_get +#define plt_intr_handle_max_intr_set rte_intr_handle_max_intr_set +#define plt_intr_handle_nb_efd_get rte_intr_handle_nb_efd_get +#define plt_intr_handle_nb_efd_set rte_intr_handle_nb_efd_set +#define plt_intr_handle_nb_intr_get rte_intr_handle_nb_intr_get +#define plt_intr_handle_nb_intr_set rte_intr_handle_nb_intr_set +#define plt_intr_handle_efds_index_get rte_intr_handle_efds_index_get +#define plt_intr_handle_efds_index_set rte_intr_handle_efds_index_set +#define plt_intr_handle_efds_base rte_intr_handle_efds_base +#define plt_intr_handle_elist_index_get rte_intr_handle_elist_index_get +#define plt_intr_handle_elist_index_set rte_intr_handle_elist_index_set +#define plt_alarm_set rte_eal_alarm_set#define plt_alarm_cancel rte_eal_alarm_cancel
drivers/common/cnxk/roc_sso.c +2 -2
@@ -491,7 +491,7 @@ roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t nb_hwgrp) goto sso_msix_fail; } - rc =sso_register_irqs_priv (roc_sso, &sso->pci_dev->intr_handle, nb_hws, + rc =sso_register_irqs_priv (roc_sso, sso->pci_dev->intr_handle, nb_hws, nb_hwgrp);if (rc <0 ) {plt_err ("Failed to register SSO LF IRQs" );
@@ -521,7 +521,7 @@ roc_sso_rsrc_fini(struct roc_sso *roc_sso)if (!roc_sso->nb_hws && !roc_sso->nb_hwgrp)return ; -sso_unregister_irqs_priv (roc_sso, &sso->pci_dev->intr_handle, +sso_unregister_irqs_priv (roc_sso, sso->pci_dev->intr_handle, roc_sso->nb_hws, roc_sso->nb_hwgrp);sso_lf_free (roc_sso,SSO_LF_TYPE_HWS , roc_sso->nb_hws);sso_lf_free (roc_sso,SSO_LF_TYPE_HWGRP , roc_sso->nb_hwgrp);
drivers/common/cnxk/roc_tim.c +2 -2
@@ -200,7 +200,7 @@ roc_tim_lf_alloc(struct roc_tim *roc_tim, uint8_t ring_id, uint64_t *clk)if (clk) *clk = rsp->tenns_clk; - rc =tim_register_irq_priv (roc_tim, &sso->pci_dev->intr_handle, ring_id, + rc =tim_register_irq_priv (roc_tim, sso->pci_dev->intr_handle, ring_id, tim->tim_msix_offsets[ring_id]);if (rc <0 ) {plt_tim_dbg ("Failed to register Ring[%d] IRQ" , ring_id);
@@ -223,7 +223,7 @@ roc_tim_lf_free(struct roc_tim *roc_tim, uint8_t ring_id)struct tim_ring_req *req;int rc = -ENOSPC ; -tim_unregister_irq_priv (roc_tim, &sso->pci_dev->intr_handle, ring_id, +tim_unregister_irq_priv (roc_tim, sso->pci_dev->intr_handle, ring_id, tim->tim_msix_offsets[ring_id]); req =mbox_alloc_msg_tim_lf_free (dev->mbox);
drivers/common/octeontx2/otx2_dev.c +7 -7
@@ -640,7 +640,7 @@ otx2_af_pf_mbox_irq(void *param)static int mbox_register_pf_irq (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int i, rc;/* HW clear irq */
@@ -690,7 +690,7 @@ mbox_register_pf_irq(struct rte_pci_device *pci_dev, struct otx2_dev *dev)static int mbox_register_vf_irq (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int rc;/* Clear irq */
@@ -723,7 +723,7 @@ mbox_register_irq(struct rte_pci_device *pci_dev, struct otx2_dev *dev)static void mbox_unregister_pf_irq (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int i;/* HW clear irq */
@@ -755,7 +755,7 @@ mbox_unregister_pf_irq(struct rte_pci_device *pci_dev, struct otx2_dev *dev)static void mbox_unregister_vf_irq (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;/* Clear irq */ otx2_write64 (~0ull , dev->bar2 +RVU_VF_INT_ENA_W1C );
@@ -838,7 +838,7 @@ otx2_pf_vf_flr_irq(void *param)static int vf_flr_unregister_irqs (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int i;otx2_base_dbg ("Unregister VF FLR interrupts for %s" , pci_dev->name);
@@ -859,7 +859,7 @@ vf_flr_unregister_irqs(struct rte_pci_device *pci_dev, struct otx2_dev *dev)static int vf_flr_register_irqs (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int i, rc;otx2_base_dbg ("Register VF FLR interrupts for %s" , pci_dev->name);
@@ -1036,7 +1036,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)void otx2_dev_fini (struct rte_pci_device *pci_dev,void *otx2_dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct otx2_dev *dev = otx2_dev;struct otx2_idev_cfg *idev;struct otx2_mbox *mbox;
drivers/common/octeontx2/otx2_irq.c +68 -49
231 lines not on this page · raw message
drivers/crypto/octeontx2/otx2_cryptodev_hw_access.c +2 -2
@@ -36,7 +36,7 @@ otx2_cpt_lf_err_intr_unregister(const struct rte_cryptodev *dev, uint16_t msix_off, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;/* Disable error interrupts */ otx2_write64 (~0ull , base +OTX2_CPT_LF_MISC_INT_ENA_W1C );
@@ -65,7 +65,7 @@ otx2_cpt_lf_err_intr_register(const struct rte_cryptodev *dev, uint16_t msix_off, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int ret;/* Disable error interrupts */
drivers/event/octeontx2/otx2_evdev_irq.c +6 -6
@@ -29,7 +29,7 @@ sso_lf_register_irq(const struct rte_eventdev *event_dev, uint16_t ggrp_msixoff, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (event_dev->dev); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int rc, vec; vec = ggrp_msixoff +SSO_LF_INT_VEC_GRP ;
@@ -66,7 +66,7 @@ ssow_lf_register_irq(const struct rte_eventdev *event_dev, uint16_t gws_msixoff, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (event_dev->dev); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int rc, vec; vec = gws_msixoff +SSOW_LF_INT_VEC_IOP ;
@@ -86,7 +86,7 @@ sso_lf_unregister_irq(const struct rte_eventdev *event_dev, uint16_t ggrp_msixoff, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (event_dev->dev); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int vec; vec = ggrp_msixoff +SSO_LF_INT_VEC_GRP ;
@@ -101,7 +101,7 @@ ssow_lf_unregister_irq(const struct rte_eventdev *event_dev, uint16_t gws_msixoff, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (event_dev->dev); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int vec; vec = gws_msixoff +SSOW_LF_INT_VEC_IOP ;
@@ -198,7 +198,7 @@ static int tim_lf_register_irq(struct rte_pci_device *pci_dev, uint16_t tim_msixoff, uintptr_t base) { - struct rte_intr_handle *handle = &pci_dev->intr_handle; + struct rte_intr_handle *handle = pci_dev->intr_handle;int rc, vec; vec = tim_msixoff +TIM_LF_INT_VEC_NRSPERR_INT ;
@@ -226,7 +226,7 @@ static void tim_lf_unregister_irq(struct rte_pci_device *pci_dev, uint16_t tim_msixoff, uintptr_t base) { - struct rte_intr_handle *handle = &pci_dev->intr_handle; + struct rte_intr_handle *handle = pci_dev->intr_handle;int vec; vec = tim_msixoff +TIM_LF_INT_VEC_NRSPERR_INT ;
drivers/mempool/octeontx2/otx2_mempool.c +1 -1
@@ -301,7 +301,7 @@ otx2_npa_lf_init(struct rte_pci_device *pci_dev, void *otx2_dev) lf->pf_func = dev->pf_func; lf->npa_msixoff = npa_msixoff; - lf->intr_handle = &pci_dev->intr_handle; + lf->intr_handle = pci_dev->intr_handle; lf->pci_dev = pci_dev; idev->npa_pf_func = dev->pf_func;
drivers/net/atlantic/atl_ethdev.c +10 -12
@@ -360,7 +360,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) {struct atl_adapter *adapter = eth_dev->data->dev_private;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);int err =0 ;
@@ -479,7 +479,7 @@ atl_dev_start(struct rte_eth_dev *dev) {struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;int status;int err;
@@ -525,10 +525,10 @@ atl_dev_start(struct rte_eth_dev *dev) } } -if (rte_intr_dp_is_en (intr_handle) && !intr_handle->intr_vec) { - intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->nb_rx_queues *sizeof (int ),0 ); -if (intr_handle->intr_vec ==NULL ) { +if (rte_intr_dp_is_en (intr_handle) && + !rte_intr_handle_vec_list_base (intr_handle)) { +if (rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + dev->data->nb_rx_queues)) {PMD_INIT_LOG (ERR ,"Failed to allocate %d rx_queues" " intr_vec" , dev->data->nb_rx_queues);return -ENOMEM ;
@@ -608,7 +608,7 @@ atl_dev_stop(struct rte_eth_dev *dev)struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;PMD_INIT_FUNC_TRACE (); dev->data->dev_started =0 ;
@@ -638,10 +638,8 @@ atl_dev_stop(struct rte_eth_dev *dev)/* Clean datapath event and queue/vec mapping */ rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle);return 0 ; }
@@ -692,7 +690,7 @@ static int atl_dev_close(struct rte_eth_dev *dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct aq_hw_s *hw;int ret;
drivers/net/avp/avp_ethdev.c +4 -4
@@ -711,7 +711,7 @@ avp_dev_interrupt_handler(void *data) status);/* re-enable UIO interrupt handling */ - ret =rte_intr_ack (&pci_dev->intr_handle); + ret =rte_intr_ack (pci_dev->intr_handle);if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to re-enable UIO interrupts, ret=%d\n" , ret);
@@ -730,7 +730,7 @@ avp_dev_enable_interrupts(struct rte_eth_dev *eth_dev)return -EINVAL ;/* enable UIO interrupt handling */ - ret =rte_intr_enable (&pci_dev->intr_handle); + ret =rte_intr_enable (pci_dev->intr_handle);if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to enable UIO interrupts, ret=%d\n" , ret);
@@ -759,7 +759,7 @@ avp_dev_disable_interrupts(struct rte_eth_dev *eth_dev) RTE_PTR_ADD(registers, RTE_AVP_INTERRUPT_MASK_OFFSET));/* enable UIO interrupt handling */ - ret =rte_intr_disable (&pci_dev->intr_handle); + ret =rte_intr_disable (pci_dev->intr_handle);if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to disable UIO interrupts, ret=%d\n" , ret);
@@ -776,7 +776,7 @@ avp_dev_setup_interrupts(struct rte_eth_dev *eth_dev)int ret;/* register a callback handler with UIO for interrupt notifications */ - ret =rte_intr_callback_register (&pci_dev->intr_handle, + ret =rte_intr_callback_register (pci_dev->intr_handle, avp_dev_interrupt_handler, (void *)eth_dev);if (ret <0 ) {
drivers/net/axgbe/axgbe_ethdev.c +6 -6
@@ -313,7 +313,7 @@ axgbe_dev_interrupt_handler(void *param) } }/* Unmask interrupts since disabled after generation */ -rte_intr_ack (&pdata->pci_dev->intr_handle); +rte_intr_ack (pdata->pci_dev->intr_handle); }/*
@@ -374,7 +374,7 @@ axgbe_dev_start(struct rte_eth_dev *dev) }/* enable uio/vfio intr/eventfd mapping */ -rte_intr_enable (&pdata->pci_dev->intr_handle); +rte_intr_enable (pdata->pci_dev->intr_handle);/* phy start*/ pdata->phy_if.phy_start (pdata);
@@ -404,7 +404,7 @@ axgbe_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); -rte_intr_disable (&pdata->pci_dev->intr_handle); +rte_intr_disable (pdata->pci_dev->intr_handle);if (rte_bit_relaxed_get32 (AXGBE_STOPPED , &pdata->dev_state))return 0 ;
@@ -2323,7 +2323,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)return ret; } -rte_intr_callback_register (&pci_dev->intr_handle, +rte_intr_callback_register (pci_dev->intr_handle, axgbe_dev_interrupt_handler, (void *)eth_dev); PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
@@ -2347,8 +2347,8 @@ axgbe_dev_close(struct rte_eth_dev *eth_dev)axgbe_dev_clear_queues (eth_dev);/* disable uio intr before callback unregister */ -rte_intr_disable (&pci_dev->intr_handle); -rte_intr_callback_unregister (&pci_dev->intr_handle, +rte_intr_disable (pci_dev->intr_handle); +rte_intr_callback_unregister (pci_dev->intr_handle, axgbe_dev_interrupt_handler, (void *)eth_dev);
drivers/net/axgbe/axgbe_mdio.c +3 -3
@@ -933,7 +933,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) }/* Disable auto-negotiation interrupt */ -rte_intr_disable (&pdata->pci_dev->intr_handle); +rte_intr_disable (pdata->pci_dev->intr_handle);/* Start auto-negotiation in a supported mode */ if (axgbe_use_mode (pdata,AXGBE_MODE_KR )) {
@@ -951,7 +951,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) }else if (axgbe_use_mode (pdata,AXGBE_MODE_SGMII_100 )) {axgbe_set_mode (pdata,AXGBE_MODE_SGMII_100 ); }else { -rte_intr_enable (&pdata->pci_dev->intr_handle); +rte_intr_enable (pdata->pci_dev->intr_handle);return -EINVAL ; }
@@ -964,7 +964,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) pdata->kx_state =AXGBE_RX_BPA ;/* Re-enable auto-negotiation interrupt */ -rte_intr_enable (&pdata->pci_dev->intr_handle); +rte_intr_enable (pdata->pci_dev->intr_handle);axgbe_an37_enable_interrupts (pdata);axgbe_an_init (pdata);
drivers/net/bnx2x/bnx2x_ethdev.c +5 -5
@@ -134,7 +134,7 @@ bnx2x_interrupt_handler(void *param)PMD_DEBUG_PERIODIC_LOG (INFO , sc,"Interrupt handled" );bnx2x_interrupt_action (dev,1 ); -rte_intr_ack (&sc->pci_dev->intr_handle); +rte_intr_ack (sc->pci_dev->intr_handle); }static void bnx2x_periodic_start (void *param)
@@ -234,10 +234,10 @@ bnx2x_dev_start(struct rte_eth_dev *dev) }if (IS_PF (sc)) { -rte_intr_callback_register (&sc->pci_dev->intr_handle, +rte_intr_callback_register (sc->pci_dev->intr_handle, bnx2x_interrupt_handler, (void *)dev); -if (rte_intr_enable (&sc->pci_dev->intr_handle)) +if (rte_intr_enable (sc->pci_dev->intr_handle))PMD_DRV_LOG (ERR , sc,"rte_intr_enable failed" ); }
@@ -262,8 +262,8 @@ bnx2x_dev_stop(struct rte_eth_dev *dev)bnx2x_dev_rxtx_init_dummy (dev);if (IS_PF (sc)) { -rte_intr_disable (&sc->pci_dev->intr_handle); -rte_intr_callback_unregister (&sc->pci_dev->intr_handle, +rte_intr_disable (sc->pci_dev->intr_handle); +rte_intr_callback_unregister (sc->pci_dev->intr_handle, bnx2x_interrupt_handler, (void *)dev);/* stop the periodic callout */
drivers/net/bnxt/bnxt_ethdev.c +15 -17
@@ -729,7 +729,7 @@ static int bnxt_alloc_prev_ring_stats(struct bnxt *bp)static int bnxt_start_nic (struct bnxt *bp) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (bp->eth_dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;uint32_t queue_id, base =BNXT_MISC_VEC_ID ;uint32_t vec =BNXT_MISC_VEC_ID ;
@@ -831,12 +831,10 @@ static int bnxt_start_nic(struct bnxt *bp)return rc; } -if (rte_intr_dp_is_en (intr_handle) && !intr_handle->intr_vec) { - intr_handle->intr_vec = -rte_zmalloc ("intr_vec" , - bp->eth_dev->data->nb_rx_queues * -sizeof (int ),0 ); -if (intr_handle->intr_vec ==NULL ) { +if (rte_intr_dp_is_en (intr_handle) && + !rte_intr_handle_vec_list_base (intr_handle)) { +if (rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + bp->eth_dev->data->nb_rx_queues)) {PMD_DRV_LOG (ERR ,"Failed to allocate %d rx_queues" " intr_vec" , bp->eth_dev->data->nb_rx_queues); rc = -ENOMEM ;
@@ -844,13 +842,15 @@ static int bnxt_start_nic(struct bnxt *bp) }PMD_DRV_LOG (DEBUG ,"intr_handle->intr_vec = %p " "intr_handle->nb_efd = %d intr_handle->max_intr = %d\n" , - intr_handle->intr_vec, intr_handle->nb_efd, - intr_handle->max_intr); +rte_intr_handle_vec_list_base (intr_handle), +rte_intr_handle_nb_efd_get (intr_handle), +rte_intr_handle_max_intr_get (intr_handle));for (queue_id =0 ; queue_id < bp->eth_dev->data->nb_rx_queues; queue_id++) { - intr_handle->intr_vec[queue_id] = - vec +BNXT_RX_VEC_START ; -if (vec < base + intr_handle->nb_efd -1 ) +rte_intr_handle_vec_list_index_set (intr_handle, + queue_id, vec +BNXT_RX_VEC_START ); +if (vec < base +rte_intr_handle_nb_efd_get (intr_handle) + -1 ) vec++; } }
@@ -1459,7 +1459,7 @@ static int bnxt_dev_stop(struct rte_eth_dev *eth_dev) {struct bnxt *bp = eth_dev->data->dev_private;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rte_eth_link link;int ret;
@@ -1501,10 +1501,8 @@ static int bnxt_dev_stop(struct rte_eth_dev *eth_dev)/* Clean queue intr-vector mapping */ rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle);bnxt_hwrm_port_clr_stats (bp);bnxt_free_tx_mbufs (bp);
drivers/net/bnxt/bnxt_irq.c +2 -2
@@ -67,7 +67,7 @@ void bnxt_int_handler(void *param)int bnxt_free_int (struct bnxt *bp) { -struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle; +struct rte_intr_handle *intr_handle = bp->pdev->intr_handle;struct bnxt_irq *irq = bp->irq_tbl;int rc =0 ;
@@ -170,7 +170,7 @@ int bnxt_setup_int(struct bnxt *bp)int bnxt_request_int (struct bnxt *bp) { -struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle; +struct rte_intr_handle *intr_handle = bp->pdev->intr_handle;struct bnxt_irq *irq = bp->irq_tbl;int rc =0 ;
drivers/net/dpaa/dpaa_ethdev.c +31 -16
94 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.c +5 -5
@@ -1157,7 +1157,7 @@ dpaa2_dev_start(struct rte_eth_dev *dev)struct rte_intr_handle *intr_handle; dpaa2_dev = container_of(rdev, struct rte_dpaa2_device, device); - intr_handle = &dpaa2_dev->intr_handle; + intr_handle = dpaa2_dev->intr_handle;PMD_INIT_FUNC_TRACE ();
@@ -1228,8 +1228,8 @@ dpaa2_dev_start(struct rte_eth_dev *dev) }/* if the interrupts were configured on this devices*/ -if (intr_handle && (intr_handle->fd) && - (dev->data->dev_conf.intr_conf.lsc !=0 )) { +if (intr_handle &&rte_intr_handle_fd_get (intr_handle) && + dev->data->dev_conf.intr_conf.lsc !=0 ) {/* Registering LSC interrupt handler */ rte_intr_callback_register(intr_handle, dpaa2_interrupt_handler,
@@ -1268,8 +1268,8 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE ();/* reset interrupt callback */ -if (intr_handle && (intr_handle->fd) && - (dev->data->dev_conf.intr_conf.lsc !=0 )) { +if (intr_handle &&rte_intr_handle_fd_get (intr_handle) && + dev->data->dev_conf.intr_conf.lsc !=0 ) {/*disable dpni irqs */ dpaa2_eth_setup_irqs (dev,0 );
drivers/net/e1000/em_ethdev.c +10 -14
@@ -237,7 +237,7 @@ static int eth_em_dev_init(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct e1000_adapter *adapter =E1000_DEV_PRIVATE (eth_dev->data->dev_private); struct e1000_hw *hw =
@@ -525,7 +525,7 @@ eth_em_start(struct rte_eth_dev *dev)struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret, mask;uint32_t intr_vector =0 ;uint32_t *speeds;
@@ -575,12 +575,10 @@ eth_em_start(struct rte_eth_dev *dev) }if (rte_intr_dp_is_en (intr_handle)) { - intr_handle->intr_vec = -rte_zmalloc ("intr_vec" , - dev->data->nb_rx_queues *sizeof (int ),0 ); -if (intr_handle->intr_vec ==NULL ) { +if (rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + dev->data->nb_rx_queues)) {PMD_INIT_LOG (ERR ,"Failed to allocate %d rx_queues" -" intr_vec" , dev->data->nb_rx_queues); +" intr_vec" , dev->data->nb_rx_queues);return -ENOMEM ; }
@@ -718,7 +716,7 @@ eth_em_stop(struct rte_eth_dev *dev)struct rte_eth_link link;struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle; dev->data->dev_started =0 ;
@@ -752,10 +750,8 @@ eth_em_stop(struct rte_eth_dev *dev)/* Clean datapath event and queue/vec mapping */ rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle);return 0 ; }
@@ -767,7 +763,7 @@ eth_em_close(struct rte_eth_dev *dev)struct e1000_adapter *adapter =E1000_DEV_PRIVATE (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret;if (rte_eal_process_type () !=RTE_PROC_PRIMARY )
@@ -1008,7 +1004,7 @@ eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, __rte_unused uint16_t queue {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;em_rxq_intr_enable (hw);rte_intr_ack (intr_handle);
drivers/net/e1000/igb_ethdev.c +41 -43
220 lines not on this page · raw message
drivers/net/ena/ena_ethdev.c +20 -16
@@ -473,7 +473,7 @@ static void ena_config_debug_area(struct ena_adapter *adapter)static int ena_close (struct rte_eth_dev *dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ena_adapter *adapter = dev->data->dev_private;int ret =0 ;
@@ -947,7 +947,7 @@ static int ena_stop(struct rte_eth_dev *dev)struct ena_adapter *adapter = dev->data->dev_private;struct ena_com_dev *ena_dev = &adapter->ena_dev;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int rc;/* Cannot free memory in secondary process */
@@ -969,10 +969,10 @@ static int ena_stop(struct rte_eth_dev *dev)rte_intr_disable (intr_handle);rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } + +/* Cleanup vector list */ +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle);rte_intr_enable (intr_handle);
@@ -988,7 +988,7 @@ static int ena_create_io_queue(struct rte_eth_dev *dev, struct ena_ring *ring)struct ena_adapter *adapter = ring->adapter;struct ena_com_dev *ena_dev = &adapter->ena_dev;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ena_com_create_io_ctx ctx =/* policy set to _HOST just to satisfy icc compiler */ {ENA_ADMIN_PLACEMENT_POLICY_HOST ,
@@ -1008,7 +1008,10 @@ static int ena_create_io_queue(struct rte_eth_dev *dev, struct ena_ring *ring) ena_qid =ENA_IO_RXQ_IDX (ring->id); ctx.direction =ENA_COM_IO_QUEUE_DIRECTION_RX ;if (rte_intr_dp_is_en (intr_handle)) - ctx.msix_vector = intr_handle->intr_vec[ring->id]; + ctx.msix_vector = +rte_intr_handle_vec_list_index_get (intr_handle, + ring->id); +for (i =0 ; i < ring->ring_size; i++) ring->empty_rx_reqs[i] = i; }
@@ -1665,7 +1668,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) pci_dev->addr.devid, pci_dev->addr.function); - intr_handle = &pci_dev->intr_handle; + intr_handle = pci_dev->intr_handle; adapter->regs = pci_dev->mem_resource[ENA_REGS_BAR ].addr; adapter->dev_mem_base = pci_dev->mem_resource[ENA_MEM_BAR ].addr;
@@ -2817,7 +2820,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter,static int ena_setup_rx_intr (struct rte_eth_dev *dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int rc;uint16_t vectors_nb, i;bool rx_intr_requested = dev->data->dev_conf.intr_conf.rxq;
@@ -2844,9 +2847,9 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev) goto enable_intr; } - intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->nb_rx_queues *sizeof (*intr_handle->intr_vec),0 ); -if (intr_handle->intr_vec ==NULL ) { +/* Allocate the vector list */ +if (rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + dev->data->nb_rx_queues)) {PMD_DRV_LOG (ERR ,"Failed to allocate interrupt vector for %d queues\n" , dev->data->nb_rx_queues);
@@ -2865,7 +2868,9 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev) }for (i =0 ; i < vectors_nb; ++i) - intr_handle->intr_vec[i] =RTE_INTR_VEC_RXTX_OFFSET + i; +if (rte_intr_handle_vec_list_index_set (intr_handle, i, +RTE_INTR_VEC_RXTX_OFFSET + i)) + goto disable_intr_efd;rte_intr_enable (intr_handle);return 0 ;
@@ -2873,8 +2878,7 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev) disable_intr_efd:rte_intr_efd_disable (intr_handle); free_intr_vec: -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; +rte_intr_handle_vec_list_free (intr_handle); enable_intr:rte_intr_enable (intr_handle);return rc;
drivers/net/enic/enic_main.c +14 -13
@@ -448,7 +448,7 @@ enic_intr_handler(void *arg)rte_eth_dev_callback_process (dev,RTE_ETH_EVENT_INTR_LSC ,NULL );enic_log_q_error (enic);/* Re-enable irq in case of INTx */ -rte_intr_ack (&enic->pdev->intr_handle); +rte_intr_ack (enic->pdev->intr_handle); }static int enic_rxq_intr_init (struct enic *enic)
@@ -477,14 +477,16 @@ static int enic_rxq_intr_init(struct enic *enic) " interrupts\n");return err; } - intr_handle->intr_vec =rte_zmalloc ("enic_intr_vec" , - rxq_intr_count *sizeof (int ),0 ); -if (intr_handle->intr_vec ==NULL ) { + +if (rte_intr_handle_vec_list_alloc (intr_handle,"enic_intr_vec" , + rxq_intr_count)) {dev_err (enic,"Failed to allocate intr_vec\n" );return -ENOMEM ; }for (i =0 ; i < rxq_intr_count; i++) - intr_handle->intr_vec[i] = i +ENICPMD_RXQ_INTR_OFFSET ; +if (rte_intr_handle_vec_list_index_set (intr_handle, i, + i +ENICPMD_RXQ_INTR_OFFSET )) +return -rte_errno;return 0 ; }
@@ -494,10 +496,9 @@ static void enic_rxq_intr_deinit(struct enic *enic) intr_handle = enic->rte_dev->intr_handle;rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } + +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle); }static void enic_prep_wq_for_simple_tx (struct enic *enic,uint16_t queue_idx)
@@ -667,10 +668,10 @@ int enic_enable(struct enic *enic)vnic_dev_enable_wait (enic->vdev);/* Register and enable error interrupt */ -rte_intr_callback_register (&(enic->pdev->intr_handle), +rte_intr_callback_register (enic->pdev->intr_handle, enic_intr_handler, (void *)enic->rte_dev); -rte_intr_enable (&(enic->pdev->intr_handle)); +rte_intr_enable (enic->pdev->intr_handle);/* Unmask LSC interrupt */ vnic_intr_unmask (&enic->intr[ENICPMD_LSC_INTR_OFFSET ]);
@@ -1112,8 +1113,8 @@ int enic_disable(struct enic *enic) (void )vnic_intr_masked (&enic->intr[i]);/* flush write */ }enic_rxq_intr_deinit (enic); -rte_intr_disable (&enic->pdev->intr_handle); -rte_intr_callback_unregister (&enic->pdev->intr_handle, +rte_intr_disable (enic->pdev->intr_handle); +rte_intr_callback_unregister (enic->pdev->intr_handle, enic_intr_handler, (void *)enic->rte_dev);
drivers/net/failsafe/failsafe.c +20 -4
@@ -266,11 +266,25 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) mac->addr_bytes[4], mac->addr_bytes[5]); dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC |RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS ; -PRIV (dev)->intr_handle = (struct rte_intr_handle ){ - .fd =-1 , - .type =RTE_INTR_HANDLE_EXT , - }; + +/* Allocate interrupt instance */ +PRIV (dev)->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + true); +if (!PRIV (dev)->intr_handle) { +ERROR ("Failed to allocate intr handle" ); + goto cancel_alarm; + } + +if (rte_intr_handle_fd_set (PRIV (dev)->intr_handle,-1 )) + goto cancel_alarm; + +if (rte_intr_handle_type_set (PRIV (dev)->intr_handle, +RTE_INTR_HANDLE_EXT )) + goto cancel_alarm; +rte_eth_dev_probing_finish (dev); +return 0 ; cancel_alarm:failsafe_hotplug_alarm_cancel (dev);
@@ -299,6 +313,8 @@ fs_rte_eth_free(const char *name)return 0 ;/* port already released */ ret =failsafe_eth_dev_close (dev);rte_eth_dev_release_port (dev); +if (PRIV (dev)->intr_handle) +rte_intr_handle_instance_free (PRIV (dev)->intr_handle);return ret; }
drivers/net/failsafe/failsafe_intr.c +26 -19
86 lines not on this page · raw message
drivers/net/failsafe/failsafe_ops.c +17 -6
@@ -398,15 +398,24 @@ fs_rx_queue_setup(struct rte_eth_dev *dev,* For the time being, fake as if we are using MSIX interrupts, * this will cause rte_intr_efd_enable to allocate an eventfd for us. */ -struct rte_intr_handle intr_handle = { - .type =RTE_INTR_HANDLE_VFIO_MSIX , - .efds = {-1 , }, - }; +struct rte_intr_handle *intr_handle;struct sub_device *sdev;struct rxq *rxq;uint8_t i;int ret; + intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!intr_handle) +return -ENOMEM ; + +if (rte_intr_handle_type_set (intr_handle,RTE_INTR_HANDLE_VFIO_MSIX )) +return -rte_errno; + +if (rte_intr_handle_efds_index_set (intr_handle,0 ,-1 )) +return -rte_errno; +fs_lock (dev,0 );if (rx_conf->rx_deferred_start) { FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
@@ -440,12 +449,12 @@ fs_rx_queue_setup(struct rte_eth_dev *dev, rxq->info.nb_desc = nb_rx_desc; rxq->priv =PRIV (dev); rxq->sdev =PRIV (dev)->subs; - ret =rte_intr_efd_enable (&intr_handle,1 ); + ret =rte_intr_efd_enable (intr_handle,1 );if (ret <0 ) {fs_unlock (dev,0 );return ret; } - rxq->event_fd = intr_handle.efds[0 ]; + rxq->event_fd =rte_intr_handle_efds_index_get (intr_handle,0 ); dev->data->rx_queues[rx_queue_id] = rxq; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_rx_queue_setup(PORT_ID(sdev),
@@ -458,10 +467,12 @@ fs_rx_queue_setup(struct rte_eth_dev *dev, } }fs_unlock (dev,0 ); +rte_intr_handle_instance_free (intr_handle);return 0 ; free_rxq:fs_rx_queue_release (rxq);fs_unlock (dev,0 ); +rte_intr_handle_instance_free (intr_handle);return ret; }
drivers/net/failsafe/failsafe_private.h +1 -1
@@ -166,7 +166,7 @@ struct fs_priv {struct rte_ether_addr *mcast_addrs;/* current capabilities */ struct rte_eth_dev_owner my_owner;/* Unique owner. */ -struct rte_intr_handle intr_handle;/* Port interrupt handle. */ +struct rte_intr_handle *intr_handle;/* Port interrupt handle. */ /* * Fail-safe state machine. * This level will be tracking state of the EAL and eth
drivers/net/fm10k/fm10k_ethdev.c +17 -15
@@ -32,7 +32,8 @@#define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)/* default 1:1 map from queue ID to interrupt vector ID */ -#define Q2V (pci_dev, queue_id) ((pci_dev)->intr_handle.intr_vec[queue_id]) +#define Q2V (pci_dev, queue_id) \ + (rte_intr_handle_vec_list_index_get((pci_dev)->intr_handle, queue_id))/* First 64 Logical ports for PF/VMDQ, second 64 for Flow director */ #define MAX_LPORT_NUM 128
@@ -690,7 +691,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev)struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct fm10k_macvlan_filter_info *macvlan;struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pdev->intr_handle; +struct rte_intr_handle *intr_handle = pdev->intr_handle;int i, ret;struct fm10k_rx_queue *rxq;uint64_t base_addr;
@@ -1158,7 +1159,7 @@ fm10k_dev_stop(struct rte_eth_dev *dev) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pdev->intr_handle; +struct rte_intr_handle *intr_handle = pdev->intr_handle;int i;PMD_INIT_FUNC_TRACE ();
@@ -1187,8 +1188,7 @@ fm10k_dev_stop(struct rte_eth_dev *dev) }/* Clean datapath event and queue/vec mapping */ rte_intr_efd_disable (intr_handle); -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; +rte_intr_handle_vec_list_free (intr_handle);return 0 ; }
@@ -2368,7 +2368,7 @@ fm10k_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)else FM10K_WRITE_REG (hw,FM10K_VFITR (Q2V (pdev, queue_id)),FM10K_ITR_AUTOMASK |FM10K_ITR_MASK_CLEAR ); -rte_intr_ack (&pdev->intr_handle); +rte_intr_ack (pdev->intr_handle);return 0 ; }
@@ -2393,7 +2393,7 @@ fm10k_dev_rxq_interrupt_setup(struct rte_eth_dev *dev) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pdev->intr_handle; +struct rte_intr_handle *intr_handle = pdev->intr_handle;uint32_t intr_vector, vec;uint16_t queue_id;int result =0 ;
@@ -2421,15 +2421,17 @@ fm10k_dev_rxq_interrupt_setup(struct rte_eth_dev *dev) }if (rte_intr_dp_is_en (intr_handle) && !result) { - intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->nb_rx_queues *sizeof (int ),0 ); -if (intr_handle->intr_vec) { +if (!rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + dev->data->nb_rx_queues)) {for (queue_id =0 , vec =FM10K_RX_VEC_START ; queue_id < dev->data->nb_rx_queues; queue_id++) {
Lines of this file are not shown. View the raw message.
drivers/net/hns3/hns3_ethdev.c +25 -25
50 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev_vf.c +30 -27
57 lines not on this page · raw message
drivers/net/i40e/i40e_ethdev.c +28 -27
55 lines not on this page · raw message
drivers/net/i40e/i40e_ethdev_vf.c +22 -21
43 lines not on this page · raw message
drivers/net/iavf/iavf_ethdev.c +22 -19
41 lines not on this page · raw message
drivers/net/ice/ice_ethdev.c +26 -25
51 lines not on this page · raw message
drivers/net/igc/igc_ethdev.c +23 -24
47 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethdev.c +34 -36
70 lines not on this page · raw message
drivers/net/memif/memif_socket.c +71 -28
99 lines not on this page · raw message
drivers/net/memif/rte_eth_memif.c +51 -12
63 lines not on this page · raw message
drivers/net/mlx4/mlx4_intr.c +30 -18
48 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_os.c +38 -18
56 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxq.c +25 -18
43 lines not on this page · raw message
drivers/net/nfp/nfp_net.c +23 -19
42 lines not on this page · raw message
drivers/net/octeontx2/otx2_ethdev_irq.c +18 -17
Lines of this file are not shown. View the raw message.
drivers/net/vhost/rte_eth_vhost.c +48 -30
78 lines not on this page · raw message
drivers/net/virtio/virtio_user/virtio_user_dev.c +37 -16
53 lines not on this page · raw message
drivers/net/vmxnet3/vmxnet3_ethdev.c +25 -20
45 lines not on this page · raw message
drivers/raw/ifpga/ifpga_rawdev.c +29 -13
42 lines not on this page · raw message
drivers/regex/octeontx2/otx2_regexdev_hw_access.c +2 -2
Lines of this file are not shown. View the raw message.
drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +32 -14
46 lines not on this page · raw message
lib/eal/linux/eal_dev.c +42 -23
65 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.18.0
Part of the diff is not shown here. View the raw message.
RFC 6/7 eal/interrupts: make interrupt handle structure opaque
In reply to Harman KalraMoving interrupt handle structure definition inside the c file to make its fields totally opaque to the outside world.
Dynamically allocating the efds and elist array os intr_handle structure, based on size provided by user. Eg size can be MSIX interrupts supported by a PCI device.
--- drivers/bus/pci/linux/pci_vfio.c | 7 + lib/eal/common/eal_common_interrupts.c | 172 ++++++++++++++++++++++++- lib/eal/include/meson.build | 1 - lib/eal/include/rte_eal_interrupts.h | 72 ----------- lib/eal/include/rte_interrupts.h | 24 +++- 5 files changed, 196 insertions(+), 80 deletions(-) delete mode 100644 lib/eal/include/rte_eal_interrupts.h
drivers/bus/pci/linux/pci_vfio.c +7 -0
@@ -266,6 +266,13 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd)return -1 ; } +/* Reallocate the efds and elist fields of intr_handle based +* on PCI device MSIX size. +*/ +if (rte_intr_handle_event_list_update (dev->intr_handle, + irq.count)) +return -1 ; +/* if this vector cannot be used with eventfd, fail if we explicitly * specified interrupt type, otherwise continue */ if ((irq.flags &VFIO_IRQ_INFO_EVENTFD ) ==0 ) {
lib/eal/common/eal_common_interrupts.c +167 -5
256 lines not on this page · raw message
lib/eal/include/meson.build +0 -1
@@ -49,7 +49,6 @@ headers += files( 'rte_version.h', 'rte_vfio.h', ) -indirect_headers += files('rte_eal_interrupts.h') # special case install the generic headers, since they go in a subdir generic_headers = files(
lib/eal/include/rte_eal_interrupts.h deleted +0 -72
72 lines not on this page · raw message
lib/eal/include/rte_interrupts.h +22 -2
@@ -25,9 +25,29 @@ extern "C" {/** Interrupt handle */ struct rte_intr_handle ; -#define RTE_INTR_HANDLE_DEFAULT_SIZE 1 +#define RTE_MAX_RXTX_INTR_VEC_ID 512 +#define RTE_INTR_VEC_ZERO_OFFSET 0 +#define RTE_INTR_VEC_RXTX_OFFSET 1 + +/** +* The interrupt source type, e.g. UIO, VFIO, ALARM etc. +*/ +enum rte_intr_handle_type { +RTE_INTR_HANDLE_UNKNOWN =0 ,/**< generic unknown handle */ +RTE_INTR_HANDLE_UIO ,/**< uio device handle */ +RTE_INTR_HANDLE_UIO_INTX ,/**< uio generic handle */ +RTE_INTR_HANDLE_VFIO_LEGACY ,/**< vfio device handle (legacy) */ +RTE_INTR_HANDLE_VFIO_MSI ,/**< vfio device handle (MSI) */ +RTE_INTR_HANDLE_VFIO_MSIX ,/**< vfio device handle (MSIX) */ +RTE_INTR_HANDLE_ALARM ,/**< alarm handle */ +RTE_INTR_HANDLE_EXT ,/**< external handler */ +RTE_INTR_HANDLE_VDEV ,/**< virtual device */ +RTE_INTR_HANDLE_DEV_EVENT ,/**< device event handle */ +RTE_INTR_HANDLE_VFIO_REQ ,/**< VFIO request handle */ +RTE_INTR_HANDLE_MAX /**< count of elements */ +}; -#include "rte_eal_interrupts.h" +#define RTE_INTR_HANDLE_DEFAULT_SIZE 1/** Function to be registered for the specific interrupt */ typedef void (*rte_intr_callback_fn )(void *cb_arg);
Signature · 1 line
2.18.0
RFC 7/7 eal/alarm: introduce alarm fini routine
In reply to Harman KalraImplementing alarm cleanup routine, where the memory allocated for interrupt instance can be freed.
--- lib/eal/common/eal_private.h | 11 ++++++++ lib/eal/freebsd/eal.c | 1 + lib/eal/freebsd/eal_alarm.c | 50 +++++++++++++++++++++++++++++++----- lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_alarm.c | 10 +++++++- 5 files changed, 66 insertions(+), 7 deletions(-)
lib/eal/common/eal_private.h +11 -0
@@ -162,6 +162,17 @@ int rte_eal_intr_init(void);*/ int rte_eal_alarm_init (void ); +/** +* Init alarm mechanism. This is to allow a callback be called after +* specific time. +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +void rte_eal_alarm_fini (void ); +/** * Function is to check if the kernel module(like, vfio, vfio_iommu_type1, * etc.) loaded.
lib/eal/freebsd/eal.c +1 -0
@@ -973,6 +973,7 @@ rte_eal_cleanup(void)rte_eal_memory_detach ();rte_trace_save ();eal_trace_fini (); +rte_eal_alarm_fini ();eal_cleanup_config (internal_conf);return 0 ; }
lib/eal/freebsd/eal_alarm.c +44 -6
112 lines not on this page · raw message
lib/eal/linux/eal.c +1 -0
@@ -1370,6 +1370,7 @@ rte_eal_cleanup(void)rte_eal_memory_detach ();rte_trace_save ();eal_trace_fini (); +rte_eal_alarm_fini ();eal_cleanup_config (internal_conf);return 0 ; }
lib/eal/linux/eal_alarm.c +9 -1
@@ -58,6 +58,13 @@ static struct rte_intr_handle *intr_handle;static int handler_registered =0 ;static void eal_alarm_callback (void *arg); +void +rte_eal_alarm_fini (void ) +{ +if (intr_handle) +rte_intr_handle_instance_free (intr_handle); +} +int rte_eal_alarm_init (void ) {
@@ -70,7 +77,8 @@ rte_eal_alarm_init(void) goto error; } -rte_intr_handle_type_set (intr_handle,RTE_INTR_HANDLE_ALARM ); +if (rte_intr_handle_type_set (intr_handle,RTE_INTR_HANDLE_ALARM )) + goto error;/* create a timerfd file descriptor */ if (rte_intr_handle_fd_set(intr_handle,
Signature · 1 line
2.18.0
cover make rte_intr_handle internal
In reply to Harman KalraMoving struct rte_intr_handle as an internal structure to avoid any ABI breakages in future. Since this structure defines some static arrays and changing respective macros breaks the ABI. Eg:
Currently RTE_MAX_RXTX_INTR_VEC_ID imposes a limit of maximum 512 MSI-X interrupts that can be defined for a PCI device, while PCI specification allows maximum 2048 MSI-X interrupts that can be used. If some PCI device requires more than 512 vectors, either change the RTE_MAX_RXTX_INTR_VEC_ID limit or dynamically allocate based on PCI device MSI-X size on probe time. Either way its an ABI breakage.
Change already included in 21.11 ABI improvement spreadsheet (item 42):
https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.google.com_s
preadsheets_d_1betlC000ua5SsSiJIcC54mCCCJnW6voH5Dqv9UxeyfE_edit-23gid- 3D0&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=5ESHPj7V-7JdkxT_Z_SU6RrS37ys4U XudBQ_rrS5LRo&m=7dl3OmXU7QHMmWYB6V1hYJtq1cUkjfhXUwze2Si_48c&s=lh6DEGhR Bg1shODpAy3RQk-H-0uQx5icRfUBf9dtCp4&e=
This series makes struct rte_intr_handle totally opaque to the outside world by wrapping it inside a .c file and providing get set wrapper APIs to read or manipulate its fields.. Any changes to be made to any of the fields should be done via these get set APIs.
Introduced a new eal_common_interrupts.c where all these APIs are defined and also hides struct rte_intr_handle definition.
Details on each patch of the series:
Patch 1: eal: interrupt handle API prototypes
This patch provides prototypes of all the new get set APIs, and also rearranges the headers related to interrupt framework. Epoll related definitions prototypes are moved into a new header i.e. rte_epoll.h and APIs defined in rte_eal_interrupts.h which were driver specific are moved to rte_interrupts.h (as anyways it was accessible and used outside DPDK library. Later in the series rte_eal_interrupts.h is removed.
Patch 2: eal/interrupts: implement get set APIs
Implementing all get, set and alloc APIs. Alloc APIs are implemented to allocate memory for interrupt handle instance. Currently most of the drivers defines interrupt handle instance as static but now it cant be static as size of rte_intr_handle is unknown to all the drivers. Drivers are expected to allocate interrupt instances during initialization and free these instances during cleanup phase.
Patch 3: eal/interrupts: avoid direct access to interrupt handle Modifying the interrupt framework for linux and freebsd to use these get set alloc APIs as per requirement and avoid accessing the fields directly.
Patch 4: test/interrupt: apply get set interrupt handle APIs Updating interrupt test suite to use interrupt handle APIs.
Patch 5: drivers: remove direct access to interrupt handle fields Modifying all the drivers and libraries which are currently directly accessing the interrupt handle fields. Drivers are expected to allocated the interrupt instance, use get set APIs with the allocated interrupt handle and free it on cleanup.
Patch 6: eal/interrupts: make interrupt handle structure opaque In this patch rte_eal_interrupt.h is removed, struct rte_intr_handle definition is moved to c file to make it completely opaque. As part of interrupt handle allocation, array like efds and elist(which are currently static) are dynamically allocated with default size (RTE_MAX_RXTX_INTR_VEC_ID). Later these arrays can be reallocated as per device requirement using new API rte_intr_handle_event_list_update(). Eg, on PCI device probing MSIX size can be queried and these arrays can be reallocated accordingly.
Patch 7: eal/alarm: introduce alarm fini routine
Introducing alarm fini routine, as the memory allocated for alarm interrupt instance can be freed in alarm fini.
Testing performed:
1. Validated the series by running interrupts and alarm test suite.
2. Validate l3fwd power functionality with octeontx2 and i40e intel cards, where interrupts are expected on packet arrival.
v1:
* Fixed freebsd compilation failure
* Fixed seg fault in case of memif
Harman Kalra (7):
eal: interrupt handle API prototypes eal/interrupts: implement get set APIs eal/interrupts: avoid direct access to interrupt handle test/interrupt: apply get set interrupt handle APIs
drivers: remove direct access to interrupt handle fields eal/interrupts: make interrupt handle structure opaque eal/alarm: introduce alarm fini routine
MAINTAINERS | 1 + app/test/test_interrupts.c | 237 +++--- drivers/baseband/acc100/rte_acc100_pmd.c | 18 +- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 13 +- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 14 +- drivers/bus/auxiliary/auxiliary_common.c | 2 + drivers/bus/auxiliary/linux/auxiliary.c | 11 + drivers/bus/auxiliary/rte_bus_auxiliary.h | 2 +- drivers/bus/dpaa/dpaa_bus.c | 28 +- drivers/bus/dpaa/rte_dpaa_bus.h | 2 +- drivers/bus/fslmc/fslmc_bus.c | 17 +- drivers/bus/fslmc/fslmc_vfio.c | 32 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 21 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- drivers/bus/fslmc/rte_fslmc.h | 2 +- drivers/bus/ifpga/ifpga_bus.c | 16 +- drivers/bus/ifpga/rte_bus_ifpga.h | 2 +- drivers/bus/pci/bsd/pci.c | 21 +- drivers/bus/pci/linux/pci.c | 4 +- drivers/bus/pci/linux/pci_uio.c | 73 +- drivers/bus/pci/linux/pci_vfio.c | 115 ++- drivers/bus/pci/pci_common.c | 29 +- drivers/bus/pci/pci_common_uio.c | 21 +- drivers/bus/pci/rte_bus_pci.h | 4 +- drivers/bus/vmbus/linux/vmbus_bus.c | 7 + drivers/bus/vmbus/linux/vmbus_uio.c | 37 +- drivers/bus/vmbus/rte_bus_vmbus.h | 2 +- drivers/bus/vmbus/vmbus_common_uio.c | 24 +- drivers/common/cnxk/roc_cpt.c | 8 +- drivers/common/cnxk/roc_dev.c | 14 +- drivers/common/cnxk/roc_irq.c | 106 +-- drivers/common/cnxk/roc_nix_irq.c | 37 +- drivers/common/cnxk/roc_npa.c | 2 +- drivers/common/cnxk/roc_platform.h | 34 + drivers/common/cnxk/roc_sso.c | 4 +- drivers/common/cnxk/roc_tim.c | 4 +- drivers/common/octeontx2/otx2_dev.c | 14 +- drivers/common/octeontx2/otx2_irq.c | 117 +-- .../octeontx2/otx2_cryptodev_hw_access.c | 4 +- drivers/event/octeontx2/otx2_evdev_irq.c | 12 +- drivers/mempool/octeontx2/otx2_mempool.c | 2 +- drivers/net/atlantic/atl_ethdev.c | 22 +- drivers/net/avp/avp_ethdev.c | 8 +- drivers/net/axgbe/axgbe_ethdev.c | 12 +- drivers/net/axgbe/axgbe_mdio.c | 6 +- drivers/net/bnx2x/bnx2x_ethdev.c | 10 +- drivers/net/bnxt/bnxt_ethdev.c | 32 +- drivers/net/bnxt/bnxt_irq.c | 4 +- drivers/net/dpaa/dpaa_ethdev.c | 47 +- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +- drivers/net/e1000/em_ethdev.c | 24 +- drivers/net/e1000/igb_ethdev.c | 84 ++- drivers/net/ena/ena_ethdev.c | 36 +- drivers/net/enic/enic_main.c | 27 +- drivers/net/failsafe/failsafe.c | 24 +- drivers/net/failsafe/failsafe_intr.c | 45 +- drivers/net/failsafe/failsafe_ops.c | 23 +- drivers/net/failsafe/failsafe_private.h | 2 +- drivers/net/fm10k/fm10k_ethdev.c | 32 +- drivers/net/hinic/hinic_pmd_ethdev.c | 10 +- drivers/net/hns3/hns3_ethdev.c | 50 +- drivers/net/hns3/hns3_ethdev_vf.c | 57 +- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/i40e/i40e_ethdev.c | 55 +- drivers/net/i40e/i40e_ethdev_vf.c | 43 +- drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_vchnl.c | 4 +- drivers/net/ice/ice_dcf.c | 10 +- drivers/net/ice/ice_dcf_ethdev.c | 23 +- drivers/net/ice/ice_ethdev.c | 51 +- drivers/net/igc/igc_ethdev.c | 47 +- drivers/net/ionic/ionic_ethdev.c | 12 +- drivers/net/ixgbe/ixgbe_ethdev.c | 70 +- drivers/net/memif/memif_socket.c | 114 ++- drivers/net/memif/memif_socket.h | 4 +- drivers/net/memif/rte_eth_memif.c | 63 +- drivers/net/memif/rte_eth_memif.h | 2 +- drivers/net/mlx4/mlx4.c | 20 +- drivers/net/mlx4/mlx4.h | 2 +- drivers/net/mlx4/mlx4_intr.c | 48 +- drivers/net/mlx5/linux/mlx5_os.c | 56 +- drivers/net/mlx5/linux/mlx5_socket.c | 26 +- drivers/net/mlx5/mlx5.h | 6 +- drivers/net/mlx5/mlx5_rxq.c | 43 +- drivers/net/mlx5/mlx5_trigger.c | 4 +- drivers/net/mlx5/mlx5_txpp.c | 27 +- drivers/net/netvsc/hn_ethdev.c | 4 +- drivers/net/nfp/nfp_common.c | 28 +- drivers/net/nfp/nfp_ethdev.c | 13 +- drivers/net/nfp/nfp_ethdev_vf.c | 13 +- drivers/net/ngbe/ngbe_ethdev.c | 31 +- drivers/net/octeontx2/otx2_ethdev_irq.c | 35 +- drivers/net/qede/qede_ethdev.c | 16 +- drivers/net/sfc/sfc_intr.c | 29 +- drivers/net/tap/rte_eth_tap.c | 37 +- drivers/net/tap/rte_eth_tap.h | 2 +- drivers/net/tap/tap_intr.c | 33 +- drivers/net/thunderx/nicvf_ethdev.c | 13 + drivers/net/thunderx/nicvf_struct.h | 2 +- drivers/net/txgbe/txgbe_ethdev.c | 36 +- drivers/net/txgbe/txgbe_ethdev_vf.c | 35 +- drivers/net/vhost/rte_eth_vhost.c | 78 +- drivers/net/virtio/virtio_ethdev.c | 17 +- .../net/virtio/virtio_user/virtio_user_dev.c | 53 +- drivers/net/vmxnet3/vmxnet3_ethdev.c | 45 +- drivers/raw/ifpga/ifpga_rawdev.c | 42 +- drivers/raw/ntb/ntb.c | 10 +- .../regex/octeontx2/otx2_regexdev_hw_access.c | 4 +- drivers/vdpa/ifc/ifcvf_vdpa.c | 5 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 11 + drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 22 +- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 46 +- lib/bbdev/rte_bbdev.c | 4 +- lib/eal/common/eal_common_interrupts.c | 668 +++++++++++++++++ lib/eal/common/eal_private.h | 11 + lib/eal/common/meson.build | 2 + lib/eal/freebsd/eal.c | 1 + lib/eal/freebsd/eal_alarm.c | 56 +- lib/eal/freebsd/eal_interrupts.c | 94 ++- lib/eal/include/meson.build | 2 +- lib/eal/include/rte_eal_interrupts.h | 269 ------- lib/eal/include/rte_eal_trace.h | 24 +- lib/eal/include/rte_epoll.h | 116 +++ lib/eal/include/rte_interrupts.h | 673 +++++++++++++++++- lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_alarm.c | 39 +- lib/eal/linux/eal_dev.c | 65 +- lib/eal/linux/eal_interrupts.c | 294 +++++--- lib/eal/version.map | 30 + lib/ethdev/ethdev_pci.h | 2 +- lib/ethdev/rte_ethdev.c | 14 +- 132 files changed, 3797 insertions(+), 1685 deletions(-) create mode 100644 lib/eal/common/eal_common_interrupts.c delete mode 100644 lib/eal/include/rte_eal_interrupts.h create mode 100644 lib/eal/include/rte_epoll.h
Signature · 1 line
2.18.0
PATCH 1/7 eal: interrupt handle API prototypes
Defining protypes of get/set APIs for accessing/manipulating interrupt handle fields.
Internal interrupt header i.e. rte_eal_interrupt.h is rearranged, as APIs defined are moved to rte_interrupts.h and epoll specific definitions are moved to a new header rte_epoll.h. Later in the series rte_eal_interrupt.h will be removed.
--- MAINTAINERS | 1 + lib/eal/include/meson.build | 1 + lib/eal/include/rte_eal_interrupts.h | 201 --------- lib/eal/include/rte_epoll.h | 116 +++++ lib/eal/include/rte_interrupts.h | 653 ++++++++++++++++++++++++++- 5 files changed, 769 insertions(+), 203 deletions(-) create mode 100644 lib/eal/include/rte_epoll.h
MAINTAINERS +1 -0
@@ -208,6 +208,7 @@ F: app/test/test_memzone.c Interrupt Subsystem M: Harman Kalra <[email protected]> +F: lib/eal/include/rte_epoll.h F: lib/eal/*/*interrupts.* F: app/test/test_interrupts.c
lib/eal/include/meson.build +1 -0
@@ -19,6 +19,7 @@ headers += files( 'rte_eal_memconfig.h', 'rte_eal_trace.h', 'rte_errno.h', + 'rte_epoll.h', 'rte_fbarray.h', 'rte_hexdump.h', 'rte_hypervisor.h',
lib/eal/include/rte_eal_interrupts.h +0 -201
211 lines not on this page · raw message
lib/eal/include/rte_epoll.h new file +116 -0
116 lines not on this page · raw message
lib/eal/include/rte_interrupts.h +651 -2
679 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH 2/7 eal/interrupts: implement get set APIs
In reply to Harman KalraImplementing get set APIs for interrupt handle fields. To make any change to the interrupt handle fields, one should make use of these APIs.
--- lib/eal/common/eal_common_interrupts.c | 506 +++++++++++++++++++++++++ lib/eal/common/meson.build | 2 + lib/eal/include/rte_eal_interrupts.h | 6 +- lib/eal/version.map | 30 ++ 4 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 lib/eal/common/eal_common_interrupts.c
lib/eal/common/eal_common_interrupts.c new file +506 -0
@@ -0,0 +1,506 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2021 Marvell. +*/ + +#include <stdlib.h> +#include <string.h> + +#include <rte_errno.h> +#include <rte_log.h> +#include <rte_malloc.h> + +#include <rte_interrupts.h> + + +struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool from_hugepage) +{ +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct rte_intr_handle )); +if (!intr_handle) { +RTE_LOG (ERR ,EAL ,"Fail to allocate intr_handle\n" ); + rte_errno =ENOMEM ; +return NULL ; + } + +for (i =0 ; i < size; i++) { + intr_handle[i].nb_intr =RTE_MAX_RXTX_INTR_VEC_ID ; + intr_handle[i].alloc_from_hugepage = from_hugepage; + } + +return intr_handle; +} + +struct rte_intr_handle *rte_intr_handle_instance_index_get ( +struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOMEM ; +return NULL ; + } + +return &intr_handle[index]; +} + +int rte_intr_handle_instance_index_set (struct rte_intr_handle *intr_handle, +const struct rte_intr_handle *src, +int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (src ==NULL ) { +RTE_LOG (ERR ,EAL ,"Source interrupt instance unallocated\n" ); + rte_errno =EINVAL ; + goto fail; + } + +if (index <0 ) { +RTE_LOG (ERR ,EAL ,"Index cany be negative" ); + rte_errno =EINVAL ; + goto fail; + } + + intr_handle[index].fd = src->fd; + intr_handle[index].vfio_dev_fd = src->vfio_dev_fd; + intr_handle[index].type = src->type; + intr_handle[index].max_intr = src->max_intr; + intr_handle[index].nb_efd = src->nb_efd; + intr_handle[index].efd_counter_size = src->efd_counter_size; + +memcpy (intr_handle[index].efds, src->efds, src->nb_intr); +memcpy (intr_handle[index].elist, src->elist, src->nb_intr); + +return 0 ; +fail: +return rte_errno; +} + +void rte_intr_handle_instance_free (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + } + +if (intr_handle->alloc_from_hugepage) +rte_free (intr_handle); +else +free (intr_handle); +} + +int rte_intr_handle_fd_set (struct rte_intr_handle *intr_handle,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->fd = fd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_fd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->fd; +fail: +return rte_errno; +} + +int rte_intr_handle_type_set (struct rte_intr_handle *intr_handle, +enum rte_intr_handle_type type) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->type = type; + +return 0 ; +fail: +return rte_errno; +} + +enum rte_intr_handle_type rte_intr_handle_type_get ( +const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; +return RTE_INTR_HANDLE_UNKNOWN ; + } + +return intr_handle->type; +} + +int rte_intr_handle_dev_fd_set (struct rte_intr_handle *intr_handle,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->vfio_dev_fd = fd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_dev_fd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->vfio_dev_fd; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (max_intr > intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Max_intr=%d greater than PLT_MAX_RXTX_INTR_VEC_ID=%d" , + max_intr, intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->max_intr = max_intr; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->max_intr; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_efd_set (struct rte_intr_handle *intr_handle, +int nb_efd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->nb_efd = nb_efd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_efd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->nb_efd; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_intr_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->nb_intr; +fail: +return rte_errno; +} + +int rte_intr_handle_efd_counter_size_set (struct rte_intr_handle *intr_handle, +uint8_t efd_counter_size) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->efd_counter_size = efd_counter_size; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_efd_counter_size_get ( +const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->efd_counter_size; +fail: +return rte_errno; +} + +int *rte_intr_handle_efds_base (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->efds; +fail: +return NULL ; +} + +int rte_intr_handle_efds_index_get (const struct rte_intr_handle *intr_handle, +int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =EINVAL ; + goto fail; + } + +return intr_handle->efds[index]; +fail: +return rte_errno; +} + +int rte_intr_handle_efds_index_set (struct rte_intr_handle *intr_handle, +int index,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->efds[index] = fd; + +return 0 ; +fail: +return rte_errno; +} + +struct rte_epoll_event *rte_intr_handle_elist_index_get ( +struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + +return &intr_handle->elist[index]; +fail: +return NULL ; +} + +int rte_intr_handle_elist_index_set (struct rte_intr_handle *intr_handle, +int index,struct rte_epoll_event elist) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->elist[index] = elist; + +return 0 ; +fail: +return rte_errno; +} + +int *rte_intr_handle_vec_list_base (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; +return NULL ; + } + +return intr_handle->intr_vec; +} + +int rte_intr_handle_vec_list_alloc (struct rte_intr_handle *intr_handle, +const char *name,int size) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +/* Vector list already allocated */ +if (intr_handle->intr_vec) +return 0 ; + +if (size > intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , size, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->intr_vec =rte_zmalloc (name, size *sizeof (int ),0 ); +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Failed to allocate %d intr_vec" , size); + rte_errno =ENOMEM ; + goto fail; + } + + intr_handle->vec_list_size = size; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_vec_list_index_get ( +const struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Intr vector list not allocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index > intr_handle->vec_list_size) { +RTE_LOG (ERR ,EAL ,"Index %d greater than vec list size %d\n" , + index, intr_handle->vec_list_size); + rte_errno =ERANGE ; + goto fail; + } + +return intr_handle->intr_vec[index]; +fail: +return rte_errno; +} + +int rte_intr_handle_vec_list_index_set (struct rte_intr_handle *intr_handle, +int index,int vec) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Intr vector list not allocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index > intr_handle->vec_list_size) { +RTE_LOG (ERR ,EAL ,"Index %d greater than vec list size %d\n" , + index, intr_handle->vec_list_size); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->intr_vec[index] = vec; + +return 0 ; +fail: +return rte_errno; +} + +void rte_intr_handle_vec_list_free (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + } + +rte_free (intr_handle->intr_vec); + intr_handle->intr_vec =NULL ; +}
lib/eal/common/meson.build +2 -0
@@ -17,6 +17,7 @@ if is_windows 'eal_common_errno.c', 'eal_common_fbarray.c', 'eal_common_hexdump.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',
@@ -53,6 +54,7 @@ sources += files( 'eal_common_fbarray.c', 'eal_common_hexdump.c', 'eal_common_hypervisor.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',
lib/eal/include/rte_eal_interrupts.h +5 -1
@@ -55,13 +55,17 @@ struct rte_intr_handle { };void *handle;/**< device driver handle (Windows) */ }; +bool alloc_from_hugepage;enum rte_intr_handle_type type;/**< handle type */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */ +uint16_t nb_intr; +/**< Max vector count, default RTE_MAX_RXTX_INTR_VEC_ID */ int efds[RTE_MAX_RXTX_INTR_VEC_ID ];/**< intr vectors/efds mapping */ struct rte_epoll_event elist[RTE_MAX_RXTX_INTR_VEC_ID ]; -/**< intr vector epoll event */ +/**< intr vector epoll event */ +uint16_t vec_list_size;int *intr_vec;/**< intr vector number array */ };
lib/eal/version.map +30 -0
@@ -426,6 +426,36 @@ EXPERIMENTAL { # added in 21.08 rte_power_monitor_multi; # WINDOWS_NO_EXPORT + + # added in 21.11 + rte_intr_handle_fd_set; + rte_intr_handle_fd_get; + rte_intr_handle_dev_fd_set; + rte_intr_handle_dev_fd_get; + rte_intr_handle_type_set; + rte_intr_handle_type_get; + rte_intr_handle_instance_alloc; + rte_intr_handle_instance_index_get; + rte_intr_handle_instance_free; + rte_intr_handle_instance_index_set; + rte_intr_handle_event_list_update; + rte_intr_handle_max_intr_set; + rte_intr_handle_max_intr_get; + rte_intr_handle_nb_efd_set; + rte_intr_handle_nb_efd_get; + rte_intr_handle_nb_intr_get; + rte_intr_handle_efds_index_set; + rte_intr_handle_efds_index_get; + rte_intr_handle_efds_base; + rte_intr_handle_elist_index_set; + rte_intr_handle_elist_index_get; + rte_intr_handle_efd_counter_size_set; + rte_intr_handle_efd_counter_size_get; + rte_intr_handle_vec_list_alloc; + rte_intr_handle_vec_list_index_set; + rte_intr_handle_vec_list_index_get; + rte_intr_handle_vec_list_free; + rte_intr_handle_vec_list_base; }; INTERNAL {
Signature · 1 line
2.18.0
Re: [dpdk-dev] [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 4 lines · Harman Kalra
Implementing get set APIs for interrupt handle fields. To make any change to the interrupt handle fields, one should make use of these APIs.
Some global comments.
- Please merge API prototype (from patch 1) and actual implementation in a single patch.
- rte_intr_handle_ seems a rather long prefix, does it really matter to have the _handle part?
- what part of this API needs to be exported to applications? Let's hide as much as we can with __rte_internal.
Quoted 33 lines
Signed-off-by Harman Kalra <[email protected]>Acked-by Ray Kinsella <[email protected]>--- lib/eal/common/eal_common_interrupts.c | 506 +++++++++++++++++++++++++ lib/eal/common/meson.build | 2 + lib/eal/include/rte_eal_interrupts.h | 6 +- lib/eal/version.map | 30 ++ 4 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 lib/eal/common/eal_common_interrupts.clib/eal/common/eal_common_interrupts.c new file +16
-0@@ -0,0 +1,506 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2021 Marvell. +*/ + +#include <stdlib.h> +#include <string.h> + +#include <rte_errno.h> +#include <rte_log.h> +#include <rte_malloc.h> + +#include <rte_interrupts.h> + + +struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool from_hugepage)
lib/eal/common/eal_common_interrupts.c line 26
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+{ +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct rte_intr_handle ));
We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.
Wdyt?
Plus "from_hugepage" is misleading, you could be in --no-huge mode, rte_zmalloc still works.
Quoted 270 lines
lib/eal/common/eal_common_interrupts.c new file +270
-0+if (!intr_handle) { +RTE_LOG (ERR ,EAL ,"Fail to allocate intr_handle\n" ); + rte_errno =ENOMEM ; +return NULL ; + } + +for (i =0 ; i < size; i++) { + intr_handle[i].nb_intr =RTE_MAX_RXTX_INTR_VEC_ID ; + intr_handle[i].alloc_from_hugepage = from_hugepage; + } + +return intr_handle; +} + +struct rte_intr_handle *rte_intr_handle_instance_index_get ( +struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOMEM ; +return NULL ; + } + +return &intr_handle[index]; +} + +int rte_intr_handle_instance_index_set (struct rte_intr_handle *intr_handle, +const struct rte_intr_handle *src, +int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (src ==NULL ) { +RTE_LOG (ERR ,EAL ,"Source interrupt instance unallocated\n" ); + rte_errno =EINVAL ; + goto fail; + } + +if (index <0 ) { +RTE_LOG (ERR ,EAL ,"Index cany be negative" ); + rte_errno =EINVAL ; + goto fail; + } + + intr_handle[index].fd = src->fd; + intr_handle[index].vfio_dev_fd = src->vfio_dev_fd; + intr_handle[index].type = src->type; + intr_handle[index].max_intr = src->max_intr; + intr_handle[index].nb_efd = src->nb_efd; + intr_handle[index].efd_counter_size = src->efd_counter_size; + +memcpy (intr_handle[index].efds, src->efds, src->nb_intr); +memcpy (intr_handle[index].elist, src->elist, src->nb_intr); + +return 0 ; +fail: +return rte_errno; +} + +void rte_intr_handle_instance_free (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + } + +if (intr_handle->alloc_from_hugepage) +rte_free (intr_handle); +else +free (intr_handle); +} + +int rte_intr_handle_fd_set (struct rte_intr_handle *intr_handle,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->fd = fd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_fd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->fd; +fail: +return rte_errno; +} + +int rte_intr_handle_type_set (struct rte_intr_handle *intr_handle, +enum rte_intr_handle_type type) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->type = type; + +return 0 ; +fail: +return rte_errno; +} + +enum rte_intr_handle_type rte_intr_handle_type_get ( +const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; +return RTE_INTR_HANDLE_UNKNOWN ; + } + +return intr_handle->type; +} + +int rte_intr_handle_dev_fd_set (struct rte_intr_handle *intr_handle,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->vfio_dev_fd = fd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_dev_fd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->vfio_dev_fd; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (max_intr > intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Max_intr=%d greater than PLT_MAX_RXTX_INTR_VEC_ID=%d" , + max_intr, intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->max_intr = max_intr; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->max_intr; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_efd_set (struct rte_intr_handle *intr_handle, +int nb_efd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->nb_efd = nb_efd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_efd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->nb_efd; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_intr_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->nb_intr; +fail: +return rte_errno; +} + +int rte_intr_handle_efd_counter_size_set (struct rte_intr_handle *intr_handle, +uint8_t efd_counter_size) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->efd_counter_size = efd_counter_size; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_efd_counter_size_get ( +const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->efd_counter_size; +fail: +return rte_errno; +} + +int *rte_intr_handle_efds_base (struct rte_intr_handle *intr_handle) +{
lib/eal/common/eal_common_interrupts.c line 306
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->efds; +fail: +return NULL ; +}
We don't need this new accessor.
It leaks the internal representation to the API caller. If the internal representation is later changed, we would have to maintain this array thing.
The only user is drivers/raw/ifpga/ifpga_rawdev.c. This driver can build an array itself, and call rte_intr_handle_efds_index_get() as much as needed.
Quoted 89 lines
lib/eal/common/eal_common_interrupts.c new file +89
-0+ +int rte_intr_handle_efds_index_get (const struct rte_intr_handle *intr_handle, +int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =EINVAL ; + goto fail; + } + +return intr_handle->efds[index]; +fail: +return rte_errno; +} + +int rte_intr_handle_efds_index_set (struct rte_intr_handle *intr_handle, +int index,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->efds[index] = fd; + +return 0 ; +fail: +return rte_errno; +} + +struct rte_epoll_event *rte_intr_handle_elist_index_get ( +struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + +return &intr_handle->elist[index]; +fail: +return NULL ; +} + +int rte_intr_handle_elist_index_set (struct rte_intr_handle *intr_handle, +int index,struct rte_epoll_event elist) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->elist[index] = elist; + +return 0 ; +fail: +return rte_errno; +} +
lib/eal/common/eal_common_interrupts.c line 405
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+int *rte_intr_handle_vec_list_base (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; +return NULL ; + } + +return intr_handle->intr_vec; +}
rte_intr_handle_vec_list_base leaks an internal representation too.
Afaics with the whole series applied, it is always paired with a rte_intr_handle_vec_list_alloc or rte_intr_handle_vec_list_free. rte_intr_handle_vec_list_alloc could do this check itself. And rte_intr_handle_vec_list_free should already be fine, since it sets intr_vec to NULL.
Quoted 188 lines
lib/eal/common/eal_common_interrupts.c new file +101
-0+ +int rte_intr_handle_vec_list_alloc (struct rte_intr_handle *intr_handle, +const char *name,int size) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +/* Vector list already allocated */ +if (intr_handle->intr_vec) +return 0 ; + +if (size > intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , size, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->intr_vec =rte_zmalloc (name, size *sizeof (int ),0 ); +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Failed to allocate %d intr_vec" , size); + rte_errno =ENOMEM ; + goto fail; + } + + intr_handle->vec_list_size = size; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_vec_list_index_get ( +const struct rte_intr_handle *intr_handle,int index) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Intr vector list not allocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index > intr_handle->vec_list_size) { +RTE_LOG (ERR ,EAL ,"Index %d greater than vec list size %d\n" , + index, intr_handle->vec_list_size); + rte_errno =ERANGE ; + goto fail; + } + +return intr_handle->intr_vec[index]; +fail: +return rte_errno; +} + +int rte_intr_handle_vec_list_index_set (struct rte_intr_handle *intr_handle, +int index,int vec) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Intr vector list not allocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index > intr_handle->vec_list_size) { +RTE_LOG (ERR ,EAL ,"Index %d greater than vec list size %d\n" , + index, intr_handle->vec_list_size); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->intr_vec[index] = vec; + +return 0 ; +fail: +return rte_errno; +} + +void rte_intr_handle_vec_list_free (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + } + +rte_free (intr_handle->intr_vec); + intr_handle->intr_vec =NULL ; +}lib/eal/common/meson.build +2
-0@@ -17,6 +17,7 @@ if is_windows 'eal_common_errno.c', 'eal_common_fbarray.c', 'eal_common_hexdump.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',@@ -53,6 +54,7 @@ sources += files( 'eal_common_fbarray.c', 'eal_common_hexdump.c', 'eal_common_hypervisor.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',lib/eal/include/rte_eal_interrupts.h +5
-1@@ -55,13 +55,17 @@ struct rte_intr_handle { };void *handle;/**< device driver handle (Windows) */ }; +bool alloc_from_hugepage;enum rte_intr_handle_type type;/**< handle type */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */ +uint16_t nb_intr; +/**< Max vector count, default RTE_MAX_RXTX_INTR_VEC_ID */ int efds[RTE_MAX_RXTX_INTR_VEC_ID ];/**< intr vectors/efds mapping */ struct rte_epoll_event elist[RTE_MAX_RXTX_INTR_VEC_ID ]; -/**< intr vector epoll event */ +/**< intr vector epoll event */ +uint16_t vec_list_size;int *intr_vec;/**< intr vector number array */ };lib/eal/version.map +30
-1@@ -426,6 +426,36 @@ EXPERIMENTAL { # added in 21.08 rte_power_monitor_multi; # WINDOWS_NO_EXPORT + + # added in 21.11 + rte_intr_handle_fd_set; + rte_intr_handle_fd_get; + rte_intr_handle_dev_fd_set; + rte_intr_handle_dev_fd_get; + rte_intr_handle_type_set; + rte_intr_handle_type_get; + rte_intr_handle_instance_alloc; + rte_intr_handle_instance_index_get; + rte_intr_handle_instance_free; + rte_intr_handle_instance_index_set; + rte_intr_handle_event_list_update; + rte_intr_handle_max_intr_set; + rte_intr_handle_max_intr_get; + rte_intr_handle_nb_efd_set; + rte_intr_handle_nb_efd_get; + rte_intr_handle_nb_intr_get; + rte_intr_handle_efds_index_set; + rte_intr_handle_efds_index_get; + rte_intr_handle_efds_base; + rte_intr_handle_elist_index_set; + rte_intr_handle_elist_index_get; + rte_intr_handle_efd_counter_size_set; + rte_intr_handle_efd_counter_size_get; + rte_intr_handle_vec_list_alloc; + rte_intr_handle_vec_list_index_set; + rte_intr_handle_vec_list_index_get; + rte_intr_handle_vec_list_free; + rte_intr_handle_vec_list_base; }; INTERNAL { --2.18.0
Signature · 1 line
David Marchand
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Hi David,
Thanks for the review.
Please see my comments inline.
Quoted 18 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, September 28, 2021 9:17 PM
To: Harman Kalra <[email protected]>
Cc: dev <[email protected]>; Ray Kinsella <[email protected]>
Subject: [EXT] Re: [dpdk-dev] [PATCH v1 2/7] eal/interrupts: implement get set APIsExternal Email
----------------------------------------------------------------------
Quoted 4 lines · Harman Kalra
Implementing get set APIs for interrupt handle fields.
To make any change to the interrupt handle fields, one should make use of these APIs.
Quoted 4 lines
Some global comments.
- Please merge API prototype (from patch 1) and actual implementation in a single patch.
<HK> Sure, will do.
Quoted 2 lines
-
rte_intr_handle_seems a rather long prefix, does it really matter to have the_handlepart?
<HK> Will fix the API names.
Quoted 2 lines
- what part of this API needs to be exported to applications? Let's hide as much as we can with
__rte_internal.
<HK> I will make all the APIs (new and some old) not used in test suite and example app as __rte_internal.
Quoted 54 lines
Quoted 7 lines
Signed-off-by Harman Kalra <[email protected]>Acked-by Ray Kinsella <[email protected]>--- lib/eal/common/eal_common_interrupts.c | 506+++++++++++++++++++++++++
Quoted 30 lines
lib/eal/common/meson.build | 2 + lib/eal/include/rte_eal_interrupts.h | 6 +- lib/eal/version.map | 30 ++ 4 files changed, 543 insertions(+), 1 deletion(-) create mode 100644
lib/eal/common/eal_common_interrupts.clib/eal/common/eal_common_interrupts.c new file +17
-0@@ -0,0 +1,506 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2021 Marvell. +*/ + +#include <stdlib.h> +#include <string.h> + +#include <rte_errno.h> +#include <rte_log.h> +#include <rte_malloc.h> + +#include <rte_interrupts.h> + + +struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool +from_hugepage) {lib/eal/common/eal_common_interrupts.c line 27
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct +rte_intr_handle ));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.
Wdyt?
Quoted 2 lines
Plus "
from_hugepage" is misleading, you could be in --no-huge mode,rte_zmallocstill works.
<HK> In mellanox 5 driver interrupt handle instance is freed in destructor " mlx5_pmd_interrupt_handler_uninstall()" while DPDK memory allocators are already cleaned up in "rte_eal_cleanup". Hence I allocated interrupt instances for such cases from normal heap. There could be other such cases so I think its ok to keep this support.
Regarding name, I will change " from_hugepage" to "dpdk_allocator".
As per suggestion from Dmitry, I will replace bool arg with a flag variable, to support more such configurations in future.
Quoted 285 lines
Quoted 19 lines
lib/eal/common/eal_common_interrupts.c new file +17
-0+if (!intr_handle) { +RTE_LOG (ERR ,EAL ,"Fail to allocate intr_handle\n" ); + rte_errno =ENOMEM ; +return NULL ; + } + +for (i =0 ; i < size; i++) { + intr_handle[i].nb_intr =RTE_MAX_RXTX_INTR_VEC_ID ; + intr_handle[i].alloc_from_hugepage = from_hugepage; + } + +return intr_handle; +} + +struct rte_intr_handle *rte_intr_handle_instance_index_get ( +struct rte_intr_handle *intr_handle, +int index) {lib/eal/common/eal_common_interrupts.c
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOMEM ; +return NULL ; + } + +return &intr_handle[index]; +} + +int rte_intr_handle_instance_index_set(struct rte_intr_handle
*intr_handle,Quoted 131 lines
lib/eal/common/eal_common_interrupts.c new file +131
-0+const struct rte_intr_handle *src, + int index) { + if (intr_handle == NULL) { + RTE_LOG(ERR, EAL, "Interrupt instance unallocated\n"); + rte_errno =ENOTSUP ; + goto fail; + } + +if (src ==NULL ) { +RTE_LOG (ERR ,EAL ,"Source interrupt instance unallocated\n" ); + rte_errno =EINVAL ; + goto fail; + } + +if (index <0 ) { +RTE_LOG (ERR ,EAL ,"Index cany be negative" ); + rte_errno =EINVAL ; + goto fail; + } + + intr_handle[index].fd = src->fd; + intr_handle[index].vfio_dev_fd = src->vfio_dev_fd; + intr_handle[index].type = src->type; + intr_handle[index].max_intr = src->max_intr; + intr_handle[index].nb_efd = src->nb_efd; + intr_handle[index].efd_counter_size = src->efd_counter_size; + +memcpy (intr_handle[index].efds, src->efds, src->nb_intr); +memcpy (intr_handle[index].elist, src->elist, src->nb_intr); + +return 0 ; +fail: +return rte_errno; +} + +void rte_intr_handle_instance_free (struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + } + +if (intr_handle->alloc_from_hugepage) +rte_free (intr_handle); +else +free (intr_handle); +} + +int rte_intr_handle_fd_set (struct rte_intr_handle *intr_handle,int +fd) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->fd = fd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_fd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->fd; +fail: +return rte_errno; +} + +int rte_intr_handle_type_set (struct rte_intr_handle *intr_handle, +enum rte_intr_handle_type type) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->type = type; + +return 0 ; +fail: +return rte_errno; +} + +enum rte_intr_handle_type rte_intr_handle_type_get ( +const struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; +return RTE_INTR_HANDLE_UNKNOWN ; + } + +return intr_handle->type; +} + +int rte_intr_handle_dev_fd_set (struct rte_intr_handle *intr_handle, +int fd) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->vfio_dev_fd = fd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_dev_fd_get (const struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->vfio_dev_fd; +fail: +return rte_errno; +} +lib/eal/common/eal_common_interrupts.c
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+int rte_intr_handle_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (max_intr > intr_handle->nb_intr) { + RTE_LOG(ERR, EAL, "Max_intr=%d greater thanPLT_MAX_RXTX_INTR_VEC_ID=%d",
Quoted 57 lines
lib/eal/common/eal_common_interrupts.c new file +57
-0+ max_intr, intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->max_intr = max_intr; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_get (const struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->max_intr; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_efd_set (struct rte_intr_handle *intr_handle, +int nb_efd) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->nb_efd = nb_efd; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_efd_get (const struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->nb_efd; +fail: +return rte_errno; +} + +int rte_intr_handle_nb_intr_get (const struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" );lib/eal/common/eal_common_interrupts.c
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+ rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->nb_intr; +fail: +return rte_errno; +} + +int rte_intr_handle_efd_counter_size_set(struct rte_intr_handle
*intr_handle,Quoted 29 lines
lib/eal/common/eal_common_interrupts.c new file +29
-0+ uint8_t efd_counter_size) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + + intr_handle->efd_counter_size = efd_counter_size; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_efd_counter_size_get ( +const struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->efd_counter_size; +fail: +return rte_errno; +} + +int *rte_intr_handle_efds_base (struct rte_intr_handle *intr_handle) {lib/eal/common/eal_common_interrupts.c line 306
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->efds; +fail: +return NULL ; +}We don't need this new accessor.
It leaks the internal representation to the API caller.
If the internal representation is later changed, we would have to maintain this array thing.
Quoted 3 lines
The only user is
drivers/raw/ifpga/ifpga_rawdev.c. This driver can build an array itself, and callrte_intr_handle_efds_index_get()as much as needed.
<HK> Yes, it’s a leak I will remove these base APIs and fix the ifpga_rawdev.c driver.
Quoted 105 lines
lib/eal/common/eal_common_interrupts.c line 303
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c new file +2
-0+ +int rte_intr_handle_efds_index_get(const struct rte_intr_handle
*intr_handle,Quoted 85 lines
lib/eal/common/eal_common_interrupts.c new file +85
-0+ int index) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =EINVAL ; + goto fail; + } + +return intr_handle->efds[index]; +fail: +return rte_errno; +} + +int rte_intr_handle_efds_index_set (struct rte_intr_handle *intr_handle, +int index,int fd) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->efds[index] = fd; + +return 0 ; +fail: +return rte_errno; +} + +struct rte_epoll_event *rte_intr_handle_elist_index_get ( +struct rte_intr_handle *intr_handle, +int index) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + +return &intr_handle->elist[index]; +fail: +return NULL ; +} + +int rte_intr_handle_elist_index_set (struct rte_intr_handle *intr_handle, +int index,struct rte_epoll_event +elist) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index >= intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , index, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->elist[index] = elist; + +return 0 ; +fail: +return rte_errno; +} +lib/eal/common/eal_common_interrupts.c line 405
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+int *rte_intr_handle_vec_list_base (const struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; +return NULL ; + } + +return intr_handle->intr_vec; +}
rte_intr_handle_vec_list_baseleaks an internal representation too.
Quoted 5 lines
Afaics with the whole series applied, it is always paired with a
rte_intr_handle_vec_list_allocorrte_intr_handle_vec_list_free.rte_intr_handle_vec_list_alloccould do this check itself. Andrte_intr_handle_vec_list_freeshould already be fine, since it setsintr_vecto NULL.
<HK> Yes, base API not required.
Thanks
Harman
Quoted 199 lines
Quoted 57 lines
lib/eal/common/eal_common_interrupts.c new file +52
-0+ +int rte_intr_handle_vec_list_alloc (struct rte_intr_handle *intr_handle, +const char *name,int size) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +/* Vector list already allocated */ +if (intr_handle->intr_vec) +return 0 ; + +if (size > intr_handle->nb_intr) { +RTE_LOG (ERR ,EAL ,"Invalid size %d, max limit %d\n" , size, + intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->intr_vec =rte_zmalloc (name, size *sizeof (int ),0 ); +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Failed to allocate %d intr_vec" , size); + rte_errno =ENOMEM ; + goto fail; + } + + intr_handle->vec_list_size = size; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_vec_list_index_get ( +const struct rte_intr_handle *intr_handle,int +index) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Intr vector list not allocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index > intr_handle->vec_list_size) { +RTE_LOG (ERR ,EAL ,"Index %d greater than vec list size %d\n" , + index, intr_handle->vec_list_size);lib/eal/common/eal_common_interrupts.c
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+ rte_errno =ERANGE ; + goto fail; + } + +return intr_handle->intr_vec[index]; +fail: +return rte_errno; +} + +int rte_intr_handle_vec_list_index_set(struct rte_intr_handle
*intr_handle,Quoted 65 lines
lib/eal/common/eal_common_interrupts.c new file +37
-0+ int index, int vec) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (!intr_handle->intr_vec) { +RTE_LOG (ERR ,EAL ,"Intr vector list not allocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (index > intr_handle->vec_list_size) { +RTE_LOG (ERR ,EAL ,"Index %d greater than vec list size %d\n" , + index, intr_handle->vec_list_size); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->intr_vec[index] = vec; + +return 0 ; +fail: +return rte_errno; +} + +void rte_intr_handle_vec_list_free (struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + } + +rte_free (intr_handle->intr_vec); + intr_handle->intr_vec =NULL ; +}lib/eal/common/meson.build +2
-0@@ -17,6 +17,7 @@ if is_windows 'eal_common_errno.c', 'eal_common_fbarray.c', 'eal_common_hexdump.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',@@ -53,6 +54,7 @@ sources += files( 'eal_common_fbarray.c', 'eal_common_hexdump.c', 'eal_common_hypervisor.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',lib/eal/include/rte_eal_interrupts.h +0
-0@@ -55,13 +55,17 @@ struct rte_intr_handle { };void *handle;/**< device driver handle (Windows) */ lib/eal/include/rte_eal_interrupts.h struct rte_intr_handle { · line 66
Quoted 10 lines
lib/eal/include/rte_eal_interrupts.h +4
-0}; +bool alloc_from_hugepage;enum rte_intr_handle_type type;/**< handle type */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */ +uint16_t nb_intr; +/**< Max vector count, default +RTE_MAX_RXTX_INTR_VEC_ID */ int efds[RTE_MAX_RXTX_INTR_VEC_ID ];/**< intr vectors/efds mapping */
Quoted 49 lines
lib/eal/include/rte_eal_interrupts.h +2
-1struct rte_epoll_event elist[RTE_MAX_RXTX_INTR_VEC_ID ]; -/**< intr vector epoll event */ +/**< intr vector epoll event */ +uint16_t vec_list_size;int *intr_vec;/**< intr vector number array */ };lib/eal/version.map index renamed from lib/eal/version.map +0
-0
beeb986adc..56108d0998100644lib/eal/version.map +30
-1@@ -426,6 +426,36 @@ EXPERIMENTAL { # added in 21.08 rte_power_monitor_multi; # WINDOWS_NO_EXPORT + + # added in 21.11 + rte_intr_handle_fd_set; + rte_intr_handle_fd_get; + rte_intr_handle_dev_fd_set; + rte_intr_handle_dev_fd_get; + rte_intr_handle_type_set; + rte_intr_handle_type_get; + rte_intr_handle_instance_alloc; + rte_intr_handle_instance_index_get; + rte_intr_handle_instance_free; + rte_intr_handle_instance_index_set; + rte_intr_handle_event_list_update; + rte_intr_handle_max_intr_set; + rte_intr_handle_max_intr_get; + rte_intr_handle_nb_efd_set; + rte_intr_handle_nb_efd_get; + rte_intr_handle_nb_intr_get; + rte_intr_handle_efds_index_set; + rte_intr_handle_efds_index_get; + rte_intr_handle_efds_base; + rte_intr_handle_elist_index_set; + rte_intr_handle_elist_index_get; + rte_intr_handle_efd_counter_size_set; + rte_intr_handle_efd_counter_size_get; + rte_intr_handle_vec_list_alloc; + rte_intr_handle_vec_list_index_set; + rte_intr_handle_vec_list_index_get; + rte_intr_handle_vec_list_free; + rte_intr_handle_vec_list_base; }; INTERNAL { --Quoted 2 lines
2.18.0
--
David Marchand
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 19 lines · Harman Kalra
Quoted 19 lines
lib/eal/common/eal_common_interrupts.c
Quoted 13 lines
lib/eal/common/eal_common_interrupts.c new file +13
-0+struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool +from_hugepage) { +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct +rte_intr_handle ));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.
Wdyt?
Quoted 8 lines
Quoted 2 lines
Plus "
from_hugepage" is misleading, you could be in --no-huge mode,rte_zmallocstill works.<HK> In mellanox 5 driver interrupt handle instance is freed in destructor "
mlx5_pmd_interrupt_handler_uninstall()" while DPDK memory allocators are already cleaned up in "rte_eal_cleanup". Hence I allocated interrupt instances for such cases from normal heap. There could be other such cases so I think its ok to keep this support.
This is surprising.
Why would the mlx5 driver wait to release in a destructor? It should be done once no interrupt handler is necessary (like when stopping all ports), and that would be before rte_eal_cleanup().
Signature · 1 line
David Marchand
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
04/10/2021 11:57, David Marchand:
Quoted 29 lines · Harman Kalra
Quoted 19 lines
Quoted 19 lines
lib/eal/common/eal_common_interrupts.c
Quoted 13 lines
lib/eal/common/eal_common_interrupts.c new file +13
-0+struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool +from_hugepage) { +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct +rte_intr_handle ));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.
Wdyt?Quoted 8 lines
Quoted 2 lines
Plus "
from_hugepage" is misleading, you could be in --no-huge mode,rte_zmallocstill works.<HK> In mellanox 5 driver interrupt handle instance is freed in destructor "
mlx5_pmd_interrupt_handler_uninstall()" while DPDK memory allocators are already cleaned up in "rte_eal_cleanup". Hence I allocated interrupt instances for such cases from normal heap. There could be other such cases so I think its ok to keep this support.
Quoted 4 lines
This is surprising.
Why would the mlx5 driver wait to release in a destructor? It should be done once no interrupt handler is necessary (like when stopping all ports), and that would be beforerte_eal_cleanup().
I agree with David.
I prefer a simpler API which always use rte_malloc,
and make sure interrupts are always handled betweenrte_eal_init and rte_eal_cleanup.
The mlx5 PMD could be reworked to match this requirement.
In any case we should not any memory management in constructors/destructors.
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 49 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 12, 2021 8:53 PM
To: Harman Kalra <[email protected]>
Cc: Raslan Darawsheh <[email protected]>; [email protected]; Ray Kinsella <[email protected]>; Dmitry Kozlyuk <[email protected]>; David Marchand <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs04/10/2021 11:57, David Marchand:
Quoted 1 line
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra <[email protected]>
Quoted 28 lines · wrote:
Quoted 19 lines
Quoted 19 lines
lib/eal/common/eal_common_interrupts.c
Quoted 13 lines
lib/eal/common/eal_common_interrupts.c new file +13
-0+struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool +from_hugepage) { +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct +rte_intr_handle ));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.
Wdyt?Quoted 8 lines
Quoted 2 lines
Plus "
from_hugepage" is misleading, you could be in --no-huge mode,rte_zmallocstill works.<HK> In mellanox 5 driver interrupt handle instance is freed in destructor "
mlx5_pmd_interrupt_handler_uninstall()" while DPDK memory allocators are already cleaned up in "rte_eal_cleanup". Hence I allocated interrupt instances for such cases from normal heap. There could be other such cases so I think its ok to keep this support.Quoted 4 lines
This is surprising.
Why would the mlx5 driver wait to release in a destructor? It should be done once no interrupt handler is necessary (like when stopping all ports), and that would be beforerte_eal_cleanup().
Quoted 6 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initandrte_eal_cleanup.
The mlx5 PMD could be reworked to match this requirement.
In any case we should not any memory management in constructors/destructors.
Hi Thomas, David
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init.
Not sure what all challenges we may face in moving alarm_init after memory_init as it might break some subsystem inits.
Other option could be to allocate interrupt instance for timerfd on first alarm_setup call.
2. Currently interrupt handle field inside struct rte_pci_device is static which is changed to a pointer in this series(as struct rte_intr_handle is hidden inside a c file and size is unknown outside). I am allocating the memory for this interrupt instance inside "rte_pci_probe_one_driver()" just before "pci_vfio_map_resource()" which sets up vfio resources and calls " pci_vfio_setup_interrupts()" which setups the interrupt support. Here challenge is "rte_bus_probe()" also gets called before "rte_eal_memory_init()".
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap APIs.
Thanks
Harman
Quoted 1 line
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 81 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Harman Kalra
Sent: Wednesday, October 13, 2021 11:24 PM
To: Thomas Monjalon <[email protected]>
Cc: Raslan Darawsheh <[email protected]>; [email protected]; Ray Kinsella <[email protected]>; Dmitry Kozlyuk <[email protected]>; David Marchand <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIsQuoted 47 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 12, 2021 8:53 PM
To: Harman Kalra <[email protected]>
Cc: Raslan Darawsheh <[email protected]>; [email protected]; Ray Kinsella <[email protected]>; Dmitry Kozlyuk <[email protected]>; David Marchand <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts:
implement get set APIs04/10/2021 11:57, David Marchand:
Quoted 1 line
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra <[email protected]>
Quoted 28 lines · wrote:
Quoted 19 lines
Quoted 19 lines
lib/eal/common/eal_common_interrupts.c
Quoted 13 lines
lib/eal/common/eal_common_interrupts.c new file +13
-0+struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool +from_hugepage) { +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct +rte_intr_handle ));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.
Wdyt?Quoted 8 lines
Quoted 2 lines
Plus "
from_hugepage" is misleading, you could be in --no-huge mode,rte_zmallocstill works.<HK> In mellanox 5 driver interrupt handle instance is freed in destructor "
mlx5_pmd_interrupt_handler_uninstall()" while DPDK memory allocators are already cleaned up in "rte_eal_cleanup". Hence I allocated interrupt instances for such cases from normal heap. There could be other such cases so I think its ok to keep this support.Quoted 4 lines
This is surprising.
Why would the mlx5 driver wait to release in a destructor? It should be done once no interrupt handler is necessary (like when stopping all ports), and that would be beforerte_eal_cleanup().Quoted 6 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initandrte_eal_cleanup. The mlx5 PMD could be reworked to match this requirement.
In any case we should not any memory management in constructors/destructors.Hi Thomas, David
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init.
Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsystem inits.
Other option could be to allocate interrupt instance for timerfd on firstalarm_setupcall.
Quoted 8 lines
2. Currently interrupt handle field inside struct
rte_pci_deviceis static which is changed to a pointer in thisseries(as struct rte_intr_handle is hidden inside a c file and size is unknown outside).
I am allocating the memory for this interrupt instance inside "rte_pci_probe_one_driver()" just before "pci_vfio_map_resource()" which sets up vfio resources and calls "pci_vfio_setup_interrupts()" which setups the interrupt support. Here challenge is "rte_bus_probe()" also gets called before "rte_eal_memory_init()".
Sorry my bad, bus probing happens after "rte_eal_memory_init()", so second point Is invalid.
Quoted 12 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap APIs.
Thanks
HarmanQuoted 1 line
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
13/10/2021 19:57, Harman Kalra:
Quoted 44 lines
From: dev <[email protected]> On Behalf Of Harman Kalra
Quoted 43 lines
From: Thomas Monjalon <[email protected]>
Quoted 42 lines
04/10/2021 11:57, David Marchand:
Quoted 1 line
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra <[email protected]>
Quoted 28 lines · wrote:
Quoted 19 lines
Quoted 19 lines
Review
Quoted 13 lines
(quoted diff) +13
-0+struct rte_intr_handle *rte_intr_handle_instance_alloc(int size, + bool +from_hugepage) { + struct rte_intr_handle *intr_handle; + int i; + + if (from_hugepage) + intr_handle = rte_zmalloc(NULL, + size * sizeof(struct rte_intr_handle), + 0); + else + intr_handle = calloc(1, size * sizeof(struct + rte_intr_handle));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.
Wdyt?Quoted 8 lines
Quoted 2 lines
Plus "
from_hugepage" is misleading, you could be in --no-huge mode,rte_zmallocstill works.<HK> In mellanox 5 driver interrupt handle instance is freed in destructor "
mlx5_pmd_interrupt_handler_uninstall()" while DPDK memory allocators are already cleaned up in "rte_eal_cleanup". Hence I allocated interrupt instances for such cases from normal heap. There could be other such cases so I think its ok to keep this support.Quoted 4 lines
This is surprising.
Why would the mlx5 driver wait to release in a destructor? It should be done once no interrupt handler is necessary (like when stopping all ports), and that would be beforerte_eal_cleanup().I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initandrte_eal_cleanup. The mlx5 PMD could be reworked to match this requirement.
In any case we should not any memory management in constructors/destructors.
For info, Dmitry is going to send a fix for mlx5.
Quoted 10 lines
Quoted 10 lines
Hi Thomas, David
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init.
Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsystem inits.
Other option could be to allocate interrupt instance for timerfd on firstalarm_setupcall.
Indeed it is an issue.
[...]
Quoted 4 lines
Quoted 4 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap APIs.
Could you use rte_malloc in these drivers?
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
13/10/2021 20:52, Thomas Monjalon:
Quoted 23 lines
13/10/2021 19:57, Harman Kalra:
Quoted 22 lines
From: dev <[email protected]> On Behalf Of Harman Kalra
Quoted 21 lines
From: Thomas Monjalon <[email protected]>
Quoted 20 lines
04/10/2021 11:57, David Marchand:
Quoted 1 line
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra <[email protected]>
Quoted 17 lines · wrote:
Quoted 17 lines
Quoted 17 lines
Review
Quoted 13 lines
(quoted diff) +13
-0+struct rte_intr_handle *rte_intr_handle_instance_alloc(int size, + bool +from_hugepage) { + struct rte_intr_handle *intr_handle; + int i; + + if (from_hugepage) + intr_handle = rte_zmalloc(NULL, + size * sizeof(struct rte_intr_handle), + 0); + else + intr_handle = calloc(1, size * sizeof(struct + rte_intr_handle));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.
[...]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initandrte_eal_cleanup.
[...]
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init.
Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsystem inits.
Other option could be to allocate interrupt instance for timerfd on firstalarm_setupcall.Indeed it is an issue.
Quoted 8 lines
[...]
Quoted 4 lines
Quoted 4 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap APIs.
Could you use
rte_mallocin these drivers?
If we take the direction of 2 different allocations mode for the interrupts, I suggest we make it automatic without any API parameter.
We don't have any function to check rte_malloc readiness I think. But we can detect whether shared memory is ready with this check:
rte_eal_get_configuration()->mem_config->magic == RTE_MAGIC
This check is true at the end of rte_eal_init, so it is false during probing. Would it be enough? Or should we implement rte_malloc_is_ready()?
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 64 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, October 14, 2021 1:53 PM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Ray Kinsella <[email protected]>; Dmitry Kozlyuk <[email protected]>; David Marchand <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs13/10/2021 20:52, Thomas Monjalon:
Quoted 8 lines
13/10/2021 19:57, Harman Kalra:
Quoted 7 lines
From: dev <[email protected]> On Behalf Of Harman Kalra
Quoted 6 lines
From: Thomas Monjalon <[email protected]>
Quoted 5 lines
04/10/2021 11:57, David Marchand:
Quoted 2 lines
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra
<[email protected]>Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
+struct
rte_intr_handle*rte_intr_handle_instance_alloc(intsize,
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Review
Quoted 13 lines
(quoted diff) +13
-0+ +bool +from_hugepage) { + struct rte_intr_handle *intr_handle; + int i; + + if (from_hugepage) + intr_handle = rte_zmalloc(NULL, + size * sizeof(struct rte_intr_handle), + 0); + else + intr_handle = calloc(1, size * + sizeof(struct rte_intr_handle));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.[...]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initand
rte_eal_cleanup.
[...]Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init.
Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsystem inits. Other option could be to allocate interrupt instance for timerfd on firstalarm_setupcall.Indeed it is an issue.
Quoted 8 lines
[...]
Quoted 4 lines
Quoted 4 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap APIs.
Could you use
rte_mallocin these drivers?
Quoted 7 lines
If we take the direction of 2 different allocations mode for the interrupts, I suggest we make it automatic without any API parameter.
We don't have any function to checkrte_mallocreadiness I think. But we can detect whether shared memory is ready with this check:
rte_eal_get_configuration()->mem_config->magic ==RTE_MAGICThis check is true at the end ofrte_eal_init, so it is false during probing. Would it be enough? Or should we implementrte_malloc_is_ready()?
Hi Thomas,
It's a very good suggestion. Let's implement "rte_malloc_is_ready()" which could be as simple as " rte_eal_get_configuration()->mem_config->magic == RTE_MAGIC" check. There may be more consumers for this API in future.
If we are making it automatic detection, shall we now even have argument to this alloc API?
I added a flags argument (32 bit) in latest series where each bit of this flag can be an allocation capability. I used two bits for discriminating between glibc malloc and rte_malloc. Shall we keep it or drop it?
David, Dmitry please share your thoughts.
Thanks
Harman
Quoted 1 line
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 5 lines · Harman Kalra
If we are making it automatic detection, shall we now even have argument to this alloc API?
I added a flags argument (32 bit) in latest series where each bit of this flag can be an allocation capability. I used two bits for discriminating between glibc malloc andrte_malloc. Shall we keep it or drop it?David, Dmitry please share your thoughts.
I don't have ideas of how we would extend allocations of such object, so I am unsure.
In doubt, I would keep this flags field, and validate it's always 0 (as mentioned in my reply on ABI).
Signature · 1 line
David Marchand
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
In reply to Harman Kalra14/10/2021 11:31, Harman Kalra:
Quoted 62 lines
From: Thomas Monjalon <[email protected]>
Quoted 53 lines
13/10/2021 20:52, Thomas Monjalon:
Quoted 8 lines
13/10/2021 19:57, Harman Kalra:
Quoted 7 lines
From: dev <[email protected]> On Behalf Of Harman Kalra
Quoted 6 lines
From: Thomas Monjalon <[email protected]>
Quoted 5 lines
04/10/2021 11:57, David Marchand:
Quoted 2 lines
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra
<[email protected]>Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
+struct
rte_intr_handle*rte_intr_handle_instance_alloc(intsize,
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Review
Quoted 13 lines
(quoted diff) +13
-0+ +bool +from_hugepage) { + struct rte_intr_handle *intr_handle; + int i; + + if (from_hugepage) + intr_handle = rte_zmalloc(NULL, + size * sizeof(struct rte_intr_handle), + 0); + else + intr_handle = calloc(1, size * + sizeof(struct rte_intr_handle));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.[...]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initand
rte_eal_cleanup.
[...]Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init.
Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsystem inits. Other option could be to allocate interrupt instance for timerfd on firstalarm_setupcall.Indeed it is an issue.
Quoted 8 lines
[...]
Quoted 4 lines
Quoted 4 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap APIs.
Could you use
rte_mallocin these drivers?Quoted 7 lines
If we take the direction of 2 different allocations mode for the interrupts, I suggest we make it automatic without any API parameter.
We don't have any function to checkrte_mallocreadiness I think. But we can detect whether shared memory is ready with this check:
rte_eal_get_configuration()->mem_config->magic ==RTE_MAGICThis check is true at the end ofrte_eal_init, so it is false during probing. Would it be enough? Or should we implementrte_malloc_is_ready()?
Quoted 5 lines
Hi Thomas,
It's a very good suggestion. Let's implement "
rte_malloc_is_ready()" which could be as simple as " rte_eal_get_configuration()->mem_config->magic ==RTE_MAGIC" check. There may be more consumers for this API in future.
You cannot rely on the magic because it is set only after probing. For such API you need to have another internal flag to check that malloc is setup.
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 80 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, October 14, 2021 3:11 PM
To: Harman Kalra <[email protected]>
Cc: David Marchand <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>; Ray Kinsella <[email protected]>; Dmitry Kozlyuk <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs14/10/2021 11:31, Harman Kalra:
Quoted 52 lines
From: Thomas Monjalon <[email protected]>
Quoted 51 lines
13/10/2021 20:52, Thomas Monjalon:
Quoted 9 lines
13/10/2021 19:57, Harman Kalra:
Quoted 8 lines
From: dev <[email protected]> On Behalf Of Harman Kalra
Quoted 7 lines
From: Thomas Monjalon <[email protected]>
Quoted 6 lines
04/10/2021 11:57, David Marchand:
Quoted 2 lines
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra
<[email protected]>Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+struct rte_intr_handle +*rte_intr_handle_instance_alloc(intsize,
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Review
Quoted 13 lines
(quoted diff) +13
-0+ +bool +from_hugepage) { + struct rte_intr_handle *intr_handle; + int i; + + if (from_hugepage) + intr_handle = rte_zmalloc(NULL, + size * sizeof(struct rte_intr_handle), + 0); + else + intr_handle = calloc(1, size * + sizeof(struct rte_intr_handle));We can call DPDK allocator in all cases. That would avoid headaches on why multiprocess does not work in some rarely tested cases.
[...]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initand
rte_eal_cleanup.
[...]Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init. Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsystem inits. Other option could be to allocate interrupt instance for timerfd on firstalarm_setupcall.Indeed it is an issue.
[...]
Quoted 4 lines
Quoted 4 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap
APIs.
Quoted 13 lines
Quoted 10 lines
Quoted 2 lines
Could you use
rte_mallocin these drivers?If we take the direction of 2 different allocations mode for the interrupts, I suggest we make it automatic without any API parameter. We don't have any function to check
rte_mallocreadiness I think. But we can detect whether shared memory is ready with this check:
rte_eal_get_configuration()->mem_config->magic ==RTE_MAGICThis check is true at the end ofrte_eal_init, so it is false during probing. Would it be enough? Or should we implementrte_malloc_is_ready()?Hi Thomas,
Quoted 8 lines
Quoted 4 lines
It's a very good suggestion. Let's implement "
rte_malloc_is_ready()" which could be as simple as " rte_eal_get_configuration()->mem_config- magic ==RTE_MAGIC" check.
There may be more consumers for this API in future.You cannot rely on the magic because it is set only after probing. For such API you need to have another internal flag to check that malloc is setup.
Yeah, got that. You mean in case of bus probing although rte_malloc is setup but eal_mcfg_complete() is calledt done yet. So we should set another malloc specific flag at the end of rte_eal_memory_init(). Correct?
But just for understanding, as David suggested that we preserve keep this flag then why not use it, have rte_malloc and malloc bits and make a decision. Let driver has the flexibility to choose. Do you see any harm in this?
Thanks
Harman
Quoted 1 line
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
14/10/2021 12:31, Harman Kalra:
Quoted 73 lines
From: Thomas Monjalon <[email protected]>
Quoted 72 lines
14/10/2021 11:31, Harman Kalra:
Quoted 52 lines
From: Thomas Monjalon <[email protected]>
Quoted 51 lines
13/10/2021 20:52, Thomas Monjalon:
Quoted 9 lines
13/10/2021 19:57, Harman Kalra:
Quoted 8 lines
From: dev <[email protected]> On Behalf Of Harman Kalra
Quoted 7 lines
From: Thomas Monjalon <[email protected]>
Quoted 6 lines
04/10/2021 11:57, David Marchand:
Quoted 2 lines
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra
<[email protected]>Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+struct rte_intr_handle +*rte_intr_handle_instance_alloc(intsize,
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Review
Quoted 13 lines
(quoted diff) +13
-0+ +bool +from_hugepage) { + struct rte_intr_handle *intr_handle; + int i; + + if (from_hugepage) + intr_handle = rte_zmalloc(NULL, + size * sizeof(struct rte_intr_handle), + 0); + else + intr_handle = calloc(1, size * + sizeof(struct rte_intr_handle));We can call DPDK allocator in all cases. That would avoid headaches on why multiprocess does not work in some rarely tested cases.
[...]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initand
rte_eal_cleanup.
[...]Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init. Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsystem inits. Other option could be to allocate interrupt instance for timerfd on firstalarm_setupcall.Indeed it is an issue.
[...]
Quoted 4 lines
Quoted 4 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap
APIs.
Quoted 17 lines
Quoted 10 lines
Quoted 2 lines
Could you use
rte_mallocin these drivers?If we take the direction of 2 different allocations mode for the interrupts, I suggest we make it automatic without any API parameter. We don't have any function to check
rte_mallocreadiness I think. But we can detect whether shared memory is ready with this check:
rte_eal_get_configuration()->mem_config->magic ==RTE_MAGICThis check is true at the end ofrte_eal_init, so it is false during probing. Would it be enough? Or should we implementrte_malloc_is_ready()?Hi Thomas,
It's a very good suggestion. Let's implement "
rte_malloc_is_ready()" which could be as simple as " rte_eal_get_configuration()->mem_config- magic ==RTE_MAGIC" check.
There may be more consumers for this API in future.
Quoted 7 lines
Quoted 3 lines
You cannot rely on the magic because it is set only after probing. For such API you need to have another internal flag to check that malloc is setup.
Yeah, got that. You mean in case of bus probing although
rte_mallocis setup buteal_mcfg_complete()is calledt done yet. So we should set another malloc specific flag at the end ofrte_eal_memory_init(). Correct?
I think the new internal flag should be at the end of rte_eal_malloc_heap_init(). Then a rte_internal function rte_malloc_is_ready() should check this flag.
Quoted 3 lines
But just for understanding, as David suggested that we preserve keep this flag then why not use it, have
rte_mallocand malloc bits and make a decision. Let driver has the flexibility to choose. Do you see any harm in this?
Which flag?
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 96 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, October 14, 2021 4:06 PM
To: Harman Kalra <[email protected]>
Cc: David Marchand <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>; Ray Kinsella <[email protected]>; Dmitry Kozlyuk <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs14/10/2021 12:31, Harman Kalra:
Quoted 14 lines
From: Thomas Monjalon <[email protected]>
Quoted 13 lines
14/10/2021 11:31, Harman Kalra:
Quoted 12 lines
From: Thomas Monjalon <[email protected]>
Quoted 11 lines
13/10/2021 20:52, Thomas Monjalon:
Quoted 9 lines
13/10/2021 19:57, Harman Kalra:
Quoted 8 lines
From: dev <[email protected]> On Behalf Of Harman Kalra
Quoted 7 lines
From: Thomas Monjalon <[email protected]>
Quoted 6 lines
04/10/2021 11:57, David Marchand:
Quoted 2 lines
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra
<[email protected]>Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+struct rte_intr_handle
+*rte_intr_handle_instance_alloc(intsize,
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
+
+bool
+from_hugepage) {
+ struct rte_intr_handle *intr_handle;
+ int i;
+
+ if (from_hugepage)
+ intr_handle = rte_zmalloc(NULL,
+ size * sizeof(struct
rte_intr_handle),Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
+ 0);
+ else
+ intr_handle = calloc(1, size *
+ sizeof(struct rte_intr_handle));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess
does not work in some rarely tested cases.[...]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initandQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
rte_eal_cleanup.
[...]Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init. Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsysteminits.
Quoted 36 lines
Quoted 35 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Other option could be to allocate interrupt instance for timerfd on first
alarm_setupcall.Indeed it is an issue.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
[...]
Quoted 5 lines
Quoted 5 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap
APIs.
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines
Could you use
rte_mallocin these drivers?If we take the direction of 2 different allocations mode for the interrupts, I suggest we make it automatic without any API parameter. We don't have any function to check
rte_mallocreadiness I think. But we can detect whether shared memory is ready with this check:
rte_eal_get_configuration()->mem_config->magic ==RTE_MAGICThis check is true at the end ofrte_eal_init, so it is false during probing. Would it be enough? Or should we implementrte_malloc_is_ready()?Quoted 7 lines
Hi Thomas,
It's a very good suggestion. Let's implement "
rte_malloc_is_ready()" which could be as simple as " rte_eal_get_configuration()->mem_config-
magic ==RTE_MAGIC" check.
There may be more consumers for this API in future.You cannot rely on the magic because it is set only after probing. For such API you need to have another internal flag to check that malloc is setup.
Quoted 7 lines
Quoted 3 lines
Yeah, got that. You mean in case of bus probing although
rte_mallocis setup buteal_mcfg_complete()is calledt done yet. So we should set another malloc specific flag at the end ofrte_eal_memory_init(). Correct?I think the new internal flag should be at the end of
rte_eal_malloc_heap_init().
Then arte_internalfunctionrte_malloc_is_ready()should check this flag.
Sure.
Quoted 7 lines
Quoted 3 lines
But just for understanding, as David suggested that we preserve keep this flag then why not use it, have
rte_mallocand malloc bits and make adecision.
Quoted 1 line
Let driver has the flexibility to choose. Do you see any harm in this?
Which flag?
In V2, I have replaced the bool arg with an 32bit flag in alloc api:
struct rte_intr_handle *rte_intr_instance_alloc(uint32_t flags);
Declared some flags which can be passed by the consumer /** Interrupt instance allocation flags
* @see rte_intr_instance_alloc
*/
/** Allocate interrupt instance from traditional heap */
#define RTE_INTR_ALLOC_TRAD_HEAP 0x00000000
/** Allocate interrupt instance using DPDK memory management APIs */
#define RTE_INTR_ALLOC_DPDK_ALLOCATOR 0x00000001
As a future enhancement, if more options to the allocation is required by user, new flags can be added.
Thanks
Harman
Quoted 2 lines
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
14/10/2021 12:44, Harman Kalra:
Quoted 19 lines
Quoted 6 lines
Quoted 2 lines
But just for understanding, as David suggested that we preserve keep this flag then why not use it, have
rte_mallocand malloc bits and make adecision.
Quoted 1 line
Let driver has the flexibility to choose. Do you see any harm in this?
Which flag?
In V2, I have replaced the bool arg with an 32bit flag in alloc api:
structrte_intr_handle*rte_intr_instance_alloc(uint32_t flags);Declared some flags which can be passed by the consumer /** Interrupt instance allocation flags
* @seerte_intr_instance_alloc
*/
/** Allocate interrupt instance from traditional heap */
#defineRTE_INTR_ALLOC_TRAD_HEAP0x00000000
/** Allocate interrupt instance using DPDK memory management APIs */
#defineRTE_INTR_ALLOC_DPDK_ALLOCATOR0x00000001
Quoted 2 lines
As a future enhancement, if more options to the allocation is required by user, new flags can be added.
I am not sure we need such flag.
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
In reply to Harman Kalra2021-10-14 09:31 (UTC+0000), Harman Kalra:
Quoted 72 lines
Quoted 64 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, October 14, 2021 1:53 PM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Ray Kinsella <[email protected]>; Dmitry Kozlyuk <[email protected]>; David Marchand <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs13/10/2021 20:52, Thomas Monjalon:
Quoted 8 lines
13/10/2021 19:57, Harman Kalra:
Quoted 7 lines
From: dev <[email protected]> On Behalf Of Harman Kalra
Quoted 6 lines
From: Thomas Monjalon <[email protected]>
Quoted 5 lines
04/10/2021 11:57, David Marchand:
Quoted 2 lines
On Mon, Oct 4, 2021 at 10:51 AM Harman Kalra
<[email protected]>Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
+struct
rte_intr_handle*rte_intr_handle_instance_alloc(intsize,
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Review
Quoted 13 lines
(quoted diff) +13
-0+ +bool +from_hugepage) { + struct rte_intr_handle *intr_handle; + int i; + + if (from_hugepage) + intr_handle = rte_zmalloc(NULL, + size * sizeof(struct rte_intr_handle), + 0); + else + intr_handle = calloc(1, size * + sizeof(struct rte_intr_handle));We can call DPDK allocator in all cases.
That would avoid headaches on why multiprocess does not work in some rarely tested cases.[...]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I agree with David.
I prefer a simpler API which always userte_malloc, and make sure interrupts are always handled betweenrte_eal_initand
rte_eal_cleanup.
[...]Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
There are couple of more dependencies on glibc heap APIs:
1. "rte_eal_alarm_init()" allocates an interrupt instance which is used for timerfd, is called before "rte_eal_memory_init()" which does the memseg init.
Not sure what all challenges we may face in movingalarm_initaftermemory_initas it might break some subsystem inits. Other option could be to allocate interrupt instance for timerfd on firstalarm_setupcall.Indeed it is an issue.
Quoted 8 lines
[...]
Quoted 4 lines
Quoted 4 lines
There are many other drivers which statically declares the interrupt handles inside their respective private structures and memory for those structure was allocated from heap. For such drivers I allocated interrupt instances also using glibc heap APIs.
Could you use
rte_mallocin these drivers?Quoted 7 lines
If we take the direction of 2 different allocations mode for the interrupts, I suggest we make it automatic without any API parameter.
We don't have any function to checkrte_mallocreadiness I think. But we can detect whether shared memory is ready with this check:
rte_eal_get_configuration()->mem_config->magic ==RTE_MAGICThis check is true at the end ofrte_eal_init, so it is false during probing. Would it be enough? Or should we implementrte_malloc_is_ready()?
Quoted 5 lines
Hi Thomas,
It's a very good suggestion. Let's implement "
rte_malloc_is_ready()" which could be as simple as " rte_eal_get_configuration()->mem_config->magic ==RTE_MAGIC" check. There may be more consumers for this API in future.
I doubt it should be public. How it is supposed to be used? Any application code for DPDK necessarily calls rte_eal_init() first, after that this function would always return true.
Quoted 6 lines
If we are making it automatic detection, shall we now even have argument to this alloc API?
I added a flags argument (32 bit) in latest series where each bit of this flag can be an allocation capability. I used two bits for discriminating between glibc malloc andrte_malloc. Shall we keep it or drop it?David, Dmitry please share your thoughts.
I'd drop it, but no strong opinion.
Since allocation type is automatic and all other properties can be set later, there are no use cases for any options here.
And if they appear, flags may be insufficient as well.
Re: [dpdk-dev] [PATCH v1 2/7] eal/interrupts: implement get set APIs
In reply to Harman Kalra2021-09-03 18:10 (UTC+0530), Harman Kalra:
Quoted 13 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +6
-0@@ -0,0 +1,506 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2021 Marvell. +*/ + +#include <stdlib.h> +#include <string.h>
lib/eal/common/eal_common_interrupts.c line 16
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+ +#include <rte_errno.h> +#include <rte_log.h> +#include <rte_malloc.h> + +#include <rte_interrupts.h> + + +struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool from_hugepage)
Since the purpose of the series is to reduce future ABI breakages, how about making the second parameter "flags" to have some spare bits? (If not removing it completely per David's suggestion.)
Quoted 16 lines
lib/eal/common/eal_common_interrupts.c new file +16
-0+{ +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct rte_intr_handle )); +if (!intr_handle) { +RTE_LOG (ERR ,EAL ,"Fail to allocate intr_handle\n" ); + rte_errno =ENOMEM ; +return NULL ; + } +
lib/eal/common/eal_common_interrupts.c line 42
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+for (i =0 ; i < size; i++) { + intr_handle[i].nb_intr =RTE_MAX_RXTX_INTR_VEC_ID ; + intr_handle[i].alloc_from_hugepage = from_hugepage; + } + +return intr_handle; +} + +struct rte_intr_handle *rte_intr_handle_instance_index_get ( +struct rte_intr_handle *intr_handle,int index)
If rte_intr_handle_instance_alloc() returns a pointer to an array, this function is useless since the user can simply manipulate a pointer. If we want to make a distinction between a single struct rte_intr_handle and a commonly allocated bunch of such (but why?), then they should be represented by distinct types.
lib/eal/common/eal_common_interrupts.c line 46
Quoted 4 lines
lib/eal/common/eal_common_interrupts.c new file +4
-0+{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOMEM ;
Why it's sometimes ENOMEM and sometimes ENOTSUP when the handle is not allocated?
lib/eal/common/eal_common_interrupts.c line 55
Quoted 9 lines
lib/eal/common/eal_common_interrupts.c new file +9
-0+return NULL ; + } + +return &intr_handle[index]; +} + +int rte_intr_handle_instance_index_set (struct rte_intr_handle *intr_handle, +const struct rte_intr_handle *src, +int index)
See above regarding the "index" parameter. If it can be removed, a better name for this function would be rte_intr_handle_copy().
Quoted 8 lines
lib/eal/common/eal_common_interrupts.c new file +8
-0+{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (src ==NULL ) {
lib/eal/common/eal_common_interrupts.c line 73
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+RTE_LOG (ERR ,EAL ,"Source interrupt instance unallocated\n" ); + rte_errno =EINVAL ; + goto fail; + } + +if (index <0 ) { +RTE_LOG (ERR ,EAL ,"Index cany be negative" ); + rte_errno =EINVAL ; + goto fail; + }
How about making this parameter "size_t"?
Quoted 4 lines
lib/eal/common/eal_common_interrupts.c new file +4
-0+ + intr_handle[index].fd = src->fd; + intr_handle[index].vfio_dev_fd = src->vfio_dev_fd; + intr_handle[index].type = src->type;
lib/eal/common/eal_common_interrupts.c line 87
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+ intr_handle[index].max_intr = src->max_intr; + intr_handle[index].nb_efd = src->nb_efd; + intr_handle[index].efd_counter_size = src->efd_counter_size; + +memcpy (intr_handle[index].efds, src->efds, src->nb_intr); +memcpy (intr_handle[index].elist, src->elist, src->nb_intr); + +return 0 ; +fail: +return rte_errno;
Should be (-rte_errno) per documentation.
Please check all functions in this file that return an "int" status.
lib/eal/common/eal_common_interrupts.c line 185
Quoted 13 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +12
-0+int rte_intr_handle_dev_fd_get (const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->vfio_dev_fd; +fail: +return rte_errno; +}
Returning a errno value instead of an FD is very error-prone. Probably returning (-1) is both safe and convenient?
lib/eal/common/eal_common_interrupts.c line 197
Quoted 12 lines
lib/eal/common/eal_common_interrupts.c new file +12
-0+ +int rte_intr_handle_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (max_intr > intr_handle->nb_intr) { + RTE_LOG(ERR, EAL, "Max_intr=%d greater than PLT_MAX_RXTX_INTR_VEC_ID=%d",
Seems like this common/cnxk name leaked here by mistake?
Quoted 14 lines
lib/eal/common/eal_common_interrupts.c new file +14
-0+ max_intr, intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->max_intr = max_intr; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_get (const struct rte_intr_handle *intr_handle) +{
lib/eal/common/eal_common_interrupts.c line 221
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->max_intr; +fail: +return rte_errno; +}
Should be negative per documentation and to avoid returning a positive value that cannot be distinguished from a successful return.
Please also check other functions in this file returning an "int" result (not status).
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Hi Dmitry,
Thanks for reviewing the series.
Please find my comments inline.
Quoted 32 lines
-----Original Message-----
From: Dmitry Kozlyuk <[email protected]>
Sent: Sunday, October 3, 2021 11:35 PM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Ray Kinsella <[email protected]>
Subject: [EXT] Re: [dpdk-dev] [PATCH v1 2/7] eal/interrupts: implement get set APIsExternal Email
----------------------------------------------------------------------
2021-09-03 18:10 (UTC+0530), Harman Kalra:Quoted 20 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +12
-0@@ -0,0 +1,506 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2021 Marvell. +*/ + +#include <stdlib.h> +#include <string.h> + +#include <rte_errno.h> +#include <rte_log.h> +#include <rte_malloc.h> + +#include <rte_interrupts.h>
Quoted 9 lines
lib/eal/common/eal_common_interrupts.c line 16
Quoted 4 lines
lib/eal/common/eal_common_interrupts.c new file +4
-0+ + +struct rte_intr_handle *rte_intr_handle_instance_alloc (int size, +bool from_hugepage)Since the purpose of the series is to reduce future ABI breakages, how about making the second parameter "flags" to have some spare bits?
(If not removing it completely per David's suggestion.)
<HK> Having second parameter "flags" is a good suggestion, I will include it.
Quoted 28 lines
Quoted 16 lines
lib/eal/common/eal_common_interrupts.c new file +16
-0+{ +struct rte_intr_handle *intr_handle; +int i; + +if (from_hugepage) + intr_handle =rte_zmalloc (NULL , + size *sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 , size *sizeof (struct rte_intr_handle )); +if (!intr_handle) { +RTE_LOG (ERR ,EAL ,"Fail to allocate intr_handle\n" ); + rte_errno =ENOMEM ; +return NULL ; + } +lib/eal/common/eal_common_interrupts.c
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+for (i =0 ; i < size; i++) { + intr_handle[i].nb_intr =RTE_MAX_RXTX_INTR_VEC_ID ; + intr_handle[i].alloc_from_hugepage = from_hugepage; + } + +return intr_handle; +} + +struct rte_intr_handle *rte_intr_handle_instance_index_get ( + struct rte_intr_handle *intr_handle, intindex)
Quoted 2 lines
If
rte_intr_handle_instance_alloc()returns a pointer to an array, this function is useless since the user can simply manipulate a pointer.
<HK> User wont be able to manipulate the pointer as he is not aware of size of struct rte_intr_handle. He will observe "dereferencing pointer to incomplete type" compilation error.
Quoted 3 lines
If we want to make a distinction between a single struct
rte_intr_handleand a commonly allocated bunch of such (but why?), then they should be represented by distinct types.
<HK> Do you mean, we should have separate APIs for single allocation and batch allocation? As get API will be useful only in case of batch allocation. Currently interrupt autotests and ifpga_rawdev driver makes batch allocation.
I think common API for single and batch is fine, get API is required for returning a particular intr_handle instance. But one problem I see in current implementation is there should be upper limit check for index in get/set API, which I will fix.
Quoted 8 lines
lib/eal/common/eal_common_interrupts.c line 46
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c new file +4
-0+{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOMEM ;Why it's sometimes ENOMEM and sometimes ENOTSUP when the handle is not allocated?
<HK> I will fix and make it symmetrical across.
Quoted 9 lines
lib/eal/common/eal_common_interrupts.c
Quoted 8 lines
lib/eal/common/eal_common_interrupts.c new file +7
-0+return NULL ; + } + +return &intr_handle[index]; +} + +int rte_intr_handle_instance_index_set(struct rte_intr_handle
*intr_handle,
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c line 55
Quoted 2 lines
lib/eal/common/eal_common_interrupts.c new file +2
-0+const struct rte_intr_handle *src, + int index)See above regarding the "index" parameter. If it can be removed, a better name for this function would be
rte_intr_handle_copy().
<HK> I think get API is required.
Quoted 11 lines
lib/eal/common/eal_common_interrupts.c
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +9
-0+{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (src ==NULL ) { + RTE_LOG(ERR, EAL, "Source interrupt instanceunallocated\n");
Quoted 11 lines
lib/eal/common/eal_common_interrupts.c line 73
Quoted 9 lines
lib/eal/common/eal_common_interrupts.c new file +9
-0+ rte_errno =EINVAL ; + goto fail; + } + +if (index <0 ) { +RTE_LOG (ERR ,EAL ,"Index cany be negative" ); + rte_errno =EINVAL ; + goto fail; + }How about making this parameter "
size_t"?
<HK> You mean index ? It can be size_t.
Quoted 10 lines
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +9
-0+ + intr_handle[index].fd = src->fd; + intr_handle[index].vfio_dev_fd = src->vfio_dev_fd; + intr_handle[index].type = src->type; + intr_handle[index].max_intr = src->max_intr; + intr_handle[index].nb_efd = src->nb_efd; + intr_handle[index].efd_counter_size = src->efd_counter_size; + +memcpy (intr_handle[index].efds, src->efds, src->nb_intr);
Quoted 8 lines
lib/eal/common/eal_common_interrupts.c line 87
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c new file +5
-0+memcpy (intr_handle[index].elist, src->elist, src->nb_intr); + +return 0 ; +fail: +return rte_errno;Should be (-rte_errno) per documentation.
Please check all functions in this file that return an "int" status.
<HK> Sure will fix it across APIs.
Quoted 17 lines
Quoted 4 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +2
-0+int rte_intr_handle_dev_fd_get (const struct rte_intr_handle +*intr_handle) {lib/eal/common/eal_common_interrupts.c line 185
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->vfio_dev_fd; +fail: +return rte_errno; +}Returning a errno value instead of an FD is very error-prone. Probably returning (-1) is both safe and convenient?
<HK> Ack
Quoted 16 lines
Quoted 4 lines
lib/eal/common/eal_common_interrupts.c new file +3
-0+ +int rte_intr_handle_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr)lib/eal/common/eal_common_interrupts.c
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (max_intr > intr_handle->nb_intr) { + RTE_LOG(ERR, EAL, "Max_intr=%d greater than +PLT_MAX_RXTX_INTR_VEC_ID=%d",Seems like this common/cnxk name leaked here by mistake?
<HK> Thanks for catching this.
Quoted 22 lines
Quoted 22 lines
lib/eal/common/eal_common_interrupts.c new file +21
-0+ max_intr, intr_handle->nb_intr); + rte_errno =ERANGE ; + goto fail; + } + + intr_handle->max_intr = max_intr; + +return 0 ; +fail: +return rte_errno; +} + +int rte_intr_handle_max_intr_get (const struct rte_intr_handle +*intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->max_intr;
Quoted 8 lines
lib/eal/common/eal_common_interrupts.c line 88
Quoted 3 lines
lib/eal/common/eal_common_interrupts.c new file +3
-0+fail: +return rte_errno; +}Should be negative per documentation and to avoid returning a positive value that cannot be distinguished from a successful return. Please also check other functions in this file returning an "int" result (not status).
<HK> Will fix it.
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
2021-10-04 10:37 (UTC+0000), Harman Kalra:
Quoted 10 lines
[...]
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+struct rte_intr_handle *rte_intr_handle_instance_index_get( + struct rte_intr_handle *intr_handle, intindex)
If
rte_intr_handle_instance_alloc()returns a pointer to an array, this function is useless since the user can simply manipulate a pointer.<HK> User wont be able to manipulate the pointer as he is not aware of size of struct
rte_intr_handle. He will observe "dereferencing pointer to incomplete type" compilation error.
Sorry, my bad.
Quoted 10 lines
Quoted 3 lines
If we want to make a distinction between a single struct
rte_intr_handleand a commonly allocated bunch of such (but why?), then they should be represented by distinct types.<HK> Do you mean, we should have separate APIs for single allocation and batch allocation? As get API will be useful only in case of batch allocation. Currently interrupt autotests and
ifpga_rawdevdriver makes batch allocation.
I think common API for single and batch is fine, get API is required for returning a particularintr_handleinstance. But one problem I see in current implementation is there should be upper limit check for index in get/set API, which I will fix.
I don't think we need different APIs, I was asking if it was your intention. Now I understand it and agree with you.
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
+int rte_intr_handle_instance_index_set(struct
rte_intr_handle
*intr_handle,lib/eal/common/eal_common_interrupts.c line 55
Quoted 2 lines
lib/eal/common/eal_common_interrupts.c new file +2
-0+const struct rte_intr_handle *src, + int index)See above regarding the "index" parameter. If it can be removed, a better name for this function would be
rte_intr_handle_copy().<HK> I think get API is required.
Maybe index is still not needed: "intr_handle" can just be a pointer to the right item obtained with rte_intr_handle_instance_index_get(). This way you also don't need to duplicate the index-checking logic.
Re: [dpdk-dev] [EXT] Re: [PATCH v1 2/7] eal/interrupts: implement get set APIs
Quoted 51 lines
-----Original Message-----
From: Dmitry Kozlyuk <[email protected]>
Sent: Monday, October 4, 2021 4:48 PM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Ray Kinsella <[email protected]>; David Marchand <[email protected]>
Subject: Re: [EXT] Re: [dpdk-dev] [PATCH v1 2/7] eal/interrupts: implement get set APIs2021-10-04 10:37 (UTC+0000), Harman Kalra:
Quoted 9 lines
[...]
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+struct rte_intr_handle *rte_intr_handle_instance_index_get( + struct rte_intr_handle *intr_handle, intindex)
If
rte_intr_handle_instance_alloc()returns a pointer to an array, this function is useless since the user can simply manipulate a pointer.<HK> User wont be able to manipulate the pointer as he is not aware of
size of struct
rte_intr_handle.Quoted 1 line
He will observe "dereferencing pointer to incomplete type" compilation
error.
Sorry, my bad.
Quoted 7 lines
Quoted 3 lines
If we want to make a distinction between a single struct
rte_intr_handleand a commonly allocated bunch of such (but why?), then they should be represented by distinct types.<HK> Do you mean, we should have separate APIs for single allocation and batch allocation? As get API will be useful only in case of batch allocation. Currently interrupt autotests and
ifpga_rawdevdriver makesbatch allocation.
Quoted 1 line
I think common API for single and batch is fine, get API is required for
returning a particular
intr_handleinstance.Quoted 2 lines
But one problem I see in current implementation is there should be upper limit check for index in get/set API, which I will fix.
I don't think we need different APIs, I was asking if it was your intention. Now I understand it and agree with you.
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
+int rte_intr_handle_instance_index_set(struct
rte_intr_handle
*intr_handle,lib/eal/common/eal_common_interrupts.c line 55
Quoted 2 lines
lib/eal/common/eal_common_interrupts.c new file +2
-0+const struct rte_intr_handle *src, + int index)See above regarding the "index" parameter. If it can be removed, a better name for this function would be
rte_intr_handle_copy().
Quoted 5 lines
Quoted 1 line
<HK> I think get API is required.
Maybe index is still not needed: "
intr_handle" can just be a pointer to the right item obtained withrte_intr_handle_instance_index_get(). This way you also don't need to duplicate the index-checking logic.
In the current implementation, batch allocation of interrupt handle may lead to mem leak while freeing efds and elist array. I am only freeing efds/elist for intr_handle[0] in rte_intr_handle_instance_free(). To free efds/elist of all the intr_handles[], either I should cache the size parameter passed during alloc. But where should I store it? In first instance of struct rte_intr_handle. I don't think it will be a good idea.
Since batch allocation is only done in test suite and ifpga_rawdev.c, to keep things simpler let's restrict rte_intr_handle_instance_alloc() to single instance allocation and user can call this API in a loop and maintain array of handles locally.
With this approach get_index API is not required and set_index API can be renamed to rte_intr_handle_copy()
Thoughts?
Thanks
Harman
PATCH 3/7 eal/interrupts: avoid direct access to interrupt handle
In reply to Harman KalraMaking changes to the interrupt framework to use interrupt handle APIs to get/set any field. Direct access to any of the fields should be avoided to avoid any ABI breakage in future.
--- lib/eal/freebsd/eal_interrupts.c | 94 ++++++---- lib/eal/linux/eal_interrupts.c | 294 +++++++++++++++++++------------ 2 files changed, 242 insertions(+), 146 deletions(-)
lib/eal/freebsd/eal_interrupts.c +60 -34
@@ -40,7 +40,7 @@ struct rte_intr_callback {struct rte_intr_source {TAILQ_ENTRY (rte_intr_source) next; -struct rte_intr_handle intr_handle;/**< interrupt handle */ +struct rte_intr_handle *intr_handle;/**< interrupt handle */ struct rte_intr_cb_list callbacks;/**< user callbacks */ uint32_t active; };
@@ -60,7 +60,7 @@ static int intr_source_to_kevent(const struct rte_intr_handle *ih, struct kevent *ke) {/* alarm callbacks are special case */ -if (ih->type ==RTE_INTR_HANDLE_ALARM ) { +if (rte_intr_handle_type_get (ih) ==RTE_INTR_HANDLE_ALARM ) {uint64_t timeout_ns;/* get soonest alarm timeout */
@@ -75,7 +75,7 @@ intr_source_to_kevent(const struct rte_intr_handle *ih, struct kevent *ke) }else { ke->filter =EVFILT_READ ; } - ke->ident = ih->fd; + ke->ident =rte_intr_handle_fd_get (ih);return 0 ; }
@@ -89,7 +89,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,int ret =0 , add_event =0 ;/* first do parameter checking */ -if (intr_handle ==NULL || intr_handle->fd <0 || cb ==NULL ) { +if (intr_handle ==NULL ||rte_intr_handle_fd_get (intr_handle) <0 || + cb ==NULL ) {RTE_LOG (ERR ,EAL ,"Registering with invalid input parameter\n" );return -EINVAL ;
@@ -103,7 +104,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,/* find the source for this intr_handle */ TAILQ_FOREACH(src, &intr_sources, next) { -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_handle_fd_get (src->intr_handle) == +rte_intr_handle_fd_get (intr_handle))break ; }
@@ -112,8 +114,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,* thing on the list should be eal_alarm_callback() and we may * be called just to reset the timer. */ -if (src !=NULL && src->intr_handle.type ==RTE_INTR_HANDLE_ALARM && - !TAILQ_EMPTY (&src->callbacks)) { +if (src !=NULL &&rte_intr_handle_type_get (src->intr_handle) == +RTE_INTR_HANDLE_ALARM && !TAILQ_EMPTY (&src->callbacks)) { callback =NULL ; }else {/* allocate a new interrupt callback entity */
@@ -135,9 +137,20 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle, ret = -ENOMEM ; goto fail; }else { - src->intr_handle = *intr_handle; -TAILQ_INIT (&src->callbacks); -TAILQ_INSERT_TAIL (&intr_sources, src, next); + src->intr_handle = +rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (src->intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Can not create intr instance\n" ); +free (callback); + ret = -ENOMEM ; + }else { +rte_intr_handle_instance_index_set ( + src->intr_handle, intr_handle,0 ); +TAILQ_INIT (&src->callbacks); +TAILQ_INSERT_TAIL (&intr_sources, src, + next); + } } }
@@ -151,7 +164,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,/* add events to the queue. timer events are special as we need to * re-set the timer. */ -if (add_event || src->intr_handle.type ==RTE_INTR_HANDLE_ALARM ) { +if (add_event ||rte_intr_handle_type_get (src->intr_handle) == +RTE_INTR_HANDLE_ALARM ) {struct kevent ke;memset (&ke,0 ,sizeof (ke));
@@ -173,12 +187,13 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,*/ if (errno ==ENODEV )RTE_LOG (DEBUG ,EAL ,"Interrupt handle %d not supported\n" , - src->intr_handle.fd); +rte_intr_handle_fd_get (src->intr_handle));else RTE_LOG (ERR ,EAL ,"Error adding fd %d " -"kevent, %s\n" , - src->intr_handle.fd, -strerror (errno)); +"kevent, %s\n" , +rte_intr_handle_fd_get ( + src->intr_handle), +strerror (errno)); ret = -errno; goto fail; }
@@ -213,7 +228,7 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,struct rte_intr_callback *cb, *next;/* do parameter checking first */ -if (intr_handle ==NULL || intr_handle->fd <0 ) { +if (intr_handle ==NULL ||rte_intr_handle_fd_get (intr_handle) <0 ) {RTE_LOG (ERR ,EAL ,"Unregistering with invalid input parameter\n" );return -EINVAL ;
@@ -228,7 +243,8 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,/* check if the insterrupt source for the fd is existent */ TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_handle_fd_get (src->intr_handle) == +rte_intr_handle_fd_get (intr_handle))break ;/* No interrupt source registered for the fd */
@@ -268,7 +284,7 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,struct rte_intr_callback *cb, *next;/* do parameter checking first */ -if (intr_handle ==NULL || intr_handle->fd <0 ) { +if (intr_handle ==NULL ||rte_intr_handle_fd_get (intr_handle) <0 ) {RTE_LOG (ERR ,EAL ,"Unregistering with invalid input parameter\n" );return -EINVAL ;
@@ -282,7 +298,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,/* check if the insterrupt source for the fd is existent */ TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_handle_fd_get (src->intr_handle) == +rte_intr_handle_fd_get (intr_handle))break ;/* No interrupt source registered for the fd */
@@ -314,7 +331,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,*/ if (kevent (kq, &ke,1 ,NULL ,0 ,NULL ) <0 ) {RTE_LOG (ERR ,EAL ,"Error removing fd %d kevent, %s\n" , - src->intr_handle.fd,strerror (errno)); +rte_intr_handle_fd_get (src->intr_handle), +strerror (errno));/* removing non-existent even is an expected condition * in some circumstances (e.g. oneshot events). */
@@ -365,17 +383,18 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)if (intr_handle ==NULL )return -1 ; -if (intr_handle->type ==RTE_INTR_HANDLE_VDEV ) { +if (rte_intr_handle_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV ) { rc =0 ; goto out; } -if (intr_handle->fd <0 || intr_handle->uio_cfg_fd <0 ) { +if (rte_intr_handle_fd_get (intr_handle) <0 || +rte_intr_handle_dev_fd_get (intr_handle) <0 ) { rc =-1 ; goto out; } -switch (intr_handle->type) { +switch (rte_intr_handle_type_get (intr_handle)) {/* not used at this moment */ case RTE_INTR_HANDLE_ALARM : rc =-1 ;
@@ -388,7 +407,7 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)default :RTE_LOG (ERR ,EAL ,"Unknown handle type of fd %d\n" , - intr_handle->fd); +rte_intr_handle_fd_get (intr_handle)); rc =-1 ;break ; }
@@ -406,17 +425,18 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)if (intr_handle ==NULL )return -1 ; -if (intr_handle->type ==RTE_INTR_HANDLE_VDEV ) { +if (rte_intr_handle_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV ) { rc =0 ; goto out; } -if (intr_handle->fd <0 || intr_handle->uio_cfg_fd <0 ) { +if (rte_intr_handle_fd_get (intr_handle) <0 || +rte_intr_handle_dev_fd_get (intr_handle) <0 ) { rc =-1 ; goto out; } -switch (intr_handle->type) { +switch (rte_intr_handle_type_get (intr_handle)) {/* not used at this moment */ case RTE_INTR_HANDLE_ALARM : rc =-1 ;
@@ -429,7 +449,7 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)default :RTE_LOG (ERR ,EAL ,"Unknown handle type of fd %d\n" , - intr_handle->fd); +rte_intr_handle_fd_get (intr_handle)); rc =-1 ;break ; }
@@ -441,7 +461,8 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)int rte_intr_ack (const struct rte_intr_handle *intr_handle) { -if (intr_handle && intr_handle->type ==RTE_INTR_HANDLE_VDEV ) +if (intr_handle && +rte_intr_handle_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV )return 0 ;return -1 ;
@@ -463,7 +484,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)rte_spinlock_lock (&intr_lock); TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == event_fd) +if (rte_intr_handle_fd_get (src->intr_handle) == + event_fd)break ;if (src ==NULL ) {rte_spinlock_unlock (&intr_lock);
@@ -475,7 +497,7 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)rte_spinlock_unlock (&intr_lock);/* set the length to be read dor different handle type */ -switch (src->intr_handle.type) { +switch (rte_intr_handle_type_get (src->intr_handle)) {case RTE_INTR_HANDLE_ALARM : bytes_read =0 ; call = true;
@@ -546,7 +568,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)/* mark for deletion from the queue */ ke.flags =EV_DELETE ; -if (intr_source_to_kevent (&src->intr_handle, &ke) <0 ) { +if (intr_source_to_kevent (src->intr_handle, + &ke) <0 ) {RTE_LOG (ERR ,EAL ,"Cannot convert to kevent\n" );rte_spinlock_unlock (&intr_lock);return ;
@@ -557,7 +580,9 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)*/ if (kevent (kq, &ke,1 ,NULL ,0 ,NULL ) <0 ) {RTE_LOG (ERR ,EAL ,"Error removing fd %d kevent, " -"%s\n" , src->intr_handle.fd, +"%s\n" , +rte_intr_handle_fd_get ( + src->intr_handle),strerror (errno));/* removing non-existent even is an expected * condition in some circumstances
@@ -567,7 +592,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)TAILQ_REMOVE (&src->callbacks, cb, next);if (cb->ucb_fn) - cb->ucb_fn (&src->intr_handle, cb->cb_arg); + cb->ucb_fn (src->intr_handle, + cb->cb_arg);free (cb); } }
lib/eal/linux/eal_interrupts.c +182 -112
754 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH 4/7 test/interrupt: apply get set interrupt handle APIs
In reply to Harman KalraUpdating the interrupt testsuite to make use of interrupt handle get set APIs.
--- app/test/test_interrupts.c | 237 ++++++++++++++++++++++++------------- 1 file changed, 152 insertions(+), 85 deletions(-)
app/test/test_interrupts.c +152 -85
@@ -27,7 +27,7 @@ enum test_interrupt_handle_type {/* flag of if callback is called */ static volatile int flag; -static struct rte_intr_handle intr_handles[TEST_INTERRUPT_HANDLE_MAX ]; +static struct rte_intr_handle *intr_handles;static enum test_interrupt_handle_type test_intr_type =TEST_INTERRUPT_HANDLE_MAX ;
@@ -50,7 +50,7 @@ static union intr_pipefds pfds;static inline int test_interrupt_handle_sanity_check (struct rte_intr_handle *intr_handle) { -if (!intr_handle || intr_handle->fd <0 ) +if (!intr_handle ||rte_intr_handle_fd_get (intr_handle) <0 )return -1 ;return 0 ;
@@ -62,31 +62,70 @@ test_interrupt_handle_sanity_check(struct rte_intr_handle *intr_handle)static int test_interrupt_init (void ) { +struct rte_intr_handle *test_intr_handle; +if (pipe (pfds.pipefd) <0 )return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_INVALID ].fd =-1 ; - intr_handles[TEST_INTERRUPT_HANDLE_INVALID ].type = -RTE_INTR_HANDLE_UNKNOWN ; + intr_handles =rte_intr_handle_instance_alloc (TEST_INTERRUPT_HANDLE_MAX , + false); +if (!intr_handles) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID ].type = -RTE_INTR_HANDLE_UNKNOWN ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle,-1 )) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_UNKNOWN )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ].type = -RTE_INTR_HANDLE_UIO ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_UNKNOWN )) +return -1 ; + + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_UIO ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_UIO )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ].type = -RTE_INTR_HANDLE_ALARM ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_ALARM ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_ALARM )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ].type = -RTE_INTR_HANDLE_DEV_EVENT ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle, +RTE_INTR_HANDLE_DEV_EVENT )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ].fd = pfds.writefd; - intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ].type =RTE_INTR_HANDLE_UIO ; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_CASE1 ); +if (!test_intr_handle) +return -1 ; +if (rte_intr_handle_fd_set (test_intr_handle, pfds.writefd)) +return -1 ; +if (rte_intr_handle_type_set (test_intr_handle,RTE_INTR_HANDLE_UIO )) +return -1 ;return 0 ; }
@@ -97,6 +136,7 @@ test_interrupt_init(void)static int test_interrupt_deinit (void ) { +rte_intr_handle_instance_free (intr_handles);close (pfds.pipefd[0 ]);close (pfds.pipefd[1 ]);
@@ -125,8 +165,10 @@ test_interrupt_handle_compare(struct rte_intr_handle *intr_handle_l,if (!intr_handle_l || !intr_handle_r)return -1 ; -if (intr_handle_l->fd != intr_handle_r->fd || - intr_handle_l->type != intr_handle_r->type) +if (rte_intr_handle_fd_get (intr_handle_l) != +rte_intr_handle_fd_get (intr_handle_r) || +rte_intr_handle_type_get (intr_handle_l) != +rte_intr_handle_type_get (intr_handle_r))return -1 ;return 0 ;
@@ -178,6 +220,8 @@ static void test_interrupt_callback(void *arg) {struct rte_intr_handle *intr_handle = arg; +struct rte_intr_handle *test_intr_handle; +if (test_intr_type >=TEST_INTERRUPT_HANDLE_MAX ) {printf ("invalid interrupt type\n" ); flag =-1 ;
@@ -198,8 +242,9 @@ test_interrupt_callback(void *arg)return ; } -if (test_interrupt_handle_compare (intr_handle, - &(intr_handles[test_intr_type])) ==0 ) + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, + test_intr_type); +if (test_interrupt_handle_compare (intr_handle, test_intr_handle) ==0 ) flag =1 ; }
@@ -223,7 +268,7 @@ test_interrupt_callback_1(void *arg)static int test_interrupt_enable (void ) { -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;/* check with null intr_handle */ if (rte_intr_enable (NULL ) ==0 ) {
@@ -232,46 +277,52 @@ test_interrupt_enable(void) }/* check with invalid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable invalid intr_handle " "successfully\n" );return -1 ; }/* check with valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ; }/* check with specific valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_ALARM ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ; }/* check with specific valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ; }/* check with valid handler and its type */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ]; -if (rte_intr_enable (&test_intr_handle) <0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_CASE1 ); +if (rte_intr_enable (test_intr_handle) <0 ) {printf ("fail to enable interrupt on a simulated handler\n" );return -1 ; } - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_UIO ); +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ;
@@ -286,7 +337,7 @@ test_interrupt_enable(void)static int test_interrupt_disable (void ) { -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;/* check with null intr_handle */ if (rte_intr_disable (NULL ) ==0 ) {
@@ -296,46 +347,52 @@ test_interrupt_disable(void) }/* check with invalid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable invalid intr_handle " "successfully\n" );return -1 ; }/* check with valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ; }/* check with specific valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_ALARM ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ; }/* check with specific valid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ; }/* check with valid handler and its type */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ]; -if (rte_intr_disable (&test_intr_handle) <0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_CASE1 ); +if (rte_intr_disable (test_intr_handle) <0 ) {printf ("fail to disable interrupt on a simulated handler\n" );return -1 ; } - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_UIO ); +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ;
@@ -351,13 +408,14 @@ static int test_interrupt_full_path_check(enum test_interrupt_handle_type intr_type) {int count; -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle; flag =0 ; - test_intr_handle = intr_handles[intr_type]; + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, + intr_type); test_intr_type = intr_type; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <0 ) { +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) <0 ) {printf ("fail to register callback\n" );return -1 ; }
@@ -371,9 +429,9 @@ test_interrupt_full_path_check(enum test_interrupt_handle_type intr_type)rte_delay_ms (TEST_INTERRUPT_CHECK_INTERVAL );while ((count = -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, - &test_intr_handle)) <0 ) { + test_intr_handle)) <0 ) {if (count != -EAGAIN )return -1 ; }
@@ -396,7 +454,7 @@ static inttest_interrupt (void) {int ret =-1 ; -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;if (test_interrupt_init () <0 ) {printf ("fail to initialize for testing interrupt\n" );
@@ -444,17 +502,20 @@ test_interrupt(void) }/* check if it will fail to register cb with invalid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) ==0 ) {printf ("unexpectedly register successfully with invalid " "intr_handle\n" ); goto out; }/* check if it will fail to register without callback */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_callback_register (&test_intr_handle,NULL , &test_intr_handle) ==0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (rte_intr_callback_register (test_intr_handle,NULL , + test_intr_handle) ==0 ) {printf ("unexpectedly register successfully with " "null callback\n" ); goto out;
@@ -469,39 +530,41 @@ test_interrupt(void) }/* check if it will fail to unregister cb with invalid intr_handle */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_callback_unregister (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) >0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_INVALID ); +if (rte_intr_callback_unregister (test_intr_handle, + test_interrupt_callback, test_intr_handle) >0 ) {printf ("unexpectedly unregister successfully with " "invalid intr_handle\n" ); goto out; }/* check if it is ok to register the same intr_handle twice */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <0 ) { + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) <0 ) {printf ("it fails to register test_interrupt_callback\n" ); goto out; } -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback_1, &test_intr_handle) <0 ) { +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback_1, test_intr_handle) <0 ) {printf ("it fails to register test_interrupt_callback_1\n" ); goto out; }/* check if it will fail to unregister with invalid parameter */ -if (rte_intr_callback_unregister (&test_intr_handle, +if (rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)0xff ) !=0 ) {printf ("unexpectedly unregisters successfully with " "invalid arg\n" ); goto out; } -if (rte_intr_callback_unregister (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <=0 ) { +if (rte_intr_callback_unregister (test_intr_handle, + test_interrupt_callback, test_intr_handle) <=0 ) {printf ("it fails to unregister test_interrupt_callback\n" ); goto out; } -if (rte_intr_callback_unregister (&test_intr_handle, +if (rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ) <=0 ) {printf ("it fails to unregister test_interrupt_callback_1 " "for all\n" );
@@ -528,28 +591,32 @@ test_interrupt(void) out:printf ("Clearing for interrupt tests\n" );/* clear registered callbacks */ - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -rte_intr_callback_unregister (&test_intr_handle, + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID ); +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -rte_intr_callback_unregister (&test_intr_handle, + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_UIO ); +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -rte_intr_callback_unregister (&test_intr_handle, + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_ALARM ); +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); - test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -rte_intr_callback_unregister (&test_intr_handle, + test_intr_handle =rte_intr_handle_instance_index_get (intr_handles, +TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ); +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 );rte_delay_ms (2 *TEST_INTERRUPT_CHECK_INTERVAL );
Signature · 1 line
2.18.0
PATCH 5/7 drivers: remove direct access to interrupt handle fields
In reply to Harman KalraRemoving direct access to interrupt handle structure fields, rather use respective get set APIs for the same. Making changes to all the drivers and libraries access the interrupt handle fields.
--- drivers/baseband/acc100/rte_acc100_pmd.c | 18 +-- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 13 +- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 14 ++- drivers/bus/auxiliary/auxiliary_common.c | 2 + drivers/bus/auxiliary/linux/auxiliary.c | 11 ++ drivers/bus/auxiliary/rte_bus_auxiliary.h | 2 +- drivers/bus/dpaa/dpaa_bus.c | 28 ++++- drivers/bus/dpaa/rte_dpaa_bus.h | 2 +- drivers/bus/fslmc/fslmc_bus.c | 17 ++- drivers/bus/fslmc/fslmc_vfio.c | 32 +++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 21 +++- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- drivers/bus/fslmc/rte_fslmc.h | 2 +- drivers/bus/ifpga/ifpga_bus.c | 16 ++- drivers/bus/ifpga/rte_bus_ifpga.h | 2 +- drivers/bus/pci/bsd/pci.c | 21 ++-- drivers/bus/pci/linux/pci.c | 4 +- drivers/bus/pci/linux/pci_uio.c | 73 +++++++---- drivers/bus/pci/linux/pci_vfio.c | 108 ++++++++++------ drivers/bus/pci/pci_common.c | 29 ++++- drivers/bus/pci/pci_common_uio.c | 21 ++-- drivers/bus/pci/rte_bus_pci.h | 4 +- drivers/bus/vmbus/linux/vmbus_bus.c | 7 ++ drivers/bus/vmbus/linux/vmbus_uio.c | 37 ++++-- drivers/bus/vmbus/rte_bus_vmbus.h | 2 +- drivers/bus/vmbus/vmbus_common_uio.c | 24 ++-- drivers/common/cnxk/roc_cpt.c | 8 +- drivers/common/cnxk/roc_dev.c | 14 +-- drivers/common/cnxk/roc_irq.c | 106 +++++++++------- drivers/common/cnxk/roc_nix_irq.c | 37 +++--- drivers/common/cnxk/roc_npa.c | 2 +- drivers/common/cnxk/roc_platform.h | 34 +++++ drivers/common/cnxk/roc_sso.c | 4 +- drivers/common/cnxk/roc_tim.c | 4 +- drivers/common/octeontx2/otx2_dev.c | 14 +-- drivers/common/octeontx2/otx2_irq.c | 117 ++++++++++-------- .../octeontx2/otx2_cryptodev_hw_access.c | 4 +- drivers/event/octeontx2/otx2_evdev_irq.c | 12 +- drivers/mempool/octeontx2/otx2_mempool.c | 2 +- drivers/net/atlantic/atl_ethdev.c | 22 ++-- drivers/net/avp/avp_ethdev.c | 8 +- drivers/net/axgbe/axgbe_ethdev.c | 12 +- drivers/net/axgbe/axgbe_mdio.c | 6 +- drivers/net/bnx2x/bnx2x_ethdev.c | 10 +- drivers/net/bnxt/bnxt_ethdev.c | 32 +++-- drivers/net/bnxt/bnxt_irq.c | 4 +- drivers/net/dpaa/dpaa_ethdev.c | 47 ++++--- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +- drivers/net/e1000/em_ethdev.c | 24 ++-- drivers/net/e1000/igb_ethdev.c | 84 ++++++------- drivers/net/ena/ena_ethdev.c | 36 +++--- drivers/net/enic/enic_main.c | 27 ++-- drivers/net/failsafe/failsafe.c | 24 +++- drivers/net/failsafe/failsafe_intr.c | 45 ++++--- drivers/net/failsafe/failsafe_ops.c | 23 +++- drivers/net/failsafe/failsafe_private.h | 2 +- drivers/net/fm10k/fm10k_ethdev.c | 32 ++--- drivers/net/hinic/hinic_pmd_ethdev.c | 10 +- drivers/net/hns3/hns3_ethdev.c | 50 ++++---- drivers/net/hns3/hns3_ethdev_vf.c | 57 +++++---- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/i40e/i40e_ethdev.c | 55 ++++---- drivers/net/i40e/i40e_ethdev_vf.c | 43 +++---- drivers/net/iavf/iavf_ethdev.c | 41 +++--- drivers/net/iavf/iavf_vchnl.c | 4 +- drivers/net/ice/ice_dcf.c | 10 +- drivers/net/ice/ice_dcf_ethdev.c | 23 ++-- drivers/net/ice/ice_ethdev.c | 51 ++++---- drivers/net/igc/igc_ethdev.c | 47 ++++--- drivers/net/ionic/ionic_ethdev.c | 12 +- drivers/net/ixgbe/ixgbe_ethdev.c | 70 +++++------ drivers/net/memif/memif_socket.c | 114 ++++++++++++----- drivers/net/memif/memif_socket.h | 4 +- drivers/net/memif/rte_eth_memif.c | 63 ++++++++-- drivers/net/memif/rte_eth_memif.h | 2 +- drivers/net/mlx4/mlx4.c | 20 ++- drivers/net/mlx4/mlx4.h | 2 +- drivers/net/mlx4/mlx4_intr.c | 48 ++++--- drivers/net/mlx5/linux/mlx5_os.c | 56 ++++++--- drivers/net/mlx5/linux/mlx5_socket.c | 26 ++-- drivers/net/mlx5/mlx5.h | 6 +- drivers/net/mlx5/mlx5_rxq.c | 43 ++++--- drivers/net/mlx5/mlx5_trigger.c | 4 +- drivers/net/mlx5/mlx5_txpp.c | 27 ++-- drivers/net/netvsc/hn_ethdev.c | 4 +- drivers/net/nfp/nfp_common.c | 28 +++-- drivers/net/nfp/nfp_ethdev.c | 13 +- drivers/net/nfp/nfp_ethdev_vf.c | 13 +- drivers/net/ngbe/ngbe_ethdev.c | 31 +++-- drivers/net/octeontx2/otx2_ethdev_irq.c | 35 +++--- drivers/net/qede/qede_ethdev.c | 16 +-- drivers/net/sfc/sfc_intr.c | 29 ++--- drivers/net/tap/rte_eth_tap.c | 37 ++++-- drivers/net/tap/rte_eth_tap.h | 2 +- drivers/net/tap/tap_intr.c | 33 +++-- drivers/net/thunderx/nicvf_ethdev.c | 13 ++ drivers/net/thunderx/nicvf_struct.h | 2 +- drivers/net/txgbe/txgbe_ethdev.c | 36 +++--- drivers/net/txgbe/txgbe_ethdev_vf.c | 35 +++--- drivers/net/vhost/rte_eth_vhost.c | 78 +++++++----- drivers/net/virtio/virtio_ethdev.c | 17 +-- .../net/virtio/virtio_user/virtio_user_dev.c | 53 +++++--- drivers/net/vmxnet3/vmxnet3_ethdev.c | 45 ++++--- drivers/raw/ifpga/ifpga_rawdev.c | 42 +++++-- drivers/raw/ntb/ntb.c | 10 +- .../regex/octeontx2/otx2_regexdev_hw_access.c | 4 +- drivers/vdpa/ifc/ifcvf_vdpa.c | 5 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 11 ++ drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 22 ++-- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 46 ++++--- lib/bbdev/rte_bbdev.c | 4 +- lib/eal/freebsd/eal_alarm.c | 49 +++++++- lib/eal/include/rte_eal_trace.h | 24 +--- lib/eal/linux/eal_alarm.c | 31 +++-- lib/eal/linux/eal_dev.c | 65 ++++++---- lib/ethdev/ethdev_pci.h | 2 +- lib/ethdev/rte_ethdev.c | 14 +-- 118 files changed, 1879 insertions(+), 1182 deletions(-)
drivers/baseband/acc100/rte_acc100_pmd.c +11 -7
@@ -720,8 +720,10 @@ acc100_intr_enable(struct rte_bbdev *dev)struct acc100_device *d = dev->data->dev_private;/* Only MSI are currently supported */ -if (dev->intr_handle->type ==RTE_INTR_HANDLE_VFIO_MSI || - dev->intr_handle->type ==RTE_INTR_HANDLE_UIO ) { +if (rte_intr_handle_type_get (dev->intr_handle) == +RTE_INTR_HANDLE_VFIO_MSI || +rte_intr_handle_type_get (dev->intr_handle) == +RTE_INTR_HANDLE_UIO ) { ret =allocate_info_ring (dev);if (ret <0 ) {
@@ -1096,8 +1098,9 @@ acc100_queue_intr_enable(struct rte_bbdev *dev, uint16_t queue_id) {struct acc100_queue *q = dev->data->queues[queue_id].queue_private; -if (dev->intr_handle->type !=RTE_INTR_HANDLE_VFIO_MSI && - dev->intr_handle->type !=RTE_INTR_HANDLE_UIO ) +if (rte_intr_handle_type_get (dev->intr_handle) != +RTE_INTR_HANDLE_VFIO_MSI && +rte_intr_handle_type_get (dev->intr_handle) !=RTE_INTR_HANDLE_UIO )return -ENOTSUP ; q->irq_enable =1 ;
@@ -1109,8 +1112,9 @@ acc100_queue_intr_disable(struct rte_bbdev *dev, uint16_t queue_id) {struct acc100_queue *q = dev->data->queues[queue_id].queue_private; -if (dev->intr_handle->type !=RTE_INTR_HANDLE_VFIO_MSI && - dev->intr_handle->type !=RTE_INTR_HANDLE_UIO ) +if (rte_intr_handle_type_get (dev->intr_handle) != +RTE_INTR_HANDLE_VFIO_MSI && +rte_intr_handle_type_get (dev->intr_handle) !=RTE_INTR_HANDLE_UIO )return -ENOTSUP ; q->irq_enable =0 ;
@@ -4178,7 +4182,7 @@ static int acc100_pci_probe(struct rte_pci_driver *pci_drv,/* Fill HW specific part of device structure */ bbdev->device = &pci_dev->device; - bbdev->intr_handle = &pci_dev->intr_handle; + bbdev->intr_handle = pci_dev->intr_handle; bbdev->data->socket_id = pci_dev->device.numa_node;/* Invoke ACC100 device initialization function */
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +7 -6
@@ -743,12 +743,13 @@ fpga_intr_enable(struct rte_bbdev *dev)* invoked when any FPGA queue issues interrupt. */ for (i =0 ; i <FPGA_NUM_INTR_VEC ; ++i) - dev->intr_handle->efds[i] = dev->intr_handle->fd; +if (rte_intr_handle_efds_index_set (dev->intr_handle, i, +rte_intr_handle_fd_get (dev->intr_handle))) +return -rte_errno; -if (!dev->intr_handle->intr_vec) { - dev->intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->num_queues *sizeof (int ),0 ); -if (!dev->intr_handle->intr_vec) { +if (!rte_intr_handle_vec_list_base (dev->intr_handle)) { +if (rte_intr_handle_vec_list_alloc (dev->intr_handle,"intr_vec" , + dev->data->num_queues)) {rte_bbdev_log (ERR ,"Failed to allocate %u vectors" , dev->data->num_queues);return -ENOMEM ;
@@ -1879,7 +1880,7 @@ fpga_5gnr_fec_probe(struct rte_pci_driver *pci_drv,/* Fill HW specific part of device structure */ bbdev->device = &pci_dev->device; - bbdev->intr_handle = &pci_dev->intr_handle; + bbdev->intr_handle = pci_dev->intr_handle; bbdev->data->socket_id = pci_dev->device.numa_node;/* Invoke FEC FPGA device initialization function */
drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +8 -6
@@ -1014,18 +1014,20 @@ fpga_intr_enable(struct rte_bbdev *dev)* invoked when any FPGA queue issues interrupt. */ for (i =0 ; i <FPGA_NUM_INTR_VEC ; ++i) - dev->intr_handle->efds[i] = dev->intr_handle->fd; +if (rte_intr_handle_efds_index_set (dev->intr_handle, i, +rte_intr_handle_fd_get (dev->intr_handle))) +return -rte_errno; -if (!dev->intr_handle->intr_vec) { - dev->intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->num_queues *sizeof (int ),0 ); -if (!dev->intr_handle->intr_vec) { +if (!rte_intr_handle_vec_list_base (dev->intr_handle)) { +if (rte_intr_handle_vec_list_alloc (dev->intr_handle,"intr_vec" , + dev->data->num_queues)) {rte_bbdev_log (ERR ,"Failed to allocate %u vectors" , dev->data->num_queues);return -ENOMEM ; } } + ret =rte_intr_enable (dev->intr_handle);if (ret <0 ) { rte_bbdev_log(ERR,
@@ -2369,7 +2371,7 @@ fpga_lte_fec_probe(struct rte_pci_driver *pci_drv,/* Fill HW specific part of device structure */ bbdev->device = &pci_dev->device; - bbdev->intr_handle = &pci_dev->intr_handle; + bbdev->intr_handle = pci_dev->intr_handle; bbdev->data->socket_id = pci_dev->device.numa_node;/* Invoke FEC FPGA device initialization function */
drivers/bus/auxiliary/auxiliary_common.c +2 -0
@@ -320,6 +320,8 @@ auxiliary_unplug(struct rte_device *dev)if (ret ==0 ) {rte_auxiliary_remove_device (adev);rte_devargs_remove (dev->devargs); +if (adev->intr_handle) +rte_intr_handle_instance_free (adev->intr_handle);free (adev); }return ret;
drivers/bus/auxiliary/linux/auxiliary.c +11 -0
@@ -39,6 +39,15 @@ auxiliary_scan_one(const char *dirname, const char *name) dev->device.name = dev->name; dev->device.bus = &auxiliary_bus.bus; +/* Allocate interrupt instance */ + dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!dev->intr_handle) { +free (dev); +return -1 ; + } +/* Get NUMA node, default to 0 if not present */ snprintf (filename,sizeof (filename),"%s/%s/numa_node" , dirname, name);
@@ -67,6 +76,8 @@ auxiliary_scan_one(const char *dirname, const char *name)rte_devargs_remove (dev2->device.devargs);auxiliary_on_scan (dev2); } +if (dev->intr_handle) +rte_intr_handle_instance_free (dev->intr_handle);free (dev); }return 0 ;
drivers/bus/auxiliary/rte_bus_auxiliary.h +1 -1
@@ -116,7 +116,7 @@ struct rte_auxiliary_device {TAILQ_ENTRY (rte_auxiliary_device) next;/**< Next probed device. */ struct rte_device device;/**< Inherit core device */ char name[RTE_DEV_NAME_MAX_LEN +1 ];/**< ASCII device name */ -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_auxiliary_driver *driver;/**< Device driver */ };
drivers/bus/dpaa/dpaa_bus.c +25 -3
@@ -172,6 +172,15 @@ dpaa_create_device_list(void) dev->device.bus = &rte_dpaa_bus.bus; +/* Allocate interrupt handle instance */ + dev->intr_handle =rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (!dev->intr_handle) { +DPAA_BUS_LOG (ERR ,"Failed to allocate intr handle" ); + ret = -ENOMEM ; + goto cleanup; + } + cfg = &dpaa_netcfg->port_cfg[i]; fman_intf = cfg->fman_if;
@@ -214,6 +223,15 @@ dpaa_create_device_list(void) goto cleanup; } +/* Allocate interrupt handle instance */ + dev->intr_handle =rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (!dev->intr_handle) { +DPAA_BUS_LOG (ERR ,"Failed to allocate intr handle" ); + ret = -ENOMEM ; + goto cleanup; + } + dev->device_type =FSL_DPAA_CRYPTO ; dev->id.dev_id = rte_dpaa_bus.device_count + i;
@@ -247,6 +265,7 @@ dpaa_clean_device_list(void) TAILQ_FOREACH_SAFE(dev, &rte_dpaa_bus.device_list, next, tdev) {TAILQ_REMOVE (&rte_dpaa_bus.device_list, dev, next); +rte_intr_handle_instance_free (dev->intr_handle);free (dev); dev =NULL ; }
@@ -559,8 +578,11 @@ static int rte_dpaa_setup_intr(struct rte_intr_handle *intr_handle)return errno; } - intr_handle->fd = fd; - intr_handle->type =RTE_INTR_HANDLE_EXT ; +if (rte_intr_handle_fd_set (intr_handle, fd)) +return -rte_errno; + +if (rte_intr_handle_type_set (intr_handle,RTE_INTR_HANDLE_EXT )) +return -rte_errno;return 0 ; }
@@ -612,7 +634,7 @@ rte_dpaa_bus_probe(void) TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) {if (dev->device_type ==FSL_DPAA_ETH ) { - ret =rte_dpaa_setup_intr (&dev->intr_handle); + ret =rte_dpaa_setup_intr (dev->intr_handle);if (ret)DPAA_BUS_ERR ("Error setting up interrupt.\n" ); }
drivers/bus/dpaa/rte_dpaa_bus.h +1 -1
@@ -101,7 +101,7 @@ struct rte_dpaa_device { };struct rte_dpaa_driver *driver;struct dpaa_device_id id; -struct rte_intr_handle intr_handle; +struct rte_intr_handle *intr_handle;enum rte_dpaa_type device_type;/**< Ethernet or crypto type device */ char name[RTE_ETH_NAME_MAX_LEN ]; };
drivers/bus/fslmc/fslmc_bus.c +16 -1
@@ -47,6 +47,8 @@ cleanup_fslmc_device_list(void) TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, t_dev) {TAILQ_REMOVE (&rte_fslmc_bus.device_list, dev, next); +if (dev->intr_handle) +rte_intr_handle_instance_free (dev->intr_handle);free (dev); dev =NULL ; }
@@ -160,6 +162,16 @@ scan_one_fslmc_device(char *dev_name) dev->device.bus = &rte_fslmc_bus.bus; +/* Allocate interrupt instance */ + dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!dev->intr_handle) { +DPAA2_BUS_ERR ("Failed to allocate intr handle" ); + ret = -ENOMEM ; + goto cleanup; + } +/* Parse the device name and ID */ t_ptr =strtok (dup_dev_name,"." );if (!t_ptr) {
@@ -220,8 +232,11 @@ scan_one_fslmc_device(char *dev_name) cleanup:if (dup_dev_name)free (dup_dev_name); -if (dev) +if (dev) { +if (dev->intr_handle) +rte_intr_handle_instance_free (dev->intr_handle);free (dev); + }return ret; }
drivers/bus/fslmc/fslmc_vfio.c +21 -11
@@ -599,7 +599,7 @@ int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index)int len, ret;char irq_set_buf[IRQ_SET_BUF_LEN ];struct vfio_irq_set *irq_set; -int *fd_ptr; +int *fd_ptr, vfio_dev_fd; len =sizeof (irq_set_buf);
@@ -611,12 +611,14 @@ int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index) irq_set->index = index; irq_set->start =0 ; fd_ptr = (int *)&irq_set->data; - *fd_ptr = intr_handle->fd; + *fd_ptr =rte_intr_handle_fd_get (intr_handle); - ret =ioctl (intr_handle->vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set); + vfio_dev_fd =rte_intr_handle_dev_fd_get (intr_handle); + ret =ioctl (vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set);if (ret) {DPAA2_BUS_ERR ("Error:dpaa2 SET IRQs fd=%d, err = %d(%s)" , - intr_handle->fd, errno,strerror (errno)); +rte_intr_handle_fd_get (intr_handle), errno, +strerror (errno));return ret; }
@@ -627,7 +629,7 @@ int rte_dpaa2_intr_disable(struct rte_intr_handle *intr_handle, int index) {struct vfio_irq_set *irq_set;char irq_set_buf[IRQ_SET_BUF_LEN ]; -int len, ret; +int len, ret, vfio_dev_fd; len =sizeof (struct vfio_irq_set );
@@ -638,11 +640,12 @@ int rte_dpaa2_intr_disable(struct rte_intr_handle *intr_handle, int index) irq_set->start =0 ; irq_set->count =0 ; - ret =ioctl (intr_handle->vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set); + vfio_dev_fd =rte_intr_handle_dev_fd_get (intr_handle); + ret =ioctl (vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set);if (ret)DPAA2_BUS_ERR ("Error disabling dpaa2 interrupts for fd %d" , - intr_handle->fd); +rte_intr_handle_fd_get (intr_handle));return ret; }
@@ -684,9 +687,16 @@ rte_dpaa2_vfio_setup_intr(struct rte_intr_handle *intr_handle,return -1 ; } - intr_handle->fd = fd; - intr_handle->type =RTE_INTR_HANDLE_VFIO_MSI ; - intr_handle->vfio_dev_fd = vfio_dev_fd; +if (rte_intr_handle_fd_set (intr_handle, fd)) +return -rte_errno; + +if (rte_intr_handle_type_set (intr_handle, +RTE_INTR_HANDLE_VFIO_MSI )) +return -rte_errno; + +if (rte_intr_handle_dev_fd_set (intr_handle, vfio_dev_fd)) +return -rte_errno; +return 0 ; }
@@ -711,7 +721,7 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev)switch (dev->dev_type) {case DPAA2_ETH : -rte_dpaa2_vfio_setup_intr (&dev->intr_handle, dev_fd, +rte_dpaa2_vfio_setup_intr (dev->intr_handle, dev_fd, device_info.num_irqs);break ;case DPAA2_CON :
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +17 -4
@@ -176,7 +176,7 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)int threshold =0x3 , timeout =0xFF ; dpio_epoll_fd =epoll_create (1 ); - ret =rte_dpaa2_intr_enable (&dpio_dev->intr_handle,0 ); + ret =rte_dpaa2_intr_enable (dpio_dev->intr_handle,0 );if (ret) {DPAA2_BUS_ERR ("Interrupt registeration failed" );return -1 ;
@@ -195,7 +195,7 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)qbman_swp_dqrr_thrshld_write (dpio_dev->sw_portal, threshold);qbman_swp_intr_timeout_write (dpio_dev->sw_portal, timeout); - eventfd = dpio_dev->intr_handle.fd; + eventfd =rte_intr_handle_fd_get (dpio_dev->intr_handle); epoll_ev.events =EPOLLIN |EPOLLPRI |EPOLLET ; epoll_ev.data.fd = eventfd;
@@ -213,7 +213,7 @@ static void dpaa2_dpio_intr_deinit(struct dpaa2_dpio_dev *dpio_dev) {int ret; - ret =rte_dpaa2_intr_disable (&dpio_dev->intr_handle,0 ); + ret =rte_dpaa2_intr_disable (dpio_dev->intr_handle,0 );if (ret)DPAA2_BUS_ERR ("DPIO interrupt disable failed" );
@@ -388,6 +388,15 @@ dpaa2_create_dpio_device(int vdev_fd,/* Using single portal for all devices */ dpio_dev->mc_portal =dpaa2_get_mcp_ptr (MC_PORTAL_INDEX ); +/* Allocate interrupt instance */ + dpio_dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + true); +if (!dpio_dev->intr_handle) { +DPAA2_BUS_ERR ("Failed to allocate intr handle" ); + goto err; + } + dpio_dev->dpio =rte_zmalloc (NULL ,sizeof (struct fsl_mc_io ),RTE_CACHE_LINE_SIZE );if (!dpio_dev->dpio) {
@@ -490,7 +499,7 @@ dpaa2_create_dpio_device(int vdev_fd, io_space_count++; dpio_dev->index = io_space_count; -if (rte_dpaa2_vfio_setup_intr (&dpio_dev->intr_handle, vdev_fd,1 )) { +if (rte_dpaa2_vfio_setup_intr (dpio_dev->intr_handle, vdev_fd,1 )) {DPAA2_BUS_ERR ("Fail to setup interrupt for %d" , dpio_dev->hw_id); goto err;
@@ -538,6 +547,8 @@ dpaa2_create_dpio_device(int vdev_fd,rte_free (dpio_dev->dpio); } +if (dpio_dev->intr_handle) +rte_intr_handle_instance_free (dpio_dev->intr_handle);rte_free (dpio_dev);/* For each element in the list, cleanup */
@@ -549,6 +560,8 @@ dpaa2_create_dpio_device(int vdev_fd, dpio_dev->token);rte_free (dpio_dev->dpio); } +if (dpio_dev->intr_handle) +rte_intr_handle_instance_free (dpio_dev->intr_handle);rte_free (dpio_dev); }
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -1
@@ -116,7 +116,7 @@ struct dpaa2_dpio_dev {uintptr_t qbman_portal_ci_paddr;/**< Physical address of Cache Inhibit Area */ uintptr_t ci_size;/**< Size of the CI region */ -struct rte_intr_handle intr_handle;/* Interrupt related info */ +struct rte_intr_handle *intr_handle;/* Interrupt related info */ int32_t epoll_fd;/**< File descriptor created for interrupt polling */ int32_t hw_id;/**< An unique ID of this DPIO device instance */ struct dpaa2_portal_dqrr dpaa2_held_bufs;
drivers/bus/fslmc/rte_fslmc.h +1 -1
@@ -125,7 +125,7 @@ struct rte_dpaa2_device { };enum rte_dpaa2_dev_type dev_type;/**< Device Type */ uint16_t object_id;/**< DPAA2 Object ID */ -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_dpaa2_driver *driver;/**< Associated driver */ char name[FSLMC_OBJECT_MAX_LEN ];/**< DPAA2 Object name*/ };
drivers/bus/ifpga/ifpga_bus.c +15 -1
@@ -161,6 +161,15 @@ ifpga_scan_one(struct rte_rawdev *rawdev, afu_dev->id.uuid.uuid_high =0 ; afu_dev->id.port = afu_pr_conf.afu_id.port; +/* Allocate interrupt instance */ + afu_dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!afu_dev->intr_handle) { +IFPGA_BUS_ERR ("Failed to allocate intr handle" ); + goto end; + } +if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get) rawdev->dev_ops->dev_info_get (rawdev, afu_dev,sizeof (*afu_dev));
@@ -189,8 +198,11 @@ ifpga_scan_one(struct rte_rawdev *rawdev,rte_kvargs_free (kvlist);if (path)free (path); -if (afu_dev) +if (afu_dev) { +if (afu_dev->intr_handle) +rte_intr_handle_instance_free (afu_dev->intr_handle);free (afu_dev); + }return NULL ; }
@@ -396,6 +408,8 @@ ifpga_unplug(struct rte_device *dev)TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next);rte_devargs_remove (dev->devargs); +if (afu_dev->intr_handle) +rte_intr_handle_instance_free (afu_dev->intr_handle);free (afu_dev);return 0 ;
drivers/bus/ifpga/rte_bus_ifpga.h +1 -1
@@ -79,7 +79,7 @@ struct rte_afu_device {struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ];/**< AFU Memory Resource */ struct rte_afu_shared shared; -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_afu_driver *driver;/**< Associated driver */ char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; } __rte_packed;
drivers/bus/pci/bsd/pci.c +14 -7
@@ -95,10 +95,11 @@ pci_uio_free_resource(struct rte_pci_device *dev, {rte_free (uio_res); -if (dev->intr_handle.fd) { -close (dev->intr_handle.fd); - dev->intr_handle.fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +if (rte_intr_handle_fd_get (dev->intr_handle)) { +close (rte_intr_handle_fd_get (dev->intr_handle)); +rte_intr_handle_fd_set (dev->intr_handle,-1 ); +rte_intr_handle_type_set (dev->intr_handle, +RTE_INTR_HANDLE_UNKNOWN ); } }
@@ -121,13 +122,19 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, }/* save fd if in primary process */ - dev->intr_handle.fd =open (devname,O_RDWR ); -if (dev->intr_handle.fd <0 ) { +if (rte_intr_handle_fd_set (dev->intr_handle,open (devname,O_RDWR ))) { +RTE_LOG (WARNING ,EAL ,"Failed to save fd" ); + goto error; + } + +if (rte_intr_handle_fd_get (dev->intr_handle) <0 ) {RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , devname,strerror (errno)); goto error; } - dev->intr_handle.type =RTE_INTR_HANDLE_UIO ; + +if (rte_intr_handle_type_set (dev->intr_handle,RTE_INTR_HANDLE_UIO )) + goto error;/* allocate the mapping details for secondary processes*/ *uio_res =rte_zmalloc ("UIO_RES" ,sizeof (**uio_res),0 );
drivers/bus/pci/linux/pci.c +2 -2
@@ -645,7 +645,7 @@ int rte_pci_read_config(const struct rte_pci_device *device, void *buf, size_t len, off_t offset) { char devname[RTE_DEV_NAME_MAX_LEN] = ""; -const struct rte_intr_handle *intr_handle = &device->intr_handle; +const struct rte_intr_handle *intr_handle = device->intr_handle;switch (device->kdrv) {case RTE_PCI_KDRV_IGB_UIO :
@@ -669,7 +669,7 @@ int rte_pci_write_config(const struct rte_pci_device *device, const void *buf, size_t len, off_t offset) { char devname[RTE_DEV_NAME_MAX_LEN] = ""; -const struct rte_intr_handle *intr_handle = &device->intr_handle; +const struct rte_intr_handle *intr_handle = device->intr_handle;switch (device->kdrv) {case RTE_PCI_KDRV_IGB_UIO :
drivers/bus/pci/linux/pci_uio.c +49 -24
142 lines not on this page · raw message
drivers/bus/pci/linux/pci_vfio.c +70 -38
245 lines not on this page · raw message
drivers/bus/pci/pci_common.c +27 -2
@@ -230,6 +230,24 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, }if (!already_probed && (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING )) { +/* Allocate interrupt instance for pci device */ + dev->intr_handle =rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (!dev->intr_handle) { +RTE_LOG (ERR ,EAL , +"Failed to create interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + } + + dev->vfio_req_intr_handle =rte_intr_handle_instance_alloc ( +RTE_INTR_HANDLE_DEFAULT_SIZE , false); +if (!dev->vfio_req_intr_handle) { +RTE_LOG (ERR ,EAL , +"Failed to create vfio req interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + }/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) {
@@ -253,8 +271,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver needs mapped resources. */ !(ret > 0 && - (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES))) + (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES))) {rte_pci_unmap_device (dev); +rte_intr_handle_instance_free (dev->intr_handle); +rte_intr_handle_instance_free ( + dev->vfio_req_intr_handle); + } }else { dev->device.driver = &dr->driver; }
@@ -296,9 +318,12 @@ rte_pci_detach_dev(struct rte_pci_device *dev) dev->driver =NULL ; dev->device.driver =NULL ; -if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) +if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) {/* unmap resources for devices that use igb_uio */ rte_pci_unmap_device (dev); +rte_intr_handle_instance_free (dev->intr_handle); +rte_intr_handle_instance_free (dev->vfio_req_intr_handle); + }return 0 ; }
drivers/bus/pci/pci_common_uio.c +13 -8
@@ -90,8 +90,11 @@ pci_uio_map_resource(struct rte_pci_device *dev)struct mapped_pci_res_list *uio_res_list =RTE_TAILQ_CAST (rte_uio_tailq.head, mapped_pci_res_list); - dev->intr_handle.fd =-1 ; - dev->intr_handle.uio_cfg_fd =-1 ; +if (rte_intr_handle_fd_set (dev->intr_handle,-1 )) +return -1 ; + +if (rte_intr_handle_dev_fd_set (dev->intr_handle,-1 )) +return -1 ;/* secondary processes - use already recorded details */ if (rte_eal_process_type () !=RTE_PROC_PRIMARY )
@@ -207,6 +210,7 @@ pci_uio_unmap_resource(struct rte_pci_device *dev)struct mapped_pci_resource *uio_res;struct mapped_pci_res_list *uio_res_list =RTE_TAILQ_CAST (rte_uio_tailq.head, mapped_pci_res_list); +int uio_cfg_fd;if (dev ==NULL )return ;
@@ -229,12 +233,13 @@ pci_uio_unmap_resource(struct rte_pci_device *dev)rte_free (uio_res);/* close fd if in primary process */ -close (dev->intr_handle.fd); -if (dev->intr_handle.uio_cfg_fd >=0 ) { -close (dev->intr_handle.uio_cfg_fd); - dev->intr_handle.uio_cfg_fd =-1 ; +close (rte_intr_handle_fd_get (dev->intr_handle)); + uio_cfg_fd =rte_intr_handle_dev_fd_get (dev->intr_handle); +if (uio_cfg_fd >=0 ) { +close (uio_cfg_fd); +rte_intr_handle_dev_fd_set (dev->intr_handle,-1 ); } - dev->intr_handle.fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +rte_intr_handle_fd_set (dev->intr_handle,-1 ); +rte_intr_handle_type_set (dev->intr_handle,RTE_INTR_HANDLE_UNKNOWN ); }
drivers/bus/pci/rte_bus_pci.h +2 -2
@@ -70,12 +70,12 @@ struct rte_pci_device {struct rte_pci_id id;/**< PCI ID. */ struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ];/**< PCI Memory Resource */ -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_pci_driver *driver;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_pci_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */ -struct rte_intr_handle vfio_req_intr_handle; +struct rte_intr_handle *vfio_req_intr_handle;/**< Handler of VFIO request interrupt */ };
drivers/bus/vmbus/linux/vmbus_bus.c +7 -0
@@ -297,6 +297,13 @@ vmbus_scan_one(const char *name) dev->device.devargs =vmbus_devargs_lookup (dev); +/* Allocate interrupt handle instance */ + dev->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!dev->intr_handle) + goto error; +/* device is valid, add in list (sorted) */ VMBUS_LOG (DEBUG ,"Adding vmbus device %s" , name);
drivers/bus/vmbus/linux/vmbus_uio.c +24 -13
@@ -29,9 +29,11 @@ static void *vmbus_map_addr;/* Control interrupts */ void vmbus_uio_irq_control (struct rte_vmbus_device *dev,int32_t onoff) { -if (write (dev->intr_handle.fd, &onoff,sizeof (onoff)) <0 ) { +if (write (rte_intr_handle_fd_get (dev->intr_handle), &onoff, +sizeof (onoff)) <0 ) {VMBUS_LOG (ERR ,"cannot write to %d:%s" , - dev->intr_handle.fd,strerror (errno)); +rte_intr_handle_fd_get (dev->intr_handle), +strerror (errno)); } }
@@ -40,7 +42,8 @@ int vmbus_uio_irq_read(struct rte_vmbus_device *dev)int32_t count;int cc; - cc =read (dev->intr_handle.fd, &count,sizeof (count)); + cc =read (rte_intr_handle_fd_get (dev->intr_handle), &count, +sizeof (count));if (cc < (int )sizeof (count)) {if (cc <0 ) { VMBUS_LOG(ERR, "IRQ read failed %s",
@@ -60,15 +63,16 @@ vmbus_uio_free_resource(struct rte_vmbus_device *dev, {rte_free (uio_res); -if (dev->intr_handle.uio_cfg_fd >=0 ) { -close (dev->intr_handle.uio_cfg_fd); - dev->intr_handle.uio_cfg_fd =-1 ; +if (rte_intr_handle_dev_fd_get (dev->intr_handle) >=0 ) { +close (rte_intr_handle_dev_fd_get (dev->intr_handle)); +rte_intr_handle_dev_fd_set (dev->intr_handle,-1 ); } -if (dev->intr_handle.fd >=0 ) { -close (dev->intr_handle.fd); - dev->intr_handle.fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +if (rte_intr_handle_fd_get (dev->intr_handle) >=0 ) { +close (rte_intr_handle_fd_get (dev->intr_handle)); +rte_intr_handle_fd_set (dev->intr_handle,-1 ); +rte_intr_handle_type_set (dev->intr_handle, +RTE_INTR_HANDLE_UNKNOWN ); } }
@@ -77,16 +81,23 @@ vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, struct mapped_vmbus_resource **uio_res) {char devname[PATH_MAX ];/* contains the /dev/uioX */ +int fd;/* save fd if in primary process */ snprintf (devname,sizeof (devname),"/dev/uio%u" , dev->uio_num); - dev->intr_handle.fd =open (devname,O_RDWR ); -if (dev->intr_handle.fd <0 ) { + fd =open (devname,O_RDWR ); +if (fd <0 ) {VMBUS_LOG (ERR ,"Cannot open %s: %s" , devname,strerror (errno)); goto error; } - dev->intr_handle.type =RTE_INTR_HANDLE_UIO_INTX ; + +if (rte_intr_handle_fd_set (dev->intr_handle, fd)) + goto error; + +if (rte_intr_handle_type_set (dev->intr_handle, +RTE_INTR_HANDLE_UIO_INTX )) + goto error;/* allocate the mapping details for secondary processes*/ *uio_res =rte_zmalloc ("UIO_RES" ,sizeof (**uio_res),0 );
drivers/bus/vmbus/rte_bus_vmbus.h +1 -1
@@ -74,7 +74,7 @@ struct rte_vmbus_device {struct vmbus_channel *primary;/**< VMBUS primary channel */ struct vmbus_mon_page *monitor_page;/**< VMBUS monitor page */ -struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_mem_resource resource[VMBUS_MAX_RESOURCE ]; };
drivers/bus/vmbus/vmbus_common_uio.c +15 -9
@@ -149,9 +149,15 @@ vmbus_uio_map_resource(struct rte_vmbus_device *dev)int ret;/* TODO: handle rescind */ - dev->intr_handle.fd =-1 ; - dev->intr_handle.uio_cfg_fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +if (rte_intr_handle_fd_set (dev->intr_handle,-1 )) +return -1 ; + +if (rte_intr_handle_dev_fd_set (dev->intr_handle,-1 )) +return -1 ; + +if (rte_intr_handle_type_set (dev->intr_handle, +RTE_INTR_HANDLE_UNKNOWN )) +return -1 ;/* secondary processes - use already recorded details */ if (rte_eal_process_type () !=RTE_PROC_PRIMARY )
@@ -223,12 +229,12 @@ vmbus_uio_unmap_resource(struct rte_vmbus_device *dev)rte_free (uio_res);/* close fd if in primary process */ -close (dev->intr_handle.fd); -if (dev->intr_handle.uio_cfg_fd >=0 ) { -close (dev->intr_handle.uio_cfg_fd); - dev->intr_handle.uio_cfg_fd =-1 ; +close (rte_intr_handle_fd_get (dev->intr_handle)); +if (rte_intr_handle_dev_fd_get (dev->intr_handle) >=0 ) { +close (rte_intr_handle_dev_fd_get (dev->intr_handle)); +rte_intr_handle_dev_fd_set (dev->intr_handle,-1 ); } - dev->intr_handle.fd =-1 ; - dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +rte_intr_handle_fd_set (dev->intr_handle,-1 ); +rte_intr_handle_type_set (dev->intr_handle,RTE_INTR_HANDLE_UNKNOWN ); }
drivers/common/cnxk/roc_cpt.c +4 -4
@@ -62,7 +62,7 @@ cpt_lf_register_misc_irq(struct roc_cpt_lf *lf)struct plt_intr_handle *handle;int rc, vec; - handle = &pci_dev->intr_handle; + handle = pci_dev->intr_handle; vec = lf->msixoff +CPT_LF_INT_VEC_MISC ;/* Clear err interrupt */
@@ -82,7 +82,7 @@ cpt_lf_unregister_misc_irq(struct roc_cpt_lf *lf)struct plt_intr_handle *handle;int vec; - handle = &pci_dev->intr_handle; + handle = pci_dev->intr_handle; vec = lf->msixoff +CPT_LF_INT_VEC_MISC ;/* Clear err interrupt */
@@ -126,7 +126,7 @@ cpt_lf_register_done_irq(struct roc_cpt_lf *lf)struct plt_intr_handle *handle;int rc, vec; - handle = &pci_dev->intr_handle; + handle = pci_dev->intr_handle; vec = lf->msixoff +CPT_LF_INT_VEC_DONE ;
@@ -149,7 +149,7 @@ cpt_lf_unregister_done_irq(struct roc_cpt_lf *lf)struct plt_intr_handle *handle;int vec; - handle = &pci_dev->intr_handle; + handle = pci_dev->intr_handle; vec = lf->msixoff +CPT_LF_INT_VEC_DONE ;
drivers/common/cnxk/roc_dev.c +7 -7
@@ -608,7 +608,7 @@ roc_af_pf_mbox_irq(void *param)static int mbox_register_pf_irq (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;int i, rc;/* HW clear irq */
@@ -658,7 +658,7 @@ mbox_register_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev)static int mbox_register_vf_irq (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;int rc;/* Clear irq */
@@ -691,7 +691,7 @@ mbox_register_irq(struct plt_pci_device *pci_dev, struct dev *dev)static void mbox_unregister_pf_irq (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;int i;/* HW clear irq */
@@ -722,7 +722,7 @@ mbox_unregister_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev)static void mbox_unregister_vf_irq (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;/* Clear irq */ plt_write64 (~0ull , dev->bar2 +RVU_VF_INT_ENA_W1C );
@@ -806,7 +806,7 @@ roc_pf_vf_flr_irq(void *param)static int vf_flr_unregister_irqs (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;int i;plt_base_dbg ("Unregister VF FLR interrupts for %s" , pci_dev->name);
@@ -827,7 +827,7 @@ vf_flr_unregister_irqs(struct plt_pci_device *pci_dev, struct dev *dev)static int vf_flr_register_irqs (struct plt_pci_device *pci_dev,struct dev *dev) { -struct plt_intr_handle *handle = &pci_dev->intr_handle; +struct plt_intr_handle *handle = pci_dev->intr_handle;int i, rc;plt_base_dbg ("Register VF FLR interrupts for %s" , pci_dev->name);
@@ -1143,7 +1143,7 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)int dev_fini (struct dev *dev,struct plt_pci_device *pci_dev) { -struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; +struct plt_intr_handle *intr_handle = pci_dev->intr_handle;struct mbox *mbox;/* Check if this dev hosts npalf and has 1+ refs */
drivers/common/cnxk/roc_irq.c +63 -43
219 lines not on this page · raw message
drivers/common/cnxk/roc_nix_irq.c +21 -16
@@ -82,7 +82,7 @@ nix_lf_err_irq(void *param)static int nix_lf_register_err_irq (struct nix *nix) { -struct plt_intr_handle *handle = &nix->pci_dev->intr_handle; +struct plt_intr_handle *handle = nix->pci_dev->intr_handle;int rc, vec; vec = nix->msixoff +NIX_LF_INT_VEC_ERR_INT ;
@@ -99,7 +99,7 @@ nix_lf_register_err_irq(struct nix *nix)static void nix_lf_unregister_err_irq (struct nix *nix) { -struct plt_intr_handle *handle = &nix->pci_dev->intr_handle; +struct plt_intr_handle *handle = nix->pci_dev->intr_handle;int vec; vec = nix->msixoff +NIX_LF_INT_VEC_ERR_INT ;
@@ -131,7 +131,7 @@ nix_lf_ras_irq(void *param)static int nix_lf_register_ras_irq (struct nix *nix) { -struct plt_intr_handle *handle = &nix->pci_dev->intr_handle; +struct plt_intr_handle *handle = nix->pci_dev->intr_handle;int rc, vec; vec = nix->msixoff +NIX_LF_INT_VEC_POISON ;
@@ -148,7 +148,7 @@ nix_lf_register_ras_irq(struct nix *nix)static void nix_lf_unregister_ras_irq (struct nix *nix) { -struct plt_intr_handle *handle = &nix->pci_dev->intr_handle; +struct plt_intr_handle *handle = nix->pci_dev->intr_handle;int vec; vec = nix->msixoff +NIX_LF_INT_VEC_POISON ;
@@ -300,7 +300,7 @@ roc_nix_register_queue_irqs(struct roc_nix *roc_nix)struct nix *nix; nix =roc_nix_to_nix_priv (roc_nix); - handle = &nix->pci_dev->intr_handle; + handle = nix->pci_dev->intr_handle;/* Figure out max qintx required */ rqs =PLT_MIN (nix->qints, nix->nb_rx_queues);
@@ -352,7 +352,7 @@ roc_nix_unregister_queue_irqs(struct roc_nix *roc_nix)int vec, q; nix =roc_nix_to_nix_priv (roc_nix); - handle = &nix->pci_dev->intr_handle; + handle = nix->pci_dev->intr_handle;for (q =0 ; q < nix->configured_qints; q++) { vec = nix->msixoff +NIX_LF_INT_VEC_QINT_START + q;
@@ -382,7 +382,7 @@ roc_nix_register_cq_irqs(struct roc_nix *roc_nix)struct nix *nix; nix =roc_nix_to_nix_priv (roc_nix); - handle = &nix->pci_dev->intr_handle; + handle = nix->pci_dev->intr_handle; nix->configured_cints =PLT_MIN (nix->cints, nix->nb_rx_queues);
@@ -414,19 +414,21 @@ roc_nix_register_cq_irqs(struct roc_nix *roc_nix)return rc; } -if (!handle->intr_vec) { - handle->intr_vec =plt_zmalloc ( - nix->configured_cints *sizeof (int ),0 ); -if (!handle->intr_vec) { -plt_err ("Failed to allocate %d rx intr_vec" , - nix->configured_cints); -return -ENOMEM ; +if (!plt_intr_handle_vec_list_base (handle)) { + rc =plt_intr_handle_vec_list_alloc (handle,"cnxk" , + nix->configured_cints); +if (rc) { +plt_err ("Fail to allocate intr vec list, rc=%d" , + rc); +return rc; } }/* VFIO vector zero is resereved for misc interrupt so * doing required adjustment. (b13bfab4cd) */ - handle->intr_vec[q] =PLT_INTR_VEC_RXTX_OFFSET + vec; +if (plt_intr_handle_vec_list_index_set (handle, q, +PLT_INTR_VEC_RXTX_OFFSET + vec)) +return -1 ;/* Configure CQE interrupt coalescing parameters */ plt_write64(((CQ_CQE_THRESH_DEFAULT) |
@@ -450,7 +452,7 @@ roc_nix_unregister_cq_irqs(struct roc_nix *roc_nix)int vec, q; nix =roc_nix_to_nix_priv (roc_nix); - handle = &nix->pci_dev->intr_handle; + handle = nix->pci_dev->intr_handle;for (q =0 ; q < nix->configured_cints; q++) { vec = nix->msixoff +NIX_LF_INT_VEC_CINT_START + q;
@@ -465,6 +467,9 @@ roc_nix_unregister_cq_irqs(struct roc_nix *roc_nix)dev_irq_unregister (handle, nix_lf_cq_irq, &nix->cints_mem[q], vec); } + +if (plt_intr_handle_vec_list_base (handle)) +plt_intr_handle_vec_list_free (handle);plt_free (nix->cints_mem); }
drivers/common/cnxk/roc_npa.c +1 -1
@@ -710,7 +710,7 @@ npa_lf_init(struct dev *dev, struct plt_pci_device *pci_dev) lf->pf_func = dev->pf_func; lf->npa_msixoff = npa_msixoff; - lf->intr_handle = &pci_dev->intr_handle; + lf->intr_handle = pci_dev->intr_handle; lf->pci_dev = pci_dev; idev->npa_pf_func = dev->pf_func;
drivers/common/cnxk/roc_platform.h +34 -0
@@ -101,6 +101,40 @@#define plt_thread_is_intr rte_thread_is_intr#define plt_intr_callback_fn rte_intr_callback_fn +#define plt_intr_handle_efd_counter_size_get \ + rte_intr_handle_efd_counter_size_get +#define plt_intr_handle_efd_counter_size_set \ + rte_intr_handle_efd_counter_size_set +#define plt_intr_handle_vec_list_index_get rte_intr_handle_vec_list_index_get +#define plt_intr_handle_vec_list_index_set rte_intr_handle_vec_list_index_set +#define plt_intr_handle_vec_list_base rte_intr_handle_vec_list_base +#define plt_intr_handle_vec_list_alloc rte_intr_handle_vec_list_alloc +#define plt_intr_handle_vec_list_free rte_intr_handle_vec_list_free +#define plt_intr_handle_vec_list_base rte_intr_handle_vec_list_base +#define plt_intr_handle_vec_list_base rte_intr_handle_vec_list_base +#define plt_intr_handle_fd_set rte_intr_handle_fd_set +#define plt_intr_handle_fd_get rte_intr_handle_fd_get +#define plt_intr_handle_dev_fd_get rte_intr_handle_dev_fd_get +#define plt_intr_handle_dev_fd_set rte_intr_handle_dev_fd_set +#define plt_intr_handle_type_get rte_intr_handle_type_get +#define plt_intr_handle_type_set rte_intr_handle_type_set +#define plt_intr_handle_instance_alloc rte_intr_handle_instance_alloc +#define plt_intr_handle_instance_index_get rte_intr_handle_instance_index_get +#define plt_intr_handle_instance_index_set rte_intr_handle_instance_index_set +#define plt_intr_handle_instance_free rte_intr_handle_instance_free +#define plt_intr_handle_event_list_update rte_intr_handle_event_list_update +#define plt_intr_handle_max_intr_get rte_intr_handle_max_intr_get +#define plt_intr_handle_max_intr_set rte_intr_handle_max_intr_set +#define plt_intr_handle_nb_efd_get rte_intr_handle_nb_efd_get +#define plt_intr_handle_nb_efd_set rte_intr_handle_nb_efd_set +#define plt_intr_handle_nb_intr_get rte_intr_handle_nb_intr_get +#define plt_intr_handle_nb_intr_set rte_intr_handle_nb_intr_set +#define plt_intr_handle_efds_index_get rte_intr_handle_efds_index_get +#define plt_intr_handle_efds_index_set rte_intr_handle_efds_index_set +#define plt_intr_handle_efds_base rte_intr_handle_efds_base +#define plt_intr_handle_elist_index_get rte_intr_handle_elist_index_get +#define plt_intr_handle_elist_index_set rte_intr_handle_elist_index_set +#define plt_alarm_set rte_eal_alarm_set#define plt_alarm_cancel rte_eal_alarm_cancel
drivers/common/cnxk/roc_sso.c +2 -2
@@ -491,7 +491,7 @@ roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t nb_hwgrp) goto sso_msix_fail; } - rc =sso_register_irqs_priv (roc_sso, &sso->pci_dev->intr_handle, nb_hws, + rc =sso_register_irqs_priv (roc_sso, sso->pci_dev->intr_handle, nb_hws, nb_hwgrp);if (rc <0 ) {plt_err ("Failed to register SSO LF IRQs" );
@@ -521,7 +521,7 @@ roc_sso_rsrc_fini(struct roc_sso *roc_sso)if (!roc_sso->nb_hws && !roc_sso->nb_hwgrp)return ; -sso_unregister_irqs_priv (roc_sso, &sso->pci_dev->intr_handle, +sso_unregister_irqs_priv (roc_sso, sso->pci_dev->intr_handle, roc_sso->nb_hws, roc_sso->nb_hwgrp);sso_lf_free (roc_sso,SSO_LF_TYPE_HWS , roc_sso->nb_hws);sso_lf_free (roc_sso,SSO_LF_TYPE_HWGRP , roc_sso->nb_hwgrp);
drivers/common/cnxk/roc_tim.c +2 -2
@@ -200,7 +200,7 @@ roc_tim_lf_alloc(struct roc_tim *roc_tim, uint8_t ring_id, uint64_t *clk)if (clk) *clk = rsp->tenns_clk; - rc =tim_register_irq_priv (roc_tim, &sso->pci_dev->intr_handle, ring_id, + rc =tim_register_irq_priv (roc_tim, sso->pci_dev->intr_handle, ring_id, tim->tim_msix_offsets[ring_id]);if (rc <0 ) {plt_tim_dbg ("Failed to register Ring[%d] IRQ" , ring_id);
@@ -223,7 +223,7 @@ roc_tim_lf_free(struct roc_tim *roc_tim, uint8_t ring_id)struct tim_ring_req *req;int rc = -ENOSPC ; -tim_unregister_irq_priv (roc_tim, &sso->pci_dev->intr_handle, ring_id, +tim_unregister_irq_priv (roc_tim, sso->pci_dev->intr_handle, ring_id, tim->tim_msix_offsets[ring_id]); req =mbox_alloc_msg_tim_lf_free (dev->mbox);
drivers/common/octeontx2/otx2_dev.c +7 -7
@@ -640,7 +640,7 @@ otx2_af_pf_mbox_irq(void *param)static int mbox_register_pf_irq (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int i, rc;/* HW clear irq */
@@ -690,7 +690,7 @@ mbox_register_pf_irq(struct rte_pci_device *pci_dev, struct otx2_dev *dev)static int mbox_register_vf_irq (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int rc;/* Clear irq */
@@ -723,7 +723,7 @@ mbox_register_irq(struct rte_pci_device *pci_dev, struct otx2_dev *dev)static void mbox_unregister_pf_irq (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int i;/* HW clear irq */
@@ -755,7 +755,7 @@ mbox_unregister_pf_irq(struct rte_pci_device *pci_dev, struct otx2_dev *dev)static void mbox_unregister_vf_irq (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;/* Clear irq */ otx2_write64 (~0ull , dev->bar2 +RVU_VF_INT_ENA_W1C );
@@ -838,7 +838,7 @@ otx2_pf_vf_flr_irq(void *param)static int vf_flr_unregister_irqs (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int i;otx2_base_dbg ("Unregister VF FLR interrupts for %s" , pci_dev->name);
@@ -859,7 +859,7 @@ vf_flr_unregister_irqs(struct rte_pci_device *pci_dev, struct otx2_dev *dev)static int vf_flr_register_irqs (struct rte_pci_device *pci_dev,struct otx2_dev *dev) { -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int i, rc;otx2_base_dbg ("Register VF FLR interrupts for %s" , pci_dev->name);
@@ -1036,7 +1036,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)void otx2_dev_fini (struct rte_pci_device *pci_dev,void *otx2_dev) { -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct otx2_dev *dev = otx2_dev;struct otx2_idev_cfg *idev;struct otx2_mbox *mbox;
drivers/common/octeontx2/otx2_irq.c +68 -49
231 lines not on this page · raw message
drivers/crypto/octeontx2/otx2_cryptodev_hw_access.c +2 -2
@@ -36,7 +36,7 @@ otx2_cpt_lf_err_intr_unregister(const struct rte_cryptodev *dev, uint16_t msix_off, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;/* Disable error interrupts */ otx2_write64 (~0ull , base +OTX2_CPT_LF_MISC_INT_ENA_W1C );
@@ -65,7 +65,7 @@ otx2_cpt_lf_err_intr_register(const struct rte_cryptodev *dev, uint16_t msix_off, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int ret;/* Disable error interrupts */
drivers/event/octeontx2/otx2_evdev_irq.c +6 -6
@@ -29,7 +29,7 @@ sso_lf_register_irq(const struct rte_eventdev *event_dev, uint16_t ggrp_msixoff, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (event_dev->dev); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int rc, vec; vec = ggrp_msixoff +SSO_LF_INT_VEC_GRP ;
@@ -66,7 +66,7 @@ ssow_lf_register_irq(const struct rte_eventdev *event_dev, uint16_t gws_msixoff, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (event_dev->dev); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int rc, vec; vec = gws_msixoff +SSOW_LF_INT_VEC_IOP ;
@@ -86,7 +86,7 @@ sso_lf_unregister_irq(const struct rte_eventdev *event_dev, uint16_t ggrp_msixoff, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (event_dev->dev); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int vec; vec = ggrp_msixoff +SSO_LF_INT_VEC_GRP ;
@@ -101,7 +101,7 @@ ssow_lf_unregister_irq(const struct rte_eventdev *event_dev, uint16_t gws_msixoff, uintptr_t base) {struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (event_dev->dev); -struct rte_intr_handle *handle = &pci_dev->intr_handle; +struct rte_intr_handle *handle = pci_dev->intr_handle;int vec; vec = gws_msixoff +SSOW_LF_INT_VEC_IOP ;
@@ -198,7 +198,7 @@ static int tim_lf_register_irq(struct rte_pci_device *pci_dev, uint16_t tim_msixoff, uintptr_t base) { - struct rte_intr_handle *handle = &pci_dev->intr_handle; + struct rte_intr_handle *handle = pci_dev->intr_handle;int rc, vec; vec = tim_msixoff +TIM_LF_INT_VEC_NRSPERR_INT ;
@@ -226,7 +226,7 @@ static void tim_lf_unregister_irq(struct rte_pci_device *pci_dev, uint16_t tim_msixoff, uintptr_t base) { - struct rte_intr_handle *handle = &pci_dev->intr_handle; + struct rte_intr_handle *handle = pci_dev->intr_handle;int vec; vec = tim_msixoff +TIM_LF_INT_VEC_NRSPERR_INT ;
drivers/mempool/octeontx2/otx2_mempool.c +1 -1
@@ -301,7 +301,7 @@ otx2_npa_lf_init(struct rte_pci_device *pci_dev, void *otx2_dev) lf->pf_func = dev->pf_func; lf->npa_msixoff = npa_msixoff; - lf->intr_handle = &pci_dev->intr_handle; + lf->intr_handle = pci_dev->intr_handle; lf->pci_dev = pci_dev; idev->npa_pf_func = dev->pf_func;
drivers/net/atlantic/atl_ethdev.c +10 -12
@@ -360,7 +360,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) {struct atl_adapter *adapter = eth_dev->data->dev_private;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);int err =0 ;
@@ -479,7 +479,7 @@ atl_dev_start(struct rte_eth_dev *dev) {struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;int status;int err;
@@ -525,10 +525,10 @@ atl_dev_start(struct rte_eth_dev *dev) } } -if (rte_intr_dp_is_en (intr_handle) && !intr_handle->intr_vec) { - intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->nb_rx_queues *sizeof (int ),0 ); -if (intr_handle->intr_vec ==NULL ) { +if (rte_intr_dp_is_en (intr_handle) && + !rte_intr_handle_vec_list_base (intr_handle)) { +if (rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + dev->data->nb_rx_queues)) {PMD_INIT_LOG (ERR ,"Failed to allocate %d rx_queues" " intr_vec" , dev->data->nb_rx_queues);return -ENOMEM ;
@@ -608,7 +608,7 @@ atl_dev_stop(struct rte_eth_dev *dev)struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;PMD_INIT_FUNC_TRACE (); dev->data->dev_started =0 ;
@@ -638,10 +638,8 @@ atl_dev_stop(struct rte_eth_dev *dev)/* Clean datapath event and queue/vec mapping */ rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle);return 0 ; }
@@ -692,7 +690,7 @@ static int atl_dev_close(struct rte_eth_dev *dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct aq_hw_s *hw;int ret;
drivers/net/avp/avp_ethdev.c +4 -4
@@ -711,7 +711,7 @@ avp_dev_interrupt_handler(void *data) status);/* re-enable UIO interrupt handling */ - ret =rte_intr_ack (&pci_dev->intr_handle); + ret =rte_intr_ack (pci_dev->intr_handle);if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to re-enable UIO interrupts, ret=%d\n" , ret);
@@ -730,7 +730,7 @@ avp_dev_enable_interrupts(struct rte_eth_dev *eth_dev)return -EINVAL ;/* enable UIO interrupt handling */ - ret =rte_intr_enable (&pci_dev->intr_handle); + ret =rte_intr_enable (pci_dev->intr_handle);if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to enable UIO interrupts, ret=%d\n" , ret);
@@ -759,7 +759,7 @@ avp_dev_disable_interrupts(struct rte_eth_dev *eth_dev) RTE_PTR_ADD(registers, RTE_AVP_INTERRUPT_MASK_OFFSET));/* enable UIO interrupt handling */ - ret =rte_intr_disable (&pci_dev->intr_handle); + ret =rte_intr_disable (pci_dev->intr_handle);if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to disable UIO interrupts, ret=%d\n" , ret);
@@ -776,7 +776,7 @@ avp_dev_setup_interrupts(struct rte_eth_dev *eth_dev)int ret;/* register a callback handler with UIO for interrupt notifications */ - ret =rte_intr_callback_register (&pci_dev->intr_handle, + ret =rte_intr_callback_register (pci_dev->intr_handle, avp_dev_interrupt_handler, (void *)eth_dev);if (ret <0 ) {
drivers/net/axgbe/axgbe_ethdev.c +6 -6
@@ -313,7 +313,7 @@ axgbe_dev_interrupt_handler(void *param) } }/* Unmask interrupts since disabled after generation */ -rte_intr_ack (&pdata->pci_dev->intr_handle); +rte_intr_ack (pdata->pci_dev->intr_handle); }/*
@@ -374,7 +374,7 @@ axgbe_dev_start(struct rte_eth_dev *dev) }/* enable uio/vfio intr/eventfd mapping */ -rte_intr_enable (&pdata->pci_dev->intr_handle); +rte_intr_enable (pdata->pci_dev->intr_handle);/* phy start*/ pdata->phy_if.phy_start (pdata);
@@ -404,7 +404,7 @@ axgbe_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); -rte_intr_disable (&pdata->pci_dev->intr_handle); +rte_intr_disable (pdata->pci_dev->intr_handle);if (rte_bit_relaxed_get32 (AXGBE_STOPPED , &pdata->dev_state))return 0 ;
@@ -2323,7 +2323,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)return ret; } -rte_intr_callback_register (&pci_dev->intr_handle, +rte_intr_callback_register (pci_dev->intr_handle, axgbe_dev_interrupt_handler, (void *)eth_dev); PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
@@ -2347,8 +2347,8 @@ axgbe_dev_close(struct rte_eth_dev *eth_dev)axgbe_dev_clear_queues (eth_dev);/* disable uio intr before callback unregister */ -rte_intr_disable (&pci_dev->intr_handle); -rte_intr_callback_unregister (&pci_dev->intr_handle, +rte_intr_disable (pci_dev->intr_handle); +rte_intr_callback_unregister (pci_dev->intr_handle, axgbe_dev_interrupt_handler, (void *)eth_dev);
drivers/net/axgbe/axgbe_mdio.c +3 -3
@@ -933,7 +933,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) }/* Disable auto-negotiation interrupt */ -rte_intr_disable (&pdata->pci_dev->intr_handle); +rte_intr_disable (pdata->pci_dev->intr_handle);/* Start auto-negotiation in a supported mode */ if (axgbe_use_mode (pdata,AXGBE_MODE_KR )) {
@@ -951,7 +951,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) }else if (axgbe_use_mode (pdata,AXGBE_MODE_SGMII_100 )) {axgbe_set_mode (pdata,AXGBE_MODE_SGMII_100 ); }else { -rte_intr_enable (&pdata->pci_dev->intr_handle); +rte_intr_enable (pdata->pci_dev->intr_handle);return -EINVAL ; }
@@ -964,7 +964,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) pdata->kx_state =AXGBE_RX_BPA ;/* Re-enable auto-negotiation interrupt */ -rte_intr_enable (&pdata->pci_dev->intr_handle); +rte_intr_enable (pdata->pci_dev->intr_handle);axgbe_an37_enable_interrupts (pdata);axgbe_an_init (pdata);
drivers/net/bnx2x/bnx2x_ethdev.c +5 -5
@@ -134,7 +134,7 @@ bnx2x_interrupt_handler(void *param)PMD_DEBUG_PERIODIC_LOG (INFO , sc,"Interrupt handled" );bnx2x_interrupt_action (dev,1 ); -rte_intr_ack (&sc->pci_dev->intr_handle); +rte_intr_ack (sc->pci_dev->intr_handle); }static void bnx2x_periodic_start (void *param)
@@ -234,10 +234,10 @@ bnx2x_dev_start(struct rte_eth_dev *dev) }if (IS_PF (sc)) { -rte_intr_callback_register (&sc->pci_dev->intr_handle, +rte_intr_callback_register (sc->pci_dev->intr_handle, bnx2x_interrupt_handler, (void *)dev); -if (rte_intr_enable (&sc->pci_dev->intr_handle)) +if (rte_intr_enable (sc->pci_dev->intr_handle))PMD_DRV_LOG (ERR , sc,"rte_intr_enable failed" ); }
@@ -262,8 +262,8 @@ bnx2x_dev_stop(struct rte_eth_dev *dev)bnx2x_dev_rxtx_init_dummy (dev);if (IS_PF (sc)) { -rte_intr_disable (&sc->pci_dev->intr_handle); -rte_intr_callback_unregister (&sc->pci_dev->intr_handle, +rte_intr_disable (sc->pci_dev->intr_handle); +rte_intr_callback_unregister (sc->pci_dev->intr_handle, bnx2x_interrupt_handler, (void *)dev);/* stop the periodic callout */
drivers/net/bnxt/bnxt_ethdev.c +15 -17
@@ -729,7 +729,7 @@ static int bnxt_alloc_prev_ring_stats(struct bnxt *bp)static int bnxt_start_nic (struct bnxt *bp) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (bp->eth_dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;uint32_t queue_id, base =BNXT_MISC_VEC_ID ;uint32_t vec =BNXT_MISC_VEC_ID ;
@@ -831,12 +831,10 @@ static int bnxt_start_nic(struct bnxt *bp)return rc; } -if (rte_intr_dp_is_en (intr_handle) && !intr_handle->intr_vec) { - intr_handle->intr_vec = -rte_zmalloc ("intr_vec" , - bp->eth_dev->data->nb_rx_queues * -sizeof (int ),0 ); -if (intr_handle->intr_vec ==NULL ) { +if (rte_intr_dp_is_en (intr_handle) && + !rte_intr_handle_vec_list_base (intr_handle)) { +if (rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + bp->eth_dev->data->nb_rx_queues)) {PMD_DRV_LOG (ERR ,"Failed to allocate %d rx_queues" " intr_vec" , bp->eth_dev->data->nb_rx_queues); rc = -ENOMEM ;
@@ -844,13 +842,15 @@ static int bnxt_start_nic(struct bnxt *bp) }PMD_DRV_LOG (DEBUG ,"intr_handle->intr_vec = %p " "intr_handle->nb_efd = %d intr_handle->max_intr = %d\n" , - intr_handle->intr_vec, intr_handle->nb_efd, - intr_handle->max_intr); +rte_intr_handle_vec_list_base (intr_handle), +rte_intr_handle_nb_efd_get (intr_handle), +rte_intr_handle_max_intr_get (intr_handle));for (queue_id =0 ; queue_id < bp->eth_dev->data->nb_rx_queues; queue_id++) { - intr_handle->intr_vec[queue_id] = - vec +BNXT_RX_VEC_START ; -if (vec < base + intr_handle->nb_efd -1 ) +rte_intr_handle_vec_list_index_set (intr_handle, + queue_id, vec +BNXT_RX_VEC_START ); +if (vec < base +rte_intr_handle_nb_efd_get (intr_handle) + -1 ) vec++; } }
@@ -1459,7 +1459,7 @@ static int bnxt_dev_stop(struct rte_eth_dev *eth_dev) {struct bnxt *bp = eth_dev->data->dev_private;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rte_eth_link link;int ret;
@@ -1501,10 +1501,8 @@ static int bnxt_dev_stop(struct rte_eth_dev *eth_dev)/* Clean queue intr-vector mapping */ rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle);bnxt_hwrm_port_clr_stats (bp);bnxt_free_tx_mbufs (bp);
drivers/net/bnxt/bnxt_irq.c +2 -2
@@ -67,7 +67,7 @@ void bnxt_int_handler(void *param)int bnxt_free_int (struct bnxt *bp) { -struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle; +struct rte_intr_handle *intr_handle = bp->pdev->intr_handle;struct bnxt_irq *irq = bp->irq_tbl;int rc =0 ;
@@ -170,7 +170,7 @@ int bnxt_setup_int(struct bnxt *bp)int bnxt_request_int (struct bnxt *bp) { -struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle; +struct rte_intr_handle *intr_handle = bp->pdev->intr_handle;struct bnxt_irq *irq = bp->irq_tbl;int rc =0 ;
drivers/net/dpaa/dpaa_ethdev.c +31 -16
94 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.c +5 -5
@@ -1157,7 +1157,7 @@ dpaa2_dev_start(struct rte_eth_dev *dev)struct rte_intr_handle *intr_handle; dpaa2_dev = container_of(rdev, struct rte_dpaa2_device, device); - intr_handle = &dpaa2_dev->intr_handle; + intr_handle = dpaa2_dev->intr_handle;PMD_INIT_FUNC_TRACE ();
@@ -1228,8 +1228,8 @@ dpaa2_dev_start(struct rte_eth_dev *dev) }/* if the interrupts were configured on this devices*/ -if (intr_handle && (intr_handle->fd) && - (dev->data->dev_conf.intr_conf.lsc !=0 )) { +if (intr_handle &&rte_intr_handle_fd_get (intr_handle) && + dev->data->dev_conf.intr_conf.lsc !=0 ) {/* Registering LSC interrupt handler */ rte_intr_callback_register(intr_handle, dpaa2_interrupt_handler,
@@ -1268,8 +1268,8 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE ();/* reset interrupt callback */ -if (intr_handle && (intr_handle->fd) && - (dev->data->dev_conf.intr_conf.lsc !=0 )) { +if (intr_handle &&rte_intr_handle_fd_get (intr_handle) && + dev->data->dev_conf.intr_conf.lsc !=0 ) {/*disable dpni irqs */ dpaa2_eth_setup_irqs (dev,0 );
drivers/net/e1000/em_ethdev.c +10 -14
@@ -237,7 +237,7 @@ static int eth_em_dev_init(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct e1000_adapter *adapter =E1000_DEV_PRIVATE (eth_dev->data->dev_private); struct e1000_hw *hw =
@@ -525,7 +525,7 @@ eth_em_start(struct rte_eth_dev *dev)struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret, mask;uint32_t intr_vector =0 ;uint32_t *speeds;
@@ -575,12 +575,10 @@ eth_em_start(struct rte_eth_dev *dev) }if (rte_intr_dp_is_en (intr_handle)) { - intr_handle->intr_vec = -rte_zmalloc ("intr_vec" , - dev->data->nb_rx_queues *sizeof (int ),0 ); -if (intr_handle->intr_vec ==NULL ) { +if (rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + dev->data->nb_rx_queues)) {PMD_INIT_LOG (ERR ,"Failed to allocate %d rx_queues" -" intr_vec" , dev->data->nb_rx_queues); +" intr_vec" , dev->data->nb_rx_queues);return -ENOMEM ; }
@@ -718,7 +716,7 @@ eth_em_stop(struct rte_eth_dev *dev)struct rte_eth_link link;struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle; dev->data->dev_started =0 ;
@@ -752,10 +750,8 @@ eth_em_stop(struct rte_eth_dev *dev)/* Clean datapath event and queue/vec mapping */ rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle);return 0 ; }
@@ -767,7 +763,7 @@ eth_em_close(struct rte_eth_dev *dev)struct e1000_adapter *adapter =E1000_DEV_PRIVATE (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret;if (rte_eal_process_type () !=RTE_PROC_PRIMARY )
@@ -1008,7 +1004,7 @@ eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, __rte_unused uint16_t queue {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;em_rxq_intr_enable (hw);rte_intr_ack (intr_handle);
drivers/net/e1000/igb_ethdev.c +41 -43
220 lines not on this page · raw message
drivers/net/ena/ena_ethdev.c +20 -16
@@ -473,7 +473,7 @@ static void ena_config_debug_area(struct ena_adapter *adapter)static int ena_close (struct rte_eth_dev *dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ena_adapter *adapter = dev->data->dev_private;int ret =0 ;
@@ -947,7 +947,7 @@ static int ena_stop(struct rte_eth_dev *dev)struct ena_adapter *adapter = dev->data->dev_private;struct ena_com_dev *ena_dev = &adapter->ena_dev;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int rc;/* Cannot free memory in secondary process */
@@ -969,10 +969,10 @@ static int ena_stop(struct rte_eth_dev *dev)rte_intr_disable (intr_handle);rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } + +/* Cleanup vector list */ +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle);rte_intr_enable (intr_handle);
@@ -988,7 +988,7 @@ static int ena_create_io_queue(struct rte_eth_dev *dev, struct ena_ring *ring)struct ena_adapter *adapter = ring->adapter;struct ena_com_dev *ena_dev = &adapter->ena_dev;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ena_com_create_io_ctx ctx =/* policy set to _HOST just to satisfy icc compiler */ {ENA_ADMIN_PLACEMENT_POLICY_HOST ,
@@ -1008,7 +1008,10 @@ static int ena_create_io_queue(struct rte_eth_dev *dev, struct ena_ring *ring) ena_qid =ENA_IO_RXQ_IDX (ring->id); ctx.direction =ENA_COM_IO_QUEUE_DIRECTION_RX ;if (rte_intr_dp_is_en (intr_handle)) - ctx.msix_vector = intr_handle->intr_vec[ring->id]; + ctx.msix_vector = +rte_intr_handle_vec_list_index_get (intr_handle, + ring->id); +for (i =0 ; i < ring->ring_size; i++) ring->empty_rx_reqs[i] = i; }
@@ -1665,7 +1668,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) pci_dev->addr.devid, pci_dev->addr.function); - intr_handle = &pci_dev->intr_handle; + intr_handle = pci_dev->intr_handle; adapter->regs = pci_dev->mem_resource[ENA_REGS_BAR ].addr; adapter->dev_mem_base = pci_dev->mem_resource[ENA_MEM_BAR ].addr;
@@ -2817,7 +2820,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter,static int ena_setup_rx_intr (struct rte_eth_dev *dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int rc;uint16_t vectors_nb, i;bool rx_intr_requested = dev->data->dev_conf.intr_conf.rxq;
@@ -2844,9 +2847,9 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev) goto enable_intr; } - intr_handle->intr_vec =rte_zmalloc ("intr_vec" , - dev->data->nb_rx_queues *sizeof (*intr_handle->intr_vec),0 ); -if (intr_handle->intr_vec ==NULL ) { +/* Allocate the vector list */ +if (rte_intr_handle_vec_list_alloc (intr_handle,"intr_vec" , + dev->data->nb_rx_queues)) {PMD_DRV_LOG (ERR ,"Failed to allocate interrupt vector for %d queues\n" , dev->data->nb_rx_queues);
@@ -2865,7 +2868,9 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev) }for (i =0 ; i < vectors_nb; ++i) - intr_handle->intr_vec[i] =RTE_INTR_VEC_RXTX_OFFSET + i; +if (rte_intr_handle_vec_list_index_set (intr_handle, i, +RTE_INTR_VEC_RXTX_OFFSET + i)) + goto disable_intr_efd;rte_intr_enable (intr_handle);return 0 ;
@@ -2873,8 +2878,7 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev) disable_intr_efd:rte_intr_efd_disable (intr_handle); free_intr_vec: -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; +rte_intr_handle_vec_list_free (intr_handle); enable_intr:rte_intr_enable (intr_handle);return rc;
drivers/net/enic/enic_main.c +14 -13
@@ -448,7 +448,7 @@ enic_intr_handler(void *arg)rte_eth_dev_callback_process (dev,RTE_ETH_EVENT_INTR_LSC ,NULL );enic_log_q_error (enic);/* Re-enable irq in case of INTx */ -rte_intr_ack (&enic->pdev->intr_handle); +rte_intr_ack (enic->pdev->intr_handle); }static int enic_rxq_intr_init (struct enic *enic)
@@ -477,14 +477,16 @@ static int enic_rxq_intr_init(struct enic *enic) " interrupts\n");return err; } - intr_handle->intr_vec =rte_zmalloc ("enic_intr_vec" , - rxq_intr_count *sizeof (int ),0 ); -if (intr_handle->intr_vec ==NULL ) { + +if (rte_intr_handle_vec_list_alloc (intr_handle,"enic_intr_vec" , + rxq_intr_count)) {dev_err (enic,"Failed to allocate intr_vec\n" );return -ENOMEM ; }for (i =0 ; i < rxq_intr_count; i++) - intr_handle->intr_vec[i] = i +ENICPMD_RXQ_INTR_OFFSET ; +if (rte_intr_handle_vec_list_index_set (intr_handle, i, + i +ENICPMD_RXQ_INTR_OFFSET )) +return -rte_errno;return 0 ; }
@@ -494,10 +496,9 @@ static void enic_rxq_intr_deinit(struct enic *enic) intr_handle = enic->rte_dev->intr_handle;rte_intr_efd_disable (intr_handle); -if (intr_handle->intr_vec !=NULL ) { -rte_free (intr_handle->intr_vec); - intr_handle->intr_vec =NULL ; - } + +if (rte_intr_handle_vec_list_base (intr_handle)) +rte_intr_handle_vec_list_free (intr_handle); }static void enic_prep_wq_for_simple_tx (struct enic *enic,uint16_t queue_idx)
@@ -667,10 +668,10 @@ int enic_enable(struct enic *enic)vnic_dev_enable_wait (enic->vdev);/* Register and enable error interrupt */ -rte_intr_callback_register (&(enic->pdev->intr_handle), +rte_intr_callback_register (enic->pdev->intr_handle, enic_intr_handler, (void *)enic->rte_dev); -rte_intr_enable (&(enic->pdev->intr_handle)); +rte_intr_enable (enic->pdev->intr_handle);/* Unmask LSC interrupt */ vnic_intr_unmask (&enic->intr[ENICPMD_LSC_INTR_OFFSET ]);
@@ -1112,8 +1113,8 @@ int enic_disable(struct enic *enic) (void )vnic_intr_masked (&enic->intr[i]);/* flush write */ }enic_rxq_intr_deinit (enic); -rte_intr_disable (&enic->pdev->intr_handle); -rte_intr_callback_unregister (&enic->pdev->intr_handle, +rte_intr_disable (enic->pdev->intr_handle); +rte_intr_callback_unregister (enic->pdev->intr_handle, enic_intr_handler, (void *)enic->rte_dev);
drivers/net/failsafe/failsafe.c +20 -4
@@ -266,11 +266,25 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) mac->addr_bytes[4], mac->addr_bytes[5]); dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC |RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS ; -PRIV (dev)->intr_handle = (struct rte_intr_handle ){ - .fd =-1 , - .type =RTE_INTR_HANDLE_EXT , - }; + +/* Allocate interrupt instance */ +PRIV (dev)->intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + true); +if (!PRIV (dev)->intr_handle) { +ERROR ("Failed to allocate intr handle" ); + goto cancel_alarm; + } + +if (rte_intr_handle_fd_set (PRIV (dev)->intr_handle,-1 )) + goto cancel_alarm; + +if (rte_intr_handle_type_set (PRIV (dev)->intr_handle, +RTE_INTR_HANDLE_EXT )) + goto cancel_alarm; +rte_eth_dev_probing_finish (dev); +return 0 ; cancel_alarm:failsafe_hotplug_alarm_cancel (dev);
@@ -299,6 +313,8 @@ fs_rte_eth_free(const char *name)return 0 ;/* port already released */ ret =failsafe_eth_dev_close (dev);rte_eth_dev_release_port (dev); +if (PRIV (dev)->intr_handle) +rte_intr_handle_instance_free (PRIV (dev)->intr_handle);return ret; }
drivers/net/failsafe/failsafe_intr.c +26 -19
86 lines not on this page · raw message
drivers/net/failsafe/failsafe_ops.c +17 -6
@@ -398,15 +398,24 @@ fs_rx_queue_setup(struct rte_eth_dev *dev,* For the time being, fake as if we are using MSIX interrupts, * this will cause rte_intr_efd_enable to allocate an eventfd for us. */ -struct rte_intr_handle intr_handle = { - .type =RTE_INTR_HANDLE_VFIO_MSIX , - .efds = {-1 , }, - }; +struct rte_intr_handle *intr_handle;struct sub_device *sdev;struct rxq *rxq;uint8_t i;int ret; + intr_handle = +rte_intr_handle_instance_alloc (RTE_INTR_HANDLE_DEFAULT_SIZE , + false); +if (!intr_handle) +return -ENOMEM ; + +if (rte_intr_handle_type_set (intr_handle,RTE_INTR_HANDLE_VFIO_MSIX )) +return -rte_errno; + +if (rte_intr_handle_efds_index_set (intr_handle,0 ,-1 )) +return -rte_errno; +fs_lock (dev,0 );if (rx_conf->rx_deferred_start) { FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
@@ -440,12 +449,12 @@ fs_rx_queue_setup(struct rte_eth_dev *dev, rxq->info.nb_desc = nb_rx_desc; rxq->priv =PRIV (dev); rxq->sdev =PRIV (dev)->subs; - ret =rte_intr_efd_enable (&intr_handle,1 ); + ret =rte_intr_efd_enable (intr_handle,1 );if (ret <0 ) {fs_unlock (dev,0 );return ret; } - rxq->event_fd = intr_handle.efds[0 ]; + rxq->event_fd =rte_intr_handle_efds_index_get (intr_handle,0 ); dev->data->rx_queues[rx_queue_id] = rxq; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_rx_queue_setup(PORT_ID(sdev),
@@ -458,10 +467,12 @@ fs_rx_queue_setup(struct rte_eth_dev *dev, } }fs_unlock (dev,0 ); +rte_intr_handle_instance_free (intr_handle);return 0 ; free_rxq:fs_rx_queue_release (rxq);fs_unlock (dev,0 ); +rte_intr_handle_instance_free (intr_handle);return ret; }
drivers/net/failsafe/failsafe_private.h +1 -1
@@ -166,7 +166,7 @@ struct fs_priv {struct rte_ether_addr *mcast_addrs;/* current capabilities */ struct rte_eth_dev_owner my_owner;/* Unique owner. */ -struct rte_intr_handle intr_handle;/* Port interrupt handle. */ +struct rte_intr_handle *intr_handle;/* Port interrupt handle. */ /* * Fail-safe state machine. * This level will be tracking state of the EAL and eth
drivers/net/fm10k/fm10k_ethdev.c +17 -15
@@ -32,7 +32,8 @@#define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)/* default 1:1 map from queue ID to interrupt vector ID */ -#define Q2V (pci_dev, queue_id) ((pci_dev)->intr_handle.intr_vec[queue_id]) +#define Q2V (pci_dev, queue_id) \ + (rte_intr_handle_vec_list_index_get((pci_dev)->intr_handle, queue_id))/* First 64 Logical ports for PF/VMDQ, second 64 for Flow director */ #define MAX_LPORT_NUM 128
@@ -690,7 +691,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev)struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct fm10k_macvlan_filter_info *macvlan;struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pdev->intr_handle; +struct rte_intr_handle *intr_handle = pdev->intr_handle;int i, ret;struct fm10k_rx_queue *rxq;uint64_t base_addr;
@@ -1158,7 +1159,7 @@ fm10k_dev_stop(struct rte_eth_dev *dev) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); -struct rte_intr_handle *intr_handle = &pdev->intr_handle; +struct rte_intr_handle *intr_handle = pdev->intr_handle;int i;
Lines of this file are not shown. View the raw message.
drivers/net/hns3/hns3_ethdev.c +25 -25
50 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev_vf.c +30 -27
57 lines not on this page · raw message
drivers/net/i40e/i40e_ethdev.c +28 -27
55 lines not on this page · raw message
drivers/net/i40e/i40e_ethdev_vf.c +22 -21
43 lines not on this page · raw message
drivers/net/iavf/iavf_ethdev.c +22 -19
41 lines not on this page · raw message
drivers/net/ice/ice_ethdev.c +26 -25
51 lines not on this page · raw message
drivers/net/igc/igc_ethdev.c +23 -24
47 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethdev.c +34 -36
70 lines not on this page · raw message
drivers/net/memif/memif_socket.c +85 -29
114 lines not on this page · raw message
drivers/net/memif/rte_eth_memif.c +51 -12
63 lines not on this page · raw message
drivers/net/mlx4/mlx4_intr.c +30 -18
48 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_os.c +38 -18
56 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxq.c +25 -18
43 lines not on this page · raw message
drivers/net/octeontx2/otx2_ethdev_irq.c +18 -17
Lines of this file are not shown. View the raw message.
drivers/net/vhost/rte_eth_vhost.c +48 -30
78 lines not on this page · raw message
drivers/net/virtio/virtio_user/virtio_user_dev.c +37 -16
53 lines not on this page · raw message
drivers/net/vmxnet3/vmxnet3_ethdev.c +25 -20
45 lines not on this page · raw message
drivers/raw/ifpga/ifpga_rawdev.c +29 -13
42 lines not on this page · raw message
drivers/regex/octeontx2/otx2_regexdev_hw_access.c +2 -2
Lines of this file are not shown. View the raw message.
drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +32 -14
46 lines not on this page · raw message
lib/eal/freebsd/eal_alarm.c +43 -6
49 lines not on this page · raw message
lib/eal/linux/eal_dev.c +42 -23
65 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.18.0
Part of the diff is not shown here. View the raw message.
PATCH 6/7 eal/interrupts: make interrupt handle structure opaque
In reply to Harman KalraMoving interrupt handle structure definition inside the c file to make its fields totally opaque to the outside world.
Dynamically allocating the efds and elist array os intr_handle structure, based on size provided by user. Eg size can be MSIX interrupts supported by a PCI device.
--- drivers/bus/pci/linux/pci_vfio.c | 7 + lib/eal/common/eal_common_interrupts.c | 172 ++++++++++++++++++++++++- lib/eal/include/meson.build | 1 - lib/eal/include/rte_eal_interrupts.h | 72 ----------- lib/eal/include/rte_interrupts.h | 24 +++- 5 files changed, 196 insertions(+), 80 deletions(-) delete mode 100644 lib/eal/include/rte_eal_interrupts.h
drivers/bus/pci/linux/pci_vfio.c +7 -0
@@ -266,6 +266,13 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd)return -1 ; } +/* Reallocate the efds and elist fields of intr_handle based +* on PCI device MSIX size. +*/ +if (rte_intr_handle_event_list_update (dev->intr_handle, + irq.count)) +return -1 ; +/* if this vector cannot be used with eventfd, fail if we explicitly * specified interrupt type, otherwise continue */ if ((irq.flags &VFIO_IRQ_INFO_EVENTFD ) ==0 ) {
lib/eal/common/eal_common_interrupts.c +167 -5
256 lines not on this page · raw message
lib/eal/include/meson.build +0 -1
@@ -49,7 +49,6 @@ headers += files( 'rte_version.h', 'rte_vfio.h', ) -indirect_headers += files('rte_eal_interrupts.h') # special case install the generic headers, since they go in a subdir generic_headers = files(
lib/eal/include/rte_eal_interrupts.h deleted +0 -72
72 lines not on this page · raw message
lib/eal/include/rte_interrupts.h +22 -2
@@ -25,9 +25,29 @@ extern "C" {/** Interrupt handle */ struct rte_intr_handle ; -#define RTE_INTR_HANDLE_DEFAULT_SIZE 1 +#define RTE_MAX_RXTX_INTR_VEC_ID 512 +#define RTE_INTR_VEC_ZERO_OFFSET 0 +#define RTE_INTR_VEC_RXTX_OFFSET 1 + +/** +* The interrupt source type, e.g. UIO, VFIO, ALARM etc. +*/ +enum rte_intr_handle_type { +RTE_INTR_HANDLE_UNKNOWN =0 ,/**< generic unknown handle */ +RTE_INTR_HANDLE_UIO ,/**< uio device handle */ +RTE_INTR_HANDLE_UIO_INTX ,/**< uio generic handle */ +RTE_INTR_HANDLE_VFIO_LEGACY ,/**< vfio device handle (legacy) */ +RTE_INTR_HANDLE_VFIO_MSI ,/**< vfio device handle (MSI) */ +RTE_INTR_HANDLE_VFIO_MSIX ,/**< vfio device handle (MSIX) */ +RTE_INTR_HANDLE_ALARM ,/**< alarm handle */ +RTE_INTR_HANDLE_EXT ,/**< external handler */ +RTE_INTR_HANDLE_VDEV ,/**< virtual device */ +RTE_INTR_HANDLE_DEV_EVENT ,/**< device event handle */ +RTE_INTR_HANDLE_VFIO_REQ ,/**< VFIO request handle */ +RTE_INTR_HANDLE_MAX /**< count of elements */ +}; -#include "rte_eal_interrupts.h" +#define RTE_INTR_HANDLE_DEFAULT_SIZE 1/** Function to be registered for the specific interrupt */ typedef void (*rte_intr_callback_fn )(void *cb_arg);
Signature · 1 line
2.18.0
Re: [dpdk-dev] [PATCH v1 6/7] eal/interrupts: make interrupt handle structure opaque
2021-09-03 18:11 (UTC+0530), Harman Kalra:
Quoted 29 lines
[...]
lib/eal/common/eal_common_interrupts.c +24
-0@@ -31,11 +54,40 @@ struct rte_intr_handle *rte_intr_handle_instance_alloc(int size, }for (i =0 ; i < size; i++) { +if (from_hugepage) + intr_handle[i].efds =rte_zmalloc (NULL , +RTE_MAX_RXTX_INTR_VEC_ID *sizeof (uint32_t ),0 ); +else + intr_handle[i].efds =calloc (1 , +RTE_MAX_RXTX_INTR_VEC_ID *sizeof (uint32_t )); +if (!intr_handle[i].efds) { +RTE_LOG (ERR ,EAL ,"Fail to allocate event fd list\n" ); + rte_errno =ENOMEM ; + goto fail; + } + +if (from_hugepage) + intr_handle[i].elist =rte_zmalloc (NULL , +RTE_MAX_RXTX_INTR_VEC_ID * +sizeof (struct rte_epoll_event ),0 ); +else + intr_handle[i].elist =calloc (1 , +RTE_MAX_RXTX_INTR_VEC_ID * +sizeof (struct rte_epoll_event )); +if (!intr_handle[i].elist) { +RTE_LOG (ERR ,EAL ,"fail to allocate event fd list\n" ); + rte_errno =ENOMEM ; + goto fail;
lib/eal/common/eal_common_interrupts.c struct rte_intr_handle *rte_intr_handle_instance_alloc(int size, · line 90
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c +5
-0+ } intr_handle[i].nb_intr =RTE_MAX_RXTX_INTR_VEC_ID ; intr_handle[i].alloc_from_hugepage = from_hugepage; }return intr_handle; +fail: +free (intr_handle->efds); +free (intr_handle); +return NULL ;
This is incorrect if "from_hugepage" is set.
Quoted 40 lines
lib/eal/common/eal_common_interrupts.c +27
-1} struct rte_intr_handle *rte_intr_handle_instance_index_get(@@ -73,12 +125,48 @@ int rte_intr_handle_instance_index_set(struct rte_intr_handle *intr_handle, } intr_handle[index].fd = src->fd; - intr_handle[index].vfio_dev_fd = src->vfio_dev_fd; + intr_handle[index].dev_fd = src->dev_fd; + intr_handle[index].type = src->type; intr_handle[index].max_intr = src->max_intr; intr_handle[index].nb_efd = src->nb_efd; intr_handle[index].efd_counter_size = src->efd_counter_size; +if (intr_handle[index].nb_intr != src->nb_intr) { +if (src->alloc_from_hugepage) + intr_handle[index].efds = +rte_realloc (intr_handle[index].efds, + src->nb_intr * +sizeof (uint32_t ),0 ); +else + intr_handle[index].efds = +realloc (intr_handle[index].efds, + src->nb_intr *sizeof (uint32_t )); +if (intr_handle[index].efds ==NULL ) { +RTE_LOG (ERR ,EAL ,"Failed to realloc the efds list" ); + rte_errno =ENOMEM ; + goto fail; + } + +if (src->alloc_from_hugepage) + intr_handle[index].elist = +rte_realloc (intr_handle[index].elist, + src->nb_intr * +sizeof (struct rte_epoll_event ),0 ); +else + intr_handle[index].elist = + realloc(intr_handle[index].elist, + src->nb_intr *
lib/eal/common/eal_common_interrupts.c int rte_intr_handle_instance_index_set(struct rte_intr_handle *intr_handle, · line 169
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c +10
-0+ sizeof(struct rte_epoll_event)); +if (intr_handle[index].elist ==NULL ) { +RTE_LOG (ERR ,EAL ,"Failed to realloc the event list" ); + rte_errno =ENOMEM ; + goto fail; + } + + intr_handle[index].nb_intr = src->nb_intr; + } +
This implementation leaves "intr_handle" in an invalid state and leaks memory on error paths.
Quoted 36 lines
lib/eal/common/eal_common_interrupts.c +29
-0memcpy (intr_handle[index].efds, src->efds, src->nb_intr);memcpy (intr_handle[index].elist, src->elist, src->nb_intr);@@ -87,6 +175,45 @@ int rte_intr_handle_instance_index_set(struct rte_intr_handle *intr_handle,return rte_errno; } +int rte_intr_handle_event_list_update (struct rte_intr_handle *intr_handle, +int size) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (size ==0 ) { +RTE_LOG (ERR ,EAL ,"Size can't be zero\n" ); + rte_errno =EINVAL ; + goto fail; + } + + intr_handle->efds =realloc (intr_handle->efds, + size *sizeof (uint32_t )); +if (intr_handle->efds ==NULL ) { +RTE_LOG (ERR ,EAL ,"Failed to realloc the efds list" ); + rte_errno =ENOMEM ; + goto fail; + } + + intr_handle->elist =realloc (intr_handle->elist, + size *sizeof (struct rte_epoll_event )); +if (intr_handle->elist ==NULL ) { +RTE_LOG (ERR ,EAL ,"Failed to realloc the event list" ); + rte_errno =ENOMEM ; + goto fail;
lib/eal/common/eal_common_interrupts.c int rte_intr_handle_instance_index_set(struct rte_intr_handle *intr_handle, · line 216
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c +10
-0+ } + + intr_handle->nb_intr = size; + +return 0 ; +fail: +return rte_errno; +} + +
Same here.
Quoted 20 lines
(quoted diff) +0
-0lib/eal/include/rte_interrupts.h +10
-1@@ -25,9 +25,29 @@ extern "C" {/** Interrupt handle */ struct rte_intr_handle ; -#define RTE_INTR_HANDLE_DEFAULT_SIZE 1 +#define RTE_MAX_RXTX_INTR_VEC_ID 512 +#define RTE_INTR_VEC_ZERO_OFFSET 0 +#define RTE_INTR_VEC_RXTX_OFFSET 1 + +/** +* The interrupt source type, e.g. UIO, VFIO, ALARM etc. +*/ +enum rte_intr_handle_type { +RTE_INTR_HANDLE_UNKNOWN =0 ,/**< generic unknown handle */ +RTE_INTR_HANDLE_UIO ,/**< uio device handle */
lib/eal/include/rte_interrupts.h extern "C" { · line 47
Quoted 10 lines
lib/eal/include/rte_interrupts.h +10
-0+RTE_INTR_HANDLE_UIO_INTX ,/**< uio generic handle */ +RTE_INTR_HANDLE_VFIO_LEGACY ,/**< vfio device handle (legacy) */ +RTE_INTR_HANDLE_VFIO_MSI ,/**< vfio device handle (MSI) */ +RTE_INTR_HANDLE_VFIO_MSIX ,/**< vfio device handle (MSIX) */ +RTE_INTR_HANDLE_ALARM ,/**< alarm handle */ +RTE_INTR_HANDLE_EXT ,/**< external handler */ +RTE_INTR_HANDLE_VDEV ,/**< virtual device */ +RTE_INTR_HANDLE_DEV_EVENT ,/**< device event handle */ +RTE_INTR_HANDLE_VFIO_REQ ,/**< VFIO request handle */ +RTE_INTR_HANDLE_MAX /**< count of elements */
Enums shouldn't have a _MAX member, can we remove it?
lib/eal/include/rte_interrupts.h extern "C" { · line 50
Quoted 4 lines
lib/eal/include/rte_interrupts.h +2
-1+}; -#include "rte_eal_interrupts.h" +#define RTE_INTR_HANDLE_DEFAULT_SIZE 1
I find this constant more cluttering call sites than helpful.
If a handle is allocated with a calloc-like function, plain 1 reads just fine.
Re: [dpdk-dev] [EXT] Re: [PATCH v1 6/7] eal/interrupts: make interrupt handle structure opaque
Hi Dmitry,
Please find my comments inline.
Quoted 49 lines
-----Original Message-----
From: Dmitry Kozlyuk <[email protected]>
Sent: Sunday, October 3, 2021 11:46 PM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Anatoly Burakov <[email protected]>
Subject: [EXT] Re: [dpdk-dev] [PATCH v1 6/7] eal/interrupts: make interrupt handle structure opaqueExternal Email
----------------------------------------------------------------------
2021-09-03 18:11 (UTC+0530), Harman Kalra:Review struct rte_intr_handle
Quoted 2 lines
[...]
(quoted diff) +0
-0@@ -31,11 +54,40 @@ struct rte_intr_handle*rte_intr_handle_instance_alloc(int size,
lib/eal/common/eal_common_interrupts.c struct rte_intr_handle *rte_intr_handle_instance_alloc(int size, · line 71
Quoted 6 lines
lib/eal/common/eal_common_interrupts.c +3
-0}for (i =0 ; i < size; i++) { +if (from_hugepage) + intr_handle[i].efds = rte_zmalloc(NULL, + RTE_MAX_RXTX_INTR_VEC_ID *
sizeof(uint32_t), 0);lib/eal/common/eal_common_interrupts.c struct rte_intr_handle *rte_intr_handle_instance_alloc(int size, · line 71
Quoted 3 lines
lib/eal/common/eal_common_interrupts.c +3
-0+else + intr_handle[i].efds = calloc(1, + RTE_MAX_RXTX_INTR_VEC_ID *
sizeof(uint32_t));Quoted 23 lines
lib/eal/common/eal_common_interrupts.c +19
-0+if (!intr_handle[i].efds) { +RTE_LOG (ERR ,EAL ,"Fail to allocate event fd list\n" ); + rte_errno =ENOMEM ; + goto fail; + } + +if (from_hugepage) + intr_handle[i].elist =rte_zmalloc (NULL , +RTE_MAX_RXTX_INTR_VEC_ID * +sizeof (struct rte_epoll_event ),0 ); +else + intr_handle[i].elist =calloc (1 , +RTE_MAX_RXTX_INTR_VEC_ID * +sizeof (struct rte_epoll_event )); +if (!intr_handle[i].elist) { +RTE_LOG (ERR ,EAL ,"fail to allocate event fd list\n" ); + rte_errno =ENOMEM ; + goto fail; + } intr_handle[i].nb_intr =RTE_MAX_RXTX_INTR_VEC_ID ; intr_handle[i].alloc_from_hugepage = from_hugepage; }
Quoted 7 lines
lib/eal/common/eal_common_interrupts.c struct rte_intr_handle *rte_intr_handle_instance_alloc(int size, · line 90
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c +4
-0return intr_handle; +fail: +free (intr_handle->efds); +free (intr_handle); +return NULL ;This is incorrect if "
from_hugepage" is set.
<HK> Ack, will fix it.
Quoted 47 lines
lib/eal/common/eal_common_interrupts.c int rte_intr_handle_instance_index_set(struct
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c +0
-0} struct rte_intr_handle *rte_intr_handle_instance_index_get(@@ -73,12 +125,48 @@ int rte_intr_handle_instance_index_set(struct
rte_intr_handle*intr_handle,Quoted 41 lines
lib/eal/common/eal_common_interrupts.c +32
-1} intr_handle[index].fd = src->fd; - intr_handle[index].vfio_dev_fd = src->vfio_dev_fd; + intr_handle[index].dev_fd = src->dev_fd; + intr_handle[index].type = src->type; intr_handle[index].max_intr = src->max_intr; intr_handle[index].nb_efd = src->nb_efd; intr_handle[index].efd_counter_size = src->efd_counter_size; +if (intr_handle[index].nb_intr != src->nb_intr) { +if (src->alloc_from_hugepage) + intr_handle[index].efds = +rte_realloc (intr_handle[index].efds, + src->nb_intr * +sizeof (uint32_t ),0 ); +else + intr_handle[index].efds = +realloc (intr_handle[index].efds, + src->nb_intr *sizeof (uint32_t )); +if (intr_handle[index].efds ==NULL ) { +RTE_LOG (ERR ,EAL ,"Failed to realloc the efds list" ); + rte_errno =ENOMEM ; + goto fail; + } + +if (src->alloc_from_hugepage) + intr_handle[index].elist = +rte_realloc (intr_handle[index].elist, + src->nb_intr * +sizeof (struct rte_epoll_event ),0 ); +else + intr_handle[index].elist = +realloc (intr_handle[index].elist, + src->nb_intr * +sizeof (struct rte_epoll_event )); +if (intr_handle[index].elist ==NULL ) { +RTE_LOG (ERR ,EAL ,"Failed to realloc the event list" ); + rte_errno =ENOMEM ; + goto fail;
Quoted 8 lines
lib/eal/common/eal_common_interrupts.c int rte_intr_handle_instance_index_set(struct rte_intr_handle *intr_handle, · line 169
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c +5
-0+ } + + intr_handle[index].nb_intr = src->nb_intr; + } +This implementation leaves "
intr_handle" in an invalid state and leaks memory on error paths.
<HK> Yes, I will get the reallocated pointer in a tmp variable and will update (intr_handle[index].elist/efds only after all error paths are cleared.
Quoted 43 lines
lib/eal/common/eal_common_interrupts.c int rte_intr_handle_instance_index_set(struct
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c +0
-0memcpy (intr_handle[index].efds, src->efds, src->nb_intr);memcpy (intr_handle[index].elist, src->elist, src->nb_intr);@@ -87,6 +175,45 @@ int rte_intr_handle_instance_index_set(struct
rte_intr_handle*intr_handle,lib/eal/common/eal_common_interrupts.c int rte_intr_handle_instance_index_set(struct rte_intr_handle *intr_handle,
Quoted 4 lines
lib/eal/common/eal_common_interrupts.c +1
-0return rte_errno; } +int rte_intr_handle_event_list_update(struct rte_intr_handle
*intr_handle,Quoted 32 lines
lib/eal/common/eal_common_interrupts.c +32
-0+ int size) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (size ==0 ) { +RTE_LOG (ERR ,EAL ,"Size can't be zero\n" ); + rte_errno =EINVAL ; + goto fail; + } + + intr_handle->efds =realloc (intr_handle->efds, + size *sizeof (uint32_t )); +if (intr_handle->efds ==NULL ) { +RTE_LOG (ERR ,EAL ,"Failed to realloc the efds list" ); + rte_errno =ENOMEM ; + goto fail; + } + + intr_handle->elist =realloc (intr_handle->elist, + size *sizeof (struct rte_epoll_event )); +if (intr_handle->elist ==NULL ) { +RTE_LOG (ERR ,EAL ,"Failed to realloc the event list" ); + rte_errno =ENOMEM ; + goto fail; + } + + intr_handle->nb_intr = size; +
Quoted 8 lines
lib/eal/common/eal_common_interrupts.c int rte_intr_handle_instance_index_set(struct rte_intr_handle *intr_handle, · line 216
Quoted 6 lines
lib/eal/common/eal_common_interrupts.c +6
-0+return 0 ; +fail: +return rte_errno; +} + +Same here.
<HK> Ack
Quoted 25 lines
Quoted 14 lines
(quoted diff) +0
-0lib/eal/include/rte_interrupts.h +2
-1@@ -25,9 +25,29 @@ extern "C" {/** Interrupt handle */ struct rte_intr_handle ; -#define RTE_INTR_HANDLE_DEFAULT_SIZE 1 +#define RTE_MAX_RXTX_INTR_VEC_ID 512 +#define RTE_INTR_VEC_ZERO_OFFSET 0lib/eal/include/rte_interrupts.h extern "C" { · line 39
Quoted 10 lines
lib/eal/include/rte_interrupts.h +10
-0+#define RTE_INTR_VEC_RXTX_OFFSET 1 + +/** +* The interrupt source type, e.g. UIO, VFIO, ALARM etc. +*/ +enum rte_intr_handle_type { +RTE_INTR_HANDLE_UNKNOWN =0 ,/**< generic unknown handle */ +RTE_INTR_HANDLE_UIO ,/**< uio device handle */ +RTE_INTR_HANDLE_UIO_INTX ,/**< uio generic handle */ +RTE_INTR_HANDLE_VFIO_LEGACY ,/**< vfio device handle (legacy) */
Quoted 10 lines
lib/eal/include/rte_interrupts.h extern "C" { · line 47
Quoted 8 lines
lib/eal/include/rte_interrupts.h +8
-0+RTE_INTR_HANDLE_VFIO_MSI ,/**< vfio device handle (MSI) */ +RTE_INTR_HANDLE_VFIO_MSIX ,/**< vfio device handle (MSIX) */ +RTE_INTR_HANDLE_ALARM ,/**< alarm handle */ +RTE_INTR_HANDLE_EXT ,/**< external handler */ +RTE_INTR_HANDLE_VDEV ,/**< virtual device */ +RTE_INTR_HANDLE_DEV_EVENT ,/**< device event handle */ +RTE_INTR_HANDLE_VFIO_REQ ,/**< VFIO request handle */ +RTE_INTR_HANDLE_MAX /**< count of elements */ Enums shouldn't have a
_MAXmember, can we remove it?
<HK> I don't see RTE_INTR_HANDLE_MAX used at any place, I will remove it.
Quoted 8 lines
lib/eal/include/rte_interrupts.h extern "C" { · line 50
Quoted 5 lines
lib/eal/include/rte_interrupts.h +2
-1+}; -#include "rte_eal_interrupts.h" +#define RTE_INTR_HANDLE_DEFAULT_SIZE 1I find this constant more cluttering call sites than helpful.
If a handle is allocated with a calloc-like function, plain 1 reads just fine.
Now since we are thinking of restricting rte_intr_handle_instance_alloc() to single intr_handle allocation, I will remove this macro.
Thanks
Harman
PATCH 7/7 eal/alarm: introduce alarm fini routine
In reply to Harman KalraImplementing alarm cleanup routine, where the memory allocated for interrupt instance can be freed.
--- lib/eal/common/eal_private.h | 11 +++++++++++ lib/eal/freebsd/eal.c | 1 + lib/eal/freebsd/eal_alarm.c | 7 +++++++ lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_alarm.c | 10 +++++++++- 5 files changed, 29 insertions(+), 1 deletion(-)
lib/eal/common/eal_private.h +11 -0
@@ -162,6 +162,17 @@ int rte_eal_intr_init(void);*/ int rte_eal_alarm_init (void ); +/** +* Init alarm mechanism. This is to allow a callback be called after +* specific time. +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +void rte_eal_alarm_fini (void ); +/** * Function is to check if the kernel module(like, vfio, vfio_iommu_type1, * etc.) loaded.
lib/eal/freebsd/eal.c +1 -0
@@ -973,6 +973,7 @@ rte_eal_cleanup(void)rte_eal_memory_detach ();rte_trace_save ();eal_trace_fini (); +rte_eal_alarm_fini ();eal_cleanup_config (internal_conf);return 0 ; }
lib/eal/freebsd/eal_alarm.c +7 -0
@@ -46,6 +46,13 @@ static rte_spinlock_t alarm_list_lk = RTE_SPINLOCK_INITIALIZER;static struct rte_intr_handle *intr_handle;static void eal_alarm_callback (void *arg); +void +rte_eal_alarm_fini (void ) +{ +if (intr_handle) +rte_intr_handle_instance_free (intr_handle); +} +int rte_eal_alarm_init (void ) {
lib/eal/linux/eal.c +1 -0
@@ -1370,6 +1370,7 @@ rte_eal_cleanup(void)rte_eal_memory_detach ();rte_trace_save ();eal_trace_fini (); +rte_eal_alarm_fini ();eal_cleanup_config (internal_conf);return 0 ; }
lib/eal/linux/eal_alarm.c +9 -1
@@ -58,6 +58,13 @@ static struct rte_intr_handle *intr_handle;static int handler_registered =0 ;static void eal_alarm_callback (void *arg); +void +rte_eal_alarm_fini (void ) +{ +if (intr_handle) +rte_intr_handle_instance_free (intr_handle); +} +int rte_eal_alarm_init (void ) {
@@ -70,7 +77,8 @@ rte_eal_alarm_init(void) goto error; } -rte_intr_handle_type_set (intr_handle,RTE_INTR_HANDLE_ALARM ); +if (rte_intr_handle_type_set (intr_handle,RTE_INTR_HANDLE_ALARM )) + goto error;/* create a timerfd file descriptor */ if (rte_intr_handle_fd_set(intr_handle,
Signature · 1 line
2.18.0
Ping...
Kindly review the series. Also would like to request PMD maintainers(who uses interrupt APIs) to validate the series for their respective drivers, as many drivers underwent interrupt related changes in patch 5 of the series.
Thanks
Harman
Quoted 236 lines
-----Original Message-----
From: Harman Kalra <[email protected]>
Sent: Friday, September 3, 2021 6:11 PM
To: [email protected]
Cc: Harman Kalra <[email protected]>
Subject: [PATCH v1 0/7] makerte_intr_handleinternalMoving struct
rte_intr_handleas an internal structure to avoid any ABI breakages in future. Since this structure defines some static arrays and changing respective macros breaks the ABI.
Eg:
CurrentlyRTE_MAX_RXTX_INTR_VEC_IDimposes a limit of maximum 512 MSI-X interrupts that can be defined for a PCI device, while PCI specification allows maximum 2048 MSI-X interrupts that can be used.
If some PCI device requires more than 512 vectors, either change theRTE_MAX_RXTX_INTR_VEC_IDlimit or dynamically allocate based on PCI device MSI-X size on probe time. Either way its an ABI breakage.Change already included in 21.11 ABI improvement spreadsheet (item 42):
https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.google.com_s
preadsheets_d_1betlC000ua5SsSiJIcC54mCCCJnW6voH5Dqv9UxeyfE_edit- 23gid-
3D0&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=5ESHPj7V- 7JdkxT_Z_SU6RrS37ys4U XudBQ_rrS5LRo&m=7dl3OmXU7QHMmWYB6V1hYJtq1cUkjfhXUwze2Si_48c &s=lh6DEGhR
Bg1shODpAy3RQk-H-0uQx5icRfUBf9dtCp4&e=This series makes struct
rte_intr_handletotally opaque to the outside world by wrapping it inside a .c file and providing get set wrapper APIs to read or manipulate its fields.. Any changes to be made to any of the fields should be done via these get set APIs.
Introduced a neweal_common_interrupts.cwhere all these APIs are defined and also hides structrte_intr_handledefinition.Details on each patch of the series:
Patch 1: eal: interrupt handle API prototypes This patch provides prototypes of all the new get set APIs, and also rearranges the headers related to interrupt framework. Epoll related definitions prototypes are moved into a new header i.e.rte_epoll.hand APIs defined inrte_eal_interrupts.hwhich were driver specific are moved torte_interrupts.h(as anyways it was accessible and used outside DPDK library. Later in the seriesrte_eal_interrupts.his removed.Patch 2: eal/interrupts: implement get set APIs Implementing all get, set and alloc APIs. Alloc APIs are implemented to allocate memory for interrupt handle instance. Currently most of the drivers defines interrupt handle instance as static but now it cant be static as size of
rte_intr_handleis unknown to all the drivers.
Drivers are expected to allocate interrupt instances during initialization and free these instances during cleanup phase.Patch 3: eal/interrupts: avoid direct access to interrupt handle Modifying the interrupt framework for linux and freebsd to use these get set alloc APIs as per requirement and avoid accessing the fields directly.
Patch 4: test/interrupt: apply get set interrupt handle APIs Updating interrupt test suite to use interrupt handle APIs.
Patch 5: drivers: remove direct access to interrupt handle fields Modifying all the drivers and libraries which are currently directly accessing the interrupt handle fields. Drivers are expected to allocated the interrupt instance, use get set APIs with the allocated interrupt handle and free it on cleanup.
Patch 6: eal/interrupts: make interrupt handle structure opaque In this patch
rte_eal_interrupt.his removed, structrte_intr_handledefinition is moved to c file to make it completely opaque. As part of interrupt handle allocation, array like efds and elist(which are currently
static) are dynamically allocated with default size (RTE_MAX_RXTX_INTR_VEC_ID). Later these arrays can be reallocated as per device requirement using new APIrte_intr_handle_event_list_update(). Eg, on PCI device probing MSIX size can be queried and these arrays can be reallocated accordingly.Patch 7: eal/alarm: introduce alarm fini routine Introducing alarm fini routine, as the memory allocated for alarm interrupt instance can be freed in alarm fini.
Testing performed:
1. Validated the series by running interrupts and alarm test suite.
2. Validate l3fwd power functionality with octeontx2 and i40e intel cards, where interrupts are expected on packet arrival.v1:
* Fixed freebsd compilation failure
* Fixed seg fault in case of memifHarman Kalra (7):
eal: interrupt handle API prototypes eal/interrupts: implement get set APIs eal/interrupts: avoid direct access to interrupt handle test/interrupt: apply get set interrupt handle APIs
drivers: remove direct access to interrupt handle fields eal/interrupts: make interrupt handle structure opaque eal/alarm: introduce alarm fini routineMAINTAINERS | 1 + app/test/test_interrupts.c | 237 +++--- drivers/baseband/acc100/rte_acc100_pmd.c | 18 +- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 13 +- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 14 +- drivers/bus/auxiliary/auxiliary_common.c | 2 + drivers/bus/auxiliary/linux/auxiliary.c | 11 + drivers/bus/auxiliary/rte_bus_auxiliary.h | 2 +- drivers/bus/dpaa/dpaa_bus.c | 28 +- drivers/bus/dpaa/rte_dpaa_bus.h | 2 +- drivers/bus/fslmc/fslmc_bus.c | 17 +- drivers/bus/fslmc/fslmc_vfio.c | 32 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 21 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- drivers/bus/fslmc/rte_fslmc.h | 2 +- drivers/bus/ifpga/ifpga_bus.c | 16 +- drivers/bus/ifpga/rte_bus_ifpga.h | 2 +- drivers/bus/pci/bsd/pci.c | 21 +- drivers/bus/pci/linux/pci.c | 4 +- drivers/bus/pci/linux/pci_uio.c | 73 +- drivers/bus/pci/linux/pci_vfio.c | 115 ++- drivers/bus/pci/pci_common.c | 29 +- drivers/bus/pci/pci_common_uio.c | 21 +- drivers/bus/pci/rte_bus_pci.h | 4 +- drivers/bus/vmbus/linux/vmbus_bus.c | 7 + drivers/bus/vmbus/linux/vmbus_uio.c | 37 +- drivers/bus/vmbus/rte_bus_vmbus.h | 2 +- drivers/bus/vmbus/vmbus_common_uio.c | 24 +- drivers/common/cnxk/roc_cpt.c | 8 +- drivers/common/cnxk/roc_dev.c | 14 +- drivers/common/cnxk/roc_irq.c | 106 +-- drivers/common/cnxk/roc_nix_irq.c | 37 +- drivers/common/cnxk/roc_npa.c | 2 +- drivers/common/cnxk/roc_platform.h | 34 + drivers/common/cnxk/roc_sso.c | 4 +- drivers/common/cnxk/roc_tim.c | 4 +- drivers/common/octeontx2/otx2_dev.c | 14 +- drivers/common/octeontx2/otx2_irq.c | 117 +-- .../octeontx2/otx2_cryptodev_hw_access.c | 4 +- drivers/event/octeontx2/otx2_evdev_irq.c | 12 +- drivers/mempool/octeontx2/otx2_mempool.c | 2 +- drivers/net/atlantic/atl_ethdev.c | 22 +- drivers/net/avp/avp_ethdev.c | 8 +- drivers/net/axgbe/axgbe_ethdev.c | 12 +- drivers/net/axgbe/axgbe_mdio.c | 6 +- drivers/net/bnx2x/bnx2x_ethdev.c | 10 +- drivers/net/bnxt/bnxt_ethdev.c | 32 +- drivers/net/bnxt/bnxt_irq.c | 4 +- drivers/net/dpaa/dpaa_ethdev.c | 47 +- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +- drivers/net/e1000/em_ethdev.c | 24 +- drivers/net/e1000/igb_ethdev.c | 84 ++- drivers/net/ena/ena_ethdev.c | 36 +- drivers/net/enic/enic_main.c | 27 +- drivers/net/failsafe/failsafe.c | 24 +- drivers/net/failsafe/failsafe_intr.c | 45 +- drivers/net/failsafe/failsafe_ops.c | 23 +- drivers/net/failsafe/failsafe_private.h | 2 +- drivers/net/fm10k/fm10k_ethdev.c | 32 +- drivers/net/hinic/hinic_pmd_ethdev.c | 10 +- drivers/net/hns3/hns3_ethdev.c | 50 +- drivers/net/hns3/hns3_ethdev_vf.c | 57 +- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/i40e/i40e_ethdev.c | 55 +- drivers/net/i40e/i40e_ethdev_vf.c | 43 +- drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_vchnl.c | 4 +- drivers/net/ice/ice_dcf.c | 10 +- drivers/net/ice/ice_dcf_ethdev.c | 23 +- drivers/net/ice/ice_ethdev.c | 51 +- drivers/net/igc/igc_ethdev.c | 47 +- drivers/net/ionic/ionic_ethdev.c | 12 +- drivers/net/ixgbe/ixgbe_ethdev.c | 70 +- drivers/net/memif/memif_socket.c | 114 ++- drivers/net/memif/memif_socket.h | 4 +- drivers/net/memif/rte_eth_memif.c | 63 +- drivers/net/memif/rte_eth_memif.h | 2 +- drivers/net/mlx4/mlx4.c | 20 +- drivers/net/mlx4/mlx4.h | 2 +- drivers/net/mlx4/mlx4_intr.c | 48 +- drivers/net/mlx5/linux/mlx5_os.c | 56 +- drivers/net/mlx5/linux/mlx5_socket.c | 26 +- drivers/net/mlx5/mlx5.h | 6 +- drivers/net/mlx5/mlx5_rxq.c | 43 +- drivers/net/mlx5/mlx5_trigger.c | 4 +- drivers/net/mlx5/mlx5_txpp.c | 27 +- drivers/net/netvsc/hn_ethdev.c | 4 +- drivers/net/nfp/nfp_common.c | 28 +- drivers/net/nfp/nfp_ethdev.c | 13 +- drivers/net/nfp/nfp_ethdev_vf.c | 13 +- drivers/net/ngbe/ngbe_ethdev.c | 31 +- drivers/net/octeontx2/otx2_ethdev_irq.c | 35 +- drivers/net/qede/qede_ethdev.c | 16 +- drivers/net/sfc/sfc_intr.c | 29 +- drivers/net/tap/rte_eth_tap.c | 37 +- drivers/net/tap/rte_eth_tap.h | 2 +- drivers/net/tap/tap_intr.c | 33 +- drivers/net/thunderx/nicvf_ethdev.c | 13 + drivers/net/thunderx/nicvf_struct.h | 2 +- drivers/net/txgbe/txgbe_ethdev.c | 36 +- drivers/net/txgbe/txgbe_ethdev_vf.c | 35 +- drivers/net/vhost/rte_eth_vhost.c | 78 +- drivers/net/virtio/virtio_ethdev.c | 17 +- .../net/virtio/virtio_user/virtio_user_dev.c | 53 +- drivers/net/vmxnet3/vmxnet3_ethdev.c | 45 +- drivers/raw/ifpga/ifpga_rawdev.c | 42 +- drivers/raw/ntb/ntb.c | 10 +- .../regex/octeontx2/otx2_regexdev_hw_access.c | 4 +- drivers/vdpa/ifc/ifcvf_vdpa.c | 5 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 11 + drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 22 +- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 46 +- lib/bbdev/rte_bbdev.c | 4 +- lib/eal/common/eal_common_interrupts.c | 668 +++++++++++++++++ lib/eal/common/eal_private.h | 11 + lib/eal/common/meson.build | 2 + lib/eal/freebsd/eal.c | 1 + lib/eal/freebsd/eal_alarm.c | 56 +- lib/eal/freebsd/eal_interrupts.c | 94 ++- lib/eal/include/meson.build | 2 +- lib/eal/include/rte_eal_interrupts.h | 269 ------- lib/eal/include/rte_eal_trace.h | 24 +- lib/eal/include/rte_epoll.h | 116 +++ lib/eal/include/rte_interrupts.h | 673 +++++++++++++++++- lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_alarm.c | 39 +- lib/eal/linux/eal_dev.c | 65 +- lib/eal/linux/eal_interrupts.c | 294 +++++--- lib/eal/version.map | 30 + lib/ethdev/ethdev_pci.h | 2 +- lib/ethdev/rte_ethdev.c | 14 +- 132 files changed, 3797 insertions(+), 1685 deletions(-) create mode 100644 lib/eal/common/eal_common_interrupts.c delete mode 100644 lib/eal/include/rte_eal_interrupts.h create mode 100644 lib/eal/include/rte_epoll.h--
2.18.0
Hello Harman,
Quoted 12 lines · Harman Kalra
Moving struct
rte_intr_handleas an internal structure to avoid any ABI breakages in future. Since this structure defines some static arrays and changing respective macros breaks the ABI. Eg:
CurrentlyRTE_MAX_RXTX_INTR_VEC_IDimposes a limit of maximum 512 MSI-X interrupts that can be defined for a PCI device, while PCI specification allows maximum 2048 MSI-X interrupts that can be used. If some PCI device requires more than 512 vectors, either change theRTE_MAX_RXTX_INTR_VEC_IDlimit or dynamically allocate based on PCI device MSI-X size on probe time. Either way its an ABI breakage.
Quoted 7 lines
Change already included in 21.11 ABI improvement spreadsheet (item 42):
https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.google.com_s
preadsheets_d_1betlC000ua5SsSiJIcC54mCCCJnW6voH5Dqv9UxeyfE_edit-23gid- 3D0&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=5ESHPj7V-7JdkxT_Z_SU6RrS37ys4U XudBQ_rrS5LRo&m=7dl3OmXU7QHMmWYB6V1hYJtq1cUkjfhXUwze2Si_48c&s=lh6DEGhR Bg1shODpAy3RQk-H-0uQx5icRfUBf9dtCp4&e=
Thanks for taking care of this huge cleanup.
I started looking at it.
Signature · 1 line
David Marchand
v2 cover make rte_intr_handle internal
In reply to Harman KalraMoving struct rte_intr_handle as an internal structure to avoid any ABI breakages in future. Since this structure defines some static arrays and changing respective macros breaks the ABI. Eg:
Currently RTE_MAX_RXTX_INTR_VEC_ID imposes a limit of maximum 512 MSI-X interrupts that can be defined for a PCI device, while PCI specification allows maximum 2048 MSI-X interrupts that can be used. If some PCI device requires more than 512 vectors, either change the RTE_MAX_RXTX_INTR_VEC_ID limit or dynamically allocate based on PCI device MSI-X size on probe time. Either way its an ABI breakage.
Change already included in 21.11 ABI improvement spreadsheet (item 42):
https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.google.com_s
preadsheets_d_1betlC000ua5SsSiJIcC54mCCCJnW6voH5Dqv9UxeyfE_edit-23gid- 3D0&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=5ESHPj7V-7JdkxT_Z_SU6RrS37ys4U XudBQ_rrS5LRo&m=7dl3OmXU7QHMmWYB6V1hYJtq1cUkjfhXUwze2Si_48c&s=lh6DEGhR Bg1shODpAy3RQk-H-0uQx5icRfUBf9dtCp4&e=
This series makes struct rte_intr_handle totally opaque to the outside world by wrapping it inside a .c file and providing get set wrapper APIs to read or manipulate its fields.. Any changes to be made to any of the fields should be done via these get set APIs.
Introduced a new eal_common_interrupts.c where all these APIs are defined and also hides struct rte_intr_handle definition.
Details on each patch of the series:
Patch 1: eal/interrupts: implement get set APIs
This patch provides prototypes and implementation of all the new get set APIs. Alloc APIs are implemented to allocate memory for interrupt handle instance. Currently most of the drivers defines interrupt handle instance as static but now it cant be static as size of rte_intr_handle is unknown to all the drivers. Drivers are expected to allocate interrupt instances during initialization and free these instances during cleanup phase.
This patch also rearranges the headers related to interrupt framework. Epoll related definitions prototypes are moved into a new header i.e. rte_epoll.h and APIs defined in rte_eal_interrupts.h which were driver specific are moved to rte_interrupts.h (as anyways it was accessible and used outside DPDK library. Later in the series rte_eal_interrupts.h is removed.
Patch 2: eal/interrupts: avoid direct access to interrupt handle Modifying the interrupt framework for linux and freebsd to use these get set alloc APIs as per requirement and avoid accessing the fields directly.
Patch 3: test/interrupt: apply get set interrupt handle APIs Updating interrupt test suite to use interrupt handle APIs.
Patch 4: drivers: remove direct access to interrupt handle fields Modifying all the drivers and libraries which are currently directly accessing the interrupt handle fields. Drivers are expected to allocated the interrupt instance, use get set APIs with the allocated interrupt handle and free it on cleanup.
Patch 5: eal/interrupts: make interrupt handle structure opaque In this patch rte_eal_interrupt.h is removed, struct rte_intr_handle definition is moved to c file to make it completely opaque. As part of interrupt handle allocation, array like efds and elist(which are currently static) are dynamically allocated with default size (RTE_MAX_RXTX_INTR_VEC_ID). Later these arrays can be reallocated as per device requirement using new API rte_intr_handle_event_list_update(). Eg, on PCI device probing MSIX size can be queried and these arrays can be reallocated accordingly.
Patch 6: eal/alarm: introduce alarm fini routine
Introducing alarm fini routine, as the memory allocated for alarm interrupt instance can be freed in alarm fini.
Testing performed:
1. Validated the series by running interrupts and alarm test suite.
2. Validate l3fwd power functionality with octeontx2 and i40e intel cards, where interrupts are expected on packet arrival.
v1:
* Fixed freebsd compilation failure
* Fixed seg fault in case of memif
v2:
* Merged the prototype and implementation patch to 1.
* Restricting allocation of single interrupt instance.
* Removed base APIs, as they were exposing internally allocated memory information.
* Fixed some memory leak issues.
* Marked some library specific APIs as internal.
Harman Kalra (6):
eal/interrupts: implement get set APIs eal/interrupts: avoid direct access to interrupt handle test/interrupt: apply get set interrupt handle APIs
drivers: remove direct access to interrupt handle eal/interrupts: make interrupt handle structure opaque eal/alarm: introduce alarm fini routine
MAINTAINERS | 1 + app/test/test_interrupts.c | 163 +++-- drivers/baseband/acc100/rte_acc100_pmd.c | 18 +- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 21 +- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 21 +- drivers/bus/auxiliary/auxiliary_common.c | 2 + drivers/bus/auxiliary/linux/auxiliary.c | 9 + drivers/bus/auxiliary/rte_bus_auxiliary.h | 2 +- drivers/bus/dpaa/dpaa_bus.c | 28 +- drivers/bus/dpaa/rte_dpaa_bus.h | 2 +- drivers/bus/fslmc/fslmc_bus.c | 15 +- drivers/bus/fslmc/fslmc_vfio.c | 32 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 20 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- drivers/bus/fslmc/rte_fslmc.h | 2 +- drivers/bus/ifpga/ifpga_bus.c | 15 +- drivers/bus/ifpga/rte_bus_ifpga.h | 2 +- drivers/bus/pci/bsd/pci.c | 21 +- drivers/bus/pci/linux/pci.c | 4 +- drivers/bus/pci/linux/pci_uio.c | 73 +- drivers/bus/pci/linux/pci_vfio.c | 115 +++- drivers/bus/pci/pci_common.c | 29 +- drivers/bus/pci/pci_common_uio.c | 21 +- drivers/bus/pci/rte_bus_pci.h | 4 +- drivers/bus/vmbus/linux/vmbus_bus.c | 5 + drivers/bus/vmbus/linux/vmbus_uio.c | 37 +- drivers/bus/vmbus/rte_bus_vmbus.h | 2 +- drivers/bus/vmbus/vmbus_common_uio.c | 24 +- drivers/common/cnxk/roc_cpt.c | 8 +- drivers/common/cnxk/roc_dev.c | 14 +- drivers/common/cnxk/roc_irq.c | 106 +-- drivers/common/cnxk/roc_nix_irq.c | 36 +- drivers/common/cnxk/roc_npa.c | 2 +- drivers/common/cnxk/roc_platform.h | 49 +- drivers/common/cnxk/roc_sso.c | 4 +- drivers/common/cnxk/roc_tim.c | 4 +- drivers/common/octeontx2/otx2_dev.c | 14 +- drivers/common/octeontx2/otx2_irq.c | 117 ++-- .../octeontx2/otx2_cryptodev_hw_access.c | 4 +- drivers/event/octeontx2/otx2_evdev_irq.c | 12 +- drivers/mempool/octeontx2/otx2_mempool.c | 2 +- drivers/net/atlantic/atl_ethdev.c | 20 +- drivers/net/avp/avp_ethdev.c | 8 +- drivers/net/axgbe/axgbe_ethdev.c | 12 +- drivers/net/axgbe/axgbe_mdio.c | 6 +- drivers/net/bnx2x/bnx2x_ethdev.c | 10 +- drivers/net/bnxt/bnxt_ethdev.c | 33 +- drivers/net/bnxt/bnxt_irq.c | 4 +- drivers/net/dpaa/dpaa_ethdev.c | 47 +- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +- drivers/net/e1000/em_ethdev.c | 23 +- drivers/net/e1000/igb_ethdev.c | 79 +-- drivers/net/ena/ena_ethdev.c | 35 +- drivers/net/enic/enic_main.c | 26 +- drivers/net/failsafe/failsafe.c | 23 +- drivers/net/failsafe/failsafe_intr.c | 43 +- drivers/net/failsafe/failsafe_ops.c | 21 +- drivers/net/failsafe/failsafe_private.h | 2 +- drivers/net/fm10k/fm10k_ethdev.c | 32 +- drivers/net/hinic/hinic_pmd_ethdev.c | 10 +- drivers/net/hns3/hns3_ethdev.c | 57 +- drivers/net/hns3/hns3_ethdev_vf.c | 64 +- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/i40e/i40e_ethdev.c | 53 +- drivers/net/iavf/iavf_ethdev.c | 42 +- drivers/net/iavf/iavf_vchnl.c | 4 +- drivers/net/ice/ice_dcf.c | 10 +- drivers/net/ice/ice_dcf_ethdev.c | 21 +- drivers/net/ice/ice_ethdev.c | 49 +- drivers/net/igc/igc_ethdev.c | 45 +- drivers/net/ionic/ionic_ethdev.c | 17 +- drivers/net/ixgbe/ixgbe_ethdev.c | 66 +- drivers/net/memif/memif_socket.c | 111 ++- drivers/net/memif/memif_socket.h | 4 +- drivers/net/memif/rte_eth_memif.c | 61 +- drivers/net/memif/rte_eth_memif.h | 2 +- drivers/net/mlx4/mlx4.c | 19 +- drivers/net/mlx4/mlx4.h | 2 +- drivers/net/mlx4/mlx4_intr.c | 47 +- drivers/net/mlx5/linux/mlx5_os.c | 54 +- drivers/net/mlx5/linux/mlx5_socket.c | 24 +- drivers/net/mlx5/mlx5.h | 6 +- drivers/net/mlx5/mlx5_rxq.c | 42 +- drivers/net/mlx5/mlx5_trigger.c | 4 +- drivers/net/mlx5/mlx5_txpp.c | 26 +- drivers/net/netvsc/hn_ethdev.c | 4 +- drivers/net/nfp/nfp_common.c | 34 +- drivers/net/nfp/nfp_ethdev.c | 13 +- drivers/net/nfp/nfp_ethdev_vf.c | 13 +- drivers/net/ngbe/ngbe_ethdev.c | 29 +- drivers/net/octeontx2/otx2_ethdev_irq.c | 35 +- drivers/net/qede/qede_ethdev.c | 16 +- drivers/net/sfc/sfc_intr.c | 30 +- drivers/net/tap/rte_eth_tap.c | 36 +- drivers/net/tap/rte_eth_tap.h | 2 +- drivers/net/tap/tap_intr.c | 32 +- drivers/net/thunderx/nicvf_ethdev.c | 12 + drivers/net/thunderx/nicvf_struct.h | 2 +- drivers/net/txgbe/txgbe_ethdev.c | 34 +- drivers/net/txgbe/txgbe_ethdev_vf.c | 33 +- drivers/net/vhost/rte_eth_vhost.c | 75 +- drivers/net/virtio/virtio_ethdev.c | 21 +- .../net/virtio/virtio_user/virtio_user_dev.c | 48 +- drivers/net/vmxnet3/vmxnet3_ethdev.c | 43 +- drivers/raw/ifpga/ifpga_rawdev.c | 62 +- drivers/raw/ntb/ntb.c | 9 +- .../regex/octeontx2/otx2_regexdev_hw_access.c | 4 +- drivers/vdpa/ifc/ifcvf_vdpa.c | 5 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 10 + drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 22 +- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 45 +- lib/bbdev/rte_bbdev.c | 4 +- lib/eal/common/eal_common_interrupts.c | 649 ++++++++++++++++++ lib/eal/common/eal_private.h | 11 + lib/eal/common/meson.build | 1 + lib/eal/freebsd/eal.c | 1 + lib/eal/freebsd/eal_alarm.c | 52 +- lib/eal/freebsd/eal_interrupts.c | 110 ++- lib/eal/include/meson.build | 2 +- lib/eal/include/rte_eal_interrupts.h | 269 -------- lib/eal/include/rte_eal_trace.h | 24 +- lib/eal/include/rte_epoll.h | 118 ++++ lib/eal/include/rte_interrupts.h | 634 ++++++++++++++++- lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_alarm.c | 37 +- lib/eal/linux/eal_dev.c | 63 +- lib/eal/linux/eal_interrupts.c | 302 +++++--- lib/eal/version.map | 46 +- lib/ethdev/ethdev_pci.h | 2 +- lib/ethdev/rte_ethdev.c | 14 +- 131 files changed, 3645 insertions(+), 1706 deletions(-) create mode 100644 lib/eal/common/eal_common_interrupts.c delete mode 100644 lib/eal/include/rte_eal_interrupts.h create mode 100644 lib/eal/include/rte_epoll.h
Signature · 1 line
2.18.0
PATCH v2 1/6 eal/interrupts: implement get set APIs
Prototype/Implement get set APIs for interrupt handle fields. User wont be able to access any of the interrupt handle fields directly while should use these get/set APIs to access/manipulate them.
Internal interrupt header i.e. rte_eal_interrupt.h is rearranged, as APIs defined are moved to rte_interrupts.h and epoll specific definitions are moved to a new header rte_epoll.h. Later in the series rte_eal_interrupt.h will be removed.
--- MAINTAINERS | 1 + lib/eal/common/eal_common_interrupts.c | 470 +++++++++++++++++++ lib/eal/common/meson.build | 1 + lib/eal/include/meson.build | 1 + lib/eal/include/rte_eal_interrupts.h | 207 +-------- lib/eal/include/rte_epoll.h | 118 +++++ lib/eal/include/rte_interrupts.h | 614 ++++++++++++++++++++++++- lib/eal/version.map | 46 +- 8 files changed, 1245 insertions(+), 213 deletions(-) create mode 100644 lib/eal/common/eal_common_interrupts.c create mode 100644 lib/eal/include/rte_epoll.h
MAINTAINERS +1 -0
@@ -210,6 +210,7 @@ F: app/test/test_memzone.c Interrupt Subsystem M: Harman Kalra <[email protected]> +F: lib/eal/include/rte_epoll.h F: lib/eal/*/*interrupts.* F: app/test/test_interrupts.c
lib/eal/common/eal_common_interrupts.c new file +470 -0
470 lines not on this page · raw message
lib/eal/common/meson.build +1 -0
@@ -15,6 +15,7 @@ sources += files( 'eal_common_errno.c', 'eal_common_fbarray.c', 'eal_common_hexdump.c', + 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c',
lib/eal/include/meson.build +1 -0
@@ -19,6 +19,7 @@ headers += files( 'rte_eal_memconfig.h', 'rte_eal_trace.h', 'rte_errno.h', + 'rte_epoll.h', 'rte_fbarray.h', 'rte_hexdump.h', 'rte_hypervisor.h',
lib/eal/include/rte_eal_interrupts.h +5 -202
226 lines not on this page · raw message
lib/eal/include/rte_epoll.h new file +118 -0
118 lines not on this page · raw message
lib/eal/include/rte_interrupts.h +612 -2
640 lines not on this page · raw message
lib/eal/version.map +37 -9
65 lines not on this page · raw message
Signature · 1 line
2.18.0
Re: [dpdk-dev] [PATCH v2 1/6] eal/interrupts: implement get set APIs
2021-10-05 17:44 (UTC+0530), Harman Kalra:
Quoted 15 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +14
-0+int rte_intr_instance_copy (struct rte_intr_handle *intr_handle, +const struct rte_intr_handle *src) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (src ==NULL ) { +RTE_LOG (ERR ,EAL ,"Source interrupt instance unallocated\n" ); + rte_errno =EINVAL ; + goto fail; + }
lib/eal/common/eal_common_interrupts.c line 61
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+ + intr_handle->fd = src->fd; + intr_handle->vfio_dev_fd = src->vfio_dev_fd; + intr_handle->type = src->type; + intr_handle->max_intr = src->max_intr; + intr_handle->nb_efd = src->nb_efd; + intr_handle->efd_counter_size = src->efd_counter_size; + +memcpy (intr_handle->efds, src->efds, src->nb_intr); +memcpy (intr_handle->elist, src->elist, src->nb_intr);
Buffer overrun if "intr_handle->nb_intr < src->nb_intr"?
lib/eal/common/eal_common_interrupts.c line 73
Quoted 12 lines
lib/eal/common/eal_common_interrupts.c new file +12
-0+ +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_instance_mem_allocator_get ( +const struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); +return -ENOTSUP ;
ENOTSUP usually means the operation is valid from API standpoint but not supported by the implementation. EINVAL/EFAULT suits better.
lib/eal/common/eal_common_interrupts.c line 77
Quoted 4 lines
lib/eal/common/eal_common_interrupts.c new file +4
-0+ } + +return intr_handle->mem_allocator; +}
What do you think about having an API to retrieve the entire flags instead?
lib/eal/common/eal_common_interrupts.c line 84
Quoted 7 lines
lib/eal/common/eal_common_interrupts.c new file +7
-0+ +void rte_intr_instance_free (struct rte_intr_handle *intr_handle) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + }
API are neater when free(NULL) is a no-op.
Quoted 4 lines
lib/eal/common/eal_common_interrupts.c new file +4
-0+ +if (intr_handle->mem_allocator) +rte_free (intr_handle); +else
lib/eal/common/eal_common_interrupts.c line 98
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+free (intr_handle); +} + +int rte_intr_fd_set (struct rte_intr_handle *intr_handle,int fd) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + }
This piece repeats over and over, how about making it a function or a macro, like in ethdev?
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+ + intr_handle->fd = fd; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_fd_get (const struct rte_intr_handle *intr_handle) +{
lib/eal/common/eal_common_interrupts.c line 118
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->fd; +fail: +return -1 ; +}
Please add a similar pair of experimental API for the "handle" member, it is needed for Windows interrupt support I'm working on top of these series (IIUC, API changes should be closed by RC1.)
If you will be doing this and don't like "handle" name, it might be like "dev_handle" or "windows_device".
lib/eal/common/eal_common_interrupts.c line 186
Quoted 12 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +11
-0+int rte_intr_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (max_intr > intr_handle->nb_intr) { + RTE_LOG(ERR, EAL, "Max_intr=%d greater than RTE_MAX_RXTX_INTR_VEC_ID=%d",
The macros is not used in the comparison, neither should the log mention it.
lib/eal/version.map EXPERIMENTAL { · line 418
Quoted 9 lines
[...]
lib/eal/version.map +4
-0@@ -420,6 +412,14 @@ EXPERIMENTAL { # added in 21.08 rte_power_monitor_multi; # WINDOWS_NO_EXPORT + + # added in 21.11 + rte_intr_fd_set; + rte_intr_fd_get;
WINDOWS_NO_EXPORT
lib/eal/version.map EXPERIMENTAL { · line 423
Quoted 5 lines
lib/eal/version.map +4
-0+ rte_intr_type_set; + rte_intr_type_get; + rte_intr_instance_alloc; + rte_intr_instance_free; };
Do I understand correctly that these exports are needed
to allow an application to use DPDK callback facilities
for its own interrupt sources?
If so, I'd suggest that instead we export a simpler set of functions:
1. Create/free a handle instance with automatic fixed type selection.
2. Trigger an interrupt on the specified handle instance.
The flow would be that the application listens on whatever it wants, probably with OS-specific mechanisms, and just notifies the interrupt thread about events to trigger callbacks.
Because these APIs are experimental we don't need to change it now, just my thoughts for the future.
Re: [dpdk-dev] [EXT] Re: [PATCH v2 1/6] eal/interrupts: implement get set APIs
Hi Dmitry,
Thanks for your inputs.
Please see inline.
Quoted 24 lines
-----Original Message-----
From: Dmitry Kozlyuk <[email protected]>
Sent: Thursday, October 14, 2021 6:29 AM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; Ray Kinsella <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH v2 1/6] eal/interrupts: implement get set APIsExternal Email
----------------------------------------------------------------------
2021-10-05 17:44 (UTC+0530), Harman Kalra:lib/eal/common/eal_common_interrupts.c
Quoted 11 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +10
-0+int rte_intr_instance_copy (struct rte_intr_handle *intr_handle, +const struct rte_intr_handle *src) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (src ==NULL ) { + RTE_LOG(ERR, EAL, "Source interrupt instanceunallocated\n");
Quoted 15 lines
lib/eal/common/eal_common_interrupts.c line 61
Quoted 13 lines
lib/eal/common/eal_common_interrupts.c new file +13
-0+ rte_errno =EINVAL ; + goto fail; + } + + intr_handle->fd = src->fd; + intr_handle->vfio_dev_fd = src->vfio_dev_fd; + intr_handle->type = src->type; + intr_handle->max_intr = src->max_intr; + intr_handle->nb_efd = src->nb_efd; + intr_handle->efd_counter_size = src->efd_counter_size; + +memcpy (intr_handle->efds, src->efds, src->nb_intr); +memcpy (intr_handle->elist, src->elist, src->nb_intr);Buffer overrun if "
intr_handle->nb_intr<src->nb_intr"?
Ack, I will add the check.
Quoted 15 lines
lib/eal/common/eal_common_interrupts.c line 73
Quoted 12 lines
lib/eal/common/eal_common_interrupts.c new file +11
-0+ +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_instance_mem_allocator_get ( +const struct rte_intr_handle *intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); +return -ENOTSUP ;ENOTSUP usually means the operation is valid from API standpoint but not supported by the implementation. EINVAL/EFAULT suits better.
Ack, will make it EFAULT.
Quoted 7 lines
lib/eal/common/eal_common_interrupts.c line 77
Quoted 5 lines
lib/eal/common/eal_common_interrupts.c new file +4
-0+ } + +return intr_handle->mem_allocator; +}What do you think about having an API to retrieve the entire flags instead?
Now since we are planning to remove this flag variable and rely on auto detection mechanism. I will remove this API.
Quoted 9 lines
lib/eal/common/eal_common_interrupts.c line 45
Quoted 7 lines
lib/eal/common/eal_common_interrupts.c new file +6
-0+ +void rte_intr_instance_free (struct rte_intr_handle *intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + }API are neater when free(NULL) is a no-op.
Correct.
Quoted 17 lines
Quoted 4 lines
lib/eal/common/eal_common_interrupts.c new file +3
-0+ +if (intr_handle->mem_allocator) +rte_free (intr_handle);lib/eal/common/eal_common_interrupts.c line 98
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+else +free (intr_handle); +} + +int rte_intr_fd_set (struct rte_intr_handle *intr_handle,int fd) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + }This piece repeats over and over, how about making it a function or a macro, like in ethdev?
Ack, will define a macro for the same.
Quoted 18 lines
Quoted 18 lines
lib/eal/common/eal_common_interrupts.c new file +17
-0+ + intr_handle->fd = fd; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_fd_get (const struct rte_intr_handle *intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->fd; +fail:
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return -1; +}Please add a similar pair of experimental API for the "handle" member, it is needed for Windows interrupt support I'm working on top of these series (IIUC, API changes should be closed by RC1.) If you will be doing this and don't like "handle" name, it might be like "
dev_handle" or "windows_device".
I add new APIs to get/set handle. Let's rename it to "windows_handle"
Quoted 16 lines
Quoted 4 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +2
-0+int rte_intr_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr)lib/eal/common/eal_common_interrupts.c
Quoted 10 lines
lib/eal/common/eal_common_interrupts.c new file +10
-0+{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +if (max_intr > intr_handle->nb_intr) { + RTE_LOG(ERR, EAL, "Max_intr=%d greater than +RTE_MAX_RXTX_INTR_VEC_ID=%d",The macros is not used in the comparison, neither should the log mention it.
I will add the check.
Quoted 4 lines
Quoted 4 lines
[...]
(quoted diff) +0
-0@@ -420,6 +412,14 @@ EXPERIMENTAL {
Quoted 8 lines
lib/eal/version.map EXPERIMENTAL { · line 418
Quoted 6 lines
lib/eal/version.map +4
-0# added in 21.08 rte_power_monitor_multi; # WINDOWS_NO_EXPORT + + # added in 21.11 + rte_intr_fd_set; + rte_intr_fd_get;
WINDOWS_NO_EXPORT
Ack.
Quoted 9 lines
lib/eal/version.map EXPERIMENTAL { · line 423
Quoted 6 lines
lib/eal/version.map +4
-0+ rte_intr_type_set; + rte_intr_type_get; + rte_intr_instance_alloc; + rte_intr_instance_free; };Do I understand correctly that these exports are needed to allow an application to use DPDK callback facilities for its own interrupt sources?
I exported only those APIs which are currently used by test suite or example applications, may be later more APIs can be moved from internal to public on need basis.
Quoted 8 lines
If so, I'd suggest that instead we export a simpler set of functions:
1. Create/free a handle instance with automatic fixed type selection.
2. Trigger an interrupt on the specified handle instance.
The flow would be that the application listens on whatever it wants, probably with OS-specific mechanisms, and just notifies the interrupt thread about events to trigger callbacks.
Because these APIs are experimental we don't need to change it now, just my thoughts for the future.
I am sorry but I did not followed your suggestion, can you please explain.
Thanks
Harman
Re: [dpdk-dev] [EXT] Re: [PATCH v2 1/6] eal/interrupts: implement get set APIs
2021-10-14 17:15 (UTC+0000), Harman Kalra:
Quoted 19 lines
[...]
Quoted 9 lines
Quoted 9 lines
lib/eal/common/eal_common_interrupts.c new file +9
-0+int rte_intr_fd_get (const struct rte_intr_handle *intr_handle) { +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ; + goto fail; + } + +return intr_handle->fd; +fail:Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return -1; +}Please add a similar pair of experimental API for the "handle" member, it is needed for Windows interrupt support I'm working on top of these series (IIUC, API changes should be closed by RC1.) If you will be doing this and don't like "handle" name, it might be like "
dev_handle" or "windows_device".
Quoted 1 line
I add new APIs to get/set handle. Let's rename it to "
windows_handle"
The name works for me, thanks.
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
[...]
lib/eal/common/eal_common_interrupts.c new file +6
-0+int rte_intr_max_intr_set (struct rte_intr_handle *intr_handle, +int max_intr) +{ +if (intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Interrupt instance unallocated\n" ); + rte_errno =ENOTSUP ;Quoted 8 lines
lib/eal/common/eal_common_interrupts.c
Quoted 6 lines
lib/eal/common/eal_common_interrupts.c new file +6
-0+ goto fail; + } + +if (max_intr > intr_handle->nb_intr) { + RTE_LOG(ERR, EAL, "Max_intr=%d greater than +RTE_MAX_RXTX_INTR_VEC_ID=%d",The macros is not used in the comparison, neither should the log mention it.
Quoted 1 line
I will add the check.
What check? I mean that the condition is max_intr > intr_handle->nb_intr, so RTE_MAX_RXTX_INTR_VEC_ID is not relevant, intr_handle->nb_intr is dynamic. Probably it should be like this:
RTE_LOG(ERR, EAL, "Maximum interrupt vector ID (%d) exceeds "
"the number of available events (%d)\n", max_intr, intr_handle->nb_intr);
Quoted 24 lines
[...]
Quoted 8 lines
lib/eal/version.map EXPERIMENTAL { · line 423
Quoted 5 lines
lib/eal/version.map +4
-0+ rte_intr_type_set; + rte_intr_type_get; + rte_intr_instance_alloc; + rte_intr_instance_free; };Do I understand correctly that these exports are needed to allow an application to use DPDK callback facilities for its own interrupt sources?
I exported only those APIs which are currently used by test suite or example applications, may be later more APIs can be moved from internal to public on need basis.
Quoted 8 lines
If so, I'd suggest that instead we export a simpler set of functions:
1. Create/free a handle instance with automatic fixed type selection.
2. Trigger an interrupt on the specified handle instance.
The flow would be that the application listens on whatever it wants, probably with OS-specific mechanisms, and just notifies the interrupt thread about events to trigger callbacks.
Because these APIs are experimental we don't need to change it now, just my thoughts for the future.
Quoted 1 line
I am sorry but I did not followed your suggestion, can you please explain.
These API is used as follows. The application has a file descriptor that becomes readable on some event. The programmer doesn't want to create another thread like EAL interrupt thread, implement thread-safe callback registration and invocation. They want to reuse DPDK mechanism instead. So they create an instance of type EXT and give it the descriptor. In case of the unit test the descriptor is a pipe read end.
In case of a real application it can be a socket, like in mlx5 PMD. This is often convenient, but not always. An event may be a signal, or busy-wait end, or it may be Windows with its completely different IO model (it's "issue an IO, wait for completion" instead of POSIX
"wait for IO readiness, do a blocking IO").
In all these cases the user needs to create a fake pipe (or whatever) to fit into how the interrupt thread waits for events.
But what the application really needs is to say "there's an event, please run the callback on this handle". It's a function call that doesn't require any explicit file descriptors or handles, doesn't rely on any IO model. How it is implemented depends on the EAL, for POSIX it will probably be an internal pipe, Windows can use APC as in eal_intr_thread_schedule(). Again, I'm thinking out loud here, nothing of this needs to be done now.
Re: [dpdk-dev] [EXT] Re: [PATCH v2 1/6] eal/interrupts: implement get set APIs
14/10/2021 19:53, Dmitry Kozlyuk:
Quoted 36 lines
2021-10-14 17:15 (UTC+0000), Harman Kalra:
Quoted 22 lines
Quoted 8 lines
lib/eal/version.map EXPERIMENTAL { · line 423
Quoted 5 lines
lib/eal/version.map +4
-0+ rte_intr_type_set; + rte_intr_type_get; + rte_intr_instance_alloc; + rte_intr_instance_free; };Do I understand correctly that these exports are needed to allow an application to use DPDK callback facilities for its own interrupt sources?
I exported only those APIs which are currently used by test suite or example applications, may be later more APIs can be moved from internal to public on need basis.
Quoted 8 lines
If so, I'd suggest that instead we export a simpler set of functions:
1. Create/free a handle instance with automatic fixed type selection.
2. Trigger an interrupt on the specified handle instance.
The flow would be that the application listens on whatever it wants, probably with OS-specific mechanisms, and just notifies the interrupt thread about events to trigger callbacks.
Because these APIs are experimental we don't need to change it now, just my thoughts for the future.Quoted 1 line
I am sorry but I did not followed your suggestion, can you please explain.
These API is used as follows. The application has a file descriptor that becomes readable on some event. The programmer doesn't want to create another thread like EAL interrupt thread, implement thread-safe callback registration and invocation. They want to reuse DPDK mechanism instead. So they create an instance of type EXT and give it the descriptor. In case of the unit test the descriptor is a pipe read end.
In case of a real application it can be a socket, like in mlx5 PMD. This is often convenient, but not always. An event may be a signal, or busy-wait end, or it may be Windows with its completely different IO model (it's "issue an IO, wait for completion" instead of POSIX
"wait for IO readiness, do a blocking IO").
Quoted 8 lines
In all these cases the user needs to create a fake pipe (or whatever) to fit into how the interrupt thread waits for events.
But what the application really needs is to say "there's an event, please run the callback on this handle". It's a function call that doesn't require any explicit file descriptors or handles, doesn't rely on any IO model. How it is implemented depends on the EAL, for POSIX it will probably be an internal pipe, Windows can use APC as ineal_intr_thread_schedule(). Again, I'm thinking out loud here, nothing of this needs to be done now.
I like this way of thinking.
Re: [dpdk-dev] [PATCH v2 1/6] eal/interrupts: implement get set APIs
In reply to Harman Kalralib/eal/common/eal_common_interrupts.c line 18
Quoted 4 lines · Harman Kalra
lib/eal/common/eal_common_interrupts.c new file +4
-0+struct rte_intr_handle *rte_intr_instance_alloc (uint32_t flags) +{ +struct rte_intr_handle *intr_handle; +bool mem_allocator;
Regardless of the currently defined flags, we want to have an ABI ready for future changes, so if there is a "flags" input parameter, it must be checked against valid values.
You can build a RTE_INTR_ALLOC_KNOWN_FLAGS define that contains all valid flags either in a private header or only in this .c file if no other unit needs it.
Next, in this function:
if ((flags & ~RTE_INTR_ALLOC_KNOWN_FLAGS) != 0) {
rte_errno = EINVAL;
return NULL;
}A check in unit tests is then a good thing to add so that developpers adding new flag get a CI failure.
This is not a blocker as this API is still experimental, but please let's do this from the start.
Quoted 7 lines
lib/eal/common/eal_common_interrupts.c new file +7
-0+ + mem_allocator = (flags &RTE_INTR_ALLOC_DPDK_ALLOCATOR ) !=0 ; +if (mem_allocator) + intr_handle =rte_zmalloc (NULL ,sizeof (struct rte_intr_handle ), +0 ); +else + intr_handle =calloc (1 ,sizeof (struct rte_intr_handle ));
Signature · 1 line
David Marchand
PATCH v2 2/6 eal/interrupts: avoid direct access to interrupt handle
In reply to Harman KalraMaking changes to the interrupt framework to use interrupt handle APIs to get/set any field. Direct access to any of the fields should be avoided to avoid any ABI breakage in future.
--- lib/eal/freebsd/eal_interrupts.c | 111 ++++++++---- lib/eal/include/rte_interrupts.h | 2 + lib/eal/linux/eal_interrupts.c | 302 +++++++++++++++++++------------ 3 files changed, 268 insertions(+), 147 deletions(-)
lib/eal/freebsd/eal_interrupts.c +76 -35
@@ -40,7 +40,7 @@ struct rte_intr_callback {struct rte_intr_source {TAILQ_ENTRY (rte_intr_source) next; -struct rte_intr_handle intr_handle;/**< interrupt handle */ +struct rte_intr_handle *intr_handle;/**< interrupt handle */ struct rte_intr_cb_list callbacks;/**< user callbacks */ uint32_t active; };
@@ -60,7 +60,7 @@ static int intr_source_to_kevent(const struct rte_intr_handle *ih, struct kevent *ke) {/* alarm callbacks are special case */ -if (ih->type ==RTE_INTR_HANDLE_ALARM ) { +if (rte_intr_type_get (ih) ==RTE_INTR_HANDLE_ALARM ) {uint64_t timeout_ns;/* get soonest alarm timeout */
@@ -75,7 +75,7 @@ intr_source_to_kevent(const struct rte_intr_handle *ih, struct kevent *ke) }else { ke->filter =EVFILT_READ ; } - ke->ident = ih->fd; + ke->ident =rte_intr_fd_get (ih);return 0 ; }
@@ -86,10 +86,11 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle, {struct rte_intr_callback *callback;struct rte_intr_source *src; -int ret =0 , add_event =0 ; +int ret =0 , add_event =0 , mem_allocator;/* first do parameter checking */ -if (intr_handle ==NULL || intr_handle->fd <0 || cb ==NULL ) { +if (intr_handle ==NULL ||rte_intr_fd_get (intr_handle) <0 || + cb ==NULL ) {RTE_LOG (ERR ,EAL ,"Registering with invalid input parameter\n" );return -EINVAL ;
@@ -103,7 +104,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,/* find the source for this intr_handle */ TAILQ_FOREACH(src, &intr_sources, next) { -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_fd_get (src->intr_handle) == +rte_intr_fd_get (intr_handle))break ; }
@@ -112,8 +114,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,* thing on the list should be eal_alarm_callback() and we may * be called just to reset the timer. */ -if (src !=NULL && src->intr_handle.type ==RTE_INTR_HANDLE_ALARM && - !TAILQ_EMPTY (&src->callbacks)) { +if (src !=NULL &&rte_intr_type_get (src->intr_handle) == +RTE_INTR_HANDLE_ALARM && !TAILQ_EMPTY (&src->callbacks)) { callback =NULL ; }else {/* allocate a new interrupt callback entity */
@@ -135,9 +137,35 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle, ret = -ENOMEM ; goto fail; }else { - src->intr_handle = *intr_handle; -TAILQ_INIT (&src->callbacks); -TAILQ_INSERT_TAIL (&intr_sources, src, next); +/* src->interrupt instance memory allocated +* depends on from where intr_handle memory +* is allocated. +*/ + mem_allocator = +rte_intr_instance_mem_allocator_get ( + intr_handle); +if (mem_allocator ==0 ) + src->intr_handle = +rte_intr_instance_alloc ( +RTE_INTR_ALLOC_TRAD_HEAP ); +else if (mem_allocator ==1 ) + src->intr_handle = +rte_intr_instance_alloc ( +RTE_INTR_ALLOC_DPDK_ALLOCATOR ); +else +RTE_LOG (ERR ,EAL ,"Failed to get mem allocator\n" ); + +if (src->intr_handle ==NULL ) { +RTE_LOG (ERR ,EAL ,"Can not create intr instance\n" ); +free (callback); + ret = -ENOMEM ; + }else { +rte_intr_instance_copy (src->intr_handle, + intr_handle); +TAILQ_INIT (&src->callbacks); +TAILQ_INSERT_TAIL (&intr_sources, src, + next); + } } }
@@ -151,7 +179,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,/* add events to the queue. timer events are special as we need to * re-set the timer. */ -if (add_event || src->intr_handle.type ==RTE_INTR_HANDLE_ALARM ) { +if (add_event ||rte_intr_type_get (src->intr_handle) == +RTE_INTR_HANDLE_ALARM ) {struct kevent ke;memset (&ke,0 ,sizeof (ke));
@@ -173,12 +202,13 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,*/ if (errno ==ENODEV )RTE_LOG (DEBUG ,EAL ,"Interrupt handle %d not supported\n" , - src->intr_handle.fd); +rte_intr_fd_get (src->intr_handle));else RTE_LOG (ERR ,EAL ,"Error adding fd %d " -"kevent, %s\n" , - src->intr_handle.fd, -strerror (errno)); +"kevent, %s\n" , +rte_intr_fd_get ( + src->intr_handle), +strerror (errno)); ret = -errno; goto fail; }
@@ -213,7 +243,7 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,struct rte_intr_callback *cb, *next;/* do parameter checking first */ -if (intr_handle ==NULL || intr_handle->fd <0 ) { +if (intr_handle ==NULL ||rte_intr_fd_get (intr_handle) <0 ) {RTE_LOG (ERR ,EAL ,"Unregistering with invalid input parameter\n" );return -EINVAL ;
@@ -228,7 +258,8 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,/* check if the insterrupt source for the fd is existent */ TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_fd_get (src->intr_handle) == +rte_intr_fd_get (intr_handle))break ;/* No interrupt source registered for the fd */
@@ -268,7 +299,7 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,struct rte_intr_callback *cb, *next;/* do parameter checking first */ -if (intr_handle ==NULL || intr_handle->fd <0 ) { +if (intr_handle ==NULL ||rte_intr_fd_get (intr_handle) <0 ) {RTE_LOG (ERR ,EAL ,"Unregistering with invalid input parameter\n" );return -EINVAL ;
@@ -282,7 +313,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,/* check if the insterrupt source for the fd is existent */ TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == intr_handle->fd) +if (rte_intr_fd_get (src->intr_handle) == +rte_intr_fd_get (intr_handle))break ;/* No interrupt source registered for the fd */
@@ -314,7 +346,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,*/ if (kevent (kq, &ke,1 ,NULL ,0 ,NULL ) <0 ) {RTE_LOG (ERR ,EAL ,"Error removing fd %d kevent, %s\n" , - src->intr_handle.fd,strerror (errno)); +rte_intr_fd_get (src->intr_handle), +strerror (errno));/* removing non-existent even is an expected condition * in some circumstances (e.g. oneshot events). */
@@ -365,17 +398,18 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)if (intr_handle ==NULL )return -1 ; -if (intr_handle->type ==RTE_INTR_HANDLE_VDEV ) { +if (rte_intr_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV ) { rc =0 ; goto out; } -if (intr_handle->fd <0 || intr_handle->uio_cfg_fd <0 ) { +if (rte_intr_fd_get (intr_handle) <0 || +rte_intr_dev_fd_get (intr_handle) <0 ) { rc =-1 ; goto out; } -switch (intr_handle->type) { +switch (rte_intr_type_get (intr_handle)) {/* not used at this moment */ case RTE_INTR_HANDLE_ALARM : rc =-1 ;
@@ -388,7 +422,7 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)default :RTE_LOG (ERR ,EAL ,"Unknown handle type of fd %d\n" , - intr_handle->fd); +rte_intr_fd_get (intr_handle)); rc =-1 ;break ; }
@@ -406,17 +440,18 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)if (intr_handle ==NULL )return -1 ; -if (intr_handle->type ==RTE_INTR_HANDLE_VDEV ) { +if (rte_intr_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV ) { rc =0 ; goto out; } -if (intr_handle->fd <0 || intr_handle->uio_cfg_fd <0 ) { +if (rte_intr_fd_get (intr_handle) <0 || +rte_intr_dev_fd_get (intr_handle) <0 ) { rc =-1 ; goto out; } -switch (intr_handle->type) { +switch (rte_intr_type_get (intr_handle)) {/* not used at this moment */ case RTE_INTR_HANDLE_ALARM : rc =-1 ;
@@ -429,7 +464,7 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)default :RTE_LOG (ERR ,EAL ,"Unknown handle type of fd %d\n" , - intr_handle->fd); +rte_intr_fd_get (intr_handle)); rc =-1 ;break ; }
@@ -441,7 +476,8 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)int rte_intr_ack (const struct rte_intr_handle *intr_handle) { -if (intr_handle && intr_handle->type ==RTE_INTR_HANDLE_VDEV ) +if (intr_handle && +rte_intr_type_get (intr_handle) ==RTE_INTR_HANDLE_VDEV )return 0 ;return -1 ;
@@ -463,7 +499,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)rte_spinlock_lock (&intr_lock); TAILQ_FOREACH(src, &intr_sources, next) -if (src->intr_handle.fd == event_fd) +if (rte_intr_fd_get (src->intr_handle) == + event_fd)break ;if (src ==NULL ) {rte_spinlock_unlock (&intr_lock);
@@ -475,7 +512,7 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)rte_spinlock_unlock (&intr_lock);/* set the length to be read dor different handle type */ -switch (src->intr_handle.type) { +switch (rte_intr_type_get (src->intr_handle)) {case RTE_INTR_HANDLE_ALARM : bytes_read =0 ; call = true;
@@ -546,7 +583,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)/* mark for deletion from the queue */ ke.flags =EV_DELETE ; -if (intr_source_to_kevent (&src->intr_handle, &ke) <0 ) { +if (intr_source_to_kevent (src->intr_handle, + &ke) <0 ) {RTE_LOG (ERR ,EAL ,"Cannot convert to kevent\n" );rte_spinlock_unlock (&intr_lock);return ;
@@ -557,7 +595,9 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)*/ if (kevent (kq, &ke,1 ,NULL ,0 ,NULL ) <0 ) {RTE_LOG (ERR ,EAL ,"Error removing fd %d kevent, " -"%s\n" , src->intr_handle.fd, +"%s\n" , +rte_intr_fd_get ( + src->intr_handle),strerror (errno));/* removing non-existent even is an expected * condition in some circumstances
@@ -567,7 +607,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)TAILQ_REMOVE (&src->callbacks, cb, next);if (cb->ucb_fn) - cb->ucb_fn (&src->intr_handle, cb->cb_arg); + cb->ucb_fn (src->intr_handle, + cb->cb_arg);free (cb); } }
lib/eal/include/rte_interrupts.h +2 -0
@@ -28,6 +28,8 @@ struct rte_intr_handle;/** Interrupt instance allocation flags * @see rte_intr_instance_alloc */ +/** Allocate interrupt instance from traditional heap */ +#define RTE_INTR_ALLOC_TRAD_HEAP 0x00000000/** Allocate interrupt instance using DPDK memory management APIs */ #define RTE_INTR_ALLOC_DPDK_ALLOCATOR 0x00000001
lib/eal/linux/eal_interrupts.c +190 -112
769 lines not on this page · raw message
Signature · 1 line
2.18.0
Re: [dpdk-dev] [PATCH v2 2/6] eal/interrupts: avoid direct access to interrupt handle
2021-10-05 17:44 (UTC+0530), Harman Kalra:
Quoted 3 lines
Making changes to the interrupt framework to use interrupt handle APIs to get/set any field. Direct access to any of the fields should be avoided to avoid any ABI breakage in future.
How is ABI breakage applicable to internal consumers?
This protects against fields renaming for sure, but convenience is arguable. If EAL needs to add a EAL-private field to struct rte_intr_handle, it must add an accessor even though the field is likely OS-specific. It would be simpler if the definition was in some private EAL header and could be accessed directly by EAL code.
Re: [dpdk-dev] [EXT] Re: [PATCH v2 2/6] eal/interrupts: avoid direct access to interrupt handle
Quoted 19 lines
-----Original Message-----
From: Dmitry Kozlyuk <[email protected]>
Sent: Thursday, October 14, 2021 6:29 AM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2 2/6] eal/interrupts: avoid direct access to interrupt handleExternal Email
----------------------------------------------------------------------
2021-10-05 17:44 (UTC+0530), Harman Kalra:Quoted 3 lines
Making changes to the interrupt framework to use interrupt handle APIs to get/set any field. Direct access to any of the fields should be avoided to avoid any ABI breakage in future.
Quoted 7 lines
How is ABI breakage applicable to internal consumers?
This protects against fields renaming for sure, but convenience is arguable. If EAL needs to add a EAL-private field to struct
rte_intr_handle, it must add an accessor even though the field is likely OS-specific.
It would be simpler if the definition was in some private EAL header and could be accessed directly by EAL code.
Initially we thought to implement this way only i.e. defining rte_intr_handle inside internal headers but supporting out of tree drivers was one of the reason to go via this get/set approach. All drivers internal and external should follow the same way, that was the intention.
Thanks
Harman
Re: [dpdk-dev] [EXT] Re: [PATCH v2 2/6] eal/interrupts: avoid direct access to interrupt handle
2021-10-14 17:31 (UTC+0000), Harman Kalra:
Quoted 25 lines
Quoted 17 lines
-----Original Message-----
From: Dmitry Kozlyuk <[email protected]>
Sent: Thursday, October 14, 2021 6:29 AM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2 2/6] eal/interrupts: avoid direct access to interrupt handleExternal Email
----------------------------------------------------------------------
2021-10-05 17:44 (UTC+0530), Harman Kalra:Quoted 3 lines
Making changes to the interrupt framework to use interrupt handle APIs to get/set any field. Direct access to any of the fields should be avoided to avoid any ABI breakage in future.
Quoted 7 lines
How is ABI breakage applicable to internal consumers?
This protects against fields renaming for sure, but convenience is arguable. If EAL needs to add a EAL-private field to struct
rte_intr_handle, it must add an accessor even though the field is likely OS-specific.
It would be simpler if the definition was in some private EAL header and could be accessed directly by EAL code.
Quoted 6 lines
Initially we thought to implement this way only i.e. defining
rte_intr_handleinside internal headers but supporting out of tree drivers was one of the reason to go via this get/set approach. All drivers internal and external should follow the same way, that was the intention.Thanks
Harman
True for drivers, I understand this, but the question is about EAL itself. I shouldn't say "internal consumers", I only meant EAL, not inbox drivers.
PATCH v2 3/6 test/interrupt: apply get set interrupt handle APIs
In reply to Harman KalraUpdating the interrupt testsuite to make use of interrupt handle get set APIs.
--- app/test/test_interrupts.c | 163 ++++++++++++++++++++++--------------- 1 file changed, 98 insertions(+), 65 deletions(-)
app/test/test_interrupts.c +98 -65
@@ -16,7 +16,7 @@/* predefined interrupt handle types */ enum test_interrupt_handle_type { -TEST_INTERRUPT_HANDLE_INVALID , +TEST_INTERRUPT_HANDLE_INVALID =0 ,TEST_INTERRUPT_HANDLE_VALID ,TEST_INTERRUPT_HANDLE_VALID_UIO ,TEST_INTERRUPT_HANDLE_VALID_ALARM ,
@@ -27,7 +27,7 @@ enum test_interrupt_handle_type {/* flag of if callback is called */ static volatile int flag; -static struct rte_intr_handle intr_handles[TEST_INTERRUPT_HANDLE_MAX ]; +static struct rte_intr_handle *intr_handles[TEST_INTERRUPT_HANDLE_MAX ];static enum test_interrupt_handle_type test_intr_type =TEST_INTERRUPT_HANDLE_MAX ;
@@ -50,7 +50,7 @@ static union intr_pipefds pfds;static inline int test_interrupt_handle_sanity_check (struct rte_intr_handle *intr_handle) { -if (!intr_handle || intr_handle->fd <0 ) +if (!intr_handle ||rte_intr_fd_get (intr_handle) <0 )return -1 ;return 0 ;
@@ -62,31 +62,55 @@ test_interrupt_handle_sanity_check(struct rte_intr_handle *intr_handle)static int test_interrupt_init (void ) { +struct rte_intr_handle *test_intr_handle; +int i; +if (pipe (pfds.pipefd) <0 )return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_INVALID ].fd =-1 ; - intr_handles[TEST_INTERRUPT_HANDLE_INVALID ].type = -RTE_INTR_HANDLE_UNKNOWN ; +for (i =0 ; i <TEST_INTERRUPT_HANDLE_MAX ; i++) { + intr_handles[i] = +rte_intr_instance_alloc (RTE_INTR_ALLOC_TRAD_HEAP ); +if (!intr_handles[i]) +return -1 ; + } + + test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; +if (rte_intr_fd_set (test_intr_handle,-1 )) +return -1 ; +if (rte_intr_type_set (test_intr_handle,RTE_INTR_HANDLE_UNKNOWN )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID ].type = -RTE_INTR_HANDLE_UNKNOWN ; + test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; +if (rte_intr_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_type_set (test_intr_handle,RTE_INTR_HANDLE_UNKNOWN )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ].type = -RTE_INTR_HANDLE_UIO ; + test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; +if (rte_intr_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_type_set (test_intr_handle,RTE_INTR_HANDLE_UIO )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ].type = -RTE_INTR_HANDLE_ALARM ; + test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; +if (rte_intr_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_type_set (test_intr_handle,RTE_INTR_HANDLE_ALARM )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ].fd = pfds.readfd; - intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ].type = -RTE_INTR_HANDLE_DEV_EVENT ; + test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; +if (rte_intr_fd_set (test_intr_handle, pfds.readfd)) +return -1 ; +if (rte_intr_type_set (test_intr_handle, +RTE_INTR_HANDLE_DEV_EVENT )) +return -1 ; - intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ].fd = pfds.writefd; - intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ].type =RTE_INTR_HANDLE_UIO ; + test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ]; +if (rte_intr_fd_set (test_intr_handle, pfds.writefd)) +return -1 ; +if (rte_intr_type_set (test_intr_handle,RTE_INTR_HANDLE_UIO )) +return -1 ;return 0 ; }
@@ -97,6 +121,10 @@ test_interrupt_init(void)static int test_interrupt_deinit (void ) { +int i; + +for (i =0 ; i <TEST_INTERRUPT_HANDLE_MAX ; i++) +rte_intr_instance_free (intr_handles[i]);close (pfds.pipefd[0 ]);close (pfds.pipefd[1 ]);
@@ -125,8 +153,10 @@ test_interrupt_handle_compare(struct rte_intr_handle *intr_handle_l,if (!intr_handle_l || !intr_handle_r)return -1 ; -if (intr_handle_l->fd != intr_handle_r->fd || - intr_handle_l->type != intr_handle_r->type) +if (rte_intr_fd_get (intr_handle_l) != +rte_intr_fd_get (intr_handle_r) || +rte_intr_type_get (intr_handle_l) != +rte_intr_type_get (intr_handle_r))return -1 ;return 0 ;
@@ -178,6 +208,8 @@ static void test_interrupt_callback(void *arg) {struct rte_intr_handle *intr_handle = arg; +struct rte_intr_handle *test_intr_handle; +if (test_intr_type >=TEST_INTERRUPT_HANDLE_MAX ) {printf ("invalid interrupt type\n" ); flag =-1 ;
@@ -198,8 +230,8 @@ test_interrupt_callback(void *arg)return ; } -if (test_interrupt_handle_compare (intr_handle, - &(intr_handles[test_intr_type])) ==0 ) + test_intr_handle = intr_handles[test_intr_type]; +if (test_interrupt_handle_compare (intr_handle, test_intr_handle) ==0 ) flag =1 ; }
@@ -223,7 +255,7 @@ test_interrupt_callback_1(void *arg)static int test_interrupt_enable (void ) { -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;/* check with null intr_handle */ if (rte_intr_enable (NULL ) ==0 ) {
@@ -233,7 +265,7 @@ test_interrupt_enable(void)/* check with invalid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable invalid intr_handle " "successfully\n" );return -1 ;
@@ -241,7 +273,7 @@ test_interrupt_enable(void)/* check with valid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ;
@@ -249,7 +281,7 @@ test_interrupt_enable(void)/* check with specific valid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ;
@@ -257,7 +289,7 @@ test_interrupt_enable(void)/* check with specific valid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ;
@@ -265,13 +297,13 @@ test_interrupt_enable(void)/* check with valid handler and its type */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ]; -if (rte_intr_enable (&test_intr_handle) <0 ) { +if (rte_intr_enable (test_intr_handle) <0 ) {printf ("fail to enable interrupt on a simulated handler\n" );return -1 ; } test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -if (rte_intr_enable (&test_intr_handle) ==0 ) { +if (rte_intr_enable (test_intr_handle) ==0 ) {printf ("unexpectedly enable a specific intr_handle " "successfully\n" );return -1 ;
@@ -286,7 +318,7 @@ test_interrupt_enable(void)static int test_interrupt_disable (void ) { -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;/* check with null intr_handle */ if (rte_intr_disable (NULL ) ==0 ) {
@@ -297,7 +329,7 @@ test_interrupt_disable(void)/* check with invalid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable invalid intr_handle " "successfully\n" );return -1 ;
@@ -305,7 +337,7 @@ test_interrupt_disable(void)/* check with valid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ;
@@ -313,7 +345,7 @@ test_interrupt_disable(void)/* check with specific valid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ;
@@ -321,7 +353,7 @@ test_interrupt_disable(void)/* check with specific valid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ;
@@ -329,13 +361,13 @@ test_interrupt_disable(void)/* check with valid handler and its type */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_CASE1 ]; -if (rte_intr_disable (&test_intr_handle) <0 ) { +if (rte_intr_disable (test_intr_handle) <0 ) {printf ("fail to disable interrupt on a simulated handler\n" );return -1 ; } test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -if (rte_intr_disable (&test_intr_handle) ==0 ) { +if (rte_intr_disable (test_intr_handle) ==0 ) {printf ("unexpectedly disable a specific intr_handle " "successfully\n" );return -1 ;
@@ -351,13 +383,13 @@ static int test_interrupt_full_path_check(enum test_interrupt_handle_type intr_type) {int count; -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle; flag =0 ; test_intr_handle = intr_handles[intr_type]; test_intr_type = intr_type; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <0 ) { +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) <0 ) {printf ("fail to register callback\n" );return -1 ; }
@@ -371,9 +403,9 @@ test_interrupt_full_path_check(enum test_interrupt_handle_type intr_type)rte_delay_ms (TEST_INTERRUPT_CHECK_INTERVAL );while ((count = -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, - &test_intr_handle)) <0 ) { + test_intr_handle)) <0 ) {if (count != -EAGAIN )return -1 ; }
@@ -396,7 +428,7 @@ static inttest_interrupt (void) {int ret =-1 ; -struct rte_intr_handle test_intr_handle; +struct rte_intr_handle *test_intr_handle;if (test_interrupt_init () <0 ) {printf ("fail to initialize for testing interrupt\n" );
@@ -445,8 +477,8 @@ test_interrupt(void)/* check if it will fail to register cb with invalid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) ==0 ) { +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) ==0 ) {printf ("unexpectedly register successfully with invalid " "intr_handle\n" ); goto out;
@@ -454,7 +486,8 @@ test_interrupt(void)/* check if it will fail to register without callback */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_callback_register (&test_intr_handle,NULL , &test_intr_handle) ==0 ) { +if (rte_intr_callback_register (test_intr_handle,NULL , + test_intr_handle) ==0 ) {printf ("unexpectedly register successfully with " "null callback\n" ); goto out;
@@ -470,8 +503,8 @@ test_interrupt(void)/* check if it will fail to unregister cb with invalid intr_handle */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID ]; -if (rte_intr_callback_unregister (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) >0 ) { +if (rte_intr_callback_unregister (test_intr_handle, + test_interrupt_callback, test_intr_handle) >0 ) {printf ("unexpectedly unregister successfully with " "invalid intr_handle\n" ); goto out;
@@ -479,29 +512,29 @@ test_interrupt(void)/* check if it is ok to register the same intr_handle twice */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <0 ) { +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback, test_intr_handle) <0 ) {printf ("it fails to register test_interrupt_callback\n" ); goto out; } -if (rte_intr_callback_register (&test_intr_handle, - test_interrupt_callback_1, &test_intr_handle) <0 ) { +if (rte_intr_callback_register (test_intr_handle, + test_interrupt_callback_1, test_intr_handle) <0 ) {printf ("it fails to register test_interrupt_callback_1\n" ); goto out; }/* check if it will fail to unregister with invalid parameter */ -if (rte_intr_callback_unregister (&test_intr_handle, +if (rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)0xff ) !=0 ) {printf ("unexpectedly unregisters successfully with " "invalid arg\n" ); goto out; } -if (rte_intr_callback_unregister (&test_intr_handle, - test_interrupt_callback, &test_intr_handle) <=0 ) { +if (rte_intr_callback_unregister (test_intr_handle, + test_interrupt_callback, test_intr_handle) <=0 ) {printf ("it fails to unregister test_interrupt_callback\n" ); goto out; } -if (rte_intr_callback_unregister (&test_intr_handle, +if (rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ) <=0 ) {printf ("it fails to unregister test_interrupt_callback_1 " "for all\n" );
@@ -529,27 +562,27 @@ test_interrupt(void)printf ("Clearing for interrupt tests\n" );/* clear registered callbacks */ test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID ]; -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_UIO ]; -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_ALARM ]; -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 ); test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_VALID_DEV_EVENT ]; -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback, (void *)-1 ); -rte_intr_callback_unregister (&test_intr_handle, +rte_intr_callback_unregister (test_intr_handle, test_interrupt_callback_1, (void *)-1 );rte_delay_ms (2 *TEST_INTERRUPT_CHECK_INTERVAL );
Signature · 1 line
2.18.0