diff mbox series

[net-next,v1,7/9] net: Add NAPI IRQ support

Message ID 169059164799.3736.4793522919350631917.stgit@anambiarhost.jf.intel.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Introduce NAPI queues support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5473 this patch: 5473
netdev/cc_maintainers warning 7 maintainers not CCed: daniel@iogearbox.net jesse.brandeburg@intel.com intel-wired-lan@lists.osuosl.org anthony.l.nguyen@intel.com pabeni@redhat.com ast@kernel.org edumazet@google.com
netdev/build_clang fail Errors and warnings before: 969 this patch: 958
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 4380 this patch: 4384
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 44 lines checked
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

Nambiar, Amritha July 29, 2023, 12:47 a.m. UTC
Add support to associate the interrupt vector number for a
NAPI instance.

Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_lib.c |    3 +++
 include/linux/netdevice.h                |    6 ++++++
 net/core/dev.c                           |    1 +
 net/core/netdev-genl.c                   |    4 ++++
 4 files changed, 14 insertions(+)

Comments

Stephen Hemminger July 29, 2023, 4:05 a.m. UTC | #1
On Fri, 28 Jul 2023 17:47:28 -0700
Amritha Nambiar <amritha.nambiar@intel.com> wrote:

> Add support to associate the interrupt vector number for a
> NAPI instance.
> 
> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_lib.c |    3 +++
>  include/linux/netdevice.h                |    6 ++++++
>  net/core/dev.c                           |    1 +
>  net/core/netdev-genl.c                   |    4 ++++
>  4 files changed, 14 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 171177db8fb4..1ebd293ca7de 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -2975,6 +2975,9 @@ int ice_q_vector_add_napi_queues(struct ice_q_vector *q_vector)
>  			return ret;
>  	}
>  
> +	/* Also set the interrupt number for the NAPI */
> +	napi_set_irq(&q_vector->napi, q_vector->irq.virq);
> +
>  	return ret;
>  }

Doing this for only one device seems like a potential problem.
Also, there are some weird devices where there may not be a 1:1:1 mapping
between IRQ, NAPI, and netdev.
Nambiar, Amritha July 31, 2023, 11:22 p.m. UTC | #2
On 7/28/2023 9:05 PM, Stephen Hemminger wrote:
> On Fri, 28 Jul 2023 17:47:28 -0700
> Amritha Nambiar <amritha.nambiar@intel.com> wrote:
> 
>> Add support to associate the interrupt vector number for a
>> NAPI instance.
>>
>> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
>> ---
>>   drivers/net/ethernet/intel/ice/ice_lib.c |    3 +++
>>   include/linux/netdevice.h                |    6 ++++++
>>   net/core/dev.c                           |    1 +
>>   net/core/netdev-genl.c                   |    4 ++++
>>   4 files changed, 14 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
>> index 171177db8fb4..1ebd293ca7de 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
>> @@ -2975,6 +2975,9 @@ int ice_q_vector_add_napi_queues(struct ice_q_vector *q_vector)
>>   			return ret;
>>   	}
>>   
>> +	/* Also set the interrupt number for the NAPI */
>> +	napi_set_irq(&q_vector->napi, q_vector->irq.virq);
>> +
>>   	return ret;
>>   }
> 
> Doing this for only one device seems like a potential problem.

For devices that does not call napi_set_irq(), irq will be initialized 
to -1 as part of netif_napi_add_weight().

> Also, there are some weird devices where there may not be a 1:1:1 mapping
> between IRQ, NAPI, and netdev.
> 

IIUC, there's a 1:1 mapping between IRQ and NAPI, and need not be mapped 
:1 with netdev.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 171177db8fb4..1ebd293ca7de 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -2975,6 +2975,9 @@  int ice_q_vector_add_napi_queues(struct ice_q_vector *q_vector)
 			return ret;
 	}
 
+	/* Also set the interrupt number for the NAPI */
+	napi_set_irq(&q_vector->napi, q_vector->irq.virq);
+
 	return ret;
 }
 
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7afbf346dfd1..a0ae6de1a4aa 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -386,6 +386,7 @@  struct napi_struct {
 	struct hlist_node	napi_hash_node;
 	struct list_head	napi_rxq_list;
 	struct list_head	napi_txq_list;
+	int			irq;
 };
 
 enum {
@@ -2646,6 +2647,11 @@  static inline void *netdev_priv(const struct net_device *dev)
  */
 #define SET_NETDEV_DEVTYPE(net, devtype)	((net)->dev.type = (devtype))
 
+static inline void napi_set_irq(struct napi_struct *napi, int irq)
+{
+	napi->irq = irq;
+}
+
 int netif_napi_add_queue(struct napi_struct *napi, unsigned int queue_index,
 			 enum queue_type type);
 
diff --git a/net/core/dev.c b/net/core/dev.c
index 875023ab614c..118f0b957b6e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6463,6 +6463,7 @@  void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi,
 
 	INIT_LIST_HEAD(&napi->napi_rxq_list);
 	INIT_LIST_HEAD(&napi->napi_txq_list);
+	napi->irq = -1;
 }
 EXPORT_SYMBOL(netif_napi_add_weight);
 
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index ca3ed6eb457b..8401f646a10b 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -161,6 +161,10 @@  netdev_nl_napi_fill_one(struct sk_buff *msg, struct napi_struct *napi)
 			goto nla_put_failure;
 	}
 
+	if (napi->irq >= 0)
+		if (nla_put_u32(msg, NETDEV_A_NAPI_INFO_ENTRY_IRQ, napi->irq))
+			goto nla_put_failure;
+
 	nla_nest_end(msg, napi_info);
 	return 0;
 nla_put_failure: