@@ -690,7 +690,7 @@ struct netdev_queue {
* slow- / control-path part
*/
/* NAPI instance for the queue
- * Readers and writers must hold RTNL
+ * Readers and writers must hold netdev->lock
*/
struct napi_struct *napi;
@@ -2458,7 +2458,8 @@ struct net_device {
* Partially protects (writers must hold both @lock and rtnl_lock):
* @up
*
- * Also protects some fields in struct napi_struct.
+ * Also protects some fields in:
+ * struct napi_struct, struct netdev_queue, struct netdev_rx_queue
*
* Ordering: take after rtnl_lock.
*/
@@ -2685,6 +2686,10 @@ static inline void *netdev_priv(const struct net_device *dev)
void netif_queue_set_napi(struct net_device *dev, unsigned int queue_index,
enum netdev_queue_type type,
struct napi_struct *napi);
+void netif_queue_set_napi_locked(struct net_device *dev,
+ unsigned int queue_index,
+ enum netdev_queue_type type,
+ struct napi_struct *napi);
static inline void netdev_lock(struct net_device *dev)
{
@@ -23,7 +23,7 @@ struct netdev_rx_queue {
struct xsk_buff_pool *pool;
#endif
/* NAPI instance for the queue
- * Readers and writers must hold RTNL
+ * Readers and writers must hold netdev->lock
*/
struct napi_struct *napi;
struct pp_memory_provider_params mp_params;
@@ -6851,14 +6851,24 @@ EXPORT_SYMBOL(dev_set_threaded);
*/
void netif_queue_set_napi(struct net_device *dev, unsigned int queue_index,
enum netdev_queue_type type, struct napi_struct *napi)
+{
+ netdev_lock(dev);
+ netif_queue_set_napi_locked(dev, queue_index, type, napi);
+ netdev_unlock(dev);
+}
+EXPORT_SYMBOL(netif_queue_set_napi);
+
+void netif_queue_set_napi_locked(struct net_device *dev,
+ unsigned int queue_index,
+ enum netdev_queue_type type,
+ struct napi_struct *napi)
{
struct netdev_rx_queue *rxq;
struct netdev_queue *txq;
if (WARN_ON_ONCE(napi && !napi->dev))
return;
- if (dev->reg_state >= NETREG_REGISTERED)
- ASSERT_RTNL();
+ netdev_assert_locked_or_invisible(dev);
switch (type) {
case NETDEV_QUEUE_TYPE_RX:
@@ -6873,7 +6883,7 @@ void netif_queue_set_napi(struct net_device *dev, unsigned int queue_index,
return;
}
}
-EXPORT_SYMBOL(netif_queue_set_napi);
+EXPORT_SYMBOL(netif_queue_set_napi_locked);
static void napi_restore_config(struct napi_struct *n)
{