From patchwork Mon Aug 22 15:06:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12950729 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 A357CC32774 for ; Mon, 22 Aug 2022 15:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235916AbiHVPJb (ORCPT ); Mon, 22 Aug 2022 11:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235998AbiHVPJF (ORCPT ); Mon, 22 Aug 2022 11:09:05 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01EED3DF3E for ; Mon, 22 Aug 2022 08:07:09 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id e4so8313122qvr.2 for ; Mon, 22 Aug 2022 08:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc; bh=KVNuV0nawU5p5zFBSk1Rmd1N53t5M5FBZ+StSlZLmB0=; b=XC81aM+C7mDXhBljNn0P736uUZZKfbRNFo5HNGdfLnjtQ35dfwMt58RKBzm9COhJGn 2dSeHYXXMeXi3S3kZ471pNDrNFZeeVel65ALZQeEsvUyJkT4QzYu3n+0IhGGLlaRYmyc wFyuxY/wQ2FkNM23YMAGSnYoFzpi1kTqV35mE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc; bh=KVNuV0nawU5p5zFBSk1Rmd1N53t5M5FBZ+StSlZLmB0=; b=LlUQD1DAtZJ+yMV3jseHXOYnXA8OFX30pdl818+fAoFWdDh81tbavhU5U4Vk3Zief4 QEK+mfJ2UEW7B6MyxuH9bUbp/kBTBlzvY/WZ3vVD9Dj0OuCla9gEZz8taXAOh7c0dXN7 Li/I8MamiZ0m4Z+lzJHHOm7v/kW1UlDeuJyfMzC8LnAb+j1/ULrsS55/RIzsMREnuBCH +xAGHir0sEGj5kj6IFsyH6lTLxFJLm0aP2AmmqIteF7hBQUy5eLhfIH7UrdhVeEV4IGC rOHIQ9/qLQjg+nqhlUcDGY5ts3bSf+sZOIm7/BKgL6+0xtKziwUw1dmb4svNb/waVBTk JKyg== X-Gm-Message-State: ACgBeo1dG6V6IBXX3TSnlV6pCtqUU3+mBU56PHnGn2l4rns/cAgAmTq2 5VruZ/edq4lUwvr10v4X7OfSDw== X-Google-Smtp-Source: AA6agR41cPOQFxAY/KdscTR0eCQdAWgtSQrZay4PBKCqX+mVaMgaJrC/JWnDMwY+cLn4s1v0V0GMJA== X-Received: by 2002:a05:6214:76a:b0:496:c298:d165 with SMTP id f10-20020a056214076a00b00496c298d165mr13556874qvz.100.1661180825917; Mon, 22 Aug 2022 08:07:05 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id f39-20020a05622a1a2700b00342f05defd1sm9380836qtb.66.2022.08.22.08.07.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Aug 2022 08:07:05 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, gospo@broadcom.com, Pavan Chebbi Subject: [PATCH net 1/4] bnxt_en: Use PAGE_SIZE to init buffer when multi buffer XDP is not in use Date: Mon, 22 Aug 2022 11:06:51 -0400 Message-Id: <1661180814-19350-2-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1661180814-19350-1-git-send-email-michael.chan@broadcom.com> References: <1661180814-19350-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: Pavan Chebbi Using BNXT_PAGE_MODE_BUF_SIZE + offset as buffer length value is not sufficient when running single buffer XDP programs doing redirect operations. The stack will complain on missing skb tail room. Fix it by using PAGE_SIZE when calling xdp_init_buff() for single buffer programs. Fixes: b231c3f3414c ("bnxt: refactor bnxt_rx_xdp to separate xdp_init_buff/xdp_prepare_buff") Reviewed-by: Somnath Kotur Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 075c6206325c..b1b17f911300 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2130,6 +2130,7 @@ struct bnxt { #define BNXT_DUMP_CRASH 1 struct bpf_prog *xdp_prog; + u8 xdp_has_frags; struct bnxt_ptp_cfg *ptp_cfg; u8 ptp_all_rx_tstamp; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c index f53387ed0167..c3065ec0a479 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c @@ -181,6 +181,7 @@ void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, struct xdp_buff *xdp) { struct bnxt_sw_rx_bd *rx_buf; + u32 buflen = PAGE_SIZE; struct pci_dev *pdev; dma_addr_t mapping; u32 offset; @@ -192,7 +193,10 @@ void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, mapping = rx_buf->mapping - bp->rx_dma_offset; dma_sync_single_for_cpu(&pdev->dev, mapping + offset, *len, bp->rx_dir); - xdp_init_buff(xdp, BNXT_PAGE_MODE_BUF_SIZE + offset, &rxr->xdp_rxq); + if (bp->xdp_has_frags) + buflen = BNXT_PAGE_MODE_BUF_SIZE + offset; + + xdp_init_buff(xdp, buflen, &rxr->xdp_rxq); xdp_prepare_buff(xdp, *data_ptr - offset, offset, *len, false); } @@ -397,8 +401,10 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) netdev_warn(dev, "ethtool rx/tx channels must be combined to support XDP.\n"); return -EOPNOTSUPP; } - if (prog) + if (prog) { tx_xdp = bp->rx_nr_rings; + bp->xdp_has_frags = prog->aux->xdp_has_frags; + } tc = netdev_get_num_tc(dev); if (!tc)