From patchwork Fri Apr 8 07:59:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12806231 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 7573CC43219 for ; Fri, 8 Apr 2022 08:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230406AbiDHIDH (ORCPT ); Fri, 8 Apr 2022 04:03:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230520AbiDHIB6 (ORCPT ); Fri, 8 Apr 2022 04:01:58 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CECDB0A79 for ; Fri, 8 Apr 2022 00:59:45 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id y6so7229061plg.2 for ; Fri, 08 Apr 2022 00:59:45 -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=d/mFypBt0S0IWjKUskVt6x3GbXjBPUd/8MqPnhjOIVU=; b=WSlyvOzQom0xQpMn+DBcqs6hunpBYZ/Gv4IkzU9XuVoFFEBCola0uUW/LW/3leqNOn Vr4VfhNgxqZnxOFSGpT+gY1pP63Px3nnLP4Wl9OR8NV3Y56JT4Ul/Lqq1u8SHvW6hAOk 2ZP6J1TBa4pZylfwkVMUGgvpHgo7wKpN3kurw= 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=d/mFypBt0S0IWjKUskVt6x3GbXjBPUd/8MqPnhjOIVU=; b=UV49I1gakamJvlJ3TGfS8c2vSoC6LAQBrsWsHAB1TorW+VNCnHYnyPR1+KeCSmINAS T5EKiPrfjzneM7womAe3AM3SoFdXwtRmbNM91EAQV4dYJx8RMnP6ml2goCaWZohH7Uvr GkT/UxRgQYoSNgdY+SwocLfixhgyvYJERGkDcJpHRosiaW0SdgvvfnjDMel8s8yLs+E1 pkuU3065eITQSwAyrCsspT3F9kcUB/em+tK3NAhecs164HOFYIDKa/zl+dUenR5O19Qk dY4vaRqG4KShfE4jv37uAZ+UgyRH8yGFaWqxNRphcbTdEorR8YpKC4/tlr+XddlEV2D2 u08w== X-Gm-Message-State: AOAM532iMWQek+oFXOq/3UKXFhHdLT1q59GxvP9HDNTpR43h400sHqpz LupyVyWEmpyZ9Yze9agcHWu7mg== X-Google-Smtp-Source: ABdhPJxA678mCm0T0Nt8cIX4aAu4PnJiXmaE9ysEc8wGHTbQSU/4PtTEMNl7fgBSIrsGEzBKZQXTMg== X-Received: by 2002:a17:90b:1181:b0:1ca:8b8f:3854 with SMTP id gk1-20020a17090b118100b001ca8b8f3854mr20468982pjb.191.1649404784375; Fri, 08 Apr 2022 00:59:44 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id l2-20020a637c42000000b003644cfa0dd1sm20507448pgn.79.2022.04.08.00.59.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Apr 2022 00:59:43 -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 v4 05/11] bnxt: adding bnxt_rx_agg_pages_xdp for aggregated xdp Date: Fri, 8 Apr 2022 03:59:00 -0400 Message-Id: <1649404746-31033-6-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1649404746-31033-1-git-send-email-michael.chan@broadcom.com> References: <1649404746-31033-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; }