[openib-general] [PATCH] CM: set CM bit on port info
Sean Hefty
mshefty at ichips.intel.com
Wed Jan 19 01:25:57 PST 2005
Following patch sets the CM supported bit on port info records.
signed-off-by: Sean Hefty <sean.hefty at intel.com>
Index: core/cm.c
===================================================================
--- core/cm.c (revision 1570)
+++ core/cm.c (working copy)
@@ -2295,9 +2295,16 @@
static void cm_add_one(struct ib_device *device)
{
struct cm_port *port_array, *port;
- struct ib_mad_reg_req reg_req;
+ struct ib_mad_reg_req reg_req = {
+ .mgmt_class = IB_MGMT_CLASS_CM,
+ .mgmt_class_version = 1
+ };
+ struct ib_port_modify port_modify = {
+ .set_port_cap_mask = IB_PORT_CM_SUP
+ };
u64 ca_guid;
u8 i;
+ int ret;
ca_guid = cm_get_ca_guid(device);
if (!ca_guid)
@@ -2307,15 +2314,12 @@
if (!port_array)
return;
- /* todo: (high priority) set CM bit in port info */
- memset(®_req, 0, sizeof reg_req);
- reg_req.mgmt_class = IB_MGMT_CLASS_CM;
- reg_req.mgmt_class_version = 1;
set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
for (i = 1, port = port_array; i <= device->phys_port_cnt; i++, port++){
spin_lock_init(&port->lock);
port->ca_guid = ca_guid;
port->port_num = i;
+
port->mad_agent = ib_register_mad_agent(device, i,
IB_QPT_GSI,
®_req,
@@ -2324,21 +2328,30 @@
cm_recv_handler,
port);
if (IS_ERR(port->mad_agent))
- goto error;
+ goto error1;
port->mr = ib_get_dma_mr(port->mad_agent->qp->pd,
IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(port->mr)) {
- ib_unregister_mad_agent(port->mad_agent);
- goto error;
- }
+ if (IS_ERR(port->mr))
+ goto error2;
+
+ ret = ib_modify_port(device, i, 0, &port_modify);
+ if (ret)
+ goto error3;
}
ib_set_client_data(device, &cm_client, port_array);
return;
-error:
+error3:
+ ib_dereg_mr(port->mr);
+error2:
+ ib_unregister_mad_agent(port->mad_agent);
+error1:
+ port_modify.set_port_cap_mask = 0;
+ port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
while (port != port_array) {
--port;
+ ib_modify_port(device, port->port_num, 0, &port_modify);
ib_dereg_mr(port->mr);
ib_unregister_mad_agent(port->mad_agent);
}
@@ -2348,6 +2361,9 @@
static void cm_remove_one(struct ib_device *device)
{
struct cm_port *port_array, *port;
+ struct ib_port_modify port_modify = {
+ .clr_port_cap_mask = IB_PORT_CM_SUP
+ };
int i;
port_array = (struct cm_port *)ib_get_client_data(device, &cm_client);
@@ -2355,6 +2371,7 @@
return;
for (i = 1, port = port_array; i <= device->phys_port_cnt; i++, port++){
+ ib_modify_port(device, port->port_num, 0, &port_modify);
ib_dereg_mr(port->mr);
ib_unregister_mad_agent(port->mad_agent);
}
More information about the general
mailing list