From patchwork Thu Feb 2 11:00:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xuan Zhuo X-Patchwork-Id: 13125777 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA707C05027 for ; Thu, 2 Feb 2023 11:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232889AbjBBLCO (ORCPT ); Thu, 2 Feb 2023 06:02:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232530AbjBBLBn (ORCPT ); Thu, 2 Feb 2023 06:01:43 -0500 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11C0889A5; Thu, 2 Feb 2023 03:01:36 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R331e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0VakkM9._1675335690; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0VakkM9._1675335690) by smtp.aliyun-inc.com; Thu, 02 Feb 2023 19:01:31 +0800 From: Xuan Zhuo To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Sebastian Andrzej Siewior , Menglong Dong , Kuniyuki Iwashima , Petr Machata , virtualization@lists.linux-foundation.org, bpf@vger.kernel.org Subject: [PATCH 28/33] net: introduce napi_tx_raise() Date: Thu, 2 Feb 2023 19:00:53 +0800 Message-Id: <20230202110058.130695-29-xuanzhuo@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20230202110058.130695-1-xuanzhuo@linux.alibaba.com> References: <20230202110058.130695-1-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 X-Git-Hash: d7589ab6ea10 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- include/linux/netdevice.h | 7 +++++++ net/core/dev.c | 11 +++++++++++ 2 files changed, 18 insertions(+) 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) {