From patchwork Mon Jul 31 14:20:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13334860 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E49A18B1A for ; Mon, 31 Jul 2023 14:21:18 +0000 (UTC) Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F2C6C9 for ; Mon, 31 Jul 2023 07:21:17 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-686fc0d3c92so2731669b3a.0 for ; Mon, 31 Jul 2023 07:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1690813277; x=1691418077; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=RqXeNBUPCVG4rZtlAm970K94Z4yDle39Gzg9QRqd9jQ=; b=PZdVXEiuShQMFbXw3FFYeH1Nyqtn761+65qseS/Iy8hHF7GDLG1LK88pErY741oKJm e0417hlhiATk3tNFpWQUmAcASFTMvuAR+4anwubtNM+ZrgzEFOTfAUxTmWq1T4J4r8ry 5eQq7W164ox1K0+yJ7GBKmct/3gp1JG+/6hnw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690813277; x=1691418077; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RqXeNBUPCVG4rZtlAm970K94Z4yDle39Gzg9QRqd9jQ=; b=ReOZWABD9RIWNHLNKmNvhaGvlQFOqrmG5+ofcfrc3qAACErBy9IsQQoF5q934qa587 yj7/bBlLnYwwEcglR9hOuHn8GSQvuLvvmYcKSi9OlMHXLlea6hlyUuGBThAx2Q2sRMVF 4mJ25zbR6Ep0+dXETyFsd7hxDb4Q5o018AKddqKy3a8eTXgKRzRmNtTb6WCsL8gJ3xOc rWpmEyuZGS0C7fFDi3ZiDyJpxzPg7FLbQdwt7dKyMlOxOw8fKS+JlpXcsOrfr7DaV+j0 R0T7ANYWTykiFQGwQwu/FpprQTd0oGZtlyTi+rf8FDRdd5VI9l/yT8IpjTgxhmOAItDb UuFA== X-Gm-Message-State: ABy/qLbboKWLaj2fPNZ6LzfEFrpDyfDhwuVYDXJVDIBYXx8UVRlmjcD+ y6+2vVMfbi1wrJdGCYEyfDERLGOyI0Rewj95iMk= X-Google-Smtp-Source: APBJJlHyzdEIr3Yzkz+0ZAyFSHmjSRzKNNp1w3rO5/OCkx6mzz9RQ9WseVw068mNnZRLztSwsU+Gbw== X-Received: by 2002:a05:6a20:3d23:b0:13a:72a9:799d with SMTP id y35-20020a056a203d2300b0013a72a9799dmr10279662pzi.19.1690813276686; Mon, 31 Jul 2023 07:21:16 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id k12-20020aa790cc000000b00682c1db7551sm5509924pfk.49.2023.07.31.07.21.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jul 2023 07:21:15 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, bpf@vger.kernel.org, somnath.kotur@broadcom.com, Ajit Khaparde , Andy Gospodarek Subject: [PATCH net 2/2] bnxt_en: Fix max_mtu setting for multi-buf XDP Date: Mon, 31 Jul 2023 07:20:43 -0700 Message-Id: <20230731142043.58855-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230731142043.58855-1-michael.chan@broadcom.com> References: <20230731142043.58855-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The existing code does not allow the MTU to be set to the maximum even after an XDP program supporting multiple buffers is attached. Fix it to set the netdev->max_mtu to the maximum value if the attached XDP program supports mutiple buffers, regardless of the current MTU value. Also use a local variable dev instead of repeatedly using bp->dev. Fixes: 1dc4c557bfed ("bnxt: adding bnxt_xdp_build_skb to build skb from multibuffer xdp_buff") Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 13662b114f90..b2bb8a22963d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -3999,26 +3999,29 @@ void bnxt_set_ring_params(struct bnxt *bp) */ int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode) { + struct net_device *dev = bp->dev; + if (page_mode) { bp->flags &= ~BNXT_FLAG_AGG_RINGS; bp->flags |= BNXT_FLAG_RX_PAGE_MODE; - if (bp->dev->mtu > BNXT_MAX_PAGE_MODE_MTU) { + if (bp->xdp_prog->aux->xdp_has_frags) + dev->max_mtu = min_t(u16, bp->max_mtu, BNXT_MAX_MTU); + else + dev->max_mtu = + min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU); + if (dev->mtu > BNXT_MAX_PAGE_MODE_MTU) { bp->flags |= BNXT_FLAG_JUMBO; bp->rx_skb_func = bnxt_rx_multi_page_skb; - bp->dev->max_mtu = - min_t(u16, bp->max_mtu, BNXT_MAX_MTU); } else { bp->flags |= BNXT_FLAG_NO_AGG_RINGS; bp->rx_skb_func = bnxt_rx_page_skb; - bp->dev->max_mtu = - min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU); } bp->rx_dir = DMA_BIDIRECTIONAL; /* Disable LRO or GRO_HW */ - netdev_update_features(bp->dev); + netdev_update_features(dev); } else { - bp->dev->max_mtu = bp->max_mtu; + dev->max_mtu = bp->max_mtu; bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE; bp->rx_dir = DMA_FROM_DEVICE; bp->rx_skb_func = bnxt_rx_skb;