Skip to contentSkip to conversation

Make Node Description default to "<hostname> <device>"

PATCH Superseded [email protected] 2 participants 10 messages Oct 30, 2014 – Nov 7, 2014 4 messages not in the archive

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Make Node Description default to "<hostname> <device>"

The following series defines a new mad core function to support Node Description processing which supports format specifiers. The first 2 format specifiers are "%h" and "%d" for hostname and device respectively.

It also changes the default Node Description of all the devices which support Node Description in software to use "%h %d" by default which translates into <hostname> <device>.

Note that the sysfs node_desc file for devices now reflects the format specifier and not the actual remapped Node Description. This allows userspace to detect the current format used and change it as needed.

Devices which store the Node Description in FW have a translated version written to FW while maintaining the format specifier string in memory.

This work is a continuation of the following thread and the work done by Mike Heinz:

http://www.mail-archive.com/[email protected]/msg07329.html

A follow on patch to the infiniband-diags package adds support for a "RDMA Node Description Daemon" (rdma-ndd) which uses the new poll support of the procfs hostname file to monitor for changes to the hostname and updates the Node Descriptions appropriately. Both the kernel changes and the user space daemon are necessary to ensure that the Node Description in the SMA and SA reflect the hostname/device in all cases if the device supports traps and the SM either responds to those traps or polls for the Node Description periodically. This is true for the following reasons.

1) No matter when the drivers are loaded they will return "<hostname> <device>" to the SM when initially queried.
2) If the hostname is not set when the driver is loaded (as is likely at boot) subsequent sets of hostname (from any source including dhclient) will trigger the daemon to update all node descriptions. The use of dhclient hooks is not sufficient to handle user invoked hostname changes.
3) If the daemon is started after the hostname has changed it starts by writing the hostname to the Node Descriptions sysfs files which will trigger the devices to send a trap to the SM.

Thus the drivers, any automated set of the hostname (such as DHCP), and the rdma-ndd daemon can be started in any order and the SMA will reflect the hostname properly.

[PATCH 1/6] ib/mad: Add function to support format specifiers for node description [PATCH 2/6] ib/ipath: change default node description processing [PATCH 3/6] ib/mlx4: change default node description processing [PATCH 4/6] ib/mthca: change default node description processing [PATCH 5/6] ib/qib: change default node description processing
[PATCH 6/6] ib/mlx5: change default node description processing
--
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): 1414713021-12175-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/6 ib/mad: Add function to support format specifiers for node description

From: Ira Weiny <[email protected]>

ib_build_node_desc - prints src node description into dest while mapping format specifiers

Specifiers supported:
%h system hostname
%d device name

Define a default Node Description format to be "%h %d"

Original work done by Mike Heinz.

The function signature is generic to support some devices which are not processing an ib_smp object when calling this function.

---
 drivers/infiniband/core/mad.c | 38 ++++++++++++++++++++++++++++++++++++++
 include/rdma/ib_mad.h         | 17 +++++++++++++++++
 include/rdma/ib_verbs.h       |  6 ++++--
 3 files changed, 59 insertions(+), 2 deletions(-)
drivers/infiniband/core/mad.c +38 -0
index 74c30f4..a7ed0ada 100644
@@ -39,7 +39,9 @@
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/utsname.h>
 #include <rdma/ib_cache.h>
+#include <rdma/ib_smi.h>
 
 #include "mad_priv.h"
 #include "mad_rmpp.h"
@@ -996,6 +998,42 @@ int ib_get_mad_data_offset(u8 mgmt_class)
 }
 EXPORT_SYMBOL(ib_get_mad_data_offset);
 
