DPDK patches and discussions
 help / color / mirror / Atom feed
From: Robert Sanford <rsanford2@gmail.com>
To: dev@dpdk.org
Cc: chas3@att.com, humin29@huawei.com
Subject: [PATCH 5/7] net/bonding: add LACP short timeout to tests
Date: Wed, 15 Dec 2021 13:19:59 -0500	[thread overview]
Message-ID: <1639592401-56845-6-git-send-email-rsanford@akamai.com> (raw)
In-Reply-To: <1639592401-56845-1-git-send-email-rsanford@akamai.com>

- Add "set bonding lacp timeout_ctrl <port_id> on|off" to testpmd.
- Add "test_mode4_lacp_timeout_control" to app/test.

Signed-off-by: Robert Sanford <rsanford@akamai.com>
---
 app/test-pmd/cmdline.c             | 77 ++++++++++++++++++++++++++++++++++++++
 app/test/test_link_bonding_mode4.c | 65 ++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 9fd2c2a..b0c2fb4 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -633,6 +633,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)\n"
 			"	Set Aggregation mode for IEEE802.3AD (mode 4)\n\n"
 
+			"set bonding lacp timeout_ctrl (port_id) (on|off)\n"
+				"Configure LACP partner to use fast|slow periodic tx interval.\n\n"
+
 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
 
@@ -6192,6 +6195,7 @@ static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
 		printf("\taggregation mode: invalid\n");
 		break;
 	}
+	printf("\tlacp timeout control: %u\n", conf->lacp_timeout_control);
 
 	printf("\n");
 }
@@ -6863,6 +6867,78 @@ cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
 };
 
 
+/* *** SET LACP TIMEOUT CONTROL ON BONDED DEVICE *** */
+struct cmd_set_lacp_timeout_control_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t bonding;
+	cmdline_fixed_string_t lacp;
+	cmdline_fixed_string_t timeout_ctrl;
+	uint16_t port_id;
+	cmdline_fixed_string_t on_off;
+};
+
+static void
+cmd_set_lacp_timeout_control_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_set_lacp_timeout_control_result *res = parsed_result;
+	struct rte_eth_bond_8023ad_conf port_conf;
+	uint8_t on_off = 0;
+	int ret;
+
+	if (!strcmp(res->on_off, "on"))
+		on_off = 1;
+
+	ret = rte_eth_bond_8023ad_conf_get(res->port_id, &port_conf);
+	if (ret != 0) {
+		fprintf(stderr, "\tGet bonded device %u lacp conf failed\n",
+			res->port_id);
+		return;
+	}
+
+	port_conf.lacp_timeout_control = on_off;
+	ret = rte_eth_bond_8023ad_setup(res->port_id, &port_conf);
+	if (ret != 0)
+		fprintf(stderr, "\tSetup bonded device %u lacp conf failed\n",
+			res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_set_lacp_timeout_control_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_lacp_timeout_control_result,
+				set, "set");
+cmdline_parse_token_string_t cmd_set_lacp_timeout_control_bonding =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_lacp_timeout_control_result,
+				bonding, "bonding");
+cmdline_parse_token_string_t cmd_set_lacp_timeout_control_lacp =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_lacp_timeout_control_result,
+				lacp, "lacp");
+cmdline_parse_token_string_t cmd_set_lacp_timeout_control_timeout_ctrl =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_lacp_timeout_control_result,
+				timeout_ctrl, "timeout_ctrl");
+cmdline_parse_token_num_t cmd_set_lacp_timeout_control_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_lacp_timeout_control_result,
+				port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_set_lacp_timeout_control_on_off =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_lacp_timeout_control_result,
+				on_off, "on#off");
+
+cmdline_parse_inst_t cmd_set_lacp_timeout_control = {
+	.f = cmd_set_lacp_timeout_control_parsed,
+	.data = (void *) 0,
+	.help_str = "set bonding lacp timeout_ctrl <port_id> on|off: "
+		"Configure partner to use fast|slow periodic tx interval",
+	.tokens = {
+		(void *)&cmd_set_lacp_timeout_control_set,
+		(void *)&cmd_set_lacp_timeout_control_bonding,
+		(void *)&cmd_set_lacp_timeout_control_lacp,
+		(void *)&cmd_set_lacp_timeout_control_timeout_ctrl,
+		(void *)&cmd_set_lacp_timeout_control_port_id,
+		(void *)&cmd_set_lacp_timeout_control_on_off,
+		NULL
+	}
+};
+
 #endif /* RTE_NET_BOND */
 
 /* *** SET FORWARDING MODE *** */
