Skip to content

Commit edd8b29

Browse files
committed
Merge branch 'mlx5-ipsec-packet-offload-support-in-eswitch-mode'
Leon Romanovsky says: ==================== mlx5 IPsec packet offload support in eswitch mode This series from Jianbo adds mlx5 IPsec packet offload support in eswitch offloaded mode. It works exactly like "regular" IPsec, nothing special, except now users can switch to switchdev before adding IPsec rules. devlink dev eswitch set pci/0000:06:00.0 mode switchdev Same configurations as here: https://lore.kernel.org/netdev/[email protected]/ Packet offload mode: ip xfrm state offload packet dev <if-name> dir <in|out> ip xfrm policy .... offload packet dev <if-name> Crypto offload mode: ip xfrm state offload crypto dev <if-name> dir <in|out> or (backward compatibility) ip xfrm state offload dev <if-name> dir <in|out> v0: https://lore.kernel.org/all/[email protected] ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 30ff01e + c8e350e commit edd8b29

File tree

19 files changed

+1270
-217
lines changed

19 files changed

+1270
-217
lines changed

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ mlx5_core-$(CONFIG_MLX5_ESWITCH) += esw/acl/helper.o \
7575
esw/acl/egress_lgcy.o esw/acl/egress_ofld.o \
7676
esw/acl/ingress_lgcy.o esw/acl/ingress_ofld.o
7777

78+
ifneq ($(CONFIG_MLX5_EN_IPSEC),)
79+
mlx5_core-$(CONFIG_MLX5_ESWITCH) += esw/ipsec_fs.o
80+
endif
81+
7882
mlx5_core-$(CONFIG_MLX5_BRIDGE) += esw/bridge.o esw/bridge_mcast.o esw/bridge_debugfs.o \
7983
en/rep/bridge.o
8084

drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,20 @@ void mlx5e_rep_tc_receive(struct mlx5_cqe64 *cqe, struct mlx5e_rq *rq,
715715
uplink_priv = &uplink_rpriv->uplink_priv;
716716
ct_priv = uplink_priv->ct_priv;
717717

718-
if (!mlx5_ipsec_is_rx_flow(cqe) &&
719-
!mlx5e_tc_update_skb(cqe, skb, mapping_ctx, reg_c0, ct_priv, zone_restore_id, tunnel_id,
720-
&tc_priv))
718+
#ifdef CONFIG_MLX5_EN_IPSEC
719+
if (!(tunnel_id >> ESW_TUN_OPTS_BITS)) {
720+
u32 mapped_id;
721+
u32 metadata;
722+
723+
mapped_id = tunnel_id & ESW_IPSEC_RX_MAPPED_ID_MASK;
724+
if (mapped_id &&
725+
!mlx5_esw_ipsec_rx_make_metadata(priv, mapped_id, &metadata))
726+
mlx5e_ipsec_offload_handle_rx_skb(priv->netdev, skb, metadata);
727+
}
728+
#endif
729+
730+
if (!mlx5e_tc_update_skb(cqe, skb, mapping_ctx, reg_c0, ct_priv,
731+
zone_restore_id, tunnel_id, &tc_priv))
721732
goto free_skb;
722733

723734
forward:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "en.h"
4141
#include "ipsec.h"
4242
#include "ipsec_rxtx.h"
43+
#include "en_rep.h"
4344

4445
#define MLX5_IPSEC_RESCHED msecs_to_jiffies(1000)
4546
#define MLX5E_IPSEC_TUNNEL_SA XA_MARK_1
@@ -858,6 +859,7 @@ void mlx5e_ipsec_init(struct mlx5e_priv *priv)
858859
goto clear_aso;
859860
}
860861

862+
ipsec->is_uplink_rep = mlx5e_is_uplink_rep(priv);
861863
ret = mlx5e_accel_ipsec_fs_init(ipsec);
862864
if (ret)
863865
goto err_fs_init;

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

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct mlx5e_ipsec_sw_stats {
143143
atomic64_t ipsec_tx_drop_trailer;
144144
};
145145

146-
struct mlx5e_ipsec_rx;
146+
struct mlx5e_ipsec_fc;
147147
struct mlx5e_ipsec_tx;
148148

