patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display
@ 2022-07-19  2:49 Huisong Li
  2022-07-19  2:49 ` [PATCH 19.11 1/4] app/testpmd: fix port status of bonding slave device Huisong Li
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Huisong Li @ 2022-07-19  2:49 UTC (permalink / raw)
  To: stable, christian.ehrhardt
  Cc: liudongdong3, fengchengwen, huangdaode, haijie1, lihuisong

Backporting some bonding bugfix and supported RSS offload display.

Huisong Li (4):
  app/testpmd: fix port status of bonding slave device
  app/testpmd: fix bonding slave devices not released
  app/testpmd: fix supported RSS offload display
  net/bonding: fix stopping non-active slaves

 app/test-pmd/cmdline.c                 |  2 +
 app/test-pmd/config.c                  | 37 ++++++----
 app/test-pmd/testpmd.c                 | 94 ++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                 |  7 +-
 drivers/net/bonding/rte_eth_bond_pmd.c |  9 +--
 5 files changed, 132 insertions(+), 17 deletions(-)

-- 
2.22.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 19.11 1/4] app/testpmd: fix port status of bonding slave device
  2022-07-19  2:49 [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Huisong Li
@ 2022-07-19  2:49 ` Huisong Li
  2022-07-19  2:49 ` [PATCH 19.11 2/4] app/testpmd: fix bonding slave devices not released Huisong Li
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Huisong Li @ 2022-07-19  2:49 UTC (permalink / raw)
  To: stable, christian.ehrhardt
  Cc: liudongdong3, fengchengwen, huangdaode, haijie1, lihuisong

[ upstream commit e46372d7b082706718bb17981ae632e4e4d56414 ]

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")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
Acked-by: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>
---
 app/test-pmd/cmdline.c |  1 +
 app/test-pmd/testpmd.c | 56 ++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h |  3 ++-
 3 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 3a2ba414c8..b7a59203ac 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -6229,6 +6229,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result,
 			printf("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 2a182eda20..ba4c3dafb7 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -60,6 +60,9 @@
 #ifdef RTE_LIBRTE_LATENCY_STATS
 #include <rte_latencystats.h>
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+#include <rte_eth_bond.h>
+#endif
 
 #include "testpmd.h"
 
@@ -2295,6 +2298,38 @@ setup_hairpin_queues(portid_t pi)
 	return 0;
 }
 
+static int
+change_bonding_slave_port_status(portid_t bond_pid, bool is_stop)
+{
+#ifdef RTE_LIBRTE_PMD_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;
+}
+
 int
 start_port(portid_t pid)
 {
@@ -2467,6 +2502,15 @@ start_port(portid_t pid)
 							"stopped\n", pi);
 			continue;
 		}
+		/*
+		 * 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) {
+			if (change_bonding_slave_port_status(pi, false) != 0)
+				continue;
+		}
 
 		if (rte_atomic16_cmpset(&(port->port_status),
 			RTE_PORT_HANDLING, RTE_PORT_STARTED) == 0)
@@ -2527,6 +2571,18 @@ stop_port(portid_t pid)
 
 		rte_eth_dev_stop(pi);
 
+		/*
+		 * 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) {
+			if (change_bonding_slave_port_status(pi, true) != 0) {
+				RTE_LOG(ERR, EAL, "Fail to change bonding slave port status %u\n",
+					pi);
+			}
+		}
+
 		if (rte_atomic16_cmpset(&(port->port_status),
 			RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0)
 			printf("Port %d can not be set into stopped\n", pi);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 334bcc28e6..2690dda2e2 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -183,7 +183,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. */
 	const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
 	const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
-- 
2.22.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 19.11 2/4] app/testpmd: fix bonding slave devices not released
  2022-07-19  2:49 [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Huisong Li
  2022-07-19  2:49 ` [PATCH 19.11 1/4] app/testpmd: fix port status of bonding slave device Huisong Li
@ 2022-07-19  2:49 ` Huisong Li
  2022-07-19  2:49 ` [PATCH 19.11 3/4] app/testpmd: fix supported RSS offload display Huisong Li
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Huisong Li @ 2022-07-19  2:49 UTC (permalink / raw)
  To: stable, christian.ehrhardt
  Cc: liudongdong3, fengchengwen, huangdaode, haijie1, lihuisong

