Intel Wired LAN Driver Updates 2021-11-03
Subsystems (3)
Tony Nguyen
maintainerThis series contains updates to ice driver only.
Brett fixes issues with promiscuous mode settings not being properly enabled and removes setting of VF antispoof along with promiscuous mode. He also ensures that VF Tx queues are always disabled and resolves a race between virtchnl handling and VF related ndo ops.
Sylwester fixes an issue where a VF MAC could not be set to its primary MAC if the address is already present.
---
v2:
- Rebased
The following are changes since commit 92f62485b3715882cd397b0cbd80a96d179b86d6:
net: dsa: felix: fix broken VLAN-tagged PTP under VLAN-aware bridge
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 100GbE
Brett Creeley (4):
ice: Fix VF true promiscuous mode
ice: Remove toggling of antispoof for VF trusted promiscuous mode
ice: Fix not stopping Tx queues for VFs
ice: Fix race conditions between virtchnl handling and VF ndo ops
Sylwester Dziedziuch (1):
ice: Fix replacing VF hardware MAC to existing MAC filter
drivers/net/ethernet/intel/ice/ice.h | 5 +- drivers/net/ethernet/intel/ice/ice_base.c | 2 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 141 ++++++++++-------- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 5 + 4 files changed, 82 insertions(+), 71 deletions(-)
Signature · 1 line
2.31.1
Tony Nguyen
maintainerPATCH v2 1/5 ice: Fix VF true promiscuous mode
From: Brett Creeley <[email protected]>
When a VF requests promiscuous mode and it's trusted and true promiscuous mode is enabled the PF driver attempts to enable unicast and/or multicast promiscuous mode filters based on the request. This is fine, but there are a couple issues with the current code.
[1] The define to configure the unicast promiscuous mode mask also includes bits to configure the multicast promiscuous mode mask, which causes multicast to be set/cleared unintentionally.
[2] All 4 cases for enable/disable unicast/multicast mode are not handled in the promiscuous mode message handler, which causes unexpected results regarding the current promiscuous mode settings.
To fix [1] make sure any promiscuous mask defines include the correct bits for each of the promiscuous modes.
To fix [2] make sure that all 4 cases are handled since there are 2 bits (FLAG_VF_UNICAST_PROMISC and FLAG_VF_MULTICAST_PROMISC) that can be either set or cleared. Also, since either unicast and/or multicast promiscuous configuration can fail, introduce two separate error values to handle each of these cases.
--- drivers/net/ethernet/intel/ice/ice.h | 5 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 78 +++++++++---------- 2 files changed, 40 insertions(+), 43 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -4
@@ -165,13 +165,10 @@#define ice_for_each_chnl_tc (i) \ for ((i) = ICE_CHNL_START_TC; (i) < ICE_CHNL_MAX_TC; (i)++) -#define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_MCAST_TX | \ - ICE_PROMISC_UCAST_RX | ICE_PROMISC_MCAST_RX) +#define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_UCAST_RX)#define ICE_UCAST_VLAN_PROMISC_BITS (ICE_PROMISC_UCAST_TX | \ - ICE_PROMISC_MCAST_TX | \ ICE_PROMISC_UCAST_RX | \ - ICE_PROMISC_MCAST_RX | \ ICE_PROMISC_VLAN_TX | \ ICE_PROMISC_VLAN_RX)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +39 -39
97 lines not on this page · raw message
Signature · 1 line
2.31.1
Tony Nguyen
maintainerPATCH v2 2/5 ice: Remove toggling of antispoof for VF trusted promiscuous mode
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently when a trusted VF enables promiscuous mode spoofchk will be disabled. This is wrong and should only be modified from the ndo_set_vf_spoofchk callback. Fix this by removing the call to toggle spoofchk for trusted VFs.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +0 -18
@@ -3055,24 +3055,6 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) rm_promisc = !allmulti && !alluni;if (vsi->num_vlan || vf->port_vlan_info) { -struct ice_vsi *pf_vsi =ice_get_main_vsi (pf); -struct net_device *pf_netdev; - -if (!pf_vsi) { - v_ret =VIRTCHNL_STATUS_ERR_PARAM ; - goto error_param; - } - - pf_netdev = pf_vsi->netdev; - - ret =ice_set_vf_spoofchk (pf_netdev, vf->vf_id, rm_promisc); -if (ret) { -dev_err (dev,"Failed to update spoofchk to %s for VF %d VSI %d when setting promiscuous mode\n" , - rm_promisc ?"ON" :"OFF" , vf->vf_id, - vsi->vsi_num); - v_ret =VIRTCHNL_STATUS_ERR_PARAM ; - } -if (rm_promisc) ret =ice_cfg_vlan_pruning (vsi, true);else
Signature · 1 line
2.31.1
Tony Nguyen
maintainerPATCH v2 3/5 ice: Fix replacing VF hardware MAC to existing MAC filter
In reply to Tony NguyenFrom: Sylwester Dziedziuch <[email protected]>
VF was not able to change its hardware MAC address in case the new address was already present in the MAC filter list. Change the handling of VF add mac request to not return if requested MAC address is already present on the list and check if its hardware MAC needs to be updated in this case.
--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +9 -5
@@ -3806,6 +3806,7 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi,struct device *dev =ice_pf_to_dev (vf->pf);u8 *mac_addr = vc_ether_addr->addr;enum ice_status status; +int ret =0 ;/* device MAC already added */ if (ether_addr_equal (mac_addr, vf->dev_lan_addr.addr))
@@ -3818,20 +3819,23 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, status =ice_fltr_add_mac (vsi, mac_addr,ICE_FWD_TO_VSI );if (status ==ICE_ERR_ALREADY_EXISTS ) { -dev_err (dev,"MAC %pM already exists for VF %d\n" , mac_addr, +dev_dbg (dev,"MAC %pM already exists for VF %d\n" , mac_addr, vf->vf_id); -return -EEXIST ; +/* don't return since we might need to update +* the primary MAC in ice_vfhw_mac_add() below +*/ + ret = -EEXIST ; }else if (status) {dev_err (dev,"Failed to add MAC %pM for VF %d\n, error %s\n" , mac_addr, vf->vf_id,ice_stat_str (status));return -EIO ; + }else { + vf->num_mac++; }ice_vfhw_mac_add (vf, vc_ether_addr); - vf->num_mac++; - -return 0 ; +return ret; }/**
Signature · 1 line
2.31.1
Tony Nguyen
maintainerPATCH v2 4/5 ice: Fix not stopping Tx queues for VFs
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
When a VF is removed and/or reset its Tx queues need to be stopped from the PF. This is done by calling the ice_dis_vf_qs() function, which calls ice_vsi_stop_lan_tx_rings(). Currently ice_dis_vf_qs() is protected by the VF state bit ICE_VF_STATE_QS_ENA. Unfortunately, this is causing the Tx queues to not be disabled in some cases and when the VF tries to re-enable/reconfigure its Tx queues over virtchnl the op is failing. This is because a VF can be reset and/or removed before the ICE_VF_STATE_QS_ENA bit is set, but the Tx queues were already configured via ice_vsi_cfg_single_txq() in the VIRTCHNL_OP_CONFIG_VSI_QUEUES op. However, the ICE_VF_STATE_QS_ENA bit is set on a successful VIRTCHNL_OP_ENABLE_QUEUES, which will always happen after the VIRTCHNL_OP_CONFIG_VSI_QUEUES op.
This was causing the following error message when loading the ice driver, creating VFs, and modifying VF trust in an endless loop:
[35274.192484] ice 0000:88:00.0: Failed to set LAN Tx queue context, error: ICE_ERR_PARAM [35274.193074] ice 0000:88:00.0: VF 0 failed opcode 6, retval: -5 [35274.193640] iavf 0000:88:01.0: PF returned error -5 (IAVF_ERR_PARAM) to our request 6
Fix this by always calling ice_dis_vf_qs() and silencing the error message in ice_vsi_stop_tx_ring() since the calling code ignores the return anyway. Also, all other places that call ice_vsi_stop_tx_ring() catch the error, so this doesn't affect those flows since there was no change to the values the function returns.
Other solutions were considered (i.e. tracking which VF queues had been "started/configured" in VIRTCHNL_OP_CONFIG_VSI_QUEUES, but it seemed more complicated than it was worth. This solution also brings in the chance for other unexpected conditions due to invalid state bit checks. So, the proposed solution seemed like the best option since there is no harm in failing to stop Tx queues that were never started.
This issue can be seen using the following commands:
for i in {0..50}; do
rmmod ice
modprobe ice
sleep 1
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
ip link set ens785f1 vf 0 trust on
ip link set ens785f0 vf 0 trust on
sleep 2
echo 0 > /sys/class/net/ens785f0/device/sriov_numvfs echo 0 > /sys/class/net/ens785f1/device/sriov_numvfs sleep 1
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
ip link set ens785f1 vf 0 trust on
ip link set ens785f0 vf 0 trust on
done
--- drivers/net/ethernet/intel/ice/ice_base.c | 2 +- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +1 -1
@@ -962,7 +962,7 @@ ice_vsi_stop_tx_ring(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, }else if (status ==ICE_ERR_DOES_NOT_EXIST ) {dev_dbg (ice_pf_to_dev (vsi->back),"LAN Tx queues do not exist, nothing to disable\n" ); }else if (status) { -dev_err (ice_pf_to_dev (vsi->back),"Failed to disable LAN Tx queues, error: %s\n" , +dev_dbg (ice_pf_to_dev (vsi->back),"Failed to disable LAN Tx queues, error: %s\n" ,ice_stat_str (status));return -ENODEV ; }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +2 -4
@@ -638,8 +638,7 @@ void ice_free_vfs(struct ice_pf *pf)/* Avoid wait time by stopping all VFs at the same time */ ice_for_each_vf (pf, i) -if (test_bit (ICE_VF_STATE_QS_ENA , pf->vf[i].vf_states)) -ice_dis_vf_qs (&pf->vf[i]); +ice_dis_vf_qs (&pf->vf[i]); tmp = pf->num_alloc_vfs; pf->num_qps_per_vf =0 ;
@@ -1695,8 +1694,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) vsi =ice_get_vf_vsi (vf); -if (test_bit (ICE_VF_STATE_QS_ENA , vf->vf_states)) -ice_dis_vf_qs (vf); +ice_dis_vf_qs (vf);/* Call Disable LAN Tx queue AQ whether or not queues are * enabled. This is needed for successful completion of VFR.
Signature · 1 line
2.31.1
Tony Nguyen
maintainerPATCH v2 5/5 ice: Fix race conditions between virtchnl handling and VF ndo ops
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
The VF can be configured via the PF's ndo ops at the same time the PF is receiving/handling virtchnl messages. This has many issues, with one of them being the ndo op could be actively resetting a VF (i.e. resetting it to the default state and deleting/re-adding the VF's VSI) while a virtchnl message is being handled. The following error was seen because a VF ndo op was used to change a VF's trust setting while the VIRTCHNL_OP_CONFIG_VSI_QUEUES was ongoing:
[35274.192484] ice 0000:88:00.0: Failed to set LAN Tx queue context, error: ICE_ERR_PARAM [35274.193074] ice 0000:88:00.0: VF 0 failed opcode 6, retval: -5 [35274.193640] iavf 0000:88:01.0: PF returned error -5 (IAVF_ERR_PARAM) to our request 6
Fix this by making sure the virtchnl handling and VF ndo ops that trigger VF resets cannot run concurrently. This is done by adding a struct mutex cfg_lock to each VF structure. For VF ndo ops, the mutex will be locked around the critical operations and VFR. Since the ndo ops will trigger a VFR, the virtchnl thread will use mutex_trylock(). This is done because if any other thread (i.e. VF ndo op) has the mutex, then that means the current VF message being handled is no longer valid, so just ignore it.
This issue can be seen using the following commands:
for i in {0..50}; do
rmmod ice
modprobe ice
sleep 1
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
ip link set ens785f1 vf 0 trust on
ip link set ens785f0 vf 0 trust on
sleep 2
echo 0 > /sys/class/net/ens785f0/device/sriov_numvfs echo 0 > /sys/class/net/ens785f1/device/sriov_numvfs sleep 1
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
ip link set ens785f1 vf 0 trust on
ip link set ens785f0 vf 0 trust on
done
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 25 +++++++++++++++++++ .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 5 ++++ 2 files changed, 30 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +25 -0
@@ -650,6 +650,8 @@ void ice_free_vfs(struct ice_pf *pf)set_bit (ICE_VF_STATE_DIS , pf->vf[i].vf_states);ice_free_vf_res (&pf->vf[i]); } + +mutex_destroy (&pf->vf[i].cfg_lock); }if (ice_sriov_free_msix_res (pf))
@@ -1946,6 +1948,8 @@ static void ice_set_dflt_settings_vfs(struct ice_pf *pf)ice_vf_fdir_init (vf);ice_vc_set_dflt_vf_ops (&vf->vc_ops); + +mutex_init (&vf->cfg_lock); } }
@@ -4135,6 +4139,8 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,return 0 ; } +mutex_lock (&vf->cfg_lock); + vf->port_vlan_info = vlanprio;if (vf->port_vlan_info)
@@ -4144,6 +4150,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,dev_info (dev,"Clearing port VLAN on VF %d\n" , vf_id);ice_vc_reset_vf (vf); +mutex_unlock (&vf->cfg_lock);return 0 ; }
@@ -4683,6 +4690,15 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event)return ; } +/* VF is being configured in another context that triggers a VFR, so no +* need to process this message +*/ +if (!mutex_trylock (&vf->cfg_lock)) { +dev_info (dev,"VF %u is being configured in another context that will trigger a VFR, so there is no need to handle this message\n" , + vf->vf_id); +return ; + } +switch (v_opcode) {case VIRTCHNL_OP_VERSION : err = ops->get_ver_msg (vf, msg);
@@ -4771,6 +4787,8 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event)dev_info (dev,"PF failed to honor VF %d, opcode %d, error %d\n" , vf_id, v_opcode, err); } + +mutex_unlock (&vf->cfg_lock); }/**
@@ -4886,6 +4904,8 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)return -EINVAL ; } +mutex_lock (&vf->cfg_lock); +/* VF is notified of its new MAC via the PF's response to the * VIRTCHNL_OP_GET_VF_RESOURCES message after the VF has been reset */
@@ -4904,6 +4924,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) }ice_vc_reset_vf (vf); +mutex_unlock (&vf->cfg_lock);return 0 ; }
@@ -4938,11 +4959,15 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)if (trusted == vf->trusted)return 0 ; +mutex_lock (&vf->cfg_lock); + vf->trusted = trusted;ice_vc_reset_vf (vf);dev_info (ice_pf_to_dev (pf),"VF %u is now %strusted\n" , vf_id, trusted ?"" :"un" ); +mutex_unlock (&vf->cfg_lock); +return 0 ; }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +5 -0
@@ -100,6 +100,11 @@ struct ice_vc_vf_ops {struct ice_vf {struct ice_pf *pf; +/* Used during virtchnl message handling and NDO ops against the VF +* that will trigger a VFR +*/ +struct mutex cfg_lock; +u16 vf_id;/* VF ID in the PF space */ u16 lan_vsi_idx;/* index into PF struct */ u16 ctrl_vsi_idx;
Signature · 1 line
2.31.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 8 lines · On Wed, 3 Nov 2021 09:19:30 -0700 you wrote:
This series contains updates to ice driver only.
Brett fixes issues with promiscuous mode settings not being properly enabled and removes setting of VF antispoof along with promiscuous mode. He also ensures that VF Tx queues are always disabled and resolves a race between virtchnl handling and VF related ndo ops.
[...]
Here is the summary with links:
- [net,v2,1/5] ice: Fix VF true promiscuous mode
https://git.kernel.org/netdev/net/c/1a8c7778bcde - [net,v2,2/5] ice: Remove toggling of antispoof for VF trusted promiscuous mode https://git.kernel.org/netdev/net/c/0299faeaf8eb - [net,v2,3/5] ice: Fix replacing VF hardware MAC to existing MAC filter https://git.kernel.org/netdev/net/c/ce572a5b88d5 - [net,v2,4/5] ice: Fix not stopping Tx queues for VFs https://git.kernel.org/netdev/net/c/b385cca47363 - [net,v2,5/5] ice: Fix race conditions between virtchnl handling and VF ndo ops https://git.kernel.org/netdev/net/c/e6ba5273d4ed
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html