aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Chancellor <natechancellor@gmail.com>2019-07-10 02:06:15 -0400
committerDavid S. Miller <davem@davemloft.net>2019-07-12 14:37:03 -0400
commit9db7e618fca34d0a7d61c149d726fd90644ecb1e (patch)
tree0e0834e601c41c1cf85bb3ba65ec1f94a64b78ce
parent3194d6adfe8e4da74e04b8eacef2bd7eea3f8992 (diff)
net/mlx5e: Convert single case statement switch statements into if statements
During the review of commit 1ff2f0fa450e ("net/mlx5e: Return in default case statement in tx_post_resync_params"), Leon and Nick pointed out that the switch statements can be converted to single if statements that return early so that the code is easier to follow. Suggested-by: Leon Romanovsky <leon@kernel.org> Suggested-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
index 5c08891806f0..ea032f54197e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
@@ -25,23 +25,17 @@ static void
25fill_static_params_ctx(void *ctx, struct mlx5e_ktls_offload_context_tx *priv_tx) 25fill_static_params_ctx(void *ctx, struct mlx5e_ktls_offload_context_tx *priv_tx)
26{ 26{
27 struct tls_crypto_info *crypto_info = priv_tx->crypto_info; 27 struct tls_crypto_info *crypto_info = priv_tx->crypto_info;
28 struct tls12_crypto_info_aes_gcm_128 *info;
28 char *initial_rn, *gcm_iv; 29 char *initial_rn, *gcm_iv;
29 u16 salt_sz, rec_seq_sz; 30 u16 salt_sz, rec_seq_sz;
30 char *salt, *rec_seq; 31 char *salt, *rec_seq;
31 u8 tls_version; 32 u8 tls_version;
32 33
33 switch (crypto_info->cipher_type) { 34 if (WARN_ON(crypto_info->cipher_type != TLS_CIPHER_AES_GCM_128))
34 case TLS_CIPHER_AES_GCM_128: {
35 struct tls12_crypto_info_aes_gcm_128 *info =
36 (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
37
38 EXTRACT_INFO_FIELDS;
39 break;
40 }
41 default:
42 WARN_ON(1);
43 return; 35 return;
44 } 36
37 info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
38 EXTRACT_INFO_FIELDS;
45 39
46 gcm_iv = MLX5_ADDR_OF(tls_static_params, ctx, gcm_iv); 40 gcm_iv = MLX5_ADDR_OF(tls_static_params, ctx, gcm_iv);
47 initial_rn = MLX5_ADDR_OF(tls_static_params, ctx, initial_record_number); 41 initial_rn = MLX5_ADDR_OF(tls_static_params, ctx, initial_record_number);
@@ -234,24 +228,18 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
234 u64 rcd_sn) 228 u64 rcd_sn)
235{ 229{
236 struct tls_crypto_info *crypto_info = priv_tx->crypto_info; 230 struct tls_crypto_info *crypto_info = priv_tx->crypto_info;
231 struct tls12_crypto_info_aes_gcm_128 *info;
237 __be64 rn_be = cpu_to_be64(rcd_sn); 232 __be64 rn_be = cpu_to_be64(rcd_sn);
238 bool skip_static_post; 233 bool skip_static_post;
239 u16 rec_seq_sz; 234 u16 rec_seq_sz;
240 char *rec_seq; 235 char *rec_seq;
241 236
242 switch (crypto_info->cipher_type) { 237 if (WARN_ON(crypto_info->cipher_type != TLS_CIPHER_AES_GCM_128))
243 case TLS_CIPHER_AES_GCM_128: {
244 struct tls12_crypto_info_aes_gcm_128 *info =
245 (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
246
247 rec_seq = info->rec_seq;
248 rec_seq_sz = sizeof(info->rec_seq);
249 break;
250 }
251 default:
252 WARN_ON(1);
253 return; 238 return;
254 } 239
240 info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
241 rec_seq = info->rec_seq;
242 rec_seq_sz = sizeof(info->rec_seq);
255 243
256 skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz); 244 skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);
257 if (!skip_static_post) 245 if (!skip_static_post)