aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mlx4/mad.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/mlx4/mad.c')
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index f38d5b118927..c9a8dd63b9e2 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -311,19 +311,25 @@ int mlx4_ib_mad_init(struct mlx4_ib_dev *dev)
311 struct ib_mad_agent *agent; 311 struct ib_mad_agent *agent;
312 int p, q; 312 int p, q;
313 int ret; 313 int ret;
314 enum rdma_link_layer ll;
314 315
315 for (p = 0; p < dev->num_ports; ++p) 316 for (p = 0; p < dev->num_ports; ++p) {
317 ll = rdma_port_get_link_layer(&dev->ib_dev, p + 1);
316 for (q = 0; q <= 1; ++q) { 318 for (q = 0; q <= 1; ++q) {
317 agent = ib_register_mad_agent(&dev->ib_dev, p + 1, 319 if (ll == IB_LINK_LAYER_INFINIBAND) {
318 q ? IB_QPT_GSI : IB_QPT_SMI, 320 agent = ib_register_mad_agent(&dev->ib_dev, p + 1,
319 NULL, 0, send_handler, 321 q ? IB_QPT_GSI : IB_QPT_SMI,
320 NULL, NULL); 322 NULL, 0, send_handler,
321 if (IS_ERR(agent)) { 323 NULL, NULL);
322 ret = PTR_ERR(agent); 324 if (IS_ERR(agent)) {
323 goto err; 325 ret = PTR_ERR(agent);
324 } 326 goto err;
325 dev->send_agent[p][q] = agent; 327 }
328 dev->send_agent[p][q] = agent;
329 } else
330 dev->send_agent[p][q] = NULL;
326 } 331 }
332 }
327 333
328 return 0; 334 return 0;
329 335
@@ -344,8 +350,10 @@ void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev)
344 for (p = 0; p < dev->num_ports; ++p) { 350 for (p = 0; p < dev->num_ports; ++p) {
345 for (q = 0; q <= 1; ++q) { 351 for (q = 0; q <= 1; ++q) {
346 agent = dev->send_agent[p][q]; 352 agent = dev->send_agent[p][q];
347 dev->send_agent[p][q] = NULL; 353 if (agent) {
348 ib_unregister_mad_agent(agent); 354 dev->send_agent[p][q] = NULL;
355 ib_unregister_mad_agent(agent);
356 }
349 } 357 }
350 358
351 if (dev->sm_ah[p]) 359 if (dev->sm_ah[p])