Intel Wired LAN Driver Updates 2024-09-09 (ice, igb)
Subsystems (4)
Tony Nguyen
maintainerThis series contains updates to ice and igb drivers.
Martyna moves LLDP rule removal to the proper uninitialization function for ice.
Jake corrects accounting logic for FWD_TO_VSI_LIST switch filters on ice.
Przemek removes incorrect, explicit calls to pci_disable_device() for ice.
Michal Schmidt stops incorrect use of VSI list for VLAN use on ice.
Sriram Yagnaraman adjusts igb_xdp_ring_update_tail() to be called under Tx lock on igb.
The following are changes since commit b3c9e65eb227269ed72a115ba22f4f51b4e62b4d:
net: hsr: remove seqnr_lock
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 100GbE
Jacob Keller (1):
ice: fix accounting for filters shared by multiple VSIs
Martyna Szapar-Mudlaw (1):
ice: Fix lldp packets dropping after changing the number of channels
Michal Schmidt (1):
ice: fix VSI lists confusion when adding VLANs
Przemek Kitszel (1):
ice: stop calling pci_disable_device() as we use pcim
Sriram Yagnaraman (1):
igb: Always call igb_xdp_ring_update_tail() under Tx lock
drivers/net/ethernet/intel/ice/ice_lib.c | 15 ++++++++------- drivers/net/ethernet/intel/ice/ice_main.c | 2 -- drivers/net/ethernet/intel/ice/ice_switch.c | 4 ++-- drivers/net/ethernet/intel/igb/igb_main.c | 17 +++++++++++++---- 4 files changed, 23 insertions(+), 15 deletions(-)
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 1/5 ice: Fix lldp packets dropping after changing the number of channels
From: Martyna Szapar-Mudlaw <[email protected]>
After vsi setup refactor commit 6624e780a577 ("ice: split ice_vsi_setup into smaller functions") ice_cfg_sw_lldp function which removes rx rule directing LLDP packets to vsi is moved from ice_vsi_release to ice_vsi_decfg function. ice_vsi_decfg is used in more cases than just in vsi_release resulting in unnecessary removal of rx lldp packets handling switch rule. This leads to lldp packets being dropped after a change number of channels via ethtool.
This patch moves ice_cfg_sw_lldp function that removes rx lldp sw rule back to ice_vsi_release function.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +8 -7
@@ -2413,13 +2413,6 @@ void ice_vsi_decfg(struct ice_vsi *vsi)struct ice_pf *pf = vsi->back;int err; -/* The Rx rule will only exist to remove if the LLDP FW -* engine is currently stopped -*/ -if (!ice_is_safe_mode (pf) && vsi->type ==ICE_VSI_PF && - !test_bit (ICE_FLAG_FW_LLDP_AGENT , pf->flags)) -ice_cfg_sw_lldp (vsi, false, false); -ice_rm_vsi_lan_cfg (vsi->port_info, vsi->idx); err =ice_rm_vsi_rdma_cfg (vsi->port_info, vsi->idx);if (err)
@@ -2764,6 +2757,14 @@ int ice_vsi_release(struct ice_vsi *vsi)ice_rss_clean (vsi);ice_vsi_close (vsi); + +/* The Rx rule will only exist to remove if the LLDP FW +* engine is currently stopped +*/ +if (!ice_is_safe_mode (pf) && vsi->type ==ICE_VSI_PF && + !test_bit (ICE_FLAG_FW_LLDP_AGENT , pf->flags)) +ice_cfg_sw_lldp (vsi, false, false); +ice_vsi_decfg (vsi);/* retain SW VSI data structure since it is needed to unregister and
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 2/5 ice: fix accounting for filters shared by multiple VSIs
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
When adding a switch filter (such as a MAC or VLAN filter), it is expected that the driver will detect the case where the filter already exists, and return -EEXIST. This is used by calling code such as ice_vc_add_mac_addr, and ice_vsi_add_vlan to avoid incrementing the accounting fields such as vsi->num_vlan or vf->num_mac.
This logic works correctly for the case where only a single VSI has added a given switch filter.
When a second VSI adds the same switch filter, the driver converts the existing filter from an ICE_FWD_TO_VSI filter into an ICE_FWD_TO_VSI_LIST filter. This saves switch resources, by ensuring that multiple VSIs can re-use the same filter.
The ice_add_update_vsi_list() function is responsible for doing this conversion. When first converting a filter from the FWD_TO_VSI into FWD_TO_VSI_LIST, it checks if the VSI being added is the same as the existing rule's VSI. In such a case it returns -EEXIST.
However, when the switch rule has already been converted to a FWD_TO_VSI_LIST, the logic is different. Adding a new VSI in this case just requires extending the VSI list entry. The logic for checking if the rule already exists in this case returns 0 instead of -EEXIST.
This breaks the accounting logic mentioned above, so the counters for how many MAC and VLAN filters exist for a given VF or VSI no longer accurately reflect the actual count. This breaks other code which relies on these counts.
In typical usage this primarily affects such filters generally shared by multiple VSIs such as VLAN 0, or broadcast and multicast MAC addresses.
Fix this by correctly reporting -EEXIST in the case of adding the same VSI to a switch rule already converted to ICE_FWD_TO_VSI_LIST.
--- drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_switch.c +1 -1
@@ -3194,7 +3194,7 @@ ice_add_update_vsi_list(struct ice_hw *hw,/* A rule already exists with the new VSI being added */ if (test_bit (vsi_handle, m_entry->vsi_list_info->vsi_map)) -return 0 ; +return -EEXIST ;/* Update the previously created VSI list set with * the new VSI ID passed in
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 3/5 ice: stop calling pci_disable_device() as we use pcim
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Our driver uses devres to manage resources, in particular we call pcim_enable_device(), what also means we express the intent to get automatic pci_disable_device() call at driver removal. Manual calls to pci_disable_device() misuse the API.
Recent commit (see "Fixes" tag) has changed the removal action from conditional (silent ignore of double call to pci_disable_device()) to unconditional, but able to catch unwanted redundant calls; see cited "Fixes" commit for details.
Since that, unloading the driver yields following warn+splat:
[70633.628490] ice 0000:af:00.7: disabling already-disabled device [70633.628512] WARNING: CPU: 52 PID: 33890 at drivers/pci/pci.c:2250 pci_disable_device+0xf4/0x100 ... [70633.628744] ? pci_disable_device+0xf4/0x100 [70633.628752] release_nodes+0x4a/0x70 [70633.628759] devres_release_all+0x8b/0xc0 [70633.628768] device_unbind_cleanup+0xe/0x70 [70633.628774] device_release_driver_internal+0x208/0x250 [70633.628781] driver_detach+0x47/0x90 [70633.628786] bus_remove_driver+0x80/0x100 [70633.628791] pci_unregister_driver+0x2a/0xb0 [70633.628799] ice_module_exit+0x11/0x3a [ice]
Note that this is the only Intel ethernet driver that needs such fix.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +0 -2
@@ -5363,7 +5363,6 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)ice_deinit (pf); err_init:ice_adapter_put (pdev); -pci_disable_device (pdev);return err; }
@@ -5470,7 +5469,6 @@ static void ice_remove(struct pci_dev *pdev)ice_set_wake (pf);ice_adapter_put (pdev); -pci_disable_device (pdev); }/**
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 4/5 ice: fix VSI lists confusion when adding VLANs
In reply to Tony NguyenFrom: Michal Schmidt <[email protected]>
The description of function ice_find_vsi_list_entry says:
Search VSI list map with VSI count 1
However, since the blamed commit (see Fixes below), the function no longer checks vsi_count. This causes a problem in ice_add_vlan_internal, where the decision to share VSI lists between filter rules relies on the vsi_count of the found existing VSI list being 1.
The reproducing steps:
1. Have a PF and two VFs.
There will be a filter rule for VLAN 0, referring to a VSI list containing VSIs: 0 (PF), 2 (VF#0), 3 (VF#1).
2. Add VLAN 1234 to VF#0.
ice will make the wrong decision to share the VSI list with the new rule. The wrong behavior may not be immediately apparent, but it can be observed with debug prints.
3. Add VLAN 1234 to VF#1.
ice will unshare the VSI list for the VLAN 1234 rule. Due to the earlier bad decision, the newly created VSI list will contain VSIs 0 (PF) and 3 (VF#1), instead of expected 2 (VF#0) and 3 (VF#1).
4. Try pinging a network peer over the VLAN interface on VF#0. This fails.
Reproducer script at:
https://gitlab.com/mschmidt2/repro/-/blob/master/RHEL-46814/test-vlan-vsi-list-confusion.sh
Commented debug trace:
https://gitlab.com/mschmidt2/repro/-/blob/master/RHEL-46814/ice-vlan-vsi-lists-debug.txt
Patch adding the debug prints:
https://gitlab.com/mschmidt2/linux/-/commit/f8a8814623944a45091a77c6094c40bfe726bfdb
(Unsafe, by the way. Lacks rule_lock when dumping in ice_remove_vlan.)
Michal Swiatkowski added to the explanation that the bug is caused by reusing a VSI list created for VLAN 0. All created VFs' VSIs are added to VLAN 0 filter. When a non-zero VLAN is created on a VF which is already in VLAN 0 (normal case), the VSI list from VLAN 0 is reused. It leads to a problem because all VFs (VSIs to be specific) that are subscribed to VLAN 0 will now receive a new VLAN tag traffic. This is one bug, another is the bug described above. Removing filters from one VF will remove VLAN filter from the previous VF. It happens a VF is reset. Example:
- creation of 3 VFs
- we have VSI list (used for VLAN 0) [0 (pf), 2 (vf1), 3 (vf2), 4 (vf3)]
- we are adding VLAN 100 on VF1, we are reusing the previous list because 2 is there
- VLAN traffic works fine, but VLAN 100 tagged traffic can be received on all VSIs from the list (for example broadcast or unicast)
- trust is turning on VF2, VF2 is resetting, all filters from VF2 are removed; the VLAN 100 filter is also removed because 3 is on the list
- VLAN traffic to VF1 isn't working anymore, there is a need to recreate VLAN interface to readd VLAN filter
One thing I'm not certain about is the implications for the LAG feature, which is another caller of ice_find_vsi_list_entry. I don't have a LAG-capable card at hand to test.
--- drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_switch.c +1 -1
@@ -3264,7 +3264,7 @@ ice_find_vsi_list_entry(struct ice_hw *hw, u8 recp_id, u16 vsi_handle, list_head = &sw->recp_list[recp_id].filt_rules;list_for_each_entry (list_itr, list_head, list_entry) { -if (list_itr->vsi_list_info) { +if (list_itr->vsi_count ==1 && list_itr->vsi_list_info) { map_info = list_itr->vsi_list_info;if (test_bit (vsi_handle, map_info->vsi_map)) { *vsi_list_id = map_info->vsi_list_id;
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 5/5 igb: Always call igb_xdp_ring_update_tail() under Tx lock
In reply to Tony NguyenFrom: Sriram Yagnaraman <[email protected]>
Always call igb_xdp_ring_update_tail() under __netif_tx_lock, add a comment and lockdep assert to indicate that. This is needed to share the same TX ring between XDP, XSK and slow paths. Furthermore, the current XDP implementation is racy on tail updates.
--- drivers/net/ethernet/intel/igb/igb_main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +13 -4
@@ -33,6 +33,7 @@#include <linux/bpf_trace.h> #include <linux/pm_runtime.h> #include <linux/etherdevice.h> +#include <linux/lockdep.h> #ifdef CONFIG_IGB_DCA #include <linux/dca.h> #endif
@@ -2914,8 +2915,11 @@ static int igb_xdp(struct net_device *dev, struct netdev_bpf *xdp) } } +/* This function assumes __netif_tx_lock is held by the caller. */ static void igb_xdp_ring_update_tail (struct igb_ring *ring) { +lockdep_assert_held (&txring_txq (ring)->_xmit_lock); +/* Force memory writes to complete before letting h/w know there * are new descriptors to fetch. */
@@ -3000,11 +3004,11 @@ static int igb_xdp_xmit(struct net_device *dev, int n, nxmit++; } -__netif_tx_unlock (nq); -if (unlikely (flags &XDP_XMIT_FLUSH ))igb_xdp_ring_update_tail (tx_ring); +__netif_tx_unlock (nq); +return nxmit; }
@@ -8864,12 +8868,14 @@ static void igb_put_rx_buffer(struct igb_ring *rx_ring,static int igb_clean_rx_irq (struct igb_q_vector *q_vector,const int budget) { +unsigned int total_bytes =0 , total_packets =0 ;struct igb_adapter *adapter = q_vector->adapter;struct igb_ring *rx_ring = q_vector->rx.ring; -struct sk_buff *skb = rx_ring->skb; -unsigned int total_bytes =0 , total_packets =0 ;u16 cleaned_count =igb_desc_unused (rx_ring); +struct sk_buff *skb = rx_ring->skb; +int cpu =smp_processor_id ();unsigned int xdp_xmit =0 ; +struct netdev_queue *nq;struct xdp_buff xdp;u32 frame_sz =0 ;int rx_buf_pgcnt;
@@ -8997,7 +9003,10 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget)if (xdp_xmit &IGB_XDP_TX ) {struct igb_ring *tx_ring =igb_xdp_tx_queue_mapping (adapter); + nq =txring_txq (tx_ring); +__netif_tx_lock (nq, cpu);igb_xdp_ring_update_tail (tx_ring); +__netif_tx_unlock (nq); }u64_stats_update_begin (&rx_ring->rx_syncp);
Signature · 1 line
2.42.0
This series was applied to netdev/net.git (main) by Tony Nguyen <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Tony Nguyen <[email protected]>:
Quoted 9 lines · On Mon, 9 Sep 2024 13:38:36 -0700 you wrote:
This series contains updates to ice and igb drivers.
Martyna moves LLDP rule removal to the proper uninitialization function for ice.
Jake corrects accounting logic for
FWD_TO_VSI_LISTswitch filters on ice.[...]
Here is the summary with links:
- [net,1/5] ice: Fix lldp packets dropping after changing the number of channels
https://git.kernel.org/netdev/net/c/9debb703e149 - [net,2/5] ice: fix accounting for filters shared by multiple VSIs https://git.kernel.org/netdev/net/c/e843cf7b34fe - [net,3/5] ice: stop calling pci_disable_device() as we use pcim https://git.kernel.org/netdev/net/c/e6501fc38a75 - [net,4/5] ice: fix VSI lists confusion when adding VLANs https://git.kernel.org/netdev/net/c/d2940002b0aa - [net,5/5] igb: Always call igb_xdp_ring_update_tail() under Tx lock https://git.kernel.org/netdev/net/c/27717f8b17c0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html