From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>,
Michal Kubiak <michal.kubiak@intel.com>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Simon Horman <horms@kernel.org>,
nxne.cnse.osdt.itp.upstreaming@intel.com, bpf@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH iwl-next v5 04/13] idpf: link NAPIs to queues
Date: Tue, 26 Aug 2025 17:54:58 +0200 [thread overview]
Message-ID: <20250826155507.2138401-5-aleksander.lobakin@intel.com> (raw)
In-Reply-To: <20250826155507.2138401-1-aleksander.lobakin@intel.com>
Add the missing linking of NAPIs to netdev queues when enabling
interrupt vectors in order to support NAPI configuration and
interfaces requiring get_rx_queue()->napi to be set (like XSk
busy polling).
As currently, idpf_vport_{start,stop}() is called from several flows
with inconsistent RTNL locking, we need to synchronize them to avoid
runtime assertions. Notably:
* idpf_{open,stop}() -- regular NDOs, RTNL is always taken;
* idpf_initiate_soft_reset() -- usually called under RTNL;
* idpf_init_task -- called from the init work, needs RTNL;
* idpf_vport_dealloc -- called without RTNL taken, needs it.
Expand common idpf_vport_{start,stop}() to take an additional bool
telling whether we need to manually take the RTNL lock.
Suggested-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> # helper
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
---
drivers/net/ethernet/intel/idpf/idpf_lib.c | 38 +++++++++++++++------
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 17 +++++++++
2 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index 67236a68f6be..b5a7215488b9 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -884,14 +884,18 @@ static void idpf_remove_features(struct idpf_vport *vport)
/**
* idpf_vport_stop - Disable a vport
* @vport: vport to disable
+ * @rtnl: whether to take RTNL lock
*/
-static void idpf_vport_stop(struct idpf_vport *vport)
+static void idpf_vport_stop(struct idpf_vport *vport, bool rtnl)
{
struct idpf_netdev_priv *np = netdev_priv(vport->netdev);
if (np->state <= __IDPF_VPORT_DOWN)
return;
+ if (rtnl)
+ rtnl_lock();
+
netif_carrier_off(vport->netdev);
netif_tx_disable(vport->netdev);
@@ -913,6 +917,9 @@ static void idpf_vport_stop(struct idpf_vport *vport)
idpf_vport_queues_rel(vport);
idpf_vport_intr_rel(vport);
np->state = __IDPF_VPORT_DOWN;
+
+ if (rtnl)
+ rtnl_unlock();
}
/**
@@ -936,7 +943,7 @@ static int idpf_stop(struct net_device *netdev)
idpf_vport_ctrl_lock(netdev);
vport = idpf_netdev_to_vport(netdev);
- idpf_vport_stop(vport);
+ idpf_vport_stop(vport, false);
idpf_vport_ctrl_unlock(netdev);
@@ -1029,7 +1036,7 @@ static void idpf_vport_dealloc(struct idpf_vport *vport)
idpf_idc_deinit_vport_aux_device(vport->vdev_info);
idpf_deinit_mac_addr(vport);
- idpf_vport_stop(vport);
+ idpf_vport_stop(vport, true);
if (!test_bit(IDPF_HR_RESET_IN_PROG, adapter->flags))
idpf_decfg_netdev(vport);
@@ -1370,8 +1377,9 @@ static void idpf_rx_init_buf_tail(struct idpf_vport *vport)
/**
* idpf_vport_open - Bring up a vport
* @vport: vport to bring up
+ * @rtnl: whether to take RTNL lock
*/
-static int idpf_vport_open(struct idpf_vport *vport)
+static int idpf_vport_open(struct idpf_vport *vport, bool rtnl)
{
struct idpf_netdev_priv *np = netdev_priv(vport->netdev);
struct idpf_adapter *adapter = vport->adapter;
@@ -1381,6 +1389,9 @@ static int idpf_vport_open(struct idpf_vport *vport)
if (np->state != __IDPF_VPORT_DOWN)
return -EBUSY;
+ if (rtnl)
+ rtnl_lock();
+
/* we do not allow interface up just yet */
netif_carrier_off(vport->netdev);
@@ -1388,7 +1399,7 @@ static int idpf_vport_open(struct idpf_vport *vport)
if (err) {
dev_err(&adapter->pdev->dev, "Failed to allocate interrupts for vport %u: %d\n",
vport->vport_id, err);
- return err;
+ goto err_rtnl_unlock;
}
err = idpf_vport_queues_alloc(vport);
@@ -1475,6 +1486,9 @@ static int idpf_vport_open(struct idpf_vport *vport)
goto deinit_rss;
}
+ if (rtnl)
+ rtnl_unlock();
+
return 0;
deinit_rss:
@@ -1492,6 +1506,10 @@ static int idpf_vport_open(struct idpf_vport *vport)
intr_rel:
idpf_vport_intr_rel(vport);
+err_rtnl_unlock:
+ if (rtnl)
+ rtnl_unlock();
+
return err;
}
@@ -1572,7 +1590,7 @@ void idpf_init_task(struct work_struct *work)
np = netdev_priv(vport->netdev);
np->state = __IDPF_VPORT_DOWN;
if (test_and_clear_bit(IDPF_VPORT_UP_REQUESTED, vport_config->flags))
- idpf_vport_open(vport);
+ idpf_vport_open(vport, true);
/* Spawn and return 'idpf_init_task' work queue until all the
* default vports are created
@@ -1962,7 +1980,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
idpf_send_delete_queues_msg(vport);
} else {
set_bit(IDPF_VPORT_DEL_QUEUES, vport->flags);
- idpf_vport_stop(vport);
+ idpf_vport_stop(vport, false);
}
idpf_deinit_rss(vport);
@@ -1992,7 +2010,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
goto err_open;
if (current_state == __IDPF_VPORT_UP)
- err = idpf_vport_open(vport);
+ err = idpf_vport_open(vport, false);
goto free_vport;
@@ -2002,7 +2020,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
err_open:
if (current_state == __IDPF_VPORT_UP)
- idpf_vport_open(vport);
+ idpf_vport_open(vport, false);
free_vport:
kfree(new_vport);
@@ -2240,7 +2258,7 @@ static int idpf_open(struct net_device *netdev)
if (err)
goto unlock;
- err = idpf_vport_open(vport);
+ err = idpf_vport_open(vport, false);
unlock:
idpf_vport_ctrl_unlock(netdev);
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index f49791eab07d..0a2a2b21d1ef 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -3423,6 +3423,20 @@ void idpf_vport_intr_rel(struct idpf_vport *vport)
vport->q_vectors = NULL;
}
+static void idpf_q_vector_set_napi(struct idpf_q_vector *q_vector, bool link)
+{
+ struct napi_struct *napi = link ? &q_vector->napi : NULL;
+ struct net_device *dev = q_vector->vport->netdev;
+
+ for (u32 i = 0; i < q_vector->num_rxq; i++)
+ netif_queue_set_napi(dev, q_vector->rx[i]->idx,
+ NETDEV_QUEUE_TYPE_RX, napi);
+
+ for (u32 i = 0; i < q_vector->num_txq; i++)
+ netif_queue_set_napi(dev, q_vector->tx[i]->idx,
+ NETDEV_QUEUE_TYPE_TX, napi);
+}
+
/**
* idpf_vport_intr_rel_irq - Free the IRQ association with the OS
* @vport: main vport structure
@@ -3443,6 +3457,7 @@ static void idpf_vport_intr_rel_irq(struct idpf_vport *vport)
vidx = vport->q_vector_idxs[vector];
irq_num = adapter->msix_entries[vidx].vector;
+ idpf_q_vector_set_napi(q_vector, false);
kfree(free_irq(irq_num, q_vector));
}
}
@@ -3630,6 +3645,8 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport)
"Request_irq failed, error: %d\n", err);
goto free_q_irqs;
}
+
+ idpf_q_vector_set_napi(q_vector, true);
}
return 0;
--
2.51.0
next prev parent reply other threads:[~2025-08-26 16:13 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 15:54 [PATCH iwl-next v5 00/13] idpf: add XDP support Alexander Lobakin
2025-08-26 15:54 ` [PATCH iwl-next v5 01/13] xdp, libeth: make the xdp_init_buff() micro-optimization generic Alexander Lobakin
[not found] ` <PH0PR11MB5013AB6B0FE10D9986EDC1909600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:44 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:54 ` [PATCH iwl-next v5 02/13] idpf: fix Rx descriptor ready check barrier in splitq Alexander Lobakin
[not found] ` <PH0PR11MB501389C85BEE4E0550FCBD139600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:43 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:54 ` [PATCH iwl-next v5 03/13] idpf: use a saner limit for default number of queues to allocate Alexander Lobakin
[not found] ` <PH0PR11MB5013FF9A3B773061512583C39600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:42 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:54 ` Alexander Lobakin [this message]
[not found] ` <PH0PR11MB5013A0358A8D847F0E757A959600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:38 ` [Intel-wired-lan] [PATCH iwl-next v5 04/13] idpf: link NAPIs to queues R, Ramu
2025-08-26 15:54 ` [PATCH iwl-next v5 05/13] idpf: add 4-byte completion descriptor definition Alexander Lobakin
[not found] ` <PH0PR11MB501349FEDC2D158B29D2BA3F9600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:37 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:55 ` [PATCH iwl-next v5 06/13] idpf: remove SW marker handling from NAPI Alexander Lobakin
[not found] ` <PH0PR11MB5013310C54F6A0098AC9F45F9600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:33 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:55 ` [PATCH iwl-next v5 07/13] idpf: add support for nointerrupt queues Alexander Lobakin
[not found] ` <PH0PR11MB50137C213B5616331E5960399600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:35 ` [Intel-wired-lan] " R, Ramu
2025-09-04 17:44 ` R, Ramu
2025-08-26 15:55 ` [PATCH iwl-next v5 08/13] idpf: prepare structures to support XDP Alexander Lobakin
[not found] ` <PH0PR11MB5013D0C085A90142820588F49600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:28 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:55 ` [PATCH iwl-next v5 09/13] idpf: implement XDP_SETUP_PROG in ndo_bpf for splitq Alexander Lobakin
[not found] ` <PH0PR11MB5013593A9866105499C7ACC79600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:23 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:55 ` [PATCH iwl-next v5 10/13] idpf: use generic functions to build xdp_buff and skb Alexander Lobakin
[not found] ` <PH0PR11MB50133F214C27D489B08EC0C79600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:21 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:55 ` [PATCH iwl-next v5 11/13] idpf: add support for XDP on Rx Alexander Lobakin
[not found] ` <PH0PR11MB5013E983FC06BF5A751C1F4D9600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:20 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:55 ` [PATCH iwl-next v5 12/13] idpf: add support for .ndo_xdp_xmit() Alexander Lobakin
[not found] ` <PH0PR11MB5013E23D4355463542468E3E9600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:14 ` [Intel-wired-lan] " R, Ramu
2025-08-26 15:55 ` [PATCH iwl-next v5 13/13] idpf: add XDP RSS hash hint Alexander Lobakin
[not found] ` <PH0PR11MB5013AA7138C81ABCB5F95F0C9600A@PH0PR11MB5013.namprd11.prod.outlook.com>
2025-09-04 16:05 ` [Intel-wired-lan] " R, Ramu
2025-08-27 17:28 ` [PATCH iwl-next v5 00/13] idpf: add XDP support Simon Horman
2025-08-27 20:42 ` Tony Nguyen
2025-08-28 15:17 ` Alexander Lobakin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250826155507.2138401-5-aleksander.lobakin@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=michal.kubiak@intel.com \
--cc=netdev@vger.kernel.org \
--cc=nxne.cnse.osdt.itp.upstreaming@intel.com \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®