Skip to content

Commit b8c697e

Browse files
rleonSaeed Mahameed
authored andcommitted
net/mlx5e: Support IPsec upper TCP protocol selector
Support TCP as protocol selector for policy and state in IPsec packet offload mode. Example of state configuration is as follows: ip xfrm state add src 192.168.25.3 dst 192.168.25.1 \ proto esp spi 1001 reqid 10001 aead 'rfc4106(gcm(aes))' \ 0x54a7588d36873b031e4bd46301be5a86b3a53879 128 mode transport \ offload packet dev re0 dir in sel src 192.168.25.3 dst 192.168.25.1 \ proto tcp dport 9003 Acked-by: Raed Salem <raeds@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent c338325 commit b8c697e

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,9 @@ static int mlx5e_xfrm_validate_state(struct mlx5_core_dev *mdev,
440440
return -EINVAL;
441441
}
442442

443-
if (x->sel.proto != IPPROTO_IP && x->sel.proto != IPPROTO_UDP) {
444-
NL_SET_ERR_MSG_MOD(extack, "Device does not support upper protocol other than UDP");
443+
if (x->sel.proto != IPPROTO_IP && x->sel.proto != IPPROTO_UDP &&
444+
x->sel.proto != IPPROTO_TCP) {
445+
NL_SET_ERR_MSG_MOD(extack, "Device does not support upper protocol other than TCP/UDP");
445446
return -EINVAL;
446447
}
447448

@@ -982,8 +983,10 @@ static int mlx5e_xfrm_validate_policy(struct mlx5_core_dev *mdev,
982983
return -EINVAL;
983984
}
984985

985-
if (x->selector.proto != IPPROTO_IP && x->selector.proto != IPPROTO_UDP) {
986-
NL_SET_ERR_MSG_MOD(extack, "Device does not support upper protocol other than UDP");
986+
if (x->selector.proto != IPPROTO_IP &&
987+
x->selector.proto != IPPROTO_UDP &&
988+
x->selector.proto != IPPROTO_TCP) {
989+
NL_SET_ERR_MSG_MOD(extack, "Device does not support upper protocol other than TCP/UDP");
987990
return -EINVAL;
988991
}
989992

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

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -936,23 +936,42 @@ static void setup_fte_reg_c4(struct mlx5_flow_spec *spec, u32 reqid)
936936

937937
static void setup_fte_upper_proto_match(struct mlx5_flow_spec *spec, struct upspec *upspec)
938938
{
939-
if (upspec->proto != IPPROTO_UDP)
939+
switch (upspec->proto) {
940+
case IPPROTO_UDP:
941+
if (upspec->dport) {
942+
MLX5_SET(fte_match_set_lyr_2_4, spec->match_criteria,
943+
udp_dport, upspec->dport_mask);
944+
MLX5_SET(fte_match_set_lyr_2_4, spec->match_value,
945+
udp_dport, upspec->dport);
946+
}
947+
if (upspec->sport) {
948+
MLX5_SET(fte_match_set_lyr_2_4, spec->match_criteria,
949+
udp_sport, upspec->sport_mask);
950+
MLX5_SET(fte_match_set_lyr_2_4, spec->match_value,
951+
udp_sport, upspec->sport);
952+
}
953+
break;
954+
case IPPROTO_TCP:
955+
if (upspec->dport) {
956+
MLX5_SET(fte_match_set_lyr_2_4, spec->match_criteria,
957+
tcp_dport, upspec->dport_mask);
958+
MLX5_SET(fte_match_set_lyr_2_4, spec->match_value,
959+
tcp_dport, upspec->dport);
960+
}
961+
if (upspec->sport) {
962+
MLX5_SET(fte_match_set_lyr_2_4, spec->match_criteria,
963+
tcp_sport, upspec->sport_mask);
964+
MLX5_SET(fte_match_set_lyr_2_4, spec->match_value,
965+
tcp_sport, upspec->sport);
966+
}
967+
break;
968+
default:
940969
return;
970+
}
941971

942972
spec->match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS;
943973
MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, spec->match_criteria, ip_protocol);
944974
MLX5_SET(fte_match_set_lyr_2_4, spec->match_value, ip_protocol, upspec->proto);
945-
if (upspec->dport) {
946-
MLX5_SET(fte_match_set_lyr_2_4, spec->match_criteria, udp_dport,
947-
upspec->dport_mask);
948-
MLX5_SET(fte_match_set_lyr_2_4, spec->match_value, udp_dport, upspec->dport);
949-
}
950-
951-
if (upspec->sport) {
952-
MLX5_SET(fte_match_set_lyr_2_4, spec->match_criteria, udp_sport,
953-
upspec->sport_mask);
954-
MLX5_SET(fte_match_set_lyr_2_4, spec->match_value, udp_sport, upspec->sport);
955-
}
956975
}
957976

958977
static enum mlx5_flow_namespace_type ipsec_fs_get_ns(struct mlx5e_ipsec *ipsec,

0 commit comments

Comments
 (0)