[ upstream commit 3889a3220c9b93f07dfdf95e30b2661e6e3f698f ]

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")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
 app/test-pmd/cmdline.c |  1 +
 app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h |  2 ++
 3 files changed, 41 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b7a59203ac..a2e65a7e4d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -8058,6 +8058,7 @@ static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
 			    __attribute__((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 ba4c3dafb7..cce2cbb5c2 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -209,6 +209,7 @@ uint16_t stats_period; /**< Period to show statistics (disabled by default) */
  * option. Set flag to exit stats period loop after received SIGINT/SIGTERM.
  */
 uint8_t f_quit;
+uint8_t cl_quit; /* Quit testpmd from cmdline. */
 
 /*
  * Configuration of packet segments used by the "txonly" processing engine.
@@ -2616,11 +2617,36 @@ 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) {
+			rte_eth_dev_stop(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;
@@ -2656,7 +2682,19 @@ close_port(portid_t pid)
 
 		if (port->flow_list)
 			port_flow_flush(pi);
+
+#ifdef RTE_LIBRTE_PMD_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);
 
 		remove_invalid_ports();
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 2690dda2e2..a3ae3f392a 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -23,6 +23,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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 19.11 3/4] app/testpmd: fix supported RSS offload display
  2022-07-19  2:49 [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Huisong Li
  2022-07-19  2:49 ` [PATCH 19.11 1/4] app/testpmd: fix port status of bonding slave device Huisong Li
  2022-07-19  2:49 ` [PATCH 19.11 2/4] app/testpmd: fix bonding slave devices not released Huisong Li
@ 2022-07-19  2:49 ` Huisong Li
  2022-07-19  2:49 ` [PATCH 19.11 4/4] net/bonding: fix stopping non-active slaves Huisong Li
  2022-08-03  9:55 ` [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Christian Ehrhardt
  4 siblings, 0 replies; 6+ messages in thread
From: Huisong Li @ 2022-07-19  2:49 UTC (permalink / raw)
  To: stable, christian.ehrhardt
  Cc: liudongdong3, fengchengwen, huangdaode, haijie1, lihuisong

[ upstream commit 3c23ee6cdddf28641f52f31ced84d3feb867027c ]

The rte_eth_dev_info.flow_type_rss_offloads is populated in terms of
RTE_ETH_RSS_* bits. If PMD sets RTE_ETH_RSS_L3_SRC_ONLY to
dev_info->flow_type_rss_offloads. testpmd will display "user defined 63"
when run 'show port info 0'. Because testpmd use flowtype_to_str()
to display the supported RSS offload of PMD. In fact, the function is
used to display flow type in FDIR commands for i40e or ixgbe. This patch
uses the RTE_ETH_RSS_* bits to display supported RSS offload of PMD.

Fixes: b12964f621dc ("ethdev: unification of RSS offload types")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
 app/test-pmd/config.c  | 37 +++++++++++++++++++++++++------------
 app/test-pmd/testpmd.h |  2 ++
 2 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 7d826632dc..61c1716971 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -61,8 +61,6 @@
 
 #define NS_PER_SEC 1E9
 
-static char *flowtype_to_str(uint16_t flow_type);
-
 static const struct {
 	enum tx_pkt_split split;
 	const char *name;
@@ -555,6 +553,19 @@ device_infos_display(const char *identifier)
 	};
 }
 
+const char *
+rsstypes_to_str(uint64_t rss_type)
+{
+	uint16_t i;
+
+	for (i = 0; rss_type_table[i].str != NULL; i++) {
+		if (rss_type_table[i].rss_type == rss_type)
+			return rss_type_table[i].str;
+	}
+
+	return NULL;
+}
+
 void
 port_infos_display(portid_t port_id)
 {
@@ -649,19 +660,21 @@ port_infos_display(portid_t port_id)
 	if (!dev_info.flow_type_rss_offloads)
 		printf("No RSS offload flow type is supported.\n");
 	else {
+		uint64_t rss_offload_types = dev_info.flow_type_rss_offloads;
 		uint16_t i;
-		char *p;
 
 		printf("Supported RSS offload flow types:\n");
-		for (i = RTE_ETH_FLOW_UNKNOWN + 1;
-		     i < sizeof(dev_info.flow_type_rss_offloads) * CHAR_BIT; i++) {
-			if (!(dev_info.flow_type_rss_offloads & (1ULL << i)))
-				continue;
-			p = flowtype_to_str(i);
-			if (p)
-				printf("  %s\n", p);
-			else
-				printf("  user defined %d\n", i);
+		for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
+			uint64_t rss_offload = 1ULL << i;
+
+			if ((rss_offload_types & rss_offload) != 0) {
+				const char *p = rsstypes_to_str(rss_offload);
+				if (p)
+					printf("  %s\n", p);
+				else
+					printf("  user defined %u\n",
+					       i);
+			}
 		}
 	}
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a3ae3f392a..0284538c50 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -823,6 +823,8 @@ int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 void port_rss_hash_conf_show(portid_t port_id, int show_rss_key);
 void port_rss_hash_key_update(portid_t port_id, char rss_type[],
 			      uint8_t *hash_key, uint8_t hash_key_len);
+const char *rsstypes_to_str(uint64_t rss_type);
+
 int rx_queue_id_is_invalid(queueid_t rxq_id);
 int tx_queue_id_is_invalid(queueid_t txq_id);
 void setup_gro(const char *onoff, portid_t port_id);
-- 
2.22.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 19.11 4/4] net/bonding: fix stopping non-active slaves
  2022-07-19  2:49 [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Huisong Li
                   ` (2 preceding siblings ...)
  2022-07-19  2:49 ` [PATCH 19.11 3/4] app/testpmd: fix supported RSS offload display Huisong Li
@ 2022-07-19  2:49 ` Huisong Li
  2022-08-03  9:55 ` [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Christian Ehrhardt
  4 siblings, 0 replies; 6+ messages in thread
From: Huisong Li @ 2022-07-19  2:49 UTC (permalink / raw)
  To: stable, christian.ehrhardt
  Cc: liudongdong3, fengchengwen, huangdaode, haijie1, lihuisong

[ upstream commit f5e72e8e8d57b331baf1a86d15eb7fae921f57fb ]

When stopping a bonded port, all slaves should be stopped. But only active
slaves are stopped.
So fix by stopping all slave ports and later do "deactivate_slave()" for
active slaves.

Fixes: 0911d4ec0183 ("net/bonding: fix crash when stopping mode 4 port")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5b1507e817..191c821b46 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2089,13 +2089,14 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	internals->link_status_polling_enabled = 0;
 	for (i = 0; i < internals->slave_count; i++) {
 		uint16_t slave_id = internals->slaves[i].port_id;
+
+		internals->slaves[i].last_link_status = 0;
+		rte_eth_dev_stop(slave_id);
+		/* active slaves need to be deactivated. */
 		if (find_slave_by_id(internals->active_slaves,
 				internals->active_slave_count, slave_id) !=
-						internals->active_slave_count) {
-			internals->slaves[i].last_link_status = 0;
-			rte_eth_dev_stop(slave_id);
+					internals->active_slave_count)
 			deactivate_slave(eth_dev, slave_id);
-		}
 	}
 }
 
