History

net/mlx5: Remove useless validity check

All callers build xfrm attributes with help of mlx5e_ipsec_build_accel_xfrm_attrs() function that ensure validity of attributes. There is no need to recheck them again.

Leon Romanovsky committed 4 years ago

Commit 2ea36e21 parent c674df92 files · +0 −54Browse files

Unified · Split

2 files
  1. drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +0 −44
  2. include/linux/mlx5/accel.h +0 −10
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c+0−44
@@ -62,55 +62,11 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev) · 61 unmodified lines
6262 }
6363 EXPORT_SYMBOL_GPL(mlx5_ipsec_device_caps);
6464
65−static int
66−mlx5_ipsec_offload_esp_validate_xfrm_attrs(struct mlx5_core_dev *mdev,
67− const struct mlx5_accel_esp_xfrm_attrs *attrs)
68−{
69− if (attrs->replay_type != MLX5_ACCEL_ESP_REPLAY_NONE) {
70− mlx5_core_err(mdev, "Cannot offload xfrm states with anti replay (replay_type = %d)\n",
71− attrs->replay_type);
72− return -EOPNOTSUPP;
73− }
74−
75− if (attrs->keymat_type != MLX5_ACCEL_ESP_KEYMAT_AES_GCM) {
76− mlx5_core_err(mdev, "Only aes gcm keymat is supported (keymat_type = %d)\n",
77− attrs->keymat_type);
78− return -EOPNOTSUPP;
79− }
80−
81− if (attrs->keymat.aes_gcm.iv_algo !=
82− MLX5_ACCEL_ESP_AES_GCM_IV_ALGO_SEQ) {
83− mlx5_core_err(mdev, "Only iv sequence algo is supported (iv_algo = %d)\n",
84− attrs->keymat.aes_gcm.iv_algo);
85− return -EOPNOTSUPP;
86− }
87−
88− if (attrs->keymat.aes_gcm.key_len != 128 &&
89− attrs->keymat.aes_gcm.key_len != 256) {
90− mlx5_core_err(mdev, "Cannot offload xfrm states with key length other than 128/256 bit (key length = %d)\n",
91− attrs->keymat.aes_gcm.key_len);
92− return -EOPNOTSUPP;
93− }
94−
95− if ((attrs->flags & MLX5_ACCEL_ESP_FLAGS_ESN_TRIGGERED) &&
96− !MLX5_CAP_IPSEC(mdev, ipsec_esn)) {
97− mlx5_core_err(mdev, "Cannot offload xfrm states with ESN triggered\n");
98− return -EOPNOTSUPP;
99− }
100−
101− return 0;
102−}
103−
10465 static struct mlx5_accel_esp_xfrm *
10566 mlx5_ipsec_offload_esp_create_xfrm(struct mlx5_core_dev *mdev,
10667 const struct mlx5_accel_esp_xfrm_attrs *attrs)
10768 {
10869 struct mlx5_ipsec_esp_xfrm *mxfrm;
109− int err = 0;
110−
111− err = mlx5_ipsec_offload_esp_validate_xfrm_attrs(mdev, attrs);
112− if (err)
113− return ERR_PTR(err);
11470
11571 mxfrm = kzalloc(sizeof(*mxfrm), GFP_KERNEL);
11672 if (!mxfrm)
include/linux/mlx5/accel.h+0−10
@@ -36,10 +36,6 @@ · 35 unmodified lines
3636
3737 #include <linux/mlx5/driver.h>
3838
39−enum mlx5_accel_esp_aes_gcm_keymat_iv_algo {
40− MLX5_ACCEL_ESP_AES_GCM_IV_ALGO_SEQ,
41−};
42−
4339 enum mlx5_accel_esp_flags {
4440 MLX5_ACCEL_ESP_FLAGS_TUNNEL = 0, /* Default */
4541 MLX5_ACCEL_ESP_FLAGS_TRANSPORT = 1UL << 0,
@@ -57,14 +53,9 @@ enum mlx5_accel_esp_keymats { · 11 unmodified lines
5753 MLX5_ACCEL_ESP_KEYMAT_AES_GCM,
5854 };
5955
60−enum mlx5_accel_esp_replay {
61− MLX5_ACCEL_ESP_REPLAY_NONE,
62− MLX5_ACCEL_ESP_REPLAY_BMP,
63−};
6456
6557 struct aes_gcm_keymat {
6658 u64 seq_iv;
67− enum mlx5_accel_esp_aes_gcm_keymat_iv_algo iv_algo;
6859
6960 u32 salt;
7061 u32 icv_len;
@@ -81,7 +72,6 @@ struct mlx5_accel_esp_xfrm_attrs { · 10 unmodified lines
8172 u32 tfc_pad;
8273 u32 flags;
8374 u32 sa_handle;
84− enum mlx5_accel_esp_replay replay_type;
8575 union {
8676 struct {
8777 u32 size;