[openib-general] [PATCH][UVERBS][RFC] Node Type in Userland

Tom Tucker tom at opengridcomputing.com
Mon Apr 24 10:46:00 PDT 2006


This patch uses the sys/class entries to divine the node type and 
stores the result in the cma_id when the cm_id is bound to a device. 
The node_type can then be used by both the CMA and Applications to
select transport specific code paths. 

Signed-off-by: Tom Tucker <tom at opengridcomputing.com>

Index: libibverbs/include/infiniband/verbs.h
===================================================================
--- libibverbs/include/infiniband/verbs.h	(revision 6570)
+++ libibverbs/include/infiniband/verbs.h	(working copy)
@@ -698,6 +698,12 @@
 		   struct ibv_port_attr *port_attr);
 
 /**
+ * ibv_query_node_type - Get the device node_type
+ */
+int ibv_query_node_type(struct ibv_context *context, 
+			enum ibv_node_type *node_type);
+
+/**
  * ibv_query_gid - Get a GID table entry
  */
 int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
Index: libibverbs/src/libibverbs.map
===================================================================
--- libibverbs/src/libibverbs.map	(revision 6570)
+++ libibverbs/src/libibverbs.map	(working copy)
@@ -9,6 +9,7 @@
 		ibv_get_async_event;
 		ibv_ack_async_event;
 		ibv_query_device;
+		ibv_query_node_type;
 		ibv_query_port;
 		ibv_query_gid;
 		ibv_query_pkey;
Index: libibverbs/src/verbs.c
===================================================================
--- libibverbs/src/verbs.c	(revision 6570)
+++ libibverbs/src/verbs.c	(working copy)
@@ -89,6 +89,23 @@
 	return context->ops.query_port(context, port_num, port_attr);
 }
 
+int ibv_query_node_type(struct ibv_context *context, 
+			enum ibv_node_type *node_type)
+{
+	char node_desc[24];
+	char node_str[24];
+
+	if (!context)
+		return -1;
+
+	if (ibv_read_sysfs_file(context->device->ibdev->path, "node_type",
+				node_desc, sizeof(node_desc)) < 0)
+		return -1;
+
+	sscanf(node_desc, "%d: %s\n", (int*)node_type, node_str);
+	return 0;
+}
+
 int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
 		  int index, union ibv_gid *gid)
 {
Index: librdmacm/include/rdma/rdma_cma.h
===================================================================
--- librdmacm/include/rdma/rdma_cma.h	(revision 6570)
+++ librdmacm/include/rdma/rdma_cma.h	(working copy)
@@ -79,6 +79,7 @@
 	void			*context;
 	struct ibv_qp		*qp;
 	struct rdma_route	 route;
+	enum ibv_node_type       node_type;
 	uint8_t			 port_num;
 };
 
Index: librdmacm/src/cma.c
===================================================================
--- librdmacm/src/cma.c	(revision 6570)
+++ librdmacm/src/cma.c	(working copy)
@@ -248,6 +248,8 @@
 		if (cma_dev->guid == guid) {
 			id_priv->cma_dev = cma_dev;
 			id_priv->id.verbs = cma_dev->verbs;
+			ibv_query_node_type(cma_dev->verbs,
+					    &id_priv->id.node_type);
 			return 0;
 		}




More information about the general mailing list