netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Adham Faris <afaris@nvidia.com>
Subject: [net V2 10/14] net/mlx5e: Lower maximum allowed MTU in XSK to match XDP prerequisites
Date: Wed, 15 Mar 2023 15:58:43 -0700	[thread overview]
Message-ID: <20230315225847.360083-11-saeed@kernel.org> (raw)
In-Reply-To: <20230315225847.360083-1-saeed@kernel.org>

From: Adham Faris <afaris@nvidia.com>

XSK redirecting XDP programs require linearity, hence applies
restrictions on the MTU. For PAGE_SIZE=4K, MTU shouldn't exceed 3498.

Features that contradict with XDP such HW-LRO and HW-GRO are enforced
by the driver in advance, during XSK params validation, except for MTU,
which was not enforced before this patch.

This has been spotted during test scenario described below:
Attaching xdpsock program (PAGE_SIZE=4K), with MTU < 3498, detaching
XDP program, changing the MTU to arbitrary value in the range
[3499, 3754], attaching XDP program again, which ended up with failure
since MTU is > 3498.

This commit lowers the XSK MTU limitation to be aligned with XDP MTU
limitation, since XSK socket is meaningless without XDP program.

Signed-off-by: Adham Faris <afaris@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 56fc2aebb9ee..a7f2ab22cc40 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4169,13 +4169,17 @@ static bool mlx5e_xsk_validate_mtu(struct net_device *netdev,
 		struct xsk_buff_pool *xsk_pool =
 			mlx5e_xsk_get_pool(&chs->params, chs->params.xsk, ix);
 		struct mlx5e_xsk_param xsk;
+		int max_xdp_mtu;
 
 		if (!xsk_pool)
 			continue;
 
 		mlx5e_build_xsk_param(xsk_pool, &xsk);
+		max_xdp_mtu = mlx5e_xdp_max_mtu(new_params, &xsk);
 
-		if (!mlx5e_validate_xsk_param(new_params, &xsk, mdev)) {
+		/* Validate XSK params and XDP MTU in advance */
+		if (!mlx5e_validate_xsk_param(new_params, &xsk, mdev) ||
+		    new_params->sw_mtu > max_xdp_mtu) {
 			u32 hr = mlx5e_get_linear_rq_headroom(new_params, &xsk);
 			int max_mtu_frame, max_mtu_page, max_mtu;
 
@@ -4185,9 +4189,9 @@ static bool mlx5e_xsk_validate_mtu(struct net_device *netdev,
 			 */
 			max_mtu_frame = MLX5E_HW2SW_MTU(new_params, xsk.chunk_size - hr);
 			max_mtu_page = MLX5E_HW2SW_MTU(new_params, SKB_MAX_HEAD(0));
-			max_mtu = min(max_mtu_frame, max_mtu_page);
+			max_mtu = min3(max_mtu_frame, max_mtu_page, max_xdp_mtu);
 
-			netdev_err(netdev, "MTU %d is too big for an XSK running on channel %u. Try MTU <= %d\n",
+			netdev_err(netdev, "MTU %d is too big for an XSK running on channel %u or its redirection XDP program. Try MTU <= %d\n",
 				   new_params->sw_mtu, ix, max_mtu);
 			return false;
 		}
-- 
2.39.2


  parent reply	other threads:[~2023-03-15 22:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15 22:58 [pull request][net V2 00/14] mlx5 fixes 2023-03-15 Saeed Mahameed
2023-03-15 22:58 ` [net V2 01/14] net/mlx5e: Fix macsec ASO context alignment Saeed Mahameed
2023-03-17  4:30   ` patchwork-bot+netdevbpf
2023-03-15 22:58 ` [net V2 02/14] net/mlx5e: Don't cache tunnel offloads capability Saeed Mahameed
2023-03-15 22:58 ` [net V2 03/14] net/mlx5: Fix setting ec_function bit in MANAGE_PAGES Saeed Mahameed
2023-03-15 22:58 ` [net V2 04/14] net/mlx5: Disable eswitch before waiting for VF pages Saeed Mahameed
2023-03-15 22:58 ` [net V2 05/14] net/mlx5: E-switch, Fix wrong usage of source port rewrite in split rules Saeed Mahameed
2023-03-15 22:58 ` [net V2 06/14] net/mlx5: E-switch, Fix missing set of split_count when forward to ovs internal port Saeed Mahameed
2023-03-15 22:58 ` [net V2 07/14] net/mlx5e: Fix cleanup null-ptr deref on encap lock Saeed Mahameed
2023-03-15 22:58 ` [net V2 08/14] net/mlx5e: kTLS, Fix missing error unwind on unsupported cipher type Saeed Mahameed
2023-03-15 22:58 ` [net V2 09/14] net/mlx5: Set BREAK_FW_WAIT flag first when removing driver Saeed Mahameed
2023-03-15 22:58 ` Saeed Mahameed [this message]
2023-03-15 22:58 ` [net V2 11/14] net/sched: TC, fix raw counter initialization Saeed Mahameed
2023-03-15 22:58 ` [net V2 12/14] net/mlx5e: TC, fix missing error code Saeed Mahameed
2023-03-15 22:58 ` [net V2 13/14] net/mlx5e: TC, fix cloned flow attribute Saeed Mahameed
2023-03-15 22:58 ` [net V2 14/14] net/mlx5e: TC, Remove error message log print Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230315225847.360083-11-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=afaris@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).