Blame SOURCES/0002-ibverbs-Allow-creation-and-modification-of-WQ-with-c.patch

23f80e
From 147a96f89b7ea5e5f708ab323c41fb81a99855aa Mon Sep 17 00:00:00 2001
23f80e
From: Noa Osherovich <noaos@mellanox.com>
23f80e
Date: Tue, 15 Nov 2016 11:15:43 +0200
23f80e
Subject: [PATCH rdma-core 2/6] ibverbs: Allow creation and modification of WQ
23f80e
 with cvlan offload
23f80e
23f80e
Enable WQ creation and modification with cvlan stripping offload.
23f80e
This includes:
23f80e
- Adding flags and flags mask fields to ibv_wq_init_attr.
23f80e
- Similarly extend ibv_wq_attr to allow setting and unsetting this
23f80e
  offload during ibv_modify_wq.
23f80e
23f80e
Creation of a WQ with cvlan offload is done by setting the following
23f80e
fields of the ibv_wq_init_attr struct:
23f80e
- Setting the IBV_WQ_FLAGS_CVLAN_STRIPPING bit of the create_flags
23f80e
  field.
23f80e
- Setting the IBV_WQ_INIT_ATTR_FLAGS bit of the comp_mask field.
23f80e
23f80e
Modification of the cvlan stripping property is done by setting the
23f80e
following fields of the ibv_wq_attr struct:
23f80e
- Setting IBV_WQ_ATTR_FLAGS bit of the attr_mask field.
23f80e
- Setting the IBV_RAW_PACKET_CAP_CVLAN_STRIPPING bit of the
23f80e
  flags_mask field.
23f80e
- Setting or unsetting the IBV_RAW_PACKET_CAP_CVLAN_STRIPPING bit of
23f80e
  the flags field.
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               | 18 ++++++++++++++++++
23f80e
 libibverbs/kern-abi.h          |  4 ++++
23f80e
 libibverbs/man/ibv_create_wq.3 | 11 +++++++++++
23f80e
 libibverbs/man/ibv_modify_wq.3 |  2 ++
23f80e
 libibverbs/verbs.h             | 14 ++++++++++++--
23f80e
 5 files changed, 47 insertions(+), 2 deletions(-)
