Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4507727rwb; Tue, 8 Aug 2023 09:25:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEb/jXQXa69XqdVziTKZ2f9cSGfSCEXkU+iZ47HL34wxMAsE9/t1TVFSwZb8hzyPEw+ko8R X-Received: by 2002:a17:906:3001:b0:99c:c4b3:9ffd with SMTP id 1-20020a170906300100b0099cc4b39ffdmr57501ejz.48.1691511941490; Tue, 08 Aug 2023 09:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691511941; cv=none; d=google.com; s=arc-20160816; b=xhRxeL+U/EwSGimctZg9xQqz2iFxdCVLSoxpyYu751R8w8x/KJ/uBqqsnf8Db6UJwy 7PdrB2/fk5cmQQZcz5P2qY7KatlRv7xiEhuGttWZcimWmsgtwJslObIkPCaBWNl4hJ/1 NDOwoJLlHLZbWCh9m/9BY3g/FYLDkysSIR4x7PoowW1t7hY4qHASMvKT8zhLQ9f8poW/ bmqM+1jN5jRx3u15T124jYBmSz8aBB6RRPM61+8hhAWNF9dDMKgNQQ2e8gLRlhUqSh+H 3UE9LNavRu2nylhDS3aifEEdZUra5uErQnV+qstVH0hr7Ik7gu2YzR/HF1JOuahXK61g /dDQ== 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=9C7bHaMSd+SY+pPB7Vtx4/6UZIJ72tWmfxoauVOSVx0=; fh=d52JIWYEkePcj18BLr16Py79ZIzTYL7SzTuYhl8wvHo=; b=yoLiH0Eo915g23Cy0N3z50HBMr5PIDqKHlTfK/v09lsXEqMNDPCUnpWEnyUjjP0ThK 6ViH+R9hngBdRhEdNojk1ewBRkDy3h42anML85mV6bwJn+p5UGM9OO69ZA1o+cpzCZFm 8eNKJMBulZnd3ZCaVaOjrOdTASw+aimUPG99w+Fydl1iN2tljXRPESHaRaI1twhRNtpM 1ZwyZyxG4EB2h7RrcGgLmEiyxegcJvehLy9qErD4yrCJavCp2ZAu6UOBrVPDp/qyUYeJ sWR/nQGSv3TkSh91shAvNwCYN7RwZ8tCZHyyB9oW0Q4I78aCpNWZsLQba796UctOTGhs gqkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=VHfxDg5Q; 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 gj20-20020a170906e11400b0099bcf76e4casi7140730ejb.933.2023.08.08.09.25.15; Tue, 08 Aug 2023 09:25:41 -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=VHfxDg5Q; 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 S231171AbjHHDUx (ORCPT + 99 others); Mon, 7 Aug 2023 23:20:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231157AbjHHDUp (ORCPT ); Mon, 7 Aug 2023 23:20:45 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C358A10DC for ; Mon, 7 Aug 2023 20:20:43 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bc73a2b0easo8964765ad.0 for ; Mon, 07 Aug 2023 20:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691464843; x=1692069643; 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=9C7bHaMSd+SY+pPB7Vtx4/6UZIJ72tWmfxoauVOSVx0=; b=VHfxDg5QSz1PqjRWt9B9x6mNaS6RhCwH3kbVmHYf16gDy0fMcTjbQfLdJ1bUO9PgyF e858P0e+77eKT6XZAaPITT05KvwS75X5CChow28CxQevaNfwHO/a/b/Tjth6QhYmamUl D2koPxHSfUnNqjewXP7wEAFJPTs3dyQoX1v5vV3qDUxrlvdVl0KOQKfXzW86ewoVN7mA /80D4Vn2cmagGQlwfUnU6NadEKweg09+IK+04wQqqwm6DaEtzrp97grfGS8he+jLvx/k eWU21VDBsw4THoGugTPD0TDkYAr8PyGh2PllRIUx5Bm4PqGbt8R1AGICgsH1UV/Qg33Y IKPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691464843; x=1692069643; 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=9C7bHaMSd+SY+pPB7Vtx4/6UZIJ72tWmfxoauVOSVx0=; b=Z0GK9sJ93Bj4mxmCK8FbBdK98zsvZp/9F2IpYptBe/fYoPdCYy2Uw86oHYHaZ/MhH0 JWwlk837gooaXPbwQ0rt6lMfaidwbuHsr44Eoe7J+B5y2iK8kiDWJm4vUF33mxWSoMRY midOoAHBHJNuOp6iSLEEAq/50elAXcV6+jRTEio6MlwxjvYmUrSWCz8OfUR/LfQEXJqT iXvGLr0ZbP8U9L4h964zfYLVygkiCL7IbxIzskb4PrbVyPQgWCyoukycEMO3njiSkNPc h16PmFBzKG0PAmyO8NeTVO5u5Ny4+pi+EV8P0avQNsTooRsbDeDzZGIoiXFsNFsVj0Ve whWg== X-Gm-Message-State: AOJu0Yy5sdKo4MUWzeB1DrxjPe0zH4uK8jFilz3EKEwnLXJ94GD/yvyf v67zeKIT/iypg1r3rVZSTwdRPA== X-Received: by 2002:a17:902:c404:b0:1bb:a367:a77 with SMTP id k4-20020a170902c40400b001bba3670a77mr11633095plk.31.1691464843297; Mon, 07 Aug 2023 20:20:43 -0700 (PDT) Received: from C02FG34NMD6R.bytedance.net ([2408:8656:30f8:e020::b]) by smtp.gmail.com with ESMTPSA id 13-20020a170902c10d00b001b896686c78sm7675800pli.66.2023.08.07.20.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 20:20:42 -0700 (PDT) From: Albert Huang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: Albert Huang , 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 , Yunsheng Lin , Kees Cook , Richard Gobert , "open list:NETWORKING DRIVERS" , open list , "open list:XDP (eXpress Data Path)" Subject: [RFC v3 Optimizing veth xsk performance 3/9] veth: add support for send queue Date: Tue, 8 Aug 2023 11:19:07 +0800 Message-Id: <20230808031913.46965-4-huangjie.albert@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230808031913.46965-1-huangjie.albert@bytedance.com> References: <20230808031913.46965-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_PASS,URIBL_BLOCKED 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: Albert Huang --- drivers/net/veth.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 77e12d52ca2b..25faba879505 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; + /* 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