Commit 130b1207 authored by Adham Faris's avatar Adham Faris Committed by Saeed Mahameed
Browse files

net/mlx5e: Fail with messages when params are not valid for XSK



Current XSK prerequisites validation implementation
(setup.c/mlx5e_validate_xsk_param()) fails silently when xsk
prerequisites are not fulfilled.
Add error messages to the kernel log to help the user understand what
went wrong when params are not valid for XSK.

Signed-off-by: default avatarAdham Faris <afaris@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 1158b7d1
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -581,11 +581,16 @@ int mlx5e_mpwrq_validate_xsk(struct mlx5_core_dev *mdev, struct mlx5e_params *pa
	bool unaligned = xsk ? xsk->unaligned : false;
	u16 max_mtu_pkts;

	if (!mlx5e_check_fragmented_striding_rq_cap(mdev, page_shift, umr_mode))
	if (!mlx5e_check_fragmented_striding_rq_cap(mdev, page_shift, umr_mode)) {
		mlx5_core_err(mdev, "Striding RQ for XSK can't be activated with page_shift %u and umr_mode %d\n",
			      page_shift, umr_mode);
		return -EOPNOTSUPP;
	}

	if (!mlx5e_rx_mpwqe_is_linear_skb(mdev, params, xsk))
	if (!mlx5e_rx_mpwqe_is_linear_skb(mdev, params, xsk)) {
		mlx5_core_err(mdev, "Striding RQ linear mode for XSK can't be activated with current params\n");
		return -EINVAL;
	}

	/* Current RQ length is too big for the given frame size, the
	 * needed number of WQEs exceeds the maximum.
+17 −2
Original line number Diff line number Diff line
@@ -7,6 +7,18 @@
#include "en/health.h"
#include <net/xdp_sock_drv.h>

static int mlx5e_legacy_rq_validate_xsk(struct mlx5_core_dev *mdev,
					struct mlx5e_params *params,
					struct mlx5e_xsk_param *xsk)
{
	if (!mlx5e_rx_is_linear_skb(mdev, params, xsk)) {
		mlx5_core_err(mdev, "Legacy RQ linear mode for XSK can't be activated with current params\n");
		return -EINVAL;
	}

	return 0;
}

/* The limitation of 2048 can be altered, but shouldn't go beyond the minimal
 * stride size of striding RQ.
 */
@@ -17,8 +29,11 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
			      struct mlx5_core_dev *mdev)
{
	/* AF_XDP doesn't support frames larger than PAGE_SIZE. */
	if (xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE)
	if (xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) {
		mlx5_core_err(mdev, "XSK chunk size %u out of bounds [%u, %lu]\n", xsk->chunk_size,
			      MLX5E_MIN_XSK_CHUNK_SIZE, PAGE_SIZE);
		return false;
	}

	/* frag_sz is different for regular and XSK RQs, so ensure that linear
	 * SKB mode is possible.
@@ -27,7 +42,7 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
	case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
		return !mlx5e_mpwrq_validate_xsk(mdev, params, xsk);
	default: /* MLX5_WQ_TYPE_CYCLIC */
		return mlx5e_rx_is_linear_skb(mdev, params, xsk);
		return !mlx5e_legacy_rq_validate_xsk(mdev, params, xsk);
	}
}