Skip to content

Commit 4807724

Browse files
fengchengwenshemminger
authored andcommitted
app/testpmd: support specify TCs when DCB forward
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 <[email protected]> Acked-by: Huisong Li <[email protected]>
1 parent 6804b63 commit 4807724

File tree

5 files changed

+122
-2
lines changed

5 files changed

+122
-2
lines changed

app/test-pmd/cmdline.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ static void cmd_help_long_parsed(void *parsed_result,
511511
"set fwd (%s)\n"
512512
" Set packet forwarding mode.\n\n"
513513

514+
"set dcb fwd_tc (tc_mask)\n"
515+
" Set dcb forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled\n\n"
516+
514517
"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
515518
" Add a MAC address on port_id.\n\n"
516519

@@ -6224,6 +6227,59 @@ static void cmd_set_fwd_retry_mode_init(void)
62246227
token_struct->string_data.str = token;
62256228
}
62266229

6230+
/* *** set dcb forward TCs *** */
6231+
struct cmd_set_dcb_fwd_tc_result {
6232+
cmdline_fixed_string_t set;
6233+
cmdline_fixed_string_t dcb;
6234+
cmdline_fixed_string_t fwd_tc;
6235+
uint8_t tc_mask;
6236+
};
6237+
6238+
static void cmd_set_dcb_fwd_tc_parsed(void *parsed_result,
6239+
__rte_unused struct cmdline *cl,
6240+
__rte_unused void *data)
6241+
{
6242+
struct cmd_set_dcb_fwd_tc_result *res = parsed_result;
6243+
int i;
6244+
if (res->tc_mask == 0) {
6245+
fprintf(stderr, "TC mask should not be zero!\n");
6246+
return;
6247+
}
6248+
printf("Enabled DCB forwarding TC list:");
6249+
dcb_fwd_tc_mask = res->tc_mask;
6250+
for (i = 0; i < RTE_ETH_8_TCS; i++) {
6251+
if (dcb_fwd_tc_mask & (1u << i))
6252+
printf(" %d", i);
6253+
}
6254+
printf("\n");
6255+
}
6256+
6257+
static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_set =
6258+
TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6259+
set, "set");
6260+
static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_dcb =
6261+
TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6262+
dcb, "dcb");
6263+
static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_fwdtc =
6264+
TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6265+
fwd_tc, "fwd_tc");
6266+
static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_tcmask =
6267+
TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6268+
tc_mask, RTE_UINT8);
6269+
6270+
static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = {
6271+
.f = cmd_set_dcb_fwd_tc_parsed,
6272+
.data = NULL,
6273+
.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.",
6274+
.tokens = {
6275+
(void *)&cmd_set_dcb_fwd_tc_set,
6276+
(void *)&cmd_set_dcb_fwd_tc_dcb,
6277+
(void *)&cmd_set_dcb_fwd_tc_fwdtc,
6278+
(void *)&cmd_set_dcb_fwd_tc_tcmask,
6279+
NULL,
6280+
},
6281+
};
6282+
62276283
/* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
62286284
struct cmd_set_burst_tx_retry_result {
62296285
cmdline_fixed_string_t set;
@@ -14003,6 +14059,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
1400314059
&cmd_set_fwd_mask,
1400414060
&cmd_set_fwd_mode,
1400514061
&cmd_set_fwd_retry_mode,
14062+
&cmd_set_dcb_fwd_tc,
1400614063
&cmd_set_burst_tx_retry,
1400714064
&cmd_set_promisc_mode_one,
1400814065
&cmd_set_promisc_mode_all,

app/test-pmd/config.c

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5121,12 +5121,48 @@ get_fwd_port_total_tc_num(void)
51215121

51225122
for (i = 0; i < nb_fwd_ports; i++) {
51235123
(void)rte_eth_dev_get_dcb_info(fwd_ports_ids[i], &dcb_info);
5124-
total_tc_num += dcb_info.nb_tcs;
5124+
total_tc_num += rte_popcount32(dcb_fwd_tc_mask & ((1u << dcb_info.nb_tcs) - 1));
51255125
}
51265126

51275127
return total_tc_num;
51285128
}
51295129

5130+
static void
5131+
dcb_fwd_tc_update_dcb_info(struct rte_eth_dcb_info *org_dcb_info)
5132+
{
5133+
struct rte_eth_dcb_info dcb_info = {0};
5134+
uint32_t i, vmdq_idx;
5135+
uint32_t tc = 0;
5136+
5137+
if (dcb_fwd_tc_mask == DEFAULT_DCB_FWD_TC_MASK)
5138+
return;
5139+
5140+
/*
5141+
* Use compress scheme to update dcb-info.
5142+
* E.g. If org_dcb_info->nb_tcs is 4 and dcb_fwd_tc_mask is 0x8, it
5143+
* means only enable TC3, then the new dcb-info's nb_tcs is set to
5144+
* 1, and also move corresponding tc_rxq and tc_txq info to new
5145+
* index.
5146+
*/
5147+
for (i = 0; i < org_dcb_info->nb_tcs; i++) {
5148+
if (!(dcb_fwd_tc_mask & (1u << i)))
5149+
continue;
5150+
for (vmdq_idx = 0; vmdq_idx < RTE_ETH_MAX_VMDQ_POOL; vmdq_idx++) {
5151+
dcb_info.tc_queue.tc_rxq[vmdq_idx][tc].base =
5152+
org_dcb_info->tc_queue.tc_rxq[vmdq_idx][i].base;
5153+
dcb_info.tc_queue.tc_rxq[vmdq_idx][tc].nb_queue =
5154+
org_dcb_info->tc_queue.tc_rxq[vmdq_idx][i].nb_queue;
5155+
dcb_info.tc_queue.tc_txq[vmdq_idx][tc].base =
5156+
org_dcb_info->tc_queue.tc_txq[vmdq_idx][i].base;
5157+
dcb_info.tc_queue.tc_txq[vmdq_idx][tc].nb_queue =
5158+
org_dcb_info->tc_queue.tc_txq[vmdq_idx][i].nb_queue;
5159+
}
5160+
tc++;
5161+
}
5162+
dcb_info.nb_tcs = tc;
5163+
*org_dcb_info = dcb_info;
5164+
}
5165+
51305166
/**
51315167
* For the DCB forwarding test, each core is assigned on each traffic class.
51325168
*
@@ -5176,11 +5212,17 @@ dcb_fwd_config_setup(void)
51765212
}
51775213
}
51785214

5215+
total_tc_num = get_fwd_port_total_tc_num();
5216+
if (total_tc_num == 0) {
5217+
fprintf(stderr, "Error: total forwarding TC num is zero!\n");
5218+
cur_fwd_config.nb_fwd_lcores = 0;
5219+
return;
5220+
}
5221+
51795222
cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores;
51805223
cur_fwd_config.nb_fwd_ports = nb_fwd_ports;
51815224
cur_fwd_config.nb_fwd_streams =
51825225
(streamid_t) (nb_rxq * cur_fwd_config.nb_fwd_ports);
5183-
total_tc_num = get_fwd_port_total_tc_num();
51845226
if (cur_fwd_config.nb_fwd_lcores > total_tc_num)
51855227
cur_fwd_config.nb_fwd_lcores = total_tc_num;
51865228

@@ -5190,7 +5232,9 @@ dcb_fwd_config_setup(void)
51905232
txp = fwd_topology_tx_port_get(rxp);
51915233
/* get the dcb info on the first RX and TX ports */
51925234
(void)rte_eth_dev_get_dcb_info(fwd_ports_ids[rxp], &rxp_dcb_info);
5235+
dcb_fwd_tc_update_dcb_info(&rxp_dcb_info);
51935236
(void)rte_eth_dev_get_dcb_info(fwd_ports_ids[txp], &txp_dcb_info);
5237+
dcb_fwd_tc_update_dcb_info(&txp_dcb_info);
51945238