@@ -17728,6 +17804,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
+	(cmdline_parse_inst_t *) &cmd_set_lacp_timeout_control,
 #endif
 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
diff --git a/app/test/test_link_bonding_mode4.c b/app/test/test_link_bonding_mode4.c
index 2be86d5..68f77ec 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -735,6 +735,63 @@ test_mode4_agg_mode_selection(void)
 }
 
 static int
+test_mode4_lacp_timeout_control(void)
+{
+	int retval;
+	int iterations;
+	size_t i;
+	struct slave_conf *slave;
+	uint16_t port_id = test_params.bonded_port_id;
+	struct rte_eth_bond_8023ad_conf conf;
+	struct rte_eth_bond_8023ad_slave_info info;
+	uint8_t on_off = 0;
+	uint8_t lacp_timeout_flag = 0;
+
+	retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
+	TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
+
+	/* Iteration 0: Verify that LACP timeout control is off by default.
+	 * Iteration 1: Verify that we can set LACP timeout control.
+	 * Iteration 2: Verify that we can reset LACP timeout control.
+	 */
+	for (iterations = 0; iterations < 3; iterations++) {
+		/* Verify that bond conf has expected timeout control value.*/
+		retval = rte_eth_bond_8023ad_conf_get(port_id, &conf);
+		TEST_ASSERT_SUCCESS(retval, "Failed to get LACP conf");
+		TEST_ASSERT_EQUAL(conf.lacp_timeout_control, on_off,
+			"Wrong LACP timeout control value");
+
+		/* State machine must run to propagate new timeout control
+		 * value to slaves (iterations 1 and 2). */
+		retval = bond_handshake();
+		TEST_ASSERT_SUCCESS(retval, "Bond handshake failed");
+
+		/* Verify that slaves' actor states have expected value.*/
+		FOR_EACH_PORT(i, slave) {
+			retval = rte_eth_bond_8023ad_slave_info(port_id,
+				slave->port_id, &info);
+			TEST_ASSERT_SUCCESS(retval,
+				"Failed to get LACP slave info");
+			TEST_ASSERT_EQUAL((info.actor_state &
+				STATE_LACP_SHORT_TIMEOUT), lacp_timeout_flag,
+				" Wrong LACP slave info timeout flag");
+		}
+
+		/* Toggle timeout control. */
+		on_off ^= 1;
+		lacp_timeout_flag ^= STATE_LACP_SHORT_TIMEOUT;
+		conf.lacp_timeout_control = on_off;
+		retval = rte_eth_bond_8023ad_setup(port_id, &conf);
+		TEST_ASSERT_SUCCESS(retval, "Failed to setup LACP conf");
+	}
+
+	retval = remove_slaves_and_stop_bonded_device();
+	TEST_ASSERT_SUCCESS(retval, "Test cleanup failed.");
+
+	return TEST_SUCCESS;
+}
+
+static int
 generate_packets(struct rte_ether_addr *src_mac,
 	struct rte_ether_addr *dst_mac, uint16_t count, struct rte_mbuf **buf)
 {
@@ -1649,6 +1706,12 @@ test_mode4_ext_lacp_wrapper(void)
 	return test_mode4_executor(&test_mode4_ext_lacp);
 }
 
