[openib-general] [PATCH][RFC] Add node_type / transport_type to struct ibv_device
Roland Dreier
rdreier at cisco.com
Tue Oct 3 13:48:28 PDT 2006
err, here's the patch:
Index: libibverbs/include/infiniband/verbs.h
===================================================================
--- libibverbs/include/infiniband/verbs.h (revision 9680)
+++ libibverbs/include/infiniband/verbs.h (working copy)
@@ -66,9 +66,17 @@ union ibv_gid {
};
enum ibv_node_type {
- IBV_NODE_CA = 1,
+ IBV_NODE_UNKNOWN = -1,
+ IBV_NODE_CA = 1,
IBV_NODE_SWITCH,
- IBV_NODE_ROUTER
+ IBV_NODE_ROUTER,
+ IBV_NODE_RNIC
+};
+
+enum ibv_transport_type {
+ IBV_TRANSPORT_UNKNOWN = -1,
+ IBV_TRANSPORT_IB = 0,
+ IBV_TRANSPORT_IWARP
};
enum ibv_device_cap_flags {
@@ -577,6 +585,8 @@ enum {
struct ibv_device {
struct ibv_driver *driver;
struct ibv_device_ops ops;
+ enum ibv_node_type node_type;
+ enum ibv_transport_type transport_type;
/* Name of underlying kernel IB device, eg "mthca0" */
char name[IBV_SYSFS_NAME_MAX];
/* Name of uverbs device, eg "uverbs0" */
Index: libibverbs/ChangeLog
===================================================================
--- libibverbs/ChangeLog (revision 9680)
+++ libibverbs/ChangeLog (working copy)
@@ -1,3 +1,12 @@
+2006-10-03 Roland Dreier <rdreier at cisco.com>
+
+ * src/init.c (init_drivers): Set node_type and transport_type
+ values of device being created.
+
+ * include/infiniband/verbs.h: Add ibv_node_type enum value
+ IBV_NODE_RNIC, and add enum ibv_transport_type. Add node_type and
+ transport_type fields to struct ibv_device.
+
2006-09-12 Roland Dreier <rdreier at cisco.com>
* include/infiniband/verbs.h: Swap wr_id and next members of
Index: libibverbs/src/init.c
===================================================================
--- libibverbs/src/init.c (revision 9680)
+++ libibverbs/src/init.c (working copy)
@@ -130,7 +130,9 @@ static struct ibv_device *init_drivers(c
int abi_ver = 0;
char sys_path[IBV_SYSFS_PATH_MAX];
char ibdev_name[IBV_SYSFS_NAME_MAX];
+ char ibdev_path[IBV_SYSFS_PATH_MAX];
char value[8];
+ enum ibv_node_type node_type;
snprintf(sys_path, sizeof sys_path, "%s/%s",
class_path, dev_name);
@@ -144,17 +146,44 @@ static struct ibv_device *init_drivers(c
return NULL;
}
+ snprintf(ibdev_path, IBV_SYSFS_PATH_MAX, "%s/class/infiniband/%s",
+ ibv_get_sysfs_path(), ibdev_name);
+
+ if (ibv_read_sysfs_file(ibdev_path, "node_type", value, sizeof value) < 0) {
+ fprintf(stderr, PFX "Warning: no node_type attr for %s\n",
+ ibdev_path);
+ return NULL;
+ }
+ node_type = strtol(value, NULL, 10);
+ if (node_type < IBV_NODE_CA || node_type > IBV_NODE_RNIC)
+ node_type = IBV_NODE_UNKNOWN;
+
for (driver = driver_list; driver; driver = driver->next) {
dev = driver->init_func(sys_path, abi_ver);
if (!dev)
continue;
dev->driver = driver;
+ dev->node_type = node_type;
+
+ switch (node_type) {
+ case IBV_NODE_CA:
+ case IBV_NODE_SWITCH:
+ case IBV_NODE_ROUTER:
+ dev->transport_type = IBV_TRANSPORT_IB;
+ break;
+ case IBV_NODE_RNIC:
+ dev->transport_type = IBV_TRANSPORT_IWARP;
+ break;
+ default:
+ dev->transport_type = IBV_TRANSPORT_UNKNOWN;
+ break;
+ }
+
strcpy(dev->dev_path, sys_path);
- snprintf(dev->ibdev_path, IBV_SYSFS_PATH_MAX, "%s/class/infiniband/%s",
- ibv_get_sysfs_path(), ibdev_name);
strcpy(dev->dev_name, dev_name);
strcpy(dev->name, ibdev_name);
+ strcpy(dev->ibdev_path, ibdev_path);
return dev;
}
More information about the general
mailing list