This patch adds the equivalent functionality to FreeBSD as with patches 1 and 2
Signed-off-by: Alan Carew <alan.carew at intel.com> --- lib/librte_eal/bsdapp/eal/eal_pci.c | 45 +++++++++++++++++++++++++++++++ lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 14 +++++++++ 2 files changed, 59 insertions(+), 0 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 94ae461..7c270bb 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -50,6 +50,7 @@ #include <sys/ioctl.h> #include <sys/pciio.h> #include <dev/pci/pcireg.h> +#include <sys/sysctl.h> #include <rte_interrupts.h> #include <rte_log.h> @@ -108,6 +109,44 @@ TAILQ_HEAD(uio_res_list, uio_resource); static struct uio_res_list *uio_res_list = NULL; +struct rte_pci_dev_intr_mode { + enum igbuio_intr_mode mode; + const char *name; +}; + +/* Table of interrupt modes */ +const struct rte_pci_dev_intr_mode interrupt_modes[] = { +#define RTE_PCI_DEV_INTR_MODE(id, mode_name) {INTR_MODE (id, mode_name)}, +#include <rte_pci_dev_features.h> +}; + +/* + * Determine the kernel configured interrupt mode + */ +static int +pci_parse_intr_mode(struct rte_pci_device *dev) +{ + char intr_mode[INTR_NAME_LEN]; + unsigned int i, num_intr_modes = RTE_DIM(interrupt_modes); + size_t sysctl_size = sizeof(intr_mode); + + if (sysctlbyname("hw.nic_uio."RTE_PCI_DEV_FEATURE_INTR_MODE, &intr_mode, + &sysctl_size, NULL, 0) < 0) { + RTE_LOG(ERR, EAL, + "%s(): cannot get sysctlbyname: hw.nic_uio.intr_mode\n", + __func__); + return (-1); + } + for (i = 0; i < num_intr_modes; i++) { + if (!strncmp(intr_mode, interrupt_modes[i].name, INTR_NAME_LEN)) { + dev->intr_mode = interrupt_modes[i].mode; + return 0; + } + } + return -1; + +} + /* unbind kernel driver for this device */ static int pci_unbind_kernel_driver(struct rte_pci_device *dev) @@ -220,6 +259,12 @@ pci_uio_map_resource(struct rte_pci_device *dev) return -1; } + if (pci_parse_intr_mode(dev) < 0) { + RTE_LOG(ERR, EAL, + "%s(): unable to determine interrupt mode\n", __func__); + return (-1); + } + /* save fd if in primary process */ dev->intr_handle.fd = open(devname, O_RDWR); if (dev->intr_handle.fd < 0) { diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c index c10e9aa..0e17d63 100644 --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c @@ -51,6 +51,10 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_object.h> #include <vm/vm_page.h> #include <vm/vm_pager.h> +#include <sys/sysctl.h> + +#include <rte_pci_dev_feature_defs.h> +#include <rte_pci_dev_features.h> #define MAX_BARS (PCIR_MAX_BAR_0 + 1) @@ -116,6 +120,16 @@ const struct device devices[] = { }; #define NUM_DEVICES (sizeof(devices)/sizeof(devices[0])) +static char nic_uio_intr_mode[] = {IGBUIO_NONE_INTR_NAME}; + +TUNABLE_STR("hw.nic_uio."RTE_PCI_DEV_FEATURE_INTR_MODE, nic_uio_intr_mode, sizeof(nic_uio_intr_mode)); + +static SYSCTL_NODE(_hw, OID_AUTO, nic_uio, CTLFLAG_RD, 0, "nic_uio"); + +SYSCTL_STRING(_hw_nic_uio, OID_AUTO, interrupt_mode, CTLFLAG_RW, + &nic_uio_intr_mode, sizeof(nic_uio_intr_mode), + "Configured interrupt mode"); + static devclass_t nic_uio_devclass; -- 1.7.0.7