Skip to content

Commit fca6f29

Browse files
fengchengwenshemminger
authored andcommitted
app/testpmd: support multi-cores process one TC
Currently, one TC can be processed by only one core, when there are a large number of small packets, this core becomes a bottleneck. This commit supports multi-cores process one TC, the command: set dcb fwd_tc_cores (tc_cores) Signed-off-by: Chengwen Feng <[email protected]> Acked-by: Huisong Li <[email protected]>
1 parent 4807724 commit fca6f29

File tree

5 files changed

+134
-17
lines changed

5 files changed

+134
-17
lines changed

app/test-pmd/cmdline.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6280,6 +6280,53 @@ static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = {
62806280
},
62816281
};
62826282

6283+
/* *** set dcb forward cores per TC *** */
6284+
struct cmd_set_dcb_fwd_tc_cores_result {
6285+
cmdline_fixed_string_t set;
6286+
cmdline_fixed_string_t dcb;
6287+
cmdline_fixed_string_t fwd_tc_cores;
6288+
uint8_t tc_cores;
6289+
};
6290+
6291+
static void cmd_set_dcb_fwd_tc_cores_parsed(void *parsed_result,
6292+
__rte_unused struct cmdline *cl,
6293+
__rte_unused void *data)
6294+
{
6295+
struct cmd_set_dcb_fwd_tc_cores_result *res = parsed_result;
6296+
if (res->tc_cores == 0) {
6297+
fprintf(stderr, "Cores per-TC should not be zero!\n");
6298+
return;
6299+
}
6300+
dcb_fwd_tc_cores = res->tc_cores;
6301+
printf("Set cores-per-TC: %u\n", dcb_fwd_tc_cores);
6302+
}
6303+
6304+
static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_set =
6305+
TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6306+
set, "set");
6307+
static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_dcb =
6308+
TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6309+
dcb, "dcb");
6310+
static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_fwdtccores =
6311+
TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6312+
fwd_tc_cores, "fwd_tc_cores");
6313+
static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_cores_tccores =
6314+
TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6315+
tc_cores, RTE_UINT8);
6316+
6317+
static cmdline_parse_inst_t cmd_set_dcb_fwd_tc_cores = {
6318+
.f = cmd_set_dcb_fwd_tc_cores_parsed,
6319+
.data = NULL,
6320+
.help_str = "config DCB forwarding cores per-TC, 1-means one core process all queues of a TC.",
6321+
.tokens = {
6322+
(void *)&cmd_set_dcb_fwd_tc_cores_set,
6323+
(void *)&cmd_set_dcb_fwd_tc_cores_dcb,
6324+
(void *)&cmd_set_dcb_fwd_tc_cores_fwdtccores,
6325+
(void *)&cmd_set_dcb_fwd_tc_cores_tccores,
6326+
NULL,
6327+
},
6328+
};
6329+
62836330
/* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
62846331
struct cmd_set_burst_tx_retry_result {
62856332
cmdline_fixed_string_t set;
@@ -14060,6 +14107,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
1406014107
&cmd_set_fwd_mode,
1406114108
&cmd_set_fwd_retry_mode,
1406214109
&cmd_set_dcb_fwd_tc,
14110+
&cmd_set_dcb_fwd_tc_cores,
1406314111
&cmd_set_burst_tx_retry,
1406414112
&cmd_set_promisc_mode_one,
1406514113
&cmd_set_promisc_mode_all,

app/test-pmd/config.c

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5112,6 +5112,36 @@ rss_fwd_config_setup(void)
51125112
}
51135113
}
51145114

5115+
static int
5116+
dcb_fwd_check_cores_per_tc(void)
5117+
{
5118+
struct rte_eth_dcb_info dcb_info = {0};
5119+
uint32_t port, tc, vmdq_idx;
5120+
5121+
if (dcb_fwd_tc_cores == 1)
5122+
return 0;
5123+
5124+
for (port = 0; port < nb_fwd_ports; port++) {
5125+
(void)rte_eth_dev_get_dcb_info(fwd_ports_ids[port], &dcb_info);
5126+
for (tc = 0; tc < dcb_info.nb_tcs; tc++) {
5127+
for (vmdq_idx = 0; vmdq_idx < RTE_ETH_MAX_VMDQ_POOL; vmdq_idx++) {
5128+
if (dcb_info.tc_queue.tc_rxq[vmdq_idx][tc].nb_queue == 0)
5129+
break;
5130+
/* make sure nb_rx_queue can be divisible. */
5131+
if (dcb_info.tc_queue.tc_rxq[vmdq_idx][tc].nb_queue %
5132+
dcb_fwd_tc_cores)
5133+
return -1;
5134+
/* make sure nb_tx_queue can be divisible. */
5135+
if (dcb_info.tc_queue.tc_txq[vmdq_idx][tc].nb_queue %
5136+
dcb_fwd_tc_cores)
5137+
return -1;
5138+
}
5139+
}
5140+
}
5141+
5142+
return 0;
5143+
}
5144+
51155145
static uint16_t
51165146
get_fwd_port_total_tc_num(void)
51175147
{
@@ -5164,24 +5194,28 @@ dcb_fwd_tc_update_dcb_info(struct rte_eth_dcb_info *org_dcb_info)
51645194
}
51655195

