Intel Wired LAN Driver Updates 2022-09-19 (iavf, i40e)
Subsystems (3)
Tony Nguyen
maintainerThis series contains updates to iavf and i40e drivers.
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.
The following are changes since commit 96628951869c0dedf0377adca01c8675172d8639:
tcp: Use WARN_ON_ONCE() in tcp_read_skb()
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 40GbE
Michal Jaron (3):
iavf: Fix set max MTU size with port VLAN and jumbo frames
i40e: Fix VF set max MTU size
i40e: Fix set max_tx_rate when it is lower than 1 Mbps
Norbert Zulinski (1):
iavf: Fix bad page state
drivers/net/ethernet/intel/i40e/i40e_main.c | 32 +++++++++++++++---- .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 20 ++++++++++++ drivers/net/ethernet/intel/iavf/iavf_txrx.c | 4 +-- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 7 ++-- 4 files changed, 53 insertions(+), 10 deletions(-)
Signature · 1 line
2.35.1
Tony Nguyen
maintainerPATCH 1/4 iavf: Fix bad page state
From: Norbert Zulinski <[email protected]>
Fix bad page state, free inappropriate page in handling dummy descriptor. iavf_build_skb now has to check not only if rx_buffer is NULL but also if size is zero, same thing in iavf_clean_rx_irq. Without this patch driver would free page that will be used by napi_build_skb.
--- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_txrx.c +2 -2
@@ -1393,7 +1393,7 @@ static struct sk_buff *iavf_build_skb(struct iavf_ring *rx_ring,#endif struct sk_buff *skb; -if (!rx_buffer) +if (!rx_buffer || !size)return NULL ;/* prefetch first cache line of first page */ 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)/* exit if we failed to retrieve a buffer */ if (!skb) { rx_ring->rx_stats.alloc_buff_failed++; -if (rx_buffer) +if (rx_buffer && size) rx_buffer->pagecnt_bias++;break ; }
Signature · 1 line
2.35.1
Tony Nguyen
maintainerPATCH 2/4 iavf: Fix set max MTU size with port VLAN and jumbo frames
In reply to Tony NguyenFrom: Michal Jaron <[email protected]>
After setting port VLAN and MTU to 9000 on VF with ice driver there was an iavf error
"PF returned error -5 (IAVF_ERR_PARAM) to our request 6".
During queue configuration, VF's max packet size was set to IAVF_MAX_RXBUFFER but on ice max frame size was smaller by VLAN_HLEN due to making some space for port VLAN as VF is not aware whether it's in a port VLAN. This mismatch in sizes caused ice to reject queue configuration with ERR_PARAM error. Proper max_mtu is sent from ice PF to VF with GET_VF_RESOURCES msg but VF does not look at this.
In iavf change max_frame from IAVF_MAX_RXBUFFER to max_mtu received from pf with GET_VF_RESOURCES msg to make vf's max_frame_size dependent from pf. Add check if received max_mtu is not in eligible range then set it to IAVF_MAX_RXBUFFER.
--- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +5 -2
@@ -269,11 +269,14 @@ int iavf_get_vf_vlan_v2_caps(struct iavf_adapter *adapter)void iavf_configure_queues (struct iavf_adapter *adapter) {struct virtchnl_vsi_queue_config_info *vqci; -struct virtchnl_queue_pair_info *vqpi; +int i, max_frame = adapter->vf_res->max_mtu;int pairs = adapter->num_active_queues; -int i, max_frame =IAVF_MAX_RXBUFFER ; +struct virtchnl_queue_pair_info *vqpi;size_t len; +if (max_frame >IAVF_MAX_RXBUFFER || !max_frame) + max_frame =IAVF_MAX_RXBUFFER ; +if (adapter->current_op !=VIRTCHNL_OP_UNKNOWN ) {/* bail because we already have a command pending */ dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",
Signature · 1 line
2.35.1
Tony Nguyen
maintainerPATCH 3/4 i40e: Fix VF set max MTU size
In reply to Tony NguyenFrom: Michal Jaron <[email protected]>
Max MTU sent to VF is set to 0 during memory allocation. It cause that max MTU on VF is changed to IAVF_MAX_RXBUFFER and does not depend on data from HW.
Set max_mtu field in virtchnl_vf_resource struct to inform VF in GET_VF_RESOURCES msg what size should be max frame.
--- .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +20 -0
@@ -2038,6 +2038,25 @@ static void i40e_del_qch(struct i40e_vf *vf) } } +/** +* i40e_vc_get_max_frame_size +* @vf: pointer to the VF +* +* Max frame size is determined based on the current port's max frame size and +* whether a port VLAN is configured on this VF. The VF is not aware whether +* it's in a port VLAN so the PF needs to account for this in max frame size +* checks and sending the max frame size to the VF. +**/ +static u16 i40e_vc_get_max_frame_size (struct i40e_vf *vf) +{ +u16 max_frame_size = vf->pf->hw.phy.link_info.max_frame_size; + +if (vf->port_vlan_id) + max_frame_size -=VLAN_HLEN ; + +return max_frame_size; +} +/** * i40e_vc_get_vf_resources_msg * @vf: pointer to the VF info
@@ -2139,6 +2158,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg) vfres->max_vectors = pf->hw.func_caps.num_msix_vectors_vf; vfres->rss_key_size =I40E_HKEY_ARRAY_SIZE ; vfres->rss_lut_size =I40E_VF_HLUT_ARRAY_SIZE ; + vfres->max_mtu =i40e_vc_get_max_frame_size (vf);if (vf->lan_vsi_idx) { vfres->vsi_res[0 ].vsi_id = vf->lan_vsi_id;
Signature · 1 line
2.35.1
Tony Nguyen
maintainerPATCH 4/4 i40e: Fix set max_tx_rate when it is lower than 1 Mbps
In reply to Tony NguyenFrom: Michal Jaron <[email protected]>
While converting max_tx_rate from bytes to Mbps, this value was set to 0, if the original value was lower than 125000 bytes (1 Mbps). This would cause no transmission rate limiting to occur. This happened due to lack of check of max_tx_rate against the 1 Mbps value for max_tx_rate and the following division by 125000. Fix this issue by adding a helper i40e_bw_bytes_to_mbits() which sets max_tx_rate to minimum usable value of 50 Mbps, if its value is less than 1 Mbps, otherwise do the required conversion by dividing by 125000.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 32 +++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +26 -6
@@ -5908,6 +5908,26 @@ static int i40e_get_link_speed(struct i40e_vsi *vsi) } } +/** +* i40e_bw_bytes_to_mbits - Convert max_tx_rate from bytes to mbits +* @vsi: Pointer to vsi structure +* @max_tx_rate: max TX rate in bytes to be converted into Mbits +* +* Helper function to convert units before send to set BW limit +**/ +static u64 i40e_bw_bytes_to_mbits (struct i40e_vsi *vsi,u64 max_tx_rate) +{ +if (max_tx_rate <I40E_BW_MBPS_DIVISOR ) { +dev_warn (&vsi->back->pdev->dev, +"Setting max tx rate to minimum usable value of 50Mbps.\n" ); + max_tx_rate =I40E_BW_CREDIT_DIVISOR ; + }else { +do_div (max_tx_rate,I40E_BW_MBPS_DIVISOR ); + } + +return max_tx_rate; +} +/** * i40e_set_bw_limit - setup BW limit for Tx traffic based on max_tx_rate * @vsi: VSI to be configured
@@ -5930,10 +5950,10 @@ int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate) max_tx_rate, seid);return -EINVAL ; } -if (max_tx_rate && max_tx_rate <50 ) { +if (max_tx_rate && max_tx_rate <I40E_BW_CREDIT_DIVISOR ) {dev_warn (&pf->pdev->dev,"Setting max tx rate to minimum usable value of 50Mbps.\n" ); - max_tx_rate =50 ; + max_tx_rate =I40E_BW_CREDIT_DIVISOR ; }/* 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)if (i40e_is_tc_mqprio_enabled (pf)) {if (vsi->mqprio_qopt.max_rate[0 ]) { -u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0 ]; +u64 max_tx_rate =i40e_bw_bytes_to_mbits (vsi, + vsi->mqprio_qopt.max_rate[0 ]); -do_div (max_tx_rate,I40E_BW_MBPS_DIVISOR ); ret =i40e_set_bw_limit (vsi, vsi->seid, max_tx_rate);if (!ret) {u64 credits = max_tx_rate;
@@ -10971,10 +10991,10 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) }if (vsi->mqprio_qopt.max_rate[0 ]) { -u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0 ]; +u64 max_tx_rate =i40e_bw_bytes_to_mbits (vsi, + vsi->mqprio_qopt.max_rate[0 ]);u64 credits =0 ; -do_div (max_tx_rate,I40E_BW_MBPS_DIVISOR ); ret =i40e_set_bw_limit (vsi, vsi->seid, max_tx_rate);if (ret) goto end_unlock;
Signature · 1 line
2.35.1
This series was applied to netdev/net.git (master) by Tony Nguyen <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Tony Nguyen <[email protected]>:
Quoted 9 lines · On Mon, 19 Sep 2022 15:34:24 -0700 you wrote:
This series contains updates to iavf and i40e drivers.
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.
[...]
Here is the summary with links:
- [net,1/4] iavf: Fix bad page state
https://git.kernel.org/netdev/net/c/66039eb9015e - [net,2/4] iavf: Fix set max MTU size with port VLAN and jumbo frames https://git.kernel.org/netdev/net/c/399c98c4dc50 - [net,3/4] i40e: Fix VF set max MTU size https://git.kernel.org/netdev/net/c/372539def282 - [net,4/4] i40e: Fix set max_tx_rate when it is lower than 1 Mbps https://git.kernel.org/netdev/net/c/198eb7e1b81d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html