From patchwork Sun Mar 20 19:57:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12786681 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 3250DC4332F for ; Sun, 20 Mar 2022 19:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343617AbiCTT77 (ORCPT ); Sun, 20 Mar 2022 15:59:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343618AbiCTT7w (ORCPT ); Sun, 20 Mar 2022 15:59:52 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F04436163 for ; Sun, 20 Mar 2022 12:58:29 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id e6so8904511pgn.2 for ; Sun, 20 Mar 2022 12:58:29 -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=as+Gor1YPld9R1CaP7xwp+25DitgFSo4wUsy11/ueo0=; b=JrLNWycgcQPcIo0UyDp+x6h4R4uPY1EMvvX4xUuKqfNaugQKNCm9wM04RIq10ZLhjQ FyADRCCWRtJlczONkY+KzTooEE3dAURDTLhrQWg6uu7s8vb0W0xqqX1pbdS3UEroEFoK mmFM3WH2KnIaljL01/eyAdLc/N9GpyCFIBchw= 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=as+Gor1YPld9R1CaP7xwp+25DitgFSo4wUsy11/ueo0=; b=3P48xEwUF3B6LpUYXwCYY6sj+r7YqucYU13ssjoQSaPLLXoB5HF389Lj1570/Mwgld QgSVb6ZxTuy8fTtUUTis9+LfVK2ztYtcQMPvpPTyh+nE0tFxxhXtxyuzVpVZoMNV3NnN 1xXxay7HwFre0rUJuaJxmUCfR+cEY+PA1Jl3i74YPfyNTXcieKnwKKkDHV3sOW5XeH8T zs9ltnzwSnegh2THSk8xHW0kKszwyBtZfiMNGOkqILkXJS/i9mRhShxBLXYRUC78dZzs HBccopcH+LWdaQyHWtCt8wkODLj1aq6XaOdBqHnKg5UrN1FJ/kmzP5qA4a08IRcLF9p0 uhRA== X-Gm-Message-State: AOAM533OWmAAaZjARXibU6iRNCyFmvMjO95hKskb6eJx7kbJXmkPE1ab jrkmuTDxaQbCBiXSl4nF1atbcA== X-Google-Smtp-Source: ABdhPJxSHhvp7Zd8N3hy2oBfCuRgM+SvXZ85li4pm6m7u58nMSFXywkYR48obOw788a6e/lX2lpfBQ== X-Received: by 2002:a05:6a00:2284:b0:4f7:86a3:6f6 with SMTP id f4-20020a056a00228400b004f786a306f6mr20497233pfe.20.1647806308308; Sun, 20 Mar 2022 12:58:28 -0700 (PDT) Received: from localhost.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id h10-20020a056a001a4a00b004f7c76f29c3sm16418335pfv.24.2022.03.20.12.58.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Mar 2022 12:58:28 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com Subject: [PATCH net-next v2 05/11] bnxt: adding bnxt_rx_agg_pages_xdp for aggregated xdp Date: Sun, 20 Mar 2022 15:57:58 -0400 Message-Id: <1647806284-8529-6-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1647806284-8529-1-git-send-email-michael.chan@broadcom.com> References: <1647806284-8529-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 3324d0070667..4f42efeddb32 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; }