net/mlx5e: Accept tunnel mode for IPsec packet offload
authorLeon Romanovsky <leonro@nvidia.com>
Thu, 13 Apr 2023 12:29:28 +0000 (15:29 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 18 Apr 2023 01:55:25 +0000 (18:55 -0700)
Open mlx5 driver to accept IPsec tunnel mode.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c

index 0bda5a91bff65dc181af70c5af49902fbc217ad3..5fd609d1120ebf370c252f8567c1bb6d04d17b29 100644 (file)
@@ -422,6 +422,11 @@ static int mlx5e_xfrm_validate_state(struct mlx5_core_dev *mdev,
                return -EINVAL;
        }
 
+       if (x->props.mode != XFRM_MODE_TRANSPORT && x->props.mode != XFRM_MODE_TUNNEL) {
+               NL_SET_ERR_MSG_MOD(extack, "Only transport and tunnel xfrm states may be offloaded");
+               return -EINVAL;
+       }
+
        switch (x->xso.type) {
        case XFRM_DEV_OFFLOAD_CRYPTO:
                if (!(mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_CRYPTO)) {
@@ -429,11 +434,6 @@ static int mlx5e_xfrm_validate_state(struct mlx5_core_dev *mdev,
                        return -EINVAL;
                }
 
-               if (x->props.mode != XFRM_MODE_TRANSPORT &&
-                   x->props.mode != XFRM_MODE_TUNNEL) {
-                       NL_SET_ERR_MSG_MOD(extack, "Only transport and tunnel xfrm states may be offloaded");
-                       return -EINVAL;
-               }
                break;
        case XFRM_DEV_OFFLOAD_PACKET:
                if (!(mlx5_ipsec_device_caps(mdev) &
@@ -442,8 +442,9 @@ static int mlx5e_xfrm_validate_state(struct mlx5_core_dev *mdev,
                        return -EINVAL;
                }
 
-               if (x->props.mode != XFRM_MODE_TRANSPORT) {
-                       NL_SET_ERR_MSG_MOD(extack, "Only transport xfrm states may be offloaded in packet mode");
+               if (x->props.mode == XFRM_MODE_TUNNEL &&
+                   !(mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_TUNNEL)) {
+                       NL_SET_ERR_MSG_MOD(extack, "Packet offload is not supported for tunnel mode");
                        return -EINVAL;
                }