diff --git a/0001-add-igb-uio.patch b/0001-add-igb-uio.patch new file mode 100644 index 0000000..3e31860 --- /dev/null +++ b/0001-add-igb-uio.patch @@ -0,0 +1,927 @@ +From b46793510b200c4120f03963252f7f54d23f6f8b Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Sat, 18 Dec 2021 19:07:58 +0800 +Subject: [PATCH] add igb_uio + +--- + kernel/linux/igb_uio/Kbuild | 2 + + kernel/linux/igb_uio/compat.h | 154 +++++++ + kernel/linux/igb_uio/igb_uio.c | 674 +++++++++++++++++++++++++++++++ + kernel/linux/igb_uio/meson.build | 27 ++ + kernel/linux/meson.build | 2 +- + meson_options.txt | 2 +- + 6 files changed, 859 insertions(+), 2 deletions(-) + create mode 100644 kernel/linux/igb_uio/Kbuild + create mode 100644 kernel/linux/igb_uio/compat.h + create mode 100644 kernel/linux/igb_uio/igb_uio.c + create mode 100644 kernel/linux/igb_uio/meson.build + +diff --git a/kernel/linux/igb_uio/Kbuild b/kernel/linux/igb_uio/Kbuild +new file mode 100644 +index 0000000000..3ab85c4116 +--- /dev/null ++++ b/kernel/linux/igb_uio/Kbuild +@@ -0,0 +1,2 @@ ++ccflags-y := $(MODULE_CFLAGS) ++obj-m := igb_uio.o +diff --git a/kernel/linux/igb_uio/compat.h b/kernel/linux/igb_uio/compat.h +new file mode 100644 +index 0000000000..8dbb896ae1 +--- /dev/null ++++ b/kernel/linux/igb_uio/compat.h +@@ -0,0 +1,154 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * Minimal wrappers to allow compiling igb_uio on older kernels. ++ */ ++ ++#ifndef RHEL_RELEASE_VERSION ++#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b)) ++#endif ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) ++#define pci_cfg_access_lock pci_block_user_cfg_access ++#define pci_cfg_access_unlock pci_unblock_user_cfg_access ++#endif ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) ++#define HAVE_PTE_MASK_PAGE_IOMAP ++#endif ++ ++#ifndef PCI_MSIX_ENTRY_SIZE ++#define PCI_MSIX_ENTRY_SIZE 16 ++#define PCI_MSIX_ENTRY_VECTOR_CTRL 12 ++#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1 ++#endif ++ ++/* ++ * for kernels < 2.6.38 and backported patch that moves MSI-X entry definition ++ * to pci_regs.h Those kernels has PCI_MSIX_ENTRY_SIZE defined but not ++ * PCI_MSIX_ENTRY_CTRL_MASKBIT ++ */ ++#ifndef PCI_MSIX_ENTRY_CTRL_MASKBIT ++#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1 ++#endif ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \ ++ (!(defined(RHEL_RELEASE_CODE) && \ ++ RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5, 9))) ++ ++static int pci_num_vf(struct pci_dev *dev) ++{ ++ struct iov { ++ int pos; ++ int nres; ++ u32 cap; ++ u16 ctrl; ++ u16 total; ++ u16 initial; ++ u16 nr_virtfn; ++ } *iov = (struct iov *)dev->sriov; ++ ++ if (!dev->is_physfn) ++ return 0; ++ ++ return iov->nr_virtfn; ++} ++ ++#endif /* < 2.6.34 */ ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \ ++ (!(defined(RHEL_RELEASE_CODE) && \ ++ RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4))) ++ ++#define kstrtoul strict_strtoul ++ ++#endif /* < 2.6.39 */ ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) && \ ++ (!(defined(RHEL_RELEASE_CODE) && \ ++ RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 3))) ++ ++/* Check if INTX works to control irq's. ++ * Set's INTX_DISABLE flag and reads it back ++ */ ++static bool pci_intx_mask_supported(struct pci_dev *pdev) ++{ ++ bool mask_supported = false; ++ uint16_t orig, new; ++ ++ pci_block_user_cfg_access(pdev); ++ pci_read_config_word(pdev, PCI_COMMAND, &orig); ++ pci_write_config_word(pdev, PCI_COMMAND, ++ orig ^ PCI_COMMAND_INTX_DISABLE); ++ pci_read_config_word(pdev, PCI_COMMAND, &new); ++ ++ if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) { ++ dev_err(&pdev->dev, "Command register changed from " ++ "0x%x to 0x%x: driver or hardware bug?\n", orig, new); ++ } else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) { ++ mask_supported = true; ++ pci_write_config_word(pdev, PCI_COMMAND, orig); ++ } ++ pci_unblock_user_cfg_access(pdev); ++ ++ return mask_supported; ++} ++ ++static bool pci_check_and_mask_intx(struct pci_dev *pdev) ++{ ++ bool pending; ++ uint32_t status; ++ ++ pci_block_user_cfg_access(pdev); ++ pci_read_config_dword(pdev, PCI_COMMAND, &status); ++ ++ /* interrupt is not ours, goes to out */ ++ pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0); ++ if (pending) { ++ uint16_t old, new; ++ ++ old = status; ++ if (status != 0) ++ new = old & (~PCI_COMMAND_INTX_DISABLE); ++ else ++ new = old | PCI_COMMAND_INTX_DISABLE; ++ ++ if (old != new) ++ pci_write_config_word(pdev, PCI_COMMAND, new); ++ } ++ pci_unblock_user_cfg_access(pdev); ++ ++ return pending; ++} ++ ++#endif /* < 3.3.0 */ ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) ++#define HAVE_PCI_IS_BRIDGE_API 1 ++#endif ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) ++#define HAVE_MSI_LIST_IN_GENERIC_DEVICE 1 ++#endif ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ++#define HAVE_PCI_MSI_MASK_IRQ 1 ++#endif ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) ++#define HAVE_ALLOC_IRQ_VECTORS 1 ++#endif ++ ++static inline bool igbuio_kernel_is_locked_down(void) ++{ ++#ifdef CONFIG_LOCK_DOWN_KERNEL ++#ifdef CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT ++ return kernel_is_locked_down(NULL); ++#elif defined(CONFIG_EFI_SECURE_BOOT_LOCK_DOWN) ++ return kernel_is_locked_down(); ++#else ++ return false; ++#endif ++#else ++ return false; ++#endif ++} +diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c +new file mode 100644 +index 0000000000..ea439d131d +--- /dev/null ++++ b/kernel/linux/igb_uio/igb_uio.c +@@ -0,0 +1,674 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/*- ++ * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. ++ */ ++ ++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/** ++ * These enum and macro definitions are copied from the ++ * file rte_pci_dev_features.h ++ */ ++enum rte_intr_mode { ++ RTE_INTR_MODE_NONE = 0, ++ RTE_INTR_MODE_LEGACY, ++ RTE_INTR_MODE_MSI, ++ RTE_INTR_MODE_MSIX ++}; ++#define RTE_INTR_MODE_NONE_NAME "none" ++#define RTE_INTR_MODE_LEGACY_NAME "legacy" ++#define RTE_INTR_MODE_MSI_NAME "msi" ++#define RTE_INTR_MODE_MSIX_NAME "msix" ++ ++ ++#include "compat.h" ++ ++/** ++ * A structure describing the private information for a uio device. ++ */ ++struct rte_uio_pci_dev { ++ struct uio_info info; ++ struct pci_dev *pdev; ++ enum rte_intr_mode mode; ++ atomic_t refcnt; ++}; ++ ++static int wc_activate; ++static char *intr_mode; ++static enum rte_intr_mode igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; ++/* sriov sysfs */ ++static ssize_t ++show_max_vfs(struct device *dev, struct device_attribute *attr, ++ char *buf) ++{ ++ return snprintf(buf, 10, "%u\n", dev_num_vf(dev)); ++} ++ ++static ssize_t ++store_max_vfs(struct device *dev, struct device_attribute *attr, ++ const char *buf, size_t count) ++{ ++ int err = 0; ++ unsigned long max_vfs; ++ struct pci_dev *pdev = to_pci_dev(dev); ++ ++ if (0 != kstrtoul(buf, 0, &max_vfs)) ++ return -EINVAL; ++ ++ if (0 == max_vfs) ++ pci_disable_sriov(pdev); ++ else if (0 == pci_num_vf(pdev)) ++ err = pci_enable_sriov(pdev, max_vfs); ++ else /* do nothing if change max_vfs number */ ++ err = -EINVAL; ++ ++ return err ? err : count; ++} ++ ++static DEVICE_ATTR(max_vfs, S_IRUGO | S_IWUSR, show_max_vfs, store_max_vfs); ++ ++static struct attribute *dev_attrs[] = { ++ &dev_attr_max_vfs.attr, ++ NULL, ++}; ++ ++static const struct attribute_group dev_attr_grp = { ++ .attrs = dev_attrs, ++}; ++ ++#ifndef HAVE_PCI_MSI_MASK_IRQ ++/* ++ * It masks the msix on/off of generating MSI-X messages. ++ */ ++static void ++igbuio_msix_mask_irq(struct msi_desc *desc, s32 state) ++{ ++ u32 mask_bits = desc->masked; ++ unsigned int offset = desc->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + ++ PCI_MSIX_ENTRY_VECTOR_CTRL; ++ ++ if (state != 0) ++ mask_bits &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT; ++ else ++ mask_bits |= PCI_MSIX_ENTRY_CTRL_MASKBIT; ++ ++ if (mask_bits != desc->masked) { ++ writel(mask_bits, desc->mask_base + offset); ++ readl(desc->mask_base); ++ desc->masked = mask_bits; ++ } ++} ++ ++/* ++ * It masks the msi on/off of generating MSI messages. ++ */ ++static void ++igbuio_msi_mask_irq(struct pci_dev *pdev, struct msi_desc *desc, int32_t state) ++{ ++ u32 mask_bits = desc->masked; ++ u32 offset = desc->irq - pdev->irq; ++ u32 mask = 1 << offset; ++ ++ if (!desc->msi_attrib.maskbit) ++ return; ++ ++ if (state != 0) ++ mask_bits &= ~mask; ++ else ++ mask_bits |= mask; ++ ++ if (mask_bits != desc->masked) { ++ pci_write_config_dword(pdev, desc->mask_pos, mask_bits); ++ desc->masked = mask_bits; ++ } ++} ++ ++static void ++igbuio_mask_irq(struct pci_dev *pdev, enum rte_intr_mode mode, s32 irq_state) ++{ ++ struct msi_desc *desc; ++ struct list_head *msi_list; ++ ++#ifdef HAVE_MSI_LIST_IN_GENERIC_DEVICE ++ msi_list = &pdev->dev.msi_list; ++#else ++ msi_list = &pdev->msi_list; ++#endif ++ ++ if (mode == RTE_INTR_MODE_MSIX) { ++ list_for_each_entry(desc, msi_list, list) ++ igbuio_msix_mask_irq(desc, irq_state); ++ } else if (mode == RTE_INTR_MODE_MSI) { ++ list_for_each_entry(desc, msi_list, list) ++ igbuio_msi_mask_irq(pdev, desc, irq_state); ++ } ++} ++#endif ++ ++/** ++ * This is the irqcontrol callback to be registered to uio_info. ++ * It can be used to disable/enable interrupt from user space processes. ++ * ++ * @param info ++ * pointer to uio_info. ++ * @param irq_state ++ * state value. 1 to enable interrupt, 0 to disable interrupt. ++ * ++ * @return ++ * - On success, 0. ++ * - On failure, a negative value. ++ */ ++static int ++igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) ++{ ++ struct rte_uio_pci_dev *udev = info->priv; ++ struct pci_dev *pdev = udev->pdev; ++ ++#ifdef HAVE_PCI_MSI_MASK_IRQ ++ struct irq_data *irq = irq_get_irq_data(udev->info.irq); ++#endif ++ ++ pci_cfg_access_lock(pdev); ++ ++ if (udev->mode == RTE_INTR_MODE_MSIX || udev->mode == RTE_INTR_MODE_MSI) { ++#ifdef HAVE_PCI_MSI_MASK_IRQ ++ if (irq_state == 1) ++ pci_msi_unmask_irq(irq); ++ else ++ pci_msi_mask_irq(irq); ++#else ++ igbuio_mask_irq(pdev, udev->mode, irq_state); ++#endif ++ } ++ ++ if (udev->mode == RTE_INTR_MODE_LEGACY) ++ pci_intx(pdev, !!irq_state); ++ ++ pci_cfg_access_unlock(pdev); ++ ++ return 0; ++} ++ ++/** ++ * This is interrupt handler which will check if the interrupt is for the right device. ++ * If yes, disable it here and will be enable later. ++ */ ++static irqreturn_t ++igbuio_pci_irqhandler(int irq, void *dev_id) ++{ ++ struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id; ++ struct uio_info *info = &udev->info; ++ ++ /* Legacy mode need to mask in hardware */ ++ if (udev->mode == RTE_INTR_MODE_LEGACY && ++ !pci_check_and_mask_intx(udev->pdev)) ++ return IRQ_NONE; ++ ++ uio_event_notify(info); ++ ++ /* Message signal mode, no share IRQ and automasked */ ++ return IRQ_HANDLED; ++} ++ ++static int ++igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) ++{ ++ int err = 0; ++#ifndef HAVE_ALLOC_IRQ_VECTORS ++ struct msix_entry msix_entry; ++#endif ++ ++ switch (igbuio_intr_mode_preferred) { ++ case RTE_INTR_MODE_MSIX: ++ /* Only 1 msi-x vector needed */ ++#ifndef HAVE_ALLOC_IRQ_VECTORS ++ msix_entry.entry = 0; ++ if (pci_enable_msix(udev->pdev, &msix_entry, 1) == 0) { ++ dev_dbg(&udev->pdev->dev, "using MSI-X"); ++ udev->info.irq_flags = IRQF_NO_THREAD; ++ udev->info.irq = msix_entry.vector; ++ udev->mode = RTE_INTR_MODE_MSIX; ++ break; ++ } ++#else ++ if (pci_alloc_irq_vectors(udev->pdev, 1, 1, PCI_IRQ_MSIX) == 1) { ++ dev_dbg(&udev->pdev->dev, "using MSI-X"); ++ udev->info.irq_flags = IRQF_NO_THREAD; ++ udev->info.irq = pci_irq_vector(udev->pdev, 0); ++ udev->mode = RTE_INTR_MODE_MSIX; ++ break; ++ } ++#endif ++ ++ /* falls through - to MSI */ ++ case RTE_INTR_MODE_MSI: ++#ifndef HAVE_ALLOC_IRQ_VECTORS ++ if (pci_enable_msi(udev->pdev) == 0) { ++ dev_dbg(&udev->pdev->dev, "using MSI"); ++ udev->info.irq_flags = IRQF_NO_THREAD; ++ udev->info.irq = udev->pdev->irq; ++ udev->mode = RTE_INTR_MODE_MSI; ++ break; ++ } ++#else ++ if (pci_alloc_irq_vectors(udev->pdev, 1, 1, PCI_IRQ_MSI) == 1) { ++ dev_dbg(&udev->pdev->dev, "using MSI"); ++ udev->info.irq_flags = IRQF_NO_THREAD; ++ udev->info.irq = pci_irq_vector(udev->pdev, 0); ++ udev->mode = RTE_INTR_MODE_MSI; ++ break; ++ } ++#endif ++ /* falls through - to INTX */ ++ case RTE_INTR_MODE_LEGACY: ++ if (pci_intx_mask_supported(udev->pdev)) { ++ dev_dbg(&udev->pdev->dev, "using INTX"); ++ udev->info.irq_flags = IRQF_SHARED | IRQF_NO_THREAD; ++ udev->info.irq = udev->pdev->irq; ++ udev->mode = RTE_INTR_MODE_LEGACY; ++ break; ++ } ++ dev_notice(&udev->pdev->dev, "PCI INTX mask not supported\n"); ++ /* falls through - to no IRQ */ ++ case RTE_INTR_MODE_NONE: ++ udev->mode = RTE_INTR_MODE_NONE; ++ udev->info.irq = UIO_IRQ_NONE; ++ break; ++ ++ default: ++ dev_err(&udev->pdev->dev, "invalid IRQ mode %u", ++ igbuio_intr_mode_preferred); ++ udev->info.irq = UIO_IRQ_NONE; ++ err = -EINVAL; ++ } ++ ++ if (udev->info.irq != UIO_IRQ_NONE) ++ err = request_irq(udev->info.irq, igbuio_pci_irqhandler, ++ udev->info.irq_flags, udev->info.name, ++ udev); ++ dev_info(&udev->pdev->dev, "uio device registered with irq %ld\n", ++ udev->info.irq); ++ ++ return err; ++} ++ ++static void ++igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev) ++{ ++ if (udev->info.irq) { ++ free_irq(udev->info.irq, udev); ++ udev->info.irq = 0; ++ } ++ ++#ifndef HAVE_ALLOC_IRQ_VECTORS ++ if (udev->mode == RTE_INTR_MODE_MSIX) ++ pci_disable_msix(udev->pdev); ++ if (udev->mode == RTE_INTR_MODE_MSI) ++ pci_disable_msi(udev->pdev); ++#else ++ if (udev->mode == RTE_INTR_MODE_MSIX || ++ udev->mode == RTE_INTR_MODE_MSI) ++ pci_free_irq_vectors(udev->pdev); ++#endif ++} ++ ++ ++/** ++ * 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; ++ int err; ++ ++ if (atomic_inc_return(&udev->refcnt) != 1) ++ return 0; ++ ++ /* set bus master, which was cleared by the reset function */ ++ pci_set_master(dev); ++ ++ /* enable interrupts */ ++ err = igbuio_pci_enable_interrupts(udev); ++ if (err) { ++ atomic_dec(&udev->refcnt); ++ dev_err(&dev->dev, "Enable interrupt fails\n"); ++ } ++ return err; ++} ++ ++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; ++ ++ if (atomic_dec_and_test(&udev->refcnt)) { ++ /* disable interrupts */ ++ igbuio_pci_disable_interrupts(udev); ++ ++ /* stop the device from further DMA */ ++ pci_clear_master(dev); ++ } ++ ++ return 0; ++} ++ ++/* Remap pci resources described by bar #pci_bar in uio resource n. */ ++static int ++igbuio_pci_setup_iomem(struct pci_dev *dev, struct uio_info *info, ++ int n, int pci_bar, const char *name) ++{ ++ unsigned long addr, len; ++ void *internal_addr; ++ ++ if (n >= ARRAY_SIZE(info->mem)) ++ return -EINVAL; ++ ++ addr = pci_resource_start(dev, pci_bar); ++ len = pci_resource_len(dev, pci_bar); ++ if (addr == 0 || len == 0) ++ return -1; ++ if (wc_activate == 0) { ++ internal_addr = ioremap(addr, len); ++ if (internal_addr == NULL) ++ return -1; ++ } else { ++ internal_addr = NULL; ++ } ++ info->mem[n].name = name; ++ info->mem[n].addr = addr; ++ info->mem[n].internal_addr = internal_addr; ++ info->mem[n].size = len; ++ info->mem[n].memtype = UIO_MEM_PHYS; ++ return 0; ++} ++ ++/* Get pci port io resources described by bar #pci_bar in uio resource n. */ ++static int ++igbuio_pci_setup_ioport(struct pci_dev *dev, struct uio_info *info, ++ int n, int pci_bar, const char *name) ++{ ++ unsigned long addr, len; ++ ++ if (n >= ARRAY_SIZE(info->port)) ++ return -EINVAL; ++ ++ addr = pci_resource_start(dev, pci_bar); ++ len = pci_resource_len(dev, pci_bar); ++ if (addr == 0 || len == 0) ++ return -EINVAL; ++ ++ info->port[n].name = name; ++ info->port[n].start = addr; ++ info->port[n].size = len; ++ info->port[n].porttype = UIO_PORT_X86; ++ ++ return 0; ++} ++ ++/* Unmap previously ioremap'd resources */ ++static void ++igbuio_pci_release_iomem(struct uio_info *info) ++{ ++ int i; ++ ++ for (i = 0; i < MAX_UIO_MAPS; i++) { ++ if (info->mem[i].internal_addr) ++ iounmap(info->mem[i].internal_addr); ++ } ++} ++ ++static int ++igbuio_setup_bars(struct pci_dev *dev, struct uio_info *info) ++{ ++ int i, iom, iop, ret; ++ unsigned long flags; ++ static const char *bar_names[PCI_STD_RESOURCE_END + 1] = { ++ "BAR0", ++ "BAR1", ++ "BAR2", ++ "BAR3", ++ "BAR4", ++ "BAR5", ++ }; ++ ++ iom = 0; ++ iop = 0; ++ ++ for (i = 0; i < ARRAY_SIZE(bar_names); i++) { ++ if (pci_resource_len(dev, i) != 0 && ++ pci_resource_start(dev, i) != 0) { ++ flags = pci_resource_flags(dev, i); ++ if (flags & IORESOURCE_MEM) { ++ ret = igbuio_pci_setup_iomem(dev, info, iom, ++ i, bar_names[i]); ++ if (ret != 0) ++ return ret; ++ iom++; ++ } else if (flags & IORESOURCE_IO) { ++ ret = igbuio_pci_setup_ioport(dev, info, iop, ++ i, bar_names[i]); ++ if (ret != 0) ++ return ret; ++ iop++; ++ } ++ } ++ } ++ ++ return (iom != 0 || iop != 0) ? ret : -ENOENT; ++} ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0) ++static int __devinit ++#else ++static int ++#endif ++igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) ++{ ++ struct rte_uio_pci_dev *udev; ++ dma_addr_t map_dma_addr; ++ void *map_addr; ++ int err; ++ ++#ifdef HAVE_PCI_IS_BRIDGE_API ++ if (pci_is_bridge(dev)) { ++ dev_warn(&dev->dev, "Ignoring PCI bridge device\n"); ++ return -ENODEV; ++ } ++#endif ++ ++ udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL); ++ if (!udev) ++ return -ENOMEM; ++ ++ /* ++ * enable device: ask low-level code to enable I/O and ++ * memory ++ */ ++ err = pci_enable_device(dev); ++ if (err != 0) { ++ dev_err(&dev->dev, "Cannot enable PCI device\n"); ++ goto fail_free; ++ } ++ ++ /* enable bus mastering on the device */ ++ pci_set_master(dev); ++ ++ /* remap IO memory */ ++ err = igbuio_setup_bars(dev, &udev->info); ++ if (err != 0) ++ goto fail_release_iomem; ++ ++ /* set 64-bit DMA mask */ ++ err = pci_set_dma_mask(dev, DMA_BIT_MASK(64)); ++ if (err != 0) { ++ dev_err(&dev->dev, "Cannot set DMA mask\n"); ++ goto fail_release_iomem; ++ } ++ ++ err = pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(64)); ++ if (err != 0) { ++ dev_err(&dev->dev, "Cannot set consistent DMA mask\n"); ++ goto fail_release_iomem; ++ } ++ ++ /* fill uio infos */ ++ udev->info.name = "igb_uio"; ++ udev->info.version = "0.1"; ++ udev->info.irqcontrol = igbuio_pci_irqcontrol; ++ udev->info.open = igbuio_pci_open; ++ udev->info.release = igbuio_pci_release; ++ udev->info.priv = udev; ++ udev->pdev = dev; ++ atomic_set(&udev->refcnt, 0); ++ ++ err = sysfs_create_group(&dev->dev.kobj, &dev_attr_grp); ++ if (err != 0) ++ goto fail_release_iomem; ++ ++ /* register uio driver */ ++ err = uio_register_device(&dev->dev, &udev->info); ++ if (err != 0) ++ goto fail_remove_group; ++ ++ pci_set_drvdata(dev, udev); ++ ++ /* ++ * Doing a harmless dma mapping for attaching the device to ++ * the iommu identity mapping if kernel boots with iommu=pt. ++ * Note this is not a problem if no IOMMU at all. ++ */ ++ map_addr = dma_alloc_coherent(&dev->dev, 1024, &map_dma_addr, ++ GFP_KERNEL); ++ if (map_addr) ++ memset(map_addr, 0, 1024); ++ ++ if (!map_addr) ++ dev_info(&dev->dev, "dma mapping failed\n"); ++ else { ++ dev_info(&dev->dev, "mapping 1K dma=%#llx host=%p\n", ++ (unsigned long long)map_dma_addr, map_addr); ++ ++ dma_free_coherent(&dev->dev, 1024, map_addr, map_dma_addr); ++ dev_info(&dev->dev, "unmapping 1K dma=%#llx host=%p\n", ++ (unsigned long long)map_dma_addr, map_addr); ++ } ++ ++ return 0; ++ ++fail_remove_group: ++ sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); ++fail_release_iomem: ++ igbuio_pci_release_iomem(&udev->info); ++ pci_disable_device(dev); ++fail_free: ++ kfree(udev); ++ ++ return err; ++} ++ ++static void ++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); ++ pci_disable_device(dev); ++ pci_set_drvdata(dev, NULL); ++ kfree(udev); ++} ++ ++static int ++igbuio_config_intr_mode(char *intr_str) ++{ ++ if (!intr_str) { ++ pr_info("Use MSIX interrupt by default\n"); ++ return 0; ++ } ++ ++ if (!strcmp(intr_str, RTE_INTR_MODE_MSIX_NAME)) { ++ igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; ++ pr_info("Use MSIX interrupt\n"); ++ } else if (!strcmp(intr_str, RTE_INTR_MODE_MSI_NAME)) { ++ igbuio_intr_mode_preferred = RTE_INTR_MODE_MSI; ++ pr_info("Use MSI interrupt\n"); ++ } else if (!strcmp(intr_str, RTE_INTR_MODE_LEGACY_NAME)) { ++ igbuio_intr_mode_preferred = RTE_INTR_MODE_LEGACY; ++ pr_info("Use legacy interrupt\n"); ++ } else { ++ pr_info("Error: bad parameter - %s\n", intr_str); ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static struct pci_driver igbuio_pci_driver = { ++ .name = "igb_uio", ++ .id_table = NULL, ++ .probe = igbuio_pci_probe, ++ .remove = igbuio_pci_remove, ++}; ++ ++static int __init ++igbuio_pci_init_module(void) ++{ ++ int ret; ++ ++ if (igbuio_kernel_is_locked_down()) { ++ pr_err("Not able to use module, kernel lock down is enabled\n"); ++ return -EINVAL; ++ } ++ ++ if (wc_activate != 0) ++ pr_info("wc_activate is set\n"); ++ ++ ret = igbuio_config_intr_mode(intr_mode); ++ if (ret < 0) ++ return ret; ++ ++ return pci_register_driver(&igbuio_pci_driver); ++} ++ ++static void __exit ++igbuio_pci_exit_module(void) ++{ ++ pci_unregister_driver(&igbuio_pci_driver); ++} ++ ++module_init(igbuio_pci_init_module); ++module_exit(igbuio_pci_exit_module); ++ ++module_param(intr_mode, charp, S_IRUGO); ++MODULE_PARM_DESC(intr_mode, ++"igb_uio interrupt mode (default=msix):\n" ++" " RTE_INTR_MODE_MSIX_NAME " Use MSIX interrupt\n" ++" " RTE_INTR_MODE_MSI_NAME " Use MSI interrupt\n" ++" " RTE_INTR_MODE_LEGACY_NAME " Use Legacy interrupt\n" ++"\n"); ++ ++module_param(wc_activate, int, 0); ++MODULE_PARM_DESC(wc_activate, ++"Activate support for write combining (WC) (default=0)\n" ++" 0 - disable\n" ++" other - enable\n"); ++ ++MODULE_DESCRIPTION("UIO driver for Intel IGB PCI cards"); ++MODULE_LICENSE("GPL"); ++MODULE_AUTHOR("Intel Corporation"); +diff --git a/kernel/linux/igb_uio/meson.build b/kernel/linux/igb_uio/meson.build +new file mode 100644 +index 0000000000..ff8f97ca23 +--- /dev/null ++++ b/kernel/linux/igb_uio/meson.build +@@ -0,0 +1,27 @@ ++# SPDX-License-Identifier: BSD-3-Clause ++# Copyright(c) 2018 Luca Boccassi ++ ++# For SUSE build check function arguments of ndo_tx_timeout API ++# Ref: https://jira.devtools.intel.com/browse/DPDK-29263 ++kmod_cflags = '' ++ ++igb_uio_mkfile = custom_target('igb_uio_makefile', ++ output: 'Makefile', ++ command: ['touch', '@OUTPUT@']) ++ ++igb_uio_sources = files( ++ 'igb_uio.c', ++ 'Kbuild', ++) ++ ++custom_target('igb_uio', ++ input: igb_uio_sources, ++ output: 'igb_uio.ko', ++ command: ['make', '-j4', '-C', kernel_build_dir, ++ 'M=' + meson.current_build_dir(), ++ 'src=' + meson.current_source_dir(), ++ 'modules'] + cross_args, ++ depends: igb_uio_mkfile, ++ install: install, ++ install_dir: kernel_install_dir, ++ build_by_default: get_option('enable_kmods')) +diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build +index 0637452e95..3230368f14 100644 +--- a/kernel/linux/meson.build ++++ b/kernel/linux/meson.build +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: BSD-3-Clause + # Copyright(c) 2018 Intel Corporation + +-subdirs = ['kni'] ++subdirs = ['kni', 'igb_uio'] + + kernel_build_dir = get_option('kernel_dir') + kernel_source_dir = get_option('kernel_dir') +diff --git a/meson_options.txt b/meson_options.txt +index 7c220ad68d..d2e172facd 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -18,7 +18,7 @@ option('enable_drivers', type: 'string', value: '', description: + 'Comma-separated list of drivers to build. If unspecified, build all drivers.') + option('enable_driver_sdk', type: 'boolean', value: false, description: + 'Install headers to build drivers.') +-option('enable_kmods', type: 'boolean', value: false, description: ++option('enable_kmods', type: 'boolean', value: true, description: + 'build kernel modules') + option('examples', type: 'string', value: '', description: + 'Comma-separated list of examples to build by default') +-- +2.27.0 diff --git a/0001-dpdk-add-secure-compile-option-and-fPIC-option.patch b/0001-dpdk-add-secure-compile-option-and-fPIC-option.patch deleted file mode 100644 index 0ac0273..0000000 --- a/0001-dpdk-add-secure-compile-option-and-fPIC-option.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 62729b425f3b3a9ccb53b7a57f3dcc0db76d039e Mon Sep 17 00:00:00 2001 -From: zhuhengbo -Date: Thu, 19 Mar 2020 17:10:51 +0800 -Subject: [PATCH] dpdk: - add-secure-compile-option-and-compile-with-fPIC-for-static-lib - -Signed-off-by: zhuhengbo ---- - lib/librte_eal/common/include/rte_log.h | 1 + - mk/rte.lib.mk | 1 + - mk/target/generic/rte.vars.mk | 2 ++ - 3 files changed, 4 insertions(+) - -diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h -index 1bb0e66..6426ea2 100644 ---- a/lib/librte_eal/common/include/rte_log.h -+++ b/lib/librte_eal/common/include/rte_log.h -@@ -311,6 +311,7 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...) - * - Negative on error. - */ - int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) -+ __attribute__((weak)) - __attribute__((format(printf,3,0))); - - /** -diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk -index 655a1b1..4516d1c 100644 ---- a/mk/rte.lib.mk -+++ b/mk/rte.lib.mk -@@ -6,6 +6,7 @@ include $(RTE_SDK)/mk/internal/rte.install-pre.mk - include $(RTE_SDK)/mk/internal/rte.clean-pre.mk - include $(RTE_SDK)/mk/internal/rte.build-pre.mk - -+CFLAGS += -fPIC - EXTLIB_BUILD ?= n - - # VPATH contains at least SRCDIR -diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk -index 3747221..bf3f4ff 100644 ---- a/mk/target/generic/rte.vars.mk -+++ b/mk/target/generic/rte.vars.mk -@@ -75,6 +75,8 @@ ifeq ($(KERNELRELEASE),) - include $(RTE_SDK)/mk/rte.cpuflags.mk - - # merge all CFLAGS -+CPU_CFLAGS += -fPIE -pie -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -Wall -+CPU_CFLAGS += -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines - CFLAGS := $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS) - CFLAGS += $(TARGET_CFLAGS) - --- -2.19.1 - diff --git a/0001-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch b/0001-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch deleted file mode 100644 index 8db887c..0000000 --- a/0001-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 28be6f7f94f85dd15e1807abb6d14a1164b4396d Mon Sep 17 00:00:00 2001 -From: jiangheng12 -Date: Sat, 17 Jun 2023 20:29:39 +0800 -Subject: [PATCH] pdump: fix pcap_dump coredump caused by incorrect pkt_len - ---- - drivers/net/pcap/rte_eth_pcap.c | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c -index aa7ef6f..18b2f30 100644 ---- a/drivers/net/pcap/rte_eth_pcap.c -+++ b/drivers/net/pcap/rte_eth_pcap.c -@@ -342,8 +342,13 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) - * in the mbuf (when the mbuf is contiguous) or, otherwise, - * a pointer to temp_data after copying into it. - */ -- pcap_dump((u_char *)dumper, &header, -- rte_pktmbuf_read(mbuf, 0, len, temp_data)); -+ const void *sp = rte_pktmbuf_read(mbuf, 0, len, temp_data); -+ if (sp == NULL) { -+ rte_pktmbuf_free(mbuf); -+ continue; -+ } else { -+ pcap_dump((u_char *)dumper, &header, sp); -+ } - - num_tx++; - tx_bytes += len; --- -2.23.0 - diff --git a/0002-dpdk-add-secure-compile-option-and-fPIC-option.patch b/0002-dpdk-add-secure-compile-option-and-fPIC-option.patch new file mode 100644 index 0000000..4afcad1 --- /dev/null +++ b/0002-dpdk-add-secure-compile-option-and-fPIC-option.patch @@ -0,0 +1,81 @@ +From a655c865fce412d7e661d866bde0df30607fb6a4 Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Thu, 16 Dec 2021 20:35:09 +0800 +Subject: [PATCH] huawei-0001-dpdk-add-secure-compile-option-and-fPIC + +--- + app/meson.build | 2 ++ + buildtools/chkincs/meson.build | 2 ++ + drivers/meson.build | 2 ++ + examples/meson.build | 2 ++ + lib/meson.build | 2 ++ + 5 files changed, 10 insertions(+) + +diff --git a/app/meson.build b/app/meson.build +index 93d8c15032..68be53c92d 100644 +--- a/app/meson.build ++++ b/app/meson.build +@@ -21,6 +21,8 @@ apps = [ + ] + + default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API'] ++default_cflags += ['-fPIE', '-pie', '-fPIC', '-fstack-protector-strong', '-D_FORTIFY_SOURCE=2', '-O2', '-Wall', '-Werror'] ++default_cflags += ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wtrampolines'] + default_ldflags = [] + if get_option('default_library') == 'static' and not is_windows + default_ldflags += ['-Wl,--export-dynamic'] +diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.build +index 5ffca89761..e3d13a691c 100644 +--- a/buildtools/chkincs/meson.build ++++ b/buildtools/chkincs/meson.build +@@ -13,6 +13,8 @@ gen_c_files = generator(gen_c_file_for_header, + + cflags = machine_args + cflags += '-DALLOW_EXPERIMENTAL_API' ++cflags += ['-fPIE', '-pie', '-fPIC', '-fstack-protector-strong', '-D_FORTIFY_SOURCE=2', '-O2', '-Wall', '-Werror'] ++cflags += ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wtrampolines'] + + sources = files('main.c') + sources += gen_c_files.process(dpdk_chkinc_headers) +diff --git a/drivers/meson.build b/drivers/meson.build +index d5f4e1c1f2..9e71057afb 100644 +--- a/drivers/meson.build ++++ b/drivers/meson.build +@@ -45,6 +45,8 @@ enable_drivers += always_enable + default_cflags = machine_args + default_cflags += ['-DALLOW_EXPERIMENTAL_API'] + default_cflags += ['-DALLOW_INTERNAL_API'] ++default_cflags += ['-fPIE', '-pie', '-fPIC', '-fstack-protector-strong', '-D_FORTIFY_SOURCE=2', '-O2', '-Wall', '-Werror'] ++default_cflags += ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wtrampolines'] + + if cc.has_argument('-Wno-format-truncation') + default_cflags += '-Wno-format-truncation' +diff --git a/examples/meson.build b/examples/meson.build +index bac9b76007..db8603542f 100644 +--- a/examples/meson.build ++++ b/examples/meson.build +@@ -90,6 +90,8 @@ default_ldflags = dpdk_extra_ldflags + if get_option('default_library') == 'static' and not is_windows + default_ldflags += ['-Wl,--export-dynamic'] + endif ++default_cflags += ['-fPIE', '-pie', '-fPIC', '-fstack-protector-strong', '-D_FORTIFY_SOURCE=2', '-O2', '-Wall', '-Werror'] ++default_cflags += ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wtrampolines'] + + foreach example: examples + name = example.split('/')[-1] +diff --git a/lib/meson.build b/lib/meson.build +index 018976df17..668050dcc7 100644 +--- a/lib/meson.build ++++ b/lib/meson.build +@@ -94,6 +94,8 @@ endforeach + default_cflags = machine_args + default_cflags += ['-DALLOW_EXPERIMENTAL_API'] + default_cflags += ['-DALLOW_INTERNAL_API'] ++default_cflags += ['-fPIE', '-pie', '-fPIC', '-fstack-protector-strong', '-D_FORTIFY_SOURCE=2', '-O2', '-Wall', '-Werror'] ++default_cflags += ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wtrampolines'] + + if cc.has_argument('-Wno-format-truncation') + default_cflags += '-Wno-format-truncation' +-- +2.27.0 + diff --git a/0002-dpdk-add-secure-option-in-makefile.patch b/0002-dpdk-add-secure-option-in-makefile.patch deleted file mode 100644 index d1e7ad6..0000000 --- a/0002-dpdk-add-secure-option-in-makefile.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 94cc085f2890fefd1f91c38b245262c4da232e02 Mon Sep 17 00:00:00 2001 -From: zhuhengbo -Date: Thu, 19 Mar 2020 17:31:31 +0800 -Subject: [PATCH] dpdk: add secure option in makefile. - -reason: add secure option in makefile. - -Signed-off-by: zhuhengbo ---- - mk/exec-env/linux/rte.vars.mk | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/mk/exec-env/linux/rte.vars.mk b/mk/exec-env/linux/rte.vars.mk -index bea3f76..6844281 100644 ---- a/mk/exec-env/linux/rte.vars.mk -+++ b/mk/exec-env/linux/rte.vars.mk -@@ -11,10 +11,13 @@ - # - # examples for RTE_EXEC_ENV: linux, freebsd - # -+ -+SEC_FLAGS = -fstack-protector-all -Wall -Wl,-z,relro,-z,now -Wl,-z,noexecstack -Wtrampolines -fPIC -+ - ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) --EXECENV_CFLAGS = -pthread -fPIC -+EXECENV_CFLAGS = -pthread -fPIC $(SEC_FLAGS) - else --EXECENV_CFLAGS = -pthread -+EXECENV_CFLAGS = -pthread $(SEC_FLAGS) - endif - - # include in every library to build --- -2.19.1 - diff --git a/0003-dpdk-bugfix-the-deadlock-in-rte_eal_init.patch b/0003-dpdk-bugfix-the-deadlock-in-rte_eal_init.patch index a77728e..a1e831e 100644 --- a/0003-dpdk-bugfix-the-deadlock-in-rte_eal_init.patch +++ b/0003-dpdk-bugfix-the-deadlock-in-rte_eal_init.patch @@ -1,46 +1,44 @@ -From dee3ff16473b956d8cfca15baa419e5dfdf47130 Mon Sep 17 00:00:00 2001 -From: zhuhengbo -Date: Thu, 19 Mar 2020 17:14:25 +0800 -Subject: [PATCH] dpdk: bugfix the deadlock in rte_eal_init when executes this - function concurrently +From 5134068ace9870203f3e25d9f7b48281582fafbd Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Fri, 12 Nov 2021 16:17:36 +0800 +Subject: [PATCH] huawei-0003-dpdk-bugfix-the-deadlock-in-rte_eal_init -Signed-off-by: zhuhengbo --- - lib/librte_eal/linux/eal/eal.c | 14 +++++++++----- + lib/eal/linux/eal.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) -diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c -index c4233ec..a3bb9c6 100644 ---- a/lib/librte_eal/linux/eal/eal.c -+++ b/lib/librte_eal/linux/eal/eal.c -@@ -1128,7 +1128,7 @@ rte_eal_init(int argc, char **argv) +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index 60b4924838..127b7f7b53 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -1145,7 +1145,7 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("Cannot get hugepage information."); rte_errno = EACCES; - rte_atomic32_clear(&run_once); + __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED); - return -1; + goto out; } } -@@ -1152,7 +1152,7 @@ rte_eal_init(int argc, char **argv) +@@ -1169,7 +1169,7 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("Cannot init logging."); rte_errno = ENOMEM; - rte_atomic32_clear(&run_once); + __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED); - return -1; + goto out; } #ifdef VFIO_PRESENT -@@ -1160,7 +1160,7 @@ rte_eal_init(int argc, char **argv) +@@ -1177,7 +1177,7 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("Cannot init VFIO"); rte_errno = EAGAIN; - rte_atomic32_clear(&run_once); + __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED); - return -1; + goto out; } #endif /* in secondary processes, memory init may allocate additional fbarrays -@@ -1170,13 +1170,13 @@ rte_eal_init(int argc, char **argv) +@@ -1187,13 +1187,13 @@ rte_eal_init(int argc, char **argv) if (rte_eal_memzone_init() < 0) { rte_eal_init_alert("Cannot init memzone"); rte_errno = ENODEV; @@ -56,8 +54,8 @@ index c4233ec..a3bb9c6 100644 } /* the directories are locked during eal_hugepage_info_init */ -@@ -1297,6 +1297,10 @@ rte_eal_init(int argc, char **argv) - rte_option_init(); +@@ -1332,6 +1332,10 @@ rte_eal_init(int argc, char **argv) + eal_mcfg_complete(); return fctret; + @@ -68,5 +66,5 @@ index c4233ec..a3bb9c6 100644 static int -- -2.19.1 +2.27.0 diff --git a/0004-dpdk-master-core-donot-set-affinity-in-libstorage.patch b/0004-dpdk-master-core-donot-set-affinity-in-libstorage.patch index ce6ef10..07b72e0 100644 --- a/0004-dpdk-master-core-donot-set-affinity-in-libstorage.patch +++ b/0004-dpdk-master-core-donot-set-affinity-in-libstorage.patch @@ -1,73 +1,27 @@ -From c2d29472c3ddd1b2d66f34ae4025c9e074913eaa Mon Sep 17 00:00:00 2001 -From: zhuhengbo -Date: Thu, 19 Mar 2020 17:38:13 +0800 -Subject: [PATCH] dpdk: master core donot set affinity in libstorage +From 1d18079dea84bd368605f851738f8f14b917c98d Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Thu, 16 Dec 2021 15:33:11 +0800 +Subject: [PATCH] huawei-0004-dpdk-master-core-donot-set-affinity-in-libstorage -Signed-off-by: zhuhengbo --- - lib/librte_eal/common/eal_private.h | 6 ++++++ - lib/librte_eal/linux/eal/eal.c | 12 ++++++++++++ - lib/librte_eal/linux/eal/eal_thread.c | 2 +- - 3 files changed, 19 insertions(+), 1 deletion(-) + lib/eal/linux/eal.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) -diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h -index 8a9d493..597fd02 100644 ---- a/lib/librte_eal/common/eal_private.h -+++ b/lib/librte_eal/common/eal_private.h -@@ -444,4 +444,10 @@ rte_option_usage(void); - uint64_t - eal_get_baseaddr(void); +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index 127b7f7b53..47c2186bee 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -1219,7 +1219,9 @@ rte_eal_init(int argc, char **argv) -+/** -+ * Determine whether the master core needs to set affinity. -+ * The master thread in the LibStorage application cannot set affinity. -+ **/ -+bool -+eal_is_master_set_affinity(void); - #endif /* _EAL_PRIVATE_H_ */ -diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c -index a3bb9c6..8bb1842 100644 ---- a/lib/librte_eal/linux/eal/eal.c -+++ b/lib/librte_eal/linux/eal/eal.c -@@ -103,6 +103,13 @@ static char runtime_dir[PATH_MAX]; - - static const char *default_runtime_dir = "/var/run"; - -+static bool master_set_affinity = true; -+bool -+eal_is_master_set_affinity(void) -+{ -+ return master_set_affinity; -+} -+ - int - eal_create_runtime_dir(void) - { -@@ -985,6 +992,11 @@ rte_eal_init(int argc, char **argv) - strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid)); - thread_id = pthread_self(); + eal_check_mem_on_local_socket(); +- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t), + /* Master thread don't set affinity in LibStorage application */ -+ if (strstr(logid, "LibStorage") != NULL) { -+ master_set_affinity = false; -+ } -+ - eal_reset_internal_config(&internal_config); - - /* set log level as early as possible */ -diff --git a/lib/librte_eal/linux/eal/eal_thread.c b/lib/librte_eal/linux/eal/eal_thread.c -index 379773b..5b06108 100644 ---- a/lib/librte_eal/linux/eal/eal_thread.c -+++ b/lib/librte_eal/linux/eal/eal_thread.c -@@ -84,7 +84,7 @@ void eal_thread_init_master(unsigned lcore_id) - RTE_PER_LCORE(_lcore_id) = lcore_id; - - /* set CPU affinity */ -- if (eal_thread_set_affinity() < 0) -+ if (eal_is_master_set_affinity() && eal_thread_set_affinity() < 0) - rte_panic("cannot set affinity\n"); - } - ++ if (strstr(logid, "LibStorage") != NULL && ++ pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t), + &lcore_config[config->main_lcore].cpuset) != 0) { + rte_eal_init_alert("Cannot set affinity"); + rte_errno = EINVAL; -- -2.19.1 +2.27.0 diff --git a/0005-dpdk-change-the-log-level-in-prepare_numa.patch b/0005-dpdk-change-the-log-level-in-prepare_numa.patch index 6adec3b..0e26e8a 100644 --- a/0005-dpdk-change-the-log-level-in-prepare_numa.patch +++ b/0005-dpdk-change-the-log-level-in-prepare_numa.patch @@ -1,19 +1,16 @@ -From e970ca944126de31844a323b8e9e014ee2a9e128 Mon Sep 17 00:00:00 2001 -From: zhuhengbo -Date: Thu, 19 Mar 2020 17:44:24 +0800 -Subject: [PATCH] dpdk: change the log level in prepare_numa +From e6009977b9ecb1136489b483e312a5e3e09a5497 Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Fri, 12 Nov 2021 17:04:22 +0800 +Subject: [PATCH] huawei-0005-dpdk-change-the-log-level-in-prepare_numa -reason: prevent rushing logs - -Signed-off-by: zhuhengbo --- - lib/librte_eal/linux/eal/eal_memalloc.c | 2 +- + lib/eal/linux/eal_memalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c -index af6d0d0..cad4934 100644 ---- a/lib/librte_eal/linux/eal/eal_memalloc.c -+++ b/lib/librte_eal/linux/eal/eal_memalloc.c +diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c +index 337f2bc739..fc354f4a17 100644 +--- a/lib/eal/linux/eal_memalloc.c ++++ b/lib/eal/linux/eal_memalloc.c @@ -167,7 +167,7 @@ prepare_numa(int *oldpolicy, struct bitmask *oldmask, int socket_id) RTE_LOG(DEBUG, EAL, "Trying to obtain current memory policy.\n"); if (get_mempolicy(oldpolicy, oldmask->maskp, @@ -24,5 +21,5 @@ index af6d0d0..cad4934 100644 "Assuming MPOL_DEFAULT.\n", strerror(errno)); *oldpolicy = MPOL_DEFAULT; -- -2.19.1 +2.27.0 diff --git a/0006-dpdk-fix-dpdk-coredump-problem.patch b/0006-dpdk-fix-dpdk-coredump-problem.patch index 57815d4..6f81b85 100644 --- a/0006-dpdk-fix-dpdk-coredump-problem.patch +++ b/0006-dpdk-fix-dpdk-coredump-problem.patch @@ -1,18 +1,17 @@ -From a78efd329d52e1adf813eb1b76352c2680b75961 Mon Sep 17 00:00:00 2001 -From: zhuhengbo -Date: Thu, 19 Mar 2020 17:49:53 +0800 -Subject: [PATCH] dpdk: modification summary +From a76d953f02beecc057c96159e32e292b847b2d63 Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Fri, 12 Nov 2021 17:18:23 +0800 +Subject: [PATCH] huawei-0006-dpdk-fix-dpdk-coredump-problem -Signed-off-by: zhuhengbo --- - lib/librte_eal/linux/eal/eal_interrupts.c | 4 ++-- + lib/eal/linux/eal_interrupts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c b/lib/librte_eal/linux/eal/eal_interrupts.c -index 1955324..3d73cce 100644 ---- a/lib/librte_eal/linux/eal/eal_interrupts.c -+++ b/lib/librte_eal/linux/eal/eal_interrupts.c -@@ -1070,7 +1070,7 @@ eal_intr_thread_main(__rte_unused void *arg) +diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c +index 6e3925efd4..621e43626e 100644 +--- a/lib/eal/linux/eal_interrupts.c ++++ b/lib/eal/linux/eal_interrupts.c +@@ -1137,7 +1137,7 @@ eal_intr_thread_main(__rte_unused void *arg) */ if (epoll_ctl(pfd, EPOLL_CTL_ADD, intr_pipe.readfd, &pipe_event) < 0) { @@ -21,15 +20,15 @@ index 1955324..3d73cce 100644 intr_pipe.readfd, strerror(errno)); } numfds++; -@@ -1089,7 +1089,7 @@ eal_intr_thread_main(__rte_unused void *arg) +@@ -1159,7 +1159,7 @@ eal_intr_thread_main(__rte_unused void *arg) */ if (epoll_ctl(pfd, EPOLL_CTL_ADD, - src->intr_handle.fd, &ev) < 0){ + rte_intr_fd_get(src->intr_handle), &ev) < 0) { - rte_panic("Error adding fd %d epoll_ctl, %s\n", + RTE_LOG(ERR, EAL, "Error adding fd %d epoll_ctl, %s\n", - src->intr_handle.fd, strerror(errno)); + rte_intr_fd_get(src->intr_handle), + strerror(errno)); } - else -- -2.19.1 +2.27.0 diff --git a/0007-dpdk-add-secure-compile-option-in-pmdinfogen-Makefil.patch b/0007-dpdk-add-secure-compile-option-in-pmdinfogen-Makefil.patch deleted file mode 100644 index 0cd8210..0000000 --- a/0007-dpdk-add-secure-compile-option-in-pmdinfogen-Makefil.patch +++ /dev/null @@ -1,26 +0,0 @@ -From e7c97339d38f9d2655ca7834a99cc95b7427dd5c Mon Sep 17 00:00:00 2001 -From: zhuhengbo -Date: Thu, 19 Mar 2020 17:53:22 +0800 -Subject: [PATCH] dpdk: add secure compile option in pmdinfogen Makefile - -Signed-off-by: zhuhengbo ---- - buildtools/pmdinfogen/Makefile | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/buildtools/pmdinfogen/Makefile b/buildtools/pmdinfogen/Makefile -index a97a764..af41c74 100644 ---- a/buildtools/pmdinfogen/Makefile -+++ b/buildtools/pmdinfogen/Makefile -@@ -15,6 +15,8 @@ HOSTAPP = dpdk-pmdinfogen - SRCS-y += pmdinfogen.c - - HOST_CFLAGS += $(HOST_WERROR_FLAGS) -g -+HOST_CFLAGS += -fPIE -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror - HOST_CFLAGS += -I$(RTE_OUTPUT)/include - -+HOST_LDFLAGS += -Wl,-z,relro,-z,now -pie - include $(RTE_SDK)/mk/rte.hostapp.mk --- -2.19.1 - diff --git a/0007-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262.patch b/0007-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262.patch new file mode 100644 index 0000000..41c4f59 --- /dev/null +++ b/0007-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262.patch @@ -0,0 +1,28 @@ +From d0f302751a57cea1ee64261c749f59c4026f7af7 Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Thu, 16 Dec 2021 11:46:58 +0800 +Subject: [PATCH] + huawei-0008-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262 + +--- + config/meson.build | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/config/meson.build b/config/meson.build +index 17b5bec406..293703a90d 100644 +--- a/config/meson.build ++++ b/config/meson.build +@@ -121,6 +121,10 @@ if cpu_instruction_set == 'generic' + elif host_machine.cpu_family().startswith('ppc') + cpu_instruction_set = 'power8' + endif ++elif host_machine.cpu_family().startswith('x86') ++ if cc.get_define('__SSE4_2__', args:'-march=native') == '' ++ cpu_instruction_set = 'corei7' ++ endif + endif + + dpdk_conf.set('RTE_MACHINE', cpu_instruction_set) +-- +2.27.0 + diff --git a/0009-dpdk-add-support-gazelle.patch b/0008-dpdk-add-support-for-gazelle.patch similarity index 52% rename from 0009-dpdk-add-support-gazelle.patch rename to 0008-dpdk-add-support-for-gazelle.patch index 080d516..287b79e 100644 --- a/0009-dpdk-add-support-gazelle.patch +++ b/0008-dpdk-add-support-for-gazelle.patch @@ -1,62 +1,248 @@ -From 0813978b00875a8465b845672ecbc54082af9573 Mon Sep 17 00:00:00 2001 +From 359d54d7a384c12e0b4d0514939d082138163905 Mon Sep 17 00:00:00 2001 From: wuchangsheng -Date: Sat, 6 Nov 2021 20:10:49 +0800 -Subject: [PATCH] 0009-dpdk-add-support-gazelle +Date: Sat, 25 Dec 2021 15:54:12 +0800 +Subject: [PATCH] 7 --- - config/common_base | 3 +- - config/rte_config.h | 3 +- - lib/librte_eal/common/eal_common_fbarray.c | 106 ++++++- - lib/librte_eal/common/eal_common_memory.c | 88 ++++-- - lib/librte_eal/common/eal_common_options.c | 46 ++- - lib/librte_eal/common/eal_filesystem.h | 56 +++- - lib/librte_eal/common/eal_internal_cfg.h | 2 + - lib/librte_eal/common/eal_memalloc.h | 7 + - lib/librte_eal/common/eal_options.h | 7 +- - lib/librte_eal/common/eal_private.h | 25 +- - lib/librte_eal/common/include/rte_eal.h | 10 +- - lib/librte_eal/common/include/rte_fbarray.h | 7 + - lib/librte_eal/common/include/rte_memory.h | 20 +- - lib/librte_eal/linux/eal/eal.c | 277 ++++++++++++++++--- - lib/librte_eal/linux/eal/eal_hugepage_info.c | 2 +- - lib/librte_eal/linux/eal/eal_memalloc.c | 127 +++++++-- - lib/librte_eal/linux/eal/eal_memory.c | 171 ++++++++++-- - lib/librte_ring/rte_ring.h | 75 +++++ - 18 files changed, 903 insertions(+), 129 deletions(-) + config/rte_config.h | 3 +- + lib/eal/common/eal_common_config.c | 43 +++++- + lib/eal/common/eal_common_dynmem.c | 67 +++++++- + lib/eal/common/eal_common_fbarray.c | 106 +++++++++++-- + lib/eal/common/eal_common_memory.c | 90 +++++++++-- + lib/eal/common/eal_common_options.c | 179 +++++++++++++--------- + lib/eal/common/eal_filesystem.h | 58 ++++++- + lib/eal/common/eal_internal_cfg.h | 4 +- + lib/eal/common/eal_memalloc.h | 7 + + lib/eal/common/eal_options.h | 11 +- + lib/eal/common/eal_private.h | 27 +++- + lib/eal/include/rte_eal.h | 10 +- + lib/eal/include/rte_fbarray.h | 6 + + lib/eal/include/rte_memory.h | 20 ++- + lib/eal/linux/eal.c | 230 +++++++++++++++++++++++++--- + lib/eal/linux/eal_hugepage_info.c | 2 +- + lib/eal/linux/eal_memalloc.c | 128 +++++++++++++--- + lib/eal/linux/eal_memory.c | 104 ++++++++++--- + lib/ring/rte_ring.h | 75 +++++++++ + 19 files changed, 978 insertions(+), 192 deletions(-) -diff --git a/config/common_base b/config/common_base -index 7dec7ed..57b1349 100644 ---- a/config/common_base -+++ b/config/common_base -@@ -95,7 +95,8 @@ CONFIG_RTE_MAX_MEMSEG_PER_TYPE=32768 - CONFIG_RTE_MAX_MEM_MB_PER_TYPE=131072 - # global maximum usable amount of VA, in megabytes - CONFIG_RTE_MAX_MEM_MB=524288 --CONFIG_RTE_MAX_MEMZONE=2560 -+CONFIG_RTE_MAX_MEMZONE=65535 -+CONFIG_RTE_MAX_SECONDARY=256 - CONFIG_RTE_MAX_TAILQ=32 - CONFIG_RTE_ENABLE_ASSERT=n - CONFIG_RTE_LOG_DP_LEVEL=RTE_LOG_INFO diff --git a/config/rte_config.h b/config/rte_config.h -index d30786b..b848b1c 100644 +index cab4390a97..d2f192ee9b 100644 --- a/config/rte_config.h +++ b/config/rte_config.h -@@ -39,7 +39,8 @@ +@@ -34,7 +34,8 @@ + #define RTE_MAX_MEM_MB_PER_LIST 32768 #define RTE_MAX_MEMSEG_PER_TYPE 32768 #define RTE_MAX_MEM_MB_PER_TYPE 65536 - #define RTE_MAX_MEM_MB 524288 -#define RTE_MAX_MEMZONE 2560 +#define RTE_MAX_MEMZONE 65535 +#define RTE_MAX_SECONDARY 256 #define RTE_MAX_TAILQ 32 #define RTE_LOG_DP_LEVEL RTE_LOG_INFO #define RTE_BACKTRACE 1 -diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c -index 1312f93..b611ffa 100644 ---- a/lib/librte_eal/common/eal_common_fbarray.c -+++ b/lib/librte_eal/common/eal_common_fbarray.c -@@ -833,8 +833,9 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len, +diff --git a/lib/eal/common/eal_common_config.c b/lib/eal/common/eal_common_config.c +index 1c4c4dd585..fe3db184b7 100644 +--- a/lib/eal/common/eal_common_config.c ++++ b/lib/eal/common/eal_common_config.c +@@ -22,18 +22,29 @@ static char runtime_dir[PATH_MAX]; + /* internal configuration */ + static struct internal_config internal_config; + +-const char * ++/****** APIs for libnet ******/ ++static char sec_runtime_dir[RTE_MAX_SECONDARY][PATH_MAX]; ++static struct rte_config sec_rte_config[RTE_MAX_SECONDARY]; ++static struct internal_config sec_internal_config[RTE_MAX_SECONDARY]; ++ ++char * + rte_eal_get_runtime_dir(void) + { + return runtime_dir; + } + +-int +-eal_set_runtime_dir(char *run_dir, size_t size) ++char * ++rte_eal_sec_get_runtime_dir(const int sec_idx) ++{ ++ return sec_runtime_dir[sec_idx]; ++} ++ ++static int ++set_runtime_dir(char *dst_dir, char *src_dir, size_t size) + { + size_t str_size; + +- str_size = strlcpy(runtime_dir, run_dir, size); ++ str_size = strlcpy(dst_dir, src_dir, size); + if (str_size >= size) { + RTE_LOG(ERR, EAL, "Runtime directory string too long\n"); + return -1; +@@ -42,6 +53,18 @@ eal_set_runtime_dir(char *run_dir, size_t size) + return 0; + } + ++int ++eal_sec_set_runtime_dir(char *run_dir, size_t size, const int sec_idx) ++{ ++ return set_runtime_dir(sec_runtime_dir[sec_idx], run_dir, size); ++} ++ ++int ++eal_set_runtime_dir(char *run_dir, size_t size) ++{ ++ return set_runtime_dir(runtime_dir, run_dir, size); ++} ++ + /* Return a pointer to the configuration structure */ + struct rte_config * + rte_eal_get_configuration(void) +@@ -49,6 +72,18 @@ rte_eal_get_configuration(void) + return &rte_config; + } + ++struct rte_config * ++rte_eal_sec_get_configuration(const int sec_idx) ++{ ++ return &sec_rte_config[sec_idx]; ++} ++ ++struct internal_config * ++rte_eal_sec_get_internal_config(const int sec_idx) ++{ ++ return &sec_internal_config[sec_idx]; ++} ++ + /* Return a pointer to the internal configuration structure */ + struct internal_config * + eal_get_internal_configuration(void) +diff --git a/lib/eal/common/eal_common_dynmem.c b/lib/eal/common/eal_common_dynmem.c +index 7c5437ddfa..eff78c14d9 100644 +--- a/lib/eal/common/eal_common_dynmem.c ++++ b/lib/eal/common/eal_common_dynmem.c +@@ -16,6 +16,50 @@ + + /** @file Functions common to EALs that support dynamic memory allocation. */ + ++static int ++eal_sec_set_num_pages(struct internal_config *internal_conf, ++ struct hugepage_info *used_hp) ++{ ++ int ret; ++ int hp_sz_idx; ++ uint64_t memory[RTE_MAX_NUMA_NODES]; ++ ++ if (!internal_conf || !used_hp) { ++ return -1; ++ } ++ ++ for (hp_sz_idx = 0; ++ hp_sz_idx < (int) internal_conf->num_hugepage_sizes; ++ hp_sz_idx++) { ++ struct hugepage_info *hpi; ++ hpi = &internal_conf->hugepage_info[hp_sz_idx]; ++ used_hp[hp_sz_idx].hugepage_sz = hpi->hugepage_sz; ++ } ++ ++ for (hp_sz_idx = 0; hp_sz_idx < RTE_MAX_NUMA_NODES; hp_sz_idx++) ++ memory[hp_sz_idx] = internal_conf->socket_mem[hp_sz_idx]; ++ ++ ret = eal_dynmem_calc_num_pages_per_socket(memory, ++ internal_conf->hugepage_info, used_hp, ++ internal_conf->num_hugepage_sizes); ++ ++ return ret; ++} ++ ++static int ++eal_sec_get_num_pages(const struct hugepage_info *used_hp, ++ uint64_t hugepage_sz, int socket) ++{ ++ int hp_sz_idx; ++ ++ for (hp_sz_idx = 0; hp_sz_idx < MAX_HUGEPAGE_SIZES; hp_sz_idx++) { ++ if (used_hp[hp_sz_idx].hugepage_sz == hugepage_sz) ++ return used_hp[hp_sz_idx].num_pages[socket]; ++ } ++ ++ return 0; ++} ++ + int + eal_dynmem_memseg_lists_init(void) + { +@@ -29,6 +73,7 @@ eal_dynmem_memseg_lists_init(void) + uint64_t max_mem, max_mem_per_type; + unsigned int max_seglists_per_type; + unsigned int n_memtypes, cur_type; ++ struct hugepage_info used_hp[MAX_HUGEPAGE_SIZES]; + struct internal_config *internal_conf = + eal_get_internal_configuration(); + +@@ -36,6 +81,14 @@ eal_dynmem_memseg_lists_init(void) + if (internal_conf->no_hugetlbfs) + return 0; + ++ if (internal_conf->map_perfect) { ++ memset(used_hp, 0, sizeof(used_hp)); ++ ret = eal_sec_set_num_pages(internal_conf, used_hp); ++ if (ret == -1) { ++ RTE_LOG(ERR, EAL, "Cannot get num pages\n"); ++ } ++ } ++ + /* + * figuring out amount of memory we're going to have is a long and very + * involved process. the basic element we're operating with is a memory +@@ -132,6 +185,7 @@ eal_dynmem_memseg_lists_init(void) + struct memtype *type = &memtypes[cur_type]; + uint64_t max_mem_per_list, pagesz; + int socket_id; ++ unsigned int need_n_segs, cur_n_segs; + + pagesz = type->page_sz; + socket_id = type->socket_id; +@@ -175,8 +229,17 @@ eal_dynmem_memseg_lists_init(void) + "n_segs:%i socket_id:%i hugepage_sz:%" PRIu64 "\n", + n_seglists, n_segs, socket_id, pagesz); + ++ if (internal_conf->map_perfect) ++ need_n_segs = eal_sec_get_num_pages(used_hp, pagesz, socket_id); ++ else ++ need_n_segs = n_segs; ++ + /* create all segment lists */ +- for (cur_seglist = 0; cur_seglist < n_seglists; cur_seglist++) { ++ for (cur_seglist = 0; cur_seglist < n_seglists && need_n_segs > 0; cur_seglist++) { ++ cur_n_segs = RTE_MIN(need_n_segs, n_segs); ++ if (internal_conf->map_perfect) ++ need_n_segs -= cur_n_segs; ++ + if (msl_idx >= RTE_MAX_MEMSEG_LISTS) { + RTE_LOG(ERR, EAL, + "No more space in memseg lists, please increase %s\n", +@@ -185,7 +248,7 @@ eal_dynmem_memseg_lists_init(void) + } + msl = &mcfg->memsegs[msl_idx++]; + +- if (eal_memseg_list_init(msl, pagesz, n_segs, ++ if (eal_memseg_list_init(msl, pagesz, cur_n_segs, + socket_id, cur_seglist, true)) + goto out; + +diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c +index 3a28a53247..9c125c104c 100644 +--- a/lib/eal/common/eal_common_fbarray.c ++++ b/lib/eal/common/eal_common_fbarray.c +@@ -9,6 +9,8 @@ + #include + #include + #include ++#include ++#include + + #include + #include +@@ -830,8 +832,9 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len, return -1; } @@ -64,17 +250,17 @@ index 1312f93..b611ffa 100644 -rte_fbarray_attach(struct rte_fbarray *arr) +static int +__rte_fbarray_attach(struct rte_fbarray *arr, const char *runtime_dir, -+ const struct internal_config *internal_cfg) ++ const struct internal_config *internal_conf) { struct mem_area *ma = NULL, *tmp = NULL; size_t page_sz, mmap_len; -@@ -870,13 +871,15 @@ rte_fbarray_attach(struct rte_fbarray *arr) +@@ -867,13 +870,15 @@ rte_fbarray_attach(struct rte_fbarray *arr) mmap_len = calc_data_size(page_sz, arr->elt_sz, arr->len); - /* check the tailq - maybe user has already mapped this address space */ - rte_spinlock_lock(&mem_area_lock); -+ if (!internal_cfg->pri_and_sec) { ++ if (!internal_conf->pri_and_sec) { + /* check the tailq - maybe user has already mapped this address space */ + rte_spinlock_lock(&mem_area_lock); @@ -90,20 +276,20 @@ index 1312f93..b611ffa 100644 } } -@@ -886,7 +889,7 @@ rte_fbarray_attach(struct rte_fbarray *arr) +@@ -883,7 +888,7 @@ rte_fbarray_attach(struct rte_fbarray *arr) if (data == NULL) goto fail; - eal_get_fbarray_path(path, sizeof(path), arr->name); + eal_sec_get_fbarray_path(path, sizeof(path), arr->name, runtime_dir); - fd = open(path, O_RDWR); + fd = eal_file_open(path, EAL_OPEN_READWRITE); if (fd < 0) { -@@ -903,16 +906,27 @@ rte_fbarray_attach(struct rte_fbarray *arr) - if (resize_and_map(fd, data, mmap_len)) +@@ -897,16 +902,27 @@ rte_fbarray_attach(struct rte_fbarray *arr) + if (resize_and_map(fd, path, data, mmap_len)) goto fail; -+ if (internal_cfg->pri_and_sec) { ++ if (internal_conf->pri_and_sec) { + if (flock(fd, LOCK_UN)) { + rte_errno = errno; + goto fail; @@ -118,7 +304,7 @@ index 1312f93..b611ffa 100644 ma->len = mmap_len; - TAILQ_INSERT_TAIL(&mem_area_tailq, ma, next); -+ if (!internal_cfg->pri_and_sec) { ++ if (!internal_conf->pri_and_sec) { + TAILQ_INSERT_TAIL(&mem_area_tailq, ma, next); - /* we're done */ @@ -130,38 +316,39 @@ index 1312f93..b611ffa 100644 return 0; fail: if (data) -@@ -924,6 +938,30 @@ rte_fbarray_attach(struct rte_fbarray *arr) +@@ -918,6 +934,31 @@ rte_fbarray_attach(struct rte_fbarray *arr) return -1; } +int +rte_fbarray_attach(struct rte_fbarray *arr) +{ -+ return __rte_fbarray_attach(arr, rte_eal_get_runtime_dir(), &internal_config); ++ const struct internal_config *internal_conf = eal_get_internal_configuration(); ++ return __rte_fbarray_attach(arr, rte_eal_get_runtime_dir(), internal_conf); +} + +int +rte_sec_fbarray_attach(struct rte_fbarray *arr, + const int switch_pri_and_sec, const int sec_idx) +{ -+ struct internal_config *internal_cfg = NULL; ++ struct internal_config *internal_conf = NULL; + char *runtime_dir = NULL; + + if (!switch_pri_and_sec) { + runtime_dir = rte_eal_get_runtime_dir(); -+ internal_cfg = &internal_config; ++ internal_conf = eal_get_internal_configuration(); + } else { + runtime_dir = rte_eal_sec_get_runtime_dir(sec_idx); -+ internal_cfg = rte_eal_sec_get_internal_config(sec_idx); ++ internal_conf = rte_eal_sec_get_internal_config(sec_idx); + } + -+ return __rte_fbarray_attach(arr, runtime_dir, internal_cfg); ++ return __rte_fbarray_attach(arr, runtime_dir, internal_conf); +} + int rte_fbarray_detach(struct rte_fbarray *arr) { -@@ -1063,6 +1101,50 @@ rte_fbarray_destroy(struct rte_fbarray *arr) +@@ -1057,6 +1098,47 @@ rte_fbarray_destroy(struct rte_fbarray *arr) return ret; } @@ -170,7 +357,6 @@ index 1312f93..b611ffa 100644 + const int sec_idx) +{ + int fd, ret; -+ size_t mmap_len; + char path[PATH_MAX]; + + if (arr == NULL) { @@ -178,21 +364,19 @@ index 1312f93..b611ffa 100644 + return -1; + } + -+ size_t page_sz = sysconf(_SC_PAGESIZE); -+ ++ size_t page_sz = rte_mem_page_size(); + if (page_sz == (size_t)-1) + return -1; + -+ mmap_len = calc_data_size(page_sz, arr->elt_sz, arr->len); -+ munmap(arr->data, mmap_len); ++ size_t mmap_len = calc_data_size(page_sz, arr->elt_sz, arr->len); ++ rte_mem_unmap(arr->data, mmap_len); + + /* try deleting the file */ + eal_sec_get_fbarray_path(path, sizeof(path), arr->name, rte_eal_sec_get_runtime_dir(sec_idx)); + + fd = open(path, O_RDONLY); + if (fd < 0) { -+ RTE_LOG(ERR, EAL, "Could not open fbarray file: %s\n", -+ strerror(errno)); ++ RTE_LOG(ERR, EAL, "Could not open fbarray file: %s\n", strerror(errno)); + return -1; + } + if (flock(fd, LOCK_EX | LOCK_NB)) { @@ -212,11 +396,11 @@ index 1312f93..b611ffa 100644 void * rte_fbarray_get(const struct rte_fbarray *arr, unsigned int idx) { -diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c -index 4a9cc1f..842fc9b 100644 ---- a/lib/librte_eal/common/eal_common_memory.c -+++ b/lib/librte_eal/common/eal_common_memory.c -@@ -206,9 +206,9 @@ virt2memseg(const void *addr, const struct rte_memseg_list *msl) +diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c +index 616db5ce31..884996faf2 100644 +--- a/lib/eal/common/eal_common_memory.c ++++ b/lib/eal/common/eal_common_memory.c +@@ -307,9 +307,9 @@ virt2memseg(const void *addr, const struct rte_memseg_list *msl) } static struct rte_memseg_list * @@ -228,7 +412,7 @@ index 4a9cc1f..842fc9b 100644 struct rte_memseg_list *msl; int msl_idx; -@@ -230,7 +230,13 @@ virt2memseg_list(const void *addr) +@@ -331,7 +331,13 @@ virt2memseg_list(const void *addr) struct rte_memseg_list * rte_mem_virt2memseg_list(const void *addr) { @@ -243,7 +427,7 @@ index 4a9cc1f..842fc9b 100644 } struct virtiova { -@@ -283,11 +289,25 @@ rte_mem_iova2virt(rte_iova_t iova) +@@ -386,11 +392,25 @@ rte_mem_iova2virt(rte_iova_t iova) return vi.virt; } @@ -271,7 +455,7 @@ index 4a9cc1f..842fc9b 100644 } static int -@@ -889,10 +909,14 @@ rte_extmem_detach(void *va_addr, size_t len) +@@ -1069,12 +1089,14 @@ rte_eal_memory_detach(void) } /* init memory subsystem */ @@ -279,17 +463,19 @@ index 4a9cc1f..842fc9b 100644 -rte_eal_memory_init(void) +static int +__rte_eal_memory_init(__attribute__((__unused__)) const char *runtime_dir, -+ const struct internal_config *internal_cfg, ++ const struct internal_config *internal_conf, + struct rte_config *rte_cfg, + const int switch_pri_and_sec, + const int sec_idx) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; +- const struct internal_config *internal_conf = +- eal_get_internal_configuration(); + struct rte_mem_config *mcfg = rte_cfg->mem_config; + int retval; RTE_LOG(DEBUG, EAL, "Setting up physically contiguous memory...\n"); - -@@ -900,25 +924,57 @@ rte_eal_memory_init(void) +@@ -1083,17 +1105,18 @@ rte_eal_memory_init(void) return -1; /* lock mem hotplug here, to prevent races while we init */ @@ -302,7 +488,7 @@ index 4a9cc1f..842fc9b 100644 - if (eal_memalloc_init() < 0) - goto fail; -+ if (!internal_cfg->pri_and_sec) ++ if (!internal_conf->pri_and_sec) + if (eal_memalloc_init() < 0) + goto fail; @@ -314,9 +500,7 @@ index 4a9cc1f..842fc9b 100644 if (retval < 0) goto fail; -- if (internal_config.no_shconf == 0 && rte_eal_memdevice_init() < 0) -+ if (internal_cfg->no_shconf == 0 && rte_eal_memdevice_init() < 0) - goto fail; +@@ -1102,10 +1125,43 @@ rte_eal_memory_init(void) return 0; fail: @@ -324,14 +508,16 @@ index 4a9cc1f..842fc9b 100644 + rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); return -1; } -+ + +int +rte_eal_memory_init(void) +{ + const int unused_idx = -1; ++ const struct internal_config *internal_conf = ++ eal_get_internal_configuration(); + + return __rte_eal_memory_init(rte_eal_get_runtime_dir(), -+ &internal_config, rte_eal_get_configuration(), ++ internal_conf, rte_eal_get_configuration(), + false, unused_idx); +} + @@ -353,29 +539,120 @@ index 4a9cc1f..842fc9b 100644 +int +rte_eal_sec_memory_cleanup(const int sec_idx) +{ -+ return eal_memalloc_destroy(sec_idx); ++ return eal_sec_memalloc_destroy(sec_idx); +} -diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c -index a7f9c5f..34f4199 100644 ---- a/lib/librte_eal/common/eal_common_options.c -+++ b/lib/librte_eal/common/eal_common_options.c -@@ -82,6 +82,7 @@ eal_long_options[] = { - {OPT_LEGACY_MEM, 0, NULL, OPT_LEGACY_MEM_NUM }, - {OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM}, - {OPT_MATCH_ALLOCATIONS, 0, NULL, OPT_MATCH_ALLOCATIONS_NUM}, ++ + #ifndef RTE_EXEC_ENV_WINDOWS + #define EAL_MEMZONE_LIST_REQ "/eal/memzone_list" + #define EAL_MEMZONE_INFO_REQ "/eal/memzone_info" +diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c +index 1cfdd75f3b..ba3b19ee6e 100644 +--- a/lib/eal/common/eal_common_options.c ++++ b/lib/eal/common/eal_common_options.c +@@ -105,6 +105,7 @@ eal_long_options[] = { + {OPT_TELEMETRY, 0, NULL, OPT_TELEMETRY_NUM }, + {OPT_NO_TELEMETRY, 0, NULL, OPT_NO_TELEMETRY_NUM }, + {OPT_FORCE_MAX_SIMD_BITWIDTH, 1, NULL, OPT_FORCE_MAX_SIMD_BITWIDTH_NUM}, + {OPT_MAP_PERFECT, 0, NULL, OPT_MAP_PERFECT_NUM }, + {0, 0, NULL, 0 } }; +@@ -301,54 +302,66 @@ eal_get_hugefile_prefix(void) + return HUGEFILE_PREFIX_DEFAULT; + } -@@ -221,6 +222,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg) - internal_cfg->user_mbuf_pool_ops_name = NULL; - CPU_ZERO(&internal_cfg->ctrl_cpuset); - internal_cfg->init_complete = 0; -+ internal_cfg->map_perfect = 0; ++const char * ++eal_sec_get_hugefile_prefix(const int sec_idx) ++{ ++ struct internal_config *internal_conf = ++ rte_eal_sec_get_internal_config(sec_idx); ++ ++ if (internal_conf->hugefile_prefix != NULL) ++ return internal_conf->hugefile_prefix; ++ return HUGEFILE_PREFIX_DEFAULT; ++} ++ + void +-eal_reset_internal_config(struct internal_config *internal_cfg) ++eal_reset_internal_config(struct internal_config *internal_conf) + { + int i; + +- internal_cfg->memory = 0; +- internal_cfg->force_nrank = 0; +- internal_cfg->force_nchannel = 0; +- internal_cfg->hugefile_prefix = NULL; +- internal_cfg->hugepage_dir = NULL; +- internal_cfg->force_sockets = 0; ++ internal_conf->memory = 0; ++ internal_conf->force_nrank = 0; ++ internal_conf->force_nchannel = 0; ++ internal_conf->hugefile_prefix = NULL; ++ internal_conf->hugepage_dir = NULL; ++ internal_conf->force_sockets = 0; + /* zero out the NUMA config */ + for (i = 0; i < RTE_MAX_NUMA_NODES; i++) +- internal_cfg->socket_mem[i] = 0; +- internal_cfg->force_socket_limits = 0; ++ internal_conf->socket_mem[i] = 0; ++ internal_conf->force_socket_limits = 0; + /* zero out the NUMA limits config */ + for (i = 0; i < RTE_MAX_NUMA_NODES; i++) +- internal_cfg->socket_limit[i] = 0; ++ internal_conf->socket_limit[i] = 0; + /* zero out hugedir descriptors */ + for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) { +- memset(&internal_cfg->hugepage_info[i], 0, +- sizeof(internal_cfg->hugepage_info[0])); +- internal_cfg->hugepage_info[i].lock_descriptor = -1; ++ memset(&internal_conf->hugepage_info[i], 0, ++ sizeof(internal_conf->hugepage_info[0])); ++ internal_conf->hugepage_info[i].lock_descriptor = -1; + } +- internal_cfg->base_virtaddr = 0; ++ internal_conf->base_virtaddr = 0; + + #ifdef LOG_DAEMON +- internal_cfg->syslog_facility = LOG_DAEMON; ++ internal_conf->syslog_facility = LOG_DAEMON; + #endif + + /* if set to NONE, interrupt mode is determined automatically */ +- internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE; +- memset(internal_cfg->vfio_vf_token, 0, +- sizeof(internal_cfg->vfio_vf_token)); ++ internal_conf->vfio_intr_mode = RTE_INTR_MODE_NONE; ++ memset(internal_conf->vfio_vf_token, 0, ++ sizeof(internal_conf->vfio_vf_token)); + + #ifdef RTE_LIBEAL_USE_HPET +- internal_cfg->no_hpet = 0; ++ internal_conf->no_hpet = 0; + #else +- internal_cfg->no_hpet = 1; ++ internal_conf->no_hpet = 1; + #endif +- internal_cfg->vmware_tsc_map = 0; +- internal_cfg->create_uio_dev = 0; +- internal_cfg->iova_mode = RTE_IOVA_DC; +- internal_cfg->user_mbuf_pool_ops_name = NULL; +- CPU_ZERO(&internal_cfg->ctrl_cpuset); +- internal_cfg->init_complete = 0; +- internal_cfg->max_simd_bitwidth.bitwidth = RTE_VECT_DEFAULT_SIMD_BITWIDTH; +- internal_cfg->max_simd_bitwidth.forced = 0; ++ internal_conf->vmware_tsc_map = 0; ++ internal_conf->create_uio_dev = 0; ++ internal_conf->iova_mode = RTE_IOVA_DC; ++ internal_conf->user_mbuf_pool_ops_name = NULL; ++ CPU_ZERO(&internal_conf->ctrl_cpuset); ++ internal_conf->init_complete = 0; ++ internal_conf->map_perfect = 0; ++ internal_conf->max_simd_bitwidth.bitwidth = RTE_VECT_DEFAULT_SIMD_BITWIDTH; ++ internal_conf->max_simd_bitwidth.forced = 0; } static int -@@ -1097,7 +1099,7 @@ eal_parse_iova_mode(const char *name) +@@ -1496,12 +1509,10 @@ eal_parse_simd_bitwidth(const char *arg) } static int @@ -384,16 +661,21 @@ index a7f9c5f..34f4199 100644 { char *end; uint64_t addr; -@@ -1120,7 +1122,7 @@ eal_parse_base_virtaddr(const char *arg) +- struct internal_config *internal_conf = +- eal_get_internal_configuration(); + + errno = 0; + addr = strtoull(arg, &end, 16); +@@ -1521,7 +1532,7 @@ eal_parse_base_virtaddr(const char *arg) * it can align to 2MB for x86. So this alignment can also be used * on x86 and other architectures. */ -- internal_config.base_virtaddr = +- internal_conf->base_virtaddr = + conf->base_virtaddr = RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16M); return 0; -@@ -1440,7 +1442,7 @@ eal_parse_common_option(int opt, const char *optarg, +@@ -1877,7 +1888,7 @@ eal_parse_common_option(int opt, const char *optarg, } break; case OPT_BASE_VIRTADDR_NUM: @@ -402,58 +684,197 @@ index a7f9c5f..34f4199 100644 RTE_LOG(ERR, EAL, "invalid parameter for --" OPT_BASE_VIRTADDR "\n"); return -1; -@@ -1553,11 +1555,33 @@ eal_adjust_config(struct internal_config *internal_cfg) +@@ -1933,9 +1944,9 @@ eal_auto_detect_cores(struct rte_config *cfg) + } + + static void +-compute_ctrl_threads_cpuset(struct internal_config *internal_cfg) ++compute_ctrl_threads_cpuset(struct internal_config *internal_conf) + { +- rte_cpuset_t *cpuset = &internal_cfg->ctrl_cpuset; ++ rte_cpuset_t *cpuset = &internal_conf->ctrl_cpuset; + rte_cpuset_t default_set; + unsigned int lcore_id; + +@@ -1960,25 +1971,23 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg) + } + + int +-eal_cleanup_config(struct internal_config *internal_cfg) ++eal_cleanup_config(struct internal_config *internal_conf) + { +- if (internal_cfg->hugefile_prefix != NULL) +- free(internal_cfg->hugefile_prefix); +- if (internal_cfg->hugepage_dir != NULL) +- free(internal_cfg->hugepage_dir); +- if (internal_cfg->user_mbuf_pool_ops_name != NULL) +- free(internal_cfg->user_mbuf_pool_ops_name); ++ if (internal_conf->hugefile_prefix != NULL) ++ free(internal_conf->hugefile_prefix); ++ if (internal_conf->hugepage_dir != NULL) ++ free(internal_conf->hugepage_dir); ++ if (internal_conf->user_mbuf_pool_ops_name != NULL) ++ free(internal_conf->user_mbuf_pool_ops_name); + + return 0; + } + + int +-eal_adjust_config(struct internal_config *internal_cfg) ++eal_adjust_config(struct internal_config *internal_conf) + { + int i; + struct rte_config *cfg = rte_eal_get_configuration(); +- struct internal_config *internal_conf = +- eal_get_internal_configuration(); + + if (!core_parsed) + eal_auto_detect_cores(cfg); +@@ -1994,44 +2003,64 @@ eal_adjust_config(struct internal_config *internal_cfg) + lcore_config[cfg->main_lcore].core_role = ROLE_RTE; + } + +- compute_ctrl_threads_cpuset(internal_cfg); ++ compute_ctrl_threads_cpuset(internal_conf); + + /* if no memory amounts were requested, this will result in 0 and + * will be overridden later, right after eal_hugepage_info_init() */ + for (i = 0; i < RTE_MAX_NUMA_NODES; i++) +- internal_cfg->memory += internal_cfg->socket_mem[i]; ++ internal_conf->memory += internal_conf->socket_mem[i]; + + return 0; } int -eal_check_common_options(struct internal_config *internal_cfg) -+eal_sec_adjust_config(struct internal_config *internal_cfg) ++eal_sec_adjust_config(struct internal_config *internal_conf) { - struct rte_config *cfg = rte_eal_get_configuration(); -+ struct internal_config *internal_cfg_head; -+ internal_cfg->process_type = RTE_PROC_SECONDARY; +- const struct internal_config *internal_conf = +- eal_get_internal_configuration(); ++ struct internal_config *internal_conf_head; ++ internal_conf->process_type = RTE_PROC_SECONDARY; + -+ internal_cfg_head = rte_eal_sec_get_internal_config(0); ++ internal_conf_head = rte_eal_sec_get_internal_config(0); + for (int i = 0; i < RTE_MAX_SECONDARY; ++i) { -+ if (!internal_cfg_head[i].pri_and_sec) ++ if (!internal_conf_head[i].pri_and_sec) + continue; -+ if (internal_cfg == &internal_cfg_head[i]) ++ if (internal_conf == &internal_conf_head[i]) + continue; -+ if (!strcmp(internal_cfg_head[i].hugefile_prefix, internal_cfg->hugefile_prefix)) ++ if (!strcmp(internal_conf_head[i].hugefile_prefix, internal_conf->hugefile_prefix)) + return -EALREADY; + } + + for (int i = 0; i < RTE_MAX_NUMA_NODES; i++) -+ internal_cfg->memory += internal_cfg->socket_mem[i]; -+ ++ internal_conf->memory += internal_conf->socket_mem[i]; + +- if (cfg->lcore_role[cfg->main_lcore] != ROLE_RTE) { + return 0; +} - -- if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) { ++ +int -+eal_check_common_options(struct internal_config *internal_cfg, ++eal_check_common_options(struct internal_config *internal_conf, + struct rte_config *cfg) +{ -+ if (!internal_cfg->pri_and_sec && -+ cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) { - RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n"); ++ if (!internal_conf->pri_and_sec && ++ cfg->lcore_role[cfg->main_lcore] != ROLE_RTE) { + RTE_LOG(ERR, EAL, "Main lcore is not enabled for DPDK\n"); return -1; } -@@ -1602,7 +1626,7 @@ eal_check_common_options(struct internal_config *internal_cfg) + +- if (internal_cfg->process_type == RTE_PROC_INVALID) { ++ if (internal_conf->process_type == RTE_PROC_INVALID) { + RTE_LOG(ERR, EAL, "Invalid process type specified\n"); + return -1; + } +- if (internal_cfg->hugefile_prefix != NULL && +- strlen(internal_cfg->hugefile_prefix) < 1) { ++ if (internal_conf->hugefile_prefix != NULL && ++ strlen(internal_conf->hugefile_prefix) < 1) { + RTE_LOG(ERR, EAL, "Invalid length of --" OPT_FILE_PREFIX " option\n"); + return -1; + } +- if (internal_cfg->hugepage_dir != NULL && +- strlen(internal_cfg->hugepage_dir) < 1) { ++ if (internal_conf->hugepage_dir != NULL && ++ strlen(internal_conf->hugepage_dir) < 1) { + RTE_LOG(ERR, EAL, "Invalid length of --" OPT_HUGE_DIR" option\n"); + return -1; + } +- if (internal_cfg->user_mbuf_pool_ops_name != NULL && +- strlen(internal_cfg->user_mbuf_pool_ops_name) < 1) { ++ if (internal_conf->user_mbuf_pool_ops_name != NULL && ++ strlen(internal_conf->user_mbuf_pool_ops_name) < 1) { + RTE_LOG(ERR, EAL, "Invalid length of --" OPT_MBUF_POOL_OPS_NAME" option\n"); + return -1; + } +@@ -2040,18 +2069,18 @@ eal_check_common_options(struct internal_config *internal_cfg) + "option\n"); + return -1; + } +- if (mem_parsed && internal_cfg->force_sockets == 1) { ++ if (mem_parsed && internal_conf->force_sockets == 1) { + RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot " + "be specified at the same time\n"); + return -1; + } +- if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) { ++ if (internal_conf->no_hugetlbfs && internal_conf->force_sockets == 1) { + RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot " "be specified together with --"OPT_NO_HUGE"\n"); return -1; } -- if (internal_config.force_socket_limits && internal_config.legacy_mem) { -+ if (internal_cfg->force_socket_limits && internal_config.legacy_mem) { +- if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink && +- !internal_cfg->in_memory) { ++ if (internal_conf->no_hugetlbfs && internal_conf->hugepage_unlink && ++ !internal_conf->in_memory) { + RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot " + "be specified together with --"OPT_NO_HUGE"\n"); + return -1; +@@ -2060,35 +2089,43 @@ eal_check_common_options(struct internal_config *internal_cfg) RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_LIMIT " is only supported in non-legacy memory mode\n"); } -@@ -1635,6 +1659,14 @@ eal_check_common_options(struct internal_config *internal_cfg) +- if (internal_cfg->single_file_segments && +- internal_cfg->hugepage_unlink && +- !internal_cfg->in_memory) { ++ if (internal_conf->single_file_segments && ++ internal_conf->hugepage_unlink && ++ !internal_conf->in_memory) { + RTE_LOG(ERR, EAL, "Option --"OPT_SINGLE_FILE_SEGMENTS" is " + "not compatible with --"OPT_HUGE_UNLINK"\n"); + return -1; + } +- if (internal_cfg->legacy_mem && +- internal_cfg->in_memory) { ++ if (internal_conf->legacy_mem && ++ internal_conf->in_memory) { + RTE_LOG(ERR, EAL, "Option --"OPT_LEGACY_MEM" is not compatible " + "with --"OPT_IN_MEMORY"\n"); + return -1; + } +- if (internal_cfg->legacy_mem && internal_cfg->match_allocations) { ++ if (internal_conf->legacy_mem && internal_conf->match_allocations) { + RTE_LOG(ERR, EAL, "Option --"OPT_LEGACY_MEM" is not compatible " + "with --"OPT_MATCH_ALLOCATIONS"\n"); + return -1; + } +- if (internal_cfg->no_hugetlbfs && internal_cfg->match_allocations) { ++ if (internal_conf->no_hugetlbfs && internal_conf->match_allocations) { + RTE_LOG(ERR, EAL, "Option --"OPT_NO_HUGE" is not compatible " + "with --"OPT_MATCH_ALLOCATIONS"\n"); + return -1; + } +- if (internal_cfg->legacy_mem && internal_cfg->memory == 0) { ++ if (internal_conf->legacy_mem && internal_conf->memory == 0) { + RTE_LOG(NOTICE, EAL, "Static memory layout is selected, " + "amount of reserved memory can be adjusted with " "-m or --"OPT_SOCKET_MEM"\n"); } -+ if (internal_cfg->map_perfect || internal_cfg->pri_and_sec) { -+ if (!internal_cfg->legacy_mem || internal_cfg->in_memory || internal_cfg->no_hugetlbfs) { ++ if (internal_conf->map_perfect || internal_conf->pri_and_sec) { ++ if (!internal_conf->legacy_mem || internal_conf->in_memory || internal_conf->no_hugetlbfs) { + RTE_LOG(ERR, EAL, "Option --"OPT_LEGACY_MEM" or "OPT_IN_MEMORY" or "OPT_NO_HUGE" " + "is not compatible with --"OPT_MAP_PERFECT" and "OPT_PRI_AND_SEC"\n"); + return -1; @@ -463,22 +884,26 @@ index a7f9c5f..34f4199 100644 return 0; } -diff --git a/lib/librte_eal/common/eal_filesystem.h b/lib/librte_eal/common/eal_filesystem.h -index 5d21f07..e65a183 100644 ---- a/lib/librte_eal/common/eal_filesystem.h -+++ b/lib/librte_eal/common/eal_filesystem.h -@@ -23,7 +23,8 @@ +diff --git a/lib/eal/common/eal_filesystem.h b/lib/eal/common/eal_filesystem.h +index 5d21f07c20..719678772f 100644 +--- a/lib/eal/common/eal_filesystem.h ++++ b/lib/eal/common/eal_filesystem.h +@@ -23,7 +23,7 @@ /* sets up platform-specific runtime data dir */ int -eal_create_runtime_dir(void); -+eal_create_runtime_dir(char *runtime_dir, const int buflen, -+ const struct internal_config *conf); ++eal_create_runtime_dir(const int sec_idx); int eal_clean_runtime_dir(void); -@@ -34,15 +35,27 @@ eal_get_hugefile_prefix(void); +@@ -32,17 +32,32 @@ eal_clean_runtime_dir(void); + const char * + eal_get_hugefile_prefix(void); ++const char * ++eal_sec_get_hugefile_prefix(const int sec_idx); ++ #define RUNTIME_CONFIG_FNAME "config" static inline const char * -eal_runtime_config_path(void) @@ -507,7 +932,7 @@ index 5d21f07..e65a183 100644 /** Path of primary/secondary communication unix socket file. */ #define MP_SOCKET_FNAME "mp_socket" static inline const char * -@@ -57,12 +70,29 @@ eal_mp_socket_path(void) +@@ -57,12 +72,29 @@ eal_mp_socket_path(void) #define FBARRAY_NAME_FMT "%s/fbarray_%s" static inline const char * @@ -539,7 +964,7 @@ index 5d21f07..e65a183 100644 /** Path of hugepage info file. */ #define HUGEPAGE_INFO_FNAME "hugepage_info" static inline const char * -@@ -78,15 +108,27 @@ eal_hugepage_info_path(void) +@@ -78,15 +110,27 @@ eal_hugepage_info_path(void) /** Path of hugepage data file. */ #define HUGEPAGE_DATA_FNAME "hugepage_data" static inline const char * @@ -569,23 +994,26 @@ index 5d21f07..e65a183 100644 /** String format for hugepage map files. */ #define HUGEFILE_FMT "%s/%smap_%d" static inline const char * -diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h -index a42f349..50d5da1 100644 ---- a/lib/librte_eal/common/eal_internal_cfg.h -+++ b/lib/librte_eal/common/eal_internal_cfg.h -@@ -82,6 +82,8 @@ struct internal_config { - rte_cpuset_t ctrl_cpuset; /**< cpuset for ctrl threads */ - volatile unsigned int init_complete; - /**< indicates whether EAL has completed initialization */ +diff --git a/lib/eal/common/eal_internal_cfg.h b/lib/eal/common/eal_internal_cfg.h +index d6c0470eb8..8c326f2f87 100644 +--- a/lib/eal/common/eal_internal_cfg.h ++++ b/lib/eal/common/eal_internal_cfg.h +@@ -94,8 +94,10 @@ struct internal_config { + unsigned int no_telemetry; /**< true to disable Telemetry */ + struct simd_bitwidth max_simd_bitwidth; + /**< max simd bitwidth path to use */ + volatile unsigned pri_and_sec; + volatile unsigned map_perfect; }; - extern struct internal_config internal_config; /**< Global EAL configuration. */ -diff --git a/lib/librte_eal/common/eal_memalloc.h b/lib/librte_eal/common/eal_memalloc.h -index e953cd8..d5ea6e1 100644 ---- a/lib/librte_eal/common/eal_memalloc.h -+++ b/lib/librte_eal/common/eal_memalloc.h +-void eal_reset_internal_config(struct internal_config *internal_cfg); ++void eal_reset_internal_config(struct internal_config *internal_conf); + + #endif /* EAL_INTERNAL_CFG_H */ +diff --git a/lib/eal/common/eal_memalloc.h b/lib/eal/common/eal_memalloc.h +index ebc3a6f6c1..19ccee7891 100644 +--- a/lib/eal/common/eal_memalloc.h ++++ b/lib/eal/common/eal_memalloc.h @@ -83,6 +83,10 @@ eal_memalloc_get_seg_fd(int list_idx, int seg_idx); int eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd); @@ -597,45 +1025,48 @@ index e953cd8..d5ea6e1 100644 /* returns 0 or -errno */ int eal_memalloc_set_seg_list_fd(int list_idx, int fd); -@@ -93,4 +97,7 @@ eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset); +@@ -96,4 +100,7 @@ eal_memalloc_init(void); int - eal_memalloc_init(void); + eal_memalloc_cleanup(void); +int -+eal_memalloc_destroy(const int sec_idx); ++eal_sec_memalloc_destroy(const int sec_idx); + #endif /* EAL_MEMALLOC_H */ -diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h -index 9855429..b42d41d 100644 ---- a/lib/librte_eal/common/eal_options.h -+++ b/lib/librte_eal/common/eal_options.h -@@ -69,6 +69,10 @@ enum { - OPT_IOVA_MODE_NUM, - #define OPT_MATCH_ALLOCATIONS "match-allocations" - OPT_MATCH_ALLOCATIONS_NUM, +diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h +index 8e4f7202a2..95625c4002 100644 +--- a/lib/eal/common/eal_options.h ++++ b/lib/eal/common/eal_options.h +@@ -87,6 +87,10 @@ enum { + OPT_NO_TELEMETRY_NUM, + #define OPT_FORCE_MAX_SIMD_BITWIDTH "force-max-simd-bitwidth" + OPT_FORCE_MAX_SIMD_BITWIDTH_NUM, +#define OPT_PRI_AND_SEC "pri-and-sec" + OPT_PRI_AND_SEC_NUM, +#define OPT_MAP_PERFECT "map-perfect" + OPT_MAP_PERFECT_NUM, + OPT_LONG_MAX_NUM }; - -@@ -79,8 +83,9 @@ int eal_parse_common_option(int opt, const char *argv, +@@ -97,9 +101,10 @@ extern const struct option eal_long_options[]; + int eal_parse_common_option(int opt, const char *argv, struct internal_config *conf); int eal_option_device_parse(void); - int eal_adjust_config(struct internal_config *internal_cfg); -+int eal_sec_adjust_config(struct internal_config *internal_cfg); - int eal_cleanup_config(struct internal_config *internal_cfg); +-int eal_adjust_config(struct internal_config *internal_cfg); +-int eal_cleanup_config(struct internal_config *internal_cfg); -int eal_check_common_options(struct internal_config *internal_cfg); -+int eal_check_common_options(struct internal_config *internal_cfg, struct rte_config *cfg); ++int eal_adjust_config(struct internal_config *internal_conf); ++int eal_sec_adjust_config(struct internal_config *internal_conf); ++int eal_cleanup_config(struct internal_config *internal_conf); ++int eal_check_common_options(struct internal_config *internal_conf, struct rte_config *cfg); void eal_common_usage(void); enum rte_proc_type_t eal_proc_type_detect(void); int eal_plugins_init(void); -diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h -index 597fd02..1fd32a9 100644 ---- a/lib/librte_eal/common/eal_private.h -+++ b/lib/librte_eal/common/eal_private.h -@@ -113,7 +113,8 @@ int rte_eal_cpu_init(void); +diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h +index 36bcc0b5a4..ac8af18773 100644 +--- a/lib/eal/common/eal_private.h ++++ b/lib/eal/common/eal_private.h +@@ -103,7 +103,8 @@ int rte_eal_cpu_init(void); * @return * 0 on success, negative on error */ @@ -645,7 +1076,7 @@ index 597fd02..1fd32a9 100644 /** * Map memory -@@ -127,6 +128,9 @@ int rte_eal_memseg_init(void); +@@ -117,6 +118,9 @@ int rte_eal_memseg_init(void); */ int rte_eal_memory_init(void); @@ -655,7 +1086,7 @@ index 597fd02..1fd32a9 100644 /** * Configure timers * -@@ -291,7 +295,8 @@ int rte_eal_hugepage_init(void); +@@ -413,7 +417,8 @@ int rte_eal_hugepage_init(void); * * This function is private to the EAL. */ @@ -664,12 +1095,21 @@ index 597fd02..1fd32a9 100644 +int rte_eal_hugepage_attach(const int switch_pri_and_sec, const int sec_idx); /** - * Find a bus capable of identifying a device. -@@ -450,4 +455,20 @@ eal_get_baseaddr(void); - **/ - bool - eal_is_master_set_affinity(void); + * Detaches all memory mappings from a process. +@@ -689,6 +694,9 @@ eal_mem_set_dump(void *virt, size_t size, bool dump); + int + eal_set_runtime_dir(char *run_dir, size_t size); + ++int ++eal_sec_set_runtime_dir(char *run_dir, size_t size, const int sec_idx); + + /** + * Get the internal configuration structure. + * +@@ -738,4 +746,19 @@ int eal_asprintf(char **buffer, const char *format, ...); + eal_asprintf(buffer, format, ##__VA_ARGS__) + #endif + + +/****** APIs for libnet ******/ +#include @@ -686,11 +1126,11 @@ index 597fd02..1fd32a9 100644 + struct rte_config *rte_cfg); + #endif /* _EAL_PRIVATE_H_ */ -diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h -index 2f9ed29..ac1dc1d 100644 ---- a/lib/librte_eal/common/include/rte_eal.h -+++ b/lib/librte_eal/common/include/rte_eal.h -@@ -485,9 +485,17 @@ rte_eal_mbuf_user_pool_ops(void); +diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h +index 5a34a6acd9..c3259a4af3 100644 +--- a/lib/eal/include/rte_eal.h ++++ b/lib/eal/include/rte_eal.h +@@ -472,9 +472,17 @@ rte_eal_mbuf_user_pool_ops(void); * @return * The runtime directory path of DPDK */ @@ -709,11 +1149,11 @@ index 2f9ed29..ac1dc1d 100644 #ifdef __cplusplus } #endif -diff --git a/lib/librte_eal/common/include/rte_fbarray.h b/lib/librte_eal/common/include/rte_fbarray.h -index 6dccdbe..dffee1e 100644 ---- a/lib/librte_eal/common/include/rte_fbarray.h -+++ b/lib/librte_eal/common/include/rte_fbarray.h -@@ -101,6 +101,10 @@ __rte_experimental +diff --git a/lib/eal/include/rte_fbarray.h b/lib/eal/include/rte_fbarray.h +index c64868711e..e35a0cc0b4 100644 +--- a/lib/eal/include/rte_fbarray.h ++++ b/lib/eal/include/rte_fbarray.h +@@ -99,6 +99,10 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len, int rte_fbarray_attach(struct rte_fbarray *arr); @@ -724,22 +1164,21 @@ index 6dccdbe..dffee1e 100644 /** * Deallocate resources for an already allocated and correctly set up -@@ -123,6 +127,9 @@ __rte_experimental +@@ -120,6 +124,8 @@ rte_fbarray_attach(struct rte_fbarray *arr); int rte_fbarray_destroy(struct rte_fbarray *arr); +int -+rte_sec_fbarray_destroy(struct rte_fbarray *arr, -+ const int sec_idx); ++rte_sec_fbarray_destroy(struct rte_fbarray *arr, const int sec_idx); /** * Deallocate resources for an already allocated and correctly set up -diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h -index 3d8d0bd..4dd6daa 100644 ---- a/lib/librte_eal/common/include/rte_memory.h -+++ b/lib/librte_eal/common/include/rte_memory.h -@@ -152,7 +152,12 @@ rte_mem_iova2virt(rte_iova_t iova); - __rte_experimental +diff --git a/lib/eal/include/rte_memory.h b/lib/eal/include/rte_memory.h +index 6d018629ae..bf4c6098e3 100644 +--- a/lib/eal/include/rte_memory.h ++++ b/lib/eal/include/rte_memory.h +@@ -143,7 +143,12 @@ rte_mem_iova2virt(rte_iova_t iova); + */ struct rte_memseg * rte_mem_virt2memseg(const void *virt, const struct rte_memseg_list *msl); - @@ -752,8 +1191,8 @@ index 3d8d0bd..4dd6daa 100644 /** * Get memseg list corresponding to virtual memory address. * -@@ -164,7 +169,11 @@ rte_mem_virt2memseg(const void *virt, const struct rte_memseg_list *msl); - __rte_experimental +@@ -154,7 +159,11 @@ rte_mem_virt2memseg(const void *virt, const struct rte_memseg_list *msl); + */ struct rte_memseg_list * rte_mem_virt2memseg_list(const void *virt); - @@ -765,8 +1204,8 @@ index 3d8d0bd..4dd6daa 100644 /** * Memseg walk function prototype. * -@@ -282,7 +291,12 @@ rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg); - __rte_experimental +@@ -268,7 +277,12 @@ rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg); + */ int rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg); - @@ -779,101 +1218,65 @@ index 3d8d0bd..4dd6daa 100644 /** * Walk each VA-contiguous area without performing any locking. * -diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c -index 8bb1842..a1f2b42 100644 ---- a/lib/librte_eal/linux/eal/eal.c -+++ b/lib/librte_eal/linux/eal/eal.c -@@ -103,6 +103,12 @@ static char runtime_dir[PATH_MAX]; +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index 47c2186bee..a3afa80d99 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -88,8 +88,10 @@ int rte_cycles_vmware_tsc_map; static const char *default_runtime_dir = "/var/run"; -+/****** APIs for libnet ******/ +static unsigned int sec_count = 0; -+static struct rte_config sec_rte_config[RTE_MAX_SECONDARY]; -+static struct internal_config sec_internal_config[RTE_MAX_SECONDARY]; -+static char sec_runtime_dir[RTE_MAX_SECONDARY][PATH_MAX]; + - static bool master_set_affinity = true; - bool - eal_is_master_set_affinity(void) -@@ -111,7 +117,8 @@ eal_is_master_set_affinity(void) - } - int -eal_create_runtime_dir(void) -+eal_create_runtime_dir(char *runtime_dir, const int buflen, -+ const struct internal_config *conf) ++eal_create_runtime_dir(const int sec_idx) { const char *directory = default_runtime_dir; const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); -@@ -134,8 +141,8 @@ eal_create_runtime_dir(void) +@@ -113,8 +115,9 @@ eal_create_runtime_dir(void) } /* create prefix-specific subdirectory under DPDK runtime dir */ -- ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s/%s", +- ret = snprintf(run_dir, sizeof(run_dir), "%s/%s", - tmp, eal_get_hugefile_prefix()); -+ ret = snprintf(runtime_dir, buflen, "%s/%s", -+ tmp, conf->hugefile_prefix); - if (ret < 0 || ret == sizeof(runtime_dir)) { ++ const char *prefix = (sec_idx < 0) ? eal_get_hugefile_prefix() : ++ eal_sec_get_hugefile_prefix(sec_idx); ++ ret = snprintf(run_dir, sizeof(run_dir), "%s/%s", tmp, prefix); + if (ret < 0 || ret == sizeof(run_dir)) { RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime path name\n"); return -1; -@@ -246,12 +253,18 @@ eal_clean_runtime_dir(void) - return -1; - } +@@ -137,7 +140,9 @@ eal_create_runtime_dir(void) + return -1; + } --const char * -+char * - rte_eal_get_runtime_dir(void) - { - return runtime_dir; - } +- if (eal_set_runtime_dir(run_dir, sizeof(run_dir))) ++ ret = (sec_idx < 0) ? eal_set_runtime_dir(run_dir, sizeof(run_dir)) : ++ eal_sec_set_runtime_dir(run_dir, sizeof(run_dir), sec_idx); ++ if (ret) + return -1; -+char * -+rte_eal_sec_get_runtime_dir(const int sec_idx) -+{ -+ return sec_runtime_dir[sec_idx]; -+} -+ - /* Return user provided mbuf pool ops name */ - const char * - rte_eal_mbuf_user_pool_ops(void) -@@ -266,6 +279,18 @@ rte_eal_get_configuration(void) - return &rte_config; - } - -+struct rte_config * -+rte_eal_sec_get_configuration(const int sec_idx) -+{ -+ return &sec_rte_config[sec_idx]; -+} -+ -+struct internal_config * -+rte_eal_sec_get_internal_config(const int sec_idx) -+{ -+ return &sec_internal_config[sec_idx]; -+} -+ - enum rte_iova_mode - rte_eal_iova_mode(void) - { -@@ -395,18 +420,22 @@ rte_eal_config_create(void) + return 0; +@@ -355,21 +360,22 @@ rte_eal_config_create(void) /* attach to an existing shared memory config */ static int -rte_eal_config_attach(void) +__rte_eal_config_attach(const int mmap_flags, int *mem_cfg_fd, + const char *runtime_dir, -+ const struct internal_config *internal_cfg, ++ const struct internal_config *internal_conf, + struct rte_config *rte_cfg) { +- struct rte_config *config = rte_eal_get_configuration(); struct rte_mem_config *mem_config; +- const struct internal_config *internal_conf = +- eal_get_internal_configuration(); + int mcfg_fd = *mem_cfg_fd; - const char *pathname = eal_runtime_config_path(); + const char *pathname = eal_sec_runtime_config_path(runtime_dir); -- if (internal_config.no_shconf) -+ if (internal_cfg->no_shconf) + if (internal_conf->no_shconf) return 0; - if (mem_cfg_fd < 0){ @@ -885,7 +1288,7 @@ index 8bb1842..a1f2b42 100644 RTE_LOG(ERR, EAL, "Cannot open '%s' for rte_mem_config\n", pathname); return -1; -@@ -415,20 +444,29 @@ rte_eal_config_attach(void) +@@ -378,20 +384,32 @@ rte_eal_config_attach(void) /* map it as read-only first */ mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config), @@ -901,7 +1304,7 @@ index 8bb1842..a1f2b42 100644 return -1; } -- rte_config.mem_config = mem_config; +- config->mem_config = mem_config; + rte_cfg->mem_config = mem_config; + *mem_cfg_fd = mcfg_fd; @@ -911,15 +1314,18 @@ index 8bb1842..a1f2b42 100644 +static int +rte_eal_config_attach(void) +{ ++ const struct internal_config *internal_conf = eal_get_internal_configuration(); ++ + return __rte_eal_config_attach(PROT_READ, &mem_cfg_fd, -+ rte_eal_get_runtime_dir(), &internal_config, -+ rte_eal_get_configuration()); ++ rte_eal_get_runtime_dir(), internal_conf, ++ rte_eal_get_configuration()); +} ++ + /* reattach the shared config at exact memory location primary process has it */ static int rte_eal_config_reattach(void) -@@ -531,6 +569,45 @@ rte_config_init(void) +@@ -508,6 +526,45 @@ rte_config_init(void) return 0; } @@ -930,13 +1336,13 @@ index 8bb1842..a1f2b42 100644 + int mmap_flags = PROT_READ | PROT_WRITE; + + struct rte_config *rte_cfg = rte_eal_sec_get_configuration(sec_idx); -+ struct internal_config *internal_cfg = rte_eal_sec_get_internal_config(sec_idx); ++ struct internal_config *internal_conf = rte_eal_sec_get_internal_config(sec_idx); + -+ rte_cfg->process_type = internal_cfg->process_type; ++ rte_cfg->process_type = internal_conf->process_type; + + __rte_eal_config_attach(mmap_flags, &mem_cfg_fd, + rte_eal_sec_get_runtime_dir(sec_idx), -+ internal_cfg, rte_cfg); ++ internal_conf, rte_cfg); + + close(mem_cfg_fd); +} @@ -965,174 +1371,94 @@ index 8bb1842..a1f2b42 100644 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */ static void eal_hugedirs_unlock(void) -@@ -566,6 +643,7 @@ eal_usage(const char *prgname) +@@ -548,6 +605,7 @@ eal_usage(const char *prgname) " --"OPT_LEGACY_MEM" Legacy memory mode (no dynamic allocation, contiguous segments)\n" " --"OPT_SINGLE_FILE_SEGMENTS" Put all hugepage memory in single files\n" " --"OPT_MATCH_ALLOCATIONS" Free hugepages exactly as allocated\n" + " --"OPT_MAP_PERFECT" Map virtual addresses according to configured hugepage size\n" "\n"); /* Allow the application to print its usage message too if hook is set */ - if ( rte_application_usage_hook ) { -@@ -693,7 +771,9 @@ eal_log_level_parse(int argc, char **argv) + if (hook) { +@@ -678,7 +736,9 @@ eal_log_level_parse(int argc, char **argv) /* Parse the argument given in the command line of the application */ static int -eal_parse_args(int argc, char **argv) -+__eal_parse_args(int argc, char **argv, char *runtime_dir, const int buflen, -+ struct internal_config *internal_cfg, ++__eal_parse_args(int argc, char **argv, const int sec_idx, ++ struct internal_config *internal_conf, + struct rte_config *rte_cfg) { int opt, ret; char **argvopt; -@@ -724,7 +804,7 @@ eal_parse_args(int argc, char **argv) - goto out; - } +@@ -687,8 +747,6 @@ eal_parse_args(int argc, char **argv) + const int old_optind = optind; + const int old_optopt = optopt; + char * const old_optarg = optarg; +- struct internal_config *internal_conf = +- eal_get_internal_configuration(); -- ret = eal_parse_common_option(opt, optarg, &internal_config); -+ ret = eal_parse_common_option(opt, optarg, internal_cfg); - /* common parser is not happy */ - if (ret < 0) { - eal_usage(prgname); -@@ -747,9 +827,9 @@ eal_parse_args(int argc, char **argv) - RTE_LOG(ERR, EAL, "Could not store hugepage directory\n"); - else { - /* free old hugepage dir */ -- if (internal_config.hugepage_dir != NULL) -- free(internal_config.hugepage_dir); -- internal_config.hugepage_dir = hdir; -+ if (internal_cfg->hugepage_dir != NULL) -+ free(internal_cfg->hugepage_dir); -+ internal_cfg->hugepage_dir = hdir; - } - break; - } -@@ -760,34 +840,34 @@ eal_parse_args(int argc, char **argv) - RTE_LOG(ERR, EAL, "Could not store file prefix\n"); - else { - /* free old prefix */ -- if (internal_config.hugefile_prefix != NULL) -- free(internal_config.hugefile_prefix); -- internal_config.hugefile_prefix = prefix; -+ if (internal_cfg->hugefile_prefix != NULL) -+ free(internal_cfg->hugefile_prefix); -+ internal_cfg->hugefile_prefix = prefix; - } - break; - } - case OPT_SOCKET_MEM_NUM: - if (eal_parse_socket_arg(optarg, -- internal_config.socket_mem) < 0) { -+ internal_cfg->socket_mem) < 0) { - RTE_LOG(ERR, EAL, "invalid parameters for --" - OPT_SOCKET_MEM "\n"); - eal_usage(prgname); - ret = -1; - goto out; - } -- internal_config.force_sockets = 1; -+ internal_cfg->force_sockets = 1; - break; - - case OPT_SOCKET_LIMIT_NUM: - if (eal_parse_socket_arg(optarg, -- internal_config.socket_limit) < 0) { -+ internal_cfg->socket_limit) < 0) { - RTE_LOG(ERR, EAL, "invalid parameters for --" - OPT_SOCKET_LIMIT "\n"); - eal_usage(prgname); - ret = -1; - goto out; - } -- internal_config.force_socket_limits = 1; -+ internal_cfg->force_socket_limits = 1; - break; - - case OPT_VFIO_INTR_NUM: -@@ -801,7 +881,7 @@ eal_parse_args(int argc, char **argv) - break; - - case OPT_CREATE_UIO_DEV_NUM: -- internal_config.create_uio_dev = 1; -+ internal_cfg->create_uio_dev = 1; - break; - - case OPT_MBUF_POOL_OPS_NAME_NUM: -@@ -811,17 +891,21 @@ eal_parse_args(int argc, char **argv) - RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n"); - else { - /* free old ops name */ -- if (internal_config.user_mbuf_pool_ops_name != -+ if (internal_cfg->user_mbuf_pool_ops_name != - NULL) -- free(internal_config.user_mbuf_pool_ops_name); -+ free(internal_cfg->user_mbuf_pool_ops_name); - -- internal_config.user_mbuf_pool_ops_name = -+ internal_cfg->user_mbuf_pool_ops_name = - ops_name; - } - break; - } + argvopt = argv; + optind = 1; +@@ -816,6 +874,9 @@ eal_parse_args(int argc, char **argv) case OPT_MATCH_ALLOCATIONS_NUM: -- internal_config.match_allocations = 1; -+ internal_cfg->match_allocations = 1; -+ break; -+ -+ case OPT_MAP_PERFECT_NUM: -+ internal_cfg->map_perfect = 1; + internal_conf->match_allocations = 1; break; ++ case OPT_MAP_PERFECT_NUM: ++ internal_conf->map_perfect = 1; ++ break; default: -@@ -844,20 +928,25 @@ eal_parse_args(int argc, char **argv) + if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { +@@ -837,7 +898,7 @@ eal_parse_args(int argc, char **argv) } - /* create runtime data directory */ -- if (internal_config.no_shconf == 0 && -- eal_create_runtime_dir() < 0) { -+ if (internal_cfg->no_shconf == 0 && -+ eal_create_runtime_dir(runtime_dir, buflen, internal_cfg) < 0) { - RTE_LOG(ERR, EAL, "Cannot create runtime directory\n"); - ret = -1; - goto out; + /* create runtime data directory. In no_shconf mode, skip any errors */ +- if (eal_create_runtime_dir() < 0) { ++ if (eal_create_runtime_dir(sec_idx) < 0) { + if (internal_conf->no_shconf == 0) { + RTE_LOG(ERR, EAL, "Cannot create runtime directory\n"); + ret = -1; +@@ -846,13 +907,18 @@ eal_parse_args(int argc, char **argv) + RTE_LOG(WARNING, EAL, "No DPDK runtime directory created\n"); } -- if (eal_adjust_config(&internal_config) != 0) { +- if (eal_adjust_config(internal_conf) != 0) { - ret = -1; - goto out; -+ if (!internal_cfg->pri_and_sec) { -+ ret = eal_adjust_config(internal_cfg); ++ if (!internal_conf->pri_and_sec) { ++ ret = eal_adjust_config(internal_conf); + if (ret != 0) + goto out; + } else { -+ ret = eal_sec_adjust_config(internal_cfg); ++ ret = eal_sec_adjust_config(internal_conf); + if (ret != 0) + goto out; } /* sanity checks */ -- if (eal_check_common_options(&internal_config) != 0) { -+ if (eal_check_common_options(internal_cfg, rte_cfg) != 0) { +- if (eal_check_common_options(internal_conf) != 0) { ++ if (eal_check_common_options(internal_conf, rte_cfg) != 0) { eal_usage(prgname); ret = -1; goto out; -@@ -876,6 +965,24 @@ eal_parse_args(int argc, char **argv) +@@ -871,6 +937,24 @@ eal_parse_args(int argc, char **argv) return ret; } +static int +eal_parse_args(int argc, char **argv) +{ -+ return __eal_parse_args(argc, argv, -+ rte_eal_get_runtime_dir(), PATH_MAX, -+ &internal_config, ++ struct internal_config *internal_conf = eal_get_internal_configuration(); ++ ++ return __eal_parse_args(argc, argv, -1, ++ internal_conf, + rte_eal_get_configuration()); +} + +static int +eal_sec_parse_args(int argc, char **argv, const int sec_idx) +{ -+ return __eal_parse_args(argc, argv, -+ rte_eal_sec_get_runtime_dir(sec_idx), PATH_MAX, ++ return __eal_parse_args(argc, argv, sec_idx, + rte_eal_sec_get_internal_config(sec_idx), + rte_eal_sec_get_configuration(sec_idx)); +} @@ -1140,7 +1466,7 @@ index 8bb1842..a1f2b42 100644 static int check_socket(const struct rte_memseg_list *msl, void *arg) { -@@ -1406,3 +1513,99 @@ rte_eal_check_module(const char *module_name) +@@ -1437,3 +1521,101 @@ rte_eal_check_module(const char *module_name) /* Module has been found */ return 1; } @@ -1152,7 +1478,7 @@ index 8bb1842..a1f2b42 100644 +{ + int ret; + int sec_idx = -1; -+ struct internal_config *lc_internal_cfg = NULL; ++ struct internal_config *lc_internal_conf = NULL; + + if (sec_count >= RTE_MAX_SECONDARY) { + RTE_LOG(ERR, EAL, "Too many secondary processes: %d.\n", sec_count); @@ -1161,21 +1487,21 @@ index 8bb1842..a1f2b42 100644 + } + + for (int i = 0; i < RTE_MAX_SECONDARY; ++i) { -+ if (sec_internal_config[i].pri_and_sec == 0) { -+ sec_internal_config[i].pri_and_sec = 1; ++ lc_internal_conf = rte_eal_sec_get_internal_config(i); ++ if (lc_internal_conf->pri_and_sec == 0) { ++ lc_internal_conf->pri_and_sec = 1; + sec_idx = i; + break; + } + } -+ lc_internal_cfg = rte_eal_sec_get_internal_config(sec_idx); + -+ eal_reset_internal_config(lc_internal_cfg); ++ eal_reset_internal_config(lc_internal_conf); + + ret = eal_sec_parse_args(argc, argv, sec_idx); + if (ret < 0) { + if (ret == -EALREADY) { + RTE_LOG(ERR, EAL, "file_refix %s already called initialization.\n", -+ lc_internal_cfg->hugefile_prefix); ++ lc_internal_conf->hugefile_prefix); + rte_errno = EALREADY; + } else { + RTE_LOG(ERR, EAL, "Invalid 'command line' arguments.\n"); @@ -1202,6 +1528,7 @@ index 8bb1842..a1f2b42 100644 +{ + int ret; + int sec_idx = -1; ++ struct internal_config *lc_internal_conf = NULL; + + if (!file_prefix || length <= 0) { + RTE_LOG(ERR, EAL, "Invalid 'file_prefix or length' arguments.\n"); @@ -1210,9 +1537,10 @@ index 8bb1842..a1f2b42 100644 + } + + for (int i = 0; i < RTE_MAX_SECONDARY; ++i) { -+ if (sec_internal_config[i].pri_and_sec == 0) ++ lc_internal_conf = rte_eal_sec_get_internal_config(i); ++ if (lc_internal_conf->pri_and_sec == 0) + continue; -+ if (!strncmp(sec_internal_config[i].hugefile_prefix, file_prefix, length)) { ++ if (!strncmp(lc_internal_conf->hugefile_prefix, file_prefix, length)) { + sec_idx = i; + break; + } @@ -1240,24 +1568,32 @@ index 8bb1842..a1f2b42 100644 + sec_count--; + return 0; +} -diff --git a/lib/librte_eal/linux/eal/eal_hugepage_info.c b/lib/librte_eal/linux/eal/eal_hugepage_info.c -index 91a4fed..911acec 100644 ---- a/lib/librte_eal/linux/eal/eal_hugepage_info.c -+++ b/lib/librte_eal/linux/eal/eal_hugepage_info.c -@@ -350,7 +350,7 @@ calc_num_pages(struct hugepage_info *hpi, struct dirent *dirent) +diff --git a/lib/eal/linux/eal_hugepage_info.c b/lib/eal/linux/eal_hugepage_info.c +index 9fb0e968db..41acf180ee 100644 +--- a/lib/eal/linux/eal_hugepage_info.c ++++ b/lib/eal/linux/eal_hugepage_info.c +@@ -389,7 +389,7 @@ calc_num_pages(struct hugepage_info *hpi, struct dirent *dirent) */ total_pages = 0; /* we also don't want to do this for legacy init */ -- if (!internal_config.legacy_mem) -+ if (!internal_config.legacy_mem || internal_config.map_perfect) +- if (!internal_conf->legacy_mem) ++ if (!internal_conf->legacy_mem || internal_conf->map_perfect) for (i = 0; i < rte_socket_count(); i++) { int socket = rte_socket_id_by_idx(i); unsigned int num_pages = -diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c -index cad4934..8e7f120 100644 ---- a/lib/librte_eal/linux/eal/eal_memalloc.c -+++ b/lib/librte_eal/linux/eal/eal_memalloc.c -@@ -95,12 +95,14 @@ static int fallocate_supported = -1; /* unknown */ +diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c +index fc354f4a17..dac9098c8c 100644 +--- a/lib/eal/linux/eal_memalloc.c ++++ b/lib/eal/linux/eal_memalloc.c +@@ -39,6 +39,7 @@ + #include + #include + #include ++#include + + #include "eal_filesystem.h" + #include "eal_internal_cfg.h" +@@ -95,12 +96,14 @@ static int fallocate_supported = -1; /* unknown */ * they will be initialized at startup, and filled as we allocate/deallocate * segments. */ @@ -1274,7 +1610,7 @@ index cad4934..8e7f120 100644 /** local copy of a memory map, used to synchronize memory hotplug in MP */ static struct rte_memseg_list local_memsegs[RTE_MAX_MEMSEG_LISTS]; -@@ -1391,13 +1393,13 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl, +@@ -1462,7 +1465,7 @@ secondary_msl_destroy_walk(const struct rte_memseg_list *msl, } static int @@ -1283,14 +1619,16 @@ index cad4934..8e7f120 100644 { int *data; int i; +@@ -1470,7 +1473,7 @@ alloc_list(int list_idx, int len) + eal_get_internal_configuration(); /* single-file segments mode does not need fd list */ -- if (!internal_config.single_file_segments) { -+ if (!internal_config.single_file_segments) { // sec todo +- if (!internal_conf->single_file_segments) { ++ if (!internal_conf->single_file_segments) { // sec todo /* ensure we have space to store fd per each possible segment */ data = malloc(sizeof(int) * len); if (data == NULL) { -@@ -1407,19 +1409,31 @@ alloc_list(int list_idx, int len) +@@ -1480,24 +1483,36 @@ alloc_list(int list_idx, int len) /* set all fd's as invalid */ for (i = 0; i < len; i++) data[i] = -1; @@ -1326,42 +1664,34 @@ index cad4934..8e7f120 100644 +} + static int - fd_list_create_walk(const struct rte_memseg_list *msl, - void *arg __rte_unused) -@@ -1437,27 +1451,71 @@ fd_list_create_walk(const struct rte_memseg_list *msl, - return alloc_list(msl_idx, len); + destroy_list(int list_idx) + { + const struct internal_config *internal_conf = +- eal_get_internal_configuration(); ++ eal_get_internal_configuration(); + + /* single-file segments mode does not need fd list */ + if (!internal_conf->single_file_segments) { +@@ -1552,29 +1567,54 @@ fd_list_destroy_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) + return destroy_list(msl_idx); } -int -eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd) +static int -+fd_list_destroy_walk(const struct rte_memseg_list *msl, const int sec_idx) - { -- struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; -+ struct rte_mem_config *mcfg = rte_eal_sec_get_configuration(sec_idx)->mem_config; -+ struct fd_list *fd_ls = sec_fd_list[sec_idx]; -+ int list_idx; -+ -+ list_idx = msl - mcfg->memsegs; -+ if (fd_ls[list_idx].len != 0) { -+ free(fd_ls[list_idx].fds); -+ /* We have closed fd, seeing in function of eal_legacy_hugepage_attach. */ -+ //close(fd_ls[list_idx].fds[seg_idx]); -+ } -+ memset(&fd_ls[list_idx], 0, sizeof(fd_ls[list_idx])); -+ -+ return 0; -+} -+ -+static int +__eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd, + const struct rte_config *rte_cfg, struct fd_list *fd_ls) -+{ + { +- struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; +- const struct internal_config *internal_conf = +- eal_get_internal_configuration(); +- + struct rte_mem_config *mcfg = rte_cfg->mem_config; - ++ const struct internal_config *internal_conf = eal_get_internal_configuration(); ++ /* single file segments mode doesn't support individual segment fd's */ -- if (internal_config.single_file_segments) -+ if (internal_config.single_file_segments) // sec todo +- if (internal_conf->single_file_segments) ++ if (internal_conf->single_file_segments) // sec todo return -ENOTSUP; /* if list is not allocated, allocate it */ @@ -1382,13 +1712,13 @@ index cad4934..8e7f120 100644 +int +eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd) +{ -+ return __eal_memalloc_set_seg_fd(list_idx, seg_idx, fd, -+ rte_eal_get_configuration(), fd_list); ++ return __eal_memalloc_set_seg_fd(list_idx, seg_idx, fd, ++ rte_eal_get_configuration(), fd_list); +} + +int +eal_sec_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd, -+ const int switch_pri_and_sec, const int sec_idx) ++ const int switch_pri_and_sec, const int sec_idx) +{ + struct rte_config *rte_cfg = NULL; + struct fd_list *fd_ls = NULL; @@ -1407,88 +1737,107 @@ index cad4934..8e7f120 100644 int eal_memalloc_set_seg_list_fd(int list_idx, int fd) { -@@ -1602,3 +1660,38 @@ eal_memalloc_init(void) +@@ -1749,3 +1789,49 @@ eal_memalloc_init(void) return -1; return 0; } + -+int -+eal_memalloc_destroy(const int sec_idx) ++static int ++fd_sec_list_destroy_walk(const struct rte_memseg_list *msl, const int sec_idx) +{ -+ int msl_idx = 0; -+ struct rte_memseg_list *msl; + struct rte_mem_config *mcfg = rte_eal_sec_get_configuration(sec_idx)->mem_config; -+ -+ for (msl_idx = 0; msl_idx < RTE_MAX_MEMSEG_LISTS; msl_idx++) { -+ -+ msl = &mcfg->memsegs[msl_idx]; -+ -+ /* skip empty memseg lists */ -+ if (msl->memseg_arr.len == 0) -+ continue; -+ -+ if (rte_sec_fbarray_destroy(&msl->memseg_arr, sec_idx)) { -+ RTE_LOG(ERR, EAL, "Cannot clear secondary process local memseg lists\n"); -+ return -1; -+ } -+ -+ if (munmap(msl->base_va, msl->len) < 0) { -+ RTE_LOG(ERR, EAL, "Failed to unmap memseg lists\n"); -+ return -1; -+ } -+ memset(msl, 0, sizeof(*msl)); ++ struct fd_list *fd_ls = sec_fd_list[sec_idx]; ++ int list_idx; + -+ if (fd_list_destroy_walk(msl, sec_idx)) { ++ list_idx = msl - mcfg->memsegs; ++ if (fd_ls[list_idx].len != 0) { ++ free(fd_ls[list_idx].fds); ++ /* We have closed fd, seeing in function of eal_legacy_hugepage_attach. */ ++ //close(fd_ls[list_idx].fds[seg_idx]); ++ } ++ memset(&fd_ls[list_idx], 0, sizeof(fd_ls[list_idx])); ++ ++ return 0; ++} ++ ++int ++eal_sec_memalloc_destroy(const int sec_idx) ++{ ++ struct rte_mem_config *mcfg = rte_eal_sec_get_configuration(sec_idx)->mem_config; ++ int i, ret = 0; ++ ++ for (i = 0; i < RTE_MAX_MEMSEG_LISTS; i++) { ++ struct rte_memseg_list *msl = &mcfg->memsegs[i]; ++ ++ if (msl->base_va == NULL) ++ continue; ++ ++ if (fd_sec_list_destroy_walk(msl, sec_idx)) { + RTE_LOG(ERR, EAL, "Failed to clear secondary fd_list.\n"); + return -1; + } ++ ++ ret = rte_sec_fbarray_destroy(&msl->memseg_arr, sec_idx); ++ if (ret) ++ return ret; ++ ++ rte_mem_unmap(msl->base_va, msl->len); ++ memset(msl, 0, sizeof(*msl)); + } + + return 0; +} -diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c -index 43e4ffc..ac81f43 100644 ---- a/lib/librte_eal/linux/eal/eal_memory.c -+++ b/lib/librte_eal/linux/eal/eal_memory.c -@@ -1055,10 +1055,10 @@ remap_needed_hugepages(struct hugepage_file *hugepages, int n_pages) +diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c +index 03a4f2dd2d..4d78a47e0a 100644 +--- a/lib/eal/linux/eal_memory.c ++++ b/lib/eal/linux/eal_memory.c +@@ -992,6 +992,7 @@ static int + remap_needed_hugepages(struct hugepage_file *hugepages, int n_pages) + { + int cur_page, seg_start_page, new_memseg, ret; ++ const struct internal_config *internal_conf = eal_get_internal_configuration(); + + seg_start_page = 0; + for (cur_page = 0; cur_page < n_pages; cur_page++) { +@@ -1017,10 +1018,10 @@ remap_needed_hugepages(struct hugepage_file *hugepages, int n_pages) * address to lower address. Here, physical addresses are in * descending order. */ - else if ((prev->physaddr - cur->physaddr) != cur->size) -+ else if (!internal_config.map_perfect && (prev->physaddr - cur->physaddr) != cur->size) ++ else if (!internal_conf->map_perfect && (prev->physaddr - cur->physaddr) != cur->size) new_memseg = 1; #else - else if ((cur->physaddr - prev->physaddr) != cur->size) -+ else if (!internal_config.map_perfect && (cur->physaddr - prev->physaddr) != cur->size) ++ else if (!internal_conf->map_perfect && (cur->physaddr - prev->physaddr) != cur->size) new_memseg = 1; #endif -@@ -1457,6 +1457,24 @@ eal_legacy_hugepage_init(void) +@@ -1235,6 +1236,24 @@ eal_legacy_hugepage_init(void) + for (i = 0; i < (int) internal_conf->num_hugepage_sizes; i++) { /* meanwhile, also initialize used_hp hugepage sizes in used_hp */ - used_hp[i].hugepage_sz = internal_config.hugepage_info[i].hugepage_sz; - -+ if (internal_config.map_perfect) { + used_hp[i].hugepage_sz = internal_conf->hugepage_info[i].hugepage_sz; ++ ++ if (internal_conf->map_perfect) { + int sys_num_pages = 0; + int need_num_pages = 0; + struct rte_memseg_list *msl; -+ ++ + for (j = 0; j < RTE_MAX_NUMA_NODES; j++) { -+ sys_num_pages += internal_config.hugepage_info[i].num_pages[j]; ++ sys_num_pages += internal_conf->hugepage_info[i].num_pages[j]; + } -+ ++ + for (j = 0; j < RTE_MAX_MEMSEG_LISTS; j++) { + msl = &mcfg->memsegs[j]; -+ if (internal_config.hugepage_info[i].hugepage_sz == msl->page_sz) ++ if (internal_conf->hugepage_info[i].hugepage_sz == msl->page_sz) + need_num_pages += msl->memseg_arr.len; -+ } -+ -+ internal_config.hugepage_info[i].num_pages[0] = RTE_MIN(sys_num_pages, need_num_pages); -+ } ++ } + - nr_hugepages += internal_config.hugepage_info[i].num_pages[0]; - } ++ internal_conf->hugepage_info[i].num_pages[0] = RTE_MIN(sys_num_pages, need_num_pages); ++ } -@@ -1537,8 +1555,13 @@ eal_legacy_hugepage_init(void) + nr_hugepages += internal_conf->hugepage_info[i].num_pages[0]; + } +@@ -1316,8 +1335,13 @@ eal_legacy_hugepage_init(void) goto fail; } @@ -1497,14 +1846,14 @@ index 43e4ffc..ac81f43 100644 + /* continuous physical memory does not bring performance improvements, + * so no sorting is performed for quick startup. + */ -+ if (!internal_config.map_perfect) { ++ if (!internal_conf->map_perfect) { + qsort(&tmp_hp[hp_offset], hpi->num_pages[0], + sizeof(struct hugepage_file), cmp_physaddr); + } /* we have processed a num of hugepages of this size, so inc offset */ hp_offset += hpi->num_pages[0]; -@@ -1857,9 +1880,9 @@ getFileSize(int fd) +@@ -1502,9 +1526,9 @@ getFileSize(int fd) * in order to form a contiguous block in the virtual memory space */ static int @@ -1516,22 +1865,22 @@ index 43e4ffc..ac81f43 100644 struct hugepage_file *hp = NULL; unsigned int num_hp = 0; unsigned int i = 0; -@@ -1867,6 +1890,22 @@ eal_legacy_hugepage_attach(void) +@@ -1512,6 +1536,22 @@ eal_legacy_hugepage_attach(void) off_t size = 0; int fd, fd_hugepage = -1; + struct rte_config *rte_cfg = NULL; -+ struct internal_config *internal_cfg = NULL; ++ struct internal_config *internal_conf = NULL; + char *runtime_dir = NULL; + + if (!switch_pri_and_sec) { + runtime_dir = rte_eal_get_runtime_dir(); + rte_cfg = rte_eal_get_configuration(); -+ internal_cfg = &internal_config; ++ internal_conf = eal_get_internal_configuration(); + } else { + runtime_dir = rte_eal_sec_get_runtime_dir(sec_idx); + rte_cfg = rte_eal_sec_get_configuration(sec_idx); -+ internal_cfg = rte_eal_sec_get_internal_config(sec_idx); ++ internal_conf = rte_eal_sec_get_internal_config(sec_idx); + } + + mcfg = rte_cfg->mem_config; @@ -1539,7 +1888,7 @@ index 43e4ffc..ac81f43 100644 if (aslr_enabled() > 0) { RTE_LOG(WARNING, EAL, "WARNING: Address Space Layout Randomization " "(ASLR) is enabled in the kernel.\n"); -@@ -1874,10 +1913,10 @@ eal_legacy_hugepage_attach(void) +@@ -1519,10 +1559,10 @@ eal_legacy_hugepage_attach(void) "into secondary processes\n"); } @@ -1552,7 +1901,7 @@ index 43e4ffc..ac81f43 100644 goto error; } -@@ -1885,7 +1924,7 @@ eal_legacy_hugepage_attach(void) +@@ -1530,7 +1570,7 @@ eal_legacy_hugepage_attach(void) hp = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd_hugepage, 0); if (hp == MAP_FAILED) { RTE_LOG(ERR, EAL, "Could not mmap %s\n", @@ -1561,7 +1910,7 @@ index 43e4ffc..ac81f43 100644 goto error; } -@@ -1932,13 +1971,13 @@ eal_legacy_hugepage_attach(void) +@@ -1577,13 +1617,13 @@ eal_legacy_hugepage_attach(void) } /* find segment data */ @@ -1570,21 +1919,21 @@ index 43e4ffc..ac81f43 100644 if (msl == NULL) { RTE_LOG(DEBUG, EAL, "%s(): Cannot find memseg list\n", __func__); - goto fd_error; + goto mmap_error; } - ms = rte_mem_virt2memseg(map_addr, msl); + ms = rte_sec_mem_virt2memseg(map_addr, msl, rte_cfg); if (ms == NULL) { RTE_LOG(DEBUG, EAL, "%s(): Cannot find memseg\n", __func__); -@@ -1953,8 +1992,16 @@ eal_legacy_hugepage_attach(void) - goto fd_error; +@@ -1598,8 +1638,16 @@ eal_legacy_hugepage_attach(void) + goto mmap_error; } + /* No hugefile lock is required in PRI_AND_SEC mode, close it + * to avoid opening too much fd. + */ -+ if (internal_cfg->pri_and_sec) { ++ if (internal_conf->pri_and_sec) { + close(fd); + fd = -1; + } @@ -1595,136 +1944,29 @@ index 43e4ffc..ac81f43 100644 RTE_LOG(ERR, EAL, "Could not store segment fd: %s\n", rte_strerror(rte_errno)); } -@@ -2003,10 +2050,17 @@ rte_eal_hugepage_init(void) +@@ -1648,13 +1696,17 @@ rte_eal_hugepage_init(void) } int -rte_eal_hugepage_attach(void) +rte_eal_hugepage_attach(const int switch_pri_and_sec, const int sec_idx) { -- return internal_config.legacy_mem ? -- eal_legacy_hugepage_attach() : -+ struct internal_config *internal_cfg; -+ +- const struct internal_config *internal_conf = +- eal_get_internal_configuration(); ++ struct internal_config *internal_conf; ++ + if (!switch_pri_and_sec) -+ internal_cfg = &internal_config; ++ internal_conf = eal_get_internal_configuration(); + else -+ internal_cfg = rte_eal_sec_get_internal_config(sec_idx); -+ -+ return internal_cfg->legacy_mem ? ++ internal_conf = rte_eal_sec_get_internal_config(sec_idx); + + return internal_conf->legacy_mem ? +- eal_legacy_hugepage_attach() : + eal_legacy_hugepage_attach(switch_pri_and_sec, sec_idx) : eal_hugepage_attach(); } -@@ -2215,6 +2269,50 @@ memseg_primary_init_32(void) - return 0; - } - -+static int -+eal_sec_set_num_pages(struct internal_config *internal_cfg, -+ struct hugepage_info *used_hp) -+{ -+ int ret; -+ int hp_sz_idx; -+ uint64_t memory[RTE_MAX_NUMA_NODES]; -+ -+ if (!internal_cfg || !used_hp) { -+ return -1; -+ } -+ -+ for (hp_sz_idx = 0; -+ hp_sz_idx < (int) internal_cfg->num_hugepage_sizes; -+ hp_sz_idx++) { -+ struct hugepage_info *hpi; -+ hpi = &internal_cfg->hugepage_info[hp_sz_idx]; -+ used_hp[hp_sz_idx].hugepage_sz = hpi->hugepage_sz; -+ } -+ -+ for (hp_sz_idx = 0; hp_sz_idx < RTE_MAX_NUMA_NODES; hp_sz_idx++) -+ memory[hp_sz_idx] = internal_cfg->socket_mem[hp_sz_idx]; -+ -+ ret = calc_num_pages_per_socket(memory, -+ internal_cfg->hugepage_info, used_hp, -+ internal_cfg->num_hugepage_sizes); -+ -+ return ret; -+} -+ -+static int -+eal_sec_get_num_pages(const struct hugepage_info *used_hp, -+ uint64_t hugepage_sz, int socket) -+{ -+ int hp_sz_idx; -+ -+ for (hp_sz_idx = 0; hp_sz_idx < MAX_HUGEPAGE_SIZES; hp_sz_idx++) { -+ if (used_hp[hp_sz_idx].hugepage_sz == hugepage_sz) -+ return used_hp[hp_sz_idx].num_pages[socket]; -+ } -+ -+ return 0; -+} -+ - static int __rte_unused - memseg_primary_init(void) - { -@@ -2228,11 +2326,20 @@ memseg_primary_init(void) - uint64_t max_mem, max_mem_per_type; - unsigned int max_seglists_per_type; - unsigned int n_memtypes, cur_type; -+ struct hugepage_info used_hp[MAX_HUGEPAGE_SIZES]; - - /* no-huge does not need this at all */ - if (internal_config.no_hugetlbfs) - return 0; - -+ if (internal_config.map_perfect) { -+ memset(used_hp, 0, sizeof(used_hp)); -+ ret = eal_sec_set_num_pages(&internal_config, used_hp); -+ if (ret == -1) { -+ RTE_LOG(ERR, EAL, "Cannot get num pages\n"); -+ } -+ } -+ - /* - * figuring out amount of memory we're going to have is a long and very - * involved process. the basic element we're operating with is a memory -@@ -2329,6 +2436,7 @@ memseg_primary_init(void) - struct memtype *type = &memtypes[cur_type]; - uint64_t max_mem_per_list, pagesz; - int socket_id; -+ unsigned int need_n_segs, cur_n_segs; - - pagesz = type->page_sz; - socket_id = type->socket_id; -@@ -2372,8 +2480,17 @@ memseg_primary_init(void) - "n_segs:%i socket_id:%i hugepage_sz:%" PRIu64 "\n", - n_seglists, n_segs, socket_id, pagesz); - -+ if (internal_config.map_perfect) -+ need_n_segs = eal_sec_get_num_pages(used_hp, pagesz, socket_id); -+ else -+ need_n_segs = n_segs; -+ - /* create all segment lists */ -- for (cur_seglist = 0; cur_seglist < n_seglists; cur_seglist++) { -+ for (cur_seglist = 0; cur_seglist < n_seglists && need_n_segs > 0; cur_seglist++) { -+ cur_n_segs = RTE_MIN(need_n_segs, n_segs); -+ if (internal_config.map_perfect) -+ need_n_segs -= cur_n_segs; -+ - if (msl_idx >= RTE_MAX_MEMSEG_LISTS) { - RTE_LOG(ERR, EAL, - "No more space in memseg lists, please increase %s\n", -@@ -2382,7 +2499,7 @@ memseg_primary_init(void) - } - msl = &mcfg->memsegs[msl_idx++]; - -- if (alloc_memseg_list(msl, pagesz, n_segs, -+ if (alloc_memseg_list(msl, pagesz, cur_n_segs, - socket_id, cur_seglist)) - goto out; - -@@ -2400,9 +2517,10 @@ memseg_primary_init(void) +@@ -1873,9 +1925,10 @@ memseg_primary_init(void) } static int @@ -1737,7 +1979,7 @@ index 43e4ffc..ac81f43 100644 int msl_idx = 0; struct rte_memseg_list *msl; -@@ -2414,7 +2532,7 @@ memseg_secondary_init(void) +@@ -1887,7 +1940,7 @@ memseg_secondary_init(void) if (msl->memseg_arr.len == 0) continue; @@ -1746,7 +1988,7 @@ index 43e4ffc..ac81f43 100644 RTE_LOG(ERR, EAL, "Cannot attach to primary process memseg lists\n"); return -1; } -@@ -2430,11 +2548,18 @@ memseg_secondary_init(void) +@@ -1903,11 +1956,18 @@ memseg_secondary_init(void) } int @@ -1763,10 +2005,10 @@ index 43e4ffc..ac81f43 100644 + rte_cfg = rte_eal_sec_get_configuration(sec_idx); + } + - if (getrlimit(RLIMIT_NOFILE, &lim) == 0) { - /* set limit to maximum */ - lim.rlim_cur = lim.rlim_max; -@@ -2458,11 +2583,11 @@ rte_eal_memseg_init(void) + #ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES + const struct internal_config *internal_conf = + eal_get_internal_configuration(); +@@ -1935,11 +1995,11 @@ rte_eal_memseg_init(void) } #endif @@ -1780,12 +2022,12 @@ index 43e4ffc..ac81f43 100644 - memseg_secondary_init(); + memseg_secondary_init(rte_cfg, switch_pri_and_sec, sec_idx); } -diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h -index 2a9f768..0eb3a48 100644 ---- a/lib/librte_ring/rte_ring.h -+++ b/lib/librte_ring/rte_ring.h -@@ -953,6 +953,81 @@ rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, - r->cons.single, available); +diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h +index da17ed6d7c..ef18a2b39b 100644 +--- a/lib/ring/rte_ring.h ++++ b/lib/ring/rte_ring.h +@@ -802,6 +802,81 @@ rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, + n, available); } +/****** APIs for libnet ******/ @@ -1806,7 +2048,7 @@ index 2a9f768..0eb3a48 100644 + r->prod.head = old_head + n; + rte_smp_rmb(); + -+ DEQUEUE_PTRS(r, &r[1], old_head, obj_table, n, void *); ++ __rte_ring_dequeue_elems(r, old_head, obj_table, sizeof(void *), n); + return n; +} + @@ -1834,7 +2076,7 @@ index 2a9f768..0eb3a48 100644 + const uint32_t new_tail = old_tail + n; + rte_smp_rmb(); + -+ DEQUEUE_PTRS(r, &r[1], old_tail, obj_table, n, void *); ++ __rte_ring_dequeue_elems(r, old_tail, obj_table, sizeof(void *), n); + rte_smp_rmb(); + + r->cons.tail = new_tail; @@ -1856,7 +2098,7 @@ index 2a9f768..0eb3a48 100644 + const uint32_t new_head = old_head + n; + rte_smp_rmb(); + -+ ENQUEUE_PTRS(r, &r[1], old_head, obj_table, n, void *); ++ __rte_ring_enqueue_elems(r, old_head, obj_table, sizeof(void *), n); + rte_smp_wmb(); + + r->cons.head = new_head; @@ -1867,5 +2109,5 @@ index 2a9f768..0eb3a48 100644 } #endif -- -2.30.0 +2.27.0 diff --git a/0008-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262.patch b/0008-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262.patch deleted file mode 100644 index 170eb50..0000000 --- a/0008-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 145e9a29777cc660bd031670a7aeb8a4d3cb88a8 Mon Sep 17 00:00:00 2001 -From: zhuhengbo -Date: Thu, 30 Apr 2020 02:53:08 -0400 -Subject: [PATCH] dpdk: fix cpu flag error in Intel(R) Xeon(R) CPU E5-2620 v3 @ - 2.40GHz - -Signed-off-by: zhuhengbo ---- - config/defconfig_x86_64-cpu_v2-linux-gcc | 1 + - config/defconfig_x86_64-cpu_v2-linuxapp-gcc | 14 ++++++++ - mk/machine/cpu_v2/rte.vars.mk | 39 +++++++++++++++++++++ - 3 files changed, 54 insertions(+) - create mode 120000 config/defconfig_x86_64-cpu_v2-linux-gcc - create mode 100644 config/defconfig_x86_64-cpu_v2-linuxapp-gcc - create mode 100644 mk/machine/cpu_v2/rte.vars.mk - -diff --git a/config/defconfig_x86_64-cpu_v2-linux-gcc b/config/defconfig_x86_64-cpu_v2-linux-gcc -new file mode 120000 -index 0000000..64f21b6 ---- /dev/null -+++ b/config/defconfig_x86_64-cpu_v2-linux-gcc -@@ -0,0 +1 @@ -+defconfig_x86_64-cpu_v2-linuxapp-gcc -\ No newline at end of file -diff --git a/config/defconfig_x86_64-cpu_v2-linuxapp-gcc b/config/defconfig_x86_64-cpu_v2-linuxapp-gcc -new file mode 100644 -index 0000000..2748e30 ---- /dev/null -+++ b/config/defconfig_x86_64-cpu_v2-linuxapp-gcc -@@ -0,0 +1,14 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+# Copyright(c) 2010-2014 Intel Corporation -+ -+#include "common_linux" -+ -+CONFIG_RTE_MACHINE="cpu_v2" -+ -+CONFIG_RTE_ARCH="x86_64" -+CONFIG_RTE_ARCH_X86_64=y -+CONFIG_RTE_ARCH_X86=y -+CONFIG_RTE_ARCH_64=y -+ -+CONFIG_RTE_TOOLCHAIN="gcc" -+CONFIG_RTE_TOOLCHAIN_GCC=y -diff --git a/mk/machine/cpu_v2/rte.vars.mk b/mk/machine/cpu_v2/rte.vars.mk -new file mode 100644 -index 0000000..ffa7d3f ---- /dev/null -+++ b/mk/machine/cpu_v2/rte.vars.mk -@@ -0,0 +1,39 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+# Copyright(c) 2010-2014 Intel Corporation -+ -+# -+# machine: -+# -+# - can define ARCH variable (overridden by cmdline value) -+# - can define CROSS variable (overridden by cmdline value) -+# - define MACHINE_CFLAGS variable (overridden by cmdline value) -+# - define MACHINE_LDFLAGS variable (overridden by cmdline value) -+# - define MACHINE_ASFLAGS variable (overridden by cmdline value) -+# - can define CPU_CFLAGS variable (overridden by cmdline value) that -+# overrides the one defined in arch. -+# - can define CPU_LDFLAGS variable (overridden by cmdline value) that -+# overrides the one defined in arch. -+# - can define CPU_ASFLAGS variable (overridden by cmdline value) that -+# overrides the one defined in arch. -+# - may override any previously defined variable -+# -+ -+# ARCH = -+# CROSS = -+# MACHINE_CFLAGS = -+# MACHINE_LDFLAGS = -+# MACHINE_ASFLAGS = -+# CPU_CFLAGS = -+# CPU_LDFLAGS = -+# CPU_ASFLAGS = -+ -+MACHINE_CFLAGS = -march=core-avx-i -+ -+# On FreeBSD systems, sometimes the correct CPU type is not picked up. -+# To get everything to compile, we need SSE4.2 support, so check if that is -+# reported by compiler. If not, check if the CPU actually supports it, and if -+# so, set the compilation target to be a corei7, minimum target with SSE4.2. -+SSE42_SUPPORT=$(shell $(CC) -march=native -dM -E - +Date: Sat, 18 Dec 2021 16:45:51 +0800 +Subject: [PATCH] + huawei-0008-dpdk-fix-error-in-clearing-secondary-process-memseg-lists + +--- + lib/eal/common/eal_common_fbarray.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c +index 9c125c104c..d4a4cea7c1 100644 +--- a/lib/eal/common/eal_common_fbarray.c ++++ b/lib/eal/common/eal_common_fbarray.c +@@ -1102,7 +1102,7 @@ int + rte_sec_fbarray_destroy(struct rte_fbarray *arr, + const int sec_idx) + { +- int fd, ret; ++ int fd; + char path[PATH_MAX]; + + if (arr == NULL) { +@@ -1128,15 +1128,13 @@ rte_sec_fbarray_destroy(struct rte_fbarray *arr, + if (flock(fd, LOCK_EX | LOCK_NB)) { + RTE_LOG(DEBUG, EAL, "Cannot destroy fbarray - another process is using it\n"); + rte_errno = EBUSY; +- ret = -1; + } else { +- ret = 0; + unlink(path); + memset(arr, 0, sizeof(*arr)); + } + close(fd); + +- return ret; ++ return 0; + } + + void * +-- +2.27.0 + diff --git a/0010-dpdk-fix-coredump-when-primary-process-attach-without-shared-file.patch b/0010-dpdk-fix-coredump-when-primary-process-attach-without-shared-file.patch new file mode 100644 index 0000000..665e213 --- /dev/null +++ b/0010-dpdk-fix-coredump-when-primary-process-attach-without-shared-file.patch @@ -0,0 +1,61 @@ +From 097d8acb68c7d7dbfd7800c7f69eaf171ce9da4b Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Sat, 18 Dec 2021 16:49:16 +0800 +Subject: [PATCH] 0009 + +--- + lib/eal/linux/eal.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index f269e67fae..2555043155 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -524,22 +524,29 @@ rte_config_init(void) + return 0; + } + +-static void ++static int + rte_sec_config_init(const int sec_idx) + { + int mem_cfg_fd = -1; + int mmap_flags = PROT_READ | PROT_WRITE; ++ int ret = -1; + + struct rte_config *rte_cfg = rte_eal_sec_get_configuration(sec_idx); + struct internal_config *internal_conf = rte_eal_sec_get_internal_config(sec_idx); + + rte_cfg->process_type = internal_conf->process_type; + +- __rte_eal_config_attach(mmap_flags, &mem_cfg_fd, ++ ret = __rte_eal_config_attach(mmap_flags, &mem_cfg_fd, + rte_eal_sec_get_runtime_dir(sec_idx), + internal_conf, rte_cfg); ++ if (ret < 0) { ++ RTE_LOG(ERR, EAL, "Cannot attach shared memory\n"); ++ return -1; ++ } ++ + + close(mem_cfg_fd); ++ return 0; + } + + static int +@@ -1561,7 +1568,11 @@ rte_eal_sec_attach(int argc, char **argv) + return -1; + } + +- rte_sec_config_init(sec_idx); ++ ret = rte_sec_config_init(sec_idx); ++ if (ret < 0) { ++ RTE_LOG(ERR, EAL, "Cannot init sec config\n"); ++ return -1; ++ } + + ret = rte_eal_sec_memory_init(sec_idx); + if (ret < 0) { +-- +2.27.0 + diff --git a/0010-dpdk-fix-error-in-clearing-secondary-process-memseg-lists.patch b/0010-dpdk-fix-error-in-clearing-secondary-process-memseg-lists.patch deleted file mode 100644 index ddb4c02..0000000 --- a/0010-dpdk-fix-error-in-clearing-secondary-process-memseg-lists.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 4bda889d737ee2b1fb2381e658bcf4f2a7ca21c8 Mon Sep 17 00:00:00 2001 -From: HuangLiming -Date: Tue, 18 Aug 2020 04:58:53 -0400 -Subject: [PATCH] fix error in clearing secondary process memseg lists - -Signed-off-by: HuangLiming ---- - lib/librte_eal/common/eal_common_fbarray.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c -index b611ffa..116c695 100644 ---- a/lib/librte_eal/common/eal_common_fbarray.c -+++ b/lib/librte_eal/common/eal_common_fbarray.c -@@ -1105,7 +1105,7 @@ int - rte_sec_fbarray_destroy(struct rte_fbarray *arr, - const int sec_idx) - { -- int fd, ret; -+ int fd; - size_t mmap_len; - char path[PATH_MAX]; - -@@ -1134,15 +1134,13 @@ rte_sec_fbarray_destroy(struct rte_fbarray *arr, - if (flock(fd, LOCK_EX | LOCK_NB)) { - RTE_LOG(DEBUG, EAL, "Cannot destroy fbarray - another process is using it\n"); - rte_errno = EBUSY; -- ret = -1; - } else { -- ret = 0; - unlink(path); - memset(arr, 0, sizeof(*arr)); - } - close(fd); - -- return ret; -+ return 0; - } - - void * --- -2.21.0 - diff --git a/0011-dpdk-fix-coredump-when-primary-process-attach-without-shared-file.patch b/0011-dpdk-fix-coredump-when-primary-process-attach-without-shared-file.patch deleted file mode 100644 index 8696044..0000000 --- a/0011-dpdk-fix-coredump-when-primary-process-attach-without-shared-file.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 561a37288d629398f976dfa4e57854b7ea484cc7 Mon Sep 17 00:00:00 2001 -From: yuanyunkang -Date: Sat, 22 Aug 2020 14:39:16 +0800 -Subject: [PATCH] dpdk:fix coredump when primary process attach without shared - file - -Signed-off-by: yuanyunkang ---- - lib/librte_eal/linux/eal/eal.c | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c -index a1f2b42..ff86ff9 100644 ---- a/lib/librte_eal/linux/eal/eal.c -+++ b/lib/librte_eal/linux/eal/eal.c -@@ -569,22 +569,28 @@ rte_config_init(void) - return 0; - } - --static void -+static int - rte_sec_config_init(const int sec_idx) - { - int mem_cfg_fd = -1; - int mmap_flags = PROT_READ | PROT_WRITE; -+ int ret = -1; - - struct rte_config *rte_cfg = rte_eal_sec_get_configuration(sec_idx); - struct internal_config *internal_cfg = rte_eal_sec_get_internal_config(sec_idx); - - rte_cfg->process_type = internal_cfg->process_type; - -- __rte_eal_config_attach(mmap_flags, &mem_cfg_fd, -+ ret = __rte_eal_config_attach(mmap_flags, &mem_cfg_fd, - rte_eal_sec_get_runtime_dir(sec_idx), - internal_cfg, rte_cfg); -+ if (ret < 0) { -+ RTE_LOG(ERR, EAL, "Cannot attach shared memory\n"); -+ return -1; -+ } - - close(mem_cfg_fd); -+ return 0; - } - - static int -@@ -1553,7 +1559,11 @@ rte_eal_sec_attach(int argc, char **argv) - return -1; - } - -- rte_sec_config_init(sec_idx); -+ ret = rte_sec_config_init(sec_idx); -+ if (ret < 0) { -+ RTE_LOG(ERR, EAL, "Cannot init sec config\n"); -+ return -1; -+ } - - ret = rte_eal_sec_memory_init(sec_idx); - if (ret < 0) { --- -2.19.1 - diff --git a/0011-dpdk-fix-fbarray-memseg-destory-error-during-detach.patch b/0011-dpdk-fix-fbarray-memseg-destory-error-during-detach.patch new file mode 100644 index 0000000..abd1d2d --- /dev/null +++ b/0011-dpdk-fix-fbarray-memseg-destory-error-during-detach.patch @@ -0,0 +1,27 @@ +From dad8149d187448f85be497ce3bb6c34bf1ffde5e Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Sat, 18 Dec 2021 16:54:03 +0800 +Subject: [PATCH] 0010 + +--- + lib/eal/common/eal_common_fbarray.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c +index d4a4cea7c1..fa726cd2f5 100644 +--- a/lib/eal/common/eal_common_fbarray.c ++++ b/lib/eal/common/eal_common_fbarray.c +@@ -1122,8 +1122,8 @@ rte_sec_fbarray_destroy(struct rte_fbarray *arr, + + fd = open(path, O_RDONLY); + if (fd < 0) { +- RTE_LOG(ERR, EAL, "Could not open fbarray file: %s\n", strerror(errno)); +- return -1; ++ RTE_LOG(WARNING, EAL, "Could not open %s: %s, and just skip it\n", path, strerror(errno)); ++ return 0; + } + if (flock(fd, LOCK_EX | LOCK_NB)) { + RTE_LOG(DEBUG, EAL, "Cannot destroy fbarray - another process is using it\n"); +-- +2.27.0 + diff --git a/0012-dpdk-fix-fbarray-memseg-destory-error-during-detach.patch b/0012-dpdk-fix-fbarray-memseg-destory-error-during-detach.patch deleted file mode 100644 index 27642e5..0000000 --- a/0012-dpdk-fix-fbarray-memseg-destory-error-during-detach.patch +++ /dev/null @@ -1,31 +0,0 @@ -From e5cc58807c8d03554f2c3f0eee3b0b6d6f44278f Mon Sep 17 00:00:00 2001 -From: HuangLiming -Date: Sat, 22 Aug 2020 05:32:47 -0400 -Subject: [PATCH] fix fbarray memseg destory error during detach without shared - file - -Signed-off-by: HuangLiming ---- - lib/librte_eal/common/eal_common_fbarray.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c -index 116c695..d1aa074 100644 ---- a/lib/librte_eal/common/eal_common_fbarray.c -+++ b/lib/librte_eal/common/eal_common_fbarray.c -@@ -1127,9 +1127,9 @@ rte_sec_fbarray_destroy(struct rte_fbarray *arr, - - fd = open(path, O_RDONLY); - if (fd < 0) { -- RTE_LOG(ERR, EAL, "Could not open fbarray file: %s\n", -- strerror(errno)); -- return -1; -+ RTE_LOG(WARNING, EAL, "Could not open %s: %s, and just skip it\n", -+ path, strerror(errno)); -+ return 0; - } - if (flock(fd, LOCK_EX | LOCK_NB)) { - RTE_LOG(DEBUG, EAL, "Cannot destroy fbarray - another process is using it\n"); --- -2.21.0 - diff --git a/0012-fix-rte-eal-sec-detach-coredump-count-rollover.patch b/0012-fix-rte-eal-sec-detach-coredump-count-rollover.patch new file mode 100644 index 0000000..b10f190 --- /dev/null +++ b/0012-fix-rte-eal-sec-detach-coredump-count-rollover.patch @@ -0,0 +1,42 @@ +From 8ca5f1cfbea80f7524eb2f2dfa67760be80666c3 Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Sat, 18 Dec 2021 16:57:31 +0800 +Subject: [PATCH] 0011 + +--- + lib/eal/linux/eal.c | 4 +++- + lib/eal/linux/eal_memalloc.c | 4 ++++ + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index 2555043155..c833b46c36 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -1627,6 +1627,8 @@ rte_eal_sec_detach(const char *file_prefix, int length) + return -1; + } + +- sec_count--; ++ if (sec_count) { ++ sec_count--; ++ } + return 0; + } +diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c +index dac9098c8c..38543bf8c4 100644 +--- a/lib/eal/linux/eal_memalloc.c ++++ b/lib/eal/linux/eal_memalloc.c +@@ -1814,6 +1814,10 @@ eal_sec_memalloc_destroy(const int sec_idx) + struct rte_mem_config *mcfg = rte_eal_sec_get_configuration(sec_idx)->mem_config; + int i, ret = 0; + ++ if (mcfg == NULL) { ++ return 0; ++ } ++ + for (i = 0; i < RTE_MAX_MEMSEG_LISTS; i++) { + struct rte_memseg_list *msl = &mcfg->memsegs[i]; + +-- +2.27.0 + diff --git a/0013-dpdk-optimize-the-efficiency-of-compiling-dpdk.patch b/0013-dpdk-optimize-the-efficiency-of-compiling-dpdk.patch deleted file mode 100644 index 3a23de0..0000000 --- a/0013-dpdk-optimize-the-efficiency-of-compiling-dpdk.patch +++ /dev/null @@ -1,195 +0,0 @@ -From 5e554c15982617a89b85aeb71592c20bfa7bdecd Mon Sep 17 00:00:00 2001 -From: Renmingshuai -Date: Tue, 13 Apr 2021 16:25:43 +0800 -Subject: [PATCH] optimize the efficiency of compiling dpdk - ---- - config/common_base | 5 +++ - mk/rte.combinedlib.mk | 10 +++++ - mk/rte.lib.mk | 102 +++++++++++++++++++++++++++++++++++++++--- - 3 files changed, 110 insertions(+), 7 deletions(-) - -diff --git a/config/common_base b/config/common_base -index 57b1349..392e6c3 100644 ---- a/config/common_base -+++ b/config/common_base -@@ -59,6 +59,11 @@ CONFIG_RTE_ENABLE_LTO=n - # - CONFIG_RTE_BUILD_SHARED_LIB=n - -+# -+# Compile to both static library and share library -+# -+CONFIG_RTE_BUILD_BOTH_STATIC_AND_SHARED_LIBS=n -+ - # - # Use newest code breaking previous ABI - # -diff --git a/mk/rte.combinedlib.mk b/mk/rte.combinedlib.mk -index 9d0f935..1088543 100644 ---- a/mk/rte.combinedlib.mk -+++ b/mk/rte.combinedlib.mk -@@ -15,9 +15,16 @@ RTE_LIBNAME := dpdk - COMBINEDLIB := lib$(RTE_LIBNAME)$(EXT) - - LIBS := $(filter-out $(COMBINEDLIB), $(sort $(notdir $(wildcard $(RTE_OUTPUT)/lib/*$(EXT))))) -+ifeq ($(CONFIG_RTE_BUILD_BOTH_STATIC_AND_SHARED_LIBS),y) -+COMBINEDLIB_SO := lib$(RTE_LIBNAME).so -+LIBS_SO := $(filter-out $(COMBINEDLIB_SO), $(sort $(notdir $(wildcard $(RTE_OUTPUT)/lib/*.so)))) -+endif - - all: FORCE - $(Q)echo "GROUP ( $(LIBS) )" > $(RTE_OUTPUT)/lib/$(COMBINEDLIB) -+ifeq ($(CONFIG_RTE_BUILD_BOTH_STATIC_AND_SHARED_LIBS),y) -+ $(Q)echo "GROUP ( $(LIBS_SO) )" > $(RTE_OUTPUT)/lib/$(COMBINEDLIB_SO) -+endif - - # - # Clean all generated files -@@ -25,6 +32,9 @@ all: FORCE - .PHONY: clean - clean: - $(Q)rm -f $(RTE_OUTPUT)/lib/$(COMBINEDLIB) -+ifeq ($(CONFIG_RTE_BUILD_BOTH_STATIC_AND_SHARED_LIBS),y) -+ $(Q)rm -f $(RTE_OUTPUT)/lib/$(COMBINEDLIB_SO) -+endif - - .PHONY: FORCE - FORCE: -diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk -index 4516d1c..78f3c27 100644 ---- a/mk/rte.lib.mk -+++ b/mk/rte.lib.mk -@@ -19,13 +19,6 @@ else ifeq ($(LIBABIVER),) - LIBABIVER := 0.$(shell cat $(RTE_SRCDIR)/ABI_VERSION | tr -d '.') - endif - --ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) --LIB := $(patsubst %.a,%.so.$(LIBABIVER),$(LIB)) --ifeq ($(EXTLIB_BUILD),n) --CPU_LDFLAGS += --version-script=$(SRCDIR)/$(EXPORT_MAP) --endif --endif -- - - _BUILD = $(LIB) - PREINSTALL = $(SYMLINK-FILES-y) -@@ -34,6 +27,16 @@ _CLEAN = doclean - - LDLIBS += $(EXECENV_LDLIBS-y) - -+ifeq ($(CONFIG_RTE_BUILD_BOTH_STATIC_AND_SHARED_LIBS),y) -+LIB_SO = $(LIB) -+LIB_SO := $(patsubst %.a,%.so.$(LIBABIVER),$(LIB_SO)) -+ifeq ($(EXTLIB_BUILD),n) -+CPU_LDFLAGS += --version-script=$(SRCDIR)/$(EXPORT_MAP) -+endif -+_BUILD += $(LIB_SO) -+_INSTALL += $(INSTALL-FILES-y) $(RTE_OUTPUT)/lib/$(LIB_SO) -+endif -+ - .PHONY: all - all: install - -@@ -74,6 +77,89 @@ ifneq ($(CC_SUPPORTS_Z),false) - NO_UNDEFINED := -z defs - endif - -+ifeq ($(CONFIG_RTE_BUILD_BOTH_STATIC_AND_SHARED_LIBS),y) -+O_TO_S = $(LD) -L$(RTE_SDK_BIN)/lib $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) \ -+ -shared $(OBJS-y) $(NO_UNDEFINED) $(LDLIBS) -Wl,-soname,$(LIB_SO) -o $(LIB_SO) -+O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight -+O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)"," LD $(@)") -+O_TO_S_DO = @set -e; \ -+ echo $(O_TO_S_DISP); \ -+ $(O_TO_S) && \ -+ echo $(O_TO_S_CMD) > $(call exe2cmd,$(@)) -+ -+-include .$(LIB_SO).cmd -+ -+# -+# Archive objects in .a file if needed -+# -+$(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE -+ @[ -d $(dir $@) ] || mkdir -p $(dir $@) -+ $(if $(D),\ -+ @echo -n "$< -> $@ " ; \ -+ echo -n "file_missing=$(call boolean,$(file_missing)) " ; \ -+ echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_A_STR))) " ; \ -+ echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \ -+ echo "depfile_newer=$(call boolean,$(depfile_newer)) ") -+ $(if $(or \ -+ $(file_missing),\ -+ $(call cmdline_changed,$(O_TO_A_STR)),\ -+ $(depfile_missing),\ -+ $(depfile_newer)),\ -+ $(O_TO_A_DO)) -+ -+$(LIB_SO): $(OBJS-y) $(DEP_$(LIB_SO)) FORCE -+ifeq ($(LIBABIVER),) -+ @echo "Must Specify a $(LIB_SO) ABI version" -+ @false -+endif -+ @[ -d $(dir $@) ] || mkdir -p $(dir $@) -+ $(if $(D),\ -+ @echo -n "$< -> $@ " ; \ -+ echo -n "file_missing=$(call boolean,$(file_missing)) " ; \ -+ echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_S_STR))) " ; \ -+ echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \ -+ echo "depfile_newer=$(call boolean,$(depfile_newer)) ") -+ $(if $(or \ -+ $(file_missing),\ -+ $(call cmdline_changed,$(O_TO_S_STR)),\ -+ $(depfile_missing),\ -+ $(depfile_newer)),\ -+ $(O_TO_S_DO)) -+ -+# -+# install lib in $(RTE_OUTPUT)/lib -+# -+$(RTE_OUTPUT)/lib/$(LIB): $(LIB) -+ @echo " INSTALL-LIB $(LIB)" -+ @[ -d $(RTE_OUTPUT)/lib ] || mkdir -p $(RTE_OUTPUT)/lib -+ cp -f $(LIB) $(RTE_OUTPUT)/lib -+ -+$(RTE_OUTPUT)/lib/$(LIB_SO): $(LIB_SO) -+ @echo " INSTALL-LIB $(LIB_SO)" -+ @[ -d $(RTE_OUTPUT)/lib ] || mkdir -p $(RTE_OUTPUT)/lib -+ cp -f $(LIB_SO) $(RTE_OUTPUT)/lib -+ ln -s -f $< $(shell echo $@ | sed 's/\.so.*/.so/') -+ -+# -+# Clean all generated files -+# -+.PHONY: clean -+clean: _postclean -+ -+.PHONY: doclean -+doclean: -+ $(Q)rm -rf $(LIB) $(LIB_SO) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \ -+ $(CMDS-all) .$(LIB).cmd $(INSTALL-FILES-all) *.pmd.c *.pmd.o -+ $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS) -+ -+else -+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) -+LIB := $(patsubst %.a,%.so.$(LIBABIVER),$(LIB)) -+ifeq ($(EXTLIB_BUILD),n) -+CPU_LDFLAGS += --version-script=$(SRCDIR)/$(EXPORT_MAP) -+endif -+endif -+ - O_TO_S = $(LD) -L$(RTE_SDK_BIN)/lib $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) \ - -shared $(OBJS-y) $(NO_UNDEFINED) $(LDLIBS) -Wl,-soname,$(LIB) -o $(LIB) - O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight -@@ -148,6 +234,8 @@ doclean: - $(CMDS-all) .$(LIB).cmd $(INSTALL-FILES-all) *.pmd.c *.pmd.o - $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS) - -+endif -+ - include $(RTE_SDK)/mk/internal/rte.compile-post.mk - include $(RTE_SDK)/mk/internal/rte.install-post.mk - include $(RTE_SDK)/mk/internal/rte.clean-post.mk --- -2.19.1 - diff --git a/0013-fix-rte-eal-memory-init-double-unlock.patch b/0013-fix-rte-eal-memory-init-double-unlock.patch new file mode 100644 index 0000000..3dcc04a --- /dev/null +++ b/0013-fix-rte-eal-memory-init-double-unlock.patch @@ -0,0 +1,29 @@ +From d9e578c64144bf35e3141d2a3f3ada2763534cb2 Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Thu, 16 Dec 2021 19:26:51 +0800 +Subject: [PATCH] huawei-0015-fix-rte-eal-memory-init-double-unlock + +--- + lib/eal/common/eal_common_memory.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c +index 15ce4341b0..d983e37cc8 100644 +--- a/lib/eal/common/eal_common_memory.c ++++ b/lib/eal/common/eal_common_memory.c +@@ -1150,8 +1150,10 @@ rte_eal_sec_memory_init(const int sec_idx) + ret = __rte_eal_memory_init(rte_eal_sec_get_runtime_dir(sec_idx), + rte_eal_sec_get_internal_config(sec_idx), rte_cfg, + true, sec_idx); +- +- rte_rwlock_read_unlock(&rte_cfg->mem_config->memory_hotplug_lock); ++ if (ret == 0) { ++ /* when ret != 0 unlock in __rte_eal_memory_init */ ++ rte_rwlock_read_unlock(&rte_cfg->mem_config->memory_hotplug_lock); ++ } + + return ret; + } +-- +2.27.0 + diff --git a/0014-fix-last-argv-pointer-change-to-first.patch b/0014-fix-last-argv-pointer-change-to-first.patch new file mode 100644 index 0000000..e30a4bb --- /dev/null +++ b/0014-fix-last-argv-pointer-change-to-first.patch @@ -0,0 +1,25 @@ +From 23113e9f48414f534358274a732921cd3f5345cf Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Thu, 16 Dec 2021 20:12:42 +0800 +Subject: [PATCH] huawei-0016-fix-last-argv-pointer-change-to-first + +--- + lib/eal/linux/eal.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index 16bb2b60cc..78c61a1979 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -935,8 +935,6 @@ __eal_parse_args(int argc, char **argv, char *runtime_dir, const int buflen, + goto out; + } + +- if (optind >= 0) +- argv[optind-1] = prgname; + ret = optind-1; + + out: +-- +2.27.0 + diff --git a/0014-fix-rte-eal-sec-detach-coredump-count-rollover.patch b/0014-fix-rte-eal-sec-detach-coredump-count-rollover.patch deleted file mode 100644 index 7bc23d9..0000000 --- a/0014-fix-rte-eal-sec-detach-coredump-count-rollover.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 73a222f904e1c5d69966a7716f5a1fd5c82e66cc Mon Sep 17 00:00:00 2001 -From: wuchangsheng -Date: Thu, 3 Jun 2021 17:31:51 +0800 -Subject: [PATCH] fix rte eal sec detach coredump - ---- - lib/librte_eal/linux/eal/eal.c | 4 +++- - lib/librte_eal/linux/eal/eal_memalloc.c | 5 ++++- - 2 files changed, 7 insertions(+), 2 deletions(-) - -diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c -index ff86ff9..7718e3a 100644 ---- a/lib/librte_eal/linux/eal/eal.c -+++ b/lib/librte_eal/linux/eal/eal.c -@@ -1616,6 +1616,8 @@ rte_eal_sec_detach(const char *file_prefix, int length) - return -1; - } - -- sec_count--; -+ if (sec_count) { -+ sec_count--; -+ } - return 0; - } -diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c -index 8e7f120..80646a2 100644 ---- a/lib/librte_eal/linux/eal/eal_memalloc.c -+++ b/lib/librte_eal/linux/eal/eal_memalloc.c -@@ -1667,7 +1667,10 @@ eal_memalloc_destroy(const int sec_idx) - int msl_idx = 0; - struct rte_memseg_list *msl; - struct rte_mem_config *mcfg = rte_eal_sec_get_configuration(sec_idx)->mem_config; -- -+ -+ if (mcfg == NULL) { -+ return 0; -+ } - for (msl_idx = 0; msl_idx < RTE_MAX_MEMSEG_LISTS; msl_idx++) { - - msl = &mcfg->memsegs[msl_idx]; --- -2.23.0 - diff --git a/0015-fix-internal-cfg-and-fbarray-attach-mememory-leak.patch b/0015-fix-internal-cfg-and-fbarray-attach-mememory-leak.patch new file mode 100644 index 0000000..0354da9 --- /dev/null +++ b/0015-fix-internal-cfg-and-fbarray-attach-mememory-leak.patch @@ -0,0 +1,55 @@ +From 847cbe34e8e45a0c0613cf5cd96f06ee31ada0f9 Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Sat, 18 Dec 2021 17:02:16 +0800 +Subject: [PATCH] 0014 + +--- + lib/eal/common/eal_common_fbarray.c | 13 ++++++++----- + lib/eal/linux/eal.c | 1 + + 2 files changed, 9 insertions(+), 5 deletions(-) + +diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c +index fa726cd2f5..b809d3c669 100644 +--- a/lib/eal/common/eal_common_fbarray.c ++++ b/lib/eal/common/eal_common_fbarray.c +@@ -911,17 +911,20 @@ __rte_fbarray_attach(struct rte_fbarray *arr, const char *runtime_dir, + fd = -1; + } + +- /* store our new memory area */ +- ma->addr = data; +- ma->fd = fd; /* keep fd until detach/destroy */ +- ma->len = mmap_len; +- + if (!internal_conf->pri_and_sec) { ++ /* store our new memory area */ ++ ma->addr = data; ++ ma->fd = fd; /* keep fd until detach/destroy */ ++ ma->len = mmap_len; ++ + TAILQ_INSERT_TAIL(&mem_area_tailq, ma, next); + + /* we're done */ + + rte_spinlock_unlock(&mem_area_lock); ++ } else { ++ /* pri_and_sec don't use mem_area_tailq */ ++ free(ma); + } + return 0; + fail: +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index f70c4d55fa..2dee945be4 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -564,6 +564,7 @@ eal_sec_config_cleanup(const int sec_idx) + } + + memset(lc_rte_cfg, 0, sizeof(*lc_rte_cfg)); ++ eal_cleanup_config(lc_internal_cfg); + memset(lc_internal_cfg, 0, sizeof(*lc_internal_cfg)); + memset(lc_runtime_dir, 0, PATH_MAX); + +-- +2.27.0 + diff --git a/0015-fix-rte-eal-memory-init-double-unlock.patch b/0015-fix-rte-eal-memory-init-double-unlock.patch deleted file mode 100644 index 340a32a..0000000 --- a/0015-fix-rte-eal-memory-init-double-unlock.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 6271d4d2365298ea7e25fe867605618e559b15a4 Mon Sep 17 00:00:00 2001 -From: wuchangsheng -Date: Fri, 11 Jun 2021 17:56:16 +0800 -Subject: [PATCH] stuck - ---- - lib/librte_eal/common/eal_common_memory.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c -index 842fc9b..ffb0c04 100644 ---- a/lib/librte_eal/common/eal_common_memory.c -+++ b/lib/librte_eal/common/eal_common_memory.c -@@ -967,8 +967,10 @@ rte_eal_sec_memory_init(const int sec_idx) - ret = __rte_eal_memory_init(rte_eal_sec_get_runtime_dir(sec_idx), - rte_eal_sec_get_internal_config(sec_idx), rte_cfg, - true, sec_idx); -- -- rte_rwlock_read_unlock(&rte_cfg->mem_config->memory_hotplug_lock); -+ if (ret == 0) { -+ /* when ret != 0 unlock in __rte_eal_memory_init */ -+ rte_rwlock_read_unlock(&rte_cfg->mem_config->memory_hotplug_lock); -+ } - - return ret; - } --- -2.23.0 - diff --git a/0016-fix-error-that-the-secondary-attach-fails-due-to-detach.patch b/0016-fix-error-that-the-secondary-attach-fails-due-to-detach.patch new file mode 100644 index 0000000..ccba129 --- /dev/null +++ b/0016-fix-error-that-the-secondary-attach-fails-due-to-detach.patch @@ -0,0 +1,24 @@ +From e8466bb5c02192727a140688df0c8882ed35ca59 Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Sat, 18 Dec 2021 17:09:27 +0800 +Subject: [PATCH] 15 + +--- + lib/eal/linux/eal_memalloc.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c +index d5fe856dd8..38543bf8c4 100644 +--- a/lib/eal/linux/eal_memalloc.c ++++ b/lib/eal/linux/eal_memalloc.c +@@ -1830,7 +1830,6 @@ eal_sec_memalloc_destroy(const int sec_idx) + return ret; + + rte_mem_unmap(msl->base_va, msl->len); +- memset(msl, 0, sizeof(*msl)); + } + + return 0; +-- +2.27.0 + diff --git a/0016-fix-last-argv-pointer-change-to-first.patch b/0016-fix-last-argv-pointer-change-to-first.patch deleted file mode 100644 index 64f1023..0000000 --- a/0016-fix-last-argv-pointer-change-to-first.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 8f69aa023ffa1ea951615defb24138d7d5ef3db3 Mon Sep 17 00:00:00 2001 -From: wuchangsheng -Date: Sun, 18 Jul 2021 19:43:51 +0800 -Subject: [PATCH] fix-arfgs - ---- - lib/librte_eal/linux/eal/eal.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c -index 60074ff..4385031 100644 ---- a/lib/librte_eal/linux/eal/eal.c -+++ b/lib/librte_eal/linux/eal/eal.c -@@ -958,8 +958,6 @@ __eal_parse_args(int argc, char **argv, char *runtime_dir, const int buflen, - goto out; - } - -- if (optind >= 0) -- argv[optind-1] = prgname; - ret = optind-1; - - out: --- -2.23.0 - diff --git a/0017-fix-internal-cfg-and-fbarray-attach-mememory-leak.patch b/0017-fix-internal-cfg-and-fbarray-attach-mememory-leak.patch deleted file mode 100644 index a1100f9..0000000 --- a/0017-fix-internal-cfg-and-fbarray-attach-mememory-leak.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 9e7b1be6e2d25663b3a997edd0ec8e9e603a770c Mon Sep 17 00:00:00 2001 -From: wuchangsheng -Date: Mon, 19 Jul 2021 23:09:53 +0800 -Subject: [PATCH] test - ---- - lib/librte_eal/common/eal_common_fbarray.c | 15 +++++++++------ - lib/librte_eal/linux/eal/eal.c | 1 + - 2 files changed, 10 insertions(+), 6 deletions(-) - -diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c -index d1aa074..adfcd09 100644 ---- a/lib/librte_eal/common/eal_common_fbarray.c -+++ b/lib/librte_eal/common/eal_common_fbarray.c -@@ -915,18 +915,21 @@ __rte_fbarray_attach(struct rte_fbarray *arr, const char *runtime_dir, - fd = -1; - } - -- /* store our new memory area */ -- ma->addr = data; -- ma->fd = fd; /* keep fd until detach/destroy */ -- ma->len = mmap_len; - - if (!internal_cfg->pri_and_sec) { -+ /* store our new memory area */ -+ ma->addr = data; -+ ma->fd = fd; /* keep fd until detach/destroy */ -+ ma->len = mmap_len; -+ - TAILQ_INSERT_TAIL(&mem_area_tailq, ma, next); - - /* we're done */ -- - rte_spinlock_unlock(&mem_area_lock); -- } -+ } else { -+ /* pri_and_sec don't use mem_area_tailq */ -+ free(ma); -+ } - return 0; - fail: - if (data) -diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c -index 4385031..92f1b56 100644 ---- a/lib/librte_eal/linux/eal/eal.c -+++ b/lib/librte_eal/linux/eal/eal.c -@@ -608,6 +608,7 @@ eal_sec_config_cleanup(const int sec_idx) - } - - memset(lc_rte_cfg, 0, sizeof(*lc_rte_cfg)); -+ eal_cleanup_config(lc_internal_cfg); - memset(lc_internal_cfg, 0, sizeof(*lc_internal_cfg)); - memset(lc_runtime_dir, 0, PATH_MAX); - --- -2.23.0 - diff --git a/0017-fix-master-thread-not-set-affinity.patch b/0017-fix-master-thread-not-set-affinity.patch new file mode 100644 index 0000000..1a5588e --- /dev/null +++ b/0017-fix-master-thread-not-set-affinity.patch @@ -0,0 +1,25 @@ +From 269be3f974c22f62892554dbb51fe859047058d7 Mon Sep 17 00:00:00 2001 +From: wuchangsheng +Date: Fri, 14 Jan 2022 11:11:08 +0800 +Subject: [PATCH] fix master thread not set affinity + +--- + lib/eal/linux/eal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index 123a8e8..7ca8bb2 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -1310,7 +1310,7 @@ rte_eal_init(int argc, char **argv) + eal_check_mem_on_local_socket(); + + /* Master thread don't set affinity in LibStorage application */ +- if (strstr(logid, "LibStorage") != NULL && ++ if (strstr(logid, "LibStorage") == NULL && + pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t), + &lcore_config[config->main_lcore].cpuset) != 0) { + rte_eal_init_alert("Cannot set affinity"); +-- +2.30.0 + diff --git a/0018-fix-error-that-the-secondary-attach-fails-due-to-detach.patch b/0018-fix-error-that-the-secondary-attach-fails-due-to-detach.patch deleted file mode 100644 index 84852b9..0000000 --- a/0018-fix-error-that-the-secondary-attach-fails-due-to-detach.patch +++ /dev/null @@ -1,26 +0,0 @@ -From d4236bd136c94d8272a145525ac9128d2fefce13 Mon Sep 17 00:00:00 2001 -From: wuchangsheng -Date: Wed, 21 Jul 2021 15:13:59 +0800 -Subject: [PATCH] fix detach memset rte mem config - -eal_memalloc_destroy memset rte_mem_config while detach. rte_mem_config mmap from file witch share with primary proc. this break rte_mem_config of primary proc - ---- - lib/librte_eal/linux/eal/eal_memalloc.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c -index f50954e..e345d94 100644 ---- a/lib/librte_eal/linux/eal/eal_memalloc.c -+++ b/lib/librte_eal/linux/eal/eal_memalloc.c -@@ -1688,7 +1688,6 @@ eal_memalloc_destroy(const int sec_idx) - RTE_LOG(ERR, EAL, "Failed to unmap memseg lists\n"); - return -1; - } -- memset(msl, 0, sizeof(*msl)); - - if (fd_list_destroy_walk(msl, sec_idx)) { - RTE_LOG(ERR, EAL, "Failed to clear secondary fd_list.\n"); --- -2.23.0 - diff --git a/0018-net-bonding-fix-offloading-configuration.patch b/0018-net-bonding-fix-offloading-configuration.patch new file mode 100644 index 0000000..5a61ab3 --- /dev/null +++ b/0018-net-bonding-fix-offloading-configuration.patch @@ -0,0 +1,71 @@ +From ef72dacdec6c5dca8773854906159f7bc75eeb5c Mon Sep 17 00:00:00 2001 +From: Chengchang Tang +Date: Tue, 9 Nov 2021 15:57:26 +0800 +Subject: [PATCH] net/bonding: fix offloading configuration + +Currently, part offloadings of the bonding device will not take effect +by using dev_configure(). Because the related configuration will not be +delivered to the slave devices in this way. + +The offloading capability of the bonding device is the intersection of +the capability of all slave devices. Based on this, the following +functions are added to the bonding driver: +1. If a Tx offloading is within the capability of the bonding device + (i.e, all the slave devices support this Tx offloading), the enabling + status of the offloading of all slave devices depends on the + configuration of the bonding device. + +2. For the Tx offloading that is not within the Tx offloading capability + of the bonding device, the enabling status of the offloading on the + slave devices is irrelevant to the bonding device configuration. And + it depends on the original configuration of the slave devices. + +Fixes: e8b3e1a9b1bb ("net/bonding: switch to new offloading API") +Cc: stable@dpdk.org + +Signed-off-by: Chengchang Tang +Signed-off-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 23 +++++++++++++++-------- + 1 file changed, 15 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 84f4900ee5..0f11a2f5a8 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -1713,17 +1713,24 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev, + bonded_eth_dev->data->dev_conf.rxmode.mq_mode; + } + +- if (bonded_eth_dev->data->dev_conf.rxmode.offloads & +- RTE_ETH_RX_OFFLOAD_VLAN_FILTER) +- slave_eth_dev->data->dev_conf.rxmode.offloads |= +- RTE_ETH_RX_OFFLOAD_VLAN_FILTER; +- else +- slave_eth_dev->data->dev_conf.rxmode.offloads &= +- ~RTE_ETH_RX_OFFLOAD_VLAN_FILTER; +- + slave_eth_dev->data->dev_conf.rxmode.mtu = + bonded_eth_dev->data->dev_conf.rxmode.mtu; + ++ slave_eth_dev->data->dev_conf.txmode.offloads |= ++ bonded_eth_dev->data->dev_conf.txmode.offloads; ++ ++ slave_eth_dev->data->dev_conf.txmode.offloads &= ++ (bonded_eth_dev->data->dev_conf.txmode.offloads | ++ ~internals->tx_offload_capa); ++ ++ slave_eth_dev->data->dev_conf.rxmode.offloads |= ++ bonded_eth_dev->data->dev_conf.rxmode.offloads; ++ ++ slave_eth_dev->data->dev_conf.rxmode.offloads &= ++ (bonded_eth_dev->data->dev_conf.rxmode.offloads | ++ ~internals->rx_offload_capa); ++ ++ + nb_rx_queues = bonded_eth_dev->data->nb_rx_queues; + nb_tx_queues = bonded_eth_dev->data->nb_tx_queues; + +-- +2.33.0 + diff --git a/0018-secure-complilation-options-rpath.patch b/0018-secure-complilation-options-rpath.patch new file mode 100644 index 0000000..f3aae0b --- /dev/null +++ b/0018-secure-complilation-options-rpath.patch @@ -0,0 +1,38 @@ +From 620b54f7d1c4bbf99d894ac3c8ddf3e73c29071f Mon Sep 17 00:00:00 2001 +From: wu-changsheng +Date: Tue, 13 Sep 2022 22:33:48 +0800 +Subject: [PATCH] delete rpath + +--- + app/meson.build | 1 - + app/test/meson.build | 2 -- + 2 files changed, 3 deletions(-) + +diff --git a/app/meson.build b/app/meson.build +index 885dfe3..d1c6b25 100644 +--- a/app/meson.build ++++ b/app/meson.build +@@ -74,7 +74,6 @@ foreach app:apps + link_whole: link_libs, + dependencies: ext_deps + dep_objs, + include_directories: includes, +- install_rpath: join_paths(get_option('prefix'), driver_install_path), + install: true) + endforeach + +diff --git a/app/test/meson.build b/app/test/meson.build +index 2b480ad..51d09ec 100644 +--- a/app/test/meson.build ++++ b/app/test/meson.build +@@ -488,8 +488,6 @@ dpdk_test = executable('dpdk-test', + link_whole: link_libs, + dependencies: test_dep_objs + ext_deps, + c_args: cflags, +- install_rpath: join_paths(get_option('prefix'), +- driver_install_path), + install: true) + + has_hugepage = run_command('has-hugepage.sh').stdout().strip() != '0' +-- +2.23.0 + diff --git a/0019-net-hns3-fix-Rx-Tx-when-fast-path-operation-introduc.patch b/0019-net-hns3-fix-Rx-Tx-when-fast-path-operation-introduc.patch new file mode 100644 index 0000000..71adecf --- /dev/null +++ b/0019-net-hns3-fix-Rx-Tx-when-fast-path-operation-introduc.patch @@ -0,0 +1,114 @@ +From 7ae766e2863868698a26a17f40995bd5ba02356d Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Mon, 17 Jan 2022 10:43:00 +0800 +Subject: [PATCH] net/hns3: fix Rx/Tx when fast path operation introduced + +When fast path operation is introduced, the Rx/Tx function is done by +object 'rte_eth_fp_ops'. So 'rte_eth_fp_ops' should be updated if +'fast-path functions' need to be changed, such as PMD receive function, +prepare function and so on. + +This patch fixed receiving packets bug when fast path operation is +introduced. + +Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") +Fixes: 168b7d79dada ("net/hns3: support set link up/down for PF") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_mp.c | 7 ++----- + drivers/net/hns3/hns3_rxtx.c | 28 +++++++++++++++++++++++++++- + 2 files changed, 29 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c +index 999b407f7d..e74ddea195 100644 +--- a/drivers/net/hns3/hns3_mp.c ++++ b/drivers/net/hns3/hns3_mp.c +@@ -74,7 +74,6 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) + struct hns3_mp_param *res = (struct hns3_mp_param *)mp_res.param; + const struct hns3_mp_param *param = + (const struct hns3_mp_param *)mp_msg->param; +- eth_tx_prep_t prep = NULL; + struct rte_eth_dev *dev; + int ret; + +@@ -98,14 +97,12 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) + case HNS3_MP_REQ_START_TX: + PMD_INIT_LOG(INFO, "port %u starting Tx datapath", + dev->data->port_id); +- dev->tx_pkt_burst = hns3_get_tx_function(dev, &prep); +- dev->tx_pkt_prepare = prep; ++ hns3_start_tx_datapath(dev); + break; + case HNS3_MP_REQ_STOP_TX: + PMD_INIT_LOG(INFO, "port %u stopping Tx datapath", + dev->data->port_id); +- dev->tx_pkt_burst = hns3_dummy_rxtx_burst; +- dev->tx_pkt_prepare = NULL; ++ hns3_stop_tx_datapath(dev); + break; + default: + rte_errno = EINVAL; +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index d240e36e6a..c86aeb2366 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4408,7 +4408,21 @@ hns3_trace_rxtx_function(struct rte_eth_dev *dev) + rx_mode.info, tx_mode.info); + } + +-void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) ++static void ++hns3_eth_dev_fp_ops_config(const struct rte_eth_dev *dev) ++{ ++ struct rte_eth_fp_ops *fpo = rte_eth_fp_ops; ++ uint16_t port_id = dev->data->port_id; ++ ++ fpo[port_id].rx_pkt_burst = dev->rx_pkt_burst; ++ fpo[port_id].tx_pkt_burst = dev->tx_pkt_burst; ++ fpo[port_id].tx_pkt_prepare = dev->tx_pkt_prepare; ++ fpo[port_id].rx_descriptor_status = dev->rx_descriptor_status; ++ fpo[port_id].tx_descriptor_status = dev->tx_descriptor_status; ++} ++ ++void ++hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + struct hns3_adapter *hns = eth_dev->data->dev_private; +@@ -4429,6 +4443,8 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) + eth_dev->tx_pkt_burst = hns3_dummy_rxtx_burst; + eth_dev->tx_pkt_prepare = NULL; + } ++ ++ hns3_eth_dev_fp_ops_config(eth_dev); + } + + void +@@ -4729,6 +4745,11 @@ hns3_stop_tx_datapath(struct rte_eth_dev *dev) + { + dev->tx_pkt_burst = hns3_dummy_rxtx_burst; + dev->tx_pkt_prepare = NULL; ++ hns3_eth_dev_fp_ops_config(dev); ++ ++ if (rte_eal_process_type() == RTE_PROC_SECONDARY) ++ return; ++ + rte_wmb(); + /* Disable tx datapath on secondary process. */ + hns3_mp_req_stop_tx(dev); +@@ -4743,5 +4764,10 @@ hns3_start_tx_datapath(struct rte_eth_dev *dev) + + dev->tx_pkt_burst = hns3_get_tx_function(dev, &prep); + dev->tx_pkt_prepare = prep; ++ hns3_eth_dev_fp_ops_config(dev); ++ ++ if (rte_eal_process_type() == RTE_PROC_SECONDARY) ++ return; ++ + hns3_mp_req_start_tx(dev); + } +-- +2.33.0 + diff --git a/0019-reinit-support-return-ok.patch b/0019-reinit-support-return-ok.patch index 93f4e1c..5105741 100644 --- a/0019-reinit-support-return-ok.patch +++ b/0019-reinit-support-return-ok.patch @@ -1,36 +1,37 @@ -From d6d940b4a57cefdfa8efe751480cd4e7a1c10613 Mon Sep 17 00:00:00 2001 +From 12a22b874a4852996dcec56ae30c7a17551bfeeb Mon Sep 17 00:00:00 2001 From: wuchangsheng -Date: Thu, 6 Oct 2022 17:09:03 +0800 +Date: Thu, 6 Oct 2022 16:35:16 +0800 Subject: [PATCH] reinit support return ok --- - lib/librte_eal/linux/eal/eal.c | 8 ++++++++ + lib/eal/linux/eal.c | 8 ++++++++ 1 file changed, 8 insertions(+) -diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c -index 92f1b56..7673b18 100644 ---- a/lib/librte_eal/linux/eal/eal.c -+++ b/lib/librte_eal/linux/eal/eal.c -@@ -1081,6 +1081,7 @@ rte_eal_init(int argc, char **argv) +diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c +index 7ca8bb2..fc2a7fd 100644 +--- a/lib/eal/linux/eal.c ++++ b/lib/eal/linux/eal.c +@@ -1055,6 +1055,7 @@ 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); -+ static uint32_t reinit_ok = 0; + static uint32_t run_once; ++ static uint32_t reinit_ok = 0; + uint32_t has_run = 0; const char *p; static char logid[PATH_MAX]; - char cpuset[RTE_CPU_AFFINITY_STR_LEN]; -@@ -1094,7 +1095,14 @@ rte_eal_init(int argc, char **argv) +@@ -1072,8 +1073,15 @@ rte_eal_init(int argc, char **argv) return -1; } -+ if (argc > 1 && !strncmp(argv[1], "reinit-ok", strlen("reinit-ok"))) { -+ reinit_ok = 1; -+ } ++ if (argc > 1 && !strncmp(argv[1], "reinit-ok", strlen("reinit-ok"))) { ++ reinit_ok = 1; ++ } + - if (!rte_atomic32_test_and_set(&run_once)) { -+ if (reinit_ok) { -+ return 0; -+ } + if (!__atomic_compare_exchange_n(&run_once, &has_run, 1, 0, + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) { ++ if (reinit_ok) { ++ return 0; ++ } rte_eal_init_alert("already called initialization."); rte_errno = EALREADY; return -1; diff --git a/0020-net-hns3-fix-mailbox-wait-time-uninitialization.patch b/0020-net-hns3-fix-mailbox-wait-time-uninitialization.patch new file mode 100644 index 0000000..7cc0ba9 --- /dev/null +++ b/0020-net-hns3-fix-mailbox-wait-time-uninitialization.patch @@ -0,0 +1,47 @@ +From b274c48fc01ed8fe854c285b02f1ac108bbf2721 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 17 Jan 2022 10:43:01 +0800 +Subject: [PATCH] net/hns3: fix mailbox wait time uninitialization + +The mailbox wait time can be specified at runtime. But the variable that +controls this time are not initialized when the variable isn't designated +or is specified as an invalid value, which will fail to initialize device +in the case where no device is bound to initialize the device. + +Fixes: 2fc3e696a7f1 ("net/hns3: add runtime config for mailbox limit time") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +--- + drivers/net/hns3/hns3_common.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 0bb552ea3e..78158401f2 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -216,7 +216,7 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) + + /* + * 500ms is empirical value in process of mailbox communication. If +- * the delay value is set to one lower thanthe empirical value, mailbox ++ * the delay value is set to one lower than the empirical value, mailbox + * communication may fail. + */ + if (val > HNS3_MBX_DEF_TIME_LIMIT_MS && val <= UINT16_MAX) +@@ -236,6 +236,12 @@ hns3_parse_devargs(struct rte_eth_dev *dev) + uint64_t dev_caps_mask = 0; + struct rte_kvargs *kvlist; + ++ /* Set default value of runtime config parameters. */ ++ hns->rx_func_hint = HNS3_IO_FUNC_HINT_NONE; ++ hns->tx_func_hint = HNS3_IO_FUNC_HINT_NONE; ++ hns->dev_caps_mask = 0; ++ hns->mbx_time_limit_ms = HNS3_MBX_DEF_TIME_LIMIT_MS; ++ + if (dev->device->devargs == NULL) + return; + +-- +2.33.0 + diff --git a/0020-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch b/0020-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch new file mode 100644 index 0000000..72ec829 --- /dev/null +++ b/0020-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch @@ -0,0 +1,32 @@ +From c02e48b92050856389403518be8bb70a4fdda551 Mon Sep 17 00:00:00 2001 +From: jiangheng12 +Date: Thu, 8 Jun 2023 20:59:15 +0800 +Subject: [PATCH] pdump: fix pcap_dump coredump caused by incorrect pkt_len + +--- + drivers/net/pcap/pcap_ethdev.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c +index ec29fd6..40ad166 100644 +--- a/drivers/net/pcap/pcap_ethdev.c ++++ b/drivers/net/pcap/pcap_ethdev.c +@@ -408,8 +408,13 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) + * in the mbuf (when the mbuf is contiguous) or, otherwise, + * a pointer to temp_data after copying into it. + */ +- pcap_dump((u_char *)dumper, &header, +- rte_pktmbuf_read(mbuf, 0, caplen, temp_data)); ++ const void *sp = rte_pktmbuf_read(mbuf, 0, caplen, temp_data); ++ if (sp == NULL) { ++ rte_pktmbuf_free(mbuf); ++ continue; ++ } else { ++ pcap_dump((u_char *)dumper, &header, sp); ++ } + + num_tx++; + tx_bytes += caplen; +-- +2.23.0 + diff --git a/0002-gro-fix-gro-with-tcp-push-flag.patch b/0021-gro-fix-gro-with-tcp-push-flag.patch similarity index 76% rename from 0002-gro-fix-gro-with-tcp-push-flag.patch rename to 0021-gro-fix-gro-with-tcp-push-flag.patch index 75632fe..ec67eaf 100644 --- a/0002-gro-fix-gro-with-tcp-push-flag.patch +++ b/0021-gro-fix-gro-with-tcp-push-flag.patch @@ -1,6 +1,6 @@ -From 027e250f2246b6a3c9b8fd370b27348e7b3f2be1 Mon Sep 17 00:00:00 2001 +From f541da70a5fdb553dc0cb71b3de54065dd245c2d Mon Sep 17 00:00:00 2001 From: jiangheng -Date: Mon, 19 Jun 2023 01:29:51 +0800 +Date: Mon, 19 Jun 2023 00:56:38 +0800 Subject: [PATCH] gro:fix gro with tcp push flag TCP data packets sometimes carry a PUSH flag. Currently, @@ -20,15 +20,15 @@ PUSH flag, the packets after GRO will carry PUSH flag. Reference: https://mails.dpdk.org/archives/stable/2022-July/039759.html --- - lib/librte_gro/gro_tcp4.c | 4 ++-- - lib/librte_gro/gro_tcp4.h | 16 +++++++++++++--- - 2 files changed, 15 insertions(+), 5 deletions(-) + lib/gro/gro_tcp4.c | 3 ++- + lib/gro/gro_tcp4.h | 16 +++++++++++++--- + 2 files changed, 15 insertions(+), 4 deletions(-) -diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c -index 15b7ae7..31d165f 100644 ---- a/lib/librte_gro/gro_tcp4.c -+++ b/lib/librte_gro/gro_tcp4.c -@@ -221,10 +221,10 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, +diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c +index d92e5dd..69b1b17 100644 +--- a/lib/gro/gro_tcp4.c ++++ b/lib/gro/gro_tcp4.c +@@ -221,10 +221,11 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; /* @@ -36,15 +36,15 @@ index 15b7ae7..31d165f 100644 + * Don't process the packet which has FIN, SYN, RST, URG, ECE * or CWR set. */ -- if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) + if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) + if (tcp_hdr->tcp_flags & (~(RTE_TCP_ACK_FLAG | RTE_TCP_PSH_FLAG))) return -1; /* trim the tail padding bytes */ -diff --git a/lib/librte_gro/gro_tcp4.h b/lib/librte_gro/gro_tcp4.h -index bb875a5..5032ef3 100644 ---- a/lib/librte_gro/gro_tcp4.h -+++ b/lib/librte_gro/gro_tcp4.h +diff --git a/lib/gro/gro_tcp4.h b/lib/gro/gro_tcp4.h +index bb875a5..3e08222 100644 +--- a/lib/gro/gro_tcp4.h ++++ b/lib/gro/gro_tcp4.h @@ -212,7 +212,8 @@ merge_two_tcp4_packets(struct gro_tcp4_item *item, uint16_t l2_offset) { @@ -70,10 +70,10 @@ index bb875a5..5032ef3 100644 + /* merge push flag to pkt_head */ + tail_tcp_hdr = rte_pktmbuf_mtod_offset(pkt_tail, -+ struct rte_tcp_hdr *, l3_offset); ++ struct rte_tcp_hdr *, l3_offset); + if (tail_tcp_hdr->tcp_flags & RTE_TCP_PSH_FLAG) { + head_tcp_hdr = rte_pktmbuf_mtod_offset(pkt_head, -+ struct rte_tcp_hdr *, l3_offset); ++ struct rte_tcp_hdr *, l3_offset); + head_tcp_hdr->tcp_flags |= RTE_TCP_PSH_FLAG; + } + diff --git a/0021-net-hns3-fix-vector-burst-when-PTP-enable.patch b/0021-net-hns3-fix-vector-burst-when-PTP-enable.patch new file mode 100644 index 0000000..032609b --- /dev/null +++ b/0021-net-hns3-fix-vector-burst-when-PTP-enable.patch @@ -0,0 +1,237 @@ +From 17efba586961886bd96033965f3ce4d5dcb3367a Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Mon, 17 Jan 2022 10:43:02 +0800 +Subject: [PATCH] net/hns3: fix vector burst when PTP enable + +If hardware supports IEEE 1588 PTP, PTP capability will be set. +Currently, vec and sve burst is unsupported when PTP capability is set. + +For sake of Rx/Tx performance, IEEE 1588 PTP is not supported in sve or +vec burst mode. When enabling IEEE 1588 PTP, Rx/Tx burst mode should be +simple or common. Rx/Tx burst mode could be set like this, for example: +-a 0000:35:00.0,rx_func_hint=common,tx_func_hint=common + +This patch supports vec and sve burst when PTP is disabled. And only +support simple or common burst When PTP is enabled. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +--- + doc/guides/nics/hns3.rst | 5 +++++ + drivers/net/hns3/hns3_ethdev.c | 8 +------- + drivers/net/hns3/hns3_ptp.c | 1 + + drivers/net/hns3/hns3_rxtx.c | 29 +++++++++++++++++------------ + drivers/net/hns3/hns3_rxtx_vec.c | 20 ++++++++++++-------- + 5 files changed, 36 insertions(+), 27 deletions(-) + +diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst +index 5f68a10ecf..791c9cc2ed 100644 +--- a/doc/guides/nics/hns3.rst ++++ b/doc/guides/nics/hns3.rst +@@ -290,5 +290,10 @@ Currently, we only support VF device driven by DPDK driver when PF is driven + by kernel mode hns3 ethdev driver. VF is not supported when PF is driven by + DPDK driver. + ++For sake of Rx/Tx performance, IEEE 1588 is not supported when using vec or ++sve burst function. When enabling IEEE 1588, Rx/Tx burst mode should be ++simple or common. It is recommended that enable IEEE 1588 before ethdev ++start. In this way, the correct Rx/Tx burst function can be selected. ++ + Build with ICC is not supported yet. + X86-32, Power8, ARMv7 and BSD are not supported yet. +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 3b897492d3..ef13d31d19 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -227,17 +227,11 @@ hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) + return ret; + } + +-static bool +-hns3_is_1588_event_type(uint32_t event_type) +-{ +- return (event_type == HNS3_VECTOR0_EVENT_PTP); +-} +- + static void + hns3_clear_event_cause(struct hns3_hw *hw, uint32_t event_type, uint32_t regclr) + { + if (event_type == HNS3_VECTOR0_EVENT_RST || +- hns3_is_1588_event_type(event_type)) ++ event_type == HNS3_VECTOR0_EVENT_PTP) + hns3_write_dev(hw, HNS3_MISC_RESET_STS_REG, regclr); + else if (event_type == HNS3_VECTOR0_EVENT_MBX) + hns3_write_dev(hw, HNS3_VECTOR0_CMDQ_SRC_REG, regclr); +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index 9a829d7011..1442241a4e 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -125,6 +125,7 @@ hns3_timesync_enable(struct rte_eth_dev *dev) + + if (pf->ptp_enable) + return 0; ++ hns3_warn(hw, "note: please ensure Rx/Tx burst mode is simple or common when enabling PTP!"); + + rte_spinlock_lock(&hw->lock); + ret = hns3_timesync_configure(hns, true); +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index c86aeb2366..c43131cac6 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -2388,14 +2388,14 @@ hns3_rx_alloc_buffer(struct hns3_rx_queue *rxq) + return rte_mbuf_raw_alloc(rxq->mb_pool); + } + +-static inline void ++static void + hns3_rx_ptp_timestamp_handle(struct hns3_rx_queue *rxq, struct rte_mbuf *mbuf, +- volatile struct hns3_desc *rxd) ++ uint64_t timestamp) + { + struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(rxq->hns); +- uint64_t timestamp = rte_le_to_cpu_64(rxd->timestamp); + +- mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP | RTE_MBUF_F_RX_IEEE1588_TMST; ++ mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP | ++ RTE_MBUF_F_RX_IEEE1588_TMST; + if (hns3_timestamp_rx_dynflag > 0) { + *RTE_MBUF_DYNFIELD(mbuf, hns3_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = timestamp; +@@ -2469,7 +2469,8 @@ hns3_recv_pkts_simple(void *rx_queue, + rxe->mbuf = nmb; + + if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B))) +- hns3_rx_ptp_timestamp_handle(rxq, rxm, rxdp); ++ hns3_rx_ptp_timestamp_handle(rxq, rxm, ++ rte_le_to_cpu_64(rxdp->timestamp)); + + dma_addr = rte_mbuf_data_iova_default(nmb); + rxdp->addr = rte_cpu_to_le_64(dma_addr); +@@ -2540,6 +2541,7 @@ hns3_recv_scattered_pkts(void *rx_queue, + struct rte_mbuf *rxm; + struct rte_eth_dev *dev; + uint32_t bd_base_info; ++ uint64_t timestamp; + uint32_t l234_info; + uint32_t gro_size; + uint32_t ol_info; +@@ -2649,6 +2651,9 @@ hns3_recv_scattered_pkts(void *rx_queue, + rxm = rxe->mbuf; + rxe->mbuf = nmb; + ++ if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B))) ++ timestamp = rte_le_to_cpu_64(rxdp->timestamp); ++ + dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb)); + rxdp->rx.bd_base_info = 0; + rxdp->addr = dma_addr; +@@ -2671,7 +2676,7 @@ hns3_recv_scattered_pkts(void *rx_queue, + } + + if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B))) +- hns3_rx_ptp_timestamp_handle(rxq, first_seg, rxdp); ++ hns3_rx_ptp_timestamp_handle(rxq, first_seg, timestamp); + + /* + * The last buffer of the received packet. packet len from +@@ -4044,7 +4049,7 @@ static inline void + hns3_tx_setup_4bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) + { + #define PER_LOOP_NUM 4 +- const uint16_t bd_flag = BIT(HNS3_TXD_VLD_B) | BIT(HNS3_TXD_FE_B); ++ uint16_t bd_flag = BIT(HNS3_TXD_VLD_B) | BIT(HNS3_TXD_FE_B); + uint64_t dma_addr; + uint32_t i; + +@@ -4055,6 +4060,8 @@ hns3_tx_setup_4bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) + txdp->tx.paylen_fd_dop_ol4cs = 0; + txdp->tx.type_cs_vlan_tso_len = 0; + txdp->tx.ol_type_vlan_len_msec = 0; ++ if (unlikely((*pkts)->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)) ++ bd_flag |= BIT(HNS3_TXD_TSYN_B); + txdp->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(bd_flag); + } + } +@@ -4062,7 +4069,7 @@ hns3_tx_setup_4bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) + static inline void + hns3_tx_setup_1bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) + { +- const uint16_t bd_flag = BIT(HNS3_TXD_VLD_B) | BIT(HNS3_TXD_FE_B); ++ uint16_t bd_flag = BIT(HNS3_TXD_VLD_B) | BIT(HNS3_TXD_FE_B); + uint64_t dma_addr; + + dma_addr = rte_mbuf_data_iova(*pkts); +@@ -4071,6 +4078,8 @@ hns3_tx_setup_1bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) + txdp->tx.paylen_fd_dop_ol4cs = 0; + txdp->tx.type_cs_vlan_tso_len = 0; + txdp->tx.ol_type_vlan_len_msec = 0; ++ if (unlikely((*pkts)->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)) ++ bd_flag |= BIT(HNS3_TXD_TSYN_B); + txdp->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(bd_flag); + } + +@@ -4312,10 +4321,6 @@ hns3_tx_check_simple_support(struct rte_eth_dev *dev) + { + uint64_t offloads = dev->data->dev_conf.txmode.offloads; + +- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- if (hns3_dev_get_support(hw, PTP)) +- return false; +- + return (offloads == (offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)); + } + +diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c +index 455110361a..73f0ab6bc8 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec.c ++++ b/drivers/net/hns3/hns3_rxtx_vec.c +@@ -17,15 +17,17 @@ int + hns3_tx_check_vec_support(struct rte_eth_dev *dev) + { + struct rte_eth_txmode *txmode = &dev->data->dev_conf.txmode; +- +- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- if (hns3_dev_get_support(hw, PTP)) +- return -ENOTSUP; ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_pf *pf = &hns->pf; + + /* Only support RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE */ + if (txmode->offloads != RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) + return -ENOTSUP; + ++ /* Vec is not supported when PTP enabled */ ++ if (pf->ptp_enable) ++ return -ENOTSUP; ++ + return 0; + } + +@@ -232,10 +234,8 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) + struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; + uint64_t offloads_mask = RTE_ETH_RX_OFFLOAD_TCP_LRO | + RTE_ETH_RX_OFFLOAD_VLAN; +- +- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- if (hns3_dev_get_support(hw, PTP)) +- return -ENOTSUP; ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_pf *pf = &hns->pf; + + if (dev->data->scattered_rx) + return -ENOTSUP; +@@ -249,5 +249,9 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) + if (hns3_rxq_iterate(dev, hns3_rxq_vec_check, NULL) != 0) + return -ENOTSUP; + ++ /* Vec is not supported when PTP enabled */ ++ if (pf->ptp_enable) ++ return -ENOTSUP; ++ + return 0; + } +-- +2.33.0 + diff --git a/0022-eal-loongarch-support-LoongArch-architecture.patch b/0022-eal-loongarch-support-LoongArch-architecture.patch new file mode 100644 index 0000000..87738d1 --- /dev/null +++ b/0022-eal-loongarch-support-LoongArch-architecture.patch @@ -0,0 +1,1630 @@ +From 4dae75f4278caf8477ddf0e3140f86153f51a2e5 Mon Sep 17 00:00:00 2001 +From: Min Zhou +Date: Thu, 29 Jun 2023 20:35:55 +0800 +Subject: [PATCH 1/1] eal/loongarch: support LoongArch architecture + +Add all necessary elements for DPDK to compile and run EAL on +LoongArch64 Soc. + +This includes: + +- EAL library implementation for LoongArch ISA. +- meson build structure for 'loongarch' architecture. + RTE_ARCH_LOONGARCH define is added for architecture identification. +- xmm_t structure operation stubs as there is no vector support in +the current version for LoongArch. + +Compilation was tested on Debian and CentOS using loongarch64 +cross-compile toolchain from x86 build hosts. Functions were tested +on Loongnix and Kylin which are two Linux distributions supported +LoongArch host based on Linux 4.19 maintained by Loongson +Corporation. + +We also tested DPDK on LoongArch with some external applications, +including: Pktgen-DPDK, OVS, VPP. + +The platform is currently marked as linux-only because there is no +other OS than Linux support LoongArch host currently. + +The i40e PMD driver is disabled on LoongArch because of the absence +of vector support in the current version. + +Signed-off-by: Min Zhou +--- + app/test/test_cpuflags.c | 41 ++++ + app/test/test_xmmt_ops.h | 12 + + .../loongarch/loongarch_loongarch64_linux_gcc | 16 ++ + config/loongarch/meson.build | 43 ++++ + drivers/net/i40e/meson.build | 6 + + drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- + drivers/net/memif/rte_eth_memif.h | 2 + + drivers/net/tap/tap_bpf.h | 2 + + examples/l3fwd/l3fwd_em.c | 8 + + examples/l3fwd/l3fwd_fib.c | 2 + + examples/l3fwd/l3fwd_lpm.c | 5 +- + examples/l3fwd/l3fwd_lpm_lsx.h | 30 +++ + lib/eal/linux/eal_memory.c | 4 + + lib/eal/loongarch/include/meson.build | 21 ++ + lib/eal/loongarch/include/rte_atomic.h | 47 ++++ + lib/eal/loongarch/include/rte_byteorder.h | 40 ++++ + lib/eal/loongarch/include/rte_cpuflags.h | 39 ++++ + lib/eal/loongarch/include/rte_cycles.h | 47 ++++ + lib/eal/loongarch/include/rte_io.h | 18 ++ + lib/eal/loongarch/include/rte_mcslock.h | 18 ++ + lib/eal/loongarch/include/rte_memcpy.h | 61 +++++ + lib/eal/loongarch/include/rte_pause.h | 24 ++ + lib/eal/loongarch/include/rte_pflock.h | 18 ++ + .../loongarch/include/rte_power_intrinsics.h | 20 ++ + lib/eal/loongarch/include/rte_prefetch.h | 48 ++++ + lib/eal/loongarch/include/rte_rwlock.h | 42 ++++ + lib/eal/loongarch/include/rte_spinlock.h | 64 ++++++ + lib/eal/loongarch/include/rte_ticketlock.h | 214 ++++++++++++++++++ + lib/eal/loongarch/include/rte_vect.h | 65 ++++++ + lib/eal/loongarch/meson.build | 11 + + lib/eal/loongarch/rte_cpuflags.c | 93 ++++++++ + lib/eal/loongarch/rte_cycles.c | 45 ++++ + lib/eal/loongarch/rte_hypervisor.c | 11 + + lib/eal/loongarch/rte_power_intrinsics.c | 53 +++++ + lib/lpm/meson.build | 1 + + lib/lpm/rte_lpm.h | 6 +- + lib/lpm/rte_lpm_scalar.h | 38 ++++ + meson.build | 2 + + 38 files changed, 1216 insertions(+), 5 deletions(-) + create mode 100644 config/loongarch/loongarch_loongarch64_linux_gcc + create mode 100644 config/loongarch/meson.build + create mode 100644 examples/l3fwd/l3fwd_lpm_lsx.h + create mode 100644 lib/eal/loongarch/include/meson.build + create mode 100644 lib/eal/loongarch/include/rte_atomic.h + create mode 100644 lib/eal/loongarch/include/rte_byteorder.h + create mode 100644 lib/eal/loongarch/include/rte_cpuflags.h + create mode 100644 lib/eal/loongarch/include/rte_cycles.h + create mode 100644 lib/eal/loongarch/include/rte_io.h + create mode 100644 lib/eal/loongarch/include/rte_mcslock.h + create mode 100644 lib/eal/loongarch/include/rte_memcpy.h + create mode 100644 lib/eal/loongarch/include/rte_pause.h + create mode 100644 lib/eal/loongarch/include/rte_pflock.h + create mode 100644 lib/eal/loongarch/include/rte_power_intrinsics.h + create mode 100644 lib/eal/loongarch/include/rte_prefetch.h + create mode 100644 lib/eal/loongarch/include/rte_rwlock.h + create mode 100644 lib/eal/loongarch/include/rte_spinlock.h + create mode 100644 lib/eal/loongarch/include/rte_ticketlock.h + create mode 100644 lib/eal/loongarch/include/rte_vect.h + create mode 100644 lib/eal/loongarch/meson.build + create mode 100644 lib/eal/loongarch/rte_cpuflags.c + create mode 100644 lib/eal/loongarch/rte_cycles.c + create mode 100644 lib/eal/loongarch/rte_hypervisor.c + create mode 100644 lib/eal/loongarch/rte_power_intrinsics.c + create mode 100644 lib/lpm/rte_lpm_scalar.h + +diff --git a/app/test/test_cpuflags.c b/app/test/test_cpuflags.c +index 40f6ac7..17c9986 100644 +--- a/app/test/test_cpuflags.c ++++ b/app/test/test_cpuflags.c +@@ -200,6 +200,47 @@ test_cpuflags(void) + CHECK_FOR_FLAG(RTE_CPUFLAG_INVTSC); + #endif + ++#if defined(RTE_ARCH_LOONGARCH) ++ printf("Check for CPUCFG:\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_CPUCFG); ++ ++ printf("Check for LAM:\t\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_LAM); ++ ++ printf("Check for UAL:\t\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_UAL); ++ ++ printf("Check for FPU:\t\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_FPU); ++ ++ printf("Check for LSX:\t\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_LSX); ++ ++ printf("Check for LASX:\t\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_LASX); ++ ++ printf("Check for CRC32:\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_CRC32); ++ ++ printf("Check for COMPLEX:\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_COMPLEX); ++ ++ printf("Check for CRYPTO:\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_CRYPTO); ++ ++ printf("Check for LVZ:\t\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_LVZ); ++ ++ printf("Check for LBT_X86:\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_LBT_X86); ++ ++ printf("Check for LBT_ARM:\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_LBT_ARM); ++ ++ printf("Check for LBT_MIPS:\t"); ++ CHECK_FOR_FLAG(RTE_CPUFLAG_LBT_MIPS); ++#endif ++ + /* + * Check if invalid data is handled properly + */ +diff --git a/app/test/test_xmmt_ops.h b/app/test/test_xmmt_ops.h +index 3a82d5e..21490e7 100644 +--- a/app/test/test_xmmt_ops.h ++++ b/app/test/test_xmmt_ops.h +@@ -49,6 +49,18 @@ vect_set_epi32(int i3, int i2, int i1, int i0) + return data; + } + ++#elif defined(RTE_ARCH_LOONGARCH) ++ ++#define vect_loadu_sil128(p) vect_load_128(p) ++ ++/* sets the 4 signed 32-bit integer values and returns the xmm_t variable */ ++static __rte_always_inline xmm_t ++vect_set_epi32(int i3, int i2, int i1, int i0) ++{ ++ xmm_t data = (xmm_t){.u32 = {i0, i1, i2, i3}}; ++ ++ return data; ++} + #endif + + #endif /* _TEST_XMMT_OPS_H_ */ +diff --git a/config/loongarch/loongarch_loongarch64_linux_gcc b/config/loongarch/loongarch_loongarch64_linux_gcc +new file mode 100644 +index 0000000..c933022 +--- /dev/null ++++ b/config/loongarch/loongarch_loongarch64_linux_gcc +@@ -0,0 +1,16 @@ ++[binaries] ++c = ['ccache', 'loongarch64-unknown-linux-gnu-gcc'] ++cpp = ['ccache', 'loongarch64-unknown-linux-gnu-g++'] ++ar = 'loongarch64-unknown-linux-gnu-gcc-ar' ++strip = 'loongarch64-unknown-linux-gnu-strip' ++pcap-config = '' ++ ++[host_machine] ++system = 'linux' ++cpu_family = 'loongarch64' ++cpu = '3a5000' ++endian = 'little' ++ ++[properties] ++implementor_id = 'generic' ++implementor_pn = 'default' +diff --git a/config/loongarch/meson.build b/config/loongarch/meson.build +new file mode 100644 +index 0000000..99dabef +--- /dev/null ++++ b/config/loongarch/meson.build +@@ -0,0 +1,43 @@ ++# SPDX-License-Identifier: BSD-3-Clause ++# Copyright(c) 2022 Loongson Technology Corporation Limited ++ ++if not dpdk_conf.get('RTE_ARCH_64') ++ error('Only 64-bit compiles are supported for this platform type') ++endif ++dpdk_conf.set('RTE_ARCH', 'loongarch') ++dpdk_conf.set('RTE_ARCH_LOONGARCH', 1) ++dpdk_conf.set('RTE_FORCE_INTRINSICS', 1) ++ ++machine_args_generic = [ ++ ['default', ['-march=loongarch64']], ++] ++ ++flags_generic = [ ++ ['RTE_MACHINE', '"loongarch64"'], ++ ['RTE_MAX_LCORE', 64], ++ ['RTE_MAX_NUMA_NODES', 16], ++ ['RTE_CACHE_LINE_SIZE', 64]] ++ ++impl_generic = ['Generic loongarch', flags_generic, machine_args_generic] ++ ++machine = [] ++machine_args = [] ++ ++machine = impl_generic ++impl_pn = 'default' ++ ++message('Implementer : ' + machine[0]) ++foreach flag: machine[1] ++ if flag.length() > 0 ++ dpdk_conf.set(flag[0], flag[1]) ++ endif ++endforeach ++ ++foreach marg: machine[2] ++ if marg[0] == impl_pn ++ foreach f: marg[1] ++ machine_args += f ++ endforeach ++ endif ++endforeach ++message(machine_args) +diff --git a/drivers/net/i40e/meson.build b/drivers/net/i40e/meson.build +index efc5f93..19ddd50 100644 +--- a/drivers/net/i40e/meson.build ++++ b/drivers/net/i40e/meson.build +@@ -1,6 +1,12 @@ + # SPDX-License-Identifier: BSD-3-Clause + # Copyright(c) 2017 Intel Corporation + ++if arch_subdir == 'loongarch' ++ build = false ++ reason = 'not supported on LoongArch' ++ subdir_done() ++endif ++ + cflags += ['-DPF_DRIVER', + '-DVF_DRIVER', + '-DINTEGRATED_VF', +diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c +index d7c80d4..e19e832 100644 +--- a/drivers/net/ixgbe/ixgbe_rxtx.c ++++ b/drivers/net/ixgbe/ixgbe_rxtx.c +@@ -5958,8 +5958,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, + return 0; + } + +-/* Stubs needed for linkage when RTE_ARCH_PPC_64 is set */ +-#if defined(RTE_ARCH_PPC_64) ++/* Stubs needed for linkage when RTE_ARCH_PPC_64 or RTE_ARCH_LOONGARCH is set */ ++#if defined(RTE_ARCH_PPC_64) || defined(RTE_ARCH_LOONGARCH) + int + ixgbe_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev) + { +diff --git a/drivers/net/memif/rte_eth_memif.h b/drivers/net/memif/rte_eth_memif.h +index a5ee23d..864a498 100644 +--- a/drivers/net/memif/rte_eth_memif.h ++++ b/drivers/net/memif/rte_eth_memif.h +@@ -180,6 +180,8 @@ const char *memif_version(void); + #define __NR_memfd_create 360 + #elif defined __i386__ + #define __NR_memfd_create 356 ++#elif defined __loongarch__ ++#define __NR_memfd_create 279 + #else + #error "__NR_memfd_create unknown for this architecture" + #endif +diff --git a/drivers/net/tap/tap_bpf.h b/drivers/net/tap/tap_bpf.h +index f0b9fc7..de7ab91 100644 +--- a/drivers/net/tap/tap_bpf.h ++++ b/drivers/net/tap/tap_bpf.h +@@ -101,6 +101,8 @@ union bpf_attr { + # define __NR_bpf 351 + # elif defined(__powerpc__) + # define __NR_bpf 361 ++# elif defined(__loongarch__) ++# define __NR_bpf 280 + # else + # error __NR_bpf not defined + # endif +diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c +index 5cc4a4d..67e042f 100644 +--- a/examples/l3fwd/l3fwd_em.c ++++ b/examples/l3fwd/l3fwd_em.c +@@ -270,6 +270,14 @@ em_mask_key(void *key, xmm_t mask) + + return vec_and(data, mask); + } ++#elif defined(RTE_ARCH_LOONGARCH) ++static inline xmm_t ++em_mask_key(void *key, xmm_t mask) ++{ ++ xmm_t data = vect_load_128(key); ++ ++ return vect_and(data, mask); ++} + #else + #error No vector engine (SSE, NEON, ALTIVEC) available, check your toolchain + #endif +diff --git a/examples/l3fwd/l3fwd_fib.c b/examples/l3fwd/l3fwd_fib.c +index 2110459..4aa2fa5 100644 +--- a/examples/l3fwd/l3fwd_fib.c ++++ b/examples/l3fwd/l3fwd_fib.c +@@ -18,6 +18,8 @@ + #include "l3fwd_neon.h" + #elif defined RTE_ARCH_PPC_64 + #include "l3fwd_altivec.h" ++#else ++#include "l3fwd_common.h" + #endif + #include "l3fwd_event.h" + #include "l3fwd_route.h" +diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c +index a5b476c..160a7c6 100644 +--- a/examples/l3fwd/l3fwd_lpm.c ++++ b/examples/l3fwd/l3fwd_lpm.c +@@ -135,6 +135,9 @@ lpm_get_dst_port_with_ipv4(const struct lcore_conf *qconf, struct rte_mbuf *pkt, + #include "l3fwd_lpm_neon.h" + #elif defined(RTE_ARCH_PPC_64) + #include "l3fwd_lpm_altivec.h" ++#elif defined(RTE_ARCH_LOONGARCH) ++#include "l3fwd_lpm_lsx.h" ++#include "l3fwd_lpm.h" + #else + #include "l3fwd_lpm.h" + #endif +@@ -231,7 +234,7 @@ lpm_process_event_pkt(const struct lcore_conf *lconf, struct rte_mbuf *mbuf) + mbuf->port = lpm_get_dst_port(lconf, mbuf, mbuf->port); + + #if defined RTE_ARCH_X86 || defined __ARM_NEON \ +- || defined RTE_ARCH_PPC_64 ++ || defined RTE_ARCH_PPC_64 || defined RTE_ARCH_LOONGARCH + process_packet(mbuf, &mbuf->port); + #else + +diff --git a/examples/l3fwd/l3fwd_lpm_lsx.h b/examples/l3fwd/l3fwd_lpm_lsx.h +new file mode 100644 +index 0000000..a4d7449 +--- /dev/null ++++ b/examples/l3fwd/l3fwd_lpm_lsx.h +@@ -0,0 +1,30 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef __L3FWD_LPM_LSX_H__ ++#define __L3FWD_LPM_LSX_H__ ++ ++#include "l3fwd_common.h" ++ ++static inline void ++process_packet(struct rte_mbuf *pkt, uint16_t *hop) ++{ ++ struct rte_ether_hdr *eth_hdr; ++ ++ /* Run rfc1812 if packet is ipv4 and checks enabled. */ ++#if defined DO_RFC_1812_CHECKS ++ rfc1812_process( ++ (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod( ++ pkt, struct rte_ether_hdr *) + ++ 1), ++ hop, pkt->packet_type); ++#endif ++ ++ /* Set MAC addresses. */ ++ eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); ++ *(uint64_t *)ð_hdr->dst_addr = dest_eth_addr[*hop]; ++ rte_ether_addr_copy(&ports_eth_addr[*hop], ð_hdr->src_addr); ++} ++ ++#endif /* __L3FWD_LPM_LSX_H__ */ +diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c +index 03a4f2d..d97f1e4 100644 +--- a/lib/eal/linux/eal_memory.c ++++ b/lib/eal/linux/eal_memory.c +@@ -86,7 +86,11 @@ uint64_t eal_get_baseaddr(void) + * rte_mem_check_dma_mask for ensuring all memory is within supported + * range. + */ ++#if defined(RTE_ARCH_LOONGARCH) ++ return 0x7000000000ULL; ++#else + return 0x100000000ULL; ++#endif + } + + /* +diff --git a/lib/eal/loongarch/include/meson.build b/lib/eal/loongarch/include/meson.build +new file mode 100644 +index 0000000..1fa96e4 +--- /dev/null ++++ b/lib/eal/loongarch/include/meson.build +@@ -0,0 +1,21 @@ ++# SPDX-License-Identifier: BSD-3-Clause ++# Copyright(c) 2022 Loongson Technology Corporation Limited ++ ++arch_headers = files( ++ 'rte_atomic.h', ++ 'rte_byteorder.h', ++ 'rte_cpuflags.h', ++ 'rte_cycles.h', ++ 'rte_io.h', ++ 'rte_mcslock.h', ++ 'rte_memcpy.h', ++ 'rte_pause.h', ++ 'rte_pflock.h', ++ 'rte_power_intrinsics.h', ++ 'rte_prefetch.h', ++ 'rte_rwlock.h', ++ 'rte_spinlock.h', ++ 'rte_ticketlock.h', ++ 'rte_vect.h', ++) ++install_headers(arch_headers, subdir: get_option('include_subdir_arch')) +diff --git a/lib/eal/loongarch/include/rte_atomic.h b/lib/eal/loongarch/include/rte_atomic.h +new file mode 100644 +index 0000000..3c82845 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_atomic.h +@@ -0,0 +1,47 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_ATOMIC_LOONGARCH_H ++#define RTE_ATOMIC_LOONGARCH_H ++ ++#ifndef RTE_FORCE_INTRINSICS ++# error Platform must be built with RTE_FORCE_INTRINSICS ++#endif ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include "generic/rte_atomic.h" ++ ++#define rte_mb() do { asm volatile("dbar 0":::"memory"); } while (0) ++ ++#define rte_wmb() rte_mb() ++ ++#define rte_rmb() rte_mb() ++ ++#define rte_smp_mb() rte_mb() ++ ++#define rte_smp_wmb() rte_mb() ++ ++#define rte_smp_rmb() rte_mb() ++ ++#define rte_io_mb() rte_mb() ++ ++#define rte_io_wmb() rte_mb() ++ ++#define rte_io_rmb() rte_mb() ++ ++static __rte_always_inline void ++rte_atomic_thread_fence(int memorder) ++{ ++ __atomic_thread_fence(memorder); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_ATOMIC_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_byteorder.h b/lib/eal/loongarch/include/rte_byteorder.h +new file mode 100644 +index 0000000..0da6097 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_byteorder.h +@@ -0,0 +1,40 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_BYTEORDER_LOONGARCH_H ++#define RTE_BYTEORDER_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include "generic/rte_byteorder.h" ++ ++#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN ++ ++#define rte_cpu_to_le_16(x) (x) ++#define rte_cpu_to_le_32(x) (x) ++#define rte_cpu_to_le_64(x) (x) ++ ++#define rte_cpu_to_be_16(x) rte_bswap16(x) ++#define rte_cpu_to_be_32(x) rte_bswap32(x) ++#define rte_cpu_to_be_64(x) rte_bswap64(x) ++ ++#define rte_le_to_cpu_16(x) (x) ++#define rte_le_to_cpu_32(x) (x) ++#define rte_le_to_cpu_64(x) (x) ++ ++#define rte_be_to_cpu_16(x) rte_bswap16(x) ++#define rte_be_to_cpu_32(x) rte_bswap32(x) ++#define rte_be_to_cpu_64(x) rte_bswap64(x) ++ ++#else /* RTE_BIG_ENDIAN */ ++#error "LoongArch not support big endian!" ++#endif ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_BYTEORDER_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_cpuflags.h b/lib/eal/loongarch/include/rte_cpuflags.h +new file mode 100644 +index 0000000..1c80779 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_cpuflags.h +@@ -0,0 +1,39 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_CPUFLAGS_LOONGARCH_H ++#define RTE_CPUFLAGS_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/** ++ * Enumeration of all CPU features supported ++ */ ++enum rte_cpu_flag_t { ++ RTE_CPUFLAG_CPUCFG = 0, ++ RTE_CPUFLAG_LAM, ++ RTE_CPUFLAG_UAL, ++ RTE_CPUFLAG_FPU, ++ RTE_CPUFLAG_LSX, ++ RTE_CPUFLAG_LASX, ++ RTE_CPUFLAG_CRC32, ++ RTE_CPUFLAG_COMPLEX, ++ RTE_CPUFLAG_CRYPTO, ++ RTE_CPUFLAG_LVZ, ++ RTE_CPUFLAG_LBT_X86, ++ RTE_CPUFLAG_LBT_ARM, ++ RTE_CPUFLAG_LBT_MIPS, ++ /* The last item */ ++ RTE_CPUFLAG_NUMFLAGS /**< This should always be the last! */ ++}; ++ ++#include "generic/rte_cpuflags.h" ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_CPUFLAGS_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_cycles.h b/lib/eal/loongarch/include/rte_cycles.h +new file mode 100644 +index 0000000..f612d1a +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_cycles.h +@@ -0,0 +1,47 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_CYCLES_LOONGARCH_H ++#define RTE_CYCLES_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include "generic/rte_cycles.h" ++ ++/** ++ * Read the time base register. ++ * ++ * @return ++ * The time base for this lcore. ++ */ ++static inline uint64_t ++rte_rdtsc(void) ++{ ++ uint64_t count; ++ ++ __asm__ __volatile__ ( ++ "rdtime.d %[cycles], $zero\n" ++ : [cycles] "=r" (count) ++ :: ++ ); ++ return count; ++} ++ ++static inline uint64_t ++rte_rdtsc_precise(void) ++{ ++ rte_mb(); ++ return rte_rdtsc(); ++} ++ ++static inline uint64_t ++rte_get_tsc_cycles(void) { return rte_rdtsc(); } ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_CYCLES_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_io.h b/lib/eal/loongarch/include/rte_io.h +new file mode 100644 +index 0000000..40e40ef +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_io.h +@@ -0,0 +1,18 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_IO_LOONGARCH_H ++#define RTE_IO_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include "generic/rte_io.h" ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_IO_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_mcslock.h b/lib/eal/loongarch/include/rte_mcslock.h +new file mode 100644 +index 0000000..c4484b6 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_mcslock.h +@@ -0,0 +1,18 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef _RTE_MCSLOCK_LOONGARCH_H_ ++#define _RTE_MCSLOCK_LOONGARCH_H_ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include "generic/rte_mcslock.h" ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* _RTE_MCSLOCK_LOONGARCH_H_ */ +diff --git a/lib/eal/loongarch/include/rte_memcpy.h b/lib/eal/loongarch/include/rte_memcpy.h +new file mode 100644 +index 0000000..22578d4 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_memcpy.h +@@ -0,0 +1,61 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_MEMCPY_LOONGARCH_H ++#define RTE_MEMCPY_LOONGARCH_H ++ ++#include ++#include ++ ++#include "rte_common.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include "generic/rte_memcpy.h" ++ ++static inline void ++rte_mov16(uint8_t *dst, const uint8_t *src) ++{ ++ memcpy(dst, src, 16); ++} ++ ++static inline void ++rte_mov32(uint8_t *dst, const uint8_t *src) ++{ ++ memcpy(dst, src, 32); ++} ++ ++static inline void ++rte_mov48(uint8_t *dst, const uint8_t *src) ++{ ++ memcpy(dst, src, 48); ++} ++ ++static inline void ++rte_mov64(uint8_t *dst, const uint8_t *src) ++{ ++ memcpy(dst, src, 64); ++} ++ ++static inline void ++rte_mov128(uint8_t *dst, const uint8_t *src) ++{ ++ memcpy(dst, src, 128); ++} ++ ++static inline void ++rte_mov256(uint8_t *dst, const uint8_t *src) ++{ ++ memcpy(dst, src, 256); ++} ++ ++#define rte_memcpy(d, s, n) memcpy((d), (s), (n)) ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_MEMCPY_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_pause.h b/lib/eal/loongarch/include/rte_pause.h +new file mode 100644 +index 0000000..4302e1b +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_pause.h +@@ -0,0 +1,24 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_PAUSE_LOONGARCH_H ++#define RTE_PAUSE_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include "rte_atomic.h" ++ ++#include "generic/rte_pause.h" ++ ++static inline void rte_pause(void) ++{ ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_PAUSE_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_pflock.h b/lib/eal/loongarch/include/rte_pflock.h +new file mode 100644 +index 0000000..d3e5824 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_pflock.h +@@ -0,0 +1,18 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2021 Microsoft Corporation ++ */ ++ ++#ifndef _RTE_PFLOCK_LOONGARCH_H_ ++#define _RTE_PFLOCK_LOONGARCH_H_ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include "generic/rte_pflock.h" ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* _RTE_PFLOCK_LOONGARCH_H_ */ +diff --git a/lib/eal/loongarch/include/rte_power_intrinsics.h b/lib/eal/loongarch/include/rte_power_intrinsics.h +new file mode 100644 +index 0000000..d5dbd94 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_power_intrinsics.h +@@ -0,0 +1,20 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_POWER_INTRINSIC_LOONGARCH_H ++#define RTE_POWER_INTRINSIC_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++ ++#include "generic/rte_power_intrinsics.h" ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_POWER_INTRINSIC_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_prefetch.h b/lib/eal/loongarch/include/rte_prefetch.h +new file mode 100644 +index 0000000..64b1fd2 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_prefetch.h +@@ -0,0 +1,48 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_PREFETCH_LOONGARCH_H ++#define RTE_PREFETCH_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include "generic/rte_prefetch.h" ++ ++static inline void rte_prefetch0(const volatile void *p) ++{ ++ __builtin_prefetch((const void *)(uintptr_t)p, 0, 3); ++} ++ ++static inline void rte_prefetch1(const volatile void *p) ++{ ++ __builtin_prefetch((const void *)(uintptr_t)p, 0, 2); ++} ++ ++static inline void rte_prefetch2(const volatile void *p) ++{ ++ __builtin_prefetch((const void *)(uintptr_t)p, 0, 1); ++} ++ ++static inline void rte_prefetch_non_temporal(const volatile void *p) ++{ ++ /* non-temporal version not available, fallback to rte_prefetch0 */ ++ rte_prefetch0(p); ++} ++ ++__rte_experimental ++static inline void ++rte_cldemote(const volatile void *p) ++{ ++ RTE_SET_USED(p); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_PREFETCH_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_rwlock.h b/lib/eal/loongarch/include/rte_rwlock.h +new file mode 100644 +index 0000000..aedc6f3 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_rwlock.h +@@ -0,0 +1,42 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_RWLOCK_LOONGARCH_H ++#define RTE_RWLOCK_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include "generic/rte_rwlock.h" ++ ++static inline void ++rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) ++{ ++ rte_rwlock_read_lock(rwl); ++} ++ ++static inline void ++rte_rwlock_read_unlock_tm(rte_rwlock_t *rwl) ++{ ++ rte_rwlock_read_unlock(rwl); ++} ++ ++static inline void ++rte_rwlock_write_lock_tm(rte_rwlock_t *rwl) ++{ ++ rte_rwlock_write_lock(rwl); ++} ++ ++static inline void ++rte_rwlock_write_unlock_tm(rte_rwlock_t *rwl) ++{ ++ rte_rwlock_write_unlock(rwl); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_RWLOCK_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_spinlock.h b/lib/eal/loongarch/include/rte_spinlock.h +new file mode 100644 +index 0000000..e8d34e9 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_spinlock.h +@@ -0,0 +1,64 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_SPINLOCK_LOONGARCH_H ++#define RTE_SPINLOCK_LOONGARCH_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include "generic/rte_spinlock.h" ++ ++#ifndef RTE_FORCE_INTRINSICS ++# error Platform must be built with RTE_FORCE_INTRINSICS ++#endif ++ ++static inline int rte_tm_supported(void) ++{ ++ return 0; ++} ++ ++static inline void ++rte_spinlock_lock_tm(rte_spinlock_t *sl) ++{ ++ rte_spinlock_lock(sl); /* fall-back */ ++} ++ ++static inline int ++rte_spinlock_trylock_tm(rte_spinlock_t *sl) ++{ ++ return rte_spinlock_trylock(sl); ++} ++ ++static inline void ++rte_spinlock_unlock_tm(rte_spinlock_t *sl) ++{ ++ rte_spinlock_unlock(sl); ++} ++ ++static inline void ++rte_spinlock_recursive_lock_tm(rte_spinlock_recursive_t *slr) ++{ ++ rte_spinlock_recursive_lock(slr); /* fall-back */ ++} ++ ++static inline void ++rte_spinlock_recursive_unlock_tm(rte_spinlock_recursive_t *slr) ++{ ++ rte_spinlock_recursive_unlock(slr); ++} ++ ++static inline int ++rte_spinlock_recursive_trylock_tm(rte_spinlock_recursive_t *slr) ++{ ++ return rte_spinlock_recursive_trylock(slr); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_SPINLOCK_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/include/rte_ticketlock.h b/lib/eal/loongarch/include/rte_ticketlock.h +new file mode 100644 +index 0000000..48494cb +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_ticketlock.h +@@ -0,0 +1,214 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef _RTE_TICKETLOCK_H_ ++#define _RTE_TICKETLOCK_H_ ++ ++/** ++ * @file ++ * ++ * RTE ticket locks ++ * ++ * This file defines an API for ticket locks, which give each waiting ++ * thread a ticket and take the lock one by one, first come, first ++ * serviced. ++ * ++ * All locks must be initialised before use, and only initialised once. ++ * ++ */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * The rte_ticketlock_t type. ++ */ ++typedef union { ++ uint32_t tickets; ++ struct { ++ uint16_t current; ++ uint16_t next; ++ } s; ++} rte_ticketlock_t; ++ ++/** ++ * A static ticketlock initializer. ++ */ ++#define RTE_TICKETLOCK_INITIALIZER { 0 } ++ ++/** ++ * Initialize the ticketlock to an unlocked state. ++ * ++ * @param tl ++ * A pointer to the ticketlock. ++ */ ++static inline void ++rte_ticketlock_init(rte_ticketlock_t *tl) ++{ ++ __atomic_store_n(&tl->tickets, 0, __ATOMIC_RELAXED); ++} ++ ++/** ++ * Take the ticketlock. ++ * ++ * @param tl ++ * A pointer to the ticketlock. ++ */ ++static inline void ++rte_ticketlock_lock(rte_ticketlock_t *tl) ++{ ++ uint16_t me = __atomic_fetch_add(&tl->s.next, 1, __ATOMIC_RELAXED); ++ rte_wait_until_equal_16(&tl->s.current, me, __ATOMIC_ACQUIRE); ++} ++ ++/** ++ * Release the ticketlock. ++ * ++ * @param tl ++ * A pointer to the ticketlock. ++ */ ++static inline void ++rte_ticketlock_unlock(rte_ticketlock_t *tl) ++{ ++ uint16_t i = __atomic_load_n(&tl->s.current, __ATOMIC_RELAXED); ++ __atomic_store_n(&tl->s.current, i + 1, __ATOMIC_RELEASE); ++} ++ ++/** ++ * Try to take the lock. ++ * ++ * @param tl ++ * A pointer to the ticketlock. ++ * @return ++ * 1 if the lock is successfully taken; 0 otherwise. ++ */ ++static inline int ++rte_ticketlock_trylock(rte_ticketlock_t *tl) ++{ ++ rte_ticketlock_t old, new; ++ old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED); ++ new.tickets = old.tickets; ++ new.s.next++; ++ if (old.s.next == old.s.current) { ++ if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets, ++ new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) ++ return 1; ++ } ++ ++ return 0; ++} ++ ++/** ++ * Test if the lock is taken. ++ * ++ * @param tl ++ * A pointer to the ticketlock. ++ * @return ++ * 1 if the lock is currently taken; 0 otherwise. ++ */ ++static inline int ++rte_ticketlock_is_locked(rte_ticketlock_t *tl) ++{ ++ rte_ticketlock_t tic; ++ tic.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_ACQUIRE); ++ return (tic.s.current != tic.s.next); ++} ++ ++/** ++ * The rte_ticketlock_recursive_t type. ++ */ ++#define TICKET_LOCK_INVALID_ID -1 ++ ++typedef struct { ++ rte_ticketlock_t tl; /**< the actual ticketlock */ ++ int user; /**< core id using lock, TICKET_LOCK_INVALID_ID for unused */ ++ unsigned int count; /**< count of time this lock has been called */ ++} rte_ticketlock_recursive_t; ++ ++/** ++ * A static recursive ticketlock initializer. ++ */ ++#define RTE_TICKETLOCK_RECURSIVE_INITIALIZER {RTE_TICKETLOCK_INITIALIZER, \ ++ TICKET_LOCK_INVALID_ID, 0} ++ ++/** ++ * Initialize the recursive ticketlock to an unlocked state. ++ * ++ * @param tlr ++ * A pointer to the recursive ticketlock. ++ */ ++static inline void ++rte_ticketlock_recursive_init(rte_ticketlock_recursive_t *tlr) ++{ ++ rte_ticketlock_init(&tlr->tl); ++ __atomic_store_n(&tlr->user, TICKET_LOCK_INVALID_ID, __ATOMIC_RELAXED); ++ tlr->count = 0; ++} ++ ++/** ++ * Take the recursive ticketlock. ++ * ++ * @param tlr ++ * A pointer to the recursive ticketlock. ++ */ ++static inline void ++rte_ticketlock_recursive_lock(rte_ticketlock_recursive_t *tlr) ++{ ++ int id = rte_gettid(); ++ ++ if (__atomic_load_n(&tlr->user, __ATOMIC_RELAXED) != id) { ++ rte_ticketlock_lock(&tlr->tl); ++ __atomic_store_n(&tlr->user, id, __ATOMIC_RELAXED); ++ } ++ tlr->count++; ++} ++ ++/** ++ * Release the recursive ticketlock. ++ * ++ * @param tlr ++ * A pointer to the recursive ticketlock. ++ */ ++static inline void ++rte_ticketlock_recursive_unlock(rte_ticketlock_recursive_t *tlr) ++{ ++ if (--(tlr->count) == 0) { ++ __atomic_store_n(&tlr->user, TICKET_LOCK_INVALID_ID, ++ __ATOMIC_RELAXED); ++ rte_ticketlock_unlock(&tlr->tl); ++ } ++} ++ ++/** ++ * Try to take the recursive lock. ++ * ++ * @param tlr ++ * A pointer to the recursive ticketlock. ++ * @return ++ * 1 if the lock is successfully taken; 0 otherwise. ++ */ ++static inline int ++rte_ticketlock_recursive_trylock(rte_ticketlock_recursive_t *tlr) ++{ ++ int id = rte_gettid(); ++ ++ if (__atomic_load_n(&tlr->user, __ATOMIC_RELAXED) != id) { ++ if (rte_ticketlock_trylock(&tlr->tl) == 0) ++ return 0; ++ __atomic_store_n(&tlr->user, id, __ATOMIC_RELAXED); ++ } ++ tlr->count++; ++ return 1; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* _RTE_TICKETLOCK_H_ */ +diff --git a/lib/eal/loongarch/include/rte_vect.h b/lib/eal/loongarch/include/rte_vect.h +new file mode 100644 +index 0000000..1546515 +--- /dev/null ++++ b/lib/eal/loongarch/include/rte_vect.h +@@ -0,0 +1,65 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#ifndef RTE_VECT_LOONGARCH_H ++#define RTE_VECT_LOONGARCH_H ++ ++#include ++#include "generic/rte_vect.h" ++#include "rte_common.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#define RTE_VECT_DEFAULT_SIMD_BITWIDTH RTE_VECT_SIMD_DISABLED ++ ++typedef union xmm { ++ int8_t i8[16]; ++ int16_t i16[8]; ++ int32_t i32[4]; ++ int64_t i64[2]; ++ uint8_t u8[16]; ++ uint16_t u16[8]; ++ uint32_t u32[4]; ++ uint64_t u64[2]; ++ double pd[2]; ++} __rte_aligned(16) xmm_t; ++ ++#define XMM_SIZE (sizeof(xmm_t)) ++#define XMM_MASK (XMM_SIZE - 1) ++ ++typedef union rte_xmm { ++ xmm_t x; ++ uint8_t u8[XMM_SIZE / sizeof(uint8_t)]; ++ uint16_t u16[XMM_SIZE / sizeof(uint16_t)]; ++ uint32_t u32[XMM_SIZE / sizeof(uint32_t)]; ++ uint64_t u64[XMM_SIZE / sizeof(uint64_t)]; ++ double pd[XMM_SIZE / sizeof(double)]; ++} __rte_aligned(16) rte_xmm_t; ++ ++static inline xmm_t ++vect_load_128(void *p) ++{ ++ xmm_t ret = *((xmm_t *)p); ++ ++ return ret; ++} ++ ++static inline xmm_t ++vect_and(xmm_t data, xmm_t mask) ++{ ++ rte_xmm_t ret = {.x = data }; ++ rte_xmm_t m = {.x = mask }; ++ ret.u64[0] &= m.u64[0]; ++ ret.u64[1] &= m.u64[1]; ++ ++ return ret.x; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* RTE_VECT_LOONGARCH_H */ +diff --git a/lib/eal/loongarch/meson.build b/lib/eal/loongarch/meson.build +new file mode 100644 +index 0000000..4dcc27b +--- /dev/null ++++ b/lib/eal/loongarch/meson.build +@@ -0,0 +1,11 @@ ++# SPDX-License-Identifier: BSD-3-Clause ++# Copyright(c) 2022 Loongson Technology Corporation Limited ++ ++subdir('include') ++ ++sources += files( ++ 'rte_cpuflags.c', ++ 'rte_cycles.c', ++ 'rte_hypervisor.c', ++ 'rte_power_intrinsics.c', ++) +diff --git a/lib/eal/loongarch/rte_cpuflags.c b/lib/eal/loongarch/rte_cpuflags.c +new file mode 100644 +index 0000000..0a75ca5 +--- /dev/null ++++ b/lib/eal/loongarch/rte_cpuflags.c +@@ -0,0 +1,93 @@ ++/* ++ * SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#include "rte_cpuflags.h" ++ ++#include ++#include ++#include ++#include ++#include ++ ++/* Symbolic values for the entries in the auxiliary table */ ++#define AT_HWCAP 16 ++ ++/* software based registers */ ++enum cpu_register_t { ++ REG_NONE = 0, ++ REG_HWCAP, ++ REG_MAX ++}; ++ ++typedef uint32_t hwcap_registers_t[REG_MAX]; ++ ++struct feature_entry { ++ uint32_t reg; ++ uint32_t bit; ++#define CPU_FLAG_NAME_MAX_LEN 64 ++ char name[CPU_FLAG_NAME_MAX_LEN]; ++}; ++ ++#define FEAT_DEF(name, reg, bit) \ ++ [RTE_CPUFLAG_##name] = {reg, bit, #name}, ++ ++const struct feature_entry rte_cpu_feature_table[] = { ++ FEAT_DEF(CPUCFG, REG_HWCAP, 0) ++ FEAT_DEF(LAM, REG_HWCAP, 1) ++ FEAT_DEF(UAL, REG_HWCAP, 2) ++ FEAT_DEF(FPU, REG_HWCAP, 3) ++ FEAT_DEF(LSX, REG_HWCAP, 4) ++ FEAT_DEF(LASX, REG_HWCAP, 5) ++ FEAT_DEF(CRC32, REG_HWCAP, 6) ++ FEAT_DEF(COMPLEX, REG_HWCAP, 7) ++ FEAT_DEF(CRYPTO, REG_HWCAP, 8) ++ FEAT_DEF(LVZ, REG_HWCAP, 9) ++ FEAT_DEF(LBT_X86, REG_HWCAP, 10) ++ FEAT_DEF(LBT_ARM, REG_HWCAP, 11) ++ FEAT_DEF(LBT_MIPS, REG_HWCAP, 12) ++}; ++ ++/* ++ * Read AUXV software register and get cpu features for LoongArch ++ */ ++static void ++rte_cpu_get_features(hwcap_registers_t out) ++{ ++ out[REG_HWCAP] = rte_cpu_getauxval(AT_HWCAP); ++} ++ ++/* ++ * Checks if a particular flag is available on current machine. ++ */ ++int ++rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) ++{ ++ const struct feature_entry *feat; ++ hwcap_registers_t regs = {0}; ++ ++ if (feature >= RTE_CPUFLAG_NUMFLAGS) ++ return -ENOENT; ++ ++ feat = &rte_cpu_feature_table[feature]; ++ if (feat->reg == REG_NONE) ++ return -EFAULT; ++ ++ rte_cpu_get_features(regs); ++ return (regs[feat->reg] >> feat->bit) & 1; ++} ++ ++const char * ++rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) ++{ ++ if (feature >= RTE_CPUFLAG_NUMFLAGS) ++ return NULL; ++ return rte_cpu_feature_table[feature].name; ++} ++ ++void ++rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics) ++{ ++ memset(intrinsics, 0, sizeof(*intrinsics)); ++} +diff --git a/lib/eal/loongarch/rte_cycles.c b/lib/eal/loongarch/rte_cycles.c +new file mode 100644 +index 0000000..582601d +--- /dev/null ++++ b/lib/eal/loongarch/rte_cycles.c +@@ -0,0 +1,45 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#include "eal_private.h" ++ ++#define LOONGARCH_CPUCFG4 0x4 ++#define CPUCFG4_CCFREQ_MASK 0xFFFFFFFF ++#define CPUCFG4_CCFREQ_SHIFT 0 ++ ++#define LOONGARCH_CPUCFG5 0x5 ++#define CPUCFG5_CCMUL_MASK 0xFFFF ++#define CPUCFG5_CCMUL_SHIFT 0 ++ ++#define CPUCFG5_CCDIV_MASK 0xFFFF0000 ++#define CPUCFG5_CCDIV_SHIFT 16 ++ ++static __rte_noinline uint32_t ++read_cpucfg(int arg) ++{ ++ int ret = 0; ++ ++ __asm__ __volatile__ ( ++ "cpucfg %[var], %[index]\n" ++ : [var]"=r"(ret) ++ : [index]"r"(arg) ++ : ++ ); ++ ++ return ret; ++} ++ ++uint64_t ++get_tsc_freq_arch(void) ++{ ++ uint32_t base_freq, mul_factor, div_factor; ++ ++ base_freq = read_cpucfg(LOONGARCH_CPUCFG4); ++ mul_factor = (read_cpucfg(LOONGARCH_CPUCFG5) & CPUCFG5_CCMUL_MASK) >> ++ CPUCFG5_CCMUL_SHIFT; ++ div_factor = (read_cpucfg(LOONGARCH_CPUCFG5) & CPUCFG5_CCDIV_MASK) >> ++ CPUCFG5_CCDIV_SHIFT; ++ ++ return base_freq * mul_factor / div_factor; ++} +diff --git a/lib/eal/loongarch/rte_hypervisor.c b/lib/eal/loongarch/rte_hypervisor.c +new file mode 100644 +index 0000000..d044906 +--- /dev/null ++++ b/lib/eal/loongarch/rte_hypervisor.c +@@ -0,0 +1,11 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#include "rte_hypervisor.h" ++ ++enum rte_hypervisor ++rte_hypervisor_get(void) ++{ ++ return RTE_HYPERVISOR_UNKNOWN; ++} +diff --git a/lib/eal/loongarch/rte_power_intrinsics.c b/lib/eal/loongarch/rte_power_intrinsics.c +new file mode 100644 +index 0000000..a8969c2 +--- /dev/null ++++ b/lib/eal/loongarch/rte_power_intrinsics.c +@@ -0,0 +1,53 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Loongson Technology Corporation Limited ++ */ ++ ++#include ++ ++#include "rte_power_intrinsics.h" ++ ++/** ++ * This function is not supported on LOONGARCH. ++ */ ++int ++rte_power_monitor(const struct rte_power_monitor_cond *pmc, ++ const uint64_t tsc_timestamp) ++{ ++ RTE_SET_USED(pmc); ++ RTE_SET_USED(tsc_timestamp); ++ ++ return -ENOTSUP; ++} ++ ++/** ++ * This function is not supported on LOONGARCH. ++ */ ++int ++rte_power_pause(const uint64_t tsc_timestamp) ++{ ++ RTE_SET_USED(tsc_timestamp); ++ ++ return -ENOTSUP; ++} ++ ++/** ++ * This function is not supported on LOONGARCH. ++ */ ++int ++rte_power_monitor_wakeup(const unsigned int lcore_id) ++{ ++ RTE_SET_USED(lcore_id); ++ ++ return -ENOTSUP; ++} ++ ++int ++rte_power_monitor_multi(const struct rte_power_monitor_cond pmc[], ++ const uint32_t num, const uint64_t tsc_timestamp) ++{ ++ RTE_SET_USED(pmc); ++ RTE_SET_USED(num); ++ RTE_SET_USED(tsc_timestamp); ++ ++ return -ENOTSUP; ++} +diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build +index 78d91d3..6b47361 100644 +--- a/lib/lpm/meson.build ++++ b/lib/lpm/meson.build +@@ -14,6 +14,7 @@ headers = files('rte_lpm.h', 'rte_lpm6.h') + indirect_headers += files( + 'rte_lpm_altivec.h', + 'rte_lpm_neon.h', ++ 'rte_lpm_scalar.h', + 'rte_lpm_sse.h', + 'rte_lpm_sve.h', + ) +diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h +index 5eb14c1..49cfa5b 100644 +--- a/lib/lpm/rte_lpm.h ++++ b/lib/lpm/rte_lpm.h +@@ -283,7 +283,7 @@ rte_lpm_delete_all(struct rte_lpm *lpm); + * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit + */ + static inline int +-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop) ++rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop) + { + unsigned tbl24_index = (ip >> 8); + uint32_t tbl_entry; +@@ -409,8 +409,10 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], + #endif + #elif defined(RTE_ARCH_PPC_64) + #include "rte_lpm_altivec.h" +-#else ++#elif defined(RTE_ARCH_X86) + #include "rte_lpm_sse.h" ++#else ++#include "rte_lpm_scalar.h" + #endif + + #ifdef __cplusplus +diff --git a/lib/lpm/rte_lpm_scalar.h b/lib/lpm/rte_lpm_scalar.h +new file mode 100644 +index 0000000..df4f83f +--- /dev/null ++++ b/lib/lpm/rte_lpm_scalar.h +@@ -0,0 +1,38 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 StarFive ++ * Copyright(c) 2022 SiFive ++ * Copyright(c) 2022 Semihalf ++ */ ++ ++#ifndef _RTE_LPM_SCALAR_H_ ++#define _RTE_LPM_SCALAR_H_ ++ ++#include ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++static inline void ++rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], ++ uint32_t defv) ++{ ++ rte_xmm_t xip = { .x = ip }; ++ uint32_t nh; ++ int ret; ++ ++ ret = rte_lpm_lookup(lpm, xip.u32[0], &nh); ++ hop[0] = (ret == 0) ? nh : defv; ++ ret = rte_lpm_lookup(lpm, xip.u32[1], &nh); ++ hop[1] = (ret == 0) ? nh : defv; ++ ret = rte_lpm_lookup(lpm, xip.u32[2], &nh); ++ hop[2] = (ret == 0) ? nh : defv; ++ ret = rte_lpm_lookup(lpm, xip.u32[3], &nh); ++ hop[3] = (ret == 0) ? nh : defv; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* _RTE_LPM_SCALAR_H_ */ +diff --git a/meson.build b/meson.build +index 12cb6e0..1052fba 100644 +--- a/meson.build ++++ b/meson.build +@@ -42,6 +42,8 @@ if host_machine.cpu_family().startswith('x86') + arch_subdir = 'x86' + elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch') + arch_subdir = 'arm' ++elif host_machine.cpu_family().startswith('loongarch') ++ arch_subdir = 'loongarch' + elif host_machine.cpu_family().startswith('ppc') + arch_subdir = 'ppc' + endif +-- +2.33.0 diff --git a/0022-net-hns3-remove-unnecessary-assignment.patch b/0022-net-hns3-remove-unnecessary-assignment.patch new file mode 100644 index 0000000..dd75097 --- /dev/null +++ b/0022-net-hns3-remove-unnecessary-assignment.patch @@ -0,0 +1,28 @@ +From b70e96833a753239454c660b71cbab6e0dcbbeae Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:28 +0800 +Subject: [PATCH] net/hns3: remove unnecessary assignment + +Remove unnecessary assignment. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_flow.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 0dbc3f6502..5f2b279546 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1890,7 +1890,6 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, + } + } + rte_free(flow); +- flow = NULL; + + return 0; + } +-- +2.33.0 + diff --git a/0023-example-l3fwd-masking-wrong-warning-array-subscript-.patch b/0023-example-l3fwd-masking-wrong-warning-array-subscript-.patch new file mode 100644 index 0000000..11d404e --- /dev/null +++ b/0023-example-l3fwd-masking-wrong-warning-array-subscript-.patch @@ -0,0 +1,46 @@ +From 2889419e10a68fad89df35350a1ea5e41e4cbf35 Mon Sep 17 00:00:00 2001 +From: j00660176 +Date: Wed, 12 Jul 2023 16:39:56 +0800 +Subject: [PATCH] example/l3fwd: masking wrong warning array subscript [0] is + partly outside array bounds + +GCC 12 raises the following warning: +In file included from ../examples/l3fwd/l3fwd_lpm_neon.h:11, + from ../examples/l3fwd/l3fwd_lpm.c:135: +../examples/l3fwd/l3fwd_neon.h: In function 'port_groupx4': +../examples/l3fwd/l3fwd_neon.h:95:21: error: array subscript 'union [0]' is partly outside array bounds of 'uint16_t[5]' {aka 'short unsigned int[5]'} [-Werror=array-bounds] + 95 | pnum->u64 = gptbl[v].pnum; + | ^~ +../examples/l3fwd/l3fwd_neon.h:74:23: note: object 'pn' of size [0, 10] + 74 | port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1, + | ~~~~~~~~~^~~~~~~~~~~~~~~ +../examples/l3fwd/l3fwd_neon.h:96:21: error: array subscript 'union [0]' is partly outside array bounds of 'uint16_t[5]' {aka 'short unsigned int[5]'} [-Werror=array-bounds] + 96 | pnum->u16[FWDSTEP] = 1; + | ^~ +../examples/l3fwd/l3fwd_neon.h:74:23: note: object 'pn' of size [0, 10] + 74 | port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1, + | ~~~~~~~~~^~~~~~~~~~~~~~~ +cc1: all warnings being treated as errors + +according to the code review, this is a wrong warning: +pnum's size is uint16_t * 5 = 10, FWDSTEP is 4, line 96 access pnum->[4]; lin95 access accesses a 64-bit value, taking up the first four elements of a number. +due to patch 0002-dpdk-add-secure-compile-option-and-fPIC-option.patch, it treats warnings as errors. so the l3fwd compilation fails. +--- + examples/l3fwd/meson.build | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/examples/l3fwd/meson.build b/examples/l3fwd/meson.build +index 0830b3e..827206e 100644 +--- a/examples/l3fwd/meson.build ++++ b/examples/l3fwd/meson.build +@@ -7,6 +7,8 @@ + # DPDK instance, use 'make' + + allow_experimental_apis = true ++cflags += ['-Wno-array-bounds'] ++ + deps += ['hash', 'lpm', 'fib', 'eventdev'] + sources = files( + 'l3fwd_em.c', +-- +2.33.0 diff --git a/0023-net-hns3-fix-using-enum-as-boolean.patch b/0023-net-hns3-fix-using-enum-as-boolean.patch new file mode 100644 index 0000000..80ee21d --- /dev/null +++ b/0023-net-hns3-fix-using-enum-as-boolean.patch @@ -0,0 +1,34 @@ +From 67d0b17947d6936147f4cbfff6ff938884f14776 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:29 +0800 +Subject: [PATCH] net/hns3: fix using enum as boolean + +The enum type variables cannot be used as bool variables. This patch +fixes for "with->func" in hns3_action_rss_same(). + +Fixes: eb158fc756a5 ("net/hns3: fix config when creating RSS rule after flush") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_flow.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 5f2b279546..00084872ad 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1251,7 +1251,8 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + if (comp->func == RTE_ETH_HASH_FUNCTION_MAX) + func_is_same = false; + else +- func_is_same = with->func ? (comp->func == with->func) : true; ++ func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? ++ (comp->func == with->func) : true; + + return (func_is_same && + comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) && +-- +2.33.0 + diff --git a/0024-net-hns3-extract-common-function-to-initialize-MAC-a.patch b/0024-net-hns3-extract-common-function-to-initialize-MAC-a.patch new file mode 100644 index 0000000..af05128 --- /dev/null +++ b/0024-net-hns3-extract-common-function-to-initialize-MAC-a.patch @@ -0,0 +1,205 @@ +From 2665a92054019bdb73cd2c43e5a581d081772915 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:30 +0800 +Subject: [PATCH] net/hns3: extract common function to initialize MAC address + +The code logic to initialize "data->mac_addrs" for PF and VF is similar. +This patch extracts a common API to initialize it to improve code +maintainability. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_common.c | 54 +++++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_common.h | 1 + + drivers/net/hns3/hns3_ethdev.c | 31 +++--------------- + drivers/net/hns3/hns3_ethdev_vf.c | 33 +++---------------- + 4 files changed, 63 insertions(+), 56 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 78158401f2..0f39d51a87 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -587,6 +587,60 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) + } + } + ++int ++hns3_init_mac_addrs(struct rte_eth_dev *dev) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ const char *memory_name = hns->is_vf ? "hns3vf-mac" : "hns3-mac"; ++ uint16_t mac_addrs_capa = hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : ++ HNS3_UC_MACADDR_NUM; ++ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; ++ struct rte_ether_addr *eth_addr; ++ ++ /* Allocate memory for storing MAC addresses */ ++ dev->data->mac_addrs = rte_zmalloc(memory_name, ++ sizeof(struct rte_ether_addr) * mac_addrs_capa, ++ 0); ++ if (dev->data->mac_addrs == NULL) { ++ hns3_err(hw, "failed to allocate %zx bytes needed to store MAC addresses", ++ sizeof(struct rte_ether_addr) * mac_addrs_capa); ++ return -ENOMEM; ++ } ++ ++ eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr; ++ if (!hns->is_vf) { ++ if (!rte_is_valid_assigned_ether_addr(eth_addr)) { ++ rte_eth_random_addr(hw->mac.mac_addr); ++ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, ++ (struct rte_ether_addr *)hw->mac.mac_addr); ++ hns3_warn(hw, "default mac_addr from firmware is an invalid " ++ "unicast address, using random MAC address %s", ++ mac_str); ++ } ++ } else { ++ /* ++ * The hns3 PF ethdev driver in kernel support setting VF MAC ++ * address on the host by "ip link set ..." command. To avoid ++ * some incorrect scenes, for example, hns3 VF PMD driver fails ++ * to receive and send packets after user configure the MAC ++ * address by using the "ip link set ..." command, hns3 VF PMD ++ * driver keep the same MAC address strategy as the hns3 kernel ++ * ethdev driver in the initialization. If user configure a MAC ++ * address by the ip command for VF device, then hns3 VF PMD ++ * driver will start with it, otherwise start with a random MAC ++ * address in the initialization. ++ */ ++ if (rte_is_zero_ether_addr(eth_addr)) ++ rte_eth_random_addr(hw->mac.mac_addr); ++ } ++ ++ rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.mac_addr, ++ &dev->data->mac_addrs[0]); ++ ++ return 0; ++} ++ + int + hns3_init_ring_with_vector(struct hns3_hw *hw) + { +diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h +index 0dbb1c0413..a9e8a9cccf 100644 +--- a/drivers/net/hns3/hns3_common.h ++++ b/drivers/net/hns3/hns3_common.h +@@ -52,6 +52,7 @@ int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, + uint32_t nb_mc_addr); + void hns3_ether_format_addr(char *buf, uint16_t size, + const struct rte_ether_addr *ether_addr); ++int hns3_init_mac_addrs(struct rte_eth_dev *dev); + + int hns3_init_ring_with_vector(struct hns3_hw *hw); + int hns3_map_rx_interrupt(struct rte_eth_dev *dev); +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index ef13d31d19..722660d0cc 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -6617,8 +6617,6 @@ static int + hns3_dev_init(struct rte_eth_dev *eth_dev) + { + struct hns3_adapter *hns = eth_dev->data->dev_private; +- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; +- struct rte_ether_addr *eth_addr; + struct hns3_hw *hw = &hns->hw; + int ret; + +@@ -6661,30 +6659,9 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) + goto err_init_pf; + } + +- /* Allocate memory for storing MAC addresses */ +- eth_dev->data->mac_addrs = rte_zmalloc("hns3-mac", +- sizeof(struct rte_ether_addr) * +- HNS3_UC_MACADDR_NUM, 0); +- if (eth_dev->data->mac_addrs == NULL) { +- PMD_INIT_LOG(ERR, "Failed to allocate %zx bytes needed " +- "to store MAC addresses", +- sizeof(struct rte_ether_addr) * +- HNS3_UC_MACADDR_NUM); +- ret = -ENOMEM; +- goto err_rte_zmalloc; +- } +- +- eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr; +- if (!rte_is_valid_assigned_ether_addr(eth_addr)) { +- rte_eth_random_addr(hw->mac.mac_addr); +- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- (struct rte_ether_addr *)hw->mac.mac_addr); +- hns3_warn(hw, "default mac_addr from firmware is an invalid " +- "unicast address, using random MAC address %s", +- mac_str); +- } +- rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.mac_addr, +- ð_dev->data->mac_addrs[0]); ++ ret = hns3_init_mac_addrs(eth_dev); ++ if (ret != 0) ++ goto err_init_mac_addrs; + + hw->adapter_state = HNS3_NIC_INITIALIZED; + +@@ -6700,7 +6677,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) + hns3_info(hw, "hns3 dev initialization successful!"); + return 0; + +-err_rte_zmalloc: ++err_init_mac_addrs: + hns3_uninit_pf(eth_dev); + + err_init_pf: +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 5015fe0d5f..5a1286e17b 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -2400,34 +2400,9 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) + goto err_init_vf; + } + +- /* Allocate memory for storing MAC addresses */ +- eth_dev->data->mac_addrs = rte_zmalloc("hns3vf-mac", +- sizeof(struct rte_ether_addr) * +- HNS3_VF_UC_MACADDR_NUM, 0); +- if (eth_dev->data->mac_addrs == NULL) { +- PMD_INIT_LOG(ERR, "Failed to allocate %zx bytes needed " +- "to store MAC addresses", +- sizeof(struct rte_ether_addr) * +- HNS3_VF_UC_MACADDR_NUM); +- ret = -ENOMEM; +- goto err_rte_zmalloc; +- } +- +- /* +- * The hns3 PF ethdev driver in kernel support setting VF MAC address +- * on the host by "ip link set ..." command. To avoid some incorrect +- * scenes, for example, hns3 VF PMD fails to receive and send +- * packets after user configure the MAC address by using the +- * "ip link set ..." command, hns3 VF PMD keep the same MAC +- * address strategy as the hns3 kernel ethdev driver in the +- * initialization. If user configure a MAC address by the ip command +- * for VF device, then hns3 VF PMD will start with it, otherwise +- * start with a random MAC address in the initialization. +- */ +- if (rte_is_zero_ether_addr((struct rte_ether_addr *)hw->mac.mac_addr)) +- rte_eth_random_addr(hw->mac.mac_addr); +- rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.mac_addr, +- ð_dev->data->mac_addrs[0]); ++ ret = hns3_init_mac_addrs(eth_dev); ++ if (ret != 0) ++ goto err_init_mac_addrs; + + hw->adapter_state = HNS3_NIC_INITIALIZED; + +@@ -2443,7 +2418,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) + eth_dev); + return 0; + +-err_rte_zmalloc: ++err_init_mac_addrs: + hns3vf_uninit_vf(eth_dev); + + err_init_vf: +-- +2.33.0 + diff --git a/0025-net-hns3-make-control-plane-function-non-inline.patch b/0025-net-hns3-make-control-plane-function-non-inline.patch new file mode 100644 index 0000000..4f658d1 --- /dev/null +++ b/0025-net-hns3-make-control-plane-function-non-inline.patch @@ -0,0 +1,30 @@ +From 7be11baa6e5fd2143f5574403c44e45fc9c5e393 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Sat, 22 Jan 2022 09:51:31 +0800 +Subject: [PATCH] net/hns3: make control plane function non-inline + +This function is a control-plane interface and does +not need to use inline. + +Signed-off-by: Jie Hai +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 722660d0cc..f92832a4aa 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4853,7 +4853,7 @@ hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds) + return 0; + } + +-static inline uint32_t ++static uint32_t + hns3_get_link_speed(uint32_t link_speeds) + { + uint32_t speed = RTE_ETH_SPEED_NUM_NONE; +-- +2.33.0 + diff --git a/0026-net-hns3-remove-unnecessary-blank-lines.patch b/0026-net-hns3-remove-unnecessary-blank-lines.patch new file mode 100644 index 0000000..4cdecd0 --- /dev/null +++ b/0026-net-hns3-remove-unnecessary-blank-lines.patch @@ -0,0 +1,49 @@ +From fbbcf80a9dc6d2f2d553b1c0b8762b5a35f4afc0 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:32 +0800 +Subject: [PATCH] net/hns3: remove unnecessary blank lines + +Remove unnecessary blank lines. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 1 - + drivers/net/hns3/hns3_rxtx.h | 2 -- + 2 files changed, 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index f92832a4aa..0f6d238f6f 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -6295,7 +6295,6 @@ hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode) + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); + struct hns3_pf *pf = &hns->pf; +- + struct rte_eth_fec_capa fec_capa[FEC_CAPA_NUM]; + uint32_t cur_capa; + uint32_t num = FEC_CAPA_NUM; +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index e202eb9c30..094b65b7de 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -344,7 +344,6 @@ struct hns3_rx_queue { + + struct rte_mbuf fake_mbuf; /* fake mbuf used with vector rx */ + +- + /* + * The following fields are not accessed in the I/O path, so they are + * placed at the end. +@@ -518,7 +517,6 @@ struct hns3_tx_queue { + struct hns3_tx_basic_stats basic_stats; + struct hns3_tx_dfx_stats dfx_stats; + +- + /* + * The following fields are not accessed in the I/O path, so they are + * placed at the end. +-- +2.33.0 + diff --git a/0027-net-hns3-extract-reset-failure-handling-to-function.patch b/0027-net-hns3-extract-reset-failure-handling-to-function.patch new file mode 100644 index 0000000..0b685f5 --- /dev/null +++ b/0027-net-hns3-extract-reset-failure-handling-to-function.patch @@ -0,0 +1,95 @@ +From f13c07a570fabe362b55d2e3643b5ff96513597f Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:33 +0800 +Subject: [PATCH] net/hns3: extract reset failure handling to function + +Extract a function to handle reset fail for clearer code logic. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_intr.c | 54 +++++++++++++++++++++--------------- + 1 file changed, 32 insertions(+), 22 deletions(-) + +diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c +index 66dc509086..3ca2e1e338 100644 +--- a/drivers/net/hns3/hns3_intr.c ++++ b/drivers/net/hns3/hns3_intr.c +@@ -2770,6 +2770,37 @@ hns3_reset_post(struct hns3_adapter *hns) + return -EIO; + } + ++static void ++hns3_reset_fail_handle(struct hns3_adapter *hns) ++{ ++ struct hns3_hw *hw = &hns->hw; ++ struct timeval tv_delta; ++ struct timeval tv; ++ ++ hns3_clear_reset_level(hw, &hw->reset.pending); ++ if (hns3_reset_err_handle(hns)) { ++ hw->reset.stage = RESET_STAGE_PREWAIT; ++ hns3_schedule_reset(hns); ++ return; ++ } ++ ++ rte_spinlock_lock(&hw->lock); ++ if (hw->reset.mbuf_deferred_free) { ++ hns3_dev_release_mbufs(hns); ++ hw->reset.mbuf_deferred_free = false; ++ } ++ rte_spinlock_unlock(&hw->lock); ++ __atomic_store_n(&hns->hw.reset.resetting, 0, __ATOMIC_RELAXED); ++ hw->reset.stage = RESET_STAGE_NONE; ++ hns3_clock_gettime(&tv); ++ timersub(&tv, &hw->reset.start_time, &tv_delta); ++ hns3_warn(hw, "%s reset fail delta %" PRIu64 " ms time=%ld.%.6ld", ++ reset_string[hw->reset.level], ++ hns3_clock_calctime_ms(&tv_delta), ++ tv.tv_sec, tv.tv_usec); ++ hw->reset.level = HNS3_NONE_RESET; ++} ++ + /* + * There are three scenarios as follows: + * When the reset is not in progress, the reset process starts. +@@ -2784,7 +2815,6 @@ int + hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) + { + struct hns3_hw *hw = &hns->hw; +- struct timeval tv_delta; + struct timeval tv; + int ret; + +@@ -2843,27 +2873,7 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) + if (ret == -EAGAIN) + return ret; + err: +- hns3_clear_reset_level(hw, &hw->reset.pending); +- if (hns3_reset_err_handle(hns)) { +- hw->reset.stage = RESET_STAGE_PREWAIT; +- hns3_schedule_reset(hns); +- } else { +- rte_spinlock_lock(&hw->lock); +- if (hw->reset.mbuf_deferred_free) { +- hns3_dev_release_mbufs(hns); +- hw->reset.mbuf_deferred_free = false; +- } +- rte_spinlock_unlock(&hw->lock); +- __atomic_store_n(&hns->hw.reset.resetting, 0, __ATOMIC_RELAXED); +- hw->reset.stage = RESET_STAGE_NONE; +- hns3_clock_gettime(&tv); +- timersub(&tv, &hw->reset.start_time, &tv_delta); +- hns3_warn(hw, "%s reset fail delta %" PRIu64 " ms time=%ld.%.6ld", +- reset_string[hw->reset.level], +- hns3_clock_calctime_ms(&tv_delta), +- tv.tv_sec, tv.tv_usec); +- hw->reset.level = HNS3_NONE_RESET; +- } ++ hns3_reset_fail_handle(hns); + + return -EIO; + } +-- +2.33.0 + diff --git a/0028-net-hns3-remove-unused-variables.patch b/0028-net-hns3-remove-unused-variables.patch new file mode 100644 index 0000000..b913c60 --- /dev/null +++ b/0028-net-hns3-remove-unused-variables.patch @@ -0,0 +1,77 @@ +From a65941e9c461bfc050778ed318a90e621d903163 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:34 +0800 +Subject: [PATCH] net/hns3: remove unused variables + +Remove unused variables. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_dcb.c | 12 +----------- + drivers/net/hns3/hns3_ethdev.c | 3 --- + drivers/net/hns3/hns3_ethdev.h | 2 -- + 3 files changed, 1 insertion(+), 16 deletions(-) + +diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c +index e4417e87fd..73693786d1 100644 +--- a/drivers/net/hns3/hns3_dcb.c ++++ b/drivers/net/hns3/hns3_dcb.c +@@ -750,19 +750,9 @@ static int + hns3_dcb_update_tc_queue_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, + uint16_t nb_tx_q) + { +- struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); +- struct hns3_pf *pf = &hns->pf; +- int ret; +- + hw->num_tc = hw->dcb_info.num_tc; +- ret = hns3_queue_to_tc_mapping(hw, nb_rx_q, nb_tx_q); +- if (ret) +- return ret; + +- if (!hns->is_vf) +- memcpy(pf->prio_tc, hw->dcb_info.prio_tc, HNS3_MAX_USER_PRIO); +- +- return 0; ++ return hns3_queue_to_tc_mapping(hw, nb_rx_q, nb_tx_q); + } + + int +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 0f6d238f6f..90eb6340a9 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2546,9 +2546,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc) + cfg->media_type = hns3_get_field(rte_le_to_cpu_32(req->param[1]), + HNS3_CFG_MEDIA_TP_M, + HNS3_CFG_MEDIA_TP_S); +- cfg->rx_buf_len = hns3_get_field(rte_le_to_cpu_32(req->param[1]), +- HNS3_CFG_RX_BUF_LEN_M, +- HNS3_CFG_RX_BUF_LEN_S); + /* get mac address */ + mac_addr_tmp = rte_le_to_cpu_32(req->param[2]); + mac_addr_tmp_high = hns3_get_field(rte_le_to_cpu_32(req->param[3]), +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 153e67337f..1dd388625b 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -156,7 +156,6 @@ struct hns3_tc_queue_info { + struct hns3_cfg { + uint8_t tc_num; + uint16_t tqp_desc_num; +- uint16_t rx_buf_len; + uint16_t rss_size_max; + uint8_t phy_addr; + uint8_t media_type; +@@ -804,7 +803,6 @@ struct hns3_pf { + uint8_t tc_max; /* max number of tc driver supported */ + uint8_t local_max_tc; /* max number of local tc */ + uint8_t pfc_max; +- uint8_t prio_tc[HNS3_MAX_USER_PRIO]; /* TC indexed by prio */ + uint16_t pause_time; + bool support_fc_autoneg; /* support FC autonegotiate */ + bool support_multi_tc_pause; +-- +2.33.0 + diff --git a/0029-net-hns3-remove-getting-number-of-queue-descriptors-.patch b/0029-net-hns3-remove-getting-number-of-queue-descriptors-.patch new file mode 100644 index 0000000..ddb9a47 --- /dev/null +++ b/0029-net-hns3-remove-getting-number-of-queue-descriptors-.patch @@ -0,0 +1,107 @@ +From af1f62b3d1e6bf12830facbb0161981bdce6685d Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:35 +0800 +Subject: [PATCH] net/hns3: remove getting number of queue descriptors from FW + +Application can specify the number of Rx/Tx queue descriptors in DPDK. +So driver does not obtain the default value from firmware and PF. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 5 ----- + drivers/net/hns3/hns3_ethdev.h | 3 --- + drivers/net/hns3/hns3_ethdev_vf.c | 26 -------------------------- + 3 files changed, 34 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 90eb6340a9..aa9301c561 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2536,9 +2536,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc) + /* get the configuration */ + cfg->tc_num = hns3_get_field(rte_le_to_cpu_32(req->param[0]), + HNS3_CFG_TC_NUM_M, HNS3_CFG_TC_NUM_S); +- cfg->tqp_desc_num = hns3_get_field(rte_le_to_cpu_32(req->param[0]), +- HNS3_CFG_TQP_DESC_N_M, +- HNS3_CFG_TQP_DESC_N_S); + + cfg->phy_addr = hns3_get_field(rte_le_to_cpu_32(req->param[1]), + HNS3_CFG_PHY_ADDR_M, +@@ -2849,8 +2846,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) + hw->rss_dis_flag = false; + memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN); + hw->mac.phy_addr = cfg.phy_addr; +- hw->num_tx_desc = cfg.tqp_desc_num; +- hw->num_rx_desc = cfg.tqp_desc_num; + hw->dcb_info.num_pg = 1; + hw->dcb_info.hw_pfc_map = 0; + +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 1dd388625b..cf6380ebb2 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -155,7 +155,6 @@ struct hns3_tc_queue_info { + + struct hns3_cfg { + uint8_t tc_num; +- uint16_t tqp_desc_num; + uint16_t rss_size_max; + uint8_t phy_addr; + uint8_t media_type; +@@ -512,8 +511,6 @@ struct hns3_hw { + uint16_t intr_tqps_num; /* num queue pairs mapping interrupt */ + uint16_t rss_size_max; /* HW defined max RSS task queue */ + uint16_t rx_buf_len; /* hold min hardware rx buf len */ +- uint16_t num_tx_desc; /* desc num of per tx queue */ +- uint16_t num_rx_desc; /* desc num of per rx queue */ + uint32_t mng_entry_num; /* number of manager table entry */ + uint32_t mac_entry_num; /* number of mac-vlan table entry */ + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 5a1286e17b..36d860d08a 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -941,27 +941,6 @@ hns3vf_get_queue_info(struct hns3_hw *hw) + return hns3vf_check_tqp_info(hw); + } + +-static int +-hns3vf_get_queue_depth(struct hns3_hw *hw) +-{ +-#define HNS3VF_TQPS_DEPTH_INFO_LEN 4 +- uint8_t resp_msg[HNS3VF_TQPS_DEPTH_INFO_LEN]; +- int ret; +- +- ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_QDEPTH, 0, NULL, 0, true, +- resp_msg, HNS3VF_TQPS_DEPTH_INFO_LEN); +- if (ret) { +- PMD_INIT_LOG(ERR, "Failed to get tqp depth info from PF: %d", +- ret); +- return ret; +- } +- +- memcpy(&hw->num_tx_desc, &resp_msg[0], sizeof(uint16_t)); +- memcpy(&hw->num_rx_desc, &resp_msg[2], sizeof(uint16_t)); +- +- return 0; +-} +- + static void + hns3vf_update_caps(struct hns3_hw *hw, uint32_t caps) + { +@@ -1052,11 +1031,6 @@ hns3vf_get_configuration(struct hns3_hw *hw) + if (ret) + return ret; + +- /* Get queue depth info from PF */ +- ret = hns3vf_get_queue_depth(hw); +- if (ret) +- return ret; +- + /* Get user defined VF MAC addr from PF */ + ret = hns3vf_get_host_mac_addr(hw); + if (ret) +-- +2.33.0 + diff --git a/0030-net-hns3-remove-logging-memory-addresses.patch b/0030-net-hns3-remove-logging-memory-addresses.patch new file mode 100644 index 0000000..533ba28 --- /dev/null +++ b/0030-net-hns3-remove-logging-memory-addresses.patch @@ -0,0 +1,79 @@ +From 5608b54756d91505e66e58c2562601b3f7e2fe80 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:36 +0800 +Subject: [PATCH] net/hns3: remove logging memory addresses + +Remove the printing of memory addresses. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_cmd.c | 12 ++++-------- + drivers/net/hns3/hns3_rxtx.c | 6 ------ + 2 files changed, 4 insertions(+), 14 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index 5b42d38aa5..5dc874fd7a 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -60,18 +60,14 @@ hns3_allocate_dma_mem(struct hns3_hw *hw, struct hns3_cmq_ring *ring, + ring->desc = mz->addr; + ring->desc_dma_addr = mz->iova; + ring->zone = (const void *)mz; +- hns3_dbg(hw, "memzone %s allocated with physical address: %" PRIu64, +- mz->name, ring->desc_dma_addr); ++ hns3_dbg(hw, "cmd ring memzone name: %s", mz->name); + + return 0; + } + + static void +-hns3_free_dma_mem(struct hns3_hw *hw, struct hns3_cmq_ring *ring) ++hns3_free_dma_mem(struct hns3_cmq_ring *ring) + { +- hns3_dbg(hw, "memzone %s to be freed with physical address: %" PRIu64, +- ((const struct rte_memzone *)ring->zone)->name, +- ring->desc_dma_addr); + rte_memzone_free((const struct rte_memzone *)ring->zone); + ring->buf_size = 0; + ring->desc = NULL; +@@ -93,10 +89,10 @@ hns3_alloc_cmd_desc(struct hns3_hw *hw, struct hns3_cmq_ring *ring) + } + + static void +-hns3_free_cmd_desc(struct hns3_hw *hw, struct hns3_cmq_ring *ring) ++hns3_free_cmd_desc(__rte_unused struct hns3_hw *hw, struct hns3_cmq_ring *ring) + { + if (ring->desc) +- hns3_free_dma_mem(hw, ring); ++ hns3_free_dma_mem(ring); + } + + static int +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index c43131cac6..3b72c2375a 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -1382,9 +1382,6 @@ hns3_alloc_rxq_and_dma_zone(struct rte_eth_dev *dev, + rxq->rx_ring = (struct hns3_desc *)rx_mz->addr; + rxq->rx_ring_phys_addr = rx_mz->iova; + +- hns3_dbg(hw, "No.%u rx descriptors iova 0x%" PRIx64, q_info->idx, +- rxq->rx_ring_phys_addr); +- + return rxq; + } + +@@ -1469,9 +1466,6 @@ hns3_alloc_txq_and_dma_zone(struct rte_eth_dev *dev, + txq->tx_ring = (struct hns3_desc *)tx_mz->addr; + txq->tx_ring_phys_addr = tx_mz->iova; + +- hns3_dbg(hw, "No.%u tx descriptors iova 0x%" PRIx64, q_info->idx, +- txq->tx_ring_phys_addr); +- + /* Clear tx bd */ + desc = txq->tx_ring; + for (i = 0; i < txq->nb_tx_desc; i++) { +-- +2.33.0 + diff --git a/0031-net-hns3-extract-common-function-to-obtain-revision-.patch b/0031-net-hns3-extract-common-function-to-obtain-revision-.patch new file mode 100644 index 0000000..a6d6adc --- /dev/null +++ b/0031-net-hns3-extract-common-function-to-obtain-revision-.patch @@ -0,0 +1,145 @@ +From f5ed7d99cf45d550a69c1430b7c4a5623a9c774a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:37 +0800 +Subject: [PATCH] net/hns3: extract common function to obtain revision ID + +The code logic of obtaining the revision ID of PCI device is the same +for PF and VF driver. This patch extracts a common interface to do it. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_common.c | 22 ++++++++++++++++++++++ + drivers/net/hns3/hns3_common.h | 2 ++ + drivers/net/hns3/hns3_ethdev.c | 16 ++++------------ + drivers/net/hns3/hns3_ethdev_vf.c | 21 ++++----------------- + 4 files changed, 32 insertions(+), 29 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 0f39d51a87..dcdc609654 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -821,3 +821,25 @@ hns3_restore_rx_interrupt(struct hns3_hw *hw) + + return 0; + } ++ ++int ++hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id) ++{ ++ struct rte_pci_device *pci_dev; ++ struct rte_eth_dev *eth_dev; ++ uint8_t revision; ++ int ret; ++ ++ eth_dev = &rte_eth_devices[hw->data->port_id]; ++ pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); ++ ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, ++ HNS3_PCI_REVISION_ID); ++ if (ret != HNS3_PCI_REVISION_ID_LEN) { ++ hns3_err(hw, "failed to read pci revision id, ret = %d", ret); ++ return -EIO; ++ } ++ ++ *revision_id = revision; ++ ++ return 0; ++} +diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h +index a9e8a9cccf..2994e4a269 100644 +--- a/drivers/net/hns3/hns3_common.h ++++ b/drivers/net/hns3/hns3_common.h +@@ -59,4 +59,6 @@ int hns3_map_rx_interrupt(struct rte_eth_dev *dev); + void hns3_unmap_rx_interrupt(struct rte_eth_dev *dev); + int hns3_restore_rx_interrupt(struct hns3_hw *hw); + ++int hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id); ++ + #endif /* _HNS3_COMMON_H_ */ +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index aa9301c561..b417d55e10 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5,7 +5,6 @@ + #include + #include + #include +-#include + + #include "hns3_ethdev.h" + #include "hns3_common.h" +@@ -2732,7 +2731,6 @@ hns3_get_capability(struct hns3_hw *hw) + struct hns3_pf *pf = &hns->pf; + struct rte_eth_dev *eth_dev; + uint16_t device_id; +- uint8_t revision; + int ret; + + eth_dev = &rte_eth_devices[hw->data->port_id]; +@@ -2745,17 +2743,11 @@ hns3_get_capability(struct hns3_hw *hw) + device_id == HNS3_DEV_ID_200G_RDMA) + hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1); + +- /* Get PCI revision id */ +- ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, +- HNS3_PCI_REVISION_ID); +- if (ret != HNS3_PCI_REVISION_ID_LEN) { +- PMD_INIT_LOG(ERR, "failed to read pci revision id, ret = %d", +- ret); +- return -EIO; +- } +- hw->revision = revision; ++ ret = hns3_get_pci_revision_id(hw, &hw->revision); ++ if (ret) ++ return ret; + +- if (revision < PCI_REVISION_ID_HIP09_A) { ++ if (hw->revision < PCI_REVISION_ID_HIP09_A) { + hns3_set_default_dev_specifications(hw); + hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE; + hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_2US; +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 36d860d08a..a9e129288b 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -6,7 +6,6 @@ + #include + #include + #include +-#include + #include + + #include "hns3_ethdev.h" +@@ -810,25 +809,13 @@ hns3vf_get_push_lsc_cap(struct hns3_hw *hw) + static int + hns3vf_get_capability(struct hns3_hw *hw) + { +- struct rte_pci_device *pci_dev; +- struct rte_eth_dev *eth_dev; +- uint8_t revision; + int ret; + +- eth_dev = &rte_eth_devices[hw->data->port_id]; +- pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); +- +- /* Get PCI revision id */ +- ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, +- HNS3_PCI_REVISION_ID); +- if (ret != HNS3_PCI_REVISION_ID_LEN) { +- PMD_INIT_LOG(ERR, "failed to read pci revision id, ret = %d", +- ret); +- return -EIO; +- } +- hw->revision = revision; ++ ret = hns3_get_pci_revision_id(hw, &hw->revision); ++ if (ret) ++ return ret; + +- if (revision < PCI_REVISION_ID_HIP09_A) { ++ if (hw->revision < PCI_REVISION_ID_HIP09_A) { + hns3vf_set_default_dev_specifications(hw); + hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE; + hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_2US; +-- +2.33.0 + diff --git a/0032-net-hns3-replace-single-line-functions.patch b/0032-net-hns3-replace-single-line-functions.patch new file mode 100644 index 0000000..d6d89ff --- /dev/null +++ b/0032-net-hns3-replace-single-line-functions.patch @@ -0,0 +1,114 @@ +From 3340aa9f50da68f20d2cdb6382a9ab6891e7363c Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Sat, 22 Jan 2022 09:51:38 +0800 +Subject: [PATCH] net/hns3: replace single line functions + +This patch removes single functions with actual calls. + +Signed-off-by: Chengwen Feng +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 27 ++++++++------------------- + drivers/net/hns3/hns3_ethdev_vf.c | 13 ++----------- + 2 files changed, 10 insertions(+), 30 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index b417d55e10..a5114662d2 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -587,22 +587,6 @@ hns3_set_vlan_rx_offload_cfg(struct hns3_adapter *hns, + return ret; + } + +-static void +-hns3_update_rx_offload_cfg(struct hns3_adapter *hns, +- struct hns3_rx_vtag_cfg *vcfg) +-{ +- struct hns3_pf *pf = &hns->pf; +- memcpy(&pf->vtag_config.rx_vcfg, vcfg, sizeof(pf->vtag_config.rx_vcfg)); +-} +- +-static void +-hns3_update_tx_offload_cfg(struct hns3_adapter *hns, +- struct hns3_tx_vtag_cfg *vcfg) +-{ +- struct hns3_pf *pf = &hns->pf; +- memcpy(&pf->vtag_config.tx_vcfg, vcfg, sizeof(pf->vtag_config.tx_vcfg)); +-} +- + static int + hns3_en_hw_strip_rxvtag(struct hns3_adapter *hns, bool enable) + { +@@ -632,7 +616,8 @@ hns3_en_hw_strip_rxvtag(struct hns3_adapter *hns, bool enable) + return ret; + } + +- hns3_update_rx_offload_cfg(hns, &rxvlan_cfg); ++ memcpy(&hns->pf.vtag_config.rx_vcfg, &rxvlan_cfg, ++ sizeof(struct hns3_rx_vtag_cfg)); + + return ret; + } +@@ -830,7 +815,9 @@ hns3_vlan_txvlan_cfg(struct hns3_adapter *hns, uint16_t port_base_vlan_state, + return ret; + } + +- hns3_update_tx_offload_cfg(hns, &txvlan_cfg); ++ memcpy(&hns->pf.vtag_config.tx_vcfg, &txvlan_cfg, ++ sizeof(struct hns3_tx_vtag_cfg)); ++ + return ret; + } + +@@ -956,7 +943,9 @@ hns3_en_pvid_strip(struct hns3_adapter *hns, int on) + if (ret) + return ret; + +- hns3_update_rx_offload_cfg(hns, &rx_vlan_cfg); ++ memcpy(&hns->pf.vtag_config.rx_vcfg, &rx_vlan_cfg, ++ sizeof(struct hns3_rx_vtag_cfg)); ++ + return ret; + } + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index a9e129288b..1af2e07e81 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1026,15 +1026,6 @@ hns3vf_get_configuration(struct hns3_hw *hw) + return hns3vf_get_port_base_vlan_filter_state(hw); + } + +-static int +-hns3vf_set_tc_queue_mapping(struct hns3_adapter *hns, uint16_t nb_rx_q, +- uint16_t nb_tx_q) +-{ +- struct hns3_hw *hw = &hns->hw; +- +- return hns3_queue_to_tc_mapping(hw, nb_rx_q, nb_tx_q); +-} +- + static void + hns3vf_request_link_info(struct hns3_hw *hw) + { +@@ -1530,7 +1521,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) + goto err_set_tc_queue; + } + +- ret = hns3vf_set_tc_queue_mapping(hns, hw->tqps_num, hw->tqps_num); ++ ret = hns3_queue_to_tc_mapping(hw, hw->tqps_num, hw->tqps_num); + if (ret) { + PMD_INIT_LOG(ERR, "failed to set tc info, ret = %d.", ret); + goto err_set_tc_queue; +@@ -1739,7 +1730,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue) + uint16_t nb_tx_q = hw->data->nb_tx_queues; + int ret; + +- ret = hns3vf_set_tc_queue_mapping(hns, nb_rx_q, nb_tx_q); ++ ret = hns3_queue_to_tc_mapping(hw, nb_rx_q, nb_tx_q); + if (ret) + return ret; + +-- +2.33.0 + diff --git a/0033-net-hns3-remove-non-re-entrant-strerror-call.patch b/0033-net-hns3-remove-non-re-entrant-strerror-call.patch new file mode 100644 index 0000000..2d45217 --- /dev/null +++ b/0033-net-hns3-remove-non-re-entrant-strerror-call.patch @@ -0,0 +1,30 @@ +From 2a1e7c4782ee21823eb37acbb073bcf9f73b173f Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Sat, 22 Jan 2022 09:51:39 +0800 +Subject: [PATCH] net/hns3: remove non re-entrant strerror call + +This patch delete strerror invoke which was non re-entrant. + +Signed-off-by: Chengwen Feng +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_fdir.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index d043f5786d..2a7978ac07 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -919,8 +919,7 @@ static int hns3_insert_fdir_filter(struct hns3_hw *hw, + sig = rte_hash_crc(key, sizeof(*key), 0); + ret = rte_hash_add_key_with_hash(fdir_info->hash_handle, key, sig); + if (ret < 0) { +- hns3_err(hw, "Hash table full? err:%d(%s)!", ret, +- strerror(-ret)); ++ hns3_err(hw, "Hash table full? err:%d!", ret); + return ret; + } + +-- +2.33.0 + diff --git a/0034-net-hns3-rename-function.patch b/0034-net-hns3-rename-function.patch new file mode 100644 index 0000000..6f2e90e --- /dev/null +++ b/0034-net-hns3-rename-function.patch @@ -0,0 +1,39 @@ +From 092ffe854dafe98f3e8e4c412211b80f6932315e Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Sat, 22 Jan 2022 09:51:40 +0800 +Subject: [PATCH] net/hns3: rename function + +This patch rename hns3_parse_rss_key with hns3_adjust_rss_key to +improve readability. + +Signed-off-by: Chengwen Feng +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_flow.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 00084872ad..72986abaff 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1405,7 +1405,7 @@ hns3_disable_rss(struct hns3_hw *hw) + } + + static void +-hns3_parse_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf) ++hns3_adjust_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf) + { + if (rss_conf->key == NULL || rss_conf->key_len < HNS3_RSS_KEY_SIZE) { + hns3_warn(hw, "Default RSS hash key to be set"); +@@ -1449,7 +1449,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + struct hns3_rss_tuple_cfg *tuple; + int ret; + +- hns3_parse_rss_key(hw, rss_config); ++ hns3_adjust_rss_key(hw, rss_config); + + ret = hns3_parse_rss_algorithm(hw, &rss_config->func, + &hw->rss_info.hash_algo); +-- +2.33.0 + diff --git a/0035-net-hns3-extract-functions-to-create-RSS-and-FDIR-fl.patch b/0035-net-hns3-extract-functions-to-create-RSS-and-FDIR-fl.patch new file mode 100644 index 0000000..6c65621 --- /dev/null +++ b/0035-net-hns3-extract-functions-to-create-RSS-and-FDIR-fl.patch @@ -0,0 +1,225 @@ +From c48499171f5df62a71697dce517b9fa22bc30985 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 22 Jan 2022 09:51:41 +0800 +Subject: [PATCH] net/hns3: extract functions to create RSS and FDIR flow rule + +Extract two functions to create the RSS and FDIR flow rule for clearer +code logic. + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_flow.c | 173 +++++++++++++++++++++-------------- + 1 file changed, 106 insertions(+), 67 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 72986abaff..4f271a32dd 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1706,6 +1706,105 @@ hns3_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, + return hns3_parse_fdir_filter(dev, pattern, actions, &fdir_rule, error); + } + ++static int ++hns3_flow_create_rss_rule(struct rte_eth_dev *dev, ++ const struct rte_flow_action *act, ++ struct rte_flow *flow) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_rss_conf_ele *rss_filter_ptr; ++ const struct hns3_rss_conf *rss_conf; ++ int ret; ++ ++ rss_filter_ptr = rte_zmalloc("hns3 rss filter", ++ sizeof(struct hns3_rss_conf_ele), 0); ++ if (rss_filter_ptr == NULL) { ++ hns3_err(hw, "failed to allocate hns3_rss_filter memory"); ++ return -ENOMEM; ++ } ++ ++ /* ++ * After all the preceding tasks are successfully configured, configure ++ * rules to the hardware to simplify the rollback of rules in the ++ * hardware. ++ */ ++ rss_conf = (const struct hns3_rss_conf *)act->conf; ++ ret = hns3_flow_parse_rss(dev, rss_conf, true); ++ if (ret != 0) { ++ rte_free(rss_filter_ptr); ++ return ret; ++ } ++ ++ hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf); ++ rss_filter_ptr->filter_info.valid = true; ++ TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries); ++ flow->rule = rss_filter_ptr; ++ flow->filter_type = RTE_ETH_FILTER_HASH; ++ ++ return 0; ++} ++ ++static int ++hns3_flow_create_fdir_rule(struct rte_eth_dev *dev, ++ const struct rte_flow_item pattern[], ++ const struct rte_flow_action actions[], ++ struct rte_flow_error *error, ++ struct rte_flow *flow) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ struct hns3_fdir_rule_ele *fdir_rule_ptr; ++ struct hns3_fdir_rule fdir_rule; ++ int ret; ++ ++ memset(&fdir_rule, 0, sizeof(struct hns3_fdir_rule)); ++ ret = hns3_parse_fdir_filter(dev, pattern, actions, &fdir_rule, error); ++ if (ret != 0) ++ return ret; ++ ++ if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) { ++ ret = hns3_counter_new(dev, 0, ++ fdir_rule.act_cnt.id, error); ++ if (ret != 0) ++ return ret; ++ ++ flow->counter_id = fdir_rule.act_cnt.id; ++ } ++ ++ fdir_rule_ptr = rte_zmalloc("hns3 fdir rule", ++ sizeof(struct hns3_fdir_rule_ele), 0); ++ if (fdir_rule_ptr == NULL) { ++ hns3_err(hw, "failed to allocate fdir_rule memory."); ++ ret = -ENOMEM; ++ goto err_malloc; ++ } ++ ++ /* ++ * After all the preceding tasks are successfully configured, configure ++ * rules to the hardware to simplify the rollback of rules in the ++ * hardware. ++ */ ++ ret = hns3_fdir_filter_program(hns, &fdir_rule, false); ++ if (ret != 0) ++ goto err_fdir_filter; ++ ++ memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule, ++ sizeof(struct hns3_fdir_rule)); ++ TAILQ_INSERT_TAIL(&hw->flow_fdir_list, fdir_rule_ptr, entries); ++ flow->rule = fdir_rule_ptr; ++ flow->filter_type = RTE_ETH_FILTER_FDIR; ++ ++ return 0; ++ ++err_fdir_filter: ++ rte_free(fdir_rule_ptr); ++err_malloc: ++ if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) ++ hns3_counter_release(dev, fdir_rule.act_cnt.id); ++ ++ return ret; ++} ++ + /* + * Create or destroy a flow rule. + * Theorically one rule can match more than one filters. +@@ -1720,13 +1819,9 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +- const struct hns3_rss_conf *rss_conf; +- struct hns3_fdir_rule_ele *fdir_rule_ptr; +- struct hns3_rss_conf_ele *rss_filter_ptr; + struct hns3_flow_mem *flow_node; + const struct rte_flow_action *act; + struct rte_flow *flow; +- struct hns3_fdir_rule fdir_rule; + int ret; + + ret = hns3_flow_validate(dev, attr, pattern, actions, error); +@@ -1752,76 +1847,20 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, + TAILQ_INSERT_TAIL(&hw->flow_list, flow_node, entries); + + act = hns3_find_rss_general_action(pattern, actions); +- if (act) { +- rss_conf = act->conf; +- +- ret = hns3_flow_parse_rss(dev, rss_conf, true); +- if (ret) +- goto err; +- +- rss_filter_ptr = rte_zmalloc("hns3 rss filter", +- sizeof(struct hns3_rss_conf_ele), +- 0); +- if (rss_filter_ptr == NULL) { +- hns3_err(hw, +- "Failed to allocate hns3_rss_filter memory"); +- ret = -ENOMEM; +- goto err; +- } +- hns3_rss_conf_copy(&rss_filter_ptr->filter_info, +- &rss_conf->conf); +- rss_filter_ptr->filter_info.valid = true; +- TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries); +- +- flow->rule = rss_filter_ptr; +- flow->filter_type = RTE_ETH_FILTER_HASH; +- return flow; +- } +- +- memset(&fdir_rule, 0, sizeof(struct hns3_fdir_rule)); +- ret = hns3_parse_fdir_filter(dev, pattern, actions, &fdir_rule, error); +- if (ret) +- goto out; +- +- if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) { +- ret = hns3_counter_new(dev, 0, fdir_rule.act_cnt.id, error); +- if (ret) +- goto out; +- +- flow->counter_id = fdir_rule.act_cnt.id; +- } +- +- fdir_rule_ptr = rte_zmalloc("hns3 fdir rule", +- sizeof(struct hns3_fdir_rule_ele), +- 0); +- if (fdir_rule_ptr == NULL) { +- hns3_err(hw, "failed to allocate fdir_rule memory."); +- ret = -ENOMEM; +- goto err_fdir; +- } +- +- ret = hns3_fdir_filter_program(hns, &fdir_rule, false); +- if (!ret) { +- memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule, +- sizeof(struct hns3_fdir_rule)); +- TAILQ_INSERT_TAIL(&hw->flow_fdir_list, fdir_rule_ptr, entries); +- flow->rule = fdir_rule_ptr; +- flow->filter_type = RTE_ETH_FILTER_FDIR; +- ++ if (act) ++ ret = hns3_flow_create_rss_rule(dev, act, flow); ++ else ++ ret = hns3_flow_create_fdir_rule(dev, pattern, actions, ++ error, flow); ++ if (ret == 0) + return flow; +- } + +- rte_free(fdir_rule_ptr); +-err_fdir: +- if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) +- hns3_counter_release(dev, fdir_rule.act_cnt.id); +-err: + rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Failed to create flow"); +-out: + TAILQ_REMOVE(&hw->flow_list, flow_node, entries); + rte_free(flow_node); + rte_free(flow); ++ + return NULL; + } + +-- +2.33.0 + diff --git a/0036-net-hns3-support-indirect-counter-flow-action.patch b/0036-net-hns3-support-indirect-counter-flow-action.patch new file mode 100644 index 0000000..7251d4d --- /dev/null +++ b/0036-net-hns3-support-indirect-counter-flow-action.patch @@ -0,0 +1,367 @@ +From fdfcb94d8fb32364a999108baf1e4b835cd807fc Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Sat, 22 Jan 2022 09:51:42 +0800 +Subject: [PATCH] net/hns3: support indirect counter flow action + +This patch support indirect counter action because the shared counter +attribute has been deprecated in DPDK 21.11. + +Signed-off-by: Chengwen Feng +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_fdir.h | 1 + + drivers/net/hns3/hns3_flow.c | 222 +++++++++++++++++++++++++++++++++-- + drivers/net/hns3/hns3_flow.h | 11 +- + 3 files changed, 224 insertions(+), 10 deletions(-) + +diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h +index 07b393393d..8d588ffef3 100644 +--- a/drivers/net/hns3/hns3_fdir.h ++++ b/drivers/net/hns3/hns3_fdir.h +@@ -125,6 +125,7 @@ struct hns3_fd_ad_data { + #define HNS3_RULE_FLAG_FDID 0x1 + #define HNS3_RULE_FLAG_VF_ID 0x2 + #define HNS3_RULE_FLAG_COUNTER 0x4 ++#define HNS3_RULE_FLAG_COUNTER_INDIR 0x8 + + struct hns3_fdir_key_conf { + struct hns3_fd_rule_tuples spec; +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 4f271a32dd..56ef6f57b2 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -154,7 +154,7 @@ hns3_counter_lookup(struct rte_eth_dev *dev, uint32_t id) + } + + static int +-hns3_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id, ++hns3_counter_new(struct rte_eth_dev *dev, uint32_t indirect, uint32_t id, + struct rte_flow_error *error) + { + struct hns3_adapter *hns = dev->data->dev_private; +@@ -166,11 +166,14 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id, + + cnt = hns3_counter_lookup(dev, id); + if (cnt) { +- if (!cnt->shared || cnt->shared != shared) ++ if (!cnt->indirect || cnt->indirect != indirect) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + cnt, +- "Counter id is used, shared flag not match"); ++ "Counter id is used, indirect flag not match"); ++ /* Clear the indirect counter on first use. */ ++ if (cnt->indirect && cnt->ref_cnt == 1) ++ (void)hns3_get_count(hw, id, &value); + cnt->ref_cnt++; + return 0; + } +@@ -188,7 +191,7 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id, + RTE_FLOW_ERROR_TYPE_HANDLE, cnt, + "Alloc mem for counter failed"); + cnt->id = id; +- cnt->shared = shared; ++ cnt->indirect = indirect; + cnt->ref_cnt = 1; + cnt->hits = 0; + LIST_INSERT_HEAD(&pf->flow_counters, cnt, next); +@@ -253,16 +256,30 @@ hns3_counter_release(struct rte_eth_dev *dev, uint32_t id) + static void + hns3_counter_flush(struct rte_eth_dev *dev) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_pf *pf = &hns->pf; ++ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); ++ LIST_HEAD(counters, hns3_flow_counter) indir_counters; + struct hns3_flow_counter *cnt_ptr; + ++ LIST_INIT(&indir_counters); + cnt_ptr = LIST_FIRST(&pf->flow_counters); + while (cnt_ptr) { + LIST_REMOVE(cnt_ptr, next); +- rte_free(cnt_ptr); ++ if (cnt_ptr->indirect) ++ LIST_INSERT_HEAD(&indir_counters, cnt_ptr, next); ++ else ++ rte_free(cnt_ptr); + cnt_ptr = LIST_FIRST(&pf->flow_counters); + } ++ ++ /* Reset the indirect action and add to pf->flow_counters list. */ ++ cnt_ptr = LIST_FIRST(&indir_counters); ++ while (cnt_ptr) { ++ LIST_REMOVE(cnt_ptr, next); ++ cnt_ptr->ref_cnt = 1; ++ cnt_ptr->hits = 0; ++ LIST_INSERT_HEAD(&pf->flow_counters, cnt_ptr, next); ++ cnt_ptr = LIST_FIRST(&indir_counters); ++ } + } + + static int +@@ -332,6 +349,30 @@ hns3_handle_action_queue_region(struct rte_eth_dev *dev, + return 0; + } + ++static int ++hns3_handle_action_indirect(struct rte_eth_dev *dev, ++ const struct rte_flow_action *action, ++ struct hns3_fdir_rule *rule, ++ struct rte_flow_error *error) ++{ ++ const struct rte_flow_action_handle *indir = action->conf; ++ ++ if (indir->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ action, "Invalid indirect type"); ++ ++ if (hns3_counter_lookup(dev, indir->counter_id) == NULL) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ action, "Counter id not exist"); ++ ++ rule->act_cnt.id = indir->counter_id; ++ rule->flags |= (HNS3_RULE_FLAG_COUNTER | HNS3_RULE_FLAG_COUNTER_INDIR); ++ ++ return 0; ++} ++ + /* + * Parse actions structure from the provided pattern. + * The pattern is validated as the items are copied. +@@ -403,6 +444,13 @@ hns3_handle_actions(struct rte_eth_dev *dev, + "Invalid counter id"); + rule->act_cnt = *act_count; + rule->flags |= HNS3_RULE_FLAG_COUNTER; ++ rule->flags &= ~HNS3_RULE_FLAG_COUNTER_INDIR; ++ break; ++ case RTE_FLOW_ACTION_TYPE_INDIRECT: ++ ret = hns3_handle_action_indirect(dev, actions, rule, ++ error); ++ if (ret) ++ return ret; + break; + case RTE_FLOW_ACTION_TYPE_VOID: + break; +@@ -1755,6 +1803,7 @@ hns3_flow_create_fdir_rule(struct rte_eth_dev *dev, + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + struct hns3_fdir_rule_ele *fdir_rule_ptr; + struct hns3_fdir_rule fdir_rule; ++ bool indir; + int ret; + + memset(&fdir_rule, 0, sizeof(struct hns3_fdir_rule)); +@@ -1762,9 +1811,10 @@ hns3_flow_create_fdir_rule(struct rte_eth_dev *dev, + if (ret != 0) + return ret; + ++ indir = !!(fdir_rule.flags & HNS3_RULE_FLAG_COUNTER_INDIR); + if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) { +- ret = hns3_counter_new(dev, 0, +- fdir_rule.act_cnt.id, error); ++ ret = hns3_counter_new(dev, indir, fdir_rule.act_cnt.id, ++ error); + if (ret != 0) + return ret; + +@@ -2086,6 +2136,157 @@ hns3_flow_query_wrap(struct rte_eth_dev *dev, struct rte_flow *flow, + return ret; + } + ++static int ++hns3_check_indir_action(const struct rte_flow_indir_action_conf *conf, ++ const struct rte_flow_action *action, ++ struct rte_flow_error *error) ++{ ++ if (!conf->ingress) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION, ++ NULL, "Indir action ingress can't be zero"); ++ ++ if (conf->egress) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION, ++ NULL, "Indir action not support egress"); ++ ++ if (conf->transfer) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION, ++ NULL, "Indir action not support transfer"); ++ ++ if (action->type != RTE_FLOW_ACTION_TYPE_COUNT) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION, ++ NULL, "Indir action only support count"); ++ ++ return 0; ++} ++ ++static struct rte_flow_action_handle * ++hns3_flow_action_create(struct rte_eth_dev *dev, ++ const struct rte_flow_indir_action_conf *conf, ++ const struct rte_flow_action *action, ++ struct rte_flow_error *error) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); ++ const struct rte_flow_action_count *act_count; ++ struct rte_flow_action_handle *handle = NULL; ++ struct hns3_flow_counter *counter; ++ ++ if (hns3_check_indir_action(conf, action, error)) ++ return NULL; ++ ++ handle = rte_zmalloc("hns3 action handle", ++ sizeof(struct rte_flow_action_handle), 0); ++ if (handle == NULL) { ++ rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, ++ NULL, "Failed to allocate action memory"); ++ return NULL; ++ } ++ ++ pthread_mutex_lock(&hw->flows_lock); ++ ++ act_count = (const struct rte_flow_action_count *)action->conf; ++ if (act_count->id >= pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1]) { ++ rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ action, "Invalid counter id"); ++ goto err_exit; ++ } ++ ++ if (hns3_counter_new(dev, false, act_count->id, error)) ++ goto err_exit; ++ ++ counter = hns3_counter_lookup(dev, act_count->id); ++ if (counter == NULL) { ++ rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ action, "Counter id not found"); ++ goto err_exit; ++ } ++ ++ counter->indirect = true; ++ handle->indirect_type = HNS3_INDIRECT_ACTION_TYPE_COUNT; ++ handle->counter_id = counter->id; ++ ++ pthread_mutex_unlock(&hw->flows_lock); ++ return handle; ++ ++err_exit: ++ pthread_mutex_unlock(&hw->flows_lock); ++ rte_free(handle); ++ return NULL; ++} ++ ++static int ++hns3_flow_action_destroy(struct rte_eth_dev *dev, ++ struct rte_flow_action_handle *handle, ++ struct rte_flow_error *error) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_flow_counter *counter; ++ ++ pthread_mutex_lock(&hw->flows_lock); ++ ++ if (handle->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { ++ pthread_mutex_unlock(&hw->flows_lock); ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ handle, "Invalid indirect type"); ++ } ++ ++ counter = hns3_counter_lookup(dev, handle->counter_id); ++ if (counter == NULL) { ++ pthread_mutex_unlock(&hw->flows_lock); ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ handle, "Counter id not exist"); ++ } ++ ++ if (counter->ref_cnt > 1) { ++ pthread_mutex_unlock(&hw->flows_lock); ++ return rte_flow_error_set(error, EBUSY, ++ RTE_FLOW_ERROR_TYPE_HANDLE, ++ handle, "Counter id in use"); ++ } ++ ++ (void)hns3_counter_release(dev, handle->counter_id); ++ rte_free(handle); ++ ++ pthread_mutex_unlock(&hw->flows_lock); ++ return 0; ++} ++ ++static int ++hns3_flow_action_query(struct rte_eth_dev *dev, ++ const struct rte_flow_action_handle *handle, ++ void *data, ++ struct rte_flow_error *error) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct rte_flow flow; ++ int ret; ++ ++ pthread_mutex_lock(&hw->flows_lock); ++ ++ if (handle->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { ++ pthread_mutex_unlock(&hw->flows_lock); ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ handle, "Invalid indirect type"); ++ } ++ ++ memset(&flow, 0, sizeof(flow)); ++ flow.counter_id = handle->counter_id; ++ ret = hns3_counter_query(dev, &flow, ++ (struct rte_flow_query_count *)data, error); ++ pthread_mutex_unlock(&hw->flows_lock); ++ return ret; ++} ++ + static const struct rte_flow_ops hns3_flow_ops = { + .validate = hns3_flow_validate_wrap, + .create = hns3_flow_create_wrap, +@@ -2093,6 +2294,9 @@ static const struct rte_flow_ops hns3_flow_ops = { + .flush = hns3_flow_flush_wrap, + .query = hns3_flow_query_wrap, + .isolate = NULL, ++ .action_handle_create = hns3_flow_action_create, ++ .action_handle_destroy = hns3_flow_action_destroy, ++ .action_handle_query = hns3_flow_action_query, + }; + + int +diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h +index 2eb451b720..1ab3f9f5c6 100644 +--- a/drivers/net/hns3/hns3_flow.h ++++ b/drivers/net/hns3/hns3_flow.h +@@ -9,7 +9,7 @@ + + struct hns3_flow_counter { + LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */ +- uint32_t shared:1; /* Share counter ID with other flow rules. */ ++ uint32_t indirect:1; /* Indirect counter flag */ + uint32_t ref_cnt:31; /* Reference counter. */ + uint16_t id; /* Counter ID. */ + uint64_t hits; /* Number of packets matched by the rule. */ +@@ -33,6 +33,15 @@ struct hns3_flow_mem { + struct rte_flow *flow; + }; + ++enum { ++ HNS3_INDIRECT_ACTION_TYPE_COUNT = 1, ++}; ++ ++struct rte_flow_action_handle { ++ int indirect_type; ++ uint32_t counter_id; ++}; ++ + TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); + TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); + +-- +2.33.0 + diff --git a/0037-net-hns3-fix-max-packet-size-rollback-in-PF.patch b/0037-net-hns3-fix-max-packet-size-rollback-in-PF.patch new file mode 100644 index 0000000..c825a46 --- /dev/null +++ b/0037-net-hns3-fix-max-packet-size-rollback-in-PF.patch @@ -0,0 +1,63 @@ +From dc55ce9c6253664160b881a1b83b2b4f1e90a587 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 28 Jan 2022 10:07:03 +0800 +Subject: [PATCH] net/hns3: fix max packet size rollback in PF + +HNS3 PF driver use the hns->pf.mps to restore the MTU when a reset +occurs. +If user fails to configure the MTU, the MPS of PF may not be restored to +the original value. + +Fixes: 25fb790f7868 ("net/hns3: fix HW buffer size on MTU update") +Fixes: 1f5ca0b460cd ("net/hns3: support some device operations") +Fixes: d51867db65c1 ("net/hns3: add initialization") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index a5114662d2..73bf209717 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2075,7 +2075,6 @@ static int + hns3_config_mtu(struct hns3_hw *hw, uint16_t mps) + { + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); +- uint16_t original_mps = hns->pf.mps; + int err; + int ret; + +@@ -2085,22 +2084,20 @@ hns3_config_mtu(struct hns3_hw *hw, uint16_t mps) + return ret; + } + +- hns->pf.mps = mps; + ret = hns3_buffer_alloc(hw); + if (ret) { + hns3_err(hw, "failed to allocate buffer, ret = %d", ret); + goto rollback; + } + ++ hns->pf.mps = mps; ++ + return 0; + + rollback: +- err = hns3_set_mac_mtu(hw, original_mps); +- if (err) { ++ err = hns3_set_mac_mtu(hw, hns->pf.mps); ++ if (err) + hns3_err(hw, "fail to rollback MTU, err = %d", err); +- return ret; +- } +- hns->pf.mps = original_mps; + + return ret; + } +-- +2.33.0 + diff --git a/0038-net-hns3-fix-RSS-key-with-null.patch b/0038-net-hns3-fix-RSS-key-with-null.patch new file mode 100644 index 0000000..e96ce28 --- /dev/null +++ b/0038-net-hns3-fix-RSS-key-with-null.patch @@ -0,0 +1,57 @@ +From ca937bfe5f48de028c25312bcdb30ec1a6a4cd8e Mon Sep 17 00:00:00 2001 +From: Lijun Ou +Date: Fri, 28 Jan 2022 10:07:04 +0800 +Subject: [PATCH] net/hns3: fix RSS key with null + +Since the patch '1848b117' has initialized the variable 'key' in +'struct rte_flow_action_rss' with 'NULL', the PMD will use the +default RSS key when create the first RSS rule with NULL RSS key. +Then, if create a repeated RSS rule with the above, it will not +identify duplicate rules and return an error message. + +To solve the preceding problem, determine whether the current RSS keys +are the same based on whether the length of key_len of rss is 0. + +Fixes: 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule") +Cc: stable@dpdk.org + +Signed-off-by: Lijun Ou +--- + drivers/net/hns3/hns3_flow.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 56ef6f57b2..aba07aaa6f 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1286,6 +1286,7 @@ static bool + hns3_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) + { ++ bool rss_key_is_same; + bool func_is_same; + + /* +@@ -1302,11 +1303,16 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? + (comp->func == with->func) : true; + +- return (func_is_same && ++ if (with->key_len == 0 || with->key == NULL) ++ rss_key_is_same = 1; ++ else ++ rss_key_is_same = comp->key_len == with->key_len && ++ !memcmp(comp->key, with->key, with->key_len); ++ ++ return (func_is_same && rss_key_is_same && + comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) && +- comp->level == with->level && comp->key_len == with->key_len && ++ comp->level == with->level && + comp->queue_num == with->queue_num && +- !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); + } +-- +2.33.0 + diff --git a/0039-net-hns3-fix-insecure-way-to-query-MAC-statistics.patch b/0039-net-hns3-fix-insecure-way-to-query-MAC-statistics.patch new file mode 100644 index 0000000..da6c6f5 --- /dev/null +++ b/0039-net-hns3-fix-insecure-way-to-query-MAC-statistics.patch @@ -0,0 +1,271 @@ +From a29f3b66f858a7e2fabcb6b557aea7bde17d41fb Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 28 Jan 2022 10:07:05 +0800 +Subject: [PATCH] net/hns3: fix insecure way to query MAC statistics + +The query way of MAC statistics in HNS3 PF driver is as following: +1) get MAC statistics register number and calculate descriptor number. +2) use above descriptor number to send command to firmware to query all + MAC statistics and copy to hns3_mac_stats struct in driver. + +The preceding way does not verify the validity of the number of obtained +register, which may cause memory out-of-bounds. + +Fixes: 8839c5e202f3 ("net/hns3: support device stats") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 4 ++ + drivers/net/hns3/hns3_ethdev.h | 1 + + drivers/net/hns3/hns3_stats.c | 116 ++++++++++++++++----------------- + drivers/net/hns3/hns3_stats.h | 11 ++-- + 4 files changed, 65 insertions(+), 67 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 73bf209717..57f1572340 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2733,6 +2733,10 @@ hns3_get_capability(struct hns3_hw *hw) + if (ret) + return ret; + ++ ret = hns3_query_mac_stats_reg_num(hw); ++ if (ret) ++ return ret; ++ + if (hw->revision < PCI_REVISION_ID_HIP09_A) { + hns3_set_default_dev_specifications(hw); + hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE; +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index cf6380ebb2..ef028a7b2c 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -500,6 +500,7 @@ struct hns3_hw { + struct hns3_tqp_stats tqp_stats; + /* Include Mac stats | Rx stats | Tx stats */ + struct hns3_mac_stats mac_stats; ++ uint32_t mac_stats_reg_num; + struct hns3_rx_missed_stats imissed_stats; + uint64_t oerror_stats; + uint32_t fw_version; +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index 606b72509a..806720faff 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -307,24 +307,21 @@ static const struct hns3_xstats_name_offset hns3_imissed_stats_strings[] = { + + static void hns3_tqp_stats_clear(struct hns3_hw *hw); + +-/* +- * Query all the MAC statistics data of Network ICL command ,opcode id: 0x0034. +- * This command is used before send 'query_mac_stat command', the descriptor +- * number of 'query_mac_stat command' must match with reg_num in this command. +- * @praram hw +- * Pointer to structure hns3_hw. +- * @return +- * 0 on success. +- */ + static int +-hns3_update_mac_stats(struct hns3_hw *hw, const uint32_t desc_num) ++hns3_update_mac_stats(struct hns3_hw *hw) + { ++#define HNS3_MAC_STATS_REG_NUM_PER_DESC 4 ++ + uint64_t *data = (uint64_t *)(&hw->mac_stats); + struct hns3_cmd_desc *desc; ++ uint32_t stats_iterms; + uint64_t *desc_data; +- uint16_t i, k, n; ++ uint32_t desc_num; ++ uint16_t i; + int ret; + ++ /* The first desc has a 64-bit header, so need to consider it. */ ++ desc_num = hw->mac_stats_reg_num / HNS3_MAC_STATS_REG_NUM_PER_DESC + 1; + desc = rte_malloc("hns3_mac_desc", + desc_num * sizeof(struct hns3_cmd_desc), 0); + if (desc == NULL) { +@@ -340,65 +337,71 @@ hns3_update_mac_stats(struct hns3_hw *hw, const uint32_t desc_num) + return ret; + } + +- for (i = 0; i < desc_num; i++) { +- /* For special opcode 0034, only the first desc has the head */ +- if (i == 0) { +- desc_data = (uint64_t *)(&desc[i].data[0]); +- n = HNS3_RD_FIRST_STATS_NUM; +- } else { +- desc_data = (uint64_t *)(&desc[i]); +- n = HNS3_RD_OTHER_STATS_NUM; +- } +- +- for (k = 0; k < n; k++) { +- *data += rte_le_to_cpu_64(*desc_data); +- data++; +- desc_data++; +- } ++ stats_iterms = RTE_MIN(sizeof(hw->mac_stats) / sizeof(uint64_t), ++ hw->mac_stats_reg_num); ++ desc_data = (uint64_t *)(&desc[0].data[0]); ++ for (i = 0; i < stats_iterms; i++) { ++ /* ++ * Data memory is continuous and only the first descriptor has a ++ * header in this command. ++ */ ++ *data += rte_le_to_cpu_64(*desc_data); ++ data++; ++ desc_data++; + } + rte_free(desc); + + return 0; + } + +-/* +- * Query Mac stat reg num command ,opcode id: 0x0033. +- * This command is used before send 'query_mac_stat command', the descriptor +- * number of 'query_mac_stat command' must match with reg_num in this command. +- * @praram rte_stats +- * Pointer to structure rte_eth_stats. +- * @return +- * 0 on success. +- */ + static int +-hns3_mac_query_reg_num(struct rte_eth_dev *dev, uint32_t *desc_num) ++hns3_mac_query_reg_num(struct hns3_hw *hw, uint32_t *reg_num) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; ++#define HNS3_MAC_STATS_RSV_REG_NUM_ON_HIP08_B 3 + struct hns3_cmd_desc desc; +- uint32_t *desc_data; +- uint32_t reg_num; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_MAC_REG_NUM, true); + ret = hns3_cmd_send(hw, &desc, 1); +- if (ret) ++ if (ret) { ++ hns3_err(hw, "failed to query MAC statistic reg number, ret = %d", ++ ret); + return ret; ++ } + +- /* +- * The num of MAC statistics registers that are provided by IMP in this +- * version. +- */ +- desc_data = (uint32_t *)(&desc.data[0]); +- reg_num = rte_le_to_cpu_32(*desc_data); ++ /* The number of MAC statistics registers are provided by firmware. */ ++ *reg_num = rte_le_to_cpu_32(desc.data[0]); ++ if (*reg_num == 0) { ++ hns3_err(hw, "MAC statistic reg number is invalid!"); ++ return -ENODATA; ++ } + + /* +- * The descriptor number of 'query_additional_mac_stat command' is +- * '1 + (reg_num-3)/4 + ((reg_num-3)%4 !=0)'; +- * This value is 83 in this version ++ * If driver doesn't request the firmware to report more MAC statistics ++ * iterms and the total number of MAC statistics registers by using new ++ * method, firmware will only reports the number of valid statistics ++ * registers. However, structure hns3_mac_stats in driver contains valid ++ * and reserved statistics iterms. In this case, the total register ++ * number must be added to three reserved statistics registers. + */ +- *desc_num = 1 + ((reg_num - 3) >> 2) + +- (uint32_t)(((reg_num - 3) & 0x3) ? 1 : 0); ++ *reg_num += HNS3_MAC_STATS_RSV_REG_NUM_ON_HIP08_B; ++ ++ return 0; ++} ++ ++int ++hns3_query_mac_stats_reg_num(struct hns3_hw *hw) ++{ ++ uint32_t mac_stats_reg_num = 0; ++ int ret; ++ ++ ret = hns3_mac_query_reg_num(hw, &mac_stats_reg_num); ++ if (ret) ++ return ret; ++ ++ hw->mac_stats_reg_num = mac_stats_reg_num; ++ if (hw->mac_stats_reg_num > sizeof(hw->mac_stats) / sizeof(uint64_t)) ++ hns3_warn(hw, "MAC stats reg number from firmware is greater than stats iterms in driver."); + + return 0; + } +@@ -408,15 +411,8 @@ hns3_query_update_mac_stats(struct rte_eth_dev *dev) + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +- uint32_t desc_num; +- int ret; + +- ret = hns3_mac_query_reg_num(dev, &desc_num); +- if (ret == 0) +- ret = hns3_update_mac_stats(hw, desc_num); +- else +- hns3_err(hw, "Query mac reg num fail : %d", ret); +- return ret; ++ return hns3_update_mac_stats(hw); + } + + static int +diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h +index d1230f94cb..c81d351082 100644 +--- a/drivers/net/hns3/hns3_stats.h ++++ b/drivers/net/hns3/hns3_stats.h +@@ -5,11 +5,6 @@ + #ifndef _HNS3_STATS_H_ + #define _HNS3_STATS_H_ + +-/* stats macro */ +-#define HNS3_MAC_CMD_NUM 21 +-#define HNS3_RD_FIRST_STATS_NUM 2 +-#define HNS3_RD_OTHER_STATS_NUM 4 +- + /* TQP stats */ + struct hns3_tqp_stats { + uint64_t rcb_tx_ring_pktnum_rcd; /* Total num of transmitted packets */ +@@ -22,6 +17,7 @@ struct hns3_tqp_stats { + struct hns3_mac_stats { + uint64_t mac_tx_mac_pause_num; + uint64_t mac_rx_mac_pause_num; ++ uint64_t rsv0; + uint64_t mac_tx_pfc_pri0_pkt_num; + uint64_t mac_tx_pfc_pri1_pkt_num; + uint64_t mac_tx_pfc_pri2_pkt_num; +@@ -58,7 +54,7 @@ struct hns3_mac_stats { + uint64_t mac_tx_1519_2047_oct_pkt_num; + uint64_t mac_tx_2048_4095_oct_pkt_num; + uint64_t mac_tx_4096_8191_oct_pkt_num; +- uint64_t rsv0; ++ uint64_t rsv1; + uint64_t mac_tx_8192_9216_oct_pkt_num; + uint64_t mac_tx_9217_12287_oct_pkt_num; + uint64_t mac_tx_12288_16383_oct_pkt_num; +@@ -85,7 +81,7 @@ struct hns3_mac_stats { + uint64_t mac_rx_1519_2047_oct_pkt_num; + uint64_t mac_rx_2048_4095_oct_pkt_num; + uint64_t mac_rx_4096_8191_oct_pkt_num; +- uint64_t rsv1; ++ uint64_t rsv2; + uint64_t mac_rx_8192_9216_oct_pkt_num; + uint64_t mac_rx_9217_12287_oct_pkt_num; + uint64_t mac_rx_12288_16383_oct_pkt_num; +@@ -168,5 +164,6 @@ int hns3_stats_reset(struct rte_eth_dev *dev); + int hns3_tqp_stats_init(struct hns3_hw *hw); + void hns3_tqp_stats_uninit(struct hns3_hw *hw); + int hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear); ++int hns3_query_mac_stats_reg_num(struct hns3_hw *hw); + + #endif /* _HNS3_STATS_H_ */ +-- +2.33.0 + diff --git a/0040-net-hns3-fix-double-decrement-of-secondary-count.patch b/0040-net-hns3-fix-double-decrement-of-secondary-count.patch new file mode 100644 index 0000000..e612190 --- /dev/null +++ b/0040-net-hns3-fix-double-decrement-of-secondary-count.patch @@ -0,0 +1,33 @@ +From eb0bbc8fbec6bb10dfcfdca470dc413038e8608c Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 28 Jan 2022 10:07:06 +0800 +Subject: [PATCH] net/hns3: fix double decrement of secondary count + +The "secondary_cnt" indicates the number of secondary processes on an +Ethernet device. But the variable is double subtracted when detach the +device in secondary processes. + +Fixes: ff6dc76e40b8 ("net/hns3: refactor multi-process initialization") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev_vf.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 1af2e07e81..dab1130dad 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -2399,7 +2399,6 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) + PMD_INIT_FUNC_TRACE(); + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { +- __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); + hns3_mp_uninit(eth_dev); + return 0; + } +-- +2.33.0 + diff --git a/0041-net-hns3-fix-operating-queue-when-TCAM-table-is-inva.patch b/0041-net-hns3-fix-operating-queue-when-TCAM-table-is-inva.patch new file mode 100644 index 0000000..95b77f7 --- /dev/null +++ b/0041-net-hns3-fix-operating-queue-when-TCAM-table-is-inva.patch @@ -0,0 +1,57 @@ +From 1c73c33c5ff07ac2a369f0d796e5892ed504e0d3 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 28 Jan 2022 10:07:07 +0800 +Subject: [PATCH] net/hns3: fix operating queue when TCAM table is invalid + +Reset queues will query the TCAM table. The table is cleared after global +or imp reset. Currently, PF driver first resets Rx/Tx queues and then +restore the table during the reset recovery process, which will fail to +query the table and trigger a RAS error. + +Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 57f1572340..2641b6f79b 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4378,6 +4378,10 @@ hns3_init_hardware(struct hns3_adapter *hns) + struct hns3_hw *hw = &hns->hw; + int ret; + ++ /* ++ * All queue-related HW operations must be performed after the TCAM ++ * table is configured. ++ */ + ret = hns3_map_tqp(hw); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to map tqp: %d", ret); +@@ -5547,15 +5551,15 @@ hns3_reinit_dev(struct hns3_adapter *hns) + return ret; + } + +- ret = hns3_reset_all_tqps(hns); ++ ret = hns3_init_hardware(hns); + if (ret) { +- hns3_err(hw, "Failed to reset all queues: %d", ret); ++ hns3_err(hw, "Failed to init hardware: %d", ret); + return ret; + } + +- ret = hns3_init_hardware(hns); ++ ret = hns3_reset_all_tqps(hns); + if (ret) { +- hns3_err(hw, "Failed to init hardware: %d", ret); ++ hns3_err(hw, "Failed to reset all queues: %d", ret); + return ret; + } + +-- +2.33.0 + diff --git a/0042-net-hns3-delete-duplicated-RSS-type.patch b/0042-net-hns3-delete-duplicated-RSS-type.patch new file mode 100644 index 0000000..3adec93 --- /dev/null +++ b/0042-net-hns3-delete-duplicated-RSS-type.patch @@ -0,0 +1,35 @@ +From 6c3c017f980084daef4ddafd111e9ed9aa9619c3 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 28 Jan 2022 10:07:08 +0800 +Subject: [PATCH] net/hns3: delete duplicated RSS type + +The hns3_set_rss_types hold two IPV4_TCP items, this patch deletes +duplicate item. + +Fixes: 806f1d5ab0e3 ("net/hns3: set RSS hash type input configuration") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rss.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 3a4b699ae2..1782d63883 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -152,10 +152,6 @@ static const struct { + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV4_TCP, BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV4_UDP, BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) | +-- +2.33.0 + diff --git a/0043-net-bonding-fix-promiscuous-and-allmulticast-state.patch b/0043-net-bonding-fix-promiscuous-and-allmulticast-state.patch new file mode 100644 index 0000000..94183f7 --- /dev/null +++ b/0043-net-bonding-fix-promiscuous-and-allmulticast-state.patch @@ -0,0 +1,130 @@ +From 905b76987bd194e1356e6fe79949b5119c30f842 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 28 Jan 2022 10:25:32 +0800 +Subject: [PATCH] net/bonding: fix promiscuous and allmulticast state + +Currently, promiscuous or allmulticast state of bonding port will not be +passed to the new primary slave when active/standby switch-over. It +causes bugs in some scenario. + +For example, promiscuous state of bonding port is off now, primary slave +(called A) is off but secondary slave(called B) is on. +Then active/standby switch-over, promiscuous state of the bonding port +is off, but the new primary slave turns to be B and its promiscuous +state is still on. +It is not consistent with bonding port. And this patch will fix it. + +Fixes: 2efb58cbab6e ("bond: new link bonding library") +Fixes: 68218b87c184 ("net/bonding: prefer allmulti to promiscuous for LACP") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 70 ++++++++++++++++++++++++++ + 1 file changed, 70 insertions(+) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index e5abe90e07..d2fcfad676 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -2691,6 +2691,39 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev) + return ret; + } + ++static int ++bond_ethdev_promiscuous_update(struct rte_eth_dev *dev) ++{ ++ struct bond_dev_private *internals = dev->data->dev_private; ++ uint16_t port_id = internals->current_primary_port; ++ ++ switch (internals->mode) { ++ case BONDING_MODE_ROUND_ROBIN: ++ case BONDING_MODE_BALANCE: ++ case BONDING_MODE_BROADCAST: ++ case BONDING_MODE_8023AD: ++ /* As promiscuous mode is propagated to all slaves for these ++ * mode, no need to update for bonding device. ++ */ ++ break; ++ case BONDING_MODE_ACTIVE_BACKUP: ++ case BONDING_MODE_TLB: ++ case BONDING_MODE_ALB: ++ default: ++ /* As promiscuous mode is propagated only to primary slave ++ * for these mode. When active/standby switchover, promiscuous ++ * mode should be set to new primary slave according to bonding ++ * device. ++ */ ++ if (rte_eth_promiscuous_get(internals->port_id) == 1) ++ rte_eth_promiscuous_enable(port_id); ++ else ++ rte_eth_promiscuous_disable(port_id); ++ } ++ ++ return 0; ++} ++ + static int + bond_ethdev_allmulticast_enable(struct rte_eth_dev *eth_dev) + { +@@ -2804,6 +2837,39 @@ bond_ethdev_allmulticast_disable(struct rte_eth_dev *eth_dev) + return ret; + } + ++static int ++bond_ethdev_allmulticast_update(struct rte_eth_dev *dev) ++{ ++ struct bond_dev_private *internals = dev->data->dev_private; ++ uint16_t port_id = internals->current_primary_port; ++ ++ switch (internals->mode) { ++ case BONDING_MODE_ROUND_ROBIN: ++ case BONDING_MODE_BALANCE: ++ case BONDING_MODE_BROADCAST: ++ case BONDING_MODE_8023AD: ++ /* As allmulticast mode is propagated to all slaves for these ++ * mode, no need to update for bonding device. ++ */ ++ break; ++ case BONDING_MODE_ACTIVE_BACKUP: ++ case BONDING_MODE_TLB: ++ case BONDING_MODE_ALB: ++ default: ++ /* As allmulticast mode is propagated only to primary slave ++ * for these mode. When active/standby switchover, allmulticast ++ * mode should be set to new primary slave according to bonding ++ * device. ++ */ ++ if (rte_eth_allmulticast_get(internals->port_id) == 1) ++ rte_eth_allmulticast_enable(port_id); ++ else ++ rte_eth_allmulticast_disable(port_id); ++ } ++ ++ return 0; ++} ++ + static void + bond_ethdev_delayed_lsc_propagation(void *arg) + { +@@ -2893,6 +2959,8 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, + lsc_flag = 1; + + mac_address_slaves_update(bonded_eth_dev); ++ bond_ethdev_promiscuous_update(bonded_eth_dev); ++ bond_ethdev_allmulticast_update(bonded_eth_dev); + } + + activate_slave(bonded_eth_dev, port_id); +@@ -2922,6 +2990,8 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, + else + internals->current_primary_port = internals->primary_port; + mac_address_slaves_update(bonded_eth_dev); ++ bond_ethdev_promiscuous_update(bonded_eth_dev); ++ bond_ethdev_allmulticast_update(bonded_eth_dev); + } + } + +-- +2.33.0 + diff --git a/0044-net-bonding-fix-reference-count-on-mbufs.patch b/0044-net-bonding-fix-reference-count-on-mbufs.patch new file mode 100644 index 0000000..5085cc6 --- /dev/null +++ b/0044-net-bonding-fix-reference-count-on-mbufs.patch @@ -0,0 +1,36 @@ +From 2c1857b46ec66643f127301b9466a3b93fa2d42b Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 28 Jan 2022 10:25:33 +0800 +Subject: [PATCH] net/bonding: fix reference count on mbufs + +In bonding Tx broadcast mode, Packets should be sent by every slave, +but only one mbuf exits. The solution is to increment reference count +on mbufs, but it ignores multi segments. + +This patch fixed it by adding reference for every segment in multi +segments Tx scenario. + +Fixes: 2efb58cbab6e ("bond: new link bonding library") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index d2fcfad676..bfa931098e 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -1318,7 +1318,7 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs, + + /* Increment reference count on mbufs */ + for (i = 0; i < nb_pkts; i++) +- rte_mbuf_refcnt_update(bufs[i], num_of_slaves - 1); ++ rte_pktmbuf_refcnt_update(bufs[i], num_of_slaves - 1); + + /* Transmit burst on each active slave */ + for (i = 0; i < num_of_slaves; i++) { +-- +2.33.0 + diff --git a/0045-app-testpmd-fix-bonding-mode-set.patch b/0045-app-testpmd-fix-bonding-mode-set.patch new file mode 100644 index 0000000..572f666 --- /dev/null +++ b/0045-app-testpmd-fix-bonding-mode-set.patch @@ -0,0 +1,70 @@ +From 32d1817dbff6499dd1d126c466d0f7cb1c114713 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 28 Jan 2022 10:35:19 +0800 +Subject: [PATCH] app/testpmd: fix bonding mode set + +when start testpmd, and type command like this, it will lead to +Segmentation fault, like: + +testpmd> create bonded device 4 0 +testpmd> add bonding slave 0 2 +testpmd> add bonding slave 1 2 +testpmd> port start 2 +testpmd> set bonding mode 0 2 +testpmd> quit +Stopping port 0... +Stopping ports... +... +Bye... +Segmentation fault + +The reason to the bug is that rte timer do not be cancelled when quit. +That is, in 'bond_ethdev_start', resources are allocated according to +different bonding mode. In 'bond_ethdev_stop', resources are free by +the corresponding mode. + +For example, 'bond_ethdev_start' start bond_mode_8023ad_ext_periodic_cb +timer for bonding mode 4. and 'bond_ethdev_stop' cancel the timer only +when the current bonding mode is 4. If the bonding mode is changed, +and directly quit the process, the timer will still on, and freed memory +will be accessed, then segmentation fault. + +'bonding mode' changed means resources changed, reallocate resources for +different mode should be done, that is, device should be restarted. + +Fixes: 2950a769315e ("bond: testpmd support") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +Tested-by: Ferruh Yigit +--- + app/test-pmd/cmdline.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index e626b1c7d9..16ad4be005 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -5915,6 +5915,19 @@ static void cmd_set_bonding_mode_parsed(void *parsed_result, + { + struct cmd_set_bonding_mode_result *res = parsed_result; + portid_t port_id = res->port_id; ++ struct rte_port *port = &ports[port_id]; ++ ++ /* ++ * Bonding mode changed means resources of device changed, like whether ++ * started rte timer or not. Device should be restarted when resources ++ * of device changed. ++ */ ++ if (port->port_status != RTE_PORT_STOPPED) { ++ fprintf(stderr, ++ "\t Error: Can't set bonding mode when port %d is not stopped\n", ++ port_id); ++ return; ++ } + + /* Set the bonding mode for the relevant port. */ + if (0 != rte_eth_bond_mode_set(port_id, res->value)) +-- +2.33.0 + diff --git a/0046-ethdev-introduce-dump-API.patch b/0046-ethdev-introduce-dump-API.patch new file mode 100644 index 0000000..1fd481b --- /dev/null +++ b/0046-ethdev-introduce-dump-API.patch @@ -0,0 +1,129 @@ +From 42a26d7136b259ee7ff1b39325e19ef5ef9fe0e3 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 12:49:22 +0800 +Subject: [PATCH 01/13] ethdev: introduce dump API +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Added the ethdev dump API which provides querying private info from device. +There exists many private properties in different PMD drivers, such as +adapter state, Rx/Tx func algorithm in hns3 PMD. The information of these +properties is important for debug. As the information is private, the new +API is introduced. + +Signed-off-by: Min Hu (Connor) +Acked-by: Morten Brørup +Acked-by: Ray Kinsella +Acked-by: Ajit Khaparde +Acked-by: Ferruh Yigit +--- + lib/ethdev/ethdev_driver.h | 23 +++++++++++++++++++++++ + lib/ethdev/rte_ethdev.c | 17 +++++++++++++++++ + lib/ethdev/rte_ethdev.h | 21 +++++++++++++++++++++ + 3 files changed, 61 insertions(+) + +diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h +index d95605a355..e24ff7064c 100644 +--- a/lib/ethdev/ethdev_driver.h ++++ b/lib/ethdev/ethdev_driver.h +@@ -990,6 +990,26 @@ typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, + typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev, + uint64_t *features); + ++/** ++ ++ * @internal ++ * Dump private info from device to a file. ++ * ++ * @param dev ++ * Port (ethdev) handle. ++ * @param file ++ * A pointer to a file for output. ++ * ++ * @return ++ * Negative value on error, 0 on success. ++ * ++ * @retval 0 ++ * Success ++ * @retval -EINVAL ++ * Invalid file ++ */ ++typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file); ++ + /** + * @internal A structure containing the functions exported by an Ethernet driver. + */ +@@ -1186,6 +1206,9 @@ struct eth_dev_ops { + * kinds of metadata to the PMD + */ + eth_rx_metadata_negotiate_t rx_metadata_negotiate; ++ ++ /** Dump private info from device */ ++ eth_dev_priv_dump_t eth_dev_priv_dump; + }; + + /** +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index a1d475a292..b9a452107f 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6472,6 +6472,23 @@ rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) + (*dev->dev_ops->rx_metadata_negotiate)(dev, features)); + } + ++int ++rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) ++{ ++ struct rte_eth_dev *dev; ++ ++ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); ++ dev = &rte_eth_devices[port_id]; ++ ++ if (file == NULL) { ++ RTE_ETHDEV_LOG(ERR, "Invalid file (NULL)\n"); ++ return -EINVAL; ++ } ++ ++ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_dev_priv_dump, -ENOTSUP); ++ return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); ++} ++ + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); + + RTE_INIT(ethdev_init_telemetry) +diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h +index fa299c8ad7..b8f135ba3f 100644 +--- a/lib/ethdev/rte_ethdev.h ++++ b/lib/ethdev/rte_ethdev.h +@@ -5188,6 +5188,27 @@ int rte_eth_representor_info_get(uint16_t port_id, + __rte_experimental + int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features); + ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice ++ * ++ * Dump private info from device to a file. Provided data and the order depends ++ * on the PMD. ++ * ++ * @param port_id ++ * The port identifier of the Ethernet device. ++ * @param file ++ * A pointer to a file for output. ++ * @return ++ * - (0) on success. ++ * - (-ENODEV) if *port_id* is invalid. ++ * - (-EINVAL) if null file. ++ * - (-ENOTSUP) if the device does not support this function. ++ * - (-EIO) if device is removed. ++ */ ++__rte_experimental ++int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file); ++ + #include + + /** +-- +2.30.0 + diff --git a/0047-app-procinfo-add-device-private-info-dump.patch b/0047-app-procinfo-add-device-private-info-dump.patch new file mode 100644 index 0000000..7df98b8 --- /dev/null +++ b/0047-app-procinfo-add-device-private-info-dump.patch @@ -0,0 +1,90 @@ +From a91c0f253dd9b31cbe30bf5470a818aa0a909e26 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Sat, 19 Feb 2022 09:37:46 +0800 +Subject: [PATCH 02/13] app/procinfo: add device private info dump + +This patch adds support for dump the device private info from a running +application. It can help developers locate the problem. + +Signed-off-by: Min Hu (Connor) +--- + app/proc-info/main.c | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index ce140aaf84..fbc1715ce9 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -84,6 +84,8 @@ static char bdr_str[MAX_STRING_LEN]; + + /**< Enable show port. */ + static uint32_t enable_shw_port; ++/**< Enable show port private info. */ ++static uint32_t enable_shw_port_priv; + /**< Enable show tm. */ + static uint32_t enable_shw_tm; + /**< Enable show crypto. */ +@@ -123,6 +125,7 @@ proc_info_usage(const char *prgname) + " --collectd-format: to print statistics to STDOUT in expected by collectd format\n" + " --host-id STRING: host id used to identify the system process is running on\n" + " --show-port: to display ports information\n" ++ " --show-port-private: to display ports private information\n" + " --show-tm: to display traffic manager information for ports\n" + " --show-crypto: to display crypto information\n" + " --show-ring[=name]: to display ring information\n" +@@ -232,6 +235,7 @@ proc_info_parse_args(int argc, char **argv) + {"xstats-ids", 1, NULL, 1}, + {"host-id", 0, NULL, 0}, + {"show-port", 0, NULL, 0}, ++ {"show-port-private", 0, NULL, 0}, + {"show-tm", 0, NULL, 0}, + {"show-crypto", 0, NULL, 0}, + {"show-ring", optional_argument, NULL, 0}, +@@ -284,6 +288,9 @@ proc_info_parse_args(int argc, char **argv) + else if (!strncmp(long_option[option_index].name, + "show-port", MAX_LONG_OPT_SZ)) + enable_shw_port = 1; ++ else if (!strncmp(long_option[option_index].name, ++ "show-port-private", MAX_LONG_OPT_SZ)) ++ enable_shw_port_priv = 1; + else if (!strncmp(long_option[option_index].name, + "show-tm", MAX_LONG_OPT_SZ)) + enable_shw_tm = 1; +@@ -887,6 +894,25 @@ show_port(void) + } + } + ++static void ++show_port_private_info(void) ++{ ++ int i; ++ ++ snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD Private "); ++ STATS_BDR_STR(10, bdr_str); ++ ++ RTE_ETH_FOREACH_DEV(i) { ++ /* Skip if port is not in mask */ ++ if ((enabled_port_mask & (1ul << i)) == 0) ++ continue; ++ ++ snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i); ++ STATS_BDR_STR(5, bdr_str); ++ rte_eth_dev_priv_dump(i, stdout); ++ } ++} ++ + static void + display_nodecap_info(int is_leaf, struct rte_tm_node_capabilities *cap) + { +@@ -1549,6 +1575,8 @@ main(int argc, char **argv) + /* show information for PMD */ + if (enable_shw_port) + show_port(); ++ if (enable_shw_port_priv) ++ show_port_private_info(); + if (enable_shw_tm) + show_tm(); + if (enable_shw_crypto) +-- +2.30.0 + diff --git a/0048-net-hns3-dump-device-basic-info.patch b/0048-net-hns3-dump-device-basic-info.patch new file mode 100644 index 0000000..bad71a6 --- /dev/null +++ b/0048-net-hns3-dump-device-basic-info.patch @@ -0,0 +1,174 @@ +From c79d78f63ba993a7fb45b7c842cfcfefb38ba5b6 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 10:42:46 +0800 +Subject: [PATCH 03/13] net/hns3: dump device basic info + +This patch dumps device basic info such as device name, adapter state +for debug. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 1 + + drivers/net/hns3/hns3_ethdev.h | 1 + + drivers/net/hns3/hns3_ethdev_dump.c | 99 +++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_ethdev_vf.c | 1 + + drivers/net/hns3/meson.build | 1 + + 5 files changed, 103 insertions(+) + create mode 100644 drivers/net/hns3/hns3_ethdev_dump.c + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 13ebcde002..a9394eeeff 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -6568,6 +6568,7 @@ static const struct eth_dev_ops hns3_eth_dev_ops = { + .timesync_adjust_time = hns3_timesync_adjust_time, + .timesync_read_time = hns3_timesync_read_time, + .timesync_write_time = hns3_timesync_write_time, ++ .eth_dev_priv_dump = hns3_eth_dev_priv_dump, + }; + + static const struct hns3_reset_ops hns3_reset_ops = { +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index d62884cd9b..412626c053 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -1055,6 +1055,7 @@ int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts); + int hns3_timesync_write_time(struct rte_eth_dev *dev, + const struct timespec *ts); + int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta); ++int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file); + + static inline bool + is_reset_pending(struct hns3_adapter *hns) +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c +new file mode 100644 +index 0000000000..bd95184b02 +--- /dev/null ++++ b/drivers/net/hns3/hns3_ethdev_dump.c +@@ -0,0 +1,99 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(C) 2022 HiSilicon Limited ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#include "hns3_common.h" ++#include "hns3_logs.h" ++#include "hns3_regs.h" ++#include "hns3_rxtx.h" ++ ++static const char * ++hns3_get_adapter_state_name(uint32_t state) ++{ ++ static const char * const state_name[] = { ++ "UNINITIALIZED", ++ "INITIALIZED", ++ "CONFIGURING", ++ "CONFIGURED", ++ "STARTING", ++ "STARTED", ++ "STOPPING", ++ "CLOSING", ++ "CLOSED", ++ "REMOVED", ++ "NSTATES" ++ }; ++ ++ if (state < RTE_DIM(state_name)) ++ return state_name[state]; ++ else ++ return "unknown"; ++} ++ ++static const char * ++hns3_get_io_func_hint_name(uint32_t hint) ++{ ++ switch (hint) { ++ case HNS3_IO_FUNC_HINT_NONE: ++ return "none"; ++ case HNS3_IO_FUNC_HINT_VEC: ++ return "vec"; ++ case HNS3_IO_FUNC_HINT_SVE: ++ return "sve"; ++ case HNS3_IO_FUNC_HINT_SIMPLE: ++ return "simple"; ++ case HNS3_IO_FUNC_HINT_COMMON: ++ return "common"; ++ default: ++ return "unknown"; ++ } ++} ++ ++static void ++hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev) ++{ ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = &hns->hw; ++ ++ fprintf(file, ++ " - Device Base Info:\n" ++ "\t -- name: %s\n" ++ "\t -- adapter_state=%s\n" ++ "\t -- nb_rx_queues=%u nb_tx_queues=%u\n" ++ "\t -- total_tqps_num=%u tqps_num=%u intr_tqps_num=%u\n" ++ "\t -- rss_size_max=%u alloc_rss_size=%u tx_qnum_per_tc=%u\n" ++ "\t -- min_tx_pkt_len=%u intr_mapping_mode=%u vlan_mode=%u\n" ++ "\t -- tso_mode=%u max_non_tso_bd_num=%u\n" ++ "\t -- max_tm_rate=%u Mbps\n" ++ "\t -- set link down: %s\n" ++ "\t -- rx_func_hint=%s tx_func_hint=%s\n" ++ "\t -- dev_flags: lsc=%d\n" ++ "\t -- intr_conf: lsc=%u rxq=%u\n", ++ dev->data->name, ++ hns3_get_adapter_state_name(hw->adapter_state), ++ dev->data->nb_rx_queues, dev->data->nb_tx_queues, ++ hw->total_tqps_num, hw->tqps_num, hw->intr_tqps_num, ++ hw->rss_size_max, hw->alloc_rss_size, hw->tx_qnum_per_tc, ++ hw->min_tx_pkt_len, hw->intr.mapping_mode, hw->vlan_mode, ++ hw->tso_mode, hw->max_non_tso_bd_num, ++ hw->max_tm_rate, ++ hw->set_link_down ? "Yes" : "No", ++ hns3_get_io_func_hint_name(hns->rx_func_hint), ++ hns3_get_io_func_hint_name(hns->tx_func_hint), ++ !!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC), ++ dev->data->dev_conf.intr_conf.lsc, ++ dev->data->dev_conf.intr_conf.rxq); ++} ++ ++int ++hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) ++{ ++ hns3_get_device_basic_info(file, dev); ++ ++ return 0; ++} +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 5f905c515c..aee0c36360 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -2290,6 +2290,7 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = { + .get_reg = hns3_get_regs, + .dev_supported_ptypes_get = hns3_dev_supported_ptypes_get, + .tx_done_cleanup = hns3_tx_done_cleanup, ++ .eth_dev_priv_dump = hns3_eth_dev_priv_dump, + }; + + static const struct hns3_reset_ops hns3vf_reset_ops = { +diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build +index 8a4c7cc100..665b2afedf 100644 +--- a/drivers/net/hns3/meson.build ++++ b/drivers/net/hns3/meson.build +@@ -30,6 +30,7 @@ sources = files( + 'hns3_tm.c', + 'hns3_ptp.c', + 'hns3_common.c', ++ 'hns3_ethdev_dump.c', + ) + + deps += ['hash'] +-- +2.30.0 + diff --git a/0049-net-hns3-dump-device-feature-capability.patch b/0049-net-hns3-dump-device-feature-capability.patch new file mode 100644 index 0000000..60a66c1 --- /dev/null +++ b/0049-net-hns3-dump-device-feature-capability.patch @@ -0,0 +1,63 @@ +From 9bbea26d3c903f5741447a1b1a943d02b275af56 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 10:52:06 +0800 +Subject: [PATCH 04/13] net/hns3: dump device feature capability + +Kunpeng 920 and Kunpeng 930 support different feature capability. +This patch dumps feature capability Current device supports. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev_dump.c | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c +index bd95184b02..a0fa0a3584 100644 +--- a/drivers/net/hns3/hns3_ethdev_dump.c ++++ b/drivers/net/hns3/hns3_ethdev_dump.c +@@ -55,6 +55,30 @@ hns3_get_io_func_hint_name(uint32_t hint) + } + + static void ++hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) ++{ ++ const char * const caps_name[] = { ++ "DCB", ++ "COPPER", ++ "FD QUEUE REGION", ++ "PTP", ++ "TX PUSH", ++ "INDEP TXRX", ++ "STASH", ++ "SIMPLE BD", ++ "RXD Advanced Layout", ++ "OUTER UDP CKSUM", ++ "RAS IMP", ++ "TM", ++ }; ++ uint32_t i; ++ ++ fprintf(file, " - Dev Capability:\n"); ++ for (i = 0; i < RTE_DIM(caps_name); i++) ++ fprintf(file, "\t -- support %s: %s\n", caps_name[i], ++ hw->capability & BIT(i) ? "yes" : "no"); ++} ++ + hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev) + { + struct hns3_adapter *hns = dev->data->dev_private; +@@ -93,7 +117,11 @@ hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev) + int + hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + { ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = &hns->hw; ++ + hns3_get_device_basic_info(file, dev); ++ hns3_get_dev_feature_capability(file, hw); + + return 0; + } +-- +2.30.0 + diff --git a/0050-net-hns3-dump-device-MAC-info.patch b/0050-net-hns3-dump-device-MAC-info.patch new file mode 100644 index 0000000..e644a1c --- /dev/null +++ b/0050-net-hns3-dump-device-MAC-info.patch @@ -0,0 +1,63 @@ +From 7041258cda77065d991d6ee8913edf110bd12531 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 10:56:54 +0800 +Subject: [PATCH 05/13] net/hns3: dump device MAC info + +This patch dumps device MAC info which hns3 PMD private info offers. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev_dump.c | 31 +++++++++++++++++++++++++++++ + 1 file changed, 31 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c +index a0fa0a3584..83601d9bda 100644 +--- a/drivers/net/hns3/hns3_ethdev_dump.c ++++ b/drivers/net/hns3/hns3_ethdev_dump.c +@@ -54,6 +54,28 @@ hns3_get_io_func_hint_name(uint32_t hint) + } + } + ++static void ++hns3_get_dev_mac_info(FILE *file, struct hns3_adapter *hns) ++{ ++ struct hns3_hw *hw = &hns->hw; ++ struct hns3_pf *pf = &hns->pf; ++ ++ fprintf(file, " - MAC Info:\n"); ++ fprintf(file, ++ "\t -- query_type=%u\n" ++ "\t -- supported_speed=0x%x\n" ++ "\t -- advertising=0x%x\n" ++ "\t -- lp_advertising=0x%x\n" ++ "\t -- support_autoneg=%s\n" ++ "\t -- support_fc_autoneg=%s\n", ++ hw->mac.query_type, ++ hw->mac.supported_speed, ++ hw->mac.advertising, ++ hw->mac.lp_advertising, ++ hw->mac.support_autoneg != 0 ? "Yes" : "No", ++ pf->support_fc_autoneg ? "Yes" : "No"); ++} ++ + static void + hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) + { +@@ -123,5 +145,14 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + hns3_get_device_basic_info(file, dev); + hns3_get_dev_feature_capability(file, hw); + ++ /* ++ * VF only supports dumping basic info, feaure capability and queue ++ * info. ++ */ ++ if (hns->is_vf) ++ return 0; ++ ++ hns3_get_dev_mac_info(file, hns); ++ + return 0; + } +-- +2.30.0 + diff --git a/0051-net-hns3-dump-queue-info.patch b/0051-net-hns3-dump-queue-info.patch new file mode 100644 index 0000000..58bcfb5 --- /dev/null +++ b/0051-net-hns3-dump-queue-info.patch @@ -0,0 +1,254 @@ +From 698e42cb7ca963e34b2f8c7e1f9be98a7793bed3 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 11:03:05 +0800 +Subject: [PATCH 06/13] net/hns3: dump queue info + +This patch dumps Rx/Tx queue info, such as queue numbers, queue enable +state for debug. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev_dump.c | 220 ++++++++++++++++++++++++++++ + 1 file changed, 220 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c +index 83601d9bda..face41e4a7 100644 +--- a/drivers/net/hns3/hns3_ethdev_dump.c ++++ b/drivers/net/hns3/hns3_ethdev_dump.c +@@ -136,6 +136,225 @@ hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev) + dev->data->dev_conf.intr_conf.rxq); + } + ++/* ++ * Note: caller must make sure queue_id < nb_queues ++ * nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues, ++ * eth_dev->data->nb_tx_queues) ++ */ ++static struct hns3_rx_queue * ++hns3_get_rx_queue(struct rte_eth_dev *dev, uint32_t queue_id) ++{ ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = &hns->hw; ++ uint32_t offset; ++ void **rx_queues; ++ ++ if (queue_id < dev->data->nb_rx_queues) { ++ rx_queues = dev->data->rx_queues; ++ offset = queue_id; ++ } else { ++ /* ++ * For kunpeng930, fake queue is not exist. But since the queues ++ * are usually accessd in pairs, this branch may still exist. ++ */ ++ if (hns3_dev_get_support(hw, INDEP_TXRX)) ++ return NULL; ++ ++ rx_queues = hw->fkq_data.rx_queues; ++ offset = queue_id - dev->data->nb_rx_queues; ++ } ++ ++ if (rx_queues != NULL && rx_queues[offset] != NULL) ++ return rx_queues[offset]; ++ ++ hns3_err(hw, "Detect rx_queues is NULL!\n"); ++ return NULL; ++} ++ ++/* ++ * Note: caller must make sure queue_id < nb_queues ++ * nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues, ++ * eth_dev->data->nb_tx_queues) ++ */ ++static struct hns3_tx_queue * ++hns3_get_tx_queue(struct rte_eth_dev *dev, uint32_t queue_id) ++{ ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = &hns->hw; ++ uint32_t offset; ++ void **tx_queues; ++ ++ if (queue_id < dev->data->nb_tx_queues) { ++ tx_queues = dev->data->tx_queues; ++ offset = queue_id; ++ } else { ++ /* ++ * For kunpeng930, fake queue is not exist. But since the queues ++ * are usually accessd in pairs, this branch may still exist. ++ */ ++ if (hns3_dev_get_support(hw, INDEP_TXRX)) ++ return NULL; ++ tx_queues = hw->fkq_data.tx_queues; ++ offset = queue_id - dev->data->nb_tx_queues; ++ } ++ ++ if (tx_queues != NULL && tx_queues[offset] != NULL) ++ return tx_queues[offset]; ++ ++ hns3_err(hw, "Detect tx_queues is NULL!\n"); ++ return NULL; ++} ++ ++static void ++hns3_get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev) ++{ ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); ++ struct hns3_rx_queue *rxq; ++ struct hns3_tx_queue *txq; ++ uint32_t queue_id; ++ ++ if (dev->data->nb_rx_queues != dev->data->nb_tx_queues && ++ !hns3_dev_get_support(hw, INDEP_TXRX)) { ++ queue_id = RTE_MIN(dev->data->nb_rx_queues, ++ dev->data->nb_tx_queues); ++ rxq = hns3_get_rx_queue(dev, queue_id); ++ if (rxq == NULL) ++ return; ++ txq = hns3_get_tx_queue(dev, queue_id); ++ if (txq == NULL) ++ return; ++ fprintf(file, ++ "\t -- first fake_queue rxtx info:\n" ++ "\t Rx: port=%u nb_desc=%u free_thresh=%u\n" ++ "\t Tx: port=%u nb_desc=%u\n", ++ rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh, ++ txq->port_id, txq->nb_tx_desc); ++ } ++} ++ ++static void ++hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state, ++ uint32_t nb_queues, bool is_rxq) ++{ ++#define STATE_SIZE (sizeof(*queue_state) * CHAR_BIT) ++ uint32_t queue_en_reg; ++ uint32_t reg_offset; ++ uint32_t state; ++ uint32_t i; ++ ++ queue_en_reg = is_rxq ? HNS3_RING_RX_EN_REG : HNS3_RING_TX_EN_REG; ++ for (i = 0; i < nb_queues; i++) { ++ reg_offset = hns3_get_tqp_reg_offset(i); ++ state = hns3_read_dev(hw, reg_offset + HNS3_RING_EN_REG); ++ if (hns3_dev_get_support(hw, INDEP_TXRX)) ++ state = state && hns3_read_dev(hw, reg_offset + ++ queue_en_reg); ++ hns3_set_bit(queue_state[i / STATE_SIZE], ++ i % STATE_SIZE, state); ++ } ++} ++ ++static void ++hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state, ++ uint32_t nb_queues, uint32_t line_num) ++{ ++#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT) ++ uint32_t qid = line_num * NUM_QUEUE_PER_LINE; ++ uint32_t j; ++ ++ for (j = 0; j < NUM_QUEUE_PER_LINE; j++) { ++ fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], j)); ++ ++ if (qid % CHAR_BIT == CHAR_BIT - 1) { ++ fprintf(file, "%s", ++ j == NUM_QUEUE_PER_LINE - 1 ? "\n" : ":"); ++ } ++ qid++; ++ if (qid >= nb_queues) { ++ fprintf(file, "\n"); ++ break; ++ } ++ } ++} ++ ++static void ++hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state, ++ uint32_t nb_queues, bool is_rxq) ++{ ++#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT) ++ uint32_t i; ++ ++ if (nb_queues == 0) { ++ fprintf(file, "\t %s queue number is 0\n", ++ is_rxq ? "Rx" : "Tx"); ++ return; ++ } ++ ++ fprintf(file, "\t %s queue id | enable state bitMap\n", ++ is_rxq ? "Rx" : "Tx"); ++ ++ for (i = 0; i < (nb_queues - 1) / NUM_QUEUE_PER_LINE + 1; i++) { ++ uint32_t line_end = (i + 1) * NUM_QUEUE_PER_LINE - 1; ++ uint32_t line_start = i * NUM_QUEUE_PER_LINE; ++ fprintf(file, "\t %04u - %04u | ", line_start, ++ nb_queues - 1 > line_end ? line_end : nb_queues - 1); ++ ++ hns3_print_queue_state_perline(file, queue_state, nb_queues, i); ++ } ++} ++ ++static void ++hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev) ++{ ++#define MAX_TQP_NUM 1280 ++#define QUEUE_BITMAP_SIZE (MAX_TQP_NUM / 32) ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ uint32_t rx_queue_state[QUEUE_BITMAP_SIZE] = {0}; ++ uint32_t tx_queue_state[QUEUE_BITMAP_SIZE] = {0}; ++ uint32_t nb_rx_queues; ++ uint32_t nb_tx_queues; ++ ++ nb_rx_queues = dev->data->nb_rx_queues; ++ nb_tx_queues = dev->data->nb_tx_queues; ++ ++ fprintf(file, "\t -- enable state:\n"); ++ hns3_get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true); ++ hns3_display_queue_enable_state(file, rx_queue_state, nb_rx_queues, ++ true); ++ ++ hns3_get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false); ++ hns3_display_queue_enable_state(file, tx_queue_state, nb_tx_queues, ++ false); ++} ++ ++static void ++hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev) ++{ ++ struct hns3_rx_queue *rxq; ++ struct hns3_tx_queue *txq; ++ uint32_t queue_id = 0; ++ ++ rxq = hns3_get_rx_queue(dev, queue_id); ++ if (rxq == NULL) ++ return; ++ txq = hns3_get_tx_queue(dev, queue_id); ++ if (txq == NULL) ++ return; ++ fprintf(file, " - Rx/Tx Queue Info:\n"); ++ fprintf(file, ++ "\t -- first queue rxtx info:\n" ++ "\t Rx: port=%u nb_desc=%u free_thresh=%u\n" ++ "\t Tx: port=%u nb_desc=%u\n" ++ "\t -- tx push: %s\n", ++ rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh, ++ txq->port_id, txq->nb_tx_desc, ++ txq->tx_push_enable ? "enabled" : "disabled"); ++ ++ hns3_get_rxtx_fake_queue_info(file, dev); ++ hns3_get_rxtx_queue_enable_state(file, dev); ++} ++ + int + hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + { +@@ -144,6 +363,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + + hns3_get_device_basic_info(file, dev); + hns3_get_dev_feature_capability(file, hw); ++ hns3_get_rxtx_queue_info(file, dev); + + /* + * VF only supports dumping basic info, feaure capability and queue +-- +2.30.0 + diff --git a/0052-net-hns3-dump-VLAN-configuration-info.patch b/0052-net-hns3-dump-VLAN-configuration-info.patch new file mode 100644 index 0000000..03f3bf8 --- /dev/null +++ b/0052-net-hns3-dump-VLAN-configuration-info.patch @@ -0,0 +1,180 @@ +From 05e415e929a404187f6b595a0b0f1ea958c1ca12 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 11:06:55 +0800 +Subject: [PATCH 07/13] net/hns3: dump VLAN configuration info + +This patch dump VLAN filter, strip related info and Pvid info for debug. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev_dump.c | 147 ++++++++++++++++++++++++++++ + 1 file changed, 147 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c +index face41e4a7..d017e66e69 100644 +--- a/drivers/net/hns3/hns3_ethdev_dump.c ++++ b/drivers/net/hns3/hns3_ethdev_dump.c +@@ -355,6 +355,152 @@ hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev) + hns3_get_rxtx_queue_enable_state(file, dev); + } + ++static int ++hns3_get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw) ++{ ++ struct hns3_vport_vtag_rx_cfg_cmd *req; ++ struct hns3_cmd_desc desc; ++ uint16_t vport_id; ++ uint8_t bitmap; ++ int ret; ++ ++ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_RX_CFG, true); ++ req = (struct hns3_vport_vtag_rx_cfg_cmd *)desc.data; ++ vport_id = HNS3_PF_FUNC_ID; ++ req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD; ++ bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE); ++ req->vf_bitmap[req->vf_offset] = bitmap; ++ ++ /* ++ * current version VF is not supported when PF is driven by DPDK driver, ++ * just need to configure rx parameters for PF vport. ++ */ ++ ret = hns3_cmd_send(hw, &desc, 1); ++ if (ret != 0) { ++ hns3_err(hw, ++ "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!", ++ ret, 1, rte_le_to_cpu_16(desc.opcode)); ++ return ret; ++ } ++ ++ fprintf(file, ++ "\t -- RX VLAN configuration\n" ++ "\t vlan1_strip_en :%s\n" ++ "\t vlan2_strip_en :%s\n" ++ "\t vlan1_vlan_prionly :%s\n" ++ "\t vlan2_vlan_prionly :%s\n" ++ "\t vlan1_strip_discard :%s\n" ++ "\t vlan2_strip_discard :%s\n", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_REM_TAG1_EN_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_REM_TAG2_EN_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_SHOW_TAG1_EN_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_SHOW_TAG2_EN_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_DISCARD_TAG1_EN_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_DISCARD_TAG2_EN_B) ? "Enable" : "Disable"); ++ ++ return 0; ++} ++ ++static void ++hns3_parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req) ++{ ++#define VLAN_VID_MASK 0x0fff ++#define VLAN_PRIO_SHIFT 13 ++ ++ fprintf(file, ++ "\t -- TX VLAN configuration\n" ++ "\t accept_tag1 :%s\n" ++ "\t accept_untag1 :%s\n" ++ "\t insert_tag1_en :%s\n" ++ "\t default_vlan_tag1 = %d, qos = %d\n" ++ "\t accept_tag2 :%s\n" ++ "\t accept_untag2 :%s\n" ++ "\t insert_tag2_en :%s\n" ++ "\t default_vlan_tag2 = %d, qos = %d\n" ++ "\t vlan_shift_mode :%s\n", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_ACCEPT_TAG1_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_ACCEPT_UNTAG1_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_PORT_INS_TAG1_EN_B) ? "Enable" : "Disable", ++ req->def_vlan_tag1 & VLAN_VID_MASK, ++ req->def_vlan_tag1 >> VLAN_PRIO_SHIFT, ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_ACCEPT_TAG2_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_ACCEPT_UNTAG2_B) ? "Enable" : "Disable", ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_PORT_INS_TAG2_EN_B) ? "Enable" : "Disable", ++ req->def_vlan_tag2 & VLAN_VID_MASK, ++ req->def_vlan_tag2 >> VLAN_PRIO_SHIFT, ++ hns3_get_bit(req->vport_vlan_cfg, ++ HNS3_TAG_SHIFT_MODE_EN_B) ? "Enable" : ++ "Disable"); ++} ++ ++static int ++hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw) ++{ ++ struct hns3_vport_vtag_tx_cfg_cmd *req; ++ struct hns3_cmd_desc desc; ++ uint16_t vport_id; ++ uint8_t bitmap; ++ int ret; ++ ++ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_TX_CFG, true); ++ req = (struct hns3_vport_vtag_tx_cfg_cmd *)desc.data; ++ vport_id = HNS3_PF_FUNC_ID; ++ req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD; ++ bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE); ++ req->vf_bitmap[req->vf_offset] = bitmap; ++ /* ++ * current version VF is not supported when PF is driven by DPDK driver, ++ * just need to configure tx parameters for PF vport. ++ */ ++ ret = hns3_cmd_send(hw, &desc, 1); ++ if (ret != 0) { ++ hns3_err(hw, ++ "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!", ++ ret, 1, rte_le_to_cpu_16(desc.opcode)); ++ return ret; ++ } ++ ++ hns3_parse_tx_vlan_cfg(file, req); ++ ++ return 0; ++} ++ ++static void ++hns3_get_port_pvid_info(FILE *file, struct hns3_hw *hw) ++{ ++ fprintf(file, "\t -- pvid status: %s\n", ++ hw->port_base_vlan_cfg.state ? "on" : "off"); ++} ++ ++static void ++hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw) ++{ ++ int ret; ++ ++ fprintf(file, " - VLAN Config Info:\n"); ++ ret = hns3_get_vlan_rx_offload_cfg(file, hw); ++ if (ret < 0) ++ return; ++ ++ ret = hns3_get_vlan_tx_offload_cfg(file, hw); ++ if (ret < 0) ++ return; ++ ++ hns3_get_port_pvid_info(file, hw); ++} ++ + int + hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + { +@@ -373,6 +519,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + return 0; + + hns3_get_dev_mac_info(file, hns); ++ hns3_get_vlan_config_info(file, hw); + + return 0; + } +-- +2.30.0 + diff --git a/0053-net-hns3-dump-flow-director-basic-info.patch b/0053-net-hns3-dump-flow-director-basic-info.patch new file mode 100644 index 0000000..186d8fb --- /dev/null +++ b/0053-net-hns3-dump-flow-director-basic-info.patch @@ -0,0 +1,119 @@ +From ca1080fde102a1b9de5781e0919a5342b6151bd3 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 11:10:28 +0800 +Subject: [PATCH 08/13] net/hns3: dump flow director basic info + +This patch dumps flow director basic info such rule numbers, hit counts +for debug. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev_dump.c | 85 +++++++++++++++++++++++++++++ + 1 file changed, 85 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c +index d017e66e69..792ef99b81 100644 +--- a/drivers/net/hns3/hns3_ethdev_dump.c ++++ b/drivers/net/hns3/hns3_ethdev_dump.c +@@ -101,6 +101,90 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) + hw->capability & BIT(i) ? "yes" : "no"); + } + ++static const char * ++hns3_get_fdir_tuple_name(uint32_t index) ++{ ++ static const char * const tuple_name[] = { ++ "outer_dst_mac", ++ "outer_src_mac", ++ "outer_vlan_1st_tag", ++ "outer_vlan_2nd_tag", ++ "outer_eth_type", ++ "outer_l2_rsv", ++ "outer_ip_tos", ++ "outer_ip_proto", ++ "outer_src_ip", ++ "outer_dst_ip", ++ "outer_l3_rsv", ++ "outer_src_port", ++ "outer_dst_port", ++ "outer_l4_rsv", ++ "outer_tun_vni", ++ "outer_tun_flow_id", ++ "inner_dst_mac", ++ "inner_src_mac", ++ "inner_vlan_tag1", ++ "inner_vlan_tag2", ++ "inner_eth_type", ++ "inner_l2_rsv", ++ "inner_ip_tos", ++ "inner_ip_proto", ++ "inner_src_ip", ++ "inner_dst_ip", ++ "inner_l3_rsv", ++ "inner_src_port", ++ "inner_dst_port", ++ "inner_sctp_tag", ++ }; ++ if (index < RTE_DIM(tuple_name)) ++ return tuple_name[index]; ++ else ++ return "unknown"; ++} ++ ++static void ++hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf) ++{ ++#define TMPBUF_SIZE 2048 ++#define PERLINE_TUPLE_NAMES 4 ++ struct hns3_fd_cfg *fdcfg = &pf->fdir.fd_cfg; ++ char tmpbuf[TMPBUF_SIZE] = {0}; ++ uint32_t i, count = 0; ++ ++ fprintf(file, " - Fdir Info:\n"); ++ fprintf(file, ++ "\t -- mode=%u max_key_len=%u rule_num:%u cnt_num:%u\n" ++ "\t -- key_sel=%u tuple_active=0x%x meta_data_active=0x%x\n" ++ "\t -- ipv6_word_en: in_s=%u in_d=%u out_s=%u out_d=%u\n" ++ "\t -- active_tuples:\n", ++ fdcfg->fd_mode, fdcfg->max_key_length, ++ fdcfg->rule_num[HNS3_FD_STAGE_1], ++ fdcfg->cnt_num[HNS3_FD_STAGE_1], ++ fdcfg->key_cfg[HNS3_FD_STAGE_1].key_sel, ++ fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active, ++ fdcfg->key_cfg[HNS3_FD_STAGE_1].meta_data_active, ++ fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_sipv6_word_en, ++ fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_dipv6_word_en, ++ fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_sipv6_word_en, ++ fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_dipv6_word_en); ++ ++ for (i = 0; i < MAX_TUPLE; i++) { ++ if (!(fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active & BIT(i))) ++ continue; ++ if (count % PERLINE_TUPLE_NAMES == 0) ++ fprintf(file, "\t "); ++ fprintf(file, " %s", hns3_get_fdir_tuple_name(i)); ++ count++; ++ if (count % PERLINE_TUPLE_NAMES == 0) ++ fprintf(file, "\n"); ++ } ++ if (count % PERLINE_TUPLE_NAMES) ++ fprintf(file, "\n"); ++ ++ fprintf(file, "%s", tmpbuf); ++} ++ ++static void + hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev) + { + struct hns3_adapter *hns = dev->data->dev_private; +@@ -520,6 +604,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + + hns3_get_dev_mac_info(file, hns); + hns3_get_vlan_config_info(file, hw); ++ hns3_get_fdir_basic_info(file, &hns->pf); + + return 0; + } +-- +2.30.0 + diff --git a/0054-net-hns3-dump-TM-configuration-info.patch b/0054-net-hns3-dump-TM-configuration-info.patch new file mode 100644 index 0000000..9100422 --- /dev/null +++ b/0054-net-hns3-dump-TM-configuration-info.patch @@ -0,0 +1,188 @@ +From f612c76b724c499f870026ec3deda07f0de13543 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 11:22:23 +0800 +Subject: [PATCH 09/13] net/hns3: dump TM configuration info + +This patch dumps TM configuration info about shaper, port node, TC node, +queue node related info. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev_dump.c | 154 ++++++++++++++++++++++++++++ + 1 file changed, 154 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c +index 792ef99b81..c0fc55b290 100644 +--- a/drivers/net/hns3/hns3_ethdev_dump.c ++++ b/drivers/net/hns3/hns3_ethdev_dump.c +@@ -585,6 +585,159 @@ hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw) + hns3_get_port_pvid_info(file, hw); + } + ++static void ++hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf) ++{ ++ struct hns3_shaper_profile_list *shaper_profile_list = ++ &conf->shaper_profile_list; ++ struct hns3_tm_shaper_profile *shaper_profile; ++ ++ if (!conf->nb_shaper_profile) ++ return; ++ ++ fprintf(file, " shaper_profile:\n"); ++ TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) { ++ fprintf(file, ++ " id=%u reference_count=%u peak_rate=%" PRIu64 "Bps\n", ++ shaper_profile->shaper_profile_id, ++ shaper_profile->reference_count, ++ shaper_profile->profile.peak.rate); ++ } ++} ++ ++static void ++hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf) ++{ ++ if (!conf->root) ++ return; ++ ++ fprintf(file, ++ " port_node: \n" ++ " node_id=%u reference_count=%u shaper_profile_id=%d\n", ++ conf->root->id, conf->root->reference_count, ++ conf->root->shaper_profile ? ++ (int)conf->root->shaper_profile->shaper_profile_id : -1); ++} ++ ++static void ++hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf) ++{ ++ struct hns3_tm_node_list *tc_list = &conf->tc_list; ++ struct hns3_tm_node *tc_node[HNS3_MAX_TC_NUM]; ++ struct hns3_tm_node *tm_node; ++ uint32_t tidx; ++ ++ if (!conf->nb_tc_node) ++ return; ++ ++ fprintf(file, " tc_node: \n"); ++ memset(tc_node, 0, sizeof(tc_node)); ++ TAILQ_FOREACH(tm_node, tc_list, node) { ++ tidx = hns3_tm_calc_node_tc_no(conf, tm_node->id); ++ if (tidx < HNS3_MAX_TC_NUM) ++ tc_node[tidx] = tm_node; ++ } ++ ++ for (tidx = 0; tidx < HNS3_MAX_TC_NUM; tidx++) { ++ tm_node = tc_node[tidx]; ++ if (tm_node == NULL) ++ continue; ++ fprintf(file, ++ " id=%u TC%u reference_count=%u parent_id=%d " ++ "shaper_profile_id=%d\n", ++ tm_node->id, hns3_tm_calc_node_tc_no(conf, tm_node->id), ++ tm_node->reference_count, ++ tm_node->parent ? (int)tm_node->parent->id : -1, ++ tm_node->shaper_profile ? ++ (int)tm_node->shaper_profile->shaper_profile_id : -1); ++ } ++} ++ ++static void ++hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node, ++ uint32_t *queue_node_tc, ++ uint32_t nb_tx_queues) ++{ ++#define PERLINE_QUEUES 32 ++#define PERLINE_STRIDE 8 ++#define LINE_BUF_SIZE 1024 ++ uint32_t i, j, line_num, start_queue, end_queue; ++ char tmpbuf[LINE_BUF_SIZE] = {0}; ++ ++ line_num = (nb_tx_queues + PERLINE_QUEUES - 1) / PERLINE_QUEUES; ++ for (i = 0; i < line_num; i++) { ++ start_queue = i * PERLINE_QUEUES; ++ end_queue = (i + 1) * PERLINE_QUEUES - 1; ++ if (end_queue > nb_tx_queues - 1) ++ end_queue = nb_tx_queues - 1; ++ fprintf(file, " %04u - %04u | ", start_queue, end_queue); ++ for (j = start_queue; j < nb_tx_queues; j++) { ++ if (j >= end_queue + 1) ++ break; ++ if (j > start_queue && j % PERLINE_STRIDE == 0) ++ fprintf(file, ":"); ++ fprintf(file, "%u", ++ queue_node[j] ? queue_node_tc[j] : ++ HNS3_MAX_TC_NUM); ++ } ++ fprintf(file, "%s\n", tmpbuf); ++ } ++} ++ ++static void ++hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, ++ uint32_t nb_tx_queues) ++{ ++ struct hns3_tm_node_list *queue_list = &conf->queue_list; ++ uint32_t nb_queue_node = conf->nb_leaf_nodes_max + 1; ++ struct hns3_tm_node *queue_node[nb_queue_node]; ++ uint32_t queue_node_tc[nb_queue_node]; ++ struct hns3_tm_node *tm_node; ++ ++ if (!conf->nb_queue_node) ++ return; ++ ++ fprintf(file, ++ " queue_node: \n" ++ " tx queue id | mapped tc (8 mean node not exist)\n"); ++ ++ memset(queue_node, 0, sizeof(queue_node)); ++ memset(queue_node_tc, 0, sizeof(queue_node_tc)); ++ nb_tx_queues = RTE_MIN(nb_tx_queues, nb_queue_node); ++ TAILQ_FOREACH(tm_node, queue_list, node) { ++ if (tm_node->id >= nb_queue_node) ++ continue; ++ queue_node[tm_node->id] = tm_node; ++ queue_node_tc[tm_node->id] = tm_node->parent ? ++ hns3_tm_calc_node_tc_no(conf, tm_node->parent->id) : 0; ++ nb_tx_queues = RTE_MAX(nb_tx_queues, tm_node->id + 1); ++ } ++ ++ hns3_get_tm_conf_queue_format_info(file, queue_node, queue_node_tc, ++ nb_tx_queues); ++} ++ ++static void ++hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev) ++{ ++ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); ++ struct hns3_tm_conf *conf = &pf->tm_conf; ++ ++ fprintf(file, " - TM config info:\n"); ++ fprintf(file, ++ "\t -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n" ++ "\t -- nb_shaper_profile=%u nb_tc_node=%u nb_queue_node=%u\n" ++ "\t -- committed=%u\n", ++ conf->nb_leaf_nodes_max, conf->nb_nodes_max, ++ conf->nb_shaper_profile, conf->nb_tc_node, conf->nb_queue_node, ++ conf->committed); ++ ++ hns3_get_tm_conf_shaper_info(file, conf); ++ hns3_get_tm_conf_port_node_info(file, conf); ++ hns3_get_tm_conf_tc_node_info(file, conf); ++ hns3_get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues); ++} ++ + int + hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + { +@@ -605,6 +758,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + hns3_get_dev_mac_info(file, hns); + hns3_get_vlan_config_info(file, hw); + hns3_get_fdir_basic_info(file, &hns->pf); ++ hns3_get_tm_conf_info(file, dev); + + return 0; + } +-- +2.30.0 + diff --git a/0055-net-hns3-dump-flow-control-info.patch b/0055-net-hns3-dump-flow-control-info.patch new file mode 100644 index 0000000..0d67770 --- /dev/null +++ b/0055-net-hns3-dump-flow-control-info.patch @@ -0,0 +1,165 @@ +From e5e64a038775d3c7bd8f412fe9d814c8dfe795eb Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 11 Feb 2022 11:27:04 +0800 +Subject: [PATCH 10/13] net/hns3: dump flow control info + +This patch dumps flow control info such as flow control mode +for debug. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 2 +- + drivers/net/hns3/hns3_ethdev.h | 2 + + drivers/net/hns3/hns3_ethdev_dump.c | 103 ++++++++++++++++++++++++++++ + 3 files changed, 106 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index a9394eeeff..cac6dd7755 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5350,7 +5350,7 @@ hns3_get_current_fc_mode(struct rte_eth_dev *dev) + return hns3_get_autoneg_fc_mode(hw); + } + +-static int ++int + hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 412626c053..fd83bb7109 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -1030,6 +1030,8 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr) + return __atomic_fetch_and(addr, ~mask, __ATOMIC_RELAXED) & mask; + } + ++int ++hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); + uint32_t hns3_get_speed_capa(struct hns3_hw *hw); + + int hns3_buffer_alloc(struct hns3_hw *hw); +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c +index c0fc55b290..d9c1879f74 100644 +--- a/drivers/net/hns3/hns3_ethdev_dump.c ++++ b/drivers/net/hns3/hns3_ethdev_dump.c +@@ -738,6 +738,108 @@ hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev) + hns3_get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues); + } + ++static void ++hns3_fc_mode_to_rxtx_pause(enum hns3_fc_mode fc_mode, bool *rx_pause, ++ bool *tx_pause) ++{ ++ switch (fc_mode) { ++ case HNS3_FC_NONE: ++ *tx_pause = false; ++ *rx_pause = false; ++ break; ++ case HNS3_FC_RX_PAUSE: ++ *rx_pause = true; ++ *tx_pause = false; ++ break; ++ case HNS3_FC_TX_PAUSE: ++ *rx_pause = false; ++ *tx_pause = true; ++ break; ++ case HNS3_FC_FULL: ++ *rx_pause = true; ++ *tx_pause = true; ++ break; ++ default: ++ *rx_pause = false; ++ *tx_pause = false; ++ break; ++ } ++} ++ ++static bool ++hns3_is_link_fc_mode(struct hns3_adapter *hns) ++{ ++ struct hns3_hw *hw = &hns->hw; ++ struct hns3_pf *pf = &hns->pf; ++ ++ if (hw->current_fc_status == HNS3_FC_STATUS_PFC) ++ return false; ++ ++ if (hw->num_tc > 1 && !pf->support_multi_tc_pause) ++ return false; ++ ++ return true; ++} ++ ++static void ++hns3_get_link_fc_info(FILE *file, struct rte_eth_dev *dev) ++{ ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = &hns->hw; ++ struct rte_eth_fc_conf cur_fc_conf; ++ bool rx_pause1; ++ bool tx_pause1; ++ bool rx_pause2; ++ bool tx_pause2; ++ int ret; ++ ++ if (!hns3_is_link_fc_mode(hns)) ++ return; ++ ++ ret = hns3_flow_ctrl_get(dev, &cur_fc_conf); ++ if (ret) { ++ fprintf(file, "get device flow control info fail!\n"); ++ return; ++ } ++ ++ hns3_fc_mode_to_rxtx_pause(hw->requested_fc_mode, ++ &rx_pause1, &tx_pause1); ++ hns3_fc_mode_to_rxtx_pause((enum hns3_fc_mode)cur_fc_conf.mode, ++ &rx_pause2, &tx_pause2); ++ ++ fprintf(file, ++ "\t -- link_fc_info:\n" ++ "\t Requested fc:\n" ++ "\t Rx: %s\n" ++ "\t Tx: %s\n" ++ "\t Current fc:\n" ++ "\t Rx: %s\n" ++ "\t Tx: %s\n" ++ "\t Autonegotiate: %s\n" ++ "\t Pause time: 0x%x\n", ++ rx_pause1 ? "On" : "Off", tx_pause1 ? "On" : "Off", ++ rx_pause2 ? "On" : "Off", tx_pause2 ? "On" : "Off", ++ cur_fc_conf.autoneg == RTE_ETH_LINK_AUTONEG ? "On" : "Off", ++ cur_fc_conf.pause_time); ++} ++ ++static void ++hns3_get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev) ++{ ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = &hns->hw; ++ ++ fprintf(file, " - Flow Ctrl Info:\n"); ++ fprintf(file, ++ "\t -- fc_common_info:\n" ++ "\t current_fc_status=%u\n" ++ "\t requested_fc_mode=%u\n", ++ hw->current_fc_status, ++ hw->requested_fc_mode); ++ ++ hns3_get_link_fc_info(file, dev); ++} ++ + int + hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + { +@@ -759,6 +861,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + hns3_get_vlan_config_info(file, hw); + hns3_get_fdir_basic_info(file, &hns->pf); + hns3_get_tm_conf_info(file, dev); ++ hns3_get_flow_ctrl_info(file, dev); + + return 0; + } +-- +2.30.0 + diff --git a/0056-net-hns3-change-dump-file-name.patch b/0056-net-hns3-change-dump-file-name.patch new file mode 100644 index 0000000..bfead0a --- /dev/null +++ b/0056-net-hns3-change-dump-file-name.patch @@ -0,0 +1,35 @@ +From 297a29aa8a27e93b2fa1fdc40a4964f0fbbaa4ec Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Thu, 31 Mar 2022 14:20:42 +0800 +Subject: [PATCH 11/13] net/hns3: change dump file name + +change dump file name 'hns3_ethdev_dump.c' to 'hns3_dump.c', as it +is more simple. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} | 0 + drivers/net/hns3/meson.build | 2 +- + 2 files changed, 1 insertion(+), 1 deletion(-) + rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (100%) + +diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_dump.c +similarity index 100% +rename from drivers/net/hns3/hns3_ethdev_dump.c +rename to drivers/net/hns3/hns3_dump.c +diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build +index 665b2afedf..9f30f6b7af 100644 +--- a/drivers/net/hns3/meson.build ++++ b/drivers/net/hns3/meson.build +@@ -30,7 +30,7 @@ sources = files( + 'hns3_tm.c', + 'hns3_ptp.c', + 'hns3_common.c', +- 'hns3_ethdev_dump.c', ++ 'hns3_dump.c', + ) + + deps += ['hash'] +-- +2.30.0 + diff --git a/0057-net-hns3-fix-code-check-for-dump.patch b/0057-net-hns3-fix-code-check-for-dump.patch new file mode 100644 index 0000000..cf4687d --- /dev/null +++ b/0057-net-hns3-fix-code-check-for-dump.patch @@ -0,0 +1,680 @@ +From d2c737bb909c52de76246d9c74944d96c5e7792f Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Thu, 31 Mar 2022 15:59:51 +0800 +Subject: [PATCH 12/13] net/hns3: fix code check for dump + +This patch fix code check for dump, making it more readable. + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_dump.c | 341 +++++++++++++++--------------- + drivers/net/hns3/hns3_dump.h | 10 + + drivers/net/hns3/hns3_ethdev.c | 1 + + drivers/net/hns3/hns3_ethdev.h | 3 +- + drivers/net/hns3/hns3_ethdev_vf.c | 1 + + 5 files changed, 187 insertions(+), 169 deletions(-) + create mode 100644 drivers/net/hns3/hns3_dump.h + +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index d9c1879f74..3a30a585c5 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -2,37 +2,41 @@ + * Copyright(C) 2022 HiSilicon Limited + */ + +-#include +-#include +-#include +-#include ++#include + ++#include "hns3_ethdev.h" + #include "hns3_common.h" +-#include "hns3_logs.h" +-#include "hns3_regs.h" + #include "hns3_rxtx.h" ++#include "hns3_regs.h" ++#include "hns3_logs.h" ++#include "hns3_dump.h" + + static const char * +-hns3_get_adapter_state_name(uint32_t state) ++hns3_get_adapter_state_name(enum hns3_adapter_state state) + { +- static const char * const state_name[] = { +- "UNINITIALIZED", +- "INITIALIZED", +- "CONFIGURING", +- "CONFIGURED", +- "STARTING", +- "STARTED", +- "STOPPING", +- "CLOSING", +- "CLOSED", +- "REMOVED", +- "NSTATES" ++ const struct { ++ enum hns3_adapter_state state; ++ const char *name; ++ } adapter_state_name[] = { ++ {HNS3_NIC_UNINITIALIZED, "UNINITIALIZED"}, ++ {HNS3_NIC_INITIALIZED, "INITIALIZED"}, ++ {HNS3_NIC_CONFIGURING, "CONFIGURING"}, ++ {HNS3_NIC_CONFIGURED, "CONFIGURED"}, ++ {HNS3_NIC_STARTING, "STARTING"}, ++ {HNS3_NIC_STARTED, "STARTED"}, ++ {HNS3_NIC_STOPPING, "STOPPING"}, ++ {HNS3_NIC_CLOSING, "CLOSING"}, ++ {HNS3_NIC_CLOSED, "CLOSED"}, ++ {HNS3_NIC_REMOVED, "REMOVED"}, ++ {HNS3_NIC_NSTATES, "NSTATES"}, + }; ++ uint32_t i; + +- if (state < RTE_DIM(state_name)) +- return state_name[state]; +- else +- return "unknown"; ++ for (i = 0; i < RTE_DIM(adapter_state_name); i++) ++ if (state == adapter_state_name[i].state) ++ return adapter_state_name[i].name; ++ ++ return "Unknown"; + } + + static const char * +@@ -79,32 +83,36 @@ hns3_get_dev_mac_info(FILE *file, struct hns3_adapter *hns) + static void + hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) + { +- const char * const caps_name[] = { +- "DCB", +- "COPPER", +- "FD QUEUE REGION", +- "PTP", +- "TX PUSH", +- "INDEP TXRX", +- "STASH", +- "SIMPLE BD", +- "RXD Advanced Layout", +- "OUTER UDP CKSUM", +- "RAS IMP", +- "TM", ++ const struct { ++ enum hns3_dev_cap cap; ++ const char *name; ++ } caps_name[] = { ++ {HNS3_DEV_SUPPORT_DCB_B, "DCB"}, ++ {HNS3_DEV_SUPPORT_COPPER_B, "COPPER"}, ++ {HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, "FD QUEUE REGION"}, ++ {HNS3_DEV_SUPPORT_PTP_B, "PTP"}, ++ {HNS3_DEV_SUPPORT_TX_PUSH_B, "TX PUSH"}, ++ {HNS3_DEV_SUPPORT_INDEP_TXRX_B, "INDEP TXRX"}, ++ {HNS3_DEV_SUPPORT_STASH_B, "STASH"}, ++ {HNS3_DEV_SUPPORT_SIMPLE_BD_B, "SIMPLE BD"}, ++ {HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, "RXD Advanced Layout"}, ++ {HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"}, ++ {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"}, ++ {HNS3_DEV_SUPPORT_TM_B, "TM"}, + }; + uint32_t i; + + fprintf(file, " - Dev Capability:\n"); + for (i = 0; i < RTE_DIM(caps_name); i++) +- fprintf(file, "\t -- support %s: %s\n", caps_name[i], +- hw->capability & BIT(i) ? "yes" : "no"); ++ fprintf(file, "\t -- support %s: %s\n", caps_name[i].name, ++ hns3_get_bit(hw->capability, caps_name[i].cap) ? "Yes" : ++ "No"); + } + + static const char * + hns3_get_fdir_tuple_name(uint32_t index) + { +- static const char * const tuple_name[] = { ++ const char * const tuple_name[] = { + "outer_dst_mac", + "outer_src_mac", + "outer_vlan_1st_tag", +@@ -145,10 +153,8 @@ hns3_get_fdir_tuple_name(uint32_t index) + static void + hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf) + { +-#define TMPBUF_SIZE 2048 +-#define PERLINE_TUPLE_NAMES 4 ++#define HNS3_PERLINE_TUPLE_NAME_LEN 4 + struct hns3_fd_cfg *fdcfg = &pf->fdir.fd_cfg; +- char tmpbuf[TMPBUF_SIZE] = {0}; + uint32_t i, count = 0; + + fprintf(file, " - Fdir Info:\n"); +@@ -171,17 +177,15 @@ hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf) + for (i = 0; i < MAX_TUPLE; i++) { + if (!(fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active & BIT(i))) + continue; +- if (count % PERLINE_TUPLE_NAMES == 0) ++ if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0) + fprintf(file, "\t "); + fprintf(file, " %s", hns3_get_fdir_tuple_name(i)); + count++; +- if (count % PERLINE_TUPLE_NAMES == 0) ++ if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0) + fprintf(file, "\n"); + } +- if (count % PERLINE_TUPLE_NAMES) ++ if (count % HNS3_PERLINE_TUPLE_NAME_LEN) + fprintf(file, "\n"); +- +- fprintf(file, "%s", tmpbuf); + } + + static void +@@ -220,99 +224,94 @@ hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev) + dev->data->dev_conf.intr_conf.rxq); + } + +-/* +- * Note: caller must make sure queue_id < nb_queues +- * nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues, +- * eth_dev->data->nb_tx_queues) +- */ + static struct hns3_rx_queue * +-hns3_get_rx_queue(struct rte_eth_dev *dev, uint32_t queue_id) ++hns3_get_rx_queue(struct rte_eth_dev *dev) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; +- uint32_t offset; ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_rx_queue *rxq; ++ uint32_t queue_id; + void **rx_queues; + +- if (queue_id < dev->data->nb_rx_queues) { ++ for (queue_id = 0; queue_id < dev->data->nb_rx_queues; queue_id++) { + rx_queues = dev->data->rx_queues; +- offset = queue_id; +- } else { +- /* +- * For kunpeng930, fake queue is not exist. But since the queues +- * are usually accessd in pairs, this branch may still exist. +- */ +- if (hns3_dev_get_support(hw, INDEP_TXRX)) ++ if (rx_queues == NULL || rx_queues[queue_id] == NULL) { ++ hns3_err(hw, "detect rx_queues is NULL!\n"); + return NULL; ++ } + +- rx_queues = hw->fkq_data.rx_queues; +- offset = queue_id - dev->data->nb_rx_queues; +- } ++ rxq = (struct hns3_rx_queue *)rx_queues[queue_id]; ++ if (rxq->rx_deferred_start) ++ continue; + +- if (rx_queues != NULL && rx_queues[offset] != NULL) +- return rx_queues[offset]; ++ return rx_queues[queue_id]; ++ } + +- hns3_err(hw, "Detect rx_queues is NULL!\n"); + return NULL; + } + +-/* +- * Note: caller must make sure queue_id < nb_queues +- * nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues, +- * eth_dev->data->nb_tx_queues) +- */ + static struct hns3_tx_queue * +-hns3_get_tx_queue(struct rte_eth_dev *dev, uint32_t queue_id) ++hns3_get_tx_queue(struct rte_eth_dev *dev) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; +- uint32_t offset; ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_tx_queue *txq; ++ uint32_t queue_id; + void **tx_queues; + +- if (queue_id < dev->data->nb_tx_queues) { ++ for (queue_id = 0; queue_id < dev->data->nb_tx_queues; queue_id++) { + tx_queues = dev->data->tx_queues; +- offset = queue_id; +- } else { +- /* +- * For kunpeng930, fake queue is not exist. But since the queues +- * are usually accessd in pairs, this branch may still exist. +- */ +- if (hns3_dev_get_support(hw, INDEP_TXRX)) ++ if (tx_queues == NULL || tx_queues[queue_id] == NULL) { ++ hns3_err(hw, "detect tx_queues is NULL!\n"); + return NULL; +- tx_queues = hw->fkq_data.tx_queues; +- offset = queue_id - dev->data->nb_tx_queues; +- } ++ } + +- if (tx_queues != NULL && tx_queues[offset] != NULL) +- return tx_queues[offset]; ++ txq = (struct hns3_tx_queue *)tx_queues[queue_id]; ++ if (txq->tx_deferred_start) ++ continue; ++ ++ return tx_queues[queue_id]; ++ } + +- hns3_err(hw, "Detect tx_queues is NULL!\n"); + return NULL; + } + + static void + hns3_get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct hns3_rx_queue *rxq; + struct hns3_tx_queue *txq; +- uint32_t queue_id; ++ uint32_t queue_id = 0; ++ void **rx_queues; ++ void **tx_queues; + +- if (dev->data->nb_rx_queues != dev->data->nb_tx_queues && +- !hns3_dev_get_support(hw, INDEP_TXRX)) { +- queue_id = RTE_MIN(dev->data->nb_rx_queues, +- dev->data->nb_tx_queues); +- rxq = hns3_get_rx_queue(dev, queue_id); +- if (rxq == NULL) ++ if (hns3_dev_get_support(hw, INDEP_TXRX)) ++ return; ++ ++ if (dev->data->nb_rx_queues < dev->data->nb_tx_queues) { ++ rx_queues = hw->fkq_data.rx_queues; ++ if (rx_queues == NULL || rx_queues[queue_id] == NULL) { ++ hns3_err(hw, "detect rx_queues is NULL!\n"); + return; +- txq = hns3_get_tx_queue(dev, queue_id); +- if (txq == NULL) ++ } ++ rxq = (struct hns3_rx_queue *)rx_queues[queue_id]; ++ ++ fprintf(file, ++ "\t -- first fake_queue info:\n" ++ "\t Rx: port=%u nb_desc=%u free_thresh=%u\n", ++ rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh); ++ } else if (dev->data->nb_rx_queues > dev->data->nb_tx_queues) { ++ tx_queues = hw->fkq_data.tx_queues; ++ queue_id = 0; ++ ++ if (tx_queues == NULL || tx_queues[queue_id] == NULL) { ++ hns3_err(hw, "detect tx_queues is NULL!\n"); + return; ++ } ++ txq = (struct hns3_tx_queue *)tx_queues[queue_id]; ++ + fprintf(file, +- "\t -- first fake_queue rxtx info:\n" +- "\t Rx: port=%u nb_desc=%u free_thresh=%u\n" +- "\t Tx: port=%u nb_desc=%u\n", +- rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh, ++ "\t -- first fake_queue info:\n" ++ "\t Tx: port=%u nb_desc=%u\n", + txq->port_id, txq->nb_tx_desc); + } + } +@@ -321,7 +320,7 @@ static void + hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state, + uint32_t nb_queues, bool is_rxq) + { +-#define STATE_SIZE (sizeof(*queue_state) * CHAR_BIT) ++#define HNS3_QUEUE_NUM_PER_STATS (sizeof(*queue_state) * HNS3_UINT8_BIT) + uint32_t queue_en_reg; + uint32_t reg_offset; + uint32_t state; +@@ -334,28 +333,28 @@ hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state, + if (hns3_dev_get_support(hw, INDEP_TXRX)) + state = state && hns3_read_dev(hw, reg_offset + + queue_en_reg); +- hns3_set_bit(queue_state[i / STATE_SIZE], +- i % STATE_SIZE, state); ++ hns3_set_bit(queue_state[i / HNS3_QUEUE_NUM_PER_STATS], ++ i % HNS3_QUEUE_NUM_PER_STATS, state); + } + } + + static void + hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state, +- uint32_t nb_queues, uint32_t line_num) ++ uint32_t nb_queues, uint32_t line_num) + { +-#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT) +- uint32_t qid = line_num * NUM_QUEUE_PER_LINE; +- uint32_t j; ++#define HNS3_NUM_QUEUE_PER_LINE (sizeof(*queue_state) * HNS3_UINT8_BIT) ++ uint32_t id = line_num * HNS3_NUM_QUEUE_PER_LINE; ++ uint32_t i; + +- for (j = 0; j < NUM_QUEUE_PER_LINE; j++) { +- fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], j)); ++ for (i = 0; i < HNS3_NUM_QUEUE_PER_LINE; i++) { ++ fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], i)); + +- if (qid % CHAR_BIT == CHAR_BIT - 1) { ++ if (id % HNS3_UINT8_BIT == HNS3_UINT8_BIT - 1) { + fprintf(file, "%s", +- j == NUM_QUEUE_PER_LINE - 1 ? "\n" : ":"); ++ i == HNS3_NUM_QUEUE_PER_LINE - 1 ? "\n" : ":"); + } +- qid++; +- if (qid >= nb_queues) { ++ id++; ++ if (id >= nb_queues) { + fprintf(file, "\n"); + break; + } +@@ -364,23 +363,17 @@ hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state, + + static void + hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state, +- uint32_t nb_queues, bool is_rxq) ++ uint32_t nb_queues, bool is_rxq) + { +-#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT) ++#define HNS3_NUM_QUEUE_PER_LINE (sizeof(*queue_state) * HNS3_UINT8_BIT) + uint32_t i; + +- if (nb_queues == 0) { +- fprintf(file, "\t %s queue number is 0\n", +- is_rxq ? "Rx" : "Tx"); +- return; +- } +- + fprintf(file, "\t %s queue id | enable state bitMap\n", + is_rxq ? "Rx" : "Tx"); + +- for (i = 0; i < (nb_queues - 1) / NUM_QUEUE_PER_LINE + 1; i++) { +- uint32_t line_end = (i + 1) * NUM_QUEUE_PER_LINE - 1; +- uint32_t line_start = i * NUM_QUEUE_PER_LINE; ++ for (i = 0; i < (nb_queues - 1) / HNS3_NUM_QUEUE_PER_LINE + 1; i++) { ++ uint32_t line_end = (i + 1) * HNS3_NUM_QUEUE_PER_LINE - 1; ++ uint32_t line_start = i * HNS3_NUM_QUEUE_PER_LINE; + fprintf(file, "\t %04u - %04u | ", line_start, + nb_queues - 1 > line_end ? line_end : nb_queues - 1); + +@@ -391,16 +384,28 @@ hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state, + static void + hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev) + { +-#define MAX_TQP_NUM 1280 +-#define QUEUE_BITMAP_SIZE (MAX_TQP_NUM / 32) + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- uint32_t rx_queue_state[QUEUE_BITMAP_SIZE] = {0}; +- uint32_t tx_queue_state[QUEUE_BITMAP_SIZE] = {0}; ++ uint32_t *rx_queue_state; ++ uint32_t *tx_queue_state; + uint32_t nb_rx_queues; + uint32_t nb_tx_queues; ++ uint32_t bitmap_size; ++ ++ bitmap_size = (hw->tqps_num * sizeof(uint32_t) + HNS3_UINT32_BIT) / ++ HNS3_UINT32_BIT; ++ rx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0); ++ tx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0); + + nb_rx_queues = dev->data->nb_rx_queues; + nb_tx_queues = dev->data->nb_tx_queues; ++ if (nb_rx_queues == 0) { ++ fprintf(file, "\t -- Rx queue number is 0\n"); ++ return; ++ } ++ if (nb_tx_queues == 0) { ++ fprintf(file, "\t -- Tx queue number is 0\n"); ++ return; ++ } + + fprintf(file, "\t -- enable state:\n"); + hns3_get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true); +@@ -410,6 +415,8 @@ hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev) + hns3_get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false); + hns3_display_queue_enable_state(file, tx_queue_state, nb_tx_queues, + false); ++ rte_free(rx_queue_state); ++ rte_free(tx_queue_state); + } + + static void +@@ -417,12 +424,11 @@ hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev) + { + struct hns3_rx_queue *rxq; + struct hns3_tx_queue *txq; +- uint32_t queue_id = 0; + +- rxq = hns3_get_rx_queue(dev, queue_id); ++ rxq = hns3_get_rx_queue(dev); + if (rxq == NULL) + return; +- txq = hns3_get_tx_queue(dev, queue_id); ++ txq = hns3_get_tx_queue(dev); + if (txq == NULL) + return; + fprintf(file, " - Rx/Tx Queue Info:\n"); +@@ -462,8 +468,8 @@ hns3_get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw) + ret = hns3_cmd_send(hw, &desc, 1); + if (ret != 0) { + hns3_err(hw, +- "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!", +- ret, 1, rte_le_to_cpu_16(desc.opcode)); ++ "NIC firmware exec ret=%d optcode=0x%x!", ret, ++ rte_le_to_cpu_16(desc.opcode)); + return ret; + } + +@@ -551,7 +557,7 @@ hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw) + ret = hns3_cmd_send(hw, &desc, 1); + if (ret != 0) { + hns3_err(hw, +- "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!", ++ "NIC firmware exec ret=%d desc_num=%d optcode=0x%x!", + ret, 1, rte_le_to_cpu_16(desc.opcode)); + return ret; + } +@@ -564,8 +570,8 @@ hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw) + static void + hns3_get_port_pvid_info(FILE *file, struct hns3_hw *hw) + { +- fprintf(file, "\t -- pvid status: %s\n", +- hw->port_base_vlan_cfg.state ? "on" : "off"); ++ fprintf(file, " - pvid status: %s\n", ++ hw->port_base_vlan_cfg.state ? "On" : "Off"); + } + + static void +@@ -581,8 +587,6 @@ hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw) + ret = hns3_get_vlan_tx_offload_cfg(file, hw); + if (ret < 0) + return; +- +- hns3_get_port_pvid_info(file, hw); + } + + static void +@@ -592,7 +596,7 @@ hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf) + &conf->shaper_profile_list; + struct hns3_tm_shaper_profile *shaper_profile; + +- if (!conf->nb_shaper_profile) ++ if (conf->nb_shaper_profile == 0) + return; + + fprintf(file, " shaper_profile:\n"); +@@ -608,7 +612,7 @@ hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf) + static void + hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf) + { +- if (!conf->root) ++ if (conf->root == NULL) + return; + + fprintf(file, +@@ -627,7 +631,7 @@ hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf) + struct hns3_tm_node *tm_node; + uint32_t tidx; + +- if (!conf->nb_tc_node) ++ if (conf->nb_tc_node == 0) + return; + + fprintf(file, " tc_node: \n"); +@@ -658,29 +662,28 @@ hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node, + uint32_t *queue_node_tc, + uint32_t nb_tx_queues) + { +-#define PERLINE_QUEUES 32 +-#define PERLINE_STRIDE 8 +-#define LINE_BUF_SIZE 1024 +- uint32_t i, j, line_num, start_queue, end_queue; +- char tmpbuf[LINE_BUF_SIZE] = {0}; ++#define HNS3_PERLINE_QUEUES 32 ++#define HNS3_PERLINE_STRIDE 8 ++ uint32_t i, j, line_num, start_queue_id, end_queue_id; + +- line_num = (nb_tx_queues + PERLINE_QUEUES - 1) / PERLINE_QUEUES; ++ line_num = (nb_tx_queues + HNS3_PERLINE_QUEUES - 1) / ++ HNS3_PERLINE_QUEUES; + for (i = 0; i < line_num; i++) { +- start_queue = i * PERLINE_QUEUES; +- end_queue = (i + 1) * PERLINE_QUEUES - 1; +- if (end_queue > nb_tx_queues - 1) +- end_queue = nb_tx_queues - 1; +- fprintf(file, " %04u - %04u | ", start_queue, end_queue); +- for (j = start_queue; j < nb_tx_queues; j++) { +- if (j >= end_queue + 1) ++ start_queue_id = i * HNS3_PERLINE_QUEUES; ++ end_queue_id = (i + 1) * HNS3_PERLINE_QUEUES - 1; ++ if (end_queue_id > nb_tx_queues - 1) ++ end_queue_id = nb_tx_queues - 1; ++ fprintf(file, " %04u - %04u | ", start_queue_id, ++ end_queue_id); ++ for (j = start_queue_id; j < nb_tx_queues; j++) { ++ if (j >= end_queue_id + 1) + break; +- if (j > start_queue && j % PERLINE_STRIDE == 0) ++ if (j > start_queue_id && j % HNS3_PERLINE_STRIDE == 0) + fprintf(file, ":"); + fprintf(file, "%u", + queue_node[j] ? queue_node_tc[j] : + HNS3_MAX_TC_NUM); + } +- fprintf(file, "%s\n", tmpbuf); + } + } + +@@ -694,7 +697,7 @@ hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, + uint32_t queue_node_tc[nb_queue_node]; + struct hns3_tm_node *tm_node; + +- if (!conf->nb_queue_node) ++ if (conf->nb_queue_node == 0) + return; + + fprintf(file, +@@ -720,9 +723,13 @@ hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, + static void + hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev) + { ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct hns3_tm_conf *conf = &pf->tm_conf; + ++ if (!hns3_dev_get_support(hw, TM)) ++ return; ++ + fprintf(file, " - TM config info:\n"); + fprintf(file, + "\t -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n" +@@ -826,8 +833,7 @@ hns3_get_link_fc_info(FILE *file, struct rte_eth_dev *dev) + static void + hns3_get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + fprintf(file, " - Flow Ctrl Info:\n"); + fprintf(file, +@@ -849,6 +855,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + hns3_get_device_basic_info(file, dev); + hns3_get_dev_feature_capability(file, hw); + hns3_get_rxtx_queue_info(file, dev); ++ hns3_get_port_pvid_info(file, hw); + + /* + * VF only supports dumping basic info, feaure capability and queue +diff --git a/drivers/net/hns3/hns3_dump.h b/drivers/net/hns3/hns3_dump.h +new file mode 100644 +index 0000000000..8ba7ee866a +--- /dev/null ++++ b/drivers/net/hns3/hns3_dump.h +@@ -0,0 +1,10 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(C) 2022 HiSilicon Limited ++ */ ++ ++#ifndef _HNS3_DUMP_H_ ++#define _HNS3_DUMP_H_ ++ ++int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file); ++ ++#endif /* _HNS3_DUMP_H_ */ +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index cac6dd7755..dfc41d2a05 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -8,6 +8,7 @@ + + #include "hns3_ethdev.h" + #include "hns3_common.h" ++#include "hns3_dump.h" + #include "hns3_logs.h" + #include "hns3_rxtx.h" + #include "hns3_intr.h" +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index fd83bb7109..d6d82c55f9 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -874,7 +874,7 @@ struct hns3_adapter { + + #define HNS3_DEVARG_MBX_TIME_LIMIT_MS "mbx_time_limit_ms" + +-enum { ++enum hns3_dev_cap { + HNS3_DEV_SUPPORT_DCB_B, + HNS3_DEV_SUPPORT_COPPER_B, + HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, +@@ -1057,7 +1057,6 @@ int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts); + int hns3_timesync_write_time(struct rte_eth_dev *dev, + const struct timespec *ts); + int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta); +-int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file); + + static inline bool + is_reset_pending(struct hns3_adapter *hns) +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index aee0c36360..92fbdb90cd 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -10,6 +10,7 @@ + + #include "hns3_ethdev.h" + #include "hns3_common.h" ++#include "hns3_dump.h" + #include "hns3_logs.h" + #include "hns3_rxtx.h" + #include "hns3_regs.h" +-- +2.30.0 + diff --git a/0058-ethdev-fix-ethdev-version-map.patch b/0058-ethdev-fix-ethdev-version-map.patch new file mode 100644 index 0000000..05f1f9e --- /dev/null +++ b/0058-ethdev-fix-ethdev-version-map.patch @@ -0,0 +1,31 @@ +From fe0c1c3ea1023ecece4bf5f5ef99a014fcb182b8 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Wed, 6 Apr 2022 09:29:30 +0800 +Subject: [PATCH 13/13] ethdev: fix ethdev version map + +This patch fix ethdev version map as new API introduced. + +Fixes: 2d2aea5495d1 ("ethdev: introduce dump API") + +Signed-off-by: Min Hu (Connor) +--- + lib/ethdev/version.map | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map +index c2fb0669a4..f29c60eda4 100644 +--- a/lib/ethdev/version.map ++++ b/lib/ethdev/version.map +@@ -256,6 +256,9 @@ EXPERIMENTAL { + rte_flow_flex_item_create; + rte_flow_flex_item_release; + rte_flow_pick_transfer_proxy; ++ ++ # added in 22.03 ++ rte_eth_dev_priv_dump; + }; + + INTERNAL { +-- +2.30.0 + diff --git a/0059-net-hns3-delete-simple-bd-cap.patch b/0059-net-hns3-delete-simple-bd-cap.patch new file mode 100644 index 0000000..db030f3 --- /dev/null +++ b/0059-net-hns3-delete-simple-bd-cap.patch @@ -0,0 +1,28 @@ +From b757a6bf3bef31517f3799fa5a0426e38da04a71 Mon Sep 17 00:00:00 2001 +From: Min Hu +Date: Wed, 6 Apr 2022 11:56:06 +0800 +Subject: [PATCH] net/hns3: delete simple bd cap + +This patch delete simple bd cap for dump as it has not been merged +in community. + +Signed-off-by: Min Hu +--- + drivers/net/hns3/hns3_dump.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index 3a30a585c5..4b18bb647c 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -94,7 +94,6 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) + {HNS3_DEV_SUPPORT_TX_PUSH_B, "TX PUSH"}, + {HNS3_DEV_SUPPORT_INDEP_TXRX_B, "INDEP TXRX"}, + {HNS3_DEV_SUPPORT_STASH_B, "STASH"}, +- {HNS3_DEV_SUPPORT_SIMPLE_BD_B, "SIMPLE BD"}, + {HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, "RXD Advanced Layout"}, + {HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"}, + {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"}, +-- +2.30.0 + diff --git a/0060-net-hns3-fix-TM-info-dump.patch b/0060-net-hns3-fix-TM-info-dump.patch new file mode 100644 index 0000000..6ed0381 --- /dev/null +++ b/0060-net-hns3-fix-TM-info-dump.patch @@ -0,0 +1,29 @@ +From 288da934034f84ab87b9e0d087db7e1e3c88bc8a Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 8 Apr 2022 11:27:04 +0800 +Subject: [PATCH] net/hns3: fix TM info dump + +This patch add newline characterat the end of TM info dump. + +Fixes: 761dfa44be2f ("net/hns3: dump TM configuration info") + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_dump.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index 3a30a585c5..6ec3125b10 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -684,6 +684,7 @@ hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node, + queue_node[j] ? queue_node_tc[j] : + HNS3_MAX_TC_NUM); + } ++ fprintf(file, "\n"); + } + } + +-- +2.33.0 + diff --git a/0061-dma-hisilicon-support-Kunpeng-930.patch b/0061-dma-hisilicon-support-Kunpeng-930.patch new file mode 100644 index 0000000..4427fa9 --- /dev/null +++ b/0061-dma-hisilicon-support-Kunpeng-930.patch @@ -0,0 +1,182 @@ +From 0ac9cae2d0e1763cf884f0b5d735e4b57b6acb27 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 17 Feb 2022 10:59:07 +0800 +Subject: [PATCH 01/25] dma/hisilicon: support Kunpeng 930 + +The Kunpeng930 DMA devices have the same PCI device id with Kunpeng920, +but with different PCI revision and register layout. This patch +introduces the basic initialization for Kunpeng930 DMA devices. + +Signed-off-by: Chengwen Feng +--- + doc/guides/dmadevs/hisilicon.rst | 1 + + drivers/dma/hisilicon/hisi_dmadev.c | 34 ++++++++++++++++++++++++++--- + drivers/dma/hisilicon/hisi_dmadev.h | 28 +++++++++++++++++++----- + 3 files changed, 54 insertions(+), 9 deletions(-) + +diff --git a/doc/guides/dmadevs/hisilicon.rst b/doc/guides/dmadevs/hisilicon.rst +index 191e56f2f7..81bf090311 100644 +--- a/doc/guides/dmadevs/hisilicon.rst ++++ b/doc/guides/dmadevs/hisilicon.rst +@@ -13,6 +13,7 @@ Supported Kunpeng SoCs + ---------------------- + + * Kunpeng 920 ++* Kunpeng 930 + + + Device Setup +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index 05066b4d0e..d4e08994a8 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -39,6 +39,8 @@ hisi_dma_queue_base(struct hisi_dma_dev *hw) + { + if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08) + return HISI_DMA_HIP08_QUEUE_BASE; ++ else if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP09) ++ return HISI_DMA_HIP09_QUEUE_BASE; + else + return 0; + } +@@ -174,7 +176,7 @@ hisi_dma_reset_hw(struct hisi_dma_dev *hw) + } + + static void +-hisi_dma_init_hw(struct hisi_dma_dev *hw) ++hisi_dma_init_common(struct hisi_dma_dev *hw) + { + hisi_dma_write_queue(hw, HISI_DMA_QUEUE_SQ_BASE_L_REG, + lower_32_bits(hw->sqe_iova)); +@@ -192,6 +194,12 @@ hisi_dma_init_hw(struct hisi_dma_dev *hw) + hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM0_REG, 0); + hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM1_REG, 0); + hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM2_REG, 0); ++} ++ ++static void ++hisi_dma_init_hw(struct hisi_dma_dev *hw) ++{ ++ hisi_dma_init_common(hw); + + if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08) { + hisi_dma_write_queue(hw, HISI_DMA_HIP08_QUEUE_ERR_INT_NUM3_REG, +@@ -206,9 +214,27 @@ hisi_dma_init_hw(struct hisi_dma_dev *hw) + HISI_DMA_HIP08_QUEUE_CTRL0_ERR_ABORT_B, false); + hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_STATUS_REG, + HISI_DMA_HIP08_QUEUE_INT_MASK_M, true); +- hisi_dma_update_queue_mbit(hw, +- HISI_DMA_HIP08_QUEUE_INT_MASK_REG, ++ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_MASK_REG, + HISI_DMA_HIP08_QUEUE_INT_MASK_M, true); ++ } else if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP09) { ++ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_CTRL0_REG, ++ HISI_DMA_HIP09_QUEUE_CTRL0_ERR_ABORT_M, false); ++ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_STATUS_REG, ++ HISI_DMA_HIP09_QUEUE_INT_MASK_M, true); ++ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_MASK_REG, ++ HISI_DMA_HIP09_QUEUE_INT_MASK_M, true); ++ hisi_dma_update_queue_mbit(hw, ++ HISI_DMA_HIP09_QUEUE_ERR_INT_STATUS_REG, ++ HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_M, true); ++ hisi_dma_update_queue_mbit(hw, ++ HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_REG, ++ HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_M, true); ++ hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL1_REG, ++ HISI_DMA_HIP09_QUEUE_CTRL1_VA_ENABLE_B, true); ++ hisi_dma_update_bit(hw, ++ HISI_DMA_HIP09_QUEUE_CFG_REG(hw->queue_id), ++ HISI_DMA_HIP09_QUEUE_CFG_LINK_DOWN_MASK_B, ++ true); + } + } + +@@ -230,6 +256,8 @@ hisi_dma_reg_layout(uint8_t revision) + { + if (revision == HISI_DMA_REVISION_HIP08B) + return HISI_DMA_REG_LAYOUT_HIP08; ++ else if (revision >= HISI_DMA_REVISION_HIP09A) ++ return HISI_DMA_REG_LAYOUT_HIP09; + else + return HISI_DMA_REG_LAYOUT_INVALID; + } +diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h +index 12e209c86e..591aec0b32 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.h ++++ b/drivers/dma/hisilicon/hisi_dmadev.h +@@ -23,20 +23,22 @@ + #define HISI_DMA_DEVICE_ID 0xA122 + #define HISI_DMA_PCI_REVISION_ID_REG 0x08 + #define HISI_DMA_REVISION_HIP08B 0x21 ++#define HISI_DMA_REVISION_HIP09A 0x30 + + #define HISI_DMA_MAX_HW_QUEUES 4 + #define HISI_DMA_MAX_DESC_NUM 8192 + #define HISI_DMA_MIN_DESC_NUM 32 + + /** +- * The HIP08B(HiSilicon IP08) and later Chip(e.g. HiSilicon IP09) are DMA iEPs, +- * they have the same pci device id but with different pci revision. +- * Unfortunately, they have different register layouts, so the layout ++ * The HIP08B(HiSilicon IP08) and HIP09B(HiSilicon IP09) are DMA iEPs, they ++ * have the same pci device id but different pci revision. ++ * Unfortunately, they have different register layouts, so two layout + * enumerations are defined. + */ + enum { + HISI_DMA_REG_LAYOUT_INVALID = 0, +- HISI_DMA_REG_LAYOUT_HIP08 ++ HISI_DMA_REG_LAYOUT_HIP08, ++ HISI_DMA_REG_LAYOUT_HIP09 + }; + + /** +@@ -66,7 +68,7 @@ enum { + * calculated by: + * offset = queue-base + (queue-id * queue-region) + reg-offset-in-region. + * +- * The first part of queue region is basically the same for HIP08 and later chip ++ * The first part of queue region is basically the same for HIP08 and HIP09 + * register layouts, therefore, HISI_QUEUE_* registers are defined for it. + */ + #define HISI_DMA_QUEUE_SQ_BASE_L_REG 0x0 +@@ -85,6 +87,7 @@ enum { + #define HISI_DMA_QUEUE_FSM_REG 0x30 + #define HISI_DMA_QUEUE_FSM_STS_M GENMASK(3, 0) + #define HISI_DMA_QUEUE_INT_STATUS_REG 0x40 ++#define HISI_DMA_QUEUE_INT_MASK_REG 0x44 + #define HISI_DMA_QUEUE_ERR_INT_NUM0_REG 0x84 + #define HISI_DMA_QUEUE_ERR_INT_NUM1_REG 0x88 + #define HISI_DMA_QUEUE_ERR_INT_NUM2_REG 0x8C +@@ -95,7 +98,6 @@ enum { + */ + #define HISI_DMA_HIP08_QUEUE_BASE 0x0 + #define HISI_DMA_HIP08_QUEUE_CTRL0_ERR_ABORT_B 2 +-#define HISI_DMA_HIP08_QUEUE_INT_MASK_REG 0x44 + #define HISI_DMA_HIP08_QUEUE_INT_MASK_M GENMASK(14, 0) + #define HISI_DMA_HIP08_QUEUE_ERR_INT_NUM3_REG 0x90 + #define HISI_DMA_HIP08_QUEUE_ERR_INT_NUM4_REG 0x94 +@@ -106,6 +108,20 @@ enum { + #define HISI_DMA_HIP08_DUMP_START_REG 0x2000 + #define HISI_DMA_HIP08_DUMP_END_REG 0x2280 + ++/** ++ * HiSilicon IP09 DMA register and field define: ++ */ ++#define HISI_DMA_HIP09_QUEUE_BASE 0x2000 ++#define HISI_DMA_HIP09_QUEUE_CTRL0_ERR_ABORT_M GENMASK(31, 28) ++#define HISI_DMA_HIP09_QUEUE_CTRL1_VA_ENABLE_B 2 ++#define HISI_DMA_HIP09_QUEUE_INT_MASK_M 0x1 ++#define HISI_DMA_HIP09_QUEUE_ERR_INT_STATUS_REG 0x48 ++#define HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_REG 0x4C ++#define HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_M GENMASK(18, 1) ++#define HISI_DMA_HIP09_QUEUE_CFG_REG(queue_id) (0x800 + \ ++ (queue_id) * 0x20) ++#define HISI_DMA_HIP09_QUEUE_CFG_LINK_DOWN_MASK_B 16 ++ + /** + * In fact, there are multiple states, but it need to pay attention to + * the following two states for the driver: +-- +2.30.0 + diff --git a/0062-dma-hisilicon-support-error-handling-with-Kunpeng-93.patch b/0062-dma-hisilicon-support-error-handling-with-Kunpeng-93.patch new file mode 100644 index 0000000..3eefdcb --- /dev/null +++ b/0062-dma-hisilicon-support-error-handling-with-Kunpeng-93.patch @@ -0,0 +1,35 @@ +From 2265601837805a2fc70dd5935ffe3f2ccaec17d1 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 17 Feb 2022 10:59:08 +0800 +Subject: [PATCH] dma/hisilicon: support error handling with Kunpeng 930 + +The Kunpeng930 DMA supports the capability of handles errors. + +Signed-off-by: Chengwen Feng +--- + drivers/dma/hisilicon/hisi_dmadev.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index d4e08994a8..b99a9bce6c 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -328,11 +328,14 @@ hisi_dma_info_get(const struct rte_dma_dev *dev, + struct rte_dma_info *dev_info, + uint32_t info_sz) + { +- RTE_SET_USED(dev); ++ struct hisi_dma_dev *hw = dev->data->dev_private; + RTE_SET_USED(info_sz); + + dev_info->dev_capa = RTE_DMA_CAPA_MEM_TO_MEM | + RTE_DMA_CAPA_OPS_COPY; ++ if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP09) ++ dev_info->dev_capa |= RTE_DMA_CAPA_HANDLES_ERRORS; ++ + dev_info->max_vchans = 1; + dev_info->max_desc = HISI_DMA_MAX_DESC_NUM; + dev_info->min_desc = HISI_DMA_MIN_DESC_NUM; +-- +2.33.0 + diff --git a/0063-dma-hisilicon-support-registers-dump-for-Kunpeng-930.patch b/0063-dma-hisilicon-support-registers-dump-for-Kunpeng-930.patch new file mode 100644 index 0000000..6ff5fea --- /dev/null +++ b/0063-dma-hisilicon-support-registers-dump-for-Kunpeng-930.patch @@ -0,0 +1,112 @@ +From dd69081182fae0a65606e8d8b509aa46795b7cfa Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 17 Feb 2022 10:59:09 +0800 +Subject: [PATCH] dma/hisilicon: support registers dump for Kunpeng 930 + +This patch supports dump Kunpeng930 DMA registers. + +Signed-off-by: Chengwen Feng +--- + drivers/dma/hisilicon/hisi_dmadev.c | 54 +++++++++++++++++++---------- + drivers/dma/hisilicon/hisi_dmadev.h | 8 +++++ + 2 files changed, 44 insertions(+), 18 deletions(-) + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index b99a9bce6c..3917db38b7 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -460,29 +460,13 @@ hisi_dma_stats_reset(struct rte_dma_dev *dev, uint16_t vchan) + } + + static void +-hisi_dma_get_dump_range(struct hisi_dma_dev *hw, uint32_t *start, uint32_t *end) +-{ +- if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08) { +- *start = HISI_DMA_HIP08_DUMP_START_REG; +- *end = HISI_DMA_HIP08_DUMP_END_REG; +- } else { +- *start = 0; +- *end = 0; +- } +-} +- +-static void +-hisi_dma_dump_common(struct hisi_dma_dev *hw, FILE *f) ++hisi_dma_dump_range(struct hisi_dma_dev *hw, FILE *f, uint32_t start, ++ uint32_t end) + { + #define DUMP_REGNUM_PER_LINE 4 + +- uint32_t start, end; + uint32_t cnt, i; + +- hisi_dma_get_dump_range(hw, &start, &end); +- +- (void)fprintf(f, " common-register:\n"); +- + cnt = 0; + for (i = start; i <= end; i += sizeof(uint32_t)) { + if (cnt % DUMP_REGNUM_PER_LINE == 0) +@@ -496,6 +480,40 @@ hisi_dma_dump_common(struct hisi_dma_dev *hw, FILE *f) + (void)fprintf(f, "\n"); + } + ++static void ++hisi_dma_dump_common(struct hisi_dma_dev *hw, FILE *f) ++{ ++ struct { ++ uint8_t reg_layout; ++ uint32_t start; ++ uint32_t end; ++ } reg_info[] = { ++ { HISI_DMA_REG_LAYOUT_HIP08, ++ HISI_DMA_HIP08_DUMP_START_REG, ++ HISI_DMA_HIP08_DUMP_END_REG }, ++ { HISI_DMA_REG_LAYOUT_HIP09, ++ HISI_DMA_HIP09_DUMP_REGION_A_START_REG, ++ HISI_DMA_HIP09_DUMP_REGION_A_END_REG }, ++ { HISI_DMA_REG_LAYOUT_HIP09, ++ HISI_DMA_HIP09_DUMP_REGION_B_START_REG, ++ HISI_DMA_HIP09_DUMP_REGION_B_END_REG }, ++ { HISI_DMA_REG_LAYOUT_HIP09, ++ HISI_DMA_HIP09_DUMP_REGION_C_START_REG, ++ HISI_DMA_HIP09_DUMP_REGION_C_END_REG }, ++ { HISI_DMA_REG_LAYOUT_HIP09, ++ HISI_DMA_HIP09_DUMP_REGION_D_START_REG, ++ HISI_DMA_HIP09_DUMP_REGION_D_END_REG }, ++ }; ++ uint32_t i; ++ ++ (void)fprintf(f, " common-register:\n"); ++ for (i = 0; i < RTE_DIM(reg_info); i++) { ++ if (hw->reg_layout != reg_info[i].reg_layout) ++ continue; ++ hisi_dma_dump_range(hw, f, reg_info[i].start, reg_info[i].end); ++ } ++} ++ + static void + hisi_dma_dump_read_queue(struct hisi_dma_dev *hw, uint32_t qoff, + char *buffer, int max_sz) +diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h +index 591aec0b32..1eaa822db1 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.h ++++ b/drivers/dma/hisilicon/hisi_dmadev.h +@@ -121,6 +121,14 @@ enum { + #define HISI_DMA_HIP09_QUEUE_CFG_REG(queue_id) (0x800 + \ + (queue_id) * 0x20) + #define HISI_DMA_HIP09_QUEUE_CFG_LINK_DOWN_MASK_B 16 ++#define HISI_DMA_HIP09_DUMP_REGION_A_START_REG 0x0 ++#define HISI_DMA_HIP09_DUMP_REGION_A_END_REG 0x368 ++#define HISI_DMA_HIP09_DUMP_REGION_B_START_REG 0x800 ++#define HISI_DMA_HIP09_DUMP_REGION_B_END_REG 0xA08 ++#define HISI_DMA_HIP09_DUMP_REGION_C_START_REG 0x1800 ++#define HISI_DMA_HIP09_DUMP_REGION_C_END_REG 0x1A4C ++#define HISI_DMA_HIP09_DUMP_REGION_D_START_REG 0x1C00 ++#define HISI_DMA_HIP09_DUMP_REGION_D_END_REG 0x1CC4 + + /** + * In fact, there are multiple states, but it need to pay attention to +-- +2.33.0 + diff --git a/0064-dma-hisilicon-add-queue-full-statistics.patch b/0064-dma-hisilicon-add-queue-full-statistics.patch new file mode 100644 index 0000000..8ef63af --- /dev/null +++ b/0064-dma-hisilicon-add-queue-full-statistics.patch @@ -0,0 +1,78 @@ +From 410c9bc8354b4cccc3ae56608ca5f89f03e53cb3 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 17 Feb 2022 10:59:10 +0800 +Subject: [PATCH] dma/hisilicon: add queue full statistics + +This patch adds queue full statistics for HiSilicon DMA PMD. + +Signed-off-by: Chengwen Feng +--- + drivers/dma/hisilicon/hisi_dmadev.c | 12 ++++++++---- + drivers/dma/hisilicon/hisi_dmadev.h | 1 + + 2 files changed, 9 insertions(+), 4 deletions(-) + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index 3917db38b7..c36acf01be 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -407,6 +407,7 @@ hisi_dma_start(struct rte_dma_dev *dev) + hw->submitted = 0; + hw->completed = 0; + hw->errors = 0; ++ hw->qfulls = 0; + + hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL0_REG, + HISI_DMA_QUEUE_CTRL0_EN_B, true); +@@ -455,6 +456,7 @@ hisi_dma_stats_reset(struct rte_dma_dev *dev, uint16_t vchan) + hw->submitted = 0; + hw->completed = 0; + hw->errors = 0; ++ hw->qfulls = 0; + + return 0; + } +@@ -566,14 +568,14 @@ hisi_dma_dump(const struct rte_dma_dev *dev, FILE *f) + " ridx: %u cridx: %u\n" + " sq_head: %u sq_tail: %u cq_sq_head: %u\n" + " cq_head: %u cqs_completed: %u cqe_vld: %u\n" +- " submitted: %" PRIu64 " completed: %" PRIu64 " errors %" +- PRIu64"\n", ++ " submitted: %" PRIu64 " completed: %" PRIu64 " errors: %" ++ PRIu64 " qfulls: %" PRIu64 "\n", + hw->revision, hw->queue_id, + hw->sq_depth_mask > 0 ? hw->sq_depth_mask + 1 : 0, + hw->ridx, hw->cridx, + hw->sq_head, hw->sq_tail, hw->cq_sq_head, + hw->cq_head, hw->cqs_completed, hw->cqe_vld, +- hw->submitted, hw->completed, hw->errors); ++ hw->submitted, hw->completed, hw->errors, hw->qfulls); + hisi_dma_dump_queue(hw, f); + hisi_dma_dump_common(hw, f); + +@@ -590,8 +592,10 @@ hisi_dma_copy(void *dev_private, uint16_t vchan, + + RTE_SET_USED(vchan); + +- if (((hw->sq_tail + 1) & hw->sq_depth_mask) == hw->sq_head) ++ if (((hw->sq_tail + 1) & hw->sq_depth_mask) == hw->sq_head) { ++ hw->qfulls++; + return -ENOSPC; ++ } + + sqe->dw0 = rte_cpu_to_le_32(SQE_OPCODE_M2M); + sqe->dw1 = 0; +diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h +index 1eaa822db1..90b85322ca 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.h ++++ b/drivers/dma/hisilicon/hisi_dmadev.h +@@ -241,6 +241,7 @@ struct hisi_dma_dev { + uint64_t submitted; + uint64_t completed; + uint64_t errors; ++ uint64_t qfulls; + + /** + * The following fields are not accessed in the I/O path, so they are +-- +2.33.0 + diff --git a/0065-dma-hisilicon-use-common-PCI-device-naming.patch b/0065-dma-hisilicon-use-common-PCI-device-naming.patch new file mode 100644 index 0000000..7dffe6f --- /dev/null +++ b/0065-dma-hisilicon-use-common-PCI-device-naming.patch @@ -0,0 +1,79 @@ +From 033904450b1d52fd3d09e2bb53e529e3ba0ecf77 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 17 Feb 2022 10:59:11 +0800 +Subject: [PATCH] dma/hisilicon: use common PCI device naming + +For DMA device 0000:7d:0.0, the original generated dmadev name starts +with the "7d:0.0", which is not expected. +This patch uses rte_pci_device_name API to generates the dmadev name. + +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + doc/guides/dmadevs/hisilicon.rst | 4 ++-- + drivers/dma/hisilicon/hisi_dmadev.c | 23 +++++++---------------- + 2 files changed, 9 insertions(+), 18 deletions(-) + +diff --git a/doc/guides/dmadevs/hisilicon.rst b/doc/guides/dmadevs/hisilicon.rst +index 81bf090311..8c1f0f8886 100644 +--- a/doc/guides/dmadevs/hisilicon.rst ++++ b/doc/guides/dmadevs/hisilicon.rst +@@ -30,8 +30,8 @@ which can be accessed using API from the ``rte_dmadev`` library. + + The name of the ``dmadev`` created is like "B:D.F-chX", e.g. DMA 0000:7b:00.0 + will create four ``dmadev``, +-the 1st ``dmadev`` name is "7b:00.0-ch0", +-and the 2nd ``dmadev`` name is "7b:00.0-ch1". ++the 1st ``dmadev`` name is "0000:7b:00.0-ch0", ++and the 2nd ``dmadev`` name is "0000:7b:00.0-ch1". + + Device Configuration + ~~~~~~~~~~~~~~~~~~~~~ +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index c36acf01be..9cef2cbfbe 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -784,24 +784,15 @@ hisi_dma_burst_capacity(const void *dev_private, uint16_t vchan) + sq_head - 1 - sq_tail; + } + +-static void +-hisi_dma_gen_pci_device_name(const struct rte_pci_device *pci_dev, +- char *name, size_t size) +-{ +- memset(name, 0, size); +- (void)snprintf(name, size, "%x:%x.%x", +- pci_dev->addr.bus, pci_dev->addr.devid, +- pci_dev->addr.function); +-} +- + static void + hisi_dma_gen_dev_name(const struct rte_pci_device *pci_dev, +- uint8_t queue_id, char *name, size_t size) ++ uint8_t queue_id, char *dev_name, size_t size) + { +- memset(name, 0, size); +- (void)snprintf(name, size, "%x:%x.%x-ch%u", +- pci_dev->addr.bus, pci_dev->addr.devid, +- pci_dev->addr.function, queue_id); ++ char name[RTE_DEV_NAME_MAX_LEN] = { 0 }; ++ ++ memset(dev_name, 0, size); ++ rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); ++ (void)snprintf(dev_name, size, "%s-ch%u", name, queue_id); + } + + /** +@@ -917,7 +908,7 @@ hisi_dma_probe(struct rte_pci_driver *pci_drv __rte_unused, + uint8_t i; + int ret; + +- hisi_dma_gen_pci_device_name(pci_dev, name, sizeof(name)); ++ rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + + if (pci_dev->mem_resource[2].addr == NULL) { + HISI_DMA_LOG(ERR, "%s BAR2 is NULL!\n", name); +-- +2.33.0 + diff --git a/0066-app-testpmd-check-starting-port-is-not-in-bonding.patch b/0066-app-testpmd-check-starting-port-is-not-in-bonding.patch new file mode 100644 index 0000000..a9f5f53 --- /dev/null +++ b/0066-app-testpmd-check-starting-port-is-not-in-bonding.patch @@ -0,0 +1,38 @@ +From d8c079a572f3b76ca22fbfe665fb2e5e578ba881 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Thu, 17 Feb 2022 19:36:55 +0800 +Subject: [PATCH] app/testpmd: check starting port is not in bonding + +In bond, start or stop slave port should be operated by bonding port. +This patch add port_is_bonding_slave in start_port function. + +Fixes: 0e545d3047fe ("app/testpmd: check stopping port is not in bonding") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +Reviewed-by: Ferruh Yigit +--- + app/test-pmd/testpmd.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index 6d2e52c790..fe2ce19f99 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -2726,6 +2726,13 @@ start_port(portid_t pid) + if (pid != pi && pid != (portid_t)RTE_PORT_ALL) + continue; + ++ if (port_is_bonding_slave(pi)) { ++ fprintf(stderr, ++ "Please remove port %d from bonded device.\n", ++ pi); ++ continue; ++ } ++ + need_check_link_status = 0; + port = &ports[pi]; + if (port->port_status == RTE_PORT_STOPPED) +-- +2.33.0 + diff --git a/0067-examples-vhost-remove-DMA-type-option-help-info.patch b/0067-examples-vhost-remove-DMA-type-option-help-info.patch new file mode 100644 index 0000000..42606cc --- /dev/null +++ b/0067-examples-vhost-remove-DMA-type-option-help-info.patch @@ -0,0 +1,32 @@ +From 73d16d660b866aa209dcdc44a698427dac5f2eb7 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 17 Feb 2022 11:24:51 +0800 +Subject: [PATCH] examples/vhost: remove DMA type option help info + +The dma-type parameter was not supported when dmadev was +integrated in vhost, but the help info still exists. This +patch deletes it. + +Fixes: 53d3f4778c1d ("vhost: integrate dmadev in asynchronous data-path") + +Signed-off-by: Chengwen Feng +Reviewed-by: Chenbo Xia +--- + examples/vhost/main.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/examples/vhost/main.c b/examples/vhost/main.c +index 3e784f5c6f..68afd398bb 100644 +--- a/examples/vhost/main.c ++++ b/examples/vhost/main.c +@@ -608,7 +608,6 @@ us_vhost_usage(const char *prgname) + " --tx-csum [0|1] disable/enable TX checksum offload.\n" + " --tso [0|1] disable/enable TCP segment offload.\n" + " --client register a vhost-user socket as client mode.\n" +- " --dma-type register dma type for your vhost async driver. For example \"ioat\" for now.\n" + " --dmas register dma channel for specific vhost device.\n", + prgname); + } +-- +2.33.0 + diff --git a/0068-kni-fix-freeing-order-in-device-release.patch b/0068-kni-fix-freeing-order-in-device-release.patch new file mode 100644 index 0000000..c237f65 --- /dev/null +++ b/0068-kni-fix-freeing-order-in-device-release.patch @@ -0,0 +1,169 @@ +From d57f2899e29a74fffeb876863e1f570084d6437b Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 9 Feb 2022 15:35:25 +0800 +Subject: [PATCH] kni: fix freeing order in device release + +The "kni_dev" is the private data of the "net_device" in kni, and allocated +with the "net_device" by calling "alloc_netdev()". The "net_device" is +freed by calling "free_netdev()" when kni release. The freed memory +includes the "kni_dev". So after "kni_dev" should not be accessed after +"net_device" is released. + +Fixes: e77fec694936 ("kni: fix possible mbuf leaks and speed up port release") +Cc: stable@dpdk.org + +KASAN trace: + +[ 85.263717] ========================================================== +[ 85.264418] BUG: KASAN: use-after-free in kni_net_release_fifo_phy+ + 0x30/0x84 [rte_kni] +[ 85.265139] Read of size 8 at addr ffff000260668d60 by task kni/341 +[ 85.265703] +[ 85.265857] CPU: 0 PID: 341 Comm: kni Tainted: G U O + 5.15.0-rc4+ #1 +[ 85.266525] Hardware name: linux,dummy-virt (DT) +[ 85.266968] Call trace: +[ 85.267220] dump_backtrace+0x0/0x2d0 +[ 85.267591] show_stack+0x24/0x30 +[ 85.267924] dump_stack_lvl+0x8c/0xb8 +[ 85.268294] print_address_description.constprop.0+0x74/0x2b8 +[ 85.268855] kasan_report+0x1e4/0x200 +[ 85.269224] __asan_load8+0x98/0xd4 +[ 85.269577] kni_net_release_fifo_phy+0x30/0x84 [rte_kni] +[ 85.270116] kni_dev_remove.isra.0+0x50/0x64 [rte_kni] +[ 85.270630] kni_ioctl_release+0x254/0x320 [rte_kni] +[ 85.271136] kni_ioctl+0x64/0xb0 [rte_kni] +[ 85.271553] __arm64_sys_ioctl+0xdc/0x120 +[ 85.271955] invoke_syscall+0x68/0x1a0 +[ 85.272332] el0_svc_common.constprop.0+0x90/0x200 +[ 85.272807] do_el0_svc+0x94/0xa4 +[ 85.273144] el0_svc+0x78/0x240 +[ 85.273463] el0t_64_sync_handler+0x1a8/0x1b0 +[ 85.273895] el0t_64_sync+0x1a0/0x1a4 +[ 85.274264] +[ 85.274427] Allocated by task 341: +[ 85.274767] kasan_save_stack+0x2c/0x60 +[ 85.275157] __kasan_kmalloc+0x90/0xb4 +[ 85.275533] __kmalloc_node+0x230/0x594 +[ 85.275917] kvmalloc_node+0x8c/0x190 +[ 85.276286] alloc_netdev_mqs+0x70/0x6b0 +[ 85.276678] kni_ioctl_create+0x224/0xf40 [rte_kni] +[ 85.277166] kni_ioctl+0x9c/0xb0 [rte_kni] +[ 85.277581] __arm64_sys_ioctl+0xdc/0x120 +[ 85.277980] invoke_syscall+0x68/0x1a0 +[ 85.278357] el0_svc_common.constprop.0+0x90/0x200 +[ 85.278830] do_el0_svc+0x94/0xa4 +[ 85.279172] el0_svc+0x78/0x240 +[ 85.279491] el0t_64_sync_handler+0x1a8/0x1b0 +[ 85.279925] el0t_64_sync+0x1a0/0x1a4 +[ 85.280292] +[ 85.280454] Freed by task 341: +[ 85.280763] kasan_save_stack+0x2c/0x60 +[ 85.281147] kasan_set_track+0x2c/0x40 +[ 85.281522] kasan_set_free_info+0x2c/0x50 +[ 85.281930] __kasan_slab_free+0xdc/0x140 +[ 85.282331] slab_free_freelist_hook+0x90/0x250 +[ 85.282782] kfree+0x128/0x580 +[ 85.283099] kvfree+0x48/0x60 +[ 85.283402] netdev_freemem+0x34/0x44 +[ 85.283770] netdev_release+0x50/0x64 +[ 85.284138] device_release+0xa0/0x120 +[ 85.284516] kobject_put+0xf8/0x160 +[ 85.284867] put_device+0x20/0x30 +[ 85.285204] free_netdev+0x22c/0x310 +[ 85.285562] kni_dev_remove.isra.0+0x48/0x64 [rte_kni] +[ 85.286076] kni_ioctl_release+0x254/0x320 [rte_kni] +[ 85.286573] kni_ioctl+0x64/0xb0 [rte_kni] +[ 85.286992] __arm64_sys_ioctl+0xdc/0x120 +[ 85.287392] invoke_syscall+0x68/0x1a0 +[ 85.287769] el0_svc_common.constprop.0+0x90/0x200 +[ 85.288243] do_el0_svc+0x94/0xa4 +[ 85.288579] el0_svc+0x78/0x240 +[ 85.288899] el0t_64_sync_handler+0x1a8/0x1b0 +[ 85.289332] el0t_64_sync+0x1a0/0x1a4 +[ 85.289699] +[ 85.289862] The buggy address belongs to the object at ffff000260668000 +[ 85.289862] which belongs to the cache kmalloc-cg-8k of size 8192 +[ 85.291079] The buggy address is located 3424 bytes inside of +[ 85.291079] 8192-byte region [ffff000260668000, ffff00026066a000) +[ 85.292213] The buggy address belongs to the page: +[ 85.292684] page:(____ptrval____) refcount:1 mapcount:0 mapping: + 0000000000000000 index:0x0 pfn:0x2a0668 +[ 85.293585] head:(____ptrval____) order:3 compound_mapcount:0 + compound_pincount:0 +[ 85.294305] flags: 0xbfff80000010200(slab|head|node=0|zone=2| + lastcpupid=0x7fff) +[ 85.295020] raw: 0bfff80000010200 0000000000000000 dead000000000122 + ffff0000c000d680 +[ 85.295767] raw: 0000000000000000 0000000080020002 00000001ffffffff + 0000000000000000 +[ 85.296512] page dumped because: kasan: bad access detected +[ 85.297054] +[ 85.297217] Memory state around the buggy address: +[ 85.297688] ffff000260668c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb + fb fb +[ 85.298384] ffff000260668c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb + fb fb +[ 85.299088] >ffff000260668d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb + fb fb +[ 85.299781] ^ +[ 85.300396] ffff000260668d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb + fb fb +[ 85.301092] ffff000260668e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb + fb fb +[ 85.301787] =========================================================== + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Acked-by: Ferruh Yigit +--- + kernel/linux/kni/kni_misc.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c +index ec70190042..780187d8bf 100644 +--- a/kernel/linux/kni/kni_misc.c ++++ b/kernel/linux/kni/kni_misc.c +@@ -182,13 +182,17 @@ kni_dev_remove(struct kni_dev *dev) + if (!dev) + return -ENODEV; + ++ /* ++ * The memory of kni device is allocated and released together ++ * with net device. Release mbuf before freeing net device. ++ */ ++ kni_net_release_fifo_phy(dev); ++ + if (dev->net_dev) { + unregister_netdev(dev->net_dev); + free_netdev(dev->net_dev); + } + +- kni_net_release_fifo_phy(dev); +- + return 0; + } + +@@ -218,8 +222,8 @@ kni_release(struct inode *inode, struct file *file) + dev->pthread = NULL; + } + +- kni_dev_remove(dev); + list_del(&dev->list); ++ kni_dev_remove(dev); + } + up_write(&knet->kni_list_lock); + +@@ -468,8 +472,8 @@ kni_ioctl_release(struct net *net, uint32_t ioctl_num, + dev->pthread = NULL; + } + +- kni_dev_remove(dev); + list_del(&dev->list); ++ kni_dev_remove(dev); + ret = 0; + break; + } +-- +2.33.0 + diff --git a/0069-net-hns3-remove-duplicate-macro-definition.patch b/0069-net-hns3-remove-duplicate-macro-definition.patch new file mode 100644 index 0000000..96dcbb8 --- /dev/null +++ b/0069-net-hns3-remove-duplicate-macro-definition.patch @@ -0,0 +1,31 @@ +From 0983cdc1870f52a360eadb40eab84b34c20b464d Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Mon, 28 Feb 2022 11:21:41 +0800 +Subject: [PATCH] net/hns3: remove duplicate macro definition + +This patch fixes duplicate macro definition of HNS3_RSS_CFG_TBL_SIZE. + +Fixes: 737f30e1c3ab ("net/hns3: support command interface with firmware") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_cmd.h | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index 81bc9e9d98..f9addc6069 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -603,7 +603,6 @@ struct hns3_cfg_gro_status_cmd { + + #define HNS3_RSS_HASH_KEY_OFFSET_B 4 + +-#define HNS3_RSS_CFG_TBL_SIZE 16 + #define HNS3_RSS_HASH_KEY_NUM 16 + /* Configure the algorithm mode and Hash Key, opcode:0x0D01 */ + struct hns3_rss_generic_config_cmd { +-- +2.33.0 + diff --git a/0070-net-hns3-fix-RSS-TC-mode-entry.patch b/0070-net-hns3-fix-RSS-TC-mode-entry.patch new file mode 100644 index 0000000..bf53c80 --- /dev/null +++ b/0070-net-hns3-fix-RSS-TC-mode-entry.patch @@ -0,0 +1,35 @@ +From cdb9a7ae5f8f3b59b6de9dc2b52387636245e3a5 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 28 Feb 2022 11:21:45 +0800 +Subject: [PATCH] net/hns3: fix RSS TC mode entry + +The driver allocates queues only to valid TCs. But the driver also +configure queues for invalid TCs, which is unreasonable. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rss.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 1782d63883..ebf3c60f07 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -601,8 +601,8 @@ hns3_set_rss_tc_mode(struct hns3_hw *hw) + + for (i = 0; i < HNS3_MAX_TC_NUM; i++) { + tc_valid[i] = !!(hw->hw_tc_map & BIT(i)); +- tc_size[i] = roundup_size; +- tc_offset[i] = rss_size * i; ++ tc_size[i] = tc_valid[i] ? roundup_size : 0; ++ tc_offset[i] = tc_valid[i] ? rss_size * i : 0; + } + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_TC_MODE, false); +-- +2.33.0 + diff --git a/0071-net-hns3-fix-VF-RSS-TC-mode-entry.patch b/0071-net-hns3-fix-VF-RSS-TC-mode-entry.patch new file mode 100644 index 0000000..cb318b5 --- /dev/null +++ b/0071-net-hns3-fix-VF-RSS-TC-mode-entry.patch @@ -0,0 +1,103 @@ +From 87f9628e2c786dff500139baf59720693e46b0bc Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 28 Feb 2022 11:21:46 +0800 +Subject: [PATCH] net/hns3: fix VF RSS TC mode entry + +For packets with VLAN priorities destined for the VF, hardware still +assign Rx queue based on the Up-to-TC mapping PF configured. But VF has +only one TC. If other TC don't enable, it causes that the priority +packets that aren't destined for TC0 aren't received by RSS hash but is +destined for queue 0. So driver has to enable the unused TC by using TC0 +queue mapping configuration. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rss.c | 56 +++++++++++++++++++++++++++---------- + 1 file changed, 41 insertions(+), 15 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index ebf3c60f07..1493b10f96 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -578,33 +578,59 @@ hns3_dev_rss_reta_query(struct rte_eth_dev *dev, + return 0; + } + +-/* +- * Used to configure the tc_size and tc_offset. +- */ ++static void ++hns3_set_rss_tc_mode_entry(struct hns3_hw *hw, uint8_t *tc_valid, ++ uint16_t *tc_size, uint16_t *tc_offset, ++ uint8_t tc_num) ++{ ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ uint16_t rss_size = hw->alloc_rss_size; ++ uint16_t roundup_size; ++ uint16_t i; ++ ++ roundup_size = roundup_pow_of_two(rss_size); ++ roundup_size = ilog2(roundup_size); ++ ++ for (i = 0; i < tc_num; i++) { ++ if (hns->is_vf) { ++ /* ++ * For packets with VLAN priorities destined for the VF, ++ * hardware still assign Rx queue based on the Up-to-TC ++ * mapping PF configured. But VF has only one TC. If ++ * other TC don't enable, it causes that the priority ++ * packets that aren't destined for TC0 aren't received ++ * by RSS hash but is destined for queue 0. So driver ++ * has to enable the unused TC by using TC0 queue ++ * mapping configuration. ++ */ ++ tc_valid[i] = (hw->hw_tc_map & BIT(i)) ? ++ !!(hw->hw_tc_map & BIT(i)) : 1; ++ tc_size[i] = roundup_size; ++ tc_offset[i] = (hw->hw_tc_map & BIT(i)) ? ++ rss_size * i : 0; ++ } else { ++ tc_valid[i] = !!(hw->hw_tc_map & BIT(i)); ++ tc_size[i] = tc_valid[i] ? roundup_size : 0; ++ tc_offset[i] = tc_valid[i] ? rss_size * i : 0; ++ } ++ } ++} ++ + static int + hns3_set_rss_tc_mode(struct hns3_hw *hw) + { +- uint16_t rss_size = hw->alloc_rss_size; + struct hns3_rss_tc_mode_cmd *req; + uint16_t tc_offset[HNS3_MAX_TC_NUM]; + uint8_t tc_valid[HNS3_MAX_TC_NUM]; + uint16_t tc_size[HNS3_MAX_TC_NUM]; + struct hns3_cmd_desc desc; +- uint16_t roundup_size; + uint16_t i; + int ret; + +- req = (struct hns3_rss_tc_mode_cmd *)desc.data; +- +- roundup_size = roundup_pow_of_two(rss_size); +- roundup_size = ilog2(roundup_size); +- +- for (i = 0; i < HNS3_MAX_TC_NUM; i++) { +- tc_valid[i] = !!(hw->hw_tc_map & BIT(i)); +- tc_size[i] = tc_valid[i] ? roundup_size : 0; +- tc_offset[i] = tc_valid[i] ? rss_size * i : 0; +- } ++ hns3_set_rss_tc_mode_entry(hw, tc_valid, tc_size, ++ tc_offset, HNS3_MAX_TC_NUM); + ++ req = (struct hns3_rss_tc_mode_cmd *)desc.data; + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_TC_MODE, false); + for (i = 0; i < HNS3_MAX_TC_NUM; i++) { + uint16_t mode = 0; +-- +2.33.0 + diff --git a/0072-net-hns3-increase-time-waiting-for-PF-reset-completi.patch b/0072-net-hns3-increase-time-waiting-for-PF-reset-completi.patch new file mode 100644 index 0000000..462c7fd --- /dev/null +++ b/0072-net-hns3-increase-time-waiting-for-PF-reset-completi.patch @@ -0,0 +1,51 @@ +From d6a9f8fb26b8d6adaac20d6a303faa5c5ba4d5bc Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 2 Mar 2022 08:35:01 +0800 +Subject: [PATCH] net/hns3: increase time waiting for PF reset completion + +On the case that PF and VF need to be reset, after the hardware reset is +complete, VF needs wait for 1 second to restore the configuration so +that VF does not fail to recover because PF reset isn't complete. But +the estimated time is not sufficient. This patch fixes it to 5 seconds. + +Fixes: 2790c6464725 ("net/hns3: support device reset") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev_vf.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 06ddf64184..9091706fe5 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1877,6 +1877,7 @@ hns3vf_is_reset_pending(struct hns3_adapter *hns) + static int + hns3vf_wait_hardware_ready(struct hns3_adapter *hns) + { ++#define HNS3_WAIT_PF_RESET_READY_TIME 5 + struct hns3_hw *hw = &hns->hw; + struct hns3_wait_data *wait_data = hw->reset.wait_data; + struct timeval tv; +@@ -1897,12 +1898,14 @@ hns3vf_wait_hardware_ready(struct hns3_adapter *hns) + return 0; + + wait_data->check_completion = NULL; +- wait_data->interval = 1 * MSEC_PER_SEC * USEC_PER_MSEC; ++ wait_data->interval = HNS3_WAIT_PF_RESET_READY_TIME * ++ MSEC_PER_SEC * USEC_PER_MSEC; + wait_data->count = 1; + wait_data->result = HNS3_WAIT_REQUEST; + rte_eal_alarm_set(wait_data->interval, hns3_wait_callback, + wait_data); +- hns3_warn(hw, "hardware is ready, delay 1 sec for PF reset complete"); ++ hns3_warn(hw, "hardware is ready, delay %d sec for PF reset complete", ++ HNS3_WAIT_PF_RESET_READY_TIME); + return -EAGAIN; + } else if (wait_data->result == HNS3_WAIT_TIMEOUT) { + hns3_clock_gettime(&tv); +-- +2.33.0 + diff --git a/0073-net-bonding-fix-stopping-non-active-slaves.patch b/0073-net-bonding-fix-stopping-non-active-slaves.patch new file mode 100644 index 0000000..f29bb40 --- /dev/null +++ b/0073-net-bonding-fix-stopping-non-active-slaves.patch @@ -0,0 +1,56 @@ +From f5e72e8e8d57b331baf1a86d15eb7fae921f57fb Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 3 May 2022 18:02:13 +0800 +Subject: [PATCH] net/bonding: fix stopping non-active slaves + +When stopping a bonded port, all slaves should be stopped. But only +active slaves are stopped. +So fix by stopping all slave ports and later do "deactivate_slave()" for +active slaves. + +Fixes: 0911d4ec0183 ("net/bonding: fix crash when stopping mode 4 port") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 20 +++++++++++--------- + 1 file changed, 11 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 5cbe89031b..605fc2ffb5 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -2118,18 +2118,20 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev) + internals->link_status_polling_enabled = 0; + for (i = 0; i < internals->slave_count; i++) { + uint16_t slave_id = internals->slaves[i].port_id; ++ ++ internals->slaves[i].last_link_status = 0; ++ ret = rte_eth_dev_stop(slave_id); ++ if (ret != 0) { ++ RTE_BOND_LOG(ERR, "Failed to stop device on port %u", ++ slave_id); ++ return ret; ++ } ++ ++ /* active slaves need to be deactivated. */ + if (find_slave_by_id(internals->active_slaves, + internals->active_slave_count, slave_id) != +- internals->active_slave_count) { +- internals->slaves[i].last_link_status = 0; +- ret = rte_eth_dev_stop(slave_id); +- if (ret != 0) { +- RTE_BOND_LOG(ERR, "Failed to stop device on port %u", +- slave_id); +- return ret; +- } ++ internals->active_slave_count) + deactivate_slave(eth_dev, slave_id); +- } + } + + return 0; +-- +2.33.0 + diff --git a/0074-net-bonding-fix-slave-stop-and-remove-on-port-close.patch b/0074-net-bonding-fix-slave-stop-and-remove-on-port-close.patch new file mode 100644 index 0000000..8e20027 --- /dev/null +++ b/0074-net-bonding-fix-slave-stop-and-remove-on-port-close.patch @@ -0,0 +1,37 @@ +From 1c5c6cd85f8cab2af92d265b6c7671df0b82e6fb Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 3 May 2022 18:02:14 +0800 +Subject: [PATCH] net/bonding: fix slave stop and remove on port close + +All slaves will be stopped and removed when closing a bonded port. +But the while loop can not end if both rte_eth_dev_stop and +rte_eth_bond_slave_remove fails, runs infinitely. +This is because the skipped slave port counted in both function failures +but it should be counted only one. + +Fixing by not continue to process in the loop after first failure. + +Fixes: fb0379bc5db3 ("net/bonding: check stop call status") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 605fc2ffb5..f0668a636f 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -2156,6 +2156,7 @@ bond_ethdev_close(struct rte_eth_dev *dev) + RTE_BOND_LOG(ERR, "Failed to stop device on port %u", + port_id); + skipped++; ++ continue; + } + + if (rte_eth_bond_slave_remove(bond_port_id, port_id) != 0) { +-- +2.33.0 + diff --git a/0075-net-hns3-fix-order-of-clearing-imissed-register-in-P.patch b/0075-net-hns3-fix-order-of-clearing-imissed-register-in-P.patch new file mode 100644 index 0000000..d22e487 --- /dev/null +++ b/0075-net-hns3-fix-order-of-clearing-imissed-register-in-P.patch @@ -0,0 +1,186 @@ +From 1a1de9879f58b4fd202ecd481c56ae9777207fe9 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 5 May 2022 20:27:01 +0800 +Subject: [PATCH] net/hns3: fix order of clearing imissed register in PF + +Clearing imissed registers in PF hardware depends on the +'drop_stats_mode' in struct hns3_hw. The variable is initialized after +the "hns3_get_configuration". But, in current code, the clearing +operation runs before the function. +So this patch fixes this order. In addition, this patch extracts a +public function to initialize and uninitialize statistics to improve the +maintainability of these codes. + +Fixes: 3e9f3042d7c8 ("net/hns3: add imissed packet stats") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 13 +++---------- + drivers/net/hns3/hns3_ethdev_vf.c | 13 +++---------- + drivers/net/hns3/hns3_stats.c | 27 ++++++++++++++++++++++++--- + drivers/net/hns3/hns3_stats.h | 5 ++--- + 4 files changed, 32 insertions(+), 26 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 4e089e682f..5aed7046d8 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4622,13 +4622,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) + goto err_cmd_init; + } + +- /* Hardware statistics of imissed registers cleared. */ +- ret = hns3_update_imissed_stats(hw, true); +- if (ret) { +- hns3_err(hw, "clear imissed stats failed, ret = %d", ret); +- goto err_cmd_init; +- } +- + hns3_config_all_msix_error(hw, true); + + ret = rte_intr_callback_register(pci_dev->intr_handle, +@@ -4654,7 +4647,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) + goto err_get_config; + } + +- ret = hns3_tqp_stats_init(hw); ++ ret = hns3_stats_init(hw); + if (ret) + goto err_get_config; + +@@ -4700,7 +4693,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) + err_fdir: + hns3_uninit_umv_space(hw); + err_init_hw: +- hns3_tqp_stats_uninit(hw); ++ hns3_stats_uninit(hw); + err_get_config: + hns3_pf_disable_irq0(hw); + rte_intr_disable(pci_dev->intr_handle); +@@ -4734,7 +4727,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) + hns3_flow_uninit(eth_dev); + hns3_fdir_filter_uninit(hns); + hns3_uninit_umv_space(hw); +- hns3_tqp_stats_uninit(hw); ++ hns3_stats_uninit(hw); + hns3_config_mac_tnl_int(hw, false); + hns3_pf_disable_irq0(hw); + rte_intr_disable(pci_dev->intr_handle); +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 9091706fe5..9e9fdc4144 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1510,17 +1510,10 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) + goto err_get_config; + } + +- ret = hns3_tqp_stats_init(hw); ++ ret = hns3_stats_init(hw); + if (ret) + goto err_get_config; + +- /* Hardware statistics of imissed registers cleared. */ +- ret = hns3_update_imissed_stats(hw, true); +- if (ret) { +- hns3_err(hw, "clear imissed stats failed, ret = %d", ret); +- goto err_set_tc_queue; +- } +- + ret = hns3_queue_to_tc_mapping(hw, hw->tqps_num, hw->tqps_num); + if (ret) { + PMD_INIT_LOG(ERR, "failed to set tc info, ret = %d.", ret); +@@ -1548,7 +1541,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) + return 0; + + err_set_tc_queue: +- hns3_tqp_stats_uninit(hw); ++ hns3_stats_uninit(hw); + + err_get_config: + hns3vf_disable_irq0(hw); +@@ -1579,7 +1572,7 @@ hns3vf_uninit_vf(struct rte_eth_dev *eth_dev) + (void)hns3vf_set_alive(hw, false); + (void)hns3vf_set_promisc_mode(hw, false, false, false); + hns3_flow_uninit(eth_dev); +- hns3_tqp_stats_uninit(hw); ++ hns3_stats_uninit(hw); + hns3vf_disable_irq0(hw); + rte_intr_disable(pci_dev->intr_handle); + hns3_intr_unregister(pci_dev->intr_handle, hns3vf_interrupt_handler, +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index 806720faff..e4a5dcf2f8 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -540,7 +540,7 @@ hns3_update_port_tx_ssu_drop_stats(struct hns3_hw *hw) + return 0; + } + +-int ++static int + hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear) + { + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); +@@ -1476,7 +1476,7 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) + return 0; + } + +-int ++static int + hns3_tqp_stats_init(struct hns3_hw *hw) + { + struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats; +@@ -1500,7 +1500,7 @@ hns3_tqp_stats_init(struct hns3_hw *hw) + return 0; + } + +-void ++static void + hns3_tqp_stats_uninit(struct hns3_hw *hw) + { + struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats; +@@ -1521,3 +1521,24 @@ hns3_tqp_stats_clear(struct hns3_hw *hw) + memset(stats->rcb_rx_ring_pktnum, 0, sizeof(uint64_t) * hw->tqps_num); + memset(stats->rcb_tx_ring_pktnum, 0, sizeof(uint64_t) * hw->tqps_num); + } ++ ++int ++hns3_stats_init(struct hns3_hw *hw) ++{ ++ int ret; ++ ++ /* Hardware statistics of imissed registers cleared. */ ++ ret = hns3_update_imissed_stats(hw, true); ++ if (ret) { ++ hns3_err(hw, "clear imissed stats failed, ret = %d", ret); ++ return ret; ++ } ++ ++ return hns3_tqp_stats_init(hw); ++} ++ ++void ++hns3_stats_uninit(struct hns3_hw *hw) ++{ ++ hns3_tqp_stats_uninit(hw); ++} +diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h +index c81d351082..e89dc97632 100644 +--- a/drivers/net/hns3/hns3_stats.h ++++ b/drivers/net/hns3/hns3_stats.h +@@ -161,9 +161,8 @@ int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + uint32_t size); + int hns3_stats_reset(struct rte_eth_dev *dev); +-int hns3_tqp_stats_init(struct hns3_hw *hw); +-void hns3_tqp_stats_uninit(struct hns3_hw *hw); +-int hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear); ++int hns3_stats_init(struct hns3_hw *hw); ++void hns3_stats_uninit(struct hns3_hw *hw); + int hns3_query_mac_stats_reg_num(struct hns3_hw *hw); + + #endif /* _HNS3_STATS_H_ */ +-- +2.33.0 + diff --git a/0076-net-hns3-fix-MAC-and-queues-HW-statistics-overflow.patch b/0076-net-hns3-fix-MAC-and-queues-HW-statistics-overflow.patch new file mode 100644 index 0000000..2326d59 --- /dev/null +++ b/0076-net-hns3-fix-MAC-and-queues-HW-statistics-overflow.patch @@ -0,0 +1,432 @@ +From dd4cf775f6c2f7dc18c6845983bc84c6351326c4 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 5 May 2022 20:27:02 +0800 +Subject: [PATCH 16/25] net/hns3: fix MAC and queues HW statistics overflow + +The MAC and queues statistics are 32-bit registers in hardware. If +hardware statistics are not obtained for a long time, these statistics +will be overflow. +So PF and VF driver have to periodically obtain and save these +statistics. Since the periodical task and the stats API are in different +threads, we introduce a statistics lock to protect the statistics. + +Fixes: 8839c5e202f3 ("net/hns3: support device stats") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 6 +- + drivers/net/hns3/hns3_ethdev.h | 6 ++ + drivers/net/hns3/hns3_ethdev_vf.c | 6 +- + drivers/net/hns3/hns3_stats.c | 144 +++++++++++++++++++++--------- + drivers/net/hns3/hns3_stats.h | 1 + + 5 files changed, 116 insertions(+), 47 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index dc37914aea..af317a8c47 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4365,10 +4365,12 @@ hns3_service_handler(void *param) + struct hns3_adapter *hns = eth_dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; + +- if (!hns3_is_reset_pending(hns)) ++ if (!hns3_is_reset_pending(hns)) { + hns3_update_linkstatus_and_event(hw, true); +- else ++ hns3_update_hw_stats(hw); ++ } else { + hns3_warn(hw, "Cancel the query when reset is pending"); ++ } + + rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev); + } +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index d6d82c55f9..889220237c 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -503,6 +503,12 @@ struct hns3_hw { + uint32_t mac_stats_reg_num; + struct hns3_rx_missed_stats imissed_stats; + uint64_t oerror_stats; ++ /* ++ * The lock is used to protect statistics update in stats APIs and ++ * periodic task. ++ */ ++ rte_spinlock_t stats_lock; ++ + uint32_t fw_version; + uint16_t pf_vf_if_version; /* version of communication interface */ + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index b66047c09f..70b773cfe9 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1338,10 +1338,12 @@ hns3vf_service_handler(void *param) + * Before querying the link status, check whether there is a reset + * pending, and if so, abandon the query. + */ +- if (!hns3vf_is_reset_pending(hns)) ++ if (!hns3vf_is_reset_pending(hns)) { + hns3vf_request_link_info(hw); +- else ++ hns3_update_hw_stats(hw); ++ } else { + hns3_warn(hw, "Cancel the query when reset is pending"); ++ } + + rte_eal_alarm_set(HNS3VF_SERVICE_INTERVAL, hns3vf_service_handler, + eth_dev); +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index 03719cd014..9b7ad067aa 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -584,6 +584,28 @@ hns3_update_oerror_stats(struct hns3_hw *hw, bool is_clear) + return 0; + } + ++static void ++hns3_rcb_rx_ring_stats_get(struct hns3_rx_queue *rxq, ++ struct hns3_tqp_stats *stats) ++{ ++ uint32_t cnt; ++ ++ cnt = hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG); ++ stats->rcb_rx_ring_pktnum_rcd += cnt; ++ stats->rcb_rx_ring_pktnum[rxq->queue_id] += cnt; ++} ++ ++static void ++hns3_rcb_tx_ring_stats_get(struct hns3_tx_queue *txq, ++ struct hns3_tqp_stats *stats) ++{ ++ uint32_t cnt; ++ ++ cnt = hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG); ++ stats->rcb_tx_ring_pktnum_rcd += cnt; ++ stats->rcb_tx_ring_pktnum[txq->queue_id] += cnt; ++} ++ + /* + * Query tqp tx queue statistics ,opcode id: 0x0B03. + * Query tqp rx queue statistics ,opcode id: 0x0B13. +@@ -604,16 +626,14 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) + struct hns3_tqp_stats *stats = &hw->tqp_stats; + struct hns3_rx_queue *rxq; + struct hns3_tx_queue *txq; +- uint64_t cnt; + uint16_t i; + int ret; + + /* Update imissed stats */ + ret = hns3_update_imissed_stats(hw, false); + if (ret) { +- hns3_err(hw, "update imissed stats failed, ret = %d", +- ret); +- return ret; ++ hns3_err(hw, "update imissed stats failed, ret = %d", ret); ++ goto out; + } + rte_stats->imissed = imissed_stats->rpu_rx_drop_cnt + + imissed_stats->ssu_rx_drop_cnt; +@@ -624,15 +644,12 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) + if (rxq == NULL) + continue; + +- cnt = hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG); +- /* +- * Read hardware and software in adjacent positions to minumize +- * the timing variance. +- */ ++ rte_spinlock_lock(&hw->stats_lock); ++ hns3_rcb_rx_ring_stats_get(rxq, stats); ++ rte_spinlock_unlock(&hw->stats_lock); ++ + rte_stats->ierrors += rxq->err_stats.l2_errors + + rxq->err_stats.pkt_len_errors; +- stats->rcb_rx_ring_pktnum_rcd += cnt; +- stats->rcb_rx_ring_pktnum[i] += cnt; + rte_stats->ibytes += rxq->basic_stats.bytes; + } + +@@ -642,17 +659,16 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) + if (txq == NULL) + continue; + +- cnt = hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG); +- stats->rcb_tx_ring_pktnum_rcd += cnt; +- stats->rcb_tx_ring_pktnum[i] += cnt; ++ rte_spinlock_lock(&hw->stats_lock); ++ hns3_rcb_tx_ring_stats_get(txq, stats); ++ rte_spinlock_unlock(&hw->stats_lock); + rte_stats->obytes += txq->basic_stats.bytes; + } + + ret = hns3_update_oerror_stats(hw, false); + if (ret) { +- hns3_err(hw, "update oerror stats failed, ret = %d", +- ret); +- return ret; ++ hns3_err(hw, "update oerror stats failed, ret = %d", ret); ++ goto out; + } + rte_stats->oerrors = hw->oerror_stats; + +@@ -667,8 +683,8 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) + rte_stats->opackets = stats->rcb_tx_ring_pktnum_rcd - + rte_stats->oerrors; + rte_stats->rx_nombuf = eth_dev->data->rx_mbuf_alloc_failed; +- +- return 0; ++out: ++ return ret; + } + + int +@@ -688,7 +704,7 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + ret = hns3_update_imissed_stats(hw, true); + if (ret) { + hns3_err(hw, "clear imissed stats failed, ret = %d", ret); +- return ret; ++ goto out; + } + + /* +@@ -697,9 +713,8 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + */ + ret = hns3_update_oerror_stats(hw, true); + if (ret) { +- hns3_err(hw, "clear oerror stats failed, ret = %d", +- ret); +- return ret; ++ hns3_err(hw, "clear oerror stats failed, ret = %d", ret); ++ goto out; + } + + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { +@@ -717,6 +732,7 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + if (rxq == NULL) + continue; + ++ rte_spinlock_lock(&hw->stats_lock); + memset(&rxq->basic_stats, 0, + sizeof(struct hns3_rx_basic_stats)); + +@@ -724,6 +740,7 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + (void)hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG); + rxq->err_stats.pkt_len_errors = 0; + rxq->err_stats.l2_errors = 0; ++ rte_spinlock_unlock(&hw->stats_lock); + } + + /* Clear all the stats of a txq in a loop to keep them synchronized */ +@@ -732,16 +749,20 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + if (txq == NULL) + continue; + ++ rte_spinlock_lock(&hw->stats_lock); + memset(&txq->basic_stats, 0, + sizeof(struct hns3_tx_basic_stats)); + + /* This register is read-clear */ + (void)hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG); ++ rte_spinlock_unlock(&hw->stats_lock); + } + ++ rte_spinlock_lock(&hw->stats_lock); + hns3_tqp_stats_clear(hw); +- +- return 0; ++ rte_spinlock_unlock(&hw->stats_lock); ++out: ++ return ret; + } + + static int +@@ -908,7 +929,6 @@ hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + struct hns3_rx_basic_stats *rxq_stats; + struct hns3_rx_queue *rxq; + uint16_t i, j; +- uint32_t cnt; + char *val; + + for (i = 0; i < dev->data->nb_rx_queues; i++) { +@@ -916,16 +936,10 @@ hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + if (rxq == NULL) + continue; + +- cnt = hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG); +- /* +- * Read hardware and software in adjacent positions to minimize +- * the time difference. +- */ ++ hns3_rcb_rx_ring_stats_get(rxq, stats); + rxq_stats = &rxq->basic_stats; + rxq_stats->errors = rxq->err_stats.l2_errors + + rxq->err_stats.pkt_len_errors; +- stats->rcb_rx_ring_pktnum_rcd += cnt; +- stats->rcb_rx_ring_pktnum[i] += cnt; + + /* + * If HW statistics are reset by stats_reset, but a lot of +@@ -955,7 +969,6 @@ hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + struct hns3_tx_basic_stats *txq_stats; + struct hns3_tx_queue *txq; + uint16_t i, j; +- uint32_t cnt; + char *val; + + for (i = 0; i < dev->data->nb_tx_queues; i++) { +@@ -963,9 +976,7 @@ hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + if (txq == NULL) + continue; + +- cnt = hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG); +- stats->rcb_tx_ring_pktnum_rcd += cnt; +- stats->rcb_tx_ring_pktnum[i] += cnt; ++ hns3_rcb_tx_ring_stats_get(txq, stats); + + txq_stats = &txq->basic_stats; + txq_stats->packets = stats->rcb_tx_ring_pktnum[i]; +@@ -1050,6 +1061,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + + count = 0; + ++ rte_spinlock_lock(&hw->stats_lock); + hns3_tqp_basic_stats_get(dev, xstats, &count); + + if (!hns->is_vf) { +@@ -1057,6 +1069,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + ret = hns3_query_update_mac_stats(dev); + if (ret < 0) { + hns3_err(hw, "Update Mac stats fail : %d", ret); ++ rte_spinlock_unlock(&hw->stats_lock); + return ret; + } + +@@ -1068,11 +1081,11 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + count++; + } + } ++ rte_spinlock_unlock(&hw->stats_lock); + + ret = hns3_update_imissed_stats(hw, false); + if (ret) { +- hns3_err(hw, "update imissed stats failed, ret = %d", +- ret); ++ hns3_err(hw, "update imissed stats failed, ret = %d", ret); + return ret; + } + +@@ -1101,8 +1114,10 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + } + } + ++ rte_spinlock_lock(&hw->stats_lock); + hns3_tqp_dfx_stats_get(dev, xstats, &count); + hns3_queue_stats_get(dev, xstats, &count); ++ rte_spinlock_unlock(&hw->stats_lock); + + return count; + } +@@ -1453,6 +1468,7 @@ int + hns3_dev_xstats_reset(struct rte_eth_dev *dev) + { + struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = &hns->hw; + int ret; + + /* Clear tqp stats */ +@@ -1460,20 +1476,22 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) + if (ret) + return ret; + ++ rte_spinlock_lock(&hw->stats_lock); + hns3_tqp_dfx_stats_clear(dev); + + /* Clear reset stats */ + memset(&hns->hw.reset.stats, 0, sizeof(struct hns3_reset_stats)); + + if (hns->is_vf) +- return 0; ++ goto out; + + /* HW registers are cleared on read */ + ret = hns3_mac_stats_reset(dev); +- if (ret) +- return ret; + +- return 0; ++out: ++ rte_spinlock_unlock(&hw->stats_lock); ++ ++ return ret; + } + + static int +@@ -1527,6 +1545,7 @@ hns3_stats_init(struct hns3_hw *hw) + { + int ret; + ++ rte_spinlock_init(&hw->stats_lock); + /* Hardware statistics of imissed registers cleared. */ + ret = hns3_update_imissed_stats(hw, true); + if (ret) { +@@ -1542,3 +1561,42 @@ hns3_stats_uninit(struct hns3_hw *hw) + { + hns3_tqp_stats_uninit(hw); + } ++ ++static void ++hns3_update_queues_stats(struct hns3_hw *hw) ++{ ++ struct rte_eth_dev_data *data = hw->data; ++ struct hns3_rx_queue *rxq; ++ struct hns3_tx_queue *txq; ++ uint16_t i; ++ ++ for (i = 0; i < data->nb_rx_queues; i++) { ++ rxq = data->rx_queues[i]; ++ if (rxq != NULL) ++ hns3_rcb_rx_ring_stats_get(rxq, &hw->tqp_stats); ++ } ++ ++ for (i = 0; i < data->nb_tx_queues; i++) { ++ txq = data->tx_queues[i]; ++ if (txq != NULL) ++ hns3_rcb_tx_ring_stats_get(txq, &hw->tqp_stats); ++ } ++} ++ ++/* ++ * Some hardware statistics registers are not 64-bit. If hardware statistics are ++ * not obtained for a long time, these statistics may be reversed. This function ++ * is used to update these hardware statistics in periodic task. ++ */ ++void ++hns3_update_hw_stats(struct hns3_hw *hw) ++{ ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ ++ rte_spinlock_lock(&hw->stats_lock); ++ if (!hns->is_vf) ++ hns3_update_mac_stats(hw); ++ ++ hns3_update_queues_stats(hw); ++ rte_spinlock_unlock(&hw->stats_lock); ++} +diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h +index e89dc97632..b5cd6188b4 100644 +--- a/drivers/net/hns3/hns3_stats.h ++++ b/drivers/net/hns3/hns3_stats.h +@@ -164,5 +164,6 @@ int hns3_stats_reset(struct rte_eth_dev *dev); + int hns3_stats_init(struct hns3_hw *hw); + void hns3_stats_uninit(struct hns3_hw *hw); + int hns3_query_mac_stats_reg_num(struct hns3_hw *hw); ++void hns3_update_hw_stats(struct hns3_hw *hw); + + #endif /* _HNS3_STATS_H_ */ +-- +2.30.0 + diff --git a/0077-net-hns3-fix-pseudo-sharing-between-threads.patch b/0077-net-hns3-fix-pseudo-sharing-between-threads.patch new file mode 100644 index 0000000..b191828 --- /dev/null +++ b/0077-net-hns3-fix-pseudo-sharing-between-threads.patch @@ -0,0 +1,45 @@ +From ec0147b5690e6cae2cc4555f78b87defee59c946 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 5 May 2022 20:27:03 +0800 +Subject: [PATCH] net/hns3: fix pseudo-sharing between threads + +Some fields in the end of 'struct hns3_rx_queue' and +'struct hns3_tx_queue' are not accessed in the I/O path. +But these fields may be accessed in other threads, which may lead to the +problem of cache pseudo-sharing of IO threads. This patch add a +cacheline alignment to avoid it. + +Fixes: 9261fd3caf1f ("net/hns3: improve IO path data cache usage") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index a000318357..62efc854e4 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -348,7 +348,7 @@ struct hns3_rx_queue { + * The following fields are not accessed in the I/O path, so they are + * placed at the end. + */ +- void *io_base; ++ void *io_base __rte_cache_aligned; + struct hns3_adapter *hns; + uint64_t rx_ring_phys_addr; /* RX ring DMA address */ + const struct rte_memzone *mz; +@@ -521,7 +521,7 @@ struct hns3_tx_queue { + * The following fields are not accessed in the I/O path, so they are + * placed at the end. + */ +- void *io_base; ++ void *io_base __rte_cache_aligned; + struct hns3_adapter *hns; + uint64_t tx_ring_phys_addr; /* TX ring DMA address */ + const struct rte_memzone *mz; +-- +2.33.0 + diff --git a/0078-net-hns3-fix-mbuf-free-on-Tx-done-cleanup.patch b/0078-net-hns3-fix-mbuf-free-on-Tx-done-cleanup.patch new file mode 100644 index 0000000..46b2c9b --- /dev/null +++ b/0078-net-hns3-fix-mbuf-free-on-Tx-done-cleanup.patch @@ -0,0 +1,50 @@ +From 2d287ea3c2301219c201617df15efa161deabf76 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 5 May 2022 20:27:04 +0800 +Subject: [PATCH] net/hns3: fix mbuf free on Tx done cleanup + +Currently, the hns3 PMD may free more mbufs than free_cnt parameter, +this is an incorrect implementation. This patch fixes it. + +Fixes: 0b77e8f3d364 ("net/hns3: optimize Tx performance") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index a28de06dfd..0c91e4721e 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4595,7 +4595,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) + static int + hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) + { +- uint16_t round_free_cnt; ++ uint16_t round_cnt; + uint32_t idx; + + if (free_cnt == 0 || free_cnt > txq->nb_tx_desc) +@@ -4604,13 +4604,13 @@ hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) + if (txq->tx_rs_thresh == 0) + return 0; + +- round_free_cnt = roundup(free_cnt, txq->tx_rs_thresh); +- for (idx = 0; idx < round_free_cnt; idx += txq->tx_rs_thresh) { ++ round_cnt = rounddown(free_cnt, txq->tx_rs_thresh); ++ for (idx = 0; idx < round_cnt; idx += txq->tx_rs_thresh) { + if (hns3_tx_free_useless_buffer(txq) != 0) + break; + } + +- return RTE_MIN(idx, free_cnt); ++ return idx; + } + + int +-- +2.33.0 + diff --git a/0079-net-hns3-fix-RSS-disable.patch b/0079-net-hns3-fix-RSS-disable.patch new file mode 100644 index 0000000..ebb61a1 --- /dev/null +++ b/0079-net-hns3-fix-RSS-disable.patch @@ -0,0 +1,214 @@ +From 75ccc3f3d7fa06901d5b768448be4dc9f31f550a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 5 May 2022 20:27:05 +0800 +Subject: [PATCH] net/hns3: fix RSS disable + +Currently, hns3 PMD disable RSS by resetting redirection table when user +set rss_hf to 0 so as to all packets go to queue 0. The implementation +may cause following problems: +1) the same type packet may go to different queue on the case of + disabling all tuples and partial tuples. The problem is determined by + hardware design. +2) affect the configuration of redirection table and user experience. + +For hns3 hardware, the packets with RSS disabled are always go to the +queue corresponding to first entry of the redirection table. Generally, +disable RSS should be implemented by disabling all tuples, This patch +fix the implementation. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 1 - + drivers/net/hns3/hns3_flow.c | 6 +-- + drivers/net/hns3/hns3_rss.c | 93 +++++++--------------------------- + 3 files changed, 18 insertions(+), 82 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 1d9b19d83e..4d5a595aab 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2015,7 +2015,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) + goto cfg_err; + } + +- /* When RSS is not configured, redirect the packet queue 0 */ + if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) { + conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; + rss_conf = conf->rx_adv_conf.rss_conf; +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index aba07aaa6f..feabac9f41 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1446,13 +1446,9 @@ hns3_disable_rss(struct hns3_hw *hw) + { + int ret; + +- /* Redirected the redirection table to queue 0 */ +- ret = hns3_rss_reset_indir_table(hw); ++ ret = hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, 0); + if (ret) + return ret; +- +- /* Disable RSS */ +- hw->rss_info.conf.types = 0; + hw->rss_dis_flag = true; + + return 0; +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 1493b10f96..1c703952b9 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -237,31 +237,6 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key) + return 0; + } + +-/* +- * Used to configure the tuple selection for RSS hash input. +- */ +-static int +-hns3_rss_set_input_tuple(struct hns3_hw *hw) +-{ +- struct hns3_rss_conf *rss_config = &hw->rss_info; +- struct hns3_rss_input_tuple_cmd *req; +- struct hns3_cmd_desc desc_tuple; +- int ret; +- +- hns3_cmd_setup_basic_desc(&desc_tuple, HNS3_OPC_RSS_INPUT_TUPLE, false); +- +- req = (struct hns3_rss_input_tuple_cmd *)desc_tuple.data; +- +- req->tuple_field = +- rte_cpu_to_le_64(rss_config->rss_tuple_sets.rss_tuple_fields); +- +- ret = hns3_cmd_send(hw, &desc_tuple, 1); +- if (ret) +- hns3_err(hw, "Configure RSS input tuple mode failed %d", ret); +- +- return ret; +-} +- + /* + * rss_indirection_table command function, opcode:0x0D07. + * Used to configure the indirection table of rss. +@@ -382,6 +357,8 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, + } + + tuple->rss_tuple_fields = rte_le_to_cpu_64(req->tuple_field); ++ /* Update supported flow types when set tuple success */ ++ hw->rss_info.conf.types = rss_hf; + + return 0; + } +@@ -402,7 +379,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; + struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets; +- struct hns3_rss_conf *rss_cfg = &hw->rss_info; + uint8_t key_len = rss_conf->rss_key_len; + uint64_t rss_hf = rss_conf->rss_hf; + uint8_t *key = rss_conf->rss_key; +@@ -416,22 +392,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + if (ret) + goto conf_err; + +- if (rss_cfg->conf.types && rss_hf == 0) { +- /* Disable RSS, reset indirection table by local variable */ +- ret = hns3_rss_reset_indir_table(hw); +- if (ret) +- goto conf_err; +- } else if (rss_hf && rss_cfg->conf.types == 0) { +- /* Enable RSS, restore indirection table by hw's config */ +- ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl, +- hw->rss_ind_tbl_size); +- if (ret) +- goto conf_err; +- } +- +- /* Update supported flow types when set tuple success */ +- rss_cfg->conf.types = rss_hf; +- + if (key) { + if (key_len != HNS3_RSS_KEY_SIZE) { + hns3_err(hw, "The hash key len(%u) is invalid", +@@ -697,7 +657,8 @@ hns3_config_rss(struct hns3_adapter *hns) + struct hns3_hw *hw = &hns->hw; + struct hns3_rss_conf *rss_cfg = &hw->rss_info; + uint8_t *hash_key = rss_cfg->key; +- int ret, ret1; ++ uint64_t rss_hf; ++ int ret; + + enum rte_eth_rx_mq_mode mq_mode = hw->data->dev_conf.rxmode.mq_mode; + +@@ -713,51 +674,31 @@ hns3_config_rss(struct hns3_adapter *hns) + break; + } + +- /* When RSS is off, redirect the packet queue 0 */ +- if (((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) == 0) +- hns3_rss_uninit(hns); +- + /* Configure RSS hash algorithm and hash key offset */ + ret = hns3_rss_set_algo_key(hw, hash_key); + if (ret) + return ret; + +- /* Configure the tuple selection for RSS hash input */ +- ret = hns3_rss_set_input_tuple(hw); ++ ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl, ++ hw->rss_ind_tbl_size); + if (ret) + return ret; + +- /* +- * When RSS is off, it doesn't need to configure rss redirection table +- * to hardware. +- */ +- if (((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)) { +- ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl, +- hw->rss_ind_tbl_size); +- if (ret) +- goto rss_tuple_uninit; +- } +- + ret = hns3_set_rss_tc_mode(hw); + if (ret) +- goto rss_indir_table_uninit; +- +- return ret; +- +-rss_indir_table_uninit: +- if (((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)) { +- ret1 = hns3_rss_reset_indir_table(hw); +- if (ret1 != 0) +- return ret; +- } +- +-rss_tuple_uninit: +- hns3_rss_tuple_uninit(hw); ++ return ret; + +- /* Disable RSS */ +- hw->rss_info.conf.types = 0; ++ /* ++ * When muli-queue RSS mode flag is not set or unsupported tuples are ++ * set, disable all tuples. ++ */ ++ rss_hf = hw->rss_info.conf.types; ++ if (!((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) || ++ !(rss_hf & HNS3_ETH_RSS_SUPPORT)) ++ rss_hf = 0; + +- return ret; ++ return hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, ++ rss_hf); + } + + /* +-- +2.33.0 + diff --git a/0080-net-hns3-fix-rollback-on-RSS-hash-update.patch b/0080-net-hns3-fix-rollback-on-RSS-hash-update.patch new file mode 100644 index 0000000..7e3e8b4 --- /dev/null +++ b/0080-net-hns3-fix-rollback-on-RSS-hash-update.patch @@ -0,0 +1,75 @@ +From 07f64b5f576a779c8c3df4ba45ad70c306dcb562 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 5 May 2022 20:27:06 +0800 +Subject: [PATCH] net/hns3: fix rollback on RSS hash update + +The RSS tuple isn't restored when RSS key length is invalid or setting +algo key failed. This patch fixes it. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rss.c | 24 +++++++++++++----------- + 1 file changed, 13 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 1c703952b9..4b2c24ace4 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -376,9 +376,9 @@ int + hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets; ++ uint64_t rss_hf_bk = hw->rss_info.conf.types; + uint8_t key_len = rss_conf->rss_key_len; + uint64_t rss_hf = rss_conf->rss_hf; + uint8_t *key = rss_conf->rss_key; +@@ -387,27 +387,29 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + if (hw->rss_dis_flag) + return -EINVAL; + ++ if (key && key_len != HNS3_RSS_KEY_SIZE) { ++ hns3_err(hw, "the hash key len(%u) is invalid, must be %u", ++ key_len, HNS3_RSS_KEY_SIZE); ++ return -EINVAL; ++ } ++ + rte_spinlock_lock(&hw->lock); + ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf); + if (ret) +- goto conf_err; ++ goto set_tuple_fail; + + if (key) { +- if (key_len != HNS3_RSS_KEY_SIZE) { +- hns3_err(hw, "The hash key len(%u) is invalid", +- key_len); +- ret = -EINVAL; +- goto conf_err; +- } + ret = hns3_rss_set_algo_key(hw, key); + if (ret) +- goto conf_err; ++ goto set_algo_key_fail; + } + rte_spinlock_unlock(&hw->lock); + + return 0; + +-conf_err: ++set_algo_key_fail: ++ (void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk); ++set_tuple_fail: + rte_spinlock_unlock(&hw->lock); + return ret; + } +-- +2.33.0 + diff --git a/0081-net-hns3-remove-redundant-RSS-tuple-field.patch b/0081-net-hns3-remove-redundant-RSS-tuple-field.patch new file mode 100644 index 0000000..462d198 --- /dev/null +++ b/0081-net-hns3-remove-redundant-RSS-tuple-field.patch @@ -0,0 +1,136 @@ +From 7a036b213b972e2c90e349f1eb90a30b98a740b4 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 5 May 2022 20:27:07 +0800 +Subject: [PATCH 21/25] net/hns3: remove redundant RSS tuple field + +The 'rss_tuple_fields' in struct struct hns3_rss_conf::rss_tuple_sets is +redundant. Because the enabled RSS tuple in PMD is already managed by +the 'types' in struct hns3_rss_conf::conf. This patch removes this +redundant variable. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_flow.c | 6 ++---- + drivers/net/hns3/hns3_rss.c | 12 ++++-------- + drivers/net/hns3/hns3_rss.h | 5 +---- + 3 files changed, 7 insertions(+), 16 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index a74b140563..65f8ee3ae1 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1446,7 +1446,7 @@ hns3_disable_rss(struct hns3_hw *hw) + { + int ret; + +- ret = hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, 0); ++ ret = hns3_set_rss_tuple_by_rss_hf(hw, 0); + if (ret) + return ret; + hw->rss_dis_flag = true; +@@ -1496,7 +1496,6 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, + static int + hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + { +- struct hns3_rss_tuple_cfg *tuple; + int ret; + + hns3_adjust_rss_key(hw, rss_config); +@@ -1512,8 +1511,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + + hw->rss_info.conf.func = rss_config->func; + +- tuple = &hw->rss_info.rss_tuple_sets; +- ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_config->types); ++ ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_config->types); + if (ret) + hns3_err(hw, "Update RSS tuples by rss hf failed %d", ret); + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 4b2c24ace4..e149c16bfe 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -310,8 +310,7 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw) + } + + int +-hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, +- struct hns3_rss_tuple_cfg *tuple, uint64_t rss_hf) ++hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf) + { + struct hns3_rss_input_tuple_cmd *req; + struct hns3_cmd_desc desc; +@@ -356,7 +355,6 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, + return ret; + } + +- tuple->rss_tuple_fields = rte_le_to_cpu_64(req->tuple_field); + /* Update supported flow types when set tuple success */ + hw->rss_info.conf.types = rss_hf; + +@@ -377,7 +375,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets; + uint64_t rss_hf_bk = hw->rss_info.conf.types; + uint8_t key_len = rss_conf->rss_key_len; + uint64_t rss_hf = rss_conf->rss_hf; +@@ -394,7 +391,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + } + + rte_spinlock_lock(&hw->lock); +- ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf); ++ ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_hf); + if (ret) + goto set_tuple_fail; + +@@ -408,7 +405,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + return 0; + + set_algo_key_fail: +- (void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk); ++ (void)hns3_set_rss_tuple_by_rss_hf(hw, rss_hf_bk); + set_tuple_fail: + rte_spinlock_unlock(&hw->lock); + return ret; +@@ -699,8 +696,7 @@ hns3_config_rss(struct hns3_adapter *hns) + !(rss_hf & HNS3_ETH_RSS_SUPPORT)) + rss_hf = 0; + +- return hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, +- rss_hf); ++ return hns3_set_rss_tuple_by_rss_hf(hw, rss_hf); + } + + /* +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 6f153a1b7b..7789f02a08 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -43,7 +43,6 @@ struct hns3_rss_conf { + struct rte_flow_action_rss conf; + uint8_t hash_algo; /* hash function type definited by hardware */ + uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */ +- struct hns3_rss_tuple_cfg rss_tuple_sets; + uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; + uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ + bool valid; /* check if RSS rule is valid */ +@@ -107,9 +106,7 @@ int hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, + int hns3_rss_reset_indir_table(struct hns3_hw *hw); + int hns3_config_rss(struct hns3_adapter *hns); + void hns3_rss_uninit(struct hns3_adapter *hns); +-int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, +- struct hns3_rss_tuple_cfg *tuple, +- uint64_t rss_hf); ++int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); + int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key); + int hns3_restore_rss_filter(struct rte_eth_dev *dev); + +-- +2.30.0 + diff --git a/0082-ethdev-fix-RSS-update-when-RSS-is-disabled.patch b/0082-ethdev-fix-RSS-update-when-RSS-is-disabled.patch new file mode 100644 index 0000000..0ff17c4 --- /dev/null +++ b/0082-ethdev-fix-RSS-update-when-RSS-is-disabled.patch @@ -0,0 +1,70 @@ +From 93e1ea6dfa99dea359b8d66123576a395c2c0acd Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 6 Apr 2022 14:57:00 +0800 +Subject: [PATCH] ethdev: fix RSS update when RSS is disabled + +The RTE_ETH_MQ_RX_RSS_FLAG flag is a switch to enable RSS. If the flag +is not set in dev_configure, RSS will be not configured and enabled. +However, RSS hash and reta can still be configured by ethdev ops to +enable RSS if the flag isn't set. The behavior is inconsistent. + +Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Reviewed-by: Ferruh Yigit +--- + lib/ethdev/rte_ethdev.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 29a3d80466..8520aec561 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -3867,6 +3867,7 @@ rte_eth_dev_rss_reta_update(uint16_t port_id, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) + { ++ enum rte_eth_rx_mq_mode mq_mode; + struct rte_eth_dev *dev; + int ret; + +@@ -3898,6 +3899,12 @@ rte_eth_dev_rss_reta_update(uint16_t port_id, + if (ret < 0) + return ret; + ++ mq_mode = dev->data->dev_conf.rxmode.mq_mode; ++ if (!(mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)) { ++ RTE_ETHDEV_LOG(ERR, "Multi-queue RSS mode isn't enabled.\n"); ++ return -ENOTSUP; ++ } ++ + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP); + return eth_err(port_id, (*dev->dev_ops->reta_update)(dev, reta_conf, + reta_size)); +@@ -3937,6 +3944,7 @@ rte_eth_dev_rss_hash_update(uint16_t port_id, + { + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; ++ enum rte_eth_rx_mq_mode mq_mode; + int ret; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); +@@ -3962,6 +3970,13 @@ rte_eth_dev_rss_hash_update(uint16_t port_id, + dev_info.flow_type_rss_offloads); + return -EINVAL; + } ++ ++ mq_mode = dev->data->dev_conf.rxmode.mq_mode; ++ if (!(mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)) { ++ RTE_ETHDEV_LOG(ERR, "Multi-queue RSS mode isn't enabled.\n"); ++ return -ENOTSUP; ++ } ++ + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP); + return eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev, + rss_conf)); +-- +2.33.0 + diff --git a/0083-net-hns3-remove-unnecessary-RSS-switch.patch b/0083-net-hns3-remove-unnecessary-RSS-switch.patch new file mode 100644 index 0000000..18f7e26 --- /dev/null +++ b/0083-net-hns3-remove-unnecessary-RSS-switch.patch @@ -0,0 +1,103 @@ +From ec1691494273ef4f9cb60ed24099196de1ce0cc4 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 6 Apr 2022 14:57:01 +0800 +Subject: [PATCH] net/hns3: remove unnecessary RSS switch + +Whether the RSS is enabled depends on RTE_ETH_MQ_RX_RSS_FLAG and packet +tuple are enabled. So the RSS switch is unnecessary. + +Fixes: 5e782bc2570c ("net/hns3: fix configuring RSS hash when rules are flushed") +Fixes: fd8196838763 ("net/hns3: fix configuring device with RSS enabled") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ethdev.c | 2 -- + drivers/net/hns3/hns3_ethdev.h | 1 - + drivers/net/hns3/hns3_ethdev_vf.c | 2 -- + drivers/net/hns3/hns3_flow.c | 1 - + drivers/net/hns3/hns3_rss.c | 3 --- + 5 files changed, 9 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 4d5a595aab..0b565a5614 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2018,7 +2018,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) + if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) { + conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; + rss_conf = conf->rx_adv_conf.rss_conf; +- hw->rss_dis_flag = false; + ret = hns3_dev_rss_hash_update(dev, &rss_conf); + if (ret) + goto cfg_err; +@@ -2824,7 +2823,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) + + hw->mac.media_type = cfg.media_type; + hw->rss_size_max = cfg.rss_size_max; +- hw->rss_dis_flag = false; + memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN); + hw->mac.phy_addr = cfg.phy_addr; + hw->dcb_info.num_pg = 1; +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index bb6ddd97ba..5e8a746514 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -526,7 +526,6 @@ struct hns3_hw { + + /* The configuration info of RSS */ + struct hns3_rss_conf rss_info; +- bool rss_dis_flag; /* disable rss flag. true: disable, false: enable */ + uint16_t rss_ind_tbl_size; + uint16_t rss_key_size; + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index f641e0dc36..589de0ab3a 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -495,7 +495,6 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) + /* When RSS is not configured, redirect the packet queue 0 */ + if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) { + conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; +- hw->rss_dis_flag = false; + rss_conf = conf->rx_adv_conf.rss_conf; + ret = hns3_dev_rss_hash_update(dev, &rss_conf); + if (ret) +@@ -997,7 +996,6 @@ hns3vf_get_configuration(struct hns3_hw *hw) + int ret; + + hw->mac.media_type = HNS3_MEDIA_TYPE_NONE; +- hw->rss_dis_flag = false; + + /* Get device capability */ + ret = hns3vf_get_capability(hw); +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 317f91fc71..86ebbf69b6 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1449,7 +1449,6 @@ hns3_disable_rss(struct hns3_hw *hw) + ret = hns3_set_rss_tuple_by_rss_hf(hw, 0); + if (ret) + return ret; +- hw->rss_dis_flag = true; + + return 0; + } +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index e149c16bfe..d376486a1d 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -381,9 +381,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + uint8_t *key = rss_conf->rss_key; + int ret; + +- if (hw->rss_dis_flag) +- return -EINVAL; +- + if (key && key_len != HNS3_RSS_KEY_SIZE) { + hns3_err(hw, "the hash key len(%u) is invalid, must be %u", + key_len, HNS3_RSS_KEY_SIZE); +-- +2.33.0 + diff --git a/0084-app-testpmd-check-statistics-query-before-printing.patch b/0084-app-testpmd-check-statistics-query-before-printing.patch new file mode 100644 index 0000000..871ecc8 --- /dev/null +++ b/0084-app-testpmd-check-statistics-query-before-printing.patch @@ -0,0 +1,96 @@ +From baef6bbfad1b9596c7051f5c1fcc308310296342 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Wed, 6 Apr 2022 16:45:36 +0800 +Subject: [PATCH] app/testpmd: check statistics query before printing + +In function 'fwd_stats_display', if function 'rte_eth_stats_get' fails, +'stats' is uncertainty value. The display result will be abnormal. + +This patch check the return value of 'rte_eth_stats_get' to avoid +display abnormal stats. + +Fixes: 53324971a14e ("app/testpmd: display/clear forwarding stats on demand") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +Acked-by: Aman Singh +--- + app/test-pmd/config.c | 10 ++++++++-- + app/test-pmd/testpmd.c | 16 ++++++++++++++-- + 2 files changed, 22 insertions(+), 4 deletions(-) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index cc8e7aa138..bd689f9f86 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -249,14 +249,20 @@ nic_stats_display(portid_t port_id) + diff_ns; + uint64_t mpps_rx, mpps_tx, mbps_rx, mbps_tx; + struct rte_eth_stats stats; +- + static const char *nic_stats_border = "########################"; ++ int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) { + print_valid_ports(); + return; + } +- rte_eth_stats_get(port_id, &stats); ++ ret = rte_eth_stats_get(port_id, &stats); ++ if (ret != 0) { ++ fprintf(stderr, ++ "%s: Error: failed to get stats (port %u): %d", ++ __func__, port_id, ret); ++ return; ++ } + printf("\n %s NIC statistics for port %-2d %s\n", + nic_stats_border, port_id, nic_stats_border); + +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index fe2ce19f99..79bb23264b 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -1982,6 +1982,7 @@ fwd_stats_display(void) + struct rte_port *port; + streamid_t sm_id; + portid_t pt_id; ++ int ret; + int i; + + memset(ports_stats, 0, sizeof(ports_stats)); +@@ -2013,7 +2014,13 @@ fwd_stats_display(void) + pt_id = fwd_ports_ids[i]; + port = &ports[pt_id]; + +- rte_eth_stats_get(pt_id, &stats); ++ ret = rte_eth_stats_get(pt_id, &stats); ++ if (ret != 0) { ++ fprintf(stderr, ++ "%s: Error: failed to get stats (port %u): %d", ++ __func__, pt_id, ret); ++ continue; ++ } + stats.ipackets -= port->stats.ipackets; + stats.opackets -= port->stats.opackets; + stats.ibytes -= port->stats.ibytes; +@@ -2108,11 +2115,16 @@ fwd_stats_reset(void) + { + streamid_t sm_id; + portid_t pt_id; ++ int ret; + int i; + + for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { + pt_id = fwd_ports_ids[i]; +- rte_eth_stats_get(pt_id, &ports[pt_id].stats); ++ ret = rte_eth_stats_get(pt_id, &ports[pt_id].stats); ++ if (ret != 0) ++ fprintf(stderr, ++ "%s: Error: failed to clear stats (port %u):%d", ++ __func__, pt_id, ret); + } + for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) { + struct fwd_stream *fs = fwd_streams[sm_id]; +-- +2.33.0 + diff --git a/0085-app-testpmd-fix-MTU-verification.patch b/0085-app-testpmd-fix-MTU-verification.patch new file mode 100644 index 0000000..4a04ea8 --- /dev/null +++ b/0085-app-testpmd-fix-MTU-verification.patch @@ -0,0 +1,110 @@ +From f0b3966a5072bd0a6c7f7e8652aef793afa4f4d0 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 6 Apr 2022 16:45:37 +0800 +Subject: [PATCH] app/testpmd: fix MTU verification + +The macro RTE_ETHER_MIN_LEN isn't the minimum value of MTU. But testpmd +used it when execute 'port config mtu 0 xx' cmd. This patch fixes it. + +Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Acked-by: Ferruh Yigit +--- + app/test-pmd/cmdline.c | 4 --- + app/test-pmd/config.c | 55 ++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 55 insertions(+), 4 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 6ffea8e21a..91e4090582 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -2050,10 +2050,6 @@ cmd_config_mtu_parsed(void *parsed_result, + { + struct cmd_config_mtu_result *res = parsed_result; + +- if (res->value < RTE_ETHER_MIN_LEN) { +- fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); +- return; +- } + port_mtu_set(res->port_id, res->value); + } + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index bd689f9f86..1b1e738f83 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -1254,6 +1254,57 @@ port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t reg_v) + display_port_reg_value(port_id, reg_off, reg_v); + } + ++static uint32_t ++eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu) ++{ ++ uint32_t overhead_len; ++ ++ if (max_mtu != UINT16_MAX && max_rx_pktlen > max_mtu) ++ overhead_len = max_rx_pktlen - max_mtu; ++ else ++ overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; ++ ++ return overhead_len; ++} ++ ++static int ++eth_dev_validate_mtu(uint16_t port_id, uint16_t mtu) ++{ ++ struct rte_eth_dev_info dev_info; ++ uint32_t overhead_len; ++ uint32_t frame_size; ++ int ret; ++ ++ ret = rte_eth_dev_info_get(port_id, &dev_info); ++ if (ret != 0) ++ return ret; ++ ++ if (mtu < dev_info.min_mtu) { ++ fprintf(stderr, ++ "MTU (%u) < device min MTU (%u) for port_id %u\n", ++ mtu, dev_info.min_mtu, port_id); ++ return -EINVAL; ++ } ++ if (mtu > dev_info.max_mtu) { ++ fprintf(stderr, ++ "MTU (%u) > device max MTU (%u) for port_id %u\n", ++ mtu, dev_info.max_mtu, port_id); ++ return -EINVAL; ++ } ++ ++ overhead_len = eth_dev_get_overhead_len(dev_info.max_rx_pktlen, ++ dev_info.max_mtu); ++ frame_size = mtu + overhead_len; ++ if (frame_size > dev_info.max_rx_pktlen) { ++ fprintf(stderr, ++ "Frame size (%u) > device max frame size (%u) for port_id %u\n", ++ frame_size, dev_info.max_rx_pktlen, port_id); ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ + void + port_mtu_set(portid_t port_id, uint16_t mtu) + { +@@ -1263,6 +1314,10 @@ port_mtu_set(portid_t port_id, uint16_t mtu) + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + ++ diag = eth_dev_validate_mtu(port_id, mtu); ++ if (diag != 0) ++ return; ++ + if (port->need_reconfig == 0) { + diag = rte_eth_dev_set_mtu(port_id, mtu); + if (diag != 0) { +-- +2.33.0 + diff --git a/0086-app-testpmd-fix-port-status-of-bonding-slave-device.patch b/0086-app-testpmd-fix-port-status-of-bonding-slave-device.patch new file mode 100644 index 0000000..170317a --- /dev/null +++ b/0086-app-testpmd-fix-port-status-of-bonding-slave-device.patch @@ -0,0 +1,152 @@ +From 82a85bc3c90744e171e0a16330685c4fd8c86a4a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 11 May 2022 10:14:34 +0800 +Subject: [PATCH 086/122] app/testpmd: fix port status of bonding slave device + +Starting or stopping a bonded port also starts or stops all active slaves +under the bonded port. If this port is a bonded device, we need to modify +the port status of all slaves. + +Fixes: 0e545d3047fe ("app/testpmd: check stopping port is not in bonding") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Acked-by: Aman Singh +Acked-by: Konstantin Ananyev +--- + app/test-pmd/cmdline.c | 1 + + app/test-pmd/testpmd.c | 73 +++++++++++++++++++++++++++++++++++++++--- + app/test-pmd/testpmd.h | 3 +- + 3 files changed, 72 insertions(+), 5 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 969a333c93..1991ee3446 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -6660,6 +6660,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result, + "Failed to enable promiscuous mode for port %u: %s - ignore\n", + port_id, rte_strerror(-ret)); + ++ ports[port_id].bond_flag = 1; + ports[port_id].need_setup = 0; + ports[port_id].port_status = RTE_PORT_STOPPED; + } +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index f9c025f97e..c4be9abe73 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -66,6 +66,9 @@ + #ifdef RTE_EXEC_ENV_WINDOWS + #include + #endif ++#ifdef RTE_NET_BOND ++#include ++#endif + + #include "testpmd.h" + +@@ -591,11 +594,58 @@ eth_dev_configure_mp(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, + return 0; + } + ++static int ++change_bonding_slave_port_status(portid_t bond_pid, bool is_stop) ++{ ++#ifdef RTE_NET_BOND ++ ++ portid_t slave_pids[RTE_MAX_ETHPORTS]; ++ struct rte_port *port; ++ int num_slaves; ++ portid_t slave_pid; ++ int i; ++ ++ num_slaves = rte_eth_bond_slaves_get(bond_pid, slave_pids, ++ RTE_MAX_ETHPORTS); ++ if (num_slaves < 0) { ++ fprintf(stderr, "Failed to get slave list for port = %u\n", ++ bond_pid); ++ return num_slaves; ++ } ++ ++ for (i = 0; i < num_slaves; i++) { ++ slave_pid = slave_pids[i]; ++ port = &ports[slave_pid]; ++ port->port_status = ++ is_stop ? RTE_PORT_STOPPED : RTE_PORT_STARTED; ++ } ++#else ++ RTE_SET_USED(bond_pid); ++ RTE_SET_USED(is_stop); ++#endif ++ return 0; ++} ++ + static int + eth_dev_start_mp(uint16_t port_id) + { +- if (is_proc_primary()) +- return rte_eth_dev_start(port_id); ++ int ret; ++ ++ if (is_proc_primary()) { ++ ret = rte_eth_dev_start(port_id); ++ if (ret != 0) ++ return ret; ++ ++ struct rte_port *port = &ports[port_id]; ++ ++ /* ++ * Starting a bonded port also starts all slaves under the bonded ++ * device. So if this port is bond device, we need to modify the ++ * port status of these slaves. ++ */ ++ if (port->bond_flag == 1) ++ return change_bonding_slave_port_status(port_id, false); ++ } + + return 0; + } +@@ -603,8 +653,23 @@ eth_dev_start_mp(uint16_t port_id) + static int + eth_dev_stop_mp(uint16_t port_id) + { +- if (is_proc_primary()) +- return rte_eth_dev_stop(port_id); ++ int ret; ++ ++ if (is_proc_primary()) { ++ ret = rte_eth_dev_stop(port_id); ++ if (ret != 0) ++ return ret; ++ ++ struct rte_port *port = &ports[port_id]; ++ ++ /* ++ * Stopping a bonded port also stops all slaves under the bonded ++ * device. So if this port is bond device, we need to modify the ++ * port status of these slaves. ++ */ ++ if (port->bond_flag == 1) ++ return change_bonding_slave_port_status(port_id, true); ++ } + + return 0; + } +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 2149ecd93a..9c24cb07e0 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -242,7 +242,8 @@ struct rte_port { + struct rte_eth_txconf tx_conf[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue tx configuration */ + struct rte_ether_addr *mc_addr_pool; /**< pool of multicast addrs */ + uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */ +- uint8_t slave_flag; /**< bonding slave port */ ++ uint8_t slave_flag : 1, /**< bonding slave port */ ++ bond_flag : 1; /**< port is bond device */ + struct port_flow *flow_list; /**< Associated flows. */ + struct port_indirect_action *actions_list; + /**< Associated indirect actions. */ +-- +2.22.0 + diff --git a/0087-ethdev-clarify-null-location-case-in-xstats-get.patch b/0087-ethdev-clarify-null-location-case-in-xstats-get.patch new file mode 100644 index 0000000..e2b5f97 --- /dev/null +++ b/0087-ethdev-clarify-null-location-case-in-xstats-get.patch @@ -0,0 +1,79 @@ +From 21658b863d246055c225286d9bce8a0a884fc9d9 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:49 +0800 +Subject: [PATCH 087/122] ethdev: clarify null location case in xstats get +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When xstats location is null in rte_eth_xstats_get() the return value +is not clearly specified. Some PMDs (eg. hns3/ipn3ke/mvpp2/axgbe) return +zero while others return the required number of elements. + +In this patch, special parameter combinations are restricted: + 1. highlight that xstats location may be null if and only if n is 0. + 2. amend n parameter description to specify that if n is lower than + the required number of elements, the function returns the required + number of elements. + 3. specify that if n is zero, the xstats must be NULL, the function + returns the required number of elements (a duplicate which should + help to not very attentive readers). + +Add sanity check for null xstats and non-zero n case on API level to +make it unnecessary to care about it in drivers. + +Fixes: ce757f5c9a4d ("ethdev: new method to retrieve extended statistics") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 4 +++- + lib/ethdev/rte_ethdev.h | 6 +++++- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index cea2f0b498..b4a331b671 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -3319,6 +3319,8 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + int ret; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); ++ if (xstats == NULL && n > 0) ++ return -EINVAL; + dev = &rte_eth_devices[port_id]; + + nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); +@@ -3335,7 +3337,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + * xstats struct. + */ + xcount = (*dev->dev_ops->xstats_get)(dev, +- xstats ? xstats + count : NULL, ++ (n > count) ? xstats + count : NULL, + (n > count) ? n - count : 0); + + if (xcount < 0) +diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h +index b8f135ba3f..082166ed42 100644 +--- a/lib/ethdev/rte_ethdev.h ++++ b/lib/ethdev/rte_ethdev.h +@@ -3105,9 +3105,13 @@ int rte_eth_xstats_get_names(uint16_t port_id, + * @param xstats + * A pointer to a table of structure of type *rte_eth_xstat* + * to be filled with device statistics ids and values. +- * This parameter can be set to NULL if n is 0. ++ * This parameter can be set to NULL if and only if n is 0. + * @param n + * The size of the xstats array (number of elements). ++ * If lower than the required number of elements, the function returns ++ * the required number of elements. ++ * If equal to zero, the xstats must be NULL, the function returns the ++ * required number of elements. + * @return + * - A positive value lower or equal to n: success. The return value + * is the number of entries filled in the stats table. +-- +2.22.0 + diff --git a/0088-ethdev-simplify-xstats-get-implementation.patch b/0088-ethdev-simplify-xstats-get-implementation.patch new file mode 100644 index 0000000..aa8c197 --- /dev/null +++ b/0088-ethdev-simplify-xstats-get-implementation.patch @@ -0,0 +1,50 @@ +From a6cce2fd3fb2eda175989fd4a6dbfdd470a08189 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:50 +0800 +Subject: [PATCH 088/122] ethdev: simplify xstats get implementation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Use eth_dev_get_xstats_basic_count() to retrieve generic statistics count. + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index b4a331b671..6110cd1893 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -3313,9 +3313,8 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + unsigned int n) + { + struct rte_eth_dev *dev; +- unsigned int count = 0, i; ++ unsigned int count, i; + signed int xcount = 0; +- uint16_t nb_rxqs, nb_txqs; + int ret; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); +@@ -3323,13 +3322,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + return -EINVAL; + dev = &rte_eth_devices[port_id]; + +- nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); +- nb_txqs = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); +- +- /* Return generic statistics */ +- count = RTE_NB_STATS; +- if (dev->data->dev_flags & RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS) +- count += (nb_rxqs * RTE_NB_RXQ_STATS) + (nb_txqs * RTE_NB_TXQ_STATS); ++ count = eth_dev_get_xstats_basic_count(dev); + + /* implemented by the driver */ + if (dev->dev_ops->xstats_get != NULL) { +-- +2.22.0 + diff --git a/0089-net-hns3-fix-xstats-get-return-if-xstats-is-null.patch b/0089-net-hns3-fix-xstats-get-return-if-xstats-is-null.patch new file mode 100644 index 0000000..4060a22 --- /dev/null +++ b/0089-net-hns3-fix-xstats-get-return-if-xstats-is-null.patch @@ -0,0 +1,58 @@ +From ae08d50d862073a8c53ed7ab4159f3125595667b Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:51 +0800 +Subject: [PATCH 089/122] net/hns3: fix xstats get return if xstats is null +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) +to retrieve the required number of elements, but currently hns3 PMD +returns zero when xstats is null. + +Dedicated check for xstats vs null is not required, since ethdev layer +guarantees that it may be null only if number of entries n is 0 (which +is definitely smaller than total xstats count). + +Fixes: 8839c5e202f3 ("net/hns3: support device stats") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/hns3/hns3_stats.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index 9b7ad067aa..e69761c8b3 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -1031,9 +1031,13 @@ hns3_imissed_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + * @praram xstats + * A pointer to a table of structure of type *rte_eth_xstat* + * to be filled with device statistics ids and values. +- * This parameter can be set to NULL if n is 0. ++ * This parameter can be set to NULL if and only if n is 0. + * @param n + * The size of the xstats array (number of elements). ++ * If lower than the required number of elements, the function returns the ++ * required number of elements. ++ * If equal to zero, the xstats parameter must be NULL, the function returns ++ * the required number of elements. + * @return + * 0 on fail, count(The size of the statistics elements) on success. + */ +@@ -1052,9 +1056,6 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + int count; + int ret; + +- if (xstats == NULL) +- return 0; +- + count = hns3_xstats_calc_num(dev); + if ((int)n < count) + return count; +-- +2.22.0 + diff --git a/0090-net-ipn3ke-fix-xstats-get-return-if-xstats-is-null.patch b/0090-net-ipn3ke-fix-xstats-get-return-if-xstats-is-null.patch new file mode 100644 index 0000000..c2c40e8 --- /dev/null +++ b/0090-net-ipn3ke-fix-xstats-get-return-if-xstats-is-null.patch @@ -0,0 +1,43 @@ +From 15b2772cfbdc62631556222a1c15491125b14e2f Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:52 +0800 +Subject: [PATCH 090/122] net/ipn3ke: fix xstats get return if xstats is null +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) +to retrieve the required number of elements, but currently ipn3ke PMD +returns zero when xstats is null. + +Dedicated check for xstats vs null is not required, since ethdev layer +guarantees that it may be null only if number of entries n is 0 (which +is definitely smaller than total xstats count). + +Fixes: 5a6d883878db ("net/ipn3ke: implement statistics") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/ipn3ke/ipn3ke_representor.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c +index de325c7d29..8139e13a23 100644 +--- a/drivers/net/ipn3ke/ipn3ke_representor.c ++++ b/drivers/net/ipn3ke/ipn3ke_representor.c +@@ -2218,9 +2218,6 @@ ipn3ke_rpst_xstats_get + struct ipn3ke_rpst_hw_port_stats hw_stats; + struct rte_eth_stats stats; + +- if (!xstats) +- return 0; +- + if (!ethdev) { + IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL"); + return -EINVAL; +-- +2.22.0 + diff --git a/0091-net-mvpp2-fix-xstats-get-return-if-xstats-is-null.patch b/0091-net-mvpp2-fix-xstats-get-return-if-xstats-is-null.patch new file mode 100644 index 0000000..43011cf --- /dev/null +++ b/0091-net-mvpp2-fix-xstats-get-return-if-xstats-is-null.patch @@ -0,0 +1,61 @@ +From ae30c4a7b550e0ac12857279c0a337d80f73261c Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:53 +0800 +Subject: [PATCH 091/122] net/mvpp2: fix xstats get return if xstats is null +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) +to retrieve the required number of elements, but currently mvpp2 PMD +returns zero when xstats is null. + +Remove the logic of "return zero when xstats is NULL", and add the logic +of "return the required number of entries when n is lower than the +required number of entries". + +Fixes: a77b5378cd41 ("net/mrvl: add extended statistics") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/mvpp2/mrvl_ethdev.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c +index 9c7fe13f7f..2a8fb6cbce 100644 +--- a/drivers/net/mvpp2/mrvl_ethdev.c ++++ b/drivers/net/mvpp2/mrvl_ethdev.c +@@ -1626,13 +1626,14 @@ mrvl_xstats_get(struct rte_eth_dev *dev, + { + struct mrvl_priv *priv = dev->data->dev_private; + struct pp2_ppio_statistics ppio_stats; +- unsigned int i; ++ unsigned int i, count; + +- if (!stats) +- return 0; ++ count = RTE_DIM(mrvl_xstats_tbl); ++ if (n < count) ++ return count; + + pp2_ppio_get_statistics(priv->ppio, &ppio_stats, 0); +- for (i = 0; i < n && i < RTE_DIM(mrvl_xstats_tbl); i++) { ++ for (i = 0; i < count; i++) { + uint64_t val; + + if (mrvl_xstats_tbl[i].size == sizeof(uint32_t)) +@@ -1648,7 +1649,7 @@ mrvl_xstats_get(struct rte_eth_dev *dev, + stats[i].value = val; + } + +- return n; ++ return count; + } + + /** +-- +2.22.0 + diff --git a/0092-net-axgbe-fix-xstats-get-return-if-xstats-is-null.patch b/0092-net-axgbe-fix-xstats-get-return-if-xstats-is-null.patch new file mode 100644 index 0000000..1b10848 --- /dev/null +++ b/0092-net-axgbe-fix-xstats-get-return-if-xstats-is-null.patch @@ -0,0 +1,56 @@ +From fc8702a84b7e794ab95aac021aa2cc3b4c92c5cd Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:54 +0800 +Subject: [PATCH 092/122] net/axgbe: fix xstats get return if xstats is null +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) +to retrieve the required number of elements, but currently axgbe PMD +returns zero when xstats is null. + +Remove the logic of "return zero when xstats is NULL", and add the logic +of "return the required number of entries when n is lower than the +required number of entries". + +Fixes: 9d1ef6b2e731 ("net/axgbe: add xstats") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/axgbe/axgbe_ethdev.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c +index 7d40c18a86..b209ab67cf 100644 +--- a/drivers/net/axgbe/axgbe_ethdev.c ++++ b/drivers/net/axgbe/axgbe_ethdev.c +@@ -1009,18 +1009,18 @@ axgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, + struct axgbe_port *pdata = dev->data->dev_private; + unsigned int i; + +- if (!stats) +- return 0; ++ if (n < AXGBE_XSTATS_COUNT) ++ return AXGBE_XSTATS_COUNT; + + axgbe_read_mmc_stats(pdata); + +- for (i = 0; i < n && i < AXGBE_XSTATS_COUNT; i++) { ++ for (i = 0; i < AXGBE_XSTATS_COUNT; i++) { + stats[i].id = i; + stats[i].value = *(u64 *)((uint8_t *)&pdata->mmc_stats + + axgbe_xstats_strings[i].offset); + } + +- return i; ++ return AXGBE_XSTATS_COUNT; + } + + static int +-- +2.22.0 + diff --git a/0093-ethdev-fix-memory-leak-in-xstats-telemetry.patch b/0093-ethdev-fix-memory-leak-in-xstats-telemetry.patch new file mode 100644 index 0000000..0cff404 --- /dev/null +++ b/0093-ethdev-fix-memory-leak-in-xstats-telemetry.patch @@ -0,0 +1,35 @@ +From 30aa792dda9b9e361f1d00012304ee78472c80f6 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:55 +0800 +Subject: [PATCH 093/122] ethdev: fix memory leak in xstats telemetry +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The 'eth_xstats' should be freed after telemetry dictionary setup. + +Fixes: c190daedb9b1 ("ethdev: add telemetry callbacks") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 6110cd1893..1db59d3a0e 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6259,6 +6259,7 @@ eth_dev_handle_port_xstats(const char *cmd __rte_unused, + for (i = 0; i < num_xstats; i++) + rte_tel_data_add_dict_u64(d, xstat_names[i].name, + eth_xstats[i].value); ++ free(eth_xstats); + return 0; + } + +-- +2.22.0 + diff --git a/0094-ethdev-fix-possible-null-pointer-access.patch b/0094-ethdev-fix-possible-null-pointer-access.patch new file mode 100644 index 0000000..977060c --- /dev/null +++ b/0094-ethdev-fix-possible-null-pointer-access.patch @@ -0,0 +1,37 @@ +From bfe03dd331bcfda1ab9fcbe32305eb515b5d7e32 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:56 +0800 +Subject: [PATCH 094/122] ethdev: fix possible null pointer access +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The rte_tel_data_alloc() may return NULL, so the caller should add +judgement for it. + +Fixes: 083b0b310b19 ("ethdev: add common stats for telemetry") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 1db59d3a0e..e55d11937e 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6166,6 +6166,8 @@ eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats, + { + int q; + struct rte_tel_data *q_data = rte_tel_data_alloc(); ++ if (q_data == NULL) ++ return; + rte_tel_data_start_array(q_data, RTE_TEL_U64_VAL); + for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++) + rte_tel_data_add_array_u64(q_data, q_stats[q]); +-- +2.22.0 + diff --git a/0095-net-cnxk-fix-possible-null-dereference-in-telemetry.patch b/0095-net-cnxk-fix-possible-null-dereference-in-telemetry.patch new file mode 100644 index 0000000..6147c58 --- /dev/null +++ b/0095-net-cnxk-fix-possible-null-dereference-in-telemetry.patch @@ -0,0 +1,37 @@ +From d3078f7a0fe21d94fa8d6027f2541311a990585a Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:57 +0800 +Subject: [PATCH 095/122] net/cnxk: fix possible null dereference in telemetry +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The return value of rte_tel_data_alloc() may be null pointer. +Add missing check vs null. + +Fixes: 5ea354a1f2cc ("net/cnxk: support telemetry") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/cnxk/cnxk_ethdev_telemetry.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c +index 83bc65848c..4fd9048643 100644 +--- a/drivers/net/cnxk/cnxk_ethdev_telemetry.c ++++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c +@@ -49,6 +49,8 @@ ethdev_tel_handle_info(const char *cmd __rte_unused, + rte_tel_data_add_dict_int(d, "n_ports", n_ports); + + i_data = rte_tel_data_alloc(); ++ if (i_data == NULL) ++ return -ENOMEM; + rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL); + + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { +-- +2.22.0 + diff --git a/0096-net-bonding-fix-mbuf-fast-free-usage.patch b/0096-net-bonding-fix-mbuf-fast-free-usage.patch new file mode 100644 index 0000000..5c76dd7 --- /dev/null +++ b/0096-net-bonding-fix-mbuf-fast-free-usage.patch @@ -0,0 +1,57 @@ +From 77eaa2e2b5ae1651abdaa0fb885bc3971e9e0587 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Wed, 25 May 2022 09:08:28 +0800 +Subject: [PATCH 096/122] net/bonding: fix mbuf fast free usage + +Usage of 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload has two +constraints: per-queue all mbufs comes from the same mempool and +has refcnt = 1. + +Bonding mode Broadcast, Tx mbuf has more than one refcnt. +Bonding mode 8023AD, It contains two mempools separately for LACP +packets and other packets. In Tx or Rx, Fast mbuf free will operate +mbuf from different mempool. + +This patch will prevent 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload +when in bonding mode Broadcast and mode 8023AD. + +Fixes: 78aecefed955 ("bond: move param parsing in configure step") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index c929b55768..0d6f0a30d1 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -3563,6 +3563,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev) + const char *name = dev->device->name; + struct bond_dev_private *internals = dev->data->dev_private; + struct rte_kvargs *kvlist = internals->kvlist; ++ uint64_t offloads; + int arg_count; + uint16_t port_id = dev - rte_eth_devices; + uint8_t agg_mode; +@@ -3613,6 +3614,16 @@ bond_ethdev_configure(struct rte_eth_dev *dev) + } + } + ++ offloads = dev->data->dev_conf.txmode.offloads; ++ if ((offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) && ++ (internals->mode == BONDING_MODE_8023AD || ++ internals->mode == BONDING_MODE_BROADCAST)) { ++ RTE_BOND_LOG(WARNING, ++ "bond mode broadcast & 8023AD don't support MBUF_FAST_FREE offload, force disable it."); ++ offloads &= ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; ++ dev->data->dev_conf.txmode.offloads = offloads; ++ } ++ + /* set the max_rx_pktlen */ + internals->max_rx_pktlen = internals->candidate_max_rx_pktlen; + +-- +2.22.0 + diff --git a/0097-ethdev-fix-port-state-when-stop.patch b/0097-ethdev-fix-port-state-when-stop.patch new file mode 100644 index 0000000..6e952a7 --- /dev/null +++ b/0097-ethdev-fix-port-state-when-stop.patch @@ -0,0 +1,36 @@ +From df393a512efe98bffa9b872844ea999507e51fba Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Tue, 3 May 2022 18:02:17 +0800 +Subject: [PATCH 097/122] ethdev: fix port state when stop + +Currently, 'dev_started' is always set to be 0 when dev stop, whether +it succeeded or failed. This is unreasonable and this patch fixed it. + +Fixes: 62024eb82756 ("ethdev: change stop operation callback to return int") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +Acked-by: Thomas Monjalon +Acked-by: Ferruh Yigit +--- + lib/ethdev/rte_ethdev.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index e55d11937e..2671f47738 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -1879,8 +1879,9 @@ rte_eth_dev_stop(uint16_t port_id) + /* point fast-path functions to dummy ones */ + eth_dev_fp_ops_reset(rte_eth_fp_ops + port_id); + +- dev->data->dev_started = 0; + ret = (*dev->dev_ops->dev_stop)(dev); ++ if (ret == 0) ++ dev->data->dev_started = 0; + rte_ethdev_trace_stop(port_id, ret); + + return ret; +-- +2.22.0 + diff --git a/0098-ethdev-fix-port-close-in-secondary-process.patch b/0098-ethdev-fix-port-close-in-secondary-process.patch new file mode 100644 index 0000000..9dcc92e --- /dev/null +++ b/0098-ethdev-fix-port-close-in-secondary-process.patch @@ -0,0 +1,40 @@ +From 8c0618338ca0b8a540980b4a475322f2cf48d9a6 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Wed, 1 Jun 2022 11:15:13 +0800 +Subject: [PATCH 098/122] ethdev: fix port close in secondary process + +Secondary process needs to close device to release process private +resources. But secondary process should not be obliged to wait for +device stop before closing ethdev. + +Fixes: febc855b358e ("ethdev: forbid closing started device") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 2671f47738..25c9f0c123 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -1921,7 +1921,13 @@ rte_eth_dev_close(uint16_t port_id) + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + +- if (dev->data->dev_started) { ++ /* ++ * Secondary process needs to close device to release process private ++ * resources. But secondary process should not be obliged to wait ++ * for device stop before closing ethdev. ++ */ ++ if (rte_eal_process_type() == RTE_PROC_PRIMARY && ++ dev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n", + port_id); + return -EINVAL; +-- +2.22.0 + diff --git a/0099-examples-dma-fix-MTU-configuration.patch b/0099-examples-dma-fix-MTU-configuration.patch new file mode 100644 index 0000000..6b6ecf3 --- /dev/null +++ b/0099-examples-dma-fix-MTU-configuration.patch @@ -0,0 +1,95 @@ +From f5e60c8f1d74d2a01f91fad546003eef876d71f1 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sun, 24 Apr 2022 14:07:39 +0800 +Subject: [PATCH 099/122] examples/dma: fix MTU configuration + +The MTU in dma App can be configured by 'max_frame_size' parameters which +have a default value(1518). It's not reasonable to use it directly as MTU. +This patch fix it. + +Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +--- + examples/dma/dmafwd.c | 43 +++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 39 insertions(+), 4 deletions(-) + +diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c +index d074acc905..cfd978ec6c 100644 +--- a/examples/dma/dmafwd.c ++++ b/examples/dma/dmafwd.c +@@ -117,7 +117,7 @@ static uint16_t nb_txd = TX_DEFAULT_RINGSIZE; + static volatile bool force_quit; + + static uint32_t dma_batch_sz = MAX_PKT_BURST; +-static uint32_t max_frame_size = RTE_ETHER_MAX_LEN; ++static uint32_t max_frame_size; + + /* ethernet addresses of ports */ + static struct rte_ether_addr dma_ports_eth_addr[RTE_MAX_ETHPORTS]; +@@ -851,6 +851,38 @@ assign_rings(void) + } + /* >8 End of assigning ring structures for packet exchanging. */ + ++static uint32_t ++eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu) ++{ ++ uint32_t overhead_len; ++ ++ if (max_mtu != UINT16_MAX && max_rx_pktlen > max_mtu) ++ overhead_len = max_rx_pktlen - max_mtu; ++ else ++ overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; ++ ++ return overhead_len; ++} ++ ++static int ++config_port_max_pkt_len(struct rte_eth_conf *conf, ++ struct rte_eth_dev_info *dev_info) ++{ ++ uint32_t overhead_len; ++ ++ if (max_frame_size == 0) ++ return 0; ++ ++ if (max_frame_size < RTE_ETHER_MIN_LEN) ++ return -1; ++ ++ overhead_len = eth_dev_get_overhead_len(dev_info->max_rx_pktlen, ++ dev_info->max_mtu); ++ conf->rxmode.mtu = max_frame_size - overhead_len; ++ ++ return 0; ++} ++ + /* + * Initializes a given port using global settings and with the RX buffers + * coming from the mbuf_pool passed as a parameter. +@@ -878,9 +910,6 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues) + struct rte_eth_dev_info dev_info; + int ret, i; + +- if (max_frame_size > local_port_conf.rxmode.mtu) +- local_port_conf.rxmode.mtu = max_frame_size; +- + /* Skip ports that are not enabled */ + if ((dma_enabled_port_mask & (1 << portid)) == 0) { + printf("Skipping disabled port %u\n", portid); +@@ -895,6 +924,12 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues) + rte_exit(EXIT_FAILURE, "Cannot get device info: %s, port=%u\n", + rte_strerror(-ret), portid); + ++ ret = config_port_max_pkt_len(&local_port_conf, &dev_info); ++ if (ret != 0) ++ rte_exit(EXIT_FAILURE, ++ "Invalid max frame size: %u (port %u)\n", ++ max_frame_size, portid); ++ + local_port_conf.rx_adv_conf.rss_conf.rss_hf &= + dev_info.flow_type_rss_offloads; + ret = rte_eth_dev_configure(portid, nb_queues, 1, &local_port_conf); +-- +2.22.0 + diff --git a/0100-examples-dma-fix-Tx-drop-statistics.patch b/0100-examples-dma-fix-Tx-drop-statistics.patch new file mode 100644 index 0000000..b82c3d4 --- /dev/null +++ b/0100-examples-dma-fix-Tx-drop-statistics.patch @@ -0,0 +1,79 @@ +From 5059d5fd27626e1d34b6dcaa2e74c7a5f1c7ee1f Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Sun, 24 Apr 2022 14:07:40 +0800 +Subject: [PATCH 100/122] examples/dma: fix Tx drop statistics + +The Tx drop statistic was designed to be collected by +rte_eth_dev_tx_buffer mechanism, but the application uses +rte_eth_tx_burst to send packets and this lead the Tx drop statistic +was not collected. + +This patch removes rte_eth_dev_tx_buffer mechanism to fix the problem. + +Fixes: 632bcd9b5d4f ("examples/ioat: print statistics") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Bruce Richardson +Acked-by: Kevin Laatz +--- + examples/dma/dmafwd.c | 27 +++++---------------------- + 1 file changed, 5 insertions(+), 22 deletions(-) + +diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c +index cfd978ec6c..d7d39b6a14 100644 +--- a/examples/dma/dmafwd.c ++++ b/examples/dma/dmafwd.c +@@ -122,7 +122,6 @@ static uint32_t max_frame_size; + /* ethernet addresses of ports */ + static struct rte_ether_addr dma_ports_eth_addr[RTE_MAX_ETHPORTS]; + +-static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; + struct rte_mempool *dma_pktmbuf_pool; + + /* Print out statistics for one port. */ +@@ -484,10 +483,13 @@ dma_tx_port(struct rxtx_port_config *tx_config) + + port_statistics.tx[tx_config->rxtx_port] += nb_tx; + +- /* Free any unsent packets. */ +- if (unlikely(nb_tx < nb_dq)) ++ if (unlikely(nb_tx < nb_dq)) { ++ port_statistics.tx_dropped[tx_config->rxtx_port] += ++ (nb_dq - nb_tx); ++ /* Free any unsent packets. */ + rte_mempool_put_bulk(dma_pktmbuf_pool, + (void *)&mbufs[nb_tx], nb_dq - nb_tx); ++ } + } + } + /* >8 End of transmitting packets from dmadev. */ +@@ -970,25 +972,6 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues) + "rte_eth_tx_queue_setup:err=%d,port=%u\n", + ret, portid); + +- /* Initialize TX buffers */ +- tx_buffer[portid] = rte_zmalloc_socket("tx_buffer", +- RTE_ETH_TX_BUFFER_SIZE(MAX_PKT_BURST), 0, +- rte_eth_dev_socket_id(portid)); +- if (tx_buffer[portid] == NULL) +- rte_exit(EXIT_FAILURE, +- "Cannot allocate buffer for tx on port %u\n", +- portid); +- +- rte_eth_tx_buffer_init(tx_buffer[portid], MAX_PKT_BURST); +- +- ret = rte_eth_tx_buffer_set_err_callback(tx_buffer[portid], +- rte_eth_tx_buffer_count_callback, +- &port_statistics.tx_dropped[portid]); +- if (ret < 0) +- rte_exit(EXIT_FAILURE, +- "Cannot set error callback for tx buffer on port %u\n", +- portid); +- + /* Start device. 8< */ + ret = rte_eth_dev_start(portid); + if (ret < 0) +-- +2.22.0 + diff --git a/0101-examples-dma-add-force-minimal-copy-size-parameter.patch b/0101-examples-dma-add-force-minimal-copy-size-parameter.patch new file mode 100644 index 0000000..b0c08c9 --- /dev/null +++ b/0101-examples-dma-add-force-minimal-copy-size-parameter.patch @@ -0,0 +1,127 @@ +From abc65cadf4b5ef0f898cb4851a100af26fbc55a6 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Sun, 24 Apr 2022 14:07:41 +0800 +Subject: [PATCH 101/122] examples/dma: add force minimal copy size parameter + +This patch adds force minimal copy size parameter +(-m/--force-min-copy-size), so when do copy by CPU or DMA, the real copy +size will be the maximum of mbuf's data_len and this parameter. + +This parameter was designed to compare the performance between CPU copy +and DMA copy. User could send small packets with a high rate to drive +the performance test. + +Signed-off-by: Chengwen Feng +Acked-by: Bruce Richardson +Acked-by: Kevin Laatz +--- + examples/dma/dmafwd.c | 30 +++++++++++++++++++++++++++--- + 1 file changed, 27 insertions(+), 3 deletions(-) + +diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c +index d7d39b6a14..9b17b40dbf 100644 +--- a/examples/dma/dmafwd.c ++++ b/examples/dma/dmafwd.c +@@ -25,6 +25,7 @@ + #define CMD_LINE_OPT_RING_SIZE "ring-size" + #define CMD_LINE_OPT_BATCH_SIZE "dma-batch-size" + #define CMD_LINE_OPT_FRAME_SIZE "max-frame-size" ++#define CMD_LINE_OPT_FORCE_COPY_SIZE "force-min-copy-size" + #define CMD_LINE_OPT_STATS_INTERVAL "stats-interval" + + /* configurable number of RX/TX ring descriptors */ +@@ -118,6 +119,7 @@ static volatile bool force_quit; + + static uint32_t dma_batch_sz = MAX_PKT_BURST; + static uint32_t max_frame_size; ++static uint32_t force_min_copy_size; + + /* ethernet addresses of ports */ + static struct rte_ether_addr dma_ports_eth_addr[RTE_MAX_ETHPORTS]; +@@ -205,7 +207,13 @@ print_stats(char *prgname) + "Rx Queues = %d, ", nb_queues); + status_strlen += snprintf(status_string + status_strlen, + sizeof(status_string) - status_strlen, +- "Ring Size = %d", ring_size); ++ "Ring Size = %d\n", ring_size); ++ status_strlen += snprintf(status_string + status_strlen, ++ sizeof(status_string) - status_strlen, ++ "Force Min Copy Size = %u Packet Data Room Size = %u", ++ force_min_copy_size, ++ rte_pktmbuf_data_room_size(dma_pktmbuf_pool) - ++ RTE_PKTMBUF_HEADROOM); + + memset(&ts, 0, sizeof(struct total_statistics)); + +@@ -303,7 +311,8 @@ static inline void + pktmbuf_sw_copy(struct rte_mbuf *src, struct rte_mbuf *dst) + { + rte_memcpy(rte_pktmbuf_mtod(dst, char *), +- rte_pktmbuf_mtod(src, char *), src->data_len); ++ rte_pktmbuf_mtod(src, char *), ++ RTE_MAX(src->data_len, force_min_copy_size)); + } + /* >8 End of perform packet copy there is a user-defined function. */ + +@@ -320,7 +329,9 @@ dma_enqueue_packets(struct rte_mbuf *pkts[], struct rte_mbuf *pkts_copy[], + ret = rte_dma_copy(dev_id, 0, + rte_pktmbuf_iova(pkts[i]), + rte_pktmbuf_iova(pkts_copy[i]), +- rte_pktmbuf_data_len(pkts[i]), 0); ++ RTE_MAX(rte_pktmbuf_data_len(pkts[i]), ++ force_min_copy_size), ++ 0); + + if (ret < 0) + break; +@@ -572,6 +583,7 @@ dma_usage(const char *prgname) + printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" + " -b --dma-batch-size: number of requests per DMA batch\n" + " -f --max-frame-size: max frame size\n" ++ " -m --force-min-copy-size: force a minimum copy length, even for smaller packets\n" + " -p --portmask: hexadecimal bitmask of ports to configure\n" + " -q NQ: number of RX queues per port (default is 1)\n" + " --[no-]mac-updating: Enable or disable MAC addresses updating (enabled by default)\n" +@@ -617,6 +629,7 @@ dma_parse_args(int argc, char **argv, unsigned int nb_ports) + "b:" /* dma batch size */ + "c:" /* copy type (sw|hw) */ + "f:" /* max frame size */ ++ "m:" /* force min copy size */ + "p:" /* portmask */ + "q:" /* number of RX queues per port */ + "s:" /* ring size */ +@@ -632,6 +645,7 @@ dma_parse_args(int argc, char **argv, unsigned int nb_ports) + {CMD_LINE_OPT_RING_SIZE, required_argument, NULL, 's'}, + {CMD_LINE_OPT_BATCH_SIZE, required_argument, NULL, 'b'}, + {CMD_LINE_OPT_FRAME_SIZE, required_argument, NULL, 'f'}, ++ {CMD_LINE_OPT_FORCE_COPY_SIZE, required_argument, NULL, 'm'}, + {CMD_LINE_OPT_STATS_INTERVAL, required_argument, NULL, 'i'}, + {NULL, 0, 0, 0} + }; +@@ -666,6 +680,10 @@ dma_parse_args(int argc, char **argv, unsigned int nb_ports) + } + break; + ++ case 'm': ++ force_min_copy_size = atoi(optarg); ++ break; ++ + /* portmask */ + case 'p': + dma_enabled_port_mask = dma_parse_portmask(optarg); +@@ -1064,6 +1082,12 @@ main(int argc, char **argv) + rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); + /* >8 End of allocates mempool to hold the mbufs. */ + ++ if (force_min_copy_size > ++ (uint32_t)(rte_pktmbuf_data_room_size(dma_pktmbuf_pool) - ++ RTE_PKTMBUF_HEADROOM)) ++ rte_exit(EXIT_FAILURE, ++ "Force min copy size > packet mbuf size\n"); ++ + /* Initialize each port. 8< */ + cfg.nb_ports = 0; + RTE_ETH_FOREACH_DEV(portid) +-- +2.22.0 + diff --git a/0102-dma-hisilicon-fix-index-returned-when-no-DMA-complet.patch b/0102-dma-hisilicon-fix-index-returned-when-no-DMA-complet.patch new file mode 100644 index 0000000..0924a01 --- /dev/null +++ b/0102-dma-hisilicon-fix-index-returned-when-no-DMA-complet.patch @@ -0,0 +1,54 @@ +From efe4049f48dd09ea069354f7e515bf7d81aa0f92 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 27 May 2022 11:40:52 +0800 +Subject: [PATCH 102/122] dma/hisilicon: fix index returned when no DMA + completed + +If no DMA request is completed, the ring_idx of the last completed +operation need returned by last_idx parameter. This patch fixes it. + +Fixes: 2db4f0b82360 ("dma/hisilicon: add data path") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + drivers/dma/hisilicon/hisi_dmadev.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index 9cef2cbfbe..f5c3cd914d 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -702,12 +702,12 @@ hisi_dma_completed(void *dev_private, + } + sq_head = (sq_head + 1) & hw->sq_depth_mask; + } ++ *last_idx = hw->cridx + i - 1; + if (i > 0) { + hw->cridx += i; +- *last_idx = hw->cridx - 1; + hw->sq_head = sq_head; ++ hw->completed += i; + } +- hw->completed += i; + + return i; + } +@@ -761,12 +761,12 @@ hisi_dma_completed_status(void *dev_private, + hw->status[sq_head] = HISI_DMA_STATUS_SUCCESS; + sq_head = (sq_head + 1) & hw->sq_depth_mask; + } ++ *last_idx = hw->cridx + cpl_num - 1; + if (likely(cpl_num > 0)) { + hw->cridx += cpl_num; +- *last_idx = hw->cridx - 1; + hw->sq_head = sq_head; ++ hw->completed += cpl_num; + } +- hw->completed += cpl_num; + + return cpl_num; + } +-- +2.22.0 + diff --git a/0103-test-dma-check-index-when-no-DMA-completed.patch b/0103-test-dma-check-index-when-no-DMA-completed.patch new file mode 100644 index 0000000..35b0e1f --- /dev/null +++ b/0103-test-dma-check-index-when-no-DMA-completed.patch @@ -0,0 +1,51 @@ +From 33e515de3d5d00094f934e10b2d15af8e52511b5 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 27 May 2022 11:40:53 +0800 +Subject: [PATCH 103/122] test/dma: check index when no DMA completed + +If no DMA request is completed, the ring_idx of the last completed +operation need returned by last_idx parameter. This patch adds +testcase for it. + +Signed-off-by: Chengwen Feng +Tested-by: Kevin Laatz +--- + app/test/test_dmadev.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c +index b206db27ae..d9e8f6d8c3 100644 +--- a/app/test/test_dmadev.c ++++ b/app/test/test_dmadev.c +@@ -177,6 +177,7 @@ do_multi_copies(int16_t dev_id, uint16_t vchan, + static int + test_enqueue_copies(int16_t dev_id, uint16_t vchan) + { ++ enum rte_dma_status_code status; + unsigned int i; + uint16_t id; + +@@ -215,6 +216,20 @@ test_enqueue_copies(int16_t dev_id, uint16_t vchan) + ERR_RETURN("Error:incorrect job id received, %u [expected %u]\n", + id, id_count); + ++ /* check for completed and id when no job done */ ++ if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 0) ++ ERR_RETURN("Error with rte_dma_completed when no job done\n"); ++ if (id != id_count) ++ ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", ++ id, id_count); ++ ++ /* check for completed_status and id when no job done */ ++ if (rte_dma_completed_status(dev_id, vchan, 1, &id, &status) != 0) ++ ERR_RETURN("Error with rte_dma_completed_status when no job done\n"); ++ if (id != id_count) ++ ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", ++ id, id_count); ++ + rte_pktmbuf_free(src); + rte_pktmbuf_free(dst); + +-- +2.22.0 + diff --git a/0104-dma-hisilicon-enhance-CQ-scan-robustness.patch b/0104-dma-hisilicon-enhance-CQ-scan-robustness.patch new file mode 100644 index 0000000..d4da26d --- /dev/null +++ b/0104-dma-hisilicon-enhance-CQ-scan-robustness.patch @@ -0,0 +1,54 @@ +From 5b84cc2a652f2646d2d4b4cdc1e6b00c13f4d790 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 27 May 2022 11:40:54 +0800 +Subject: [PATCH 104/122] dma/hisilicon: enhance CQ scan robustness + +The CQ (completion queue) descriptors were updated by hardware, and then +scanned by driver to retrieve hardware completion status. + +This patch enhances robustness by following: +1. replace while (true) with a finite loop to avoid potential dead loop. +2. check the csq_head field in CQ descriptor to avoid status array +overflows. + +Fixes: 2db4f0b82360 ("dma/hisilicon: add data path") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + drivers/dma/hisilicon/hisi_dmadev.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index f5c3cd914d..fbe09284ed 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -634,7 +634,7 @@ hisi_dma_scan_cq(struct hisi_dma_dev *hw) + uint16_t count = 0; + uint64_t misc; + +- while (true) { ++ while (count < hw->cq_depth) { + cqe = &hw->cqe[cq_head]; + misc = cqe->misc; + misc = rte_le_to_cpu_64(misc); +@@ -642,6 +642,16 @@ hisi_dma_scan_cq(struct hisi_dma_dev *hw) + break; + + csq_head = FIELD_GET(CQE_SQ_HEAD_MASK, misc); ++ if (unlikely(csq_head > hw->sq_depth_mask)) { ++ /** ++ * Defensive programming to prevent overflow of the ++ * status array indexed by csq_head. Only error logs ++ * are used for prompting. ++ */ ++ HISI_DMA_ERR(hw, "invalid csq_head:%u!\n", csq_head); ++ count = 0; ++ break; ++ } + if (unlikely(misc & CQE_STATUS_MASK)) + hw->status[csq_head] = FIELD_GET(CQE_STATUS_MASK, + misc); +-- +2.22.0 + diff --git a/0105-net-failsafe-fix-device-freeing.patch b/0105-net-failsafe-fix-device-freeing.patch new file mode 100644 index 0000000..8579b7c --- /dev/null +++ b/0105-net-failsafe-fix-device-freeing.patch @@ -0,0 +1,37 @@ +From f74659ac42dca5d47b03de3b22010a0f45434137 Mon Sep 17 00:00:00 2001 +From: Yunjian Wang +Date: Tue, 7 Jun 2022 14:50:49 +0800 +Subject: [PATCH 105/122] net/failsafe: fix device freeing + +The PMD destroy function was calling the release function, which frees +dev->data->dev_private, and then tries to free PRIV(dev)->intr_handle, +which causes the heap use after free issue. + +The free can be moved to before the release function is called. + +Fixes: d61138d4f0e ("drivers: remove direct access to interrupt handle") +Cc: stable@dpdk.org + +Signed-off-by: Yunjian Wang +Reviewed-by: Andrew Rybchenko +--- + drivers/net/failsafe/failsafe.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c +index 3c754a5f66..05cf533896 100644 +--- a/drivers/net/failsafe/failsafe.c ++++ b/drivers/net/failsafe/failsafe.c +@@ -308,8 +308,8 @@ fs_rte_eth_free(const char *name) + if (dev == NULL) + return 0; /* port already released */ + ret = failsafe_eth_dev_close(dev); +- rte_eth_dev_release_port(dev); + rte_intr_instance_free(PRIV(dev)->intr_handle); ++ rte_eth_dev_release_port(dev); + return ret; + } + +-- +2.22.0 + diff --git a/0106-net-tap-fix-device-freeing.patch b/0106-net-tap-fix-device-freeing.patch new file mode 100644 index 0000000..1468924 --- /dev/null +++ b/0106-net-tap-fix-device-freeing.patch @@ -0,0 +1,38 @@ +From 601f63e2f591a0b191c0ab0d4b39e826b15a0226 Mon Sep 17 00:00:00 2001 +From: Yunjian Wang +Date: Tue, 7 Jun 2022 14:50:57 +0800 +Subject: [PATCH 106/122] net/tap: fix device freeing + +The error path was calling rte_eth_dev_release_port() function, +which frees eth_dev->data->dev_private, and then tries to free +pmd->intr_handle, which causes the use after free issue. + +The free can be moved to before the release function is called. + +Fixes: d61138d4f0e ("drivers: remove direct access to interrupt handle") +Cc: stable@dpdk.org + +Signed-off-by: Xiangjun Meng +Signed-off-by: Yunjian Wang +Reviewed-by: Andrew Rybchenko +--- + drivers/net/tap/rte_eth_tap.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c +index f1b48cae82..ddca630574 100644 +--- a/drivers/net/tap/rte_eth_tap.c ++++ b/drivers/net/tap/rte_eth_tap.c +@@ -2099,8 +2099,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, + close(pmd->ioctl_sock); + /* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs = NULL; +- rte_eth_dev_release_port(dev); + rte_intr_instance_free(pmd->intr_handle); ++ rte_eth_dev_release_port(dev); + + error_exit_nodev: + TAP_LOG(ERR, "%s Unable to initialize %s", +-- +2.22.0 + diff --git a/0107-net-bonding-fix-RSS-inconsistent-between-bonded-and-.patch b/0107-net-bonding-fix-RSS-inconsistent-between-bonded-and-.patch new file mode 100644 index 0000000..08130df --- /dev/null +++ b/0107-net-bonding-fix-RSS-inconsistent-between-bonded-and-.patch @@ -0,0 +1,43 @@ +From 440f7e8f67673b8482d1b8e779ea93603f37c21f Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 8 Jun 2022 19:45:47 +0800 +Subject: [PATCH 107/122] net/bonding: fix RSS inconsistent between bonded and + slaves + +Currently, RSS configuration of slave is set only when RSS is enabled for +bonded port. If RSS is enabled for the slaves port before adding to the +bonded port with disabling RSS, it will run into that the RSS enabled state +of bonded and slaves port is inconsistent after starting bonded port. +So the RSS configuration of slave should also be set when RSS is disabled +for bonded port. + +Fixes: 734ce47f71e0 ("bonding: support RSS dynamic configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +Reviewed-by: Andrew Rybchenko +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 0d6f0a30d1..09636321cd 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -1711,6 +1711,12 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev, + bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf; + slave_eth_dev->data->dev_conf.rxmode.mq_mode = + bonded_eth_dev->data->dev_conf.rxmode.mq_mode; ++ } else { ++ slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len = 0; ++ slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL; ++ slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf = 0; ++ slave_eth_dev->data->dev_conf.rxmode.mq_mode = ++ bonded_eth_dev->data->dev_conf.rxmode.mq_mode; + } + + slave_eth_dev->data->dev_conf.rxmode.mtu = +-- +2.22.0 + diff --git a/0108-app-test-fix-bonding-RSS-test-when-disable-RSS.patch b/0108-app-test-fix-bonding-RSS-test-when-disable-RSS.patch new file mode 100644 index 0000000..435cc18 --- /dev/null +++ b/0108-app-test-fix-bonding-RSS-test-when-disable-RSS.patch @@ -0,0 +1,129 @@ +From 36c97bb881ddd7caaf8d9e3885a747880024c3fd Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 8 Jun 2022 19:45:48 +0800 +Subject: [PATCH 108/122] app/test: fix bonding RSS test when disable RSS + +The "test_rss_lazy" test is used for testing bonding RSS functions +when bonded port disable RSS. Currently, this test case can update +RSS functions of bonded and slave port if bonded port turns off RSS. +It is unreasonable and has been adjusted to be non-updateable in +following patch: +"93e1ea6dfa99 ethdev: fix RSS update when RSS is disabled" + +So this patch fixes this test code. + +Fixes: 43b630244e7e ("app/test: add dynamic bonding RSS configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + app/test/test_link_bonding_rssconf.c | 78 ++++++++++++++++++++++++++-- + 1 file changed, 73 insertions(+), 5 deletions(-) + +diff --git a/app/test/test_link_bonding_rssconf.c b/app/test/test_link_bonding_rssconf.c +index f9eae93973..a5aba6b2b9 100644 +--- a/app/test/test_link_bonding_rssconf.c ++++ b/app/test/test_link_bonding_rssconf.c +@@ -464,15 +464,85 @@ test_rss(void) + + TEST_ASSERT_SUCCESS(test_propagate(), "Propagation test failed"); + +- TEST_ASSERT(slave_remove_and_add() == 1, "New slave should be synced"); ++ TEST_ASSERT(slave_remove_and_add() == 1, "remove and add slaves success."); + + remove_slaves_and_stop_bonded_device(); + + return TEST_SUCCESS; + } + ++ ++/** ++ * Test RSS configuration over bonded and slaves. ++ */ ++static int ++test_rss_config_lazy(void) ++{ ++ struct rte_eth_rss_conf bond_rss_conf = {0}; ++ struct slave_conf *port; ++ uint8_t rss_key[40]; ++ uint64_t rss_hf; ++ int retval; ++ uint16_t i; ++ uint8_t n; ++ ++ retval = rte_eth_dev_info_get(test_params.bond_port_id, ++ &test_params.bond_dev_info); ++ TEST_ASSERT((retval == 0), "Error during getting device (port %u) info: %s\n", ++ test_params.bond_port_id, strerror(-retval)); ++ ++ rss_hf = test_params.bond_dev_info.flow_type_rss_offloads; ++ if (rss_hf != 0) { ++ bond_rss_conf.rss_key = NULL; ++ bond_rss_conf.rss_hf = rss_hf; ++ retval = rte_eth_dev_rss_hash_update(test_params.bond_port_id, ++ &bond_rss_conf); ++ TEST_ASSERT(retval != 0, "Succeeded in setting bonded port hash function"); ++ } ++ ++ /* Set all keys to zero for all slaves */ ++ FOR_EACH_PORT(n, port) { ++ port = &test_params.slave_ports[n]; ++ retval = rte_eth_dev_rss_hash_conf_get(port->port_id, ++ &port->rss_conf); ++ TEST_ASSERT_SUCCESS(retval, "Cannot get slaves RSS configuration"); ++ memset(port->rss_key, 0, sizeof(port->rss_key)); ++ port->rss_conf.rss_key = port->rss_key; ++ port->rss_conf.rss_key_len = sizeof(port->rss_key); ++ retval = rte_eth_dev_rss_hash_update(port->port_id, ++ &port->rss_conf); ++ TEST_ASSERT(retval != 0, "Succeeded in setting slaves RSS keys"); ++ } ++ ++ /* Set RSS keys for bonded port */ ++ memset(rss_key, 1, sizeof(rss_key)); ++ bond_rss_conf.rss_hf = rss_hf; ++ bond_rss_conf.rss_key = rss_key; ++ bond_rss_conf.rss_key_len = sizeof(rss_key); ++ ++ retval = rte_eth_dev_rss_hash_update(test_params.bond_port_id, ++ &bond_rss_conf); ++ TEST_ASSERT(retval != 0, "Succeeded in setting bonded port RSS keys"); ++ ++ /* Test RETA propagation */ ++ for (i = 0; i < RXTX_QUEUE_COUNT; i++) { ++ FOR_EACH_PORT(n, port) { ++ port = &test_params.slave_ports[n]; ++ retval = reta_set(port->port_id, (i + 1) % RXTX_QUEUE_COUNT, ++ port->dev_info.reta_size); ++ TEST_ASSERT(retval != 0, "Succeeded in setting slaves RETA"); ++ } ++ ++ retval = reta_set(test_params.bond_port_id, i % RXTX_QUEUE_COUNT, ++ test_params.bond_dev_info.reta_size); ++ TEST_ASSERT(retval != 0, "Succeeded in setting bonded port RETA"); ++ } ++ ++ return TEST_SUCCESS; ++} ++ + /** +- * Test propagation logic, when RX_RSS mq_mode is turned off for bonding port ++ * Test RSS function logic, when RX_RSS mq_mode is turned off for bonding port + */ + static int + test_rss_lazy(void) +@@ -493,9 +563,7 @@ test_rss_lazy(void) + TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bond_port_id), + "Failed to start bonding port (%d).", test_params.bond_port_id); + +- TEST_ASSERT_SUCCESS(test_propagate(), "Propagation test failed"); +- +- TEST_ASSERT(slave_remove_and_add() == 0, "New slave shouldn't be synced"); ++ TEST_ASSERT_SUCCESS(test_rss_config_lazy(), "Succeeded in setting RSS hash when RX_RSS mq_mode is turned off"); + + remove_slaves_and_stop_bonded_device(); + +-- +2.22.0 + diff --git a/0109-net-hns3-add-check-for-deferred-start-queue-when-rol.patch b/0109-net-hns3-add-check-for-deferred-start-queue-when-rol.patch new file mode 100644 index 0000000..bf17159 --- /dev/null +++ b/0109-net-hns3-add-check-for-deferred-start-queue-when-rol.patch @@ -0,0 +1,32 @@ +From 256f7ae943d4c15cca9cdf11ce84d4c8b536ad20 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:41 +0800 +Subject: [PATCH 109/122] net/hns3: add check for deferred start queue when + rollback + +Driver doesn't allocate mbufs for the deferred start queues, so no need to +free it when rollback. + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index d3fa4889d2..a9b997d32e 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -1202,6 +1202,9 @@ hns3_init_rx_queues(struct hns3_adapter *hns) + out: + for (j = 0; j < i; j++) { + rxq = (struct hns3_rx_queue *)hw->data->rx_queues[j]; ++ if (rxq->rx_deferred_start) ++ continue; ++ + hns3_rx_queue_release_mbufs(rxq); + } + +-- +2.22.0 + diff --git a/0110-net-hns3-remove-redundant-parentheses.patch b/0110-net-hns3-remove-redundant-parentheses.patch new file mode 100644 index 0000000..dd641e0 --- /dev/null +++ b/0110-net-hns3-remove-redundant-parentheses.patch @@ -0,0 +1,38 @@ +From e4fd147156e0b915ff6787824889bb552965ebfd Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:42 +0800 +Subject: [PATCH 110/122] net/hns3: remove redundant parentheses + +Remove redundant parentheses. + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index a9b997d32e..ee0aaaf7fc 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -170,7 +170,7 @@ hns3_fake_rx_queue_release(struct hns3_rx_queue *queue) + } + + /* free fake rx queue arrays */ +- if (idx == (hw->fkq_data.nb_fake_rx_queues - 1)) { ++ if (idx == hw->fkq_data.nb_fake_rx_queues - 1) { + hw->fkq_data.nb_fake_rx_queues = 0; + rte_free(hw->fkq_data.rx_queues); + hw->fkq_data.rx_queues = NULL; +@@ -197,7 +197,7 @@ hns3_fake_tx_queue_release(struct hns3_tx_queue *queue) + } + + /* free fake tx queue arrays */ +- if (idx == (hw->fkq_data.nb_fake_tx_queues - 1)) { ++ if (idx == hw->fkq_data.nb_fake_tx_queues - 1) { + hw->fkq_data.nb_fake_tx_queues = 0; + rte_free(hw->fkq_data.tx_queues); + hw->fkq_data.tx_queues = NULL; +-- +2.22.0 + diff --git a/0111-net-hns3-adjust-the-data-type-of-some-variables.patch b/0111-net-hns3-adjust-the-data-type-of-some-variables.patch new file mode 100644 index 0000000..061bda5 --- /dev/null +++ b/0111-net-hns3-adjust-the-data-type-of-some-variables.patch @@ -0,0 +1,227 @@ +From ca3ada1984f4c159ae2c7e94c82f38d0f239ba84 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:43 +0800 +Subject: [PATCH 111/122] net/hns3: adjust the data type of some variables + +Using the 'int' type and 'uint16_t' type to compare is insecure. +Make them consistent. + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_common.c | 4 ++-- + drivers/net/hns3/hns3_dcb.c | 2 +- + drivers/net/hns3/hns3_ethdev.c | 2 +- + drivers/net/hns3/hns3_regs.c | 2 +- + drivers/net/hns3/hns3_rss.c | 2 +- + drivers/net/hns3/hns3_rxtx.c | 23 ++++++++++++----------- + drivers/net/hns3/hns3_rxtx_vec.h | 4 ++-- + 7 files changed, 20 insertions(+), 19 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 9c86c00a04..edd16d8076 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -475,7 +475,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) + struct rte_ether_addr *addr; + uint16_t mac_addrs_capa; + int ret = 0; +- int i; ++ uint16_t i; + + mac_addrs_capa = + hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : HNS3_UC_MACADDR_NUM; +@@ -645,8 +645,8 @@ int + hns3_init_ring_with_vector(struct hns3_hw *hw) + { + uint16_t vec; ++ uint16_t i; + int ret; +- int i; + + /* + * In hns3 network engine, vector 0 is always the misc interrupt of this +diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c +index 136ada626b..d88757611c 100644 +--- a/drivers/net/hns3/hns3_dcb.c ++++ b/drivers/net/hns3/hns3_dcb.c +@@ -628,7 +628,7 @@ hns3_set_rss_size(struct hns3_hw *hw, uint16_t nb_rx_q) + struct hns3_rss_conf *rss_cfg = &hw->rss_info; + uint16_t rx_qnum_per_tc; + uint16_t used_rx_queues; +- int i; ++ uint16_t i; + + rx_qnum_per_tc = nb_rx_q / hw->num_tc; + if (rx_qnum_per_tc > hw->rss_size_max) { +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 29c9f96c05..97cf27d2a1 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2929,8 +2929,8 @@ hns3_map_tqps_to_func(struct hns3_hw *hw, uint16_t func_id, uint16_t tqp_pid, + static int + hns3_map_tqp(struct hns3_hw *hw) + { ++ uint16_t i; + int ret; +- int i; + + /* + * In current version, VF is not supported when PF is driven by DPDK +diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c +index 86a4cf74d5..6778e4cfc2 100644 +--- a/drivers/net/hns3/hns3_regs.c ++++ b/drivers/net/hns3/hns3_regs.c +@@ -294,8 +294,8 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + uint32_t *origin_data_ptr = data; + uint32_t reg_offset; ++ uint16_t i, j; + int reg_num; +- int i, j; + + /* fetching per-PF registers values from PF PCIe register space */ + reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t); +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index d376486a1d..4c546c9363 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -631,7 +631,7 @@ hns3_rss_set_default_args(struct hns3_hw *hw) + { + struct hns3_rss_conf *rss_cfg = &hw->rss_info; + uint16_t queue_num = hw->alloc_rss_size; +- int i; ++ uint16_t i; + + /* Default hash algorithm */ + rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index ee0aaaf7fc..510802be05 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -390,7 +390,7 @@ hns3_enable_all_queues(struct hns3_hw *hw, bool en) + struct hns3_tx_queue *txq; + uint32_t rcb_reg; + void *tqp_base; +- int i; ++ uint16_t i; + + for (i = 0; i < hw->cfg_max_queues; i++) { + if (hns3_dev_get_support(hw, INDEP_TXRX)) { +@@ -736,8 +736,8 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw) + #define HNS3_RESET_RCB_NOT_SUPPORT 0U + #define HNS3_RESET_ALL_TQP_SUCCESS 1U + uint8_t reset_status; ++ uint16_t i; + int ret; +- int i; + + ret = hns3_reset_rcb_cmd(hw, &reset_status); + if (ret) +@@ -774,7 +774,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw) + uint8_t reset_status; + uint8_t msg_data[2]; + int ret; +- int i; ++ uint16_t i; + + memset(msg_data, 0, sizeof(uint16_t)); + ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data, +@@ -806,7 +806,8 @@ int + hns3_reset_all_tqps(struct hns3_adapter *hns) + { + struct hns3_hw *hw = &hns->hw; +- int ret, i; ++ uint16_t i; ++ int ret; + + /* Disable all queues before reset all queues */ + for (i = 0; i < hw->cfg_max_queues; i++) { +@@ -1037,7 +1038,7 @@ hns3_dev_all_rx_queue_intr_enable(struct hns3_hw *hw, bool en) + { + struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + uint16_t nb_rx_q = hw->data->nb_rx_queues; +- int i; ++ uint16_t i; + + if (dev->data->dev_conf.intr_conf.rxq == 0) + return; +@@ -1121,7 +1122,7 @@ static void + hns3_init_txq(struct hns3_tx_queue *txq) + { + struct hns3_desc *desc; +- int i; ++ uint16_t i; + + /* Clear tx bd */ + desc = txq->tx_ring; +@@ -1145,7 +1146,7 @@ hns3_init_tx_ring_tc(struct hns3_adapter *hns) + + for (i = 0; i < HNS3_MAX_TC_NUM; i++) { + struct hns3_tc_queue_info *tc_queue = &hw->tc_queue[i]; +- int j; ++ uint16_t j; + + if (!tc_queue->enable) + continue; +@@ -1442,7 +1443,7 @@ hns3_alloc_txq_and_dma_zone(struct rte_eth_dev *dev, + struct hns3_tx_queue *txq; + struct hns3_desc *desc; + unsigned int tx_desc; +- int i; ++ uint16_t i; + + txq = rte_zmalloc_socket(q_info->type, sizeof(struct hns3_tx_queue), + RTE_CACHE_LINE_SIZE, q_info->socket_id); +@@ -1679,7 +1680,7 @@ hns3_dev_release_mbufs(struct hns3_adapter *hns) + struct rte_eth_dev_data *dev_data = hns->hw.data; + struct hns3_rx_queue *rxq; + struct hns3_tx_queue *txq; +- int i; ++ uint16_t i; + + if (dev_data->rx_queues) + for (i = 0; i < dev_data->nb_rx_queues; i++) { +@@ -3086,7 +3087,7 @@ hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq) + uint16_t tx_next_use = txq->next_to_use; + struct hns3_entry *tx_entry = &txq->sw_ring[tx_next_clean]; + struct hns3_desc *desc = &txq->tx_ring[tx_next_clean]; +- int i; ++ uint16_t i; + + if (tx_next_use >= tx_next_clean && + tx_next_use < tx_next_clean + txq->tx_rs_thresh) +@@ -3984,7 +3985,7 @@ hns3_tx_free_buffer_simple(struct hns3_tx_queue *txq) + struct hns3_entry *tx_entry; + struct hns3_desc *desc; + uint16_t tx_next_clean; +- int i; ++ uint16_t i; + + while (1) { + if (HNS3_GET_TX_QUEUE_PEND_BD_NUM(txq) < txq->tx_rs_thresh) +diff --git a/drivers/net/hns3/hns3_rxtx_vec.h b/drivers/net/hns3/hns3_rxtx_vec.h +index 4985a7cae8..d13f18627d 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec.h ++++ b/drivers/net/hns3/hns3_rxtx_vec.h +@@ -15,7 +15,7 @@ hns3_tx_bulk_free_buffers(struct hns3_tx_queue *txq) + struct hns3_entry *tx_entry; + struct rte_mbuf *m; + int nb_free = 0; +- int i; ++ uint16_t i; + + tx_entry = &txq->sw_ring[txq->next_to_clean]; + if (txq->mbuf_fast_free_en) { +@@ -56,7 +56,7 @@ static inline void + hns3_tx_free_buffers(struct hns3_tx_queue *txq) + { + struct hns3_desc *tx_desc; +- int i; ++ uint16_t i; + + /* + * All mbufs can be released only when the VLD bits of all +-- +2.22.0 + diff --git a/0112-net-hns3-fix-an-unreasonable-memset.patch b/0112-net-hns3-fix-an-unreasonable-memset.patch new file mode 100644 index 0000000..4f93c18 --- /dev/null +++ b/0112-net-hns3-fix-an-unreasonable-memset.patch @@ -0,0 +1,30 @@ +From d3b39f5bca72e2ecd16527d3c63e1b2e620830bc Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:44 +0800 +Subject: [PATCH 112/122] net/hns3: fix an unreasonable memset + +Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 510802be05..5a2cfe5a54 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw) + int ret; + uint16_t i; + +- memset(msg_data, 0, sizeof(uint16_t)); ++ memset(msg_data, 0, sizeof(msg_data)); + ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data, + sizeof(msg_data), true, &reset_status, + sizeof(reset_status)); +-- +2.22.0 + diff --git a/0113-net-hns3-remove-duplicate-definition.patch b/0113-net-hns3-remove-duplicate-definition.patch new file mode 100644 index 0000000..68289f1 --- /dev/null +++ b/0113-net-hns3-remove-duplicate-definition.patch @@ -0,0 +1,71 @@ +From 1650e90eef5c7be334b29d276479c8f4d997ba02 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:45 +0800 +Subject: [PATCH 113/122] net/hns3: remove duplicate definition + +The default hash key array is defined twice. Remove the extra one. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_flow.c | 9 --------- + drivers/net/hns3/hns3_rss.c | 6 ++---- + drivers/net/hns3/hns3_rss.h | 2 ++ + 3 files changed, 4 insertions(+), 13 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 12afc24910..e994cac314 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -10,15 +10,6 @@ + #include "hns3_logs.h" + #include "hns3_flow.h" + +-/* Default default keys */ +-static uint8_t hns3_hash_key[] = { +- 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, +- 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0, +- 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4, +- 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C, +- 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA +-}; +- + static const uint8_t full_mask[VNI_OR_TNI_LEN] = { 0xFF, 0xFF, 0xFF }; + static const uint8_t zero_mask[VNI_OR_TNI_LEN] = { 0x00, 0x00, 0x00 }; + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 4c546c9363..1003daf03e 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -9,10 +9,8 @@ + #include "hns3_ethdev.h" + #include "hns3_logs.h" + +-/* +- * The hash key used for rss initialization. +- */ +-static const uint8_t hns3_hash_key[] = { ++/* Default hash keys */ ++const uint8_t hns3_hash_key[] = { + 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, + 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0, + 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4, +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 7789f02a08..5b90d3a628 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -88,6 +88,8 @@ static inline uint32_t roundup_pow_of_two(uint32_t x) + return 1UL << fls(x - 1); + } + ++extern const uint8_t hns3_hash_key[]; ++ + struct hns3_adapter; + + int hns3_dev_rss_hash_update(struct rte_eth_dev *dev, +-- +2.22.0 + diff --git a/0114-net-hns3-fix-code-check-warning.patch b/0114-net-hns3-fix-code-check-warning.patch new file mode 100644 index 0000000..2ea529d --- /dev/null +++ b/0114-net-hns3-fix-code-check-warning.patch @@ -0,0 +1,31 @@ +From 1c88a050b04c9dc12458d4127052f542a0919739 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Wed, 1 Jun 2022 11:52:46 +0800 +Subject: [PATCH 114/122] net/hns3: fix code check warning + +In bitwise operation, "val" should be an unsigned type. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ptp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index 1442241a4e..0b0061bba5 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -81,7 +81,7 @@ hns3_timesync_configure(struct hns3_adapter *hns, bool en) + struct hns3_hw *hw = &hns->hw; + struct hns3_pf *pf = &hns->pf; + struct hns3_cmd_desc desc; +- int val; ++ uint32_t val; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_PTP_MODE, false); +-- +2.22.0 + diff --git a/0115-net-hns3-fix-return-value-for-unsupported-tuple.patch b/0115-net-hns3-fix-return-value-for-unsupported-tuple.patch new file mode 100644 index 0000000..3cef721 --- /dev/null +++ b/0115-net-hns3-fix-return-value-for-unsupported-tuple.patch @@ -0,0 +1,32 @@ +From a0077b01d8ba2b5310ca6fdee7c61e40ae6eeca3 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:47 +0800 +Subject: [PATCH 115/122] net/hns3: fix return value for unsupported tuple + +Driver should return false for unsupported tuple. + +Fixes: 18a4b4c3fa80 ("net/hns3: add default to switch when parsing fd tuple") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_fdir.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index 2a7978ac07..a0d6598e57 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -631,7 +631,7 @@ static bool hns3_fd_convert_tuple(struct hns3_hw *hw, + break; + default: + hns3_warn(hw, "not support tuple of (%u)", tuple); +- break; ++ return false; + } + return true; + } +-- +2.22.0 + diff --git a/0116-net-hns3-modify-a-function-name.patch b/0116-net-hns3-modify-a-function-name.patch new file mode 100644 index 0000000..464012a --- /dev/null +++ b/0116-net-hns3-modify-a-function-name.patch @@ -0,0 +1,74 @@ +From 25cd4e3af8f0c5e86bff599ea31a0e4024cf03d2 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:48 +0800 +Subject: [PATCH 116/122] net/hns3: modify a function name + +The meaning of the "hns3_get_count" function is not precise enough. +Change from "hns3_get_count" to "hns3_fd_get_count". + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_fdir.c | 2 +- + drivers/net/hns3/hns3_fdir.h | 2 +- + drivers/net/hns3/hns3_flow.c | 6 +++--- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index a0d6598e57..762b89a51e 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -1099,7 +1099,7 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns) + return 0; + } + +-int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value) ++int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value) + { + struct hns3_fd_get_cnt_cmd *req; + struct hns3_cmd_desc desc; +diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h +index 3376c40c8e..4d18759160 100644 +--- a/drivers/net/hns3/hns3_fdir.h ++++ b/drivers/net/hns3/hns3_fdir.h +@@ -184,7 +184,7 @@ void hns3_fdir_filter_uninit(struct hns3_adapter *hns); + int hns3_fdir_filter_program(struct hns3_adapter *hns, + struct hns3_fdir_rule *rule, bool del); + int hns3_clear_all_fdir_filter(struct hns3_adapter *hns); +-int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); ++int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); + int hns3_restore_all_fdir_filter(struct hns3_adapter *hns); + + #endif /* _HNS3_FDIR_H_ */ +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index e994cac314..b60ad596dc 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -164,13 +164,13 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t indirect, uint32_t id, + "Counter id is used, indirect flag not match"); + /* Clear the indirect counter on first use. */ + if (cnt->indirect && cnt->ref_cnt == 1) +- (void)hns3_get_count(hw, id, &value); ++ (void)hns3_fd_get_count(hw, id, &value); + cnt->ref_cnt++; + return 0; + } + + /* Clear the counter by read ops because the counter is read-clear */ +- ret = hns3_get_count(hw, id, &value); ++ ret = hns3_fd_get_count(hw, id, &value); + if (ret) + return rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, +@@ -210,7 +210,7 @@ hns3_counter_query(struct rte_eth_dev *dev, struct rte_flow *flow, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Can't find counter id"); + +- ret = hns3_get_count(&hns->hw, flow->counter_id, &value); ++ ret = hns3_fd_get_count(&hns->hw, flow->counter_id, &value); + if (ret) { + rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, + NULL, "Read counter fail."); +-- +2.22.0 + diff --git a/0117-net-hns3-unify-the-code-wrap-style.patch b/0117-net-hns3-unify-the-code-wrap-style.patch new file mode 100644 index 0000000..3a0dbd4 --- /dev/null +++ b/0117-net-hns3-unify-the-code-wrap-style.patch @@ -0,0 +1,516 @@ +From 9a1166d20bc7b1b07207ec2f8c1964f59053570b Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:49 +0800 +Subject: [PATCH 117/122] net/hns3: unify the code wrap style + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_cmd.c | 2 +- + drivers/net/hns3/hns3_common.c | 10 +++++----- + drivers/net/hns3/hns3_dcb.c | 5 ++--- + drivers/net/hns3/hns3_ethdev.c | 18 ++++++++---------- + drivers/net/hns3/hns3_ethdev_vf.c | 23 +++++++++++------------ + drivers/net/hns3/hns3_fdir.c | 26 +++++++++++++------------- + drivers/net/hns3/hns3_flow.c | 10 ++++------ + drivers/net/hns3/hns3_rxtx.c | 28 +++++++++++++--------------- + drivers/net/hns3/hns3_stats.c | 28 ++++++++++++++-------------- + 9 files changed, 71 insertions(+), 79 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index 96f8f38cbb..e3d096d9cb 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -108,7 +108,7 @@ hns3_alloc_cmd_queue(struct hns3_hw *hw, int ring_type) + ret = hns3_alloc_cmd_desc(hw, ring); + if (ret) + hns3_err(hw, "descriptor %s alloc error %d", +- (ring_type == HNS3_TYPE_CSQ) ? "CSQ" : "CRQ", ret); ++ (ring_type == HNS3_TYPE_CSQ) ? "CSQ" : "CRQ", ret); + + return ret; + } +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index edd16d8076..7a65db907e 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -604,7 +604,7 @@ hns3_init_mac_addrs(struct rte_eth_dev *dev) + 0); + if (dev->data->mac_addrs == NULL) { + hns3_err(hw, "failed to allocate %zx bytes needed to store MAC addresses", +- sizeof(struct rte_ether_addr) * mac_addrs_capa); ++ sizeof(struct rte_ether_addr) * mac_addrs_capa); + return -ENOMEM; + } + +@@ -680,16 +680,16 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) + ret = hw->ops.bind_ring_with_vector(hw, vec, false, + HNS3_RING_TYPE_TX, i); + if (ret) { +- PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with " +- "vector: %u, ret=%d", i, vec, ret); ++ PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with vector: %u, ret=%d", ++ i, vec, ret); + return ret; + } + + ret = hw->ops.bind_ring_with_vector(hw, vec, false, + HNS3_RING_TYPE_RX, i); + if (ret) { +- PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with " +- "vector: %u, ret=%d", i, vec, ret); ++ PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with vector: %u, ret=%d", ++ i, vec, ret); + return ret; + } + } +diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c +index d88757611c..b22f618e0a 100644 +--- a/drivers/net/hns3/hns3_dcb.c ++++ b/drivers/net/hns3/hns3_dcb.c +@@ -876,9 +876,8 @@ hns3_dcb_pri_tc_base_dwrr_cfg(struct hns3_hw *hw) + + ret = hns3_dcb_pri_weight_cfg(hw, i, dwrr); + if (ret) { +- hns3_err(hw, +- "fail to send priority weight cmd: %d, ret = %d", +- i, ret); ++ hns3_err(hw, "fail to send priority weight cmd: %d, ret = %d", ++ i, ret); + return ret; + } + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 97cf27d2a1..8a8f3f1950 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -1627,7 +1627,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, + ret = hw->ops.del_uc_mac_addr(hw, oaddr); + if (ret) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- oaddr); ++ oaddr); + hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", + mac_str, ret); + +@@ -1659,7 +1659,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, + ret_val = hw->ops.del_uc_mac_addr(hw, mac_addr); + if (ret_val) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_warn(hw, + "Failed to roll back to del setted mac addr(%s): %d", + mac_str, ret_val); +@@ -1670,7 +1670,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, + if (ret_val) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr); + hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", +- mac_str, ret_val); ++ mac_str, ret_val); + } + rte_spinlock_unlock(&hw->lock); + +@@ -1747,7 +1747,7 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) + if (ret == -ENOSPC) + hns3_err(hw, "mc mac vlan table is full"); + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_err(hw, "failed to add mc mac addr(%s): %d", mac_str, ret); + } + +@@ -2676,9 +2676,8 @@ hns3_check_dev_specifications(struct hns3_hw *hw) + { + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_err(hw, "the size of hash lookup table configured (%u)" +- " exceeds the maximum(%u)", hw->rss_ind_tbl_size, +- HNS3_RSS_IND_TBL_SIZE_MAX); ++ hns3_err(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", ++ hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } + +@@ -3916,7 +3915,7 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) + ret = hns3_enable_vlan_filter(hns, false); + if (ret) { + hns3_err(hw, "failed to enable promiscuous mode due to " +- "failure to disable vlan filter, ret = %d", ++ "failure to disable vlan filter, ret = %d", + ret); + err = hns3_set_promisc_mode(hw, false, allmulti); + if (err) +@@ -5993,8 +5992,7 @@ hns3_reset_service(void *param) + timersub(&tv, &tv_start, &tv_delta); + msec = hns3_clock_calctime_ms(&tv_delta); + if (msec > HNS3_RESET_PROCESS_MS) +- hns3_err(hw, "%d handle long time delta %" PRIu64 +- " ms time=%ld.%.6ld", ++ hns3_err(hw, "%d handle long time delta %" PRIu64 " ms time=%ld.%.6ld", + hw->reset.level, msec, + tv.tv_sec, tv.tv_usec); + if (ret == -EAGAIN) +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 0c170797f4..7323e47f15 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -142,7 +142,7 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op) + pos = hns3vf_find_pci_capability(device, PCI_CAP_ID_MSIX); + if (pos) { + ret = rte_pci_read_config(device, &control, sizeof(control), +- (pos + PCI_MSIX_FLAGS)); ++ (pos + PCI_MSIX_FLAGS)); + if (ret < 0) { + PMD_INIT_LOG(ERR, "Failed to read PCI offset 0x%x", + (pos + PCI_MSIX_FLAGS)); +@@ -154,10 +154,10 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op) + else + control &= ~PCI_MSIX_FLAGS_ENABLE; + ret = rte_pci_write_config(device, &control, sizeof(control), +- (pos + PCI_MSIX_FLAGS)); ++ (pos + PCI_MSIX_FLAGS)); + if (ret < 0) { + PMD_INIT_LOG(ERR, "failed to write PCI offset 0x%x", +- (pos + PCI_MSIX_FLAGS)); ++ (pos + PCI_MSIX_FLAGS)); + return -ENXIO; + } + +@@ -199,7 +199,7 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) + false, NULL, 0); + if (ret) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_err(hw, "failed to add uc mac addr(%s), ret = %d", + mac_str, ret); + } +@@ -242,11 +242,11 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, + if (ret == -EPERM) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, + old_addr); +- hns3_warn(hw, "Has permanet mac addr(%s) for vf", ++ hns3_warn(hw, "Has permanent mac addr(%s) for vf", + mac_str); + } else { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_err(hw, "Failed to set mac addr(%s) for vf: %d", + mac_str, ret); + } +@@ -293,7 +293,7 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw, + NULL, 0); + if (ret) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d", + mac_str, ret); + } +@@ -715,9 +715,8 @@ hns3vf_check_dev_specifications(struct hns3_hw *hw) + { + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_warn(hw, "the size of hash lookup table configured (%u)" +- " exceeds the maximum(%u)", hw->rss_ind_tbl_size, +- HNS3_RSS_IND_TBL_SIZE_MAX); ++ hns3_warn(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", ++ hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } + +@@ -1168,8 +1167,8 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask) + int ret = 0; + + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { +- hns3_err(hw, "vf set vlan offload failed during resetting, " +- "mask = 0x%x", mask); ++ hns3_err(hw, "vf set vlan offload failed during resetting, mask = 0x%x", ++ mask); + return -EIO; + } + +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index 762b89a51e..30e5e66772 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -321,7 +321,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + break; + default: + hns3_err(hw, "Unsupported flow director mode %u", +- pf->fdir.fd_cfg.fd_mode); ++ pf->fdir.fd_cfg.fd_mode); + return -EOPNOTSUPP; + } + +@@ -337,7 +337,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + BIT(INNER_SRC_IP) | BIT(INNER_DST_IP) | + BIT(INNER_SRC_PORT) | BIT(INNER_DST_PORT); + hns3_dbg(hw, "fdir tuple: inner"); ++ "ip_proto ip_tos l4_src_port l4_dst_port>"); + + /* If use max 400bit key, we can support tuples for ether type */ + if (pf->fdir.fd_cfg.max_key_length == MAX_KEY_LENGTH) { +@@ -348,8 +348,8 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + BIT(OUTER_TUN_VNI) | BIT(OUTER_TUN_FLOW_ID) | + BIT(OUTER_ETH_TYPE) | BIT(OUTER_IP_PROTO); + hns3_dbg(hw, "fdir tuple more: inner outer"); ++ "vlan_tag2 sctp_tag> outer"); + } + + /* roce_type is used to filter roce frames +@@ -367,12 +367,11 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + if (ret) + return ret; + +- hns3_dbg(hw, "fdir: stage1 stage2", +- pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1], +- pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1], +- pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2], +- pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]); ++ hns3_dbg(hw, "fdir: stage1 stage2", ++ pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1], ++ pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1], ++ pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2], ++ pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]); + + return hns3_set_fd_key_config(hns); + } +@@ -420,7 +419,7 @@ static int hns3_fd_tcam_config(struct hns3_hw *hw, bool sel_x, int loc, + ret = hns3_cmd_send(hw, desc, FD_TCAM_CMD_NUM); + if (ret) + hns3_err(hw, "Config tcam key fail, ret=%d loc=%d add=%d", +- ret, loc, is_add); ++ ret, loc, is_add); + return ret; + } + +@@ -673,6 +672,7 @@ static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg, + } else if (i == VLAN_NUMBER) { + uint32_t vlan_tag; + uint8_t vlan_num; ++ + if (rule->key_conf.spec.tunnel_type == 0) + vlan_num = rule->key_conf.vlan_num; + else +@@ -758,14 +758,14 @@ static int hns3_config_key(struct hns3_adapter *hns, + ret = hns3_fd_tcam_config(hw, false, rule->location, key_y, true); + if (ret) { + hns3_err(hw, "Config fd key_y fail, loc=%u, ret=%d", +- rule->queue_id, ret); ++ rule->queue_id, ret); + return ret; + } + + ret = hns3_fd_tcam_config(hw, true, rule->location, key_x, true); + if (ret) + hns3_err(hw, "Config fd key_x fail, loc=%u, ret=%d", +- rule->queue_id, ret); ++ rule->queue_id, ret); + return ret; + } + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index b60ad596dc..5e0a9bc93f 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -285,9 +285,8 @@ hns3_handle_action_queue(struct rte_eth_dev *dev, + + queue = (const struct rte_flow_action_queue *)action->conf; + if (queue->index >= hw->data->nb_rx_queues) { +- hns3_err(hw, "queue ID(%u) is greater than number of " +- "available queue (%u) in driver.", +- queue->index, hw->data->nb_rx_queues); ++ hns3_err(hw, "queue ID(%u) is greater than number of available queue (%u) in driver.", ++ queue->index, hw->data->nb_rx_queues); + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + action, "Invalid queue ID in PF"); +@@ -1656,9 +1655,8 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) + } + + if (rss_rule_fail_cnt) { +- hns3_err(hw, "fail to delete all RSS filters, success num = %d " +- "fail num = %d", rss_rule_succ_cnt, +- rss_rule_fail_cnt); ++ hns3_err(hw, "fail to delete all RSS filters, success num = %d fail num = %d", ++ rss_rule_succ_cnt, rss_rule_fail_cnt); + ret = -EIO; + } + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 5a2cfe5a54..3f576fbf4b 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -606,8 +606,8 @@ hns3_send_reset_tqp_cmd(struct hns3_hw *hw, uint16_t queue_id, bool enable) + hns3_set_bit(req->reset_req, HNS3_TQP_RESET_B, enable ? 1 : 0); + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) +- hns3_err(hw, "send tqp reset cmd error, queue_id = %u, " +- "ret = %d", queue_id, ret); ++ hns3_err(hw, "send tqp reset cmd error, queue_id = %u, ret = %d", ++ queue_id, ret); + + return ret; + } +@@ -627,8 +627,8 @@ hns3_get_tqp_reset_status(struct hns3_hw *hw, uint16_t queue_id, + + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) { +- hns3_err(hw, "get tqp reset status error, queue_id = %u, " +- "ret = %d.", queue_id, ret); ++ hns3_err(hw, "get tqp reset status error, queue_id = %u, ret = %d.", ++ queue_id, ret); + return ret; + } + *reset_status = hns3_get_bit(req->ready_to_reset, HNS3_TQP_RESET_B); +@@ -669,7 +669,7 @@ hns3pf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id) + if (!reset_status) { + ret = -ETIMEDOUT; + hns3_err(hw, "reset tqp timeout, queue_id = %u, ret = %d", +- queue_id, ret); ++ queue_id, ret); + goto tqp_reset_fail; + } + +@@ -752,15 +752,14 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw) + for (i = 0; i < hw->cfg_max_queues; i++) { + ret = hns3pf_reset_tqp(hw, i); + if (ret) { +- hns3_err(hw, +- "fail to reset tqp, queue_id = %d, ret = %d.", +- i, ret); ++ hns3_err(hw, "fail to reset tqp, queue_id = %d, ret = %d.", ++ i, ret); + return ret; + } + } + } else if (reset_status != HNS3_RESET_ALL_TQP_SUCCESS) { + hns3_err(hw, "fail to reset all tqps, reset_status = %u.", +- reset_status); ++ reset_status); + return -EIO; + } + +@@ -813,9 +812,8 @@ hns3_reset_all_tqps(struct hns3_adapter *hns) + for (i = 0; i < hw->cfg_max_queues; i++) { + ret = hns3_tqp_enable(hw, i, false); + if (ret) { +- hns3_err(hw, +- "fail to disable tqps before tqps reset, ret = %d.", +- ret); ++ hns3_err(hw, "fail to disable tqps before tqps reset, ret = %d.", ++ ret); + return ret; + } + } +@@ -922,9 +920,9 @@ hns3_reset_queue(struct hns3_hw *hw, uint16_t queue_id, + } + + if (!reset_status) { +- hns3_err(hw, "reset queue timeout, queue_id = %u, " +- "queue_type = %s", queue_id, +- queue_type == HNS3_RING_TYPE_TX ? "Tx" : "Rx"); ++ hns3_err(hw, "reset queue timeout, queue_id = %u, queue_type = %s", ++ queue_id, ++ queue_type == HNS3_RING_TYPE_TX ? "Tx" : "Rx"); + ret = -ETIMEDOUT; + goto queue_reset_fail; + } +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index e69761c8b3..bf8af4531f 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -507,8 +507,8 @@ hns3_update_port_rx_ssu_drop_stats(struct hns3_hw *hw) + + req = (struct hns3_query_ssu_cmd *)desc[0].data; + cnt = rte_le_to_cpu_32(req->oq_drop_cnt) + +- rte_le_to_cpu_32(req->full_drop_cnt) + +- rte_le_to_cpu_32(req->part_drop_cnt); ++ rte_le_to_cpu_32(req->full_drop_cnt) + ++ rte_le_to_cpu_32(req->part_drop_cnt); + + stats->ssu_rx_drop_cnt += cnt; + +@@ -532,8 +532,8 @@ hns3_update_port_tx_ssu_drop_stats(struct hns3_hw *hw) + + req = (struct hns3_query_ssu_cmd *)desc[0].data; + cnt = rte_le_to_cpu_32(req->oq_drop_cnt) + +- rte_le_to_cpu_32(req->full_drop_cnt) + +- rte_le_to_cpu_32(req->part_drop_cnt); ++ rte_le_to_cpu_32(req->full_drop_cnt) + ++ rte_le_to_cpu_32(req->part_drop_cnt); + + hw->oerror_stats += cnt; + +@@ -1337,8 +1337,8 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + len = cnt_stats * sizeof(struct rte_eth_xstat); + values_copy = rte_zmalloc("hns3_xstats_values", len, 0); + if (values_copy == NULL) { +- hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed " +- "to store statistics values", len); ++ hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed to store statistics values", ++ len); + return -ENOMEM; + } + +@@ -1359,8 +1359,8 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + + for (i = 0; i < size; i++) { + if (ids[i] >= cnt_stats) { +- hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, " +- "should < %u", i, ids[i], cnt_stats); ++ hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, should < %u", ++ i, ids[i], cnt_stats); + rte_free(values_copy); + return -EINVAL; + } +@@ -1419,8 +1419,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, + len = cnt_stats * sizeof(struct rte_eth_xstat_name); + names_copy = rte_zmalloc("hns3_xstats_names", len, 0); + if (names_copy == NULL) { +- hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed " +- "to store statistics names", len); ++ hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed to store statistics names", ++ len); + return -ENOMEM; + } + +@@ -1428,8 +1428,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, + + for (i = 0; i < size; i++) { + if (ids[i] >= cnt_stats) { +- hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, " +- "should < %u", i, ids[i], cnt_stats); ++ hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, should < %u", ++ i, ids[i], cnt_stats); + rte_free(names_copy); + return -EINVAL; + } +@@ -1501,14 +1501,14 @@ hns3_tqp_stats_init(struct hns3_hw *hw) + struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats; + + tqp_stats->rcb_rx_ring_pktnum = rte_zmalloc("hns3_rx_ring_pkt_num", +- sizeof(uint64_t) * hw->tqps_num, 0); ++ sizeof(uint64_t) * hw->tqps_num, 0); + if (tqp_stats->rcb_rx_ring_pktnum == NULL) { + hns3_err(hw, "failed to allocate rx_ring pkt_num."); + return -ENOMEM; + } + + tqp_stats->rcb_tx_ring_pktnum = rte_zmalloc("hns3_tx_ring_pkt_num", +- sizeof(uint64_t) * hw->tqps_num, 0); ++ sizeof(uint64_t) * hw->tqps_num, 0); + if (tqp_stats->rcb_tx_ring_pktnum == NULL) { + hns3_err(hw, "failed to allocate tx_ring pkt_num."); + rte_free(tqp_stats->rcb_rx_ring_pktnum); +-- +2.22.0 + diff --git a/0118-net-hns3-fix-a-segfault-from-secondary-process.patch b/0118-net-hns3-fix-a-segfault-from-secondary-process.patch new file mode 100644 index 0000000..89bcf9d --- /dev/null +++ b/0118-net-hns3-fix-a-segfault-from-secondary-process.patch @@ -0,0 +1,39 @@ +From 0526fc076a0e45de04597722128d4a2b87a44255 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:50 +0800 +Subject: [PATCH 118/122] net/hns3: fix a segfault from secondary process + +If a hns3 device in the secondary process is attached to do probing +operation, 'rx_queues' and 'tx_queues' in dev->data are null in +eth_dev_fp_ops_setup when calling rte_eth_dev_probing_finish. The primary +process calls dev_start to re-setup their fp_ops. But the secondary process +can't call dev_start and has no chance to do it. If the application sends +and receives packets at this time, a segfault will occur. So this patch +uses the MP communication of the PMD to update the fp_ops of the device in +the secondary process. + +Fixes: 96c33cfb06cf ("net/hns3: fix Rx/Tx functions update") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 3f576fbf4b..0dc1d8cb60 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4420,6 +4420,8 @@ hns3_eth_dev_fp_ops_config(const struct rte_eth_dev *dev) + fpo[port_id].tx_pkt_prepare = dev->tx_pkt_prepare; + fpo[port_id].rx_descriptor_status = dev->rx_descriptor_status; + fpo[port_id].tx_descriptor_status = dev->tx_descriptor_status; ++ fpo[port_id].rxq.data = dev->data->rx_queues; ++ fpo[port_id].txq.data = dev->data->tx_queues; + } + + void +-- +2.22.0 + diff --git a/0119-net-hns3-fix-TM-capability-incorrectly-defined.patch b/0119-net-hns3-fix-TM-capability-incorrectly-defined.patch new file mode 100644 index 0000000..6796c87 --- /dev/null +++ b/0119-net-hns3-fix-TM-capability-incorrectly-defined.patch @@ -0,0 +1,33 @@ +From 40df3e3ffa8c645ce7e5c0ff6e698c5bd7cf1ff8 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Wed, 1 Jun 2022 11:52:51 +0800 +Subject: [PATCH 119/122] net/hns3: fix TM capability incorrectly defined + +The TM capability should be bit-19 according to the user manual of +firmware. + +Fixes: fc18d1b4b85f ("net/hns3: fix traffic management") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_cmd.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index f9addc6069..82c999061d 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -323,7 +323,7 @@ enum HNS3_CAPS_BITS { + HNS3_CAPS_UDP_TUNNEL_CSUM_B, + HNS3_CAPS_RAS_IMP_B, + HNS3_CAPS_RXD_ADV_LAYOUT_B = 15, +- HNS3_CAPS_TM_B = 17, ++ HNS3_CAPS_TM_B = 19, + }; + + /* Capabilities of VF dependent on the PF */ +-- +2.22.0 + diff --git a/0120-app-testpmd-add-help-messages-for-multi-process.patch b/0120-app-testpmd-add-help-messages-for-multi-process.patch new file mode 100644 index 0000000..6c87ec4 --- /dev/null +++ b/0120-app-testpmd-add-help-messages-for-multi-process.patch @@ -0,0 +1,38 @@ +From 519b373d853909d953ff0c0fc6b15199be516fdd Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 9 Jun 2022 16:52:34 +0800 +Subject: [PATCH 120/122] app/testpmd: add help messages for multi-process + +This patch adds help messages for multi-process. +--num-procs=N: set the total number of multi-process instances. +--proc-id=id: set the id of the current process from multi-process +instances(0 <= id < num-procs). + +Fixes: a550baf24af9 ("app/testpmd: support multi-process") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Ferruh Yigit +--- + app/test-pmd/parameters.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c +index f9185065af..24e03e769c 100644 +--- a/app/test-pmd/parameters.c ++++ b/app/test-pmd/parameters.c +@@ -61,6 +61,9 @@ usage(char* progname) + "extended statistics to show. Used with --stats-period " + "specified or interactive commands that show Rx/Tx statistics " + "(i.e. 'show port stats').\n"); ++ printf(" --num-procs=N: set the total number of multi-process instances.\n"); ++ printf(" --proc-id=id: set the id of the current process from " ++ "multi-process instances (0 <= id < num-procs).\n"); + printf(" --nb-cores=N: set the number of forwarding cores " + "(1 <= N <= %d).\n", nb_lcores); + printf(" --nb-ports=N: set the number of forwarding ports " +-- +2.22.0 + diff --git a/0121-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch b/0121-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch new file mode 100644 index 0000000..d080e93 --- /dev/null +++ b/0121-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch @@ -0,0 +1,94 @@ +From 83d21ff84152f5912ce3e53ecb577216243fb4e4 Mon Sep 17 00:00:00 2001 +From: Dmitry Kozlyuk +Date: Mon, 7 Mar 2022 18:48:21 +0200 +Subject: [PATCH 121/122] app/testpmd: fix use of indirect action after port + close + +When a port was closed, indirect actions could remain +with their handles no longer valid. +If a newly attached device was assigned the same ID as the closed port, +those indirect actions became accessible again. +Any attempt to use them resulted in an undefined behavior. +Automatically flush indirect actions when a port is closed. + +Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action") +Cc: stable@dpdk.org + +Signed-off-by: Dmitry Kozlyuk +Acked-by: Matan Azrad +Acked-by: Aman Singh +--- + app/test-pmd/config.c | 31 +++++++++++++++++++++++++++++++ + app/test-pmd/testpmd.c | 1 + + app/test-pmd/testpmd.h | 1 + + 3 files changed, 33 insertions(+) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index 496e787edd..a7fffc3d1d 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -1743,6 +1743,37 @@ port_action_handle_destroy(portid_t port_id, + return ret; + } + ++int ++port_action_handle_flush(portid_t port_id) ++{ ++ struct rte_port *port; ++ struct port_indirect_action **tmp; ++ int ret = 0; ++ ++ if (port_id_is_invalid(port_id, ENABLED_WARN) || ++ port_id == (portid_t)RTE_PORT_ALL) ++ return -EINVAL; ++ port = &ports[port_id]; ++ tmp = &port->actions_list; ++ while (*tmp != NULL) { ++ struct rte_flow_error error; ++ struct port_indirect_action *pia = *tmp; ++ ++ /* Poisoning to make sure PMDs update it in case of error. */ ++ memset(&error, 0x44, sizeof(error)); ++ if (pia->handle != NULL && ++ rte_flow_action_handle_destroy ++ (port_id, pia->handle, &error) != 0) { ++ printf("Indirect action #%u not destroyed\n", pia->id); ++ ret = port_flow_complain(&error); ++ tmp = &pia->next; ++ } else { ++ *tmp = pia->next; ++ free(pia); ++ } ++ } ++ return ret; ++} + + /** Get indirect action by port + id */ + struct rte_flow_action_handle * +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index c4be9abe73..ac090bde06 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -3212,6 +3212,7 @@ close_port(portid_t pid) + if (is_proc_primary()) { + port_flow_flush(pi); + port_flex_item_flush(pi); ++ port_action_handle_flush(pi); + rte_eth_dev_close(pi); + } + +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 9c24cb07e0..042802b205 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -881,6 +881,7 @@ int port_action_handle_create(portid_t port_id, uint32_t id, + const struct rte_flow_action *action); + int port_action_handle_destroy(portid_t port_id, + uint32_t n, const uint32_t *action); ++int port_action_handle_flush(portid_t port_id); + struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id, + uint32_t id); + int port_action_handle_update(portid_t port_id, uint32_t id, +-- +2.22.0 + diff --git a/0122-app-testpmd-fix-bonding-slave-devices-not-released.patch b/0122-app-testpmd-fix-bonding-slave-devices-not-released.patch new file mode 100644 index 0000000..4d1c23e --- /dev/null +++ b/0122-app-testpmd-fix-bonding-slave-devices-not-released.patch @@ -0,0 +1,122 @@ +From f53f8218cfe85b78779cee5d499e7b32f26c4769 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 9 Jun 2022 19:49:21 +0800 +Subject: [PATCH 122/122] app/testpmd: fix bonding slave devices not released + +Currently, some eth devices are added to bond device, these devices are +not released when the quit command is executed in testpmd. This patch +adds the release operation for all active slaves under a bond device. + +Fixes: 0e545d3047fe ("app/testpmd: check stopping port is not in bonding") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Ferruh Yigit +--- + app/test-pmd/cmdline.c | 1 + + app/test-pmd/testpmd.c | 41 +++++++++++++++++++++++++++++++++++++++++ + app/test-pmd/testpmd.h | 2 ++ + 3 files changed, 44 insertions(+) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 1991ee3446..1f9fd61394 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -8764,6 +8764,7 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result, + __rte_unused void *data) + { + cmdline_quit(cl); ++ cl_quit = 1; + } + + cmdline_parse_token_string_t cmd_quit_quit = +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index ac090bde06..66d5167f57 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -223,6 +223,7 @@ unsigned int xstats_display_num; /**< Size of extended statistics to show */ + * option. Set flag to exit stats period loop after received SIGINT/SIGTERM. + */ + uint8_t f_quit; ++uint8_t cl_quit; /* Quit testpmd from cmdline. */ + + /* + * Max Rx frame size, set by '--max-pkt-len' parameter. +@@ -3174,11 +3175,39 @@ remove_invalid_ports(void) + nb_cfg_ports = nb_fwd_ports; + } + ++static void ++clear_bonding_slave_device(portid_t *slave_pids, uint16_t num_slaves) ++{ ++ struct rte_port *port; ++ portid_t slave_pid; ++ uint16_t i; ++ ++ for (i = 0; i < num_slaves; i++) { ++ slave_pid = slave_pids[i]; ++ if (port_is_started(slave_pid) == 1) { ++ if (rte_eth_dev_stop(slave_pid) != 0) ++ fprintf(stderr, "rte_eth_dev_stop failed for port %u\n", ++ slave_pid); ++ ++ port = &ports[slave_pid]; ++ port->port_status = RTE_PORT_STOPPED; ++ } ++ ++ clear_port_slave_flag(slave_pid); ++ ++ /* Close slave device when testpmd quit or is killed. */ ++ if (cl_quit == 1 || f_quit == 1) ++ rte_eth_dev_close(slave_pid); ++ } ++} ++ + void + close_port(portid_t pid) + { + portid_t pi; + struct rte_port *port; ++ portid_t slave_pids[RTE_MAX_ETHPORTS]; ++ int num_slaves = 0; + + if (port_id_is_invalid(pid, ENABLED_WARN)) + return; +@@ -3213,7 +3242,19 @@ close_port(portid_t pid) + port_flow_flush(pi); + port_flex_item_flush(pi); + port_action_handle_flush(pi); ++#ifdef RTE_NET_BOND ++ if (port->bond_flag == 1) ++ num_slaves = rte_eth_bond_slaves_get(pi, ++ slave_pids, RTE_MAX_ETHPORTS); ++#endif + rte_eth_dev_close(pi); ++ /* ++ * If this port is bonded device, all slaves under the ++ * device need to be removed or closed. ++ */ ++ if (port->bond_flag == 1 && num_slaves > 0) ++ clear_bonding_slave_device(slave_pids, ++ num_slaves); + } + + free_xstats_display_info(pi); +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 042802b205..569b4300cf 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -32,6 +32,8 @@ + #define RTE_PORT_CLOSED (uint16_t)2 + #define RTE_PORT_HANDLING (uint16_t)3 + ++extern uint8_t cl_quit; ++ + /* + * It is used to allocate the memory for hash key. + * The hash key size is NIC dependent. +-- +2.22.0 + diff --git a/0125-net-hns3-fix-link-status-capability-query-from-VF.patch b/0125-net-hns3-fix-link-status-capability-query-from-VF.patch new file mode 100644 index 0000000..8ce11a5 --- /dev/null +++ b/0125-net-hns3-fix-link-status-capability-query-from-VF.patch @@ -0,0 +1,52 @@ +From fe5e02e38e96e0b6ac33fd56a0f0b8cbad30b66f Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:01 +0800 +Subject: [PATCH 125/189] net/hns3: fix link status capability query from VF + +Currently, the VF LSC capability is obtained from PF driver in +the interrupt mailbox interrupt thread, it is asynchronous. +The VF driver waits for 500ms to get this capability in probe +process. + +The primary process will receive a message and do probe in the +interrupt thread context when attach a device in the secondary +process. At this case, VF driver never obtains this capability +from PF. + +The root cause is that 'vf->pf_push_lsc_cap' is not updated by +the handling mailbox thread until finishing probe. The reason +this update wouldn't be done is that the handling mailbox interrupt +thread and the probe alarm thread are both in epool thread, and +the probe alarm thread is before the mailbox interrupt thread. + +Fixes: 9bc2289fe5ea ("net/hns3: refactor VF LSC event report") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev_vf.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 7323e47f15..b85f68cb1d 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -778,6 +778,14 @@ hns3vf_get_push_lsc_cap(struct hns3_hw *hw) + + while (remain_ms > 0) { + rte_delay_ms(HNS3_POLL_RESPONE_MS); ++ /* ++ * The probe process may perform in interrupt thread context. ++ * For example, users attach a device in the secondary process. ++ * At the moment, the handling mailbox task will be blocked. So ++ * driver has to actively handle the HNS3_MBX_LINK_STAT_CHANGE ++ * mailbox from PF driver to get this capability. ++ */ ++ hns3_dev_handle_mbx_msg(hw); + if (__atomic_load_n(&vf->pf_push_lsc_cap, __ATOMIC_ACQUIRE) != + HNS3_PF_PUSH_LSC_CAP_UNKNOWN) + break; +-- +2.23.0 + diff --git a/0126-net-hns3-support-backplane-media-type.patch b/0126-net-hns3-support-backplane-media-type.patch new file mode 100644 index 0000000..1b9564c --- /dev/null +++ b/0126-net-hns3-support-backplane-media-type.patch @@ -0,0 +1,131 @@ +From 0e4f6eceec1c0cd0cae67504b90eb6a4f0451307 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:02 +0800 +Subject: [PATCH 126/189] net/hns3: support backplane media type + +The 802.11 physical PMA sub-layer defines three media: copper, fiber and +backplane. For PMD, the backplane is similar to the fiber, the main +differences are that backplane doesn't have optical module. + +Because the interface of firmware fiber is also applicable to the +backplane, this patch supports the backplane only through simple +extension. + +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 54 +++++++++++++++++++--------------- + 1 file changed, 30 insertions(+), 24 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 8a8f3f1950..5632b82078 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2788,11 +2788,8 @@ hns3_check_media_type(struct hns3_hw *hw, uint8_t media_type) + } + break; + case HNS3_MEDIA_TYPE_FIBER: +- ret = 0; +- break; + case HNS3_MEDIA_TYPE_BACKPLANE: +- PMD_INIT_LOG(ERR, "Media type is Backplane, not supported."); +- ret = -EOPNOTSUPP; ++ ret = 0; + break; + default: + PMD_INIT_LOG(ERR, "Unknown media type = %u!", media_type); +@@ -4245,14 +4242,11 @@ hns3_update_link_info(struct rte_eth_dev *eth_dev) + { + struct hns3_adapter *hns = eth_dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +- int ret = 0; + + if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) +- ret = hns3_update_copper_link_info(hw); +- else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) +- ret = hns3_update_fiber_link_info(hw); ++ return hns3_update_copper_link_info(hw); + +- return ret; ++ return hns3_update_fiber_link_info(hw); + } + + static int +@@ -4545,11 +4539,13 @@ hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev) + if (ret) + return ret; + +- if (mac->media_type == HNS3_MEDIA_TYPE_FIBER) { ++ if (mac->media_type == HNS3_MEDIA_TYPE_FIBER || ++ mac->media_type == HNS3_MEDIA_TYPE_BACKPLANE) { + /* + * Some firmware does not support the report of supported_speed, +- * and only report the effective speed of SFP. In this case, it +- * is necessary to use the SFP's speed as the supported_speed. ++ * and only report the effective speed of SFP/backplane. In this ++ * case, it is necessary to use the SFP/backplane's speed as the ++ * supported_speed. + */ + if (mac->supported_speed == 0) + mac->supported_speed = +@@ -4811,7 +4807,7 @@ hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds) + + if (mac->media_type == HNS3_MEDIA_TYPE_COPPER) + speed_bit = hns3_convert_link_speeds2bitmap_copper(link_speeds); +- else if (mac->media_type == HNS3_MEDIA_TYPE_FIBER) ++ else + speed_bit = hns3_convert_link_speeds2bitmap_fiber(link_speeds); + + if (!(speed_bit & supported_speed)) { +@@ -4955,6 +4951,19 @@ hns3_set_fiber_port_link_speed(struct hns3_hw *hw, + return hns3_cfg_mac_speed_dup(hw, cfg->speed, cfg->duplex); + } + ++static const char * ++hns3_get_media_type_name(uint8_t media_type) ++{ ++ if (media_type == HNS3_MEDIA_TYPE_FIBER) ++ return "fiber"; ++ else if (media_type == HNS3_MEDIA_TYPE_COPPER) ++ return "copper"; ++ else if (media_type == HNS3_MEDIA_TYPE_BACKPLANE) ++ return "backplane"; ++ else ++ return "unknown"; ++} ++ + static int + hns3_set_port_link_speed(struct hns3_hw *hw, + struct hns3_set_link_speed_cfg *cfg) +@@ -4969,18 +4978,15 @@ hns3_set_port_link_speed(struct hns3_hw *hw, + #endif + + ret = hns3_set_copper_port_link_speed(hw, cfg); +- if (ret) { +- hns3_err(hw, "failed to set copper port link speed," +- "ret = %d.", ret); +- return ret; +- } +- } else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) { ++ } else { + ret = hns3_set_fiber_port_link_speed(hw, cfg); +- if (ret) { +- hns3_err(hw, "failed to set fiber port link speed," +- "ret = %d.", ret); +- return ret; +- } ++ } ++ ++ if (ret) { ++ hns3_err(hw, "failed to set %s port link speed, ret = %d.", ++ hns3_get_media_type_name(hw->mac.media_type), ++ ret); ++ return ret; + } + + return 0; +-- +2.23.0 + diff --git a/0127-net-hns3-cancel-heartbeat-alarm-when-VF-reset.patch b/0127-net-hns3-cancel-heartbeat-alarm-when-VF-reset.patch new file mode 100644 index 0000000..80022d0 --- /dev/null +++ b/0127-net-hns3-cancel-heartbeat-alarm-when-VF-reset.patch @@ -0,0 +1,46 @@ +From 9a640a6c9cfbf7b5dea307209dc6f20cbfc871c0 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:03 +0800 +Subject: [PATCH 127/189] net/hns3: cancel heartbeat alarm when VF reset + +The purpose of the heartbeat alarm is to keep alive for VF. The mailbox +channel is disabled when VF is reset, and the heartbeat mailbox message +will fail to send. If the reset is not complete, the error information +about the heartbeat sending failure will be printed continuously. +In fact, VF does set alive when VF restore its configuration. So the +heartbeat alarm can be canceled to prepare to start reset and start the +alarm when start service. + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev_vf.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index b85f68cb1d..0dea63e8be 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1977,6 +1977,8 @@ hns3vf_stop_service(struct hns3_adapter *hns) + } else + hw->reset.mbuf_deferred_free = false; + ++ rte_eal_alarm_cancel(hns3vf_keep_alive_handler, eth_dev); ++ + /* + * It is cumbersome for hardware to pick-and-choose entries for deletion + * from table space. Hence, for function reset software intervention is +@@ -1998,6 +2000,10 @@ hns3vf_start_service(struct hns3_adapter *hns) + eth_dev = &rte_eth_devices[hw->data->port_id]; + hns3_set_rxtx_function(eth_dev); + hns3_mp_req_start_rxtx(eth_dev); ++ ++ rte_eal_alarm_set(HNS3VF_KEEP_ALIVE_INTERVAL, hns3vf_keep_alive_handler, ++ eth_dev); ++ + if (hw->adapter_state == HNS3_NIC_STARTED) { + hns3vf_start_poll_job(eth_dev); + +-- +2.23.0 + diff --git a/0128-net-hns3-fix-PTP-interrupt-logging.patch b/0128-net-hns3-fix-PTP-interrupt-logging.patch new file mode 100644 index 0000000..fd02fb7 --- /dev/null +++ b/0128-net-hns3-fix-PTP-interrupt-logging.patch @@ -0,0 +1,35 @@ +From f4039f8c809b290e1031023c6dc680af7e8dbe11 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:04 +0800 +Subject: [PATCH 128/189] net/hns3: fix PTP interrupt logging + +PMD driver will receive a PTP interrupt when receive a PTP packet. +But driver doesn't distinguish it. As a result, many unknown events +are printed when many PTP packets are received on the link. The PTP +interrupt is normal, so this patch doesn't log and ignores it. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 5632b82078..7c9938b96e 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -318,7 +318,7 @@ hns3_interrupt_handler(void *param) + hns3_schedule_reset(hns); + } else if (event_cause == HNS3_VECTOR0_EVENT_MBX) { + hns3_dev_handle_mbx_msg(hw); +- } else { ++ } else if (event_cause != HNS3_VECTOR0_EVENT_PTP) { + hns3_warn(hw, "received unknown event: vector0_int_stat:0x%x " + "ras_int_stat:0x%x cmdq_int_stat:0x%x", + vector0_int, ras_int, cmdq_int); +-- +2.23.0 + diff --git a/0129-net-hns3-fix-statistics-locking.patch b/0129-net-hns3-fix-statistics-locking.patch new file mode 100644 index 0000000..4c1349f --- /dev/null +++ b/0129-net-hns3-fix-statistics-locking.patch @@ -0,0 +1,132 @@ +From 8626a054e516796e942019ce4a1e22d6d8fcd3ee Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:05 +0800 +Subject: [PATCH 129/189] net/hns3: fix statistics locking + +The stats_lock is used to protect statistics update in stats APIs and +periodic task, but current code only protect queue related statistics. + +Fixes: a65342d9d5d2 ("net/hns3: fix MAC and queues HW statistics overflow") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_stats.c | 22 +++++++++------------- + 1 file changed, 9 insertions(+), 13 deletions(-) + +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index bf8af4531f..d56d3ec174 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -629,6 +629,7 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) + uint16_t i; + int ret; + ++ rte_spinlock_lock(&hw->stats_lock); + /* Update imissed stats */ + ret = hns3_update_imissed_stats(hw, false); + if (ret) { +@@ -644,10 +645,7 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) + if (rxq == NULL) + continue; + +- rte_spinlock_lock(&hw->stats_lock); + hns3_rcb_rx_ring_stats_get(rxq, stats); +- rte_spinlock_unlock(&hw->stats_lock); +- + rte_stats->ierrors += rxq->err_stats.l2_errors + + rxq->err_stats.pkt_len_errors; + rte_stats->ibytes += rxq->basic_stats.bytes; +@@ -659,9 +657,7 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) + if (txq == NULL) + continue; + +- rte_spinlock_lock(&hw->stats_lock); + hns3_rcb_tx_ring_stats_get(txq, stats); +- rte_spinlock_unlock(&hw->stats_lock); + rte_stats->obytes += txq->basic_stats.bytes; + } + +@@ -683,7 +679,10 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) + rte_stats->opackets = stats->rcb_tx_ring_pktnum_rcd - + rte_stats->oerrors; + rte_stats->rx_nombuf = eth_dev->data->rx_mbuf_alloc_failed; ++ + out: ++ rte_spinlock_unlock(&hw->stats_lock); ++ + return ret; + } + +@@ -697,6 +696,7 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + uint16_t i; + int ret; + ++ rte_spinlock_lock(&hw->stats_lock); + /* + * Note: Reading hardware statistics of imissed registers will + * clear them. +@@ -732,7 +732,6 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + if (rxq == NULL) + continue; + +- rte_spinlock_lock(&hw->stats_lock); + memset(&rxq->basic_stats, 0, + sizeof(struct hns3_rx_basic_stats)); + +@@ -740,7 +739,6 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + (void)hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG); + rxq->err_stats.pkt_len_errors = 0; + rxq->err_stats.l2_errors = 0; +- rte_spinlock_unlock(&hw->stats_lock); + } + + /* Clear all the stats of a txq in a loop to keep them synchronized */ +@@ -749,19 +747,18 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + if (txq == NULL) + continue; + +- rte_spinlock_lock(&hw->stats_lock); + memset(&txq->basic_stats, 0, + sizeof(struct hns3_tx_basic_stats)); + + /* This register is read-clear */ + (void)hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG); +- rte_spinlock_unlock(&hw->stats_lock); + } + +- rte_spinlock_lock(&hw->stats_lock); + hns3_tqp_stats_clear(hw); +- rte_spinlock_unlock(&hw->stats_lock); ++ + out: ++ rte_spinlock_unlock(&hw->stats_lock); ++ + return ret; + } + +@@ -1082,11 +1079,11 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + count++; + } + } +- rte_spinlock_unlock(&hw->stats_lock); + + ret = hns3_update_imissed_stats(hw, false); + if (ret) { + hns3_err(hw, "update imissed stats failed, ret = %d", ret); ++ rte_spinlock_unlock(&hw->stats_lock); + return ret; + } + +@@ -1115,7 +1112,6 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + } + } + +- rte_spinlock_lock(&hw->stats_lock); + hns3_tqp_dfx_stats_get(dev, xstats, &count); + hns3_queue_stats_get(dev, xstats, &count); + rte_spinlock_unlock(&hw->stats_lock); +-- +2.23.0 + diff --git a/0130-net-hns3-fix-descriptors-check-with-SVE.patch b/0130-net-hns3-fix-descriptors-check-with-SVE.patch new file mode 100644 index 0000000..e41221a --- /dev/null +++ b/0130-net-hns3-fix-descriptors-check-with-SVE.patch @@ -0,0 +1,34 @@ +From 07210d18c368b27539218d9c3a907f30447c2a1e Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:06 +0800 +Subject: [PATCH 130/189] net/hns3: fix descriptors check with SVE + +The SVE algorithm and NEON algorithm have the same requirements for +nb-desc, but the nb-desc is verified only when using NEON. + +Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 0dc1d8cb60..b7fe2352a1 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -1759,7 +1759,8 @@ hns3_rxq_conf_runtime_check(struct hns3_hw *hw, uint16_t buf_size, + return -EINVAL; + } + +- if (pkt_burst == hns3_recv_pkts_vec) { ++ if (pkt_burst == hns3_recv_pkts_vec || ++ pkt_burst == hns3_recv_pkts_vec_sve) { + min_vec_bds = HNS3_DEFAULT_RXQ_REARM_THRESH + + HNS3_DEFAULT_RX_BURST; + if (nb_desc < min_vec_bds || +-- +2.23.0 + diff --git a/0131-net-hns3-clean-some-functions.patch b/0131-net-hns3-clean-some-functions.patch new file mode 100644 index 0000000..412cc7d --- /dev/null +++ b/0131-net-hns3-clean-some-functions.patch @@ -0,0 +1,50 @@ +From 3a1871f1dfbba831c9c6a65081d22e6021d78ffe Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Fri, 21 Oct 2022 15:36:07 +0800 +Subject: [PATCH 131/189] net/hns3: clean some functions + +Delete unnecessary code and adjust code to make code more clean. + +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 10 +++------- + 1 file changed, 3 insertions(+), 7 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index b7fe2352a1..840ca384ce 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -1909,8 +1909,6 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, + rxq->pvid_sw_discard_en = false; + rxq->ptype_en = hns3_dev_get_support(hw, RXD_ADV_LAYOUT) ? true : false; + rxq->configured = true; +- rxq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET + +- idx * HNS3_TQP_REG_SIZE); + rxq->io_base = (void *)((char *)hw->io_base + + hns3_get_tqp_reg_offset(idx)); + rxq->io_head_reg = (volatile void *)((char *)rxq->io_base + +@@ -2442,10 +2440,8 @@ hns3_recv_pkts_simple(void *rx_queue, + + nmb = hns3_rx_alloc_buffer(rxq); + if (unlikely(nmb == NULL)) { +- uint16_t port_id; +- +- port_id = rxq->port_id; +- rte_eth_devices[port_id].data->rx_mbuf_alloc_failed++; ++ rte_eth_devices[rxq->port_id].data-> ++ rx_mbuf_alloc_failed++; + break; + } + +@@ -3870,7 +3866,7 @@ hns3_prep_pkt_proc(struct hns3_tx_queue *tx_queue, struct rte_mbuf *m) + #endif + if (hns3_pkt_is_tso(m)) { + if (hns3_pkt_need_linearized(m, m->nb_segs, +- tx_queue->max_non_tso_bd_num) || ++ tx_queue->max_non_tso_bd_num) || + hns3_check_tso_pkt_valid(m)) { + rte_errno = EINVAL; + return -EINVAL; +-- +2.23.0 + diff --git a/0132-net-hns3-delete-unused-code.patch b/0132-net-hns3-delete-unused-code.patch new file mode 100644 index 0000000..d944971 --- /dev/null +++ b/0132-net-hns3-delete-unused-code.patch @@ -0,0 +1,88 @@ +From a8c847f28e885f7ef07b3fd3fc415e2ce4113ee8 Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Fri, 21 Oct 2022 15:36:08 +0800 +Subject: [PATCH 132/189] net/hns3: delete unused code + +The RTE_HNS3_ONLY_1630_FPGA macro is not in use, so delete the code. + +Fixes: 2192c428f9a6 ("net/hns3: fix firmware compatibility configuration") +Fixes: bdaf190f8235 ("net/hns3: support link speed autoneg for PF") +Cc: stable@dpdk.org + +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.c | 33 --------------------------------- + drivers/net/hns3/hns3_ethdev.c | 11 ++--------- + 2 files changed, 2 insertions(+), 42 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index e3d096d9cb..50cb3eabb1 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -631,39 +631,6 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) + struct hns3_cmd_desc desc; + uint32_t compat = 0; + +-#if defined(RTE_HNS3_ONLY_1630_FPGA) +- /* If resv reg enabled phy driver of imp is not configured, driver +- * will use temporary phy driver. +- */ +- struct rte_pci_device *pci_dev; +- struct rte_eth_dev *eth_dev; +- uint8_t revision; +- int ret; +- +- eth_dev = &rte_eth_devices[hw->data->port_id]; +- pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); +- /* Get PCI revision id */ +- ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, +- HNS3_PCI_REVISION_ID); +- if (ret != HNS3_PCI_REVISION_ID_LEN) { +- PMD_INIT_LOG(ERR, "failed to read pci revision id, ret = %d", +- ret); +- return -EIO; +- } +- if (revision == PCI_REVISION_ID_HIP09_A) { +- struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); +- if (hns3_dev_get_support(hw, COPPER) == 0 || pf->is_tmp_phy) { +- PMD_INIT_LOG(ERR, "***use temp phy driver in dpdk***"); +- pf->is_tmp_phy = true; +- hns3_set_bit(hw->capability, +- HNS3_DEV_SUPPORT_COPPER_B, 1); +- return 0; +- } +- +- PMD_INIT_LOG(ERR, "***use phy driver in imp***"); +- } +-#endif +- + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_FIRMWARE_COMPAT_CFG, false); + req = (struct hns3_firmware_compat_cmd *)desc.data; + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 7c9938b96e..401736f5a6 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4970,17 +4970,10 @@ hns3_set_port_link_speed(struct hns3_hw *hw, + { + int ret; + +- if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) { +-#if defined(RTE_HNS3_ONLY_1630_FPGA) +- struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); +- if (pf->is_tmp_phy) +- return 0; +-#endif +- ++ if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) + ret = hns3_set_copper_port_link_speed(hw, cfg); +- } else { ++ else + ret = hns3_set_fiber_port_link_speed(hw, cfg); +- } + + if (ret) { + hns3_err(hw, "failed to set %s port link speed, ret = %d.", +-- +2.23.0 + diff --git a/0133-examples-dma-support-dequeue-when-no-packet-received.patch b/0133-examples-dma-support-dequeue-when-no-packet-received.patch new file mode 100644 index 0000000..4cf6fab --- /dev/null +++ b/0133-examples-dma-support-dequeue-when-no-packet-received.patch @@ -0,0 +1,62 @@ +From ab50c70fe965fb931156eddfbde0ead68323849a Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:09 +0800 +Subject: [PATCH 133/189] examples/dma: support dequeue when no packet received + +Currently the example using DMA in asynchronous mode, which are: + nb_rx = rte_eth_rx_burst(); + if (nb_rx == 0) + continue; + ... + dma_enqueue(); // enqueue the received packets copy request + nb_cpl = dma_dequeue(); // get copy completed packets + ... + +There are no waiting inside dma_dequeue(), and this is why it's called +asynchronus. If there are no packet received, it won't call +dma_dequeue(), but some packets may still in the DMA queue which +enqueued in last cycle. As a result, when the traffic is stopped, the +sent packets and received packets are unbalanced from the perspective +of the traffic generator. + +The patch supports DMA dequeue when no packet received, it helps to +judge the test result by comparing the sent packets with the received +packets on traffic generator sides. + +Signed-off-by: Chengwen Feng +Acked-by: Bruce Richardson +Acked-by: Kevin Laatz +--- + examples/dma/dmafwd.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c +index 9b17b40dbf..b06042e5fe 100644 +--- a/examples/dma/dmafwd.c ++++ b/examples/dma/dmafwd.c +@@ -408,8 +408,13 @@ dma_rx_port(struct rxtx_port_config *rx_config) + nb_rx = rte_eth_rx_burst(rx_config->rxtx_port, i, + pkts_burst, MAX_PKT_BURST); + +- if (nb_rx == 0) ++ if (nb_rx == 0) { ++ if (copy_mode == COPY_MODE_DMA_NUM && ++ (nb_rx = dma_dequeue(pkts_burst, pkts_burst_copy, ++ MAX_PKT_BURST, rx_config->dmadev_ids[i])) > 0) ++ goto handle_tx; + continue; ++ } + + port_statistics.rx[rx_config->rxtx_port] += nb_rx; + +@@ -450,6 +455,7 @@ dma_rx_port(struct rxtx_port_config *rx_config) + pkts_burst_copy[j]); + } + ++handle_tx: + rte_mempool_put_bulk(dma_pktmbuf_pool, + (void *)pkts_burst, nb_rx); + +-- +2.23.0 + diff --git a/0134-net-hns3-add-dump-of-VF-VLAN-filter-modify-capabilit.patch b/0134-net-hns3-add-dump-of-VF-VLAN-filter-modify-capabilit.patch new file mode 100644 index 0000000..b5d1ac4 --- /dev/null +++ b/0134-net-hns3-add-dump-of-VF-VLAN-filter-modify-capabilit.patch @@ -0,0 +1,31 @@ +From 29cb11b1bfafa7a4cefaffbbd5b05afab32957ba Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Fri, 21 Oct 2022 15:36:10 +0800 +Subject: [PATCH 134/189] net/hns3: add dump of VF VLAN filter modify + capability + +Show whether support modifying VF VLAN filter or not. +Sample output changes: ++ -- support VF VLAN FILTER MOD: Yes + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_dump.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index ef3e5c0fb4..646e93d8e6 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -98,6 +98,7 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) + {HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"}, + {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"}, + {HNS3_DEV_SUPPORT_TM_B, "TM"}, ++ {HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, "VF VLAN FILTER MOD"}, + }; + uint32_t i; + +-- +2.23.0 + diff --git a/0135-net-hns3-fix-Rx-with-PTP.patch b/0135-net-hns3-fix-Rx-with-PTP.patch new file mode 100644 index 0000000..4afa8cb --- /dev/null +++ b/0135-net-hns3-fix-Rx-with-PTP.patch @@ -0,0 +1,89 @@ +From 9fd76879f458693e1cf368aeeb08238c579c8ff3 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:11 +0800 +Subject: [PATCH 135/189] net/hns3: fix Rx with PTP + +The Rx and Tx vector algorithm of hns3 PMD don't support PTP +function. Currently, hns3 driver uses 'pf->ptp_enable' to check +whether PTP is enabled so as to not select Rx and Tx vector +algorithm. And the variable is set when call rte_eth_timesync_enable(). +Namely, it may not be set before selecting Rx/Tx function, let's say +the case: set PTP offload in dev_configure(), do dev_start() and then +call rte_eth_timesync_enable(). In this case, all PTP packets can not +be received to application. So this patch fixes the check based on the +RTE_ETH_RX_OFFLOAD_TIMESTAMP flag. + +Fixes: 3ca3dcd65101 ("net/hns3: fix vector Rx/Tx when PTP enabled") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ptp.c | 1 - + drivers/net/hns3/hns3_rxtx_vec.c | 20 +++++++++----------- + 2 files changed, 9 insertions(+), 12 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index 0b0061bba5..6bbd85ba23 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -125,7 +125,6 @@ hns3_timesync_enable(struct rte_eth_dev *dev) + + if (pf->ptp_enable) + return 0; +- hns3_warn(hw, "note: please ensure Rx/Tx burst mode is simple or common when enabling PTP!"); + + rte_spinlock_lock(&hw->lock); + ret = hns3_timesync_configure(hns, true); +diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c +index 73f0ab6bc8..153866cf03 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec.c ++++ b/drivers/net/hns3/hns3_rxtx_vec.c +@@ -17,15 +17,18 @@ int + hns3_tx_check_vec_support(struct rte_eth_dev *dev) + { + struct rte_eth_txmode *txmode = &dev->data->dev_conf.txmode; +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_pf *pf = &hns->pf; ++ struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; + + /* Only support RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE */ + if (txmode->offloads != RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) + return -ENOTSUP; + +- /* Vec is not supported when PTP enabled */ +- if (pf->ptp_enable) ++ /* ++ * PTP function requires the cooperation of Rx and Tx. ++ * Tx vector isn't supported if RTE_ETH_RX_OFFLOAD_TIMESTAMP is set ++ * in Rx offloads. ++ */ ++ if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) + return -ENOTSUP; + + return 0; +@@ -233,9 +236,8 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) + struct rte_eth_fdir_conf *fconf = &dev->data->dev_conf.fdir_conf; + struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; + uint64_t offloads_mask = RTE_ETH_RX_OFFLOAD_TCP_LRO | +- RTE_ETH_RX_OFFLOAD_VLAN; +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_pf *pf = &hns->pf; ++ RTE_ETH_RX_OFFLOAD_VLAN | ++ RTE_ETH_RX_OFFLOAD_TIMESTAMP; + + if (dev->data->scattered_rx) + return -ENOTSUP; +@@ -249,9 +251,5 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) + if (hns3_rxq_iterate(dev, hns3_rxq_vec_check, NULL) != 0) + return -ENOTSUP; + +- /* Vec is not supported when PTP enabled */ +- if (pf->ptp_enable) +- return -ENOTSUP; +- + return 0; + } +-- +2.23.0 + diff --git a/0136-net-hns3-fix-crash-in-SVE-Tx.patch b/0136-net-hns3-fix-crash-in-SVE-Tx.patch new file mode 100644 index 0000000..c08d282 --- /dev/null +++ b/0136-net-hns3-fix-crash-in-SVE-Tx.patch @@ -0,0 +1,44 @@ +From eaab0561c2effa2f60f27c10d27c099d819fdd1f Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:12 +0800 +Subject: [PATCH 136/189] net/hns3: fix crash in SVE Tx + +Currently, the number of Tx send bytes is obtained by accumulating the +length of the batch 'mbuf' packets of the current loop cycle. +Unfortunately, it uses svcntd (which means all lane, regardless of +whether the corresponding lane is valid) which may lead to overflow, +and thus refers to an invalid mbuf. + +Because the SVE xmit algorithm applies only to a single mbuf, the +mbuf's data_len is equal pkt_len, so this patch fixes it by using +svaddv_u64(svbool_t pg, svuint64_t data_len) which only adds valid +lanes. + +Fixes: fdcd6a3e0246 ("net/hns3: add bytes stats") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx_vec_sve.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c +index be1fdbcdf0..b0dfb052bb 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec_sve.c ++++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c +@@ -435,9 +435,8 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, + offsets, svdup_n_u64(valid_bit)); + + /* Increment bytes counter */ +- uint32_t idx; +- for (idx = 0; idx < svcntd(); idx++) +- txq->basic_stats.bytes += pkts[idx]->pkt_len; ++ txq->basic_stats.bytes += ++ (svaddv_u64(pg, data_len) >> HNS3_UINT16_BIT); + + /* update index for next loop */ + i += svcntd(); +-- +2.23.0 + diff --git a/0137-net-hns3-fix-next-to-use-overflow-in-SVE-Tx.patch b/0137-net-hns3-fix-next-to-use-overflow-in-SVE-Tx.patch new file mode 100644 index 0000000..cf96059 --- /dev/null +++ b/0137-net-hns3-fix-next-to-use-overflow-in-SVE-Tx.patch @@ -0,0 +1,46 @@ +From e95f25b7cda1108b4e0579dd70f1bf90516b7e2c Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:13 +0800 +Subject: [PATCH 137/189] net/hns3: fix next-to-use overflow in SVE Tx + +If txq's next-to-use plus nb_pkts equal txq's nb_tx_desc when using +SVE xmit algorithm, the txq's next-to-use will equal nb_tx_desc after +the xmit, this does not cause Tx exceptions, but may affect other ops +that depend on this field, such as tx_descriptor_status. + +Fixes: f0c243a6cb6f ("net/hns3: support SVE Tx") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx_vec_sve.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c +index b0dfb052bb..f09a81dbd5 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec_sve.c ++++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c +@@ -464,14 +464,16 @@ hns3_xmit_fixed_burst_vec_sve(void *__restrict tx_queue, + return 0; + } + +- if (txq->next_to_use + nb_pkts > txq->nb_tx_desc) { ++ if (txq->next_to_use + nb_pkts >= txq->nb_tx_desc) { + nb_tx = txq->nb_tx_desc - txq->next_to_use; + hns3_tx_fill_hw_ring_sve(txq, tx_pkts, nb_tx); + txq->next_to_use = 0; + } + +- hns3_tx_fill_hw_ring_sve(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); +- txq->next_to_use += nb_pkts - nb_tx; ++ if (nb_pkts > nb_tx) { ++ hns3_tx_fill_hw_ring_sve(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); ++ txq->next_to_use += nb_pkts - nb_tx; ++ } + + txq->tx_bd_ready -= nb_pkts; + hns3_write_txq_tail_reg(txq, nb_pkts); +-- +2.23.0 + diff --git a/0138-net-hns3-fix-next-to-use-overflow-in-simple-Tx.patch b/0138-net-hns3-fix-next-to-use-overflow-in-simple-Tx.patch new file mode 100644 index 0000000..8310dfa --- /dev/null +++ b/0138-net-hns3-fix-next-to-use-overflow-in-simple-Tx.patch @@ -0,0 +1,46 @@ +From 982c9eabe68c6d5a0e8328df8dc11c5f315eddf0 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:14 +0800 +Subject: [PATCH 138/189] net/hns3: fix next-to-use overflow in simple Tx + +If txq's next-to-use plus nb_pkts equal txq's nb_tx_desc when using +simple xmit algorithm, the txq's next-to-use will equal nb_tx_desc +fter the xmit, this does not cause Tx exceptions, but may affect other +ops that depend on this field, such as tx_descriptor_status. + +Fixes: 7ef933908f04 ("net/hns3: add simple Tx path") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 840ca384ce..93cc70477d 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4129,14 +4129,16 @@ hns3_xmit_pkts_simple(void *tx_queue, + } + + txq->tx_bd_ready -= nb_pkts; +- if (txq->next_to_use + nb_pkts > txq->nb_tx_desc) { ++ if (txq->next_to_use + nb_pkts >= txq->nb_tx_desc) { + nb_tx = txq->nb_tx_desc - txq->next_to_use; + hns3_tx_fill_hw_ring(txq, tx_pkts, nb_tx); + txq->next_to_use = 0; + } + +- hns3_tx_fill_hw_ring(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); +- txq->next_to_use += nb_pkts - nb_tx; ++ if (nb_pkts > nb_tx) { ++ hns3_tx_fill_hw_ring(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); ++ txq->next_to_use += nb_pkts - nb_tx; ++ } + + hns3_write_txq_tail_reg(txq, nb_pkts); + +-- +2.23.0 + diff --git a/0139-net-hns3-optimize-SVE-Tx-performance.patch b/0139-net-hns3-optimize-SVE-Tx-performance.patch new file mode 100644 index 0000000..df5df6e --- /dev/null +++ b/0139-net-hns3-optimize-SVE-Tx-performance.patch @@ -0,0 +1,56 @@ +From c4f3e4cf9404434d8062c523c8b6bc55df136140 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:15 +0800 +Subject: [PATCH 139/189] net/hns3: optimize SVE Tx performance + +Optimize SVE xmit algorithm performance, will get about 1%+ +performance gain under 64B macfwd. + +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + drivers/net/hns3/hns3_rxtx_vec_sve.c | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c +index f09a81dbd5..6f23ba674d 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec_sve.c ++++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c +@@ -389,10 +389,12 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, + HNS3_UINT32_BIT; + svuint64_t base_addr, buf_iova, data_off, data_len, addr; + svuint64_t offsets = svindex_u64(0, BD_SIZE); +- uint32_t i = 0; +- svbool_t pg = svwhilelt_b64_u32(i, nb_pkts); ++ uint32_t cnt = svcntd(); ++ svbool_t pg; ++ uint32_t i; + +- do { ++ for (i = 0; i < nb_pkts; /* i is updated in the inner loop */) { ++ pg = svwhilelt_b64_u32(i, nb_pkts); + base_addr = svld1_u64(pg, (uint64_t *)pkts); + /* calc mbuf's field buf_iova address */ + buf_iova = svadd_n_u64_z(pg, base_addr, +@@ -439,12 +441,11 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, + (svaddv_u64(pg, data_len) >> HNS3_UINT16_BIT); + + /* update index for next loop */ +- i += svcntd(); +- pkts += svcntd(); +- txdp += svcntd(); +- tx_entry += svcntd(); +- pg = svwhilelt_b64_u32(i, nb_pkts); +- } while (svptest_any(svptrue_b64(), pg)); ++ i += cnt; ++ pkts += cnt; ++ txdp += cnt; ++ tx_entry += cnt; ++ } + } + + static uint16_t +-- +2.23.0 + diff --git a/0140-net-hns3-fix-crash-when-secondary-process-access-FW.patch b/0140-net-hns3-fix-crash-when-secondary-process-access-FW.patch new file mode 100644 index 0000000..5159982 --- /dev/null +++ b/0140-net-hns3-fix-crash-when-secondary-process-access-FW.patch @@ -0,0 +1,75 @@ +From aa31e13f290fb82b43dac134f6b2b0332b3ffd45 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:16 +0800 +Subject: [PATCH 140/189] net/hns3: fix crash when secondary process access FW + +Currently, to prevent missing reporting of reset interrupts and quickly +identify reset interrupts, the following logic is designed in the +FW (firmware) command interface hns3_cmd_send: if an unprocessed +interrupt exist (by checking reset registers), related reset task is +scheduled. + +The secondary process may invoke the hns3_cmd_send interface (e.g. using +proc-info query some stats). Unfortunately, the secondary process +does not support reset processing, and a segment fault may occur if it +schedules reset task. + +Fix it by limit the checking and scheduling of reset under only primary +process. + +Fixes: 2790c6464725 ("net/hns3: support device reset") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 10 +++++++++- + drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++++++-- + 2 files changed, 18 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 401736f5a6..24ee9df332 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5602,7 +5602,15 @@ hns3_is_reset_pending(struct hns3_adapter *hns) + struct hns3_hw *hw = &hns->hw; + enum hns3_reset_level reset; + +- hns3_check_event_cause(hns, NULL); ++ /* ++ * Check the registers to confirm whether there is reset pending. ++ * Note: This check may lead to schedule reset task, but only primary ++ * process can process the reset event. Therefore, limit the ++ * checking under only primary process. ++ */ ++ if (rte_eal_process_type() == RTE_PROC_PRIMARY) ++ hns3_check_event_cause(hns, NULL); ++ + reset = hns3_get_reset_level(hns, &hw->reset.pending); + if (reset != HNS3_NONE_RESET && hw->reset.level != HNS3_NONE_RESET && + hw->reset.level < reset) { +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 0dea63e8be..db2f15abe2 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1864,8 +1864,15 @@ hns3vf_is_reset_pending(struct hns3_adapter *hns) + if (hw->reset.level == HNS3_VF_FULL_RESET) + return false; + +- /* Check the registers to confirm whether there is reset pending */ +- hns3vf_check_event_cause(hns, NULL); ++ /* ++ * Check the registers to confirm whether there is reset pending. ++ * Note: This check may lead to schedule reset task, but only primary ++ * process can process the reset event. Therefore, limit the ++ * checking under only primary process. ++ */ ++ if (rte_eal_process_type() == RTE_PROC_PRIMARY) ++ hns3vf_check_event_cause(hns, NULL); ++ + reset = hns3vf_get_reset_level(hw, &hw->reset.pending); + if (hw->reset.level != HNS3_NONE_RESET && reset != HNS3_NONE_RESET && + hw->reset.level < reset) { +-- +2.23.0 + diff --git a/0141-net-hns3-delete-unused-markup.patch b/0141-net-hns3-delete-unused-markup.patch new file mode 100644 index 0000000..ac54d7e --- /dev/null +++ b/0141-net-hns3-delete-unused-markup.patch @@ -0,0 +1,81 @@ +From a3cc39e81492da62dc98146c33f8f5dbb632e746 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:17 +0800 +Subject: [PATCH 141/189] net/hns3: delete unused markup + +The '__rte_unused' tag in the input parameter of 'hns3_mac_stats_reset' +is redundant. This patch remove this tag. In addition, this function is +aimed to clear MAC statics. So using 'struct hns3_hw' as input parameter +is better than 'struct rte_eth_dev', and it also facilitates the call of +this function. + +Fixes: 8839c5e202f3 ("net/hns3: support device stats") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_stats.c | 22 +++++----------------- + 1 file changed, 5 insertions(+), 17 deletions(-) + +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index d56d3ec174..c2af3bd231 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -406,15 +406,6 @@ hns3_query_mac_stats_reg_num(struct hns3_hw *hw) + return 0; + } + +-static int +-hns3_query_update_mac_stats(struct rte_eth_dev *dev) +-{ +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; +- +- return hns3_update_mac_stats(hw); +-} +- + static int + hns3_update_port_rpu_drop_stats(struct hns3_hw *hw) + { +@@ -763,14 +754,13 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) + } + + static int +-hns3_mac_stats_reset(__rte_unused struct rte_eth_dev *dev) ++hns3_mac_stats_reset(struct hns3_hw *hw) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; + struct hns3_mac_stats *mac_stats = &hw->mac_stats; + int ret; + +- ret = hns3_query_update_mac_stats(dev); ++ /* Clear hardware MAC statistics by reading it. */ ++ ret = hns3_update_mac_stats(hw); + if (ret) { + hns3_err(hw, "Clear Mac stats fail : %d", ret); + return ret; +@@ -1063,8 +1053,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + hns3_tqp_basic_stats_get(dev, xstats, &count); + + if (!hns->is_vf) { +- /* Update Mac stats */ +- ret = hns3_query_update_mac_stats(dev); ++ ret = hns3_update_mac_stats(hw); + if (ret < 0) { + hns3_err(hw, "Update Mac stats fail : %d", ret); + rte_spinlock_unlock(&hw->stats_lock); +@@ -1482,8 +1471,7 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) + if (hns->is_vf) + goto out; + +- /* HW registers are cleared on read */ +- ret = hns3_mac_stats_reset(dev); ++ ret = hns3_mac_stats_reset(hw); + + out: + rte_spinlock_unlock(&hw->stats_lock); +-- +2.23.0 + diff --git a/0142-net-hns3-fix-clearing-hardware-MAC-statistics.patch b/0142-net-hns3-fix-clearing-hardware-MAC-statistics.patch new file mode 100644 index 0000000..9b7706b --- /dev/null +++ b/0142-net-hns3-fix-clearing-hardware-MAC-statistics.patch @@ -0,0 +1,44 @@ +From 70cecb90da490a7f0d484ab9cd8bd481c17f20a3 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:18 +0800 +Subject: [PATCH 142/189] net/hns3: fix clearing hardware MAC statistics + +In the situation that the driver hns3 exits abnormally during packets +sending and receiving, the hardware statistics are not cleared when the +driver hns3 is reloaded. It need to be cleared during driver hns3 +initialization that hardware MAC statistics. + +Fixes: 8839c5e202f3 ("net/hns3: support device stats") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_stats.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index c2af3bd231..552ae9d30c 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -1528,6 +1528,7 @@ hns3_tqp_stats_clear(struct hns3_hw *hw) + int + hns3_stats_init(struct hns3_hw *hw) + { ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + int ret; + + rte_spinlock_init(&hw->stats_lock); +@@ -1538,6 +1539,9 @@ hns3_stats_init(struct hns3_hw *hw) + return ret; + } + ++ if (!hns->is_vf) ++ hns3_mac_stats_reset(hw); ++ + return hns3_tqp_stats_init(hw); + } + +-- +2.23.0 + diff --git a/0143-net-hns3-revert-Tx-performance-optimization.patch b/0143-net-hns3-revert-Tx-performance-optimization.patch new file mode 100644 index 0000000..41fb7b0 --- /dev/null +++ b/0143-net-hns3-revert-Tx-performance-optimization.patch @@ -0,0 +1,185 @@ +From 39caf6f8ce22bb3d8af12ab16b1182fe1679698d Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:19 +0800 +Subject: [PATCH 143/189] net/hns3: revert Tx performance optimization + +The Tx performance deteriorates in the case of larger packets size and +larger burst. It may take a long time to optimize in these scenarios, +so this commit reverts +commit 0b77e8f3d364 ("net/hns3: optimize Tx performance") + +Fixes: 0b77e8f3d364 ("net/hns3: optimize Tx performance") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 115 ++++++++++++++++++----------------- + 1 file changed, 60 insertions(+), 55 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 93cc70477d..21c3ef72b1 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -3075,51 +3075,40 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, + return 0; + } + +-static int ++static void + hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq) + { + uint16_t tx_next_clean = txq->next_to_clean; +- uint16_t tx_next_use = txq->next_to_use; +- struct hns3_entry *tx_entry = &txq->sw_ring[tx_next_clean]; ++ uint16_t tx_next_use = txq->next_to_use; ++ uint16_t tx_bd_ready = txq->tx_bd_ready; ++ uint16_t tx_bd_max = txq->nb_tx_desc; ++ struct hns3_entry *tx_bak_pkt = &txq->sw_ring[tx_next_clean]; + struct hns3_desc *desc = &txq->tx_ring[tx_next_clean]; +- uint16_t i; +- +- if (tx_next_use >= tx_next_clean && +- tx_next_use < tx_next_clean + txq->tx_rs_thresh) +- return -1; ++ struct rte_mbuf *mbuf; + +- /* +- * All mbufs can be released only when the VLD bits of all +- * descriptors in a batch are cleared. +- */ +- for (i = 0; i < txq->tx_rs_thresh; i++) { +- if (desc[i].tx.tp_fe_sc_vld_ra_ri & +- rte_le_to_cpu_16(BIT(HNS3_TXD_VLD_B))) +- return -1; +- } ++ while ((!(desc->tx.tp_fe_sc_vld_ra_ri & ++ rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B)))) && ++ tx_next_use != tx_next_clean) { ++ mbuf = tx_bak_pkt->mbuf; ++ if (mbuf) { ++ rte_pktmbuf_free_seg(mbuf); ++ tx_bak_pkt->mbuf = NULL; ++ } + +- for (i = 0; i < txq->tx_rs_thresh; i++) { +- rte_pktmbuf_free_seg(tx_entry[i].mbuf); +- tx_entry[i].mbuf = NULL; ++ desc++; ++ tx_bak_pkt++; ++ tx_next_clean++; ++ tx_bd_ready++; ++ ++ if (tx_next_clean >= tx_bd_max) { ++ tx_next_clean = 0; ++ desc = txq->tx_ring; ++ tx_bak_pkt = txq->sw_ring; ++ } + } + +- /* Update numbers of available descriptor due to buffer freed */ +- txq->tx_bd_ready += txq->tx_rs_thresh; +- txq->next_to_clean += txq->tx_rs_thresh; +- if (txq->next_to_clean >= txq->nb_tx_desc) +- txq->next_to_clean = 0; +- +- return 0; +-} +- +-static inline int +-hns3_tx_free_required_buffer(struct hns3_tx_queue *txq, uint16_t required_bds) +-{ +- while (required_bds > txq->tx_bd_ready) { +- if (hns3_tx_free_useless_buffer(txq) != 0) +- return -1; +- } +- return 0; ++ txq->next_to_clean = tx_next_clean; ++ txq->tx_bd_ready = tx_bd_ready; + } + + int +@@ -4162,8 +4151,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) + uint16_t nb_tx; + uint16_t i; + +- if (txq->tx_bd_ready < txq->tx_free_thresh) +- (void)hns3_tx_free_useless_buffer(txq); ++ hns3_tx_free_useless_buffer(txq); + + tx_next_use = txq->next_to_use; + tx_bd_max = txq->nb_tx_desc; +@@ -4178,14 +4166,10 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) + nb_buf = tx_pkt->nb_segs; + + if (nb_buf > txq->tx_bd_ready) { +- /* Try to release the required MBUF, but avoid releasing +- * all MBUFs, otherwise, the MBUFs will be released for +- * a long time and may cause jitter. +- */ +- if (hns3_tx_free_required_buffer(txq, nb_buf) != 0) { +- txq->dfx_stats.queue_full_cnt++; +- goto end_of_tx; +- } ++ txq->dfx_stats.queue_full_cnt++; ++ if (nb_tx == 0) ++ return 0; ++ goto end_of_tx; + } + + /* +@@ -4609,22 +4593,43 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) + static int + hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) + { +- uint16_t round_cnt; ++ uint16_t next_to_clean = txq->next_to_clean; ++ uint16_t next_to_use = txq->next_to_use; ++ uint16_t tx_bd_ready = txq->tx_bd_ready; ++ struct hns3_entry *tx_pkt = &txq->sw_ring[next_to_clean]; ++ struct hns3_desc *desc = &txq->tx_ring[next_to_clean]; + uint32_t idx; + + if (free_cnt == 0 || free_cnt > txq->nb_tx_desc) + free_cnt = txq->nb_tx_desc; + +- if (txq->tx_rs_thresh == 0) +- return 0; +- +- round_cnt = rounddown(free_cnt, txq->tx_rs_thresh); +- for (idx = 0; idx < round_cnt; idx += txq->tx_rs_thresh) { +- if (hns3_tx_free_useless_buffer(txq) != 0) ++ for (idx = 0; idx < free_cnt; idx++) { ++ if (next_to_clean == next_to_use) ++ break; ++ if (desc->tx.tp_fe_sc_vld_ra_ri & ++ rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B))) + break; ++ if (tx_pkt->mbuf != NULL) { ++ rte_pktmbuf_free_seg(tx_pkt->mbuf); ++ tx_pkt->mbuf = NULL; ++ } ++ next_to_clean++; ++ tx_bd_ready++; ++ tx_pkt++; ++ desc++; ++ if (next_to_clean == txq->nb_tx_desc) { ++ tx_pkt = txq->sw_ring; ++ desc = txq->tx_ring; ++ next_to_clean = 0; ++ } ++ } ++ ++ if (idx > 0) { ++ txq->next_to_clean = next_to_clean; ++ txq->tx_bd_ready = tx_bd_ready; + } + +- return idx; ++ return (int)idx; + } + + int +-- +2.23.0 + diff --git a/0144-net-hns3-fix-RSS-rule-restore.patch b/0144-net-hns3-fix-RSS-rule-restore.patch new file mode 100644 index 0000000..2eca942 --- /dev/null +++ b/0144-net-hns3-fix-RSS-rule-restore.patch @@ -0,0 +1,71 @@ +From 85b5d5a0807856f276bb382af7a443e030975cce Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:20 +0800 +Subject: [PATCH 144/189] net/hns3: fix RSS rule restore + +The 'hns3_restore_rss_filter' function is used to restore RSS rule. +But this function calls the 'hns3_config_rss_filter' which sets the +last to invalid in flow RSS list. This causes the flow RSS list has +no valid rule. + +Fixes: ec674cb742e5 ("net/hns3: fix flushing RSS rule") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 17 +++++++++-------- + 1 file changed, 9 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 5e0a9bc93f..8b9bfe4880 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1539,7 +1539,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, + const struct hns3_rss_conf *conf, bool add) + { + struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_rss_conf_ele *rss_filter_ptr; + struct hns3_hw *hw = &hns->hw; + struct hns3_rss_conf *rss_info; + uint64_t flow_types; +@@ -1618,13 +1617,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, + goto rss_config_err; + } + +- /* +- * When create a new RSS rule, the old rule will be overlaid and set +- * invalid. +- */ +- TAILQ_FOREACH(rss_filter_ptr, &hw->flow_rss_list, entries) +- rss_filter_ptr->filter_info.valid = false; +- + rss_config_err: + rte_spinlock_unlock(&hw->lock); + +@@ -1749,6 +1741,7 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct hns3_rss_conf_ele *rss_filter_ptr; ++ struct hns3_rss_conf_ele *filter_ptr; + const struct hns3_rss_conf *rss_conf; + int ret; + +@@ -1773,6 +1766,14 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + + hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf); + rss_filter_ptr->filter_info.valid = true; ++ ++ /* ++ * When create a new RSS rule, the old rule will be overlaid and set ++ * invalid. ++ */ ++ TAILQ_FOREACH(filter_ptr, &hw->flow_rss_list, entries) ++ filter_ptr->filter_info.valid = false; ++ + TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries); + flow->rule = rss_filter_ptr; + flow->filter_type = RTE_ETH_FILTER_HASH; +-- +2.23.0 + diff --git a/0145-net-hns3-fix-RSS-filter-restore.patch b/0145-net-hns3-fix-RSS-filter-restore.patch new file mode 100644 index 0000000..6860ca5 --- /dev/null +++ b/0145-net-hns3-fix-RSS-filter-restore.patch @@ -0,0 +1,65 @@ +From 2e78798fe932e9064677c6f2d1ea14542c503202 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:21 +0800 +Subject: [PATCH 145/189] net/hns3: fix RSS filter restore + +Currently, driver sets RSS function to 'RTE_ETH_HASH_FUNCTION_MAX' +when user flush all rules in order to judge whether driver needs +to restore RSS rules. In fact, all rules are saved in flow RSS list. +So there is no need to modify RSS function to this macro. And this +list can be used to restore. The modification of RSS function may +introduce new problem. + +Fixes: eb158fc756a5 ("net/hns3: fix config when creating RSS rule after flush") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 20 ++++++++++++++------ + 1 file changed, 14 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 8b9bfe4880..82ead96854 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1587,8 +1587,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, + rss_info->conf.queue_num = 0; + } + +- /* set RSS func invalid after flushed */ +- rss_info->conf.func = RTE_ETH_HASH_FUNCTION_MAX; + return 0; + } + +@@ -1659,13 +1657,23 @@ int + hns3_restore_rss_filter(struct rte_eth_dev *dev) + { + struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_rss_conf_ele *filter; + struct hns3_hw *hw = &hns->hw; ++ int ret = 0; + +- /* When user flush all rules, it doesn't need to restore RSS rule */ +- if (hw->rss_info.conf.func == RTE_ETH_HASH_FUNCTION_MAX) +- return 0; ++ TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) { ++ if (!filter->filter_info.valid) ++ continue; + +- return hns3_config_rss_filter(dev, &hw->rss_info, true); ++ ret = hns3_config_rss_filter(dev, &filter->filter_info, true); ++ if (ret != 0) { ++ hns3_err(hw, "restore RSS filter failed, ret=%d", ret); ++ goto out; ++ } ++ } ++ ++out: ++ return ret; + } + + static int +-- +2.23.0 + diff --git a/0146-net-hns3-fix-lock-protection-of-RSS-flow-rule.patch b/0146-net-hns3-fix-lock-protection-of-RSS-flow-rule.patch new file mode 100644 index 0000000..e2b0e4b --- /dev/null +++ b/0146-net-hns3-fix-lock-protection-of-RSS-flow-rule.patch @@ -0,0 +1,74 @@ +From baa250c283ba4180f3ac55b42c74f98d85860598 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:22 +0800 +Subject: [PATCH 146/189] net/hns3: fix lock protection of RSS flow rule + +RSS flow rules are saved in RSS filter linked list. The linked +list is modified by rte_flow API and is used to restore RSS rules +during reset process. So this patch uses 'hw->flows_lock' to protect +the configuration and recovery of RSS rule. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 16 ++++++---------- + 1 file changed, 6 insertions(+), 10 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 82ead96854..301a4a56b3 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1596,27 +1596,20 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, + hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated", + rss_flow_conf.queue_num); + hns3_info(hw, "Max of contiguous %u PF queues are configured", num); +- +- rte_spinlock_lock(&hw->lock); + if (num) { + ret = hns3_update_indir_table(dev, &rss_flow_conf, num); + if (ret) +- goto rss_config_err; ++ return ret; + } + + /* Set hash algorithm and flow types by the user's config */ + ret = hns3_hw_rss_hash_set(hw, &rss_flow_conf); + if (ret) +- goto rss_config_err; ++ return ret; + + ret = hns3_rss_conf_copy(rss_info, &rss_flow_conf); +- if (ret) { ++ if (ret) + hns3_err(hw, "RSS config init fail(%d)", ret); +- goto rss_config_err; +- } +- +-rss_config_err: +- rte_spinlock_unlock(&hw->lock); + + return ret; + } +@@ -1661,6 +1654,7 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev) + struct hns3_hw *hw = &hns->hw; + int ret = 0; + ++ pthread_mutex_lock(&hw->flows_lock); + TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) { + if (!filter->filter_info.valid) + continue; +@@ -1673,6 +1667,8 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev) + } + + out: ++ pthread_mutex_unlock(&hw->flows_lock); ++ + return ret; + } + +-- +2.23.0 + diff --git a/0147-net-hns3-fix-RSS-flow-rule-restore.patch b/0147-net-hns3-fix-RSS-flow-rule-restore.patch new file mode 100644 index 0000000..da815ee --- /dev/null +++ b/0147-net-hns3-fix-RSS-flow-rule-restore.patch @@ -0,0 +1,159 @@ +From c05520ce0dfe94fd8a676a4d69502f6abc67df08 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:23 +0800 +Subject: [PATCH 147/189] net/hns3: fix RSS flow rule restore + +After reset process, types of RSS flow rule cannot be restored when +load driver without RTE_ETH_MQ_RX_RSS_FLAG flag. This is because the +restoration for RSS flow rule is done in the 'hns3_config_rss()'. But +this function is also used to configure and restore RSS configuration +from ethdev ops, and doesn't configure RSS types if 'rxmode.mq_mode' +has not the flag. As a result, RSS types configured by rte flow API +can't be restored in this case when encounter reset. Actually, all +RSS rules are saved to a global link list. + +Use the linked list to restore RSS flow rule. + +Fixes: 920be799dbc3 ("net/hns3: fix RSS indirection table configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 11 ++--------- + drivers/net/hns3/hns3_ethdev_vf.c | 11 ++--------- + drivers/net/hns3/hns3_flow.c | 8 +++++++- + drivers/net/hns3/hns3_flow.h | 1 + + drivers/net/hns3/hns3_rss.h | 1 - + 5 files changed, 12 insertions(+), 20 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 24ee9df332..fc3fc76a40 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5006,6 +5006,7 @@ static int + hns3_do_start(struct hns3_adapter *hns, bool reset_queue) + { + struct hns3_hw *hw = &hns->hw; ++ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + bool link_en; + int ret; + +@@ -5042,7 +5043,7 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) + if (ret) + goto err_set_link_speed; + +- return 0; ++ return hns3_restore_filter(dev); + + err_set_link_speed: + (void)hns3_cfg_mac_mode(hw, false); +@@ -5059,12 +5060,6 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) + return ret; + } + +-static void +-hns3_restore_filter(struct rte_eth_dev *dev) +-{ +- hns3_restore_rss_filter(dev); +-} +- + static int + hns3_dev_start(struct rte_eth_dev *dev) + { +@@ -5121,8 +5116,6 @@ hns3_dev_start(struct rte_eth_dev *dev) + hns3_set_rxtx_function(dev); + hns3_mp_req_start_rxtx(dev); + +- hns3_restore_filter(dev); +- + /* Enable interrupt of all rx queues before enabling queues */ + hns3_dev_all_rx_queue_intr_enable(hw, true); + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index db2f15abe2..13f1cba0e6 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1727,6 +1727,7 @@ static int + hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue) + { + struct hns3_hw *hw = &hns->hw; ++ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + uint16_t nb_rx_q = hw->data->nb_rx_queues; + uint16_t nb_tx_q = hw->data->nb_tx_queues; + int ret; +@@ -1741,13 +1742,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue) + if (ret) + hns3_err(hw, "failed to init queues, ret = %d.", ret); + +- return ret; +-} +- +-static void +-hns3vf_restore_filter(struct rte_eth_dev *dev) +-{ +- hns3_restore_rss_filter(dev); ++ return hns3_restore_filter(dev); + } + + static int +@@ -1799,8 +1794,6 @@ hns3vf_dev_start(struct rte_eth_dev *dev) + hns3_set_rxtx_function(dev); + hns3_mp_req_start_rxtx(dev); + +- hns3vf_restore_filter(dev); +- + /* Enable interrupt of all rx queues before enabling queues */ + hns3_dev_all_rx_queue_intr_enable(hw, true); + hns3_start_tqps(hw); +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 301a4a56b3..7bd2f0bf7a 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1646,7 +1646,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) + return ret; + } + +-int ++static int + hns3_restore_rss_filter(struct rte_eth_dev *dev) + { + struct hns3_adapter *hns = dev->data->dev_private; +@@ -1672,6 +1672,12 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev) + return ret; + } + ++int ++hns3_restore_filter(struct rte_eth_dev *dev) ++{ ++ return hns3_restore_rss_filter(dev); ++} ++ + static int + hns3_flow_parse_rss(struct rte_eth_dev *dev, + const struct hns3_rss_conf *conf, bool add) +diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h +index 1ab3f9f5c6..0f5de129a3 100644 +--- a/drivers/net/hns3/hns3_flow.h ++++ b/drivers/net/hns3/hns3_flow.h +@@ -49,5 +49,6 @@ int hns3_dev_flow_ops_get(struct rte_eth_dev *dev, + const struct rte_flow_ops **ops); + void hns3_flow_init(struct rte_eth_dev *dev); + void hns3_flow_uninit(struct rte_eth_dev *dev); ++int hns3_restore_filter(struct rte_eth_dev *dev); + + #endif /* _HNS3_FLOW_H_ */ +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 5b90d3a628..78c9eff827 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -110,6 +110,5 @@ int hns3_config_rss(struct hns3_adapter *hns); + void hns3_rss_uninit(struct hns3_adapter *hns); + int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); + int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key); +-int hns3_restore_rss_filter(struct rte_eth_dev *dev); + + #endif /* _HNS3_RSS_H_ */ +-- +2.23.0 + diff --git a/0148-net-hns3-move-flow-direction-rule-recovery.patch b/0148-net-hns3-move-flow-direction-rule-recovery.patch new file mode 100644 index 0000000..1428150 --- /dev/null +++ b/0148-net-hns3-move-flow-direction-rule-recovery.patch @@ -0,0 +1,71 @@ +From d982e1518b7fc217dbf14816b0b929079d742137 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:24 +0800 +Subject: [PATCH 148/189] net/hns3: move flow direction rule recovery + +The 'hns3_restore_filter' is used to restore flow rules from +rte_flow API during the reset process. This patch moves the +recovery of flow direction rule to this function to improve +code maintainability. + +Fixes: fcba820d9b9e ("net/hns3: support flow director") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 4 ---- + drivers/net/hns3/hns3_fdir.c | 3 +++ + drivers/net/hns3/hns3_flow.c | 7 +++++++ + 3 files changed, 10 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index fc3fc76a40..01c13f8d70 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5907,10 +5907,6 @@ hns3_restore_conf(struct hns3_adapter *hns) + if (ret) + goto err_promisc; + +- ret = hns3_restore_all_fdir_filter(hns); +- if (ret) +- goto err_promisc; +- + ret = hns3_restore_ptp(hns); + if (ret) + goto err_promisc; +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index 30e5e66772..48a91fb517 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -1068,6 +1068,9 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns) + bool err = false; + int ret; + ++ if (hns->is_vf) ++ return 0; ++ + /* + * This API is called in the reset recovery process, the parent function + * must hold hw->lock. +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 7bd2f0bf7a..17c4274123 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1675,6 +1675,13 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev) + int + hns3_restore_filter(struct rte_eth_dev *dev) + { ++ struct hns3_adapter *hns = dev->data->dev_private; ++ int ret; ++ ++ ret = hns3_restore_all_fdir_filter(hns); ++ if (ret != 0) ++ return ret; ++ + return hns3_restore_rss_filter(dev); + } + +-- +2.23.0 + diff --git a/0149-net-hns3-fix-restore-filter-function-input.patch b/0149-net-hns3-fix-restore-filter-function-input.patch new file mode 100644 index 0000000..2d68011 --- /dev/null +++ b/0149-net-hns3-fix-restore-filter-function-input.patch @@ -0,0 +1,195 @@ +From 470e1b242046d7968ce039428201cc6c9595e114 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:25 +0800 +Subject: [PATCH 149/189] net/hns3: fix restore filter function input + +This 'hns3_restore_filter' is an internal interface of driver. +Currently, it uses 'struct rte_eth_dev *dev' as input parameter, +This is inconvenient for the function to call in driver because +caller has to obtain its device address by global variable +'rte_eth_devices[]'. Fix the input of this function. + +Fixes: 920be799dbc3 ("net/hns3: fix RSS indirection table configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 3 +-- + drivers/net/hns3/hns3_ethdev_vf.c | 3 +-- + drivers/net/hns3/hns3_flow.c | 30 ++++++++++++------------------ + drivers/net/hns3/hns3_flow.h | 2 +- + 4 files changed, 15 insertions(+), 23 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 01c13f8d70..c59543ef5b 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5006,7 +5006,6 @@ static int + hns3_do_start(struct hns3_adapter *hns, bool reset_queue) + { + struct hns3_hw *hw = &hns->hw; +- struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + bool link_en; + int ret; + +@@ -5043,7 +5042,7 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) + if (ret) + goto err_set_link_speed; + +- return hns3_restore_filter(dev); ++ return hns3_restore_filter(hns); + + err_set_link_speed: + (void)hns3_cfg_mac_mode(hw, false); +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 13f1cba0e6..72d60191ab 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1727,7 +1727,6 @@ static int + hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue) + { + struct hns3_hw *hw = &hns->hw; +- struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + uint16_t nb_rx_q = hw->data->nb_rx_queues; + uint16_t nb_tx_q = hw->data->nb_tx_queues; + int ret; +@@ -1742,7 +1741,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue) + if (ret) + hns3_err(hw, "failed to init queues, ret = %d.", ret); + +- return hns3_restore_filter(dev); ++ return hns3_restore_filter(hns); + } + + static int +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 17c4274123..2b4286d46d 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1508,11 +1508,9 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + } + + static int +-hns3_update_indir_table(struct rte_eth_dev *dev, ++hns3_update_indir_table(struct hns3_hw *hw, + const struct rte_flow_action_rss *conf, uint16_t num) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; + uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; + uint16_t j; + uint32_t i; +@@ -1535,11 +1533,9 @@ hns3_update_indir_table(struct rte_eth_dev *dev, + } + + static int +-hns3_config_rss_filter(struct rte_eth_dev *dev, ++hns3_config_rss_filter(struct hns3_hw *hw, + const struct hns3_rss_conf *conf, bool add) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; + struct hns3_rss_conf *rss_info; + uint64_t flow_types; + uint16_t num; +@@ -1591,13 +1587,13 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, + } + + /* Set rx queues to use */ +- num = RTE_MIN(dev->data->nb_rx_queues, rss_flow_conf.queue_num); ++ num = RTE_MIN(hw->data->nb_rx_queues, rss_flow_conf.queue_num); + if (rss_flow_conf.queue_num > num) + hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated", + rss_flow_conf.queue_num); + hns3_info(hw, "Max of contiguous %u PF queues are configured", num); + if (num) { +- ret = hns3_update_indir_table(dev, &rss_flow_conf, num); ++ ret = hns3_update_indir_table(hw, &rss_flow_conf, num); + if (ret) + return ret; + } +@@ -1627,7 +1623,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) + rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); + while (rss_filter_ptr) { + TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); +- ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info, ++ ret = hns3_config_rss_filter(hw, &rss_filter_ptr->filter_info, + false); + if (ret) + rss_rule_fail_cnt++; +@@ -1647,11 +1643,9 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) + } + + static int +-hns3_restore_rss_filter(struct rte_eth_dev *dev) ++hns3_restore_rss_filter(struct hns3_hw *hw) + { +- struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_rss_conf_ele *filter; +- struct hns3_hw *hw = &hns->hw; + int ret = 0; + + pthread_mutex_lock(&hw->flows_lock); +@@ -1659,7 +1653,7 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev) + if (!filter->filter_info.valid) + continue; + +- ret = hns3_config_rss_filter(dev, &filter->filter_info, true); ++ ret = hns3_config_rss_filter(hw, &filter->filter_info, true); + if (ret != 0) { + hns3_err(hw, "restore RSS filter failed, ret=%d", ret); + goto out; +@@ -1673,16 +1667,16 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev) + } + + int +-hns3_restore_filter(struct rte_eth_dev *dev) ++hns3_restore_filter(struct hns3_adapter *hns) + { +- struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = &hns->hw; + int ret; + + ret = hns3_restore_all_fdir_filter(hns); + if (ret != 0) + return ret; + +- return hns3_restore_rss_filter(dev); ++ return hns3_restore_rss_filter(hw); + } + + static int +@@ -1699,7 +1693,7 @@ hns3_flow_parse_rss(struct rte_eth_dev *dev, + return -EINVAL; + } + +- return hns3_config_rss_filter(dev, conf, add); ++ return hns3_config_rss_filter(hw, conf, add); + } + + static int +@@ -1960,7 +1954,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, + break; + case RTE_ETH_FILTER_HASH: + rss_filter_ptr = (struct hns3_rss_conf_ele *)flow->rule; +- ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info, ++ ret = hns3_config_rss_filter(hw, &rss_filter_ptr->filter_info, + false); + if (ret) + return rte_flow_error_set(error, EIO, +diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h +index 0f5de129a3..854fbb7ff0 100644 +--- a/drivers/net/hns3/hns3_flow.h ++++ b/drivers/net/hns3/hns3_flow.h +@@ -49,6 +49,6 @@ int hns3_dev_flow_ops_get(struct rte_eth_dev *dev, + const struct rte_flow_ops **ops); + void hns3_flow_init(struct rte_eth_dev *dev); + void hns3_flow_uninit(struct rte_eth_dev *dev); +-int hns3_restore_filter(struct rte_eth_dev *dev); ++int hns3_restore_filter(struct hns3_adapter *hns); + + #endif /* _HNS3_FLOW_H_ */ +-- +2.23.0 + diff --git a/0150-net-hns3-fix-build-with-gcov.patch b/0150-net-hns3-fix-build-with-gcov.patch new file mode 100644 index 0000000..0218795 --- /dev/null +++ b/0150-net-hns3-fix-build-with-gcov.patch @@ -0,0 +1,37 @@ +From 0acb77e818a7a0e71126667f0624c19c2706f59c Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Fri, 21 Oct 2022 15:36:26 +0800 +Subject: [PATCH 150/189] net/hns3: fix build with gcov +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +meson build -Db_coverage=true +ninja -C build + +../drivers/net/hns3/hns3_ethdev.c:2856:22: warning: ‘cfg.umv_space’ may be +used uninitialized in this function [-Wmaybe-uninitialized] + 2856 | pf->wanted_umv_size = cfg.umv_space; + +Fix compiling warnings using gcc 10.3.1. + +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index c59543ef5b..45b5d699b4 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2808,6 +2808,7 @@ hns3_get_board_configuration(struct hns3_hw *hw) + struct hns3_cfg cfg; + int ret; + ++ memset(&cfg, 0, sizeof(cfg)); + ret = hns3_get_board_cfg(hw, &cfg); + if (ret) { + PMD_INIT_LOG(ERR, "get board config failed %d", ret); +-- +2.23.0 + diff --git a/0151-net-hns3-fix-packet-type-for-GENEVE.patch b/0151-net-hns3-fix-packet-type-for-GENEVE.patch new file mode 100644 index 0000000..c86ef9b --- /dev/null +++ b/0151-net-hns3-fix-packet-type-for-GENEVE.patch @@ -0,0 +1,44 @@ +From c2fd801565933c744bc6342f9dad56de644d68a3 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:27 +0800 +Subject: [PATCH 151/189] net/hns3: fix packet type for GENEVE + +Currently, hns3 reports VXLAN tunnel packet type for GENEVE, +which is misleading to user. In fact, hns3 hardware cannot +distinguish between VXLAN and GENEVE packet. So this patch +uses RTE_PTYPE_TUNNEL_GRENAT packet type to report. + +Fixes: 7d6df32cf742 ("net/hns3: fix missing outer L4 UDP flag for VXLAN") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 21c3ef72b1..089caccd7f 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -1995,7 +1995,7 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev) + RTE_PTYPE_INNER_L4_TCP, + RTE_PTYPE_INNER_L4_SCTP, + RTE_PTYPE_INNER_L4_ICMP, +- RTE_PTYPE_TUNNEL_VXLAN, ++ RTE_PTYPE_TUNNEL_GRENAT, + RTE_PTYPE_TUNNEL_NVGRE, + RTE_PTYPE_UNKNOWN + }; +@@ -2092,7 +2092,7 @@ hns3_init_tunnel_ptype_tbl(struct hns3_ptype_table *tbl) + tbl->ol3table[5] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT; + + tbl->ol4table[0] = RTE_PTYPE_UNKNOWN; +- tbl->ol4table[1] = RTE_PTYPE_L4_UDP | RTE_PTYPE_TUNNEL_VXLAN; ++ tbl->ol4table[1] = RTE_PTYPE_L4_UDP | RTE_PTYPE_TUNNEL_GRENAT; + tbl->ol4table[2] = RTE_PTYPE_TUNNEL_NVGRE; + } + +-- +2.23.0 + diff --git a/0152-net-hns3-remove-magic-numbers-for-MAC-address.patch b/0152-net-hns3-remove-magic-numbers-for-MAC-address.patch new file mode 100644 index 0000000..68fd0c9 --- /dev/null +++ b/0152-net-hns3-remove-magic-numbers-for-MAC-address.patch @@ -0,0 +1,40 @@ +From 36416b8c0fd1918ed0f89cca83b8c21e22a529c7 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Fri, 21 Oct 2022 15:36:28 +0800 +Subject: [PATCH 152/189] net/hns3: remove magic numbers for MAC address + +Removing magic numbers with macros. + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 45b5d699b4..adc47d815d 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -1713,6 +1713,7 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) + char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; + uint8_t vf_id; + int ret; ++ int idx; + + /* Check if mac addr is valid */ + if (!rte_is_multicast_ether_addr(mac_addr)) { +@@ -1730,9 +1731,8 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) + HNS3_MC_MAC_VLAN_OPS_DESC_NUM); + if (ret) { + /* This mac addr do not exist, add new entry for it */ +- memset(desc[0].data, 0, sizeof(desc[0].data)); +- memset(desc[1].data, 0, sizeof(desc[0].data)); +- memset(desc[2].data, 0, sizeof(desc[0].data)); ++ for (idx = 0; idx < HNS3_MC_MAC_VLAN_OPS_DESC_NUM; idx++) ++ memset(desc[idx].data, 0, sizeof(desc[idx].data)); + } + + /* +-- +2.23.0 + diff --git a/0153-net-hns3-fix-code-check-warnings.patch b/0153-net-hns3-fix-code-check-warnings.patch new file mode 100644 index 0000000..564a862 --- /dev/null +++ b/0153-net-hns3-fix-code-check-warnings.patch @@ -0,0 +1,379 @@ +From 308a29f8342797bedb8005b7061a9b10be36cc6c Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 21 Oct 2022 15:36:29 +0800 +Subject: [PATCH 153/189] net/hns3: fix code check warnings + +Fix code check warnings according to: + - function should have same name with previous declaration; + - local variable should no be referenced in macro referenced; + - macro argument 'adapter' should be enclosed in parentheses. + +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_common.c | 4 ++-- + drivers/net/hns3/hns3_dump.c | 4 ++-- + drivers/net/hns3/hns3_ethdev.h | 14 +++++++------- + drivers/net/hns3/hns3_flow.c | 4 ++-- + drivers/net/hns3/hns3_intr.c | 27 ++++++++++++--------------- + drivers/net/hns3/hns3_intr.h | 4 ++-- + drivers/net/hns3/hns3_regs.c | 4 ++-- + drivers/net/hns3/hns3_rss.c | 2 +- + drivers/net/hns3/hns3_rss.h | 2 +- + drivers/net/hns3/hns3_rxtx.c | 4 ++-- + drivers/net/hns3/hns3_rxtx.h | 14 +++++++++----- + drivers/net/hns3/hns3_stats.h | 5 +++-- + 12 files changed, 45 insertions(+), 43 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 7a65db907e..1a1a016aa6 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -493,7 +493,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) + if (ret) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, + addr); +- hns3_err(hw, "failed to %s mac addr(%s) index:%d ret = %d.", ++ hns3_err(hw, "failed to %s mac addr(%s) index:%u ret = %d.", + del ? "remove" : "restore", mac_str, i, ret); + } + } +@@ -680,7 +680,7 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) + ret = hw->ops.bind_ring_with_vector(hw, vec, false, + HNS3_RING_TYPE_TX, i); + if (ret) { +- PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with vector: %u, ret=%d", ++ PMD_INIT_LOG(ERR, "fail to unbind TX ring(%u) with vector: %u, ret=%d", + i, vec, ret); + return ret; + } +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index 646e93d8e6..cf5b500be1 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -342,7 +342,7 @@ static void + hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state, + uint32_t nb_queues, uint32_t line_num) + { +-#define HNS3_NUM_QUEUE_PER_LINE (sizeof(*queue_state) * HNS3_UINT8_BIT) ++#define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT) + uint32_t id = line_num * HNS3_NUM_QUEUE_PER_LINE; + uint32_t i; + +@@ -365,7 +365,7 @@ static void + hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state, + uint32_t nb_queues, bool is_rxq) + { +-#define HNS3_NUM_QUEUE_PER_LINE (sizeof(*queue_state) * HNS3_UINT8_BIT) ++#define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT) + uint32_t i; + + fprintf(file, "\t %s queue id | enable state bitMap\n", +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index eb8ca1e60f..aad779e949 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -898,11 +898,11 @@ enum hns3_dev_cap { + hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_##_name##_B) + + #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ +- (&((struct hns3_adapter *)adapter)->hw) ++ (&((struct hns3_adapter *)(adapter))->hw) + #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ +- (&((struct hns3_adapter *)adapter)->pf) ++ (&((struct hns3_adapter *)(adapter))->pf) + #define HNS3_DEV_PRIVATE_TO_VF(adapter) \ +- (&((struct hns3_adapter *)adapter)->vf) ++ (&((struct hns3_adapter *)(adapter))->vf) + #define HNS3_DEV_HW_TO_ADAPTER(hw) \ + container_of(hw, struct hns3_adapter, hw) + +@@ -999,10 +999,10 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) + + #define NEXT_ITEM_OF_ACTION(act, actions, index) \ + do { \ +- act = (actions) + (index); \ +- while (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \ ++ (act) = (actions) + (index); \ ++ while ((act)->type == RTE_FLOW_ACTION_TYPE_VOID) { \ + (index)++; \ +- act = actions + index; \ ++ (act) = (actions) + (index); \ + } \ + } while (0) + +@@ -1027,7 +1027,7 @@ hns3_atomic_clear_bit(unsigned int nr, volatile uint64_t *addr) + __atomic_fetch_and(addr, ~(1UL << nr), __ATOMIC_RELAXED); + } + +-static inline int64_t ++static inline uint64_t + hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr) + { + uint64_t mask = (1UL << nr); +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 2b4286d46d..1aee965e4a 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -66,7 +66,7 @@ static enum rte_flow_item_type tunnel_next_items[] = { + + struct items_step_mngr { + enum rte_flow_item_type *items; +- int count; ++ size_t count; + }; + + static inline void +@@ -1141,7 +1141,7 @@ hns3_validate_item(const struct rte_flow_item *item, + struct items_step_mngr step_mngr, + struct rte_flow_error *error) + { +- int i; ++ uint32_t i; + + if (item->last) + return rte_flow_error_set(error, ENOTSUP, +diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c +index 3ca2e1e338..4bdcd6070b 100644 +--- a/drivers/net/hns3/hns3_intr.c ++++ b/drivers/net/hns3/hns3_intr.c +@@ -16,12 +16,6 @@ + + #define SWITCH_CONTEXT_US 10 + +-#define HNS3_CHECK_MERGE_CNT(val) \ +- do { \ +- if (val) \ +- hw->reset.stats.merge_cnt++; \ +- } while (0) +- + static const char *reset_string[HNS3_MAX_RESET] = { + "flr", "vf_func", "vf_pf_func", "vf_full", "vf_global", + "pf_func", "global", "IMP", "none", +@@ -2525,20 +2519,20 @@ static void + hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels) + { + uint64_t merge_cnt = hw->reset.stats.merge_cnt; +- int64_t tmp; ++ uint64_t tmp; + + switch (hw->reset.level) { + case HNS3_IMP_RESET: + hns3_atomic_clear_bit(HNS3_IMP_RESET, levels); + tmp = hns3_test_and_clear_bit(HNS3_GLOBAL_RESET, levels); +- HNS3_CHECK_MERGE_CNT(tmp); ++ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; + tmp = hns3_test_and_clear_bit(HNS3_FUNC_RESET, levels); +- HNS3_CHECK_MERGE_CNT(tmp); ++ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; + break; + case HNS3_GLOBAL_RESET: + hns3_atomic_clear_bit(HNS3_GLOBAL_RESET, levels); + tmp = hns3_test_and_clear_bit(HNS3_FUNC_RESET, levels); +- HNS3_CHECK_MERGE_CNT(tmp); ++ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; + break; + case HNS3_FUNC_RESET: + hns3_atomic_clear_bit(HNS3_FUNC_RESET, levels); +@@ -2546,19 +2540,19 @@ hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels) + case HNS3_VF_RESET: + hns3_atomic_clear_bit(HNS3_VF_RESET, levels); + tmp = hns3_test_and_clear_bit(HNS3_VF_PF_FUNC_RESET, levels); +- HNS3_CHECK_MERGE_CNT(tmp); ++ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; + tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels); +- HNS3_CHECK_MERGE_CNT(tmp); ++ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; + break; + case HNS3_VF_FULL_RESET: + hns3_atomic_clear_bit(HNS3_VF_FULL_RESET, levels); + tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels); +- HNS3_CHECK_MERGE_CNT(tmp); ++ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; + break; + case HNS3_VF_PF_FUNC_RESET: + hns3_atomic_clear_bit(HNS3_VF_PF_FUNC_RESET, levels); + tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels); +- HNS3_CHECK_MERGE_CNT(tmp); ++ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; + break; + case HNS3_VF_FUNC_RESET: + hns3_atomic_clear_bit(HNS3_VF_FUNC_RESET, levels); +@@ -2570,13 +2564,16 @@ hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels) + default: + return; + }; +- if (merge_cnt != hw->reset.stats.merge_cnt) ++ ++ if (merge_cnt != hw->reset.stats.merge_cnt) { + hns3_warn(hw, + "No need to do low-level reset after %s reset. " + "merge cnt: %" PRIu64 " total merge cnt: %" PRIu64, + reset_string[hw->reset.level], + hw->reset.stats.merge_cnt - merge_cnt, + hw->reset.stats.merge_cnt); ++ hw->reset.stats.merge_cnt = merge_cnt; ++ } + } + + static bool +diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h +index 1a0f196614..1490a5e387 100644 +--- a/drivers/net/hns3/hns3_intr.h ++++ b/drivers/net/hns3/hns3_intr.h +@@ -170,7 +170,7 @@ struct hns3_hw_error_desc { + const struct hns3_hw_error *hw_err; + }; + +-int hns3_enable_hw_error_intr(struct hns3_adapter *hns, bool state); ++int hns3_enable_hw_error_intr(struct hns3_adapter *hns, bool en); + void hns3_handle_msix_error(struct hns3_adapter *hns, uint64_t *levels); + void hns3_handle_ras_error(struct hns3_adapter *hns, uint64_t *levels); + void hns3_config_mac_tnl_int(struct hns3_hw *hw, bool en); +@@ -185,7 +185,7 @@ void hns3_schedule_reset(struct hns3_adapter *hns); + void hns3_schedule_delayed_reset(struct hns3_adapter *hns); + int hns3_reset_req_hw_reset(struct hns3_adapter *hns); + int hns3_reset_process(struct hns3_adapter *hns, +- enum hns3_reset_level reset_level); ++ enum hns3_reset_level new_level); + void hns3_reset_abort(struct hns3_adapter *hns); + void hns3_start_report_lse(struct rte_eth_dev *dev); + void hns3_stop_report_lse(struct rte_eth_dev *dev); +diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c +index 6778e4cfc2..33392fd1f0 100644 +--- a/drivers/net/hns3/hns3_regs.c ++++ b/drivers/net/hns3/hns3_regs.c +@@ -15,7 +15,7 @@ + #define REG_NUM_PER_LINE 4 + #define REG_LEN_PER_LINE (REG_NUM_PER_LINE * sizeof(uint32_t)) + +-static int hns3_get_dfx_reg_line(struct hns3_hw *hw, uint32_t *length); ++static int hns3_get_dfx_reg_line(struct hns3_hw *hw, uint32_t *lines); + + static const uint32_t cmdq_reg_addrs[] = {HNS3_CMDQ_TX_ADDR_L_REG, + HNS3_CMDQ_TX_ADDR_H_REG, +@@ -295,7 +295,7 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) + uint32_t *origin_data_ptr = data; + uint32_t reg_offset; + uint16_t i, j; +- int reg_num; ++ size_t reg_num; + + /* fetching per-PF registers values from PF PCIe register space */ + reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t); +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 1003daf03e..fc912ed2e8 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -10,7 +10,7 @@ + #include "hns3_logs.h" + + /* Default hash keys */ +-const uint8_t hns3_hash_key[] = { ++const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE] = { + 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, + 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0, + 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4, +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 78c9eff827..a12f8b7034 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -88,7 +88,7 @@ static inline uint32_t roundup_pow_of_two(uint32_t x) + return 1UL << fls(x - 1); + } + +-extern const uint8_t hns3_hash_key[]; ++extern const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE]; + + struct hns3_adapter; + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 089caccd7f..f7641b1309 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -2762,7 +2762,7 @@ hns3_rx_check_vec_support(__rte_unused struct rte_eth_dev *dev) + } + + uint16_t __rte_weak +-hns3_recv_pkts_vec(__rte_unused void *tx_queue, ++hns3_recv_pkts_vec(__rte_unused void *rx_queue, + __rte_unused struct rte_mbuf **rx_pkts, + __rte_unused uint16_t nb_pkts) + { +@@ -2770,7 +2770,7 @@ hns3_recv_pkts_vec(__rte_unused void *tx_queue, + } + + uint16_t __rte_weak +-hns3_recv_pkts_vec_sve(__rte_unused void *tx_queue, ++hns3_recv_pkts_vec_sve(__rte_unused void *rx_queue, + __rte_unused struct rte_mbuf **rx_pkts, + __rte_unused uint16_t nb_pkts) + { +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index 803e805a5b..87c7c115a1 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -691,10 +691,12 @@ int hns3_rxq_iterate(struct rte_eth_dev *dev, + int (*callback)(struct hns3_rx_queue *, void *), void *arg); + void hns3_dev_release_mbufs(struct hns3_adapter *hns); + int hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, +- unsigned int socket, const struct rte_eth_rxconf *conf, ++ unsigned int socket_id, ++ const struct rte_eth_rxconf *conf, + struct rte_mempool *mp); + int hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, +- unsigned int socket, const struct rte_eth_txconf *conf); ++ unsigned int socket_id, ++ const struct rte_eth_txconf *conf); + uint32_t hns3_rx_queue_count(void *rx_queue); + int hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); + int hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); +@@ -704,9 +706,11 @@ uint16_t hns3_recv_pkts_simple(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); + uint16_t hns3_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); +-uint16_t hns3_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, ++uint16_t hns3_recv_pkts_vec(void *__restrict rx_queue, ++ struct rte_mbuf **__restrict rx_pkts, + uint16_t nb_pkts); +-uint16_t hns3_recv_pkts_vec_sve(void *rx_queue, struct rte_mbuf **rx_pkts, ++uint16_t hns3_recv_pkts_vec_sve(void *__restrict rx_queue, ++ struct rte_mbuf **__restrict rx_pkts, + uint16_t nb_pkts); + int hns3_rx_burst_mode_get(struct rte_eth_dev *dev, + __rte_unused uint16_t queue_id, +@@ -754,7 +758,7 @@ void hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, + struct rte_eth_rxq_info *qinfo); + void hns3_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, + struct rte_eth_txq_info *qinfo); +-uint32_t hns3_get_tqp_reg_offset(uint16_t idx); ++uint32_t hns3_get_tqp_reg_offset(uint16_t queue_id); + int hns3_start_all_txqs(struct rte_eth_dev *dev); + int hns3_start_all_rxqs(struct rte_eth_dev *dev); + void hns3_stop_all_txqs(struct rte_eth_dev *dev); +diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h +index b5cd6188b4..9d84072205 100644 +--- a/drivers/net/hns3/hns3_stats.h ++++ b/drivers/net/hns3/hns3_stats.h +@@ -145,7 +145,8 @@ struct hns3_reset_stats; + #define HNS3_IMISSED_STATS_FIELD_OFFSET(f) \ + (offsetof(struct hns3_rx_missed_stats, f)) + +-int hns3_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); ++int hns3_stats_get(struct rte_eth_dev *eth_dev, ++ struct rte_eth_stats *rte_stats); + int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + unsigned int n); + int hns3_dev_xstats_reset(struct rte_eth_dev *dev); +@@ -160,7 +161,7 @@ int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + uint32_t size); +-int hns3_stats_reset(struct rte_eth_dev *dev); ++int hns3_stats_reset(struct rte_eth_dev *eth_dev); + int hns3_stats_init(struct hns3_hw *hw); + void hns3_stats_uninit(struct hns3_hw *hw); + int hns3_query_mac_stats_reg_num(struct hns3_hw *hw); +-- +2.23.0 + diff --git a/0154-net-hns3-fix-header-files-includes.patch b/0154-net-hns3-fix-header-files-includes.patch new file mode 100644 index 0000000..938a6dd --- /dev/null +++ b/0154-net-hns3-fix-header-files-includes.patch @@ -0,0 +1,285 @@ +From 0dcac22b697cc9585a91793d4b632cff11391ec3 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:30 +0800 +Subject: [PATCH 154/189] net/hns3: fix header files includes + +Header files should be self contained and should not be cyclically +dependent. + +Signed-off-by: Chengwen Feng +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.h | 3 +++ + drivers/net/hns3/hns3_common.c | 2 +- + drivers/net/hns3/hns3_dcb.h | 4 ++++ + drivers/net/hns3/hns3_ethdev.c | 2 +- + drivers/net/hns3/hns3_fdir.h | 5 +++++ + drivers/net/hns3/hns3_flow.h | 3 +++ + drivers/net/hns3/hns3_intr.c | 2 +- + drivers/net/hns3/hns3_mbx.h | 4 ++++ + drivers/net/hns3/hns3_mp.h | 2 ++ + drivers/net/hns3/hns3_regs.h | 3 +++ + drivers/net/hns3/hns3_rss.h | 2 ++ + drivers/net/hns3/hns3_rxtx.c | 2 +- + drivers/net/hns3/hns3_rxtx.h | 9 +++++++++ + drivers/net/hns3/hns3_stats.h | 5 +++++ + drivers/net/hns3/hns3_tm.h | 2 ++ + 15 files changed, 46 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index 82c999061d..bee96c1e46 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -7,6 +7,9 @@ + + #include + ++#include ++#include ++ + #define HNS3_CMDQ_TX_TIMEOUT 30000 + #define HNS3_CMDQ_CLEAR_WAIT_TIME 200 + #define HNS3_CMDQ_RX_INVLD_B 0 +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 1a1a016aa6..716cebbcec 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -7,10 +7,10 @@ + #include + #include + +-#include "hns3_common.h" + #include "hns3_logs.h" + #include "hns3_regs.h" + #include "hns3_rxtx.h" ++#include "hns3_common.h" + + int + hns3_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, +diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h +index e06ec177c8..9d9e7684c1 100644 +--- a/drivers/net/hns3/hns3_dcb.h ++++ b/drivers/net/hns3/hns3_dcb.h +@@ -7,7 +7,11 @@ + + #include + ++#include ++#include ++ + #include "hns3_cmd.h" ++#include "hns3_ethdev.h" + + #define HNS3_ETHER_MAX_RATE 100000 + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index adc47d815d..7b0e8fc77d 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -6,7 +6,6 @@ + #include + #include + +-#include "hns3_ethdev.h" + #include "hns3_common.h" + #include "hns3_dump.h" + #include "hns3_logs.h" +@@ -16,6 +15,7 @@ + #include "hns3_dcb.h" + #include "hns3_mp.h" + #include "hns3_flow.h" ++#include "hns3_ethdev.h" + + #define HNS3_SERVICE_INTERVAL 1000000 /* us */ + #define HNS3_SERVICE_QUICK_INTERVAL 10 +diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h +index 4d18759160..7be1c0a248 100644 +--- a/drivers/net/hns3/hns3_fdir.h ++++ b/drivers/net/hns3/hns3_fdir.h +@@ -5,6 +5,10 @@ + #ifndef _HNS3_FDIR_H_ + #define _HNS3_FDIR_H_ + ++#include ++ ++#include ++ + struct hns3_fd_key_cfg { + uint8_t key_sel; + uint8_t inner_sipv6_word_en; +@@ -177,6 +181,7 @@ struct hns3_fdir_info { + }; + + struct hns3_adapter; ++struct hns3_hw; + + int hns3_init_fd_config(struct hns3_adapter *hns); + int hns3_fdir_filter_init(struct hns3_adapter *hns); +diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h +index 854fbb7ff0..ec94510152 100644 +--- a/drivers/net/hns3/hns3_flow.h ++++ b/drivers/net/hns3/hns3_flow.h +@@ -6,6 +6,9 @@ + #define _HNS3_FLOW_H_ + + #include ++#include ++ ++#include "hns3_rss.h" + + struct hns3_flow_counter { + LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */ +diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c +index 4bdcd6070b..57679254ee 100644 +--- a/drivers/net/hns3/hns3_intr.c ++++ b/drivers/net/hns3/hns3_intr.c +@@ -10,9 +10,9 @@ + + #include "hns3_common.h" + #include "hns3_logs.h" +-#include "hns3_intr.h" + #include "hns3_regs.h" + #include "hns3_rxtx.h" ++#include "hns3_intr.h" + + #define SWITCH_CONTEXT_US 10 + +diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h +index d637bd2b23..b6ccd9ff8c 100644 +--- a/drivers/net/hns3/hns3_mbx.h ++++ b/drivers/net/hns3/hns3_mbx.h +@@ -5,6 +5,10 @@ + #ifndef _HNS3_MBX_H_ + #define _HNS3_MBX_H_ + ++#include ++ ++#include ++ + enum HNS3_MBX_OPCODE { + HNS3_MBX_RESET = 0x01, /* (VF -> PF) assert reset */ + HNS3_MBX_ASSERTING_RESET, /* (PF -> VF) PF is asserting reset */ +diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h +index a74221d086..230230bbfe 100644 +--- a/drivers/net/hns3/hns3_mp.h ++++ b/drivers/net/hns3/hns3_mp.h +@@ -5,6 +5,8 @@ + #ifndef _HNS3_MP_H_ + #define _HNS3_MP_H_ + ++#include ++ + /* Local data for primary or secondary process. */ + struct hns3_process_local_data { + bool init_done; /* Process action register completed flag. */ +diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h +index 5812eb39db..2636429844 100644 +--- a/drivers/net/hns3/hns3_regs.h ++++ b/drivers/net/hns3/hns3_regs.h +@@ -5,6 +5,9 @@ + #ifndef _HNS3_REGS_H_ + #define _HNS3_REGS_H_ + ++#include ++#include ++ + /* bar registers for cmdq */ + #define HNS3_CMDQ_TX_ADDR_L_REG 0x27000 + #define HNS3_CMDQ_TX_ADDR_H_REG 0x27004 +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index a12f8b7034..ebb51b4c66 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -4,6 +4,7 @@ + + #ifndef _HNS3_RSS_H_ + #define _HNS3_RSS_H_ ++ + #include + #include + +@@ -91,6 +92,7 @@ static inline uint32_t roundup_pow_of_two(uint32_t x) + extern const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE]; + + struct hns3_adapter; ++struct hns3_hw; + + int hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf); +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index f7641b1309..8ad40a49c7 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -17,10 +17,10 @@ + #endif + + #include "hns3_common.h" +-#include "hns3_rxtx.h" + #include "hns3_regs.h" + #include "hns3_logs.h" + #include "hns3_mp.h" ++#include "hns3_rxtx.h" + + #define HNS3_CFG_DESC_NUM(num) ((num) / 8 - 1) + #define HNS3_RX_RING_PREFETCTH_MASK 3 +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index 87c7c115a1..f619d6d466 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -6,7 +6,16 @@ + #define _HNS3_RXTX_H_ + + #include ++ ++#include + #include ++#include ++#include ++#include ++#include ++#include ++ ++#include "hns3_ethdev.h" + + #define HNS3_MIN_RING_DESC 64 + #define HNS3_MAX_RING_DESC 32768 +diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h +index 9d84072205..9a360f8870 100644 +--- a/drivers/net/hns3/hns3_stats.h ++++ b/drivers/net/hns3/hns3_stats.h +@@ -5,6 +5,9 @@ + #ifndef _HNS3_STATS_H_ + #define _HNS3_STATS_H_ + ++#include ++#include ++ + /* TQP stats */ + struct hns3_tqp_stats { + uint64_t rcb_tx_ring_pktnum_rcd; /* Total num of transmitted packets */ +@@ -145,6 +148,8 @@ struct hns3_reset_stats; + #define HNS3_IMISSED_STATS_FIELD_OFFSET(f) \ + (offsetof(struct hns3_rx_missed_stats, f)) + ++struct hns3_hw; ++ + int hns3_stats_get(struct rte_eth_dev *eth_dev, + struct rte_eth_stats *rte_stats); + int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, +diff --git a/drivers/net/hns3/hns3_tm.h b/drivers/net/hns3/hns3_tm.h +index 83e9cc8ba9..47345eeed1 100644 +--- a/drivers/net/hns3/hns3_tm.h ++++ b/drivers/net/hns3/hns3_tm.h +@@ -105,6 +105,8 @@ hns3_tm_calc_node_tc_no(struct hns3_tm_conf *conf, uint32_t node_id) + return 0; + } + ++struct hns3_hw; ++ + void hns3_tm_conf_init(struct rte_eth_dev *dev); + void hns3_tm_conf_uninit(struct rte_eth_dev *dev); + int hns3_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg); +-- +2.23.0 + diff --git a/0155-net-hns3-remove-unused-structures.patch b/0155-net-hns3-remove-unused-structures.patch new file mode 100644 index 0000000..17a1646 --- /dev/null +++ b/0155-net-hns3-remove-unused-structures.patch @@ -0,0 +1,67 @@ +From b099debb4a0b3d33ef2c8f5defbaba29c775657b Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:31 +0800 +Subject: [PATCH 155/189] net/hns3: remove unused structures + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.h | 19 ------------------- + drivers/net/hns3/hns3_rss.h | 4 ---- + 2 files changed, 23 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index bee96c1e46..902638ba99 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -59,11 +59,6 @@ enum hns3_cmd_return_status { + HNS3_CMD_ROH_CHECK_FAIL = 12 + }; + +-struct hns3_misc_vector { +- uint8_t *addr; +- int vector_irq; +-}; +- + struct hns3_cmq { + struct hns3_cmq_ring csq; + struct hns3_cmq_ring crq; +@@ -397,20 +392,6 @@ struct hns3_pkt_buf_alloc { + struct hns3_shared_buf s_buf; + }; + +-#define HNS3_RX_COM_WL_EN_B 15 +-struct hns3_rx_com_wl_buf_cmd { +- uint16_t high_wl; +- uint16_t low_wl; +- uint8_t rsv[20]; +-}; +- +-#define HNS3_RX_PKT_EN_B 15 +-struct hns3_rx_pkt_buf_cmd { +- uint16_t high_pkt; +- uint16_t low_pkt; +- uint8_t rsv[20]; +-}; +- + #define HNS3_PF_STATE_DONE_B 0 + #define HNS3_PF_STATE_MAIN_B 1 + #define HNS3_PF_STATE_BOND_B 2 +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index ebb51b4c66..0d24436cbe 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -34,10 +34,6 @@ + #define HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP 2 + #define HNS3_RSS_HASH_ALGO_MASK 0xf + +-struct hns3_rss_tuple_cfg { +- uint64_t rss_tuple_fields; +-}; +- + #define HNS3_RSS_QUEUES_BUFFER_NUM 64 /* Same as the Max rx/tx queue num */ + struct hns3_rss_conf { + /* RSS parameters :algorithm, flow_types, key, queue */ +-- +2.23.0 + diff --git a/0156-net-hns3-rename-header-guards.patch b/0156-net-hns3-rename-header-guards.patch new file mode 100644 index 0000000..28e0a6c --- /dev/null +++ b/0156-net-hns3-rename-header-guards.patch @@ -0,0 +1,410 @@ +From 73da6c3b6da30cc03c4a36f0d71d4ffd220f4026 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:32 +0800 +Subject: [PATCH 156/189] net/hns3: rename header guards + +Currently, the hns3 driver uses _HNS3_XXX conditional compilation +macros to prevent duplicate header files. But in the C11 standard, all +identifiers starting with an underscore plus an uppercase letter are +always reserved. So this patch fixes it. + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.h | 6 +++--- + drivers/net/hns3/hns3_common.h | 6 +++--- + drivers/net/hns3/hns3_dcb.h | 6 +++--- + drivers/net/hns3/hns3_dump.h | 6 +++--- + drivers/net/hns3/hns3_ethdev.h | 6 +++--- + drivers/net/hns3/hns3_fdir.h | 6 +++--- + drivers/net/hns3/hns3_flow.h | 6 +++--- + drivers/net/hns3/hns3_intr.h | 6 +++--- + drivers/net/hns3/hns3_logs.h | 6 +++--- + drivers/net/hns3/hns3_mbx.h | 6 +++--- + drivers/net/hns3/hns3_mp.h | 6 +++--- + drivers/net/hns3/hns3_regs.h | 6 +++--- + drivers/net/hns3/hns3_rss.h | 6 +++--- + drivers/net/hns3/hns3_rxtx.h | 6 +++--- + drivers/net/hns3/hns3_rxtx_vec.h | 6 +++--- + drivers/net/hns3/hns3_rxtx_vec_neon.h | 6 +++--- + drivers/net/hns3/hns3_stats.h | 6 +++--- + drivers/net/hns3/hns3_tm.h | 6 +++--- + 18 files changed, 54 insertions(+), 54 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index 902638ba99..8ac8b45819 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_CMD_H_ +-#define _HNS3_CMD_H_ ++#ifndef HNS3_CMD_H ++#define HNS3_CMD_H + + #include + +@@ -1038,4 +1038,4 @@ int hns3_cmd_init(struct hns3_hw *hw); + void hns3_cmd_destroy_queue(struct hns3_hw *hw); + void hns3_cmd_uninit(struct hns3_hw *hw); + +-#endif /* _HNS3_CMD_H_ */ ++#endif /* HNS3_CMD_H */ +diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h +index 2994e4a269..5aa001f0cc 100644 +--- a/drivers/net/hns3/hns3_common.h ++++ b/drivers/net/hns3/hns3_common.h +@@ -2,8 +2,8 @@ + * Copyright(C) 2021 HiSilicon Limited + */ + +-#ifndef _HNS3_COMMON_H_ +-#define _HNS3_COMMON_H_ ++#ifndef HNS3_COMMON_H ++#define HNS3_COMMON_H + + #include + +@@ -61,4 +61,4 @@ int hns3_restore_rx_interrupt(struct hns3_hw *hw); + + int hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id); + +-#endif /* _HNS3_COMMON_H_ */ ++#endif /* HNS3_COMMON_H */ +diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h +index 9d9e7684c1..d5bb5edf4d 100644 +--- a/drivers/net/hns3/hns3_dcb.h ++++ b/drivers/net/hns3/hns3_dcb.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_DCB_H_ +-#define _HNS3_DCB_H_ ++#ifndef HNS3_DCB_H ++#define HNS3_DCB_H + + #include + +@@ -215,4 +215,4 @@ int hns3_update_queue_map_configure(struct hns3_adapter *hns); + int hns3_port_shaper_update(struct hns3_hw *hw, uint32_t speed); + uint8_t hns3_txq_mapped_tc_get(struct hns3_hw *hw, uint16_t txq_no); + +-#endif /* _HNS3_DCB_H_ */ ++#endif /* HNS3_DCB_H */ +diff --git a/drivers/net/hns3/hns3_dump.h b/drivers/net/hns3/hns3_dump.h +index 8ba7ee866a..616cb70d6e 100644 +--- a/drivers/net/hns3/hns3_dump.h ++++ b/drivers/net/hns3/hns3_dump.h +@@ -2,9 +2,9 @@ + * Copyright(C) 2022 HiSilicon Limited + */ + +-#ifndef _HNS3_DUMP_H_ +-#define _HNS3_DUMP_H_ ++#ifndef HNS3_DUMP_H ++#define HNS3_DUMP_H + + int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file); + +-#endif /* _HNS3_DUMP_H_ */ ++#endif /* HNS3_DUMP_H */ +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index aad779e949..40476bf882 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_ETHDEV_H_ +-#define _HNS3_ETHDEV_H_ ++#ifndef HNS3_ETHDEV_H ++#define HNS3_ETHDEV_H + + #include + #include +@@ -1074,4 +1074,4 @@ is_reset_pending(struct hns3_adapter *hns) + return ret; + } + +-#endif /* _HNS3_ETHDEV_H_ */ ++#endif /* HNS3_ETHDEV_H */ +diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h +index 7be1c0a248..de2422e12f 100644 +--- a/drivers/net/hns3/hns3_fdir.h ++++ b/drivers/net/hns3/hns3_fdir.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_FDIR_H_ +-#define _HNS3_FDIR_H_ ++#ifndef HNS3_FDIR_H ++#define HNS3_FDIR_H + + #include + +@@ -192,4 +192,4 @@ int hns3_clear_all_fdir_filter(struct hns3_adapter *hns); + int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); + int hns3_restore_all_fdir_filter(struct hns3_adapter *hns); + +-#endif /* _HNS3_FDIR_H_ */ ++#endif /* HNS3_FDIR_H */ +diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h +index ec94510152..e4b2fdf2e6 100644 +--- a/drivers/net/hns3/hns3_flow.h ++++ b/drivers/net/hns3/hns3_flow.h +@@ -2,8 +2,8 @@ + * Copyright(C) 2021 HiSilicon Limited + */ + +-#ifndef _HNS3_FLOW_H_ +-#define _HNS3_FLOW_H_ ++#ifndef HNS3_FLOW_H ++#define HNS3_FLOW_H + + #include + #include +@@ -54,4 +54,4 @@ void hns3_flow_init(struct rte_eth_dev *dev); + void hns3_flow_uninit(struct rte_eth_dev *dev); + int hns3_restore_filter(struct hns3_adapter *hns); + +-#endif /* _HNS3_FLOW_H_ */ ++#endif /* HNS3_FLOW_H */ +diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h +index 1490a5e387..aca1c0722c 100644 +--- a/drivers/net/hns3/hns3_intr.h ++++ b/drivers/net/hns3/hns3_intr.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_INTR_H_ +-#define _HNS3_INTR_H_ ++#ifndef HNS3_INTR_H ++#define HNS3_INTR_H + + #include + +@@ -190,4 +190,4 @@ void hns3_reset_abort(struct hns3_adapter *hns); + void hns3_start_report_lse(struct rte_eth_dev *dev); + void hns3_stop_report_lse(struct rte_eth_dev *dev); + +-#endif /* _HNS3_INTR_H_ */ ++#endif /* HNS3_INTR_H */ +diff --git a/drivers/net/hns3/hns3_logs.h b/drivers/net/hns3/hns3_logs.h +index 072a53bd69..c880f752ab 100644 +--- a/drivers/net/hns3/hns3_logs.h ++++ b/drivers/net/hns3/hns3_logs.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_LOGS_H_ +-#define _HNS3_LOGS_H_ ++#ifndef HNS3_LOGS_H ++#define HNS3_LOGS_H + + extern int hns3_logtype_init; + #define PMD_INIT_LOG(level, fmt, args...) \ +@@ -31,4 +31,4 @@ extern int hns3_logtype_driver; + #define hns3_dbg(hw, fmt, args...) \ + PMD_DRV_LOG_RAW(hw, RTE_LOG_DEBUG, fmt "\n", ## args) + +-#endif /* _HNS3_LOGS_H_ */ ++#endif /* HNS3_LOGS_H */ +diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h +index b6ccd9ff8c..c71f43238c 100644 +--- a/drivers/net/hns3/hns3_mbx.h ++++ b/drivers/net/hns3/hns3_mbx.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_MBX_H_ +-#define _HNS3_MBX_H_ ++#ifndef HNS3_MBX_H ++#define HNS3_MBX_H + + #include + +@@ -172,4 +172,4 @@ void hns3_dev_handle_mbx_msg(struct hns3_hw *hw); + int hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, + const uint8_t *msg_data, uint8_t msg_len, bool need_resp, + uint8_t *resp_data, uint16_t resp_len); +-#endif /* _HNS3_MBX_H_ */ ++#endif /* HNS3_MBX_H */ +diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h +index 230230bbfe..5dc32a41d4 100644 +--- a/drivers/net/hns3/hns3_mp.h ++++ b/drivers/net/hns3/hns3_mp.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_MP_H_ +-#define _HNS3_MP_H_ ++#ifndef HNS3_MP_H ++#define HNS3_MP_H + + #include + +@@ -21,4 +21,4 @@ void hns3_mp_req_stop_tx(struct rte_eth_dev *dev); + int hns3_mp_init(struct rte_eth_dev *dev); + void hns3_mp_uninit(struct rte_eth_dev *dev); + +-#endif /* _HNS3_MP_H_ */ ++#endif /* HNS3_MP_H */ +diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h +index 2636429844..459bbaf773 100644 +--- a/drivers/net/hns3/hns3_regs.h ++++ b/drivers/net/hns3/hns3_regs.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_REGS_H_ +-#define _HNS3_REGS_H_ ++#ifndef HNS3_REGS_H ++#define HNS3_REGS_H + + #include + #include +@@ -153,4 +153,4 @@ + #define HNS3_RL_USEC_TO_REG(rl_usec) ((rl_usec) >> 2) + + int hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs); +-#endif /* _HNS3_REGS_H_ */ ++#endif /* HNS3_REGS_H */ +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 0d24436cbe..5c288c8bb2 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_RSS_H_ +-#define _HNS3_RSS_H_ ++#ifndef HNS3_RSS_H ++#define HNS3_RSS_H + + #include + #include +@@ -109,4 +109,4 @@ void hns3_rss_uninit(struct hns3_adapter *hns); + int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); + int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key); + +-#endif /* _HNS3_RSS_H_ */ ++#endif /* HNS3_RSS_H */ +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index f619d6d466..ed40621b3a 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_RXTX_H_ +-#define _HNS3_RXTX_H_ ++#ifndef HNS3_RXTX_H ++#define HNS3_RXTX_H + + #include + +@@ -780,4 +780,4 @@ void hns3_tx_push_init(struct rte_eth_dev *dev); + void hns3_stop_tx_datapath(struct rte_eth_dev *dev); + void hns3_start_tx_datapath(struct rte_eth_dev *dev); + +-#endif /* _HNS3_RXTX_H_ */ ++#endif /* HNS3_RXTX_H */ +diff --git a/drivers/net/hns3/hns3_rxtx_vec.h b/drivers/net/hns3/hns3_rxtx_vec.h +index d13f18627d..2c8a91921e 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec.h ++++ b/drivers/net/hns3/hns3_rxtx_vec.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2020-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_RXTX_VEC_H_ +-#define _HNS3_RXTX_VEC_H_ ++#ifndef HNS3_RXTX_VEC_H ++#define HNS3_RXTX_VEC_H + + #include "hns3_rxtx.h" + #include "hns3_ethdev.h" +@@ -94,4 +94,4 @@ hns3_rx_reassemble_pkts(struct rte_mbuf **rx_pkts, + + return count; + } +-#endif /* _HNS3_RXTX_VEC_H_ */ ++#endif /* HNS3_RXTX_VEC_H */ +diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h +index 0edd4756f1..55d9bf817d 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec_neon.h ++++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2020-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_RXTX_VEC_NEON_H_ +-#define _HNS3_RXTX_VEC_NEON_H_ ++#ifndef HNS3_RXTX_VEC_NEON_H ++#define HNS3_RXTX_VEC_NEON_H + + #include + +@@ -299,4 +299,4 @@ hns3_recv_burst_vec(struct hns3_rx_queue *__restrict rxq, + + return nb_rx; + } +-#endif /* _HNS3_RXTX_VEC_NEON_H_ */ ++#endif /* HNS3_RXTX_VEC_NEON_H */ +diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h +index 9a360f8870..74bc4173cc 100644 +--- a/drivers/net/hns3/hns3_stats.h ++++ b/drivers/net/hns3/hns3_stats.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2018-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_STATS_H_ +-#define _HNS3_STATS_H_ ++#ifndef HNS3_STATS_H ++#define HNS3_STATS_H + + #include + #include +@@ -172,4 +172,4 @@ void hns3_stats_uninit(struct hns3_hw *hw); + int hns3_query_mac_stats_reg_num(struct hns3_hw *hw); + void hns3_update_hw_stats(struct hns3_hw *hw); + +-#endif /* _HNS3_STATS_H_ */ ++#endif /* HNS3_STATS_H */ +diff --git a/drivers/net/hns3/hns3_tm.h b/drivers/net/hns3/hns3_tm.h +index 47345eeed1..0cac1a5bb2 100644 +--- a/drivers/net/hns3/hns3_tm.h ++++ b/drivers/net/hns3/hns3_tm.h +@@ -2,8 +2,8 @@ + * Copyright(c) 2020-2021 HiSilicon Limited. + */ + +-#ifndef _HNS3_TM_H_ +-#define _HNS3_TM_H_ ++#ifndef HNS3_TM_H ++#define HNS3_TM_H + + #include + #include +@@ -114,4 +114,4 @@ void hns3_tm_dev_start_proc(struct hns3_hw *hw); + void hns3_tm_dev_stop_proc(struct hns3_hw *hw); + int hns3_tm_conf_update(struct hns3_hw *hw); + +-#endif /* _HNS3_TM_H */ ++#endif /* HNS3_TM_H */ +-- +2.23.0 + diff --git a/0157-net-hns3-fix-IPv4-and-IPv6-RSS.patch b/0157-net-hns3-fix-IPv4-and-IPv6-RSS.patch new file mode 100644 index 0000000..ed89f25 --- /dev/null +++ b/0157-net-hns3-fix-IPv4-and-IPv6-RSS.patch @@ -0,0 +1,87 @@ +From e11bff8abbbe9cacc59fa64d3d2046b150c45a6d Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:33 +0800 +Subject: [PATCH 157/189] net/hns3: fix IPv4 and IPv6 RSS + +Currently, hns3 driver use 'ipv4-other' and 'ipv6-other' as the flag +of IP packets to judge if enable RSS tuple field. But user may use +'RTE_ETH_RSS_IPV4' or 'RTE_ETH_RSS_IPV6' as the flag. So this patch +adds the processing of these macros. + +Fixes: 806f1d5ab0e3 ("net/hns3: set RSS hash type input configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.c | 14 ++++++++++++++ + drivers/net/hns3/hns3_rss.h | 2 ++ + 2 files changed, 16 insertions(+) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index fc912ed2e8..e7e114727f 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -102,6 +102,10 @@ static const struct { + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L4_DST_ONLY, + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) }, ++ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, ++ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_DST_ONLY, +@@ -134,6 +138,10 @@ static const struct { + BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_DST_ONLY, + BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D) }, ++ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, ++ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_DST_ONLY, +@@ -159,6 +167,9 @@ static const struct { + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER) }, ++ { RTE_ETH_RSS_IPV4, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV4_OTHER, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, +@@ -177,6 +188,9 @@ static const struct { + BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D) | + BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) }, ++ { RTE_ETH_RSS_IPV6, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV6_OTHER, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) } +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 5c288c8bb2..9471e7039d 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -9,11 +9,13 @@ + #include + + #define HNS3_ETH_RSS_SUPPORT ( \ ++ RTE_ETH_RSS_IPV4 | \ + RTE_ETH_RSS_FRAG_IPV4 | \ + RTE_ETH_RSS_NONFRAG_IPV4_TCP | \ + RTE_ETH_RSS_NONFRAG_IPV4_UDP | \ + RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \ + RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \ ++ RTE_ETH_RSS_IPV6 | \ + RTE_ETH_RSS_FRAG_IPV6 | \ + RTE_ETH_RSS_NONFRAG_IPV6_TCP | \ + RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ +-- +2.23.0 + diff --git a/0158-net-hns3-fix-types-in-IPv6-SCTP-fields.patch b/0158-net-hns3-fix-types-in-IPv6-SCTP-fields.patch new file mode 100644 index 0000000..7229a33 --- /dev/null +++ b/0158-net-hns3-fix-types-in-IPv6-SCTP-fields.patch @@ -0,0 +1,57 @@ +From 3907f30765bd5ca0d973c0b828de210b3d87713a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:34 +0800 +Subject: [PATCH 158/189] net/hns3: fix types in IPv6 SCTP fields + +Fix spelling errors about IPV6-SCTP macro. + +Fixes: 1bc633c34008 ("net/hns3: enable RSS for IPv6-SCTP dst/src port fields") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index e7e114727f..6d71ee94a9 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -57,8 +57,8 @@ enum hns3_tuple_field { + HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S, + + /* IPV6_SCTP ENABLE FIELD */ +- HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D = 48, +- HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S, ++ HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D = 48, ++ HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S, + HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D, + HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S, + HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER, +@@ -135,9 +135,9 @@ static const struct { + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L3_DST_ONLY, + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_SRC_ONLY, +- BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_DST_ONLY, +- BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) }, + { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, + { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY, +@@ -185,8 +185,8 @@ static const struct { + BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP, BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) | +- BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D) | +- BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) }, + { RTE_ETH_RSS_IPV6, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | +-- +2.23.0 + diff --git a/0159-net-hns3-fix-IPv4-RSS.patch b/0159-net-hns3-fix-IPv4-RSS.patch new file mode 100644 index 0000000..4654d2d --- /dev/null +++ b/0159-net-hns3-fix-IPv4-RSS.patch @@ -0,0 +1,380 @@ +From c300374b7ef19f05acaa6501093610fbe25bc187 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:35 +0800 +Subject: [PATCH 159/189] net/hns3: fix IPv4 RSS + +When user only use 'ipv4' to set 'rss_hf', hns3 will enable +all tuple fields for 'ipv4' flow. But if user use 'ipv4-tcp' +, 'ipv4' and 'l4-src-only' to set 'rss_hf', driver does not +enable all tuple fields for 'ipv4' flow. + +Fixes: 806f1d5ab0e3 ("net/hns3: set RSS hash type input configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.c | 266 ++++++++++++++++++++++++------------ + 1 file changed, 176 insertions(+), 90 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 6d71ee94a9..ea745c791f 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -70,130 +70,209 @@ enum hns3_tuple_field { + HNS3_RSS_FIELD_IPV6_FRAG_IP_S + }; + ++enum hns3_rss_tuple_type { ++ HNS3_RSS_IP_TUPLE, ++ HNS3_RSS_IP_L4_TUPLE, ++}; ++ + static const struct { + uint64_t rss_types; ++ uint16_t tuple_type; + uint64_t rss_field; + } hns3_set_tuple_table[] = { ++ /* IPV4-FRAG */ + { RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) }, + { RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) }, ++ { RTE_ETH_RSS_FRAG_IPV4, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) }, ++ ++ /* IPV4 */ ++ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, ++ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ { RTE_ETH_RSS_IPV4, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ ++ /* IPV4-OTHER */ ++ { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, ++ { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ { RTE_ETH_RSS_NONFRAG_IPV4_OTHER, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ ++ /* IPV4-TCP */ + { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L4_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L4_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) }, ++ { RTE_ETH_RSS_NONFRAG_IPV4_TCP, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) }, ++ ++ /* IPV4-UDP */ + { RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L4_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L4_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D) }, ++ { RTE_ETH_RSS_NONFRAG_IPV4_UDP, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D) }, ++ ++ /* IPV4-SCTP */ + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L4_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L4_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) }, +- { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, +- { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, +- { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_DST_ONLY, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ { RTE_ETH_RSS_NONFRAG_IPV4_SCTP, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER) }, ++ ++ /* IPV6-FRAG */ + { RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) }, + { RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) }, ++ { RTE_ETH_RSS_FRAG_IPV6, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) }, ++ ++ /* IPV6 */ ++ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, ++ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, ++ { RTE_ETH_RSS_IPV6, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, ++ ++ /* IPV6-OTHER */ ++ { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, ++ { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, ++ { RTE_ETH_RSS_NONFRAG_IPV6_OTHER, ++ HNS3_RSS_IP_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, ++ ++ /* IPV6-TCP */ + { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L4_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L4_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) }, ++ { RTE_ETH_RSS_NONFRAG_IPV6_TCP, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) }, ++ ++ /* IPV6-UDP */ + { RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L4_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L4_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) }, ++ { RTE_ETH_RSS_NONFRAG_IPV6_UDP, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) }, ++ ++ /* IPV6-SCTP */ + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L3_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L3_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_SRC_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_DST_ONLY, ++ HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) }, +- { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, +- { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, +- { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_DST_ONLY, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, +-}; +- +-static const struct { +- uint64_t rss_types; +- uint64_t rss_field; +-} hns3_set_rss_types[] = { +- { RTE_ETH_RSS_FRAG_IPV4, BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) }, +- { RTE_ETH_RSS_NONFRAG_IPV4_TCP, BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV4_UDP, BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV4_SCTP, BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER) }, +- { RTE_ETH_RSS_IPV4, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV4_OTHER, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, +- { RTE_ETH_RSS_FRAG_IPV6, BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV6_TCP, BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV6_UDP, BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV6_SCTP, BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) | ++ { RTE_ETH_RSS_NONFRAG_IPV6_SCTP, ++ HNS3_RSS_IP_L4_TUPLE, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) }, +- { RTE_ETH_RSS_IPV6, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, +- { RTE_ETH_RSS_NONFRAG_IPV6_OTHER, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) } + }; + + /* +@@ -321,46 +400,53 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw) + return ret; + } + ++static uint64_t ++hns3_rss_calc_tuple_filed(uint64_t rss_hf) ++{ ++ uint64_t l3_only_mask = RTE_ETH_RSS_L3_SRC_ONLY | ++ RTE_ETH_RSS_L3_DST_ONLY; ++ uint64_t l4_only_mask = RTE_ETH_RSS_L4_SRC_ONLY | ++ RTE_ETH_RSS_L4_DST_ONLY; ++ uint64_t l3_l4_only_mask = l3_only_mask | l4_only_mask; ++ bool has_l3_l4_only = !!(rss_hf & l3_l4_only_mask); ++ bool has_l3_only = !!(rss_hf & l3_only_mask); ++ uint64_t tuple = 0; ++ uint32_t i; ++ ++ for (i = 0; i < RTE_DIM(hns3_set_tuple_table); i++) { ++ if ((rss_hf & hns3_set_tuple_table[i].rss_types) != ++ hns3_set_tuple_table[i].rss_types) ++ continue; ++ ++ if (hns3_set_tuple_table[i].tuple_type == HNS3_RSS_IP_TUPLE) { ++ if (hns3_set_tuple_table[i].rss_types & l3_only_mask || ++ !has_l3_only) ++ tuple |= hns3_set_tuple_table[i].rss_field; ++ continue; ++ } ++ ++ /* For IP types with L4, we need check both L3 and L4 */ ++ if (hns3_set_tuple_table[i].rss_types & l3_l4_only_mask || ++ !has_l3_l4_only) ++ tuple |= hns3_set_tuple_table[i].rss_field; ++ } ++ ++ return tuple; ++} ++ + int + hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf) + { + struct hns3_rss_input_tuple_cmd *req; + struct hns3_cmd_desc desc; +- uint32_t fields_count = 0; /* count times for setting tuple fields */ +- uint32_t i; ++ uint64_t tuple_field; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false); +- + req = (struct hns3_rss_input_tuple_cmd *)desc.data; + +- for (i = 0; i < RTE_DIM(hns3_set_tuple_table); i++) { +- if ((rss_hf & hns3_set_tuple_table[i].rss_types) == +- hns3_set_tuple_table[i].rss_types) { +- req->tuple_field |= +- rte_cpu_to_le_64(hns3_set_tuple_table[i].rss_field); +- fields_count++; +- } +- } +- +- /* +- * When user does not specify the following types or a combination of +- * the following types, it enables all fields for the supported RSS +- * types. the following types as: +- * - RTE_ETH_RSS_L3_SRC_ONLY +- * - RTE_ETH_RSS_L3_DST_ONLY +- * - RTE_ETH_RSS_L4_SRC_ONLY +- * - RTE_ETH_RSS_L4_DST_ONLY +- */ +- if (fields_count == 0) { +- for (i = 0; i < RTE_DIM(hns3_set_rss_types); i++) { +- if ((rss_hf & hns3_set_rss_types[i].rss_types) == +- hns3_set_rss_types[i].rss_types) +- req->tuple_field |= rte_cpu_to_le_64( +- hns3_set_rss_types[i].rss_field); +- } +- } +- ++ tuple_field = hns3_rss_calc_tuple_filed(rss_hf); ++ req->tuple_field = rte_cpu_to_le_64(tuple_field); + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) { + hns3_err(hw, "Update RSS flow types tuples failed %d", ret); +-- +2.23.0 + diff --git a/0160-net-hns3-add-check-for-L3-and-L4-type.patch b/0160-net-hns3-add-check-for-L3-and-L4-type.patch new file mode 100644 index 0000000..0c54982 --- /dev/null +++ b/0160-net-hns3-add-check-for-L3-and-L4-type.patch @@ -0,0 +1,77 @@ +From 3406502c1af41be568561d74b39417dd2a3a771a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:36 +0800 +Subject: [PATCH 160/189] net/hns3: add check for L3 and L4 type + +When user set 'L3_SRC/DST_ONLY' or 'L4_SRC/DST_ONLY' to 'rss_hf' and +do not specify the packet type, these types will be not set to hardware. +So this patch adds a check for them. + +Fixes: 806f1d5ab0e3 ("net/hns3: set RSS hash type input configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +--- + drivers/net/hns3/hns3_rss.c | 31 +++++++++++++++++++++++++++++-- + 1 file changed, 29 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index ea745c791f..ca5a129234 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -400,8 +400,34 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw) + return ret; + } + ++static void ++hns3_rss_check_l3l4_types(struct hns3_hw *hw, uint64_t rss_hf) ++{ ++ uint64_t ip_mask = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | ++ RTE_ETH_RSS_NONFRAG_IPV4_OTHER | ++ RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | ++ RTE_ETH_RSS_NONFRAG_IPV6_OTHER; ++ uint64_t l4_mask = RTE_ETH_RSS_NONFRAG_IPV4_TCP | ++ RTE_ETH_RSS_NONFRAG_IPV4_UDP | ++ RTE_ETH_RSS_NONFRAG_IPV4_SCTP | ++ RTE_ETH_RSS_NONFRAG_IPV6_TCP | ++ RTE_ETH_RSS_NONFRAG_IPV6_UDP | ++ RTE_ETH_RSS_NONFRAG_IPV6_SCTP; ++ uint64_t l3_src_dst_mask = RTE_ETH_RSS_L3_SRC_ONLY | ++ RTE_ETH_RSS_L3_DST_ONLY; ++ uint64_t l4_src_dst_mask = RTE_ETH_RSS_L4_SRC_ONLY | ++ RTE_ETH_RSS_L4_DST_ONLY; ++ ++ if (rss_hf & l3_src_dst_mask && ++ !(rss_hf & ip_mask || rss_hf & l4_mask)) ++ hns3_warn(hw, "packet type isn't specified, L3_SRC/DST_ONLY is ignored."); ++ ++ if (rss_hf & l4_src_dst_mask && !(rss_hf & l4_mask)) ++ hns3_warn(hw, "packet type isn't specified, L4_SRC/DST_ONLY is ignored."); ++} ++ + static uint64_t +-hns3_rss_calc_tuple_filed(uint64_t rss_hf) ++hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf) + { + uint64_t l3_only_mask = RTE_ETH_RSS_L3_SRC_ONLY | + RTE_ETH_RSS_L3_DST_ONLY; +@@ -430,6 +456,7 @@ hns3_rss_calc_tuple_filed(uint64_t rss_hf) + !has_l3_l4_only) + tuple |= hns3_set_tuple_table[i].rss_field; + } ++ hns3_rss_check_l3l4_types(hw, rss_hf); + + return tuple; + } +@@ -445,7 +472,7 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf) + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false); + req = (struct hns3_rss_input_tuple_cmd *)desc.data; + +- tuple_field = hns3_rss_calc_tuple_filed(rss_hf); ++ tuple_field = hns3_rss_calc_tuple_filed(hw, rss_hf); + req->tuple_field = rte_cpu_to_le_64(tuple_field); + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) { +-- +2.23.0 + diff --git a/0161-net-hns3-revert-fix-mailbox-communication-with-HW.patch b/0161-net-hns3-revert-fix-mailbox-communication-with-HW.patch new file mode 100644 index 0000000..a33b40c --- /dev/null +++ b/0161-net-hns3-revert-fix-mailbox-communication-with-HW.patch @@ -0,0 +1,58 @@ +From e438ad9ab2897ec33b94ee5f31bd1b2fbfc4e36e Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:37 +0800 +Subject: [PATCH 161/189] net/hns3: revert fix mailbox communication with HW + +VF's command receive queue was mainly used to receive mailbox messages +from PF. There are two type mailbox messages: request response message +and message pushed by PF. + +There are two types of threads that can handle these messages: +1) the interrupt thread of the main process: it could handle both types +of messages. +2) other threads: it could only handle request response messages. + +The collaboration mechanism between the two type threads is that other +threads set the opcode of processed messages to zero so that the +interrupt thread of the main process does not process these messages +again. Because other threads can only process part of the messages, +after the processing is complete, the next-to-use pointer of the +command receive queue should not be updated. Otherwise, some messages +(e.g. messages pushed by PF) maybe discarded. + +Unfortunately, the patch to be reverted updates next-to-use pointer of +the command receive queue in other threads context, and this will lead +to discard some mailbox message. + +So this commit reverts +commit 599ef84add7e ("net/hns3: fix mailbox communication with HW") + +Fixes: 599ef84add7e ("net/hns3: fix mailbox communication with HW") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_mbx.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c +index b3563d4694..2de55a6417 100644 +--- a/drivers/net/hns3/hns3_mbx.c ++++ b/drivers/net/hns3/hns3_mbx.c +@@ -436,8 +436,10 @@ hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw) + next_to_use = (next_to_use + 1) % hw->cmq.crq.desc_num; + } + +- crq->next_to_use = next_to_use; +- hns3_write_dev(hw, HNS3_CMDQ_RX_HEAD_REG, crq->next_to_use); ++ /* ++ * Note: the crq->next_to_use field should not updated, otherwise, ++ * mailbox messages may be discarded. ++ */ + } + + void +-- +2.23.0 + diff --git a/0162-net-hns3-fix-VF-mailbox-message-handling.patch b/0162-net-hns3-fix-VF-mailbox-message-handling.patch new file mode 100644 index 0000000..b018883 --- /dev/null +++ b/0162-net-hns3-fix-VF-mailbox-message-handling.patch @@ -0,0 +1,48 @@ +From 33814ad89cd618df8c596f7b138150cd4b71a8c3 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:38 +0800 +Subject: [PATCH 162/189] net/hns3: fix VF mailbox message handling + +VF's command receive queue was mainly used to receive mailbox messages +from PF. There are two type mailbox messages: request response message +and message pushed by PF. + +There are two types of threads that can handle these messages: +1) the interrupt thread of the main process: it could handle both types +of messages. +2) other threads: it could only handle request response messages. + +The collaboration mechanism between the two type threads is that other +threads set the opcode of processed messages to zero so that the +interrupt thread of the main process does not process these messages +again. + +Unfortunately, the other threads mark the message pointed to by the +crq->next-to-use variable which is fixed in the loop, not the message +pointed to by the next-to-use variable. + +Fixes: dbbbad23e380 ("net/hns3: fix VF handling LSC event in secondary process") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_mbx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c +index 2de55a6417..9a05f0d1ee 100644 +--- a/drivers/net/hns3/hns3_mbx.c ++++ b/drivers/net/hns3/hns3_mbx.c +@@ -429,7 +429,7 @@ hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw) + * Clear opcode to inform intr thread don't process + * again. + */ +- crq->desc[crq->next_to_use].opcode = 0; ++ crq->desc[next_to_use].opcode = 0; + } + + scan_next: +-- +2.23.0 + diff --git a/0163-net-hns3-fix-minimum-Tx-frame-length.patch b/0163-net-hns3-fix-minimum-Tx-frame-length.patch new file mode 100644 index 0000000..af4c901 --- /dev/null +++ b/0163-net-hns3-fix-minimum-Tx-frame-length.patch @@ -0,0 +1,123 @@ +From ac646ee28e8c9780d02ec685b7581486c13f6961 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Fri, 21 Oct 2022 15:36:39 +0800 +Subject: [PATCH 163/189] net/hns3: fix minimum Tx frame length + +When packet length in Tx is less than length hardware supported, +the minimum frame length in hns3 is used to do padding to avoid +hardware error. Currently, this length is fixed by macro, which +is very unfavorable for subsequent hardware evolution. So fix it +as firmware report. + +Fixes: 395b5e08ef8d ("net/hns3: add Tx short frame padding compatibility") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.h | 6 ++++++ + drivers/net/hns3/hns3_ethdev.c | 4 +++- + drivers/net/hns3/hns3_ethdev.h | 3 +-- + drivers/net/hns3/hns3_ethdev_vf.c | 4 +++- + 4 files changed, 13 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index 8ac8b45819..994dfc48cc 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -967,6 +967,12 @@ struct hns3_dev_specs_0_cmd { + uint32_t max_tm_rate; + }; + ++struct hns3_dev_specs_1_cmd { ++ uint8_t rsv0[12]; ++ uint8_t min_tx_pkt_len; ++ uint8_t rsv1[11]; ++}; ++ + struct hns3_query_rpu_cmd { + uint32_t tc_queue_num; + uint32_t rsv1[2]; +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 7b0e8fc77d..7330515535 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2661,14 +2661,17 @@ static void + hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) + { + struct hns3_dev_specs_0_cmd *req0; ++ struct hns3_dev_specs_1_cmd *req1; + + req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; ++ req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; + + hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; + hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); + hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); + hw->max_tm_rate = rte_le_to_cpu_32(req0->max_tm_rate); + hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); ++ hw->min_tx_pkt_len = req1->min_tx_pkt_len; + } + + static int +@@ -2763,7 +2766,6 @@ hns3_get_capability(struct hns3_hw *hw) + hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM; + hw->vlan_mode = HNS3_HW_SHIFT_AND_DISCARD_MODE; + hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE2; +- hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN; + pf->tqp_config_mode = HNS3_FLEX_MAX_TQP_NUM_MODE; + hw->rss_info.ipv6_sctp_offload_supported = true; + hw->udp_cksum_mode = HNS3_SPECIAL_PORT_HW_CKSUM_MODE; +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 40476bf882..4406611fe9 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -75,7 +75,6 @@ + #define HNS3_DEFAULT_MTU 1500UL + #define HNS3_DEFAULT_FRAME_LEN (HNS3_DEFAULT_MTU + HNS3_ETH_OVERHEAD) + #define HNS3_HIP08_MIN_TX_PKT_LEN 33 +-#define HNS3_HIP09_MIN_TX_PKT_LEN 9 + + #define HNS3_BITS_PER_BYTE 8 + +@@ -550,7 +549,7 @@ struct hns3_hw { + * The minimum length of the packet supported by hardware in the Tx + * direction. + */ +- uint32_t min_tx_pkt_len; ++ uint8_t min_tx_pkt_len; + + struct hns3_queue_intr intr; + /* +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 72d60191ab..6976a9f23d 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -701,13 +701,16 @@ static void + hns3vf_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) + { + struct hns3_dev_specs_0_cmd *req0; ++ struct hns3_dev_specs_1_cmd *req1; + + req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; ++ req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; + + hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; + hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); + hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); + hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); ++ hw->min_tx_pkt_len = req1->min_tx_pkt_len; + } + + static int +@@ -846,7 +849,6 @@ hns3vf_get_capability(struct hns3_hw *hw) + hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_1US; + hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM; + hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE2; +- hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN; + hw->rss_info.ipv6_sctp_offload_supported = true; + hw->promisc_mode = HNS3_LIMIT_PROMISC_MODE; + +-- +2.23.0 + diff --git a/0164-ethdev-introduce-Rx-Tx-descriptor-dump-API.patch b/0164-ethdev-introduce-Rx-Tx-descriptor-dump-API.patch new file mode 100644 index 0000000..82be665 --- /dev/null +++ b/0164-ethdev-introduce-Rx-Tx-descriptor-dump-API.patch @@ -0,0 +1,238 @@ +From e4f2f2e047f123e5aff0a9a5699bf2d4ece4ebb8 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 21 Oct 2022 15:36:40 +0800 +Subject: [PATCH 164/189] ethdev: introduce Rx/Tx descriptor dump API + +Added the ethdev Rx/Tx desc dump API which provides functions for query +descriptor from device. HW descriptor info differs in different NICs. +The information demonstrates I/O process which is important for debug. +As the information is different between NICs, the new API is introduced. + +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Reviewed-by: Ferruh Yigit +--- + lib/ethdev/ethdev_driver.h | 53 ++++++++++++++++++++++++++++++++++++ + lib/ethdev/rte_ethdev.c | 52 +++++++++++++++++++++++++++++++++++ + lib/ethdev/rte_ethdev.h | 55 ++++++++++++++++++++++++++++++++++++++ + lib/ethdev/version.map | 4 +++ + 4 files changed, 164 insertions(+) + +diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h +index e24ff7064c..41f67f2740 100644 +--- a/lib/ethdev/ethdev_driver.h ++++ b/lib/ethdev/ethdev_driver.h +@@ -1010,6 +1010,54 @@ typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev, + */ + typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file); + ++/** ++ * @internal ++ * Dump Rx descriptor info to a file. ++ * ++ * It is used for debugging, not a dataplane API. ++ * ++ * @param dev ++ * Port (ethdev) handle. ++ * @param queue_id ++ * A Rx queue identifier on this port. ++ * @param offset ++ * The offset of the descriptor starting from tail. (0 is the next ++ * packet to be received by the driver). ++ * @param num ++ * The number of the descriptors to dump. ++ * @param file ++ * A pointer to a file for output. ++ * @return ++ * Negative errno value on error, zero on success. ++ */ ++typedef int (*eth_rx_descriptor_dump_t)(const struct rte_eth_dev *dev, ++ uint16_t queue_id, uint16_t offset, ++ uint16_t num, FILE *file); ++ ++/** ++ * @internal ++ * Dump Tx descriptor info to a file. ++ * ++ * This API is used for debugging, not a dataplane API. ++ * ++ * @param dev ++ * Port (ethdev) handle. ++ * @param queue_id ++ * A Tx queue identifier on this port. ++ * @param offset ++ * The offset of the descriptor starting from tail. (0 is the place where ++ * the next packet will be send). ++ * @param num ++ * The number of the descriptors to dump. ++ * @param file ++ * A pointer to a file for output. ++ * @return ++ * Negative errno value on error, zero on success. ++ */ ++typedef int (*eth_tx_descriptor_dump_t)(const struct rte_eth_dev *dev, ++ uint16_t queue_id, uint16_t offset, ++ uint16_t num, FILE *file); ++ + /** + * @internal A structure containing the functions exported by an Ethernet driver. + */ +@@ -1209,6 +1257,11 @@ struct eth_dev_ops { + + /** Dump private info from device */ + eth_dev_priv_dump_t eth_dev_priv_dump; ++ ++ /** Dump Rx descriptor info */ ++ eth_rx_descriptor_dump_t eth_rx_descriptor_dump; ++ /** Dump Tx descriptor info */ ++ eth_tx_descriptor_dump_t eth_tx_descriptor_dump; + }; + + /** +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 25c9f0c123..b95f501b51 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6509,6 +6509,58 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) + return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); + } + ++int ++rte_eth_rx_descriptor_dump(uint16_t port_id, uint16_t queue_id, ++ uint16_t offset, uint16_t num, FILE *file) ++{ ++ struct rte_eth_dev *dev; ++ ++ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); ++ dev = &rte_eth_devices[port_id]; ++ ++ if (queue_id >= dev->data->nb_rx_queues) { ++ RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id); ++ return -EINVAL; ++ } ++ ++ if (file == NULL) { ++ RTE_ETHDEV_LOG(ERR, "Invalid file (NULL)\n"); ++ return -EINVAL; ++ } ++ ++ if (*dev->dev_ops->eth_rx_descriptor_dump == NULL) ++ return -ENOTSUP; ++ ++ return eth_err(port_id, (*dev->dev_ops->eth_rx_descriptor_dump)(dev, ++ queue_id, offset, num, file)); ++} ++ ++int ++rte_eth_tx_descriptor_dump(uint16_t port_id, uint16_t queue_id, ++ uint16_t offset, uint16_t num, FILE *file) ++{ ++ struct rte_eth_dev *dev; ++ ++ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); ++ dev = &rte_eth_devices[port_id]; ++ ++ if (queue_id >= dev->data->nb_tx_queues) { ++ RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", queue_id); ++ return -EINVAL; ++ } ++ ++ if (file == NULL) { ++ RTE_ETHDEV_LOG(ERR, "Invalid file (NULL)\n"); ++ return -EINVAL; ++ } ++ ++ if (*dev->dev_ops->eth_tx_descriptor_dump == NULL) ++ return -ENOTSUP; ++ ++ return eth_err(port_id, (*dev->dev_ops->eth_tx_descriptor_dump)(dev, ++ queue_id, offset, num, file)); ++} ++ + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); + + RTE_INIT(ethdev_init_telemetry) +diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h +index 082166ed42..8c894e090d 100644 +--- a/lib/ethdev/rte_ethdev.h ++++ b/lib/ethdev/rte_ethdev.h +@@ -5213,6 +5213,61 @@ int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features); + __rte_experimental + int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file); + ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice ++ * ++ * Dump ethdev Rx descriptor info to a file. ++ * ++ * This API is used for debugging, not a dataplane API. ++ * ++ * @param port_id ++ * The port identifier of the Ethernet device. ++ * @param queue_id ++ * A Rx queue identifier on this port. ++ * @param offset ++ * The offset of the descriptor starting from tail. (0 is the next ++ * packet to be received by the driver). ++ * @param num ++ * The number of the descriptors to dump. ++ * @param file ++ * A pointer to a file for output. ++ * @return ++ * - On success, zero. ++ * - On failure, a negative value. ++ */ ++__rte_experimental ++int rte_eth_rx_descriptor_dump(uint16_t port_id, uint16_t queue_id, ++ uint16_t offset, uint16_t num, FILE *file); ++ ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice ++ * ++ * Dump ethdev Tx descriptor info to a file. ++ * ++ * This API is used for debugging, not a dataplane API. ++ * ++ * @param port_id ++ * The port identifier of the Ethernet device. ++ * @param queue_id ++ * A Tx queue identifier on this port. ++ * @param offset ++ * The offset of the descriptor starting from tail. (0 is the place where ++ * the next packet will be send). ++ * @param num ++ * The number of the descriptors to dump. ++ * @param file ++ * A pointer to a file for output. ++ * @return ++ * - On success, zero. ++ * - On failure, a negative value. ++ */ ++__rte_experimental ++int rte_eth_tx_descriptor_dump(uint16_t port_id, uint16_t queue_id, ++ uint16_t offset, uint16_t num, FILE *file); ++ ++ + #include + + /** +diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map +index f29c60eda4..09dba86bee 100644 +--- a/lib/ethdev/version.map ++++ b/lib/ethdev/version.map +@@ -259,6 +259,10 @@ EXPERIMENTAL { + + # added in 22.03 + rte_eth_dev_priv_dump; ++ ++ # added in 22.11 ++ rte_eth_rx_descriptor_dump; ++ rte_eth_tx_descriptor_dump; + }; + + INTERNAL { +-- +2.23.0 + diff --git a/0165-net-hns3-support-Rx-Tx-descriptor-dump.patch b/0165-net-hns3-support-Rx-Tx-descriptor-dump.patch new file mode 100644 index 0000000..a2fbe3b --- /dev/null +++ b/0165-net-hns3-support-Rx-Tx-descriptor-dump.patch @@ -0,0 +1,164 @@ +From 450591abedaabee32a21d53a50cb5b65440ce971 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Fri, 21 Oct 2022 15:36:41 +0800 +Subject: [PATCH 165/189] net/hns3: support Rx/Tx descriptor dump + +This patch support query HW descriptor from hns3 device. HW descriptor +is also called BD (buffer description) which is shared memory between +software and hardware. + +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Ferruh Yigit +--- + drivers/net/hns3/hns3_dump.c | 88 +++++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_dump.h | 4 ++ + drivers/net/hns3/hns3_ethdev.c | 2 + + drivers/net/hns3/hns3_ethdev_vf.c | 2 + + 4 files changed, 96 insertions(+) + +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index cf5b500be1..1007b09bd2 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -11,6 +11,9 @@ + #include "hns3_logs.h" + #include "hns3_dump.h" + ++#define HNS3_BD_DW_NUM 8 ++#define HNS3_BD_ADDRESS_LAST_DW 2 ++ + static const char * + hns3_get_adapter_state_name(enum hns3_adapter_state state) + { +@@ -873,3 +876,88 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) + + return 0; + } ++ ++int ++hns3_rx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id, ++ uint16_t offset, uint16_t num, FILE *file) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id]; ++ uint32_t *bd_data; ++ uint16_t count = 0; ++ uint16_t desc_id; ++ int i; ++ ++ if (offset >= rxq->nb_rx_desc) ++ return -EINVAL; ++ ++ if (num > rxq->nb_rx_desc) { ++ hns3_err(hw, "Invalid BD num=%u\n", num); ++ return -EINVAL; ++ } ++ ++ while (count < num) { ++ desc_id = (rxq->next_to_use + offset + count) % rxq->nb_rx_desc; ++ bd_data = (uint32_t *)(&rxq->rx_ring[desc_id]); ++ fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id); ++ for (i = 0; i < HNS3_BD_DW_NUM; i++) { ++ /* ++ * For the sake of security, first 8 bytes of BD which ++ * stands for physical address of packet should not be ++ * shown. ++ */ ++ if (i < HNS3_BD_ADDRESS_LAST_DW) { ++ fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0); ++ continue; ++ } ++ fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, ++ *(bd_data + i)); ++ } ++ count++; ++ } ++ ++ return 0; ++} ++ ++int ++hns3_tx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id, ++ uint16_t offset, uint16_t num, FILE *file) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id]; ++ uint32_t *bd_data; ++ uint16_t count = 0; ++ uint16_t desc_id; ++ int i; ++ ++ if (offset >= txq->nb_tx_desc) ++ return -EINVAL; ++ ++ if (num > txq->nb_tx_desc) { ++ hns3_err(hw, "Invalid BD num=%u\n", num); ++ return -EINVAL; ++ } ++ ++ while (count < num) { ++ desc_id = (txq->next_to_use + offset + count) % txq->nb_tx_desc; ++ bd_data = (uint32_t *)(&txq->tx_ring[desc_id]); ++ fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id); ++ for (i = 0; i < HNS3_BD_DW_NUM; i++) { ++ /* ++ * For the sake of security, first 8 bytes of BD which ++ * stands for physical address of packet should not be ++ * shown. ++ */ ++ if (i < HNS3_BD_ADDRESS_LAST_DW) { ++ fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0); ++ continue; ++ } ++ ++ fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i, ++ *(bd_data + i)); ++ } ++ count++; ++ } ++ ++ return 0; ++} +diff --git a/drivers/net/hns3/hns3_dump.h b/drivers/net/hns3/hns3_dump.h +index 616cb70d6e..021ce1bbdb 100644 +--- a/drivers/net/hns3/hns3_dump.h ++++ b/drivers/net/hns3/hns3_dump.h +@@ -7,4 +7,8 @@ + + int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file); + ++int hns3_rx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id, ++ uint16_t offset, uint16_t num, FILE *file); ++int hns3_tx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id, ++ uint16_t offset, uint16_t num, FILE *file); + #endif /* HNS3_DUMP_H */ +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 7330515535..f83cff4d98 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -6558,6 +6558,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = { + .timesync_read_time = hns3_timesync_read_time, + .timesync_write_time = hns3_timesync_write_time, + .eth_dev_priv_dump = hns3_eth_dev_priv_dump, ++ .eth_rx_descriptor_dump = hns3_rx_descriptor_dump, ++ .eth_tx_descriptor_dump = hns3_tx_descriptor_dump, + }; + + static const struct hns3_reset_ops hns3_reset_ops = { +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 6976a9f23d..1022b02697 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -2302,6 +2302,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = { + .dev_supported_ptypes_get = hns3_dev_supported_ptypes_get, + .tx_done_cleanup = hns3_tx_done_cleanup, + .eth_dev_priv_dump = hns3_eth_dev_priv_dump, ++ .eth_rx_descriptor_dump = hns3_rx_descriptor_dump, ++ .eth_tx_descriptor_dump = hns3_tx_descriptor_dump, + }; + + static const struct hns3_reset_ops hns3vf_reset_ops = { +-- +2.23.0 + diff --git a/0166-remove-unnecessary-null-checks.patch b/0166-remove-unnecessary-null-checks.patch new file mode 100644 index 0000000..9ffc903 --- /dev/null +++ b/0166-remove-unnecessary-null-checks.patch @@ -0,0 +1,50 @@ +From ea171dea8f8417fe0715620a3de77e0cf3054916 Mon Sep 17 00:00:00 2001 +From: Stephen Hemminger +Date: Fri, 21 Oct 2022 15:36:42 +0800 +Subject: [PATCH 166/189] remove unnecessary null checks + +Functions like free, rte_free, and rte_mempool_free +already handle NULL pointer so the checks here are not necessary. + +Remove redundant NULL pointer checks before free functions +found by nullfree.cocci + +Note: This patch only captures some hns3 modification from the +following patch: +Fixes: 06c047b68061 ("remove unnecessary null checks") + +Signed-off-by: Stephen Hemminger +--- + drivers/net/hns3/hns3_rxtx.c | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 8ad40a49c7..29caaeafbd 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -86,8 +86,7 @@ hns3_rx_queue_release(void *queue) + hns3_rx_queue_release_mbufs(rxq); + if (rxq->mz) + rte_memzone_free(rxq->mz); +- if (rxq->sw_ring) +- rte_free(rxq->sw_ring); ++ rte_free(rxq->sw_ring); + rte_free(rxq); + } + } +@@ -100,10 +99,8 @@ hns3_tx_queue_release(void *queue) + hns3_tx_queue_release_mbufs(txq); + if (txq->mz) + rte_memzone_free(txq->mz); +- if (txq->sw_ring) +- rte_free(txq->sw_ring); +- if (txq->free) +- rte_free(txq->free); ++ rte_free(txq->sw_ring); ++ rte_free(txq->free); + rte_free(txq); + } + } +-- +2.23.0 + diff --git a/0167-ethdev-introduce-generic-dummy-packet-burst-function.patch b/0167-ethdev-introduce-generic-dummy-packet-burst-function.patch new file mode 100644 index 0000000..ffcd0a7 --- /dev/null +++ b/0167-ethdev-introduce-generic-dummy-packet-burst-function.patch @@ -0,0 +1,175 @@ +From 93df9193174fc6190ec793a0fdfc7bf2ee105669 Mon Sep 17 00:00:00 2001 +From: Ferruh Yigit +Date: Fri, 21 Oct 2022 15:36:43 +0800 +Subject: [PATCH 167/189] ethdev: introduce generic dummy packet burst function +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Multiple PMDs have dummy/noop Rx/Tx packet burst functions. +These dummy functions are very simple, introduce a common function in +the ethdev and update drivers to use it instead of each driver having +its own functions. + +Note: +Note: This patch only captures some hns3 modification from the +following patch: +Fixes: a41f593f1bce ("ethdev: introduce generic dummy packet burst function") + +Signed-off-by: Ferruh Yigit +Acked-by: Morten Brørup +Acked-by: Viacheslav Ovsiienko +Acked-by: Thomas Monjalon +--- + drivers/net/hns3/hns3_rxtx.c | 18 +++++------------- + drivers/net/hns3/hns3_rxtx.h | 3 --- + lib/ethdev/ethdev_driver.c | 13 +++++++++++++ + lib/ethdev/ethdev_driver.h | 17 +++++++++++++++++ + lib/ethdev/meson.build | 1 + + lib/ethdev/version.map | 1 + + 6 files changed, 37 insertions(+), 16 deletions(-) + create mode 100644 lib/ethdev/ethdev_driver.c + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 29caaeafbd..3c02fd54e1 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4365,14 +4365,6 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) + return hns3_xmit_pkts; + } + +-uint16_t +-hns3_dummy_rxtx_burst(void *dpdk_txq __rte_unused, +- struct rte_mbuf **pkts __rte_unused, +- uint16_t pkts_n __rte_unused) +-{ +- return 0; +-} +- + static void + hns3_trace_rxtx_function(struct rte_eth_dev *dev) + { +@@ -4416,14 +4408,14 @@ hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) + eth_dev->rx_pkt_burst = hns3_get_rx_function(eth_dev); + eth_dev->rx_descriptor_status = hns3_dev_rx_descriptor_status; + eth_dev->tx_pkt_burst = hw->set_link_down ? +- hns3_dummy_rxtx_burst : ++ rte_eth_pkt_burst_dummy : + hns3_get_tx_function(eth_dev, &prep); + eth_dev->tx_pkt_prepare = prep; + eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status; + hns3_trace_rxtx_function(eth_dev); + } else { +- eth_dev->rx_pkt_burst = hns3_dummy_rxtx_burst; +- eth_dev->tx_pkt_burst = hns3_dummy_rxtx_burst; ++ eth_dev->rx_pkt_burst = rte_eth_pkt_burst_dummy; ++ eth_dev->tx_pkt_burst = rte_eth_pkt_burst_dummy; + eth_dev->tx_pkt_prepare = NULL; + } + +@@ -4637,7 +4629,7 @@ hns3_tx_done_cleanup(void *txq, uint32_t free_cnt) + + if (dev->tx_pkt_burst == hns3_xmit_pkts) + return hns3_tx_done_cleanup_full(q, free_cnt); +- else if (dev->tx_pkt_burst == hns3_dummy_rxtx_burst) ++ else if (dev->tx_pkt_burst == rte_eth_pkt_burst_dummy) + return 0; + else + return -ENOTSUP; +@@ -4747,7 +4739,7 @@ hns3_enable_rxd_adv_layout(struct hns3_hw *hw) + void + hns3_stop_tx_datapath(struct rte_eth_dev *dev) + { +- dev->tx_pkt_burst = hns3_dummy_rxtx_burst; ++ dev->tx_pkt_burst = rte_eth_pkt_burst_dummy; + dev->tx_pkt_prepare = NULL; + hns3_eth_dev_fp_ops_config(dev); + +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index ed40621b3a..e633b336b1 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -742,9 +742,6 @@ void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev); + void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev); + eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev, + eth_tx_prep_t *prep); +-uint16_t hns3_dummy_rxtx_burst(void *dpdk_txq __rte_unused, +- struct rte_mbuf **pkts __rte_unused, +- uint16_t pkts_n __rte_unused); + + uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id); + void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id, +diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c +new file mode 100644 +index 0000000000..fb7323f4d3 +--- /dev/null ++++ b/lib/ethdev/ethdev_driver.c +@@ -0,0 +1,13 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2022 Intel Corporation ++ */ ++ ++#include "ethdev_driver.h" ++ ++uint16_t ++rte_eth_pkt_burst_dummy(void *queue __rte_unused, ++ struct rte_mbuf **pkts __rte_unused, ++ uint16_t nb_pkts __rte_unused) ++{ ++ return 0; ++} +diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h +index 41f67f2740..d3de203d7a 100644 +--- a/lib/ethdev/ethdev_driver.h ++++ b/lib/ethdev/ethdev_driver.h +@@ -1497,6 +1497,23 @@ rte_eth_linkstatus_get(const struct rte_eth_dev *dev, + *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST); + } + ++/** ++ * @internal ++ * Dummy DPDK callback for Rx/Tx packet burst. ++ * ++ * @param queue ++ * Pointer to Rx/Tx queue ++ * @param pkts ++ * Packet array ++ * @param nb_pkts ++ * Number of packets in packet array ++ */ ++__rte_internal ++uint16_t ++rte_eth_pkt_burst_dummy(void *queue __rte_unused, ++ struct rte_mbuf **pkts __rte_unused, ++ uint16_t nb_pkts __rte_unused); ++ + /** + * Allocate an unique switch domain identifier. + * +diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build +index 0205c853df..a094585bf7 100644 +--- a/lib/ethdev/meson.build ++++ b/lib/ethdev/meson.build +@@ -2,6 +2,7 @@ + # Copyright(c) 2017 Intel Corporation + + sources = files( ++ 'ethdev_driver.c', + 'ethdev_private.c', + 'ethdev_profile.c', + 'ethdev_trace_points.c', +diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map +index 09dba86bee..590aa5a0a6 100644 +--- a/lib/ethdev/version.map ++++ b/lib/ethdev/version.map +@@ -286,6 +286,7 @@ INTERNAL { + rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; ++ rte_eth_pkt_burst_dummy; + rte_eth_representor_id_get; + rte_eth_switch_domain_alloc; + rte_eth_switch_domain_free; +-- +2.23.0 + diff --git a/0168-fix-spelling-in-comments-and-strings.patch b/0168-fix-spelling-in-comments-and-strings.patch new file mode 100644 index 0000000..96827ab --- /dev/null +++ b/0168-fix-spelling-in-comments-and-strings.patch @@ -0,0 +1,9689 @@ +From bf14a018352f534ffdd3586745f362e4a2deb772 Mon Sep 17 00:00:00 2001 +From: Josh Soref +Date: Fri, 21 Oct 2022 15:36:44 +0800 +Subject: [PATCH 168/189] fix spelling in comments and strings + +The tool comes from https://github.com/jsoref + +Signed-off-by: Josh Soref +Signed-off-by: Thomas Monjalon +--- + app/proc-info/main.c | 6 +-- + app/test-acl/main.c | 6 +-- + .../comp_perf_test_cyclecount.c | 2 +- + .../comp_perf_test_throughput.c | 2 +- + .../comp_perf_test_verify.c | 2 +- + app/test-compress-perf/main.c | 2 +- + .../cperf_test_pmd_cyclecount.c | 2 +- + app/test-eventdev/evt_options.c | 2 +- + app/test-eventdev/test_order_common.c | 2 +- + app/test-fib/main.c | 4 +- + app/test-flow-perf/config.h | 2 +- + app/test-flow-perf/main.c | 2 +- + app/test-pmd/cmdline.c | 2 +- + app/test-pmd/cmdline_flow.c | 6 +-- + app/test-pmd/cmdline_tm.c | 4 +- + app/test-pmd/csumonly.c | 2 +- + app/test-pmd/parameters.c | 2 +- + app/test-pmd/testpmd.c | 2 +- + app/test-pmd/txonly.c | 4 +- + app/test/test_barrier.c | 2 +- + app/test/test_bpf.c | 4 +- + app/test/test_compressdev.c | 2 +- + app/test/test_cryptodev.c | 2 +- + app/test/test_fib_perf.c | 2 +- + app/test/test_kni.c | 4 +- + app/test/test_kvargs.c | 16 ++++---- + app/test/test_lpm6_data.h | 2 +- + app/test/test_member.c | 2 +- + app/test/test_mempool.c | 4 +- + app/test/test_memzone.c | 6 +-- + app/test/test_metrics.c | 2 +- + app/test/test_pcapng.c | 2 +- + app/test/test_power_cpufreq.c | 2 +- + app/test/test_rcu_qsbr.c | 4 +- + app/test/test_red.c | 8 ++-- + app/test/test_security.c | 2 +- + app/test/test_table_pipeline.c | 2 +- + app/test/test_thash.c | 2 +- + buildtools/binutils-avx512-check.py | 2 +- + devtools/check-symbol-change.sh | 6 +-- + .../virtio_user_for_container_networking.svg | 2 +- + doc/guides/nics/af_packet.rst | 2 +- + doc/guides/nics/mlx4.rst | 2 +- + doc/guides/nics/mlx5.rst | 6 +-- + doc/guides/prog_guide/cryptodev_lib.rst | 2 +- + .../prog_guide/env_abstraction_layer.rst | 4 +- + doc/guides/prog_guide/img/turbo_tb_decode.svg | 2 +- + doc/guides/prog_guide/img/turbo_tb_encode.svg | 2 +- + doc/guides/prog_guide/qos_framework.rst | 6 +-- + doc/guides/prog_guide/rte_flow.rst | 2 +- + doc/guides/rawdevs/cnxk_bphy.rst | 2 +- + doc/guides/regexdevs/features_overview.rst | 2 +- + doc/guides/rel_notes/release_16_07.rst | 2 +- + doc/guides/rel_notes/release_17_08.rst | 2 +- + doc/guides/rel_notes/release_2_1.rst | 2 +- + doc/guides/sample_app_ug/ip_reassembly.rst | 4 +- + doc/guides/sample_app_ug/l2_forward_cat.rst | 2 +- + doc/guides/sample_app_ug/server_node_efd.rst | 2 +- + doc/guides/sample_app_ug/skeleton.rst | 2 +- + .../sample_app_ug/vm_power_management.rst | 2 +- + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- + drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 8 ++-- + drivers/baseband/null/bbdev_null.c | 2 +- + .../baseband/turbo_sw/bbdev_turbo_software.c | 2 +- + drivers/bus/dpaa/dpaa_bus.c | 2 +- + drivers/bus/dpaa/include/fsl_qman.h | 6 +-- + drivers/bus/dpaa/include/fsl_usd.h | 2 +- + drivers/bus/dpaa/include/process.h | 2 +- + drivers/bus/fslmc/fslmc_bus.c | 2 +- + drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 +- + drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- + .../fslmc/qbman/include/fsl_qbman_portal.h | 20 +++++----- + drivers/bus/pci/linux/pci_vfio.c | 2 +- + drivers/bus/vdev/rte_bus_vdev.h | 2 +- + drivers/bus/vmbus/vmbus_common.c | 2 +- + drivers/common/cnxk/roc_bphy_cgx.c | 2 +- + drivers/common/cnxk/roc_nix_bpf.c | 2 +- + drivers/common/cnxk/roc_nix_tm_ops.c | 2 +- + drivers/common/cnxk/roc_npc_mcam.c | 2 +- + drivers/common/cnxk/roc_npc_priv.h | 2 +- + drivers/common/cpt/cpt_ucode.h | 4 +- + drivers/common/cpt/cpt_ucode_asym.h | 2 +- + drivers/common/dpaax/caamflib/desc/algo.h | 2 +- + drivers/common/dpaax/caamflib/desc/sdap.h | 6 +-- + drivers/common/dpaax/dpaax_iova_table.c | 2 +- + drivers/common/iavf/iavf_type.h | 2 +- + drivers/common/iavf/virtchnl.h | 2 +- + drivers/common/mlx5/mlx5_common.c | 2 +- + drivers/common/mlx5/mlx5_common_mr.c | 2 +- + drivers/common/mlx5/mlx5_devx_cmds.c | 2 +- + drivers/common/mlx5/mlx5_malloc.c | 4 +- + drivers/common/mlx5/mlx5_malloc.h | 2 +- + drivers/common/mlx5/mlx5_prm.h | 2 +- + drivers/common/mlx5/windows/mlx5_common_os.c | 4 +- + drivers/common/mlx5/windows/mlx5_common_os.h | 2 +- + .../qat/qat_adf/adf_transport_access_macros.h | 2 +- + drivers/common/sfc_efx/efsys.h | 2 +- + drivers/compress/octeontx/include/zip_regs.h | 4 +- + drivers/compress/octeontx/otx_zip.h | 2 +- + drivers/compress/qat/qat_comp_pmd.c | 2 +- + drivers/crypto/bcmfs/bcmfs_device.h | 2 +- + drivers/crypto/bcmfs/bcmfs_qp.c | 2 +- + drivers/crypto/bcmfs/bcmfs_sym_defs.h | 6 +-- + drivers/crypto/bcmfs/bcmfs_sym_engine.h | 2 +- + drivers/crypto/bcmfs/hw/bcmfs5_rm.c | 2 +- + drivers/crypto/caam_jr/caam_jr_hw_specific.h | 4 +- + drivers/crypto/caam_jr/caam_jr_pvt.h | 4 +- + drivers/crypto/caam_jr/caam_jr_uio.c | 2 +- + drivers/crypto/ccp/ccp_crypto.c | 2 +- + drivers/crypto/ccp/ccp_crypto.h | 2 +- + drivers/crypto/ccp/ccp_dev.h | 2 +- + drivers/crypto/dpaa_sec/dpaa_sec.c | 2 +- + .../crypto/octeontx/otx_cryptodev_hw_access.c | 2 +- + drivers/crypto/octeontx/otx_cryptodev_mbox.h | 2 +- + drivers/crypto/octeontx/otx_cryptodev_ops.c | 2 +- + drivers/crypto/qat/qat_asym.c | 2 +- + drivers/crypto/qat/qat_sym.c | 2 +- + drivers/crypto/virtio/virtqueue.h | 2 +- + drivers/dma/skeleton/skeleton_dmadev.c | 2 +- + drivers/event/cnxk/cnxk_eventdev_selftest.c | 4 +- + drivers/event/dlb2/dlb2.c | 2 +- + drivers/event/dlb2/dlb2_priv.h | 2 +- + drivers/event/dlb2/dlb2_selftest.c | 2 +- + drivers/event/dlb2/rte_pmd_dlb2.h | 2 +- + drivers/event/dpaa2/dpaa2_eventdev_selftest.c | 2 +- + drivers/event/dsw/dsw_evdev.h | 4 +- + drivers/event/dsw/dsw_event.c | 4 +- + drivers/event/octeontx/ssovf_evdev.h | 2 +- + drivers/event/octeontx/ssovf_evdev_selftest.c | 2 +- + drivers/event/octeontx2/otx2_evdev_selftest.c | 2 +- + drivers/event/octeontx2/otx2_worker_dual.h | 2 +- + drivers/event/opdl/opdl_evdev.c | 2 +- + drivers/event/opdl/opdl_test.c | 2 +- + drivers/event/sw/sw_evdev.h | 2 +- + drivers/event/sw/sw_evdev_selftest.c | 2 +- + drivers/mempool/dpaa/dpaa_mempool.c | 2 +- + drivers/mempool/octeontx/octeontx_fpavf.c | 4 +- + drivers/net/ark/ark_global.h | 2 +- + drivers/net/atlantic/atl_ethdev.c | 2 +- + drivers/net/atlantic/atl_rxtx.c | 2 +- + drivers/net/atlantic/hw_atl/hw_atl_b0.c | 2 +- + drivers/net/axgbe/axgbe_dev.c | 2 +- + drivers/net/axgbe/axgbe_ethdev.c | 2 +- + drivers/net/axgbe/axgbe_ethdev.h | 2 +- + drivers/net/axgbe/axgbe_phy_impl.c | 4 +- + drivers/net/axgbe/axgbe_rxtx_vec_sse.c | 2 +- + drivers/net/bnx2x/bnx2x.c | 38 +++++++++---------- + drivers/net/bnx2x/bnx2x.h | 10 ++--- + drivers/net/bnx2x/bnx2x_stats.c | 2 +- + drivers/net/bnx2x/bnx2x_stats.h | 4 +- + drivers/net/bnx2x/bnx2x_vfpf.c | 2 +- + drivers/net/bnx2x/bnx2x_vfpf.h | 2 +- + drivers/net/bnx2x/ecore_fw_defs.h | 2 +- + drivers/net/bnx2x/ecore_hsi.h | 26 ++++++------- + drivers/net/bnx2x/ecore_init_ops.h | 6 +-- + drivers/net/bnx2x/ecore_reg.h | 28 +++++++------- + drivers/net/bnx2x/ecore_sp.c | 6 +-- + drivers/net/bnx2x/ecore_sp.h | 6 +-- + drivers/net/bnx2x/elink.c | 20 +++++----- + drivers/net/bnxt/bnxt_hwrm.c | 2 +- + drivers/net/bnxt/tf_core/tfp.c | 2 +- + drivers/net/bnxt/tf_core/tfp.h | 2 +- + drivers/net/bonding/eth_bond_8023ad_private.h | 2 +- + drivers/net/bonding/eth_bond_private.h | 2 +- + drivers/net/bonding/rte_eth_bond_8023ad.c | 20 +++++----- + drivers/net/bonding/rte_eth_bond_8023ad.h | 4 +- + drivers/net/bonding/rte_eth_bond_alb.h | 2 +- + drivers/net/bonding/rte_eth_bond_api.c | 4 +- + drivers/net/cnxk/cn10k_ethdev.h | 2 +- + drivers/net/cnxk/cn10k_tx.h | 6 +-- + drivers/net/cnxk/cn9k_tx.h | 6 +-- + drivers/net/cnxk/cnxk_ptp.c | 2 +- + drivers/net/cxgbe/cxgbe_flow.c | 2 +- + drivers/net/cxgbe/cxgbevf_main.c | 2 +- + drivers/net/cxgbe/sge.c | 8 ++-- + drivers/net/dpaa/dpaa_ethdev.c | 6 +-- + drivers/net/dpaa/dpaa_rxtx.c | 4 +- + drivers/net/dpaa/fmlib/fm_ext.h | 2 +- + drivers/net/dpaa/fmlib/fm_pcd_ext.h | 8 ++-- + drivers/net/dpaa/fmlib/fm_port_ext.h | 14 +++---- + drivers/net/dpaa2/dpaa2_ethdev.c | 14 +++---- + drivers/net/dpaa2/dpaa2_ethdev.h | 2 +- + drivers/net/dpaa2/dpaa2_flow.c | 8 ++-- + drivers/net/dpaa2/dpaa2_mux.c | 2 +- + drivers/net/dpaa2/dpaa2_rxtx.c | 6 +-- + drivers/net/dpaa2/mc/fsl_dpni.h | 10 ++--- + drivers/net/e1000/e1000_ethdev.h | 4 +- + drivers/net/e1000/em_ethdev.c | 10 ++--- + drivers/net/e1000/em_rxtx.c | 6 +-- + drivers/net/e1000/igb_ethdev.c | 18 ++++----- + drivers/net/e1000/igb_flow.c | 4 +- + drivers/net/e1000/igb_pf.c | 2 +- + drivers/net/e1000/igb_rxtx.c | 14 +++---- + drivers/net/ena/ena_ethdev.c | 2 +- + drivers/net/ena/ena_ethdev.h | 2 +- + drivers/net/enetfec/enet_regs.h | 2 +- + drivers/net/enic/enic_flow.c | 18 ++++----- + drivers/net/enic/enic_fm_flow.c | 10 ++--- + drivers/net/enic/enic_main.c | 2 +- + drivers/net/enic/enic_rxtx.c | 2 +- + drivers/net/fm10k/fm10k.h | 2 +- + drivers/net/fm10k/fm10k_ethdev.c | 12 +++--- + drivers/net/fm10k/fm10k_rxtx_vec.c | 10 ++--- + drivers/net/hinic/hinic_pmd_ethdev.c | 4 +- + drivers/net/hinic/hinic_pmd_ethdev.h | 2 +- + drivers/net/hinic/hinic_pmd_flow.c | 4 +- + drivers/net/hinic/hinic_pmd_tx.c | 2 +- + drivers/net/hns3/hns3_cmd.c | 4 +- + drivers/net/hns3/hns3_common.c | 2 +- + drivers/net/hns3/hns3_dcb.c | 10 ++--- + drivers/net/hns3/hns3_ethdev.c | 14 +++---- + drivers/net/hns3/hns3_ethdev.h | 8 ++-- + drivers/net/hns3/hns3_ethdev_vf.c | 4 +- + drivers/net/hns3/hns3_fdir.h | 2 +- + drivers/net/hns3/hns3_flow.c | 12 +++--- + drivers/net/hns3/hns3_mbx.c | 4 +- + drivers/net/hns3/hns3_mbx.h | 2 +- + drivers/net/hns3/hns3_rss.h | 2 +- + drivers/net/hns3/hns3_rxtx.c | 16 ++++---- + drivers/net/hns3/hns3_rxtx.h | 2 +- + drivers/net/hns3/hns3_stats.c | 2 +- + drivers/net/i40e/i40e_ethdev.c | 12 +++--- + drivers/net/i40e/i40e_ethdev.h | 10 ++--- + drivers/net/i40e/i40e_fdir.c | 10 ++--- + drivers/net/i40e/i40e_flow.c | 2 +- + drivers/net/i40e/i40e_pf.c | 4 +- + drivers/net/i40e/i40e_rxtx.c | 20 +++++----- + drivers/net/i40e/i40e_rxtx_vec_altivec.c | 2 +- + drivers/net/i40e/i40e_rxtx_vec_neon.c | 4 +- + drivers/net/i40e/i40e_rxtx_vec_sse.c | 6 +-- + drivers/net/i40e/rte_pmd_i40e.c | 2 +- + drivers/net/iavf/iavf_ethdev.c | 6 +-- + drivers/net/iavf/iavf_ipsec_crypto.c | 14 +++---- + drivers/net/iavf/iavf_ipsec_crypto.h | 2 +- + drivers/net/iavf/iavf_rxtx.c | 4 +- + drivers/net/iavf/iavf_rxtx_vec_sse.c | 4 +- + drivers/net/iavf/iavf_vchnl.c | 4 +- + drivers/net/ice/ice_dcf.c | 2 +- + drivers/net/ice/ice_dcf_ethdev.c | 2 +- + drivers/net/ice/ice_ethdev.c | 12 +++--- + drivers/net/ice/ice_rxtx.c | 10 ++--- + drivers/net/ice/ice_rxtx_vec_sse.c | 4 +- + drivers/net/igc/igc_filter.c | 2 +- + drivers/net/igc/igc_txrx.c | 4 +- + drivers/net/ionic/ionic_if.h | 6 +-- + drivers/net/ipn3ke/ipn3ke_ethdev.c | 2 +- + drivers/net/ipn3ke/ipn3ke_ethdev.h | 4 +- + drivers/net/ipn3ke/ipn3ke_flow.c | 2 +- + drivers/net/ipn3ke/ipn3ke_representor.c | 12 +++--- + drivers/net/ipn3ke/meson.build | 2 +- + drivers/net/ixgbe/ixgbe_bypass.c | 2 +- + drivers/net/ixgbe/ixgbe_bypass_api.h | 4 +- + drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++----- + drivers/net/ixgbe/ixgbe_ethdev.h | 2 +- + drivers/net/ixgbe/ixgbe_fdir.c | 2 +- + drivers/net/ixgbe/ixgbe_flow.c | 4 +- + drivers/net/ixgbe/ixgbe_ipsec.c | 2 +- + drivers/net/ixgbe/ixgbe_pf.c | 2 +- + drivers/net/ixgbe/ixgbe_rxtx.c | 10 ++--- + drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 2 +- + drivers/net/memif/memif_socket.c | 2 +- + drivers/net/memif/rte_eth_memif.c | 2 +- + drivers/net/mlx4/mlx4.h | 2 +- + drivers/net/mlx4/mlx4_ethdev.c | 2 +- + drivers/net/mlx5/linux/mlx5_os.c | 8 ++-- + drivers/net/mlx5/mlx5.c | 10 ++--- + drivers/net/mlx5/mlx5.h | 8 ++-- + drivers/net/mlx5/mlx5_flow.c | 20 +++++----- + drivers/net/mlx5/mlx5_flow.h | 6 +-- + drivers/net/mlx5/mlx5_flow_dv.c | 14 +++---- + drivers/net/mlx5/mlx5_flow_flex.c | 4 +- + drivers/net/mlx5/mlx5_flow_meter.c | 10 ++--- + drivers/net/mlx5/mlx5_rx.c | 2 +- + drivers/net/mlx5/mlx5_rxq.c | 4 +- + drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 2 +- + drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 2 +- + drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 2 +- + drivers/net/mlx5/mlx5_tx.c | 2 +- + drivers/net/mlx5/mlx5_utils.h | 2 +- + drivers/net/mlx5/windows/mlx5_flow_os.c | 2 +- + drivers/net/mlx5/windows/mlx5_os.c | 2 +- + drivers/net/mvneta/mvneta_ethdev.c | 2 +- + drivers/net/mvpp2/mrvl_ethdev.c | 2 +- + drivers/net/mvpp2/mrvl_qos.c | 4 +- + drivers/net/netvsc/hn_nvs.c | 2 +- + drivers/net/netvsc/hn_rxtx.c | 4 +- + drivers/net/netvsc/hn_vf.c | 2 +- + .../net/nfp/nfpcore/nfp-common/nfp_resid.h | 6 +-- + drivers/net/nfp/nfpcore/nfp_cppcore.c | 2 +- + drivers/net/nfp/nfpcore/nfp_nsp.h | 2 +- + drivers/net/nfp/nfpcore/nfp_resource.c | 2 +- + drivers/net/nfp/nfpcore/nfp_rtsym.c | 2 +- + drivers/net/ngbe/ngbe_ethdev.c | 6 +-- + drivers/net/ngbe/ngbe_pf.c | 2 +- + drivers/net/octeontx/octeontx_ethdev.c | 2 +- + drivers/net/octeontx2/otx2_ethdev_irq.c | 2 +- + drivers/net/octeontx2/otx2_ptp.c | 2 +- + drivers/net/octeontx2/otx2_tx.h | 4 +- + drivers/net/octeontx2/otx2_vlan.c | 2 +- + drivers/net/octeontx_ep/otx2_ep_vf.c | 2 +- + drivers/net/octeontx_ep/otx_ep_vf.c | 2 +- + drivers/net/pfe/pfe_ethdev.c | 2 +- + drivers/net/pfe/pfe_hal.c | 2 +- + drivers/net/pfe/pfe_hif.c | 4 +- + drivers/net/pfe/pfe_hif.h | 2 +- + drivers/net/pfe/pfe_hif_lib.c | 8 ++-- + drivers/net/qede/qede_debug.c | 4 +- + drivers/net/qede/qede_ethdev.c | 2 +- + drivers/net/qede/qede_rxtx.c | 12 +++--- + drivers/net/qede/qede_rxtx.h | 2 +- + drivers/net/sfc/sfc.c | 2 +- + drivers/net/sfc/sfc_dp.c | 2 +- + drivers/net/sfc/sfc_dp_rx.h | 4 +- + drivers/net/sfc/sfc_ef100.h | 2 +- + drivers/net/sfc/sfc_ef100_rx.c | 2 +- + drivers/net/sfc/sfc_ef10_essb_rx.c | 2 +- + drivers/net/sfc/sfc_ef10_rx_ev.h | 2 +- + drivers/net/sfc/sfc_intr.c | 2 +- + drivers/net/sfc/sfc_rx.c | 6 +-- + drivers/net/sfc/sfc_tx.c | 2 +- + drivers/net/softnic/rte_eth_softnic_flow.c | 2 +- + drivers/net/tap/rte_eth_tap.c | 2 +- + drivers/net/tap/tap_bpf_api.c | 4 +- + drivers/net/tap/tap_flow.c | 4 +- + drivers/net/thunderx/nicvf_svf.c | 2 +- + drivers/net/txgbe/txgbe_ethdev.c | 6 +-- + drivers/net/txgbe/txgbe_ethdev_vf.c | 6 +-- + drivers/net/txgbe/txgbe_ipsec.c | 2 +- + drivers/net/txgbe/txgbe_pf.c | 2 +- + drivers/net/virtio/virtio_ethdev.c | 4 +- + drivers/net/virtio/virtio_pci.c | 2 +- + drivers/net/virtio/virtio_rxtx.c | 2 +- + drivers/net/virtio/virtio_rxtx_packed_avx.h | 2 +- + drivers/net/virtio/virtqueue.c | 2 +- + drivers/net/virtio/virtqueue.h | 4 +- + drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 2 +- + drivers/raw/dpaa2_qdma/dpaa2_qdma.h | 4 +- + drivers/raw/ifpga/ifpga_rawdev.c | 10 ++--- + drivers/raw/ntb/ntb.h | 2 +- + drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 2 +- + drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 2 +- + examples/bbdev_app/main.c | 2 +- + examples/bond/main.c | 4 +- + examples/dma/dmafwd.c | 2 +- + examples/ethtool/lib/rte_ethtool.c | 2 +- + examples/ethtool/lib/rte_ethtool.h | 4 +- + examples/ip_reassembly/main.c | 8 ++-- + examples/ipsec-secgw/event_helper.c | 2 +- + examples/ipsec-secgw/ipsec-secgw.c | 14 +++---- + examples/ipsec-secgw/sa.c | 6 +-- + examples/ipsec-secgw/sp4.c | 2 +- + examples/ipsec-secgw/sp6.c | 2 +- + examples/ipsec-secgw/test/common_defs.sh | 4 +- + examples/kni/main.c | 2 +- + examples/l2fwd-cat/l2fwd-cat.c | 2 +- + examples/l2fwd-event/l2fwd_event_generic.c | 2 +- + .../l2fwd-event/l2fwd_event_internal_port.c | 2 +- + examples/l2fwd-jobstats/main.c | 2 +- + examples/l3fwd-acl/main.c | 6 +-- + examples/l3fwd-power/main.c | 4 +- + examples/l3fwd/l3fwd_common.h | 4 +- + examples/l3fwd/l3fwd_neon.h | 2 +- + examples/l3fwd/l3fwd_sse.h | 2 +- + examples/multi_process/hotplug_mp/commands.c | 2 +- + examples/multi_process/simple_mp/main.c | 2 +- + examples/multi_process/symmetric_mp/main.c | 2 +- + examples/ntb/ntb_fwd.c | 2 +- + examples/packet_ordering/main.c | 2 +- + examples/performance-thread/common/lthread.c | 6 +-- + .../performance-thread/common/lthread_diag.c | 2 +- + .../performance-thread/common/lthread_int.h | 2 +- + .../performance-thread/common/lthread_tls.c | 2 +- + .../performance-thread/l3fwd-thread/main.c | 12 +++--- + .../pthread_shim/pthread_shim.h | 2 +- + examples/pipeline/examples/registers.spec | 2 +- + examples/qos_sched/cmdline.c | 2 +- + examples/server_node_efd/node/node.c | 2 +- + examples/skeleton/basicfwd.c | 2 +- + examples/vhost/main.c | 10 ++--- + examples/vm_power_manager/channel_monitor.c | 2 +- + examples/vm_power_manager/power_manager.h | 2 +- + examples/vmdq/main.c | 2 +- + kernel/linux/kni/kni_fifo.h | 2 +- + lib/acl/acl_bld.c | 2 +- + lib/acl/acl_run_altivec.h | 2 +- + lib/acl/acl_run_avx512.c | 2 +- + lib/acl/acl_run_avx512x16.h | 14 +++---- + lib/acl/acl_run_avx512x8.h | 12 +++--- + lib/bpf/bpf_convert.c | 4 +- + lib/dmadev/rte_dmadev.h | 4 +- + lib/eal/arm/include/rte_cycles_32.h | 2 +- + lib/eal/freebsd/eal_interrupts.c | 4 +- + lib/eal/include/generic/rte_pflock.h | 2 +- + lib/eal/include/rte_malloc.h | 4 +- + lib/eal/linux/eal_interrupts.c | 4 +- + lib/eal/linux/eal_vfio.h | 2 +- + lib/eal/windows/eal_windows.h | 2 +- + lib/eal/windows/include/dirent.h | 4 +- + lib/eal/windows/include/fnmatch.h | 4 +- + lib/eal/x86/include/rte_atomic.h | 2 +- + lib/eventdev/rte_event_eth_rx_adapter.c | 6 +-- + lib/fib/rte_fib.c | 6 +-- + lib/fib/rte_fib.h | 4 +- + lib/fib/rte_fib6.c | 6 +-- + lib/fib/rte_fib6.h | 4 +- + lib/ipsec/ipsec_telemetry.c | 2 +- + lib/ipsec/rte_ipsec_sad.h | 2 +- + lib/ipsec/sa.c | 2 +- + lib/mbuf/rte_mbuf_core.h | 2 +- + lib/meson.build | 2 +- + lib/net/rte_l2tpv2.h | 4 +- + lib/pipeline/rte_swx_ctl.h | 4 +- + lib/pipeline/rte_swx_pipeline_internal.h | 4 +- + lib/pipeline/rte_swx_pipeline_spec.c | 2 +- + lib/power/power_cppc_cpufreq.c | 2 +- + lib/regexdev/rte_regexdev.h | 6 +-- + lib/ring/rte_ring_core.h | 2 +- + lib/sched/rte_pie.h | 6 +-- + lib/sched/rte_red.h | 4 +- + lib/sched/rte_sched.c | 2 +- + lib/sched/rte_sched.h | 2 +- + lib/table/rte_swx_table.h | 2 +- + lib/table/rte_swx_table_selector.h | 2 +- + lib/telemetry/telemetry.c | 2 +- + lib/telemetry/telemetry_json.h | 2 +- + lib/vhost/vhost_user.c | 4 +- + 426 files changed, 869 insertions(+), 869 deletions(-) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index fbc1715ce9..accb5e716d 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -637,7 +637,7 @@ metrics_display(int port_id) + + names = rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0); + if (names == NULL) { +- printf("Cannot allocate memory for metrcis names\n"); ++ printf("Cannot allocate memory for metrics names\n"); + rte_free(metrics); + return; + } +@@ -1135,7 +1135,7 @@ show_tm(void) + caplevel.n_nodes_max, + caplevel.n_nodes_nonleaf_max, + caplevel.n_nodes_leaf_max); +- printf("\t -- indetical: non leaf %u leaf %u\n", ++ printf("\t -- identical: non leaf %u leaf %u\n", + caplevel.non_leaf_nodes_identical, + caplevel.leaf_nodes_identical); + +@@ -1289,7 +1289,7 @@ show_ring(char *name) + printf(" - Name (%s) on socket (%d)\n" + " - flags:\n" + "\t -- Single Producer Enqueue (%u)\n" +- "\t -- Single Consmer Dequeue (%u)\n", ++ "\t -- Single Consumer Dequeue (%u)\n", + ptr->name, + ptr->memzone->socket_id, + ptr->flags & RING_F_SP_ENQ, +diff --git a/app/test-acl/main.c b/app/test-acl/main.c +index c2de18770d..06e3847ab9 100644 +--- a/app/test-acl/main.c ++++ b/app/test-acl/main.c +@@ -386,8 +386,8 @@ parse_cb_ipv4_trace(char *str, struct ipv4_5tuple *v) + } + + /* +- * Parses IPV6 address, exepcts the following format: +- * XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX (where X - is a hexedecimal digit). ++ * Parse IPv6 address, expects the following format: ++ * XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX (where X is a hexadecimal digit). + */ + static int + parse_ipv6_addr(const char *in, const char **end, uint32_t v[IPV6_ADDR_U32], +@@ -994,7 +994,7 @@ print_usage(const char *prgname) + "should be either 1 or multiple of %zu, " + "but not greater then %u]\n" + "[--" OPT_MAX_SIZE +- "= " ++ "= " + "leave 0 for default behaviour]\n" + "[--" OPT_ITER_NUM "=]\n" + "[--" OPT_VERBOSE "=]\n" +diff --git a/app/test-compress-perf/comp_perf_test_cyclecount.c b/app/test-compress-perf/comp_perf_test_cyclecount.c +index da55b02b74..1d8e5fe6c2 100644 +--- a/app/test-compress-perf/comp_perf_test_cyclecount.c ++++ b/app/test-compress-perf/comp_perf_test_cyclecount.c +@@ -180,7 +180,7 @@ main_loop(struct cperf_cyclecount_ctx *ctx, enum rte_comp_xform_type type) + + if (ops == NULL) { + RTE_LOG(ERR, USER1, +- "Can't allocate memory for ops strucures\n"); ++ "Can't allocate memory for ops structures\n"); + return -1; + } + +diff --git a/app/test-compress-perf/comp_perf_test_throughput.c b/app/test-compress-perf/comp_perf_test_throughput.c +index d3dff070b0..4569599eb9 100644 +--- a/app/test-compress-perf/comp_perf_test_throughput.c ++++ b/app/test-compress-perf/comp_perf_test_throughput.c +@@ -72,7 +72,7 @@ main_loop(struct cperf_benchmark_ctx *ctx, enum rte_comp_xform_type type) + + if (ops == NULL) { + RTE_LOG(ERR, USER1, +- "Can't allocate memory for ops strucures\n"); ++ "Can't allocate memory for ops structures\n"); + return -1; + } + +diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c +index f6e21368e8..7d06029488 100644 +--- a/app/test-compress-perf/comp_perf_test_verify.c ++++ b/app/test-compress-perf/comp_perf_test_verify.c +@@ -75,7 +75,7 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type) + + if (ops == NULL) { + RTE_LOG(ERR, USER1, +- "Can't allocate memory for ops strucures\n"); ++ "Can't allocate memory for ops structures\n"); + return -1; + } + +diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c +index cc9951a9b1..6ff6a2f04a 100644 +--- a/app/test-compress-perf/main.c ++++ b/app/test-compress-perf/main.c +@@ -67,7 +67,7 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) + + uint64_t comp_flags = cap->comp_feature_flags; + +- /* Huffman enconding */ ++ /* Huffman encoding */ + if (test_data->huffman_enc == RTE_COMP_HUFFMAN_FIXED && + (comp_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0) { + RTE_LOG(ERR, USER1, +diff --git a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c +index ba1f104f72..5842f29d43 100644 +--- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c ++++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c +@@ -334,7 +334,7 @@ pmd_cyclecount_bench_burst_sz( + * queue, so we never get any failed enqs unless the driver won't accept + * the exact number of descriptors we requested, or the driver won't + * wrap around the end of the TX ring. However, since we're only +- * dequeueing once we've filled up the queue, we have to benchmark it ++ * dequeuing once we've filled up the queue, we have to benchmark it + * piecemeal and then average out the results. + */ + cur_op = 0; +diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c +index 753a7dbd7d..4ae44801da 100644 +--- a/app/test-eventdev/evt_options.c ++++ b/app/test-eventdev/evt_options.c +@@ -336,7 +336,7 @@ usage(char *program) + "\t--deq_tmo_nsec : global dequeue timeout\n" + "\t--prod_type_ethdev : use ethernet device as producer.\n" + "\t--prod_type_timerdev : use event timer device as producer.\n" +- "\t expity_nsec would be the timeout\n" ++ "\t expiry_nsec would be the timeout\n" + "\t in ns.\n" + "\t--prod_type_timerdev_burst : use timer device as producer\n" + "\t burst mode.\n" +diff --git a/app/test-eventdev/test_order_common.c b/app/test-eventdev/test_order_common.c +index ff7813f9c2..603e7c9178 100644 +--- a/app/test-eventdev/test_order_common.c ++++ b/app/test-eventdev/test_order_common.c +@@ -253,7 +253,7 @@ void + order_opt_dump(struct evt_options *opt) + { + evt_dump_producer_lcores(opt); +- evt_dump("nb_wrker_lcores", "%d", evt_nr_active_lcores(opt->wlcores)); ++ evt_dump("nb_worker_lcores", "%d", evt_nr_active_lcores(opt->wlcores)); + evt_dump_worker_lcores(opt); + evt_dump("nb_evdev_ports", "%d", order_nb_event_ports(opt)); + } +diff --git a/app/test-fib/main.c b/app/test-fib/main.c +index ecd420116a..622703dce8 100644 +--- a/app/test-fib/main.c ++++ b/app/test-fib/main.c +@@ -624,7 +624,7 @@ print_usage(void) + "(if -f is not specified)>]\n" + "[-r ]\n" +- "[-c ]\n" ++ "[-c ]\n" + "[-6 ]\n" + "[-s ]\n" + "[-a ]\n" + "[-w ]\n" + "[-u ]\n" +- "[-v ]\n", +diff --git a/app/test-flow-perf/config.h b/app/test-flow-perf/config.h +index 0db2254bd1..29b63298e0 100644 +--- a/app/test-flow-perf/config.h ++++ b/app/test-flow-perf/config.h +@@ -28,7 +28,7 @@ + #define PORT_ID_DST 1 + #define TEID_VALUE 1 + +-/* Flow items/acctions max size */ ++/* Flow items/actions max size */ + #define MAX_ITEMS_NUM 32 + #define MAX_ACTIONS_NUM 32 + #define MAX_ATTRS_NUM 16 +diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c +index 11f1ee0e1e..56d43734e3 100644 +--- a/app/test-flow-perf/main.c ++++ b/app/test-flow-perf/main.c +@@ -1519,7 +1519,7 @@ dump_used_cpu_time(const char *item, + * threads time. + * + * Throughput: total count of rte rules divided +- * over the average of the time cosumed by all ++ * over the average of the time consumed by all + * threads time. + */ + double insertion_latency_time; +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 1f9fd61394..26d95e64e0 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -561,7 +561,7 @@ static void cmd_help_long_parsed(void *parsed_result, + " Set the option to enable display of RX and TX bursts.\n" + + "set port (port_id) vf (vf_id) rx|tx on|off\n" +- " Enable/Disable a VF receive/tranmit from a port\n\n" ++ " Enable/Disable a VF receive/transmit from a port\n\n" + + "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" + "|MPE) (on|off)\n" +diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c +index bbe3dc0115..5c2bba48ad 100644 +--- a/app/test-pmd/cmdline_flow.c ++++ b/app/test-pmd/cmdline_flow.c +@@ -2162,7 +2162,7 @@ static const struct token token_list[] = { + }, + [COMMON_POLICY_ID] = { + .name = "{policy_id}", +- .type = "POLCIY_ID", ++ .type = "POLICY_ID", + .help = "policy id", + .call = parse_int, + .comp = comp_none, +@@ -2370,7 +2370,7 @@ static const struct token token_list[] = { + }, + [TUNNEL_DESTROY] = { + .name = "destroy", +- .help = "destroy tunel", ++ .help = "destroy tunnel", + .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID), + NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), +@@ -2378,7 +2378,7 @@ static const struct token token_list[] = { + }, + [TUNNEL_DESTROY_ID] = { + .name = "id", +- .help = "tunnel identifier to testroy", ++ .help = "tunnel identifier to destroy", + .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)), + .call = parse_tunnel, +diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c +index bfbd43ca9b..c058b8946e 100644 +--- a/app/test-pmd/cmdline_tm.c ++++ b/app/test-pmd/cmdline_tm.c +@@ -69,7 +69,7 @@ print_err_msg(struct rte_tm_error *error) + [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS] + = "num shared shapers field (node params)", + [RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE] +- = "wfq weght mode field (node params)", ++ = "wfq weight mode field (node params)", + [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES] + = "num strict priorities field (node params)", + [RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN] +@@ -479,7 +479,7 @@ static void cmd_show_port_tm_level_cap_parsed(void *parsed_result, + cmdline_parse_inst_t cmd_show_port_tm_level_cap = { + .f = cmd_show_port_tm_level_cap_parsed, + .data = NULL, +- .help_str = "Show Port TM Hierarhical level Capabilities", ++ .help_str = "Show port TM hierarchical level capabilities", + .tokens = { + (void *)&cmd_show_port_tm_level_cap_show, + (void *)&cmd_show_port_tm_level_cap_port, +diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c +index 2aeea243b6..0177284d9c 100644 +--- a/app/test-pmd/csumonly.c ++++ b/app/test-pmd/csumonly.c +@@ -796,7 +796,7 @@ pkt_copy_split(const struct rte_mbuf *pkt) + * + * The testpmd command line for this forward engine sets the flags + * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control +- * wether a checksum must be calculated in software or in hardware. The ++ * whether a checksum must be calculated in software or in hardware. The + * IP, UDP, TCP and SCTP flags always concern the inner layer. The + * OUTER_IP is only useful for tunnel packets. + */ +diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c +index 24e03e769c..435687fa6d 100644 +--- a/app/test-pmd/parameters.c ++++ b/app/test-pmd/parameters.c +@@ -113,7 +113,7 @@ usage(char* progname) + "If the drop-queue doesn't exist, the packet is dropped. " + "By default drop-queue=127.\n"); + #ifdef RTE_LIB_LATENCYSTATS +- printf(" --latencystats=N: enable latency and jitter statistcs " ++ printf(" --latencystats=N: enable latency and jitter statistics " + "monitoring on forwarding lcore id N.\n"); + #endif + printf(" --disable-crc-strip: disable CRC stripping by hardware.\n"); +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index 66d5167f57..2be92af9f8 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -453,7 +453,7 @@ uint32_t bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; + uint8_t latencystats_enabled; + + /* +- * Lcore ID to serive latency statistics. ++ * Lcore ID to service latency statistics. + */ + lcoreid_t latencystats_lcore_id = -1; + +diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c +index b8497e733d..e8c0c7b926 100644 +--- a/app/test-pmd/txonly.c ++++ b/app/test-pmd/txonly.c +@@ -174,14 +174,14 @@ update_pkt_header(struct rte_mbuf *pkt, uint32_t total_pkt_len) + sizeof(struct rte_ether_hdr) + + sizeof(struct rte_ipv4_hdr) + + sizeof(struct rte_udp_hdr))); +- /* updata udp pkt length */ ++ /* update UDP packet length */ + udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *, + sizeof(struct rte_ether_hdr) + + sizeof(struct rte_ipv4_hdr)); + pkt_len = (uint16_t) (pkt_data_len + sizeof(struct rte_udp_hdr)); + udp_hdr->dgram_len = RTE_CPU_TO_BE_16(pkt_len); + +- /* updata ip pkt length and csum */ ++ /* update IP packet length and checksum */ + ip_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *, + sizeof(struct rte_ether_hdr)); + ip_hdr->hdr_checksum = 0; +diff --git a/app/test/test_barrier.c b/app/test/test_barrier.c +index 6d6d48749c..ec69af25bf 100644 +--- a/app/test/test_barrier.c ++++ b/app/test/test_barrier.c +@@ -11,7 +11,7 @@ + * (https://en.wikipedia.org/wiki/Peterson%27s_algorithm) + * for two execution units to make sure that rte_smp_mb() prevents + * store-load reordering to happen. +- * Also when executed on a single lcore could be used as a approxiamate ++ * Also when executed on a single lcore could be used as a approximate + * estimation of number of cycles particular implementation of rte_smp_mb() + * will take. + */ +diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c +index 46bcb51f86..2d755a872f 100644 +--- a/app/test/test_bpf.c ++++ b/app/test/test_bpf.c +@@ -23,7 +23,7 @@ + /* + * Basic functional tests for librte_bpf. + * The main procedure - load eBPF program, execute it and +- * compare restuls with expected values. ++ * compare results with expected values. + */ + + struct dummy_offset { +@@ -2707,7 +2707,7 @@ test_ld_mbuf1_check(uint64_t rc, const void *arg) + } + + /* +- * same as ld_mbuf1, but then trancate the mbuf by 1B, ++ * same as ld_mbuf1, but then truncate the mbuf by 1B, + * so load of last 4B fail. + */ + static void +diff --git a/app/test/test_compressdev.c b/app/test/test_compressdev.c +index c63b5b6737..57c566aa92 100644 +--- a/app/test/test_compressdev.c ++++ b/app/test/test_compressdev.c +@@ -1256,7 +1256,7 @@ test_deflate_comp_run(const struct interim_data_params *int_data, + /* + * Store original operation index in private data, + * since ordering does not have to be maintained, +- * when dequeueing from compressdev, so a comparison ++ * when dequeuing from compressdev, so a comparison + * at the end of the test can be done. + */ + priv_data = (struct priv_op_data *) (ops[i] + 1); +diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c +index 10b48cdadb..6c949605b8 100644 +--- a/app/test/test_cryptodev.c ++++ b/app/test/test_cryptodev.c +@@ -6870,7 +6870,7 @@ test_snow3g_decryption_with_digest_test_case_1(void) + } + + /* +- * Function prepare data for hash veryfication test case. ++ * Function prepare data for hash verification test case. + * Digest is allocated in 4 last bytes in plaintext, pattern. + */ + snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data); +diff --git a/app/test/test_fib_perf.c b/app/test/test_fib_perf.c +index 86b2f832b8..7a25fe8df7 100644 +--- a/app/test/test_fib_perf.c ++++ b/app/test/test_fib_perf.c +@@ -346,7 +346,7 @@ test_fib_perf(void) + fib = rte_fib_create(__func__, SOCKET_ID_ANY, &config); + TEST_FIB_ASSERT(fib != NULL); + +- /* Measue add. */ ++ /* Measure add. */ + begin = rte_rdtsc(); + + for (i = 0; i < NUM_ROUTE_ENTRIES; i++) { +diff --git a/app/test/test_kni.c b/app/test/test_kni.c +index 40ab0d5c4c..2761de9b07 100644 +--- a/app/test/test_kni.c ++++ b/app/test/test_kni.c +@@ -326,7 +326,7 @@ test_kni_register_handler_mp(void) + + /* Check with the invalid parameters */ + if (rte_kni_register_handlers(kni, NULL) == 0) { +- printf("Unexpectedly register successuflly " ++ printf("Unexpectedly register successfully " + "with NULL ops pointer\n"); + exit(-1); + } +@@ -475,7 +475,7 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp) + + /** + * Check multiple processes support on +- * registerring/unregisterring handlers. ++ * registering/unregistering handlers. + */ + if (test_kni_register_handler_mp() < 0) { + printf("fail to check multiple process support\n"); +diff --git a/app/test/test_kvargs.c b/app/test/test_kvargs.c +index a91ea8dc47..b7b97a0dd9 100644 +--- a/app/test/test_kvargs.c ++++ b/app/test/test_kvargs.c +@@ -11,7 +11,7 @@ + + #include "test.h" + +-/* incrementd in handler, to check it is properly called once per ++/* incremented in handler, to check it is properly called once per + * key/value association */ + static unsigned count; + +@@ -107,14 +107,14 @@ static int test_valid_kvargs(void) + goto fail; + } + count = 0; +- /* call check_handler() for all entries with key="unexistant_key" */ +- if (rte_kvargs_process(kvlist, "unexistant_key", check_handler, NULL) < 0) { ++ /* call check_handler() for all entries with key="nonexistent_key" */ ++ if (rte_kvargs_process(kvlist, "nonexistent_key", check_handler, NULL) < 0) { + printf("rte_kvargs_process() error\n"); + rte_kvargs_free(kvlist); + goto fail; + } + if (count != 0) { +- printf("invalid count value %d after rte_kvargs_process(unexistant_key)\n", ++ printf("invalid count value %d after rte_kvargs_process(nonexistent_key)\n", + count); + rte_kvargs_free(kvlist); + goto fail; +@@ -135,10 +135,10 @@ static int test_valid_kvargs(void) + rte_kvargs_free(kvlist); + goto fail; + } +- /* count all entries with key="unexistant_key" */ +- count = rte_kvargs_count(kvlist, "unexistant_key"); ++ /* count all entries with key="nonexistent_key" */ ++ count = rte_kvargs_count(kvlist, "nonexistent_key"); + if (count != 0) { +- printf("invalid count value %d after rte_kvargs_count(unexistant_key)\n", ++ printf("invalid count value %d after rte_kvargs_count(nonexistent_key)\n", + count); + rte_kvargs_free(kvlist); + goto fail; +@@ -156,7 +156,7 @@ static int test_valid_kvargs(void) + /* call check_handler() on all entries with key="check", it + * should fail as the value is not recognized by the handler */ + if (rte_kvargs_process(kvlist, "check", check_handler, NULL) == 0) { +- printf("rte_kvargs_process() is success bu should not\n"); ++ printf("rte_kvargs_process() is success but should not\n"); + rte_kvargs_free(kvlist); + goto fail; + } +diff --git a/app/test/test_lpm6_data.h b/app/test/test_lpm6_data.h +index c3894f730e..da9b161f20 100644 +--- a/app/test/test_lpm6_data.h ++++ b/app/test/test_lpm6_data.h +@@ -22,7 +22,7 @@ struct ips_tbl_entry { + * in previous test_lpm6_routes.h . Because this table has only 1000 + * lines, keeping it doesn't make LPM6 test case so large and also + * make the algorithm to generate rule table unnecessary and the +- * algorithm to genertate test input IPv6 and associated expected ++ * algorithm to generate test input IPv6 and associated expected + * next_hop much simple. + */ + +diff --git a/app/test/test_member.c b/app/test/test_member.c +index 40aa4c8627..af9d50915c 100644 +--- a/app/test/test_member.c ++++ b/app/test/test_member.c +@@ -459,7 +459,7 @@ static int test_member_multimatch(void) + MAX_MATCH, set_ids_cache); + /* + * For cache mode, keys overwrite when signature same. +- * the mutimatch should work like single match. ++ * the multimatch should work like single match. + */ + TEST_ASSERT(ret_ht == M_MATCH_CNT && ret_vbf == M_MATCH_CNT && + ret_cache == 1, +diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c +index f6c650d11f..8e493eda47 100644 +--- a/app/test/test_mempool.c ++++ b/app/test/test_mempool.c +@@ -304,7 +304,7 @@ static int test_mempool_single_consumer(void) + } + + /* +- * test function for mempool test based on singple consumer and single producer, ++ * test function for mempool test based on single consumer and single producer, + * can run on one lcore only + */ + static int +@@ -322,7 +322,7 @@ my_mp_init(struct rte_mempool *mp, __rte_unused void *arg) + } + + /* +- * it tests the mempool operations based on singple producer and single consumer ++ * it tests the mempool operations based on single producer and single consumer + */ + static int + test_mempool_sp_sc(void) +diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c +index 6ddd0fbab5..c9255e5763 100644 +--- a/app/test/test_memzone.c ++++ b/app/test/test_memzone.c +@@ -543,7 +543,7 @@ test_memzone_reserve_max(void) + } + + if (mz->len != maxlen) { +- printf("Memzone reserve with 0 size did not return bigest block\n"); ++ printf("Memzone reserve with 0 size did not return biggest block\n"); + printf("Expected size = %zu, actual size = %zu\n", + maxlen, mz->len); + rte_dump_physmem_layout(stdout); +@@ -606,7 +606,7 @@ test_memzone_reserve_max_aligned(void) + + if (mz->len < minlen || mz->len > maxlen) { + printf("Memzone reserve with 0 size and alignment %u did not return" +- " bigest block\n", align); ++ " biggest block\n", align); + printf("Expected size = %zu-%zu, actual size = %zu\n", + minlen, maxlen, mz->len); + rte_dump_physmem_layout(stdout); +@@ -1054,7 +1054,7 @@ test_memzone_basic(void) + if (mz != memzone1) + return -1; + +- printf("test duplcate zone name\n"); ++ printf("test duplicate zone name\n"); + mz = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone1"), 100, + SOCKET_ID_ANY, 0); + if (mz != NULL) +diff --git a/app/test/test_metrics.c b/app/test/test_metrics.c +index e736019ae4..11222133d0 100644 +--- a/app/test/test_metrics.c ++++ b/app/test/test_metrics.c +@@ -121,7 +121,7 @@ test_metrics_update_value(void) + err = rte_metrics_update_value(RTE_METRICS_GLOBAL, KEY, VALUE); + TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__); + +- /* Successful Test: Valid port_id otherthan RTE_METRICS_GLOBAL, key ++ /* Successful Test: Valid port_id other than RTE_METRICS_GLOBAL, key + * and value + */ + err = rte_metrics_update_value(9, KEY, VALUE); +diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c +index c2dbeaf603..34c5e12346 100644 +--- a/app/test/test_pcapng.c ++++ b/app/test/test_pcapng.c +@@ -109,7 +109,7 @@ test_setup(void) + return -1; + } + +- /* Make a pool for cloned packeets */ ++ /* Make a pool for cloned packets */ + mp = rte_pktmbuf_pool_create_by_ops("pcapng_test_pool", NUM_PACKETS, + 0, 0, + rte_pcapng_mbuf_size(pkt_len), +diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c +index 1a9549527e..4d013cd7bb 100644 +--- a/app/test/test_power_cpufreq.c ++++ b/app/test/test_power_cpufreq.c +@@ -659,7 +659,7 @@ test_power_cpufreq(void) + /* test of exit power management for an invalid lcore */ + ret = rte_power_exit(TEST_POWER_LCORE_INVALID); + if (ret == 0) { +- printf("Unpectedly exit power management successfully for " ++ printf("Unexpectedly exit power management successfully for " + "lcore %u\n", TEST_POWER_LCORE_INVALID); + rte_power_unset_env(); + return -1; +diff --git a/app/test/test_rcu_qsbr.c b/app/test/test_rcu_qsbr.c +index ab37a068cd..70404e89e6 100644 +--- a/app/test/test_rcu_qsbr.c ++++ b/app/test/test_rcu_qsbr.c +@@ -408,7 +408,7 @@ test_rcu_qsbr_synchronize_reader(void *arg) + + /* + * rte_rcu_qsbr_synchronize: Wait till all the reader threads have entered +- * the queiscent state. ++ * the quiescent state. + */ + static int + test_rcu_qsbr_synchronize(void) +@@ -443,7 +443,7 @@ test_rcu_qsbr_synchronize(void) + rte_rcu_qsbr_synchronize(t[0], RTE_MAX_LCORE - 1); + rte_rcu_qsbr_thread_offline(t[0], RTE_MAX_LCORE - 1); + +- /* Test if the API returns after unregisterng all the threads */ ++ /* Test if the API returns after unregistering all the threads */ + for (i = 0; i < RTE_MAX_LCORE; i++) + rte_rcu_qsbr_thread_unregister(t[0], i); + rte_rcu_qsbr_synchronize(t[0], RTE_QSBR_THRID_INVALID); +diff --git a/app/test/test_red.c b/app/test/test_red.c +index 05936cfee8..33a9f4ebb7 100644 +--- a/app/test/test_red.c ++++ b/app/test/test_red.c +@@ -1566,10 +1566,10 @@ static void ovfl_check_avg(uint32_t avg) + } + + static struct test_config ovfl_test1_config = { +- .ifname = "queue avergage overflow test interface", ++ .ifname = "queue average overflow test interface", + .msg = "overflow test 1 : use one RED configuration,\n" + " increase average queue size to target level,\n" +- " check maximum number of bits requirte_red to represent avg_s\n\n", ++ " check maximum number of bits required to represent avg_s\n\n", + .htxt = "avg queue size " + "wq_log2 " + "fraction bits " +@@ -1757,12 +1757,12 @@ test_invalid_parameters(void) + printf("%i: rte_red_config_init should have failed!\n", __LINE__); + return -1; + } +- /* min_treshold == max_treshold */ ++ /* min_threshold == max_threshold */ + if (rte_red_config_init(&config, 0, 1, 1, 0) == 0) { + printf("%i: rte_red_config_init should have failed!\n", __LINE__); + return -1; + } +- /* min_treshold > max_treshold */ ++ /* min_threshold > max_threshold */ + if (rte_red_config_init(&config, 0, 2, 1, 0) == 0) { + printf("%i: rte_red_config_init should have failed!\n", __LINE__); + return -1; +diff --git a/app/test/test_security.c b/app/test/test_security.c +index 060cf1ffa8..059731b65d 100644 +--- a/app/test/test_security.c ++++ b/app/test/test_security.c +@@ -237,7 +237,7 @@ + * increases .called counter. Function returns value stored in .ret field + * of the structure. + * In case of some parameters in some functions the expected value is unknown +- * and cannot be detrmined prior to call. Such parameters are stored ++ * and cannot be determined prior to call. Such parameters are stored + * in structure and can be compared or analyzed later in test case code. + * + * Below structures and functions follow the rules just described. +diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c +index aabf4375db..915c451fed 100644 +--- a/app/test/test_table_pipeline.c ++++ b/app/test/test_table_pipeline.c +@@ -364,7 +364,7 @@ setup_pipeline(int test_type) + .action = RTE_PIPELINE_ACTION_PORT, + {.port_id = port_out_id[i^1]}, + }; +- printf("Setting secont table to output to port\n"); ++ printf("Setting second table to output to port\n"); + + /* Add the default action for the table. */ + ret = rte_pipeline_table_default_entry_add(p, +diff --git a/app/test/test_thash.c b/app/test/test_thash.c +index a62530673f..62ba4a9528 100644 +--- a/app/test/test_thash.c ++++ b/app/test/test_thash.c +@@ -684,7 +684,7 @@ test_predictable_rss_multirange(void) + + /* + * calculate hashes, complements, then adjust keys with +- * complements and recalsulate hashes ++ * complements and recalculate hashes + */ + for (i = 0; i < RTE_DIM(rng_arr); i++) { + for (k = 0; k < 100; k++) { +diff --git a/buildtools/binutils-avx512-check.py b/buildtools/binutils-avx512-check.py +index a4e14f3593..57392ecdc8 100644 +--- a/buildtools/binutils-avx512-check.py ++++ b/buildtools/binutils-avx512-check.py +@@ -1,5 +1,5 @@ + #! /usr/bin/env python3 +-# SPDX-License-Identitifer: BSD-3-Clause ++# SPDX-License-Identifier: BSD-3-Clause + # Copyright(c) 2020 Intel Corporation + + import subprocess +diff --git a/devtools/check-symbol-change.sh b/devtools/check-symbol-change.sh +index 8fcd0ce1a1..8992214ac8 100755 +--- a/devtools/check-symbol-change.sh ++++ b/devtools/check-symbol-change.sh +@@ -25,7 +25,7 @@ build_map_changes() + + # Triggering this rule, which starts a line and ends it + # with a { identifies a versioned section. The section name is +- # the rest of the line with the + and { symbols remvoed. ++ # the rest of the line with the + and { symbols removed. + # Triggering this rule sets in_sec to 1, which actives the + # symbol rule below + /^.*{/ { +@@ -35,7 +35,7 @@ build_map_changes() + } + } + +- # This rule idenfies the end of a section, and disables the ++ # This rule identifies the end of a section, and disables the + # symbol rule + /.*}/ {in_sec=0} + +@@ -100,7 +100,7 @@ check_for_rule_violations() + # Just inform the user of this occurrence, but + # don't flag it as an error + echo -n "INFO: symbol $symname is added but " +- echo -n "patch has insuficient context " ++ echo -n "patch has insufficient context " + echo -n "to determine the section name " + echo -n "please ensure the version is " + echo "EXPERIMENTAL" +diff --git a/doc/guides/howto/img/virtio_user_for_container_networking.svg b/doc/guides/howto/img/virtio_user_for_container_networking.svg +index de80806649..dc9b318e7e 100644 +--- a/doc/guides/howto/img/virtio_user_for_container_networking.svg ++++ b/doc/guides/howto/img/virtio_user_for_container_networking.svg +@@ -465,7 +465,7 @@ + v:mID="63" + id="shape63-63">Sheet.63Contanier/AppContainer/Appoffse offset offse offset = 4.5.** + +- The mmaping of the iomem range of the PCI device fails for kernels that ++ The mmapping of the iomem range of the PCI device fails for kernels that + enabled the ``CONFIG_IO_STRICT_DEVMEM`` option. The error seen by the + user is as similar to the following:: + +diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst +index 25439dad45..1fd1755858 100644 +--- a/doc/guides/rel_notes/release_17_08.rst ++++ b/doc/guides/rel_notes/release_17_08.rst +@@ -232,7 +232,7 @@ API Changes + * The ``rte_cryptodev_configure()`` function does not create the session + mempool for the device anymore. + * The ``rte_cryptodev_queue_pair_attach_sym_session()`` and +- ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require ++ ``rte_cryptodev_queue_pair_detach_sym_session()`` functions require + the new parameter ``device id``. + * Parameters of ``rte_cryptodev_sym_session_create()`` were modified to + accept ``mempool``, instead of ``device id`` and ``rte_crypto_sym_xform``. +diff --git a/doc/guides/rel_notes/release_2_1.rst b/doc/guides/rel_notes/release_2_1.rst +index 35e6c88884..d0ad99ebce 100644 +--- a/doc/guides/rel_notes/release_2_1.rst ++++ b/doc/guides/rel_notes/release_2_1.rst +@@ -671,7 +671,7 @@ Resolved Issues + value 0. + + +- Fixes: 40b966a211ab ("ivshmem: library changes for mmaping using ivshmem") ++ Fixes: 40b966a211ab ("ivshmem: library changes for mmapping using ivshmem") + + + * **ixgbe/base: Fix SFP probing.** +diff --git a/doc/guides/sample_app_ug/ip_reassembly.rst b/doc/guides/sample_app_ug/ip_reassembly.rst +index 06289c2248..5280bf4ea0 100644 +--- a/doc/guides/sample_app_ug/ip_reassembly.rst ++++ b/doc/guides/sample_app_ug/ip_reassembly.rst +@@ -154,8 +154,8 @@ each RX queue uses its own mempool. + + .. literalinclude:: ../../../examples/ip_reassembly/main.c + :language: c +- :start-after: mbufs stored int the gragment table. 8< +- :end-before: >8 End of mbufs stored int the fragmentation table. ++ :start-after: mbufs stored in the fragment table. 8< ++ :end-before: >8 End of mbufs stored in the fragmentation table. + :dedent: 1 + + Packet Reassembly and Forwarding +diff --git a/doc/guides/sample_app_ug/l2_forward_cat.rst b/doc/guides/sample_app_ug/l2_forward_cat.rst +index 440642ef7c..3ada3575ba 100644 +--- a/doc/guides/sample_app_ug/l2_forward_cat.rst ++++ b/doc/guides/sample_app_ug/l2_forward_cat.rst +@@ -176,7 +176,7 @@ function. The value returned is the number of parsed arguments: + .. literalinclude:: ../../../examples/l2fwd-cat/l2fwd-cat.c + :language: c + :start-after: Initialize the Environment Abstraction Layer (EAL). 8< +- :end-before: >8 End of initializion the Environment Abstraction Layer (EAL). ++ :end-before: >8 End of initialization the Environment Abstraction Layer (EAL). + :dedent: 1 + + The next task is to initialize the PQoS library and configure CAT. The +diff --git a/doc/guides/sample_app_ug/server_node_efd.rst b/doc/guides/sample_app_ug/server_node_efd.rst +index 605eb09a61..c6cbc3def6 100644 +--- a/doc/guides/sample_app_ug/server_node_efd.rst ++++ b/doc/guides/sample_app_ug/server_node_efd.rst +@@ -191,7 +191,7 @@ flow is not handled by the node. + .. literalinclude:: ../../../examples/server_node_efd/node/node.c + :language: c + :start-after: Packets dequeued from the shared ring. 8< +- :end-before: >8 End of packets dequeueing. ++ :end-before: >8 End of packets dequeuing. + + Finally, note that both processes updates statistics, such as transmitted, received + and dropped packets, which are shown and refreshed by the server app. +diff --git a/doc/guides/sample_app_ug/skeleton.rst b/doc/guides/sample_app_ug/skeleton.rst +index 6d0de64401..08ddd7aa59 100644 +--- a/doc/guides/sample_app_ug/skeleton.rst ++++ b/doc/guides/sample_app_ug/skeleton.rst +@@ -54,7 +54,7 @@ function. The value returned is the number of parsed arguments: + .. literalinclude:: ../../../examples/skeleton/basicfwd.c + :language: c + :start-after: Initializion the Environment Abstraction Layer (EAL). 8< +- :end-before: >8 End of initializion the Environment Abstraction Layer (EAL). ++ :end-before: >8 End of initialization the Environment Abstraction Layer (EAL). + :dedent: 1 + + +diff --git a/doc/guides/sample_app_ug/vm_power_management.rst b/doc/guides/sample_app_ug/vm_power_management.rst +index 7160b6a63a..9ce87956c9 100644 +--- a/doc/guides/sample_app_ug/vm_power_management.rst ++++ b/doc/guides/sample_app_ug/vm_power_management.rst +@@ -681,7 +681,7 @@ The following is an example JSON string for a power management request. + "resource_id": 10 + }} + +-To query the available frequences of an lcore, use the query_cpu_freq command. ++To query the available frequencies of an lcore, use the query_cpu_freq command. + Where {core_num} is the lcore to query. + Before using this command, please enable responses via the set_query command on the host. + +diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +index 44228cd7d2..94792d88cc 100644 +--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst ++++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +@@ -3510,7 +3510,7 @@ Tunnel offload + Indicate tunnel offload rule type + + - ``tunnel_set {tunnel_id}``: mark rule as tunnel offload decap_set type. +-- ``tunnel_match {tunnel_id}``: mark rule as tunel offload match type. ++- ``tunnel_match {tunnel_id}``: mark rule as tunnel offload match type. + + Matching pattern + ^^^^^^^^^^^^^^^^ +diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +index 92decc3e05..21d35292a3 100644 +--- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c ++++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +@@ -2097,7 +2097,7 @@ dequeue_enc_one_op_cb(struct fpga_queue *q, struct rte_bbdev_enc_op **op, + rte_bbdev_log_debug("DMA response desc %p", desc); + + *op = desc->enc_req.op_addr; +- /* Check the decriptor error field, return 1 on error */ ++ /* Check the descriptor error field, return 1 on error */ + desc_error = check_desc_error(desc->enc_req.error); + (*op)->status = desc_error << RTE_BBDEV_DATA_ERROR; + +@@ -2139,7 +2139,7 @@ dequeue_enc_one_op_tb(struct fpga_queue *q, struct rte_bbdev_enc_op **op, + for (cb_idx = 0; cb_idx < cbs_in_op; ++cb_idx) { + desc = q->ring_addr + ((q->head_free_desc + desc_offset + + cb_idx) & q->sw_ring_wrap_mask); +- /* Check the decriptor error field, return 1 on error */ ++ /* Check the descriptor error field, return 1 on error */ + desc_error = check_desc_error(desc->enc_req.error); + status |= desc_error << RTE_BBDEV_DATA_ERROR; + rte_bbdev_log_debug("DMA response desc %p", desc); +@@ -2177,7 +2177,7 @@ dequeue_dec_one_op_cb(struct fpga_queue *q, struct rte_bbdev_dec_op **op, + (*op)->turbo_dec.iter_count = (desc->dec_req.iter + 2) >> 1; + /* crc_pass = 0 when decoder fails */ + (*op)->status = !(desc->dec_req.crc_pass) << RTE_BBDEV_CRC_ERROR; +- /* Check the decriptor error field, return 1 on error */ ++ /* Check the descriptor error field, return 1 on error */ + desc_error = check_desc_error(desc->enc_req.error); + (*op)->status |= desc_error << RTE_BBDEV_DATA_ERROR; + return 1; +@@ -2221,7 +2221,7 @@ dequeue_dec_one_op_tb(struct fpga_queue *q, struct rte_bbdev_dec_op **op, + iter_count = RTE_MAX(iter_count, (uint8_t) desc->dec_req.iter); + /* crc_pass = 0 when decoder fails, one fails all */ + status |= !(desc->dec_req.crc_pass) << RTE_BBDEV_CRC_ERROR; +- /* Check the decriptor error field, return 1 on error */ ++ /* Check the descriptor error field, return 1 on error */ + desc_error = check_desc_error(desc->enc_req.error); + status |= desc_error << RTE_BBDEV_DATA_ERROR; + rte_bbdev_log_debug("DMA response desc %p", desc); +diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c +index 753d920e18..08cff582b9 100644 +--- a/drivers/baseband/null/bbdev_null.c ++++ b/drivers/baseband/null/bbdev_null.c +@@ -31,7 +31,7 @@ struct bbdev_null_params { + uint16_t queues_num; /*< Null BBDEV queues number */ + }; + +-/* Accecptable params for null BBDEV devices */ ++/* Acceptable params for null BBDEV devices */ + #define BBDEV_NULL_MAX_NB_QUEUES_ARG "max_nb_queues" + #define BBDEV_NULL_SOCKET_ID_ARG "socket_id" + +diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c +index b234bb751a..c6b1eb8679 100644 +--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c ++++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c +@@ -61,7 +61,7 @@ struct turbo_sw_params { + uint16_t queues_num; /*< Turbo SW device queues number */ + }; + +-/* Accecptable params for Turbo SW devices */ ++/* Acceptable params for Turbo SW devices */ + #define TURBO_SW_MAX_NB_QUEUES_ARG "max_nb_queues" + #define TURBO_SW_SOCKET_ID_ARG "socket_id" + +diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c +index 737ac8d8c5..5546a9cb8d 100644 +--- a/drivers/bus/dpaa/dpaa_bus.c ++++ b/drivers/bus/dpaa/dpaa_bus.c +@@ -70,7 +70,7 @@ compare_dpaa_devices(struct rte_dpaa_device *dev1, + { + int comp = 0; + +- /* Segragating ETH from SEC devices */ ++ /* Segregating ETH from SEC devices */ + if (dev1->device_type > dev2->device_type) + comp = 1; + else if (dev1->device_type < dev2->device_type) +diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h +index 7ef2f3b2e3..9b63e559bc 100644 +--- a/drivers/bus/dpaa/include/fsl_qman.h ++++ b/drivers/bus/dpaa/include/fsl_qman.h +@@ -1353,7 +1353,7 @@ __rte_internal + int qman_irqsource_add(u32 bits); + + /** +- * qman_fq_portal_irqsource_add - samilar to qman_irqsource_add, but it ++ * qman_fq_portal_irqsource_add - similar to qman_irqsource_add, but it + * takes portal (fq specific) as input rather than using the thread affined + * portal. + */ +@@ -1416,7 +1416,7 @@ __rte_internal + struct qm_dqrr_entry *qman_dequeue(struct qman_fq *fq); + + /** +- * qman_dqrr_consume - Consume the DQRR entriy after volatile dequeue ++ * qman_dqrr_consume - Consume the DQRR entry after volatile dequeue + * @fq: Frame Queue on which the volatile dequeue command is issued + * @dq: DQRR entry to consume. This is the one which is provided by the + * 'qbman_dequeue' command. +@@ -2017,7 +2017,7 @@ int qman_create_cgr_to_dcp(struct qman_cgr *cgr, u32 flags, u16 dcp_portal, + * @cgr: the 'cgr' object to deregister + * + * "Unplugs" this CGR object from the portal affine to the cpu on which this API +- * is executed. This must be excuted on the same affine portal on which it was ++ * is executed. This must be executed on the same affine portal on which it was + * created. + */ + __rte_internal +diff --git a/drivers/bus/dpaa/include/fsl_usd.h b/drivers/bus/dpaa/include/fsl_usd.h +index dcf35e4adb..97279421ad 100644 +--- a/drivers/bus/dpaa/include/fsl_usd.h ++++ b/drivers/bus/dpaa/include/fsl_usd.h +@@ -40,7 +40,7 @@ struct dpaa_raw_portal { + /* Specifies the stash request queue this portal should use */ + uint8_t sdest; + +- /* Specifes a specific portal index to map or QBMAN_ANY_PORTAL_IDX ++ /* Specifies a specific portal index to map or QBMAN_ANY_PORTAL_IDX + * for don't care. The portal index will be populated by the + * driver when the ioctl() successfully completes. + */ +diff --git a/drivers/bus/dpaa/include/process.h b/drivers/bus/dpaa/include/process.h +index a922988607..48d6b5693f 100644 +--- a/drivers/bus/dpaa/include/process.h ++++ b/drivers/bus/dpaa/include/process.h +@@ -49,7 +49,7 @@ struct dpaa_portal_map { + struct dpaa_ioctl_portal_map { + /* Input parameter, is a qman or bman portal required. */ + enum dpaa_portal_type type; +- /* Specifes a specific portal index to map or 0xffffffff ++ /* Specifies a specific portal index to map or 0xffffffff + * for don't care. + */ + uint32_t index; +diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c +index a0ef24cdc8..53fd75539e 100644 +--- a/drivers/bus/fslmc/fslmc_bus.c ++++ b/drivers/bus/fslmc/fslmc_bus.c +@@ -539,7 +539,7 @@ rte_fslmc_driver_unregister(struct rte_dpaa2_driver *driver) + + fslmc_bus = driver->fslmc_bus; + +- /* Cleanup the PA->VA Translation table; From whereever this function ++ /* Cleanup the PA->VA Translation table; From wherever this function + * is called from. + */ + if (rte_eal_iova_mode() == RTE_IOVA_PA) +diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +index 2210a0fa4a..52605ea2c3 100644 +--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c ++++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +@@ -178,7 +178,7 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev) + dpio_epoll_fd = epoll_create(1); + ret = rte_dpaa2_intr_enable(dpio_dev->intr_handle, 0); + if (ret) { +- DPAA2_BUS_ERR("Interrupt registeration failed"); ++ DPAA2_BUS_ERR("Interrupt registration failed"); + return -1; + } + +diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +index b1bba1ac36..957fc62d4c 100644 +--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h ++++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +@@ -156,7 +156,7 @@ struct dpaa2_queue { + struct rte_cryptodev_data *crypto_data; + }; + uint32_t fqid; /*!< Unique ID of this queue */ +- uint16_t flow_id; /*!< To be used by DPAA2 frmework */ ++ uint16_t flow_id; /*!< To be used by DPAA2 framework */ + uint8_t tc_index; /*!< traffic class identifier */ + uint8_t cgid; /*! < Congestion Group id for this queue */ + uint64_t rx_pkts; +diff --git a/drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h b/drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +index eb68c9cab5..5375ea386d 100644 +--- a/drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h ++++ b/drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +@@ -510,7 +510,7 @@ int qbman_result_has_new_result(struct qbman_swp *s, + struct qbman_result *dq); + + /** +- * qbman_check_command_complete() - Check if the previous issued dq commnd ++ * qbman_check_command_complete() - Check if the previous issued dq command + * is completed and results are available in memory. + * @s: the software portal object. + * @dq: the dequeue result read from the memory. +@@ -687,7 +687,7 @@ uint16_t qbman_result_DQ_seqnum(const struct qbman_result *dq); + + /** + * qbman_result_DQ_odpid() - Get the seqnum field in dequeue response +- * odpid is valid only if ODPVAILD flag is TRUE. ++ * odpid is valid only if ODPVALID flag is TRUE. + * @dq: the dequeue result. + * + * Return odpid. +@@ -743,7 +743,7 @@ const struct qbman_fd *qbman_result_DQ_fd(const struct qbman_result *dq); + * qbman_result_SCN_state() - Get the state field in State-change notification + * @scn: the state change notification. + * +- * Return the state in the notifiation. ++ * Return the state in the notification. + */ + __rte_internal + uint8_t qbman_result_SCN_state(const struct qbman_result *scn); +@@ -825,7 +825,7 @@ uint64_t qbman_result_bpscn_ctx(const struct qbman_result *scn); + + /* Parsing CGCU */ + /** +- * qbman_result_cgcu_cgid() - Check CGCU resouce id, i.e. cgid ++ * qbman_result_cgcu_cgid() - Check CGCU resource id, i.e. cgid + * @scn: the state change notification. + * + * Return the CGCU resource id. +@@ -903,14 +903,14 @@ void qbman_eq_desc_clear(struct qbman_eq_desc *d); + __rte_internal + void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *d, int respond_success); + /** +- * qbman_eq_desc_set_orp() - Set order-resotration in the enqueue descriptor ++ * qbman_eq_desc_set_orp() - Set order-restoration in the enqueue descriptor + * @d: the enqueue descriptor. + * @response_success: 1 = enqueue with response always; 0 = enqueue with + * rejections returned on a FQ. + * @opr_id: the order point record id. + * @seqnum: the order restoration sequence number. +- * @incomplete: indiates whether this is the last fragments using the same +- * sequeue number. ++ * @incomplete: indicates whether this is the last fragments using the same ++ * sequence number. + */ + __rte_internal + void qbman_eq_desc_set_orp(struct qbman_eq_desc *d, int respond_success, +@@ -1052,10 +1052,10 @@ __rte_internal + uint8_t qbman_result_eqresp_rspid(struct qbman_result *eqresp); + + /** +- * qbman_result_eqresp_rc() - determines if enqueue command is sucessful. ++ * qbman_result_eqresp_rc() - determines if enqueue command is successful. + * @eqresp: enqueue response. + * +- * Return 0 when command is sucessful. ++ * Return 0 when command is successful. + */ + __rte_internal + uint8_t qbman_result_eqresp_rc(struct qbman_result *eqresp); +@@ -1250,7 +1250,7 @@ int qbman_swp_fq_force(struct qbman_swp *s, uint32_t fqid); + /** + * These functions change the FQ flow-control stuff between XON/XOFF. (The + * default is XON.) This setting doesn't affect enqueues to the FQ, just +- * dequeues. XOFF FQs will remain in the tenatively-scheduled state, even when ++ * dequeues. XOFF FQs will remain in the tentatively-scheduled state, even when + * non-empty, meaning they won't be selected for scheduled dequeuing. If a FQ is + * changed to XOFF after it had already become truly-scheduled to a channel, and + * a pull dequeue of that channel occurs that selects that FQ for dequeuing, +diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c +index 1a5e7c2d2a..cd0d0b1670 100644 +--- a/drivers/bus/pci/linux/pci_vfio.c ++++ b/drivers/bus/pci/linux/pci_vfio.c +@@ -815,7 +815,7 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev) + continue; + } + +- /* skip non-mmapable BARs */ ++ /* skip non-mmappable BARs */ + if ((reg->flags & VFIO_REGION_INFO_FLAG_MMAP) == 0) { + free(reg); + continue; +diff --git a/drivers/bus/vdev/rte_bus_vdev.h b/drivers/bus/vdev/rte_bus_vdev.h +index 2856799953..5af6be009f 100644 +--- a/drivers/bus/vdev/rte_bus_vdev.h ++++ b/drivers/bus/vdev/rte_bus_vdev.h +@@ -197,7 +197,7 @@ rte_vdev_remove_custom_scan(rte_vdev_scan_callback callback, void *user_arg); + int rte_vdev_init(const char *name, const char *args); + + /** +- * Uninitalize a driver specified by name. ++ * Uninitialize a driver specified by name. + * + * @param name + * The pointer to a driver name to be uninitialized. +diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c +index 519ca9c6fe..367727367e 100644 +--- a/drivers/bus/vmbus/vmbus_common.c ++++ b/drivers/bus/vmbus/vmbus_common.c +@@ -134,7 +134,7 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr, + + /* + * If device class GUID matches, call the probe function of +- * registere drivers for the vmbus device. ++ * register drivers for the vmbus device. + * Return -1 if initialization failed, + * and 1 if no driver found for this device. + */ +diff --git a/drivers/common/cnxk/roc_bphy_cgx.c b/drivers/common/cnxk/roc_bphy_cgx.c +index 7449cbe77a..c3be3c9041 100644 +--- a/drivers/common/cnxk/roc_bphy_cgx.c ++++ b/drivers/common/cnxk/roc_bphy_cgx.c +@@ -14,7 +14,7 @@ + #define CGX_CMRX_INT_OVERFLW BIT_ULL(1) + /* + * CN10K stores number of lmacs in 4 bit filed +- * in contraty to CN9K which uses only 3 bits. ++ * in contrary to CN9K which uses only 3 bits. + * + * In theory masks should differ yet on CN9K + * bits beyond specified range contain zeros. +diff --git a/drivers/common/cnxk/roc_nix_bpf.c b/drivers/common/cnxk/roc_nix_bpf.c +index 6996a54be0..4941f62995 100644 +--- a/drivers/common/cnxk/roc_nix_bpf.c ++++ b/drivers/common/cnxk/roc_nix_bpf.c +@@ -138,7 +138,7 @@ nix_lf_bpf_dump(__io struct nix_band_prof_s *bpf) + { + plt_dump("W0: cir_mantissa \t\t\t%d\nW0: pebs_mantissa \t\t\t0x%03x", + bpf->cir_mantissa, bpf->pebs_mantissa); +- plt_dump("W0: peir_matissa \t\t\t\t%d\nW0: cbs_exponent \t\t\t%d", ++ plt_dump("W0: peir_mantissa \t\t\t\t%d\nW0: cbs_exponent \t\t\t%d", + bpf->peir_mantissa, bpf->cbs_exponent); + plt_dump("W0: cir_exponent \t\t\t%d\nW0: pebs_exponent \t\t\t%d", + bpf->cir_exponent, bpf->pebs_exponent); +diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c b/drivers/common/cnxk/roc_nix_tm_ops.c +index 3257fa67c7..3d81247a12 100644 +--- a/drivers/common/cnxk/roc_nix_tm_ops.c ++++ b/drivers/common/cnxk/roc_nix_tm_ops.c +@@ -107,7 +107,7 @@ nix_tm_adjust_shaper_pps_rate(struct nix_tm_shaper_profile *profile) + if (profile->peak.rate && min_rate > profile->peak.rate) + min_rate = profile->peak.rate; + +- /* Each packet accomulate single count, whereas HW ++ /* Each packet accumulate single count, whereas HW + * considers each unit as Byte, so we need convert + * user pps to bps + */ +diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c +index ba7f89b45b..82014a2ca0 100644 +--- a/drivers/common/cnxk/roc_npc_mcam.c ++++ b/drivers/common/cnxk/roc_npc_mcam.c +@@ -234,7 +234,7 @@ npc_get_kex_capability(struct npc *npc) + /* Ethtype: Offset 12B, len 2B */ + kex_cap.bit.ethtype_0 = npc_is_kex_enabled( + npc, NPC_LID_LA, NPC_LT_LA_ETHER, 12 * 8, 2 * 8); +- /* QINQ VLAN Ethtype: ofset 8B, len 2B */ ++ /* QINQ VLAN Ethtype: offset 8B, len 2B */ + kex_cap.bit.ethtype_x = npc_is_kex_enabled( + npc, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 8 * 8, 2 * 8); + /* VLAN ID0 : Outer VLAN: Offset 2B, len 2B */ +diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h +index 712302bc5c..74e0fb2ece 100644 +--- a/drivers/common/cnxk/roc_npc_priv.h ++++ b/drivers/common/cnxk/roc_npc_priv.h +@@ -363,7 +363,7 @@ struct npc { + uint32_t rss_grps; /* rss groups supported */ + uint16_t flow_prealloc_size; /* Pre allocated mcam size */ + uint16_t flow_max_priority; /* Max priority for flow */ +- uint16_t switch_header_type; /* Suppprted switch header type */ ++ uint16_t switch_header_type; /* Supported switch header type */ + uint32_t mark_actions; /* Number of mark actions */ + uint32_t vtag_strip_actions; /* vtag insert/strip actions */ + uint16_t pf_func; /* pf_func of device */ +diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h +index e015cf66a1..e1f2f6005d 100644 +--- a/drivers/common/cpt/cpt_ucode.h ++++ b/drivers/common/cpt/cpt_ucode.h +@@ -246,7 +246,7 @@ cpt_fc_ciph_set_key(struct cpt_ctx *cpt_ctx, cipher_type_t type, + if (cpt_ctx->fc_type == FC_GEN) { + /* + * We need to always say IV is from DPTR as user can +- * sometimes iverride IV per operation. ++ * sometimes override IV per operation. + */ + fctx->enc.iv_source = CPT_FROM_DPTR; + +@@ -3035,7 +3035,7 @@ prepare_iov_from_pkt_inplace(struct rte_mbuf *pkt, + tailroom = rte_pktmbuf_tailroom(pkt); + if (likely((headroom >= 24) && + (tailroom >= 8))) { +- /* In 83XX this is prerequivisit for Direct mode */ ++ /* In 83XX this is prerequisite for Direct mode */ + *flags |= SINGLE_BUF_HEADTAILROOM; + } + param->bufs[0].vaddr = seg_data; +diff --git a/drivers/common/cpt/cpt_ucode_asym.h b/drivers/common/cpt/cpt_ucode_asym.h +index a67ded642a..f0b5dddd8c 100644 +--- a/drivers/common/cpt/cpt_ucode_asym.h ++++ b/drivers/common/cpt/cpt_ucode_asym.h +@@ -779,7 +779,7 @@ cpt_ecdsa_verify_prep(struct rte_crypto_ecdsa_op_param *ecdsa, + * Set dlen = sum(sizeof(fpm address), ROUNDUP8(message len), + * ROUNDUP8(sign len(r and s), public key len(x and y coordinates), + * prime len, order len)). +- * Please note sign, public key and order can not excede prime length ++ * Please note sign, public key and order can not exceed prime length + * i.e. 6 * p_align + */ + dlen = sizeof(fpm_table_iova) + m_align + (8 * p_align); +diff --git a/drivers/common/dpaax/caamflib/desc/algo.h b/drivers/common/dpaax/caamflib/desc/algo.h +index 6bb915054a..e0848f0940 100644 +--- a/drivers/common/dpaax/caamflib/desc/algo.h ++++ b/drivers/common/dpaax/caamflib/desc/algo.h +@@ -67,7 +67,7 @@ cnstr_shdsc_zuce(uint32_t *descbuf, bool ps, bool swap, + * @authlen: size of digest + * + * The IV prepended before hmac payload must be 8 bytes consisting +- * of COUNT||BEAERER||DIR. The COUNT is of 32-bits, bearer is of 5 bits and ++ * of COUNT||BEARER||DIR. The COUNT is of 32-bits, bearer is of 5 bits and + * direction is of 1 bit - totalling to 38 bits. + * + * Return: size of descriptor written in words or negative number on error +diff --git a/drivers/common/dpaax/caamflib/desc/sdap.h b/drivers/common/dpaax/caamflib/desc/sdap.h +index b2497a5424..07f55b5b40 100644 +--- a/drivers/common/dpaax/caamflib/desc/sdap.h ++++ b/drivers/common/dpaax/caamflib/desc/sdap.h +@@ -492,10 +492,10 @@ pdcp_sdap_insert_snoop_op(struct program *p, bool swap __maybe_unused, + + /* Set the variable size of data the register will write */ + if (dir == OP_TYPE_ENCAP_PROTOCOL) { +- /* We will add the interity data so add its length */ ++ /* We will add the integrity data so add its length */ + MATHI(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2); + } else { +- /* We will check the interity data so remove its length */ ++ /* We will check the integrity data so remove its length */ + MATHI(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2); + /* Do not take the ICV in the out-snooping configuration */ + MATHI(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQINSZ, 4, IMMED2); +@@ -803,7 +803,7 @@ static inline int pdcp_sdap_insert_no_snoop_op( + CLRW_CLR_C1MODE, + CLRW, 0, 4, IMMED); + +- /* Load the key for authentcation */ ++ /* Load the key for authentication */ + KEY(p, KEY1, authdata->key_enc_flags, authdata->key, + authdata->keylen, INLINE_KEY(authdata)); + +diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax/dpaax_iova_table.c +index 3d661102cc..9daac4bc03 100644 +--- a/drivers/common/dpaax/dpaax_iova_table.c ++++ b/drivers/common/dpaax/dpaax_iova_table.c +@@ -261,7 +261,7 @@ dpaax_iova_table_depopulate(void) + rte_free(dpaax_iova_table_p->entries); + dpaax_iova_table_p = NULL; + +- DPAAX_DEBUG("IOVA Table cleanedup"); ++ DPAAX_DEBUG("IOVA Table cleaned"); + } + + int +diff --git a/drivers/common/iavf/iavf_type.h b/drivers/common/iavf/iavf_type.h +index 51267ca3b3..1cd87587d6 100644 +--- a/drivers/common/iavf/iavf_type.h ++++ b/drivers/common/iavf/iavf_type.h +@@ -1006,7 +1006,7 @@ struct iavf_profile_tlv_section_record { + u8 data[12]; + }; + +-/* Generic AQ section in proflie */ ++/* Generic AQ section in profile */ + struct iavf_profile_aq_section { + u16 opcode; + u16 flags; +diff --git a/drivers/common/iavf/virtchnl.h b/drivers/common/iavf/virtchnl.h +index 269578f7c0..80e754a1b2 100644 +--- a/drivers/common/iavf/virtchnl.h ++++ b/drivers/common/iavf/virtchnl.h +@@ -233,7 +233,7 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode) + case VIRTCHNL_OP_DCF_CMD_DESC: + return "VIRTCHNL_OP_DCF_CMD_DESC"; + case VIRTCHNL_OP_DCF_CMD_BUFF: +- return "VIRTCHHNL_OP_DCF_CMD_BUFF"; ++ return "VIRTCHNL_OP_DCF_CMD_BUFF"; + case VIRTCHNL_OP_DCF_DISABLE: + return "VIRTCHNL_OP_DCF_DISABLE"; + case VIRTCHNL_OP_DCF_GET_VSI_MAP: +diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c +index f1650f94c6..cc13022150 100644 +--- a/drivers/common/mlx5/mlx5_common.c ++++ b/drivers/common/mlx5/mlx5_common.c +@@ -854,7 +854,7 @@ static void mlx5_common_driver_init(void) + static bool mlx5_common_initialized; + + /** +- * One time innitialization routine for run-time dependency on glue library ++ * One time initialization routine for run-time dependency on glue library + * for multiple PMDs. Each mlx5 PMD that depends on mlx5_common module, + * must invoke in its constructor. + */ +diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c +index c694aaf28c..1537b5d428 100644 +--- a/drivers/common/mlx5/mlx5_common_mr.c ++++ b/drivers/common/mlx5/mlx5_common_mr.c +@@ -1541,7 +1541,7 @@ mlx5_mempool_reg_create(struct rte_mempool *mp, unsigned int mrs_n, + * Destroy a mempool registration object. + * + * @param standalone +- * Whether @p mpr owns its MRs excludively, i.e. they are not shared. ++ * Whether @p mpr owns its MRs exclusively, i.e. they are not shared. + */ + static void + mlx5_mempool_reg_destroy(struct mlx5_mr_share_cache *share_cache, +diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c +index e52b995ee3..7cd3d4fa98 100644 +--- a/drivers/common/mlx5/mlx5_devx_cmds.c ++++ b/drivers/common/mlx5/mlx5_devx_cmds.c +@@ -1822,7 +1822,7 @@ mlx5_devx_cmd_create_td(void *ctx) + * Pointer to file stream. + * + * @return +- * 0 on success, a nagative value otherwise. ++ * 0 on success, a negative value otherwise. + */ + int + mlx5_devx_cmd_flow_dump(void *fdb_domain __rte_unused, +diff --git a/drivers/common/mlx5/mlx5_malloc.c b/drivers/common/mlx5/mlx5_malloc.c +index b19501e1bc..cef3b88e11 100644 +--- a/drivers/common/mlx5/mlx5_malloc.c ++++ b/drivers/common/mlx5/mlx5_malloc.c +@@ -58,7 +58,7 @@ static struct mlx5_sys_mem mlx5_sys_mem = { + * Check if the address belongs to memory seg list. + * + * @param addr +- * Memory address to be ckeced. ++ * Memory address to be checked. + * @param msl + * Memory seg list. + * +@@ -109,7 +109,7 @@ mlx5_mem_update_msl(void *addr) + * Check if the address belongs to rte memory. + * + * @param addr +- * Memory address to be ckeced. ++ * Memory address to be checked. + * + * @return + * True if it belongs, false otherwise. +diff --git a/drivers/common/mlx5/mlx5_malloc.h b/drivers/common/mlx5/mlx5_malloc.h +index 74b7eeb26e..92149f7b92 100644 +--- a/drivers/common/mlx5/mlx5_malloc.h ++++ b/drivers/common/mlx5/mlx5_malloc.h +@@ -19,7 +19,7 @@ extern "C" { + + enum mlx5_mem_flags { + MLX5_MEM_ANY = 0, +- /* Memory will be allocated dpends on sys_mem_en. */ ++ /* Memory will be allocated depends on sys_mem_en. */ + MLX5_MEM_SYS = 1 << 0, + /* Memory should be allocated from system. */ + MLX5_MEM_RTE = 1 << 1, +diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h +index 2ded67e85e..982a53ffbe 100644 +--- a/drivers/common/mlx5/mlx5_prm.h ++++ b/drivers/common/mlx5/mlx5_prm.h +@@ -4172,7 +4172,7 @@ mlx5_flow_mark_get(uint32_t val) + * timestamp format supported by the queue. + * + * @return +- * Converted timstamp format settings. ++ * Converted timestamp format settings. + */ + static inline uint32_t + mlx5_ts_format_conv(uint32_t ts_format) +diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c +index 162c7476cc..c3cfc315f2 100644 +--- a/drivers/common/mlx5/windows/mlx5_common_os.c ++++ b/drivers/common/mlx5/windows/mlx5_common_os.c +@@ -302,7 +302,7 @@ mlx5_os_umem_dereg(void *pumem) + } + + /** +- * Register mr. Given protection doamin pointer, pointer to addr and length ++ * Register mr. Given protection domain pointer, pointer to addr and length + * register the memory region. + * + * @param[in] pd +@@ -310,7 +310,7 @@ mlx5_os_umem_dereg(void *pumem) + * @param[in] addr + * Pointer to memory start address (type devx_device_ctx). + * @param[in] length +- * Lengtoh of the memory to register. ++ * Length of the memory to register. + * @param[out] pmd_mr + * pmd_mr struct set with lkey, address, length, pointer to mr object, mkey + * +diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h +index 3afce56cd9..61fc8dd761 100644 +--- a/drivers/common/mlx5/windows/mlx5_common_os.h ++++ b/drivers/common/mlx5/windows/mlx5_common_os.h +@@ -21,7 +21,7 @@ + /** + * This API allocates aligned or non-aligned memory. The free can be on either + * aligned or nonaligned memory. To be protected - even though there may be no +- * alignment - in Windows this API will unconditioanlly call _aligned_malloc() ++ * alignment - in Windows this API will unconditionally call _aligned_malloc() + * with at least a minimal alignment size. + * + * @param[in] align +diff --git a/drivers/common/qat/qat_adf/adf_transport_access_macros.h b/drivers/common/qat/qat_adf/adf_transport_access_macros.h +index a6d403fac3..12a7258c60 100644 +--- a/drivers/common/qat/qat_adf/adf_transport_access_macros.h ++++ b/drivers/common/qat/qat_adf/adf_transport_access_macros.h +@@ -72,7 +72,7 @@ + #define ADF_SIZE_TO_RING_SIZE_IN_BYTES(SIZE) ((1 << (SIZE - 1)) << 7) + #define ADF_RING_SIZE_IN_BYTES_TO_SIZE(SIZE) ((1 << (SIZE - 1)) >> 7) + +-/* Minimum ring bufer size for memory allocation */ ++/* Minimum ring buffer size for memory allocation */ + #define ADF_RING_SIZE_BYTES_MIN(SIZE) ((SIZE < ADF_RING_SIZE_4K) ? \ + ADF_RING_SIZE_4K : SIZE) + #define ADF_RING_SIZE_MODULO(SIZE) (SIZE + 0x6) +diff --git a/drivers/common/sfc_efx/efsys.h b/drivers/common/sfc_efx/efsys.h +index 3860c2835a..224254bee7 100644 +--- a/drivers/common/sfc_efx/efsys.h ++++ b/drivers/common/sfc_efx/efsys.h +@@ -616,7 +616,7 @@ typedef struct efsys_bar_s { + + #define EFSYS_DMA_SYNC_FOR_KERNEL(_esmp, _offset, _size) ((void)0) + +-/* Just avoid store and compiler (impliciltly) reordering */ ++/* Just avoid store and compiler (implicitly) reordering */ + #define EFSYS_DMA_SYNC_FOR_DEVICE(_esmp, _offset, _size) rte_wmb() + + /* TIMESTAMP */ +diff --git a/drivers/compress/octeontx/include/zip_regs.h b/drivers/compress/octeontx/include/zip_regs.h +index 96e538bb75..94a48cde66 100644 +--- a/drivers/compress/octeontx/include/zip_regs.h ++++ b/drivers/compress/octeontx/include/zip_regs.h +@@ -195,7 +195,7 @@ union zip_inst_s { + uint64_t bf : 1; + /** Comp/decomp operation */ + uint64_t op : 2; +- /** Data sactter */ ++ /** Data scatter */ + uint64_t ds : 1; + /** Data gather */ + uint64_t dg : 1; +@@ -376,7 +376,7 @@ union zip_inst_s { + uint64_t bf : 1; + /** Comp/decomp operation */ + uint64_t op : 2; +- /** Data sactter */ ++ /** Data scatter */ + uint64_t ds : 1; + /** Data gather */ + uint64_t dg : 1; +diff --git a/drivers/compress/octeontx/otx_zip.h b/drivers/compress/octeontx/otx_zip.h +index e43f7f5c3e..118a95d738 100644 +--- a/drivers/compress/octeontx/otx_zip.h ++++ b/drivers/compress/octeontx/otx_zip.h +@@ -31,7 +31,7 @@ extern int octtx_zip_logtype_driver; + /**< PCI device id of ZIP VF */ + #define PCI_DEVICE_ID_OCTEONTX_ZIPVF 0xA037 + +-/* maxmum number of zip vf devices */ ++/* maximum number of zip vf devices */ + #define ZIP_MAX_VFS 8 + + /* max size of one chunk */ +diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c +index 9b24d46e97..da6404c017 100644 +--- a/drivers/compress/qat/qat_comp_pmd.c ++++ b/drivers/compress/qat/qat_comp_pmd.c +@@ -463,7 +463,7 @@ qat_comp_create_stream_pool(struct qat_comp_dev_private *comp_dev, + } else if (info.error) { + rte_mempool_obj_iter(mp, qat_comp_stream_destroy, NULL); + QAT_LOG(ERR, +- "Destoying mempool %s as at least one element failed initialisation", ++ "Destroying mempool %s as at least one element failed initialisation", + stream_pool_name); + rte_mempool_free(mp); + mp = NULL; +diff --git a/drivers/crypto/bcmfs/bcmfs_device.h b/drivers/crypto/bcmfs/bcmfs_device.h +index e5ca866977..4901a6cfd9 100644 +--- a/drivers/crypto/bcmfs/bcmfs_device.h ++++ b/drivers/crypto/bcmfs/bcmfs_device.h +@@ -32,7 +32,7 @@ enum bcmfs_device_type { + BCMFS_UNKNOWN + }; + +-/* A table to store registered queue pair opertations */ ++/* A table to store registered queue pair operations */ + struct bcmfs_hw_queue_pair_ops_table { + rte_spinlock_t tl; + /* Number of used ops structs in the table. */ +diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c +index cb5ff6c61b..61d457f4e0 100644 +--- a/drivers/crypto/bcmfs/bcmfs_qp.c ++++ b/drivers/crypto/bcmfs/bcmfs_qp.c +@@ -212,7 +212,7 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr, + nb_descriptors = FS_RM_MAX_REQS; + + if (qp_conf->iobase == NULL) { +- BCMFS_LOG(ERR, "IO onfig space null"); ++ BCMFS_LOG(ERR, "IO config space null"); + return -EINVAL; + } + +diff --git a/drivers/crypto/bcmfs/bcmfs_sym_defs.h b/drivers/crypto/bcmfs/bcmfs_sym_defs.h +index eaefe97e26..9bb8a695a0 100644 +--- a/drivers/crypto/bcmfs/bcmfs_sym_defs.h ++++ b/drivers/crypto/bcmfs/bcmfs_sym_defs.h +@@ -20,11 +20,11 @@ struct bcmfs_sym_request; + + /** Crypto Request processing successful. */ + #define BCMFS_SYM_RESPONSE_SUCCESS (0) +-/** Crypot Request processing protocol failure. */ ++/** Crypto Request processing protocol failure. */ + #define BCMFS_SYM_RESPONSE_PROTO_FAILURE (1) +-/** Crypot Request processing completion failure. */ ++/** Crypto Request processing completion failure. */ + #define BCMFS_SYM_RESPONSE_COMPL_ERROR (2) +-/** Crypot Request processing hash tag check error. */ ++/** Crypto Request processing hash tag check error. */ + #define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR (3) + + /** Maximum threshold length to adjust AAD in continuation +diff --git a/drivers/crypto/bcmfs/bcmfs_sym_engine.h b/drivers/crypto/bcmfs/bcmfs_sym_engine.h +index d9594246b5..51ff9f75ed 100644 +--- a/drivers/crypto/bcmfs/bcmfs_sym_engine.h ++++ b/drivers/crypto/bcmfs/bcmfs_sym_engine.h +@@ -12,7 +12,7 @@ + #include "bcmfs_sym_defs.h" + #include "bcmfs_sym_req.h" + +-/* structure to hold element's arrtibutes */ ++/* structure to hold element's attributes */ + struct fsattr { + void *va; + uint64_t pa; +diff --git a/drivers/crypto/bcmfs/hw/bcmfs5_rm.c b/drivers/crypto/bcmfs/hw/bcmfs5_rm.c +index 86e53051dd..c677c0cd9b 100644 +--- a/drivers/crypto/bcmfs/hw/bcmfs5_rm.c ++++ b/drivers/crypto/bcmfs/hw/bcmfs5_rm.c +@@ -441,7 +441,7 @@ static void bcmfs5_write_doorbell(struct bcmfs_qp *qp) + { + struct bcmfs_queue *txq = &qp->tx_q; + +- /* sync in bfeore ringing the door-bell */ ++ /* sync in before ringing the door-bell */ + rte_wmb(); + + FS_MMIO_WRITE32(txq->descs_inflight, +diff --git a/drivers/crypto/caam_jr/caam_jr_hw_specific.h b/drivers/crypto/caam_jr/caam_jr_hw_specific.h +index bbe8bc3f90..6ee7f7cef3 100644 +--- a/drivers/crypto/caam_jr/caam_jr_hw_specific.h ++++ b/drivers/crypto/caam_jr/caam_jr_hw_specific.h +@@ -376,7 +376,7 @@ struct sec_job_ring_t { + void *register_base_addr; /* Base address for SEC's + * register memory for this job ring. + */ +- uint8_t coalescing_en; /* notifies if coelescing is ++ uint8_t coalescing_en; /* notifies if coalescing is + * enabled for the job ring + */ + sec_job_ring_state_t jr_state; /* The state of this job ring */ +@@ -479,7 +479,7 @@ void hw_job_ring_error_print(struct sec_job_ring_t *job_ring, int code); + + /* @brief Set interrupt coalescing parameters on the Job Ring. + * @param [in] job_ring The job ring +- * @param [in] irq_coalesing_timer Interrupt coalescing timer threshold. ++ * @param [in] irq_coalescing_timer Interrupt coalescing timer threshold. + * This value determines the maximum + * amount of time after processing a + * descriptor before raising an interrupt. +diff --git a/drivers/crypto/caam_jr/caam_jr_pvt.h b/drivers/crypto/caam_jr/caam_jr_pvt.h +index 552d6b9b1b..52f872bcd0 100644 +--- a/drivers/crypto/caam_jr/caam_jr_pvt.h ++++ b/drivers/crypto/caam_jr/caam_jr_pvt.h +@@ -169,7 +169,7 @@ struct sec4_sg_entry { + + /* Structure encompassing a job descriptor which is to be processed + * by SEC. User should also initialise this structure with the callback +- * function pointer which will be called by driver after recieving proccessed ++ * function pointer which will be called by driver after receiving processed + * descriptor from SEC. User data is also passed in this data structure which + * will be sent as an argument to the user callback function. + */ +@@ -288,7 +288,7 @@ int caam_jr_enable_irqs(int uio_fd); + * value that indicates an IRQ disable action into UIO file descriptor + * of this job ring. + * +- * @param [in] uio_fd UIO File descripto ++ * @param [in] uio_fd UIO File descriptor + * @retval 0 for success + * @retval -1 value for error + * +diff --git a/drivers/crypto/caam_jr/caam_jr_uio.c b/drivers/crypto/caam_jr/caam_jr_uio.c +index e4ee102344..583ba3b523 100644 +--- a/drivers/crypto/caam_jr/caam_jr_uio.c ++++ b/drivers/crypto/caam_jr/caam_jr_uio.c +@@ -227,7 +227,7 @@ caam_jr_enable_irqs(int uio_fd) + * value that indicates an IRQ disable action into UIO file descriptor + * of this job ring. + * +- * @param [in] uio_fd UIO File descripto ++ * @param [in] uio_fd UIO File descriptor + * @retval 0 for success + * @retval -1 value for error + * +diff --git a/drivers/crypto/ccp/ccp_crypto.c b/drivers/crypto/ccp/ccp_crypto.c +index 70daed791e..4ed91a7436 100644 +--- a/drivers/crypto/ccp/ccp_crypto.c ++++ b/drivers/crypto/ccp/ccp_crypto.c +@@ -1299,7 +1299,7 @@ ccp_auth_slot(struct ccp_session *session) + case CCP_AUTH_ALGO_SHA512_HMAC: + /** + * 1. Load PHash1 = H(k ^ ipad); to LSB +- * 2. generate IHash = H(hash on meassage with PHash1 ++ * 2. generate IHash = H(hash on message with PHash1 + * as init values); + * 3. Retrieve IHash 2 slots for 384/512 + * 4. Load Phash2 = H(k ^ opad); to LSB +diff --git a/drivers/crypto/ccp/ccp_crypto.h b/drivers/crypto/ccp/ccp_crypto.h +index 8e6d03efc8..d307f73ee4 100644 +--- a/drivers/crypto/ccp/ccp_crypto.h ++++ b/drivers/crypto/ccp/ccp_crypto.h +@@ -70,7 +70,7 @@ + /* Maximum length for digest */ + #define DIGEST_LENGTH_MAX 64 + +-/* SHA LSB intialiazation values */ ++/* SHA LSB initialization values */ + + #define SHA1_H0 0x67452301UL + #define SHA1_H1 0xefcdab89UL +diff --git a/drivers/crypto/ccp/ccp_dev.h b/drivers/crypto/ccp/ccp_dev.h +index 85c8fc47a2..2a205cd446 100644 +--- a/drivers/crypto/ccp/ccp_dev.h ++++ b/drivers/crypto/ccp/ccp_dev.h +@@ -19,7 +19,7 @@ + #include + #include + +-/**< CCP sspecific */ ++/**< CCP specific */ + #define MAX_HW_QUEUES 5 + #define CCP_MAX_TRNG_RETRIES 10 + #define CCP_ALIGN(x, y) ((((x) + (y - 1)) / y) * y) +diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c +index a552e64506..f20acdd123 100644 +--- a/drivers/crypto/dpaa_sec/dpaa_sec.c ++++ b/drivers/crypto/dpaa_sec/dpaa_sec.c +@@ -723,7 +723,7 @@ dpaa_sec_deq(struct dpaa_sec_qp *qp, struct rte_crypto_op **ops, int nb_ops) + } + ops[pkts++] = op; + +- /* report op status to sym->op and then free the ctx memeory */ ++ /* report op status to sym->op and then free the ctx memory */ + rte_mempool_put(ctx->ctx_pool, (void *)ctx); + + qman_dqrr_consume(fq, dq); +diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c +index 20b288334a..27604459e4 100644 +--- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c ++++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c +@@ -296,7 +296,7 @@ cpt_vq_init(struct cpt_vf *cptvf, uint8_t group) + /* CPT VF device initialization */ + otx_cpt_vfvq_init(cptvf); + +- /* Send msg to PF to assign currnet Q to required group */ ++ /* Send msg to PF to assign current Q to required group */ + cptvf->vfgrp = group; + err = otx_cpt_send_vf_grp_msg(cptvf, group); + if (err) { +diff --git a/drivers/crypto/octeontx/otx_cryptodev_mbox.h b/drivers/crypto/octeontx/otx_cryptodev_mbox.h +index 508f3afd47..c1eedc1b9e 100644 +--- a/drivers/crypto/octeontx/otx_cryptodev_mbox.h ++++ b/drivers/crypto/octeontx/otx_cryptodev_mbox.h +@@ -70,7 +70,7 @@ void + otx_cpt_handle_mbox_intr(struct cpt_vf *cptvf); + + /* +- * Checks if VF is able to comminicate with PF ++ * Checks if VF is able to communicate with PF + * and also gets the CPT number this VF is associated to. + */ + int +diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c +index 9e8fd495cf..f7ca8a8a8e 100644 +--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c ++++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c +@@ -558,7 +558,7 @@ otx_cpt_enq_single_sym(struct cpt_instance *instance, + &mdata, (void **)&prep_req); + + if (unlikely(ret)) { +- CPT_LOG_DP_ERR("prep cryto req : op %p, cpt_op 0x%x " ++ CPT_LOG_DP_ERR("prep crypto req : op %p, cpt_op 0x%x " + "ret 0x%x", op, (unsigned int)cpt_op, ret); + return NULL; + } +diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c +index f893508030..09d8761c5f 100644 +--- a/drivers/crypto/qat/qat_asym.c ++++ b/drivers/crypto/qat/qat_asym.c +@@ -109,7 +109,7 @@ static void qat_clear_arrays_by_alg(struct qat_asym_op_cookie *cookie, + static int qat_asym_check_nonzero(rte_crypto_param n) + { + if (n.length < 8) { +- /* Not a case for any cryptograpic function except for DH ++ /* Not a case for any cryptographic function except for DH + * generator which very often can be of one byte length + */ + size_t i; +diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c +index 93b257522b..00ec703754 100644 +--- a/drivers/crypto/qat/qat_sym.c ++++ b/drivers/crypto/qat/qat_sym.c +@@ -419,7 +419,7 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, + ICP_QAT_HW_AUTH_ALGO_AES_CBC_MAC) { + + /* In case of AES-CCM this may point to user selected +- * memory or iv offset in cypto_op ++ * memory or iv offset in crypto_op + */ + uint8_t *aad_data = op->sym->aead.aad.data; + /* This is true AAD length, it not includes 18 bytes of +diff --git a/drivers/crypto/virtio/virtqueue.h b/drivers/crypto/virtio/virtqueue.h +index bf10c6579b..c96ca62992 100644 +--- a/drivers/crypto/virtio/virtqueue.h ++++ b/drivers/crypto/virtio/virtqueue.h +@@ -145,7 +145,7 @@ virtqueue_notify(struct virtqueue *vq) + { + /* + * Ensure updated avail->idx is visible to host. +- * For virtio on IA, the notificaiton is through io port operation ++ * For virtio on IA, the notification is through io port operation + * which is a serialization instruction itself. + */ + VTPCI_OPS(vq->hw)->notify_queue(vq->hw, vq); +diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c +index d9e4f731d7..81cbdd286e 100644 +--- a/drivers/dma/skeleton/skeleton_dmadev.c ++++ b/drivers/dma/skeleton/skeleton_dmadev.c +@@ -169,7 +169,7 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc) + struct rte_ring *completed; + uint16_t i; + +- desc = rte_zmalloc_socket("dma_skelteon_desc", ++ desc = rte_zmalloc_socket("dma_skeleton_desc", + nb_desc * sizeof(struct skeldma_desc), + RTE_CACHE_LINE_SIZE, hw->socket_id); + if (desc == NULL) { +diff --git a/drivers/event/cnxk/cnxk_eventdev_selftest.c b/drivers/event/cnxk/cnxk_eventdev_selftest.c +index 69c15b1d0a..2fe6467f88 100644 +--- a/drivers/event/cnxk/cnxk_eventdev_selftest.c ++++ b/drivers/event/cnxk/cnxk_eventdev_selftest.c +@@ -140,7 +140,7 @@ _eventdev_setup(int mode) + struct rte_event_dev_info info; + int i, ret; + +- /* Create and destrory pool for each test case to make it standalone */ ++ /* Create and destroy pool for each test case to make it standalone */ + eventdev_test_mempool = rte_pktmbuf_pool_create( + pool_name, MAX_EVENTS, 0, 0, 512, rte_socket_id()); + if (!eventdev_test_mempool) { +@@ -1543,7 +1543,7 @@ cnxk_sso_selftest(const char *dev_name) + cn9k_sso_set_rsrc(dev); + if (cnxk_sso_testsuite_run(dev_name)) + return rc; +- /* Verift dual ws mode. */ ++ /* Verify dual ws mode. */ + printf("Verifying CN9K Dual workslot mode\n"); + dev->dual_ws = 1; + cn9k_sso_set_rsrc(dev); +diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c +index 16e9764dbf..d75f12e382 100644 +--- a/drivers/event/dlb2/dlb2.c ++++ b/drivers/event/dlb2/dlb2.c +@@ -2145,7 +2145,7 @@ dlb2_event_queue_detach_ldb(struct dlb2_eventdev *dlb2, + } + + /* This is expected with eventdev API! +- * It blindly attemmpts to unmap all queues. ++ * It blindly attempts to unmap all queues. + */ + if (i == DLB2_MAX_NUM_QIDS_PER_LDB_CQ) { + DLB2_LOG_DBG("dlb2: ignoring LB QID %d not mapped for qm_port %d.\n", +diff --git a/drivers/event/dlb2/dlb2_priv.h b/drivers/event/dlb2/dlb2_priv.h +index a5e2f8e46b..7837ae8733 100644 +--- a/drivers/event/dlb2/dlb2_priv.h ++++ b/drivers/event/dlb2/dlb2_priv.h +@@ -519,7 +519,7 @@ struct dlb2_eventdev_port { + bool setup_done; + /* enq_configured is set when the qm port is created */ + bool enq_configured; +- uint8_t implicit_release; /* release events before dequeueing */ ++ uint8_t implicit_release; /* release events before dequeuing */ + } __rte_cache_aligned; + + struct dlb2_queue { +diff --git a/drivers/event/dlb2/dlb2_selftest.c b/drivers/event/dlb2/dlb2_selftest.c +index 2113bc2c99..1863ffe049 100644 +--- a/drivers/event/dlb2/dlb2_selftest.c ++++ b/drivers/event/dlb2/dlb2_selftest.c +@@ -223,7 +223,7 @@ test_stop_flush(struct test *t) /* test to check we can properly flush events */ + 0, + RTE_EVENT_PORT_ATTR_DEQ_DEPTH, + &dequeue_depth)) { +- printf("%d: Error retrieveing dequeue depth\n", __LINE__); ++ printf("%d: Error retrieving dequeue depth\n", __LINE__); + goto err; + } + +diff --git a/drivers/event/dlb2/rte_pmd_dlb2.h b/drivers/event/dlb2/rte_pmd_dlb2.h +index 74399db018..1dbd885a16 100644 +--- a/drivers/event/dlb2/rte_pmd_dlb2.h ++++ b/drivers/event/dlb2/rte_pmd_dlb2.h +@@ -24,7 +24,7 @@ extern "C" { + * Selects the token pop mode for a DLB2 port. + */ + enum dlb2_token_pop_mode { +- /* Pop the CQ tokens immediately after dequeueing. */ ++ /* Pop the CQ tokens immediately after dequeuing. */ + AUTO_POP, + /* Pop CQ tokens after (dequeue_depth - 1) events are released. + * Supported on load-balanced ports only. +diff --git a/drivers/event/dpaa2/dpaa2_eventdev_selftest.c b/drivers/event/dpaa2/dpaa2_eventdev_selftest.c +index bbbd20951f..b549bdfcbb 100644 +--- a/drivers/event/dpaa2/dpaa2_eventdev_selftest.c ++++ b/drivers/event/dpaa2/dpaa2_eventdev_selftest.c +@@ -118,7 +118,7 @@ _eventdev_setup(int mode) + struct rte_event_dev_info info; + const char *pool_name = "evdev_dpaa2_test_pool"; + +- /* Create and destrory pool for each test case to make it standalone */ ++ /* Create and destroy pool for each test case to make it standalone */ + eventdev_test_mempool = rte_pktmbuf_pool_create(pool_name, + MAX_EVENTS, + 0 /*MBUF_CACHE_SIZE*/, +diff --git a/drivers/event/dsw/dsw_evdev.h b/drivers/event/dsw/dsw_evdev.h +index e64ae26f6e..c907c00c78 100644 +--- a/drivers/event/dsw/dsw_evdev.h ++++ b/drivers/event/dsw/dsw_evdev.h +@@ -24,7 +24,7 @@ + /* Multiple 24-bit flow ids will map to the same DSW-level flow. The + * number of DSW flows should be high enough make it unlikely that + * flow ids of several large flows hash to the same DSW-level flow. +- * Such collisions will limit parallism and thus the number of cores ++ * Such collisions will limit parallelism and thus the number of cores + * that may be utilized. However, configuring a large number of DSW + * flows might potentially, depending on traffic and actual + * application flow id value range, result in each such DSW-level flow +@@ -104,7 +104,7 @@ + /* Only one outstanding migration per port is allowed */ + #define DSW_MAX_PAUSED_FLOWS (DSW_MAX_PORTS*DSW_MAX_FLOWS_PER_MIGRATION) + +-/* Enough room for paus request/confirm and unpaus request/confirm for ++/* Enough room for pause request/confirm and unpaus request/confirm for + * all possible senders. + */ + #define DSW_CTL_IN_RING_SIZE ((DSW_MAX_PORTS-1)*4) +diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c +index c6ed470286..e209cd5b00 100644 +--- a/drivers/event/dsw/dsw_event.c ++++ b/drivers/event/dsw/dsw_event.c +@@ -1096,7 +1096,7 @@ dsw_port_ctl_process(struct dsw_evdev *dsw, struct dsw_port *port) + static void + dsw_port_note_op(struct dsw_port *port, uint16_t num_events) + { +- /* To pull the control ring reasonbly often on busy ports, ++ /* To pull the control ring reasonably often on busy ports, + * each dequeued/enqueued event is considered an 'op' too. + */ + port->ops_since_bg_task += (num_events+1); +@@ -1180,7 +1180,7 @@ dsw_event_enqueue_burst_generic(struct dsw_port *source_port, + * addition, a port cannot be left "unattended" (e.g. unused) + * for long periods of time, since that would stall + * migration. Eventdev API extensions to provide a cleaner way +- * to archieve both of these functions should be ++ * to archive both of these functions should be + * considered. + */ + if (unlikely(events_len == 0)) { +diff --git a/drivers/event/octeontx/ssovf_evdev.h b/drivers/event/octeontx/ssovf_evdev.h +index bb1056a955..e46dc055eb 100644 +--- a/drivers/event/octeontx/ssovf_evdev.h ++++ b/drivers/event/octeontx/ssovf_evdev.h +@@ -88,7 +88,7 @@ + + /* + * In Cavium OCTEON TX SoC, all accesses to the device registers are +- * implictly strongly ordered. So, The relaxed version of IO operation is ++ * implicitly strongly ordered. So, The relaxed version of IO operation is + * safe to use with out any IO memory barriers. + */ + #define ssovf_read64 rte_read64_relaxed +diff --git a/drivers/event/octeontx/ssovf_evdev_selftest.c b/drivers/event/octeontx/ssovf_evdev_selftest.c +index d7b0d22111..b55523632a 100644 +--- a/drivers/event/octeontx/ssovf_evdev_selftest.c ++++ b/drivers/event/octeontx/ssovf_evdev_selftest.c +@@ -151,7 +151,7 @@ _eventdev_setup(int mode) + struct rte_event_dev_info info; + const char *pool_name = "evdev_octeontx_test_pool"; + +- /* Create and destrory pool for each test case to make it standalone */ ++ /* Create and destroy pool for each test case to make it standalone */ + eventdev_test_mempool = rte_pktmbuf_pool_create(pool_name, + MAX_EVENTS, + 0 /*MBUF_CACHE_SIZE*/, +diff --git a/drivers/event/octeontx2/otx2_evdev_selftest.c b/drivers/event/octeontx2/otx2_evdev_selftest.c +index 48bfaf893d..a89637d60f 100644 +--- a/drivers/event/octeontx2/otx2_evdev_selftest.c ++++ b/drivers/event/octeontx2/otx2_evdev_selftest.c +@@ -139,7 +139,7 @@ _eventdev_setup(int mode) + struct rte_event_dev_info info; + int i, ret; + +- /* Create and destrory pool for each test case to make it standalone */ ++ /* Create and destroy pool for each test case to make it standalone */ + eventdev_test_mempool = rte_pktmbuf_pool_create(pool_name, MAX_EVENTS, + 0, 0, 512, + rte_socket_id()); +diff --git a/drivers/event/octeontx2/otx2_worker_dual.h b/drivers/event/octeontx2/otx2_worker_dual.h +index 36ae4dd88f..ca06d51c8a 100644 +--- a/drivers/event/octeontx2/otx2_worker_dual.h ++++ b/drivers/event/octeontx2/otx2_worker_dual.h +@@ -74,7 +74,7 @@ otx2_ssogws_dual_get_work(struct otx2_ssogws_state *ws, + event.flow_id, flags, lookup_mem); + /* Extracting tstamp, if PTP enabled. CGX will prepend + * the timestamp at starting of packet data and it can +- * be derieved from WQE 9 dword which corresponds to SG ++ * be derived from WQE 9 dword which corresponds to SG + * iova. + * rte_pktmbuf_mtod_offset can be used for this purpose + * but it brings down the performance as it reads +diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c +index 15c10240b0..8b6890b220 100644 +--- a/drivers/event/opdl/opdl_evdev.c ++++ b/drivers/event/opdl/opdl_evdev.c +@@ -703,7 +703,7 @@ opdl_probe(struct rte_vdev_device *vdev) + } + + PMD_DRV_LOG(INFO, "DEV_ID:[%02d] : " +- "Success - creating eventdev device %s, numa_node:[%d], do_valdation:[%s]" ++ "Success - creating eventdev device %s, numa_node:[%d], do_validation:[%s]" + " , self_test:[%s]\n", + dev->data->dev_id, + name, +diff --git a/drivers/event/opdl/opdl_test.c b/drivers/event/opdl/opdl_test.c +index e4fc70a440..24b92df476 100644 +--- a/drivers/event/opdl/opdl_test.c ++++ b/drivers/event/opdl/opdl_test.c +@@ -864,7 +864,7 @@ qid_basic(struct test *t) + } + + +- /* Start the devicea */ ++ /* Start the device */ + if (!err) { + if (rte_event_dev_start(evdev) < 0) { + PMD_DRV_LOG(ERR, "%s:%d: Error with start call\n", +diff --git a/drivers/event/sw/sw_evdev.h b/drivers/event/sw/sw_evdev.h +index 33645bd1df..4fd1054470 100644 +--- a/drivers/event/sw/sw_evdev.h ++++ b/drivers/event/sw/sw_evdev.h +@@ -180,7 +180,7 @@ struct sw_port { + uint16_t outstanding_releases __rte_cache_aligned; + uint16_t inflight_max; /* app requested max inflights for this port */ + uint16_t inflight_credits; /* num credits this port has right now */ +- uint8_t implicit_release; /* release events before dequeueing */ ++ uint8_t implicit_release; /* release events before dequeuing */ + + uint16_t last_dequeue_burst_sz; /* how big the burst was */ + uint64_t last_dequeue_ticks; /* used to track burst processing time */ +diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c +index 9768d3a0c7..cb97a4d615 100644 +--- a/drivers/event/sw/sw_evdev_selftest.c ++++ b/drivers/event/sw/sw_evdev_selftest.c +@@ -1109,7 +1109,7 @@ xstats_tests(struct test *t) + NULL, + 0); + +- /* Verify that the resetable stats are reset, and others are not */ ++ /* Verify that the resettable stats are reset, and others are not */ + static const uint64_t queue_expected_zero[] = { + 0 /* rx */, + 0 /* tx */, +diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c +index f17aff9655..32639a3bfd 100644 +--- a/drivers/mempool/dpaa/dpaa_mempool.c ++++ b/drivers/mempool/dpaa/dpaa_mempool.c +@@ -258,7 +258,7 @@ dpaa_mbuf_alloc_bulk(struct rte_mempool *pool, + } + /* assigning mbuf from the acquired objects */ + for (i = 0; (i < ret) && bufs[i].addr; i++) { +- /* TODO-errata - objerved that bufs may be null ++ /* TODO-errata - observed that bufs may be null + * i.e. first buffer is valid, remaining 6 buffers + * may be null. + */ +diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c +index 94dc5cd815..8fd9edced2 100644 +--- a/drivers/mempool/octeontx/octeontx_fpavf.c ++++ b/drivers/mempool/octeontx/octeontx_fpavf.c +@@ -669,7 +669,7 @@ octeontx_fpa_bufpool_destroy(uintptr_t handle, int node_id) + break; + } + +- /* Imsert it into an ordered linked list */ ++ /* Insert it into an ordered linked list */ + for (curr = &head; curr[0] != NULL; curr = curr[0]) { + if ((uintptr_t)node <= (uintptr_t)curr[0]) + break; +@@ -705,7 +705,7 @@ octeontx_fpa_bufpool_destroy(uintptr_t handle, int node_id) + + ret = octeontx_fpapf_aura_detach(gpool); + if (ret) { +- fpavf_log_err("Failed to dettach gaura %u. error code=%d\n", ++ fpavf_log_err("Failed to detach gaura %u. error code=%d\n", + gpool, ret); + } + +diff --git a/drivers/net/ark/ark_global.h b/drivers/net/ark/ark_global.h +index 6f9b3013d8..49193ac5b3 100644 +--- a/drivers/net/ark/ark_global.h ++++ b/drivers/net/ark/ark_global.h +@@ -67,7 +67,7 @@ + typedef void (*rx_user_meta_hook_fn)(struct rte_mbuf *mbuf, + const uint32_t *meta, + void *ext_user_data); +-/* TX hook poplulate *meta, with up to 20 bytes. meta_cnt ++/* TX hook populate *meta, with up to 20 bytes. meta_cnt + * returns the number of uint32_t words populated, 0 to 5 + */ + typedef void (*tx_user_meta_hook_fn)(const struct rte_mbuf *mbuf, +diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c +index 1c03e8bfa1..3a028f4290 100644 +--- a/drivers/net/atlantic/atl_ethdev.c ++++ b/drivers/net/atlantic/atl_ethdev.c +@@ -1423,7 +1423,7 @@ atl_dev_interrupt_action(struct rte_eth_dev *dev, + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +diff --git a/drivers/net/atlantic/atl_rxtx.c b/drivers/net/atlantic/atl_rxtx.c +index e3f57ded73..aeb79bf5a2 100644 +--- a/drivers/net/atlantic/atl_rxtx.c ++++ b/drivers/net/atlantic/atl_rxtx.c +@@ -1094,7 +1094,7 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) + * register. + * Update the RDT with the value of the last processed RX descriptor + * minus 1, to guarantee that the RDT register is never equal to the +- * RDH register, which creates a "full" ring situtation from the ++ * RDH register, which creates a "full" ring situation from the + * hardware point of view... + */ + nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold); +diff --git a/drivers/net/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/atlantic/hw_atl/hw_atl_b0.c +index 7d0e724019..d0eb4af928 100644 +--- a/drivers/net/atlantic/hw_atl/hw_atl_b0.c ++++ b/drivers/net/atlantic/hw_atl/hw_atl_b0.c +@@ -281,7 +281,7 @@ int hw_atl_b0_hw_init_rx_path(struct aq_hw_s *self) + hw_atl_rpf_vlan_outer_etht_set(self, 0x88A8U); + hw_atl_rpf_vlan_inner_etht_set(self, 0x8100U); + +- /* VLAN proimisc bu defauld */ ++ /* VLAN promisc by default */ + hw_atl_rpf_vlan_prom_mode_en_set(self, 1); + + /* Rx Interrupts */ +diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c +index daeb3308f4..6a7fddffca 100644 +--- a/drivers/net/axgbe/axgbe_dev.c ++++ b/drivers/net/axgbe/axgbe_dev.c +@@ -1046,7 +1046,7 @@ static int axgbe_config_rx_threshold(struct axgbe_port *pdata, + return 0; + } + +-/*Distrubting fifo size */ ++/* Distributing FIFO size */ + static void axgbe_config_rx_fifo_size(struct axgbe_port *pdata) + { + unsigned int fifo_size; +diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c +index b209ab67cf..f6c49bbbda 100644 +--- a/drivers/net/axgbe/axgbe_ethdev.c ++++ b/drivers/net/axgbe/axgbe_ethdev.c +@@ -284,7 +284,7 @@ static int axgbe_phy_reset(struct axgbe_port *pdata) + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h +index a207f2ae1b..e06d40f9eb 100644 +--- a/drivers/net/axgbe/axgbe_ethdev.h ++++ b/drivers/net/axgbe/axgbe_ethdev.h +@@ -641,7 +641,7 @@ struct axgbe_port { + + unsigned int kr_redrv; + +- /* Auto-negotiation atate machine support */ ++ /* Auto-negotiation state machine support */ + unsigned int an_int; + unsigned int an_status; + enum axgbe_an an_result; +diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c +index 02236ec192..72104f8a3f 100644 +--- a/drivers/net/axgbe/axgbe_phy_impl.c ++++ b/drivers/net/axgbe/axgbe_phy_impl.c +@@ -347,7 +347,7 @@ static int axgbe_phy_i2c_read(struct axgbe_port *pdata, unsigned int target, + + retry = 1; + again2: +- /* Read the specfied register */ ++ /* Read the specified register */ + i2c_op.cmd = AXGBE_I2C_CMD_READ; + i2c_op.target = target; + i2c_op.len = val_len; +@@ -1093,7 +1093,7 @@ static int axgbe_phy_an_config(struct axgbe_port *pdata __rte_unused) + { + return 0; + /* Dummy API since there is no case to support +- * external phy devices registred through kerenl apis ++ * external phy devices registered through kernel APIs + */ + } + +diff --git a/drivers/net/axgbe/axgbe_rxtx_vec_sse.c b/drivers/net/axgbe/axgbe_rxtx_vec_sse.c +index 816371cd79..d95a446bef 100644 +--- a/drivers/net/axgbe/axgbe_rxtx_vec_sse.c ++++ b/drivers/net/axgbe/axgbe_rxtx_vec_sse.c +@@ -11,7 +11,7 @@ + #include + #include + +-/* Useful to avoid shifting for every descriptor prepration*/ ++/* Useful to avoid shifting for every descriptor preparation */ + #define TX_DESC_CTRL_FLAGS 0xb000000000000000 + #define TX_DESC_CTRL_FLAG_TMST 0x40000000 + #define TX_FREE_BULK 8 +diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c +index f67db015b5..74e3018eab 100644 +--- a/drivers/net/bnx2x/bnx2x.c ++++ b/drivers/net/bnx2x/bnx2x.c +@@ -926,7 +926,7 @@ storm_memset_eq_prod(struct bnx2x_softc *sc, uint16_t eq_prod, uint16_t pfid) + * block. + * + * RAMROD_CMD_ID_ETH_UPDATE +- * Used to update the state of the leading connection, usually to udpate ++ * Used to update the state of the leading connection, usually to update + * the RSS indirection table. Completes on the RCQ of the leading + * connection. (Not currently used under FreeBSD until OS support becomes + * available.) +@@ -941,7 +941,7 @@ storm_memset_eq_prod(struct bnx2x_softc *sc, uint16_t eq_prod, uint16_t pfid) + * the RCQ of the leading connection. + * + * RAMROD_CMD_ID_ETH_CFC_DEL +- * Used when tearing down a conneciton prior to driver unload. Completes ++ * Used when tearing down a connection prior to driver unload. Completes + * on the RCQ of the leading connection (since the current connection + * has been completely removed from controller memory). + * +@@ -1072,7 +1072,7 @@ bnx2x_sp_post(struct bnx2x_softc *sc, int command, int cid, uint32_t data_hi, + + /* + * It's ok if the actual decrement is issued towards the memory +- * somewhere between the lock and unlock. Thus no more explict ++ * somewhere between the lock and unlock. Thus no more explicit + * memory barrier is needed. + */ + if (common) { +@@ -1190,7 +1190,7 @@ bnx2x_sp_event(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, + break; + + case (RAMROD_CMD_ID_ETH_TERMINATE): +- PMD_DRV_LOG(DEBUG, sc, "got MULTI[%d] teminate ramrod", cid); ++ PMD_DRV_LOG(DEBUG, sc, "got MULTI[%d] terminate ramrod", cid); + drv_cmd = ECORE_Q_CMD_TERMINATE; + break; + +@@ -1476,7 +1476,7 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode, + case BNX2X_RX_MODE_ALLMULTI_PROMISC: + case BNX2X_RX_MODE_PROMISC: + /* +- * According to deffinition of SI mode, iface in promisc mode ++ * According to definition of SI mode, iface in promisc mode + * should receive matched and unmatched (in resolution of port) + * unicast packets. + */ +@@ -1944,7 +1944,7 @@ static void bnx2x_disable_close_the_gate(struct bnx2x_softc *sc) + + /* + * Cleans the object that have internal lists without sending +- * ramrods. Should be run when interrutps are disabled. ++ * ramrods. Should be run when interrupts are disabled. + */ + static void bnx2x_squeeze_objects(struct bnx2x_softc *sc) + { +@@ -2043,7 +2043,7 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link + + /* + * Nothing to do during unload if previous bnx2x_nic_load() +- * did not completed successfully - all resourses are released. ++ * did not complete successfully - all resources are released. + */ + if ((sc->state == BNX2X_STATE_CLOSED) || (sc->state == BNX2X_STATE_ERROR)) { + return 0; +@@ -2084,7 +2084,7 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link + /* + * Prevent transactions to host from the functions on the + * engine that doesn't reset global blocks in case of global +- * attention once gloabl blocks are reset and gates are opened ++ * attention once global blocks are reset and gates are opened + * (the engine which leader will perform the recovery + * last). + */ +@@ -2101,7 +2101,7 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link + + /* + * At this stage no more interrupts will arrive so we may safely clean +- * the queue'able objects here in case they failed to get cleaned so far. ++ * the queueable objects here in case they failed to get cleaned so far. + */ + if (IS_PF(sc)) { + bnx2x_squeeze_objects(sc); +@@ -2151,7 +2151,7 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link + } + + /* +- * Encapsulte an mbuf cluster into the tx bd chain and makes the memory ++ * Encapsulate an mbuf cluster into the Tx BD chain and makes the memory + * visible to the controller. + * + * If an mbuf is submitted to this routine and cannot be given to the +@@ -2719,7 +2719,7 @@ static uint8_t bnx2x_clear_pf_load(struct bnx2x_softc *sc) + return val1 != 0; + } + +-/* send load requrest to mcp and analyze response */ ++/* send load request to MCP and analyze response */ + static int bnx2x_nic_load_request(struct bnx2x_softc *sc, uint32_t * load_code) + { + PMD_INIT_FUNC_TRACE(sc); +@@ -5325,7 +5325,7 @@ static void bnx2x_func_init(struct bnx2x_softc *sc, struct bnx2x_func_init_param + * sum of vn_min_rates. + * or + * 0 - if all the min_rates are 0. +- * In the later case fainess algorithm should be deactivated. ++ * In the later case fairness algorithm should be deactivated. + * If all min rates are not zero then those that are zeroes will be set to 1. + */ + static void bnx2x_calc_vn_min(struct bnx2x_softc *sc, struct cmng_init_input *input) +@@ -6564,7 +6564,7 @@ bnx2x_pf_tx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, + txq_init->fw_sb_id = fp->fw_sb_id; + + /* +- * set the TSS leading client id for TX classfication to the ++ * set the TSS leading client id for Tx classification to the + * leading RSS client id + */ + txq_init->tss_leading_cl_id = BNX2X_FP(sc, 0, cl_id); +@@ -7634,8 +7634,8 @@ static uint8_t bnx2x_is_pcie_pending(struct bnx2x_softc *sc) + } + + /* +-* Walk the PCI capabiites list for the device to find what features are +-* supported. These capabilites may be enabled/disabled by firmware so it's ++* Walk the PCI capabilities list for the device to find what features are ++* supported. These capabilities may be enabled/disabled by firmware so it's + * best to walk the list rather than make assumptions. + */ + static void bnx2x_probe_pci_caps(struct bnx2x_softc *sc) +@@ -8425,7 +8425,7 @@ static int bnx2x_get_device_info(struct bnx2x_softc *sc) + } else { + sc->devinfo.int_block = INT_BLOCK_IGU; + +-/* do not allow device reset during IGU info preocessing */ ++/* do not allow device reset during IGU info processing */ + bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RESET); + + val = REG_RD(sc, IGU_REG_BLOCK_CONFIGURATION); +@@ -9765,7 +9765,7 @@ int bnx2x_attach(struct bnx2x_softc *sc) + + sc->igu_base_addr = IS_VF(sc) ? PXP_VF_ADDR_IGU_START : BAR_IGU_INTMEM; + +- /* get PCI capabilites */ ++ /* get PCI capabilities */ + bnx2x_probe_pci_caps(sc); + + if (sc->devinfo.pcie_msix_cap_reg != 0) { +@@ -10284,7 +10284,7 @@ static int bnx2x_init_hw_common(struct bnx2x_softc *sc) + * stay set) + * f. If this is VNIC 3 of a port then also init + * first_timers_ilt_entry to zero and last_timers_ilt_entry +- * to the last enrty in the ILT. ++ * to the last entry in the ILT. + * + * Notes: + * Currently the PF error in the PGLC is non recoverable. +@@ -11090,7 +11090,7 @@ static void bnx2x_hw_enable_status(struct bnx2x_softc *sc) + /** + * bnx2x_pf_flr_clnup + * a. re-enable target read on the PF +- * b. poll cfc per function usgae counter ++ * b. poll cfc per function usage counter + * c. poll the qm perfunction usage counter + * d. poll the tm per function usage counter + * e. poll the tm per function scan-done indication +diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h +index 80d19cbfd6..d7e1729e68 100644 +--- a/drivers/net/bnx2x/bnx2x.h ++++ b/drivers/net/bnx2x/bnx2x.h +@@ -681,13 +681,13 @@ struct bnx2x_slowpath { + }; /* struct bnx2x_slowpath */ + + /* +- * Port specifc data structure. ++ * Port specific data structure. + */ + struct bnx2x_port { + /* + * Port Management Function (for 57711E only). + * When this field is set the driver instance is +- * responsible for managing port specifc ++ * responsible for managing port specific + * configurations such as handling link attentions. + */ + uint32_t pmf; +@@ -732,7 +732,7 @@ struct bnx2x_port { + + /* + * MCP scratchpad address for port specific statistics. +- * The device is responsible for writing statistcss ++ * The device is responsible for writing statistics + * back to the MCP for use with management firmware such + * as UMP/NC-SI. + */ +@@ -937,8 +937,8 @@ struct bnx2x_devinfo { + * already registered for this port (which means that the user wants storage + * services). + * 2. During cnic-related load, to know if offload mode is already configured +- * in the HW or needs to be configrued. Since the transition from nic-mode to +- * offload-mode in HW causes traffic coruption, nic-mode is configured only ++ * in the HW or needs to be configured. Since the transition from nic-mode to ++ * offload-mode in HW causes traffic corruption, nic-mode is configured only + * in ports on which storage services where never requested. + */ + #define CONFIGURE_NIC_MODE(sc) (!CHIP_IS_E1x(sc) && !CNIC_ENABLED(sc)) +diff --git a/drivers/net/bnx2x/bnx2x_stats.c b/drivers/net/bnx2x/bnx2x_stats.c +index 1cd972591a..c07b01510a 100644 +--- a/drivers/net/bnx2x/bnx2x_stats.c ++++ b/drivers/net/bnx2x/bnx2x_stats.c +@@ -1358,7 +1358,7 @@ bnx2x_prep_fw_stats_req(struct bnx2x_softc *sc) + + /* + * Prepare the first stats ramrod (will be completed with +- * the counters equal to zero) - init counters to somethig different. ++ * the counters equal to zero) - init counters to something different. + */ + memset(&sc->fw_stats_data->storm_counters, 0xff, + sizeof(struct stats_counter)); +diff --git a/drivers/net/bnx2x/bnx2x_stats.h b/drivers/net/bnx2x/bnx2x_stats.h +index 635412bdd3..11ddab5039 100644 +--- a/drivers/net/bnx2x/bnx2x_stats.h ++++ b/drivers/net/bnx2x/bnx2x_stats.h +@@ -314,7 +314,7 @@ struct bnx2x_eth_stats_old { + }; + + struct bnx2x_eth_q_stats_old { +- /* Fields to perserve over fw reset*/ ++ /* Fields to preserve over FW reset */ + uint32_t total_unicast_bytes_received_hi; + uint32_t total_unicast_bytes_received_lo; + uint32_t total_broadcast_bytes_received_hi; +@@ -328,7 +328,7 @@ struct bnx2x_eth_q_stats_old { + uint32_t total_multicast_bytes_transmitted_hi; + uint32_t total_multicast_bytes_transmitted_lo; + +- /* Fields to perserve last of */ ++ /* Fields to preserve last of */ + uint32_t total_bytes_received_hi; + uint32_t total_bytes_received_lo; + uint32_t total_bytes_transmitted_hi; +diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c +index 945e3df84f..63953c2979 100644 +--- a/drivers/net/bnx2x/bnx2x_vfpf.c ++++ b/drivers/net/bnx2x/bnx2x_vfpf.c +@@ -73,7 +73,7 @@ bnx2x_add_tlv(__rte_unused struct bnx2x_softc *sc, void *tlvs_list, + tl->length = length; + } + +-/* Initiliaze header of the first tlv and clear mailbox*/ ++/* Initialize header of the first TLV and clear mailbox */ + static void + bnx2x_vf_prep(struct bnx2x_softc *sc, struct vf_first_tlv *first_tlv, + uint16_t type, uint16_t length) +diff --git a/drivers/net/bnx2x/bnx2x_vfpf.h b/drivers/net/bnx2x/bnx2x_vfpf.h +index 9577341266..d71e81c005 100644 +--- a/drivers/net/bnx2x/bnx2x_vfpf.h ++++ b/drivers/net/bnx2x/bnx2x_vfpf.h +@@ -241,7 +241,7 @@ struct vf_close_tlv { + uint8_t pad[2]; + }; + +-/* rlease the VF's acquired resources */ ++/* release the VF's acquired resources */ + struct vf_release_tlv { + struct vf_first_tlv first_tlv; + uint16_t vf_id; /* for debug */ +diff --git a/drivers/net/bnx2x/ecore_fw_defs.h b/drivers/net/bnx2x/ecore_fw_defs.h +index 93bca8ad33..6fc1fce7e2 100644 +--- a/drivers/net/bnx2x/ecore_fw_defs.h ++++ b/drivers/net/bnx2x/ecore_fw_defs.h +@@ -379,7 +379,7 @@ + /* temporarily used for RTT */ + #define XSEMI_CLK1_RESUL_CHIP (1e-3) + +-/* used for Host Coallescing */ ++/* used for Host Coalescing */ + #define SDM_TIMER_TICK_RESUL_CHIP (4 * (1e-6)) + #define TSDM_TIMER_TICK_RESUL_CHIP (1 * (1e-6)) + +diff --git a/drivers/net/bnx2x/ecore_hsi.h b/drivers/net/bnx2x/ecore_hsi.h +index 5508c53639..eda79408e9 100644 +--- a/drivers/net/bnx2x/ecore_hsi.h ++++ b/drivers/net/bnx2x/ecore_hsi.h +@@ -1062,7 +1062,7 @@ struct port_feat_cfg { /* port 0: 0x454 port 1: 0x4c8 */ + #define PORT_FEATURE_MBA_LINK_SPEED_20G 0x20000000 + + /* Secondary MBA configuration, +- * see mba_config for the fileds defination. ++ * see mba_config for the fields definition. + */ + uint32_t mba_config2; + +@@ -1075,7 +1075,7 @@ struct port_feat_cfg { /* port 0: 0x454 port 1: 0x4c8 */ + #define PORT_FEATURE_BOFM_CFGD_VEN 0x00080000 + + /* Secondary MBA configuration, +- * see mba_vlan_cfg for the fileds defination. ++ * see mba_vlan_cfg for the fields definition. + */ + uint32_t mba_vlan_cfg2; + +@@ -1429,7 +1429,7 @@ struct extended_dev_info_shared_cfg { /* NVRAM OFFSET */ + #define EXTENDED_DEV_INFO_SHARED_CFG_DBG_GEN3_COMPLI_ENA 0x00080000 + + /* Override Rx signal detect threshold when enabled the threshold +- * will be set staticaly ++ * will be set statically + */ + #define EXTENDED_DEV_INFO_SHARED_CFG_OVERRIDE_RX_SIG_MASK 0x00100000 + #define EXTENDED_DEV_INFO_SHARED_CFG_OVERRIDE_RX_SIG_SHIFT 20 +@@ -2189,9 +2189,9 @@ struct eee_remote_vals { + * elements on a per byte or word boundary. + * + * example: an array with 8 entries each 4 bit wide. This array will fit into +- * a single dword. The diagrmas below show the array order of the nibbles. ++ * a single dword. The diagrams below show the array order of the nibbles. + * +- * SHMEM_ARRAY_BITPOS(i, 4, 4) defines the stadard ordering: ++ * SHMEM_ARRAY_BITPOS(i, 4, 4) defines the standard ordering: + * + * | | | | + * 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +@@ -2519,17 +2519,17 @@ struct shmem_lfa { + }; + + /* +- * Used to suppoert NSCI get OS driver version ++ * Used to support NSCI get OS driver version + * On driver load the version value will be set + * On driver unload driver value of 0x0 will be set + */ + struct os_drv_ver { + #define DRV_VER_NOT_LOADED 0 +- /*personalites orrder is importent */ ++ /* personalities order is important */ + #define DRV_PERS_ETHERNET 0 + #define DRV_PERS_ISCSI 1 + #define DRV_PERS_FCOE 2 +- /*shmem2 struct is constatnt can't add more personalites here*/ ++ /* shmem2 struct is constant can't add more personalities here */ + #define MAX_DRV_PERS 3 + uint32_t versions[MAX_DRV_PERS]; + }; +@@ -2821,7 +2821,7 @@ struct shmem2_region { + /* Flag to the driver that PF's drv_info_host_addr buffer was read */ + uint32_t mfw_drv_indication; /* Offset 0x19c */ + +- /* We use inidcation for each PF (0..3) */ ++ /* We use indication for each PF (0..3) */ + #define MFW_DRV_IND_READ_DONE_OFFSET(_pf_) (1 << (_pf_)) + + union { /* For various OEMs */ /* Offset 0x1a0 */ +@@ -6195,7 +6195,7 @@ struct hc_sb_data { + + + /* +- * Segment types for host coaslescing ++ * Segment types for host coalescing + */ + enum hc_segment { + HC_REGULAR_SEGMENT, +@@ -6242,7 +6242,7 @@ struct hc_status_block_data_e2 { + + + /* +- * IGU block operartion modes (in Everest2) ++ * IGU block operation modes (in Everest2) + */ + enum igu_mode { + HC_IGU_BC_MODE, +@@ -6508,7 +6508,7 @@ struct stats_query_header { + + + /* +- * Types of statistcis query entry ++ * Types of statistics query entry + */ + enum stats_query_type { + STATS_TYPE_QUEUE, +@@ -6542,7 +6542,7 @@ enum storm_id { + + + /* +- * Taffic types used in ETS and flow control algorithms ++ * Traffic types used in ETS and flow control algorithms + */ + enum traffic_type { + LLFC_TRAFFIC_TYPE_NW, +diff --git a/drivers/net/bnx2x/ecore_init_ops.h b/drivers/net/bnx2x/ecore_init_ops.h +index 0945e79993..4ed811fdd4 100644 +--- a/drivers/net/bnx2x/ecore_init_ops.h ++++ b/drivers/net/bnx2x/ecore_init_ops.h +@@ -534,7 +534,7 @@ static void ecore_init_pxp_arb(struct bnx2x_softc *sc, int r_order, + REG_WR(sc, PXP2_REG_WR_CDU_MPS, val); + } + +- /* Validate number of tags suppoted by device */ ++ /* Validate number of tags supported by device */ + #define PCIE_REG_PCIER_TL_HDR_FC_ST 0x2980 + val = REG_RD(sc, PCIE_REG_PCIER_TL_HDR_FC_ST); + val &= 0xFF; +@@ -714,7 +714,7 @@ static void ecore_ilt_client_init_op_ilt(struct bnx2x_softc *sc, + for (i = ilt_cli->start; i <= ilt_cli->end; i++) + ecore_ilt_line_init_op(sc, ilt, i, initop); + +- /* init/clear the ILT boundries */ ++ /* init/clear the ILT boundaries */ + ecore_ilt_boundary_init_op(sc, ilt_cli, ilt->start_line, initop); + } + +@@ -765,7 +765,7 @@ static void ecore_ilt_init_client_psz(struct bnx2x_softc *sc, int cli_num, + + /* + * called during init common stage, ilt clients should be initialized +- * prioir to calling this function ++ * prior to calling this function + */ + static void ecore_ilt_init_page_size(struct bnx2x_softc *sc, uint8_t initop) + { +diff --git a/drivers/net/bnx2x/ecore_reg.h b/drivers/net/bnx2x/ecore_reg.h +index bb92d131f8..6f7b0522f2 100644 +--- a/drivers/net/bnx2x/ecore_reg.h ++++ b/drivers/net/bnx2x/ecore_reg.h +@@ -19,7 +19,7 @@ + #define ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT (0x1 << 3) + #define ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR (0x1 << 4) + #define ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND (0x1 << 1) +-/* [R 1] ATC initalization done */ ++/* [R 1] ATC initialization done */ + #define ATC_REG_ATC_INIT_DONE 0x1100bc + /* [RW 6] Interrupt mask register #0 read/write */ + #define ATC_REG_ATC_INT_MASK 0x1101c8 +@@ -56,7 +56,7 @@ + #define BRB1_REG_PAUSE_HIGH_THRESHOLD_0 0x60078 + /* [RW 10] Write client 0: Assert pause threshold. Not Functional */ + #define BRB1_REG_PAUSE_LOW_THRESHOLD_0 0x60068 +-/* [R 24] The number of full blocks occpied by port. */ ++/* [R 24] The number of full blocks occupied by port. */ + #define BRB1_REG_PORT_NUM_OCC_BLOCKS_0 0x60094 + /* [R 5] Used to read the value of the XX protection CAM occupancy counter. */ + #define CCM_REG_CAM_OCCUP 0xd0188 +@@ -456,7 +456,7 @@ + #define IGU_REG_PCI_PF_MSIX_FUNC_MASK 0x130148 + #define IGU_REG_PCI_PF_MSI_EN 0x130140 + /* [WB_R 32] Each bit represent the pending bits status for that SB. 0 = no +- * pending; 1 = pending. Pendings means interrupt was asserted; and write ++ * pending; 1 = pending. Pending means interrupt was asserted; and write + * done was not received. Data valid only in addresses 0-4. all the rest are + * zero. + */ +@@ -1059,14 +1059,14 @@ + /* [R 28] this field hold the last information that caused reserved + * attention. bits [19:0] - address; [22:20] function; [23] reserved; + * [27:24] the master that caused the attention - according to the following +- * encodeing:1 = pxp; 2 = mcp; 3 = usdm; 4 = tsdm; 5 = xsdm; 6 = csdm; 7 = ++ * encoding:1 = pxp; 2 = mcp; 3 = usdm; 4 = tsdm; 5 = xsdm; 6 = csdm; 7 = + * dbu; 8 = dmae + */ + #define MISC_REG_GRC_RSV_ATTN 0xa3c0 + /* [R 28] this field hold the last information that caused timeout + * attention. bits [19:0] - address; [22:20] function; [23] reserved; + * [27:24] the master that caused the attention - according to the following +- * encodeing:1 = pxp; 2 = mcp; 3 = usdm; 4 = tsdm; 5 = xsdm; 6 = csdm; 7 = ++ * encoding:1 = pxp; 2 = mcp; 3 = usdm; 4 = tsdm; 5 = xsdm; 6 = csdm; 7 = + * dbu; 8 = dmae + */ + #define MISC_REG_GRC_TIMEOUT_ATTN 0xa3c4 +@@ -1567,7 +1567,7 @@ + * MAC DA 2. The reset default is set to mask out all parameters. + */ + #define NIG_REG_P0_LLH_PTP_PARAM_MASK 0x187a0 +-/* [RW 14] Mask regiser for the rules used in detecting PTP packets. Set ++/* [RW 14] Mask register for the rules used in detecting PTP packets. Set + * each bit to 1 to mask out that particular rule. 0-{IPv4 DA 0; UDP DP 0} . + * 1-{IPv4 DA 0; UDP DP 1} . 2-{IPv4 DA 1; UDP DP 0} . 3-{IPv4 DA 1; UDP DP + * 1} . 4-{IPv6 DA 0; UDP DP 0} . 5-{IPv6 DA 0; UDP DP 1} . 6-{IPv6 DA 1; +@@ -1672,7 +1672,7 @@ + * MAC DA 2. The reset default is set to mask out all parameters. + */ + #define NIG_REG_P0_TLLH_PTP_PARAM_MASK 0x187f0 +-/* [RW 14] Mask regiser for the rules used in detecting PTP packets. Set ++/* [RW 14] Mask register for the rules used in detecting PTP packets. Set + * each bit to 1 to mask out that particular rule. 0-{IPv4 DA 0; UDP DP 0} . + * 1-{IPv4 DA 0; UDP DP 1} . 2-{IPv4 DA 1; UDP DP 0} . 3-{IPv4 DA 1; UDP DP + * 1} . 4-{IPv6 DA 0; UDP DP 0} . 5-{IPv6 DA 0; UDP DP 1} . 6-{IPv6 DA 1; +@@ -1839,7 +1839,7 @@ + * MAC DA 2. The reset default is set to mask out all parameters. + */ + #define NIG_REG_P1_LLH_PTP_PARAM_MASK 0x187c8 +-/* [RW 14] Mask regiser for the rules used in detecting PTP packets. Set ++/* [RW 14] Mask register for the rules used in detecting PTP packets. Set + * each bit to 1 to mask out that particular rule. 0-{IPv4 DA 0; UDP DP 0} . + * 1-{IPv4 DA 0; UDP DP 1} . 2-{IPv4 DA 1; UDP DP 0} . 3-{IPv4 DA 1; UDP DP + * 1} . 4-{IPv6 DA 0; UDP DP 0} . 5-{IPv6 DA 0; UDP DP 1} . 6-{IPv6 DA 1; +@@ -1926,7 +1926,7 @@ + * MAC DA 2. The reset default is set to mask out all parameters. + */ + #define NIG_REG_P1_TLLH_PTP_PARAM_MASK 0x187f8 +-/* [RW 14] Mask regiser for the rules used in detecting PTP packets. Set ++/* [RW 14] Mask register for the rules used in detecting PTP packets. Set + * each bit to 1 to mask out that particular rule. 0-{IPv4 DA 0; UDP DP 0} . + * 1-{IPv4 DA 0; UDP DP 1} . 2-{IPv4 DA 1; UDP DP 0} . 3-{IPv4 DA 1; UDP DP + * 1} . 4-{IPv6 DA 0; UDP DP 0} . 5-{IPv6 DA 0; UDP DP 1} . 6-{IPv6 DA 1; +@@ -2306,7 +2306,7 @@ + #define PBF_REG_HDRS_AFTER_BASIC 0x15c0a8 + /* [RW 6] Bit-map indicating which L2 hdrs may appear after L2 tag 0 */ + #define PBF_REG_HDRS_AFTER_TAG_0 0x15c0b8 +-/* [R 1] Removed for E3 B0 - Indicates which COS is conncted to the highest ++/* [R 1] Removed for E3 B0 - Indicates which COS is connected to the highest + * priority in the command arbiter. + */ + #define PBF_REG_HIGH_PRIORITY_COS_NUM 0x15c04c +@@ -2366,7 +2366,7 @@ + */ + #define PBF_REG_NUM_STRICT_ARB_SLOTS 0x15c064 + /* [R 11] Removed for E3 B0 - Port 0 threshold used by arbiter in 16 byte +- * lines used when pause not suppoterd. ++ * lines used when pause not supported. + */ + #define PBF_REG_P0_ARB_THRSH 0x1400e4 + /* [R 11] Removed for E3 B0 - Current credit for port 0 in the tx port +@@ -3503,7 +3503,7 @@ + * queues. + */ + #define QM_REG_OVFERROR 0x16805c +-/* [RC 6] the Q were the qverflow occurs */ ++/* [RC 6] the Q were the overflow occurs */ + #define QM_REG_OVFQNUM 0x168058 + /* [R 16] Pause state for physical queues 15-0 */ + #define QM_REG_PAUSESTATE0 0x168410 +@@ -4890,7 +4890,7 @@ + if set, generate pcie_err_attn output when this error is seen. WC \ + */ + #define PXPCS_TL_FUNC345_STAT_ERR_MASTER_ABRT2 \ +- (1 << 3) /* Receive UR Statusfor Function 2. If set, generate \ ++ (1 << 3) /* Receive UR Status for Function 2. If set, generate \ + pcie_err_attn output when this error is seen. WC */ + #define PXPCS_TL_FUNC345_STAT_ERR_CPL_TIMEOUT2 \ + (1 << 2) /* Completer Timeout Status Status for Function 2, if \ +@@ -4986,7 +4986,7 @@ + if set, generate pcie_err_attn output when this error is seen. WC \ + */ + #define PXPCS_TL_FUNC678_STAT_ERR_MASTER_ABRT5 \ +- (1 << 3) /* Receive UR Statusfor Function 5. If set, generate \ ++ (1 << 3) /* Receive UR Status for Function 5. If set, generate \ + pcie_err_attn output when this error is seen. WC */ + #define PXPCS_TL_FUNC678_STAT_ERR_CPL_TIMEOUT5 \ + (1 << 2) /* Completer Timeout Status Status for Function 5, if \ +diff --git a/drivers/net/bnx2x/ecore_sp.c b/drivers/net/bnx2x/ecore_sp.c +index 0075422eee..c6c3857778 100644 +--- a/drivers/net/bnx2x/ecore_sp.c ++++ b/drivers/net/bnx2x/ecore_sp.c +@@ -1338,7 +1338,7 @@ static int __ecore_vlan_mac_execute_step(struct bnx2x_softc *sc, + if (rc != ECORE_SUCCESS) { + __ecore_vlan_mac_h_pend(sc, o, *ramrod_flags); + +- /** Calling function should not diffrentiate between this case ++ /** Calling function should not differentiate between this case + * and the case in which there is already a pending ramrod + */ + rc = ECORE_PENDING; +@@ -2246,7 +2246,7 @@ struct ecore_pending_mcast_cmd { + union { + ecore_list_t macs_head; + uint32_t macs_num; /* Needed for DEL command */ +- int next_bin; /* Needed for RESTORE flow with aprox match */ ++ int next_bin; /* Needed for RESTORE flow with approx match */ + } data; + + int done; /* set to TRUE, when the command has been handled, +@@ -3424,7 +3424,7 @@ void ecore_init_mac_credit_pool(struct bnx2x_softc *sc, + } else { + + /* +- * CAM credit is equaly divided between all active functions ++ * CAM credit is equally divided between all active functions + * on the PATH. + */ + if (func_num > 0) { +diff --git a/drivers/net/bnx2x/ecore_sp.h b/drivers/net/bnx2x/ecore_sp.h +index d58072dac0..1f4d5a3ebe 100644 +--- a/drivers/net/bnx2x/ecore_sp.h ++++ b/drivers/net/bnx2x/ecore_sp.h +@@ -430,7 +430,7 @@ enum { + RAMROD_RESTORE, + /* Execute the next command now */ + RAMROD_EXEC, +- /* Don't add a new command and continue execution of posponed ++ /* Don't add a new command and continue execution of postponed + * commands. If not set a new command will be added to the + * pending commands list. + */ +@@ -1173,7 +1173,7 @@ struct ecore_rss_config_obj { + /* Last configured indirection table */ + uint8_t ind_table[T_ETH_INDIRECTION_TABLE_SIZE]; + +- /* flags for enabling 4-tupple hash on UDP */ ++ /* flags for enabling 4-tuple hash on UDP */ + uint8_t udp_rss_v4; + uint8_t udp_rss_v6; + +@@ -1285,7 +1285,7 @@ enum ecore_q_type { + #define ECORE_MULTI_TX_COS_E3B0 3 + #define ECORE_MULTI_TX_COS 3 /* Maximum possible */ + #define MAC_PAD (ECORE_ALIGN(ETH_ALEN, sizeof(uint32_t)) - ETH_ALEN) +-/* DMAE channel to be used by FW for timesync workaroun. A driver that sends ++/* DMAE channel to be used by FW for timesync workaround. A driver that sends + * timesync-related ramrods must not use this DMAE command ID. + */ + #define FW_DMAE_CMD_ID 6 +diff --git a/drivers/net/bnx2x/elink.c b/drivers/net/bnx2x/elink.c +index 2093d8f373..43fbf04ece 100644 +--- a/drivers/net/bnx2x/elink.c ++++ b/drivers/net/bnx2x/elink.c +@@ -1460,7 +1460,7 @@ static void elink_ets_e3b0_pbf_disabled(const struct elink_params *params) + } + /****************************************************************************** + * Description: +- * E3B0 disable will return basicly the values to init values. ++ * E3B0 disable will return basically the values to init values. + *. + ******************************************************************************/ + static elink_status_t elink_ets_e3b0_disabled(const struct elink_params *params, +@@ -1483,7 +1483,7 @@ static elink_status_t elink_ets_e3b0_disabled(const struct elink_params *params, + + /****************************************************************************** + * Description: +- * Disable will return basicly the values to init values. ++ * Disable will return basically the values to init values. + * + ******************************************************************************/ + elink_status_t elink_ets_disabled(struct elink_params *params, +@@ -1506,7 +1506,7 @@ elink_status_t elink_ets_disabled(struct elink_params *params, + + /****************************************************************************** + * Description +- * Set the COS mappimg to SP and BW until this point all the COS are not ++ * Set the COS mapping to SP and BW until this point all the COS are not + * set as SP or BW. + ******************************************************************************/ + static elink_status_t elink_ets_e3b0_cli_map(const struct elink_params *params, +@@ -1652,7 +1652,7 @@ static elink_status_t elink_ets_e3b0_get_total_bw( + } + ELINK_DEBUG_P0(sc, + "elink_ets_E3B0_config total BW should be 100"); +- /* We can handle a case whre the BW isn't 100 this can happen ++ /* We can handle a case where the BW isn't 100 this can happen + * if the TC are joined. + */ + } +@@ -2608,7 +2608,7 @@ static elink_status_t elink_emac_enable(struct elink_params *params, + REG_WR(sc, NIG_REG_EGRESS_EMAC0_PORT + port * 4, 1); + + #ifdef ELINK_INCLUDE_EMUL +- /* for paladium */ ++ /* for palladium */ + if (CHIP_REV_IS_EMUL(sc)) { + /* Use lane 1 (of lanes 0-3) */ + REG_WR(sc, NIG_REG_XGXS_LANE_SEL_P0 + port * 4, 1); +@@ -2850,7 +2850,7 @@ static void elink_update_pfc_bmac2(struct elink_params *params, + + /* Set Time (based unit is 512 bit time) between automatic + * re-sending of PP packets amd enable automatic re-send of +- * Per-Priroity Packet as long as pp_gen is asserted and ++ * Per-Priority Packet as long as pp_gen is asserted and + * pp_disable is low. + */ + val = 0x8000; +@@ -3369,7 +3369,7 @@ static elink_status_t elink_pbf_update(struct elink_params *params, + } + + /** +- * elink_get_emac_base - retrive emac base address ++ * elink_get_emac_base - retrieve emac base address + * + * @bp: driver handle + * @mdc_mdio_access: access type +@@ -4518,7 +4518,7 @@ static void elink_warpcore_enable_AN_KR2(struct elink_phy *phy, + elink_cl45_write(sc, phy, reg_set[i].devad, reg_set[i].reg, + reg_set[i].val); + +- /* Start KR2 work-around timer which handles BNX2X8073 link-parner */ ++ /* Start KR2 work-around timer which handles BNX2X8073 link-partner */ + params->link_attr_sync |= LINK_ATTR_SYNC_KR2_ENABLE; + elink_update_link_attr(params, params->link_attr_sync); + } +@@ -7824,7 +7824,7 @@ elink_status_t elink_link_update(struct elink_params *params, + * hence its link is expected to be down + * - SECOND_PHY means that first phy should not be able + * to link up by itself (using configuration) +- * - DEFAULT should be overridden during initialiazation ++ * - DEFAULT should be overridden during initialization + */ + ELINK_DEBUG_P1(sc, "Invalid link indication" + " mpc=0x%x. DISABLING LINK !!!", +@@ -10991,7 +10991,7 @@ static elink_status_t elink_84858_cmd_hdlr(struct elink_phy *phy, + ELINK_DEBUG_P0(sc, "FW cmd failed."); + return ELINK_STATUS_ERROR; + } +- /* Step5: Once the command has completed, read the specficied DATA ++ /* Step5: Once the command has completed, read the specified DATA + * registers for any saved results for the command, if applicable + */ + +diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c +index f53f8632fe..7bcf36c9cb 100644 +--- a/drivers/net/bnxt/bnxt_hwrm.c ++++ b/drivers/net/bnxt/bnxt_hwrm.c +@@ -3727,7 +3727,7 @@ int bnxt_hwrm_allocate_pf_only(struct bnxt *bp) + int rc; + + if (!BNXT_PF(bp)) { +- PMD_DRV_LOG(ERR, "Attempt to allcoate VFs on a VF!\n"); ++ PMD_DRV_LOG(ERR, "Attempt to allocate VFs on a VF!\n"); + return -EINVAL; + } + +diff --git a/drivers/net/bnxt/tf_core/tfp.c b/drivers/net/bnxt/tf_core/tfp.c +index a4b0934610..a967a9ccf2 100644 +--- a/drivers/net/bnxt/tf_core/tfp.c ++++ b/drivers/net/bnxt/tf_core/tfp.c +@@ -52,7 +52,7 @@ tfp_send_msg_direct(struct bnxt *bp, + } + + /** +- * Allocates zero'ed memory from the heap. ++ * Allocates zeroed memory from the heap. + * + * Returns success or failure code. + */ +diff --git a/drivers/net/bnxt/tf_core/tfp.h b/drivers/net/bnxt/tf_core/tfp.h +index dd0a347058..5a99c7a06e 100644 +--- a/drivers/net/bnxt/tf_core/tfp.h ++++ b/drivers/net/bnxt/tf_core/tfp.h +@@ -150,7 +150,7 @@ tfp_msg_hwrm_oem_cmd(struct tf *tfp, + uint32_t max_flows); + + /** +- * Allocates zero'ed memory from the heap. ++ * Allocates zeroed memory from the heap. + * + * NOTE: Also performs virt2phy address conversion by default thus is + * can be expensive to invoke. +diff --git a/drivers/net/bonding/eth_bond_8023ad_private.h b/drivers/net/bonding/eth_bond_8023ad_private.h +index 9b5738afee..a5e1fffea1 100644 +--- a/drivers/net/bonding/eth_bond_8023ad_private.h ++++ b/drivers/net/bonding/eth_bond_8023ad_private.h +@@ -20,7 +20,7 @@ + /** Maximum number of LACP packets from one slave queued in TX ring. */ + #define BOND_MODE_8023AX_SLAVE_TX_PKTS 1 + /** +- * Timeouts deffinitions (5.4.4 in 802.1AX documentation). ++ * Timeouts definitions (5.4.4 in 802.1AX documentation). + */ + #define BOND_8023AD_FAST_PERIODIC_MS 900 + #define BOND_8023AD_SLOW_PERIODIC_MS 29000 +diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h +index 8b104b6391..9626b26d67 100644 +--- a/drivers/net/bonding/eth_bond_private.h ++++ b/drivers/net/bonding/eth_bond_private.h +@@ -139,7 +139,7 @@ struct bond_dev_private { + + uint16_t slave_count; /**< Number of bonded slaves */ + struct bond_slave_details slaves[RTE_MAX_ETHPORTS]; +- /**< Arary of bonded slaves details */ ++ /**< Array of bonded slaves details */ + + struct mode8023ad_private mode4; + uint16_t tlb_slaves_order[RTE_MAX_ETHPORTS]; +diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c +index ca50583d62..b3cddd8a20 100644 +--- a/drivers/net/bonding/rte_eth_bond_8023ad.c ++++ b/drivers/net/bonding/rte_eth_bond_8023ad.c +@@ -243,7 +243,7 @@ record_default(struct port *port) + { + /* Record default parameters for partner. Partner admin parameters + * are not implemented so set them to arbitrary default (last known) and +- * mark actor that parner is in defaulted state. */ ++ * mark actor that partner is in defaulted state. */ + port->partner_state = STATE_LACP_ACTIVE; + ACTOR_STATE_SET(port, DEFAULTED); + } +@@ -300,7 +300,7 @@ rx_machine(struct bond_dev_private *internals, uint16_t slave_id, + MODE4_DEBUG("LACP -> CURRENT\n"); + BOND_PRINT_LACP(lacp); + /* Update selected flag. If partner parameters are defaulted assume they +- * are match. If not defaulted compare LACP actor with ports parner ++ * are match. If not defaulted compare LACP actor with ports partner + * params. */ + if (!ACTOR_STATE(port, DEFAULTED) && + (ACTOR_STATE(port, AGGREGATION) != PARTNER_STATE(port, AGGREGATION) +@@ -399,16 +399,16 @@ periodic_machine(struct bond_dev_private *internals, uint16_t slave_id) + PARTNER_STATE(port, LACP_ACTIVE); + + uint8_t is_partner_fast, was_partner_fast; +- /* No periodic is on BEGIN, LACP DISABLE or when both sides are pasive */ ++ /* No periodic is on BEGIN, LACP DISABLE or when both sides are passive */ + if (SM_FLAG(port, BEGIN) || !SM_FLAG(port, LACP_ENABLED) || !active) { + timer_cancel(&port->periodic_timer); + timer_force_expired(&port->tx_machine_timer); + SM_FLAG_CLR(port, PARTNER_SHORT_TIMEOUT); + + MODE4_DEBUG("-> NO_PERIODIC ( %s%s%s)\n", +- SM_FLAG(port, BEGIN) ? "begind " : "", ++ SM_FLAG(port, BEGIN) ? "begin " : "", + SM_FLAG(port, LACP_ENABLED) ? "" : "LACP disabled ", +- active ? "LACP active " : "LACP pasive "); ++ active ? "LACP active " : "LACP passive "); + return; + } + +@@ -495,10 +495,10 @@ mux_machine(struct bond_dev_private *internals, uint16_t slave_id) + if ((ACTOR_STATE(port, DISTRIBUTING) || ACTOR_STATE(port, COLLECTING)) && + !PARTNER_STATE(port, SYNCHRONIZATION)) { + /* If in COLLECTING or DISTRIBUTING state and partner becomes out of +- * sync transit to ATACHED state. */ ++ * sync transit to ATTACHED state. */ + ACTOR_STATE_CLR(port, DISTRIBUTING); + ACTOR_STATE_CLR(port, COLLECTING); +- /* Clear actor sync to activate transit ATACHED in condition bellow */ ++ /* Clear actor sync to activate transit ATTACHED in condition bellow */ + ACTOR_STATE_CLR(port, SYNCHRONIZATION); + MODE4_DEBUG("Out of sync -> ATTACHED\n"); + } +@@ -696,7 +696,7 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id) + /* Search for aggregator suitable for this port */ + for (i = 0; i < slaves_count; ++i) { + agg = &bond_mode_8023ad_ports[slaves[i]]; +- /* Skip ports that are not aggreagators */ ++ /* Skip ports that are not aggregators */ + if (agg->aggregator_port_id != slaves[i]) + continue; + +@@ -921,7 +921,7 @@ bond_mode_8023ad_periodic_cb(void *arg) + + SM_FLAG_SET(port, BEGIN); + +- /* LACP is disabled on half duples or link is down */ ++ /* LACP is disabled on half duplex or link is down */ + if (SM_FLAG(port, LACP_ENABLED)) { + /* If port was enabled set it to BEGIN state */ + SM_FLAG_CLR(port, LACP_ENABLED); +@@ -1069,7 +1069,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, + port->partner_state = STATE_LACP_ACTIVE | STATE_AGGREGATION; + port->sm_flags = SM_FLAGS_BEGIN; + +- /* use this port as agregator */ ++ /* use this port as aggregator */ + port->aggregator_port_id = slave_id; + + if (bond_mode_8023ad_register_lacp_mac(slave_id) < 0) { +diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.h b/drivers/net/bonding/rte_eth_bond_8023ad.h +index 11a71a55e5..7eb392f8c8 100644 +--- a/drivers/net/bonding/rte_eth_bond_8023ad.h ++++ b/drivers/net/bonding/rte_eth_bond_8023ad.h +@@ -68,7 +68,7 @@ struct port_params { + struct rte_ether_addr system; + /**< System ID - Slave MAC address, same as bonding MAC address */ + uint16_t key; +- /**< Speed information (implementation dependednt) and duplex. */ ++ /**< Speed information (implementation dependent) and duplex. */ + uint16_t port_priority; + /**< Priority of this (unused in current implementation) */ + uint16_t port_number; +@@ -317,7 +317,7 @@ rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port_id); + * @param port_id Bonding device id + * + * @return +- * agregator mode on success, negative value otherwise ++ * aggregator mode on success, negative value otherwise + */ + int + rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id); +diff --git a/drivers/net/bonding/rte_eth_bond_alb.h b/drivers/net/bonding/rte_eth_bond_alb.h +index 386e70c594..4e9aeda9bc 100644 +--- a/drivers/net/bonding/rte_eth_bond_alb.h ++++ b/drivers/net/bonding/rte_eth_bond_alb.h +@@ -96,7 +96,7 @@ bond_mode_alb_arp_xmit(struct rte_ether_hdr *eth_h, uint16_t offset, + * @param internals Bonding data. + * + * @return +- * Index of slawe on which packet should be sent. ++ * Index of slave on which packet should be sent. + */ + uint16_t + bond_mode_alb_arp_upd(struct client_data *client_info, +diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c +index 84943cffe2..2d5cac6c51 100644 +--- a/drivers/net/bonding/rte_eth_bond_api.c ++++ b/drivers/net/bonding/rte_eth_bond_api.c +@@ -375,7 +375,7 @@ eth_bond_slave_inherit_dev_info_rx_next(struct bond_dev_private *internals, + * value. Thus, the new internal value of default Rx queue offloads + * has to be masked by rx_queue_offload_capa to make sure that only + * commonly supported offloads are preserved from both the previous +- * value and the value being inhereted from the new slave device. ++ * value and the value being inherited from the new slave device. + */ + rxconf_i->offloads = (rxconf_i->offloads | rxconf->offloads) & + internals->rx_queue_offload_capa; +@@ -413,7 +413,7 @@ eth_bond_slave_inherit_dev_info_tx_next(struct bond_dev_private *internals, + * value. Thus, the new internal value of default Tx queue offloads + * has to be masked by tx_queue_offload_capa to make sure that only + * commonly supported offloads are preserved from both the previous +- * value and the value being inhereted from the new slave device. ++ * value and the value being inherited from the new slave device. + */ + txconf_i->offloads = (txconf_i->offloads | txconf->offloads) & + internals->tx_queue_offload_capa; +diff --git a/drivers/net/cnxk/cn10k_ethdev.h b/drivers/net/cnxk/cn10k_ethdev.h +index c2a46ad7ec..0982158c62 100644 +--- a/drivers/net/cnxk/cn10k_ethdev.h ++++ b/drivers/net/cnxk/cn10k_ethdev.h +@@ -53,7 +53,7 @@ struct cn10k_outb_priv_data { + void *userdata; + /* Rlen computation data */ + struct cnxk_ipsec_outb_rlens rlens; +- /* Back pinter to eth sec session */ ++ /* Back pointer to eth sec session */ + struct cnxk_eth_sec_sess *eth_sec; + /* SA index */ + uint32_t sa_idx; +diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h +index 873e1871f9..f3a282f429 100644 +--- a/drivers/net/cnxk/cn10k_tx.h ++++ b/drivers/net/cnxk/cn10k_tx.h +@@ -736,7 +736,7 @@ cn10k_nix_xmit_prepare_tstamp(uintptr_t lmt_addr, const uint64_t *cmd, + /* Retrieving the default desc values */ + lmt[off] = cmd[2]; + +- /* Using compiler barier to avoid voilation of C ++ /* Using compiler barrier to avoid violation of C + * aliasing rules. + */ + rte_compiler_barrier(); +@@ -745,7 +745,7 @@ cn10k_nix_xmit_prepare_tstamp(uintptr_t lmt_addr, const uint64_t *cmd, + /* Packets for which RTE_MBUF_F_TX_IEEE1588_TMST is not set, tx tstamp + * should not be recorded, hence changing the alg type to + * NIX_SENDMEMALG_SET and also changing send mem addr field to +- * next 8 bytes as it corrpt the actual tx tstamp registered ++ * next 8 bytes as it corrupts the actual Tx tstamp registered + * address. + */ + send_mem->w0.subdc = NIX_SUBDC_MEM; +@@ -2254,7 +2254,7 @@ cn10k_nix_xmit_pkts_vector(void *tx_queue, struct rte_mbuf **tx_pkts, + } + + if (flags & NIX_TX_OFFLOAD_TSTAMP_F) { +- /* Tx ol_flag for timestam. */ ++ /* Tx ol_flag for timestamp. */ + const uint64x2_t olf = {RTE_MBUF_F_TX_IEEE1588_TMST, + RTE_MBUF_F_TX_IEEE1588_TMST}; + /* Set send mem alg to SUB. */ +diff --git a/drivers/net/cnxk/cn9k_tx.h b/drivers/net/cnxk/cn9k_tx.h +index 435dde1317..070a7d9439 100644 +--- a/drivers/net/cnxk/cn9k_tx.h ++++ b/drivers/net/cnxk/cn9k_tx.h +@@ -304,7 +304,7 @@ cn9k_nix_xmit_prepare_tstamp(uint64_t *cmd, const uint64_t *send_mem_desc, + /* Retrieving the default desc values */ + cmd[off] = send_mem_desc[6]; + +- /* Using compiler barier to avoid voilation of C ++ /* Using compiler barrier to avoid violation of C + * aliasing rules. + */ + rte_compiler_barrier(); +@@ -313,7 +313,7 @@ cn9k_nix_xmit_prepare_tstamp(uint64_t *cmd, const uint64_t *send_mem_desc, + /* Packets for which RTE_MBUF_F_TX_IEEE1588_TMST is not set, tx tstamp + * should not be recorded, hence changing the alg type to + * NIX_SENDMEMALG_SET and also changing send mem addr field to +- * next 8 bytes as it corrpt the actual tx tstamp registered ++ * next 8 bytes as it corrupts the actual Tx tstamp registered + * address. + */ + send_mem->w0.cn9k.alg = +@@ -1531,7 +1531,7 @@ cn9k_nix_xmit_pkts_vector(void *tx_queue, struct rte_mbuf **tx_pkts, + } + + if (flags & NIX_TX_OFFLOAD_TSTAMP_F) { +- /* Tx ol_flag for timestam. */ ++ /* Tx ol_flag for timestamp. */ + const uint64x2_t olf = {RTE_MBUF_F_TX_IEEE1588_TMST, + RTE_MBUF_F_TX_IEEE1588_TMST}; + /* Set send mem alg to SUB. */ +diff --git a/drivers/net/cnxk/cnxk_ptp.c b/drivers/net/cnxk/cnxk_ptp.c +index 139fea256c..359f9a30ae 100644 +--- a/drivers/net/cnxk/cnxk_ptp.c ++++ b/drivers/net/cnxk/cnxk_ptp.c +@@ -12,7 +12,7 @@ cnxk_nix_read_clock(struct rte_eth_dev *eth_dev, uint64_t *clock) + /* This API returns the raw PTP HI clock value. Since LFs do not + * have direct access to PTP registers and it requires mbox msg + * to AF for this value. In fastpath reading this value for every +- * packet (which involes mbox call) becomes very expensive, hence ++ * packet (which involves mbox call) becomes very expensive, hence + * we should be able to derive PTP HI clock value from tsc by + * using freq_mult and clk_delta calculated during configure stage. + */ +diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c +index edcbba9d7c..6e460dfe2e 100644 +--- a/drivers/net/cxgbe/cxgbe_flow.c ++++ b/drivers/net/cxgbe/cxgbe_flow.c +@@ -1378,7 +1378,7 @@ cxgbe_flow_validate(struct rte_eth_dev *dev, + } + + /* +- * @ret : > 0 filter destroyed succsesfully ++ * @ret : > 0 filter destroyed successfully + * < 0 error destroying filter + * == 1 filter not active / not found + */ +diff --git a/drivers/net/cxgbe/cxgbevf_main.c b/drivers/net/cxgbe/cxgbevf_main.c +index f639612ae4..d0c93f8ac3 100644 +--- a/drivers/net/cxgbe/cxgbevf_main.c ++++ b/drivers/net/cxgbe/cxgbevf_main.c +@@ -44,7 +44,7 @@ static void size_nports_qsets(struct adapter *adapter) + */ + pmask_nports = hweight32(adapter->params.vfres.pmask); + if (pmask_nports < adapter->params.nports) { +- dev_warn(adapter->pdev_dev, "only using %d of %d provissioned" ++ dev_warn(adapter->pdev_dev, "only using %d of %d provisioned" + " virtual interfaces; limited by Port Access Rights" + " mask %#x\n", pmask_nports, adapter->params.nports, + adapter->params.vfres.pmask); +diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c +index f623f3e684..1c76b8e4d0 100644 +--- a/drivers/net/cxgbe/sge.c ++++ b/drivers/net/cxgbe/sge.c +@@ -211,7 +211,7 @@ static inline unsigned int fl_cap(const struct sge_fl *fl) + * @fl: the Free List + * + * Tests specified Free List to see whether the number of buffers +- * available to the hardware has falled below our "starvation" ++ * available to the hardware has fallen below our "starvation" + * threshold. + */ + static inline bool fl_starving(const struct adapter *adapter, +@@ -678,7 +678,7 @@ static void write_sgl(struct rte_mbuf *mbuf, struct sge_txq *q, + * @q: the Tx queue + * @n: number of new descriptors to give to HW + * +- * Ring the doorbel for a Tx queue. ++ * Ring the doorbell for a Tx queue. + */ + static inline void ring_tx_db(struct adapter *adap, struct sge_txq *q) + { +@@ -877,7 +877,7 @@ static inline void ship_tx_pkt_coalesce_wr(struct adapter *adap, + } + + /** +- * should_tx_packet_coalesce - decides wether to coalesce an mbuf or not ++ * should_tx_packet_coalesce - decides whether to coalesce an mbuf or not + * @txq: tx queue where the mbuf is sent + * @mbuf: mbuf to be sent + * @nflits: return value for number of flits needed +@@ -1846,7 +1846,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, + * for its status page) along with the associated software + * descriptor ring. The free list size needs to be a multiple + * of the Egress Queue Unit and at least 2 Egress Units larger +- * than the SGE's Egress Congrestion Threshold ++ * than the SGE's Egress Congestion Threshold + * (fl_starve_thres - 1). + */ + if (fl->size < s->fl_starve_thres - 1 + 2 * 8) +diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c +index e49f765434..2c2c4e4ebb 100644 +--- a/drivers/net/dpaa/dpaa_ethdev.c ++++ b/drivers/net/dpaa/dpaa_ethdev.c +@@ -1030,7 +1030,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, + QM_FQCTRL_CTXASTASHING | + QM_FQCTRL_PREFERINCACHE; + opts.fqd.context_a.stashing.exclusive = 0; +- /* In muticore scenario stashing becomes a bottleneck on LS1046. ++ /* In multicore scenario stashing becomes a bottleneck on LS1046. + * So do not enable stashing in this case + */ + if (dpaa_svr_family != SVR_LS1046A_FAMILY) +@@ -1866,7 +1866,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) + + dpaa_intf->name = dpaa_device->name; + +- /* save fman_if & cfg in the interface struture */ ++ /* save fman_if & cfg in the interface structure */ + eth_dev->process_private = fman_intf; + dpaa_intf->ifid = dev_id; + dpaa_intf->cfg = cfg; +@@ -2169,7 +2169,7 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv, + if (dpaa_svr_family == SVR_LS1043A_FAMILY) + dpaa_push_mode_max_queue = 0; + +- /* if push mode queues to be enabled. Currenly we are allowing ++ /* if push mode queues to be enabled. Currently we are allowing + * only one queue per thread. + */ + if (getenv("DPAA_PUSH_QUEUES_NUMBER")) { +diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c +index ffac6ce3e2..956fe946fa 100644 +--- a/drivers/net/dpaa/dpaa_rxtx.c ++++ b/drivers/net/dpaa/dpaa_rxtx.c +@@ -600,8 +600,8 @@ void dpaa_rx_cb_prepare(struct qm_dqrr_entry *dq, void **bufs) + void *ptr = rte_dpaa_mem_ptov(qm_fd_addr(&dq->fd)); + + /* In case of LS1046, annotation stashing is disabled due to L2 cache +- * being bottleneck in case of multicore scanario for this platform. +- * So we prefetch the annoation beforehand, so that it is available ++ * being bottleneck in case of multicore scenario for this platform. ++ * So we prefetch the annotation beforehand, so that it is available + * in cache when accessed. + */ + rte_prefetch0((void *)((uint8_t *)ptr + DEFAULT_RX_ICEOF)); +diff --git a/drivers/net/dpaa/fmlib/fm_ext.h b/drivers/net/dpaa/fmlib/fm_ext.h +index 27c9fb471e..8e7153bdaf 100644 +--- a/drivers/net/dpaa/fmlib/fm_ext.h ++++ b/drivers/net/dpaa/fmlib/fm_ext.h +@@ -176,7 +176,7 @@ typedef struct t_fm_prs_result { + #define FM_FD_ERR_PRS_HDR_ERR 0x00000020 + /**< Header error was identified during parsing */ + #define FM_FD_ERR_BLOCK_LIMIT_EXCEEDED 0x00000008 +- /**< Frame parsed beyind 256 first bytes */ ++ /**< Frame parsed beyond 256 first bytes */ + + #define FM_FD_TX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \ + FM_FD_ERR_LENGTH | \ +diff --git a/drivers/net/dpaa/fmlib/fm_pcd_ext.h b/drivers/net/dpaa/fmlib/fm_pcd_ext.h +index 8be3885fbc..3802b42916 100644 +--- a/drivers/net/dpaa/fmlib/fm_pcd_ext.h ++++ b/drivers/net/dpaa/fmlib/fm_pcd_ext.h +@@ -276,7 +276,7 @@ typedef struct ioc_fm_pcd_counters_params_t { + } ioc_fm_pcd_counters_params_t; + + /* +- * @Description structure for FM exception definitios ++ * @Description structure for FM exception definitions + */ + typedef struct ioc_fm_pcd_exception_params_t { + ioc_fm_pcd_exceptions exception; /**< The requested exception */ +@@ -883,7 +883,7 @@ typedef enum ioc_fm_pcd_manip_hdr_rmv_specific_l2 { + e_IOC_FM_PCD_MANIP_HDR_RMV_ETHERNET, /**< Ethernet/802.3 MAC */ + e_IOC_FM_PCD_MANIP_HDR_RMV_STACKED_QTAGS, /**< stacked QTags */ + e_IOC_FM_PCD_MANIP_HDR_RMV_ETHERNET_AND_MPLS, +- /**< MPLS and Ethernet/802.3 MAC header unitl the header ++ /**< MPLS and Ethernet/802.3 MAC header until the header + * which follows the MPLS header + */ + e_IOC_FM_PCD_MANIP_HDR_RMV_MPLS +@@ -3293,7 +3293,7 @@ typedef struct ioc_fm_pcd_cc_tbl_get_stats_t { + /* + * @Function fm_pcd_net_env_characteristics_delete + * +- * @Description Deletes a set of Network Environment Charecteristics. ++ * @Description Deletes a set of Network Environment Characteristics. + * + * @Param[in] ioc_fm_obj_t The id of a Network Environment object. + * +@@ -3493,7 +3493,7 @@ typedef struct ioc_fm_pcd_cc_tbl_get_stats_t { + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() not only of +- * the relevnt node but also the node that points to this node. ++ * the relevant node but also the node that points to this node. + */ + #define FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_AND_NEXT_ENGINE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(35), \ +diff --git a/drivers/net/dpaa/fmlib/fm_port_ext.h b/drivers/net/dpaa/fmlib/fm_port_ext.h +index 6f5479fbe1..bb2e00222e 100644 +--- a/drivers/net/dpaa/fmlib/fm_port_ext.h ++++ b/drivers/net/dpaa/fmlib/fm_port_ext.h +@@ -498,7 +498,7 @@ typedef struct ioc_fm_port_pcd_prs_params_t { + /**< Number of bytes from beginning of packet to start parsing + */ + ioc_net_header_type first_prs_hdr; +- /**< The type of the first header axpected at 'parsing_offset' ++ /**< The type of the first header expected at 'parsing_offset' + */ + bool include_in_prs_statistics; + /**< TRUE to include this port in the parser statistics */ +@@ -524,7 +524,7 @@ typedef struct ioc_fm_port_pcd_prs_params_t { + } ioc_fm_port_pcd_prs_params_t; + + /* +- * @Description A structure for defining coarse alassification parameters ++ * @Description A structure for defining coarse classification parameters + * (Must match t_fm_portPcdCcParams defined in fm_port_ext.h) + */ + typedef struct ioc_fm_port_pcd_cc_params_t { +@@ -602,7 +602,7 @@ typedef struct ioc_fm_pcd_prs_start_t { + /**< Number of bytes from beginning of packet to start parsing + */ + ioc_net_header_type first_prs_hdr; +- /**< The type of the first header axpected at 'parsing_offset' ++ /**< The type of the first header expected at 'parsing_offset' + */ + } ioc_fm_pcd_prs_start_t; + +@@ -1356,7 +1356,7 @@ typedef uint32_t fm_port_frame_err_select_t; + #define FM_PORT_FRM_ERR_PRS_HDR_ERR FM_FD_ERR_PRS_HDR_ERR + /**< Header error was identified during parsing */ + #define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED FM_FD_ERR_BLOCK_LIMIT_EXCEEDED +- /**< Frame parsed beyind 256 first bytes */ ++ /**< Frame parsed beyond 256 first bytes */ + #define FM_PORT_FRM_ERR_PROCESS_TIMEOUT 0x00000001 + /**< FPM Frame Processing Timeout Exceeded */ + /* @} */ +@@ -1390,7 +1390,7 @@ typedef void (t_fm_port_exception_callback) (t_handle h_app, + * @Param[in] length length of received data + * @Param[in] status receive status and errors + * @Param[in] position position of buffer in frame +- * @Param[in] h_buf_context A handle of the user acossiated with this buffer ++ * @Param[in] h_buf_context A handle of the user associated with this buffer + * + * @Retval e_RX_STORE_RESPONSE_CONTINUE + * order the driver to continue Rx operation for all ready data. +@@ -1414,7 +1414,7 @@ typedef e_rx_store_response(t_fm_port_im_rx_store_callback) (t_handle h_app, + * @Param[in] p_data A pointer to data received + * @Param[in] status transmit status and errors + * @Param[in] last_buffer is last buffer in frame +- * @Param[in] h_buf_context A handle of the user acossiated with this buffer ++ * @Param[in] h_buf_context A handle of the user associated with this buffer + */ + typedef void (t_fm_port_im_tx_conf_callback) (t_handle h_app, + uint8_t *p_data, +@@ -2585,7 +2585,7 @@ typedef struct t_fm_port_congestion_grps { + bool pfc_prio_enable[FM_NUM_CONG_GRPS][FM_MAX_PFC_PRIO]; + /**< a matrix that represents the map between the CG ids + * defined in 'congestion_grps_to_consider' to the +- * priorties mapping array. ++ * priorities mapping array. + */ + } t_fm_port_congestion_grps; + +diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c +index a3706439d5..2b04f14168 100644 +--- a/drivers/net/dpaa2/dpaa2_ethdev.c ++++ b/drivers/net/dpaa2/dpaa2_ethdev.c +@@ -143,7 +143,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) + PMD_INIT_FUNC_TRACE(); + + if (mask & RTE_ETH_VLAN_FILTER_MASK) { +- /* VLAN Filter not avaialble */ ++ /* VLAN Filter not available */ + if (!priv->max_vlan_filters) { + DPAA2_PMD_INFO("VLAN filter not available"); + return -ENOTSUP; +@@ -916,7 +916,7 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev, + cong_notif_cfg.units = DPNI_CONGESTION_UNIT_FRAMES; + cong_notif_cfg.threshold_entry = nb_tx_desc; + /* Notify that the queue is not congested when the data in +- * the queue is below this thershold.(90% of value) ++ * the queue is below this threshold.(90% of value) + */ + cong_notif_cfg.threshold_exit = (nb_tx_desc * 9) / 10; + cong_notif_cfg.message_ctx = 0; +@@ -1058,7 +1058,7 @@ dpaa2_supported_ptypes_get(struct rte_eth_dev *dev) + * Dpaa2 link Interrupt handler + * + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +@@ -2236,7 +2236,7 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, + ocfg.oa = 1; + /* Late arrival window size disabled */ + ocfg.olws = 0; +- /* ORL resource exhaustaion advance NESN disabled */ ++ /* ORL resource exhaustion advance NESN disabled */ + ocfg.oeane = 0; + /* Loose ordering enabled */ + ocfg.oloe = 1; +@@ -2720,13 +2720,13 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) + } + eth_dev->tx_pkt_burst = dpaa2_dev_tx; + +- /*Init fields w.r.t. classficaition*/ ++ /* Init fields w.r.t. classification */ + memset(&priv->extract.qos_key_extract, 0, + sizeof(struct dpaa2_key_extract)); + priv->extract.qos_extract_param = (size_t)rte_malloc(NULL, 256, 64); + if (!priv->extract.qos_extract_param) { + DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow " +- " classificaiton ", ret); ++ " classification ", ret); + goto init_err; + } + priv->extract.qos_key_extract.key_info.ipv4_src_offset = +@@ -2744,7 +2744,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) + priv->extract.tc_extract_param[i] = + (size_t)rte_malloc(NULL, 256, 64); + if (!priv->extract.tc_extract_param[i]) { +- DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow classificaiton", ++ DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow classification", + ret); + goto init_err; + } +diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h +index c5e9267bf0..e27239e256 100644 +--- a/drivers/net/dpaa2/dpaa2_ethdev.h ++++ b/drivers/net/dpaa2/dpaa2_ethdev.h +@@ -117,7 +117,7 @@ extern int dpaa2_timestamp_dynfield_offset; + + #define DPAA2_FLOW_MAX_KEY_SIZE 16 + +-/*Externaly defined*/ ++/* Externally defined */ + extern const struct rte_flow_ops dpaa2_flow_ops; + + extern const struct rte_tm_ops dpaa2_tm_ops; +diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c +index 84fe37a7c0..bf55eb70a3 100644 +--- a/drivers/net/dpaa2/dpaa2_flow.c ++++ b/drivers/net/dpaa2/dpaa2_flow.c +@@ -1451,7 +1451,7 @@ dpaa2_configure_flow_generic_ip( + flow, pattern, &local_cfg, + device_configured, group); + if (ret) { +- DPAA2_PMD_ERR("IP discrimation failed!"); ++ DPAA2_PMD_ERR("IP discrimination failed!"); + return -1; + } + +@@ -3349,7 +3349,7 @@ dpaa2_flow_verify_action( + (actions[j].conf); + if (rss_conf->queue_num > priv->dist_queues) { + DPAA2_PMD_ERR( +- "RSS number exceeds the distrbution size"); ++ "RSS number exceeds the distribution size"); + return -ENOTSUP; + } + for (i = 0; i < (int)rss_conf->queue_num; i++) { +@@ -3596,7 +3596,7 @@ dpaa2_generic_flow_set(struct rte_flow *flow, + qos_cfg.keep_entries = true; + qos_cfg.key_cfg_iova = + (size_t)priv->extract.qos_extract_param; +- /* QoS table is effecitive for multiple TCs.*/ ++ /* QoS table is effective for multiple TCs. */ + if (priv->num_rx_tc > 1) { + ret = dpni_set_qos_table(dpni, CMD_PRI_LOW, + priv->token, &qos_cfg); +@@ -3655,7 +3655,7 @@ dpaa2_generic_flow_set(struct rte_flow *flow, + 0, 0); + if (ret < 0) { + DPAA2_PMD_ERR( +- "Error in addnig entry to QoS table(%d)", ret); ++ "Error in adding entry to QoS table(%d)", ret); + return ret; + } + } +diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c +index d347f4df51..cd2f7b8aa5 100644 +--- a/drivers/net/dpaa2/dpaa2_mux.c ++++ b/drivers/net/dpaa2/dpaa2_mux.c +@@ -95,7 +95,7 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id, + mask_iova = (void *)((size_t)key_iova + DIST_PARAM_IOVA_SIZE); + + /* Currently taking only IP protocol as an extract type. +- * This can be exended to other fields using pattern->type. ++ * This can be extended to other fields using pattern->type. + */ + memset(&kg_cfg, 0, sizeof(struct dpkg_profile_cfg)); + +diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c +index c65589a5f3..90b971b4bf 100644 +--- a/drivers/net/dpaa2/dpaa2_rxtx.c ++++ b/drivers/net/dpaa2/dpaa2_rxtx.c +@@ -714,7 +714,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) + rte_prefetch0((void *)(size_t)(dq_storage + 1)); + + /* Prepare next pull descriptor. This will give space for the +- * prefething done on DQRR entries ++ * prefetching done on DQRR entries + */ + q_storage->toggle ^= 1; + dq_storage1 = q_storage->dq_storage[q_storage->toggle]; +@@ -1510,7 +1510,7 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) + if (*dpaa2_seqn(*bufs)) { + /* Use only queue 0 for Tx in case of atomic/ + * ordered packets as packets can get unordered +- * when being tranmitted out from the interface ++ * when being transmitted out from the interface + */ + dpaa2_set_enqueue_descriptor(order_sendq, + (*bufs), +@@ -1738,7 +1738,7 @@ dpaa2_dev_loopback_rx(void *queue, + rte_prefetch0((void *)(size_t)(dq_storage + 1)); + + /* Prepare next pull descriptor. This will give space for the +- * prefething done on DQRR entries ++ * prefetching done on DQRR entries + */ + q_storage->toggle ^= 1; + dq_storage1 = q_storage->dq_storage[q_storage->toggle]; +diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpni.h +index 469ab9b3d4..3b9bffeed7 100644 +--- a/drivers/net/dpaa2/mc/fsl_dpni.h ++++ b/drivers/net/dpaa2/mc/fsl_dpni.h +@@ -93,7 +93,7 @@ struct fsl_mc_io; + */ + #define DPNI_OPT_OPR_PER_TC 0x000080 + /** +- * All Tx traffic classes will use a single sender (ignore num_queueus for tx) ++ * All Tx traffic classes will use a single sender (ignore num_queues for tx) + */ + #define DPNI_OPT_SINGLE_SENDER 0x000100 + /** +@@ -617,7 +617,7 @@ int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, + * @page_3.ceetm_reject_bytes: Cumulative count of the number of bytes in all + * frames whose enqueue was rejected + * @page_3.ceetm_reject_frames: Cumulative count of all frame enqueues rejected +- * @page_4: congestion point drops for seleted TC ++ * @page_4: congestion point drops for selected TC + * @page_4.cgr_reject_frames: number of rejected frames due to congestion point + * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point + * @page_5: policer statistics per TC +@@ -1417,7 +1417,7 @@ int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io, + * dpkg_prepare_key_cfg() + * @discard_on_miss: Set to '1' to discard frames in case of no match (miss); + * '0' to use the 'default_tc' in such cases +- * @keep_entries: if set to one will not delele existing table entries. This ++ * @keep_entries: if set to one will not delete existing table entries. This + * option will work properly only for dpni objects created with + * DPNI_OPT_HAS_KEY_MASKING option. All previous QoS entries must + * be compatible with new key composition rule. +@@ -1516,7 +1516,7 @@ int dpni_clear_qos_table(struct fsl_mc_io *mc_io, + * @flow_id: Identifies the Rx queue used for matching traffic. Supported + * values are in range 0 to num_queue-1. + * @redirect_obj_token: token that identifies the object where frame is +- * redirected when this rule is hit. This paraneter is used only when one of the ++ * redirected when this rule is hit. This parameter is used only when one of the + * flags DPNI_FS_OPT_REDIRECT_TO_DPNI_RX or DPNI_FS_OPT_REDIRECT_TO_DPNI_TX is + * set. + * The token is obtained using dpni_open() API call. The object must stay +@@ -1797,7 +1797,7 @@ int dpni_load_sw_sequence(struct fsl_mc_io *mc_io, + struct dpni_load_ss_cfg *cfg); + + /** +- * dpni_eanble_sw_sequence() - Enables a software sequence in the parser ++ * dpni_enable_sw_sequence() - Enables a software sequence in the parser + * profile + * corresponding to the ingress or egress of the DPNI. + * @mc_io: Pointer to MC portal's I/O object +diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h +index a548ae2ccb..718a9746ed 100644 +--- a/drivers/net/e1000/e1000_ethdev.h ++++ b/drivers/net/e1000/e1000_ethdev.h +@@ -103,7 +103,7 @@ + * Maximum number of Ring Descriptors. + * + * Since RDLEN/TDLEN should be multiple of 128 bytes, the number of ring +- * desscriptors should meet the following condition: ++ * descriptors should meet the following condition: + * (num_ring_desc * sizeof(struct e1000_rx/tx_desc)) % 128 == 0 + */ + #define E1000_MIN_RING_DESC 32 +@@ -252,7 +252,7 @@ struct igb_rte_flow_rss_conf { + }; + + /* +- * Structure to store filters'info. ++ * Structure to store filters' info. + */ + struct e1000_filter_info { + uint8_t ethertype_mask; /* Bit mask for every used ethertype filter */ +diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c +index 31c4870086..794496abfc 100644 +--- a/drivers/net/e1000/em_ethdev.c ++++ b/drivers/net/e1000/em_ethdev.c +@@ -1058,8 +1058,8 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) + + /* + * Starting with 631xESB hw supports 2 TX/RX queues per port. +- * Unfortunatelly, all these nics have just one TX context. +- * So we have few choises for TX: ++ * Unfortunately, all these nics have just one TX context. ++ * So we have few choices for TX: + * - Use just one TX queue. + * - Allow cksum offload only for one TX queue. + * - Don't allow TX cksum offload at all. +@@ -1068,7 +1068,7 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) + * (Multiple Receive Queues are mutually exclusive with UDP + * fragmentation and are not supported when a legacy receive + * descriptor format is used). +- * Which means separate RX routinies - as legacy nics (82540, 82545) ++ * Which means separate RX routines - as legacy nics (82540, 82545) + * don't support extended RXD. + * To avoid it we support just one RX queue for now (no RSS). + */ +@@ -1558,7 +1558,7 @@ eth_em_interrupt_get_status(struct rte_eth_dev *dev) + } + + /* +- * It executes link_update after knowing an interrupt is prsent. ++ * It executes link_update after knowing an interrupt is present. + * + * @param dev + * Pointer to struct rte_eth_dev. +@@ -1616,7 +1616,7 @@ eth_em_interrupt_action(struct rte_eth_dev *dev, + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c +index 39262502bb..cea5b490ba 100644 +--- a/drivers/net/e1000/em_rxtx.c ++++ b/drivers/net/e1000/em_rxtx.c +@@ -141,7 +141,7 @@ union em_vlan_macip { + struct em_ctx_info { + uint64_t flags; /**< ol_flags related to context build. */ + uint32_t cmp_mask; /**< compare mask */ +- union em_vlan_macip hdrlen; /**< L2 and L3 header lenghts */ ++ union em_vlan_macip hdrlen; /**< L2 and L3 header lengths */ + }; + + /** +@@ -829,7 +829,7 @@ eth_em_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + * register. + * Update the RDT with the value of the last processed RX descriptor + * minus 1, to guarantee that the RDT register is never equal to the +- * RDH register, which creates a "full" ring situtation from the ++ * RDH register, which creates a "full" ring situation from the + * hardware point of view... + */ + nb_hold = (uint16_t) (nb_hold + rxq->nb_rx_hold); +@@ -1074,7 +1074,7 @@ eth_em_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + * register. + * Update the RDT with the value of the last processed RX descriptor + * minus 1, to guarantee that the RDT register is never equal to the +- * RDH register, which creates a "full" ring situtation from the ++ * RDH register, which creates a "full" ring situation from the + * hardware point of view... + */ + nb_hold = (uint16_t) (nb_hold + rxq->nb_rx_hold); +diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c +index 3ee16c15fe..a9c18b27e8 100644 +--- a/drivers/net/e1000/igb_ethdev.c ++++ b/drivers/net/e1000/igb_ethdev.c +@@ -1149,7 +1149,7 @@ eth_igb_configure(struct rte_eth_dev *dev) + if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) + dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; + +- /* multipe queue mode checking */ ++ /* multiple queue mode checking */ + ret = igb_check_mq_mode(dev); + if (ret != 0) { + PMD_DRV_LOG(ERR, "igb_check_mq_mode fails with %d.", +@@ -1265,7 +1265,7 @@ eth_igb_start(struct rte_eth_dev *dev) + } + } + +- /* confiugre msix for rx interrupt */ ++ /* configure MSI-X for Rx interrupt */ + eth_igb_configure_msix_intr(dev); + + /* Configure for OS presence */ +@@ -2819,7 +2819,7 @@ eth_igb_interrupt_get_status(struct rte_eth_dev *dev) + } + + /* +- * It executes link_update after knowing an interrupt is prsent. ++ * It executes link_update after knowing an interrupt is present. + * + * @param dev + * Pointer to struct rte_eth_dev. +@@ -2889,7 +2889,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev, + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +@@ -3787,7 +3787,7 @@ igb_inject_2uple_filter(struct rte_eth_dev *dev, + * + * @param + * dev: Pointer to struct rte_eth_dev. +- * ntuple_filter: ponter to the filter that will be added. ++ * ntuple_filter: pointer to the filter that will be added. + * + * @return + * - On success, zero. +@@ -3868,7 +3868,7 @@ igb_delete_2tuple_filter(struct rte_eth_dev *dev, + * + * @param + * dev: Pointer to struct rte_eth_dev. +- * ntuple_filter: ponter to the filter that will be removed. ++ * ntuple_filter: pointer to the filter that will be removed. + * + * @return + * - On success, zero. +@@ -4226,7 +4226,7 @@ igb_inject_5tuple_filter_82576(struct rte_eth_dev *dev, + * + * @param + * dev: Pointer to struct rte_eth_dev. +- * ntuple_filter: ponter to the filter that will be added. ++ * ntuple_filter: pointer to the filter that will be added. + * + * @return + * - On success, zero. +@@ -4313,7 +4313,7 @@ igb_delete_5tuple_filter_82576(struct rte_eth_dev *dev, + * + * @param + * dev: Pointer to struct rte_eth_dev. +- * ntuple_filter: ponter to the filter that will be removed. ++ * ntuple_filter: pointer to the filter that will be removed. + * + * @return + * - On success, zero. +@@ -4831,7 +4831,7 @@ igb_timesync_disable(struct rte_eth_dev *dev) + /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */ + E1000_WRITE_REG(hw, E1000_ETQF(E1000_ETQF_FILTER_1588), 0); + +- /* Stop incrementating the System Time registers. */ ++ /* Stop incrementing the System Time registers. */ + E1000_WRITE_REG(hw, E1000_TIMINCA, 0); + + return 0; +diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c +index e72376f69c..e46697b6a1 100644 +--- a/drivers/net/e1000/igb_flow.c ++++ b/drivers/net/e1000/igb_flow.c +@@ -57,7 +57,7 @@ struct igb_flex_filter_list igb_filter_flex_list; + struct igb_rss_filter_list igb_filter_rss_list; + + /** +- * Please aware there's an asumption for all the parsers. ++ * Please be aware there's an assumption for all the parsers. + * rte_flow_item is using big endian, rte_flow_attr and + * rte_flow_action are using CPU order. + * Because the pattern is used to describe the packets, +@@ -1608,7 +1608,7 @@ igb_flow_create(struct rte_eth_dev *dev, + + /** + * Check if the flow rule is supported by igb. +- * It only checkes the format. Don't guarantee the rule can be programmed into ++ * It only checks the format. Don't guarantee the rule can be programmed into + * the HW. Because there can be no enough room for the rule. + */ + static int +diff --git a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c +index fe355ef6b3..3f3fd0d61e 100644 +--- a/drivers/net/e1000/igb_pf.c ++++ b/drivers/net/e1000/igb_pf.c +@@ -155,7 +155,7 @@ int igb_pf_host_configure(struct rte_eth_dev *eth_dev) + else + E1000_WRITE_REG(hw, E1000_DTXSWC, E1000_DTXSWC_VMDQ_LOOPBACK_EN); + +- /* clear VMDq map to perment rar 0 */ ++ /* clear VMDq map to permanent rar 0 */ + rah = E1000_READ_REG(hw, E1000_RAH(0)); + rah &= ~ (0xFF << E1000_RAH_POOLSEL_SHIFT); + E1000_WRITE_REG(hw, E1000_RAH(0), rah); +diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c +index 4a311a7b18..f32dee46df 100644 +--- a/drivers/net/e1000/igb_rxtx.c ++++ b/drivers/net/e1000/igb_rxtx.c +@@ -150,7 +150,7 @@ union igb_tx_offload { + (TX_MACIP_LEN_CMP_MASK | TX_TCP_LEN_CMP_MASK | TX_TSO_MSS_CMP_MASK) + + /** +- * Strucutre to check if new context need be built ++ * Structure to check if new context need be built + */ + struct igb_advctx_info { + uint64_t flags; /**< ol_flags related to context build. */ +@@ -967,7 +967,7 @@ eth_igb_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + * register. + * Update the RDT with the value of the last processed RX descriptor + * minus 1, to guarantee that the RDT register is never equal to the +- * RDH register, which creates a "full" ring situtation from the ++ * RDH register, which creates a "full" ring situation from the + * hardware point of view... + */ + nb_hold = (uint16_t) (nb_hold + rxq->nb_rx_hold); +@@ -1229,7 +1229,7 @@ eth_igb_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + * register. + * Update the RDT with the value of the last processed RX descriptor + * minus 1, to guarantee that the RDT register is never equal to the +- * RDH register, which creates a "full" ring situtation from the ++ * RDH register, which creates a "full" ring situation from the + * hardware point of view... + */ + nb_hold = (uint16_t) (nb_hold + rxq->nb_rx_hold); +@@ -1252,7 +1252,7 @@ eth_igb_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + * Maximum number of Ring Descriptors. + * + * Since RDLEN/TDLEN should be multiple of 128bytes, the number of ring +- * desscriptors should meet the following condition: ++ * descriptors should meet the following condition: + * (num_ring_desc * sizeof(struct e1000_rx/tx_desc)) % 128 == 0 + */ + +@@ -1350,7 +1350,7 @@ igb_tx_done_cleanup(struct igb_tx_queue *txq, uint32_t free_cnt) + sw_ring[tx_id].last_id = tx_id; + } + +- /* Move to next segemnt. */ ++ /* Move to next segment. */ + tx_id = sw_ring[tx_id].next_id; + + } while (tx_id != tx_next); +@@ -1383,7 +1383,7 @@ igb_tx_done_cleanup(struct igb_tx_queue *txq, uint32_t free_cnt) + + /* Walk the list and find the next mbuf, if any. */ + do { +- /* Move to next segemnt. */ ++ /* Move to next segment. */ + tx_id = sw_ring[tx_id].next_id; + + if (sw_ring[tx_id].mbuf) +@@ -2146,7 +2146,7 @@ igb_vmdq_rx_hw_configure(struct rte_eth_dev *dev) + + igb_rss_disable(dev); + +- /* RCTL: eanble VLAN filter */ ++ /* RCTL: enable VLAN filter */ + rctl = E1000_READ_REG(hw, E1000_RCTL); + rctl |= E1000_RCTL_VFE; + E1000_WRITE_REG(hw, E1000_RCTL, rctl); +diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c +index 634c97acf6..dce26cfa48 100644 +--- a/drivers/net/ena/ena_ethdev.c ++++ b/drivers/net/ena/ena_ethdev.c +@@ -1408,7 +1408,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) + ++rxq->rx_stats.refill_partial; + } + +- /* When we submitted free recources to device... */ ++ /* When we submitted free resources to device... */ + if (likely(i > 0)) { + /* ...let HW know that it can fill buffers with data. */ + ena_com_write_sq_doorbell(rxq->ena_com_io_sq); +diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h +index 865e1241e0..f99e4f3984 100644 +--- a/drivers/net/ena/ena_ethdev.h ++++ b/drivers/net/ena/ena_ethdev.h +@@ -42,7 +42,7 @@ + + /* While processing submitted and completed descriptors (rx and tx path + * respectively) in a loop it is desired to: +- * - perform batch submissions while populating sumbissmion queue ++ * - perform batch submissions while populating submission queue + * - avoid blocking transmission of other packets during cleanup phase + * Hence the utilization ratio of 1/8 of a queue size or max value if the size + * of the ring is very big - like 8k Rx rings. +diff --git a/drivers/net/enetfec/enet_regs.h b/drivers/net/enetfec/enet_regs.h +index a300c6f8bc..c9400957f8 100644 +--- a/drivers/net/enetfec/enet_regs.h ++++ b/drivers/net/enetfec/enet_regs.h +@@ -12,7 +12,7 @@ + #define RX_BD_CR ((ushort)0x0004) /* CRC or Frame error */ + #define RX_BD_SH ((ushort)0x0008) /* Reserved */ + #define RX_BD_NO ((ushort)0x0010) /* Rcvd non-octet aligned frame */ +-#define RX_BD_LG ((ushort)0x0020) /* Rcvd frame length voilation */ ++#define RX_BD_LG ((ushort)0x0020) /* Rcvd frame length violation */ + #define RX_BD_FIRST ((ushort)0x0400) /* Reserved */ + #define RX_BD_LAST ((ushort)0x0800) /* last buffer in the frame */ + #define RX_BD_INT 0x00800000 +diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c +index 33147169ba..cf51793cfe 100644 +--- a/drivers/net/enic/enic_flow.c ++++ b/drivers/net/enic/enic_flow.c +@@ -405,7 +405,7 @@ enic_copy_item_ipv4_v1(struct copy_item_args *arg) + return ENOTSUP; + } + +- /* check that the suppied mask exactly matches capabilty */ ++ /* check that the supplied mask exactly matches capability */ + if (!mask_exact_match((const uint8_t *)&supported_mask, + (const uint8_t *)item->mask, sizeof(*mask))) { + ENICPMD_LOG(ERR, "IPv4 exact match mask"); +@@ -443,7 +443,7 @@ enic_copy_item_udp_v1(struct copy_item_args *arg) + return ENOTSUP; + } + +- /* check that the suppied mask exactly matches capabilty */ ++ /* check that the supplied mask exactly matches capability */ + if (!mask_exact_match((const uint8_t *)&supported_mask, + (const uint8_t *)item->mask, sizeof(*mask))) { + ENICPMD_LOG(ERR, "UDP exact match mask"); +@@ -482,7 +482,7 @@ enic_copy_item_tcp_v1(struct copy_item_args *arg) + return ENOTSUP; + } + +- /* check that the suppied mask exactly matches capabilty */ ++ /* check that the supplied mask exactly matches capability */ + if (!mask_exact_match((const uint8_t *)&supported_mask, + (const uint8_t *)item->mask, sizeof(*mask))) { + ENICPMD_LOG(ERR, "TCP exact match mask"); +@@ -1044,14 +1044,14 @@ fixup_l5_layer(struct enic *enic, struct filter_generic_1 *gp, + } + + /** +- * Build the intenal enic filter structure from the provided pattern. The ++ * Build the internal enic filter structure from the provided pattern. The + * pattern is validated as the items are copied. + * + * @param pattern[in] + * @param items_info[in] + * Info about this NICs item support, like valid previous items. + * @param enic_filter[out] +- * NIC specfilc filters derived from the pattern. ++ * NIC specific filters derived from the pattern. + * @param error[out] + */ + static int +@@ -1123,12 +1123,12 @@ enic_copy_filter(const struct rte_flow_item pattern[], + } + + /** +- * Build the intenal version 1 NIC action structure from the provided pattern. ++ * Build the internal version 1 NIC action structure from the provided pattern. + * The pattern is validated as the items are copied. + * + * @param actions[in] + * @param enic_action[out] +- * NIC specfilc actions derived from the actions. ++ * NIC specific actions derived from the actions. + * @param error[out] + */ + static int +@@ -1170,12 +1170,12 @@ enic_copy_action_v1(__rte_unused struct enic *enic, + } + + /** +- * Build the intenal version 2 NIC action structure from the provided pattern. ++ * Build the internal version 2 NIC action structure from the provided pattern. + * The pattern is validated as the items are copied. + * + * @param actions[in] + * @param enic_action[out] +- * NIC specfilc actions derived from the actions. ++ * NIC specific actions derived from the actions. + * @param error[out] + */ + static int +diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c +index ae43f36bc0..bef842d460 100644 +--- a/drivers/net/enic/enic_fm_flow.c ++++ b/drivers/net/enic/enic_fm_flow.c +@@ -721,7 +721,7 @@ enic_fm_copy_item_gtp(struct copy_item_args *arg) + } + + /* NIC does not support GTP tunnels. No Items are allowed after this. +- * This prevents the specificaiton of further items. ++ * This prevents the specification of further items. + */ + arg->header_level = 0; + +@@ -733,7 +733,7 @@ enic_fm_copy_item_gtp(struct copy_item_args *arg) + + /* + * Use the raw L4 buffer to match GTP as fm_header_set does not have +- * GTP header. UDP dst port must be specifiec. Using the raw buffer ++ * GTP header. UDP dst port must be specific. Using the raw buffer + * does not affect such UDP item, since we skip UDP in the raw buffer. + */ + fm_data->fk_header_select |= FKH_L4RAW; +@@ -1846,7 +1846,7 @@ enic_fm_dump_tcam_actions(const struct fm_action *fm_action) + /* Remove trailing comma */ + if (buf[0]) + *(bp - 1) = '\0'; +- ENICPMD_LOG(DEBUG, " Acions: %s", buf); ++ ENICPMD_LOG(DEBUG, " Actions: %s", buf); + } + + static int +@@ -2364,7 +2364,7 @@ enic_action_handle_get(struct enic_flowman *fm, struct fm_action *action_in, + if (ret < 0 && ret != -ENOENT) + return rte_flow_error_set(error, -ret, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, +- NULL, "enic: rte_hash_lookup(aciton)"); ++ NULL, "enic: rte_hash_lookup(action)"); + + if (ret == -ENOENT) { + /* Allocate a new action on the NIC. */ +@@ -2435,7 +2435,7 @@ __enic_fm_flow_add_entry(struct enic_flowman *fm, + + ENICPMD_FUNC_TRACE(); + +- /* Get or create an aciton handle. */ ++ /* Get or create an action handle. */ + ret = enic_action_handle_get(fm, action_in, error, &ah); + if (ret) + return ret; +diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c +index 7f84b5f935..97d97ea793 100644 +--- a/drivers/net/enic/enic_main.c ++++ b/drivers/net/enic/enic_main.c +@@ -1137,7 +1137,7 @@ int enic_disable(struct enic *enic) + } + + /* If we were using interrupts, set the interrupt vector to -1 +- * to disable interrupts. We are not disabling link notifcations, ++ * to disable interrupts. We are not disabling link notifications, + * though, as we want the polling of link status to continue working. + */ + if (enic->rte_dev->data->dev_conf.intr_conf.lsc) +diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c +index c44715bfd0..33e96b480e 100644 +--- a/drivers/net/enic/enic_rxtx.c ++++ b/drivers/net/enic/enic_rxtx.c +@@ -653,7 +653,7 @@ static void enqueue_simple_pkts(struct rte_mbuf **pkts, + * The app should not send oversized + * packets. tx_pkt_prepare includes a check as + * well. But some apps ignore the device max size and +- * tx_pkt_prepare. Oversized packets cause WQ errrors ++ * tx_pkt_prepare. Oversized packets cause WQ errors + * and the NIC ends up disabling the whole WQ. So + * truncate packets.. + */ +diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h +index 7cfa29faa8..17a7056c45 100644 +--- a/drivers/net/fm10k/fm10k.h ++++ b/drivers/net/fm10k/fm10k.h +@@ -44,7 +44,7 @@ + #define FM10K_TX_MAX_MTU_SEG UINT8_MAX + + /* +- * byte aligment for HW RX data buffer ++ * byte alignment for HW RX data buffer + * Datasheet requires RX buffer addresses shall either be 512-byte aligned or + * be 8-byte aligned but without crossing host memory pages (4KB alignment + * boundaries). Satisfy first option. +diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c +index 43e1d13431..8bbd8b445d 100644 +--- a/drivers/net/fm10k/fm10k_ethdev.c ++++ b/drivers/net/fm10k/fm10k_ethdev.c +@@ -290,7 +290,7 @@ rx_queue_free(struct fm10k_rx_queue *q) + } + + /* +- * disable RX queue, wait unitl HW finished necessary flush operation ++ * disable RX queue, wait until HW finished necessary flush operation + */ + static inline int + rx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) +@@ -379,7 +379,7 @@ tx_queue_free(struct fm10k_tx_queue *q) + } + + /* +- * disable TX queue, wait unitl HW finished necessary flush operation ++ * disable TX queue, wait until HW finished necessary flush operation + */ + static inline int + tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) +@@ -453,7 +453,7 @@ fm10k_dev_configure(struct rte_eth_dev *dev) + if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) + dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; + +- /* multipe queue mode checking */ ++ /* multiple queue mode checking */ + ret = fm10k_check_mq_mode(dev); + if (ret != 0) { + PMD_DRV_LOG(ERR, "fm10k_check_mq_mode fails with %d.", +@@ -2553,7 +2553,7 @@ fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr) + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +@@ -2676,7 +2676,7 @@ fm10k_dev_interrupt_handler_pf(void *param) + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +@@ -3034,7 +3034,7 @@ fm10k_params_init(struct rte_eth_dev *dev) + struct fm10k_dev_info *info = + FM10K_DEV_PRIVATE_TO_INFO(dev->data->dev_private); + +- /* Inialize bus info. Normally we would call fm10k_get_bus_info(), but ++ /* Initialize bus info. Normally we would call fm10k_get_bus_info(), but + * there is no way to get link status without reading BAR4. Until this + * works, assume we have maximum bandwidth. + * @todo - fix bus info +diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c b/drivers/net/fm10k/fm10k_rxtx_vec.c +index 1269250e23..10ce5a7582 100644 +--- a/drivers/net/fm10k/fm10k_rxtx_vec.c ++++ b/drivers/net/fm10k/fm10k_rxtx_vec.c +@@ -212,7 +212,7 @@ fm10k_rx_vec_condition_check(struct rte_eth_dev *dev) + struct rte_eth_fdir_conf *fconf = &dev->data->dev_conf.fdir_conf; + + #ifndef RTE_FM10K_RX_OLFLAGS_ENABLE +- /* whithout rx ol_flags, no VP flag report */ ++ /* without rx ol_flags, no VP flag report */ + if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND) + return -1; + #endif +@@ -239,7 +239,7 @@ fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq) + struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */ + + mb_def.nb_segs = 1; +- /* data_off will be ajusted after new mbuf allocated for 512-byte ++ /* data_off will be adjusted after new mbuf allocated for 512-byte + * alignment. + */ + mb_def.data_off = RTE_PKTMBUF_HEADROOM; +@@ -410,7 +410,7 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, + if (!(rxdp->d.staterr & FM10K_RXD_STATUS_DD)) + return 0; + +- /* Vecotr RX will process 4 packets at a time, strip the unaligned ++ /* Vector RX will process 4 packets at a time, strip the unaligned + * tails in case it's not multiple of 4. + */ + nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, RTE_FM10K_DESCS_PER_LOOP); +@@ -481,7 +481,7 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, + _mm_storeu_si128((__m128i *)&rx_pkts[pos], mbp1); + + #if defined(RTE_ARCH_X86_64) +- /* B.1 load 2 64 bit mbuf poitns */ ++ /* B.1 load 2 64 bit mbuf points */ + mbp2 = _mm_loadu_si128((__m128i *)&mbufp[pos+2]); + #endif + +@@ -573,7 +573,7 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, + + fm10k_desc_to_pktype_v(descs0, &rx_pkts[pos]); + +- /* C.4 calc avaialbe number of desc */ ++ /* C.4 calc available number of desc */ + var = __builtin_popcountll(_mm_cvtsi128_si64(staterr)); + nb_pkts_recd += var; + if (likely(var != RTE_FM10K_DESCS_PER_LOOP)) +diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c +index 1853511c3b..e8d9aaba84 100644 +--- a/drivers/net/hinic/hinic_pmd_ethdev.c ++++ b/drivers/net/hinic/hinic_pmd_ethdev.c +@@ -255,7 +255,7 @@ static int hinic_vlan_offload_set(struct rte_eth_dev *dev, int mask); + * Interrupt handler triggered by NIC for handling + * specific event. + * +- * @param: The address of parameter (struct rte_eth_dev *) regsitered before. ++ * @param: The address of parameter (struct rte_eth_dev *) registered before. + */ + static void hinic_dev_interrupt_handler(void *param) + { +@@ -336,7 +336,7 @@ static int hinic_dev_configure(struct rte_eth_dev *dev) + return err; + } + +- /* init vlan offoad */ ++ /* init VLAN offload */ + err = hinic_vlan_offload_set(dev, + RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK); + if (err) { +diff --git a/drivers/net/hinic/hinic_pmd_ethdev.h b/drivers/net/hinic/hinic_pmd_ethdev.h +index 5eca8b10b9..8e6251f69f 100644 +--- a/drivers/net/hinic/hinic_pmd_ethdev.h ++++ b/drivers/net/hinic/hinic_pmd_ethdev.h +@@ -170,7 +170,7 @@ struct tag_tcam_key_mem { + /* + * tunnel packet, mask must be 0xff, spec value is 1; + * normal packet, mask must be 0, spec value is 0; +- * if tunnal packet, ucode use ++ * if tunnel packet, ucode use + * sip/dip/protocol/src_port/dst_dport from inner packet + */ + u32 tunnel_flag:8; +diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c +index d71a42afbd..2cf24ebcf6 100644 +--- a/drivers/net/hinic/hinic_pmd_flow.c ++++ b/drivers/net/hinic/hinic_pmd_flow.c +@@ -734,7 +734,7 @@ static int hinic_check_ntuple_item_ele(const struct rte_flow_item *item, + * END + * other members in mask and spec should set to 0x00. + * item->last should be NULL. +- * Please aware there's an asumption for all the parsers. ++ * Please be aware there's an assumption for all the parsers. + * rte_flow_item is using big endian, rte_flow_attr and + * rte_flow_action are using CPU order. + * Because the pattern is used to describe the packets, +@@ -1630,7 +1630,7 @@ static int hinic_parse_fdir_filter(struct rte_eth_dev *dev, + + /** + * Check if the flow rule is supported by nic. +- * It only checkes the format. Don't guarantee the rule can be programmed into ++ * It only checks the format. Don't guarantee the rule can be programmed into + * the HW. Because there can be no enough room for the rule. + */ + static int hinic_flow_validate(struct rte_eth_dev *dev, +diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c +index 2688817f37..f09b1a6e1e 100644 +--- a/drivers/net/hinic/hinic_pmd_tx.c ++++ b/drivers/net/hinic/hinic_pmd_tx.c +@@ -1144,7 +1144,7 @@ u16 hinic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts) + mbuf_pkt = *tx_pkts++; + queue_info = 0; + +- /* 1. parse sge and tx offlod info from mbuf */ ++ /* 1. parse sge and tx offload info from mbuf */ + if (unlikely(!hinic_get_sge_txoff_info(mbuf_pkt, + &sqe_info, &off_info))) { + txq->txq_stats.off_errs++; +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index 50cb3eabb1..bdfc85f934 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -462,7 +462,7 @@ hns3_mask_capability(struct hns3_hw *hw, + for (i = 0; i < MAX_CAPS_BIT; i++) { + if (!(caps_masked & BIT_ULL(i))) + continue; +- hns3_info(hw, "mask capabiliy: id-%u, name-%s.", ++ hns3_info(hw, "mask capability: id-%u, name-%s.", + i, hns3_get_caps_name(i)); + } + } +@@ -699,7 +699,7 @@ hns3_cmd_init(struct hns3_hw *hw) + return 0; + + /* +- * Requiring firmware to enable some features, firber port can still ++ * Requiring firmware to enable some features, fiber port can still + * work without it, but copper port can't work because the firmware + * fails to take over the PHY. + */ +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 716cebbcec..2ebcf5695b 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -663,7 +663,7 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) + hw->intr_tqps_num = RTE_MIN(vec, hw->tqps_num); + for (i = 0; i < hw->intr_tqps_num; i++) { + /* +- * Set gap limiter/rate limiter/quanity limiter algorithm ++ * Set gap limiter/rate limiter/quantity limiter algorithm + * configuration for interrupt coalesce of queue's interrupt. + */ + hns3_set_queue_intr_gl(hw, i, HNS3_RING_GL_RX, +diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c +index b22f618e0a..af045b22f7 100644 +--- a/drivers/net/hns3/hns3_dcb.c ++++ b/drivers/net/hns3/hns3_dcb.c +@@ -25,7 +25,7 @@ + * IR(Mbps) = ------------------------- * CLOCK(1000Mbps) + * Tick * (2 ^ IR_s) + * +- * @return: 0: calculate sucessful, negative: fail ++ * @return: 0: calculate successful, negative: fail + */ + static int + hns3_shaper_para_calc(struct hns3_hw *hw, uint32_t ir, uint8_t shaper_level, +@@ -36,8 +36,8 @@ hns3_shaper_para_calc(struct hns3_hw *hw, uint32_t ir, uint8_t shaper_level, + #define DIVISOR_IR_B_126 (126 * DIVISOR_CLK) + + const uint16_t tick_array[HNS3_SHAPER_LVL_CNT] = { +- 6 * 256, /* Prioriy level */ +- 6 * 32, /* Prioriy group level */ ++ 6 * 256, /* Priority level */ ++ 6 * 32, /* Priority group level */ + 6 * 8, /* Port level */ + 6 * 256 /* Qset level */ + }; +@@ -1521,7 +1521,7 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) + + ret = hns3_dcb_schd_setup_hw(hw); + if (ret) { +- hns3_err(hw, "dcb schdule configure failed! ret = %d", ret); ++ hns3_err(hw, "dcb schedule configure failed! ret = %d", ret); + return ret; + } + +@@ -1726,7 +1726,7 @@ hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode) + * hns3_dcb_pfc_enable - Enable priority flow control + * @dev: pointer to ethernet device + * +- * Configures the pfc settings for one porority. ++ * Configures the pfc settings for one priority. + */ + int + hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index f83cff4d98..25f9c9fab1 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -568,7 +568,7 @@ hns3_set_vlan_rx_offload_cfg(struct hns3_adapter *hns, + hns3_set_bit(req->vport_vlan_cfg, HNS3_SHOW_TAG2_EN_B, + vcfg->vlan2_vlan_prionly ? 1 : 0); + +- /* firmwall will ignore this configuration for PCI_REVISION_ID_HIP08 */ ++ /* firmware will ignore this configuration for PCI_REVISION_ID_HIP08 */ + hns3_set_bit(req->vport_vlan_cfg, HNS3_DISCARD_TAG1_EN_B, + vcfg->strip_tag1_discard_en ? 1 : 0); + hns3_set_bit(req->vport_vlan_cfg, HNS3_DISCARD_TAG2_EN_B, +@@ -763,7 +763,7 @@ hns3_set_vlan_tx_offload_cfg(struct hns3_adapter *hns, + vcfg->insert_tag2_en ? 1 : 0); + hns3_set_bit(req->vport_vlan_cfg, HNS3_CFG_NIC_ROCE_SEL_B, 0); + +- /* firmwall will ignore this configuration for PCI_REVISION_ID_HIP08 */ ++ /* firmware will ignore this configuration for PCI_REVISION_ID_HIP08 */ + hns3_set_bit(req->vport_vlan_cfg, HNS3_TAG_SHIFT_MODE_EN_B, + vcfg->tag_shift_mode_en ? 1 : 0); + +@@ -3385,7 +3385,7 @@ hns3_only_alloc_priv_buff(struct hns3_hw *hw, + * hns3_rx_buffer_calc: calculate the rx private buffer size for all TCs + * @hw: pointer to struct hns3_hw + * @buf_alloc: pointer to buffer calculation data +- * @return: 0: calculate sucessful, negative: fail ++ * @return: 0: calculate successful, negative: fail + */ + static int + hns3_rx_buffer_calc(struct hns3_hw *hw, struct hns3_pkt_buf_alloc *buf_alloc) +@@ -4518,14 +4518,14 @@ hns3_set_firber_default_support_speed(struct hns3_hw *hw) + } + + /* +- * Validity of supported_speed for firber and copper media type can be ++ * Validity of supported_speed for fiber and copper media type can be + * guaranteed by the following policy: + * Copper: + * Although the initialization of the phy in the firmware may not be + * completed, the firmware can guarantees that the supported_speed is + * an valid value. + * Firber: +- * If the version of firmware supports the acitive query way of the ++ * If the version of firmware supports the active query way of the + * HNS3_OPC_GET_SFP_INFO opcode, the supported_speed can be obtained + * through it. If unsupported, use the SFP's speed as the value of the + * supported_speed. +@@ -5285,7 +5285,7 @@ hns3_get_autoneg_fc_mode(struct hns3_hw *hw) + + /* + * Flow control auto-negotiation is not supported for fiber and +- * backpalne media type. ++ * backplane media type. + */ + case HNS3_MEDIA_TYPE_FIBER: + case HNS3_MEDIA_TYPE_BACKPLANE: +@@ -6152,7 +6152,7 @@ hns3_fec_get_internal(struct hns3_hw *hw, uint32_t *fec_capa) + } + + /* +- * FEC mode order defined in hns3 hardware is inconsistend with ++ * FEC mode order defined in hns3 hardware is inconsistent with + * that defined in the ethdev library. So the sequence needs + * to be converted. + */ +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 4406611fe9..2457754b3d 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -125,7 +125,7 @@ struct hns3_tc_info { + uint8_t tc_sch_mode; /* 0: sp; 1: dwrr */ + uint8_t pgid; + uint32_t bw_limit; +- uint8_t up_to_tc_map; /* user priority maping on the TC */ ++ uint8_t up_to_tc_map; /* user priority mapping on the TC */ + }; + + struct hns3_dcb_info { +@@ -572,12 +572,12 @@ struct hns3_hw { + /* + * vlan mode. + * value range: +- * HNS3_SW_SHIFT_AND_DISCARD_MODE/HNS3_HW_SHFIT_AND_DISCARD_MODE ++ * HNS3_SW_SHIFT_AND_DISCARD_MODE/HNS3_HW_SHIFT_AND_DISCARD_MODE + * + * - HNS3_SW_SHIFT_AND_DISCARD_MODE + * For some versions of hardware network engine, because of the + * hardware limitation, PMD needs to detect the PVID status +- * to work with haredware to implement PVID-related functions. ++ * to work with hardware to implement PVID-related functions. + * For example, driver need discard the stripped PVID tag to ensure + * the PVID will not report to mbuf and shift the inserted VLAN tag + * to avoid port based VLAN covering it. +@@ -725,7 +725,7 @@ enum hns3_mp_req_type { + HNS3_MP_REQ_MAX + }; + +-/* Pameters for IPC. */ ++/* Parameters for IPC. */ + struct hns3_mp_param { + enum hns3_mp_req_type type; + int port_id; +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 1022b02697..de44b07691 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -318,7 +318,7 @@ hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc, + * 1. The promiscuous/allmulticast mode can be configured successfully + * only based on the trusted VF device. If based on the non trusted + * VF device, configuring promiscuous/allmulticast mode will fail. +- * The hns3 VF device can be confiruged as trusted device by hns3 PF ++ * The hns3 VF device can be configured as trusted device by hns3 PF + * kernel ethdev driver on the host by the following command: + * "ip link set vf turst on" + * 2. After the promiscuous mode is configured successfully, hns3 VF PMD +@@ -330,7 +330,7 @@ hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc, + * filter is still effective even in promiscuous mode. If upper + * applications don't call rte_eth_dev_vlan_filter API function to + * set vlan based on VF device, hns3 VF PMD will can't receive +- * the packets with vlan tag in promiscuoue mode. ++ * the packets with vlan tag in promiscuous mode. + */ + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_MBX_VF_TO_PF, false); + req->msg[0] = HNS3_MBX_SET_PROMISC_MODE; +diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h +index de2422e12f..ce70a534dc 100644 +--- a/drivers/net/hns3/hns3_fdir.h ++++ b/drivers/net/hns3/hns3_fdir.h +@@ -144,7 +144,7 @@ struct hns3_fdir_rule { + uint32_t flags; + uint32_t fd_id; /* APP marked unique value for this rule. */ + uint8_t action; +- /* VF id, avaiblable when flags with HNS3_RULE_FLAG_VF_ID. */ ++ /* VF id, available when flags with HNS3_RULE_FLAG_VF_ID. */ + uint8_t vf_id; + /* + * equal 0 when action is drop. +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 1aee965e4a..a2c1589c39 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -369,7 +369,7 @@ hns3_handle_action_indirect(struct rte_eth_dev *dev, + * + * @param actions[in] + * @param rule[out] +- * NIC specfilc actions derived from the actions. ++ * NIC specific actions derived from the actions. + * @param error[out] + */ + static int +@@ -400,7 +400,7 @@ hns3_handle_actions(struct rte_eth_dev *dev, + * Queue region is implemented by FDIR + RSS in hns3 hardware, + * the FDIR's action is one queue region (start_queue_id and + * queue_num), then RSS spread packets to the queue region by +- * RSS algorigthm. ++ * RSS algorithm. + */ + case RTE_FLOW_ACTION_TYPE_RSS: + ret = hns3_handle_action_queue_region(dev, actions, +@@ -978,7 +978,7 @@ hns3_parse_nvgre(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, + if (nvgre_mask->protocol || nvgre_mask->c_k_s_rsvd0_ver) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_MASK, item, +- "Ver/protocal is not supported in NVGRE"); ++ "Ver/protocol is not supported in NVGRE"); + + /* TNI must be totally masked or not. */ + if (memcmp(nvgre_mask->tni, full_mask, VNI_OR_TNI_LEN) && +@@ -1023,7 +1023,7 @@ hns3_parse_geneve(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, + if (geneve_mask->ver_opt_len_o_c_rsvd0 || geneve_mask->protocol) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_MASK, item, +- "Ver/protocal is not supported in GENEVE"); ++ "Ver/protocol is not supported in GENEVE"); + /* VNI must be totally masked or not. */ + if (memcmp(geneve_mask->vni, full_mask, VNI_OR_TNI_LEN) && + memcmp(geneve_mask->vni, zero_mask, VNI_OR_TNI_LEN)) +@@ -1354,7 +1354,7 @@ hns3_rss_input_tuple_supported(struct hns3_hw *hw, + } + + /* +- * This function is used to parse rss action validatation. ++ * This function is used to parse rss action validation. + */ + static int + hns3_parse_rss_filter(struct rte_eth_dev *dev, +@@ -1722,7 +1722,7 @@ hns3_flow_args_check(const struct rte_flow_attr *attr, + + /* + * Check if the flow rule is supported by hns3. +- * It only checkes the format. Don't guarantee the rule can be programmed into ++ * It only checks the format. Don't guarantee the rule can be programmed into + * the HW. Because there can be no enough room for the rule. + */ + static int +diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c +index 9a05f0d1ee..8e0a58aa02 100644 +--- a/drivers/net/hns3/hns3_mbx.c ++++ b/drivers/net/hns3/hns3_mbx.c +@@ -78,14 +78,14 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, + mbx_time_limit = (uint32_t)hns->mbx_time_limit_ms * US_PER_MS; + while (wait_time < mbx_time_limit) { + if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { +- hns3_err(hw, "Don't wait for mbx respone because of " ++ hns3_err(hw, "Don't wait for mbx response because of " + "disable_cmd"); + return -EBUSY; + } + + if (is_reset_pending(hns)) { + hw->mbx_resp.req_msg_data = 0; +- hns3_err(hw, "Don't wait for mbx respone because of " ++ hns3_err(hw, "Don't wait for mbx response because of " + "reset pending"); + return -EIO; + } +diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h +index c71f43238c..c378783c6c 100644 +--- a/drivers/net/hns3/hns3_mbx.h ++++ b/drivers/net/hns3/hns3_mbx.h +@@ -26,7 +26,7 @@ enum HNS3_MBX_OPCODE { + HNS3_MBX_GET_RETA, /* (VF -> PF) get RETA */ + HNS3_MBX_GET_RSS_KEY, /* (VF -> PF) get RSS key */ + HNS3_MBX_GET_MAC_ADDR, /* (VF -> PF) get MAC addr */ +- HNS3_MBX_PF_VF_RESP, /* (PF -> VF) generate respone to VF */ ++ HNS3_MBX_PF_VF_RESP, /* (PF -> VF) generate response to VF */ + HNS3_MBX_GET_BDNUM, /* (VF -> PF) get BD num */ + HNS3_MBX_GET_BUFSIZE, /* (VF -> PF) get buffer size */ + HNS3_MBX_GET_STREAMID, /* (VF -> PF) get stream id */ +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 9471e7039d..8e8b056f4e 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -40,7 +40,7 @@ + struct hns3_rss_conf { + /* RSS parameters :algorithm, flow_types, key, queue */ + struct rte_flow_action_rss conf; +- uint8_t hash_algo; /* hash function type definited by hardware */ ++ uint8_t hash_algo; /* hash function type defined by hardware */ + uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */ + uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; + uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 3c02fd54e1..9a597e032e 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -1897,7 +1897,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, + * For hns3 VF device, whether it needs to process PVID depends + * on the configuration of PF kernel mode netdevice driver. And the + * related PF configuration is delivered through the mailbox and finally +- * reflectd in port_base_vlan_cfg. ++ * reflected in port_base_vlan_cfg. + */ + if (hns->is_vf || hw->vlan_mode == HNS3_SW_SHIFT_AND_DISCARD_MODE) + rxq->pvid_sw_discard_en = hw->port_base_vlan_cfg.state == +@@ -3038,7 +3038,7 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, + * For hns3 VF device, whether it needs to process PVID depends + * on the configuration of PF kernel mode netdev driver. And the + * related PF configuration is delivered through the mailbox and finally +- * reflectd in port_base_vlan_cfg. ++ * reflected in port_base_vlan_cfg. + */ + if (hns->is_vf || hw->vlan_mode == HNS3_SW_SHIFT_AND_DISCARD_MODE) + txq->pvid_sw_shift_en = hw->port_base_vlan_cfg.state == +@@ -3192,7 +3192,7 @@ hns3_fill_first_desc(struct hns3_tx_queue *txq, struct hns3_desc *desc, + * in Tx direction based on hns3 network engine. So when the number of + * VLANs in the packets represented by rxm plus the number of VLAN + * offload by hardware such as PVID etc, exceeds two, the packets will +- * be discarded or the original VLAN of the packets will be overwitted ++ * be discarded or the original VLAN of the packets will be overwritten + * by hardware. When the PF PVID is enabled by calling the API function + * named rte_eth_dev_set_vlan_pvid or the VF PVID is enabled by the hns3 + * PF kernel ether driver, the outer VLAN tag will always be the PVID. +@@ -3377,7 +3377,7 @@ hns3_parse_inner_params(struct rte_mbuf *m, uint32_t *ol_type_vlan_len_msec, + /* + * The inner l2 length of mbuf is the sum of outer l4 length, + * tunneling header length and inner l2 length for a tunnel +- * packect. But in hns3 tx descriptor, the tunneling header ++ * packet. But in hns3 tx descriptor, the tunneling header + * length is contained in the field of outer L4 length. + * Therefore, driver need to calculate the outer L4 length and + * inner L2 length. +@@ -3393,7 +3393,7 @@ hns3_parse_inner_params(struct rte_mbuf *m, uint32_t *ol_type_vlan_len_msec, + tmp_outer |= hns3_gen_field_val(HNS3_TXD_TUNTYPE_M, + HNS3_TXD_TUNTYPE_S, HNS3_TUN_NVGRE); + /* +- * For NVGRE tunnel packect, the outer L4 is empty. So only ++ * For NVGRE tunnel packet, the outer L4 is empty. So only + * fill the NVGRE header length to the outer L4 field. + */ + tmp_outer |= hns3_gen_field_val(HNS3_TXD_L4LEN_M, +@@ -3436,7 +3436,7 @@ hns3_parse_tunneling_params(struct hns3_tx_queue *txq, struct rte_mbuf *m, + * mbuf, but for hns3 descriptor, it is contained in the outer L4. So, + * there is a need that switching between them. To avoid multiple + * calculations, the length of the L2 header include the outer and +- * inner, will be filled during the parsing of tunnel packects. ++ * inner, will be filled during the parsing of tunnel packets. + */ + if (!(ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)) { + /* +@@ -3616,7 +3616,7 @@ hns3_outer_ipv4_cksum_prepared(struct rte_mbuf *m, uint64_t ol_flags, + if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { + struct rte_udp_hdr *udp_hdr; + /* +- * If OUTER_UDP_CKSUM is support, HW can caclulate the pseudo ++ * If OUTER_UDP_CKSUM is support, HW can calculate the pseudo + * header for TSO packets + */ + if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) +@@ -3641,7 +3641,7 @@ hns3_outer_ipv6_cksum_prepared(struct rte_mbuf *m, uint64_t ol_flags, + if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { + struct rte_udp_hdr *udp_hdr; + /* +- * If OUTER_UDP_CKSUM is support, HW can caclulate the pseudo ++ * If OUTER_UDP_CKSUM is support, HW can calculate the pseudo + * header for TSO packets + */ + if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index e633b336b1..ea1a805491 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -618,7 +618,7 @@ hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, + + /* + * If packet len bigger than mtu when recv with no-scattered algorithm, +- * the first n bd will without FE bit, we need process this sisution. ++ * the first n bd will without FE bit, we need process this situation. + * Note: we don't need add statistic counter because latest BD which + * with FE bit will mark HNS3_RXD_L2E_B bit. + */ +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index 552ae9d30c..bad65fcbed 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -1286,7 +1286,7 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, + * A pointer to an ids array passed by application. This tells which + * statistics values function should retrieve. This parameter + * can be set to NULL if size is 0. In this case function will retrieve +- * all avalible statistics. ++ * all available statistics. + * @param values + * A pointer to a table to be filled with device statistics values. + * @param size +diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c +index c0bfff43ee..1d417dbf8a 100644 +--- a/drivers/net/i40e/i40e_ethdev.c ++++ b/drivers/net/i40e/i40e_ethdev.c +@@ -2483,7 +2483,7 @@ i40e_dev_start(struct rte_eth_dev *dev) + if (ret != I40E_SUCCESS) + PMD_DRV_LOG(WARNING, "Fail to set phy mask"); + +- /* Call get_link_info aq commond to enable/disable LSE */ ++ /* Call get_link_info aq command to enable/disable LSE */ + i40e_dev_link_update(dev, 0); + } + +@@ -3555,7 +3555,7 @@ static int i40e_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + count++; + } + +- /* Get individiual stats from i40e_hw_port struct */ ++ /* Get individual stats from i40e_hw_port struct */ + for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) { + strlcpy(xstats_names[count].name, + rte_i40e_hw_port_strings[i].name, +@@ -3613,7 +3613,7 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + count++; + } + +- /* Get individiual stats from i40e_hw_port struct */ ++ /* Get individual stats from i40e_hw_port struct */ + for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) { + xstats[count].value = *(uint64_t *)(((char *)hw_stats) + + rte_i40e_hw_port_strings[i].offset); +@@ -5544,7 +5544,7 @@ i40e_vsi_get_bw_config(struct i40e_vsi *vsi) + &ets_sla_config, NULL); + if (ret != I40E_SUCCESS) { + PMD_DRV_LOG(ERR, +- "VSI failed to get TC bandwdith configuration %u", ++ "VSI failed to get TC bandwidth configuration %u", + hw->aq.asq_last_status); + return ret; + } +@@ -6822,7 +6822,7 @@ i40e_handle_mdd_event(struct rte_eth_dev *dev) + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +@@ -9719,7 +9719,7 @@ i40e_ethertype_filter_convert(const struct rte_eth_ethertype_filter *input, + return 0; + } + +-/* Check if there exists the ehtertype filter */ ++/* Check if there exists the ethertype filter */ + struct i40e_ethertype_filter * + i40e_sw_ethertype_filter_lookup(struct i40e_ethertype_rule *ethertype_rule, + const struct i40e_ethertype_filter_input *input) +diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h +index 2d182f8000..a1ebdc093c 100644 +--- a/drivers/net/i40e/i40e_ethdev.h ++++ b/drivers/net/i40e/i40e_ethdev.h +@@ -897,7 +897,7 @@ struct i40e_tunnel_filter { + TAILQ_ENTRY(i40e_tunnel_filter) rules; + struct i40e_tunnel_filter_input input; + uint8_t is_to_vf; /* 0 - to PF, 1 - to VF */ +- uint16_t vf_id; /* VF id, avaiblable when is_to_vf is 1. */ ++ uint16_t vf_id; /* VF id, available when is_to_vf is 1. */ + uint16_t queue; /* Queue assigned to when match */ + }; + +@@ -966,7 +966,7 @@ struct i40e_tunnel_filter_conf { + uint32_t tenant_id; /**< Tenant ID to match. VNI, GRE key... */ + uint16_t queue_id; /**< Queue assigned to if match. */ + uint8_t is_to_vf; /**< 0 - to PF, 1 - to VF */ +- uint16_t vf_id; /**< VF id, avaiblable when is_to_vf is 1. */ ++ uint16_t vf_id; /**< VF id, available when is_to_vf is 1. */ + }; + + TAILQ_HEAD(i40e_flow_list, rte_flow); +@@ -1100,7 +1100,7 @@ struct i40e_vf_msg_cfg { + /* + * If message statistics from a VF exceed the maximal limitation, + * the PF will ignore any new message from that VF for +- * 'ignor_second' time. ++ * 'ignore_second' time. + */ + uint32_t ignore_second; + }; +@@ -1257,7 +1257,7 @@ struct i40e_adapter { + }; + + /** +- * Strucute to store private data for each VF representor instance ++ * Structure to store private data for each VF representor instance + */ + struct i40e_vf_representor { + uint16_t switch_domain_id; +@@ -1265,7 +1265,7 @@ struct i40e_vf_representor { + uint16_t vf_id; + /**< Virtual Function ID */ + struct i40e_adapter *adapter; +- /**< Private data store of assocaiated physical function */ ++ /**< Private data store of associated physical function */ + struct i40e_eth_stats stats_offset; + /**< Zero-point of VF statistics*/ + }; +diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c +index df2a5aaecc..8caedea14e 100644 +--- a/drivers/net/i40e/i40e_fdir.c ++++ b/drivers/net/i40e/i40e_fdir.c +@@ -142,7 +142,7 @@ i40e_fdir_rx_queue_init(struct i40e_rx_queue *rxq) + I40E_QRX_TAIL(rxq->vsi->base_queue); + + rte_wmb(); +- /* Init the RX tail regieter. */ ++ /* Init the RX tail register. */ + I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1); + + return err; +@@ -430,7 +430,7 @@ i40e_check_fdir_flex_payload(const struct rte_eth_flex_payload_cfg *flex_cfg) + + for (i = 0; i < I40E_FDIR_MAX_FLEX_LEN; i++) { + if (flex_cfg->src_offset[i] >= I40E_MAX_FLX_SOURCE_OFF) { +- PMD_DRV_LOG(ERR, "exceeds maxmial payload limit."); ++ PMD_DRV_LOG(ERR, "exceeds maximal payload limit."); + return -EINVAL; + } + } +@@ -438,7 +438,7 @@ i40e_check_fdir_flex_payload(const struct rte_eth_flex_payload_cfg *flex_cfg) + memset(flex_pit, 0, sizeof(flex_pit)); + num = i40e_srcoff_to_flx_pit(flex_cfg->src_offset, flex_pit); + if (num > I40E_MAX_FLXPLD_FIED) { +- PMD_DRV_LOG(ERR, "exceeds maxmial number of flex fields."); ++ PMD_DRV_LOG(ERR, "exceeds maximal number of flex fields."); + return -EINVAL; + } + for (i = 0; i < num; i++) { +@@ -948,7 +948,7 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf, + uint8_t pctype = fdir_input->pctype; + struct i40e_customized_pctype *cus_pctype; + +- /* raw pcket template - just copy contents of the raw packet */ ++ /* raw packet template - just copy contents of the raw packet */ + if (fdir_input->flow_ext.pkt_template) { + memcpy(raw_pkt, fdir_input->flow.raw_flow.packet, + fdir_input->flow.raw_flow.length); +@@ -1831,7 +1831,7 @@ i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev, + &check_filter.fdir.input); + if (!node) { + PMD_DRV_LOG(ERR, +- "There's no corresponding flow firector filter!"); ++ "There's no corresponding flow director filter!"); + return -EINVAL; + } + +diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c +index c9676caab5..e0cf996200 100644 +--- a/drivers/net/i40e/i40e_flow.c ++++ b/drivers/net/i40e/i40e_flow.c +@@ -3043,7 +3043,7 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, +- "Exceeds maxmial payload limit."); ++ "Exceeds maximal payload limit."); + return -rte_errno; + } + +diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c +index ccb3924a5f..2435a8a070 100644 +--- a/drivers/net/i40e/i40e_pf.c ++++ b/drivers/net/i40e/i40e_pf.c +@@ -343,7 +343,7 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg, + vf->request_caps = *(uint32_t *)msg; + + /* enable all RSS by default, +- * doesn't support hena setting by virtchnnl yet. ++ * doesn't support hena setting by virtchnl yet. + */ + if (vf->request_caps & VIRTCHNL_VF_OFFLOAD_RSS_PF) { + I40E_WRITE_REG(hw, I40E_VFQF_HENA1(0, vf->vf_idx), +@@ -725,7 +725,7 @@ i40e_pf_host_process_cmd_config_irq_map(struct i40e_pf_vf *vf, + if ((map->rxq_map < qbit_max) && (map->txq_map < qbit_max)) { + i40e_pf_config_irq_link_list(vf, map); + } else { +- /* configured queue size excceed limit */ ++ /* configured queue size exceed limit */ + ret = I40E_ERR_PARAM; + goto send_msg; + } +diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c +index e4cb33dc3c..9a00a9b71e 100644 +--- a/drivers/net/i40e/i40e_rxtx.c ++++ b/drivers/net/i40e/i40e_rxtx.c +@@ -609,7 +609,7 @@ i40e_rx_alloc_bufs(struct i40e_rx_queue *rxq) + rxdp[i].read.pkt_addr = dma_addr; + } + +- /* Update rx tail regsiter */ ++ /* Update rx tail register */ + I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger); + + rxq->rx_free_trigger = +@@ -995,7 +995,7 @@ i40e_recv_scattered_pkts(void *rx_queue, + * threshold of the queue, advance the Receive Descriptor Tail (RDT) + * register. Update the RDT with the value of the last processed RX + * descriptor minus 1, to guarantee that the RDT register is never +- * equal to the RDH register, which creates a "full" ring situtation ++ * equal to the RDH register, which creates a "full" ring situation + * from the hardware point of view. + */ + nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold); +@@ -1467,7 +1467,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, + i40e_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n)); + txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n)); + +- /* Determin if RS bit needs to be set */ ++ /* Determine if RS bit needs to be set */ + if (txq->tx_tail > txq->tx_next_rs) { + txr[txq->tx_next_rs].cmd_type_offset_bsz |= + rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) << +@@ -1697,7 +1697,7 @@ i40e_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) + } + + if (rxq->rx_deferred_start) +- PMD_DRV_LOG(WARNING, "RX queue %u is deferrd start", ++ PMD_DRV_LOG(WARNING, "RX queue %u is deferred start", + rx_queue_id); + + err = i40e_alloc_rx_queue_mbufs(rxq); +@@ -1706,7 +1706,7 @@ i40e_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) + return err; + } + +- /* Init the RX tail regieter. */ ++ /* Init the RX tail register. */ + I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1); + + err = i40e_switch_rx_queue(hw, rxq->reg_idx, TRUE); +@@ -1771,7 +1771,7 @@ i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) + } + + if (txq->tx_deferred_start) +- PMD_DRV_LOG(WARNING, "TX queue %u is deferrd start", ++ PMD_DRV_LOG(WARNING, "TX queue %u is deferred start", + tx_queue_id); + + /* +@@ -1930,7 +1930,7 @@ i40e_dev_rx_queue_setup_runtime(struct rte_eth_dev *dev, + PMD_DRV_LOG(ERR, "Can't use default burst."); + return -EINVAL; + } +- /* check scatterred conflict */ ++ /* check scattered conflict */ + if (!dev->data->scattered_rx && use_scattered_rx) { + PMD_DRV_LOG(ERR, "Scattered rx is required."); + return -EINVAL; +@@ -2014,7 +2014,7 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev, + rxq->rx_deferred_start = rx_conf->rx_deferred_start; + rxq->offloads = offloads; + +- /* Allocate the maximun number of RX ring hardware descriptor. */ ++ /* Allocate the maximum number of RX ring hardware descriptor. */ + len = I40E_MAX_RING_DESC; + + /** +@@ -2322,7 +2322,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev, + */ + tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ? + tx_conf->tx_free_thresh : DEFAULT_TX_FREE_THRESH); +- /* force tx_rs_thresh to adapt an aggresive tx_free_thresh */ ++ /* force tx_rs_thresh to adapt an aggressive tx_free_thresh */ + tx_rs_thresh = (DEFAULT_TX_RS_THRESH + tx_free_thresh > nb_desc) ? + nb_desc - tx_free_thresh : DEFAULT_TX_RS_THRESH; + if (tx_conf->tx_rs_thresh > 0) +@@ -2991,7 +2991,7 @@ i40e_rx_queue_init(struct i40e_rx_queue *rxq) + if (rxq->max_pkt_len > buf_size) + dev_data->scattered_rx = 1; + +- /* Init the RX tail regieter. */ ++ /* Init the RX tail register. */ + I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1); + + return 0; +diff --git a/drivers/net/i40e/i40e_rxtx_vec_altivec.c b/drivers/net/i40e/i40e_rxtx_vec_altivec.c +index d0bf86dfba..f78ba994f7 100644 +--- a/drivers/net/i40e/i40e_rxtx_vec_altivec.c ++++ b/drivers/net/i40e/i40e_rxtx_vec_altivec.c +@@ -430,7 +430,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, + desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl); + desc_to_olflags_v(descs, &rx_pkts[pos]); + +- /* C.4 calc avaialbe number of desc */ ++ /* C.4 calc available number of desc */ + var = __builtin_popcountll((vec_ld(0, + (vector unsigned long *)&staterr)[0])); + nb_pkts_recd += var; +diff --git a/drivers/net/i40e/i40e_rxtx_vec_neon.c b/drivers/net/i40e/i40e_rxtx_vec_neon.c +index b951ea2dc3..507468531f 100644 +--- a/drivers/net/i40e/i40e_rxtx_vec_neon.c ++++ b/drivers/net/i40e/i40e_rxtx_vec_neon.c +@@ -151,7 +151,7 @@ desc_to_olflags_v(struct i40e_rx_queue *rxq, uint64x2_t descs[4], + vreinterpretq_u8_u32(l3_l4e))); + /* then we shift left 1 bit */ + l3_l4e = vshlq_n_u32(l3_l4e, 1); +- /* we need to mask out the reduntant bits */ ++ /* we need to mask out the redundant bits */ + l3_l4e = vandq_u32(l3_l4e, cksum_mask); + + vlan0 = vorrq_u32(vlan0, rss); +@@ -416,7 +416,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq, + I40E_UINT16_BIT - 1)); + stat = ~vgetq_lane_u64(vreinterpretq_u64_u16(staterr), 0); + +- /* C.4 calc avaialbe number of desc */ ++ /* C.4 calc available number of desc */ + if (unlikely(stat == 0)) { + nb_pkts_recd += RTE_I40E_DESCS_PER_LOOP; + } else { +diff --git a/drivers/net/i40e/i40e_rxtx_vec_sse.c b/drivers/net/i40e/i40e_rxtx_vec_sse.c +index 497b2404c6..3782e8052f 100644 +--- a/drivers/net/i40e/i40e_rxtx_vec_sse.c ++++ b/drivers/net/i40e/i40e_rxtx_vec_sse.c +@@ -282,7 +282,7 @@ desc_to_olflags_v(struct i40e_rx_queue *rxq, volatile union i40e_rx_desc *rxdp, + l3_l4e = _mm_shuffle_epi8(l3_l4e_flags, l3_l4e); + /* then we shift left 1 bit */ + l3_l4e = _mm_slli_epi32(l3_l4e, 1); +- /* we need to mask out the reduntant bits */ ++ /* we need to mask out the redundant bits */ + l3_l4e = _mm_and_si128(l3_l4e, cksum_mask); + + vlan0 = _mm_or_si128(vlan0, rss); +@@ -297,7 +297,7 @@ desc_to_olflags_v(struct i40e_rx_queue *rxq, volatile union i40e_rx_desc *rxdp, + __m128i v_fdir_ol_flags = descs_to_fdir_16b(desc_fltstat, + descs, rx_pkts); + #endif +- /* OR in ol_flag bits after descriptor speicific extraction */ ++ /* OR in ol_flag bits after descriptor specific extraction */ + vlan0 = _mm_or_si128(vlan0, v_fdir_ol_flags); + } + +@@ -577,7 +577,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, + _mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1, + pkt_mb1); + desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl); +- /* C.4 calc avaialbe number of desc */ ++ /* C.4 calc available number of desc */ + var = __builtin_popcountll(_mm_cvtsi128_si64(staterr)); + nb_pkts_recd += var; + if (likely(var != RTE_I40E_DESCS_PER_LOOP)) +diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c +index a492959b75..35829a1eea 100644 +--- a/drivers/net/i40e/rte_pmd_i40e.c ++++ b/drivers/net/i40e/rte_pmd_i40e.c +@@ -1427,7 +1427,7 @@ rte_pmd_i40e_set_tc_strict_prio(uint16_t port, uint8_t tc_map) + /* Get all TCs' bandwidth. */ + for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { + if (veb->enabled_tc & BIT_ULL(i)) { +- /* For rubust, if bandwidth is 0, use 1 instead. */ ++ /* For robust, if bandwidth is 0, use 1 instead. */ + if (veb->bw_info.bw_ets_share_credits[i]) + ets_data.tc_bw_share_credits[i] = + veb->bw_info.bw_ets_share_credits[i]; +diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c +index 377d7bc7a6..79397f15e5 100644 +--- a/drivers/net/iavf/iavf_ethdev.c ++++ b/drivers/net/iavf/iavf_ethdev.c +@@ -516,7 +516,7 @@ iavf_init_rss(struct iavf_adapter *adapter) + j = 0; + vf->rss_lut[i] = j; + } +- /* send virtchnnl ops to configure rss*/ ++ /* send virtchnl ops to configure RSS */ + ret = iavf_configure_rss_lut(adapter); + if (ret) + return ret; +@@ -831,7 +831,7 @@ static int iavf_config_rx_queues_irqs(struct rte_eth_dev *dev, + "vector %u are mapping to all Rx queues", + vf->msix_base); + } else { +- /* If Rx interrupt is reuquired, and we can use ++ /* If Rx interrupt is required, and we can use + * multi interrupts, then the vec is from 1 + */ + vf->nb_msix = +@@ -1420,7 +1420,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev, + } + + rte_memcpy(vf->rss_lut, lut, reta_size); +- /* send virtchnnl ops to configure rss*/ ++ /* send virtchnl ops to configure RSS */ + ret = iavf_configure_rss_lut(adapter); + if (ret) /* revert back */ + rte_memcpy(vf->rss_lut, lut, reta_size); +diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c +index 884169e061..adf101ab8a 100644 +--- a/drivers/net/iavf/iavf_ipsec_crypto.c ++++ b/drivers/net/iavf/iavf_ipsec_crypto.c +@@ -69,7 +69,7 @@ struct iavf_security_session { + * 16B - 3 + * + * but we also need the IV Length for TSO to correctly calculate the total +- * header length so placing it in the upper 6-bits here for easier reterival. ++ * header length so placing it in the upper 6-bits here for easier retrieval. + */ + static inline uint8_t + calc_ipsec_desc_iv_len_field(uint16_t iv_sz) +@@ -448,7 +448,7 @@ sa_add_set_auth_params(struct virtchnl_ipsec_crypto_cfg_item *cfg, + /** + * Send SA add virtual channel request to Inline IPsec driver. + * +- * Inline IPsec driver expects SPI and destination IP adderss to be in host ++ * Inline IPsec driver expects SPI and destination IP address to be in host + * order, but DPDK APIs are network order, therefore we need to do a htonl + * conversion of these parameters. + */ +@@ -726,7 +726,7 @@ iavf_ipsec_crypto_action_valid(struct rte_eth_dev *ethdev, + /** + * Send virtual channel security policy add request to IES driver. + * +- * IES driver expects SPI and destination IP adderss to be in host ++ * IES driver expects SPI and destination IP address to be in host + * order, but DPDK APIs are network order, therefore we need to do a htonl + * conversion of these parameters. + */ +@@ -994,7 +994,7 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter, + request->req_id = (uint16_t)0xDEADBEEF; + + /** +- * SA delete supports deletetion of 1-8 specified SA's or if the flag ++ * SA delete supports deletion of 1-8 specified SA's or if the flag + * field is zero, all SA's associated with VF will be deleted. + */ + if (sess) { +@@ -1147,7 +1147,7 @@ iavf_ipsec_crypto_pkt_metadata_set(void *device, + md = RTE_MBUF_DYNFIELD(m, iavf_sctx->pkt_md_offset, + struct iavf_ipsec_crypto_pkt_metadata *); + +- /* Set immutatable metadata values from session template */ ++ /* Set immutable metadata values from session template */ + memcpy(md, &iavf_sess->pkt_metadata_template, + sizeof(struct iavf_ipsec_crypto_pkt_metadata)); + +@@ -1355,7 +1355,7 @@ iavf_ipsec_crypto_set_security_capabililites(struct iavf_security_ctx + capabilities[number_of_capabilities].op = RTE_CRYPTO_OP_TYPE_UNDEFINED; + + /** +- * Iterate over each virtchl crypto capability by crypto type and ++ * Iterate over each virtchnl crypto capability by crypto type and + * algorithm. + */ + for (i = 0; i < VIRTCHNL_IPSEC_MAX_CRYPTO_CAP_NUM; i++) { +@@ -1454,7 +1454,7 @@ iavf_ipsec_crypto_capabilities_get(void *device) + /** + * Update the security capabilities struct with the runtime discovered + * crypto capabilities, except for last element of the array which is +- * the null terminatation ++ * the null termination + */ + for (i = 0; i < ((sizeof(iavf_security_capabilities) / + sizeof(iavf_security_capabilities[0])) - 1); i++) { +diff --git a/drivers/net/iavf/iavf_ipsec_crypto.h b/drivers/net/iavf/iavf_ipsec_crypto.h +index 4e4c8798ec..687541077a 100644 +--- a/drivers/net/iavf/iavf_ipsec_crypto.h ++++ b/drivers/net/iavf/iavf_ipsec_crypto.h +@@ -73,7 +73,7 @@ enum iavf_ipsec_iv_len { + }; + + +-/* IPsec Crypto Packet Metaday offload flags */ ++/* IPsec Crypto Packet Metadata offload flags */ + #define IAVF_IPSEC_CRYPTO_OL_FLAGS_IS_TUN (0x1 << 0) + #define IAVF_IPSEC_CRYPTO_OL_FLAGS_ESN (0x1 << 1) + #define IAVF_IPSEC_CRYPTO_OL_FLAGS_IPV6_EXT_HDRS (0x1 << 2) +diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c +index 154472c50f..59623ac820 100644 +--- a/drivers/net/iavf/iavf_rxtx.c ++++ b/drivers/net/iavf/iavf_rxtx.c +@@ -648,8 +648,8 @@ iavf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, + return -ENOMEM; + } + +- /* Allocate the maximun number of RX ring hardware descriptor with +- * a liitle more to support bulk allocate. ++ /* Allocate the maximum number of RX ring hardware descriptor with ++ * a little more to support bulk allocate. + */ + len = IAVF_MAX_RING_DESC + IAVF_RX_MAX_BURST; + ring_size = RTE_ALIGN(len * sizeof(union iavf_rx_desc), +diff --git a/drivers/net/iavf/iavf_rxtx_vec_sse.c b/drivers/net/iavf/iavf_rxtx_vec_sse.c +index 1bac59bf0e..d582a36326 100644 +--- a/drivers/net/iavf/iavf_rxtx_vec_sse.c ++++ b/drivers/net/iavf/iavf_rxtx_vec_sse.c +@@ -159,7 +159,7 @@ desc_to_olflags_v(struct iavf_rx_queue *rxq, __m128i descs[4], + l3_l4e = _mm_shuffle_epi8(l3_l4e_flags, l3_l4e); + /* then we shift left 1 bit */ + l3_l4e = _mm_slli_epi32(l3_l4e, 1); +- /* we need to mask out the reduntant bits */ ++ /* we need to mask out the redundant bits */ + l3_l4e = _mm_and_si128(l3_l4e, cksum_mask); + + vlan0 = _mm_or_si128(vlan0, rss); +@@ -613,7 +613,7 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts, + _mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1, + pkt_mb1); + desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl); +- /* C.4 calc avaialbe number of desc */ ++ /* C.4 calc available number of desc */ + var = __builtin_popcountll(_mm_cvtsi128_si64(staterr)); + nb_pkts_recd += var; + if (likely(var != IAVF_VPMD_DESCS_PER_LOOP)) +diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c +index 145b059837..7602691649 100644 +--- a/drivers/net/iavf/iavf_vchnl.c ++++ b/drivers/net/iavf/iavf_vchnl.c +@@ -461,7 +461,7 @@ iavf_check_api_version(struct iavf_adapter *adapter) + (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR_START && + vf->virtchnl_version.minor < VIRTCHNL_VERSION_MINOR_START)) { + PMD_INIT_LOG(ERR, "VIRTCHNL API version should not be lower" +- " than (%u.%u) to support Adapative VF", ++ " than (%u.%u) to support Adaptive VF", + VIRTCHNL_VERSION_MAJOR_START, + VIRTCHNL_VERSION_MAJOR_START); + return -1; +@@ -1487,7 +1487,7 @@ iavf_fdir_check(struct iavf_adapter *adapter, + + err = iavf_execute_vf_cmd(adapter, &args, 0); + if (err) { +- PMD_DRV_LOG(ERR, "fail to check flow direcotor rule"); ++ PMD_DRV_LOG(ERR, "fail to check flow director rule"); + return err; + } + +diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c +index cca1d7bf46..7f0c074b01 100644 +--- a/drivers/net/ice/ice_dcf.c ++++ b/drivers/net/ice/ice_dcf.c +@@ -864,7 +864,7 @@ ice_dcf_init_rss(struct ice_dcf_hw *hw) + j = 0; + hw->rss_lut[i] = j; + } +- /* send virtchnnl ops to configure rss*/ ++ /* send virtchnl ops to configure RSS */ + ret = ice_dcf_configure_rss_lut(hw); + if (ret) + return ret; +diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c +index 28f7f7fb72..164d834a18 100644 +--- a/drivers/net/ice/ice_dcf_ethdev.c ++++ b/drivers/net/ice/ice_dcf_ethdev.c +@@ -203,7 +203,7 @@ ice_dcf_config_rx_queues_irqs(struct rte_eth_dev *dev, + "vector %u are mapping to all Rx queues", + hw->msix_base); + } else { +- /* If Rx interrupt is reuquired, and we can use ++ /* If Rx interrupt is required, and we can use + * multi interrupts, then the vec is from 1 + */ + hw->nb_msix = RTE_MIN(hw->vf_res->max_vectors, +diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c +index 13a7a9702a..c9fd3de2bd 100644 +--- a/drivers/net/ice/ice_ethdev.c ++++ b/drivers/net/ice/ice_ethdev.c +@@ -1264,7 +1264,7 @@ ice_handle_aq_msg(struct rte_eth_dev *dev) + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +@@ -1627,7 +1627,7 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type) + } + + /* At the beginning, only TC0. */ +- /* What we need here is the maximam number of the TX queues. ++ /* What we need here is the maximum number of the TX queues. + * Currently vsi->nb_qps means it. + * Correct it if any change. + */ +@@ -3576,7 +3576,7 @@ ice_dev_start(struct rte_eth_dev *dev) + goto rx_err; + } + +- /* enable Rx interrput and mapping Rx queue to interrupt vector */ ++ /* enable Rx interrupt and mapping Rx queue to interrupt vector */ + if (ice_rxq_intr_setup(dev)) + return -EIO; + +@@ -3603,7 +3603,7 @@ ice_dev_start(struct rte_eth_dev *dev) + + ice_dev_set_link_up(dev); + +- /* Call get_link_info aq commond to enable/disable LSE */ ++ /* Call get_link_info aq command to enable/disable LSE */ + ice_link_update(dev, 0); + + pf->adapter_stopped = false; +@@ -5395,7 +5395,7 @@ ice_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + count++; + } + +- /* Get individiual stats from ice_hw_port struct */ ++ /* Get individual stats from ice_hw_port struct */ + for (i = 0; i < ICE_NB_HW_PORT_XSTATS; i++) { + xstats[count].value = + *(uint64_t *)((char *)hw_stats + +@@ -5426,7 +5426,7 @@ static int ice_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + count++; + } + +- /* Get individiual stats from ice_hw_port struct */ ++ /* Get individual stats from ice_hw_port struct */ + for (i = 0; i < ICE_NB_HW_PORT_XSTATS; i++) { + strlcpy(xstats_names[count].name, ice_hw_port_strings[i].name, + sizeof(xstats_names[count].name)); +diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c +index f6d8564ab8..c80d86915e 100644 +--- a/drivers/net/ice/ice_rxtx.c ++++ b/drivers/net/ice/ice_rxtx.c +@@ -1118,7 +1118,7 @@ ice_rx_queue_setup(struct rte_eth_dev *dev, + rxq->proto_xtr = pf->proto_xtr != NULL ? + pf->proto_xtr[queue_idx] : PROTO_XTR_NONE; + +- /* Allocate the maximun number of RX ring hardware descriptor. */ ++ /* Allocate the maximum number of RX ring hardware descriptor. */ + len = ICE_MAX_RING_DESC; + + /** +@@ -1248,7 +1248,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev, + tx_free_thresh = (uint16_t)(tx_conf->tx_free_thresh ? + tx_conf->tx_free_thresh : + ICE_DEFAULT_TX_FREE_THRESH); +- /* force tx_rs_thresh to adapt an aggresive tx_free_thresh */ ++ /* force tx_rs_thresh to adapt an aggressive tx_free_thresh */ + tx_rs_thresh = + (ICE_DEFAULT_TX_RSBIT_THRESH + tx_free_thresh > nb_desc) ? + nb_desc - tx_free_thresh : ICE_DEFAULT_TX_RSBIT_THRESH; +@@ -1714,7 +1714,7 @@ ice_rx_alloc_bufs(struct ice_rx_queue *rxq) + rxdp[i].read.pkt_addr = dma_addr; + } + +- /* Update rx tail regsiter */ ++ /* Update Rx tail register */ + ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger); + + rxq->rx_free_trigger = +@@ -1976,7 +1976,7 @@ ice_recv_scattered_pkts(void *rx_queue, + * threshold of the queue, advance the Receive Descriptor Tail (RDT) + * register. Update the RDT with the value of the last processed RX + * descriptor minus 1, to guarantee that the RDT register is never +- * equal to the RDH register, which creates a "full" ring situtation ++ * equal to the RDH register, which creates a "full" ring situation + * from the hardware point of view. + */ + nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold); +@@ -3117,7 +3117,7 @@ tx_xmit_pkts(struct ice_tx_queue *txq, + ice_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n)); + txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n)); + +- /* Determin if RS bit needs to be set */ ++ /* Determine if RS bit needs to be set */ + if (txq->tx_tail > txq->tx_next_rs) { + txr[txq->tx_next_rs].cmd_type_offset_bsz |= + rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) << +diff --git a/drivers/net/ice/ice_rxtx_vec_sse.c b/drivers/net/ice/ice_rxtx_vec_sse.c +index 6cd44c5847..fd94cedde3 100644 +--- a/drivers/net/ice/ice_rxtx_vec_sse.c ++++ b/drivers/net/ice/ice_rxtx_vec_sse.c +@@ -202,7 +202,7 @@ ice_rx_desc_to_olflags_v(struct ice_rx_queue *rxq, __m128i descs[4], + __m128i l3_l4_mask = _mm_set_epi32(~0x6, ~0x6, ~0x6, ~0x6); + __m128i l3_l4_flags = _mm_and_si128(flags, l3_l4_mask); + flags = _mm_or_si128(l3_l4_flags, l4_outer_flags); +- /* we need to mask out the reduntant bits introduced by RSS or ++ /* we need to mask out the redundant bits introduced by RSS or + * VLAN fields. + */ + flags = _mm_and_si128(flags, cksum_mask); +@@ -566,7 +566,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts, + _mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1, + pkt_mb0); + ice_rx_desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl); +- /* C.4 calc avaialbe number of desc */ ++ /* C.4 calc available number of desc */ + var = __builtin_popcountll(_mm_cvtsi128_si64(staterr)); + nb_pkts_recd += var; + if (likely(var != ICE_DESCS_PER_LOOP)) +diff --git a/drivers/net/igc/igc_filter.c b/drivers/net/igc/igc_filter.c +index 51fcabfb59..bff98df200 100644 +--- a/drivers/net/igc/igc_filter.c ++++ b/drivers/net/igc/igc_filter.c +@@ -167,7 +167,7 @@ igc_tuple_filter_lookup(const struct igc_adapter *igc, + /* search the filter array */ + for (; i < IGC_MAX_NTUPLE_FILTERS; i++) { + if (igc->ntuple_filters[i].hash_val) { +- /* compare the hase value */ ++ /* compare the hash value */ + if (ntuple->hash_val == + igc->ntuple_filters[i].hash_val) + /* filter be found, return index */ +diff --git a/drivers/net/igc/igc_txrx.c b/drivers/net/igc/igc_txrx.c +index 339b0c9aa1..e48d5df11a 100644 +--- a/drivers/net/igc/igc_txrx.c ++++ b/drivers/net/igc/igc_txrx.c +@@ -2099,7 +2099,7 @@ eth_igc_tx_done_cleanup(void *txqueue, uint32_t free_cnt) + sw_ring[tx_id].mbuf = NULL; + sw_ring[tx_id].last_id = tx_id; + +- /* Move to next segemnt. */ ++ /* Move to next segment. */ + tx_id = sw_ring[tx_id].next_id; + } while (tx_id != tx_next); + +@@ -2133,7 +2133,7 @@ eth_igc_tx_done_cleanup(void *txqueue, uint32_t free_cnt) + * Walk the list and find the next mbuf, if any. + */ + do { +- /* Move to next segemnt. */ ++ /* Move to next segment. */ + tx_id = sw_ring[tx_id].next_id; + + if (sw_ring[tx_id].mbuf) +diff --git a/drivers/net/ionic/ionic_if.h b/drivers/net/ionic/ionic_if.h +index 693b44d764..45bad9b040 100644 +--- a/drivers/net/ionic/ionic_if.h ++++ b/drivers/net/ionic/ionic_if.h +@@ -2068,7 +2068,7 @@ typedef struct ionic_admin_comp ionic_fw_download_comp; + * enum ionic_fw_control_oper - FW control operations + * @IONIC_FW_RESET: Reset firmware + * @IONIC_FW_INSTALL: Install firmware +- * @IONIC_FW_ACTIVATE: Acticate firmware ++ * @IONIC_FW_ACTIVATE: Activate firmware + */ + enum ionic_fw_control_oper { + IONIC_FW_RESET = 0, +@@ -2091,7 +2091,7 @@ struct ionic_fw_control_cmd { + }; + + /** +- * struct ionic_fw_control_comp - Firmware control copletion ++ * struct ionic_fw_control_comp - Firmware control completion + * @status: Status of the command (enum ionic_status_code) + * @comp_index: Index in the descriptor ring for which this is the completion + * @slot: Slot where the firmware was installed +@@ -2878,7 +2878,7 @@ struct ionic_doorbell { + * and @identity->intr_coal_div to convert from + * usecs to device units: + * +- * coal_init = coal_usecs * coal_mutl / coal_div ++ * coal_init = coal_usecs * coal_mult / coal_div + * + * When an interrupt is sent the interrupt + * coalescing timer current value +diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c +index 964506c6db..014e438dd5 100644 +--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c ++++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c +@@ -483,7 +483,7 @@ static int ipn3ke_vswitch_probe(struct rte_afu_device *afu_dev) + RTE_CACHE_LINE_SIZE, + afu_dev->device.numa_node); + if (!hw) { +- IPN3KE_AFU_PMD_ERR("failed to allocate hardwart data"); ++ IPN3KE_AFU_PMD_ERR("failed to allocate hardware data"); + retval = -ENOMEM; + return -ENOMEM; + } +diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h +index 041f13d9c3..58fcc50c57 100644 +--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h ++++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h +@@ -223,7 +223,7 @@ struct ipn3ke_hw_cap { + }; + + /** +- * Strucute to store private data for each representor instance ++ * Structure to store private data for each representor instance + */ + struct ipn3ke_rpst { + TAILQ_ENTRY(ipn3ke_rpst) next; /**< Next in device list. */ +@@ -237,7 +237,7 @@ struct ipn3ke_rpst { + uint16_t i40e_pf_eth_port_id; + struct rte_eth_link ori_linfo; + struct ipn3ke_tm_internals tm; +- /**< Private data store of assocaiated physical function */ ++ /**< Private data store of associated physical function */ + struct rte_ether_addr mac_addr; + }; + +diff --git a/drivers/net/ipn3ke/ipn3ke_flow.c b/drivers/net/ipn3ke/ipn3ke_flow.c +index f5867ca055..66ae31a5a9 100644 +--- a/drivers/net/ipn3ke/ipn3ke_flow.c ++++ b/drivers/net/ipn3ke/ipn3ke_flow.c +@@ -1299,7 +1299,7 @@ int ipn3ke_flow_init(void *dev) + IPN3KE_AFU_PMD_DEBUG("IPN3KE_CLF_LKUP_ENABLE: %x\n", data); + + +- /* configure rx parse config, settings associatied with VxLAN */ ++ /* configure rx parse config, settings associated with VxLAN */ + IPN3KE_MASK_WRITE_REG(hw, + IPN3KE_CLF_RX_PARSE_CFG, + 0, +diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c +index 8139e13a23..abbecfdf2e 100644 +--- a/drivers/net/ipn3ke/ipn3ke_representor.c ++++ b/drivers/net/ipn3ke/ipn3ke_representor.c +@@ -2279,7 +2279,7 @@ ipn3ke_rpst_xstats_get + count++; + } + +- /* Get individiual stats from ipn3ke_rpst_hw_port */ ++ /* Get individual stats from ipn3ke_rpst_hw_port */ + for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) { + xstats[count].value = *(uint64_t *)(((char *)(&hw_stats)) + + ipn3ke_rpst_hw_port_strings[i].offset); +@@ -2287,7 +2287,7 @@ ipn3ke_rpst_xstats_get + count++; + } + +- /* Get individiual stats from ipn3ke_rpst_rxq_pri */ ++ /* Get individual stats from ipn3ke_rpst_rxq_pri */ + for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) { + for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) { + xstats[count].value = +@@ -2299,7 +2299,7 @@ ipn3ke_rpst_xstats_get + } + } + +- /* Get individiual stats from ipn3ke_rpst_txq_prio */ ++ /* Get individual stats from ipn3ke_rpst_txq_prio */ + for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) { + for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) { + xstats[count].value = +@@ -2337,7 +2337,7 @@ __rte_unused unsigned int limit) + count++; + } + +- /* Get individiual stats from ipn3ke_rpst_hw_port */ ++ /* Get individual stats from ipn3ke_rpst_hw_port */ + for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) { + snprintf(xstats_names[count].name, + sizeof(xstats_names[count].name), +@@ -2346,7 +2346,7 @@ __rte_unused unsigned int limit) + count++; + } + +- /* Get individiual stats from ipn3ke_rpst_rxq_pri */ ++ /* Get individual stats from ipn3ke_rpst_rxq_pri */ + for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) { + for (prio = 0; prio < 8; prio++) { + snprintf(xstats_names[count].name, +@@ -2358,7 +2358,7 @@ __rte_unused unsigned int limit) + } + } + +- /* Get individiual stats from ipn3ke_rpst_txq_prio */ ++ /* Get individual stats from ipn3ke_rpst_txq_prio */ + for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) { + for (prio = 0; prio < 8; prio++) { + snprintf(xstats_names[count].name, +diff --git a/drivers/net/ipn3ke/meson.build b/drivers/net/ipn3ke/meson.build +index 4bf739809e..104d2f58e5 100644 +--- a/drivers/net/ipn3ke/meson.build ++++ b/drivers/net/ipn3ke/meson.build +@@ -8,7 +8,7 @@ if is_windows + endif + + # +-# Add the experimenatal APIs called from this PMD ++# Add the experimental APIs called from this PMD + # rte_eth_switch_domain_alloc() + # rte_eth_dev_create() + # rte_eth_dev_destroy() +diff --git a/drivers/net/ixgbe/ixgbe_bypass.c b/drivers/net/ixgbe/ixgbe_bypass.c +index 67ced6c723..94f34a2996 100644 +--- a/drivers/net/ixgbe/ixgbe_bypass.c ++++ b/drivers/net/ixgbe/ixgbe_bypass.c +@@ -11,7 +11,7 @@ + + #define BYPASS_STATUS_OFF_MASK 3 + +-/* Macros to check for invlaid function pointers. */ ++/* Macros to check for invalid function pointers. */ + #define FUNC_PTR_OR_ERR_RET(func, retval) do { \ + if ((func) == NULL) { \ + PMD_DRV_LOG(ERR, "%s:%d function not supported", \ +diff --git a/drivers/net/ixgbe/ixgbe_bypass_api.h b/drivers/net/ixgbe/ixgbe_bypass_api.h +index 8eb773391b..6ef965dbb6 100644 +--- a/drivers/net/ixgbe/ixgbe_bypass_api.h ++++ b/drivers/net/ixgbe/ixgbe_bypass_api.h +@@ -135,7 +135,7 @@ static s32 ixgbe_bypass_rw_generic(struct ixgbe_hw *hw, u32 cmd, u32 *status) + * ixgbe_bypass_valid_rd_generic - Verify valid return from bit-bang. + * + * If we send a write we can't be sure it took until we can read back +- * that same register. It can be a problem as some of the feilds may ++ * that same register. It can be a problem as some of the fields may + * for valid reasons change between the time wrote the register and + * we read it again to verify. So this function check everything we + * can check and then assumes it worked. +@@ -189,7 +189,7 @@ static bool ixgbe_bypass_valid_rd_generic(u32 in_reg, u32 out_reg) + } + + /** +- * ixgbe_bypass_set_generic - Set a bypass field in the FW CTRL Regiter. ++ * ixgbe_bypass_set_generic - Set a bypass field in the FW CTRL Register. + * + * @hw: pointer to hardware structure + * @cmd: The control word we are setting. +diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c +index fe61dba81d..c8f0460440 100644 +--- a/drivers/net/ixgbe/ixgbe_ethdev.c ++++ b/drivers/net/ixgbe/ixgbe_ethdev.c +@@ -2375,7 +2375,7 @@ ixgbe_dev_configure(struct rte_eth_dev *dev) + if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) + dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; + +- /* multipe queue mode checking */ ++ /* multiple queue mode checking */ + ret = ixgbe_check_mq_mode(dev); + if (ret != 0) { + PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.", +@@ -2603,7 +2603,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev) + } + } + +- /* confiugre msix for sleep until rx interrupt */ ++ /* configure MSI-X for sleep until Rx interrupt */ + ixgbe_configure_msix(dev); + + /* initialize transmission unit */ +@@ -2907,7 +2907,7 @@ ixgbe_dev_set_link_up(struct rte_eth_dev *dev) + if (hw->mac.type == ixgbe_mac_82599EB) { + #ifdef RTE_LIBRTE_IXGBE_BYPASS + if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) { +- /* Not suported in bypass mode */ ++ /* Not supported in bypass mode */ + PMD_INIT_LOG(ERR, "Set link up is not supported " + "by device id 0x%x", hw->device_id); + return -ENOTSUP; +@@ -2938,7 +2938,7 @@ ixgbe_dev_set_link_down(struct rte_eth_dev *dev) + if (hw->mac.type == ixgbe_mac_82599EB) { + #ifdef RTE_LIBRTE_IXGBE_BYPASS + if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) { +- /* Not suported in bypass mode */ ++ /* Not supported in bypass mode */ + PMD_INIT_LOG(ERR, "Set link down is not supported " + "by device id 0x%x", hw->device_id); + return -ENOTSUP; +@@ -4603,7 +4603,7 @@ ixgbe_dev_interrupt_action(struct rte_eth_dev *dev) + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +@@ -4659,7 +4659,7 @@ ixgbe_dev_interrupt_delayed_handler(void *param) + * @param handle + * Pointer to interrupt handle. + * @param param +- * The address of parameter (struct rte_eth_dev *) regsitered before. ++ * The address of parameter (struct rte_eth_dev *) registered before. + * + * @return + * void +@@ -5921,7 +5921,7 @@ ixgbevf_configure_msix(struct rte_eth_dev *dev) + /* Configure all RX queues of VF */ + for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) { + /* Force all queue use vector 0, +- * as IXGBE_VF_MAXMSIVECOTR = 1 ++ * as IXGBE_VF_MAXMSIVECTOR = 1 + */ + ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx); + rte_intr_vec_list_index_set(intr_handle, q_idx, +@@ -6256,7 +6256,7 @@ ixgbe_inject_5tuple_filter(struct rte_eth_dev *dev, + * @param + * dev: Pointer to struct rte_eth_dev. + * index: the index the filter allocates. +- * filter: ponter to the filter that will be added. ++ * filter: pointer to the filter that will be added. + * rx_queue: the queue id the filter assigned to. + * + * @return +@@ -6872,7 +6872,7 @@ ixgbe_timesync_disable(struct rte_eth_dev *dev) + /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */ + IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0); + +- /* Stop incrementating the System Time registers. */ ++ /* Stop incrementing the System Time registers. */ + IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0); + + return 0; +diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h +index 83e8b5e56a..69e0e82a5b 100644 +--- a/drivers/net/ixgbe/ixgbe_ethdev.h ++++ b/drivers/net/ixgbe/ixgbe_ethdev.h +@@ -68,7 +68,7 @@ + #define IXGBE_LPBK_NONE 0x0 /* Default value. Loopback is disabled. */ + #define IXGBE_LPBK_TX_RX 0x1 /* Tx->Rx loopback operation is enabled. */ + /* X540-X550 specific loopback operations */ +-#define IXGBE_MII_AUTONEG_ENABLE 0x1000 /* Auto-negociation enable (default = 1) */ ++#define IXGBE_MII_AUTONEG_ENABLE 0x1000 /* Auto-negotiation enable (default = 1) */ + + #define IXGBE_MAX_JUMBO_FRAME_SIZE 0x2600 /* Maximum Jumbo frame size. */ + +diff --git a/drivers/net/ixgbe/ixgbe_fdir.c b/drivers/net/ixgbe/ixgbe_fdir.c +index 7894047829..834c1b3f51 100644 +--- a/drivers/net/ixgbe/ixgbe_fdir.c ++++ b/drivers/net/ixgbe/ixgbe_fdir.c +@@ -390,7 +390,7 @@ fdir_set_input_mask_x550(struct rte_eth_dev *dev) + + switch (info->mask.tunnel_type_mask) { + case 0: +- /* Mask turnnel type */ ++ /* Mask tunnel type */ + fdiripv6m |= IXGBE_FDIRIP6M_TUNNEL_TYPE; + break; + case 1: +diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c +index bdc9d4796c..368342872a 100644 +--- a/drivers/net/ixgbe/ixgbe_flow.c ++++ b/drivers/net/ixgbe/ixgbe_flow.c +@@ -135,7 +135,7 @@ const struct rte_flow_action *next_no_void_action( + } + + /** +- * Please aware there's an asumption for all the parsers. ++ * Please be aware there's an assumption for all the parsers. + * rte_flow_item is using big endian, rte_flow_attr and + * rte_flow_action are using CPU order. + * Because the pattern is used to describe the packets, +@@ -3261,7 +3261,7 @@ ixgbe_flow_create(struct rte_eth_dev *dev, + + /** + * Check if the flow rule is supported by ixgbe. +- * It only checkes the format. Don't guarantee the rule can be programmed into ++ * It only checks the format. Don't guarantee the rule can be programmed into + * the HW. Because there can be no enough room for the rule. + */ + static int +diff --git a/drivers/net/ixgbe/ixgbe_ipsec.c b/drivers/net/ixgbe/ixgbe_ipsec.c +index 944c9f2380..c353ae33b4 100644 +--- a/drivers/net/ixgbe/ixgbe_ipsec.c ++++ b/drivers/net/ixgbe/ixgbe_ipsec.c +@@ -310,7 +310,7 @@ ixgbe_crypto_remove_sa(struct rte_eth_dev *dev, + return -1; + } + +- /* Disable and clear Rx SPI and key table table entryes*/ ++ /* Disable and clear Rx SPI and key table table entries*/ + reg_val = IPSRXIDX_WRITE | IPSRXIDX_TABLE_SPI | (sa_index << 3); + IXGBE_WRITE_REG(hw, IXGBE_IPSRXSPI, 0); + IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPIDX, 0); +diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c +index 9f1bd0a62b..c73833b7ae 100644 +--- a/drivers/net/ixgbe/ixgbe_pf.c ++++ b/drivers/net/ixgbe/ixgbe_pf.c +@@ -242,7 +242,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev) + /* PFDMA Tx General Switch Control Enables VMDQ loopback */ + IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN); + +- /* clear VMDq map to perment rar 0 */ ++ /* clear VMDq map to permanent rar 0 */ + hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL); + + /* clear VMDq map to scan rar 127 */ +diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c +index d7c80d4242..99e928a2a9 100644 +--- a/drivers/net/ixgbe/ixgbe_rxtx.c ++++ b/drivers/net/ixgbe/ixgbe_rxtx.c +@@ -1954,7 +1954,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + * register. + * Update the RDT with the value of the last processed RX descriptor + * minus 1, to guarantee that the RDT register is never equal to the +- * RDH register, which creates a "full" ring situtation from the ++ * RDH register, which creates a "full" ring situation from the + * hardware point of view... + */ + nb_hold = (uint16_t) (nb_hold + rxq->nb_rx_hold); +@@ -2303,7 +2303,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, + * register. + * Update the RDT with the value of the last processed RX descriptor + * minus 1, to guarantee that the RDT register is never equal to the +- * RDH register, which creates a "full" ring situtation from the ++ * RDH register, which creates a "full" ring situation from the + * hardware point of view... + */ + if (!bulk_alloc && nb_hold > rxq->rx_free_thresh) { +@@ -2666,7 +2666,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, + */ + tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ? + tx_conf->tx_free_thresh : DEFAULT_TX_FREE_THRESH); +- /* force tx_rs_thresh to adapt an aggresive tx_free_thresh */ ++ /* force tx_rs_thresh to adapt an aggressive tx_free_thresh */ + tx_rs_thresh = (DEFAULT_TX_RS_THRESH + tx_free_thresh > nb_desc) ? + nb_desc - tx_free_thresh : DEFAULT_TX_RS_THRESH; + if (tx_conf->tx_rs_thresh > 0) +@@ -4831,7 +4831,7 @@ ixgbe_set_rx_function(struct rte_eth_dev *dev) + dev->data->port_id); + dev->rx_pkt_burst = ixgbe_recv_pkts_lro_bulk_alloc; + } else { +- PMD_INIT_LOG(DEBUG, "Using Regualr (non-vector, " ++ PMD_INIT_LOG(DEBUG, "Using Regular (non-vector, " + "single allocation) " + "Scattered Rx callback " + "(port=%d).", +@@ -5170,7 +5170,7 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev) + /* + * Setup the Checksum Register. + * Disable Full-Packet Checksum which is mutually exclusive with RSS. +- * Enable IP/L4 checkum computation by hardware if requested to do so. ++ * Enable IP/L4 checksum computation by hardware if requested to do so. + */ + rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM); + rxcsum |= IXGBE_RXCSUM_PCSD; +diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +index 1eed949495..c56f76b368 100644 +--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c ++++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +@@ -562,7 +562,7 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts, + + desc_to_ptype_v(descs, rxq->pkt_type_mask, &rx_pkts[pos]); + +- /* C.4 calc avaialbe number of desc */ ++ /* C.4 calc available number of desc */ + var = __builtin_popcountll(_mm_cvtsi128_si64(staterr)); + nb_pkts_recd += var; + if (likely(var != RTE_IXGBE_DESCS_PER_LOOP)) +diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c +index 079cf01269..42f48a68a1 100644 +--- a/drivers/net/memif/memif_socket.c ++++ b/drivers/net/memif/memif_socket.c +@@ -726,7 +726,7 @@ memif_msg_receive(struct memif_control_channel *cc) + break; + case MEMIF_MSG_TYPE_INIT: + /* +- * This cc does not have an interface asociated with it. ++ * This cc does not have an interface associated with it. + * If suitable interface is found it will be assigned here. + */ + ret = memif_msg_receive_init(cc, &msg); +diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c +index e3d523af57..59cb5a82a2 100644 +--- a/drivers/net/memif/rte_eth_memif.c ++++ b/drivers/net/memif/rte_eth_memif.c +@@ -1026,7 +1026,7 @@ memif_regions_init(struct rte_eth_dev *dev) + if (ret < 0) + return ret; + } else { +- /* create one memory region contaning rings and buffers */ ++ /* create one memory region containing rings and buffers */ + ret = memif_region_init_shm(dev, /* has buffers */ 1); + if (ret < 0) + return ret; +diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h +index 2d0c512f79..4023a47602 100644 +--- a/drivers/net/mlx4/mlx4.h ++++ b/drivers/net/mlx4/mlx4.h +@@ -74,7 +74,7 @@ enum mlx4_mp_req_type { + MLX4_MP_REQ_STOP_RXTX, + }; + +-/* Pameters for IPC. */ ++/* Parameters for IPC. */ + struct mlx4_mp_param { + enum mlx4_mp_req_type type; + int port_id; +diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c +index d606ec8ca7..ce74c51ce2 100644 +--- a/drivers/net/mlx4/mlx4_ethdev.c ++++ b/drivers/net/mlx4/mlx4_ethdev.c +@@ -752,7 +752,7 @@ mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) + * Pointer to Ethernet device structure. + * + * @return +- * alwasy 0 on success ++ * always 0 on success + */ + int + mlx4_stats_reset(struct rte_eth_dev *dev) +diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c +index c29fe3d92b..36f0fbf04a 100644 +--- a/drivers/net/mlx5/linux/mlx5_os.c ++++ b/drivers/net/mlx5/linux/mlx5_os.c +@@ -112,7 +112,7 @@ static struct mlx5_indexed_pool_config icfg[] = { + * Pointer to RQ channel object, which includes the channel fd + * + * @param[out] fd +- * The file descriptor (representing the intetrrupt) used in this channel. ++ * The file descriptor (representing the interrupt) used in this channel. + * + * @return + * 0 on successfully setting the fd to non-blocking, non-zero otherwise. +@@ -1743,7 +1743,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, + priv->drop_queue.hrxq = mlx5_drop_action_create(eth_dev); + if (!priv->drop_queue.hrxq) + goto error; +- /* Port representor shares the same max prioirity with pf port. */ ++ /* Port representor shares the same max priority with pf port. */ + if (!priv->sh->flow_priority_check_flag) { + /* Supported Verbs flow priority number detection. */ + err = mlx5_flow_discover_priorities(eth_dev); +@@ -2300,7 +2300,7 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev, + /* + * Force standalone bonding + * device for ROCE LAG +- * confgiurations. ++ * configurations. + */ + list[ns].info.master = 0; + list[ns].info.representor = 0; +@@ -2637,7 +2637,7 @@ mlx5_os_pci_probe(struct mlx5_common_device *cdev) + } + if (ret) { + DRV_LOG(ERR, "Probe of PCI device " PCI_PRI_FMT " " +- "aborted due to proding failure of PF %u", ++ "aborted due to prodding failure of PF %u", + pci_dev->addr.domain, pci_dev->addr.bus, + pci_dev->addr.devid, pci_dev->addr.function, + eth_da.ports[p]); +diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c +index aa5f313c1a..8b4387d6b4 100644 +--- a/drivers/net/mlx5/mlx5.c ++++ b/drivers/net/mlx5/mlx5.c +@@ -1642,7 +1642,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) + /* + * Free the shared context in last turn, because the cleanup + * routines above may use some shared fields, like +- * mlx5_os_mac_addr_flush() uses ibdev_path for retrieveing ++ * mlx5_os_mac_addr_flush() uses ibdev_path for retrieving + * ifindex if Netlink fails. + */ + mlx5_free_shared_dev_ctx(priv->sh); +@@ -1962,7 +1962,7 @@ mlx5_args_check(const char *key, const char *val, void *opaque) + if (tmp != MLX5_RCM_NONE && + tmp != MLX5_RCM_LIGHT && + tmp != MLX5_RCM_AGGR) { +- DRV_LOG(ERR, "Unrecognize %s: \"%s\"", key, val); ++ DRV_LOG(ERR, "Unrecognized %s: \"%s\"", key, val); + rte_errno = EINVAL; + return -rte_errno; + } +@@ -2177,17 +2177,17 @@ mlx5_set_metadata_mask(struct rte_eth_dev *dev) + break; + } + if (sh->dv_mark_mask && sh->dv_mark_mask != mark) +- DRV_LOG(WARNING, "metadata MARK mask mismatche %08X:%08X", ++ DRV_LOG(WARNING, "metadata MARK mask mismatch %08X:%08X", + sh->dv_mark_mask, mark); + else + sh->dv_mark_mask = mark; + if (sh->dv_meta_mask && sh->dv_meta_mask != meta) +- DRV_LOG(WARNING, "metadata META mask mismatche %08X:%08X", ++ DRV_LOG(WARNING, "metadata META mask mismatch %08X:%08X", + sh->dv_meta_mask, meta); + else + sh->dv_meta_mask = meta; + if (sh->dv_regc0_mask && sh->dv_regc0_mask != reg_c0) +- DRV_LOG(WARNING, "metadata reg_c0 mask mismatche %08X:%08X", ++ DRV_LOG(WARNING, "metadata reg_c0 mask mismatch %08X:%08X", + sh->dv_meta_mask, reg_c0); + else + sh->dv_regc0_mask = reg_c0; +diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h +index 8466531060..b55f5816af 100644 +--- a/drivers/net/mlx5/mlx5.h ++++ b/drivers/net/mlx5/mlx5.h +@@ -977,7 +977,7 @@ struct mlx5_flow_id_pool { + uint32_t base_index; + /**< The next index that can be used without any free elements. */ + uint32_t *curr; /**< Pointer to the index to pop. */ +- uint32_t *last; /**< Pointer to the last element in the empty arrray. */ ++ uint32_t *last; /**< Pointer to the last element in the empty array. */ + uint32_t max_id; /**< Maximum id can be allocated from the pool. */ + }; + +@@ -1014,7 +1014,7 @@ struct mlx5_dev_txpp { + void *pp; /* Packet pacing context. */ + uint16_t pp_id; /* Packet pacing context index. */ + uint16_t ts_n; /* Number of captured timestamps. */ +- uint16_t ts_p; /* Pointer to statisticks timestamp. */ ++ uint16_t ts_p; /* Pointer to statistics timestamp. */ + struct mlx5_txpp_ts *tsa; /* Timestamps sliding window stats. */ + struct mlx5_txpp_ts ts; /* Cached completion id/timestamp. */ + uint32_t sync_lost:1; /* ci/timestamp synchronization lost. */ +@@ -1118,7 +1118,7 @@ struct mlx5_flex_parser_devx { + uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM]; + }; + +-/* Pattern field dscriptor - how to translate flex pattern into samples. */ ++/* Pattern field descriptor - how to translate flex pattern into samples. */ + __extension__ + struct mlx5_flex_pattern_field { + uint16_t width:6; +@@ -1169,7 +1169,7 @@ struct mlx5_dev_ctx_shared { + /* Shared DV/DR flow data section. */ + uint32_t dv_meta_mask; /* flow META metadata supported mask. */ + uint32_t dv_mark_mask; /* flow MARK metadata supported mask. */ +- uint32_t dv_regc0_mask; /* available bits of metatada reg_c[0]. */ ++ uint32_t dv_regc0_mask; /* available bits of metadata reg_c[0]. */ + void *fdb_domain; /* FDB Direct Rules name space handle. */ + void *rx_domain; /* RX Direct Rules name space handle. */ + void *tx_domain; /* TX Direct Rules name space handle. */ +diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c +index f34e4b88aa..b7cf4143d5 100644 +--- a/drivers/net/mlx5/mlx5_flow.c ++++ b/drivers/net/mlx5/mlx5_flow.c +@@ -1206,7 +1206,7 @@ flow_rxq_tunnel_ptype_update(struct mlx5_rxq_ctrl *rxq_ctrl) + } + + /** +- * Set the Rx queue flags (Mark/Flag and Tunnel Ptypes) according to the devive ++ * Set the Rx queue flags (Mark/Flag and Tunnel Ptypes) according to the device + * flow. + * + * @param[in] dev +@@ -3008,7 +3008,7 @@ mlx5_flow_validate_item_geneve_opt(const struct rte_flow_item *item, + if ((uint32_t)spec->option_len > MLX5_GENEVE_OPTLEN_MASK) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, item, +- "Geneve TLV opt length exceeeds the limit (31)"); ++ "Geneve TLV opt length exceeds the limit (31)"); + /* Check if class type and length masks are full. */ + if (full_mask.option_class != mask->option_class || + full_mask.option_type != mask->option_type || +@@ -3957,7 +3957,7 @@ find_graph_root(uint32_t rss_level) + * subflow. + * + * @param[in] dev_flow +- * Pointer the created preifx subflow. ++ * Pointer the created prefix subflow. + * + * @return + * The layers get from prefix subflow. +@@ -4284,7 +4284,7 @@ flow_dv_mreg_create_cb(void *tool_ctx, void *cb_ctx) + [3] = { .type = RTE_FLOW_ACTION_TYPE_END, }, + }; + +- /* Fill the register fileds in the flow. */ ++ /* Fill the register fields in the flow. */ + ret = mlx5_flow_get_reg_id(dev, MLX5_FLOW_MARK, 0, error); + if (ret < 0) + return NULL; +@@ -4353,7 +4353,7 @@ flow_dv_mreg_create_cb(void *tool_ctx, void *cb_ctx) + /* + * The copy Flows are not included in any list. There + * ones are referenced from other Flows and can not +- * be applied, removed, deleted in ardbitrary order ++ * be applied, removed, deleted in arbitrary order + * by list traversing. + */ + mcp_res->rix_flow = flow_list_create(dev, MLX5_FLOW_TYPE_MCP, +@@ -4810,7 +4810,7 @@ flow_create_split_inner(struct rte_eth_dev *dev, + /* + * If dev_flow is as one of the suffix flow, some actions in suffix + * flow may need some user defined item layer flags, and pass the +- * Metadate rxq mark flag to suffix flow as well. ++ * Metadata rxq mark flag to suffix flow as well. + */ + if (flow_split_info->prefix_layers) + dev_flow->handle->layers = flow_split_info->prefix_layers; +@@ -5359,7 +5359,7 @@ flow_mreg_split_qrss_prep(struct rte_eth_dev *dev, + * @param[out] error + * Perform verbose error reporting if not NULL. + * @param[in] encap_idx +- * The encap action inndex. ++ * The encap action index. + * + * @return + * 0 on success, negative value otherwise +@@ -6884,7 +6884,7 @@ flow_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type, + * @param type + * Flow type to be flushed. + * @param active +- * If flushing is called avtively. ++ * If flushing is called actively. + */ + void + mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type, +@@ -8531,7 +8531,7 @@ mlx5_flow_dev_dump_sh_all(struct rte_eth_dev *dev, + * Perform verbose error reporting if not NULL. PMDs initialize this + * structure in case of error only. + * @return +- * 0 on success, a nagative value otherwise. ++ * 0 on success, a negative value otherwise. + */ + int + mlx5_flow_dev_dump(struct rte_eth_dev *dev, struct rte_flow *flow_idx, +@@ -9009,7 +9009,7 @@ mlx5_get_tof(const struct rte_flow_item *item, + } + + /** +- * tunnel offload functionalilty is defined for DV environment only ++ * tunnel offload functionality is defined for DV environment only + */ + #ifdef HAVE_IBV_FLOW_DV_SUPPORT + __extension__ +diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h +index 1f54649c69..8c131d61ae 100644 +--- a/drivers/net/mlx5/mlx5_flow.h ++++ b/drivers/net/mlx5/mlx5_flow.h +@@ -598,7 +598,7 @@ struct mlx5_flow_tbl_data_entry { + const struct mlx5_flow_tunnel *tunnel; + uint32_t group_id; + uint32_t external:1; +- uint32_t tunnel_offload:1; /* Tunnel offlod table or not. */ ++ uint32_t tunnel_offload:1; /* Tunnel offload table or not. */ + uint32_t is_egress:1; /**< Egress table. */ + uint32_t is_transfer:1; /**< Transfer table. */ + uint32_t dummy:1; /**< DR table. */ +@@ -696,8 +696,8 @@ struct mlx5_flow_handle { + /**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ + void *drv_flow; /**< pointer to driver flow object. */ + uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ +- uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ +- uint32_t mark:1; /**< Metadate rxq mark flag. */ ++ uint32_t is_meter_flow_id:1; /**< Indicate if flow_id is for meter. */ ++ uint32_t mark:1; /**< Metadata rxq mark flag. */ + uint32_t fate_action:3; /**< Fate action type. */ + uint32_t flex_item; /**< referenced Flex Item bitmask. */ + union { +diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c +index 3da122cbb9..8022d7d11f 100644 +--- a/drivers/net/mlx5/mlx5_flow_dv.c ++++ b/drivers/net/mlx5/mlx5_flow_dv.c +@@ -2032,7 +2032,7 @@ flow_dv_validate_item_meta(struct rte_eth_dev *dev __rte_unused, + if (reg == REG_NON) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, +- "unavalable extended metadata register"); ++ "unavailable extended metadata register"); + if (reg == REG_B) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, +@@ -3205,7 +3205,7 @@ flow_dv_validate_action_set_meta(struct rte_eth_dev *dev, + if (reg == REG_NON) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, action, +- "unavalable extended metadata register"); ++ "unavailable extended metadata register"); + if (reg != REG_A && reg != REG_B) { + struct mlx5_priv *priv = dev->data->dev_private; + +@@ -5145,7 +5145,7 @@ flow_dv_modify_hdr_action_max(struct rte_eth_dev *dev __rte_unused, + * Pointer to error structure. + * + * @return +- * 0 on success, a negative errno value otherwise and rte_ernno is set. ++ * 0 on success, a negative errno value otherwise and rte_errno is set. + */ + static int + mlx5_flow_validate_action_meter(struct rte_eth_dev *dev, +@@ -7858,7 +7858,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, + * - Explicit decap action is prohibited by the tunnel offload API. + * - Drop action in tunnel steer rule is prohibited by the API. + * - Application cannot use MARK action because it's value can mask +- * tunnel default miss nitification. ++ * tunnel default miss notification. + * - JUMP in tunnel match rule has no support in current PMD + * implementation. + * - TAG & META are reserved for future uses. +@@ -9184,7 +9184,7 @@ flow_dev_geneve_tlv_option_resource_register(struct rte_eth_dev *dev, + geneve_opt_v->option_type && + geneve_opt_resource->length == + geneve_opt_v->option_len) { +- /* We already have GENVE TLV option obj allocated. */ ++ /* We already have GENEVE TLV option obj allocated. */ + __atomic_fetch_add(&geneve_opt_resource->refcnt, 1, + __ATOMIC_RELAXED); + } else { +@@ -10226,7 +10226,7 @@ __flow_dv_adjust_buf_size(size_t *size, uint8_t match_criteria) + * Check flow matching criteria first, subtract misc5/4 length if flow + * doesn't own misc5/4 parameters. In some old rdma-core releases, + * misc5/4 are not supported, and matcher creation failure is expected +- * w/o subtration. If misc5 is provided, misc4 must be counted in since ++ * w/o subtraction. If misc5 is provided, misc4 must be counted in since + * misc5 is right after misc4. + */ + if (!(match_criteria & (1 << MLX5_MATCH_CRITERIA_ENABLE_MISC5_BIT))) { +@@ -11425,7 +11425,7 @@ flow_dv_dest_array_create_cb(void *tool_ctx __rte_unused, void *cb_ctx) + goto error; + } + } +- /* create a dest array actioin */ ++ /* create a dest array action */ + ret = mlx5_os_flow_dr_create_flow_action_dest_array + (domain, + resource->num_of_dest, +diff --git a/drivers/net/mlx5/mlx5_flow_flex.c b/drivers/net/mlx5/mlx5_flow_flex.c +index 64867dc9e2..9413d4d817 100644 +--- a/drivers/net/mlx5/mlx5_flow_flex.c ++++ b/drivers/net/mlx5/mlx5_flow_flex.c +@@ -205,7 +205,7 @@ mlx5_flex_set_match_sample(void *misc4_m, void *misc4_v, + * @param dev + * Ethernet device to translate flex item on. + * @param[in, out] matcher +- * Flow matcher to confgiure ++ * Flow matcher to configure + * @param[in, out] key + * Flow matcher value. + * @param[in] item +@@ -457,7 +457,7 @@ mlx5_flex_translate_length(struct mlx5_hca_flex_attr *attr, + if (field->offset_shift > 15 || field->offset_shift < 0) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, NULL, +- "header length field shift exceeeds limit"); ++ "header length field shift exceeds limit"); + node->header_length_field_shift = field->offset_shift; + node->header_length_field_offset = field->offset_base; + } +diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c +index f4a7b697e6..0e4e6ac3d5 100644 +--- a/drivers/net/mlx5/mlx5_flow_meter.c ++++ b/drivers/net/mlx5/mlx5_flow_meter.c +@@ -251,7 +251,7 @@ mlx5_flow_meter_xir_man_exp_calc(int64_t xir, uint8_t *man, uint8_t *exp) + uint8_t _exp = 0; + uint64_t m, e; + +- /* Special case xir == 0 ? both exp and matissa are 0. */ ++ /* Special case xir == 0 ? both exp and mantissa are 0. */ + if (xir == 0) { + *man = 0; + *exp = 0; +@@ -287,7 +287,7 @@ mlx5_flow_meter_xbs_man_exp_calc(uint64_t xbs, uint8_t *man, uint8_t *exp) + int _exp; + double _man; + +- /* Special case xbs == 0 ? both exp and matissa are 0. */ ++ /* Special case xbs == 0 ? both exp and mantissa are 0. */ + if (xbs == 0) { + *man = 0; + *exp = 0; +@@ -305,7 +305,7 @@ mlx5_flow_meter_xbs_man_exp_calc(uint64_t xbs, uint8_t *man, uint8_t *exp) + * Fill the prm meter parameter. + * + * @param[in,out] fmp +- * Pointer to meter profie to be converted. ++ * Pointer to meter profile to be converted. + * @param[out] error + * Pointer to the error structure. + * +@@ -1101,7 +1101,7 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv, + if (ret) + return ret; + } +- /* Update succeedded modify meter parameters. */ ++ /* Update succeeded modify meter parameters. */ + if (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_ACTIVE) + fm->active_state = !!active_state; + } +@@ -1615,7 +1615,7 @@ mlx5_flow_meter_profile_update(struct rte_eth_dev *dev, + return -rte_mtr_error_set(error, -ret, + RTE_MTR_ERROR_TYPE_MTR_PARAMS, + NULL, "Failed to update meter" +- " parmeters in hardware."); ++ " parameters in hardware."); + } + old_fmp->ref_cnt--; + fmp->ref_cnt++; +diff --git a/drivers/net/mlx5/mlx5_rx.c b/drivers/net/mlx5/mlx5_rx.c +index cc98cd1ea5..11214f6c41 100644 +--- a/drivers/net/mlx5/mlx5_rx.c ++++ b/drivers/net/mlx5/mlx5_rx.c +@@ -178,7 +178,7 @@ mlx5_rxq_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id, + * Pointer to the device structure. + * + * @param rx_queue_id +- * Rx queue identificatior. ++ * Rx queue identification. + * + * @param mode + * Pointer to the burts mode information. +diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c +index f77d42dedf..be5f4da1e5 100644 +--- a/drivers/net/mlx5/mlx5_rxq.c ++++ b/drivers/net/mlx5/mlx5_rxq.c +@@ -2152,7 +2152,7 @@ mlx5_rxq_get_hairpin_conf(struct rte_eth_dev *dev, uint16_t idx) + * Number of queues in the array. + * + * @return +- * 1 if all queues in indirection table match 0 othrwise. ++ * 1 if all queues in indirection table match 0 otherwise. + */ + static int + mlx5_ind_table_obj_match_queues(const struct mlx5_ind_table_obj *ind_tbl, +@@ -2586,7 +2586,7 @@ mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hrxq_idx, + if (hrxq->standalone) { + /* + * Replacement of indirection table unsupported for +- * stanalone hrxq objects (used by shared RSS). ++ * standalone hrxq objects (used by shared RSS). + */ + rte_errno = ENOTSUP; + return -rte_errno; +diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +index 423e229508..f6e434c165 100644 +--- a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h ++++ b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +@@ -1230,7 +1230,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, + uint32_t mask = rxq->flow_meta_port_mask; + uint32_t metadata; + +- /* This code is subject for futher optimization. */ ++ /* This code is subject for further optimization. */ + metadata = rte_be_to_cpu_32 + (cq[pos].flow_table_metadata) & mask; + *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = +diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h +index b1d16baa61..f7bbde4e0e 100644 +--- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h ++++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h +@@ -839,7 +839,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, + } + } + if (rxq->dynf_meta) { +- /* This code is subject for futher optimization. */ ++ /* This code is subject for further optimization. */ + int32_t offs = rxq->flow_meta_offset; + uint32_t mask = rxq->flow_meta_port_mask; + +diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h +index f3d838389e..185d2695db 100644 +--- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h ++++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h +@@ -772,7 +772,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, + } + } + if (rxq->dynf_meta) { +- /* This code is subject for futher optimization. */ ++ /* This code is subject for further optimization. */ + int32_t offs = rxq->flow_meta_offset; + uint32_t mask = rxq->flow_meta_port_mask; + +diff --git a/drivers/net/mlx5/mlx5_tx.c b/drivers/net/mlx5/mlx5_tx.c +index 5492d64cae..fd2cf20967 100644 +--- a/drivers/net/mlx5/mlx5_tx.c ++++ b/drivers/net/mlx5/mlx5_tx.c +@@ -728,7 +728,7 @@ mlx5_txq_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id, + * Pointer to the device structure. + * + * @param tx_queue_id +- * Tx queue identificatior. ++ * Tx queue identification. + * + * @param mode + * Pointer to the burts mode information. +diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h +index cf3db89403..e2dcbafc0a 100644 +--- a/drivers/net/mlx5/mlx5_utils.h ++++ b/drivers/net/mlx5/mlx5_utils.h +@@ -55,7 +55,7 @@ extern int mlx5_logtype; + + /* + * For the case which data is linked with sequence increased index, the +- * array table will be more efficiect than hash table once need to serarch ++ * array table will be more efficient than hash table once need to search + * one data entry in large numbers of entries. Since the traditional hash + * tables has fixed table size, when huge numbers of data saved to the hash + * table, it also comes lots of hash conflict. +diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c +index c4d5790726..7bb4c4590a 100644 +--- a/drivers/net/mlx5/windows/mlx5_flow_os.c ++++ b/drivers/net/mlx5/windows/mlx5_flow_os.c +@@ -400,7 +400,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) + /* + * set_specific_workspace when current value is NULL + * can happen only once per thread, mark this thread in +- * linked list to be able to release reasorces later on. ++ * linked list to be able to release resources later on. + */ + err = mlx5_add_workspace_to_list(data); + if (err) { +diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c +index dec4b923d0..f143724990 100644 +--- a/drivers/net/mlx5/windows/mlx5_os.c ++++ b/drivers/net/mlx5/windows/mlx5_os.c +@@ -226,7 +226,7 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv) + * Pointer to RQ channel object, which includes the channel fd + * + * @param[out] fd +- * The file descriptor (representing the intetrrupt) used in this channel. ++ * The file descriptor (representing the interrupt) used in this channel. + * + * @return + * 0 on successfully setting the fd to non-blocking, non-zero otherwise. +diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c +index 10fe6d828c..eef016aa0b 100644 +--- a/drivers/net/mvneta/mvneta_ethdev.c ++++ b/drivers/net/mvneta/mvneta_ethdev.c +@@ -247,7 +247,7 @@ mvneta_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) + (mru + MRVL_NETA_PKT_OFFS > mbuf_data_size)) { + mru = mbuf_data_size - MRVL_NETA_PKT_OFFS; + mtu = MRVL_NETA_MRU_TO_MTU(mru); +- MVNETA_LOG(WARNING, "MTU too big, max MTU possible limitted by" ++ MVNETA_LOG(WARNING, "MTU too big, max MTU possible limited by" + " current mbuf size: %u. Set MTU to %u, MRU to %u", + mbuf_data_size, mtu, mru); + } +diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c +index 2a8fb6cbce..735efb6cfc 100644 +--- a/drivers/net/mvpp2/mrvl_ethdev.c ++++ b/drivers/net/mvpp2/mrvl_ethdev.c +@@ -579,7 +579,7 @@ mrvl_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) + if (mru - RTE_ETHER_CRC_LEN + MRVL_PKT_OFFS > mbuf_data_size) { + mru = mbuf_data_size + RTE_ETHER_CRC_LEN - MRVL_PKT_OFFS; + mtu = MRVL_PP2_MRU_TO_MTU(mru); +- MRVL_LOG(WARNING, "MTU too big, max MTU possible limitted " ++ MRVL_LOG(WARNING, "MTU too big, max MTU possible limited " + "by current mbuf size: %u. Set MTU to %u, MRU to %u", + mbuf_data_size, mtu, mru); + } +diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c +index dbfc3b5d20..99f0ee56d1 100644 +--- a/drivers/net/mvpp2/mrvl_qos.c ++++ b/drivers/net/mvpp2/mrvl_qos.c +@@ -301,7 +301,7 @@ get_entry_values(const char *entry, uint8_t *tab, + } + + /** +- * Parse Traffic Class'es mapping configuration. ++ * Parse Traffic Classes mapping configuration. + * + * @param file Config file handle. + * @param port Which port to look for. +@@ -736,7 +736,7 @@ mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args) + + /* MRVL_TOK_START_HDR replaces MRVL_TOK_DSA_MODE parameter. + * MRVL_TOK_DSA_MODE will be supported for backward +- * compatibillity. ++ * compatibility. + */ + entry = rte_cfgfile_get_entry(file, sec_name, + MRVL_TOK_START_HDR); +diff --git a/drivers/net/netvsc/hn_nvs.c b/drivers/net/netvsc/hn_nvs.c +index 89dbba6cd9..a29ac18ff4 100644 +--- a/drivers/net/netvsc/hn_nvs.c ++++ b/drivers/net/netvsc/hn_nvs.c +@@ -229,7 +229,7 @@ hn_nvs_conn_rxbuf(struct hn_data *hv) + hv->rxbuf_section_cnt = resp.nvs_sect[0].slotcnt; + + /* +- * Pimary queue's rxbuf_info is not allocated at creation time. ++ * Primary queue's rxbuf_info is not allocated at creation time. + * Now we can allocate it after we figure out the slotcnt. + */ + hv->primary->rxbuf_info = rte_calloc("HN_RXBUF_INFO", +diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c +index 028f176c7e..50ca1710ef 100644 +--- a/drivers/net/netvsc/hn_rxtx.c ++++ b/drivers/net/netvsc/hn_rxtx.c +@@ -578,7 +578,7 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb, + rte_iova_t iova; + + /* +- * Build an external mbuf that points to recveive area. ++ * Build an external mbuf that points to receive area. + * Use refcount to handle multiple packets in same + * receive buffer section. + */ +@@ -1031,7 +1031,7 @@ hn_dev_rx_queue_count(void *rx_queue) + * returns: + * - -EINVAL - offset outside of ring + * - RTE_ETH_RX_DESC_AVAIL - no data available yet +- * - RTE_ETH_RX_DESC_DONE - data is waiting in stagin ring ++ * - RTE_ETH_RX_DESC_DONE - data is waiting in staging ring + */ + int hn_dev_rx_queue_status(void *arg, uint16_t offset) + { +diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c +index fead8eba5d..ebb9c60147 100644 +--- a/drivers/net/netvsc/hn_vf.c ++++ b/drivers/net/netvsc/hn_vf.c +@@ -103,7 +103,7 @@ static void hn_remove_delayed(void *args) + struct rte_device *dev = rte_eth_devices[port_id].device; + int ret; + +- /* Tell VSP to switch data path to synthentic */ ++ /* Tell VSP to switch data path to synthetic */ + hn_vf_remove(hv); + + PMD_DRV_LOG(NOTICE, "Start to remove port %d", port_id); +diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h +index 0e03948ec7..394a7628e0 100644 +--- a/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h ++++ b/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h +@@ -63,7 +63,7 @@ + * Wildcard indicating a CPP read or write action + * + * The action used will be either read or write depending on whether a read or +- * write instruction/call is performed on the NFP_CPP_ID. It is recomended that ++ * write instruction/call is performed on the NFP_CPP_ID. It is recommended that + * the RW action is used even if all actions to be performed on a NFP_CPP_ID are + * known to be only reads or writes. Doing so will in many cases save NFP CPP + * internal software resources. +@@ -405,7 +405,7 @@ int nfp_idstr2meid(int chip_family, const char *s, const char **endptr); + * @param chip_family Chip family ID + * @param s A string of format "iX.anything" or "iX" + * @param endptr If non-NULL, *endptr will point to the trailing +- * striong after the ME ID part of the string, which ++ * string after the ME ID part of the string, which + * is either an empty string or the first character + * after the separating period. + * @return The island ID on succes, -1 on error. +@@ -425,7 +425,7 @@ int nfp_idstr2island(int chip_family, const char *s, const char **endptr); + * @param chip_family Chip family ID + * @param s A string of format "meX.anything" or "meX" + * @param endptr If non-NULL, *endptr will point to the trailing +- * striong after the ME ID part of the string, which ++ * string after the ME ID part of the string, which + * is either an empty string or the first character + * after the separating period. + * @return The ME number on succes, -1 on error. +diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c +index f91049383e..37799af558 100644 +--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c ++++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c +@@ -202,7 +202,7 @@ nfp_cpp_area_alloc(struct nfp_cpp *cpp, uint32_t dest, + * @address: start address on CPP target + * @size: size of area + * +- * Allocate and initilizae a CPP area structure, and lock it down so ++ * Allocate and initialize a CPP area structure, and lock it down so + * that it can be accessed directly. + * + * NOTE: @address and @size must be 32-bit aligned values. +diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h +index c9c7b0d0fb..e74cdeb191 100644 +--- a/drivers/net/nfp/nfpcore/nfp_nsp.h ++++ b/drivers/net/nfp/nfpcore/nfp_nsp.h +@@ -272,7 +272,7 @@ int __nfp_eth_set_split(struct nfp_nsp *nsp, unsigned int lanes); + * @br_primary: branch id of primary bootloader + * @br_secondary: branch id of secondary bootloader + * @br_nsp: branch id of NSP +- * @primary: version of primarary bootloader ++ * @primary: version of primary bootloader + * @secondary: version id of secondary bootloader + * @nsp: version id of NSP + * @sensor_mask: mask of present sensors available on NIC +diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c +index dd41fa4de4..7b5630fd86 100644 +--- a/drivers/net/nfp/nfpcore/nfp_resource.c ++++ b/drivers/net/nfp/nfpcore/nfp_resource.c +@@ -207,7 +207,7 @@ nfp_resource_acquire(struct nfp_cpp *cpp, const char *name) + * nfp_resource_release() - Release a NFP Resource handle + * @res: NFP Resource handle + * +- * NOTE: This function implictly unlocks the resource handle ++ * NOTE: This function implicitly unlocks the resource handle + */ + void + nfp_resource_release(struct nfp_resource *res) +diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.c b/drivers/net/nfp/nfpcore/nfp_rtsym.c +index cb7d83db51..2feca2ed81 100644 +--- a/drivers/net/nfp/nfpcore/nfp_rtsym.c ++++ b/drivers/net/nfp/nfpcore/nfp_rtsym.c +@@ -236,7 +236,7 @@ nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name) + * nfp_rtsym_read_le() - Read a simple unsigned scalar value from symbol + * @rtbl: NFP RTsym table + * @name: Symbol name +- * @error: Poniter to error code (optional) ++ * @error: Pointer to error code (optional) + * + * Lookup a symbol, map, read it and return it's value. Value of the symbol + * will be interpreted as a simple little-endian unsigned value. Symbol can +diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c +index 981592f7f4..0d66c32551 100644 +--- a/drivers/net/ngbe/ngbe_ethdev.c ++++ b/drivers/net/ngbe/ngbe_ethdev.c +@@ -983,7 +983,7 @@ ngbe_dev_start(struct rte_eth_dev *dev) + } + } + +- /* confiugre MSI-X for sleep until Rx interrupt */ ++ /* configure MSI-X for sleep until Rx interrupt */ + ngbe_configure_msix(dev); + + /* initialize transmission unit */ +@@ -2641,7 +2641,7 @@ ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction, + wr32(hw, NGBE_IVARMISC, tmp); + } else { + /* rx or tx causes */ +- /* Workround for ICR lost */ ++ /* Workaround for ICR lost */ + idx = ((16 * (queue & 1)) + (8 * direction)); + tmp = rd32(hw, NGBE_IVAR(queue >> 1)); + tmp &= ~(0xFF << idx); +@@ -2893,7 +2893,7 @@ ngbe_timesync_disable(struct rte_eth_dev *dev) + /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */ + wr32(hw, NGBE_ETFLT(NGBE_ETF_ID_1588), 0); + +- /* Stop incrementating the System Time registers. */ ++ /* Stop incrementing the System Time registers. */ + wr32(hw, NGBE_TSTIMEINC, 0); + + return 0; +diff --git a/drivers/net/ngbe/ngbe_pf.c b/drivers/net/ngbe/ngbe_pf.c +index 7f9c04fb0e..12a18de31d 100644 +--- a/drivers/net/ngbe/ngbe_pf.c ++++ b/drivers/net/ngbe/ngbe_pf.c +@@ -163,7 +163,7 @@ int ngbe_pf_host_configure(struct rte_eth_dev *eth_dev) + + wr32(hw, NGBE_PSRCTL, NGBE_PSRCTL_LBENA); + +- /* clear VMDq map to perment rar 0 */ ++ /* clear VMDq map to permanent rar 0 */ + hw->mac.clear_vmdq(hw, 0, BIT_MASK32); + + /* clear VMDq map to scan rar 31 */ +diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c +index 4f1e368c61..b47472ebbd 100644 +--- a/drivers/net/octeontx/octeontx_ethdev.c ++++ b/drivers/net/octeontx/octeontx_ethdev.c +@@ -1090,7 +1090,7 @@ octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, + + /* Verify queue index */ + if (qidx >= dev->data->nb_rx_queues) { +- octeontx_log_err("QID %d not supporteded (0 - %d available)\n", ++ octeontx_log_err("QID %d not supported (0 - %d available)\n", + qidx, (dev->data->nb_rx_queues - 1)); + return -ENOTSUP; + } +diff --git a/drivers/net/octeontx2/otx2_ethdev_irq.c b/drivers/net/octeontx2/otx2_ethdev_irq.c +index cc573bb2e8..f56d5b2a38 100644 +--- a/drivers/net/octeontx2/otx2_ethdev_irq.c ++++ b/drivers/net/octeontx2/otx2_ethdev_irq.c +@@ -369,7 +369,7 @@ oxt2_nix_register_cq_irqs(struct rte_eth_dev *eth_dev) + "rc=%d", rc); + return rc; + } +- /* VFIO vector zero is resereved for misc interrupt so ++ /* VFIO vector zero is reserved for misc interrupt so + * doing required adjustment. (b13bfab4cd) + */ + if (rte_intr_vec_list_index_set(handle, q, +diff --git a/drivers/net/octeontx2/otx2_ptp.c b/drivers/net/octeontx2/otx2_ptp.c +index abb2130587..974018f97e 100644 +--- a/drivers/net/octeontx2/otx2_ptp.c ++++ b/drivers/net/octeontx2/otx2_ptp.c +@@ -440,7 +440,7 @@ otx2_nix_read_clock(struct rte_eth_dev *eth_dev, uint64_t *clock) + /* This API returns the raw PTP HI clock value. Since LFs doesn't + * have direct access to PTP registers and it requires mbox msg + * to AF for this value. In fastpath reading this value for every +- * packet (which involes mbox call) becomes very expensive, hence ++ * packet (which involves mbox call) becomes very expensive, hence + * we should be able to derive PTP HI clock value from tsc by + * using freq_mult and clk_delta calculated during configure stage. + */ +diff --git a/drivers/net/octeontx2/otx2_tx.h b/drivers/net/octeontx2/otx2_tx.h +index 4bbd5a390f..a2fb7ce3cb 100644 +--- a/drivers/net/octeontx2/otx2_tx.h ++++ b/drivers/net/octeontx2/otx2_tx.h +@@ -61,7 +61,7 @@ otx2_nix_xmit_prepare_tstamp(uint64_t *cmd, const uint64_t *send_mem_desc, + /* Retrieving the default desc values */ + cmd[off] = send_mem_desc[6]; + +- /* Using compiler barier to avoid voilation of C ++ /* Using compiler barrier to avoid violation of C + * aliasing rules. + */ + rte_compiler_barrier(); +@@ -70,7 +70,7 @@ otx2_nix_xmit_prepare_tstamp(uint64_t *cmd, const uint64_t *send_mem_desc, + /* Packets for which RTE_MBUF_F_TX_IEEE1588_TMST is not set, tx tstamp + * should not be recorded, hence changing the alg type to + * NIX_SENDMEMALG_SET and also changing send mem addr field to +- * next 8 bytes as it corrpt the actual tx tstamp registered ++ * next 8 bytes as it corrupts the actual tx tstamp registered + * address. + */ + send_mem->alg = NIX_SENDMEMALG_SETTSTMP - (is_ol_tstamp); +diff --git a/drivers/net/octeontx2/otx2_vlan.c b/drivers/net/octeontx2/otx2_vlan.c +index cce643b7b5..359680de5c 100644 +--- a/drivers/net/octeontx2/otx2_vlan.c ++++ b/drivers/net/octeontx2/otx2_vlan.c +@@ -953,7 +953,7 @@ static void nix_vlan_reinstall_vlan_filters(struct rte_eth_dev *eth_dev) + struct vlan_entry *entry; + int rc; + +- /* VLAN filters can't be set without setting filtern on */ ++ /* VLAN filters can't be set without setting filters on */ + rc = nix_vlan_handle_default_rx_entry(eth_dev, false, true, true); + if (rc) { + otx2_err("Failed to reinstall vlan filters"); +diff --git a/drivers/net/octeontx_ep/otx2_ep_vf.c b/drivers/net/octeontx_ep/otx2_ep_vf.c +index 0716beb9b1..85e14a998f 100644 +--- a/drivers/net/octeontx_ep/otx2_ep_vf.c ++++ b/drivers/net/octeontx_ep/otx2_ep_vf.c +@@ -104,7 +104,7 @@ otx2_vf_setup_iq_regs(struct otx_ep_device *otx_ep, uint32_t iq_no) + iq->inst_cnt_reg = (uint8_t *)otx_ep->hw_addr + + SDP_VF_R_IN_CNTS(iq_no); + +- otx_ep_dbg("InstQ[%d]:dbell reg @ 0x%p instcnt_reg @ 0x%p", ++ otx_ep_dbg("InstQ[%d]:dbell reg @ 0x%p inst_cnt_reg @ 0x%p", + iq_no, iq->doorbell_reg, iq->inst_cnt_reg); + + do { +diff --git a/drivers/net/octeontx_ep/otx_ep_vf.c b/drivers/net/octeontx_ep/otx_ep_vf.c +index c9b91fef9e..96366b2a7f 100644 +--- a/drivers/net/octeontx_ep/otx_ep_vf.c ++++ b/drivers/net/octeontx_ep/otx_ep_vf.c +@@ -117,7 +117,7 @@ otx_ep_setup_iq_regs(struct otx_ep_device *otx_ep, uint32_t iq_no) + iq->inst_cnt_reg = (uint8_t *)otx_ep->hw_addr + + OTX_EP_R_IN_CNTS(iq_no); + +- otx_ep_dbg("InstQ[%d]:dbell reg @ 0x%p instcnt_reg @ 0x%p\n", ++ otx_ep_dbg("InstQ[%d]:dbell reg @ 0x%p inst_cnt_reg @ 0x%p\n", + iq_no, iq->doorbell_reg, iq->inst_cnt_reg); + + do { +diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c +index 047010e15e..ebb5d1ae0e 100644 +--- a/drivers/net/pfe/pfe_ethdev.c ++++ b/drivers/net/pfe/pfe_ethdev.c +@@ -769,7 +769,7 @@ pfe_eth_init(struct rte_vdev_device *vdev, struct pfe *pfe, int id) + if (eth_dev == NULL) + return -ENOMEM; + +- /* Extract pltform data */ ++ /* Extract platform data */ + pfe_info = (struct ls1012a_pfe_platform_data *)&pfe->platform_data; + if (!pfe_info) { + PFE_PMD_ERR("pfe missing additional platform data"); +diff --git a/drivers/net/pfe/pfe_hal.c b/drivers/net/pfe/pfe_hal.c +index 41d783dbff..6431dec47e 100644 +--- a/drivers/net/pfe/pfe_hal.c ++++ b/drivers/net/pfe/pfe_hal.c +@@ -187,7 +187,7 @@ gemac_set_mode(void *base, __rte_unused int mode) + { + u32 val = readl(base + EMAC_RCNTRL_REG); + +- /*Remove loopbank*/ ++ /* Remove loopback */ + val &= ~EMAC_RCNTRL_LOOP; + + /*Enable flow control and MII mode*/ +diff --git a/drivers/net/pfe/pfe_hif.c b/drivers/net/pfe/pfe_hif.c +index c4a7154ba7..69b1d0edde 100644 +--- a/drivers/net/pfe/pfe_hif.c ++++ b/drivers/net/pfe/pfe_hif.c +@@ -114,9 +114,9 @@ pfe_hif_init_buffers(struct pfe_hif *hif) + * results, eth id, queue id from PFE block along with data. + * so we have to provide additional memory for each packet to + * HIF rx rings so that PFE block can write its headers. +- * so, we are giving the data pointor to HIF rings whose ++ * so, we are giving the data pointer to HIF rings whose + * calculation is as below: +- * mbuf->data_pointor - Required_header_size ++ * mbuf->data_pointer - Required_header_size + * + * We are utilizing the HEADROOM area to receive the PFE + * block headers. On packet reception, HIF driver will use +diff --git a/drivers/net/pfe/pfe_hif.h b/drivers/net/pfe/pfe_hif.h +index 6aaf904bb1..e8d5ba10e1 100644 +--- a/drivers/net/pfe/pfe_hif.h ++++ b/drivers/net/pfe/pfe_hif.h +@@ -8,7 +8,7 @@ + #define HIF_CLIENT_QUEUES_MAX 16 + #define HIF_RX_PKT_MIN_SIZE RTE_CACHE_LINE_SIZE + /* +- * HIF_TX_DESC_NT value should be always greter than 4, ++ * HIF_TX_DESC_NT value should be always greater than 4, + * Otherwise HIF_TX_POLL_MARK will become zero. + */ + #define HIF_RX_DESC_NT 64 +diff --git a/drivers/net/pfe/pfe_hif_lib.c b/drivers/net/pfe/pfe_hif_lib.c +index 799050dce3..6fe6d33d23 100644 +--- a/drivers/net/pfe/pfe_hif_lib.c ++++ b/drivers/net/pfe/pfe_hif_lib.c +@@ -38,7 +38,7 @@ pfe_hif_shm_clean(struct hif_shm *hif_shm) + * This function should be called before initializing HIF driver. + * + * @param[in] hif_shm Shared memory address location in DDR +- * @rerurn 0 - on succes, <0 on fail to initialize ++ * @return 0 - on succes, <0 on fail to initialize + */ + int + pfe_hif_shm_init(struct hif_shm *hif_shm, struct rte_mempool *mb_pool) +@@ -109,9 +109,9 @@ hif_lib_client_release_rx_buffers(struct hif_client_s *client) + for (ii = 0; ii < client->rx_q[qno].size; ii++) { + buf = (void *)desc->data; + if (buf) { +- /* Data pointor to mbuf pointor calculation: ++ /* Data pointer to mbuf pointer calculation: + * "Data - User private data - headroom - mbufsize" +- * Actual data pointor given to HIF BDs was ++ * Actual data pointer given to HIF BDs was + * "mbuf->data_offset - PFE_PKT_HEADER_SZ" + */ + buf = buf + PFE_PKT_HEADER_SZ +@@ -477,7 +477,7 @@ hif_hdr_write(struct hif_hdr *pkt_hdr, unsigned int + client_id, unsigned int qno, + u32 client_ctrl) + { +- /* Optimize the write since the destinaton may be non-cacheable */ ++ /* Optimize the write since the destination may be non-cacheable */ + if (!((unsigned long)pkt_hdr & 0x3)) { + ((u32 *)pkt_hdr)[0] = (client_ctrl << 16) | (qno << 8) | + client_id; +diff --git a/drivers/net/qede/qede_debug.c b/drivers/net/qede/qede_debug.c +index 2297d245c4..af86bcc692 100644 +--- a/drivers/net/qede/qede_debug.c ++++ b/drivers/net/qede/qede_debug.c +@@ -5983,7 +5983,7 @@ static char *qed_get_buf_ptr(void *buf, u32 offset) + /* Reads a param from the specified buffer. Returns the number of dwords read. + * If the returned str_param is NULL, the param is numeric and its value is + * returned in num_param. +- * Otheriwise, the param is a string and its pointer is returned in str_param. ++ * Otherwise, the param is a string and its pointer is returned in str_param. + */ + static u32 qed_read_param(u32 *dump_buf, + const char **param_name, +@@ -7558,7 +7558,7 @@ static enum dbg_status format_feature(struct ecore_hwfn *p_hwfn, + text_buf[i] = '\n'; + + +- /* Free the old dump_buf and point the dump_buf to the newly allocagted ++ /* Free the old dump_buf and point the dump_buf to the newly allocated + * and formatted text buffer. + */ + OSAL_VFREE(p_hwfn, feature->dump_buf); +diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c +index 3e9aaeecd3..a1122a297e 100644 +--- a/drivers/net/qede/qede_ethdev.c ++++ b/drivers/net/qede/qede_ethdev.c +@@ -2338,7 +2338,7 @@ static int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) + if (fp->rxq != NULL) { + bufsz = (uint16_t)rte_pktmbuf_data_room_size( + fp->rxq->mb_pool) - RTE_PKTMBUF_HEADROOM; +- /* cache align the mbuf size to simplfy rx_buf_size ++ /* cache align the mbuf size to simplify rx_buf_size + * calculation + */ + bufsz = QEDE_FLOOR_TO_CACHE_LINE_SIZE(bufsz); +diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c +index c0eeea896e..7088c57b50 100644 +--- a/drivers/net/qede/qede_rxtx.c ++++ b/drivers/net/qede/qede_rxtx.c +@@ -90,7 +90,7 @@ static inline int qede_alloc_rx_bulk_mbufs(struct qede_rx_queue *rxq, int count) + * (MTU + Maximum L2 Header Size + 2) / ETH_RX_MAX_BUFF_PER_PKT + * 3) In regular mode - minimum rx_buf_size should be + * (MTU + Maximum L2 Header Size + 2) +- * In above cases +2 corrosponds to 2 bytes padding in front of L2 ++ * In above cases +2 corresponds to 2 bytes padding in front of L2 + * header. + * 4) rx_buf_size should be cacheline-size aligned. So considering + * criteria 1, we need to adjust the size to floor instead of ceil, +@@ -106,7 +106,7 @@ qede_calc_rx_buf_size(struct rte_eth_dev *dev, uint16_t mbufsz, + + if (dev->data->scattered_rx) { + /* per HW limitation, only ETH_RX_MAX_BUFF_PER_PKT number of +- * bufferes can be used for single packet. So need to make sure ++ * buffers can be used for single packet. So need to make sure + * mbuf size is sufficient enough for this. + */ + if ((mbufsz * ETH_RX_MAX_BUFF_PER_PKT) < +@@ -247,7 +247,7 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, + + /* Fix up RX buffer size */ + bufsz = (uint16_t)rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM; +- /* cache align the mbuf size to simplfy rx_buf_size calculation */ ++ /* cache align the mbuf size to simplify rx_buf_size calculation */ + bufsz = QEDE_FLOOR_TO_CACHE_LINE_SIZE(bufsz); + if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_SCATTER) || + (max_rx_pktlen + QEDE_ETH_OVERHEAD) > bufsz) { +@@ -1745,7 +1745,7 @@ qede_recv_pkts_regular(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) + } + } + +- /* Request number of bufferes to be allocated in next loop */ ++ /* Request number of buffers to be allocated in next loop */ + rxq->rx_alloc_count = rx_alloc_count; + + rxq->rcv_pkts += rx_pkt; +@@ -2042,7 +2042,7 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) + } + } + +- /* Request number of bufferes to be allocated in next loop */ ++ /* Request number of buffers to be allocated in next loop */ + rxq->rx_alloc_count = rx_alloc_count; + + rxq->rcv_pkts += rx_pkt; +@@ -2506,7 +2506,7 @@ qede_xmit_pkts(void *p_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) + /* Inner L2 header size in two byte words */ + inner_l2_hdr_size = (mbuf->l2_len - + MPLSINUDP_HDR_SIZE) / 2; +- /* Inner L4 header offset from the beggining ++ /* Inner L4 header offset from the beginning + * of inner packet in two byte words + */ + inner_l4_hdr_offset = (mbuf->l2_len - +diff --git a/drivers/net/qede/qede_rxtx.h b/drivers/net/qede/qede_rxtx.h +index 754efe793f..11ed1d9b9c 100644 +--- a/drivers/net/qede/qede_rxtx.h ++++ b/drivers/net/qede/qede_rxtx.h +@@ -225,7 +225,7 @@ struct qede_fastpath { + struct qede_tx_queue *txq; + }; + +-/* This structure holds the inforation of fast path queues ++/* This structure holds the information of fast path queues + * belonging to individual engines in CMT mode. + */ + struct qede_fastpath_cmt { +diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c +index ed714fe02f..2cead4e045 100644 +--- a/drivers/net/sfc/sfc.c ++++ b/drivers/net/sfc/sfc.c +@@ -371,7 +371,7 @@ sfc_set_drv_limits(struct sfc_adapter *sa) + + /* + * Limits are strict since take into account initial estimation. +- * Resource allocation stategy is described in ++ * Resource allocation strategy is described in + * sfc_estimate_resource_limits(). + */ + lim.edl_min_evq_count = lim.edl_max_evq_count = +diff --git a/drivers/net/sfc/sfc_dp.c b/drivers/net/sfc/sfc_dp.c +index d4cd162541..da2d1603cf 100644 +--- a/drivers/net/sfc/sfc_dp.c ++++ b/drivers/net/sfc/sfc_dp.c +@@ -68,7 +68,7 @@ sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry) + { + if (sfc_dp_find_by_name(head, entry->type, entry->name) != NULL) { + SFC_GENERIC_LOG(ERR, +- "sfc %s dapapath '%s' already registered", ++ "sfc %s datapath '%s' already registered", + entry->type == SFC_DP_RX ? "Rx" : + entry->type == SFC_DP_TX ? "Tx" : + "unknown", +diff --git a/drivers/net/sfc/sfc_dp_rx.h b/drivers/net/sfc/sfc_dp_rx.h +index 760540ba22..246adbd87c 100644 +--- a/drivers/net/sfc/sfc_dp_rx.h ++++ b/drivers/net/sfc/sfc_dp_rx.h +@@ -158,7 +158,7 @@ typedef int (sfc_dp_rx_qcreate_t)(uint16_t port_id, uint16_t queue_id, + struct sfc_dp_rxq **dp_rxqp); + + /** +- * Free resources allocated for datapath recevie queue. ++ * Free resources allocated for datapath receive queue. + */ + typedef void (sfc_dp_rx_qdestroy_t)(struct sfc_dp_rxq *dp_rxq); + +@@ -191,7 +191,7 @@ typedef bool (sfc_dp_rx_qrx_ps_ev_t)(struct sfc_dp_rxq *dp_rxq, + /** + * Receive queue purge function called after queue flush. + * +- * Should be used to free unused recevie buffers. ++ * Should be used to free unused receive buffers. + */ + typedef void (sfc_dp_rx_qpurge_t)(struct sfc_dp_rxq *dp_rxq); + +diff --git a/drivers/net/sfc/sfc_ef100.h b/drivers/net/sfc/sfc_ef100.h +index 5e2052d142..e81847e75a 100644 +--- a/drivers/net/sfc/sfc_ef100.h ++++ b/drivers/net/sfc/sfc_ef100.h +@@ -19,7 +19,7 @@ extern "C" { + * + * @param evq_prime Global address of the prime register + * @param evq_hw_index Event queue index +- * @param evq_read_ptr Masked event qeueu read pointer ++ * @param evq_read_ptr Masked event queue read pointer + */ + static inline void + sfc_ef100_evq_prime(volatile void *evq_prime, unsigned int evq_hw_index, +diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c +index 5d16bf281d..45253ed7dc 100644 +--- a/drivers/net/sfc/sfc_ef100_rx.c ++++ b/drivers/net/sfc/sfc_ef100_rx.c +@@ -851,7 +851,7 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr, + unsup_rx_prefix_fields = + efx_rx_prefix_layout_check(pinfo, &sfc_ef100_rx_prefix_layout); + +- /* LENGTH and CLASS filds must always be present */ ++ /* LENGTH and CLASS fields must always be present */ + if ((unsup_rx_prefix_fields & + ((1U << EFX_RX_PREFIX_FIELD_LENGTH) | + (1U << EFX_RX_PREFIX_FIELD_CLASS))) != 0) +diff --git a/drivers/net/sfc/sfc_ef10_essb_rx.c b/drivers/net/sfc/sfc_ef10_essb_rx.c +index 712c207617..78bd430363 100644 +--- a/drivers/net/sfc/sfc_ef10_essb_rx.c ++++ b/drivers/net/sfc/sfc_ef10_essb_rx.c +@@ -630,7 +630,7 @@ sfc_ef10_essb_rx_qcreate(uint16_t port_id, uint16_t queue_id, + rxq->block_size, rxq->buf_stride); + sfc_ef10_essb_rx_info(&rxq->dp.dpq, + "max fill level is %u descs (%u bufs), " +- "refill threashold %u descs (%u bufs)", ++ "refill threshold %u descs (%u bufs)", + rxq->max_fill_level, + rxq->max_fill_level * rxq->block_size, + rxq->refill_threshold, +diff --git a/drivers/net/sfc/sfc_ef10_rx_ev.h b/drivers/net/sfc/sfc_ef10_rx_ev.h +index 821e2227bb..412254e3d7 100644 +--- a/drivers/net/sfc/sfc_ef10_rx_ev.h ++++ b/drivers/net/sfc/sfc_ef10_rx_ev.h +@@ -40,7 +40,7 @@ sfc_ef10_rx_ev_to_offloads(const efx_qword_t rx_ev, struct rte_mbuf *m, + rte_cpu_to_le_64((1ull << ESF_DZ_RX_ECC_ERR_LBN) | + (1ull << ESF_DZ_RX_ECRC_ERR_LBN) | + (1ull << ESF_DZ_RX_PARSE_INCOMPLETE_LBN)))) { +- /* Zero packet type is used as a marker to dicard bad packets */ ++ /* Zero packet type is used as a marker to discard bad packets */ + goto done; + } + +diff --git a/drivers/net/sfc/sfc_intr.c b/drivers/net/sfc/sfc_intr.c +index ab67aa9237..ddddefad7b 100644 +--- a/drivers/net/sfc/sfc_intr.c ++++ b/drivers/net/sfc/sfc_intr.c +@@ -8,7 +8,7 @@ + */ + + /* +- * At the momemt of writing DPDK v16.07 has notion of two types of ++ * At the moment of writing DPDK v16.07 has notion of two types of + * interrupts: LSC (link status change) and RXQ (receive indication). + * It allows to register interrupt callback for entire device which is + * not intended to be used for receive indication (i.e. link status +diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c +index 7104284106..cd58d60a36 100644 +--- a/drivers/net/sfc/sfc_rx.c ++++ b/drivers/net/sfc/sfc_rx.c +@@ -1057,7 +1057,7 @@ sfc_rx_mb_pool_buf_size(struct sfc_adapter *sa, struct rte_mempool *mb_pool) + /* Make sure that end padding does not write beyond the buffer */ + if (buf_aligned < nic_align_end) { + /* +- * Estimate space which can be lost. If guarnteed buffer ++ * Estimate space which can be lost. If guaranteed buffer + * size is odd, lost space is (nic_align_end - 1). More + * accurate formula is below. + */ +@@ -1702,7 +1702,7 @@ sfc_rx_fini_queues(struct sfc_adapter *sa, unsigned int nb_rx_queues) + + /* + * Finalize only ethdev queues since other ones are finalized only +- * on device close and they may require additional deinitializaton. ++ * on device close and they may require additional deinitialization. + */ + ethdev_qid = sas->ethdev_rxq_count; + while (--ethdev_qid >= (int)nb_rx_queues) { +@@ -1775,7 +1775,7 @@ sfc_rx_configure(struct sfc_adapter *sa) + + reconfigure = true; + +- /* Do not ununitialize reserved queues */ ++ /* Do not uninitialize reserved queues */ + if (nb_rx_queues < sas->ethdev_rxq_count) + sfc_rx_fini_queues(sa, nb_rx_queues); + +diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c +index 0dccf21f7c..cd927cf2f7 100644 +--- a/drivers/net/sfc/sfc_tx.c ++++ b/drivers/net/sfc/sfc_tx.c +@@ -356,7 +356,7 @@ sfc_tx_fini_queues(struct sfc_adapter *sa, unsigned int nb_tx_queues) + + /* + * Finalize only ethdev queues since other ones are finalized only +- * on device close and they may require additional deinitializaton. ++ * on device close and they may require additional deinitialization. + */ + ethdev_qid = sas->ethdev_txq_count; + while (--ethdev_qid >= (int)nb_tx_queues) { +diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c +index ca70eab678..ad96288e7e 100644 +--- a/drivers/net/softnic/rte_eth_softnic_flow.c ++++ b/drivers/net/softnic/rte_eth_softnic_flow.c +@@ -930,7 +930,7 @@ flow_rule_match_acl_get(struct pmd_internals *softnic __rte_unused, + * Both *tmask* and *fmask* are byte arrays of size *tsize* and *fsize* + * respectively. + * They are located within a larger buffer at offsets *toffset* and *foffset* +- * respectivelly. Both *tmask* and *fmask* represent bitmasks for the larger ++ * respectively. Both *tmask* and *fmask* represent bitmasks for the larger + * buffer. + * Question: are the two masks equivalent? + * +diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c +index ddca630574..6567e5891b 100644 +--- a/drivers/net/tap/rte_eth_tap.c ++++ b/drivers/net/tap/rte_eth_tap.c +@@ -525,7 +525,7 @@ tap_tx_l4_cksum(uint16_t *l4_cksum, uint16_t l4_phdr_cksum, + } + } + +-/* Accumaulate L4 raw checksums */ ++/* Accumulate L4 raw checksums */ + static void + tap_tx_l4_add_rcksum(char *l4_data, unsigned int l4_len, uint16_t *l4_cksum, + uint32_t *l4_raw_cksum) +diff --git a/drivers/net/tap/tap_bpf_api.c b/drivers/net/tap/tap_bpf_api.c +index 98f6a76011..15283f8917 100644 +--- a/drivers/net/tap/tap_bpf_api.c ++++ b/drivers/net/tap/tap_bpf_api.c +@@ -96,7 +96,7 @@ static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, + * Load BPF instructions to kernel + * + * @param[in] type +- * BPF program type: classifieir or action ++ * BPF program type: classifier or action + * + * @param[in] insns + * Array of BPF instructions (equivalent to BPF instructions) +@@ -104,7 +104,7 @@ static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, + * @param[in] insns_cnt + * Number of BPF instructions (size of array) + * +- * @param[in] lincense ++ * @param[in] license + * License string that must be acknowledged by the kernel + * + * @return +diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c +index c4f60ce98e..7673823945 100644 +--- a/drivers/net/tap/tap_flow.c ++++ b/drivers/net/tap/tap_flow.c +@@ -961,7 +961,7 @@ add_action(struct rte_flow *flow, size_t *act_index, struct action_data *adata) + } + + /** +- * Helper function to send a serie of TC actions to the kernel ++ * Helper function to send a series of TC actions to the kernel + * + * @param[in] flow + * Pointer to rte flow containing the netlink message +@@ -2017,7 +2017,7 @@ static int bpf_rss_key(enum bpf_rss_key_e cmd, __u32 *key_idx) + break; + + /* +- * Subtract offest to restore real key index ++ * Subtract offset to restore real key index + * If a non RSS flow is falsely trying to release map + * entry 0 - the offset subtraction will calculate the real + * map index as an out-of-range value and the release operation +diff --git a/drivers/net/thunderx/nicvf_svf.c b/drivers/net/thunderx/nicvf_svf.c +index bccf290599..1bcf73d9fc 100644 +--- a/drivers/net/thunderx/nicvf_svf.c ++++ b/drivers/net/thunderx/nicvf_svf.c +@@ -21,7 +21,7 @@ nicvf_svf_push(struct nicvf *vf) + + entry = rte_zmalloc("nicvf", sizeof(*entry), RTE_CACHE_LINE_SIZE); + if (entry == NULL) +- rte_panic("Cannoc allocate memory for svf_entry\n"); ++ rte_panic("Cannot allocate memory for svf_entry\n"); + + entry->vf = vf; + +diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c +index 47d0e6ea40..ac4d4e08f4 100644 +--- a/drivers/net/txgbe/txgbe_ethdev.c ++++ b/drivers/net/txgbe/txgbe_ethdev.c +@@ -1678,7 +1678,7 @@ txgbe_dev_start(struct rte_eth_dev *dev) + return -ENOMEM; + } + } +- /* confiugre msix for sleep until rx interrupt */ ++ /* configure msix for sleep until rx interrupt */ + txgbe_configure_msix(dev); + + /* initialize transmission unit */ +@@ -3682,7 +3682,7 @@ txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction, + wr32(hw, TXGBE_IVARMISC, tmp); + } else { + /* rx or tx causes */ +- /* Workround for ICR lost */ ++ /* Workaround for ICR lost */ + idx = ((16 * (queue & 1)) + (8 * direction)); + tmp = rd32(hw, TXGBE_IVAR(queue >> 1)); + tmp &= ~(0xFF << idx); +@@ -4387,7 +4387,7 @@ txgbe_timesync_disable(struct rte_eth_dev *dev) + /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */ + wr32(hw, TXGBE_ETFLT(TXGBE_ETF_ID_1588), 0); + +- /* Stop incrementating the System Time registers. */ ++ /* Stop incrementing the System Time registers. */ + wr32(hw, TXGBE_TSTIMEINC, 0); + + return 0; +diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c b/drivers/net/txgbe/txgbe_ethdev_vf.c +index 84b960b8f9..f52cd8bc19 100644 +--- a/drivers/net/txgbe/txgbe_ethdev_vf.c ++++ b/drivers/net/txgbe/txgbe_ethdev_vf.c +@@ -961,7 +961,7 @@ txgbevf_set_ivar_map(struct txgbe_hw *hw, int8_t direction, + wr32(hw, TXGBE_VFIVARMISC, tmp); + } else { + /* rx or tx cause */ +- /* Workround for ICR lost */ ++ /* Workaround for ICR lost */ + idx = ((16 * (queue & 1)) + (8 * direction)); + tmp = rd32(hw, TXGBE_VFIVAR(queue >> 1)); + tmp &= ~(0xFF << idx); +@@ -997,7 +997,7 @@ txgbevf_configure_msix(struct rte_eth_dev *dev) + /* Configure all RX queues of VF */ + for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) { + /* Force all queue use vector 0, +- * as TXGBE_VF_MAXMSIVECOTR = 1 ++ * as TXGBE_VF_MAXMSIVECTOR = 1 + */ + txgbevf_set_ivar_map(hw, 0, q_idx, vector_idx); + rte_intr_vec_list_index_set(intr_handle, q_idx, +@@ -1288,7 +1288,7 @@ txgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev) + + /* only one misc vector supported - mailbox */ + eicr &= TXGBE_VFICR_MASK; +- /* Workround for ICR lost */ ++ /* Workaround for ICR lost */ + intr->flags |= TXGBE_FLAG_MAILBOX; + + /* To avoid compiler warnings set eicr to used. */ +diff --git a/drivers/net/txgbe/txgbe_ipsec.c b/drivers/net/txgbe/txgbe_ipsec.c +index 445733f3ba..3ca3d85ed5 100644 +--- a/drivers/net/txgbe/txgbe_ipsec.c ++++ b/drivers/net/txgbe/txgbe_ipsec.c +@@ -288,7 +288,7 @@ txgbe_crypto_remove_sa(struct rte_eth_dev *dev, + return -1; + } + +- /* Disable and clear Rx SPI and key table entryes*/ ++ /* Disable and clear Rx SPI and key table entries */ + reg_val = TXGBE_IPSRXIDX_WRITE | + TXGBE_IPSRXIDX_TB_SPI | (sa_index << 3); + wr32(hw, TXGBE_IPSRXSPI, 0); +diff --git a/drivers/net/txgbe/txgbe_pf.c b/drivers/net/txgbe/txgbe_pf.c +index 30be287330..67d92bfa56 100644 +--- a/drivers/net/txgbe/txgbe_pf.c ++++ b/drivers/net/txgbe/txgbe_pf.c +@@ -236,7 +236,7 @@ int txgbe_pf_host_configure(struct rte_eth_dev *eth_dev) + + wr32(hw, TXGBE_PSRCTL, TXGBE_PSRCTL_LBENA); + +- /* clear VMDq map to perment rar 0 */ ++ /* clear VMDq map to permanent rar 0 */ + hw->mac.clear_vmdq(hw, 0, BIT_MASK32); + + /* clear VMDq map to scan rar 127 */ +diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c +index c2588369b2..b317649d7e 100644 +--- a/drivers/net/virtio/virtio_ethdev.c ++++ b/drivers/net/virtio/virtio_ethdev.c +@@ -2657,7 +2657,7 @@ virtio_dev_configure(struct rte_eth_dev *dev) + hw->has_rx_offload = rx_offload_enabled(hw); + + if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) +- /* Enable vector (0) for Link State Intrerrupt */ ++ /* Enable vector (0) for Link State Interrupt */ + if (VIRTIO_OPS(hw)->set_config_irq(hw, 0) == + VIRTIO_MSI_NO_VECTOR) { + PMD_DRV_LOG(ERR, "failed to set config vector"); +@@ -2775,7 +2775,7 @@ virtio_dev_start(struct rte_eth_dev *dev) + } + } + +- /* Enable uio/vfio intr/eventfd mapping: althrough we already did that ++ /* Enable uio/vfio intr/eventfd mapping: although we already did that + * in device configure, but it could be unmapped when device is + * stopped. + */ +diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c +index 182cfc9eae..632451dcbe 100644 +--- a/drivers/net/virtio/virtio_pci.c ++++ b/drivers/net/virtio/virtio_pci.c +@@ -235,7 +235,7 @@ legacy_get_isr(struct virtio_hw *hw) + return dst; + } + +-/* Enable one vector (0) for Link State Intrerrupt */ ++/* Enable one vector (0) for Link State Interrupt */ + static uint16_t + legacy_set_config_irq(struct virtio_hw *hw, uint16_t vec) + { +diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c +index 2e115ded02..b39dd92d1b 100644 +--- a/drivers/net/virtio/virtio_rxtx.c ++++ b/drivers/net/virtio/virtio_rxtx.c +@@ -962,7 +962,7 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) + return -EINVAL; + } + +- /* Update mss lengthes in mbuf */ ++ /* Update mss lengths in mbuf */ + m->tso_segsz = hdr->gso_size; + switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) { + case VIRTIO_NET_HDR_GSO_TCPV4: +diff --git a/drivers/net/virtio/virtio_rxtx_packed_avx.h b/drivers/net/virtio/virtio_rxtx_packed_avx.h +index 8cb71f3fe6..584ac72f95 100644 +--- a/drivers/net/virtio/virtio_rxtx_packed_avx.h ++++ b/drivers/net/virtio/virtio_rxtx_packed_avx.h +@@ -192,7 +192,7 @@ virtqueue_dequeue_batch_packed_vec(struct virtnet_rx *rxvq, + + /* + * load len from desc, store into mbuf pkt_len and data_len +- * len limiated by l6bit buf_len, pkt_len[16:31] can be ignored ++ * len limited by l6bit buf_len, pkt_len[16:31] can be ignored + */ + const __mmask16 mask = 0x6 | 0x6 << 4 | 0x6 << 8 | 0x6 << 12; + __m512i values = _mm512_maskz_shuffle_epi32(mask, v_desc, 0xAA); +diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c +index 65bf792eb0..c98d696e62 100644 +--- a/drivers/net/virtio/virtqueue.c ++++ b/drivers/net/virtio/virtqueue.c +@@ -13,7 +13,7 @@ + /* + * Two types of mbuf to be cleaned: + * 1) mbuf that has been consumed by backend but not used by virtio. +- * 2) mbuf that hasn't been consued by backend. ++ * 2) mbuf that hasn't been consumed by backend. + */ + struct rte_mbuf * + virtqueue_detach_unused(struct virtqueue *vq) +diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h +index 855f57a956..99c68cf622 100644 +--- a/drivers/net/virtio/virtqueue.h ++++ b/drivers/net/virtio/virtqueue.h +@@ -227,7 +227,7 @@ struct virtio_net_ctrl_rss { + * Control link announce acknowledgement + * + * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that +- * driver has recevied the notification; device would clear the ++ * driver has received the notification; device would clear the + * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives + * this command. + */ +@@ -312,7 +312,7 @@ struct virtqueue { + struct vq_desc_extra vq_descx[0]; + }; + +-/* If multiqueue is provided by host, then we suppport it. */ ++/* If multiqueue is provided by host, then we support it. */ + #define VIRTIO_NET_CTRL_MQ 4 + + #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 +diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c +index de26d2aef3..ebc2cd5d0d 100644 +--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c ++++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c +@@ -653,7 +653,7 @@ dpdmai_dev_dequeue_multijob_prefetch( + rte_prefetch0((void *)(size_t)(dq_storage + 1)); + + /* Prepare next pull descriptor. This will give space for the +- * prefething done on DQRR entries ++ * prefetching done on DQRR entries + */ + q_storage->toggle ^= 1; + dq_storage1 = q_storage->dq_storage[q_storage->toggle]; +diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.h b/drivers/raw/dpaa2_qdma/dpaa2_qdma.h +index d6f6bb5522..1973d5d2b2 100644 +--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.h ++++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.h +@@ -82,7 +82,7 @@ struct qdma_device { + /** total number of hw queues. */ + uint16_t num_hw_queues; + /** +- * Maximum number of hw queues to be alocated per core. ++ * Maximum number of hw queues to be allocated per core. + * This is limited by MAX_HW_QUEUE_PER_CORE + */ + uint16_t max_hw_queues_per_core; +@@ -268,7 +268,7 @@ struct dpaa2_dpdmai_dev { + struct fsl_mc_io dpdmai; + /** HW ID for DPDMAI object */ + uint32_t dpdmai_id; +- /** Tocken of this device */ ++ /** Token of this device */ + uint16_t token; + /** Number of queue in this DPDMAI device */ + uint8_t num_queues; +diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c +index 8d9db585a4..0eae0c9477 100644 +--- a/drivers/raw/ifpga/ifpga_rawdev.c ++++ b/drivers/raw/ifpga/ifpga_rawdev.c +@@ -382,7 +382,7 @@ ifpga_monitor_sensor(struct rte_rawdev *raw_dev, + + if (HIGH_WARN(sensor, value) || + LOW_WARN(sensor, value)) { +- IFPGA_RAWDEV_PMD_INFO("%s reach theshold %d\n", ++ IFPGA_RAWDEV_PMD_INFO("%s reach threshold %d\n", + sensor->name, value); + *gsd_start = true; + break; +@@ -393,7 +393,7 @@ ifpga_monitor_sensor(struct rte_rawdev *raw_dev, + if (!strcmp(sensor->name, "12V AUX Voltage")) { + if (value < AUX_VOLTAGE_WARN) { + IFPGA_RAWDEV_PMD_INFO( +- "%s reach theshold %d mV\n", ++ "%s reach threshold %d mV\n", + sensor->name, value); + *gsd_start = true; + break; +@@ -441,12 +441,12 @@ static int set_surprise_link_check_aer( + pos = ifpga_pci_find_ext_capability(fd, RTE_PCI_EXT_CAP_ID_ERR); + if (!pos) + goto end; +- /* save previout ECAP_AER+0x08 */ ++ /* save previous ECAP_AER+0x08 */ + ret = pread(fd, &data, sizeof(data), pos+0x08); + if (ret == -1) + goto end; + ifpga_rdev->aer_old[0] = data; +- /* save previout ECAP_AER+0x14 */ ++ /* save previous ECAP_AER+0x14 */ + ret = pread(fd, &data, sizeof(data), pos+0x14); + if (ret == -1) + goto end; +@@ -531,7 +531,7 @@ ifpga_monitor_start_func(void) + ifpga_rawdev_gsd_handle, NULL); + if (ret != 0) { + IFPGA_RAWDEV_PMD_ERR( +- "Fail to create ifpga nonitor thread"); ++ "Fail to create ifpga monitor thread"); + return -1; + } + ifpga_monitor_start = 1; +diff --git a/drivers/raw/ntb/ntb.h b/drivers/raw/ntb/ntb.h +index cdf7667d5d..c9ff33aa59 100644 +--- a/drivers/raw/ntb/ntb.h ++++ b/drivers/raw/ntb/ntb.h +@@ -95,7 +95,7 @@ enum ntb_spad_idx { + * @spad_write: Write val to local/peer spad register. + * @db_read: Read doorbells status. + * @db_clear: Clear local doorbells. +- * @db_set_mask: Set bits in db mask, preventing db interrpts generated ++ * @db_set_mask: Set bits in db mask, preventing db interrupts generated + * for those db bits. + * @peer_db_set: Set doorbell bit to generate peer interrupt for that bit. + * @vector_bind: Bind vector source [intr] to msix vector [msix]. +diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c +index b1b9053bff..130d201a85 100644 +--- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c ++++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c +@@ -160,7 +160,7 @@ mlx5_vdpa_vhost_mem_regions_prepare(int vid, uint8_t *mode, uint64_t *mem_size, + * The target here is to group all the physical memory regions of the + * virtio device in one indirect mkey. + * For KLM Fixed Buffer Size mode (HW find the translation entry in one +- * read according to the guest phisical address): ++ * read according to the guest physical address): + * All the sub-direct mkeys of it must be in the same size, hence, each + * one of them should be in the GCD size of all the virtio memory + * regions and the holes between them. +diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +index db971bad48..2f32aef67f 100644 +--- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c ++++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +@@ -403,7 +403,7 @@ mlx5_vdpa_features_validate(struct mlx5_vdpa_priv *priv) + if (priv->features & (1ULL << VIRTIO_F_RING_PACKED)) { + if (!(priv->caps.virtio_queue_type & (1 << + MLX5_VIRTQ_TYPE_PACKED))) { +- DRV_LOG(ERR, "Failed to configur PACKED mode for vdev " ++ DRV_LOG(ERR, "Failed to configure PACKED mode for vdev " + "%d - it was not reported by HW/driver" + " capability.", priv->vid); + return -ENOTSUP; +diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c +index ecafc5e4f1..fc7e8b8174 100644 +--- a/examples/bbdev_app/main.c ++++ b/examples/bbdev_app/main.c +@@ -372,7 +372,7 @@ add_awgn(struct rte_mbuf **mbufs, uint16_t num_pkts) + /* Encoder output to Decoder input adapter. The Decoder accepts only soft input + * so each bit of the encoder output must be translated into one byte of LLR. If + * Sub-block Deinterleaver is bypassed, which is the case, the padding bytes +- * must additionally be insterted at the end of each sub-block. ++ * must additionally be inserted at the end of each sub-block. + */ + static inline void + transform_enc_out_dec_in(struct rte_mbuf **mbufs, uint8_t *temp_buf, +diff --git a/examples/bond/main.c b/examples/bond/main.c +index 1087b0dad1..335bde5c8d 100644 +--- a/examples/bond/main.c ++++ b/examples/bond/main.c +@@ -230,7 +230,7 @@ bond_port_init(struct rte_mempool *mbuf_pool) + 0 /*SOCKET_ID_ANY*/); + if (retval < 0) + rte_exit(EXIT_FAILURE, +- "Faled to create bond port\n"); ++ "Failed to create bond port\n"); + + BOND_PORT = retval; + +@@ -405,7 +405,7 @@ static int lcore_main(__rte_unused void *arg1) + struct rte_ether_hdr *); + ether_type = eth_hdr->ether_type; + if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN)) +- printf("VLAN taged frame, offset:"); ++ printf("VLAN tagged frame, offset:"); + offset = get_vlan_offset(eth_hdr, ðer_type); + if (offset > 0) + printf("%d\n", offset); +diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c +index b06042e5fe..9fc46f5255 100644 +--- a/examples/dma/dmafwd.c ++++ b/examples/dma/dmafwd.c +@@ -88,7 +88,7 @@ static uint16_t nb_queues = 1; + /* MAC updating enabled by default. */ + static int mac_updating = 1; + +-/* hardare copy mode enabled by default. */ ++/* hardware copy mode enabled by default. */ + static copy_mode_t copy_mode = COPY_MODE_DMA_NUM; + + /* size of descriptor ring for hardware copy mode or +diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c +index 86286d38a6..ffaad96498 100644 +--- a/examples/ethtool/lib/rte_ethtool.c ++++ b/examples/ethtool/lib/rte_ethtool.c +@@ -402,7 +402,7 @@ rte_ethtool_net_set_rx_mode(uint16_t port_id) + #endif + } + +- /* Enable Rx vlan filter, VF unspport status is discard */ ++ /* Enable Rx vlan filter, VF unsupported status is discard */ + ret = rte_eth_dev_set_vlan_offload(port_id, RTE_ETH_VLAN_FILTER_MASK); + if (ret != 0) + return ret; +diff --git a/examples/ethtool/lib/rte_ethtool.h b/examples/ethtool/lib/rte_ethtool.h +index f177096636..d27e0102b1 100644 +--- a/examples/ethtool/lib/rte_ethtool.h ++++ b/examples/ethtool/lib/rte_ethtool.h +@@ -189,7 +189,7 @@ int rte_ethtool_get_module_eeprom(uint16_t port_id, + + /** + * Retrieve the Ethernet device pause frame configuration according to +- * parameter attributes desribed by ethtool data structure, ++ * parameter attributes described by ethtool data structure, + * ethtool_pauseparam. + * + * @param port_id +@@ -209,7 +209,7 @@ int rte_ethtool_get_pauseparam(uint16_t port_id, + + /** + * Setting the Ethernet device pause frame configuration according to +- * parameter attributes desribed by ethtool data structure, ethtool_pauseparam. ++ * parameter attributes described by ethtool data structure, ethtool_pauseparam. + * + * @param port_id + * The port identifier of the Ethernet device. +diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c +index fb3cac3bd0..6e4c11c3c7 100644 +--- a/examples/ip_reassembly/main.c ++++ b/examples/ip_reassembly/main.c +@@ -244,7 +244,7 @@ static struct rte_lpm6 *socket_lpm6[RTE_MAX_NUMA_NODES]; + #endif /* RTE_LIBRTE_IP_FRAG_TBL_STAT */ + + /* +- * If number of queued packets reached given threahold, then ++ * If number of queued packets reached given threshold, then + * send burst of packets on an output interface. + */ + static inline uint32_t +@@ -873,11 +873,11 @@ setup_queue_tbl(struct rx_queue *rxq, uint32_t lcore, uint32_t queue) + + /* + * At any given moment up to +- * mbufs could be stored int the fragment table. ++ * mbufs could be stored in the fragment table. + * Plus, each TX queue can hold up to packets. + */ + +- /* mbufs stored int the gragment table. 8< */ ++ /* mbufs stored in the fragment table. 8< */ + nb_mbuf = RTE_MAX(max_flow_num, 2UL * MAX_PKT_BURST) * MAX_FRAG_NUM; + nb_mbuf *= (port_conf.rxmode.mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + + BUF_SIZE - 1) / BUF_SIZE; +@@ -895,7 +895,7 @@ setup_queue_tbl(struct rx_queue *rxq, uint32_t lcore, uint32_t queue) + "rte_pktmbuf_pool_create(%s) failed", buf); + return -1; + } +- /* >8 End of mbufs stored int the fragmentation table. */ ++ /* >8 End of mbufs stored in the fragmentation table. */ + + return 0; + } +diff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/event_helper.c +index e8600f5e90..24b210add4 100644 +--- a/examples/ipsec-secgw/event_helper.c ++++ b/examples/ipsec-secgw/event_helper.c +@@ -1353,7 +1353,7 @@ eh_display_rx_adapter_conf(struct eventmode_conf *em_conf) + for (i = 0; i < nb_rx_adapter; i++) { + adapter = &(em_conf->rx_adapter[i]); + sprintf(print_buf, +- "\tRx adaper ID: %-2d\tConnections: %-2d\tEvent dev ID: %-2d", ++ "\tRx adapter ID: %-2d\tConnections: %-2d\tEvent dev ID: %-2d", + adapter->adapter_id, + adapter->nb_connections, + adapter->eventdev_id); +diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c +index bf3dbf6b5c..96916cd3c5 100644 +--- a/examples/ipsec-secgw/ipsec-secgw.c ++++ b/examples/ipsec-secgw/ipsec-secgw.c +@@ -265,7 +265,7 @@ struct socket_ctx socket_ctx[NB_SOCKETS]; + /* + * Determine is multi-segment support required: + * - either frame buffer size is smaller then mtu +- * - or reassmeble support is requested ++ * - or reassemble support is requested + */ + static int + multi_seg_required(void) +@@ -2050,7 +2050,7 @@ add_mapping(struct rte_hash *map, const char *str, uint16_t cdev_id, + + ret = rte_hash_add_key_data(map, &key, (void *)i); + if (ret < 0) { +- printf("Faled to insert cdev mapping for (lcore %u, " ++ printf("Failed to insert cdev mapping for (lcore %u, " + "cdev %u, qp %u), errno %d\n", + key.lcore_id, ipsec_ctx->tbl[i].id, + ipsec_ctx->tbl[i].qp, ret); +@@ -2083,7 +2083,7 @@ add_cdev_mapping(struct rte_cryptodev_info *dev_info, uint16_t cdev_id, + str = "Inbound"; + } + +- /* Required cryptodevs with operation chainning */ ++ /* Required cryptodevs with operation chaining */ + if (!(dev_info->feature_flags & + RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING)) + return ret; +@@ -2251,7 +2251,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads) + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + +- /* limit allowed HW offloafs, as user requested */ ++ /* limit allowed HW offloads, as user requested */ + dev_info.rx_offload_capa &= dev_rx_offload; + dev_info.tx_offload_capa &= dev_tx_offload; + +@@ -2298,7 +2298,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads) + local_port_conf.rxmode.offloads) + rte_exit(EXIT_FAILURE, + "Error: port %u required RX offloads: 0x%" PRIx64 +- ", avaialbe RX offloads: 0x%" PRIx64 "\n", ++ ", available RX offloads: 0x%" PRIx64 "\n", + portid, local_port_conf.rxmode.offloads, + dev_info.rx_offload_capa); + +@@ -2306,7 +2306,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads) + local_port_conf.txmode.offloads) + rte_exit(EXIT_FAILURE, + "Error: port %u required TX offloads: 0x%" PRIx64 +- ", avaialbe TX offloads: 0x%" PRIx64 "\n", ++ ", available TX offloads: 0x%" PRIx64 "\n", + portid, local_port_conf.txmode.offloads, + dev_info.tx_offload_capa); + +@@ -2317,7 +2317,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads) + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) + local_port_conf.txmode.offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM; + +- printf("port %u configurng rx_offloads=0x%" PRIx64 ++ printf("port %u configuring rx_offloads=0x%" PRIx64 + ", tx_offloads=0x%" PRIx64 "\n", + portid, local_port_conf.rxmode.offloads, + local_port_conf.txmode.offloads); +diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c +index 30bc693e06..1839ac71af 100644 +--- a/examples/ipsec-secgw/sa.c ++++ b/examples/ipsec-secgw/sa.c +@@ -897,7 +897,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, + continue; + } + +- /* unrecognizeable input */ ++ /* unrecognizable input */ + APP_CHECK(0, status, "unrecognized input \"%s\"", + tokens[ti]); + return; +@@ -1145,7 +1145,7 @@ get_spi_proto(uint32_t spi, enum rte_security_ipsec_sa_direction dir, + if (rc4 >= 0) { + if (rc6 >= 0) { + RTE_LOG(ERR, IPSEC, +- "%s: SPI %u used simultaeously by " ++ "%s: SPI %u used simultaneously by " + "IPv4(%d) and IPv6 (%d) SP rules\n", + __func__, spi, rc4, rc6); + return -EINVAL; +@@ -1550,7 +1550,7 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size) + } + + /* +- * Allocate space and init rte_ipsec_sa strcutures, ++ * Allocate space and init rte_ipsec_sa structures, + * one per session. + */ + static int +diff --git a/examples/ipsec-secgw/sp4.c b/examples/ipsec-secgw/sp4.c +index beddd7bc1d..fc4101a4a2 100644 +--- a/examples/ipsec-secgw/sp4.c ++++ b/examples/ipsec-secgw/sp4.c +@@ -410,7 +410,7 @@ parse_sp4_tokens(char **tokens, uint32_t n_tokens, + continue; + } + +- /* unrecognizeable input */ ++ /* unrecognizable input */ + APP_CHECK(0, status, "unrecognized input \"%s\"", + tokens[ti]); + return; +diff --git a/examples/ipsec-secgw/sp6.c b/examples/ipsec-secgw/sp6.c +index 328e085288..cce4da7862 100644 +--- a/examples/ipsec-secgw/sp6.c ++++ b/examples/ipsec-secgw/sp6.c +@@ -515,7 +515,7 @@ parse_sp6_tokens(char **tokens, uint32_t n_tokens, + continue; + } + +- /* unrecognizeable input */ ++ /* unrecognizable input */ + APP_CHECK(0, status, "unrecognized input \"%s\"", + tokens[ti]); + return; +diff --git a/examples/ipsec-secgw/test/common_defs.sh b/examples/ipsec-secgw/test/common_defs.sh +index f22eb3ab12..3ef06bc761 100644 +--- a/examples/ipsec-secgw/test/common_defs.sh ++++ b/examples/ipsec-secgw/test/common_defs.sh +@@ -20,7 +20,7 @@ REMOTE_MAC=`ssh ${REMOTE_HOST} ip addr show dev ${REMOTE_IFACE}` + st=$? + REMOTE_MAC=`echo ${REMOTE_MAC} | sed -e 's/^.*ether //' -e 's/ brd.*$//'` + if [[ $st -ne 0 || -z "${REMOTE_MAC}" ]]; then +- echo "coouldn't retrieve ether addr from ${REMOTE_IFACE}" ++ echo "couldn't retrieve ether addr from ${REMOTE_IFACE}" + exit 127 + fi + +@@ -40,7 +40,7 @@ DPDK_VARS="" + + # by default ipsec-secgw can't deal with multi-segment packets + # make sure our local/remote host wouldn't generate fragmented packets +-# if reassmebly option is not enabled ++# if reassembly option is not enabled + DEF_MTU_LEN=1400 + DEF_PING_LEN=1200 + +diff --git a/examples/kni/main.c b/examples/kni/main.c +index d324ee2241..f5b20a7b62 100644 +--- a/examples/kni/main.c ++++ b/examples/kni/main.c +@@ -1039,7 +1039,7 @@ main(int argc, char** argv) + pthread_t kni_link_tid; + int pid; + +- /* Associate signal_hanlder function with USR signals */ ++ /* Associate signal_handler function with USR signals */ + signal(SIGUSR1, signal_handler); + signal(SIGUSR2, signal_handler); + signal(SIGRTMIN, signal_handler); +diff --git a/examples/l2fwd-cat/l2fwd-cat.c b/examples/l2fwd-cat/l2fwd-cat.c +index d9cf00c9df..6e16705e99 100644 +--- a/examples/l2fwd-cat/l2fwd-cat.c ++++ b/examples/l2fwd-cat/l2fwd-cat.c +@@ -157,7 +157,7 @@ main(int argc, char *argv[]) + int ret = rte_eal_init(argc, argv); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); +- /* >8 End of initializion the Environment Abstraction Layer (EAL). */ ++ /* >8 End of initialization the Environment Abstraction Layer (EAL). */ + + argc -= ret; + argv += ret; +diff --git a/examples/l2fwd-event/l2fwd_event_generic.c b/examples/l2fwd-event/l2fwd_event_generic.c +index f31569a744..1977e23261 100644 +--- a/examples/l2fwd-event/l2fwd_event_generic.c ++++ b/examples/l2fwd-event/l2fwd_event_generic.c +@@ -42,7 +42,7 @@ l2fwd_event_device_setup_generic(struct l2fwd_resources *rsrc) + ethdev_count++; + } + +- /* Event device configurtion */ ++ /* Event device configuration */ + rte_event_dev_info_get(event_d_id, &dev_info); + + /* Enable implicit release */ +diff --git a/examples/l2fwd-event/l2fwd_event_internal_port.c b/examples/l2fwd-event/l2fwd_event_internal_port.c +index 86d772d817..717a7bceb8 100644 +--- a/examples/l2fwd-event/l2fwd_event_internal_port.c ++++ b/examples/l2fwd-event/l2fwd_event_internal_port.c +@@ -40,7 +40,7 @@ l2fwd_event_device_setup_internal_port(struct l2fwd_resources *rsrc) + ethdev_count++; + } + +- /* Event device configurtion */ ++ /* Event device configuration */ + rte_event_dev_info_get(event_d_id, &dev_info); + + /* Enable implicit release */ +diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c +index d8eabe4c86..9e71ba2d4e 100644 +--- a/examples/l2fwd-jobstats/main.c ++++ b/examples/l2fwd-jobstats/main.c +@@ -468,7 +468,7 @@ l2fwd_flush_job(__rte_unused struct rte_timer *timer, __rte_unused void *arg) + qconf->next_flush_time[portid] = rte_get_timer_cycles() + drain_tsc; + } + +- /* Pass target to indicate that this job is happy of time interwal ++ /* Pass target to indicate that this job is happy of time interval + * in which it was called. */ + rte_jobstats_finish(&qconf->flush_job, qconf->flush_job.target); + } +diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c +index 1fb1807235..2d2ecc7635 100644 +--- a/examples/l3fwd-acl/main.c ++++ b/examples/l3fwd-acl/main.c +@@ -801,8 +801,8 @@ send_packets(struct rte_mbuf **m, uint32_t *res, int num) + } + + /* +- * Parses IPV6 address, exepcts the following format: +- * XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX (where X - is a hexedecimal digit). ++ * Parse IPv6 address, expects the following format: ++ * XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX (where X is a hexadecimal digit). + */ + static int + parse_ipv6_addr(const char *in, const char **end, uint32_t v[IPV6_ADDR_U32], +@@ -1959,7 +1959,7 @@ check_all_ports_link_status(uint32_t port_mask) + } + + /* +- * build-up default vaues for dest MACs. ++ * build-up default values for dest MACs. + */ + static void + set_default_dest_mac(void) +diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c +index b8b3be2b8a..20e5b59af9 100644 +--- a/examples/l3fwd-power/main.c ++++ b/examples/l3fwd-power/main.c +@@ -433,7 +433,7 @@ signal_exit_now(int sigtype) + + } + +-/* Freqency scale down timer callback */ ++/* Frequency scale down timer callback */ + static void + power_timer_cb(__rte_unused struct rte_timer *tim, + __rte_unused void *arg) +@@ -2358,7 +2358,7 @@ update_telemetry(__rte_unused struct rte_timer *tim, + ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index, + values, RTE_DIM(values)); + if (ret < 0) +- RTE_LOG(WARNING, POWER, "failed to update metrcis\n"); ++ RTE_LOG(WARNING, POWER, "failed to update metrics\n"); + } + + static int +diff --git a/examples/l3fwd/l3fwd_common.h b/examples/l3fwd/l3fwd_common.h +index 7d83ff641a..cbaab79f5b 100644 +--- a/examples/l3fwd/l3fwd_common.h ++++ b/examples/l3fwd/l3fwd_common.h +@@ -51,7 +51,7 @@ rfc1812_process(struct rte_ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype) + #endif /* DO_RFC_1812_CHECKS */ + + /* +- * We group consecutive packets with the same destionation port into one burst. ++ * We group consecutive packets with the same destination port into one burst. + * To avoid extra latency this is done together with some other packet + * processing, but after we made a final decision about packet's destination. + * To do this we maintain: +@@ -76,7 +76,7 @@ rfc1812_process(struct rte_ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype) + + static const struct { + uint64_t pnum; /* prebuild 4 values for pnum[]. */ +- int32_t idx; /* index for new last updated elemnet. */ ++ int32_t idx; /* index for new last updated element. */ + uint16_t lpv; /* add value to the last updated element. */ + } gptbl[GRPSZ] = { + { +diff --git a/examples/l3fwd/l3fwd_neon.h b/examples/l3fwd/l3fwd_neon.h +index 86ac5971d7..e3d33a5229 100644 +--- a/examples/l3fwd/l3fwd_neon.h ++++ b/examples/l3fwd/l3fwd_neon.h +@@ -64,7 +64,7 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP]) + + /* + * Group consecutive packets with the same destination port in bursts of 4. +- * Suppose we have array of destionation ports: ++ * Suppose we have array of destination ports: + * dst_port[] = {a, b, c, d,, e, ... } + * dp1 should contain: , dp2: . + * We doing 4 comparisons at once and the result is 4 bit mask. +diff --git a/examples/l3fwd/l3fwd_sse.h b/examples/l3fwd/l3fwd_sse.h +index bb565ed546..d5a717e18c 100644 +--- a/examples/l3fwd/l3fwd_sse.h ++++ b/examples/l3fwd/l3fwd_sse.h +@@ -64,7 +64,7 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP]) + + /* + * Group consecutive packets with the same destination port in bursts of 4. +- * Suppose we have array of destionation ports: ++ * Suppose we have array of destination ports: + * dst_port[] = {a, b, c, d,, e, ... } + * dp1 should contain: , dp2: . + * We doing 4 comparisons at once and the result is 4 bit mask. +diff --git a/examples/multi_process/hotplug_mp/commands.c b/examples/multi_process/hotplug_mp/commands.c +index 48fd329583..41ea265e45 100644 +--- a/examples/multi_process/hotplug_mp/commands.c ++++ b/examples/multi_process/hotplug_mp/commands.c +@@ -175,7 +175,7 @@ static void cmd_dev_detach_parsed(void *parsed_result, + cmdline_printf(cl, "detached device %s\n", + da.name); + else +- cmdline_printf(cl, "failed to dettach device %s\n", ++ cmdline_printf(cl, "failed to detach device %s\n", + da.name); + rte_devargs_reset(&da); + } +diff --git a/examples/multi_process/simple_mp/main.c b/examples/multi_process/simple_mp/main.c +index 5df2a39000..9d5f1088b0 100644 +--- a/examples/multi_process/simple_mp/main.c ++++ b/examples/multi_process/simple_mp/main.c +@@ -4,7 +4,7 @@ + + /* + * This sample application is a simple multi-process application which +- * demostrates sharing of queues and memory pools between processes, and ++ * demonstrates sharing of queues and memory pools between processes, and + * using those queues/pools for communication between the processes. + * + * Application is designed to run with two processes, a primary and a +diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c +index b35886a77b..050337765f 100644 +--- a/examples/multi_process/symmetric_mp/main.c ++++ b/examples/multi_process/symmetric_mp/main.c +@@ -3,7 +3,7 @@ + */ + + /* +- * Sample application demostrating how to do packet I/O in a multi-process ++ * Sample application demonstrating how to do packet I/O in a multi-process + * environment. The same code can be run as a primary process and as a + * secondary process, just with a different proc-id parameter in each case + * (apart from the EAL flag to indicate a secondary process). +diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c +index f110fc129f..81964d0308 100644 +--- a/examples/ntb/ntb_fwd.c ++++ b/examples/ntb/ntb_fwd.c +@@ -696,7 +696,7 @@ assign_stream_to_lcores(void) + break; + } + +- /* Print packet forwading config. */ ++ /* Print packet forwarding config. */ + RTE_LCORE_FOREACH_WORKER(lcore_id) { + conf = &fwd_lcore_conf[lcore_id]; + +diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c +index b01ac60fd1..99e67ef67b 100644 +--- a/examples/packet_ordering/main.c ++++ b/examples/packet_ordering/main.c +@@ -686,7 +686,7 @@ main(int argc, char **argv) + if (ret < 0) + rte_exit(EXIT_FAILURE, "Invalid packet_ordering arguments\n"); + +- /* Check if we have enought cores */ ++ /* Check if we have enough cores */ + if (rte_lcore_count() < 3) + rte_exit(EXIT_FAILURE, "Error, This application needs at " + "least 3 logical cores to run:\n" +diff --git a/examples/performance-thread/common/lthread.c b/examples/performance-thread/common/lthread.c +index 009374a8c3..b02e0fc13a 100644 +--- a/examples/performance-thread/common/lthread.c ++++ b/examples/performance-thread/common/lthread.c +@@ -178,7 +178,7 @@ lthread_create(struct lthread **new_lt, int lcore_id, + bzero(lt, sizeof(struct lthread)); + lt->root_sched = THIS_SCHED; + +- /* set the function args and exit handlder */ ++ /* set the function args and exit handler */ + _lthread_init(lt, fun, arg, _lthread_exit_handler); + + /* put it in the ready queue */ +@@ -384,7 +384,7 @@ void lthread_exit(void *ptr) + } + + +- /* wait until the joinging thread has collected the exit value */ ++ /* wait until the joining thread has collected the exit value */ + while (lt->join != LT_JOIN_EXIT_VAL_READ) + _reschedule(); + +@@ -410,7 +410,7 @@ int lthread_join(struct lthread *lt, void **ptr) + /* invalid to join a detached thread, or a thread that is joined */ + if ((lt_state & BIT(ST_LT_DETACH)) || (lt->join == LT_JOIN_THREAD_SET)) + return POSIX_ERRNO(EINVAL); +- /* pointer to the joining thread and a poingter to return a value */ ++ /* pointer to the joining thread and a pointer to return a value */ + lt->lt_join = current; + current->lt_exit_ptr = ptr; + /* There is a race between lthread_join() and lthread_exit() +diff --git a/examples/performance-thread/common/lthread_diag.c b/examples/performance-thread/common/lthread_diag.c +index 57760a1e23..b1bdf7a30c 100644 +--- a/examples/performance-thread/common/lthread_diag.c ++++ b/examples/performance-thread/common/lthread_diag.c +@@ -232,7 +232,7 @@ lthread_sched_stats_display(void) + } + + /* +- * Defafult diagnostic callback ++ * Default diagnostic callback + */ + static uint64_t + _lthread_diag_default_cb(uint64_t time, struct lthread *lt, int diag_event, +diff --git a/examples/performance-thread/common/lthread_int.h b/examples/performance-thread/common/lthread_int.h +index d010126f16..ec018e34a1 100644 +--- a/examples/performance-thread/common/lthread_int.h ++++ b/examples/performance-thread/common/lthread_int.h +@@ -107,7 +107,7 @@ enum join_st { + LT_JOIN_EXIT_VAL_READ, /* joining thread has collected ret val */ + }; + +-/* defnition of an lthread stack object */ ++/* definition of an lthread stack object */ + struct lthread_stack { + uint8_t stack[LTHREAD_MAX_STACK_SIZE]; + size_t stack_size; +diff --git a/examples/performance-thread/common/lthread_tls.c b/examples/performance-thread/common/lthread_tls.c +index 4ab2e3558b..bae45f2aa9 100644 +--- a/examples/performance-thread/common/lthread_tls.c ++++ b/examples/performance-thread/common/lthread_tls.c +@@ -215,7 +215,7 @@ void _lthread_tls_alloc(struct lthread *lt) + tls->root_sched = (THIS_SCHED); + lt->tls = tls; + +- /* allocate data for TLS varaiables using RTE_PER_LTHREAD macros */ ++ /* allocate data for TLS variables using RTE_PER_LTHREAD macros */ + if (sizeof(void *) < (uint64_t)RTE_PER_LTHREAD_SECTION_SIZE) { + lt->per_lthread_data = + _lthread_objcache_alloc((THIS_SCHED)->per_lthread_cache); +diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c +index 8a35040597..1ddb2a9138 100644 +--- a/examples/performance-thread/l3fwd-thread/main.c ++++ b/examples/performance-thread/l3fwd-thread/main.c +@@ -125,7 +125,7 @@ cb_parse_ptype(__rte_unused uint16_t port, __rte_unused uint16_t queue, + } + + /* +- * When set to zero, simple forwaring path is eanbled. ++ * When set to zero, simple forwarding path is enabled. + * When set to one, optimized forwarding path is enabled. + * Note that LPM optimisation path uses SSE4.1 instructions. + */ +@@ -1529,7 +1529,7 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP]) + } + + /* +- * We group consecutive packets with the same destionation port into one burst. ++ * We group consecutive packets with the same destination port into one burst. + * To avoid extra latency this is done together with some other packet + * processing, but after we made a final decision about packet's destination. + * To do this we maintain: +@@ -1554,7 +1554,7 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP]) + + /* + * Group consecutive packets with the same destination port in bursts of 4. +- * Suppose we have array of destionation ports: ++ * Suppose we have array of destination ports: + * dst_port[] = {a, b, c, d,, e, ... } + * dp1 should contain: , dp2: . + * We doing 4 comparisons at once and the result is 4 bit mask. +@@ -1565,7 +1565,7 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, __m128i dp1, __m128i dp2) + { + static const struct { + uint64_t pnum; /* prebuild 4 values for pnum[]. */ +- int32_t idx; /* index for new last updated elemnet. */ ++ int32_t idx; /* index for new last updated element. */ + uint16_t lpv; /* add value to the last updated element. */ + } gptbl[GRPSZ] = { + { +@@ -1834,7 +1834,7 @@ process_burst(struct rte_mbuf *pkts_burst[MAX_PKT_BURST], int nb_rx, + + /* + * Send packets out, through destination port. +- * Consecuteve pacekts with the same destination port ++ * Consecutive packets with the same destination port + * are already grouped together. + * If destination port for the packet equals BAD_PORT, + * then free the packet without sending it out. +@@ -3514,7 +3514,7 @@ main(int argc, char **argv) + + ret = rte_timer_subsystem_init(); + if (ret < 0) +- rte_exit(EXIT_FAILURE, "Failed to initialize timer subystem\n"); ++ rte_exit(EXIT_FAILURE, "Failed to initialize timer subsystem\n"); + + /* pre-init dst MACs for all ports to 02:00:00:00:00:xx */ + for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { +diff --git a/examples/performance-thread/pthread_shim/pthread_shim.h b/examples/performance-thread/pthread_shim/pthread_shim.h +index e90fb15fc1..ce51627a5b 100644 +--- a/examples/performance-thread/pthread_shim/pthread_shim.h ++++ b/examples/performance-thread/pthread_shim/pthread_shim.h +@@ -41,7 +41,7 @@ + * + * The decision whether to invoke the real library function or the lthread + * function is controlled by a per pthread flag that can be switched +- * on of off by the pthread_override_set() API described below. Typcially ++ * on of off by the pthread_override_set() API described below. Typically + * this should be done as the first action of the initial lthread. + * + * N.B In general it would be poor practice to revert to invoke a real +diff --git a/examples/pipeline/examples/registers.spec b/examples/pipeline/examples/registers.spec +index 74a014ad06..59998fef03 100644 +--- a/examples/pipeline/examples/registers.spec ++++ b/examples/pipeline/examples/registers.spec +@@ -4,7 +4,7 @@ + ; This program is setting up two register arrays called "pkt_counters" and "byte_counters". + ; On every input packet (Ethernet/IPv4), the "pkt_counters" register at location indexed by + ; the IPv4 header "Source Address" field is incremented, while the same location in the +-; "byte_counters" array accummulates the value of the IPv4 header "Total Length" field. ++; "byte_counters" array accumulates the value of the IPv4 header "Total Length" field. + ; + ; The "regrd" and "regwr" CLI commands can be used to read and write the current value of + ; any register array location. +diff --git a/examples/qos_sched/cmdline.c b/examples/qos_sched/cmdline.c +index 257b87a7cf..6691b02d89 100644 +--- a/examples/qos_sched/cmdline.c ++++ b/examples/qos_sched/cmdline.c +@@ -41,7 +41,7 @@ static void cmd_help_parsed(__rte_unused void *parsed_result, + " qavg port X subport Y pipe Z : Show average queue size per pipe.\n" + " qavg port X subport Y pipe Z tc A : Show average queue size per pipe and TC.\n" + " qavg port X subport Y pipe Z tc A q B : Show average queue size of a specific queue.\n" +- " qavg [n|period] X : Set number of times and peiod (us).\n\n" ++ " qavg [n|period] X : Set number of times and period (us).\n\n" + ); + + } +diff --git a/examples/server_node_efd/node/node.c b/examples/server_node_efd/node/node.c +index ba1c7e5153..fc2aa5ffef 100644 +--- a/examples/server_node_efd/node/node.c ++++ b/examples/server_node_efd/node/node.c +@@ -296,7 +296,7 @@ handle_packets(struct rte_hash *h, struct rte_mbuf **bufs, uint16_t num_packets) + } + } + } +-/* >8 End of packets dequeueing. */ ++/* >8 End of packets dequeuing. */ + + /* + * Application main function - loops through +diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c +index 16435ee3cc..518cd72179 100644 +--- a/examples/skeleton/basicfwd.c ++++ b/examples/skeleton/basicfwd.c +@@ -179,7 +179,7 @@ main(int argc, char *argv[]) + int ret = rte_eal_init(argc, argv); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); +- /* >8 End of initializion the Environment Abstraction Layer (EAL). */ ++ /* >8 End of initialization the Environment Abstraction Layer (EAL). */ + + argc -= ret; + argv += ret; +diff --git a/examples/vhost/main.c b/examples/vhost/main.c +index 5ebfff3ac4..d05a8f9193 100644 +--- a/examples/vhost/main.c ++++ b/examples/vhost/main.c +@@ -107,7 +107,7 @@ static uint32_t burst_rx_retry_num = BURST_RX_RETRIES; + static char *socket_files; + static int nb_sockets; + +-/* empty vmdq configuration structure. Filled in programatically */ ++/* empty VMDq configuration structure. Filled in programmatically */ + static struct rte_eth_conf vmdq_conf_default = { + .rxmode = { + .mq_mode = RTE_ETH_MQ_RX_VMDQ_ONLY, +@@ -115,7 +115,7 @@ static struct rte_eth_conf vmdq_conf_default = { + /* + * VLAN strip is necessary for 1G NIC such as I350, + * this fixes bug of ipv4 forwarding in guest can't +- * forward pakets from one virtio dev to another virtio dev. ++ * forward packets from one virtio dev to another virtio dev. + */ + .offloads = RTE_ETH_RX_OFFLOAD_VLAN_STRIP, + }, +@@ -463,7 +463,7 @@ us_vhost_usage(const char *prgname) + " --nb-devices ND\n" + " -p PORTMASK: Set mask for ports to be used by application\n" + " --vm2vm [0|1|2]: disable/software(default)/hardware vm2vm comms\n" +- " --rx-retry [0|1]: disable/enable(default) retries on rx. Enable retry if destintation queue is full\n" ++ " --rx-retry [0|1]: disable/enable(default) retries on Rx. Enable retry if destination queue is full\n" + " --rx-retry-delay [0-N]: timeout(in usecond) between retries on RX. This makes effect only if retries on rx enabled\n" + " --rx-retry-num [0-N]: the number of retries on rx. This makes effect only if retries on rx enabled\n" + " --mergeable [0|1]: disable(default)/enable RX mergeable buffers\n" +@@ -1288,7 +1288,7 @@ switch_worker(void *arg __rte_unused) + struct vhost_dev *vdev; + struct mbuf_table *tx_q; + +- RTE_LOG(INFO, VHOST_DATA, "Procesing on Core %u started\n", lcore_id); ++ RTE_LOG(INFO, VHOST_DATA, "Processing on Core %u started\n", lcore_id); + + tx_q = &lcore_tx_queue[lcore_id]; + for (i = 0; i < rte_lcore_count(); i++) { +@@ -1332,7 +1332,7 @@ switch_worker(void *arg __rte_unused) + + /* + * Remove a device from the specific data core linked list and from the +- * main linked list. Synchonization occurs through the use of the ++ * main linked list. Synchronization occurs through the use of the + * lcore dev_removal_flag. Device is made volatile here to avoid re-ordering + * of dev->remove=1 which can cause an infinite loop in the rte_pause loop. + */ +diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c +index d767423a40..97b8def7ca 100644 +--- a/examples/vm_power_manager/channel_monitor.c ++++ b/examples/vm_power_manager/channel_monitor.c +@@ -404,7 +404,7 @@ get_pcpu_to_control(struct policy *pol) + + /* + * So now that we're handling virtual and physical cores, we need to +- * differenciate between them when adding them to the branch monitor. ++ * differentiate between them when adding them to the branch monitor. + * Virtual cores need to be converted to physical cores. + */ + if (pol->pkt.core_type == RTE_POWER_CORE_TYPE_VIRTUAL) { +diff --git a/examples/vm_power_manager/power_manager.h b/examples/vm_power_manager/power_manager.h +index d35f8cbe01..d51039e2c6 100644 +--- a/examples/vm_power_manager/power_manager.h ++++ b/examples/vm_power_manager/power_manager.h +@@ -224,7 +224,7 @@ int power_manager_enable_turbo_core(unsigned int core_num); + int power_manager_disable_turbo_core(unsigned int core_num); + + /** +- * Get the current freuency of the core specified by core_num ++ * Get the current frequency of the core specified by core_num + * + * @param core_num + * The core number to get the current frequency +diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c +index 2c00a942f1..10410b8783 100644 +--- a/examples/vmdq/main.c ++++ b/examples/vmdq/main.c +@@ -62,7 +62,7 @@ static uint8_t rss_enable; + + /* Default structure for VMDq. 8< */ + +-/* empty vmdq configuration structure. Filled in programatically */ ++/* empty VMDq configuration structure. Filled in programmatically */ + static const struct rte_eth_conf vmdq_conf_default = { + .rxmode = { + .mq_mode = RTE_ETH_MQ_RX_VMDQ_ONLY, +diff --git a/kernel/linux/kni/kni_fifo.h b/kernel/linux/kni/kni_fifo.h +index 5c91b55379..1ba5172002 100644 +--- a/kernel/linux/kni/kni_fifo.h ++++ b/kernel/linux/kni/kni_fifo.h +@@ -41,7 +41,7 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, uint32_t num) + } + + /** +- * Get up to num elements from the fifo. Return the number actully read ++ * Get up to num elements from the FIFO. Return the number actually read + */ + static inline uint32_t + kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num) +diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c +index f316d3e875..7ea30f4186 100644 +--- a/lib/acl/acl_bld.c ++++ b/lib/acl/acl_bld.c +@@ -885,7 +885,7 @@ acl_gen_range_trie(struct acl_build_context *context, + return root; + } + +- /* gather information about divirgent paths */ ++ /* gather information about divergent paths */ + lo_00 = 0; + hi_ff = UINT8_MAX; + for (k = n - 1; k >= 0; k--) { +diff --git a/lib/acl/acl_run_altivec.h b/lib/acl/acl_run_altivec.h +index 2de6f27b1f..24a41eec17 100644 +--- a/lib/acl/acl_run_altivec.h ++++ b/lib/acl/acl_run_altivec.h +@@ -146,7 +146,7 @@ transition4(xmm_t next_input, const uint64_t *trans, + + dfa_ofs = vec_sub(t, r); + +- /* QUAD/SINGLE caluclations. */ ++ /* QUAD/SINGLE calculations. */ + t = (xmm_t)vec_cmpgt((vector signed char)in, (vector signed char)tr_hi); + t = (xmm_t)vec_sel( + vec_sel( +diff --git a/lib/acl/acl_run_avx512.c b/lib/acl/acl_run_avx512.c +index 78fbe34f7c..3b8795561b 100644 +--- a/lib/acl/acl_run_avx512.c ++++ b/lib/acl/acl_run_avx512.c +@@ -64,7 +64,7 @@ update_flow_mask(const struct acl_flow_avx512 *flow, uint32_t *fmsk, + } + + /* +- * Resolve matches for multiple categories (LE 8, use 128b instuctions/regs) ++ * Resolve matches for multiple categories (LE 8, use 128b instructions/regs) + */ + static inline void + resolve_mcle8_avx512x1(uint32_t result[], +diff --git a/lib/acl/acl_run_avx512x16.h b/lib/acl/acl_run_avx512x16.h +index 48bb6fed85..f87293eeb7 100644 +--- a/lib/acl/acl_run_avx512x16.h ++++ b/lib/acl/acl_run_avx512x16.h +@@ -10,7 +10,7 @@ + */ + + /* +- * This implementation uses 512-bit registers(zmm) and instrincts. ++ * This implementation uses 512-bit registers(zmm) and intrinsics. + * So our main SIMD type is 512-bit width and each such variable can + * process sizeof(__m512i) / sizeof(uint32_t) == 16 entries in parallel. + */ +@@ -25,20 +25,20 @@ + #define _F_(x) x##_avx512x16 + + /* +- * Same instrincts have different syntaxis (depending on the bit-width), ++ * Same intrinsics have different syntaxes (depending on the bit-width), + * so to overcome that few macros need to be defined. + */ + +-/* Naming convention for generic epi(packed integers) type instrincts. */ ++/* Naming convention for generic epi(packed integers) type intrinsics. */ + #define _M_I_(x) _mm512_##x + +-/* Naming convention for si(whole simd integer) type instrincts. */ ++/* Naming convention for si(whole simd integer) type intrinsics. */ + #define _M_SI_(x) _mm512_##x##_si512 + +-/* Naming convention for masked gather type instrincts. */ ++/* Naming convention for masked gather type intrinsics. */ + #define _M_MGI_(x) _mm512_##x + +-/* Naming convention for gather type instrincts. */ ++/* Naming convention for gather type intrinsics. */ + #define _M_GI_(name, idx, base, scale) _mm512_##name(idx, base, scale) + + /* num/mask of transitions per SIMD regs */ +@@ -239,7 +239,7 @@ _F_(gather_bytes)(__m512i zero, const __m512i p[2], const uint32_t m[2], + } + + /* +- * Resolve matches for multiple categories (GT 8, use 512b instuctions/regs) ++ * Resolve matches for multiple categories (GT 8, use 512b instructions/regs) + */ + static inline void + resolve_mcgt8_avx512x1(uint32_t result[], +diff --git a/lib/acl/acl_run_avx512x8.h b/lib/acl/acl_run_avx512x8.h +index 61ac9d1b47..5da2bbfdeb 100644 +--- a/lib/acl/acl_run_avx512x8.h ++++ b/lib/acl/acl_run_avx512x8.h +@@ -10,7 +10,7 @@ + */ + + /* +- * This implementation uses 256-bit registers(ymm) and instrincts. ++ * This implementation uses 256-bit registers(ymm) and intrinsics. + * So our main SIMD type is 256-bit width and each such variable can + * process sizeof(__m256i) / sizeof(uint32_t) == 8 entries in parallel. + */ +@@ -25,20 +25,20 @@ + #define _F_(x) x##_avx512x8 + + /* +- * Same instrincts have different syntaxis (depending on the bit-width), ++ * Same intrinsics have different syntaxes (depending on the bit-width), + * so to overcome that few macros need to be defined. + */ + +-/* Naming convention for generic epi(packed integers) type instrincts. */ ++/* Naming convention for generic epi(packed integers) type intrinsics. */ + #define _M_I_(x) _mm256_##x + +-/* Naming convention for si(whole simd integer) type instrincts. */ ++/* Naming convention for si(whole simd integer) type intrinsics. */ + #define _M_SI_(x) _mm256_##x##_si256 + +-/* Naming convention for masked gather type instrincts. */ ++/* Naming convention for masked gather type intrinsics. */ + #define _M_MGI_(x) _mm256_m##x + +-/* Naming convention for gather type instrincts. */ ++/* Naming convention for gather type intrinsics. */ + #define _M_GI_(name, idx, base, scale) _mm256_##name(base, idx, scale) + + /* num/mask of transitions per SIMD regs */ +diff --git a/lib/bpf/bpf_convert.c b/lib/bpf/bpf_convert.c +index db84add7dc..9563274c9c 100644 +--- a/lib/bpf/bpf_convert.c ++++ b/lib/bpf/bpf_convert.c +@@ -412,7 +412,7 @@ static int bpf_convert_filter(const struct bpf_insn *prog, size_t len, + BPF_EMIT_JMP; + break; + +- /* ldxb 4 * ([14] & 0xf) is remaped into 6 insns. */ ++ /* ldxb 4 * ([14] & 0xf) is remapped into 6 insns. */ + case BPF_LDX | BPF_MSH | BPF_B: + /* tmp = A */ + *insn++ = BPF_MOV64_REG(BPF_REG_TMP, BPF_REG_A); +@@ -428,7 +428,7 @@ static int bpf_convert_filter(const struct bpf_insn *prog, size_t len, + *insn = BPF_MOV64_REG(BPF_REG_A, BPF_REG_TMP); + break; + +- /* RET_K is remaped into 2 insns. RET_A case doesn't need an ++ /* RET_K is remapped into 2 insns. RET_A case doesn't need an + * extra mov as EBPF_REG_0 is already mapped into BPF_REG_A. + */ + case BPF_RET | BPF_A: +diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h +index 9942c6ec21..4abe79c536 100644 +--- a/lib/dmadev/rte_dmadev.h ++++ b/lib/dmadev/rte_dmadev.h +@@ -533,7 +533,7 @@ struct rte_dma_port_param { + * @note If some fields can not be supported by the + * hardware/driver, then the driver ignores those fields. + * Please check driver-specific documentation for limitations +- * and capablites. ++ * and capabilities. + */ + __extension__ + struct { +@@ -731,7 +731,7 @@ enum rte_dma_status_code { + /** The operation completed successfully. */ + RTE_DMA_STATUS_SUCCESSFUL, + /** The operation failed to complete due abort by user. +- * This is mainly used when processing dev_stop, user could modidy the ++ * This is mainly used when processing dev_stop, user could modify the + * descriptors (e.g. change one bit to tell hardware abort this job), + * it allows outstanding requests to be complete as much as possible, + * so reduce the time to stop the device. +diff --git a/lib/eal/arm/include/rte_cycles_32.h b/lib/eal/arm/include/rte_cycles_32.h +index f79718ce8c..cec4d69e7a 100644 +--- a/lib/eal/arm/include/rte_cycles_32.h ++++ b/lib/eal/arm/include/rte_cycles_32.h +@@ -30,7 +30,7 @@ extern "C" { + + /** + * This call is easily portable to any architecture, however, +- * it may require a system call and inprecise for some tasks. ++ * it may require a system call and imprecise for some tasks. + */ + static inline uint64_t + __rte_rdtsc_syscall(void) +diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c +index 10aa91cc09..9f720bdc8f 100644 +--- a/lib/eal/freebsd/eal_interrupts.c ++++ b/lib/eal/freebsd/eal_interrupts.c +@@ -234,7 +234,7 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle, + + rte_spinlock_lock(&intr_lock); + +- /* check if the insterrupt source for the fd is existent */ ++ /* check if the interrupt source for the fd is existent */ + TAILQ_FOREACH(src, &intr_sources, next) + if (rte_intr_fd_get(src->intr_handle) == rte_intr_fd_get(intr_handle)) + break; +@@ -288,7 +288,7 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle, + + rte_spinlock_lock(&intr_lock); + +- /* check if the insterrupt source for the fd is existent */ ++ /* check if the interrupt source for the fd is existent */ + TAILQ_FOREACH(src, &intr_sources, next) + if (rte_intr_fd_get(src->intr_handle) == rte_intr_fd_get(intr_handle)) + break; +diff --git a/lib/eal/include/generic/rte_pflock.h b/lib/eal/include/generic/rte_pflock.h +index b9de063c89..e7bb29b3c5 100644 +--- a/lib/eal/include/generic/rte_pflock.h ++++ b/lib/eal/include/generic/rte_pflock.h +@@ -157,7 +157,7 @@ rte_pflock_write_lock(rte_pflock_t *pf) + uint16_t ticket, w; + + /* Acquire ownership of write-phase. +- * This is same as rte_tickelock_lock(). ++ * This is same as rte_ticketlock_lock(). + */ + ticket = __atomic_fetch_add(&pf->wr.in, 1, __ATOMIC_RELAXED); + rte_wait_until_equal_16(&pf->wr.out, ticket, __ATOMIC_ACQUIRE); +diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h +index ed02e15119..3892519fab 100644 +--- a/lib/eal/include/rte_malloc.h ++++ b/lib/eal/include/rte_malloc.h +@@ -58,7 +58,7 @@ rte_malloc(const char *type, size_t size, unsigned align) + __rte_alloc_size(2); + + /** +- * Allocate zero'ed memory from the heap. ++ * Allocate zeroed memory from the heap. + * + * Equivalent to rte_malloc() except that the memory zone is + * initialised with zeros. In NUMA systems, the memory allocated resides on the +@@ -189,7 +189,7 @@ rte_malloc_socket(const char *type, size_t size, unsigned align, int socket) + __rte_alloc_size(2); + + /** +- * Allocate zero'ed memory from the heap. ++ * Allocate zeroed memory from the heap. + * + * Equivalent to rte_malloc() except that the memory zone is + * initialised with zeros. +diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c +index 621e43626e..c3e9a08822 100644 +--- a/lib/eal/linux/eal_interrupts.c ++++ b/lib/eal/linux/eal_interrupts.c +@@ -589,7 +589,7 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle, + + rte_spinlock_lock(&intr_lock); + +- /* check if the insterrupt source for the fd is existent */ ++ /* check if the interrupt source for the fd is existent */ + TAILQ_FOREACH(src, &intr_sources, next) { + if (rte_intr_fd_get(src->intr_handle) == rte_intr_fd_get(intr_handle)) + break; +@@ -639,7 +639,7 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle, + + rte_spinlock_lock(&intr_lock); + +- /* check if the insterrupt source for the fd is existent */ ++ /* check if the interrupt source for the fd is existent */ + TAILQ_FOREACH(src, &intr_sources, next) + if (rte_intr_fd_get(src->intr_handle) == rte_intr_fd_get(intr_handle)) + break; +diff --git a/lib/eal/linux/eal_vfio.h b/lib/eal/linux/eal_vfio.h +index 6ebaca6a0c..c5d5f70548 100644 +--- a/lib/eal/linux/eal_vfio.h ++++ b/lib/eal/linux/eal_vfio.h +@@ -103,7 +103,7 @@ struct vfio_group { + typedef int (*vfio_dma_func_t)(int); + + /* Custom memory region DMA mapping function prototype. +- * Takes VFIO container fd, virtual address, phisical address, length and ++ * Takes VFIO container fd, virtual address, physical address, length and + * operation type (0 to unmap 1 for map) as a parameters. + * Returns 0 on success, -1 on error. + **/ +diff --git a/lib/eal/windows/eal_windows.h b/lib/eal/windows/eal_windows.h +index 23ead6d30c..245aa60344 100644 +--- a/lib/eal/windows/eal_windows.h ++++ b/lib/eal/windows/eal_windows.h +@@ -63,7 +63,7 @@ unsigned int eal_socket_numa_node(unsigned int socket_id); + * @param arg + * Argument to the called function. + * @return +- * 0 on success, netagive error code on failure. ++ * 0 on success, negative error code on failure. + */ + int eal_intr_thread_schedule(void (*func)(void *arg), void *arg); + +diff --git a/lib/eal/windows/include/dirent.h b/lib/eal/windows/include/dirent.h +index 869a598378..34eb077f8c 100644 +--- a/lib/eal/windows/include/dirent.h ++++ b/lib/eal/windows/include/dirent.h +@@ -440,7 +440,7 @@ opendir(const char *dirname) + * display correctly on console. The problem can be fixed in two ways: + * (1) change the character set of console to 1252 using chcp utility + * and use Lucida Console font, or (2) use _cprintf function when +- * writing to console. The _cprinf() will re-encode ANSI strings to the ++ * writing to console. The _cprintf() will re-encode ANSI strings to the + * console code page so many non-ASCII characters will display correctly. + */ + static struct dirent* +@@ -579,7 +579,7 @@ dirent_mbstowcs_s( + wcstr[n] = 0; + } + +- /* Length of resuting multi-byte string WITH zero ++ /* Length of resulting multi-byte string WITH zero + *terminator + */ + if (pReturnValue) +diff --git a/lib/eal/windows/include/fnmatch.h b/lib/eal/windows/include/fnmatch.h +index c272f65ccd..c6b226bd5d 100644 +--- a/lib/eal/windows/include/fnmatch.h ++++ b/lib/eal/windows/include/fnmatch.h +@@ -26,14 +26,14 @@ extern "C" { + #define FNM_PREFIX_DIRS 0x20 + + /** +- * This function is used for searhing a given string source ++ * This function is used for searching a given string source + * with the given regular expression pattern. + * + * @param pattern + * regular expression notation describing the pattern to match + * + * @param string +- * source string to searcg for the pattern ++ * source string to search for the pattern + * + * @param flag + * containing information about the pattern +diff --git a/lib/eal/x86/include/rte_atomic.h b/lib/eal/x86/include/rte_atomic.h +index 915afd9d27..f2ee1a9ce9 100644 +--- a/lib/eal/x86/include/rte_atomic.h ++++ b/lib/eal/x86/include/rte_atomic.h +@@ -60,7 +60,7 @@ extern "C" { + * Basic idea is to use lock prefixed add with some dummy memory location + * as the destination. From their experiments 128B(2 cache lines) below + * current stack pointer looks like a good candidate. +- * So below we use that techinque for rte_smp_mb() implementation. ++ * So below we use that technique for rte_smp_mb() implementation. + */ + + static __rte_always_inline void +diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c +index 809416d9b7..3182b52c23 100644 +--- a/lib/eventdev/rte_event_eth_rx_adapter.c ++++ b/lib/eventdev/rte_event_eth_rx_adapter.c +@@ -3334,7 +3334,7 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused, + token = strtok(NULL, "\0"); + if (token != NULL) + RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" +- " telemetry command, igrnoring"); ++ " telemetry command, ignoring"); + + if (rte_event_eth_rx_adapter_queue_conf_get(rx_adapter_id, eth_dev_id, + rx_queue_id, &queue_conf)) { +@@ -3398,7 +3398,7 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused, + token = strtok(NULL, "\0"); + if (token != NULL) + RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" +- " telemetry command, igrnoring"); ++ " telemetry command, ignoring"); + + if (rte_event_eth_rx_adapter_queue_stats_get(rx_adapter_id, eth_dev_id, + rx_queue_id, &q_stats)) { +@@ -3460,7 +3460,7 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused, + token = strtok(NULL, "\0"); + if (token != NULL) + RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" +- " telemetry command, igrnoring"); ++ " telemetry command, ignoring"); + + if (rte_event_eth_rx_adapter_queue_stats_reset(rx_adapter_id, + eth_dev_id, +diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c +index 6ca180d7e7..0cced97a77 100644 +--- a/lib/fib/rte_fib.c ++++ b/lib/fib/rte_fib.c +@@ -40,10 +40,10 @@ EAL_REGISTER_TAILQ(rte_fib_tailq) + struct rte_fib { + char name[RTE_FIB_NAMESIZE]; + enum rte_fib_type type; /**< Type of FIB struct */ +- struct rte_rib *rib; /**< RIB helper datastruct */ ++ struct rte_rib *rib; /**< RIB helper datastructure */ + void *dp; /**< pointer to the dataplane struct*/ +- rte_fib_lookup_fn_t lookup; /**< fib lookup function */ +- rte_fib_modify_fn_t modify; /**< modify fib datastruct */ ++ rte_fib_lookup_fn_t lookup; /**< FIB lookup function */ ++ rte_fib_modify_fn_t modify; /**< modify FIB datastructure */ + uint64_t def_nh; + }; + +diff --git a/lib/fib/rte_fib.h b/lib/fib/rte_fib.h +index b3c59dfaaa..e592d3251a 100644 +--- a/lib/fib/rte_fib.h ++++ b/lib/fib/rte_fib.h +@@ -189,7 +189,7 @@ rte_fib_lookup_bulk(struct rte_fib *fib, uint32_t *ips, + * FIB object handle + * @return + * Pointer on the dataplane struct on success +- * NULL othervise ++ * NULL otherwise + */ + void * + rte_fib_get_dp(struct rte_fib *fib); +@@ -201,7 +201,7 @@ rte_fib_get_dp(struct rte_fib *fib); + * FIB object handle + * @return + * Pointer on the RIB on success +- * NULL othervise ++ * NULL otherwise + */ + struct rte_rib * + rte_fib_get_rib(struct rte_fib *fib); +diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c +index be79efe004..eebee297d6 100644 +--- a/lib/fib/rte_fib6.c ++++ b/lib/fib/rte_fib6.c +@@ -40,10 +40,10 @@ EAL_REGISTER_TAILQ(rte_fib6_tailq) + struct rte_fib6 { + char name[FIB6_NAMESIZE]; + enum rte_fib6_type type; /**< Type of FIB struct */ +- struct rte_rib6 *rib; /**< RIB helper datastruct */ ++ struct rte_rib6 *rib; /**< RIB helper datastructure */ + void *dp; /**< pointer to the dataplane struct*/ +- rte_fib6_lookup_fn_t lookup; /**< fib lookup function */ +- rte_fib6_modify_fn_t modify; /**< modify fib datastruct */ ++ rte_fib6_lookup_fn_t lookup; /**< FIB lookup function */ ++ rte_fib6_modify_fn_t modify; /**< modify FIB datastructure */ + uint64_t def_nh; + }; + +diff --git a/lib/fib/rte_fib6.h b/lib/fib/rte_fib6.h +index 95879af96d..cb133719e1 100644 +--- a/lib/fib/rte_fib6.h ++++ b/lib/fib/rte_fib6.h +@@ -184,7 +184,7 @@ rte_fib6_lookup_bulk(struct rte_fib6 *fib, + * FIB6 object handle + * @return + * Pointer on the dataplane struct on success +- * NULL othervise ++ * NULL otherwise + */ + void * + rte_fib6_get_dp(struct rte_fib6 *fib); +@@ -196,7 +196,7 @@ rte_fib6_get_dp(struct rte_fib6 *fib); + * FIB object handle + * @return + * Pointer on the RIB6 on success +- * NULL othervise ++ * NULL otherwise + */ + struct rte_rib6 * + rte_fib6_get_rib(struct rte_fib6 *fib); +diff --git a/lib/ipsec/ipsec_telemetry.c b/lib/ipsec/ipsec_telemetry.c +index b8b08404b6..9a91e47122 100644 +--- a/lib/ipsec/ipsec_telemetry.c ++++ b/lib/ipsec/ipsec_telemetry.c +@@ -236,7 +236,7 @@ RTE_INIT(rte_ipsec_telemetry_init) + "Return list of IPsec SAs with telemetry enabled."); + rte_telemetry_register_cmd("/ipsec/sa/stats", + handle_telemetry_cmd_ipsec_sa_stats, +- "Returns IPsec SA stastistics. Parameters: int sa_spi"); ++ "Returns IPsec SA statistics. Parameters: int sa_spi"); + rte_telemetry_register_cmd("/ipsec/sa/details", + handle_telemetry_cmd_ipsec_sa_details, + "Returns IPsec SA configuration. Parameters: int sa_spi"); +diff --git a/lib/ipsec/rte_ipsec_sad.h b/lib/ipsec/rte_ipsec_sad.h +index b65d295831..a3ae57df7e 100644 +--- a/lib/ipsec/rte_ipsec_sad.h ++++ b/lib/ipsec/rte_ipsec_sad.h +@@ -153,7 +153,7 @@ rte_ipsec_sad_destroy(struct rte_ipsec_sad *sad); + * @param keys + * Array of keys to be looked up in the SAD + * @param sa +- * Pointer assocoated with the keys. ++ * Pointer associated with the keys. + * If the lookup for the given key failed, then corresponding sa + * will be NULL + * @param n +diff --git a/lib/ipsec/sa.c b/lib/ipsec/sa.c +index 1e51482c92..cdb70af0cb 100644 +--- a/lib/ipsec/sa.c ++++ b/lib/ipsec/sa.c +@@ -362,7 +362,7 @@ esp_outb_tun_init(struct rte_ipsec_sa *sa, const struct rte_ipsec_sa_prm *prm) + + memcpy(sa->hdr, prm->tun.hdr, prm->tun.hdr_len); + +- /* insert UDP header if UDP encapsulation is inabled */ ++ /* insert UDP header if UDP encapsulation is enabled */ + if (sa->type & RTE_IPSEC_SATP_NATT_ENABLE) { + struct rte_udp_hdr *udph = (struct rte_udp_hdr *) + &sa->hdr[prm->tun.hdr_len]; +diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h +index 321a419c71..3d6ddd6773 100644 +--- a/lib/mbuf/rte_mbuf_core.h ++++ b/lib/mbuf/rte_mbuf_core.h +@@ -8,7 +8,7 @@ + + /** + * @file +- * This file contains definion of RTE mbuf structure itself, ++ * This file contains definition of RTE mbuf structure itself, + * packet offload flags and some related macros. + * For majority of DPDK entities, it is not recommended to include + * this file directly, use include instead. +diff --git a/lib/meson.build b/lib/meson.build +index 5363f0d184..963287b174 100644 +--- a/lib/meson.build ++++ b/lib/meson.build +@@ -3,7 +3,7 @@ + + + # process all libraries equally, as far as possible +-# "core" libs first, then others alphebetically as far as possible ++# "core" libs first, then others alphabetically as far as possible + # NOTE: for speed of meson runs, the dependencies in the subdirectories + # sometimes skip deps that would be implied by others, e.g. if mempool is + # given as a dep, no need to mention ring. This is especially true for the +diff --git a/lib/net/rte_l2tpv2.h b/lib/net/rte_l2tpv2.h +index b90e36cf12..938a993b48 100644 +--- a/lib/net/rte_l2tpv2.h ++++ b/lib/net/rte_l2tpv2.h +@@ -143,7 +143,7 @@ struct rte_l2tpv2_msg_without_length { + /** + * L2TPv2 message Header contains all options except ns_nr(length, + * offset size, offset padding). +- * Ns and Nr MUST be toghter. ++ * Ns and Nr MUST be together. + */ + struct rte_l2tpv2_msg_without_ns_nr { + rte_be16_t length; /**< length(16) */ +@@ -155,7 +155,7 @@ struct rte_l2tpv2_msg_without_ns_nr { + + /** + * L2TPv2 message Header contains all options except ns_nr(length, ns, nr). +- * offset size and offset padding MUST be toghter. ++ * offset size and offset padding MUST be together. + */ + struct rte_l2tpv2_msg_without_offset { + rte_be16_t length; /**< length(16) */ +diff --git a/lib/pipeline/rte_swx_ctl.h b/lib/pipeline/rte_swx_ctl.h +index 46d05823e1..82e62e70a7 100644 +--- a/lib/pipeline/rte_swx_ctl.h ++++ b/lib/pipeline/rte_swx_ctl.h +@@ -369,7 +369,7 @@ struct rte_swx_table_stats { + uint64_t n_pkts_miss; + + /** Number of packets (with either lookup hit or miss) per pipeline +- * action. Array of pipeline *n_actions* elements indedex by the ++ * action. Array of pipeline *n_actions* elements indexed by the + * pipeline-level *action_id*, therefore this array has the same size + * for all the tables within the same pipeline. + */ +@@ -629,7 +629,7 @@ struct rte_swx_learner_stats { + uint64_t n_pkts_forget; + + /** Number of packets (with either lookup hit or miss) per pipeline action. Array of +- * pipeline *n_actions* elements indedex by the pipeline-level *action_id*, therefore this ++ * pipeline *n_actions* elements indexed by the pipeline-level *action_id*, therefore this + * array has the same size for all the tables within the same pipeline. + */ + uint64_t *n_pkts_action; +diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h +index 1921fdcd78..fa944c95f2 100644 +--- a/lib/pipeline/rte_swx_pipeline_internal.h ++++ b/lib/pipeline/rte_swx_pipeline_internal.h +@@ -309,7 +309,7 @@ enum instruction_type { + */ + INSTR_ALU_CKADD_FIELD, /* src = H */ + INSTR_ALU_CKADD_STRUCT20, /* src = h.header, with sizeof(header) = 20 */ +- INSTR_ALU_CKADD_STRUCT, /* src = h.hdeader, with any sizeof(header) */ ++ INSTR_ALU_CKADD_STRUCT, /* src = h.header, with any sizeof(header) */ + + /* cksub dst src + * dst = dst '- src +@@ -1562,7 +1562,7 @@ emit_handler(struct thread *t) + return; + } + +- /* Header encapsulation (optionally, with prior header decasulation). */ ++ /* Header encapsulation (optionally, with prior header decapsulation). */ + if ((t->n_headers_out == 2) && + (h1->ptr + h1->n_bytes == t->ptr) && + (h0->ptr == h0->ptr0)) { +diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c +index 8e9aa44e30..07a7580ac8 100644 +--- a/lib/pipeline/rte_swx_pipeline_spec.c ++++ b/lib/pipeline/rte_swx_pipeline_spec.c +@@ -2011,7 +2011,7 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, + if (err_line) + *err_line = 0; + if (err_msg) +- *err_msg = "Null pipeline arument."; ++ *err_msg = "Null pipeline argument."; + status = -EINVAL; + goto error; + } +diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c +index 6afd310e4e..25185a791c 100644 +--- a/lib/power/power_cppc_cpufreq.c ++++ b/lib/power/power_cppc_cpufreq.c +@@ -621,7 +621,7 @@ power_cppc_enable_turbo(unsigned int lcore_id) + return -1; + } + +- /* TODO: must set to max once enbling Turbo? Considering add condition: ++ /* TODO: must set to max once enabling Turbo? Considering add condition: + * if ((pi->turbo_available) && (pi->curr_idx <= 1)) + */ + /* Max may have changed, so call to max function */ +diff --git a/lib/regexdev/rte_regexdev.h b/lib/regexdev/rte_regexdev.h +index 86f0b231b0..0bac46cda9 100644 +--- a/lib/regexdev/rte_regexdev.h ++++ b/lib/regexdev/rte_regexdev.h +@@ -298,14 +298,14 @@ rte_regexdev_get_dev_id(const char *name); + * backtracking positions remembered by any tokens inside the group. + * Example RegEx is `a(?>bc|b)c` if the given patterns are `abc` and `abcc` then + * `a(bc|b)c` matches both where as `a(?>bc|b)c` matches only abcc because +- * atomic groups don't allow backtracing back to `b`. ++ * atomic groups don't allow backtracking back to `b`. + * + * @see struct rte_regexdev_info::regexdev_capa + */ + + #define RTE_REGEXDEV_SUPP_PCRE_BACKTRACKING_CTRL_F (1ULL << 3) + /**< RegEx device support PCRE backtracking control verbs. +- * Some examples of backtracing verbs are (*COMMIT), (*ACCEPT), (*FAIL), ++ * Some examples of backtracking verbs are (*COMMIT), (*ACCEPT), (*FAIL), + * (*SKIP), (*PRUNE). + * + * @see struct rte_regexdev_info::regexdev_capa +@@ -1015,7 +1015,7 @@ rte_regexdev_rule_db_update(uint8_t dev_id, + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Compile local rule set and burn the complied result to the +- * RegEx deive. ++ * RegEx device. + * + * @param dev_id + * RegEx device identifier. +diff --git a/lib/ring/rte_ring_core.h b/lib/ring/rte_ring_core.h +index 46ad584f9c..1252ca9546 100644 +--- a/lib/ring/rte_ring_core.h ++++ b/lib/ring/rte_ring_core.h +@@ -12,7 +12,7 @@ + + /** + * @file +- * This file contains definion of RTE ring structure itself, ++ * This file contains definition of RTE ring structure itself, + * init flags and some related macros. + * For majority of DPDK entities, it is not recommended to include + * this file directly, use include or +diff --git a/lib/sched/rte_pie.h b/lib/sched/rte_pie.h +index dfdf572311..02a987f54a 100644 +--- a/lib/sched/rte_pie.h ++++ b/lib/sched/rte_pie.h +@@ -252,7 +252,7 @@ _rte_pie_drop(const struct rte_pie_config *pie_cfg, + } + + /** +- * @brief Decides if new packet should be enqeued or dropped for non-empty queue ++ * @brief Decides if new packet should be enqueued or dropped for non-empty queue + * + * @param pie_cfg [in] config pointer to a PIE configuration parameter structure + * @param pie [in,out] data pointer to PIE runtime data +@@ -319,7 +319,7 @@ rte_pie_enqueue_nonempty(const struct rte_pie_config *pie_cfg, + } + + /** +- * @brief Decides if new packet should be enqeued or dropped ++ * @brief Decides if new packet should be enqueued or dropped + * Updates run time data and gives verdict whether to enqueue or drop the packet. + * + * @param pie_cfg [in] config pointer to a PIE configuration parameter structure +@@ -330,7 +330,7 @@ rte_pie_enqueue_nonempty(const struct rte_pie_config *pie_cfg, + * + * @return Operation status + * @retval 0 enqueue the packet +- * @retval 1 drop the packet based on drop probility criteria ++ * @retval 1 drop the packet based on drop probability criteria + */ + static inline int + __rte_experimental +diff --git a/lib/sched/rte_red.h b/lib/sched/rte_red.h +index 36273cac64..f5843dab1b 100644 +--- a/lib/sched/rte_red.h ++++ b/lib/sched/rte_red.h +@@ -303,7 +303,7 @@ __rte_red_drop(const struct rte_red_config *red_cfg, struct rte_red *red) + } + + /** +- * @brief Decides if new packet should be enqeued or dropped in queue non-empty case ++ * @brief Decides if new packet should be enqueued or dropped in queue non-empty case + * + * @param red_cfg [in] config pointer to a RED configuration parameter structure + * @param red [in,out] data pointer to RED runtime data +@@ -361,7 +361,7 @@ rte_red_enqueue_nonempty(const struct rte_red_config *red_cfg, + } + + /** +- * @brief Decides if new packet should be enqeued or dropped ++ * @brief Decides if new packet should be enqueued or dropped + * Updates run time data based on new queue size value. + * Based on new queue average and RED configuration parameters + * gives verdict whether to enqueue or drop the packet. +diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c +index ed44808f7b..62b3d2e315 100644 +--- a/lib/sched/rte_sched.c ++++ b/lib/sched/rte_sched.c +@@ -239,7 +239,7 @@ struct rte_sched_port { + int socket; + + /* Timing */ +- uint64_t time_cpu_cycles; /* Current CPU time measured in CPU cyles */ ++ uint64_t time_cpu_cycles; /* Current CPU time measured in CPU cycles */ + uint64_t time_cpu_bytes; /* Current CPU time measured in bytes */ + uint64_t time; /* Current NIC TX time measured in bytes */ + struct rte_reciprocal inv_cycles_per_byte; /* CPU cycles per byte */ +diff --git a/lib/sched/rte_sched.h b/lib/sched/rte_sched.h +index 484dbdcc3d..3c625ba169 100644 +--- a/lib/sched/rte_sched.h ++++ b/lib/sched/rte_sched.h +@@ -360,7 +360,7 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, + * + * Hierarchical scheduler subport bandwidth profile add + * Note that this function is safe to use in runtime for adding new +- * subport bandwidth profile as it doesn't have any impact on hiearchical ++ * subport bandwidth profile as it doesn't have any impact on hierarchical + * structure of the scheduler. + * @param port + * Handle to port scheduler instance +diff --git a/lib/table/rte_swx_table.h b/lib/table/rte_swx_table.h +index f93e5f3f95..c1383c2e57 100644 +--- a/lib/table/rte_swx_table.h ++++ b/lib/table/rte_swx_table.h +@@ -216,7 +216,7 @@ typedef int + * operations into the same table. + * + * The typical reason an implementation may choose to split the table lookup +- * operation into multiple steps is to hide the latency of the inherrent memory ++ * operation into multiple steps is to hide the latency of the inherent memory + * read operations: before a read operation with the source data likely not in + * the CPU cache, the source data prefetch is issued and the table lookup + * operation is postponed in favor of some other unrelated work, which the CPU +diff --git a/lib/table/rte_swx_table_selector.h b/lib/table/rte_swx_table_selector.h +index 62988d2856..05863cc90b 100644 +--- a/lib/table/rte_swx_table_selector.h ++++ b/lib/table/rte_swx_table_selector.h +@@ -155,7 +155,7 @@ rte_swx_table_selector_group_set(void *table, + * mechanism allows for multiple concurrent select operations into the same table. + * + * The typical reason an implementation may choose to split the operation into multiple steps is to +- * hide the latency of the inherrent memory read operations: before a read operation with the ++ * hide the latency of the inherent memory read operations: before a read operation with the + * source data likely not in the CPU cache, the source data prefetch is issued and the operation is + * postponed in favor of some other unrelated work, which the CPU executes in parallel with the + * source data being fetched into the CPU cache; later on, the operation is resumed, this time with +diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c +index a7483167d4..e5ccfe47f7 100644 +--- a/lib/telemetry/telemetry.c ++++ b/lib/telemetry/telemetry.c +@@ -534,7 +534,7 @@ telemetry_legacy_init(void) + } + rc = pthread_create(&t_old, NULL, socket_listener, &v1_socket); + if (rc != 0) { +- TMTY_LOG(ERR, "Error with create legcay socket thread: %s\n", ++ TMTY_LOG(ERR, "Error with create legacy socket thread: %s\n", + strerror(rc)); + close(v1_socket.sock); + v1_socket.sock = -1; +diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h +index f02a12f5b0..db70690274 100644 +--- a/lib/telemetry/telemetry_json.h ++++ b/lib/telemetry/telemetry_json.h +@@ -23,7 +23,7 @@ + /** + * @internal + * Copies a value into a buffer if the buffer has enough available space. +- * Nothing written to buffer if an overflow ocurs. ++ * Nothing written to buffer if an overflow occurs. + * This function is not for use for values larger than given buffer length. + */ + __rte_format_printf(3, 4) +diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c +index 550b0ee8b5..9b690dc81e 100644 +--- a/lib/vhost/vhost_user.c ++++ b/lib/vhost/vhost_user.c +@@ -1115,7 +1115,7 @@ vhost_user_postcopy_region_register(struct virtio_net *dev, + struct uffdio_register reg_struct; + + /* +- * Let's register all the mmap'ed area to ensure ++ * Let's register all the mmapped area to ensure + * alignment on page boundary. + */ + reg_struct.range.start = (uint64_t)(uintptr_t)reg->mmap_addr; +@@ -1177,7 +1177,7 @@ vhost_user_postcopy_register(struct virtio_net *dev, int main_fd, + msg->fd_num = 0; + send_vhost_reply(main_fd, msg); + +- /* Wait for qemu to acknolwedge it's got the addresses ++ /* Wait for qemu to acknowledge it got the addresses + * we've got to wait before we're allowed to generate faults. + */ + if (read_vhost_message(main_fd, &ack_msg) <= 0) { +-- +2.23.0 + diff --git a/0169-net-hns3-add-VLAN-filter-query-in-dump-file.patch b/0169-net-hns3-add-VLAN-filter-query-in-dump-file.patch new file mode 100644 index 0000000..ed99963 --- /dev/null +++ b/0169-net-hns3-add-VLAN-filter-query-in-dump-file.patch @@ -0,0 +1,158 @@ +From 11186d5e167f1b11c436f0ca550789e855d5292c Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Fri, 21 Oct 2022 15:36:45 +0800 +Subject: [PATCH 169/189] net/hns3: add VLAN filter query in dump file + +Add VLAN filter query in dump file. + +Signed-off-by: Dongdong Liu +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_dump.c | 80 +++++++++++++++++++++++++++++++----- + 1 file changed, 69 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index 1007b09bd2..8268506f6f 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -4,11 +4,10 @@ + + #include + +-#include "hns3_ethdev.h" + #include "hns3_common.h" +-#include "hns3_rxtx.h" +-#include "hns3_regs.h" + #include "hns3_logs.h" ++#include "hns3_regs.h" ++#include "hns3_rxtx.h" + #include "hns3_dump.h" + + #define HNS3_BD_DW_NUM 8 +@@ -394,11 +393,6 @@ hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev) + uint32_t nb_tx_queues; + uint32_t bitmap_size; + +- bitmap_size = (hw->tqps_num * sizeof(uint32_t) + HNS3_UINT32_BIT) / +- HNS3_UINT32_BIT; +- rx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0); +- tx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0); +- + nb_rx_queues = dev->data->nb_rx_queues; + nb_tx_queues = dev->data->nb_tx_queues; + if (nb_rx_queues == 0) { +@@ -410,6 +404,21 @@ hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev) + return; + } + ++ bitmap_size = (hw->tqps_num * sizeof(uint32_t) + HNS3_UINT32_BIT) / ++ HNS3_UINT32_BIT; ++ rx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0); ++ if (rx_queue_state == NULL) { ++ hns3_err(hw, "Failed to allocate memory for rx queue state!"); ++ return; ++ } ++ ++ tx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0); ++ if (tx_queue_state == NULL) { ++ hns3_err(hw, "Failed to allocate memory for tx queue state!"); ++ rte_free(rx_queue_state); ++ return; ++ } ++ + fprintf(file, "\t -- enable state:\n"); + hns3_get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true); + hns3_display_queue_enable_state(file, rx_queue_state, nb_rx_queues, +@@ -448,6 +457,51 @@ hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev) + hns3_get_rxtx_queue_enable_state(file, dev); + } + ++static int ++hns3_get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw) ++{ ++#define HNS3_FILTER_TYPE_VF 0 ++#define HNS3_FILTER_TYPE_PORT 1 ++#define HNS3_FILTER_FE_NIC_INGRESS_B BIT(0) ++#define HNS3_FILTER_FE_NIC_EGRESS_B BIT(1) ++ struct hns3_vlan_filter_ctrl_cmd *req; ++ struct hns3_cmd_desc desc; ++ uint8_t i; ++ int ret; ++ ++ static const uint32_t vlan_filter_type[] = { ++ HNS3_FILTER_TYPE_PORT, ++ HNS3_FILTER_TYPE_VF ++ }; ++ ++ for (i = 0; i < RTE_DIM(vlan_filter_type); i++) { ++ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_FILTER_CTRL, ++ true); ++ req = (struct hns3_vlan_filter_ctrl_cmd *)desc.data; ++ req->vlan_type = vlan_filter_type[i]; ++ req->vf_id = HNS3_PF_FUNC_ID; ++ ret = hns3_cmd_send(hw, &desc, 1); ++ if (ret != 0) { ++ hns3_err(hw, ++ "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!", ++ ret, 1, rte_le_to_cpu_16(desc.opcode)); ++ return ret; ++ } ++ fprintf(file, ++ "\t -- %s VLAN filter configuration\n" ++ "\t nic_ingress :%s\n" ++ "\t nic_egress :%s\n", ++ req->vlan_type == HNS3_FILTER_TYPE_PORT ? ++ "Port" : "VF", ++ req->vlan_fe & HNS3_FILTER_FE_NIC_INGRESS_B ? ++ "Enable" : "Disable", ++ req->vlan_fe & HNS3_FILTER_FE_NIC_EGRESS_B ? ++ "Enable" : "Disable"); ++ } ++ ++ return 0; ++} ++ + static int + hns3_get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw) + { +@@ -583,6 +637,10 @@ hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw) + int ret; + + fprintf(file, " - VLAN Config Info:\n"); ++ ret = hns3_get_vlan_filter_cfg(file, hw); ++ if (ret < 0) ++ return; ++ + ret = hns3_get_vlan_rx_offload_cfg(file, hw); + if (ret < 0) + return; +@@ -619,7 +677,7 @@ hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf) + return; + + fprintf(file, +- " port_node: \n" ++ " port_node:\n" + " node_id=%u reference_count=%u shaper_profile_id=%d\n", + conf->root->id, conf->root->reference_count, + conf->root->shaper_profile ? +@@ -637,7 +695,7 @@ hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf) + if (conf->nb_tc_node == 0) + return; + +- fprintf(file, " tc_node: \n"); ++ fprintf(file, " tc_node:\n"); + memset(tc_node, 0, sizeof(tc_node)); + TAILQ_FOREACH(tm_node, tc_list, node) { + tidx = hns3_tm_calc_node_tc_no(conf, tm_node->id); +@@ -705,7 +763,7 @@ hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, + return; + + fprintf(file, +- " queue_node: \n" ++ " queue_node:\n" + " tx queue id | mapped tc (8 mean node not exist)\n"); + + memset(queue_node, 0, sizeof(queue_node)); +-- +2.23.0 + diff --git a/0170-net-bonding-fix-array-overflow-in-Rx-burst.patch b/0170-net-bonding-fix-array-overflow-in-Rx-burst.patch new file mode 100644 index 0000000..fb901ba --- /dev/null +++ b/0170-net-bonding-fix-array-overflow-in-Rx-burst.patch @@ -0,0 +1,39 @@ +From a087560ab1d0e5920f77859f5a06245cc5d7bafe Mon Sep 17 00:00:00 2001 +From: Yunjian Wang +Date: Fri, 21 Oct 2022 15:36:46 +0800 +Subject: [PATCH 170/189] net/bonding: fix array overflow in Rx burst + +In bond_ethdev_rx_burst() function, we check the validity of the +'active_slave' as this code: +if (++active_slave == slave_count) + active_slave = 0; +However, the value of 'active_slave' maybe equal to 'slave_count', +when a slave is down. This is wrong and it can cause buffer overflow. +This patch fixes the issue by using '>=' instead of '=='. + +Fixes: e1110e977648 ("net/bonding: fix Rx slave fairness") +Cc: stable@dpdk.org + +Signed-off-by: Lei Ji +Signed-off-by: Yunjian Wang +Acked-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 09636321cd..828fb5f96d 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -82,7 +82,7 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) + bufs + num_rx_total, nb_pkts); + num_rx_total += num_rx_slave; + nb_pkts -= num_rx_slave; +- if (++active_slave == slave_count) ++ if (++active_slave >= slave_count) + active_slave = 0; + } + +-- +2.23.0 + diff --git a/0171-net-bonding-fix-double-slave-link-status-query.patch b/0171-net-bonding-fix-double-slave-link-status-query.patch new file mode 100644 index 0000000..4470d8d --- /dev/null +++ b/0171-net-bonding-fix-double-slave-link-status-query.patch @@ -0,0 +1,60 @@ +From 7ec0325f9c2bfe2ea961e66588f8ba9e22bb6483 Mon Sep 17 00:00:00 2001 +From: Yunjian Wang +Date: Fri, 21 Oct 2022 15:36:47 +0800 +Subject: [PATCH 171/189] net/bonding: fix double slave link status query + +When link status polling mode is used, the slave link status is +queried twice, which may be inconsistent. To fix this, we can keep +the latest queried link state. + +Fixes: a45b288ef21a ("bond: support link status polling") +Cc: stable@dpdk.org + +Signed-off-by: Yunjian Wang +Acked-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 828fb5f96d..3be2b08128 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -2400,9 +2400,6 @@ bond_ethdev_slave_link_status_change_monitor(void *cb_arg) + * event callback */ + if (slave_ethdev->data->dev_link.link_status != + internals->slaves[i].last_link_status) { +- internals->slaves[i].last_link_status = +- slave_ethdev->data->dev_link.link_status; +- + bond_ethdev_lsc_event_callback(internals->slaves[i].port_id, + RTE_ETH_EVENT_INTR_LSC, + &bonded_ethdev->data->port_id, +@@ -2901,7 +2898,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, + + uint8_t lsc_flag = 0; + int valid_slave = 0; +- uint16_t active_pos; ++ uint16_t active_pos, slave_idx; + uint16_t i; + + if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL) +@@ -2922,6 +2919,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, + for (i = 0; i < internals->slave_count; i++) { + if (internals->slaves[i].port_id == port_id) { + valid_slave = 1; ++ slave_idx = i; + break; + } + } +@@ -3010,6 +3008,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, + * slaves + */ + bond_ethdev_link_update(bonded_eth_dev, 0); ++ internals->slaves[slave_idx].last_link_status = link.link_status; + + if (lsc_flag) { + /* Cancel any possible outstanding interrupts if delays are enabled */ +-- +2.23.0 + diff --git a/0172-app-testpmd-fix-supported-RSS-offload-display.patch b/0172-app-testpmd-fix-supported-RSS-offload-display.patch new file mode 100644 index 0000000..26d4294 --- /dev/null +++ b/0172-app-testpmd-fix-supported-RSS-offload-display.patch @@ -0,0 +1,121 @@ +From 4ba54bf73c3f5038f03163d70e60d43e968878d5 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:48 +0800 +Subject: [PATCH 172/189] app/testpmd: fix supported RSS offload display + +The rte_eth_dev_info.flow_type_rss_offloads is populated in terms of +RTE_ETH_RSS_* bits. If PMD sets RTE_ETH_RSS_L3_SRC_ONLY to +dev_info->flow_type_rss_offloads. testpmd will display "user defined 63" +when run 'show port info 0'. Because testpmd use flowtype_to_str() +to display the supported RSS offload of PMD. In fact, the function is +used to display flow type in FDIR commands for i40e or ixgbe. This patch +uses the RTE_ETH_RSS_* bits to display supported RSS offload of PMD. + +Fixes: b12964f621dc ("ethdev: unification of RSS offload types") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Ferruh Yigit +--- + app/test-pmd/config.c | 40 ++++++++++++++++++++++++++-------------- + app/test-pmd/testpmd.h | 2 ++ + 2 files changed, 28 insertions(+), 14 deletions(-) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index a7fffc3d1d..2849ee7e7c 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -66,8 +66,6 @@ + + #define NS_PER_SEC 1E9 + +-static char *flowtype_to_str(uint16_t flow_type); +- + static const struct { + enum tx_pkt_split split; + const char *name; +@@ -674,6 +672,19 @@ print_dev_capabilities(uint64_t capabilities) + } + } + ++const char * ++rsstypes_to_str(uint64_t rss_type) ++{ ++ uint16_t i; ++ ++ for (i = 0; rss_type_table[i].str != NULL; i++) { ++ if (rss_type_table[i].rss_type == rss_type) ++ return rss_type_table[i].str; ++ } ++ ++ return NULL; ++} ++ + void + port_infos_display(portid_t port_id) + { +@@ -778,19 +789,20 @@ port_infos_display(portid_t port_id) + if (!dev_info.flow_type_rss_offloads) + printf("No RSS offload flow type is supported.\n"); + else { ++ uint64_t rss_offload_types = dev_info.flow_type_rss_offloads; + uint16_t i; +- char *p; + + printf("Supported RSS offload flow types:\n"); +- for (i = RTE_ETH_FLOW_UNKNOWN + 1; +- i < sizeof(dev_info.flow_type_rss_offloads) * CHAR_BIT; i++) { +- if (!(dev_info.flow_type_rss_offloads & (1ULL << i))) +- continue; +- p = flowtype_to_str(i); +- if (p) +- printf(" %s\n", p); +- else +- printf(" user defined %d\n", i); ++ for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) { ++ uint64_t rss_offload = RTE_BIT64(i); ++ if ((rss_offload_types & rss_offload) != 0) { ++ const char *p = rsstypes_to_str(rss_offload); ++ if (p) ++ printf(" %s\n", p); ++ else ++ printf(" user defined %u\n", ++ i); ++ } + } + } + +@@ -4811,6 +4823,8 @@ set_record_burst_stats(uint8_t on_off) + record_burst_stats = on_off; + } + ++#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) ++ + static char* + flowtype_to_str(uint16_t flow_type) + { +@@ -4854,8 +4868,6 @@ flowtype_to_str(uint16_t flow_type) + return NULL; + } + +-#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) +- + static inline void + print_fdir_mask(struct rte_eth_fdir_masks *mask) + { +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 569b4300cf..d6a775c485 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -1105,6 +1105,8 @@ extern int flow_parse(const char *src, void *result, unsigned int size, + struct rte_flow_item **pattern, + struct rte_flow_action **actions); + ++const char *rsstypes_to_str(uint64_t rss_type); ++ + /* + * Work-around of a compilation error with ICC on invocations of the + * rte_be_to_cpu_16() function. +-- +2.23.0 + diff --git a/0173-app-testpmd-unify-name-of-L2-payload-offload.patch b/0173-app-testpmd-unify-name-of-L2-payload-offload.patch new file mode 100644 index 0000000..383ce7d --- /dev/null +++ b/0173-app-testpmd-unify-name-of-L2-payload-offload.patch @@ -0,0 +1,71 @@ +From d1bfba3efc17445439ba794a63643a57b9b5be5a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:49 +0800 +Subject: [PATCH 173/189] app/testpmd: unify name of L2 payload offload + +Currently, the "port config all rss xx" command uses 'ether' name to match +and to set 'RTE_ETH_RSS_L2_PAYLOAD' offload. However, others RSS command, +such as, "port config rss-hash-key" and "show port +rss-hash key", use 'l2-payload' to represent this offload. So this patch +unifies the name of 'RTE_ETH_RSS_L2_PAYLOAD' offload. + +Signed-off-by: Huisong Li +Acked-by: Ferruh Yigit +--- + app/test-pmd/cmdline.c | 12 ++++++------ + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- + 2 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 26d95e64e0..c5e4c30c9f 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -793,8 +793,8 @@ static void cmd_help_long_parsed(void *parsed_result, + "receive buffers available.\n\n" + + "port config all rss (all|default|ip|tcp|udp|sctp|" +- "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|" +- "level-outer|level-inner|)\n" ++ "l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|" ++ "none|level-default|level-outer|level-inner|)\n" + " Set the RSS mode.\n\n" + + "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" +@@ -2187,7 +2187,7 @@ cmd_config_rss_parsed(void *parsed_result, + rss_conf.rss_hf = RTE_ETH_RSS_TCP; + else if (!strcmp(res->value, "sctp")) + rss_conf.rss_hf = RTE_ETH_RSS_SCTP; +- else if (!strcmp(res->value, "ether")) ++ else if (!strcmp(res->value, "l2_payload")) + rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD; + else if (!strcmp(res->value, "port")) + rss_conf.rss_hf = RTE_ETH_RSS_PORT; +@@ -2308,9 +2308,9 @@ cmdline_parse_inst_t cmd_config_rss = { + .f = cmd_config_rss_parsed, + .data = NULL, + .help_str = "port config all rss " +- "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" +- "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|" +- "level-outer|level-inner|ipv4-chksum|", ++ "all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|" ++ "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|" ++ "none|level-default|level-outer|level-inner|", + .tokens = { + (void *)&cmd_config_rss_port, + (void *)&cmd_config_rss_keyword, +diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +index 94792d88cc..b75adcce55 100644 +--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst ++++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +@@ -2285,7 +2285,7 @@ port config - RSS + + Set the RSS (Receive Side Scaling) mode on or off:: + +- testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none) ++ testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none) + + RSS is on by default. + +-- +2.23.0 + diff --git a/0174-app-testpmd-refactor-config-all-RSS-command.patch b/0174-app-testpmd-refactor-config-all-RSS-command.patch new file mode 100644 index 0000000..a7ee60a --- /dev/null +++ b/0174-app-testpmd-refactor-config-all-RSS-command.patch @@ -0,0 +1,251 @@ +From 860c15e4347ca38d50f4ce9d3f00e744f090e4e8 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:50 +0800 +Subject: [PATCH 174/189] app/testpmd: refactor config all RSS command + +The "port config rss-hash-key" and "show port +rss-hash key" commands both use the 'rss_type_table[]' to get +'rss_types' or the RSS type name. So this patch uses the +'rss_type_table[]' to get the RSS types. In this way, this command +naturally supports more individual types. + +Suggested-by: Ferruh Yigit +Signed-off-by: Huisong Li +Acked-by: Ferruh Yigit +--- + app/test-pmd/cmdline.c | 120 ++++++-------------- + app/test-pmd/config.c | 20 +++- + app/test-pmd/testpmd.h | 1 + + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 10 +- + 4 files changed, 58 insertions(+), 93 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index c5e4c30c9f..6cb095f965 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -792,9 +792,14 @@ static void cmd_help_long_parsed(void *parsed_result, + " Enable or disable packet drop on all RX queues of all ports when no " + "receive buffers available.\n\n" + +- "port config all rss (all|default|ip|tcp|udp|sctp|" +- "l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|" +- "none|level-default|level-outer|level-inner|)\n" ++ "port config all rss (all|default|level-default|level-outer|level-inner|" ++ "ip|tcp|udp|sctp|tunnel|vlan|none|" ++ "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" ++ "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" ++ "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|" ++ "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|" ++ "l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|" ++ "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|)\n" + " Set the RSS mode.\n\n" + + "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" +@@ -2169,79 +2174,7 @@ cmd_config_rss_parsed(void *parsed_result, + uint16_t i; + int ret; + +- if (!strcmp(res->value, "all")) +- rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP | +- RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP | +- RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP | +- RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU | +- RTE_ETH_RSS_ECPRI; +- else if (!strcmp(res->value, "eth")) +- rss_conf.rss_hf = RTE_ETH_RSS_ETH; +- else if (!strcmp(res->value, "vlan")) +- rss_conf.rss_hf = RTE_ETH_RSS_VLAN; +- else if (!strcmp(res->value, "ip")) +- rss_conf.rss_hf = RTE_ETH_RSS_IP; +- else if (!strcmp(res->value, "udp")) +- rss_conf.rss_hf = RTE_ETH_RSS_UDP; +- else if (!strcmp(res->value, "tcp")) +- rss_conf.rss_hf = RTE_ETH_RSS_TCP; +- else if (!strcmp(res->value, "sctp")) +- rss_conf.rss_hf = RTE_ETH_RSS_SCTP; +- else if (!strcmp(res->value, "l2_payload")) +- rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD; +- else if (!strcmp(res->value, "port")) +- rss_conf.rss_hf = RTE_ETH_RSS_PORT; +- else if (!strcmp(res->value, "vxlan")) +- rss_conf.rss_hf = RTE_ETH_RSS_VXLAN; +- else if (!strcmp(res->value, "geneve")) +- rss_conf.rss_hf = RTE_ETH_RSS_GENEVE; +- else if (!strcmp(res->value, "nvgre")) +- rss_conf.rss_hf = RTE_ETH_RSS_NVGRE; +- else if (!strcmp(res->value, "l3-pre32")) +- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; +- else if (!strcmp(res->value, "l3-pre40")) +- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; +- else if (!strcmp(res->value, "l3-pre48")) +- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; +- else if (!strcmp(res->value, "l3-pre56")) +- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; +- else if (!strcmp(res->value, "l3-pre64")) +- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; +- else if (!strcmp(res->value, "l3-pre96")) +- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; +- else if (!strcmp(res->value, "l3-src-only")) +- rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY; +- else if (!strcmp(res->value, "l3-dst-only")) +- rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY; +- else if (!strcmp(res->value, "l4-src-only")) +- rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY; +- else if (!strcmp(res->value, "l4-dst-only")) +- rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY; +- else if (!strcmp(res->value, "l2-src-only")) +- rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY; +- else if (!strcmp(res->value, "l2-dst-only")) +- rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY; +- else if (!strcmp(res->value, "l2tpv3")) +- rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3; +- else if (!strcmp(res->value, "esp")) +- rss_conf.rss_hf = RTE_ETH_RSS_ESP; +- else if (!strcmp(res->value, "ah")) +- rss_conf.rss_hf = RTE_ETH_RSS_AH; +- else if (!strcmp(res->value, "pfcp")) +- rss_conf.rss_hf = RTE_ETH_RSS_PFCP; +- else if (!strcmp(res->value, "pppoe")) +- rss_conf.rss_hf = RTE_ETH_RSS_PPPOE; +- else if (!strcmp(res->value, "gtpu")) +- rss_conf.rss_hf = RTE_ETH_RSS_GTPU; +- else if (!strcmp(res->value, "ecpri")) +- rss_conf.rss_hf = RTE_ETH_RSS_ECPRI; +- else if (!strcmp(res->value, "mpls")) +- rss_conf.rss_hf = RTE_ETH_RSS_MPLS; +- else if (!strcmp(res->value, "ipv4-chksum")) +- rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM; +- else if (!strcmp(res->value, "none")) +- rss_conf.rss_hf = 0; +- else if (!strcmp(res->value, "level-default")) { ++ if (!strcmp(res->value, "level-default")) { + rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK); + rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT); + } else if (!strcmp(res->value, "level-outer")) { +@@ -2250,14 +2183,24 @@ cmd_config_rss_parsed(void *parsed_result, + } else if (!strcmp(res->value, "level-inner")) { + rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK); + rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST); +- } else if (!strcmp(res->value, "default")) ++ } else if (!strcmp(res->value, "default")) { + use_default = 1; +- else if (isdigit(res->value[0]) && atoi(res->value) > 0 && +- atoi(res->value) < 64) +- rss_conf.rss_hf = 1ULL << atoi(res->value); +- else { +- fprintf(stderr, "Unknown parameter\n"); +- return; ++ } else if (isdigit(res->value[0])) { ++ int value = atoi(res->value); ++ if (value > 0 && value < 64) ++ rss_conf.rss_hf = 1ULL << (uint8_t)value; ++ else { ++ fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n"); ++ return; ++ } ++ } else if (!strcmp(res->value, "none")) { ++ rss_conf.rss_hf = 0; ++ } else { ++ rss_conf.rss_hf = str_to_rsstypes(res->value); ++ if (rss_conf.rss_hf == 0) { ++ fprintf(stderr, "Unknown parameter\n"); ++ return; ++ } + } + rss_conf.rss_key = NULL; + /* Update global configuration for RSS types. */ +@@ -2308,9 +2251,14 @@ cmdline_parse_inst_t cmd_config_rss = { + .f = cmd_config_rss_parsed, + .data = NULL, + .help_str = "port config all rss " +- "all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|" +- "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|" +- "none|level-default|level-outer|level-inner|", ++ "all|default|level-default|level-outer|level-inner|" ++ "ip|tcp|udp|sctp|tunnel|vlan|none|" ++ "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" ++ "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" ++ "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|" ++ "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|" ++ "l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|" ++ "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|", + .tokens = { + (void *)&cmd_config_rss_port, + (void *)&cmd_config_rss_keyword, +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index 2849ee7e7c..b08face76d 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -672,6 +672,19 @@ print_dev_capabilities(uint64_t capabilities) + } + } + ++uint64_t ++str_to_rsstypes(const char *str) ++{ ++ uint16_t i; ++ ++ for (i = 0; rss_type_table[i].str != NULL; i++) { ++ if (strcmp(rss_type_table[i].str, str) == 0) ++ return rss_type_table[i].rss_type; ++ } ++ ++ return 0; ++} ++ + const char * + rsstypes_to_str(uint64_t rss_type) + { +@@ -3063,15 +3076,10 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key, + { + struct rte_eth_rss_conf rss_conf; + int diag; +- unsigned int i; + + rss_conf.rss_key = NULL; + rss_conf.rss_key_len = 0; +- rss_conf.rss_hf = 0; +- for (i = 0; rss_type_table[i].str; i++) { +- if (!strcmp(rss_type_table[i].str, rss_type)) +- rss_conf.rss_hf = rss_type_table[i].rss_type; +- } ++ rss_conf.rss_hf = str_to_rsstypes(rss_type); + diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf); + if (diag == 0) { + rss_conf.rss_key = hash_key; +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index d6a775c485..e50188778b 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -1105,6 +1105,7 @@ extern int flow_parse(const char *src, void *result, unsigned int size, + struct rte_flow_item **pattern, + struct rte_flow_action **actions); + ++uint64_t str_to_rsstypes(const char *str); + const char *rsstypes_to_str(uint64_t rss_type); + + /* +diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +index b75adcce55..e15dc0c4c4 100644 +--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst ++++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +@@ -2285,7 +2285,15 @@ port config - RSS + + Set the RSS (Receive Side Scaling) mode on or off:: + +- testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none) ++ testpmd> port config all rss (all|default|level-default|level-outer|level-inner| \ ++ ip|tcp|udp|sctp|tunnel|vlan|none| \ ++ ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other| \ ++ ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp| \ ++ ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex| \ ++ l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan| \ ++ esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum| \ ++ l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32| \ ++ l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|) + + RSS is on by default. + +-- +2.23.0 + diff --git a/0175-app-testpmd-unify-RSS-types-display.patch b/0175-app-testpmd-unify-RSS-types-display.patch new file mode 100644 index 0000000..80c5273 --- /dev/null +++ b/0175-app-testpmd-unify-RSS-types-display.patch @@ -0,0 +1,76 @@ +From 6515c3f93ea7b5f5ef79f32ca7360b9edfc5e2ab Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:51 +0800 +Subject: [PATCH 175/189] app/testpmd: unify RSS types display + +The 'rss_type_table[]' maintains the name and value of RSS types. This +patch unifies a common interface to display RSS types. + +Signed-off-by: Huisong Li +Signed-off-by: Ferruh Yigit +--- + app/test-pmd/config.c | 34 ++++++++++++++++++++-------------- + 1 file changed, 20 insertions(+), 14 deletions(-) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index b08face76d..7b725fc7a1 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -1554,6 +1554,23 @@ port_flow_complain(struct rte_flow_error *error) + return -err; + } + ++static void ++rss_types_display(uint64_t rss_types) ++{ ++ uint16_t i; ++ ++ if (rss_types == 0) ++ return; ++ ++ for (i = 0; rss_type_table[i].str; i++) { ++ if (rss_type_table[i].rss_type == 0) ++ continue; ++ if ((rss_types & rss_type_table[i].rss_type) == ++ rss_type_table[i].rss_type) ++ printf(" %s", rss_type_table[i].str); ++ } ++} ++ + static void + rss_config_display(struct rte_flow_action_rss *rss_conf) + { +@@ -1596,13 +1613,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) + printf(" none\n"); + return; + } +- for (i = 0; rss_type_table[i].str; i++) { +- if ((rss_conf->types & +- rss_type_table[i].rss_type) == +- rss_type_table[i].rss_type && +- rss_type_table[i].rss_type != 0) +- printf(" %s\n", rss_type_table[i].str); +- } ++ rss_types_display(rss_conf->types); + } + + static struct port_indirect_action * +@@ -3054,13 +3065,8 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key) + printf("RSS disabled\n"); + return; + } +- printf("RSS functions:\n "); +- for (i = 0; rss_type_table[i].str; i++) { +- if (rss_type_table[i].rss_type == 0) +- continue; +- if ((rss_hf & rss_type_table[i].rss_type) == rss_type_table[i].rss_type) +- printf("%s ", rss_type_table[i].str); +- } ++ printf("RSS functions:\n"); ++ rss_types_display(rss_hf); + printf("\n"); + if (!show_rss_key) + return; +-- +2.23.0 + diff --git a/0176-app-testpmd-compact-RSS-types-output.patch b/0176-app-testpmd-compact-RSS-types-output.patch new file mode 100644 index 0000000..1f44146 --- /dev/null +++ b/0176-app-testpmd-compact-RSS-types-output.patch @@ -0,0 +1,165 @@ +From ce06141d60c64963a7dc02fbdd9b2229d38a6819 Mon Sep 17 00:00:00 2001 +From: Ferruh Yigit +Date: Fri, 21 Oct 2022 15:36:52 +0800 +Subject: [PATCH 176/189] app/testpmd: compact RSS types output + +In port info command output, 'show port info all', supported RSS offload +types printed one type per line, and although this information is not +most important part of the command it takes big part of the command +output. + +In port RSS hash and flow RSS command output, 'show port 0 rss-hash', +and 'flow query 0 0 rss', all enabled RSS types are printed on one line. +If there are many types, the print will be very long. + +Compacting these RSS offloads and types output by fixing the length of +the character string printed on each line, instead of one per line or +one line. +Output becomes as following: + +Supported RSS offload flow types: + ipv4-frag ipv4-tcp ipv4-udp ipv4-sctp ipv4-other + ipv6-frag ipv6-tcp ipv6-udp ipv6-sctp ipv6-other + l4-dst-only l4-src-only l3-dst-only l3-src-only + +Signed-off-by: Ferruh Yigit +Signed-off-by: Huisong Li +--- + app/test-pmd/config.c | 68 +++++++++++++++++++++++++++++++----------- + app/test-pmd/testpmd.h | 2 ++ + 2 files changed, 52 insertions(+), 18 deletions(-) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index 7b725fc7a1..873cca6f3e 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -698,6 +698,38 @@ rsstypes_to_str(uint64_t rss_type) + return NULL; + } + ++static void ++rss_offload_types_display(uint64_t offload_types, uint16_t char_num_per_line) ++{ ++ uint16_t user_defined_str_len; ++ uint16_t total_len = 0; ++ uint16_t str_len = 0; ++ uint64_t rss_offload; ++ uint16_t i; ++ ++ for (i = 0; i < sizeof(offload_types) * CHAR_BIT; i++) { ++ rss_offload = RTE_BIT64(i); ++ if ((offload_types & rss_offload) != 0) { ++ const char *p = rsstypes_to_str(rss_offload); ++ ++ user_defined_str_len = ++ strlen("user-defined-") + (i / 10 + 1); ++ str_len = p ? strlen(p) : user_defined_str_len; ++ str_len += 2; /* add two spaces */ ++ if (total_len + str_len >= char_num_per_line) { ++ total_len = 0; ++ printf("\n"); ++ } ++ ++ if (p) ++ printf(" %s", p); ++ else ++ printf(" user-defined-%u", i); ++ total_len += str_len; ++ } ++ } ++} ++ + void + port_infos_display(portid_t port_id) + { +@@ -802,21 +834,10 @@ port_infos_display(portid_t port_id) + if (!dev_info.flow_type_rss_offloads) + printf("No RSS offload flow type is supported.\n"); + else { +- uint64_t rss_offload_types = dev_info.flow_type_rss_offloads; +- uint16_t i; +- + printf("Supported RSS offload flow types:\n"); +- for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) { +- uint64_t rss_offload = RTE_BIT64(i); +- if ((rss_offload_types & rss_offload) != 0) { +- const char *p = rsstypes_to_str(rss_offload); +- if (p) +- printf(" %s\n", p); +- else +- printf(" user defined %u\n", +- i); +- } +- } ++ rss_offload_types_display(dev_info.flow_type_rss_offloads, ++ TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); ++ printf("\n"); + } + + printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize); +@@ -1555,8 +1576,10 @@ port_flow_complain(struct rte_flow_error *error) + } + + static void +-rss_types_display(uint64_t rss_types) ++rss_types_display(uint64_t rss_types, uint16_t char_num_per_line) + { ++ uint16_t total_len = 0; ++ uint16_t str_len; + uint16_t i; + + if (rss_types == 0) +@@ -1565,9 +1588,18 @@ rss_types_display(uint64_t rss_types) + for (i = 0; rss_type_table[i].str; i++) { + if (rss_type_table[i].rss_type == 0) + continue; ++ + if ((rss_types & rss_type_table[i].rss_type) == +- rss_type_table[i].rss_type) ++ rss_type_table[i].rss_type) { ++ /* Contain two spaces */ ++ str_len = strlen(rss_type_table[i].str) + 2; ++ if (total_len + str_len > char_num_per_line) { ++ printf("\n"); ++ total_len = 0; ++ } + printf(" %s", rss_type_table[i].str); ++ total_len += str_len; ++ } + } + } + +@@ -1613,7 +1645,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) + printf(" none\n"); + return; + } +- rss_types_display(rss_conf->types); ++ rss_types_display(rss_conf->types, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); + } + + static struct port_indirect_action * +@@ -3066,7 +3098,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key) + return; + } + printf("RSS functions:\n"); +- rss_types_display(rss_hf); ++ rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); + printf("\n"); + if (!show_rss_key) + return; +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index e50188778b..9c3a5d9bc5 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -105,6 +105,8 @@ struct pkt_burst_stats { + unsigned int pkt_burst_spread[MAX_PKT_BURST + 1]; + }; + ++ ++#define TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE 64 + /** Information for a given RSS type. */ + struct rss_type_info { + const char *str; /**< Type name. */ +-- +2.23.0 + diff --git a/0177-app-testpmd-reorder-RSS-type-table.patch b/0177-app-testpmd-reorder-RSS-type-table.patch new file mode 100644 index 0000000..863b080 --- /dev/null +++ b/0177-app-testpmd-reorder-RSS-type-table.patch @@ -0,0 +1,99 @@ +From 00a08212bf6e1c96e491353183d3db9ffbcf3463 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:53 +0800 +Subject: [PATCH 177/189] app/testpmd: reorder RSS type table + +There are group and individual types in rss_type_table[]. However, group +types are very scattered, and individual types are not arranged based on +the bit number order in 'RTE_ETH_RSS_xxx'. For a clear distribution of +types and better maintenance, this patch reorders this table. + +Signed-off-by: Huisong Li +Acked-by: Ferruh Yigit +--- + app/test-pmd/config.c | 47 +++++++++++++++++++++++-------------------- + 1 file changed, 25 insertions(+), 22 deletions(-) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index 873cca6f3e..f8cd135970 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -85,17 +85,20 @@ static const struct { + }; + + const struct rss_type_info rss_type_table[] = { ++ /* Group types */ + { "all", RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP | RTE_ETH_RSS_TCP | + RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP | RTE_ETH_RSS_L2_PAYLOAD | + RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP | RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | + RTE_ETH_RSS_GTPU | RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_MPLS}, + { "none", 0 }, +- { "eth", RTE_ETH_RSS_ETH }, +- { "l2-src-only", RTE_ETH_RSS_L2_SRC_ONLY }, +- { "l2-dst-only", RTE_ETH_RSS_L2_DST_ONLY }, ++ { "ip", RTE_ETH_RSS_IP }, ++ { "udp", RTE_ETH_RSS_UDP }, ++ { "tcp", RTE_ETH_RSS_TCP }, ++ { "sctp", RTE_ETH_RSS_SCTP }, ++ { "tunnel", RTE_ETH_RSS_TUNNEL }, + { "vlan", RTE_ETH_RSS_VLAN }, +- { "s-vlan", RTE_ETH_RSS_S_VLAN }, +- { "c-vlan", RTE_ETH_RSS_C_VLAN }, ++ ++ /* Individual type */ + { "ipv4", RTE_ETH_RSS_IPV4 }, + { "ipv4-frag", RTE_ETH_RSS_FRAG_IPV4 }, + { "ipv4-tcp", RTE_ETH_RSS_NONFRAG_IPV4_TCP }, +@@ -116,32 +119,32 @@ const struct rss_type_info rss_type_table[] = { + { "vxlan", RTE_ETH_RSS_VXLAN }, + { "geneve", RTE_ETH_RSS_GENEVE }, + { "nvgre", RTE_ETH_RSS_NVGRE }, +- { "ip", RTE_ETH_RSS_IP }, +- { "udp", RTE_ETH_RSS_UDP }, +- { "tcp", RTE_ETH_RSS_TCP }, +- { "sctp", RTE_ETH_RSS_SCTP }, +- { "tunnel", RTE_ETH_RSS_TUNNEL }, +- { "l3-pre32", RTE_ETH_RSS_L3_PRE32 }, +- { "l3-pre40", RTE_ETH_RSS_L3_PRE40 }, +- { "l3-pre48", RTE_ETH_RSS_L3_PRE48 }, +- { "l3-pre56", RTE_ETH_RSS_L3_PRE56 }, +- { "l3-pre64", RTE_ETH_RSS_L3_PRE64 }, +- { "l3-pre96", RTE_ETH_RSS_L3_PRE96 }, +- { "l3-src-only", RTE_ETH_RSS_L3_SRC_ONLY }, +- { "l3-dst-only", RTE_ETH_RSS_L3_DST_ONLY }, +- { "l4-src-only", RTE_ETH_RSS_L4_SRC_ONLY }, +- { "l4-dst-only", RTE_ETH_RSS_L4_DST_ONLY }, ++ { "gtpu", RTE_ETH_RSS_GTPU }, ++ { "eth", RTE_ETH_RSS_ETH }, ++ { "s-vlan", RTE_ETH_RSS_S_VLAN }, ++ { "c-vlan", RTE_ETH_RSS_C_VLAN }, + { "esp", RTE_ETH_RSS_ESP }, + { "ah", RTE_ETH_RSS_AH }, + { "l2tpv3", RTE_ETH_RSS_L2TPV3 }, + { "pfcp", RTE_ETH_RSS_PFCP }, + { "pppoe", RTE_ETH_RSS_PPPOE }, +- { "gtpu", RTE_ETH_RSS_GTPU }, + { "ecpri", RTE_ETH_RSS_ECPRI }, + { "mpls", RTE_ETH_RSS_MPLS }, + { "ipv4-chksum", RTE_ETH_RSS_IPV4_CHKSUM }, + { "l4-chksum", RTE_ETH_RSS_L4_CHKSUM }, +- { NULL, 0 }, ++ { "l3-pre96", RTE_ETH_RSS_L3_PRE96 }, ++ { "l3-pre64", RTE_ETH_RSS_L3_PRE64 }, ++ { "l3-pre56", RTE_ETH_RSS_L3_PRE56 }, ++ { "l3-pre48", RTE_ETH_RSS_L3_PRE48 }, ++ { "l3-pre40", RTE_ETH_RSS_L3_PRE40 }, ++ { "l3-pre32", RTE_ETH_RSS_L3_PRE32 }, ++ { "l2-dst-only", RTE_ETH_RSS_L2_DST_ONLY }, ++ { "l2-src-only", RTE_ETH_RSS_L2_SRC_ONLY }, ++ { "l4-dst-only", RTE_ETH_RSS_L4_DST_ONLY }, ++ { "l4-src-only", RTE_ETH_RSS_L4_SRC_ONLY }, ++ { "l3-dst-only", RTE_ETH_RSS_L3_DST_ONLY }, ++ { "l3-src-only", RTE_ETH_RSS_L3_SRC_ONLY }, ++ { NULL, 0}, + }; + + static const struct { +-- +2.23.0 + diff --git a/0178-app-testpmd-fix-RSS-types-display.patch b/0178-app-testpmd-fix-RSS-types-display.patch new file mode 100644 index 0000000..e296b43 --- /dev/null +++ b/0178-app-testpmd-fix-RSS-types-display.patch @@ -0,0 +1,61 @@ +From 34d8e6bf37155488c61029cf392255dd18ed0a87 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 21 Oct 2022 15:36:54 +0800 +Subject: [PATCH 178/189] app/testpmd: fix RSS types display + +Now testpmd fails to display types when query RSS rule. The failure is +because the '\n' character is missing at the end of the function +'rss_config_display()'. +Actually, all places calling 'xxx_types_display()' need to '\n'. So this +patch moves '\n' to the inside of these function. + +Bugzilla ID: 1048 +Fixes: 534988c490f1 ("app/testpmd: unify RSS types display") +Fixes: 44a37f3cffe0 ("app/testpmd: compact RSS types output") + +Signed-off-by: Huisong Li +Tested-by: Weiyuan Li +Reviewed-by: Ferruh Yigit +--- + app/test-pmd/config.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index f8cd135970..12386c4d82 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -731,6 +731,7 @@ rss_offload_types_display(uint64_t offload_types, uint16_t char_num_per_line) + total_len += str_len; + } + } ++ printf("\n"); + } + + void +@@ -840,7 +841,6 @@ port_infos_display(portid_t port_id) + printf("Supported RSS offload flow types:\n"); + rss_offload_types_display(dev_info.flow_type_rss_offloads, + TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); +- printf("\n"); + } + + printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize); +@@ -1604,6 +1604,7 @@ rss_types_display(uint64_t rss_types, uint16_t char_num_per_line) + total_len += str_len; + } + } ++ printf("\n"); + } + + static void +@@ -3102,7 +3103,6 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key) + } + printf("RSS functions:\n"); + rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); +- printf("\n"); + if (!show_rss_key) + return; + printf("RSS key:\n"); +-- +2.23.0 + diff --git a/0179-ethdev-support-telemetry-private-dump.patch b/0179-ethdev-support-telemetry-private-dump.patch new file mode 100644 index 0000000..92cc946 --- /dev/null +++ b/0179-ethdev-support-telemetry-private-dump.patch @@ -0,0 +1,91 @@ +From 9de9c8f454d4d1d87105700f626568f5f59e6985 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:55 +0800 +Subject: [PATCH 179/189] ethdev: support telemetry private dump +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This patch supports telemetry private dump a ethdev port. + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +--- + lib/ethdev/rte_ethdev.c | 47 +++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 47 insertions(+) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index b95f501b51..df5a627cbe 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -7,6 +7,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -6272,6 +6273,48 @@ eth_dev_handle_port_xstats(const char *cmd __rte_unused, + return 0; + } + ++#ifndef RTE_EXEC_ENV_WINDOWS ++static int ++eth_dev_handle_port_dump_priv(const char *cmd __rte_unused, ++ const char *params, ++ struct rte_tel_data *d) ++{ ++ char *buf, *end_param; ++ int port_id, ret; ++ FILE *f; ++ ++ if (params == NULL || strlen(params) == 0 || !isdigit(*params)) ++ return -EINVAL; ++ ++ port_id = strtoul(params, &end_param, 0); ++ if (*end_param != '\0') ++ RTE_ETHDEV_LOG(NOTICE, ++ "Extra parameters passed to ethdev telemetry command, ignoring"); ++ if (!rte_eth_dev_is_valid_port(port_id)) ++ return -EINVAL; ++ ++ buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN); ++ if (buf == NULL) ++ return -ENOMEM; ++ ++ f = fmemopen(buf, RTE_TEL_MAX_SINGLE_STRING_LEN - 1, "w+"); ++ if (f == NULL) { ++ free(buf); ++ return -EINVAL; ++ } ++ ++ ret = rte_eth_dev_priv_dump(port_id, f); ++ fclose(f); ++ if (ret == 0) { ++ rte_tel_data_start_dict(d); ++ rte_tel_data_string(d, buf); ++ } ++ ++ free(buf); ++ return 0; ++} ++#endif /* !RTE_EXEC_ENV_WINDOWS */ ++ + static int + eth_dev_handle_port_link_status(const char *cmd __rte_unused, + const char *params, +@@ -6571,6 +6614,10 @@ RTE_INIT(ethdev_init_telemetry) + "Returns the common stats for a port. Parameters: int port_id"); + rte_telemetry_register_cmd("/ethdev/xstats", eth_dev_handle_port_xstats, + "Returns the extended stats for a port. Parameters: int port_id"); ++#ifndef RTE_EXEC_ENV_WINDOWS ++ rte_telemetry_register_cmd("/ethdev/dump_priv", eth_dev_handle_port_dump_priv, ++ "Returns dump private information for a port. Parameters: int port_id"); ++#endif + rte_telemetry_register_cmd("/ethdev/link_status", + eth_dev_handle_port_link_status, + "Returns the link status for a port. Parameters: int port_id"); +-- +2.23.0 + diff --git a/0180-dmadev-add-telemetry.patch b/0180-dmadev-add-telemetry.patch new file mode 100644 index 0000000..d445f54 --- /dev/null +++ b/0180-dmadev-add-telemetry.patch @@ -0,0 +1,224 @@ +From ab11b7f71865aaab19e2a59e877bc70dfbc317b0 Mon Sep 17 00:00:00 2001 +From: Sean Morrissey +Date: Fri, 21 Oct 2022 15:36:56 +0800 +Subject: [PATCH 180/189] dmadev: add telemetry + +Telemetry commands are now registered through the dmadev library +for the gathering of DSA stats. The corresponding callback +functions for listing dmadevs and providing info and stats for a + +An example usage can be seen below: +Connecting to /var/run/dpdk/rte/dpdk_telemetry.v2 +{"version": "DPDK 22.03.0-rc2", "pid": 2956551, "max_output_len": 16384} +Connected to application: "dpdk-dma" +--> / +{"/": ["/", "/dmadev/info", "/dmadev/list", "/dmadev/stats", ...]} +--> /dmadev/list +{"/dmadev/info": {"name": "0000:00:01.0", "nb_vchans": 1, "numa_node": 0, +"max_vchans": 1, "max_desc": 4096, "min_desc": 32, "max_sges": 0, +"capabilities": {"mem2mem": 1, "mem2dev": 0, "dev2mem": 0, ...}}} +--> /dmadev/stats,0,0 +{"/dmadev/stats": {"submitted": 0, "completed": 0, "errors": 0}} + +Signed-off-by: Sean Morrissey +Reviewed-by: Bruce Richardson +Reviewed-by: Conor Walsh +Tested-by: Sunil Pai G +Tested-by: Kevin Laatz +Acked-by: Chengwen Feng +--- + doc/guides/prog_guide/dmadev.rst | 24 ++++++ + lib/dmadev/meson.build | 2 + + lib/dmadev/rte_dmadev.c | 130 +++++++++++++++++++++++++++++++ + 3 files changed, 156 insertions(+) + +diff --git a/doc/guides/prog_guide/dmadev.rst b/doc/guides/prog_guide/dmadev.rst +index 77863f8028..2aa26d33b8 100644 +--- a/doc/guides/prog_guide/dmadev.rst ++++ b/doc/guides/prog_guide/dmadev.rst +@@ -118,3 +118,27 @@ i.e. ``rte_dma_stats_get()``. The statistics returned for each device instance a + * ``submitted``: The number of operations submitted to the device. + * ``completed``: The number of operations which have completed (successful and failed). + * ``errors``: The number of operations that completed with error. ++ ++The dmadev library has support for displaying DMA device information ++through the Telemetry interface. Telemetry commands that can be used ++are shown below. ++ ++#. Get the list of available DMA devices by ID:: ++ ++ --> /dmadev/list ++ {"/dmadev/list": [0, 1]} ++ ++#. Get general information from a DMA device by passing the device id as a parameter:: ++ ++ --> /dmadev/info,0 ++ {"/dmadev/info": {"name": "0000:00:01.0", "nb_vchans": 1, "numa_node": 0, "max_vchans": 1, "max_desc": 4096, ++ "min_desc": 32, "max_sges": 0, "capabilities": {"mem2mem": 1, "mem2dev": 0, "dev2mem": 0, ...}}} ++ ++#. Get the statistics for a particular DMA device and virtual DMA channel by passing the device id and vchan id as parameters ++ (if a DMA device only has one virtual DMA channel you only need to pass the device id):: ++ ++ --> /dmadev/stats,0,0 ++ {"/dmadev/stats": {"submitted": 0, "completed": 0, "errors": 0}} ++ ++For more information on how to use the Telemetry interface, see ++the :doc:`../howto/telemetry`. +diff --git a/lib/dmadev/meson.build b/lib/dmadev/meson.build +index d2fc85e8c7..2f17587b75 100644 +--- a/lib/dmadev/meson.build ++++ b/lib/dmadev/meson.build +@@ -5,3 +5,5 @@ sources = files('rte_dmadev.c') + headers = files('rte_dmadev.h') + indirect_headers += files('rte_dmadev_core.h') + driver_sdk_headers += files('rte_dmadev_pmd.h') ++ ++deps += ['telemetry'] +diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c +index d4b32b2971..174d4c40ae 100644 +--- a/lib/dmadev/rte_dmadev.c ++++ b/lib/dmadev/rte_dmadev.c +@@ -11,6 +11,7 @@ + #include + #include + #include ++#include + + #include "rte_dmadev.h" + #include "rte_dmadev_pmd.h" +@@ -864,3 +865,132 @@ dma_fp_object_dummy(struct rte_dma_fp_object *obj) + obj->completed_status = dummy_completed_status; + obj->burst_capacity = dummy_burst_capacity; + } ++ ++static int ++dmadev_handle_dev_list(const char *cmd __rte_unused, ++ const char *params __rte_unused, ++ struct rte_tel_data *d) ++{ ++ int dev_id; ++ ++ rte_tel_data_start_array(d, RTE_TEL_INT_VAL); ++ for (dev_id = 0; dev_id < dma_devices_max; dev_id++) ++ if (rte_dma_is_valid(dev_id)) ++ rte_tel_data_add_array_int(d, dev_id); ++ ++ return 0; ++} ++ ++#define ADD_CAPA(td, dc, c) rte_tel_data_add_dict_int(td, dma_capability_name(c), !!(dc & c)) ++ ++static int ++dmadev_handle_dev_info(const char *cmd __rte_unused, ++ const char *params, struct rte_tel_data *d) ++{ ++ struct rte_dma_info dma_info; ++ struct rte_tel_data *dma_caps; ++ int dev_id, ret; ++ uint64_t dev_capa; ++ char *end_param; ++ ++ if (params == NULL || strlen(params) == 0 || !isdigit(*params)) ++ return -EINVAL; ++ ++ dev_id = strtoul(params, &end_param, 0); ++ if (*end_param != '\0') ++ RTE_DMA_LOG(WARNING, "Extra parameters passed to dmadev telemetry command, ignoring"); ++ ++ /* Function info_get validates dev_id so we don't need to. */ ++ ret = rte_dma_info_get(dev_id, &dma_info); ++ if (ret < 0) ++ return -EINVAL; ++ dev_capa = dma_info.dev_capa; ++ ++ rte_tel_data_start_dict(d); ++ rte_tel_data_add_dict_string(d, "name", dma_info.dev_name); ++ rte_tel_data_add_dict_int(d, "nb_vchans", dma_info.nb_vchans); ++ rte_tel_data_add_dict_int(d, "numa_node", dma_info.numa_node); ++ rte_tel_data_add_dict_int(d, "max_vchans", dma_info.max_vchans); ++ rte_tel_data_add_dict_int(d, "max_desc", dma_info.max_desc); ++ rte_tel_data_add_dict_int(d, "min_desc", dma_info.min_desc); ++ rte_tel_data_add_dict_int(d, "max_sges", dma_info.max_sges); ++ ++ dma_caps = rte_tel_data_alloc(); ++ if (!dma_caps) ++ return -ENOMEM; ++ ++ rte_tel_data_start_dict(dma_caps); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_MEM_TO_MEM); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_MEM_TO_DEV); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_DEV_TO_MEM); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_DEV_TO_DEV); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_SVA); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_SILENT); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_HANDLES_ERRORS); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_OPS_COPY); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_OPS_COPY_SG); ++ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_OPS_FILL); ++ rte_tel_data_add_dict_container(d, "capabilities", dma_caps, 0); ++ ++ return 0; ++} ++ ++#define ADD_DICT_STAT(s) rte_tel_data_add_dict_u64(d, #s, dma_stats.s) ++ ++static int ++dmadev_handle_dev_stats(const char *cmd __rte_unused, ++ const char *params, ++ struct rte_tel_data *d) ++{ ++ struct rte_dma_info dma_info; ++ struct rte_dma_stats dma_stats; ++ int dev_id, ret, vchan_id; ++ char *end_param; ++ const char *vchan_param; ++ ++ if (params == NULL || strlen(params) == 0 || !isdigit(*params)) ++ return -EINVAL; ++ ++ dev_id = strtoul(params, &end_param, 0); ++ ++ /* Function info_get validates dev_id so we don't need to. */ ++ ret = rte_dma_info_get(dev_id, &dma_info); ++ if (ret < 0) ++ return -EINVAL; ++ ++ /* If the device has one vchan the user does not need to supply the ++ * vchan id and only the device id is needed, no extra parameters. ++ */ ++ if (dma_info.nb_vchans == 1 && *end_param == '\0') ++ vchan_id = 0; ++ else { ++ vchan_param = strtok(end_param, ","); ++ if (!vchan_param || strlen(vchan_param) == 0 || !isdigit(*vchan_param)) ++ return -EINVAL; ++ ++ vchan_id = strtoul(vchan_param, &end_param, 0); ++ } ++ if (*end_param != '\0') ++ RTE_DMA_LOG(WARNING, "Extra parameters passed to dmadev telemetry command, ignoring"); ++ ++ ret = rte_dma_stats_get(dev_id, vchan_id, &dma_stats); ++ if (ret < 0) ++ return -EINVAL; ++ ++ rte_tel_data_start_dict(d); ++ ADD_DICT_STAT(submitted); ++ ADD_DICT_STAT(completed); ++ ADD_DICT_STAT(errors); ++ ++ return 0; ++} ++ ++RTE_INIT(dmadev_init_telemetry) ++{ ++ rte_telemetry_register_cmd("/dmadev/list", dmadev_handle_dev_list, ++ "Returns list of available dmadev devices by IDs. No parameters."); ++ rte_telemetry_register_cmd("/dmadev/info", dmadev_handle_dev_info, ++ "Returns information for a dmadev. Parameters: int dev_id"); ++ rte_telemetry_register_cmd("/dmadev/stats", dmadev_handle_dev_stats, ++ "Returns the stats for a dmadev vchannel. Parameters: int dev_id, vchan_id (Optional if only one vchannel)"); ++} +-- +2.23.0 + diff --git a/0181-dmadev-support-telemetry-dump-dmadev.patch b/0181-dmadev-support-telemetry-dump-dmadev.patch new file mode 100644 index 0000000..cf85684 --- /dev/null +++ b/0181-dmadev-support-telemetry-dump-dmadev.patch @@ -0,0 +1,78 @@ +From a36114ed036f8c4976dfe3d47f0ee29c9f214fc5 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Oct 2022 15:36:57 +0800 +Subject: [PATCH 181/189] dmadev: support telemetry dump dmadev +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This patch supports telemetry dump dmadev. + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +--- + lib/dmadev/rte_dmadev.c | 43 +++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 43 insertions(+) + +diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c +index 174d4c40ae..ea1cb815b4 100644 +--- a/lib/dmadev/rte_dmadev.c ++++ b/lib/dmadev/rte_dmadev.c +@@ -985,6 +985,45 @@ dmadev_handle_dev_stats(const char *cmd __rte_unused, + return 0; + } + ++#ifndef RTE_EXEC_ENV_WINDOWS ++static int ++dmadev_handle_dev_dump(const char *cmd __rte_unused, ++ const char *params, ++ struct rte_tel_data *d) ++{ ++ char *buf, *end_param; ++ int dev_id, ret; ++ FILE *f; ++ ++ if (params == NULL || strlen(params) == 0 || !isdigit(*params)) ++ return -EINVAL; ++ ++ dev_id = strtoul(params, &end_param, 0); ++ if (*end_param != '\0') ++ RTE_DMA_LOG(WARNING, "Extra parameters passed to dmadev telemetry command, ignoring"); ++ ++ buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN); ++ if (buf == NULL) ++ return -ENOMEM; ++ ++ f = fmemopen(buf, RTE_TEL_MAX_SINGLE_STRING_LEN - 1, "w+"); ++ if (f == NULL) { ++ free(buf); ++ return -EINVAL; ++ } ++ ++ ret = rte_dma_dump(dev_id, f); ++ fclose(f); ++ if (ret == 0) { ++ rte_tel_data_start_dict(d); ++ rte_tel_data_string(d, buf); ++ } ++ ++ free(buf); ++ return ret; ++} ++#endif /* !RTE_EXEC_ENV_WINDOWS */ ++ + RTE_INIT(dmadev_init_telemetry) + { + rte_telemetry_register_cmd("/dmadev/list", dmadev_handle_dev_list, +@@ -993,4 +1032,8 @@ RTE_INIT(dmadev_init_telemetry) + "Returns information for a dmadev. Parameters: int dev_id"); + rte_telemetry_register_cmd("/dmadev/stats", dmadev_handle_dev_stats, + "Returns the stats for a dmadev vchannel. Parameters: int dev_id, vchan_id (Optional if only one vchannel)"); ++#ifndef RTE_EXEC_ENV_WINDOWS ++ rte_telemetry_register_cmd("/dmadev/dump", dmadev_handle_dev_dump, ++ "Returns dump information for a dmadev. Parameters: int dev_id"); ++#endif + } +-- +2.23.0 + diff --git a/0182-telemetry-add-missing-C-guards.patch b/0182-telemetry-add-missing-C-guards.patch new file mode 100644 index 0000000..5fa53d2 --- /dev/null +++ b/0182-telemetry-add-missing-C-guards.patch @@ -0,0 +1,45 @@ +From dcccc81ecd1f1a0a24ba361d474ef81c9691fd14 Mon Sep 17 00:00:00 2001 +From: Brian Dooley +Date: Fri, 21 Oct 2022 15:36:58 +0800 +Subject: [PATCH 182/189] telemetry: add missing C++ guards + +Some public header files were missing 'extern "C"' C++ guards, +and couldn't be used by C++ applications. Add the missing guards. + +Fixes: 8877ac688b52 ("telemetry: introduce infrastructure") +Cc: stable@dpdk.org + +Signed-off-by: Brian Dooley +Acked-by: Bruce Richardson +Acked-by: Tyler Retzlaff +--- + lib/telemetry/rte_telemetry.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h +index 7bca8a9a49..3372b32f38 100644 +--- a/lib/telemetry/rte_telemetry.h ++++ b/lib/telemetry/rte_telemetry.h +@@ -9,6 +9,10 @@ + #ifndef _RTE_TELEMETRY_H_ + #define _RTE_TELEMETRY_H_ + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ + /** Maximum length for string used in object. */ + #define RTE_TEL_MAX_STRING_LEN 128 + /** Maximum length of string. */ +@@ -294,4 +298,8 @@ rte_tel_data_alloc(void); + void + rte_tel_data_free(struct rte_tel_data *data); + ++#ifdef __cplusplus ++} ++#endif ++ + #endif +-- +2.23.0 + diff --git a/0183-telemetry-limit-characters-allowed-in-dictionary-nam.patch b/0183-telemetry-limit-characters-allowed-in-dictionary-nam.patch new file mode 100644 index 0000000..07df7a5 --- /dev/null +++ b/0183-telemetry-limit-characters-allowed-in-dictionary-nam.patch @@ -0,0 +1,146 @@ +From 926dc7ff064ee81e6b9732247ddb7785a4ab98b8 Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 21 Oct 2022 15:36:59 +0800 +Subject: [PATCH 183/189] telemetry: limit characters allowed in dictionary names + +To save issues with encoding the names of values in dicts, we limit the +allowed names to a subset of character values. This list of allowed +characters can be expanded as necessary in future. + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng + +--- + lib/telemetry/rte_telemetry.h | 8 ++++++++ + lib/telemetry/telemetry_data.c | 31 +++++++++++++++++++++++++++++++ + 2 files changed, 39 insertions(+) + +diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h +index 3372b32f38..fadea48cb9 100644 +--- a/lib/telemetry/rte_telemetry.h ++++ b/lib/telemetry/rte_telemetry.h +@@ -64,6 +64,10 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type); + /** + * Start a dictionary of values for returning from a callback + * ++ * Dictionaries consist of key-values pairs to be returned, where the keys, ++ * or names, are strings and the values can be any of the types supported by telemetry. ++ * Name strings may only contain alphanumeric characters as well as '_' or '/' ++ * + * @param d + * The data structure passed to the callback + * @return +@@ -159,6 +163,7 @@ rte_tel_data_add_array_container(struct rte_tel_data *d, + * The data structure passed to the callback + * @param name + * The name the value is to be stored under in the dict ++ * Must contain only alphanumeric characters or the symbols: '_' or '/' + * @param val + * The string to be stored in the dict + * @return +@@ -177,6 +182,7 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name, + * The data structure passed to the callback + * @param name + * The name the value is to be stored under in the dict ++ * Must contain only alphanumeric characters or the symbols: '_' or '/' + * @param val + * The number to be stored in the dict + * @return +@@ -193,6 +199,7 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val); + * The data structure passed to the callback + * @param name + * The name the value is to be stored under in the dict ++ * Must contain only alphanumeric characters or the symbols: '_' or '/' + * @param val + * The number to be stored in the dict + * @return +@@ -212,6 +219,7 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d, + * The data structure passed to the callback + * @param name + * The name the value is to be stored under in the dict. ++ * Must contain only alphanumeric characters or the symbols: '_' or '/' + * @param val + * The pointer to the container to be stored in the dict. + * @param keep +diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c +index e14ae3c4d4..be46054c29 100644 +--- a/lib/telemetry/telemetry_data.c ++++ b/lib/telemetry/telemetry_data.c +@@ -3,6 +3,7 @@ + */ + + #undef RTE_USE_LIBBSD ++#include + #include + + #include "telemetry_data.h" +@@ -92,6 +93,24 @@ rte_tel_data_add_array_container(struct rte_tel_data *d, + return 0; + } + ++static bool ++valid_name(const char *name) ++{ ++ char allowed[128] = { ++ ['0' ... '9'] = 1, ++ ['A' ... 'Z'] = 1, ++ ['a' ... 'z'] = 1, ++ ['_'] = 1, ++ ['/'] = 1, ++ }; ++ while (*name != '\0') { ++ if ((size_t)*name >= RTE_DIM(allowed) || allowed[(int)*name] == 0) ++ return false; ++ name++; ++ } ++ return true; ++} ++ + int + rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name, + const char *val) +@@ -104,6 +123,9 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name, + if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES) + return -ENOSPC; + ++ if (!valid_name(name)) ++ return -EINVAL; ++ + d->data_len++; + e->type = RTE_TEL_STRING_VAL; + vbytes = strlcpy(e->value.sval, val, RTE_TEL_MAX_STRING_LEN); +@@ -123,6 +145,9 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val) + if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES) + return -ENOSPC; + ++ if (!valid_name(name)) ++ return -EINVAL; ++ + d->data_len++; + e->type = RTE_TEL_INT_VAL; + e->value.ival = val; +@@ -140,6 +165,9 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d, + if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES) + return -ENOSPC; + ++ if (!valid_name(name)) ++ return -EINVAL; ++ + d->data_len++; + e->type = RTE_TEL_U64_VAL; + e->value.u64val = val; +@@ -161,6 +189,9 @@ rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name, + if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES) + return -ENOSPC; + ++ if (!valid_name(name)) ++ return -EINVAL; ++ + d->data_len++; + e->type = RTE_TEL_CONTAINER; + e->value.container.data = val; +-- +2.23.0 + diff --git a/0184-telemetry-fix-escaping-of-invalid-json-characters.patch b/0184-telemetry-fix-escaping-of-invalid-json-characters.patch new file mode 100644 index 0000000..9f32e8c --- /dev/null +++ b/0184-telemetry-fix-escaping-of-invalid-json-characters.patch @@ -0,0 +1,122 @@ +From bdedf8a96e0782e98291e219ed7b74cb7b04fc9c Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 21 Oct 2022 15:37:00 +0800 +Subject: [PATCH 184/189] telemetry: fix escaping of invalid json characters +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +For string values returned from telemetry, escape any values that cannot +normally appear in a json string. According to the json spec[1], the +characters than need to be handled are control chars (char value < 0x20) +and '"' and '\' characters. + +To handle this, we replace the snprintf call with a separate string +copying and encapsulation routine which checks each character as it +copies it to the final array. + +[1] https://www.rfc-editor.org/rfc/rfc8259.txt + +Bugzilla ID: 1037 +Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality") + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/telemetry/telemetry.c | 11 +++++--- + lib/telemetry/telemetry_json.h | 48 +++++++++++++++++++++++++++++++++- + 2 files changed, 55 insertions(+), 4 deletions(-) + +diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c +index e5ccfe47f7..d4a7838ded 100644 +--- a/lib/telemetry/telemetry.c ++++ b/lib/telemetry/telemetry.c +@@ -233,9 +233,14 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) + MAX_CMD_LEN, cmd ? cmd : "none"); + break; + case RTE_TEL_STRING: +- used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":\"%.*s\"}", +- MAX_CMD_LEN, cmd, +- RTE_TEL_MAX_SINGLE_STRING_LEN, d->data.str); ++ prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":", ++ MAX_CMD_LEN, cmd); ++ cb_data_buf = &out_buf[prefix_used]; ++ buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */ ++ ++ used = rte_tel_json_str(cb_data_buf, buf_len, 0, d->data.str); ++ used += prefix_used; ++ used += strlcat(out_buf + used, "}", sizeof(out_buf) - used); + break; + case RTE_TEL_DICT: + prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":", +diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h +index db70690274..13df5d07e3 100644 +--- a/lib/telemetry/telemetry_json.h ++++ b/lib/telemetry/telemetry_json.h +@@ -44,6 +44,52 @@ __json_snprintf(char *buf, const int len, const char *format, ...) + return 0; /* nothing written or modified */ + } + ++static const char control_chars[0x20] = { ++ ['\n'] = 'n', ++ ['\r'] = 'r', ++ ['\t'] = 't', ++}; ++ ++/** ++ * @internal ++ * Does the same as __json_snprintf(buf, len, "\"%s\"", str) ++ * except that it does proper escaping as necessary. ++ * Drops any invalid characters we don't support ++ */ ++static inline int ++__json_format_str(char *buf, const int len, const char *str) ++{ ++ char tmp[len]; ++ int tmpidx = 0; ++ ++ tmp[tmpidx++] = '"'; ++ while (*str != '\0') { ++ if (*str < (int)RTE_DIM(control_chars)) { ++ int idx = *str; /* compilers don't like char type as index */ ++ if (control_chars[idx] != 0) { ++ tmp[tmpidx++] = '\\'; ++ tmp[tmpidx++] = control_chars[idx]; ++ } ++ } else if (*str == '"' || *str == '\\') { ++ tmp[tmpidx++] = '\\'; ++ tmp[tmpidx++] = *str; ++ } else ++ tmp[tmpidx++] = *str; ++ /* we always need space for closing quote and null character. ++ * Ensuring at least two free characters also means we can always take an ++ * escaped character like "\n" without overflowing ++ */ ++ if (tmpidx > len - 2) ++ return 0; ++ str++; ++ } ++ tmp[tmpidx++] = '"'; ++ tmp[tmpidx] = '\0'; ++ ++ strcpy(buf, tmp); ++ return tmpidx; ++} ++ + /* Copies an empty array into the provided buffer. */ + static inline int + rte_tel_json_empty_array(char *buf, const int len, const int used) +@@ -62,7 +108,7 @@ rte_tel_json_empty_obj(char *buf, const int len, const int used) + static inline int + rte_tel_json_str(char *buf, const int len, const int used, const char *str) + { +- return used + __json_snprintf(buf + used, len - used, "\"%s\"", str); ++ return used + __json_format_str(buf + used, len - used, str); + } + + /* Appends a string into the JSON array in the provided buffer. */ +-- +2.23.0 + diff --git a/0185-telemetry-add-escaping-of-strings-in-arrays.patch b/0185-telemetry-add-escaping-of-strings-in-arrays.patch new file mode 100644 index 0000000..0523e66 --- /dev/null +++ b/0185-telemetry-add-escaping-of-strings-in-arrays.patch @@ -0,0 +1,97 @@ +From df367f0febc7e5ea999f119f420d30a953268503 Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 21 Oct 2022 15:37:01 +0800 +Subject: [PATCH 185/189] telemetry: add escaping of strings in arrays +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When strings are added to an array variable, we need to properly escape +the invalid json characters in the strings. + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/telemetry/telemetry_json.h | 28 +++++++++++++++++++--------- + 1 file changed, 19 insertions(+), 9 deletions(-) + +diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h +index 13df5d07e3..c4442a0bf0 100644 +--- a/lib/telemetry/telemetry_json.h ++++ b/lib/telemetry/telemetry_json.h +@@ -52,17 +52,22 @@ static const char control_chars[0x20] = { + + /** + * @internal +- * Does the same as __json_snprintf(buf, len, "\"%s\"", str) +- * except that it does proper escaping as necessary. ++ * This function acts the same as __json_snprintf(buf, len, "%s%s%s", prefix, str, suffix) ++ * except that it does proper escaping of "str" as necessary. Prefix and suffix should be compile- ++ * time constants not needing escaping. + * Drops any invalid characters we don't support + */ + static inline int +-__json_format_str(char *buf, const int len, const char *str) ++__json_format_str(char *buf, const int len, const char *prefix, const char *str, const char *suffix) + { + char tmp[len]; + int tmpidx = 0; + +- tmp[tmpidx++] = '"'; ++ while (*prefix != '\0' && tmpidx < len) ++ tmp[tmpidx++] = *prefix++; ++ if (tmpidx >= len) ++ return 0; ++ + while (*str != '\0') { + if (*str < (int)RTE_DIM(control_chars)) { + int idx = *str; /* compilers don't like char type as index */ +@@ -75,7 +80,7 @@ __json_format_str(char *buf, const int len, const char *str) + tmp[tmpidx++] = *str; + } else + tmp[tmpidx++] = *str; +- /* we always need space for closing quote and null character. ++ /* we always need space for (at minimum) closing quote and null character. + * Ensuring at least two free characters also means we can always take an + * escaped character like "\n" without overflowing + */ +@@ -83,7 +88,12 @@ __json_format_str(char *buf, const int len, const char *str) + return 0; + str++; + } +- tmp[tmpidx++] = '"'; ++ ++ while (*suffix != '\0' && tmpidx < len) ++ tmp[tmpidx++] = *suffix++; ++ if (tmpidx >= len) ++ return 0; ++ + tmp[tmpidx] = '\0'; + + strcpy(buf, tmp); +@@ -108,7 +118,7 @@ rte_tel_json_empty_obj(char *buf, const int len, const int used) + static inline int + rte_tel_json_str(char *buf, const int len, const int used, const char *str) + { +- return used + __json_format_str(buf + used, len - used, str); ++ return used + __json_format_str(buf + used, len - used, "\"", str, "\""); + } + + /* Appends a string into the JSON array in the provided buffer. */ +@@ -118,9 +128,9 @@ rte_tel_json_add_array_string(char *buf, const int len, const int used, + { + int ret, end = used - 1; /* strip off final delimiter */ + if (used <= 2) /* assume empty, since minimum is '[]' */ +- return __json_snprintf(buf, len, "[\"%s\"]", str); ++ return __json_format_str(buf, len, "[\"", str, "\"]"); + +- ret = __json_snprintf(buf + end, len - end, ",\"%s\"]", str); ++ ret = __json_format_str(buf + end, len - end, ",\"", str, "\"]"); + return ret == 0 ? used : end + ret; + } + +-- +2.23.0 + diff --git a/0186-telemetry-add-escaping-of-strings-in-dicts.patch b/0186-telemetry-add-escaping-of-strings-in-dicts.patch new file mode 100644 index 0000000..9234a9a --- /dev/null +++ b/0186-telemetry-add-escaping-of-strings-in-dicts.patch @@ -0,0 +1,55 @@ +From c3036c497f29f4acf6423a88f59963781af3eafd Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 21 Oct 2022 15:37:02 +0800 +Subject: [PATCH 186/189] telemetry: add escaping of strings in dicts +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When strings are added to an dict variable, we need to properly escape +the invalid json characters in the strings. + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/telemetry/telemetry_json.h | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h +index c4442a0bf0..e3fae7c30d 100644 +--- a/lib/telemetry/telemetry_json.h ++++ b/lib/telemetry/telemetry_json.h +@@ -54,7 +54,7 @@ static const char control_chars[0x20] = { + * @internal + * This function acts the same as __json_snprintf(buf, len, "%s%s%s", prefix, str, suffix) + * except that it does proper escaping of "str" as necessary. Prefix and suffix should be compile- +- * time constants not needing escaping. ++ * time constants, or values not needing escaping. + * Drops any invalid characters we don't support + */ + static inline int +@@ -219,12 +219,16 @@ static inline int + rte_tel_json_add_obj_str(char *buf, const int len, const int used, + const char *name, const char *val) + { ++ char tmp_name[RTE_TEL_MAX_STRING_LEN + 5]; + int ret, end = used - 1; ++ ++ /* names are limited to certain characters so need no escaping */ ++ snprintf(tmp_name, sizeof(tmp_name), "{\"%s\":\"", name); + if (used <= 2) /* assume empty, since minimum is '{}' */ +- return __json_snprintf(buf, len, "{\"%s\":\"%s\"}", name, val); ++ return __json_format_str(buf, len, tmp_name, val, "\"}"); + +- ret = __json_snprintf(buf + end, len - end, ",\"%s\":\"%s\"}", +- name, val); ++ tmp_name[0] = ','; /* replace '{' with ',' at start */ ++ ret = __json_format_str(buf + end, len - end, tmp_name, val, "\"}"); + return ret == 0 ? used : end + ret; + } + +-- +2.23.0 + diff --git a/0187-telemetry-limit-command-characters.patch b/0187-telemetry-limit-command-characters.patch new file mode 100644 index 0000000..ea65d46 --- /dev/null +++ b/0187-telemetry-limit-command-characters.patch @@ -0,0 +1,55 @@ +From 585eeea3522ce2225a1df94fcc0b8aec2d881b44 Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 21 Oct 2022 15:37:03 +0800 +Subject: [PATCH 187/189] telemetry: limit command characters +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Limit the telemetry command characters to the minimum set needed for +current implementations. This prevents issues with invalid json +characters needing to be escaped on replies. + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/telemetry/telemetry.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c +index d4a7838ded..f0be50b2bf 100644 +--- a/lib/telemetry/telemetry.c ++++ b/lib/telemetry/telemetry.c +@@ -3,6 +3,7 @@ + */ + + #ifndef RTE_EXEC_ENV_WINDOWS ++#include + #include + #include + #include +@@ -71,12 +72,19 @@ int + rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help) + { + struct cmd_callback *new_callbacks; ++ const char *cmdp = cmd; + int i = 0; + + if (strlen(cmd) >= MAX_CMD_LEN || fn == NULL || cmd[0] != '/' + || strlen(help) >= RTE_TEL_MAX_STRING_LEN) + return -EINVAL; + ++ while (*cmdp != '\0') { ++ if (!isalnum(*cmdp) && *cmdp != '_' && *cmdp != '/') ++ return -EINVAL; ++ cmdp++; ++ } ++ + rte_spinlock_lock(&callback_sl); + new_callbacks = realloc(callbacks, sizeof(callbacks[0]) * (num_callbacks + 1)); + if (new_callbacks == NULL) { +-- +2.23.0 + diff --git a/0188-telemetry-eliminate-duplicate-code-for-json-output.patch b/0188-telemetry-eliminate-duplicate-code-for-json-output.patch new file mode 100644 index 0000000..89e8c42 --- /dev/null +++ b/0188-telemetry-eliminate-duplicate-code-for-json-output.patch @@ -0,0 +1,103 @@ +From c89a9af036a9063903537404d615bed04a700e5b Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 21 Oct 2022 15:37:04 +0800 +Subject: [PATCH 188/189] telemetry: eliminate duplicate code for json output +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When preparing the json response to a telemetry socket query, the code +for prefixing the command name, and appending the file "}" on the end of +the response was duplicated for multiple reply types. Taking this code +out of the switch statement reduces the duplication and makes the code +more maintainable. + +For completeness of testing, add in a test case to validate the "null" +response type - the only leg of the switch statement not already covered +by an existing test case in the telemetry_data tests. + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/telemetry/telemetry.c | 35 ++++++++++++----------------------- + 1 file changed, 12 insertions(+), 23 deletions(-) + +diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c +index f0be50b2bf..25ab6ed877 100644 +--- a/lib/telemetry/telemetry.c ++++ b/lib/telemetry/telemetry.c +@@ -235,27 +235,22 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) + + RTE_BUILD_BUG_ON(sizeof(out_buf) < MAX_CMD_LEN + + RTE_TEL_MAX_SINGLE_STRING_LEN + 10); ++ ++ prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":", ++ MAX_CMD_LEN, cmd); ++ cb_data_buf = &out_buf[prefix_used]; ++ buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */ ++ + switch (d->type) { + case RTE_TEL_NULL: +- used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":null}", +- MAX_CMD_LEN, cmd ? cmd : "none"); ++ used = strlcpy(cb_data_buf, "null", buf_len); + break; +- case RTE_TEL_STRING: +- prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":", +- MAX_CMD_LEN, cmd); +- cb_data_buf = &out_buf[prefix_used]; +- buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */ + ++ case RTE_TEL_STRING: + used = rte_tel_json_str(cb_data_buf, buf_len, 0, d->data.str); +- used += prefix_used; +- used += strlcat(out_buf + used, "}", sizeof(out_buf) - used); + break; +- case RTE_TEL_DICT: +- prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":", +- MAX_CMD_LEN, cmd); +- cb_data_buf = &out_buf[prefix_used]; +- buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */ + ++ case RTE_TEL_DICT: + used = rte_tel_json_empty_obj(cb_data_buf, buf_len, 0); + for (i = 0; i < d->data_len; i++) { + const struct tel_dict_entry *v = &d->data.dict[i]; +@@ -291,18 +286,12 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) + } + } + } +- used += prefix_used; +- used += strlcat(out_buf + used, "}", sizeof(out_buf) - used); + break; ++ + case RTE_TEL_ARRAY_STRING: + case RTE_TEL_ARRAY_INT: + case RTE_TEL_ARRAY_U64: + case RTE_TEL_ARRAY_CONTAINER: +- prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":", +- MAX_CMD_LEN, cmd); +- cb_data_buf = &out_buf[prefix_used]; +- buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */ +- + used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0); + for (i = 0; i < d->data_len; i++) + if (d->type == RTE_TEL_ARRAY_STRING) +@@ -330,10 +319,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) + if (!rec_data->keep) + rte_tel_data_free(rec_data->data); + } +- used += prefix_used; +- used += strlcat(out_buf + used, "}", sizeof(out_buf) - used); + break; + } ++ used += prefix_used; ++ used += strlcat(out_buf + used, "}", sizeof(out_buf) - used); + if (write(s, out_buf, used) < 0) + perror("Error writing to socket"); + } +-- +2.23.0 + diff --git a/0189-telemetry-make-help-command-more-helpful.patch b/0189-telemetry-make-help-command-more-helpful.patch new file mode 100644 index 0000000..fa2242c --- /dev/null +++ b/0189-telemetry-make-help-command-more-helpful.patch @@ -0,0 +1,52 @@ +From 2674bf9f28b9dd7724d72096a8e54b19400239bd Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 21 Oct 2022 15:37:05 +0800 +Subject: [PATCH 189/189] telemetry: make help command more helpful +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The /help telemetry command prints out the help text for the given +command passed in as parameter. However, entering /help without any +parameters does not give any useful information as to the fact that you +need to pass in a command to get help on. Update the command so it +prints its own help text when called without any parameters. + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/telemetry/telemetry.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c +index 25ab6ed877..52048de55c 100644 +--- a/lib/telemetry/telemetry.c ++++ b/lib/telemetry/telemetry.c +@@ -141,15 +141,17 @@ command_help(const char *cmd __rte_unused, const char *params, + struct rte_tel_data *d) + { + int i; ++ /* if no parameters return our own help text */ ++ const char *to_lookup = (params == NULL ? cmd : params); + +- if (!params) +- return -1; + rte_tel_data_start_dict(d); + rte_spinlock_lock(&callback_sl); + for (i = 0; i < num_callbacks; i++) +- if (strcmp(params, callbacks[i].cmd) == 0) { +- rte_tel_data_add_dict_string(d, params, +- callbacks[i].help); ++ if (strcmp(to_lookup, callbacks[i].cmd) == 0) { ++ if (params == NULL) ++ rte_tel_data_string(d, callbacks[i].help); ++ else ++ rte_tel_data_add_dict_string(d, params, callbacks[i].help); + break; + } + rte_spinlock_unlock(&callback_sl); +-- +2.23.0 + diff --git a/0190-net-bonding-fix-Tx-hash-for-TCP.patch b/0190-net-bonding-fix-Tx-hash-for-TCP.patch new file mode 100644 index 0000000..36d3796 --- /dev/null +++ b/0190-net-bonding-fix-Tx-hash-for-TCP.patch @@ -0,0 +1,42 @@ +From fbe9bd4deab755855a4ef2d88e559da6ae4b76c2 Mon Sep 17 00:00:00 2001 +From: Jun Qiu +Date: Fri, 28 Oct 2022 15:32:42 +0800 +Subject: net/bonding: fix Tx hash for TCP + +In the following two cases, tcp_hdr + sizeof(*tcp_hdr) == pkt_end, +and the TCP port is not taken into account in calculating the HASH +value of TCP packets. TCP connections with the same source and +destination IP addresses will be hashed to the same slave port, +which may cause load imbalance. +1. TCP Pure ACK packets with no options, The header length is 20 +and there is no data. +2. A TCP packet contains data, but the first seg of the mbuf +contains only the header information (ETH, IP, TCP), and the +data is in subsequent segs, which is usually the case in the +indirect mbuf used for zero-copy. + +Fixes: 726158060d55 ("net/bonding: fix potential out of bounds read") +Cc: stable@dpdk.org + +Signed-off-by: Jun Qiu +Acked-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 3be2b08128..18754e3299 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -768,7 +768,7 @@ burst_xmit_l34_hash(struct rte_mbuf **buf, uint16_t nb_pkts, + ((char *)ipv4_hdr + + ip_hdr_offset); + if ((size_t)tcp_hdr + sizeof(*tcp_hdr) +- < pkt_end) ++ <= pkt_end) + l4hash = HASH_L4_PORTS(tcp_hdr); + } else if (ipv4_hdr->next_proto_id == + IPPROTO_UDP) { +-- +2.23.0 + diff --git a/0191-net-bonding-add-link-speeds-configuration.patch b/0191-net-bonding-add-link-speeds-configuration.patch new file mode 100644 index 0000000..8bdecef --- /dev/null +++ b/0191-net-bonding-add-link-speeds-configuration.patch @@ -0,0 +1,112 @@ +From b92c505e9506f38e76dcf094fbbb2e765e5452a8 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 28 Oct 2022 15:32:43 +0800 +Subject: net/bonding: add link speeds configuration + +This patch adds link speeds configuration. + +Signed-off-by: Huisong Li +Acked-by: Chas Williams <3chas3@gmail.com> +--- + drivers/net/bonding/eth_bond_private.h | 3 +++ + drivers/net/bonding/rte_eth_bond_api.c | 3 +++ + drivers/net/bonding/rte_eth_bond_pmd.c | 27 ++++++++++++++++++++++++++ + 3 files changed, 33 insertions(+) + +diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h +index 9626b26d67..c338e11d4f 100644 +--- a/drivers/net/bonding/eth_bond_private.h ++++ b/drivers/net/bonding/eth_bond_private.h +@@ -131,6 +131,9 @@ struct bond_dev_private { + uint32_t link_down_delay_ms; + uint32_t link_up_delay_ms; + ++ uint32_t speed_capa; ++ /**< Supported speeds bitmap (RTE_ETH_LINK_SPEED_). */ ++ + uint16_t nb_rx_queues; /**< Total number of rx queues */ + uint16_t nb_tx_queues; /**< Total number of tx queues*/ + +diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c +index 2d5cac6c51..b74477128a 100644 +--- a/drivers/net/bonding/rte_eth_bond_api.c ++++ b/drivers/net/bonding/rte_eth_bond_api.c +@@ -513,6 +513,8 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) + internals->primary_port = slave_port_id; + internals->current_primary_port = slave_port_id; + ++ internals->speed_capa = dev_info.speed_capa; ++ + /* Inherit queues settings from first slave */ + internals->nb_rx_queues = slave_eth_dev->data->nb_rx_queues; + internals->nb_tx_queues = slave_eth_dev->data->nb_tx_queues; +@@ -527,6 +529,7 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) + } else { + int ret; + ++ internals->speed_capa &= dev_info.speed_capa; + eth_bond_slave_inherit_dev_info_rx_next(internals, &dev_info); + eth_bond_slave_inherit_dev_info_tx_next(internals, &dev_info); + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 18754e3299..b5b706901a 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -1721,6 +1721,8 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev, + + slave_eth_dev->data->dev_conf.rxmode.mtu = + bonded_eth_dev->data->dev_conf.rxmode.mtu; ++ slave_eth_dev->data->dev_conf.link_speeds = ++ bonded_eth_dev->data->dev_conf.link_speeds; + + slave_eth_dev->data->dev_conf.txmode.offloads |= + bonded_eth_dev->data->dev_conf.txmode.offloads; +@@ -2257,6 +2259,7 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) + + dev_info->reta_size = internals->reta_size; + dev_info->hash_key_size = internals->rss_key_len; ++ dev_info->speed_capa = internals->speed_capa; + + return 0; + } +@@ -3571,6 +3574,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev) + uint64_t offloads; + int arg_count; + uint16_t port_id = dev - rte_eth_devices; ++ uint32_t link_speeds; + uint8_t agg_mode; + + static const uint8_t default_rss_key[40] = { +@@ -3629,6 +3633,29 @@ bond_ethdev_configure(struct rte_eth_dev *dev) + dev->data->dev_conf.txmode.offloads = offloads; + } + ++ link_speeds = dev->data->dev_conf.link_speeds; ++ /* ++ * The default value of 'link_speeds' is zero. From its definition, ++ * this value actually means auto-negotiation. But not all PMDs support ++ * auto-negotiation. So ignore the check for the auto-negotiation and ++ * only consider fixed speed to reduce the impact on PMDs. ++ */ ++ if (link_speeds & RTE_ETH_LINK_SPEED_FIXED) { ++ if ((link_speeds & ++ (internals->speed_capa & ~RTE_ETH_LINK_SPEED_FIXED)) == 0) { ++ RTE_BOND_LOG(ERR, "the fixed speed is not supported by all slave devices."); ++ return -EINVAL; ++ } ++ /* ++ * Two '1' in binary of 'link_speeds': bit0 and a unique ++ * speed bit. ++ */ ++ if (__builtin_popcountl(link_speeds) != 2) { ++ RTE_BOND_LOG(ERR, "please set a unique speed."); ++ return -EINVAL; ++ } ++ } ++ + /* set the max_rx_pktlen */ + internals->max_rx_pktlen = internals->candidate_max_rx_pktlen; + +-- +2.23.0 + diff --git a/0192-net-bonding-call-Tx-prepare-before-Tx-burst.patch b/0192-net-bonding-call-Tx-prepare-before-Tx-burst.patch new file mode 100644 index 0000000..f8fad78 --- /dev/null +++ b/0192-net-bonding-call-Tx-prepare-before-Tx-burst.patch @@ -0,0 +1,211 @@ +From 2606fe3bfdbe544819a08f27cd5ed6b5432c96a7 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 28 Oct 2022 15:32:44 +0800 +Subject: net/bonding: call Tx prepare before Tx burst + +Normally, to use the HW offloads capability (e.g. checksum and TSO) in +the Tx direction, the application needs to call rte_eth_tx_prepare() to +do some adjustment with the packets before sending them. But the +tx_prepare callback of the bonding driver is not implemented. Therefore, +the sent packets may have errors (e.g. checksum errors). + +However, it is difficult to design the tx_prepare callback for bonding +driver. Because when a bonded device sends packets, the bonded device +allocates the packets to different slave devices based on the real-time +link status and bonding mode. That is, it is very difficult for the +bonded device to determine which slave device's prepare function should +be invoked. + +So in this patch, the tx_prepare callback of bonding driver is not +implemented. Instead, the rte_eth_tx_prepare() will be called before +rte_eth_tx_burst(). In this way, all tx_offloads can be processed +correctly for all NIC devices. + +Note: because it is rara that bond different PMDs together, so just +call tx-prepare once in broadcast bonding mode. + +Also the following description was added to the rte_eth_tx_burst() +function: +"@note This function must not modify mbufs (including packets data) +unless the refcnt is 1. The exception is the bonding PMD, which does not +have tx-prepare function, in this case, mbufs maybe modified." + +Signed-off-by: Chengchang Tang +Signed-off-by: Chengwen Feng +Reviewed-by: Min Hu (Connor) +Acked-by: Chas Williams <3chas3@gmail.com> +--- + drivers/net/bonding/rte_eth_bond_8023ad.c | 10 ++++-- + drivers/net/bonding/rte_eth_bond_pmd.c | 37 ++++++++++++++++++----- + lib/ethdev/rte_ethdev.h | 4 +++ + 3 files changed, 41 insertions(+), 10 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c +index b3cddd8a20..29a71ae0bf 100644 +--- a/drivers/net/bonding/rte_eth_bond_8023ad.c ++++ b/drivers/net/bonding/rte_eth_bond_8023ad.c +@@ -636,9 +636,12 @@ tx_machine(struct bond_dev_private *internals, uint16_t slave_id) + return; + } + } else { +- uint16_t pkts_sent = rte_eth_tx_burst(slave_id, ++ uint16_t pkts_sent = rte_eth_tx_prepare(slave_id, + internals->mode4.dedicated_queues.tx_qid, + &lacp_pkt, 1); ++ pkts_sent = rte_eth_tx_burst(slave_id, ++ internals->mode4.dedicated_queues.tx_qid, ++ &lacp_pkt, pkts_sent); + if (pkts_sent != 1) { + rte_pktmbuf_free(lacp_pkt); + set_warning_flags(port, WRN_TX_QUEUE_FULL); +@@ -1371,9 +1374,12 @@ bond_mode_8023ad_handle_slow_pkt(struct bond_dev_private *internals, + } + } else { + /* Send packet directly to the slow queue */ +- uint16_t tx_count = rte_eth_tx_burst(slave_id, ++ uint16_t tx_count = rte_eth_tx_prepare(slave_id, + internals->mode4.dedicated_queues.tx_qid, + &pkt, 1); ++ tx_count = rte_eth_tx_burst(slave_id, ++ internals->mode4.dedicated_queues.tx_qid, ++ &pkt, tx_count); + if (tx_count != 1) { + /* reset timer */ + port->rx_marker_timer = 0; +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index b5b706901a..4e82f7b145 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -602,8 +602,11 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs, + /* Send packet burst on each slave device */ + for (i = 0; i < num_of_slaves; i++) { + if (slave_nb_pkts[i] > 0) { ++ num_tx_slave = rte_eth_tx_prepare(slaves[i], ++ bd_tx_q->queue_id, slave_bufs[i], ++ slave_nb_pkts[i]); + num_tx_slave = rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id, +- slave_bufs[i], slave_nb_pkts[i]); ++ slave_bufs[i], num_tx_slave); + + /* if tx burst fails move packets to end of bufs */ + if (unlikely(num_tx_slave < slave_nb_pkts[i])) { +@@ -628,6 +631,7 @@ bond_ethdev_tx_burst_active_backup(void *queue, + { + struct bond_dev_private *internals; + struct bond_tx_queue *bd_tx_q; ++ uint16_t nb_prep_pkts; + + bd_tx_q = (struct bond_tx_queue *)queue; + internals = bd_tx_q->dev_private; +@@ -635,8 +639,11 @@ bond_ethdev_tx_burst_active_backup(void *queue, + if (internals->active_slave_count < 1) + return 0; + ++ nb_prep_pkts = rte_eth_tx_prepare(internals->current_primary_port, ++ bd_tx_q->queue_id, bufs, nb_pkts); ++ + return rte_eth_tx_burst(internals->current_primary_port, bd_tx_q->queue_id, +- bufs, nb_pkts); ++ bufs, nb_prep_pkts); + } + + static inline uint16_t +@@ -910,7 +917,7 @@ bond_ethdev_tx_burst_tlb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) + + struct rte_eth_dev *primary_port = + &rte_eth_devices[internals->primary_port]; +- uint16_t num_tx_total = 0; ++ uint16_t num_tx_total = 0, num_tx_prep; + uint16_t i, j; + + uint16_t num_of_slaves = internals->active_slave_count; +@@ -951,8 +958,10 @@ bond_ethdev_tx_burst_tlb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) + #endif + } + +- num_tx_total += rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id, ++ num_tx_prep = rte_eth_tx_prepare(slaves[i], bd_tx_q->queue_id, + bufs + num_tx_total, nb_pkts - num_tx_total); ++ num_tx_total += rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id, ++ bufs + num_tx_total, num_tx_prep); + + if (num_tx_total == nb_pkts) + break; +@@ -1064,8 +1073,10 @@ bond_ethdev_tx_burst_alb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) + /* Send ARP packets on proper slaves */ + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { + if (slave_bufs_pkts[i] > 0) { +- num_send = rte_eth_tx_burst(i, bd_tx_q->queue_id, ++ num_send = rte_eth_tx_prepare(i, bd_tx_q->queue_id, + slave_bufs[i], slave_bufs_pkts[i]); ++ num_send = rte_eth_tx_burst(i, bd_tx_q->queue_id, ++ slave_bufs[i], num_send); + for (j = 0; j < slave_bufs_pkts[i] - num_send; j++) { + bufs[nb_pkts - 1 - num_not_send - j] = + slave_bufs[i][nb_pkts - 1 - j]; +@@ -1088,8 +1099,10 @@ bond_ethdev_tx_burst_alb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) + /* Send update packets on proper slaves */ + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { + if (update_bufs_pkts[i] > 0) { ++ num_send = rte_eth_tx_prepare(i, bd_tx_q->queue_id, ++ update_bufs[i], update_bufs_pkts[i]); + num_send = rte_eth_tx_burst(i, bd_tx_q->queue_id, update_bufs[i], +- update_bufs_pkts[i]); ++ num_send); + for (j = num_send; j < update_bufs_pkts[i]; j++) { + rte_pktmbuf_free(update_bufs[i][j]); + } +@@ -1158,9 +1171,12 @@ tx_burst_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_bufs, + if (slave_nb_bufs[i] == 0) + continue; + +- slave_tx_count = rte_eth_tx_burst(slave_port_ids[i], ++ slave_tx_count = rte_eth_tx_prepare(slave_port_ids[i], + bd_tx_q->queue_id, slave_bufs[i], + slave_nb_bufs[i]); ++ slave_tx_count = rte_eth_tx_burst(slave_port_ids[i], ++ bd_tx_q->queue_id, slave_bufs[i], ++ slave_tx_count); + + total_tx_count += slave_tx_count; + +@@ -1243,8 +1259,10 @@ tx_burst_8023ad(void *queue, struct rte_mbuf **bufs, uint16_t nb_bufs, + + if (rte_ring_dequeue(port->tx_ring, + (void **)&ctrl_pkt) != -ENOENT) { +- slave_tx_count = rte_eth_tx_burst(slave_port_ids[i], ++ slave_tx_count = rte_eth_tx_prepare(slave_port_ids[i], + bd_tx_q->queue_id, &ctrl_pkt, 1); ++ slave_tx_count = rte_eth_tx_burst(slave_port_ids[i], ++ bd_tx_q->queue_id, &ctrl_pkt, slave_tx_count); + /* + * re-enqueue LAG control plane packets to buffering + * ring if transmission fails so the packet isn't lost. +@@ -1316,6 +1334,9 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs, + if (num_of_slaves < 1) + return 0; + ++ /* It is rare that bond different PMDs together, so just call tx-prepare once */ ++ nb_pkts = rte_eth_tx_prepare(slaves[0], bd_tx_q->queue_id, bufs, nb_pkts); ++ + /* Increment reference count on mbufs */ + for (i = 0; i < nb_pkts; i++) + rte_pktmbuf_refcnt_update(bufs[i], num_of_slaves - 1); +diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h +index 8c894e090d..b262939a33 100644 +--- a/lib/ethdev/rte_ethdev.h ++++ b/lib/ethdev/rte_ethdev.h +@@ -5691,6 +5691,10 @@ uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id, + * @see rte_eth_tx_prepare to perform some prior checks or adjustments + * for offloads. + * ++ * @note This function must not modify mbufs (including packets data) unless ++ * the refcnt is 1. The exception is the bonding PMD, which does not have ++ * tx-prepare function, in this case, mbufs maybe modified. ++ * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id +-- +2.23.0 + diff --git a/0193-net-bonding-fix-MTU-set-for-slaves.patch b/0193-net-bonding-fix-MTU-set-for-slaves.patch new file mode 100644 index 0000000..5c59f56 --- /dev/null +++ b/0193-net-bonding-fix-MTU-set-for-slaves.patch @@ -0,0 +1,62 @@ +From f099709983c155337a14340da3d9607a2a08a7f9 Mon Sep 17 00:00:00 2001 +From: Ferruh Yigit +Date: Fri, 28 Oct 2022 15:32:45 +0800 +Subject: net/bonding: fix MTU set for slaves + +ethdev requires device to be configured before setting MTU. + +In bonding PMD, while configuring slaves, bonding first sets MTU later +configures them, which causes failure if slaves are not configured in +advance. + +Fixing by changing the order in slave configure as requested in ethdev +layer, configure first and set MTU later. + +Bugzilla ID: 864 +Fixes: b26bee10ee37 ("ethdev: forbid MTU set before device configure") +Cc: stable@dpdk.org + +Signed-off-by: Ferruh Yigit +Tested-by: Yu Jiang +Acked-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 4e82f7b145..ab1196e505 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -1770,14 +1770,6 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev, + } + } + +- errval = rte_eth_dev_set_mtu(slave_eth_dev->data->port_id, +- bonded_eth_dev->data->mtu); +- if (errval != 0 && errval != -ENOTSUP) { +- RTE_BOND_LOG(ERR, "rte_eth_dev_set_mtu: port %u, err (%d)", +- slave_eth_dev->data->port_id, errval); +- return errval; +- } +- + /* Configure device */ + errval = rte_eth_dev_configure(slave_eth_dev->data->port_id, + nb_rx_queues, nb_tx_queues, +@@ -1788,6 +1780,14 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev, + return errval; + } + ++ errval = rte_eth_dev_set_mtu(slave_eth_dev->data->port_id, ++ bonded_eth_dev->data->mtu); ++ if (errval != 0 && errval != -ENOTSUP) { ++ RTE_BOND_LOG(ERR, "rte_eth_dev_set_mtu: port %u, err (%d)", ++ slave_eth_dev->data->port_id, errval); ++ return errval; ++ } ++ + /* Setup Rx Queues */ + for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) { + bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id]; +-- +2.23.0 + diff --git a/0194-app-testpmd-remove-jumbo-offload-related-code.patch b/0194-app-testpmd-remove-jumbo-offload-related-code.patch new file mode 100644 index 0000000..d34e048 --- /dev/null +++ b/0194-app-testpmd-remove-jumbo-offload-related-code.patch @@ -0,0 +1,121 @@ +From 20204b1f3811015975a5dac2012ca770be174acb Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 28 Oct 2022 15:32:46 +0800 +Subject: app/testpmd: remove jumbo offload related code + +The jumbo offload was removed from patch [1], but testpmd still exist +jumbo offload related code, this patch removes it, and also updates +the rst file. + +[1] ethdev: remove jumbo offload flag + +Fixes: b563c1421282 ("ethdev: remove jumbo offload flag") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Reviewed-by: Andrew Rybchenko +--- + app/test-pmd/cmdline.c | 12 ++++++------ + app/test-pmd/testpmd.h | 1 - + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 ++++---- + 3 files changed, 10 insertions(+), 11 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 6cb095f965..8d4a88bb85 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -861,7 +861,7 @@ static void cmd_help_long_parsed(void *parsed_result, + "port config rx_offload vlan_strip|" + "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" + "outer_ipv4_cksum|macsec_strip|header_split|" +- "vlan_filter|vlan_extend|jumbo_frame|scatter|" ++ "vlan_filter|vlan_extend|scatter|" + "buffer_split|timestamp|security|keep_crc on|off\n" + " Enable or disable a per port Rx offloading" + " on all Rx queues of a port\n\n" +@@ -869,7 +869,7 @@ static void cmd_help_long_parsed(void *parsed_result, + "port (port_id) rxq (queue_id) rx_offload vlan_strip|" + "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" + "outer_ipv4_cksum|macsec_strip|header_split|" +- "vlan_filter|vlan_extend|jumbo_frame|scatter|" ++ "vlan_filter|vlan_extend|scatter|" + "buffer_split|timestamp|security|keep_crc on|off\n" + " Enable or disable a per queue Rx offloading" + " only on a specific Rx queue\n\n" +@@ -16080,7 +16080,7 @@ cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = + (struct cmd_config_per_port_rx_offload_result, + offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" + "qinq_strip#outer_ipv4_cksum#macsec_strip#" +- "header_split#vlan_filter#vlan_extend#jumbo_frame#" ++ "header_split#vlan_filter#vlan_extend#" + "scatter#buffer_split#timestamp#security#" + "keep_crc#rss_hash"); + cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = +@@ -16163,7 +16163,7 @@ cmdline_parse_inst_t cmd_config_per_port_rx_offload = { + .help_str = "port config rx_offload vlan_strip|ipv4_cksum|" + "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" + "macsec_strip|header_split|vlan_filter|vlan_extend|" +- "jumbo_frame|scatter|buffer_split|timestamp|security|" ++ "scatter|buffer_split|timestamp|security|" + "keep_crc|rss_hash on|off", + .tokens = { + (void *)&cmd_config_per_port_rx_offload_result_port, +@@ -16212,7 +16212,7 @@ cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = + (struct cmd_config_per_queue_rx_offload_result, + offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" + "qinq_strip#outer_ipv4_cksum#macsec_strip#" +- "header_split#vlan_filter#vlan_extend#jumbo_frame#" ++ "header_split#vlan_filter#vlan_extend#" + "scatter#buffer_split#timestamp#security#keep_crc"); + cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = + TOKEN_STRING_INITIALIZER +@@ -16271,7 +16271,7 @@ cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { + "vlan_strip|ipv4_cksum|" + "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" + "macsec_strip|header_split|vlan_filter|vlan_extend|" +- "jumbo_frame|scatter|buffer_split|timestamp|security|" ++ "scatter|buffer_split|timestamp|security|" + "keep_crc on|off", + .tokens = { + (void *)&cmd_config_per_queue_rx_offload_result_port, +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 9c3a5d9bc5..ab6642585e 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -1097,7 +1097,6 @@ uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue, + void add_tx_dynf_callback(portid_t portid); + void remove_tx_dynf_callback(portid_t portid); + int update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen); +-int update_jumbo_frame_offload(portid_t portid); + void flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename); + void flex_item_destroy(portid_t port_id, uint16_t flex_id); + void port_flex_item_flush(portid_t port_id); +diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +index e15dc0c4c4..e0edd349bc 100644 +--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst ++++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +@@ -1767,8 +1767,8 @@ Enable or disable a per port Rx offloading on all Rx queues of a port:: + * ``offloading``: can be any of these offloading capability: + vlan_strip, ipv4_cksum, udp_cksum, tcp_cksum, tcp_lro, + qinq_strip, outer_ipv4_cksum, macsec_strip, +- header_split, vlan_filter, vlan_extend, jumbo_frame, +- scatter, timestamp, security, keep_crc, rss_hash ++ header_split, vlan_filter, vlan_extend, scatter, timestamp, security, ++ keep_crc, rss_hash + + This command should be run when the port is stopped, or else it will fail. + +@@ -1782,8 +1782,8 @@ Enable or disable a per queue Rx offloading only on a specific Rx queue:: + * ``offloading``: can be any of these offloading capability: + vlan_strip, ipv4_cksum, udp_cksum, tcp_cksum, tcp_lro, + qinq_strip, outer_ipv4_cksum, macsec_strip, +- header_split, vlan_filter, vlan_extend, jumbo_frame, +- scatter, timestamp, security, keep_crc ++ header_split, vlan_filter, vlan_extend, scatter, timestamp, security, ++ keep_crc + + This command should be run when the port is stopped, or else it will fail. + +-- +2.23.0 + diff --git a/0195-app-testpmd-revert-MAC-update-in-checksum-forwarding.patch b/0195-app-testpmd-revert-MAC-update-in-checksum-forwarding.patch new file mode 100644 index 0000000..8e18c47 --- /dev/null +++ b/0195-app-testpmd-revert-MAC-update-in-checksum-forwarding.patch @@ -0,0 +1,42 @@ +From 304a7bf032352999131c0b3e28c585610000990e Mon Sep 17 00:00:00 2001 +From: Maxime Coquelin +Date: Tue, 15 Nov 2022 12:06:06 +0800 +Subject: app/testpmd: revert MAC update in checksum forwarding + +[ upstream commit 9b4ea7ae77faa8f8aba8c7510c821f75d7863b16 ] + +This patch reverts +commit 10f4620f02e1 ("app/testpmd: modify mac in csum forwarding"), +as the checksum forwarding is expected to only perform +checksum and not also overwrites the source and destination MAC addresses. + +Doing so, we can test checksum offloading with real traffic +without breaking broadcast packets. + +Fixes: 10f4620f02e1 ("app/testpmd: modify mac in csum forwarding") + +Signed-off-by: Maxime Coquelin +Acked-by: Chenbo Xia +Acked-by: Aman Singh +--- + app/test-pmd/csumonly.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c +index 0177284d9c..206968d37a 100644 +--- a/app/test-pmd/csumonly.c ++++ b/app/test-pmd/csumonly.c +@@ -887,10 +887,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) + * and inner headers */ + + eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); +- rte_ether_addr_copy(&peer_eth_addrs[fs->peer_addr], +- ð_hdr->dst_addr); +- rte_ether_addr_copy(&ports[fs->tx_port].eth_addr, +- ð_hdr->src_addr); + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; + +-- +2.23.0 + diff --git a/0196-net-bonding-fix-bond4-drop-valid-MAC-packets.patch b/0196-net-bonding-fix-bond4-drop-valid-MAC-packets.patch new file mode 100644 index 0000000..41c8dea --- /dev/null +++ b/0196-net-bonding-fix-bond4-drop-valid-MAC-packets.patch @@ -0,0 +1,86 @@ +From 44f34b117cb446f9dce03e683942a40a8a04436c Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 15 Nov 2022 12:06:07 +0800 +Subject: net/bonding: fix bond4 drop valid MAC packets + +[ upstream commit 2176782ec87589927e1b13737b60ee8be28d76af ] + +Currently, by default, bond4 will first try to enable allmulti and +then enable promiscuous if fail to enable allmulti. On reception, +whether unicast and multicast packets should be dropped depends on +which mode has been enabled on the bonding interface. + +In fact, if MAC address of packets in mac_addrs array of bonding +interface, these packets should not be dropped. However, now only +check the default MAC address, which will cause the packets with +MAC added by the '.mac_addr_add' are dropped. + +Fixes: 68218b87c184 ("net/bonding: prefer allmulti to promiscuous for LACP") + +Signed-off-by: Huisong Li +Reviewed-by: Andrew Rybchenko +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 33 +++++++++++++++++++------- + 1 file changed, 25 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index ab1196e505..f1e7b6459a 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -271,6 +271,24 @@ bond_ethdev_8023ad_flow_set(struct rte_eth_dev *bond_dev, uint16_t slave_port) { + return 0; + } + ++static bool ++is_bond_mac_addr(const struct rte_ether_addr *ea, ++ const struct rte_ether_addr *mac_addrs, uint32_t max_mac_addrs) ++{ ++ uint32_t i; ++ ++ for (i = 0; i < max_mac_addrs; i++) { ++ /* skip zero address */ ++ if (rte_is_zero_ether_addr(&mac_addrs[i])) ++ continue; ++ ++ if (rte_is_same_ether_addr(ea, &mac_addrs[i])) ++ return true; ++ } ++ ++ return false; ++} ++ + static inline uint16_t + rx_burst_8023ad(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts, + bool dedicated_rxq) +@@ -331,8 +349,9 @@ rx_burst_8023ad(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts, + /* Remove packet from array if: + * - it is slow packet but no dedicated rxq is present, + * - slave is not in collecting state, +- * - bonding interface is not in promiscuous mode: +- * - packet is unicast and address does not match, ++ * - bonding interface is not in promiscuous mode and ++ * packet address isn't in mac_addrs array: ++ * - packet is unicast, + * - packet is multicast and bonding interface + * is not in allmulti, + */ +@@ -342,12 +361,10 @@ rx_burst_8023ad(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts, + bufs[j])) || + !collecting || + (!promisc && +- ((rte_is_unicast_ether_addr(&hdr->dst_addr) && +- !rte_is_same_ether_addr(bond_mac, +- &hdr->dst_addr)) || +- (!allmulti && +- rte_is_multicast_ether_addr(&hdr->dst_addr)))))) { +- ++ !is_bond_mac_addr(&hdr->dst_addr, bond_mac, ++ BOND_MAX_MAC_ADDRS) && ++ (rte_is_unicast_ether_addr(&hdr->dst_addr) || ++ !allmulti)))) { + if (hdr->ether_type == ether_type_slow_be) { + bond_mode_8023ad_handle_slow_pkt( + internals, slaves[idx], bufs[j]); +-- +2.23.0 + diff --git a/0197-net-bonding-fix-slave-device-Rx-Tx-offload-configura.patch b/0197-net-bonding-fix-slave-device-Rx-Tx-offload-configura.patch new file mode 100644 index 0000000..ee6e168 --- /dev/null +++ b/0197-net-bonding-fix-slave-device-Rx-Tx-offload-configura.patch @@ -0,0 +1,54 @@ +From 6ca88723b7df208ffa5c43fdfda06381103e488a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 15 Nov 2022 12:06:08 +0800 +Subject: net/bonding: fix slave device Rx/Tx offload configuration + +[ upstream commit fdbc4e7704a7de0f41f72d4f5337b0eddaa81991 ] + +Normally, the Rx/Tx offload capability of bonding interface is +the intersection of the capability of all slave devices. And +Rx/Tx offloads configuration of slave device comes from bonding +interface. But now there is a risk that slave device retains its +previous offload configurations which is not within the offload +configurations of bond interface. + +Fixes: 57b156540f51 ("net/bonding: fix offloading configuration") + +Signed-off-by: Huisong Li +Acked-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 17 ++++------------- + 1 file changed, 4 insertions(+), 13 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index f1e7b6459a..2bf28b829d 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -1762,20 +1762,11 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev, + slave_eth_dev->data->dev_conf.link_speeds = + bonded_eth_dev->data->dev_conf.link_speeds; + +- slave_eth_dev->data->dev_conf.txmode.offloads |= +- bonded_eth_dev->data->dev_conf.txmode.offloads; +- +- slave_eth_dev->data->dev_conf.txmode.offloads &= +- (bonded_eth_dev->data->dev_conf.txmode.offloads | +- ~internals->tx_offload_capa); +- +- slave_eth_dev->data->dev_conf.rxmode.offloads |= +- bonded_eth_dev->data->dev_conf.rxmode.offloads; +- +- slave_eth_dev->data->dev_conf.rxmode.offloads &= +- (bonded_eth_dev->data->dev_conf.rxmode.offloads | +- ~internals->rx_offload_capa); ++ slave_eth_dev->data->dev_conf.txmode.offloads = ++ bonded_eth_dev->data->dev_conf.txmode.offloads; + ++ slave_eth_dev->data->dev_conf.rxmode.offloads = ++ bonded_eth_dev->data->dev_conf.rxmode.offloads; + + nb_rx_queues = bonded_eth_dev->data->nb_rx_queues; + nb_tx_queues = bonded_eth_dev->data->nb_tx_queues; +-- +2.23.0 + diff --git a/0198-app-testpmd-fix-MAC-header-in-csum-forward-engine.patch b/0198-app-testpmd-fix-MAC-header-in-csum-forward-engine.patch new file mode 100644 index 0000000..00ef57e --- /dev/null +++ b/0198-app-testpmd-fix-MAC-header-in-csum-forward-engine.patch @@ -0,0 +1,154 @@ +From a31eaf3090f26f73fa3996487d9bde36418dbcd9 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 15 Nov 2022 12:06:09 +0800 +Subject: app/testpmd: fix MAC header in csum forward engine + +[ upstream commit 008834b91ac9a9e4ea982e5d2a4526d1b90a8d18 ] + +MLX5 SR-IOV Tx engine will not transmit Ethernet frame +if destination MAC address matched local port address. The frame ether +looped-back to Rx or dropped, depending on the port configuration. + +Application running over MLX5 SR-IOV port cannot transmit packet +polled from Rx queue as is. The packet Ethernet destination address +must be changed. + +Add new run-time configuration parameter to the `csum` forwarding +engine to control MAC addresses configuration: + +testpmd> csum mac-swap on|off + +`mac-swap on` replace MAC addresses. +`mac-swap off` keep Ethernet header unchanged. + +Fixes: 9b4ea7ae77fa ("app/testpmd: revert MAC update in checksum forwarding") + +Signed-off-by: Gregory Etelson +Acked-by: Huisong Li +--- + app/test-pmd/cmdline.c | 50 +++++++++++++++++++++++++++++++++++++++++ + app/test-pmd/csumonly.c | 6 +++++ + app/test-pmd/testpmd.c | 5 +++-- + app/test-pmd/testpmd.h | 3 ++- + 4 files changed, 61 insertions(+), 3 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 8d4a88bb85..9e0e725913 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -4836,6 +4836,55 @@ cmdline_parse_inst_t cmd_csum_tunnel = { + }, + }; + ++struct cmd_csum_mac_swap_result { ++ cmdline_fixed_string_t csum; ++ cmdline_fixed_string_t parse; ++ cmdline_fixed_string_t onoff; ++ portid_t port_id; ++}; ++ ++static void ++cmd_csum_mac_swap_parsed(void *parsed_result, ++ __rte_unused struct cmdline *cl, ++ __rte_unused void *data) ++{ ++ struct cmd_csum_mac_swap_result *res = parsed_result; ++ ++ if (port_id_is_invalid(res->port_id, ENABLED_WARN)) ++ return; ++ if (strcmp(res->onoff, "on") == 0) ++ ports[res->port_id].fwd_mac_swap = 1; ++ else ++ ports[res->port_id].fwd_mac_swap = 0; ++} ++ ++static cmdline_parse_token_string_t cmd_csum_mac_swap_csum = ++ TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result, ++ csum, "csum"); ++static cmdline_parse_token_string_t cmd_csum_mac_swap_parse = ++ TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result, ++ parse, "mac-swap"); ++static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff = ++ TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result, ++ onoff, "on#off"); ++static cmdline_parse_token_num_t cmd_csum_mac_swap_portid = ++ TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result, ++ port_id, RTE_UINT16); ++ ++static cmdline_parse_inst_t cmd_csum_mac_swap = { ++ .f = cmd_csum_mac_swap_parsed, ++ .data = NULL, ++ .help_str = "csum mac-swap on|off : " ++ "Enable/Disable forward mac address swap", ++ .tokens = { ++ (void *)&cmd_csum_mac_swap_csum, ++ (void *)&cmd_csum_mac_swap_parse, ++ (void *)&cmd_csum_mac_swap_onoff, ++ (void *)&cmd_csum_mac_swap_portid, ++ NULL, ++ }, ++}; ++ + /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ + struct cmd_tso_set_result { + cmdline_fixed_string_t tso; +@@ -17699,6 +17748,7 @@ cmdline_parse_ctx_t main_ctx[] = { + (cmdline_parse_inst_t *)&cmd_csum_set, + (cmdline_parse_inst_t *)&cmd_csum_show, + (cmdline_parse_inst_t *)&cmd_csum_tunnel, ++ (cmdline_parse_inst_t *)&cmd_csum_mac_swap, + (cmdline_parse_inst_t *)&cmd_tso_set, + (cmdline_parse_inst_t *)&cmd_tso_show, + (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, +diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c +index 206968d37a..d8cb8c89aa 100644 +--- a/app/test-pmd/csumonly.c ++++ b/app/test-pmd/csumonly.c +@@ -887,6 +887,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) + * and inner headers */ + + eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); ++ if (ports[fs->tx_port].fwd_mac_swap) { ++ rte_ether_addr_copy(&peer_eth_addrs[fs->peer_addr], ++ ð_hdr->dst_addr); ++ rte_ether_addr_copy(&ports[fs->tx_port].eth_addr, ++ ð_hdr->src_addr); ++ } + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; + +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index 2be92af9f8..ff9eabbcb7 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -4160,10 +4160,11 @@ init_port(void) + "rte_zmalloc(%d struct rte_port) failed\n", + RTE_MAX_ETHPORTS); + } +- for (i = 0; i < RTE_MAX_ETHPORTS; i++) ++ for (i = 0; i < RTE_MAX_ETHPORTS; i++) { ++ ports[i].fwd_mac_swap = 1; + ports[i].xstats_info.allocated = false; +- for (i = 0; i < RTE_MAX_ETHPORTS; i++) + LIST_INIT(&ports[i].flow_tunnel_list); ++ } + /* Initialize ports NUMA structures */ + memset(port_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS); + memset(rxring_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS); +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index ab6642585e..442f97ce3d 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -247,7 +247,8 @@ struct rte_port { + struct rte_ether_addr *mc_addr_pool; /**< pool of multicast addrs */ + uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */ + uint8_t slave_flag : 1, /**< bonding slave port */ +- bond_flag : 1; /**< port is bond device */ ++ bond_flag : 1, /**< port is bond device */ ++ fwd_mac_swap : 1; /**< swap packet MAC before forward */ + struct port_flow *flow_list; /**< Associated flows. */ + struct port_indirect_action *actions_list; + /**< Associated indirect actions. */ +-- +2.23.0 + diff --git a/0199-app-testpmd-update-bond-port-configurations-when-add.patch b/0199-app-testpmd-update-bond-port-configurations-when-add.patch new file mode 100644 index 0000000..d973067 --- /dev/null +++ b/0199-app-testpmd-update-bond-port-configurations-when-add.patch @@ -0,0 +1,110 @@ +From 97b384c9ecb993ea111bd7648a0aac9127917d22 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 15 Nov 2022 12:06:10 +0800 +Subject: app/testpmd: update bond port configurations when add slave + +[ upstream commit 76376bd9cd491fb0ca9c0b78346cee0ca7c4a351 ] + +Some capabilities (like, rx_offload_capa and tx_offload_capa) of bonding +device in dev_info is zero when no slave is added. And its capability will +be updated when add a new slave device. + +The capability to update dynamically may introduce some problems if not +handled properly. For example, the reconfig() is called to initialize +bonding port configurations when create a bonding device. The global +tx_mode is assigned to dev_conf.txmode. The DEV_TX_OFFLOAD_MBUF_FAST_FREE +which is the default value of global tx_mode.offloads in testpmd is removed +from bonding device configuration because of zero rx_offload_capa. +As a result, this offload isn't set to bonding device. + +Generally, port configurations of bonding device must be within the +intersection of the capability of all slave devices. If use original port +configurations, the removed capabilities because of adding a new slave may +cause failure when re-initialize bonding device. + +So port configurations of bonding device need to be updated because of the +added and removed capabilities. In addition, this also helps to ensure +consistency between testpmd and bonding device. + +Signed-off-by: Huisong Li +Reviewed-by: Min Hu (Connor) +--- + app/test-pmd/testpmd.c | 40 ++++++++++++++++++++++++++++++++++++++++ + app/test-pmd/testpmd.h | 3 ++- + 2 files changed, 42 insertions(+), 1 deletion(-) + +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index ff9eabbcb7..32098d4701 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -2778,6 +2778,41 @@ fill_xstats_display_info(void) + fill_xstats_display_info_for_port(pi); + } + ++/* ++ * Some capabilities (like, rx_offload_capa and tx_offload_capa) of bonding ++ * device in dev_info is zero when no slave is added. And its capability ++ * will be updated when add a new slave device. So adding a slave device need ++ * to update the port configurations of bonding device. ++ */ ++static void ++update_bonding_port_dev_conf(portid_t bond_pid) ++{ ++#ifdef RTE_NET_BOND ++ struct rte_port *port = &ports[bond_pid]; ++ uint16_t i; ++ int ret; ++ ++ ret = eth_dev_info_get_print_err(bond_pid, &port->dev_info); ++ if (ret != 0) { ++ fprintf(stderr, "Failed to get dev info for port = %u\n", ++ bond_pid); ++ return; ++ } ++ ++ if (port->dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) ++ port->dev_conf.txmode.offloads |= ++ RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; ++ /* Apply Tx offloads configuration */ ++ for (i = 0; i < port->dev_info.max_tx_queues; i++) ++ port->tx_conf[i].offloads = port->dev_conf.txmode.offloads; ++ ++ port->dev_conf.rx_adv_conf.rss_conf.rss_hf &= ++ port->dev_info.flow_type_rss_offloads; ++#else ++ RTE_SET_USED(bond_pid); ++#endif ++} ++ + int + start_port(portid_t pid) + { +@@ -2842,6 +2877,11 @@ start_port(portid_t pid) + return -1; + } + ++ if (port->bond_flag == 1 && port->update_conf == 1) { ++ update_bonding_port_dev_conf(pi); ++ port->update_conf = 0; ++ } ++ + /* configure port */ + diag = eth_dev_configure_mp(pi, nb_rxq + nb_hairpinq, + nb_txq + nb_hairpinq, +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 442f97ce3d..480dc3fa34 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -248,7 +248,8 @@ struct rte_port { + uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */ + uint8_t slave_flag : 1, /**< bonding slave port */ + bond_flag : 1, /**< port is bond device */ +- fwd_mac_swap : 1; /**< swap packet MAC before forward */ ++ fwd_mac_swap : 1, /**< swap packet MAC before forward */ ++ update_conf : 1; /**< need to update bonding device configuration */ + struct port_flow *flow_list; /**< Associated flows. */ + struct port_indirect_action *actions_list; + /**< Associated indirect actions. */ +-- +2.23.0 + diff --git a/0200-app-testpmd-fix-GENEVE-parsing-in-checksum-mode.patch b/0200-app-testpmd-fix-GENEVE-parsing-in-checksum-mode.patch new file mode 100644 index 0000000..60512e6 --- /dev/null +++ b/0200-app-testpmd-fix-GENEVE-parsing-in-checksum-mode.patch @@ -0,0 +1,83 @@ +From ecfa2e7054530f4a1eb9118a30a9bc6439b29bd8 Mon Sep 17 00:00:00 2001 +From: Raja Zidane +Date: Tue, 15 Nov 2022 12:06:11 +0800 +Subject: app/testpmd: fix GENEVE parsing in checksum mode + +[ upstream commit 993677affe391be8bb390c2625bc3d8bb857f0a5 ] + +The csum FWD mode parses any received packet to set mbuf offloads for +the transmitting burst, mainly in the checksum/TSO areas. +In the case of a tunnel header, the csum FWD tries to detect known +tunnels by the standard definition using the header's data and fallback +to check the packet type in the mbuf to see if the Rx port driver +already sign the packet as a tunnel. +In the fallback case, the csum assumes the tunnel is VXLAN and parses +the tunnel as VXLAN. +When the GENEVE tunnel was added to the known tunnels in csum, its +parsing trial was wrongly located after the pkt type detection, causing +the csum to parse the GENEVE header as VXLAN when the Rx port set the +tunnel packet type. + +Remove the fall back case to VXLAN. +Log error of unrecognized tunnel if no tunnel was parsed successfully. + +Fixes: c10a026c3b03 ("app/testpmd: introduce vxlan parsing function in csum fwd engine") +Cc: stable@dpdk.org + +Signed-off-by: Raja Zidane +Acked-by: Aman Singh +Acked-by: Ferruh Yigit +--- + app/test-pmd/csumonly.c | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c +index d8cb8c89aa..7c4c04be26 100644 +--- a/app/test-pmd/csumonly.c ++++ b/app/test-pmd/csumonly.c +@@ -257,8 +257,7 @@ parse_gtp(struct rte_udp_hdr *udp_hdr, + /* Parse a vxlan header */ + static void + parse_vxlan(struct rte_udp_hdr *udp_hdr, +- struct testpmd_offload_info *info, +- uint32_t pkt_type) ++ struct testpmd_offload_info *info) + { + struct rte_ether_hdr *eth_hdr; + +@@ -266,8 +265,7 @@ parse_vxlan(struct rte_udp_hdr *udp_hdr, + * default vxlan port (rfc7348) or that the rx offload flag is set + * (i40e only currently) + */ +- if (udp_hdr->dst_port != _htons(RTE_VXLAN_DEFAULT_PORT) && +- RTE_ETH_IS_TUNNEL_PKT(pkt_type) == 0) ++ if (udp_hdr->dst_port != _htons(RTE_VXLAN_DEFAULT_PORT)) + return; + + update_tunnel_outer(info); +@@ -914,8 +912,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) + RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE; + goto tunnel_update; + } +- parse_vxlan(udp_hdr, &info, +- m->packet_type); ++ parse_vxlan(udp_hdr, &info); + if (info.is_tunnel) { + tx_ol_flags |= + RTE_MBUF_F_TX_TUNNEL_VXLAN; +@@ -927,6 +924,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) + RTE_MBUF_F_TX_TUNNEL_GENEVE; + goto tunnel_update; + } ++ /* Always keep last. */ ++ if (unlikely(RTE_ETH_IS_TUNNEL_PKT( ++ m->packet_type) != 0)) { ++ TESTPMD_LOG(DEBUG, "Unknown tunnel packet. UDP dst port: %hu", ++ udp_hdr->dst_port); ++ } + } else if (info.l4_proto == IPPROTO_GRE) { + struct simple_gre_hdr *gre_hdr; + +-- +2.23.0 + diff --git a/0201-net-add-UDP-TCP-checksum-in-mbuf-segments.patch b/0201-net-add-UDP-TCP-checksum-in-mbuf-segments.patch new file mode 100644 index 0000000..bdaa89e --- /dev/null +++ b/0201-net-add-UDP-TCP-checksum-in-mbuf-segments.patch @@ -0,0 +1,239 @@ +From 179fb7a7246a835dbf3fb0449faa506214468b5f Mon Sep 17 00:00:00 2001 +From: Xiaoyun Li +Date: Tue, 15 Nov 2022 12:06:12 +0800 +Subject: net: add UDP/TCP checksum in mbuf segments + +[ upstream commit d178f693bbfe07506d6e3e23a3ce9c34ee554444 ] + +Add functions to call rte_raw_cksum_mbuf() to calculate IPv4/6 +UDP/TCP checksum in mbuf which can be over multi-segments. + +Signed-off-by: Xiaoyun Li +Acked-by: Aman Singh +Acked-by: Ferruh Yigit +Tested-by: Sunil Pai G +--- + lib/net/rte_ip.h | 186 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 186 insertions(+) + +diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h +index c575250852..534f401d26 100644 +--- a/lib/net/rte_ip.h ++++ b/lib/net/rte_ip.h +@@ -400,6 +400,65 @@ rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) + return cksum; + } + ++/** ++ * @internal Calculate the non-complemented IPv4 L4 checksum of a packet ++ */ ++static inline uint16_t ++__rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m, ++ const struct rte_ipv4_hdr *ipv4_hdr, ++ uint16_t l4_off) ++{ ++ uint16_t raw_cksum; ++ uint32_t cksum; ++ ++ if (l4_off > m->pkt_len) ++ return 0; ++ ++ if (rte_raw_cksum_mbuf(m, l4_off, m->pkt_len - l4_off, &raw_cksum)) ++ return 0; ++ ++ cksum = raw_cksum + rte_ipv4_phdr_cksum(ipv4_hdr, 0); ++ ++ cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); ++ ++ return (uint16_t)cksum; ++} ++ ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change without prior notice. ++ * ++ * Compute the IPv4 UDP/TCP checksum of a packet. ++ * ++ * @param m ++ * The pointer to the mbuf. ++ * @param ipv4_hdr ++ * The pointer to the contiguous IPv4 header. ++ * @param l4_off ++ * The offset in bytes to start L4 checksum. ++ * @return ++ * The complemented checksum to set in the L4 header. ++ */ ++__rte_experimental ++static inline uint16_t ++rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m, ++ const struct rte_ipv4_hdr *ipv4_hdr, uint16_t l4_off) ++{ ++ uint16_t cksum = __rte_ipv4_udptcp_cksum_mbuf(m, ipv4_hdr, l4_off); ++ ++ cksum = ~cksum; ++ ++ /* ++ * Per RFC 768: If the computed checksum is zero for UDP, ++ * it is transmitted as all ones ++ * (the equivalent in one's complement arithmetic). ++ */ ++ if (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP) ++ cksum = 0xffff; ++ ++ return cksum; ++} ++ + /** + * Validate the IPv4 UDP or TCP checksum. + * +@@ -426,6 +485,38 @@ rte_ipv4_udptcp_cksum_verify(const struct rte_ipv4_hdr *ipv4_hdr, + return 0; + } + ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change without prior notice. ++ * ++ * Verify the IPv4 UDP/TCP checksum of a packet. ++ * ++ * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0 ++ * (i.e. no checksum). ++ * ++ * @param m ++ * The pointer to the mbuf. ++ * @param ipv4_hdr ++ * The pointer to the contiguous IPv4 header. ++ * @param l4_off ++ * The offset in bytes to start L4 checksum. ++ * @return ++ * Return 0 if the checksum is correct, else -1. ++ */ ++__rte_experimental ++static inline uint16_t ++rte_ipv4_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m, ++ const struct rte_ipv4_hdr *ipv4_hdr, ++ uint16_t l4_off) ++{ ++ uint16_t cksum = __rte_ipv4_udptcp_cksum_mbuf(m, ipv4_hdr, l4_off); ++ ++ if (cksum != 0xffff) ++ return -1; ++ ++ return 0; ++} ++ + /** + * IPv6 Header + */ +@@ -538,6 +629,68 @@ rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) + return cksum; + } + ++/** ++ * @internal Calculate the non-complemented IPv6 L4 checksum of a packet ++ */ ++static inline uint16_t ++__rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m, ++ const struct rte_ipv6_hdr *ipv6_hdr, ++ uint16_t l4_off) ++{ ++ uint16_t raw_cksum; ++ uint32_t cksum; ++ ++ if (l4_off > m->pkt_len) ++ return 0; ++ ++ if (rte_raw_cksum_mbuf(m, l4_off, m->pkt_len - l4_off, &raw_cksum)) ++ return 0; ++ ++ cksum = raw_cksum + rte_ipv6_phdr_cksum(ipv6_hdr, 0); ++ ++ cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); ++ ++ return (uint16_t)cksum; ++} ++ ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change without prior notice. ++ * ++ * Process the IPv6 UDP or TCP checksum of a packet. ++ * ++ * The IPv6 header must not be followed by extension headers. The layer 4 ++ * checksum must be set to 0 in the L4 header by the caller. ++ * ++ * @param m ++ * The pointer to the mbuf. ++ * @param ipv6_hdr ++ * The pointer to the contiguous IPv6 header. ++ * @param l4_off ++ * The offset in bytes to start L4 checksum. ++ * @return ++ * The complemented checksum to set in the L4 header. ++ */ ++__rte_experimental ++static inline uint16_t ++rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m, ++ const struct rte_ipv6_hdr *ipv6_hdr, uint16_t l4_off) ++{ ++ uint16_t cksum = __rte_ipv6_udptcp_cksum_mbuf(m, ipv6_hdr, l4_off); ++ ++ cksum = ~cksum; ++ ++ /* ++ * Per RFC 768: If the computed checksum is zero for UDP, ++ * it is transmitted as all ones ++ * (the equivalent in one's complement arithmetic). ++ */ ++ if (cksum == 0 && ipv6_hdr->proto == IPPROTO_UDP) ++ cksum = 0xffff; ++ ++ return cksum; ++} ++ + /** + * Validate the IPv6 UDP or TCP checksum. + * +@@ -565,6 +718,39 @@ rte_ipv6_udptcp_cksum_verify(const struct rte_ipv6_hdr *ipv6_hdr, + return 0; + } + ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change without prior notice. ++ * ++ * Validate the IPv6 UDP or TCP checksum of a packet. ++ * ++ * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0: ++ * this is either invalid or means no checksum in some situations. See 8.1 ++ * (Upper-Layer Checksums) in RFC 8200. ++ * ++ * @param m ++ * The pointer to the mbuf. ++ * @param ipv6_hdr ++ * The pointer to the contiguous IPv6 header. ++ * @param l4_off ++ * The offset in bytes to start L4 checksum. ++ * @return ++ * Return 0 if the checksum is correct, else -1. ++ */ ++__rte_experimental ++static inline int ++rte_ipv6_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m, ++ const struct rte_ipv6_hdr *ipv6_hdr, ++ uint16_t l4_off) ++{ ++ uint16_t cksum = __rte_ipv6_udptcp_cksum_mbuf(m, ipv6_hdr, l4_off); ++ ++ if (cksum != 0xffff) ++ return -1; ++ ++ return 0; ++} ++ + /** IPv6 fragment extension header. */ + #define RTE_IPV6_EHDR_MF_SHIFT 0 + #define RTE_IPV6_EHDR_MF_MASK 1 +-- +2.23.0 + diff --git a/0202-app-testpmd-add-SW-L4-checksum-in-multi-segments.patch b/0202-app-testpmd-add-SW-L4-checksum-in-multi-segments.patch new file mode 100644 index 0000000..dcbe38e --- /dev/null +++ b/0202-app-testpmd-add-SW-L4-checksum-in-multi-segments.patch @@ -0,0 +1,137 @@ +From 2f89f906acfed6fe476f84875bbe1f2c53b8f31a Mon Sep 17 00:00:00 2001 +From: Xiaoyun Li +Date: Tue, 15 Nov 2022 12:06:13 +0800 +Subject: app/testpmd: add SW L4 checksum in multi-segments + +[ upstream commit e6b9d6411e91be7289409238f05ad1c09e8a0d05 ] + +Csum forwarding mode only supports software UDP/TCP csum calculation +for single segment packets when hardware offload is not enabled. +This patch enables software UDP/TCP csum calculation over multiple +segments. + +Signed-off-by: Xiaoyun Li +Tested-by: Sunil Pai G +Acked-by: Ferruh Yigit +--- + app/test-pmd/csumonly.c | 41 ++++++++++++++++++++++++++--------------- + 1 file changed, 26 insertions(+), 15 deletions(-) + +diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c +index 7c4c04be26..10aab3431b 100644 +--- a/app/test-pmd/csumonly.c ++++ b/app/test-pmd/csumonly.c +@@ -96,12 +96,13 @@ struct simple_gre_hdr { + } __rte_packed; + + static uint16_t +-get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) ++get_udptcp_checksum(struct rte_mbuf *m, void *l3_hdr, uint16_t l4_off, ++ uint16_t ethertype) + { + if (ethertype == _htons(RTE_ETHER_TYPE_IPV4)) +- return rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr); ++ return rte_ipv4_udptcp_cksum_mbuf(m, l3_hdr, l4_off); + else /* assume ethertype == RTE_ETHER_TYPE_IPV6 */ +- return rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); ++ return rte_ipv6_udptcp_cksum_mbuf(m, l3_hdr, l4_off); + } + + /* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ +@@ -458,7 +459,7 @@ parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info) + * depending on the testpmd command line configuration */ + static uint64_t + process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, +- uint64_t tx_offloads) ++ uint64_t tx_offloads, struct rte_mbuf *m) + { + struct rte_ipv4_hdr *ipv4_hdr = l3_hdr; + struct rte_udp_hdr *udp_hdr; +@@ -466,6 +467,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + struct rte_sctp_hdr *sctp_hdr; + uint64_t ol_flags = 0; + uint32_t max_pkt_len, tso_segsz = 0; ++ uint16_t l4_off; + + /* ensure packet is large enough to require tso */ + if (!info->is_tunnel) { +@@ -508,9 +510,15 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + if (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) { + ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM; + } else { ++ if (info->is_tunnel) ++ l4_off = info->l2_len + ++ info->outer_l3_len + ++ info->l2_len + info->l3_len; ++ else ++ l4_off = info->l2_len + info->l3_len; + udp_hdr->dgram_cksum = 0; + udp_hdr->dgram_cksum = +- get_udptcp_checksum(l3_hdr, udp_hdr, ++ get_udptcp_checksum(m, l3_hdr, l4_off, + info->ethertype); + } + } +@@ -525,9 +533,14 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + else if (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) { + ol_flags |= RTE_MBUF_F_TX_TCP_CKSUM; + } else { ++ if (info->is_tunnel) ++ l4_off = info->l2_len + info->outer_l3_len + ++ info->l2_len + info->l3_len; ++ else ++ l4_off = info->l2_len + info->l3_len; + tcp_hdr->cksum = 0; + tcp_hdr->cksum = +- get_udptcp_checksum(l3_hdr, tcp_hdr, ++ get_udptcp_checksum(m, l3_hdr, l4_off, + info->ethertype); + } + #ifdef RTE_LIB_GSO +@@ -555,7 +568,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + /* Calculate the checksum of outer header */ + static uint64_t + process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, +- uint64_t tx_offloads, int tso_enabled) ++ uint64_t tx_offloads, int tso_enabled, struct rte_mbuf *m) + { + struct rte_ipv4_hdr *ipv4_hdr = outer_l3_hdr; + struct rte_ipv6_hdr *ipv6_hdr = outer_l3_hdr; +@@ -609,12 +622,9 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, + /* do not recalculate udp cksum if it was 0 */ + if (udp_hdr->dgram_cksum != 0) { + udp_hdr->dgram_cksum = 0; +- if (info->outer_ethertype == _htons(RTE_ETHER_TYPE_IPV4)) +- udp_hdr->dgram_cksum = +- rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr); +- else +- udp_hdr->dgram_cksum = +- rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr); ++ udp_hdr->dgram_cksum = get_udptcp_checksum(m, outer_l3_hdr, ++ info->l2_len + info->outer_l3_len, ++ info->outer_ethertype); + } + + return ol_flags; +@@ -962,7 +972,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) + + /* process checksums of inner headers first */ + tx_ol_flags |= process_inner_cksums(l3_hdr, &info, +- tx_offloads); ++ tx_offloads, m); + + /* Then process outer headers if any. Note that the software + * checksum will be wrong if one of the inner checksums is +@@ -970,7 +980,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) + if (info.is_tunnel == 1) { + tx_ol_flags |= process_outer_cksums(outer_l3_hdr, &info, + tx_offloads, +- !!(tx_ol_flags & RTE_MBUF_F_TX_TCP_SEG)); ++ !!(tx_ol_flags & RTE_MBUF_F_TX_TCP_SEG), ++ m); + } + + /* step 3: fill the mbuf meta data (flags and header lengths) */ +-- +2.23.0 + diff --git a/0203-app-testpmd-fix-L4-checksum-in-multi-segments.patch b/0203-app-testpmd-fix-L4-checksum-in-multi-segments.patch new file mode 100644 index 0000000..2640687 --- /dev/null +++ b/0203-app-testpmd-fix-L4-checksum-in-multi-segments.patch @@ -0,0 +1,59 @@ +From e6b89f7ed49494302ef1e9cd852281c808f5b14f Mon Sep 17 00:00:00 2001 +From: Kevin Liu +Date: Tue, 15 Nov 2022 12:06:14 +0800 +Subject: app/testpmd: fix L4 checksum in multi-segments + +[ upstream commit 7dc92d17298d8fd05a912606f02a094566ec0b3f ] + +Testpmd forwards packets in checksum mode that it needs to calculate +the checksum of each layer's protocol. + +In process_inner_cksums, when parsing tunnel packets, inner L4 offset +should be outer_l2_len + outer_l3_len + l2_len + l3_len. + +In process_outer_cksums, when parsing tunnel packets, outer L4 offset +should be outer_l2_len + outer_l3_len. + +Fixes: e6b9d6411e91 ("app/testpmd: add SW L4 checksum in multi-segments") + +Signed-off-by: Kevin Liu +Acked-by: Yuying Zhang +Acked-by: Aman Singh +--- + app/test-pmd/csumonly.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c +index 10aab3431b..47856dd70a 100644 +--- a/app/test-pmd/csumonly.c ++++ b/app/test-pmd/csumonly.c +@@ -511,7 +511,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM; + } else { + if (info->is_tunnel) +- l4_off = info->l2_len + ++ l4_off = info->outer_l2_len + + info->outer_l3_len + + info->l2_len + info->l3_len; + else +@@ -534,7 +534,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + ol_flags |= RTE_MBUF_F_TX_TCP_CKSUM; + } else { + if (info->is_tunnel) +- l4_off = info->l2_len + info->outer_l3_len + ++ l4_off = info->outer_l2_len + info->outer_l3_len + + info->l2_len + info->l3_len; + else + l4_off = info->l2_len + info->l3_len; +@@ -623,7 +623,7 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, + if (udp_hdr->dgram_cksum != 0) { + udp_hdr->dgram_cksum = 0; + udp_hdr->dgram_cksum = get_udptcp_checksum(m, outer_l3_hdr, +- info->l2_len + info->outer_l3_len, ++ info->outer_l2_len + info->outer_l3_len, + info->outer_ethertype); + } + +-- +2.23.0 + diff --git a/0204-net-bonding-fix-mbuf-fast-free-handling.patch b/0204-net-bonding-fix-mbuf-fast-free-handling.patch new file mode 100644 index 0000000..73b5613 --- /dev/null +++ b/0204-net-bonding-fix-mbuf-fast-free-handling.patch @@ -0,0 +1,73 @@ +From c90a36013ccaeeb3baf258e4e23120253faee7aa Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 15 Nov 2022 12:06:15 +0800 +Subject: net/bonding: fix mbuf fast free handling + +[ upstream commit b4924c0db589b5d4698abfab3ce60978d9df518b ] + +The RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE offload can't be used in bonding +mode Broadcast and mode 8023AD. Currently, bonding driver forcibly removes +from the dev->data->dev_conf.txmode.offloads and processes as success in +bond_ethdev_configure(). But this still cause that rte_eth_dev_configure() +fails to execute because of the failure of validating Tx offload in the +eth_dev_validate_offloads(). So this patch moves the modification of txmode +offlaods to the stage of adding slave device to report the correct txmode +offloads. + +Fixes: 18c41457cbae ("net/bonding: fix mbuf fast free usage") + +Signed-off-by: Huisong Li +Acked-by: Stephen Hemminger +--- + drivers/net/bonding/rte_eth_bond_api.c | 5 +++++ + drivers/net/bonding/rte_eth_bond_pmd.c | 11 ----------- + 2 files changed, 5 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c +index b74477128a..1235573bf2 100644 +--- a/drivers/net/bonding/rte_eth_bond_api.c ++++ b/drivers/net/bonding/rte_eth_bond_api.c +@@ -544,6 +544,11 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) + return ret; + } + ++ /* Bond mode Broadcast & 8023AD don't support MBUF_FAST_FREE offload. */ ++ if (internals->mode == BONDING_MODE_8023AD || ++ internals->mode == BONDING_MODE_BROADCAST) ++ internals->tx_offload_capa &= ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; ++ + bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &= + internals->flow_type_rss_offloads; + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 2bf28b829d..29871cf8a3 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -3600,7 +3600,6 @@ bond_ethdev_configure(struct rte_eth_dev *dev) + const char *name = dev->device->name; + struct bond_dev_private *internals = dev->data->dev_private; + struct rte_kvargs *kvlist = internals->kvlist; +- uint64_t offloads; + int arg_count; + uint16_t port_id = dev - rte_eth_devices; + uint32_t link_speeds; +@@ -3652,16 +3651,6 @@ bond_ethdev_configure(struct rte_eth_dev *dev) + } + } + +- offloads = dev->data->dev_conf.txmode.offloads; +- if ((offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) && +- (internals->mode == BONDING_MODE_8023AD || +- internals->mode == BONDING_MODE_BROADCAST)) { +- RTE_BOND_LOG(WARNING, +- "bond mode broadcast & 8023AD don't support MBUF_FAST_FREE offload, force disable it."); +- offloads &= ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; +- dev->data->dev_conf.txmode.offloads = offloads; +- } +- + link_speeds = dev->data->dev_conf.link_speeds; + /* + * The default value of 'link_speeds' is zero. From its definition, +-- +2.23.0 + diff --git a/0205-doc-fix-application-name-in-procinfo-guide.patch b/0205-doc-fix-application-name-in-procinfo-guide.patch new file mode 100644 index 0000000..a733689 --- /dev/null +++ b/0205-doc-fix-application-name-in-procinfo-guide.patch @@ -0,0 +1,71 @@ +From 3ebc362fe3f70616922d46f3959c1e6d63cf76dc Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Tue, 11 Oct 2022 19:18:43 +0800 +Subject: doc: fix application name in procinfo guide + +[ upstream commit 2a65f12f6ab461e2cb81192c6bdd136191c82ea9 ] + +In commit 996ef1176111 ("app: add all remaining apps to meson build"), +building the procinfo application through Meson has been done with a +binary name different from the previous Makefile build system [1]. + +When we dropped Makefile support, the documentation was not updated. + +Fixes: 3cc6ecfdfe85 ("build: remove makefiles") +Cc: stable@dpdk.org + +Signed-off-by: Dongdong Liu +Signed-off-by: David Marchand +--- + doc/guides/tools/proc_info.rst | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst +index 9772d97ef0..e4f0c83f1b 100644 +--- a/doc/guides/tools/proc_info.rst ++++ b/doc/guides/tools/proc_info.rst +@@ -1,10 +1,10 @@ + .. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2015 Intel Corporation. + +-dpdk-procinfo Application +-========================= ++dpdk-proc-info Application ++========================== + +-The dpdk-procinfo application is a Data Plane Development Kit (DPDK) application ++The dpdk-proc-info application is a Data Plane Development Kit (DPDK) application + that runs as a DPDK secondary process and is capable of retrieving port + statistics, resetting port statistics, printing DPDK memory information and + displaying debug information for port. +@@ -17,7 +17,7 @@ The application has a number of command line options: + + .. code-block:: console + +- .//app/dpdk-procinfo -- -m | [-p PORTMASK] [--stats | --xstats | ++ .//app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats | + --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto | + --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name ] + +@@ -72,14 +72,14 @@ by name. For invalid or no mempool name no elements are displayed. + Limitations + ----------- + +-* dpdk-procinfo should run alongside primary process with same DPDK version. ++* dpdk-proc-info should run alongside primary process with same DPDK version. + +-* When running ``dpdk-procinfo`` with shared library mode, it is required to ++* When running ``dpdk-proc-info`` with shared library mode, it is required to + pass the same NIC PMD libraries as used for the primary application. Any + mismatch in PMD library arguments can lead to undefined behavior and results + affecting primary application too. + +-* Stats retrieval using ``dpdk-procinfo`` is not supported for virtual devices like PCAP and TAP. ++* Stats retrieval using ``dpdk-proc-info`` is not supported for virtual devices like PCAP and TAP. + +-* Since default DPDK EAL arguments for ``dpdk-procinfo`` are ``-c1, -n4 & --proc-type=secondary``, ++* Since default DPDK EAL arguments for ``dpdk-proc-info`` are ``-c1, -n4 & --proc-type=secondary``, + It is not expected that the user passes any EAL arguments. +-- +2.23.0 + diff --git a/0206-doc-document-device-dump-in-procinfo-guide.patch b/0206-doc-document-device-dump-in-procinfo-guide.patch new file mode 100644 index 0000000..b0c5617 --- /dev/null +++ b/0206-doc-document-device-dump-in-procinfo-guide.patch @@ -0,0 +1,44 @@ +From 245e4f0da830830c6ca9b59ce9eb2f7d9ba6e0a5 Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Tue, 11 Oct 2022 19:18:43 +0800 +Subject: doc: document device dump in procinfo guide + +[ upstream commit dd2658f8d0e4725f579ff098f1ee159d897d6abc ] + +The --show-port-private option was not documented. + +Fixes: bb947a7264da ("app/procinfo: dump device private info") + +Signed-off-by: Dongdong Liu +Signed-off-by: David Marchand +--- + doc/guides/tools/proc_info.rst | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst +index e4f0c83f1b..5dd6f9ecae 100644 +--- a/doc/guides/tools/proc_info.rst ++++ b/doc/guides/tools/proc_info.rst +@@ -19,7 +19,8 @@ The application has a number of command line options: + + .//app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats | + --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto | +- --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name ] ++ --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name | ++ --show-port-private ] + + Parameters + ~~~~~~~~~~ +@@ -69,6 +70,9 @@ mempool. For invalid or no mempool name, whole list is dump. + The iter-mempool parameter iterates and displays mempool elements specified + by name. For invalid or no mempool name no elements are displayed. + ++**--show-port-private** ++The show-port-private parameter displays ports private information. ++ + Limitations + ----------- + +-- +2.23.0 + diff --git a/0207-app-procinfo-remove-doxygen-comments.patch b/0207-app-procinfo-remove-doxygen-comments.patch new file mode 100644 index 0000000..1de48ed --- /dev/null +++ b/0207-app-procinfo-remove-doxygen-comments.patch @@ -0,0 +1,108 @@ +From 85da70e47d6f94ddaf88625b87e1ba9144c2df1d Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Tue, 11 Oct 2022 19:18:41 +0800 +Subject: app/procinfo: remove doxygen comments + +[ upstream commit 797f2f510ce10fd049f4815bd7cce9bc19c460be ] + +This code is to do cleanup for the wrong doxygen syntax comments +The DPDK API is documented using doxygen comment annotations in the +header files. The procinfo code seems no need to use doxygen comment. + +Signed-off-by: Dongdong Liu +Acked-by: Reshma Pattan +--- + app/proc-info/main.c | 42 +++++++++++++++++++++--------------------- + 1 file changed, 21 insertions(+), 21 deletions(-) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index accb5e716d..a75a1aa9bd 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -48,33 +48,33 @@ + #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \ + STATS_BDR_FMT, s, w, STATS_BDR_FMT) + +-/**< mask of enabled ports */ ++/* mask of enabled ports */ + static unsigned long enabled_port_mask; +-/**< Enable stats. */ ++/* Enable stats. */ + static uint32_t enable_stats; +-/**< Enable xstats. */ ++/* Enable xstats. */ + static uint32_t enable_xstats; +-/**< Enable collectd format*/ ++/* Enable collectd format */ + static uint32_t enable_collectd_format; +-/**< FD to send collectd format messages to STDOUT*/ ++/* FD to send collectd format messages to STDOUT */ + static int stdout_fd; +-/**< Host id process is running on */ ++/* Host id process is running on */ + static char host_id[MAX_LONG_OPT_SZ]; + #ifdef RTE_LIB_METRICS +-/**< Enable metrics. */ ++/* Enable metrics. */ + static uint32_t enable_metrics; + #endif +-/**< Enable stats reset. */ ++/* Enable stats reset. */ + static uint32_t reset_stats; +-/**< Enable xstats reset. */ ++/* Enable xstats reset. */ + static uint32_t reset_xstats; +-/**< Enable memory info. */ ++/* Enable memory info. */ + static uint32_t mem_info; +-/**< Enable displaying xstat name. */ ++/* Enable displaying xstat name. */ + static uint32_t enable_xstats_name; + static char *xstats_name; + +-/**< Enable xstats by ids. */ ++/* Enable xstats by ids. */ + #define MAX_NB_XSTATS_IDS 1024 + static uint32_t nb_xstats_ids; + static uint64_t xstats_ids[MAX_NB_XSTATS_IDS]; +@@ -82,28 +82,28 @@ static uint64_t xstats_ids[MAX_NB_XSTATS_IDS]; + /* show border */ + static char bdr_str[MAX_STRING_LEN]; + +-/**< Enable show port. */ ++/* Enable show port. */ + static uint32_t enable_shw_port; +-/**< Enable show port private info. */ ++/* Enable show port private info. */ + static uint32_t enable_shw_port_priv; +-/**< Enable show tm. */ ++/* Enable show tm. */ + static uint32_t enable_shw_tm; +-/**< Enable show crypto. */ ++/* Enable show crypto. */ + static uint32_t enable_shw_crypto; +-/**< Enable show ring. */ ++/* Enable show ring. */ + static uint32_t enable_shw_ring; + static char *ring_name; +-/**< Enable show mempool. */ ++/* Enable show mempool. */ + static uint32_t enable_shw_mempool; + static char *mempool_name; +-/**< Enable iter mempool. */ ++/* Enable iter mempool. */ + static uint32_t enable_iter_mempool; + static char *mempool_iter_name; +-/**< Enable dump regs. */ ++/* Enable dump regs. */ + static uint32_t enable_dump_regs; + static char *dump_regs_file_prefix; + +-/**< display usage */ ++/* display usage */ + static void + proc_info_usage(const char *prgname) + { +-- +2.23.0 + diff --git a/0208-app-procinfo-dump-DPDK-version.patch b/0208-app-procinfo-dump-DPDK-version.patch new file mode 100644 index 0000000..f82e2dc --- /dev/null +++ b/0208-app-procinfo-dump-DPDK-version.patch @@ -0,0 +1,118 @@ +From 1cc631c496d706bfc02cf776ef403b0c22bfede3 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Tue, 11 Oct 2022 19:18:36 +0800 +Subject: app/procinfo: dump DPDK version + +[ upstream commit 4778a8ec8bcf453f039b0663534cc37cb5367b43 ] + +Add support for dump dpdk version. + +The command is like: +dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- --version + +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Reshma Pattan +--- + app/proc-info/main.c | 19 ++++++++++++++++++- + doc/guides/tools/proc_info.rst | 5 ++++- + 2 files changed, 22 insertions(+), 2 deletions(-) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index a75a1aa9bd..651d678cd1 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -39,6 +39,7 @@ + #include + #include + #include ++#include + + /* Maximum long option length for option parsing. */ + #define MAX_LONG_OPT_SZ 64 +@@ -102,6 +103,8 @@ static char *mempool_iter_name; + /* Enable dump regs. */ + static uint32_t enable_dump_regs; + static char *dump_regs_file_prefix; ++/* Enable show DPDK version. */ ++static uint32_t enable_shw_version; + + /* display usage */ + static void +@@ -130,6 +133,7 @@ proc_info_usage(const char *prgname) + " --show-crypto: to display crypto information\n" + " --show-ring[=name]: to display ring information\n" + " --show-mempool[=name]: to display mempool information\n" ++ " --version: to display DPDK version\n" + " --iter-mempool=name: iterate mempool elements to display content\n" + " --dump-regs=file-prefix: dump registers to file with the file-prefix\n", + prgname); +@@ -242,6 +246,7 @@ proc_info_parse_args(int argc, char **argv) + {"show-mempool", optional_argument, NULL, 0}, + {"iter-mempool", required_argument, NULL, 0}, + {"dump-regs", required_argument, NULL, 0}, ++ {"version", 0, NULL, 0}, + {NULL, 0, 0, 0} + }; + +@@ -313,7 +318,9 @@ proc_info_parse_args(int argc, char **argv) + "dump-regs", MAX_LONG_OPT_SZ)) { + enable_dump_regs = 1; + dump_regs_file_prefix = optarg; +- } ++ } else if (!strncmp(long_option[option_index].name, ++ "version", MAX_LONG_OPT_SZ)) ++ enable_shw_version = 1; + break; + case 1: + /* Print xstat single value given by name*/ +@@ -1476,6 +1483,14 @@ dump_regs(char *file_prefix) + } + } + ++static void ++show_version(void) ++{ ++ snprintf(bdr_str, MAX_STRING_LEN, " show - DPDK version "); ++ STATS_BDR_STR(10, bdr_str); ++ printf("DPDK version: %s\n", rte_version()); ++} ++ + int + main(int argc, char **argv) + { +@@ -1589,6 +1604,8 @@ main(int argc, char **argv) + iter_mempool(mempool_iter_name); + if (enable_dump_regs) + dump_regs(dump_regs_file_prefix); ++ if (enable_shw_version) ++ show_version(); + + RTE_ETH_FOREACH_DEV(i) + rte_eth_dev_close(i); +diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst +index 5dd6f9ecae..121142fdd4 100644 +--- a/doc/guides/tools/proc_info.rst ++++ b/doc/guides/tools/proc_info.rst +@@ -20,7 +20,7 @@ The application has a number of command line options: + .//app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats | + --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto | + --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name | +- --show-port-private ] ++ --show-port-private | --version ] + + Parameters + ~~~~~~~~~~ +@@ -73,6 +73,9 @@ by name. For invalid or no mempool name no elements are displayed. + **--show-port-private** + The show-port-private parameter displays ports private information. + ++**--version** ++The version parameter displays DPDK version. ++ + Limitations + ----------- + +-- +2.23.0 + diff --git a/0209-app-procinfo-dump-firmware-version.patch b/0209-app-procinfo-dump-firmware-version.patch new file mode 100644 index 0000000..865bdc7 --- /dev/null +++ b/0209-app-procinfo-dump-firmware-version.patch @@ -0,0 +1,134 @@ +From a9114b29e2916f51faac5923cab0a12c34749d10 Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Tue, 11 Oct 2022 19:18:37 +0800 +Subject: app/procinfo: dump firmware version + +[ upstream commit 37ebf5ab67d7ef4b532819de47ab780dded655e4 ] + +Add support for dump ethdev firmware version. + +The command is like: +dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- --firmware-version + +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Reshma Pattan +--- + app/proc-info/main.c | 35 ++++++++++++++++++++++++++++++++++ + doc/guides/tools/proc_info.rst | 5 ++++- + 2 files changed, 39 insertions(+), 1 deletion(-) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index 651d678cd1..351c55896b 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -45,6 +45,8 @@ + #define MAX_LONG_OPT_SZ 64 + #define MAX_STRING_LEN 256 + ++#define ETHDEV_FWVERS_LEN 32 ++ + #define STATS_BDR_FMT "========================================" + #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \ + STATS_BDR_FMT, s, w, STATS_BDR_FMT) +@@ -105,6 +107,8 @@ static uint32_t enable_dump_regs; + static char *dump_regs_file_prefix; + /* Enable show DPDK version. */ + static uint32_t enable_shw_version; ++/* Enable show ethdev firmware version. */ ++static uint32_t enable_shw_fw_version; + + /* display usage */ + static void +@@ -134,6 +138,7 @@ proc_info_usage(const char *prgname) + " --show-ring[=name]: to display ring information\n" + " --show-mempool[=name]: to display mempool information\n" + " --version: to display DPDK version\n" ++ " --firmware-version: to display ethdev firmware version\n" + " --iter-mempool=name: iterate mempool elements to display content\n" + " --dump-regs=file-prefix: dump registers to file with the file-prefix\n", + prgname); +@@ -247,6 +252,7 @@ proc_info_parse_args(int argc, char **argv) + {"iter-mempool", required_argument, NULL, 0}, + {"dump-regs", required_argument, NULL, 0}, + {"version", 0, NULL, 0}, ++ {"firmware-version", 0, NULL, 0}, + {NULL, 0, 0, 0} + }; + +@@ -321,6 +327,9 @@ proc_info_parse_args(int argc, char **argv) + } else if (!strncmp(long_option[option_index].name, + "version", MAX_LONG_OPT_SZ)) + enable_shw_version = 1; ++ else if (!strncmp(long_option[option_index].name, ++ "firmware-version", MAX_LONG_OPT_SZ)) ++ enable_shw_fw_version = 1; + break; + case 1: + /* Print xstat single value given by name*/ +@@ -1491,6 +1500,30 @@ show_version(void) + printf("DPDK version: %s\n", rte_version()); + } + ++static void ++show_firmware_version(void) ++{ ++ char fw_version[ETHDEV_FWVERS_LEN]; ++ uint16_t i; ++ ++ snprintf(bdr_str, MAX_STRING_LEN, " show - firmware version "); ++ STATS_BDR_STR(10, bdr_str); ++ ++ RTE_ETH_FOREACH_DEV(i) { ++ /* Skip if port is not in mask */ ++ if ((enabled_port_mask & (1ul << i)) == 0) ++ continue; ++ ++ if (rte_eth_dev_fw_version_get(i, fw_version, ++ ETHDEV_FWVERS_LEN) == 0) ++ printf("Ethdev port %u firmware version: %s\n", i, ++ fw_version); ++ else ++ printf("Ethdev port %u firmware version: %s\n", i, ++ "not available"); ++ } ++} ++ + int + main(int argc, char **argv) + { +@@ -1606,6 +1639,8 @@ main(int argc, char **argv) + dump_regs(dump_regs_file_prefix); + if (enable_shw_version) + show_version(); ++ if (enable_shw_fw_version) ++ show_firmware_version(); + + RTE_ETH_FOREACH_DEV(i) + rte_eth_dev_close(i); +diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst +index 121142fdd4..4eb9fb9249 100644 +--- a/doc/guides/tools/proc_info.rst ++++ b/doc/guides/tools/proc_info.rst +@@ -20,7 +20,7 @@ The application has a number of command line options: + .//app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats | + --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto | + --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name | +- --show-port-private | --version ] ++ --show-port-private | --version | --firmware-version ] + + Parameters + ~~~~~~~~~~ +@@ -76,6 +76,9 @@ The show-port-private parameter displays ports private information. + **--version** + The version parameter displays DPDK version. + ++**--firmware-version** ++The firmware-version parameter displays ethdev firmware version. ++ + Limitations + ----------- + +-- +2.23.0 + diff --git a/0210-app-procinfo-dump-RSS-RETA.patch b/0210-app-procinfo-dump-RSS-RETA.patch new file mode 100644 index 0000000..84c8f64 --- /dev/null +++ b/0210-app-procinfo-dump-RSS-RETA.patch @@ -0,0 +1,156 @@ +From 1ec0e71ea5d6b0fbb5bbe7bcde8bf11f57a708ef Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Tue, 11 Oct 2022 19:18:38 +0800 +Subject: app/procinfo: dump RSS RETA + +[ upstream commit 0cc5126ccfe5b67b60d869d036cf40496f7591d3 ] + +This patch add support for RSS reta dump. + +The command is like: +dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- --show-rss-reta + +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Reshma Pattan +--- + app/proc-info/main.c | 57 ++++++++++++++++++++++++++++++++++ + doc/guides/tools/proc_info.rst | 5 ++- + 2 files changed, 61 insertions(+), 1 deletion(-) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index 351c55896b..efae5c6036 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -46,6 +46,8 @@ + #define MAX_STRING_LEN 256 + + #define ETHDEV_FWVERS_LEN 32 ++#define RTE_RETA_CONF_GROUP_NUM 32 ++#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) + + #define STATS_BDR_FMT "========================================" + #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \ +@@ -109,6 +111,8 @@ static char *dump_regs_file_prefix; + static uint32_t enable_shw_version; + /* Enable show ethdev firmware version. */ + static uint32_t enable_shw_fw_version; ++/* Enable show RSS reta. */ ++static uint32_t enable_shw_rss_reta; + + /* display usage */ + static void +@@ -139,6 +143,7 @@ proc_info_usage(const char *prgname) + " --show-mempool[=name]: to display mempool information\n" + " --version: to display DPDK version\n" + " --firmware-version: to display ethdev firmware version\n" ++ " --show-rss-reta: to display ports redirection table\n" + " --iter-mempool=name: iterate mempool elements to display content\n" + " --dump-regs=file-prefix: dump registers to file with the file-prefix\n", + prgname); +@@ -253,6 +258,7 @@ proc_info_parse_args(int argc, char **argv) + {"dump-regs", required_argument, NULL, 0}, + {"version", 0, NULL, 0}, + {"firmware-version", 0, NULL, 0}, ++ {"show-rss-reta", 0, NULL, 0}, + {NULL, 0, 0, 0} + }; + +@@ -330,6 +336,9 @@ proc_info_parse_args(int argc, char **argv) + else if (!strncmp(long_option[option_index].name, + "firmware-version", MAX_LONG_OPT_SZ)) + enable_shw_fw_version = 1; ++ else if (!strncmp(long_option[option_index].name, ++ "show-rss-reta", MAX_LONG_OPT_SZ)) ++ enable_shw_rss_reta = 1; + break; + case 1: + /* Print xstat single value given by name*/ +@@ -1524,6 +1533,52 @@ show_firmware_version(void) + } + } + ++static void ++show_port_rss_reta_info(void) ++{ ++ struct rte_eth_rss_reta_entry64 reta_conf[RTE_RETA_CONF_GROUP_NUM + 1]; ++ struct rte_eth_dev_info dev_info; ++ uint16_t i, idx, shift; ++ uint16_t num; ++ uint16_t id; ++ int ret; ++ ++ RTE_ETH_FOREACH_DEV(id) { ++ /* Skip if port is not in mask */ ++ if ((enabled_port_mask & (1ul << id)) == 0) ++ continue; ++ ++ snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", id); ++ STATS_BDR_STR(5, bdr_str); ++ ++ ret = rte_eth_dev_info_get(id, &dev_info); ++ if (ret != 0) { ++ fprintf(stderr, "Error getting device info: %s\n", ++ strerror(-ret)); ++ return; ++ } ++ ++ num = DIV_ROUND_UP(dev_info.reta_size, RTE_ETH_RETA_GROUP_SIZE); ++ memset(reta_conf, 0, sizeof(reta_conf)); ++ for (i = 0; i < num; i++) ++ reta_conf[i].mask = ~0ULL; ++ ++ ret = rte_eth_dev_rss_reta_query(id, reta_conf, dev_info.reta_size); ++ if (ret != 0) { ++ fprintf(stderr, "Error getting RSS RETA info: %s\n", ++ strerror(-ret)); ++ return; ++ } ++ ++ for (i = 0; i < dev_info.reta_size; i++) { ++ idx = i / RTE_ETH_RETA_GROUP_SIZE; ++ shift = i % RTE_ETH_RETA_GROUP_SIZE; ++ printf("RSS RETA configuration: hash index=%u, queue=%u\n", ++ i, reta_conf[idx].reta[shift]); ++ } ++ } ++} ++ + int + main(int argc, char **argv) + { +@@ -1641,6 +1696,8 @@ main(int argc, char **argv) + show_version(); + if (enable_shw_fw_version) + show_firmware_version(); ++ if (enable_shw_rss_reta) ++ show_port_rss_reta_info(); + + RTE_ETH_FOREACH_DEV(i) + rte_eth_dev_close(i); +diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst +index 4eb9fb9249..7c8d115fdf 100644 +--- a/doc/guides/tools/proc_info.rst ++++ b/doc/guides/tools/proc_info.rst +@@ -20,7 +20,7 @@ The application has a number of command line options: + .//app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats | + --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto | + --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name | +- --show-port-private | --version | --firmware-version ] ++ --show-port-private | --version | --firmware-version | --show-rss-reta ] + + Parameters + ~~~~~~~~~~ +@@ -79,6 +79,9 @@ The version parameter displays DPDK version. + **--firmware-version** + The firmware-version parameter displays ethdev firmware version. + ++**--show-rss-reta** ++The show-rss-reta parameter displays ports rss redirection table. ++ + Limitations + ----------- + +-- +2.23.0 + diff --git a/0211-app-procinfo-dump-module-EEPROM-info.patch b/0211-app-procinfo-dump-module-EEPROM-info.patch new file mode 100644 index 0000000..fa5d3a7 --- /dev/null +++ b/0211-app-procinfo-dump-module-EEPROM-info.patch @@ -0,0 +1,152 @@ +From 24094ec56e38b32eb2d8bab9822a9fb1355a5ef4 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Tue, 11 Oct 2022 19:18:39 +0800 +Subject: app/procinfo: dump module EEPROM info + +[ upstream commit 0084463ea0042f15b3ef50d9e4c47dbe4d3704b1 ] + +This patch add support for module eeprom info dump. + +The command is like: +dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- --show-module-eeprom + +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Reshma Pattan +--- + app/proc-info/main.c | 52 ++++++++++++++++++++++++++++++++++ + doc/guides/tools/proc_info.rst | 6 +++- + 2 files changed, 57 insertions(+), 1 deletion(-) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index efae5c6036..2d12644543 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -48,6 +48,7 @@ + #define ETHDEV_FWVERS_LEN 32 + #define RTE_RETA_CONF_GROUP_NUM 32 + #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) ++#define EEPROM_DUMP_CHUNKSIZE 1024 + + #define STATS_BDR_FMT "========================================" + #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \ +@@ -113,6 +114,8 @@ static uint32_t enable_shw_version; + static uint32_t enable_shw_fw_version; + /* Enable show RSS reta. */ + static uint32_t enable_shw_rss_reta; ++/* Enable show module eeprom information. */ ++static uint32_t enable_shw_module_eeprom; + + /* display usage */ + static void +@@ -144,6 +147,7 @@ proc_info_usage(const char *prgname) + " --version: to display DPDK version\n" + " --firmware-version: to display ethdev firmware version\n" + " --show-rss-reta: to display ports redirection table\n" ++ " --show-module-eeprom: to display ports module eeprom information\n" + " --iter-mempool=name: iterate mempool elements to display content\n" + " --dump-regs=file-prefix: dump registers to file with the file-prefix\n", + prgname); +@@ -259,6 +263,7 @@ proc_info_parse_args(int argc, char **argv) + {"version", 0, NULL, 0}, + {"firmware-version", 0, NULL, 0}, + {"show-rss-reta", 0, NULL, 0}, ++ {"show-module-eeprom", 0, NULL, 0}, + {NULL, 0, 0, 0} + }; + +@@ -339,6 +344,9 @@ proc_info_parse_args(int argc, char **argv) + else if (!strncmp(long_option[option_index].name, + "show-rss-reta", MAX_LONG_OPT_SZ)) + enable_shw_rss_reta = 1; ++ else if (!strncmp(long_option[option_index].name, ++ "show-module-eeprom", MAX_LONG_OPT_SZ)) ++ enable_shw_module_eeprom = 1; + break; + case 1: + /* Print xstat single value given by name*/ +@@ -1579,6 +1587,48 @@ show_port_rss_reta_info(void) + } + } + ++static void ++show_module_eeprom_info(void) ++{ ++ unsigned char bytes_eeprom[EEPROM_DUMP_CHUNKSIZE]; ++ struct rte_eth_dev_module_info module_info; ++ struct rte_dev_eeprom_info eeprom_info; ++ uint16_t i; ++ int ret; ++ ++ RTE_ETH_FOREACH_DEV(i) { ++ /* Skip if port is not in mask */ ++ if ((enabled_port_mask & (1ul << i)) == 0) ++ continue; ++ ++ snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i); ++ STATS_BDR_STR(5, bdr_str); ++ ++ ret = rte_eth_dev_get_module_info(i, &module_info); ++ if (ret != 0) { ++ fprintf(stderr, "Module EEPROM information read error: %s\n", ++ strerror(-ret)); ++ return; ++ } ++ ++ eeprom_info.offset = 0; ++ eeprom_info.length = module_info.eeprom_len; ++ eeprom_info.data = bytes_eeprom; ++ ++ ret = rte_eth_dev_get_module_eeprom(i, &eeprom_info); ++ if (ret != 0) { ++ fprintf(stderr, "Module EEPROM read error: %s\n", ++ strerror(-ret)); ++ return; ++ } ++ ++ rte_hexdump(stdout, "hexdump", eeprom_info.data, ++ eeprom_info.length); ++ printf("Finish -- Port: %u MODULE EEPROM length: %d bytes\n", ++ i, eeprom_info.length); ++ } ++} ++ + int + main(int argc, char **argv) + { +@@ -1698,6 +1748,8 @@ main(int argc, char **argv) + show_firmware_version(); + if (enable_shw_rss_reta) + show_port_rss_reta_info(); ++ if (enable_shw_module_eeprom) ++ show_module_eeprom_info(); + + RTE_ETH_FOREACH_DEV(i) + rte_eth_dev_close(i); +diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst +index 7c8d115fdf..dc5d017cff 100644 +--- a/doc/guides/tools/proc_info.rst ++++ b/doc/guides/tools/proc_info.rst +@@ -20,7 +20,8 @@ The application has a number of command line options: + .//app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats | + --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto | + --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name | +- --show-port-private | --version | --firmware-version | --show-rss-reta ] ++ --show-port-private | --version | --firmware-version | --show-rss-reta | ++ --show-module-eeprom ] + + Parameters + ~~~~~~~~~~ +@@ -82,6 +83,9 @@ The firmware-version parameter displays ethdev firmware version. + **--show-rss-reta** + The show-rss-reta parameter displays ports rss redirection table. + ++**--show-module-eeprom** ++The show-module-eeprom parameter displays ports module eeprom information. ++ + Limitations + ----------- + +-- +2.23.0 + diff --git a/0212-app-procinfo-add-burst-mode-to-Rx-Tx-queue-info.patch b/0212-app-procinfo-add-burst-mode-to-Rx-Tx-queue-info.patch new file mode 100644 index 0000000..9889d3d --- /dev/null +++ b/0212-app-procinfo-add-burst-mode-to-Rx-Tx-queue-info.patch @@ -0,0 +1,76 @@ +From cf883e9e107e5f646ab8cb41c50e0cd0ab41b3ce Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Tue, 11 Oct 2022 19:18:40 +0800 +Subject: app/procinfo: add burst mode to Rx/Tx queue info + +[ upstream commit a6d81dc0326aae58ea377fc1dc3d62f6bad4ad94 ] + +Add dump of Rx/Tx burst mode in --show-port. + +Sample output changes: + - rx queue +- -- 0 descriptors 0/1024 drop_en rx buffer size 2048 \ + mempool mb_pool_0 socket 0 ++ -- 0 descriptors 0/1024 drop_en rx buffer size 2048 \ + mempool mb_pool_0 socket 0 burst mode : Vector Neon + - tx queue +- -- 0 descriptors 1024 thresh 32/928 \ + offloads : MBUF_FAST_FREE ++ -- 0 descriptors 1024 thresh 32/928 \ + offloads : MBUF_FAST_FREE burst mode : Scalar + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +Acked-by: Reshma Pattan +--- + app/proc-info/main.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index 2d12644543..dc948c7cc5 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -845,6 +845,7 @@ show_port(void) + + for (j = 0; j < dev_info.nb_rx_queues; j++) { + struct rte_eth_rxq_info queue_info; ++ struct rte_eth_burst_mode mode; + int count; + + ret = rte_eth_rx_queue_info_get(i, j, &queue_info); +@@ -880,11 +881,18 @@ show_port(void) + if (queue_info.conf.offloads != 0) + show_offloads(queue_info.conf.offloads, rte_eth_dev_rx_offload_name); + ++ if (rte_eth_rx_burst_mode_get(i, j, &mode) == 0) ++ printf(" burst mode : %s%s", ++ mode.info, ++ mode.flags & RTE_ETH_BURST_FLAG_PER_QUEUE ? ++ " (per queue)" : ""); ++ + printf("\n"); + } + + for (j = 0; j < dev_info.nb_tx_queues; j++) { + struct rte_eth_txq_info queue_info; ++ struct rte_eth_burst_mode mode; + + ret = rte_eth_tx_queue_info_get(i, j, &queue_info); + if (ret != 0) +@@ -905,6 +913,13 @@ show_port(void) + + if (queue_info.conf.offloads != 0) + show_offloads(queue_info.conf.offloads, rte_eth_dev_tx_offload_name); ++ ++ if (rte_eth_tx_burst_mode_get(i, j, &mode) == 0) ++ printf(" burst mode : %s%s", ++ mode.info, ++ mode.flags & RTE_ETH_BURST_FLAG_PER_QUEUE ? ++ " (per queue)" : ""); ++ + printf("\n"); + } + +-- +2.23.0 + diff --git a/0213-app-procinfo-dump-detailed-info-for-Rx-Tx-descriptor.patch b/0213-app-procinfo-dump-detailed-info-for-Rx-Tx-descriptor.patch new file mode 100644 index 0000000..4489047 --- /dev/null +++ b/0213-app-procinfo-dump-detailed-info-for-Rx-Tx-descriptor.patch @@ -0,0 +1,223 @@ +From 95af4fb4b6c89c9488637920c497849b9ffb1bc6 Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Tue, 11 Oct 2022 19:18:42 +0800 +Subject: app/procinfo: dump detailed info for Rx/Tx descriptors + +[ upstream commit 6ff065b221b1048e27a0c9a9438d0f11e6fae06d ] + +This patch support Rx/Tx descriptor dump + +The command is like: +dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- +--show-rx-descriptor queue_id:offset:num + +dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- +--show-tx-descriptor queue_id:offset:num + +queue_id: A queue identifier on this port. +offset: The offset of the descriptor starting from tail. +num: The number of the descriptors to dump. + +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Reshma Pattan +--- + app/proc-info/main.c | 104 +++++++++++++++++++++++++++++++++ + doc/guides/tools/proc_info.rst | 17 +++++- + 2 files changed, 120 insertions(+), 1 deletion(-) + +diff --git a/app/proc-info/main.c b/app/proc-info/main.c +index dc948c7cc5..0cc01e3dad 100644 +--- a/app/proc-info/main.c ++++ b/app/proc-info/main.c +@@ -117,6 +117,21 @@ static uint32_t enable_shw_rss_reta; + /* Enable show module eeprom information. */ + static uint32_t enable_shw_module_eeprom; + ++/* Enable dump Rx/Tx descriptor. */ ++static uint32_t enable_shw_rx_desc_dump; ++static uint32_t enable_shw_tx_desc_dump; ++ ++#define DESC_PARAM_NUM 3 ++ ++struct desc_param { ++ uint16_t queue_id; /* A queue identifier on this port. */ ++ uint16_t offset; /* The offset of the descriptor starting from tail. */ ++ uint16_t num; /* The number of the descriptors to dump. */ ++}; ++ ++static struct desc_param rx_desc_param; ++static struct desc_param tx_desc_param; ++ + /* display usage */ + static void + proc_info_usage(const char *prgname) +@@ -148,6 +163,14 @@ proc_info_usage(const char *prgname) + " --firmware-version: to display ethdev firmware version\n" + " --show-rss-reta: to display ports redirection table\n" + " --show-module-eeprom: to display ports module eeprom information\n" ++ " --show-rx-descriptor queue_id:offset:num to display ports Rx descriptor information. " ++ "queue_id: A Rx queue identifier on this port. " ++ "offset: The offset of the descriptor starting from tail. " ++ "num: The number of the descriptors to dump.\n" ++ " --show-tx-descriptor queue_id:offset:num to display ports Tx descriptor information. " ++ "queue_id: A Tx queue identifier on this port. " ++ "offset: The offset of the descriptor starting from tail. " ++ "num: The number of the descriptors to dump.\n" + " --iter-mempool=name: iterate mempool elements to display content\n" + " --dump-regs=file-prefix: dump registers to file with the file-prefix\n", + prgname); +@@ -200,6 +223,19 @@ parse_xstats_ids(char *list, uint64_t *ids, int limit) { + return length; + } + ++static int ++parse_descriptor_param(char *list, struct desc_param *desc) ++{ ++ int ret; ++ ++ ret = sscanf(list, "%hu:%hu:%hu", &desc->queue_id, &desc->offset, ++ &desc->num); ++ if (ret != DESC_PARAM_NUM) ++ return -EINVAL; ++ ++ return 0; ++} ++ + static int + proc_info_preparse_args(int argc, char **argv) + { +@@ -264,6 +300,8 @@ proc_info_parse_args(int argc, char **argv) + {"firmware-version", 0, NULL, 0}, + {"show-rss-reta", 0, NULL, 0}, + {"show-module-eeprom", 0, NULL, 0}, ++ {"show-rx-descriptor", required_argument, NULL, 1}, ++ {"show-tx-descriptor", required_argument, NULL, 1}, + {NULL, 0, 0, 0} + }; + +@@ -367,6 +405,26 @@ proc_info_parse_args(int argc, char **argv) + return -1; + } + nb_xstats_ids = ret; ++ } else if (!strncmp(long_option[option_index].name, ++ "show-rx-descriptor", MAX_LONG_OPT_SZ)) { ++ int ret = parse_descriptor_param(optarg, ++ &rx_desc_param); ++ if (ret < 0) { ++ fprintf(stderr, "Error parsing Rx descriptor param: %s\n", ++ strerror(-ret)); ++ return -1; ++ } ++ enable_shw_rx_desc_dump = 1; ++ } else if (!strncmp(long_option[option_index].name, ++ "show-tx-descriptor", MAX_LONG_OPT_SZ)) { ++ int ret = parse_descriptor_param(optarg, ++ &tx_desc_param); ++ if (ret < 0) { ++ fprintf(stderr, "Error parsing Tx descriptor param: %s\n", ++ strerror(-ret)); ++ return -1; ++ } ++ enable_shw_tx_desc_dump = 1; + } + break; + default: +@@ -1644,6 +1702,48 @@ show_module_eeprom_info(void) + } + } + ++static void ++nic_rx_descriptor_display(uint16_t port_id, struct desc_param *desc) ++{ ++ uint16_t queue_id = desc->queue_id; ++ uint16_t offset = desc->offset; ++ uint16_t num = desc->num; ++ int ret; ++ ++ snprintf(bdr_str, MAX_STRING_LEN, " show - Rx descriptor "); ++ STATS_BDR_STR(10, bdr_str); ++ ++ printf("Dump ethdev Rx descriptor for port %u, queue %u, offset %u, num %u\n", ++ port_id, queue_id, offset, num); ++ ++ ret = rte_eth_rx_descriptor_dump(port_id, queue_id, offset, num, ++ stdout); ++ if (ret < 0) ++ fprintf(stderr, "Error dumping ethdev Rx descriptor: %s\n", ++ strerror(-ret)); ++} ++ ++static void ++nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc) ++{ ++ uint16_t queue_id = desc->queue_id; ++ uint16_t offset = desc->offset; ++ uint16_t num = desc->num; ++ int ret; ++ ++ snprintf(bdr_str, MAX_STRING_LEN, " show - Tx descriptor "); ++ STATS_BDR_STR(10, bdr_str); ++ ++ printf("Dump ethdev Tx descriptor for port %u, queue %u, offset %u, num %u\n", ++ port_id, queue_id, offset, num); ++ ++ ret = rte_eth_tx_descriptor_dump(port_id, queue_id, offset, num, ++ stdout); ++ if (ret < 0) ++ fprintf(stderr, "Error dumping ethdev Tx descriptor: %s\n", ++ strerror(-ret)); ++} ++ + int + main(int argc, char **argv) + { +@@ -1732,6 +1832,10 @@ main(int argc, char **argv) + metrics_display(i); + #endif + ++ if (enable_shw_rx_desc_dump) ++ nic_rx_descriptor_display(i, &rx_desc_param); ++ if (enable_shw_tx_desc_dump) ++ nic_tx_descriptor_display(i, &tx_desc_param); + } + + #ifdef RTE_LIB_METRICS +diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst +index dc5d017cff..cf3502a8cb 100644 +--- a/doc/guides/tools/proc_info.rst ++++ b/doc/guides/tools/proc_info.rst +@@ -21,7 +21,8 @@ The application has a number of command line options: + --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto | + --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name | + --show-port-private | --version | --firmware-version | --show-rss-reta | +- --show-module-eeprom ] ++ --show-module-eeprom | --show-rx-descriptor queue_id:offset:num | ++ --show-tx-descriptor queue_id:offset:num ] + + Parameters + ~~~~~~~~~~ +@@ -86,6 +87,20 @@ The show-rss-reta parameter displays ports rss redirection table. + **--show-module-eeprom** + The show-module-eeprom parameter displays ports module eeprom information. + ++**--show-rx-descriptor queue_id:offset:num** ++The show-rx-descriptor parameter displays ports Rx descriptor information ++specified by queue_id, offset and num. ++queue_id: A Rx queue identifier on this port. ++offset: The offset of the descriptor starting from tail. ++num: The number of the descriptors to dump. ++ ++**--show-tx-descriptor queue_id:offset:num** ++The show-tx-descriptor parameter displays ports Tx descriptor information ++specified by queue_id, offset and num. ++queue_id: A Tx queue identifier on this port. ++offset: The offset of the descriptor starting from tail. ++num: The number of the descriptors to dump. ++ + Limitations + ----------- + +-- +2.23.0 + diff --git a/0214-dma-hisilicon-support-vchan-status-query.patch b/0214-dma-hisilicon-support-vchan-status-query.patch new file mode 100644 index 0000000..0c7ad0d --- /dev/null +++ b/0214-dma-hisilicon-support-vchan-status-query.patch @@ -0,0 +1,95 @@ +From 400f952c52abac8906cc64c0ef644cb450ef7deb Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 27 May 2022 11:40:55 +0800 +Subject: dma/hisilicon: support vchan status query + +[ upstream commit 157e8326e9ef627dc6bca8110a103496bfb6fd88 ] + +This patch adds support for vchan-status ops. + +Signed-off-by: Chengwen Feng +--- + drivers/dma/hisilicon/hisi_dmadev.c | 30 +++++++++++++++++++++++++++++ + drivers/dma/hisilicon/hisi_dmadev.h | 7 ++++++- + 2 files changed, 36 insertions(+), 1 deletion(-) + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index fbe09284ed..9494b60779 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -461,6 +461,27 @@ hisi_dma_stats_reset(struct rte_dma_dev *dev, uint16_t vchan) + return 0; + } + ++static int ++hisi_dma_vchan_status(const struct rte_dma_dev *dev, uint16_t vchan, ++ enum rte_dma_vchan_status *status) ++{ ++ struct hisi_dma_dev *hw = dev->data->dev_private; ++ uint32_t val; ++ ++ RTE_SET_USED(vchan); ++ ++ val = hisi_dma_read_queue(hw, HISI_DMA_QUEUE_FSM_REG); ++ val = FIELD_GET(HISI_DMA_QUEUE_FSM_STS_M, val); ++ if (val == HISI_DMA_STATE_RUN) ++ *status = RTE_DMA_VCHAN_ACTIVE; ++ else if (val == HISI_DMA_STATE_CPL) ++ *status = RTE_DMA_VCHAN_IDLE; ++ else ++ *status = RTE_DMA_VCHAN_HALTED_ERROR; ++ ++ return 0; ++} ++ + static void + hisi_dma_dump_range(struct hisi_dma_dev *hw, FILE *f, uint32_t start, + uint32_t end) +@@ -816,6 +837,14 @@ hisi_dma_gen_dev_name(const struct rte_pci_device *pci_dev, + * dev_stop| | + * | v + * ------------------ ++ * | CPL | ++ * ------------------ ++ * ^ | ++ * hardware | | ++ * completed all| |dev_submit ++ * descriptors | | ++ * | | ++ * ------------------ + * | RUN | + * ------------------ + * +@@ -829,6 +858,7 @@ static const struct rte_dma_dev_ops hisi_dmadev_ops = { + .vchan_setup = hisi_dma_vchan_setup, + .stats_get = hisi_dma_stats_get, + .stats_reset = hisi_dma_stats_reset, ++ .vchan_status = hisi_dma_vchan_status, + .dev_dump = hisi_dma_dump, + }; + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h +index 90b85322ca..deb1357eea 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.h ++++ b/drivers/dma/hisilicon/hisi_dmadev.h +@@ -132,11 +132,16 @@ enum { + + /** + * In fact, there are multiple states, but it need to pay attention to +- * the following two states for the driver: ++ * the following three states for the driver: + */ + enum { + HISI_DMA_STATE_IDLE = 0, + HISI_DMA_STATE_RUN, ++ /** ++ * All of the submitted descriptor are finished, and the queue ++ * is waiting for new descriptors. ++ */ ++ HISI_DMA_STATE_CPL, + }; + + /** +-- +2.23.0 + diff --git a/0215-kni-fix-build-with-Linux-5.18.patch b/0215-kni-fix-build-with-Linux-5.18.patch new file mode 100644 index 0000000..30822d1 --- /dev/null +++ b/0215-kni-fix-build-with-Linux-5.18.patch @@ -0,0 +1,53 @@ +From 3aeeea257f187e4a05e3a7f70915c82808fb0ee8 Mon Sep 17 00:00:00 2001 +From: Jiri Slaby +Date: Wed, 1 Jun 2022 08:53:58 +0200 +Subject: [PATCH] kni: fix build with Linux 5.18 + +[ upstream commit c98600d4bed6d15599e448990f2ba117ca938a2d ] + +Since commit 2655926aea9b (net: Remove netif_rx_any_context() and +netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() +can be called from any context. So define HAVE_NETIF_RX_NI for older +releases and call the appropriate function in kni_net. + +netif_rx_ni() must be used on older kernel since netif_rx() might +might lead to deadlocks or other problems there. + +Signed-off-by: Jiri Slaby +Reviewed-by: Andrew Rybchenko +--- + kernel/linux/kni/compat.h | 4 ++++ + kernel/linux/kni/kni_net.c | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h +index 664785674f..0db29a4a6f 100644 +--- a/kernel/linux/kni/compat.h ++++ b/kernel/linux/kni/compat.h +@@ -141,3 +141,7 @@ + #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE + #define HAVE_TSK_IN_GUP + #endif ++ ++#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE ++#define HAVE_NETIF_RX_NI ++#endif +diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c +index 29e5b9e21f..a8b092b756 100644 +--- a/kernel/linux/kni/kni_net.c ++++ b/kernel/linux/kni/kni_net.c +@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni) + skb->ip_summed = CHECKSUM_UNNECESSARY; + + /* Call netif interface */ ++#ifdef HAVE_NETIF_RX_NI + netif_rx_ni(skb); ++#else ++ netif_rx(skb); ++#endif + + /* Update statistics */ + dev->stats.rx_bytes += len; +-- +2.23.0 + diff --git a/0216-kni-use-dedicated-function-to-set-random-MAC-address.patch b/0216-kni-use-dedicated-function-to-set-random-MAC-address.patch new file mode 100644 index 0000000..04362df --- /dev/null +++ b/0216-kni-use-dedicated-function-to-set-random-MAC-address.patch @@ -0,0 +1,49 @@ +From 9b7982b9867a3c28728f73678ff9cf497dde72f3 Mon Sep 17 00:00:00 2001 +From: Ke Zhang +Date: Wed, 8 Jun 2022 15:11:16 +0300 +Subject: [PATCH] kni: use dedicated function to set random MAC address +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 2ee8c67ef9399759cb0d3f34b2c9fb6ea0ecc832 ] + +eth_hw_addr_random() sets address type correctly. + +eth_hw_addr_random() is available since Linux v3.4, so +no compat is required. + +Also fix the warning: +warning: passing argument 1 of ‘memcpy’ discards ‘const’ +qualifier from pointer target type + +Variable dev_addr is done const intentionally in Linux v5.17 to +prevent using it directly. + +Fixes: ea6b39b5b847 ("kni: remove ethtool support") + +Signed-off-by: Ke Zhang +Signed-off-by: Andrew Rybchenko +Acked-by: Ferruh Yigit +--- + kernel/linux/kni/kni_misc.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c +index ad1582d911..38fcd7f4f2 100644 +--- a/kernel/linux/kni/kni_misc.c ++++ b/kernel/linux/kni/kni_misc.c +@@ -407,8 +407,8 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, + if (is_valid_ether_addr(dev_info.mac_addr)) + memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN); + else +- /* Generate random MAC address. */ +- eth_random_addr(net_dev->dev_addr); ++ /* Assign random MAC address. */ ++ eth_hw_addr_random(net_dev); + + if (dev_info.mtu) + net_dev->mtu = dev_info.mtu; +-- +2.23.0 + diff --git a/0217-kni-use-dedicated-function-to-set-MAC-address.patch b/0217-kni-use-dedicated-function-to-set-MAC-address.patch new file mode 100644 index 0000000..f001986 --- /dev/null +++ b/0217-kni-use-dedicated-function-to-set-MAC-address.patch @@ -0,0 +1,89 @@ +From 4cfe56040171e791b021d5490f8fd58c55b088fb Mon Sep 17 00:00:00 2001 +From: Ke Zhang +Date: Wed, 8 Jun 2022 15:11:17 +0300 +Subject: [PATCH] kni: use dedicated function to set MAC address +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit b99bd4a0aacab47165d045a6aeee88ee74744600 ] + +The warning info: +warning: passing argument 1 of ‘memcpy’ discards ‘const’ +qualifier from pointer target type + +Variable dev_addr is done const intentionally in v5.17 to prevent using +it directly. See the following Linux kernel changeset for details: + +commit adeef3e32146 ("net: constify netdev->dev_addr") + +Used helper function was introduced earlier in v5.15. + +Fixes: ea6b39b5b847 ("kni: remove ethtool support") + +Signed-off-by: Ke Zhang +Signed-off-by: Andrew Rybchenko +Acked-by: Ferruh Yigit +--- + kernel/linux/kni/compat.h | 4 ++++ + kernel/linux/kni/kni_misc.c | 9 +++++++-- + kernel/linux/kni/kni_net.c | 4 ++++ + 3 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h +index 0db29a4a6f..3a86d12bbc 100644 +--- a/kernel/linux/kni/compat.h ++++ b/kernel/linux/kni/compat.h +@@ -142,6 +142,10 @@ + #define HAVE_TSK_IN_GUP + #endif + ++#if KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE ++#define HAVE_ETH_HW_ADDR_SET ++#endif ++ + #if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE + #define HAVE_NETIF_RX_NI + #endif +diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c +index 38fcd7f4f2..feed12b568 100644 +--- a/kernel/linux/kni/kni_misc.c ++++ b/kernel/linux/kni/kni_misc.c +@@ -404,11 +404,16 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, + pr_debug("mbuf_size: %u\n", kni->mbuf_size); + + /* if user has provided a valid mac address */ +- if (is_valid_ether_addr(dev_info.mac_addr)) ++ if (is_valid_ether_addr(dev_info.mac_addr)) { ++#ifdef HAVE_ETH_HW_ADDR_SET ++ eth_hw_addr_set(net_dev, dev_info.mac_addr); ++#else + memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN); +- else ++#endif ++ } else { + /* Assign random MAC address. */ + eth_hw_addr_random(net_dev); ++ } + + if (dev_info.mtu) + net_dev->mtu = dev_info.mtu; +diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c +index 41805fcabf..779ee3451a 100644 +--- a/kernel/linux/kni/kni_net.c ++++ b/kernel/linux/kni/kni_net.c +@@ -783,7 +783,11 @@ kni_net_set_mac(struct net_device *netdev, void *p) + return -EADDRNOTAVAIL; + + memcpy(req.mac_addr, addr->sa_data, netdev->addr_len); ++#ifdef HAVE_ETH_HW_ADDR_SET ++ eth_hw_addr_set(netdev, addr->sa_data); ++#else + memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); ++#endif + + ret = kni_net_process_request(netdev, &req); + +-- +2.23.0 + diff --git a/0218-linux-igb_uio-fix-build-for-switch-fall-through.patch b/0218-linux-igb_uio-fix-build-for-switch-fall-through.patch new file mode 100644 index 0000000..3ab65bb --- /dev/null +++ b/0218-linux-igb_uio-fix-build-for-switch-fall-through.patch @@ -0,0 +1,78 @@ +From e68a705cc5dc3d1333bbcd722fe4e9a6ba3ee648 Mon Sep 17 00:00:00 2001 +From: Ferruh Yigit +Date: Thu, 16 Dec 2021 12:03:49 +0000 +Subject: [PATCH] linux/igb_uio: fix build for switch fall through + +Linux is using '-Wimplicit-fallthrough=5' compiler option, which doesn't +take any fall through comments into account but only uses compiler +'fallthrough' attribute to document fall through action is intended. + +"falls through" comment was used in the code which is causing a build +error now, this patch converts comment to the 'fallthrough' macro +defined in the Linux. + +To cover the case where an old Linux version doesn't have the macro, +defined it in the compatibility header too. + +Signed-off-by: Ferruh Yigit +--- + linux/igb_uio/compat.h | 14 ++++++++++++++ + linux/igb_uio/igb_uio.c | 6 +++--- + 2 files changed, 17 insertions(+), 3 deletions(-) + +diff --git a/kernel/linux/igb_uio/compat.h b/kernel/linux/igb_uio/compat.h +index 8dbb896..71172f4 100644 +--- a/kernel/linux/igb_uio/compat.h ++++ b/kernel/linux/igb_uio/compat.h +@@ -152,3 +152,17 @@ static inline bool igbuio_kernel_is_locked_down(void) + return false; + #endif + } ++ ++#ifndef fallthrough ++ ++#ifndef __has_attribute ++#define __has_attribute(x) 0 ++#endif ++ ++#if __has_attribute(__fallthrough__) ++#define fallthrough __attribute__((__fallthrough__)) ++#else ++#define fallthrough do {} while (0) /* fallthrough */ ++#endif ++ ++#endif +diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c +index ea439d1..33e0e02 100644 +--- a/kernel/linux/igb_uio/igb_uio.c ++++ b/kernel/linux/igb_uio/igb_uio.c +@@ -250,7 +250,7 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) + } + #endif + +- /* falls through - to MSI */ ++ fallthrough; + case RTE_INTR_MODE_MSI: + #ifndef HAVE_ALLOC_IRQ_VECTORS + if (pci_enable_msi(udev->pdev) == 0) { +@@ -269,7 +269,7 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) + break; + } + #endif +- /* falls through - to INTX */ ++ fallthrough; + case RTE_INTR_MODE_LEGACY: + if (pci_intx_mask_supported(udev->pdev)) { + dev_dbg(&udev->pdev->dev, "using INTX"); +@@ -279,7 +279,7 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) + break; + } + dev_notice(&udev->pdev->dev, "PCI INTX mask not supported\n"); +- /* falls through - to no IRQ */ ++ fallthrough; + case RTE_INTR_MODE_NONE: + udev->mode = RTE_INTR_MODE_NONE; + udev->info.irq = UIO_IRQ_NONE; +-- +2.23.0 + diff --git a/0219-linux-igb_uio-fix-build-with-kernel-5.18.patch b/0219-linux-igb_uio-fix-build-with-kernel-5.18.patch new file mode 100644 index 0000000..f19c6e5 --- /dev/null +++ b/0219-linux-igb_uio-fix-build-with-kernel-5.18.patch @@ -0,0 +1,49 @@ +From 29b1c1e43014099548bb9424749cbc062e16a087 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Georg=20M=C3=BCller?= +Date: Thu, 6 Oct 2022 20:51:37 +0200 +Subject: [PATCH] linux/igb_uio: fix build with kernel 5.18+ +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +pci_set_dma_mask() and pci_set_consistent_dma_mask() were removed with +kernel 5.18. They both were just wrappers for dma_set_mask() and +dma_set_coherent_mask(). + +Instead, use dma_set_mask_and_coherent(), which is a combination of +dma_set_mask() and dma_set_coherent_mask(). + +dma_set_mask_and_coherent() exists since kernel 3.13. + +Signed-off-by: Georg Müller +--- + kernel/linux/igb_uio/igb_uio.c | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c +index 33e0e02..aea67da 100644 +--- a/kernel/linux/igb_uio/igb_uio.c ++++ b/kernel/linux/igb_uio/igb_uio.c +@@ -512,18 +512,12 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) + goto fail_release_iomem; + + /* set 64-bit DMA mask */ +- err = pci_set_dma_mask(dev, DMA_BIT_MASK(64)); ++ err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)); + if (err != 0) { + dev_err(&dev->dev, "Cannot set DMA mask\n"); + goto fail_release_iomem; + } + +- err = pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(64)); +- if (err != 0) { +- dev_err(&dev->dev, "Cannot set consistent DMA mask\n"); +- goto fail_release_iomem; +- } +- + /* fill uio infos */ + udev->info.name = "igb_uio"; + udev->info.version = "0.1"; +-- +2.23.0 + diff --git a/0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch b/0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch new file mode 100644 index 0000000..59a0c08 --- /dev/null +++ b/0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch @@ -0,0 +1,53 @@ +From 3cd01cd12d4987b76be0ff1b25bc21a558aab6f1 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 9 Jan 2023 16:23:44 +0800 +Subject: net/hns3: fix inaccurate RTC time to read + +[ upstream commit 4243282181f38d387188af5fd38a5428864a94a2 ] + +The sequence of reading current RTC time register doesn't meet +the hardware requirements, which causes this time obtained is +the one before modifying RTC time. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ptp.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index 6bbd85ba23..db3c007b12 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -216,17 +216,21 @@ hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev, + int + hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts) + { ++#define HNS3_PTP_SEC_H_OFFSET 32 ++#define HNS3_PTP_SEC_H_MASK 0xFFFF ++ + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ uint32_t sec_hi, sec_lo; + uint64_t ns, sec; + + if (!hns3_dev_get_support(hw, PTP)) + return -ENOTSUP; + +- sec = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_L); +- sec |= (uint64_t)(hns3_read_dev(hw, HNS3_CURR_TIME_OUT_H) & 0xFFFF) +- << 32; +- + ns = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_NS); ++ sec_hi = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_H) & HNS3_PTP_SEC_H_MASK; ++ sec_lo = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_L); ++ sec = ((uint64_t)sec_hi << HNS3_PTP_SEC_H_OFFSET) | sec_lo; ++ + ns += sec * NSEC_PER_SEC; + *ts = rte_ns_to_timespec(ns); + +-- +2.23.0 + diff --git a/0221-net-hns3-fix-log-about-indirection-table-size.patch b/0221-net-hns3-fix-log-about-indirection-table-size.patch new file mode 100644 index 0000000..613aaf4 --- /dev/null +++ b/0221-net-hns3-fix-log-about-indirection-table-size.patch @@ -0,0 +1,53 @@ +From 55cc3ba793a896aeac7abb05a247b3b32d2adc75 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:51 +0800 +Subject: net/hns3: fix log about indirection table size + +[ upstream commit b55516a94246364f272db802f5dfb9aeb8d3a2f2 ] + +The error log about indirection table size during initialization phase +of PF and VF is unreasonable. + +In addition, VF driver should use error level to print this log. + +Fixes: 0fce2c46dc16 ("net/hns3: fix RSS indirection table size") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 2 +- + drivers/net/hns3/hns3_ethdev_vf.c | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 25f9c9fab1..ed273b5b69 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2679,7 +2679,7 @@ hns3_check_dev_specifications(struct hns3_hw *hw) + { + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_err(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", ++ hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", + hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index de44b07691..8a3a3cc657 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -718,8 +718,8 @@ hns3vf_check_dev_specifications(struct hns3_hw *hw) + { + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_warn(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", +- hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); ++ hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", ++ hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } + +-- +2.23.0 + diff --git a/0222-net-hns3-extract-common-function-to-query-device.patch b/0222-net-hns3-extract-common-function-to-query-device.patch new file mode 100644 index 0000000..99e65ff --- /dev/null +++ b/0222-net-hns3-extract-common-function-to-query-device.patch @@ -0,0 +1,291 @@ +From 6fb8330396b77c4a4acc73ff895a8d2b62a5ab93 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:52 +0800 +Subject: net/hns3: extract common function to query device + +[ upstream commit 52a4e960b49c526dd1ad7c1e91ebcfa664a38e6d ] + +Extract common function to query device specifications used by VF and +PF. + +Fixes: 9c740336f024 ("net/hns3: get device specifications from firmware") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_common.c | 75 +++++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_common.h | 2 + + drivers/net/hns3/hns3_ethdev.c | 63 -------------------------- + drivers/net/hns3/hns3_ethdev_vf.c | 65 +-------------------------- + 4 files changed, 79 insertions(+), 126 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 2ebcf5695b..212b35d842 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -10,6 +10,7 @@ + #include "hns3_logs.h" + #include "hns3_regs.h" + #include "hns3_rxtx.h" ++#include "hns3_dcb.h" + #include "hns3_common.h" + + int +@@ -843,3 +844,77 @@ hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id) + + return 0; + } ++ ++void ++hns3_set_default_dev_specifications(struct hns3_hw *hw) ++{ ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ ++ hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; ++ hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; ++ hw->rss_key_size = HNS3_RSS_KEY_SIZE; ++ hw->intr.int_ql_max = HNS3_INTR_QL_NONE; ++ ++ if (hns->is_vf) ++ return; ++ ++ hw->max_tm_rate = HNS3_ETHER_MAX_RATE; ++} ++ ++static void ++hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) ++{ ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ struct hns3_dev_specs_0_cmd *req0; ++ struct hns3_dev_specs_1_cmd *req1; ++ ++ req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; ++ req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; ++ ++ hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; ++ hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); ++ hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); ++ hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); ++ hw->min_tx_pkt_len = req1->min_tx_pkt_len; ++ ++ if (hns->is_vf) ++ return; ++ ++ hw->max_tm_rate = rte_le_to_cpu_32(req0->max_tm_rate); ++} ++ ++static int ++hns3_check_dev_specifications(struct hns3_hw *hw) ++{ ++ if (hw->rss_ind_tbl_size == 0 || ++ hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { ++ hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", ++ hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++int ++hns3_query_dev_specifications(struct hns3_hw *hw) ++{ ++ struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; ++ int ret; ++ int i; ++ ++ for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { ++ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, ++ true); ++ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); ++ } ++ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); ++ ++ ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); ++ if (ret) ++ return ret; ++ ++ hns3_parse_dev_specifications(hw, desc); ++ ++ return hns3_check_dev_specifications(hw); ++} +diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h +index 5aa001f0cc..8eaeda26e7 100644 +--- a/drivers/net/hns3/hns3_common.h ++++ b/drivers/net/hns3/hns3_common.h +@@ -60,5 +60,7 @@ void hns3_unmap_rx_interrupt(struct rte_eth_dev *dev); + int hns3_restore_rx_interrupt(struct hns3_hw *hw); + + int hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id); ++void hns3_set_default_dev_specifications(struct hns3_hw *hw); ++int hns3_query_dev_specifications(struct hns3_hw *hw); + + #endif /* HNS3_COMMON_H */ +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index ed273b5b69..8fa12d91bb 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2647,69 +2647,6 @@ hns3_parse_speed(int speed_cmd, uint32_t *speed) + return 0; + } + +-static void +-hns3_set_default_dev_specifications(struct hns3_hw *hw) +-{ +- hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; +- hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; +- hw->rss_key_size = HNS3_RSS_KEY_SIZE; +- hw->max_tm_rate = HNS3_ETHER_MAX_RATE; +- hw->intr.int_ql_max = HNS3_INTR_QL_NONE; +-} +- +-static void +-hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) +-{ +- struct hns3_dev_specs_0_cmd *req0; +- struct hns3_dev_specs_1_cmd *req1; +- +- req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; +- req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; +- +- hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; +- hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); +- hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); +- hw->max_tm_rate = rte_le_to_cpu_32(req0->max_tm_rate); +- hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); +- hw->min_tx_pkt_len = req1->min_tx_pkt_len; +-} +- +-static int +-hns3_check_dev_specifications(struct hns3_hw *hw) +-{ +- if (hw->rss_ind_tbl_size == 0 || +- hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", +- hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); +- return -EINVAL; +- } +- +- return 0; +-} +- +-static int +-hns3_query_dev_specifications(struct hns3_hw *hw) +-{ +- struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; +- int ret; +- int i; +- +- for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { +- hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, +- true); +- desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); +- } +- hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); +- +- ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); +- if (ret) +- return ret; +- +- hns3_parse_dev_specifications(hw, desc); +- +- return hns3_check_dev_specifications(hw); +-} +- + static int + hns3_get_capability(struct hns3_hw *hw) + { +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 8a3a3cc657..a3a1b71a63 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -688,67 +688,6 @@ hns3vf_interrupt_handler(void *param) + hns3vf_enable_irq0(hw); + } + +-static void +-hns3vf_set_default_dev_specifications(struct hns3_hw *hw) +-{ +- hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; +- hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; +- hw->rss_key_size = HNS3_RSS_KEY_SIZE; +- hw->intr.int_ql_max = HNS3_INTR_QL_NONE; +-} +- +-static void +-hns3vf_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) +-{ +- struct hns3_dev_specs_0_cmd *req0; +- struct hns3_dev_specs_1_cmd *req1; +- +- req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; +- req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; +- +- hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; +- hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); +- hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); +- hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); +- hw->min_tx_pkt_len = req1->min_tx_pkt_len; +-} +- +-static int +-hns3vf_check_dev_specifications(struct hns3_hw *hw) +-{ +- if (hw->rss_ind_tbl_size == 0 || +- hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", +- hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); +- return -EINVAL; +- } +- +- return 0; +-} +- +-static int +-hns3vf_query_dev_specifications(struct hns3_hw *hw) +-{ +- struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; +- int ret; +- int i; +- +- for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { +- hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, +- true); +- desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); +- } +- hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); +- +- ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); +- if (ret) +- return ret; +- +- hns3vf_parse_dev_specifications(hw, desc); +- +- return hns3vf_check_dev_specifications(hw); +-} +- + void + hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported) + { +@@ -826,7 +765,7 @@ hns3vf_get_capability(struct hns3_hw *hw) + return ret; + + if (hw->revision < PCI_REVISION_ID_HIP09_A) { +- hns3vf_set_default_dev_specifications(hw); ++ hns3_set_default_dev_specifications(hw); + hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE; + hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_2US; + hw->tso_mode = HNS3_TSO_SW_CAL_PSEUDO_H_CSUM; +@@ -837,7 +776,7 @@ hns3vf_get_capability(struct hns3_hw *hw) + return 0; + } + +- ret = hns3vf_query_dev_specifications(hw); ++ ret = hns3_query_dev_specifications(hw); + if (ret) { + PMD_INIT_LOG(ERR, + "failed to query dev specifications, ret = %d", +-- +2.23.0 + diff --git a/0223-net-hns3-refactor-set-RSS-hash-algorithm-and-key-int.patch b/0223-net-hns3-refactor-set-RSS-hash-algorithm-and-key-int.patch new file mode 100644 index 0000000..7d48ce2 --- /dev/null +++ b/0223-net-hns3-refactor-set-RSS-hash-algorithm-and-key-int.patch @@ -0,0 +1,149 @@ +From d0c9a7b130290b2079dfaeaf301b95982480912c Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:53 +0800 +Subject: net/hns3: refactor set RSS hash algorithm and key interface + +[ upstream commit 88347111eb53bc54c598dde81715a06ca1dbd132 ] + +The hns3_rss_set_algo_key() is used to set RSS hash algorithm and key to +hardware. +The maximum execution time of the command sent to the firmware is +proportional to the length of the key. +However, now this times is fixed, which isn't good for key expansion. + +In addition, hash algorithm comes from rss_info::hash_algo maintained in +the driver, which also isn't good for the usage of this function. + +Interface is updated to get hash algorithm and key length as input +parameters. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 3 ++- + drivers/net/hns3/hns3_rss.c | 48 ++++++++++++++++-------------------- + drivers/net/hns3/hns3_rss.h | 4 ++- + 3 files changed, 26 insertions(+), 29 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index a2c1589c39..95609f8483 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1494,7 +1494,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + if (ret) + return ret; + +- ret = hns3_rss_set_algo_key(hw, rss_config->key); ++ ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, ++ rss_config->key, HNS3_RSS_KEY_SIZE); + if (ret) + return ret; + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index ca5a129234..3db7bf0445 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -277,45 +277,37 @@ static const struct { + + /* + * rss_generic_config command function, opcode:0x0D01. +- * Used to set algorithm, key_offset and hash key of rss. ++ * Used to set algorithm and hash key of RSS. + */ + int +-hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key) ++hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, ++ const uint8_t *key, uint8_t key_len) + { +-#define HNS3_KEY_OFFSET_MAX 3 +-#define HNS3_SET_HASH_KEY_BYTE_FOUR 2 +- + struct hns3_rss_generic_config_cmd *req; + struct hns3_cmd_desc desc; +- uint32_t key_offset, key_size; +- const uint8_t *key_cur; +- uint8_t cur_offset; ++ const uint8_t *cur_key; ++ uint16_t cur_key_size; ++ uint16_t max_bd_num; ++ uint16_t idx; + int ret; + + req = (struct hns3_rss_generic_config_cmd *)desc.data; + +- /* +- * key_offset=0, hash key byte0~15 is set to hardware. +- * key_offset=1, hash key byte16~31 is set to hardware. +- * key_offset=2, hash key byte32~39 is set to hardware. +- */ +- for (key_offset = 0; key_offset < HNS3_KEY_OFFSET_MAX; key_offset++) { ++ max_bd_num = DIV_ROUND_UP(key_len, HNS3_RSS_HASH_KEY_NUM); ++ for (idx = 0; idx < max_bd_num; idx++) { + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_GENERIC_CONFIG, + false); + +- req->hash_config |= +- (hw->rss_info.hash_algo & HNS3_RSS_HASH_ALGO_MASK); +- req->hash_config |= (key_offset << HNS3_RSS_HASH_KEY_OFFSET_B); ++ req->hash_config |= (hash_algo & HNS3_RSS_HASH_ALGO_MASK); ++ req->hash_config |= (idx << HNS3_RSS_HASH_KEY_OFFSET_B); + +- if (key_offset == HNS3_SET_HASH_KEY_BYTE_FOUR) +- key_size = HNS3_RSS_KEY_SIZE - HNS3_RSS_HASH_KEY_NUM * +- HNS3_SET_HASH_KEY_BYTE_FOUR; ++ if (idx == max_bd_num - 1) ++ cur_key_size = key_len % HNS3_RSS_HASH_KEY_NUM; + else +- key_size = HNS3_RSS_HASH_KEY_NUM; ++ cur_key_size = HNS3_RSS_HASH_KEY_NUM; + +- cur_offset = key_offset * HNS3_RSS_HASH_KEY_NUM; +- key_cur = key + cur_offset; +- memcpy(req->hash_key, key_cur, key_size); ++ cur_key = key + idx * HNS3_RSS_HASH_KEY_NUM; ++ memcpy(req->hash_key, cur_key, cur_key_size); + + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) { +@@ -518,7 +510,8 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + goto set_tuple_fail; + + if (key) { +- ret = hns3_rss_set_algo_key(hw, key); ++ ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, ++ key, HNS3_RSS_KEY_SIZE); + if (ret) + goto set_algo_key_fail; + } +@@ -795,8 +788,9 @@ hns3_config_rss(struct hns3_adapter *hns) + break; + } + +- /* Configure RSS hash algorithm and hash key offset */ +- ret = hns3_rss_set_algo_key(hw, hash_key); ++ /* Configure RSS hash algorithm and hash key */ ++ ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, hash_key, ++ HNS3_RSS_KEY_SIZE); + if (ret) + return ret; + +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 8e8b056f4e..b7f62ca1ee 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -109,6 +109,8 @@ int hns3_rss_reset_indir_table(struct hns3_hw *hw); + int hns3_config_rss(struct hns3_adapter *hns); + void hns3_rss_uninit(struct hns3_adapter *hns); + int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); +-int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key); ++int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, ++ const uint8_t *key, uint8_t key_len); ++ + + #endif /* HNS3_RSS_H */ +-- +2.23.0 + diff --git a/0224-net-hns3-fix-RSS-key-size-compatibility.patch b/0224-net-hns3-fix-RSS-key-size-compatibility.patch new file mode 100644 index 0000000..ed823ec --- /dev/null +++ b/0224-net-hns3-fix-RSS-key-size-compatibility.patch @@ -0,0 +1,209 @@ +From 7d81fd5ed42af46c6e5eef15b4dce7172a2e571d Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:54 +0800 +Subject: net/hns3: fix RSS key size compatibility + +[ upstream commit 5172f9c464aa315a9d45b9177af71b4f99d55cdb ] + +For better compatibility, the RSS key size of PF and VF are obtained +from firmware. However, the outdated HNS3_RSS_KEY_SIZE macro is still +utilized in many locations as the key size. + +Fixes: 9c740336f024 ("net/hns3: get device specifications from firmware") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_common.c | 12 +++++++++++- + drivers/net/hns3/hns3_flow.c | 26 ++++++++++++-------------- + drivers/net/hns3/hns3_rss.c | 23 +++++++++++------------ + drivers/net/hns3/hns3_rss.h | 3 ++- + 4 files changed, 36 insertions(+), 28 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 212b35d842..9bfbe1161f 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -129,7 +129,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) + }; + + info->reta_size = hw->rss_ind_tbl_size; +- info->hash_key_size = HNS3_RSS_KEY_SIZE; ++ info->hash_key_size = hw->rss_key_size; + info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; + + info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; +@@ -893,6 +893,16 @@ hns3_check_dev_specifications(struct hns3_hw *hw) + return -EINVAL; + } + ++ if (hw->rss_key_size == 0 || hw->rss_key_size > HNS3_RSS_KEY_SIZE_MAX) { ++ hns3_err(hw, "the RSS key size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", ++ hw->rss_key_size, HNS3_RSS_KEY_SIZE_MAX); ++ return -EINVAL; ++ } ++ ++ if (hw->rss_key_size > HNS3_RSS_KEY_SIZE) ++ hns3_warn(hw, "the RSS key size obtained (%u) is greater than the default key size (%u)", ++ hw->rss_key_size, HNS3_RSS_KEY_SIZE); ++ + return 0; + } + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 95609f8483..a18ec7650d 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1406,10 +1406,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, + "a nonzero RSS encapsulation level is not supported"); +- if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) ++ if (rss->key_len && rss->key_len != hw->rss_key_size) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, +- "RSS hash key must be exactly 40 bytes"); ++ "invalid RSS key length"); + + if (!hns3_rss_input_tuple_supported(hw, rss)) + return rte_flow_error_set(error, EINVAL, +@@ -1443,16 +1443,6 @@ hns3_disable_rss(struct hns3_hw *hw) + return 0; + } + +-static void +-hns3_adjust_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf) +-{ +- if (rss_conf->key == NULL || rss_conf->key_len < HNS3_RSS_KEY_SIZE) { +- hns3_warn(hw, "Default RSS hash key to be set"); +- rss_conf->key = hns3_hash_key; +- rss_conf->key_len = HNS3_RSS_KEY_SIZE; +- } +-} +- + static int + hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, + uint8_t *hash_algo) +@@ -1485,9 +1475,16 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, + static int + hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + { ++ uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; ++ bool use_default_key = false; + int ret; + +- hns3_adjust_rss_key(hw, rss_config); ++ if (rss_config->key == NULL || rss_config->key_len != hw->rss_key_size) { ++ hns3_warn(hw, "Default RSS hash key to be set"); ++ memcpy(rss_key, hns3_hash_key, ++ RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); ++ use_default_key = true; ++ } + + ret = hns3_parse_rss_algorithm(hw, &rss_config->func, + &hw->rss_info.hash_algo); +@@ -1495,7 +1492,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + return ret; + + ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, +- rss_config->key, HNS3_RSS_KEY_SIZE); ++ use_default_key ? rss_key : rss_config->key, ++ hw->rss_key_size); + if (ret) + return ret; + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 3db7bf0445..d6e0754273 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -316,7 +316,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + } + } + /* Update the shadow RSS key with user specified */ +- memcpy(hw->rss_info.key, key, HNS3_RSS_KEY_SIZE); ++ memcpy(hw->rss_info.key, key, hw->rss_key_size); + return 0; + } + +@@ -498,9 +498,9 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + uint8_t *key = rss_conf->rss_key; + int ret; + +- if (key && key_len != HNS3_RSS_KEY_SIZE) { ++ if (key && key_len != hw->rss_key_size) { + hns3_err(hw, "the hash key len(%u) is invalid, must be %u", +- key_len, HNS3_RSS_KEY_SIZE); ++ key_len, hw->rss_key_size); + return -EINVAL; + } + +@@ -511,7 +511,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + + if (key) { + ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, +- key, HNS3_RSS_KEY_SIZE); ++ key, hw->rss_key_size); + if (ret) + goto set_algo_key_fail; + } +@@ -547,9 +547,9 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + rss_conf->rss_hf = rss_cfg->conf.types; + + /* Get the RSS Key required by the user */ +- if (rss_conf->rss_key && rss_conf->rss_key_len >= HNS3_RSS_KEY_SIZE) { +- memcpy(rss_conf->rss_key, rss_cfg->key, HNS3_RSS_KEY_SIZE); +- rss_conf->rss_key_len = HNS3_RSS_KEY_SIZE; ++ if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) { ++ memcpy(rss_conf->rss_key, rss_cfg->key, hw->rss_key_size); ++ rss_conf->rss_key_len = hw->rss_key_size; + } + rte_spinlock_unlock(&hw->lock); + +@@ -754,8 +754,8 @@ hns3_rss_set_default_args(struct hns3_hw *hw) + /* Default hash algorithm */ + rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + +- /* Default RSS key */ +- memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE); ++ memcpy(rss_cfg->key, hns3_hash_key, ++ RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); + + /* Initialize RSS indirection table */ + for (i = 0; i < hw->rss_ind_tbl_size; i++) +@@ -788,9 +788,8 @@ hns3_config_rss(struct hns3_adapter *hns) + break; + } + +- /* Configure RSS hash algorithm and hash key */ +- ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, hash_key, +- HNS3_RSS_KEY_SIZE); ++ ret = hns3_rss_set_algo_key(hw, rss_cfg->hash_algo, ++ hash_key, hw->rss_key_size); + if (ret) + return ret; + +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index b7f62ca1ee..d6f81996f4 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -29,6 +29,7 @@ + #define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */ + #define HNS3_RSS_IND_TBL_SIZE_MAX 2048 + #define HNS3_RSS_KEY_SIZE 40 ++#define HNS3_RSS_KEY_SIZE_MAX 128 + #define HNS3_RSS_SET_BITMAP_MSK 0xffff + + #define HNS3_RSS_HASH_ALGO_TOEPLITZ 0 +@@ -41,7 +42,7 @@ struct hns3_rss_conf { + /* RSS parameters :algorithm, flow_types, key, queue */ + struct rte_flow_action_rss conf; + uint8_t hash_algo; /* hash function type defined by hardware */ +- uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */ ++ uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ + uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; + uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ + bool valid; /* check if RSS rule is valid */ +-- +2.23.0 + diff --git a/0225-net-hns3-fix-clearing-RSS-configuration.patch b/0225-net-hns3-fix-clearing-RSS-configuration.patch new file mode 100644 index 0000000..2a850e2 --- /dev/null +++ b/0225-net-hns3-fix-clearing-RSS-configuration.patch @@ -0,0 +1,42 @@ +From b81a2f05658192464916c0d4f5cc1349d9d3aca4 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:55 +0800 +Subject: net/hns3: fix clearing RSS configuration + +[ upstream commit 1aa5222454725001939ff571e685225f6cf85653 ] + +When a RSS rule has an unsupported action, the RSS configuration is +cleared by mistake. + +Remove clearing RSS configuration in this case. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index a18ec7650d..c338eab049 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1421,12 +1421,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, + + /* Check if the next not void action is END */ + NEXT_ITEM_OF_ACTION(act, actions, act_index); +- if (act->type != RTE_FLOW_ACTION_TYPE_END) { +- memset(rss_conf, 0, sizeof(struct hns3_rss_conf)); ++ if (act->type != RTE_FLOW_ACTION_TYPE_END) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + act, "Not supported action."); +- } + + return 0; + } +-- +2.23.0 + diff --git a/0226-net-hns3-use-RSS-filter-list-to-check-duplicated-rul.patch b/0226-net-hns3-use-RSS-filter-list-to-check-duplicated-rul.patch new file mode 100644 index 0000000..4f30996 --- /dev/null +++ b/0226-net-hns3-use-RSS-filter-list-to-check-duplicated-rul.patch @@ -0,0 +1,89 @@ +From dd5efbef75ed9511f497e2da05131e902dc4f277 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:56 +0800 +Subject: net/hns3: use RSS filter list to check duplicated rule + +[ upstream commit 6afde23d843ecf67453eaf69924bd79873f6f207 ] + +All rules from user are saved in RSS filter list, so use RSS +filter list to check duplicated rule. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 35 +++++++++++++++++++++-------------- + 1 file changed, 21 insertions(+), 14 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index c338eab049..303275ae93 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1300,7 +1300,7 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + !memcmp(comp->key, with->key, with->key_len); + + return (func_is_same && rss_key_is_same && +- comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) && ++ comp->types == with->types && + comp->level == with->level && + comp->queue_num == with->queue_num && + !memcmp(comp->queue, with->queue, +@@ -1596,15 +1596,7 @@ hns3_config_rss_filter(struct hns3_hw *hw, + } + + /* Set hash algorithm and flow types by the user's config */ +- ret = hns3_hw_rss_hash_set(hw, &rss_flow_conf); +- if (ret) +- return ret; +- +- ret = hns3_rss_conf_copy(rss_info, &rss_flow_conf); +- if (ret) +- hns3_err(hw, "RSS config init fail(%d)", ret); +- +- return ret; ++ return hns3_hw_rss_hash_set(hw, &rss_flow_conf); + } + + static int +@@ -1676,17 +1668,32 @@ hns3_restore_filter(struct hns3_adapter *hns) + return hns3_restore_rss_filter(hw); + } + ++static bool ++hns3_rss_action_is_dup(struct hns3_hw *hw, ++ const struct rte_flow_action_rss *act) ++{ ++ struct hns3_rss_conf_ele *filter; ++ ++ TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) { ++ if (!filter->filter_info.valid) ++ continue; ++ ++ if (hns3_action_rss_same(&filter->filter_info.conf, act)) ++ return true; ++ } ++ ++ return false; ++} ++ + static int + hns3_flow_parse_rss(struct rte_eth_dev *dev, + const struct hns3_rss_conf *conf, bool add) + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +- bool ret; + +- ret = hns3_action_rss_same(&hw->rss_info.conf, &conf->conf); +- if (ret) { +- hns3_err(hw, "Enter duplicate RSS configuration : %d", ret); ++ if (hns3_rss_action_is_dup(hw, &conf->conf)) { ++ hns3_err(hw, "duplicate RSS configuration"); + return -EINVAL; + } + +-- +2.23.0 + diff --git a/0227-net-hns3-remove-useless-code-when-destroy-valid-RSS-.patch b/0227-net-hns3-remove-useless-code-when-destroy-valid-RSS-.patch new file mode 100644 index 0000000..082bc02 --- /dev/null +++ b/0227-net-hns3-remove-useless-code-when-destroy-valid-RSS-.patch @@ -0,0 +1,91 @@ +From 1f32e5059ee95c4433d1c37034e02f8c4a722418 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:57 +0800 +Subject: net/hns3: remove useless code when destroy valid RSS rule + +[ upstream commit 546031ba551485c3e3aa57c3698975c2852cbef1 ] + +When all rules are flushed the hw::rss_info::conf::func set to +RTE_ETH_HASH_FUNCTION_MAX and hw::rss_info::conf::queue set to NULL +which indicates no flow rules is issued. +See: commit eb158fc756a5 ("net/hns3: fix config when creating RSS rule +after flush"). + +Actually, the way determining whether there are rules has been changed +by walking the flow RSS list. +See: commit 705a50800334 ("net/hns3: fix RSS filter restore"). + +In addition, the rte_flow_action_rss from user isn't saved to 'conf' in +hw->rss_info now. So this code can be removed. + +Fixes: eb158fc756a5 ("net/hns3: fix config when creating RSS rule after flush") +Fixes: 705a50800334 ("net/hns3: fix RSS filter restore") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 26 ++------------------------ + 1 file changed, 2 insertions(+), 24 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 303275ae93..7adde16cbc 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1279,19 +1279,8 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + bool rss_key_is_same; + bool func_is_same; + +- /* +- * When user flush all RSS rule, RSS func is set invalid with +- * RTE_ETH_HASH_FUNCTION_MAX. Then the user create a flow after +- * flushed, any validate RSS func is different with it before +- * flushed. Others, when user create an action RSS with RSS func +- * specified RTE_ETH_HASH_FUNCTION_DEFAULT, the func is the same +- * between continuous RSS flow. +- */ +- if (comp->func == RTE_ETH_HASH_FUNCTION_MAX) +- func_is_same = false; +- else +- func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? +- (comp->func == with->func) : true; ++ func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? ++ (comp->func == with->func) : true; + + if (with->key_len == 0 || with->key == NULL) + rss_key_is_same = 1; +@@ -1533,7 +1522,6 @@ static int + hns3_config_rss_filter(struct hns3_hw *hw, + const struct hns3_rss_conf *conf, bool add) + { +- struct hns3_rss_conf *rss_info; + uint64_t flow_types; + uint16_t num; + int ret; +@@ -1560,7 +1548,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, + /* Update the useful flow types */ + rss_flow_conf.types = flow_types; + +- rss_info = &hw->rss_info; + if (!add) { + if (!conf->valid) + return 0; +@@ -1571,15 +1558,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, + return ret; + } + +- if (rss_flow_conf.queue_num) { +- /* +- * Due the content of queue pointer have been reset to +- * 0, the rss_info->conf.queue should be set to NULL +- */ +- rss_info->conf.queue = NULL; +- rss_info->conf.queue_num = 0; +- } +- + return 0; + } + +-- +2.23.0 + diff --git a/0228-net-hns3-fix-warning-on-flush-or-destroy-rule.patch b/0228-net-hns3-fix-warning-on-flush-or-destroy-rule.patch new file mode 100644 index 0000000..5a7fecf --- /dev/null +++ b/0228-net-hns3-fix-warning-on-flush-or-destroy-rule.patch @@ -0,0 +1,66 @@ +From 21b43c2f2d66de594ed174a0ba18da03a6fe5296 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:58 +0800 +Subject: net/hns3: fix warning on flush or destroy rule + +[ upstream commit a7bf2789168c8d49ca4dec5bb7bb0b3f765fc1bd ] + +Although flow rules will no longer be used when user flush all rules +or destroy a rule a warning is generated like: +"modified RSS types based on hardware support, requested:0x137f83fffc +configured:0x3ffc". + +Prevent warning for flush or destroy rule case. + +Fixes: ec674cb742e5 ("net/hns3: fix flushing RSS rule") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 22 +++++++++++----------- + 1 file changed, 11 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 7adde16cbc..fbc38dd3d4 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1537,17 +1537,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, + .queue = conf->conf.queue, + }; + +- /* Filter the unsupported flow types */ +- flow_types = conf->conf.types ? +- rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT : +- hw->rss_info.conf.types; +- if (flow_types != rss_flow_conf.types) +- hns3_warn(hw, "modified RSS types based on hardware support, " +- "requested:0x%" PRIx64 " configured:0x%" PRIx64, +- rss_flow_conf.types, flow_types); +- /* Update the useful flow types */ +- rss_flow_conf.types = flow_types; +- + if (!add) { + if (!conf->valid) + return 0; +@@ -1573,6 +1562,17 @@ hns3_config_rss_filter(struct hns3_hw *hw, + return ret; + } + ++ /* Filter the unsupported flow types */ ++ flow_types = conf->conf.types ? ++ rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT : ++ hw->rss_info.conf.types; ++ if (flow_types != rss_flow_conf.types) ++ hns3_warn(hw, "modified RSS types based on hardware support," ++ " requested:0x%" PRIx64 " configured:0x%" PRIx64, ++ rss_flow_conf.types, flow_types); ++ /* Update the useful flow types */ ++ rss_flow_conf.types = flow_types; ++ + /* Set hash algorithm and flow types by the user's config */ + return hns3_hw_rss_hash_set(hw, &rss_flow_conf); + } +-- +2.23.0 + diff --git a/0229-net-hns3-fix-config-struct-used-for-conversion.patch b/0229-net-hns3-fix-config-struct-used-for-conversion.patch new file mode 100644 index 0000000..9706fe1 --- /dev/null +++ b/0229-net-hns3-fix-config-struct-used-for-conversion.patch @@ -0,0 +1,133 @@ +From e59403adf4cc2485d10fba148bf935b037170fb7 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:59 +0800 +Subject: net/hns3: fix config struct used for conversion + +[ upstream commit 815c7db53167f7ee1573dca18fa7f889e44764d4 ] + +When the type in 'struct rte_flow_action' is RTE_FLOW_ACTION_TYPE_RSS, +the 'conf' pointer references the 'struct rte_flow_action_rss' instead +of the 'struct hns3_rss_conf' in driver. But driver uses 'struct +hns3_rss_conf' to convert this 'conf' pointer to get RSS action +configuration. + +In addition, RSS filter configuration is directly cloned to RSS filter +node instead of coping it after successfully setting to hardware. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 59 ++++++++++++++---------------------- + 1 file changed, 22 insertions(+), 37 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index fbc38dd3d4..a30b19cfdb 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -95,8 +95,8 @@ static const struct rte_flow_action * + hns3_find_rss_general_action(const struct rte_flow_item pattern[], + const struct rte_flow_action actions[]) + { ++ const struct rte_flow_action_rss *rss_act; + const struct rte_flow_action *act = NULL; +- const struct hns3_rss_conf *rss; + bool have_eth = false; + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { +@@ -115,8 +115,8 @@ hns3_find_rss_general_action(const struct rte_flow_item pattern[], + } + } + +- rss = act->conf; +- if (have_eth && rss->conf.queue_num) { ++ rss_act = act->conf; ++ if (have_eth && rss_act->queue_num) { + /* + * Pattern have ETH and action's queue_num > 0, indicate this is + * queue region configuration. +@@ -1296,30 +1296,6 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + sizeof(*with->queue) * with->queue_num)); + } + +-static int +-hns3_rss_conf_copy(struct hns3_rss_conf *out, +- const struct rte_flow_action_rss *in) +-{ +- if (in->key_len > RTE_DIM(out->key) || +- in->queue_num > RTE_DIM(out->queue)) +- return -EINVAL; +- if (in->key == NULL && in->key_len) +- return -EINVAL; +- out->conf = (struct rte_flow_action_rss) { +- .func = in->func, +- .level = in->level, +- .types = in->types, +- .key_len = in->key_len, +- .queue_num = in->queue_num, +- }; +- out->conf.queue = memcpy(out->queue, in->queue, +- sizeof(*in->queue) * in->queue_num); +- if (in->key) +- out->conf.key = memcpy(out->key, in->key, in->key_len); +- +- return 0; +-} +- + static bool + hns3_rss_input_tuple_supported(struct hns3_hw *hw, + const struct rte_flow_action_rss *rss) +@@ -1733,9 +1709,10 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + struct rte_flow *flow) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ const struct rte_flow_action_rss *rss_act; + struct hns3_rss_conf_ele *rss_filter_ptr; + struct hns3_rss_conf_ele *filter_ptr; +- const struct hns3_rss_conf *rss_conf; ++ struct hns3_rss_conf *new_conf; + int ret; + + rss_filter_ptr = rte_zmalloc("hns3 rss filter", +@@ -1745,19 +1722,27 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + return -ENOMEM; + } + +- /* +- * After all the preceding tasks are successfully configured, configure +- * rules to the hardware to simplify the rollback of rules in the +- * hardware. +- */ +- rss_conf = (const struct hns3_rss_conf *)act->conf; +- ret = hns3_flow_parse_rss(dev, rss_conf, true); ++ rss_act = (const struct rte_flow_action_rss *)act->conf; ++ new_conf = &rss_filter_ptr->filter_info; ++ memcpy(&new_conf->conf, rss_act, sizeof(*rss_act)); ++ if (rss_act->queue_num > 0) { ++ memcpy(new_conf->queue, rss_act->queue, ++ rss_act->queue_num * sizeof(new_conf->queue[0])); ++ new_conf->conf.queue = new_conf->queue; ++ } ++ if (rss_act->key_len > 0) { ++ if (rss_act->key != NULL) { ++ memcpy(new_conf->key, rss_act->key, ++ rss_act->key_len * sizeof(new_conf->key[0])); ++ new_conf->conf.key = new_conf->key; ++ } ++ } ++ ++ ret = hns3_flow_parse_rss(dev, new_conf, true); + if (ret != 0) { + rte_free(rss_filter_ptr); + return ret; + } +- +- hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf); + rss_filter_ptr->filter_info.valid = true; + + /* +-- +2.23.0 + diff --git a/0230-net-hns3-fix-duplicate-RSS-rule-check.patch b/0230-net-hns3-fix-duplicate-RSS-rule-check.patch new file mode 100644 index 0000000..02518e8 --- /dev/null +++ b/0230-net-hns3-fix-duplicate-RSS-rule-check.patch @@ -0,0 +1,108 @@ +From 4aa7369a34a576a630beb0680b55b7c3c8b982f5 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:03:00 +0800 +Subject: net/hns3: fix duplicate RSS rule check + +[ upstream commit 150fd8f839e332d68aa7b60646c2033084544cb7 ] + +Currently, the interface for verifying duplicate RSS rules has +some problems: +1) If the value of 'func' in configuring RSS rule is default + value, this rule is mistakenly considered as a duplicate rule. +2) If key length is zero or 'key' is NULL in configuring RSS rule + this rule is also mistakenly considered as a duplicate rule. +3) If 'key' or 'queue' in struct rte_flow_action_rss being NULL + is used to memcpy, which may cause segment fault. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 63 +++++++++++++++++++++++++++--------- + 1 file changed, 47 insertions(+), 16 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index a30b19cfdb..e80ec0f053 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1272,28 +1272,59 @@ hns3_filterlist_flush(struct rte_eth_dev *dev) + } + } + ++static bool ++hns3_flow_rule_key_same(const struct rte_flow_action_rss *comp, ++ const struct rte_flow_action_rss *with) ++{ ++ if (comp->key_len != with->key_len) ++ return false; ++ ++ if (with->key_len == 0) ++ return true; ++ ++ if (comp->key == NULL && with->key == NULL) ++ return true; ++ ++ if (!(comp->key != NULL && with->key != NULL)) ++ return false; ++ ++ return !memcmp(comp->key, with->key, with->key_len); ++} ++ ++static bool ++hns3_flow_rule_queues_same(const struct rte_flow_action_rss *comp, ++ const struct rte_flow_action_rss *with) ++{ ++ if (comp->queue_num != with->queue_num) ++ return false; ++ ++ if (with->queue_num == 0) ++ return true; ++ ++ if (comp->queue == NULL && with->queue == NULL) ++ return true; ++ ++ if (!(comp->queue != NULL && with->queue != NULL)) ++ return false; ++ ++ return !memcmp(comp->queue, with->queue, with->queue_num); ++} ++ + static bool + hns3_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) + { +- bool rss_key_is_same; +- bool func_is_same; ++ bool same_level; ++ bool same_types; ++ bool same_func; + +- func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? +- (comp->func == with->func) : true; ++ same_level = (comp->level == with->level); ++ same_types = (comp->types == with->types); ++ same_func = (comp->func == with->func); + +- if (with->key_len == 0 || with->key == NULL) +- rss_key_is_same = 1; +- else +- rss_key_is_same = comp->key_len == with->key_len && +- !memcmp(comp->key, with->key, with->key_len); +- +- return (func_is_same && rss_key_is_same && +- comp->types == with->types && +- comp->level == with->level && +- comp->queue_num == with->queue_num && +- !memcmp(comp->queue, with->queue, +- sizeof(*with->queue) * with->queue_num)); ++ return same_level && same_types && same_func && ++ hns3_flow_rule_key_same(comp, with) && ++ hns3_flow_rule_queues_same(comp, with); + } + + static bool +-- +2.23.0 + diff --git a/0231-net-hns3-fix-burst-mode-query-with-dummy-function.patch b/0231-net-hns3-fix-burst-mode-query-with-dummy-function.patch new file mode 100644 index 0000000..e49dbef --- /dev/null +++ b/0231-net-hns3-fix-burst-mode-query-with-dummy-function.patch @@ -0,0 +1,82 @@ +From 6a7c7c31b57bb4dadaf3750a3fc36e3ec0761f3f Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 11 Feb 2023 17:18:25 +0800 +Subject: net/hns3: fix burst mode query with dummy function + +[ upstream commit 10f91af5a5b370df922f888826a4387abebe1cde ] + +The rte_eth_rx/tx_burst_mode_get API will fail when Rx/Tx +function is dummy. + +Fixes: 7ef933908f04 ("net/hns3: add simple Tx path") +Fixes: 521ab3e93361 ("net/hns3: add simple Rx path") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 38 ++++++++++++++++++++++-------------- + 1 file changed, 23 insertions(+), 15 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 9a597e032e..c69fb38402 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -2786,6 +2786,7 @@ hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, + { hns3_recv_scattered_pkts, "Scalar Scattered" }, + { hns3_recv_pkts_vec, "Vector Neon" }, + { hns3_recv_pkts_vec_sve, "Vector Sve" }, ++ { rte_eth_pkt_burst_dummy, "Dummy" }, + }; + + eth_rx_burst_t pkt_burst = dev->rx_pkt_burst; +@@ -4272,24 +4273,31 @@ int + hns3_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, + struct rte_eth_burst_mode *mode) + { ++ static const struct { ++ eth_tx_burst_t pkt_burst; ++ const char *info; ++ } burst_infos[] = { ++ { hns3_xmit_pkts_simple, "Scalar Simple" }, ++ { hns3_xmit_pkts, "Scalar" }, ++ { hns3_xmit_pkts_vec, "Vector Neon" }, ++ { hns3_xmit_pkts_vec_sve, "Vector Sve" }, ++ { rte_eth_pkt_burst_dummy, "Dummy" }, ++ }; ++ + eth_tx_burst_t pkt_burst = dev->tx_pkt_burst; +- const char *info = NULL; +- +- if (pkt_burst == hns3_xmit_pkts_simple) +- info = "Scalar Simple"; +- else if (pkt_burst == hns3_xmit_pkts) +- info = "Scalar"; +- else if (pkt_burst == hns3_xmit_pkts_vec) +- info = "Vector Neon"; +- else if (pkt_burst == hns3_xmit_pkts_vec_sve) +- info = "Vector Sve"; +- +- if (info == NULL) +- return -EINVAL; ++ int ret = -EINVAL; ++ unsigned int i; + +- snprintf(mode->info, sizeof(mode->info), "%s", info); ++ for (i = 0; i < RTE_DIM(burst_infos); i++) { ++ if (pkt_burst == burst_infos[i].pkt_burst) { ++ snprintf(mode->info, sizeof(mode->info), "%s", ++ burst_infos[i].info); ++ ret = 0; ++ break; ++ } ++ } + +- return 0; ++ return ret; + } + + static bool +-- +2.23.0 + diff --git a/0232-net-hns3-add-debug-info-for-Rx-Tx-dummy-function.patch b/0232-net-hns3-add-debug-info-for-Rx-Tx-dummy-function.patch new file mode 100644 index 0000000..a3fb1ee --- /dev/null +++ b/0232-net-hns3-add-debug-info-for-Rx-Tx-dummy-function.patch @@ -0,0 +1,41 @@ +From cd3db5d9c5aea3efa6b0bbaefecb7fb8367a7719 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 11 Feb 2023 17:18:26 +0800 +Subject: net/hns3: add debug info for Rx/Tx dummy function + +[ upstream commit a8f52a5cf13715c61dfe224815c7f4e4858be82f ] + +Now dummy function can be report by rte_eth_rx/tx_burst_mode_get. +So this patch adds debug info for Rx/Tx dummy function. + +Fixes: 7feb2aee0e2c ("net/hns3: log selected datapath") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index c69fb38402..52393b1f6f 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4420,13 +4420,13 @@ hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) + hns3_get_tx_function(eth_dev, &prep); + eth_dev->tx_pkt_prepare = prep; + eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status; +- hns3_trace_rxtx_function(eth_dev); + } else { + eth_dev->rx_pkt_burst = rte_eth_pkt_burst_dummy; + eth_dev->tx_pkt_burst = rte_eth_pkt_burst_dummy; + eth_dev->tx_pkt_prepare = NULL; + } + ++ hns3_trace_rxtx_function(eth_dev); + hns3_eth_dev_fp_ops_config(eth_dev); + } + +-- +2.23.0 + diff --git a/0233-net-hns3-remove-debug-condition-for-Tx-prepare.patch b/0233-net-hns3-remove-debug-condition-for-Tx-prepare.patch new file mode 100644 index 0000000..8c3973e --- /dev/null +++ b/0233-net-hns3-remove-debug-condition-for-Tx-prepare.patch @@ -0,0 +1,46 @@ +From 25a54df88c36a76f4914287ba393d2251f4492ec Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 11 Feb 2023 17:18:27 +0800 +Subject: net/hns3: remove debug condition for Tx prepare + +[ upstream commit a8d240786e1af129fdf789391d574bf4a7fe60e6 ] + +The Tx prepare in driver is always needed if RTE_LIBRTE_ETHDEV_DEBUG +is defined. But it doesn't matter with this macro. Let's remove it. + +Fixes: d7ec2c076579 ("net/hns3: select Tx prepare based on Tx offload") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 52393b1f6f..9fc54d50f1 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4311,11 +4311,6 @@ hns3_tx_check_simple_support(struct rte_eth_dev *dev) + static bool + hns3_get_tx_prep_needed(struct rte_eth_dev *dev) + { +-#ifdef RTE_LIBRTE_ETHDEV_DEBUG +- RTE_SET_USED(dev); +- /* always perform tx_prepare when debug */ +- return true; +-#else + #define HNS3_DEV_TX_CSKUM_TSO_OFFLOAD_MASK (\ + RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \ + RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \ +@@ -4333,7 +4328,6 @@ hns3_get_tx_prep_needed(struct rte_eth_dev *dev) + return true; + + return false; +-#endif + } + + eth_tx_burst_t +-- +2.23.0 + diff --git a/0234-net-hns3-separate-Tx-prepare-from-getting-Tx-functio.patch b/0234-net-hns3-separate-Tx-prepare-from-getting-Tx-functio.patch new file mode 100644 index 0000000..0aaa9a7 --- /dev/null +++ b/0234-net-hns3-separate-Tx-prepare-from-getting-Tx-functio.patch @@ -0,0 +1,130 @@ +From 9e0cd6d469351131e473edc8a9dbbcd70890519f Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 11 Feb 2023 17:18:28 +0800 +Subject: net/hns3: separate Tx prepare from getting Tx function + +[ upstream commit 6a934ba4c6c48691b119a878981a4e3748766518 ] + +Separate getting tx prepare from hns3_get_tx_function by extracting +an independent function. + +Fixes: d7ec2c076579 ("net/hns3: select Tx prepare based on Tx offload") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 32 ++++++++++++++------------------ + drivers/net/hns3/hns3_rxtx.h | 3 +-- + 2 files changed, 15 insertions(+), 20 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 9fc54d50f1..2dba4d8120 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4324,26 +4324,30 @@ hns3_get_tx_prep_needed(struct rte_eth_dev *dev) + RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO) + + uint64_t tx_offload = dev->data->dev_conf.txmode.offloads; ++ + if (tx_offload & HNS3_DEV_TX_CSKUM_TSO_OFFLOAD_MASK) + return true; + + return false; + } + ++static eth_tx_prep_t ++hns3_get_tx_prepare(struct rte_eth_dev *dev) ++{ ++ return hns3_get_tx_prep_needed(dev) ? hns3_prep_pkts : NULL; ++} ++ + eth_tx_burst_t +-hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) ++hns3_get_tx_function(struct rte_eth_dev *dev) + { + struct hns3_adapter *hns = dev->data->dev_private; + bool vec_allowed, sve_allowed, simple_allowed; +- bool vec_support, tx_prepare_needed; ++ bool vec_support; + + vec_support = hns3_tx_check_vec_support(dev) == 0; + vec_allowed = vec_support && hns3_get_default_vec_support(); + sve_allowed = vec_support && hns3_get_sve_support(); + simple_allowed = hns3_tx_check_simple_support(dev); +- tx_prepare_needed = hns3_get_tx_prep_needed(dev); +- +- *prep = NULL; + + if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_VEC && vec_allowed) + return hns3_xmit_pkts_vec; +@@ -4351,19 +4355,14 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) + return hns3_xmit_pkts_vec_sve; + if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_SIMPLE && simple_allowed) + return hns3_xmit_pkts_simple; +- if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_COMMON) { +- if (tx_prepare_needed) +- *prep = hns3_prep_pkts; ++ if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_COMMON) + return hns3_xmit_pkts; +- } + + if (vec_allowed) + return hns3_xmit_pkts_vec; + if (simple_allowed) + return hns3_xmit_pkts_simple; + +- if (tx_prepare_needed) +- *prep = hns3_prep_pkts; + return hns3_xmit_pkts; + } + +@@ -4403,7 +4402,6 @@ hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + struct hns3_adapter *hns = eth_dev->data->dev_private; +- eth_tx_prep_t prep = NULL; + + if (hns->hw.adapter_state == HNS3_NIC_STARTED && + __atomic_load_n(&hns->hw.reset.resetting, __ATOMIC_RELAXED) == 0) { +@@ -4411,8 +4409,8 @@ hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) + eth_dev->rx_descriptor_status = hns3_dev_rx_descriptor_status; + eth_dev->tx_pkt_burst = hw->set_link_down ? + rte_eth_pkt_burst_dummy : +- hns3_get_tx_function(eth_dev, &prep); +- eth_dev->tx_pkt_prepare = prep; ++ hns3_get_tx_function(eth_dev); ++ eth_dev->tx_pkt_prepare = hns3_get_tx_prepare(eth_dev); + eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status; + } else { + eth_dev->rx_pkt_burst = rte_eth_pkt_burst_dummy; +@@ -4758,10 +4756,8 @@ hns3_stop_tx_datapath(struct rte_eth_dev *dev) + void + hns3_start_tx_datapath(struct rte_eth_dev *dev) + { +- eth_tx_prep_t prep = NULL; +- +- dev->tx_pkt_burst = hns3_get_tx_function(dev, &prep); +- dev->tx_pkt_prepare = prep; ++ dev->tx_pkt_burst = hns3_get_tx_function(dev); ++ dev->tx_pkt_prepare = hns3_get_tx_prepare(dev); + hns3_eth_dev_fp_ops_config(dev); + + if (rte_eal_process_type() == RTE_PROC_SECONDARY) +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index ea1a805491..38c3581312 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -740,8 +740,7 @@ int hns3_tx_burst_mode_get(struct rte_eth_dev *dev, + const uint32_t *hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev); + void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev); + void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev); +-eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev, +- eth_tx_prep_t *prep); ++eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev); + + uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id); + void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id, +-- +2.23.0 + diff --git a/0235-net-hns3-make-getting-Tx-function-static.patch b/0235-net-hns3-make-getting-Tx-function-static.patch new file mode 100644 index 0000000..b2793aa --- /dev/null +++ b/0235-net-hns3-make-getting-Tx-function-static.patch @@ -0,0 +1,49 @@ +From 4efa4ab6f451ebc5ef8439eedda3b3982e9465ca Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 11 Feb 2023 17:18:29 +0800 +Subject: net/hns3: make getting Tx function static + +[ upstream commit 2aec7beaba05cd82cd951f0c6bbaecb82d533ce0 ] + +The hns3_get_tx_function() is an intrinsic function now and should +not be open to other files. + +Fixes: 96c33cfb06cf ("net/hns3: fix Rx/Tx functions update") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 2 +- + drivers/net/hns3/hns3_rxtx.h | 2 -- + 2 files changed, 1 insertion(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 2dba4d8120..b5e7ba7325 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4337,7 +4337,7 @@ hns3_get_tx_prepare(struct rte_eth_dev *dev) + return hns3_get_tx_prep_needed(dev) ? hns3_prep_pkts : NULL; + } + +-eth_tx_burst_t ++static eth_tx_burst_t + hns3_get_tx_function(struct rte_eth_dev *dev) + { + struct hns3_adapter *hns = dev->data->dev_private; +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index 38c3581312..1bdc124b7b 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -740,8 +740,6 @@ int hns3_tx_burst_mode_get(struct rte_eth_dev *dev, + const uint32_t *hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev); + void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev); + void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev); +-eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev); +- + uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id); + void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id, + uint8_t gl_idx, uint16_t gl_value); +-- +2.23.0 + diff --git a/0236-net-hns3-extract-common-functions-to-set-Rx-Tx.patch b/0236-net-hns3-extract-common-functions-to-set-Rx-Tx.patch new file mode 100644 index 0000000..ecb2c65 --- /dev/null +++ b/0236-net-hns3-extract-common-functions-to-set-Rx-Tx.patch @@ -0,0 +1,196 @@ +From a83eecfe38a20bbfa51a108f62d55d6189e943d7 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sat, 11 Feb 2023 17:18:30 +0800 +Subject: net/hns3: extract common functions to set Rx/Tx + +[ upstream commit 4ba28c957a16bbfe5b2a8d49dfda1c85387d7602 ] + +Extract two common functions to set Rx/Tx function in order to +reduce duplicate codes. + +Fixes: 23d4b61fee5d ("net/hns3: support multiple process") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 20 ++++---------------- + drivers/net/hns3/hns3_ethdev_vf.c | 19 ++++--------------- + drivers/net/hns3/hns3_mp.c | 4 ++-- + drivers/net/hns3/hns3_rxtx.c | 28 ++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_rxtx.h | 2 ++ + 5 files changed, 40 insertions(+), 33 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 8fa12d91bb..1c67ff2c99 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5052,8 +5052,7 @@ hns3_dev_start(struct rte_eth_dev *dev) + rte_spinlock_unlock(&hw->lock); + + hns3_rx_scattered_calc(dev); +- hns3_set_rxtx_function(dev); +- hns3_mp_req_start_rxtx(dev); ++ hns3_start_rxtx_datapath(dev); + + /* Enable interrupt of all rx queues before enabling queues */ + hns3_dev_all_rx_queue_intr_enable(hw, true); +@@ -5131,12 +5130,7 @@ hns3_dev_stop(struct rte_eth_dev *dev) + dev->data->dev_started = 0; + + hw->adapter_state = HNS3_NIC_STOPPING; +- hns3_set_rxtx_function(dev); +- rte_wmb(); +- /* Disable datapath on secondary process. */ +- hns3_mp_req_stop_rxtx(dev); +- /* Prevent crashes when queues are still in use. */ +- rte_delay_ms(hw->cfg_max_queues); ++ hns3_stop_rxtx_datapath(dev); + + rte_spinlock_lock(&hw->lock); + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { +@@ -5752,12 +5746,7 @@ hns3_stop_service(struct hns3_adapter *hns) + rte_eal_alarm_cancel(hns3_service_handler, eth_dev); + hns3_update_linkstatus_and_event(hw, false); + } +- +- hns3_set_rxtx_function(eth_dev); +- rte_wmb(); +- /* Disable datapath on secondary process. */ +- hns3_mp_req_stop_rxtx(eth_dev); +- rte_delay_ms(hw->cfg_max_queues); ++ hns3_stop_rxtx_datapath(eth_dev); + + rte_spinlock_lock(&hw->lock); + if (hns->hw.adapter_state == HNS3_NIC_STARTED || +@@ -5790,8 +5779,7 @@ hns3_start_service(struct hns3_adapter *hns) + hw->reset.level == HNS3_GLOBAL_RESET) + hns3_set_rst_done(hw); + eth_dev = &rte_eth_devices[hw->data->port_id]; +- hns3_set_rxtx_function(eth_dev); +- hns3_mp_req_start_rxtx(eth_dev); ++ hns3_start_rxtx_datapath(eth_dev); + if (hw->adapter_state == HNS3_NIC_STARTED) { + /* + * This API parent function already hold the hns3_hw.lock, the +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index a3a1b71a63..3a93987409 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1572,12 +1572,7 @@ hns3vf_dev_stop(struct rte_eth_dev *dev) + dev->data->dev_started = 0; + + hw->adapter_state = HNS3_NIC_STOPPING; +- hns3_set_rxtx_function(dev); +- rte_wmb(); +- /* Disable datapath on secondary process. */ +- hns3_mp_req_stop_rxtx(dev); +- /* Prevent crashes when queues are still in use. */ +- rte_delay_ms(hw->cfg_max_queues); ++ hns3_stop_rxtx_datapath(dev); + + rte_spinlock_lock(&hw->lock); + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { +@@ -1731,8 +1726,7 @@ hns3vf_dev_start(struct rte_eth_dev *dev) + rte_spinlock_unlock(&hw->lock); + + hns3_rx_scattered_calc(dev); +- hns3_set_rxtx_function(dev); +- hns3_mp_req_start_rxtx(dev); ++ hns3_start_rxtx_datapath(dev); + + /* Enable interrupt of all rx queues before enabling queues */ + hns3_dev_all_rx_queue_intr_enable(hw, true); +@@ -1902,11 +1896,7 @@ hns3vf_stop_service(struct hns3_adapter *hns) + } + hw->mac.link_status = RTE_ETH_LINK_DOWN; + +- hns3_set_rxtx_function(eth_dev); +- rte_wmb(); +- /* Disable datapath on secondary process. */ +- hns3_mp_req_stop_rxtx(eth_dev); +- rte_delay_ms(hw->cfg_max_queues); ++ hns3_stop_rxtx_datapath(eth_dev); + + rte_spinlock_lock(&hw->lock); + if (hw->adapter_state == HNS3_NIC_STARTED || +@@ -1938,8 +1928,7 @@ hns3vf_start_service(struct hns3_adapter *hns) + struct rte_eth_dev *eth_dev; + + eth_dev = &rte_eth_devices[hw->data->port_id]; +- hns3_set_rxtx_function(eth_dev); +- hns3_mp_req_start_rxtx(eth_dev); ++ hns3_start_rxtx_datapath(eth_dev); + + rte_eal_alarm_set(HNS3VF_KEEP_ALIVE_INTERVAL, hns3vf_keep_alive_handler, + eth_dev); +diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c +index e74ddea195..c3005b943f 100644 +--- a/drivers/net/hns3/hns3_mp.c ++++ b/drivers/net/hns3/hns3_mp.c +@@ -87,12 +87,12 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) + case HNS3_MP_REQ_START_RXTX: + PMD_INIT_LOG(INFO, "port %u starting datapath", + dev->data->port_id); +- hns3_set_rxtx_function(dev); ++ hns3_start_rxtx_datapath(dev); + break; + case HNS3_MP_REQ_STOP_RXTX: + PMD_INIT_LOG(INFO, "port %u stopping datapath", + dev->data->port_id); +- hns3_set_rxtx_function(dev); ++ hns3_stop_rxtx_datapath(dev); + break; + case HNS3_MP_REQ_START_TX: + PMD_INIT_LOG(INFO, "port %u starting Tx datapath", +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index b5e7ba7325..1f44c0345f 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4765,3 +4765,31 @@ hns3_start_tx_datapath(struct rte_eth_dev *dev) + + hns3_mp_req_start_tx(dev); + } ++ ++void ++hns3_stop_rxtx_datapath(struct rte_eth_dev *dev) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ ++ hns3_set_rxtx_function(dev); ++ ++ if (rte_eal_process_type() == RTE_PROC_SECONDARY) ++ return; ++ ++ rte_wmb(); ++ /* Disable datapath on secondary process. */ ++ hns3_mp_req_stop_rxtx(dev); ++ /* Prevent crashes when queues are still in use. */ ++ rte_delay_ms(hw->cfg_max_queues); ++} ++ ++void ++hns3_start_rxtx_datapath(struct rte_eth_dev *dev) ++{ ++ hns3_set_rxtx_function(dev); ++ ++ if (rte_eal_process_type() == RTE_PROC_SECONDARY) ++ return; ++ ++ hns3_mp_req_start_rxtx(dev); ++} +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index 1bdc124b7b..fa39f6481a 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -773,5 +773,7 @@ int hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); + void hns3_tx_push_init(struct rte_eth_dev *dev); + void hns3_stop_tx_datapath(struct rte_eth_dev *dev); + void hns3_start_tx_datapath(struct rte_eth_dev *dev); ++void hns3_stop_rxtx_datapath(struct rte_eth_dev *dev); ++void hns3_start_rxtx_datapath(struct rte_eth_dev *dev); + + #endif /* HNS3_RXTX_H */ +-- +2.23.0 + diff --git a/0237-net-hns3-declare-flow-rule-keeping-capability.patch b/0237-net-hns3-declare-flow-rule-keeping-capability.patch new file mode 100644 index 0000000..7e0426e --- /dev/null +++ b/0237-net-hns3-declare-flow-rule-keeping-capability.patch @@ -0,0 +1,45 @@ +From 1ee0d9b0270d2a6954c6276aa08f437232707f18 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 15 Dec 2022 01:41:41 +0000 +Subject: net/hns3: declare flow rule keeping capability + +[ upstream commit 27fd46521517cae0f456dad850a04f18de0690f8 ] + +The driver supports create flow rules when device is stopped, and +re-setup flow rules when restarting, so declare support +RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP. + +The driver also supports to create indirect actions when device is +stopped, and keeps the indirect actions when restarting, so declare +support RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP. + +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Dongdong Liu +--- + drivers/net/hns3/hns3_common.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 9bfbe1161f..3c5e07f1bd 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -91,10 +91,11 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) + if (hns3_dev_get_support(hw, OUTER_UDP_CKSUM)) + info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM; + ++ info->dev_capa = RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP | ++ RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP; + if (hns3_dev_get_support(hw, INDEP_TXRX)) +- info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | +- RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; +- info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP; ++ info->dev_capa |= RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | ++ RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; + + if (hns3_dev_get_support(hw, PTP)) + info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP; +-- +2.23.0 + diff --git a/0238-app-testpmd-add-disable-flow-flush-option.patch b/0238-app-testpmd-add-disable-flow-flush-option.patch new file mode 100644 index 0000000..ee3c2ab --- /dev/null +++ b/0238-app-testpmd-add-disable-flow-flush-option.patch @@ -0,0 +1,106 @@ +From c4daf6ffbb78fb4cb2ec3b6d632364d5e077cf10 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 15 Dec 2022 01:41:42 +0000 +Subject: app/testpmd: add --disable-flow-flush option + +[ upstream commit 543df472bced6a9bf0e45c290c3af852486b474a ] + +This patch adds "--disable-flow-flush" parameter, which could used to +disable port flow flush when stop port. It allows testing keep flow +rules or shared flow objects across restart. + +Signed-off-by: Chengwen Feng +Acked-by: Ori Kam +Acked-by: Aman Singh +--- + app/test-pmd/parameters.c | 4 ++++ + app/test-pmd/testpmd.c | 7 ++++++- + app/test-pmd/testpmd.h | 1 + + doc/guides/testpmd_app_ug/run_app.rst | 5 +++++ + 4 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c +index 435687fa6d..e147be28b3 100644 +--- a/app/test-pmd/parameters.c ++++ b/app/test-pmd/parameters.c +@@ -184,6 +184,7 @@ usage(char* progname) + "disable print of designated event or all of them.\n"); + printf(" --flow-isolate-all: " + "requests flow API isolated mode on all ports at initialization time.\n"); ++ printf(" --disable-flow-flush: disable port flow flush when stop port.\n"); + printf(" --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n"); + printf(" --rx-offloads=0xXXXXXXXX: hexadecimal bitmask of RX queue offloads\n"); + printf(" --hot-plug: enable hot plug for device.\n"); +@@ -674,6 +675,7 @@ launch_args_parse(int argc, char** argv) + { "rxfreet", 1, 0, 0 }, + { "no-flush-rx", 0, 0, 0 }, + { "flow-isolate-all", 0, 0, 0 }, ++ { "disable-flow-flush", 0, 0, 0 }, + { "rxoffs", 1, 0, 0 }, + { "rxpkts", 1, 0, 0 }, + { "txpkts", 1, 0, 0 }, +@@ -1381,6 +1383,8 @@ launch_args_parse(int argc, char** argv) + rmv_interrupt = 0; + if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all")) + flow_isolate_all = 1; ++ if (!strcmp(lgopts[opt_idx].name, "disable-flow-flush")) ++ no_flow_flush = 1; + if (!strcmp(lgopts[opt_idx].name, "tx-offloads")) { + char *end = NULL; + n = strtoull(optarg, &end, 16); +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index 32098d4701..20134c5234 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -371,6 +371,11 @@ uint8_t no_flush_rx = 0; /* flush by default */ + */ + uint8_t flow_isolate_all; + ++/* ++ * Disable port flow flush when stop port. ++ */ ++uint8_t no_flow_flush = 0; /* do flow flush by default */ ++ + /* + * Avoids to check link status when starting/stopping a port. + */ +@@ -3173,7 +3178,7 @@ stop_port(portid_t pid) + } + } + +- if (port->flow_list) ++ if (port->flow_list && !no_flow_flush) + port_flow_flush(pi); + + if (eth_dev_stop_mp(pi) != 0) +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 480dc3fa34..be7454ab44 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -398,6 +398,7 @@ extern uint8_t numa_support; /**< set by "--numa" parameter */ + extern uint16_t port_topology; /**< set by "--port-topology" parameter */ + extern uint8_t no_flush_rx; /** +Date: Fri, 10 Mar 2023 17:35:03 +0800 +Subject: net/hns3: fix possible truncation of hash key when config + +[ upstream commit bb38316e738ad6009b3f20b3abfaf27ea8cb0202 ] + +The hash key length of hns3 driver is obtained from firmware. If the +length is a multiple of HNS3_RSS_HASH_KEY_NUM (16), the last part +of hash key will be truncated. + +Fixes: 88347111eb53 ("net/hns3: refactor set RSS hash algorithm and key interface") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index d6e0754273..2011c18b9b 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -301,7 +301,8 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + req->hash_config |= (hash_algo & HNS3_RSS_HASH_ALGO_MASK); + req->hash_config |= (idx << HNS3_RSS_HASH_KEY_OFFSET_B); + +- if (idx == max_bd_num - 1) ++ if (idx == max_bd_num - 1 && ++ (key_len % HNS3_RSS_HASH_KEY_NUM) != 0) + cur_key_size = key_len % HNS3_RSS_HASH_KEY_NUM; + else + cur_key_size = HNS3_RSS_HASH_KEY_NUM; +-- +2.23.0 + diff --git a/0240-net-hns3-fix-possible-truncation-of-redirection-tabl.patch b/0240-net-hns3-fix-possible-truncation-of-redirection-tabl.patch new file mode 100644 index 0000000..01b8996 --- /dev/null +++ b/0240-net-hns3-fix-possible-truncation-of-redirection-tabl.patch @@ -0,0 +1,59 @@ +From 81cda32ef08ef6b179a36fcfe5b04b0a702dfa33 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:04 +0800 +Subject: net/hns3: fix possible truncation of redirection table + +[ upstream commit 4729376e555b58a739e6e231d403ca3b029ad92c ] + +The size of the redirection table is obtained from firmware. If the size +isn't a multiple of HNS3_RSS_CFG_TBL_SIZE, the redirection table from +user will be truncated. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 2011c18b9b..ed397587b5 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -329,6 +329,7 @@ int + hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size) + { + struct hns3_rss_indirection_table_cmd *req; ++ uint16_t max_bd_num, cfg_tbl_size; + struct hns3_cmd_desc desc; + uint8_t qid_msb_off; + uint8_t qid_msb_val; +@@ -337,14 +338,20 @@ hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size) + int ret; + + req = (struct hns3_rss_indirection_table_cmd *)desc.data; +- +- for (i = 0; i < size / HNS3_RSS_CFG_TBL_SIZE; i++) { ++ max_bd_num = DIV_ROUND_UP(size, HNS3_RSS_CFG_TBL_SIZE); ++ for (i = 0; i < max_bd_num; i++) { + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INDIR_TABLE, + false); + req->start_table_index = + rte_cpu_to_le_16(i * HNS3_RSS_CFG_TBL_SIZE); + req->rss_set_bitmap = rte_cpu_to_le_16(HNS3_RSS_SET_BITMAP_MSK); +- for (j = 0; j < HNS3_RSS_CFG_TBL_SIZE; j++) { ++ ++ if (i == max_bd_num - 1 && (size % HNS3_RSS_CFG_TBL_SIZE) != 0) ++ cfg_tbl_size = size % HNS3_RSS_CFG_TBL_SIZE; ++ else ++ cfg_tbl_size = HNS3_RSS_CFG_TBL_SIZE; ++ ++ for (j = 0; j < cfg_tbl_size; j++) { + q_id = indir[i * HNS3_RSS_CFG_TBL_SIZE + j]; + req->rss_result_l[j] = q_id & 0xff; + +-- +2.23.0 + diff --git a/0241-net-hns3-use-hardware-config-to-report-hash-key.patch b/0241-net-hns3-use-hardware-config-to-report-hash-key.patch new file mode 100644 index 0000000..0175113 --- /dev/null +++ b/0241-net-hns3-use-hardware-config-to-report-hash-key.patch @@ -0,0 +1,114 @@ +From da66262ce661cba4454a7e00971822791a5e1305 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:05 +0800 +Subject: net/hns3: use hardware config to report hash key + +[ upstream commit 7da415d27d8872a45a2d0cf9b5e66a8027c8f53c ] + +Currently, hns3_dev_rss_hash_conf_get() interface reports RSS key from +the key maintained by driver. It's better to report the key from +hardware, which is more realistic. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.c | 53 ++++++++++++++++++++++++++++++++++++- + drivers/net/hns3/hns3_rss.h | 3 ++- + 2 files changed, 54 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index ed397587b5..a8ea5150ab 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -321,6 +321,48 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + return 0; + } + ++int ++hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo, ++ uint8_t *key, uint8_t key_len) ++{ ++ struct hns3_rss_generic_config_cmd *req; ++ struct hns3_cmd_desc desc; ++ uint16_t cur_key_size; ++ uint16_t max_bd_num; ++ uint8_t *cur_key; ++ uint16_t idx; ++ int ret; ++ ++ req = (struct hns3_rss_generic_config_cmd *)desc.data; ++ max_bd_num = DIV_ROUND_UP(key_len, HNS3_RSS_HASH_KEY_NUM); ++ for (idx = 0; idx < max_bd_num; idx++) { ++ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_GENERIC_CONFIG, ++ true); ++ ++ req->hash_config |= (idx << HNS3_RSS_HASH_KEY_OFFSET_B); ++ ret = hns3_cmd_send(hw, &desc, 1); ++ if (ret) { ++ hns3_err(hw, "fail to obtain RSS algo and key from firmware, ret = %d", ++ ret); ++ return ret; ++ } ++ ++ if (idx == 0) ++ *hash_algo = req->hash_config & HNS3_RSS_HASH_ALGO_MASK; ++ ++ if (idx == max_bd_num - 1 && ++ (key_len % HNS3_RSS_HASH_KEY_NUM) != 0) ++ cur_key_size = key_len % HNS3_RSS_HASH_KEY_NUM; ++ else ++ cur_key_size = HNS3_RSS_HASH_KEY_NUM; ++ ++ cur_key = key + idx * HNS3_RSS_HASH_KEY_NUM; ++ memcpy(cur_key, req->hash_key, cur_key_size); ++ } ++ ++ return 0; ++} ++ + /* + * rss_indirection_table command function, opcode:0x0D07. + * Used to configure the indirection table of rss. +@@ -550,13 +592,22 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; + struct hns3_rss_conf *rss_cfg = &hw->rss_info; ++ uint8_t hash_algo; ++ int ret; + + rte_spinlock_lock(&hw->lock); + rss_conf->rss_hf = rss_cfg->conf.types; + + /* Get the RSS Key required by the user */ + if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) { +- memcpy(rss_conf->rss_key, rss_cfg->key, hw->rss_key_size); ++ ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key, ++ hw->rss_key_size); ++ if (ret != 0) { ++ rte_spinlock_unlock(&hw->lock); ++ hns3_err(hw, "obtain hash algo and key failed, ret = %d", ++ ret); ++ return ret; ++ } + rss_conf->rss_key_len = hw->rss_key_size; + } + rte_spinlock_unlock(&hw->lock); +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index d6f81996f4..be0141f602 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -112,6 +112,7 @@ void hns3_rss_uninit(struct hns3_adapter *hns); + int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); + int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + const uint8_t *key, uint8_t key_len); +- ++int hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo, ++ uint8_t *key, uint8_t key_len); + + #endif /* HNS3_RSS_H */ +-- +2.23.0 + diff --git a/0242-net-hns3-use-hardware-config-to-report-hash-types.patch b/0242-net-hns3-use-hardware-config-to-report-hash-types.patch new file mode 100644 index 0000000..ef63558 --- /dev/null +++ b/0242-net-hns3-use-hardware-config-to-report-hash-types.patch @@ -0,0 +1,490 @@ +From b36d99962a7ef0c2ae408e4edbabb95f00554d58 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:06 +0800 +Subject: net/hns3: use hardware config to report hash types + +[ upstream commit 406b25c7ffd2d84b1e09665872f69755c75e7d89 ] + +Use the configuration in hardware to report hash types instead +of data maintained in software. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.c | 260 ++++++++++++++++++++++++++++-------- + drivers/net/hns3/hns3_rss.h | 1 + + 2 files changed, 208 insertions(+), 53 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index a8ea5150ab..9addc00a67 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -70,6 +70,17 @@ enum hns3_tuple_field { + HNS3_RSS_FIELD_IPV6_FRAG_IP_S + }; + ++#define HNS3_RSS_TUPLE_IPV4_TCP_M GENMASK(3, 0) ++#define HNS3_RSS_TUPLE_IPV4_UDP_M GENMASK(11, 8) ++#define HNS3_RSS_TUPLE_IPV4_SCTP_M GENMASK(20, 16) ++#define HNS3_RSS_TUPLE_IPV4_NONF_M GENMASK(25, 24) ++#define HNS3_RSS_TUPLE_IPV4_FLAG_M GENMASK(27, 26) ++#define HNS3_RSS_TUPLE_IPV6_TCP_M GENMASK(35, 32) ++#define HNS3_RSS_TUPLE_IPV6_UDP_M GENMASK(43, 40) ++#define HNS3_RSS_TUPLE_IPV6_SCTP_M GENMASK(52, 48) ++#define HNS3_RSS_TUPLE_IPV6_NONF_M GENMASK(57, 56) ++#define HNS3_RSS_TUPLE_IPV6_FLAG_M GENMASK(59, 58) ++ + enum hns3_rss_tuple_type { + HNS3_RSS_IP_TUPLE, + HNS3_RSS_IP_L4_TUPLE, +@@ -79,200 +90,249 @@ static const struct { + uint64_t rss_types; + uint16_t tuple_type; + uint64_t rss_field; ++ uint64_t tuple_mask; + } hns3_set_tuple_table[] = { + /* IPV4-FRAG */ + { RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S), ++ HNS3_RSS_TUPLE_IPV4_FLAG_M }, + { RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV4_FLAG_M }, + { RTE_ETH_RSS_FRAG_IPV4, + HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV4_FLAG_M }, + + /* IPV4 */ + { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S), ++ HNS3_RSS_TUPLE_IPV4_NONF_M }, + { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV4_NONF_M }, + { RTE_ETH_RSS_IPV4, + HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV4_NONF_M }, + + /* IPV4-OTHER */ + { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S), ++ HNS3_RSS_TUPLE_IPV4_NONF_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV4_NONF_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_OTHER, + HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV4_NONF_M }, + + /* IPV4-TCP */ + { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S), ++ HNS3_RSS_TUPLE_IPV4_TCP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D), ++ HNS3_RSS_TUPLE_IPV4_TCP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L4_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S), ++ HNS3_RSS_TUPLE_IPV4_TCP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L4_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D), ++ HNS3_RSS_TUPLE_IPV4_TCP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_TCP, + HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D), ++ HNS3_RSS_TUPLE_IPV4_TCP_M }, + + /* IPV4-UDP */ + { RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S), ++ HNS3_RSS_TUPLE_IPV4_UDP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D), ++ HNS3_RSS_TUPLE_IPV4_UDP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L4_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S), ++ HNS3_RSS_TUPLE_IPV4_UDP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L4_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D), ++ HNS3_RSS_TUPLE_IPV4_UDP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_UDP, + HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D), ++ HNS3_RSS_TUPLE_IPV4_UDP_M }, + + /* IPV4-SCTP */ + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S), ++ HNS3_RSS_TUPLE_IPV4_SCTP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D), ++ HNS3_RSS_TUPLE_IPV4_SCTP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L4_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S), ++ HNS3_RSS_TUPLE_IPV4_SCTP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L4_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D), ++ HNS3_RSS_TUPLE_IPV4_SCTP_M }, + { RTE_ETH_RSS_NONFRAG_IPV4_SCTP, + HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) | +- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER), ++ HNS3_RSS_TUPLE_IPV4_SCTP_M }, + + /* IPV6-FRAG */ + { RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S), ++ HNS3_RSS_TUPLE_IPV6_FLAG_M }, + { RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV6_FLAG_M }, + { RTE_ETH_RSS_FRAG_IPV6, + HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV6_FLAG_M }, + + /* IPV6 */ + { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S), ++ HNS3_RSS_TUPLE_IPV6_NONF_M }, + { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV6_NONF_M }, + { RTE_ETH_RSS_IPV6, + HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV6_NONF_M }, + + /* IPV6-OTHER */ + { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S), ++ HNS3_RSS_TUPLE_IPV6_NONF_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV6_NONF_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_OTHER, + HNS3_RSS_IP_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D), ++ HNS3_RSS_TUPLE_IPV6_NONF_M }, + + /* IPV6-TCP */ + { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S), ++ HNS3_RSS_TUPLE_IPV6_TCP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D), ++ HNS3_RSS_TUPLE_IPV6_TCP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L4_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S), ++ HNS3_RSS_TUPLE_IPV6_TCP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L4_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D), ++ HNS3_RSS_TUPLE_IPV6_TCP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_TCP, + HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D), ++ HNS3_RSS_TUPLE_IPV6_TCP_M }, + + /* IPV6-UDP */ + { RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S), ++ HNS3_RSS_TUPLE_IPV6_UDP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D), ++ HNS3_RSS_TUPLE_IPV6_UDP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L4_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S), ++ HNS3_RSS_TUPLE_IPV6_UDP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L4_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D), ++ HNS3_RSS_TUPLE_IPV6_UDP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_UDP, + HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D), ++ HNS3_RSS_TUPLE_IPV6_UDP_M }, + + /* IPV6-SCTP */ + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L3_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S), ++ HNS3_RSS_TUPLE_IPV6_SCTP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L3_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D), ++ HNS3_RSS_TUPLE_IPV6_SCTP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_SRC_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S), ++ HNS3_RSS_TUPLE_IPV6_SCTP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_DST_ONLY, + HNS3_RSS_IP_L4_TUPLE, +- BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D), ++ HNS3_RSS_TUPLE_IPV6_SCTP_M }, + { RTE_ETH_RSS_NONFRAG_IPV6_SCTP, + HNS3_RSS_IP_L4_TUPLE, + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) | +- BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) }, ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER), ++ HNS3_RSS_TUPLE_IPV6_SCTP_M }, + }; + + /* +@@ -576,6 +636,96 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + return ret; + } + ++int ++hns3_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields) ++{ ++ struct hns3_rss_input_tuple_cmd *req; ++ struct hns3_cmd_desc desc; ++ int ret; ++ ++ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, true); ++ req = (struct hns3_rss_input_tuple_cmd *)desc.data; ++ ret = hns3_cmd_send(hw, &desc, 1); ++ if (ret != 0) { ++ hns3_err(hw, "fail to get RSS hash tuple fields from firmware, ret = %d", ++ ret); ++ return ret; ++ } ++ ++ *tuple_fields = rte_le_to_cpu_64(req->tuple_field); ++ ++ return 0; ++} ++ ++static uint64_t ++hns3_rss_tuple_fields_to_rss_hf(struct hns3_hw *hw, uint64_t tuple_fields) ++{ ++ uint64_t ipv6_sctp_l4_mask = ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) | ++ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S); ++ uint64_t rss_hf = 0; ++ uint64_t tuple_mask; ++ uint32_t i; ++ ++ for (i = 0; i < RTE_DIM(hns3_set_tuple_table); i++) { ++ tuple_mask = hns3_set_tuple_table[i].tuple_mask; ++ /* ++ * The RSS hash of the packet type is disabled if its tuples is ++ * zero. ++ */ ++ if ((tuple_fields & tuple_mask) == 0) ++ continue; ++ ++ /* ++ * Some hardware don't support to use src/dst port fields to ++ * hash for IPV6-SCTP packet. ++ */ ++ if ((hns3_set_tuple_table[i].rss_types & ++ RTE_ETH_RSS_NONFRAG_IPV6_SCTP) && ++ !hw->rss_info.ipv6_sctp_offload_supported) ++ tuple_mask &= ~ipv6_sctp_l4_mask; ++ ++ /* ++ * The framework (ethdev ops) or driver (rte flow API) ensure ++ * that both L3_SRC/DST_ONLY and L4_SRC/DST_ONLY cannot be set ++ * to driver at the same time. But if user doesn't specify ++ * anything L3/L4_SRC/DST_ONLY, driver enables all tuple fields. ++ * In this case, driver should not report L3/L4_SRC/DST_ONLY. ++ */ ++ if ((tuple_fields & tuple_mask) == tuple_mask) { ++ /* Skip the item enabled part tuples. */ ++ if ((tuple_fields & hns3_set_tuple_table[i].rss_field) != ++ tuple_mask) ++ continue; ++ ++ rss_hf |= hns3_set_tuple_table[i].rss_types; ++ continue; ++ } ++ ++ /* Match the item enabled part tuples.*/ ++ if ((tuple_fields & hns3_set_tuple_table[i].rss_field) == ++ hns3_set_tuple_table[i].rss_field) ++ rss_hf |= hns3_set_tuple_table[i].rss_types; ++ } ++ ++ return rss_hf; ++} ++ ++static int ++hns3_rss_hash_get_rss_hf(struct hns3_hw *hw, uint64_t *rss_hf) ++{ ++ uint64_t tuple_fields; ++ int ret; ++ ++ ret = hns3_get_rss_tuple_field(hw, &tuple_fields); ++ if (ret != 0) ++ return ret; ++ ++ *rss_hf = hns3_rss_tuple_fields_to_rss_hf(hw, tuple_fields); ++ ++ return 0; ++} ++ + /* + * Get rss key and rss_hf types set of RSS hash configuration. + * @param dev +@@ -591,28 +741,32 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +- struct hns3_rss_conf *rss_cfg = &hw->rss_info; + uint8_t hash_algo; + int ret; + + rte_spinlock_lock(&hw->lock); +- rss_conf->rss_hf = rss_cfg->conf.types; ++ ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf); ++ if (ret != 0) { ++ hns3_err(hw, "obtain hash tuples failed, ret = %d", ret); ++ goto out; ++ } + + /* Get the RSS Key required by the user */ + if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) { + ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key, + hw->rss_key_size); + if (ret != 0) { +- rte_spinlock_unlock(&hw->lock); + hns3_err(hw, "obtain hash algo and key failed, ret = %d", + ret); +- return ret; ++ goto out; + } + rss_conf->rss_key_len = hw->rss_key_size; + } ++ ++out: + rte_spinlock_unlock(&hw->lock); + +- return 0; ++ return ret; + } + + /* +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index be0141f602..17473e70e2 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -110,6 +110,7 @@ int hns3_rss_reset_indir_table(struct hns3_hw *hw); + int hns3_config_rss(struct hns3_adapter *hns); + void hns3_rss_uninit(struct hns3_adapter *hns); + int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); ++int hns3_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields); + int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + const uint8_t *key, uint8_t key_len); + int hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo, +-- +2.23.0 + diff --git a/0243-net-hns3-use-hardware-config-to-report-redirection-t.patch b/0243-net-hns3-use-hardware-config-to-report-redirection-t.patch new file mode 100644 index 0000000..df64168 --- /dev/null +++ b/0243-net-hns3-use-hardware-config-to-report-redirection-t.patch @@ -0,0 +1,133 @@ +From 866a61065fb67ec7e8cf34f5919ca93633d09cf7 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:07 +0800 +Subject: net/hns3: use hardware config to report redirection table + +[ upstream commit d1e37d1c6916858314a2c67e6317b0bb6c691b36 ] + +Currently, reta_query() API reports the redirection table from software. +This patch uses the one in hardware to report. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.h | 1 + + drivers/net/hns3/hns3_rss.c | 65 ++++++++++++++++++++++++++++++++++--- + 2 files changed, 62 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index 994dfc48cc..eb394c9dec 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -606,6 +606,7 @@ struct hns3_rss_input_tuple_cmd { + #define HNS3_RSS_CFG_TBL_SIZE_H 4 + #define HNS3_RSS_CFG_TBL_BW_H 2 + #define HNS3_RSS_CFG_TBL_BW_L 8 ++#define HNS3_RSS_CFG_TBL_BW_H_M 0x3 + + /* Configure the indirection table, opcode:0x0D07 */ + struct hns3_rss_indirection_table_cmd { +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 9addc00a67..7dc4e03d83 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -481,6 +481,54 @@ hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size) + return 0; + } + ++static int ++hns3_get_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size) ++{ ++ struct hns3_rss_indirection_table_cmd *req; ++ uint16_t max_bd_num, cfg_tbl_size; ++ uint8_t qid_msb_off, qid_msb_idx; ++ struct hns3_cmd_desc desc; ++ uint16_t q_id, q_hi, q_lo; ++ uint8_t rss_result_h; ++ uint16_t i, j; ++ int ret; ++ ++ req = (struct hns3_rss_indirection_table_cmd *)desc.data; ++ max_bd_num = DIV_ROUND_UP(size, HNS3_RSS_CFG_TBL_SIZE); ++ for (i = 0; i < max_bd_num; i++) { ++ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INDIR_TABLE, ++ true); ++ req->start_table_index = ++ rte_cpu_to_le_16(i * HNS3_RSS_CFG_TBL_SIZE); ++ ret = hns3_cmd_send(hw, &desc, 1); ++ if (ret) { ++ hns3_err(hw, "fail to get RSS indirection table from firmware, ret = %d", ++ ret); ++ return ret; ++ } ++ ++ if (i == max_bd_num - 1 && (size % HNS3_RSS_CFG_TBL_SIZE) != 0) ++ cfg_tbl_size = size % HNS3_RSS_CFG_TBL_SIZE; ++ else ++ cfg_tbl_size = HNS3_RSS_CFG_TBL_SIZE; ++ ++ for (j = 0; j < cfg_tbl_size; j++) { ++ qid_msb_idx = ++ j * HNS3_RSS_CFG_TBL_BW_H / HNS3_BITS_PER_BYTE; ++ rss_result_h = req->rss_result_h[qid_msb_idx]; ++ qid_msb_off = ++ j * HNS3_RSS_CFG_TBL_BW_H % HNS3_BITS_PER_BYTE; ++ q_hi = (rss_result_h >> qid_msb_off) & ++ HNS3_RSS_CFG_TBL_BW_H_M; ++ q_lo = req->rss_result_l[j]; ++ q_id = (q_hi << HNS3_RSS_CFG_TBL_BW_L) | q_lo; ++ indir[i * HNS3_RSS_CFG_TBL_SIZE + j] = q_id; ++ } ++ } ++ ++ return 0; ++} ++ + int + hns3_rss_reset_indir_table(struct hns3_hw *hw) + { +@@ -842,10 +890,11 @@ hns3_dev_rss_reta_query(struct rte_eth_dev *dev, + uint16_t reta_size) + { + struct hns3_adapter *hns = dev->data->dev_private; ++ uint16_t reta_table[HNS3_RSS_IND_TBL_SIZE_MAX]; + struct hns3_hw *hw = &hns->hw; +- struct hns3_rss_conf *rss_cfg = &hw->rss_info; + uint16_t idx, shift; + uint16_t i; ++ int ret; + + if (reta_size != hw->rss_ind_tbl_size) { + hns3_err(hw, "The size of hash lookup table configured (%u)" +@@ -854,14 +903,22 @@ hns3_dev_rss_reta_query(struct rte_eth_dev *dev, + return -EINVAL; + } + rte_spinlock_lock(&hw->lock); ++ ret = hns3_get_rss_indir_table(hw, reta_table, reta_size); ++ if (ret != 0) { ++ rte_spinlock_unlock(&hw->lock); ++ hns3_err(hw, "query RSS redirection table failed, ret = %d.", ++ ret); ++ return ret; ++ } ++ rte_spinlock_unlock(&hw->lock); ++ + for (i = 0; i < reta_size; i++) { + idx = i / RTE_ETH_RETA_GROUP_SIZE; + shift = i % RTE_ETH_RETA_GROUP_SIZE; + if (reta_conf[idx].mask & (1ULL << shift)) +- reta_conf[idx].reta[shift] = +- rss_cfg->rss_indirection_tbl[i]; ++ reta_conf[idx].reta[shift] = reta_table[i]; + } +- rte_spinlock_unlock(&hw->lock); ++ + return 0; + } + +-- +2.23.0 + diff --git a/0244-net-hns3-separate-setting-hash-algorithm.patch b/0244-net-hns3-separate-setting-hash-algorithm.patch new file mode 100644 index 0000000..0526a23 --- /dev/null +++ b/0244-net-hns3-separate-setting-hash-algorithm.patch @@ -0,0 +1,186 @@ +From e9ff78f09278b62f184277357777ebec6b7ac0f2 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:08 +0800 +Subject: net/hns3: separate setting hash algorithm + +[ upstream commit 1fcbef5ccb993b6028a3f8a68a7b01f9b8c67413 ] + +Currently, the setting of hash algorithm comes from the +default configuration in driver and the rte_flow interface. +The hash algorithm that is set to hardware in both ways is +saved in hw->rss_info.conf.func. + +But the 'func' in struct rte_flow_action_rss is usually used +in rte flow interface. And the ethdev ops interface may also +set hash algorithm in the future. It is not appropriate and +is a little messy for ethdev ops interface and driver default +configuration to use struct rte_flow_action_rss. So we have +to separate the RSS configuration from ethdev ops and rte +flow interface to make codes more easier to maintain. + +This patch separates hash algorithm by following ways: +1) 'hash_algo' in struct hns3_rss_conf is used for ethdev ops + interface or default configuration in driver. +2) Add a 'rte_flow_hash_algo' field in struct hns3_rss_conf + to save algorithm from rte flow interface. The main reasons + are as follows: + Currently, only the last rule is used to restore the rte + flow rule. If 'func' in RSS action is 'DEFAULT', it means + that this rule doesn't modify algorithm and driver need to + save current algorithm for restoring algorithm during reset + phase. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 60 +++++++++++++++++++++--------------- + drivers/net/hns3/hns3_rss.c | 14 +-------- + drivers/net/hns3/hns3_rss.h | 1 + + 3 files changed, 37 insertions(+), 38 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index e80ec0f053..0cb6914982 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1438,30 +1438,40 @@ hns3_disable_rss(struct hns3_hw *hw) + } + + static int +-hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, ++hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function func, + uint8_t *hash_algo) + { +- enum rte_eth_hash_function algo_func = *func; +- switch (algo_func) { +- case RTE_ETH_HASH_FUNCTION_DEFAULT: +- /* Keep *hash_algo as what it used to be */ +- algo_func = hw->rss_info.conf.func; +- break; +- case RTE_ETH_HASH_FUNCTION_TOEPLITZ: +- *hash_algo = HNS3_RSS_HASH_ALGO_TOEPLITZ; +- break; +- case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: +- *hash_algo = HNS3_RSS_HASH_ALGO_SIMPLE; +- break; +- case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: +- *hash_algo = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP; +- break; +- default: +- hns3_err(hw, "Invalid RSS algorithm configuration(%d)", +- algo_func); +- return -EINVAL; ++ const uint8_t hash_func_map[] = { ++ [RTE_ETH_HASH_FUNCTION_DEFAULT] = HNS3_RSS_HASH_ALGO_TOEPLITZ, ++ [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = HNS3_RSS_HASH_ALGO_TOEPLITZ, ++ [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = HNS3_RSS_HASH_ALGO_SIMPLE, ++ [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP, ++ }; ++ uint8_t key[HNS3_RSS_KEY_SIZE_MAX] = {0}; ++ int ret; ++ ++ if (func == RTE_ETH_HASH_FUNCTION_DEFAULT) { ++ ret = hns3_rss_get_algo_key(hw, hash_algo, key, ++ hw->rss_key_size); ++ if (ret != 0) { ++ hns3_err(hw, "fail to get current RSS hash algorithm, ret = %d", ++ ret); ++ return ret; ++ } ++ ++ /* ++ * During the phase of reset recovery, the hash algorithm ++ * obtained from hardware may not be the one used(saved in ++ * rte_flow_hash_algo) when this rule is delivered. ++ */ ++ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) && ++ *hash_algo != hw->rss_info.rte_flow_hash_algo) ++ *hash_algo = hw->rss_info.rte_flow_hash_algo; ++ ++ return 0; + } +- *func = algo_func; ++ ++ *hash_algo = hash_func_map[func]; + + return 0; + } +@@ -1471,6 +1481,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + { + uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; + bool use_default_key = false; ++ uint8_t hash_algo; + int ret; + + if (rss_config->key == NULL || rss_config->key_len != hw->rss_key_size) { +@@ -1480,18 +1491,17 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + use_default_key = true; + } + +- ret = hns3_parse_rss_algorithm(hw, &rss_config->func, +- &hw->rss_info.hash_algo); ++ ret = hns3_parse_rss_algorithm(hw, rss_config->func, &hash_algo); + if (ret) + return ret; + +- ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, ++ ret = hns3_rss_set_algo_key(hw, hash_algo, + use_default_key ? rss_key : rss_config->key, + hw->rss_key_size); + if (ret) + return ret; + +- hw->rss_info.conf.func = rss_config->func; ++ hw->rss_info.rte_flow_hash_algo = hash_algo; + + ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_config->types); + if (ret) +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 7dc4e03d83..dcd42b554a 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -1022,7 +1022,7 @@ hns3_rss_set_default_args(struct hns3_hw *hw) + uint16_t i; + + /* Default hash algorithm */ +- rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; ++ rss_cfg->hash_algo = HNS3_RSS_HASH_ALGO_TOEPLITZ; + + memcpy(rss_cfg->key, hns3_hash_key, + RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); +@@ -1046,18 +1046,6 @@ hns3_config_rss(struct hns3_adapter *hns) + + enum rte_eth_rx_mq_mode mq_mode = hw->data->dev_conf.rxmode.mq_mode; + +- switch (hw->rss_info.conf.func) { +- case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: +- hw->rss_info.hash_algo = HNS3_RSS_HASH_ALGO_SIMPLE; +- break; +- case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: +- hw->rss_info.hash_algo = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP; +- break; +- default: +- hw->rss_info.hash_algo = HNS3_RSS_HASH_ALGO_TOEPLITZ; +- break; +- } +- + ret = hns3_rss_set_algo_key(hw, rss_cfg->hash_algo, + hash_key, hw->rss_key_size); + if (ret) +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 17473e70e2..6e679b709b 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -42,6 +42,7 @@ struct hns3_rss_conf { + /* RSS parameters :algorithm, flow_types, key, queue */ + struct rte_flow_action_rss conf; + uint8_t hash_algo; /* hash function type defined by hardware */ ++ uint8_t rte_flow_hash_algo; + uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ + uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; + uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ +-- +2.23.0 + diff --git a/0245-net-hns3-separate-setting-hash-key.patch b/0245-net-hns3-separate-setting-hash-key.patch new file mode 100644 index 0000000..85b75f4 --- /dev/null +++ b/0245-net-hns3-separate-setting-hash-key.patch @@ -0,0 +1,49 @@ +From 8ca08cd0671207b57d934b439d7b245966fbbfe8 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:09 +0800 +Subject: net/hns3: separate setting hash key + +[ upstream commit fe9cc8b88babd0911d91dc194b35c7c352e2bf7b ] + +The settings of hash key comes from the ethdev ops (like, dev_configure +and rss_hash_update) and rte_flow API. For the ethdev ops, driver has +to save it to rss_info::key in hns3_hw structure so as to it can be +restored when reset is triggered. While rte_flow API no need to use +this field to save, they has a global flow_rss_list to maintain all +rules which save hash key. And hash key can be restored by this rule +information during the reset phase. + +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index dcd42b554a..401e3adfdf 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -376,8 +376,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + return ret; + } + } +- /* Update the shadow RSS key with user specified */ +- memcpy(hw->rss_info.key, key, hw->rss_key_size); ++ + return 0; + } + +@@ -672,6 +671,8 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + key, hw->rss_key_size); + if (ret) + goto set_algo_key_fail; ++ /* Update the shadow RSS key with user specified */ ++ memcpy(hw->rss_info.key, key, hw->rss_key_size); + } + rte_spinlock_unlock(&hw->lock); + +-- +2.23.0 + diff --git a/0246-net-hns3-separate-setting-redirection-table.patch b/0246-net-hns3-separate-setting-redirection-table.patch new file mode 100644 index 0000000..4e71a61 --- /dev/null +++ b/0246-net-hns3-separate-setting-redirection-table.patch @@ -0,0 +1,98 @@ +From 5a9f2de85e9f9185165c7fe82247ef6125ef4115 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:10 +0800 +Subject: net/hns3: separate setting redirection table + +[ upstream commit a421cb93462932717f23c5d8342381726e547ba6 ] + +The settings of redirection table comes from the ethdev ops (like, +dev_configure and rss_hash_update) and rte_flow API. For the ethdev +ops, driver has to save it to rss_info::rss_indirection_tbl in hns3_hw +structure so as to it can be restored when reset is triggered. +While rte_flow API no need to use this field to save, they has a global +RSS flow list to maintain all rules which can be used to restore the +table during the reset phase. + +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 2 -- + drivers/net/hns3/hns3_rss.c | 21 +++++++++++++-------- + 2 files changed, 13 insertions(+), 10 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 0cb6914982..875c0eec11 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1519,8 +1519,6 @@ hns3_update_indir_table(struct hns3_hw *hw, + uint32_t i; + + /* Fill in redirection table */ +- memcpy(indir_tbl, hw->rss_info.rss_indirection_tbl, +- sizeof(hw->rss_info.rss_indirection_tbl)); + for (i = 0, j = 0; i < hw->rss_ind_tbl_size; i++, j++) { + j %= num; + if (conf->queue[j] >= hw->alloc_rss_size) { +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 401e3adfdf..751033d98f 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -473,10 +473,6 @@ hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size) + } + } + +- /* Update redirection table of hw */ +- memcpy(hw->rss_info.rss_indirection_tbl, indir, +- sizeof(uint16_t) * size); +- + return 0; + } + +@@ -542,8 +538,11 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw) + } + + ret = hns3_set_rss_indir_table(hw, lut, hw->rss_ind_tbl_size); +- if (ret) +- hns3_err(hw, "RSS uninit indir table failed: %d", ret); ++ if (ret != 0) ++ hns3_err(hw, "RSS uninit indir table failed, ret = %d.", ret); ++ else ++ memcpy(hw->rss_info.rss_indirection_tbl, lut, ++ sizeof(uint16_t) * hw->rss_ind_tbl_size); + rte_free(lut); + + return ret; +@@ -855,12 +854,12 @@ hns3_dev_rss_reta_update(struct rte_eth_dev *dev, + idx = i / RTE_ETH_RETA_GROUP_SIZE; + shift = i % RTE_ETH_RETA_GROUP_SIZE; + if (reta_conf[idx].reta[shift] >= hw->alloc_rss_size) { +- rte_spinlock_unlock(&hw->lock); + hns3_err(hw, "queue id(%u) set to redirection table " + "exceeds queue number(%u) allocated to a TC", + reta_conf[idx].reta[shift], + hw->alloc_rss_size); +- return -EINVAL; ++ ret = -EINVAL; ++ goto out; + } + + if (reta_conf[idx].mask & (1ULL << shift)) +@@ -869,7 +868,13 @@ hns3_dev_rss_reta_update(struct rte_eth_dev *dev, + + ret = hns3_set_rss_indir_table(hw, indirection_tbl, + hw->rss_ind_tbl_size); ++ if (ret != 0) ++ goto out; + ++ memcpy(rss_cfg->rss_indirection_tbl, indirection_tbl, ++ sizeof(uint16_t) * hw->rss_ind_tbl_size); ++ ++out: + rte_spinlock_unlock(&hw->lock); + return ret; + } +-- +2.23.0 + diff --git a/0247-net-hns3-separate-setting-RSS-types.patch b/0247-net-hns3-separate-setting-RSS-types.patch new file mode 100644 index 0000000..457d326 --- /dev/null +++ b/0247-net-hns3-separate-setting-RSS-types.patch @@ -0,0 +1,131 @@ +From b99379a51ab920cbd8d4ee51122efff2f1af57db Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:11 +0800 +Subject: net/hns3: separate setting RSS types + +[ upstream commit 791e56935e488b8154a83daaf3952e1901ed7552 ] + +The settings of RSS types comes from the ethdev ops (like, dev_configure +and rss_hash_update) and rte_flow API. For the ethdev ops, driver has to +save it so as to it can be restored when reset is triggered. +While rte_flow API no need to maintain this field, it can be restored by +the saved rule. + +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 3 ++- + drivers/net/hns3/hns3_rss.c | 22 ++++++++++++++-------- + drivers/net/hns3/hns3_rss.h | 1 + + 3 files changed, 17 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 875c0eec11..9e51891bd9 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1433,6 +1433,7 @@ hns3_disable_rss(struct hns3_hw *hw) + ret = hns3_set_rss_tuple_by_rss_hf(hw, 0); + if (ret) + return ret; ++ hw->rss_info.rss_hf = 0; + + return 0; + } +@@ -1580,7 +1581,7 @@ hns3_config_rss_filter(struct hns3_hw *hw, + /* Filter the unsupported flow types */ + flow_types = conf->conf.types ? + rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT : +- hw->rss_info.conf.types; ++ hw->rss_info.rss_hf; + if (flow_types != rss_flow_conf.types) + hns3_warn(hw, "modified RSS types based on hardware support," + " requested:0x%" PRIx64 " configured:0x%" PRIx64, +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 751033d98f..f51d70a8e5 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -628,9 +628,6 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf) + return ret; + } + +- /* Update supported flow types when set tuple success */ +- hw->rss_info.conf.types = rss_hf; +- + return 0; + } + +@@ -648,7 +645,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- uint64_t rss_hf_bk = hw->rss_info.conf.types; ++ uint64_t rss_hf_bk = hw->rss_info.rss_hf; + uint8_t key_len = rss_conf->rss_key_len; + uint64_t rss_hf = rss_conf->rss_hf; + uint8_t *key = rss_conf->rss_key; +@@ -673,6 +670,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + /* Update the shadow RSS key with user specified */ + memcpy(hw->rss_info.key, key, hw->rss_key_size); + } ++ hw->rss_info.rss_hf = rss_hf; + rte_spinlock_unlock(&hw->lock); + + return 0; +@@ -1030,6 +1028,7 @@ hns3_rss_set_default_args(struct hns3_hw *hw) + /* Default hash algorithm */ + rss_cfg->hash_algo = HNS3_RSS_HASH_ALGO_TOEPLITZ; + ++ hw->rss_info.rss_hf = 0; + memcpy(rss_cfg->key, hns3_hash_key, + RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); + +@@ -1067,15 +1066,22 @@ hns3_config_rss(struct hns3_adapter *hns) + return ret; + + /* +- * When muli-queue RSS mode flag is not set or unsupported tuples are ++ * When multi-queue RSS mode flag is not set or unsupported tuples are + * set, disable all tuples. + */ +- rss_hf = hw->rss_info.conf.types; ++ rss_hf = hw->rss_info.rss_hf; + if (!((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) || + !(rss_hf & HNS3_ETH_RSS_SUPPORT)) + rss_hf = 0; + +- return hns3_set_rss_tuple_by_rss_hf(hw, rss_hf); ++ ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_hf); ++ if (ret != 0) { ++ hns3_err(hw, "set RSS tuples failed, ret = %d.", ret); ++ return ret; ++ } ++ hw->rss_info.rss_hf = rss_hf; ++ ++ return 0; + } + + /* +@@ -1093,5 +1099,5 @@ hns3_rss_uninit(struct hns3_adapter *hns) + return; + + /* Disable RSS */ +- hw->rss_info.conf.types = 0; ++ hw->rss_info.rss_hf = 0; + } +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 6e679b709b..21b90789d0 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -41,6 +41,7 @@ + struct hns3_rss_conf { + /* RSS parameters :algorithm, flow_types, key, queue */ + struct rte_flow_action_rss conf; ++ uint64_t rss_hf; + uint8_t hash_algo; /* hash function type defined by hardware */ + uint8_t rte_flow_hash_algo; + uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ +-- +2.23.0 + diff --git a/0248-net-hns3-separate-setting-and-clearing-RSS-rule.patch b/0248-net-hns3-separate-setting-and-clearing-RSS-rule.patch new file mode 100644 index 0000000..85d77c6 --- /dev/null +++ b/0248-net-hns3-separate-setting-and-clearing-RSS-rule.patch @@ -0,0 +1,126 @@ +From 0667045e83f2ed2769e1e71947ce6530108739ed Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:12 +0800 +Subject: net/hns3: separate setting and clearing RSS rule + +[ upstream commit 1c3aeb2be4b8ef8b18846883ebbb9320f62cf097 ] + +Separate the setting and clearing of RSS rule. + +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 46 +++++++++++++++++------------------- + 1 file changed, 22 insertions(+), 24 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 9e51891bd9..80dda63afe 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1535,8 +1535,22 @@ hns3_update_indir_table(struct hns3_hw *hw, + } + + static int +-hns3_config_rss_filter(struct hns3_hw *hw, +- const struct hns3_rss_conf *conf, bool add) ++hns3_reset_rss_filter(struct hns3_hw *hw, const struct hns3_rss_conf *conf) ++{ ++ int ret; ++ ++ if (!conf->valid) ++ return 0; ++ ++ ret = hns3_disable_rss(hw); ++ if (ret) ++ hns3_err(hw, "RSS disable failed(%d)", ret); ++ ++ return ret; ++} ++ ++static int ++hns3_config_rss_filter(struct hns3_hw *hw, const struct hns3_rss_conf *conf) + { + uint64_t flow_types; + uint16_t num; +@@ -1553,19 +1567,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, + .queue = conf->conf.queue, + }; + +- if (!add) { +- if (!conf->valid) +- return 0; +- +- ret = hns3_disable_rss(hw); +- if (ret) { +- hns3_err(hw, "RSS disable failed(%d)", ret); +- return ret; +- } +- +- return 0; +- } +- + /* Set rx queues to use */ + num = RTE_MIN(hw->data->nb_rx_queues, rss_flow_conf.queue_num); + if (rss_flow_conf.queue_num > num) +@@ -1606,8 +1607,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) + rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); + while (rss_filter_ptr) { + TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); +- ret = hns3_config_rss_filter(hw, &rss_filter_ptr->filter_info, +- false); ++ ret = hns3_reset_rss_filter(hw, &rss_filter_ptr->filter_info); + if (ret) + rss_rule_fail_cnt++; + else +@@ -1636,7 +1636,7 @@ hns3_restore_rss_filter(struct hns3_hw *hw) + if (!filter->filter_info.valid) + continue; + +- ret = hns3_config_rss_filter(hw, &filter->filter_info, true); ++ ret = hns3_config_rss_filter(hw, &filter->filter_info); + if (ret != 0) { + hns3_err(hw, "restore RSS filter failed, ret=%d", ret); + goto out; +@@ -1680,8 +1680,7 @@ hns3_rss_action_is_dup(struct hns3_hw *hw, + } + + static int +-hns3_flow_parse_rss(struct rte_eth_dev *dev, +- const struct hns3_rss_conf *conf, bool add) ++hns3_flow_parse_rss(struct rte_eth_dev *dev, const struct hns3_rss_conf *conf) + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +@@ -1691,7 +1690,7 @@ hns3_flow_parse_rss(struct rte_eth_dev *dev, + return -EINVAL; + } + +- return hns3_config_rss_filter(hw, conf, add); ++ return hns3_config_rss_filter(hw, conf); + } + + static int +@@ -1778,7 +1777,7 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + } + } + +- ret = hns3_flow_parse_rss(dev, new_conf, true); ++ ret = hns3_flow_parse_rss(dev, new_conf); + if (ret != 0) { + rte_free(rss_filter_ptr); + return ret; +@@ -1961,8 +1960,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, + break; + case RTE_ETH_FILTER_HASH: + rss_filter_ptr = (struct hns3_rss_conf_ele *)flow->rule; +- ret = hns3_config_rss_filter(hw, &rss_filter_ptr->filter_info, +- false); ++ ret = hns3_reset_rss_filter(hw, &rss_filter_ptr->filter_info); + if (ret) + return rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_HANDLE, +-- +2.23.0 + diff --git a/0249-net-hns3-use-new-RSS-rule-to-configure-hardware.patch b/0249-net-hns3-use-new-RSS-rule-to-configure-hardware.patch new file mode 100644 index 0000000..82de7a0 --- /dev/null +++ b/0249-net-hns3-use-new-RSS-rule-to-configure-hardware.patch @@ -0,0 +1,121 @@ +From 08730d02d9f5cb532ea3953c2ae1920aaa123358 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:13 +0800 +Subject: net/hns3: use new RSS rule to configure hardware + +[ upstream commit 218a119a08e01f203f92b46334b6b2f03ff9765d ] + +Remove redundant assignment and directly use new RSS rule to configure +hardware. Additionally, considering that the new rule configuration may +need to be modified, the 'const' of input parameter about it is removed. + +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 52 ++++++++++++++---------------------- + 1 file changed, 20 insertions(+), 32 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 80dda63afe..3ac5279538 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1482,6 +1482,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + { + uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; + bool use_default_key = false; ++ uint64_t flow_types; + uint8_t hash_algo; + int ret; + +@@ -1501,10 +1502,18 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + hw->rss_key_size); + if (ret) + return ret; +- + hw->rss_info.rte_flow_hash_algo = hash_algo; + +- ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_config->types); ++ /* Filter the unsupported flow types */ ++ flow_types = rss_config->types ? ++ rss_config->types & HNS3_ETH_RSS_SUPPORT : ++ hw->rss_info.rss_hf; ++ if (flow_types != rss_config->types) ++ hns3_warn(hw, "modified RSS types based on hardware support," ++ " requested:0x%" PRIx64 " configured:0x%" PRIx64, ++ rss_config->types, flow_types); ++ ++ ret = hns3_set_rss_tuple_by_rss_hf(hw, flow_types); + if (ret) + hns3_err(hw, "Update RSS tuples by rss hf failed %d", ret); + +@@ -1550,48 +1559,27 @@ hns3_reset_rss_filter(struct hns3_hw *hw, const struct hns3_rss_conf *conf) + } + + static int +-hns3_config_rss_filter(struct hns3_hw *hw, const struct hns3_rss_conf *conf) ++hns3_config_rss_filter(struct hns3_hw *hw, struct hns3_rss_conf *conf) + { +- uint64_t flow_types; ++ struct rte_flow_action_rss *rss_act; + uint16_t num; + int ret; + +- struct rte_flow_action_rss rss_flow_conf = { +- .func = conf->conf.func, +- .level = conf->conf.level, +- .types = conf->conf.types, +- .key_len = conf->conf.key_len, +- .queue_num = conf->conf.queue_num, +- .key = conf->conf.key_len ? +- (void *)(uintptr_t)conf->conf.key : NULL, +- .queue = conf->conf.queue, +- }; +- ++ rss_act = &conf->conf; + /* Set rx queues to use */ +- num = RTE_MIN(hw->data->nb_rx_queues, rss_flow_conf.queue_num); +- if (rss_flow_conf.queue_num > num) ++ num = RTE_MIN(hw->data->nb_rx_queues, rss_act->queue_num); ++ if (rss_act->queue_num > num) + hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated", +- rss_flow_conf.queue_num); ++ rss_act->queue_num); + hns3_info(hw, "Max of contiguous %u PF queues are configured", num); + if (num) { +- ret = hns3_update_indir_table(hw, &rss_flow_conf, num); ++ ret = hns3_update_indir_table(hw, rss_act, num); + if (ret) + return ret; + } + +- /* Filter the unsupported flow types */ +- flow_types = conf->conf.types ? +- rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT : +- hw->rss_info.rss_hf; +- if (flow_types != rss_flow_conf.types) +- hns3_warn(hw, "modified RSS types based on hardware support," +- " requested:0x%" PRIx64 " configured:0x%" PRIx64, +- rss_flow_conf.types, flow_types); +- /* Update the useful flow types */ +- rss_flow_conf.types = flow_types; +- + /* Set hash algorithm and flow types by the user's config */ +- return hns3_hw_rss_hash_set(hw, &rss_flow_conf); ++ return hns3_hw_rss_hash_set(hw, rss_act); + } + + static int +@@ -1680,7 +1668,7 @@ hns3_rss_action_is_dup(struct hns3_hw *hw, + } + + static int +-hns3_flow_parse_rss(struct rte_eth_dev *dev, const struct hns3_rss_conf *conf) ++hns3_flow_parse_rss(struct rte_eth_dev *dev, struct hns3_rss_conf *conf) + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +-- +2.23.0 + diff --git a/0250-net-hns3-save-hash-algo-to-RSS-filter-list-node.patch b/0250-net-hns3-save-hash-algo-to-RSS-filter-list-node.patch new file mode 100644 index 0000000..77d24d8 --- /dev/null +++ b/0250-net-hns3-save-hash-algo-to-RSS-filter-list-node.patch @@ -0,0 +1,96 @@ +From e439b6f69b496ab010cff1b87f7a8cd83e258faf Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:14 +0800 +Subject: net/hns3: save hash algo to RSS filter list node + +[ upstream commit 9d34b8a181bf022fe3a3a3ae8511f3d921fc5c67 ] + +Save hash algo from rte flow RSS rule to RSS filter list node +instead of struct hns3_rss_conf. + +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 3ac5279538..f073adebb6 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1439,7 +1439,7 @@ hns3_disable_rss(struct hns3_hw *hw) + } + + static int +-hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function func, ++hns3_parse_rss_algorithm(struct hns3_hw *hw, struct hns3_rss_conf *rss_conf, + uint8_t *hash_algo) + { + const uint8_t hash_func_map[] = { +@@ -1451,7 +1451,7 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function func, + uint8_t key[HNS3_RSS_KEY_SIZE_MAX] = {0}; + int ret; + +- if (func == RTE_ETH_HASH_FUNCTION_DEFAULT) { ++ if (rss_conf->conf.func == RTE_ETH_HASH_FUNCTION_DEFAULT) { + ret = hns3_rss_get_algo_key(hw, hash_algo, key, + hw->rss_key_size); + if (ret != 0) { +@@ -1466,20 +1466,21 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function func, + * rte_flow_hash_algo) when this rule is delivered. + */ + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) && +- *hash_algo != hw->rss_info.rte_flow_hash_algo) +- *hash_algo = hw->rss_info.rte_flow_hash_algo; ++ *hash_algo != rss_conf->rte_flow_hash_algo) ++ *hash_algo = rss_conf->rte_flow_hash_algo; + + return 0; + } + +- *hash_algo = hash_func_map[func]; ++ *hash_algo = hash_func_map[rss_conf->conf.func]; + + return 0; + } + + static int +-hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) ++hns3_hw_rss_hash_set(struct hns3_hw *hw, struct hns3_rss_conf *conf) + { ++ struct rte_flow_action_rss *rss_config = &conf->conf; + uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; + bool use_default_key = false; + uint64_t flow_types; +@@ -1493,7 +1494,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + use_default_key = true; + } + +- ret = hns3_parse_rss_algorithm(hw, rss_config->func, &hash_algo); ++ ret = hns3_parse_rss_algorithm(hw, conf, &hash_algo); + if (ret) + return ret; + +@@ -1502,7 +1503,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + hw->rss_key_size); + if (ret) + return ret; +- hw->rss_info.rte_flow_hash_algo = hash_algo; ++ conf->rte_flow_hash_algo = hash_algo; + + /* Filter the unsupported flow types */ + flow_types = rss_config->types ? +@@ -1579,7 +1580,7 @@ hns3_config_rss_filter(struct hns3_hw *hw, struct hns3_rss_conf *conf) + } + + /* Set hash algorithm and flow types by the user's config */ +- return hns3_hw_rss_hash_set(hw, rss_act); ++ return hns3_hw_rss_hash_set(hw, conf); + } + + static int +-- +2.23.0 + diff --git a/0251-net-hns3-allow-adding-queue-buffer-size-hash-rule.patch b/0251-net-hns3-allow-adding-queue-buffer-size-hash-rule.patch new file mode 100644 index 0000000..31542c5 --- /dev/null +++ b/0251-net-hns3-allow-adding-queue-buffer-size-hash-rule.patch @@ -0,0 +1,37 @@ +From 9810ccb9266f09bef6f0d8cfcab6ac0d203d8e23 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:15 +0800 +Subject: net/hns3: allow adding queue buffer size hash rule + +[ upstream commit 8095bf3e6d8ca7349e0a15f95407acd2063e7be0 ] + +The maximum queue number from RSS flow rule allowed depends on +the maximum queue number (512) under one TC instead of the one +of Rx/Tx queue so as to eliminate restrictions on user usage. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rss.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 21b90789d0..cc0bb8431d 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -37,7 +37,8 @@ + #define HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP 2 + #define HNS3_RSS_HASH_ALGO_MASK 0xf + +-#define HNS3_RSS_QUEUES_BUFFER_NUM 64 /* Same as the Max rx/tx queue num */ ++/* Same as the Max queue num under TC */ ++#define HNS3_RSS_QUEUES_BUFFER_NUM 512 + struct hns3_rss_conf { + /* RSS parameters :algorithm, flow_types, key, queue */ + struct rte_flow_action_rss conf; +-- +2.23.0 + diff --git a/0252-net-hns3-separate-flow-RSS-config-from-RSS-conf.patch b/0252-net-hns3-separate-flow-RSS-config-from-RSS-conf.patch new file mode 100644 index 0000000..22b7646 --- /dev/null +++ b/0252-net-hns3-separate-flow-RSS-config-from-RSS-conf.patch @@ -0,0 +1,169 @@ +From bfbcc4acf9a007f4774e54febda3eac275b9c747 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:16 +0800 +Subject: net/hns3: separate flow RSS config from RSS conf + +[ upstream commit b93ad0cc7677881911e5fc3baa89e0a0bbd73c48 ] + +Some RSS fields in struct hns3_rss_conf (e.g. conf, queue, +valid) are only used when create RSS flow rule, which is +unnecessary for RSS configuration information from ethdev +ops. This patch removes these fields from hns3_rss_conf +and add a new struct hns3_flow_rss_conf as rte flow +RSS filter list node element. + +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 23 ++++++++++++----------- + drivers/net/hns3/hns3_flow.h | 10 +++++++++- + drivers/net/hns3/hns3_rss.h | 5 ----- + 3 files changed, 21 insertions(+), 17 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index f073adebb6..b1189455ec 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1359,7 +1359,6 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +- struct hns3_rss_conf *rss_conf = &hw->rss_info; + const struct rte_flow_action_rss *rss; + const struct rte_flow_action *act; + uint32_t act_index = 0; +@@ -1374,7 +1373,7 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, + act, "no valid queues"); + } + +- if (rss->queue_num > RTE_DIM(rss_conf->queue)) ++ if (rss->queue_num > HNS3_RSS_QUEUES_BUFFER_NUM) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, + "queue number configured exceeds " +@@ -1439,7 +1438,7 @@ hns3_disable_rss(struct hns3_hw *hw) + } + + static int +-hns3_parse_rss_algorithm(struct hns3_hw *hw, struct hns3_rss_conf *rss_conf, ++hns3_parse_rss_algorithm(struct hns3_hw *hw, struct hns3_flow_rss_conf *rss_conf, + uint8_t *hash_algo) + { + const uint8_t hash_func_map[] = { +@@ -1466,8 +1465,8 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, struct hns3_rss_conf *rss_conf, + * rte_flow_hash_algo) when this rule is delivered. + */ + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) && +- *hash_algo != rss_conf->rte_flow_hash_algo) +- *hash_algo = rss_conf->rte_flow_hash_algo; ++ *hash_algo != rss_conf->hash_algo) ++ *hash_algo = rss_conf->hash_algo; + + return 0; + } +@@ -1478,7 +1477,7 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, struct hns3_rss_conf *rss_conf, + } + + static int +-hns3_hw_rss_hash_set(struct hns3_hw *hw, struct hns3_rss_conf *conf) ++hns3_hw_rss_hash_set(struct hns3_hw *hw, struct hns3_flow_rss_conf *conf) + { + struct rte_flow_action_rss *rss_config = &conf->conf; + uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; +@@ -1503,7 +1502,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct hns3_rss_conf *conf) + hw->rss_key_size); + if (ret) + return ret; +- conf->rte_flow_hash_algo = hash_algo; ++ conf->hash_algo = hash_algo; + + /* Filter the unsupported flow types */ + flow_types = rss_config->types ? +@@ -1545,7 +1544,8 @@ hns3_update_indir_table(struct hns3_hw *hw, + } + + static int +-hns3_reset_rss_filter(struct hns3_hw *hw, const struct hns3_rss_conf *conf) ++hns3_reset_rss_filter(struct hns3_hw *hw, ++ const struct hns3_flow_rss_conf *conf) + { + int ret; + +@@ -1560,7 +1560,7 @@ hns3_reset_rss_filter(struct hns3_hw *hw, const struct hns3_rss_conf *conf) + } + + static int +-hns3_config_rss_filter(struct hns3_hw *hw, struct hns3_rss_conf *conf) ++hns3_config_rss_filter(struct hns3_hw *hw, struct hns3_flow_rss_conf *conf) + { + struct rte_flow_action_rss *rss_act; + uint16_t num; +@@ -1669,7 +1669,8 @@ hns3_rss_action_is_dup(struct hns3_hw *hw, + } + + static int +-hns3_flow_parse_rss(struct rte_eth_dev *dev, struct hns3_rss_conf *conf) ++hns3_flow_parse_rss(struct rte_eth_dev *dev, ++ struct hns3_flow_rss_conf *conf) + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +@@ -1739,8 +1740,8 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + const struct rte_flow_action_rss *rss_act; + struct hns3_rss_conf_ele *rss_filter_ptr; ++ struct hns3_flow_rss_conf *new_conf; + struct hns3_rss_conf_ele *filter_ptr; +- struct hns3_rss_conf *new_conf; + int ret; + + rss_filter_ptr = rte_zmalloc("hns3 rss filter", +diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h +index e4b2fdf2e6..90126f2b6e 100644 +--- a/drivers/net/hns3/hns3_flow.h ++++ b/drivers/net/hns3/hns3_flow.h +@@ -24,10 +24,18 @@ struct rte_flow { + uint32_t counter_id; + }; + ++struct hns3_flow_rss_conf { ++ struct rte_flow_action_rss conf; ++ uint8_t hash_algo; ++ uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ ++ uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ ++ bool valid; /* check if RSS rule is valid */ ++}; ++ + /* rss filter list structure */ + struct hns3_rss_conf_ele { + TAILQ_ENTRY(hns3_rss_conf_ele) entries; +- struct hns3_rss_conf filter_info; ++ struct hns3_flow_rss_conf filter_info; + }; + + /* hns3_flow memory list structure */ +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index cc0bb8431d..d19730c69c 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -40,15 +40,10 @@ + /* Same as the Max queue num under TC */ + #define HNS3_RSS_QUEUES_BUFFER_NUM 512 + struct hns3_rss_conf { +- /* RSS parameters :algorithm, flow_types, key, queue */ +- struct rte_flow_action_rss conf; + uint64_t rss_hf; + uint8_t hash_algo; /* hash function type defined by hardware */ +- uint8_t rte_flow_hash_algo; + uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ + uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; +- uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ +- bool valid; /* check if RSS rule is valid */ + /* + * For IPv6 SCTP packets type, check whether the NIC hardware support + * RSS hash using the src/dst port as the input tuple. For Kunpeng920 +-- +2.23.0 + diff --git a/0253-net-hns3-reimplement-hash-flow-function.patch b/0253-net-hns3-reimplement-hash-flow-function.patch new file mode 100644 index 0000000..ea37f42 --- /dev/null +++ b/0253-net-hns3-reimplement-hash-flow-function.patch @@ -0,0 +1,1697 @@ +From d5ee6b81de99a8699a6d4adb620ecc88103eb6e2 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:17 +0800 +Subject: net/hns3: reimplement hash flow function + +[ upstream commit e3069658da9ffb6f83a0d972ff2776c405eb6a8f ] + +Currently, hns3 driver supports setting multiple rte flow RSS rule, +but only the last is valid. This implementation is different from +the mainstream usage of rte flow hash in the community. Please see +the discussion threads [1] and [2]. + +This patch sets RSS hash feature completely based on the request of +the flow rule so that multiple hash rules can take effect at the same +time. Please notice that: +1. For hns3, 'func' has only one hardware. 'key' and 'queue' have only + one entry in hardware. +2. the overlapping part of the old rule will be overridden if the + configuration items of a new rule overlap with those of an old rule. + +The hns3_flow_validate() verifies and parses RSS or Fdir rules from +user, and saves them to a local variable at the same time. The local +variable is directly used to create RSS or Fdir rules. In this way, +we save one parsing and saving process. + +[1] https://lore.kernel.org/all/DM5PR12MB46648085D7CABF1AFF2D75CDD60A9@DM5PR12MB4664.namprd12.prod.outlook.com/ +[2] https://lore.kernel.org/all/f7de4db4-1b88-622f-4e03-acd3eee8a72c@oktetlabs.ru/ + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.h | 9 - + drivers/net/hns3/hns3_flow.c | 966 +++++++++++++++++++++++---------- + drivers/net/hns3/hns3_flow.h | 15 +- + drivers/net/hns3/hns3_rss.c | 144 ++--- + drivers/net/hns3/hns3_rss.h | 117 +++- + 5 files changed, 855 insertions(+), 396 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 2457754b3d..9acc5a3d7e 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -996,15 +996,6 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) + #define hns3_read_dev(a, reg) \ + hns3_read_reg((a)->io_base, (reg)) + +-#define NEXT_ITEM_OF_ACTION(act, actions, index) \ +- do { \ +- (act) = (actions) + (index); \ +- while ((act)->type == RTE_FLOW_ACTION_TYPE_VOID) { \ +- (index)++; \ +- (act) = (actions) + (index); \ +- } \ +- } while (0) +- + static inline uint64_t + hns3_atomic_test_bit(unsigned int nr, volatile uint64_t *addr) + { +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index b1189455ec..c38bd9dd8b 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -10,6 +10,125 @@ + #include "hns3_logs.h" + #include "hns3_flow.h" + ++#define NEXT_ITEM_OF_ACTION(act, actions, index) \ ++ do { \ ++ (act) = (actions) + (index); \ ++ while ((act)->type == RTE_FLOW_ACTION_TYPE_VOID) { \ ++ (index)++; \ ++ (act) = (actions) + (index); \ ++ } \ ++ } while (0) ++ ++#define NEXT_ITEM_OF_PATTERN(item, pattern, index) \ ++ do { \ ++ (item) = (pattern) + (index); \ ++ while ((item)->type == RTE_FLOW_ITEM_TYPE_VOID) { \ ++ (index)++; \ ++ (item) = (pattern) + (index); \ ++ } \ ++ } while (0) ++ ++#define HNS3_HASH_HDR_ETH RTE_BIT64(0) ++#define HNS3_HASH_HDR_IPV4 RTE_BIT64(1) ++#define HNS3_HASH_HDR_IPV6 RTE_BIT64(2) ++#define HNS3_HASH_HDR_TCP RTE_BIT64(3) ++#define HNS3_HASH_HDR_UDP RTE_BIT64(4) ++#define HNS3_HASH_HDR_SCTP RTE_BIT64(5) ++ ++#define HNS3_HASH_VOID_NEXT_ALLOW BIT_ULL(RTE_FLOW_ITEM_TYPE_ETH) ++ ++#define HNS3_HASH_ETH_NEXT_ALLOW (BIT_ULL(RTE_FLOW_ITEM_TYPE_IPV4) | \ ++ BIT_ULL(RTE_FLOW_ITEM_TYPE_IPV6)) ++ ++#define HNS3_HASH_IP_NEXT_ALLOW (BIT_ULL(RTE_FLOW_ITEM_TYPE_TCP) | \ ++ BIT_ULL(RTE_FLOW_ITEM_TYPE_UDP) | \ ++ BIT_ULL(RTE_FLOW_ITEM_TYPE_SCTP)) ++ ++static const uint64_t hash_pattern_next_allow_items[] = { ++ [RTE_FLOW_ITEM_TYPE_VOID] = HNS3_HASH_VOID_NEXT_ALLOW, ++ [RTE_FLOW_ITEM_TYPE_ETH] = HNS3_HASH_ETH_NEXT_ALLOW, ++ [RTE_FLOW_ITEM_TYPE_IPV4] = HNS3_HASH_IP_NEXT_ALLOW, ++ [RTE_FLOW_ITEM_TYPE_IPV6] = HNS3_HASH_IP_NEXT_ALLOW, ++}; ++ ++static const uint64_t hash_pattern_item_header[] = { ++ [RTE_FLOW_ITEM_TYPE_ETH] = HNS3_HASH_HDR_ETH, ++ [RTE_FLOW_ITEM_TYPE_IPV4] = HNS3_HASH_HDR_IPV4, ++ [RTE_FLOW_ITEM_TYPE_IPV6] = HNS3_HASH_HDR_IPV6, ++ [RTE_FLOW_ITEM_TYPE_TCP] = HNS3_HASH_HDR_TCP, ++ [RTE_FLOW_ITEM_TYPE_UDP] = HNS3_HASH_HDR_UDP, ++ [RTE_FLOW_ITEM_TYPE_SCTP] = HNS3_HASH_HDR_SCTP, ++}; ++ ++#define HNS3_HASH_IPV4 (HNS3_HASH_HDR_ETH | HNS3_HASH_HDR_IPV4) ++#define HNS3_HASH_IPV4_TCP (HNS3_HASH_HDR_ETH | \ ++ HNS3_HASH_HDR_IPV4 | \ ++ HNS3_HASH_HDR_TCP) ++#define HNS3_HASH_IPV4_UDP (HNS3_HASH_HDR_ETH | \ ++ HNS3_HASH_HDR_IPV4 | \ ++ HNS3_HASH_HDR_UDP) ++#define HNS3_HASH_IPV4_SCTP (HNS3_HASH_HDR_ETH | \ ++ HNS3_HASH_HDR_IPV4 | \ ++ HNS3_HASH_HDR_SCTP) ++#define HNS3_HASH_IPV6 (HNS3_HASH_HDR_ETH | HNS3_HASH_HDR_IPV6) ++#define HNS3_HASH_IPV6_TCP (HNS3_HASH_HDR_ETH | \ ++ HNS3_HASH_HDR_IPV6 | \ ++ HNS3_HASH_HDR_TCP) ++#define HNS3_HASH_IPV6_UDP (HNS3_HASH_HDR_ETH | \ ++ HNS3_HASH_HDR_IPV6 | \ ++ HNS3_HASH_HDR_UDP) ++#define HNS3_HASH_IPV6_SCTP (HNS3_HASH_HDR_ETH | \ ++ HNS3_HASH_HDR_IPV6 | \ ++ HNS3_HASH_HDR_SCTP) ++ ++static const struct hns3_hash_map_info { ++ /* flow type specified, zero means action works for all flow types. */ ++ uint64_t pattern_type; ++ uint64_t rss_pctype; /* packet type with prefix RTE_ETH_RSS_xxx */ ++ uint64_t l3l4_types; /* Supported L3/L4 RSS types for this packet type */ ++ uint64_t hw_pctype; /* packet type in driver */ ++ uint64_t tuple_mask; /* full tuples of the hw_pctype */ ++} hash_map_table[] = { ++ /* IPV4 */ ++ { HNS3_HASH_IPV4, ++ RTE_ETH_RSS_IPV4, HNS3_RSS_SUPPORT_L3_SRC_DST, ++ HNS3_RSS_PCTYPE_IPV4_NONF, HNS3_RSS_TUPLE_IPV4_NONF_M }, ++ { HNS3_HASH_IPV4, ++ RTE_ETH_RSS_NONFRAG_IPV4_OTHER, HNS3_RSS_SUPPORT_L3_SRC_DST, ++ HNS3_RSS_PCTYPE_IPV4_NONF, HNS3_RSS_TUPLE_IPV4_NONF_M }, ++ { HNS3_HASH_IPV4, ++ RTE_ETH_RSS_FRAG_IPV4, HNS3_RSS_SUPPORT_L3_SRC_DST, ++ HNS3_RSS_PCTYPE_IPV4_FLAG, HNS3_RSS_TUPLE_IPV4_FLAG_M }, ++ { HNS3_HASH_IPV4_TCP, ++ RTE_ETH_RSS_NONFRAG_IPV4_TCP, HNS3_RSS_SUPPORT_L3L4, ++ HNS3_RSS_PCTYPE_IPV4_TCP, HNS3_RSS_TUPLE_IPV4_TCP_M }, ++ { HNS3_HASH_IPV4_UDP, ++ RTE_ETH_RSS_NONFRAG_IPV4_UDP, HNS3_RSS_SUPPORT_L3L4, ++ HNS3_RSS_PCTYPE_IPV4_UDP, HNS3_RSS_TUPLE_IPV4_UDP_M }, ++ { HNS3_HASH_IPV4_SCTP, ++ RTE_ETH_RSS_NONFRAG_IPV4_SCTP, HNS3_RSS_SUPPORT_L3L4, ++ HNS3_RSS_PCTYPE_IPV4_SCTP, HNS3_RSS_TUPLE_IPV4_SCTP_M }, ++ /* IPV6 */ ++ { HNS3_HASH_IPV6, ++ RTE_ETH_RSS_IPV6, HNS3_RSS_SUPPORT_L3_SRC_DST, ++ HNS3_RSS_PCTYPE_IPV6_NONF, HNS3_RSS_TUPLE_IPV6_NONF_M }, ++ { HNS3_HASH_IPV6, ++ RTE_ETH_RSS_NONFRAG_IPV6_OTHER, HNS3_RSS_SUPPORT_L3_SRC_DST, ++ HNS3_RSS_PCTYPE_IPV6_NONF, HNS3_RSS_TUPLE_IPV6_NONF_M }, ++ { HNS3_HASH_IPV6, ++ RTE_ETH_RSS_FRAG_IPV6, HNS3_RSS_SUPPORT_L3_SRC_DST, ++ HNS3_RSS_PCTYPE_IPV6_FLAG, HNS3_RSS_TUPLE_IPV6_FLAG_M }, ++ { HNS3_HASH_IPV6_TCP, ++ RTE_ETH_RSS_NONFRAG_IPV6_TCP, HNS3_RSS_SUPPORT_L3L4, ++ HNS3_RSS_PCTYPE_IPV6_TCP, HNS3_RSS_TUPLE_IPV6_TCP_M }, ++ { HNS3_HASH_IPV6_UDP, ++ RTE_ETH_RSS_NONFRAG_IPV6_UDP, HNS3_RSS_SUPPORT_L3L4, ++ HNS3_RSS_PCTYPE_IPV6_UDP, HNS3_RSS_TUPLE_IPV6_UDP_M }, ++ { HNS3_HASH_IPV6_SCTP, ++ RTE_ETH_RSS_NONFRAG_IPV6_SCTP, HNS3_RSS_SUPPORT_L3L4, ++ HNS3_RSS_PCTYPE_IPV6_SCTP, HNS3_RSS_TUPLE_IPV6_SCTP_M }, ++}; ++ + static const uint8_t full_mask[VNI_OR_TNI_LEN] = { 0xFF, 0xFF, 0xFF }; + static const uint8_t zero_mask[VNI_OR_TNI_LEN] = { 0x00, 0x00, 0x00 }; + +@@ -79,7 +198,7 @@ net_addr_to_host(uint32_t *dst, const rte_be32_t *src, size_t len) + } + + /* +- * This function is used to find rss general action. ++ * This function is used to parse filter type. + * 1. As we know RSS is used to spread packets among several queues, the flow + * API provide the struct rte_flow_action_rss, user could config its field + * sush as: func/level/types/key/queue to control RSS function. +@@ -87,16 +206,18 @@ net_addr_to_host(uint32_t *dst, const rte_be32_t *src, size_t len) + * implemented by FDIR + RSS in hns3 hardware, user can create one FDIR rule + * which action is RSS queues region. + * 3. When action is RSS, we use the following rule to distinguish: +- * Case 1: pattern have ETH and action's queue_num > 0, indicate it is queue +- * region configuration. ++ * Case 1: pattern has ETH and all fields in RSS action except 'queues' are ++ * zero or default, indicate it is queue region configuration. + * Case other: an rss general action. + */ +-static const struct rte_flow_action * +-hns3_find_rss_general_action(const struct rte_flow_item pattern[], +- const struct rte_flow_action actions[]) ++static void ++hns3_parse_filter_type(const struct rte_flow_item pattern[], ++ const struct rte_flow_action actions[], ++ struct hns3_filter_info *filter_info) + { + const struct rte_flow_action_rss *rss_act; + const struct rte_flow_action *act = NULL; ++ bool only_has_queues = false; + bool have_eth = false; + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { +@@ -105,8 +226,10 @@ hns3_find_rss_general_action(const struct rte_flow_item pattern[], + break; + } + } +- if (!act) +- return NULL; ++ if (act == NULL) { ++ filter_info->type = RTE_ETH_FILTER_FDIR; ++ return; ++ } + + for (; pattern->type != RTE_FLOW_ITEM_TYPE_END; pattern++) { + if (pattern->type == RTE_FLOW_ITEM_TYPE_ETH) { +@@ -116,18 +239,20 @@ hns3_find_rss_general_action(const struct rte_flow_item pattern[], + } + + rss_act = act->conf; +- if (have_eth && rss_act->queue_num) { ++ only_has_queues = (rss_act->queue_num > 0) && ++ (rss_act->func == RTE_ETH_HASH_FUNCTION_DEFAULT && ++ rss_act->types == 0 && rss_act->key_len == 0); ++ if (have_eth && only_has_queues) { + /* +- * Pattern have ETH and action's queue_num > 0, indicate this is +- * queue region configuration. +- * Because queue region is implemented by FDIR + RSS in hns3 +- * hardware, it needs to enter FDIR process, so here return NULL +- * to avoid enter RSS process. ++ * Pattern has ETH and all fields in RSS action except 'queues' ++ * are zero or default, which indicates this is queue region ++ * configuration. + */ +- return NULL; ++ filter_info->type = RTE_ETH_FILTER_FDIR; ++ return; + } + +- return act; ++ filter_info->type = RTE_ETH_FILTER_HASH; + } + + static inline struct hns3_flow_counter * +@@ -1246,7 +1371,6 @@ hns3_filterlist_flush(struct rte_eth_dev *dev) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct hns3_fdir_rule_ele *fdir_rule_ptr; +- struct hns3_rss_conf_ele *rss_filter_ptr; + struct hns3_flow_mem *flow_node; + + fdir_rule_ptr = TAILQ_FIRST(&hw->flow_fdir_list); +@@ -1256,13 +1380,6 @@ hns3_filterlist_flush(struct rte_eth_dev *dev) + fdir_rule_ptr = TAILQ_FIRST(&hw->flow_fdir_list); + } + +- rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); +- while (rss_filter_ptr) { +- TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); +- rte_free(rss_filter_ptr); +- rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); +- } +- + flow_node = TAILQ_FIRST(&hw->flow_list); + while (flow_node) { + TAILQ_REMOVE(&hw->flow_list, flow_node, entries); +@@ -1328,196 +1445,422 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + } + + static bool +-hns3_rss_input_tuple_supported(struct hns3_hw *hw, +- const struct rte_flow_action_rss *rss) ++hns3_valid_ipv6_sctp_rss_types(struct hns3_hw *hw, uint64_t types) + { + /* +- * For IP packet, it is not supported to use src/dst port fields to RSS +- * hash for the following packet types. +- * - IPV4 FRAG | IPV4 NONFRAG | IPV6 FRAG | IPV6 NONFRAG +- * Besides, for Kunpeng920, the NIC HW is not supported to use src/dst +- * port fields to RSS hash for IPV6 SCTP packet type. However, the +- * Kunpeng930 and future kunpeng series support to use src/dst port +- * fields to RSS hash for IPv6 SCTP packet type. ++ * Some hardware don't support to use src/dst port fields to hash ++ * for IPV6 SCTP packet type. + */ +- if (rss->types & (RTE_ETH_RSS_L4_DST_ONLY | RTE_ETH_RSS_L4_SRC_ONLY) && +- (rss->types & RTE_ETH_RSS_IP || +- (!hw->rss_info.ipv6_sctp_offload_supported && +- rss->types & RTE_ETH_RSS_NONFRAG_IPV6_SCTP))) ++ if (types & RTE_ETH_RSS_NONFRAG_IPV6_SCTP && ++ types & HNS3_RSS_SUPPORT_L4_SRC_DST && ++ !hw->rss_info.ipv6_sctp_offload_supported) + return false; + + return true; + } + +-/* +- * This function is used to parse rss action validation. +- */ + static int +-hns3_parse_rss_filter(struct rte_eth_dev *dev, +- const struct rte_flow_action *actions, +- struct rte_flow_error *error) ++hns3_flow_parse_hash_func(const struct rte_flow_action_rss *rss_act, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) + { +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; +- const struct rte_flow_action_rss *rss; +- const struct rte_flow_action *act; +- uint32_t act_index = 0; +- uint16_t n; ++ if (rss_act->func >= RTE_ETH_HASH_FUNCTION_MAX) ++ return rte_flow_error_set(error, ENOTSUP, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ NULL, "RSS hash func are not supported"); + +- NEXT_ITEM_OF_ACTION(act, actions, act_index); +- rss = act->conf; ++ rss_conf->conf.func = rss_act->func; ++ return 0; ++} + +- if (rss == NULL) { ++static int ++hns3_flow_parse_hash_key(struct hns3_hw *hw, ++ const struct rte_flow_action_rss *rss_act, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) ++{ ++ if (rss_act->key_len != hw->rss_key_size) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, +- act, "no valid queues"); +- } ++ NULL, "invalid RSS key length"); ++ ++ if (rss_act->key != NULL) ++ memcpy(rss_conf->key, rss_act->key, rss_act->key_len); ++ else ++ memcpy(rss_conf->key, hns3_hash_key, ++ RTE_MIN(sizeof(hns3_hash_key), rss_act->key_len)); ++ /* Need to record if user sets hash key. */ ++ rss_conf->conf.key = rss_act->key; ++ rss_conf->conf.key_len = rss_act->key_len; + +- if (rss->queue_num > HNS3_RSS_QUEUES_BUFFER_NUM) ++ return 0; ++} ++ ++static int ++hns3_flow_parse_queues(struct hns3_hw *hw, ++ const struct rte_flow_action_rss *rss_act, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) ++{ ++ uint16_t i; ++ ++ if (rss_act->queue_num > hw->rss_ind_tbl_size) + return rte_flow_error_set(error, ENOTSUP, +- RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, +- "queue number configured exceeds " +- "queue buffer size driver supported"); ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ NULL, ++ "queue number can not exceed RSS indirection table."); + +- for (n = 0; n < rss->queue_num; n++) { +- if (rss->queue[n] < hw->alloc_rss_size) +- continue; +- return rte_flow_error_set(error, EINVAL, +- RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, +- "queue id must be less than queue number allocated to a TC"); ++ if (rss_act->queue_num > HNS3_RSS_QUEUES_BUFFER_NUM) ++ return rte_flow_error_set(error, ENOTSUP, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ NULL, ++ "queue number configured exceeds queue buffer size driver supported"); ++ ++ for (i = 0; i < rss_act->queue_num; i++) { ++ if (rss_act->queue[i] >= hw->alloc_rss_size) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ NULL, ++ "queue id must be less than queue number allocated to a TC"); + } + +- if (!(rss->types & HNS3_ETH_RSS_SUPPORT) && rss->types) ++ memcpy(rss_conf->queue, rss_act->queue, ++ rss_act->queue_num * sizeof(rss_conf->queue[0])); ++ rss_conf->conf.queue = rss_conf->queue; ++ rss_conf->conf.queue_num = rss_act->queue_num; ++ ++ return 0; ++} ++ ++static int ++hns3_flow_get_hw_pctype(struct hns3_hw *hw, ++ const struct rte_flow_action_rss *rss_act, ++ const struct hns3_hash_map_info *map, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) ++{ ++ uint64_t l3l4_src_dst, l3l4_refine, left_types; ++ ++ if (rss_act->types == 0) { ++ /* Disable RSS hash of this packet type if types is zero. */ ++ rss_conf->hw_pctypes |= map->hw_pctype; ++ return 0; ++ } ++ ++ /* ++ * Can not have extra types except rss_pctype and l3l4_type in this map. ++ */ ++ left_types = ~map->rss_pctype & rss_act->types; ++ if (left_types & ~map->l3l4_types) + return rte_flow_error_set(error, EINVAL, +- RTE_FLOW_ERROR_TYPE_ACTION_CONF, +- act, +- "Flow types is unsupported by " +- "hns3's RSS"); +- if (rss->func >= RTE_ETH_HASH_FUNCTION_MAX) +- return rte_flow_error_set(error, ENOTSUP, +- RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, +- "RSS hash func are not supported"); +- if (rss->level) ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, ++ "cannot set extra types."); ++ ++ l3l4_src_dst = left_types; ++ /* L3/L4 SRC and DST shouldn't be specified at the same time. */ ++ l3l4_refine = rte_eth_rss_hf_refine(l3l4_src_dst); ++ if (l3l4_refine != l3l4_src_dst) + return rte_flow_error_set(error, ENOTSUP, +- RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, +- "a nonzero RSS encapsulation level is not supported"); +- if (rss->key_len && rss->key_len != hw->rss_key_size) ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, ++ "cannot specify L3_SRC/DST_ONLY or L4_SRC/DST_ONLY at the same."); ++ ++ if (!hns3_valid_ipv6_sctp_rss_types(hw, rss_act->types)) + return rte_flow_error_set(error, ENOTSUP, +- RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, +- "invalid RSS key length"); ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, ++ "hardware doesn't support to use L4 src/dst to hash for IPV6-SCTP."); + +- if (!hns3_rss_input_tuple_supported(hw, rss)) +- return rte_flow_error_set(error, EINVAL, ++ rss_conf->hw_pctypes |= map->hw_pctype; ++ ++ return 0; ++} ++ ++static int ++hns3_flow_parse_rss_types_by_ptype(struct hns3_hw *hw, ++ const struct rte_flow_action_rss *rss_act, ++ uint64_t pattern_type, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) ++{ ++ const struct hns3_hash_map_info *map; ++ bool matched = false; ++ uint16_t i; ++ int ret; ++ ++ for (i = 0; i < RTE_DIM(hash_map_table); i++) { ++ map = &hash_map_table[i]; ++ if (map->pattern_type != pattern_type) { ++ /* ++ * If the target pattern type is already matched with ++ * the one before this pattern in the hash map table, ++ * no need to continue walk. ++ */ ++ if (matched) ++ break; ++ continue; ++ } ++ matched = true; ++ ++ /* ++ * If pattern type is matched and the 'types' is zero, all packet flow ++ * types related to this pattern type disable RSS hash. ++ * Otherwise, RSS types must match the pattern type and cannot have no ++ * extra or unsupported types. ++ */ ++ if (rss_act->types != 0 && !(map->rss_pctype & rss_act->types)) ++ continue; ++ ++ ret = hns3_flow_get_hw_pctype(hw, rss_act, map, rss_conf, error); ++ if (ret != 0) ++ return ret; ++ } ++ ++ if (rss_conf->hw_pctypes != 0) ++ return 0; ++ ++ if (matched) ++ return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, +- &rss->types, +- "input RSS types are not supported"); ++ NULL, "RSS types are unsupported"); + +- act_index++; ++ return rte_flow_error_set(error, ENOTSUP, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ NULL, "Pattern specified is unsupported"); ++} + +- /* Check if the next not void action is END */ +- NEXT_ITEM_OF_ACTION(act, actions, act_index); +- if (act->type != RTE_FLOW_ACTION_TYPE_END) +- return rte_flow_error_set(error, EINVAL, +- RTE_FLOW_ERROR_TYPE_ACTION, +- act, "Not supported action."); ++static uint64_t ++hns3_flow_get_all_hw_pctypes(uint64_t types) ++{ ++ uint64_t hw_pctypes = 0; ++ uint16_t i; + +- return 0; ++ for (i = 0; i < RTE_DIM(hash_map_table); i++) { ++ if (types & hash_map_table[i].rss_pctype) ++ hw_pctypes |= hash_map_table[i].hw_pctype; ++ } ++ ++ return hw_pctypes; + } + + static int +-hns3_disable_rss(struct hns3_hw *hw) ++hns3_flow_parse_rss_types(struct hns3_hw *hw, ++ const struct rte_flow_action_rss *rss_act, ++ uint64_t pattern_type, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) ++{ ++ rss_conf->conf.types = rss_act->types; ++ ++ /* no pattern specified to set global RSS types. */ ++ if (pattern_type == 0) { ++ if (rss_act->types & ~HNS3_ETH_RSS_SUPPORT) ++ hns3_warn(hw, "some types in the requested RSS types (0x%" PRIx64 ") aren't supported, they are ignored.", ++ rss_act->types); ++ rss_conf->hw_pctypes = ++ hns3_flow_get_all_hw_pctypes(rss_act->types); ++ return 0; ++ } ++ ++ return hns3_flow_parse_rss_types_by_ptype(hw, rss_act, pattern_type, ++ rss_conf, error); ++} ++ ++static int ++hns3_flow_parse_hash_global_conf(struct rte_eth_dev *dev, ++ const struct rte_flow_action_rss *rss_act, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) + { ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int ret; + +- ret = hns3_set_rss_tuple_by_rss_hf(hw, 0); +- if (ret) ++ ret = hns3_flow_parse_hash_func(rss_act, rss_conf, error); ++ if (ret != 0) + return ret; +- hw->rss_info.rss_hf = 0; + +- return 0; ++ if (rss_act->queue_num > 0) { ++ ret = hns3_flow_parse_queues(hw, rss_act, rss_conf, error); ++ if (ret != 0) ++ return ret; ++ } ++ ++ if (rss_act->key_len > 0) { ++ ret = hns3_flow_parse_hash_key(hw, rss_act, rss_conf, error); ++ if (ret != 0) ++ return ret; ++ } ++ ++ return hns3_flow_parse_rss_types(hw, rss_act, rss_conf->pattern_type, ++ rss_conf, error); + } + + static int +-hns3_parse_rss_algorithm(struct hns3_hw *hw, struct hns3_flow_rss_conf *rss_conf, +- uint8_t *hash_algo) +-{ +- const uint8_t hash_func_map[] = { +- [RTE_ETH_HASH_FUNCTION_DEFAULT] = HNS3_RSS_HASH_ALGO_TOEPLITZ, +- [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = HNS3_RSS_HASH_ALGO_TOEPLITZ, +- [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = HNS3_RSS_HASH_ALGO_SIMPLE, +- [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP, +- }; +- uint8_t key[HNS3_RSS_KEY_SIZE_MAX] = {0}; +- int ret; ++hns3_flow_parse_pattern_type(const struct rte_flow_item pattern[], ++ uint64_t *ptype, struct rte_flow_error *error) ++{ ++ enum rte_flow_item_type pre_type = RTE_FLOW_ITEM_TYPE_VOID; ++ const char *message = "Pattern specified isn't supported"; ++ uint64_t item_hdr, pattern_hdrs = 0; ++ enum rte_flow_item_type cur_type; + +- if (rss_conf->conf.func == RTE_ETH_HASH_FUNCTION_DEFAULT) { +- ret = hns3_rss_get_algo_key(hw, hash_algo, key, +- hw->rss_key_size); +- if (ret != 0) { +- hns3_err(hw, "fail to get current RSS hash algorithm, ret = %d", +- ret); +- return ret; ++ for (; pattern->type != RTE_FLOW_ITEM_TYPE_END; pattern++) { ++ if (pattern->type == RTE_FLOW_ITEM_TYPE_VOID) ++ continue; ++ if (pattern->mask || pattern->spec || pattern->last) { ++ message = "Header info shouldn't be specified"; ++ goto unsup; + } + +- /* +- * During the phase of reset recovery, the hash algorithm +- * obtained from hardware may not be the one used(saved in +- * rte_flow_hash_algo) when this rule is delivered. +- */ +- if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) && +- *hash_algo != rss_conf->hash_algo) +- *hash_algo = rss_conf->hash_algo; ++ /* Check the sub-item allowed by the previous item . */ ++ if (pre_type >= RTE_DIM(hash_pattern_next_allow_items) || ++ !(hash_pattern_next_allow_items[pre_type] & ++ BIT_ULL(pattern->type))) ++ goto unsup; ++ ++ cur_type = pattern->type; ++ /* Unsupported for current type being greater than array size. */ ++ if (cur_type >= RTE_DIM(hash_pattern_item_header)) ++ goto unsup; ++ ++ /* The value is zero, which means unsupported current header. */ ++ item_hdr = hash_pattern_item_header[cur_type]; ++ if (item_hdr == 0) ++ goto unsup; ++ ++ /* Have duplicate pattern header. */ ++ if (item_hdr & pattern_hdrs) ++ goto unsup; ++ pre_type = cur_type; ++ pattern_hdrs |= item_hdr; ++ } + ++ if (pattern_hdrs != 0) { ++ *ptype = pattern_hdrs; + return 0; + } + +- *hash_algo = hash_func_map[rss_conf->conf.func]; ++unsup: ++ return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, ++ pattern, message); ++} ++ ++static int ++hns3_flow_parse_pattern_act(struct rte_eth_dev *dev, ++ const struct rte_flow_item pattern[], ++ const struct rte_flow_action_rss *rss_act, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) ++{ ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ int ret; ++ ++ ret = hns3_flow_parse_hash_func(rss_act, rss_conf, error); ++ if (ret != 0) ++ return ret; ++ ++ if (rss_act->key_len > 0) { ++ ret = hns3_flow_parse_hash_key(hw, rss_act, rss_conf, error); ++ if (ret != 0) ++ return ret; ++ } ++ ++ if (rss_act->queue_num > 0) { ++ ret = hns3_flow_parse_queues(hw, rss_act, rss_conf, error); ++ if (ret != 0) ++ return ret; ++ } ++ ++ ret = hns3_flow_parse_pattern_type(pattern, &rss_conf->pattern_type, ++ error); ++ if (ret != 0) ++ return ret; ++ ++ ret = hns3_flow_parse_rss_types(hw, rss_act, rss_conf->pattern_type, ++ rss_conf, error); ++ if (ret != 0) ++ return ret; ++ ++ if (rss_act->func != RTE_ETH_HASH_FUNCTION_DEFAULT || ++ rss_act->key_len > 0 || rss_act->queue_num > 0) ++ hns3_warn(hw, "hash func, key and queues are global config, which work for all flow types. " ++ "Recommend: don't set them together with pattern."); + + return 0; + } + ++static bool ++hns3_rss_action_is_dup(struct hns3_hw *hw, ++ const struct hns3_flow_rss_conf *conf) ++{ ++ struct hns3_rss_conf_ele *filter; ++ ++ TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) { ++ if (conf->pattern_type != filter->filter_info.pattern_type) ++ continue; ++ ++ if (hns3_action_rss_same(&filter->filter_info.conf, &conf->conf)) ++ return true; ++ } ++ ++ return false; ++} ++ ++/* ++ * This function is used to parse rss action validation. ++ */ + static int +-hns3_hw_rss_hash_set(struct hns3_hw *hw, struct hns3_flow_rss_conf *conf) ++hns3_parse_rss_filter(struct rte_eth_dev *dev, ++ const struct rte_flow_item pattern[], ++ const struct rte_flow_action *actions, ++ struct hns3_flow_rss_conf *rss_conf, ++ struct rte_flow_error *error) + { +- struct rte_flow_action_rss *rss_config = &conf->conf; +- uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; +- bool use_default_key = false; +- uint64_t flow_types; +- uint8_t hash_algo; ++ struct hns3_adapter *hns = dev->data->dev_private; ++ const struct rte_flow_action_rss *rss_act; ++ const struct rte_flow_action *act; ++ const struct rte_flow_item *pat; ++ struct hns3_hw *hw = &hns->hw; ++ uint32_t index = 0; + int ret; + +- if (rss_config->key == NULL || rss_config->key_len != hw->rss_key_size) { +- hns3_warn(hw, "Default RSS hash key to be set"); +- memcpy(rss_key, hns3_hash_key, +- RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); +- use_default_key = true; ++ NEXT_ITEM_OF_ACTION(act, actions, index); ++ if (actions[1].type != RTE_FLOW_ACTION_TYPE_END) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION, ++ &actions[1], ++ "Only support one action for RSS."); ++ ++ rss_act = (const struct rte_flow_action_rss *)act->conf; ++ if (rss_act == NULL) { ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ act, "lost RSS action configuration"); + } + +- ret = hns3_parse_rss_algorithm(hw, conf, &hash_algo); +- if (ret) ++ if (rss_act->level != 0) ++ return rte_flow_error_set(error, ENOTSUP, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ act, ++ "RSS level is not supported"); ++ ++ index = 0; ++ NEXT_ITEM_OF_PATTERN(pat, pattern, index); ++ if (pat[0].type == RTE_FLOW_ITEM_TYPE_END) { ++ rss_conf->pattern_type = 0; ++ ret = hns3_flow_parse_hash_global_conf(dev, rss_act, ++ rss_conf, error); ++ } else { ++ ret = hns3_flow_parse_pattern_act(dev, pat, rss_act, ++ rss_conf, error); ++ } ++ if (ret != 0) + return ret; + +- ret = hns3_rss_set_algo_key(hw, hash_algo, +- use_default_key ? rss_key : rss_config->key, +- hw->rss_key_size); +- if (ret) +- return ret; +- conf->hash_algo = hash_algo; +- +- /* Filter the unsupported flow types */ +- flow_types = rss_config->types ? +- rss_config->types & HNS3_ETH_RSS_SUPPORT : +- hw->rss_info.rss_hf; +- if (flow_types != rss_config->types) +- hns3_warn(hw, "modified RSS types based on hardware support," +- " requested:0x%" PRIx64 " configured:0x%" PRIx64, +- rss_config->types, flow_types); +- +- ret = hns3_set_rss_tuple_by_rss_hf(hw, flow_types); +- if (ret) +- hns3_err(hw, "Update RSS tuples by rss hf failed %d", ret); ++ if (hns3_rss_action_is_dup(hw, rss_conf)) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ act, "duplicate RSS rule"); + +- return ret; ++ return 0; + } + + static int +@@ -1543,44 +1886,106 @@ hns3_update_indir_table(struct hns3_hw *hw, + return hns3_set_rss_indir_table(hw, indir_tbl, hw->rss_ind_tbl_size); + } + ++static uint64_t ++hns3_flow_get_pctype_tuple_mask(uint64_t hw_pctype) ++{ ++ uint64_t tuple_mask = 0; ++ uint16_t i; ++ ++ for (i = 0; i < RTE_DIM(hash_map_table); i++) { ++ if (hw_pctype == hash_map_table[i].hw_pctype) { ++ tuple_mask = hash_map_table[i].tuple_mask; ++ break; ++ } ++ } ++ ++ return tuple_mask; ++} ++ + static int +-hns3_reset_rss_filter(struct hns3_hw *hw, +- const struct hns3_flow_rss_conf *conf) ++hns3_flow_set_rss_ptype_tuple(struct hns3_hw *hw, ++ struct hns3_flow_rss_conf *rss_conf) + { ++ uint64_t old_tuple_fields, new_tuple_fields; ++ uint64_t hw_pctypes, tuples, tuple_mask = 0; ++ bool cfg_global_tuple; + int ret; + +- if (!conf->valid) +- return 0; ++ cfg_global_tuple = (rss_conf->pattern_type == 0); ++ if (!cfg_global_tuple) { ++ /* ++ * To ensure that different packets do not affect each other, ++ * we have to first read all tuple fields, and then only modify ++ * the tuples for the specified packet type. ++ */ ++ ret = hns3_get_rss_tuple_field(hw, &old_tuple_fields); ++ if (ret != 0) ++ return ret; + +- ret = hns3_disable_rss(hw); +- if (ret) +- hns3_err(hw, "RSS disable failed(%d)", ret); ++ new_tuple_fields = old_tuple_fields; ++ hw_pctypes = rss_conf->hw_pctypes; ++ while (hw_pctypes > 0) { ++ uint32_t idx = rte_bsf64(hw_pctypes); ++ uint64_t pctype = BIT_ULL(idx); ++ ++ tuple_mask = hns3_flow_get_pctype_tuple_mask(pctype); ++ tuples = hns3_rss_calc_tuple_filed(hw, ++ rss_conf->conf.types); ++ new_tuple_fields &= ~tuple_mask; ++ new_tuple_fields |= tuples; ++ hw_pctypes &= ~pctype; ++ } ++ } else { ++ new_tuple_fields = ++ hns3_rss_calc_tuple_filed(hw, rss_conf->conf.types); ++ } + +- return ret; ++ ret = hns3_set_rss_tuple_field(hw, new_tuple_fields); ++ if (ret != 0) ++ return ret; ++ ++ hns3_info(hw, "RSS tuple fields changed from 0x%" PRIx64 " to 0x%" PRIx64, ++ old_tuple_fields, new_tuple_fields); ++ ++ return 0; + } + + static int +-hns3_config_rss_filter(struct hns3_hw *hw, struct hns3_flow_rss_conf *conf) ++hns3_config_rss_filter(struct hns3_hw *hw, ++ struct hns3_flow_rss_conf *rss_conf) + { + struct rte_flow_action_rss *rss_act; +- uint16_t num; + int ret; + +- rss_act = &conf->conf; +- /* Set rx queues to use */ +- num = RTE_MIN(hw->data->nb_rx_queues, rss_act->queue_num); +- if (rss_act->queue_num > num) +- hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated", +- rss_act->queue_num); +- hns3_info(hw, "Max of contiguous %u PF queues are configured", num); +- if (num) { +- ret = hns3_update_indir_table(hw, rss_act, num); +- if (ret) ++ rss_act = &rss_conf->conf; ++ if (rss_act->queue_num > 0) { ++ ret = hns3_update_indir_table(hw, rss_act, rss_act->queue_num); ++ if (ret) { ++ hns3_err(hw, "set queues action failed, ret = %d", ret); ++ return ret; ++ } ++ } ++ ++ if (rss_act->key_len > 0 || ++ rss_act->func != RTE_ETH_HASH_FUNCTION_DEFAULT) { ++ ret = hns3_update_rss_algo_key(hw, rss_act->func, rss_conf->key, ++ rss_act->key_len); ++ if (ret != 0) { ++ hns3_err(hw, "set func or hash key action failed, ret = %d", ++ ret); + return ret; ++ } ++ } ++ ++ if (rss_conf->hw_pctypes > 0) { ++ ret = hns3_flow_set_rss_ptype_tuple(hw, rss_conf); ++ if (ret != 0) { ++ hns3_err(hw, "set types action failed, ret = %d", ret); ++ return ret; ++ } + } + +- /* Set hash algorithm and flow types by the user's config */ +- return hns3_hw_rss_hash_set(hw, conf); ++ return 0; + } + + static int +@@ -1589,50 +1994,44 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_rss_conf_ele *rss_filter_ptr; + struct hns3_hw *hw = &hns->hw; +- int rss_rule_succ_cnt = 0; /* count for success of clearing RSS rules */ +- int rss_rule_fail_cnt = 0; /* count for failure of clearing RSS rules */ +- int ret = 0; + + rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); + while (rss_filter_ptr) { + TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); +- ret = hns3_reset_rss_filter(hw, &rss_filter_ptr->filter_info); +- if (ret) +- rss_rule_fail_cnt++; +- else +- rss_rule_succ_cnt++; + rte_free(rss_filter_ptr); + rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); + } + +- if (rss_rule_fail_cnt) { +- hns3_err(hw, "fail to delete all RSS filters, success num = %d fail num = %d", +- rss_rule_succ_cnt, rss_rule_fail_cnt); +- ret = -EIO; +- } +- +- return ret; ++ return hns3_config_rss(hns); + } + + static int +-hns3_restore_rss_filter(struct hns3_hw *hw) ++hns3_reconfig_all_rss_filter(struct hns3_hw *hw) + { + struct hns3_rss_conf_ele *filter; +- int ret = 0; ++ uint32_t rule_no = 0; ++ int ret; + +- pthread_mutex_lock(&hw->flows_lock); + TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) { +- if (!filter->filter_info.valid) +- continue; +- + ret = hns3_config_rss_filter(hw, &filter->filter_info); + if (ret != 0) { +- hns3_err(hw, "restore RSS filter failed, ret=%d", ret); +- goto out; ++ hns3_err(hw, "config %uth RSS filter failed, ret = %d", ++ rule_no, ret); ++ return ret; + } ++ rule_no++; + } + +-out: ++ return 0; ++} ++ ++static int ++hns3_restore_rss_filter(struct hns3_hw *hw) ++{ ++ int ret; ++ ++ pthread_mutex_lock(&hw->flows_lock); ++ ret = hns3_reconfig_all_rss_filter(hw); + pthread_mutex_unlock(&hw->flows_lock); + + return ret; +@@ -1651,38 +2050,6 @@ hns3_restore_filter(struct hns3_adapter *hns) + return hns3_restore_rss_filter(hw); + } + +-static bool +-hns3_rss_action_is_dup(struct hns3_hw *hw, +- const struct rte_flow_action_rss *act) +-{ +- struct hns3_rss_conf_ele *filter; +- +- TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) { +- if (!filter->filter_info.valid) +- continue; +- +- if (hns3_action_rss_same(&filter->filter_info.conf, act)) +- return true; +- } +- +- return false; +-} +- +-static int +-hns3_flow_parse_rss(struct rte_eth_dev *dev, +- struct hns3_flow_rss_conf *conf) +-{ +- struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; +- +- if (hns3_rss_action_is_dup(hw, &conf->conf)) { +- hns3_err(hw, "duplicate RSS configuration"); +- return -EINVAL; +- } +- +- return hns3_config_rss_filter(hw, conf); +-} +- + static int + hns3_flow_args_check(const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], +@@ -1716,32 +2083,55 @@ static int + hns3_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], +- struct rte_flow_error *error) ++ struct rte_flow_error *error, ++ struct hns3_filter_info *filter_info) + { +- struct hns3_fdir_rule fdir_rule; ++ union hns3_filter_conf *conf; + int ret; + + ret = hns3_flow_args_check(attr, pattern, actions, error); + if (ret) + return ret; + +- if (hns3_find_rss_general_action(pattern, actions)) +- return hns3_parse_rss_filter(dev, actions, error); ++ hns3_parse_filter_type(pattern, actions, filter_info); ++ conf = &filter_info->conf; ++ if (filter_info->type == RTE_ETH_FILTER_HASH) ++ return hns3_parse_rss_filter(dev, pattern, actions, ++ &conf->rss_conf, error); + +- memset(&fdir_rule, 0, sizeof(struct hns3_fdir_rule)); +- return hns3_parse_fdir_filter(dev, pattern, actions, &fdir_rule, error); ++ return hns3_parse_fdir_filter(dev, pattern, actions, ++ &conf->fdir_conf, error); ++} ++ ++static int ++hns3_flow_rebuild_all_rss_filter(struct hns3_adapter *hns) ++{ ++ struct hns3_hw *hw = &hns->hw; ++ int ret; ++ ++ ret = hns3_config_rss(hns); ++ if (ret != 0) { ++ hns3_err(hw, "restore original RSS configuration failed, ret = %d.", ++ ret); ++ return ret; ++ } ++ ret = hns3_reconfig_all_rss_filter(hw); ++ if (ret != 0) ++ hns3_err(hw, "rebuild all RSS filter failed, ret = %d.", ret); ++ ++ return ret; + } + + static int + hns3_flow_create_rss_rule(struct rte_eth_dev *dev, +- const struct rte_flow_action *act, ++ struct hns3_flow_rss_conf *rss_conf, + struct rte_flow *flow) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- const struct rte_flow_action_rss *rss_act; ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + struct hns3_rss_conf_ele *rss_filter_ptr; + struct hns3_flow_rss_conf *new_conf; +- struct hns3_rss_conf_ele *filter_ptr; ++ struct rte_flow_action_rss *rss_act; + int ret; + + rss_filter_ptr = rte_zmalloc("hns3 rss filter", +@@ -1751,35 +2141,28 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + return -ENOMEM; + } + +- rss_act = (const struct rte_flow_action_rss *)act->conf; + new_conf = &rss_filter_ptr->filter_info; +- memcpy(&new_conf->conf, rss_act, sizeof(*rss_act)); +- if (rss_act->queue_num > 0) { +- memcpy(new_conf->queue, rss_act->queue, +- rss_act->queue_num * sizeof(new_conf->queue[0])); ++ memcpy(new_conf, rss_conf, sizeof(*new_conf)); ++ rss_act = &new_conf->conf; ++ if (rss_act->queue_num > 0) + new_conf->conf.queue = new_conf->queue; +- } +- if (rss_act->key_len > 0) { +- if (rss_act->key != NULL) { +- memcpy(new_conf->key, rss_act->key, +- rss_act->key_len * sizeof(new_conf->key[0])); +- new_conf->conf.key = new_conf->key; +- } +- } ++ /* ++ * There are two ways to deliver hash key action: ++ * 1> 'key_len' is greater than zero and 'key' isn't NULL. ++ * 2> 'key_len' is greater than zero, but 'key' is NULL. ++ * For case 2, we need to keep 'key' of the new_conf is NULL so as to ++ * inherit the configuration from user in case of failing to verify ++ * duplicate rule later. ++ */ ++ if (rss_act->key_len > 0 && rss_act->key != NULL) ++ new_conf->conf.key = new_conf->key; + +- ret = hns3_flow_parse_rss(dev, new_conf); ++ ret = hns3_config_rss_filter(hw, new_conf); + if (ret != 0) { + rte_free(rss_filter_ptr); ++ (void)hns3_flow_rebuild_all_rss_filter(hns); + return ret; + } +- rss_filter_ptr->filter_info.valid = true; +- +- /* +- * When create a new RSS rule, the old rule will be overlaid and set +- * invalid. +- */ +- TAILQ_FOREACH(filter_ptr, &hw->flow_rss_list, entries) +- filter_ptr->filter_info.valid = false; + + TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries); + flow->rule = rss_filter_ptr; +@@ -1790,31 +2173,24 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + + static int + hns3_flow_create_fdir_rule(struct rte_eth_dev *dev, +- const struct rte_flow_item pattern[], +- const struct rte_flow_action actions[], ++ struct hns3_fdir_rule *fdir_rule, + struct rte_flow_error *error, + struct rte_flow *flow) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + struct hns3_fdir_rule_ele *fdir_rule_ptr; +- struct hns3_fdir_rule fdir_rule; + bool indir; + int ret; + +- memset(&fdir_rule, 0, sizeof(struct hns3_fdir_rule)); +- ret = hns3_parse_fdir_filter(dev, pattern, actions, &fdir_rule, error); +- if (ret != 0) +- return ret; +- +- indir = !!(fdir_rule.flags & HNS3_RULE_FLAG_COUNTER_INDIR); +- if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) { +- ret = hns3_counter_new(dev, indir, fdir_rule.act_cnt.id, ++ indir = !!(fdir_rule->flags & HNS3_RULE_FLAG_COUNTER_INDIR); ++ if (fdir_rule->flags & HNS3_RULE_FLAG_COUNTER) { ++ ret = hns3_counter_new(dev, indir, fdir_rule->act_cnt.id, + error); + if (ret != 0) + return ret; + +- flow->counter_id = fdir_rule.act_cnt.id; ++ flow->counter_id = fdir_rule->act_cnt.id; + } + + fdir_rule_ptr = rte_zmalloc("hns3 fdir rule", +@@ -1830,11 +2206,11 @@ hns3_flow_create_fdir_rule(struct rte_eth_dev *dev, + * rules to the hardware to simplify the rollback of rules in the + * hardware. + */ +- ret = hns3_fdir_filter_program(hns, &fdir_rule, false); ++ ret = hns3_fdir_filter_program(hns, fdir_rule, false); + if (ret != 0) + goto err_fdir_filter; + +- memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule, ++ memcpy(&fdir_rule_ptr->fdir_conf, fdir_rule, + sizeof(struct hns3_fdir_rule)); + TAILQ_INSERT_TAIL(&hw->flow_fdir_list, fdir_rule_ptr, entries); + flow->rule = fdir_rule_ptr; +@@ -1845,8 +2221,8 @@ hns3_flow_create_fdir_rule(struct rte_eth_dev *dev, + err_fdir_filter: + rte_free(fdir_rule_ptr); + err_malloc: +- if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) +- hns3_counter_release(dev, fdir_rule.act_cnt.id); ++ if (fdir_rule->flags & HNS3_RULE_FLAG_COUNTER) ++ hns3_counter_release(dev, fdir_rule->act_cnt.id); + + return ret; + } +@@ -1864,13 +2240,15 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, + struct rte_flow_error *error) + { + struct hns3_adapter *hns = dev->data->dev_private; +- struct hns3_hw *hw = &hns->hw; ++ struct hns3_filter_info filter_info = {0}; + struct hns3_flow_mem *flow_node; +- const struct rte_flow_action *act; ++ struct hns3_hw *hw = &hns->hw; ++ union hns3_filter_conf *conf; + struct rte_flow *flow; + int ret; + +- ret = hns3_flow_validate(dev, attr, pattern, actions, error); ++ ret = hns3_flow_validate(dev, attr, pattern, actions, error, ++ &filter_info); + if (ret) + return NULL; + +@@ -1890,13 +2268,12 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, + } + + flow_node->flow = flow; ++ conf = &filter_info.conf; + TAILQ_INSERT_TAIL(&hw->flow_list, flow_node, entries); +- +- act = hns3_find_rss_general_action(pattern, actions); +- if (act) +- ret = hns3_flow_create_rss_rule(dev, act, flow); ++ if (filter_info.type == RTE_ETH_FILTER_HASH) ++ ret = hns3_flow_create_rss_rule(dev, &conf->rss_conf, flow); + else +- ret = hns3_flow_create_fdir_rule(dev, pattern, actions, ++ ret = hns3_flow_create_fdir_rule(dev, &conf->fdir_conf, + error, flow); + if (ret == 0) + return flow; +@@ -1950,15 +2327,10 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, + break; + case RTE_ETH_FILTER_HASH: + rss_filter_ptr = (struct hns3_rss_conf_ele *)flow->rule; +- ret = hns3_reset_rss_filter(hw, &rss_filter_ptr->filter_info); +- if (ret) +- return rte_flow_error_set(error, EIO, +- RTE_FLOW_ERROR_TYPE_HANDLE, +- flow, +- "Destroy RSS fail.Try again"); + TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); + rte_free(rss_filter_ptr); + rss_filter_ptr = NULL; ++ (void)hns3_flow_rebuild_all_rss_filter(hns); + break; + default: + return rte_flow_error_set(error, EINVAL, +@@ -2064,10 +2436,12 @@ hns3_flow_validate_wrap(struct rte_eth_dev *dev, + struct rte_flow_error *error) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct hns3_filter_info filter_info = {0}; + int ret; + + pthread_mutex_lock(&hw->flows_lock); +- ret = hns3_flow_validate(dev, attr, pattern, actions, error); ++ ret = hns3_flow_validate(dev, attr, pattern, actions, error, ++ &filter_info); + pthread_mutex_unlock(&hw->flows_lock); + + return ret; +diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h +index 90126f2b6e..1b49673f11 100644 +--- a/drivers/net/hns3/hns3_flow.h ++++ b/drivers/net/hns3/hns3_flow.h +@@ -9,6 +9,7 @@ + #include + + #include "hns3_rss.h" ++#include "hns3_fdir.h" + + struct hns3_flow_counter { + LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */ +@@ -26,10 +27,10 @@ struct rte_flow { + + struct hns3_flow_rss_conf { + struct rte_flow_action_rss conf; +- uint8_t hash_algo; + uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ + uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ +- bool valid; /* check if RSS rule is valid */ ++ uint64_t pattern_type; ++ uint64_t hw_pctypes; /* packet types in driver */ + }; + + /* rss filter list structure */ +@@ -53,6 +54,16 @@ struct rte_flow_action_handle { + uint32_t counter_id; + }; + ++union hns3_filter_conf { ++ struct hns3_fdir_rule fdir_conf; ++ struct hns3_flow_rss_conf rss_conf; ++}; ++ ++struct hns3_filter_info { ++ enum rte_filter_type type; ++ union hns3_filter_conf conf; ++}; ++ + TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); + TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index f51d70a8e5..dfa2901ae3 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -18,69 +18,13 @@ const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE] = { + 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA + }; + +-enum hns3_tuple_field { +- /* IPV4_TCP ENABLE FIELD */ +- HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D = 0, +- HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S, +- HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D, +- HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S, +- +- /* IPV4_UDP ENABLE FIELD */ +- HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D = 8, +- HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S, +- HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D, +- HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S, +- +- /* IPV4_SCTP ENABLE FIELD */ +- HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D = 16, +- HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S, +- HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D, +- HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S, +- HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER, +- +- /* IPV4 ENABLE FIELD */ +- HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D = 24, +- HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S, +- HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D, +- HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S, +- +- /* IPV6_TCP ENABLE FIELD */ +- HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D = 32, +- HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S, +- HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D, +- HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S, +- +- /* IPV6_UDP ENABLE FIELD */ +- HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D = 40, +- HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S, +- HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D, +- HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S, +- +- /* IPV6_SCTP ENABLE FIELD */ +- HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D = 48, +- HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S, +- HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D, +- HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S, +- HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER, +- +- /* IPV6 ENABLE FIELD */ +- HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D = 56, +- HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S, +- HNS3_RSS_FIELD_IPV6_FRAG_IP_D, +- HNS3_RSS_FIELD_IPV6_FRAG_IP_S ++const uint8_t hns3_hash_func_map[] = { ++ [RTE_ETH_HASH_FUNCTION_DEFAULT] = HNS3_RSS_HASH_ALGO_TOEPLITZ, ++ [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = HNS3_RSS_HASH_ALGO_TOEPLITZ, ++ [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = HNS3_RSS_HASH_ALGO_SIMPLE, ++ [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP, + }; + +-#define HNS3_RSS_TUPLE_IPV4_TCP_M GENMASK(3, 0) +-#define HNS3_RSS_TUPLE_IPV4_UDP_M GENMASK(11, 8) +-#define HNS3_RSS_TUPLE_IPV4_SCTP_M GENMASK(20, 16) +-#define HNS3_RSS_TUPLE_IPV4_NONF_M GENMASK(25, 24) +-#define HNS3_RSS_TUPLE_IPV4_FLAG_M GENMASK(27, 26) +-#define HNS3_RSS_TUPLE_IPV6_TCP_M GENMASK(35, 32) +-#define HNS3_RSS_TUPLE_IPV6_UDP_M GENMASK(43, 40) +-#define HNS3_RSS_TUPLE_IPV6_SCTP_M GENMASK(52, 48) +-#define HNS3_RSS_TUPLE_IPV6_NONF_M GENMASK(57, 56) +-#define HNS3_RSS_TUPLE_IPV6_FLAG_M GENMASK(59, 58) +- + enum hns3_rss_tuple_type { + HNS3_RSS_IP_TUPLE, + HNS3_RSS_IP_L4_TUPLE, +@@ -574,7 +518,7 @@ hns3_rss_check_l3l4_types(struct hns3_hw *hw, uint64_t rss_hf) + hns3_warn(hw, "packet type isn't specified, L4_SRC/DST_ONLY is ignored."); + } + +-static uint64_t ++uint64_t + hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf) + { + uint64_t l3_only_mask = RTE_ETH_RSS_L3_SRC_ONLY | +@@ -610,25 +554,35 @@ hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf) + } + + int +-hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf) ++hns3_set_rss_tuple_field(struct hns3_hw *hw, uint64_t tuple_fields) + { + struct hns3_rss_input_tuple_cmd *req; + struct hns3_cmd_desc desc; +- uint64_t tuple_field; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false); + req = (struct hns3_rss_input_tuple_cmd *)desc.data; +- +- tuple_field = hns3_rss_calc_tuple_filed(hw, rss_hf); +- req->tuple_field = rte_cpu_to_le_64(tuple_field); ++ req->tuple_field = rte_cpu_to_le_64(tuple_fields); + ret = hns3_cmd_send(hw, &desc, 1); +- if (ret) { +- hns3_err(hw, "Update RSS flow types tuples failed %d", ret); +- return ret; +- } ++ if (ret != 0) ++ hns3_err(hw, "set RSS hash tuple fields failed ret = %d", ret); + +- return 0; ++ return ret; ++} ++ ++int ++hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf) ++{ ++ uint64_t tuple_fields; ++ int ret; ++ ++ tuple_fields = hns3_rss_calc_tuple_filed(hw, rss_hf); ++ ret = hns3_set_rss_tuple_field(hw, tuple_fields); ++ if (ret != 0) ++ hns3_err(hw, "Update RSS flow types tuples failed, ret = %d", ++ ret); ++ ++ return ret; + } + + /* +@@ -1000,6 +954,52 @@ hns3_set_rss_tc_mode(struct hns3_hw *hw) + return ret; + } + ++/* ++ * Note: the 'hash_algo' is defined by enum rte_eth_hash_function. ++ */ ++int ++hns3_update_rss_algo_key(struct hns3_hw *hw, uint8_t hash_func, ++ uint8_t *key, uint8_t key_len) ++{ ++ uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; ++ bool modify_key, modify_algo; ++ uint8_t hash_algo; ++ int ret; ++ ++ modify_key = (key != NULL && key_len > 0); ++ modify_algo = hash_func != RTE_ETH_HASH_FUNCTION_DEFAULT; ++ if (!modify_key && !modify_algo) ++ return 0; ++ ++ if (modify_algo && hash_func >= RTE_DIM(hns3_hash_func_map)) { ++ hns3_err(hw, "hash func (%u) is unsupported.", hash_func); ++ return -ENOTSUP; ++ } ++ if (modify_key && key_len != hw->rss_key_size) { ++ hns3_err(hw, "hash key length (%u) is invalid.", key_len); ++ return -EINVAL; ++ } ++ ++ ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_key, hw->rss_key_size); ++ if (ret != 0) { ++ hns3_err(hw, "fail to get RSS hash algorithm and key, ret = %d", ++ ret); ++ return ret; ++ } ++ ++ if (modify_algo) ++ hash_algo = hns3_hash_func_map[hash_func]; ++ if (modify_key) ++ memcpy(rss_key, key, key_len); ++ ++ ret = hns3_rss_set_algo_key(hw, hash_algo, rss_key, hw->rss_key_size); ++ if (ret != 0) ++ hns3_err(hw, "fail to set RSS hash algorithm and key, ret = %d", ++ ret); ++ ++ return ret; ++} ++ + static void + hns3_rss_tuple_uninit(struct hns3_hw *hw) + { +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index d19730c69c..d672481a14 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -8,23 +8,102 @@ + #include + #include + +-#define HNS3_ETH_RSS_SUPPORT ( \ +- RTE_ETH_RSS_IPV4 | \ +- RTE_ETH_RSS_FRAG_IPV4 | \ +- RTE_ETH_RSS_NONFRAG_IPV4_TCP | \ +- RTE_ETH_RSS_NONFRAG_IPV4_UDP | \ +- RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \ +- RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \ +- RTE_ETH_RSS_IPV6 | \ +- RTE_ETH_RSS_FRAG_IPV6 | \ +- RTE_ETH_RSS_NONFRAG_IPV6_TCP | \ +- RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ +- RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ +- RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ +- RTE_ETH_RSS_L3_SRC_ONLY | \ +- RTE_ETH_RSS_L3_DST_ONLY | \ +- RTE_ETH_RSS_L4_SRC_ONLY | \ +- RTE_ETH_RSS_L4_DST_ONLY) ++#define HNS3_RSS_SUPPORT_L3_SRC_DST (RTE_ETH_RSS_L3_SRC_ONLY | \ ++ RTE_ETH_RSS_L3_DST_ONLY) ++#define HNS3_RSS_SUPPORT_L4_SRC_DST (RTE_ETH_RSS_L4_SRC_ONLY | \ ++ RTE_ETH_RSS_L4_DST_ONLY) ++#define HNS3_RSS_SUPPORT_L3L4 (HNS3_RSS_SUPPORT_L3_SRC_DST | \ ++ HNS3_RSS_SUPPORT_L4_SRC_DST) ++ ++#define HNS3_RSS_SUPPORT_FLOW_TYPE (RTE_ETH_RSS_IPV4 | \ ++ RTE_ETH_RSS_FRAG_IPV4 | \ ++ RTE_ETH_RSS_NONFRAG_IPV4_TCP | \ ++ RTE_ETH_RSS_NONFRAG_IPV4_UDP | \ ++ RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \ ++ RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \ ++ RTE_ETH_RSS_IPV6 | \ ++ RTE_ETH_RSS_FRAG_IPV6 | \ ++ RTE_ETH_RSS_NONFRAG_IPV6_TCP | \ ++ RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ ++ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ ++ RTE_ETH_RSS_NONFRAG_IPV6_OTHER) ++ ++#define HNS3_ETH_RSS_SUPPORT (HNS3_RSS_SUPPORT_FLOW_TYPE | \ ++ HNS3_RSS_SUPPORT_L3L4) ++ ++enum hns3_tuple_field { ++ /* IPV4_TCP ENABLE FIELD */ ++ HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D = 0, ++ HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S, ++ HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D, ++ HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S, ++ ++ /* IPV4_UDP ENABLE FIELD */ ++ HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D = 8, ++ HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S, ++ HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D, ++ HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S, ++ ++ /* IPV4_SCTP ENABLE FIELD */ ++ HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D = 16, ++ HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S, ++ HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D, ++ HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S, ++ HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER, ++ ++ /* IPV4 ENABLE FIELD */ ++ HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D = 24, ++ HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S, ++ HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D, ++ HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S, ++ ++ /* IPV6_TCP ENABLE FIELD */ ++ HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D = 32, ++ HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S, ++ HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D, ++ HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S, ++ ++ /* IPV6_UDP ENABLE FIELD */ ++ HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D = 40, ++ HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S, ++ HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D, ++ HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S, ++ ++ /* IPV6_SCTP ENABLE FIELD */ ++ HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D = 48, ++ HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S, ++ HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D, ++ HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S, ++ HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER, ++ ++ /* IPV6 ENABLE FIELD */ ++ HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D = 56, ++ HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S, ++ HNS3_RSS_FIELD_IPV6_FRAG_IP_D, ++ HNS3_RSS_FIELD_IPV6_FRAG_IP_S ++}; ++ ++#define HNS3_RSS_PCTYPE_IPV4_TCP BIT_ULL(0) ++#define HNS3_RSS_PCTYPE_IPV4_UDP BIT_ULL(8) ++#define HNS3_RSS_PCTYPE_IPV4_SCTP BIT_ULL(16) ++#define HNS3_RSS_PCTYPE_IPV4_NONF BIT_ULL(24) ++#define HNS3_RSS_PCTYPE_IPV4_FLAG BIT_ULL(26) ++#define HNS3_RSS_PCTYPE_IPV6_TCP BIT_ULL(32) ++#define HNS3_RSS_PCTYPE_IPV6_UDP BIT_ULL(40) ++#define HNS3_RSS_PCTYPE_IPV6_SCTP BIT_ULL(48) ++#define HNS3_RSS_PCTYPE_IPV6_NONF BIT_ULL(56) ++#define HNS3_RSS_PCTYPE_IPV6_FLAG BIT_ULL(58) ++ ++#define HNS3_RSS_TUPLE_IPV4_TCP_M GENMASK(3, 0) ++#define HNS3_RSS_TUPLE_IPV4_UDP_M GENMASK(11, 8) ++#define HNS3_RSS_TUPLE_IPV4_SCTP_M GENMASK(20, 16) ++#define HNS3_RSS_TUPLE_IPV4_NONF_M GENMASK(25, 24) ++#define HNS3_RSS_TUPLE_IPV4_FLAG_M GENMASK(27, 26) ++#define HNS3_RSS_TUPLE_IPV6_TCP_M GENMASK(35, 32) ++#define HNS3_RSS_TUPLE_IPV6_UDP_M GENMASK(43, 40) ++#define HNS3_RSS_TUPLE_IPV6_SCTP_M GENMASK(52, 48) ++#define HNS3_RSS_TUPLE_IPV6_NONF_M GENMASK(57, 56) ++#define HNS3_RSS_TUPLE_IPV6_FLAG_M GENMASK(59, 58) + + #define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */ + #define HNS3_RSS_IND_TBL_SIZE_MAX 2048 +@@ -108,10 +187,14 @@ int hns3_rss_reset_indir_table(struct hns3_hw *hw); + int hns3_config_rss(struct hns3_adapter *hns); + void hns3_rss_uninit(struct hns3_adapter *hns); + int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); ++int hns3_set_rss_tuple_field(struct hns3_hw *hw, uint64_t tuple_fields); + int hns3_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields); + int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + const uint8_t *key, uint8_t key_len); + int hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo, + uint8_t *key, uint8_t key_len); ++uint64_t hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf); ++int hns3_update_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo, ++ uint8_t *key, uint8_t key_len); + + #endif /* HNS3_RSS_H */ +-- +2.23.0 + diff --git a/0254-net-hns3-add-verification-of-RSS-types.patch b/0254-net-hns3-add-verification-of-RSS-types.patch new file mode 100644 index 0000000..302bf4a --- /dev/null +++ b/0254-net-hns3-add-verification-of-RSS-types.patch @@ -0,0 +1,199 @@ +From 190de70e4c72d4abb356c8f8a24fec9ec17ce6c1 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 10 Mar 2023 17:35:18 +0800 +Subject: net/hns3: add verification of RSS types + +[ upstream commit eb3ef9e0d7eb54b47ab58d3d14f9f5fff3f4120b ] + +Add the verification of RSS types from ethdev ops and rte flow without +pattern attribute. The following cases are invalid: +1. types contains unsupported RSS type but hasn't type driver support. +2. types has L3 src/dst but hasn't supported packet type. +3. types has L4 src/dst but hasn't supported packet type and hasn't IP + packet type. + +Fixes: 13c3993240c8 ("net/hns3: add L3 and L4 RSS types") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 12 +++--- + drivers/net/hns3/hns3_rss.c | 74 +++++++++++++++++++++++++----------- + drivers/net/hns3/hns3_rss.h | 3 +- + 3 files changed, 60 insertions(+), 29 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index c38bd9dd8b..c1f4f5cb0b 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1652,9 +1652,10 @@ hns3_flow_parse_rss_types(struct hns3_hw *hw, + + /* no pattern specified to set global RSS types. */ + if (pattern_type == 0) { +- if (rss_act->types & ~HNS3_ETH_RSS_SUPPORT) +- hns3_warn(hw, "some types in the requested RSS types (0x%" PRIx64 ") aren't supported, they are ignored.", +- rss_act->types); ++ if (!hns3_check_rss_types_valid(hw, rss_act->types)) ++ return rte_flow_error_set(error, EINVAL, ++ RTE_FLOW_ERROR_TYPE_ACTION_CONF, ++ NULL, "RSS types is invalid."); + rss_conf->hw_pctypes = + hns3_flow_get_all_hw_pctypes(rss_act->types); + return 0; +@@ -1929,15 +1930,14 @@ hns3_flow_set_rss_ptype_tuple(struct hns3_hw *hw, + uint64_t pctype = BIT_ULL(idx); + + tuple_mask = hns3_flow_get_pctype_tuple_mask(pctype); +- tuples = hns3_rss_calc_tuple_filed(hw, +- rss_conf->conf.types); ++ tuples = hns3_rss_calc_tuple_filed(rss_conf->conf.types); + new_tuple_fields &= ~tuple_mask; + new_tuple_fields |= tuples; + hw_pctypes &= ~pctype; + } + } else { + new_tuple_fields = +- hns3_rss_calc_tuple_filed(hw, rss_conf->conf.types); ++ hns3_rss_calc_tuple_filed(rss_conf->conf.types); + } + + ret = hns3_set_rss_tuple_field(hw, new_tuple_fields); +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index dfa2901ae3..6126512bd7 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -492,34 +492,62 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw) + return ret; + } + +-static void +-hns3_rss_check_l3l4_types(struct hns3_hw *hw, uint64_t rss_hf) ++bool ++hns3_check_rss_types_valid(struct hns3_hw *hw, uint64_t types) + { + uint64_t ip_mask = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | + RTE_ETH_RSS_NONFRAG_IPV4_OTHER | + RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | + RTE_ETH_RSS_NONFRAG_IPV6_OTHER; +- uint64_t l4_mask = RTE_ETH_RSS_NONFRAG_IPV4_TCP | +- RTE_ETH_RSS_NONFRAG_IPV4_UDP | +- RTE_ETH_RSS_NONFRAG_IPV4_SCTP | +- RTE_ETH_RSS_NONFRAG_IPV6_TCP | +- RTE_ETH_RSS_NONFRAG_IPV6_UDP | +- RTE_ETH_RSS_NONFRAG_IPV6_SCTP; +- uint64_t l3_src_dst_mask = RTE_ETH_RSS_L3_SRC_ONLY | +- RTE_ETH_RSS_L3_DST_ONLY; +- uint64_t l4_src_dst_mask = RTE_ETH_RSS_L4_SRC_ONLY | +- RTE_ETH_RSS_L4_DST_ONLY; +- +- if (rss_hf & l3_src_dst_mask && +- !(rss_hf & ip_mask || rss_hf & l4_mask)) +- hns3_warn(hw, "packet type isn't specified, L3_SRC/DST_ONLY is ignored."); +- +- if (rss_hf & l4_src_dst_mask && !(rss_hf & l4_mask)) +- hns3_warn(hw, "packet type isn't specified, L4_SRC/DST_ONLY is ignored."); ++ uint64_t ip_l4_mask = RTE_ETH_RSS_NONFRAG_IPV4_TCP | ++ RTE_ETH_RSS_NONFRAG_IPV4_UDP | ++ RTE_ETH_RSS_NONFRAG_IPV4_SCTP | ++ RTE_ETH_RSS_NONFRAG_IPV6_TCP | ++ RTE_ETH_RSS_NONFRAG_IPV6_UDP | ++ RTE_ETH_RSS_NONFRAG_IPV6_SCTP; ++ bool has_l4_src_dst = !!(types & HNS3_RSS_SUPPORT_L4_SRC_DST); ++ bool has_ip_pkt = !!(types & ip_mask); ++ uint64_t final_types; ++ ++ if (types == 0) ++ return true; ++ ++ if ((types & HNS3_ETH_RSS_SUPPORT) == 0) { ++ hns3_err(hw, "specified types(0x%" PRIx64 ") are unsupported.", ++ types); ++ return false; ++ } ++ ++ if ((types & HNS3_RSS_SUPPORT_L3_SRC_DST) != 0 && ++ (types & HNS3_RSS_SUPPORT_FLOW_TYPE) == 0) { ++ hns3_err(hw, "IP or IP-TCP/UDP/SCTP packet type isn't specified, L3_SRC/DST_ONLY cannot be set."); ++ return false; ++ } ++ ++ if (has_l4_src_dst && (types & ip_l4_mask) == 0) { ++ if (!has_ip_pkt) { ++ hns3_err(hw, "IP-TCP/UDP/SCTP packet type isn't specified, L4_SRC/DST_ONLY cannot be set."); ++ return false; ++ } ++ /* ++ * For the case that the types has L4_SRC/DST_ONLY but hasn't ++ * IP-TCP/UDP/SCTP packet type, this types is considered valid ++ * if it also has IP packet type. ++ */ ++ hns3_warn(hw, "L4_SRC/DST_ONLY is ignored because of no including L4 packet."); ++ } ++ ++ if ((types & ~HNS3_ETH_RSS_SUPPORT) != 0) { ++ final_types = types & HNS3_ETH_RSS_SUPPORT; ++ hns3_warn(hw, "set RSS types based on hardware support, requested:0x%" PRIx64 " configured:0x%" PRIx64 "", ++ types, final_types); ++ } ++ ++ return true; + } + + uint64_t +-hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf) ++hns3_rss_calc_tuple_filed(uint64_t rss_hf) + { + uint64_t l3_only_mask = RTE_ETH_RSS_L3_SRC_ONLY | + RTE_ETH_RSS_L3_DST_ONLY; +@@ -548,7 +576,6 @@ hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf) + !has_l3_l4_only) + tuple |= hns3_set_tuple_table[i].rss_field; + } +- hns3_rss_check_l3l4_types(hw, rss_hf); + + return tuple; + } +@@ -576,7 +603,7 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf) + uint64_t tuple_fields; + int ret; + +- tuple_fields = hns3_rss_calc_tuple_filed(hw, rss_hf); ++ tuple_fields = hns3_rss_calc_tuple_filed(rss_hf); + ret = hns3_set_rss_tuple_field(hw, tuple_fields); + if (ret != 0) + hns3_err(hw, "Update RSS flow types tuples failed, ret = %d", +@@ -611,6 +638,9 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + return -EINVAL; + } + ++ if (!hns3_check_rss_types_valid(hw, rss_hf)) ++ return -EINVAL; ++ + rte_spinlock_lock(&hw->lock); + ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_hf); + if (ret) +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index d672481a14..415430a399 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -186,6 +186,7 @@ int hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, + int hns3_rss_reset_indir_table(struct hns3_hw *hw); + int hns3_config_rss(struct hns3_adapter *hns); + void hns3_rss_uninit(struct hns3_adapter *hns); ++bool hns3_check_rss_types_valid(struct hns3_hw *hw, uint64_t types); + int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); + int hns3_set_rss_tuple_field(struct hns3_hw *hw, uint64_t tuple_fields); + int hns3_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields); +@@ -193,7 +194,7 @@ int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + const uint8_t *key, uint8_t key_len); + int hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo, + uint8_t *key, uint8_t key_len); +-uint64_t hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf); ++uint64_t hns3_rss_calc_tuple_filed(uint64_t rss_hf); + int hns3_update_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + uint8_t *key, uint8_t key_len); + +-- +2.23.0 + diff --git a/0255-test-mbuf-fix-mbuf-reset-test.patch b/0255-test-mbuf-fix-mbuf-reset-test.patch new file mode 100644 index 0000000..b66b2a3 --- /dev/null +++ b/0255-test-mbuf-fix-mbuf-reset-test.patch @@ -0,0 +1,35 @@ +From b6f800b2897f8e2008d0897ceaa491a357eab1cf Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Tue, 31 Jan 2023 10:48:51 +0800 +Subject: test/mbuf: fix mbuf reset test + +[ upstream commit bf47fb83a61a4bc6bf45e1ec6e3ddd239a856190 ] + +Retest "mbuf_autotest" will fail because the mbuf pool was +not freed after previous test successful done. +This patch fixes it. + +Fixes: efc6f9104c80 ("mbuf: fix reset on mbuf free") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +Reviewed-by: David Marchand +--- + app/test/test_mbuf.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c +index f54d1d7c00..cd9f8fd8cf 100644 +--- a/app/test/test_mbuf.c ++++ b/app/test/test_mbuf.c +@@ -2769,6 +2769,7 @@ test_nb_segs_and_next_reset(void) + m2->nb_segs != 1 || m2->next != NULL) + GOTO_FAIL("nb_segs or next was not reset properly"); + ++ rte_mempool_free(pool); + return 0; + + fail: +-- +2.23.0 + diff --git a/0256-examples-l3fwd-power-support-CPPC-cpufreq.patch b/0256-examples-l3fwd-power-support-CPPC-cpufreq.patch new file mode 100644 index 0000000..8100126 --- /dev/null +++ b/0256-examples-l3fwd-power-support-CPPC-cpufreq.patch @@ -0,0 +1,53 @@ +From 9f45602b8df4c7a0eca4228ab94de824b1c5337b Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Tue, 31 Jan 2023 10:58:52 +0800 +Subject: examples/l3fwd-power: support CPPC cpufreq + +[ upstream commit bc6fe48468767df2b6a31c9de06796164981cbaf ] + +Currently the l3fwd-power only supports ACPI cpufreq and Pstate +cpufreq, This patch adds CPPC cpufreq. + +Signed-off-by: Jie Hai +Acked-by: David Hunt +Acked-by: Dongdong Liu +--- + examples/l3fwd-power/main.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c +index 20e5b59af9..a2eb35d6e2 100644 +--- a/examples/l3fwd-power/main.c ++++ b/examples/l3fwd-power/main.c +@@ -2290,9 +2290,10 @@ init_power_library(void) + /* we're not supporting the VM channel mode */ + env = rte_power_get_env(); + if (env != PM_ENV_ACPI_CPUFREQ && +- env != PM_ENV_PSTATE_CPUFREQ) { ++ env != PM_ENV_PSTATE_CPUFREQ && ++ env != PM_ENV_CPPC_CPUFREQ) { + RTE_LOG(ERR, POWER, +- "Only ACPI and PSTATE mode are supported\n"); ++ "Only ACPI, PSTATE and CPPC mode are supported\n"); + return -1; + } + } +@@ -2456,12 +2457,14 @@ autodetect_mode(void) + /* + * Empty poll and telemetry modes have to be specifically requested to + * be enabled, but we can auto-detect between interrupt mode with or +- * without frequency scaling. Both ACPI and pstate can be used. ++ * without frequency scaling. Any of ACPI, pstate and CPPC can be used. + */ + if (rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ)) + return APP_MODE_LEGACY; + if (rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ)) + return APP_MODE_LEGACY; ++ if (rte_power_check_env_supported(PM_ENV_CPPC_CPUFREQ)) ++ return APP_MODE_LEGACY; + + RTE_LOG(NOTICE, L3FWD_POWER, "Frequency scaling not supported, selecting interrupt-only mode\n"); + +-- +2.23.0 + diff --git a/hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch b/0257-hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch similarity index 78% rename from hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch rename to 0257-hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch index a4a410e..9a8d751 100644 --- a/hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch +++ b/0257-hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch @@ -1,7 +1,7 @@ -From 5600cdc0dcdc7e70a44fb6c8c9e7594cce62f119 Mon Sep 17 00:00:00 2001 +From b5c93dae2b73115c46f2e66dc87be61a200e006b Mon Sep 17 00:00:00 2001 From: jiangheng12 -Date: Fri, 24 Mar 2023 16:58:43 +0800 -Subject: [PATCH] hinic: free mbuf use rte_pktmbuf_free_seg +Date: Sat, 1 Apr 2023 21:56:20 +0800 +Subject: [PATCH] hinic: free tx mbuf use rte_pktmbuf_free_seg --- drivers/net/hinic/hinic_pmd_tx.c | 27 ++++++++++++++++++--------- @@ -9,7 +9,7 @@ Subject: [PATCH] hinic: free mbuf use rte_pktmbuf_free_seg 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c -index 985540a..670247b 100644 +index f09b1a6..8eab94d 100644 --- a/drivers/net/hinic/hinic_pmd_tx.c +++ b/drivers/net/hinic/hinic_pmd_tx.c @@ -30,13 +30,6 @@ @@ -23,10 +23,10 @@ index 985540a..670247b 100644 -#define HINIC_TSO_PKT_MAX_SGE 127 /* tso max sge 127 */ -#define HINIC_TSO_SEG_NUM_INVALID(num) ((num) > HINIC_TSO_PKT_MAX_SGE) - - #define HINIC_TX_OUTER_CHECKSUM_FLAG_SET 1 - #define HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET 0 + /* sizeof(struct hinic_sq_bufdesc) == 16, shift 4 */ + #define HINIC_BUF_DESC_SIZE(nr_descs) (SIZE_8BYTES(((u32)nr_descs) << 4)) -@@ -608,6 +601,7 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq) +@@ -640,6 +633,7 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq) if (likely(mbuf->nb_segs == 1)) { m = rte_pktmbuf_prefree_seg(mbuf); tx_info->mbuf = NULL; @@ -34,7 +34,7 @@ index 985540a..670247b 100644 if (unlikely(m == NULL)) continue; -@@ -621,8 +615,11 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq) +@@ -653,8 +647,11 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq) mbuf_free[nb_free++] = m; } } else { @@ -47,7 +47,7 @@ index 985540a..670247b 100644 } } -@@ -1129,6 +1126,13 @@ u16 hinic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts) +@@ -1191,6 +1188,13 @@ u16 hinic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts) tx_info->mbuf = mbuf_pkt; tx_info->wqebb_cnt = wqe_wqebb_cnt; @@ -61,7 +61,7 @@ index 985540a..670247b 100644 /* 7. fill sq wqe header section */ hinic_fill_sq_wqe_header(&sq_wqe->ctrl, queue_info, sqe_info.sge_cnt, sqe_info.owner); -@@ -1169,7 +1173,12 @@ void hinic_free_all_tx_mbufs(struct hinic_txq *txq) +@@ -1231,7 +1235,12 @@ void hinic_free_all_tx_mbufs(struct hinic_txq *txq) tx_info->cpy_mbuf = NULL; } @@ -76,12 +76,12 @@ index 985540a..670247b 100644 tx_info->wqebb_cnt); diff --git a/drivers/net/hinic/hinic_pmd_tx.h b/drivers/net/hinic/hinic_pmd_tx.h -index a1ca580..dd2baff 100644 +index a3ec629..70159bd 100644 --- a/drivers/net/hinic/hinic_pmd_tx.h +++ b/drivers/net/hinic/hinic_pmd_tx.h -@@ -21,6 +21,13 @@ - PKT_TX_OUTER_IP_CKSUM | \ - PKT_TX_TCP_SEG) +@@ -20,6 +20,13 @@ + RTE_MBUF_F_TX_OUTER_IP_CKSUM | \ + RTE_MBUF_F_TX_TCP_SEG) +#define HINIC_NONTSO_PKT_MAX_SGE 17 /* non-tso max sge 17 */ +#define HINIC_NONTSO_SEG_NUM_INVALID(num) \ @@ -93,7 +93,7 @@ index a1ca580..dd2baff 100644 enum sq_wqe_type { SQ_NORMAL_WQE = 0, }; -@@ -97,6 +104,8 @@ struct hinic_txq_stats { +@@ -98,6 +105,8 @@ struct hinic_txq_stats { struct hinic_tx_info { struct rte_mbuf *mbuf; diff --git a/0258-net-bonding-support-private-dump-operation.patch b/0258-net-bonding-support-private-dump-operation.patch new file mode 100644 index 0000000..88867d1 --- /dev/null +++ b/0258-net-bonding-support-private-dump-operation.patch @@ -0,0 +1,150 @@ +From fdbebc668c5df36d34a64ba627b6e373263c1fca Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Wed, 14 Dec 2022 06:13:23 +0000 +Subject: net/bonding: support private dump operation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 29e89fb1e30cf12937dec8a3f4f7ab86f0303d24 ] + +This patch implements eth_dev_priv_dump ops which could enhance the +debug capability. + +The dump output is similar to testpmd command +"show bonding config [port]". + +Signed-off-by: Chengwen Feng +Acked-by:Min Hu (Connor) +Acked-by: Huisong Li +Acked-by: Ferruh Yigit +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 105 ++++++++++++++++++++++++- + 1 file changed, 104 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 29871cf8a3..cf7d275bf5 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -3297,6 +3297,108 @@ bond_ethdev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) + rte_spinlock_unlock(&internals->lock); + } + ++static const char * ++bond_mode_name(uint8_t mode) ++{ ++ switch (mode) { ++ case BONDING_MODE_ROUND_ROBIN: ++ return "ROUND_ROBIN"; ++ case BONDING_MODE_ACTIVE_BACKUP: ++ return "ACTIVE_BACKUP"; ++ case BONDING_MODE_BALANCE: ++ return "BALANCE"; ++ case BONDING_MODE_BROADCAST: ++ return "BROADCAST"; ++ case BONDING_MODE_8023AD: ++ return "8023AD"; ++ case BONDING_MODE_TLB: ++ return "TLB"; ++ case BONDING_MODE_ALB: ++ return "ALB"; ++ default: ++ return "Unknown"; ++ } ++} ++ ++static int ++bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f) ++{ ++ struct bond_dev_private instant_priv; ++ const struct bond_dev_private *internals = &instant_priv; ++ int mode, i; ++ ++ /* Obtain a instance of dev_private to prevent data from being modified. */ ++ memcpy(&instant_priv, dev->data->dev_private, sizeof(struct bond_dev_private)); ++ mode = internals->mode; ++ ++ fprintf(f, " - Dev basic:\n"); ++ fprintf(f, "\tBonding mode: %s(%d)\n", bond_mode_name(mode), mode); ++ ++ if (mode == BONDING_MODE_BALANCE || mode == BONDING_MODE_8023AD) { ++ fprintf(f, "\tBalance Xmit Policy: "); ++ switch (internals->balance_xmit_policy) { ++ case BALANCE_XMIT_POLICY_LAYER2: ++ fprintf(f, "BALANCE_XMIT_POLICY_LAYER2"); ++ break; ++ case BALANCE_XMIT_POLICY_LAYER23: ++ fprintf(f, "BALANCE_XMIT_POLICY_LAYER23"); ++ break; ++ case BALANCE_XMIT_POLICY_LAYER34: ++ fprintf(f, "BALANCE_XMIT_POLICY_LAYER34"); ++ break; ++ default: ++ fprintf(f, "Unknown"); ++ } ++ fprintf(f, "\n"); ++ } ++ ++ if (mode == BONDING_MODE_8023AD) { ++ fprintf(f, "\tIEEE802.3AD Aggregator Mode: "); ++ switch (internals->mode4.agg_selection) { ++ case AGG_BANDWIDTH: ++ fprintf(f, "bandwidth"); ++ break; ++ case AGG_STABLE: ++ fprintf(f, "stable"); ++ break; ++ case AGG_COUNT: ++ fprintf(f, "count"); ++ break; ++ default: ++ fprintf(f, "unknown"); ++ } ++ fprintf(f, "\n"); ++ } ++ ++ if (internals->slave_count > 0) { ++ fprintf(f, "\tSlaves (%u): [", internals->slave_count); ++ for (i = 0; i < internals->slave_count - 1; i++) ++ fprintf(f, "%u ", internals->slaves[i].port_id); ++ ++ fprintf(f, "%u]\n", internals->slaves[internals->slave_count - 1].port_id); ++ } else { ++ fprintf(f, "\tSlaves: []\n"); ++ } ++ ++ if (internals->active_slave_count > 0) { ++ fprintf(f, "\tActive Slaves (%u): [", internals->active_slave_count); ++ for (i = 0; i < internals->active_slave_count - 1; i++) ++ fprintf(f, "%u ", internals->active_slaves[i]); ++ ++ fprintf(f, "%u]\n", internals->active_slaves[internals->active_slave_count - 1]); ++ ++ } else { ++ fprintf(f, "\tActive Slaves: []\n"); ++ } ++ ++ if (internals->user_defined_primary_port) ++ fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port); ++ if (internals->slave_count > 0) ++ fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port); ++ ++ return 0; ++} ++ + const struct eth_dev_ops default_dev_ops = { + .dev_start = bond_ethdev_start, + .dev_stop = bond_ethdev_stop, +@@ -3323,7 +3425,8 @@ const struct eth_dev_ops default_dev_ops = { + .mac_addr_set = bond_ethdev_mac_address_set, + .mac_addr_add = bond_ethdev_mac_addr_add, + .mac_addr_remove = bond_ethdev_mac_addr_remove, +- .flow_ops_get = bond_flow_ops_get ++ .flow_ops_get = bond_flow_ops_get, ++ .eth_dev_priv_dump = bond_ethdev_priv_dump, + }; + + static int +-- +2.23.0 + diff --git a/0259-net-bonding-add-LACP-info-dump.patch b/0259-net-bonding-add-LACP-info-dump.patch new file mode 100644 index 0000000..6839d34 --- /dev/null +++ b/0259-net-bonding-add-LACP-info-dump.patch @@ -0,0 +1,187 @@ +From a74801e4c1d59a8e40317c8ea9e4ba3a5472d633 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Wed, 14 Dec 2022 06:13:24 +0000 +Subject: net/bonding: add LACP info dump +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit b00119fc03dc585213236ea7f550662befa68fbe ] + +This patch adds dump lacp info in eth_dev_priv_dump ops. + +The extra dump output is similar to testpmd command +"show bonding lacp info [port]". + +Signed-off-by: Chengwen Feng +Acked-by:Min Hu (Connor) +Acked-by: Huisong Li +Acked-by: Ferruh Yigit +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 143 ++++++++++++++++++++++++- + 1 file changed, 141 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index cf7d275bf5..0f2b21a568 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -3320,8 +3320,8 @@ bond_mode_name(uint8_t mode) + } + } + +-static int +-bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f) ++static void ++dump_basic(const struct rte_eth_dev *dev, FILE *f) + { + struct bond_dev_private instant_priv; + const struct bond_dev_private *internals = &instant_priv; +@@ -3395,6 +3395,145 @@ bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f) + fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port); + if (internals->slave_count > 0) + fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port); ++} ++ ++static void ++dump_lacp_conf(const struct rte_eth_bond_8023ad_conf *conf, FILE *f) ++{ ++ fprintf(f, "\tfast period: %u ms\n", conf->fast_periodic_ms); ++ fprintf(f, "\tslow period: %u ms\n", conf->slow_periodic_ms); ++ fprintf(f, "\tshort timeout: %u ms\n", conf->short_timeout_ms); ++ fprintf(f, "\tlong timeout: %u ms\n", conf->long_timeout_ms); ++ fprintf(f, "\taggregate wait timeout: %u ms\n", ++ conf->aggregate_wait_timeout_ms); ++ fprintf(f, "\ttx period: %u ms\n", conf->tx_period_ms); ++ fprintf(f, "\trx marker period: %u ms\n", conf->rx_marker_period_ms); ++ fprintf(f, "\tupdate timeout: %u ms\n", conf->update_timeout_ms); ++ switch (conf->agg_selection) { ++ case AGG_BANDWIDTH: ++ fprintf(f, "\taggregation mode: bandwidth\n"); ++ break; ++ case AGG_STABLE: ++ fprintf(f, "\taggregation mode: stable\n"); ++ break; ++ case AGG_COUNT: ++ fprintf(f, "\taggregation mode: count\n"); ++ break; ++ default: ++ fprintf(f, "\taggregation mode: invalid\n"); ++ break; ++ } ++ fprintf(f, "\n"); ++} ++ ++static void ++dump_lacp_port_param(const struct port_params *params, FILE *f) ++{ ++ char buf[RTE_ETHER_ADDR_FMT_SIZE]; ++ fprintf(f, "\t\tsystem priority: %u\n", params->system_priority); ++ rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system); ++ fprintf(f, "\t\tsystem mac address: %s\n", buf); ++ fprintf(f, "\t\tport key: %u\n", params->key); ++ fprintf(f, "\t\tport priority: %u\n", params->port_priority); ++ fprintf(f, "\t\tport number: %u\n", params->port_number); ++} ++ ++static void ++dump_lacp_slave(const struct rte_eth_bond_8023ad_slave_info *info, FILE *f) ++{ ++ char a_state[256] = { 0 }; ++ char p_state[256] = { 0 }; ++ int a_len = 0; ++ int p_len = 0; ++ uint32_t i; ++ ++ static const char * const state[] = { ++ "ACTIVE", ++ "TIMEOUT", ++ "AGGREGATION", ++ "SYNCHRONIZATION", ++ "COLLECTING", ++ "DISTRIBUTING", ++ "DEFAULTED", ++ "EXPIRED" ++ }; ++ static const char * const selection[] = { ++ "UNSELECTED", ++ "STANDBY", ++ "SELECTED" ++ }; ++ ++ for (i = 0; i < RTE_DIM(state); i++) { ++ if ((info->actor_state >> i) & 1) ++ a_len += snprintf(&a_state[a_len], ++ RTE_DIM(a_state) - a_len, "%s ", ++ state[i]); ++ ++ if ((info->partner_state >> i) & 1) ++ p_len += snprintf(&p_state[p_len], ++ RTE_DIM(p_state) - p_len, "%s ", ++ state[i]); ++ } ++ fprintf(f, "\tAggregator port id: %u\n", info->agg_port_id); ++ fprintf(f, "\tselection: %s\n", selection[info->selected]); ++ fprintf(f, "\tActor detail info:\n"); ++ dump_lacp_port_param(&info->actor, f); ++ fprintf(f, "\t\tport state: %s\n", a_state); ++ fprintf(f, "\tPartner detail info:\n"); ++ dump_lacp_port_param(&info->partner, f); ++ fprintf(f, "\t\tport state: %s\n", p_state); ++ fprintf(f, "\n"); ++} ++ ++static void ++dump_lacp(uint16_t port_id, FILE *f) ++{ ++ struct rte_eth_bond_8023ad_slave_info slave_info; ++ struct rte_eth_bond_8023ad_conf port_conf; ++ uint16_t slaves[RTE_MAX_ETHPORTS]; ++ int num_active_slaves; ++ int i, ret; ++ ++ fprintf(f, " - Lacp info:\n"); ++ ++ num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, ++ RTE_MAX_ETHPORTS); ++ if (num_active_slaves < 0) { ++ fprintf(f, "\tFailed to get active slave list for port %u\n", ++ port_id); ++ return; ++ } ++ ++ fprintf(f, "\tIEEE802.3 port: %u\n", port_id); ++ ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf); ++ if (ret) { ++ fprintf(f, "\tGet bonded device %u 8023ad config failed\n", ++ port_id); ++ return; ++ } ++ dump_lacp_conf(&port_conf, f); ++ ++ for (i = 0; i < num_active_slaves; i++) { ++ ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i], ++ &slave_info); ++ if (ret) { ++ fprintf(f, "\tGet slave device %u 8023ad info failed\n", ++ slaves[i]); ++ return; ++ } ++ fprintf(f, "\tSlave Port: %u\n", slaves[i]); ++ dump_lacp_slave(&slave_info, f); ++ } ++} ++ ++static int ++bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f) ++{ ++ const struct bond_dev_private *internals = dev->data->dev_private; ++ ++ dump_basic(dev, f); ++ if (internals->mode == BONDING_MODE_8023AD) ++ dump_lacp(dev->data->port_id, f); + + return 0; + } +-- +2.23.0 + diff --git a/0260-net-virtio-support-private-dump.patch b/0260-net-virtio-support-private-dump.patch new file mode 100644 index 0000000..f2f6550 --- /dev/null +++ b/0260-net-virtio-support-private-dump.patch @@ -0,0 +1,56 @@ +From a247b89fe26e5bae41159dfa59475c04ae53e8e2 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 19 Jan 2023 12:30:55 +0000 +Subject: net/virtio: support private dump + +[ upstream commit 426858d6a9975a26539f0398037558dcb418947a ] + +This patch implements eth_dev_priv_dump callback which could use for +debugging. + +Signed-off-by: Chengwen Feng +Reviewed-by: Maxime Coquelin +--- + drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c +index b317649d7e..a38b15d01c 100644 +--- a/drivers/net/virtio/virtio_ethdev.c ++++ b/drivers/net/virtio/virtio_ethdev.c +@@ -1018,6 +1018,24 @@ virtio_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) + return 0; + } + ++static int ++virtio_dev_priv_dump(struct rte_eth_dev *dev, FILE *f) ++{ ++ struct virtio_hw *hw = dev->data->dev_private; ++ ++ fprintf(f, "guest_features: 0x%" PRIx64 "\n", hw->guest_features); ++ fprintf(f, "vtnet_hdr_size: %u\n", hw->vtnet_hdr_size); ++ fprintf(f, "use_vec: rx-%u tx-%u\n", hw->use_vec_rx, hw->use_vec_tx); ++ fprintf(f, "use_inorder: rx-%u tx-%u\n", hw->use_inorder_rx, hw->use_inorder_tx); ++ fprintf(f, "intr_lsc: %u\n", hw->intr_lsc); ++ fprintf(f, "max_mtu: %u\n", hw->max_mtu); ++ fprintf(f, "max_rx_pkt_len: %zu\n", hw->max_rx_pkt_len); ++ fprintf(f, "max_queue_pairs: %u\n", hw->max_queue_pairs); ++ fprintf(f, "req_guest_features: 0x%" PRIx64 "\n", hw->req_guest_features); ++ ++ return 0; ++} ++ + /* + * dev_ops for virtio, bare necessities for basic operation + */ +@@ -1054,6 +1072,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { + .mac_addr_remove = virtio_mac_addr_remove, + .mac_addr_set = virtio_mac_addr_set, + .get_monitor_addr = virtio_get_monitor_addr, ++ .eth_dev_priv_dump = virtio_dev_priv_dump, + }; + + /* +-- +2.23.0 + diff --git a/0261-net-vhost-support-private-dump.patch b/0261-net-vhost-support-private-dump.patch new file mode 100644 index 0000000..ec38d71 --- /dev/null +++ b/0261-net-vhost-support-private-dump.patch @@ -0,0 +1,55 @@ +From 423959cfe25c9dc231b80f3df59318585df3a023 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 19 Jan 2023 12:30:56 +0000 +Subject: net/vhost: support private dump + +[ upstream commit 47b9fb64c15d60e1c8c2c8f6e63824fd2cada428 ] + +This patch implements eth_dev_priv_dump callback which could use for +debugging. + +Signed-off-by: Chengwen Feng +Reviewed-by: Maxime Coquelin +--- + drivers/net/vhost/rte_eth_vhost.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c +index 070f0e6dfd..b120341d0c 100644 +--- a/drivers/net/vhost/rte_eth_vhost.c ++++ b/drivers/net/vhost/rte_eth_vhost.c +@@ -1429,6 +1429,23 @@ vhost_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) + return 0; + } + ++static int ++vhost_dev_priv_dump(struct rte_eth_dev *dev, FILE *f) ++{ ++ struct pmd_internal *internal = dev->data->dev_private; ++ ++ fprintf(f, "iface_name: %s\n", internal->iface_name); ++ fprintf(f, "flags: 0x%" PRIx64 "\n", internal->flags); ++ fprintf(f, "disable_flags: 0x%" PRIx64 "\n", internal->disable_flags); ++ fprintf(f, "max_queues: %u\n", internal->max_queues); ++ fprintf(f, "vid: %d\n", internal->vid); ++ fprintf(f, "started: %d\n", rte_atomic32_read(&internal->started)); ++ fprintf(f, "dev_attached: %d\n", rte_atomic32_read(&internal->dev_attached)); ++ fprintf(f, "vlan_strip: %d\n", internal->vlan_strip); ++ ++ return 0; ++} ++ + static const struct eth_dev_ops ops = { + .dev_start = eth_dev_start, + .dev_stop = eth_dev_stop, +@@ -1449,6 +1466,7 @@ static const struct eth_dev_ops ops = { + .rx_queue_intr_enable = eth_rxq_intr_enable, + .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, ++ .eth_dev_priv_dump = vhost_dev_priv_dump, + }; + + static int +-- +2.23.0 + diff --git a/0262-app-testpmd-show-private-info-in-port-info.patch b/0262-app-testpmd-show-private-info-in-port-info.patch new file mode 100644 index 0000000..3ba2887 --- /dev/null +++ b/0262-app-testpmd-show-private-info-in-port-info.patch @@ -0,0 +1,37 @@ +From 9f1acbbbe8050c3b8794d45a4af610f9e0774211 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 16 Mar 2023 09:32:16 +0000 +Subject: app/testpmd: show private info in port info + +[ upstream commit d0aa6cd7a43d737797ba139a7f18b879cc44dac3 ] + +This patch adds dump private info in 'show port info [port_id]' cmd. + +Signed-off-by: Chengwen Feng +Acked-by: Aman Singh +Acked-by: Ferruh Yigit +--- + app/test-pmd/config.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index 12386c4d82..873d1f1357 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -891,6 +891,13 @@ port_infos_display(portid_t port_id) + printf("Switch Rx domain: %u\n", + dev_info.switch_info.rx_domain); + } ++ printf("Device private info:\n"); ++ ret = rte_eth_dev_priv_dump(port_id, stdout); ++ if (ret == -ENOTSUP) ++ printf(" none\n"); ++ else if (ret < 0) ++ fprintf(stderr, " Failed to dump private info with error (%d): %s\n", ++ ret, strerror(-ret)); + } + + void +-- +2.23.0 + diff --git a/0263-app-testpmd-display-RSS-hash-key-of-flow-rule.patch b/0263-app-testpmd-display-RSS-hash-key-of-flow-rule.patch new file mode 100644 index 0000000..3dd36b7 --- /dev/null +++ b/0263-app-testpmd-display-RSS-hash-key-of-flow-rule.patch @@ -0,0 +1,48 @@ +From 491333ae684b8303e019536900bb931b9f64b1ce Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 16 Mar 2023 20:58:14 +0800 +Subject: app/testpmd: display RSS hash key of flow rule + +[ upstream commit f958bbe2210dcc888032e81ec1326c0df5e5c518 ] + +There are two ways to set RSS hash key with rte flow rule: +1. 'key_len' isn't zero and 'key' is NULL. +2. 'key_len' isn't zero and 'key' isn't NULL. +This patch adds displaying for the hash key of rte flow rule. + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +Acked-by: Ferruh Yigit +--- + app/test-pmd/config.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index 873d1f1357..78af232a8a 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -1651,6 +1651,21 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) + return; + } + ++ printf(" RSS key:\n"); ++ if (rss_conf->key_len == 0) { ++ printf(" none"); ++ } else { ++ printf(" key_len: %u\n", rss_conf->key_len); ++ printf(" key: "); ++ if (rss_conf->key == NULL) { ++ printf("none"); ++ } else { ++ for (i = 0; i < rss_conf->key_len; i++) ++ printf("%02X", rss_conf->key[i]); ++ } ++ } ++ printf("\n"); ++ + printf(" types:\n"); + if (rss_conf->types == 0) { + printf(" none\n"); +-- +2.23.0 + diff --git a/0264-ethdev-fix-Rx-queue-telemetry-memory-leak-on-failure.patch b/0264-ethdev-fix-Rx-queue-telemetry-memory-leak-on-failure.patch new file mode 100644 index 0000000..3a166df --- /dev/null +++ b/0264-ethdev-fix-Rx-queue-telemetry-memory-leak-on-failure.patch @@ -0,0 +1,39 @@ +From 8cd9ea525b1e9c2a966fdf3616d68c7037b3820a Mon Sep 17 00:00:00 2001 +From: Yunjian Wang +Date: Sat, 8 Jan 2022 15:51:57 +0800 +Subject: ethdev: fix Rx queue telemetry memory leak on failure + +[ upstream commit 52b49ea06ffb2cfbef8fe9578149f1e2dba99e89 ] + +In eth_dev_handle_port_info() allocated memory for rxq_state, +we should free it when error happens, otherwise it will lead +to memory leak. + +Fixes: 58b43c1ddfd1 ("ethdev: add telemetry endpoint for device info") +Cc: stable@dpdk.org + +Signed-off-by: Yunjian Wang +Reviewed-by: Ferruh Yigit +--- + lib/ethdev/rte_ethdev.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index df5a627cbe..d466efffc7 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6383,8 +6383,10 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, + return -ENOMEM; + + txq_state = rte_tel_data_alloc(); +- if (!txq_state) ++ if (!txq_state) { ++ rte_tel_data_free(rxq_state); + return -ENOMEM; ++ } + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_string(d, "name", eth_dev->data->name); +-- +2.23.0 + diff --git a/0265-ethdev-fix-MAC-address-in-telemetry-device-info.patch b/0265-ethdev-fix-MAC-address-in-telemetry-device-info.patch new file mode 100644 index 0000000..327c3b9 --- /dev/null +++ b/0265-ethdev-fix-MAC-address-in-telemetry-device-info.patch @@ -0,0 +1,53 @@ +From db1ea57482d4d11c1c86ad9941c6be782a17ec57 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 16 Feb 2022 15:13:16 +0100 +Subject: ethdev: fix MAC address in telemetry device info + +[ upstream commit ffe77e911f6a3d62757bc740670c4fda28f882f2 ] + +The right size for a human readable MAC is RTE_ETHER_ADDR_FMT_SIZE. +While at it, the net library provides a helper for MAC address +formatting. Prefer it. + +Fixes: 58b43c1ddfd1 ("ethdev: add telemetry endpoint for device info") +Cc: stable@dpdk.org + +Reported-by: Christophe Fontaine +Signed-off-by: David Marchand +Reviewed-by: Ferruh Yigit +--- + lib/ethdev/rte_ethdev.c | 11 +++-------- + 1 file changed, 3 insertions(+), 8 deletions(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index d466efffc7..d82819a458 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6358,7 +6358,7 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, + struct rte_tel_data *d) + { + struct rte_tel_data *rxq_state, *txq_state; +- char mac_addr[RTE_ETHER_ADDR_LEN]; ++ char mac_addr[RTE_ETHER_ADDR_FMT_SIZE]; + struct rte_eth_dev *eth_dev; + char *end_param; + int port_id, i; +@@ -6401,13 +6401,8 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, + eth_dev->data->min_rx_buf_size); + rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail", + eth_dev->data->rx_mbuf_alloc_failed); +- snprintf(mac_addr, RTE_ETHER_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", +- eth_dev->data->mac_addrs->addr_bytes[0], +- eth_dev->data->mac_addrs->addr_bytes[1], +- eth_dev->data->mac_addrs->addr_bytes[2], +- eth_dev->data->mac_addrs->addr_bytes[3], +- eth_dev->data->mac_addrs->addr_bytes[4], +- eth_dev->data->mac_addrs->addr_bytes[5]); ++ rte_ether_format_addr(mac_addr, sizeof(mac_addr), ++ eth_dev->data->mac_addrs); + rte_tel_data_add_dict_string(d, "mac_addr", mac_addr); + rte_tel_data_add_dict_int(d, "promiscuous", + eth_dev->data->promiscuous); +-- +2.23.0 + diff --git a/0266-eventdev-eth_rx-fix-telemetry-Rx-stats-reset.patch b/0266-eventdev-eth_rx-fix-telemetry-Rx-stats-reset.patch new file mode 100644 index 0000000..8fd0662 --- /dev/null +++ b/0266-eventdev-eth_rx-fix-telemetry-Rx-stats-reset.patch @@ -0,0 +1,44 @@ +From 08b69766da122d7d3e20cee328a9166a12f320cb Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Thu, 24 Mar 2022 16:28:30 +0100 +Subject: eventdev/eth_rx: fix telemetry Rx stats reset + +[ upstream commit b450a990b07e008077377a6dfa45a562b3f9a496 ] + +Caught by covscan: + +1. dpdk-21.11/lib/eventdev/rte_event_eth_rx_adapter.c:3279: +logical_vs_bitwise: "~(*__ctype_b_loc()[(int)*params] & 2048 /* +(unsigned short)_ISdigit */)" is always 1/true regardless of the values +of its operand. This occurs as the logical second operand of "||". +2. dpdk-21.11/lib/eventdev/rte_event_eth_rx_adapter.c:3279: remediation: +Did you intend to use "!" rather than "~"? + +While isdigit return value should be compared as an int to 0, +prefer ! since all of this file uses this convention. + +Fixes: 814d01709328 ("eventdev/eth_rx: support telemetry") +Cc: stable@dpdk.org + +Signed-off-by: David Marchand +Acked-by: Jay Jayatheerthan +--- + lib/eventdev/rte_event_eth_rx_adapter.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c +index 3182b52c23..6f160b03c2 100644 +--- a/lib/eventdev/rte_event_eth_rx_adapter.c ++++ b/lib/eventdev/rte_event_eth_rx_adapter.c +@@ -3276,7 +3276,7 @@ handle_rxa_stats_reset(const char *cmd __rte_unused, + { + uint8_t rx_adapter_id; + +- if (params == NULL || strlen(params) == 0 || ~isdigit(*params)) ++ if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + /* Get Rx adapter ID from parameter string */ +-- +2.23.0 + diff --git a/0267-test-telemetry_data-refactor-for-maintainability.patch b/0267-test-telemetry_data-refactor-for-maintainability.patch new file mode 100644 index 0000000..af4da8e --- /dev/null +++ b/0267-test-telemetry_data-refactor-for-maintainability.patch @@ -0,0 +1,369 @@ +From 9e0c047add440fb5fbe84ef5131d5574f7cdcf37 Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 9 Sep 2022 10:35:20 +0100 +Subject: test/telemetry_data: refactor for maintainability +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 1306df2cd1d9ae654c2e5b3b0f40ca19ab440006 ] + +To help with the writing and maintaining of test cases in this file we +can make the following changes to it: + +- rename non-test-case functions i.e. the infrastructure functions, to + not start with "test_", so that each sub-test case can be identified + by starting with that prefix. +- add a comment at the start of the file explaining how tests are to be + written and managed, so as to keep consistency. +- add a trivial test-case for returning a simple string value to use as + a reference example for those wanting to add test cases. +- improve the key macro used for validating the output from each + function, so that the standard json preamble can be skipped for each + function. This hides more of the infrastructure implementation from + the user i.e. they don't need to worry what the actual command used is + called, and also shortens the output strings so we can avoid line + splitting in most cases. +- add clearing the "response_data" structure to the loop calling each + test to avoid each test function having to do so individually. + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + app/test/test_telemetry_data.c | 101 ++++++++++++++++++++------------- + 1 file changed, 60 insertions(+), 41 deletions(-) + +diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c +index 18b93db8ef..75aca8791f 100644 +--- a/app/test/test_telemetry_data.c ++++ b/app/test/test_telemetry_data.c +@@ -19,18 +19,45 @@ + #define TELEMETRY_VERSION "v2" + #define REQUEST_CMD "/test" + #define BUF_SIZE 1024 +-#define TEST_OUTPUT(exp) test_output(__func__, exp) ++#define CHECK_OUTPUT(exp) check_output(__func__, "{\"" REQUEST_CMD "\":" exp "}") ++ ++/* ++ * Runs a series of test cases, checking the output of telemetry for various different types of ++ * responses. On init, a single connection to DPDK telemetry is made, and a single telemetry ++ * callback "/test" is registered. That callback always returns the value of the static global ++ * variable "response_data", so each test case builds up that structure, and then calls the ++ * "check_output" function to ensure the response received over the socket for "/test" matches ++ * that expected for the response_data value populated. ++ * ++ * NOTE: ++ * - each test case function in this file should be added to the "test_cases" array in ++ * test_telemetry_data function at the bottom of the file. ++ * - each test case function should populate the "response_data" global variable (below) ++ * with the appropriate values which would be returned from a simulated telemetry function. ++ * Then the test case function should have "return CHECK_OUTPUT();" as it's ++ * last line. The test infrastructure will then validate that the output when returning ++ * "response_data" structure matches that in "". ++ * - the response_data structure will be zeroed on entry to each test function, so each function ++ * can begin with a call to "rte_tel_data_string/start_array/start_dict" as so desired. ++ * - the expected_output for each function can be just the actual json data from the ++ * "response_data" value. The CHECK_OUTPUT macro will include the appropriate "{\"/test\": ... }" ++ * structure around the json output. ++ * ++ * See test_simple_string(), or test_case_array_int() for a basic examples of test cases. ++ */ ++ + + static struct rte_tel_data response_data; + static int sock; + ++ + /* + * This function is the callback registered with Telemetry to be used when + * the /test command is requested. This callback returns the global data built + * up by the individual test cases. + */ + static int +-test_cb(const char *cmd __rte_unused, const char *params __rte_unused, ++telemetry_test_cb(const char *cmd __rte_unused, const char *params __rte_unused, + struct rte_tel_data *d) + { + *d = response_data; +@@ -44,7 +71,7 @@ test_cb(const char *cmd __rte_unused, const char *params __rte_unused, + * and is compared to the actual response received from Telemetry. + */ + static int +-test_output(const char *func_name, const char *expected) ++check_output(const char *func_name, const char *expected) + { + int bytes; + char buf[BUF_SIZE * 16]; +@@ -64,6 +91,14 @@ test_output(const char *func_name, const char *expected) + return strncmp(expected, buf, sizeof(buf)); + } + ++static int ++test_simple_string(void) ++{ ++ rte_tel_data_string(&response_data, "Simple string"); ++ ++ return CHECK_OUTPUT("\"Simple string\""); ++} ++ + static int + test_dict_with_array_int_values(void) + { +@@ -75,7 +110,6 @@ test_dict_with_array_int_values(void) + struct rte_tel_data *child_data2 = rte_tel_data_alloc(); + rte_tel_data_start_array(child_data2, RTE_TEL_INT_VAL); + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_dict(&response_data); + + for (i = 0; i < 5; i++) { +@@ -88,8 +122,7 @@ test_dict_with_array_int_values(void) + rte_tel_data_add_dict_container(&response_data, "dict_1", + child_data2, 0); + +- return TEST_OUTPUT("{\"/test\":{\"dict_0\":[0,1,2,3,4]," +- "\"dict_1\":[0,1,2,3,4]}}"); ++ return CHECK_OUTPUT("{\"dict_0\":[0,1,2,3,4],\"dict_1\":[0,1,2,3,4]}"); + } + + static int +@@ -103,7 +136,6 @@ test_array_with_array_int_values(void) + struct rte_tel_data *child_data2 = rte_tel_data_alloc(); + rte_tel_data_start_array(child_data2, RTE_TEL_INT_VAL); + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER); + + for (i = 0; i < 5; i++) { +@@ -113,18 +145,18 @@ test_array_with_array_int_values(void) + rte_tel_data_add_array_container(&response_data, child_data, 0); + rte_tel_data_add_array_container(&response_data, child_data2, 0); + +- return TEST_OUTPUT("{\"/test\":[[0,1,2,3,4],[0,1,2,3,4]]}"); ++ return CHECK_OUTPUT("[[0,1,2,3,4],[0,1,2,3,4]]"); + } + + static int + test_case_array_int(void) + { + int i; +- memset(&response_data, 0, sizeof(response_data)); ++ + rte_tel_data_start_array(&response_data, RTE_TEL_INT_VAL); + for (i = 0; i < 5; i++) + rte_tel_data_add_array_int(&response_data, i); +- return TEST_OUTPUT("{\"/test\":[0,1,2,3,4]}"); ++ return CHECK_OUTPUT("[0,1,2,3,4]"); + } + + static int +@@ -133,7 +165,6 @@ test_case_add_dict_int(void) + int i = 0; + char name_of_value[8]; + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_dict(&response_data); + + for (i = 0; i < 5; i++) { +@@ -141,14 +172,12 @@ test_case_add_dict_int(void) + rte_tel_data_add_dict_int(&response_data, name_of_value, i); + } + +- return TEST_OUTPUT("{\"/test\":{\"dict_0\":0,\"dict_1\":1,\"dict_2\":2," +- "\"dict_3\":3,\"dict_4\":4}}"); ++ return CHECK_OUTPUT("{\"dict_0\":0,\"dict_1\":1,\"dict_2\":2,\"dict_3\":3,\"dict_4\":4}"); + } + + static int + test_case_array_string(void) + { +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_array(&response_data, RTE_TEL_STRING_VAL); + rte_tel_data_add_array_string(&response_data, "aaaa"); + rte_tel_data_add_array_string(&response_data, "bbbb"); +@@ -156,14 +185,12 @@ test_case_array_string(void) + rte_tel_data_add_array_string(&response_data, "dddd"); + rte_tel_data_add_array_string(&response_data, "eeee"); + +- return TEST_OUTPUT("{\"/test\":[\"aaaa\",\"bbbb\",\"cccc\",\"dddd\"," +- "\"eeee\"]}"); ++ return CHECK_OUTPUT("[\"aaaa\",\"bbbb\",\"cccc\",\"dddd\",\"eeee\"]"); + } + + static int + test_case_add_dict_string(void) + { +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_dict(&response_data); + + rte_tel_data_add_dict_string(&response_data, "dict_0", "aaaa"); +@@ -171,8 +198,7 @@ test_case_add_dict_string(void) + rte_tel_data_add_dict_string(&response_data, "dict_2", "cccc"); + rte_tel_data_add_dict_string(&response_data, "dict_3", "dddd"); + +- return TEST_OUTPUT("{\"/test\":{\"dict_0\":\"aaaa\",\"dict_1\":" +- "\"bbbb\",\"dict_2\":\"cccc\",\"dict_3\":\"dddd\"}}"); ++ return CHECK_OUTPUT("{\"dict_0\":\"aaaa\",\"dict_1\":\"bbbb\",\"dict_2\":\"cccc\",\"dict_3\":\"dddd\"}"); + } + + +@@ -185,7 +211,6 @@ test_dict_with_array_string_values(void) + struct rte_tel_data *child_data2 = rte_tel_data_alloc(); + rte_tel_data_start_array(child_data2, RTE_TEL_STRING_VAL); + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_dict(&response_data); + + rte_tel_data_add_array_string(child_data, "aaaa"); +@@ -196,8 +221,7 @@ test_dict_with_array_string_values(void) + rte_tel_data_add_dict_container(&response_data, "dict_1", + child_data2, 0); + +- return TEST_OUTPUT("{\"/test\":{\"dict_0\":[\"aaaa\"],\"dict_1\":" +- "[\"bbbb\"]}}"); ++ return CHECK_OUTPUT("{\"dict_0\":[\"aaaa\"],\"dict_1\":[\"bbbb\"]}"); + } + + static int +@@ -212,7 +236,6 @@ test_dict_with_dict_values(void) + struct rte_tel_data *child_data2 = rte_tel_data_alloc(); + rte_tel_data_start_array(child_data2, RTE_TEL_STRING_VAL); + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_dict(&response_data); + + rte_tel_data_add_array_string(child_data, "aaaa"); +@@ -224,8 +247,7 @@ test_dict_with_dict_values(void) + rte_tel_data_add_dict_container(&response_data, "dict_of_dicts", + dict_of_dicts, 0); + +- return TEST_OUTPUT("{\"/test\":{\"dict_of_dicts\":{\"dict_0\":" +- "[\"aaaa\"],\"dict_1\":[\"bbbb\"]}}}"); ++ return CHECK_OUTPUT("{\"dict_of_dicts\":{\"dict_0\":[\"aaaa\"],\"dict_1\":[\"bbbb\"]}}"); + } + + static int +@@ -237,7 +259,6 @@ test_array_with_array_string_values(void) + struct rte_tel_data *child_data2 = rte_tel_data_alloc(); + rte_tel_data_start_array(child_data2, RTE_TEL_STRING_VAL); + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER); + + rte_tel_data_add_array_string(child_data, "aaaa"); +@@ -246,18 +267,18 @@ test_array_with_array_string_values(void) + rte_tel_data_add_array_container(&response_data, child_data, 0); + rte_tel_data_add_array_container(&response_data, child_data2, 0); + +- return TEST_OUTPUT("{\"/test\":[[\"aaaa\"],[\"bbbb\"]]}"); ++ return CHECK_OUTPUT("[[\"aaaa\"],[\"bbbb\"]]"); + } + + static int + test_case_array_u64(void) + { + int i; +- memset(&response_data, 0, sizeof(response_data)); ++ + rte_tel_data_start_array(&response_data, RTE_TEL_U64_VAL); + for (i = 0; i < 5; i++) + rte_tel_data_add_array_u64(&response_data, i); +- return TEST_OUTPUT("{\"/test\":[0,1,2,3,4]}"); ++ return CHECK_OUTPUT("[0,1,2,3,4]"); + } + + static int +@@ -266,15 +287,13 @@ test_case_add_dict_u64(void) + int i = 0; + char name_of_value[8]; + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_dict(&response_data); + + for (i = 0; i < 5; i++) { + sprintf(name_of_value, "dict_%d", i); + rte_tel_data_add_dict_u64(&response_data, name_of_value, i); + } +- return TEST_OUTPUT("{\"/test\":{\"dict_0\":0,\"dict_1\":1,\"dict_2\":2," +- "\"dict_3\":3,\"dict_4\":4}}"); ++ return CHECK_OUTPUT("{\"dict_0\":0,\"dict_1\":1,\"dict_2\":2,\"dict_3\":3,\"dict_4\":4}"); + } + + static int +@@ -288,7 +307,6 @@ test_dict_with_array_u64_values(void) + struct rte_tel_data *child_data2 = rte_tel_data_alloc(); + rte_tel_data_start_array(child_data2, RTE_TEL_U64_VAL); + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_dict(&response_data); + + for (i = 0; i < 10; i++) { +@@ -301,8 +319,7 @@ test_dict_with_array_u64_values(void) + rte_tel_data_add_dict_container(&response_data, "dict_1", + child_data2, 0); + +- return TEST_OUTPUT("{\"/test\":{\"dict_0\":[0,1,2,3,4,5,6,7,8,9]," +- "\"dict_1\":[0,1,2,3,4,5,6,7,8,9]}}"); ++ return CHECK_OUTPUT("{\"dict_0\":[0,1,2,3,4,5,6,7,8,9],\"dict_1\":[0,1,2,3,4,5,6,7,8,9]}"); + } + + static int +@@ -316,7 +333,6 @@ test_array_with_array_u64_values(void) + struct rte_tel_data *child_data2 = rte_tel_data_alloc(); + rte_tel_data_start_array(child_data2, RTE_TEL_U64_VAL); + +- memset(&response_data, 0, sizeof(response_data)); + rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER); + + for (i = 0; i < 5; i++) { +@@ -326,7 +342,7 @@ test_array_with_array_u64_values(void) + rte_tel_data_add_array_container(&response_data, child_data, 0); + rte_tel_data_add_array_container(&response_data, child_data2, 0); + +- return TEST_OUTPUT("{\"/test\":[[0,1,2,3,4],[0,1,2,3,4]]}"); ++ return CHECK_OUTPUT("[[0,1,2,3,4],[0,1,2,3,4]]"); + } + + static int +@@ -367,7 +383,7 @@ connect_to_socket(void) + } + + static int +-test_telemetry_data(void) ++telemetry_data_autotest(void) + { + typedef int (*test_case)(void); + unsigned int i = 0; +@@ -376,7 +392,9 @@ test_telemetry_data(void) + if (sock <= 0) + return -1; + +- test_case test_cases[] = {test_case_array_string, ++ test_case test_cases[] = { ++ test_simple_string, ++ test_case_array_string, + test_case_array_int, test_case_array_u64, + test_case_add_dict_int, test_case_add_dict_u64, + test_case_add_dict_string, +@@ -388,8 +406,9 @@ test_telemetry_data(void) + test_array_with_array_u64_values, + test_array_with_array_string_values }; + +- rte_telemetry_register_cmd(REQUEST_CMD, test_cb, "Test"); ++ rte_telemetry_register_cmd(REQUEST_CMD, telemetry_test_cb, "Test"); + for (i = 0; i < RTE_DIM(test_cases); i++) { ++ memset(&response_data, 0, sizeof(response_data)); + if (test_cases[i]() != 0) { + close(sock); + return -1; +@@ -399,4 +418,4 @@ test_telemetry_data(void) + return 0; + } + +-REGISTER_TEST_COMMAND(telemetry_data_autotest, test_telemetry_data); ++REGISTER_TEST_COMMAND(telemetry_data_autotest, telemetry_data_autotest); +-- +2.23.0 + diff --git a/0268-test-telemetry_data-add-test-cases-for-character-esc.patch b/0268-test-telemetry_data-add-test-cases-for-character-esc.patch new file mode 100644 index 0000000..c8e1d13 --- /dev/null +++ b/0268-test-telemetry_data-add-test-cases-for-character-esc.patch @@ -0,0 +1,74 @@ +From 9da99d5eaf004c1ea202753c4618dcaa48744ba3 Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Fri, 9 Sep 2022 10:35:21 +0100 +Subject: test/telemetry_data: add test cases for character escaping +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit d0049f7a2c1654ffe704d7c1803db0402e49a2a7 ] + +Add in some basic unit tests to validate the character escaping being +done on string data values, which tests end-to-end processing of those +values beyond just the json-encoding steps tested by the +"telemetry_json_autotest". + +Signed-off-by: Bruce Richardson +Acked-by: Ciara Power +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + app/test/test_telemetry_data.c | 30 +++++++++++++++++++++++++++++- + 1 file changed, 29 insertions(+), 1 deletion(-) + +diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c +index 75aca8791f..79ec48063f 100644 +--- a/app/test/test_telemetry_data.c ++++ b/app/test/test_telemetry_data.c +@@ -345,6 +345,30 @@ test_array_with_array_u64_values(void) + return CHECK_OUTPUT("[[0,1,2,3,4],[0,1,2,3,4]]"); + } + ++static int ++test_string_char_escaping(void) ++{ ++ rte_tel_data_string(&response_data, "hello,\nworld\n"); ++ return CHECK_OUTPUT("\"hello,\\nworld\\n\""); ++} ++ ++static int ++test_array_char_escaping(void) ++{ ++ rte_tel_data_start_array(&response_data, RTE_TEL_STRING_VAL); ++ rte_tel_data_add_array_string(&response_data, "\\escape\r"); ++ rte_tel_data_add_array_string(&response_data, "characters\n"); ++ return CHECK_OUTPUT("[\"\\\\escape\\r\",\"characters\\n\"]"); ++} ++ ++static int ++test_dict_char_escaping(void) ++{ ++ rte_tel_data_start_dict(&response_data); ++ rte_tel_data_add_dict_string(&response_data, "name", "escaped\n\tvalue"); ++ return CHECK_OUTPUT("{\"name\":\"escaped\\n\\tvalue\"}"); ++} ++ + static int + connect_to_socket(void) + { +@@ -404,7 +428,11 @@ telemetry_data_autotest(void) + test_dict_with_dict_values, + test_array_with_array_int_values, + test_array_with_array_u64_values, +- test_array_with_array_string_values }; ++ test_array_with_array_string_values, ++ test_string_char_escaping, ++ test_array_char_escaping, ++ test_dict_char_escaping, ++ }; + + rte_telemetry_register_cmd(REQUEST_CMD, telemetry_test_cb, "Test"); + for (i = 0; i < RTE_DIM(test_cases); i++) { +-- +2.23.0 + diff --git a/0269-usertools-telemetry-add-JSON-pretty-print.patch b/0269-usertools-telemetry-add-JSON-pretty-print.patch new file mode 100644 index 0000000..33fa7f7 --- /dev/null +++ b/0269-usertools-telemetry-add-JSON-pretty-print.patch @@ -0,0 +1,87 @@ +From dccf49c20f2be4f9b92a635117dc06c9d17be545 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Mon, 17 Oct 2022 07:41:02 +0000 +Subject: usertools/telemetry: add JSON pretty print + +[ upstream commit 66542840dfd184c06813e6740664b280ef77d4e0 ] + +Currently, the dpdk-telemetry.py show JSON in raw format under +interactive mode, which is not good for human reading. + +E.g. The command '/ethdev/xstats,0' will output: +{"/ethdev/xstats": {"rx_good_packets": 0, "tx_good_packets": 0, +"rx_good_bytes": 0, "tx_good_bytes": 0, "rx_missed_errors": 0, +"rx_errors": 0, "tx_errors": 0, "rx_mbuf_allocation_errors": 0, +"rx_q0_packets": 0,...}} + +This patch supports JSON pretty print by adding extra indent=2 +parameter under interactive mode, so the same command will output: +{ + "/ethdev/xstats": { + "rx_good_packets": 0, + "tx_good_packets": 0, + "rx_good_bytes": 0, + "tx_good_bytes": 0, + "rx_missed_errors": 0, + "rx_errors": 0, + "rx_mbuf_allocation_errors": 0, + "rx_q0_packets": 0, + ... + } +} + +Note: the non-interactive mode is made machine-readable and remains the +original way (it means don't use indent to pretty print). + +Signed-off-by: Chengwen Feng +Acked-by: David Marchand +Acked-by: Ciara Power +Tested-by: Bruce Richardson +--- + usertools/dpdk-telemetry.py | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py +index 5b3bf83356..e36b0af811 100755 +--- a/usertools/dpdk-telemetry.py ++++ b/usertools/dpdk-telemetry.py +@@ -23,7 +23,7 @@ + CMDS = [] + + +-def read_socket(sock, buf_len, echo=True): ++def read_socket(sock, buf_len, echo=True, pretty=False): + """ Read data from socket and return it in JSON format """ + reply = sock.recv(buf_len).decode() + try: +@@ -33,7 +33,8 @@ def read_socket(sock, buf_len, echo=True): + sock.close() + raise + if echo: +- print(json.dumps(ret)) ++ indent = 2 if pretty else None ++ print(json.dumps(ret, indent=indent)) + return ret + + +@@ -123,7 +124,7 @@ def handle_socket(args, path): + else: + list_fp() + return +- json_reply = read_socket(sock, 1024, prompt) ++ json_reply = read_socket(sock, 1024, prompt, prompt) + output_buf_len = json_reply["max_output_len"] + app_name = get_app_name(json_reply["pid"]) + if app_name and prompt: +@@ -139,7 +140,7 @@ def handle_socket(args, path): + while text != "quit": + if text.startswith('/'): + sock.send(text.encode()) +- read_socket(sock, output_buf_len) ++ read_socket(sock, output_buf_len, pretty=prompt) + text = input(prompt).strip() + except EOFError: + pass +-- +2.23.0 + diff --git a/0270-telemetry-move-include-after-guard.patch b/0270-telemetry-move-include-after-guard.patch new file mode 100644 index 0000000..cb718cc --- /dev/null +++ b/0270-telemetry-move-include-after-guard.patch @@ -0,0 +1,52 @@ +From 46fdcb394e83402924e6fdcf2d6da2873570d2f4 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 19 Dec 2022 15:06:41 +0800 +Subject: telemetry: move include after guard +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit f7b74387be1de6803716262d7988794accd6d39f ] + +The "stdint.h" header is outside '_RTE_TELEMETRY_H_' macro, which cause +this header is unconditional. So this patch moves this header to inside +'_RTE_TELEMETRY_H_'. + +Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +Acked-by: Bruce Richardson +--- + lib/telemetry/rte_telemetry.h | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h +index fadea48cb9..08d7f18dff 100644 +--- a/lib/telemetry/rte_telemetry.h ++++ b/lib/telemetry/rte_telemetry.h +@@ -2,10 +2,6 @@ + * Copyright(c) 2018 Intel Corporation + */ + +-#include +- +-#include +- + #ifndef _RTE_TELEMETRY_H_ + #define _RTE_TELEMETRY_H_ + +@@ -13,6 +9,8 @@ + extern "C" { + #endif + ++#include ++ + /** Maximum length for string used in object. */ + #define RTE_TEL_MAX_STRING_LEN 128 + /** Maximum length of string. */ +-- +2.23.0 + diff --git a/0271-ethdev-fix-telemetry-data-truncation.patch b/0271-ethdev-fix-telemetry-data-truncation.patch new file mode 100644 index 0000000..43748bd --- /dev/null +++ b/0271-ethdev-fix-telemetry-data-truncation.patch @@ -0,0 +1,59 @@ +From f4f89120a7df52f92fcac89e3fe13cfac1097051 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 19 Dec 2022 15:06:42 +0800 +Subject: ethdev: fix telemetry data truncation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 7db3f2af573287abb9201d46a92b4ca3ebc5d9ad ] + +The 'u32' and 'u64' data can not assigned to 'int' type variable. +They need to use the 'u64' APIs to add. + +Fixes: 58b43c1ddfd1 ("ethdev: add telemetry endpoint for device info") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/ethdev/rte_ethdev.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index d82819a458..c216091e79 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6397,9 +6397,9 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, + eth_dev->data->nb_tx_queues); + rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id); + rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu); +- rte_tel_data_add_dict_int(d, "rx_mbuf_size_min", ++ rte_tel_data_add_dict_u64(d, "rx_mbuf_size_min", + eth_dev->data->min_rx_buf_size); +- rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail", ++ rte_tel_data_add_dict_u64(d, "rx_mbuf_alloc_fail", + eth_dev->data->rx_mbuf_alloc_failed); + rte_ether_format_addr(mac_addr, sizeof(mac_addr), + eth_dev->data->mac_addrs); +@@ -6428,12 +6428,12 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, + rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0); + rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0); + rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node); +- rte_tel_data_add_dict_int(d, "dev_flags", eth_dev->data->dev_flags); +- rte_tel_data_add_dict_int(d, "rx_offloads", ++ rte_tel_data_add_dict_u64(d, "dev_flags", eth_dev->data->dev_flags); ++ rte_tel_data_add_dict_u64(d, "rx_offloads", + eth_dev->data->dev_conf.rxmode.offloads); +- rte_tel_data_add_dict_int(d, "tx_offloads", ++ rte_tel_data_add_dict_u64(d, "tx_offloads", + eth_dev->data->dev_conf.txmode.offloads); +- rte_tel_data_add_dict_int(d, "ethdev_rss_hf", ++ rte_tel_data_add_dict_u64(d, "ethdev_rss_hf", + eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf); + + return 0; +-- +2.23.0 + diff --git a/0272-mempool-fix-telemetry-data-truncation.patch b/0272-mempool-fix-telemetry-data-truncation.patch new file mode 100644 index 0000000..00e8a61 --- /dev/null +++ b/0272-mempool-fix-telemetry-data-truncation.patch @@ -0,0 +1,70 @@ +From 2d3ca311972da8c7d4770697e62e6a4812665c5b Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 19 Dec 2022 15:06:43 +0800 +Subject: mempool: fix telemetry data truncation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 4eebfcf70a21b2b608e3bb9f20b5ee23338172ec ] + +The 'u32' and 'u64' data can not assigned to 'int' type variable. +They need to use the 'u64' APIs to add. + +Fixes: 2f5c4025abb3 ("mempool: add telemetry endpoint") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/mempool/rte_mempool.c | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c +index c5a699b1d6..871f4d1fe3 100644 +--- a/lib/mempool/rte_mempool.c ++++ b/lib/mempool/rte_mempool.c +@@ -1517,27 +1517,27 @@ mempool_info_cb(struct rte_mempool *mp, void *arg) + return; + + rte_tel_data_add_dict_string(info->d, "name", mp->name); +- rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id); +- rte_tel_data_add_dict_int(info->d, "flags", mp->flags); ++ rte_tel_data_add_dict_u64(info->d, "pool_id", mp->pool_id); ++ rte_tel_data_add_dict_u64(info->d, "flags", mp->flags); + rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id); +- rte_tel_data_add_dict_int(info->d, "size", mp->size); +- rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size); +- rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size); +- rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size); +- rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size); +- rte_tel_data_add_dict_int(info->d, "private_data_size", ++ rte_tel_data_add_dict_u64(info->d, "size", mp->size); ++ rte_tel_data_add_dict_u64(info->d, "cache_size", mp->cache_size); ++ rte_tel_data_add_dict_u64(info->d, "elt_size", mp->elt_size); ++ rte_tel_data_add_dict_u64(info->d, "header_size", mp->header_size); ++ rte_tel_data_add_dict_u64(info->d, "trailer_size", mp->trailer_size); ++ rte_tel_data_add_dict_u64(info->d, "private_data_size", + mp->private_data_size); + rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index); +- rte_tel_data_add_dict_int(info->d, "populated_size", ++ rte_tel_data_add_dict_u64(info->d, "populated_size", + mp->populated_size); + + mz = mp->mz; + rte_tel_data_add_dict_string(info->d, "mz_name", mz->name); +- rte_tel_data_add_dict_int(info->d, "mz_len", mz->len); +- rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz", ++ rte_tel_data_add_dict_u64(info->d, "mz_len", mz->len); ++ rte_tel_data_add_dict_u64(info->d, "mz_hugepage_sz", + mz->hugepage_sz); + rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id); +- rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags); ++ rte_tel_data_add_dict_u64(info->d, "mz_flags", mz->flags); + } + + static int +-- +2.23.0 + diff --git a/0273-cryptodev-fix-telemetry-data-truncation.patch b/0273-cryptodev-fix-telemetry-data-truncation.patch new file mode 100644 index 0000000..df68d0c --- /dev/null +++ b/0273-cryptodev-fix-telemetry-data-truncation.patch @@ -0,0 +1,39 @@ +From 5af68a4b3406c0477a2a0c33c546795d6be7f6a5 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 19 Dec 2022 15:06:44 +0800 +Subject: cryptodev: fix telemetry data truncation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 45038f04ab577db8844ef54d7f523119be6c205f ] + +The 'u32' data can not assigned to 'int' type variable. The 'u32' data +needs to use the 'u64' APIs to add. + +Fixes: d3d98f5ce9d0 ("cryptodev: support telemetry") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/cryptodev/rte_cryptodev.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c +index a40536c5ea..23e079d639 100644 +--- a/lib/cryptodev/rte_cryptodev.c ++++ b/lib/cryptodev/rte_cryptodev.c +@@ -2472,7 +2472,7 @@ cryptodev_handle_dev_info(const char *cmd __rte_unused, + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_string(d, "device_name", + cryptodev_info.device->name); +- rte_tel_data_add_dict_int(d, "max_nb_queue_pairs", ++ rte_tel_data_add_dict_u64(d, "max_nb_queue_pairs", + cryptodev_info.max_nb_queue_pairs); + + return 0; +-- +2.23.0 + diff --git a/0274-mem-fix-telemetry-data-truncation.patch b/0274-mem-fix-telemetry-data-truncation.patch new file mode 100644 index 0000000..0dec824 --- /dev/null +++ b/0274-mem-fix-telemetry-data-truncation.patch @@ -0,0 +1,65 @@ +From ecdcf5720497371f360dde918df83dbc56f32284 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 19 Dec 2022 15:06:45 +0800 +Subject: mem: fix telemetry data truncation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 6243e36b837b754c33017718cf79f7574a52b09c ] + +The 'u32' and 'u64' data can not assigned to 'int' type variable. +They need to use the 'u64' APIs to add. + +Fixes: e6732d0d6e26 ("mem: add telemetry infos") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/eal/common/eal_common_memory.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c +index 69dea8f72b..f2f8858e22 100644 +--- a/lib/eal/common/eal_common_memory.c ++++ b/lib/eal/common/eal_common_memory.c +@@ -1191,7 +1191,7 @@ handle_eal_heap_info_request(const char *cmd __rte_unused, const char *params, + malloc_heap_get_stats(heap, &sock_stats); + + rte_tel_data_start_dict(d); +- rte_tel_data_add_dict_int(d, "Head id", heap_id); ++ rte_tel_data_add_dict_u64(d, "Head id", heap_id); + rte_tel_data_add_dict_string(d, "Name", heap->name); + rte_tel_data_add_dict_u64(d, "Heap_size", + sock_stats.heap_totalsz_bytes); +@@ -1253,13 +1253,13 @@ handle_eal_memzone_info_request(const char *cmd __rte_unused, + mz = rte_fbarray_get(&mcfg->memzones, mz_idx); + + rte_tel_data_start_dict(d); +- rte_tel_data_add_dict_int(d, "Zone", mz_idx); ++ rte_tel_data_add_dict_u64(d, "Zone", mz_idx); + rte_tel_data_add_dict_string(d, "Name", mz->name); +- rte_tel_data_add_dict_int(d, "Length", mz->len); ++ rte_tel_data_add_dict_u64(d, "Length", mz->len); + snprintf(addr, ADDR_STR, "%p", mz->addr); + rte_tel_data_add_dict_string(d, "Address", addr); + rte_tel_data_add_dict_int(d, "Socket", mz->socket_id); +- rte_tel_data_add_dict_int(d, "Flags", mz->flags); ++ rte_tel_data_add_dict_u64(d, "Flags", mz->flags); + + /* go through each page occupied by this memzone */ + msl = rte_mem_virt2memseg_list(mz->addr); +@@ -1274,7 +1274,7 @@ handle_eal_memzone_info_request(const char *cmd __rte_unused, + ms_idx = RTE_PTR_DIFF(mz->addr, msl->base_va) / page_sz; + ms = rte_fbarray_get(&msl->memseg_arr, ms_idx); + +- rte_tel_data_add_dict_int(d, "Hugepage_size", page_sz); ++ rte_tel_data_add_dict_u64(d, "Hugepage_size", page_sz); + snprintf(addr, ADDR_STR, "%p", ms->addr); + rte_tel_data_add_dict_string(d, "Hugepage_base", addr); + +-- +2.23.0 + diff --git a/0275-telemetry-support-adding-integer-as-hexadecimal.patch b/0275-telemetry-support-adding-integer-as-hexadecimal.patch new file mode 100644 index 0000000..8eea185 --- /dev/null +++ b/0275-telemetry-support-adding-integer-as-hexadecimal.patch @@ -0,0 +1,426 @@ +From cec570b800d47867e900c30761c7b50018184bbf Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 19 Dec 2022 15:06:46 +0800 +Subject: telemetry: support adding integer as hexadecimal +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 82c33481c6abdec2fc58f1199ca6202e7400c08d ] + +Sometimes displaying an unsigned integer value as hexadecimal encoded style +is more expected for human consumption, such as, offload capability and +device flag. This patch introduces two APIs to add unsigned integer value +as hexadecimal encoded string to array or dictionary. And user can choose +whether the stored value is padded to the specified width. + +Signed-off-by: Huisong Li +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +Acked-by: Bruce Richardson +--- + app/test/test_telemetry_data.c | 150 +++++++++++++++++++++++++++++++++ + lib/telemetry/rte_telemetry.h | 47 +++++++++++ + lib/telemetry/telemetry_data.c | 74 ++++++++++++++++ + lib/telemetry/version.map | 10 +++ + 4 files changed, 281 insertions(+) + +diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c +index 79ec48063f..7d9be376a6 100644 +--- a/app/test/test_telemetry_data.c ++++ b/app/test/test_telemetry_data.c +@@ -201,6 +201,39 @@ test_case_add_dict_string(void) + return CHECK_OUTPUT("{\"dict_0\":\"aaaa\",\"dict_1\":\"bbbb\",\"dict_2\":\"cccc\",\"dict_3\":\"dddd\"}"); + } + ++static int ++test_case_add_dict_uint_hex_padding(void) ++{ ++ rte_tel_data_start_dict(&response_data); ++ ++ rte_tel_data_add_dict_uint_hex(&response_data, "dict_0", ++ (uint8_t)0x8, 8); ++ rte_tel_data_add_dict_uint_hex(&response_data, "dict_1", ++ (uint16_t)0x88, 16); ++ rte_tel_data_add_dict_uint_hex(&response_data, "dict_2", ++ (uint32_t)0x888, 32); ++ rte_tel_data_add_dict_uint_hex(&response_data, "dict_3", ++ (uint64_t)0x8888, 64); ++ ++ return CHECK_OUTPUT("{\"dict_0\":\"0x08\",\"dict_1\":\"0x0088\",\"dict_2\":\"0x00000888\",\"dict_3\":\"0x0000000000008888\"}"); ++} ++ ++static int ++test_case_add_dict_uint_hex_nopadding(void) ++{ ++ rte_tel_data_start_dict(&response_data); ++ ++ rte_tel_data_add_dict_uint_hex(&response_data, "dict_0", ++ (uint8_t)0x8, 0); ++ rte_tel_data_add_dict_uint_hex(&response_data, "dict_1", ++ (uint16_t)0x88, 0); ++ rte_tel_data_add_dict_uint_hex(&response_data, "dict_2", ++ (uint32_t)0x888, 0); ++ rte_tel_data_add_dict_uint_hex(&response_data, "dict_3", ++ (uint64_t)0x8888, 0); ++ ++ return CHECK_OUTPUT("{\"dict_0\":\"0x8\",\"dict_1\":\"0x88\",\"dict_2\":\"0x888\",\"dict_3\":\"0x8888\"}"); ++} + + static int + test_dict_with_array_string_values(void) +@@ -224,6 +257,50 @@ test_dict_with_array_string_values(void) + return CHECK_OUTPUT("{\"dict_0\":[\"aaaa\"],\"dict_1\":[\"bbbb\"]}"); + } + ++static int ++test_dict_with_array_uint_hex_values_padding(void) ++{ ++ struct rte_tel_data *child_data = rte_tel_data_alloc(); ++ rte_tel_data_start_array(child_data, RTE_TEL_STRING_VAL); ++ ++ struct rte_tel_data *child_data2 = rte_tel_data_alloc(); ++ rte_tel_data_start_array(child_data2, RTE_TEL_STRING_VAL); ++ ++ rte_tel_data_start_dict(&response_data); ++ ++ rte_tel_data_add_array_uint_hex(child_data, (uint32_t)0x888, 32); ++ rte_tel_data_add_array_uint_hex(child_data2, (uint64_t)0x8888, 64); ++ ++ rte_tel_data_add_dict_container(&response_data, "dict_0", ++ child_data, 0); ++ rte_tel_data_add_dict_container(&response_data, "dict_1", ++ child_data2, 0); ++ ++ return CHECK_OUTPUT("{\"dict_0\":[\"0x00000888\"],\"dict_1\":[\"0x0000000000008888\"]}"); ++} ++ ++static int ++test_dict_with_array_uint_hex_values_nopadding(void) ++{ ++ struct rte_tel_data *child_data = rte_tel_data_alloc(); ++ rte_tel_data_start_array(child_data, RTE_TEL_STRING_VAL); ++ ++ struct rte_tel_data *child_data2 = rte_tel_data_alloc(); ++ rte_tel_data_start_array(child_data2, RTE_TEL_STRING_VAL); ++ ++ rte_tel_data_start_dict(&response_data); ++ ++ rte_tel_data_add_array_uint_hex(child_data, (uint32_t)0x888, 0); ++ rte_tel_data_add_array_uint_hex(child_data2, (uint64_t)0x8888, 0); ++ ++ rte_tel_data_add_dict_container(&response_data, "dict_0", ++ child_data, 0); ++ rte_tel_data_add_dict_container(&response_data, "dict_1", ++ child_data2, 0); ++ ++ return CHECK_OUTPUT("{\"dict_0\":[\"0x888\"],\"dict_1\":[\"0x8888\"]}"); ++} ++ + static int + test_dict_with_dict_values(void) + { +@@ -270,6 +347,47 @@ test_array_with_array_string_values(void) + return CHECK_OUTPUT("[[\"aaaa\"],[\"bbbb\"]]"); + } + ++static int ++test_array_with_array_uint_hex_values_padding(void) ++{ ++ struct rte_tel_data *child_data = rte_tel_data_alloc(); ++ rte_tel_data_start_array(child_data, RTE_TEL_STRING_VAL); ++ ++ struct rte_tel_data *child_data2 = rte_tel_data_alloc(); ++ rte_tel_data_start_array(child_data2, RTE_TEL_STRING_VAL); ++ ++ rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER); ++ ++ rte_tel_data_add_array_uint_hex(child_data, (uint32_t)0x888, 32); ++ rte_tel_data_add_array_uint_hex(child_data2, (uint64_t)0x8888, 64); ++ ++ rte_tel_data_add_array_container(&response_data, child_data, 0); ++ rte_tel_data_add_array_container(&response_data, child_data2, 0); ++ ++ return CHECK_OUTPUT("[[\"0x00000888\"],[\"0x0000000000008888\"]]"); ++} ++ ++ ++static int ++test_array_with_array_uint_hex_values_nopadding(void) ++{ ++ struct rte_tel_data *child_data = rte_tel_data_alloc(); ++ rte_tel_data_start_array(child_data, RTE_TEL_STRING_VAL); ++ ++ struct rte_tel_data *child_data2 = rte_tel_data_alloc(); ++ rte_tel_data_start_array(child_data2, RTE_TEL_STRING_VAL); ++ ++ rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER); ++ ++ rte_tel_data_add_array_uint_hex(child_data, (uint32_t)0x888, 0); ++ rte_tel_data_add_array_uint_hex(child_data2, (uint64_t)0x8888, 0); ++ ++ rte_tel_data_add_array_container(&response_data, child_data, 0); ++ rte_tel_data_add_array_container(&response_data, child_data2, 0); ++ ++ return CHECK_OUTPUT("[[\"0x888\"],[\"0x8888\"]]"); ++} ++ + static int + test_case_array_u64(void) + { +@@ -281,6 +399,30 @@ test_case_array_u64(void) + return CHECK_OUTPUT("[0,1,2,3,4]"); + } + ++static int ++test_case_array_uint_hex_padding(void) ++{ ++ rte_tel_data_start_array(&response_data, RTE_TEL_STRING_VAL); ++ rte_tel_data_add_array_uint_hex(&response_data, (uint8_t)0x8, 8); ++ rte_tel_data_add_array_uint_hex(&response_data, (uint16_t)0x88, 16); ++ rte_tel_data_add_array_uint_hex(&response_data, (uint32_t)0x888, 32); ++ rte_tel_data_add_array_uint_hex(&response_data, (uint64_t)0x8888, 64); ++ ++ return CHECK_OUTPUT("[\"0x08\",\"0x0088\",\"0x00000888\",\"0x0000000000008888\"]"); ++} ++ ++static int ++test_case_array_uint_hex_nopadding(void) ++{ ++ rte_tel_data_start_array(&response_data, RTE_TEL_STRING_VAL); ++ rte_tel_data_add_array_uint_hex(&response_data, (uint8_t)0x8, 0); ++ rte_tel_data_add_array_uint_hex(&response_data, (uint16_t)0x88, 0); ++ rte_tel_data_add_array_uint_hex(&response_data, (uint32_t)0x888, 0); ++ rte_tel_data_add_array_uint_hex(&response_data, (uint64_t)0x8888, 0); ++ ++ return CHECK_OUTPUT("[\"0x8\",\"0x88\",\"0x888\",\"0x8888\"]"); ++} ++ + static int + test_case_add_dict_u64(void) + { +@@ -420,15 +562,23 @@ telemetry_data_autotest(void) + test_simple_string, + test_case_array_string, + test_case_array_int, test_case_array_u64, ++ test_case_array_uint_hex_padding, ++ test_case_array_uint_hex_nopadding, + test_case_add_dict_int, test_case_add_dict_u64, + test_case_add_dict_string, ++ test_case_add_dict_uint_hex_padding, ++ test_case_add_dict_uint_hex_nopadding, + test_dict_with_array_int_values, + test_dict_with_array_u64_values, + test_dict_with_array_string_values, ++ test_dict_with_array_uint_hex_values_padding, ++ test_dict_with_array_uint_hex_values_nopadding, + test_dict_with_dict_values, + test_array_with_array_int_values, + test_array_with_array_u64_values, + test_array_with_array_string_values, ++ test_array_with_array_uint_hex_values_padding, ++ test_array_with_array_uint_hex_values_nopadding, + test_string_char_escaping, + test_array_char_escaping, + test_dict_char_escaping, +diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h +index 08d7f18dff..5d5b75b683 100644 +--- a/lib/telemetry/rte_telemetry.h ++++ b/lib/telemetry/rte_telemetry.h +@@ -10,6 +10,7 @@ extern "C" { + #endif + + #include ++#include + + /** Maximum length for string used in object. */ + #define RTE_TEL_MAX_STRING_LEN 128 +@@ -153,6 +154,28 @@ int + rte_tel_data_add_array_container(struct rte_tel_data *d, + struct rte_tel_data *val, int keep); + ++/** ++ * Convert an unsigned integer to hexadecimal encoded strings ++ * and add this string to an array. ++ * The array must have been started by rte_tel_data_start_array() ++ * with RTE_TEL_STRING_VAL as the type parameter. ++ * ++ * @param d ++ * The data structure passed to the callback. ++ * @param val ++ * The number to be returned in the array as a hexadecimal encoded strings. ++ * @param display_bitwidth ++ * The display bit width of the 'val'. If 'display_bitwidth' is zero, the ++ * value is stored in the array as no-padding zero hexadecimal encoded string, ++ * or the value is stored as padding zero to specified hexadecimal width. ++ * @return ++ * 0 on success, negative errno on error. ++ */ ++__rte_experimental ++int ++rte_tel_data_add_array_uint_hex(struct rte_tel_data *d, uint64_t val, ++ uint8_t display_bitwidth); ++ + /** + * Add a string value to a dictionary. + * The dict must have been started by rte_tel_data_start_dict(). +@@ -231,6 +254,30 @@ int + rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name, + struct rte_tel_data *val, int keep); + ++/** ++ * Convert an unsigned integer to hexadecimal encoded strings ++ * and add this string to an dictionary. ++ * The dict must have been started by rte_tel_data_start_dict(). ++ * ++ * @param d ++ * The data structure passed to the callback. ++ * @param name ++ * The name of the value is to be stored in the dict. ++ * Must contain only alphanumeric characters or the symbols: '_' or '/'. ++ * @param val ++ * The number to be stored in the dict as a hexadecimal encoded strings. ++ * @param display_bitwidth ++ * The display bit width of the 'val'. If 'display_bitwidth' is zero, the ++ * value is stored in the array as no-padding zero hexadecimal encoded string, ++ * or the value is stored as padding zero to specified hexadecimal width. ++ * @return ++ * 0 on success, negative errno on error. ++ */ ++__rte_experimental ++int ++rte_tel_data_add_dict_uint_hex(struct rte_tel_data *d, const char *name, ++ uint64_t val, uint8_t display_bitwidth); ++ + /** + * This telemetry callback is used when registering a telemetry command. + * It handles getting and formatting information to be returned to telemetry +diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c +index be46054c29..61d9eeac6a 100644 +--- a/lib/telemetry/telemetry_data.c ++++ b/lib/telemetry/telemetry_data.c +@@ -2,12 +2,16 @@ + * Copyright(c) 2020 Intel Corporation + */ + ++#include ++ + #undef RTE_USE_LIBBSD + #include + #include + + #include "telemetry_data.h" + ++#define RTE_TEL_UINT_HEX_STR_BUF_LEN 64 ++ + int + rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type) + { +@@ -93,6 +97,60 @@ rte_tel_data_add_array_container(struct rte_tel_data *d, + return 0; + } + ++/* To suppress compiler warning about format string. */ ++#if defined(RTE_TOOLCHAIN_GCC) ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wformat-nonliteral" ++#elif defined(RTE_TOOLCHAIN_CLANG) ++#pragma clang diagnostic push ++#pragma clang diagnostic ignored "-Wformat-nonliteral" ++#endif ++ ++static int ++rte_tel_uint_to_hex_encoded_str(char *buf, size_t buf_len, uint64_t val, ++ uint8_t display_bitwidth) ++{ ++#define RTE_TEL_HEX_FORMAT_LEN 16 ++ ++ uint8_t spec_hex_width = (display_bitwidth + 3) / 4; ++ char format[RTE_TEL_HEX_FORMAT_LEN]; ++ ++ if (display_bitwidth != 0) { ++ if (snprintf(format, RTE_TEL_HEX_FORMAT_LEN, "0x%%0%u" PRIx64, ++ spec_hex_width) >= RTE_TEL_HEX_FORMAT_LEN) ++ return -EINVAL; ++ ++ if (snprintf(buf, buf_len, format, val) >= (int)buf_len) ++ return -EINVAL; ++ } else { ++ if (snprintf(buf, buf_len, "0x%" PRIx64, val) >= (int)buf_len) ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++#if defined(RTE_TOOLCHAIN_GCC) ++#pragma GCC diagnostic pop ++#elif defined(RTE_TOOLCHAIN_CLANG) ++#pragma clang diagnostic pop ++#endif ++ ++int ++rte_tel_data_add_array_uint_hex(struct rte_tel_data *d, uint64_t val, ++ uint8_t display_bitwidth) ++{ ++ char hex_str[RTE_TEL_UINT_HEX_STR_BUF_LEN]; ++ int ret; ++ ++ ret = rte_tel_uint_to_hex_encoded_str(hex_str, ++ RTE_TEL_UINT_HEX_STR_BUF_LEN, val, display_bitwidth); ++ if (ret != 0) ++ return ret; ++ ++ return rte_tel_data_add_array_string(d, hex_str); ++} ++ + static bool + valid_name(const char *name) + { +@@ -200,6 +258,22 @@ rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name, + return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG; + } + ++int ++rte_tel_data_add_dict_uint_hex(struct rte_tel_data *d, const char *name, ++ uint64_t val, uint8_t display_bitwidth) ++{ ++ char hex_str[RTE_TEL_UINT_HEX_STR_BUF_LEN]; ++ int ret; ++ ++ ret = rte_tel_uint_to_hex_encoded_str(hex_str, ++ RTE_TEL_UINT_HEX_STR_BUF_LEN, val, display_bitwidth); ++ if (ret != 0) ++ return ret; ++ ++ ++ return rte_tel_data_add_dict_string(d, name, hex_str); ++} ++ + struct rte_tel_data * + rte_tel_data_alloc(void) + { +diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map +index 77528bb1fe..576ac55297 100644 +--- a/lib/telemetry/version.map ++++ b/lib/telemetry/version.map +@@ -19,6 +19,16 @@ DPDK_22 { + local: *; + }; + ++EXPERIMENTAL { ++ global: ++ ++ # added in 23.03 ++ rte_tel_data_add_array_uint_hex; ++ rte_tel_data_add_dict_uint_hex; ++ ++ local: *; ++}; ++ + INTERNAL { + rte_telemetry_legacy_register; + rte_telemetry_init; +-- +2.23.0 + diff --git a/0276-ethdev-get-capabilities-from-telemetry-in-hexadecima.patch b/0276-ethdev-get-capabilities-from-telemetry-in-hexadecima.patch new file mode 100644 index 0000000..625ffe3 --- /dev/null +++ b/0276-ethdev-get-capabilities-from-telemetry-in-hexadecima.patch @@ -0,0 +1,62 @@ +From baa8bc0cc5736e2804e53c09b6cadf193993ce45 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 19 Dec 2022 15:06:48 +0800 +Subject: ethdev: get capabilities from telemetry in hexadecimal +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 796b031608d8d52e040f83304c676d3cda5af617 ] + +The 'dev_flags', 'rx_offloads', 'tx_offloads' and 'rss_hf' are better +displayed in hexadecimal format. + +Like: + --> old display by input /ethdev/info,0 + "dev_flags": 3, + "rx_offloads": 524288, + "tx_offloads": 65536, + "ethdev_rss_hf": 9100 + + --> new display + "dev_flags": "0x3", + "rx_offloads": "0x80000", + "tx_offloads": "0x10000", + "ethdev_rss_hf": "0x238c" + +Signed-off-by: Huisong Li +Acked-by: Morten Brørup +Acked-by: Chengwen Feng +--- + lib/ethdev/rte_ethdev.c | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index c216091e79..4e5499ad2d 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6428,13 +6428,14 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, + rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0); + rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0); + rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node); +- rte_tel_data_add_dict_u64(d, "dev_flags", eth_dev->data->dev_flags); +- rte_tel_data_add_dict_u64(d, "rx_offloads", +- eth_dev->data->dev_conf.rxmode.offloads); +- rte_tel_data_add_dict_u64(d, "tx_offloads", +- eth_dev->data->dev_conf.txmode.offloads); +- rte_tel_data_add_dict_u64(d, "ethdev_rss_hf", +- eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf); ++ rte_tel_data_add_dict_uint_hex(d, "dev_flags", ++ eth_dev->data->dev_flags, 0); ++ rte_tel_data_add_dict_uint_hex(d, "rx_offloads", ++ eth_dev->data->dev_conf.rxmode.offloads, 0); ++ rte_tel_data_add_dict_uint_hex(d, "tx_offloads", ++ eth_dev->data->dev_conf.txmode.offloads, 0); ++ rte_tel_data_add_dict_uint_hex(d, "ethdev_rss_hf", ++ eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf, 0); + + return 0; + } +-- +2.23.0 + diff --git a/0277-mem-fix-hugepage-info-mapping.patch b/0277-mem-fix-hugepage-info-mapping.patch new file mode 100644 index 0000000..c7c302b --- /dev/null +++ b/0277-mem-fix-hugepage-info-mapping.patch @@ -0,0 +1,51 @@ +From 2d42f6d26a83262c9765c6db7dfca44c8c26d995 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Mon, 6 Feb 2023 10:53:10 +0000 +Subject: mem: fix hugepage info mapping + +[ upstream commit 66e7ac416f3d62c5ee773ff02c115a24da9f1991 ] + +The map_shared_memory() function should treat mmap MAP_FAILED as NULL +because callers compare it with NULL to determine whether the map is +failed. + +Fixes: 764bf26873b9 ("add FreeBSD support") +Fixes: cb97d93e9d3b ("mem: share hugepage info primary and secondary") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Reviewed-by: David Marchand +--- + lib/eal/freebsd/eal_hugepage_info.c | 2 +- + lib/eal/linux/eal_hugepage_info.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/eal/freebsd/eal_hugepage_info.c b/lib/eal/freebsd/eal_hugepage_info.c +index 9dbe375bd3..e58e618469 100644 +--- a/lib/eal/freebsd/eal_hugepage_info.c ++++ b/lib/eal/freebsd/eal_hugepage_info.c +@@ -33,7 +33,7 @@ map_shared_memory(const char *filename, const size_t mem_size, int flags) + } + retval = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + close(fd); +- return retval; ++ return retval == MAP_FAILED ? NULL : retval; + } + + static void * +diff --git a/lib/eal/linux/eal_hugepage_info.c b/lib/eal/linux/eal_hugepage_info.c +index 41acf180ee..6c76a36a0d 100644 +--- a/lib/eal/linux/eal_hugepage_info.c ++++ b/lib/eal/linux/eal_hugepage_info.c +@@ -57,7 +57,7 @@ map_shared_memory(const char *filename, const size_t mem_size, int flags) + retval = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, + MAP_SHARED, fd, 0); + close(fd); +- return retval; ++ return retval == MAP_FAILED ? NULL : retval; + } + + static void * +-- +2.23.0 + diff --git a/0278-raw-ifpga-base-fix-init-with-multi-process.patch b/0278-raw-ifpga-base-fix-init-with-multi-process.patch new file mode 100644 index 0000000..d5d7ab9 --- /dev/null +++ b/0278-raw-ifpga-base-fix-init-with-multi-process.patch @@ -0,0 +1,44 @@ +From 08ad2bc6e7fd4bc11b25011dbae48268828d372f Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Mon, 6 Feb 2023 10:53:11 +0000 +Subject: raw/ifpga/base: fix init with multi-process + +[ upstream commit e6a2804b77c5fbfd97d0fe05ec7f959a0404a380 ] + +The MAP_FAILED should be used to determine whether the mapping is +successful. + +Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-process") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Reviewed-by: Rosen Xu +--- + drivers/raw/ifpga/base/opae_hw_api.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/raw/ifpga/base/opae_hw_api.c b/drivers/raw/ifpga/base/opae_hw_api.c +index 11c9887c7f..45efe70473 100644 +--- a/drivers/raw/ifpga/base/opae_hw_api.c ++++ b/drivers/raw/ifpga/base/opae_hw_api.c +@@ -380,7 +380,7 @@ static pthread_mutex_t *opae_adapter_mutex_open(struct opae_adapter *adapter) + PROT_READ | PROT_WRITE, MAP_SHARED, + shm_id, 0); + adapter->lock = (pthread_mutex_t *)ptr; +- if (ptr) { ++ if (ptr != MAP_FAILED) { + dev_info(NULL, + "shared memory %s address is %p\n", + shm_name, ptr); +@@ -499,7 +499,7 @@ static void *opae_adapter_shm_alloc(struct opae_adapter *adapter) + adapter->shm.size = size; + adapter->shm.ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, + MAP_SHARED, shm_id, 0); +- if (adapter->shm.ptr) { ++ if (adapter->shm.ptr != MAP_FAILED) { + dev_info(NULL, + "shared memory %s address is %p\n", + shm_name, adapter->shm.ptr); +-- +2.23.0 + diff --git a/0279-compressdev-fix-empty-devargs-parsing.patch b/0279-compressdev-fix-empty-devargs-parsing.patch new file mode 100644 index 0000000..d42e29d --- /dev/null +++ b/0279-compressdev-fix-empty-devargs-parsing.patch @@ -0,0 +1,52 @@ +From 37b765efbca81e4aa81fcb685e7810398e800e29 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 2 Mar 2023 07:50:05 +0000 +Subject: compressdev: fix empty devargs parsing + +[ upstream commit bb27182482d61777de6a38b16a1d2c692c2c3f8b ] + +The rte_kvargs_process() was used to parse KV pairs, it also supports +to parse 'only keys' (e.g. socket_id) type. And the callback function +parameter 'value' is NULL when parsed 'only keys'. + +This patch fixes segment fault in rte_compressdev_pmd_parse_uint_arg() +when parse input args with 'only keys' (e.g. socket_id). + +For a similar reason, this patch fixes +rte_compressdev_pmd_parse_name_arg(). + +Fixes: ed7dd94f7f66 ("compressdev: add basic device management") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + lib/compressdev/rte_compressdev_pmd.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/lib/compressdev/rte_compressdev_pmd.c b/lib/compressdev/rte_compressdev_pmd.c +index 7f500d76d4..6a11a396b7 100644 +--- a/lib/compressdev/rte_compressdev_pmd.c ++++ b/lib/compressdev/rte_compressdev_pmd.c +@@ -20,6 +20,9 @@ rte_compressdev_pmd_parse_name_arg(const char *key __rte_unused, + struct rte_compressdev_pmd_init_params *params = extra_args; + int n; + ++ if (value == NULL || extra_args == NULL) ++ return -EINVAL; ++ + n = strlcpy(params->name, value, RTE_COMPRESSDEV_NAME_MAX_LEN); + if (n >= RTE_COMPRESSDEV_NAME_MAX_LEN) + return -EINVAL; +@@ -37,6 +40,9 @@ rte_compressdev_pmd_parse_uint_arg(const char *key __rte_unused, + int i; + char *end; + ++ if (value == NULL || extra_args == NULL) ++ return -EINVAL; ++ + errno = 0; + i = strtol(value, &end, 10); + if (*end != 0 || errno != 0 || i < 0) +-- +2.23.0 + diff --git a/0280-cryptodev-fix-empty-devargs-parsing.patch b/0280-cryptodev-fix-empty-devargs-parsing.patch new file mode 100644 index 0000000..9e9f0ea --- /dev/null +++ b/0280-cryptodev-fix-empty-devargs-parsing.patch @@ -0,0 +1,55 @@ +From 23320d21b4abc8f52c612768a8508443f77dfcd8 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 2 Mar 2023 07:50:07 +0000 +Subject: cryptodev: fix empty devargs parsing + +[ upstream commit 8146454c56636ba8af5263b57e1c4a9f67fd4a39 ] + +The rte_kvargs_process() was used to parse KV pairs, it also supports +to parse 'only keys' (e.g. socket_id) type. And the callback function +parameter 'value' is NULL when parsed 'only keys'. + +This patch fixes segment fault in rte_cryptodev_pmd_parse_uint_arg() +when parse input args with 'only keys' (e.g. socket_id, +max_nb_queue_pairs). + +For a similar reason, this patch fixes +rte_cryptodev_pmd_parse_name_arg(). + +Fixes: 9e6edea41805 ("cryptodev: add APIs to assist PMD initialisation") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Akhil Goyal +--- + lib/cryptodev/cryptodev_pmd.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c +index 739a0b3f34..9dab1ef7cd 100644 +--- a/lib/cryptodev/cryptodev_pmd.c ++++ b/lib/cryptodev/cryptodev_pmd.c +@@ -19,6 +19,9 @@ rte_cryptodev_pmd_parse_name_arg(const char *key __rte_unused, + struct rte_cryptodev_pmd_init_params *params = extra_args; + int n; + ++ if (value == NULL || extra_args == NULL) ++ return -EINVAL; ++ + n = strlcpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN); + if (n >= RTE_CRYPTODEV_NAME_MAX_LEN) + return -EINVAL; +@@ -35,6 +38,10 @@ rte_cryptodev_pmd_parse_uint_arg(const char *key __rte_unused, + { + int i; + char *end; ++ ++ if (value == NULL || extra_args == NULL) ++ return -EINVAL; ++ + errno = 0; + + i = strtol(value, &end, 10); +-- +2.23.0 + diff --git a/0281-net-hns3-fix-empty-devargs-parsing.patch b/0281-net-hns3-fix-empty-devargs-parsing.patch new file mode 100644 index 0000000..84791c6 --- /dev/null +++ b/0281-net-hns3-fix-empty-devargs-parsing.patch @@ -0,0 +1,62 @@ +From cd1064bf44f8da3286a48f3f3da7df88ae4fa645 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 2 Mar 2023 07:50:09 +0000 +Subject: net/hns3: fix empty devargs parsing + +[ upstream commit 8e9bd29995ddb1205d90291a684bcf71599d6623 ] + +The rte_kvargs_process() was used to parse KV pairs, it also supports +to parse 'only keys' (e.g. socket_id) type. And the callback function +parameter 'value' is NULL when parsed 'only keys'. + +This patch fixes segment fault when parse input args with 'only keys' +(e.g. rx_func_hint). + +Fixes: a124f9e9591b ("net/hns3: add runtime config to select IO burst function") +Fixes: 70791213242e ("net/hns3: support masking device capability") +Fixes: 2fc3e696a7f1 ("net/hns3: add runtime config for mailbox limit time") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Dongdong Liu +--- + drivers/net/hns3/hns3_common.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 3c5e07f1bd..6697ecefe6 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -161,6 +161,9 @@ hns3_parse_io_hint_func(const char *key, const char *value, void *extra_args) + + RTE_SET_USED(key); + ++ if (value == NULL || extra_args == NULL) ++ return 0; ++ + if (strcmp(value, "vec") == 0) + hint = HNS3_IO_FUNC_HINT_VEC; + else if (strcmp(value, "sve") == 0) +@@ -201,6 +204,9 @@ hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) + + RTE_SET_USED(key); + ++ if (value == NULL || extra_args == NULL) ++ return 0; ++ + val = strtoull(value, NULL, HNS3_CONVERT_TO_HEXADECIMAL); + *(uint64_t *)extra_args = val; + +@@ -214,6 +220,9 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) + + RTE_SET_USED(key); + ++ if (value == NULL || extra_args == NULL) ++ return 0; ++ + val = strtoul(value, NULL, HNS3_CONVERT_TO_DECIMAL); + + /* +-- +2.23.0 + diff --git a/0282-net-virtio-fix-empty-devargs-parsing.patch b/0282-net-virtio-fix-empty-devargs-parsing.patch new file mode 100644 index 0000000..dafb867 --- /dev/null +++ b/0282-net-virtio-fix-empty-devargs-parsing.patch @@ -0,0 +1,57 @@ +From 51a50c25f5884df574cb254ee92de23bc821c0b4 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 2 Mar 2023 07:50:10 +0000 +Subject: net/virtio: fix empty devargs parsing + +[ upstream commit 1c1b35b59b4cee8836f34498b7c55b49de39d7b3 ] + +The rte_kvargs_process() was used to parse KV pairs, it also supports +to parse 'only keys' (e.g. socket_id) type. And the callback function +parameter 'value' is NULL when parsed 'only keys'. + +This patch fixes segment fault when parse input args with 'only keys' +(e.g. vectorized,vdpa). + +Fixes: 4710e16a4a7b ("net/virtio: add parameter to enable vectorized path") +Fixes: 44d7b2e87b69 ("net/virtio: refactor devargs parsing") +Fixes: 440f03c25378 ("net/virtio: skip device probe in vDPA mode") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Reviewed-by: Maxime Coquelin +--- + drivers/net/virtio/virtio_ethdev.c | 3 +++ + drivers/net/virtio/virtio_pci_ethdev.c | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c +index a38b15d01c..c22b2f2889 100644 +--- a/drivers/net/virtio/virtio_ethdev.c ++++ b/drivers/net/virtio/virtio_ethdev.c +@@ -2474,6 +2474,9 @@ virtio_dev_speed_capa_get(uint32_t speed) + static int vectorized_check_handler(__rte_unused const char *key, + const char *value, void *ret_val) + { ++ if (value == NULL || ret_val == NULL) ++ return -EINVAL; ++ + if (strcmp(value, "1") == 0) + *(int *)ret_val = 1; + else +diff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c +index 54645dc62e..de7b1ef344 100644 +--- a/drivers/net/virtio/virtio_pci_ethdev.c ++++ b/drivers/net/virtio/virtio_pci_ethdev.c +@@ -138,6 +138,9 @@ eth_virtio_pci_uninit(struct rte_eth_dev *eth_dev) + static int vdpa_check_handler(__rte_unused const char *key, + const char *value, void *ret_val) + { ++ if (value == NULL || ret_val == NULL) ++ return -EINVAL; ++ + if (strcmp(value, "1") == 0) + *(int *)ret_val = 1; + else +-- +2.23.0 + diff --git a/0283-dma-skeleton-fix-empty-devargs-parsing.patch b/0283-dma-skeleton-fix-empty-devargs-parsing.patch new file mode 100644 index 0000000..61664ec --- /dev/null +++ b/0283-dma-skeleton-fix-empty-devargs-parsing.patch @@ -0,0 +1,46 @@ +From 9db4a191823cb2dec68c4be50bb1143c141da22c Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 2 Mar 2023 07:50:11 +0000 +Subject: dma/skeleton: fix empty devargs parsing + +[ upstream commit e0e5dd0450db22fc7712da4b5a8e6fd6e081c870 ] + +The rte_kvargs_process() was used to parse KV pairs, it also supports +to parse 'only keys' (e.g. socket_id) type. And the callback function +parameter 'value' is NULL when parsed 'only keys'. + +This patch fixes segment fault when parse input args with 'only keys' +(e.g. lcore). + +Fixes: 05d5fc66a269 ("dma/skeleton: introduce skeleton driver") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + drivers/dma/skeleton/skeleton_dmadev.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c +index 81cbdd286e..67e0357cf0 100644 +--- a/drivers/dma/skeleton/skeleton_dmadev.c ++++ b/drivers/dma/skeleton/skeleton_dmadev.c +@@ -500,9 +500,15 @@ skeldma_parse_lcore(const char *key __rte_unused, + const char *value, + void *opaque) + { +- int lcore_id = atoi(value); ++ int lcore_id; ++ ++ if (value == NULL || opaque == NULL) ++ return -EINVAL; ++ ++ lcore_id = atoi(value); + if (lcore_id >= 0 && lcore_id < RTE_MAX_LCORE) + *(int *)opaque = lcore_id; ++ + return 0; + } + +-- +2.23.0 + diff --git a/0284-raw-skeleton-fix-empty-devargs-parsing.patch b/0284-raw-skeleton-fix-empty-devargs-parsing.patch new file mode 100644 index 0000000..4a67dc6 --- /dev/null +++ b/0284-raw-skeleton-fix-empty-devargs-parsing.patch @@ -0,0 +1,38 @@ +From db5368482035c920449a75d336afd3622044ee89 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Thu, 2 Mar 2023 07:50:12 +0000 +Subject: raw/skeleton: fix empty devargs parsing + +[ upstream commit 11da6149224a8de53d2ddd2aacba7b158cc4e3b4 ] + +The rte_kvargs_process() was used to parse KV pairs, it also supports +to parse 'only keys' (e.g. socket_id) type. And the callback function +parameter 'value' is NULL when parsed 'only keys'. + +This patch fixes segment fault when parse input args with 'only keys' +(e.g. self_test). + +Fixes: 55ca1b0f2151 ("raw/skeleton: add test cases") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + drivers/raw/skeleton/skeleton_rawdev.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/raw/skeleton/skeleton_rawdev.c b/drivers/raw/skeleton/skeleton_rawdev.c +index 16ecae3d92..a49e000146 100644 +--- a/drivers/raw/skeleton/skeleton_rawdev.c ++++ b/drivers/raw/skeleton/skeleton_rawdev.c +@@ -659,6 +659,8 @@ skeldev_get_selftest(const char *key __rte_unused, + void *opaque) + { + int *flag = opaque; ++ if (value == NULL || opaque == NULL) ++ return -EINVAL; + *flag = atoi(value); + return 0; + } +-- +2.23.0 + diff --git a/0285-net-hns3-simplify-hardware-checksum-offloading.patch b/0285-net-hns3-simplify-hardware-checksum-offloading.patch new file mode 100644 index 0000000..6e6422b --- /dev/null +++ b/0285-net-hns3-simplify-hardware-checksum-offloading.patch @@ -0,0 +1,224 @@ +From bc4b30bb7c3ce3310d98a43bb5364b327ecd5cf9 Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Fri, 21 Apr 2023 17:53:21 +0800 +Subject: net/hns3: simplify hardware checksum offloading + +[ upstream commit 7fd763a9dd18a3edd98e95c26e96349fd71cbb9b ] + +If the NIC support simple BD mode, the hardware will calculate +the checksum from the start position of checksum and fill the +checksum result to the offset position, which simple the +HW operations of calculating the type and header length of +L3/L4. + +Add this mode for hns3 PMD when the packet type is L4. + +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.c | 3 ++ + drivers/net/hns3/hns3_cmd.h | 1 + + drivers/net/hns3/hns3_dump.c | 1 + + drivers/net/hns3/hns3_ethdev.h | 1 + + drivers/net/hns3/hns3_rxtx.c | 52 +++++++++++++++++++++++++++++++++- + drivers/net/hns3/hns3_rxtx.h | 12 +++++++- + 6 files changed, 68 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index bdfc85f934..d530650452 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -419,6 +419,7 @@ hns3_get_caps_name(uint32_t caps_id) + } dev_caps[] = { + { HNS3_CAPS_FD_QUEUE_REGION_B, "fd_queue_region" }, + { HNS3_CAPS_PTP_B, "ptp" }, ++ { HNS3_CAPS_SIMPLE_BD_B, "simple_bd" }, + { HNS3_CAPS_TX_PUSH_B, "tx_push" }, + { HNS3_CAPS_PHY_IMP_B, "phy_imp" }, + { HNS3_CAPS_TQP_TXRX_INDEP_B, "tqp_txrx_indep" }, +@@ -489,6 +490,8 @@ hns3_parse_capability(struct hns3_hw *hw, + hns3_warn(hw, "ignore PTP capability due to lack of " + "rxd advanced layout capability."); + } ++ if (hns3_get_bit(caps, HNS3_CAPS_SIMPLE_BD_B)) ++ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_SIMPLE_BD_B, 1); + if (hns3_get_bit(caps, HNS3_CAPS_TX_PUSH_B)) + hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TX_PUSH_B, 1); + if (hns3_get_bit(caps, HNS3_CAPS_PHY_IMP_B)) +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index eb394c9dec..4abe0f1d13 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -313,6 +313,7 @@ enum HNS3_CAPS_BITS { + */ + HNS3_CAPS_FD_QUEUE_REGION_B = 2, + HNS3_CAPS_PTP_B, ++ HNS3_CAPS_SIMPLE_BD_B = 5, + HNS3_CAPS_TX_PUSH_B = 6, + HNS3_CAPS_PHY_IMP_B = 7, + HNS3_CAPS_TQP_TXRX_INDEP_B, +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index 8268506f6f..a793ba64ad 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -96,6 +96,7 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) + {HNS3_DEV_SUPPORT_TX_PUSH_B, "TX PUSH"}, + {HNS3_DEV_SUPPORT_INDEP_TXRX_B, "INDEP TXRX"}, + {HNS3_DEV_SUPPORT_STASH_B, "STASH"}, ++ {HNS3_DEV_SUPPORT_SIMPLE_BD_B, "SIMPLE BD"}, + {HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, "RXD Advanced Layout"}, + {HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"}, + {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"}, +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 9acc5a3d7e..ee4dd18d7b 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -886,6 +886,7 @@ enum hns3_dev_cap { + HNS3_DEV_SUPPORT_TX_PUSH_B, + HNS3_DEV_SUPPORT_INDEP_TXRX_B, + HNS3_DEV_SUPPORT_STASH_B, ++ HNS3_DEV_SUPPORT_SIMPLE_BD_B, + HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, + HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, + HNS3_DEV_SUPPORT_RAS_IMP_B, +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 1f44c0345f..aaf0a06ca6 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -3046,6 +3046,10 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, + HNS3_PORT_BASE_VLAN_ENABLE; + else + txq->pvid_sw_shift_en = false; ++ ++ if (hns3_dev_get_support(hw, SIMPLE_BD)) ++ txq->simple_bd_enable = true; ++ + txq->max_non_tso_bd_num = hw->max_non_tso_bd_num; + txq->configured = true; + txq->io_base = (void *)((char *)hw->io_base + +@@ -3162,7 +3166,7 @@ hns3_set_tso(struct hns3_desc *desc, uint32_t paylen, struct rte_mbuf *rxm) + return; + + desc->tx.type_cs_vlan_tso_len |= rte_cpu_to_le_32(BIT(HNS3_TXD_TSO_B)); +- desc->tx.mss = rte_cpu_to_le_16(rxm->tso_segsz); ++ desc->tx.ckst_mss |= rte_cpu_to_le_16(rxm->tso_segsz); + } + + static inline void +@@ -3901,6 +3905,50 @@ hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, + return i; + } + ++static inline int ++hns3_handle_simple_bd(struct hns3_tx_queue *txq, struct hns3_desc *desc, ++ struct rte_mbuf *m) ++{ ++#define HNS3_TCP_CSUM_OFFSET 16 ++#define HNS3_UDP_CSUM_OFFSET 6 ++ ++ /* ++ * In HIP09, NIC HW support Tx simple BD mode that the HW will ++ * calculate the checksum from the start position of checksum and fill ++ * the checksum result to the offset position without packet type and ++ * header length of L3/L4. ++ * For non-tunneling packet: ++ * - Tx simple BD support for TCP and UDP checksum. ++ * For tunneling packet: ++ * - Tx simple BD support for inner L4 checksum(except sctp checksum). ++ * - Tx simple BD not support the outer checksum and the inner L3 ++ * checksum. ++ * - Besides, Tx simple BD is not support for TSO. ++ */ ++ if (txq->simple_bd_enable && !(m->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) && ++ !(m->ol_flags & RTE_MBUF_F_TX_TCP_SEG) && ++ !(m->ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM) && ++ ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM || ++ (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM)) { ++ /* set checksum start and offset, defined in 2 Bytes */ ++ hns3_set_field(desc->tx.type_cs_vlan_tso_len, ++ HNS3_TXD_L4_START_M, HNS3_TXD_L4_START_S, ++ (m->l2_len + m->l3_len) >> HNS3_SIMPLE_BD_UNIT); ++ hns3_set_field(desc->tx.ol_type_vlan_len_msec, ++ HNS3_TXD_L4_CKS_OFFSET_M, HNS3_TXD_L4_CKS_OFFSET_S, ++ (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == ++ RTE_MBUF_F_TX_TCP_CKSUM ? ++ HNS3_TCP_CSUM_OFFSET >> HNS3_SIMPLE_BD_UNIT : ++ HNS3_UDP_CSUM_OFFSET >> HNS3_SIMPLE_BD_UNIT); ++ ++ hns3_set_bit(desc->tx.ckst_mss, HNS3_TXD_CKST_B, 1); ++ ++ return 0; ++ } ++ ++ return -ENOTSUP; ++} ++ + static int + hns3_parse_cksum(struct hns3_tx_queue *txq, uint16_t tx_desc_id, + struct rte_mbuf *m) +@@ -3910,6 +3958,8 @@ hns3_parse_cksum(struct hns3_tx_queue *txq, uint16_t tx_desc_id, + + /* Enable checksum offloading */ + if (m->ol_flags & HNS3_TX_CKSUM_OFFLOAD_MASK) { ++ if (hns3_handle_simple_bd(txq, desc, m) == 0) ++ return 0; + /* Fill in tunneling parameters if necessary */ + if (hns3_parse_tunneling_params(txq, m, tx_desc_id)) { + txq->dfx_stats.unsupported_tunnel_pkt_cnt++; +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index fa39f6481a..7685ac2ea3 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -134,6 +134,9 @@ + #define HNS3_TXD_L4LEN_S 24 + #define HNS3_TXD_L4LEN_M (0xffUL << HNS3_TXD_L4LEN_S) + ++#define HNS3_TXD_L4_START_S 8 ++#define HNS3_TXD_L4_START_M (0xffff << HNS3_TXD_L4_START_S) ++ + #define HNS3_TXD_OL3T_S 0 + #define HNS3_TXD_OL3T_M (0x3 << HNS3_TXD_OL3T_S) + #define HNS3_TXD_OVLAN_B 2 +@@ -141,6 +144,9 @@ + #define HNS3_TXD_TUNTYPE_S 4 + #define HNS3_TXD_TUNTYPE_M (0xf << HNS3_TXD_TUNTYPE_S) + ++#define HNS3_TXD_L4_CKS_OFFSET_S 8 ++#define HNS3_TXD_L4_CKS_OFFSET_M (0xffff << HNS3_TXD_L4_CKS_OFFSET_S) ++ + #define HNS3_TXD_BDTYPE_S 0 + #define HNS3_TXD_BDTYPE_M (0xf << HNS3_TXD_BDTYPE_S) + #define HNS3_TXD_FE_B 4 +@@ -157,10 +163,13 @@ + #define HNS3_TXD_MSS_S 0 + #define HNS3_TXD_MSS_M (0x3fff << HNS3_TXD_MSS_S) + ++#define HNS3_TXD_CKST_B 14 ++ + #define HNS3_TXD_OL4CS_B 22 + #define HNS3_L2_LEN_UNIT 1UL + #define HNS3_L3_LEN_UNIT 2UL + #define HNS3_L4_LEN_UNIT 2UL ++#define HNS3_SIMPLE_BD_UNIT 1UL + + #define HNS3_TXD_DEFAULT_BDTYPE 0 + #define HNS3_TXD_VLD_CMD (0x1 << HNS3_TXD_VLD_B) +@@ -247,7 +256,7 @@ struct hns3_desc { + + uint32_t paylen_fd_dop_ol4cs; + uint16_t tp_fe_sc_vld_ra_ri; +- uint16_t mss; ++ uint16_t ckst_mss; + } tx; + + struct { +@@ -488,6 +497,7 @@ struct hns3_tx_queue { + */ + uint16_t udp_cksum_mode:1; + ++ /* check whether the simple BD mode is supported */ + uint16_t simple_bd_enable:1; + uint16_t tx_push_enable:1; /* check whether the tx push is enabled */ + /* +-- +2.23.0 + diff --git a/0286-net-hns3-support-dump-media-type.patch b/0286-net-hns3-support-dump-media-type.patch new file mode 100644 index 0000000..08e2e5c --- /dev/null +++ b/0286-net-hns3-support-dump-media-type.patch @@ -0,0 +1,66 @@ +From 8c4f049f4ed9885886d4f16332472df7d2bd4773 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 21 Apr 2023 17:53:22 +0800 +Subject: net/hns3: support dump media type + +[ upstream commit 5a4af56b354d412b1be460f65d2977fd56b21ef8 ] + +The media type information helps locate faults such as AN or rate +switching, so add dump media type in eth_dev_priv_dump ops. + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_dump.c | 2 ++ + drivers/net/hns3/hns3_ethdev.c | 2 +- + drivers/net/hns3/hns3_ethdev.h | 2 ++ + 3 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index a793ba64ad..7daa54ec87 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -68,12 +68,14 @@ hns3_get_dev_mac_info(FILE *file, struct hns3_adapter *hns) + + fprintf(file, " - MAC Info:\n"); + fprintf(file, ++ "\t -- media_type=%s\n" + "\t -- query_type=%u\n" + "\t -- supported_speed=0x%x\n" + "\t -- advertising=0x%x\n" + "\t -- lp_advertising=0x%x\n" + "\t -- support_autoneg=%s\n" + "\t -- support_fc_autoneg=%s\n", ++ hns3_get_media_type_name(hw->mac.media_type), + hw->mac.query_type, + hw->mac.supported_speed, + hw->mac.advertising, +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 1c67ff2c99..12e7a72c36 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4891,7 +4891,7 @@ hns3_set_fiber_port_link_speed(struct hns3_hw *hw, + return hns3_cfg_mac_speed_dup(hw, cfg->speed, cfg->duplex); + } + +-static const char * ++const char * + hns3_get_media_type_name(uint8_t media_type) + { + if (media_type == HNS3_MEDIA_TYPE_FIBER) +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index ee4dd18d7b..8268dba788 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -1054,6 +1054,8 @@ int hns3_timesync_write_time(struct rte_eth_dev *dev, + const struct timespec *ts); + int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta); + ++const char *hns3_get_media_type_name(uint8_t media_type); ++ + static inline bool + is_reset_pending(struct hns3_adapter *hns) + { +-- +2.23.0 + diff --git a/0287-ethdev-fix-one-address-occupies-two-entries-in-MAC-a.patch b/0287-ethdev-fix-one-address-occupies-two-entries-in-MAC-a.patch new file mode 100644 index 0000000..2e8275d --- /dev/null +++ b/0287-ethdev-fix-one-address-occupies-two-entries-in-MAC-a.patch @@ -0,0 +1,111 @@ +From 9b1a4cdf89156605b4b5a5b1a5f5507423964dc9 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 19 May 2023 17:31:55 +0800 +Subject: [PATCH] ethdev: fix MAC address occupies two entries + +[ upstream commit 8f02f472a29432650d999969359d6a49ea6aadca ] + +The dev->data->mac_addrs[0] will be changed to a new MAC address when +applications modify the default MAC address by .mac_addr_set(). However, +if the new default one has been added as a non-default MAC address by +.mac_addr_add(), the .mac_addr_set() didn't check this address. +As a result, this MAC address occupies two entries in the list. Like: +add(MAC1) +add(MAC2) +add(MAC3) +add(MAC4) +set_default(MAC3) +default=MAC3, the rest of the list=MAC1, MAC2, MAC3, MAC4 +Note: MAC3 occupies two entries. + +But .mac_addr_set() cannot remove it implicitly in case of MAC address +shrinking in the list. +So this patch adds a check on whether the new default address was +already in the list and if so requires the user to remove it first. + +In addition, this patch documents the position of the default MAC +address and address unique in the list. + +Fixes: 854d8ad4ef68 ("ethdev: add default mac address modifier") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Chengwen Feng +Acked-by: Thomas Monjalon +Reviewed-by: Ferruh Yigit +--- + lib/ethdev/ethdev_driver.h | 6 +++++- + lib/ethdev/rte_ethdev.c | 10 ++++++++++ + lib/ethdev/rte_ethdev.h | 4 ++++ + 3 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h +index d3de203d7a..6f539d45c6 100644 +--- a/lib/ethdev/ethdev_driver.h ++++ b/lib/ethdev/ethdev_driver.h +@@ -111,7 +111,11 @@ struct rte_eth_dev_data { + + uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */ + +- /** Device Ethernet link address. @see rte_eth_dev_release_port() */ ++ /** ++ * Device Ethernet link addresses. ++ * All entries are unique. ++ * The first entry (index zero) is the default address. ++ */ + struct rte_ether_addr *mac_addrs; + /** Bitmap associating MAC addresses to pools */ + uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR]; +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 4e5499ad2d..bd5dac284d 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -4470,6 +4470,7 @@ int + rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) + { + struct rte_eth_dev *dev; ++ int index; + int ret; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); +@@ -4487,6 +4488,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); + ++ /* Keep address unique in dev->data->mac_addrs[]. */ ++ index = eth_dev_get_mac_addr_index(port_id, addr); ++ if (index > 0) { ++ RTE_ETHDEV_LOG(ERR, ++ "New default address for port %u was already in the address list. Please remove it first.\n", ++ port_id); ++ return -EEXIST; ++ } ++ + ret = (*dev->dev_ops->mac_addr_set)(dev, addr); + if (ret < 0) + return ret; +diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h +index b262939a33..9df50c30b4 100644 +--- a/lib/ethdev/rte_ethdev.h ++++ b/lib/ethdev/rte_ethdev.h +@@ -4167,6 +4167,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, + + /** + * Set the default MAC address. ++ * It replaces the address at index 0 of the MAC address list. ++ * If the address was already in the MAC address list, ++ * please remove it first. + * + * @param port_id + * The port identifier of the Ethernet device. +@@ -4177,6 +4180,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if *port* invalid. + * - (-EINVAL) if MAC address is invalid. ++ * - (-EEXIST) if MAC address was already in the address list. + */ + int rte_eth_dev_default_mac_addr_set(uint16_t port_id, + struct rte_ether_addr *mac_addr); +-- +2.23.0 + diff --git a/0288-net-hns3-fix-never-set-MAC-flow-control.patch b/0288-net-hns3-fix-never-set-MAC-flow-control.patch new file mode 100644 index 0000000..a99c01f --- /dev/null +++ b/0288-net-hns3-fix-never-set-MAC-flow-control.patch @@ -0,0 +1,47 @@ +From 68c936210f151e6359bb770026a2d6b7a3bed43a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 22 May 2023 21:17:36 +0800 +Subject: net/hns3: fix never set MAC flow control + +[ upstream commit 73b4f0011f09c5a57776c9f4edaf2d88a3065053 ] + +When some hardware and firmware support speed auto-negotiation +but do not support flow control auto-negotiation, driver can +never successfully set MAC flow control by flow_ctrl_set() API. +So only tell user driver doesn't support flow control autoneg +when user enable it. + +Fixes: 1f411e31a826 ("net/hns3: support flow control autoneg for copper port") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 11 +---------- + 1 file changed, 1 insertion(+), 10 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 12e7a72c36..e01d5f76db 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5304,16 +5304,7 @@ hns3_check_fc_autoneg_valid(struct hns3_hw *hw, uint8_t autoneg) + + if (!pf->support_fc_autoneg) { + if (autoneg != 0) { +- hns3_err(hw, "unsupported fc auto-negotiation setting."); +- return -EOPNOTSUPP; +- } +- +- /* +- * Flow control auto-negotiation of the NIC is not supported, +- * but other auto-negotiation features may be supported. +- */ +- if (autoneg != hw->mac.link_autoneg) { +- hns3_err(hw, "please use 'link_speeds' in struct rte_eth_conf to disable autoneg!"); ++ hns3_err(hw, "unsupported fc auto-negotiation."); + return -EOPNOTSUPP; + } + +-- +2.23.0 + diff --git a/0289-net-hns3-add-flow-control-autoneg-for-fiber-port.patch b/0289-net-hns3-add-flow-control-autoneg-for-fiber-port.patch new file mode 100644 index 0000000..b402c1c --- /dev/null +++ b/0289-net-hns3-add-flow-control-autoneg-for-fiber-port.patch @@ -0,0 +1,303 @@ +From 1a547f79f8d9b412dd4d643107b134e653500865 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 22 May 2023 21:17:37 +0800 +Subject: net/hns3: add flow control autoneg for fiber port + +[ upstream commit ab0ddd9a0ad5adcc96eabd1fe49edbd2809f202e ] + +Support flow control autoneg for fiber and backplane port. +And it depends on the capability of firmware. + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.c | 30 +++++++++++++++++- + drivers/net/hns3/hns3_cmd.h | 20 +++++++++++- + drivers/net/hns3/hns3_dump.c | 1 + + drivers/net/hns3/hns3_ethdev.c | 58 ++++++++-------------------------- + drivers/net/hns3/hns3_ethdev.h | 1 + + 5 files changed, 63 insertions(+), 47 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index d530650452..d0a3853656 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -428,7 +428,8 @@ hns3_get_caps_name(uint32_t caps_id) + { HNS3_CAPS_UDP_TUNNEL_CSUM_B, "udp_tunnel_csum" }, + { HNS3_CAPS_RAS_IMP_B, "ras_imp" }, + { HNS3_CAPS_RXD_ADV_LAYOUT_B, "rxd_adv_layout" }, +- { HNS3_CAPS_TM_B, "tm_capability" } ++ { HNS3_CAPS_TM_B, "tm_capability" }, ++ { HNS3_CAPS_FC_AUTO_B, "fc_autoneg" } + }; + uint32_t i; + +@@ -510,6 +511,8 @@ hns3_parse_capability(struct hns3_hw *hw, + hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_RAS_IMP_B, 1); + if (hns3_get_bit(caps, HNS3_CAPS_TM_B)) + hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TM_B, 1); ++ if (hns3_get_bit(caps, HNS3_CAPS_FC_AUTO_B)) ++ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_FC_AUTO_B, 1); + } + + static uint32_t +@@ -613,9 +616,31 @@ hns3_update_dev_lsc_cap(struct hns3_hw *hw, int fw_compact_cmd_result) + } + } + ++static void ++hns3_set_fc_autoneg_cap(struct hns3_adapter *hns, int fw_compact_cmd_result) ++{ ++ struct hns3_hw *hw = &hns->hw; ++ struct hns3_mac *mac = &hw->mac; ++ ++ if (mac->media_type == HNS3_MEDIA_TYPE_COPPER) { ++ hns->pf.support_fc_autoneg = true; ++ return; ++ } ++ ++ /* ++ * Flow control auto-negotiation requires the cooperation of the driver ++ * and firmware. ++ */ ++ hns->pf.support_fc_autoneg = (hns3_dev_get_support(hw, FC_AUTO) && ++ fw_compact_cmd_result == 0) ? ++ true : false; ++} ++ + static int + hns3_apply_fw_compat_cmd_result(struct hns3_hw *hw, int result) + { ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ + if (result != 0 && hns3_dev_get_support(hw, COPPER)) { + hns3_err(hw, "firmware fails to initialize the PHY, ret = %d.", + result); +@@ -623,6 +648,7 @@ hns3_apply_fw_compat_cmd_result(struct hns3_hw *hw, int result) + } + + hns3_update_dev_lsc_cap(hw, result); ++ hns3_set_fc_autoneg_cap(hns, result); + + return 0; + } +@@ -642,6 +668,8 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) + hns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0); + if (hns3_dev_get_support(hw, COPPER)) + hns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1); ++ if (hns3_dev_get_support(hw, FC_AUTO)) ++ hns3_set_bit(compat, HNS3_MAC_FC_AUTONEG_EN_B, 1); + } + req->compat = rte_cpu_to_le_32(compat); + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index 4abe0f1d13..d78c1b401e 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -323,6 +323,7 @@ enum HNS3_CAPS_BITS { + HNS3_CAPS_RAS_IMP_B, + HNS3_CAPS_RXD_ADV_LAYOUT_B = 15, + HNS3_CAPS_TM_B = 19, ++ HNS3_CAPS_FC_AUTO_B = 30, + }; + + /* Capabilities of VF dependent on the PF */ +@@ -666,6 +667,9 @@ enum hns3_promisc_type { + #define HNS3_LINK_EVENT_REPORT_EN_B 0 + #define HNS3_NCSI_ERROR_REPORT_EN_B 1 + #define HNS3_FIRMWARE_PHY_DRIVER_EN_B 2 ++ ++#define HNS3_MAC_FC_AUTONEG_EN_B 6 ++ + struct hns3_firmware_compat_cmd { + uint32_t compat; + uint8_t rsv[20]; +@@ -680,6 +684,7 @@ struct hns3_firmware_compat_cmd { + #define HNS3_PHY_LINK_MODE_AUTONEG_BIT BIT(6) + #define HNS3_PHY_LINK_MODE_PAUSE_BIT BIT(13) + #define HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT BIT(14) ++#define HNS3_PHY_LINK_MODE_PAUSE_S 13 + + #define HNS3_PHY_PARAM_CFG_BD_NUM 2 + struct hns3_phy_params_bd0_cmd { +@@ -789,6 +794,17 @@ struct hns3_sfp_type { + #define HNS3_FIBER_LINK_SPEED_10M_BIT BIT(7) + #define HNS3_FIBER_LINK_SPEED_200G_BIT BIT(8) + ++/* Flags for pause status field */ ++#define HNS3_FIBER_LOCAL_PAUSE_BIT BIT(0) ++#define HNS3_FIBER_LOCAL_ASYM_PAUSE_BIT BIT(1) ++#define HNS3_FIBER_LP_PAUSE_BIT BIT(2) ++#define HNS3_FIBER_LP_ASYM_PAUSE_BIT BIT(3) ++#define HNS3_FIBER_LOCAL_PAUSE_MASK (HNS3_FIBER_LOCAL_PAUSE_BIT | \ ++ HNS3_FIBER_LOCAL_ASYM_PAUSE_BIT) ++#define HNS3_FIBER_LP_PAUSE_MASK (HNS3_FIBER_LP_PAUSE_BIT | \ ++ HNS3_FIBER_LP_ASYM_PAUSE_BIT) ++#define HNS3_FIBER_LP_PAUSE_S 2 ++ + struct hns3_sfp_info_cmd { + uint32_t sfp_speed; + uint8_t query_type; /* 0: sfp speed, 1: active */ +@@ -798,7 +814,9 @@ struct hns3_sfp_info_cmd { + uint8_t autoneg_ability; + uint32_t supported_speed; /* speed supported by current media */ + uint32_t module_type; +- uint8_t rsv1[8]; ++ uint8_t rsv[2]; ++ uint8_t pause_status; ++ uint8_t rsv1[5]; + }; + + #define HNS3_MAC_CFG_FEC_AUTO_EN_B 0 +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index 7daa54ec87..7ecfca8497 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -104,6 +104,7 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) + {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"}, + {HNS3_DEV_SUPPORT_TM_B, "TM"}, + {HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, "VF VLAN FILTER MOD"}, ++ {HNS3_DEV_SUPPORT_FC_AUTO_B, "FC AUTO"} + }; + uint32_t i; + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index e01d5f76db..8a7f6cc7be 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -3975,6 +3975,7 @@ static int + hns3_get_sfp_info(struct hns3_hw *hw, struct hns3_mac *mac_info) + { + struct hns3_sfp_info_cmd *resp; ++ uint32_t local_pause, lp_pause; + struct hns3_cmd_desc desc; + int ret; + +@@ -4011,6 +4012,13 @@ hns3_get_sfp_info(struct hns3_hw *hw, struct hns3_mac *mac_info) + mac_info->support_autoneg = resp->autoneg_ability; + mac_info->link_autoneg = (resp->autoneg == 0) ? RTE_ETH_LINK_FIXED + : RTE_ETH_LINK_AUTONEG; ++ local_pause = resp->pause_status & HNS3_FIBER_LOCAL_PAUSE_MASK; ++ lp_pause = (resp->pause_status & HNS3_FIBER_LP_PAUSE_MASK) >> ++ HNS3_FIBER_LP_PAUSE_S; ++ mac_info->advertising = ++ local_pause << HNS3_PHY_LINK_MODE_PAUSE_S; ++ mac_info->lp_advertising = ++ lp_pause << HNS3_PHY_LINK_MODE_PAUSE_S; + } else { + mac_info->query_type = HNS3_DEFAULT_QUERY; + } +@@ -4093,6 +4101,8 @@ hns3_update_fiber_link_info(struct hns3_hw *hw) + mac->supported_speed = mac_info.supported_speed; + mac->support_autoneg = mac_info.support_autoneg; + mac->link_autoneg = mac_info.link_autoneg; ++ mac->advertising = mac_info.advertising; ++ mac->lp_advertising = mac_info.lp_advertising; + + return 0; + } +@@ -4495,24 +4505,6 @@ hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev) + return 0; + } + +-static void +-hns3_get_fc_autoneg_capability(struct hns3_adapter *hns) +-{ +- struct hns3_mac *mac = &hns->hw.mac; +- +- if (mac->media_type == HNS3_MEDIA_TYPE_COPPER) { +- hns->pf.support_fc_autoneg = true; +- return; +- } +- +- /* +- * Flow control auto-negotiation requires the cooperation of the driver +- * and firmware. Currently, the optical port does not support flow +- * control auto-negotiation. +- */ +- hns->pf.support_fc_autoneg = false; +-} +- + static int + hns3_init_pf(struct rte_eth_dev *eth_dev) + { +@@ -4615,8 +4607,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) + goto err_supported_speed; + } + +- hns3_get_fc_autoneg_capability(hns); +- + hns3_tm_conf_init(eth_dev); + + return 0; +@@ -5181,8 +5171,7 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) + } + + static void +-hns3_get_autoneg_rxtx_pause_copper(struct hns3_hw *hw, bool *rx_pause, +- bool *tx_pause) ++hns3_get_autoneg_rxtx_pause(struct hns3_hw *hw, bool *rx_pause, bool *tx_pause) + { + struct hns3_mac *mac = &hw->mac; + uint32_t advertising = mac->advertising; +@@ -5193,8 +5182,7 @@ hns3_get_autoneg_rxtx_pause_copper(struct hns3_hw *hw, bool *rx_pause, + if (advertising & lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) { + *rx_pause = true; + *tx_pause = true; +- } else if (advertising & lp_advertising & +- HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT) { ++ } else if (advertising & lp_advertising & HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT) { + if (advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) + *rx_pause = true; + else if (lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) +@@ -5209,26 +5197,7 @@ hns3_get_autoneg_fc_mode(struct hns3_hw *hw) + bool rx_pause = false; + bool tx_pause = false; + +- switch (hw->mac.media_type) { +- case HNS3_MEDIA_TYPE_COPPER: +- hns3_get_autoneg_rxtx_pause_copper(hw, &rx_pause, &tx_pause); +- break; +- +- /* +- * Flow control auto-negotiation is not supported for fiber and +- * backplane media type. +- */ +- case HNS3_MEDIA_TYPE_FIBER: +- case HNS3_MEDIA_TYPE_BACKPLANE: +- hns3_err(hw, "autoneg FC mode can't be obtained, but flow control auto-negotiation is enabled."); +- current_mode = hw->requested_fc_mode; +- goto out; +- default: +- hns3_err(hw, "autoneg FC mode can't be obtained for unknown media type(%u).", +- hw->mac.media_type); +- current_mode = HNS3_FC_NONE; +- goto out; +- } ++ hns3_get_autoneg_rxtx_pause(hw, &rx_pause, &tx_pause); + + if (rx_pause && tx_pause) + current_mode = HNS3_FC_FULL; +@@ -5239,7 +5208,6 @@ hns3_get_autoneg_fc_mode(struct hns3_hw *hw) + else + current_mode = HNS3_FC_NONE; + +-out: + return current_mode; + } + +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 8268dba788..88146f5054 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -892,6 +892,7 @@ enum hns3_dev_cap { + HNS3_DEV_SUPPORT_RAS_IMP_B, + HNS3_DEV_SUPPORT_TM_B, + HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, ++ HNS3_DEV_SUPPORT_FC_AUTO_B, + }; + + #define hns3_dev_get_support(hw, _name) \ +-- +2.23.0 + diff --git a/0290-net-hns3-fix-variable-type-mismatch.patch b/0290-net-hns3-fix-variable-type-mismatch.patch new file mode 100644 index 0000000..801d350 --- /dev/null +++ b/0290-net-hns3-fix-variable-type-mismatch.patch @@ -0,0 +1,52 @@ +From cae0ec81453b65080372918ea266b3e571fc6197 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Mon, 22 May 2023 21:17:38 +0800 +Subject: net/hns3: fix variable type mismatch + +[ upstream commit 84b195b9348810cb9ee2ac71f61ee4331b27d552 ] + +Loop conditions are compared with different variable types, +which may cause overflow risks. + +Fixes: 67d010346933 ("net/hns3: adjust data type of some variables") +Fixes: 6ee07e3cb589 ("net/hns3: fix insecure way to query MAC statistics") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_regs.c | 3 ++- + drivers/net/hns3/hns3_stats.c | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c +index 33392fd1f0..5d6f92e4bb 100644 +--- a/drivers/net/hns3/hns3_regs.c ++++ b/drivers/net/hns3/hns3_regs.c +@@ -294,8 +294,9 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + uint32_t *origin_data_ptr = data; + uint32_t reg_offset; +- uint16_t i, j; + size_t reg_num; ++ uint16_t j; ++ size_t i; + + /* fetching per-PF registers values from PF PCIe register space */ + reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t); +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index bad65fcbed..c2e692a2c5 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -317,7 +317,7 @@ hns3_update_mac_stats(struct hns3_hw *hw) + uint32_t stats_iterms; + uint64_t *desc_data; + uint32_t desc_num; +- uint16_t i; ++ uint32_t i; + int ret; + + /* The first desc has a 64-bit header, so need to consider it. */ +-- +2.23.0 + diff --git a/0291-net-hns3-fix-Rx-multiple-firmware-reset-interrupts.patch b/0291-net-hns3-fix-Rx-multiple-firmware-reset-interrupts.patch new file mode 100644 index 0000000..0273b41 --- /dev/null +++ b/0291-net-hns3-fix-Rx-multiple-firmware-reset-interrupts.patch @@ -0,0 +1,67 @@ +From 307e0a26dd0c00b0e600e97c975f0e9d71b175a3 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Mon, 22 May 2023 21:17:39 +0800 +Subject: net/hns3: fix Rx multiple firmware reset interrupts + +[ upstream commit 312dd216fe75173016a4c5edce60bb1bea988315 ] + +In the firmware (also known as IMP) reset scenario, driver interrupt +processing and firmware watchdog initialization are asynchronous. + +If the driver interrupt processing is faster than firmware watchdog +initialization (that is, the driver clears the firmware reset +interrupt source before the firmware watchdog is initialized), the +driver will receive multiple firmware reset interrupts. + +In the Kunpeng 920 platform, the above situation does not exist. But +it does on the newer platforms. So we add 5ms delay before drivers +clears the IMP reset interrupt source. + +As for the impact of 5ms, the number of PFs managed by a firmware is +limited. Therefore, even if a DPDK process takes over all the PFs +which managed by the firmware, the delay is controllable. + +Fixes: ee930d38ffca ("net/hns3: fix timing of clearing interrupt source") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 8a7f6cc7be..c0df8f5d97 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -286,6 +286,19 @@ hns3_handle_mac_tnl(struct hns3_hw *hw) + } + } + ++static void ++hns3_delay_before_clear_event_cause(struct hns3_hw *hw, uint32_t event_type, uint32_t regclr) ++{ ++#define IMPRESET_WAIT_MS_TIME 5 ++ ++ if (event_type == HNS3_VECTOR0_EVENT_RST && ++ regclr & BIT(HNS3_VECTOR0_IMPRESET_INT_B) && ++ hw->revision >= PCI_REVISION_ID_HIP09_A) { ++ rte_delay_ms(IMPRESET_WAIT_MS_TIME); ++ hns3_dbg(hw, "wait firmware watchdog initialization completed."); ++ } ++} ++ + static void + hns3_interrupt_handler(void *param) + { +@@ -305,6 +318,7 @@ hns3_interrupt_handler(void *param) + vector0_int = hns3_read_dev(hw, HNS3_VECTOR0_OTHER_INT_STS_REG); + ras_int = hns3_read_dev(hw, HNS3_RAS_PF_OTHER_INT_STS_REG); + cmdq_int = hns3_read_dev(hw, HNS3_VECTOR0_CMDQ_SRC_REG); ++ hns3_delay_before_clear_event_cause(hw, event_cause, clearval); + hns3_clear_event_cause(hw, event_cause, clearval); + /* vector 0 interrupt is shared with reset and mailbox source events. */ + if (event_cause == HNS3_VECTOR0_EVENT_ERR) { +-- +2.23.0 + diff --git a/0292-net-hns3-add-Tx-Rx-descriptor-logs.patch b/0292-net-hns3-add-Tx-Rx-descriptor-logs.patch new file mode 100644 index 0000000..49a403b --- /dev/null +++ b/0292-net-hns3-add-Tx-Rx-descriptor-logs.patch @@ -0,0 +1,132 @@ +From 23e9f9ec10d6ef2cbb794d55c0018c76e393a9b0 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Mon, 22 May 2023 21:17:40 +0800 +Subject: net/hns3: add Tx/Rx descriptor logs + +[ upstream commit 7cd4df57fb216489979528d603d39a7a5d1529da ] + +Add Tx/Rx descriptor logs, controlled by 'RTE_ETHDEV_DEBUG_RX/TX' +compile time flag with 'pmd.net.hns3.rx/tx' log type. + +Signed-off-by: Dengdui Huang +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 6 ++++++ + drivers/net/hns3/hns3_logs.h | 18 ++++++++++++++++++ + drivers/net/hns3/hns3_rxtx.c | 4 ++++ + drivers/net/hns3/hns3_rxtx.h | 29 +++++++++++++++++++++++++++++ + 4 files changed, 57 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index c0df8f5d97..2fb9e68039 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -6625,3 +6625,9 @@ RTE_PMD_REGISTER_PARAM_STRING(net_hns3, + HNS3_DEVARG_MBX_TIME_LIMIT_MS "= "); + RTE_LOG_REGISTER_SUFFIX(hns3_logtype_init, init, NOTICE); + RTE_LOG_REGISTER_SUFFIX(hns3_logtype_driver, driver, NOTICE); ++#ifdef RTE_ETHDEV_DEBUG_RX ++RTE_LOG_REGISTER_SUFFIX(hns3_logtype_rx, rx, DEBUG); ++#endif ++#ifdef RTE_ETHDEV_DEBUG_TX ++RTE_LOG_REGISTER_SUFFIX(hns3_logtype_tx, tx, DEBUG); ++#endif +diff --git a/drivers/net/hns3/hns3_logs.h b/drivers/net/hns3/hns3_logs.h +index c880f752ab..47d3a13220 100644 +--- a/drivers/net/hns3/hns3_logs.h ++++ b/drivers/net/hns3/hns3_logs.h +@@ -31,4 +31,22 @@ extern int hns3_logtype_driver; + #define hns3_dbg(hw, fmt, args...) \ + PMD_DRV_LOG_RAW(hw, RTE_LOG_DEBUG, fmt "\n", ## args) + ++#ifdef RTE_ETHDEV_DEBUG_RX ++extern int hns3_logtype_rx; ++#define PMD_RX_LOG(hw, level, fmt, args...) \ ++ rte_log(RTE_LOG_ ## level, hns3_logtype_rx, "%s %s(): " fmt "\n", \ ++ (hw)->data->name, __func__, ## args) ++#else ++#define PMD_RX_LOG(hw, level, fmt, args...) do { } while (0) ++#endif ++ ++#ifdef RTE_ETHDEV_DEBUG_TX ++extern int hns3_logtype_tx; ++#define PMD_TX_LOG(hw, level, fmt, args...) \ ++ rte_log(RTE_LOG_ ## level, hns3_logtype_tx, "%s %s(): " fmt "\n", \ ++ (hw)->data->name, __func__, ## args) ++#else ++#define PMD_TX_LOG(hw, level, fmt, args...) do { } while (0) ++#endif ++ + #endif /* HNS3_LOGS_H */ +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index aaf0a06ca6..e055b5415d 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -2618,6 +2618,7 @@ hns3_recv_scattered_pkts(void *rx_queue, + */ + rxd = rxdp[(bd_base_info & (1u << HNS3_RXD_VLD_B)) - + (1u << HNS3_RXD_VLD_B)]; ++ RX_BD_LOG(&rxq->hns->hw, DEBUG, &rxd); + + nmb = hns3_rx_alloc_buffer(rxq); + if (unlikely(nmb == NULL)) { +@@ -4274,6 +4275,8 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) + tx_next_use = 0; + tx_bak_pkt = txq->sw_ring; + } ++ if (m_seg != NULL) ++ TX_BD_LOG(&txq->hns->hw, DEBUG, desc); + + i++; + } while (m_seg != NULL); +@@ -4281,6 +4284,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) + /* Add end flag for the last Tx Buffer Descriptor */ + desc->tx.tp_fe_sc_vld_ra_ri |= + rte_cpu_to_le_16(BIT(HNS3_TXD_FE_B)); ++ TX_BD_LOG(&txq->hns->hw, DEBUG, desc); + + /* Increment bytes counter */ + txq->basic_stats.bytes += tx_pkt->pkt_len; +diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h +index 7685ac2ea3..b6a6513307 100644 +--- a/drivers/net/hns3/hns3_rxtx.h ++++ b/drivers/net/hns3/hns3_rxtx.h +@@ -553,6 +553,35 @@ struct hns3_tx_queue { + bool enabled; /* indicate if Tx queue has been enabled */ + }; + ++#define RX_BD_LOG(hw, level, rxdp) \ ++ PMD_RX_LOG(hw, level, "Rx descriptor: " \ ++ "l234_info=%#x pkt_len=%u size=%u rss_hash=%#x fd_id=%u vlan_tag=%u " \ ++ "o_dm_vlan_id_fb=%#x ot_vlan_tag=%u bd_base_info=%#x", \ ++ rte_le_to_cpu_32((rxdp)->rx.l234_info), \ ++ rte_le_to_cpu_16((rxdp)->rx.pkt_len), \ ++ rte_le_to_cpu_16((rxdp)->rx.size), \ ++ rte_le_to_cpu_32((rxdp)->rx.rss_hash), \ ++ rte_le_to_cpu_16((rxdp)->rx.fd_id), \ ++ rte_le_to_cpu_16((rxdp)->rx.vlan_tag), \ ++ rte_le_to_cpu_16((rxdp)->rx.o_dm_vlan_id_fb), \ ++ rte_le_to_cpu_16((rxdp)->rx.ot_vlan_tag), \ ++ rte_le_to_cpu_32((rxdp)->rx.bd_base_info)) ++ ++#define TX_BD_LOG(hw, level, txdp) \ ++ PMD_TX_LOG(hw, level, "Tx descriptor: " \ ++ "vlan_tag=%u send_size=%u type_cs_vlan_tso_len=%#x outer_vlan_tag=%u " \ ++ "tv=%#x ol_type_vlan_len_msec=%#x paylen_fd_dop_ol4cs=%#x " \ ++ "tp_fe_sc_vld_ra_ri=%#x ckst_mss=%u", \ ++ rte_le_to_cpu_16((txdp)->tx.vlan_tag), \ ++ rte_le_to_cpu_16((txdp)->tx.send_size), \ ++ rte_le_to_cpu_32((txdp)->tx.type_cs_vlan_tso_len), \ ++ rte_le_to_cpu_16((txdp)->tx.outer_vlan_tag), \ ++ rte_le_to_cpu_16((txdp)->tx.tv), \ ++ rte_le_to_cpu_32((txdp)->tx.ol_type_vlan_len_msec), \ ++ rte_le_to_cpu_32((txdp)->tx.paylen_fd_dop_ol4cs), \ ++ rte_le_to_cpu_16((txdp)->tx.tp_fe_sc_vld_ra_ri), \ ++ rte_le_to_cpu_16((txdp)->tx.ckst_mss)) ++ + #define HNS3_GET_TX_QUEUE_PEND_BD_NUM(txq) \ + ((txq)->nb_tx_desc - 1 - (txq)->tx_bd_ready) + +-- +2.23.0 + diff --git a/0293-net-hns3-fix-FEC-mode-for-200G-ports.patch b/0293-net-hns3-fix-FEC-mode-for-200G-ports.patch new file mode 100644 index 0000000..57c720c --- /dev/null +++ b/0293-net-hns3-fix-FEC-mode-for-200G-ports.patch @@ -0,0 +1,36 @@ +From 6c8780bfc15e2a039dca70e615a3568032ebcf21 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Sat, 8 Apr 2023 10:27:33 +0800 +Subject: net/hns3: fix FEC mode for 200G ports + +[ upstream commit 0ed9d6d08faf83dcaef02dc22edff2ee0f18c41a ] + +The hardware does not support NOFEC for 200G ports. So delete this +bit. + +Fixes: 9bf2ea8dbc65 ("net/hns3: support FEC") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 2fb9e68039..06d4752ab1 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -83,8 +83,7 @@ static const struct rte_eth_fec_capa speed_fec_capa_tbl[] = { + RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) | + RTE_ETH_FEC_MODE_CAPA_MASK(RS) }, + +- { RTE_ETH_SPEED_NUM_200G, RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC) | +- RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) | ++ { RTE_ETH_SPEED_NUM_200G, RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) | + RTE_ETH_FEC_MODE_CAPA_MASK(RS) } + }; + +-- +2.23.0 + diff --git a/0294-net-hns3-fix-FEC-mode-check-error.patch b/0294-net-hns3-fix-FEC-mode-check-error.patch new file mode 100644 index 0000000..8249486 --- /dev/null +++ b/0294-net-hns3-fix-FEC-mode-check-error.patch @@ -0,0 +1,108 @@ +From be516a78df6de13d6e87aaae19dad374819fca19 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Sat, 8 Apr 2023 10:27:34 +0800 +Subject: net/hns3: fix FEC mode check error + +[ upstream commit 5aba4e41d02222c5cf414b48876cff829f0b6a6f ] + +The function is_fec_mode_one_bit_set() is used to check whether +the binary of the mode from user only contains one '1'. But it +uses the bytes number this mode variable occupied to calculate +the count. So this patch uses __builtin_popcount() to replace it. + +This patch also extracts the code for verifying mode parameter into +a function. + +Fixes: 9bf2ea8dbc65 ("net/hns3: support FEC") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 50 ++++++++++++++++------------------ + 1 file changed, 24 insertions(+), 26 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 06d4752ab1..74e785c0cf 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -6139,52 +6139,50 @@ get_current_speed_fec_cap(struct hns3_hw *hw, struct rte_eth_fec_capa *fec_capa) + return cur_capa; + } + +-static bool +-is_fec_mode_one_bit_set(uint32_t mode) +-{ +- int cnt = 0; +- uint8_t i; +- +- for (i = 0; i < sizeof(mode); i++) +- if (mode >> i & 0x1) +- cnt++; +- +- return cnt == 1 ? true : false; +-} +- + static int +-hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode) ++hns3_fec_mode_valid(struct rte_eth_dev *dev, uint32_t mode) + { + #define FEC_CAPA_NUM 2 + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); +- struct hns3_pf *pf = &hns->pf; + struct rte_eth_fec_capa fec_capa[FEC_CAPA_NUM]; +- uint32_t cur_capa; + uint32_t num = FEC_CAPA_NUM; ++ uint32_t cur_capa; + int ret; + +- ret = hns3_fec_get_capability(dev, fec_capa, num); +- if (ret < 0) +- return ret; +- +- /* HNS3 PMD only support one bit set mode, e.g. 0x1, 0x4 */ +- if (!is_fec_mode_one_bit_set(mode)) { +- hns3_err(hw, "FEC mode(0x%x) not supported in HNS3 PMD, " +- "FEC mode should be only one bit set", mode); ++ if (__builtin_popcount(mode) != 1) { ++ hns3_err(hw, "FEC mode(0x%x) should be only one bit set", mode); + return -EINVAL; + } + ++ ret = hns3_fec_get_capability(dev, fec_capa, num); ++ if (ret < 0) ++ return ret; + /* + * Check whether the configured mode is within the FEC capability. + * If not, the configured mode will not be supported. + */ + cur_capa = get_current_speed_fec_cap(hw, fec_capa); +- if (!(cur_capa & mode)) { +- hns3_err(hw, "unsupported FEC mode = 0x%x", mode); ++ if ((cur_capa & mode) == 0) { ++ hns3_err(hw, "unsupported FEC mode(0x%x)", mode); + return -EINVAL; + } + ++ return 0; ++} ++ ++static int ++hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode) ++{ ++ struct hns3_adapter *hns = dev->data->dev_private; ++ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); ++ struct hns3_pf *pf = &hns->pf; ++ int ret; ++ ++ ret = hns3_fec_mode_valid(dev, mode); ++ if (ret != 0) ++ return ret; ++ + rte_spinlock_lock(&hw->lock); + ret = hns3_set_fec_hw(hw, mode); + if (ret) { +-- +2.23.0 + diff --git a/0295-net-hns3-fix-missing-FEC-capability.patch b/0295-net-hns3-fix-missing-FEC-capability.patch new file mode 100644 index 0000000..7e8e303 --- /dev/null +++ b/0295-net-hns3-fix-missing-FEC-capability.patch @@ -0,0 +1,222 @@ +From 19c77a23c28779fdbaca1e477749bcb3a9c3ecdd Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Sat, 8 Apr 2023 10:27:35 +0800 +Subject: net/hns3: fix missing FEC capability + +[ upstream commit f611c42363f434d62500b7c7f4b7ecaa46774bdd ] + +Currently, FEC capabilities are reported based on the device ID. +And a device ID is bound to only one or two rates. So some cases +hns3 driver only reports the FEC capabilities corresponding to +the rate. But hns3 supports speed switching function, which causes +the FEC capabilities of other rates are not reported. So this patch +reports the FEC capabilities by the speed capabilities of the +network port. + +Fixes: 9bf2ea8dbc65 ("net/hns3: support FEC") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 129 ++++++++++++--------------------- + 1 file changed, 45 insertions(+), 84 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 74e785c0cf..05d489a12b 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -60,6 +60,13 @@ enum hns3_evt_cause { + HNS3_VECTOR0_EVENT_OTHER, + }; + ++#define HNS3_SPEEDS_SUPP_FEC (RTE_ETH_LINK_SPEED_10G | \ ++ RTE_ETH_LINK_SPEED_25G | \ ++ RTE_ETH_LINK_SPEED_40G | \ ++ RTE_ETH_LINK_SPEED_50G | \ ++ RTE_ETH_LINK_SPEED_100G | \ ++ RTE_ETH_LINK_SPEED_200G) ++ + static const struct rte_eth_fec_capa speed_fec_capa_tbl[] = { + { RTE_ETH_SPEED_NUM_10G, RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC) | + RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) | +@@ -5900,56 +5907,27 @@ hns3_reset_service(void *param) + hns3_msix_process(hns, reset_level); + } + +-static unsigned int +-hns3_get_speed_capa_num(uint16_t device_id) ++static uint32_t ++hns3_get_speed_fec_capa(struct rte_eth_fec_capa *speed_fec_capa, ++ uint32_t speed_capa) + { +- unsigned int num; +- +- switch (device_id) { +- case HNS3_DEV_ID_25GE: +- case HNS3_DEV_ID_25GE_RDMA: +- num = 2; +- break; +- case HNS3_DEV_ID_100G_RDMA_MACSEC: +- case HNS3_DEV_ID_200G_RDMA: +- num = 1; +- break; +- default: +- num = 0; +- break; +- } ++ uint32_t speed_bit; ++ uint32_t num = 0; ++ uint32_t i; + +- return num; +-} ++ for (i = 0; i < RTE_DIM(speed_fec_capa_tbl); i++) { ++ speed_bit = ++ rte_eth_speed_bitflag(speed_fec_capa_tbl[i].speed, ++ RTE_ETH_LINK_FULL_DUPLEX); ++ if ((speed_capa & speed_bit) == 0) ++ continue; + +-static int +-hns3_get_speed_fec_capa(struct rte_eth_fec_capa *speed_fec_capa, +- uint16_t device_id) +-{ +- switch (device_id) { +- case HNS3_DEV_ID_25GE: +- /* fallthrough */ +- case HNS3_DEV_ID_25GE_RDMA: +- speed_fec_capa[0].speed = speed_fec_capa_tbl[1].speed; +- speed_fec_capa[0].capa = speed_fec_capa_tbl[1].capa; +- +- /* In HNS3 device, the 25G NIC is compatible with 10G rate */ +- speed_fec_capa[1].speed = speed_fec_capa_tbl[0].speed; +- speed_fec_capa[1].capa = speed_fec_capa_tbl[0].capa; +- break; +- case HNS3_DEV_ID_100G_RDMA_MACSEC: +- speed_fec_capa[0].speed = speed_fec_capa_tbl[4].speed; +- speed_fec_capa[0].capa = speed_fec_capa_tbl[4].capa; +- break; +- case HNS3_DEV_ID_200G_RDMA: +- speed_fec_capa[0].speed = speed_fec_capa_tbl[5].speed; +- speed_fec_capa[0].capa = speed_fec_capa_tbl[5].capa; +- break; +- default: +- return -ENOTSUP; ++ speed_fec_capa[num].speed = speed_fec_capa_tbl[i].speed; ++ speed_fec_capa[num].capa = speed_fec_capa_tbl[i].capa; ++ num++; + } + +- return 0; ++ return num; + } + + static int +@@ -5958,28 +5936,28 @@ hns3_fec_get_capability(struct rte_eth_dev *dev, + unsigned int num) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); +- uint16_t device_id = pci_dev->id.device_id; +- unsigned int capa_num; +- int ret; ++ unsigned int speed_num; ++ uint32_t speed_capa; + +- capa_num = hns3_get_speed_capa_num(device_id); +- if (capa_num == 0) { +- hns3_err(hw, "device(0x%x) is not supported by hns3 PMD", +- device_id); ++ speed_capa = hns3_get_speed_capa(hw); ++ /* speed_num counts number of speed capabilities */ ++ speed_num = __builtin_popcount(speed_capa & HNS3_SPEEDS_SUPP_FEC); ++ if (speed_num == 0) + return -ENOTSUP; +- } + +- if (speed_fec_capa == NULL || num < capa_num) +- return capa_num; ++ if (speed_fec_capa == NULL) ++ return speed_num; + +- ret = hns3_get_speed_fec_capa(speed_fec_capa, device_id); +- if (ret) +- return -ENOTSUP; ++ if (num < speed_num) { ++ hns3_err(hw, "not enough array size(%u) to store FEC capabilities, should not be less than %u", ++ num, speed_num); ++ return -EINVAL; ++ } + +- return capa_num; ++ return hns3_get_speed_fec_capa(speed_fec_capa, speed_capa); + } + ++ + static int + get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) + { +@@ -6117,52 +6095,35 @@ hns3_set_fec_hw(struct hns3_hw *hw, uint32_t mode) + } + + static uint32_t +-get_current_speed_fec_cap(struct hns3_hw *hw, struct rte_eth_fec_capa *fec_capa) ++hns3_get_current_speed_fec_cap(struct hns3_mac *mac) + { +- struct hns3_mac *mac = &hw->mac; +- uint32_t cur_capa; ++ uint32_t i; + +- switch (mac->link_speed) { +- case RTE_ETH_SPEED_NUM_10G: +- cur_capa = fec_capa[1].capa; +- break; +- case RTE_ETH_SPEED_NUM_25G: +- case RTE_ETH_SPEED_NUM_100G: +- case RTE_ETH_SPEED_NUM_200G: +- cur_capa = fec_capa[0].capa; +- break; +- default: +- cur_capa = 0; +- break; ++ for (i = 0; i < RTE_DIM(speed_fec_capa_tbl); i++) { ++ if (mac->link_speed == speed_fec_capa_tbl[i].speed) ++ return speed_fec_capa_tbl[i].capa; + } + +- return cur_capa; ++ return 0; + } + + static int + hns3_fec_mode_valid(struct rte_eth_dev *dev, uint32_t mode) + { +-#define FEC_CAPA_NUM 2 + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); +- struct rte_eth_fec_capa fec_capa[FEC_CAPA_NUM]; +- uint32_t num = FEC_CAPA_NUM; + uint32_t cur_capa; +- int ret; + + if (__builtin_popcount(mode) != 1) { + hns3_err(hw, "FEC mode(0x%x) should be only one bit set", mode); + return -EINVAL; + } + +- ret = hns3_fec_get_capability(dev, fec_capa, num); +- if (ret < 0) +- return ret; + /* + * Check whether the configured mode is within the FEC capability. + * If not, the configured mode will not be supported. + */ +- cur_capa = get_current_speed_fec_cap(hw, fec_capa); ++ cur_capa = hns3_get_current_speed_fec_cap(&hw->mac); + if ((cur_capa & mode) == 0) { + hns3_err(hw, "unsupported FEC mode(0x%x)", mode); + return -EINVAL; +-- +2.23.0 + diff --git a/0296-ethdev-introduce-low-latency-RS-FEC.patch b/0296-ethdev-introduce-low-latency-RS-FEC.patch new file mode 100644 index 0000000..a396ccd --- /dev/null +++ b/0296-ethdev-introduce-low-latency-RS-FEC.patch @@ -0,0 +1,33 @@ +From 7b36a2f27f2dbe8cd518885461473349a2c04314 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Sat, 8 Apr 2023 10:27:36 +0800 +Subject: ethdev: introduce low latency RS FEC + +[ upstream commit 371c8ec7498f9ea41c84d5d1fe0ab7d44e1325b9 ] + +This patch introduces LLRS (low latency Reed Solomon FEC). +LLRS supports for 25 Gbps, 50 Gbps, 100 Gbps, 200 Gbps and +400 Gbps Ethernet networks. + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +Acked-by: Ferruh Yigit +--- + lib/ethdev/rte_ethdev.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h +index 9df50c30b4..2064d439c8 100644 +--- a/lib/ethdev/rte_ethdev.h ++++ b/lib/ethdev/rte_ethdev.h +@@ -1973,6 +1973,7 @@ enum rte_eth_fec_mode { + RTE_ETH_FEC_AUTO, /**< FEC autonegotiation modes */ + RTE_ETH_FEC_BASER, /**< FEC using common algorithm */ + RTE_ETH_FEC_RS, /**< FEC using RS algorithm */ ++ RTE_ETH_FEC_LLRS, /**< FEC using LLRS algorithm */ + }; + + /* Translate from FEC mode to FEC capa */ +-- +2.23.0 + diff --git a/0297-app-testpmd-add-setting-and-querying-of-LLRS-FEC-mod.patch b/0297-app-testpmd-add-setting-and-querying-of-LLRS-FEC-mod.patch new file mode 100644 index 0000000..0d974e3 --- /dev/null +++ b/0297-app-testpmd-add-setting-and-querying-of-LLRS-FEC-mod.patch @@ -0,0 +1,72 @@ +From 8f50b71d99a1a071b62c3b36a11a95398fc863c3 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Sat, 8 Apr 2023 10:27:37 +0800 +Subject: app/testpmd: add setting and querying of LLRS FEC mode + +[ upstream commit 6cb1eaa6f2cd024a8c56e15e4a23ada7f9006aae ] + +This patch supports setting and querying of LLRS FEC mode. + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +Acked-by: Aman Singh +--- + app/test-pmd/cmdline.c | 5 ++++- + app/test-pmd/config.c | 4 ++++ + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- + 3 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 9e0e725913..0d9c7d449c 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -17078,6 +17078,9 @@ cmd_show_fec_mode_parsed(void *parsed_result, + case RTE_ETH_FEC_MODE_CAPA_MASK(RS): + strlcpy(buf, "rs", sizeof(buf)); + break; ++ case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS): ++ strlcpy(buf, "llrs", sizeof(buf)); ++ break; + default: + return; + } +@@ -17173,7 +17176,7 @@ cmd_set_port_fec_mode_parsed( + cmdline_parse_inst_t cmd_set_fec_mode = { + .f = cmd_set_port_fec_mode_parsed, + .data = NULL, +- .help_str = "set port fec_mode auto|off|rs|baser", ++ .help_str = "set port fec_mode auto|off|rs|baser|llrs", + .tokens = { + (void *)&cmd_set_port_fec_mode_set, + (void *)&cmd_set_port_fec_mode_port, +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index 78af232a8a..22c63e214e 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -167,6 +167,10 @@ static const struct { + .mode = RTE_ETH_FEC_RS, + .name = "rs", + }, ++ { ++ .mode = RTE_ETH_FEC_LLRS, ++ .name = "llrs", ++ }, + }; + + static void +diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +index e0edd349bc..ecf89aa46c 100644 +--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst ++++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst +@@ -1993,7 +1993,7 @@ Set fec mode + + Set fec mode for a specific port:: + +- testpmd> set port (port_id) fec_mode auto|off|rs|baser ++ testpmd> set port (port_id) fec_mode auto|off|rs|baser|llrs + + Config Sample actions list + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +2.23.0 + diff --git a/0298-net-hns3-add-LLRS-FEC-mode-support-for-200G-ports.patch b/0298-net-hns3-add-LLRS-FEC-mode-support-for-200G-ports.patch new file mode 100644 index 0000000..3fecbb1 --- /dev/null +++ b/0298-net-hns3-add-LLRS-FEC-mode-support-for-200G-ports.patch @@ -0,0 +1,111 @@ +From 85597c087e93576197c6e11d41caab7d8f43dbeb Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Sat, 8 Apr 2023 10:27:38 +0800 +Subject: net/hns3: add LLRS FEC mode support for 200G ports + +[ upstream commit cddeaee10f974bda1202e82e36a3d8f09450e80a ] + +This patch supports the query and configuration of LLRS FEC mode. + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.c | 1 + + drivers/net/hns3/hns3_cmd.h | 2 ++ + drivers/net/hns3/hns3_ethdev.c | 21 ++++++++++++--------- + 3 files changed, 15 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index d0a3853656..ca1d3f1b8c 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -666,6 +666,7 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) + if (is_init) { + hns3_set_bit(compat, HNS3_LINK_EVENT_REPORT_EN_B, 1); + hns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0); ++ hns3_set_bit(compat, HNS3_LLRS_FEC_EN_B, 1); + if (hns3_dev_get_support(hw, COPPER)) + hns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1); + if (hns3_dev_get_support(hw, FC_AUTO)) +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index d78c1b401e..929278521f 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -668,6 +668,7 @@ enum hns3_promisc_type { + #define HNS3_NCSI_ERROR_REPORT_EN_B 1 + #define HNS3_FIRMWARE_PHY_DRIVER_EN_B 2 + ++#define HNS3_LLRS_FEC_EN_B 5 + #define HNS3_MAC_FC_AUTONEG_EN_B 6 + + struct hns3_firmware_compat_cmd { +@@ -825,6 +826,7 @@ struct hns3_sfp_info_cmd { + #define HNS3_MAC_FEC_OFF 0 + #define HNS3_MAC_FEC_BASER 1 + #define HNS3_MAC_FEC_RS 2 ++#define HNS3_MAC_FEC_LLRS 3 + + /* Configure FEC mode, opcode:0x031A */ + struct hns3_config_fec_cmd { +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 05d489a12b..2ca5e4ced5 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -47,11 +47,6 @@ + #define HNS3_RESET_WAIT_MS 100 + #define HNS3_RESET_WAIT_CNT 200 + +-/* FEC mode order defined in HNS3 hardware */ +-#define HNS3_HW_FEC_MODE_NOFEC 0 +-#define HNS3_HW_FEC_MODE_BASER 1 +-#define HNS3_HW_FEC_MODE_RS 2 +- + enum hns3_evt_cause { + HNS3_VECTOR0_EVENT_RST, + HNS3_VECTOR0_EVENT_MBX, +@@ -91,7 +86,8 @@ static const struct rte_eth_fec_capa speed_fec_capa_tbl[] = { + RTE_ETH_FEC_MODE_CAPA_MASK(RS) }, + + { RTE_ETH_SPEED_NUM_200G, RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) | +- RTE_ETH_FEC_MODE_CAPA_MASK(RS) } ++ RTE_ETH_FEC_MODE_CAPA_MASK(RS) | ++ RTE_ETH_FEC_MODE_CAPA_MASK(LLRS) } + }; + + static enum hns3_reset_level hns3_get_reset_level(struct hns3_adapter *hns, +@@ -6032,15 +6028,18 @@ hns3_fec_get_internal(struct hns3_hw *hw, uint32_t *fec_capa) + * to be converted. + */ + switch (resp->active_fec) { +- case HNS3_HW_FEC_MODE_NOFEC: ++ case HNS3_MAC_FEC_OFF: + tmp_fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC); + break; +- case HNS3_HW_FEC_MODE_BASER: ++ case HNS3_MAC_FEC_BASER: + tmp_fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(BASER); + break; +- case HNS3_HW_FEC_MODE_RS: ++ case HNS3_MAC_FEC_RS: + tmp_fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(RS); + break; ++ case HNS3_MAC_FEC_LLRS: ++ tmp_fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(LLRS); ++ break; + default: + tmp_fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC); + break; +@@ -6081,6 +6080,10 @@ hns3_set_fec_hw(struct hns3_hw *hw, uint32_t mode) + hns3_set_field(req->fec_mode, HNS3_MAC_CFG_FEC_MODE_M, + HNS3_MAC_CFG_FEC_MODE_S, HNS3_MAC_FEC_RS); + break; ++ case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS): ++ hns3_set_field(req->fec_mode, HNS3_MAC_CFG_FEC_MODE_M, ++ HNS3_MAC_CFG_FEC_MODE_S, HNS3_MAC_FEC_LLRS); ++ break; + case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO): + hns3_set_bit(req->fec_mode, HNS3_MAC_CFG_FEC_AUTO_EN_B, 1); + break; +-- +2.23.0 + diff --git a/0299-net-hns3-get-current-FEC-capability-from-firmware.patch b/0299-net-hns3-get-current-FEC-capability-from-firmware.patch new file mode 100644 index 0000000..b0baa4b --- /dev/null +++ b/0299-net-hns3-get-current-FEC-capability-from-firmware.patch @@ -0,0 +1,122 @@ +From 02fad185915874c196d03966947a5b705b9bdff4 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Sat, 8 Apr 2023 10:27:39 +0800 +Subject: net/hns3: get current FEC capability from firmware + +[ upstream commit 7a475771aeb1d4f74a6bfd03a68462eb85151738 ] + +Obtain the supported FEC capability from the firmware to +enhance code compatibility. + +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_cmd.h | 9 ++++++++- + drivers/net/hns3/hns3_ethdev.c | 29 +++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_ethdev.h | 2 ++ + 3 files changed, 39 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index 929278521f..3f2bb4fd29 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -795,6 +795,12 @@ struct hns3_sfp_type { + #define HNS3_FIBER_LINK_SPEED_10M_BIT BIT(7) + #define HNS3_FIBER_LINK_SPEED_200G_BIT BIT(8) + ++#define HNS3_FIBER_FEC_AUTO_BIT BIT(0) ++#define HNS3_FIBER_FEC_BASER_BIT BIT(1) ++#define HNS3_FIBER_FEC_RS_BIT BIT(2) ++#define HNS3_FIBER_FEC_LLRS_BIT BIT(3) ++#define HNS3_FIBER_FEC_NOFEC_BIT BIT(4) ++ + /* Flags for pause status field */ + #define HNS3_FIBER_LOCAL_PAUSE_BIT BIT(0) + #define HNS3_FIBER_LOCAL_ASYM_PAUSE_BIT BIT(1) +@@ -815,7 +821,8 @@ struct hns3_sfp_info_cmd { + uint8_t autoneg_ability; + uint32_t supported_speed; /* speed supported by current media */ + uint32_t module_type; +- uint8_t rsv[2]; ++ uint8_t fec_ability; /* supported fec modes, see HNS3_FIBER_FEC_XXX_BIT */ ++ uint8_t rsv0; + uint8_t pause_status; + uint8_t rsv1[5]; + }; +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 2ca5e4ced5..d6214415b7 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4028,6 +4028,7 @@ hns3_get_sfp_info(struct hns3_hw *hw, struct hns3_mac *mac_info) + mac_info->support_autoneg = resp->autoneg_ability; + mac_info->link_autoneg = (resp->autoneg == 0) ? RTE_ETH_LINK_FIXED + : RTE_ETH_LINK_AUTONEG; ++ mac_info->fec_capa = resp->fec_ability; + local_pause = resp->pause_status & HNS3_FIBER_LOCAL_PAUSE_MASK; + lp_pause = (resp->pause_status & HNS3_FIBER_LP_PAUSE_MASK) >> + HNS3_FIBER_LP_PAUSE_S; +@@ -4117,6 +4118,7 @@ hns3_update_fiber_link_info(struct hns3_hw *hw) + mac->supported_speed = mac_info.supported_speed; + mac->support_autoneg = mac_info.support_autoneg; + mac->link_autoneg = mac_info.link_autoneg; ++ mac->fec_capa = mac_info.fec_capa; + mac->advertising = mac_info.advertising; + mac->lp_advertising = mac_info.lp_advertising; + +@@ -6097,11 +6099,38 @@ hns3_set_fec_hw(struct hns3_hw *hw, uint32_t mode) + return ret; + } + ++static uint32_t ++hns3_parse_hw_fec_capa(uint8_t hw_fec_capa) ++{ ++ const struct { ++ uint32_t hw_fec_capa; ++ uint32_t fec_capa; ++ } fec_capa_map[] = { ++ { HNS3_FIBER_FEC_AUTO_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) }, ++ { HNS3_FIBER_FEC_BASER_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(BASER) }, ++ { HNS3_FIBER_FEC_RS_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(RS) }, ++ { HNS3_FIBER_FEC_LLRS_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(LLRS) }, ++ { HNS3_FIBER_FEC_NOFEC_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC) }, ++ }; ++ uint32_t capa = 0; ++ uint32_t i; ++ ++ for (i = 0; i < RTE_DIM(fec_capa_map); i++) { ++ if ((hw_fec_capa & fec_capa_map[i].hw_fec_capa) != 0) ++ capa |= fec_capa_map[i].fec_capa; ++ } ++ ++ return capa; ++} ++ + static uint32_t + hns3_get_current_speed_fec_cap(struct hns3_mac *mac) + { + uint32_t i; + ++ if (mac->fec_capa != 0) ++ return hns3_parse_hw_fec_capa(mac->fec_capa); ++ + for (i = 0; i < RTE_DIM(speed_fec_capa_tbl); i++) { + if (mac->link_speed == speed_fec_capa_tbl[i].speed) + return speed_fec_capa_tbl[i].capa; +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 88146f5054..c04edf622f 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -214,6 +214,8 @@ struct hns3_mac { + uint32_t advertising; /* advertised capability in the local part */ + uint32_t lp_advertising; /* advertised capability in the link partner */ + uint8_t support_autoneg; ++ /* current supported fec modes. see HNS3_FIBER_FEC_XXX_BIT */ ++ uint32_t fec_capa; + }; + + struct hns3_fake_queue_data { +-- +2.23.0 + diff --git a/0300-net-hns3-fix-RTC-time-on-initialization.patch b/0300-net-hns3-fix-RTC-time-on-initialization.patch new file mode 100644 index 0000000..2a5d381 --- /dev/null +++ b/0300-net-hns3-fix-RTC-time-on-initialization.patch @@ -0,0 +1,80 @@ +From 6896b9dc63327691df470cc7b1d9bac8e8c673fe Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 2 Jun 2023 19:41:55 +0800 +Subject: net/hns3: fix RTC time on initialization + +[ upstream commit 27f64ddb711901d06bbe337ab714989e799a36d0 ] + +Driver doesn't initialize RTC time during probe phase, which +lead to an inaccurate time. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ptp.c | 26 +++++++++++++++++++------- + 1 file changed, 19 insertions(+), 7 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index db3c007b12..1e27e4aeca 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -56,9 +56,23 @@ hns3_ptp_int_en(struct hns3_hw *hw, bool en) + return ret; + } + ++static void ++hns3_ptp_timesync_write_time(struct hns3_hw *hw, const struct timespec *ts) ++{ ++ uint64_t sec = ts->tv_sec; ++ uint64_t ns = ts->tv_nsec; ++ ++ /* Set the timecounters to a new value. */ ++ hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_H, upper_32_bits(sec)); ++ hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_M, lower_32_bits(sec)); ++ hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_L, lower_32_bits(ns)); ++ hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_RDY, 1); ++} ++ + int + hns3_ptp_init(struct hns3_hw *hw) + { ++ struct timespec sys_time; + int ret; + + if (!hns3_dev_get_support(hw, PTP)) +@@ -71,6 +85,10 @@ hns3_ptp_init(struct hns3_hw *hw) + /* Start PTP timer */ + hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1); + ++ /* Initializing the RTC. */ ++ clock_gettime(CLOCK_REALTIME, &sys_time); ++ hns3_ptp_timesync_write_time(hw, &sys_time); ++ + return 0; + } + +@@ -241,17 +259,11 @@ int + hns3_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); +- uint64_t sec = ts->tv_sec; +- uint64_t ns = ts->tv_nsec; + + if (!hns3_dev_get_support(hw, PTP)) + return -ENOTSUP; + +- /* Set the timecounters to a new value. */ +- hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_H, upper_32_bits(sec)); +- hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_M, lower_32_bits(sec)); +- hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_L, lower_32_bits(ns)); +- hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_RDY, 1); ++ hns3_ptp_timesync_write_time(hw, ts); + + return 0; + } +-- +2.23.0 + diff --git a/0301-net-hns3-fix-RTC-time-after-reset.patch b/0301-net-hns3-fix-RTC-time-after-reset.patch new file mode 100644 index 0000000..500dd3c --- /dev/null +++ b/0301-net-hns3-fix-RTC-time-after-reset.patch @@ -0,0 +1,51 @@ +From 974c06500687f166870e57a998fcdbb82f5d3628 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 2 Jun 2023 19:41:56 +0800 +Subject: net/hns3: fix RTC time after reset + +[ upstream commit 0335c1f3c43a7da75fe5e2ab7bac0422cfad99e3 ] + +The enabled status of RTC time will be cleared after global +or IMP reset, which cause the local RTC time doesn't work. +So this patch fix it. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index d6214415b7..cecf6929f7 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4416,6 +4416,12 @@ hns3_init_hardware(struct hns3_adapter *hns) + goto err_mac_init; + } + ++ ret = hns3_ptp_init(hw); ++ if (ret) { ++ PMD_INIT_LOG(ERR, "Failed to init PTP, ret = %d", ret); ++ goto err_mac_init; ++ } ++ + return 0; + + err_mac_init: +@@ -4577,10 +4583,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) + goto err_intr_callback_register; + } + +- ret = hns3_ptp_init(hw); +- if (ret) +- goto err_get_config; +- + /* Enable interrupt */ + rte_intr_enable(pci_dev->intr_handle); + hns3_pf_enable_irq0(hw); +-- +2.23.0 + diff --git a/0302-net-hns3-uninitialize-PTP.patch b/0302-net-hns3-uninitialize-PTP.patch new file mode 100644 index 0000000..fa9d0aa --- /dev/null +++ b/0302-net-hns3-uninitialize-PTP.patch @@ -0,0 +1,82 @@ +From 35a0d98f028f8d1b37fec44dc9b1b5eec5e0a84e Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 2 Jun 2023 19:41:57 +0800 +Subject: net/hns3: uninitialize PTP + +[ upstream commit edb0f566d8476978fa6c12467fe03c4983a28573 ] + +This patch adds the uninitialization process of PTP in case +of having an impact on PF driver in kernel. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 2 ++ + drivers/net/hns3/hns3_ethdev.h | 1 + + drivers/net/hns3/hns3_ptp.c | 18 ++++++++++++++++++ + 3 files changed, 21 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index cecf6929f7..2e3aaf191d 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4637,6 +4637,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) + hns3_fdir_filter_uninit(hns); + err_fdir: + hns3_uninit_umv_space(hw); ++ hns3_ptp_uninit(hw); + err_init_hw: + hns3_stats_uninit(hw); + err_get_config: +@@ -4672,6 +4673,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) + hns3_flow_uninit(eth_dev); + hns3_fdir_filter_uninit(hns); + hns3_uninit_umv_space(hw); ++ hns3_ptp_uninit(hw); + hns3_stats_uninit(hw); + hns3_config_mac_tnl_int(hw, false); + hns3_pf_disable_irq0(hw); +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index c04edf622f..9456204422 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -1045,6 +1045,7 @@ int hns3_restore_ptp(struct hns3_adapter *hns); + int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, + struct rte_eth_conf *conf); + int hns3_ptp_init(struct hns3_hw *hw); ++void hns3_ptp_uninit(struct hns3_hw *hw); + int hns3_timesync_enable(struct rte_eth_dev *dev); + int hns3_timesync_disable(struct rte_eth_dev *dev); + int hns3_timesync_read_rx_timestamp(struct rte_eth_dev *dev, +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index 1e27e4aeca..0e17a17034 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -306,3 +306,21 @@ hns3_restore_ptp(struct hns3_adapter *hns) + + return ret; + } ++ ++void ++hns3_ptp_uninit(struct hns3_hw *hw) ++{ ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ int ret; ++ ++ if (!hns3_dev_get_support(hw, PTP)) ++ return; ++ ++ ret = hns3_ptp_int_en(hw, false); ++ if (ret != 0) ++ hns3_err(hw, "disable PTP interrupt failed, ret = %d.", ret); ++ ++ ret = hns3_timesync_configure(hns, false); ++ if (ret != 0) ++ hns3_err(hw, "disable timesync failed, ret = %d.", ret); ++} +-- +2.23.0 + diff --git a/0303-net-hns3-extract-PTP-to-its-own-header-file.patch b/0303-net-hns3-extract-PTP-to-its-own-header-file.patch new file mode 100644 index 0000000..2b64c25 --- /dev/null +++ b/0303-net-hns3-extract-PTP-to-its-own-header-file.patch @@ -0,0 +1,168 @@ +From aeddfec842cdd80c6c295045b80a420e3a07170a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Fri, 2 Jun 2023 19:41:58 +0800 +Subject: net/hns3: extract PTP to its own header file + +[ upstream commit 8977e7539f40ac716138dd49456dc26bfbf439c5 ] + +This patch extracts a PTP header file to contain PTP registers +and external API in order to make PTP code structure more clear. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 1 + + drivers/net/hns3/hns3_ethdev.h | 17 ------------ + drivers/net/hns3/hns3_ptp.c | 2 +- + drivers/net/hns3/hns3_ptp.h | 48 ++++++++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_regs.h | 23 ---------------- + 5 files changed, 50 insertions(+), 41 deletions(-) + create mode 100644 drivers/net/hns3/hns3_ptp.h + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 2e3aaf191d..d7443e197c 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -15,6 +15,7 @@ + #include "hns3_dcb.h" + #include "hns3_mp.h" + #include "hns3_flow.h" ++#include "hns3_ptp.h" + #include "hns3_ethdev.h" + + #define HNS3_SERVICE_INTERVAL 1000000 /* us */ +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index 9456204422..c58094d87b 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -1041,23 +1041,6 @@ void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, + uint32_t link_speed, uint8_t link_duplex); + void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); + +-int hns3_restore_ptp(struct hns3_adapter *hns); +-int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, +- struct rte_eth_conf *conf); +-int hns3_ptp_init(struct hns3_hw *hw); +-void hns3_ptp_uninit(struct hns3_hw *hw); +-int hns3_timesync_enable(struct rte_eth_dev *dev); +-int hns3_timesync_disable(struct rte_eth_dev *dev); +-int hns3_timesync_read_rx_timestamp(struct rte_eth_dev *dev, +- struct timespec *timestamp, +- uint32_t flags __rte_unused); +-int hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev, +- struct timespec *timestamp); +-int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts); +-int hns3_timesync_write_time(struct rte_eth_dev *dev, +- const struct timespec *ts); +-int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta); +- + const char *hns3_get_media_type_name(uint8_t media_type); + + static inline bool +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index 0e17a17034..894ac6dd71 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -7,7 +7,7 @@ + #include + + #include "hns3_ethdev.h" +-#include "hns3_regs.h" ++#include "hns3_ptp.h" + #include "hns3_logs.h" + + uint64_t hns3_timestamp_rx_dynflag; +diff --git a/drivers/net/hns3/hns3_ptp.h b/drivers/net/hns3/hns3_ptp.h +new file mode 100644 +index 0000000000..2b8717fa3c +--- /dev/null ++++ b/drivers/net/hns3/hns3_ptp.h +@@ -0,0 +1,48 @@ ++/* SPDX-License-Identifier: BSD-3-Clause ++ * Copyright(c) 2023 HiSilicon Limited. ++ */ ++ ++#ifndef HNS3_PTP_H ++#define HNS3_PTP_H ++ ++/* Register bit for 1588 event */ ++#define HNS3_VECTOR0_1588_INT_B 0 ++ ++#define HNS3_PTP_BASE_ADDRESS 0x29000 ++ ++#define HNS3_TX_1588_SEQID_BACK (HNS3_PTP_BASE_ADDRESS + 0x0) ++#define HNS3_TX_1588_TSP_BACK_0 (HNS3_PTP_BASE_ADDRESS + 0x4) ++#define HNS3_TX_1588_TSP_BACK_1 (HNS3_PTP_BASE_ADDRESS + 0x8) ++#define HNS3_TX_1588_TSP_BACK_2 (HNS3_PTP_BASE_ADDRESS + 0xc) ++ ++#define HNS3_TX_1588_BACK_TSP_CNT (HNS3_PTP_BASE_ADDRESS + 0x30) ++ ++#define HNS3_CFG_TIME_SYNC_H (HNS3_PTP_BASE_ADDRESS + 0x50) ++#define HNS3_CFG_TIME_SYNC_M (HNS3_PTP_BASE_ADDRESS + 0x54) ++#define HNS3_CFG_TIME_SYNC_L (HNS3_PTP_BASE_ADDRESS + 0x58) ++#define HNS3_CFG_TIME_SYNC_RDY (HNS3_PTP_BASE_ADDRESS + 0x5c) ++ ++#define HNS3_CFG_TIME_CYC_EN (HNS3_PTP_BASE_ADDRESS + 0x70) ++ ++#define HNS3_CURR_TIME_OUT_H (HNS3_PTP_BASE_ADDRESS + 0x74) ++#define HNS3_CURR_TIME_OUT_L (HNS3_PTP_BASE_ADDRESS + 0x78) ++#define HNS3_CURR_TIME_OUT_NS (HNS3_PTP_BASE_ADDRESS + 0x7c) ++ ++int hns3_restore_ptp(struct hns3_adapter *hns); ++int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, ++ struct rte_eth_conf *conf); ++int hns3_ptp_init(struct hns3_hw *hw); ++void hns3_ptp_uninit(struct hns3_hw *hw); ++int hns3_timesync_enable(struct rte_eth_dev *dev); ++int hns3_timesync_disable(struct rte_eth_dev *dev); ++int hns3_timesync_read_rx_timestamp(struct rte_eth_dev *dev, ++ struct timespec *timestamp, ++ uint32_t flags __rte_unused); ++int hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev, ++ struct timespec *timestamp); ++int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts); ++int hns3_timesync_write_time(struct rte_eth_dev *dev, ++ const struct timespec *ts); ++int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta); ++ ++#endif /* HNS3_PTP_H */ +diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h +index 459bbaf773..6b037f81c1 100644 +--- a/drivers/net/hns3/hns3_regs.h ++++ b/drivers/net/hns3/hns3_regs.h +@@ -124,29 +124,6 @@ + #define HNS3_TQP_INTR_RL_DEFAULT 0 + #define HNS3_TQP_INTR_QL_DEFAULT 0 + +-/* Register bit for 1588 event */ +-#define HNS3_VECTOR0_1588_INT_B 0 +- +-#define HNS3_PTP_BASE_ADDRESS 0x29000 +- +-#define HNS3_TX_1588_SEQID_BACK (HNS3_PTP_BASE_ADDRESS + 0x0) +-#define HNS3_TX_1588_TSP_BACK_0 (HNS3_PTP_BASE_ADDRESS + 0x4) +-#define HNS3_TX_1588_TSP_BACK_1 (HNS3_PTP_BASE_ADDRESS + 0x8) +-#define HNS3_TX_1588_TSP_BACK_2 (HNS3_PTP_BASE_ADDRESS + 0xc) +- +-#define HNS3_TX_1588_BACK_TSP_CNT (HNS3_PTP_BASE_ADDRESS + 0x30) +- +-#define HNS3_CFG_TIME_SYNC_H (HNS3_PTP_BASE_ADDRESS + 0x50) +-#define HNS3_CFG_TIME_SYNC_M (HNS3_PTP_BASE_ADDRESS + 0x54) +-#define HNS3_CFG_TIME_SYNC_L (HNS3_PTP_BASE_ADDRESS + 0x58) +-#define HNS3_CFG_TIME_SYNC_RDY (HNS3_PTP_BASE_ADDRESS + 0x5c) +- +-#define HNS3_CFG_TIME_CYC_EN (HNS3_PTP_BASE_ADDRESS + 0x70) +- +-#define HNS3_CURR_TIME_OUT_H (HNS3_PTP_BASE_ADDRESS + 0x74) +-#define HNS3_CURR_TIME_OUT_L (HNS3_PTP_BASE_ADDRESS + 0x78) +-#define HNS3_CURR_TIME_OUT_NS (HNS3_PTP_BASE_ADDRESS + 0x7c) +- + /* gl_usec convert to hardware count, as writing each 1 represents 2us */ + #define HNS3_GL_USEC_TO_REG(gl_usec) ((gl_usec) >> 1) + /* rl_usec convert to hardware count, as writing each 1 represents 4us */ +-- +2.23.0 + diff --git a/0304-net-hns3-fix-mbuf-leakage-when-RxQ-started-during-re.patch b/0304-net-hns3-fix-mbuf-leakage-when-RxQ-started-during-re.patch new file mode 100644 index 0000000..8a7bf9d --- /dev/null +++ b/0304-net-hns3-fix-mbuf-leakage-when-RxQ-started-during-re.patch @@ -0,0 +1,96 @@ +From e29ec4c79236c53c61a5ca955fee16993b63fe08 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 2 Jun 2023 19:41:59 +0800 +Subject: net/hns3: fix mbuf leakage when RxQ started during reset + +[ upstream commit e2199b1897da9e26bbc700df3a00cd9c3c85eede ] + +In the reset restore-conf phase, the reset process will allocate for +the Rx ring mbufs unconditionlly. + +And the rte_eth_dev_rx_queue_start() will also allocate for the Rx ring +mbufs unconditionlly. + +So if the rte_eth_dev_rx_queue_start() is invoked before restore-conf +phase, then the mbufs allocated by rte_eth_dev_rx_queue_start() will +leak. + +Because the hw->reset.resetting was always true during the phases from +stop-service to restore-conf, so fix it by returning an error if the +hw->reset.resetting is set. + +This patch adds the above logic in both rx_queue_start/rx_queue_stop/ +tx_queue_start/tx_queue_stop ops. + +Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index e055b5415d..f766c47072 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4523,6 +4523,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) + return -ENOTSUP; + + rte_spinlock_lock(&hw->lock); ++ ++ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { ++ hns3_err(hw, "fail to start Rx queue during resetting."); ++ rte_spinlock_unlock(&hw->lock); ++ return -EIO; ++ } ++ + ret = hns3_reset_queue(hw, rx_queue_id, HNS3_RING_TYPE_RX); + if (ret) { + hns3_err(hw, "fail to reset Rx queue %u, ret = %d.", +@@ -4569,6 +4576,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) + return -ENOTSUP; + + rte_spinlock_lock(&hw->lock); ++ ++ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { ++ hns3_err(hw, "fail to stop Rx queue during resetting."); ++ rte_spinlock_unlock(&hw->lock); ++ return -EIO; ++ } ++ + hns3_enable_rxq(rxq, false); + + hns3_rx_queue_release_mbufs(rxq); +@@ -4591,6 +4605,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) + return -ENOTSUP; + + rte_spinlock_lock(&hw->lock); ++ ++ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { ++ hns3_err(hw, "fail to start Tx queue during resetting."); ++ rte_spinlock_unlock(&hw->lock); ++ return -EIO; ++ } ++ + ret = hns3_reset_queue(hw, tx_queue_id, HNS3_RING_TYPE_TX); + if (ret) { + hns3_err(hw, "fail to reset Tx queue %u, ret = %d.", +@@ -4617,6 +4638,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) + return -ENOTSUP; + + rte_spinlock_lock(&hw->lock); ++ ++ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { ++ hns3_err(hw, "fail to stop Tx queue during resetting."); ++ rte_spinlock_unlock(&hw->lock); ++ return -EIO; ++ } ++ + hns3_enable_txq(txq, false); + hns3_tx_queue_release_mbufs(txq); + /* +-- +2.23.0 + diff --git a/0305-net-hns3-fix-mbuf-leakage-when-RxQ-started-after-res.patch b/0305-net-hns3-fix-mbuf-leakage-when-RxQ-started-after-res.patch new file mode 100644 index 0000000..9997238 --- /dev/null +++ b/0305-net-hns3-fix-mbuf-leakage-when-RxQ-started-after-res.patch @@ -0,0 +1,59 @@ +From 5f5edfc2aae49af8dee267565ea36852cab4f292 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 2 Jun 2023 19:42:00 +0800 +Subject: net/hns3: fix mbuf leakage when RxQ started after reset + +[ upstream commit 4ec0409b3f3801fa01f45f9dfddfab6a343436af ] + +In the reset restore-conf phase, the reset process will allocate for +the Rx ring mbufs unconditionlly. + +And the rte_eth_dev_rx_queue_start() will also allocate for the Rx ring +mbufs unconditionlly. + +So if the rte_eth_dev_rx_queue_start() is invoked after restore-conf +phase, then the mbufs allocated in restore-conf phase will leak. + +So fix it by conditional release Rx ring mbufs in +rte_eth_dev_rx_queue_start(): if the Rx ring mbufs were allocated then +release them first. + +This patch also set all sw-ring[]'s mbuf is NULL when release Rx ring +mbufs so that we can determine whether the Rx ring mbufs were allocated +based only on the first sw-ring[0]'s mbuf. + +Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index f766c47072..767ce82cc4 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -50,6 +50,8 @@ hns3_rx_queue_release_mbufs(struct hns3_rx_queue *rxq) + rxq->sw_ring[i].mbuf = NULL; + } + } ++ for (i = 0; i < rxq->rx_rearm_nb; i++) ++ rxq->sw_ring[rxq->rx_rearm_start + i].mbuf = NULL; + } + + for (i = 0; i < rxq->bulk_mbuf_num; i++) +@@ -4538,6 +4540,9 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) + return ret; + } + ++ if (rxq->sw_ring[0].mbuf != NULL) ++ hns3_rx_queue_release_mbufs(rxq); ++ + ret = hns3_init_rxq(hns, rx_queue_id); + if (ret) { + hns3_err(hw, "fail to init Rx queue %u, ret = %d.", +-- +2.23.0 + diff --git a/0306-net-hns3-fix-device-start-return-value.patch b/0306-net-hns3-fix-device-start-return-value.patch new file mode 100644 index 0000000..63ba0ea --- /dev/null +++ b/0306-net-hns3-fix-device-start-return-value.patch @@ -0,0 +1,38 @@ +From 080088d0626c9b437f41fc0717360c89d294dfdf Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 2 Jun 2023 19:42:01 +0800 +Subject: net/hns3: fix device start return value + +[ upstream commit 3c6143436cc6d328bb41f0474040a6e1d0a9ae4c ] + +If hns3_init_queues() return failed, the hns3vf_do_start() should +return errcode. This patch fixes it. + +Fixes: 43d8adf3891c ("net/hns3: fix RSS flow rule restore") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev_vf.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 3a93987409..6898a77407 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -1674,8 +1674,10 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue) + hns3_enable_rxd_adv_layout(hw); + + ret = hns3_init_queues(hns, reset_queue); +- if (ret) ++ if (ret) { + hns3_err(hw, "failed to init queues, ret = %d.", ret); ++ return ret; ++ } + + return hns3_restore_filter(hns); + } +-- +2.23.0 + diff --git a/0307-net-hns3-fix-uninitialized-variable.patch b/0307-net-hns3-fix-uninitialized-variable.patch new file mode 100644 index 0000000..666ec53 --- /dev/null +++ b/0307-net-hns3-fix-uninitialized-variable.patch @@ -0,0 +1,38 @@ +From 8bd047fb37fbc06fd695f120d9d51a4ffbcc2493 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Fri, 2 Jun 2023 19:42:02 +0800 +Subject: net/hns3: fix uninitialized variable + +[ upstream commit 82d44a304e9a0fe5931b7c68d32c3e30477564f2 ] + +This patch fixes possible use of uninitialized variable +"old_tuple_fields". + +Fixes: e3069658da9f ("net/hns3: reimplement hash flow function") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index c1f4f5cb0b..d5c9c22633 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1944,8 +1944,9 @@ hns3_flow_set_rss_ptype_tuple(struct hns3_hw *hw, + if (ret != 0) + return ret; + +- hns3_info(hw, "RSS tuple fields changed from 0x%" PRIx64 " to 0x%" PRIx64, +- old_tuple_fields, new_tuple_fields); ++ if (!cfg_global_tuple) ++ hns3_info(hw, "RSS tuple fields changed from 0x%" PRIx64 " to 0x%" PRIx64, ++ old_tuple_fields, new_tuple_fields); + + return 0; + } +-- +2.23.0 + diff --git a/0308-net-hns3-refactor-code.patch b/0308-net-hns3-refactor-code.patch new file mode 100644 index 0000000..7e50dab --- /dev/null +++ b/0308-net-hns3-refactor-code.patch @@ -0,0 +1,82 @@ +From 27ac02da0401a657ea0a6bf3c048be6af13aeace Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Fri, 2 Jun 2023 19:42:03 +0800 +Subject: net/hns3: refactor code + +[ upstream commit 00dcbfac5f2354de6e769f00159eba942a2c908a ] + +This patch modify the code that violates the coding standards. + +Signed-off-by: Dengdui Huang +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_regs.c | 3 +-- + drivers/net/hns3/hns3_rxtx.c | 10 +++------- + 2 files changed, 4 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c +index 5d6f92e4bb..be1be6a89c 100644 +--- a/drivers/net/hns3/hns3_regs.c ++++ b/drivers/net/hns3/hns3_regs.c +@@ -385,10 +385,9 @@ hns3_dfx_reg_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc, + hns3_cmd_setup_basic_desc(&desc[i], opcode, true); + + ret = hns3_cmd_send(hw, desc, bd_num); +- if (ret) { ++ if (ret) + hns3_err(hw, "fail to query dfx registers, opcode = 0x%04X, " + "ret = %d.\n", opcode, ret); +- } + + return ret; + } +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 767ce82cc4..13b0ad24b5 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -751,7 +751,7 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw) + for (i = 0; i < hw->cfg_max_queues; i++) { + ret = hns3pf_reset_tqp(hw, i); + if (ret) { +- hns3_err(hw, "fail to reset tqp, queue_id = %d, ret = %d.", ++ hns3_err(hw, "fail to reset tqp, queue_id = %u, ret = %d.", + i, ret); + return ret; + } +@@ -829,15 +829,13 @@ hns3_send_reset_queue_cmd(struct hns3_hw *hw, uint16_t queue_id, + { + struct hns3_reset_tqp_queue_cmd *req; + struct hns3_cmd_desc desc; +- int queue_direction; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RESET_TQP_QUEUE_INDEP, false); + + req = (struct hns3_reset_tqp_queue_cmd *)desc.data; + req->tqp_id = rte_cpu_to_le_16(queue_id); +- queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1; +- req->queue_direction = rte_cpu_to_le_16(queue_direction); ++ req->queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1; + hns3_set_bit(req->reset_req, HNS3_TQP_RESET_B, enable ? 1 : 0); + + ret = hns3_cmd_send(hw, &desc, 1); +@@ -855,15 +853,13 @@ hns3_get_queue_reset_status(struct hns3_hw *hw, uint16_t queue_id, + { + struct hns3_reset_tqp_queue_cmd *req; + struct hns3_cmd_desc desc; +- int queue_direction; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RESET_TQP_QUEUE_INDEP, true); + + req = (struct hns3_reset_tqp_queue_cmd *)desc.data; + req->tqp_id = rte_cpu_to_le_16(queue_id); +- queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1; +- req->queue_direction = rte_cpu_to_le_16(queue_direction); ++ req->queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1; + + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) { +-- +2.23.0 + diff --git a/0309-net-hns3-fix-inaccurate-log.patch b/0309-net-hns3-fix-inaccurate-log.patch new file mode 100644 index 0000000..531d53f --- /dev/null +++ b/0309-net-hns3-fix-inaccurate-log.patch @@ -0,0 +1,44 @@ +From 599089c15b21493879e6509cda350284e0af4eb3 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Fri, 2 Jun 2023 19:42:04 +0800 +Subject: net/hns3: fix inaccurate log + +[ upstream commit 9ff64664c1a1b1fa636ee4d11c7ef4eb54ab0691 ] + +This patch fix inaccurate log + +Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") +Fixes: a951c1ed3ab5 ("net/hns3: support different numbers of Rx and Tx queues") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_rxtx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 13b0ad24b5..4c79163e3f 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -586,7 +586,7 @@ hns3_tqp_enable(struct hns3_hw *hw, uint16_t queue_id, bool enable) + + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) +- hns3_err(hw, "TQP enable fail, ret = %d", ret); ++ hns3_err(hw, "TQP %s fail, ret = %d", enable ? "enable" : "disable", ret); + + return ret; + } +@@ -1635,7 +1635,7 @@ hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q, + + ret = hns3_fake_tx_queue_config(hw, tx_need_add_nb_q); + if (ret) { +- hns3_err(hw, "Fail to configure fake rx queues: %d", ret); ++ hns3_err(hw, "Fail to configure fake tx queues: %d", ret); + goto cfg_fake_tx_q_fail; + } + +-- +2.23.0 + diff --git a/0310-net-hns3-fix-redundant-line-break-in-log.patch b/0310-net-hns3-fix-redundant-line-break-in-log.patch new file mode 100644 index 0000000..b80b884 --- /dev/null +++ b/0310-net-hns3-fix-redundant-line-break-in-log.patch @@ -0,0 +1,71 @@ +From acc1ca225b8618728abd2b971f55354a7f6eebcf Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Fri, 2 Jun 2023 19:42:05 +0800 +Subject: net/hns3: fix redundant line break in log + +[ upstream commit 1af035107a4da0c5ea528afbde5d3d6ccc016437 ] + +This patch remove log redundant line break + +Fixes: d51867db65c1 ("net/hns3: add initialization") +Fixes: c6332c3cf9f0 ("net/hns3: support module EEPROM dump") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index d7443e197c..9af08a7748 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -3631,7 +3631,7 @@ hns3_get_mac_ethertype_cmd_status(uint16_t cmdq_resp, uint8_t resp_code) + + if (cmdq_resp) { + PMD_INIT_LOG(ERR, +- "cmdq execute failed for get_mac_ethertype_cmd_status, status=%u.\n", ++ "cmdq execute failed for get_mac_ethertype_cmd_status, status=%u.", + cmdq_resp); + return -EIO; + } +@@ -6235,7 +6235,7 @@ hns3_optical_module_existed(struct hns3_hw *hw) + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) { + hns3_err(hw, +- "fail to get optical module exist state, ret = %d.\n", ++ "fail to get optical module exist state, ret = %d.", + ret); + return false; + } +@@ -6273,7 +6273,7 @@ hns3_get_module_eeprom_data(struct hns3_hw *hw, uint32_t offset, + + ret = hns3_cmd_send(hw, desc, HNS3_SFP_INFO_CMD_NUM); + if (ret) { +- hns3_err(hw, "fail to get module EEPROM info, ret = %d.\n", ++ hns3_err(hw, "fail to get module EEPROM info, ret = %d.", + ret); + return ret; + } +@@ -6310,7 +6310,7 @@ hns3_get_module_eeprom(struct rte_eth_dev *dev, + return -ENOTSUP; + + if (!hns3_optical_module_existed(hw)) { +- hns3_err(hw, "fail to read module EEPROM: no module is connected.\n"); ++ hns3_err(hw, "fail to read module EEPROM: no module is connected."); + return -EIO; + } + +@@ -6373,7 +6373,7 @@ hns3_get_module_info(struct rte_eth_dev *dev, + modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8636_MAX_LEN; + break; + default: +- hns3_err(hw, "unknown module, type = %u, extra_type = %u.\n", ++ hns3_err(hw, "unknown module, type = %u, extra_type = %u.", + sfp_type.type, sfp_type.ext_type); + return -EINVAL; + } +-- +2.23.0 + diff --git a/0311-ethdev-add-API-to-check-if-queue-is-valid.patch b/0311-ethdev-add-API-to-check-if-queue-is-valid.patch new file mode 100644 index 0000000..6497b7d --- /dev/null +++ b/0311-ethdev-add-API-to-check-if-queue-is-valid.patch @@ -0,0 +1,117 @@ +From 16b5ecbb2f93fa577a0f665b7e1aaf07c63525f1 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Mon, 5 Jun 2023 10:27:40 +0800 +Subject: ethdev: add API to check if queue is valid + +[ upstream commit dcf6ce9c2100c604fd0cf602841d290d8236b504 ] + +The API rte_eth_dev_is_valid_rxq/txq which +is used to check if Rx/Tx queue is valid. +If the queue has been setup, it is considered valid. + +Signed-off-by: Dengdui Huang +Acked-by: Ferruh Yigit +--- + lib/ethdev/rte_ethdev.c | 22 ++++++++++++++++++++++ + lib/ethdev/rte_ethdev.h | 38 ++++++++++++++++++++++++++++++++++++++ + lib/ethdev/version.map | 2 ++ + 3 files changed, 62 insertions(+) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 61731ec83e..1a25515148 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -1009,6 +1009,28 @@ eth_dev_validate_tx_queue(const struct rte_eth_dev *dev, uint16_t tx_queue_id) + return 0; + } + ++int ++rte_eth_dev_is_valid_rxq(uint16_t port_id, uint16_t queue_id) ++{ ++ struct rte_eth_dev *dev; ++ ++ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); ++ dev = &rte_eth_devices[port_id]; ++ ++ return eth_dev_validate_rx_queue(dev, queue_id); ++} ++ ++int ++rte_eth_dev_is_valid_txq(uint16_t port_id, uint16_t queue_id) ++{ ++ struct rte_eth_dev *dev; ++ ++ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); ++ dev = &rte_eth_devices[port_id]; ++ ++ return eth_dev_validate_tx_queue(dev, queue_id); ++} ++ + int + rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id) + { +diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h +index 2064d439c8..c555ecb840 100644 +--- a/lib/ethdev/rte_ethdev.h ++++ b/lib/ethdev/rte_ethdev.h +@@ -2692,6 +2692,44 @@ int rte_eth_dev_socket_id(uint16_t port_id); + */ + int rte_eth_dev_is_valid_port(uint16_t port_id); + ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice ++ * ++ * Check if Rx queue is valid. If the queue has been setup, ++ * it is considered valid. ++ * ++ * @param port_id ++ * The port identifier of the Ethernet device. ++ * @param queue_id ++ * The index of the receive queue. ++ * @return ++ * - -ENODEV: if *port_id* is invalid. ++ * - -EINVAL: if queue_id is out of range or queue is not been setup. ++ * - 0 if Rx queue is valid. ++ */ ++__rte_experimental ++int rte_eth_dev_is_valid_rxq(uint16_t port_id, uint16_t queue_id); ++ ++/** ++ * @warning ++ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice ++ * ++ * Check if Tx queue is valid. If the queue has been setup, ++ * it is considered valid. ++ * ++ * @param port_id ++ * The port identifier of the Ethernet device. ++ * @param queue_id ++ * The index of the transmit queue. ++ * @return ++ * - -ENODEV: if *port_id* is invalid. ++ * - -EINVAL: if queue_id is out of range or queue is not been setup. ++ * - 0 if Tx queue is valid. ++ */ ++__rte_experimental ++int rte_eth_dev_is_valid_txq(uint16_t port_id, uint16_t queue_id); ++ + /** + * Start specified Rx queue of a port. It is used when rx_deferred_start + * flag of the specified queue is true. +diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map +index 590aa5a0a6..f593f64ea9 100644 +--- a/lib/ethdev/version.map ++++ b/lib/ethdev/version.map +@@ -263,6 +263,8 @@ EXPERIMENTAL { + # added in 22.11 + rte_eth_rx_descriptor_dump; + rte_eth_tx_descriptor_dump; ++ rte_eth_dev_is_valid_rxq; ++ rte_eth_dev_is_valid_txq; + }; + + INTERNAL { +-- +2.23.0 + diff --git a/0312-app-testpmd-fix-segment-fault-with-invalid-queue-ID.patch b/0312-app-testpmd-fix-segment-fault-with-invalid-queue-ID.patch new file mode 100644 index 0000000..53f57ef --- /dev/null +++ b/0312-app-testpmd-fix-segment-fault-with-invalid-queue-ID.patch @@ -0,0 +1,82 @@ +From 1c7616769fc09d9443cfd39816fa35b4b0ddd33d Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Mon, 5 Jun 2023 10:27:41 +0800 +Subject: app/testpmd: fix segment fault with invalid queue ID + +[ upstream commit 53191add2203e943c46af0b86002613f22b734b3 ] + +When input queue ID is invalid, it will lead to +Segmentation fault, like: + +dpdk-testpmd -a 0000:01:00.0 -- -i +testpmd> show port 0 txq/rxq 99 desc 0 status +Segmentation fault + +dpdk-testpmd -a 0000:01:00.0 -- -i +testpmd> show port 0 rxq 99 desc used count +Segmentation fault + +This patch fixes it. + +Fixes: fae9aa717d6c ("app/testpmd: support checking descriptor status") +Fixes: 3f9acb5c83bb ("ethdev: avoid non-dataplane checks in Rx queue count") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +Acked-by: Ferruh Yigit +--- + app/test-pmd/cmdline.c | 23 ++++++++++++++++------- + 1 file changed, 16 insertions(+), 7 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 0d9c7d449c..bc770f3d56 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -17315,12 +17315,13 @@ cmd_show_rx_tx_desc_status_parsed(void *parsed_result, + struct cmd_show_rx_tx_desc_status_result *res = parsed_result; + int rc; + +- if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { +- fprintf(stderr, "invalid port id %u\n", res->cmd_pid); +- return; +- } +- + if (!strcmp(res->cmd_keyword, "rxq")) { ++ if (rte_eth_dev_is_valid_rxq(res->cmd_pid, res->cmd_qid) != 0) { ++ fprintf(stderr, ++ "Invalid input: port id = %d, queue id = %d\n", ++ res->cmd_pid, res->cmd_qid); ++ return; ++ } + rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, + res->cmd_did); + if (rc < 0) { +@@ -17336,6 +17337,12 @@ cmd_show_rx_tx_desc_status_parsed(void *parsed_result, + else + printf("Desc status = UNAVAILABLE\n"); + } else if (!strcmp(res->cmd_keyword, "txq")) { ++ if (rte_eth_dev_is_valid_txq(res->cmd_pid, res->cmd_qid) != 0) { ++ fprintf(stderr, ++ "Invalid input: port id = %d, queue id = %d\n", ++ res->cmd_pid, res->cmd_qid); ++ return; ++ } + rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, + res->cmd_did); + if (rc < 0) { +@@ -17415,8 +17422,10 @@ cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result, + struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result; + int rc; + +- if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { +- fprintf(stderr, "invalid port id %u\n", res->cmd_pid); ++ if (rte_eth_dev_is_valid_rxq(res->cmd_pid, res->cmd_qid) != 0) { ++ fprintf(stderr, ++ "Invalid input: port id = %d, queue id = %d\n", ++ res->cmd_pid, res->cmd_qid); + return; + } + +-- +2.23.0 + diff --git a/0313-net-hns3-fix-IMP-reset-trigger.patch b/0313-net-hns3-fix-IMP-reset-trigger.patch new file mode 100644 index 0000000..b9adb29 --- /dev/null +++ b/0313-net-hns3-fix-IMP-reset-trigger.patch @@ -0,0 +1,66 @@ +From deb9dd8d00b81173425215f82ba9cb3e0db31e5c Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 6 Jun 2023 20:10:28 +0800 +Subject: net/hns3: fix IMP reset trigger + +[ upstream commit bc49e0b4132a05cc012f5e2e7934fbec6589861c ] + +Currently, driver sends the command with an unknown opcode to the +firmware to trigger IMP reset when some hardware error happened. +This unknown opcode cannot be parsed by the firmware. + +So this patch fixes the way by writing register to do it. + +Fixes: 2790c6464725 ("net/hns3: support device reset") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 16 ++++------------ + 1 file changed, 4 insertions(+), 12 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 9af08a7748..6c3ae75c4d 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -44,6 +44,7 @@ + #define HNS3_VECTOR0_IMP_CMDQ_ERR_B 4U + #define HNS3_VECTOR0_IMP_RD_POISON_B 5U + #define HNS3_VECTOR0_ALL_MSIX_ERR_B 6U ++#define HNS3_VECTOR0_TRIGGER_IMP_RESET_B 7U + + #define HNS3_RESET_WAIT_MS 100 + #define HNS3_RESET_WAIT_CNT 200 +@@ -5575,17 +5576,6 @@ hns3_func_reset_cmd(struct hns3_hw *hw, int func_id) + return hns3_cmd_send(hw, &desc, 1); + } + +-static int +-hns3_imp_reset_cmd(struct hns3_hw *hw) +-{ +- struct hns3_cmd_desc desc; +- +- hns3_cmd_setup_basic_desc(&desc, 0xFFFE, false); +- desc.data[0] = 0xeedd; +- +- return hns3_cmd_send(hw, &desc, 1); +-} +- + static void + hns3_msix_process(struct hns3_adapter *hns, enum hns3_reset_level reset_level) + { +@@ -5603,7 +5593,9 @@ hns3_msix_process(struct hns3_adapter *hns, enum hns3_reset_level reset_level) + + switch (reset_level) { + case HNS3_IMP_RESET: +- hns3_imp_reset_cmd(hw); ++ val = hns3_read_dev(hw, HNS3_VECTOR0_OTER_EN_REG); ++ hns3_set_bit(val, HNS3_VECTOR0_TRIGGER_IMP_RESET_B, 1); ++ hns3_write_dev(hw, HNS3_VECTOR0_OTER_EN_REG, val); + hns3_warn(hw, "IMP Reset requested time=%ld.%.6ld", + tv.tv_sec, tv.tv_usec); + break; +-- +2.23.0 + diff --git a/0314-net-ixgbe-add-proper-memory-barriers-in-Rx.patch b/0314-net-ixgbe-add-proper-memory-barriers-in-Rx.patch new file mode 100644 index 0000000..092d89d --- /dev/null +++ b/0314-net-ixgbe-add-proper-memory-barriers-in-Rx.patch @@ -0,0 +1,136 @@ +From 2b198866b2753d5c8a1241a32023137a91103392 Mon Sep 17 00:00:00 2001 +From: Min Zhou +Date: Tue, 13 Jun 2023 17:44:25 +0800 +Subject: [PATCH 2/2] net/ixgbe: add proper memory barriers in Rx + +Segmentation fault has been observed while running the +ixgbe_recv_pkts_lro() function to receive packets on the Loongson 3C5000 +processor which has 64 cores and 4 NUMA nodes. + +From the ixgbe_recv_pkts_lro() function, we found that as long as the first +packet has the EOP bit set, and the length of this packet is less than or +equal to rxq->crc_len, the segmentation fault will definitely happen even +though on the other platforms. For example, if we made the first packet +which had the EOP bit set had a zero length by force, the segmentation +fault would happen on X86. + +Because when processd the first packet the first_seg->next will be NULL, if +at the same time this packet has the EOP bit set and its length is less +than or equal to rxq->crc_len, the following loop will be executed: + + for (lp = first_seg; lp->next != rxm; lp = lp->next) + ; + +We know that the first_seg->next will be NULL under this condition. So the +expression of lp->next->next will cause the segmentation fault. + +Normally, the length of the first packet with EOP bit set will be greater +than rxq->crc_len. However, the out-of-order execution of CPU may make the +read ordering of the status and the rest of the descriptor fields in this +function not be correct. The related codes are as following: + + rxdp = &rx_ring[rx_id]; + #1 staterr = rte_le_to_cpu_32(rxdp->wb.upper.status_error); + + if (!(staterr & IXGBE_RXDADV_STAT_DD)) + break; + + #2 rxd = *rxdp; + +The sentence #2 may be executed before sentence #1. This action is likely +to make the ready packet zero length. If the packet is the first packet and +has the EOP bit set, the above segmentation fault will happen. + +So, we should add a proper memory barrier to ensure the read ordering be +correct. We also did the same thing in the ixgbe_recv_pkts() function to +make the rxd data be valid even though we did not find segmentation fault +in this function. + +Fixes: 8eecb3295aed ("ixgbe: add LRO support") +Cc: stable@dpdk.org + +Signed-off-by: Min Zhou +Reviewed-by: Ruifeng Wang +--- + drivers/net/ixgbe/ixgbe_rxtx.c | 47 +++++++++++++++------------------- + 1 file changed, 21 insertions(+), 26 deletions(-) + +diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c +index e19e832..c0491bf 100644 +--- a/drivers/net/ixgbe/ixgbe_rxtx.c ++++ b/drivers/net/ixgbe/ixgbe_rxtx.c +@@ -1818,11 +1818,22 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + * of accesses cannot be reordered by the compiler. If they were + * not volatile, they could be reordered which could lead to + * using invalid descriptor fields when read from rxd. ++ * ++ * Meanwhile, to prevent the CPU from executing out of order, we ++ * need to use a proper memory barrier to ensure the memory ++ * ordering below. + */ + rxdp = &rx_ring[rx_id]; + staterr = rxdp->wb.upper.status_error; + if (!(staterr & rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD))) + break; ++ ++ /* ++ * Use acquire fence to ensure that status_error which includes ++ * DD bit is loaded before loading of other descriptor words. ++ */ ++ rte_atomic_thread_fence(__ATOMIC_ACQUIRE); ++ + rxd = *rxdp; + + /* +@@ -2089,32 +2100,10 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, + + next_desc: + /* +- * The code in this whole file uses the volatile pointer to +- * ensure the read ordering of the status and the rest of the +- * descriptor fields (on the compiler level only!!!). This is so +- * UGLY - why not to just use the compiler barrier instead? DPDK +- * even has the rte_compiler_barrier() for that. +- * +- * But most importantly this is just wrong because this doesn't +- * ensure memory ordering in a general case at all. For +- * instance, DPDK is supposed to work on Power CPUs where +- * compiler barrier may just not be enough! +- * +- * I tried to write only this function properly to have a +- * starting point (as a part of an LRO/RSC series) but the +- * compiler cursed at me when I tried to cast away the +- * "volatile" from rx_ring (yes, it's volatile too!!!). So, I'm +- * keeping it the way it is for now. +- * +- * The code in this file is broken in so many other places and +- * will just not work on a big endian CPU anyway therefore the +- * lines below will have to be revisited together with the rest +- * of the ixgbe PMD. +- * +- * TODO: +- * - Get rid of "volatile" and let the compiler do its job. +- * - Use the proper memory barrier (rte_rmb()) to ensure the +- * memory ordering below. ++ * "Volatile" only prevents caching of the variable marked ++ * volatile. Most important, "volatile" cannot prevent the CPU ++ * from executing out of order. So, it is necessary to use a ++ * proper memory barrier to ensure the memory ordering below. + */ + rxdp = &rx_ring[rx_id]; + staterr = rte_le_to_cpu_32(rxdp->wb.upper.status_error); +@@ -2122,6 +2111,12 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, + if (!(staterr & IXGBE_RXDADV_STAT_DD)) + break; + ++ /* ++ * Use acquire fence to ensure that status_error which includes ++ * DD bit is loaded before loading of other descriptor words. ++ */ ++ rte_atomic_thread_fence(__ATOMIC_ACQUIRE); ++ + rxd = *rxdp; + + PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_id=%u " +-- +2.33.0 diff --git a/0315-net-cnxk-fix-build-with-GCC-12.patch b/0315-net-cnxk-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..a5b08b3 --- /dev/null +++ b/0315-net-cnxk-fix-build-with-GCC-12.patch @@ -0,0 +1,108 @@ +From b8bfbcd1a04b143151da9688eaefc9f7b72ccc12 Mon Sep 17 00:00:00 2001 +From: Rakesh Kudurumalla +Date: Wed, 23 Feb 2022 15:25:40 +0530 +Subject: [PATCH] net/cnxk: fix build with GCC 12 + +[ upstream commit b526599020ef06811dd08c4f15c0cdf049d7f9f2 ] + +Resolve following compilation error with gcc 12 version. +error: storing the address of local variable message in *error.message + +Fixes: 26b034f78ca7 ("net/cnxk: support to validate meter policy") + +Reported-by: Ferruh Yigit +Signed-off-by: Rakesh Kudurumalla +Acked-by: Jerin Jacob +--- + drivers/net/cnxk/cnxk_ethdev_mtr.c | 59 ++++++++++++++++++++++-------- + 1 file changed, 44 insertions(+), 15 deletions(-) + +diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c +index 39d8563826..6d14c88e7d 100644 +--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c ++++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c +@@ -277,15 +277,54 @@ cnxk_nix_mtr_profile_delete(struct rte_eth_dev *eth_dev, uint32_t profile_id, + return 0; + } + ++static int ++update_mtr_err(uint32_t act_color, struct rte_mtr_error *error, bool action) ++{ ++ const char *str; ++ switch (act_color) { ++ case RTE_COLOR_GREEN: ++ if (action) { ++ str = "Green action is not valid"; ++ goto notsup; ++ } else { ++ str = "Green action is null"; ++ goto notvalid; ++ } ++ break; ++ case RTE_COLOR_YELLOW: ++ if (action) { ++ str = "Yellow action is not valid"; ++ goto notsup; ++ } else { ++ str = "Yellow action is null"; ++ goto notvalid; ++ } ++ break; ++ case RTE_COLOR_RED: ++ if (action) { ++ str = "Red action is not valid"; ++ goto notsup; ++ } else { ++ str = "Red action is null"; ++ goto notvalid; ++ } ++ break; ++ } ++notsup: ++ return -rte_mtr_error_set(error, ENOTSUP, ++ RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, str); ++notvalid: ++ return -rte_mtr_error_set(error, EINVAL, ++ RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, str); ++} ++ + static int + cnxk_nix_mtr_policy_validate(struct rte_eth_dev *dev, + struct rte_mtr_meter_policy_params *policy, + struct rte_mtr_error *error) + { +- static const char *const action_color[] = {"Green", "Yellow", "Red"}; + bool supported[RTE_COLORS] = {false, false, false}; + const struct rte_flow_action *action; +- char message[1024]; + uint32_t i; + + RTE_SET_USED(dev); +@@ -304,21 +343,11 @@ cnxk_nix_mtr_policy_validate(struct rte_eth_dev *dev, + if (action->type == RTE_FLOW_ACTION_TYPE_DROP) + supported[i] = true; + +- if (!supported[i]) { +- sprintf(message, +- "%s action is not valid", +- action_color[i]); +- return -rte_mtr_error_set(error, +- ENOTSUP, +- RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, +- message); +- } ++ if (!supported[i]) ++ return update_mtr_err(i, error, true); + } + } else { +- sprintf(message, "%s action is null", action_color[i]); +- return -rte_mtr_error_set(error, EINVAL, +- RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, +- message); ++ return update_mtr_err(i, error, false); + } + } + +-- +2.23.0 + diff --git a/0316-net-cnxk-fix-build-with-optimization.patch b/0316-net-cnxk-fix-build-with-optimization.patch new file mode 100644 index 0000000..70981ed --- /dev/null +++ b/0316-net-cnxk-fix-build-with-optimization.patch @@ -0,0 +1,44 @@ +From 213001231857c9af72f8f0288c43773b1ac2d580 Mon Sep 17 00:00:00 2001 +From: Rakesh Kudurumalla +Date: Fri, 4 Mar 2022 19:53:37 +0530 +Subject: [PATCH] net/cnxk: fix build with optimization +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 68f8a52a6b0ad6b77772d4564928aebb21c2ca66 ] + +Fix the following build error seen with --optimization=1 and +GCC 10.3.0. + +drivers/net/cnxk/cnxk_ethdev_mtr.c: In function +‘cnxk_nix_mtr_policy_validate’: +lib/ethdev/rte_mtr_driver.h:188:10: error: ‘str’ may be used +uninitialized in this function [-Werror=maybe-uninitialized] + +Bugzilla ID: 939 +Bugzilla ID: 992 +Fixes: b526599020ef ("net/cnxk: fix build with GCC 12") + +Reported-by: Ferruh Yigit +Signed-off-by: Rakesh Kudurumalla +--- + drivers/net/cnxk/cnxk_ethdev_mtr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c +index 6d14c88e7d..b6ccccdc39 100644 +--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c ++++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c +@@ -280,7 +280,7 @@ cnxk_nix_mtr_profile_delete(struct rte_eth_dev *eth_dev, uint32_t profile_id, + static int + update_mtr_err(uint32_t act_color, struct rte_mtr_error *error, bool action) + { +- const char *str; ++ const char *str = NULL; + switch (act_color) { + case RTE_COLOR_GREEN: + if (action) { +-- +2.23.0 + diff --git a/0317-crypto-ipsec_mb-fix-build-with-GCC-12.patch b/0317-crypto-ipsec_mb-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..782ec22 --- /dev/null +++ b/0317-crypto-ipsec_mb-fix-build-with-GCC-12.patch @@ -0,0 +1,73 @@ +From c86456efc916bff6ecb9b6ab9664c9409d1a3fe2 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 18 May 2022 12:16:48 +0200 +Subject: [PATCH] crypto/ipsec_mb: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 468f31eb71c4c2aa454841b316766514cabd0f02 ] + +GCC 12 raises the following warning: + +In function ‘__rte_ring_enqueue_elems_64’, + inlined from ‘__rte_ring_enqueue_elems’ at + ../lib/ring/rte_ring_elem_pvt.h:130:3, + inlined from ‘__rte_ring_do_hts_enqueue_elem’ at + ../lib/ring/rte_ring_hts_elem_pvt.h:196:3, + inlined from ‘rte_ring_mp_hts_enqueue_burst_elem’ at + ../lib/ring/rte_ring_hts.h:110:9, + inlined from ‘rte_ring_enqueue_burst_elem’ at + ../lib/ring/rte_ring_elem.h:577:10, + inlined from ‘rte_ring_enqueue_burst’ at + ../lib/ring/rte_ring.h:738:9, + inlined from ‘process_op_bit’ at + ../drivers/crypto/ipsec_mb/pmd_snow3g.c:425:16, + inlined from ‘snow3g_pmd_dequeue_burst’ at + ../drivers/crypto/ipsec_mb/pmd_snow3g.c:484:20: +../lib/ring/rte_ring_elem_pvt.h:68:44: error: array subscript 1 is + outside array bounds of ‘struct rte_crypto_op[0]’ + [-Werror=array-bounds] + 68 | ring[idx + 1] = obj[i + 1]; + | ~~~^~~~~~~ +../drivers/crypto/ipsec_mb/pmd_snow3g.c: In function + ‘snow3g_pmd_dequeue_burst’: +../drivers/crypto/ipsec_mb/pmd_snow3g.c:434:1: note: + at offset 8 into object ‘op’ of size 8 + 434 | snow3g_pmd_dequeue_burst(void *queue_pair, + | ^~~~~~~~~~~~~~~~~~~~~~~~ + +Validate that one (exactly) op has been processed or return early. + +Fixes: b537abdbee74 ("crypto/snow3g: support bit-level operations") + +Signed-off-by: David Marchand +Acked-by: Stephen Hemminger +--- + drivers/crypto/ipsec_mb/pmd_snow3g.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c +index ebc9a0b562..9a85f46721 100644 +--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c ++++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c +@@ -422,12 +422,13 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session, + op->sym->session = NULL; + } + +- enqueued_op = rte_ring_enqueue_burst(qp->ingress_queue, +- (void **)&op, processed_op, NULL); ++ if (unlikely(processed_op != 1)) ++ return 0; ++ enqueued_op = rte_ring_enqueue(qp->ingress_queue, op); + qp->stats.enqueued_count += enqueued_op; + *accumulated_enqueued_ops += enqueued_op; + +- return enqueued_op; ++ return 1; + } + + static uint16_t +-- +2.23.0 + diff --git a/0318-net-ena-fix-build-with-GCC-12.patch b/0318-net-ena-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..0dba83d --- /dev/null +++ b/0318-net-ena-fix-build-with-GCC-12.patch @@ -0,0 +1,65 @@ +From 9c1822f59fc41558231b6e67d6feac5a225fcbdb Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 18 May 2022 12:16:49 +0200 +Subject: [PATCH] net/ena: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 2449949584667fbb275df1ea5a5ceeead1a65786 ] + +GCC 12 raises the following warning: + +In file included from ../lib/mempool/rte_mempool.h:46, + from ../lib/mbuf/rte_mbuf.h:38, + from ../lib/net/rte_ether.h:22, + from ../drivers/net/ena/ena_ethdev.h:10, + from ../drivers/net/ena/ena_rss.c:6: +../drivers/net/ena/ena_rss.c: In function ‘ena_rss_key_fill’: +../lib/eal/x86/include/rte_memcpy.h:370:9: warning: array subscript 64 is + outside array bounds of ‘uint8_t[40]’ + {aka ‘unsigned char[40]’} [-Warray-bounds] + 370 | rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +../drivers/net/ena/ena_rss.c:51:24: note: while referencing ‘default_key’ + 51 | static uint8_t default_key[ENA_HASH_KEY_SIZE]; + | ^~~~~~~~~~~ + +This is a false positive because the copied size is checked against +ENA_HASH_KEY_SIZE in a (build) assert. +Silence this warning by calling memcpy with the minimal size. + +Bugzilla ID: 849 + +Signed-off-by: David Marchand +Acked-by: Stephen Hemminger +--- + drivers/net/ena/ena_rss.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/ena/ena_rss.c b/drivers/net/ena/ena_rss.c +index be4007e3f3..8193eaf6fc 100644 +--- a/drivers/net/ena/ena_rss.c ++++ b/drivers/net/ena/ena_rss.c +@@ -51,15 +51,14 @@ void ena_rss_key_fill(void *key, size_t size) + static uint8_t default_key[ENA_HASH_KEY_SIZE]; + size_t i; + +- RTE_ASSERT(size <= ENA_HASH_KEY_SIZE); +- + if (!key_generated) { +- for (i = 0; i < ENA_HASH_KEY_SIZE; ++i) ++ for (i = 0; i < RTE_DIM(default_key); ++i) + default_key[i] = rte_rand() & 0xff; + key_generated = true; + } + +- rte_memcpy(key, default_key, size); ++ RTE_ASSERT(size <= sizeof(default_key)); ++ rte_memcpy(key, default_key, RTE_MIN(size, sizeof(default_key))); + } + + int ena_rss_reta_update(struct rte_eth_dev *dev, +-- +2.23.0 + diff --git a/0319-net-enetfec-fix-build-with-GCC-12.patch b/0319-net-enetfec-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..2bc13e4 --- /dev/null +++ b/0319-net-enetfec-fix-build-with-GCC-12.patch @@ -0,0 +1,71 @@ +From ac8e3a7546ecf4c0b0a753c1efd8327e3a3e96f1 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 18 May 2022 12:16:50 +0200 +Subject: [PATCH] net/enetfec: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 7c3c0d0f290cfc03dc0e75013af8035b450ee114 ] + +GCC 12 raises the following warning: + +../drivers/net/enetfec/enet_ethdev.c: In function + ‘enetfec_rx_queue_setup’: +../drivers/net/enetfec/enet_ethdev.c:473:9: error: array + subscript 1 is + above array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’} + [-Werror=array-bounds] + 473 | rte_write32(rte_cpu_to_le_32(fep->bd_addr_p_r[queue_idx]), + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 474 | (uint8_t *)fep->hw_baseaddr_v + ENETFEC_RD_START(queue_idx)); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In file included from ../drivers/net/enetfec/enet_ethdev.c:9: +../drivers/net/enetfec/enet_ethdev.h:113:33: note: while referencing + ‘bd_addr_p_r’ + 113 | uint32_t bd_addr_p_r[ENETFEC_MAX_Q]; + | ^~~~~~~~~~~ + +This driver properly announces that it only supports 1 rxq. +Silence this warning by adding an explicit check on the queue id. + +Signed-off-by: David Marchand +Acked-by: Stephen Hemminger +Acked-by: Sachin Saxena +--- + drivers/net/enetfec/enet_ethdev.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/drivers/net/enetfec/enet_ethdev.c b/drivers/net/enetfec/enet_ethdev.c +index 714f8ac7ec..c938e58204 100644 +--- a/drivers/net/enetfec/enet_ethdev.c ++++ b/drivers/net/enetfec/enet_ethdev.c +@@ -2,9 +2,12 @@ + * Copyright 2020-2021 NXP + */ + ++#include ++ + #include + #include + #include ++ + #include "enet_pmd_logs.h" + #include "enet_ethdev.h" + #include "enet_regs.h" +@@ -454,6 +457,12 @@ enetfec_rx_queue_setup(struct rte_eth_dev *dev, + return -EINVAL; + } + ++ if (queue_idx >= ENETFEC_MAX_Q) { ++ ENETFEC_PMD_ERR("Invalid queue id %" PRIu16 ", max %d\n", ++ queue_idx, ENETFEC_MAX_Q); ++ return -EINVAL; ++ } ++ + /* allocate receive queue */ + rxq = rte_zmalloc(NULL, sizeof(*rxq), RTE_CACHE_LINE_SIZE); + if (rxq == NULL) { +-- +2.23.0 + diff --git a/0320-net-ice-fix-build-with-GCC-12.patch b/0320-net-ice-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..a1fedd7 --- /dev/null +++ b/0320-net-ice-fix-build-with-GCC-12.patch @@ -0,0 +1,56 @@ +From ec6a2fa05c425c42071d164c82d46d0f62ff2e1c Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 18 May 2022 12:16:51 +0200 +Subject: [PATCH] net/ice: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 20d6a017e148cc1944d85d4c80a0151a5b4c6436 ] + +GCC 12 raises the following warning: + +In file included from ../lib/mempool/rte_mempool.h:46, + from ../lib/mbuf/rte_mbuf.h:38, + from ../lib/net/rte_ether.h:22, + from ../lib/ethdev/rte_ethdev.h:172, + from ../lib/ethdev/ethdev_driver.h:22, + from ../lib/ethdev/ethdev_pci.h:17, + from ../drivers/net/ice/ice_ethdev.c:6: +../drivers/net/ice/ice_ethdev.c: In function ‘ice_dev_configure’: +../lib/eal/x86/include/rte_memcpy.h:370:9: warning: array subscript 64 is + outside array bounds of ‘struct ice_aqc_get_set_rss_keys[1]’ + [-Warray-bounds] + 370 | rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +../drivers/net/ice/ice_ethdev.c:3202:41: note: while referencing ‘key’ + 3202 | struct ice_aqc_get_set_rss_keys key; + | ^~~ + +Restrict copy to minimum size. + +Bugzilla ID: 850 + +Signed-off-by: David Marchand +Acked-by: Stephen Hemminger +--- + drivers/net/ice/ice_ethdev.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c +index ab3976a319..7df1b4ec19 100644 +--- a/drivers/net/ice/ice_ethdev.c ++++ b/drivers/net/ice/ice_ethdev.c +@@ -3235,7 +3235,8 @@ static int ice_init_rss(struct ice_pf *pf) + RTE_MIN(rss_conf->rss_key_len, + vsi->rss_key_size)); + +- rte_memcpy(key.standard_rss_key, vsi->rss_key, vsi->rss_key_size); ++ rte_memcpy(key.standard_rss_key, vsi->rss_key, ++ RTE_MIN(sizeof(key.standard_rss_key), vsi->rss_key_size)); + ret = ice_aq_set_rss_key(hw, vsi->idx, &key); + if (ret) + goto out; +-- +2.23.0 + diff --git a/0321-vdpa-ifc-fix-build-with-GCC-12.patch b/0321-vdpa-ifc-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..608843f --- /dev/null +++ b/0321-vdpa-ifc-fix-build-with-GCC-12.patch @@ -0,0 +1,49 @@ +From f85d0fc3975bb20a6cdbbef21408f3d8d00e2a3f Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 18 May 2022 12:16:54 +0200 +Subject: [PATCH] vdpa/ifc: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 2a213b794fdd255fde7581a7c9bd034ab39e9b6a ] + +GCC 12 raises the following warning: + +../drivers/vdpa/ifc/ifcvf_vdpa.c: In function ‘vdpa_enable_vfio_intr’: +../drivers/vdpa/ifc/ifcvf_vdpa.c:383:62: error: writing 4 bytes into a + region of size 0 [-Werror=stringop-overflow=] + 383 | fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = fd; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ +../drivers/vdpa/ifc/ifcvf_vdpa.c:348:14: note: at offset 32 into + destination object ‘irq_set_buf’ of size 32 + 348 | char irq_set_buf[MSIX_IRQ_SET_BUF_LEN]; + | ^~~~~~~~~~~ + +Validate number of vrings to avoid out of bound access. + +Bugzilla ID: 855 + +Signed-off-by: David Marchand +Acked-by: Xiao Wang +Acked-by: Stephen Hemminger +--- + drivers/vdpa/ifc/ifcvf_vdpa.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c +index 3853c4cf7e..6a915b0d5e 100644 +--- a/drivers/vdpa/ifc/ifcvf_vdpa.c ++++ b/drivers/vdpa/ifc/ifcvf_vdpa.c +@@ -356,6 +356,8 @@ vdpa_enable_vfio_intr(struct ifcvf_internal *internal, bool m_rx) + vring.callfd = -1; + + nr_vring = rte_vhost_get_vring_num(internal->vid); ++ if (nr_vring > IFCVF_MAX_QUEUES * 2) ++ return -1; + + irq_set = (struct vfio_irq_set *)irq_set_buf; + irq_set->argsz = sizeof(irq_set_buf); +-- +2.23.0 + diff --git a/0322-app-flow-perf-fix-build-with-GCC-12.patch b/0322-app-flow-perf-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..faf27f7 --- /dev/null +++ b/0322-app-flow-perf-fix-build-with-GCC-12.patch @@ -0,0 +1,134 @@ +From 675b5bdf2c1434493f508f6cf909e33ed0e019b5 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 18 May 2022 12:16:56 +0200 +Subject: [PATCH] app/flow-perf: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 5fc2eece8d4530988e5681fdc8a35e14d69b2a6f ] + +GCC 12 raises the following warning: + +../app/test-flow-perf/main.c: In function ‘start_forwarding’: +../app/test-flow-perf/main.c:1737:28: error: ‘sprintf’ may write a + terminating nul past the end of the destination + [-Werror=format-overflow=] + 1737 | sprintf(p[i++], "%d", (int)n); + | ^ +In function ‘pretty_number’, + inlined from ‘packet_per_second_stats’ at + ../app/test-flow-perf/main.c:1792:4, + inlined from ‘start_forwarding’ at + ../app/test-flow-perf/main.c:1831:3: +[...] + +We can simplify this code and rely on libc integer formatting via +this system locales. + +Bugzilla ID: 856 + +Signed-off-by: David Marchand +Acked-by: Bruce Richardson +Acked-by: Stephen Hemminger +--- + app/test-flow-perf/main.c | 48 ++++++++------------------------------- + 1 file changed, 9 insertions(+), 39 deletions(-) + +diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c +index 56d43734e3..f375097028 100644 +--- a/app/test-flow-perf/main.c ++++ b/app/test-flow-perf/main.c +@@ -16,6 +16,7 @@ + * gives packet per second measurement. + */ + ++#include + #include + #include + #include +@@ -1713,36 +1714,6 @@ do_tx(struct lcore_info *li, uint16_t cnt, uint16_t tx_port, + rte_pktmbuf_free(li->pkts[i]); + } + +-/* +- * Method to convert numbers into pretty numbers that easy +- * to read. The design here is to add comma after each three +- * digits and set all of this inside buffer. +- * +- * For example if n = 1799321, the output will be +- * 1,799,321 after this method which is easier to read. +- */ +-static char * +-pretty_number(uint64_t n, char *buf) +-{ +- char p[6][4]; +- int i = 0; +- int off = 0; +- +- while (n > 1000) { +- sprintf(p[i], "%03d", (int)(n % 1000)); +- n /= 1000; +- i += 1; +- } +- +- sprintf(p[i++], "%d", (int)n); +- +- while (i--) +- off += sprintf(buf + off, "%s,", p[i]); +- buf[strlen(buf) - 1] = '\0'; +- +- return buf; +-} +- + static void + packet_per_second_stats(void) + { +@@ -1764,7 +1735,6 @@ packet_per_second_stats(void) + uint64_t total_rx_pkts = 0; + uint64_t total_tx_drops = 0; + uint64_t tx_delta, rx_delta, drops_delta; +- char buf[3][32]; + int nr_valid_core = 0; + + sleep(1); +@@ -1789,10 +1759,8 @@ packet_per_second_stats(void) + tx_delta = li->tx_pkts - oli->tx_pkts; + rx_delta = li->rx_pkts - oli->rx_pkts; + drops_delta = li->tx_drops - oli->tx_drops; +- printf("%6d %16s %16s %16s\n", i, +- pretty_number(tx_delta, buf[0]), +- pretty_number(drops_delta, buf[1]), +- pretty_number(rx_delta, buf[2])); ++ printf("%6d %'16"PRId64" %'16"PRId64" %'16"PRId64"\n", ++ i, tx_delta, drops_delta, rx_delta); + + total_tx_pkts += tx_delta; + total_rx_pkts += rx_delta; +@@ -1803,10 +1771,9 @@ packet_per_second_stats(void) + } + + if (nr_valid_core > 1) { +- printf("%6s %16s %16s %16s\n", "total", +- pretty_number(total_tx_pkts, buf[0]), +- pretty_number(total_tx_drops, buf[1]), +- pretty_number(total_rx_pkts, buf[2])); ++ printf("%6s %'16"PRId64" %'16"PRId64" %'16"PRId64"\n", ++ "total", total_tx_pkts, total_tx_drops, ++ total_rx_pkts); + nr_lines += 1; + } + +@@ -2139,6 +2106,9 @@ main(int argc, char **argv) + if (argc > 1) + args_parse(argc, argv); + ++ /* For more fancy, localised integer formatting. */ ++ setlocale(LC_NUMERIC, ""); ++ + init_port(); + + nb_lcores = rte_lcore_count(); +-- +2.23.0 + diff --git a/0323-common-cpt-fix-build-with-GCC-12.patch b/0323-common-cpt-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..ed498bb --- /dev/null +++ b/0323-common-cpt-fix-build-with-GCC-12.patch @@ -0,0 +1,113 @@ +From 978835ed87a361a24e0c4424f1a352d13fb7bfac Mon Sep 17 00:00:00 2001 +From: Ankur Dwivedi +Date: Fri, 17 Jun 2022 19:09:29 +0530 +Subject: [PATCH] common/cpt: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 3aa16821ab3e0a21052880fbf4dcb76801380c31 ] + +The following warning is observed with GCC 12 compilation: + +In function ‘fill_sg_comp_from_iov’, + inlined from ‘cpt_zuc_snow3g_enc_prep’ at + ../drivers/common/cpt/cpt_ucode.h:1672:9, + inlined from ‘cpt_fc_enc_hmac_prep’ at + ../drivers/common/cpt/cpt_ucode.h:2472:3, + inlined from ‘fill_digest_params’ at + ../drivers/common/cpt/cpt_ucode.h:3548:14, + inlined from ‘otx_cpt_enq_single_sym’ at + ../drivers/crypto/octeontx/otx_cryptodev_ops.c:541:9, + inlined from ‘otx_cpt_enq_single_sym_sessless’ at + ../drivers/crypto/octeontx/otx_cryptodev_ops.c:584:8, + inlined from ‘otx_cpt_enq_single’ at + ../drivers/crypto/octeontx/otx_cryptodev_ops.c:611:11, + inlined from ‘otx_cpt_pkt_enqueue’ at + ../drivers/crypto/octeontx/otx_cryptodev_ops.c:643:9, + inlined from ‘otx_cpt_enqueue_sym’ at + ../drivers/crypto/octeontx/otx_cryptodev_ops.c:668:9: +../drivers/common/cpt/cpt_ucode.h:415:36: warning: array subscript 0 is +outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’} +[-Warray-bounds] + 415 | e_dma_addr = bufs[j].dma_addr; + | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ +../drivers/common/cpt/cpt_ucode.h:416:48: warning: array subscript 0 is +outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’} +[-Warray-bounds] + 416 | e_len = (size > bufs[j].size) ? + | ~~~~~~~^~~~~ + +This patch resolves the warning. + +Bugzilla ID: 861 +Fixes: 9be415daf469 ("common/cpt: add common defines for microcode") +Fixes: b74652f3a91f ("common/cpt: add microcode interface for encryption") + +Signed-off-by: Ankur Dwivedi +Reviewed-by: Anoob Joseph +Reviewed-by: Jerin Jacob +Tested-by: David Marchand +--- + drivers/common/cpt/cpt_mcode_defines.h | 2 +- + drivers/common/cpt/cpt_ucode.h | 21 ++++++++++----------- + 2 files changed, 11 insertions(+), 12 deletions(-) + +diff --git a/drivers/common/cpt/cpt_mcode_defines.h b/drivers/common/cpt/cpt_mcode_defines.h +index f16ee44297..e6dcb7674c 100644 +--- a/drivers/common/cpt/cpt_mcode_defines.h ++++ b/drivers/common/cpt/cpt_mcode_defines.h +@@ -387,7 +387,7 @@ typedef struct buf_ptr { + /* IOV Pointer */ + typedef struct{ + int buf_cnt; +- buf_ptr_t bufs[0]; ++ buf_ptr_t bufs[]; + } iov_ptr_t; + + typedef struct fc_params { +diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h +index e1f2f6005d..22aabab6ac 100644 +--- a/drivers/common/cpt/cpt_ucode.h ++++ b/drivers/common/cpt/cpt_ucode.h +@@ -394,27 +394,26 @@ fill_sg_comp_from_iov(sg_comp_t *list, + int32_t j; + uint32_t extra_len = extra_buf ? extra_buf->size : 0; + uint32_t size = *psize; +- buf_ptr_t *bufs; + +- bufs = from->bufs; + for (j = 0; (j < from->buf_cnt) && size; j++) { ++ phys_addr_t dma_addr = from->bufs[j].dma_addr; ++ uint32_t buf_sz = from->bufs[j].size; ++ sg_comp_t *to = &list[i >> 2]; + phys_addr_t e_dma_addr; + uint32_t e_len; +- sg_comp_t *to = &list[i >> 2]; + + if (unlikely(from_offset)) { +- if (from_offset >= bufs[j].size) { +- from_offset -= bufs[j].size; ++ if (from_offset >= buf_sz) { ++ from_offset -= buf_sz; + continue; + } +- e_dma_addr = bufs[j].dma_addr + from_offset; +- e_len = (size > (bufs[j].size - from_offset)) ? +- (bufs[j].size - from_offset) : size; ++ e_dma_addr = dma_addr + from_offset; ++ e_len = (size > (buf_sz - from_offset)) ? ++ (buf_sz - from_offset) : size; + from_offset = 0; + } else { +- e_dma_addr = bufs[j].dma_addr; +- e_len = (size > bufs[j].size) ? +- bufs[j].size : size; ++ e_dma_addr = dma_addr; ++ e_len = (size > buf_sz) ? buf_sz : size; + } + + to->u.s.len[i % 4] = rte_cpu_to_be_16(e_len); +-- +2.23.0 + diff --git a/0324-crypto-cnxk-fix-build-with-GCC-12.patch b/0324-crypto-cnxk-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..02b8985 --- /dev/null +++ b/0324-crypto-cnxk-fix-build-with-GCC-12.patch @@ -0,0 +1,90 @@ +From e0bff8480fce6437124558f49f608f214c9092be Mon Sep 17 00:00:00 2001 +From: Ankur Dwivedi +Date: Fri, 17 Jun 2022 19:09:30 +0530 +Subject: [PATCH] crypto/cnxk: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit d82d2db2659411059c047a96e867666625a0f1f2 ] + +The following warning is observed with GCC 12 compilation: + +In file included from ../drivers/crypto/cnxk/cn10k_cryptodev_ops.c:17: +In function ‘fill_sg_comp_from_iov’, + inlined from ‘cpt_pdcp_chain_alg_prep’ at + ../drivers/crypto/cnxk/cnxk_se.h:1194:8, + inlined from ‘cpt_fc_enc_hmac_prep’ at + ../drivers/crypto/cnxk/cnxk_se.h:1871:9, + inlined from ‘fill_digest_params’ at + ../drivers/crypto/cnxk/cnxk_se.h:2829:8, + inlined from ‘cpt_sym_inst_fill’ at + ../drivers/crypto/cnxk/cn10k_cryptodev_ops.c:92:9, + inlined from ‘cn10k_cpt_fill_inst.constprop’ at + ../drivers/crypto/cnxk/cn10k_cryptodev_ops.c:146:10: +../drivers/crypto/cnxk/cnxk_se.h:222:52: warning: array subscript 0 is +outside array bounds of ‘struct roc_se_buf_ptr[0]’ [-Warray-bounds] + 222 | e_vaddr = (uint64_t)bufs[j].vaddr; + | ~~~~~~~^~~~~~ +../drivers/crypto/cnxk/cnxk_se.h:223:48: warning: array subscript 0 is +outside array bounds of ‘struct roc_se_buf_ptr[0]’ [-Warray-bounds] + 223 | e_len = (size > bufs[j].size) ? bufs[j].size : size; + | ~~~~~~~^~~~~ + +This patch resolves the warning. + +Fixes: 3de331795f73 ("crypto/cnxk: add flexi cipher encryption") + +Signed-off-by: Ankur Dwivedi +Reviewed-by: Anoob Joseph +Reviewed-by: Jerin Jacob +Tested-by: David Marchand +--- + drivers/crypto/cnxk/cnxk_se.h | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h +index 37237de21a..99a2894fa6 100644 +--- a/drivers/crypto/cnxk/cnxk_se.h ++++ b/drivers/crypto/cnxk/cnxk_se.h +@@ -179,27 +179,27 @@ fill_sg_comp_from_iov(struct roc_se_sglist_comp *list, uint32_t i, + int32_t j; + uint32_t extra_len = extra_buf ? extra_buf->size : 0; + uint32_t size = *psize; +- struct roc_se_buf_ptr *bufs; + +- bufs = from->bufs; + for (j = 0; (j < from->buf_cnt) && size; j++) { ++ struct roc_se_sglist_comp *to = &list[i >> 2]; ++ uint32_t buf_sz = from->bufs[j].size; ++ void *vaddr = from->bufs[j].vaddr; + uint64_t e_vaddr; + uint32_t e_len; +- struct roc_se_sglist_comp *to = &list[i >> 2]; + + if (unlikely(from_offset)) { +- if (from_offset >= bufs[j].size) { +- from_offset -= bufs[j].size; ++ if (from_offset >= buf_sz) { ++ from_offset -= buf_sz; + continue; + } +- e_vaddr = (uint64_t)bufs[j].vaddr + from_offset; +- e_len = (size > (bufs[j].size - from_offset)) ? +- (bufs[j].size - from_offset) : ++ e_vaddr = (uint64_t)vaddr + from_offset; ++ e_len = (size > (buf_sz - from_offset)) ? ++ (buf_sz - from_offset) : + size; + from_offset = 0; + } else { +- e_vaddr = (uint64_t)bufs[j].vaddr; +- e_len = (size > bufs[j].size) ? bufs[j].size : size; ++ e_vaddr = (uint64_t)vaddr; ++ e_len = (size > buf_sz) ? buf_sz : size; + } + + to->u.s.len[i % 4] = rte_cpu_to_be_16(e_len); +-- +2.23.0 + diff --git a/0325-test-ipsec-fix-build-with-GCC-12.patch b/0325-test-ipsec-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..e74fae9 --- /dev/null +++ b/0325-test-ipsec-fix-build-with-GCC-12.patch @@ -0,0 +1,152 @@ +From 9445fcf1388068915ae4c0cebbac527482b39215 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Thu, 16 Jun 2022 11:33:20 +0200 +Subject: [PATCH] test/ipsec: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 6e108b6a7c0c0699e6304f7b5706736b34d32607 ] + +GCC 12 raises the following warning: + +In function ‘_mm256_loadu_si256’, + inlined from ‘rte_mov32’ at + ../lib/eal/x86/include/rte_memcpy.h:319:9, + inlined from ‘rte_mov128’ at + ../lib/eal/x86/include/rte_memcpy.h:344:2, + inlined from ‘rte_memcpy_generic’ at + ../lib/eal/x86/include/rte_memcpy.h:438:4, + inlined from ‘rte_memcpy’ at + ../lib/eal/x86/include/rte_memcpy.h:882:10, + inlined from ‘setup_test_string.constprop’ at + ../app/test/test_ipsec.c:572:4: +/usr/lib/gcc/x86_64-redhat-linux/12/include/avxintrin.h:929:10: error: + array subscript ‘__m256i_u[3]’ is partly outside array bounds of + ‘const char[108]’ [-Werror=array-bounds] + 929 | return *__P; + | ^~~~ +../app/test/test_ipsec.c: In function ‘setup_test_string.constprop’: +../app/test/test_ipsec.c:539:12: note: at offset 96 into object + ‘null_plain_data’ of size 108 + 539 | const char null_plain_data[] = + | ^~~~~~~~~~~~~~~ + +Add a hint so that the compiler understands the copied data is within +the passed string boundaries. + +Bugzilla ID: 848 +Fixes: 05fe65eb66b2 ("test/ipsec: introduce functional test") + +Signed-off-by: David Marchand +--- + app/test/test_ipsec.c | 35 ++++++++++++++++++++++------------- + 1 file changed, 22 insertions(+), 13 deletions(-) + +diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c +index bc2a3dbc2e..3c6dcdc604 100644 +--- a/app/test/test_ipsec.c ++++ b/app/test/test_ipsec.c +@@ -543,12 +543,14 @@ struct rte_ipv4_hdr ipv4_outer = { + }; + + static struct rte_mbuf * +-setup_test_string(struct rte_mempool *mpool, +- const char *string, size_t len, uint8_t blocksize) ++setup_test_string(struct rte_mempool *mpool, const char *string, ++ size_t string_len, size_t len, uint8_t blocksize) + { + struct rte_mbuf *m = rte_pktmbuf_alloc(mpool); + size_t t_len = len - (blocksize ? (len % blocksize) : 0); + ++ RTE_VERIFY(len <= string_len); ++ + if (m) { + memset(m->buf_addr, 0, m->buf_len); + char *dst = rte_pktmbuf_append(m, t_len); +@@ -1354,7 +1356,8 @@ test_ipsec_crypto_outb_burst_null_null(int i) + /* Generate input mbuf data */ + for (j = 0; j < num_pkts && rc == 0; j++) { + ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool, +- null_plain_data, test_cfg[i].pkt_sz, 0); ++ null_plain_data, sizeof(null_plain_data), ++ test_cfg[i].pkt_sz, 0); + if (ut_params->ibuf[j] == NULL) + rc = TEST_FAILED; + else { +@@ -1472,7 +1475,8 @@ test_ipsec_inline_crypto_inb_burst_null_null(int i) + /* Generate test mbuf data */ + ut_params->obuf[j] = setup_test_string( + ts_params->mbuf_pool, +- null_plain_data, test_cfg[i].pkt_sz, 0); ++ null_plain_data, sizeof(null_plain_data), ++ test_cfg[i].pkt_sz, 0); + if (ut_params->obuf[j] == NULL) + rc = TEST_FAILED; + } +@@ -1540,16 +1544,17 @@ test_ipsec_inline_proto_inb_burst_null_null(int i) + + /* Generate inbound mbuf data */ + for (j = 0; j < num_pkts && rc == 0; j++) { +- ut_params->ibuf[j] = setup_test_string( +- ts_params->mbuf_pool, +- null_plain_data, test_cfg[i].pkt_sz, 0); ++ ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool, ++ null_plain_data, sizeof(null_plain_data), ++ test_cfg[i].pkt_sz, 0); + if (ut_params->ibuf[j] == NULL) + rc = TEST_FAILED; + else { + /* Generate test mbuf data */ + ut_params->obuf[j] = setup_test_string( + ts_params->mbuf_pool, +- null_plain_data, test_cfg[i].pkt_sz, 0); ++ null_plain_data, sizeof(null_plain_data), ++ test_cfg[i].pkt_sz, 0); + if (ut_params->obuf[j] == NULL) + rc = TEST_FAILED; + } +@@ -1649,7 +1654,8 @@ test_ipsec_inline_crypto_outb_burst_null_null(int i) + /* Generate test mbuf data */ + for (j = 0; j < num_pkts && rc == 0; j++) { + ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool, +- null_plain_data, test_cfg[i].pkt_sz, 0); ++ null_plain_data, sizeof(null_plain_data), ++ test_cfg[i].pkt_sz, 0); + if (ut_params->ibuf[0] == NULL) + rc = TEST_FAILED; + +@@ -1727,15 +1733,17 @@ test_ipsec_inline_proto_outb_burst_null_null(int i) + /* Generate test mbuf data */ + for (j = 0; j < num_pkts && rc == 0; j++) { + ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool, +- null_plain_data, test_cfg[i].pkt_sz, 0); ++ null_plain_data, sizeof(null_plain_data), ++ test_cfg[i].pkt_sz, 0); + if (ut_params->ibuf[0] == NULL) + rc = TEST_FAILED; + + if (rc == 0) { + /* Generate test tunneled mbuf data for comparison */ + ut_params->obuf[j] = setup_test_string( +- ts_params->mbuf_pool, +- null_plain_data, test_cfg[i].pkt_sz, 0); ++ ts_params->mbuf_pool, null_plain_data, ++ sizeof(null_plain_data), test_cfg[i].pkt_sz, ++ 0); + if (ut_params->obuf[j] == NULL) + rc = TEST_FAILED; + } +@@ -1804,7 +1812,8 @@ test_ipsec_lksd_proto_inb_burst_null_null(int i) + for (j = 0; j < num_pkts && rc == 0; j++) { + /* packet with sequence number 0 is invalid */ + ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool, +- null_encrypted_data, test_cfg[i].pkt_sz, 0); ++ null_encrypted_data, sizeof(null_encrypted_data), ++ test_cfg[i].pkt_sz, 0); + if (ut_params->ibuf[j] == NULL) + rc = TEST_FAILED; + } +-- +2.23.0 + diff --git a/0326-vhost-crypto-fix-build-with-GCC-12.patch b/0326-vhost-crypto-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..e177c3f --- /dev/null +++ b/0326-vhost-crypto-fix-build-with-GCC-12.patch @@ -0,0 +1,221 @@ +From f69a61bde0e2d72021fd3c609fd4b62edc8f8951 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Thu, 16 Jun 2022 16:46:50 +0200 +Subject: [PATCH] vhost/crypto: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 4414bb67010dfec2559af52efe8f479b26d55447 ] + +GCC 12 raises the following warning: + +In file included from ../lib/mempool/rte_mempool.h:46, + from ../lib/mbuf/rte_mbuf.h:38, + from ../lib/vhost/vhost_crypto.c:7: +../lib/vhost/vhost_crypto.c: In function ‘rte_vhost_crypto_fetch_requests’: +../lib/eal/x86/include/rte_memcpy.h:371:9: warning: array subscript 1 is + outside array bounds of ‘struct virtio_crypto_op_data_req[1]’ + [-Warray-bounds] + 371 | rte_mov32((uint8_t *)dst + 3 * 32, (const uint8_t *)src + 3 * 32); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +../lib/vhost/vhost_crypto.c:1178:42: note: while referencing ‘req’ + 1178 | struct virtio_crypto_op_data_req req; + | ^~~ + +Split this function and separate the per descriptor copy. +This makes the code clearer, and the compiler happier. + +Note: logs for errors have been moved to callers to avoid duplicates. + +Fixes: 3c79609fda7c ("vhost/crypto: handle virtually non-contiguous buffers") + +Signed-off-by: David Marchand +Reviewed-by: Maxime Coquelin +--- + lib/vhost/vhost_crypto.c | 123 +++++++++++++++------------------------ + 1 file changed, 46 insertions(+), 77 deletions(-) + +diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c +index 926b5c0bd9..293960d350 100644 +--- a/lib/vhost/vhost_crypto.c ++++ b/lib/vhost/vhost_crypto.c +@@ -565,94 +565,58 @@ get_data_ptr(struct vhost_crypto_data_req *vc_req, + return data; + } + +-static __rte_always_inline int +-copy_data(void *dst_data, struct vhost_crypto_data_req *vc_req, +- struct vhost_crypto_desc *head, +- struct vhost_crypto_desc **cur_desc, +- uint32_t size, uint32_t max_n_descs) ++static __rte_always_inline uint32_t ++copy_data_from_desc(void *dst, struct vhost_crypto_data_req *vc_req, ++ struct vhost_crypto_desc *desc, uint32_t size) + { +- struct vhost_crypto_desc *desc = *cur_desc; +- uint64_t remain, addr, dlen, len; +- uint32_t to_copy; +- uint8_t *data = dst_data; +- uint8_t *src; +- int left = size; +- +- to_copy = RTE_MIN(desc->len, (uint32_t)left); +- dlen = to_copy; +- src = IOVA_TO_VVA(uint8_t *, vc_req, desc->addr, &dlen, +- VHOST_ACCESS_RO); +- if (unlikely(!src || !dlen)) +- return -1; ++ uint64_t remain; ++ uint64_t addr; ++ ++ remain = RTE_MIN(desc->len, size); ++ addr = desc->addr; ++ do { ++ uint64_t len; ++ void *src; ++ ++ len = remain; ++ src = IOVA_TO_VVA(void *, vc_req, addr, &len, VHOST_ACCESS_RO); ++ if (unlikely(src == NULL || len == 0)) ++ return 0; + +- rte_memcpy((uint8_t *)data, src, dlen); +- data += dlen; ++ rte_memcpy(dst, src, len); ++ remain -= len; ++ /* cast is needed for 32-bit architecture */ ++ dst = RTE_PTR_ADD(dst, (size_t)len); ++ addr += len; ++ } while (unlikely(remain != 0)); + +- if (unlikely(dlen < to_copy)) { +- remain = to_copy - dlen; +- addr = desc->addr + dlen; ++ return RTE_MIN(desc->len, size); ++} + +- while (remain) { +- len = remain; +- src = IOVA_TO_VVA(uint8_t *, vc_req, addr, &len, +- VHOST_ACCESS_RO); +- if (unlikely(!src || !len)) { +- VC_LOG_ERR("Failed to map descriptor"); +- return -1; +- } + +- rte_memcpy(data, src, len); +- addr += len; +- remain -= len; +- data += len; +- } +- } ++static __rte_always_inline int ++copy_data(void *data, struct vhost_crypto_data_req *vc_req, ++ struct vhost_crypto_desc *head, struct vhost_crypto_desc **cur_desc, ++ uint32_t size, uint32_t max_n_descs) ++{ ++ struct vhost_crypto_desc *desc = *cur_desc; ++ uint32_t left = size; + +- left -= to_copy; ++ do { ++ uint32_t copied; + +- while (desc >= head && desc - head < (int)max_n_descs && left) { +- desc++; +- to_copy = RTE_MIN(desc->len, (uint32_t)left); +- dlen = to_copy; +- src = IOVA_TO_VVA(uint8_t *, vc_req, desc->addr, &dlen, +- VHOST_ACCESS_RO); +- if (unlikely(!src || !dlen)) { +- VC_LOG_ERR("Failed to map descriptor"); ++ copied = copy_data_from_desc(data, vc_req, desc, left); ++ if (copied == 0) + return -1; +- } +- +- rte_memcpy(data, src, dlen); +- data += dlen; +- +- if (unlikely(dlen < to_copy)) { +- remain = to_copy - dlen; +- addr = desc->addr + dlen; +- +- while (remain) { +- len = remain; +- src = IOVA_TO_VVA(uint8_t *, vc_req, addr, &len, +- VHOST_ACCESS_RO); +- if (unlikely(!src || !len)) { +- VC_LOG_ERR("Failed to map descriptor"); +- return -1; +- } +- +- rte_memcpy(data, src, len); +- addr += len; +- remain -= len; +- data += len; +- } +- } +- +- left -= to_copy; +- } ++ left -= copied; ++ data = RTE_PTR_ADD(data, copied); ++ desc++; ++ } while (desc < head + max_n_descs && left != 0); + +- if (unlikely(left > 0)) { +- VC_LOG_ERR("Incorrect virtio descriptor"); ++ if (unlikely(left != 0)) + return -1; +- } + +- if (unlikely(desc - head == (int)max_n_descs)) ++ if (unlikely(desc == head + max_n_descs)) + *cur_desc = NULL; + else + *cur_desc = desc + 1; +@@ -852,6 +816,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, + /* iv */ + if (unlikely(copy_data(iv_data, vc_req, head, &desc, + cipher->para.iv_len, max_n_descs))) { ++ VC_LOG_ERR("Incorrect virtio descriptor"); + ret = VIRTIO_CRYPTO_BADMSG; + goto error_exit; + } +@@ -883,6 +848,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, + if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), + vc_req, head, &desc, cipher->para.src_data_len, + max_n_descs) < 0)) { ++ VC_LOG_ERR("Incorrect virtio descriptor"); + ret = VIRTIO_CRYPTO_BADMSG; + goto error_exit; + } +@@ -1006,6 +972,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, + /* iv */ + if (unlikely(copy_data(iv_data, vc_req, head, &desc, + chain->para.iv_len, max_n_descs) < 0)) { ++ VC_LOG_ERR("Incorrect virtio descriptor"); + ret = VIRTIO_CRYPTO_BADMSG; + goto error_exit; + } +@@ -1037,6 +1004,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, + if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), + vc_req, head, &desc, chain->para.src_data_len, + max_n_descs) < 0)) { ++ VC_LOG_ERR("Incorrect virtio descriptor"); + ret = VIRTIO_CRYPTO_BADMSG; + goto error_exit; + } +@@ -1121,6 +1089,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, + if (unlikely(copy_data(digest_addr, vc_req, head, &digest_desc, + chain->para.hash_result_len, + max_n_descs) < 0)) { ++ VC_LOG_ERR("Incorrect virtio descriptor"); + ret = VIRTIO_CRYPTO_BADMSG; + goto error_exit; + } +-- +2.23.0 + diff --git a/0327-vhost-crypto-fix-descriptor-processing.patch b/0327-vhost-crypto-fix-descriptor-processing.patch new file mode 100644 index 0000000..96f47e3 --- /dev/null +++ b/0327-vhost-crypto-fix-descriptor-processing.patch @@ -0,0 +1,40 @@ +From d6e4e0f46e27a5eae66ce436b522c7602accf346 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 22 Jun 2022 17:30:20 +0200 +Subject: [PATCH] vhost/crypto: fix descriptor processing + +[ upstream commit 2fbada91545c004f04449500af0c6276900317ab ] + +copy_data was returning a pointer to an increased (off by one) descriptor. +Subsequent calls to copy_data in the library were then failing. +Fix this by incrementing the descriptor only if there is some left data +to copy. + +Fixes: 4414bb67010d ("vhost/crypto: fix build with GCC 12") + +Reported-by: Jakub Poczatek +Signed-off-by: David Marchand +Reviewed-by: Maxime Coquelin +Tested-by: Jakub Poczatek +Acked-by: Fan Zhang +--- + lib/vhost/vhost_crypto.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c +index 293960d350..7d1d6a1861 100644 +--- a/lib/vhost/vhost_crypto.c ++++ b/lib/vhost/vhost_crypto.c +@@ -610,8 +610,7 @@ copy_data(void *data, struct vhost_crypto_data_req *vc_req, + return -1; + left -= copied; + data = RTE_PTR_ADD(data, copied); +- desc++; +- } while (desc < head + max_n_descs && left != 0); ++ } while (left != 0 && ++desc < head + max_n_descs); + + if (unlikely(left != 0)) + return -1; +-- +2.23.0 + diff --git a/0328-net-ice-base-fix-build-with-GCC-12.patch b/0328-net-ice-base-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..1559b6c --- /dev/null +++ b/0328-net-ice-base-fix-build-with-GCC-12.patch @@ -0,0 +1,82 @@ +From cca0819d488f62311320a08fbd669a21fccf4818 Mon Sep 17 00:00:00 2001 +From: Wenxuan Wu +Date: Thu, 23 Jun 2022 17:01:05 +0800 +Subject: [PATCH] net/ice/base: fix build with GCC 12 + +[ upstream commit 3e87e12dc8bcb1d06dafcb302b056fee51deb090 ] + +GCC 12 with -O2 flag would raise the following warning: +../drivers/net/ice/base/ice_switch.c:7220:61: error: writing 1 byte into a +region of size 0 [-Werror=stringop-overflow=] + 7220 | buf[recps].content.lkup_indx[i + 1] = entry->fv_idx[i]; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ + +This patch changed the type of fv_idx in struct ice_recp_grp_entry to +align with its callers which are also u8 type. + +Fixes: 04b8ec1ea807 ("net/ice/base: add protocol structures and defines") + +Signed-off-by: Wenxuan Wu +Acked-by: Qi Zhang +--- + drivers/net/ice/base/ice_flex_pipe.c | 2 +- + drivers/net/ice/base/ice_flex_pipe.h | 2 +- + drivers/net/ice/base/ice_protocol_type.h | 2 +- + drivers/net/ice/base/ice_switch.h | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c +index f6a29f87c5..3918169001 100644 +--- a/drivers/net/ice/base/ice_flex_pipe.c ++++ b/drivers/net/ice/base/ice_flex_pipe.c +@@ -2564,7 +2564,7 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all) + * @off: variable to receive the protocol offset + */ + enum ice_status +-ice_find_prot_off(struct ice_hw *hw, enum ice_block blk, u8 prof, u16 fv_idx, ++ice_find_prot_off(struct ice_hw *hw, enum ice_block blk, u8 prof, u8 fv_idx, + u8 *prot, u16 *off) + { + struct ice_fv_word *fv_ext; +diff --git a/drivers/net/ice/base/ice_flex_pipe.h b/drivers/net/ice/base/ice_flex_pipe.h +index 23ba45564a..ab897de4f3 100644 +--- a/drivers/net/ice/base/ice_flex_pipe.h ++++ b/drivers/net/ice/base/ice_flex_pipe.h +@@ -25,7 +25,7 @@ enum ice_status + ice_acquire_change_lock(struct ice_hw *hw, enum ice_aq_res_access_type access); + void ice_release_change_lock(struct ice_hw *hw); + enum ice_status +-ice_find_prot_off(struct ice_hw *hw, enum ice_block blk, u8 prof, u16 fv_idx, ++ice_find_prot_off(struct ice_hw *hw, enum ice_block blk, u8 prof, u8 fv_idx, + u8 *prot, u16 *off); + enum ice_status + ice_find_label_value(struct ice_seg *ice_seg, char const *name, u32 type, +diff --git a/drivers/net/ice/base/ice_protocol_type.h b/drivers/net/ice/base/ice_protocol_type.h +index 7dcc983707..d27ef46713 100644 +--- a/drivers/net/ice/base/ice_protocol_type.h ++++ b/drivers/net/ice/base/ice_protocol_type.h +@@ -423,7 +423,7 @@ struct ice_recp_grp_entry { + #define ICE_INVAL_CHAIN_IND 0xFF + u16 rid; + u8 chain_idx; +- u16 fv_idx[ICE_NUM_WORDS_RECIPE]; ++ u8 fv_idx[ICE_NUM_WORDS_RECIPE]; + u16 fv_mask[ICE_NUM_WORDS_RECIPE]; + struct ice_pref_recipe_group r_group; + }; +diff --git a/drivers/net/ice/base/ice_switch.h b/drivers/net/ice/base/ice_switch.h +index a2b3c80107..c67cd09d21 100644 +--- a/drivers/net/ice/base/ice_switch.h ++++ b/drivers/net/ice/base/ice_switch.h +@@ -203,7 +203,7 @@ struct ice_fltr_info { + + struct ice_update_recipe_lkup_idx_params { + u16 rid; +- u16 fv_idx; ++ u8 fv_idx; + bool ignore_valid; + u16 mask; + bool mask_valid; +-- +2.23.0 + diff --git a/0329-net-qede-fix-build-with-GCC-12.patch b/0329-net-qede-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..ebf8b8e --- /dev/null +++ b/0329-net-qede-fix-build-with-GCC-12.patch @@ -0,0 +1,155 @@ +From e4939398dfe939e8f1c91c04734ea83f335a8d37 Mon Sep 17 00:00:00 2001 +From: Stephen Hemminger +Date: Tue, 7 Jun 2022 10:17:40 -0700 +Subject: [PATCH] net/qede: fix build with GCC 12 + +[ upstream commit 4200c4d62586985d70ad69ed7bee526a282b8777 ] + +The x86 version of rte_memcpy can cause warnings. The driver does +not need to use rte_memcpy for everything. Standard memcpy is +just as fast and safer; the compiler and static analysis tools +treat memcpy specially. + +Signed-off-by: Stephen Hemminger +--- + drivers/net/qede/base/bcm_osal.h | 3 +-- + drivers/net/qede/qede_ethdev.c | 2 +- + drivers/net/qede/qede_filter.c | 16 ++++++---------- + drivers/net/qede/qede_main.c | 13 ++++++------- + drivers/net/qede/qede_sriov.c | 6 +++--- + 5 files changed, 17 insertions(+), 23 deletions(-) + +diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h +index c5b5399282..9ea579bfc8 100644 +--- a/drivers/net/qede/base/bcm_osal.h ++++ b/drivers/net/qede/base/bcm_osal.h +@@ -14,7 +14,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -99,7 +98,7 @@ typedef intptr_t osal_int_ptr_t; + } while (0) + #define OSAL_VFREE(dev, memory) OSAL_FREE(dev, memory) + #define OSAL_MEM_ZERO(mem, size) bzero(mem, size) +-#define OSAL_MEMCPY(dst, src, size) rte_memcpy(dst, src, size) ++#define OSAL_MEMCPY(dst, src, size) memcpy(dst, src, size) + #define OSAL_MEMCMP(s1, s2, size) memcmp(s1, s2, size) + #define OSAL_MEMSET(dst, val, length) \ + memset(dst, val, length) +diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c +index a1122a297e..2a3123f0c8 100644 +--- a/drivers/net/qede/qede_ethdev.c ++++ b/drivers/net/qede/qede_ethdev.c +@@ -358,7 +358,7 @@ qede_assign_rxtx_handlers(struct rte_eth_dev *dev, bool is_dummy) + static void + qede_alloc_etherdev(struct qede_dev *qdev, struct qed_dev_eth_info *info) + { +- rte_memcpy(&qdev->dev_info, info, sizeof(*info)); ++ qdev->dev_info = *info; + qdev->ops = qed_ops; + } + +diff --git a/drivers/net/qede/qede_filter.c b/drivers/net/qede/qede_filter.c +index 440440423a..ca3165d972 100644 +--- a/drivers/net/qede/qede_filter.c ++++ b/drivers/net/qede/qede_filter.c +@@ -388,10 +388,8 @@ qede_arfs_construct_pkt(struct rte_eth_dev *eth_dev, + ip6->vtc_flow = + rte_cpu_to_be_32(QEDE_FDIR_IPV6_DEFAULT_VTC_FLOW); + +- rte_memcpy(&ip6->src_addr, arfs->tuple.src_ipv6, +- IPV6_ADDR_LEN); +- rte_memcpy(&ip6->dst_addr, arfs->tuple.dst_ipv6, +- IPV6_ADDR_LEN); ++ memcpy(&ip6->src_addr, arfs->tuple.src_ipv6, IPV6_ADDR_LEN); ++ memcpy(&ip6->dst_addr, arfs->tuple.dst_ipv6, IPV6_ADDR_LEN); + len += sizeof(struct rte_ipv6_hdr); + params->ipv6 = true; + +@@ -821,12 +819,10 @@ qede_flow_parse_pattern(__rte_unused struct rte_eth_dev *dev, + const struct rte_flow_item_ipv6 *spec; + + spec = pattern->spec; +- rte_memcpy(flow->entry.tuple.src_ipv6, +- spec->hdr.src_addr, +- IPV6_ADDR_LEN); +- rte_memcpy(flow->entry.tuple.dst_ipv6, +- spec->hdr.dst_addr, +- IPV6_ADDR_LEN); ++ memcpy(flow->entry.tuple.src_ipv6, ++ spec->hdr.src_addr, IPV6_ADDR_LEN); ++ memcpy(flow->entry.tuple.dst_ipv6, ++ spec->hdr.dst_addr, IPV6_ADDR_LEN); + flow->entry.tuple.eth_proto = + RTE_ETHER_TYPE_IPV6; + } +diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c +index 2d1f70693a..c5afdb00d5 100644 +--- a/drivers/net/qede/qede_main.c ++++ b/drivers/net/qede/qede_main.c +@@ -373,7 +373,7 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info) + dev_info->mtu = ECORE_LEADING_HWFN(edev)->hw_info.mtu; + dev_info->dev_type = edev->type; + +- rte_memcpy(&dev_info->hw_mac, &edev->hwfns[0].hw_info.hw_mac_addr, ++ memcpy(&dev_info->hw_mac, &edev->hwfns[0].hw_info.hw_mac_addr, + RTE_ETHER_ADDR_LEN); + + dev_info->fw_major = FW_MAJOR_VERSION; +@@ -441,7 +441,7 @@ qed_fill_eth_dev_info(struct ecore_dev *edev, struct qed_dev_eth_info *info) + info->num_vlan_filters = RESC_NUM(&edev->hwfns[0], ECORE_VLAN) - + max_vf_vlan_filters; + +- rte_memcpy(&info->port_mac, &edev->hwfns[0].hw_info.hw_mac_addr, ++ memcpy(&info->port_mac, &edev->hwfns[0].hw_info.hw_mac_addr, + RTE_ETHER_ADDR_LEN); + } else { + ecore_vf_get_num_rxqs(ECORE_LEADING_HWFN(edev), +@@ -472,7 +472,7 @@ static void qed_set_name(struct ecore_dev *edev, char name[NAME_SIZE]) + { + int i; + +- rte_memcpy(edev->name, name, NAME_SIZE); ++ memcpy(edev->name, name, NAME_SIZE); + for_each_hwfn(edev, i) { + snprintf(edev->hwfns[i].name, NAME_SIZE, "%s-%d", name, i); + } +@@ -514,10 +514,9 @@ static void qed_fill_link(struct ecore_hwfn *hwfn, + + /* Prepare source inputs */ + if (IS_PF(hwfn->p_dev)) { +- rte_memcpy(¶ms, ecore_mcp_get_link_params(hwfn), +- sizeof(params)); +- rte_memcpy(&link, ecore_mcp_get_link_state(hwfn), sizeof(link)); +- rte_memcpy(&link_caps, ecore_mcp_get_link_capabilities(hwfn), ++ memcpy(¶ms, ecore_mcp_get_link_params(hwfn), sizeof(params)); ++ memcpy(&link, ecore_mcp_get_link_state(hwfn), sizeof(link)); ++ memcpy(&link_caps, ecore_mcp_get_link_capabilities(hwfn), + sizeof(link_caps)); + } else { + ecore_vf_read_bulletin(hwfn, &change); +diff --git a/drivers/net/qede/qede_sriov.c b/drivers/net/qede/qede_sriov.c +index 0b99a8d6fe..937d339fb8 100644 +--- a/drivers/net/qede/qede_sriov.c ++++ b/drivers/net/qede/qede_sriov.c +@@ -203,10 +203,10 @@ void qed_inform_vf_link_state(struct ecore_hwfn *hwfn) + if (!hwfn->pf_iov_info) + return; + +- rte_memcpy(¶ms, ecore_mcp_get_link_params(lead_hwfn), ++ memcpy(¶ms, ecore_mcp_get_link_params(lead_hwfn), + sizeof(params)); +- rte_memcpy(&link, ecore_mcp_get_link_state(lead_hwfn), sizeof(link)); +- rte_memcpy(&caps, ecore_mcp_get_link_capabilities(lead_hwfn), ++ memcpy(&link, ecore_mcp_get_link_state(lead_hwfn), sizeof(link)); ++ memcpy(&caps, ecore_mcp_get_link_capabilities(lead_hwfn), + sizeof(caps)); + + /* Update bulletin of all future possible VFs with link configuration */ +-- +2.23.0 + diff --git a/0330-examples-performance-thread-fix-build-with-GCC-12.patch b/0330-examples-performance-thread-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..4715122 --- /dev/null +++ b/0330-examples-performance-thread-fix-build-with-GCC-12.patch @@ -0,0 +1,62 @@ +From 125a65cb03f845d1b6d5f7078670aa1a49d62513 Mon Sep 17 00:00:00 2001 +From: Kevin Traynor +Date: Wed, 24 Aug 2022 10:17:07 +0100 +Subject: [PATCH] examples/performance-thread: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[1/2] Compiling C object examples/dpdk-pthrea... +formance-thread_pthread_shim_pthread_shim.c.o +../examples/performance-thread/pthread_shim/pthread_shim.c: +In function ‘pthread_setspecific’: +../examples/performance-thread/pthread_shim/pthread_shim.c:592:27: +warning: ‘data’ may be used uninitialized [-Wmaybe-uninitialized] +592 | int rv = lthread_setspecific((unsigned int)key, data); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +../examples/performance-thread/pthread_shim/pthread_shim.c:589:56: +note: accessing argument 2 of a function declared with attribute +‘access (none, 2)’ +589 | int pthread_setspecific(pthread_key_t key, const void *data) + | ~~~~~~~~~~~~^~~~ + +This is a false positive as pthread_setspecific() does not read from +the (const void *) so we can squash the warning. + +performance-thread example is already removed from DPDK main branch. + +Signed-off-by: Kevin Traynor +--- + examples/performance-thread/pthread_shim/pthread_shim.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/examples/performance-thread/pthread_shim/pthread_shim.c b/examples/performance-thread/pthread_shim/pthread_shim.c +index bbc076584b..a44cb8244d 100644 +--- a/examples/performance-thread/pthread_shim/pthread_shim.c ++++ b/examples/performance-thread/pthread_shim/pthread_shim.c +@@ -586,6 +586,11 @@ pthread_t pthread_self(void) + return _sys_pthread_funcs.f_pthread_self(); + } + ++#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000) ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" ++#endif ++ + int pthread_setspecific(pthread_key_t key, const void *data) + { + if (override) { +@@ -595,6 +600,10 @@ int pthread_setspecific(pthread_key_t key, const void *data) + return _sys_pthread_funcs.f_pthread_setspecific(key, data); + } + ++#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000) ++#pragma GCC diagnostic pop ++#endif ++ + int pthread_spin_init(pthread_spinlock_t *a, int b) + { + NOT_IMPLEMENTED; +-- +2.23.0 + diff --git a/0331-net-mvneta-fix-build-with-GCC-12.patch b/0331-net-mvneta-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..bd2788f --- /dev/null +++ b/0331-net-mvneta-fix-build-with-GCC-12.patch @@ -0,0 +1,41 @@ +From 6d030554f1a6a0f2d82bb3371ebb1c5458a49491 Mon Sep 17 00:00:00 2001 +From: Amit Prakash Shukla +Date: Thu, 1 Sep 2022 14:01:18 +0530 +Subject: [PATCH] net/mvneta: fix build with GCC 12 + +[ upstream commit d7b080f1e72d833d668a66199fe99ccda6c81a36 ] + +./drivers/net/mvneta/mvneta_rxtx.c:89:42: + error: 'mbufs' may be used uninitialized [-Werror=maybe-uninitialized] + 89 | MVNETA_SET_COOKIE_HIGH_ADDR(mbufs[0]); + | ^ +../drivers/net/mvneta/mvneta_rxtx.c:77:26: note: 'mbufs' declared here + 77 | struct rte_mbuf *mbufs[MRVL_NETA_BUF_RELEASE_BURST_SIZE_MAX]; + | ^~~~~ + +Fixes: ce7ea764597e ("net/mvneta: support Rx/Tx") + +Signed-off-by: Amit Prakash Shukla +Acked-by: Liron Himi +--- + drivers/net/mvneta/mvneta_rxtx.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/net/mvneta/mvneta_rxtx.c b/drivers/net/mvneta/mvneta_rxtx.c +index 6e4a7896b4..952e982275 100644 +--- a/drivers/net/mvneta/mvneta_rxtx.c ++++ b/drivers/net/mvneta/mvneta_rxtx.c +@@ -79,6 +79,10 @@ mvneta_buffs_refill(struct mvneta_priv *priv, struct mvneta_rxq *rxq, u16 *num) + int i, ret; + uint16_t nb_desc = *num; + ++ /* To prevent GCC-12 warning. */ ++ if (unlikely(nb_desc == 0)) ++ return -1; ++ + ret = rte_pktmbuf_alloc_bulk(rxq->mp, mbufs, nb_desc); + if (ret) { + MVNETA_LOG(ERR, "Failed to allocate %u mbufs.", nb_desc); +-- +2.23.0 + diff --git a/0332-test-ipsec-fix-build-with-GCC-12.patch b/0332-test-ipsec-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..d8250f9 --- /dev/null +++ b/0332-test-ipsec-fix-build-with-GCC-12.patch @@ -0,0 +1,58 @@ +From fdebff6b5aadd85e417a10c234b4159d1d0620f5 Mon Sep 17 00:00:00 2001 +From: Amit Prakash Shukla +Date: Thu, 4 Aug 2022 19:10:53 +0530 +Subject: [PATCH] test/ipsec: fix build with GCC 12 + +[ upstream commit 250cbb8d5dd2ffcb4c8a871332f9ec8e5a59242f ] + +GCC-12 raises following warning: + +In function '_mm_loadu_si128', + inlined from 'rte_mov16' at + ../lib/eal/x86/include/rte_memcpy.h:507:9, + inlined from 'rte_mov128' at + ../lib/eal/x86/include/rte_memcpy.h:549:2, + inlined from 'rte_memcpy_generic' at + ../lib/eal/x86/include/rte_memcpy.h:732:4, + inlined from 'rte_memcpy' at + ../lib/eal/x86/include/rte_memcpy.h:882:10, + inlined from 'setup_test_string_tunneled' at + ../app/test/test_ipsec.c:617:3: +/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/emmintrin.h:703:10: error: + array subscript '__m128i_u[15]' is partly outside array bounds of + 'const uint8_t[255]' {aka 'const unsigned char[255]'} + [-Werror=array-bounds] + 703 | return *__P; + | ^~~~ +../app/test/test_ipsec.c: In function 'setup_test_string_tunneled': +../app/test/test_ipsec.c:491:22: note: at offset 240 into object + 'esp_pad_bytes' of size 255 + 491 | static const uint8_t esp_pad_bytes[IPSEC_MAX_PAD_SIZE] = { + +This patch restrict the copy to minimum size. + +Fixes: 05fe65eb66b2 ("test/ipsec: introduce functional test") + +Signed-off-by: Amit Prakash Shukla +Acked-by: Akhil Goyal +--- + app/test/test_ipsec.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c +index 6d5431843f..584c132f37 100644 +--- a/app/test/test_ipsec.c ++++ b/app/test/test_ipsec.c +@@ -618,7 +618,8 @@ setup_test_string_tunneled(struct rte_mempool *mpool, const char *string, + rte_memcpy(dst, string, len); + dst += len; + /* copy pad bytes */ +- rte_memcpy(dst, esp_pad_bytes, padlen); ++ rte_memcpy(dst, esp_pad_bytes, RTE_MIN(padlen, ++ sizeof(esp_pad_bytes))); + dst += padlen; + /* copy ESP tail header */ + rte_memcpy(dst, &espt, sizeof(espt)); +-- +2.23.0 + diff --git a/0333-ipsec-fix-build-with-GCC-12.patch b/0333-ipsec-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..9f43e7d --- /dev/null +++ b/0333-ipsec-fix-build-with-GCC-12.patch @@ -0,0 +1,75 @@ +From db9f8c23a4bc89764433efa58bf256f4bb95c10c Mon Sep 17 00:00:00 2001 +From: Amit Prakash Shukla +Date: Thu, 4 Aug 2022 19:10:54 +0530 +Subject: [PATCH] ipsec: fix build with GCC 12 + +[ upstream commit 2be383423e433b5d42324cb450589b46d057c2ed ] + +GCC 12 raises the following warning: + +In function '_mm_loadu_si128', + inlined from 'rte_mov16' at + ../lib/eal/x86/include/rte_memcpy.h:507:9, + inlined from 'rte_mov128' at + ../lib/eal/x86/include/rte_memcpy.h:549:2, + inlined from 'rte_memcpy_generic' at + ../lib/eal/x86/include/rte_memcpy.h:732:4, + inlined from 'rte_memcpy' at + ../lib/eal/x86/include/rte_memcpy.h:882:10, + inlined from 'outb_tun_pkt_prepare' at + ../lib/ipsec/esp_outb.c:224:2: +/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/emmintrin.h:703:10: error: + array subscript '__m128i_u[15]' is partly outside array bounds of + 'const uint8_t[255]' {aka 'const unsigned char[255]'} + [-Werror=array-bounds] + 703 | return *__P; + | ^~~~ +In file included from ../lib/ipsec/esp_outb.c:17: +../lib/ipsec/pad.h: In function 'outb_tun_pkt_prepare': +../lib/ipsec/pad.h:10:22: note: at offset 240 into object 'esp_pad_bytes' + of size 255 + 10 | static const uint8_t esp_pad_bytes[IPSEC_MAX_PAD_SIZE] = { + | ^~~~~~~~~~~~~ + +This patch restrict copy to minimum size. + +Bugzilla ID: 1060 +Fixes: 6015e6a13398 ("ipsec: move inbound and outbound code") + +Signed-off-by: Amit Prakash Shukla +Acked-by: Konstantin Ananyev +--- + lib/ipsec/esp_outb.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c +index 28bd58e3c7..1b0eeed07f 100644 +--- a/lib/ipsec/esp_outb.c ++++ b/lib/ipsec/esp_outb.c +@@ -220,8 +220,10 @@ outb_tun_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t sqc, + /* pad length */ + pdlen -= sizeof(*espt); + ++ RTE_ASSERT(pdlen <= sizeof(esp_pad_bytes)); ++ + /* copy padding data */ +- rte_memcpy(pt, esp_pad_bytes, pdlen); ++ rte_memcpy(pt, esp_pad_bytes, RTE_MIN(pdlen, sizeof(esp_pad_bytes))); + + /* update esp trailer */ + espt = (struct rte_esp_tail *)(pt + pdlen); +@@ -417,8 +419,10 @@ outb_trs_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t sqc, + /* pad length */ + pdlen -= sizeof(*espt); + ++ RTE_ASSERT(pdlen <= sizeof(esp_pad_bytes)); ++ + /* copy padding data */ +- rte_memcpy(pt, esp_pad_bytes, pdlen); ++ rte_memcpy(pt, esp_pad_bytes, RTE_MIN(pdlen, sizeof(esp_pad_bytes))); + + /* update esp trailer */ + espt = (struct rte_esp_tail *)(pt + pdlen); +-- +2.23.0 + diff --git a/0334-crypto-qat-fix-build-with-GCC-12.patch b/0334-crypto-qat-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..875b02d --- /dev/null +++ b/0334-crypto-qat-fix-build-with-GCC-12.patch @@ -0,0 +1,70 @@ +From 29b6bd601428a25e37b282f09e4b4a2244e111d9 Mon Sep 17 00:00:00 2001 +From: Amit Prakash Shukla +Date: Thu, 4 Aug 2022 19:10:55 +0530 +Subject: [PATCH] crypto/qat: fix build with GCC 12 + +[ upstream commit 04361fe2aca8998ea06fb4823dceb965698e147c ] + +GCC 12 raises the following warning: + +In function '_mm_storeu_si128', + inlined from 'rte_mov16' at + ../lib/eal/x86/include/rte_memcpy.h:508:2, + inlined from 'rte_mov128' at + ../lib/eal/x86/include/rte_memcpy.h:542:2, + inlined from 'rte_memcpy_generic' at + ../lib/eal/x86/include/rte_memcpy.h:732:4, + inlined from 'rte_memcpy' at + ../lib/eal/x86/include/rte_memcpy.h:882:10, + inlined from 'qat_sym_do_precomputes.constprop' at + ../drivers/crypto/qat/qat_sym_session.c:1434:2: +/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/emmintrin.h:739:8: error: + array subscript 8 is outside array bounds of 'unsigned char[128]' + [-Werror=array-bounds] + 739 | *__P = __B; + | ~~~~~^~~~~ + +../drivers/crypto/qat/qat_sym_session.c: + In function 'qat_sym_do_precomputes.constprop': +../drivers/crypto/qat/qat_sym_session.c:1305:17: note: + at offset 192 into object 'opad.750' of size 128 + 1305 | uint8_t + opad[qat_hash_get_block_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)]; + | ^~~~ + +../drivers/crypto/qat/qat_sym_session.c: + In function 'qat_sym_do_precomputes.constprop': +../drivers/crypto/qat/qat_sym_session.c:1304:17: note: + at offset 128 into object 'ipad.749' of size 128 + 1304 | uint8_t + ipad[qat_hash_get_block_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)]; + | ^~~~ + +Added a check to prevent compiler warnings. + +Fixes: 1703e94ac5ce ("qat: add driver for QuickAssist devices") + +Signed-off-by: Amit Prakash Shukla +Acked-by: Fan Zhang +--- + drivers/crypto/qat/qat_sym_session.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c +index 80d6fbfa46..3697a038e5 100644 +--- a/drivers/crypto/qat/qat_sym_session.c ++++ b/drivers/crypto/qat/qat_sym_session.c +@@ -1435,6 +1435,10 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, + QAT_LOG(ERR, "invalid keylen %u", auth_keylen); + return -EFAULT; + } ++ ++ RTE_VERIFY(auth_keylen <= sizeof(ipad)); ++ RTE_VERIFY(auth_keylen <= sizeof(opad)); ++ + rte_memcpy(ipad, auth_key, auth_keylen); + rte_memcpy(opad, auth_key, auth_keylen); + +-- +2.23.0 + diff --git a/0335-vhost-fix-build-with-GCC-12.patch b/0335-vhost-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..4602c9c --- /dev/null +++ b/0335-vhost-fix-build-with-GCC-12.patch @@ -0,0 +1,100 @@ +From 54a98eecdb81d95d958998c3ecb85b20cde03837 Mon Sep 17 00:00:00 2001 +From: Maxime Coquelin +Date: Wed, 5 Oct 2022 22:35:24 +0200 +Subject: [PATCH] vhost: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 4226aa9caca9511bf95a093b6ad9c1f8727a4d43 ] + +This patch fixes a compilation issue met with GCC 12 on +LoongArch64: + +In function ‘mbuf_to_desc’, + inlined from ‘vhost_enqueue_async_packed’ + inlined from ‘virtio_dev_rx_async_packed’ + inlined from ‘virtio_dev_rx_async_submit_packed’ +lib/vhost/virtio_net.c:1159:18: error: + ‘buf_vec[0].buf_addr’ may be used uninitialized + 1159 | buf_addr = buf_vec[vec_idx].buf_addr; + | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ +lib/vhost/virtio_net.c: In function ‘virtio_dev_rx_async_submit_packed’: +lib/vhost/virtio_net.c:1834:27: note: ‘buf_vec’ declared here + 1834 | struct buf_vector buf_vec[BUF_VECTOR_MAX]; + | ^~~~~~~ + +It happens because the compiler assumes that 'size' +variable in vhost_enqueue_async_packed could wrap to 0 since +'size' is uint32_t and pkt->pkt_len too. + +In practice, it would never happen since 'pkt->pkt_len' is +unlikely to be close to UINT32_MAX, but let's just change +'size' to uint64_t to make the compiler happy without +having to add runtime checks. + +This patch also fixes similar patterns in three other +places, including one that also produces similar build +issue on ARM64 in vhost_enqueue_single_packed(). + +Fixes: 873e8dad6f49 ("vhost: support packed ring in async datapath") + +Signed-off-by: Maxime Coquelin +Reviewed-by: David Marchand +Tested-by: Amit Prakash Shukla +--- + lib/vhost/virtio_net.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c +index bf4d75b4bd..64460e3e8c 100644 +--- a/lib/vhost/virtio_net.c ++++ b/lib/vhost/virtio_net.c +@@ -599,7 +599,7 @@ fill_vec_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq, + */ + static inline int + reserve_avail_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq, +- uint32_t size, struct buf_vector *buf_vec, ++ uint64_t size, struct buf_vector *buf_vec, + uint16_t *num_buffers, uint16_t avail_head, + uint16_t *nr_vec) + { +@@ -1069,7 +1069,7 @@ vhost_enqueue_single_packed(struct virtio_net *dev, + uint16_t buf_id = 0; + uint32_t len = 0; + uint16_t desc_count; +- uint32_t size = pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_rxbuf); ++ uint64_t size = pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_rxbuf); + uint16_t num_buffers = 0; + uint32_t buffer_len[vq->size]; + uint16_t buffer_buf_id[vq->size]; +@@ -1137,7 +1137,7 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, + rte_prefetch0(&vq->avail->ring[vq->last_avail_idx & (vq->size - 1)]); + + for (pkt_idx = 0; pkt_idx < count; pkt_idx++) { +- uint32_t pkt_len = pkts[pkt_idx]->pkt_len + dev->vhost_hlen; ++ uint64_t pkt_len = pkts[pkt_idx]->pkt_len + dev->vhost_hlen; + uint16_t nr_vec = 0; + + if (unlikely(reserve_avail_buf_split(dev, vq, +@@ -1485,7 +1485,7 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev, + async_iter_reset(async); + + for (pkt_idx = 0; pkt_idx < count; pkt_idx++) { +- uint32_t pkt_len = pkts[pkt_idx]->pkt_len + dev->vhost_hlen; ++ uint64_t pkt_len = pkts[pkt_idx]->pkt_len + dev->vhost_hlen; + uint16_t nr_vec = 0; + + if (unlikely(reserve_avail_buf_split(dev, vq, pkt_len, buf_vec, +@@ -1575,7 +1575,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev, + uint16_t buf_id = 0; + uint32_t len = 0; + uint16_t desc_count = 0; +- uint32_t size = pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_rxbuf); ++ uint64_t size = pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_rxbuf); + uint32_t buffer_len[vq->size]; + uint16_t buffer_buf_id[vq->size]; + uint16_t buffer_desc_count[vq->size]; +-- +2.23.0 + diff --git a/0336-net-i40e-fix-build-with-MinGW-GCC-12.patch b/0336-net-i40e-fix-build-with-MinGW-GCC-12.patch new file mode 100644 index 0000000..9e5339e --- /dev/null +++ b/0336-net-i40e-fix-build-with-MinGW-GCC-12.patch @@ -0,0 +1,50 @@ +From 9ba87edbe69cac90bf8aff9714e3724519c633bf Mon Sep 17 00:00:00 2001 +From: Amit Prakash Shukla +Date: Wed, 24 Aug 2022 19:33:38 +0530 +Subject: [PATCH] net/i40e: fix build with MinGW GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit eb440cea1e05245f362ec7fca932f2d977f12359 ] + +When compiling with MinGW GCC 12, +the rte_flow_item array is seen as read out of bound: + +net/i40e/i40e_hash.c:389:47: error: + array subscript 50 is above array bounds of ‘const uint64_t[50]’ + {aka ‘const long long unsigned int[50]’} [-Werror=array-bounds] + 389 | item_hdr = pattern_item_header[last_item_type]; + | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ + +It seems the assert check done above this line has no impact. +A real check is added to make the compiler happy. + +Fixes: ef4c16fd9148 ("net/i40e: refactor RSS flow") + +Signed-off-by: Amit Prakash Shukla +Acked-by: Thomas Monjalon +--- + drivers/net/i40e/i40e_hash.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/i40e/i40e_hash.c b/drivers/net/i40e/i40e_hash.c +index 8962e9d97a..a1ff85fceb 100644 +--- a/drivers/net/i40e/i40e_hash.c ++++ b/drivers/net/i40e/i40e_hash.c +@@ -384,8 +384,10 @@ i40e_hash_get_pattern_type(const struct rte_flow_item pattern[], + } + + prev_item_type = last_item_type; +- assert(last_item_type < (enum rte_flow_item_type) +- RTE_DIM(pattern_item_header)); ++ if (last_item_type >= (enum rte_flow_item_type) ++ RTE_DIM(pattern_item_header)) ++ goto not_sup; ++ + item_hdr = pattern_item_header[last_item_type]; + assert(item_hdr); + +-- +2.23.0 + diff --git a/0337-net-qede-base-fix-32-bit-build-with-GCC-12.patch b/0337-net-qede-base-fix-32-bit-build-with-GCC-12.patch new file mode 100644 index 0000000..5cef6a9 --- /dev/null +++ b/0337-net-qede-base-fix-32-bit-build-with-GCC-12.patch @@ -0,0 +1,53 @@ +From 4d4b866a158e5079dcac3f6533c06c4acdf2dd69 Mon Sep 17 00:00:00 2001 +From: Amit Prakash Shukla +Date: Wed, 24 Aug 2022 19:33:39 +0530 +Subject: [PATCH] net/qede/base: fix 32-bit build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit acc0ed087cd1ce6464f63489ab17eca52b0c94b2 ] + +A pointer is passed to a macro and it seems mistakenly referenced. +This issue is seen only when compiling with GCC 12 for 32-bit: + +drivers/net/qede/base/ecore_init_fw_funcs.c:1418:25: + error: array subscript 1 is outside array bounds of ‘u32[1]’ + {aka ‘unsigned int[1]’} [-Werror=array-bounds] + 1418 | ecore_wr(dev, ptt, ((addr) + (4 * i)), \ + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 1419 | ((u32 *)&(arr))[i]); \ + | ~~~~~~~~~~~~~~~~~~~ +drivers/net/qede/base/ecore_init_fw_funcs.c:1465:17: + note: in expansion of macro ‘ARR_REG_WR’ + 1465 | ARR_REG_WR(p_hwfn, p_ptt, addr, pData, len_in_dwords); + | ^~~~~~~~~~ +drivers/net/qede/base/ecore_init_fw_funcs.c:1439:35: + note: at offset 4 into object ‘pData’ of size 4 + 1439 | u32 *pData, + | ~~~~~^~~~~ + +Fixes: 3b307c55f2ac ("net/qede/base: update FW to 8.40.25.0") + +Signed-off-by: Amit Prakash Shukla +Acked-by: Thomas Monjalon +--- + drivers/net/qede/base/ecore_init_fw_funcs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/qede/base/ecore_init_fw_funcs.c b/drivers/net/qede/base/ecore_init_fw_funcs.c +index 6a52f32cc9..4e4d1dc374 100644 +--- a/drivers/net/qede/base/ecore_init_fw_funcs.c ++++ b/drivers/net/qede/base/ecore_init_fw_funcs.c +@@ -1416,7 +1416,7 @@ void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn, + u32 i; \ + for (i = 0; i < (arr_size); i++) \ + ecore_wr(dev, ptt, ((addr) + (4 * i)), \ +- ((u32 *)&(arr))[i]); \ ++ ((u32 *)(arr))[i]); \ + } while (0) + + #ifndef DWORDS_TO_BYTES +-- +2.23.0 + diff --git a/0338-hash-fix-GFNI-implementation-build-with-GCC-12.patch b/0338-hash-fix-GFNI-implementation-build-with-GCC-12.patch new file mode 100644 index 0000000..f75a193 --- /dev/null +++ b/0338-hash-fix-GFNI-implementation-build-with-GCC-12.patch @@ -0,0 +1,104 @@ +From 47951ef1dc21882215a531472d055c58a7618cb0 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Mon, 9 Jan 2023 11:03:37 +0100 +Subject: [PATCH] hash: fix GFNI implementation build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit fe2c18a0a8b22703dec3add385a371ad819d7872 ] + +On a system that has AVX512F and GFNI, compiling fails with: + +In file included from /usr/lib/gcc/x86_64-redhat-linux/12/include/immintrin.h:71, + from /usr/lib/gcc/x86_64-redhat-linux/12/include/x86intrin.h:32, + from ../../../git/pub/dpdk.org/main/lib/eal/x86/include/rte_vect.h:31, + from ../../../git/pub/dpdk.org/main/lib/eal/x86/include/rte_memcpy.h:17, + from ../../../git/pub/dpdk.org/main/lib/mempool/rte_mempool.h:48, + from ../../../git/pub/dpdk.org/main/lib/mbuf/rte_mbuf.h:38, + from ../../../git/pub/dpdk.org/main/lib/net/rte_ip.h:33, + from ../../../git/pub/dpdk.org/main/lib/hash/rte_thash.h:25, + from ../../../git/pub/dpdk.org/main/lib/hash/rte_thash.c:7: +In function ‘_mm512_mask_permutexvar_epi8’, + inlined from ‘__rte_thash_gfni’ at + ../../../git/pub/dpdk.org/main/lib/hash/rte_thash_x86_gfni.h:142:17, + inlined from ‘rte_thash_gfni’ at + ../../../git/pub/dpdk.org/main/lib/hash/rte_thash_x86_gfni.h:182:20, + inlined from ‘rte_thash_adjust_tuple’ at + ../../../git/pub/dpdk.org/main/lib/hash/rte_thash.c:784:11: +/usr/lib/gcc/x86_64-redhat-linux/12/include/avx512vbmiintrin.h:97:20: + error: ‘tuple_bytes’ may be used uninitialized [-Werror=maybe-uninitialized] + 97 | return (__m512i) __builtin_ia32_permvarqi512_mask ((__v64qi) __B, + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 98 | (__v64qi) __A, + | ~~~~~~~~~~~~~~ + 99 | (__v64qi) __W, + | ~~~~~~~~~~~~~~ + 100 | (__mmask64) __M); + | ~~~~~~~~~~~~~~~~ + +And: + +In file included from ../../../git/pub/dpdk.org/main/lib/hash/rte_thash_gfni.h:17, + from ../../../git/pub/dpdk.org/main/lib/hash/rte_thash.h:27: +../../../git/pub/dpdk.org/main/lib/hash/rte_thash_x86_gfni.h: + In function ‘rte_thash_adjust_tuple’: +../../../git/pub/dpdk.org/main/lib/hash/rte_thash_x86_gfni.h:91:33: + note: ‘tuple_bytes’ was declared here + 91 | __m512i vals, matrixes, tuple_bytes, tuple_bytes_2; + | ^~~~~~~~~~~ +In function ‘_mm512_mask_permutexvar_epi8’, + inlined from ‘__rte_thash_gfni’ at + ../../../git/pub/dpdk.org/main/lib/hash/rte_thash_x86_gfni.h:142:17, + inlined from ‘rte_thash_gfni’ at + ../../../git/pub/dpdk.org/main/lib/hash/rte_thash_x86_gfni.h:182:20, + inlined from ‘rte_thash_adjust_tuple’ at + ../../../git/pub/dpdk.org/main/lib/hash/rte_thash.c:784:11: +/usr/lib/gcc/x86_64-redhat-linux/12/include/avx512vbmiintrin.h:97:20: + error: ‘permute_mask’ may be used uninitialized [-Werror=maybe-uninitialized] + 97 | return (__m512i) __builtin_ia32_permvarqi512_mask ((__v64qi) __B, + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 98 | (__v64qi) __A, + | ~~~~~~~~~~~~~~ + 99 | (__v64qi) __W, + | ~~~~~~~~~~~~~~ + 100 | (__mmask64) __M); + | ~~~~~~~~~~~~~~~~ +../../../git/pub/dpdk.org/main/lib/hash/rte_thash_x86_gfni.h: + In function ‘rte_thash_adjust_tuple’: +../../../git/pub/dpdk.org/main/lib/hash/rte_thash_x86_gfni.h:92:30: + note: ‘permute_mask’ was declared here + 92 | __mmask64 load_mask, permute_mask, permute_mask_2; + | ^~~~~~~~~~~~ +cc1: all warnings being treated as errors + +Set those variables to 0. + +Fixes: 4fd8c4cb0de1 ("hash: add new Toeplitz hash implementation") + +Signed-off-by: David Marchand +Acked-by: Bruce Richardson +--- + lib/hash/rte_thash_x86_gfni.h | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/lib/hash/rte_thash_x86_gfni.h b/lib/hash/rte_thash_x86_gfni.h +index 657b1862c3..0583f64793 100644 +--- a/lib/hash/rte_thash_x86_gfni.h ++++ b/lib/hash/rte_thash_x86_gfni.h +@@ -87,8 +87,10 @@ __rte_thash_gfni(const uint64_t *mtrx, const uint8_t *tuple, + const __m512i shift_8 = _mm512_set1_epi8(8); + __m512i xor_acc = _mm512_setzero_si512(); + __m512i perm_bytes = _mm512_setzero_si512(); +- __m512i vals, matrixes, tuple_bytes, tuple_bytes_2; +- __mmask64 load_mask, permute_mask, permute_mask_2; ++ __m512i vals, matrixes, tuple_bytes_2; ++ __m512i tuple_bytes = _mm512_setzero_si512(); ++ __mmask64 load_mask, permute_mask_2; ++ __mmask64 permute_mask = 0; + int chunk_len = 0, i = 0; + uint8_t mtrx_msk; + const int prepend = 3; +-- +2.23.0 + diff --git a/0339-examples-cmdline-fix-build-with-GCC-12.patch b/0339-examples-cmdline-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..0cef1a7 --- /dev/null +++ b/0339-examples-cmdline-fix-build-with-GCC-12.patch @@ -0,0 +1,53 @@ +From 661f5540c3785104258dc1b9f169ccd6dd770472 Mon Sep 17 00:00:00 2001 +From: Bruce Richardson +Date: Wed, 18 Jan 2023 16:11:11 +0000 +Subject: [PATCH] examples/cmdline: fix build with GCC 12 + +[ upstream commit 2ba8d0adb06f92ef73bc8e3953ca45b7d322c823 ] + +When building the example without libbsd and using the DPDK-provided +strlcpy function, a compiler warning is emitted by GCC 12 about the copy +of the parsed string into the resulting object. This is because the +source from cmdline library is 128 bytes and the destination buffer is +64-bytes. + +commands.c: In function 'cmd_obj_add_parsed': +rte_string_fns.h:61:24: warning: '%s' directive output may be truncated +writing up to 127 bytes into a region of size 64 [-Wformat-truncation=] + 61 | return (size_t)snprintf(dst, size, "%s", src); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In file included from /usr/include/stdio.h:894, + from commands.c:7: +/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: +'__builtin_snprintf' output between 1 and 128 bytes into a destination of size 64 + +Multiple options are possible to fix this, but the one taken in this +patch is to ensure truncation never occurs by setting the destination +buffer size to be the same as that used by the cmdline library. + +Fixes: af75078fece3 ("first public release") + +Signed-off-by: Bruce Richardson +Acked-by: Olivier Matz +--- + examples/cmdline/parse_obj_list.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/examples/cmdline/parse_obj_list.h b/examples/cmdline/parse_obj_list.h +index 6516d3e2c2..1223ac1e8b 100644 +--- a/examples/cmdline/parse_obj_list.h ++++ b/examples/cmdline/parse_obj_list.h +@@ -12,8 +12,9 @@ + + #include + #include ++#include + +-#define OBJ_NAME_LEN_MAX 64 ++#define OBJ_NAME_LEN_MAX sizeof(cmdline_fixed_string_t) + + struct object { + SLIST_ENTRY(object) next; +-- +2.23.0 + diff --git a/0340-net-mlx5-fix-build-with-GCC-12-and-ASan.patch b/0340-net-mlx5-fix-build-with-GCC-12-and-ASan.patch new file mode 100644 index 0000000..a212cac --- /dev/null +++ b/0340-net-mlx5-fix-build-with-GCC-12-and-ASan.patch @@ -0,0 +1,70 @@ +From c3a4fd09f9a348e9b7394b2a9d498c815f1efaac Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Wed, 22 Mar 2023 18:06:27 +0100 +Subject: [PATCH] net/mlx5: fix build with GCC 12 and ASan +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit e17840756179410283ef03660578310874432f40 ] + +Building with gcc 12 and ASan raises this warning: + +../drivers/net/mlx5/mlx5_txpp.c: In function ‘mlx5_txpp_xstats_get_names’: +../drivers/net/mlx5/mlx5_txpp.c:1066:25: error: ‘strncpy’ specified bound + 64 equals destination size [-Werror=stringop-truncation] + 1066 | strncpy(xstats_names[i + n_used].name, + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 1067 | mlx5_txpp_stat_names[i], + | ~~~~~~~~~~~~~~~~~~~~~~~~ + 1068 | RTE_ETH_XSTATS_NAME_SIZE); + | ~~~~~~~~~~~~~~~~~~~~~~~~~ +cc1: all warnings being treated as errors + +Prefer strlcpy for xstats. + +Fixes: 3b025c0ca425 ("net/mlx5: provide send scheduling error statistics") + +Signed-off-by: David Marchand +Acked-by: Raslan Darawsheh +--- + drivers/net/mlx5/mlx5_stats.c | 3 +-- + drivers/net/mlx5/mlx5_txpp.c | 4 +--- + 2 files changed, 2 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c +index f64fa3587b..615e1d073d 100644 +--- a/drivers/net/mlx5/mlx5_stats.c ++++ b/drivers/net/mlx5/mlx5_stats.c +@@ -288,10 +288,9 @@ mlx5_xstats_get_names(struct rte_eth_dev *dev, + + if (n >= mlx5_xstats_n && xstats_names) { + for (i = 0; i != mlx5_xstats_n; ++i) { +- strncpy(xstats_names[i].name, ++ strlcpy(xstats_names[i].name, + xstats_ctrl->info[i].dpdk_name, + RTE_ETH_XSTATS_NAME_SIZE); +- xstats_names[i].name[RTE_ETH_XSTATS_NAME_SIZE - 1] = 0; + } + } + mlx5_xstats_n = mlx5_txpp_xstats_get_names(dev, xstats_names, +diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c +index af77e91e4c..83d17997d1 100644 +--- a/drivers/net/mlx5/mlx5_txpp.c ++++ b/drivers/net/mlx5/mlx5_txpp.c +@@ -1064,11 +1064,9 @@ int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + + if (n >= n_used + n_txpp && xstats_names) { + for (i = 0; i < n_txpp; ++i) { +- strncpy(xstats_names[i + n_used].name, ++ strlcpy(xstats_names[i + n_used].name, + mlx5_txpp_stat_names[i], + RTE_ETH_XSTATS_NAME_SIZE); +- xstats_names[i + n_used].name +- [RTE_ETH_XSTATS_NAME_SIZE - 1] = 0; + } + } + return n_used + n_txpp; +-- +2.23.0 + diff --git a/0341-pdump-fix-build-with-GCC-12.patch b/0341-pdump-fix-build-with-GCC-12.patch new file mode 100644 index 0000000..cf4c996 --- /dev/null +++ b/0341-pdump-fix-build-with-GCC-12.patch @@ -0,0 +1,84 @@ +From 606474e9d0143ea0fb2863e64d2267b569e1fb89 Mon Sep 17 00:00:00 2001 +From: Joyce Kong +Date: Mon, 27 Mar 2023 07:07:12 +0000 +Subject: [PATCH] pdump: fix build with GCC 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit b182466683a5c76657efb4b6b8d43e7d71979034 ] + +The following warning is observed with GCC12 compilation +with release 20.11: + +In function ‘__rte_ring_enqueue_elems_64’, + inlined from ‘__rte_ring_enqueue_elems’ at + ../lib/librte_ring/rte_ring_elem.h:225:3, + inlined from ‘__rte_ring_do_enqueue_elem’ at + ../lib/librte_ring/rte_ring_elem.h:424:2, + inlined from ‘rte_ring_mp_enqueue_burst_elem’ at + ../lib/librte_ring/rte_ring_elem.h:884:9, + inlined from ‘rte_ring_enqueue_burst_elem’ at + ../lib/librte_ring/rte_ring_elem.h:946:10, + inlined from ‘rte_ring_enqueue_burst’ at + ../lib/librte_ring/rte_ring.h:721:9, + inlined from ‘pdump_copy’ at + ../lib/librte_pdump/rte_pdump.c:94:13: +../lib/librte_ring/rte_ring_elem.h:162:40: warning: ‘*dup_bufs.36_42 ++ _89’ may be used uninitialized [-Wmaybe-uninitialized] + 162 | ring[idx] = obj[i]; + | ~~~^~~ +../lib/librte_ring/rte_ring_elem.h:163:44: warning: ‘*dup_bufs.36_42 ++ _98’ may be used uninitialized [-Wmaybe-uninitialized] + 163 | ring[idx + 1] = obj[i + 1]; + | ~~~^~~~~~~ +../lib/librte_ring/rte_ring_elem.h:164:44: warning: ‘*dup_bufs.36_42 ++ _107’ may be used uninitialized [-Wmaybe-uninitialized] + 164 | ring[idx + 2] = obj[i + 2]; + | ~~~^~~~~~~ +../lib/librte_ring/rte_ring_elem.h:165:44: warning: ‘*dup_bufs.36_42 ++ _116’ may be used uninitialized [-Wmaybe-uninitialized] + 165 | ring[idx + 3] = obj[i + 3]; + | ~~~^~~~~~~ +../lib/librte_ring/rte_ring_elem.h:169:42: warning: ‘*dup_bufs.36_42 ++ _129’ may be used uninitialized [-Wmaybe-uninitialized] + 169 | ring[idx++] = obj[i++]; /* fallthrough */ + | ~~~^~~~~ +../lib/librte_ring/rte_ring_elem.h:171:42: warning: ‘*dup_bufs.36_42 ++ _139’ may be used uninitialized [-Wmaybe-uninitialized] + 171 | ring[idx++] = obj[i++]; /* fallthrough */ + | ~~~^~~~~ +../lib/librte_ring/rte_ring_elem.h:173:42: warning: ‘*dup_bufs.36_42 ++ _149’ may be used uninitialized [-Wmaybe-uninitialized] + 173 | ring[idx++] = obj[i++]; + +Actually, this is an alias warning as -O3 enables strict alias. +This patch fixes it by replacing 'dup_bufs' with '&dup_bufs[0]' +as the compiler represents them differently. + +Fixes: 278f945402c5 ("pdump: add new library for packet capture") + +Signed-off-by: Joyce Kong +Reviewed-by: Ruifeng Wang +Acked-by: Reshma Pattan +Acked-by: Tyler Retzlaff +--- + lib/pdump/rte_pdump.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c +index f0dee81e77..805d12236c 100644 +--- a/lib/pdump/rte_pdump.c ++++ b/lib/pdump/rte_pdump.c +@@ -133,7 +133,7 @@ pdump_copy(uint16_t port_id, uint16_t queue, + + __atomic_fetch_add(&stats->accepted, d_pkts, __ATOMIC_RELAXED); + +- ring_enq = rte_ring_enqueue_burst(ring, (void *)dup_bufs, d_pkts, NULL); ++ ring_enq = rte_ring_enqueue_burst(ring, (void *)&dup_bufs[0], d_pkts, NULL); + if (unlikely(ring_enq < d_pkts)) { + unsigned int drops = d_pkts - ring_enq; + +-- +2.23.0 + diff --git a/0342-net-cxgbe-fix-dangling-pointer-by-mailbox-access-rew.patch b/0342-net-cxgbe-fix-dangling-pointer-by-mailbox-access-rew.patch new file mode 100644 index 0000000..e7063b3 --- /dev/null +++ b/0342-net-cxgbe-fix-dangling-pointer-by-mailbox-access-rew.patch @@ -0,0 +1,329 @@ +From 699c30f8534c136926df9b6fb5b97ed06c1f34a0 Mon Sep 17 00:00:00 2001 +From: Rahul Lakkireddy +Date: Thu, 20 Jan 2022 03:26:40 +0530 +Subject: [PATCH] net/cxgbe: fix dangling pointer by mailbox access rework +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 19cafed99ac573662045424e559cee444c175b63 ] + +Rework mailbox access serialization to dynamically allocate and +free mbox entry. Also remove unnecessary temp memory and macros. + +Observed with: gcc-12.0 (GCC) 12.0.1 20220118 (experimental) + +In file included from ../lib/eal/linux/include/rte_os.h:14, + from ../lib/eal/include/rte_common.h:28, + from ../lib/eal/include/rte_log.h:25, + from ../lib/ethdev/rte_ethdev.h:164, + from ../lib/ethdev/ethdev_driver.h:18, + from ../drivers/net/cxgbe/base/t4vf_hw.c:6: +In function ‘t4_os_atomic_add_tail’, + inlined from ‘t4vf_wr_mbox_core’ at + ../drivers/net/cxgbe/base/t4vf_hw.c:115:2: +../drivers/net/cxgbe/base/adapter.h:742:9: + warning: storing the address of local variable ‘entry’ in + ‘((struct mbox_list *)adapter)[96].tqh_last’ [-Wdangling-pointer=] + 742 | TAILQ_INSERT_TAIL(head, entry, next); + | ^~~~~~~~~~~~~~~~~ +../drivers/net/cxgbe/base/t4vf_hw.c: In function ‘t4vf_wr_mbox_core’: +../drivers/net/cxgbe/base/t4vf_hw.c:86:27: note: ‘entry’ declared here + 86 | struct mbox_entry entry; + | ^~~~~ +../drivers/net/cxgbe/base/t4vf_hw.c:86:27: note: ‘adapter’ declared here + +Fixes: 3bd122eef2cc ("cxgbe/base: add hardware API for Chelsio T5 series adapters") + +Reported-by: Ferruh Yigit +Signed-off-by: Rahul Lakkireddy +--- + drivers/net/cxgbe/base/adapter.h | 2 - + drivers/net/cxgbe/base/t4_hw.c | 83 ++++++++++++-------------------- + drivers/net/cxgbe/base/t4vf_hw.c | 28 +++++++---- + 3 files changed, 49 insertions(+), 64 deletions(-) + +diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h +index 1c7c8afe16..97963422bf 100644 +--- a/drivers/net/cxgbe/base/adapter.h ++++ b/drivers/net/cxgbe/base/adapter.h +@@ -291,8 +291,6 @@ struct sge { + u32 fl_starve_thres; /* Free List starvation threshold */ + }; + +-#define T4_OS_NEEDS_MBOX_LOCKING 1 +- + /* + * OS Lock/List primitives for those interfaces in the Common Code which + * need this. +diff --git a/drivers/net/cxgbe/base/t4_hw.c b/drivers/net/cxgbe/base/t4_hw.c +index cdcd7e5510..645833765a 100644 +--- a/drivers/net/cxgbe/base/t4_hw.c ++++ b/drivers/net/cxgbe/base/t4_hw.c +@@ -263,17 +263,6 @@ static void fw_asrt(struct adapter *adap, u32 mbox_addr) + + #define X_CIM_PF_NOACCESS 0xeeeeeeee + +-/* +- * If the Host OS Driver needs locking arround accesses to the mailbox, this +- * can be turned on via the T4_OS_NEEDS_MBOX_LOCKING CPP define ... +- */ +-/* makes single-statement usage a bit cleaner ... */ +-#ifdef T4_OS_NEEDS_MBOX_LOCKING +-#define T4_OS_MBOX_LOCKING(x) x +-#else +-#define T4_OS_MBOX_LOCKING(x) do {} while (0) +-#endif +- + /** + * t4_wr_mbox_meat_timeout - send a command to FW through the given mailbox + * @adap: the adapter +@@ -314,28 +303,17 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, + 1, 1, 3, 5, 10, 10, 20, 50, 100 + }; + +- u32 v; +- u64 res; +- int i, ms; +- unsigned int delay_idx; +- __be64 *temp = (__be64 *)malloc(size * sizeof(char)); +- __be64 *p = temp; + u32 data_reg = PF_REG(mbox, A_CIM_PF_MAILBOX_DATA); + u32 ctl_reg = PF_REG(mbox, A_CIM_PF_MAILBOX_CTRL); +- u32 ctl; +- struct mbox_entry entry; +- u32 pcie_fw = 0; +- +- if (!temp) +- return -ENOMEM; ++ struct mbox_entry *entry; ++ u32 v, ctl, pcie_fw = 0; ++ unsigned int delay_idx; ++ const __be64 *p; ++ int i, ms, ret; ++ u64 res; + +- if ((size & 15) || size > MBOX_LEN) { +- free(temp); ++ if ((size & 15) != 0 || size > MBOX_LEN) + return -EINVAL; +- } +- +- memset(p, 0, size); +- memcpy(p, (const __be64 *)cmd, size); + + /* + * If we have a negative timeout, that implies that we can't sleep. +@@ -345,14 +323,17 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, + timeout = -timeout; + } + +-#ifdef T4_OS_NEEDS_MBOX_LOCKING ++ entry = t4_os_alloc(sizeof(*entry)); ++ if (entry == NULL) ++ return -ENOMEM; ++ + /* + * Queue ourselves onto the mailbox access list. When our entry is at + * the front of the list, we have rights to access the mailbox. So we + * wait [for a while] till we're at the front [or bail out with an + * EBUSY] ... + */ +- t4_os_atomic_add_tail(&entry, &adap->mbox_list, &adap->mbox_lock); ++ t4_os_atomic_add_tail(entry, &adap->mbox_list, &adap->mbox_lock); + + delay_idx = 0; + ms = delay[0]; +@@ -367,18 +348,18 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, + */ + pcie_fw = t4_read_reg(adap, A_PCIE_FW); + if (i > 4 * timeout || (pcie_fw & F_PCIE_FW_ERR)) { +- t4_os_atomic_list_del(&entry, &adap->mbox_list, ++ t4_os_atomic_list_del(entry, &adap->mbox_list, + &adap->mbox_lock); + t4_report_fw_error(adap); +- free(temp); +- return (pcie_fw & F_PCIE_FW_ERR) ? -ENXIO : -EBUSY; ++ ret = ((pcie_fw & F_PCIE_FW_ERR) != 0) ? -ENXIO : -EBUSY; ++ goto out_free; + } + + /* + * If we're at the head, break out and start the mailbox + * protocol. + */ +- if (t4_os_list_first_entry(&adap->mbox_list) == &entry) ++ if (t4_os_list_first_entry(&adap->mbox_list) == entry) + break; + + /* +@@ -393,7 +374,6 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, + rte_delay_ms(ms); + } + } +-#endif /* T4_OS_NEEDS_MBOX_LOCKING */ + + /* + * Attempt to gain access to the mailbox. +@@ -410,12 +390,11 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, + * mailbox atomic access list and report the error to our caller. + */ + if (v != X_MBOWNER_PL) { +- T4_OS_MBOX_LOCKING(t4_os_atomic_list_del(&entry, +- &adap->mbox_list, +- &adap->mbox_lock)); ++ t4_os_atomic_list_del(entry, &adap->mbox_list, ++ &adap->mbox_lock); + t4_report_fw_error(adap); +- free(temp); +- return (v == X_MBOWNER_FW ? -EBUSY : -ETIMEDOUT); ++ ret = (v == X_MBOWNER_FW) ? -EBUSY : -ETIMEDOUT; ++ goto out_free; + } + + /* +@@ -441,7 +420,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, + /* + * Copy in the new mailbox command and send it on its way ... + */ +- for (i = 0; i < size; i += 8, p++) ++ for (i = 0, p = cmd; i < size; i += 8, p++) + t4_write_reg64(adap, data_reg + i, be64_to_cpu(*p)); + + CXGBE_DEBUG_MBOX(adap, "%s: mbox %u: %016llx %016llx %016llx %016llx " +@@ -512,11 +491,10 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, + get_mbox_rpl(adap, rpl, size / 8, data_reg); + } + t4_write_reg(adap, ctl_reg, V_MBOWNER(X_MBOWNER_NONE)); +- T4_OS_MBOX_LOCKING( +- t4_os_atomic_list_del(&entry, &adap->mbox_list, +- &adap->mbox_lock)); +- free(temp); +- return -G_FW_CMD_RETVAL((int)res); ++ t4_os_atomic_list_del(entry, &adap->mbox_list, ++ &adap->mbox_lock); ++ ret = -G_FW_CMD_RETVAL((int)res); ++ goto out_free; + } + } + +@@ -527,12 +505,13 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, + */ + dev_err(adap, "command %#x in mailbox %d timed out\n", + *(const u8 *)cmd, mbox); +- T4_OS_MBOX_LOCKING(t4_os_atomic_list_del(&entry, +- &adap->mbox_list, +- &adap->mbox_lock)); ++ t4_os_atomic_list_del(entry, &adap->mbox_list, &adap->mbox_lock); + t4_report_fw_error(adap); +- free(temp); +- return (pcie_fw & F_PCIE_FW_ERR) ? -ENXIO : -ETIMEDOUT; ++ ret = ((pcie_fw & F_PCIE_FW_ERR) != 0) ? -ENXIO : -ETIMEDOUT; ++ ++out_free: ++ t4_os_free(entry); ++ return ret; + } + + int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size, +diff --git a/drivers/net/cxgbe/base/t4vf_hw.c b/drivers/net/cxgbe/base/t4vf_hw.c +index 561d759dbc..7dbd4deb79 100644 +--- a/drivers/net/cxgbe/base/t4vf_hw.c ++++ b/drivers/net/cxgbe/base/t4vf_hw.c +@@ -83,7 +83,7 @@ int t4vf_wr_mbox_core(struct adapter *adapter, + + u32 mbox_ctl = T4VF_CIM_BASE_ADDR + A_CIM_VF_EXT_MAILBOX_CTRL; + __be64 cmd_rpl[MBOX_LEN / 8]; +- struct mbox_entry entry; ++ struct mbox_entry *entry; + unsigned int delay_idx; + u32 v, mbox_data; + const __be64 *p; +@@ -106,13 +106,17 @@ int t4vf_wr_mbox_core(struct adapter *adapter, + size > NUM_CIM_VF_MAILBOX_DATA_INSTANCES * 4) + return -EINVAL; + ++ entry = t4_os_alloc(sizeof(*entry)); ++ if (entry == NULL) ++ return -ENOMEM; ++ + /* + * Queue ourselves onto the mailbox access list. When our entry is at + * the front of the list, we have rights to access the mailbox. So we + * wait [for a while] till we're at the front [or bail out with an + * EBUSY] ... + */ +- t4_os_atomic_add_tail(&entry, &adapter->mbox_list, &adapter->mbox_lock); ++ t4_os_atomic_add_tail(entry, &adapter->mbox_list, &adapter->mbox_lock); + + delay_idx = 0; + ms = delay[0]; +@@ -125,17 +129,17 @@ int t4vf_wr_mbox_core(struct adapter *adapter, + * contend on access to the mailbox ... + */ + if (i > (2 * FW_CMD_MAX_TIMEOUT)) { +- t4_os_atomic_list_del(&entry, &adapter->mbox_list, ++ t4_os_atomic_list_del(entry, &adapter->mbox_list, + &adapter->mbox_lock); + ret = -EBUSY; +- return ret; ++ goto out_free; + } + + /* + * If we're at the head, break out and start the mailbox + * protocol. + */ +- if (t4_os_list_first_entry(&adapter->mbox_list) == &entry) ++ if (t4_os_list_first_entry(&adapter->mbox_list) == entry) + break; + + /* +@@ -160,10 +164,10 @@ int t4vf_wr_mbox_core(struct adapter *adapter, + v = G_MBOWNER(t4_read_reg(adapter, mbox_ctl)); + + if (v != X_MBOWNER_PL) { +- t4_os_atomic_list_del(&entry, &adapter->mbox_list, ++ t4_os_atomic_list_del(entry, &adapter->mbox_list, + &adapter->mbox_lock); + ret = (v == X_MBOWNER_FW) ? -EBUSY : -ETIMEDOUT; +- return ret; ++ goto out_free; + } + + /* +@@ -224,7 +228,7 @@ int t4vf_wr_mbox_core(struct adapter *adapter, + get_mbox_rpl(adapter, cmd_rpl, size / 8, mbox_data); + t4_write_reg(adapter, mbox_ctl, + V_MBOWNER(X_MBOWNER_NONE)); +- t4_os_atomic_list_del(&entry, &adapter->mbox_list, ++ t4_os_atomic_list_del(entry, &adapter->mbox_list, + &adapter->mbox_lock); + + /* return value in high-order host-endian word */ +@@ -236,7 +240,8 @@ int t4vf_wr_mbox_core(struct adapter *adapter, + & F_FW_CMD_REQUEST) == 0); + memcpy(rpl, cmd_rpl, size); + } +- return -((int)G_FW_CMD_RETVAL(v)); ++ ret = -((int)G_FW_CMD_RETVAL(v)); ++ goto out_free; + } + } + +@@ -246,8 +251,11 @@ int t4vf_wr_mbox_core(struct adapter *adapter, + dev_err(adapter, "command %#x timed out\n", + *(const u8 *)cmd); + dev_err(adapter, " Control = %#x\n", t4_read_reg(adapter, mbox_ctl)); +- t4_os_atomic_list_del(&entry, &adapter->mbox_list, &adapter->mbox_lock); ++ t4_os_atomic_list_del(entry, &adapter->mbox_list, &adapter->mbox_lock); + ret = -ETIMEDOUT; ++ ++out_free: ++ t4_os_free(entry); + return ret; + } + +-- +2.23.0 + diff --git a/0343-kni-fix-build-with-Linux-6.3.patch b/0343-kni-fix-build-with-Linux-6.3.patch new file mode 100644 index 0000000..a2e6db2 --- /dev/null +++ b/0343-kni-fix-build-with-Linux-6.3.patch @@ -0,0 +1,52 @@ +From 5f34cc454df420b9b2da8deb949fb76cba058b87 Mon Sep 17 00:00:00 2001 +From: Ferruh Yigit +Date: Fri, 14 Apr 2023 16:25:22 +0100 +Subject: [PATCH] kni: fix build with Linux 6.3 + +KNI calls `get_user_pages_remote()` API which is using `FOLL_TOUCH` +flag, but `FOLL_TOUCH` is no more in public headers since v6.3, +causing a build error. + +`FOLL_*` defines in Linux kernel first moved to another header [1], +later some of them moved to memory subsystem internal header [2] for 6.3 + +`get_user_pages_remote()` already sets `FOLL_TOUCH` internally, +no need to set this flag externally anyway, moving flag from the call +altogether. + +[1] +Commit b5054174ac7c ("mm: move FOLL_* defs to mm_types.h") + +[2] +Commit 2c2241081f7d ("mm/gup: move private gup FOLL_ flags to internal.h") + +Fixes: e73831dc6c26 ("kni: support userspace VA") +Cc: stable@dpdk.org + +Signed-off-by: Ferruh Yigit +Reviewed-by: David Marchand +--- + kernel/linux/kni/kni_dev.h | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h +index a2c6d9fc1a..21bfb6890e 100644 +--- a/kernel/linux/kni/kni_dev.h ++++ b/kernel/linux/kni/kni_dev.h +@@ -105,11 +105,9 @@ static inline phys_addr_t iova_to_phys(struct task_struct *tsk, + + /* Read one page struct info */ + #ifdef HAVE_TSK_IN_GUP +- ret = get_user_pages_remote(tsk, tsk->mm, iova, 1, +- FOLL_TOUCH, &page, NULL, NULL); ++ ret = get_user_pages_remote(tsk, tsk->mm, iova, 1, 0, &page, NULL, NULL); + #else +- ret = get_user_pages_remote(tsk->mm, iova, 1, +- FOLL_TOUCH, &page, NULL, NULL); ++ ret = get_user_pages_remote(tsk->mm, iova, 1, 0, &page, NULL, NULL); + #endif + if (ret < 0) + return 0; +-- +2.23.0 + diff --git a/0344-kni-fix-build-with-Linux-6.5.patch b/0344-kni-fix-build-with-Linux-6.5.patch new file mode 100644 index 0000000..e817877 --- /dev/null +++ b/0344-kni-fix-build-with-Linux-6.5.patch @@ -0,0 +1,53 @@ +From dd33d53b9a032d7376aa04a28a1235338e1fd78f Mon Sep 17 00:00:00 2001 +From: Ferruh Yigit +Date: Tue, 11 Jul 2023 11:09:41 +0100 +Subject: [PATCH] kni: fix build with Linux 6.5 + +The get_user_pages_remote() API has been modified in Linux kernel v6.5 +[1], "struct vm_area_struct **vmas" parameter removed from the API. + +To fix KNI build with Linux kernel v6.5, version check added around the +get_user_pages_remote() API. + +[1] +ca5e863233e8 ("mm/gup: remove vmas parameter from get_user_pages_remote()") + +Cc: stable@dpdk.org + +Signed-off-by: Ferruh Yigit +--- + kernel/linux/kni/compat.h | 4 ++++ + kernel/linux/kni/kni_dev.h | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h +index 7aa6cd9fca..8beb670465 100644 +--- a/kernel/linux/kni/compat.h ++++ b/kernel/linux/kni/compat.h +@@ -149,3 +149,7 @@ + #if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE + #define HAVE_NETIF_RX_NI + #endif ++ ++#if KERNEL_VERSION(6, 5, 0) > LINUX_VERSION_CODE ++#define HAVE_VMA_IN_GUP ++#endif +diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h +index 21bfb6890e..975379825b 100644 +--- a/kernel/linux/kni/kni_dev.h ++++ b/kernel/linux/kni/kni_dev.h +@@ -107,7 +107,11 @@ static inline phys_addr_t iova_to_phys(struct task_struct *tsk, + #ifdef HAVE_TSK_IN_GUP + ret = get_user_pages_remote(tsk, tsk->mm, iova, 1, 0, &page, NULL, NULL); + #else ++ #ifdef HAVE_VMA_IN_GUP + ret = get_user_pages_remote(tsk->mm, iova, 1, 0, &page, NULL, NULL); ++ #else ++ ret = get_user_pages_remote(tsk->mm, iova, 1, 0, &page, NULL); ++ #endif + #endif + if (ret < 0) + return 0; +-- +2.23.0 + diff --git a/0345-doc-unify-sections-of-networking-drivers-guide.patch b/0345-doc-unify-sections-of-networking-drivers-guide.patch new file mode 100644 index 0000000..9c2509e --- /dev/null +++ b/0345-doc-unify-sections-of-networking-drivers-guide.patch @@ -0,0 +1,96 @@ +From 2bf5b0a8dfa64f336bd59aa807e5d576612627e6 Mon Sep 17 00:00:00 2001 +From: Ferruh Yigit +Date: Tue, 21 Mar 2023 23:59:09 +0000 +Subject: doc: unify sections of networking drivers guide + +[ upstream commit b583b9a1bb49e86aa0937d55415713282000c536 ] + +- Move supported device to the top +- Move supported features up +- Move limitations down +- Rename configuration sections +- Fix section indentation +- Remove empty sections +- Remove contact info as this is duplication of maintainers file + +This patch just fix hns3 PMD because others PMDs are very +conflicting. + +Signed-off-by: Ferruh Yigit +Acked-by: Hyong Youb Kim +Acked-by: Chengwen Feng +Acked-by: Dongdong Liu +Acked-by: Qi Zhang +Acked-by: Simei Su +Reviewed-by: Rosen Xu +Acked-by: Cristian Dumitrescu +Reviewed-by: Chenbo Xia +Reviewed-by: Igor Russkikh +Acked-by: Liron Himi +Acked-by: Jerin Jacob +Acked-by: Long Li +Acked-by: Sachin Saxena +--- + doc/guides/nics/hns3.rst | 30 +++++++++++++++--------------- + 1 file changed, 15 insertions(+), 15 deletions(-) + +diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst +index 791c9cc2ed..5373ec5a8f 100644 +--- a/doc/guides/nics/hns3.rst ++++ b/doc/guides/nics/hns3.rst +@@ -47,11 +47,21 @@ Prerequisites + - Follow the DPDK :ref:`Getting Started Guide for Linux ` to + setup the basic DPDK environment. + ++Link status event Pre-conditions ++~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +-Pre-Installation Configuration +------------------------------- ++Firmware 1.8.0.0 and later versions support reporting link changes to the PF. ++Therefore, to use the LSC for the PF driver, ensure that the firmware version ++also supports reporting link changes. ++If the VF driver needs to support LSC, special patch must be added: ++``_. ++Note: The patch has been uploaded to 5.13 of the Linux kernel mainline. ++ ++ ++Configuration ++------------- + +-Config File Options ++Compilation Options + ~~~~~~~~~~~~~~~~~~~ + + The following options can be modified in the ``config/rte_config.h`` file. +@@ -60,8 +70,8 @@ The following options can be modified in the ``config/rte_config.h`` file. + + Number of MAX queues reserved for PF. + +-Runtime Config Options +-~~~~~~~~~~~~~~~~~~~~~~ ++Runtime Configuration ++~~~~~~~~~~~~~~~~~~~~~ + + - ``rx_func_hint`` (default ``none``) + +@@ -130,16 +140,6 @@ Runtime Config Options + For example:: + -a 0000:7d:00.0,mbx_time_limit_ms=600 + +-Link status event Pre-conditions +-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +-Firmware 1.8.0.0 and later versions support reporting link changes to the PF. +-Therefore, to use the LSC for the PF driver, ensure that the firmware version +-also supports reporting link changes. +-If the VF driver needs to support LSC, special patch must be added: +-``_. +-Note: The patch has been uploaded to 5.13 of the Linux kernel mainline. +- + + Driver compilation and testing + ------------------------------ +-- +2.23.0 + diff --git a/0346-net-hns3-delete-duplicate-macro-definition.patch b/0346-net-hns3-delete-duplicate-macro-definition.patch new file mode 100644 index 0000000..6c2f2d5 --- /dev/null +++ b/0346-net-hns3-delete-duplicate-macro-definition.patch @@ -0,0 +1,39 @@ +From afbdff81bcfc8c16fffc7431c247684cf3451154 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 29 Jun 2023 21:21:26 +0800 +Subject: net/hns3: delete duplicate macro definition + +[ upstream commit d48709625a2bf0f64692d925e17e254ba0dc2351 ] + +This patch delete some duplicate macro definitions. + +Fixes: a4c7152d0581 ("net/hns3: extract common code to its own file") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.h | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h +index c58094d87b..c85a6912ad 100644 +--- a/drivers/net/hns3/hns3_ethdev.h ++++ b/drivers/net/hns3/hns3_ethdev.h +@@ -873,13 +873,6 @@ struct hns3_adapter { + struct hns3_ptype_table ptype_tbl __rte_cache_aligned; + }; + +-#define HNS3_DEVARG_RX_FUNC_HINT "rx_func_hint" +-#define HNS3_DEVARG_TX_FUNC_HINT "tx_func_hint" +- +-#define HNS3_DEVARG_DEV_CAPS_MASK "dev_caps_mask" +- +-#define HNS3_DEVARG_MBX_TIME_LIMIT_MS "mbx_time_limit_ms" +- + enum hns3_dev_cap { + HNS3_DEV_SUPPORT_DCB_B, + HNS3_DEV_SUPPORT_COPPER_B, +-- +2.23.0 + diff --git a/0347-net-hns3-add-FDIR-VLAN-match-mode-runtime-config.patch b/0347-net-hns3-add-FDIR-VLAN-match-mode-runtime-config.patch new file mode 100644 index 0000000..3f6062c --- /dev/null +++ b/0347-net-hns3-add-FDIR-VLAN-match-mode-runtime-config.patch @@ -0,0 +1,201 @@ +From 01285f3f7ccbd4e3604c1cf00b6a9be2a9428502 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 29 Jun 2023 21:21:27 +0800 +Subject: net/hns3: add FDIR VLAN match mode runtime config + +[ upstream commit 5f107c4d7b7bfbc3fcaf98b4ca2963cc3e48fe93 ] + +The VLAN number in FDIR meta data is used to enable that hardware +bases on VLAN number to strictly match the input flow. And it is +enabled by default. + +For the following two rules: +rule0: + pattern: eth type is 0x0806 + actions: queue index 3 +rule1: + pattern: eth type is 0x0806 / vlan vid is 20 + actions: queue index 4 +If enable VLAN number, only the ARP packets with VLAN 20 are directed +to queue 4, and the ARP packets with other VLAN ID cannot be directed +to the specified queue. If app want to all ARP (VLAN or no VLAN) +packets to be directed to the specified queue, app has to set many +rules for VLAN packet. In this case, if driver doesn't enable VLAN +number, app just need to set one rule (rule0). + +So this patch adds a "fdir_vlan_match_mode" runtime config which only +can be 'strict' or 'nostrict'. And driver still uses 'strict' mode as +the default mode. Please select 'nostrict' mode if you request all same +ethertype packets with and without VLAN to a specified queue. + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + doc/guides/nics/hns3.rst | 27 ++++++++++++++++++++++++++ + drivers/net/hns3/hns3_common.c | 35 ++++++++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_common.h | 2 ++ + drivers/net/hns3/hns3_fdir.c | 10 +++++++--- + drivers/net/hns3/hns3_fdir.h | 8 ++++++++ + 5 files changed, 79 insertions(+), 3 deletions(-) + +diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst +index 172fcdb29f..644d520b64 100644 +--- a/doc/guides/nics/hns3.rst ++++ b/doc/guides/nics/hns3.rst +@@ -144,6 +144,33 @@ Runtime Configuration + For example:: + -a 0000:7d:00.0,mbx_time_limit_ms=600 + ++- ``fdir_vlan_match_mode`` (default ``strict``) ++ ++ Used to select VLAN match mode. This runtime config can be ``strict`` ++ or ``nostrict`` and is only valid for PF devices. ++ If driver works on ``strict`` mode (default mode), hardware does strictly ++ match the input flow base on VLAN number. ++ ++ For the following scenarios with two rules: ++ ++ .. code-block:: console ++ ++ rule0: ++ pattern: eth type is 0x0806 ++ actions: queue index 3 ++ rule1: ++ pattern: eth type is 0x0806 / vlan vid is 20 ++ actions: queue index 4 ++ ++ If application select ``strict`` mode, only the ARP packets with VLAN ++ 20 are directed to queue 4, and the ARP packets with other VLAN ID ++ cannot be directed to the specified queue. If application want to all ++ ARP packets with or without VLAN to be directed to the specified queue, ++ application can select ``nostrict`` mode and just need to set rule0. ++ ++ For example:: ++ ++ -a 0000:7d:00.0,fdir_vlan_match_mode=nostrict + + Driver compilation and testing + ------------------------------ +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 6697ecefe6..a7b576aa60 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -236,6 +236,34 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) + return 0; + } + ++static int ++hns3_parse_vlan_match_mode(const char *key, const char *value, void *args) ++{ ++ uint8_t mode; ++ ++ RTE_SET_USED(key); ++ ++ if (value == NULL) { ++ PMD_INIT_LOG(WARNING, "no value for key:\"%s\"", key); ++ return -1; ++ } ++ ++ if (strcmp(value, "strict") == 0) { ++ mode = HNS3_FDIR_VLAN_STRICT_MATCH; ++ } else if (strcmp(value, "nostrict") == 0) { ++ mode = HNS3_FDIR_VLAN_NOSTRICT_MATCH; ++ } else { ++ PMD_INIT_LOG(WARNING, "invalid value:\"%s\" for key:\"%s\", " ++ "value must be 'strict' or 'nostrict'", ++ value, key); ++ return -1; ++ } ++ ++ *(uint8_t *)args = mode; ++ ++ return 0; ++} ++ + void + hns3_parse_devargs(struct rte_eth_dev *dev) + { +@@ -252,6 +280,8 @@ hns3_parse_devargs(struct rte_eth_dev *dev) + hns->tx_func_hint = HNS3_IO_FUNC_HINT_NONE; + hns->dev_caps_mask = 0; + hns->mbx_time_limit_ms = HNS3_MBX_DEF_TIME_LIMIT_MS; ++ if (!hns->is_vf) ++ hns->pf.fdir.vlan_match_mode = HNS3_FDIR_VLAN_STRICT_MATCH; + + if (dev->device->devargs == NULL) + return; +@@ -268,6 +298,11 @@ hns3_parse_devargs(struct rte_eth_dev *dev) + &hns3_parse_dev_caps_mask, &dev_caps_mask); + (void)rte_kvargs_process(kvlist, HNS3_DEVARG_MBX_TIME_LIMIT_MS, + &hns3_parse_mbx_time_limit, &mbx_time_limit_ms); ++ if (!hns->is_vf) ++ (void)rte_kvargs_process(kvlist, ++ HNS3_DEVARG_FDIR_VALN_MATCH_MODE, ++ &hns3_parse_vlan_match_mode, ++ &hns->pf.fdir.vlan_match_mode); + + rte_kvargs_free(kvlist); + +diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h +index 8eaeda26e7..cf9593bd0c 100644 +--- a/drivers/net/hns3/hns3_common.h ++++ b/drivers/net/hns3/hns3_common.h +@@ -27,6 +27,8 @@ enum { + + #define HNS3_DEVARG_MBX_TIME_LIMIT_MS "mbx_time_limit_ms" + ++#define HNS3_DEVARG_FDIR_VALN_MATCH_MODE "fdir_vlan_match_mode" ++ + #define MSEC_PER_SEC 1000L + #define USEC_PER_MSEC 1000L + +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index 48a91fb517..c80fa59e63 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -355,9 +355,13 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + /* roce_type is used to filter roce frames + * dst_vport is used to specify the rule + */ +- key_cfg->meta_data_active = BIT(DST_VPORT) | BIT(TUNNEL_PACKET) | +- BIT(VLAN_NUMBER); +- hns3_dbg(hw, "fdir meta data: dst_vport tunnel_packet vlan_number"); ++ key_cfg->meta_data_active = BIT(DST_VPORT) | BIT(TUNNEL_PACKET); ++ if (pf->fdir.vlan_match_mode) ++ key_cfg->meta_data_active |= BIT(VLAN_NUMBER); ++ ++ hns3_dbg(hw, "fdir meta data: dst_vport tunnel_packet %s", ++ (pf->fdir.vlan_match_mode == HNS3_FDIR_VLAN_STRICT_MATCH) ? ++ "vlan_number" : ""); + + ret = hns3_get_fd_allocation(hw, + &pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1], +diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h +index ce70a534dc..308cfbe56f 100644 +--- a/drivers/net/hns3/hns3_fdir.h ++++ b/drivers/net/hns3/hns3_fdir.h +@@ -170,6 +170,13 @@ struct hns3_fdir_rule_ele { + + TAILQ_HEAD(hns3_fdir_rule_list, hns3_fdir_rule_ele); + ++/* ++ * On 'strict' mode, hardware bases on VLAN number to exactly match the ++ * input flow. ++ */ ++#define HNS3_FDIR_VLAN_STRICT_MATCH 1 ++#define HNS3_FDIR_VLAN_NOSTRICT_MATCH 0 ++ + /* + * A structure used to define fields of a FDIR related info. + */ +@@ -178,6 +185,7 @@ struct hns3_fdir_info { + struct hns3_fdir_rule_ele **hash_map; + struct rte_hash *hash_handle; + struct hns3_fd_cfg fd_cfg; ++ uint8_t vlan_match_mode; + }; + + struct hns3_adapter; +-- +2.23.0 + diff --git a/0348-doc-fix-kernel-patch-link-in-hns3-guide.patch b/0348-doc-fix-kernel-patch-link-in-hns3-guide.patch new file mode 100644 index 0000000..fcfb1b9 --- /dev/null +++ b/0348-doc-fix-kernel-patch-link-in-hns3-guide.patch @@ -0,0 +1,38 @@ +From 3838f68b46b37050749a066dd5e956ca930b5658 Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Fri, 30 Jun 2023 15:37:35 +0800 +Subject: doc: fix kernel patch link in hns3 guide + +[ upstream commit c6a4242b86a020b79d48f9dcc533be113a8df7c8 ] + +The LSC support of VF driver depends on a patch link in kernel PF +driver. +But current the link is invalid, so fixes it. + +Add a blank line after the link. + +Fixes: 80006b598730 ("doc: add link status event requirements in hns3 guide") +Cc: stable@dpdk.org + +Signed-off-by: Dongdong Liu +--- + doc/guides/nics/hns3.rst | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst +index 5373ec5a8f..82fa79dd73 100644 +--- a/doc/guides/nics/hns3.rst ++++ b/doc/guides/nics/hns3.rst +@@ -54,7 +54,8 @@ Firmware 1.8.0.0 and later versions support reporting link changes to the PF. + Therefore, to use the LSC for the PF driver, ensure that the firmware version + also supports reporting link changes. + If the VF driver needs to support LSC, special patch must be added: +-``_. ++``_. ++ + Note: The patch has been uploaded to 5.13 of the Linux kernel mainline. + + +-- +2.23.0 + diff --git a/0349-doc-fix-syntax-in-hns3-guide.patch b/0349-doc-fix-syntax-in-hns3-guide.patch new file mode 100644 index 0000000..e187abb --- /dev/null +++ b/0349-doc-fix-syntax-in-hns3-guide.patch @@ -0,0 +1,49 @@ +From 906df53424e1b95ff72af509a05bbf048072a933 Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Fri, 30 Jun 2023 15:37:36 +0800 +Subject: doc: fix syntax in hns3 guide + +[ upstream commit 059268551587f6fd929951dd7f5706bbdc46abcd ] + +'::' doesn't provide pre-formatted text without an empty line after it, +so fixes it. + +Fixes: cdf6a5fbc540 ("doc: add runtime option examples to hns3 guide") +Cc: stable@dpdk.org + +Signed-off-by: Dongdong Liu +--- + doc/guides/nics/hns3.rst | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst +index 82fa79dd73..172fcdb29f 100644 +--- a/doc/guides/nics/hns3.rst ++++ b/doc/guides/nics/hns3.rst +@@ -92,6 +92,7 @@ Runtime Configuration + ``common``. + + For example:: ++ + -a 0000:7d:00.0,rx_func_hint=simple + + - ``tx_func_hint`` (default ``none``) +@@ -112,6 +113,7 @@ Runtime Configuration + ``common``. + + For example:: ++ + -a 0000:7d:00.0,tx_func_hint=common + + - ``dev_caps_mask`` (default ``0``) +@@ -124,6 +126,7 @@ Runtime Configuration + Its main purpose is to debug and avoid problems. + + For example:: ++ + -a 0000:7d:00.0,dev_caps_mask=0xF + + - ``mbx_time_limit_ms`` (default ``500``) +-- +2.23.0 + diff --git a/0350-doc-fix-number-of-leading-spaces-in-hns3-guide.patch b/0350-doc-fix-number-of-leading-spaces-in-hns3-guide.patch new file mode 100644 index 0000000..89e7ca9 --- /dev/null +++ b/0350-doc-fix-number-of-leading-spaces-in-hns3-guide.patch @@ -0,0 +1,83 @@ +From bb21b8e295cf30381e12629096dd3f0ab7a47b6e Mon Sep 17 00:00:00 2001 +From: Dongdong Liu +Date: Fri, 30 Jun 2023 15:37:37 +0800 +Subject: doc: fix number of leading spaces in hns3 guide + +[ upstream commit 620cd2d5ac5a6d7de750a4827e2840209a1b0cbb ] + +The current description of 'mbx_time_limit_ms' has three spaces +at the beginning. Use two spaces to keep the same style with other +places and add a blank line after '::'. + +Fixes: 2fc3e696a7f1 ("net/hns3: add runtime config for mailbox limit time") +Cc: stable@dpdk.org + +Signed-off-by: Dongdong Liu +--- + doc/guides/nics/hns3.rst | 34 ++++++++++++++++++---------------- + 1 file changed, 18 insertions(+), 16 deletions(-) + +diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst +index 644d520b64..8705845d8e 100644 +--- a/doc/guides/nics/hns3.rst ++++ b/doc/guides/nics/hns3.rst +@@ -93,7 +93,7 @@ Runtime Configuration + + For example:: + +- -a 0000:7d:00.0,rx_func_hint=simple ++ -a 0000:7d:00.0,rx_func_hint=simple + + - ``tx_func_hint`` (default ``none``) + +@@ -114,7 +114,7 @@ Runtime Configuration + + For example:: + +- -a 0000:7d:00.0,tx_func_hint=common ++ -a 0000:7d:00.0,tx_func_hint=common + + - ``dev_caps_mask`` (default ``0``) + +@@ -127,22 +127,24 @@ Runtime Configuration + + For example:: + +- -a 0000:7d:00.0,dev_caps_mask=0xF ++ -a 0000:7d:00.0,dev_caps_mask=0xF + + - ``mbx_time_limit_ms`` (default ``500``) +- Used to define the mailbox time limit by user. +- Current, the max waiting time for MBX response is 500ms, but in +- some scenarios, it is not enough. Since it depends on the response +- of the kernel mode driver, and its response time is related to the +- scheduling of the system. In this special scenario, most of the +- cores are isolated, and only a few cores are used for system +- scheduling. When a large number of services are started, the +- scheduling of the system will be very busy, and the reply of the +- mbx message will time out, which will cause our PMD initialization +- to fail. So provide access to set mailbox time limit for user. +- +- For example:: +- -a 0000:7d:00.0,mbx_time_limit_ms=600 ++ ++ Used to define the mailbox time limit by user. ++ Current, the max waiting time for MBX response is 500ms, but in ++ some scenarios, it is not enough. Since it depends on the response ++ of the kernel mode driver, and its response time is related to the ++ scheduling of the system. In this special scenario, most of the ++ cores are isolated, and only a few cores are used for system ++ scheduling. When a large number of services are started, the ++ scheduling of the system will be very busy, and the reply of the ++ mbx message will time out, which will cause our PMD initialization ++ to fail. So provide access to set mailbox time limit for user. ++ ++ For example:: ++ ++ -a 0000:7d:00.0,mbx_time_limit_ms=600 + + - ``fdir_vlan_match_mode`` (default ``strict``) + +-- +2.23.0 + diff --git a/CVE-2020-10722.patch b/CVE-2020-10722.patch deleted file mode 100644 index 15c19d9..0000000 --- a/CVE-2020-10722.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 2cf9c470ebff0091e41af85f16ab906fd98cf9af Mon Sep 17 00:00:00 2001 -From: Maxime Coquelin -Date: Tue, 21 Apr 2020 11:16:56 +0200 -Subject: vhost: check log mmap offset and size overflow - -vhost_user_set_log_base() is a message handler that is -called to handle the VHOST_USER_SET_LOG_BASE message. -Its payload contains a 64 bit size and offset. Both are -added up and used as a size when calling mmap(). - -There is no integer overflow check. If an integer overflow -occurs a smaller memory map would be created than -requested. Since the returned mapping is mapped as writable -and used for logging, a memory corruption could occur. - -Fixes: fbc4d248b198 ("vhost: fix offset while mmaping log base address") - -This issue has been assigned CVE-2020-10722 - -Reported-by: Ilja Van Sprundel -Signed-off-by: Maxime Coquelin -Reviewed-by: Xiaolong Ye -Reviewed-by: Ilja Van Sprundel ---- - lib/librte_vhost/vhost_user.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c -index 40c4520..02962fc 100644 ---- a/lib/librte_vhost/vhost_user.c -+++ b/lib/librte_vhost/vhost_user.c -@@ -2060,10 +2060,10 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg, - size = msg->payload.log.mmap_size; - off = msg->payload.log.mmap_offset; - -- /* Don't allow mmap_offset to point outside the mmap region */ -- if (off > size) { -+ /* Check for mmap size and offset overflow. */ -+ if (off >= -size) { - RTE_LOG(ERR, VHOST_CONFIG, -- "log offset %#"PRIx64" exceeds log size %#"PRIx64"\n", -+ "log offset %#"PRIx64" and log size %#"PRIx64" overflow\n", - off, size); - return RTE_VHOST_MSG_RESULT_ERR; - } --- -cgit v1.0 - diff --git a/CVE-2020-10723.patch b/CVE-2020-10723.patch deleted file mode 100644 index 045a330..0000000 --- a/CVE-2020-10723.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 8e9652b0b616a3704b5cb5a3dccb2c239e16ab9c Mon Sep 17 00:00:00 2001 -From: Maxime Coquelin -Date: Tue, 21 Apr 2020 18:17:43 +0200 -Subject: vhost: fix vring index check - -vhost_user_check_and_alloc_queue_pair() is used to extract -a vring index from a payload. This function validates the -index and is called early on in when performing message -handling. Most message handlers depend on it correctly -validating the vring index. - -Depending on the message type the vring index is in -different parts of the payload. The function contains a -switch/case for each type and copies the index. This is -stored in a uint16. This index is then validated. Depending -on the message, the source index is an unsigned int. If -integer truncation occurs (uint->uint16) the top 16 bits -of the index are never validated. - -When they are used later on (e.g. in -vhost_user_set_vring_num() or vhost_user_set_vring_addr()) -it can lead to out of bound indexing. The out of bound -indexed data gets written to, and hence this can cause -memory corruption. - -This patch fixes this vulnerability by declaring vring -index as an unsigned int in -vhost_user_check_and_alloc_queue_pair(). - -Fixes: 160cbc815b41 ("vhost: remove a hack on queue allocation") - -This issue has been assigned CVE-2020-10723 - -Reported-by: Ilja Van Sprundel -Signed-off-by: Maxime Coquelin -Reviewed-by: Xiaolong Ye -Reviewed-by: Ilja Van Sprundel ---- - lib/librte_vhost/vhost_user.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c -index 02962fc..d196142 100644 ---- a/lib/librte_vhost/vhost_user.c -+++ b/lib/librte_vhost/vhost_user.c -@@ -2508,7 +2508,7 @@ static int - vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, - struct VhostUserMsg *msg) - { -- uint16_t vring_idx; -+ uint32_t vring_idx; - - switch (msg->request.master) { - case VHOST_USER_SET_VRING_KICK: --- -cgit v1.0 - diff --git a/CVE-2020-10724.patch b/CVE-2020-10724.patch deleted file mode 100644 index 729d4db..0000000 --- a/CVE-2020-10724.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 963b6eea05f3ee720fcfecd110e20f61b92205d6 Mon Sep 17 00:00:00 2001 -From: Maxime Coquelin -Date: Tue, 21 Apr 2020 19:10:09 +0200 -Subject: vhost/crypto: validate keys lengths - -transform_cipher_param() and transform_chain_param() handle -the payload data for the VHOST_USER_CRYPTO_CREATE_SESS -message. These payloads have to be validated, since it -could come from untrusted sources. - -Two buffers and their lenghts are defined in this payload, -one the the auth key and one for the cipher key. But above -functions do not validate the key length inputs, which could -lead to read out of bounds, as buffers have static sizes of -64 bytes for the cipher key and 512 bytes for the auth key. - -This patch adds necessary checks on the key length field -before being used. - -Fixes: e80a98708166 ("vhost/crypto: add session message handler") - -This issue has been assigned CVE-2020-10724 - -Reported-by: Ilja Van Sprundel -Signed-off-by: Maxime Coquelin -Reviewed-by: Xiaolong Ye -Reviewed-by: Ilja Van Sprundel ---- - lib/librte_vhost/vhost_crypto.c | 17 +++++++++++++++++ - 1 file changed, 17 insertions(+) - -diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c -index 6891197..07a4115 100644 ---- a/lib/librte_vhost/vhost_crypto.c -+++ b/lib/librte_vhost/vhost_crypto.c -@@ -237,6 +237,11 @@ transform_cipher_param(struct rte_crypto_sym_xform *xform, - if (unlikely(ret < 0)) - return ret; - -+ if (param->cipher_key_len > VHOST_USER_CRYPTO_MAX_CIPHER_KEY_LENGTH) { -+ VC_LOG_DBG("Invalid cipher key length\n"); -+ return -VIRTIO_CRYPTO_BADMSG; -+ } -+ - xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER; - xform->cipher.key.length = param->cipher_key_len; - if (xform->cipher.key.length > 0) -@@ -287,6 +292,12 @@ transform_chain_param(struct rte_crypto_sym_xform *xforms, - &xform_cipher->cipher.algo); - if (unlikely(ret < 0)) - return ret; -+ -+ if (param->cipher_key_len > VHOST_USER_CRYPTO_MAX_CIPHER_KEY_LENGTH) { -+ VC_LOG_DBG("Invalid cipher key length\n"); -+ return -VIRTIO_CRYPTO_BADMSG; -+ } -+ - xform_cipher->type = RTE_CRYPTO_SYM_XFORM_CIPHER; - xform_cipher->cipher.key.length = param->cipher_key_len; - xform_cipher->cipher.key.data = param->cipher_key_buf; -@@ -301,6 +312,12 @@ transform_chain_param(struct rte_crypto_sym_xform *xforms, - ret = auth_algo_transform(param->hash_algo, &xform_auth->auth.algo); - if (unlikely(ret < 0)) - return ret; -+ -+ if (param->auth_key_len > VHOST_USER_CRYPTO_MAX_HMAC_KEY_LENGTH) { -+ VC_LOG_DBG("Invalid auth key length\n"); -+ return -VIRTIO_CRYPTO_BADMSG; -+ } -+ - xform_auth->auth.digest_length = param->digest_len; - xform_auth->auth.key.length = param->auth_key_len; - xform_auth->auth.key.data = param->auth_key_buf; --- -cgit v1.0 - diff --git a/CVE-2020-10725.patch b/CVE-2020-10725.patch deleted file mode 100644 index a6eba33..0000000 --- a/CVE-2020-10725.patch +++ /dev/null @@ -1,44 +0,0 @@ -From cd0ea71bb6a7d1c503bf2f6f1e3c455cf246d9a1 Mon Sep 17 00:00:00 2001 -From: Marvin Liu -Date: Wed, 8 Apr 2020 17:13:55 +0800 -Subject: vhost: fix translated address not checked - -Malicious guest can construct desc with invalid address and zero buffer -length. That will request vhost to check both translated address and -translated data length. This patch will add missed address check. - -Fixes: 75ed51697820 ("vhost: add packed ring batch dequeue") -Fixes: ef861692c398 ("vhost: add packed ring batch enqueue") - -This issue has been assigned CVE-2020-10725 - -Signed-off-by: Marvin Liu -Reviewed-by: Maxime Coquelin ---- - lib/librte_vhost/virtio_net.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c -index ac2842b..33f1025 100644 ---- a/lib/librte_vhost/virtio_net.c -+++ b/lib/librte_vhost/virtio_net.c -@@ -1086,6 +1086,8 @@ virtio_dev_rx_batch_packed(struct virtio_net *dev, - VHOST_ACCESS_RW); - - vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { -+ if (unlikely(!desc_addrs[i])) -+ return -1; - if (unlikely(lens[i] != descs[avail_idx + i].len)) - return -1; - } -@@ -1841,6 +1843,8 @@ vhost_reserve_avail_batch_packed(struct virtio_net *dev, - } - - vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { -+ if (unlikely(!desc_addrs[i])) -+ return -1; - if (unlikely((lens[i] != descs[avail_idx + i].len))) - return -1; - } --- -cgit v1.0 \ No newline at end of file diff --git a/CVE-2020-10726.patch b/CVE-2020-10726.patch deleted file mode 100644 index 853ef90..0000000 --- a/CVE-2020-10726.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 95e1f29c26777ee36456e340ed9c2b07472add28 Mon Sep 17 00:00:00 2001 -From: Xiaolong Ye -Date: Wed, 8 Apr 2020 15:31:35 +0800 -Subject: vhost: fix potential memory space leak - -A malicious container which has direct access to the vhost-user socket -can keep sending VHOST_USER_GET_INFLIGHT_FD messages which may cause -leaking resources until resulting a DOS. Fix it by unmapping the -dev->inflight_info->addr before assigning new mapped addr to it. - -Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing") - -This issue has been assigned CVE-2020-10726 - -Signed-off-by: Xiaolong Ye -Reviewed-by: Maxime Coquelin ---- - lib/librte_vhost/vhost_user.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c -index d196142..2a4ba20 100644 ---- a/lib/librte_vhost/vhost_user.c -+++ b/lib/librte_vhost/vhost_user.c -@@ -1440,6 +1440,11 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, - } - memset(addr, 0, mmap_size); - -+ if (dev->inflight_info->addr) { -+ munmap(dev->inflight_info->addr, dev->inflight_info->size); -+ dev->inflight_info->addr = NULL; -+ } -+ - dev->inflight_info->addr = addr; - dev->inflight_info->size = msg->payload.inflight.mmap_size = mmap_size; - dev->inflight_info->fd = msg->fds[0] = fd; -@@ -1524,8 +1529,10 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg, - } - } - -- if (dev->inflight_info->addr) -+ if (dev->inflight_info->addr) { - munmap(dev->inflight_info->addr, dev->inflight_info->size); -+ dev->inflight_info->addr = NULL; -+ } - - addr = mmap(0, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, - fd, mmap_offset); --- -cgit v1.0 - diff --git a/CVE-2020-14374.patch b/CVE-2020-14374.patch deleted file mode 100644 index 14bc0d9..0000000 --- a/CVE-2020-14374.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 6a3a414698e45cf01bb1489ef81f4d663a88047b Mon Sep 17 00:00:00 2001 -From: Fan Zhang -Date: Thu, 16 Apr 2020 11:29:06 +0100 -Subject: vhost/crypto: fix data length check - -This patch fixes the incorrect data length check to vhost crypto. -Instead of blindly accepting the descriptor length as data length, the -change compare the request provided data length and descriptor length -first. The security issue CVE-2020-14374 is not fixed alone by this -patch, part of the fix is done through: -"vhost/crypto: fix missed request check for copy mode". - -CVE-2020-14374 -Fixes: 3c79609fda7c ("vhost/crypto: handle virtually non-contiguous buffers") -Cc: stable@dpdk.org - -Signed-off-by: Fan Zhang -Acked-by: Chenbo Xia - -reference:https://git.dpdk.org/dpdk-stable/commit/?h=19.11&id=6a3a414698e4 -Signed-off-by: gaoxingwang ---- - lib/librte_vhost/vhost_crypto.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c -index f1cc32a..cf9aa25 100644 ---- a/lib/librte_vhost/vhost_crypto.c -+++ b/lib/librte_vhost/vhost_crypto.c -@@ -624,7 +624,7 @@ copy_data(void *dst_data, struct vhost_crypto_data_req *vc_req, - desc = &vc_req->head[desc->next]; - rte_prefetch0(&vc_req->head[desc->next]); - to_copy = RTE_MIN(desc->len, (uint32_t)left); -- dlen = desc->len; -+ dlen = to_copy; - src = IOVA_TO_VVA(uint8_t *, vc_req, desc->addr, &dlen, - VHOST_ACCESS_RO); - if (unlikely(!src || !dlen)) { --- -cgit v1.0 diff --git a/CVE-2020-14375.patch b/CVE-2020-14375.patch deleted file mode 100644 index 02afbfa..0000000 --- a/CVE-2020-14375.patch +++ /dev/null @@ -1,803 +0,0 @@ -From e2666ec24535c7ba0fb325d61a753bcabc8bf1ae Mon Sep 17 00:00:00 2001 -From: Fan Zhang -Date: Wed, 9 Sep 2020 09:35:53 +0100 -Subject: vhost/crypto: fix possible TOCTOU attack - -This patch fixes the possible time-of-check to time-of-use (TOCTOU) -attack problem by copying request data and descriptor index to local -variable prior to process. - -Also the original sequential read of descriptors may lead to TOCTOU -attack. This patch fixes the problem by loading all descriptors of a -request to local buffer before processing. - -CVE-2020-14375 -Fixes: 3bb595ecd682 ("vhost/crypto: add request handler") -Cc: stable@dpdk.org - -Signed-off-by: Fan Zhang -Acked-by: Chenbo Xia - -reference:https://git.dpdk.org/dpdk-stable/commit/?h=19.11&id=e2666ec24535 -Signed-off-by: gaoxingwang ---- - lib/librte_vhost/rte_vhost_crypto.h | 2 + - lib/librte_vhost/vhost_crypto.c | 391 ++++++++++++++++++------------------ - 2 files changed, 202 insertions(+), 191 deletions(-) - -diff --git a/lib/librte_vhost/rte_vhost_crypto.h b/lib/librte_vhost/rte_vhost_crypto.h -index 866a592..b54d61d 100644 ---- a/lib/librte_vhost/rte_vhost_crypto.h -+++ b/lib/librte_vhost/rte_vhost_crypto.h -@@ -7,10 +7,12 @@ - - #define VHOST_CRYPTO_MBUF_POOL_SIZE (8192) - #define VHOST_CRYPTO_MAX_BURST_SIZE (64) -+#define VHOST_CRYPTO_MAX_DATA_SIZE (4096) - #define VHOST_CRYPTO_SESSION_MAP_ENTRIES (1024) /**< Max nb sessions */ - /** max nb virtual queues in a burst for finalizing*/ - #define VIRTIO_CRYPTO_MAX_NUM_BURST_VQS (64) - #define VHOST_CRYPTO_MAX_IV_LEN (32) -+#define VHOST_CRYPTO_MAX_N_DESC (32) - - enum rte_vhost_crypto_zero_copy { - RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE = 0, -diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c -index cf9aa25..e08f9c6 100644 ---- a/lib/librte_vhost/vhost_crypto.c -+++ b/lib/librte_vhost/vhost_crypto.c -@@ -46,6 +46,14 @@ - #define IOVA_TO_VVA(t, r, a, l, p) \ - ((t)(uintptr_t)vhost_iova_to_vva(r->dev, r->vq, a, l, p)) - -+/* -+ * vhost_crypto_desc is used to copy original vring_desc to the local buffer -+ * before processing (except the next index). The copy result will be an -+ * array of vhost_crypto_desc elements that follows the sequence of original -+ * vring_desc.next is arranged. -+ */ -+#define vhost_crypto_desc vring_desc -+ - static int - cipher_algo_transform(uint32_t virtio_cipher_algo, - enum rte_crypto_cipher_algorithm *algo) -@@ -479,83 +487,71 @@ vhost_crypto_msg_post_handler(int vid, void *msg) - return ret; - } - --static __rte_always_inline struct vring_desc * --find_write_desc(struct vring_desc *head, struct vring_desc *desc, -- uint32_t *nb_descs, uint32_t vq_size) -+static __rte_always_inline struct vhost_crypto_desc * -+find_write_desc(struct vhost_crypto_desc *head, struct vhost_crypto_desc *desc, -+ uint32_t max_n_descs) - { -- if (desc->flags & VRING_DESC_F_WRITE) -- return desc; -- -- while (desc->flags & VRING_DESC_F_NEXT) { -- if (unlikely(*nb_descs == 0 || desc->next >= vq_size)) -- return NULL; -- (*nb_descs)--; -+ if (desc < head) -+ return NULL; - -- desc = &head[desc->next]; -+ while (desc - head < (int)max_n_descs) { - if (desc->flags & VRING_DESC_F_WRITE) - return desc; -+ desc++; - } - - return NULL; - } - --static struct virtio_crypto_inhdr * --reach_inhdr(struct vhost_crypto_data_req *vc_req, struct vring_desc *desc, -- uint32_t *nb_descs, uint32_t vq_size) -+static __rte_always_inline struct virtio_crypto_inhdr * -+reach_inhdr(struct vhost_crypto_data_req *vc_req, -+ struct vhost_crypto_desc *head, -+ uint32_t max_n_descs) - { -- uint64_t dlen; - struct virtio_crypto_inhdr *inhdr; -+ struct vhost_crypto_desc *last = head + (max_n_descs - 1); -+ uint64_t dlen = last->len; - -- while (desc->flags & VRING_DESC_F_NEXT) { -- if (unlikely(*nb_descs == 0 || desc->next >= vq_size)) -- return NULL; -- (*nb_descs)--; -- desc = &vc_req->head[desc->next]; -- } -+ if (unlikely(dlen != sizeof(*inhdr))) -+ return NULL; - -- dlen = desc->len; -- inhdr = IOVA_TO_VVA(struct virtio_crypto_inhdr *, vc_req, desc->addr, -+ inhdr = IOVA_TO_VVA(struct virtio_crypto_inhdr *, vc_req, last->addr, - &dlen, VHOST_ACCESS_WO); -- if (unlikely(!inhdr || dlen != desc->len)) -+ if (unlikely(!inhdr || dlen != last->len)) - return NULL; - - return inhdr; - } - - static __rte_always_inline int --move_desc(struct vring_desc *head, struct vring_desc **cur_desc, -- uint32_t size, uint32_t *nb_descs, uint32_t vq_size) -+move_desc(struct vhost_crypto_desc *head, -+ struct vhost_crypto_desc **cur_desc, -+ uint32_t size, uint32_t max_n_descs) - { -- struct vring_desc *desc = *cur_desc; -+ struct vhost_crypto_desc *desc = *cur_desc; - int left = size - desc->len; - -- while ((desc->flags & VRING_DESC_F_NEXT) && left > 0) { -- if (unlikely(*nb_descs == 0 || desc->next >= vq_size)) -- return -1; -- -- desc = &head[desc->next]; -- rte_prefetch0(&head[desc->next]); -+ while (desc->flags & VRING_DESC_F_NEXT && left > 0 && -+ desc >= head && -+ desc - head < (int)max_n_descs) { -+ desc++; - left -= desc->len; -- if (left > 0) -- (*nb_descs)--; - } - - if (unlikely(left > 0)) - return -1; - -- if (unlikely(*nb_descs == 0)) -+ if (unlikely(head - desc == (int)max_n_descs)) - *cur_desc = NULL; -- else { -- if (unlikely(desc->next >= vq_size)) -- return -1; -- *cur_desc = &head[desc->next]; -- } -+ else -+ *cur_desc = desc + 1; - - return 0; - } - - static __rte_always_inline void * --get_data_ptr(struct vhost_crypto_data_req *vc_req, struct vring_desc *cur_desc, -+get_data_ptr(struct vhost_crypto_data_req *vc_req, -+ struct vhost_crypto_desc *cur_desc, - uint8_t perm) - { - void *data; -@@ -570,12 +566,13 @@ get_data_ptr(struct vhost_crypto_data_req *vc_req, struct vring_desc *cur_desc, - return data; - } - --static int -+static __rte_always_inline int - copy_data(void *dst_data, struct vhost_crypto_data_req *vc_req, -- struct vring_desc **cur_desc, uint32_t size, -- uint32_t *nb_descs, uint32_t vq_size) -+ struct vhost_crypto_desc *head, -+ struct vhost_crypto_desc **cur_desc, -+ uint32_t size, uint32_t max_n_descs) - { -- struct vring_desc *desc = *cur_desc; -+ struct vhost_crypto_desc *desc = *cur_desc; - uint64_t remain, addr, dlen, len; - uint32_t to_copy; - uint8_t *data = dst_data; -@@ -614,15 +611,8 @@ copy_data(void *dst_data, struct vhost_crypto_data_req *vc_req, - - left -= to_copy; - -- while ((desc->flags & VRING_DESC_F_NEXT) && left > 0) { -- if (unlikely(*nb_descs == 0 || desc->next >= vq_size)) { -- VC_LOG_ERR("Invalid descriptors"); -- return -1; -- } -- (*nb_descs)--; -- -- desc = &vc_req->head[desc->next]; -- rte_prefetch0(&vc_req->head[desc->next]); -+ while (desc >= head && desc - head < (int)max_n_descs && left) { -+ desc++; - to_copy = RTE_MIN(desc->len, (uint32_t)left); - dlen = to_copy; - src = IOVA_TO_VVA(uint8_t *, vc_req, desc->addr, &dlen, -@@ -663,13 +653,10 @@ copy_data(void *dst_data, struct vhost_crypto_data_req *vc_req, - return -1; - } - -- if (unlikely(*nb_descs == 0)) -+ if (unlikely(desc - head == (int)max_n_descs)) - *cur_desc = NULL; -- else { -- if (unlikely(desc->next >= vq_size)) -- return -1; -- *cur_desc = &vc_req->head[desc->next]; -- } -+ else -+ *cur_desc = desc + 1; - - return 0; - } -@@ -681,6 +668,7 @@ write_back_data(struct vhost_crypto_data_req *vc_req) - - while (wb_data) { - rte_memcpy(wb_data->dst, wb_data->src, wb_data->len); -+ memset(wb_data->src, 0, wb_data->len); - wb_last = wb_data; - wb_data = wb_data->next; - rte_mempool_put(vc_req->wb_pool, wb_last); -@@ -722,17 +710,18 @@ free_wb_data(struct vhost_crypto_writeback_data *wb_data, - * @return - * The pointer to the start of the write back data linked list. - */ --static struct vhost_crypto_writeback_data * -+static __rte_always_inline struct vhost_crypto_writeback_data * - prepare_write_back_data(struct vhost_crypto_data_req *vc_req, -- struct vring_desc **cur_desc, -+ struct vhost_crypto_desc *head_desc, -+ struct vhost_crypto_desc **cur_desc, - struct vhost_crypto_writeback_data **end_wb_data, - uint8_t *src, - uint32_t offset, - uint64_t write_back_len, -- uint32_t *nb_descs, uint32_t vq_size) -+ uint32_t max_n_descs) - { - struct vhost_crypto_writeback_data *wb_data, *head; -- struct vring_desc *desc = *cur_desc; -+ struct vhost_crypto_desc *desc = *cur_desc; - uint64_t dlen; - uint8_t *dst; - int ret; -@@ -775,14 +764,10 @@ prepare_write_back_data(struct vhost_crypto_data_req *vc_req, - } else - offset -= desc->len; - -- while (write_back_len) { -- if (unlikely(*nb_descs == 0 || desc->next >= vq_size)) { -- VC_LOG_ERR("Invalid descriptors"); -- goto error_exit; -- } -- (*nb_descs)--; -- -- desc = &vc_req->head[desc->next]; -+ while (write_back_len && -+ desc >= head_desc && -+ desc - head_desc < (int)max_n_descs) { -+ desc++; - if (unlikely(!(desc->flags & VRING_DESC_F_WRITE))) { - VC_LOG_ERR("incorrect descriptor"); - goto error_exit; -@@ -821,13 +806,10 @@ prepare_write_back_data(struct vhost_crypto_data_req *vc_req, - wb_data->next = NULL; - } - -- if (unlikely(*nb_descs == 0)) -+ if (unlikely(desc - head_desc == (int)max_n_descs)) - *cur_desc = NULL; -- else { -- if (unlikely(desc->next >= vq_size)) -- goto error_exit; -- *cur_desc = &vc_req->head[desc->next]; -- } -+ else -+ *cur_desc = desc + 1; - - *end_wb_data = wb_data; - -@@ -851,14 +833,14 @@ vhost_crypto_check_cipher_request(struct virtio_crypto_cipher_data_req *req) - return VIRTIO_CRYPTO_BADMSG; - } - --static uint8_t -+static __rte_always_inline uint8_t - prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - struct vhost_crypto_data_req *vc_req, - struct virtio_crypto_cipher_data_req *cipher, -- struct vring_desc *cur_desc, -- uint32_t *nb_descs, uint32_t vq_size) -+ struct vhost_crypto_desc *head, -+ uint32_t max_n_descs) - { -- struct vring_desc *desc = cur_desc; -+ struct vhost_crypto_desc *desc = head; - struct vhost_crypto_writeback_data *ewb = NULL; - struct rte_mbuf *m_src = op->sym->m_src, *m_dst = op->sym->m_dst; - uint8_t *iv_data = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET); -@@ -869,8 +851,8 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - - /* prepare */ - /* iv */ -- if (unlikely(copy_data(iv_data, vc_req, &desc, cipher->para.iv_len, -- nb_descs, vq_size) < 0)) { -+ if (unlikely(copy_data(iv_data, vc_req, head, &desc, -+ cipher->para.iv_len, max_n_descs))) { - ret = VIRTIO_CRYPTO_BADMSG; - goto error_exit; - } -@@ -888,9 +870,8 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - goto error_exit; - } - -- if (unlikely(move_desc(vc_req->head, &desc, -- cipher->para.src_data_len, nb_descs, -- vq_size) < 0)) { -+ if (unlikely(move_desc(head, &desc, cipher->para.src_data_len, -+ max_n_descs) < 0)) { - VC_LOG_ERR("Incorrect descriptor"); - ret = VIRTIO_CRYPTO_ERR; - goto error_exit; -@@ -901,8 +882,8 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - vc_req->wb_pool = vcrypto->wb_pool; - m_src->data_len = cipher->para.src_data_len; - if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), -- vc_req, &desc, cipher->para.src_data_len, -- nb_descs, vq_size) < 0)) { -+ vc_req, head, &desc, cipher->para.src_data_len, -+ max_n_descs) < 0)) { - ret = VIRTIO_CRYPTO_BADMSG; - goto error_exit; - } -@@ -913,7 +894,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - } - - /* dst */ -- desc = find_write_desc(vc_req->head, desc, nb_descs, vq_size); -+ desc = find_write_desc(head, desc, max_n_descs); - if (unlikely(!desc)) { - VC_LOG_ERR("Cannot find write location"); - ret = VIRTIO_CRYPTO_BADMSG; -@@ -931,9 +912,8 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - goto error_exit; - } - -- if (unlikely(move_desc(vc_req->head, &desc, -- cipher->para.dst_data_len, -- nb_descs, vq_size) < 0)) { -+ if (unlikely(move_desc(head, &desc, cipher->para.dst_data_len, -+ max_n_descs) < 0)) { - VC_LOG_ERR("Incorrect descriptor"); - ret = VIRTIO_CRYPTO_ERR; - goto error_exit; -@@ -942,9 +922,9 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - m_dst->data_len = cipher->para.dst_data_len; - break; - case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE: -- vc_req->wb = prepare_write_back_data(vc_req, &desc, &ewb, -+ vc_req->wb = prepare_write_back_data(vc_req, head, &desc, &ewb, - rte_pktmbuf_mtod(m_src, uint8_t *), 0, -- cipher->para.dst_data_len, nb_descs, vq_size); -+ cipher->para.dst_data_len, max_n_descs); - if (unlikely(vc_req->wb == NULL)) { - ret = VIRTIO_CRYPTO_ERR; - goto error_exit; -@@ -986,33 +966,33 @@ static __rte_always_inline uint8_t - vhost_crypto_check_chain_request(struct virtio_crypto_alg_chain_data_req *req) - { - if (likely((req->para.iv_len <= VHOST_CRYPTO_MAX_IV_LEN) && -- (req->para.src_data_len <= RTE_MBUF_DEFAULT_DATAROOM) && -+ (req->para.src_data_len <= VHOST_CRYPTO_MAX_DATA_SIZE) && - (req->para.dst_data_len >= req->para.src_data_len) && -- (req->para.dst_data_len <= RTE_MBUF_DEFAULT_DATAROOM) && -+ (req->para.dst_data_len <= VHOST_CRYPTO_MAX_DATA_SIZE) && - (req->para.cipher_start_src_offset < -- RTE_MBUF_DEFAULT_DATAROOM) && -- (req->para.len_to_cipher < RTE_MBUF_DEFAULT_DATAROOM) && -+ VHOST_CRYPTO_MAX_DATA_SIZE) && -+ (req->para.len_to_cipher <= VHOST_CRYPTO_MAX_DATA_SIZE) && - (req->para.hash_start_src_offset < -- RTE_MBUF_DEFAULT_DATAROOM) && -- (req->para.len_to_hash < RTE_MBUF_DEFAULT_DATAROOM) && -+ VHOST_CRYPTO_MAX_DATA_SIZE) && -+ (req->para.len_to_hash <= VHOST_CRYPTO_MAX_DATA_SIZE) && - (req->para.cipher_start_src_offset + req->para.len_to_cipher <= - req->para.src_data_len) && - (req->para.hash_start_src_offset + req->para.len_to_hash <= - req->para.src_data_len) && - (req->para.dst_data_len + req->para.hash_result_len <= -- RTE_MBUF_DEFAULT_DATAROOM))) -+ VHOST_CRYPTO_MAX_DATA_SIZE))) - return VIRTIO_CRYPTO_OK; - return VIRTIO_CRYPTO_BADMSG; - } - --static uint8_t -+static __rte_always_inline uint8_t - prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - struct vhost_crypto_data_req *vc_req, - struct virtio_crypto_alg_chain_data_req *chain, -- struct vring_desc *cur_desc, -- uint32_t *nb_descs, uint32_t vq_size) -+ struct vhost_crypto_desc *head, -+ uint32_t max_n_descs) - { -- struct vring_desc *desc = cur_desc, *digest_desc; -+ struct vhost_crypto_desc *desc = head, *digest_desc; - struct vhost_crypto_writeback_data *ewb = NULL, *ewb2 = NULL; - struct rte_mbuf *m_src = op->sym->m_src, *m_dst = op->sym->m_dst; - uint8_t *iv_data = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET); -@@ -1025,8 +1005,8 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - - /* prepare */ - /* iv */ -- if (unlikely(copy_data(iv_data, vc_req, &desc, -- chain->para.iv_len, nb_descs, vq_size) < 0)) { -+ if (unlikely(copy_data(iv_data, vc_req, head, &desc, -+ chain->para.iv_len, max_n_descs) < 0)) { - ret = VIRTIO_CRYPTO_BADMSG; - goto error_exit; - } -@@ -1045,9 +1025,8 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - goto error_exit; - } - -- if (unlikely(move_desc(vc_req->head, &desc, -- chain->para.src_data_len, -- nb_descs, vq_size) < 0)) { -+ if (unlikely(move_desc(head, &desc, chain->para.src_data_len, -+ max_n_descs) < 0)) { - VC_LOG_ERR("Incorrect descriptor"); - ret = VIRTIO_CRYPTO_ERR; - goto error_exit; -@@ -1057,8 +1036,8 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - vc_req->wb_pool = vcrypto->wb_pool; - m_src->data_len = chain->para.src_data_len; - if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), -- vc_req, &desc, chain->para.src_data_len, -- nb_descs, vq_size) < 0)) { -+ vc_req, head, &desc, chain->para.src_data_len, -+ max_n_descs) < 0)) { - ret = VIRTIO_CRYPTO_BADMSG; - goto error_exit; - } -@@ -1070,7 +1049,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - } - - /* dst */ -- desc = find_write_desc(vc_req->head, desc, nb_descs, vq_size); -+ desc = find_write_desc(head, desc, max_n_descs); - if (unlikely(!desc)) { - VC_LOG_ERR("Cannot find write location"); - ret = VIRTIO_CRYPTO_BADMSG; -@@ -1089,8 +1068,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - } - - if (unlikely(move_desc(vc_req->head, &desc, -- chain->para.dst_data_len, -- nb_descs, vq_size) < 0)) { -+ chain->para.dst_data_len, max_n_descs) < 0)) { - VC_LOG_ERR("Incorrect descriptor"); - ret = VIRTIO_CRYPTO_ERR; - goto error_exit; -@@ -1106,9 +1084,9 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - goto error_exit; - } - -- if (unlikely(move_desc(vc_req->head, &desc, -+ if (unlikely(move_desc(head, &desc, - chain->para.hash_result_len, -- nb_descs, vq_size) < 0)) { -+ max_n_descs) < 0)) { - VC_LOG_ERR("Incorrect descriptor"); - ret = VIRTIO_CRYPTO_ERR; - goto error_exit; -@@ -1116,34 +1094,34 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - - break; - case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE: -- vc_req->wb = prepare_write_back_data(vc_req, &desc, &ewb, -+ vc_req->wb = prepare_write_back_data(vc_req, head, &desc, &ewb, - rte_pktmbuf_mtod(m_src, uint8_t *), - chain->para.cipher_start_src_offset, - chain->para.dst_data_len - -- chain->para.cipher_start_src_offset, -- nb_descs, vq_size); -+ chain->para.cipher_start_src_offset, -+ max_n_descs); - if (unlikely(vc_req->wb == NULL)) { - ret = VIRTIO_CRYPTO_ERR; - goto error_exit; - } - -+ digest_desc = desc; - digest_offset = m_src->data_len; - digest_addr = rte_pktmbuf_mtod_offset(m_src, void *, - digest_offset); -- digest_desc = desc; - - /** create a wb_data for digest */ -- ewb->next = prepare_write_back_data(vc_req, &desc, &ewb2, -- digest_addr, 0, chain->para.hash_result_len, -- nb_descs, vq_size); -+ ewb->next = prepare_write_back_data(vc_req, head, &desc, -+ &ewb2, digest_addr, 0, -+ chain->para.hash_result_len, max_n_descs); - if (unlikely(ewb->next == NULL)) { - ret = VIRTIO_CRYPTO_ERR; - goto error_exit; - } - -- if (unlikely(copy_data(digest_addr, vc_req, &digest_desc, -+ if (unlikely(copy_data(digest_addr, vc_req, head, &digest_desc, - chain->para.hash_result_len, -- nb_descs, vq_size) < 0)) { -+ max_n_descs) < 0)) { - ret = VIRTIO_CRYPTO_BADMSG; - goto error_exit; - } -@@ -1193,74 +1171,103 @@ error_exit: - static __rte_always_inline int - vhost_crypto_process_one_req(struct vhost_crypto *vcrypto, - struct vhost_virtqueue *vq, struct rte_crypto_op *op, -- struct vring_desc *head, uint16_t desc_idx) -+ struct vring_desc *head, struct vhost_crypto_desc *descs, -+ uint16_t desc_idx) - { - struct vhost_crypto_data_req *vc_req = rte_mbuf_to_priv(op->sym->m_src); - struct rte_cryptodev_sym_session *session; -- struct virtio_crypto_op_data_req *req, tmp_req; -+ struct virtio_crypto_op_data_req req; - struct virtio_crypto_inhdr *inhdr; -- struct vring_desc *desc = NULL; -+ struct vhost_crypto_desc *desc = descs; -+ struct vring_desc *src_desc; - uint64_t session_id; - uint64_t dlen; -- uint32_t nb_descs = vq->size; -- int err = 0; -+ uint32_t nb_descs = 0, max_n_descs, i; -+ int err; - - vc_req->desc_idx = desc_idx; - vc_req->dev = vcrypto->dev; - vc_req->vq = vq; - -- if (likely(head->flags & VRING_DESC_F_INDIRECT)) { -- dlen = head->len; -- nb_descs = dlen / sizeof(struct vring_desc); -- /* drop invalid descriptors */ -- if (unlikely(nb_descs > vq->size)) -- return -1; -- desc = IOVA_TO_VVA(struct vring_desc *, vc_req, head->addr, -- &dlen, VHOST_ACCESS_RO); -- if (unlikely(!desc || dlen != head->len)) -- return -1; -- desc_idx = 0; -- head = desc; -- } else { -- desc = head; -+ if (unlikely((head->flags & VRING_DESC_F_INDIRECT) == 0)) { -+ VC_LOG_ERR("Invalid descriptor"); -+ return -1; - } - -- vc_req->head = head; -- vc_req->zero_copy = vcrypto->option; -+ dlen = head->len; -+ src_desc = IOVA_TO_VVA(struct vring_desc *, vc_req, head->addr, -+ &dlen, VHOST_ACCESS_RO); -+ if (unlikely(!src_desc || dlen != head->len)) { -+ VC_LOG_ERR("Invalid descriptor"); -+ return -1; -+ } -+ head = src_desc; - -- req = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO); -- if (unlikely(req == NULL)) { -- switch (vcrypto->option) { -- case RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE: -- err = VIRTIO_CRYPTO_BADMSG; -- VC_LOG_ERR("Invalid descriptor"); -- goto error_exit; -- case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE: -- req = &tmp_req; -- if (unlikely(copy_data(req, vc_req, &desc, sizeof(*req), -- &nb_descs, vq->size) < 0)) { -- err = VIRTIO_CRYPTO_BADMSG; -- VC_LOG_ERR("Invalid descriptor"); -- goto error_exit; -+ nb_descs = max_n_descs = dlen / sizeof(struct vring_desc); -+ if (unlikely(nb_descs > VHOST_CRYPTO_MAX_N_DESC || nb_descs == 0)) { -+ err = VIRTIO_CRYPTO_ERR; -+ VC_LOG_ERR("Cannot process num of descriptors %u", nb_descs); -+ if (nb_descs > 0) { -+ struct vring_desc *inhdr_desc = head; -+ while (inhdr_desc->flags & VRING_DESC_F_NEXT) { -+ if (inhdr_desc->next >= max_n_descs) -+ return -1; -+ inhdr_desc = &head[inhdr_desc->next]; - } -- break; -- default: -- err = VIRTIO_CRYPTO_ERR; -- VC_LOG_ERR("Invalid option"); -- goto error_exit; -+ if (inhdr_desc->len != sizeof(*inhdr)) -+ return -1; -+ inhdr = IOVA_TO_VVA(struct virtio_crypto_inhdr *, -+ vc_req, inhdr_desc->addr, &dlen, -+ VHOST_ACCESS_WO); -+ if (unlikely(!inhdr || dlen != inhdr_desc->len)) -+ return -1; -+ inhdr->status = VIRTIO_CRYPTO_ERR; -+ return -1; - } -- } else { -- if (unlikely(move_desc(vc_req->head, &desc, -- sizeof(*req), &nb_descs, vq->size) < 0)) { -- VC_LOG_ERR("Incorrect descriptor"); -+ } -+ -+ /* copy descriptors to local variable */ -+ for (i = 0; i < max_n_descs; i++) { -+ desc->addr = src_desc->addr; -+ desc->len = src_desc->len; -+ desc->flags = src_desc->flags; -+ desc++; -+ if (unlikely((src_desc->flags & VRING_DESC_F_NEXT) == 0)) -+ break; -+ if (unlikely(src_desc->next >= max_n_descs)) { -+ err = VIRTIO_CRYPTO_BADMSG; -+ VC_LOG_ERR("Invalid descriptor"); - goto error_exit; - } -+ src_desc = &head[src_desc->next]; -+ } -+ -+ vc_req->head = head; -+ vc_req->zero_copy = vcrypto->option; -+ -+ nb_descs = desc - descs; -+ desc = descs; -+ -+ if (unlikely(desc->len < sizeof(req))) { -+ err = VIRTIO_CRYPTO_BADMSG; -+ VC_LOG_ERR("Invalid descriptor"); -+ goto error_exit; - } - -- switch (req->header.opcode) { -+ if (unlikely(copy_data(&req, vc_req, descs, &desc, sizeof(req), -+ max_n_descs) < 0)) { -+ err = VIRTIO_CRYPTO_BADMSG; -+ VC_LOG_ERR("Invalid descriptor"); -+ goto error_exit; -+ } -+ -+ /* desc is advanced by 1 now */ -+ max_n_descs -= 1; -+ -+ switch (req.header.opcode) { - case VIRTIO_CRYPTO_CIPHER_ENCRYPT: - case VIRTIO_CRYPTO_CIPHER_DECRYPT: -- session_id = req->header.session_id; -+ session_id = req.header.session_id; - - /* one branch to avoid unnecessary table lookup */ - if (vcrypto->cache_session_id != session_id) { -@@ -1286,19 +1293,19 @@ vhost_crypto_process_one_req(struct vhost_crypto *vcrypto, - goto error_exit; - } - -- switch (req->u.sym_req.op_type) { -+ switch (req.u.sym_req.op_type) { - case VIRTIO_CRYPTO_SYM_OP_NONE: - err = VIRTIO_CRYPTO_NOTSUPP; - break; - case VIRTIO_CRYPTO_SYM_OP_CIPHER: - err = prepare_sym_cipher_op(vcrypto, op, vc_req, -- &req->u.sym_req.u.cipher, desc, -- &nb_descs, vq->size); -+ &req.u.sym_req.u.cipher, desc, -+ max_n_descs); - break; - case VIRTIO_CRYPTO_SYM_OP_ALGORITHM_CHAINING: - err = prepare_sym_chain_op(vcrypto, op, vc_req, -- &req->u.sym_req.u.chain, desc, -- &nb_descs, vq->size); -+ &req.u.sym_req.u.chain, desc, -+ max_n_descs); - break; - } - if (unlikely(err != 0)) { -@@ -1307,8 +1314,9 @@ vhost_crypto_process_one_req(struct vhost_crypto *vcrypto, - } - break; - default: -+ err = VIRTIO_CRYPTO_ERR; - VC_LOG_ERR("Unsupported symmetric crypto request type %u", -- req->header.opcode); -+ req.header.opcode); - goto error_exit; - } - -@@ -1316,7 +1324,7 @@ vhost_crypto_process_one_req(struct vhost_crypto *vcrypto, - - error_exit: - -- inhdr = reach_inhdr(vc_req, desc, &nb_descs, vq->size); -+ inhdr = reach_inhdr(vc_req, descs, max_n_descs); - if (likely(inhdr != NULL)) - inhdr->status = (uint8_t)err; - -@@ -1330,17 +1338,16 @@ vhost_crypto_finalize_one_request(struct rte_crypto_op *op, - struct rte_mbuf *m_src = op->sym->m_src; - struct rte_mbuf *m_dst = op->sym->m_dst; - struct vhost_crypto_data_req *vc_req = rte_mbuf_to_priv(m_src); -- uint16_t desc_idx; -+ struct vhost_virtqueue *vq = vc_req->vq; -+ uint16_t used_idx = vc_req->desc_idx, desc_idx; - - if (unlikely(!vc_req)) { - VC_LOG_ERR("Failed to retrieve vc_req"); - return NULL; - } - -- if (old_vq && (vc_req->vq != old_vq)) -- return vc_req->vq; -- -- desc_idx = vc_req->desc_idx; -+ if (old_vq && (vq != old_vq)) -+ return vq; - - if (unlikely(op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)) - vc_req->inhdr->status = VIRTIO_CRYPTO_ERR; -@@ -1349,8 +1356,9 @@ vhost_crypto_finalize_one_request(struct rte_crypto_op *op, - write_back_data(vc_req); - } - -- vc_req->vq->used->ring[desc_idx].id = desc_idx; -- vc_req->vq->used->ring[desc_idx].len = vc_req->len; -+ desc_idx = vq->avail->ring[used_idx]; -+ vq->used->ring[desc_idx].id = vq->avail->ring[desc_idx]; -+ vq->used->ring[desc_idx].len = vc_req->len; - - rte_mempool_put(m_src->pool, (void *)m_src); - -@@ -1448,7 +1456,7 @@ rte_vhost_crypto_create(int vid, uint8_t cryptodev_id, - vcrypto->mbuf_pool = rte_pktmbuf_pool_create(name, - VHOST_CRYPTO_MBUF_POOL_SIZE, 512, - sizeof(struct vhost_crypto_data_req), -- RTE_MBUF_DEFAULT_DATAROOM * 2 + RTE_PKTMBUF_HEADROOM, -+ VHOST_CRYPTO_MAX_DATA_SIZE + RTE_PKTMBUF_HEADROOM, - rte_socket_id()); - if (!vcrypto->mbuf_pool) { - VC_LOG_ERR("Failed to creath mbuf pool"); -@@ -1574,6 +1582,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, - struct rte_crypto_op **ops, uint16_t nb_ops) - { - struct rte_mbuf *mbufs[VHOST_CRYPTO_MAX_BURST_SIZE * 2]; -+ struct vhost_crypto_desc descs[VHOST_CRYPTO_MAX_N_DESC]; - struct virtio_net *dev = get_device(vid); - struct vhost_crypto *vcrypto; - struct vhost_virtqueue *vq; -@@ -1632,7 +1641,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, - op->sym->m_dst->data_off = 0; - - if (unlikely(vhost_crypto_process_one_req(vcrypto, vq, -- op, head, desc_idx) < 0)) -+ op, head, descs, used_idx) < 0)) - break; - } - -@@ -1661,7 +1670,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, - op->sym->m_src->data_off = 0; - - if (unlikely(vhost_crypto_process_one_req(vcrypto, vq, -- op, head, desc_idx) < 0)) -+ op, head, descs, desc_idx) < 0)) - break; - } - --- -cgit v1.0 diff --git a/CVE-2020-14376-CVE-2020-14377.patch b/CVE-2020-14376-CVE-2020-14377.patch deleted file mode 100644 index c28e251..0000000 --- a/CVE-2020-14376-CVE-2020-14377.patch +++ /dev/null @@ -1,163 +0,0 @@ -From e4a7c14f02480a41992414afb5e011f8ff8f02f3 Mon Sep 17 00:00:00 2001 -From: Fan Zhang -Date: Tue, 14 Apr 2020 17:26:48 +0100 -Subject: vhost/crypto: fix missed request check for copy mode - -This patch fixes the missed request check to vhost crypto -copy mode. - -CVE-2020-14376 -CVE-2020-14377 -Fixes: 3bb595ecd682 ("vhost/crypto: add request handler") -Cc: stable@dpdk.org - -Signed-off-by: Fan Zhang -Acked-by: Chenbo Xia - -reference:https://git.dpdk.org/dpdk-stable/commit/?h=19.11&id=e4a7c14f0248 -Signed-off-by: gaoxingwang ---- - lib/librte_vhost/vhost_crypto.c | 68 ++++++++++++++++++++++++++++------------- - 1 file changed, 47 insertions(+), 21 deletions(-) - -diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c -index 86747dd..494f490 100644 ---- a/lib/librte_vhost/vhost_crypto.c -+++ b/lib/librte_vhost/vhost_crypto.c -@@ -756,7 +756,7 @@ prepare_write_back_data(struct vhost_crypto_data_req *vc_req, - } - - wb_data->dst = dst; -- wb_data->len = desc->len - offset; -+ wb_data->len = RTE_MIN(desc->len - offset, write_back_len); - write_back_len -= wb_data->len; - src += offset + wb_data->len; - offset = 0; -@@ -840,6 +840,17 @@ error_exit: - return NULL; - } - -+static __rte_always_inline uint8_t -+vhost_crypto_check_cipher_request(struct virtio_crypto_cipher_data_req *req) -+{ -+ if (likely((req->para.iv_len <= VHOST_CRYPTO_MAX_IV_LEN) && -+ (req->para.src_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE) && -+ (req->para.dst_data_len >= req->para.src_data_len) && -+ (req->para.dst_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE))) -+ return VIRTIO_CRYPTO_OK; -+ return VIRTIO_CRYPTO_BADMSG; -+} -+ - static uint8_t - prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - struct vhost_crypto_data_req *vc_req, -@@ -851,7 +862,10 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - struct vhost_crypto_writeback_data *ewb = NULL; - struct rte_mbuf *m_src = op->sym->m_src, *m_dst = op->sym->m_dst; - uint8_t *iv_data = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET); -- uint8_t ret = 0; -+ uint8_t ret = vhost_crypto_check_cipher_request(cipher); -+ -+ if (unlikely(ret != VIRTIO_CRYPTO_OK)) -+ goto error_exit; - - /* prepare */ - /* iv */ -@@ -861,10 +875,9 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - goto error_exit; - } - -- m_src->data_len = cipher->para.src_data_len; -- - switch (vcrypto->option) { - case RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE: -+ m_src->data_len = cipher->para.src_data_len; - m_src->buf_iova = gpa_to_hpa(vcrypto->dev, desc->addr, - cipher->para.src_data_len); - m_src->buf_addr = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO); -@@ -886,13 +899,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - break; - case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE: - vc_req->wb_pool = vcrypto->wb_pool; -- -- if (unlikely(cipher->para.src_data_len > -- RTE_MBUF_DEFAULT_BUF_SIZE)) { -- VC_LOG_ERR("Not enough space to do data copy"); -- ret = VIRTIO_CRYPTO_ERR; -- goto error_exit; -- } -+ m_src->data_len = cipher->para.src_data_len; - if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), - vc_req, &desc, cipher->para.src_data_len, - nb_descs, vq_size) < 0)) { -@@ -975,6 +982,29 @@ error_exit: - return ret; - } - -+static __rte_always_inline uint8_t -+vhost_crypto_check_chain_request(struct virtio_crypto_alg_chain_data_req *req) -+{ -+ if (likely((req->para.iv_len <= VHOST_CRYPTO_MAX_IV_LEN) && -+ (req->para.src_data_len <= RTE_MBUF_DEFAULT_DATAROOM) && -+ (req->para.dst_data_len >= req->para.src_data_len) && -+ (req->para.dst_data_len <= RTE_MBUF_DEFAULT_DATAROOM) && -+ (req->para.cipher_start_src_offset < -+ RTE_MBUF_DEFAULT_DATAROOM) && -+ (req->para.len_to_cipher < RTE_MBUF_DEFAULT_DATAROOM) && -+ (req->para.hash_start_src_offset < -+ RTE_MBUF_DEFAULT_DATAROOM) && -+ (req->para.len_to_hash < RTE_MBUF_DEFAULT_DATAROOM) && -+ (req->para.cipher_start_src_offset + req->para.len_to_cipher <= -+ req->para.src_data_len) && -+ (req->para.hash_start_src_offset + req->para.len_to_hash <= -+ req->para.src_data_len) && -+ (req->para.dst_data_len + req->para.hash_result_len <= -+ RTE_MBUF_DEFAULT_DATAROOM))) -+ return VIRTIO_CRYPTO_OK; -+ return VIRTIO_CRYPTO_BADMSG; -+} -+ - static uint8_t - prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - struct vhost_crypto_data_req *vc_req, -@@ -988,7 +1018,10 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - uint8_t *iv_data = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET); - uint32_t digest_offset; - void *digest_addr; -- uint8_t ret = 0; -+ uint8_t ret = vhost_crypto_check_chain_request(chain); -+ -+ if (unlikely(ret != VIRTIO_CRYPTO_OK)) -+ goto error_exit; - - /* prepare */ - /* iv */ -@@ -998,10 +1031,9 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - goto error_exit; - } - -- m_src->data_len = chain->para.src_data_len; -- - switch (vcrypto->option) { - case RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE: -+ m_src->data_len = chain->para.src_data_len; - m_dst->data_len = chain->para.dst_data_len; - - m_src->buf_iova = gpa_to_hpa(vcrypto->dev, desc->addr, -@@ -1023,13 +1055,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, - break; - case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE: - vc_req->wb_pool = vcrypto->wb_pool; -- -- if (unlikely(chain->para.src_data_len > -- RTE_MBUF_DEFAULT_BUF_SIZE)) { -- VC_LOG_ERR("Not enough space to do data copy"); -- ret = VIRTIO_CRYPTO_ERR; -- goto error_exit; -- } -+ m_src->data_len = chain->para.src_data_len; - if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), - vc_req, &desc, chain->para.src_data_len, - nb_descs, vq_size) < 0)) { --- -cgit v1.0 diff --git a/CVE-2020-14378.patch b/CVE-2020-14378.patch deleted file mode 100644 index 902dc04..0000000 --- a/CVE-2020-14378.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 81e9694830209207cbba599b62858c97c3ed5cfe Mon Sep 17 00:00:00 2001 -From: Fan Zhang -Date: Tue, 14 Apr 2020 16:52:47 +0100 -Subject: vhost/crypto: fix incorrect descriptor deduction - -This patch fixes the incorrect descriptor deduction for vhost crypto. - -CVE-2020-14378 -Fixes: 16d2e718b8ce ("vhost/crypto: fix possible out of bound access") -Cc: stable@dpdk.org - -Signed-off-by: Fan Zhang -Acked-by: Chenbo Xia - -reference:https://git.dpdk.org/dpdk-stable/commit/?h=19.11&id=81e969483020 -Signed-off-by: gaoxingwang ---- - lib/librte_vhost/vhost_crypto.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c -index 0f9df40..86747dd 100644 ---- a/lib/librte_vhost/vhost_crypto.c -+++ b/lib/librte_vhost/vhost_crypto.c -@@ -530,13 +530,14 @@ move_desc(struct vring_desc *head, struct vring_desc **cur_desc, - int left = size - desc->len; - - while ((desc->flags & VRING_DESC_F_NEXT) && left > 0) { -- (*nb_descs)--; - if (unlikely(*nb_descs == 0 || desc->next >= vq_size)) - return -1; - - desc = &head[desc->next]; - rte_prefetch0(&head[desc->next]); - left -= desc->len; -+ if (left > 0) -+ (*nb_descs)--; - } - - if (unlikely(left > 0)) --- -cgit v1.0 diff --git a/CVE-2021-3839.patch b/CVE-2021-3839.patch index f390e24..9d8e1b7 100644 --- a/CVE-2021-3839.patch +++ b/CVE-2021-3839.patch @@ -1,4 +1,4 @@ -From aef547884b8a64c0754b4b7906ae9d7c912b8043 Mon Sep 17 00:00:00 2001 +From 4c40d30d2bc8a35b81d1d386e6674acee49acded Mon Sep 17 00:00:00 2001 From: Chenbo Xia Date: Mon, 14 Feb 2022 16:32:37 +0800 Subject: vhost: fix queue number check when setting inflight FD @@ -13,20 +13,19 @@ patch checks the queue number to avoid the issue and also make sure virtqueues are allocated before setting inflight information. Fixes: ad0a4ae491fe ("vhost: checkout resubmit inflight information") -Cc: stable@dpdk.org Reported-by: Wenxiang Qian Signed-off-by: Chenbo Xia Reviewed-by: Maxime Coquelin --- - lib/librte_vhost/vhost_user.c | 3 +++ + lib/vhost/vhost_user.c | 3 +++ 1 file changed, 3 insertions(+) -diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c -index 1ee6050ac0..79be132c43 100644 ---- a/lib/librte_vhost/vhost_user.c -+++ b/lib/librte_vhost/vhost_user.c -@@ -2624,6 +2624,9 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, +diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c +index 850ac49169..d4b0ec7358 100644 +--- a/lib/vhost/vhost_user.c ++++ b/lib/vhost/vhost_user.c +@@ -2876,6 +2876,9 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, case VHOST_USER_SET_VRING_ADDR: vring_idx = msg->payload.addr.index; break; diff --git a/CVE-2022-0669.patch b/CVE-2022-0669.patch index 26d5bad..9b86bc6 100644 --- a/CVE-2022-0669.patch +++ b/CVE-2022-0669.patch @@ -1,4 +1,4 @@ -From b7979d39ef4d6ad0d78bd66e07168401391c34fa Mon Sep 17 00:00:00 2001 +From 6cb68162e4b598b7c0747372fa3fcec9cddd19b8 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Tue, 18 Jan 2022 15:53:30 +0100 Subject: vhost: fix FD leak with inflight messages @@ -9,34 +9,36 @@ Even if unlikely, a buggy vhost-user master might attach fds to inflight messages. Add checks like for other types of vhost-user messages. Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing") -Cc: stable@dpdk.org + +Signed-off-by: David Marchand +Reviewed-by: Maxime Coquelin --- - lib/librte_vhost/vhost_user.c | 6 ++++++ + lib/vhost/vhost_user.c | 6 ++++++ 1 file changed, 6 insertions(+) -diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c -index 79be132c43..af44d1e69c 100644 ---- a/lib/librte_vhost/vhost_user.c -+++ b/lib/librte_vhost/vhost_user.c -@@ -1441,6 +1441,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, - int fd, i, j; +diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c +index d4b0ec7358..9a266b5d42 100644 +--- a/lib/vhost/vhost_user.c ++++ b/lib/vhost/vhost_user.c +@@ -1600,6 +1600,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, + int numa_node = SOCKET_ID_ANY; void *addr; + if (validate_msg_fds(msg, 0) != 0) + return RTE_VHOST_MSG_RESULT_ERR; + if (msg->size != sizeof(msg->payload.inflight)) { - RTE_LOG(ERR, VHOST_CONFIG, + VHOST_LOG_CONFIG(ERR, "invalid get_inflight_fd message size is %d\n", -@@ -1534,6 +1537,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg, - void *addr; +@@ -1701,6 +1704,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg, int fd, i; + int numa_node = SOCKET_ID_ANY; + if (validate_msg_fds(msg, 1) != 0) + return RTE_VHOST_MSG_RESULT_ERR; + fd = msg->fds[0]; if (msg->size != sizeof(msg->payload.inflight) || fd < 0) { - RTE_LOG(ERR, VHOST_CONFIG, + VHOST_LOG_CONFIG(ERR, -- cgit v1.2.1 diff --git a/backport-0001-CVE-2022-2132.patch b/backport-0001-CVE-2022-2132.patch index f7694bb..571f57b 100644 --- a/backport-0001-CVE-2022-2132.patch +++ b/backport-0001-CVE-2022-2132.patch @@ -1,75 +1,104 @@ -From 5b3c25e6ee2c68887aae166aed57d0b4af91fa60 Mon Sep 17 00:00:00 2001 +From e12d415556994d0901c317f6338ed2961185465f Mon Sep 17 00:00:00 2001 From: Maxime Coquelin -Date: Thu, 16 Jun 2022 11:35:56 +0200 -Subject: [PATCH] vhost: discard too small descriptor chains +Date: Thu, 16 Jun 2022 14:25:07 +0200 +Subject: [PATCH] vhost: fix header spanned across more than two descriptors -This patch discards descriptor chains which are smaller -than the Virtio-net header size, and ones that are equal. +[ upstream commit dc1516e260a0df272b218392faf6db3cbf45e717 ] -Indeed, such descriptor chains sizes mean there is no -packet data. - -This patch also has the advantage of requesting the exact -packets sizes for the mbufs. +This patch aims at supporting the unlikely case where a +Virtio-net header is spanned across more than two +descriptors. CVE-2022-2132 -Fixes: 62250c1d0978 ("vhost: extract split ring handling from Rx and Tx functions") -Fixes: c3ff0ac70acb ("vhost: improve performance by supporting large buffer") -Cc: stable@dpdk.org +Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path") Signed-off-by: Maxime Coquelin +Acked-by: Chenbo Xia +Reviewed-by: David Marchand Conflict: NA -Reference: https://git.dpdk.org/dpdk-stable/commit/?id=5b3c25e6ee +Reference: https://git.dpdk.org/dpdk-stable/commit/?id=e12d415556 --- - lib/librte_vhost/virtio_net.c | 21 +++++++++++++++++---- - 1 file changed, 17 insertions(+), 4 deletions(-) + lib/vhost/virtio_net.c | 41 +++++++++++++---------------------------- + 1 file changed, 13 insertions(+), 28 deletions(-) -diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c -index ae4e54a442..1fcbc1aca9 100644 ---- a/lib/librte_vhost/virtio_net.c -+++ b/lib/librte_vhost/virtio_net.c -@@ -1412,10 +1412,10 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, - buf_iova = buf_vec[vec_idx].buf_iova; - buf_len = buf_vec[vec_idx].buf_len; +diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c +index 991a7a2bd4..bf4d75b4bd 100644 +--- a/lib/vhost/virtio_net.c ++++ b/lib/vhost/virtio_net.c +@@ -2322,25 +2322,22 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, + uint32_t buf_avail, buf_offset; + uint64_t buf_addr, buf_len; + uint32_t mbuf_avail, mbuf_offset; ++ uint32_t hdr_remain = dev->vhost_hlen; + uint32_t cpy_len; + struct rte_mbuf *cur = m, *prev = m; + struct virtio_net_hdr tmp_hdr; + struct virtio_net_hdr *hdr = NULL; +- /* A counter to avoid desc dead loop chain */ +- uint16_t vec_idx = 0; ++ uint16_t vec_idx; + struct batch_copy_elem *batch_copy = vq->batch_copy_elems; + int error = 0; -- if (unlikely(buf_len < dev->vhost_hlen && nr_vec <= 1)) { -- error = -1; -- goto out; -- } -+ /* -+ * The caller has checked the descriptors chain is larger than the -+ * header size. -+ */ +- buf_addr = buf_vec[vec_idx].buf_addr; +- buf_len = buf_vec[vec_idx].buf_len; +- + if (unlikely(buf_len < dev->vhost_hlen && nr_vec <= 1)) { + error = -1; + goto out; + } if (virtio_net_with_host_offload(dev)) { - if (unlikely(buf_len < sizeof(struct virtio_net_hdr))) { -@@ -1742,6 +1742,14 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, - if (likely(dev->dequeue_zero_copy == 0)) - update_shadow_used_ring_split(vq, head_idx, 0); - -+ if (unlikely(buf_len <= dev->vhost_hlen)) { -+ dropped += 1; -+ i++; -+ break; -+ } -+ -+ buf_len -= dev->vhost_hlen; -+ - pkts[i] = virtio_dev_pktmbuf_alloc(dev, mbuf_pool, buf_len); - if (unlikely(pkts[i] == NULL)) { +- if (unlikely(buf_len < sizeof(struct virtio_net_hdr))) { ++ if (unlikely(buf_vec[0].buf_len < sizeof(struct virtio_net_hdr))) { /* -@@ -1955,6 +1963,11 @@ vhost_dequeue_single_packed(struct virtio_net *dev, - VHOST_ACCESS_RO) < 0)) - return -1; + * No luck, the virtio-net header doesn't fit + * in a contiguous virtual area. +@@ -2348,34 +2345,22 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, + copy_vnet_hdr_from_desc(&tmp_hdr, buf_vec); + hdr = &tmp_hdr; + } else { +- hdr = (struct virtio_net_hdr *)((uintptr_t)buf_addr); ++ hdr = (struct virtio_net_hdr *)((uintptr_t)buf_vec[0].buf_addr); + } + } -+ if (unlikely(buf_len <= dev->vhost_hlen)) -+ return -1; +- /* +- * A virtio driver normally uses at least 2 desc buffers +- * for Tx: the first for storing the header, and others +- * for storing the data. +- */ +- if (unlikely(buf_len < dev->vhost_hlen)) { +- buf_offset = dev->vhost_hlen - buf_len; +- vec_idx++; +- buf_addr = buf_vec[vec_idx].buf_addr; +- buf_len = buf_vec[vec_idx].buf_len; +- buf_avail = buf_len - buf_offset; +- } else if (buf_len == dev->vhost_hlen) { +- if (unlikely(++vec_idx >= nr_vec)) +- goto out; +- buf_addr = buf_vec[vec_idx].buf_addr; +- buf_len = buf_vec[vec_idx].buf_len; ++ for (vec_idx = 0; vec_idx < nr_vec; vec_idx++) { ++ if (buf_vec[vec_idx].buf_len > hdr_remain) ++ break; + +- buf_offset = 0; +- buf_avail = buf_len; +- } else { +- buf_offset = dev->vhost_hlen; +- buf_avail = buf_vec[vec_idx].buf_len - dev->vhost_hlen; ++ hdr_remain -= buf_vec[vec_idx].buf_len; + } + ++ buf_addr = buf_vec[vec_idx].buf_addr; ++ buf_len = buf_vec[vec_idx].buf_len; ++ buf_offset = hdr_remain; ++ buf_avail = buf_vec[vec_idx].buf_len - hdr_remain; + -+ buf_len -= dev->vhost_hlen; -+ - *pkts = virtio_dev_pktmbuf_alloc(dev, mbuf_pool, buf_len); - if (unlikely(*pkts == NULL)) { - if (!allocerr_warned) { + PRINT_PACKET(dev, + (uintptr_t)(buf_addr + buf_offset), + (uint32_t)buf_avail, 0); -- 2.23.0 diff --git a/backport-0001-net-hinic-add-flow-director-filter.patch b/backport-0001-net-hinic-add-flow-director-filter.patch deleted file mode 100644 index a285817..0000000 --- a/backport-0001-net-hinic-add-flow-director-filter.patch +++ /dev/null @@ -1,1816 +0,0 @@ -From 1fe89aa37f368722c882a4bdd2f8a427761255a5 Mon Sep 17 00:00:00 2001 -From: Xiaoyun Wang -Date: Tue, 17 Mar 2020 23:01:15 +0800 -Subject: [PATCH] net/hinic: add flow director filter - -The patch supports filter type of inner VXLAN or non vxlan dport, -and use TCAM method to config these rules. - -Signed-off-by: Xiaoyun Wang ---- - drivers/net/hinic/base/hinic_pmd_cmd.h | 6 + - drivers/net/hinic/base/hinic_pmd_niccfg.c | 184 ++++- - drivers/net/hinic/base/hinic_pmd_niccfg.h | 81 ++ - drivers/net/hinic/hinic_pmd_ethdev.c | 6 +- - drivers/net/hinic/hinic_pmd_ethdev.h | 110 ++- - drivers/net/hinic/hinic_pmd_flow.c | 961 +++++++++++++++++++--- - 6 files changed, 1199 insertions(+), 149 deletions(-) - -diff --git a/drivers/net/hinic/base/hinic_pmd_cmd.h b/drivers/net/hinic/base/hinic_pmd_cmd.h -index c025851521..09918a76fa 100644 ---- a/drivers/net/hinic/base/hinic_pmd_cmd.h -+++ b/drivers/net/hinic/base/hinic_pmd_cmd.h -@@ -115,6 +115,12 @@ enum hinic_port_cmd { - - HINIC_PORT_CMD_GET_PORT_INFO = 0xaa, - -+ HINIC_PORT_CMD_UP_TC_ADD_FLOW = 0xaf, -+ HINIC_PORT_CMD_UP_TC_DEL_FLOW = 0xb0, -+ HINIC_PORT_CMD_UP_TC_GET_FLOW = 0xb1, -+ HINIC_PORT_CMD_UP_TC_FLUSH_TCAM = 0xb2, -+ HINIC_PORT_CMD_UP_TC_CTRL_TCAM_BLOCK = 0xb3, -+ - HINIC_PORT_CMD_SET_IPSU_MAC = 0xcb, - HINIC_PORT_CMD_GET_IPSU_MAC = 0xcc, - -diff --git a/drivers/net/hinic/base/hinic_pmd_niccfg.c b/drivers/net/hinic/base/hinic_pmd_niccfg.c -index 2dc431e288..0bbcd36322 100644 ---- a/drivers/net/hinic/base/hinic_pmd_niccfg.c -+++ b/drivers/net/hinic/base/hinic_pmd_niccfg.c -@@ -19,22 +19,6 @@ - buf_out, out_size, 0) - - --#define TCAM_SET 0x1 --#define TCAM_CLEAR 0x2 -- --struct hinic_port_qfilter_info { -- struct hinic_mgmt_msg_head mgmt_msg_head; -- -- u16 func_id; -- u8 normal_type_enable; -- u8 filter_type_enable; -- u8 filter_enable; -- u8 filter_type; -- u8 qid; -- u8 fdir_flag; -- u32 key; --}; -- - /** - * hinic_init_function_table - Initialize function table. - * -@@ -1901,7 +1885,7 @@ int hinic_set_fdir_tcam(void *hwdev, u16 type_mask, - &port_tcam_cmd, sizeof(port_tcam_cmd), - &port_tcam_cmd, &out_size); - if (err || !out_size || port_tcam_cmd.mgmt_msg_head.status) { -- PMD_DRV_LOG(ERR, "Set tcam table failed, err: %d, status: 0x%x, out size: 0x%x\n", -+ PMD_DRV_LOG(ERR, "Set tcam table failed, err: %d, status: 0x%x, out size: 0x%x", - err, port_tcam_cmd.mgmt_msg_head.status, out_size); - return -EFAULT; - } -@@ -1938,10 +1922,174 @@ int hinic_clear_fdir_tcam(void *hwdev, u16 type_mask) - &port_tcam_cmd, sizeof(port_tcam_cmd), - &port_tcam_cmd, &out_size); - if (err || !out_size || port_tcam_cmd.mgmt_msg_head.status) { -- PMD_DRV_LOG(ERR, "Clear tcam table failed, err: %d, status: 0x%x, out size: 0x%x\n", -+ PMD_DRV_LOG(ERR, "Clear tcam table failed, err: %d, status: 0x%x, out size: 0x%x", - err, port_tcam_cmd.mgmt_msg_head.status, out_size); - return -EFAULT; - } - - return 0; - } -+ -+int hinic_add_tcam_rule(void *hwdev, struct tag_tcam_cfg_rule *tcam_rule) -+{ -+ u16 out_size = sizeof(struct tag_fdir_add_rule_cmd); -+ struct tag_fdir_add_rule_cmd tcam_cmd; -+ int err; -+ -+ if (!hwdev) { -+ PMD_DRV_LOG(ERR, "Hwdev is NULL"); -+ return -EINVAL; -+ } -+ -+ if (tcam_rule->index >= HINIC_MAX_TCAM_RULES_NUM) { -+ PMD_DRV_LOG(ERR, "Tcam rules num to add is invalid"); -+ return -EFAULT; -+ } -+ -+ memset(&tcam_cmd, 0, sizeof(struct tag_fdir_add_rule_cmd)); -+ tcam_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; -+ memcpy((void *)&tcam_cmd.rule, (void *)tcam_rule, -+ sizeof(struct tag_tcam_cfg_rule)); -+ -+ err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_UP_TC_ADD_FLOW, -+ &tcam_cmd, sizeof(tcam_cmd), -+ &tcam_cmd, &out_size); -+ if (err || tcam_cmd.mgmt_msg_head.status || !out_size) { -+ PMD_DRV_LOG(ERR, -+ "Add tcam rule failed, err: %d, status: 0x%x, out size: 0x%x", -+ err, tcam_cmd.mgmt_msg_head.status, out_size); -+ return -EFAULT; -+ } -+ -+ return 0; -+} -+ -+int hinic_del_tcam_rule(void *hwdev, u32 index) -+{ -+ u16 out_size = sizeof(struct tag_fdir_del_rule_cmd); -+ struct tag_fdir_del_rule_cmd tcam_cmd; -+ int err; -+ -+ if (!hwdev) { -+ PMD_DRV_LOG(ERR, "Hwdev is NULL"); -+ return -EINVAL; -+ } -+ -+ if (index >= HINIC_MAX_TCAM_RULES_NUM) { -+ PMD_DRV_LOG(ERR, "Tcam rules num to del is invalid"); -+ return -EFAULT; -+ } -+ -+ memset(&tcam_cmd, 0, sizeof(struct tag_fdir_del_rule_cmd)); -+ tcam_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; -+ tcam_cmd.index_start = index; -+ tcam_cmd.index_num = 1; -+ -+ err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_UP_TC_DEL_FLOW, -+ &tcam_cmd, sizeof(tcam_cmd), -+ &tcam_cmd, &out_size); -+ if (err || tcam_cmd.mgmt_msg_head.status || !out_size) { -+ PMD_DRV_LOG(ERR, -+ "Del tcam rule failed, err: %d, status: 0x%x, out size: 0x%x", -+ err, tcam_cmd.mgmt_msg_head.status, out_size); -+ return -EFAULT; -+ } -+ -+ return 0; -+} -+ -+static int hinic_mgmt_tcam_block(void *hwdev, u8 alloc_en, -+ u8 block_type, u16 *index) -+{ -+ struct hinic_cmd_ctrl_tcam_block tcam_block_info; -+ u16 out_size = sizeof(struct hinic_cmd_ctrl_tcam_block); -+ struct hinic_hwdev *nic_hwdev = (struct hinic_hwdev *)hwdev; -+ int err; -+ -+ if (!hwdev) { -+ PMD_DRV_LOG(ERR, "Hwdev is NULL"); -+ return -EINVAL; -+ } -+ -+ memset(&tcam_block_info, 0, sizeof(struct hinic_cmd_ctrl_tcam_block)); -+ tcam_block_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; -+ tcam_block_info.func_id = hinic_global_func_id(hwdev); -+ tcam_block_info.alloc_en = alloc_en; -+ tcam_block_info.tcam_type = block_type; -+ tcam_block_info.tcam_block_index = *index; -+ -+ err = l2nic_msg_to_mgmt_sync(hwdev, -+ HINIC_PORT_CMD_UP_TC_CTRL_TCAM_BLOCK, -+ &tcam_block_info, sizeof(tcam_block_info), -+ &tcam_block_info, &out_size); -+ if (tcam_block_info.mgmt_msg_head.status == -+ HINIC_MGMT_CMD_UNSUPPORTED) { -+ err = HINIC_MGMT_CMD_UNSUPPORTED; -+ PMD_DRV_LOG(INFO, "Firmware/uP doesn't support alloc or del tcam block"); -+ return err; -+ } else if ((err == HINIC_MBOX_VF_CMD_ERROR) && -+ (HINIC_IS_VF(nic_hwdev))) { -+ err = HINIC_MGMT_CMD_UNSUPPORTED; -+ PMD_DRV_LOG(INFO, "VF doesn't support alloc and del tcam block."); -+ return err; -+ } else if (err || (!out_size) || tcam_block_info.mgmt_msg_head.status) { -+ PMD_DRV_LOG(ERR, -+ "Set tcam block failed, err: %d, status: 0x%x, out size: 0x%x", -+ err, tcam_block_info.mgmt_msg_head.status, out_size); -+ return -EFAULT; -+ } -+ -+ if (alloc_en) -+ *index = tcam_block_info.tcam_block_index; -+ -+ return 0; -+} -+ -+int hinic_alloc_tcam_block(void *hwdev, u8 block_type, u16 *index) -+{ -+ return hinic_mgmt_tcam_block(hwdev, HINIC_TCAM_BLOCK_ENABLE, -+ block_type, index); -+} -+ -+int hinic_free_tcam_block(void *hwdev, u8 block_type, u16 *index) -+{ -+ return hinic_mgmt_tcam_block(hwdev, HINIC_TCAM_BLOCK_DISABLE, -+ block_type, index); -+} -+ -+int hinic_flush_tcam_rule(void *hwdev) -+{ -+ struct hinic_cmd_flush_tcam_rules tcam_flush; -+ u16 out_size = sizeof(struct hinic_cmd_flush_tcam_rules); -+ struct hinic_hwdev *nic_hwdev = (struct hinic_hwdev *)hwdev; -+ int err; -+ -+ if (!hwdev) { -+ PMD_DRV_LOG(ERR, "Hwdev is NULL"); -+ return -EINVAL; -+ } -+ -+ memset(&tcam_flush, 0, sizeof(struct hinic_cmd_flush_tcam_rules)); -+ tcam_flush.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; -+ tcam_flush.func_id = hinic_global_func_id(hwdev); -+ -+ err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_UP_TC_FLUSH_TCAM, -+ &tcam_flush, sizeof(struct hinic_cmd_flush_tcam_rules), -+ &tcam_flush, &out_size); -+ if (tcam_flush.mgmt_msg_head.status == HINIC_MGMT_CMD_UNSUPPORTED) { -+ err = HINIC_MGMT_CMD_UNSUPPORTED; -+ PMD_DRV_LOG(INFO, "Firmware/uP doesn't support flush tcam fdir"); -+ } else if ((err == HINIC_MBOX_VF_CMD_ERROR) && -+ (HINIC_IS_VF(nic_hwdev))) { -+ err = HINIC_MGMT_CMD_UNSUPPORTED; -+ PMD_DRV_LOG(INFO, "VF doesn't support flush tcam fdir"); -+ } else if (err || (!out_size) || tcam_flush.mgmt_msg_head.status) { -+ PMD_DRV_LOG(ERR, -+ "Flush tcam fdir rules failed, err: %d, status: 0x%x, out size: 0x%x", -+ err, tcam_flush.mgmt_msg_head.status, out_size); -+ err = -EFAULT; -+ } -+ -+ return err; -+} -+ -diff --git a/drivers/net/hinic/base/hinic_pmd_niccfg.h b/drivers/net/hinic/base/hinic_pmd_niccfg.h -index b9e037ec2d..be6b320b31 100644 ---- a/drivers/net/hinic/base/hinic_pmd_niccfg.h -+++ b/drivers/net/hinic/base/hinic_pmd_niccfg.h -@@ -750,6 +750,77 @@ struct hinic_fdir_tcam_info { - struct tag_pa_action filter_action; - }; - -+#define TCAM_SET 0x1 -+#define TCAM_CLEAR 0x2 -+ -+struct hinic_port_qfilter_info { -+ struct hinic_mgmt_msg_head mgmt_msg_head; -+ -+ u16 func_id; -+ u8 normal_type_enable; -+ u8 filter_type_enable; -+ u8 filter_enable; -+ u8 filter_type; -+ u8 qid; -+ u8 fdir_flag; -+ u32 key; -+}; -+ -+#define HINIC_MAX_TCAM_RULES_NUM (10240) -+#define HINIC_TCAM_BLOCK_ENABLE 1 -+#define HINIC_TCAM_BLOCK_DISABLE 0 -+ -+struct tag_tcam_result { -+ u32 qid; -+ u32 rsvd; -+}; -+ -+#define TCAM_FLOW_KEY_SIZE 24 -+ -+struct tag_tcam_key_x_y { -+ u8 x[TCAM_FLOW_KEY_SIZE]; -+ u8 y[TCAM_FLOW_KEY_SIZE]; -+}; -+ -+struct tag_tcam_cfg_rule { -+ u32 index; -+ struct tag_tcam_result data; -+ struct tag_tcam_key_x_y key; -+}; -+ -+struct tag_fdir_add_rule_cmd { -+ struct hinic_mgmt_msg_head mgmt_msg_head; -+ struct tag_tcam_cfg_rule rule; -+}; -+ -+struct tag_fdir_del_rule_cmd { -+ struct hinic_mgmt_msg_head mgmt_msg_head; -+ -+ u32 index_start; -+ u32 index_num; -+}; -+ -+struct hinic_cmd_flush_tcam_rules { -+ struct hinic_mgmt_msg_head mgmt_msg_head; -+ -+ u16 func_id; -+ u16 rsvd; -+}; -+ -+struct hinic_cmd_ctrl_tcam_block { -+ struct hinic_mgmt_msg_head mgmt_msg_head; -+ -+ u16 func_id; -+ u8 alloc_en; /* 0: free tcam block, 1: alloc tcam block */ -+ /* -+ * 0: alloc 1k size tcam block, -+ * 1: alloc 128 size tcam block, others rsvd -+ */ -+ u8 tcam_type; -+ u16 tcam_block_index; -+ u16 rsvd; -+}; -+ - int hinic_set_mac(void *hwdev, u8 *mac_addr, u16 vlan_id, u16 func_id); - - int hinic_del_mac(void *hwdev, u8 *mac_addr, u16 vlan_id, u16 func_id); -@@ -858,4 +929,14 @@ int hinic_set_fdir_tcam(void *hwdev, u16 type_mask, - - int hinic_clear_fdir_tcam(void *hwdev, u16 type_mask); - -+int hinic_add_tcam_rule(void *hwdev, struct tag_tcam_cfg_rule *tcam_rule); -+ -+int hinic_del_tcam_rule(void *hwdev, u32 index); -+ -+int hinic_alloc_tcam_block(void *hwdev, u8 block_type, u16 *index); -+ -+int hinic_free_tcam_block(void *hwdev, u8 block_type, u16 *index); -+ -+int hinic_flush_tcam_rule(void *hwdev); -+ - #endif /* _HINIC_PMD_NICCFG_H_ */ -diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c -index 37aa042db2..9e90056f92 100644 ---- a/drivers/net/hinic/hinic_pmd_ethdev.c -+++ b/drivers/net/hinic/hinic_pmd_ethdev.c -@@ -1222,7 +1222,7 @@ static void hinic_dev_stop(struct rte_eth_dev *dev) - /* clean root context */ - hinic_free_qp_ctxts(nic_dev->hwdev); - -- hinic_free_fdir_filter(nic_dev); -+ hinic_destroy_fdir_filter(dev); - - /* free mbuf */ - hinic_free_all_rx_mbuf(dev); -@@ -2946,6 +2946,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) - struct rte_ether_addr *eth_addr; - struct hinic_nic_dev *nic_dev; - struct hinic_filter_info *filter_info; -+ struct hinic_tcam_info *tcam_info; - u32 mac_size; - int rc; - -@@ -3035,9 +3036,12 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) - - /* initialize filter info */ - filter_info = &nic_dev->filter; -+ tcam_info = &nic_dev->tcam; - memset(filter_info, 0, sizeof(struct hinic_filter_info)); -+ memset(tcam_info, 0, sizeof(struct hinic_tcam_info)); - /* initialize 5tuple filter list */ - TAILQ_INIT(&filter_info->fivetuple_list); -+ TAILQ_INIT(&tcam_info->tcam_list); - TAILQ_INIT(&nic_dev->filter_ntuple_list); - TAILQ_INIT(&nic_dev->filter_ethertype_list); - TAILQ_INIT(&nic_dev->filter_fdir_rule_list); -diff --git a/drivers/net/hinic/hinic_pmd_ethdev.h b/drivers/net/hinic/hinic_pmd_ethdev.h -index 3e3f3b3607..d67e2161c1 100644 ---- a/drivers/net/hinic/hinic_pmd_ethdev.h -+++ b/drivers/net/hinic/hinic_pmd_ethdev.h -@@ -95,20 +95,113 @@ struct hinic_hw_fdir_mask { - uint32_t dst_ipv4_mask; - uint16_t src_port_mask; - uint16_t dst_port_mask; -+ uint16_t proto_mask; -+ uint16_t tunnel_flag; -+ uint16_t tunnel_inner_src_port_mask; -+ uint16_t tunnel_inner_dst_port_mask; - }; - - /* Flow Director attribute */ - struct hinic_atr_input { -- u32 dst_ip; -- u32 src_ip; -- u16 src_port; -- u16 dst_port; -+ uint32_t dst_ip; -+ uint32_t src_ip; -+ uint16_t src_port; -+ uint16_t dst_port; -+ uint16_t proto; -+ uint16_t tunnel_flag; -+ uint16_t tunnel_inner_src_port; -+ uint16_t tunnel_inner_dst_port; -+}; -+ -+enum hinic_fdir_mode { -+ HINIC_FDIR_MODE_NORMAL = 0, -+ HINIC_FDIR_MODE_TCAM = 1, -+}; -+ -+#define HINIC_PF_MAX_TCAM_FILTERS 1024 -+#define HINIC_VF_MAX_TCAM_FILTERS 128 -+#define HINIC_SUPPORT_PF_MAX_NUM 4 -+#define HINIC_TOTAL_PF_MAX_NUM 16 -+#define HINIC_SUPPORT_VF_MAX_NUM 32 -+#define HINIC_TCAM_BLOCK_TYPE_PF 0 /* 1024 tcam index of a block */ -+#define HINIC_TCAM_BLOCK_TYPE_VF 1 /* 128 tcam index of a block */ -+ -+#define HINIC_PKT_VF_TCAM_INDEX_START(block_index) \ -+ (HINIC_PF_MAX_TCAM_FILTERS * HINIC_SUPPORT_PF_MAX_NUM + \ -+ HINIC_VF_MAX_TCAM_FILTERS * (block_index)) -+ -+TAILQ_HEAD(hinic_tcam_filter_list, hinic_tcam_filter); -+ -+struct hinic_tcam_info { -+ struct hinic_tcam_filter_list tcam_list; -+ u8 tcam_index_array[HINIC_PF_MAX_TCAM_FILTERS]; -+ u16 tcam_block_index; -+ u16 tcam_rule_nums; -+}; -+ -+struct tag_tcam_key_mem { -+#if (RTE_BYTE_ORDER == RTE_BIG_ENDIAN) -+ -+ u32 rsvd0:16; -+ u32 function_id:16; -+ -+ u32 protocol:8; -+ /* -+ * tunnel packet, mask must be 0xff, spec value is 1; -+ * normal packet, mask must be 0, spec value is 0; -+ * if tunnal packet, ucode use -+ * sip/dip/protocol/src_port/dst_dport from inner packet -+ */ -+ u32 tunnel_flag:8; -+ u32 sip_h:16; -+ -+ u32 sip_l:16; -+ u32 dip_h:16; -+ -+ u32 dip_l:16; -+ u32 src_port:16; -+ -+ u32 dst_port:16; -+ /* -+ * tunnel packet and normal packet, -+ * ext_dip mask must be 0xffffffff -+ */ -+ u32 ext_dip_h:16; -+ u32 ext_dip_l:16; -+ u32 rsvd2:16; -+#else -+ u32 function_id:16; -+ u32 rsvd0:16; -+ -+ u32 sip_h:16; -+ u32 tunnel_flag:8; -+ u32 protocol:8; -+ -+ u32 dip_h:16; -+ u32 sip_l:16; -+ -+ u32 src_port:16; -+ u32 dip_l:16; -+ -+ u32 ext_dip_h:16; -+ u32 dst_port:16; -+ -+ u32 rsvd2:16; -+ u32 ext_dip_l:16; -+#endif -+}; -+ -+struct tag_tcam_key { -+ struct tag_tcam_key_mem key_info; -+ struct tag_tcam_key_mem key_mask; - }; - - struct hinic_fdir_rule { - struct hinic_hw_fdir_mask mask; - struct hinic_atr_input hinic_fdir; /* key of fdir filter */ - uint8_t queue; /* queue assigned when matched */ -+ enum hinic_fdir_mode mode; /* fdir type */ -+ u16 tcam_index; - }; - - /* ntuple filter list structure */ -@@ -129,6 +222,13 @@ struct hinic_fdir_rule_ele { - struct hinic_fdir_rule filter_info; - }; - -+struct hinic_tcam_filter { -+ TAILQ_ENTRY(hinic_tcam_filter) entries; -+ uint16_t index; /* tcam index */ -+ struct tag_tcam_key tcam_key; -+ uint16_t queue; /* rx queue assigned to */ -+}; -+ - struct rte_flow { - enum rte_filter_type filter_type; - void *rule; -@@ -181,6 +281,7 @@ struct hinic_nic_dev { - u32 rx_csum_en; - - struct hinic_filter_info filter; -+ struct hinic_tcam_info tcam; - struct hinic_ntuple_filter_list filter_ntuple_list; - struct hinic_ethertype_filter_list filter_ethertype_list; - struct hinic_fdir_rule_filter_list filter_fdir_rule_list; -@@ -189,4 +290,5 @@ struct hinic_nic_dev { - - void hinic_free_fdir_filter(struct hinic_nic_dev *nic_dev); - -+void hinic_destroy_fdir_filter(struct rte_eth_dev *dev); - #endif /* _HINIC_PMD_ETHDEV_H_ */ -diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c -index 49c9d8768c..c1f86eff05 100644 ---- a/drivers/net/hinic/hinic_pmd_flow.c -+++ b/drivers/net/hinic/hinic_pmd_flow.c -@@ -46,7 +46,12 @@ - #define PA_IP_PROTOCOL_TYPE_SCTP 5 - #define PA_IP_PROTOCOL_TYPE_VRRP 112 - --#define IP_HEADER_PROTOCOL_TYPE_TCP 6 -+#define IP_HEADER_PROTOCOL_TYPE_TCP 6 -+#define IP_HEADER_PROTOCOL_TYPE_UDP 17 -+#define IP_HEADER_PROTOCOL_TYPE_ICMP 1 -+ -+#define FDIR_TCAM_NORMAL_PACKET 0 -+#define FDIR_TCAM_TUNNEL_PACKET 1 - - #define HINIC_MIN_N_TUPLE_PRIO 1 - #define HINIC_MAX_N_TUPLE_PRIO 7 -@@ -82,6 +87,10 @@ - #define HINIC_DEV_PRIVATE_TO_FILTER_INFO(nic_dev) \ - (&((struct hinic_nic_dev *)nic_dev)->filter) - -+#define HINIC_DEV_PRIVATE_TO_TCAM_INFO(nic_dev) \ -+ (&((struct hinic_nic_dev *)nic_dev)->tcam) -+ -+ - enum hinic_atr_flow_type { - HINIC_ATR_FLOW_TYPE_IPV4_DIP = 0x1, - HINIC_ATR_FLOW_TYPE_IPV4_SIP = 0x2, -@@ -270,8 +279,7 @@ hinic_parse_ethertype_aciton(const struct rte_flow_action *actions, - * other members in mask and spec should set to 0x00. - * item->last should be NULL. - */ --static int --cons_parse_ethertype_filter(const struct rte_flow_attr *attr, -+static int cons_parse_ethertype_filter(const struct rte_flow_attr *attr, - const struct rte_flow_item *pattern, - const struct rte_flow_action *actions, - struct rte_eth_ethertype_filter *filter, -@@ -341,8 +349,7 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, - return 0; - } - --static int --hinic_parse_ethertype_filter(struct rte_eth_dev *dev, -+static int hinic_parse_ethertype_filter(struct rte_eth_dev *dev, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], -@@ -728,8 +735,7 @@ static int hinic_check_ntuple_item_ele(const struct rte_flow_item *item, - * Because the pattern is used to describe the packets, - * normally the packets should use network order. - */ --static int --cons_parse_ntuple_filter(const struct rte_flow_attr *attr, -+static int cons_parse_ntuple_filter(const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_eth_ntuple_filter *filter, -@@ -752,8 +758,7 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, - return 0; - } - --static int --hinic_parse_ntuple_filter(struct rte_eth_dev *dev, -+static int hinic_parse_ntuple_filter(struct rte_eth_dev *dev, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], -@@ -891,6 +896,7 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item, - - rule->mask.dst_ipv4_mask = ipv4_mask->hdr.dst_addr; - rule->mask.src_ipv4_mask = ipv4_mask->hdr.src_addr; -+ rule->mode = HINIC_FDIR_MODE_NORMAL; - - if (item->spec) { - ipv4_spec = -@@ -906,6 +912,8 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item, - item = next_no_void_pattern(pattern, item); - if (item->type != RTE_FLOW_ITEM_TYPE_TCP && - item->type != RTE_FLOW_ITEM_TYPE_UDP && -+ item->type != RTE_FLOW_ITEM_TYPE_ICMP && -+ item->type != RTE_FLOW_ITEM_TYPE_ANY && - item->type != RTE_FLOW_ITEM_TYPE_END) { - memset(rule, 0, sizeof(struct hinic_fdir_rule)); - rte_flow_error_set(error, EINVAL, -@@ -920,6 +928,239 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item, - } - - static int hinic_normal_item_check_l4(const struct rte_flow_item **in_out_item, -+ __rte_unused const struct rte_flow_item pattern[], -+ __rte_unused struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ const struct rte_flow_item *item = *in_out_item; -+ -+ if (item->type != RTE_FLOW_ITEM_TYPE_END) { -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by normal fdir filter,not support l4"); -+ return -rte_errno; -+ } -+ -+ return 0; -+} -+ -+ -+static int hinic_normal_item_check_end(const struct rte_flow_item *item, -+ struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ /* Check if the next not void item is END */ -+ if (item->type != RTE_FLOW_ITEM_TYPE_END) { -+ memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter,support end"); -+ return -rte_errno; -+ } -+ -+ return 0; -+} -+ -+static int hinic_check_normal_item_ele(const struct rte_flow_item *item, -+ const struct rte_flow_item pattern[], -+ struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ if (hinic_normal_item_check_ether(&item, pattern, error) || -+ hinic_normal_item_check_ip(&item, pattern, rule, error) || -+ hinic_normal_item_check_l4(&item, pattern, rule, error) || -+ hinic_normal_item_check_end(item, rule, error)) -+ return -rte_errno; -+ -+ return 0; -+} -+ -+static int -+hinic_tcam_normal_item_check_l4(const struct rte_flow_item **in_out_item, -+ const struct rte_flow_item pattern[], -+ struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ const struct rte_flow_item *item = *in_out_item; -+ const struct rte_flow_item_tcp *tcp_spec; -+ const struct rte_flow_item_tcp *tcp_mask; -+ const struct rte_flow_item_udp *udp_spec; -+ const struct rte_flow_item_udp *udp_mask; -+ -+ if (item->type == RTE_FLOW_ITEM_TYPE_ICMP) { -+ rule->mode = HINIC_FDIR_MODE_TCAM; -+ rule->mask.proto_mask = UINT16_MAX; -+ rule->hinic_fdir.proto = IP_HEADER_PROTOCOL_TYPE_ICMP; -+ } else if (item->type == RTE_FLOW_ITEM_TYPE_ANY) { -+ rule->mode = HINIC_FDIR_MODE_TCAM; -+ } else if (item->type == RTE_FLOW_ITEM_TYPE_TCP) { -+ if (!item->mask) { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter, support src, dst ports"); -+ return -rte_errno; -+ } -+ -+ tcp_mask = (const struct rte_flow_item_tcp *)item->mask; -+ -+ /* -+ * Only support src & dst ports, tcp flags, -+ * others should be masked. -+ */ -+ if (tcp_mask->hdr.sent_seq || -+ tcp_mask->hdr.recv_ack || -+ tcp_mask->hdr.data_off || -+ tcp_mask->hdr.rx_win || -+ tcp_mask->hdr.cksum || -+ tcp_mask->hdr.tcp_urp) { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir normal tcam filter"); -+ return -rte_errno; -+ } -+ -+ rule->mode = HINIC_FDIR_MODE_TCAM; -+ rule->mask.proto_mask = UINT16_MAX; -+ rule->mask.dst_port_mask = tcp_mask->hdr.dst_port; -+ rule->mask.src_port_mask = tcp_mask->hdr.src_port; -+ -+ rule->hinic_fdir.proto = IP_HEADER_PROTOCOL_TYPE_TCP; -+ if (item->spec) { -+ tcp_spec = (const struct rte_flow_item_tcp *)item->spec; -+ rule->hinic_fdir.dst_port = tcp_spec->hdr.dst_port; -+ rule->hinic_fdir.src_port = tcp_spec->hdr.src_port; -+ } -+ } else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) { -+ /* -+ * Only care about src & dst ports, -+ * others should be masked. -+ */ -+ if (!item->mask) { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter, support src, dst ports"); -+ return -rte_errno; -+ } -+ -+ udp_mask = (const struct rte_flow_item_udp *)item->mask; -+ if (udp_mask->hdr.dgram_len || -+ udp_mask->hdr.dgram_cksum) { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter, support udp"); -+ return -rte_errno; -+ } -+ -+ rule->mode = HINIC_FDIR_MODE_TCAM; -+ rule->mask.proto_mask = UINT16_MAX; -+ rule->mask.src_port_mask = udp_mask->hdr.src_port; -+ rule->mask.dst_port_mask = udp_mask->hdr.dst_port; -+ -+ rule->hinic_fdir.proto = IP_HEADER_PROTOCOL_TYPE_UDP; -+ if (item->spec) { -+ udp_spec = (const struct rte_flow_item_udp *)item->spec; -+ rule->hinic_fdir.src_port = udp_spec->hdr.src_port; -+ rule->hinic_fdir.dst_port = udp_spec->hdr.dst_port; -+ } -+ } else { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter tcam normal, l4 only support icmp, tcp"); -+ return -rte_errno; -+ } -+ -+ item = next_no_void_pattern(pattern, item); -+ if (item->type != RTE_FLOW_ITEM_TYPE_END) { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter tcam normal, support end"); -+ return -rte_errno; -+ } -+ -+ /* get next no void item */ -+ *in_out_item = item; -+ -+ return 0; -+} -+ -+static int hinic_check_tcam_normal_item_ele(const struct rte_flow_item *item, -+ const struct rte_flow_item pattern[], -+ struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ if (hinic_normal_item_check_ether(&item, pattern, error) || -+ hinic_normal_item_check_ip(&item, pattern, rule, error) || -+ hinic_tcam_normal_item_check_l4(&item, pattern, rule, error) || -+ hinic_normal_item_check_end(item, rule, error)) -+ return -rte_errno; -+ -+ return 0; -+} -+ -+static int hinic_tunnel_item_check_l4(const struct rte_flow_item **in_out_item, -+ const struct rte_flow_item pattern[], -+ struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ const struct rte_flow_item *item = *in_out_item; -+ -+ if (item->type == RTE_FLOW_ITEM_TYPE_UDP) { -+ item = next_no_void_pattern(pattern, item); -+ if (item->type != RTE_FLOW_ITEM_TYPE_VXLAN) { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter, support vxlan"); -+ return -rte_errno; -+ } -+ -+ *in_out_item = item; -+ } else { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter tcam tunnel, outer l4 only support udp"); -+ return -rte_errno; -+ } -+ -+ return 0; -+} -+ -+static int -+hinic_tunnel_item_check_vxlan(const struct rte_flow_item **in_out_item, -+ const struct rte_flow_item pattern[], -+ struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ const struct rte_flow_item *item = *in_out_item; -+ -+ -+ if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN) { -+ item = next_no_void_pattern(pattern, item); -+ if (item->type != RTE_FLOW_ITEM_TYPE_TCP && -+ item->type != RTE_FLOW_ITEM_TYPE_UDP && -+ item->type != RTE_FLOW_ITEM_TYPE_ANY) { -+ (void)memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter, support tcp/udp"); -+ return -rte_errno; -+ } -+ -+ *in_out_item = item; -+ } -+ -+ return 0; -+} -+ -+static int -+hinic_tunnel_inner_item_check_l4(const struct rte_flow_item **in_out_item, - const struct rte_flow_item pattern[], - struct hinic_fdir_rule *rule, - struct rte_flow_error *error) -@@ -933,13 +1174,14 @@ static int hinic_normal_item_check_l4(const struct rte_flow_item **in_out_item, - if (item->type != RTE_FLOW_ITEM_TYPE_END) { - /* Not supported last point for range */ - if (item->last) { -+ memset(rule, 0, sizeof(struct hinic_fdir_rule)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - item, "Not supported last point for range"); - return -rte_errno; - } - -- /* Get TCP/UDP info */ -+ /* get the TCP/UDP info */ - if (item->type == RTE_FLOW_ITEM_TYPE_TCP) { - /* - * Only care about src & dst ports, -@@ -948,8 +1190,8 @@ static int hinic_normal_item_check_l4(const struct rte_flow_item **in_out_item, - if (!item->mask) { - memset(rule, 0, sizeof(struct hinic_fdir_rule)); - rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Not supported by fdir filter,support src,dst ports"); -+ RTE_FLOW_ERROR_TYPE_ITEM, -+ item, "Not supported by fdir filter, support src, dst ports"); - return -rte_errno; - } - -@@ -961,26 +1203,31 @@ static int hinic_normal_item_check_l4(const struct rte_flow_item **in_out_item, - tcp_mask->hdr.rx_win || - tcp_mask->hdr.cksum || - tcp_mask->hdr.tcp_urp) { -- memset(rule, 0, sizeof(struct hinic_fdir_rule)); -+ (void)memset(rule, 0, -+ sizeof(struct hinic_fdir_rule)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, -- item, "Not supported by fdir filter,support tcp"); -+ item, "Not supported by fdir filter, support tcp"); - return -rte_errno; - } - -- rule->mask.src_port_mask = tcp_mask->hdr.src_port; -- rule->mask.dst_port_mask = tcp_mask->hdr.dst_port; -+ rule->mode = HINIC_FDIR_MODE_TCAM; -+ rule->mask.tunnel_flag = UINT16_MAX; -+ rule->mask.tunnel_inner_src_port_mask = -+ tcp_mask->hdr.src_port; -+ rule->mask.tunnel_inner_dst_port_mask = -+ tcp_mask->hdr.dst_port; -+ rule->mask.proto_mask = UINT16_MAX; - -+ rule->hinic_fdir.proto = IP_HEADER_PROTOCOL_TYPE_TCP; - if (item->spec) { - tcp_spec = -- (const struct rte_flow_item_tcp *) -- item->spec; -- rule->hinic_fdir.src_port = -- tcp_spec->hdr.src_port; -- rule->hinic_fdir.dst_port = -- tcp_spec->hdr.dst_port; -+ (const struct rte_flow_item_tcp *)item->spec; -+ rule->hinic_fdir.tunnel_inner_src_port = -+ tcp_spec->hdr.src_port; -+ rule->hinic_fdir.tunnel_inner_dst_port = -+ tcp_spec->hdr.dst_port; - } -- - } else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) { - /* - * Only care about src & dst ports, -@@ -990,7 +1237,7 @@ static int hinic_normal_item_check_l4(const struct rte_flow_item **in_out_item, - memset(rule, 0, sizeof(struct hinic_fdir_rule)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, -- item, "Not supported by fdir filter,support src,dst ports"); -+ item, "Not supported by fdir filter, support src, dst ports"); - return -rte_errno; - } - -@@ -1000,60 +1247,55 @@ static int hinic_normal_item_check_l4(const struct rte_flow_item **in_out_item, - memset(rule, 0, sizeof(struct hinic_fdir_rule)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, -- item, "Not supported by fdir filter,support udp"); -+ item, "Not supported by fdir filter, support udp"); - return -rte_errno; - } -- rule->mask.src_port_mask = udp_mask->hdr.src_port; -- rule->mask.dst_port_mask = udp_mask->hdr.dst_port; - -+ rule->mode = HINIC_FDIR_MODE_TCAM; -+ rule->mask.tunnel_flag = UINT16_MAX; -+ rule->mask.tunnel_inner_src_port_mask = -+ udp_mask->hdr.src_port; -+ rule->mask.tunnel_inner_dst_port_mask = -+ udp_mask->hdr.dst_port; -+ rule->mask.proto_mask = UINT16_MAX; -+ -+ rule->hinic_fdir.proto = IP_HEADER_PROTOCOL_TYPE_UDP; - if (item->spec) { - udp_spec = -- (const struct rte_flow_item_udp *) -- item->spec; -- rule->hinic_fdir.src_port = -- udp_spec->hdr.src_port; -- rule->hinic_fdir.dst_port = -- udp_spec->hdr.dst_port; -+ (const struct rte_flow_item_udp *)item->spec; -+ rule->hinic_fdir.tunnel_inner_src_port = -+ udp_spec->hdr.src_port; -+ rule->hinic_fdir.tunnel_inner_dst_port = -+ udp_spec->hdr.dst_port; - } -+ } else if (item->type == RTE_FLOW_ITEM_TYPE_ANY) { -+ rule->mode = HINIC_FDIR_MODE_TCAM; -+ rule->mask.tunnel_flag = UINT16_MAX; - } else { - memset(rule, 0, sizeof(struct hinic_fdir_rule)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, -- item, "Not supported by fdir filter,support tcp/udp"); -+ item, "Not supported by fdir filter, support tcp/udp"); - return -rte_errno; - } - -- /* Get next no void item */ -+ /* get next no void item */ - *in_out_item = next_no_void_pattern(pattern, item); - } - - return 0; - } - --static int hinic_normal_item_check_end(const struct rte_flow_item *item, -- struct hinic_fdir_rule *rule, -- struct rte_flow_error *error) --{ -- /* Check if the next not void item is END */ -- if (item->type != RTE_FLOW_ITEM_TYPE_END) { -- memset(rule, 0, sizeof(struct hinic_fdir_rule)); -- rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, -- item, "Not supported by fdir filter,support end"); -- return -rte_errno; -- } -- -- return 0; --} -- --static int hinic_check_normal_item_ele(const struct rte_flow_item *item, -+static int hinic_check_tcam_tunnel_item_ele(const struct rte_flow_item *item, - const struct rte_flow_item pattern[], - struct hinic_fdir_rule *rule, - struct rte_flow_error *error) - { - if (hinic_normal_item_check_ether(&item, pattern, error) || - hinic_normal_item_check_ip(&item, pattern, rule, error) || -- hinic_normal_item_check_l4(&item, pattern, rule, error) || -+ hinic_tunnel_item_check_l4(&item, pattern, rule, error) || -+ hinic_tunnel_item_check_vxlan(&item, pattern, rule, error) || -+ hinic_tunnel_inner_item_check_l4(&item, pattern, rule, error) || - hinic_normal_item_check_end(item, rule, error)) - return -rte_errno; - -@@ -1172,8 +1414,107 @@ hinic_parse_fdir_filter_normal(const struct rte_flow_attr *attr, - return 0; - } - -+/** -+ * Parse the rule to see if it is a IP or MAC VLAN flow director rule. -+ * And get the flow director filter info BTW. -+ * UDP/TCP/SCTP PATTERN: -+ * The first not void item can be ETH or IPV4 or IPV6 -+ * The second not void item must be IPV4 or IPV6 if the first one is ETH. -+ * The next not void item can be ANY/TCP/UDP -+ * ACTION: -+ * The first not void action should be QUEUE. -+ * The second not void optional action should be MARK, -+ * mark_id is a uint32_t number. -+ * The next not void action should be END. -+ * UDP/TCP pattern example: -+ * ITEM Spec Mask -+ * ETH NULL NULL -+ * IPV4 src_addr 1.2.3.6 0xFFFFFFFF -+ * dst_addr 1.2.3.5 0xFFFFFFFF -+ * UDP/TCP src_port 80 0xFFFF -+ * dst_port 80 0xFFFF -+ * END -+ * Other members in mask and spec should set to 0x00. -+ * Item->last should be NULL. -+ */ -+static int -+hinic_parse_fdir_filter_tcam_normal(const struct rte_flow_attr *attr, -+ const struct rte_flow_item pattern[], -+ const struct rte_flow_action actions[], -+ struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ const struct rte_flow_item *item = NULL; -+ -+ if (hinic_check_filter_arg(attr, pattern, actions, error)) -+ return -rte_errno; -+ -+ if (hinic_check_tcam_normal_item_ele(item, pattern, rule, error)) -+ return -rte_errno; -+ -+ if (hinic_check_normal_attr_ele(attr, rule, error)) -+ return -rte_errno; -+ -+ if (hinic_check_normal_act_ele(item, actions, rule, error)) -+ return -rte_errno; -+ -+ return 0; -+} -+ -+/** -+ * Parse the rule to see if it is a IP or MAC VLAN flow director rule. -+ * And get the flow director filter info BTW. -+ * UDP/TCP/SCTP PATTERN: -+ * The first not void item can be ETH or IPV4 or IPV6 -+ * The second not void item must be IPV4 or IPV6 if the first one is ETH. -+ * The next not void item must be UDP -+ * The next not void item must be VXLAN(optional) -+ * The first not void item can be ETH or IPV4 or IPV6 -+ * The next not void item could be ANY or UDP or TCP(optional) -+ * The next not void item must be END. -+ * ACTION: -+ * The first not void action should be QUEUE. -+ * The second not void optional action should be MARK, -+ * mark_id is a uint32_t number. -+ * The next not void action should be END. -+ * UDP/TCP pattern example: -+ * ITEM Spec Mask -+ * ETH NULL NULL -+ * IPV4 src_addr 1.2.3.6 0xFFFFFFFF -+ * dst_addr 1.2.3.5 0xFFFFFFFF -+ * UDP NULL NULL -+ * VXLAN NULL NULL -+ * UDP/TCP src_port 80 0xFFFF -+ * dst_port 80 0xFFFF -+ * END -+ * Other members in mask and spec should set to 0x00. -+ * Item->last should be NULL. -+ */ - static int --hinic_parse_fdir_filter(struct rte_eth_dev *dev, -+hinic_parse_fdir_filter_tacm_tunnel(const struct rte_flow_attr *attr, -+ const struct rte_flow_item pattern[], -+ const struct rte_flow_action actions[], -+ struct hinic_fdir_rule *rule, -+ struct rte_flow_error *error) -+{ -+ const struct rte_flow_item *item = NULL; -+ -+ if (hinic_check_filter_arg(attr, pattern, actions, error)) -+ return -rte_errno; -+ -+ if (hinic_check_tcam_tunnel_item_ele(item, pattern, rule, error)) -+ return -rte_errno; -+ -+ if (hinic_check_normal_attr_ele(attr, rule, error)) -+ return -rte_errno; -+ -+ if (hinic_check_normal_act_ele(item, actions, rule, error)) -+ return -rte_errno; -+ -+ return 0; -+} -+ -+static int hinic_parse_fdir_filter(struct rte_eth_dev *dev, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], -@@ -1182,11 +1523,22 @@ hinic_parse_fdir_filter(struct rte_eth_dev *dev, - { - int ret; - -- ret = hinic_parse_fdir_filter_normal(attr, pattern, -- actions, rule, error); -+ ret = hinic_parse_fdir_filter_normal(attr, pattern, actions, -+ rule, error); -+ if (!ret) -+ goto step_next; -+ -+ ret = hinic_parse_fdir_filter_tcam_normal(attr, pattern, actions, -+ rule, error); -+ if (!ret) -+ goto step_next; -+ -+ ret = hinic_parse_fdir_filter_tacm_tunnel(attr, pattern, actions, -+ rule, error); - if (ret) - return ret; - -+step_next: - if (rule->queue >= dev->data->nb_rx_queues) - return -ENOTSUP; - -@@ -1229,18 +1581,17 @@ static int hinic_flow_validate(struct rte_eth_dev *dev, - return ret; - } - --static inline int --ntuple_ip_filter(struct rte_eth_ntuple_filter *filter, -- struct hinic_5tuple_filter_info *filter_info) -+static inline int ntuple_ip_filter(struct rte_eth_ntuple_filter *filter, -+ struct hinic_5tuple_filter_info *hinic_filter_info) - { - switch (filter->dst_ip_mask) { - case UINT32_MAX: -- filter_info->dst_ip_mask = 0; -- filter_info->dst_ip = filter->dst_ip; -+ hinic_filter_info->dst_ip_mask = 0; -+ hinic_filter_info->dst_ip = filter->dst_ip; - break; - case 0: -- filter_info->dst_ip_mask = 1; -- filter_info->dst_ip = 0; -+ hinic_filter_info->dst_ip_mask = 1; -+ hinic_filter_info->dst_ip = 0; - break; - default: - PMD_DRV_LOG(ERR, "Invalid dst_ip mask."); -@@ -1249,12 +1600,12 @@ ntuple_ip_filter(struct rte_eth_ntuple_filter *filter, - - switch (filter->src_ip_mask) { - case UINT32_MAX: -- filter_info->src_ip_mask = 0; -- filter_info->src_ip = filter->src_ip; -+ hinic_filter_info->src_ip_mask = 0; -+ hinic_filter_info->src_ip = filter->src_ip; - break; - case 0: -- filter_info->src_ip_mask = 1; -- filter_info->src_ip = 0; -+ hinic_filter_info->src_ip_mask = 1; -+ hinic_filter_info->src_ip = 0; - break; - default: - PMD_DRV_LOG(ERR, "Invalid src_ip mask."); -@@ -1263,18 +1614,17 @@ ntuple_ip_filter(struct rte_eth_ntuple_filter *filter, - return 0; - } - --static inline int --ntuple_port_filter(struct rte_eth_ntuple_filter *filter, -- struct hinic_5tuple_filter_info *filter_info) -+static inline int ntuple_port_filter(struct rte_eth_ntuple_filter *filter, -+ struct hinic_5tuple_filter_info *hinic_filter_info) - { - switch (filter->dst_port_mask) { - case UINT16_MAX: -- filter_info->dst_port_mask = 0; -- filter_info->dst_port = filter->dst_port; -+ hinic_filter_info->dst_port_mask = 0; -+ hinic_filter_info->dst_port = filter->dst_port; - break; - case 0: -- filter_info->dst_port_mask = 1; -- filter_info->dst_port = 0; -+ hinic_filter_info->dst_port_mask = 1; -+ hinic_filter_info->dst_port = 0; - break; - default: - PMD_DRV_LOG(ERR, "Invalid dst_port mask."); -@@ -1283,12 +1633,12 @@ ntuple_port_filter(struct rte_eth_ntuple_filter *filter, - - switch (filter->src_port_mask) { - case UINT16_MAX: -- filter_info->src_port_mask = 0; -- filter_info->src_port = filter->src_port; -+ hinic_filter_info->src_port_mask = 0; -+ hinic_filter_info->src_port = filter->src_port; - break; - case 0: -- filter_info->src_port_mask = 1; -- filter_info->src_port = 0; -+ hinic_filter_info->src_port_mask = 1; -+ hinic_filter_info->src_port = 0; - break; - default: - PMD_DRV_LOG(ERR, "Invalid src_port mask."); -@@ -1298,18 +1648,17 @@ ntuple_port_filter(struct rte_eth_ntuple_filter *filter, - return 0; - } - --static inline int --ntuple_proto_filter(struct rte_eth_ntuple_filter *filter, -- struct hinic_5tuple_filter_info *filter_info) -+static inline int ntuple_proto_filter(struct rte_eth_ntuple_filter *filter, -+ struct hinic_5tuple_filter_info *hinic_filter_info) - { - switch (filter->proto_mask) { - case UINT8_MAX: -- filter_info->proto_mask = 0; -- filter_info->proto = filter->proto; -+ hinic_filter_info->proto_mask = 0; -+ hinic_filter_info->proto = filter->proto; - break; - case 0: -- filter_info->proto_mask = 1; -- filter_info->proto = 0; -+ hinic_filter_info->proto_mask = 1; -+ hinic_filter_info->proto = 0; - break; - default: - PMD_DRV_LOG(ERR, "Invalid protocol mask."); -@@ -1319,8 +1668,7 @@ ntuple_proto_filter(struct rte_eth_ntuple_filter *filter, - return 0; - } - --static inline int --ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter, -+static inline int ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter, - struct hinic_5tuple_filter_info *filter_info) - { - if (filter->queue >= HINIC_MAX_RX_QUEUE_NUM || -@@ -1468,30 +1816,20 @@ static int hinic_set_vrrp_tcam(struct hinic_nic_dev *nic_dev) - */ - void hinic_free_fdir_filter(struct hinic_nic_dev *nic_dev) - { -- struct hinic_filter_info *filter_info = -- HINIC_DEV_PRIVATE_TO_FILTER_INFO(nic_dev); -+ (void)hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, false); - -- if (filter_info->type_mask & -- (1 << HINIC_PKT_TYPE_FIND_ID(PKT_BGPD_DPORT_TYPE))) -- hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_BGP_DPORT); -+ (void)hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_BGP_DPORT); - -- if (filter_info->type_mask & -- (1 << HINIC_PKT_TYPE_FIND_ID(PKT_BGPD_SPORT_TYPE))) -- hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_BGP_SPORT); -+ (void)hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_BGP_SPORT); - -- if (filter_info->type_mask & -- (1 << HINIC_PKT_TYPE_FIND_ID(PKT_VRRP_TYPE))) -- hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_VRRP); -+ (void)hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_VRRP); - -- if (filter_info->type_mask & -- (1 << HINIC_PKT_TYPE_FIND_ID(PKT_LACP_TYPE))) -- hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_LACP); -+ (void)hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_LACP); - -- hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, false); -+ (void)hinic_flush_tcam_rule(nic_dev->hwdev); - } - --static int --hinic_filter_info_init(struct hinic_5tuple_filter *filter, -+static int hinic_filter_info_init(struct hinic_5tuple_filter *filter, - struct hinic_filter_info *filter_info) - { - switch (filter->filter_info.proto) { -@@ -1544,10 +1882,8 @@ hinic_filter_info_init(struct hinic_5tuple_filter *filter, - return 0; - } - --static int --hinic_lookup_new_filter(struct hinic_5tuple_filter *filter, -- struct hinic_filter_info *filter_info, -- int *index) -+static int hinic_lookup_new_filter(struct hinic_5tuple_filter *filter, -+ struct hinic_filter_info *filter_info, int *index) - { - int type_id; - -@@ -1586,9 +1922,8 @@ hinic_lookup_new_filter(struct hinic_5tuple_filter *filter, - * - On success, zero. - * - On failure, a negative value. - */ --static int --hinic_add_5tuple_filter(struct rte_eth_dev *dev, -- struct hinic_5tuple_filter *filter) -+static int hinic_add_5tuple_filter(struct rte_eth_dev *dev, -+ struct hinic_5tuple_filter *filter) - { - struct hinic_filter_info *filter_info = - HINIC_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); -@@ -1676,8 +2011,7 @@ hinic_add_5tuple_filter(struct rte_eth_dev *dev, - * @param filter - * The pointer of the filter will be removed. - */ --static void --hinic_remove_5tuple_filter(struct rte_eth_dev *dev, -+static void hinic_remove_5tuple_filter(struct rte_eth_dev *dev, - struct hinic_5tuple_filter *filter) - { - struct hinic_filter_info *filter_info = -@@ -1929,7 +2263,6 @@ hinic_add_del_ethertype_filter(struct rte_eth_dev *dev, - default: - break; - } -- - } else { - ethertype_filter.pkt_proto = filter->ether_type; - i = hinic_ethertype_filter_lookup(filter_info, -@@ -1972,9 +2305,8 @@ hinic_add_del_ethertype_filter(struct rte_eth_dev *dev, - return 0; - } - --static int --hinic_fdir_info_init(struct hinic_fdir_rule *rule, -- struct hinic_fdir_info *fdir_info) -+static int hinic_fdir_info_init(struct hinic_fdir_rule *rule, -+ struct hinic_fdir_info *fdir_info) - { - switch (rule->mask.src_ipv4_mask) { - case UINT32_MAX: -@@ -2014,10 +2346,8 @@ hinic_fdir_info_init(struct hinic_fdir_rule *rule, - return 0; - } - --static inline int --hinic_add_del_fdir_filter(struct rte_eth_dev *dev, -- struct hinic_fdir_rule *rule, -- bool add) -+static inline int hinic_add_del_fdir_filter(struct rte_eth_dev *dev, -+ struct hinic_fdir_rule *rule, bool add) - { - struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); - struct hinic_fdir_info fdir_info; -@@ -2062,6 +2392,352 @@ hinic_add_del_fdir_filter(struct rte_eth_dev *dev, - return 0; - } - -+static void tcam_translate_key_y(u8 *key_y, u8 *src_input, u8 *mask, u8 len) -+{ -+ u8 idx; -+ -+ for (idx = 0; idx < len; idx++) -+ key_y[idx] = src_input[idx] & mask[idx]; -+} -+ -+static void tcam_translate_key_x(u8 *key_x, u8 *key_y, u8 *mask, u8 len) -+{ -+ u8 idx; -+ -+ for (idx = 0; idx < len; idx++) -+ key_x[idx] = key_y[idx] ^ mask[idx]; -+} -+ -+static void tcam_key_calculate(struct tag_tcam_key *tcam_key, -+ struct tag_tcam_cfg_rule *fdir_tcam_rule) -+{ -+ tcam_translate_key_y(fdir_tcam_rule->key.y, -+ (u8 *)(&tcam_key->key_info), -+ (u8 *)(&tcam_key->key_mask), -+ TCAM_FLOW_KEY_SIZE); -+ tcam_translate_key_x(fdir_tcam_rule->key.x, -+ fdir_tcam_rule->key.y, -+ (u8 *)(&tcam_key->key_mask), -+ TCAM_FLOW_KEY_SIZE); -+} -+ -+static int hinic_fdir_tcam_info_init(struct rte_eth_dev *dev, -+ struct hinic_fdir_rule *rule, -+ struct tag_tcam_key *tcam_key, -+ struct tag_tcam_cfg_rule *fdir_tcam_rule) -+{ -+ struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); -+ -+ switch (rule->mask.dst_ipv4_mask) { -+ case UINT32_MAX: -+ tcam_key->key_info.ext_dip_h = -+ (rule->hinic_fdir.dst_ip >> 16) & 0xffffU; -+ tcam_key->key_info.ext_dip_l = -+ rule->hinic_fdir.dst_ip & 0xffffU; -+ tcam_key->key_mask.ext_dip_h = -+ (rule->mask.dst_ipv4_mask >> 16) & 0xffffU; -+ tcam_key->key_mask.ext_dip_l = -+ rule->mask.dst_ipv4_mask & 0xffffU; -+ break; -+ -+ case 0: -+ break; -+ -+ default: -+ PMD_DRV_LOG(ERR, "invalid src_ip mask."); -+ return -EINVAL; -+ } -+ -+ if (rule->mask.dst_port_mask > 0) { -+ tcam_key->key_info.dst_port = rule->hinic_fdir.dst_port; -+ tcam_key->key_mask.dst_port = rule->mask.dst_port_mask; -+ } -+ -+ if (rule->mask.src_port_mask > 0) { -+ tcam_key->key_info.src_port = rule->hinic_fdir.src_port; -+ tcam_key->key_mask.src_port = rule->mask.src_port_mask; -+ } -+ -+ switch (rule->mask.tunnel_flag) { -+ case UINT16_MAX: -+ tcam_key->key_info.tunnel_flag = FDIR_TCAM_TUNNEL_PACKET; -+ tcam_key->key_mask.tunnel_flag = UINT8_MAX; -+ break; -+ -+ case 0: -+ tcam_key->key_info.tunnel_flag = FDIR_TCAM_NORMAL_PACKET; -+ tcam_key->key_mask.tunnel_flag = 0; -+ break; -+ -+ default: -+ PMD_DRV_LOG(ERR, "invalid tunnel flag mask."); -+ return -EINVAL; -+ } -+ -+ if (rule->mask.tunnel_inner_dst_port_mask > 0) { -+ tcam_key->key_info.dst_port = -+ rule->hinic_fdir.tunnel_inner_dst_port; -+ tcam_key->key_mask.dst_port = -+ rule->mask.tunnel_inner_dst_port_mask; -+ } -+ -+ if (rule->mask.tunnel_inner_src_port_mask > 0) { -+ tcam_key->key_info.src_port = -+ rule->hinic_fdir.tunnel_inner_src_port; -+ tcam_key->key_mask.src_port = -+ rule->mask.tunnel_inner_src_port_mask; -+ } -+ -+ switch (rule->mask.proto_mask) { -+ case UINT16_MAX: -+ tcam_key->key_info.protocol = rule->hinic_fdir.proto; -+ tcam_key->key_mask.protocol = UINT8_MAX; -+ break; -+ -+ case 0: -+ break; -+ -+ default: -+ PMD_DRV_LOG(ERR, "invalid tunnel flag mask."); -+ return -EINVAL; -+ } -+ -+ tcam_key->key_mask.function_id = UINT16_MAX; -+ -+ tcam_key->key_info.function_id = hinic_global_func_id(nic_dev->hwdev); -+ -+ fdir_tcam_rule->data.qid = rule->queue; -+ -+ tcam_key_calculate(tcam_key, fdir_tcam_rule); -+ -+ return 0; -+} -+ -+static inline struct hinic_tcam_filter * -+hinic_tcam_filter_lookup(struct hinic_tcam_filter_list *filter_list, -+ struct tag_tcam_key *key) -+{ -+ struct hinic_tcam_filter *it; -+ -+ TAILQ_FOREACH(it, filter_list, entries) { -+ if (memcmp(key, &it->tcam_key, -+ sizeof(struct tag_tcam_key)) == 0) { -+ return it; -+ } -+ } -+ -+ return NULL; -+} -+ -+static int hinic_lookup_new_tcam_filter(struct rte_eth_dev *dev, -+ struct hinic_tcam_info *tcam_info, -+ struct hinic_tcam_filter *tcam_filter, -+ u16 *tcam_index) -+{ -+ int index; -+ int max_index; -+ struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); -+ -+ if (hinic_func_type(nic_dev->hwdev) == TYPE_VF) -+ max_index = HINIC_VF_MAX_TCAM_FILTERS; -+ else -+ max_index = HINIC_PF_MAX_TCAM_FILTERS; -+ -+ for (index = 0; index < max_index; index++) { -+ if (tcam_info->tcam_index_array[index] == 0) -+ break; -+ } -+ -+ if (index == max_index) { -+ PMD_DRV_LOG(ERR, "function 0x%x tcam filters only support %d filter rules", -+ hinic_global_func_id(nic_dev->hwdev), max_index); -+ return -EINVAL; -+ } -+ -+ tcam_filter->index = index; -+ *tcam_index = index; -+ -+ return 0; -+} -+ -+static int hinic_add_tcam_filter(struct rte_eth_dev *dev, -+ struct hinic_tcam_filter *tcam_filter, -+ struct tag_tcam_cfg_rule *fdir_tcam_rule) -+{ -+ struct hinic_tcam_info *tcam_info = -+ HINIC_DEV_PRIVATE_TO_TCAM_INFO(dev->data->dev_private); -+ struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); -+ u16 index = 0; -+ u16 tcam_block_index = 0; -+ int rc; -+ -+ if (hinic_lookup_new_tcam_filter(dev, tcam_info, tcam_filter, &index)) -+ return -EINVAL; -+ -+ if (tcam_info->tcam_rule_nums == 0) { -+ if (hinic_func_type(nic_dev->hwdev) == TYPE_VF) { -+ rc = hinic_alloc_tcam_block(nic_dev->hwdev, -+ HINIC_TCAM_BLOCK_TYPE_VF, &tcam_block_index); -+ if (rc != 0) { -+ PMD_DRV_LOG(ERR, "VF fdir filter tcam alloc block failed!"); -+ return -EFAULT; -+ } -+ } else { -+ rc = hinic_alloc_tcam_block(nic_dev->hwdev, -+ HINIC_TCAM_BLOCK_TYPE_PF, &tcam_block_index); -+ if (rc != 0) { -+ PMD_DRV_LOG(ERR, "PF fdir filter tcam alloc block failed!"); -+ return -EFAULT; -+ } -+ } -+ -+ tcam_info->tcam_block_index = tcam_block_index; -+ } else { -+ tcam_block_index = tcam_info->tcam_block_index; -+ } -+ -+ if (hinic_func_type(nic_dev->hwdev) == TYPE_VF) { -+ fdir_tcam_rule->index = -+ HINIC_PKT_VF_TCAM_INDEX_START(tcam_block_index) + index; -+ } else { -+ fdir_tcam_rule->index = -+ tcam_block_index * HINIC_PF_MAX_TCAM_FILTERS + index; -+ } -+ -+ rc = hinic_add_tcam_rule(nic_dev->hwdev, fdir_tcam_rule); -+ if (rc != 0) { -+ PMD_DRV_LOG(ERR, "Fdir_tcam_rule add failed!"); -+ return -EFAULT; -+ } -+ -+ PMD_DRV_LOG(INFO, "Add fdir_tcam_rule function_id: 0x%x," -+ "tcam_block_id: %d, index: %d, queue: %d, tcam_rule_nums: %d succeed", -+ hinic_global_func_id(nic_dev->hwdev), tcam_block_index, -+ fdir_tcam_rule->index, fdir_tcam_rule->data.qid, -+ tcam_info->tcam_rule_nums + 1); -+ -+ if (tcam_info->tcam_rule_nums == 0) { -+ rc = hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, true); -+ if (rc < 0) { -+ (void)hinic_del_tcam_rule(nic_dev->hwdev, -+ fdir_tcam_rule->index); -+ return rc; -+ } -+ } -+ -+ TAILQ_INSERT_TAIL(&tcam_info->tcam_list, tcam_filter, entries); -+ -+ tcam_info->tcam_index_array[index] = 1; -+ tcam_info->tcam_rule_nums++; -+ -+ return 0; -+} -+ -+static int hinic_del_tcam_filter(struct rte_eth_dev *dev, -+ struct hinic_tcam_filter *tcam_filter) -+{ -+ struct hinic_tcam_info *tcam_info = -+ HINIC_DEV_PRIVATE_TO_TCAM_INFO(dev->data->dev_private); -+ struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); -+ u32 index = 0; -+ u16 tcam_block_index = tcam_info->tcam_block_index; -+ int rc; -+ u8 block_type = 0; -+ -+ if (hinic_func_type(nic_dev->hwdev) == TYPE_VF) { -+ index = HINIC_PKT_VF_TCAM_INDEX_START(tcam_block_index) + -+ tcam_filter->index; -+ block_type = HINIC_TCAM_BLOCK_TYPE_VF; -+ } else { -+ index = tcam_block_index * HINIC_PF_MAX_TCAM_FILTERS + -+ tcam_filter->index; -+ block_type = HINIC_TCAM_BLOCK_TYPE_PF; -+ } -+ -+ rc = hinic_del_tcam_rule(nic_dev->hwdev, index); -+ if (rc != 0) { -+ PMD_DRV_LOG(ERR, "fdir_tcam_rule del failed!"); -+ return -EFAULT; -+ } -+ -+ PMD_DRV_LOG(INFO, "Del fdir_tcam_rule function_id: 0x%x, " -+ "tcam_block_id: %d, index: %d, tcam_rule_nums: %d succeed", -+ hinic_global_func_id(nic_dev->hwdev), tcam_block_index, index, -+ tcam_info->tcam_rule_nums - 1); -+ -+ TAILQ_REMOVE(&tcam_info->tcam_list, tcam_filter, entries); -+ -+ tcam_info->tcam_index_array[tcam_filter->index] = 0; -+ -+ rte_free(tcam_filter); -+ -+ tcam_info->tcam_rule_nums--; -+ -+ if (tcam_info->tcam_rule_nums == 0) { -+ (void)hinic_free_tcam_block(nic_dev->hwdev, block_type, -+ &tcam_block_index); -+ } -+ -+ return 0; -+} -+ -+static int hinic_add_del_tcam_fdir_filter(struct rte_eth_dev *dev, -+ struct hinic_fdir_rule *rule, bool add) -+{ -+ struct hinic_tcam_info *tcam_info = -+ HINIC_DEV_PRIVATE_TO_TCAM_INFO(dev->data->dev_private); -+ struct hinic_tcam_filter *tcam_filter; -+ struct tag_tcam_cfg_rule fdir_tcam_rule; -+ struct tag_tcam_key tcam_key; -+ int ret; -+ -+ memset(&fdir_tcam_rule, 0, sizeof(struct tag_tcam_cfg_rule)); -+ memset((void *)&tcam_key, 0, sizeof(struct tag_tcam_key)); -+ -+ ret = hinic_fdir_tcam_info_init(dev, rule, &tcam_key, &fdir_tcam_rule); -+ if (ret) { -+ PMD_DRV_LOG(ERR, "Init hiovs fdir info failed!"); -+ return ret; -+ } -+ -+ tcam_filter = hinic_tcam_filter_lookup(&tcam_info->tcam_list, -+ &tcam_key); -+ if (tcam_filter != NULL && add) { -+ PMD_DRV_LOG(ERR, "Filter exists."); -+ return -EEXIST; -+ } -+ if (tcam_filter == NULL && !add) { -+ PMD_DRV_LOG(ERR, "Filter doesn't exist."); -+ return -ENOENT; -+ } -+ -+ if (add) { -+ tcam_filter = rte_zmalloc("hiovs_5tuple_filter", -+ sizeof(struct hinic_tcam_filter), 0); -+ if (tcam_filter == NULL) -+ return -ENOMEM; -+ (void)rte_memcpy(&tcam_filter->tcam_key, -+ &tcam_key, sizeof(struct tag_tcam_key)); -+ tcam_filter->queue = fdir_tcam_rule.data.qid; -+ -+ ret = hinic_add_tcam_filter(dev, tcam_filter, &fdir_tcam_rule); -+ if (ret < 0) { -+ rte_free(tcam_filter); -+ return ret; -+ } -+ -+ rule->tcam_index = fdir_tcam_rule.index; -+ -+ } else { -+ PMD_DRV_LOG(ERR, "Begin to hiovs_del_tcam_filter"); -+ ret = hinic_del_tcam_filter(dev, tcam_filter); -+ if (ret < 0) -+ return ret; -+ } -+ -+ return 0; -+} -+ - /** - * Create or destroy a flow rule. - * Theorically one rule can match more than one filters. -@@ -2158,7 +2834,16 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - ret = hinic_parse_fdir_filter(dev, attr, pattern, - actions, &fdir_rule, error); - if (!ret) { -- ret = hinic_add_del_fdir_filter(dev, &fdir_rule, TRUE); -+ if (fdir_rule.mode == HINIC_FDIR_MODE_NORMAL) { -+ ret = hinic_add_del_fdir_filter(dev, -+ &fdir_rule, TRUE); -+ } else if (fdir_rule.mode == HINIC_FDIR_MODE_TCAM) { -+ ret = hinic_add_del_tcam_fdir_filter(dev, -+ &fdir_rule, TRUE); -+ } else { -+ PMD_DRV_LOG(INFO, "flow fdir rule create failed, rule mode wrong"); -+ goto out; -+ } - if (!ret) { - fdir_rule_ptr = rte_zmalloc("hinic_fdir_rule", - sizeof(struct hinic_fdir_rule_ele), 0); -@@ -2187,9 +2872,8 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - } - - /* Destroy a flow rule on hinic. */ --static int hinic_flow_destroy(struct rte_eth_dev *dev, -- struct rte_flow *flow, -- struct rte_flow_error *error) -+static int hinic_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, -+ struct rte_flow_error *error) - { - int ret; - struct rte_flow *pmd_flow = flow; -@@ -2235,7 +2919,15 @@ static int hinic_flow_destroy(struct rte_eth_dev *dev, - rte_memcpy(&fdir_rule, - &fdir_rule_ptr->filter_info, - sizeof(struct hinic_fdir_rule)); -- ret = hinic_add_del_fdir_filter(dev, &fdir_rule, FALSE); -+ if (fdir_rule.mode == HINIC_FDIR_MODE_NORMAL) { -+ ret = hinic_add_del_fdir_filter(dev, &fdir_rule, FALSE); -+ } else if (fdir_rule.mode == HINIC_FDIR_MODE_TCAM) { -+ ret = hinic_add_del_tcam_fdir_filter(dev, &fdir_rule, -+ FALSE); -+ } else { -+ PMD_DRV_LOG(ERR, "FDIR Filter type is wrong!"); -+ ret = -EINVAL; -+ } - if (!ret) { - TAILQ_REMOVE(&nic_dev->filter_fdir_rule_list, - fdir_rule_ptr, entries); -@@ -2318,8 +3010,16 @@ static void hinic_clear_all_ethertype_filter(struct rte_eth_dev *dev) - static void hinic_clear_all_fdir_filter(struct rte_eth_dev *dev) - { - struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); -+ struct hinic_tcam_info *tcam_info = -+ HINIC_DEV_PRIVATE_TO_TCAM_INFO(dev->data->dev_private); -+ struct hinic_tcam_filter *tcam_filter_ptr; -+ -+ while ((tcam_filter_ptr = TAILQ_FIRST(&tcam_info->tcam_list))) -+ (void)hinic_del_tcam_filter(dev, tcam_filter_ptr); - - (void)hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, false); -+ -+ (void)hinic_flush_tcam_rule(nic_dev->hwdev); - } - - static void hinic_filterlist_flush(struct rte_eth_dev *dev) -@@ -2377,9 +3077,18 @@ static int hinic_flow_flush(struct rte_eth_dev *dev, - return 0; - } - -+void hinic_destroy_fdir_filter(struct rte_eth_dev *dev) -+{ -+ hinic_clear_all_ntuple_filter(dev); -+ hinic_clear_all_ethertype_filter(dev); -+ hinic_clear_all_fdir_filter(dev); -+ hinic_filterlist_flush(dev); -+} -+ - const struct rte_flow_ops hinic_flow_ops = { - .validate = hinic_flow_validate, - .create = hinic_flow_create, - .destroy = hinic_flow_destroy, - .flush = hinic_flow_flush, - }; -+ --- -2.23.0 - diff --git a/backport-0001-net-softnic-fix-memory-leak-as-profile-is-freed.patch b/backport-0001-net-softnic-fix-memory-leak-as-profile-is-freed.patch deleted file mode 100644 index 4166c88..0000000 --- a/backport-0001-net-softnic-fix-memory-leak-as-profile-is-freed.patch +++ /dev/null @@ -1,37 +0,0 @@ -From b3bc560bd6bdf3c9851d25bc0a66cb24aa1fd48c Mon Sep 17 00:00:00 2001 -From: Dapeng Yu -Date: Wed, 28 Jul 2021 14:05:39 +0800 -Subject: [PATCH] net/softnic: fix memory leak as profile is freed - -In function softnic_table_action_profile_free(), the memory referenced -by pointer "ap" in the instance of "struct softnic_table_action_profile" -is not freed. - -This patch fixes it. - -Fixes: a737dd4e5863 ("net/softnic: add table action profile") -Cc: stable@dpdk.org - -Signed-off-by: Dapeng Yu -Acked-by: Jasvinder Singh -Conflict: NA -Reference: https://github.com/DPDK/dpdk/commit/b3bc560bd6bdf3c9851d25bc0a66cb24aa1fd48c ---- - drivers/net/softnic/rte_eth_softnic_action.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/net/softnic/rte_eth_softnic_action.c b/drivers/net/softnic/rte_eth_softnic_action.c -index 92c744dc9a..33be9552a6 100644 ---- a/drivers/net/softnic/rte_eth_softnic_action.c -+++ b/drivers/net/softnic/rte_eth_softnic_action.c -@@ -183,6 +183,7 @@ softnic_table_action_profile_free(struct pmd_internals *p) - break; - - TAILQ_REMOVE(&p->table_action_profile_list, profile, node); -+ rte_table_action_profile_free(profile->ap); - free(profile); - } - } --- -2.23.0 - diff --git a/backport-0002-CVE-2022-2131.patch b/backport-0002-CVE-2022-2131.patch deleted file mode 100644 index 3429210..0000000 --- a/backport-0002-CVE-2022-2131.patch +++ /dev/null @@ -1,105 +0,0 @@ -From e73049ea26a588518bde750f46ac700462a598ed Mon Sep 17 00:00:00 2001 -From: Maxime Coquelin -Date: Thu, 16 Jun 2022 14:25:07 +0200 -Subject: [PATCH] vhost: fix header spanned across more than two descriptors - -This patch aims at supporting the unlikely case where a -Virtio-net header is spanned across more than two -descriptors. - -CVE-2022-2132 -Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path") -Cc: stable@dpdk.org - -Signed-off-by: Maxime Coquelin -Conflict: NA -Reference: https://git.dpdk.org/dpdk-stable/commit/?id=e73049ea26 ---- - lib/librte_vhost/virtio_net.c | 45 +++++++++++------------------------ - 1 file changed, 14 insertions(+), 31 deletions(-) - -diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c -index 1fcbc1aca9..af735f9c2b 100644 ---- a/lib/librte_vhost/virtio_net.c -+++ b/lib/librte_vhost/virtio_net.c -@@ -1399,26 +1399,22 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, - uint32_t buf_avail, buf_offset; - uint64_t buf_addr, buf_iova, buf_len; - uint32_t mbuf_avail, mbuf_offset; -+ uint32_t hdr_remain = dev->vhost_hlen; - uint32_t cpy_len; - struct rte_mbuf *cur = m, *prev = m; - struct virtio_net_hdr tmp_hdr; - struct virtio_net_hdr *hdr = NULL; -- /* A counter to avoid desc dead loop chain */ -- uint16_t vec_idx = 0; -+ uint16_t vec_idx; - struct batch_copy_elem *batch_copy = vq->batch_copy_elems; - int error = 0; - -- buf_addr = buf_vec[vec_idx].buf_addr; -- buf_iova = buf_vec[vec_idx].buf_iova; -- buf_len = buf_vec[vec_idx].buf_len; -- - /* - * The caller has checked the descriptors chain is larger than the - * header size. - */ - - if (virtio_net_with_host_offload(dev)) { -- if (unlikely(buf_len < sizeof(struct virtio_net_hdr))) { -+ if (unlikely(buf_vec[0].buf_len < sizeof(struct virtio_net_hdr))) { - /* - * No luck, the virtio-net header doesn't fit - * in a contiguous virtual area. -@@ -1426,36 +1422,23 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, - copy_vnet_hdr_from_desc(&tmp_hdr, buf_vec); - hdr = &tmp_hdr; - } else { -- hdr = (struct virtio_net_hdr *)((uintptr_t)buf_addr); -+ hdr = (struct virtio_net_hdr *)((uintptr_t)buf_vec[0].buf_addr); - } - } - -- /* -- * A virtio driver normally uses at least 2 desc buffers -- * for Tx: the first for storing the header, and others -- * for storing the data. -- */ -- if (unlikely(buf_len < dev->vhost_hlen)) { -- buf_offset = dev->vhost_hlen - buf_len; -- vec_idx++; -- buf_addr = buf_vec[vec_idx].buf_addr; -- buf_iova = buf_vec[vec_idx].buf_iova; -- buf_len = buf_vec[vec_idx].buf_len; -- buf_avail = buf_len - buf_offset; -- } else if (buf_len == dev->vhost_hlen) { -- if (unlikely(++vec_idx >= nr_vec)) -- goto out; -- buf_addr = buf_vec[vec_idx].buf_addr; -- buf_iova = buf_vec[vec_idx].buf_iova; -- buf_len = buf_vec[vec_idx].buf_len; -+ for (vec_idx = 0; vec_idx < nr_vec; vec_idx++) { -+ if (buf_vec[vec_idx].buf_len > hdr_remain) -+ break; - -- buf_offset = 0; -- buf_avail = buf_len; -- } else { -- buf_offset = dev->vhost_hlen; -- buf_avail = buf_vec[vec_idx].buf_len - dev->vhost_hlen; -+ hdr_remain -= buf_vec[vec_idx].buf_len; - } - -+ buf_addr = buf_vec[vec_idx].buf_addr; -+ buf_iova = buf_vec[vec_idx].buf_iova; -+ buf_len = buf_vec[vec_idx].buf_len; -+ buf_offset = hdr_remain; -+ buf_avail = buf_vec[vec_idx].buf_len - hdr_remain; -+ - PRINT_PACKET(dev, - (uintptr_t)(buf_addr + buf_offset), - (uint32_t)buf_avail, 0); --- -2.23.0 - diff --git a/backport-0002-CVE-2022-2132.patch b/backport-0002-CVE-2022-2132.patch new file mode 100644 index 0000000..a9a83c6 --- /dev/null +++ b/backport-0002-CVE-2022-2132.patch @@ -0,0 +1,79 @@ +From f167022606b5ccca27a627ae599538ce2348ef67 Mon Sep 17 00:00:00 2001 +From: Maxime Coquelin +Date: Thu, 16 Jun 2022 11:35:56 +0200 +Subject: [PATCH] vhost: discard too small descriptor chains + +[ upstream commit 71bd0cc536ad6d84188d947d6f24c17400d8f623 ] + +This patch discards descriptor chains which are smaller +than the Virtio-net header size, and ones that are equal. + +Indeed, such descriptor chains sizes mean there is no +packet data. + +This patch also has the advantage of requesting the exact +packets sizes for the mbufs. + +CVE-2022-2132 +Fixes: 62250c1d0978 ("vhost: extract split ring handling from Rx and Tx functions") +Fixes: c3ff0ac70acb ("vhost: improve performance by supporting large buffer") +Fixes: 84d5204310d7 ("vhost: support async dequeue for split ring") + +Signed-off-by: Maxime Coquelin +Acked-by: Chenbo Xia +Reviewed-by: David Marchand +Conflict: NA +Reference: https://git.dpdk.org/dpdk-stable/commit/?id=f16702260 +--- + lib/vhost/virtio_net.c | 21 +++++++++++++++++---- + 1 file changed, 17 insertions(+), 4 deletions(-) + +diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c +index 858187d1b0..991a7a2bd4 100644 +--- a/lib/vhost/virtio_net.c ++++ b/lib/vhost/virtio_net.c +@@ -2334,10 +2334,10 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, + struct batch_copy_elem *batch_copy = vq->batch_copy_elems; + int error = 0; + +- if (unlikely(buf_len < dev->vhost_hlen && nr_vec <= 1)) { +- error = -1; +- goto out; +- } ++ /* ++ * The caller has checked the descriptors chain is larger than the ++ * header size. ++ */ + + if (virtio_net_with_host_offload(dev)) { + if (unlikely(buf_vec[0].buf_len < sizeof(struct virtio_net_hdr))) { +@@ -2568,6 +2568,14 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, + + update_shadow_used_ring_split(vq, head_idx, 0); + ++ if (unlikely(buf_len <= dev->vhost_hlen)) { ++ dropped += 1; ++ i++; ++ break; ++ } ++ ++ buf_len -= dev->vhost_hlen; ++ + err = virtio_dev_pktmbuf_prep(dev, pkts[i], buf_len); + if (unlikely(err)) { + /* +@@ -2771,6 +2779,11 @@ vhost_dequeue_single_packed(struct virtio_net *dev, + VHOST_ACCESS_RO) < 0)) + return -1; + ++ if (unlikely(buf_len <= dev->vhost_hlen)) ++ return -1; ++ ++ buf_len -= dev->vhost_hlen; ++ + if (unlikely(virtio_dev_pktmbuf_prep(dev, pkts, buf_len))) { + if (!allocerr_warned) { + VHOST_LOG_DATA(ERR, +-- +2.23.0 + diff --git a/backport-0002-net-hinic-add-TCAM-filter-switch-for-flow-director.patch b/backport-0002-net-hinic-add-TCAM-filter-switch-for-flow-director.patch deleted file mode 100644 index 7bb8fcb..0000000 --- a/backport-0002-net-hinic-add-TCAM-filter-switch-for-flow-director.patch +++ /dev/null @@ -1,150 +0,0 @@ -From 0023e525a52cd5c9463332c5f5b9e95a4c07d938 Mon Sep 17 00:00:00 2001 -From: Xiaoyun Wang -Date: Sat, 27 Jun 2020 11:55:47 +0800 -Subject: [PATCH] net/hinic: add TCAM filter switch for flow director - -When the filter rule needs to use the TCAM method, driver -enables the TCAM filter switch, otherwise disables it, which -can improve the performance of microcode in FDIR scenarios that -does not use TCAM method. - -Fixes: 1fe89aa37f36 ("net/hinic: add flow director filter") -Cc: stable@dpdk.org - -Signed-off-by: Xiaoyun Wang ---- - drivers/net/hinic/base/hinic_pmd_cmd.h | 1 + - drivers/net/hinic/base/hinic_pmd_niccfg.c | 41 +++++++++++++++++++++++ - drivers/net/hinic/base/hinic_pmd_niccfg.h | 11 ++++++ - drivers/net/hinic/hinic_pmd_flow.c | 13 +++++++ - 4 files changed, 66 insertions(+) - -diff --git a/drivers/net/hinic/base/hinic_pmd_cmd.h b/drivers/net/hinic/base/hinic_pmd_cmd.h -index 09918a76fa..9ecb712334 100644 ---- a/drivers/net/hinic/base/hinic_pmd_cmd.h -+++ b/drivers/net/hinic/base/hinic_pmd_cmd.h -@@ -120,6 +120,7 @@ enum hinic_port_cmd { - HINIC_PORT_CMD_UP_TC_GET_FLOW = 0xb1, - HINIC_PORT_CMD_UP_TC_FLUSH_TCAM = 0xb2, - HINIC_PORT_CMD_UP_TC_CTRL_TCAM_BLOCK = 0xb3, -+ HINIC_PORT_CMD_UP_TC_ENABLE = 0xb4, - - HINIC_PORT_CMD_SET_IPSU_MAC = 0xcb, - HINIC_PORT_CMD_GET_IPSU_MAC = 0xcc, -diff --git a/drivers/net/hinic/base/hinic_pmd_niccfg.c b/drivers/net/hinic/base/hinic_pmd_niccfg.c -index e894503d73..67f6bc4070 100644 ---- a/drivers/net/hinic/base/hinic_pmd_niccfg.c -+++ b/drivers/net/hinic/base/hinic_pmd_niccfg.c -@@ -2114,3 +2114,44 @@ int hinic_flush_tcam_rule(void *hwdev) - return err; - } - -+int hinic_set_fdir_tcam_rule_filter(void *hwdev, bool enable) -+{ -+ struct hinic_port_tcam_info port_tcam_cmd; -+ u16 out_size = sizeof(port_tcam_cmd); -+ int err; -+ -+ if (!hwdev) -+ return -EINVAL; -+ -+ memset(&port_tcam_cmd, 0, sizeof(port_tcam_cmd)); -+ port_tcam_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; -+ port_tcam_cmd.func_id = hinic_global_func_id(hwdev); -+ port_tcam_cmd.tcam_enable = (u8)enable; -+ -+ err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_UP_TC_ENABLE, -+ &port_tcam_cmd, sizeof(port_tcam_cmd), -+ &port_tcam_cmd, &out_size); -+ if ((port_tcam_cmd.mgmt_msg_head.status != HINIC_MGMT_CMD_UNSUPPORTED && -+ port_tcam_cmd.mgmt_msg_head.status) || err || !out_size) { -+ if (err == HINIC_MBOX_VF_CMD_ERROR && -+ HINIC_IS_VF((struct hinic_hwdev *)hwdev)) { -+ err = HINIC_MGMT_CMD_UNSUPPORTED; -+ PMD_DRV_LOG(WARNING, "VF doesn't support setting fdir tcam filter"); -+ return err; -+ } -+ PMD_DRV_LOG(ERR, "Set fdir tcam filter failed, err: %d, " -+ "status: 0x%x, out size: 0x%x, enable: 0x%x", -+ err, port_tcam_cmd.mgmt_msg_head.status, out_size, -+ enable); -+ return -EFAULT; -+ } -+ -+ if (port_tcam_cmd.mgmt_msg_head.status == HINIC_MGMT_CMD_UNSUPPORTED) { -+ err = HINIC_MGMT_CMD_UNSUPPORTED; -+ PMD_DRV_LOG(WARNING, "Fw doesn't support setting fdir tcam filter"); -+ } -+ -+ return err; -+} -+ -+ -diff --git a/drivers/net/hinic/base/hinic_pmd_niccfg.h b/drivers/net/hinic/base/hinic_pmd_niccfg.h -index 846b5973ec..73b16b4d69 100644 ---- a/drivers/net/hinic/base/hinic_pmd_niccfg.h -+++ b/drivers/net/hinic/base/hinic_pmd_niccfg.h -@@ -766,6 +766,15 @@ struct hinic_port_qfilter_info { - u32 key; - }; - -+struct hinic_port_tcam_info { -+ struct hinic_mgmt_msg_head mgmt_msg_head; -+ -+ u16 func_id; -+ u8 tcam_enable; -+ u8 rsvd1; -+ u32 rsvd2; -+}; -+ - #define HINIC_MAX_TCAM_RULES_NUM (10240) - #define HINIC_TCAM_BLOCK_ENABLE 1 - #define HINIC_TCAM_BLOCK_DISABLE 0 -@@ -941,4 +950,6 @@ int hinic_free_tcam_block(void *hwdev, u8 block_type, u16 *index); - - int hinic_flush_tcam_rule(void *hwdev); - -+int hinic_set_fdir_tcam_rule_filter(void *hwdev, bool enable); -+ - #endif /* _HINIC_PMD_NICCFG_H_ */ -diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c -index cc0744da2d..a7bad570bb 100644 ---- a/drivers/net/hinic/hinic_pmd_flow.c -+++ b/drivers/net/hinic/hinic_pmd_flow.c -@@ -1900,6 +1900,8 @@ void hinic_free_fdir_filter(struct hinic_nic_dev *nic_dev) - { - (void)hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, false); - -+ (void)hinic_set_fdir_tcam_rule_filter(nic_dev->hwdev, false); -+ - (void)hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_BGP_DPORT); - - (void)hinic_clear_fdir_tcam(nic_dev->hwdev, TCAM_PKT_BGP_SPORT); -@@ -2801,6 +2803,15 @@ static int hinic_add_tcam_filter(struct rte_eth_dev *dev, - fdir_tcam_rule->index); - return rc; - } -+ -+ rc = hinic_set_fdir_tcam_rule_filter(nic_dev->hwdev, true); -+ if (rc && rc != HINIC_MGMT_CMD_UNSUPPORTED) { -+ (void)hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, -+ false); -+ (void)hinic_del_tcam_rule(nic_dev->hwdev, -+ fdir_tcam_rule->index); -+ return rc; -+ } - } - - TAILQ_INSERT_TAIL(&tcam_info->tcam_list, tcam_filter, entries); -@@ -3197,6 +3208,8 @@ static void hinic_clear_all_fdir_filter(struct rte_eth_dev *dev) - - (void)hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, false); - -+ (void)hinic_set_fdir_tcam_rule_filter(nic_dev->hwdev, false); -+ - (void)hinic_flush_tcam_rule(nic_dev->hwdev); - } - --- -2.23.0 - diff --git a/backport-0002-net-virtio-fix-interrupt-handle-leak.patch b/backport-0002-net-virtio-fix-interrupt-handle-leak.patch deleted file mode 100644 index 0085929..0000000 --- a/backport-0002-net-virtio-fix-interrupt-handle-leak.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 7b9195154926b808e3ae23750eaff3e81cd5f529 Mon Sep 17 00:00:00 2001 -From: Gaoxiang Liu -Date: Mon, 26 Jul 2021 22:42:05 +0800 -Subject: [PATCH] net/virtio: fix interrupt handle leak - -Free memory of interrupt handle in virtio_user_dev_uninit() to -avoid memory leak. -when virtio user dev closes, memory of interrupt handle is not freed -that is allocated in virtio_user_fill_intr_handle(). - -Fixes: 3d4fb6fd2505 ("net/virtio-user: support Rx interrupt") -Cc: stable@dpdk.org - -Signed-off-by: Gaoxiang Liu -Reviewed-by: Chenbo Xia -Reviewed-by: Maxime Coquelin -Conflict: dev->hw.port_id to dev->port_id -Reference: https://github.com/DPDK/dpdk/commit/7b9195154926b808e3ae23750eaff3e81cd5f529 ---- - drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c -index ea016e8..6b91806 100644 ---- a/drivers/net/virtio/virtio_user/virtio_user_dev.c -+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c -@@ -528,6 +528,13 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev) - { - uint32_t i; - -+ struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id]; -+ -+ if (eth_dev->intr_handle) { -+ free(eth_dev->intr_handle); -+ eth_dev->intr_handle = NULL; -+ } -+ - virtio_user_stop_device(dev); - - rte_mem_event_callback_unregister(VIRTIO_USER_MEM_EVENT_CLB_NAME, dev); --- -2.23.0 - diff --git a/backport-0003-net-hinic-check-memory-allocations-in-flow-creation.patch b/backport-0003-net-hinic-check-memory-allocations-in-flow-creation.patch deleted file mode 100644 index 700902d..0000000 --- a/backport-0003-net-hinic-check-memory-allocations-in-flow-creation.patch +++ /dev/null @@ -1,57 +0,0 @@ -From d7964ce192e79507d3b32b4a02e6293a40eb4708 Mon Sep 17 00:00:00 2001 -From: Yunjian Wang -Date: Tue, 28 Jul 2020 20:34:46 +0800 -Subject: [PATCH] net/hinic: check memory allocations in flow creation - -The function rte_zmalloc() could return NULL, the return -value need to be checked. - -Fixes: f4ca3fd54c4d ("net/hinic: create and destroy flow director filter") -Cc: stable@dpdk.org - -Signed-off-by: Yunjian Wang -Reviewed-by: Ferruh Yigit ---- - drivers/net/hinic/hinic_pmd_flow.c | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c -index a7bad570bb..503a32fff0 100644 ---- a/drivers/net/hinic/hinic_pmd_flow.c -+++ b/drivers/net/hinic/hinic_pmd_flow.c -@@ -2977,6 +2977,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - if (!ret) { - ntuple_filter_ptr = rte_zmalloc("hinic_ntuple_filter", - sizeof(struct hinic_ntuple_filter_ele), 0); -+ if (ntuple_filter_ptr == NULL) { -+ PMD_DRV_LOG(ERR, "Failed to allocate ntuple_filter_ptr"); -+ goto out; -+ } - rte_memcpy(&ntuple_filter_ptr->filter_info, - &ntuple_filter, - sizeof(struct rte_eth_ntuple_filter)); -@@ -3003,6 +3007,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - ethertype_filter_ptr = - rte_zmalloc("hinic_ethertype_filter", - sizeof(struct hinic_ethertype_filter_ele), 0); -+ if (ethertype_filter_ptr == NULL) { -+ PMD_DRV_LOG(ERR, "Failed to allocate ethertype_filter_ptr"); -+ goto out; -+ } - rte_memcpy(ðertype_filter_ptr->filter_info, - ðertype_filter, - sizeof(struct rte_eth_ethertype_filter)); -@@ -3036,6 +3044,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - if (!ret) { - fdir_rule_ptr = rte_zmalloc("hinic_fdir_rule", - sizeof(struct hinic_fdir_rule_ele), 0); -+ if (fdir_rule_ptr == NULL) { -+ PMD_DRV_LOG(ERR, "Failed to allocate fdir_rule_ptr"); -+ goto out; -+ } - rte_memcpy(&fdir_rule_ptr->filter_info, &fdir_rule, - sizeof(struct hinic_fdir_rule)); - TAILQ_INSERT_TAIL(&nic_dev->filter_fdir_rule_list, --- -2.23.0 - diff --git a/backport-0003-vhost-fix-crash-on-reconnect.patch b/backport-0003-vhost-fix-crash-on-reconnect.patch deleted file mode 100644 index 4ba93cd..0000000 --- a/backport-0003-vhost-fix-crash-on-reconnect.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 3c929a0bb3e7addc5103227bff126b8b9dd952ef Mon Sep 17 00:00:00 2001 -From: Maxime Coquelin -Date: Mon, 26 Jul 2021 09:58:14 +0200 -Subject: [PATCH] vhost: fix crash on reconnect - -When the vhost-user frontend like Virtio-user tries to -reconnect to the restarted Vhost backend, the Vhost backend -segfaults when multiqueue is enabled. - -This is caused by VHOST_USER_GET_VRING_BASE being called for -a virtqueue that has not been created before, causing a NULL -pointer dereferencing. - -This patch adds the VHOST_USER_GET_VRING_BASE requests to -the list of requests that trigger queue pair allocations. - -Fixes: 160cbc815b41 ("vhost: remove a hack on queue allocation") -Cc: stable@dpdk.org - -Reported-by: Yinan Wang -Signed-off-by: Maxime Coquelin -Tested-by: Yinan Wang -Reviewed-by: Chenbo Xia -Conflict: change vhost dir to librte_vhost -Reference: https://github.com/DPDK/dpdk/commit/3c929a0bb3e7addc5103227bff126b8b9dd952ef ---- - lib/librte_vhost/vhost_user.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c -index 433f412fa8..29a4c9af60 100644 ---- a/lib/librte_vhost/vhost_user.c -+++ b/lib/librte_vhost/vhost_user.c -@@ -2796,6 +2796,7 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, - break; - case VHOST_USER_SET_VRING_NUM: - case VHOST_USER_SET_VRING_BASE: -+ case VHOST_USER_GET_VRING_BASE: - case VHOST_USER_SET_VRING_ENABLE: - vring_idx = msg->payload.state.index; - break; --- -2.23.0 - diff --git a/backport-0004-net-hinic-fix-filters-on-memory-allocation-failure.patch b/backport-0004-net-hinic-fix-filters-on-memory-allocation-failure.patch deleted file mode 100644 index 74f005f..0000000 --- a/backport-0004-net-hinic-fix-filters-on-memory-allocation-failure.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 0c87a15f5f1ccb9eefb6231aea9d095686f2def4 Mon Sep 17 00:00:00 2001 -From: Xiaoyun Wang -Date: Mon, 14 Sep 2020 22:31:42 +0800 -Subject: [PATCH] net/hinic: fix filters on memory allocation failure - -If rte_zmalloc failed, pmd driver should also delete the ntuple -filter or ethertype filter or normal and tcam filter that already -added before. - -Fixes: d7964ce192e7 ("net/hinic: check memory allocations in flow creation") -Cc: stable@dpdk.org - -Signed-off-by: Xiaoyun Wang ---- - drivers/net/hinic/hinic_pmd_flow.c | 19 +++++++++++++++---- - 1 file changed, 15 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c -index 70fd4450c2..9888a8793b 100644 ---- a/drivers/net/hinic/hinic_pmd_flow.c -+++ b/drivers/net/hinic/hinic_pmd_flow.c -@@ -694,6 +694,7 @@ static int hinic_ntuple_item_check_end(const struct rte_flow_item *item, - item, "Not supported by ntuple filter"); - return -rte_errno; - } -+ - return 0; - } - -@@ -2981,6 +2982,8 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - sizeof(struct hinic_ntuple_filter_ele), 0); - if (ntuple_filter_ptr == NULL) { - PMD_DRV_LOG(ERR, "Failed to allocate ntuple_filter_ptr"); -+ (void)hinic_add_del_ntuple_filter(dev, -+ &ntuple_filter, FALSE); - goto out; - } - rte_memcpy(&ntuple_filter_ptr->filter_info, -@@ -3011,6 +3014,8 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - sizeof(struct hinic_ethertype_filter_ele), 0); - if (ethertype_filter_ptr == NULL) { - PMD_DRV_LOG(ERR, "Failed to allocate ethertype_filter_ptr"); -+ (void)hinic_add_del_ethertype_filter(dev, -+ ðertype_filter, FALSE); - goto out; - } - rte_memcpy(ðertype_filter_ptr->filter_info, -@@ -3034,11 +3039,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - actions, &fdir_rule, error); - if (!ret) { - if (fdir_rule.mode == HINIC_FDIR_MODE_NORMAL) { -- ret = hinic_add_del_fdir_filter(dev, -- &fdir_rule, TRUE); -+ ret = hinic_add_del_fdir_filter(dev, &fdir_rule, TRUE); - } else if (fdir_rule.mode == HINIC_FDIR_MODE_TCAM) { -- ret = hinic_add_del_tcam_fdir_filter(dev, -- &fdir_rule, TRUE); -+ ret = hinic_add_del_tcam_fdir_filter(dev, &fdir_rule, -+ TRUE); - } else { - PMD_DRV_LOG(INFO, "flow fdir rule create failed, rule mode wrong"); - goto out; -@@ -3048,6 +3052,13 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, - sizeof(struct hinic_fdir_rule_ele), 0); - if (fdir_rule_ptr == NULL) { - PMD_DRV_LOG(ERR, "Failed to allocate fdir_rule_ptr"); -+ if (fdir_rule.mode == HINIC_FDIR_MODE_NORMAL) -+ hinic_add_del_fdir_filter(dev, -+ &fdir_rule, FALSE); -+ else if (fdir_rule.mode == HINIC_FDIR_MODE_TCAM) -+ hinic_add_del_tcam_fdir_filter(dev, -+ &fdir_rule, FALSE); -+ - goto out; - } - rte_memcpy(&fdir_rule_ptr->filter_info, &fdir_rule, --- -2.23.0 - diff --git a/backport-0004-net-virtio-report-maximum-MTU-in-device-info.patch b/backport-0004-net-virtio-report-maximum-MTU-in-device-info.patch deleted file mode 100644 index a43e5aa..0000000 --- a/backport-0004-net-virtio-report-maximum-MTU-in-device-info.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 11d7bc9ff074dc5e37dd9ab51bb365669d08c3d6 Mon Sep 17 00:00:00 2001 -From: Ivan Ilchenko -Date: Wed, 21 Jul 2021 12:22:25 +0300 -Subject: [PATCH] net/virtio: report maximum MTU in device info - -Fix the driver to report maximum MTU obtained from config if -VIRTIO_NET_F_MTU is supported or calculated based on maximum -Rx packet length. - -Fixes: ad97ceece12c ("ethdev: add min/max MTU to device info") -Cc: stable@dpdk.org - -Signed-off-by: Ivan Ilchenko -Signed-off-by: Andrew Rybchenko -Reviewed-by: Maxime Coquelin -Conflict: NA -Reference: https://github.com/DPDK/dpdk/commit/11d7bc9ff074dc5e37dd9ab51bb365669d08c3d6 - ---- - drivers/net/virtio/virtio_ethdev.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c -index 044eb10..89e4c23 100644 ---- a/drivers/net/virtio/virtio_ethdev.c -+++ b/drivers/net/virtio/virtio_ethdev.c -@@ -2436,6 +2436,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) - dev_info->min_rx_bufsize = VIRTIO_MIN_RX_BUFSIZE; - dev_info->max_rx_pktlen = VIRTIO_MAX_RX_PKTLEN; - dev_info->max_mac_addrs = VIRTIO_MAX_MAC_ADDRS; -+ dev_info->max_mtu = hw->max_mtu; - - host_features = VTPCI_OPS(hw)->get_features(hw); - dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP; --- -2.23.0 - diff --git a/backport-0005-bus-dpaa-fix-freeing-in-FMAN-interface-destructor.patch b/backport-0005-bus-dpaa-fix-freeing-in-FMAN-interface-destructor.patch deleted file mode 100644 index 91b3b4c..0000000 --- a/backport-0005-bus-dpaa-fix-freeing-in-FMAN-interface-destructor.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 5ddcf3de6bc08fa7c14fd1ead86012aa575cf665 Mon Sep 17 00:00:00 2001 -From: Hemant Agrawal -Date: Mon, 19 Jul 2021 19:29:11 +0530 -Subject: [PATCH] bus/dpaa: fix freeing in FMAN interface destructor - -if was allocated with rte_malloc, free shall be equivalent. - -Fixes: 4762b3d419c3 ("bus/dpaa: delay fman device list to bus probe") -Cc: stable@dpdk.org - -Signed-off-by: Hemant Agrawal -Conflict: NA -Reference: https://github.com/DPDK/dpdk/commit/5ddcf3de6bc08fa7c14fd1ead86012aa575cf665 ---- - drivers/bus/dpaa/base/fman/fman.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c -index 692071b4b0..a14004d7fc 100644 ---- a/drivers/bus/dpaa/base/fman/fman.c -+++ b/drivers/bus/dpaa/base/fman/fman.c -@@ -50,7 +50,7 @@ if_destructor(struct __fman_if *__if) - free(bp); - } - cleanup: -- free(__if); -+ rte_free(__if); - } - - static int --- -2.23.0 - diff --git a/backport-0005-net-hinic-fix-TCAM-filter-set.patch b/backport-0005-net-hinic-fix-TCAM-filter-set.patch deleted file mode 100644 index d251652..0000000 --- a/backport-0005-net-hinic-fix-TCAM-filter-set.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 19cc028345f3c2318fad89db34eec276a0af4dd2 Mon Sep 17 00:00:00 2001 -From: Xiaoyun Wang -Date: Mon, 14 Sep 2020 22:31:43 +0800 -Subject: [PATCH] net/hinic: fix TCAM filter set - -hinic supports two methods: linear table and tcam table, -if tcam filter enables failed but linear table is ok, -which also needs to enable filter, so for this scene, -driver should not close fdir switch. - -Fixes: f4ca3fd54c4d ("net/hinic: create and destroy flow director filter") -Cc: stable@dpdk.org - -Signed-off-by: Xiaoyun Wang ---- - drivers/net/hinic/hinic_pmd_flow.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c -index 9888a8793b..d71a42afbd 100644 ---- a/drivers/net/hinic/hinic_pmd_flow.c -+++ b/drivers/net/hinic/hinic_pmd_flow.c -@@ -2809,8 +2809,12 @@ static int hinic_add_tcam_filter(struct rte_eth_dev *dev, - - rc = hinic_set_fdir_tcam_rule_filter(nic_dev->hwdev, true); - if (rc && rc != HINIC_MGMT_CMD_UNSUPPORTED) { -- (void)hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, -- false); -+ /* -+ * hinic supports two methods: linear table and tcam -+ * table, if tcam filter enables failed but linear table -+ * is ok, which also needs to enable filter, so for this -+ * scene, driver should not close fdir switch. -+ */ - (void)hinic_del_tcam_rule(nic_dev->hwdev, - fdir_tcam_rule->index); - return rc; --- -2.23.0 - diff --git a/backport-0006-distributor-fix-128-bit-write-alignment.patch b/backport-0006-distributor-fix-128-bit-write-alignment.patch deleted file mode 100644 index 4d6ec8b..0000000 --- a/backport-0006-distributor-fix-128-bit-write-alignment.patch +++ /dev/null @@ -1,38 +0,0 @@ -From de8606bf73323dfa8395f2dc0a93dc6194ff21b7 Mon Sep 17 00:00:00 2001 -From: David Hunt -Date: Fri, 16 Jul 2021 14:32:37 +0100 -Subject: [PATCH] distributor: fix 128-bit write alignment - -When the distributor sample app is built as a 32-bit app, -the data buffer passed to find_match_vec can be unaligned, -causing a segmentation fault due to writing a 128-bit value -using _mm_store_si128(). 128-bit align the data being -passed in so this does not happen. - -Fixes: 775003ad2f96 ("distributor: add new burst-capable library") -Cc: stable@dpdk.org - -Signed-off-by: David Hunt -Conflict: mv distributor dir to librte_distributor -Reference: https://github.com/DPDK/dpdk/commit/de8606bf73323dfa8395f2dc0a93dc6194ff21b7 - ---- - lib/librte_distributor/rte_distributor.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c -index 6c5b0c8..f6a0107 100644 ---- a/lib/librte_distributor/rte_distributor.c -+++ b/lib/librte_distributor/rte_distributor.c -@@ -373,7 +373,7 @@ rte_distributor_process(struct rte_distributor *d, - } - - while (next_idx < num_mbufs) { -- uint16_t matches[RTE_DIST_BURST_SIZE]; -+ uint16_t matches[RTE_DIST_BURST_SIZE] __rte_aligned(128); - unsigned int pkts; - - /* Sync with worker on GET_BUF flag. */ --- -2.23.0 - diff --git a/backport-CVE-2022-28199.patch b/backport-CVE-2022-28199.patch index 2bf12d0..d442e27 100644 --- a/backport-CVE-2022-28199.patch +++ b/backport-CVE-2022-28199.patch @@ -1,8 +1,10 @@ -From 8b090f2664e9d014cd8fa0fde90597aaf4349e7e Mon Sep 17 00:00:00 2001 -From: Alexander Kozyrev -Date: Thu, 11 Aug 2022 21:19:36 +0300 +From 25c01bd32374b0c3cbc260f3e3872408d749cb45 Mon Sep 17 00:00:00 2001 +From: Matan Azrad +Date: Thu, 11 Aug 2022 19:59:18 +0300 Subject: [PATCH] net/mlx5: fix Rx queue recovery mechanism +[ upstream commit 60b254e3923d007bcadbb8d410f95ad89a2f13fa ] + The local variables are getting inconsistent in data receiving routines after queue error recovery. Receive queue consumer index is getting wrong, need to reset one to the @@ -11,22 +13,22 @@ size of the queue (as RQ was fully replenished in recovery procedure). In MPRQ case, also the local consumed strd variable should be reset. CVE-2022-28199 -Fixes: 88c0733 ("net/mlx5: extend Rx completion with error handling") +Fixes: 88c0733535d6 ("net/mlx5: extend Rx completion with error handling") Signed-off-by: Alexander Kozyrev Signed-off-by: Matan Azrad Conflict: NA -Reference: https://git.dpdk.org/dpdk-stable/commit/?id=8b090f2664 +Reference: https://git.dpdk.org/dpdk-stable/commit/?id=25c01db32374 --- - drivers/net/mlx5/mlx5_rxtx.c | 34 ++++++++++++++++++++++++---------- + drivers/net/mlx5/mlx5_rx.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) -diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c -index a4f627e1a6..07c994815a 100644 ---- a/drivers/net/mlx5/mlx5_rxtx.c -+++ b/drivers/net/mlx5/mlx5_rxtx.c -@@ -931,6 +931,11 @@ mlx5_queue_state_modify(struct rte_eth_dev *dev, - return ret; +diff --git a/drivers/net/mlx5/mlx5_rx.c b/drivers/net/mlx5/mlx5_rx.c +index f388fcc313..9fcd039c22 100644 +--- a/drivers/net/mlx5/mlx5_rx.c ++++ b/drivers/net/mlx5/mlx5_rx.c +@@ -390,6 +390,11 @@ mlx5_rxq_initialize(struct mlx5_rxq_data *rxq) + *rxq->rq_db = rte_cpu_to_be_32(rxq->rq_ci); } +/* Must be negative. */ @@ -37,7 +39,7 @@ index a4f627e1a6..07c994815a 100644 /** * Handle a Rx error. * The function inserts the RQ state to reset when the first error CQE is -@@ -945,7 +950,7 @@ mlx5_queue_state_modify(struct rte_eth_dev *dev, +@@ -404,7 +409,7 @@ mlx5_rxq_initialize(struct mlx5_rxq_data *rxq) * 0 when called from non-vectorized Rx burst. * * @return @@ -46,25 +48,25 @@ index a4f627e1a6..07c994815a 100644 */ int mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) -@@ -973,7 +978,7 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) +@@ -433,7 +438,7 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) sm.queue_id = rxq->idx; sm.state = IBV_WQS_RESET; - if (mlx5_queue_state_modify(ETH_DEV(rxq_ctrl->priv), &sm)) + if (mlx5_queue_state_modify(RXQ_DEV(rxq_ctrl), &sm)) - return -1; + return MLX5_RECOVERY_ERROR_RET; if (rxq_ctrl->dump_file_n < - rxq_ctrl->priv->config.max_dump_files_num) { + RXQ_PORT(rxq_ctrl)->config.max_dump_files_num) { MKSTR(err_str, "Unexpected CQE error syndrome " -@@ -1014,7 +1019,7 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) +@@ -473,7 +478,7 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) + sm.queue_id = rxq->idx; sm.state = IBV_WQS_RDY; - if (mlx5_queue_state_modify(ETH_DEV(rxq_ctrl->priv), - &sm)) + if (mlx5_queue_state_modify(RXQ_DEV(rxq_ctrl), &sm)) - return -1; + return MLX5_RECOVERY_ERROR_RET; if (vec) { - const uint16_t q_mask = wqe_n - 1; - uint16_t elt_idx; -@@ -1036,7 +1041,7 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) + const uint32_t elts_n = + mlx5_rxq_mprq_enabled(rxq) ? +@@ -501,7 +506,7 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) rte_pktmbuf_free_seg (*elt); } @@ -72,8 +74,8 @@ index a4f627e1a6..07c994815a 100644 + return MLX5_RECOVERY_ERROR_RET; } } - for (i = 0; i < (int)wqe_n; ++i) { -@@ -1055,7 +1060,7 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) + for (i = 0; i < (int)elts_n; ++i) { +@@ -520,7 +525,7 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) } return ret; default: @@ -82,7 +84,7 @@ index a4f627e1a6..07c994815a 100644 } } -@@ -1073,7 +1078,9 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) +@@ -538,7 +543,9 @@ mlx5_rx_err_handle(struct mlx5_rxq_data *rxq, uint8_t vec) * written. * * @return @@ -93,7 +95,7 @@ index a4f627e1a6..07c994815a 100644 */ static inline int mlx5_rx_poll_len(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe, -@@ -1140,8 +1147,8 @@ mlx5_rx_poll_len(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe, +@@ -605,8 +612,8 @@ mlx5_rx_poll_len(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe, rxq->err_state)) { ret = mlx5_rx_err_handle(rxq, 0); if (ret == MLX5_CQE_STATUS_HW_OWN || @@ -104,7 +106,7 @@ index a4f627e1a6..07c994815a 100644 } else { return 0; } -@@ -1350,8 +1357,10 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) +@@ -851,8 +858,10 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) if (!pkt) { cqe = &(*rxq->cqes)[rxq->cq_ci & cqe_cnt]; len = mlx5_rx_poll_len(rxq, cqe, cqe_cnt, &mcqe); @@ -116,21 +118,21 @@ index a4f627e1a6..07c994815a 100644 break; } pkt = seg; -@@ -1630,8 +1639,13 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) +@@ -1075,8 +1084,13 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) } cqe = &(*rxq->cqes)[rxq->cq_ci & cq_mask]; ret = mlx5_rx_poll_len(rxq, cqe, cq_mask, &mcqe); - if (!ret) + if (ret == 0) - break; ++ break; + if (unlikely(ret == MLX5_ERROR_CQE_RET)) { + rq_ci = rxq->rq_ci; + consumed_strd = rxq->consumed_strd; -+ break; + break; + } byte_cnt = ret; - strd_cnt = (byte_cnt & MLX5_MPRQ_STRIDE_NUM_MASK) >> - MLX5_MPRQ_STRIDE_NUM_SHIFT; + len = (byte_cnt & MLX5_MPRQ_LEN_MASK) >> MLX5_MPRQ_LEN_SHIFT; + MLX5_ASSERT((int)len >= (rxq->crc_present << 2)); -- 2.23.0 diff --git a/backport-fix-dedicated-queue-mode-in-vector-burst.patch b/backport-fix-dedicated-queue-mode-in-vector-burst.patch deleted file mode 100644 index c465f0e..0000000 --- a/backport-fix-dedicated-queue-mode-in-vector-burst.patch +++ /dev/null @@ -1,87 +0,0 @@ -From b8cfca26aed14354a6594d416a37881f494e2cfc Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 22 Sep 2021 15:09:12 +0800 -Subject: net/bonding: fix dedicated queue mode in vector burst - -If the vector burst mode is selected, the dedicated queue mode will not -take effect on some PMDs because these PMDs may have some limitations -in vector burst mode. For example, the limit on burst size. Currently, -both hns3 and intel I40E require four alignments when receiving packets -in vector mode. As a result, they can't accept packets if burst size -below four. However, in dedicated queue mode, the burst size of periodic -packets processing is one. - -This patch fixes the above problem by modifying the burst size to 32. -This approach also makes the packet processing of the dedicated queue -mode more reasonable. Currently, if multiple LACP protocol packets are -received in the hardware queue in a cycle, only one LACP packet will be -processed in this cycle, and the left packets will be processed in the -following cycle. After the modification, all the LACP packets will be -processed at one time, which seems more reasonable and closer to the -behavior of the bonding driver when the dedicated queue is not turned on. - -Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP control") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++++++++--------- - 1 file changed, 23 insertions(+), 9 deletions(-) - -(limited to 'drivers/net/bonding/rte_eth_bond_8023ad.c') - -diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c -index 3558644232..2029955c10 100644 ---- a/drivers/net/bonding/rte_eth_bond_8023ad.c -+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c -@@ -838,6 +838,27 @@ rx_machine_update(struct bond_dev_private *internals, uint16_t slave_id, - rx_machine(internals, slave_id, NULL); - } - -+static void -+bond_mode_8023ad_dedicated_rxq_process(struct bond_dev_private *internals, -+ uint16_t slave_id) -+{ -+#define DEDICATED_QUEUE_BURST_SIZE 32 -+ struct rte_mbuf *lacp_pkt[DEDICATED_QUEUE_BURST_SIZE]; -+ uint16_t rx_count = rte_eth_rx_burst(slave_id, -+ internals->mode4.dedicated_queues.rx_qid, -+ lacp_pkt, DEDICATED_QUEUE_BURST_SIZE); -+ -+ if (rx_count) { -+ uint16_t i; -+ -+ for (i = 0; i < rx_count; i++) -+ bond_mode_8023ad_handle_slow_pkt(internals, slave_id, -+ lacp_pkt[i]); -+ } else { -+ rx_machine_update(internals, slave_id, NULL); -+ } -+} -+ - static void - bond_mode_8023ad_periodic_cb(void *arg) - { -@@ -926,15 +947,8 @@ bond_mode_8023ad_periodic_cb(void *arg) - - rx_machine_update(internals, slave_id, lacp_pkt); - } else { -- uint16_t rx_count = rte_eth_rx_burst(slave_id, -- internals->mode4.dedicated_queues.rx_qid, -- &lacp_pkt, 1); -- -- if (rx_count == 1) -- bond_mode_8023ad_handle_slow_pkt(internals, -- slave_id, lacp_pkt); -- else -- rx_machine_update(internals, slave_id, NULL); -+ bond_mode_8023ad_dedicated_rxq_process(internals, -+ slave_id); - } - - periodic_machine(internals, slave_id); --- -cgit v1.2.1 - - diff --git a/backport-gro-check-payload-length-after-trim.patch b/backport-gro-check-payload-length-after-trim.patch index 3059921..f1f1a88 100644 --- a/backport-gro-check-payload-length-after-trim.patch +++ b/backport-gro-check-payload-length-after-trim.patch @@ -14,12 +14,13 @@ Signed-off-by: Kumara Parameshwaran Acked-by: Jiayu Hu --- lib/gro/gro_tcp4.c | 11 ++++++----- + lib/gro/gro_udp4.c | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) -diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c +diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c index 8f5e800250..0014096e63 100644 ---- a/lib/librte_gro/gro_tcp4.c -+++ b/lib/librte_gro/gro_tcp4.c +--- a/lib/gro/gro_tcp4.c ++++ b/lib/gro/gro_tcp4.c @@ -225,6 +225,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, */ if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) @@ -45,6 +46,37 @@ index 8f5e800250..0014096e63 100644 /* * Save IPv4 ID for the packet whose DF bit is 0. For the packet * whose DF bit is 1, IPv4 ID is ignored. +diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c +index 839f9748b7..42596d33b6 100644 +--- a/lib/gro/gro_udp4.c ++++ b/lib/gro/gro_udp4.c +@@ -220,6 +220,11 @@ gro_udp4_reassemble(struct rte_mbuf *pkt, + if (!is_ipv4_fragment(ipv4_hdr)) + return -1; + ++ ip_dl = rte_be_to_cpu_16(ipv4_hdr->total_length); ++ /* trim the tail padding bytes */ ++ if (pkt->pkt_len > (uint32_t)(ip_dl + pkt->l2_len)) ++ rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_dl - pkt->l2_len); ++ + /* + * Don't process the packet whose payload length is less than or + * equal to 0. +@@ -227,14 +232,9 @@ gro_udp4_reassemble(struct rte_mbuf *pkt, + if (pkt->pkt_len <= hdr_len) + return -1; + +- ip_dl = rte_be_to_cpu_16(ipv4_hdr->total_length); + if (ip_dl <= pkt->l3_len) + return -1; + +- /* trim the tail padding bytes */ +- if (pkt->pkt_len > (uint32_t)(ip_dl + pkt->l2_len)) +- rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_dl - pkt->l2_len); +- + ip_dl -= pkt->l3_len; + ip_id = rte_be_to_cpu_16(ipv4_hdr->packet_id); + frag_offset = rte_be_to_cpu_16(ipv4_hdr->fragment_offset); -- 2.23.0 diff --git a/backport-gro-fix-chain-index-for-more-than-2-packets.patch b/backport-gro-fix-chain-index-for-more-than-2-packets.patch index a42de8b..5ae4823 100644 --- a/backport-gro-fix-chain-index-for-more-than-2-packets.patch +++ b/backport-gro-fix-chain-index-for-more-than-2-packets.patch @@ -13,10 +13,10 @@ Acked-by: Jiayu Hu lib/gro/gro_tcp4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c +diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c index 7498c66141..9758e28fd5 100644 ---- a/lib/librte_gro/gro_tcp4.c -+++ b/lib/librte_gro/gro_tcp4.c +--- a/lib/gro/gro_tcp4.c ++++ b/lib/gro/gro_tcp4.c @@ -305,7 +305,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, * length is greater than the max value. Store * the packet into the flow. diff --git a/backport-gro-trim-tail-padding-bytes.patch b/backport-gro-trim-tail-padding-bytes.patch index 7ed35da..f34d4a9 100644 --- a/backport-gro-trim-tail-padding-bytes.patch +++ b/backport-gro-trim-tail-padding-bytes.patch @@ -20,12 +20,13 @@ Signed-off-by: Jun Qiu Acked-by: Jiayu Hu --- lib/gro/gro_tcp4.c | 7 ++++++- + lib/gro/gro_udp4.c | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) -diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c +diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c index 9758e28fd5..8f5e800250 100644 ---- a/lib/librte_gro/gro_tcp4.c -+++ b/lib/librte_gro/gro_tcp4.c +--- a/lib/gro/gro_tcp4.c ++++ b/lib/gro/gro_tcp4.c @@ -198,7 +198,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, struct rte_tcp_hdr *tcp_hdr; uint32_t sent_seq; @@ -47,6 +48,21 @@ index 9758e28fd5..8f5e800250 100644 /* * Save IPv4 ID for the packet whose DF bit is 0. For the packet * whose DF bit is 1, IPv4 ID is ignored. +diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c +index dd71135ada..839f9748b7 100644 +--- a/lib/gro/gro_udp4.c ++++ b/lib/gro/gro_udp4.c +@@ -231,6 +231,10 @@ gro_udp4_reassemble(struct rte_mbuf *pkt, + if (ip_dl <= pkt->l3_len) + return -1; + ++ /* trim the tail padding bytes */ ++ if (pkt->pkt_len > (uint32_t)(ip_dl + pkt->l2_len)) ++ rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_dl - pkt->l2_len); ++ + ip_dl -= pkt->l3_len; + ip_id = rte_be_to_cpu_16(ipv4_hdr->packet_id); + frag_offset = rte_be_to_cpu_16(ipv4_hdr->fragment_offset); -- 2.23.0 diff --git a/backport-net-hinic-fix-crash-in-secondary-process.patch b/backport-net-hinic-fix-crash-in-secondary-process.patch deleted file mode 100644 index 83f2fdc..0000000 --- a/backport-net-hinic-fix-crash-in-secondary-process.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 3be4c6f38ea1e2fd66f21872f38a2fb42d0fd36c Mon Sep 17 00:00:00 2001 -From: Guoyang Zhou -Date: Tue, 23 Mar 2021 21:17:51 +0800 -Subject: [PATCH] net/hinic: fix crash in secondary process - -[ upstream commit 4c670dfaa417bc5604c9c58b505a74e2725acdb2 ] - -Some apps, such as fstack, will use secondary process to access the -memory of eth_dev_ops, and they want to get the info of dev, but hinic -driver does not initialized it when in secondary process. - -Fixes: 66f64dd6dc86 ("net/hinic: fix secondary process") - -Signed-off-by: Guoyang Zhou ---- - drivers/net/hinic/hinic_pmd_ethdev.c | 5 +++++ - 2 files changed, 13 insertions(+), 17 deletions(-) -diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c -index a0499da7d4..89ee5b7a78 100644 ---- a/drivers/net/hinic/hinic_pmd_ethdev.c -+++ b/drivers/net/hinic/hinic_pmd_ethdev.c -@@ -2972,6 +2972,10 @@ static const struct eth_dev_ops hinic_pmd_vf_ops = { - .filter_ctrl = hinic_dev_filter_ctrl, - }; - -+static const struct eth_dev_ops hinic_dev_sec_ops = { -+ .dev_infos_get = hinic_dev_infos_get, -+}; -+ - static int hinic_func_init(struct rte_eth_dev *eth_dev) - { - struct rte_pci_device *pci_dev; -@@ -2985,6 +2989,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) - - /* EAL is SECONDARY and eth_dev is already created */ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ eth_dev->dev_ops = &hinic_dev_sec_ops; - PMD_DRV_LOG(INFO, "Initialize %s in secondary process", - eth_dev->data->name); - --- -2.23.0 - diff --git a/backport-vhost-handle-mbuf-allocation-failure.patch b/backport-vhost-handle-mbuf-allocation-failure.patch deleted file mode 100644 index 80d267c..0000000 --- a/backport-vhost-handle-mbuf-allocation-failure.patch +++ /dev/null @@ -1,165 +0,0 @@ -From 0fd5608ef97f9c467f1ecc926463cf793189443e Mon Sep 17 00:00:00 2001 -From: Sivaprasad Tummala -Date: Fri, 8 May 2020 16:47:51 +0530 -Subject: [PATCH] vhost: handle mbuf allocation failure - -vhost buffer allocation is successful for packets that fit -into a linear buffer. If it fails, vhost library is expected -to drop the current packet and skip to the next. - -The patch fixes the error scenario by skipping to next packet. -Note: Drop counters are not currently supported. - -Fixes: c3ff0ac70acb ("vhost: improve performance by supporting large buffer") -Cc: stable@dpdk.org - -Signed-off-by: Sivaprasad Tummala -Reviewed-by: Maxime Coquelin -Conflict: NA -Reference: https://git.dpdk.org/dpdk-stable/commit/?id=0fd5608ef9 ---- - lib/librte_vhost/virtio_net.c | 70 +++++++++++++++++++++++++++-------- - 1 file changed, 55 insertions(+), 15 deletions(-) - -diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c -index 5e8c6b99c0..751c1f3733 100644 ---- a/lib/librte_vhost/virtio_net.c -+++ b/lib/librte_vhost/virtio_net.c -@@ -1673,6 +1673,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, - { - uint16_t i; - uint16_t free_entries; -+ uint16_t dropped = 0; -+ static bool allocerr_warned; - - if (unlikely(dev->dequeue_zero_copy)) { - struct zcopy_mbuf *zmbuf, *next; -@@ -1734,13 +1736,35 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, - update_shadow_used_ring_split(vq, head_idx, 0); - - pkts[i] = virtio_dev_pktmbuf_alloc(dev, mbuf_pool, buf_len); -- if (unlikely(pkts[i] == NULL)) -+ if (unlikely(pkts[i] == NULL)) { -+ /* -+ * mbuf allocation fails for jumbo packets when external -+ * buffer allocation is not allowed and linear buffer -+ * is required. Drop this packet. -+ */ -+ if (!allocerr_warned) { -+ RTE_LOG(ERR, VHOST_DATA, -+ "Failed mbuf alloc of size %d from %s on %s.\n", -+ buf_len, mbuf_pool->name, dev->ifname); -+ allocerr_warned = true; -+ } -+ dropped += 1; -+ i++; - break; -+ } - - err = copy_desc_to_mbuf(dev, vq, buf_vec, nr_vec, pkts[i], - mbuf_pool); - if (unlikely(err)) { - rte_pktmbuf_free(pkts[i]); -+ if (!allocerr_warned) { -+ RTE_LOG(ERR, VHOST_DATA, -+ "Failed to copy desc to mbuf on %s.\n", -+ dev->ifname); -+ allocerr_warned = true; -+ } -+ dropped += 1; -+ i++; - break; - } - -@@ -1750,6 +1774,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, - zmbuf = get_zmbuf(vq); - if (!zmbuf) { - rte_pktmbuf_free(pkts[i]); -+ dropped += 1; -+ i++; - break; - } - zmbuf->mbuf = pkts[i]; -@@ -1779,7 +1805,7 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, - } - } - -- return i; -+ return (i - dropped); - } - - static __rte_always_inline int -@@ -1913,6 +1939,7 @@ vhost_dequeue_single_packed(struct virtio_net *dev, - uint32_t buf_len; - uint16_t nr_vec = 0; - int err; -+ static bool allocerr_warned; - - if (unlikely(fill_vec_buf_packed(dev, vq, - vq->last_avail_idx, desc_count, -@@ -1923,14 +1950,24 @@ vhost_dequeue_single_packed(struct virtio_net *dev, - - *pkts = virtio_dev_pktmbuf_alloc(dev, mbuf_pool, buf_len); - if (unlikely(*pkts == NULL)) { -- RTE_LOG(ERR, VHOST_DATA, -- "Failed to allocate memory for mbuf.\n"); -+ if (!allocerr_warned) { -+ RTE_LOG(ERR, VHOST_DATA, -+ "Failed mbuf alloc of size %d from %s on %s.\n", -+ buf_len, mbuf_pool->name, dev->ifname); -+ allocerr_warned = true; -+ } - return -1; - } - - err = copy_desc_to_mbuf(dev, vq, buf_vec, nr_vec, *pkts, - mbuf_pool); - if (unlikely(err)) { -+ if (!allocerr_warned) { -+ RTE_LOG(ERR, VHOST_DATA, -+ "Failed to copy desc to mbuf on %s.\n", -+ dev->ifname); -+ allocerr_warned = true; -+ } - rte_pktmbuf_free(*pkts); - return -1; - } -@@ -1945,21 +1982,24 @@ virtio_dev_tx_single_packed(struct virtio_net *dev, - struct rte_mbuf **pkts) - { - -- uint16_t buf_id, desc_count; -+ uint16_t buf_id, desc_count = 0; -+ int ret; - -- if (vhost_dequeue_single_packed(dev, vq, mbuf_pool, pkts, &buf_id, -- &desc_count)) -- return -1; -+ ret = vhost_dequeue_single_packed(dev, vq, mbuf_pool, pkts, &buf_id, -+ &desc_count); - -- if (virtio_net_is_inorder(dev)) -- vhost_shadow_dequeue_single_packed_inorder(vq, buf_id, -- desc_count); -- else -- vhost_shadow_dequeue_single_packed(vq, buf_id, desc_count); -+ if (likely(desc_count > 0)) { -+ if (virtio_net_is_inorder(dev)) -+ vhost_shadow_dequeue_single_packed_inorder(vq, buf_id, -+ desc_count); -+ else -+ vhost_shadow_dequeue_single_packed(vq, buf_id, -+ desc_count); - -- vq_inc_last_avail_packed(vq, desc_count); -+ vq_inc_last_avail_packed(vq, desc_count); -+ } - -- return 0; -+ return ret; - } - - static __rte_always_inline int --- -2.23.0 - diff --git a/dpdk-19.11.tar.xz b/dpdk-21.11.tar.xz similarity index 58% rename from dpdk-19.11.tar.xz rename to dpdk-21.11.tar.xz index 6969939..5b1b7fe 100644 Binary files a/dpdk-19.11.tar.xz and b/dpdk-21.11.tar.xz differ diff --git a/dpdk.spec b/dpdk.spec index 63bee98..e1c85ed 100644 --- a/dpdk.spec +++ b/dpdk.spec @@ -1,96 +1,400 @@ Name: dpdk -Version: 19.11 -Release: 31 +Version: 21.11 +Release: 1 Packager: packaging@6wind.com URL: http://dpdk.org -%global source_version 19.11 +%global source_version 21.11 Source: https://git.dpdk.org/dpdk/snapshot/%{name}-%{version}.tar.xz -Patch0: CVE-2020-10725.patch -Patch1: CVE-2020-10722.patch -Patch2: CVE-2020-10723.patch -Patch3: CVE-2020-10724.patch -Patch4: CVE-2020-10726.patch -Patch5: CVE-2020-14378.patch -Patch6: CVE-2020-14376-CVE-2020-14377.patch -Patch7: fix-pool-allocation.patch -Patch8: CVE-2020-14374.patch -Patch9: CVE-2020-14375.patch -Patch10: fix-populate-with-small-virtual-chunks.patch -Patch11: 0001-dpdk-add-secure-compile-option-and-fPIC-option.patch -Patch12: 0002-dpdk-add-secure-option-in-makefile.patch -Patch13: 0003-dpdk-bugfix-the-deadlock-in-rte_eal_init.patch -Patch14: 0004-dpdk-master-core-donot-set-affinity-in-libstorage.patch -Patch15: 0005-dpdk-change-the-log-level-in-prepare_numa.patch -Patch16: 0006-dpdk-fix-dpdk-coredump-problem.patch -Patch17: 0007-dpdk-add-secure-compile-option-in-pmdinfogen-Makefil.patch -Patch18: 0008-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262.patch -Patch19: 0009-dpdk-add-support-gazelle.patch -Patch20: 0010-dpdk-fix-error-in-clearing-secondary-process-memseg-lists.patch -Patch21: 0011-dpdk-fix-coredump-when-primary-process-attach-without-shared-file.patch -Patch22: 0012-dpdk-fix-fbarray-memseg-destory-error-during-detach.patch -Patch23: 0013-dpdk-optimize-the-efficiency-of-compiling-dpdk.patch -Patch24: backport-0001-net-softnic-fix-memory-leak-as-profile-is-freed.patch -Patch25: backport-0002-net-virtio-fix-interrupt-handle-leak.patch -Patch26: backport-0003-vhost-fix-crash-on-reconnect.patch -Patch27: backport-0004-net-virtio-report-maximum-MTU-in-device-info.patch -Patch28: backport-0005-bus-dpaa-fix-freeing-in-FMAN-interface-destructor.patch -Patch29: backport-0006-distributor-fix-128-bit-write-alignment.patch -Patch30: 0014-fix-rte-eal-sec-detach-coredump-count-rollover.patch -Patch31: 0015-fix-rte-eal-memory-init-double-unlock.patch -Patch32: 0016-fix-last-argv-pointer-change-to-first.patch -Patch33: 0017-fix-internal-cfg-and-fbarray-attach-mememory-leak.patch -Patch34: 0018-fix-error-that-the-secondary-attach-fails-due-to-detach.patch -Patch35: CVE-2021-3839.patch -Patch36: CVE-2022-0669.patch -Patch37: 0019-reinit-support-return-ok.patch +# upstream patch number start from 6000. +# self developed patch number start from 9000 +Patch9001: 0001-add-igb-uio.patch +Patch9002: 0002-dpdk-add-secure-compile-option-and-fPIC-option.patch +Patch9003: 0003-dpdk-bugfix-the-deadlock-in-rte_eal_init.patch +Patch9004: 0004-dpdk-master-core-donot-set-affinity-in-libstorage.patch +Patch9005: 0005-dpdk-change-the-log-level-in-prepare_numa.patch +Patch9006: 0006-dpdk-fix-dpdk-coredump-problem.patch +Patch9007: 0007-dpdk-fix-cpu-flag-error-in-Intel-R-Xeon-R-CPU-E5-262.patch +Patch9008: 0008-dpdk-add-support-for-gazelle.patch +Patch9009: 0009-dpdk-fix-error-in-clearing-secondary-process-memseg-lists.patch +Patch9010: 0010-dpdk-fix-coredump-when-primary-process-attach-without-shared-file.patch +Patch9011: 0011-dpdk-fix-fbarray-memseg-destory-error-during-detach.patch +Patch9012: 0012-fix-rte-eal-sec-detach-coredump-count-rollover.patch +Patch9013: 0013-fix-rte-eal-memory-init-double-unlock.patch +Patch9014: 0014-fix-last-argv-pointer-change-to-first.patch +Patch9015: 0015-fix-internal-cfg-and-fbarray-attach-mememory-leak.patch +Patch9016: 0016-fix-error-that-the-secondary-attach-fails-due-to-detach.patch +Patch9017: 0017-fix-master-thread-not-set-affinity.patch -Patch6000: backport-vhost-handle-mbuf-allocation-failure.patch -Patch6001: backport-0001-CVE-2022-2132.patch -Patch6002: backport-0002-CVE-2022-2131.patch -Patch6003: backport-CVE-2022-28199.patch -Patch6004: backport-gro-fix-chain-index-for-more-than-2-packets.patch -Patch6005: backport-gro-trim-tail-padding-bytes.patch -Patch6006: backport-gro-check-payload-length-after-trim.patch -Patch6007: backport-net-hinic-fix-crash-in-secondary-process.patch -Patch6008: fix-virtio-hardthrough-scenes-device-init-bug.patch -Patch6009: backport-0001-net-hinic-add-flow-director-filter.patch -Patch6010: backport-0002-net-hinic-add-TCAM-filter-switch-for-flow-director.patch -Patch6011: backport-0003-net-hinic-check-memory-allocations-in-flow-creation.patch -Patch6012: backport-0004-net-hinic-fix-filters-on-memory-allocation-failure.patch -Patch6013: backport-0005-net-hinic-fix-TCAM-filter-set.patch +Patch9018: 0018-secure-complilation-options-rpath.patch +Patch9019: 0019-reinit-support-return-ok.patch -Patch9000: hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch +Patch6001: CVE-2021-3839.patch +Patch6002: CVE-2022-0669.patch +Patch6003: backport-0001-CVE-2022-2132.patch +Patch6004: backport-0002-CVE-2022-2132.patch +Patch6005: backport-CVE-2022-28199.patch +Patch6006: backport-gro-fix-chain-index-for-more-than-2-packets.patch +Patch6007: backport-gro-trim-tail-padding-bytes.patch +Patch6008: backport-gro-check-payload-length-after-trim.patch -Patch6014: backport-fix-dedicated-queue-mode-in-vector-burst.patch +Patch6018: 0018-net-bonding-fix-offloading-configuration.patch +Patch6019: 0019-net-hns3-fix-Rx-Tx-when-fast-path-operation-introduc.patch +Patch6020: 0020-net-hns3-fix-mailbox-wait-time-uninitialization.patch +Patch6021: 0021-net-hns3-fix-vector-burst-when-PTP-enable.patch +Patch6022: 0022-net-hns3-remove-unnecessary-assignment.patch +Patch6023: 0023-net-hns3-fix-using-enum-as-boolean.patch +Patch6024: 0024-net-hns3-extract-common-function-to-initialize-MAC-a.patch +Patch6025: 0025-net-hns3-make-control-plane-function-non-inline.patch +Patch6026: 0026-net-hns3-remove-unnecessary-blank-lines.patch +Patch6027: 0027-net-hns3-extract-reset-failure-handling-to-function.patch +Patch6028: 0028-net-hns3-remove-unused-variables.patch +Patch6029: 0029-net-hns3-remove-getting-number-of-queue-descriptors-.patch +Patch6030: 0030-net-hns3-remove-logging-memory-addresses.patch +Patch6031: 0031-net-hns3-extract-common-function-to-obtain-revision-.patch +Patch6032: 0032-net-hns3-replace-single-line-functions.patch +Patch6033: 0033-net-hns3-remove-non-re-entrant-strerror-call.patch +Patch6034: 0034-net-hns3-rename-function.patch +Patch6035: 0035-net-hns3-extract-functions-to-create-RSS-and-FDIR-fl.patch +Patch6036: 0036-net-hns3-support-indirect-counter-flow-action.patch +Patch6037: 0037-net-hns3-fix-max-packet-size-rollback-in-PF.patch +Patch6038: 0038-net-hns3-fix-RSS-key-with-null.patch +Patch6039: 0039-net-hns3-fix-insecure-way-to-query-MAC-statistics.patch +Patch6040: 0040-net-hns3-fix-double-decrement-of-secondary-count.patch +Patch6041: 0041-net-hns3-fix-operating-queue-when-TCAM-table-is-inva.patch +Patch6042: 0042-net-hns3-delete-duplicated-RSS-type.patch +Patch6043: 0043-net-bonding-fix-promiscuous-and-allmulticast-state.patch +Patch6044: 0044-net-bonding-fix-reference-count-on-mbufs.patch +Patch6045: 0045-app-testpmd-fix-bonding-mode-set.patch +Patch6046: 0046-ethdev-introduce-dump-API.patch +Patch6047: 0047-app-procinfo-add-device-private-info-dump.patch +Patch6048: 0048-net-hns3-dump-device-basic-info.patch +Patch6049: 0049-net-hns3-dump-device-feature-capability.patch +Patch6050: 0050-net-hns3-dump-device-MAC-info.patch +Patch6051: 0051-net-hns3-dump-queue-info.patch +Patch6052: 0052-net-hns3-dump-VLAN-configuration-info.patch +Patch6053: 0053-net-hns3-dump-flow-director-basic-info.patch +Patch6054: 0054-net-hns3-dump-TM-configuration-info.patch +Patch6055: 0055-net-hns3-dump-flow-control-info.patch +Patch6056: 0056-net-hns3-change-dump-file-name.patch +Patch6057: 0057-net-hns3-fix-code-check-for-dump.patch +Patch6058: 0058-ethdev-fix-ethdev-version-map.patch +Patch6059: 0059-net-hns3-delete-simple-bd-cap.patch +Patch6060: 0060-net-hns3-fix-TM-info-dump.patch +Patch6061: 0061-dma-hisilicon-support-Kunpeng-930.patch +Patch6062: 0062-dma-hisilicon-support-error-handling-with-Kunpeng-93.patch +Patch6063: 0063-dma-hisilicon-support-registers-dump-for-Kunpeng-930.patch +Patch6064: 0064-dma-hisilicon-add-queue-full-statistics.patch +Patch6065: 0065-dma-hisilicon-use-common-PCI-device-naming.patch +Patch6066: 0066-app-testpmd-check-starting-port-is-not-in-bonding.patch +Patch6067: 0067-examples-vhost-remove-DMA-type-option-help-info.patch +Patch6068: 0068-kni-fix-freeing-order-in-device-release.patch +Patch6069: 0069-net-hns3-remove-duplicate-macro-definition.patch +Patch6070: 0070-net-hns3-fix-RSS-TC-mode-entry.patch +Patch6071: 0071-net-hns3-fix-VF-RSS-TC-mode-entry.patch +Patch6072: 0072-net-hns3-increase-time-waiting-for-PF-reset-completi.patch +Patch6073: 0073-net-bonding-fix-stopping-non-active-slaves.patch +Patch6074: 0074-net-bonding-fix-slave-stop-and-remove-on-port-close.patch +Patch6075: 0075-net-hns3-fix-order-of-clearing-imissed-register-in-P.patch +Patch6076: 0076-net-hns3-fix-MAC-and-queues-HW-statistics-overflow.patch +Patch6077: 0077-net-hns3-fix-pseudo-sharing-between-threads.patch +Patch6078: 0078-net-hns3-fix-mbuf-free-on-Tx-done-cleanup.patch +Patch6079: 0079-net-hns3-fix-RSS-disable.patch +Patch6080: 0080-net-hns3-fix-rollback-on-RSS-hash-update.patch +Patch6081: 0081-net-hns3-remove-redundant-RSS-tuple-field.patch +Patch6082: 0082-ethdev-fix-RSS-update-when-RSS-is-disabled.patch +Patch6083: 0083-net-hns3-remove-unnecessary-RSS-switch.patch +Patch6084: 0084-app-testpmd-check-statistics-query-before-printing.patch +Patch6085: 0085-app-testpmd-fix-MTU-verification.patch +Patch6086: 0086-app-testpmd-fix-port-status-of-bonding-slave-device.patch +Patch6087: 0087-ethdev-clarify-null-location-case-in-xstats-get.patch +Patch6088: 0088-ethdev-simplify-xstats-get-implementation.patch +Patch6089: 0089-net-hns3-fix-xstats-get-return-if-xstats-is-null.patch +Patch6090: 0090-net-ipn3ke-fix-xstats-get-return-if-xstats-is-null.patch +Patch6091: 0091-net-mvpp2-fix-xstats-get-return-if-xstats-is-null.patch +Patch6092: 0092-net-axgbe-fix-xstats-get-return-if-xstats-is-null.patch +Patch6093: 0093-ethdev-fix-memory-leak-in-xstats-telemetry.patch +Patch6094: 0094-ethdev-fix-possible-null-pointer-access.patch +Patch6095: 0095-net-cnxk-fix-possible-null-dereference-in-telemetry.patch +Patch6096: 0096-net-bonding-fix-mbuf-fast-free-usage.patch +Patch6097: 0097-ethdev-fix-port-state-when-stop.patch +Patch6098: 0098-ethdev-fix-port-close-in-secondary-process.patch +Patch6099: 0099-examples-dma-fix-MTU-configuration.patch +Patch6100: 0100-examples-dma-fix-Tx-drop-statistics.patch +Patch6101: 0101-examples-dma-add-force-minimal-copy-size-parameter.patch +Patch6102: 0102-dma-hisilicon-fix-index-returned-when-no-DMA-complet.patch +Patch6103: 0103-test-dma-check-index-when-no-DMA-completed.patch +Patch6104: 0104-dma-hisilicon-enhance-CQ-scan-robustness.patch +Patch6105: 0105-net-failsafe-fix-device-freeing.patch +Patch6106: 0106-net-tap-fix-device-freeing.patch +Patch6107: 0107-net-bonding-fix-RSS-inconsistent-between-bonded-and-.patch +Patch6108: 0108-app-test-fix-bonding-RSS-test-when-disable-RSS.patch +Patch6109: 0109-net-hns3-add-check-for-deferred-start-queue-when-rol.patch +Patch6110: 0110-net-hns3-remove-redundant-parentheses.patch +Patch6111: 0111-net-hns3-adjust-the-data-type-of-some-variables.patch +Patch6112: 0112-net-hns3-fix-an-unreasonable-memset.patch +Patch6113: 0113-net-hns3-remove-duplicate-definition.patch +Patch6114: 0114-net-hns3-fix-code-check-warning.patch +Patch6115: 0115-net-hns3-fix-return-value-for-unsupported-tuple.patch +Patch6116: 0116-net-hns3-modify-a-function-name.patch +Patch6117: 0117-net-hns3-unify-the-code-wrap-style.patch +Patch6118: 0118-net-hns3-fix-a-segfault-from-secondary-process.patch +Patch6119: 0119-net-hns3-fix-TM-capability-incorrectly-defined.patch +Patch6120: 0120-app-testpmd-add-help-messages-for-multi-process.patch +Patch6121: 0121-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch +Patch6122: 0122-app-testpmd-fix-bonding-slave-devices-not-released.patch -Patch9001: 0001-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch -Patch9002: 0002-gro-fix-gro-with-tcp-push-flag.patch +Patch6125: 0125-net-hns3-fix-link-status-capability-query-from-VF.patch +Patch6126: 0126-net-hns3-support-backplane-media-type.patch +Patch6127: 0127-net-hns3-cancel-heartbeat-alarm-when-VF-reset.patch +Patch6128: 0128-net-hns3-fix-PTP-interrupt-logging.patch +Patch6129: 0129-net-hns3-fix-statistics-locking.patch +Patch6130: 0130-net-hns3-fix-descriptors-check-with-SVE.patch +Patch6131: 0131-net-hns3-clean-some-functions.patch +Patch6132: 0132-net-hns3-delete-unused-code.patch +Patch6133: 0133-examples-dma-support-dequeue-when-no-packet-received.patch +Patch6134: 0134-net-hns3-add-dump-of-VF-VLAN-filter-modify-capabilit.patch +Patch6135: 0135-net-hns3-fix-Rx-with-PTP.patch +Patch6136: 0136-net-hns3-fix-crash-in-SVE-Tx.patch +Patch6137: 0137-net-hns3-fix-next-to-use-overflow-in-SVE-Tx.patch +Patch6138: 0138-net-hns3-fix-next-to-use-overflow-in-simple-Tx.patch +Patch6139: 0139-net-hns3-optimize-SVE-Tx-performance.patch +Patch6140: 0140-net-hns3-fix-crash-when-secondary-process-access-FW.patch +Patch6141: 0141-net-hns3-delete-unused-markup.patch +Patch6142: 0142-net-hns3-fix-clearing-hardware-MAC-statistics.patch +Patch6143: 0143-net-hns3-revert-Tx-performance-optimization.patch +Patch6144: 0144-net-hns3-fix-RSS-rule-restore.patch +Patch6145: 0145-net-hns3-fix-RSS-filter-restore.patch +Patch6146: 0146-net-hns3-fix-lock-protection-of-RSS-flow-rule.patch +Patch6147: 0147-net-hns3-fix-RSS-flow-rule-restore.patch +Patch6148: 0148-net-hns3-move-flow-direction-rule-recovery.patch +Patch6149: 0149-net-hns3-fix-restore-filter-function-input.patch +Patch6150: 0150-net-hns3-fix-build-with-gcov.patch +Patch6151: 0151-net-hns3-fix-packet-type-for-GENEVE.patch +Patch6152: 0152-net-hns3-remove-magic-numbers-for-MAC-address.patch +Patch6153: 0153-net-hns3-fix-code-check-warnings.patch +Patch6154: 0154-net-hns3-fix-header-files-includes.patch +Patch6155: 0155-net-hns3-remove-unused-structures.patch +Patch6156: 0156-net-hns3-rename-header-guards.patch +Patch6157: 0157-net-hns3-fix-IPv4-and-IPv6-RSS.patch +Patch6158: 0158-net-hns3-fix-types-in-IPv6-SCTP-fields.patch +Patch6159: 0159-net-hns3-fix-IPv4-RSS.patch +Patch6160: 0160-net-hns3-add-check-for-L3-and-L4-type.patch +Patch6161: 0161-net-hns3-revert-fix-mailbox-communication-with-HW.patch +Patch6162: 0162-net-hns3-fix-VF-mailbox-message-handling.patch +Patch6163: 0163-net-hns3-fix-minimum-Tx-frame-length.patch +Patch6164: 0164-ethdev-introduce-Rx-Tx-descriptor-dump-API.patch +Patch6165: 0165-net-hns3-support-Rx-Tx-descriptor-dump.patch +Patch6166: 0166-remove-unnecessary-null-checks.patch +Patch6167: 0167-ethdev-introduce-generic-dummy-packet-burst-function.patch +Patch6168: 0168-fix-spelling-in-comments-and-strings.patch +Patch6169: 0169-net-hns3-add-VLAN-filter-query-in-dump-file.patch +Patch6170: 0170-net-bonding-fix-array-overflow-in-Rx-burst.patch +Patch6171: 0171-net-bonding-fix-double-slave-link-status-query.patch +Patch6172: 0172-app-testpmd-fix-supported-RSS-offload-display.patch +Patch6173: 0173-app-testpmd-unify-name-of-L2-payload-offload.patch +Patch6174: 0174-app-testpmd-refactor-config-all-RSS-command.patch +Patch6175: 0175-app-testpmd-unify-RSS-types-display.patch +Patch6176: 0176-app-testpmd-compact-RSS-types-output.patch +Patch6177: 0177-app-testpmd-reorder-RSS-type-table.patch +Patch6178: 0178-app-testpmd-fix-RSS-types-display.patch +Patch6179: 0179-ethdev-support-telemetry-private-dump.patch +Patch6180: 0180-dmadev-add-telemetry.patch +Patch6181: 0181-dmadev-support-telemetry-dump-dmadev.patch +Patch6182: 0182-telemetry-add-missing-C-guards.patch +Patch6183: 0183-telemetry-limit-characters-allowed-in-dictionary-nam.patch +Patch6184: 0184-telemetry-fix-escaping-of-invalid-json-characters.patch +Patch6185: 0185-telemetry-add-escaping-of-strings-in-arrays.patch +Patch6186: 0186-telemetry-add-escaping-of-strings-in-dicts.patch +Patch6187: 0187-telemetry-limit-command-characters.patch +Patch6188: 0188-telemetry-eliminate-duplicate-code-for-json-output.patch +Patch6189: 0189-telemetry-make-help-command-more-helpful.patch + +Patch6190: 0190-net-bonding-fix-Tx-hash-for-TCP.patch +Patch6191: 0191-net-bonding-add-link-speeds-configuration.patch +Patch6192: 0192-net-bonding-call-Tx-prepare-before-Tx-burst.patch +Patch6193: 0193-net-bonding-fix-MTU-set-for-slaves.patch +Patch6194: 0194-app-testpmd-remove-jumbo-offload-related-code.patch +Patch6195: 0195-app-testpmd-revert-MAC-update-in-checksum-forwarding.patch +Patch6196: 0196-net-bonding-fix-bond4-drop-valid-MAC-packets.patch +Patch6197: 0197-net-bonding-fix-slave-device-Rx-Tx-offload-configura.patch +Patch6198: 0198-app-testpmd-fix-MAC-header-in-csum-forward-engine.patch +Patch6199: 0199-app-testpmd-update-bond-port-configurations-when-add.patch +Patch6200: 0200-app-testpmd-fix-GENEVE-parsing-in-checksum-mode.patch +Patch6201: 0201-net-add-UDP-TCP-checksum-in-mbuf-segments.patch +Patch6202: 0202-app-testpmd-add-SW-L4-checksum-in-multi-segments.patch +Patch6203: 0203-app-testpmd-fix-L4-checksum-in-multi-segments.patch +Patch6204: 0204-net-bonding-fix-mbuf-fast-free-handling.patch +Patch6205: 0205-doc-fix-application-name-in-procinfo-guide.patch +Patch6206: 0206-doc-document-device-dump-in-procinfo-guide.patch +Patch6207: 0207-app-procinfo-remove-doxygen-comments.patch +Patch6208: 0208-app-procinfo-dump-DPDK-version.patch +Patch6209: 0209-app-procinfo-dump-firmware-version.patch +Patch6210: 0210-app-procinfo-dump-RSS-RETA.patch +Patch6211: 0211-app-procinfo-dump-module-EEPROM-info.patch +Patch6212: 0212-app-procinfo-add-burst-mode-to-Rx-Tx-queue-info.patch +Patch6213: 0213-app-procinfo-dump-detailed-info-for-Rx-Tx-descriptor.patch +Patch6214: 0214-dma-hisilicon-support-vchan-status-query.patch +Patch6215: 0215-kni-fix-build-with-Linux-5.18.patch +Patch6216: 0216-kni-use-dedicated-function-to-set-random-MAC-address.patch +Patch6217: 0217-kni-use-dedicated-function-to-set-MAC-address.patch +Patch6218: 0218-linux-igb_uio-fix-build-for-switch-fall-through.patch +Patch6219: 0219-linux-igb_uio-fix-build-with-kernel-5.18.patch +Patch6220: 0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch +Patch6221: 0221-net-hns3-fix-log-about-indirection-table-size.patch +Patch6222: 0222-net-hns3-extract-common-function-to-query-device.patch +Patch6223: 0223-net-hns3-refactor-set-RSS-hash-algorithm-and-key-int.patch +Patch6224: 0224-net-hns3-fix-RSS-key-size-compatibility.patch +Patch6225: 0225-net-hns3-fix-clearing-RSS-configuration.patch +Patch6226: 0226-net-hns3-use-RSS-filter-list-to-check-duplicated-rul.patch +Patch6227: 0227-net-hns3-remove-useless-code-when-destroy-valid-RSS-.patch +Patch6228: 0228-net-hns3-fix-warning-on-flush-or-destroy-rule.patch +Patch6229: 0229-net-hns3-fix-config-struct-used-for-conversion.patch +Patch6230: 0230-net-hns3-fix-duplicate-RSS-rule-check.patch +Patch6231: 0231-net-hns3-fix-burst-mode-query-with-dummy-function.patch +Patch6232: 0232-net-hns3-add-debug-info-for-Rx-Tx-dummy-function.patch +Patch6233: 0233-net-hns3-remove-debug-condition-for-Tx-prepare.patch +Patch6234: 0234-net-hns3-separate-Tx-prepare-from-getting-Tx-functio.patch +Patch6235: 0235-net-hns3-make-getting-Tx-function-static.patch +Patch6236: 0236-net-hns3-extract-common-functions-to-set-Rx-Tx.patch +Patch6237: 0237-net-hns3-declare-flow-rule-keeping-capability.patch +Patch6238: 0238-app-testpmd-add-disable-flow-flush-option.patch +Patch6239: 0239-net-hns3-fix-possible-truncation-of-hash-key-when-co.patch +Patch6240: 0240-net-hns3-fix-possible-truncation-of-redirection-tabl.patch +Patch6241: 0241-net-hns3-use-hardware-config-to-report-hash-key.patch +Patch6242: 0242-net-hns3-use-hardware-config-to-report-hash-types.patch +Patch6243: 0243-net-hns3-use-hardware-config-to-report-redirection-t.patch +Patch6244: 0244-net-hns3-separate-setting-hash-algorithm.patch +Patch6245: 0245-net-hns3-separate-setting-hash-key.patch +Patch6246: 0246-net-hns3-separate-setting-redirection-table.patch +Patch6247: 0247-net-hns3-separate-setting-RSS-types.patch +Patch6248: 0248-net-hns3-separate-setting-and-clearing-RSS-rule.patch +Patch6249: 0249-net-hns3-use-new-RSS-rule-to-configure-hardware.patch +Patch6250: 0250-net-hns3-save-hash-algo-to-RSS-filter-list-node.patch +Patch6251: 0251-net-hns3-allow-adding-queue-buffer-size-hash-rule.patch +Patch6252: 0252-net-hns3-separate-flow-RSS-config-from-RSS-conf.patch +Patch6253: 0253-net-hns3-reimplement-hash-flow-function.patch +Patch6254: 0254-net-hns3-add-verification-of-RSS-types.patch +Patch6255: 0255-test-mbuf-fix-mbuf-reset-test.patch +Patch6256: 0256-examples-l3fwd-power-support-CPPC-cpufreq.patch +Patch6257: 0257-hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch +Patch6258: 0258-net-bonding-support-private-dump-operation.patch +Patch6259: 0259-net-bonding-add-LACP-info-dump.patch +Patch6260: 0260-net-virtio-support-private-dump.patch +Patch6261: 0261-net-vhost-support-private-dump.patch +Patch6262: 0262-app-testpmd-show-private-info-in-port-info.patch +Patch6263: 0263-app-testpmd-display-RSS-hash-key-of-flow-rule.patch +Patch6264: 0264-ethdev-fix-Rx-queue-telemetry-memory-leak-on-failure.patch +Patch6265: 0265-ethdev-fix-MAC-address-in-telemetry-device-info.patch +Patch6266: 0266-eventdev-eth_rx-fix-telemetry-Rx-stats-reset.patch +Patch6267: 0267-test-telemetry_data-refactor-for-maintainability.patch +Patch6268: 0268-test-telemetry_data-add-test-cases-for-character-esc.patch +Patch6269: 0269-usertools-telemetry-add-JSON-pretty-print.patch +Patch6270: 0270-telemetry-move-include-after-guard.patch +Patch6271: 0271-ethdev-fix-telemetry-data-truncation.patch +Patch6272: 0272-mempool-fix-telemetry-data-truncation.patch +Patch6273: 0273-cryptodev-fix-telemetry-data-truncation.patch +Patch6274: 0274-mem-fix-telemetry-data-truncation.patch +Patch6275: 0275-telemetry-support-adding-integer-as-hexadecimal.patch +Patch6276: 0276-ethdev-get-capabilities-from-telemetry-in-hexadecima.patch +Patch6277: 0277-mem-fix-hugepage-info-mapping.patch +Patch6278: 0278-raw-ifpga-base-fix-init-with-multi-process.patch +Patch6279: 0279-compressdev-fix-empty-devargs-parsing.patch +Patch6280: 0280-cryptodev-fix-empty-devargs-parsing.patch +Patch6281: 0281-net-hns3-fix-empty-devargs-parsing.patch +Patch6282: 0282-net-virtio-fix-empty-devargs-parsing.patch +Patch6283: 0283-dma-skeleton-fix-empty-devargs-parsing.patch +Patch6284: 0284-raw-skeleton-fix-empty-devargs-parsing.patch +Patch6285: 0285-net-hns3-simplify-hardware-checksum-offloading.patch +Patch6286: 0286-net-hns3-support-dump-media-type.patch +Patch6287: 0287-ethdev-fix-one-address-occupies-two-entries-in-MAC-a.patch +Patch6288: 0288-net-hns3-fix-never-set-MAC-flow-control.patch +Patch6289: 0289-net-hns3-add-flow-control-autoneg-for-fiber-port.patch +Patch6290: 0290-net-hns3-fix-variable-type-mismatch.patch +Patch6291: 0291-net-hns3-fix-Rx-multiple-firmware-reset-interrupts.patch +Patch6292: 0292-net-hns3-add-Tx-Rx-descriptor-logs.patch +Patch6293: 0293-net-hns3-fix-FEC-mode-for-200G-ports.patch +Patch6294: 0294-net-hns3-fix-FEC-mode-check-error.patch +Patch6295: 0295-net-hns3-fix-missing-FEC-capability.patch +Patch6296: 0296-ethdev-introduce-low-latency-RS-FEC.patch +Patch6297: 0297-app-testpmd-add-setting-and-querying-of-LLRS-FEC-mod.patch +Patch6298: 0298-net-hns3-add-LLRS-FEC-mode-support-for-200G-ports.patch +Patch6299: 0299-net-hns3-get-current-FEC-capability-from-firmware.patch +Patch6300: 0300-net-hns3-fix-RTC-time-on-initialization.patch +Patch6301: 0301-net-hns3-fix-RTC-time-after-reset.patch +Patch6302: 0302-net-hns3-uninitialize-PTP.patch +Patch6303: 0303-net-hns3-extract-PTP-to-its-own-header-file.patch +Patch6304: 0304-net-hns3-fix-mbuf-leakage-when-RxQ-started-during-re.patch +Patch6305: 0305-net-hns3-fix-mbuf-leakage-when-RxQ-started-after-res.patch +Patch6306: 0306-net-hns3-fix-device-start-return-value.patch +Patch6307: 0307-net-hns3-fix-uninitialized-variable.patch +Patch6308: 0308-net-hns3-refactor-code.patch +Patch6309: 0309-net-hns3-fix-inaccurate-log.patch +Patch6310: 0310-net-hns3-fix-redundant-line-break-in-log.patch +Patch6311: 0311-ethdev-add-API-to-check-if-queue-is-valid.patch +Patch6312: 0312-app-testpmd-fix-segment-fault-with-invalid-queue-ID.patch +Patch6313: 0313-net-hns3-fix-IMP-reset-trigger.patch +Patch6314: 0314-net-ixgbe-add-proper-memory-barriers-in-Rx.patch + +Patch9020: 0020-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch +Patch9021: 0021-gro-fix-gro-with-tcp-push-flag.patch +Patch9022: 0022-eal-loongarch-support-LoongArch-architecture.patch +Patch9023: 0023-example-l3fwd-masking-wrong-warning-array-subscript-.patch + +Patch6315: 0315-net-cnxk-fix-build-with-GCC-12.patch +Patch6316: 0316-net-cnxk-fix-build-with-optimization.patch +Patch6317: 0317-crypto-ipsec_mb-fix-build-with-GCC-12.patch +Patch6318: 0318-net-ena-fix-build-with-GCC-12.patch +Patch6319: 0319-net-enetfec-fix-build-with-GCC-12.patch +Patch6320: 0320-net-ice-fix-build-with-GCC-12.patch +Patch6321: 0321-vdpa-ifc-fix-build-with-GCC-12.patch +Patch6322: 0322-app-flow-perf-fix-build-with-GCC-12.patch +Patch6323: 0323-common-cpt-fix-build-with-GCC-12.patch +Patch6324: 0324-crypto-cnxk-fix-build-with-GCC-12.patch +Patch6325: 0325-test-ipsec-fix-build-with-GCC-12.patch +Patch6326: 0326-vhost-crypto-fix-build-with-GCC-12.patch +Patch6327: 0327-vhost-crypto-fix-descriptor-processing.patch +Patch6328: 0328-net-ice-base-fix-build-with-GCC-12.patch +Patch6329: 0329-net-qede-fix-build-with-GCC-12.patch +Patch6330: 0330-examples-performance-thread-fix-build-with-GCC-12.patch +Patch6331: 0331-net-mvneta-fix-build-with-GCC-12.patch +Patch6332: 0332-test-ipsec-fix-build-with-GCC-12.patch +Patch6333: 0333-ipsec-fix-build-with-GCC-12.patch +Patch6334: 0334-crypto-qat-fix-build-with-GCC-12.patch +Patch6335: 0335-vhost-fix-build-with-GCC-12.patch +Patch6336: 0336-net-i40e-fix-build-with-MinGW-GCC-12.patch +Patch6337: 0337-net-qede-base-fix-32-bit-build-with-GCC-12.patch +Patch6338: 0338-hash-fix-GFNI-implementation-build-with-GCC-12.patch +Patch6339: 0339-examples-cmdline-fix-build-with-GCC-12.patch +Patch6340: 0340-net-mlx5-fix-build-with-GCC-12-and-ASan.patch +Patch6341: 0341-pdump-fix-build-with-GCC-12.patch +Patch6342: 0342-net-cxgbe-fix-dangling-pointer-by-mailbox-access-rew.patch +Patch6343: 0343-kni-fix-build-with-Linux-6.3.patch +Patch6344: 0344-kni-fix-build-with-Linux-6.5.patch +Patch6345: 0345-doc-unify-sections-of-networking-drivers-guide.patch +Patch6346: 0346-net-hns3-delete-duplicate-macro-definition.patch +Patch6347: 0347-net-hns3-add-FDIR-VLAN-match-mode-runtime-config.patch +Patch6348: 0348-doc-fix-kernel-patch-link-in-hns3-guide.patch +Patch6349: 0349-doc-fix-syntax-in-hns3-guide.patch +Patch6350: 0350-doc-fix-number-of-leading-spaces-in-hns3-guide.patch Summary: Data Plane Development Kit core Group: System Environment/Libraries License: BSD and LGPLv2 and GPLv2 -ExclusiveArch: i686 x86_64 aarch64 -%ifarch aarch64 -%global machine armv8a -%global target arm64-%{machine}-linux-gcc -%global config arm64-%{machine}-linux-gcc -%else -%global machine native -%global target x86_64-%{machine}-linux-gcc -%global config x86_64-%{machine}-linux-gcc -%endif +ExclusiveArch: i686 x86_64 aarch64 loongarch64 -BuildRequires: gcc -BuildRequires: kernel-devel, libpcap-devel -BuildRequires: numactl-devel libconfig-devel rdma-core-devel -BuildRequires: module-init-tools uname-build-checks libnl3 libmnl -BuildRequires: glibc glibc-devel libibverbs libibverbs-devel libmnl-devel +BuildRequires: meson ninja-build gcc diffutils python3-pyelftools +BuildRequires: kernel-devel numactl-devel +BuildRequires: libpcap libpcap-devel +BuildRequires: rdma-core-devel +BuildRequires: uname-build-checks +BuildRequires: chrpath +BuildRequires: groff-base -Requires: python3-pyelftools +%define kern_devel_ver %(uname -r) +%define arch_type %(uname -m) -%define kern_devel_ver %(uname -r) %description DPDK core includes kernel modules, core libraries and tools. testpmd application allows to test fast packet processing environments @@ -102,8 +406,7 @@ More libraries are available as extensions in other packages. Summary: Data Plane Development Kit for development Requires: %{name}%{?_isa} = %{version}-%{release} %description devel -DPDK devel is a set of makefiles, headers and examples -for fast packet processing on arm64 platforms. +DPDK devel is a set of headers for fast packet processing on arm64 platforms. %package doc Summary: Data Plane Development Kit API documentation @@ -123,104 +426,98 @@ This package contains the pdump tool for capture the dpdk network packets. %autosetup -n %{name}-%{version} -p1 %build -namer=%{kern_devel_ver} -export RTE_KERNELDIR=/lib/modules/${namer}/build -export EXTRA_CFLAGS="-fstack-protector-strong -g" -make O=%{target} T=%{config} V=2 config -#make .a and .so libraries for spdk -sed -ri 's,(RTE_BUILD_BOTH_STATIC_AND_SHARED_LIBS=).*,\1y,' %{target}/.config -sed -ri 's,(CONFIG_RTE_LIB_LIBOS=).*,\1n,' %{target}/.config -sed -ri 's,(CONFIG_RTE_LIBRTE_MLX4_PMD=).*,\1y,' %{target}/.config -sed -ri 's,(CONFIG_RTE_LIBRTE_MLX5_PMD=).*,\1y,' %{target}/.config -sed -ri 's,(RTE_MACHINE=).*,\1%{machine},' %{target}/.config -sed -ri 's,(RTE_APP_TEST=).*,\1n,' %{target}/.config -sed -ri 's,(RTE_NEXT_ABI=).*,\1n,' %{target}/.config -sed -ri 's,(LIBRTE_VHOST=).*,\1y,' %{target}/.config -sed -ri 's,(LIBRTE_PMD_PCAP=).*,\1y,' %{target}/.config -make O=%{target} V=2 -j16 +export CFLAGS="%{optflags}" +%ifarch aarch64 +meson build -Dplatform=generic -Dexamples=l3fwd-power,ethtool,l3fwd,kni,dma,ptpclient -Ddisable_drivers='common/cnxk' +%else +meson build -Dplatform=generic -Dexamples=l3fwd-power,ethtool,l3fwd,kni,dma,ptpclient +%endif + +ninja -C build -v #build gazelle-pdump -cd %{target}/build/app/pdump -export GAZELLE_FLAGS="-lm -lpthread -lrt -lnuma -lconfig" -%ifarch x86_64 -export GAZELLE_FLAGS="${GAZELLE_FLAGS} -mssse3" +cd build/app/dpdk-pdump.p +export GAZELLE_FLAGS="-lm -lpthread -lrt -lnuma" +# Remove linking to i40e driver for LoongArch because it was not supported in this version +%if "%{arch_type}" == "loongarch64" +export GAZELLE_LIBS="-lrte_pci -lrte_bus_pci -lrte_cmdline -lrte_hash -lrte_mempool -lrte_mempool_ring -lrte_timer -lrte_eal -lrte_gro -lrte_ring -lrte_mbuf -lrte_telemetry -lrte_kni -lrte_net_ixgbe -lrte_kvargs -lrte_net_hinic -lrte_net_virtio -lrte_bus_vdev -lrte_net -lrte_rcu -lrte_ethdev -lrte_pdump -lrte_bpf -lrte_security -lrte_cryptodev -lrte_net_pcap -lrte_metrics" +%else +export GAZELLE_LIBS="-lrte_pci -lrte_bus_pci -lrte_cmdline -lrte_hash -lrte_mempool -lrte_mempool_ring -lrte_timer -lrte_eal -lrte_gro -lrte_ring -lrte_mbuf -lrte_telemetry -lrte_kni -lrte_net_ixgbe -lrte_kvargs -lrte_net_hinic -lrte_net_i40e -lrte_net_virtio -lrte_bus_vdev -lrte_net -lrte_rcu -lrte_ethdev -lrte_pdump -lrte_bpf -lrte_security -lrte_cryptodev -lrte_net_pcap -lrte_metrics" %endif -export GAZELLE_LIBS="-lrte_pci -lrte_bus_pci -lrte_cmdline -lrte_hash -lrte_mempool -lrte_mempool_ring -lrte_timer -lrte_eal -lrte_gro -lrte_ring -lrte_mbuf -lrte_kni -lrte_pmd_ixgbe -lrte_kvargs -lrte_pmd_hinic -lrte_pmd_i40e -lrte_pmd_virtio -lrte_bus_vdev -lrte_net -lrte_ethdev -lrte_pdump -lrte_pmd_pcap -lrte_metrics -lrte_cryptodev -lrte_security" export SECURE_OPTIONS="-fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -Wall -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fPIE -pie -fPIC -g" -gcc -o gazelle-pdump ${GAZELLE_FLAGS} ${SECURE_OPTIONS} -I../../../include -L../../../lib ${GAZELLE_LIBS} main.o +gcc -o gazelle-pdump ${GAZELLE_FLAGS} ${SOCURE_OPTIONS} -L../../drivers -L../../lib ${GAZELLE_LIBS} pdump_main.c.o cd - + %install -namer=%{kern_devel_ver} -rm -rf %{buildroot} -make install O=%{target} RTE_KERNELDIR=/lib/modules/${namer}/build \ - kerneldir=/lib/modules/${namer}/extra/dpdk DESTDIR=%{buildroot} \ - prefix=%{_prefix} bindir=%{_bindir} sbindir=%{_sbindir} \ - includedir=%{_includedir}/dpdk libdir=%{_libdir} \ - datadir=%{_datadir}/dpdk docdir=%{_docdir}/dpdk +DESTDIR=$RPM_BUILD_ROOT/ ninja install -C build -mkdir -p $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_eal.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_mempool.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_ring.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_mempool_ring.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_pci.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_bus_pci.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_kvargs.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_acl.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_ethdev.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_mbuf.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_cmdline.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_net.so* $RPM_BUILD_ROOT/lib64/ -cp -ar ./%{target}/lib/librte_meter.so* $RPM_BUILD_ROOT/lib64/ +chrpath -d ./build/examples/dpdk-l3fwd +chrpath -d ./build/examples/dpdk-l3fwd-power +chrpath -d ./build/examples/dpdk-ethtool +chrpath -d ./build/examples/dpdk-kni +chrpath -d ./build/examples/dpdk-dma +chrpath -d ./build/examples/dpdk-ptpclient +chrpath -d ./build/app/dpdk-pdump.p/gazelle-pdump -#make O=%{target} doc +cp ./build/examples/dpdk-l3fwd $RPM_BUILD_ROOT/usr/local/bin +cp ./build/examples/dpdk-l3fwd-power $RPM_BUILD_ROOT/usr/local/bin +cp ./build/examples/dpdk-ethtool $RPM_BUILD_ROOT/usr/local/bin +cp ./build/examples/dpdk-kni $RPM_BUILD_ROOT/usr/local/bin +cp ./build/examples/dpdk-dma $RPM_BUILD_ROOT/usr/local/bin +cp ./build/examples/dpdk-ptpclient $RPM_BUILD_ROOT/usr/local/bin +cp ./build/app/dpdk-pdump.p/gazelle-pdump $RPM_BUILD_ROOT/usr/local/bin -mkdir -p $RPM_BUILD_ROOT/usr/include/%{name}-%{version}/ -ln -s /usr/share/dpdk/mk $RPM_BUILD_ROOT/usr/include/%{name}-%{version}/ -ln -s /usr/share/dpdk/%{target} $RPM_BUILD_ROOT/usr/include/%{name}-%{version}/ +mkdir -p $RPM_BUILD_ROOT/usr/lib64 +mv $RPM_BUILD_ROOT/usr/local/lib64/* $RPM_BUILD_ROOT/usr/lib64/ -mkdir -p $RPM_BUILD_ROOT/usr/include/dpdk/ -ln -s /usr/share/dpdk/%{target} $RPM_BUILD_ROOT/usr/include/dpdk/ +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +ln -fs /usr/local/bin/dpdk-devbind.py $RPM_BUILD_ROOT/usr/local/bin/dpdk-devbind +mkdir $RPM_BUILD_ROOT/usr/lib64/dpdk/pmds-22.0/lib +mkdir $RPM_BUILD_ROOT/usr/lib64/dpdk/pmds-22.0/include +cd $RPM_BUILD_ROOT/usr/lib64/dpdk/pmds-22.0/include +ln -fs ../../../../local/include/* . +cd - +cd $RPM_BUILD_ROOT/usr/lib64/dpdk/pmds-22.0/lib +ln -fs ../../../*.so . +cd - -mkdir -p $RPM_BUILD_ROOT/usr/bin -cp ./%{target}/app/dpdk-pdump $RPM_BUILD_ROOT/usr/bin -cp ./%{target}/build/app/pdump/gazelle-pdump $RPM_BUILD_ROOT/usr/bin - -strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/igb_uio.ko -strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/rte_kni.ko +strip -g $RPM_BUILD_ROOT/lib/modules/%{kern_devel_ver}/extra/dpdk/rte_kni.ko +strip -g $RPM_BUILD_ROOT/lib/modules/%{kern_devel_ver}/extra/dpdk/igb_uio.ko %define _unpackaged_files_terminate_build 0 +%define _build_id_links none %files -%dir %{_datadir}/dpdk -%{_datadir}/dpdk/usertools/*.py -%{_datadir}/dpdk/usertools/*.sh -%{_sbindir}/dpdk-devbind -/lib/modules/%{kern_devel_ver}/extra/dpdk/* -/lib64/librte*.so* -%{_libdir}/*.so* +/usr/local/bin/*.py +/usr/local/bin/dpdk-devbind +/lib/modules/%{kern_devel_ver}/extra/dpdk/*.ko +/usr/lib64/*.so* +/usr/lib64/dpdk/* +%exclude /usr/lib64/dpdk/pmds-22.0/include/*.h %files devel -%{_includedir}/dpdk -%{_datadir}/dpdk/mk -%{_datadir}/dpdk/buildtools -%{_datadir}/dpdk/%{target} -%{_datadir}/dpdk/examples -%{_bindir}/* -%{_libdir}/*.a -%dir /usr/include/%{name}-%{version}/ -/usr/include/%{name}-%{version}/* -%dir /usr/include/dpdk/ -/usr/include/dpdk/* -%exclude /usr/bin/*-pdump +/usr/local/include +/usr/lib64/*.a +/usr/lib64/dpdk/pmds-22.0/include/*.h +/usr/lib64/pkgconfig/libdpdk-libs.pc +/usr/lib64/pkgconfig/libdpdk.pc %files doc -#%doc %{_docdir}/dpdk %files tools -/usr/bin/dpdk-pdump -/usr/bin/gazelle-pdump +/usr/local/bin/dpdk-pdump +/usr/local/bin/dpdk-dumpcap +/usr/local/bin/dpdk-proc-info +/usr/local/bin/dpdk-test +/usr/local/bin/dpdk-testpmd +/usr/local/bin/dpdk-l3fwd +/usr/local/bin/dpdk-l3fwd-power +/usr/local/bin/dpdk-ethtool +/usr/local/bin/dpdk-kni +/usr/local/bin/dpdk-dma +/usr/local/bin/dpdk-ptpclient +/usr/local/bin/gazelle-pdump %post /sbin/ldconfig @@ -231,6 +528,9 @@ strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/rte_kni.ko /usr/sbin/depmod %changelog +* Mon Oct 16 2023 chenyaqiang - 21.11-1 +- Update to 21.11 + * Fri Jun 30 2023 jiangheng - 19.11-31 - remove gazelle-proc-info, it function the same as gazellectl -x diff --git a/dpdk.yaml b/dpdk.yaml new file mode 100644 index 0000000..afb1e36 --- /dev/null +++ b/dpdk.yaml @@ -0,0 +1,5 @@ +version_control: git +src_repo: git://dpdk.org/dpdk-stable +tag_prefix: v +seperator: . + diff --git a/fix-pool-allocation.patch b/fix-pool-allocation.patch deleted file mode 100644 index 648bbee..0000000 --- a/fix-pool-allocation.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 3f2635c5a9c3df4ba7cc0d6598a2023569ca3d39 Mon Sep 17 00:00:00 2001 -From: Fan Zhang -Date: Tue, 14 Apr 2020 16:19:51 +0100 -Subject: vhost/crypto: fix pool allocation - -This patch fixes the missing iv space allocation in crypto -operation mempool. - -Fixes: 709521f4c2cd ("examples/vhost_crypto: support multi-core") -Cc: stable@dpdk.org - -Signed-off-by: Fan Zhang -Acked-by: Chenbo Xia ---- - examples/vhost_crypto/main.c | 2 +- - lib/librte_vhost/rte_vhost_crypto.h | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -diff --git a/examples/vhost_crypto/main.c b/examples/vhost_crypto/main.c -index 1d7ba94..11b022e 100644 ---- a/examples/vhost_crypto/main.c -+++ b/examples/vhost_crypto/main.c -@@ -544,7 +544,7 @@ main(int argc, char *argv[]) - snprintf(name, 127, "COPPOOL_%u", lo->lcore_id); - info->cop_pool = rte_crypto_op_pool_create(name, - RTE_CRYPTO_OP_TYPE_SYMMETRIC, NB_MEMPOOL_OBJS, -- NB_CACHE_OBJS, 0, -+ NB_CACHE_OBJS, VHOST_CRYPTO_MAX_IV_LEN, - rte_lcore_to_socket_id(lo->lcore_id)); - - if (!info->cop_pool) { -diff --git a/lib/librte_vhost/rte_vhost_crypto.h b/lib/librte_vhost/rte_vhost_crypto.h -index d29871c..866a592 100644 ---- a/lib/librte_vhost/rte_vhost_crypto.h -+++ b/lib/librte_vhost/rte_vhost_crypto.h -@@ -10,6 +10,7 @@ - #define VHOST_CRYPTO_SESSION_MAP_ENTRIES (1024) /**< Max nb sessions */ - /** max nb virtual queues in a burst for finalizing*/ - #define VIRTIO_CRYPTO_MAX_NUM_BURST_VQS (64) -+#define VHOST_CRYPTO_MAX_IV_LEN (32) - - enum rte_vhost_crypto_zero_copy { - RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE = 0, --- -cgit v1.0 diff --git a/fix-populate-with-small-virtual-chunks.patch b/fix-populate-with-small-virtual-chunks.patch deleted file mode 100644 index 95933a3..0000000 --- a/fix-populate-with-small-virtual-chunks.patch +++ /dev/null @@ -1,112 +0,0 @@ -From 43503c59adee6cae7069da23e105c24e044bf72c Mon Sep 17 00:00:00 2001 -From: Olivier Matz -Date: Fri, 17 Jan 2020 15:57:52 +0100 -Subject: mempool: fix populate with small virtual chunks - -To populate a mempool with a virtual area, the mempool code calls -rte_mempool_populate_iova() for each iova-contiguous area. It happens -(rarely) that this area is too small to store one object. In this case, -rte_mempool_populate_iova() returns an error, which is forwarded by -rte_mempool_populate_virt(). - -This case should not throw an error in rte_mempool_populate_virt(). -Instead, the area that is too small should just be ignored. - -To fix this issue, change the return value of -rte_mempool_populate_iova() to 0 when no object can be populated, -so it can be ignored by the caller. As this would be an API/ABI change, -only do this modification internally for now. - -Fixes: 354788b60cfd ("mempool: allow populating with unaligned virtual area") -Cc: stable@dpdk.org - -Signed-off-by: Olivier Matz -Tested-by: Anatoly Burakov -Tested-by: Alvin Zhang - -Conflict:NA -Reference:http://git.dpdk.org/dpdk/patch/?id=43503c59adee6cae7069da23e105c24e044bf72c -Signed-off-by:wuchangsheng ---- - lib/librte_mempool/rte_mempool.c | 30 +++++++++++++++++++++++++----- - 1 file changed, 25 insertions(+), 5 deletions(-) - -diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c -index aea5972..08906df 100644 ---- a/lib/librte_mempool/rte_mempool.c -+++ b/lib/librte_mempool/rte_mempool.c -@@ -297,8 +297,8 @@ mempool_ops_alloc_once(struct rte_mempool *mp) - * zone. Return the number of objects added, or a negative value - * on error. - */ --int --rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, -+static int -+__rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, - rte_iova_t iova, size_t len, rte_mempool_memchunk_free_cb_t *free_cb, - void *opaque) - { -@@ -332,7 +332,7 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, - off = RTE_PTR_ALIGN_CEIL(vaddr, RTE_MEMPOOL_ALIGN) - vaddr; - - if (off > len) { -- ret = -EINVAL; -+ ret = 0; - goto fail; - } - -@@ -343,7 +343,7 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, - - /* not enough room to store one object */ - if (i == 0) { -- ret = -EINVAL; -+ ret = 0; - goto fail; - } - -@@ -356,6 +356,21 @@ fail: - return ret; - } - -+int -+rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, -+ rte_iova_t iova, size_t len, rte_mempool_memchunk_free_cb_t *free_cb, -+ void *opaque) -+{ -+ int ret; -+ -+ ret = __rte_mempool_populate_iova(mp, vaddr, iova, len, free_cb, -+ opaque); -+ if (ret == 0) -+ ret = -EINVAL; -+ -+ return ret; -+} -+ - static rte_iova_t - get_iova(void *addr) - { -@@ -406,8 +421,10 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr, - break; - } - -- ret = rte_mempool_populate_iova(mp, addr + off, iova, -+ ret = __rte_mempool_populate_iova(mp, addr + off, iova, - phys_len, free_cb, opaque); -+ if (ret == 0) -+ continue; - if (ret < 0) - goto fail; - /* no need to call the free callback for next chunks */ -@@ -415,6 +432,9 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr, - cnt += ret; - } - -+ if (cnt == 0) -+ return -EINVAL; -+ - return cnt; - - fail: --- -cgit v1.0 diff --git a/fix-virtio-hardthrough-scenes-device-init-bug.patch b/fix-virtio-hardthrough-scenes-device-init-bug.patch deleted file mode 100644 index 3a5d5e9..0000000 --- a/fix-virtio-hardthrough-scenes-device-init-bug.patch +++ /dev/null @@ -1,45 +0,0 @@ -From c168e40a0b80b02976ed1698339bc5182b2c0f39 Mon Sep 17 00:00:00 2001 -From: root -Date: Sat, 3 Dec 2022 15:13:22 +0800 -Subject: [PATCH] fix virtio hardthrough scenes device init bug - ---- - drivers/net/virtio/virtio_ethdev.c | 1 + - drivers/net/virtio/virtio_pci.c | 2 ++ - 2 files changed, 3 insertions(+) - -diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c -index 89e4c23..b54abe5 100644 ---- a/drivers/net/virtio/virtio_ethdev.c -+++ b/drivers/net/virtio/virtio_ethdev.c -@@ -1331,6 +1331,7 @@ virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features) - req_features); - - /* Read device(host) feature bits */ -+ usleep(3000); - host_features = VTPCI_OPS(hw)->get_features(hw); - PMD_INIT_LOG(DEBUG, "host_features before negotiate = %" PRIx64, - host_features); -diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c -index 4468e89..2fade8f 100644 ---- a/drivers/net/virtio/virtio_pci.c -+++ b/drivers/net/virtio/virtio_pci.c -@@ -2,6 +2,7 @@ - * Copyright(c) 2010-2014 Intel Corporation - */ - #include -+#include - - #ifdef RTE_EXEC_ENV_LINUX - #include -@@ -472,6 +473,7 @@ vtpci_reset(struct virtio_hw *hw) - { - VTPCI_OPS(hw)->set_status(hw, VIRTIO_CONFIG_STATUS_RESET); - /* flush status write */ -+ usleep(1000); - VTPCI_OPS(hw)->get_status(hw); - } - --- -2.27.0 -