!529 upgrade to dpdk-23.11

From: @jiangheng12 
Reviewed-by: @LemmyHuang 
Signed-off-by: @LemmyHuang
This commit is contained in:
openeuler-ci-bot 2024-01-11 08:47:41 +00:00 committed by Gitee
commit 2f47ec2a85
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
435 changed files with 1178 additions and 60304 deletions

View File

@ -1,927 +0,0 @@
From b46793510b200c4120f03963252f7f54d23f6f8b Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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 <linux/device.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/uio_driver.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/msi.h>
+#include <linux/version.h>
+#include <linux/slab.h>
+
+/**
+ * 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 <bluca@debian.org>
+
+# 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

1039
0001-add-igb_uio.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,81 +0,0 @@
From a655c865fce412d7e661d866bde0df30607fb6a4 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,70 +0,0 @@
From 5134068ace9870203f3e25d9f7b48281582fafbd Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
Date: Fri, 12 Nov 2021 16:17:36 +0800
Subject: [PATCH] huawei-0003-dpdk-bugfix-the-deadlock-in-rte_eal_init
---
lib/eal/linux/eal.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
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;
__atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
- return -1;
+ goto out;
}
}
@@ -1169,7 +1169,7 @@ rte_eal_init(int argc, char **argv)
rte_eal_init_alert("Cannot init logging.");
rte_errno = ENOMEM;
__atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
- return -1;
+ goto out;
}
#ifdef VFIO_PRESENT
@@ -1177,7 +1177,7 @@ rte_eal_init(int argc, char **argv)
rte_eal_init_alert("Cannot init VFIO");
rte_errno = EAGAIN;
__atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
- return -1;
+ goto out;
}
#endif
/* in secondary processes, memory init may allocate additional fbarrays
@@ -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;
- return -1;
+ goto out;
}
if (rte_eal_memory_init() < 0) {
rte_eal_init_alert("Cannot init memory");
rte_errno = ENOMEM;
- return -1;
+ goto out;
}
/* the directories are locked during eal_hugepage_info_init */
@@ -1332,6 +1332,10 @@ rte_eal_init(int argc, char **argv)
eal_mcfg_complete();
return fctret;
+
+out:
+ eal_hugedirs_unlock();
+ return -1;
}
static int
--
2.27.0

View File

@ -1,27 +0,0 @@
From 1d18079dea84bd368605f851738f8f14b917c98d Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
Date: Thu, 16 Dec 2021 15:33:11 +0800
Subject: [PATCH] huawei-0004-dpdk-master-core-donot-set-affinity-in-libstorage
---
lib/eal/linux/eal.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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)
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 &&
+ 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.27.0

View File

