diff options
Diffstat (limited to 'lib/librte_eal')
-rw-r--r-- | lib/librte_eal/common/eal_common_options.c | 2 | ||||
-rw-r--r-- | lib/librte_eal/common/include/rte_common.h | 26 | ||||
-rw-r--r-- | lib/librte_eal/common/include/rte_pci.h | 2 | ||||
-rw-r--r-- | lib/librte_eal/common/include/rte_version.h | 2 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/eal/eal.c | 8 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/eal/eal_interrupts.c | 19 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/eal/eal_vfio.h | 25 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 1 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 31 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c | 8 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h | 35 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe.h | 2 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c | 8 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/kni/kni_ethtool.c | 10 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/kni/kni_fifo.h | 24 |
16 files changed, 169 insertions, 36 deletions
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 6ca8af17..2dc86509 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -179,7 +179,7 @@ eal_plugin_add(const char *path) return -1; } memset(solib, 0, sizeof(*solib)); - strncpy(solib->name, path, PATH_MAX-1); + strlcpy(solib->name, path, PATH_MAX-1); solib->name[PATH_MAX-1] = 0; TAILQ_INSERT_TAIL(&solib_list, solib, next); diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index f5e2f886..f17926f3 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -200,16 +200,7 @@ rte_is_aligned(void *ptr, unsigned align) /** * Triggers an error at compilation time if the condition is true. */ -#ifndef __OPTIMIZE__ #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) -#else -extern int RTE_BUILD_BUG_ON_detected_error; -#define RTE_BUILD_BUG_ON(condition) do { \ - ((void)sizeof(char[1 - 2*!!(condition)])); \ - if (condition) \ - RTE_BUILD_BUG_ON_detected_error = 1; \ -} while(0) -#endif /*********** Macros to work with powers of 2 ********/ @@ -326,6 +317,23 @@ rte_bsf32(uint32_t v) return (uint32_t)__builtin_ctz(v); } +/** + * Return the last (most-significant) bit set. + * + * @note The last (most significant) bit is at position 32. + * @note rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32 + * + * @param x + * The input parameter. + * @return + * The last (most-significant) bit set, or 0 if the input is 0. + */ +static inline int +rte_fls_u32(uint32_t x) +{ + return (x == 0) ? 0 : 32 - __builtin_clz(x); +} + #ifndef offsetof /** Return the offset of a field in a structure. */ #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 9ce88472..10fa8564 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -248,6 +248,8 @@ TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource); do { \ unsigned long val; \ char *end; \ + if (*in == '\0') \ + return -EINVAL; \ errno = 0; \ val = strtoul((in), &end, 16); \ if (errno != 0 || end[0] != (dlm) || val > (lim)) \ diff --git a/lib/librte_eal/common/include/rte_version.h b/lib/librte_eal/common/include/rte_version.h index 9148ef16..b509ec93 100644 --- a/lib/librte_eal/common/include/rte_version.h +++ b/lib/librte_eal/common/include/rte_version.h @@ -66,7 +66,7 @@ extern "C" { /** * Patch level number i.e. the z in yy.mm.z */ -#define RTE_VER_MINOR 8 +#define RTE_VER_MINOR 9 /** * Extra string to be appended to version number diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 59ed7882..bbd6284e 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -746,7 +746,8 @@ rte_eal_init(int argc, char **argv) int i, fctret, ret; pthread_t thread_id; static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0); - const char *logid; + const char *p; + static char logid[PATH_MAX]; char cpuset[RTE_CPU_AFFINITY_STR_LEN]; char thread_name[RTE_MAX_THREAD_NAME_LEN]; @@ -756,9 +757,8 @@ rte_eal_init(int argc, char **argv) if (!rte_atomic32_test_and_set(&run_once)) return -1; - logid = strrchr(argv[0], '/'); - logid = strdup(logid ? logid + 1: argv[0]); - + p = strrchr(argv[0], '/'); + strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid)); thread_id = pthread_self(); eal_log_level_parse(argc, argv); diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c index 7f739140..cce69285 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -647,7 +647,7 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds) { int n, bytes_read; struct rte_intr_source *src; - struct rte_intr_callback *cb; + struct rte_intr_callback *cb, *next; union rte_intr_read_buffer buf; struct rte_intr_callback active_cb; @@ -713,6 +713,23 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds) "descriptor %d: %s\n", events[n].data.fd, strerror(errno)); + /* + * The device is unplugged or buggy, remove + * it as an interrupt source and return to + * force the wait list to be rebuilt. + */ + rte_spinlock_lock(&intr_lock); + TAILQ_REMOVE(&intr_sources, src, next); + rte_spinlock_unlock(&intr_lock); + + for (cb = TAILQ_FIRST(&src->callbacks); cb; + cb = next) { + next = TAILQ_NEXT(cb, next); + TAILQ_REMOVE(&src->callbacks, cb, next); + free(cb); + } + free(src); + return -1; } else if (bytes_read == 0) RTE_LOG(ERR, EAL, "Read nothing from file " "descriptor %d\n", events[n].data.fd); diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c index 42280678..3ca217f4 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c @@ -327,7 +327,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, loc->function, res_idx); /* allocate memory to keep path */ - maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0); + maps[map_idx].path = rte_malloc(NULL, sizeof(devname), 0); if (maps[map_idx].path == NULL) { RTE_LOG(ERR, EAL, "Cannot allocate memory for path: %s\n", strerror(errno)); diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.h b/lib/librte_eal/linuxapp/eal/eal_vfio.h index ac31a4fc..72f1f757 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.h +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.h @@ -59,23 +59,46 @@ #define VFIO_IOMMU_SPAPR_REGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 17) #define VFIO_IOMMU_SPAPR_TCE_CREATE _IO(VFIO_TYPE, VFIO_BASE + 19) #define VFIO_IOMMU_SPAPR_TCE_REMOVE _IO(VFIO_TYPE, VFIO_BASE + 20) + struct vfio_iommu_spapr_register_memory { uint32_t argsz; uint32_t flags; uint64_t vaddr; uint64_t size; }; + struct vfio_iommu_spapr_tce_create { uint32_t argsz; uint32_t page_shift; uint64_t window_size; uint32_t levels; }; + struct vfio_iommu_spapr_tce_remove { uint32_t argsz; uint64_t start_addr; }; -#else + +struct vfio_iommu_spapr_tce_ddw_info { + uint64_t pgsizes; + uint32_t max_dynamic_windows_supported; + uint32_t levels; +}; + +/* SPAPR_v2 is not present, but SPAPR might be */ +#ifndef VFIO_SPAPR_TCE_IOMMU +#define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) + +struct vfio_iommu_spapr_tce_info { + uint32_t argsz; + uint32_t flags; + uint32_t dma32_window_start; + uint32_t dma32_window_size; + struct vfio_iommu_spapr_tce_ddw_info ddw; +}; +#endif /* VFIO_SPAPR_TCE_IOMMU */ + +#else /* VFIO_SPAPR_TCE_v2_IOMMU */ #define RTE_VFIO_SPAPR VFIO_SPAPR_TCE_v2_IOMMU #endif diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h index 09713b0c..1dc161c2 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h @@ -61,6 +61,7 @@ #ifdef __KERNEL__ #include <linux/if.h> +#include <asm/barrier.h> #define RTE_STD_C11 #else #include <rte_common.h> diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c index 9f00f07a..59d6a093 100644 --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c @@ -170,6 +170,33 @@ igbuio_pci_irqhandler(int irq, struct uio_info *info) return IRQ_HANDLED; } +/** + * This gets called while opening uio device file. + */ +static int +igbuio_pci_open(struct uio_info *info, struct inode *inode) +{ + struct rte_uio_pci_dev *udev = info->priv; + struct pci_dev *dev = udev->pdev; + + /* set bus master, which was cleared by the reset function */ + pci_set_master(dev); + + return 0; +} + +static int +igbuio_pci_release(struct uio_info *info, struct inode *inode) +{ + struct rte_uio_pci_dev *udev = info->priv; + struct pci_dev *dev = udev->pdev; + + /* stop the device from further DMA */ + pci_clear_master(dev); + + return 0; +} + #ifdef CONFIG_XEN_DOM0 static int igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma) @@ -370,6 +397,8 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) udev->info.version = "0.1"; udev->info.handler = igbuio_pci_irqhandler; udev->info.irqcontrol = igbuio_pci_irqcontrol; + udev->info.open = igbuio_pci_open; + udev->info.release = igbuio_pci_release; #ifdef CONFIG_XEN_DOM0 /* check if the driver run on Xen Dom0 */ if (xen_initial_domain()) @@ -460,6 +489,8 @@ igbuio_pci_remove(struct pci_dev *dev) { struct rte_uio_pci_dev *udev = pci_get_drvdata(dev); + igbuio_pci_release(&udev->info, NULL); + sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); uio_unregister_device(&udev->info); igbuio_pci_release_iomem(&udev->info); diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c index 1110bef8..272f3096 100644 --- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c +++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c @@ -150,6 +150,7 @@ static const char igb_gstrings_test[][ETH_GSTRING_LEN] = { #define IGB_TEST_LEN (sizeof(igb_gstrings_test) / ETH_GSTRING_LEN) #endif /* ETHTOOL_TEST */ +#ifndef ETHTOOL_GLINKSETTINGS static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) { struct igb_adapter *adapter = netdev_priv(netdev); @@ -274,7 +275,9 @@ static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) #endif /* ETH_TP_MDI_X */ return 0; } +#endif +#ifndef ETHTOOL_SLINKSETTINGS static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) { struct igb_adapter *adapter = netdev_priv(netdev); @@ -379,6 +382,7 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) clear_bit(__IGB_RESETTING, &adapter->state); return 0; } +#endif static u32 igb_get_link(struct net_device *netdev) { @@ -2752,8 +2756,12 @@ static int igb_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) #endif /* ETHTOOL_GRXRINGS */ static const struct ethtool_ops igb_ethtool_ops = { +#ifndef ETHTOOL_GLINKSETTINGS .get_settings = igb_get_settings, +#endif +#ifndef ETHTOOL_SLINKSETTINGS .set_settings = igb_set_settings, +#endif .get_drvinfo = igb_get_drvinfo, .get_regs_len = igb_get_regs_len, .get_regs = igb_get_regs, diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h index 9e4798ef..87d0096c 100644 --- a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h +++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h @@ -697,19 +697,22 @@ struct _kc_ethtool_pauseparam { #define SLE_VERSION(a,b,c) KERNEL_VERSION(a,b,c) #endif #ifdef CONFIG_SUSE_KERNEL -#if ( LINUX_VERSION_CODE == KERNEL_VERSION(2,6,27) ) -/* SLES11 GA is 2.6.27 based */ -#define SLE_VERSION_CODE SLE_VERSION(11,0,0) -#elif ( LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32) ) -/* SLES11 SP1 is 2.6.32 based */ -#define SLE_VERSION_CODE SLE_VERSION(11,1,0) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 57)) +/* SLES12SP3 is at least 4.4.57+ based */ +#define SLE_VERSION_CODE SLE_VERSION(12, 3, 0) +#elif ( LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,28) ) +/* SLES12 is at least 3.12.28+ based */ +#define SLE_VERSION_CODE SLE_VERSION(12,0,0) #elif ((LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,61)) && \ (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))) /* SLES11 SP3 is at least 3.0.61+ based */ #define SLE_VERSION_CODE SLE_VERSION(11,3,0) -#elif ( LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,28) ) -/* SLES12 is at least 3.12.28+ based */ -#define SLE_VERSION_CODE SLE_VERSION(12,0,0) +#elif ( LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32) ) +/* SLES11 SP1 is 2.6.32 based */ +#define SLE_VERSION_CODE SLE_VERSION(11,1,0) +#elif ( LINUX_VERSION_CODE == KERNEL_VERSION(2,6,27) ) +/* SLES11 GA is 2.6.27 based */ +#define SLE_VERSION_CODE SLE_VERSION(11,0,0) #endif /* LINUX_VERSION_CODE == KERNEL_VERSION(x,y,z) */ #endif /* CONFIG_SUSE_KERNEL */ #ifndef SLE_VERSION_CODE @@ -3912,7 +3915,8 @@ skb_set_hash(struct sk_buff *skb, __u32 hash, __always_unused int type) #define HAVE_NDO_BRIDGE_GETLINK_NLFLAGS #endif /* >= 4.1.0 */ -#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0) ) +#if (( LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0) ) \ + || ( RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,4) )) /* ndo_bridge_getlink adds new filter_mask and vlan_fill parameters */ #define HAVE_NDO_BRIDGE_GETLINK_FILTER_MASK_VLAN_FILL #endif /* >= 4.2.0 */ @@ -3929,9 +3933,16 @@ skb_set_hash(struct sk_buff *skb, __u32 hash, __always_unused int type) #define vlan_tx_tag_present skb_vlan_tag_present #endif -#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0) ) +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) || \ + (SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(12, 3, 0)) || \ + (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 4))) #define HAVE_VF_VLAN_PROTO -#endif /* >= 4.9.0 */ +#if (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 4)) +/* In RHEL/Centos 7.4, the "new" version of ndo_set_vf_vlan + * is in the struct net_device_ops_extended */ +#define ndo_set_vf_vlan extended.ndo_set_vf_vlan +#endif +#endif #if (defined(RHEL_RELEASE_CODE) && \ (RHEL_RELEASE_VERSION(7, 5) <= RHEL_RELEASE_CODE)) diff --git a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe.h b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe.h index 59415469..cc3f8ea4 100644 --- a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe.h +++ b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe.h @@ -905,8 +905,10 @@ s32 ixgbe_dcb_hw_ets(struct ixgbe_hw *hw, struct ieee_ets *ets, int max_frame); #endif /* CONFIG_DCB */ extern void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring); +#ifndef ETHTOOL_GLINKSETTINGS extern int ixgbe_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd); +#endif extern int ixgbe_write_uc_addr_list(struct ixgbe_adapter *adapter, struct net_device *netdev, unsigned int vfn); extern void ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter); diff --git a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c index bc3cb2f4..8e3f2587 100644 --- a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c +++ b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c @@ -173,6 +173,7 @@ static const char ixgbe_gstrings_test[][ETH_GSTRING_LEN] = { #define IXGBE_TEST_LEN (sizeof(ixgbe_gstrings_test) / ETH_GSTRING_LEN) #endif /* ETHTOOL_TEST */ +#ifndef ETHTOOL_GLINKSETTINGS int ixgbe_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) { @@ -362,7 +363,9 @@ int ixgbe_get_settings(struct net_device *netdev, return 0; } +#endif +#ifndef ETHTOOL_SLINKSETTINGS static int ixgbe_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) { @@ -406,6 +409,7 @@ static int ixgbe_set_settings(struct net_device *netdev, } return err; } +#endif static void ixgbe_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) @@ -2830,8 +2834,12 @@ static int ixgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) #endif /* ETHTOOL_GRXRINGS */ //static struct ethtool_ops ixgbe_ethtool_ops = { +#ifndef ETHTOOL_GLINKSETTINGS .get_settings = ixgbe_get_settings, +#endif +#ifndef ETHTOOL_SLINKSETTINGS .set_settings = ixgbe_set_settings, +#endif .get_drvinfo = ixgbe_get_drvinfo, .get_regs_len = ixgbe_get_regs_len, .get_regs = ixgbe_get_regs, diff --git a/lib/librte_eal/linuxapp/kni/kni_ethtool.c b/lib/librte_eal/linuxapp/kni/kni_ethtool.c index 0c88589c..8174e98d 100644 --- a/lib/librte_eal/linuxapp/kni/kni_ethtool.c +++ b/lib/librte_eal/linuxapp/kni/kni_ethtool.c @@ -46,6 +46,8 @@ kni_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) priv->lad_dev->ethtool_ops->get_drvinfo(priv->lad_dev, info); } +/* ETHTOOL_GLINKSETTINGS replaces ETHTOOL_GSET */ +#ifndef ETHTOOL_GLINKSETTINGS static int kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { @@ -53,7 +55,10 @@ kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) return priv->lad_dev->ethtool_ops->get_settings(priv->lad_dev, ecmd); } +#endif +/* ETHTOOL_SLINKSETTINGS replaces ETHTOOL_SSET */ +#ifndef ETHTOOL_SLINKSETTINGS static int kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { @@ -61,6 +66,7 @@ kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) return priv->lad_dev->ethtool_ops->set_settings(priv->lad_dev, ecmd); } +#endif static void kni_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) @@ -209,8 +215,12 @@ kni_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, struct ethtool_ops kni_ethtool_ops = { .begin = kni_check_if_running, .get_drvinfo = kni_get_drvinfo, +#ifndef ETHTOOL_GLINKSETTINGS .get_settings = kni_get_settings, +#endif +#ifndef ETHTOOL_SLINKSETTINGS .set_settings = kni_set_settings, +#endif .get_regs_len = kni_get_regs_len, .get_regs = kni_get_regs, .get_wol = kni_get_wol, diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h index 025ec1c9..208d34bf 100644 --- a/lib/librte_eal/linuxapp/kni/kni_fifo.h +++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h @@ -27,6 +27,14 @@ #include <exec-env/rte_kni_common.h> +/* Skip some memory barriers on Linux < 3.14 */ +#ifndef smp_load_acquire +#define smp_load_acquire(a) (*(a)) +#endif +#ifndef smp_store_release +#define smp_store_release(a, b) *(a) = (b) +#endif + /** * Adds num elements into the fifo. Return the number actually written */ @@ -35,7 +43,7 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, uint32_t num) { uint32_t i = 0; uint32_t fifo_write = fifo->write; - uint32_t fifo_read = fifo->read; + uint32_t fifo_read = smp_load_acquire(&fifo->read); uint32_t new_write = fifo_write; for (i = 0; i < num; i++) { @@ -46,7 +54,7 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, uint32_t num) fifo->buffer[fifo_write] = data[i]; fifo_write = new_write; } - fifo->write = fifo_write; + smp_store_release(&fifo->write, fifo_write); return i; } @@ -59,7 +67,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num) { uint32_t i = 0; uint32_t new_read = fifo->read; - uint32_t fifo_write = fifo->write; + uint32_t fifo_write = smp_load_acquire(&fifo->write); for (i = 0; i < num; i++) { if (new_read == fifo_write) @@ -68,7 +76,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num) data[i] = fifo->buffer[new_read]; new_read = (new_read + 1) & (fifo->len - 1); } - fifo->read = new_read; + smp_store_release(&fifo->read, new_read); return i; } @@ -79,7 +87,9 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num) static inline uint32_t kni_fifo_count(struct rte_kni_fifo *fifo) { - return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1); + uint32_t fifo_write = smp_load_acquire(&fifo->write); + uint32_t fifo_read = smp_load_acquire(&fifo->read); + return (fifo->len + fifo_write - fifo_read) & (fifo->len - 1); } /** @@ -88,7 +98,9 @@ kni_fifo_count(struct rte_kni_fifo *fifo) static inline uint32_t kni_fifo_free_count(struct rte_kni_fifo *fifo) { - return (fifo->read - fifo->write - 1) & (fifo->len - 1); + uint32_t fifo_write = smp_load_acquire(&fifo->write); + uint32_t fifo_read = smp_load_acquire(&fifo->read); + return (fifo_read - fifo_write - 1) & (fifo->len - 1); } #ifdef RTE_KNI_VHOST |