From patchwork Tue Mar 11 12:18:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 14011751 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7E42C28B2E for ; Tue, 11 Mar 2025 12:28:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=s/bpBIYm3FNBnLlo8ULJYs5MXNWjmzAOqyxm3wfhDGg=; b=A8aE0QBU1KPscuuyds8pUfPwRN ezR0WWztRzMXKnL3oXbtTLnzhVhtolSSC+8IyiLVvm0ogdZy392PTtikTY6PupmYL4A7gUCuZr4HK e46Fyd/EnChOf9JeM0qN5EuXgkRRiv5sEGXfsiRlKX4zFZeXZKyf/5/KlApjmKhyejtkkCVHS9jDc l+RyCkgVnGK91B3gknySDt4DwtocEHvRdQ63hqWlDgOHamNEUYSdNQZvpUCdxiChUAjjsZbz4WRjg w2fh79mybN9IHWmAalgubLtZEz+3b99Bp7l2fp0XmXUfS/sUEE+/UhSD01XGVF4iH3qIIGU6QP9AO rZiL8gWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tryiW-00000005dqF-2Zpy; Tue, 11 Mar 2025 12:28:16 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tryZh-00000005bbh-413v; Tue, 11 Mar 2025 12:19:11 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8C7E15C6222; Tue, 11 Mar 2025 12:16:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CF8DC4CEE9; Tue, 11 Mar 2025 12:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741695549; bh=LSjQ49wR95nB5Q5G/AIMKk08CggQRNScXhe5BjJKpeQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WYyjIwf0NKoI9nJPBCgY1Bv65NklpAR8eJ8qZ8zW2R0VyFs6VlCIkgkVLsrRdX0kd vduu59iVdLoyGQzlh8+Vi+1XTCx8VslZ0Nstm8soITPVVeStTNVpt1pU+9/y8AcgO4 uUYIKFcAhgR/cD0T2oxWvkg1ik/eljslHbTv6u229C83Pyq9hiGOsWNfXlYhxvQg16 FY1k6EFypst6J/6Qy58gV4rAZMAUfn4+nGf9w5d0Zz1JtKa3jZTPUwFtNUO+Fvt8Ev LMkzqqtEld2lNu2aQEWixc1OatPITJIhoYARMzYTJjKxBDOlXFl1SR1DLnGZCrPEBj 8f1dzz9unFnww== From: Lorenzo Bianconi Date: Tue, 11 Mar 2025 13:18:36 +0100 Subject: [PATCH net-next 4/7] net: octeontx2: Add metadata support for xdp mode MIME-Version: 1.0 Message-Id: <20250311-mvneta-xdp-meta-v1-4-36cf1c99790e@kernel.org> References: <20250311-mvneta-xdp-meta-v1-0-36cf1c99790e@kernel.org> In-Reply-To: <20250311-mvneta-xdp-meta-v1-0-36cf1c99790e@kernel.org> To: Marcin Wojtas , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Russell King , Ilias Apalodimas , Masahisa Kojima , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Felix Fietkau , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Siddharth Vadapalli , Roger Quadros Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-omap@vger.kernel.org, Lorenzo Bianconi X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250311_051910_086184_75121F19 X-CRM114-Status: GOOD ( 11.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Set metadata size building the skb from xdp_buff in octeontx2 driver Signed-off-by: Lorenzo Bianconi --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c index 6bc5ce5a9f61cc2830975e7cc5219344760b0e51..af8cabe828d05c8832085d24d183312f24d00330 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c @@ -41,7 +41,7 @@ static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf, struct bpf_prog *prog, struct nix_cqe_rx_s *cqe, struct otx2_cq_queue *cq, - bool *need_xdp_flush); + u32 *metasize, bool *need_xdp_flush); static void otx2_sq_set_sqe_base(struct otx2_snd_queue *sq, struct sk_buff *skb) @@ -336,6 +336,7 @@ static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf, struct nix_rx_sg_s *sg = &cqe->sg; struct sk_buff *skb = NULL; void *end, *start; + u32 metasize = 0; u64 *seg_addr; u16 *seg_size; int seg; @@ -346,7 +347,8 @@ static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf, } if (pfvf->xdp_prog) - if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq, need_xdp_flush)) + if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq, + &metasize, need_xdp_flush)) return; skb = napi_get_frags(napi); @@ -378,6 +380,8 @@ static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf, skb->mark = parse->match_id; skb_mark_for_recycle(skb); + if (metasize) + skb_metadata_set(skb, metasize); napi_gro_frags(napi); } @@ -1482,7 +1486,7 @@ static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf, struct bpf_prog *prog, struct nix_cqe_rx_s *cqe, struct otx2_cq_queue *cq, - bool *need_xdp_flush) + u32 *metasize, bool *need_xdp_flush) { struct xdp_buff xdp, *xsk_buff = NULL; unsigned char *hard_start; @@ -1514,13 +1518,14 @@ static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf, hard_start = (unsigned char *)phys_to_virt(pa); xdp_prepare_buff(&xdp, hard_start, OTX2_HEAD_ROOM, - cqe->sg.seg_size, false); + cqe->sg.seg_size, true); act = bpf_prog_run_xdp(prog, &xdp); handle_xdp_verdict: switch (act) { case XDP_PASS: + *metasize = xdp.data - xdp.data_meta; break; case XDP_TX: qidx += pfvf->hw.tx_queues;