net/mlx5e: Fix MACsec initial packet number
authorEmeel Hakim <ehakim@nvidia.com>
Wed, 21 Sep 2022 18:10:48 +0000 (11:10 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 23 Sep 2022 01:01:32 +0000 (18:01 -0700)
Currently when creating MACsec object, next_pn which represents
the initial packet number (PN) is considered only in TX flow.
The above causes mismatch between TX and RX initial PN which
is reflected in packet drops.
Fix by considering next_pn in RX flow too.

Fixes: aae3454e4d4c ("net/mlx5e: Add MACsec offload Rx command support")
Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c

index 0600c03ccc735934d603bfe8ca2b53f71c0234c8..5162863fa630db3b2b1cfd16e9e4e2ea60fdd92c 100644 (file)
@@ -107,12 +107,11 @@ static int mlx5e_macsec_create_object(struct mlx5_core_dev *mdev,
        MLX5_SET64(macsec_offload_obj, obj, sci, (__force u64)(attrs->sci));
        MLX5_SET(macsec_offload_obj, obj, aso_return_reg, MLX5_MACSEC_ASO_REG_C_4_5);
        MLX5_SET(macsec_offload_obj, obj, macsec_aso_access_pd, attrs->aso_pdn);
+       MLX5_SET(macsec_aso, aso_ctx, mode_parameter, attrs->next_pn);
 
        MLX5_SET(macsec_aso, aso_ctx, valid, 0x1);
-       if (is_tx) {
+       if (is_tx)
                MLX5_SET(macsec_aso, aso_ctx, mode, MLX5_MACSEC_ASO_INC_SN);
-               MLX5_SET(macsec_aso, aso_ctx, mode_parameter, attrs->next_pn);
-       }
 
        /* general object fields set */
        MLX5_SET(general_obj_in_cmd_hdr, in, opcode, MLX5_CMD_OP_CREATE_GENERAL_OBJECT);