51665196
/**
5167-
* For the DCB forwarding test, each core is assigned on each traffic class.
5197+
* For the DCB forwarding test, each core is assigned on each traffic class
5198+
* defaultly:
5199+
* Each core is assigned a multi-stream, each stream being composed of
5200+
* a RX queue to poll on a RX port for input messages, associated with
5201+
* a TX queue of a TX port where to send forwarded packets. All RX and
5202+
* TX queues are mapping to the same traffic class.
5203+
* If VMDQ and DCB co-exist, each traffic class on different POOLs share
5204+
* the same core.
51685205
*
5169-
* Each core is assigned a multi-stream, each stream being composed of
5170-
* a RX queue to poll on a RX port for input messages, associated with
5171-
* a TX queue of a TX port where to send forwarded packets. All RX and
5172-
* TX queues are mapping to the same traffic class.
5173-
* If VMDQ and DCB co-exist, each traffic class on different POOLs share
5174-
* the same core
5206+
* If user set cores-per-TC to other value (e.g. 2), then there will multiple
5207+
* cores to process one TC.
51755208
*/
51765209
static void
51775210
dcb_fwd_config_setup(void)
51785211
{
51795212
struct rte_eth_dcb_info rxp_dcb_info, txp_dcb_info;
51805213
portid_t txp, rxp = 0;
51815214
queueid_t txq, rxq = 0;
5182-
lcoreid_t lc_id;
5215+
lcoreid_t lc_id, target_lcores;
51835216
uint16_t nb_rx_queue, nb_tx_queue;
51845217
uint16_t i, j, k, sm_id = 0;
5218+
uint16_t sub_core_idx = 0;
51855219
uint16_t total_tc_num;
51865220
struct rte_port *port;
51875221
uint8_t tc = 0;
@@ -5212,19 +5246,31 @@ dcb_fwd_config_setup(void)
52125246
}
52135247
}
52145248

5249+
ret = dcb_fwd_check_cores_per_tc();
5250+
if (ret != 0) {
5251+
fprintf(stderr, "Error: check forwarding cores-per-TC failed!\n");
5252+
cur_fwd_config.nb_fwd_lcores = 0;
5253+
return;
5254+
}
5255+
52155256
total_tc_num = get_fwd_port_total_tc_num();
52165257
if (total_tc_num == 0) {
52175258
fprintf(stderr, "Error: total forwarding TC num is zero!\n");
52185259
cur_fwd_config.nb_fwd_lcores = 0;
52195260
return;
52205261
}
52215262

5222-
cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores;
5263+
target_lcores = (lcoreid_t)total_tc_num * (lcoreid_t)dcb_fwd_tc_cores;
5264+
if (nb_fwd_lcores < target_lcores) {
5265+
fprintf(stderr, "Error: the number of forwarding cores is insufficient!\n");
5266+
cur_fwd_config.nb_fwd_lcores = 0;
5267+
return;
5268+
}
5269+
5270+
cur_fwd_config.nb_fwd_lcores = target_lcores;
52235271
cur_fwd_config.nb_fwd_ports = nb_fwd_ports;
52245272
cur_fwd_config.nb_fwd_streams =
52255273
(streamid_t) (nb_rxq * cur_fwd_config.nb_fwd_ports);
5226-
if (cur_fwd_config.nb_fwd_lcores > total_tc_num)
5227-
cur_fwd_config.nb_fwd_lcores = total_tc_num;
52285274

