Skip to contentSkip to conversation

IB/mad: Add support for Intel Omni-Path Architecture (OPA) MAD processing.

PATCH In review [email protected] 5 participants 45 messages Jan 12, 2015 – Jan 20, 2015 23 messages not in the archive

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover IB/mad: Add support for Intel Omni-Path Architecture (OPA) MAD processing.

From: Ira Weiny <[email protected]>

The following patch series modifies the kernel MAD processing (ib_mad/ib_umad) and related interfaces to send and receive Intel Omni-Path Architecture MADs on devices which support them.

In addition to supporting some IBTA management classes, OPA devices use MADs with lengths up to 2K. These "jumbo" MADs increase the performance of management traffic.

To distinguish IBTA MADs from OPA MADs a new Base Version is introduced. The new format shares the same common header with IBTA MADs which allows us to share most of the MAD processing code when dealing with the new Base Version.

The patch series is broken into 3 main areas.

1) Add the ability for devices to indicate MAD size. modify the MAD code to use this MAD size

2) Enhance the interface to the device agents to support larger and variable length MADs.

3) Add support for creating and processing a new OPA MAD Base Version

Notes regarding changes from the RFC patches:

I did a series of tests using kmalloc vs kmem_cache. This includes running SA, PM, and SM Traffic with both OpenSM and OPA MADs. I have been unable to determine any performance difference in using kmalloc vs kmem_cache.

As Roland suggested the use of kmalloc makes device specific MAD sizes much easier to deal with so this series removes the kmem_cache and uses the common kmalloc calls for both IB and OPA devices.

Changes based on feedback from the RFC patches:

Rebased to latest Rolands for-next (3.18)
Convert from kmem_cache to kmalloc for receive buffers
remove unneeded jumbo_mad_private structure
Add device attribute caching and avoid caching of device flags in the
MAD code
Add "mad_size" device attribute
Use mad_size in all recv MAD buffer allocations
Remove IB_DEVICE_JUMBO_MAD_SUPPORT and internal MAD
"supports_jumbo_mads" flag in favor of an IB_DEVICE_OPA_MAD_SUPPORT flag
Added a new device_cap_flags2 field (device_cap_flags was "full" in 3.18) Limit the use of struct ib_mad to places where the data is actually an
IB MAD, common processing functions can use ib_mad_hdr.

rename commit messages to "IB/*" rather than "ib/*" reorder the patch series to put general refactoring and
pre-patches first.
Fix MLX5 compile

Ira Weiny (20):
IB/mad: Rename is_data_mad to is_rmpp_data_mad
IB/core: Cache device attributes for use by upper level drivers IB/mad: Change validate_mad signature to take ib_mad_hdr rather than
ib_mad
IB/mad: Change ib_response_mad signature to take ib_mad_hdr rather
than ib_mad
IB/mad: Change cast in rcv_has_same_class
IB/core: Add mad_size to ib_device_attr
IB/mad: Convert ib_mad_private allocations from kmem_cache to kmalloc IB/mad: Add helper function for smi_handle_dr_smp_send IB/mad: Add helper function for smi_handle_dr_smp_recv IB/mad: Add helper function for smi_check_forward_dr_smp IB/mad: Add helper function for SMI processing
IB/mad: Add MAD size parameters to process_mad
IB/mad: Add base version parameter to ib_create_send_mad IB/core: Add IB_DEVICE_OPA_MAD_SUPPORT device cap flag IB/mad: Create jumbo_mad data structures
IB/mad: Add Intel Omni-Path Architecture defines
IB/mad: Add registration check for Intel Omni-Path Architecture MADs IB/mad: Implement support for Intel Omni-Path Architecture base
version MADs in ib_create_send_mad
IB/mad: Implement Intel Omni-Path Architecture SMP processing IB/mad: Implement Intel Omni-Path Architecture MAD processing

 drivers/infiniband/core/agent.c              |   25 +-
 drivers/infiniband/core/agent.h              |    2 +-
 drivers/infiniband/core/cm.c                 |    6 +-
 drivers/infiniband/core/device.c             |    2 +
 drivers/infiniband/core/mad.c                |  521 +++++++++++++++++---------
 drivers/infiniband/core/mad_priv.h           |    9 +-
 drivers/infiniband/core/mad_rmpp.c           |  142 ++++----
 drivers/infiniband/core/opa_smi.h            |   78 ++++
 drivers/infiniband/core/sa_query.c           |    3 +-
 drivers/infiniband/core/smi.c                |  231 ++++++++----
 drivers/infiniband/core/smi.h                |    6 +
 drivers/infiniband/core/sysfs.c              |    5 +-
 drivers/infiniband/core/user_mad.c           |   42 ++-
 drivers/infiniband/hw/amso1100/c2_provider.c |    5 +-
 drivers/infiniband/hw/amso1100/c2_rnic.c     |    1 +
 drivers/infiniband/hw/cxgb3/iwch_provider.c  |    6 +-
 drivers/infiniband/hw/cxgb4/provider.c       |    8 +-
 drivers/infiniband/hw/ehca/ehca_hca.c        |    2 +
 drivers/infiniband/hw/ehca/ehca_sqp.c        |    8 +-
 drivers/infiniband/hw/ipath/ipath_mad.c      |    8 +-
 drivers/infiniband/hw/ipath/ipath_verbs.c    |    1 +
 drivers/infiniband/hw/ipath/ipath_verbs.h    |    3 +-
 drivers/infiniband/hw/mlx4/mad.c             |   12 +-
 drivers/infiniband/hw/mlx4/main.c            |    1 +
 drivers/infiniband/hw/mlx4/mlx4_ib.h         |    3 +-
 drivers/infiniband/hw/mlx5/mad.c             |    8 +-
 drivers/infiniband/hw/mlx5/main.c            |    1 +
 drivers/infiniband/hw/mlx5/mlx5_ib.h         |    3 +-
 drivers/infiniband/hw/mthca/mthca_dev.h      |    4 +-
 drivers/infiniband/hw/mthca/mthca_mad.c      |   12 +-
 drivers/infiniband/hw/mthca/mthca_provider.c |    2 +
 drivers/infiniband/hw/nes/nes_verbs.c        |    4 +-
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c     |    3 +-
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c  |    1 +
 drivers/infiniband/hw/qib/qib_iba7322.c      |    3 +-
 drivers/infiniband/hw/qib/qib_mad.c          |   11 +-
 drivers/infiniband/hw/qib/qib_verbs.c        |    1 +
 drivers/infiniband/hw/qib/qib_verbs.h        |    3 +-
 drivers/infiniband/hw/usnic/usnic_ib_verbs.c |    1 +
 drivers/infiniband/ulp/srpt/ib_srpt.c        |    3 +-
 include/rdma/ib_mad.h                        |   38 ++-
 include/rdma/ib_verbs.h                      |   15 +-
 include/rdma/opa_smi.h                       |  106 ++++++
 43 files changed, 987 insertions(+), 362 deletions(-)
 create mode 100644 drivers/infiniband/core/opa_smi.h
 create mode 100644 include/rdma/opa_smi.h

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1421082672-22588-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/20 IB/mad: Rename is_data_mad to is_rmpp_data_mad

From: Ira Weiny <[email protected]>

is_rmpp_data_mad is more descriptive for this function.

---
 drivers/infiniband/core/mad.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/core/mad.c +4 -3
index 74c30f4..4673262 100644
@@ -1734,7 +1734,7 @@ out:
 	return valid;
 }
 
