Skip to content

Commit f64780e

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2022-09-19 (iavf, i40e) Norbert adds checking of buffer size for Rx buffer checks in iavf. Michal corrects setting of max MTU in iavf to account for MTU data provided by PF, fixes i40e to set VF max MTU, and resolves lack of rate limiting when value was less than divisor for i40e. * '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue: i40e: Fix set max_tx_rate when it is lower than 1 Mbps i40e: Fix VF set max MTU size iavf: Fix set max MTU size with port VLAN and jumbo frames iavf: Fix bad page state ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 375a683 + 198eb7e commit f64780e

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5908,6 +5908,26 @@ static int i40e_get_link_speed(struct i40e_vsi *vsi)
59085908
}
59095909
}
59105910

5911+
/**
5912+
* i40e_bw_bytes_to_mbits - Convert max_tx_rate from bytes to mbits
5913+
* @vsi: Pointer to vsi structure
5914+
* @max_tx_rate: max TX rate in bytes to be converted into Mbits
5915+
*
5916+
* Helper function to convert units before send to set BW limit
5917+
**/
5918+
static u64 i40e_bw_bytes_to_mbits(struct i40e_vsi *vsi, u64 max_tx_rate)
5919+
{
5920+
if (max_tx_rate < I40E_BW_MBPS_DIVISOR) {
5921+
dev_warn(&vsi->back->pdev->dev,
5922+
"Setting max tx rate to minimum usable value of 50Mbps.\n");
5923+
max_tx_rate = I40E_BW_CREDIT_DIVISOR;
5924+
} else {
5925+
do_div(max_tx_rate, I40E_BW_MBPS_DIVISOR);
5926+
}
5927+
5928+
return max_tx_rate;
5929+
}
5930+
59115931
/**
59125932
* i40e_set_bw_limit - setup BW limit for Tx traffic based on max_tx_rate
59135933
* @vsi: VSI to be configured
@@ -5930,10 +5950,10 @@ int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate)
59305950
max_tx_rate, seid);
59315951
return -EINVAL;
59325952
}
5933-
if (max_tx_rate && max_tx_rate < 50) {
5953+
if (max_tx_rate && max_tx_rate < I40E_BW_CREDIT_DIVISOR) {
59345954
dev_warn(&pf->pdev->dev,
59355955
"Setting max tx rate to minimum usable value of 50Mbps.\n");
5936-
max_tx_rate = 50;
5956+
max_tx_rate = I40E_BW_CREDIT_DIVISOR;
59375957
}
59385958

59395959
/* Tx rate credits are in values of 50Mbps, 0 is disabled */
@@ -8224,9 +8244,9 @@ static int i40e_setup_tc(struct net_device *netdev, void *type_data)
82248244

82258245
if (i40e_is_tc_mqprio_enabled(pf)) {
82268246
if (vsi->mqprio_qopt.max_rate[0]) {
8227-
u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0];
8247+
u64 max_tx_rate = i40e_bw_bytes_to_mbits(vsi,
8248+
vsi->mqprio_qopt.max_rate[0]);
82288249

8229-
do_div(max_tx_rate, I40E_BW_MBPS_DIVISOR);
82308250
ret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);
82318251
if (!ret) {
82328252
u64 credits = max_tx_rate;
@@ -10971,10 +10991,10 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
1097110991
}
1097210992

1097310993
if (vsi->mqprio_qopt.max_rate[0]) {
10974-
u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0];
10994+
u64 max_tx_rate = i40e_bw_bytes_to_mbits(vsi,
10995+
vsi->mqprio_qopt.max_rate[0]);
1097510996
u64 credits = 0;
1097610997

10977-
do_div(max_tx_rate, I40E_BW_MBPS_DIVISOR);
1097810998
ret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);
1097910999
if (ret)
1098011000
goto end_unlock;

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,25 @@ static void i40e_del_qch(struct i40e_vf *vf)
20382038
}
20392039
}
20402040

2041+
/**
2042+
* i40e_vc_get_max_frame_size
2043+
* @vf: pointer to the VF
2044+
*
2045+
* Max frame size is determined based on the current port's max frame size and
2046+
* whether a port VLAN is configured on this VF. The VF is not aware whether
2047+
* it's in a port VLAN so the PF needs to account for this in max frame size
2048+
* checks and sending the max frame size to the VF.
2049+
**/
2050+
static u16 i40e_vc_get_max_frame_size(struct i40e_vf *vf)
2051+
{
2052+
u16 max_frame_size = vf->pf->hw.phy.link_info.max_frame_size;
2053+
2054+
if (vf->port_vlan_id)
2055+
max_frame_size -= VLAN_HLEN;
2056+
2057+
return max_frame_size;
2058+
}
2059+
20412060
/**
20422061
* i40e_vc_get_vf_resources_msg
20432062
* @vf: pointer to the VF info
@@ -2139,6 +2158,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
21392158
vfres->max_vectors = pf->hw.func_caps.num_msix_vectors_vf;
21402159
vfres->rss_key_size = I40E_HKEY_ARRAY_SIZE;
21412160
vfres->rss_lut_size = I40E_VF_HLUT_ARRAY_SIZE;
2161+
vfres->max_mtu = i40e_vc_get_max_frame_size(vf);
21422162

21432163
if (vf->lan_vsi_idx) {
21442164
vfres->vsi_res[0].vsi_id = vf->lan_vsi_id;

drivers/net/ethernet/intel/iavf/iavf_txrx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ static struct sk_buff *iavf_build_skb(struct iavf_ring *rx_ring,
13931393
#endif
13941394
struct sk_buff *skb;
13951395

1396-
if (!rx_buffer)
1396+
if (!rx_buffer || !size)
13971397
return NULL;
13981398
/* prefetch first cache line of first page */
13991399
va = page_address(rx_buffer->page) + rx_buffer->page_offset;
@@ -1551,7 +1551,7 @@ static int iavf_clean_rx_irq(struct iavf_ring *rx_ring, int budget)
15511551
/* exit if we failed to retrieve a buffer */
15521552
if (!skb) {
15531553
rx_ring->rx_stats.alloc_buff_failed++;
1554-
if (rx_buffer)
1554+
if (rx_buffer && size)
15551555
rx_buffer->pagecnt_bias++;
15561556
break;
15571557
}

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,14 @@ int iavf_get_vf_vlan_v2_caps(struct iavf_adapter *adapter)
269269
void iavf_configure_queues(struct iavf_adapter *adapter)
270270
{
271271
struct virtchnl_vsi_queue_config_info *vqci;
272-
struct virtchnl_queue_pair_info *vqpi;
272+
int i, max_frame = adapter->vf_res->max_mtu;
273273
int pairs = adapter->num_active_queues;
274-
int i, max_frame = IAVF_MAX_RXBUFFER;
274+
struct virtchnl_queue_pair_info *vqpi;
275275
size_t len;
276276

277+
if (max_frame > IAVF_MAX_RXBUFFER || !max_frame)
278+
max_frame = IAVF_MAX_RXBUFFER;
279+
277280
if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
278281
/* bail because we already have a command pending */
279282
dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",

0 commit comments

Comments
 (0)