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 00182A0543; Wed, 14 Dec 2022 07:20:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A855842B71; Wed, 14 Dec 2022 07:20:04 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 0C9454003F for ; Wed, 14 Dec 2022 07:20:01 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NX4v709dXzRpvN; Wed, 14 Dec 2022 14:18:59 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 14 Dec 2022 14:19:59 +0800 From: Chengwen Feng To: , CC: , , Subject: [PATCH v2 3/3] net/bonding: use dump API to impl show bonding cmd Date: Wed, 14 Dec 2022 06:13:25 +0000 Message-ID: <20221214061325.20272-4-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221214061325.20272-1-fengchengwen@huawei.com> References: <20221205081051.25905-1-fengchengwen@huawei.com> <20221214061325.20272-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected 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 The bonding PMD's eth_dev_priv_dump ops contain the following testpmd commands output: "show bonding config [port]" and "show bonding lacp info [port]". To reduce duplicate code maintenance, this patch uses rte_eth_dev_priv_dump to implement the command "show bonding config [port]", and remove the command "show bonding lacp info [port]". Signed-off-by: Chengwen Feng --- .../link_bonding_poll_mode_drv_lib.rst | 13 +- drivers/net/bonding/bonding_testpmd.c | 281 +----------------- 2 files changed, 6 insertions(+), 288 deletions(-) diff --git a/doc/guides/prog_guide/link_bonding_poll_mode_drv_lib.rst b/doc/guides/prog_guide/link_bonding_poll_mode_drv_lib.rst index 9510368103..21efa4d5bc 100644 --- a/doc/guides/prog_guide/link_bonding_poll_mode_drv_lib.rst +++ b/doc/guides/prog_guide/link_bonding_poll_mode_drv_lib.rst @@ -621,7 +621,8 @@ Enable one of the specific aggregators mode when in mode 4 (link-aggregation-802 show bonding config ~~~~~~~~~~~~~~~~~~~ -Show the current configuration of a Link Bonding device:: +Show the current configuration of a Link Bonding device, it also show link-aggregation-802.3ad +information if the Link mode is mode 4:: testpmd> show bonding config (port id) @@ -630,15 +631,9 @@ to show the configuration a Link Bonding device (port 9) with 3 slave devices (1 in balance mode with a transmission policy of layer 2+3:: testpmd> show bonding config 9 - Bonding mode: 2 + - Dev basic: + Bonding mode: BALANCE(2) Balance Xmit Policy: BALANCE_XMIT_POLICY_LAYER23 Slaves (3): [1 3 4] Active Slaves (3): [1 3 4] Primary: [3] - -show bonding lacp info -~~~~~~~~~~~~~~~~~~~~~~ - -Show information about the Link Bonding device in mode 4 (link-aggregation-802.3ad):: - - testpmd> show bonding lacp info (port_id) diff --git a/drivers/net/bonding/bonding_testpmd.c b/drivers/net/bonding/bonding_testpmd.c index 9529e16fb6..b3c12cada0 100644 --- a/drivers/net/bonding/bonding_testpmd.c +++ b/drivers/net/bonding/bonding_testpmd.c @@ -222,185 +222,6 @@ static cmdline_parse_inst_t cmd_set_balance_xmit_policy = { } }; -/* *** SHOW IEEE802.3 BONDING INFORMATION *** */ -struct cmd_show_bonding_lacp_info_result { - cmdline_fixed_string_t show; - cmdline_fixed_string_t bonding; - cmdline_fixed_string_t lacp; - cmdline_fixed_string_t info; - portid_t port_id; -}; - -static void port_param_show(struct port_params *params) -{ - char buf[RTE_ETHER_ADDR_FMT_SIZE]; - - printf("\t\tsystem priority: %u\n", params->system_priority); - rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system); - printf("\t\tsystem mac address: %s\n", buf); - printf("\t\tport key: %u\n", params->key); - printf("\t\tport priority: %u\n", params->port_priority); - printf("\t\tport number: %u\n", params->port_number); -} - -static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info) -{ - char a_state[256] = { 0 }; - char p_state[256] = { 0 }; - int a_len = 0; - int p_len = 0; - uint32_t i; - - static const char * const state[] = { - "ACTIVE", - "TIMEOUT", - "AGGREGATION", - "SYNCHRONIZATION", - "COLLECTING", - "DISTRIBUTING", - "DEFAULTED", - "EXPIRED" - }; - static const char * const selection[] = { - "UNSELECTED", - "STANDBY", - "SELECTED" - }; - - for (i = 0; i < RTE_DIM(state); i++) { - if ((info->actor_state >> i) & 1) - a_len += snprintf(&a_state[a_len], - RTE_DIM(a_state) - a_len, "%s ", - state[i]); - - if ((info->partner_state >> i) & 1) - p_len += snprintf(&p_state[p_len], - RTE_DIM(p_state) - p_len, "%s ", - state[i]); - } - printf("\tAggregator port id: %u\n", info->agg_port_id); - printf("\tselection: %s\n", selection[info->selected]); - printf("\tActor detail info:\n"); - port_param_show(&info->actor); - printf("\t\tport state: %s\n", a_state); - printf("\tPartner detail info:\n"); - port_param_show(&info->partner); - printf("\t\tport state: %s\n", p_state); - printf("\n"); -} - -static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf) -{ - printf("\tfast period: %u ms\n", conf->fast_periodic_ms); - printf("\tslow period: %u ms\n", conf->slow_periodic_ms); - printf("\tshort timeout: %u ms\n", conf->short_timeout_ms); - printf("\tlong timeout: %u ms\n", conf->long_timeout_ms); - printf("\taggregate wait timeout: %u ms\n", - conf->aggregate_wait_timeout_ms); - printf("\ttx period: %u ms\n", conf->tx_period_ms); - printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms); - printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms); - switch (conf->agg_selection) { - case AGG_BANDWIDTH: - printf("\taggregation mode: bandwidth\n"); - break; - case AGG_STABLE: - printf("\taggregation mode: stable\n"); - break; - case AGG_COUNT: - printf("\taggregation mode: count\n"); - break; - default: - printf("\taggregation mode: invalid\n"); - break; - } - - printf("\n"); -} - -static void cmd_show_bonding_lacp_info_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, __rte_unused void *data) -{ - struct cmd_show_bonding_lacp_info_result *res = parsed_result; - struct rte_eth_bond_8023ad_slave_info slave_info; - struct rte_eth_bond_8023ad_conf port_conf; - portid_t slaves[RTE_MAX_ETHPORTS]; - portid_t port_id = res->port_id; - int num_active_slaves; - int bonding_mode; - int i; - int ret; - - bonding_mode = rte_eth_bond_mode_get(port_id); - if (bonding_mode != BONDING_MODE_8023AD) { - fprintf(stderr, "\tBonding mode is not mode 4\n"); - return; - } - - num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, - RTE_MAX_ETHPORTS); - if (num_active_slaves < 0) { - fprintf(stderr, "\tFailed to get active slave list for port = %u\n", - port_id); - return; - } - if (num_active_slaves == 0) - fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n", - port_id); - - printf("\tIEEE802.3 port: %u\n", port_id); - ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf); - if (ret) { - fprintf(stderr, "\tGet bonded device %u info failed\n", - port_id); - return; - } - lacp_conf_show(&port_conf); - - for (i = 0; i < num_active_slaves; i++) { - ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i], - &slave_info); - if (ret) { - fprintf(stderr, "\tGet slave device %u info failed\n", - slaves[i]); - return; - } - printf("\tSlave Port: %u\n", slaves[i]); - lacp_slave_info_show(&slave_info); - } -} - -static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show = - TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, - show, "show"); -static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding = - TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, - bonding, "bonding"); -static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp = - TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, - bonding, "lacp"); -static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info = - TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, - info, "info"); -static cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id = - TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result, - port_id, RTE_UINT16); - -static cmdline_parse_inst_t cmd_show_bonding_lacp_info = { - .f = cmd_show_bonding_lacp_info_parsed, - .help_str = "show bonding lacp info : " - "Show bonding IEEE802.3 information for port_id", - .data = NULL, - .tokens = { - (void *)&cmd_show_bonding_lacp_info_show, - (void *)&cmd_show_bonding_lacp_info_bonding, - (void *)&cmd_show_bonding_lacp_info_lacp, - (void *)&cmd_show_bonding_lacp_info_info, - (void *)&cmd_show_bonding_lacp_info_port_id, - NULL - } -}; - /* *** SHOW NIC BONDING CONFIGURATION *** */ struct cmd_show_bonding_config_result { cmdline_fixed_string_t show; @@ -413,110 +234,17 @@ static void cmd_show_bonding_config_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data) { struct cmd_show_bonding_config_result *res = parsed_result; - int bonding_mode, agg_mode; - portid_t slaves[RTE_MAX_ETHPORTS]; - int num_slaves, num_active_slaves; - int primary_id; - int i; portid_t port_id = res->port_id; + int bonding_mode; - /* Display the bonding mode.*/ bonding_mode = rte_eth_bond_mode_get(port_id); if (bonding_mode < 0) { fprintf(stderr, "\tFailed to get bonding mode for port = %d\n", port_id); return; } - printf("\tBonding mode: %d\n", bonding_mode); - - if (bonding_mode == BONDING_MODE_BALANCE || - bonding_mode == BONDING_MODE_8023AD) { - int balance_xmit_policy; - - balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); - if (balance_xmit_policy < 0) { - fprintf(stderr, - "\tFailed to get balance xmit policy for port = %d\n", - port_id); - return; - } - printf("\tBalance Xmit Policy: "); - - switch (balance_xmit_policy) { - case BALANCE_XMIT_POLICY_LAYER2: - printf("BALANCE_XMIT_POLICY_LAYER2"); - break; - case BALANCE_XMIT_POLICY_LAYER23: - printf("BALANCE_XMIT_POLICY_LAYER23"); - break; - case BALANCE_XMIT_POLICY_LAYER34: - printf("BALANCE_XMIT_POLICY_LAYER34"); - break; - } - printf("\n"); - } - - if (bonding_mode == BONDING_MODE_8023AD) { - agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); - printf("\tIEEE802.3AD Aggregator Mode: "); - switch (agg_mode) { - case AGG_BANDWIDTH: - printf("bandwidth"); - break; - case AGG_STABLE: - printf("stable"); - break; - case AGG_COUNT: - printf("count"); - break; - } - printf("\n"); - } - - num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); - - if (num_slaves < 0) { - fprintf(stderr, "\tFailed to get slave list for port = %d\n", - port_id); - return; - } - if (num_slaves > 0) { - printf("\tSlaves (%d): [", num_slaves); - for (i = 0; i < num_slaves - 1; i++) - printf("%d ", slaves[i]); - printf("%d]\n", slaves[num_slaves - 1]); - } else { - printf("\tSlaves: []\n"); - } - - num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, - RTE_MAX_ETHPORTS); - - if (num_active_slaves < 0) { - fprintf(stderr, - "\tFailed to get active slave list for port = %d\n", - port_id); - return; - } - if (num_active_slaves > 0) { - printf("\tActive Slaves (%d): [", num_active_slaves); - for (i = 0; i < num_active_slaves - 1; i++) - printf("%d ", slaves[i]); - - printf("%d]\n", slaves[num_active_slaves - 1]); - - } else { - printf("\tActive Slaves: []\n"); - } - - primary_id = rte_eth_bond_primary_get(port_id); - if (primary_id < 0) { - fprintf(stderr, "\tFailed to get primary slave for port = %d\n", - port_id); - return; - } - printf("\tPrimary: [%d]\n", primary_id); + (void)rte_eth_dev_priv_dump(port_id, stdout); } static cmdline_parse_token_string_t cmd_showbonding_config_show = @@ -976,11 +704,6 @@ static struct testpmd_driver_commands bonding_cmds = { "show bonding config (port_id)\n" " Show the bonding config for port_id.\n", }, - { - &cmd_show_bonding_lacp_info, - "show bonding lacp info (port_id)\n" - " Show the bonding lacp information for port_id.\n", - }, { &cmd_set_bonding_primary, "set bonding primary (slave_id) (port_id)\n" -- 2.17.1