diff mbox series

[28/33] net: introduce napi_tx_raise()

Message ID 20230202110058.130695-29-xuanzhuo@linux.alibaba.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series virtio-net: support AF_XDP zero copy | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count fail Series longer than 15 patches (and no cover letter)
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4353 this patch: 4353
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1021 this patch: 1021
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4564 this patch: 4564
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Xuan Zhuo Feb. 2, 2023, 11 a.m. UTC
Raise napi tx manually without softirq/irq context.

In some cases, we hope to trigger TX Napi from the user's context.
Because it is not triggered from softirq or IRQ, softirq will not be
executed from IRQ Exit. Napi_tx_raise() here will call softirqd.

For example, in the implementation of AF_XDP ZERCOPY TX, we want TX Napi
to process packets in the XSK TX queue. But Virtio-Net does not support
to generate a interrupt from hw manually. So We hope to trigger TX NAPI
from the user's context.

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 include/linux/netdevice.h |  7 +++++++
 net/core/dev.c            | 11 +++++++++++
 2 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d5ef4c1fedd2..a3f8664fadd5 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -519,6 +519,13 @@  static inline bool napi_complete(struct napi_struct *n)
 	return napi_complete_done(n, 0);
 }
 
+/**
+ * napi_tx_raise - raise tx napi
+ *
+ * Raise napi tx manually without softirq/irq context.
+ */
+void napi_tx_raise(void);
+
 int dev_set_threaded(struct net_device *dev, bool threaded);
 
 /**
diff --git a/net/core/dev.c b/net/core/dev.c
index bb42150a38ec..ec19eff89c56 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6092,6 +6092,17 @@  bool napi_complete_done(struct napi_struct *n, int work_done)
 }
 EXPORT_SYMBOL(napi_complete_done);
 
+/**
+ * napi_tx_raise - raise tx napi
+ *
+ * Raise napi tx manually without softirq/irq context.
+ */
+void napi_tx_raise(void)
+{
+	raise_softirq(NET_TX_SOFTIRQ);
+}
+EXPORT_SYMBOL(napi_tx_raise);
+
 /* must be called under rcu_read_lock(), as we dont take a reference */
 static struct napi_struct *napi_by_id(unsigned int napi_id)
 {