149149
struct mlx5e_ipsec_work {
@@ -169,6 +169,58 @@ struct mlx5e_ipsec_aso {
169169
spinlock_t lock;
170170
};
171171

172+
struct mlx5e_ipsec_rx_create_attr {
173+
struct mlx5_flow_namespace *ns;
174+
struct mlx5_ttc_table *ttc;
175+
u32 family;
176+
int prio;
177+
int pol_level;
178+
int sa_level;
179+
int status_level;
180+
enum mlx5_flow_namespace_type chains_ns;
181+
};
182+
183+
struct mlx5e_ipsec_ft {
184+
struct mutex mutex; /* Protect changes to this struct */
185+
struct mlx5_flow_table *pol;
186+
struct mlx5_flow_table *sa;
187+
struct mlx5_flow_table *status;
188+
u32 refcnt;
189+
};
190+
191+
struct mlx5e_ipsec_rule {
192+
struct mlx5_flow_handle *rule;
193+
struct mlx5_modify_hdr *modify_hdr;
194+
struct mlx5_pkt_reformat *pkt_reformat;
195+
struct mlx5_fc *fc;
196+
};
197+
198+
struct mlx5e_ipsec_miss {
199+
struct mlx5_flow_group *group;
200+
struct mlx5_flow_handle *rule;
201+
};
202+
203+
struct mlx5e_ipsec_rx {
204+
struct mlx5e_ipsec_ft ft;
205+
struct mlx5e_ipsec_miss pol;
206+
struct mlx5e_ipsec_miss sa;
207+
struct mlx5e_ipsec_rule status;
208+
struct mlx5e_ipsec_miss status_drop;
209+
struct mlx5_fc *status_drop_cnt;
210+
struct mlx5e_ipsec_fc *fc;
211+
struct mlx5_fs_chains *chains;
212+
u8 allow_tunnel_mode : 1;
213+
struct xarray ipsec_obj_id_map;
214+
};
215+
216+
struct mlx5e_ipsec_tx_create_attr {
217+
int prio;
218+
int pol_level;
219+
int sa_level;
220+
int cnt_level;
221+
enum mlx5_flow_namespace_type chains_ns;
222+
};
223+
172224
struct mlx5e_ipsec {
173225
struct mlx5_core_dev *mdev;
174226
struct xarray sadb;
@@ -178,11 +230,14 @@ struct mlx5e_ipsec {
178230
struct mlx5e_flow_steering *fs;
179231
struct mlx5e_ipsec_rx *rx_ipv4;
180232
struct mlx5e_ipsec_rx *rx_ipv6;
233+
struct mlx5e_ipsec_rx *rx_esw;
181234
struct mlx5e_ipsec_tx *tx;
235+
struct mlx5e_ipsec_tx *tx_esw;
182236
struct mlx5e_ipsec_aso *aso;
183237
struct notifier_block nb;
184238
struct notifier_block netevent_nb;
185239
struct mlx5_ipsec_fs *roce;
240+
u8 is_uplink_rep: 1;
186241
};
187242

188243
struct mlx5e_ipsec_esn_state {
@@ -191,13 +246,6 @@ struct mlx5e_ipsec_esn_state {
191246
u8 overlap: 1;
192247
};
193248

194-
struct mlx5e_ipsec_rule {
195-
struct mlx5_flow_handle *rule;
196-
struct mlx5_modify_hdr *modify_hdr;
197-
struct mlx5_pkt_reformat *pkt_reformat;
198-
struct mlx5_fc *fc;
199-
};
200-
201249
struct mlx5e_ipsec_limits {
202250
u64 round;
203251
u8 soft_limit_hit : 1;
@@ -217,6 +265,7 @@ struct mlx5e_ipsec_sa_entry {
217265
struct mlx5e_ipsec_work *work;
218266
struct mlx5e_ipsec_dwork *dwork;
219267
struct mlx5e_ipsec_limits limits;
268+
u32 rx_mapped_id;
220269
};
221270

222271
struct mlx5_accel_pol_xfrm_attrs {

0 commit comments

Comments
 (0)