[v2,8/8] net/bonding: add LACP short timeout tests

Message ID 1640116650-3475-9-git-send-email-rsanford@akamai.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series net/bonding: fixes and LACP short timeout |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/github-robot: build fail github build: failed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Robert Sanford Dec. 21, 2021, 7:57 p.m. UTC
  - Add "set bonding lacp timeout_ctrl <port_id> on|off" to testpmd.
- Add "test_mode4_lacp_timeout_control" to dpdk-test.
- Remove call to rte_eth_dev_mac_addr_remove from add_slave,
  as it always fails and prints an error.

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

Comments

Ferruh Yigit Feb. 4, 2022, 2:49 p.m. UTC | #1
On 12/21/2021 7:57 PM, Robert Sanford wrote:
> - Add "set bonding lacp timeout_ctrl <port_id> on|off" to testpmd.
> - Add "test_mode4_lacp_timeout_control" to dpdk-test.
> - Remove call to rte_eth_dev_mac_addr_remove from add_slave,
>    as it always fails and prints an error.
> 
> Signed-off-by: Robert Sanford<rsanford@akamai.com>
> ---
>   app/test-pmd/cmdline.c             | 77 ++++++++++++++++++++++++++++++++++++++
>   app/test/test_link_bonding_mode4.c | 70 +++++++++++++++++++++++++++++++++-
>   2 files changed, 145 insertions(+), 2 deletions(-)

This patch depends on path 4/8, which cause an ABI error, so can't proceed
with this patch before ABI issue is resolved.
  

Patch

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..bc73183 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -235,8 +235,6 @@  add_slave(struct slave_conf *slave, uint8_t start)
 	rte_ether_addr_copy(&slave_mac_default, &addr);
 	addr.addr_bytes[RTE_ETHER_ADDR_LEN - 1] = slave->port_id;
 
-	rte_eth_dev_mac_addr_remove(slave->port_id, &addr);
-
 	TEST_ASSERT_SUCCESS(rte_eth_dev_mac_addr_add(slave->port_id, &addr, 0),
 		"Failed to set slave MAC address");
 
@@ -735,6 +733,66 @@  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");
+		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 +1707,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 +1729,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 */
 	}