-static int is_data_mad(struct ib_mad_agent_private *mad_agent_priv,
+static int is_rmpp_data_mad(struct ib_mad_agent_private *mad_agent_priv,
 		       struct ib_mad_hdr *mad_hdr)
 {
 	struct ib_rmpp_mad *rmpp_mad;
@@ -1836,7 +1836,7 @@ ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
 	 * been notified that the send has completed
 	 */
 	list_for_each_entry(wr, &mad_agent_priv->send_list, agent_list) {
-		if (is_data_mad(mad_agent_priv, wr->send_buf.mad) &&
+		if (is_rmpp_data_mad(mad_agent_priv, wr->send_buf.mad) &&
 		    wr->tid == mad->mad_hdr.tid &&
 		    wr->timeout &&
 		    rcv_has_same_class(wr, wc) &&
@@ -2411,7 +2411,8 @@ find_send_wr(struct ib_mad_agent_private *mad_agent_priv,
 
 	list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list,
 			    agent_list) {
-		if (is_data_mad(mad_agent_priv, mad_send_wr->send_buf.mad) &&
+		if (is_rmpp_data_mad(mad_agent_priv,
+				     mad_send_wr->send_buf.mad) &&
 		    &mad_send_wr->send_buf == send_buf)
 			return mad_send_wr;
 	}
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH 2/20 IB/core: Cache device attributes for use by upper level drivers

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

---
 drivers/infiniband/core/device.c |    2 ++
 include/rdma/ib_verbs.h          |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
drivers/infiniband/core/device.c +2 -0
index 18c1ece..3a6afde 100644
@@ -294,6 +294,8 @@ int ib_register_device(struct ib_device *device,
 	spin_lock_init(&device->event_handler_lock);
 	spin_lock_init(&device->client_data_lock);
 
+	device->query_device(device, &device->attributes);
+
 	ret = read_port_table_lengths(device);
 	if (ret) {
 		printk(KERN_WARNING "Couldn't create table lengths cache for device %s\n",
include/rdma/ib_verbs.h +1 -0
index 0d74f1d..86fc90f 100644
@@ -1675,6 +1675,7 @@ struct ib_device {
 	u32			     local_dma_lkey;
 	u8                           node_type;
 	u8                           phys_port_cnt;
+	struct ib_device_attr        attributes;
 };
 
 struct ib_client {
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1421082672-22588-3-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#5 lore raw

Re: [PATCH 02/20] IB/core: Cache device attributes for use by upper level drivers

Quoted 1 line · On 1/12/2015 7:10 PM, [email protected] wrote:

From: Ira Weiny <[email protected]>

Please avoid empty change-logs, e.g one liner will perfectly do here.

Quoted 24 lines
---
  drivers/infiniband/core/device.c |    2 ++
  include/rdma/ib_verbs.h          |    1 +
  2 files changed, 3 insertions(+), 0 deletions(-)
drivers/infiniband/core/device.c +2 -0
index 18c1ece..3a6afde 100644
@@ -294,6 +294,8 @@ int ib_register_device(struct ib_device *device,
  	spin_lock_init(&device->event_handler_lock);
  	spin_lock_init(&device->client_data_lock);
 
+	device->query_device(device, &device->attributes);
+
  	ret = read_port_table_lengths(device);
  	if (ret) {
  		printk(KERN_WARNING "Couldn't create table lengths cache for device %s\n",
include/rdma/ib_verbs.h +0 -0
index 0d74f1d..86fc90f 100644

include/rdma/ib_verbs.h struct ib_device { · line 1678

Quoted 4 lines
include/rdma/ib_verbs.h +1 -0
@@ -1675,6 +1675,7 @@ struct ib_device {
  	u32			     local_dma_lkey;
  	u8                           node_type;
  	u8                           phys_port_cnt;
+	struct ib_device_attr        attributes;

I think cached_dev_attrs will be better name.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54B607F2.3020904-VPRAkNaXOzVWk0Htik3J/[email protected]

author
#7 lore raw

RE: [PATCH 02/20] IB/core: Cache device attributes for use by upper level drivers

Quoted 5 lines · On 1/12/2015 7:10 PM, [email protected] wrote:
Quoted 1 line

From: Ira Weiny <[email protected]>

Please avoid empty change-logs, e.g one liner will perfectly do here.

Done.

Quoted 9 lines

include/rdma/ib_verbs.h struct ib_device { · line 1678

Quoted 8 lines

b/include/rdma/ib_verbs.h index 0d74f1d..86fc90f 100644

include/rdma/ib_verbs.h +1 -0
@@ -1675,6 +1675,7 @@ struct ib_device {
  	u32			     local_dma_lkey;
  	u8                           node_type;
  	u8                           phys_port_cnt;
+	struct ib_device_attr        attributes;

I think cached_dev_attrs will be better name.

Done for the entire series.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

PATCH 3/20 IB/mad: Change validate_mad signature to take ib_mad_hdr rather than ib_mad

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

validate_mad only needs access to the MAD header

---
 drivers/infiniband/core/mad.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/infiniband/core/mad.c +6 -6
index 4673262..9ffff9b 100644
@@ -1708,20 +1708,20 @@ out:
 	return mad_agent;
 }
 
-static int validate_mad(struct ib_mad *mad, u32 qp_num)
+static int validate_mad(struct ib_mad_hdr *mad_hdr, u32 qp_num)
 {
 	int valid = 0;
 
 	/* Make sure MAD base version is understood */
-	if (mad->mad_hdr.base_version != IB_MGMT_BASE_VERSION) {
+	if (mad_hdr->base_version != IB_MGMT_BASE_VERSION) {
 		pr_err("MAD received with unsupported base version %d\n",
-			mad->mad_hdr.base_version);
+			mad_hdr->base_version);
 		goto out;
 	}
 
 	/* Filter SMI packets sent to other than QP0 */
-	if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
-	    (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
+	if ((mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
+	    (mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
 		if (qp_num == 0)
 			valid = 1;
 	} else {
@@ -1979,7 +1979,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 		snoop_recv(qp_info, &recv->header.recv_wc, IB_MAD_SNOOP_RECVS);
 
 	/* Validate MAD */
-	if (!validate_mad(&recv->mad.mad, qp_info->qp->qp_num))
+	if (!validate_mad(&recv->mad.mad.mad_hdr, qp_info->qp->qp_num))
 		goto out;
 
 	response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

PATCH 4/20 IB/mad: Change ib_response_mad signature to take ib_mad_hdr rather than ib_mad

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

ib_response_mad only needs access to the MAD header

---
 drivers/infiniband/core/mad.c      |   20 ++++++++++----------
 drivers/infiniband/core/user_mad.c |    6 +++---
 include/rdma/ib_mad.h              |    2 +-
 3 files changed, 14 insertions(+), 14 deletions(-)
drivers/infiniband/core/mad.c +10 -10
index 9ffff9b..66b3940 100644
@@ -179,12 +179,12 @@ static int is_vendor_method_in_use(
 	return 0;
 }
 
-int ib_response_mad(struct ib_mad *mad)
+int ib_response_mad(struct ib_mad_hdr *hdr)
 {
-	return ((mad->mad_hdr.method & IB_MGMT_METHOD_RESP) ||
-		(mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS) ||
-		((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_BM) &&
-		 (mad->mad_hdr.attr_mod & IB_BM_ATTR_MOD_RESP)));
+	return ((hdr->method & IB_MGMT_METHOD_RESP) ||
+		(hdr->method == IB_MGMT_METHOD_TRAP_REPRESS) ||
+		((hdr->mgmt_class == IB_MGMT_CLASS_BM) &&
+		 (hdr->attr_mod & IB_BM_ATTR_MOD_RESP)));
 }
 EXPORT_SYMBOL(ib_response_mad);
 
@@ -791,7 +791,7 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
 	switch (ret)
 	{
 	case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY:
-		if (ib_response_mad(&mad_priv->mad.mad) &&
+		if (ib_response_mad(&mad_priv->mad.mad.mad_hdr) &&
 		    mad_agent_priv->agent.recv_handler) {
 			local->mad_priv = mad_priv;
 			local->recv_mad_agent = mad_agent_priv;
@@ -1628,7 +1628,7 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
 	unsigned long flags;
 
 	spin_lock_irqsave(&port_priv->reg_lock, flags);
-	if (ib_response_mad(mad)) {
+	if (ib_response_mad(&mad->mad_hdr)) {
 		u32 hi_tid;
 		struct ib_mad_agent_private *entry;
 
@@ -1765,8 +1765,8 @@ static inline int rcv_has_same_gid(struct ib_mad_agent_private *mad_agent_priv,
 	u8 port_num = mad_agent_priv->agent.port_num;
 	u8 lmc;
 
-	send_resp = ib_response_mad((struct ib_mad *)wr->send_buf.mad);
-	rcv_resp = ib_response_mad(rwc->recv_buf.mad);
+	send_resp = ib_response_mad((struct ib_mad_hdr *)wr->send_buf.mad);
+	rcv_resp = ib_response_mad(&rwc->recv_buf.mad->mad_hdr);
 
 	if (send_resp == rcv_resp)
 		/* both requests, or both responses. GIDs different */
@@ -1879,7 +1879,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
 	}
 
 	/* Complete corresponding request */
-	if (ib_response_mad(mad_recv_wc->recv_buf.mad)) {
+	if (ib_response_mad(&mad_recv_wc->recv_buf.mad->mad_hdr)) {
 		spin_lock_irqsave(&mad_agent_priv->lock, flags);
 		mad_send_wr = ib_find_send_mad(mad_agent_priv, mad_recv_wc);
 		if (!mad_send_wr) {
drivers/infiniband/core/user_mad.c +3 -3
index 928cdd2..66b5217 100644
@@ -426,11 +426,11 @@ static int is_duplicate(struct ib_umad_file *file,
 		 * the same TID, reject the second as a duplicate.  This is more
 		 * restrictive than required by the spec.
 		 */
-		if (!ib_response_mad((struct ib_mad *) hdr)) {
-			if (!ib_response_mad((struct ib_mad *) sent_hdr))
+		if (!ib_response_mad(hdr)) {
+			if (!ib_response_mad(sent_hdr))
 				return 1;
 			continue;
-		} else if (!ib_response_mad((struct ib_mad *) sent_hdr))
+		} else if (!ib_response_mad(sent_hdr))
 			continue;
 
 		if (same_destination(&packet->mad.hdr, &sent_packet->mad.hdr))
include/rdma/ib_mad.h +1 -1
index 9bb99e9..9c89939 100644
@@ -263,7 +263,7 @@ struct ib_mad_send_buf {
  * ib_response_mad - Returns if the specified MAD has been generated in
  *   response to a sent request or trap.
  */
-int ib_response_mad(struct ib_mad *mad);
+int ib_response_mad(struct ib_mad_hdr *hdr);
 
 /**
  * ib_get_rmpp_resptime - Returns the RMPP response time.
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

PATCH 5/20 IB/mad: Change cast in rcv_has_same_class

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Save dereference and clarifies that rcv_has_same_class can process both IB and OPA MADs.

---
 drivers/infiniband/core/mad.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/core/mad.c +1 -1
index 66b3940..819b794 100644
@@ -1750,7 +1750,7 @@ static int is_rmpp_data_mad(struct ib_mad_agent_private *mad_agent_priv,
 static inline int rcv_has_same_class(struct ib_mad_send_wr_private *wr,
 				     struct ib_mad_recv_wc *rwc)
 {
-	return ((struct ib_mad *)(wr->send_buf.mad))->mad_hdr.mgmt_class ==
+	return ((struct ib_mad_hdr *)(wr->send_buf.mad))->mgmt_class ==
 		rwc->recv_buf.mad->mad_hdr.mgmt_class;
 }
 
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1421082672-22588-6-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#12 lore raw

Re: [PATCH 05/20] IB/mad: Change cast in rcv_has_same_class

Quoted 4 lines · On 1/12/2015 7:10 PM, [email protected] wrote:

From: Ira Weiny <[email protected]>

Save dereference and clarifies that rcv_has_same_class can process both IB and OPA MADs.

I don't see any clarification below... something missing here?

Quoted 11 lines
---
  drivers/infiniband/core/mad.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/core/mad.c +0 -0
index 66b3940..819b794 100644

drivers/infiniband/core/mad.c static int is_rmpp_data_mad(struct ib_mad_agent_private *mad_agent_priv, · line 1756

Quoted 8 lines
drivers/infiniband/core/mad.c +1 -1
@@ -1750,7 +1750,7 @@ static int is_rmpp_data_mad(struct ib_mad_agent_private *mad_agent_priv,
  static inline int rcv_has_same_class(struct ib_mad_send_wr_private *wr,
  				     struct ib_mad_recv_wc *rwc)
  {
-	return ((struct ib_mad *)(wr->send_buf.mad))->mad_hdr.mgmt_class ==
+	return ((struct ib_mad_hdr *)(wr->send_buf.mad))->mgmt_class ==
  		rwc->recv_buf.mad->mad_hdr.mgmt_class;
  }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54B608AE.5040900-VPRAkNaXOzVWk0Htik3J/[email protected]

author
#14 lore raw

RE: [PATCH 05/20] IB/mad: Change cast in rcv_has_same_class

Quoted 8 lines · On 1/12/2015 7:10 PM, [email protected] wrote:
Quoted 4 lines

From: Ira Weiny <[email protected]>

Save dereference and clarifies that rcv_has_same_class can process both IB and OPA MADs.

I don't see any clarification below... something missing here?

Nothing missing. I was trying to indicate that this change simply indicates that this function can operate on any buffer which has an ib_mad_hdr.

Ira

Quoted 18 lines

drivers/infiniband/core/mad.c static int is_rmpp_data_mad(struct

Quoted 12 lines
---
  drivers/infiniband/core/mad.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/drivers/infiniband/core/mad.c index 66b3940..819b794 100644

drivers/infiniband/core/mad.c +0 -0
@@ -1750,7 +1750,7 @@ static int is_rmpp_data_mad(struct

ib_mad_agent_private *mad_agent_priv,

drivers/infiniband/core/mad.c static int is_rmpp_data_mad(struct ib_mad_agent_private *mad_agent_priv,

Quoted 4 lines
drivers/infiniband/core/mad.c +0 -1
  static inline int rcv_has_same_class(struct ib_mad_send_wr_private *wr,
  				     struct ib_mad_recv_wc *rwc)
  {
-	return ((struct ib_mad *)(wr->send_buf.mad))->mad_hdr.mgmt_class

==

Quoted 4 lines

drivers/infiniband/core/mad.c static int is_rmpp_data_mad(struct ib_mad_agent_private *mad_agent_priv, · line 1756

Quoted 4 lines
drivers/infiniband/core/mad.c +1 -0
+	return ((struct ib_mad_hdr *)(wr->send_buf.mad))->mgmt_class ==
  		rwc->recv_buf.mad->mad_hdr.mgmt_class;
  }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

PATCH 6/20 IB/core: Add mad_size to ib_device_attr

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Change all IB drivers to report the IB management size.
Add check to verify that all devices support at least IB_MGMT_MAD_SIZE

---
 drivers/infiniband/core/mad.c                |    6 ++++++
 drivers/infiniband/hw/amso1100/c2_rnic.c     |    1 +
 drivers/infiniband/hw/cxgb3/iwch_provider.c  |    1 +
 drivers/infiniband/hw/cxgb4/provider.c       |    1 +
 drivers/infiniband/hw/ehca/ehca_hca.c        |    2 ++
 drivers/infiniband/hw/ipath/ipath_verbs.c    |    1 +
 drivers/infiniband/hw/mlx4/main.c            |    1 +
 drivers/infiniband/hw/mlx5/main.c            |    1 +
 drivers/infiniband/hw/mthca/mthca_provider.c |    2 ++
 drivers/infiniband/hw/nes/nes_verbs.c        |    1 +
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c  |    1 +
 drivers/infiniband/hw/qib/qib_verbs.c        |    1 +
 drivers/infiniband/hw/usnic/usnic_ib_verbs.c |    1 +
 include/rdma/ib_mad.h                        |    1 +
 include/rdma/ib_verbs.h                      |    1 +
 15 files changed, 22 insertions(+), 0 deletions(-)
drivers/infiniband/core/mad.c +6 -0
index 819b794..031ae6f 100644
@@ -2924,6 +2924,12 @@ static int ib_mad_port_open(struct ib_device *device,
 	char name[sizeof "ib_mad123"];
 	int has_smi;
 
+	if (device->attributes.mad_size < IB_MGMT_MAD_SIZE) {
+		dev_err(&device->dev, "Min MAD size for device is %u\n",
+			IB_MGMT_MAD_SIZE);
+		return -EFAULT;
+	}
+
 	/* Create new device info */
 	port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL);
 	if (!port_priv) {
drivers/infiniband/hw/amso1100/c2_rnic.c +1 -0
index d2a6d96..8f77f2c 100644
@@ -197,6 +197,7 @@ static int c2_rnic_query(struct c2_dev *c2dev, struct ib_device_attr *props)
 	props->max_srq_sge         = 0;
 	props->max_pkeys           = 0;
 	props->local_ca_ack_delay  = 0;
+	props->mad_size            = IB_MGMT_MAD_SIZE;
 
  bail2:
 	vq_repbuf_free(c2dev, reply);
drivers/infiniband/hw/cxgb3/iwch_provider.c +1 -0
index 811b24a..a308760 100644
@@ -1174,6 +1174,7 @@ static int iwch_query_device(struct ib_device *ibdev,
 	props->max_pd = dev->attr.max_pds;
 	props->local_ca_ack_delay = 0;
 	props->max_fast_reg_page_list_len = T3_MAX_FASTREG_DEPTH;
+	props->mad_size = IB_MGMT_MAD_SIZE;
 
 	return 0;
 }
drivers/infiniband/hw/cxgb4/provider.c +1 -0
index 66bd6a2..cd1434e 100644
@@ -332,6 +332,7 @@ static int c4iw_query_device(struct ib_device *ibdev,
 	props->max_pd = T4_MAX_NUM_PD;
 	props->local_ca_ack_delay = 0;
 	props->max_fast_reg_page_list_len = t4_max_fr_depth(use_dsgl);
+	props->mad_size = IB_MGMT_MAD_SIZE;
 
 	return 0;
 }
drivers/infiniband/hw/ehca/ehca_hca.c +2 -0
index 9ed4d25..ca84efb 100644
@@ -133,6 +133,8 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
 		if (rblock->hca_cap_indicators & cap_mapping[i + 1])
 			props->device_cap_flags |= cap_mapping[i];
 
+	props->mad_size = IB_MGMT_MAD_SIZE;
+
 query_device1:
 	ehca_free_fw_ctrlblock(rblock);
 
drivers/infiniband/hw/ipath/ipath_verbs.c +1 -0
index 44ea939..f9d2dc9 100644
@@ -1538,6 +1538,7 @@ static int ipath_query_device(struct ib_device *ibdev,
 	props->max_mcast_qp_attach = ib_ipath_max_mcast_qp_attached;
 	props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
 		props->max_mcast_grp;
+	props->mad_size = IB_MGMT_MAD_SIZE;
 
 	return 0;
 }
drivers/infiniband/hw/mlx4/main.c +1 -0
index 57ecc5b..5c0ca80 100644
@@ -229,6 +229,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
 					   props->max_mcast_grp;
 	props->max_map_per_fmr = dev->dev->caps.max_fmr_maps;
+	props->mad_size        = IB_MGMT_MAD_SIZE;
 
 out:
 	kfree(in_mad);
drivers/infiniband/hw/mlx5/main.c +1 -0
index 8a87404..3613f87 100644
@@ -243,6 +243,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
 	props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
 					   props->max_mcast_grp;
 	props->max_map_per_fmr = INT_MAX; /* no limit in ConnectIB */
+	props->mad_size        = IB_MGMT_MAD_SIZE;
 
 #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
 	if (dev->mdev->caps.gen.flags & MLX5_DEV_CAP_FLAG_ON_DMND_PG)
drivers/infiniband/hw/mthca/mthca_provider.c +2 -0
index 415f8e1..9194b70 100644
@@ -123,6 +123,8 @@ static int mthca_query_device(struct ib_device *ibdev,
 		props->max_map_per_fmr =
 			(1 << (32 - ilog2(mdev->limits.num_mpts))) - 1;
 
+	props->mad_size = IB_MGMT_MAD_SIZE;
+
 	err = 0;
  out:
 	kfree(in_mad);
drivers/infiniband/hw/nes/nes_verbs.c +1 -0
index c0d0296..c4b0aba 100644
@@ -555,6 +555,7 @@ static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *prop
 	props->max_qp_init_rd_atom = props->max_qp_rd_atom;
 	props->atomic_cap = IB_ATOMIC_NONE;
 	props->max_map_per_fmr = 1;
+	props->mad_size = IB_MGMT_MAD_SIZE;
 
 	return 0;
 }
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 -0
index fb8d8c4..ee04a25 100644
@@ -103,6 +103,7 @@ int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr)
 	attr->local_ca_ack_delay = dev->attr.local_ca_ack_delay;
 	attr->max_fast_reg_page_list_len = dev->attr.max_pages_per_frmr;
 	attr->max_pkeys = 1;
+	attr->mad_size = IB_MGMT_MAD_SIZE;
 	return 0;
 }
 
drivers/infiniband/hw/qib/qib_verbs.c +1 -0
index 9bcfbd8..95ceb17 100644
@@ -1591,6 +1591,7 @@ static int qib_query_device(struct ib_device *ibdev,
 	props->max_mcast_qp_attach = ib_qib_max_mcast_qp_attached;
 	props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
 		props->max_mcast_grp;
+	props->mad_size = IB_MGMT_MAD_SIZE;
 
 	return 0;
 }
drivers/infiniband/hw/usnic/usnic_ib_verbs.c +1 -0
index 53bd6a2..3cd571e 100644
@@ -296,6 +296,7 @@ int usnic_ib_query_device(struct ib_device *ibdev,
 	props->max_mcast_qp_attach = 0;
 	props->max_total_mcast_qp_attach = 0;
 	props->max_map_per_fmr = 0;
+	props->mad_size = IB_MGMT_MAD_SIZE;
 	/* Owned by Userspace
 	 * max_qp_wr, max_sge, max_sge_rd, max_cqe */
 	mutex_unlock(&us_ibdev->usdev_lock);
include/rdma/ib_mad.h +1 -0
index 9c89939..5823016 100644
@@ -135,6 +135,7 @@ enum {
 	IB_MGMT_SA_DATA = 200,
 	IB_MGMT_DEVICE_HDR = 64,
 	IB_MGMT_DEVICE_DATA = 192,
+	IB_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + IB_MGMT_MAD_DATA,
 };
 
 struct ib_mad_hdr {
include/rdma/ib_verbs.h +1 -0
index 86fc90f..b35e472 100644
@@ -210,6 +210,7 @@ struct ib_device_attr {
 	int			sig_prot_cap;
 	int			sig_guard_cap;
 	struct ib_odp_caps	odp_caps;
+	u32			mad_size;
 };
 
 enum ib_mtu {
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1421082672-22588-7-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#17 lore raw

Re: [PATCH 06/20] IB/core: Add mad_size to ib_device_attr

Quoted 1 line · On 1/12/2015 7:10 PM, [email protected] wrote:

Change all IB drivers to report the IB management size.

Do you mean the maximal size of IB MADs they support? if this is the case, please reflect it in the field name.

Quoted 1 line

Add check to verify that all devices support at least IB_MGMT_MAD_SIZE

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54B608FB.8020901-VPRAkNaXOzVWk0Htik3J/[email protected]

author
#19 lore raw

RE: [PATCH 06/20] IB/core: Add mad_size to ib_device_attr

Quoted 6 lines · On 1/12/2015 7:10 PM, [email protected] wrote:
Quoted 1 line

Change all IB drivers to report the IB management size.

Do you mean the maximal size of IB MADs they support? if this is the case, please reflect it in the field name.

Done. Changed to max_mad_size.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw

PATCH 7/20 IB/mad: Convert ib_mad_private allocations from kmem_cache to kmalloc

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Use the new mad_size specified by devices for the allocations and DMA maps.

kmalloc is more flexible to support devices with different sized MADs and research and testing showed that the current use of kmem_cache does not provide performance benefits over kmalloc.

---
 drivers/infiniband/core/mad.c |   73 +++++++++++++++++------------------------
 1 files changed, 30 insertions(+), 43 deletions(-)
drivers/infiniband/core/mad.c +30 -43
index 031ae6f..b1ec225 100644
@@ -59,8 +59,6 @@ MODULE_PARM_DESC(send_queue_size, "Size of send queue in number of work requests
 module_param_named(recv_queue_size, mad_recvq_size, int, 0444);
 MODULE_PARM_DESC(recv_queue_size, "Size of receive queue in number of work requests");
 
-static struct kmem_cache *ib_mad_cache;
-
 static struct list_head ib_mad_port_list;
 static u32 ib_mad_client_id = 0;
 
@@ -717,6 +715,13 @@ static void build_smp_wc(struct ib_qp *qp,
 	wc->port_num = port_num;
 }
 
+static struct ib_mad_private *alloc_mad_priv(struct ib_device *dev)
+{
+	return (kmalloc(sizeof(struct ib_mad_private_header) +
+			sizeof(struct ib_grh) +
+			dev->attributes.mad_size, GFP_ATOMIC));
+}
+
 /*
  * Return 0 if SMP is to be sent
  * Return 1 if SMP was consumed locally (whether or not solicited)
@@ -771,7 +776,8 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
 	}
 	local->mad_priv = NULL;
 	local->recv_mad_agent = NULL;
-	mad_priv = kmem_cache_alloc(ib_mad_cache, GFP_ATOMIC);
+
+	mad_priv = alloc_mad_priv(mad_agent_priv->agent.device);
 	if (!mad_priv) {
 		ret = -ENOMEM;
 		dev_err(&device->dev, "No memory for local response MAD\n");
@@ -801,10 +807,10 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
 			 */
 			atomic_inc(&mad_agent_priv->refcount);
 		} else
-			kmem_cache_free(ib_mad_cache, mad_priv);
+			kfree(mad_priv);
 		break;
 	case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED:
-		kmem_cache_free(ib_mad_cache, mad_priv);
+		kfree(mad_priv);
 		break;
 	case IB_MAD_RESULT_SUCCESS:
 		/* Treat like an incoming receive MAD */
@@ -820,14 +826,14 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
 			 * No receiving agent so drop packet and
 			 * generate send completion.
 			 */
-			kmem_cache_free(ib_mad_cache, mad_priv);
+			kfree(mad_priv);
 			break;
 		}
 		local->mad_priv = mad_priv;
 		local->recv_mad_agent = recv_mad_agent;
 		break;
 	default:
-		kmem_cache_free(ib_mad_cache, mad_priv);
+		kfree(mad_priv);
 		kfree(local);
 		ret = -EINVAL;
 		goto out;
@@ -1237,7 +1243,7 @@ void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc)
 					    recv_wc);
 		priv = container_of(mad_priv_hdr, struct ib_mad_private,
 				    header);
-		kmem_cache_free(ib_mad_cache, priv);
+		kfree(priv);
 	}
 }
 EXPORT_SYMBOL(ib_free_recv_mad);
@@ -1924,6 +1930,11 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
 	}
 }
 
+static size_t mad_recv_buf_size(struct ib_device *dev)
+{
+	return(sizeof(struct ib_grh) + dev->attributes.mad_size);
+}
+
 static bool generate_unmatched_resp(struct ib_mad_private *recv,
 				    struct ib_mad_private *response)
 {
@@ -1964,8 +1975,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 	recv = container_of(mad_priv_hdr, struct ib_mad_private, header);
 	ib_dma_unmap_single(port_priv->device,
 			    recv->header.mapping,
-			    sizeof(struct ib_mad_private) -
-			      sizeof(struct ib_mad_private_header),
+			    mad_recv_buf_size(port_priv->device),
 			    DMA_FROM_DEVICE);
 
 	/* Setup MAD receive work completion from "normal" work completion */
@@ -1982,7 +1992,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 	if (!validate_mad(&recv->mad.mad.mad_hdr, qp_info->qp->qp_num))
 		goto out;
 
-	response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
+	response = alloc_mad_priv(port_priv->device);
 	if (!response) {
 		dev_err(&port_priv->device->dev,
 			"ib_mad_recv_done_handler no memory for response buffer\n");
@@ -2075,7 +2085,7 @@ out:
 	if (response) {
 		ib_mad_post_receive_mads(qp_info, response);
 		if (recv)
-			kmem_cache_free(ib_mad_cache, recv);
+			kfree(recv);
 	} else
 		ib_mad_post_receive_mads(qp_info, recv);
 }
@@ -2535,7 +2545,7 @@ local_send_completion:
 		spin_lock_irqsave(&mad_agent_priv->lock, flags);
 		atomic_dec(&mad_agent_priv->refcount);
 		if (free_mad)
-			kmem_cache_free(ib_mad_cache, local->mad_priv);
+			kfree(local->mad_priv);
 		kfree(local);
 	}
 	spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
@@ -2664,7 +2674,7 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
 			mad_priv = mad;
 			mad = NULL;
 		} else {
-			mad_priv = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
+			mad_priv = alloc_mad_priv(qp_info->port_priv->device);
 			if (!mad_priv) {
 				dev_err(&qp_info->port_priv->device->dev,
 					"No memory for receive buffer\n");
@@ -2674,8 +2684,7 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
 		}
 		sg_list.addr = ib_dma_map_single(qp_info->port_priv->device,
 						 &mad_priv->grh,
-						 sizeof *mad_priv -
-						   sizeof mad_priv->header,
+						 mad_recv_buf_size(qp_info->port_priv->device),
 						 DMA_FROM_DEVICE);
 		if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device,
 						  sg_list.addr))) {
@@ -2699,10 +2708,9 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
 			spin_unlock_irqrestore(&recv_queue->lock, flags);
 			ib_dma_unmap_single(qp_info->port_priv->device,
 					    mad_priv->header.mapping,
-					    sizeof *mad_priv -
-					      sizeof mad_priv->header,
+					    mad_recv_buf_size(qp_info->port_priv->device),
 					    DMA_FROM_DEVICE);
-			kmem_cache_free(ib_mad_cache, mad_priv);
+			kfree(mad_priv);
 			dev_err(&qp_info->port_priv->device->dev,
 				"ib_post_recv failed: %d\n", ret);
 			break;
@@ -2739,10 +2747,9 @@ static void cleanup_recv_queue(struct ib_mad_qp_info *qp_info)
 
 		ib_dma_unmap_single(qp_info->port_priv->device,
 				    recv->header.mapping,
-				    sizeof(struct ib_mad_private) -
-				      sizeof(struct ib_mad_private_header),
+				    mad_recv_buf_size(qp_info->port_priv->device),
 				    DMA_FROM_DEVICE);
-		kmem_cache_free(ib_mad_cache, recv);
+		kfree(recv);
 	}
 
 	qp_info->recv_queue.count = 0;
@@ -3138,45 +3145,25 @@ static struct ib_client mad_client = {
 
 static int __init ib_mad_init_module(void)
 {
-	int ret;
-
 	mad_recvq_size = min(mad_recvq_size, IB_MAD_QP_MAX_SIZE);
 	mad_recvq_size = max(mad_recvq_size, IB_MAD_QP_MIN_SIZE);
 
 	mad_sendq_size = min(mad_sendq_size, IB_MAD_QP_MAX_SIZE);
 	mad_sendq_size = max(mad_sendq_size, IB_MAD_QP_MIN_SIZE);
 
-	ib_mad_cache = kmem_cache_create("ib_mad",
-					 sizeof(struct ib_mad_private),
-					 0,
-					 SLAB_HWCACHE_ALIGN,
-					 NULL);
-	if (!ib_mad_cache) {
-		pr_err("Couldn't create ib_mad cache\n");
-		ret = -ENOMEM;
-		goto error1;
-	}
-
 	INIT_LIST_HEAD(&ib_mad_port_list);
 
 	if (ib_register_client(&mad_client)) {
 		pr_err("Couldn't register ib_mad client\n");
-		ret = -EINVAL;
-		goto error2;
+		return(-EINVAL);
 	}
 
 	return 0;
-
-error2:
-	kmem_cache_destroy(ib_mad_cache);
-error1:
-	return ret;
 }
 
 static void __exit ib_mad_cleanup_module(void)
 {
 	ib_unregister_client(&mad_client);
-	kmem_cache_destroy(ib_mad_cache);
 }
 
 module_init(ib_mad_init_module);
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#21 lore raw

PATCH 8/20 IB/mad: Add helper function for smi_handle_dr_smp_send

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

This helper function will be used for processing both IB and OPA SMP sends.

---
 drivers/infiniband/core/smi.c |   81 ++++++++++++++++++++++++-----------------
 1 files changed, 47 insertions(+), 34 deletions(-)
drivers/infiniband/core/smi.c +47 -34
index 5855e44..3bac6e6 100644
@@ -39,84 +39,81 @@
 #include <rdma/ib_smi.h>
 #include "smi.h"
 
-/*
- * Fixup a directed route SMP for sending
- * Return 0 if the SMP should be discarded
- */
-enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
-				       u8 node_type, int port_num)
+static inline
+enum smi_action __smi_handle_dr_smp_send(u8 node_type, int port_num,
+					 u8 *hop_ptr, u8 hop_cnt,
+					 u8 *initial_path,
+					 u8 *return_path,
+					 u8 direction,
+					 int dr_dlid_is_permissive,
+					 int dr_slid_is_permissive)
 {
-	u8 hop_ptr, hop_cnt;
-
-	hop_ptr = smp->hop_ptr;
-	hop_cnt = smp->hop_cnt;
-
 	/* See section 14.2.2.2, Vol 1 IB spec */
 	/* C14-6 -- valid hop_cnt values are from 0 to 63 */
 	if (hop_cnt >= IB_SMP_MAX_PATH_HOPS)
 		return IB_SMI_DISCARD;
 
-	if (!ib_get_smp_direction(smp)) {
+	if (!direction) {
 		/* C14-9:1 */
-		if (hop_cnt && hop_ptr == 0) {
-			smp->hop_ptr++;
-			return (smp->initial_path[smp->hop_ptr] ==
+		if (hop_cnt && *hop_ptr == 0) {
+			(*hop_ptr)++;
+			return (initial_path[*hop_ptr] ==
 				port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-9:2 */
-		if (hop_ptr && hop_ptr < hop_cnt) {
+		if (*hop_ptr && *hop_ptr < hop_cnt) {
 			if (node_type != RDMA_NODE_IB_SWITCH)
 				return IB_SMI_DISCARD;
 
-			/* smp->return_path set when received */
-			smp->hop_ptr++;
-			return (smp->initial_path[smp->hop_ptr] ==
+			/* return_path set when received */
+			(*hop_ptr)++;
+			return (initial_path[*hop_ptr] ==
 				port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-9:3 -- We're at the end of the DR segment of path */
-		if (hop_ptr == hop_cnt) {
-			/* smp->return_path set when received */
-			smp->hop_ptr++;
+		if (*hop_ptr == hop_cnt) {
+			/* return_path set when received */
+			(*hop_ptr)++;
 			return (node_type == RDMA_NODE_IB_SWITCH ||
-				smp->dr_dlid == IB_LID_PERMISSIVE ?
+				dr_dlid_is_permissive ?
 				IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
 		/* C14-9:5 -- Fail unreasonable hop pointer */
-		return (hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+		return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
 
 	} else {
 		/* C14-13:1 */
-		if (hop_cnt && hop_ptr == hop_cnt + 1) {
-			smp->hop_ptr--;
-			return (smp->return_path[smp->hop_ptr] ==
+		if (hop_cnt && *hop_ptr == hop_cnt + 1) {
+			(*hop_ptr)--;
+			return (return_path[*hop_ptr] ==
 				port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-13:2 */
-		if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
+		if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) {
 			if (node_type != RDMA_NODE_IB_SWITCH)
 				return IB_SMI_DISCARD;
 
-			smp->hop_ptr--;
-			return (smp->return_path[smp->hop_ptr] ==
+			(*hop_ptr)--;
+			return (return_path[*hop_ptr] ==
 				port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-13:3 -- at the end of the DR segment of path */
-		if (hop_ptr == 1) {
-			smp->hop_ptr--;
+		if (*hop_ptr == 1) {
+			(*hop_ptr)--;
 			/* C14-13:3 -- SMPs destined for SM shouldn't be here */
 			return (node_type == RDMA_NODE_IB_SWITCH ||
-				smp->dr_slid == IB_LID_PERMISSIVE ?
+				dr_slid_is_permissive ?
 				IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-13:4 -- hop_ptr = 0 -> should have gone to SM */
-		if (hop_ptr == 0)
+		if (*hop_ptr == 0)
 			return IB_SMI_HANDLE;
 
 		/* C14-13:5 -- Check for unreasonable hop pointer */
@@ -125,6 +122,22 @@ enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
 }
 
 /*
+ * Fixup a directed route SMP for sending
+ * Return 0 if the SMP should be discarded
+ */
+enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
+				       u8 node_type, int port_num)
+{
+	return __smi_handle_dr_smp_send(node_type, port_num,
+					&smp->hop_ptr, smp->hop_cnt,
+					smp->initial_path,
+					smp->return_path,
+					ib_get_smp_direction(smp),
+					smp->dr_dlid == IB_LID_PERMISSIVE,
+					smp->dr_slid == IB_LID_PERMISSIVE);
+}
+
+/*
  * Adjust information for a received SMP
  * Return 0 if the SMP should be dropped
  */
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#22 lore raw

PATCH 9/20 IB/mad: Add helper function for smi_handle_dr_smp_recv

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

This helper function will be used for processing both IB and OPA SMP recvs.

---
 drivers/infiniband/core/smi.c |   80 ++++++++++++++++++++++++-----------------
 1 files changed, 47 insertions(+), 33 deletions(-)
drivers/infiniband/core/smi.c +47 -33
index 3bac6e6..24670de 100644
@@ -137,91 +137,105 @@ enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
 					smp->dr_slid == IB_LID_PERMISSIVE);
 }
 
-/*
- * Adjust information for a received SMP
- * Return 0 if the SMP should be dropped
- */
-enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,
-				       int port_num, int phys_port_cnt)
+static inline
+enum smi_action __smi_handle_dr_smp_recv(u8 node_type, int port_num,
+					 int phys_port_cnt,
+					 u8 *hop_ptr, u8 hop_cnt,
+					 u8 *initial_path,
+					 u8 *return_path,
+					 u8 direction,
+					 int dr_dlid_is_permissive,
+					 int dr_slid_is_permissive)
 {
-	u8 hop_ptr, hop_cnt;
-
-	hop_ptr = smp->hop_ptr;
-	hop_cnt = smp->hop_cnt;
-
 	/* See section 14.2.2.2, Vol 1 IB spec */
 	/* C14-6 -- valid hop_cnt values are from 0 to 63 */
 	if (hop_cnt >= IB_SMP_MAX_PATH_HOPS)
 		return IB_SMI_DISCARD;
 
-	if (!ib_get_smp_direction(smp)) {
+	if (!direction) {
 		/* C14-9:1 -- sender should have incremented hop_ptr */
-		if (hop_cnt && hop_ptr == 0)
+		if (hop_cnt && *hop_ptr == 0)
 			return IB_SMI_DISCARD;
 
 		/* C14-9:2 -- intermediate hop */
-		if (hop_ptr && hop_ptr < hop_cnt) {
+		if (*hop_ptr && *hop_ptr < hop_cnt) {
 			if (node_type != RDMA_NODE_IB_SWITCH)
 				return IB_SMI_DISCARD;
 
-			smp->return_path[hop_ptr] = port_num;
-			/* smp->hop_ptr updated when sending */
-			return (smp->initial_path[hop_ptr+1] <= phys_port_cnt ?
+			return_path[*hop_ptr] = port_num;
+			/* hop_ptr updated when sending */
+			return (initial_path[*hop_ptr+1] <= phys_port_cnt ?
 				IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-9:3 -- We're at the end of the DR segment of path */
-		if (hop_ptr == hop_cnt) {
+		if (*hop_ptr == hop_cnt) {
 			if (hop_cnt)
-				smp->return_path[hop_ptr] = port_num;
-			/* smp->hop_ptr updated when sending */
+				return_path[*hop_ptr] = port_num;
+			/* hop_ptr updated when sending */
 
 			return (node_type == RDMA_NODE_IB_SWITCH ||
-				smp->dr_dlid == IB_LID_PERMISSIVE ?
+				dr_dlid_is_permissive ?
 				IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
 		/* C14-9:5 -- fail unreasonable hop pointer */
-		return (hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+		return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
 
 	} else {
 
 		/* C14-13:1 */
-		if (hop_cnt && hop_ptr == hop_cnt + 1) {
-			smp->hop_ptr--;
-			return (smp->return_path[smp->hop_ptr] ==
+		if (hop_cnt && *hop_ptr == hop_cnt + 1) {
+			(*hop_ptr)--;
+			return (return_path[*hop_ptr] ==
 				port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-13:2 */
-		if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
+		if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) {
 			if (node_type != RDMA_NODE_IB_SWITCH)
 				return IB_SMI_DISCARD;
 
-			/* smp->hop_ptr updated when sending */
-			return (smp->return_path[hop_ptr-1] <= phys_port_cnt ?
+			/* hop_ptr updated when sending */
+			return (return_path[*hop_ptr-1] <= phys_port_cnt ?
 				IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-13:3 -- We're at the end of the DR segment of path */
-		if (hop_ptr == 1) {
-			if (smp->dr_slid == IB_LID_PERMISSIVE) {
+		if (*hop_ptr == 1) {
+			if (dr_slid_is_permissive) {
 				/* giving SMP to SM - update hop_ptr */
-				smp->hop_ptr--;
+				(*hop_ptr)--;
 				return IB_SMI_HANDLE;
 			}
-			/* smp->hop_ptr updated when sending */
+			/* hop_ptr updated when sending */
 			return (node_type == RDMA_NODE_IB_SWITCH ?
 				IB_SMI_HANDLE : IB_SMI_DISCARD);
 		}
 
 		/* C14-13:4 -- hop_ptr = 0 -> give to SM */
 		/* C14-13:5 -- Check for unreasonable hop pointer */
-		return (hop_ptr == 0 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+		return (*hop_ptr == 0 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
 	}
 }
 
+/*
+ * Adjust information for a received SMP
+ * Return 0 if the SMP should be dropped
+ */
+enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,
+				       int port_num, int phys_port_cnt)
+{
+	return __smi_handle_dr_smp_recv(node_type, port_num, phys_port_cnt,
+					&smp->hop_ptr, smp->hop_cnt,
+					smp->initial_path,
+					smp->return_path,
+					ib_get_smp_direction(smp),
+					smp->dr_dlid == IB_LID_PERMISSIVE,
+					smp->dr_slid == IB_LID_PERMISSIVE);
+}
+
 enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp)
 {
 	u8 hop_ptr, hop_cnt;
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#23 lore raw

PATCH 10/20 IB/mad: Add helper function for smi_check_forward_dr_smp

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

This helper function will be used for processing both IB and OPA SMPs.

---
 drivers/infiniband/core/smi.c |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)
drivers/infiniband/core/smi.c +17 -9
index 24670de..8a5fb1d 100644
@@ -236,21 +236,20 @@ enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,
 					smp->dr_slid == IB_LID_PERMISSIVE);
 }
 
-enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp)
+static inline
+enum smi_forward_action __smi_check_forward_dr_smp(u8 hop_ptr, u8 hop_cnt,
+						   u8 direction,
+						   int dr_dlid_is_permissive,
+						   int dr_slid_is_permissive)
 {
-	u8 hop_ptr, hop_cnt;
-
-	hop_ptr = smp->hop_ptr;
-	hop_cnt = smp->hop_cnt;
-
-	if (!ib_get_smp_direction(smp)) {
+	if (!direction) {
 		/* C14-9:2 -- intermediate hop */
 		if (hop_ptr && hop_ptr < hop_cnt)
 			return IB_SMI_FORWARD;
 
 		/* C14-9:3 -- at the end of the DR segment of path */
 		if (hop_ptr == hop_cnt)
-			return (smp->dr_dlid == IB_LID_PERMISSIVE ?
+			return (dr_dlid_is_permissive ?
 				IB_SMI_SEND : IB_SMI_LOCAL);
 
 		/* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
@@ -263,10 +262,19 @@ enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp)
 
 		/* C14-13:3 -- at the end of the DR segment of path */
 		if (hop_ptr == 1)
-			return (smp->dr_slid != IB_LID_PERMISSIVE ?
+			return (dr_slid_is_permissive ?
 				IB_SMI_SEND : IB_SMI_LOCAL);
 	}
 	return IB_SMI_LOCAL;
+
+}
+
+enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp)
+{
+	return __smi_check_forward_dr_smp(smp->hop_ptr, smp->hop_cnt,
+					  ib_get_smp_direction(smp),
+					  smp->dr_dlid == IB_LID_PERMISSIVE,
+					  smp->dr_slid != IB_LID_PERMISSIVE);
 }
 
 /*
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#24 lore raw

PATCH 11/20 IB/mad: Add helper function for SMI processing

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

This helper function will be used for processing both IB and OPA SMPs.

---
 drivers/infiniband/core/mad.c |   85 +++++++++++++++++++++++-----------------
 1 files changed, 49 insertions(+), 36 deletions(-)
drivers/infiniband/core/mad.c +49 -36
index b1ec225..4e70e15 100644
@@ -1930,6 +1930,52 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
 	}
 }
 
+enum smi_action handle_ib_smi(struct ib_mad_port_private *port_priv,
+			      struct ib_mad_qp_info *qp_info,
+			      struct ib_wc *wc,
+			      int port_num,
+			      struct ib_mad_private *recv,
+			      struct ib_mad_private *response)
+{
+	enum smi_forward_action retsmi;
+
+	if (smi_handle_dr_smp_recv(&recv->mad.smp,
+				   port_priv->device->node_type,
+				   port_num,
+				   port_priv->device->phys_port_cnt) ==
+				   IB_SMI_DISCARD)
+		return IB_SMI_DISCARD;
+
+	retsmi = smi_check_forward_dr_smp(&recv->mad.smp);
+	if (retsmi == IB_SMI_LOCAL)
+		return IB_SMI_HANDLE;
+
+	if (retsmi == IB_SMI_SEND) { /* don't forward */
+		if (smi_handle_dr_smp_send(&recv->mad.smp,
+					   port_priv->device->node_type,
+					   port_num) == IB_SMI_DISCARD)
+			return IB_SMI_DISCARD;
+
+		if (smi_check_local_smp(&recv->mad.smp, port_priv->device) == IB_SMI_DISCARD)
+			return IB_SMI_DISCARD;
+	} else if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) {
+		/* forward case for switches */
+		memcpy(response, recv, sizeof(*response));
+		response->header.recv_wc.wc = &response->header.wc;
+		response->header.recv_wc.recv_buf.mad = &response->mad.mad;
+		response->header.recv_wc.recv_buf.grh = &response->grh;
+
+		agent_send_response(&response->mad.mad,
+				    &response->grh, wc,
+				    port_priv->device,
+				    smi_get_fwd_port(&recv->mad.smp),
+				    qp_info->qp->qp_num);
+
+		return IB_SMI_DISCARD;
+	}
+	return IB_SMI_HANDLE;
+}
+
 static size_t mad_recv_buf_size(struct ib_device *dev)
 {
 	return(sizeof(struct ib_grh) + dev->attributes.mad_size);
@@ -2006,45 +2052,12 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 
 	if (recv->mad.mad.mad_hdr.mgmt_class ==
 	    IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
-		enum smi_forward_action retsmi;
-
-		if (smi_handle_dr_smp_recv(&recv->mad.smp,
-					   port_priv->device->node_type,
-					   port_num,
-					   port_priv->device->phys_port_cnt) ==
-					   IB_SMI_DISCARD)
+		if (handle_ib_smi(port_priv, qp_info, wc, port_num, recv,
+				  response)
+		    == IB_SMI_DISCARD)
 			goto out;
-
-		retsmi = smi_check_forward_dr_smp(&recv->mad.smp);
-		if (retsmi == IB_SMI_LOCAL)
-			goto local;
-
-		if (retsmi == IB_SMI_SEND) { /* don't forward */
-			if (smi_handle_dr_smp_send(&recv->mad.smp,
-						   port_priv->device->node_type,
-						   port_num) == IB_SMI_DISCARD)
-				goto out;
-
-			if (smi_check_local_smp(&recv->mad.smp, port_priv->device) == IB_SMI_DISCARD)
-				goto out;
-		} else if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) {
-			/* forward case for switches */
-			memcpy(response, recv, sizeof(*response));
-			response->header.recv_wc.wc = &response->header.wc;
-			response->header.recv_wc.recv_buf.mad = &response->mad.mad;
-			response->header.recv_wc.recv_buf.grh = &response->grh;
-
-			agent_send_response(&response->mad.mad,
-					    &response->grh, wc,
-					    port_priv->device,
-					    smi_get_fwd_port(&recv->mad.smp),
-					    qp_info->qp->qp_num);
-
-			goto out;
-		}
 	}
 
-local:
 	/* Give driver "right of first refusal" on incoming MAD */
 	if (port_priv->device->process_mad) {
 		ret = port_priv->device->process_mad(port_priv->device, 0,
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#25 lore raw

PATCH 12/20 IB/mad: Add MAD size parameters to process_mad

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

In support of variable length MADs add in and out MAD size parameters to the process_mad call.

The out MAD size parameter is passed by reference such that it can be updated by the agent to indicate the proper response length to be sent by the MAD stack.

The in and out MAD parameters are made generic by specifying them as ib_mad_hdr.

All MAD sizes are set to the device MAD size specified by the devices.

Drivers are modified to verify the MAD sizes passed to them.

---

Changes from RFC:
Fix MLX5 compile

 drivers/infiniband/core/mad.c                |   29 +++++++++++++++++---------
 drivers/infiniband/core/sysfs.c              |    5 +++-
 drivers/infiniband/hw/amso1100/c2_provider.c |    5 +++-
 drivers/infiniband/hw/cxgb3/iwch_provider.c  |    5 +++-
 drivers/infiniband/hw/cxgb4/provider.c       |    7 ++++-
 drivers/infiniband/hw/ehca/ehca_sqp.c        |    8 ++++++-
 drivers/infiniband/hw/ipath/ipath_mad.c      |    8 ++++++-
 drivers/infiniband/hw/ipath/ipath_verbs.h    |    3 +-
 drivers/infiniband/hw/mlx4/mad.c             |    9 +++++++-
 drivers/infiniband/hw/mlx4/mlx4_ib.h         |    3 +-
 drivers/infiniband/hw/mlx5/mad.c             |    8 ++++++-
 drivers/infiniband/hw/mlx5/mlx5_ib.h         |    3 +-
 drivers/infiniband/hw/mthca/mthca_dev.h      |    4 +-
 drivers/infiniband/hw/mthca/mthca_mad.c      |    9 ++++++-
 drivers/infiniband/hw/nes/nes_verbs.c        |    3 +-
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c     |    3 +-
 drivers/infiniband/hw/qib/qib_mad.c          |    8 ++++++-
 drivers/infiniband/hw/qib/qib_verbs.h        |    3 +-
 include/rdma/ib_verbs.h                      |    8 ++++--
 19 files changed, 98 insertions(+), 33 deletions(-)
drivers/infiniband/core/mad.c +19 -10
index 4e70e15..ec2b664 100644
@@ -715,11 +715,12 @@ static void build_smp_wc(struct ib_qp *qp,
 	wc->port_num = port_num;
 }
 
-static struct ib_mad_private *alloc_mad_priv(struct ib_device *dev)
+static struct ib_mad_private *alloc_mad_priv(struct ib_device *dev,
+					     size_t *mad_size)
 {
+	*mad_size = dev->attributes.mad_size;
 	return (kmalloc(sizeof(struct ib_mad_private_header) +
-			sizeof(struct ib_grh) +
-			dev->attributes.mad_size, GFP_ATOMIC));
+			sizeof(struct ib_grh) + *mad_size, GFP_ATOMIC));
 }
 
 /*
@@ -741,6 +742,8 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
 	u8 port_num;
 	struct ib_wc mad_wc;
 	struct ib_send_wr *send_wr = &mad_send_wr->send_wr;
+	size_t in_mad_size = mad_agent_priv->agent.device->attributes.mad_size;
+	size_t out_mad_size;
 
 	if (device->node_type == RDMA_NODE_IB_SWITCH &&
 	    smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
@@ -777,7 +780,7 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
 	local->mad_priv = NULL;
 	local->recv_mad_agent = NULL;
 
-	mad_priv = alloc_mad_priv(mad_agent_priv->agent.device);
+	mad_priv = alloc_mad_priv(mad_agent_priv->agent.device, &out_mad_size);
 	if (!mad_priv) {
 		ret = -ENOMEM;
 		dev_err(&device->dev, "No memory for local response MAD\n");
@@ -792,8 +795,9 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
 
 	/* No GRH for DR SMP */
 	ret = device->process_mad(device, 0, port_num, &mad_wc, NULL,
-				  (struct ib_mad *)smp,
-				  (struct ib_mad *)&mad_priv->mad);
+				  (struct ib_mad_hdr *)smp, in_mad_size,
+				  (struct ib_mad_hdr *)&mad_priv->mad,
+				  &out_mad_size);
 	switch (ret)
 	{
 	case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY:
@@ -2011,6 +2015,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 	struct ib_mad_agent_private *mad_agent;
 	int port_num;
 	int ret = IB_MAD_RESULT_SUCCESS;
+	size_t resp_mad_size;
 
 	mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id;
 	qp_info = mad_list->mad_queue->qp_info;
@@ -2038,7 +2043,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 	if (!validate_mad(&recv->mad.mad.mad_hdr, qp_info->qp->qp_num))
 		goto out;
 
-	response = alloc_mad_priv(port_priv->device);
+	response = alloc_mad_priv(port_priv->device, &resp_mad_size);
 	if (!response) {
 		dev_err(&port_priv->device->dev,
 			"ib_mad_recv_done_handler no memory for response buffer\n");
@@ -2063,8 +2068,10 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 		ret = port_priv->device->process_mad(port_priv->device, 0,
 						     port_priv->port_num,
 						     wc, &recv->grh,
-						     &recv->mad.mad,
-						     &response->mad.mad);
+						     (struct ib_mad_hdr *)&recv->mad.mad,
+						     port_priv->device->attributes.mad_size,
+						     (struct ib_mad_hdr *)&response->mad.mad,
+						     &resp_mad_size);
 		if (ret & IB_MAD_RESULT_SUCCESS) {
 			if (ret & IB_MAD_RESULT_CONSUMED)
 				goto out;
@@ -2687,7 +2694,9 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
 			mad_priv = mad;
 			mad = NULL;
 		} else {
-			mad_priv = alloc_mad_priv(qp_info->port_priv->device);
+			size_t mad_size;
+			mad_priv = alloc_mad_priv(qp_info->port_priv->device,
+						  &mad_size);
 			if (!mad_priv) {
 				dev_err(&qp_info->port_priv->device->dev,
 					"No memory for receive buffer\n");
drivers/infiniband/core/sysfs.c +4 -1
index cbd0383..a59bb8f 100644
@@ -326,6 +326,7 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
 	int width  = (tab_attr->index >> 16) & 0xff;
 	struct ib_mad *in_mad  = NULL;
 	struct ib_mad *out_mad = NULL;
+	size_t out_mad_size = sizeof(*out_mad);
 	ssize_t ret;
 
 	if (!p->ibdev->process_mad)
@@ -347,7 +348,9 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
 	in_mad->data[41] = p->port_num;	/* PortSelect field */
 
 	if ((p->ibdev->process_mad(p->ibdev, IB_MAD_IGNORE_MKEY,
-		 p->port_num, NULL, NULL, in_mad, out_mad) &
+		 p->port_num, NULL, NULL,
+		 (struct ib_mad_hdr *)in_mad, sizeof(*in_mad),
+		 (struct ib_mad_hdr *)out_mad, &out_mad_size) &
 	     (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) !=
 	    (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) {
 		ret = -EINVAL;
drivers/infiniband/hw/amso1100/c2_provider.c +4 -1
index bdf3507..94926e6 100644
@@ -584,7 +584,10 @@ static int c2_process_mad(struct ib_device *ibdev,
 			  u8 port_num,
 			  struct ib_wc *in_wc,
 			  struct ib_grh *in_grh,
-			  struct ib_mad *in_mad, struct ib_mad *out_mad)
+			  struct ib_mad_hdr *in_mad,
+			  size_t in_mad_size,
+			  struct ib_mad_hdr *out_mad,
+			  size_t *out_mad_size)
 {
 	pr_debug("%s:%u\n", __func__, __LINE__);
 	return -ENOSYS;
drivers/infiniband/hw/cxgb3/iwch_provider.c +4 -1
index a308760..fdb1945 100644
@@ -87,7 +87,10 @@ static int iwch_process_mad(struct ib_device *ibdev,
 			    u8 port_num,
 			    struct ib_wc *in_wc,
 			    struct ib_grh *in_grh,
-			    struct ib_mad *in_mad, struct ib_mad *out_mad)
+			    struct ib_mad_hdr *in_mad,
+			    size_t in_mad_size,
+			    struct ib_mad_hdr *out_mad,
+			    size_t *out_mad_size)
 {
 	return -ENOSYS;
 }
drivers/infiniband/hw/cxgb4/provider.c +5 -2
index cd1434e..376ea3e 100644
@@ -81,8 +81,11 @@ static int c4iw_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 
 static int c4iw_process_mad(struct ib_device *ibdev, int mad_flags,
 			    u8 port_num, struct ib_wc *in_wc,
-			    struct ib_grh *in_grh, struct ib_mad *in_mad,
-			    struct ib_mad *out_mad)
+			    struct ib_grh *in_grh,
+			    struct ib_mad_hdr *in_mad,
+			    size_t in_mad_size,
+			    struct ib_mad_hdr *out_mad,
+			    size_t *out_mad_size)
 {
 	return -ENOSYS;
 }
drivers/infiniband/hw/ehca/ehca_sqp.c +7 -1
index dba8f9f..d4ed490 100644
@@ -218,9 +218,15 @@ perf_reply:
 
 int ehca_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 		     struct ib_wc *in_wc, struct ib_grh *in_grh,
-		     struct ib_mad *in_mad, struct ib_mad *out_mad)
+		     struct ib_mad_hdr *in, size_t in_mad_size,
+		     struct ib_mad_hdr *out, size_t *out_mad_size)
 {
 	int ret;
+	struct ib_mad *in_mad = (struct ib_mad *)in;
+	struct ib_mad *out_mad = (struct ib_mad *)out;
+
+	if (in_mad_size != sizeof(*in_mad) || *out_mad_size != sizeof(*out_mad))
+		return IB_MAD_RESULT_FAILURE;
 
 	if (!port_num || port_num > ibdev->phys_port_cnt || !in_wc)
 		return IB_MAD_RESULT_FAILURE;
drivers/infiniband/hw/ipath/ipath_mad.c +7 -1
index e890e5b..d554089 100644
@@ -1491,9 +1491,15 @@ bail:
  */
 int ipath_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 		      struct ib_wc *in_wc, struct ib_grh *in_grh,
-		      struct ib_mad *in_mad, struct ib_mad *out_mad)
+		      struct ib_mad_hdr *in, size_t in_mad_size,
+		      struct ib_mad_hdr *out, size_t *out_mad_size)
 {
 	int ret;
+	struct ib_mad *in_mad = (struct ib_mad *)in;
+	struct ib_mad *out_mad = (struct ib_mad *)out;
+
+	if (in_mad_size != sizeof(*in_mad) || *out_mad_size != sizeof(*out_mad))
+		return IB_MAD_RESULT_FAILURE;
 
 	switch (in_mad->mad_hdr.mgmt_class) {
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
drivers/infiniband/hw/ipath/ipath_verbs.h +2 -1
index ae6cff4..cd8dd09 100644
@@ -703,7 +703,8 @@ int ipath_process_mad(struct ib_device *ibdev,
 		      u8 port_num,
 		      struct ib_wc *in_wc,
 		      struct ib_grh *in_grh,
-		      struct ib_mad *in_mad, struct ib_mad *out_mad);
+		      struct ib_mad_hdr *in, size_t in_mad_size,
+		      struct ib_mad_hdr *out, size_t *out_mad_size);
 
 /*
  * Compare the lower 24 bits of the two values.
drivers/infiniband/hw/mlx4/mad.c +8 -1
index 82a7dd8..4acb3ee 100644
@@ -855,8 +855,15 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 
 int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 			struct ib_wc *in_wc, struct ib_grh *in_grh,
-			struct ib_mad *in_mad, struct ib_mad *out_mad)
+			struct ib_mad_hdr *in, size_t in_mad_size,
+			struct ib_mad_hdr *out, size_t *out_mad_size)
 {
+	struct ib_mad *in_mad = (struct ib_mad *)in;
+	struct ib_mad *out_mad = (struct ib_mad *)out;
+
+	if (in_mad_size != sizeof(*in_mad) || *out_mad_size != sizeof(*out_mad))
+		return IB_MAD_RESULT_FAILURE;
+
 	switch (rdma_port_get_link_layer(ibdev, port_num)) {
 	case IB_LINK_LAYER_INFINIBAND:
 		return ib_process_mad(ibdev, mad_flags, port_num, in_wc,
drivers/infiniband/hw/mlx4/mlx4_ib.h +2 -1
index 6eb743f..c5960fe 100644
@@ -690,7 +690,8 @@ int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
 		 void *in_mad, void *response_mad);
 int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags,	u8 port_num,
 			struct ib_wc *in_wc, struct ib_grh *in_grh,
-			struct ib_mad *in_mad, struct ib_mad *out_mad);
+			struct ib_mad_hdr *in, size_t in_mad_size,
+			struct ib_mad_hdr *out, size_t *out_mad_size);
 int mlx4_ib_mad_init(struct mlx4_ib_dev *dev);
 void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev);
 
drivers/infiniband/hw/mlx5/mad.c +7 -1
index 657af9a..c790066 100644
@@ -59,10 +59,16 @@ int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
 
 int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 			struct ib_wc *in_wc, struct ib_grh *in_grh,
-			struct ib_mad *in_mad, struct ib_mad *out_mad)
+			struct ib_mad_hdr *in, size_t in_mad_size,
+			struct ib_mad_hdr *out, size_t *out_mad_size)
 {
 	u16 slid;
 	int err;
+	struct ib_mad *in_mad = (struct ib_mad *)in;
+	struct ib_mad *out_mad = (struct ib_mad *)out;
+
+	if (in_mad_size != sizeof(*in_mad) || *out_mad_size != sizeof(*out_mad))
+		return IB_MAD_RESULT_FAILURE;
 
 	slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
 
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -1
index 83f22fe..7897d35 100644
@@ -589,7 +589,8 @@ int mlx5_ib_unmap_fmr(struct list_head *fmr_list);
 int mlx5_ib_fmr_dealloc(struct ib_fmr *ibfmr);
 int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 			struct ib_wc *in_wc, struct ib_grh *in_grh,
-			struct ib_mad *in_mad, struct ib_mad *out_mad);
+			struct ib_mad_hdr *in, size_t in_mad_size,
+			struct ib_mad_hdr *out, size_t *out_mad_size);
 struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
 					  struct ib_ucontext *context,
 					  struct ib_udata *udata);
drivers/infiniband/hw/mthca/mthca_dev.h +2 -2
index 7e6a6d6..60d15f1 100644
@@ -578,8 +578,8 @@ int mthca_process_mad(struct ib_device *ibdev,
 		      u8 port_num,
 		      struct ib_wc *in_wc,
 		      struct ib_grh *in_grh,
-		      struct ib_mad *in_mad,
-		      struct ib_mad *out_mad);
+		      struct ib_mad_hdr *in, size_t in_mad_size,
+		      struct ib_mad_hdr *out, size_t *out_mad_size);
 int mthca_create_agents(struct mthca_dev *dev);
 void mthca_free_agents(struct mthca_dev *dev);
 
drivers/infiniband/hw/mthca/mthca_mad.c +7 -2
index 8881fa3..5d597a1 100644
@@ -197,13 +197,18 @@ int mthca_process_mad(struct ib_device *ibdev,
 		      u8 port_num,
 		      struct ib_wc *in_wc,
 		      struct ib_grh *in_grh,
-		      struct ib_mad *in_mad,
-		      struct ib_mad *out_mad)
+		      struct ib_mad_hdr *in, size_t in_mad_size,
+		      struct ib_mad_hdr *out, size_t *out_mad_size)
 {
 	int err;
 	u16 slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
 	u16 prev_lid = 0;
 	struct ib_port_attr pattr;
+	struct ib_mad *in_mad = (struct ib_mad *)in;
+	struct ib_mad *out_mad = (struct ib_mad *)out;
+
+	if (in_mad_size != sizeof(*in_mad) || *out_mad_size != sizeof(*out_mad))
+		return IB_MAD_RESULT_FAILURE;
 
 	/* Forward locally generated traps to the SM */
 	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
drivers/infiniband/hw/nes/nes_verbs.c +2 -1
index c4b0aba..70c748f 100644
@@ -3224,7 +3224,8 @@ static int nes_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
  */
 static int nes_process_mad(struct ib_device *ibdev, int mad_flags,
 		u8 port_num, struct ib_wc *in_wc, struct ib_grh *in_grh,
-		struct ib_mad *in_mad, struct ib_mad *out_mad)
+		struct ib_mad_hdr *in, size_t in_mad_size,
+		struct ib_mad_hdr *out, size_t *out_mad_size)
 {
 	nes_debug(NES_DBG_INIT, "\n");
 	return -ENOSYS;
drivers/infiniband/hw/ocrdma/ocrdma_ah.c +2 -1
index f3cc8c9..8f22518 100644
@@ -189,7 +189,8 @@ int ocrdma_process_mad(struct ib_device *ibdev,
 		       u8 port_num,
 		       struct ib_wc *in_wc,
 		       struct ib_grh *in_grh,
-		       struct ib_mad *in_mad, struct ib_mad *out_mad)
+		       struct ib_mad_hdr *in, size_t in_mad_size,
+		       struct ib_mad_hdr *out, size_t *out_mad_size)
 {
 	return IB_MAD_RESULT_SUCCESS;
 }
drivers/infiniband/hw/qib/qib_mad.c +7 -1
index 636be11..fb022a3 100644
@@ -2401,11 +2401,17 @@ bail:
  */
 int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 		    struct ib_wc *in_wc, struct ib_grh *in_grh,
-		    struct ib_mad *in_mad, struct ib_mad *out_mad)
+		    struct ib_mad_hdr *in, size_t in_mad_size,
+		    struct ib_mad_hdr *out, size_t *out_mad_size)
 {
 	int ret;
 	struct qib_ibport *ibp = to_iport(ibdev, port);
 	struct qib_pportdata *ppd = ppd_from_ibp(ibp);
+	struct ib_mad *in_mad = (struct ib_mad *)in;
+	struct ib_mad *out_mad = (struct ib_mad *)out;
+
+	if (in_mad_size != sizeof(*in_mad) || *out_mad_size != sizeof(*out_mad))
+		return IB_MAD_RESULT_FAILURE;
 
 	switch (in_mad->mad_hdr.mgmt_class) {
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
drivers/infiniband/hw/qib/qib_verbs.h +2 -1
index bfc8948..77f1d31 100644
@@ -873,7 +873,8 @@ void qib_sys_guid_chg(struct qib_ibport *ibp);
 void qib_node_desc_chg(struct qib_ibport *ibp);
 int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 		    struct ib_wc *in_wc, struct ib_grh *in_grh,
-		    struct ib_mad *in_mad, struct ib_mad *out_mad);
+		    struct ib_mad_hdr *in, size_t in_mad_size,
+		    struct ib_mad_hdr *out, size_t *out_mad_size);
 int qib_create_agents(struct qib_ibdev *dev);
 void qib_free_agents(struct qib_ibdev *dev);
 
include/rdma/ib_verbs.h +5 -3
index b35e472..5024f1f 100644
@@ -1408,7 +1408,7 @@ struct ib_flow {
 	struct ib_uobject	*uobject;
 };
 
-struct ib_mad;
+struct ib_mad_hdr;
 struct ib_grh;
 
 enum ib_process_mad_flags {
@@ -1640,8 +1640,10 @@ struct ib_device {
 						  u8 port_num,
 						  struct ib_wc *in_wc,
 						  struct ib_grh *in_grh,
-						  struct ib_mad *in_mad,
-						  struct ib_mad *out_mad);
+						  struct ib_mad_hdr *in_mad,
+						  size_t in_mad_size,
+						  struct ib_mad_hdr *out_mad,
+						  size_t *out_mad_size);
 	struct ib_xrcd *	   (*alloc_xrcd)(struct ib_device *device,
 						 struct ib_ucontext *ucontext,
 						 struct ib_udata *udata);
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#26 lore raw

PATCH 13/20 IB/mad: Add base version parameter to ib_create_send_mad

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

In preparation to support the new OPA MAD Base version, add a base version parameter ib_create_send_mad and set it to IB_MGMT_BASE_VERSION for current users.

Definition of the new base version and it's processing will occur in later patches.

---
 drivers/infiniband/core/agent.c         |    3 ++-
 drivers/infiniband/core/cm.c            |    6 ++++--
 drivers/infiniband/core/mad.c           |    3 ++-
 drivers/infiniband/core/mad_rmpp.c      |    6 ++++--
 drivers/infiniband/core/sa_query.c      |    3 ++-
 drivers/infiniband/core/user_mad.c      |    3 ++-
 drivers/infiniband/hw/mlx4/mad.c        |    3 ++-
 drivers/infiniband/hw/mthca/mthca_mad.c |    3 ++-
 drivers/infiniband/hw/qib/qib_iba7322.c |    3 ++-
 drivers/infiniband/hw/qib/qib_mad.c     |    3 ++-
 drivers/infiniband/ulp/srpt/ib_srpt.c   |    3 ++-
 include/rdma/ib_mad.h                   |    4 +++-
 12 files changed, 29 insertions(+), 14 deletions(-)
drivers/infiniband/core/agent.c +2 -1
index f6d2961..b6bd305 100644
@@ -108,7 +108,8 @@ void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
 
 	send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0,
 				      IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
-				      GFP_KERNEL);
+				      GFP_KERNEL,
+				      IB_MGMT_BASE_VERSION);
 	if (IS_ERR(send_buf)) {
 		dev_err(&device->dev, "ib_create_send_mad error\n");
 		goto err1;
drivers/infiniband/core/cm.c +4 -2
index e28a494..5767781 100644
@@ -267,7 +267,8 @@ static int cm_alloc_msg(struct cm_id_private *cm_id_priv,
 	m = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn,
 			       cm_id_priv->av.pkey_index,
 			       0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
-			       GFP_ATOMIC);
+			       GFP_ATOMIC,
+			       IB_MGMT_BASE_VERSION);
 	if (IS_ERR(m)) {
 		ib_destroy_ah(ah);
 		return PTR_ERR(m);
@@ -297,7 +298,8 @@ static int cm_alloc_response_msg(struct cm_port *port,
 
 	m = ib_create_send_mad(port->mad_agent, 1, mad_recv_wc->wc->pkey_index,
 			       0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
-			       GFP_ATOMIC);
+			       GFP_ATOMIC,
+			       IB_MGMT_BASE_VERSION);
 	if (IS_ERR(m)) {
 		ib_destroy_ah(ah);
 		return PTR_ERR(m);
drivers/infiniband/core/mad.c +2 -1
index ec2b664..6a6efd6 100644
@@ -930,7 +930,8 @@ struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
 					    u32 remote_qpn, u16 pkey_index,
 					    int rmpp_active,
 					    int hdr_len, int data_len,
-					    gfp_t gfp_mask)
+					    gfp_t gfp_mask,
+					    u8 base_version)
 {
 	struct ib_mad_agent_private *mad_agent_priv;
 	struct ib_mad_send_wr_private *mad_send_wr;
drivers/infiniband/core/mad_rmpp.c +4 -2
index f37878c..2379e2d 100644
@@ -139,7 +139,8 @@ static void ack_recv(struct mad_rmpp_recv *rmpp_recv,
 	hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
 	msg = ib_create_send_mad(&rmpp_recv->agent->agent, recv_wc->wc->src_qp,
 				 recv_wc->wc->pkey_index, 1, hdr_len,
-				 0, GFP_KERNEL);
+				 0, GFP_KERNEL,
+				 IB_MGMT_BASE_VERSION);
 	if (IS_ERR(msg))
 		return;
 
@@ -165,7 +166,8 @@ static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent,
 	hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
 	msg = ib_create_send_mad(agent, recv_wc->wc->src_qp,
 				 recv_wc->wc->pkey_index, 1,
-				 hdr_len, 0, GFP_KERNEL);
+				 hdr_len, 0, GFP_KERNEL,
+				 IB_MGMT_BASE_VERSION);
 	if (IS_ERR(msg))
 		ib_destroy_ah(ah);
 	else {
drivers/infiniband/core/sa_query.c +2 -1
index c38f030..32c3fe6 100644
@@ -583,7 +583,8 @@ static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
 	query->mad_buf = ib_create_send_mad(query->port->agent, 1,
 					    query->sm_ah->pkey_index,
 					    0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA,
-					    gfp_mask);
+					    gfp_mask,
+					    IB_MGMT_BASE_VERSION);
 	if (IS_ERR(query->mad_buf)) {
 		kref_put(&query->sm_ah->ref, free_sm_ah);
 		return -ENOMEM;
drivers/infiniband/core/user_mad.c +2 -1
index 66b5217..9628494 100644
@@ -521,7 +521,8 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 	packet->msg = ib_create_send_mad(agent,
 					 be32_to_cpu(packet->mad.hdr.qpn),
 					 packet->mad.hdr.pkey_index, rmpp_active,
-					 hdr_len, data_len, GFP_KERNEL);
+					 hdr_len, data_len, GFP_KERNEL,
+					 IB_MGMT_BASE_VERSION);
 	if (IS_ERR(packet->msg)) {
 		ret = PTR_ERR(packet->msg);
 		goto err_ah;
drivers/infiniband/hw/mlx4/mad.c +2 -1
index 4acb3ee..cd97722 100644
@@ -358,7 +358,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, struct ib_mad *ma
 
 	if (agent) {
 		send_buf = ib_create_send_mad(agent, qpn, 0, 0, IB_MGMT_MAD_HDR,
-					      IB_MGMT_MAD_DATA, GFP_ATOMIC);
+					      IB_MGMT_MAD_DATA, GFP_ATOMIC,
+					      IB_MGMT_BASE_VERSION);
 		if (IS_ERR(send_buf))
 			return;
 		/*
drivers/infiniband/hw/mthca/mthca_mad.c +2 -1
index 5d597a1..83817da 100644
@@ -170,7 +170,8 @@ static void forward_trap(struct mthca_dev *dev,
 
 	if (agent) {
 		send_buf = ib_create_send_mad(agent, qpn, 0, 0, IB_MGMT_MAD_HDR,
-					      IB_MGMT_MAD_DATA, GFP_ATOMIC);
+					      IB_MGMT_MAD_DATA, GFP_ATOMIC,
+					      IB_MGMT_BASE_VERSION);
 		if (IS_ERR(send_buf))
 			return;
 		/*
drivers/infiniband/hw/qib/qib_iba7322.c +2 -1
index a7eb325..d41a417 100644
@@ -5488,7 +5488,8 @@ static void try_7322_ipg(struct qib_pportdata *ppd)
 		goto retry;
 
 	send_buf = ib_create_send_mad(agent, 0, 0, 0, IB_MGMT_MAD_HDR,
-				      IB_MGMT_MAD_DATA, GFP_ATOMIC);
+				      IB_MGMT_MAD_DATA, GFP_ATOMIC,
+				      IB_MGMT_BASE_VERSION);
 	if (IS_ERR(send_buf))
 		goto retry;
 
drivers/infiniband/hw/qib/qib_mad.c +2 -1
index fb022a3..cfc1be7 100644
@@ -83,7 +83,8 @@ static void qib_send_trap(struct qib_ibport *ibp, void *data, unsigned len)
 		return;
 
 	send_buf = ib_create_send_mad(agent, 0, 0, 0, IB_MGMT_MAD_HDR,
-				      IB_MGMT_MAD_DATA, GFP_ATOMIC);
+				      IB_MGMT_MAD_DATA, GFP_ATOMIC,
+				      IB_MGMT_BASE_VERSION);
 	if (IS_ERR(send_buf))
 		return;
 
drivers/infiniband/ulp/srpt/ib_srpt.c +2 -1
index dc82968..ca0f5b3 100644
@@ -477,7 +477,8 @@ static void srpt_mad_recv_handler(struct ib_mad_agent *mad_agent,
 	rsp = ib_create_send_mad(mad_agent, mad_wc->wc->src_qp,
 				 mad_wc->wc->pkey_index, 0,
 				 IB_MGMT_DEVICE_HDR, IB_MGMT_DEVICE_DATA,
-				 GFP_KERNEL);
+				 GFP_KERNEL,
+				 IB_MGMT_BASE_VERSION);
 	if (IS_ERR(rsp))
 		goto err_rsp;
 
include/rdma/ib_mad.h +3 -1
index 5823016..00a5e51 100644
@@ -619,6 +619,7 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
  *   automatically adjust the allocated buffer size to account for any
  *   additional padding that may be necessary.
  * @gfp_mask: GFP mask used for the memory allocation.
+ * @base_version: Base Version of this MAD
  *
  * This routine allocates a MAD for sending.  The returned MAD send buffer
  * will reference a data buffer usable for sending a MAD, along
@@ -634,7 +635,8 @@ struct ib_mad_send_buf *ib_create_send_mad(struct ib_mad_agent *mad_agent,
 					   u32 remote_qpn, u16 pkey_index,
 					   int rmpp_active,
 					   int hdr_len, int data_len,
-					   gfp_t gfp_mask);
+					   gfp_t gfp_mask,
+					   u8 base_version);
 
 /**
  * ib_is_mad_class_rmpp - returns whether given management class
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#27 lore raw

PATCH 14/20 IB/core: Add IB_DEVICE_OPA_MAD_SUPPORT device cap flag

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Add a device capability flag to flag OPA MAD support on devices.

---

Changes from RFC:
Changed flag to indicate OPA MAD base version support Added device_cap_flags2 as device_cap_flags bits are limited

 include/rdma/ib_verbs.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/rdma/ib_verbs.h +5 -0
index 5024f1f..83b39d5 100644
@@ -128,6 +128,10 @@ enum ib_device_cap_flags {
 	IB_DEVICE_ON_DEMAND_PAGING	= (1<<31),
 };
 
+enum ib_device_cap_flags2 {
+	IB_DEVICE_OPA_MAD_SUPPORT	= 1
+};
+
 enum ib_signature_prot_cap {
 	IB_PROT_T10DIF_TYPE_1 = 1,
 	IB_PROT_T10DIF_TYPE_2 = 1 << 1,
@@ -210,6 +214,7 @@ struct ib_device_attr {
 	int			sig_prot_cap;
 	int			sig_guard_cap;
 	struct ib_odp_caps	odp_caps;
+	u64			device_cap_flags2;
 	u32			mad_size;
 };
 
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1421082672-22588-15-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#29 lore raw

Re: [PATCH 14/20] IB/core: Add IB_DEVICE_OPA_MAD_SUPPORT device cap flag

On 1/12/2015 7:11 PM, [email protected] wrote:

--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
enum ib_signature_prot_cap {
IB_PROT_T10DIF_TYPE_1 = 1,
IB_PROT_T10DIF_TYPE_2 = 1 << 1,
@@ -210,6 +214,7 @@ struct ib_device_attr {
int sig_prot_cap;
int sig_guard_cap;
struct ib_odp_caps odp_caps;
+ u64 device_cap_flags2;

Just make the existing kernel size device_cap_flags field a u64, note it's not blankly copied to user space in uverbs as part of a chunk, so just go there and copy the lower 32 bits.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54B60A28.2030409-VPRAkNaXOzVWk0Htik3J/[email protected]

author
#31 lore raw

RE: [PATCH 14/20] IB/core: Add IB_DEVICE_OPA_MAD_SUPPORT device cap flag

Quoted 15 lines · On 1/12/2015 7:11 PM, [email protected] wrote:
include/rdma/ib_verbs.h +1 -0
  enum ib_signature_prot_cap {
  	IB_PROT_T10DIF_TYPE_1 = 1,
  	IB_PROT_T10DIF_TYPE_2 = 1 << 1,
@@ -210,6 +214,7 @@ struct ib_device_attr {
  	int			sig_prot_cap;
  	int			sig_guard_cap;
  	struct ib_odp_caps	odp_caps;
+	u64			device_cap_flags2;
 
 
Quoted 4 lines

Just make the existing kernel size device_cap_flags field a u64, note it's not blankly copied to user space in uverbs as part of a chunk, so just go there and copy the lower 32 bits.

It is an easy change but before changing this I'd like to hear what Roland or others think.

I prefer to define an additional field. Eventually we are likely to have flags which need to be communicated to user space. I think it will be cleaner at that time to report the entire new field rather than go through some sort of "upper 32 bit device capability" logic.

Thoughts?
Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#32 lore raw

Re: [PATCH 14/20] IB/core: Add IB_DEVICE_OPA_MAD_SUPPORT device cap flag

In reply to a message not in the archive
Quoted 1 line · On 1/12/2015 7:11 PM, [email protected] wrote:

Add a device capability flag to flag OPA MAD support on devices.

You should put few words here telling what is OPA/OPA MADs and why supporting them fits the IB core.

See for example the IB core patch [1] that added signature verbs API is states in a manner which is both generic across vendors and across different Mellanox HCAs. Also see [2] the IB core patch that added support for BMME API as another example.

[1] 1b01d33 IB/core: Introduce signature verbs API
[2] 00f7ec3 RDMA/core: Add memory management extensions support --
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54B60C08.9090205-VPRAkNaXOzVWk0Htik3J/[email protected]

author
#34 lore raw

RE: [PATCH 14/20] IB/core: Add IB_DEVICE_OPA_MAD_SUPPORT device cap flag

Quoted 11 lines · On 1/12/2015 7:11 PM, [email protected] wrote:
Quoted 1 line

Add a device capability flag to flag OPA MAD support on devices.

You should put few words here telling what is OPA/OPA MADs and why supporting them fits the IB core.

See for example the IB core patch [1] that added signature verbs API is states in a manner which is both generic across vendors and across different Mellanox HCAs. Also see [2] the IB core patch that added support for BMME API as another example.

I'm not quite sure what should be covered in this message which is different from the cover letter or the subsequent patches.

Would this be more acceptable?

<quote>

IB/core: Add IB_DEVICE_OPA_MAD_SUPPORT device cap flag

OPA MADs share a common header with IBTA MADs but with a different base version and an extended length. These "jumbo" MADs increase the performance of management traffic.

Sharing a common header with IBTA MADs allows us to share most of the MAD processing code when dealing with OPA MADs in addition to supporting some IBTA MADs on OPA devices.

Add a device capability flag to indicate OPA MAD support on the device.

</quote>

Ira

Quoted 4 lines

[1] 1b01d33 IB/core: Introduce signature verbs API [2] 00f7ec3 RDMA/core:
Add memory management extensions support

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#35 lore raw

PATCH 15/20 IB/mad: Create jumbo_mad data structures

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Define jumbo_mad and jumbo_rmpp_mad

Create an RMPP Base header to share between ib_rmpp_mad and jumbo_rmpp_mad

Update code to use the new structures.

---

Changes from RFC:
add JUMBO_MGMT_MAD_SIZE
remove jumbo_mad_private structure

 drivers/infiniband/core/mad.c      |   18 +++---
 drivers/infiniband/core/mad_priv.h |    2 +
 drivers/infiniband/core/mad_rmpp.c |  120 ++++++++++++++++++------------------
 drivers/infiniband/core/user_mad.c |   16 +++---
 include/rdma/ib_mad.h              |   26 +++++++-
 5 files changed, 103 insertions(+), 79 deletions(-)
drivers/infiniband/core/mad.c +9 -9
index 6a6efd6..dc78040 100644
@@ -883,7 +883,7 @@ static int alloc_send_rmpp_list(struct ib_mad_send_wr_private *send_wr,
 				gfp_t gfp_mask)
 {
 	struct ib_mad_send_buf *send_buf = &send_wr->send_buf;
-	struct ib_rmpp_mad *rmpp_mad = send_buf->mad;
+	struct ib_rmpp_base *rmpp_base = send_buf->mad;
 	struct ib_rmpp_segment *seg = NULL;
 	int left, seg_size, pad;
 
@@ -909,10 +909,10 @@ static int alloc_send_rmpp_list(struct ib_mad_send_wr_private *send_wr,
 	if (pad)
 		memset(seg->data + seg_size - pad, 0, pad);
 
-	rmpp_mad->rmpp_hdr.rmpp_version = send_wr->mad_agent_priv->
+	rmpp_base->rmpp_hdr.rmpp_version = send_wr->mad_agent_priv->
 					  agent.rmpp_version;
-	rmpp_mad->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_DATA;
-	ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
+	rmpp_base->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_DATA;
+	ib_set_rmpp_flags(&rmpp_base->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
 
 	send_wr->cur_seg = container_of(send_wr->rmpp_list.next,
 					struct ib_rmpp_segment, list);
@@ -1748,14 +1748,14 @@ out:
 static int is_rmpp_data_mad(struct ib_mad_agent_private *mad_agent_priv,
 		       struct ib_mad_hdr *mad_hdr)
 {
-	struct ib_rmpp_mad *rmpp_mad;
+	struct ib_rmpp_base *rmpp_base;
 
-	rmpp_mad = (struct ib_rmpp_mad *)mad_hdr;
+	rmpp_base = (struct ib_rmpp_base *)mad_hdr;
 	return !mad_agent_priv->agent.rmpp_version ||
 		!ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent) ||
-		!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
+		!(ib_get_rmpp_flags(&rmpp_base->rmpp_hdr) &
 				    IB_MGMT_RMPP_FLAG_ACTIVE) ||
-		(rmpp_mad->rmpp_hdr.rmpp_type == IB_MGMT_RMPP_TYPE_DATA);
+		(rmpp_base->rmpp_hdr.rmpp_type == IB_MGMT_RMPP_TYPE_DATA);
 }
 
 static inline int rcv_has_same_class(struct ib_mad_send_wr_private *wr,
@@ -1897,7 +1897,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
 			spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
 			if (!ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)
 			   && ib_is_mad_class_rmpp(mad_recv_wc->recv_buf.mad->mad_hdr.mgmt_class)
-			   && (ib_get_rmpp_flags(&((struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad)->rmpp_hdr)
+			   && (ib_get_rmpp_flags(&((struct ib_rmpp_base *)mad_recv_wc->recv_buf.mad)->rmpp_hdr)
 					& IB_MGMT_RMPP_FLAG_ACTIVE)) {
 				/* user rmpp is in effect
 				 * and this is an active RMPP MAD
drivers/infiniband/core/mad_priv.h +2 -0
index d1a0b0e..d71ddcc 100644
@@ -80,6 +80,8 @@ struct ib_mad_private {
 		struct ib_mad mad;
 		struct ib_rmpp_mad rmpp_mad;
 		struct ib_smp smp;
+		struct jumbo_mad jumbo_mad;
+		struct jumbo_rmpp_mad jumbo_rmpp_mad;
 	} mad;
 } __attribute__ ((packed));
 
drivers/infiniband/core/mad_rmpp.c +60 -60

276 lines not on this page · raw message

drivers/infiniband/core/user_mad.c +8 -8
index 9628494..ac33d34 100644
@@ -448,7 +448,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 	struct ib_mad_agent *agent;
 	struct ib_ah_attr ah_attr;
 	struct ib_ah *ah;
-	struct ib_rmpp_mad *rmpp_mad;
+	struct ib_rmpp_base *rmpp_base;
 	__be64 *tid;
 	int ret, data_len, hdr_len, copy_offset, rmpp_active;
 
@@ -504,13 +504,13 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 		goto err_up;
 	}
 
-	rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
-	hdr_len = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class);
+	rmpp_base = (struct ib_rmpp_base *) packet->mad.data;
+	hdr_len = ib_get_mad_data_offset(rmpp_base->mad_hdr.mgmt_class);
 
-	if (ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
+	if (ib_is_mad_class_rmpp(rmpp_base->mad_hdr.mgmt_class)
 	    && ib_mad_kernel_rmpp_agent(agent)) {
 		copy_offset = IB_MGMT_RMPP_HDR;
-		rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
+		rmpp_active = ib_get_rmpp_flags(&rmpp_base->rmpp_hdr) &
 						IB_MGMT_RMPP_FLAG_ACTIVE;
 	} else {
 		copy_offset = IB_MGMT_MAD_HDR;
@@ -558,12 +558,12 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 		tid = &((struct ib_mad_hdr *) packet->msg->mad)->tid;
 		*tid = cpu_to_be64(((u64) agent->hi_tid) << 32 |
 				   (be64_to_cpup(tid) & 0xffffffff));
-		rmpp_mad->mad_hdr.tid = *tid;
+		rmpp_base->mad_hdr.tid = *tid;
 	}
 
 	if (!ib_mad_kernel_rmpp_agent(agent)
-	   && ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
-	   && (ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
+	   && ib_is_mad_class_rmpp(rmpp_base->mad_hdr.mgmt_class)
+	   && (ib_get_rmpp_flags(&rmpp_base->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
 		spin_lock_irq(&file->send_lock);
 		list_add_tail(&packet->list, &file->send_list);
 		spin_unlock_irq(&file->send_lock);
include/rdma/ib_mad.h +24 -2
index 00a5e51..80e7cf4 100644
@@ -136,6 +136,11 @@ enum {
 	IB_MGMT_DEVICE_HDR = 64,
 	IB_MGMT_DEVICE_DATA = 192,
 	IB_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + IB_MGMT_MAD_DATA,
+	JUMBO_MGMT_MAD_HDR = IB_MGMT_MAD_HDR,
+	JUMBO_MGMT_MAD_DATA = 2024,
+	JUMBO_MGMT_RMPP_HDR = IB_MGMT_RMPP_HDR,
+	JUMBO_MGMT_RMPP_DATA = 2012,
+	JUMBO_MGMT_MAD_SIZE = JUMBO_MGMT_MAD_HDR + JUMBO_MGMT_MAD_DATA,
 };
 
 struct ib_mad_hdr {
@@ -182,12 +187,26 @@ struct ib_mad {
 	u8			data[IB_MGMT_MAD_DATA];
 };
 
-struct ib_rmpp_mad {
+struct jumbo_mad {
+	struct ib_mad_hdr	mad_hdr;
+	u8			data[JUMBO_MGMT_MAD_DATA];
+};
+
+struct ib_rmpp_base {
 	struct ib_mad_hdr	mad_hdr;
 	struct ib_rmpp_hdr	rmpp_hdr;
+} __packed;
+
+struct ib_rmpp_mad {
+	struct ib_rmpp_base	base;
 	u8			data[IB_MGMT_RMPP_DATA];
 };
 
+struct jumbo_rmpp_mad {
+	struct ib_rmpp_base	base;
+	u8			data[JUMBO_MGMT_RMPP_DATA];
+};
+
 struct ib_sa_mad {
 	struct ib_mad_hdr	mad_hdr;
 	struct ib_rmpp_hdr	rmpp_hdr;
@@ -402,7 +421,10 @@ struct ib_mad_send_wc {
 struct ib_mad_recv_buf {
 	struct list_head	list;
 	struct ib_grh		*grh;
-	struct ib_mad		*mad;
+	union {
+		struct ib_mad		*mad;
+		struct jumbo_mad	*jumbo_mad;
+	};
 };
 
 /**
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1421082672-22588-16-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#37 lore raw

Re: [PATCH 15/20] IB/mad: Create jumbo_mad data structures

Quoted 1 line · On 1/12/2015 7:11 PM, [email protected] wrote:

Define jumbo_mad and jumbo_rmpp_mad

For the sake of review and maintenance, please add few more words here on what are these creatures...

Quoted 2 lines

Create an RMPP Base header to share between ib_rmpp_mad and jumbo_rmpp_mad

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54B60A75.4010103-VPRAkNaXOzVWk0Htik3J/[email protected]

author
#39 lore raw

RE: [PATCH 15/20] IB/mad: Create jumbo_mad data structures

Quoted 6 lines · On 1/12/2015 7:11 PM, [email protected] wrote:
Quoted 1 line

Define jumbo_mad and jumbo_rmpp_mad

For the sake of review and maintenance, please add few more words here on what are these creatures...

Proposed new text:

Define jumbo_mad and jumbo_rmpp_mad.

Jumbo MAD structures are 2K versions of ib_mad and ib_rmpp_mad structures. Currently only OPA base version MADs are of this type.

Sound reasonable?

Ira

Quoted 3 lines
Quoted 3 lines

Create an RMPP Base header to share between ib_rmpp_mad and jumbo_rmpp_mad

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#40 lore raw

PATCH 16/20 IB/mad: Add Intel Omni-Path Architecture defines

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

OPA_MIN_CLASS_VERSION -- OPA Class versions are > 0x80 OPA_SMP_CLASS_VERSION -- Defined at 0x80 OPA_MGMT_BASE_VERSION -- Defined at 0x80

Increase max management version to accommodate OPA

---
 drivers/infiniband/core/mad_priv.h |    4 +++-
 include/rdma/ib_mad.h              |    5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/infiniband/core/mad_priv.h +3 -1
index d71ddcc..a7041b0 100644
@@ -56,11 +56,13 @@
 
 /* Registration table sizes */
 #define MAX_MGMT_CLASS		80
-#define MAX_MGMT_VERSION	8
+#define MAX_MGMT_VERSION	0x83
 #define MAX_MGMT_OUI		8
 #define MAX_MGMT_VENDOR_RANGE2	(IB_MGMT_CLASS_VENDOR_RANGE2_END - \
 				IB_MGMT_CLASS_VENDOR_RANGE2_START + 1)
 
+#define OPA_MIN_CLASS_VERSION	0x80
+
 struct ib_mad_list_head {
 	struct list_head list;
 	struct ib_mad_queue *mad_queue;
include/rdma/ib_mad.h +4 -1
index 80e7cf4..8938f1e 100644
@@ -42,8 +42,11 @@
 #include <rdma/ib_verbs.h>
 #include <uapi/rdma/ib_user_mad.h>
 
-/* Management base version */
+/* Management base versions */
 #define IB_MGMT_BASE_VERSION			1
+#define OPA_MGMT_BASE_VERSION			0x80
+
+#define OPA_SMP_CLASS_VERSION			0x80
 
 /* Management classes */
 #define IB_MGMT_CLASS_SUBN_LID_ROUTED		0x01
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1421082672-22588-17-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#42 lore raw

Re: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 7 lines · On 1/12/2015 12:11 PM, [email protected] wrote:

From: Ira Weiny <[email protected]>

OPA_MIN_CLASS_VERSION -- OPA Class versions are > 0x80 OPA_SMP_CLASS_VERSION -- Defined at 0x80 OPA_MGMT_BASE_VERSION -- Defined at 0x80

Increase max management version to accommodate OPA

Allocation of MAD base and class version numbers is owned by the IBTA. It doesn’t seem appropriate to arbitrarily claim code points without proper approval.

-- Hal

Quoted 33 lines
---
 drivers/infiniband/core/mad_priv.h |    4 +++-
 include/rdma/ib_mad.h              |    5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/infiniband/core/mad_priv.h +3 -1
index d71ddcc..a7041b0 100644
@@ -56,11 +56,13 @@
 
 /* Registration table sizes */
 #define MAX_MGMT_CLASS		80
-#define MAX_MGMT_VERSION	8
+#define MAX_MGMT_VERSION	0x83
 #define MAX_MGMT_OUI		8
 #define MAX_MGMT_VENDOR_RANGE2	(IB_MGMT_CLASS_VENDOR_RANGE2_END - \
 				IB_MGMT_CLASS_VENDOR_RANGE2_START + 1)
 
+#define OPA_MIN_CLASS_VERSION	0x80
+
 struct ib_mad_list_head {
 	struct list_head list;
 	struct ib_mad_queue *mad_queue;
include/rdma/ib_mad.h +0 -0
index 80e7cf4..8938f1e 100644
@@ -42,8 +42,11 @@
 #include <rdma/ib_verbs.h>
 #include <uapi/rdma/ib_user_mad.h>

include/rdma/ib_mad.h line 52

Quoted 10 lines
include/rdma/ib_mad.h +4 -1
 
-/* Management base version */
+/* Management base versions */
 #define IB_MGMT_BASE_VERSION			1
+#define OPA_MGMT_BASE_VERSION			0x80
+
+#define OPA_SMP_CLASS_VERSION			0x80
 
 /* Management classes */
 #define IB_MGMT_CLASS_SUBN_LID_ROUTED		0x01

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54B7CA4E.5050809-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

author
#44 lore raw

RE: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 8 lines · On 1/12/2015 12:11 PM, [email protected] wrote:
Quoted 6 lines

From: Ira Weiny <[email protected]>

OPA_MIN_CLASS_VERSION -- OPA Class versions are > 0x80 OPA_SMP_CLASS_VERSION -- Defined at 0x80 OPA_MGMT_BASE_VERSION -- Defined at 0x80

Quoted 5 lines
Quoted 1 line

Increase max management version to accommodate OPA

Allocation of MAD base and class version numbers is owned by the IBTA. It doesn't seem appropriate to arbitrarily claim code points without proper approval.

OPA is its own architecture space. While this space uses some of the same values as IB we are not claiming any IBTA values. This is similar to how IB GIDs and IPv6 addresses look the same but are in separate addressing domains.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 2807E5FD2F6FDA4886F6618EAC48510E0CC02AB4-8k97q/[email protected]

#46 lore raw

Re: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 8 lines · Ira
Quoted 8 lines · On 1/12/2015 12:11 PM, [email protected] wrote:
Quoted 6 lines

From: Ira Weiny <[email protected]>

OPA_MIN_CLASS_VERSION -- OPA Class versions are > 0x80 OPA_SMP_CLASS_VERSION -- Defined at 0x80 OPA_MGMT_BASE_VERSION -- Defined at 0x80

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Increase max management version to accommodate OPA

Allocation of MAD base and class version numbers is owned by the IBTA. It doesn't seem appropriate to arbitrarily claim code points without proper approval.

OPA is its own architecture space. While this space uses some of the same values as IB we are not claiming any IBTA values.

You *are* claiming IBTA values. When the IBTA chooses to use those values, then there will be a conflict.

-- Hal

Quoted 5 lines

This is similar to how IB GIDs and IPv6 addresses look the same but are in separate addressing domains.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54B9268B.7080600-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

author
#48 lore raw

RE: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 16 lines · Ira
Quoted 6 lines
Quoted 6 lines · On 1/12/2015 12:11 PM, [email protected] wrote:
Quoted 4 lines

From: Ira Weiny <[email protected]>

OPA_MIN_CLASS_VERSION -- OPA Class versions are > 0x80 OPA_SMP_CLASS_VERSION -- Defined at 0x80

OPA_MGMT_BASE_VERSION --

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Defined at 0x80

Increase max management version to accommodate OPA

Allocation of MAD base and class version numbers is owned by the IBTA. It doesn't seem appropriate to arbitrarily claim code points without proper approval.

Quoted 5 lines
Quoted 2 lines

OPA is its own architecture space. While this space uses some of the same values as IB we are not claiming any IBTA values.

You *are* claiming IBTA values. When the IBTA chooses to use those values, then there will be a conflict.

There is no conflict.

It is true that when the IBTA assigns meaning to those values the code may have to be changed to interpret this new meaning. That has to happen regardless of these patches or their meaning on OPA devices.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 2807E5FD2F6FDA4886F6618EAC48510E0CC03441-8k97q/[email protected]

#50 lore raw

Re: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 19 lines · Ira
Quoted 19 lines · Ira
Quoted 6 lines
Quoted 6 lines · On 1/12/2015 12:11 PM, [email protected] wrote:
Quoted 4 lines

From: Ira Weiny <[email protected]>

OPA_MIN_CLASS_VERSION -- OPA Class versions are > 0x80 OPA_SMP_CLASS_VERSION -- Defined at 0x80

OPA_MGMT_BASE_VERSION --

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

Defined at 0x80

Increase max management version to accommodate OPA

Allocation of MAD base and class version numbers is owned by the IBTA. It doesn't seem appropriate to arbitrarily claim code points without proper approval.

OPA is its own architecture space. While this space uses some of the same values as IB we are not claiming any IBTA values.

Quoted 7 lines
Quoted 2 lines

You *are* claiming IBTA values. When the IBTA chooses to use those values, then there will be a conflict.

There is no conflict.

It is true that when the IBTA assigns meaning to those values the code may have to be changed to interpret this new meaning. That has to happen regardless of these patches or their meaning on OPA devices.

Currently, these patches are claiming values that are controlled by an established standards organization. It is the equivalent of just grabbing a currently unused Ethertype value for a new protocol and then claiming that whenever the IEEE allocates it for something else you will make changes to resolve the conflict. There are then a range of kernel versions which would do the wrong thing with the new IEEE value rather than indicate that it is not (currently) supported. It's not an appropriate practice in the design of networking protocols.

-- Hal

Quoted 3 lines

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54BD3DCA.2050208-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

#52 lore raw

RE: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 5 lines

Currently, these patches are claiming values that are controlled by an established standards organization. It is the equivalent of just grabbing a currently unused Ethertype value for a new protocol and then claiming that whenever the IEEE allocates it for something else you will make changes to resolve the conflict.

It would be equivalent if OPA was Infiniband, but it is not. It is a separate architecture, with an entirely separate name space. Conceptually, it is similar to the IB GRH and the IPv6 header. They have a similar structure, but they are not the same. The IBTA can define a new GRH field values, such as NxtHdr, without consulting or getting approval from the IETF.

Ira could introduce patches to define OPA management packets, but the general structure of those packet headers would be exactly the same as IB management packets. There's no need to introduce duplicate definitions into the code base. The existing structures can be reused. However, OPA makes use of different values for the fields.

- Sean

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1828884A29C6694DAF28B7E6B8A8237399E4F4BA-P5GAC/[email protected]

author
#54 lore raw

RE: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 13 lines
Quoted 6 lines

Currently, these patches are claiming values that are controlled by an established standards organization. It is the equivalent of just grabbing a currently unused Ethertype value for a new protocol and then claiming that whenever the IEEE allocates it for something else you will make changes to resolve the conflict.

It would be equivalent if OPA was Infiniband, but it is not. It is a separate architecture, with an entirely separate name space. Conceptually, it is similar to the IB GRH and the IPv6 header. They have a similar structure, but they are not the same. The IBTA can define a new GRH field values, such as NxtHdr, without consulting or getting approval from the IETF.

Quoted 6 lines

Ira could introduce patches to define OPA management packets, but the general structure of those packet headers would be exactly the same as IB management packets. There's no need to introduce duplicate definitions into the code base. The existing structures can be reused. However, OPA makes use of different values for the fields.

Perhaps you can give us an example of where the current code would work without modifications if the IBTA were to define any new base or smp class version?

Would removing this patch satisfy your concerns?

commit a70a5af286b2985a0a95e9733d1e3166845a8be8

Author: Ira Weiny <[email protected]>
Date:   Tue Sep 23 20:04:49 2014 -0400

IB/mad: Add registration check for Intel Omni-Path Architecture MADs

If the registration specifies an OPA MAD class version and the device does not support OPA MADs, fail the MAD registration.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 2807E5FD2F6FDA4886F6618EAC48510E0CC05436-8k97q/[email protected]

#56 lore raw

Re: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 3 lines · Ira

Perhaps you can give us an example of where the current code would work without modifications if the IBTA were to define any new base or smp class version?

I think the point here is that every check for OPA_MIN_CLASS_VERSION must also be combined with a check if the device in question is OPA or not.

I don't see a problem with sharing the kernel structs or MAD processing, as long as all OPA specific behavior is conditionalized on the device in question being OPA - it should never be conditionalized on the class version of the MAD.

Quoted 5 lines

commit a70a5af286b2985a0a95e9733d1e3166845a8be8

Author: Ira Weiny <[email protected]>
Date:   Tue Sep 23 20:04:49 2014 -0400

IB/mad: Add registration check for Intel Omni-Path Architecture MADs

For instance:

+ if (mad_reg_req->mgmt_class_version >= OPA_MIN_CLASS_VERSION
+ && !port_priv->qp_info[qpn].supports_jumbo_mads) {

Is wrong because it means that no IB software can register for those MADs anymore, which is cross polluting the two architectures in the kernel.

Presumably since supports_jumbo_mads is always true for OPA the above test is not required at all and this patch should be dropped.

But I expect if we keep looking at uses of OPA_MIN_CLASS_VERSION we will see other cases where they need to be conditionalized?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20150119215311.GH13469-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

author
#58 lore raw

RE: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 9 lines · Ira
Quoted 4 lines

Perhaps you can give us an example of where the current code would work without modifications if the IBTA were to define any new base or smp class version?

I think the point here is that every check for OPA_MIN_CLASS_VERSION must also be combined with a check if the device in question is OPA or not.

This contradicts what you say below....

Quoted 18 lines

I don't see a problem with sharing the kernel structs or MAD processing, as long as all OPA specific behavior is conditionalized on the device in question being OPA - it should never be conditionalized on the class version of the MAD.

Quoted 6 lines

commit a70a5af286b2985a0a95e9733d1e3166845a8be8

Author: Ira Weiny <[email protected]>
Date:   Tue Sep 23 20:04:49 2014 -0400

IB/mad: Add registration check for Intel Omni-Path Architecture
MADs

For instance:

(quoted diff) +1 -0
+		if (mad_reg_req->mgmt_class_version >=

OPA_MIN_CLASS_VERSION

(quoted diff) +1 -0
+		    && !port_priv->qp_info[qpn].supports_jumbo_mads) {
Quoted 8 lines

Is wrong because it means that no IB software can register for those MADs anymore, which is cross polluting the two architectures in the kernel.

Presumably since supports_jumbo_mads is always true for OPA the above test is not required at all and this patch should be dropped.

But I expect if we keep looking at uses of OPA_MIN_CLASS_VERSION we will see other cases where they need to be conditionalized?

That is the only use of OPA_MIN_CLASS_VERSION. I agree with your second assessment and I'll remove the patch from the next series.

Hal was this your assessment as well?

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 2807E5FD2F6FDA4886F6618EAC48510E0CC05C0A-8k97q/[email protected]

#60 lore raw

Re: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 11 lines · Ira
Quoted 9 lines · Ira
Quoted 4 lines

Perhaps you can give us an example of where the current code would work without modifications if the IBTA were to define any new base or smp class version?

I think the point here is that every check for OPA_MIN_CLASS_VERSION must also be combined with a check if the device in question is OPA or not.

This contradicts what you say below....

How so?

if (mad_reg_req->mgmt_class_version >= OPA_MIN_CLASS_VERSION

    && !port_priv->qp_info[qpn].supports_jumbo_mads) {

Should be:

if (port_is_opa && mad_reg_req->mgmt_class_version >= OPA_MIN_CLASS_VERSION

    && !port_priv->qp_info[qpn].supports_jumbo_mads) {

And since port_is_opa = true implies port_priv->qp_info[qpn].supports_jumbo_mads = true the above if can never evaluate to true and can just be removed.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20150120181557.GC31320-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

author
#62 lore raw

RE: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

Quoted 12 lines · Ira
Quoted 10 lines
Quoted 9 lines · Ira
Quoted 4 lines

Perhaps you can give us an example of where the current code would work without modifications if the IBTA were to define any new base or smp class version?

I think the point here is that every check for OPA_MIN_CLASS_VERSION must also be combined with a check if the device in question is OPA or not.

Quoted 7 lines
Quoted 1 line

This contradicts what you say below....

How so?

if (mad_reg_req->mgmt_class_version >= OPA_MIN_CLASS_VERSION

    && !port_priv->qp_info[qpn].supports_jumbo_mads) {

Sorry, I got a bit confused because this is not the latest version of the patch.

Quoted 9 lines

Should be:

if (port_is_opa && mad_reg_req->mgmt_class_version >= OPA_MIN_CLASS_VERSION

    && !port_priv->qp_info[qpn].supports_jumbo_mads) {

And since port_is_opa = true implies port_priv->qp_info[qpn].supports_jumbo_mads = true the above if can never evaluate to true and can just be removed.

Right there is no need to check for supports_jumbo_mads. The latest version was:

+ if (mad_reg_req->mgmt_class_version >= OPA_MIN_CLASS_VERSION &&
+ !(port_priv->device->attributes.device_cap_flags2 & IB_DEVICE_OPA_MAD_SUPPORT)) {

The "bug" in the patch is that any class version should be allowed on IB devices. This check prevented class versions >= 0x80 for IB devices.

NOTE however that the current code already limits users to a class version < 8. (due to the implementation.)

-#define MAX_MGMT_VERSION 8
+#define MAX_MGMT_VERSION 0x83
...

                if (mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION) { 
                        dev_notice(&device->dev, 
                                   "ib_register_mad_agent: invalid Class Version %u\n",
                                   mad_reg_req->mgmt_class_version);
                        goto error1;
                }

Therefore I did not see this as limiting the IB implementation we already have.

I will remove the patch as I agree with Jason and Hal it is technically more correct.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#63 lore raw

Re: [PATCH 16/20] IB/mad: Add Intel Omni-Path Architecture defines

In reply to a message not in the archive
Quoted 7 lines · Sean
Quoted 5 lines

Currently, these patches are claiming values that are controlled by an established standards organization. It is the equivalent of just grabbing a currently unused Ethertype value for a new protocol and then claiming that whenever the IEEE allocates it for something else you will make changes to resolve the conflict.

It would be equivalent if OPA was Infiniband, but it is not. It is a separate architecture, with an entirely separate name space.

But the OPA MAD patches currently share the IBA name space.

-- Hal

Quoted 7 lines

Conceptually, it is similar to the IB GRH and the IPv6 header. They have a similar structure, but they are not the same. The IBTA can define a new GRH field values, such as NxtHdr, without consulting or getting approval from the IETF.

Ira could introduce patches to define OPA management packets, but the general structure of those packet headers would be exactly the same as IB management packets. There's no need to introduce duplicate definitions into the code base. The existing structures can be reused. However, OPA makes use of different values for the fields.

- Sean

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#64 lore raw

PATCH 17/20 IB/mad: Add registration check for Intel Omni-Path Architecture MADs

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

If the registration specifies an OPA MAD class version and the device does not support OPA MADs, fail the MAD registration.

---

Changes from RFC:
remove use of supports_jumbo_mads
convert to use IB_DEVICE_OPA_MAD_SUPPORT in device_cap_flags2

 drivers/infiniband/core/mad.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)
drivers/infiniband/core/mad.c +16 -8
index dc78040..2686393 100644
@@ -227,6 +227,14 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
 		goto error1;
 	}
 
+	/* Validate device and port */
+	port_priv = ib_get_mad_port(device, port_num);
+	if (!port_priv) {
+		dev_notice(&device->dev, "ib_register_mad_agent: Invalid port\n");
+		ret = ERR_PTR(-ENODEV);
+		goto error1;
+	}
+
 	/* Validate MAD registration request if supplied */
 	if (mad_reg_req) {
 		if (mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION) {
@@ -235,6 +243,14 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
 				   mad_reg_req->mgmt_class_version);
 			goto error1;
 		}
+		if (mad_reg_req->mgmt_class_version >= OPA_MIN_CLASS_VERSION &&
+		    !(port_priv->device->attributes.device_cap_flags2 & IB_DEVICE_OPA_MAD_SUPPORT)) {
+			dev_notice(&device->dev,
+				   "ib_register_mad_agent: OPA class Version 0x%x not supported on this device: cap flags 2 0x%llx\n",
+				   mad_reg_req->mgmt_class_version,
+				   port_priv->device->attributes.device_cap_flags2);
+			goto error1;
+		}
 		if (!recv_handler) {
 			dev_notice(&device->dev,
 				   "ib_register_mad_agent: no recv_handler\n");
@@ -312,14 +328,6 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
 			goto error1;
 	}
 
-	/* Validate device and port */
-	port_priv = ib_get_mad_port(device, port_num);
-	if (!port_priv) {
-		dev_notice(&device->dev, "ib_register_mad_agent: Invalid port\n");
-		ret = ERR_PTR(-ENODEV);
-		goto error1;
-	}
-
 	/* Verify the QP requested is supported.  For example, Ethernet devices
 	 * will not have QP0 */
 	if (!port_priv->qp_info[qpn].qp) {
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#65 lore raw

PATCH 18/20 IB/mad: Implement support for Intel Omni-Path Architecture base version MADs in ib_create_send_mad

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

If the MAD is an OPA base version; verify the device supports Jumbo MAD sizes Set MAD size and sg lengths as appropriate
Split RMPP MADs as appropriate

---

Changes from RFC:
remove use of supports_jumbo_mads

 drivers/infiniband/core/mad.c |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)
drivers/infiniband/core/mad.c +28 -10
index 2686393..0179d37 100644
@@ -865,11 +865,11 @@ out:
 	return ret;
 }
 
-static int get_pad_size(int hdr_len, int data_len)
+static int get_pad_size(int hdr_len, int data_len, size_t mad_size)
 {
 	int seg_size, pad;
 
-	seg_size = sizeof(struct ib_mad) - hdr_len;
+	seg_size = mad_size - hdr_len;
 	if (data_len && seg_size) {
 		pad = seg_size - data_len % seg_size;
 		return pad == seg_size ? 0 : pad;
@@ -888,14 +888,14 @@ static void free_send_rmpp_list(struct ib_mad_send_wr_private *mad_send_wr)
 }
 
 static int alloc_send_rmpp_list(struct ib_mad_send_wr_private *send_wr,
-				gfp_t gfp_mask)
+				size_t mad_size, gfp_t gfp_mask)
 {
 	struct ib_mad_send_buf *send_buf = &send_wr->send_buf;
 	struct ib_rmpp_base *rmpp_base = send_buf->mad;
 	struct ib_rmpp_segment *seg = NULL;
 	int left, seg_size, pad;
 
-	send_buf->seg_size = sizeof (struct ib_mad) - send_buf->hdr_len;
+	send_buf->seg_size = mad_size - send_buf->hdr_len;
 	seg_size = send_buf->seg_size;
 	pad = send_wr->pad;
 
@@ -945,20 +945,29 @@ struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
 	struct ib_mad_send_wr_private *mad_send_wr;
 	int pad, message_size, ret, size;
 	void *buf;
+	size_t mad_size;
 
 	mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private,
 				      agent);
-	pad = get_pad_size(hdr_len, data_len);
+
+	if (base_version == OPA_MGMT_BASE_VERSION) {
+		if (mad_agent_priv->agent.device->attributes.mad_size < JUMBO_MGMT_MAD_SIZE)
+			return ERR_PTR(-EINVAL);
+		mad_size = sizeof(struct jumbo_mad);
+	} else
+		mad_size = sizeof(struct ib_mad);
+
+	pad = get_pad_size(hdr_len, data_len, mad_size);
 	message_size = hdr_len + data_len + pad;
 
 	if (ib_mad_kernel_rmpp_agent(mad_agent)) {
-		if (!rmpp_active && message_size > sizeof(struct ib_mad))
+		if (!rmpp_active && message_size > mad_size)
 			return ERR_PTR(-EINVAL);
 	} else
-		if (rmpp_active || message_size > sizeof(struct ib_mad))
+		if (rmpp_active || message_size > mad_size)
 			return ERR_PTR(-EINVAL);
 
-	size = rmpp_active ? hdr_len : sizeof(struct ib_mad);
+	size = rmpp_active ? hdr_len : mad_size;
 	buf = kzalloc(sizeof *mad_send_wr + size, gfp_mask);
 	if (!buf)
 		return ERR_PTR(-ENOMEM);
@@ -973,7 +982,16 @@ struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
 	mad_send_wr->mad_agent_priv = mad_agent_priv;
 	mad_send_wr->sg_list[0].length = hdr_len;
 	mad_send_wr->sg_list[0].lkey = mad_agent->mr->lkey;
-	mad_send_wr->sg_list[1].length = sizeof(struct ib_mad) - hdr_len;
+
+	/* OPA MADs don't have to be the full 2048 bytes */
+	if (base_version == OPA_MGMT_BASE_VERSION &&
+	    (mad_agent_priv->agent.device->attributes.device_cap_flags2 &
+		IB_DEVICE_OPA_MAD_SUPPORT) &&
+	    data_len < mad_size - hdr_len)
+		mad_send_wr->sg_list[1].length = data_len;
+	else
+		mad_send_wr->sg_list[1].length = mad_size - hdr_len;
+
 	mad_send_wr->sg_list[1].lkey = mad_agent->mr->lkey;
 
 	mad_send_wr->send_wr.wr_id = (unsigned long) mad_send_wr;
@@ -986,7 +1004,7 @@ struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
 	mad_send_wr->send_wr.wr.ud.pkey_index = pkey_index;
 
 	if (rmpp_active) {
-		ret = alloc_send_rmpp_list(mad_send_wr, gfp_mask);
+		ret = alloc_send_rmpp_list(mad_send_wr, mad_size, gfp_mask);
 		if (ret) {
 			kfree(buf);
 			return ERR_PTR(ret);
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#66 lore raw

PATCH 19/20 IB/mad: Implement Intel Omni-Path Architecture SMP processing

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Define the new OPA SMP format, create support functions for this format using the previously defined helper functions as appropriate.

---
 drivers/infiniband/core/mad_priv.h |    2 +
 drivers/infiniband/core/opa_smi.h  |   78 ++++++++++++++++++++++++++
 drivers/infiniband/core/smi.c      |   54 ++++++++++++++++++
 drivers/infiniband/core/smi.h      |    6 ++
 include/rdma/opa_smi.h             |  106 ++++++++++++++++++++++++++++++++++++
 5 files changed, 246 insertions(+), 0 deletions(-)
 create mode 100644 drivers/infiniband/core/opa_smi.h
 create mode 100644 include/rdma/opa_smi.h
drivers/infiniband/core/mad_priv.h +2 -0
index a7041b0..bef25d2 100644
@@ -41,6 +41,7 @@
 #include <linux/workqueue.h>
 #include <rdma/ib_mad.h>
 #include <rdma/ib_smi.h>
+#include <rdma/opa_smi.h>
 
 #define IB_MAD_QPS_CORE		2 /* Always QP0 and QP1 as a minimum */
 
@@ -84,6 +85,7 @@ struct ib_mad_private {
 		struct ib_smp smp;
 		struct jumbo_mad jumbo_mad;
 		struct jumbo_rmpp_mad jumbo_rmpp_mad;
+		struct opa_smp opa_smp;
 	} mad;
 } __attribute__ ((packed));
 
drivers/infiniband/core/opa_smi.h new file +78 -0

78 lines not on this page · raw message

drivers/infiniband/core/smi.c +54 -0

87 lines not on this page · raw message

drivers/infiniband/core/smi.h +6 -0
index aff96ba..e95c537 100644
@@ -62,6 +62,9 @@ extern enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
  * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM
  * via process_mad
  */
+/* NOTE: This is called on opa_smp's don't check fields which are not common
+ * between ib_smp and opa_smp
+ */
 static inline enum smi_action smi_check_local_smp(struct ib_smp *smp,
 						  struct ib_device *device)
 {
@@ -77,6 +80,9 @@ static inline enum smi_action smi_check_local_smp(struct ib_smp *smp,
  * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM
  * via process_mad
  */
+/* NOTE: This is called on opa_smp's don't check fields which are not common
+ * between ib_smp and opa_smp
+ */
 static inline enum smi_action smi_check_local_returning_smp(struct ib_smp *smp,
 						   struct ib_device *device)
 {
include/rdma/opa_smi.h new file +106 -0

106 lines not on this page · raw message

Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#67 lore raw

PATCH 20/20 IB/mad: Implement Intel Omni-Path Architecture MAD processing

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

OPA SMP packets must carry a valid pkey
process wc.pkey_index returned by agents for response.

Handle variable length OPA MADs based on the Base Version Support is provided by:

* Adjusting the 'fake' WC for locally routed SMP's to represent the proper incoming byte_len
* out_mad_size is used from the local HCA agents
1) when sending agent responses on the wire
2) when passing responses through the local_completions function

NOTE: wc.byte_len includes the GRH length and therefore is different from the
in_mad_size specified to the local HCA agents. out_mad_size should _not_ include the GRH length as it is added by the verbs layer and is not part of MAD processing.

---

Changes from RFC:
No longer use kmem_cache for allocations; use kmalloc instead Remove supports_jumbo_mads flag
Use mad_size as specified by the devices
Patch clean up and code simplification
remove jumbo_mad_private structure

 drivers/infiniband/core/agent.c    |   26 ++++-
 drivers/infiniband/core/agent.h    |    2 +-
 drivers/infiniband/core/mad.c      |  230 +++++++++++++++++++++++++++++-------
 drivers/infiniband/core/mad_priv.h |    1 +
 drivers/infiniband/core/mad_rmpp.c |   30 +++--
 drivers/infiniband/core/user_mad.c |   39 ++++---
 6 files changed, 253 insertions(+), 75 deletions(-)
drivers/infiniband/core/agent.c +21 -5
index b6bd305..8dcebcc 100644
@@ -80,13 +80,16 @@ ib_get_agent_port(struct ib_device *device, int port_num)
 
 void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
 			 struct ib_wc *wc, struct ib_device *device,
-			 int port_num, int qpn)
+			 int port_num, int qpn, u32 resp_mad_len)
 {
 	struct ib_agent_port_private *port_priv;
 	struct ib_mad_agent *agent;
 	struct ib_mad_send_buf *send_buf;
 	struct ib_ah *ah;
+	size_t data_len;
+	size_t hdr_len;
 	struct ib_mad_send_wr_private *mad_send_wr;
+	u8 base_version;
 
 	if (device->node_type == RDMA_NODE_IB_SWITCH)
 		port_priv = ib_get_agent_port(device, 0);
@@ -106,16 +109,29 @@ void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
 		return;
 	}
 
+	/* base version determines MAD size */
+	base_version = mad->mad_hdr.base_version;
+	if (base_version == OPA_MGMT_BASE_VERSION) {
+		data_len = resp_mad_len - JUMBO_MGMT_MAD_HDR;
+		hdr_len = JUMBO_MGMT_MAD_HDR;
+	} else {
+		data_len = IB_MGMT_MAD_DATA;
+		hdr_len = IB_MGMT_MAD_HDR;
+	}
+
 	send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0,
-				      IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
-				      GFP_KERNEL,
-				      IB_MGMT_BASE_VERSION);
+				      hdr_len, data_len, GFP_KERNEL,
+				      base_version);
 	if (IS_ERR(send_buf)) {
 		dev_err(&device->dev, "ib_create_send_mad error\n");
 		goto err1;
 	}
 
-	memcpy(send_buf->mad, mad, sizeof *mad);
+	if (base_version == OPA_MGMT_BASE_VERSION)
+		memcpy(send_buf->mad, mad, JUMBO_MGMT_MAD_HDR + data_len);
+	else
+		memcpy(send_buf->mad, mad, sizeof(*mad));
+
 	send_buf->ah = ah;
 
 	if (device->node_type == RDMA_NODE_IB_SWITCH) {
drivers/infiniband/core/agent.h +1 -1
index 6669287..cb4081d 100644
@@ -46,6 +46,6 @@ extern int ib_agent_port_close(struct ib_device *device, int port_num);
 
 extern void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
 				struct ib_wc *wc, struct ib_device *device,
-				int port_num, int qpn);
+				int port_num, int qpn, u32 resp_mad_len);
 
 #endif	/* __AGENT_H_ */
drivers/infiniband/core/mad.c +186 -44

417 lines not on this page · raw message

drivers/infiniband/core/mad_priv.h +1 -0
index bef25d2..5082946 100644
@@ -156,6 +156,7 @@ struct ib_mad_local_private {
 	struct ib_mad_private *mad_priv;
 	struct ib_mad_agent_private *recv_mad_agent;
 	struct ib_mad_send_wr_private *mad_send_wr;
+	size_t return_wc_byte_len;
 };
 
 struct ib_mad_mgmt_method_table {
drivers/infiniband/core/mad_rmpp.c +20 -10
index 7184530..514f0a1 100644
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2005 Intel Inc. All rights reserved.
  * Copyright (c) 2005-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2014 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -67,6 +68,7 @@ struct mad_rmpp_recv {
 	u8 mgmt_class;
 	u8 class_version;
 	u8 method;
+	u8 base_version;
 };
 
 static inline void deref_rmpp_recv(struct mad_rmpp_recv *rmpp_recv)
@@ -318,6 +320,7 @@ create_rmpp_recv(struct ib_mad_agent_private *agent,
 	rmpp_recv->mgmt_class = mad_hdr->mgmt_class;
 	rmpp_recv->class_version = mad_hdr->class_version;
 	rmpp_recv->method  = mad_hdr->method;
+	rmpp_recv->base_version  = mad_hdr->base_version;
 	return rmpp_recv;
 
 error:	kfree(rmpp_recv);
@@ -431,16 +434,23 @@ static void update_seg_num(struct mad_rmpp_recv *rmpp_recv,
 
 static inline int get_mad_len(struct mad_rmpp_recv *rmpp_recv)
 {
-	struct ib_rmpp_mad *rmpp_mad;
+	struct ib_rmpp_base *rmpp_base;
 	int hdr_size, data_size, pad;
 
-	rmpp_mad = (struct ib_rmpp_mad *)rmpp_recv->cur_seg_buf->mad;
+	rmpp_base = &((struct jumbo_rmpp_mad *)rmpp_recv->cur_seg_buf->mad)->base;
 
-	hdr_size = ib_get_mad_data_offset(rmpp_mad->base.mad_hdr.mgmt_class);
-	data_size = sizeof(struct ib_rmpp_mad) - hdr_size;
-	pad = IB_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->base.rmpp_hdr.paylen_newwin);
-	if (pad > IB_MGMT_RMPP_DATA || pad < 0)
-		pad = 0;
+	hdr_size = ib_get_mad_data_offset(rmpp_base->mad_hdr.mgmt_class);
+	if (rmpp_recv->base_version == OPA_MGMT_BASE_VERSION) {
+		data_size = sizeof(struct jumbo_rmpp_mad) - hdr_size;
+		pad = JUMBO_MGMT_RMPP_DATA - be32_to_cpu(rmpp_base->rmpp_hdr.paylen_newwin);
+		if (pad > JUMBO_MGMT_RMPP_DATA || pad < 0)
+			pad = 0;
+	} else {
+		data_size = sizeof(struct ib_rmpp_mad) - hdr_size;
+		pad = IB_MGMT_RMPP_DATA - be32_to_cpu(rmpp_base->rmpp_hdr.paylen_newwin);
+		if (pad > IB_MGMT_RMPP_DATA || pad < 0)
+			pad = 0;
+	}
 
 	return hdr_size + rmpp_recv->seg_num * data_size - pad;
 }
@@ -933,11 +943,11 @@ int ib_process_rmpp_send_wc(struct ib_mad_send_wr_private *mad_send_wr,
 
 int ib_retry_rmpp(struct ib_mad_send_wr_private *mad_send_wr)
 {
-	struct ib_rmpp_base *rmpp_base;
+	struct ib_rmpp_mad *rmpp_mad;
 	int ret;
 
-	rmpp_base = mad_send_wr->send_buf.mad;
-	if (!(ib_get_rmpp_flags(&rmpp_base->rmpp_hdr) &
+	rmpp_mad = mad_send_wr->send_buf.mad;
+	if (!(ib_get_rmpp_flags(&rmpp_mad->base.rmpp_hdr) &
 	      IB_MGMT_RMPP_FLAG_ACTIVE))
 		return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */
 
drivers/infiniband/core/user_mad.c +24 -15
index ac33d34..3e9a36f 100644
@@ -263,20 +263,27 @@ static ssize_t copy_recv_mad(struct ib_umad_file *file, char __user *buf,
 {
 	struct ib_mad_recv_buf *recv_buf;
 	int left, seg_payload, offset, max_seg_payload;
+	int seg_size;
 
-	/* We need enough room to copy the first (or only) MAD segment. */
 	recv_buf = &packet->recv_wc->recv_buf;
-	if ((packet->length <= sizeof (*recv_buf->mad) &&
+
+	if (recv_buf->mad->mad_hdr.base_version == OPA_MGMT_BASE_VERSION)
+		seg_size = sizeof(struct jumbo_mad);
+	else
+		seg_size = sizeof(struct ib_mad);
+
+	/* We need enough room to copy the first (or only) MAD segment. */
+	if ((packet->length <= seg_size &&
 	     count < hdr_size(file) + packet->length) ||
-	    (packet->length > sizeof (*recv_buf->mad) &&
-	     count < hdr_size(file) + sizeof (*recv_buf->mad)))
+	    (packet->length > seg_size &&
+	     count < hdr_size(file) + seg_size))
 		return -EINVAL;
 
 	if (copy_to_user(buf, &packet->mad, hdr_size(file)))
 		return -EFAULT;
 
 	buf += hdr_size(file);
-	seg_payload = min_t(int, packet->length, sizeof (*recv_buf->mad));
+	seg_payload = min_t(int, packet->length, seg_size);
 	if (copy_to_user(buf, recv_buf->mad, seg_payload))
 		return -EFAULT;
 
@@ -293,7 +300,7 @@ static ssize_t copy_recv_mad(struct ib_umad_file *file, char __user *buf,
 			return -ENOSPC;
 		}
 		offset = ib_get_mad_data_offset(recv_buf->mad->mad_hdr.mgmt_class);
-		max_seg_payload = sizeof (struct ib_mad) - offset;
+		max_seg_payload = seg_size - offset;
 
 		for (left = packet->length - seg_payload, buf += seg_payload;
 		     left; left -= seg_payload, buf += seg_payload) {
@@ -448,9 +455,10 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 	struct ib_mad_agent *agent;
 	struct ib_ah_attr ah_attr;
 	struct ib_ah *ah;
-	struct ib_rmpp_base *rmpp_base;
+	struct ib_rmpp_mad *rmpp_mad;
 	__be64 *tid;
 	int ret, data_len, hdr_len, copy_offset, rmpp_active;
+	u8 base_version;
 
 	if (count < hdr_size(file) + IB_MGMT_RMPP_HDR)
 		return -EINVAL;
@@ -504,25 +512,26 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 		goto err_up;
 	}
 
-	rmpp_base = (struct ib_rmpp_base *) packet->mad.data;
-	hdr_len = ib_get_mad_data_offset(rmpp_base->mad_hdr.mgmt_class);
+	rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
+	hdr_len = ib_get_mad_data_offset(rmpp_mad->base.mad_hdr.mgmt_class);
 
-	if (ib_is_mad_class_rmpp(rmpp_base->mad_hdr.mgmt_class)
+	if (ib_is_mad_class_rmpp(rmpp_mad->base.mad_hdr.mgmt_class)
 	    && ib_mad_kernel_rmpp_agent(agent)) {
 		copy_offset = IB_MGMT_RMPP_HDR;
-		rmpp_active = ib_get_rmpp_flags(&rmpp_base->rmpp_hdr) &
+		rmpp_active = ib_get_rmpp_flags(&rmpp_mad->base.rmpp_hdr) &
 						IB_MGMT_RMPP_FLAG_ACTIVE;
 	} else {
 		copy_offset = IB_MGMT_MAD_HDR;
 		rmpp_active = 0;
 	}
 
+	base_version = ((struct ib_mad_hdr *)&packet->mad.data)->base_version;
 	data_len = count - hdr_size(file) - hdr_len;
 	packet->msg = ib_create_send_mad(agent,
 					 be32_to_cpu(packet->mad.hdr.qpn),
 					 packet->mad.hdr.pkey_index, rmpp_active,
 					 hdr_len, data_len, GFP_KERNEL,
-					 IB_MGMT_BASE_VERSION);
+					 base_version);
 	if (IS_ERR(packet->msg)) {
 		ret = PTR_ERR(packet->msg);
 		goto err_ah;
@@ -558,12 +567,12 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 		tid = &((struct ib_mad_hdr *) packet->msg->mad)->tid;
 		*tid = cpu_to_be64(((u64) agent->hi_tid) << 32 |
 				   (be64_to_cpup(tid) & 0xffffffff));
-		rmpp_base->mad_hdr.tid = *tid;
+		rmpp_mad->base.mad_hdr.tid = *tid;
 	}
 
 	if (!ib_mad_kernel_rmpp_agent(agent)
-	   && ib_is_mad_class_rmpp(rmpp_base->mad_hdr.mgmt_class)
-	   && (ib_get_rmpp_flags(&rmpp_base->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
+	   && ib_is_mad_class_rmpp(rmpp_mad->base.mad_hdr.mgmt_class)
+	   && (ib_get_rmpp_flags(&rmpp_mad->base.rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
 		spin_lock_irq(&file->send_lock);
 		list_add_tail(&packet->list, &file->send_list);
 		spin_unlock_irq(&file->send_lock);
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html