IB/Verbs: Reform IB-core mad/agent/user_mad
Use raw management helpers to reform IB-core mad/agent/user_mad. Signed-off-by: Michael Wang <yun.wang@profitbricks.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Tested-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Sean Hefty <sean.hefty@intel.com> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Tested-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
de66be9474
commit
827f2a8b0a
|
@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
|
||||||
goto error1;
|
goto error1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
|
if (rdma_protocol_ib(device, port_num)) {
|
||||||
/* Obtain send only MAD agent for SMI QP */
|
/* Obtain send only MAD agent for SMI QP */
|
||||||
port_priv->agent[0] = ib_register_mad_agent(device, port_num,
|
port_priv->agent[0] = ib_register_mad_agent(device, port_num,
|
||||||
IB_QPT_SMI, NULL, 0,
|
IB_QPT_SMI, NULL, 0,
|
||||||
|
|
|
@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
|
||||||
init_mad_qp(port_priv, &port_priv->qp_info[1]);
|
init_mad_qp(port_priv, &port_priv->qp_info[1]);
|
||||||
|
|
||||||
cq_size = mad_sendq_size + mad_recvq_size;
|
cq_size = mad_sendq_size + mad_recvq_size;
|
||||||
has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
|
has_smi = rdma_protocol_ib(device, port_num);
|
||||||
if (has_smi)
|
if (has_smi)
|
||||||
cq_size *= 2;
|
cq_size *= 2;
|
||||||
|
|
||||||
|
@ -3057,9 +3057,6 @@ static void ib_mad_init_device(struct ib_device *device)
|
||||||
{
|
{
|
||||||
int start, end, i;
|
int start, end, i;
|
||||||
|
|
||||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (device->node_type == RDMA_NODE_IB_SWITCH) {
|
if (device->node_type == RDMA_NODE_IB_SWITCH) {
|
||||||
start = 0;
|
start = 0;
|
||||||
end = 0;
|
end = 0;
|
||||||
|
@ -3069,6 +3066,9 @@ static void ib_mad_init_device(struct ib_device *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = start; i <= end; i++) {
|
for (i = start; i <= end; i++) {
|
||||||
|
if (!rdma_ib_or_iboe(device, i))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (ib_mad_port_open(device, i)) {
|
if (ib_mad_port_open(device, i)) {
|
||||||
dev_err(&device->dev, "Couldn't open port %d\n", i);
|
dev_err(&device->dev, "Couldn't open port %d\n", i);
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -3086,40 +3086,39 @@ error_agent:
|
||||||
dev_err(&device->dev, "Couldn't close port %d\n", i);
|
dev_err(&device->dev, "Couldn't close port %d\n", i);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
i--;
|
while (--i >= start) {
|
||||||
|
if (!rdma_ib_or_iboe(device, i))
|
||||||
|
continue;
|
||||||
|
|
||||||
while (i >= start) {
|
|
||||||
if (ib_agent_port_close(device, i))
|
if (ib_agent_port_close(device, i))
|
||||||
dev_err(&device->dev,
|
dev_err(&device->dev,
|
||||||
"Couldn't close port %d for agents\n", i);
|
"Couldn't close port %d for agents\n", i);
|
||||||
if (ib_mad_port_close(device, i))
|
if (ib_mad_port_close(device, i))
|
||||||
dev_err(&device->dev, "Couldn't close port %d\n", i);
|
dev_err(&device->dev, "Couldn't close port %d\n", i);
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ib_mad_remove_device(struct ib_device *device)
|
static void ib_mad_remove_device(struct ib_device *device)
|
||||||
{
|
{
|
||||||
int i, num_ports, cur_port;
|
int start, end, i;
|
||||||
|
|
||||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (device->node_type == RDMA_NODE_IB_SWITCH) {
|
if (device->node_type == RDMA_NODE_IB_SWITCH) {
|
||||||
num_ports = 1;
|
start = 0;
|
||||||
cur_port = 0;
|
end = 0;
|
||||||
} else {
|
} else {
|
||||||
num_ports = device->phys_port_cnt;
|
start = 1;
|
||||||
cur_port = 1;
|
end = device->phys_port_cnt;
|
||||||
}
|
}
|
||||||
for (i = 0; i < num_ports; i++, cur_port++) {
|
|
||||||
if (ib_agent_port_close(device, cur_port))
|
for (i = start; i <= end; i++) {
|
||||||
|
if (!rdma_ib_or_iboe(device, i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (ib_agent_port_close(device, i))
|
||||||
dev_err(&device->dev,
|
dev_err(&device->dev,
|
||||||
"Couldn't close port %d for agents\n",
|
"Couldn't close port %d for agents\n", i);
|
||||||
cur_port);
|
if (ib_mad_port_close(device, i))
|
||||||
if (ib_mad_port_close(device, cur_port))
|
dev_err(&device->dev, "Couldn't close port %d\n", i);
|
||||||
dev_err(&device->dev, "Couldn't close port %d\n",
|
|
||||||
cur_port);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1273,9 +1273,7 @@ static void ib_umad_add_one(struct ib_device *device)
|
||||||
{
|
{
|
||||||
struct ib_umad_device *umad_dev;
|
struct ib_umad_device *umad_dev;
|
||||||
int s, e, i;
|
int s, e, i;
|
||||||
|
int count = 0;
|
||||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (device->node_type == RDMA_NODE_IB_SWITCH)
|
if (device->node_type == RDMA_NODE_IB_SWITCH)
|
||||||
s = e = 0;
|
s = e = 0;
|
||||||
|
@ -1296,21 +1294,33 @@ static void ib_umad_add_one(struct ib_device *device)
|
||||||
umad_dev->end_port = e;
|
umad_dev->end_port = e;
|
||||||
|
|
||||||
for (i = s; i <= e; ++i) {
|
for (i = s; i <= e; ++i) {
|
||||||
|
if (!rdma_ib_or_iboe(device, i))
|
||||||
|
continue;
|
||||||
|
|
||||||
umad_dev->port[i - s].umad_dev = umad_dev;
|
umad_dev->port[i - s].umad_dev = umad_dev;
|
||||||
|
|
||||||
if (ib_umad_init_port(device, i, umad_dev,
|
if (ib_umad_init_port(device, i, umad_dev,
|
||||||
&umad_dev->port[i - s]))
|
&umad_dev->port[i - s]))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!count)
|
||||||
|
goto free;
|
||||||
|
|
||||||
ib_set_client_data(device, &umad_client, umad_dev);
|
ib_set_client_data(device, &umad_client, umad_dev);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
while (--i >= s)
|
while (--i >= s) {
|
||||||
ib_umad_kill_port(&umad_dev->port[i - s]);
|
if (!rdma_ib_or_iboe(device, i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ib_umad_kill_port(&umad_dev->port[i - s]);
|
||||||
|
}
|
||||||
|
free:
|
||||||
kobject_put(&umad_dev->kobj);
|
kobject_put(&umad_dev->kobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1322,8 +1332,10 @@ static void ib_umad_remove_one(struct ib_device *device)
|
||||||
if (!umad_dev)
|
if (!umad_dev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i)
|
for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i) {
|
||||||
ib_umad_kill_port(&umad_dev->port[i]);
|
if (rdma_ib_or_iboe(device, i))
|
||||||
|
ib_umad_kill_port(&umad_dev->port[i]);
|
||||||
|
}
|
||||||
|
|
||||||
kobject_put(&umad_dev->kobj);
|
kobject_put(&umad_dev->kobj);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue