Skip to content

Commit

Permalink
net/mlx5/hws: fix tunnel protocol checks
Browse files Browse the repository at this point in the history
[ upstream commit 28e69588f4170f29b73a04fc3bffba2596305782 ]

Align GRE, GTPU and VXLAN tunnel protocols to fail
in case the packet is already tunneled. Also use local
defines for protocol UDP ports for better layering of
mlx5dr API.

Fixes: c55c2bf ("net/mlx5/hws: add definer layer")
Fixes: 5bf14a4beb1a ("net/mlx5/hws: support matching on MPLSoUDP")

Signed-off-by: Alex Vesker <valex@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
  • Loading branch information
alexvesker authored and bluca committed Mar 7, 2024
1 parent 77d9b5e commit 02373cf
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions drivers/net/mlx5/hws/mlx5dr_definer.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define BAD_PORT 0xBAD
#define ETH_TYPE_IPV4_VXLAN 0x0800
#define ETH_TYPE_IPV6_VXLAN 0x86DD
#define ETH_VXLAN_DEFAULT_PORT 4789
#define UDP_VXLAN_PORT 4789

#define STE_NO_VLAN 0x0
#define STE_SVLAN 0x1
Expand Down Expand Up @@ -153,7 +153,7 @@ struct mlx5dr_definer_conv_data {
X(SET, gtp_ext_hdr_pdu, v->hdr.type, rte_flow_item_gtp_psc) \
X(SET, gtp_ext_hdr_qfi, v->hdr.qfi, rte_flow_item_gtp_psc) \
X(SET, vxlan_flags, v->flags, rte_flow_item_vxlan) \
X(SET, vxlan_udp_port, ETH_VXLAN_DEFAULT_PORT, rte_flow_item_vxlan) \
X(SET, vxlan_udp_port, UDP_VXLAN_PORT, rte_flow_item_vxlan) \
X(SET, source_qp, v->queue, mlx5_rte_flow_item_sq) \
X(SET, tag, v->data, rte_flow_item_tag) \
X(SET, metadata, v->data, rte_flow_item_meta) \
Expand Down Expand Up @@ -824,6 +824,12 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
const struct rte_flow_item_gtp *m = item->mask;
struct mlx5dr_definer_fc *fc;

if (cd->tunnel) {
DR_LOG(ERR, "Inner GTPU item not supported");
rte_errno = ENOTSUP;
return rte_errno;
}

/* Overwrite GTPU dest port if not present */
fc = &cd->fc[DR_CALC_FNAME(L4_DPORT, false)];
if (!fc->tag_set && !cd->relaxed) {
Expand Down Expand Up @@ -996,9 +1002,13 @@ mlx5dr_definer_conv_item_vxlan(struct mlx5dr_definer_conv_data *cd,
struct mlx5dr_definer_fc *fc;
bool inner = cd->tunnel;

/* In order to match on VXLAN we must match on ether_type, ip_protocol
* and l4_dport.
*/
if (inner) {
DR_LOG(ERR, "Inner VXLAN item not supported");
rte_errno = ENOTSUP;
return rte_errno;
}

/* In order to match on VXLAN we must match on ip_protocol and l4_dport */
if (!cd->relaxed) {
fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, inner)];
if (!fc->tag_set) {
Expand All @@ -1021,12 +1031,6 @@ mlx5dr_definer_conv_item_vxlan(struct mlx5dr_definer_conv_data *cd,
return 0;

if (m->flags) {
if (inner) {
DR_LOG(ERR, "Inner VXLAN flags item not supported");
rte_errno = ENOTSUP;
return rte_errno;
}

fc = &cd->fc[MLX5DR_DEFINER_FNAME_VXLAN_FLAGS];
fc->item_idx = item_idx;
fc->tag_set = &mlx5dr_definer_vxlan_flags_set;
Expand All @@ -1036,12 +1040,6 @@ mlx5dr_definer_conv_item_vxlan(struct mlx5dr_definer_conv_data *cd,
}

if (!is_mem_zero(m->vni, 3)) {
if (inner) {
DR_LOG(ERR, "Inner VXLAN vni item not supported");
rte_errno = ENOTSUP;
return rte_errno;
}

fc = &cd->fc[MLX5DR_DEFINER_FNAME_VXLAN_VNI];
fc->item_idx = item_idx;
fc->tag_set = &mlx5dr_definer_vxlan_vni_set;
Expand Down

0 comments on commit 02373cf

Please sign in to comment.