+static int
+test_mode4_lacp_timeout_control_wrapper(void)
+{
+	return test_mode4_executor(&test_mode4_lacp_timeout_control);
+}
+
 static struct unit_test_suite link_bonding_mode4_test_suite  = {
 	.suite_name = "Link Bonding mode 4 Unit Test Suite",
 	.setup = test_setup,
@@ -1665,6 +1728,8 @@ static struct unit_test_suite link_bonding_mode4_test_suite  = {
 				test_mode4_ext_ctrl_wrapper),
 		TEST_CASE_NAMED("test_mode4_ext_lacp",
 				test_mode4_ext_lacp_wrapper),
+		TEST_CASE_NAMED("test_mode4_lacp_timeout_control",
+				test_mode4_lacp_timeout_control_wrapper),
 
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.7.4


  parent reply	other threads:[~2021-12-15 18:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 18:19 [PATCH 0/7] net/bonding: fixes and LACP short timeout Robert Sanford
2021-12-15 18:19 ` [PATCH 1/7] net/bonding: fix typos and whitespace Robert Sanford
2021-12-21 19:57   ` [PATCH v2 0/8] net/bonding: fixes and LACP short timeout Robert Sanford
2021-12-21 19:57     ` [PATCH v2 1/8] net/bonding: fix typos and whitespace Robert Sanford
2022-02-04 15:06       ` Ferruh Yigit
2021-12-21 19:57     ` [PATCH v2 2/8] net/bonding: fix bonded dev configuring slave dev Robert Sanford
2021-12-21 19:57     ` [PATCH v2 3/8] net/bonding: change mbuf pool and ring creation Robert Sanford
2021-12-21 19:57     ` [PATCH v2 4/8] net/bonding: support enabling LACP short timeout Robert Sanford
2022-02-04 14:46       ` Ferruh Yigit
2021-12-21 19:57     ` [PATCH v2 5/8] net/bonding: add bond_8023ad and bond_alb to doc Robert Sanford
2022-02-04 14:48       ` Ferruh Yigit
2021-12-21 19:57     ` [PATCH v2 6/8] remove self from timers maintainers Robert Sanford
2022-03-08 23:26       ` Thomas Monjalon
2021-12-21 19:57     ` [PATCH v2 7/8] net/ring: add promisc and all-MC stubs Robert Sanford
2022-02-04 14:36       ` Ferruh Yigit
2022-02-04 14:49         ` Bruce Richardson
2022-02-11 19:57           ` Ferruh Yigit
2021-12-21 19:57     ` [PATCH v2 8/8] net/bonding: add LACP short timeout tests Robert Sanford
2022-02-04 14:49       ` Ferruh Yigit
2021-12-22  3:27     ` [PATCH v2 0/8] net/bonding: fixes and LACP short timeout Min Hu (Connor)
2022-01-11 16:41     ` Kevin Traynor
2022-02-04 15:09     ` Ferruh Yigit
2021-12-15 18:19 ` [PATCH 2/7] net/bonding: fix bonded dev configuring slave dev Robert Sanford
2021-12-15 18:19 ` [PATCH 3/7] net/bonding: change mbuf pool and ring allocation Robert Sanford
2021-12-16  8:59   ` Min Hu (Connor)
2021-12-17 19:49     ` Sanford, Robert
2021-12-18  3:44       ` Min Hu (Connor)
2021-12-20 16:47         ` Sanford, Robert
2021-12-21  2:01           ` Min Hu (Connor)
2021-12-21 15:31             ` Sanford, Robert
2021-12-22  3:25               ` Min Hu (Connor)
2021-12-15 18:19 ` [PATCH 4/7] net/bonding: support enabling LACP short timeout Robert Sanford
2021-12-15 18:19 ` Robert Sanford [this message]
2021-12-15 18:20 ` [PATCH 6/7] net/bonding: add bond_8023ad and bond_alb to doc Robert Sanford
2021-12-15 18:20 ` [PATCH 7/7] Remove self from Timers maintainers Robert Sanford

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=1639592401-56845-6-git-send-email-rsanford@akamai.com \
    --to=rsanford2@gmail.com \
    --cc=chas3@att.com \
    --cc=dev@dpdk.org \
    --cc=humin29@huawei.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).