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 v3 2/2] app/testpmd: add support for bonding port's LACP negotiation
Date: Wed,  1 Mar 2023 10:48:26 +0800	[thread overview]
Message-ID: <20230301024826.885727-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230301024826.885727-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                 | 19 ++++++++++++++
 app/test-pmd/parameters.c             |  4 +++
 app/test-pmd/testpmd.c                | 37 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  4 +++
 doc/guides/testpmd_app_ug/run_app.rst |  4 +++
 5 files changed, 68 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4121c5c9bb..02757f34de 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"
@@ -4439,6 +4444,17 @@ fwd_topology_tx_port_get(portid_t rxp)
 	}
 }
 
+static inline void
+fwd_config_bond4_send_periodical_lacp(struct fwd_stream *fwd_stream)
+{
+#ifdef RTE_NET_BOND
+	if (rte_eth_bond_8023ad_dedicated_queues_get(fwd_stream->tx_port) == 0)
+		fwd_stream->bond4_send_periodical_lacp = true;
+#else
+	RTE_SET_USED(fwd_stream);
+#endif
+}
+
 static void
 simple_fwd_config_setup(void)
 {
@@ -4469,6 +4485,7 @@ 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;
+		fwd_config_bond4_send_periodical_lacp(fwd_streams[i]);
 	}
 }
 
@@ -4530,6 +4547,7 @@ rss_fwd_config_setup(void)
 		fs->tx_queue = rxq;
 		fs->peer_addr = fs->tx_port;
 		fs->retry_enabled = retry_enabled;
+		fwd_config_bond4_send_periodical_lacp(fs);
 		rxp++;
 		if (rxp < nb_fwd_ports)
 			continue;
@@ -4645,6 +4663,7 @@ dcb_fwd_config_setup(void)
 				fs->tx_queue = txq + j % nb_tx_queue;
 				fs->peer_addr = fs->tx_port;
 				fs->retry_enabled = retry_enabled;
+				fwd_config_bond4_send_periodical_lacp(fs);
 			}
 			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..0fee5c5c94 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -205,6 +205,7 @@ 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");
+	printf("  --bond4-lacp-fwd: enable LACP update in fwd main loop\n");
 }
 
 #ifdef RTE_LIB_CMDLINE
@@ -705,6 +706,7 @@ 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 },
+		{ "bond4-lacp-fwd",             0, 0, 0 },
 		{ PARAM_NUM_PROCS,              1, 0, 0 },
 		{ PARAM_PROC_ID,                1, 0, 0 },
 		{ 0, 0, 0, 0 },
@@ -1462,6 +1464,8 @@ launch_args_parse(int argc, char** argv)
 				num_procs = atoi(optarg);
 			if (!strcmp(lgopts[opt_idx].name, PARAM_PROC_ID))
 				proc_id = atoi(optarg);
+			if (!strcmp(lgopts[opt_idx].name, "bond4-lacp-fwd"))
+				bond4_lacp_fwd = 1;
 			break;
 		case 'h':
 			usage(argv[0]);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0c14325b8d..7755243cd6 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,9 @@ struct gro_status gro_ports[RTE_MAX_ETHPORTS];
 uint8_t gro_flush_cycles = GRO_DEFAULT_FLUSH_CYCLES;
 #endif
 
+uint8_t bond4_lacp_fwd;
+#define LACP_UPDATE_PERIOD 10000
+
 /*
  * hexadecimal bitmask of RX mq mode can be enabled.
  */
@@ -2252,6 +2256,28 @@ flush_fwd_rx_queues(void)
 	}
 }
 
+static inline void
+try_lacp_send_in_fwd(struct fwd_stream **fsm, streamid_t nb_fs)
+{
+#ifdef RTE_NET_BOND
+	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);
+		}
+	}
+#else
+	RTE_SET_USED(fsm);
+	RTE_SET_USED(nb_fs);
+#endif
+}
+
 static void
 run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
 {
@@ -2269,6 +2295,9 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
 	tics_datum = rte_rdtsc();
 	tics_per_1sec = rte_get_timer_hz();
 #endif
+	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;
 	fsm = &fwd_streams[fc->stream_idx];
 	nb_fs = fc->stream_nb;
 	prev_tsc = rte_rdtsc();
@@ -2300,6 +2329,13 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
 			fc->total_cycles += tsc - prev_tsc;
 			prev_tsc = tsc;
 		}
+		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;
+			}
+		}
 	} while (! fc->stopped);
 }
 
@@ -4462,6 +4498,7 @@ main(int argc, char** argv)
 #ifdef RTE_LIB_LATENCYSTATS
 	latencystats_enabled = 0;
 #endif
+	bond4_lacp_fwd = 0;
 
 	/* on FreeBSD, mlockall() is disabled by default */
 #ifdef RTE_EXEC_ENV_FREEBSD
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 329a6378a1..8f88223069 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -175,6 +175,8 @@ struct fwd_stream {
 	unsigned int gro_times;	/**< GRO operation times */
 #endif
 	uint64_t busy_cycles; /**< used with --record-core-cycles */
+	bool bond4_send_periodical_lacp;
+	/**< Send LACP packets periodically in forward loop */
 	struct pkt_burst_stats rx_burst_stats;
 	struct pkt_burst_stats tx_burst_stats;
 	struct fwd_lcore *lcore; /**< Lcore being scheduled. */
@@ -583,6 +585,8 @@ extern lcoreid_t bitrate_lcore_id;
 extern uint8_t bitrate_enabled;
 #endif
 
+extern uint8_t bond4_lacp_fwd;
+
 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 f85f323033..8ea8aefde6 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.39.1


  parent reply	other threads:[~2023-03-01  2:49 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 ` [PATCH 2/2] app/testpmd: add support for bonding port's LACP negotiation Chaoyong He
2023-02-16  8:32 ` [PATCH v2 0/2] enhance bonding PMD to support the " 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     ` Chaoyong He [this message]
2023-03-15 12:03     ` [PATCH v3 0/2] enhance bonding PMD to support the LACP negotiation 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=20230301024826.885727-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).