diff options
author | Matan Barak <matanb@mellanox.com> | 2018-03-28 02:27:49 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-04-04 14:06:26 -0400 |
commit | 56ab0b38b80e5771920e163cc9bd52504b03f539 (patch) | |
tree | d8d251c997d1410ff029fed09301dbd97b3d4071 | |
parent | 7d12f8d5a1645275dd452138bf1fe478be736704 (diff) |
IB/uverbs: Introduce ESP steering match filter
Adding a new ESP steering match filter that could match against
spi and seq used in IPSec protocol.
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r-- | drivers/infiniband/core/uverbs.h | 1 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 11 | ||||
-rw-r--r-- | include/rdma/ib_verbs.h | 16 | ||||
-rw-r--r-- | include/uapi/rdma/ib_user_verbs.h | 18 |
4 files changed, 46 insertions, 0 deletions
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 1bac0b51686a..3229e87d03cb 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -257,6 +257,7 @@ struct ib_uverbs_flow_spec { | |||
257 | }; | 257 | }; |
258 | struct ib_uverbs_flow_spec_eth eth; | 258 | struct ib_uverbs_flow_spec_eth eth; |
259 | struct ib_uverbs_flow_spec_ipv4 ipv4; | 259 | struct ib_uverbs_flow_spec_ipv4 ipv4; |
260 | struct ib_uverbs_flow_spec_esp esp; | ||
260 | struct ib_uverbs_flow_spec_tcp_udp tcp_udp; | 261 | struct ib_uverbs_flow_spec_tcp_udp tcp_udp; |
261 | struct ib_uverbs_flow_spec_ipv6 ipv6; | 262 | struct ib_uverbs_flow_spec_ipv6 ipv6; |
262 | struct ib_uverbs_flow_spec_action_tag flow_tag; | 263 | struct ib_uverbs_flow_spec_action_tag flow_tag; |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 69050dd77421..f38600490fd1 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -2931,6 +2931,17 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type, | |||
2931 | (ntohl(ib_spec->tunnel.val.tunnel_id)) >= BIT(24)) | 2931 | (ntohl(ib_spec->tunnel.val.tunnel_id)) >= BIT(24)) |
2932 | return -EINVAL; | 2932 | return -EINVAL; |
2933 | break; | 2933 | break; |
2934 | case IB_FLOW_SPEC_ESP: | ||
2935 | ib_filter_sz = offsetof(struct ib_flow_esp_filter, real_sz); | ||
2936 | actual_filter_sz = spec_filter_size(kern_spec_mask, | ||
2937 | kern_filter_sz, | ||
2938 | ib_filter_sz); | ||
2939 | if (actual_filter_sz <= 0) | ||
2940 | return -EINVAL; | ||
2941 | ib_spec->esp.size = sizeof(struct ib_flow_spec_esp); | ||
2942 | memcpy(&ib_spec->esp.val, kern_spec_val, actual_filter_sz); | ||
2943 | memcpy(&ib_spec->esp.mask, kern_spec_mask, actual_filter_sz); | ||
2944 | break; | ||
2934 | default: | 2945 | default: |
2935 | return -EINVAL; | 2946 | return -EINVAL; |
2936 | } | 2947 | } |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 8c3ca073016d..a6dba77c1b28 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -1828,6 +1828,7 @@ enum ib_flow_spec_type { | |||
1828 | /* L3 header*/ | 1828 | /* L3 header*/ |
1829 | IB_FLOW_SPEC_IPV4 = 0x30, | 1829 | IB_FLOW_SPEC_IPV4 = 0x30, |
1830 | IB_FLOW_SPEC_IPV6 = 0x31, | 1830 | IB_FLOW_SPEC_IPV6 = 0x31, |
1831 | IB_FLOW_SPEC_ESP = 0x34, | ||
1831 | /* L4 headers*/ | 1832 | /* L4 headers*/ |
1832 | IB_FLOW_SPEC_TCP = 0x40, | 1833 | IB_FLOW_SPEC_TCP = 0x40, |
1833 | IB_FLOW_SPEC_UDP = 0x41, | 1834 | IB_FLOW_SPEC_UDP = 0x41, |
@@ -1960,6 +1961,20 @@ struct ib_flow_spec_tunnel { | |||
1960 | struct ib_flow_tunnel_filter mask; | 1961 | struct ib_flow_tunnel_filter mask; |
1961 | }; | 1962 | }; |
1962 | 1963 | ||
1964 | struct ib_flow_esp_filter { | ||
1965 | __be32 spi; | ||
1966 | __be32 seq; | ||
1967 | /* Must be last */ | ||
1968 | u8 real_sz[0]; | ||
1969 | }; | ||
1970 | |||
1971 | struct ib_flow_spec_esp { | ||
1972 | u32 type; | ||
1973 | u16 size; | ||
1974 | struct ib_flow_esp_filter val; | ||
1975 | struct ib_flow_esp_filter mask; | ||
1976 | }; | ||
1977 | |||
1963 | struct ib_flow_spec_action_tag { | 1978 | struct ib_flow_spec_action_tag { |
1964 | enum ib_flow_spec_type type; | 1979 | enum ib_flow_spec_type type; |
1965 | u16 size; | 1980 | u16 size; |
@@ -1988,6 +2003,7 @@ union ib_flow_spec { | |||
1988 | struct ib_flow_spec_tcp_udp tcp_udp; | 2003 | struct ib_flow_spec_tcp_udp tcp_udp; |
1989 | struct ib_flow_spec_ipv6 ipv6; | 2004 | struct ib_flow_spec_ipv6 ipv6; |
1990 | struct ib_flow_spec_tunnel tunnel; | 2005 | struct ib_flow_spec_tunnel tunnel; |
2006 | struct ib_flow_spec_esp esp; | ||
1991 | struct ib_flow_spec_action_tag flow_tag; | 2007 | struct ib_flow_spec_action_tag flow_tag; |
1992 | struct ib_flow_spec_action_drop drop; | 2008 | struct ib_flow_spec_action_drop drop; |
1993 | struct ib_flow_spec_action_handle action; | 2009 | struct ib_flow_spec_action_handle action; |
diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index ac41ce234186..df5d339952fe 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h | |||
@@ -1014,6 +1014,24 @@ struct ib_uverbs_flow_spec_tunnel { | |||
1014 | struct ib_uverbs_flow_tunnel_filter mask; | 1014 | struct ib_uverbs_flow_tunnel_filter mask; |
1015 | }; | 1015 | }; |
1016 | 1016 | ||
1017 | struct ib_uverbs_flow_spec_esp_filter { | ||
1018 | __u32 spi; | ||
1019 | __u32 seq; | ||
1020 | }; | ||
1021 | |||
1022 | struct ib_uverbs_flow_spec_esp { | ||
1023 | union { | ||
1024 | struct ib_uverbs_flow_spec_hdr hdr; | ||
1025 | struct { | ||
1026 | __u32 type; | ||
1027 | __u16 size; | ||
1028 | __u16 reserved; | ||
1029 | }; | ||
1030 | }; | ||
1031 | struct ib_uverbs_flow_spec_esp_filter val; | ||
1032 | struct ib_uverbs_flow_spec_esp_filter mask; | ||
1033 | }; | ||
1034 | |||
1017 | struct ib_uverbs_flow_attr { | 1035 | struct ib_uverbs_flow_attr { |
1018 | __u32 type; | 1036 | __u32 type; |
1019 | __u16 size; | 1037 | __u16 size; |