-- 
2.22.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display
  2022-07-19  2:49 [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Huisong Li
                   ` (3 preceding siblings ...)
  2022-07-19  2:49 ` [PATCH 19.11 4/4] net/bonding: fix stopping non-active slaves Huisong Li
@ 2022-08-03  9:55 ` Christian Ehrhardt
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Ehrhardt @ 2022-08-03  9:55 UTC (permalink / raw)
  To: Huisong Li; +Cc: stable, liudongdong3, fengchengwen, huangdaode, haijie1

On Tue, Jul 19, 2022 at 4:50 AM Huisong Li <lihuisong@huawei.com> wrote:
>
> Backporting some bonding bugfix and supported RSS offload display.

Thank you,
your patch was too late in regard to my original deadline and I was
then unavailable for a while.
In the meantime more patches came in and I do not want to waste any of
them just because they were late.

Your patch is applied to the WIP branch now, but currently testing of
-rc1 is going on which I do not want to disrupt.

If we need an -rc2 anyway or generally have the time to do an -rc2
without too much disruption it will be in 19.11.13, otherwise it is
already queued for 19.11.14

Applied all four of them

> Huisong Li (4):
>   app/testpmd: fix port status of bonding slave device
>   app/testpmd: fix bonding slave devices not released
>   app/testpmd: fix supported RSS offload display
>   net/bonding: fix stopping non-active slaves
>
>  app/test-pmd/cmdline.c                 |  2 +
>  app/test-pmd/config.c                  | 37 ++++++----
>  app/test-pmd/testpmd.c                 | 94 ++++++++++++++++++++++++++
>  app/test-pmd/testpmd.h                 |  7 +-
>  drivers/net/bonding/rte_eth_bond_pmd.c |  9 +--
>  5 files changed, 132 insertions(+), 17 deletions(-)
>
> --
> 2.22.0
>


-- 
Christian Ehrhardt
Senior Staff Engineer, Ubuntu Server
Canonical Ltd

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-03  9:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19  2:49 [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Huisong Li
2022-07-19  2:49 ` [PATCH 19.11 1/4] app/testpmd: fix port status of bonding slave device Huisong Li
2022-07-19  2:49 ` [PATCH 19.11 2/4] app/testpmd: fix bonding slave devices not released Huisong Li
2022-07-19  2:49 ` [PATCH 19.11 3/4] app/testpmd: fix supported RSS offload display Huisong Li
2022-07-19  2:49 ` [PATCH 19.11 4/4] net/bonding: fix stopping non-active slaves Huisong Li
2022-08-03  9:55 ` [PATCH 19.11 0/4] backporting some bonding bugfix and RSS display Christian Ehrhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).