[openib-general] [PATCH] ib_mad.c: Fix HCA and switch port numbering
Hal Rosenstock
halr at voltaire.com
Fri Sep 10 17:57:53 PDT 2004
ib_mad.c: Fix HCA and switch port numbering
Index: ib_mad.c
===================================================================
--- ib_mad.c (revision 780)
+++ ib_mad.c (working copy)
@@ -1257,7 +1257,7 @@
static int ib_mad_init_device(struct ib_device *device)
{
- int ret, num_ports, i, ret2;
+ int ret, num_ports, cur_port, i, ret2;
struct ib_device_attr device_attr;
ret = ib_query_device(device, &device_attr);
@@ -1268,13 +1268,15 @@
if (device->node_type == IB_NODE_SWITCH) {
num_ports = 1;
+ cur_port = 0;
} else {
num_ports = device_attr.phys_port_cnt;
+ cur_port = 1;
}
- for (i = 0; i < num_ports; i++) {
- ret = ib_mad_port_open(device, i);
+ for (i = 0; i < num_ports; i++, cur_port++) {
+ ret = ib_mad_port_open(device, cur_port);
if (ret) {
- printk(KERN_ERR "Could not open port %d\n", i);
+ printk(KERN_ERR "Could not open port %d\n", cur_port);
goto error_device_open;
}
}
@@ -1283,9 +1285,10 @@
error_device_open:
while (i > 0) {
- ret2 = ib_mad_port_close(device, i);
+ cur_port--;
+ ret2 = ib_mad_port_close(device, cur_port);
if (ret2) {
- printk(KERN_ERR "Could not close port %d\n", i);
+ printk(KERN_ERR "Could not close port %d\n", cur_port);
}
i--;
}
@@ -1296,7 +1299,7 @@
static int ib_mad_remove_device(struct ib_device *device)
{
- int ret, i, num_ports, ret2;
+ int ret, i, num_ports, cur_port, ret2;
struct ib_device_attr device_attr;
ret = ib_query_device(device, &device_attr);
@@ -1305,12 +1308,17 @@
goto error_device_query;
}
- /* num_ports should also be based on device type! */
- num_ports = device_attr.phys_port_cnt;
- for (i = 0; i < num_ports; i++) {
- ret2 = ib_mad_port_close(device, i);
+ if (device->node_type == IB_NODE_SWITCH) {
+ num_ports = 1;
+ cur_port = 0;
+ } else {
+ num_ports = device_attr.phys_port_cnt;
+ cur_port = 1;
+ }
+ for (i = 0; i < num_ports; i++, cur_port++) {
+ ret2 = ib_mad_port_close(device, cur_port);
if (ret2) {
- printk(KERN_ERR "Could not close port %d\n", i);
+ printk(KERN_ERR "Could not close port %d\n", cur_port);
if (!ret)
ret = ret2;
}
More information about the general
mailing list