Extend flow steering IPv4 and IPv6 specification.
Subsystems (3)
cover Extend flow steering IPv4 and IPv6 specification.
This patch set extends the IPv4 and IPv6 flow specification.
New fields in IPv4:
1. Type of Service
2. Time to Live
3. Flags
4. Protocol
New fields in IPv6:
1. Traffic Class
2. Flow Label
3. Next Header
4. Hop Limit
The first patch in this series adds support to extend the flow steering specification. Previously, user flow specification and kernel flow specification were must to be equal in their size.
To support extensions, we change the flow specifications conditions test to be as following:
1. Every mask field that is given by the user and doesn't exist in kernel is validated to be zero. Thus, new user-space would only fail if it's using (i.e field_mask != 0) a field which doesn't exist in the current kernel version.
2. All types are known by the kernel.
3. If the kernel is newer than the user-space, all fields (and by that, their masks) weren't given by the user are assumed as zeros and ignored.
4. The ABI declares filters as 32bit aligned. This is necessary to avoid unaligned access when reading the header.
Changes from v0 to v1:
* Add Reviewed-by from Sagi G.
* Split mlx4, mlx5 and uverbs to separate patches
* Rename IB/core to be IB/uverbs
Available in the "topic/ext-flow" topic branch of this git repo:git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git
Or for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/linux-rdma.git/log/?h=topic/ext-flow
Thanks,
Maor & Leon
Maor Gottlieb (7):
IB/mlx4: Add validation to flow specifications parsing IB/mlx5: Add validation to flow specifications parsing IB/uverbs: Add support to extend flow steering specifications IB/uverbs: Add more fields to IPv4 flow specification IB/uverbs: Add more fields to IPv6 flow specification IB/mlx5: Add support in TOS and protocol to flow steering IB/mlx5: Add support of more IPv6 fields to flow steering
drivers/infiniband/core/uverbs_cmd.c | 102 ++++++++++++++++++++++++-------- drivers/infiniband/hw/mlx4/main.c | 25 ++++++++ drivers/infiniband/hw/mlx5/main.c | 110 ++++++++++++++++++++++++++++------- include/rdma/ib_verbs.h | 25 ++++++++ include/uapi/rdma/ib_user_verbs.h | 13 ++++- 5 files changed, 228 insertions(+), 47 deletions(-)
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1472565516-11591-1-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
PATCH 1/7 IB/mlx4: Add validation to flow specifications parsing
From: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add validation check that all set fields in flow specification are supported by vendor.
--- drivers/infiniband/hw/mlx4/main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/infiniband/hw/mlx4/main.c +25 -0
@@ -1361,6 +1361,19 @@ struct mlx4_ib_steering {union ib_gid gid; }; +#define LAST_ETH_FIELD vlan_tag +#define LAST_IB_FIELD sl +#define LAST_IPV4_FIELD dst_ip +#define LAST_TCP_UDP_FIELD src_port + +/* Field is the last supported field */ +#define FIELDS_NOT_SUPPORTED (filter, field)\ + memchr_inv((void *)&filter.field +\ + sizeof(filter.field), 0,\ + sizeof(filter) -\ + offsetof(typeof(filter), field) -\ + sizeof(filter.field)) + static int parse_flow_attr(struct mlx4_dev *dev, u32 qp_num, union ib_flow_spec *ib_spec,
@@ -1370,6 +1383,9 @@ static int parse_flow_attr(struct mlx4_dev *dev,switch (ib_spec->type) {case IB_FLOW_SPEC_ETH : +if (FIELDS_NOT_SUPPORTED (ib_spec->eth.mask,LAST_ETH_FIELD )) +return -ENOTSUPP ; + type =MLX4_NET_TRANS_RULE_ID_ETH ;memcpy (mlx4_spec->eth.dst_mac, ib_spec->eth.val.dst_mac,ETH_ALEN );
@@ -1379,6 +1395,9 @@ static int parse_flow_attr(struct mlx4_dev *dev, mlx4_spec->eth.vlan_tag_msk = ib_spec->eth.mask.vlan_tag;break ;case IB_FLOW_SPEC_IB : +if (FIELDS_NOT_SUPPORTED (ib_spec->ib.mask,LAST_IB_FIELD )) +return -ENOTSUPP ; + type =MLX4_NET_TRANS_RULE_ID_IB ; mlx4_spec->ib.l3_qpn =cpu_to_be32 (qp_num);
@@ -1388,6 +1407,9 @@ static int parse_flow_attr(struct mlx4_dev *dev,case IB_FLOW_SPEC_IPV4 : +if (FIELDS_NOT_SUPPORTED (ib_spec->ipv4.mask,LAST_IPV4_FIELD )) +return -ENOTSUPP ; + type =MLX4_NET_TRANS_RULE_ID_IPV4 ; mlx4_spec->ipv4.src_ip = ib_spec->ipv4.val.src_ip; mlx4_spec->ipv4.src_ip_msk = ib_spec->ipv4.mask.src_ip;
@@ -1397,6 +1419,9 @@ static int parse_flow_attr(struct mlx4_dev *dev,case IB_FLOW_SPEC_TCP :case IB_FLOW_SPEC_UDP : +if (FIELDS_NOT_SUPPORTED (ib_spec->tcp_udp.mask,LAST_TCP_UDP_FIELD )) +return -ENOTSUPP ; + type = ib_spec->type ==IB_FLOW_SPEC_TCP ?MLX4_NET_TRANS_RULE_ID_TCP :MLX4_NET_TRANS_RULE_ID_UDP ;
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/7 IB/mlx5: Add validation to flow specifications parsing
In reply to a message not in the archiveFrom: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add validation check that all set fields in flow specification are supported by vendor.
--- drivers/infiniband/hw/mlx5/main.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-)
drivers/infiniband/hw/mlx5/main.c +26 -10
@@ -1405,6 +1405,20 @@ static bool outer_header_zero(u32 *match_criteria) size - 1); } +#define LAST_ETH_FIELD vlan_tag +#define LAST_IB_FIELD sl +#define LAST_IPV4_FIELD dst_ip +#define LAST_IPV6_FIELD dst_ip +#define LAST_TCP_UDP_FIELD src_port + +/* Field is the last supported field */ +#define FIELDS_NOT_SUPPORTED (filter, field)\ + memchr_inv((void *)&filter.field +\ + sizeof(filter.field), 0,\ + sizeof(filter) -\ + offsetof(typeof(filter), field) -\ + sizeof(filter.field)) +static int parse_flow_attr (u32 *match_c,u32 *match_v,union ib_flow_spec *ib_spec) {
@@ -1414,8 +1428,8 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, outer_headers);switch (ib_spec->type) {case IB_FLOW_SPEC_ETH : -if (ib_spec->size !=sizeof (ib_spec->eth)) -return -EINVAL ; +if (FIELDS_NOT_SUPPORTED (ib_spec->eth.mask,LAST_ETH_FIELD )) +return -ENOTSUPP ; ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c, dmac_47_16),
@@ -1455,8 +1469,8 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, ethertype, ntohs(ib_spec->eth.val.ether_type));break ;case IB_FLOW_SPEC_IPV4 : -if (ib_spec->size !=sizeof (ib_spec->ipv4)) -return -EINVAL ; +if (FIELDS_NOT_SUPPORTED (ib_spec->ipv4.mask,LAST_IPV4_FIELD )) +return -ENOTSUPP ;MLX5_SET (fte_match_set_lyr_2_4, outer_headers_c, ethertype,0xffff );
@@ -1481,8 +1495,8 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, sizeof(ib_spec->ipv4.val.dst_ip));break ;case IB_FLOW_SPEC_IPV6 : -if (ib_spec->size !=sizeof (ib_spec->ipv6)) -return -EINVAL ; +if (FIELDS_NOT_SUPPORTED (ib_spec->ipv6.mask,LAST_IPV6_FIELD )) +return -ENOTSUPP ;MLX5_SET (fte_match_set_lyr_2_4, outer_headers_c, ethertype,0xffff );
@@ -1507,8 +1521,9 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, sizeof(ib_spec->ipv6.val.dst_ip));break ;case IB_FLOW_SPEC_TCP : -if (ib_spec->size !=sizeof (ib_spec->tcp_udp)) -return -EINVAL ; +if (FIELDS_NOT_SUPPORTED (ib_spec->tcp_udp.mask, +LAST_TCP_UDP_FIELD )) +return -ENOTSUPP ;MLX5_SET (fte_match_set_lyr_2_4, outer_headers_c, ip_protocol,0xff );
@@ -1526,8 +1541,9 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, ntohs(ib_spec->tcp_udp.val.dst_port));break ;case IB_FLOW_SPEC_UDP : -if (ib_spec->size !=sizeof (ib_spec->tcp_udp)) -return -EINVAL ; +if (FIELDS_NOT_SUPPORTED (ib_spec->tcp_udp.mask, +LAST_TCP_UDP_FIELD )) +return -ENOTSUPP ;MLX5_SET (fte_match_set_lyr_2_4, outer_headers_c, ip_protocol,0xff );
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/7 IB/uverbs: Add support to extend flow steering specifications
In reply to a message not in the archiveFrom: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>
Flow steering specifications structures were implemented as in an extensible way that allows one to add new filters and new fields to existing filters.
These specifications have never been extended, therefore the kernel flow specifications size and the user flow specifications size were must to be equal.
In downstream patch, the IPv4 flow specifications type is extended to support TOS and TTL fields.
To support an extension we change the flow specifications size condition test to be as following:
* If the user flow specifications is bigger than the kernel specifications, we verify that all the bits which not in the kernel specifications are zeros and the flow is added only with the kernel specifications fields.
* Otherwise, we add flow rule only with the user specifications fields.
User space filters must be aligned with 32bits.
--- drivers/infiniband/core/uverbs_cmd.c | 98 +++++++++++++++++++++++++++--------- include/rdma/ib_verbs.h | 10 ++++ 2 files changed, 83 insertions(+), 25 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +73 -25
@@ -3078,51 +3078,98 @@ out_put:return ret ? ret : in_len; } +static size_t kern_spec_filter_sz (struct ib_uverbs_flow_spec_hdr *spec) +{ +/* Returns user space filter size, includes padding */ +return (spec->size -sizeof (struct ib_uverbs_flow_spec_hdr )) /2 ; +} + +static ssize_t spec_filter_size (void *kern_spec_filter,u16 kern_filter_size, +u16 ib_real_filter_sz) +{ +/* +* User space filter structures must be 64 bit aligned, otherwise this +* may pass, but we won't handle additional new attributes. +*/ + +if (kern_filter_size > ib_real_filter_sz) { +if (memchr_inv (kern_spec_filter + + ib_real_filter_sz,0 , + kern_filter_size - ib_real_filter_sz)) +return -EINVAL ; +return ib_real_filter_sz; + } +return kern_filter_size; +} +static int kern_spec_to_ib_spec (struct ib_uverbs_flow_spec *kern_spec,union ib_flow_spec *ib_spec) { +ssize_t actual_filter_sz; +ssize_t kern_filter_sz; +ssize_t ib_filter_sz; +void *kern_spec_mask; +void *kern_spec_val; +if (kern_spec->reserved)return -EINVAL ; ib_spec->type = kern_spec->type; + kern_filter_sz =kern_spec_filter_sz (&kern_spec->hdr); +/* User flow spec size must be aligned to 4 bytes */ +if (kern_filter_sz !=ALIGN (kern_filter_sz,4 )) +return -EINVAL ; + + kern_spec_val = (void *)kern_spec + +sizeof (struct ib_uverbs_flow_spec_hdr ); + kern_spec_mask = kern_spec_val + kern_filter_sz; +switch (ib_spec->type) {case IB_FLOW_SPEC_ETH : - ib_spec->eth.size =sizeof (struct ib_flow_spec_eth ); -if (ib_spec->eth.size != kern_spec->eth.size) + ib_filter_sz = offsetof(struct ib_flow_eth_filter , real_sz); + actual_filter_sz =spec_filter_size (kern_spec_mask, + kern_filter_sz, + ib_filter_sz); +if (actual_filter_sz <=0 )return -EINVAL ; -memcpy (&ib_spec->eth.val, &kern_spec->eth.val, -sizeof (struct ib_flow_eth_filter )); -memcpy (&ib_spec->eth.mask, &kern_spec->eth.mask, -sizeof (struct ib_flow_eth_filter )); + ib_spec->size =sizeof (struct ib_flow_spec_eth ); +memcpy (&ib_spec->eth.val, kern_spec_val, actual_filter_sz); +memcpy (&ib_spec->eth.mask, kern_spec_mask, actual_filter_sz);break ;case IB_FLOW_SPEC_IPV4 : - ib_spec->ipv4.size =sizeof (struct ib_flow_spec_ipv4 ); -if (ib_spec->ipv4.size != kern_spec->ipv4.size) + ib_filter_sz = offsetof(struct ib_flow_ipv4_filter , real_sz); + actual_filter_sz =spec_filter_size (kern_spec_mask, + kern_filter_sz, + ib_filter_sz); +if (actual_filter_sz <=0 )return -EINVAL ; -memcpy (&ib_spec->ipv4.val, &kern_spec->ipv4.val, -sizeof (struct ib_flow_ipv4_filter )); -memcpy (&ib_spec->ipv4.mask, &kern_spec->ipv4.mask, -sizeof (struct ib_flow_ipv4_filter )); + ib_spec->size =sizeof (struct ib_flow_spec_ipv4 ); +memcpy (&ib_spec->ipv4.val, kern_spec_val, actual_filter_sz); +memcpy (&ib_spec->ipv4.mask, kern_spec_mask, actual_filter_sz);break ;case IB_FLOW_SPEC_IPV6 : - ib_spec->ipv6.size =sizeof (struct ib_flow_spec_ipv6 ); -if (ib_spec->ipv6.size != kern_spec->ipv6.size) + ib_filter_sz = offsetof(struct ib_flow_ipv6_filter , real_sz); + actual_filter_sz =spec_filter_size (kern_spec_mask, + kern_filter_sz, + ib_filter_sz); +if (actual_filter_sz <=0 )return -EINVAL ; -memcpy (&ib_spec->ipv6.val, &kern_spec->ipv6.val, -sizeof (struct ib_flow_ipv6_filter )); -memcpy (&ib_spec->ipv6.mask, &kern_spec->ipv6.mask, -sizeof (struct ib_flow_ipv6_filter )); + ib_spec->size =sizeof (struct ib_flow_spec_ipv6 ); +memcpy (&ib_spec->ipv6.val, kern_spec_val, actual_filter_sz); +memcpy (&ib_spec->ipv6.mask, kern_spec_mask, actual_filter_sz);break ;case IB_FLOW_SPEC_TCP :case IB_FLOW_SPEC_UDP : - ib_spec->tcp_udp.size =sizeof (struct ib_flow_spec_tcp_udp ); -if (ib_spec->tcp_udp.size != kern_spec->tcp_udp.size) + ib_filter_sz = offsetof(struct ib_flow_tcp_udp_filter , real_sz); + actual_filter_sz =spec_filter_size (kern_spec_mask, + kern_filter_sz, + ib_filter_sz); +if (actual_filter_sz <=0 )return -EINVAL ; -memcpy (&ib_spec->tcp_udp.val, &kern_spec->tcp_udp.val, -sizeof (struct ib_flow_tcp_udp_filter )); -memcpy (&ib_spec->tcp_udp.mask, &kern_spec->tcp_udp.mask, -sizeof (struct ib_flow_tcp_udp_filter )); + ib_spec->size =sizeof (struct ib_flow_spec_tcp_udp ); +memcpy (&ib_spec->tcp_udp.val, kern_spec_val, actual_filter_sz); +memcpy (&ib_spec->tcp_udp.mask, kern_spec_mask, actual_filter_sz);break ;default :return -EINVAL ;
@@ -3654,7 +3701,8 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, goto err_uobj; } - flow_attr =kmalloc (sizeof (*flow_attr) + cmd.flow_attr.size,GFP_KERNEL ); + flow_attr =kzalloc (sizeof (*flow_attr) + cmd.flow_attr.num_of_specs * +sizeof (union ib_flow_spec ),GFP_KERNEL );if (!flow_attr) { err = -ENOMEM ; goto err_put;
include/rdma/ib_verbs.h +10 -0
@@ -1604,6 +1604,8 @@ struct ib_flow_eth_filter {u8 src_mac[6 ];__be16 ether_type;__be16 vlan_tag; +/* Must be last */ +u8 real_sz[0 ]; };struct ib_flow_spec_eth {
@@ -1616,6 +1618,8 @@ struct ib_flow_spec_eth {struct ib_flow_ib_filter {__be16 dlid;__u8 sl; +/* Must be last */ +u8 real_sz[0 ]; };struct ib_flow_spec_ib {
@@ -1628,6 +1632,8 @@ struct ib_flow_spec_ib {struct ib_flow_ipv4_filter {__be32 src_ip;__be32 dst_ip; +/* Must be last */ +u8 real_sz[0 ]; };struct ib_flow_spec_ipv4 {
@@ -1640,6 +1646,8 @@ struct ib_flow_spec_ipv4 {struct ib_flow_ipv6_filter {u8 src_ip[16 ];u8 dst_ip[16 ]; +/* Must be last */ +u8 real_sz[0 ]; };struct ib_flow_spec_ipv6 {
@@ -1652,6 +1660,8 @@ struct ib_flow_spec_ipv6 {struct ib_flow_tcp_udp_filter {__be16 dst_port;__be16 src_port; +/* Must be last */ +u8 real_sz[0 ]; };struct ib_flow_spec_tcp_udp {
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/7 IB/uverbs: Add more fields to IPv4 flow specification
In reply to a message not in the archiveFrom: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add the following fields to IPv4 flow filter specification:
1. Type of Service
2. Time to Live
3. Flags
4. Protocol
--- include/rdma/ib_verbs.h | 11 +++++++++++ include/uapi/rdma/ib_user_verbs.h | 4 ++++ 2 files changed, 15 insertions(+)
include/rdma/ib_verbs.h +11 -0
@@ -1629,9 +1629,20 @@ struct ib_flow_spec_ib {struct ib_flow_ib_filter mask; }; +/* IPv4 header flags */ +enum ib_ipv4_flags { +IB_IPV4_DONT_FRAG =0x2 ,/* Don't enable packet fragmentation */ +IB_IPV4_MORE_FRAG =0X4 /* For All fragmented packets except the +last have this flag set */ +}; +struct ib_flow_ipv4_filter {__be32 src_ip;__be32 dst_ip; +u8 proto; +u8 tos; +u8 ttl; +u8 flags;/* Must be last */ u8 real_sz[0 ]; };
include/uapi/rdma/ib_user_verbs.h +4 -0
@@ -834,6 +834,10 @@ struct ib_uverbs_flow_spec_eth {struct ib_uverbs_flow_ipv4_filter {__be32 src_ip;__be32 dst_ip; +__u8 proto; +__u8 tos; +__u8 ttl; +__u8 flags; };struct ib_uverbs_flow_spec_ipv4 {
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/7 IB/core: Add more fields to IPv6 flow specification
In reply to a message not in the archiveFrom: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add the following fields to IPv6 flow filter specification:
1. Traffic Class
2. Flow Label
3. Next Header
4. Hop Limit
--- drivers/infiniband/core/uverbs_cmd.c | 4 ++++ include/rdma/ib_verbs.h | 4 ++++ include/uapi/rdma/ib_user_verbs.h | 9 +++++++-- 3 files changed, 15 insertions(+), 2 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +4 -0
@@ -3158,6 +3158,10 @@ static int kern_spec_to_ib_spec(struct ib_uverbs_flow_spec *kern_spec, ib_spec->size =sizeof (struct ib_flow_spec_ipv6 );memcpy (&ib_spec->ipv6.val, kern_spec_val, actual_filter_sz);memcpy (&ib_spec->ipv6.mask, kern_spec_mask, actual_filter_sz); + +if ((ntohl (ib_spec->ipv6.mask.flow_label)) >=BIT (20 ) || + (ntohl (ib_spec->ipv6.val.flow_label)) >=BIT (20 )) +return -EINVAL ;break ;case IB_FLOW_SPEC_TCP :case IB_FLOW_SPEC_UDP :
include/rdma/ib_verbs.h +4 -0
@@ -1657,6 +1657,10 @@ struct ib_flow_spec_ipv4 {struct ib_flow_ipv6_filter {u8 src_ip[16 ];u8 dst_ip[16 ]; +__be32 flow_label; +u8 next_hdr; +u8 traffic_class; +u8 hop_limit;/* Must be last */ u8 real_sz[0 ]; };
include/uapi/rdma/ib_user_verbs.h +7 -2
@@ -872,8 +872,13 @@ struct ib_uverbs_flow_spec_tcp_udp { };struct ib_uverbs_flow_ipv6_filter { -__u8 src_ip[16 ]; -__u8 dst_ip[16 ]; +__u8 src_ip[16 ]; +__u8 dst_ip[16 ]; +__be32 flow_label; +__u8 next_hdr; +__u8 traffic_class; +__u8 hop_limit; +__u8 reserved; };struct ib_uverbs_flow_spec_ipv6 {
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/7 IB/mlx5: Add support in TOS and protocol to flow steering
In reply to a message not in the archiveFrom: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add support to receive TOS or specific IPv4 protocol.
--- drivers/infiniband/hw/mlx5/main.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +21 -1
@@ -1405,9 +1405,23 @@ static bool outer_header_zero(u32 *match_criteria) size - 1); } +static void set_proto (void *outer_c,void *outer_v,u8 mask,u8 val) +{ +MLX5_SET (fte_match_set_lyr_2_4, outer_c, ip_protocol, mask); +MLX5_SET (fte_match_set_lyr_2_4, outer_v, ip_protocol, val); +} + +static void set_tos (void *outer_c,void *outer_v,u8 mask,u8 val) +{ +MLX5_SET (fte_match_set_lyr_2_4, outer_c, ip_ecn, mask); +MLX5_SET (fte_match_set_lyr_2_4, outer_v, ip_ecn, val); +MLX5_SET (fte_match_set_lyr_2_4, outer_c, ip_dscp, mask >>2 ); +MLX5_SET (fte_match_set_lyr_2_4, outer_v, ip_dscp, val >>2 ); +} +#define LAST_ETH_FIELD vlan_tag#define LAST_IB_FIELD sl -#define LAST_IPV4_FIELD dst_ip +#define LAST_IPV4_FIELD tos#define LAST_IPV6_FIELD dst_ip#define LAST_TCP_UDP_FIELD src_port
@@ -1493,6 +1507,12 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, dst_ipv4_dst_ipv6.ipv4_layout.ipv4), &ib_spec->ipv4.val.dst_ip, sizeof(ib_spec->ipv4.val.dst_ip)); + +set_tos (outer_headers_c, outer_headers_v, + ib_spec->ipv4.mask.tos, ib_spec->ipv4.val.tos); + +set_proto (outer_headers_c, outer_headers_v, + ib_spec->ipv4.mask.proto, ib_spec->ipv4.val.proto);break ;case IB_FLOW_SPEC_IPV6 :if (FIELDS_NOT_SUPPORTED (ib_spec->ipv6.mask,LAST_IPV6_FIELD ))
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/7 IB/mlx5: Add support of more IPv6 fields to flow steering
In reply to a message not in the archiveFrom: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add support to receive Traffic Class, specific IPv6 protocol or IPv6 flow label.
--- drivers/infiniband/hw/mlx5/main.c | 56 +++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 11 deletions(-)
drivers/infiniband/hw/mlx5/main.c +45 -11
@@ -1394,15 +1394,31 @@ static int mlx5_ib_dealloc_pd(struct ib_pd *pd)return 0 ; } -static bool outer_header_zero (u32 *match_criteria) +enum { +MATCH_CRITERIA_ENABLE_OUTER_BIT , +MATCH_CRITERIA_ENABLE_MISC_BIT , +MATCH_CRITERIA_ENABLE_INNER_BIT +}; + +#define HEADER_IS_ZERO (match_criteria, headers) \ + !(memchr_inv(MLX5_ADDR_OF(fte_match_param, match_criteria, headers), \ + 0, MLX5_FLD_SZ_BYTES(fte_match_param, headers))) \ + +static u8 get_match_criteria_enable (u32 *match_criteria) { -int size =MLX5_ST_SZ_BYTES (fte_match_param); -char *outer_headers_c =MLX5_ADDR_OF (fte_match_param, match_criteria, - outer_headers); +u8 match_criteria_enable; + + match_criteria_enable = + (!HEADER_IS_ZERO (match_criteria, outer_headers)) << +MATCH_CRITERIA_ENABLE_OUTER_BIT ; + match_criteria_enable |= + (!HEADER_IS_ZERO (match_criteria, misc_parameters)) << +MATCH_CRITERIA_ENABLE_MISC_BIT ; + match_criteria_enable |= + (!HEADER_IS_ZERO (match_criteria, inner_headers)) << +MATCH_CRITERIA_ENABLE_INNER_BIT ; -return outer_headers_c[0 ] ==0 && !memcmp (outer_headers_c, - outer_headers_c +1 , - size -1 ); +return match_criteria_enable; }static void set_proto (void *outer_c,void *outer_v,u8 mask,u8 val)
@@ -1422,7 +1438,7 @@ static void set_tos(void *outer_c, void *outer_v, u8 mask, u8 val)#define LAST_ETH_FIELD vlan_tag#define LAST_IB_FIELD sl#define LAST_IPV4_FIELD tos -#define LAST_IPV6_FIELD dst_ip +#define LAST_IPV6_FIELD traffic_class#define LAST_TCP_UDP_FIELD src_port/* Field is the last supported field */
@@ -1440,6 +1456,11 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, outer_headers);void *outer_headers_v =MLX5_ADDR_OF (fte_match_param, match_v, outer_headers); +void *misc_params_c =MLX5_ADDR_OF (fte_match_param, match_c, + misc_parameters); +void *misc_params_v =MLX5_ADDR_OF (fte_match_param, match_v, + misc_parameters); +switch (ib_spec->type) {case IB_FLOW_SPEC_ETH :if (FIELDS_NOT_SUPPORTED (ib_spec->eth.mask,LAST_ETH_FIELD ))
@@ -1539,6 +1560,21 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, dst_ipv4_dst_ipv6.ipv6_layout.ipv6), &ib_spec->ipv6.val.dst_ip, sizeof(ib_spec->ipv6.val.dst_ip)); + +set_tos (outer_headers_c, outer_headers_v, + ib_spec->ipv6.mask.traffic_class, + ib_spec->ipv6.val.traffic_class); + +set_proto (outer_headers_c, outer_headers_v, + ib_spec->ipv6.mask.next_hdr, + ib_spec->ipv6.val.next_hdr); + +MLX5_SET (fte_match_set_misc, misc_params_c, + outer_ipv6_flow_label, +ntohl (ib_spec->ipv6.mask.flow_label)); +MLX5_SET (fte_match_set_misc, misc_params_v, + outer_ipv6_flow_label, +ntohl (ib_spec->ipv6.val.flow_label));break ;case IB_FLOW_SPEC_TCP : if (FIELDS_NOT_SUPPORTED(ib_spec->tcp_udp.mask,
@@ -1766,9 +1802,7 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev, ib_flow += ((union ib_flow_spec *)ib_flow)->size; } -/* Outer header support only */ - spec->match_criteria_enable = (!outer_header_zero (spec->match_criteria)) - <<0 ; + spec->match_criteria_enable =get_match_criteria_enable (spec->match_criteria); action = dst ?MLX5_FLOW_CONTEXT_ACTION_FWD_DEST :MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO ; handler->rule = mlx5_add_flow_rule(ft, spec,
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 36 lines · Leon Romanovsky
This patch set extends the IPv4 and IPv6 flow specification.
New fields in IPv4:
1. Type of Service
2. Time to Live
3. Flags
4. ProtocolNew fields in IPv6:
1. Traffic Class
2. Flow Label
3. Next Header
4. Hop LimitThe first patch in this series adds support to extend the flow steering specification. Previously, user flow specification and kernel flow specification were must to be equal in their size.
To support extensions, we change the flow specifications conditions test to be as following:
1. Every mask field that is given by the user and doesn't exist in kernel is validated to be zero. Thus, new user-space would only fail if it's using (i.efield_mask!= 0) a field which doesn't exist in the current kernel version.
2. All types are known by the kernel.
3. If the kernel is newer than the user-space, all fields (and by that, their masks) weren't given by the user are assumed as zeros and ignored.
4. The ABI declares filters as 32bit aligned. This is necessary to avoid unaligned access when reading the header.Changes from v0 to v1:
* Add Reviewed-by from Sagi G.
* Split mlx4, mlx5 and uverbs to separate patches
* Rename IB/core to be IB/uverbs
Quoted 5 lines
Available in the "topic/ext-flow" topic branch of this git repo:
git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.gitOr for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/linux-rdma.git/log/?h=topic/ext-flow
Extension was done in a way that made sense and adhered to the standard.
All items added to the extension are generic flow variables that make
sense for anyone that would implement raw eth flow rules. Series applied.
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD