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 1EEC3A034C; Tue, 21 Dec 2021 20:58:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CAA341174; Tue, 21 Dec 2021 20:58:14 +0100 (CET) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by mails.dpdk.org (Postfix) with ESMTP id AFD5B41153 for ; Tue, 21 Dec 2021 20:58:10 +0100 (CET) Received: by mail-qt1-f170.google.com with SMTP id j17so13969405qtx.2 for ; Tue, 21 Dec 2021 11:58:10 -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=phrK++lUCSHdbrwgyB89cA78usbk7bxOhNggHX6FynI=; b=djYAbTVRcFNMIcCPHAKFIuxtjXfGnC37a6Mg9F4q4rX6wFgzN/GE1PeSt/nF9pQirH NAlsOoH/DegwoLy2jRN1Y0ZnKHJ3nFsjEILA8uBva0dqh8hcHzsuasOgDI7nQhHkODgT dHCZiA6RuXhfvUCozhUVRgA+mbUBlHk+d1fX6ebwU0rsLBHARmEpVC9bsXXNrh8WwX18 VvEBNpQkLxl8ESeXlFO6aX6BIoLAuDywnkxbrED8MkY1mFuHwdiT/9iWeH41dinBPQHp 2dXg14M038Tp9NJeZtcbdNJqIGidvEkkNXBpq4tFOpVQKPUcKMYxtklpz6CMqfjIqOHH kMXg== 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=phrK++lUCSHdbrwgyB89cA78usbk7bxOhNggHX6FynI=; b=Vb+j+hSrOWu1U9ghQf4DctnaHEkA2JGIYddaQX6GEK2pcHrxoRCmG7boCQA/s+OMoU JDBXDQWMBnFiIQi1uuk59kUKN5S0l9rHsuLe5b42vyPsO409AdyA8YoNL8JUoRgmgKib 8fXtT68SSpjGcfDtfnrHtnbELWIFfF/Z93X8bLO6vHiTcJTh3FbVIUGt/OQyNPiuCx0j 0+ut1mbVWYGMV0lrLCmWcqNNdQV3oaClhaTCm8h2kAH7gwZlXz/jC39R5Zf5vK9kWfpT dtFX7g5M5nrVQJntI7I3VfaiPNkLTt/6iKIOJJemr621BCJWnnx05KEPgfOmcUR1zjOe nUcA== X-Gm-Message-State: AOAM533IXdhXweoXr/pM3hJfh1orjwe1FMHISuEDOOWtRYAkDQlrm7vQ 72XRZZcHFoOgm9nplh0TF46cjWerFFLmxA== X-Google-Smtp-Source: ABdhPJx60GvGvHgVEcaXME/S/yQZokkgyh53z63k38Lr+KgLeTsfmCu73IgskBedIuKpwLWPngMM8Q== X-Received: by 2002:ac8:59c7:: with SMTP id f7mr3659923qtf.605.1640116690022; Tue, 21 Dec 2021 11:58:10 -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 h3sm14684401qko.78.2021.12.21.11.58.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Dec 2021 11:58:09 -0800 (PST) From: Robert Sanford X-Google-Original-From: Robert Sanford To: dev@dpdk.org Cc: chas3@att.com, humin29@huawei.com, bruce.richardson@intel.com Subject: [PATCH v2 8/8] net/bonding: add LACP short timeout tests Date: Tue, 21 Dec 2021 14:57:30 -0500 Message-Id: <1640116650-3475-9-git-send-email-rsanford@akamai.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640116650-3475-1-git-send-email-rsanford@akamai.com> References: <1639592401-56845-2-git-send-email-rsanford@akamai.com> <1640116650-3475-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 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 --- app/test-pmd/cmdline.c | 77 ++++++++++++++++++++++++++++++++++++++ app/test/test_link_bonding_mode4.c | 70 +++++++++++++++++++++++++++++++++- 2 files changed, 145 insertions(+), 2 deletions(-) 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..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 */ } -- 2.7.4