Skip to content

Commit e227ee9

Browse files
Lior Nahmansondavem330
authored andcommitted
net/mlx5: Generalize Flow Context for new crypto fields
In order to support MACsec offload (and maybe some other crypto features in the future), generalize flow action parameters / defines to be used by crypto offlaods other than IPsec. The following changes made: ipsec_obj_id field at flow action context was changed to crypto_obj_id, intreduced a new crypto_type field where IPsec is the default zero type for backward compatibility. Action ipsec_decrypt was changed to crypto_decrypt. Action ipsec_encrypt was changed to crypto_encrypt. IPsec offload code was updated accordingly for backward compatibility. Signed-off-by: Lior Nahmanson <[email protected]> Reviewed-by: Raed Salem <[email protected]> Signed-off-by: Raed Salem <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d1b2234 commit e227ee9

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ static void setup_fte_common(struct mlx5_accel_esp_xfrm_attrs *attrs,
388388
0xff, 16);
389389
}
390390

391-
flow_act->ipsec_obj_id = ipsec_obj_id;
391+
flow_act->crypto.type = MLX5_FLOW_CONTEXT_ENCRYPT_DECRYPT_TYPE_IPSEC;
392+
flow_act->crypto.obj_id = ipsec_obj_id;
392393
flow_act->flags |= FLOW_ACT_NO_APPEND;
393394
}
394395

@@ -444,7 +445,7 @@ static int rx_add_rule(struct mlx5e_priv *priv,
444445
}
445446

446447
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
447-
MLX5_FLOW_CONTEXT_ACTION_IPSEC_DECRYPT |
448+
MLX5_FLOW_CONTEXT_ACTION_CRYPTO_DECRYPT |
448449
MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
449450
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
450451
flow_act.modify_hdr = modify_hdr;
@@ -500,7 +501,7 @@ static int tx_add_rule(struct mlx5e_priv *priv,
500501
MLX5_ETH_WQE_FT_META_IPSEC);
501502

502503
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_ALLOW |
503-
MLX5_FLOW_CONTEXT_ACTION_IPSEC_ENCRYPT;
504+
MLX5_FLOW_CONTEXT_ACTION_CRYPTO_ENCRYPT;
504505
rule = mlx5_add_flow_rules(priv->ipsec->tx_fs->ft, spec, &flow_act, NULL, 0);
505506
if (IS_ERR(rule)) {
506507
err = PTR_ERR(rule);

drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,10 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
577577
MLX5_SET(flow_context, in_flow_context, modify_header_id,
578578
fte->action.modify_hdr->id);
579579

580-
MLX5_SET(flow_context, in_flow_context, ipsec_obj_id, fte->action.ipsec_obj_id);
580+
MLX5_SET(flow_context, in_flow_context, encrypt_decrypt_type,
581+
fte->action.crypto.type);
582+
MLX5_SET(flow_context, in_flow_context, encrypt_decrypt_obj_id,
583+
fte->action.crypto.obj_id);
581584

582585
vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan);
583586

include/linux/mlx5/fs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ struct mlx5_flow_act {
243243
u32 action;
244244
struct mlx5_modify_hdr *modify_hdr;
245245
struct mlx5_pkt_reformat *pkt_reformat;
246-
union {
247-
u32 ipsec_obj_id;
248-
};
246+
struct mlx5_flow_act_crypto_params {
247+
u8 type;
248+
u32 obj_id;
249+
} crypto;
249250
u32 flags;
250251
struct mlx5_fs_vlan vlan[MLX5_FS_VLAN_DEPTH];
251252
struct ib_counters *counters;

include/linux/mlx5/mlx5_ifc.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3310,8 +3310,8 @@ enum {
33103310
MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH = 0x100,
33113311
MLX5_FLOW_CONTEXT_ACTION_VLAN_POP_2 = 0x400,
33123312
MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH_2 = 0x800,
3313-
MLX5_FLOW_CONTEXT_ACTION_IPSEC_DECRYPT = 0x1000,
3314-
MLX5_FLOW_CONTEXT_ACTION_IPSEC_ENCRYPT = 0x2000,
3313+
MLX5_FLOW_CONTEXT_ACTION_CRYPTO_DECRYPT = 0x1000,
3314+
MLX5_FLOW_CONTEXT_ACTION_CRYPTO_ENCRYPT = 0x2000,
33153315
MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO = 0x4000,
33163316
};
33173317

@@ -3321,6 +3321,10 @@ enum {
33213321
MLX5_FLOW_CONTEXT_FLOW_SOURCE_LOCAL_VPORT = 0x2,
33223322
};
33233323

3324+
enum {
3325+
MLX5_FLOW_CONTEXT_ENCRYPT_DECRYPT_TYPE_IPSEC = 0x0,
3326+
};
3327+
33243328
struct mlx5_ifc_vlan_bits {
33253329
u8 ethtype[0x10];
33263330
u8 prio[0x3];
@@ -3374,7 +3378,7 @@ struct mlx5_ifc_flow_context_bits {
33743378
u8 extended_destination[0x1];
33753379
u8 reserved_at_81[0x1];
33763380
u8 flow_source[0x2];
3377-
u8 reserved_at_84[0x4];
3381+
u8 encrypt_decrypt_type[0x4];
33783382
u8 destination_list_size[0x18];
33793383

33803384
u8 reserved_at_a0[0x8];
@@ -3386,7 +3390,7 @@ struct mlx5_ifc_flow_context_bits {
33863390

33873391
struct mlx5_ifc_vlan_bits push_vlan_2;
33883392

3389-
u8 ipsec_obj_id[0x20];
3393+
u8 encrypt_decrypt_obj_id[0x20];
33903394
u8 reserved_at_140[0xc0];
33913395

33923396
struct mlx5_ifc_fte_match_param_bits match_value;

0 commit comments

Comments
 (0)