diff --git a/0086-app-testpmd-fix-port-status-of-bonding-slave-device.patch b/0086-app-testpmd-fix-port-status-of-bonding-slave-device.patch new file mode 100644 index 0000000000000000000000000000000000000000..170317a220a559aec0b5eb25e639657de411aefb --- /dev/null +++ b/0086-app-testpmd-fix-port-status-of-bonding-slave-device.patch @@ -0,0 +1,152 @@ +From 82a85bc3c90744e171e0a16330685c4fd8c86a4a Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 11 May 2022 10:14:34 +0800 +Subject: [PATCH 086/122] app/testpmd: fix port status of bonding slave device + +Starting or stopping a bonded port also starts or stops all active slaves +under the bonded port. If this port is a bonded device, we need to modify +the port status of all slaves. + +Fixes: 0e545d3047fe ("app/testpmd: check stopping port is not in bonding") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Acked-by: Aman Singh +Acked-by: Konstantin Ananyev +--- + app/test-pmd/cmdline.c | 1 + + app/test-pmd/testpmd.c | 73 +++++++++++++++++++++++++++++++++++++++--- + app/test-pmd/testpmd.h | 3 +- + 3 files changed, 72 insertions(+), 5 deletions(-) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 969a333c93..1991ee3446 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -6660,6 +6660,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result, + "Failed to enable promiscuous mode for port %u: %s - ignore\n", + port_id, rte_strerror(-ret)); + ++ ports[port_id].bond_flag = 1; + ports[port_id].need_setup = 0; + ports[port_id].port_status = RTE_PORT_STOPPED; + } +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index f9c025f97e..c4be9abe73 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -66,6 +66,9 @@ + #ifdef RTE_EXEC_ENV_WINDOWS + #include + #endif ++#ifdef RTE_NET_BOND ++#include ++#endif + + #include "testpmd.h" + +@@ -591,11 +594,58 @@ eth_dev_configure_mp(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, + return 0; + } + ++static int ++change_bonding_slave_port_status(portid_t bond_pid, bool is_stop) ++{ ++#ifdef RTE_NET_BOND ++ ++ portid_t slave_pids[RTE_MAX_ETHPORTS]; ++ struct rte_port *port; ++ int num_slaves; ++ portid_t slave_pid; ++ int i; ++ ++ num_slaves = rte_eth_bond_slaves_get(bond_pid, slave_pids, ++ RTE_MAX_ETHPORTS); ++ if (num_slaves < 0) { ++ fprintf(stderr, "Failed to get slave list for port = %u\n", ++ bond_pid); ++ return num_slaves; ++ } ++ ++ for (i = 0; i < num_slaves; i++) { ++ slave_pid = slave_pids[i]; ++ port = &ports[slave_pid]; ++ port->port_status = ++ is_stop ? RTE_PORT_STOPPED : RTE_PORT_STARTED; ++ } ++#else ++ RTE_SET_USED(bond_pid); ++ RTE_SET_USED(is_stop); ++#endif ++ return 0; ++} ++ + static int + eth_dev_start_mp(uint16_t port_id) + { +- if (is_proc_primary()) +- return rte_eth_dev_start(port_id); ++ int ret; ++ ++ if (is_proc_primary()) { ++ ret = rte_eth_dev_start(port_id); ++ if (ret != 0) ++ return ret; ++ ++ struct rte_port *port = &ports[port_id]; ++ ++ /* ++ * Starting a bonded port also starts all slaves under the bonded ++ * device. So if this port is bond device, we need to modify the ++ * port status of these slaves. ++ */ ++ if (port->bond_flag == 1) ++ return change_bonding_slave_port_status(port_id, false); ++ } + + return 0; + } +@@ -603,8 +653,23 @@ eth_dev_start_mp(uint16_t port_id) + static int + eth_dev_stop_mp(uint16_t port_id) + { +- if (is_proc_primary()) +- return rte_eth_dev_stop(port_id); ++ int ret; ++ ++ if (is_proc_primary()) { ++ ret = rte_eth_dev_stop(port_id); ++ if (ret != 0) ++ return ret; ++ ++ struct rte_port *port = &ports[port_id]; ++ ++ /* ++ * Stopping a bonded port also stops all slaves under the bonded ++ * device. So if this port is bond device, we need to modify the ++ * port status of these slaves. ++ */ ++ if (port->bond_flag == 1) ++ return change_bonding_slave_port_status(port_id, true); ++ } + + return 0; + } +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 2149ecd93a..9c24cb07e0 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -242,7 +242,8 @@ struct rte_port { + struct rte_eth_txconf tx_conf[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue tx configuration */ + struct rte_ether_addr *mc_addr_pool; /**< pool of multicast addrs */ + uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */ +- uint8_t slave_flag; /**< bonding slave port */ ++ uint8_t slave_flag : 1, /**< bonding slave port */ ++ bond_flag : 1; /**< port is bond device */ + struct port_flow *flow_list; /**< Associated flows. */ + struct port_indirect_action *actions_list; + /**< Associated indirect actions. */ +-- +2.22.0 + diff --git a/0087-ethdev-clarify-null-location-case-in-xstats-get.patch b/0087-ethdev-clarify-null-location-case-in-xstats-get.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2b5f9733a8fb50af15d615ac0f367ff58e9ee12 --- /dev/null +++ b/0087-ethdev-clarify-null-location-case-in-xstats-get.patch @@ -0,0 +1,79 @@ +From 21658b863d246055c225286d9bce8a0a884fc9d9 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:49 +0800 +Subject: [PATCH 087/122] ethdev: clarify null location case in xstats get +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When xstats location is null in rte_eth_xstats_get() the return value +is not clearly specified. Some PMDs (eg. hns3/ipn3ke/mvpp2/axgbe) return +zero while others return the required number of elements. + +In this patch, special parameter combinations are restricted: + 1. highlight that xstats location may be null if and only if n is 0. + 2. amend n parameter description to specify that if n is lower than + the required number of elements, the function returns the required + number of elements. + 3. specify that if n is zero, the xstats must be NULL, the function + returns the required number of elements (a duplicate which should + help to not very attentive readers). + +Add sanity check for null xstats and non-zero n case on API level to +make it unnecessary to care about it in drivers. + +Fixes: ce757f5c9a4d ("ethdev: new method to retrieve extended statistics") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 4 +++- + lib/ethdev/rte_ethdev.h | 6 +++++- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index cea2f0b498..b4a331b671 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -3319,6 +3319,8 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + int ret; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); ++ if (xstats == NULL && n > 0) ++ return -EINVAL; + dev = &rte_eth_devices[port_id]; + + nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); +@@ -3335,7 +3337,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + * xstats struct. + */ + xcount = (*dev->dev_ops->xstats_get)(dev, +- xstats ? xstats + count : NULL, ++ (n > count) ? xstats + count : NULL, + (n > count) ? n - count : 0); + + if (xcount < 0) +diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h +index b8f135ba3f..082166ed42 100644 +--- a/lib/ethdev/rte_ethdev.h ++++ b/lib/ethdev/rte_ethdev.h +@@ -3105,9 +3105,13 @@ int rte_eth_xstats_get_names(uint16_t port_id, + * @param xstats + * A pointer to a table of structure of type *rte_eth_xstat* + * to be filled with device statistics ids and values. +- * This parameter can be set to NULL if n is 0. ++ * This parameter can be set to NULL if and only if n is 0. + * @param n + * The size of the xstats array (number of elements). ++ * If lower than the required number of elements, the function returns ++ * the required number of elements. ++ * If equal to zero, the xstats must be NULL, the function returns the ++ * required number of elements. + * @return + * - A positive value lower or equal to n: success. The return value + * is the number of entries filled in the stats table. +-- +2.22.0 + diff --git a/0088-ethdev-simplify-xstats-get-implementation.patch b/0088-ethdev-simplify-xstats-get-implementation.patch new file mode 100644 index 0000000000000000000000000000000000000000..aa8c1976bb8bb96fc16f44ca5b1052b8a2de93b0 --- /dev/null +++ b/0088-ethdev-simplify-xstats-get-implementation.patch @@ -0,0 +1,50 @@ +From a6cce2fd3fb2eda175989fd4a6dbfdd470a08189 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:50 +0800 +Subject: [PATCH 088/122] ethdev: simplify xstats get implementation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Use eth_dev_get_xstats_basic_count() to retrieve generic statistics count. + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index b4a331b671..6110cd1893 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -3313,9 +3313,8 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + unsigned int n) + { + struct rte_eth_dev *dev; +- unsigned int count = 0, i; ++ unsigned int count, i; + signed int xcount = 0; +- uint16_t nb_rxqs, nb_txqs; + int ret; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); +@@ -3323,13 +3322,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + return -EINVAL; + dev = &rte_eth_devices[port_id]; + +- nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); +- nb_txqs = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); +- +- /* Return generic statistics */ +- count = RTE_NB_STATS; +- if (dev->data->dev_flags & RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS) +- count += (nb_rxqs * RTE_NB_RXQ_STATS) + (nb_txqs * RTE_NB_TXQ_STATS); ++ count = eth_dev_get_xstats_basic_count(dev); + + /* implemented by the driver */ + if (dev->dev_ops->xstats_get != NULL) { +-- +2.22.0 + diff --git a/0089-net-hns3-fix-xstats-get-return-if-xstats-is-null.patch b/0089-net-hns3-fix-xstats-get-return-if-xstats-is-null.patch new file mode 100644 index 0000000000000000000000000000000000000000..4060a22ece94ec49822c63bed60ff8c801629499 --- /dev/null +++ b/0089-net-hns3-fix-xstats-get-return-if-xstats-is-null.patch @@ -0,0 +1,58 @@ +From ae08d50d862073a8c53ed7ab4159f3125595667b Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:51 +0800 +Subject: [PATCH 089/122] net/hns3: fix xstats get return if xstats is null +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) +to retrieve the required number of elements, but currently hns3 PMD +returns zero when xstats is null. + +Dedicated check for xstats vs null is not required, since ethdev layer +guarantees that it may be null only if number of entries n is 0 (which +is definitely smaller than total xstats count). + +Fixes: 8839c5e202f3 ("net/hns3: support device stats") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/hns3/hns3_stats.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index 9b7ad067aa..e69761c8b3 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -1031,9 +1031,13 @@ hns3_imissed_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + * @praram xstats + * A pointer to a table of structure of type *rte_eth_xstat* + * to be filled with device statistics ids and values. +- * This parameter can be set to NULL if n is 0. ++ * This parameter can be set to NULL if and only if n is 0. + * @param n + * The size of the xstats array (number of elements). ++ * If lower than the required number of elements, the function returns the ++ * required number of elements. ++ * If equal to zero, the xstats parameter must be NULL, the function returns ++ * the required number of elements. + * @return + * 0 on fail, count(The size of the statistics elements) on success. + */ +@@ -1052,9 +1056,6 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + int count; + int ret; + +- if (xstats == NULL) +- return 0; +- + count = hns3_xstats_calc_num(dev); + if ((int)n < count) + return count; +-- +2.22.0 + diff --git a/0090-net-ipn3ke-fix-xstats-get-return-if-xstats-is-null.patch b/0090-net-ipn3ke-fix-xstats-get-return-if-xstats-is-null.patch new file mode 100644 index 0000000000000000000000000000000000000000..c2c40e8677c2a4313168c80aed7d2333fb220d92 --- /dev/null +++ b/0090-net-ipn3ke-fix-xstats-get-return-if-xstats-is-null.patch @@ -0,0 +1,43 @@ +From 15b2772cfbdc62631556222a1c15491125b14e2f Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:52 +0800 +Subject: [PATCH 090/122] net/ipn3ke: fix xstats get return if xstats is null +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) +to retrieve the required number of elements, but currently ipn3ke PMD +returns zero when xstats is null. + +Dedicated check for xstats vs null is not required, since ethdev layer +guarantees that it may be null only if number of entries n is 0 (which +is definitely smaller than total xstats count). + +Fixes: 5a6d883878db ("net/ipn3ke: implement statistics") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/ipn3ke/ipn3ke_representor.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c +index de325c7d29..8139e13a23 100644 +--- a/drivers/net/ipn3ke/ipn3ke_representor.c ++++ b/drivers/net/ipn3ke/ipn3ke_representor.c +@@ -2218,9 +2218,6 @@ ipn3ke_rpst_xstats_get + struct ipn3ke_rpst_hw_port_stats hw_stats; + struct rte_eth_stats stats; + +- if (!xstats) +- return 0; +- + if (!ethdev) { + IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL"); + return -EINVAL; +-- +2.22.0 + diff --git a/0091-net-mvpp2-fix-xstats-get-return-if-xstats-is-null.patch b/0091-net-mvpp2-fix-xstats-get-return-if-xstats-is-null.patch new file mode 100644 index 0000000000000000000000000000000000000000..43011cf35c53c409840e104423e7375173074956 --- /dev/null +++ b/0091-net-mvpp2-fix-xstats-get-return-if-xstats-is-null.patch @@ -0,0 +1,61 @@ +From ae30c4a7b550e0ac12857279c0a337d80f73261c Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:53 +0800 +Subject: [PATCH 091/122] net/mvpp2: fix xstats get return if xstats is null +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) +to retrieve the required number of elements, but currently mvpp2 PMD +returns zero when xstats is null. + +Remove the logic of "return zero when xstats is NULL", and add the logic +of "return the required number of entries when n is lower than the +required number of entries". + +Fixes: a77b5378cd41 ("net/mrvl: add extended statistics") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/mvpp2/mrvl_ethdev.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c +index 9c7fe13f7f..2a8fb6cbce 100644 +--- a/drivers/net/mvpp2/mrvl_ethdev.c ++++ b/drivers/net/mvpp2/mrvl_ethdev.c +@@ -1626,13 +1626,14 @@ mrvl_xstats_get(struct rte_eth_dev *dev, + { + struct mrvl_priv *priv = dev->data->dev_private; + struct pp2_ppio_statistics ppio_stats; +- unsigned int i; ++ unsigned int i, count; + +- if (!stats) +- return 0; ++ count = RTE_DIM(mrvl_xstats_tbl); ++ if (n < count) ++ return count; + + pp2_ppio_get_statistics(priv->ppio, &ppio_stats, 0); +- for (i = 0; i < n && i < RTE_DIM(mrvl_xstats_tbl); i++) { ++ for (i = 0; i < count; i++) { + uint64_t val; + + if (mrvl_xstats_tbl[i].size == sizeof(uint32_t)) +@@ -1648,7 +1649,7 @@ mrvl_xstats_get(struct rte_eth_dev *dev, + stats[i].value = val; + } + +- return n; ++ return count; + } + + /** +-- +2.22.0 + diff --git a/0092-net-axgbe-fix-xstats-get-return-if-xstats-is-null.patch b/0092-net-axgbe-fix-xstats-get-return-if-xstats-is-null.patch new file mode 100644 index 0000000000000000000000000000000000000000..1b1084812c2f9b3b7d3bc65afd8e892db9161d41 --- /dev/null +++ b/0092-net-axgbe-fix-xstats-get-return-if-xstats-is-null.patch @@ -0,0 +1,56 @@ +From fc8702a84b7e794ab95aac021aa2cc3b4c92c5cd Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:54 +0800 +Subject: [PATCH 092/122] net/axgbe: fix xstats get return if xstats is null +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) +to retrieve the required number of elements, but currently axgbe PMD +returns zero when xstats is null. + +Remove the logic of "return zero when xstats is NULL", and add the logic +of "return the required number of entries when n is lower than the +required number of entries". + +Fixes: 9d1ef6b2e731 ("net/axgbe: add xstats") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/axgbe/axgbe_ethdev.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c +index 7d40c18a86..b209ab67cf 100644 +--- a/drivers/net/axgbe/axgbe_ethdev.c ++++ b/drivers/net/axgbe/axgbe_ethdev.c +@@ -1009,18 +1009,18 @@ axgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, + struct axgbe_port *pdata = dev->data->dev_private; + unsigned int i; + +- if (!stats) +- return 0; ++ if (n < AXGBE_XSTATS_COUNT) ++ return AXGBE_XSTATS_COUNT; + + axgbe_read_mmc_stats(pdata); + +- for (i = 0; i < n && i < AXGBE_XSTATS_COUNT; i++) { ++ for (i = 0; i < AXGBE_XSTATS_COUNT; i++) { + stats[i].id = i; + stats[i].value = *(u64 *)((uint8_t *)&pdata->mmc_stats + + axgbe_xstats_strings[i].offset); + } + +- return i; ++ return AXGBE_XSTATS_COUNT; + } + + static int +-- +2.22.0 + diff --git a/0093-ethdev-fix-memory-leak-in-xstats-telemetry.patch b/0093-ethdev-fix-memory-leak-in-xstats-telemetry.patch new file mode 100644 index 0000000000000000000000000000000000000000..0cff404543f410620c918b94021e429e881f9da6 --- /dev/null +++ b/0093-ethdev-fix-memory-leak-in-xstats-telemetry.patch @@ -0,0 +1,35 @@ +From 30aa792dda9b9e361f1d00012304ee78472c80f6 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:55 +0800 +Subject: [PATCH 093/122] ethdev: fix memory leak in xstats telemetry +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The 'eth_xstats' should be freed after telemetry dictionary setup. + +Fixes: c190daedb9b1 ("ethdev: add telemetry callbacks") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 6110cd1893..1db59d3a0e 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6259,6 +6259,7 @@ eth_dev_handle_port_xstats(const char *cmd __rte_unused, + for (i = 0; i < num_xstats; i++) + rte_tel_data_add_dict_u64(d, xstat_names[i].name, + eth_xstats[i].value); ++ free(eth_xstats); + return 0; + } + +-- +2.22.0 + diff --git a/0094-ethdev-fix-possible-null-pointer-access.patch b/0094-ethdev-fix-possible-null-pointer-access.patch new file mode 100644 index 0000000000000000000000000000000000000000..977060cadea5524d335bead120b8237098653e53 --- /dev/null +++ b/0094-ethdev-fix-possible-null-pointer-access.patch @@ -0,0 +1,37 @@ +From bfe03dd331bcfda1ab9fcbe32305eb515b5d7e32 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:56 +0800 +Subject: [PATCH 094/122] ethdev: fix possible null pointer access +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The rte_tel_data_alloc() may return NULL, so the caller should add +judgement for it. + +Fixes: 083b0b310b19 ("ethdev: add common stats for telemetry") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 1db59d3a0e..e55d11937e 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -6166,6 +6166,8 @@ eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats, + { + int q; + struct rte_tel_data *q_data = rte_tel_data_alloc(); ++ if (q_data == NULL) ++ return; + rte_tel_data_start_array(q_data, RTE_TEL_U64_VAL); + for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++) + rte_tel_data_add_array_u64(q_data, q_stats[q]); +-- +2.22.0 + diff --git a/0095-net-cnxk-fix-possible-null-dereference-in-telemetry.patch b/0095-net-cnxk-fix-possible-null-dereference-in-telemetry.patch new file mode 100644 index 0000000000000000000000000000000000000000..6147c58d9fdee631380c713a38492c640eb93d9b --- /dev/null +++ b/0095-net-cnxk-fix-possible-null-dereference-in-telemetry.patch @@ -0,0 +1,37 @@ +From d3078f7a0fe21d94fa8d6027f2541311a990585a Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 13 May 2022 10:53:57 +0800 +Subject: [PATCH 095/122] net/cnxk: fix possible null dereference in telemetry +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The return value of rte_tel_data_alloc() may be null pointer. +Add missing check vs null. + +Fixes: 5ea354a1f2cc ("net/cnxk: support telemetry") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Morten Brørup +Reviewed-by: Andrew Rybchenko +--- + drivers/net/cnxk/cnxk_ethdev_telemetry.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c +index 83bc65848c..4fd9048643 100644 +--- a/drivers/net/cnxk/cnxk_ethdev_telemetry.c ++++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c +@@ -49,6 +49,8 @@ ethdev_tel_handle_info(const char *cmd __rte_unused, + rte_tel_data_add_dict_int(d, "n_ports", n_ports); + + i_data = rte_tel_data_alloc(); ++ if (i_data == NULL) ++ return -ENOMEM; + rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL); + + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { +-- +2.22.0 + diff --git a/0096-net-bonding-fix-mbuf-fast-free-usage.patch b/0096-net-bonding-fix-mbuf-fast-free-usage.patch new file mode 100644 index 0000000000000000000000000000000000000000..5c76dd74db33e42d4cffcc76ce5621acbb424032 --- /dev/null +++ b/0096-net-bonding-fix-mbuf-fast-free-usage.patch @@ -0,0 +1,57 @@ +From 77eaa2e2b5ae1651abdaa0fb885bc3971e9e0587 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Wed, 25 May 2022 09:08:28 +0800 +Subject: [PATCH 096/122] net/bonding: fix mbuf fast free usage + +Usage of 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload has two +constraints: per-queue all mbufs comes from the same mempool and +has refcnt = 1. + +Bonding mode Broadcast, Tx mbuf has more than one refcnt. +Bonding mode 8023AD, It contains two mempools separately for LACP +packets and other packets. In Tx or Rx, Fast mbuf free will operate +mbuf from different mempool. + +This patch will prevent 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload +when in bonding mode Broadcast and mode 8023AD. + +Fixes: 78aecefed955 ("bond: move param parsing in configure step") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index c929b55768..0d6f0a30d1 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -3563,6 +3563,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev) + const char *name = dev->device->name; + struct bond_dev_private *internals = dev->data->dev_private; + struct rte_kvargs *kvlist = internals->kvlist; ++ uint64_t offloads; + int arg_count; + uint16_t port_id = dev - rte_eth_devices; + uint8_t agg_mode; +@@ -3613,6 +3614,16 @@ bond_ethdev_configure(struct rte_eth_dev *dev) + } + } + ++ offloads = dev->data->dev_conf.txmode.offloads; ++ if ((offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) && ++ (internals->mode == BONDING_MODE_8023AD || ++ internals->mode == BONDING_MODE_BROADCAST)) { ++ RTE_BOND_LOG(WARNING, ++ "bond mode broadcast & 8023AD don't support MBUF_FAST_FREE offload, force disable it."); ++ offloads &= ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; ++ dev->data->dev_conf.txmode.offloads = offloads; ++ } ++ + /* set the max_rx_pktlen */ + internals->max_rx_pktlen = internals->candidate_max_rx_pktlen; + +-- +2.22.0 + diff --git a/0097-ethdev-fix-port-state-when-stop.patch b/0097-ethdev-fix-port-state-when-stop.patch new file mode 100644 index 0000000000000000000000000000000000000000..6e952a7db3db0988abdc1deab2791be459b17fb9 --- /dev/null +++ b/0097-ethdev-fix-port-state-when-stop.patch @@ -0,0 +1,36 @@ +From df393a512efe98bffa9b872844ea999507e51fba Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Tue, 3 May 2022 18:02:17 +0800 +Subject: [PATCH 097/122] ethdev: fix port state when stop + +Currently, 'dev_started' is always set to be 0 when dev stop, whether +it succeeded or failed. This is unreasonable and this patch fixed it. + +Fixes: 62024eb82756 ("ethdev: change stop operation callback to return int") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +Acked-by: Thomas Monjalon +Acked-by: Ferruh Yigit +--- + lib/ethdev/rte_ethdev.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index e55d11937e..2671f47738 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -1879,8 +1879,9 @@ rte_eth_dev_stop(uint16_t port_id) + /* point fast-path functions to dummy ones */ + eth_dev_fp_ops_reset(rte_eth_fp_ops + port_id); + +- dev->data->dev_started = 0; + ret = (*dev->dev_ops->dev_stop)(dev); ++ if (ret == 0) ++ dev->data->dev_started = 0; + rte_ethdev_trace_stop(port_id, ret); + + return ret; +-- +2.22.0 + diff --git a/0098-ethdev-fix-port-close-in-secondary-process.patch b/0098-ethdev-fix-port-close-in-secondary-process.patch new file mode 100644 index 0000000000000000000000000000000000000000..9dcc92e6c1264bbd99d9dfbb47cc20cc5f5b1e3f --- /dev/null +++ b/0098-ethdev-fix-port-close-in-secondary-process.patch @@ -0,0 +1,40 @@ +From 8c0618338ca0b8a540980b4a475322f2cf48d9a6 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Wed, 1 Jun 2022 11:15:13 +0800 +Subject: [PATCH 098/122] ethdev: fix port close in secondary process + +Secondary process needs to close device to release process private +resources. But secondary process should not be obliged to wait for +device stop before closing ethdev. + +Fixes: febc855b358e ("ethdev: forbid closing started device") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +Reviewed-by: Andrew Rybchenko +--- + lib/ethdev/rte_ethdev.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c +index 2671f47738..25c9f0c123 100644 +--- a/lib/ethdev/rte_ethdev.c ++++ b/lib/ethdev/rte_ethdev.c +@@ -1921,7 +1921,13 @@ rte_eth_dev_close(uint16_t port_id) + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + +- if (dev->data->dev_started) { ++ /* ++ * Secondary process needs to close device to release process private ++ * resources. But secondary process should not be obliged to wait ++ * for device stop before closing ethdev. ++ */ ++ if (rte_eal_process_type() == RTE_PROC_PRIMARY && ++ dev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n", + port_id); + return -EINVAL; +-- +2.22.0 + diff --git a/0099-examples-dma-fix-MTU-configuration.patch b/0099-examples-dma-fix-MTU-configuration.patch new file mode 100644 index 0000000000000000000000000000000000000000..6b6ecf3e315a6018a6b10d492d8041d09293fd87 --- /dev/null +++ b/0099-examples-dma-fix-MTU-configuration.patch @@ -0,0 +1,95 @@ +From f5e60c8f1d74d2a01f91fad546003eef876d71f1 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Sun, 24 Apr 2022 14:07:39 +0800 +Subject: [PATCH 099/122] examples/dma: fix MTU configuration + +The MTU in dma App can be configured by 'max_frame_size' parameters which +have a default value(1518). It's not reasonable to use it directly as MTU. +This patch fix it. + +Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +--- + examples/dma/dmafwd.c | 43 +++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 39 insertions(+), 4 deletions(-) + +diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c +index d074acc905..cfd978ec6c 100644 +--- a/examples/dma/dmafwd.c ++++ b/examples/dma/dmafwd.c +@@ -117,7 +117,7 @@ static uint16_t nb_txd = TX_DEFAULT_RINGSIZE; + static volatile bool force_quit; + + static uint32_t dma_batch_sz = MAX_PKT_BURST; +-static uint32_t max_frame_size = RTE_ETHER_MAX_LEN; ++static uint32_t max_frame_size; + + /* ethernet addresses of ports */ + static struct rte_ether_addr dma_ports_eth_addr[RTE_MAX_ETHPORTS]; +@@ -851,6 +851,38 @@ assign_rings(void) + } + /* >8 End of assigning ring structures for packet exchanging. */ + ++static uint32_t ++eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu) ++{ ++ uint32_t overhead_len; ++ ++ if (max_mtu != UINT16_MAX && max_rx_pktlen > max_mtu) ++ overhead_len = max_rx_pktlen - max_mtu; ++ else ++ overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; ++ ++ return overhead_len; ++} ++ ++static int ++config_port_max_pkt_len(struct rte_eth_conf *conf, ++ struct rte_eth_dev_info *dev_info) ++{ ++ uint32_t overhead_len; ++ ++ if (max_frame_size == 0) ++ return 0; ++ ++ if (max_frame_size < RTE_ETHER_MIN_LEN) ++ return -1; ++ ++ overhead_len = eth_dev_get_overhead_len(dev_info->max_rx_pktlen, ++ dev_info->max_mtu); ++ conf->rxmode.mtu = max_frame_size - overhead_len; ++ ++ return 0; ++} ++ + /* + * Initializes a given port using global settings and with the RX buffers + * coming from the mbuf_pool passed as a parameter. +@@ -878,9 +910,6 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues) + struct rte_eth_dev_info dev_info; + int ret, i; + +- if (max_frame_size > local_port_conf.rxmode.mtu) +- local_port_conf.rxmode.mtu = max_frame_size; +- + /* Skip ports that are not enabled */ + if ((dma_enabled_port_mask & (1 << portid)) == 0) { + printf("Skipping disabled port %u\n", portid); +@@ -895,6 +924,12 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues) + rte_exit(EXIT_FAILURE, "Cannot get device info: %s, port=%u\n", + rte_strerror(-ret), portid); + ++ ret = config_port_max_pkt_len(&local_port_conf, &dev_info); ++ if (ret != 0) ++ rte_exit(EXIT_FAILURE, ++ "Invalid max frame size: %u (port %u)\n", ++ max_frame_size, portid); ++ + local_port_conf.rx_adv_conf.rss_conf.rss_hf &= + dev_info.flow_type_rss_offloads; + ret = rte_eth_dev_configure(portid, nb_queues, 1, &local_port_conf); +-- +2.22.0 + diff --git a/0100-examples-dma-fix-Tx-drop-statistics.patch b/0100-examples-dma-fix-Tx-drop-statistics.patch new file mode 100644 index 0000000000000000000000000000000000000000..b82c3d439a85936a27f8f3fd103e16072b80a532 --- /dev/null +++ b/0100-examples-dma-fix-Tx-drop-statistics.patch @@ -0,0 +1,79 @@ +From 5059d5fd27626e1d34b6dcaa2e74c7a5f1c7ee1f Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Sun, 24 Apr 2022 14:07:40 +0800 +Subject: [PATCH 100/122] examples/dma: fix Tx drop statistics + +The Tx drop statistic was designed to be collected by +rte_eth_dev_tx_buffer mechanism, but the application uses +rte_eth_tx_burst to send packets and this lead the Tx drop statistic +was not collected. + +This patch removes rte_eth_dev_tx_buffer mechanism to fix the problem. + +Fixes: 632bcd9b5d4f ("examples/ioat: print statistics") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Acked-by: Bruce Richardson +Acked-by: Kevin Laatz +--- + examples/dma/dmafwd.c | 27 +++++---------------------- + 1 file changed, 5 insertions(+), 22 deletions(-) + +diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c +index cfd978ec6c..d7d39b6a14 100644 +--- a/examples/dma/dmafwd.c ++++ b/examples/dma/dmafwd.c +@@ -122,7 +122,6 @@ static uint32_t max_frame_size; + /* ethernet addresses of ports */ + static struct rte_ether_addr dma_ports_eth_addr[RTE_MAX_ETHPORTS]; + +-static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; + struct rte_mempool *dma_pktmbuf_pool; + + /* Print out statistics for one port. */ +@@ -484,10 +483,13 @@ dma_tx_port(struct rxtx_port_config *tx_config) + + port_statistics.tx[tx_config->rxtx_port] += nb_tx; + +- /* Free any unsent packets. */ +- if (unlikely(nb_tx < nb_dq)) ++ if (unlikely(nb_tx < nb_dq)) { ++ port_statistics.tx_dropped[tx_config->rxtx_port] += ++ (nb_dq - nb_tx); ++ /* Free any unsent packets. */ + rte_mempool_put_bulk(dma_pktmbuf_pool, + (void *)&mbufs[nb_tx], nb_dq - nb_tx); ++ } + } + } + /* >8 End of transmitting packets from dmadev. */ +@@ -970,25 +972,6 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues) + "rte_eth_tx_queue_setup:err=%d,port=%u\n", + ret, portid); + +- /* Initialize TX buffers */ +- tx_buffer[portid] = rte_zmalloc_socket("tx_buffer", +- RTE_ETH_TX_BUFFER_SIZE(MAX_PKT_BURST), 0, +- rte_eth_dev_socket_id(portid)); +- if (tx_buffer[portid] == NULL) +- rte_exit(EXIT_FAILURE, +- "Cannot allocate buffer for tx on port %u\n", +- portid); +- +- rte_eth_tx_buffer_init(tx_buffer[portid], MAX_PKT_BURST); +- +- ret = rte_eth_tx_buffer_set_err_callback(tx_buffer[portid], +- rte_eth_tx_buffer_count_callback, +- &port_statistics.tx_dropped[portid]); +- if (ret < 0) +- rte_exit(EXIT_FAILURE, +- "Cannot set error callback for tx buffer on port %u\n", +- portid); +- + /* Start device. 8< */ + ret = rte_eth_dev_start(portid); + if (ret < 0) +-- +2.22.0 + diff --git a/0101-examples-dma-add-force-minimal-copy-size-parameter.patch b/0101-examples-dma-add-force-minimal-copy-size-parameter.patch new file mode 100644 index 0000000000000000000000000000000000000000..b0c08c95ddd47e80949cf7fa202c3a4e43d9dacd --- /dev/null +++ b/0101-examples-dma-add-force-minimal-copy-size-parameter.patch @@ -0,0 +1,127 @@ +From abc65cadf4b5ef0f898cb4851a100af26fbc55a6 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Sun, 24 Apr 2022 14:07:41 +0800 +Subject: [PATCH 101/122] examples/dma: add force minimal copy size parameter + +This patch adds force minimal copy size parameter +(-m/--force-min-copy-size), so when do copy by CPU or DMA, the real copy +size will be the maximum of mbuf's data_len and this parameter. + +This parameter was designed to compare the performance between CPU copy +and DMA copy. User could send small packets with a high rate to drive +the performance test. + +Signed-off-by: Chengwen Feng +Acked-by: Bruce Richardson +Acked-by: Kevin Laatz +--- + examples/dma/dmafwd.c | 30 +++++++++++++++++++++++++++--- + 1 file changed, 27 insertions(+), 3 deletions(-) + +diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c +index d7d39b6a14..9b17b40dbf 100644 +--- a/examples/dma/dmafwd.c ++++ b/examples/dma/dmafwd.c +@@ -25,6 +25,7 @@ + #define CMD_LINE_OPT_RING_SIZE "ring-size" + #define CMD_LINE_OPT_BATCH_SIZE "dma-batch-size" + #define CMD_LINE_OPT_FRAME_SIZE "max-frame-size" ++#define CMD_LINE_OPT_FORCE_COPY_SIZE "force-min-copy-size" + #define CMD_LINE_OPT_STATS_INTERVAL "stats-interval" + + /* configurable number of RX/TX ring descriptors */ +@@ -118,6 +119,7 @@ static volatile bool force_quit; + + static uint32_t dma_batch_sz = MAX_PKT_BURST; + static uint32_t max_frame_size; ++static uint32_t force_min_copy_size; + + /* ethernet addresses of ports */ + static struct rte_ether_addr dma_ports_eth_addr[RTE_MAX_ETHPORTS]; +@@ -205,7 +207,13 @@ print_stats(char *prgname) + "Rx Queues = %d, ", nb_queues); + status_strlen += snprintf(status_string + status_strlen, + sizeof(status_string) - status_strlen, +- "Ring Size = %d", ring_size); ++ "Ring Size = %d\n", ring_size); ++ status_strlen += snprintf(status_string + status_strlen, ++ sizeof(status_string) - status_strlen, ++ "Force Min Copy Size = %u Packet Data Room Size = %u", ++ force_min_copy_size, ++ rte_pktmbuf_data_room_size(dma_pktmbuf_pool) - ++ RTE_PKTMBUF_HEADROOM); + + memset(&ts, 0, sizeof(struct total_statistics)); + +@@ -303,7 +311,8 @@ static inline void + pktmbuf_sw_copy(struct rte_mbuf *src, struct rte_mbuf *dst) + { + rte_memcpy(rte_pktmbuf_mtod(dst, char *), +- rte_pktmbuf_mtod(src, char *), src->data_len); ++ rte_pktmbuf_mtod(src, char *), ++ RTE_MAX(src->data_len, force_min_copy_size)); + } + /* >8 End of perform packet copy there is a user-defined function. */ + +@@ -320,7 +329,9 @@ dma_enqueue_packets(struct rte_mbuf *pkts[], struct rte_mbuf *pkts_copy[], + ret = rte_dma_copy(dev_id, 0, + rte_pktmbuf_iova(pkts[i]), + rte_pktmbuf_iova(pkts_copy[i]), +- rte_pktmbuf_data_len(pkts[i]), 0); ++ RTE_MAX(rte_pktmbuf_data_len(pkts[i]), ++ force_min_copy_size), ++ 0); + + if (ret < 0) + break; +@@ -572,6 +583,7 @@ dma_usage(const char *prgname) + printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" + " -b --dma-batch-size: number of requests per DMA batch\n" + " -f --max-frame-size: max frame size\n" ++ " -m --force-min-copy-size: force a minimum copy length, even for smaller packets\n" + " -p --portmask: hexadecimal bitmask of ports to configure\n" + " -q NQ: number of RX queues per port (default is 1)\n" + " --[no-]mac-updating: Enable or disable MAC addresses updating (enabled by default)\n" +@@ -617,6 +629,7 @@ dma_parse_args(int argc, char **argv, unsigned int nb_ports) + "b:" /* dma batch size */ + "c:" /* copy type (sw|hw) */ + "f:" /* max frame size */ ++ "m:" /* force min copy size */ + "p:" /* portmask */ + "q:" /* number of RX queues per port */ + "s:" /* ring size */ +@@ -632,6 +645,7 @@ dma_parse_args(int argc, char **argv, unsigned int nb_ports) + {CMD_LINE_OPT_RING_SIZE, required_argument, NULL, 's'}, + {CMD_LINE_OPT_BATCH_SIZE, required_argument, NULL, 'b'}, + {CMD_LINE_OPT_FRAME_SIZE, required_argument, NULL, 'f'}, ++ {CMD_LINE_OPT_FORCE_COPY_SIZE, required_argument, NULL, 'm'}, + {CMD_LINE_OPT_STATS_INTERVAL, required_argument, NULL, 'i'}, + {NULL, 0, 0, 0} + }; +@@ -666,6 +680,10 @@ dma_parse_args(int argc, char **argv, unsigned int nb_ports) + } + break; + ++ case 'm': ++ force_min_copy_size = atoi(optarg); ++ break; ++ + /* portmask */ + case 'p': + dma_enabled_port_mask = dma_parse_portmask(optarg); +@@ -1064,6 +1082,12 @@ main(int argc, char **argv) + rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); + /* >8 End of allocates mempool to hold the mbufs. */ + ++ if (force_min_copy_size > ++ (uint32_t)(rte_pktmbuf_data_room_size(dma_pktmbuf_pool) - ++ RTE_PKTMBUF_HEADROOM)) ++ rte_exit(EXIT_FAILURE, ++ "Force min copy size > packet mbuf size\n"); ++ + /* Initialize each port. 8< */ + cfg.nb_ports = 0; + RTE_ETH_FOREACH_DEV(portid) +-- +2.22.0 + diff --git a/0102-dma-hisilicon-fix-index-returned-when-no-DMA-complet.patch b/0102-dma-hisilicon-fix-index-returned-when-no-DMA-complet.patch new file mode 100644 index 0000000000000000000000000000000000000000..0924a01648730b7c51935b69580b6d961477aa43 --- /dev/null +++ b/0102-dma-hisilicon-fix-index-returned-when-no-DMA-complet.patch @@ -0,0 +1,54 @@ +From efe4049f48dd09ea069354f7e515bf7d81aa0f92 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 27 May 2022 11:40:52 +0800 +Subject: [PATCH 102/122] dma/hisilicon: fix index returned when no DMA + completed + +If no DMA request is completed, the ring_idx of the last completed +operation need returned by last_idx parameter. This patch fixes it. + +Fixes: 2db4f0b82360 ("dma/hisilicon: add data path") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + drivers/dma/hisilicon/hisi_dmadev.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index 9cef2cbfbe..f5c3cd914d 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -702,12 +702,12 @@ hisi_dma_completed(void *dev_private, + } + sq_head = (sq_head + 1) & hw->sq_depth_mask; + } ++ *last_idx = hw->cridx + i - 1; + if (i > 0) { + hw->cridx += i; +- *last_idx = hw->cridx - 1; + hw->sq_head = sq_head; ++ hw->completed += i; + } +- hw->completed += i; + + return i; + } +@@ -761,12 +761,12 @@ hisi_dma_completed_status(void *dev_private, + hw->status[sq_head] = HISI_DMA_STATUS_SUCCESS; + sq_head = (sq_head + 1) & hw->sq_depth_mask; + } ++ *last_idx = hw->cridx + cpl_num - 1; + if (likely(cpl_num > 0)) { + hw->cridx += cpl_num; +- *last_idx = hw->cridx - 1; + hw->sq_head = sq_head; ++ hw->completed += cpl_num; + } +- hw->completed += cpl_num; + + return cpl_num; + } +-- +2.22.0 + diff --git a/0103-test-dma-check-index-when-no-DMA-completed.patch b/0103-test-dma-check-index-when-no-DMA-completed.patch new file mode 100644 index 0000000000000000000000000000000000000000..35b0e1f75602ae1a1d54b1326f16659394ce249a --- /dev/null +++ b/0103-test-dma-check-index-when-no-DMA-completed.patch @@ -0,0 +1,51 @@ +From 33e515de3d5d00094f934e10b2d15af8e52511b5 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 27 May 2022 11:40:53 +0800 +Subject: [PATCH 103/122] test/dma: check index when no DMA completed + +If no DMA request is completed, the ring_idx of the last completed +operation need returned by last_idx parameter. This patch adds +testcase for it. + +Signed-off-by: Chengwen Feng +Tested-by: Kevin Laatz +--- + app/test/test_dmadev.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c +index b206db27ae..d9e8f6d8c3 100644 +--- a/app/test/test_dmadev.c ++++ b/app/test/test_dmadev.c +@@ -177,6 +177,7 @@ do_multi_copies(int16_t dev_id, uint16_t vchan, + static int + test_enqueue_copies(int16_t dev_id, uint16_t vchan) + { ++ enum rte_dma_status_code status; + unsigned int i; + uint16_t id; + +@@ -215,6 +216,20 @@ test_enqueue_copies(int16_t dev_id, uint16_t vchan) + ERR_RETURN("Error:incorrect job id received, %u [expected %u]\n", + id, id_count); + ++ /* check for completed and id when no job done */ ++ if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 0) ++ ERR_RETURN("Error with rte_dma_completed when no job done\n"); ++ if (id != id_count) ++ ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", ++ id, id_count); ++ ++ /* check for completed_status and id when no job done */ ++ if (rte_dma_completed_status(dev_id, vchan, 1, &id, &status) != 0) ++ ERR_RETURN("Error with rte_dma_completed_status when no job done\n"); ++ if (id != id_count) ++ ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", ++ id, id_count); ++ + rte_pktmbuf_free(src); + rte_pktmbuf_free(dst); + +-- +2.22.0 + diff --git a/0104-dma-hisilicon-enhance-CQ-scan-robustness.patch b/0104-dma-hisilicon-enhance-CQ-scan-robustness.patch new file mode 100644 index 0000000000000000000000000000000000000000..d4da26d679a44f030f4b4d281b388d4e705373fa --- /dev/null +++ b/0104-dma-hisilicon-enhance-CQ-scan-robustness.patch @@ -0,0 +1,54 @@ +From 5b84cc2a652f2646d2d4b4cdc1e6b00c13f4d790 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Fri, 27 May 2022 11:40:54 +0800 +Subject: [PATCH 104/122] dma/hisilicon: enhance CQ scan robustness + +The CQ (completion queue) descriptors were updated by hardware, and then +scanned by driver to retrieve hardware completion status. + +This patch enhances robustness by following: +1. replace while (true) with a finite loop to avoid potential dead loop. +2. check the csq_head field in CQ descriptor to avoid status array +overflows. + +Fixes: 2db4f0b82360 ("dma/hisilicon: add data path") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +--- + drivers/dma/hisilicon/hisi_dmadev.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c +index f5c3cd914d..fbe09284ed 100644 +--- a/drivers/dma/hisilicon/hisi_dmadev.c ++++ b/drivers/dma/hisilicon/hisi_dmadev.c +@@ -634,7 +634,7 @@ hisi_dma_scan_cq(struct hisi_dma_dev *hw) + uint16_t count = 0; + uint64_t misc; + +- while (true) { ++ while (count < hw->cq_depth) { + cqe = &hw->cqe[cq_head]; + misc = cqe->misc; + misc = rte_le_to_cpu_64(misc); +@@ -642,6 +642,16 @@ hisi_dma_scan_cq(struct hisi_dma_dev *hw) + break; + + csq_head = FIELD_GET(CQE_SQ_HEAD_MASK, misc); ++ if (unlikely(csq_head > hw->sq_depth_mask)) { ++ /** ++ * Defensive programming to prevent overflow of the ++ * status array indexed by csq_head. Only error logs ++ * are used for prompting. ++ */ ++ HISI_DMA_ERR(hw, "invalid csq_head:%u!\n", csq_head); ++ count = 0; ++ break; ++ } + if (unlikely(misc & CQE_STATUS_MASK)) + hw->status[csq_head] = FIELD_GET(CQE_STATUS_MASK, + misc); +-- +2.22.0 + diff --git a/0105-net-failsafe-fix-device-freeing.patch b/0105-net-failsafe-fix-device-freeing.patch new file mode 100644 index 0000000000000000000000000000000000000000..8579b7c0229f1f952763a5cda019154dd060b4c6 --- /dev/null +++ b/0105-net-failsafe-fix-device-freeing.patch @@ -0,0 +1,37 @@ +From f74659ac42dca5d47b03de3b22010a0f45434137 Mon Sep 17 00:00:00 2001 +From: Yunjian Wang +Date: Tue, 7 Jun 2022 14:50:49 +0800 +Subject: [PATCH 105/122] net/failsafe: fix device freeing + +The PMD destroy function was calling the release function, which frees +dev->data->dev_private, and then tries to free PRIV(dev)->intr_handle, +which causes the heap use after free issue. + +The free can be moved to before the release function is called. + +Fixes: d61138d4f0e ("drivers: remove direct access to interrupt handle") +Cc: stable@dpdk.org + +Signed-off-by: Yunjian Wang +Reviewed-by: Andrew Rybchenko +--- + drivers/net/failsafe/failsafe.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c +index 3c754a5f66..05cf533896 100644 +--- a/drivers/net/failsafe/failsafe.c ++++ b/drivers/net/failsafe/failsafe.c +@@ -308,8 +308,8 @@ fs_rte_eth_free(const char *name) + if (dev == NULL) + return 0; /* port already released */ + ret = failsafe_eth_dev_close(dev); +- rte_eth_dev_release_port(dev); + rte_intr_instance_free(PRIV(dev)->intr_handle); ++ rte_eth_dev_release_port(dev); + return ret; + } + +-- +2.22.0 + diff --git a/0106-net-tap-fix-device-freeing.patch b/0106-net-tap-fix-device-freeing.patch new file mode 100644 index 0000000000000000000000000000000000000000..1468924e9b8a968bc4066fe6fee2592b572dc387 --- /dev/null +++ b/0106-net-tap-fix-device-freeing.patch @@ -0,0 +1,38 @@ +From 601f63e2f591a0b191c0ab0d4b39e826b15a0226 Mon Sep 17 00:00:00 2001 +From: Yunjian Wang +Date: Tue, 7 Jun 2022 14:50:57 +0800 +Subject: [PATCH 106/122] net/tap: fix device freeing + +The error path was calling rte_eth_dev_release_port() function, +which frees eth_dev->data->dev_private, and then tries to free +pmd->intr_handle, which causes the use after free issue. + +The free can be moved to before the release function is called. + +Fixes: d61138d4f0e ("drivers: remove direct access to interrupt handle") +Cc: stable@dpdk.org + +Signed-off-by: Xiangjun Meng +Signed-off-by: Yunjian Wang +Reviewed-by: Andrew Rybchenko +--- + drivers/net/tap/rte_eth_tap.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c +index f1b48cae82..ddca630574 100644 +--- a/drivers/net/tap/rte_eth_tap.c ++++ b/drivers/net/tap/rte_eth_tap.c +@@ -2099,8 +2099,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, + close(pmd->ioctl_sock); + /* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs = NULL; +- rte_eth_dev_release_port(dev); + rte_intr_instance_free(pmd->intr_handle); ++ rte_eth_dev_release_port(dev); + + error_exit_nodev: + TAP_LOG(ERR, "%s Unable to initialize %s", +-- +2.22.0 + diff --git a/0107-net-bonding-fix-RSS-inconsistent-between-bonded-and-.patch b/0107-net-bonding-fix-RSS-inconsistent-between-bonded-and-.patch new file mode 100644 index 0000000000000000000000000000000000000000..08130dfbdacb65cb6048df834ff7e1fef626c1d1 --- /dev/null +++ b/0107-net-bonding-fix-RSS-inconsistent-between-bonded-and-.patch @@ -0,0 +1,43 @@ +From 440f7e8f67673b8482d1b8e779ea93603f37c21f Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 8 Jun 2022 19:45:47 +0800 +Subject: [PATCH 107/122] net/bonding: fix RSS inconsistent between bonded and + slaves + +Currently, RSS configuration of slave is set only when RSS is enabled for +bonded port. If RSS is enabled for the slaves port before adding to the +bonded port with disabling RSS, it will run into that the RSS enabled state +of bonded and slaves port is inconsistent after starting bonded port. +So the RSS configuration of slave should also be set when RSS is disabled +for bonded port. + +Fixes: 734ce47f71e0 ("bonding: support RSS dynamic configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +Reviewed-by: Andrew Rybchenko +--- + drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c +index 0d6f0a30d1..09636321cd 100644 +--- a/drivers/net/bonding/rte_eth_bond_pmd.c ++++ b/drivers/net/bonding/rte_eth_bond_pmd.c +@@ -1711,6 +1711,12 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev, + bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf; + slave_eth_dev->data->dev_conf.rxmode.mq_mode = + bonded_eth_dev->data->dev_conf.rxmode.mq_mode; ++ } else { ++ slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len = 0; ++ slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL; ++ slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf = 0; ++ slave_eth_dev->data->dev_conf.rxmode.mq_mode = ++ bonded_eth_dev->data->dev_conf.rxmode.mq_mode; + } + + slave_eth_dev->data->dev_conf.rxmode.mtu = +-- +2.22.0 + diff --git a/0108-app-test-fix-bonding-RSS-test-when-disable-RSS.patch b/0108-app-test-fix-bonding-RSS-test-when-disable-RSS.patch new file mode 100644 index 0000000000000000000000000000000000000000..435cc1836e9a8dfee21abd892a571446d2a59a7a --- /dev/null +++ b/0108-app-test-fix-bonding-RSS-test-when-disable-RSS.patch @@ -0,0 +1,129 @@ +From 36c97bb881ddd7caaf8d9e3885a747880024c3fd Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 8 Jun 2022 19:45:48 +0800 +Subject: [PATCH 108/122] app/test: fix bonding RSS test when disable RSS + +The "test_rss_lazy" test is used for testing bonding RSS functions +when bonded port disable RSS. Currently, this test case can update +RSS functions of bonded and slave port if bonded port turns off RSS. +It is unreasonable and has been adjusted to be non-updateable in +following patch: +"93e1ea6dfa99 ethdev: fix RSS update when RSS is disabled" + +So this patch fixes this test code. + +Fixes: 43b630244e7e ("app/test: add dynamic bonding RSS configuration") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + app/test/test_link_bonding_rssconf.c | 78 ++++++++++++++++++++++++++-- + 1 file changed, 73 insertions(+), 5 deletions(-) + +diff --git a/app/test/test_link_bonding_rssconf.c b/app/test/test_link_bonding_rssconf.c +index f9eae93973..a5aba6b2b9 100644 +--- a/app/test/test_link_bonding_rssconf.c ++++ b/app/test/test_link_bonding_rssconf.c +@@ -464,15 +464,85 @@ test_rss(void) + + TEST_ASSERT_SUCCESS(test_propagate(), "Propagation test failed"); + +- TEST_ASSERT(slave_remove_and_add() == 1, "New slave should be synced"); ++ TEST_ASSERT(slave_remove_and_add() == 1, "remove and add slaves success."); + + remove_slaves_and_stop_bonded_device(); + + return TEST_SUCCESS; + } + ++ ++/** ++ * Test RSS configuration over bonded and slaves. ++ */ ++static int ++test_rss_config_lazy(void) ++{ ++ struct rte_eth_rss_conf bond_rss_conf = {0}; ++ struct slave_conf *port; ++ uint8_t rss_key[40]; ++ uint64_t rss_hf; ++ int retval; ++ uint16_t i; ++ uint8_t n; ++ ++ retval = rte_eth_dev_info_get(test_params.bond_port_id, ++ &test_params.bond_dev_info); ++ TEST_ASSERT((retval == 0), "Error during getting device (port %u) info: %s\n", ++ test_params.bond_port_id, strerror(-retval)); ++ ++ rss_hf = test_params.bond_dev_info.flow_type_rss_offloads; ++ if (rss_hf != 0) { ++ bond_rss_conf.rss_key = NULL; ++ bond_rss_conf.rss_hf = rss_hf; ++ retval = rte_eth_dev_rss_hash_update(test_params.bond_port_id, ++ &bond_rss_conf); ++ TEST_ASSERT(retval != 0, "Succeeded in setting bonded port hash function"); ++ } ++ ++ /* Set all keys to zero for all slaves */ ++ FOR_EACH_PORT(n, port) { ++ port = &test_params.slave_ports[n]; ++ retval = rte_eth_dev_rss_hash_conf_get(port->port_id, ++ &port->rss_conf); ++ TEST_ASSERT_SUCCESS(retval, "Cannot get slaves RSS configuration"); ++ memset(port->rss_key, 0, sizeof(port->rss_key)); ++ port->rss_conf.rss_key = port->rss_key; ++ port->rss_conf.rss_key_len = sizeof(port->rss_key); ++ retval = rte_eth_dev_rss_hash_update(port->port_id, ++ &port->rss_conf); ++ TEST_ASSERT(retval != 0, "Succeeded in setting slaves RSS keys"); ++ } ++ ++ /* Set RSS keys for bonded port */ ++ memset(rss_key, 1, sizeof(rss_key)); ++ bond_rss_conf.rss_hf = rss_hf; ++ bond_rss_conf.rss_key = rss_key; ++ bond_rss_conf.rss_key_len = sizeof(rss_key); ++ ++ retval = rte_eth_dev_rss_hash_update(test_params.bond_port_id, ++ &bond_rss_conf); ++ TEST_ASSERT(retval != 0, "Succeeded in setting bonded port RSS keys"); ++ ++ /* Test RETA propagation */ ++ for (i = 0; i < RXTX_QUEUE_COUNT; i++) { ++ FOR_EACH_PORT(n, port) { ++ port = &test_params.slave_ports[n]; ++ retval = reta_set(port->port_id, (i + 1) % RXTX_QUEUE_COUNT, ++ port->dev_info.reta_size); ++ TEST_ASSERT(retval != 0, "Succeeded in setting slaves RETA"); ++ } ++ ++ retval = reta_set(test_params.bond_port_id, i % RXTX_QUEUE_COUNT, ++ test_params.bond_dev_info.reta_size); ++ TEST_ASSERT(retval != 0, "Succeeded in setting bonded port RETA"); ++ } ++ ++ return TEST_SUCCESS; ++} ++ + /** +- * Test propagation logic, when RX_RSS mq_mode is turned off for bonding port ++ * Test RSS function logic, when RX_RSS mq_mode is turned off for bonding port + */ + static int + test_rss_lazy(void) +@@ -493,9 +563,7 @@ test_rss_lazy(void) + TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bond_port_id), + "Failed to start bonding port (%d).", test_params.bond_port_id); + +- TEST_ASSERT_SUCCESS(test_propagate(), "Propagation test failed"); +- +- TEST_ASSERT(slave_remove_and_add() == 0, "New slave shouldn't be synced"); ++ TEST_ASSERT_SUCCESS(test_rss_config_lazy(), "Succeeded in setting RSS hash when RX_RSS mq_mode is turned off"); + + remove_slaves_and_stop_bonded_device(); + +-- +2.22.0 + diff --git a/0109-net-hns3-add-check-for-deferred-start-queue-when-rol.patch b/0109-net-hns3-add-check-for-deferred-start-queue-when-rol.patch new file mode 100644 index 0000000000000000000000000000000000000000..bf17159205ae52268a9c6b58970bbb63a5713a9b --- /dev/null +++ b/0109-net-hns3-add-check-for-deferred-start-queue-when-rol.patch @@ -0,0 +1,32 @@ +From 256f7ae943d4c15cca9cdf11ce84d4c8b536ad20 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:41 +0800 +Subject: [PATCH 109/122] net/hns3: add check for deferred start queue when + rollback + +Driver doesn't allocate mbufs for the deferred start queues, so no need to +free it when rollback. + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index d3fa4889d2..a9b997d32e 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -1202,6 +1202,9 @@ hns3_init_rx_queues(struct hns3_adapter *hns) + out: + for (j = 0; j < i; j++) { + rxq = (struct hns3_rx_queue *)hw->data->rx_queues[j]; ++ if (rxq->rx_deferred_start) ++ continue; ++ + hns3_rx_queue_release_mbufs(rxq); + } + +-- +2.22.0 + diff --git a/0110-net-hns3-remove-redundant-parentheses.patch b/0110-net-hns3-remove-redundant-parentheses.patch new file mode 100644 index 0000000000000000000000000000000000000000..dd641e0e2aecc00c8a1f643a5653c97effab8314 --- /dev/null +++ b/0110-net-hns3-remove-redundant-parentheses.patch @@ -0,0 +1,38 @@ +From e4fd147156e0b915ff6787824889bb552965ebfd Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:42 +0800 +Subject: [PATCH 110/122] net/hns3: remove redundant parentheses + +Remove redundant parentheses. + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index a9b997d32e..ee0aaaf7fc 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -170,7 +170,7 @@ hns3_fake_rx_queue_release(struct hns3_rx_queue *queue) + } + + /* free fake rx queue arrays */ +- if (idx == (hw->fkq_data.nb_fake_rx_queues - 1)) { ++ if (idx == hw->fkq_data.nb_fake_rx_queues - 1) { + hw->fkq_data.nb_fake_rx_queues = 0; + rte_free(hw->fkq_data.rx_queues); + hw->fkq_data.rx_queues = NULL; +@@ -197,7 +197,7 @@ hns3_fake_tx_queue_release(struct hns3_tx_queue *queue) + } + + /* free fake tx queue arrays */ +- if (idx == (hw->fkq_data.nb_fake_tx_queues - 1)) { ++ if (idx == hw->fkq_data.nb_fake_tx_queues - 1) { + hw->fkq_data.nb_fake_tx_queues = 0; + rte_free(hw->fkq_data.tx_queues); + hw->fkq_data.tx_queues = NULL; +-- +2.22.0 + diff --git a/0111-net-hns3-adjust-the-data-type-of-some-variables.patch b/0111-net-hns3-adjust-the-data-type-of-some-variables.patch new file mode 100644 index 0000000000000000000000000000000000000000..061bda51483288c654d42988829a450be57b19b3 --- /dev/null +++ b/0111-net-hns3-adjust-the-data-type-of-some-variables.patch @@ -0,0 +1,227 @@ +From ca3ada1984f4c159ae2c7e94c82f38d0f239ba84 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:43 +0800 +Subject: [PATCH 111/122] net/hns3: adjust the data type of some variables + +Using the 'int' type and 'uint16_t' type to compare is insecure. +Make them consistent. + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_common.c | 4 ++-- + drivers/net/hns3/hns3_dcb.c | 2 +- + drivers/net/hns3/hns3_ethdev.c | 2 +- + drivers/net/hns3/hns3_regs.c | 2 +- + drivers/net/hns3/hns3_rss.c | 2 +- + drivers/net/hns3/hns3_rxtx.c | 23 ++++++++++++----------- + drivers/net/hns3/hns3_rxtx_vec.h | 4 ++-- + 7 files changed, 20 insertions(+), 19 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 9c86c00a04..edd16d8076 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -475,7 +475,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) + struct rte_ether_addr *addr; + uint16_t mac_addrs_capa; + int ret = 0; +- int i; ++ uint16_t i; + + mac_addrs_capa = + hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : HNS3_UC_MACADDR_NUM; +@@ -645,8 +645,8 @@ int + hns3_init_ring_with_vector(struct hns3_hw *hw) + { + uint16_t vec; ++ uint16_t i; + int ret; +- int i; + + /* + * In hns3 network engine, vector 0 is always the misc interrupt of this +diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c +index 136ada626b..d88757611c 100644 +--- a/drivers/net/hns3/hns3_dcb.c ++++ b/drivers/net/hns3/hns3_dcb.c +@@ -628,7 +628,7 @@ hns3_set_rss_size(struct hns3_hw *hw, uint16_t nb_rx_q) + struct hns3_rss_conf *rss_cfg = &hw->rss_info; + uint16_t rx_qnum_per_tc; + uint16_t used_rx_queues; +- int i; ++ uint16_t i; + + rx_qnum_per_tc = nb_rx_q / hw->num_tc; + if (rx_qnum_per_tc > hw->rss_size_max) { +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 29c9f96c05..97cf27d2a1 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2929,8 +2929,8 @@ hns3_map_tqps_to_func(struct hns3_hw *hw, uint16_t func_id, uint16_t tqp_pid, + static int + hns3_map_tqp(struct hns3_hw *hw) + { ++ uint16_t i; + int ret; +- int i; + + /* + * In current version, VF is not supported when PF is driven by DPDK +diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c +index 86a4cf74d5..6778e4cfc2 100644 +--- a/drivers/net/hns3/hns3_regs.c ++++ b/drivers/net/hns3/hns3_regs.c +@@ -294,8 +294,8 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + uint32_t *origin_data_ptr = data; + uint32_t reg_offset; ++ uint16_t i, j; + int reg_num; +- int i, j; + + /* fetching per-PF registers values from PF PCIe register space */ + reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t); +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index d376486a1d..4c546c9363 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -631,7 +631,7 @@ hns3_rss_set_default_args(struct hns3_hw *hw) + { + struct hns3_rss_conf *rss_cfg = &hw->rss_info; + uint16_t queue_num = hw->alloc_rss_size; +- int i; ++ uint16_t i; + + /* Default hash algorithm */ + rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index ee0aaaf7fc..510802be05 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -390,7 +390,7 @@ hns3_enable_all_queues(struct hns3_hw *hw, bool en) + struct hns3_tx_queue *txq; + uint32_t rcb_reg; + void *tqp_base; +- int i; ++ uint16_t i; + + for (i = 0; i < hw->cfg_max_queues; i++) { + if (hns3_dev_get_support(hw, INDEP_TXRX)) { +@@ -736,8 +736,8 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw) + #define HNS3_RESET_RCB_NOT_SUPPORT 0U + #define HNS3_RESET_ALL_TQP_SUCCESS 1U + uint8_t reset_status; ++ uint16_t i; + int ret; +- int i; + + ret = hns3_reset_rcb_cmd(hw, &reset_status); + if (ret) +@@ -774,7 +774,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw) + uint8_t reset_status; + uint8_t msg_data[2]; + int ret; +- int i; ++ uint16_t i; + + memset(msg_data, 0, sizeof(uint16_t)); + ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data, +@@ -806,7 +806,8 @@ int + hns3_reset_all_tqps(struct hns3_adapter *hns) + { + struct hns3_hw *hw = &hns->hw; +- int ret, i; ++ uint16_t i; ++ int ret; + + /* Disable all queues before reset all queues */ + for (i = 0; i < hw->cfg_max_queues; i++) { +@@ -1037,7 +1038,7 @@ hns3_dev_all_rx_queue_intr_enable(struct hns3_hw *hw, bool en) + { + struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + uint16_t nb_rx_q = hw->data->nb_rx_queues; +- int i; ++ uint16_t i; + + if (dev->data->dev_conf.intr_conf.rxq == 0) + return; +@@ -1121,7 +1122,7 @@ static void + hns3_init_txq(struct hns3_tx_queue *txq) + { + struct hns3_desc *desc; +- int i; ++ uint16_t i; + + /* Clear tx bd */ + desc = txq->tx_ring; +@@ -1145,7 +1146,7 @@ hns3_init_tx_ring_tc(struct hns3_adapter *hns) + + for (i = 0; i < HNS3_MAX_TC_NUM; i++) { + struct hns3_tc_queue_info *tc_queue = &hw->tc_queue[i]; +- int j; ++ uint16_t j; + + if (!tc_queue->enable) + continue; +@@ -1442,7 +1443,7 @@ hns3_alloc_txq_and_dma_zone(struct rte_eth_dev *dev, + struct hns3_tx_queue *txq; + struct hns3_desc *desc; + unsigned int tx_desc; +- int i; ++ uint16_t i; + + txq = rte_zmalloc_socket(q_info->type, sizeof(struct hns3_tx_queue), + RTE_CACHE_LINE_SIZE, q_info->socket_id); +@@ -1679,7 +1680,7 @@ hns3_dev_release_mbufs(struct hns3_adapter *hns) + struct rte_eth_dev_data *dev_data = hns->hw.data; + struct hns3_rx_queue *rxq; + struct hns3_tx_queue *txq; +- int i; ++ uint16_t i; + + if (dev_data->rx_queues) + for (i = 0; i < dev_data->nb_rx_queues; i++) { +@@ -3086,7 +3087,7 @@ hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq) + uint16_t tx_next_use = txq->next_to_use; + struct hns3_entry *tx_entry = &txq->sw_ring[tx_next_clean]; + struct hns3_desc *desc = &txq->tx_ring[tx_next_clean]; +- int i; ++ uint16_t i; + + if (tx_next_use >= tx_next_clean && + tx_next_use < tx_next_clean + txq->tx_rs_thresh) +@@ -3984,7 +3985,7 @@ hns3_tx_free_buffer_simple(struct hns3_tx_queue *txq) + struct hns3_entry *tx_entry; + struct hns3_desc *desc; + uint16_t tx_next_clean; +- int i; ++ uint16_t i; + + while (1) { + if (HNS3_GET_TX_QUEUE_PEND_BD_NUM(txq) < txq->tx_rs_thresh) +diff --git a/drivers/net/hns3/hns3_rxtx_vec.h b/drivers/net/hns3/hns3_rxtx_vec.h +index 4985a7cae8..d13f18627d 100644 +--- a/drivers/net/hns3/hns3_rxtx_vec.h ++++ b/drivers/net/hns3/hns3_rxtx_vec.h +@@ -15,7 +15,7 @@ hns3_tx_bulk_free_buffers(struct hns3_tx_queue *txq) + struct hns3_entry *tx_entry; + struct rte_mbuf *m; + int nb_free = 0; +- int i; ++ uint16_t i; + + tx_entry = &txq->sw_ring[txq->next_to_clean]; + if (txq->mbuf_fast_free_en) { +@@ -56,7 +56,7 @@ static inline void + hns3_tx_free_buffers(struct hns3_tx_queue *txq) + { + struct hns3_desc *tx_desc; +- int i; ++ uint16_t i; + + /* + * All mbufs can be released only when the VLD bits of all +-- +2.22.0 + diff --git a/0112-net-hns3-fix-an-unreasonable-memset.patch b/0112-net-hns3-fix-an-unreasonable-memset.patch new file mode 100644 index 0000000000000000000000000000000000000000..4f93c185dae288b32f2c70699c42b2f12d72db2d --- /dev/null +++ b/0112-net-hns3-fix-an-unreasonable-memset.patch @@ -0,0 +1,30 @@ +From d3b39f5bca72e2ecd16527d3c63e1b2e620830bc Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:44 +0800 +Subject: [PATCH 112/122] net/hns3: fix an unreasonable memset + +Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 510802be05..5a2cfe5a54 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw) + int ret; + uint16_t i; + +- memset(msg_data, 0, sizeof(uint16_t)); ++ memset(msg_data, 0, sizeof(msg_data)); + ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data, + sizeof(msg_data), true, &reset_status, + sizeof(reset_status)); +-- +2.22.0 + diff --git a/0113-net-hns3-remove-duplicate-definition.patch b/0113-net-hns3-remove-duplicate-definition.patch new file mode 100644 index 0000000000000000000000000000000000000000..68289f132d3abcea135872f4a38b0de3d3665a63 --- /dev/null +++ b/0113-net-hns3-remove-duplicate-definition.patch @@ -0,0 +1,71 @@ +From 1650e90eef5c7be334b29d276479c8f4d997ba02 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:45 +0800 +Subject: [PATCH 113/122] net/hns3: remove duplicate definition + +The default hash key array is defined twice. Remove the extra one. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_flow.c | 9 --------- + drivers/net/hns3/hns3_rss.c | 6 ++---- + drivers/net/hns3/hns3_rss.h | 2 ++ + 3 files changed, 4 insertions(+), 13 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 12afc24910..e994cac314 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -10,15 +10,6 @@ + #include "hns3_logs.h" + #include "hns3_flow.h" + +-/* Default default keys */ +-static uint8_t hns3_hash_key[] = { +- 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, +- 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0, +- 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4, +- 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C, +- 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA +-}; +- + static const uint8_t full_mask[VNI_OR_TNI_LEN] = { 0xFF, 0xFF, 0xFF }; + static const uint8_t zero_mask[VNI_OR_TNI_LEN] = { 0x00, 0x00, 0x00 }; + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 4c546c9363..1003daf03e 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -9,10 +9,8 @@ + #include "hns3_ethdev.h" + #include "hns3_logs.h" + +-/* +- * The hash key used for rss initialization. +- */ +-static const uint8_t hns3_hash_key[] = { ++/* Default hash keys */ ++const uint8_t hns3_hash_key[] = { + 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, + 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0, + 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4, +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 7789f02a08..5b90d3a628 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -88,6 +88,8 @@ static inline uint32_t roundup_pow_of_two(uint32_t x) + return 1UL << fls(x - 1); + } + ++extern const uint8_t hns3_hash_key[]; ++ + struct hns3_adapter; + + int hns3_dev_rss_hash_update(struct rte_eth_dev *dev, +-- +2.22.0 + diff --git a/0114-net-hns3-fix-code-check-warning.patch b/0114-net-hns3-fix-code-check-warning.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ea529d339c01991e21bc3b4bb92de8064c272e0 --- /dev/null +++ b/0114-net-hns3-fix-code-check-warning.patch @@ -0,0 +1,31 @@ +From 1c88a050b04c9dc12458d4127052f542a0919739 Mon Sep 17 00:00:00 2001 +From: "Min Hu (Connor)" +Date: Wed, 1 Jun 2022 11:52:46 +0800 +Subject: [PATCH 114/122] net/hns3: fix code check warning + +In bitwise operation, "val" should be an unsigned type. + +Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") +Cc: stable@dpdk.org + +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_ptp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c +index 1442241a4e..0b0061bba5 100644 +--- a/drivers/net/hns3/hns3_ptp.c ++++ b/drivers/net/hns3/hns3_ptp.c +@@ -81,7 +81,7 @@ hns3_timesync_configure(struct hns3_adapter *hns, bool en) + struct hns3_hw *hw = &hns->hw; + struct hns3_pf *pf = &hns->pf; + struct hns3_cmd_desc desc; +- int val; ++ uint32_t val; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_PTP_MODE, false); +-- +2.22.0 + diff --git a/0115-net-hns3-fix-return-value-for-unsupported-tuple.patch b/0115-net-hns3-fix-return-value-for-unsupported-tuple.patch new file mode 100644 index 0000000000000000000000000000000000000000..3cef72173207a6edf3d1c9e85ff1bfb1def13ad1 --- /dev/null +++ b/0115-net-hns3-fix-return-value-for-unsupported-tuple.patch @@ -0,0 +1,32 @@ +From a0077b01d8ba2b5310ca6fdee7c61e40ae6eeca3 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:47 +0800 +Subject: [PATCH 115/122] net/hns3: fix return value for unsupported tuple + +Driver should return false for unsupported tuple. + +Fixes: 18a4b4c3fa80 ("net/hns3: add default to switch when parsing fd tuple") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_fdir.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index 2a7978ac07..a0d6598e57 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -631,7 +631,7 @@ static bool hns3_fd_convert_tuple(struct hns3_hw *hw, + break; + default: + hns3_warn(hw, "not support tuple of (%u)", tuple); +- break; ++ return false; + } + return true; + } +-- +2.22.0 + diff --git a/0116-net-hns3-modify-a-function-name.patch b/0116-net-hns3-modify-a-function-name.patch new file mode 100644 index 0000000000000000000000000000000000000000..464012acd8f43d373ff7d405529d7b553bdab926 --- /dev/null +++ b/0116-net-hns3-modify-a-function-name.patch @@ -0,0 +1,74 @@ +From 25cd4e3af8f0c5e86bff599ea31a0e4024cf03d2 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:48 +0800 +Subject: [PATCH 116/122] net/hns3: modify a function name + +The meaning of the "hns3_get_count" function is not precise enough. +Change from "hns3_get_count" to "hns3_fd_get_count". + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_fdir.c | 2 +- + drivers/net/hns3/hns3_fdir.h | 2 +- + drivers/net/hns3/hns3_flow.c | 6 +++--- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index a0d6598e57..762b89a51e 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -1099,7 +1099,7 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns) + return 0; + } + +-int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value) ++int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value) + { + struct hns3_fd_get_cnt_cmd *req; + struct hns3_cmd_desc desc; +diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h +index 3376c40c8e..4d18759160 100644 +--- a/drivers/net/hns3/hns3_fdir.h ++++ b/drivers/net/hns3/hns3_fdir.h +@@ -184,7 +184,7 @@ void hns3_fdir_filter_uninit(struct hns3_adapter *hns); + int hns3_fdir_filter_program(struct hns3_adapter *hns, + struct hns3_fdir_rule *rule, bool del); + int hns3_clear_all_fdir_filter(struct hns3_adapter *hns); +-int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); ++int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); + int hns3_restore_all_fdir_filter(struct hns3_adapter *hns); + + #endif /* _HNS3_FDIR_H_ */ +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index e994cac314..b60ad596dc 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -164,13 +164,13 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t indirect, uint32_t id, + "Counter id is used, indirect flag not match"); + /* Clear the indirect counter on first use. */ + if (cnt->indirect && cnt->ref_cnt == 1) +- (void)hns3_get_count(hw, id, &value); ++ (void)hns3_fd_get_count(hw, id, &value); + cnt->ref_cnt++; + return 0; + } + + /* Clear the counter by read ops because the counter is read-clear */ +- ret = hns3_get_count(hw, id, &value); ++ ret = hns3_fd_get_count(hw, id, &value); + if (ret) + return rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, +@@ -210,7 +210,7 @@ hns3_counter_query(struct rte_eth_dev *dev, struct rte_flow *flow, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Can't find counter id"); + +- ret = hns3_get_count(&hns->hw, flow->counter_id, &value); ++ ret = hns3_fd_get_count(&hns->hw, flow->counter_id, &value); + if (ret) { + rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, + NULL, "Read counter fail."); +-- +2.22.0 + diff --git a/0117-net-hns3-unify-the-code-wrap-style.patch b/0117-net-hns3-unify-the-code-wrap-style.patch new file mode 100644 index 0000000000000000000000000000000000000000..3a0dbd462702a19852d9610fe2a0b4bea6861275 --- /dev/null +++ b/0117-net-hns3-unify-the-code-wrap-style.patch @@ -0,0 +1,516 @@ +From 9a1166d20bc7b1b07207ec2f8c1964f59053570b Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:49 +0800 +Subject: [PATCH 117/122] net/hns3: unify the code wrap style + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_cmd.c | 2 +- + drivers/net/hns3/hns3_common.c | 10 +++++----- + drivers/net/hns3/hns3_dcb.c | 5 ++--- + drivers/net/hns3/hns3_ethdev.c | 18 ++++++++---------- + drivers/net/hns3/hns3_ethdev_vf.c | 23 +++++++++++------------ + drivers/net/hns3/hns3_fdir.c | 26 +++++++++++++------------- + drivers/net/hns3/hns3_flow.c | 10 ++++------ + drivers/net/hns3/hns3_rxtx.c | 28 +++++++++++++--------------- + drivers/net/hns3/hns3_stats.c | 28 ++++++++++++++-------------- + 9 files changed, 71 insertions(+), 79 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index 96f8f38cbb..e3d096d9cb 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -108,7 +108,7 @@ hns3_alloc_cmd_queue(struct hns3_hw *hw, int ring_type) + ret = hns3_alloc_cmd_desc(hw, ring); + if (ret) + hns3_err(hw, "descriptor %s alloc error %d", +- (ring_type == HNS3_TYPE_CSQ) ? "CSQ" : "CRQ", ret); ++ (ring_type == HNS3_TYPE_CSQ) ? "CSQ" : "CRQ", ret); + + return ret; + } +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index edd16d8076..7a65db907e 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -604,7 +604,7 @@ hns3_init_mac_addrs(struct rte_eth_dev *dev) + 0); + if (dev->data->mac_addrs == NULL) { + hns3_err(hw, "failed to allocate %zx bytes needed to store MAC addresses", +- sizeof(struct rte_ether_addr) * mac_addrs_capa); ++ sizeof(struct rte_ether_addr) * mac_addrs_capa); + return -ENOMEM; + } + +@@ -680,16 +680,16 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) + ret = hw->ops.bind_ring_with_vector(hw, vec, false, + HNS3_RING_TYPE_TX, i); + if (ret) { +- PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with " +- "vector: %u, ret=%d", i, vec, ret); ++ PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with vector: %u, ret=%d", ++ i, vec, ret); + return ret; + } + + ret = hw->ops.bind_ring_with_vector(hw, vec, false, + HNS3_RING_TYPE_RX, i); + if (ret) { +- PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with " +- "vector: %u, ret=%d", i, vec, ret); ++ PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with vector: %u, ret=%d", ++ i, vec, ret); + return ret; + } + } +diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c +index d88757611c..b22f618e0a 100644 +--- a/drivers/net/hns3/hns3_dcb.c ++++ b/drivers/net/hns3/hns3_dcb.c +@@ -876,9 +876,8 @@ hns3_dcb_pri_tc_base_dwrr_cfg(struct hns3_hw *hw) + + ret = hns3_dcb_pri_weight_cfg(hw, i, dwrr); + if (ret) { +- hns3_err(hw, +- "fail to send priority weight cmd: %d, ret = %d", +- i, ret); ++ hns3_err(hw, "fail to send priority weight cmd: %d, ret = %d", ++ i, ret); + return ret; + } + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 97cf27d2a1..8a8f3f1950 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -1627,7 +1627,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, + ret = hw->ops.del_uc_mac_addr(hw, oaddr); + if (ret) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- oaddr); ++ oaddr); + hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", + mac_str, ret); + +@@ -1659,7 +1659,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, + ret_val = hw->ops.del_uc_mac_addr(hw, mac_addr); + if (ret_val) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_warn(hw, + "Failed to roll back to del setted mac addr(%s): %d", + mac_str, ret_val); +@@ -1670,7 +1670,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, + if (ret_val) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr); + hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", +- mac_str, ret_val); ++ mac_str, ret_val); + } + rte_spinlock_unlock(&hw->lock); + +@@ -1747,7 +1747,7 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) + if (ret == -ENOSPC) + hns3_err(hw, "mc mac vlan table is full"); + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_err(hw, "failed to add mc mac addr(%s): %d", mac_str, ret); + } + +@@ -2676,9 +2676,8 @@ hns3_check_dev_specifications(struct hns3_hw *hw) + { + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_err(hw, "the size of hash lookup table configured (%u)" +- " exceeds the maximum(%u)", hw->rss_ind_tbl_size, +- HNS3_RSS_IND_TBL_SIZE_MAX); ++ hns3_err(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", ++ hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } + +@@ -3916,7 +3915,7 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) + ret = hns3_enable_vlan_filter(hns, false); + if (ret) { + hns3_err(hw, "failed to enable promiscuous mode due to " +- "failure to disable vlan filter, ret = %d", ++ "failure to disable vlan filter, ret = %d", + ret); + err = hns3_set_promisc_mode(hw, false, allmulti); + if (err) +@@ -5993,8 +5992,7 @@ hns3_reset_service(void *param) + timersub(&tv, &tv_start, &tv_delta); + msec = hns3_clock_calctime_ms(&tv_delta); + if (msec > HNS3_RESET_PROCESS_MS) +- hns3_err(hw, "%d handle long time delta %" PRIu64 +- " ms time=%ld.%.6ld", ++ hns3_err(hw, "%d handle long time delta %" PRIu64 " ms time=%ld.%.6ld", + hw->reset.level, msec, + tv.tv_sec, tv.tv_usec); + if (ret == -EAGAIN) +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 0c170797f4..7323e47f15 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -142,7 +142,7 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op) + pos = hns3vf_find_pci_capability(device, PCI_CAP_ID_MSIX); + if (pos) { + ret = rte_pci_read_config(device, &control, sizeof(control), +- (pos + PCI_MSIX_FLAGS)); ++ (pos + PCI_MSIX_FLAGS)); + if (ret < 0) { + PMD_INIT_LOG(ERR, "Failed to read PCI offset 0x%x", + (pos + PCI_MSIX_FLAGS)); +@@ -154,10 +154,10 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op) + else + control &= ~PCI_MSIX_FLAGS_ENABLE; + ret = rte_pci_write_config(device, &control, sizeof(control), +- (pos + PCI_MSIX_FLAGS)); ++ (pos + PCI_MSIX_FLAGS)); + if (ret < 0) { + PMD_INIT_LOG(ERR, "failed to write PCI offset 0x%x", +- (pos + PCI_MSIX_FLAGS)); ++ (pos + PCI_MSIX_FLAGS)); + return -ENXIO; + } + +@@ -199,7 +199,7 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) + false, NULL, 0); + if (ret) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_err(hw, "failed to add uc mac addr(%s), ret = %d", + mac_str, ret); + } +@@ -242,11 +242,11 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, + if (ret == -EPERM) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, + old_addr); +- hns3_warn(hw, "Has permanet mac addr(%s) for vf", ++ hns3_warn(hw, "Has permanent mac addr(%s) for vf", + mac_str); + } else { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_err(hw, "Failed to set mac addr(%s) for vf: %d", + mac_str, ret); + } +@@ -293,7 +293,7 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw, + NULL, 0); + if (ret) { + hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, +- mac_addr); ++ mac_addr); + hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d", + mac_str, ret); + } +@@ -715,9 +715,8 @@ hns3vf_check_dev_specifications(struct hns3_hw *hw) + { + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_warn(hw, "the size of hash lookup table configured (%u)" +- " exceeds the maximum(%u)", hw->rss_ind_tbl_size, +- HNS3_RSS_IND_TBL_SIZE_MAX); ++ hns3_warn(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", ++ hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } + +@@ -1168,8 +1167,8 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask) + int ret = 0; + + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { +- hns3_err(hw, "vf set vlan offload failed during resetting, " +- "mask = 0x%x", mask); ++ hns3_err(hw, "vf set vlan offload failed during resetting, mask = 0x%x", ++ mask); + return -EIO; + } + +diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c +index 762b89a51e..30e5e66772 100644 +--- a/drivers/net/hns3/hns3_fdir.c ++++ b/drivers/net/hns3/hns3_fdir.c +@@ -321,7 +321,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + break; + default: + hns3_err(hw, "Unsupported flow director mode %u", +- pf->fdir.fd_cfg.fd_mode); ++ pf->fdir.fd_cfg.fd_mode); + return -EOPNOTSUPP; + } + +@@ -337,7 +337,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + BIT(INNER_SRC_IP) | BIT(INNER_DST_IP) | + BIT(INNER_SRC_PORT) | BIT(INNER_DST_PORT); + hns3_dbg(hw, "fdir tuple: inner"); ++ "ip_proto ip_tos l4_src_port l4_dst_port>"); + + /* If use max 400bit key, we can support tuples for ether type */ + if (pf->fdir.fd_cfg.max_key_length == MAX_KEY_LENGTH) { +@@ -348,8 +348,8 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + BIT(OUTER_TUN_VNI) | BIT(OUTER_TUN_FLOW_ID) | + BIT(OUTER_ETH_TYPE) | BIT(OUTER_IP_PROTO); + hns3_dbg(hw, "fdir tuple more: inner outer"); ++ "vlan_tag2 sctp_tag> outer"); + } + + /* roce_type is used to filter roce frames +@@ -367,12 +367,11 @@ int hns3_init_fd_config(struct hns3_adapter *hns) + if (ret) + return ret; + +- hns3_dbg(hw, "fdir: stage1 stage2", +- pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1], +- pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1], +- pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2], +- pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]); ++ hns3_dbg(hw, "fdir: stage1 stage2", ++ pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1], ++ pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1], ++ pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2], ++ pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]); + + return hns3_set_fd_key_config(hns); + } +@@ -420,7 +419,7 @@ static int hns3_fd_tcam_config(struct hns3_hw *hw, bool sel_x, int loc, + ret = hns3_cmd_send(hw, desc, FD_TCAM_CMD_NUM); + if (ret) + hns3_err(hw, "Config tcam key fail, ret=%d loc=%d add=%d", +- ret, loc, is_add); ++ ret, loc, is_add); + return ret; + } + +@@ -673,6 +672,7 @@ static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg, + } else if (i == VLAN_NUMBER) { + uint32_t vlan_tag; + uint8_t vlan_num; ++ + if (rule->key_conf.spec.tunnel_type == 0) + vlan_num = rule->key_conf.vlan_num; + else +@@ -758,14 +758,14 @@ static int hns3_config_key(struct hns3_adapter *hns, + ret = hns3_fd_tcam_config(hw, false, rule->location, key_y, true); + if (ret) { + hns3_err(hw, "Config fd key_y fail, loc=%u, ret=%d", +- rule->queue_id, ret); ++ rule->queue_id, ret); + return ret; + } + + ret = hns3_fd_tcam_config(hw, true, rule->location, key_x, true); + if (ret) + hns3_err(hw, "Config fd key_x fail, loc=%u, ret=%d", +- rule->queue_id, ret); ++ rule->queue_id, ret); + return ret; + } + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index b60ad596dc..5e0a9bc93f 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -285,9 +285,8 @@ hns3_handle_action_queue(struct rte_eth_dev *dev, + + queue = (const struct rte_flow_action_queue *)action->conf; + if (queue->index >= hw->data->nb_rx_queues) { +- hns3_err(hw, "queue ID(%u) is greater than number of " +- "available queue (%u) in driver.", +- queue->index, hw->data->nb_rx_queues); ++ hns3_err(hw, "queue ID(%u) is greater than number of available queue (%u) in driver.", ++ queue->index, hw->data->nb_rx_queues); + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + action, "Invalid queue ID in PF"); +@@ -1656,9 +1655,8 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) + } + + if (rss_rule_fail_cnt) { +- hns3_err(hw, "fail to delete all RSS filters, success num = %d " +- "fail num = %d", rss_rule_succ_cnt, +- rss_rule_fail_cnt); ++ hns3_err(hw, "fail to delete all RSS filters, success num = %d fail num = %d", ++ rss_rule_succ_cnt, rss_rule_fail_cnt); + ret = -EIO; + } + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 5a2cfe5a54..3f576fbf4b 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -606,8 +606,8 @@ hns3_send_reset_tqp_cmd(struct hns3_hw *hw, uint16_t queue_id, bool enable) + hns3_set_bit(req->reset_req, HNS3_TQP_RESET_B, enable ? 1 : 0); + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) +- hns3_err(hw, "send tqp reset cmd error, queue_id = %u, " +- "ret = %d", queue_id, ret); ++ hns3_err(hw, "send tqp reset cmd error, queue_id = %u, ret = %d", ++ queue_id, ret); + + return ret; + } +@@ -627,8 +627,8 @@ hns3_get_tqp_reset_status(struct hns3_hw *hw, uint16_t queue_id, + + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) { +- hns3_err(hw, "get tqp reset status error, queue_id = %u, " +- "ret = %d.", queue_id, ret); ++ hns3_err(hw, "get tqp reset status error, queue_id = %u, ret = %d.", ++ queue_id, ret); + return ret; + } + *reset_status = hns3_get_bit(req->ready_to_reset, HNS3_TQP_RESET_B); +@@ -669,7 +669,7 @@ hns3pf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id) + if (!reset_status) { + ret = -ETIMEDOUT; + hns3_err(hw, "reset tqp timeout, queue_id = %u, ret = %d", +- queue_id, ret); ++ queue_id, ret); + goto tqp_reset_fail; + } + +@@ -752,15 +752,14 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw) + for (i = 0; i < hw->cfg_max_queues; i++) { + ret = hns3pf_reset_tqp(hw, i); + if (ret) { +- hns3_err(hw, +- "fail to reset tqp, queue_id = %d, ret = %d.", +- i, ret); ++ hns3_err(hw, "fail to reset tqp, queue_id = %d, ret = %d.", ++ i, ret); + return ret; + } + } + } else if (reset_status != HNS3_RESET_ALL_TQP_SUCCESS) { + hns3_err(hw, "fail to reset all tqps, reset_status = %u.", +- reset_status); ++ reset_status); + return -EIO; + } + +@@ -813,9 +812,8 @@ hns3_reset_all_tqps(struct hns3_adapter *hns) + for (i = 0; i < hw->cfg_max_queues; i++) { + ret = hns3_tqp_enable(hw, i, false); + if (ret) { +- hns3_err(hw, +- "fail to disable tqps before tqps reset, ret = %d.", +- ret); ++ hns3_err(hw, "fail to disable tqps before tqps reset, ret = %d.", ++ ret); + return ret; + } + } +@@ -922,9 +920,9 @@ hns3_reset_queue(struct hns3_hw *hw, uint16_t queue_id, + } + + if (!reset_status) { +- hns3_err(hw, "reset queue timeout, queue_id = %u, " +- "queue_type = %s", queue_id, +- queue_type == HNS3_RING_TYPE_TX ? "Tx" : "Rx"); ++ hns3_err(hw, "reset queue timeout, queue_id = %u, queue_type = %s", ++ queue_id, ++ queue_type == HNS3_RING_TYPE_TX ? "Tx" : "Rx"); + ret = -ETIMEDOUT; + goto queue_reset_fail; + } +diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c +index e69761c8b3..bf8af4531f 100644 +--- a/drivers/net/hns3/hns3_stats.c ++++ b/drivers/net/hns3/hns3_stats.c +@@ -507,8 +507,8 @@ hns3_update_port_rx_ssu_drop_stats(struct hns3_hw *hw) + + req = (struct hns3_query_ssu_cmd *)desc[0].data; + cnt = rte_le_to_cpu_32(req->oq_drop_cnt) + +- rte_le_to_cpu_32(req->full_drop_cnt) + +- rte_le_to_cpu_32(req->part_drop_cnt); ++ rte_le_to_cpu_32(req->full_drop_cnt) + ++ rte_le_to_cpu_32(req->part_drop_cnt); + + stats->ssu_rx_drop_cnt += cnt; + +@@ -532,8 +532,8 @@ hns3_update_port_tx_ssu_drop_stats(struct hns3_hw *hw) + + req = (struct hns3_query_ssu_cmd *)desc[0].data; + cnt = rte_le_to_cpu_32(req->oq_drop_cnt) + +- rte_le_to_cpu_32(req->full_drop_cnt) + +- rte_le_to_cpu_32(req->part_drop_cnt); ++ rte_le_to_cpu_32(req->full_drop_cnt) + ++ rte_le_to_cpu_32(req->part_drop_cnt); + + hw->oerror_stats += cnt; + +@@ -1337,8 +1337,8 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + len = cnt_stats * sizeof(struct rte_eth_xstat); + values_copy = rte_zmalloc("hns3_xstats_values", len, 0); + if (values_copy == NULL) { +- hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed " +- "to store statistics values", len); ++ hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed to store statistics values", ++ len); + return -ENOMEM; + } + +@@ -1359,8 +1359,8 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + + for (i = 0; i < size; i++) { + if (ids[i] >= cnt_stats) { +- hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, " +- "should < %u", i, ids[i], cnt_stats); ++ hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, should < %u", ++ i, ids[i], cnt_stats); + rte_free(values_copy); + return -EINVAL; + } +@@ -1419,8 +1419,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, + len = cnt_stats * sizeof(struct rte_eth_xstat_name); + names_copy = rte_zmalloc("hns3_xstats_names", len, 0); + if (names_copy == NULL) { +- hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed " +- "to store statistics names", len); ++ hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed to store statistics names", ++ len); + return -ENOMEM; + } + +@@ -1428,8 +1428,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, + + for (i = 0; i < size; i++) { + if (ids[i] >= cnt_stats) { +- hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, " +- "should < %u", i, ids[i], cnt_stats); ++ hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, should < %u", ++ i, ids[i], cnt_stats); + rte_free(names_copy); + return -EINVAL; + } +@@ -1501,14 +1501,14 @@ hns3_tqp_stats_init(struct hns3_hw *hw) + struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats; + + tqp_stats->rcb_rx_ring_pktnum = rte_zmalloc("hns3_rx_ring_pkt_num", +- sizeof(uint64_t) * hw->tqps_num, 0); ++ sizeof(uint64_t) * hw->tqps_num, 0); + if (tqp_stats->rcb_rx_ring_pktnum == NULL) { + hns3_err(hw, "failed to allocate rx_ring pkt_num."); + return -ENOMEM; + } + + tqp_stats->rcb_tx_ring_pktnum = rte_zmalloc("hns3_tx_ring_pkt_num", +- sizeof(uint64_t) * hw->tqps_num, 0); ++ sizeof(uint64_t) * hw->tqps_num, 0); + if (tqp_stats->rcb_tx_ring_pktnum == NULL) { + hns3_err(hw, "failed to allocate tx_ring pkt_num."); + rte_free(tqp_stats->rcb_rx_ring_pktnum); +-- +2.22.0 + diff --git a/0118-net-hns3-fix-a-segfault-from-secondary-process.patch b/0118-net-hns3-fix-a-segfault-from-secondary-process.patch new file mode 100644 index 0000000000000000000000000000000000000000..89bcf9de400a5065fe29d0eda9fc9f753b0661e6 --- /dev/null +++ b/0118-net-hns3-fix-a-segfault-from-secondary-process.patch @@ -0,0 +1,39 @@ +From 0526fc076a0e45de04597722128d4a2b87a44255 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Wed, 1 Jun 2022 11:52:50 +0800 +Subject: [PATCH 118/122] net/hns3: fix a segfault from secondary process + +If a hns3 device in the secondary process is attached to do probing +operation, 'rx_queues' and 'tx_queues' in dev->data are null in +eth_dev_fp_ops_setup when calling rte_eth_dev_probing_finish. The primary +process calls dev_start to re-setup their fp_ops. But the secondary process +can't call dev_start and has no chance to do it. If the application sends +and receives packets at this time, a segfault will occur. So this patch +uses the MP communication of the PMD to update the fp_ops of the device in +the secondary process. + +Fixes: 96c33cfb06cf ("net/hns3: fix Rx/Tx functions update") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_rxtx.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 3f576fbf4b..0dc1d8cb60 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4420,6 +4420,8 @@ hns3_eth_dev_fp_ops_config(const struct rte_eth_dev *dev) + fpo[port_id].tx_pkt_prepare = dev->tx_pkt_prepare; + fpo[port_id].rx_descriptor_status = dev->rx_descriptor_status; + fpo[port_id].tx_descriptor_status = dev->tx_descriptor_status; ++ fpo[port_id].rxq.data = dev->data->rx_queues; ++ fpo[port_id].txq.data = dev->data->tx_queues; + } + + void +-- +2.22.0 + diff --git a/0119-net-hns3-fix-TM-capability-incorrectly-defined.patch b/0119-net-hns3-fix-TM-capability-incorrectly-defined.patch new file mode 100644 index 0000000000000000000000000000000000000000..6796c87ca85ac5934d67ab4d43cc63a2006bd425 --- /dev/null +++ b/0119-net-hns3-fix-TM-capability-incorrectly-defined.patch @@ -0,0 +1,33 @@ +From 40df3e3ffa8c645ce7e5c0ff6e698c5bd7cf1ff8 Mon Sep 17 00:00:00 2001 +From: Chengwen Feng +Date: Wed, 1 Jun 2022 11:52:51 +0800 +Subject: [PATCH 119/122] net/hns3: fix TM capability incorrectly defined + +The TM capability should be bit-19 according to the user manual of +firmware. + +Fixes: fc18d1b4b85f ("net/hns3: fix traffic management") +Cc: stable@dpdk.org + +Signed-off-by: Chengwen Feng +Signed-off-by: Min Hu (Connor) +--- + drivers/net/hns3/hns3_cmd.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index f9addc6069..82c999061d 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -323,7 +323,7 @@ enum HNS3_CAPS_BITS { + HNS3_CAPS_UDP_TUNNEL_CSUM_B, + HNS3_CAPS_RAS_IMP_B, + HNS3_CAPS_RXD_ADV_LAYOUT_B = 15, +- HNS3_CAPS_TM_B = 17, ++ HNS3_CAPS_TM_B = 19, + }; + + /* Capabilities of VF dependent on the PF */ +-- +2.22.0 + diff --git a/0120-app-testpmd-add-help-messages-for-multi-process.patch b/0120-app-testpmd-add-help-messages-for-multi-process.patch new file mode 100644 index 0000000000000000000000000000000000000000..6c87ec4ebb4e7269c5d109733dc09cb075c20594 --- /dev/null +++ b/0120-app-testpmd-add-help-messages-for-multi-process.patch @@ -0,0 +1,38 @@ +From 519b373d853909d953ff0c0fc6b15199be516fdd Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 9 Jun 2022 16:52:34 +0800 +Subject: [PATCH 120/122] app/testpmd: add help messages for multi-process + +This patch adds help messages for multi-process. +--num-procs=N: set the total number of multi-process instances. +--proc-id=id: set the id of the current process from multi-process +instances(0 <= id < num-procs). + +Fixes: a550baf24af9 ("app/testpmd: support multi-process") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Ferruh Yigit +--- + app/test-pmd/parameters.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c +index f9185065af..24e03e769c 100644 +--- a/app/test-pmd/parameters.c ++++ b/app/test-pmd/parameters.c +@@ -61,6 +61,9 @@ usage(char* progname) + "extended statistics to show. Used with --stats-period " + "specified or interactive commands that show Rx/Tx statistics " + "(i.e. 'show port stats').\n"); ++ printf(" --num-procs=N: set the total number of multi-process instances.\n"); ++ printf(" --proc-id=id: set the id of the current process from " ++ "multi-process instances (0 <= id < num-procs).\n"); + printf(" --nb-cores=N: set the number of forwarding cores " + "(1 <= N <= %d).\n", nb_lcores); + printf(" --nb-ports=N: set the number of forwarding ports " +-- +2.22.0 + diff --git a/0121-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch b/0121-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch new file mode 100644 index 0000000000000000000000000000000000000000..d080e931d8c77bf8afd04ebaa9ec6ffb3024b3f7 --- /dev/null +++ b/0121-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch @@ -0,0 +1,94 @@ +From 83d21ff84152f5912ce3e53ecb577216243fb4e4 Mon Sep 17 00:00:00 2001 +From: Dmitry Kozlyuk +Date: Mon, 7 Mar 2022 18:48:21 +0200 +Subject: [PATCH 121/122] app/testpmd: fix use of indirect action after port + close + +When a port was closed, indirect actions could remain +with their handles no longer valid. +If a newly attached device was assigned the same ID as the closed port, +those indirect actions became accessible again. +Any attempt to use them resulted in an undefined behavior. +Automatically flush indirect actions when a port is closed. + +Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action") +Cc: stable@dpdk.org + +Signed-off-by: Dmitry Kozlyuk +Acked-by: Matan Azrad +Acked-by: Aman Singh +--- + app/test-pmd/config.c | 31 +++++++++++++++++++++++++++++++ + app/test-pmd/testpmd.c | 1 + + app/test-pmd/testpmd.h | 1 + + 3 files changed, 33 insertions(+) + +diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c +index 496e787edd..a7fffc3d1d 100644 +--- a/app/test-pmd/config.c ++++ b/app/test-pmd/config.c +@@ -1743,6 +1743,37 @@ port_action_handle_destroy(portid_t port_id, + return ret; + } + ++int ++port_action_handle_flush(portid_t port_id) ++{ ++ struct rte_port *port; ++ struct port_indirect_action **tmp; ++ int ret = 0; ++ ++ if (port_id_is_invalid(port_id, ENABLED_WARN) || ++ port_id == (portid_t)RTE_PORT_ALL) ++ return -EINVAL; ++ port = &ports[port_id]; ++ tmp = &port->actions_list; ++ while (*tmp != NULL) { ++ struct rte_flow_error error; ++ struct port_indirect_action *pia = *tmp; ++ ++ /* Poisoning to make sure PMDs update it in case of error. */ ++ memset(&error, 0x44, sizeof(error)); ++ if (pia->handle != NULL && ++ rte_flow_action_handle_destroy ++ (port_id, pia->handle, &error) != 0) { ++ printf("Indirect action #%u not destroyed\n", pia->id); ++ ret = port_flow_complain(&error); ++ tmp = &pia->next; ++ } else { ++ *tmp = pia->next; ++ free(pia); ++ } ++ } ++ return ret; ++} + + /** Get indirect action by port + id */ + struct rte_flow_action_handle * +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index c4be9abe73..ac090bde06 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -3212,6 +3212,7 @@ close_port(portid_t pid) + if (is_proc_primary()) { + port_flow_flush(pi); + port_flex_item_flush(pi); ++ port_action_handle_flush(pi); + rte_eth_dev_close(pi); + } + +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 9c24cb07e0..042802b205 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -881,6 +881,7 @@ int port_action_handle_create(portid_t port_id, uint32_t id, + const struct rte_flow_action *action); + int port_action_handle_destroy(portid_t port_id, + uint32_t n, const uint32_t *action); ++int port_action_handle_flush(portid_t port_id); + struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id, + uint32_t id); + int port_action_handle_update(portid_t port_id, uint32_t id, +-- +2.22.0 + diff --git a/0122-app-testpmd-fix-bonding-slave-devices-not-released.patch b/0122-app-testpmd-fix-bonding-slave-devices-not-released.patch new file mode 100644 index 0000000000000000000000000000000000000000..4d1c23ee4ebff6ae57c6501b0c79080531c70e6b --- /dev/null +++ b/0122-app-testpmd-fix-bonding-slave-devices-not-released.patch @@ -0,0 +1,122 @@ +From f53f8218cfe85b78779cee5d499e7b32f26c4769 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Thu, 9 Jun 2022 19:49:21 +0800 +Subject: [PATCH 122/122] app/testpmd: fix bonding slave devices not released + +Currently, some eth devices are added to bond device, these devices are +not released when the quit command is executed in testpmd. This patch +adds the release operation for all active slaves under a bond device. + +Fixes: 0e545d3047fe ("app/testpmd: check stopping port is not in bonding") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Min Hu (Connor) +Signed-off-by: Dongdong Liu +Acked-by: Ferruh Yigit +--- + app/test-pmd/cmdline.c | 1 + + app/test-pmd/testpmd.c | 41 +++++++++++++++++++++++++++++++++++++++++ + app/test-pmd/testpmd.h | 2 ++ + 3 files changed, 44 insertions(+) + +diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c +index 1991ee3446..1f9fd61394 100644 +--- a/app/test-pmd/cmdline.c ++++ b/app/test-pmd/cmdline.c +@@ -8764,6 +8764,7 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result, + __rte_unused void *data) + { + cmdline_quit(cl); ++ cl_quit = 1; + } + + cmdline_parse_token_string_t cmd_quit_quit = +diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c +index ac090bde06..66d5167f57 100644 +--- a/app/test-pmd/testpmd.c ++++ b/app/test-pmd/testpmd.c +@@ -223,6 +223,7 @@ unsigned int xstats_display_num; /**< Size of extended statistics to show */ + * option. Set flag to exit stats period loop after received SIGINT/SIGTERM. + */ + uint8_t f_quit; ++uint8_t cl_quit; /* Quit testpmd from cmdline. */ + + /* + * Max Rx frame size, set by '--max-pkt-len' parameter. +@@ -3174,11 +3175,39 @@ remove_invalid_ports(void) + nb_cfg_ports = nb_fwd_ports; + } + ++static void ++clear_bonding_slave_device(portid_t *slave_pids, uint16_t num_slaves) ++{ ++ struct rte_port *port; ++ portid_t slave_pid; ++ uint16_t i; ++ ++ for (i = 0; i < num_slaves; i++) { ++ slave_pid = slave_pids[i]; ++ if (port_is_started(slave_pid) == 1) { ++ if (rte_eth_dev_stop(slave_pid) != 0) ++ fprintf(stderr, "rte_eth_dev_stop failed for port %u\n", ++ slave_pid); ++ ++ port = &ports[slave_pid]; ++ port->port_status = RTE_PORT_STOPPED; ++ } ++ ++ clear_port_slave_flag(slave_pid); ++ ++ /* Close slave device when testpmd quit or is killed. */ ++ if (cl_quit == 1 || f_quit == 1) ++ rte_eth_dev_close(slave_pid); ++ } ++} ++ + void + close_port(portid_t pid) + { + portid_t pi; + struct rte_port *port; ++ portid_t slave_pids[RTE_MAX_ETHPORTS]; ++ int num_slaves = 0; + + if (port_id_is_invalid(pid, ENABLED_WARN)) + return; +@@ -3213,7 +3242,19 @@ close_port(portid_t pid) + port_flow_flush(pi); + port_flex_item_flush(pi); + port_action_handle_flush(pi); ++#ifdef RTE_NET_BOND ++ if (port->bond_flag == 1) ++ num_slaves = rte_eth_bond_slaves_get(pi, ++ slave_pids, RTE_MAX_ETHPORTS); ++#endif + rte_eth_dev_close(pi); ++ /* ++ * If this port is bonded device, all slaves under the ++ * device need to be removed or closed. ++ */ ++ if (port->bond_flag == 1 && num_slaves > 0) ++ clear_bonding_slave_device(slave_pids, ++ num_slaves); + } + + free_xstats_display_info(pi); +diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h +index 042802b205..569b4300cf 100644 +--- a/app/test-pmd/testpmd.h ++++ b/app/test-pmd/testpmd.h +@@ -32,6 +32,8 @@ + #define RTE_PORT_CLOSED (uint16_t)2 + #define RTE_PORT_HANDLING (uint16_t)3 + ++extern uint8_t cl_quit; ++ + /* + * It is used to allocate the memory for hash key. + * The hash key size is NIC dependent. +-- +2.22.0 + diff --git a/dpdk.spec b/dpdk.spec index a0d47146b79f3476c8427da8757da158eba727a5..7c81783ddcc14ea2083a88db4042a6eba9fac179 100644 --- a/dpdk.spec +++ b/dpdk.spec @@ -1,6 +1,6 @@ Name: dpdk Version: 21.11 -Release: 11 +Release: 12 Packager: packaging@6wind.com URL: http://dpdk.org %global source_version 21.11 @@ -91,6 +91,43 @@ Patch9082: 0082-ethdev-fix-RSS-update-when-RSS-is-disabled.patch Patch9083: 0083-net-hns3-remove-unnecessary-RSS-switch.patch Patch9084: 0084-app-testpmd-check-statistics-query-before-printing.patch Patch9085: 0085-app-testpmd-fix-MTU-verification.patch +Patch9086: 0086-app-testpmd-fix-port-status-of-bonding-slave-device.patch +Patch9087: 0087-ethdev-clarify-null-location-case-in-xstats-get.patch +Patch9088: 0088-ethdev-simplify-xstats-get-implementation.patch +Patch9089: 0089-net-hns3-fix-xstats-get-return-if-xstats-is-null.patch +Patch9090: 0090-net-ipn3ke-fix-xstats-get-return-if-xstats-is-null.patch +Patch9091: 0091-net-mvpp2-fix-xstats-get-return-if-xstats-is-null.patch +Patch9092: 0092-net-axgbe-fix-xstats-get-return-if-xstats-is-null.patch +Patch9093: 0093-ethdev-fix-memory-leak-in-xstats-telemetry.patch +Patch9094: 0094-ethdev-fix-possible-null-pointer-access.patch +Patch9095: 0095-net-cnxk-fix-possible-null-dereference-in-telemetry.patch +Patch9096: 0096-net-bonding-fix-mbuf-fast-free-usage.patch +Patch9097: 0097-ethdev-fix-port-state-when-stop.patch +Patch9098: 0098-ethdev-fix-port-close-in-secondary-process.patch +Patch9099: 0099-examples-dma-fix-MTU-configuration.patch +Patch9100: 0100-examples-dma-fix-Tx-drop-statistics.patch +Patch9101: 0101-examples-dma-add-force-minimal-copy-size-parameter.patch +Patch9102: 0102-dma-hisilicon-fix-index-returned-when-no-DMA-complet.patch +Patch9103: 0103-test-dma-check-index-when-no-DMA-completed.patch +Patch9104: 0104-dma-hisilicon-enhance-CQ-scan-robustness.patch +Patch9105: 0105-net-failsafe-fix-device-freeing.patch +Patch9106: 0106-net-tap-fix-device-freeing.patch +Patch9107: 0107-net-bonding-fix-RSS-inconsistent-between-bonded-and-.patch +Patch9108: 0108-app-test-fix-bonding-RSS-test-when-disable-RSS.patch +Patch9109: 0109-net-hns3-add-check-for-deferred-start-queue-when-rol.patch +Patch9110: 0110-net-hns3-remove-redundant-parentheses.patch +Patch9111: 0111-net-hns3-adjust-the-data-type-of-some-variables.patch +Patch9112: 0112-net-hns3-fix-an-unreasonable-memset.patch +Patch9113: 0113-net-hns3-remove-duplicate-definition.patch +Patch9114: 0114-net-hns3-fix-code-check-warning.patch +Patch9115: 0115-net-hns3-fix-return-value-for-unsupported-tuple.patch +Patch9116: 0116-net-hns3-modify-a-function-name.patch +Patch9117: 0117-net-hns3-unify-the-code-wrap-style.patch +Patch9118: 0118-net-hns3-fix-a-segfault-from-secondary-process.patch +Patch9119: 0119-net-hns3-fix-TM-capability-incorrectly-defined.patch +Patch9120: 0120-app-testpmd-add-help-messages-for-multi-process.patch +Patch9121: 0121-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch +Patch9122: 0122-app-testpmd-fix-bonding-slave-devices-not-released.patch Patch6001: CVE-2021-3839.patch Patch6002: CVE-2022-0669.patch @@ -215,6 +252,9 @@ strip -g $RPM_BUILD_ROOT/lib/modules/%{kern_devel_ver}/extra/dpdk/igb_uio.ko /usr/sbin/depmod %changelog +* Thu Jun 16 2022 Dongdong Liu - 21.11-12 +- sync patches from upstreaming branch. + * Fri Jun 10 2022 xiusailong - 21.11-11 - fix CVE-2021-3839 CVE-2022-0669