From patchwork Wed Apr 6 02:53:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12803095 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 AB838C433FE for ; Wed, 6 Apr 2022 10:17:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352536AbiDFKTp (ORCPT ); Wed, 6 Apr 2022 06:19:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243558AbiDFKRd (ORCPT ); Wed, 6 Apr 2022 06:17:33 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9375232FDE5 for ; Tue, 5 Apr 2022 19:54:33 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id s21so1056318pgs.4 for ; Tue, 05 Apr 2022 19:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yL1x8ZZDJWjDqvvyOe4kaFa21ZyDDs7m8KxIQSKgIWU=; b=XxuE/eL5NJuuMT1ovErtBJgFASsss6gngID7OS1dgemv51gY8HSB/Ll1nE4THsdsso fHun6z8+ZpX/KitPR8RZSyM7fTv86ObM0pjh5WqHiebF9RBVMRqdhp7dMD0x5Of5boVx AS3P8L8Z68O8MQ6fnuHz5Vuq0HfueLEWjJeBo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yL1x8ZZDJWjDqvvyOe4kaFa21ZyDDs7m8KxIQSKgIWU=; b=qk0ByJxqbP7hjTYRqD3NVXMpezjk6y4kSixTWoE4Y/NofwCD1szcajwgFG7B+G/o4y lHCzjc0wQH+xusXAx9mBXcz1WxKas6VLTdpbZp0U5g0kCTr1/RhZNyoZ4OSVhiktI88S YPKTYv5n/R0YZWrQbwJaqgVSesdSEbZboPzk1kwpm1N8EQeSZPjq32xh++thSnQ64bXu ++pY+Sg4w7+jy3o+5YzGPArhSIBRNghuZBvMq7esS1KymrS/IAgzGk7MG9DvryZ+CtwL gFG8zih5RU21kxB+jwuAmyYbuC0pJgrtR+pYU5G1yTol+KVq7XC7Lithiteid73GXV0Z YxVA== X-Gm-Message-State: AOAM530/JOBiyMvBzSGCu1hsHfSSIQVr9FgYdM71C/tjgVfUkNZdu8ua G1fbZXTCo2qCT5Phev355BT7Bw== X-Google-Smtp-Source: ABdhPJzeVGZhsUYve046cMmexetR1CDBfCCTCMDsgs7s84+kDOKQtG0Mcb49JC6kFJwUy7kco+MiLQ== X-Received: by 2002:a05:6a00:2124:b0:4fa:739f:2386 with SMTP id n4-20020a056a00212400b004fa739f2386mr6769411pfj.68.1649213663188; Tue, 05 Apr 2022 19:54:23 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id x9-20020a17090a970900b001ca6c59b350sm3395111pjo.2.2022.04.05.19.54.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Apr 2022 19:54:22 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com, bpf@vger.kernel.org, john.fastabend@gmail.com, toke@redhat.com, lorenzo@kernel.org, ast@kernel.org, daniel@iogearbox.net, echaudro@redhat.com, pabeni@redhat.com Subject: [PATCH net-next v3 05/11] bnxt: adding bnxt_rx_agg_pages_xdp for aggregated xdp Date: Tue, 5 Apr 2022 22:53:47 -0400 Message-Id: <1649213633-7662-6-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1649213633-7662-1-git-send-email-michael.chan@broadcom.com> References: <1649213633-7662-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Andy Gospodarek This patch adds a new function that will read pages from the aggregation ring and create an xdp_buff with frags based on the entries in the aggregation ring. Signed-off-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 5487d8661f13..65992a33b973 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1131,6 +1131,27 @@ static struct sk_buff *bnxt_rx_agg_pages_skb(struct bnxt *bp, return skb; } +static u32 bnxt_rx_agg_pages_xdp(struct bnxt *bp, + struct bnxt_cp_ring_info *cpr, + struct xdp_buff *xdp, u16 idx, + u32 agg_bufs, bool tpa) +{ + struct skb_shared_info *shinfo = xdp_get_shared_info_from_buff(xdp); + u32 total_frag_len = 0; + + if (!xdp_buff_has_frags(xdp)) + shinfo->nr_frags = 0; + + total_frag_len = __bnxt_rx_agg_pages(bp, cpr, shinfo, idx, agg_bufs, tpa); + + if (total_frag_len) { + xdp_buff_set_frags_flag(xdp); + shinfo->nr_frags = agg_bufs; + shinfo->xdp_frags_size = total_frag_len; + } + return total_frag_len; +} + static int bnxt_agg_bufs_valid(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, u8 agg_bufs, u32 *raw_cons) { @@ -1859,6 +1880,16 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, if (bnxt_xdp_attached(bp, rxr)) { bnxt_xdp_buff_init(bp, rxr, cons, &data_ptr, &len, &xdp); + if (agg_bufs) { + u32 frag_len = bnxt_rx_agg_pages_xdp(bp, cpr, &xdp, + cp_cons, agg_bufs, + false); + if (!frag_len) { + cpr->sw_stats.rx.rx_oom_discards += 1; + rc = -ENOMEM; + goto next_rx; + } + } xdp_active = true; }