51955239
for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) {
51965240
fwd_lcores[lc_id]->stream_nb = 0;
@@ -5238,7 +5282,9 @@ dcb_fwd_config_setup(void)
52385282
txp = fwd_topology_tx_port_get(rxp);
52395283
/* get the dcb information on next RX and TX ports */
52405284
rte_eth_dev_get_dcb_info(fwd_ports_ids[rxp], &rxp_dcb_info);
5285+
dcb_fwd_tc_update_dcb_info(&rxp_dcb_info);
52415286
rte_eth_dev_get_dcb_info(fwd_ports_ids[txp], &txp_dcb_info);
5287+
dcb_fwd_tc_update_dcb_info(&txp_dcb_info);
52425288
}
52435289
}
52445290

app/test-pmd/testpmd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ struct fwd_engine * fwd_engines[] = {
211211
NULL,
212212
};
213213

214+
/*
215+
* Bitmask for control DCB forwarding for TCs.
216+
* If bit-n in tc-mask is 1, then TC-n's forwarding is enabled, and vice versa.
217+
*/
218+
uint8_t dcb_fwd_tc_mask = DEFAULT_DCB_FWD_TC_MASK;
219+
214220
struct rte_mempool *mempools[RTE_MAX_NUMA_NODES * MAX_SEGS_BUFFER_SPLIT];
215221
uint16_t mempool_flags;
216222

app/test-pmd/testpmd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ extern cmdline_parse_inst_t cmd_show_set_raw_all;
484484
extern cmdline_parse_inst_t cmd_set_flex_is_pattern;
485485
extern cmdline_parse_inst_t cmd_set_flex_spec_pattern;
486486

487+
#define DEFAULT_DCB_FWD_TC_MASK 0xFF
488+
extern uint8_t dcb_fwd_tc_mask;
489+
487490
extern uint16_t mempool_flags;
488491

489492
/**

doc/guides/testpmd_app_ug/testpmd_funcs.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,14 @@ Set a controllable LED associated with a certain port on or off::
18771877

18781878
testpmd> set port (port_id) led (on|off)
18791879

1880+
set dcb fwd_tc
1881+
~~~~~~~~~~~~~~
1882+
1883+
Config DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's
1884+
forwarding is enabled, and vice versa::
1885+
1886+
testpmd> set dcb fwd_tc (tc_mask)
1887+
18801888
Port Functions
18811889
--------------
18821890

0 commit comments

Comments
 (0)