support VXLAN header last 8-bits matching
Subsystems (3)
cover support VXLAN header last 8-bits matching
This update adds support for the VXLAN last 8-bits matching when creating steering rules. At the PCIe probe stage, we create a dummy VXLAN matcher using misc5 to check rdma-core library's capability.
The logic is, group 0 depends on HCA_CAP to enable misc or misc5 for VXLAN matching while group non zero depends on the rdma-core capability.
Add a new testpmd pattern field 'last_rsvd' that supports the last 8-bits matching of VXLAN header.
The examples for the "last_rsvd" pattern field are as below:
1. ...pattern eth / ipv4 / udp / vxlan last_rsvd is 0x80 / end ... This flow will exactly match the last 8-bits to be 0x80.
2. ...pattern eth / ipv4 / udp / vxlan last_rsvd spec 0x80 vxlan mask 0x80 / end ...
This flow will only match the MSB of the last 8-bits to be 1.
rongwei liu (2):
drivers: add VXLAN header the last 8-bits matching support app/testpmd: support VXLAN last 8-bits field matching
app/test-pmd/cmdline_flow.c | 9 ++ app/test-pmd/util.c | 5 +- doc/guides/nics/mlx5.rst | 11 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 1 + drivers/common/mlx5/mlx5_devx_cmds.c | 3 + drivers/common/mlx5/mlx5_devx_cmds.h | 6 + drivers/common/mlx5/mlx5_prm.h | 41 +++++- drivers/net/mlx5/linux/mlx5_os.c | 77 ++++++++++ drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.c | 26 +++- drivers/net/mlx5/mlx5_flow.h | 4 +- drivers/net/mlx5/mlx5_flow_dv.c | 152 ++++++++++++++------ drivers/net/mlx5/mlx5_flow_verbs.c | 3 +- drivers/vdpa/mlx5/mlx5_vdpa_steer.c | 6 +- 14 files changed, 283 insertions(+), 63 deletions(-)
Signature · 1 line
2.27.0
RFC 1/2 drivers: add VXLAN header the last 8-bits matching support
This update adds support for the VXLAN alert bits matching when creating steering rules. At the PCIe probe stage, we create a dummy VXLAN matcher using misc5 to check rdma-core library's capability.
The logic is, group 0 depends on HCA_CAP to enable misc or misc5 for VXLAN matching while group non zero depends on the rdma-core capability.
--- doc/guides/nics/mlx5.rst | 11 +- drivers/common/mlx5/mlx5_devx_cmds.c | 3 + drivers/common/mlx5/mlx5_devx_cmds.h | 6 ++ drivers/common/mlx5/mlx5_prm.h | 41 ++++++-- drivers/net/mlx5/linux/mlx5_os.c | 77 ++++++++++++++ drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.c | 26 ++++- drivers/net/mlx5/mlx5_flow.h | 4 +- drivers/net/mlx5/mlx5_flow_dv.c | 152 +++++++++++++++++++-------- drivers/net/mlx5/mlx5_flow_verbs.c | 3 +- drivers/vdpa/mlx5/mlx5_vdpa_steer.c | 6 +- 11 files changed, 270 insertions(+), 61 deletions(-)
doc/guides/nics/mlx5.rst +9 -2
@@ -186,8 +186,15 @@ Limitations size and ``txq_inline_min`` settings and may be from 2 (worst case forced by maximal inline settings) to 58. -- Flows with a VXLAN Network Identifier equal (or ends to be equal) - to 0 are not supported. +- Match on VXLAN supports the following fields only: + + - VNI + - Last reserved 8-bits + + Last reserved 8-bits matching is only supported When using DV flow + engine (``dv_flow_en`` = 1). + Group zero's behavior may differ which depends on FW. + Matching value equals 0 (value & mask) is not supported. - L3 VXLAN and VXLAN-GPE tunnels cannot be supported together with MPLSoGRE and MPLSoUDP.
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
@@ -947,6 +947,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->log_max_ft_sampler_num =MLX5_GET (flow_table_nic_cap, hcattr, flow_table_properties_nic_receive.log_max_ft_sampler_num); + attr->flow.tunnel_header_0_1 =MLX5_GET + (flow_table_nic_cap, hcattr, + ft_field_support_2_nic_receive.tunnel_header_0_1); attr->pkt_integrity_match =mlx5_devx_query_pkt_integrity_match (hcattr);/* Query HCA offloads for Ethernet protocol. */ memset (in,0 ,sizeof (in));
drivers/common/mlx5/mlx5_devx_cmds.h +6 -0
@@ -89,6 +89,11 @@ struct mlx5_hca_vdpa_attr {uint64_t doorbell_bar_offset; }; +struct mlx5_hca_flow_attr { +uint32_t tunnel_header_0_1; +uint32_t tunnel_header_2_3; +}; +/* HCA supports this number of time periods for LRO. */ #define MLX5_LRO_NUM_SUPP_PERIODS 4
@@ -155,6 +160,7 @@ struct mlx5_hca_attr { uint32_t pkt_integrity_match:1; /* 1 if HW supports integrity item */struct mlx5_hca_qos_attr qos;struct mlx5_hca_vdpa_attr vdpa; +struct mlx5_hca_flow_attr flow;int log_max_qp_sz;int log_max_cq_sz;int log_max_qp;
drivers/common/mlx5/mlx5_prm.h +34 -7
83 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_os.c +77 -0
95 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +2 -0
@@ -1071,6 +1071,8 @@ struct mlx5_dev_ctx_shared { uint32_t qp_ts_format:2; /* QP timestamp formats supported. */ uint32_t meter_aso_en:1; /* Flow Meter ASO is supported. */ uint32_t ct_aso_en:1; /* Connection Tracking ASO is supported. */ + uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */ + uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */uint32_t max_port;/* Maximal IB device port index. */ struct mlx5_bond_info bond;/* Bonding information. */ void *ctx;/* Verbs/DV/DevX context. */
drivers/net/mlx5/mlx5_flow.c +21 -5
@@ -2368,12 +2368,14 @@ mlx5_flow_validate_item_tcp(const struct rte_flow_item *item,/** * Validate VXLAN item. * +* @param[in] dev +* Pointer to the Ethernet device structure. * @param[in] item * Item specification. * @param[in] item_flags * Bit-fields that holds the items detected until now. -* @param[in] target_protocol -* The next protocol in the previous item. +* @param[in] attr +* Flow rule attributes. * @param[out] error * Pointer to error structure. *
@@ -2381,24 +2383,32 @@ mlx5_flow_validate_item_tcp(const struct rte_flow_item *item,* 0 on success, a negative errno value otherwise and rte_errno is set. */ int -mlx5_flow_validate_item_vxlan (const struct rte_flow_item *item, +mlx5_flow_validate_item_vxlan (struct rte_eth_dev *dev, +const struct rte_flow_item *item,uint64_t item_flags, +const struct rte_flow_attr *attr,struct rte_flow_error *error) {const struct rte_flow_item_vxlan *spec = item->spec;const struct rte_flow_item_vxlan *mask = item->mask;int ret; +struct mlx5_priv *priv = dev->data->dev_private;union vni {uint32_t vlan_id;uint8_t vni[4 ]; } id = { .vlan_id =0 , }; - +const struct rte_flow_item_vxlan nic_mask = { + .vni ="\xff\xff\xff" , + .rsvd1 =0xff , + }; +const struct rte_flow_item_vxlan *valid_mask;if (item_flags &MLX5_FLOW_LAYER_TUNNEL )return rte_flow_error_set (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ITEM , item,"multiple tunnel layers not" " supported" ); + valid_mask = &rte_flow_item_vxlan_mask;/* * Verify only UDPv4 is present as defined in * https://tools.ietf.org/html/rfc7348
@@ -2409,9 +2419,15 @@ mlx5_flow_validate_item_vxlan(const struct rte_flow_item *item, "no outer UDP layer found");if (!mask) mask = &rte_flow_item_vxlan_mask; +/* FDB domain & NIC domain non-zero group */ +if ((attr->transfer || attr->group) && priv->sh->misc5_cap) + valid_mask = &nic_mask; +/* Group zero in NIC domain */ +if (!attr->group && !attr->transfer && priv->sh->tunnel_header_0_1) + valid_mask = &nic_mask; ret =mlx5_flow_item_acceptable (item, (const uint8_t *)mask, - (const uint8_t *)&rte_flow_item_vxlan_mask, + (const uint8_t *)valid_mask,sizeof (struct rte_flow_item_vxlan ),MLX5_ITEM_RANGE_NOT_ACCEPTED , error);if (ret <0 )
drivers/net/mlx5/mlx5_flow.h +3 -1
@@ -1521,8 +1521,10 @@ int mlx5_flow_validate_item_vlan(const struct rte_flow_item *item,uint64_t item_flags, struct rte_eth_dev *dev, struct rte_flow_error *error); -int mlx5_flow_validate_item_vxlan (const struct rte_flow_item *item, +int mlx5_flow_validate_item_vxlan (struct rte_eth_dev *dev, +const struct rte_flow_item *item,uint64_t item_flags, +const struct rte_flow_attr *attr,struct rte_flow_error *error); int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item, uint64_t item_flags,
drivers/net/mlx5/mlx5_flow_dv.c +109 -43
313 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -1
@@ -1381,7 +1381,8 @@ flow_verbs_validate(struct rte_eth_dev *dev,MLX5_FLOW_LAYER_OUTER_L4_TCP ;break ;case RTE_FLOW_ITEM_TYPE_VXLAN : - ret =mlx5_flow_validate_item_vxlan (items, item_flags, + ret =mlx5_flow_validate_item_vxlan (dev, items, + item_flags, attr, error);if (ret <0 )return ret;
drivers/vdpa/mlx5/mlx5_vdpa_steer.c +4 -2
@@ -140,11 +140,13 @@ mlx5_vdpa_rss_flows_create(struct mlx5_vdpa_priv *priv)/**< Matcher value. This value is used as the mask or a key. */ } matcher_mask = { .size =sizeof (matcher_mask.buf) - -MLX5_ST_SZ_BYTES (fte_match_set_misc4), +MLX5_ST_SZ_BYTES (fte_match_set_misc4) - +MLX5_ST_SZ_BYTES (fte_match_set_misc5), }, matcher_value = { .size =sizeof (matcher_value.buf) - - MLX5_ST_SZ_BYTES(fte_match_set_misc4), +MLX5_ST_SZ_BYTES (fte_match_set_misc4) - + MLX5_ST_SZ_BYTES(fte_match_set_misc5), };struct mlx5dv_flow_matcher_attr dv_attr = { .type =IBV_FLOW_ATTR_NORMAL ,
Signature · 1 line
2.27.0
RFC 2/2 app/testpmd: support VXLAN last 8-bits field matching
In reply to rongwei liuAdd a new testpmd pattern field 'last_rsvd' that supports the last 8-bits matching of VXLAN header.
The examples for the "last_rsvd" pattern field are as below:
1. ...pattern eth / ipv4 / udp / vxlan last_rsvd is 0x80 / end ...
This flow will exactly match the last 8-bits to be 0x80.
2. ...pattern eth / ipv4 / udp / vxlan last_rsvd spec 0x80 vxlan mask 0x80 / end ...
This flow will only match the MSB of the last 8-bits to be 1.
--- app/test-pmd/cmdline_flow.c | 9 +++++++++ app/test-pmd/util.c | 5 +++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)
app/test-pmd/cmdline_flow.c +9 -0
@@ -207,6 +207,7 @@ enum index {ITEM_SCTP_CKSUM ,ITEM_VXLAN ,ITEM_VXLAN_VNI , +ITEM_VXLAN_LAST_RSVD ,ITEM_E_TAG ,ITEM_E_TAG_GRP_ECID_B , ITEM_NVGRE,
@@ -1129,6 +1130,7 @@ static const enum index item_sctp[] = {static const enum index item_vxlan[] = {ITEM_VXLAN_VNI , +ITEM_VXLAN_LAST_RSVD ,ITEM_NEXT ,ZERO , };
@@ -2806,6 +2808,13 @@ static const struct token token_list[] = { .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)), }, + [ITEM_VXLAN_LAST_RSVD] = { + .name = "last_rsvd", + .help = "VXLAN last reserved bits", + .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, + rsvd1)), + }, [ITEM_E_TAG] = { .name = "e_tag", .help = "match E-Tag header",
app/test-pmd/util.c +3 -2
@@ -266,8 +266,9 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], vx_vni =rte_be_to_cpu_32 (vxlan_hdr->vx_vni);MKDUMPSTR (print_buf, buf_size, cur_len," - VXLAN packet: packet type =%d, " -"Destination UDP port =%d, VNI = %d" , - packet_type, udp_port, vx_vni >>8 ); +"Destination UDP port =%d, VNI = %d, " +"last_rsvd = %d" , packet_type, + udp_port, vx_vni >>8 , vx_vni &0xff ); } } MKDUMPSTR(print_buf, buf_size, cur_len,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1 -0
@@ -3694,6 +3694,7 @@ This section lists supported pattern items and their attributes, if any. - ``vxlan``: match VXLAN header. - ``vni {unsigned}``: VXLAN identifier. + - ``last_rsvd {unsigned}``: VXLAN last reserved 8-bits. - ``e_tag``: match IEEE 802.1BR E-Tag header.
Signature · 1 line
2.27.0
Re: [dpdk-dev] [RFC 2/2] app/testpmd: support VXLAN last 8-bits field matching
Hi Rongwei,
As per VxLAN RFC 7348- <https://datatracker.ietf.org/doc/html/rfc7348>
Reserved fields (24 bits and 8 bits): MUST be set to zero on transmission and ignored on receipt.
I hope this criteria will be met for external packets.
Quoted 11 lines · rongwei liu
Add a new testpmd pattern field '
last_rsvd' that supports the last 8-bits matching of VXLAN header.The examples for the "
last_rsvd" pattern field are as below:1. ...pattern eth / ipv4 / udp / vxlan
last_rsvdis0x80/ end ...This flow will exactly match the last 8-bits to be
0x80.2. ...pattern eth / ipv4 / udp / vxlan
last_rsvdspec0x80vxlan mask0x80/ end ...
Shouldn't this be as below, (or I am mistaken)-
2. ...pattern eth / ipv4 / udp / vxlan last_rsvd spec 0x80 last_rsvd mask 0x80 / end ...
Quoted 71 lines
This flow will only match the MSB of the last 8-bits to be 1.
Signed-off-by rongwei liu <[email protected]>--- app/test-pmd/cmdline_flow.c | 9 +++++++++ app/test-pmd/util.c | 5 +++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)app/test-pmd/cmdline_flow.c +9
-0@@ -207,6 +207,7 @@ enum index {ITEM_SCTP_CKSUM ,ITEM_VXLAN ,ITEM_VXLAN_VNI , +ITEM_VXLAN_LAST_RSVD ,ITEM_E_TAG ,ITEM_E_TAG_GRP_ECID_B , ITEM_NVGRE,@@ -1129,6 +1130,7 @@ static const enum index item_sctp[] = {static const enum index item_vxlan[] = {ITEM_VXLAN_VNI , +ITEM_VXLAN_LAST_RSVD ,ITEM_NEXT ,ZERO , };@@ -2806,6 +2808,13 @@ static const struct token token_list[] = { .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)), }, + [ITEM_VXLAN_LAST_RSVD] = { + .name = "last_rsvd", + .help = "VXLAN last reserved bits", + .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, + rsvd1)), + }, [ITEM_E_TAG] = { .name = "e_tag", .help = "match E-Tag header",app/test-pmd/util.c +3
-2@@ -266,8 +266,9 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], vx_vni =rte_be_to_cpu_32 (vxlan_hdr->vx_vni);MKDUMPSTR (print_buf, buf_size, cur_len," - VXLAN packet: packet type =%d, " -"Destination UDP port =%d, VNI = %d" , - packet_type, udp_port, vx_vni >>8 ); +"Destination UDP port =%d, VNI = %d, " +"last_rsvd = %d" , packet_type, + udp_port, vx_vni >>8 , vx_vni &0xff ); } } MKDUMPSTR(print_buf, buf_size, cur_len,doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0@@ -3694,6 +3694,7 @@ This section lists supported pattern items and their attributes, if any. - ``vxlan``: match VXLAN header. - ``vni {unsigned}``: VXLAN identifier. + - ``last_rsvd {unsigned}``: VXLAN last reserved 8-bits. - ``e_tag``: match IEEE 802.1BR E-Tag header.
Re: [dpdk-dev] [RFC 2/2] app/testpmd: support VXLAN last 8-bits field matching
Hi Singh:
This update only provides the capability to match the last 8-bits reserved field of VXLAN header. No package modification totally. Package content is up to end user' decision.
BR
Rongwei
Quoted 111 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Singh, Aman Deep
Sent: Wednesday, June 16, 2021 1:16 AM
To: [email protected]
Subject: Re: [dpdk-dev] [RFC 2/2] app/testpmd: support VXLAN last 8-bits field matchingExternal email: Use caution opening links or attachments
Hi Rongwei,
As per VxLAN RFC 7348- <https://datatracker.ietf.org/doc/html/rfc7348>
Reserved fields (24 bits and 8 bits): MUST be set to zero on transmission and ignored on receipt.
I hope this criteria will be met for external packets.
Quoted 11 lines · rongwei liu
Add a new testpmd pattern field '
last_rsvd' that supports the last 8-bits matching of VXLAN header.The examples for the "
last_rsvd" pattern field are as below:1. ...pattern eth / ipv4 / udp / vxlan
last_rsvdis0x80/ end ...This flow will exactly match the last 8-bits to be
0x80.2. ...pattern eth / ipv4 / udp / vxlan
last_rsvdspec0x80vxlan mask0x80/ end ...Shouldn't this be as below, (or I am mistaken)-
2. ...pattern eth / ipv4 / udp / vxlan
last_rsvdspec0x80last_rsvdmask0x80/ end ...app/test-pmd/util.c dump_pkt_burst(uint16_t port_id, uint16_t queue,
Quoted 48 lines
This flow will only match the MSB of the last 8-bits to be 1.
Signed-off-by rongwei liu <[email protected]>--- app/test-pmd/cmdline_flow.c | 9 +++++++++ app/test-pmd/util.c | 5 +++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)app/test-pmd/cmdline_flow.c +9
-0@@ -207,6 +207,7 @@ enum index {ITEM_SCTP_CKSUM ,ITEM_VXLAN ,ITEM_VXLAN_VNI , +ITEM_VXLAN_LAST_RSVD ,ITEM_E_TAG ,ITEM_E_TAG_GRP_ECID_B , ITEM_NVGRE,@@ -1129,6 +1130,7 @@ static const enum index item_sctp[] = {static const enum index item_vxlan[] = {ITEM_VXLAN_VNI , +ITEM_VXLAN_LAST_RSVD ,ITEM_NEXT ,ZERO , };@@ -2806,6 +2808,13 @@ static const struct token token_list[] = { .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)), }, + [ITEM_VXLAN_LAST_RSVD] = { + .name = "last_rsvd", + .help = "VXLAN last reserved bits", + .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, + rsvd1)), + }, [ITEM_E_TAG] = { .name ="e_tag" , .help = "match E-Tag header", diff --git
a/app/test-pmd/util.cb/app/test-pmd/util.cindexa9e431a8b2..59626518d5100644app/test-pmd/util.c +0
-0@@ -266,8 +266,9 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue,struct
rte_mbuf*pkts[],doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported pattern items and
Quoted 18 lines
app/test-pmd/util.c +4
-2vx_vni =rte_be_to_cpu_32 (vxlan_hdr->vx_vni);MKDUMPSTR (print_buf, buf_size, cur_len," - VXLAN packet: packet type =%d, " -"Destination UDP port =%d, VNI = %d" , - packet_type, udp_port, vx_vni >>8 ); +"Destination UDP port =%d, VNI = %d, " +"last_rsvd = %d" , packet_type, + udp_port, vx_vni >>8 , vx_vni + &0xff ); } } MKDUMPSTR(print_buf, buf_size, cur_len, diff --git
a/doc/guides/testpmd_app_ug/testpmd_funcs.rstb/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index33857acf54..4ca3103067100644doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0@@ -3694,6 +3694,7 @@ This section lists supported pattern items andtheir attributes, if any.
Quoted 7 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0- ``vxlan``: match VXLAN header. - ``vni {unsigned}``: VXLAN identifier. + - ``last_rsvd {unsigned}``: VXLAN last reserved 8-bits. - ``e_tag``: match IEEE 802.1BR E-Tag header.