DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Long Wu <long.wu@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 2/2] app/testpmd: add support for bonding port's LACP negotiation
Date: Thu, 16 Feb 2023 15:15:14 +0800	[thread overview]
Message-ID: <20230216071514.29418-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230216071514.29418-1-chaoyong.he@corigine.com>

From: Long Wu <long.wu@corigine.com>

If bonding port is mode4 with disabling dedicated queue and there
are no other packets, forward loop will not call port's TX function
and bonding port will not send LACP packets.

Add sending LACP packets periodically in forward loop to avoid
LACP negotiation failed.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 app/test-pmd/config.c                 | 23 ++++++++++++++
 app/test-pmd/parameters.c             | 10 +++++++
 app/test-pmd/testpmd.c                | 43 ++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h                |  9 ++++++
 doc/guides/testpmd_app_ug/run_app.rst |  4 +++
 5 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 41484c3dde..4b7be9cc25 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -53,6 +53,11 @@
 #ifdef RTE_LIB_GRO
 #include <rte_gro.h>
 #endif
+#ifdef RTE_NET_BOND
+#include <rte_eth_bond.h>
+#include <rte_eth_bond_8023ad.h>
+#endif
+
 #include <rte_hexdump.h>
 
 #include "testpmd.h"
@@ -4401,6 +4406,12 @@ simple_fwd_config_setup(void)
 		fwd_streams[i]->tx_queue  = 0;
 		fwd_streams[i]->peer_addr = fwd_streams[i]->tx_port;
 		fwd_streams[i]->retry_enabled = retry_enabled;
+#ifdef RTE_NET_BOND
+		if (rte_eth_bond_8023ad_dedicated_queues_get(fwd_streams[i]->tx_port) == 0)
+			fwd_streams[i]->bond4_send_periodical_lacp = true;
+		else
+			fwd_streams[i]->bond4_send_periodical_lacp = false;
+#endif
 	}
 }
 
@@ -4462,6 +4473,12 @@ rss_fwd_config_setup(void)
 		fs->tx_queue = rxq;
 		fs->peer_addr = fs->tx_port;
 		fs->retry_enabled = retry_enabled;
+#ifdef RTE_NET_BOND
+		if (rte_eth_bond_8023ad_dedicated_queues_get(fs->tx_port) == 0)
+			fs->bond4_send_periodical_lacp = true;
+		else
+			fs->bond4_send_periodical_lacp = false;
+#endif
 		rxp++;
 		if (rxp < nb_fwd_ports)
 			continue;
@@ -4577,6 +4594,12 @@ dcb_fwd_config_setup(void)
 				fs->tx_queue = txq + j % nb_tx_queue;
 				fs->peer_addr = fs->tx_port;
 				fs->retry_enabled = retry_enabled;
+#ifdef RTE_NET_BOND
+				if (rte_eth_bond_8023ad_dedicated_queues_get(fs->tx_port) == 0)
+					fs->bond4_send_periodical_lacp = true;
+				else
+					fs->bond4_send_periodical_lacp = false;
+#endif
 			}
 			fwd_lcores[lc_id]->stream_nb +=
 				rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue;
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index e734ad9a02..5952b05b57 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -205,6 +205,9 @@ usage(char* progname)
 	printf("  --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n"
 	       "    0x10 - explicit Tx rule, 0x02 - hairpin ports paired\n"
 	       "    0x01 - hairpin ports loop, 0x00 - hairpin port self\n");
+#ifdef RTE_NET_BOND
+	printf("  --bond4-lacp-fwd: enable lacp update in fwd main loop\n");
+#endif
 }
 
 #ifdef RTE_LIB_CMDLINE
@@ -705,6 +708,9 @@ launch_args_parse(int argc, char** argv)
 		{ "rx-mq-mode",                 1, 0, 0 },
 		{ "record-core-cycles",         0, 0, 0 },
 		{ "record-burst-stats",         0, 0, 0 },
+#ifdef RTE_NET_BOND
+		{ "bond4-lacp-fwd",             0, 0, 0 },
+#endif
 		{ PARAM_NUM_PROCS,              1, 0, 0 },
 		{ PARAM_PROC_ID,                1, 0, 0 },
 		{ 0, 0, 0, 0 },
@@ -1462,6 +1468,10 @@ launch_args_parse(int argc, char** argv)
 				num_procs = atoi(optarg);
 			if (!strcmp(lgopts[opt_idx].name, PARAM_PROC_ID))
 				proc_id = atoi(optarg);
+#ifdef RTE_NET_BOND
+			if (!strcmp(lgopts[opt_idx].name, "bond4-lacp-fwd"))
+				bond4_lacp_fwd = 1;
+#endif
 			break;
 		case 'h':
 			usage(argv[0]);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index a6c5dec4c0..732137d5ce 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -68,6 +68,7 @@
 #endif
 #ifdef RTE_NET_BOND
 #include <rte_eth_bond.h>
+#include <rte_eth_bond_8023ad.h>
 #endif
 #ifdef RTE_NET_MLX5
 #include "mlx5_testpmd.h"
@@ -519,6 +520,11 @@ struct gro_status gro_ports[RTE_MAX_ETHPORTS];
 uint8_t gro_flush_cycles = GRO_DEFAULT_FLUSH_CYCLES;
 #endif
 
+#ifdef RTE_NET_BOND
+uint8_t bond4_lacp_fwd;
+#define LACP_UPDATE_PERIOD 10000
+#endif
+
 /*
  * hexadecimal bitmask of RX mq mode can be enabled.
  */
@@ -2252,6 +2258,25 @@ flush_fwd_rx_queues(void)
 	}
 }
 