+void ib_build_node_desc(char *dest, char *src, int dest_len,
+			struct ib_device *dev)
+{
+	char *end = dest + dest_len-1;
+	char *field;
+
+	while (*src && (dest < end)) {
+		if (*src != '%') {
+			*dest++ = *src++;
+		} else {
+			src++;
+			switch (*src) {
+			case 'h':
+				field = init_utsname()->nodename;
+				src++;
+				while (*field && (*field != '.') && (dest < end))
+					*dest++ = *field++;
+			break;
+			case 'd':
+				field = dev->name;
+				src++;
+				while (*field && (dest < end))
+					*dest++ = *field++;
+				break;
+			default:
+				src++;
+			}
+		}
+	}
+	if (dest < end)
+		*dest = 0;
+	else
+		*end = 0;
+}
+EXPORT_SYMBOL(ib_build_node_desc);
+
 int ib_is_mad_class_rmpp(u8 mgmt_class)
 {
 	if ((mgmt_class == IB_MGMT_CLASS_SUBN_ADM) ||
include/rdma/ib_mad.h +17 -0
index 9bb99e9..975642e 100644
@@ -677,4 +677,21 @@ void ib_free_send_mad(struct ib_mad_send_buf *send_buf);
  */
 int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent);
 
+#define IB_DEFAULT_ND_FORMAT "%h %d"
+/**
+ * ib_build_node_desc - prints src node description into dest while mapping
+ * format specifiers
+ *
+ * Specifiers supported:
+ * %h system hostname
+ * %d device name
+ *
+ * @dest: destination buffer
+ * @src: source buffer
+ * @dest_len: destination buffer length
+ * @dev: ib_device
+ */
+void ib_build_node_desc(char *dest, char *src, int dest_len,
+			struct ib_device *dev);
+
 #endif /* IB_MAD_H */
include/rdma/ib_verbs.h +4 -2
index 470a011..f3ec6de 100644
@@ -55,6 +55,8 @@
 
 extern struct workqueue_struct *ib_wq;
 
+#define IB_DEVICE_DESC_MAX 64
+
 union ib_gid {
 	u8	raw[16];
 	struct {
@@ -351,7 +353,7 @@ enum ib_device_modify_flags {
 
 struct ib_device_modify {
 	u64	sys_image_guid;
-	char	node_desc[64];
+	char	node_desc[IB_DEVICE_DESC_MAX];
 };
 
 enum ib_port_modify_flags {
@@ -1625,7 +1627,7 @@ struct ib_device {
 	u64			     uverbs_cmd_mask;
 	u64			     uverbs_ex_cmd_mask;
 
-	char			     node_desc[64];
+	char			     node_desc[IB_DEVICE_DESC_MAX];
 	__be64			     node_guid;
 	u32			     local_dma_lkey;
 	u8                           node_type;
Signature · 6 lines
1.8.2

--
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/6 ib/ipath: change default node description processing

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Change the default node description string to IB_DEFAULT_ND_FORMAT Use ib_build_node_desc to dynamically map this string when queried

---
 drivers/infiniband/hw/ipath/ipath_mad.c   | 3 ++-
 drivers/infiniband/hw/ipath/ipath_verbs.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ipath/ipath_mad.c +2 -1
index e890e5b..1ec0afd 100644
@@ -61,7 +61,8 @@ static int recv_subn_get_nodedescription(struct ib_smp *smp,
 	if (smp->attr_mod)
 		smp->status |= IB_SMP_INVALID_FIELD;
 
-	memcpy(smp->data, ibdev->node_desc, sizeof(smp->data));
+	ib_build_node_desc(smp->data, ibdev->node_desc, IB_DEVICE_DESC_MAX,
+			   ibdev);
 
 	return reply(smp);
 }
drivers/infiniband/hw/ipath/ipath_verbs.c +2 -2
index 44ea939..bec61d6 100644
@@ -2180,8 +2180,8 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
 	dev->mmap = ipath_mmap;
 	dev->dma_ops = &ipath_dma_mapping_ops;
 
-	snprintf(dev->node_desc, sizeof(dev->node_desc),
-		 IPATH_IDSTR " %s", init_utsname()->nodename);
+	snprintf(dev->node_desc, sizeof(dev->node_desc)-1, "%s",
+		 IB_DEFAULT_ND_FORMAT);
 
 	ret = ib_register_device(dev, NULL);
 	if (ret)
Signature · 6 lines
1.8.2

--
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
#4 lore raw

PATCH 3/6 ib/mlx4: change default node description processing

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Change the default node description string to IB_DEFAULT_ND_FORMAT Use ib_build_node_desc to dynamically map this string when queried and to set the Node Description in FW

---
 drivers/infiniband/hw/mlx4/mad.c  |  3 ++-
 drivers/infiniband/hw/mlx4/main.c | 14 ++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)
drivers/infiniband/hw/mlx4/mad.c +2 -1
index 82a7dd8..0d736d6 100644
@@ -343,7 +343,8 @@ static void node_desc_override(struct ib_device *dev,
 	    mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
 	    mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
 		spin_lock_irqsave(&to_mdev(dev)->sm_lock, flags);
-		memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
+		ib_build_node_desc(((struct ib_smp *)mad)->data, dev->node_desc,
+				   IB_DEVICE_DESC_MAX, dev);
 		spin_unlock_irqrestore(&to_mdev(dev)->sm_lock, flags);
 	}
 }
drivers/infiniband/hw/mlx4/main.c +6 -8
index bda5994..6327ee5 100644
@@ -553,7 +553,7 @@ static int mlx4_ib_modify_device(struct ib_device *ibdev, int mask,
 	if (IS_ERR(mailbox))
 		return 0;
 
-	memcpy(mailbox->buf, props->node_desc, 64);
+	ib_build_node_desc(mailbox->buf, props->node_desc, 64, ibdev);
 	mlx4_cmd(to_mdev(ibdev)->dev, mailbox->dma, 1, 0,
 		 MLX4_CMD_SET_NODE, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE);
 
@@ -1332,23 +1332,21 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	struct ib_smp *out_mad = NULL;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
+	struct ib_device_modify props;
 
 	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
 	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
+	snprintf(props.node_desc, sizeof(props.node_desc)-1, "%s",
+		 IB_DEFAULT_ND_FORMAT);
+	mlx4_ib_modify_device(&dev->ib_dev, IB_DEVICE_MODIFY_NODE_DESC, &props);
+
 	init_query_mad(in_mad);
-	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
 	if (mlx4_is_master(dev->dev))
 		mad_ifc_flags |= MLX4_MAD_IFC_NET_VIEW;
 
-	err = mlx4_MAD_IFC(dev, mad_ifc_flags, 1, NULL, NULL, in_mad, out_mad);
-	if (err)
-		goto out;
-
-	memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
-
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
 
 	err = mlx4_MAD_IFC(dev, mad_ifc_flags, 1, NULL, NULL, in_mad, out_mad);
Signature · 6 lines
1.8.2

--
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): 1414713021-12175-4-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#6 lore raw

Re: [PATCH 3/6] ib/mlx4: change default node description processing

Quoted 35 lines · On 10/30/2014 7:50 PM, [email protected] wrote:

From: Ira Weiny <[email protected]>

Change the default node description string to IB_DEFAULT_ND_FORMAT Use ib_build_node_desc to dynamically map this string when queried and to set the Node Description in FW

---
 drivers/infiniband/hw/mlx4/mad.c  |  3 ++-
 drivers/infiniband/hw/mlx4/main.c | 14 ++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)
drivers/infiniband/hw/mlx4/mad.c +2 -1
index 82a7dd8..0d736d6 100644
@@ -343,7 +343,8 @@ static void node_desc_override(struct ib_device *dev,
 	    mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
 	    mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
 		spin_lock_irqsave(&to_mdev(dev)->sm_lock, flags);
-		memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
+		ib_build_node_desc(((struct ib_smp *)mad)->data, dev->node_desc,
+				   IB_DEVICE_DESC_MAX, dev);
 		spin_unlock_irqrestore(&to_mdev(dev)->sm_lock, flags);
 	}
 }
drivers/infiniband/hw/mlx4/main.c +0 -0
index bda5994..6327ee5 100644

drivers/infiniband/hw/mlx4/main.c static int mlx4_ib_modify_device(struct ib_device *ibdev, int mask, · line 556

Quoted 5 lines
drivers/infiniband/hw/mlx4/main.c +1 -1
@@ -553,7 +553,7 @@ static int mlx4_ib_modify_device(struct ib_device *ibdev, int mask,
 	if (IS_ERR(mailbox))
 		return 0;
 
-	memcpy(mailbox->buf, props->node_desc, 64);
+	ib_build_node_desc(mailbox->buf, props->node_desc, 64, ibdev);

Nit: Should this be IB_DEVICE_DESC_MAX rather than 64 ?

-- Hal

Quoted 22 lines
drivers/infiniband/hw/mlx4/main.c +5 -1
 	mlx4_cmd(to_mdev(ibdev)->dev, mailbox->dma, 1, 0,
 		 MLX4_CMD_SET_NODE, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE);
 
@@ -1332,23 +1332,21 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	struct ib_smp *out_mad = NULL;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
+	struct ib_device_modify props;
 
 	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
 	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
+	snprintf(props.node_desc, sizeof(props.node_desc)-1, "%s",
+		 IB_DEFAULT_ND_FORMAT);
+	mlx4_ib_modify_device(&dev->ib_dev, IB_DEVICE_MODIFY_NODE_DESC, &props);
+
 	init_query_mad(in_mad);
-	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
 	if (mlx4_is_master(dev->dev))
 		mad_ifc_flags |= MLX4_MAD_IFC_NET_VIEW;

drivers/infiniband/hw/mlx4/main.c static int init_node_data(struct mlx4_ib_dev *dev) · line 1352

Quoted 10 lines
drivers/infiniband/hw/mlx4/main.c +0 -6
 
-	err = mlx4_MAD_IFC(dev, mad_ifc_flags, 1, NULL, NULL, in_mad, out_mad);
-	if (err)
-		goto out;
-
-	memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
-
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
 
 	err = mlx4_MAD_IFC(dev, mad_ifc_flags, 1, NULL, NULL, in_mad, out_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

#7 lore raw

PATCH 4/6 ib/mthca: change default node description processing

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Change the default node description string to IB_DEFAULT_ND_FORMAT Use ib_build_node_desc to dynamically map this string when queried

---
 drivers/infiniband/hw/mthca/mthca_mad.c      |  3 ++-
 drivers/infiniband/hw/mthca/mthca_provider.c | 12 +++---------
 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/infiniband/hw/mthca/mthca_mad.c +2 -1
index 8881fa3..2c15359 100644
@@ -153,7 +153,8 @@ static void node_desc_override(struct ib_device *dev,
 	    mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
 	    mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
 		mutex_lock(&to_mdev(dev)->cap_mask_mutex);
-		memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
+		ib_build_node_desc(((struct ib_smp *)mad)->data, dev->node_desc,
+				   64, dev);
 		mutex_unlock(&to_mdev(dev)->cap_mask_mutex);
 	}
 }
drivers/infiniband/hw/mthca/mthca_provider.c +3 -9
index 415f8e1..c8e3d23 100644
@@ -1217,16 +1217,10 @@ static int mthca_init_node_data(struct mthca_dev *dev)
 	if (!in_mad || !out_mad)
 		goto out;
 
-	init_query_mad(in_mad);
-	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
-
-	err = mthca_MAD_IFC(dev, 1, 1,
-			    1, NULL, NULL, in_mad, out_mad);
-	if (err)
-		goto out;
-
-	memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
+	snprintf(dev->ib_dev.node_desc, sizeof(dev->ib_dev.node_desc)-1, "%s",
+		 IB_DEFAULT_ND_FORMAT);
 
+	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
 
 	err = mthca_MAD_IFC(dev, 1, 1,
Signature · 6 lines
1.8.2

--
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): 1414713021-12175-5-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#9 lore raw

Re: [PATCH 4/6] ib/mthca: change default node description processing

Quoted 20 lines · On 10/30/2014 7:50 PM, [email protected] wrote:

From: Ira Weiny <[email protected]>

Change the default node description string to IB_DEFAULT_ND_FORMAT Use ib_build_node_desc to dynamically map this string when queried

---
 drivers/infiniband/hw/mthca/mthca_mad.c      |  3 ++-
 drivers/infiniband/hw/mthca/mthca_provider.c | 12 +++---------
 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/infiniband/hw/mthca/mthca_mad.c +0 -0
index 8881fa3..2c15359 100644

drivers/infiniband/hw/mthca/mthca_mad.c static void node_desc_override(struct ib_device *dev, · line 157

Quoted 6 lines
drivers/infiniband/hw/mthca/mthca_mad.c +2 -1
@@ -153,7 +153,8 @@ static void node_desc_override(struct ib_device *dev,
 	    mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
 	    mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
 		mutex_lock(&to_mdev(dev)->cap_mask_mutex);
-		memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
+		ib_build_node_desc(((struct ib_smp *)mad)->data, dev->node_desc,
+				   64, dev);

Nit: Should this be IB_DEVICE_DESC_MAX rather than 64 ?

-- Hal

Quoted 17 lines
drivers/infiniband/hw/mthca/mthca_mad.c +0 -0
 		mutex_unlock(&to_mdev(dev)->cap_mask_mutex);
 	}
 }
drivers/infiniband/hw/mthca/mthca_provider.c +0 -6
index 415f8e1..c8e3d23 100644
@@ -1217,16 +1217,10 @@ static int mthca_init_node_data(struct mthca_dev *dev)
 	if (!in_mad || !out_mad)
 		goto out;
 
-	init_query_mad(in_mad);
-	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
-
-	err = mthca_MAD_IFC(dev, 1, 1,
-			    1, NULL, NULL, in_mad, out_mad);
-	if (err)

drivers/infiniband/hw/mthca/mthca_provider.c static int mthca_init_node_data(struct mthca_dev *dev) · line 1226

Quoted 10 lines
drivers/infiniband/hw/mthca/mthca_provider.c +3 -3
-		goto out;
-
-	memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
+	snprintf(dev->ib_dev.node_desc, sizeof(dev->ib_dev.node_desc)-1, "%s",
+		 IB_DEFAULT_ND_FORMAT);
 
+	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
 
 	err = mthca_MAD_IFC(dev, 1, 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/6 ib/qib: change default node description processing

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Change the default node description string to IB_DEFAULT_ND_FORMAT Use ib_build_node_desc to dynamically map this string when queried

---
 drivers/infiniband/hw/qib/qib_mad.c   | 3 ++-
 drivers/infiniband/hw/qib/qib_verbs.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/hw/qib/qib_mad.c +2 -1
index 636be11..4db794f 100644
@@ -268,7 +268,8 @@ static int subn_get_nodedescription(struct ib_smp *smp,
 	if (smp->attr_mod)
 		smp->status |= IB_SMP_INVALID_FIELD;
 
-	memcpy(smp->data, ibdev->node_desc, sizeof(smp->data));
+	ib_build_node_desc(smp->data, ibdev->node_desc, IB_DEVICE_DESC_MAX,
+			   ibdev);
 
 	return reply(smp);
 }
drivers/infiniband/hw/qib/qib_verbs.c +2 -2
index 9bcfbd8..2c36808 100644
@@ -2225,8 +2225,8 @@ int qib_register_ib_device(struct qib_devdata *dd)
 	ibdev->mmap = qib_mmap;
 	ibdev->dma_ops = &qib_dma_mapping_ops;
 
-	snprintf(ibdev->node_desc, sizeof(ibdev->node_desc),
-		 "Intel Infiniband HCA %s", init_utsname()->nodename);
+	snprintf(ibdev->node_desc, sizeof(ibdev->node_desc)-1, "%s",
+		 IB_DEFAULT_ND_FORMAT);
 
 	ret = ib_register_device(ibdev, qib_create_port_files);
 	if (ret)
Signature · 6 lines
1.8.2

--
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
#11 lore raw

PATCH 6/6 ib/mlx5: change default node description processing

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Change the default node description string to IB_DEFAULT_ND_FORMAT Use ib_build_node_desc to dynamically map this string to set Node Description in FW

---
 drivers/infiniband/hw/mlx5/main.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/infiniband/hw/mlx5/main.c +7 -8
index a244317..a8bf1de 100644
@@ -424,11 +424,12 @@ static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask,
 	if (!(mask & IB_DEVICE_MODIFY_NODE_DESC))
 		return 0;
 
+	ib_build_node_desc(in.desc, props->node_desc, 64, ibdev);
+
 	/*
 	 * If possible, pass node desc to FW, so it can generate
 	 * a 144 trap.  If cmd fails, just ignore.
 	 */
-	memcpy(&in, props->node_desc, 64);
 	err = mlx5_core_access_reg(dev->mdev, &in, sizeof(in), &out,
 				   sizeof(out), MLX5_REG_NODE_DESC, 0, 1);
 	if (err)
@@ -806,20 +807,18 @@ static int init_node_data(struct mlx5_ib_dev *dev)
 	struct ib_smp *in_mad  = NULL;
 	struct ib_smp *out_mad = NULL;
 	int err = -ENOMEM;
+	struct ib_device_modify props;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
-	init_query_mad(in_mad);
-	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
+	snprintf(props.node_desc, sizeof(props.node_desc)-1, "%s",
+		 IB_DEFAULT_ND_FORMAT);
+	mlx5_ib_modify_device(&dev->ib_dev, IB_DEVICE_MODIFY_NODE_DESC, &props);
 
-	err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad);
-	if (err)
-		goto out;
-
-	memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
+	init_query_mad(in_mad);
 
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
 
Signature · 6 lines
1.8.2

--
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): 1414713021-12175-7-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#13 lore raw

Re: [PATCH 6/6] ib/mlx5: change default node description processing

Quoted 20 lines · On 10/30/2014 7:50 PM, [email protected] wrote:

From: Ira Weiny <[email protected]>

Change the default node description string to IB_DEFAULT_ND_FORMAT Use ib_build_node_desc to dynamically map this string to set Node Description in FW

---
 drivers/infiniband/hw/mlx5/main.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/infiniband/hw/mlx5/main.c +0 -0
index a244317..a8bf1de 100644

drivers/infiniband/hw/mlx5/main.c static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask, · line 427

Quoted 4 lines
drivers/infiniband/hw/mlx5/main.c +1 -0
@@ -424,11 +424,12 @@ static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask,
 	if (!(mask & IB_DEVICE_MODIFY_NODE_DESC))
 		return 0;
 
+	ib_build_node_desc(in.desc, props->node_desc, 64, ibdev);

Nit: Should this be IB_DEVICE_DESC_MAX rather than 64 ?

-- Hal

Quoted 25 lines
drivers/infiniband/hw/mlx5/main.c +5 -3
+
 	/*
 	 * If possible, pass node desc to FW, so it can generate
 	 * a 144 trap.  If cmd fails, just ignore.
 	 */
-	memcpy(&in, props->node_desc, 64);
 	err = mlx5_core_access_reg(dev->mdev, &in, sizeof(in), &out,
 				   sizeof(out), MLX5_REG_NODE_DESC, 0, 1);
 	if (err)
@@ -806,20 +807,18 @@ static int init_node_data(struct mlx5_ib_dev *dev)
 	struct ib_smp *in_mad  = NULL;
 	struct ib_smp *out_mad = NULL;
 	int err = -ENOMEM;
+	struct ib_device_modify props;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
-	init_query_mad(in_mad);
-	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
+	snprintf(props.node_desc, sizeof(props.node_desc)-1, "%s",
+		 IB_DEFAULT_ND_FORMAT);
+	mlx5_ib_modify_device(&dev->ib_dev, IB_DEVICE_MODIFY_NODE_DESC, &props);

drivers/infiniband/hw/mlx5/main.c static int init_node_data(struct mlx5_ib_dev *dev) · line 824

Quoted 10 lines
drivers/infiniband/hw/mlx5/main.c +1 -5
 
-	err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad);
-	if (err)
-		goto out;
-
-	memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
+	init_query_mad(in_mad);
 
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
 

--
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