@@ -46,7 +46,8 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi)
4646	if  (!vsi -> rx_rings )
4747		goto err_rings ;
4848
49- 	vsi -> txq_map  =  devm_kcalloc (& pf -> pdev -> dev , vsi -> alloc_txq ,
49+ 	/* XDP will have vsi->alloc_txq Tx queues as well, so double the size */ 
50+ 	vsi -> txq_map  =  devm_kcalloc (& pf -> pdev -> dev , (2  *  vsi -> alloc_txq ),
5051				    sizeof (* vsi -> txq_map ), GFP_KERNEL );
5152
5253	if  (!vsi -> txq_map )
@@ -1183,6 +1184,20 @@ int ice_vsi_kill_vlan(struct ice_vsi *vsi, u16 vid)
11831184	return  err ;
11841185}
11851186
1187+ /** 
1188+  * ice_vsi_cfg_frame_size - setup max frame size and Rx buffer length 
1189+  * @vsi: VSI 
1190+  */ 
1191+ void  ice_vsi_cfg_frame_size (struct  ice_vsi  * vsi )
1192+ {
1193+ 	if  (vsi -> netdev  &&  vsi -> netdev -> mtu  >  ETH_DATA_LEN )
1194+ 		vsi -> max_frame  =  vsi -> netdev -> mtu  +  ICE_ETH_PKT_HDR_PAD ;
1195+ 	else 
1196+ 		vsi -> max_frame  =  ICE_RXBUF_2048 ;
1197+ 
1198+ 	vsi -> rx_buf_len  =  ICE_RXBUF_2048 ;
1199+ }
1200+ 
11861201/** 
11871202 * ice_vsi_cfg_rxqs - Configure the VSI for Rx 
11881203 * @vsi: the VSI being configured 
@@ -1197,13 +1212,7 @@ int ice_vsi_cfg_rxqs(struct ice_vsi *vsi)
11971212	if  (vsi -> type  ==  ICE_VSI_VF )
11981213		goto setup_rings ;
11991214
1200- 	if  (vsi -> netdev  &&  vsi -> netdev -> mtu  >  ETH_DATA_LEN )
1201- 		vsi -> max_frame  =  vsi -> netdev -> mtu  + 
1202- 			ETH_HLEN  +  ETH_FCS_LEN  +  VLAN_HLEN ;
1203- 	else 
1204- 		vsi -> max_frame  =  ICE_RXBUF_2048 ;
1205- 
1206- 	vsi -> rx_buf_len  =  ICE_RXBUF_2048 ;
1215+ 	ice_vsi_cfg_frame_size (vsi );
12071216setup_rings :
12081217	/* set up individual rings */ 
12091218	for  (i  =  0 ; i  <  vsi -> num_rxq ; i ++ ) {
@@ -1265,6 +1274,18 @@ int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi)
12651274	return  ice_vsi_cfg_txqs (vsi , vsi -> tx_rings );
12661275}
12671276
1277+ /** 
1278+  * ice_vsi_cfg_xdp_txqs - Configure Tx queues dedicated for XDP in given VSI 
1279+  * @vsi: the VSI being configured 
1280+  * 
1281+  * Return 0 on success and a negative value on error 
1282+  * Configure the Tx queues dedicated for XDP in given VSI for operation. 
1283+  */ 
1284+ int  ice_vsi_cfg_xdp_txqs (struct  ice_vsi  * vsi )
1285+ {
1286+ 	return  ice_vsi_cfg_txqs (vsi , vsi -> xdp_rings );
1287+ }
1288+ 
12681289/** 
12691290 * ice_intrl_usec_to_reg - convert interrupt rate limit to register value 
12701291 * @intrl: interrupt rate limit in usecs 
@@ -1488,6 +1509,15 @@ ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src,
14881509	return  ice_vsi_stop_tx_rings (vsi , rst_src , rel_vmvf_num , vsi -> tx_rings );
14891510}
14901511
1512+ /** 
1513+  * ice_vsi_stop_xdp_tx_rings - Disable XDP Tx rings 
1514+  * @vsi: the VSI being configured 
1515+  */ 
1516+ int  ice_vsi_stop_xdp_tx_rings (struct  ice_vsi  * vsi )
1517+ {
1518+ 	return  ice_vsi_stop_tx_rings (vsi , ICE_NO_RESET , 0 , vsi -> xdp_rings );
1519+ }
1520+ 
14911521/** 
14921522 * ice_cfg_vlan_pruning - enable or disable VLAN pruning on the VSI 
14931523 * @vsi: VSI to enable or disable VLAN pruning on 
@@ -1885,6 +1915,11 @@ static void ice_vsi_release_msix(struct ice_vsi *vsi)
18851915		wr32 (hw , GLINT_ITR (ICE_IDX_ITR1 , reg_idx ), 0 );
18861916		for  (q  =  0 ; q  <  q_vector -> num_ring_tx ; q ++ ) {
18871917			wr32 (hw , QINT_TQCTL (vsi -> txq_map [txq ]), 0 );
1918+ 			if  (ice_is_xdp_ena_vsi (vsi )) {
1919+ 				u32  xdp_txq  =  txq  +  vsi -> num_xdp_txq ;
1920+ 
1921+ 				wr32 (hw , QINT_TQCTL (vsi -> txq_map [xdp_txq ]), 0 );
1922+ 			}
18881923			txq ++ ;
18891924		}
18901925
@@ -2259,6 +2294,11 @@ int ice_vsi_rebuild(struct ice_vsi *vsi)
22592294		vsi -> base_vector  =  0 ;
22602295	}
22612296
2297+ 	if  (ice_is_xdp_ena_vsi (vsi ))
2298+ 		/* return value check can be skipped here, it always returns 
2299+ 		 * 0 if reset is in progress 
2300+ 		 */ 
2301+ 		ice_destroy_xdp_rings (vsi );
22622302	ice_vsi_put_qs (vsi );
22632303	ice_vsi_clear_rings (vsi );
22642304	ice_vsi_free_arrays (vsi );
@@ -2299,6 +2339,12 @@ int ice_vsi_rebuild(struct ice_vsi *vsi)
22992339			goto err_vectors ;
23002340
23012341		ice_vsi_map_rings_to_vectors (vsi );
2342+ 		if  (ice_is_xdp_ena_vsi (vsi )) {
2343+ 			vsi -> num_xdp_txq  =  vsi -> alloc_txq ;
2344+ 			ret  =  ice_prepare_xdp_rings (vsi , vsi -> xdp_prog );
2345+ 			if  (ret )
2346+ 				goto err_vectors ;
2347+ 		}
23022348		/* Do not exit if configuring RSS had an issue, at least 
23032349		 * receive traffic on first queue. Hence no need to capture 
23042350		 * return value 
@@ -2325,9 +2371,13 @@ int ice_vsi_rebuild(struct ice_vsi *vsi)
23252371	}
23262372
23272373	/* configure VSI nodes based on number of queues and TC's */ 
2328- 	for  (i  =  0 ; i  <  vsi -> tc_cfg .numtc ; i ++ )
2374+ 	for  (i  =  0 ; i  <  vsi -> tc_cfg .numtc ; i ++ ) { 
23292375		max_txqs [i ] =  vsi -> alloc_txq ;
23302376
2377+ 		if  (ice_is_xdp_ena_vsi (vsi ))
2378+ 			max_txqs [i ] +=  vsi -> num_xdp_txq ;
2379+ 	}
2380+ 
23312381	status  =  ice_cfg_vsi_lan (vsi -> port_info , vsi -> idx , vsi -> tc_cfg .ena_tc ,
23322382				 max_txqs );
23332383	if  (status ) {
0 commit comments