From mboxrd@z Thu Jan 1 00:00:00 1970 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 CEBD5C4332F for ; Wed, 28 Dec 2022 19:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233144AbiL1ToG (ORCPT ); Wed, 28 Dec 2022 14:44:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232981AbiL1Tnv (ORCPT ); Wed, 28 Dec 2022 14:43:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53C6E12A93 for ; Wed, 28 Dec 2022 11:43:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 09F78B818EF for ; Wed, 28 Dec 2022 19:43:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A02F0C433D2; Wed, 28 Dec 2022 19:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672256628; bh=CyxulKxH0iXlTzlL/8dzwjQMH1mMEtWqeorEIFDJ5Qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C37kd7a99rWHkiQtIxTbNPx7fanGO+pnrNQaFIzOtNV0lAesUBkHrc/rMjpnIAM4w GlhKoQtjwGkFRVxT1qNM9Yp7usmCTU53k4gVA+1eSQVT4QaOgNDOWrnIuVHBpTXFX1 grETyPXWyYvTthMQgln6dn+B9gVZRfbyz0e4y8YDJkmMX55RrKqu5JwCmJfvQXRKKU k7DWRX5RnYZPtOlX4GCcymDSostjtU3wH9LkUEyAIVoUghZDLWt9y/SIsrvUJ4/Hz8 TP270Q2XH0ET6H0hFDnJzwjDLetofJua3SQorYq25BIQ45tzmKDZMTwtRZJdlyjwD4 uBfU0OYJXjVpw== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Adham Faris Subject: [net 10/12] net/mlx5e: Fix hw mtu initializing at XDP SQ allocation Date: Wed, 28 Dec 2022 11:43:29 -0800 Message-Id: <20221228194331.70419-11-saeed@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221228194331.70419-1-saeed@kernel.org> References: <20221228194331.70419-1-saeed@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Adham Faris Current xdp xmit functions logic (mlx5e_xmit_xdp_frame_mpwqe or mlx5e_xmit_xdp_frame), validates xdp packet length by comparing it to hw mtu (configured at xdp sq allocation) before xmiting it. This check does not account for ethernet fcs length (calculated and filled by the nic). Hence, when we try sending packets with length > (hw-mtu - ethernet-fcs-size), the device port drops it and tx_errors_phy is incremented. Desired behavior is to catch these packets and drop them by the driver. Fix this behavior in XDP SQ allocation function (mlx5e_alloc_xdpsq) by subtracting ethernet FCS header size (4 Bytes) from current hw mtu value, since ethernet FCS is calculated and written to ethernet frames by the nic. Fixes: d8bec2b29a82 ("net/mlx5e: Support bpf_xdp_adjust_head()") Signed-off-by: Adham Faris Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 8d36e2de53a9..cff5f2e29e1e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1305,7 +1305,7 @@ static int mlx5e_alloc_xdpsq(struct mlx5e_channel *c, sq->channel = c; sq->uar_map = mdev->mlx5e_res.hw_objs.bfreg.map; sq->min_inline_mode = params->tx_min_inline_mode; - sq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu); + sq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu) - ETH_FCS_LEN; sq->xsk_pool = xsk_pool; sq->stats = sq->xsk_pool ? -- 2.38.1