intel: fix routines that disable queue pairs
Subsystems (3)
cover intel: fix routines that disable queue pairs
Hi,
It started out as an issue on ixgbe reported by Pavel [0] which first patch is supposed to fix, but apparently i40e and ice have queue pair disabling flow a bit out of order, so I addressed them as well. More info is included in commit messages.
FWIW we are talking here about AF_XDP ZC when xsk_pool is sent down to driver. Typically these routines are executed when there is already XDP program running on interface.
Thanks!
[0]: https://lore.kernel.org/netdev/CAJEV1ijxNyPTwASJER1bcZzS9nMoZJqfR86nu_3jFFVXzZQ4NA@mail.gmail.com/
Maciej Fijalkowski (3):
ixgbe: {dis,en}able irqs in ixgbe_txrx_ring_{dis,en}able
i40e: disable NAPI right after disabling irqs when handling xsk_pool
ice: reorder disabling IRQ and NAPI in ice_qp_dis
drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 9 +-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 56 ++++++++++++++++--- 3 files changed, 55 insertions(+), 12 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 ixgbe: {dis,en}able irqs in ixgbe_txrx_ring_{dis,en}able
Currently routines that are supposed to toggle state of ring pair do not take care of associated interrupt with queue vector that these rings belong to. This causes funky issues such as dead interface due to irq misconfiguration, as per Pavel's report from Closes: tag.
Add a function responsible for disabling single IRQ in EIMC register and call this as a very first thing when disabling ring pair during xsk_pool setup. For enable let's reuse ixgbe_irq_enable_queues(). Besides this, disable/enable NAPI as first/last thing when dealing with closing or opening ring pair that xsk_pool is being configured on.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 56 ++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +49 -7
@@ -2939,8 +2939,8 @@ static void ixgbe_check_lsc(struct ixgbe_adapter *adapter)static inline void ixgbe_irq_enable_queues (struct ixgbe_adapter *adapter,u64 qmask) { -u32 mask;struct ixgbe_hw *hw = &adapter->hw; +u32 mask;switch (hw->mac.type) {case ixgbe_mac_82598EB:
@@ -10524,6 +10524,44 @@ static void ixgbe_reset_rxr_stats(struct ixgbe_ring *rx_ring)memset (&rx_ring->rx_stats,0 ,sizeof (rx_ring->rx_stats)); } +/** +* ixgbe_irq_disable_single - Disable single IRQ vector +* @adapter: adapter structure +* @ring: ring index +**/ +static void ixgbe_irq_disable_single (struct ixgbe_adapter *adapter,u32 ring) +{ +struct ixgbe_hw *hw = &adapter->hw; +u64 qmask =BIT_ULL (ring); +u32 mask; + +switch (adapter->hw.mac.type) { +case ixgbe_mac_82598EB: + mask = qmask &IXGBE_EIMC_RTX_QUEUE ; +IXGBE_WRITE_REG (&adapter->hw,IXGBE_EIMC , mask); +break ; +case ixgbe_mac_82599EB: +case ixgbe_mac_X540: +case ixgbe_mac_X550: +case ixgbe_mac_X550EM_x: +case ixgbe_mac_x550em_a: + mask = (qmask &0xFFFFFFFF ); +if (mask) +IXGBE_WRITE_REG (hw,IXGBE_EIMS_EX (0 ), mask); + mask = (qmask >>32 ); +if (mask) +IXGBE_WRITE_REG (hw,IXGBE_EIMS_EX (1 ), mask); +break ; +default : +break ; + } +IXGBE_WRITE_FLUSH (&adapter->hw); +if (adapter->flags &IXGBE_FLAG_MSIX_ENABLED ) +synchronize_irq (adapter->msix_entries[ring].vector); +else +synchronize_irq (adapter->pdev->irq); +} +/** * ixgbe_txrx_ring_disable - Disable Rx/Tx/XDP Tx rings * @adapter: adapter structure
@@ -10540,6 +10578,11 @@ void ixgbe_txrx_ring_disable(struct ixgbe_adapter *adapter, int ring) tx_ring = adapter->tx_ring[ring]; xdp_ring = adapter->xdp_ring[ring]; +ixgbe_irq_disable_single (adapter, ring); + +/* Rx/Tx/XDP Tx share the same napi context. */ +napi_disable (&rx_ring->q_vector->napi); +ixgbe_disable_txr (adapter, tx_ring);if (xdp_ring)ixgbe_disable_txr (adapter, xdp_ring);
@@ -10548,9 +10591,6 @@ void ixgbe_txrx_ring_disable(struct ixgbe_adapter *adapter, int ring)if (xdp_ring)synchronize_rcu (); -/* Rx/Tx/XDP Tx share the same napi context. */ -napi_disable (&rx_ring->q_vector->napi); -ixgbe_clean_tx_ring (tx_ring);if (xdp_ring)ixgbe_clean_tx_ring (xdp_ring);
@@ -10578,9 +10618,6 @@ void ixgbe_txrx_ring_enable(struct ixgbe_adapter *adapter, int ring) tx_ring = adapter->tx_ring[ring]; xdp_ring = adapter->xdp_ring[ring]; -/* Rx/Tx/XDP Tx share the same napi context. */ -napi_enable (&rx_ring->q_vector->napi); -ixgbe_configure_tx_ring (adapter, tx_ring);if (xdp_ring)ixgbe_configure_tx_ring (adapter, xdp_ring);
@@ -10589,6 +10626,11 @@ void ixgbe_txrx_ring_enable(struct ixgbe_adapter *adapter, int ring)clear_bit (__IXGBE_TX_DISABLED, &tx_ring->state);if (xdp_ring)clear_bit (__IXGBE_TX_DISABLED, &xdp_ring->state); + +/* Rx/Tx/XDP Tx share the same napi context. */ +napi_enable (&rx_ring->q_vector->napi); +ixgbe_irq_enable_queues (adapter,BIT_ULL (ring)); +IXGBE_WRITE_FLUSH (&adapter->hw); }/**
Signature · 1 line
2.34.1
RE: [Intel-wired-lan] [PATCH iwl-net 1/3] ixgbe: {dis, en}able irqs in ixgbe_txrx_ring_{dis, en}able
Quoted 26 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Fijalkowski, Maciej
Sent: Wednesday, February 21, 2024 3:16 AM
To: [email protected]
Cc: [email protected]; Fijalkowski, Maciej <[email protected]>; Nguyen, Anthony L <[email protected]>; Pavel Vazharov <[email protected]>; Karlsson, Magnus <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net 1/3] ixgbe: {dis, en}able irqs in ixgbe_txrx_ring_{dis, en}ableCurrently routines that are supposed to toggle state of ring pair do not take care of associated interrupt with queue vector that these rings belong to. This causes funky issues such as dead interface due to irq misconfiguration, as per Pavel's report from Closes: tag.
Add a function responsible for disabling single IRQ in EIMC register and call this as a very first thing when disabling ring pair during
xsk_poolsetup. For enable let's reuseixgbe_irq_enable_queues(). Besides this, disable/enable NAPI as first/last thing when dealing with closing or opening ring pair thatxsk_poolis being configured on.Reported-by Pavel Vazharov <[email protected]>
Quoted 9 lines
Closes:
https://lore.kernel.org/netdev/CAJEV1ijxNyPTwASJER1bcZzS9nMoZJqfR86nu
[email protected]/Fixes 024aa5800f32 ("ixgbe: added Rx/Tx ring disable/enable functions")Signed-off-by Maciej Fijalkowski <[email protected]>---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c| 56 ++++++++++++++++---1 file changed, 49 insertions(+), 7 deletions(-)
PATCH 2/3 i40e: disable NAPI right after disabling irqs when handling xsk_pool
In reply to Maciej FijalkowskiDisable NAPI before shutting down queues that this particular NAPI contains so that the order of actions in i40e_queue_pair_disable() mirrors what we do in i40e_queue_pair_enable().
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -13564,9 +13564,9 @@ int i40e_queue_pair_disable(struct i40e_vsi *vsi, int queue_pair)return err;i40e_queue_pair_disable_irq (vsi, queue_pair); +i40e_queue_pair_toggle_napi (vsi, queue_pair, false/* off */ ); err =i40e_queue_pair_toggle_rings (vsi, queue_pair, false/* off */ );i40e_clean_rx_ring (vsi->rx_rings[queue_pair]); -i40e_queue_pair_toggle_napi (vsi, queue_pair, false/* off */ );i40e_queue_pair_clean_rings (vsi, queue_pair);i40e_queue_pair_reset_stats (vsi, queue_pair);
Signature · 1 line
2.34.1
RE: [Intel-wired-lan] [PATCH iwl-net 2/3] i40e: disable NAPI right after disabling irqs when handling xsk_pool
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Fijalkowski, Maciej
Sent: Wednesday, February 21, 2024 3:16 AM
To: [email protected]
Cc: [email protected]; Fijalkowski, Maciej <[email protected]>; Nguyen, Anthony L <[email protected]>; Karlsson, Magnus <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net 2/3] i40e: disable NAPI right after disabling irqs when handlingxsk_poolDisable NAPI before shutting down queues that this particular NAPI contains so that the order of actions in
i40e_queue_pair_disable()mirrors what we do ini40e_queue_pair_enable().
Quoted 6 lines
Fixes 123cecd427b6 ("i40e: added queue pair disable/enable functions")Signed-off-by Maciej Fijalkowski <[email protected]>---
drivers/net/ethernet/intel/i40e/i40e_main.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 3/3 ice: reorder disabling IRQ and NAPI in ice_qp_dis
In reply to Maciej Fijalkowskiice_qp_dis() currently does things in very mixed way. Tx is stopped before disabling IRQ on related queue vector, then it takes care of disabling Rx and finally NAPI is disabled.
Let us start with disabling IRQs in the first place followed by turning off NAPI. Then it is safe to handle queues.
One subtle change on top of that is that even though ice_qp_ena() looks more sane, clear ICE_CFG_BUSY as the last thing there.
--- drivers/net/ethernet/intel/ice/ice_xsk.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_xsk.c +5 -4
@@ -179,6 +179,10 @@ static int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx)return -EBUSY ;usleep_range (1000 ,2000 ); } + +ice_qvec_dis_irq (vsi, rx_ring, q_vector); +ice_qvec_toggle_napi (vsi, q_vector, false); +netif_tx_stop_queue (netdev_get_tx_queue (vsi->netdev, q_idx));ice_fill_txq_meta (vsi, tx_ring, &txq_meta);
@@ -195,13 +199,10 @@ static int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx)if (err)return err; } -ice_qvec_dis_irq (vsi, rx_ring, q_vector); - err =ice_vsi_ctrl_one_rx_ring (vsi, false, q_idx, true);if (err)return err; -ice_qvec_toggle_napi (vsi, q_vector, false);ice_qp_clean_rings (vsi, q_idx);ice_qp_reset_stats (vsi, q_idx);
@@ -259,11 +260,11 @@ static int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx)if (err)return err; -clear_bit (ICE_CFG_BUSY , vsi->state);ice_qvec_toggle_napi (vsi, q_vector, true);ice_qvec_ena_irq (vsi, q_vector);netif_tx_start_queue (netdev_get_tx_queue (vsi->netdev, q_idx)); +clear_bit (ICE_CFG_BUSY , vsi->state);return 0 ; }
Signature · 1 line
2.34.1
RE: [Intel-wired-lan] [PATCH iwl-net 3/3] ice: reorder disabling IRQ and NAPI in ice_qp_dis
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Fijalkowski, Maciej
Sent: Wednesday, February 21, 2024 3:16 AM
To: [email protected]
Cc: [email protected]; Fijalkowski, Maciej <[email protected]>; Nguyen, Anthony L <[email protected]>; Karlsson, Magnus <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net 3/3] ice: reorder disabling IRQ and NAPI inice_qp_dis
ice_qp_dis()currently does things in very mixed way. Tx is stopped before disabling IRQ on related queue vector, then it takes care of disabling Rx and finally NAPI is disabled.Let us start with disabling IRQs in the first place followed by turning off NAPI. Then it is safe to handle queues.
Quoted 9 lines
One subtle change on top of that is that even though
ice_qp_ena()looks more sane, clearICE_CFG_BUSYas the last thing there.Fixes 2d4238f55697 ("ice: Add support for AF_XDP")Signed-off-by Maciej Fijalkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_xsk.c| 9 +++++----1 file changed, 5 insertions(+), 4 deletions(-)
Quoted 8 lines · Maciej Fijalkowski
Hi,
It started out as an issue on ixgbe reported by Pavel [0] which first patch is supposed to fix, but apparently i40e and ice have queue pair disabling flow a bit out of order, so I addressed them as well. More info is included in commit messages.
Quoted 7 lines
FWIW we are talking here about
AF_XDPZC whenxsk_poolis sent down to driver. Typically these routines are executed when there is already XDP program running on interface.Thanks!
[0]: https://lore.kernel.org/netdev/CAJEV1ijxNyPTwASJER1bcZzS9nMoZJqfR86nu_3jFFVXzZQ4NA@mail.gmail.com/
Thank you for this fix Maciej.
Quoted 13 lines
Maciej Fijalkowski (3):
ixgbe: {dis,en}able irqs in ixgbe_txrx_ring_{dis,en}able
i40e: disable NAPI right after disabling irqs when handlingxsk_pool
ice: reorder disabling IRQ and NAPI inice_qp_disdrivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 9 +-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 56 ++++++++++++++++--- 3 files changed, 55 insertions(+), 12 deletions(-)--
2.34.1