Commit 0dbf3332 authored by Moses Reuben's avatar Moses Reuben Committed by Doug Ledford

IB/core: Add flow spec tunneling support

In order to support tunneling, that can be used by the QP,
both struct ib_flow_spec_tunnel and struct ib_flow_tunnel_filter can be
used to more IP or UDP based tunneling protocols (e.g NVGRE, GRE, etc).

IB_FLOW_SPEC_VXLAN_TUNNEL type flow specification is added to use this
functionality and match specific Vxlan packets.

In similar to IPv6, we check overflow of the vni value by
comparing with the maximum size.
Signed-off-by: default avatarMoses Reuben <mosesr@mellanox.com>
Reviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 1cbe6fc8
...@@ -3175,6 +3175,21 @@ static int kern_spec_to_ib_spec(struct ib_uverbs_flow_spec *kern_spec, ...@@ -3175,6 +3175,21 @@ static int kern_spec_to_ib_spec(struct ib_uverbs_flow_spec *kern_spec,
memcpy(&ib_spec->tcp_udp.val, kern_spec_val, actual_filter_sz); memcpy(&ib_spec->tcp_udp.val, kern_spec_val, actual_filter_sz);
memcpy(&ib_spec->tcp_udp.mask, kern_spec_mask, actual_filter_sz); memcpy(&ib_spec->tcp_udp.mask, kern_spec_mask, actual_filter_sz);
break; break;
case IB_FLOW_SPEC_VXLAN_TUNNEL:
ib_filter_sz = offsetof(struct ib_flow_tunnel_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;
ib_spec->tunnel.size = sizeof(struct ib_flow_spec_tunnel);
memcpy(&ib_spec->tunnel.val, kern_spec_val, actual_filter_sz);
memcpy(&ib_spec->tunnel.mask, kern_spec_mask, actual_filter_sz);
if ((ntohl(ib_spec->tunnel.mask.tunnel_id)) >= BIT(24) ||
(ntohl(ib_spec->tunnel.val.tunnel_id)) >= BIT(24))
return -EINVAL;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
......
...@@ -1599,7 +1599,8 @@ enum ib_flow_spec_type { ...@@ -1599,7 +1599,8 @@ enum ib_flow_spec_type {
IB_FLOW_SPEC_IPV6 = 0x31, IB_FLOW_SPEC_IPV6 = 0x31,
/* L4 headers*/ /* L4 headers*/
IB_FLOW_SPEC_TCP = 0x40, IB_FLOW_SPEC_TCP = 0x40,
IB_FLOW_SPEC_UDP = 0x41 IB_FLOW_SPEC_UDP = 0x41,
IB_FLOW_SPEC_VXLAN_TUNNEL = 0x50,
}; };
#define IB_FLOW_SPEC_LAYER_MASK 0xF0 #define IB_FLOW_SPEC_LAYER_MASK 0xF0
#define IB_FLOW_SPEC_SUPPORT_LAYERS 4 #define IB_FLOW_SPEC_SUPPORT_LAYERS 4
...@@ -1707,6 +1708,21 @@ struct ib_flow_spec_tcp_udp { ...@@ -1707,6 +1708,21 @@ struct ib_flow_spec_tcp_udp {
struct ib_flow_tcp_udp_filter mask; struct ib_flow_tcp_udp_filter mask;
}; };
struct ib_flow_tunnel_filter {
__be32 tunnel_id;
u8 real_sz[0];
};
/* ib_flow_spec_tunnel describes the Vxlan tunnel
* the tunnel_id from val has the vni value
*/
struct ib_flow_spec_tunnel {
enum ib_flow_spec_type type;
u16 size;
struct ib_flow_tunnel_filter val;
struct ib_flow_tunnel_filter mask;
};
union ib_flow_spec { union ib_flow_spec {
struct { struct {
enum ib_flow_spec_type type; enum ib_flow_spec_type type;
...@@ -1717,6 +1733,7 @@ union ib_flow_spec { ...@@ -1717,6 +1733,7 @@ union ib_flow_spec {
struct ib_flow_spec_ipv4 ipv4; struct ib_flow_spec_ipv4 ipv4;
struct ib_flow_spec_tcp_udp tcp_udp; struct ib_flow_spec_tcp_udp tcp_udp;
struct ib_flow_spec_ipv6 ipv6; struct ib_flow_spec_ipv6 ipv6;
struct ib_flow_spec_tunnel tunnel;
}; };
struct ib_flow_attr { struct ib_flow_attr {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment