<div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">сб, 30 авг. 2025 г. в 21:54, Ivan Malov <<a href="mailto:ivan.malov@arknetworks.am" target="_blank">ivan.malov@arknetworks.am</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Vladimir,<br>
<br>
On Sat, 30 Aug 2025, Vladimir Medvedkin wrote:<br>
<br>
> Currently DCB Traffic Class queue mapping is only used when calling get<br>
> DCB info API, while setting up queue mappings is up to each individual<br>
> driver. Use the tc queue mapping structure to enable setting up custom<br>
> mapping explicitly.<br>
><br>
> Signed-off-by: Vladimir Medvedkin <<a href="mailto:vladimir.medvedkin@intel.com" target="_blank">vladimir.medvedkin@intel.com</a>><br>
> ---<br>
> app/test-pmd/testpmd.c             | 57 ++++++++++++++++++------------<br>
> drivers/net/intel/ice/ice_ethdev.c | 39 ++++++++++----------<br>
> drivers/net/intel/ice/ice_rxtx.c   | 27 +++++++-------<br>
> lib/ethdev/rte_ethdev.h            | 43 +++++++++++-----------<br>
> 4 files changed, 92 insertions(+), 74 deletions(-)<br>
><br>
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c<br>
> index b5a7e7b3ee..3a55434d44 100644<br>
> --- a/app/test-pmd/testpmd.c<br>
> +++ b/app/test-pmd/testpmd.c<br>
> @@ -4158,6 +4158,16 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,<br>
>               struct rte_eth_dcb_conf *tx_conf =<br>
>                               &eth_conf->tx_adv_conf.dcb_tx_conf;<br>
><br>
> +             struct rte_eth_dcb_tc_queue_mapping *q_map = &eth_conf->q_map;<br>
> +             memset(q_map, 0, sizeof(*q_map));<br>
> +             int queues_per_tc = nb_rxq / num_tcs;<br>
> +             for (i = 0; i < num_tcs; i++) {<br>
> +                     q_map->tc_rxq[0][i].base = i * queues_per_tc;<br>
> +                     q_map->tc_txq[0][i].base = i * queues_per_tc;<br>
> +                     q_map->tc_rxq[0][i].nb_queue = queues_per_tc;<br>
> +                     q_map->tc_txq[0][i].nb_queue = queues_per_tc;<br>
> +             }<br>
> +<br>
>               for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {<br>
>                       dcb_tc_val = prio_tc_en ? prio_tc[i] : i % num_tcs;<br>
>                       rx_conf->dcb_tc[i] = dcb_tc_val;<br>
> @@ -4231,6 +4241,30 @@ init_port_dcb_config(portid_t pid,<br>
>       /* retain the original device configuration. */<br>
>       memcpy(&port_conf, &rte_port->dev_conf, sizeof(struct rte_eth_conf));<br>
><br>
> +     if (num_tcs > 1 && keep_qnum == 0) {<br>
> +             /* Assume the ports in testpmd have the same dcb capability<br>
> +              * and has the same number of rxq and txq in dcb mode<br>
> +              */<br>
> +             if (dcb_mode == DCB_VT_ENABLED) {<br>
> +                     if (rte_port->dev_info.max_vfs > 0) {<br>
> +                             nb_rxq = rte_port->dev_info.nb_rx_queues;<br>
> +                             nb_txq = rte_port->dev_info.nb_tx_queues;<br>
> +                     } else {<br>
> +                             nb_rxq = rte_port->dev_info.max_rx_queues;<br>
> +                             nb_txq = rte_port->dev_info.max_tx_queues;<br>
> +                     }<br>
> +             } else {<br>
> +                     /*if vt is disabled, use all pf queues */<br>
<br>
Missing space between '/*' and 'if'.<br>
<br>
> +                     if (rte_port->dev_info.vmdq_pool_base == 0) {<br>
> +                             nb_rxq = rte_port->dev_info.max_rx_queues;<br>
> +                             nb_txq = rte_port->dev_info.max_tx_queues;<br>
> +                     } else {<br>
> +                             nb_rxq = (queueid_t)num_tcs;<br>
> +                             nb_txq = (queueid_t)num_tcs;<br>
> +                     }<br>
> +             }<br>
> +     }<br>
> +<br>
>       if (num_tcs > 1) {<br>
>               /* set configuration of DCB in vt mode and DCB in non-vt mode */<br>
>               get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en, prio_tc, prio_tc_en);<br>
> @@ -4267,29 +4301,6 @@ init_port_dcb_config(portid_t pid,<br>
>               return -1;<br>
>       }<br>
><br>
> -     if (num_tcs > 1 && keep_qnum == 0) {<br>
> -             /* Assume the ports in testpmd have the same dcb capability<br>
> -              * and has the same number of rxq and txq in dcb mode<br>
> -              */<br>
> -             if (dcb_mode == DCB_VT_ENABLED) {<br>
> -                     if (rte_port->dev_info.max_vfs > 0) {<br>
> -                             nb_rxq = rte_port->dev_info.nb_rx_queues;<br>
> -                             nb_txq = rte_port->dev_info.nb_tx_queues;<br>
> -                     } else {<br>
> -                             nb_rxq = rte_port->dev_info.max_rx_queues;<br>
> -                             nb_txq = rte_port->dev_info.max_tx_queues;<br>
> -                     }<br>
> -             } else {<br>
> -                     /*if vt is disabled, use all pf queues */<br>
> -                     if (rte_port->dev_info.vmdq_pool_base == 0) {<br>
> -                             nb_rxq = rte_port->dev_info.max_rx_queues;<br>
> -                             nb_txq = rte_port->dev_info.max_tx_queues;<br>
> -                     } else {<br>
> -                             nb_rxq = (queueid_t)num_tcs;<br>
> -                             nb_txq = (queueid_t)num_tcs;<br>
> -                     }<br>
> -             }<br>
> -     }<br>
>       rx_free_thresh = 64;<br>
><br>
>       memcpy(&rte_port->dev_conf, &port_conf, sizeof(struct rte_eth_conf));<br>
> diff --git a/drivers/net/intel/ice/ice_ethdev.c b/drivers/net/intel/ice/ice_ethdev.c<br>
> index ecde00182f..27559bbe18 100644<br>
> --- a/drivers/net/intel/ice/ice_ethdev.c<br>
> +++ b/drivers/net/intel/ice/ice_ethdev.c<br>
> @@ -3846,7 +3846,7 @@ ice_dev_configure(struct rte_eth_dev *dev)<br>
>               struct rte_eth_dcb_conf *tx_dcb_conf =<br>
>                       &dev->data->dev_conf.tx_adv_conf.dcb_tx_conf;<br>
>               int i;<br>
> -             int nb_tc_used_rx, nb_tc_used_tx, queues_per_tc;<br>
> +             int nb_tc_used_rx, nb_tc_used_tx;<br>
>               uint16_t total_q_nb;<br>
><br>
>               nb_tc_used_rx = check_dcb_conf(ice_get_port_max_cgd(hw) == ICE_4_CGD_PER_PORT,<br>
> @@ -3865,19 +3865,23 @@ ice_dev_configure(struct rte_eth_dev *dev)<br>
>               }<br>
><br>
>               total_q_nb = dev->data->nb_rx_queues;<br>
> -             queues_per_tc = total_q_nb / nb_tc_used_rx;<br>
> -             if (total_q_nb % nb_tc_used_rx != 0) {<br>
> -                     PMD_DRV_LOG(ERR, "For DCB, number of queues must be evenly divisble by number of used TCs");<br>
> -                     return -EINVAL;<br>
> -             } else if (!rte_is_power_of_2(queues_per_tc)) {<br>
> -                     PMD_DRV_LOG(ERR, "For DCB, number of queues per TC must be a power of 2");<br>
> -                     return -EINVAL;<br>
> -             }<br>
> -<br>
> +             struct rte_eth_dcb_tc_queue_mapping *q_map = &dev->data->dev_conf.q_map;<br>
>               for (i = 0; i < nb_tc_used_rx; i++) {<br>
> +                     if (q_map->tc_rxq[0][i].nb_queue != 0 &&<br>
<br>
How is 'nb_queue == 0' case handled here and below? Should some driver-default<br>
fill-in be used, similar to code being deleted above?<br>
<br>
Or is '(0 << ICE_AQ_VSI_TC_Q_OFFSET_S) | (0 << ICE_AQ_VSI_TC_Q_NUM_S)' legit?<br></blockquote><div><br></div><div>Yes, this is legit. In this case packets arriving to the corresponding TC will be sent to the default queue (i.e. the first queue).</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> +                                     !rte_is_power_of_2(q_map->tc_rxq[0][i].nb_queue)) {<br>
> +                             PMD_DRV_LOG(ERR, "For DCB, number of queues per TC must be a power of 2");<br>
> +                             return -EINVAL;<br>
> +                     }<br>
> +                     if ((q_map->tc_rxq[0][i].base + q_map->tc_rxq[0][i].nb_queue) > total_q_nb) {<br>
> +                             PMD_DRV_LOG(ERR, "Queue range for TC %d exceeds total number of queues",<br>
> +                                     i);<br>
> +                             return -EINVAL;<br>
> +                     }<br>
>                       ctxt.info.tc_mapping[i] =<br>
> -                             rte_cpu_to_le_16(((i * queues_per_tc) << ICE_AQ_VSI_TC_Q_OFFSET_S) |<br>
> -                                     (rte_log2_u32(queues_per_tc) << ICE_AQ_VSI_TC_Q_NUM_S));<br>
> +                             rte_cpu_to_le_16((q_map->tc_rxq[0][i].base <<<br>
> +                                     ICE_AQ_VSI_TC_Q_OFFSET_S) |<br>
> +                                     (rte_log2_u32(q_map->tc_rxq[0][i].nb_queue) <<<br>
> +                                     ICE_AQ_VSI_TC_Q_NUM_S));<br>
<br>
This seems to always use pool [0] but does not seem to check if 'nb_queue' in,<br>
say, pool [1] is non-zero, to return an error or something. Or is this unneeded?<br></blockquote><div><br></div><div>Yes, this is unneeded. DCB with VMDq is not supported in ice PMD. In more detail, we do not support VMDq1, where per-VM queue ranges are "exposed" like in older ixgbe HW. Instead we support VMDq2, where each per-VM queue range is covered under VSI (think of it as a virtual interface) abstraction layer.</div><div>For queue mapping I reuse the existing structure, which is used with rte_eth_dev_get_dcb_info() API. Maybe it is better to create a dedicated queue mapping structure without all VMDq-related stuff?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
>               }<br>
><br>
>               memset(local_dcb_conf, 0, sizeof(*local_dcb_conf));<br>
> @@ -3941,6 +3945,7 @@ ice_get_dcb_info(struct rte_eth_dev *dev, struct rte_eth_dcb_info *dcb_info)<br>
>       struct ice_dcbx_cfg *dcb_conf = &qos_cfg->local_dcbx_cfg;<br>
>       struct ice_vsi *vsi = pf->main_vsi;<br>
>       struct ice_vsi_ctx ctxt = { 0 };<br>
> +     struct rte_eth_dcb_tc_queue_mapping *q_map = &dev->data->dev_conf.q_map;<br>
><br>
>       <a href="http://ctxt.info" rel="noreferrer" target="_blank">ctxt.info</a> = vsi->info;<br>
>       if (rte_le_to_cpu_16(<a href="http://ctxt.info" target="_blank">ctxt.info</a>.mapping_flags) == ICE_AQ_VSI_Q_MAP_NONCONTIG) {<br>
> @@ -3953,13 +3958,11 @@ ice_get_dcb_info(struct rte_eth_dev *dev, struct rte_eth_dcb_info *dcb_info)<br>
>               dcb_info->prio_tc[i] = dcb_conf->etscfg.prio_table[i];<br>
>               dcb_info->tc_bws[i] = dcb_conf->etscfg.tcbwtable[i];<br>
>               /* Using VMDQ pool zero since DCB+VMDQ is not supported */<br>
> -             uint16_t tc_rx_q_map = rte_le_to_cpu_16(ctxt.info.tc_mapping[i]);<br>
> -             dcb_info->tc_queue.tc_rxq[0][i].base = tc_rx_q_map & ICE_AQ_VSI_TC_Q_OFFSET_M;<br>
> -             dcb_info->tc_queue.tc_rxq[0][i].nb_queue =<br>
> -                     1 << ((tc_rx_q_map & ICE_AQ_VSI_TC_Q_NUM_M) >> ICE_AQ_VSI_TC_Q_NUM_S);<br>
> +             dcb_info->tc_queue.tc_rxq[0][i].base = q_map->tc_rxq[0][i].base;<br>
> +             dcb_info->tc_queue.tc_rxq[0][i].nb_queue = q_map->tc_rxq[0][i].nb_queue;<br>
><br>
> -             dcb_info->tc_queue.tc_txq[0][i].base = dcb_info->tc_queue.tc_rxq[0][i].base;<br>
> -             dcb_info->tc_queue.tc_txq[0][i].nb_queue = dcb_info->tc_queue.tc_rxq[0][i].nb_queue;<br>
> +             dcb_info->tc_queue.tc_txq[0][i].base = q_map->tc_txq[0][i].base;<br>
> +             dcb_info->tc_queue.tc_txq[0][i].nb_queue = q_map->tc_txq[0][i].nb_queue;<br>
>       }<br>
><br>
>       return 0;<br>
> diff --git a/drivers/net/intel/ice/ice_rxtx.c b/drivers/net/intel/ice/ice_rxtx.c<br>
> index 451816affd..55424e7a23 100644<br>
> --- a/drivers/net/intel/ice/ice_rxtx.c<br>
> +++ b/drivers/net/intel/ice/ice_rxtx.c<br>
> @@ -796,6 +796,7 @@ ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)<br>
>       int buf_len;<br>
>       struct ice_adapter *ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);<br>
>       u16 q_base, q_range, cgd_idx = 0;<br>
> +     struct rte_eth_dcb_tc_queue_mapping *q_map = &dev->data->dev_conf.q_map;<br>
><br>
>       PMD_INIT_FUNC_TRACE();<br>
><br>
> @@ -840,22 +841,22 @@ ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)<br>
>       tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */<br>
>       tx_ctx.tsyn_ena = 1;<br>
><br>
> -     /* Mirror RXQ<->CGD association to TXQ<->CDG */<br>
> -     for (int i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {<br>
> -             q_base = rte_le_to_cpu_16(vsi->info.tc_mapping[i]) & ICE_AQ_VSI_TC_Q_OFFSET_M;<br>
> -             q_range = 1 << ((rte_le_to_cpu_16(vsi->info.tc_mapping[i]) &<br>
> -                     ICE_AQ_VSI_TC_Q_NUM_M) >> ICE_AQ_VSI_TC_Q_NUM_S);<br>
> +     if (dev->data->dev_conf.txmode.mq_mode == RTE_ETH_MQ_TX_DCB) {<br>
> +             for (int i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {<br>
> +                     q_base = q_map->tc_txq[0][i].base;<br>
> +                     q_range = q_map->tc_txq[0][i].nb_queue;<br>
><br>
> -             if (q_base <= tx_queue_id && tx_queue_id < q_base + q_range)<br>
> -                     break;<br>
> +                     if (q_base <= tx_queue_id && tx_queue_id < q_base + q_range)<br>
> +                             break;<br>
><br>
> -             cgd_idx++;<br>
> -     }<br>
> +                     cgd_idx++;<br>
> +             }<br>
><br>
> -     if (cgd_idx >= ICE_MAX_TRAFFIC_CLASS) {<br>
> -             PMD_DRV_LOG(ERR, "Bad queue mapping configuration");<br>
> -             rte_free(txq_elem);<br>
> -             return -EINVAL;<br>
> +             if (cgd_idx >= ICE_MAX_TRAFFIC_CLASS) {<br>
> +                     PMD_DRV_LOG(ERR, "Bad queue mapping configuration");<br>
> +                     rte_free(txq_elem);<br>
> +                     return -EINVAL;<br>
> +             }<br>
>       }<br>
><br>
>       tx_ctx.cgd_num = cgd_idx;<br>
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h<br>
> index c220760043..0bd86e1e7d 100644<br>
> --- a/lib/ethdev/rte_ethdev.h<br>
> +++ b/lib/ethdev/rte_ethdev.h<br>
> @@ -1472,6 +1472,26 @@ struct rte_eth_intr_conf {<br>
><br>
> #define rte_intr_conf rte_eth_intr_conf<br>
><br>
> +#define RTE_ETH_DCB_NUM_TCS    8<br>
> +#define RTE_ETH_MAX_VMDQ_POOL  64<br>
> +<br>
> +/**<br>
> + * A structure used to get the information of queue and<br>
> + * TC mapping on both Tx and Rx paths.<br>
> + */<br>
> +struct rte_eth_dcb_tc_queue_mapping {<br>
> +     /** Rx queues assigned to tc per Pool */<br>
> +     struct {<br>
> +             uint16_t base;<br>
> +             uint16_t nb_queue;<br>
> +     } tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];<br>
> +     /** Rx queues assigned to tc per Pool */<br>
> +     struct {<br>
> +             uint16_t base;<br>
> +             uint16_t nb_queue;<br>
> +     } tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];<br>
> +};<br>
> +<br>
> /**<br>
>  * A structure used to configure an Ethernet port.<br>
>  * Depending upon the Rx multi-queue mode, extra advanced<br>
> @@ -1492,18 +1512,21 @@ struct rte_eth_conf {<br>
>                                Read the datasheet of given Ethernet controller<br>
>                                for details. The possible values of this field<br>
>                                are defined in implementation of each driver. */<br>
> +     struct rte_eth_dcb_tc_queue_mapping q_map;<br>
<br>
Is the driver supposed to tell 'q_map' is valid by looking at [0][0] 'nb_queue'?<br></blockquote><div><br></div><div>Could you please clarify what validity criteria for the [0][0] 'nb_queue' do you mean?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
>       struct {<br>
>               struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */<br>
>               /** Port DCB Rx configuration. */<br>
>               struct rte_eth_dcb_conf dcb_rx_conf;<br>
>               /** Port VMDq Rx configuration. */<br>
>               struct rte_eth_vmdq_rx_conf vmdq_rx_conf;<br>
> +             /* VMDQ and DCB Rx queue mapping configuration. */<br>
<br>
Perhaps it's better to have just one such comment right before 'q_map'.<br></blockquote><div><br></div><div>Oh, my bad, last minute rework, thanks!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thank you.<br>
<br>
>       } rx_adv_conf; /**< Port Rx filtering configuration. */<br>
>       struct {<br>
>               /** Port DCB Tx configuration. */<br>
>               struct rte_eth_dcb_conf dcb_tx_conf;<br>
>               /** Port VMDq Tx configuration. */<br>
>               struct rte_eth_vmdq_tx_conf vmdq_tx_conf;<br>
> +             /* VMDQ and DCB Tx queue mapping configuration. */<br>
>       } tx_adv_conf; /**< Port Tx DCB configuration (union). */<br>
>       /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC<br>
>           is needed,and the variable must be set RTE_ETH_DCB_PFC_SUPPORT. */<br>
> @@ -1930,26 +1953,6 @@ struct rte_eth_xstat_name {<br>
>       char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */<br>
> };<br>
><br>
> -#define RTE_ETH_DCB_NUM_TCS    8<br>
> -#define RTE_ETH_MAX_VMDQ_POOL  64<br>
> -<br>
> -/**<br>
> - * A structure used to get the information of queue and<br>
> - * TC mapping on both Tx and Rx paths.<br>
> - */<br>
> -struct rte_eth_dcb_tc_queue_mapping {<br>
> -     /** Rx queues assigned to tc per Pool */<br>
> -     struct {<br>
> -             uint16_t base;<br>
> -             uint16_t nb_queue;<br>
> -     } tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];<br>
> -     /** Rx queues assigned to tc per Pool */<br>
> -     struct {<br>
> -             uint16_t base;<br>
> -             uint16_t nb_queue;<br>
> -     } tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];<br>
> -};<br>
> -<br>
> /**<br>
>  * A structure used to get the information of DCB.<br>
>  * It includes TC UP mapping and queue TC mapping.<br>
> -- <br>
> 2.43.0<br>
><br>
><br>
</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div>Vladimir<br></div></div></div>
</div>