diff mbox

[rdma-core,09/11] verbs: Add flow steering specification for ESP

Message ID 1521655800-7287-10-git-send-email-yishaih@mellanox.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Yishai Hadas March 21, 2018, 6:09 p.m. UTC
From: Matan Barak <matanb@mellanox.com>

Matching ESP packets (ipsec packets) requires a new flow steering
specification. We add such a specification containing the SPI and
the sequence number.

Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 kernel-headers/rdma/ib_user_verbs.h | 18 ++++++++++++++++++
 libibverbs/cmd.c                    |  8 ++++++++
 libibverbs/kern-abi.h               |  1 +
 libibverbs/man/ibv_create_flow.3    |  1 +
 libibverbs/verbs.h                  | 14 ++++++++++++++
 5 files changed, 42 insertions(+)
diff mbox

Patch

diff --git a/kernel-headers/rdma/ib_user_verbs.h b/kernel-headers/rdma/ib_user_verbs.h
index d56fba0..48be0c7 100644
--- a/kernel-headers/rdma/ib_user_verbs.h
+++ b/kernel-headers/rdma/ib_user_verbs.h
@@ -1001,6 +1001,24 @@  struct ib_uverbs_flow_spec_tunnel {
 	struct ib_uverbs_flow_tunnel_filter mask;
 };
 
+struct ib_uverbs_flow_spec_esp_filter {
+	__u32 spi;
+	__u32 seq;
+};
+
+struct ib_uverbs_flow_spec_esp {
+	union {
+		struct ib_uverbs_flow_spec_hdr hdr;
+		struct {
+			__u32 type;
+			__u16 size;
+			__u16 reserved;
+		};
+	};
+	struct ib_uverbs_flow_spec_esp_filter val;
+	struct ib_uverbs_flow_spec_esp_filter mask;
+};
+
 struct ib_uverbs_flow_attr {
 	__u32 type;
 	__u16 size;
diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c
index 36d62eb..77c91b9 100644
--- a/libibverbs/cmd.c
+++ b/libibverbs/cmd.c
@@ -1739,6 +1739,14 @@  static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec,
 		memcpy(&kern_spec->ipv6.mask, (void *)&ib_spec->ipv6.val
 		       + ib_filter_size, kern_filter_size);
 		break;
+	case IBV_FLOW_SPEC_ESP:
+	case IBV_FLOW_SPEC_ESP | IBV_FLOW_SPEC_INNER:
+		kern_spec->esp.size = sizeof(struct ib_uverbs_flow_spec_esp);
+		memcpy(&kern_spec->esp.val, &ib_spec->esp.val,
+		       sizeof(struct ib_uverbs_flow_spec_esp_filter));
+		memcpy(&kern_spec->esp.mask, (void *)&ib_spec->esp.mask,
+		       sizeof(struct ib_uverbs_flow_spec_esp_filter));
+		break;
 	case IBV_FLOW_SPEC_TCP:
 	case IBV_FLOW_SPEC_UDP:
 	case IBV_FLOW_SPEC_TCP | IBV_FLOW_SPEC_INNER:
diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h
index 157f64f..8e8064a 100644
--- a/libibverbs/kern-abi.h
+++ b/libibverbs/kern-abi.h
@@ -256,6 +256,7 @@  struct ibv_kern_spec {
 		struct ib_uverbs_flow_spec_eth eth;
 		struct ibv_kern_spec_ipv4 ipv4;
 		struct ib_uverbs_flow_spec_ipv4 ipv4_ext;
+		struct ib_uverbs_flow_spec_esp esp;
 		struct ib_uverbs_flow_spec_tcp_udp tcp_udp;
 		struct ib_uverbs_flow_spec_ipv6 ipv6;
 		struct ib_uverbs_flow_spec_tunnel tunnel;
diff --git a/libibverbs/man/ibv_create_flow.3 b/libibverbs/man/ibv_create_flow.3
index 1762503..43c0b9c 100644
--- a/libibverbs/man/ibv_create_flow.3
+++ b/libibverbs/man/ibv_create_flow.3
@@ -65,6 +65,7 @@  IBV_FLOW_SPEC_ETH                       = 0x20,   /* Flow specification of L2 he
 IBV_FLOW_SPEC_IPV4                      = 0x30,   /* Flow specification of IPv4 header */
 IBV_FLOW_SPEC_IPV6                      = 0x31,   /* Flow specification of IPv6 header */
 IBV_FLOW_SPEC_IPV4_EXT                  = 0x32,   /* Extended flow specification of IPv4 */
+IBV_FLOW_SPEC_ESP                       = 0x34,   /* Flow specification of ESP (IPSec) header */
 IBV_FLOW_SPEC_TCP                       = 0x40,   /* Flow specification of TCP header */
 IBV_FLOW_SPEC_UDP                       = 0x41,   /* Flow specification of UDP header */
 IBV_FLOW_SPEC_VXLAN_TUNNEL             	= 0x50,   /* Flow specification of VXLAN header */
diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h
index 8dbfcf1..a595db8 100644
--- a/libibverbs/verbs.h
+++ b/libibverbs/verbs.h
@@ -1380,6 +1380,7 @@  enum ibv_flow_spec_type {
 	IBV_FLOW_SPEC_IPV4		= 0x30,
 	IBV_FLOW_SPEC_IPV6		= 0x31,
 	IBV_FLOW_SPEC_IPV4_EXT		= 0x32,
+	IBV_FLOW_SPEC_ESP		= 0x34,
 	IBV_FLOW_SPEC_TCP		= 0x40,
 	IBV_FLOW_SPEC_UDP		= 0x41,
 	IBV_FLOW_SPEC_VXLAN_TUNNEL	= 0x50,
@@ -1449,6 +1450,18 @@  struct ibv_flow_spec_ipv6 {
 	struct ibv_flow_ipv6_filter mask;
 };
 
+struct ibv_flow_esp_filter {
+	uint32_t spi;
+	uint32_t seq;
+};
+
+struct ibv_flow_spec_esp {
+	enum ibv_flow_spec_type type;
+	uint16_t size;
+	struct ibv_flow_esp_filter val;
+	struct ibv_flow_esp_filter mask;
+};
+
 struct ibv_flow_tcp_udp_filter {
 	uint16_t dst_port;
 	uint16_t src_port;
@@ -1494,6 +1507,7 @@  struct ibv_flow_spec {
 		struct ibv_flow_spec_tcp_udp tcp_udp;
 		struct ibv_flow_spec_ipv4_ext ipv4_ext;
 		struct ibv_flow_spec_ipv6 ipv6;
+		struct ibv_flow_spec_esp esp;
 		struct ibv_flow_spec_tunnel tunnel;
 		struct ibv_flow_spec_action_tag flow_tag;
 		struct ibv_flow_spec_action_drop drop;