Blame SOURCES/0001-ibverbs-Report-raw-packet-caps-as-part-of-query-devi.patch

23f80e
From dbae02eb61ae3460922710997e7f22b1ebc075a7 Mon Sep 17 00:00:00 2001
23f80e
From: Noa Osherovich <noaos@mellanox.com>
23f80e
Date: Sun, 13 Nov 2016 10:47:15 +0200
23f80e
Subject: [PATCH rdma-core 1/6] ibverbs: Report raw packet caps as part of
23f80e
 query device
23f80e
23f80e
Currently, existing raw packet capabilities (IP CSUM and scatter FCS)
23f80e
are reported separately to the user via ibv_query_device_ex.
23f80e
23f80e
Unify those capabilities into a single enum and report them together
23f80e
for a better user experience.
23f80e
23f80e
Also introduce CVLAN stripping offload capability. CVLAN is the
23f80e
customer VLAN tag (inner tag).
23f80e
CVLAN stripping offload is the device's ability to strip this tag
23f80e
from incoming raw Ethernet packets and report the data in the
23f80e
matching work completion.
23f80e
23f80e
This patch includes:
23f80e
- Reading from the uverbs layer and report back to an application.
23f80e
- Extending ibv_devinfo to print that information.
23f80e
23f80e
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
23f80e
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
23f80e
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
23f80e
---
23f80e
 libibverbs/cmd.c                     |  8 ++++++++
23f80e
 libibverbs/examples/devinfo.c        | 14 ++++++++++++++
23f80e
 libibverbs/kern-abi.h                |  2 +-
23f80e
 libibverbs/man/ibv_query_device_ex.3 |  9 +++++++++
23f80e
 libibverbs/verbs.h                   |  7 +++++++
23f80e
 5 files changed, 39 insertions(+), 1 deletion(-)
23f80e
23f80e
diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c
23f80e
index 9b49da00..4aebbb51 100644
23f80e
--- a/libibverbs/cmd.c
23f80e
+++ b/libibverbs/cmd.c
23f80e
@@ -230,6 +230,14 @@ int ibv_cmd_query_device_ex(struct ibv_context *context,
23f80e
 			attr->max_wq_type_rq = resp->max_wq_type_rq;
23f80e
 	}
23f80e
 
23f80e
+	if (attr_size >= offsetof(struct ibv_device_attr_ex, raw_packet_caps) +
23f80e
+			 sizeof(attr->raw_packet_caps)) {
23f80e
+		if (resp->response_length >=
23f80e
+		    offsetof(struct ibv_query_device_resp_ex, raw_packet_caps) +
23f80e
+		    sizeof(resp->raw_packet_caps))
23f80e
+			attr->raw_packet_caps = resp->raw_packet_caps;
23f80e
+	}
23f80e
+
23f80e
 	return 0;
23f80e
 }
23f80e
 
23f80e
diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c
23f80e
index d88562f2..42222c4c 100644
23f80e
--- a/libibverbs/examples/devinfo.c
23f80e
+++ b/libibverbs/examples/devinfo.c
23f80e
@@ -401,6 +401,17 @@ static void print_packet_pacing_caps(const struct ibv_packet_pacing_caps *caps)
23f80e
 	}
23f80e
 }
23f80e
 
23f80e
+static void print_raw_packet_caps(uint32_t raw_packet_caps)
23f80e
+{
23f80e
+	printf("\traw packet caps:\n");
23f80e
+	if (raw_packet_caps & IBV_RAW_PACKET_CAP_CVLAN_STRIPPING)
23f80e
+		printf("\t\t\t\t\tC-VLAN stripping offload\n");
23f80e
+	if (raw_packet_caps & IBV_RAW_PACKET_CAP_SCATTER_FCS)
23f80e
+		printf("\t\t\t\t\tScatter FCS offload\n");
23f80e
+	if (raw_packet_caps & IBV_RAW_PACKET_CAP_IP_CSUM)
23f80e
+		printf("\t\t\t\t\tIP csum offload\n");
23f80e
+}
23f80e
+
23f80e
 static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