23f80e
23f80e
diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c
23f80e
index 4aebbb51..b8fe76df 100644
23f80e
--- a/libibverbs/cmd.c
23f80e
+++ b/libibverbs/cmd.c
23f80e
@@ -1894,6 +1894,15 @@ int ibv_cmd_create_wq(struct ibv_context *context,
23f80e
 	cmd->max_wr = wq_init_attr->max_wr;
23f80e
 	cmd->comp_mask = 0;
23f80e
 
23f80e
+	if (cmd_core_size >= offsetof(struct ibv_create_wq, create_flags) +
23f80e
+	    sizeof(cmd->create_flags)) {
23f80e
+		if (wq_init_attr->comp_mask & IBV_WQ_INIT_ATTR_FLAGS) {
23f80e
+			if (wq_init_attr->create_flags & ~(IBV_WQ_FLAGS_RESERVED - 1))
23f80e
+				return EOPNOTSUPP;
23f80e
+			cmd->create_flags = wq_init_attr->create_flags;
23f80e
+		}
23f80e
+	}
23f80e
+
23f80e
 	err = write(context->cmd_fd, cmd, cmd_size);
23f80e
 	if (err != cmd_size)
23f80e
 		return errno;
23f80e
@@ -1927,6 +1936,15 @@ int ibv_cmd_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr,
23f80e
 
23f80e
 	cmd->curr_wq_state = attr->curr_wq_state;
23f80e
 	cmd->wq_state = attr->wq_state;
23f80e
+	if (cmd_core_size >= offsetof(struct ibv_modify_wq, flags_mask) +
23f80e
+	    sizeof(cmd->flags_mask)) {
23f80e
+		if (attr->attr_mask & IBV_WQ_ATTR_FLAGS) {
23f80e
+			if (attr->flags_mask & ~(IBV_WQ_FLAGS_RESERVED - 1))
23f80e
+				return EOPNOTSUPP;
23f80e
+			cmd->flags = attr->flags;
23f80e
+			cmd->flags_mask = attr->flags_mask;
23f80e
+		}
23f80e
+	}
23f80e
 	cmd->wq_handle = wq->handle;
23f80e
 	cmd->attr_mask = attr->attr_mask;
23f80e
 
23f80e
diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h
23f80e
index 3958f0c1..72a16b67 100644
23f80e
--- a/libibverbs/kern-abi.h
23f80e
+++ b/libibverbs/kern-abi.h
23f80e
@@ -1249,6 +1249,8 @@ struct ibv_create_wq {
23f80e
 	__u32 cq_handle;
23f80e
 	__u32 max_wr;
23f80e
 	__u32 max_sge;
23f80e
+	__u32 create_flags;
23f80e
+	__u32 reserved;
23f80e
 };
23f80e
 
23f80e
 struct ibv_create_wq_resp {
23f80e
@@ -1279,6 +1281,8 @@ struct ibv_modify_wq  {
23f80e
 	__u32 wq_handle;
23f80e
 	__u32 wq_state;
23f80e
 	__u32 curr_wq_state;
23f80e
+	__u32 flags;
23f80e
+	__u32 flags_mask;
23f80e
 };
23f80e
 
23f80e
 struct ibv_create_rwq_ind_table {
23f80e
diff --git a/libibverbs/man/ibv_create_wq.3 b/libibverbs/man/ibv_create_wq.3
23f80e
index aad67416..9a541fea 100644
23f80e
--- a/libibverbs/man/ibv_create_wq.3
23f80e
+++ b/libibverbs/man/ibv_create_wq.3
23f80e
@@ -31,8 +31,19 @@ uint32_t                   max_sge;       /* Requested max number of scatter/gat
23f80e
 struct  ibv_pd            *pd;            /* PD to be associated with the WQ */
23f80e
 struct  ibv_cq            *cq;            /* CQ to be associated with the WQ */
23f80e
 uint32_t                   comp_mask;     /* Identifies valid fields. Use ibv_wq_init_attr_mask */
23f80e
+uint32_t                   create_flags    /* Creation flags for this WQ, use enum ibv_wq_flags */
23f80e
 .in -8
23f80e
 };
23f80e
+
23f80e
+.sp
23f80e
+.nf
23f80e
+enum ibv_wq_flags {
23f80e
+.in +8
23f80e
+IBV_WQ_FLAGS_CVLAN_STRIPPING		= 1 << 0, /* CVLAN field will be stripped from incoming packets */
23f80e
+IBV_WQ_FLAGS_RESERVED			= 1 << 1,
23f80e
+.in -8
23f80e
+};
23f80e
+.nf
23f80e
 .fi
23f80e
 .PP
23f80e
 The function
23f80e
diff --git a/libibverbs/man/ibv_modify_wq.3 b/libibverbs/man/ibv_modify_wq.3
23f80e
index f17faedf..1972ec2a 100644
23f80e
--- a/libibverbs/man/ibv_modify_wq.3
23f80e
+++ b/libibverbs/man/ibv_modify_wq.3
23f80e
@@ -26,6 +26,8 @@ struct ibv_wq_attr {
23f80e
 uint32_t                attr_mask;     /* Use enum ibv_wq_attr_mask */
23f80e
 enum ibv_wq_state       wq_state;      /* Move to this state */
23f80e
 enum ibv_wq_state       curr_wq_state; /* Assume this is the current state */
23f80e
+uint32_t                flags;         /* Flags values to modify, use enum ibv_wq_flags */
23f80e
+uint32_t                flags_mask;    /* Which flags to modify, use enum ibv_wq_flags */
23f80e
 .in -8
23f80e
 };
23f80e
 .fi
23f80e
diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h
23f80e
index 604b09e8..33985666 100644
23f80e
--- a/libibverbs/verbs.h
23f80e
+++ b/libibverbs/verbs.h
23f80e
@@ -667,7 +667,13 @@ enum ibv_wq_type {
23f80e
 };
23f80e
 
23f80e
 enum ibv_wq_init_attr_mask {
23f80e
-	IBV_WQ_INIT_ATTR_RESERVED	= 1 << 0,
23f80e
+	IBV_WQ_INIT_ATTR_FLAGS		= 1 << 0,
23f80e
+	IBV_WQ_INIT_ATTR_RESERVED	= 1 << 1,
23f80e
+};
23f80e
+
23f80e
+enum ibv_wq_flags {
23f80e
+	IBV_WQ_FLAGS_CVLAN_STRIPPING		= 1 << 0,
23f80e
+	IBV_WQ_FLAGS_RESERVED			= 1 << 1,
23f80e
 };
23f80e
 
23f80e
 struct ibv_wq_init_attr {
23f80e
@@ -678,6 +684,7 @@ struct ibv_wq_init_attr {
23f80e
 	struct	ibv_pd	       *pd;
23f80e
 	struct	ibv_cq	       *cq;
23f80e
 	uint32_t		comp_mask;
23f80e
+	uint32_t		create_flags; /* use ibv_wq_flags */
23f80e
 };
23f80e
 
23f80e
 enum ibv_wq_state {
23f80e
@@ -690,7 +697,8 @@ enum ibv_wq_state {
23f80e
 enum ibv_wq_attr_mask {
23f80e
 	IBV_WQ_ATTR_STATE	= 1 << 0,
23f80e
 	IBV_WQ_ATTR_CURR_STATE	= 1 << 1,
23f80e
-	IBV_WQ_ATTR_RESERVED	= 1 << 2
23f80e
+	IBV_WQ_ATTR_FLAGS	= 1 << 2,
23f80e
+	IBV_WQ_ATTR_RESERVED	= 1 << 3,
23f80e
 };
23f80e
 
23f80e
 struct ibv_wq_attr {
23f80e
@@ -700,6 +708,8 @@ struct ibv_wq_attr {
23f80e
 	enum	ibv_wq_state	wq_state;
23f80e
 	/* Assume this is the current WQ state */
23f80e
 	enum	ibv_wq_state	curr_wq_state;
23f80e
+	uint32_t		flags; /* Use ibv_wq_flags */
23f80e
+	uint32_t		flags_mask; /* Use ibv_wq_flags */
23f80e
 };
23f80e
 
23f80e
 /*
23f80e
-- 
23f80e
2.12.1
23f80e