@@ -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+
51155145static uint16_t
51165146get_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 */
51765209static void
51775210dcb_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 ;
0 commit comments