23f80e
 {
23f80e
 	struct ibv_context *ctx;
23f80e
@@ -499,6 +510,9 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
23f80e
 		else
23f80e
 			printf("\tcore clock not supported\n");
23f80e
 
23f80e
+		if (device_attr.raw_packet_caps)
23f80e
+			print_raw_packet_caps(device_attr.raw_packet_caps);
23f80e
+
23f80e
 		printf("\tdevice_cap_flags_ex:\t\t0x%" PRIX64 "\n", device_attr.device_cap_flags_ex);
23f80e
 		print_device_cap_flags_ex(device_attr.device_cap_flags_ex);
23f80e
 		print_tso_caps(&device_attr.tso_caps);
23f80e
diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h
23f80e
index 210dd3e4..3958f0c1 100644
23f80e
--- a/libibverbs/kern-abi.h
23f80e
+++ b/libibverbs/kern-abi.h
23f80e
@@ -290,7 +290,7 @@ struct ibv_query_device_resp_ex {
23f80e
 	__u64 device_cap_flags_ex;
23f80e
 	struct ibv_rss_caps_resp rss_caps;
23f80e
 	__u32  max_wq_type_rq;
23f80e
-	__u32 reserved;
23f80e
+	__u32 raw_packet_caps;
23f80e
 };
23f80e
 
23f80e
 struct ibv_query_port {
23f80e
diff --git a/libibverbs/man/ibv_query_device_ex.3 b/libibverbs/man/ibv_query_device_ex.3
23f80e
index c2910170..fdfb7081 100644
23f80e
--- a/libibverbs/man/ibv_query_device_ex.3
23f80e
+++ b/libibverbs/man/ibv_query_device_ex.3
23f80e
@@ -32,6 +32,7 @@ struct ibv_tso_caps    tso_caps;                   /* TCP segmentation offload c
23f80e
 struct ibv_rss_caps    rss_caps;                   /* RSS capabilities */
23f80e
 uint32_t               max_wq_type_rq;             /* Max Work Queue from type RQ */
23f80e
 struct ibv_packet_pacing_caps packet_pacing_caps; /* Packet pacing capabilities */
23f80e
+uint32_t               raw_packet_caps;            /* Raw packet capabilities, use enum ibv_raw_packet_caps */
23f80e
 .in -8
23f80e
 };
23f80e
 
23f80e
@@ -75,6 +76,14 @@ struct ibv_packet_pacing_caps {
23f80e
        uint32_t supported_qpts;    /* Bitmap showing which QP types are supported. */
23f80e
 };
23f80e
 
23f80e
+enum ibv_raw_packet_caps {
23f80e
+.in +8
23f80e
+IBV_RAW_PACKET_CAP_CVLAN_STRIPPING	= 1 << 0, /* CVLAN stripping is supported */
23f80e
+IBV_RAW_PACKET_CAP_SCATTER_FCS		= 1 << 1, /* FCS scattering is supported */
23f80e
+IBV_RAW_PACKET_CAP_IP_CSUM		= 1 << 2, /* IP CSUM offload is supported */
23f80e
+.in -8
23f80e
+};
23f80e
+
23f80e
 .fi
23f80e
 .SH "RETURN VALUE"
23f80e
 .B ibv_query_device_ex()
23f80e
diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h
23f80e
index 25f4eded..604b09e8 100644
23f80e
--- a/libibverbs/verbs.h
23f80e
+++ b/libibverbs/verbs.h
23f80e
@@ -252,6 +252,12 @@ struct ibv_packet_pacing_caps {
23f80e
 	uint32_t supported_qpts;
23f80e
 };
23f80e
 
23f80e
+enum ibv_raw_packet_caps {
23f80e
+	IBV_RAW_PACKET_CAP_CVLAN_STRIPPING	= 1 << 0,
23f80e
+	IBV_RAW_PACKET_CAP_SCATTER_FCS		= 1 << 1,
23f80e
+	IBV_RAW_PACKET_CAP_IP_CSUM		= 1 << 2,
23f80e
+};
23f80e
+
23f80e
 struct ibv_device_attr_ex {
23f80e
 	struct ibv_device_attr	orig_attr;
23f80e
 	uint32_t		comp_mask;
23f80e
@@ -263,6 +269,7 @@ struct ibv_device_attr_ex {
23f80e
 	struct ibv_rss_caps     rss_caps;
23f80e
 	uint32_t		max_wq_type_rq;
23f80e
 	struct ibv_packet_pacing_caps packet_pacing_caps;
23f80e
+	uint32_t		raw_packet_caps; /* Use ibv_raw_packet_caps */
23f80e
 };
23f80e
 
23f80e
 enum ibv_mtu {
23f80e
-- 
23f80e
2.12.1
23f80e