52295275
/* reinitialize forwarding streams */
52305276
init_fwd_streams();
@@ -5247,10 +5293,12 @@ dcb_fwd_config_setup(void)
52475293
break;
52485294
k = fwd_lcores[lc_id]->stream_nb +
52495295
fwd_lcores[lc_id]->stream_idx;
5250-
rxq = rxp_dcb_info.tc_queue.tc_rxq[i][tc].base;
5251-
txq = txp_dcb_info.tc_queue.tc_txq[i][tc].base;
5252-
nb_rx_queue = rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue;
5253-
nb_tx_queue = txp_dcb_info.tc_queue.tc_txq[i][tc].nb_queue;
5296+
nb_rx_queue = rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue /
5297+
dcb_fwd_tc_cores;
5298+
nb_tx_queue = txp_dcb_info.tc_queue.tc_txq[i][tc].nb_queue /
5299+
dcb_fwd_tc_cores;
5300+
rxq = rxp_dcb_info.tc_queue.tc_rxq[i][tc].base + nb_rx_queue * sub_core_idx;
5301+
txq = txp_dcb_info.tc_queue.tc_txq[i][tc].base + nb_tx_queue * sub_core_idx;
52545302
for (j = 0; j < nb_rx_queue; j++) {
52555303
struct fwd_stream *fs;
52565304

@@ -5262,11 +5310,14 @@ dcb_fwd_config_setup(void)
52625310
fs->peer_addr = fs->tx_port;
52635311
fs->retry_enabled = retry_enabled;
52645312
}
5265-
fwd_lcores[lc_id]->stream_nb +=
5266-
rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue;
5313+
sub_core_idx++;
5314+
fwd_lcores[lc_id]->stream_nb += nb_rx_queue;
52675315
}
52685316
sm_id = (streamid_t) (sm_id + fwd_lcores[lc_id]->stream_nb);
5317+
if (sub_core_idx < dcb_fwd_tc_cores)
5318+
continue;
52695319

5320+
sub_core_idx = 0;
52705321
tc++;
52715322
if (tc < rxp_dcb_info.nb_tcs)
52725323
continue;

app/test-pmd/testpmd.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ struct fwd_engine * fwd_engines[] = {
216216
* If bit-n in tc-mask is 1, then TC-n's forwarding is enabled, and vice versa.
217217
*/
218218
uint8_t dcb_fwd_tc_mask = DEFAULT_DCB_FWD_TC_MASK;
219+
/*
220+
* Poll cores per TC when DCB forwarding.
221+
* E.g. 1 indicates that one core process all queues of a TC.
222+
* 2 indicates that two cores process all queues of a TC. If there
223+
* is a TC with 8 queues, then [0, 3] belong to first core, and
224+
* [4, 7] belong to second core.
225+
* ...
226+
*/
227+
uint8_t dcb_fwd_tc_cores = 1;
219228

220229
struct rte_mempool *mempools[RTE_MAX_NUMA_NODES * MAX_SEGS_BUFFER_SPLIT];
221230
uint16_t mempool_flags;

app/test-pmd/testpmd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ extern cmdline_parse_inst_t cmd_set_flex_spec_pattern;
486486

487487
#define DEFAULT_DCB_FWD_TC_MASK 0xFF
488488
extern uint8_t dcb_fwd_tc_mask;
489+
extern uint8_t dcb_fwd_tc_cores;
489490

490491
extern uint16_t mempool_flags;
491492

doc/guides/testpmd_app_ug/testpmd_funcs.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,14 @@ forwarding is enabled, and vice versa::
18851885

18861886
testpmd> set dcb fwd_tc (tc_mask)
18871887

1888+
set dcb fwd_tc_cores
1889+
~~~~~~~~~~~~~~~~~~~~
1890+
1891+
Config DCB forwarding cores per-TC, 1-means one core process all queues of a TC,
1892+
2-means two cores process all queues of a TC, and so on::
1893+
1894+
testpmd> set dcb fwd_tc_cores (tc_cores)
1895+
18881896
Port Functions
18891897
--------------
18901898

0 commit comments

Comments
 (0)