net/mlx5e: Fail with messages when params are not valid for XSK
authorAdham Faris <afaris@nvidia.com>
Sun, 8 Jan 2023 07:45:36 +0000 (09:45 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 18 Jan 2023 18:34:07 +0000 (10:34 -0800)
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: 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/params.c
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c

index 585bdc8383ee21fb6371757b66a6ee1bf3edd425..a17b768b81f11b4f873c9ff087835da761bd1831 100644 (file)
@@ -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.
index ff03c43833bbf0148b6b1243a407a19224cbbeab..81a567e172646dd5b76bb434a932ab45ab37ce18 100644 (file)
@@ -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);
        }
 }