Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2292751rwo; Thu, 3 Aug 2023 07:28:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlH539FgyUg2SO7WMLGfsNqLefCzBOKUPAaAA/bCPYFN1WO+lbuI0dWuT1ZKF1/flteBOD+z X-Received: by 2002:a05:6a21:7892:b0:13e:b2bf:8481 with SMTP id bf18-20020a056a21789200b0013eb2bf8481mr8171252pzc.1.1691072931545; Thu, 03 Aug 2023 07:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691072931; cv=none; d=google.com; s=arc-20160816; b=ReyJvqd5lxb7TPBMYwL7Ut0YdJMkPDCuojOpKomx6p5Ef+2T6CeNiChZC6G3i8TACA tVhpT8lyNvi8PSwluZy5ZnSQvldQUPYawbcFVCAGaXHcMtZctOM8xmA7r25xK0rpzrN7 KF75aZWIuD5DGQv8+5sh/pMlk7DhYQNuRcv/XxjeFbAI0KQ3BQ1AK12OVpzbdOUiHjfF LWzjB3Dz9Cvp7DDslFvbyzCdD+SGqmFRgVw4Ya4MiufGzm1cV0vdjmP1vr6R+oCJQDIZ NYpDMG6eho19VawZXsZSVRBBMVhhn5vF6qvqcXrHp3wFI4hlMdMp2dKLYBiQRzfLfHtm aZ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Lk7Clg45RdUie/KjcmE3+28g2kd4eecHFcFfnkQv4M=; fh=VmDIXGzgGAt+mNxTrP6+sl6fho9mCQcJ7z//e5pew+A=; b=EMa3leDXIcMVPqV3a9bb1TaQUDhYdmilybUWr0U4Na7fdtpjLWTVjYZDgeW3vPhNRf +4MfzBNrA405VrsBep40NzRDYAPZdqq3wf4zdQxpcmjH8VsSYkwO005bA7yLiir0uMsF BZq6i2Iu1Fhy6SMG+0VEKIMpmVboU5XBpkUl7VGukAvut8coTpXOMhXWWTa7WvPRcmL5 5aY2CVaKlA8uKTwS1ThlL5dcgacOE4Zfe2usImF+MkR2VpiMVrXHt+qI3Pp0QZTg0YIn qKoZW0qGqurAros8aUIFcpn9rZztu7ATE2b9gl8mlasfIAvdr1PbKpjRBgztmBYycvXp yfhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=asWSJ+14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a056a001a4900b006546d0d5832si13255495pfv.183.2023.08.03.07.28.36; Thu, 03 Aug 2023 07:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=asWSJ+14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236444AbjHCOH0 (ORCPT + 99 others); Thu, 3 Aug 2023 10:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235486AbjHCOHB (ORCPT ); Thu, 3 Aug 2023 10:07:01 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD66044AE for ; Thu, 3 Aug 2023 07:05:47 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bba48b0bd2so6837605ad.3 for ; Thu, 03 Aug 2023 07:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691071545; x=1691676345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Lk7Clg45RdUie/KjcmE3+28g2kd4eecHFcFfnkQv4M=; b=asWSJ+14SkxdbE8UXoYgIqvov0BFM79fmeO9euJ1Wv5XRqpkHwShFP6NIXKgvBYS39 KY1uMbrWNQbSjJupGWVrrURhvJ8kmrkqWIv6ZEFPZTTKBxHUS5kikgwuA3z8c5IUvEuo pwfcOp99klDueriStK3YRP+G2A3ta6IrwdNffYwsY1QRFXnKH7rVeHr4XVx9ICdMcs8u TYhqMuVKoTXjFoBzzxm/+LJENMac9MTDwKIUuXzmbia+bqx/NXWlVFRC025fJ/SNhI7G 0sUAAhVdNnFRuvikv0BqaV30V85oEqKXByDdz6upJq+kqp/EKzh4Br8vam8A46D6ers7 qYNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071545; x=1691676345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Lk7Clg45RdUie/KjcmE3+28g2kd4eecHFcFfnkQv4M=; b=fuiISlavSALpClyHugZLb2O5AbiWQGwGCBgdbiJ6+PnRn8H2okPJtHPoEm+aR5A9Qf c1lCW/wJppL/F1Xwm3/xgRkUnKIdc9BU5nQKC5JgmqTVju9oEvzyEgzrHQ7X8YgnRQU/ 0c0P0DRLueQFDvGEfZ+srnxb46KF0eqTmuQ94R2Jr1sq5J1w8rrvjIqB74x/NFadGqOe 88qFeMOJLiULo/wkfoQ6wLDTS+hcaKmVd9vqWeLaBajCcD2058ozPPumgnQmQ/kAbrex poaQjQGN6ijs8BIZvG/HM94t91Xnl8P08uo5gZUAjIykSdSi25e6C+lFRMRcPBPGKGsP DPbg== X-Gm-Message-State: ABy/qLbcZmyBc78xxHLY6bMnkdbCab/U4rVDvjDO8yQ66DlD80SOq1dr 8DjPySrj982jlTZ7q6/DFOMgyg== X-Received: by 2002:a17:903:22c1:b0:1b8:a936:1905 with SMTP id y1-20020a17090322c100b001b8a9361905mr19934085plg.38.1691071545362; Thu, 03 Aug 2023 07:05:45 -0700 (PDT) Received: from C02FG34NMD6R.bytedance.net ([2001:c10:ff04:0:1000::8]) by smtp.gmail.com with ESMTPSA id ji11-20020a170903324b00b001b8a897cd26sm14367485plb.195.2023.08.03.07.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:05:44 -0700 (PDT) From: "huangjie.albert" To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: "huangjie.albert" , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Pavel Begunkov , Kees Cook , Richard Gobert , Yunsheng Lin , netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list), bpf@vger.kernel.org (open list:XDP (eXpress Data Path)) Subject: [RFC Optimizing veth xsk performance 03/10] veth: add support for send queue Date: Thu, 3 Aug 2023 22:04:29 +0800 Message-Id: <20230803140441.53596-4-huangjie.albert@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230803140441.53596-1-huangjie.albert@bytedance.com> References: <20230803140441.53596-1-huangjie.albert@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org in order to support native af_xdp for veth. we need support for send queue for napi tx. the upcoming patch will make use of it. Signed-off-by: huangjie.albert --- drivers/net/veth.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index c2b431a7a017..63c3ebe4c5d0 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -56,6 +56,11 @@ struct veth_rq_stats { struct u64_stats_sync syncp; }; +struct veth_sq_stats { + struct veth_stats vs; + struct u64_stats_sync syncp; +}; + struct veth_rq { struct napi_struct xdp_napi; struct napi_struct __rcu *napi; /* points to xdp_napi when the latter is initialized */ @@ -69,11 +74,25 @@ struct veth_rq { struct page_pool *page_pool; }; +struct veth_sq { + struct napi_struct xdp_napi; + struct net_device *dev; + struct xdp_mem_info xdp_mem; + struct veth_sq_stats stats; + u32 queue_index; + /* this is for xsk */ + struct { + struct xsk_buff_pool __rcu *pool; + u32 last_cpu; + }xsk; +}; + struct veth_priv { struct net_device __rcu *peer; atomic64_t dropped; struct bpf_prog *_xdp_prog; struct veth_rq *rq; + struct veth_sq *sq; unsigned int requested_headroom; }; @@ -1495,6 +1514,15 @@ static int veth_alloc_queues(struct net_device *dev) u64_stats_init(&priv->rq[i].stats.syncp); } + priv->sq = kcalloc(dev->num_tx_queues, sizeof(*priv->sq), GFP_KERNEL); + if (!priv->sq) + return -ENOMEM; + + for (i = 0; i < dev->num_tx_queues; i++) { + priv->sq[i].dev = dev; + u64_stats_init(&priv->sq[i].stats.syncp); + } + return 0; } @@ -1503,6 +1531,7 @@ static void veth_free_queues(struct net_device *dev) struct veth_priv *priv = netdev_priv(dev); kfree(priv->rq); + kfree(priv->sq); } static int veth_dev_init(struct net_device *dev) -- 2.20.1