mad.c (b2aaf8f74cdc84a9182f6cabf198b7763bcb9d40) mad.c (7ff93f8b7ecbc36e7ffc5c11a61643821c1bfee5)
1/*
2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 284 unchanged lines hidden (view full) ---

293}
294
295int mlx4_ib_mad_init(struct mlx4_ib_dev *dev)
296{
297 struct ib_mad_agent *agent;
298 int p, q;
299 int ret;
300
1/*
2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 284 unchanged lines hidden (view full) ---

293}
294
295int mlx4_ib_mad_init(struct mlx4_ib_dev *dev)
296{
297 struct ib_mad_agent *agent;
298 int p, q;
299 int ret;
300
301 for (p = 0; p < dev->dev->caps.num_ports; ++p)
301 for (p = 0; p < dev->num_ports; ++p)
302 for (q = 0; q <= 1; ++q) {
303 agent = ib_register_mad_agent(&dev->ib_dev, p + 1,
304 q ? IB_QPT_GSI : IB_QPT_SMI,
305 NULL, 0, send_handler,
306 NULL, NULL);
307 if (IS_ERR(agent)) {
308 ret = PTR_ERR(agent);
309 goto err;
310 }
311 dev->send_agent[p][q] = agent;
312 }
313
314 return 0;
315
316err:
302 for (q = 0; q <= 1; ++q) {
303 agent = ib_register_mad_agent(&dev->ib_dev, p + 1,
304 q ? IB_QPT_GSI : IB_QPT_SMI,
305 NULL, 0, send_handler,
306 NULL, NULL);
307 if (IS_ERR(agent)) {
308 ret = PTR_ERR(agent);
309 goto err;
310 }
311 dev->send_agent[p][q] = agent;
312 }
313
314 return 0;
315
316err:
317 for (p = 0; p < dev->dev->caps.num_ports; ++p)
317 for (p = 0; p < dev->num_ports; ++p)
318 for (q = 0; q <= 1; ++q)
319 if (dev->send_agent[p][q])
320 ib_unregister_mad_agent(dev->send_agent[p][q]);
321
322 return ret;
323}
324
325void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev)
326{
327 struct ib_mad_agent *agent;
328 int p, q;
329
318 for (q = 0; q <= 1; ++q)
319 if (dev->send_agent[p][q])
320 ib_unregister_mad_agent(dev->send_agent[p][q]);
321
322 return ret;
323}
324
325void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev)
326{
327 struct ib_mad_agent *agent;
328 int p, q;
329
330 for (p = 0; p < dev->dev->caps.num_ports; ++p) {
330 for (p = 0; p < dev->num_ports; ++p) {
331 for (q = 0; q <= 1; ++q) {
332 agent = dev->send_agent[p][q];
333 dev->send_agent[p][q] = NULL;
334 ib_unregister_mad_agent(agent);
335 }
336
337 if (dev->sm_ah[p])
338 ib_destroy_ah(dev->sm_ah[p]);
339 }
340}
331 for (q = 0; q <= 1; ++q) {
332 agent = dev->send_agent[p][q];
333 dev->send_agent[p][q] = NULL;
334 ib_unregister_mad_agent(agent);
335 }
336
337 if (dev->sm_ah[p])
338 ib_destroy_ah(dev->sm_ah[p]);
339 }
340}