Skip to content

Commit 37d244a

Browse files
rleonklassert
authored andcommitted
net/mlx5e: Open mlx5 driver to accept IPsec packet offload
Enable configuration of IPsec packet offload through XFRM state add interface together with moving specific to IPsec packet mode limitations to specific switch-case section. Reviewed-by: Raed Salem <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent cee137a commit 37d244a

File tree

1 file changed

+31
-10
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

1 file changed

+31
-10
lines changed

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

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,6 @@ static inline int mlx5e_xfrm_validate_state(struct xfrm_state *x)
191191
netdev_info(netdev, "Only IPv4/6 xfrm states may be offloaded\n");
192192
return -EINVAL;
193193
}
194-
if (x->props.mode != XFRM_MODE_TRANSPORT &&
195-
x->props.mode != XFRM_MODE_TUNNEL) {
196-
dev_info(&netdev->dev, "Only transport and tunnel xfrm states may be offloaded\n");
197-
return -EINVAL;
198-
}
199194
if (x->id.proto != IPPROTO_ESP) {
200195
netdev_info(netdev, "Only ESP xfrm state may be offloaded\n");
201196
return -EINVAL;
@@ -229,11 +224,32 @@ static inline int mlx5e_xfrm_validate_state(struct xfrm_state *x)
229224
netdev_info(netdev, "Cannot offload xfrm states with geniv other than seqiv\n");
230225
return -EINVAL;
231226
}
232-
if (x->xso.type != XFRM_DEV_OFFLOAD_CRYPTO) {
233-
netdev_info(netdev, "Unsupported xfrm offload type\n");
234-
return -EINVAL;
235-
}
236-
if (x->xso.type == XFRM_DEV_OFFLOAD_PACKET) {
227+
switch (x->xso.type) {
228+
case XFRM_DEV_OFFLOAD_CRYPTO:
229+
if (!(mlx5_ipsec_device_caps(priv->mdev) &
230+
MLX5_IPSEC_CAP_CRYPTO)) {
231+
netdev_info(netdev, "Crypto offload is not supported\n");
232+
return -EINVAL;
233+
}
234+
235+
if (x->props.mode != XFRM_MODE_TRANSPORT &&
236+
x->props.mode != XFRM_MODE_TUNNEL) {
237+
netdev_info(netdev, "Only transport and tunnel xfrm states may be offloaded\n");
238+
return -EINVAL;
239+
}
240+
break;
241+
case XFRM_DEV_OFFLOAD_PACKET:
242+
if (!(mlx5_ipsec_device_caps(priv->mdev) &
243+
MLX5_IPSEC_CAP_PACKET_OFFLOAD)) {
244+
netdev_info(netdev, "Packet offload is not supported\n");
245+
return -EINVAL;
246+
}
247+
248+
if (x->props.mode != XFRM_MODE_TRANSPORT) {
249+
netdev_info(netdev, "Only transport xfrm states may be offloaded in packet mode\n");
250+
return -EINVAL;
251+
}
252+
237253
if (x->replay_esn && x->replay_esn->replay_window != 32 &&
238254
x->replay_esn->replay_window != 64 &&
239255
x->replay_esn->replay_window != 128 &&
@@ -263,6 +279,11 @@ static inline int mlx5e_xfrm_validate_state(struct xfrm_state *x)
263279
"Hard packet limit must be greater than soft one\n");
264280
return -EINVAL;
265281
}
282+
break;
283+
default:
284+
netdev_info(netdev, "Unsupported xfrm offload type %d\n",
285+
x->xso.type);
286+
return -EINVAL;
266287
}
267288
return 0;
268289
}

0 commit comments

Comments
 (0)