Skip to content

Commit 5c3091f

Browse files
fengchengwenshemminger
authored andcommitted
app/testpmd: support disable DCB command
After the "port config 0 dcb ..." command is invoked, no command is available to disable DCB. This commit introduces disable DCB when num_tcs is 1, so user could disable the DCB by command: port config 0 dcb vt off 1 pfc off Signed-off-by: Chengwen Feng <[email protected]>
1 parent 8ca02e0 commit 5c3091f

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

app/test-pmd/cmdline.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3625,9 +3625,9 @@ cmd_config_dcb_parsed(void *parsed_result,
36253625
return;
36263626
}
36273627

3628-
if (res->num_tcs <= 1 || res->num_tcs > RTE_ETH_8_TCS) {
3628+
if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
36293629
fprintf(stderr,
3630-
"The invalid number of traffic class, only 2~8 allowed.\n");
3630+
"The invalid number of traffic class, only 1~8 allowed.\n");
36313631
return;
36323632
}
36333633

app/test-pmd/testpmd.c

+40-18
Original file line numberDiff line numberDiff line change
@@ -4161,6 +4161,22 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,
41614161
eth_conf->dcb_capability_en = RTE_ETH_DCB_PG_SUPPORT;
41624162
}
41634163

4164+
static void
4165+
clear_eth_dcb_conf(portid_t pid, struct rte_eth_conf *eth_conf)
4166+
{
4167+
uint32_t i;
4168+
4169+
eth_conf->rxmode.mq_mode &= ~(RTE_ETH_MQ_RX_DCB | RTE_ETH_MQ_RX_VMDQ_DCB);
4170+
eth_conf->txmode.mq_mode = RTE_ETH_MQ_TX_NONE;
4171+
eth_conf->dcb_capability_en = 0;
4172+
if (dcb_config) {
4173+
/* Unset VLAN filter configuration if already config DCB. */
4174+
eth_conf->rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
4175+
for (i = 0; i < RTE_DIM(vlan_tags); i++)
4176+
rx_vft_set(pid, vlan_tags[i], 0);
4177+
}
4178+
}
4179+
41644180
int
41654181
init_port_dcb_config(portid_t pid,
41664182
enum dcb_mode_enable dcb_mode,
@@ -4184,16 +4200,19 @@ init_port_dcb_config(portid_t pid,
41844200
/* retain the original device configuration. */
41854201
memcpy(&port_conf, &rte_port->dev_conf, sizeof(struct rte_eth_conf));
41864202

4187-
/* set configuration of DCB in vt mode and DCB in non-vt mode */
4188-
get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en, prio_tc, prio_tc_en);
4189-
4190-
port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
4191-
/* remove RSS HASH offload for DCB in vt mode */
4192-
if (port_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB) {
4193-
port_conf.rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_RSS_HASH;
4194-
for (i = 0; i < nb_rxq; i++)
4195-
rte_port->rxq[i].conf.offloads &=
4196-
~RTE_ETH_RX_OFFLOAD_RSS_HASH;
4203+
if (num_tcs > 1) {
4204+
/* set configuration of DCB in vt mode and DCB in non-vt mode */
4205+
get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en, prio_tc, prio_tc_en);
4206+
port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
4207+
/* remove RSS HASH offload for DCB in vt mode */
4208+
if (port_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB) {
4209+
port_conf.rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_RSS_HASH;
4210+
for (i = 0; i < nb_rxq; i++)
4211+
rte_port->rxq[i].conf.offloads &=
4212+
~RTE_ETH_RX_OFFLOAD_RSS_HASH;
4213+
}
4214+
} else {
4215+
clear_eth_dcb_conf(pid, &port_conf);
41974216
}
41984217

41994218
/* re-configure the device . */
@@ -4208,15 +4227,16 @@ init_port_dcb_config(portid_t pid,
42084227
/* If dev_info.vmdq_pool_base is greater than 0,
42094228
* the queue id of vmdq pools is started after pf queues.
42104229
*/
4211-
if (dcb_mode == DCB_VT_ENABLED &&
4230+
if (num_tcs > 1 &&
4231+
dcb_mode == DCB_VT_ENABLED &&
42124232
rte_port->dev_info.vmdq_pool_base > 0) {
42134233
fprintf(stderr,
42144234
"VMDQ_DCB multi-queue mode is nonsensical for port %d.\n",
42154235
pid);
42164236
return -1;
42174237
}
42184238

4219-
if (keep_qnum == 0) {
4239+
if (num_tcs > 1 && keep_qnum == 0) {
42204240
/* Assume the ports in testpmd have the same dcb capability
42214241
* and has the same number of rxq and txq in dcb mode
42224242
*/
@@ -4244,19 +4264,21 @@ init_port_dcb_config(portid_t pid,
42444264
memcpy(&rte_port->dev_conf, &port_conf, sizeof(struct rte_eth_conf));
42454265

42464266
rxtx_port_config(pid);
4247-
/* VLAN filter */
4248-
rte_port->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
4249-
for (i = 0; i < RTE_DIM(vlan_tags); i++)
4250-
rx_vft_set(pid, vlan_tags[i], 1);
4267+
if (num_tcs > 1) {
4268+
/* VLAN filter */
4269+
rte_port->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
4270+
for (i = 0; i < RTE_DIM(vlan_tags); i++)
4271+
rx_vft_set(pid, vlan_tags[i], 1);
4272+
}
42514273

42524274
retval = eth_macaddr_get_print_err(pid, &rte_port->eth_addr);
42534275
if (retval != 0)
42544276
return retval;
42554277

4256-
rte_port->dcb_flag = 1;
4278+
rte_port->dcb_flag = num_tcs > 1 ? 1 : 0;
42574279

42584280
/* Enter DCB configuration status */
4259-
dcb_config = 1;
4281+
dcb_config = num_tcs > 1 ? 1 : 0;
42604282

42614283
return 0;
42624284
}

doc/guides/testpmd_app_ug/testpmd_funcs.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ Set the DCB mode for an individual port::
21672167

21682168
testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off) prio-tc (prio-tc) keep-qnum
21692169

2170-
The traffic class could be 2~8.
2170+
The traffic class could be 1~8, if the value is 1, DCB is disabled.
21712171
The prio-tc field here is optional, if not specified then the prio-tc use default configuration.
21722172
The keep-qnum field here is also optional, if specified then don't adjust Rx/Tx queue number.
21732173

0 commit comments

Comments
 (0)