From d75d39c8e84beeba0c67c2c1b08dc37044225d07 Mon Sep 17 00:00:00 2001 From: chenjiji09 Date: Tue, 17 Jan 2023 09:18:33 +0800 Subject: [PATCH] net/hns3: fix inaccurate RTC time to read The sequence of reading current RTC time register doesn't meet the hardware requirements, which causes this time obtained is the one before modifying RTC time. --- 0215-kni-fix-build-with-Linux-5.18.patch | 53 +++++++++++ ...d-function-to-set-random-MAC-address.patch | 49 ++++++++++ ...edicated-function-to-set-MAC-address.patch | 89 +++++++++++++++++++ ...io-fix-build-for-switch-fall-through.patch | 78 ++++++++++++++++ ...nux-igb_uio-fix-build-with-liux-5.18.patch | 38 ++++++++ ...hns3-fix-inaccurate-RTC-time-to-read.patch | 53 +++++++++++ dpdk.spec | 14 ++- 7 files changed, 373 insertions(+), 1 deletion(-) create mode 100644 0215-kni-fix-build-with-Linux-5.18.patch create mode 100644 0216-kni-use-dedicated-function-to-set-random-MAC-address.patch create mode 100644 0217-kni-use-dedicated-function-to-set-MAC-address.patch create mode 100644 0218-linux-igb_uio-fix-build-for-switch-fall-through.patch create mode 100644 0219-linux-igb_uio-fix-build-with-liux-5.18.patch create mode 100644 0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch diff --git a/0215-kni-fix-build-with-Linux-5.18.patch b/0215-kni-fix-build-with-Linux-5.18.patch new file mode 100644 index 0000000..30822d1 --- /dev/null +++ b/0215-kni-fix-build-with-Linux-5.18.patch @@ -0,0 +1,53 @@ +From 3aeeea257f187e4a05e3a7f70915c82808fb0ee8 Mon Sep 17 00:00:00 2001 +From: Jiri Slaby +Date: Wed, 1 Jun 2022 08:53:58 +0200 +Subject: [PATCH] kni: fix build with Linux 5.18 + +[ upstream commit c98600d4bed6d15599e448990f2ba117ca938a2d ] + +Since commit 2655926aea9b (net: Remove netif_rx_any_context() and +netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() +can be called from any context. So define HAVE_NETIF_RX_NI for older +releases and call the appropriate function in kni_net. + +netif_rx_ni() must be used on older kernel since netif_rx() might +might lead to deadlocks or other problems there. + +Signed-off-by: Jiri Slaby +Reviewed-by: Andrew Rybchenko +--- + kernel/linux/kni/compat.h | 4 ++++ + kernel/linux/kni/kni_net.c | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h +index 664785674f..0db29a4a6f 100644 +--- a/kernel/linux/kni/compat.h ++++ b/kernel/linux/kni/compat.h +@@ -141,3 +141,7 @@ + #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE + #define HAVE_TSK_IN_GUP + #endif ++ ++#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE ++#define HAVE_NETIF_RX_NI ++#endif +diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c +index 29e5b9e21f..a8b092b756 100644 +--- a/kernel/linux/kni/kni_net.c ++++ b/kernel/linux/kni/kni_net.c +@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni) + skb->ip_summed = CHECKSUM_UNNECESSARY; + + /* Call netif interface */ ++#ifdef HAVE_NETIF_RX_NI + netif_rx_ni(skb); ++#else ++ netif_rx(skb); ++#endif + + /* Update statistics */ + dev->stats.rx_bytes += len; +-- +2.23.0 + diff --git a/0216-kni-use-dedicated-function-to-set-random-MAC-address.patch b/0216-kni-use-dedicated-function-to-set-random-MAC-address.patch new file mode 100644 index 0000000..04362df --- /dev/null +++ b/0216-kni-use-dedicated-function-to-set-random-MAC-address.patch @@ -0,0 +1,49 @@ +From 9b7982b9867a3c28728f73678ff9cf497dde72f3 Mon Sep 17 00:00:00 2001 +From: Ke Zhang +Date: Wed, 8 Jun 2022 15:11:16 +0300 +Subject: [PATCH] kni: use dedicated function to set random MAC address +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit 2ee8c67ef9399759cb0d3f34b2c9fb6ea0ecc832 ] + +eth_hw_addr_random() sets address type correctly. + +eth_hw_addr_random() is available since Linux v3.4, so +no compat is required. + +Also fix the warning: +warning: passing argument 1 of ‘memcpy’ discards ‘const’ +qualifier from pointer target type + +Variable dev_addr is done const intentionally in Linux v5.17 to +prevent using it directly. + +Fixes: ea6b39b5b847 ("kni: remove ethtool support") + +Signed-off-by: Ke Zhang +Signed-off-by: Andrew Rybchenko +Acked-by: Ferruh Yigit +--- + kernel/linux/kni/kni_misc.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c +index ad1582d911..38fcd7f4f2 100644 +--- a/kernel/linux/kni/kni_misc.c ++++ b/kernel/linux/kni/kni_misc.c +@@ -407,8 +407,8 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, + if (is_valid_ether_addr(dev_info.mac_addr)) + memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN); + else +- /* Generate random MAC address. */ +- eth_random_addr(net_dev->dev_addr); ++ /* Assign random MAC address. */ ++ eth_hw_addr_random(net_dev); + + if (dev_info.mtu) + net_dev->mtu = dev_info.mtu; +-- +2.23.0 + diff --git a/0217-kni-use-dedicated-function-to-set-MAC-address.patch b/0217-kni-use-dedicated-function-to-set-MAC-address.patch new file mode 100644 index 0000000..f001986 --- /dev/null +++ b/0217-kni-use-dedicated-function-to-set-MAC-address.patch @@ -0,0 +1,89 @@ +From 4cfe56040171e791b021d5490f8fd58c55b088fb Mon Sep 17 00:00:00 2001 +From: Ke Zhang +Date: Wed, 8 Jun 2022 15:11:17 +0300 +Subject: [PATCH] kni: use dedicated function to set MAC address +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit b99bd4a0aacab47165d045a6aeee88ee74744600 ] + +The warning info: +warning: passing argument 1 of ‘memcpy’ discards ‘const’ +qualifier from pointer target type + +Variable dev_addr is done const intentionally in v5.17 to prevent using +it directly. See the following Linux kernel changeset for details: + +commit adeef3e32146 ("net: constify netdev->dev_addr") + +Used helper function was introduced earlier in v5.15. + +Fixes: ea6b39b5b847 ("kni: remove ethtool support") + +Signed-off-by: Ke Zhang +Signed-off-by: Andrew Rybchenko +Acked-by: Ferruh Yigit +--- + kernel/linux/kni/compat.h | 4 ++++ + kernel/linux/kni/kni_misc.c | 9 +++++++-- + kernel/linux/kni/kni_net.c | 4 ++++ + 3 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h +index 0db29a4a6f..3a86d12bbc 100644 +--- a/kernel/linux/kni/compat.h ++++ b/kernel/linux/kni/compat.h +@@ -142,6 +142,10 @@ + #define HAVE_TSK_IN_GUP + #endif + ++#if KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE ++#define HAVE_ETH_HW_ADDR_SET ++#endif ++ + #if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE + #define HAVE_NETIF_RX_NI + #endif +diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c +index 38fcd7f4f2..feed12b568 100644 +--- a/kernel/linux/kni/kni_misc.c ++++ b/kernel/linux/kni/kni_misc.c +@@ -404,11 +404,16 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, + pr_debug("mbuf_size: %u\n", kni->mbuf_size); + + /* if user has provided a valid mac address */ +- if (is_valid_ether_addr(dev_info.mac_addr)) ++ if (is_valid_ether_addr(dev_info.mac_addr)) { ++#ifdef HAVE_ETH_HW_ADDR_SET ++ eth_hw_addr_set(net_dev, dev_info.mac_addr); ++#else + memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN); +- else ++#endif ++ } else { + /* Assign random MAC address. */ + eth_hw_addr_random(net_dev); ++ } + + if (dev_info.mtu) + net_dev->mtu = dev_info.mtu; +diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c +index 41805fcabf..779ee3451a 100644 +--- a/kernel/linux/kni/kni_net.c ++++ b/kernel/linux/kni/kni_net.c +@@ -783,7 +783,11 @@ kni_net_set_mac(struct net_device *netdev, void *p) + return -EADDRNOTAVAIL; + + memcpy(req.mac_addr, addr->sa_data, netdev->addr_len); ++#ifdef HAVE_ETH_HW_ADDR_SET ++ eth_hw_addr_set(netdev, addr->sa_data); ++#else + memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); ++#endif + + ret = kni_net_process_request(netdev, &req); + +-- +2.23.0 + diff --git a/0218-linux-igb_uio-fix-build-for-switch-fall-through.patch b/0218-linux-igb_uio-fix-build-for-switch-fall-through.patch new file mode 100644 index 0000000..3ab65bb --- /dev/null +++ b/0218-linux-igb_uio-fix-build-for-switch-fall-through.patch @@ -0,0 +1,78 @@ +From e68a705cc5dc3d1333bbcd722fe4e9a6ba3ee648 Mon Sep 17 00:00:00 2001 +From: Ferruh Yigit +Date: Thu, 16 Dec 2021 12:03:49 +0000 +Subject: [PATCH] linux/igb_uio: fix build for switch fall through + +Linux is using '-Wimplicit-fallthrough=5' compiler option, which doesn't +take any fall through comments into account but only uses compiler +'fallthrough' attribute to document fall through action is intended. + +"falls through" comment was used in the code which is causing a build +error now, this patch converts comment to the 'fallthrough' macro +defined in the Linux. + +To cover the case where an old Linux version doesn't have the macro, +defined it in the compatibility header too. + +Signed-off-by: Ferruh Yigit +--- + linux/igb_uio/compat.h | 14 ++++++++++++++ + linux/igb_uio/igb_uio.c | 6 +++--- + 2 files changed, 17 insertions(+), 3 deletions(-) + +diff --git a/kernel/linux/igb_uio/compat.h b/kernel/linux/igb_uio/compat.h +index 8dbb896..71172f4 100644 +--- a/kernel/linux/igb_uio/compat.h ++++ b/kernel/linux/igb_uio/compat.h +@@ -152,3 +152,17 @@ static inline bool igbuio_kernel_is_locked_down(void) + return false; + #endif + } ++ ++#ifndef fallthrough ++ ++#ifndef __has_attribute ++#define __has_attribute(x) 0 ++#endif ++ ++#if __has_attribute(__fallthrough__) ++#define fallthrough __attribute__((__fallthrough__)) ++#else ++#define fallthrough do {} while (0) /* fallthrough */ ++#endif ++ ++#endif +diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c +index ea439d1..33e0e02 100644 +--- a/kernel/linux/igb_uio/igb_uio.c ++++ b/kernel/linux/igb_uio/igb_uio.c +@@ -250,7 +250,7 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) + } + #endif + +- /* falls through - to MSI */ ++ fallthrough; + case RTE_INTR_MODE_MSI: + #ifndef HAVE_ALLOC_IRQ_VECTORS + if (pci_enable_msi(udev->pdev) == 0) { +@@ -269,7 +269,7 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) + break; + } + #endif +- /* falls through - to INTX */ ++ fallthrough; + case RTE_INTR_MODE_LEGACY: + if (pci_intx_mask_supported(udev->pdev)) { + dev_dbg(&udev->pdev->dev, "using INTX"); +@@ -279,7 +279,7 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) + break; + } + dev_notice(&udev->pdev->dev, "PCI INTX mask not supported\n"); +- /* falls through - to no IRQ */ ++ fallthrough; + case RTE_INTR_MODE_NONE: + udev->mode = RTE_INTR_MODE_NONE; + udev->info.irq = UIO_IRQ_NONE; +-- +2.23.0 + diff --git a/0219-linux-igb_uio-fix-build-with-liux-5.18.patch b/0219-linux-igb_uio-fix-build-with-liux-5.18.patch new file mode 100644 index 0000000..d0a7f2e --- /dev/null +++ b/0219-linux-igb_uio-fix-build-with-liux-5.18.patch @@ -0,0 +1,38 @@ +From ca5ef06359c9deb513d6817610e5d8ba18f86279 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Mon, 30 Jan 2023 10:37:47 +0800 +Subject: [PATCH] linux/igb_uio: fix build with linux 5.18 + +--- + kernel/linux/igb_uio/igb_uio.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c +index ea439d1..194a5ff 100644 +--- a/kernel/linux/igb_uio/igb_uio.c ++++ b/kernel/linux/igb_uio/igb_uio.c +@@ -512,13 +512,21 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) + goto fail_release_iomem; + + /* set 64-bit DMA mask */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) + err = pci_set_dma_mask(dev, DMA_BIT_MASK(64)); ++#else ++ err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)); ++#endif + if (err != 0) { + dev_err(&dev->dev, "Cannot set DMA mask\n"); + goto fail_release_iomem; + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) + err = pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(64)); ++#else ++ err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)); ++#endif + if (err != 0) { + dev_err(&dev->dev, "Cannot set consistent DMA mask\n"); + goto fail_release_iomem; +-- +2.23.0 + diff --git a/0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch b/0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch new file mode 100644 index 0000000..59a0c08 --- /dev/null +++ b/0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch @@ -0,0 +1,53 @@ +From 3cd01cd12d4987b76be0ff1b25bc21a558aab6f1 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Mon, 9 Jan 2023 16:23:44 +0800 +Subject: net/hns3: fix inaccurate RTC time to read + +[ upstream commit 4243282181f38d387188af5fd38a5428864a94a2 ] + +The sequence of reading current RTC time register doesn't meet +the hardware requirements, which causes this time obtained is +the one before modifying RTC time. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Acked-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ptp.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index 6bbd85ba23..db3c007b12 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -216,17 +216,21 @@ hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev, + int + hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts) + { ++#define HNS3_PTP_SEC_H_OFFSET 32 ++#define HNS3_PTP_SEC_H_MASK 0xFFFF ++ + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ uint32_t sec_hi, sec_lo; + uint64_t ns, sec; + + if (!hns3_dev_get_support(hw, PTP)) + return -ENOTSUP; + +- sec = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_L); +- sec |= (uint64_t)(hns3_read_dev(hw, HNS3_CURR_TIME_OUT_H) & 0xFFFF) +- << 32; +- + ns = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_NS); ++ sec_hi = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_H) & HNS3_PTP_SEC_H_MASK; ++ sec_lo = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_L); ++ sec = ((uint64_t)sec_hi << HNS3_PTP_SEC_H_OFFSET) | sec_lo; ++ + ns += sec * NSEC_PER_SEC; + *ts = rte_ns_to_timespec(ns); + +-- +2.23.0 + diff --git a/dpdk.spec b/dpdk.spec index 708bdad..649f53e 100644 --- a/dpdk.spec +++ b/dpdk.spec @@ -1,6 +1,6 @@ Name: dpdk Version: 21.11 -Release: 27 +Release: 29 Packager: packaging@6wind.com URL: http://dpdk.org %global source_version 21.11 @@ -232,6 +232,12 @@ Patch9211: 0211-app-procinfo-dump-module-EEPROM-info.patch Patch9212: 0212-app-procinfo-add-burst-mode-to-Rx-Tx-queue-info.patch Patch9213: 0213-app-procinfo-dump-detailed-info-for-Rx-Tx-descriptor.patch Patch9214: 0214-dma-hisilicon-support-vchan-status-query.patch +Patch9215: 0215-kni-fix-build-with-Linux-5.18.patch +Patch9216: 0216-kni-use-dedicated-function-to-set-random-MAC-address.patch +Patch9217: 0217-kni-use-dedicated-function-to-set-MAC-address.patch +Patch9218: 0218-linux-igb_uio-fix-build-for-switch-fall-through.patch +Patch9219: 0219-linux-igb_uio-fix-build-with-liux-5.18.patch +Patch9220: 0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch Summary: Data Plane Development Kit core Group: System Environment/Libraries @@ -374,6 +380,12 @@ strip -g $RPM_BUILD_ROOT/lib/modules/%{kern_devel_ver}/extra/dpdk/igb_uio.ko /usr/sbin/depmod %changelog +* Tue Jan 31 2023 chenjiji - 21.11-29 +- net/hns3: fix inaccurate RTC time to read + +* Wed Jan 18 2023 jiangheng - 21.11-28 +- fix build failed due to kernel upgrate to 6.1 + * Wed Dec 14 2022 chenjiji - 21.11-27 - dma/hisilicon: support vchan status query -- Gitee