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 <fengcheng...@huawei.com>
---
 app/test-pmd/cmdline.c                      |  4 +--
 app/test-pmd/testpmd.c                      | 40 +++++++++++++--------
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 +-
 3 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index ef65a75dc7..517e8d47b6 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3622,9 +3622,9 @@ cmd_config_dcb_parsed(void *parsed_result,
                return;
        }
 
-       if ((res->num_tcs <= 1 || res->num_tcs > RTE_ETH_8_TCS)) {
+       if ((res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS)) {
                fprintf(stderr,
-                       "The invalid number of traffic class, only 2~8 
allowed.\n");
+                       "The invalid number of traffic class, only 1~8 
allowed.\n");
                return;
        }
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index b11762f698..5e0892d99b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4194,6 +4194,14 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum 
dcb_mode_enable dcb_mode,
                eth_conf->dcb_capability_en = RTE_ETH_DCB_PG_SUPPORT;
 }
 
+static void
+clear_eth_dcb_conf(struct rte_eth_conf *eth_conf)
+{
+       eth_conf->rxmode.mq_mode &= ~(RTE_ETH_MQ_RX_DCB | 
RTE_ETH_MQ_RX_VMDQ_DCB);
+       eth_conf->txmode.mq_mode = RTE_ETH_MQ_TX_NONE;
+       eth_conf->dcb_capability_en = 0;
+}
+
 int
 init_port_dcb_config(portid_t pid,
                     enum dcb_mode_enable dcb_mode,
@@ -4217,16 +4225,19 @@ init_port_dcb_config(portid_t pid,
        /* retain the original device configuration. */
        memcpy(&port_conf, &rte_port->dev_conf, sizeof(struct rte_eth_conf));
 
-       /* set configuration of DCB in vt mode and DCB in non-vt mode */
-       get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en, prio_tc, 
prio_tc_en);
-
-       port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
-       /* remove RSS HASH offload for DCB in vt mode */
-       if (port_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB) {
-               port_conf.rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_RSS_HASH;
-               for (i = 0; i < nb_rxq; i++)
-                       rte_port->rxq[i].conf.offloads &=
-                               ~RTE_ETH_RX_OFFLOAD_RSS_HASH;
+       if (num_tcs > 1) {
+               /* set configuration of DCB in vt mode and DCB in non-vt mode */
+               get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en, 
prio_tc, prio_tc_en);
+               port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
+               /* remove RSS HASH offload for DCB in vt mode */
+               if (port_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB) {
+                       port_conf.rxmode.offloads &= 
~RTE_ETH_RX_OFFLOAD_RSS_HASH;
+                       for (i = 0; i < nb_rxq; i++)
+                               rte_port->rxq[i].conf.offloads &=
+                                       ~RTE_ETH_RX_OFFLOAD_RSS_HASH;
+               }
+       } else {
+               clear_eth_dcb_conf(&port_conf);
        }
 
        /* re-configure the device . */
@@ -4241,7 +4252,8 @@ init_port_dcb_config(portid_t pid,
        /* If dev_info.vmdq_pool_base is greater than 0,
         * the queue id of vmdq pools is started after pf queues.
         */
-       if (dcb_mode == DCB_VT_ENABLED &&
+       if (num_tcs > 1 &&
+           dcb_mode == DCB_VT_ENABLED &&
            rte_port->dev_info.vmdq_pool_base > 0) {
                fprintf(stderr,
                        "VMDQ_DCB multi-queue mode is nonsensical for port 
%d.\n",
@@ -4249,7 +4261,7 @@ init_port_dcb_config(portid_t pid,
                return -1;
        }
 
-       if (keep_qnum == 0) {
+       if (num_tcs > 1 && keep_qnum == 0) {
                /* Assume the ports in testpmd have the same dcb capability
                 * and has the same number of rxq and txq in dcb mode
                 */
@@ -4287,10 +4299,10 @@ init_port_dcb_config(portid_t pid,
        if (retval != 0)
                return retval;
 
-       rte_port->dcb_flag = 1;
+       rte_port->dcb_flag = num_tcs > 1 ? 1 : 0;
 
        /* Enter DCB configuration status */
-       dcb_config = 1;
+       dcb_config = num_tcs > 1 ? 1 : 0;
 
        return 0;
 }
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst 
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 44eed3f49d..6ad83ae50d 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2167,7 +2167,7 @@ Set the DCB mode for an individual port::
 
    testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off) 
prio-tc (prio-tc) keep-qnum
 
-The traffic class could be 2~8.
+The traffic class could be 1~8, if the value is 1, DCB is disabled.
 The prio-tc field here is optional, if not specified then the prio-tc use 
default configuration.
 The keep-qnum field here is also optional, if specified then don't adjust 
Rx/Tx queue number.
 
-- 
2.17.1

Reply via email to