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 566B446E24; Thu, 6 Nov 2025 13:50:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D895A4021F; Thu, 6 Nov 2025 13:50:14 +0100 (CET) Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) by mails.dpdk.org (Postfix) with ESMTP id B49BF4013F for ; Thu, 6 Nov 2025 13:50:11 +0100 (CET) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=YsNYqypT0P+quLDnzx47OtDCW0tpLJoGXh3DzpwzEyk=; b=NqVQyhuh2mKZhd6OInfdyIBLSWkIRDDZ9rouWufzgVv7pEnGiqI2d68BxXhQNtIxO8kg/abWS undXYpaNOWd2yJnSY6TJdZpue3RfmKqJAG1fnIZE+sntJjby0vVOuKO2NwIJeMcQztZ0nj1SG6v MKyR/ixyDtrC7lADg0TJ+xI= Received: from mail.maildlp.com (unknown [172.19.88.214]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4d2MSG0LRmzLlTm; Thu, 6 Nov 2025 20:48:30 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 98F2D1A016C; Thu, 6 Nov 2025 20:50:05 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 6 Nov 2025 20:50:05 +0800 From: Chengwen Feng To: , CC: , , , , Subject: [PATCH v3] app/testpmd: support specify TCs when DCB forward Date: Thu, 6 Nov 2025 20:49:59 +0800 Message-ID: <20251106124959.2592-1-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20251104040916.25864-1-fengchengwen@huawei.com> References: <20251104040916.25864-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemk500009.china.huawei.com (7.202.194.94) 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 This commit supports specify TCs when DCB forwarding, the command: set dcb fwd_tc (tc_mask) The background of this command: only some TCs are expected to generate traffic when the DCB function is tested based on txonly forwarding, we could use this command to specify TCs to be used. Signed-off-by: Chengwen Feng --- Depends-on: series-2682 ("two bugfix for testpmd DCB") --- v3: use new way to impl and fix comment from Stephen. v2: introduce pause/resume lcore's forwarding. --- app/test-pmd/cmdline.c | 57 +++++++++++++++++++++ app/test-pmd/config.c | 50 +++++++++++++++++- app/test-pmd/testpmd.c | 6 +++ app/test-pmd/testpmd.h | 3 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ 5 files changed, 121 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 22afbdbad3..0400c8356e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -511,6 +511,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set fwd (%s)\n" " Set packet forwarding mode.\n\n" + "set dcb fwd_tc (tc_mask)\n" + " Set dcb forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled\n\n" + "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" " Add a MAC address on port_id.\n\n" @@ -6224,6 +6227,59 @@ static void cmd_set_fwd_retry_mode_init(void) token_struct->string_data.str = token; } +/* *** set dcb forward TCs *** */ +struct cmd_set_dcb_fwd_tc_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t dcb; + cmdline_fixed_string_t fwd_tc; + uint8_t tc_mask; +}; + +static void cmd_set_dcb_fwd_tc_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_dcb_fwd_tc_result *res = parsed_result; + int i; + if (res->tc_mask == 0) { + fprintf(stderr, "TC mask should not be zero!\n"); + return; + } + printf("Enabled DCB forwarding TC list:"); + dcb_fwd_tc_mask = res->tc_mask; + for (i = 0; i < RTE_ETH_8_TCS; i++) { + if (dcb_fwd_tc_mask & (1u << i)) + printf(" %d", i); + } + printf("\n"); +} + +static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result, + set, "set"); +static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_dcb = + TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result, + dcb, "dcb"); +static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_fwdtc = + TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result, + fwd_tc, "fwd_tc"); +static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_tcmask = + TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_result, + tc_mask, RTE_UINT8); + +static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = { + .f = cmd_set_dcb_fwd_tc_parsed, + .data = NULL, + .help_str = "config DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled, and vice versa.", + .tokens = { + (void *)&cmd_set_dcb_fwd_tc_set, + (void *)&cmd_set_dcb_fwd_tc_dcb, + (void *)&cmd_set_dcb_fwd_tc_fwdtc, + (void *)&cmd_set_dcb_fwd_tc_tcmask, + NULL, + }, +}; + /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ struct cmd_set_burst_tx_retry_result { cmdline_fixed_string_t set; @@ -14003,6 +14059,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_set_fwd_mask, &cmd_set_fwd_mode, &cmd_set_fwd_retry_mode, + &cmd_set_dcb_fwd_tc, &cmd_set_burst_tx_retry, &cmd_set_promisc_mode_one, &cmd_set_promisc_mode_all, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 8557371488..ca40a03b40 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -5121,12 +5121,48 @@ get_fwd_port_total_tc_num(void) for (i = 0; i < nb_fwd_ports; i++) { (void)rte_eth_dev_get_dcb_info(fwd_ports_ids[i], &dcb_info); - total_tc_num += dcb_info.nb_tcs; + total_tc_num += rte_popcount32(dcb_fwd_tc_mask & ((1u << dcb_info.nb_tcs) - 1)); } return total_tc_num; } +static void +dcb_forward_tc_update_dcb_info(struct rte_eth_dcb_info *org_dcb_info) +{ + struct rte_eth_dcb_info dcb_info = {0}; + uint32_t i, vmdq_idx; + uint32_t tc = 0; + + if (dcb_fwd_tc_mask == DEFAULT_DCB_FWD_TC_MASK) + return; + + /* + * Use compress scheme to update dcb-info. + * E.g. If org_dcb_info->nb_tcs is 4 and dcb_fwd_tc_mask is 0x8, it + * means only enable TC3, then the new dcb-info's nb_tcs is set to + * 1, and also move corresponding tc_rxq and tc_txq info to new + * index. + */ + for (i = 0; i < org_dcb_info->nb_tcs; i++) { + if (!(dcb_fwd_tc_mask & (1u << i))) + continue; + for (vmdq_idx = 0; vmdq_idx < RTE_ETH_MAX_VMDQ_POOL; vmdq_idx++) { + dcb_info.tc_queue.tc_rxq[vmdq_idx][tc].base = + org_dcb_info->tc_queue.tc_rxq[vmdq_idx][i].base; + dcb_info.tc_queue.tc_rxq[vmdq_idx][tc].nb_queue = + org_dcb_info->tc_queue.tc_rxq[vmdq_idx][i].nb_queue; + dcb_info.tc_queue.tc_txq[vmdq_idx][tc].base = + org_dcb_info->tc_queue.tc_txq[vmdq_idx][i].base; + dcb_info.tc_queue.tc_txq[vmdq_idx][tc].nb_queue = + org_dcb_info->tc_queue.tc_txq[vmdq_idx][i].nb_queue; + } + tc++; + } + dcb_info.nb_tcs = tc; + memcpy(org_dcb_info, &dcb_info, sizeof(struct rte_eth_dcb_info)); +} + /** * For the DCB forwarding test, each core is assigned on each traffic class. * @@ -5176,11 +5212,17 @@ dcb_fwd_config_setup(void) } } + total_tc_num = get_fwd_port_total_tc_num(); + if (total_tc_num == 0) { + fprintf(stderr, "Error: total forwarding TC num is zero!\n"); + cur_fwd_config.nb_fwd_lcores = 0; + return; + } + cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores; cur_fwd_config.nb_fwd_ports = nb_fwd_ports; cur_fwd_config.nb_fwd_streams = (streamid_t) (nb_rxq * cur_fwd_config.nb_fwd_ports); - total_tc_num = get_fwd_port_total_tc_num(); if (cur_fwd_config.nb_fwd_lcores > total_tc_num) cur_fwd_config.nb_fwd_lcores = total_tc_num; @@ -5190,7 +5232,9 @@ dcb_fwd_config_setup(void) txp = fwd_topology_tx_port_get(rxp); /* get the dcb info on the first RX and TX ports */ (void)rte_eth_dev_get_dcb_info(fwd_ports_ids[rxp], &rxp_dcb_info); + dcb_forward_tc_update_dcb_info(&rxp_dcb_info); (void)rte_eth_dev_get_dcb_info(fwd_ports_ids[txp], &txp_dcb_info); + dcb_forward_tc_update_dcb_info(&txp_dcb_info); for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) { fwd_lcores[lc_id]->stream_nb = 0; @@ -5238,7 +5282,9 @@ dcb_fwd_config_setup(void) txp = fwd_topology_tx_port_get(rxp); /* get the dcb information on next RX and TX ports */ rte_eth_dev_get_dcb_info(fwd_ports_ids[rxp], &rxp_dcb_info); + dcb_forward_tc_update_dcb_info(&rxp_dcb_info); rte_eth_dev_get_dcb_info(fwd_ports_ids[txp], &txp_dcb_info); + dcb_forward_tc_update_dcb_info(&txp_dcb_info); } } diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 2360da3a48..9d0ce5660c 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -211,6 +211,12 @@ struct fwd_engine * fwd_engines[] = { NULL, }; +/* + * Bitmask for control DCB forwarding for TCs. + * If bit-n in tc-mask is 1, then TC-n's forwarding is enabled, and vice versa. + */ +uint8_t dcb_fwd_tc_mask = DEFAULT_DCB_FWD_TC_MASK; + struct rte_mempool *mempools[RTE_MAX_NUMA_NODES * MAX_SEGS_BUFFER_SPLIT]; uint16_t mempool_flags; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index fa46865c67..1ada0de450 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -484,6 +484,9 @@ extern cmdline_parse_inst_t cmd_show_set_raw_all; extern cmdline_parse_inst_t cmd_set_flex_is_pattern; extern cmdline_parse_inst_t cmd_set_flex_spec_pattern; +#define DEFAULT_DCB_FWD_TC_MASK 0xFF +extern uint8_t dcb_fwd_tc_mask; + extern uint16_t mempool_flags; /** diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index e423abd40e..d263734a11 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1877,6 +1877,13 @@ Set a controllable LED associated with a certain port on or off:: testpmd> set port (port_id) led (on|off) +set dcb fwd_tc +~~~~~~~~~~~~~~ + +Config DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled, and vice versa:: + + testpmd> set dcb fwd_tc (tc_mask) + Port Functions -------------- -- 2.17.1