Skip to content

Commit 6248ce9

Browse files
Huy NguyenSaeed Mahameed
authored andcommitted
net/mlx5e: Fix IPsec packet drop by mlx5e_tc_update_skb
Both TC and IPsec crypto offload use metadata_regB to store private information. Since TC does not use bit 31 of regB, IPsec will use bit 31 as the IPsec packet marker. The IPsec's regB usage is changed to: Bit31: IPsec marker Bit30-24: IPsec syndrome Bit23-0: IPsec obj id Fixes: b2ac754 ("net/mlx5e: IPsec: Add Connect-X IPsec Rx data path offload") Signed-off-by: Huy Nguyen <huyn@mellanox.com> Reviewed-by: Raed Salem <raeds@nvidia.com> Reviewed-by: Ariel Levkovich <lariel@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 5cfb540 commit 6248ce9

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ static int rx_err_add_rule(struct mlx5e_priv *priv,
6464
if (!spec)
6565
return -ENOMEM;
6666

67-
/* Action to copy 7 bit ipsec_syndrome to regB[0:6] */
67+
/* Action to copy 7 bit ipsec_syndrome to regB[24:30] */
6868
MLX5_SET(copy_action_in, action, action_type, MLX5_ACTION_TYPE_COPY);
6969
MLX5_SET(copy_action_in, action, src_field, MLX5_ACTION_IN_FIELD_IPSEC_SYNDROME);
7070
MLX5_SET(copy_action_in, action, src_offset, 0);
7171
MLX5_SET(copy_action_in, action, length, 7);
7272
MLX5_SET(copy_action_in, action, dst_field, MLX5_ACTION_IN_FIELD_METADATA_REG_B);
73-
MLX5_SET(copy_action_in, action, dst_offset, 0);
73+
MLX5_SET(copy_action_in, action, dst_offset, 24);
7474

7575
modify_hdr = mlx5_modify_header_alloc(mdev, MLX5_FLOW_NAMESPACE_KERNEL,
7676
1, action);
@@ -488,13 +488,13 @@ static int rx_add_rule(struct mlx5e_priv *priv,
488488

489489
setup_fte_common(attrs, ipsec_obj_id, spec, &flow_act);
490490

491-
/* Set 1 bit ipsec marker */
492-
/* Set 24 bit ipsec_obj_id */
491+
/* Set bit[31] ipsec marker */
492+
/* Set bit[23-0] ipsec_obj_id */
493493
MLX5_SET(set_action_in, action, action_type, MLX5_ACTION_TYPE_SET);
494494
MLX5_SET(set_action_in, action, field, MLX5_ACTION_IN_FIELD_METADATA_REG_B);
495-
MLX5_SET(set_action_in, action, data, (ipsec_obj_id << 1) | 0x1);
496-
MLX5_SET(set_action_in, action, offset, 7);
497-
MLX5_SET(set_action_in, action, length, 25);
495+
MLX5_SET(set_action_in, action, data, (ipsec_obj_id | BIT(31)));
496+
MLX5_SET(set_action_in, action, offset, 0);
497+
MLX5_SET(set_action_in, action, length, 32);
498498

499499
modify_hdr = mlx5_modify_header_alloc(priv->mdev, MLX5_FLOW_NAMESPACE_KERNEL,
500500
1, action);

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ void mlx5e_ipsec_offload_handle_rx_skb(struct net_device *netdev,
453453
struct mlx5_cqe64 *cqe)
454454
{
455455
u32 ipsec_meta_data = be32_to_cpu(cqe->ft_metadata);
456-
u8 ipsec_syndrome = ipsec_meta_data & 0xFF;
457456
struct mlx5e_priv *priv;
458457
struct xfrm_offload *xo;
459458
struct xfrm_state *xs;
@@ -481,7 +480,7 @@ void mlx5e_ipsec_offload_handle_rx_skb(struct net_device *netdev,
481480
xo = xfrm_offload(skb);
482481
xo->flags = CRYPTO_DONE;
483482

484-
switch (ipsec_syndrome & MLX5_IPSEC_METADATA_SYNDROM_MASK) {
483+
switch (MLX5_IPSEC_METADATA_SYNDROM(ipsec_meta_data)) {
485484
case MLX5E_IPSEC_OFFLOAD_RX_SYNDROME_DECRYPTED:
486485
xo->status = CRYPTO_SUCCESS;
487486
if (WARN_ON_ONCE(priv->ipsec->no_trailer))

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
#include "en.h"
4040
#include "en/txrx.h"
4141

42-
#define MLX5_IPSEC_METADATA_MARKER_MASK (0x80)
43-
#define MLX5_IPSEC_METADATA_SYNDROM_MASK (0x7F)
44-
#define MLX5_IPSEC_METADATA_HANDLE(metadata) (((metadata) >> 8) & 0xFF)
42+
/* Bit31: IPsec marker, Bit30-24: IPsec syndrome, Bit23-0: IPsec obj id */
43+
#define MLX5_IPSEC_METADATA_MARKER(metadata) (((metadata) >> 31) & 0x1)
44+
#define MLX5_IPSEC_METADATA_SYNDROM(metadata) (((metadata) >> 24) & GENMASK(6, 0))
45+
#define MLX5_IPSEC_METADATA_HANDLE(metadata) ((metadata) & GENMASK(23, 0))
4546

4647
struct mlx5e_accel_tx_ipsec_state {
4748
struct xfrm_offload *xo;
@@ -78,7 +79,7 @@ static inline unsigned int mlx5e_ipsec_tx_ids_len(struct mlx5e_accel_tx_ipsec_st
7879

7980
static inline bool mlx5_ipsec_is_rx_flow(struct mlx5_cqe64 *cqe)
8081
{
81-
return !!(MLX5_IPSEC_METADATA_MARKER_MASK & be32_to_cpu(cqe->ft_metadata));
82+
return MLX5_IPSEC_METADATA_MARKER(be32_to_cpu(cqe->ft_metadata));
8283
}
8384

8485
static inline bool mlx5e_ipsec_is_tx_flow(struct mlx5e_accel_tx_ipsec_state *ipsec_st)

drivers/net/ethernet/mellanox/mlx5/core/en_tc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ static inline bool mlx5e_cqe_regb_chain(struct mlx5_cqe64 *cqe)
283283

284284
reg_b = be32_to_cpu(cqe->ft_metadata);
285285

286+
if (reg_b >> (MLX5E_TC_TABLE_CHAIN_TAG_BITS + ZONE_RESTORE_BITS))
287+
return false;
288+
286289
chain = reg_b & MLX5E_TC_TABLE_CHAIN_TAG_MASK;
287290
if (chain)
288291
return true;

0 commit comments

Comments
 (0)