@ -1,25 +0,0 @@
From e6009977b9ecb1136489b483e312a5e3e09a5497 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
Date: Fri, 12 Nov 2021 17:04:22 +0800
Subject: [PATCH] huawei-0005-dpdk-change-the-log-level-in-prepare_numa
---
lib/eal/linux/eal_memalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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,
oldmask->size + 1, 0, 0) < 0) {
- RTE_LOG(ERR, EAL,
+ RTE_LOG(DEBUG, EAL,
"Failed to get current mempolicy: %s. "
"Assuming MPOL_DEFAULT.\n", strerror(errno));
*oldpolicy = MPOL_DEFAULT;
--
2.27.0

View File

@ -1,34 +0,0 @@
From a76d953f02beecc057c96159e32e292b847b2d63 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
Date: Fri, 12 Nov 2021 17:18:23 +0800
Subject: [PATCH] huawei-0006-dpdk-fix-dpdk-coredump-problem
---
lib/eal/linux/eal_interrupts.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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) {
- rte_panic("Error adding fd to %d epoll_ctl, %s\n",
+ RTE_LOG(ERR, EAL, "Error adding fd to %d epoll_ctl, %s\n",
intr_pipe.readfd, strerror(errno));
}
numfds++;
@@ -1159,7 +1159,7 @@ eal_intr_thread_main(__rte_unused void *arg)
*/
if (epoll_ctl(pfd, EPOLL_CTL_ADD,
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",
rte_intr_fd_get(src->intr_handle),
strerror(errno));
}
--
2.27.0

View File

@ -1,28 +0,0 @@
From d0f302751a57cea1ee64261c749f59c4026f7af7 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +0,0 @@
From 9a4c67c47896fb9aa0fd8935813f2016b543a9df Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,61 +0,0 @@
From 097d8acb68c7d7dbfd7800c7f69eaf171ce9da4b Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,27 +0,0 @@
From dad8149d187448f85be497ce3bb6c34bf1ffde5e Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,42 +0,0 @@
From 8ca5f1cfbea80f7524eb2f2dfa67760be80666c3 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,29 +0,0 @@
From d9e578c64144bf35e3141d2a3f3ada2763534cb2 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,25 +0,0 @@
From 23113e9f48414f534358274a732921cd3f5345cf Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,55 +0,0 @@
From 847cbe34e8e45a0c0613cf5cd96f06ee31ada0f9 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,24 +0,0 @@
From e8466bb5c02192727a140688df0c8882ed35ca59 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
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

View File

@ -1,25 +0,0 @@
From 269be3f974c22f62892554dbb51fe859047058d7 Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
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

View File

@ -1,71 +0,0 @@
From ef72dacdec6c5dca8773854906159f7bc75eeb5c Mon Sep 17 00:00:00 2001
From: Chengchang Tang <tangchengchang@huawei.com>
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 <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,38 +0,0 @@
From 620b54f7d1c4bbf99d894ac3c8ddf3e73c29071f Mon Sep 17 00:00:00 2001
From: wu-changsheng <wuchangsheng2@huawei.com>
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

View File

@ -1,114 +0,0 @@
From 7ae766e2863868698a26a17f40995bd5ba02356d Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,40 +0,0 @@
From 12a22b874a4852996dcec56ae30c7a17551bfeeb Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
Date: Thu, 6 Oct 2022 16:35:16 +0800
Subject: [PATCH] reinit support return ok
---
lib/eal/linux/eal.c | 8 ++++++++
1 file changed, 8 insertions(+)
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 uint32_t run_once;
+ static uint32_t reinit_ok = 0;
uint32_t has_run = 0;
const char *p;
static char logid[PATH_MAX];
@@ -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 (!__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;
--
2.27.0

View File

@ -1,47 +0,0 @@
From b274c48fc01ed8fe854c285b02f1ac108bbf2721 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
---
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

View File

@ -1,32 +0,0 @@
From c02e48b92050856389403518be8bb70a4fdda551 Mon Sep 17 00:00:00 2001
From: jiangheng12 <jiangheng14@huawei.com>
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

View File

@ -1,85 +0,0 @@
From f541da70a5fdb553dc0cb71b3de54065dd245c2d Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
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,
only the packets that do not have PUSH flag can be GROed.
The packets that have a PUSH flag cannot be GROed, the packets
that cannot be processed by GRO are placed last.
In this case, the received packets may be out of order.
For example, there are two packets mbuf1 and mbuf2. mbuf1
contains PUSH flag, mbuf2 does not contain PUSH flag.
After GRO processing, mbuf2 is sent for processing before mbuf1.
This out-of-order will affect TCP processing performance and
lead to unnecessary dup-ACK.
Referring to the Linux kernel implementation, packets with PUSH
flag can also perform GRO. And if one of the packets containing
PUSH flag, the packets after GRO will carry PUSH flag.
Reference: https://mails.dpdk.org/archives/stable/2022-July/039759.html
---
lib/gro/gro_tcp4.c | 3 ++-
lib/gro/gro_tcp4.h | 16 +++++++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
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;
/*
- * Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE
+ * 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 | RTE_TCP_PSH_FLAG)))
return -1;
/* trim the tail padding bytes */
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)
{
struct rte_mbuf *pkt_head, *pkt_tail, *lastseg;
- uint16_t hdr_len, l2_len;
+ struct rte_tcp_hdr *head_tcp_hdr, *tail_tcp_hdr;
+ uint16_t hdr_len, l2_len, l3_offset;
if (cmp > 0) {
pkt_head = item->firstseg;
@@ -223,13 +224,22 @@ merge_two_tcp4_packets(struct gro_tcp4_item *item,
}
/* check if the IPv4 packet length is greater than the max value */
- hdr_len = l2_offset + pkt_head->l2_len + pkt_head->l3_len +
- pkt_head->l4_len;
+ l3_offset = l2_offset + pkt_head->l2_len + pkt_head->l3_len;
+ hdr_len = l3_offset + pkt_head->l4_len;
l2_len = l2_offset > 0 ? pkt_head->outer_l2_len : pkt_head->l2_len;
if (unlikely(pkt_head->pkt_len - l2_len + pkt_tail->pkt_len -
hdr_len > MAX_IPV4_PKT_LENGTH))
return 0;
+ /* merge push flag to pkt_head */
+ tail_tcp_hdr = rte_pktmbuf_mtod_offset(pkt_tail,
+ 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);
+ head_tcp_hdr->tcp_flags |= RTE_TCP_PSH_FLAG;
+ }
+
/* remove the packet header for the tail packet */
rte_pktmbuf_adj(pkt_tail, hdr_len);
--
2.27.0

View File

@ -1,237 +0,0 @@
From 17efba586961886bd96033965f3ce4d5dcb3367a Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
From b70e96833a753239454c660b71cbab6e0dcbbeae Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Sat, 22 Jan 2022 09:51:28 +0800
Subject: [PATCH] net/hns3: remove unnecessary assignment
Remove unnecessary assignment.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,46 +0,0 @@
From 2889419e10a68fad89df35350a1ea5e41e4cbf35 Mon Sep 17 00:00:00 2001
From: j00660176 <jiangheng14@huawei.com>
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 <anonymous>[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 <anonymous>[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

View File

@ -1,34 +0,0 @@
From 67d0b17947d6936147f4cbfff6ff938884f14776 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,205 +0,0 @@
From 2665a92054019bdb73cd2c43e5a581d081772915 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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,
- &eth_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,
- &eth_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

View File

@ -1,30 +0,0 @@
From 7be11baa6e5fd2143f5574403c44e45fc9c5e393 Mon Sep 17 00:00:00 2001
From: Jie Hai <haijie1@huawei.com>
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 <haijie1@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,49 +0,0 @@
From fbbcf80a9dc6d2f2d553b1c0b8762b5a35f4afc0 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,95 +0,0 @@
From f13c07a570fabe362b55d2e3643b5ff96513597f Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,77 +0,0 @@
From a65941e9c461bfc050778ed318a90e621d903163 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Sat, 22 Jan 2022 09:51:34 +0800
Subject: [PATCH] net/hns3: remove unused variables
Remove unused variables.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,107 +0,0 @@
From af1f62b3d1e6bf12830facbb0161981bdce6685d Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,79 +0,0 @@
From 5608b54756d91505e66e58c2562601b3f7e2fe80 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,145 +0,0 @@
From f5ed7d99cf45d550a69c1430b7c4a5623a9c774a Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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 <rte_alarm.h>
#include <rte_bus_pci.h>
#include <ethdev_pci.h>
-#include <rte_pci.h>
#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 <rte_alarm.h>
#include <ethdev_pci.h>
#include <rte_io.h>
-#include <rte_pci.h>
#include <rte_vfio.h>
#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

View File

@ -1,114 +0,0 @@
From 3340aa9f50da68f20d2cdb6382a9ab6891e7363c Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,30 +0,0 @@
From 2a1e7c4782ee21823eb37acbb073bcf9f73b173f Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,39 +0,0 @@
From 092ffe854dafe98f3e8e4c412211b80f6932315e Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,225 +0,0 @@
From c48499171f5df62a71697dce517b9fa22bc30985 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,367 +0,0 @@
From fdfcb94d8fb32364a999108baf1e4b835cd807fc Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,63 +0,0 @@
From dc55ce9c6253664160b881a1b83b2b4f1e90a587 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,57 +0,0 @@
From ca937bfe5f48de028c25312bcdb30ec1a6a4cd8e Mon Sep 17 00:00:00 2001
From: Lijun Ou <oulijun@huawei.com>
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 <oulijun@huawei.com>
---
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

View File

@ -1,271 +0,0 @@
From a29f3b66f858a7e2fabcb6b557aea7bde17d41fb Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,33 +0,0 @@
From eb0bbc8fbec6bb10dfcfdca470dc413038e8608c Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,57 +0,0 @@
From 1c73c33c5ff07ac2a369f0d796e5892ed504e0d3 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,35 +0,0 @@
From 6c3c017f980084daef4ddafd111e9ed9aa9619c3 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,130 +0,0 @@
From 905b76987bd194e1356e6fe79949b5119c30f842 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,36 +0,0 @@
From 2c1857b46ec66643f127301b9466a3b93fa2d42b Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,70 +0,0 @@
From 32d1817dbff6499dd1d126c466d0f7cb1c114713 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
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

View File

@ -1,129 +0,0 @@
From 42a26d7136b259ee7ff1b39325e19ef5ef9fe0e3 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
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 <rte_ethdev_core.h>
/**
--
2.30.0

View File

@ -1,90 +0,0 @@
From a91c0f253dd9b31cbe30bf5470a818aa0a909e26 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,174 +0,0 @@
From c79d78f63ba993a7fb45b7c842cfcfefb38ba5b6 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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 <rte_kvargs.h>
+#include <rte_bus_pci.h>
+#include <ethdev_pci.h>
+#include <rte_pci.h>
+
+#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

View File

@ -1,63 +0,0 @@
From 9bbea26d3c903f5741447a1b1a943d02b275af56 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,63 +0,0 @@
From 7041258cda77065d991d6ee8913edf110bd12531 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,254 +0,0 @@
From 698e42cb7ca963e34b2f8c7e1f9be98a7793bed3 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,180 +0,0 @@
From 05e415e929a404187f6b595a0b0f1ea958c1ca12 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,119 +0,0 @@
From ca1080fde102a1b9de5781e0919a5342b6151bd3 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,188 +0,0 @@
From f612c76b724c499f870026ec3deda07f0de13543 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,165 +0,0 @@
From e5e64a038775d3c7bd8f412fe9d814c8dfe795eb Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,35 +0,0 @@
From 297a29aa8a27e93b2fa1fdc40a4964f0fbbaa4ec Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,680 +0,0 @@
From d2c737bb909c52de76246d9c74944d96c5e7792f Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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 <rte_kvargs.h>
-#include <rte_bus_pci.h>
-#include <ethdev_pci.h>
-#include <rte_pci.h>
+#include <rte_malloc.h>
+#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

View File

@ -1,31 +0,0 @@
From fe0c1c3ea1023ecece4bf5f5ef99a014fcb182b8 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,28 +0,0 @@
From b757a6bf3bef31517f3799fa5a0426e38da04a71 Mon Sep 17 00:00:00 2001
From: Min Hu <humin29@huawei.com>
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 <humin29@huawei.com>
---
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

View File

@ -1,29 +0,0 @@
From 288da934034f84ab87b9e0d087db7e1e3c88bc8a Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
---
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

View File

@ -1,182 +0,0 @@
From 0ac9cae2d0e1763cf884f0b5d735e4b57b6acb27 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
---
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

View File

@ -1,35 +0,0 @@
From 2265601837805a2fc70dd5935ffe3f2ccaec17d1 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
---
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

View File

@ -1,112 +0,0 @@
From dd69081182fae0a65606e8d8b509aa46795b7cfa Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
---
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

View File

@ -1,78 +0,0 @@
From 410c9bc8354b4cccc3ae56608ca5f89f03e53cb3 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
---
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

View File

@ -1,79 +0,0 @@
From 033904450b1d52fd3d09e2bb53e529e3ba0ecf77 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
---
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

View File

@ -1,38 +0,0 @@
From d8c079a572f3b76ca22fbfe665fb2e5e578ba881 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
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

View File

@ -1,32 +0,0 @@
From 73d16d660b866aa209dcdc44a698427dac5f2eb7 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
---
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

View File

@ -1,169 +0,0 @@
From d57f2899e29a74fffeb876863e1f570084d6437b Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
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

View File

@ -1,31 +0,0 @@
From 0983cdc1870f52a360eadb40eab84b34c20b464d Mon Sep 17 00:00:00 2001
From: Jie Hai <haijie1@huawei.com>
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 <haijie1@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,35 +0,0 @@
From cdb9a7ae5f8f3b59b6de9dc2b52387636245e3a5 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,103 +0,0 @@
From 87f9628e2c786dff500139baf59720693e46b0bc Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,51 +0,0 @@
From d6a9f8fb26b8d6adaac20d6a303faa5c5ba4d5bc Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,56 +0,0 @@
From f5e72e8e8d57b331baf1a86d15eb7fae921f57fb Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,37 +0,0 @@
From 1c5c6cd85f8cab2af92d265b6c7671df0b82e6fb Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,186 +0,0 @@
From 1a1de9879f58b4fd202ecd481c56ae9777207fe9 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,432 +0,0 @@
From dd4cf775f6c2f7dc18c6845983bc84c6351326c4 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,45 +0,0 @@
From ec0147b5690e6cae2cc4555f78b87defee59c946 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,50 +0,0 @@
From 2d287ea3c2301219c201617df15efa161deabf76 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,214 +0,0 @@
From 75ccc3f3d7fa06901d5b768448be4dc9f31f550a Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,75 +0,0 @@
From 07f64b5f576a779c8c3df4ba45ad70c306dcb562 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,136 +0,0 @@
From 7a036b213b972e2c90e349f1eb90a30b98a740b4 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,70 +0,0 @@
From 93e1ea6dfa99dea359b8d66123576a395c2c0acd Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
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

View File

@ -1,103 +0,0 @@
From ec1691494273ef4f9cb60ed24099196de1ce0cc4 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
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

View File

@ -1,96 +0,0 @@
From baef6bbfad1b9596c7051f5c1fcc308310296342 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
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) <humin29@huawei.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
---
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

View File

@ -1,110 +0,0 @@
From f0b3966a5072bd0a6c7f7e8652aef793afa4f4d0 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
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

View File

@ -1,152 +0,0 @@
From 82a85bc3c90744e171e0a16330685c4fd8c86a4a Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
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 <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
Acked-by: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>
---
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 <process.h>
#endif
+#ifdef RTE_NET_BOND
+#include <rte_eth_bond.h>
+#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

View File

@ -1,79 +0,0 @@
From 21658b863d246055c225286d9bce8a0a884fc9d9 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
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

View File

@ -1,50 +0,0 @@
From a6cce2fd3fb2eda175989fd4a6dbfdd470a08189 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
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

View File

@ -1,58 +0,0 @@
From ae08d50d862073a8c53ed7ab4159f3125595667b Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
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

View File

@ -1,43 +0,0 @@
From 15b2772cfbdc62631556222a1c15491125b14e2f Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
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

View File

@ -1,61 +0,0 @@
From ae30c4a7b550e0ac12857279c0a337d80f73261c Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
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

View File

@ -1,56 +0,0 @@
From fc8702a84b7e794ab95aac021aa2cc3b4c92c5cd Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
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

View File

@ -1,35 +0,0 @@
From 30aa792dda9b9e361f1d00012304ee78472c80f6 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
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

Some files were not shown because too many files have changed in this diff Show More