+#ifdef RTE_NET_BOND
+static inline void
+try_lacp_send_in_fwd(struct fwd_stream **fsm, streamid_t nb_fs)
+{
+	void *qd;
+	streamid_t sm_id;
+	struct rte_eth_fp_ops *p;
+
+	for (sm_id = 0; sm_id < nb_fs; sm_id++) {
+		/* Update bond4 LACP if dedicated queues disabled. */
+		if (fsm[sm_id]->bond4_send_periodical_lacp) {
+			p = &rte_eth_fp_ops[fsm[sm_id]->tx_port];
+			qd = p->txq.data[fsm[sm_id]->tx_queue];
+			rte_eth_bond_8023ad_lacp_send_one(qd);
+		}
+	}
+}
+#endif
+
 static void
 run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
 {
@@ -2268,6 +2293,11 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
 	cnt_ports = nb_ports;
 	tics_datum = rte_rdtsc();
 	tics_per_1sec = rte_get_timer_hz();
+#endif
+#ifdef RTE_NET_BOND
+	uint64_t before_tsc = rte_rdtsc();
+	const uint64_t bond4_lacp_period = (rte_get_tsc_hz() + US_PER_S - 1) /
+			US_PER_S * LACP_UPDATE_PERIOD;
 #endif
 	fsm = &fwd_streams[fc->stream_idx];
 	nb_fs = fc->stream_nb;
@@ -2300,6 +2330,15 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
 			fc->total_cycles += tsc - prev_tsc;
 			prev_tsc = tsc;
 		}
+#ifdef RTE_NET_BOND
+		if (bond4_lacp_fwd != 0) {
+			uint64_t current_tsc = rte_rdtsc();
+			if (unlikely((current_tsc - before_tsc) > bond4_lacp_period)) {
+				try_lacp_send_in_fwd(fsm, nb_fs);
+				before_tsc = current_tsc;
+			}
+		}
+#endif
 	} while (! fc->stopped);
 }
 
@@ -4462,7 +4501,9 @@ main(int argc, char** argv)
 #ifdef RTE_LIB_LATENCYSTATS
 	latencystats_enabled = 0;
 #endif
-
+#ifdef RTE_NET_BOND
+	bond4_lacp_fwd = 0;
+#endif
 	/* on FreeBSD, mlockall() is disabled by default */
 #ifdef RTE_EXEC_ENV_FREEBSD
 	do_mlockall = 0;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index b9c77a7a96..5d6673214f 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -175,6 +175,11 @@ struct fwd_stream {
 	unsigned int gro_times;	/**< GRO operation times */
 #endif
 	uint64_t busy_cycles; /**< used with --record-core-cycles */
+	uint64_t     core_cycles; /**< used for RX and TX processing */
+#ifdef RTE_NET_BOND
+	bool bond4_send_periodical_lacp;
+	/**< Send LACP packets periodically in forward loop */
+#endif
 	struct pkt_burst_stats rx_burst_stats;
 	struct pkt_burst_stats tx_burst_stats;
 	struct fwd_lcore *lcore; /**< Lcore being scheduled. */
@@ -582,6 +587,10 @@ extern lcoreid_t bitrate_lcore_id;
 extern uint8_t bitrate_enabled;
 #endif
 
+#ifdef RTE_NET_BOND
+extern uint8_t bond4_lacp_fwd;
+#endif
+
 extern uint32_t max_rx_pkt_len;
 
 /*
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index 3ec3d4f5e6..24aaa9d229 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -538,6 +538,10 @@ The command line options are:
 
     Enable display of RX and TX burst stats.
 
+*   ``--bond4-lacp-fwd``
+
+    Enable LACP packets sending in main forward loop to avoid LACP negotiation failed.
+
 *   ``--hairpin-mode=0xXXXX``
 
     Set the hairpin port configuration with bitmask, only valid when hairpin queues number is set::
-- 
2.29.3


  parent reply	other threads:[~2023-02-16  7:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16  7:15 [PATCH 0/2] enhance bonding PMD to support the " Chaoyong He
2023-02-16  7:15 ` [PATCH 1/2] net/bonding: add independent LACP sending function Chaoyong He
2023-02-16 19:47   ` Stephen Hemminger
2023-02-20  9:46     ` Simon Horman
2023-02-20 16:31       ` Stephen Hemminger
2023-02-22  6:47         ` Chaoyong He
2023-02-16  7:15 ` Chaoyong He [this message]
2023-02-16  8:32 ` [PATCH v2 0/2] enhance bonding PMD to support the LACP negotiation Chaoyong He
2023-02-16  8:32   ` [PATCH v2 1/2] net/bonding: add independent LACP sending function Chaoyong He
2023-02-16  8:32   ` [PATCH v2 2/2] app/testpmd: add support for bonding port's LACP negotiation Chaoyong He
2023-02-16 17:05     ` Ferruh Yigit
2023-02-22  6:47       ` Chaoyong He
2023-03-01  2:48   ` [PATCH v3 0/2] enhance bonding PMD to support the " Chaoyong He
2023-03-01  2:48     ` [PATCH v3 1/2] net/bonding: add independent LACP sending function Chaoyong He
2023-03-01  2:48     ` [PATCH v3 2/2] app/testpmd: add support for bonding port's LACP negotiation Chaoyong He
2023-03-15 12:03     ` [PATCH v3 0/2] enhance bonding PMD to support the " Niklas Söderlund
2023-05-12  1:50     ` Chaoyong He
2023-06-06  1:23       ` Chaoyong He
2023-06-06 16:48         ` Ferruh Yigit
2023-06-07  3:10           ` Chaoyong He
2023-06-23 13:32             ` Ferruh Yigit
2023-06-25  1:32               ` humin (Q)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230216071514.29418-3-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).