linux/drivers/net/ethernet/intel/ice
Brett Creeley e6ba5273d4 ice: Fix race conditions between virtchnl handling and VF ndo ops
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

Fixes: 7c710869d6 ("ice: Add handlers for VF netdevice operations")
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2021-11-03 08:16:32 -07:00
..
ice_adminq_cmd.h ice: Add support to print error on PHY FW load failure 2021-10-28 11:00:20 -07:00
ice_arfs.c ice: make use of ice_for_each_* macros 2021-10-15 07:39:03 -07:00
ice_arfs.h ice: use static inline for dummy functions 2021-06-07 08:59:01 -07:00
ice_base.c ice: Fix not stopping Tx queues for VFs 2021-11-03 08:16:08 -07:00
ice_base.h ice: split ice_ring onto Tx/Rx separate structs 2021-10-15 07:39:02 -07:00
ice_common.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-10-22 11:41:16 +01:00
ice_common.h ice: Add support for SMA control multiplexer 2021-10-14 07:37:30 -07:00
ice_controlq.c ice: add support for sideband messages 2021-06-11 07:38:00 -07:00
ice_controlq.h ice: add support for sideband messages 2021-06-11 07:38:00 -07:00
ice_dcb_lib.c ice: Add infrastructure for mqprio support via ndo_setup_tc 2021-10-20 15:57:54 -07:00
ice_dcb_lib.h ice: Add infrastructure for mqprio support via ndo_setup_tc 2021-10-20 15:57:54 -07:00
ice_dcb_nl.c ice: Add feature bitmap, helpers and a check for DSCP 2021-09-28 09:42:04 -07:00
ice_dcb_nl.h ice: use static inline for dummy functions 2021-06-07 08:59:01 -07:00
ice_dcb.c ice: Add DSCP support 2021-09-28 09:42:04 -07:00
ice_dcb.h ice: Add DSCP support 2021-09-28 09:42:04 -07:00
ice_devids.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-10-22 11:41:16 +01:00
ice_devlink.c ice: Nuild fix. 2021-10-22 14:24:44 +01:00
ice_devlink.h ice: Move devlink port to PF/VF struct 2021-10-07 10:41:41 -07:00
ice_eswitch.c ice: Clear synchronized addrs when adding VFs in switchdev mode 2021-10-29 10:56:24 -07:00
ice_eswitch.h ice: split ice_ring onto Tx/Rx separate structs 2021-10-15 07:39:02 -07:00
ice_ethtool_fdir.c ice: use devm_kcalloc() instead of devm_kzalloc() 2021-10-19 10:53:28 -07:00
ice_ethtool.c ice: Hide bus-info in ethtool for PRs in switchdev mode 2021-10-29 11:43:15 -07:00
ice_fdir.c ice: Fix macro name for IPv4 fragment flag 2021-09-28 09:42:04 -07:00
ice_fdir.h ice: Fix macro name for IPv4 fragment flag 2021-09-28 09:42:04 -07:00
ice_flex_pipe.c ice: support for GRE in eswitch 2021-10-28 11:00:20 -07:00
ice_flex_pipe.h ice: create advanced switch recipe 2021-10-11 08:38:27 -07:00
ice_flex_type.h ice: support for GRE in eswitch 2021-10-28 11:00:20 -07:00
ice_flow.c ice: Support RSS configure removal for AVF 2021-04-22 09:26:22 -07:00
ice_flow.h ice: Support RSS configure removal for AVF 2021-04-22 09:26:22 -07:00
ice_fltr.c ice: Manage act flags for switchdev offloads 2021-10-19 10:53:26 -07:00
ice_fltr.h ice: Manage act flags for switchdev offloads 2021-10-19 10:53:26 -07:00
ice_fw_update.c ice: add error message when pldmfw_flash_image fails 2021-06-07 08:59:01 -07:00
ice_fw_update.h ice: add support for flash update overwrite mask 2020-09-25 17:20:57 -07:00
ice_hw_autogen.h ice: fix software generating extra interrupts 2021-10-19 10:45:17 -07:00
ice_idc_int.h ice: Implement iidc operations 2021-05-28 20:11:13 -07:00
ice_idc.c ice: Correctly deal with PFs that do not support RDMA 2021-09-10 09:58:55 +01:00
ice_lag.c ice: Respond to a NETDEV_UNREGISTER event for LAG 2021-10-25 13:44:37 -07:00
ice_lag.h ice: Add initial support framework for LAG 2021-02-08 16:27:01 -08:00
ice_lan_tx_rx.h ice: switchdev slow path 2021-10-07 10:41:42 -07:00
ice_lib.c ice: Remove boolean vlan_promisc flag from function 2021-10-29 10:48:16 -07:00
ice_lib.h ice: Remove boolean vlan_promisc flag from function 2021-10-29 10:48:16 -07:00
ice_main.c ice: Remove boolean vlan_promisc flag from function 2021-10-29 10:48:16 -07:00
ice_nvm.c ice: suppress false cppcheck issues 2021-04-14 17:12:17 -07:00
ice_nvm.h ice: display stored UNDI firmware version via devlink info 2021-02-05 11:44:16 -08:00
ice_osdep.h
ice_protocol_type.h ice: support for GRE in eswitch 2021-10-28 11:00:20 -07:00
ice_ptp_hw.c ice: Add support for SMA control multiplexer 2021-10-14 07:37:30 -07:00
ice_ptp_hw.h ice: Add support for SMA control multiplexer 2021-10-14 07:37:30 -07:00
ice_ptp.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-10-28 10:43:58 -07:00
ice_ptp.h ice: split ice_ring onto Tx/Rx separate structs 2021-10-15 07:39:02 -07:00
ice_repr.c ice: Add support for changing MTU on PR in switchdev mode 2021-10-28 11:00:20 -07:00
ice_repr.h ice: rebuild switchdev when resetting all VFs 2021-10-07 10:41:42 -07:00
ice_sbq_cmd.h ice: add support for sideband messages 2021-06-11 07:38:00 -07:00
ice_sched.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-10-22 11:41:16 +01:00
ice_sched.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-10-22 11:41:16 +01:00
ice_sriov.c ice: warn about potentially malicious VFs 2021-04-22 09:26:22 -07:00
ice_sriov.h ice: warn about potentially malicious VFs 2021-04-22 09:26:22 -07:00
ice_status.h ice: display stored netlist versions via devlink info 2021-02-05 11:43:37 -08:00
ice_switch.c ice: fix error return code in ice_get_recp_frm_fw() 2021-10-28 11:00:21 -07:00
ice_switch.h ice: low level support for tunnels 2021-10-28 11:00:20 -07:00
ice_tc_lib.c ice: support for GRE in eswitch 2021-10-28 11:00:20 -07:00
ice_tc_lib.h ice: VXLAN and Geneve TC support 2021-10-28 11:00:18 -07:00
ice_trace.h ice: split ice_ring onto Tx/Rx separate structs 2021-10-15 07:39:02 -07:00
ice_txrx_lib.c ice: introduce XDP_TX fallback path 2021-10-15 07:39:03 -07:00
ice_txrx_lib.h ice: propagate xdp_ring onto rx_ring 2021-10-15 07:39:03 -07:00
ice_txrx.c ice: use devm_kcalloc() instead of devm_kzalloc() 2021-10-19 10:53:28 -07:00
ice_txrx.h ice: Add infrastructure for mqprio support via ndo_setup_tc 2021-10-20 15:57:54 -07:00
ice_type.h ice: Add infrastructure for mqprio support via ndo_setup_tc 2021-10-20 15:57:54 -07:00
ice_virtchnl_allowlist.c ice: Enable RSS configure for AVF 2021-04-22 09:26:22 -07:00
ice_virtchnl_allowlist.h ice: Allow ignoring opcodes on specific VF 2021-04-22 09:26:22 -07:00
ice_virtchnl_fdir.c ice: Drop leading underscores in enum ice_pf_state 2021-04-14 17:00:05 -07:00
ice_virtchnl_fdir.h ice: Check FDIR program status for AVF 2021-03-22 11:32:12 -07:00
ice_virtchnl_pf.c ice: Fix race conditions between virtchnl handling and VF ndo ops 2021-11-03 08:16:32 -07:00
ice_virtchnl_pf.h ice: Fix race conditions between virtchnl handling and VF ndo ops 2021-11-03 08:16:32 -07:00
ice_xsk.c intel: Simplify bool conversion 2021-10-29 09:42:33 -07:00
ice_xsk.h ice: split ice_ring onto Tx/Rx separate structs 2021-10-15 07:39:02 -07:00
ice.h ice: Fix VF true promiscuous mode 2021-11-03 08:15:27 -07:00
Makefile ice: ndo_setup_tc implementation for PF 2021-10-11 09:03:04 -07:00