From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B49FAA00C3; Wed, 15 Dec 2021 19:20:58 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0BA041152; Wed, 15 Dec 2021 19:20:32 +0100 (CET) Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by mails.dpdk.org (Postfix) with ESMTP id F27A04115B for ; Wed, 15 Dec 2021 19:20:29 +0100 (CET) Received: by mail-qk1-f169.google.com with SMTP id t6so20957386qkg.1 for ; Wed, 15 Dec 2021 10:20:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cnrpVZf76cZd7Cs8pDy/5yvGZSB37s7U+gTt35HpBUQ=; b=fjR4chztBs/szyS91QvNB+7IUbV+WyerCZ9SFLz4UQBiTHJ52y7LCUYJ9ZkrtuIHbE tvN3kWZ+6EE/aYdko+oOooTY/6hpshjAUpC/c6KgTN1niAmlsxSFdj7D6eLxyZUzuFnF bz3qyaTfNMqx3MzKZ67NX0poskgHPchg26oALje5++v0ld7u/+WHywBh6K+lPMXIuV9g qAPit2hddc8vbeRYRrEveB29GK4TdRkitEvCvc8iVylHdS71HuK08axVwmFGx+cokhlE UpQhEdgO9nJ1JGC5cBozVOksY5FOnBIsRLq/5htYm8632JI1u38spNIzYZgFHKWKaldQ 0VaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cnrpVZf76cZd7Cs8pDy/5yvGZSB37s7U+gTt35HpBUQ=; b=5+Vuv1pBH/QgKdnZOjBikhxpOKsS2hMuq2fS5u0yfPpLorCpG2k0kyBs4Er1M1Vrrl +qGXS5enLKIsQ5O24mnXN7GTlawhgpZtCT1x0bbDNuSyy5moMl1XVdUF/Rpemq71/6BP 4HZEeJR4czyO/DihPRREp5uSpn+xzboDNnRICuraNlpaj3JU4NHZx6P5ccE/XLpoG83B 7bT2pLpNXJoFF5tvnHHySfl8KFHT0OaYkYShUHYr/31CXSoB0MBQIz0AKuz6QeJ4VR5l KTYRfO3EA0wsKnQE24Zk939lK/PKRpVALxAv73yvLg/xFpH6Uv0VLpJMS7NQIC8H0fVk LYYA== X-Gm-Message-State: AOAM530VOcY+UmITBJmOLsk4I0tSmhJ16Dlp59bfJfAHtvKN54G80wPF NPdsuG+F1gJ6W83h6i6q8jnRXx6V4tc= X-Google-Smtp-Source: ABdhPJzW1U0AWiarxhRM7RmDclQM2OMtxIt3twGsanFz8MMRNMiy3fvU2sLYYUZeqK20K5/sVui1VQ== X-Received: by 2002:a05:620a:410e:: with SMTP id j14mr9481644qko.47.1639592428880; Wed, 15 Dec 2021 10:20:28 -0800 (PST) Received: from ubuntu.localdomain (99-153-167-175.lightspeed.ftldfl.sbcglobal.net. [99.153.167.175]) by smtp.gmail.com with ESMTPSA id 8sm2075978qtz.28.2021.12.15.10.20.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Dec 2021 10:20:28 -0800 (PST) From: Robert Sanford X-Google-Original-From: Robert Sanford 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 Message-Id: <1639592401-56845-6-git-send-email-rsanford@akamai.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1639592401-56845-1-git-send-email-rsanford@akamai.com> References: <1639592401-56845-1-git-send-email-rsanford@akamai.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org - Add "set bonding lacp timeout_ctrl on|off" to testpmd. - Add "test_mode4_lacp_timeout_control" to app/test. Signed-off-by: Robert Sanford --- 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 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