Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
/*
 * Copyright (c) 2004, 2005 Intel Corporation.  All rights reserved.
 * Copyright (c) 2005, 2006 Voltaire Inc.  All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directorY of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * $Id$
 */

#define	LINUXKPI_PARAM_PREFIX ib_madeye_

#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>

#include <rdma/ib_mad.h>
#include <rdma/ib_smi.h>
#include <rdma/ib_sa.h>

MODULE_AUTHOR("Sean Hefty");
MODULE_DESCRIPTION("InfiniBand MAD viewer");
MODULE_LICENSE("Dual BSD/GPL");

static void madeye_remove_one(struct ib_device *device);
static void madeye_add_one(struct ib_device *device);

static struct ib_client madeye_client = {
	.name   = "madeye",
	.add    = madeye_add_one,
	.remove = madeye_remove_one
};

struct madeye_port {
	struct ib_mad_agent *smi_agent;
	struct ib_mad_agent *gsi_agent;
};

static int smp = 1;
static int gmp = 1;
static int mgmt_class = 0;
static int attr_id = 0;
static int data = 0;

module_param(smp, int, 0444);
module_param(gmp, int, 0444);
module_param(mgmt_class, int, 0444);
module_param(attr_id, int, 0444);
module_param(data, int, 0444);

MODULE_PARM_DESC(smp, "Display all SMPs (default=1)");
MODULE_PARM_DESC(gmp, "Display all GMPs (default=1)");
MODULE_PARM_DESC(mgmt_class, "Display all MADs of specified class (default=0)");
MODULE_PARM_DESC(attr_id, "Display add MADs of specified attribute ID (default=0)");
MODULE_PARM_DESC(data, "Display data area of MADs (default=0)");

static char * get_class_name(u8 mgmt_class)
{
	switch(mgmt_class) {
	case IB_MGMT_CLASS_SUBN_LID_ROUTED:
		return "LID routed SMP";
	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
		return "Directed route SMP";
	case IB_MGMT_CLASS_SUBN_ADM:
		return "Subnet admin.";
	case IB_MGMT_CLASS_PERF_MGMT:
		return "Perf. mgmt.";
	case IB_MGMT_CLASS_BM:
		return "Baseboard mgmt.";
	case IB_MGMT_CLASS_DEVICE_MGMT:
		return "Device mgmt.";
	case IB_MGMT_CLASS_CM:
		return "Comm. mgmt.";
	case IB_MGMT_CLASS_SNMP:
		return "SNMP";
	default:
		return "Unknown vendor/application";
	}
}

static char * get_method_name(u8 mgmt_class, u8 method)
{
	switch(method) {
	case IB_MGMT_METHOD_GET:
		return "Get";
	case IB_MGMT_METHOD_SET:
		return "Set";
	case IB_MGMT_METHOD_GET_RESP:
		return "Get response";
	case IB_MGMT_METHOD_SEND:
		return "Send";
	case IB_MGMT_METHOD_SEND | IB_MGMT_METHOD_RESP:
		return "Send response";
	case IB_MGMT_METHOD_TRAP:
		return "Trap";
	case IB_MGMT_METHOD_REPORT:
		return "Report";
	case IB_MGMT_METHOD_REPORT_RESP:
		return "Report response";
	case IB_MGMT_METHOD_TRAP_REPRESS:
		return "Trap repress";
	default:
		break;
	}

	switch (mgmt_class) {
	case IB_MGMT_CLASS_SUBN_ADM:
		switch (method) {
		case IB_SA_METHOD_GET_TABLE:
			return "Get table";
		case IB_SA_METHOD_GET_TABLE_RESP:
			return "Get table response";
		case IB_SA_METHOD_DELETE:
			return "Delete";
		case IB_SA_METHOD_DELETE_RESP:
			return "Delete response";
		case IB_SA_METHOD_GET_MULTI:
			return "Get Multi";
		case IB_SA_METHOD_GET_MULTI_RESP:
			return "Get Multi response";
		case IB_SA_METHOD_GET_TRACE_TBL:
			return "Get Trace Table response";
		default:
			break;
		}
	default:
		break;
	}

	return "Unknown";
}

static void print_status_details(u16 status)
{
	if (status & 0x0001)
		printk("               busy\n");
	if (status & 0x0002)
		printk("               redirection required\n");
	switch((status & 0x001C) >> 2) {
	case 1:
		printk("               bad version\n");
		break;
	case 2:
		printk("               method not supported\n");
		break;
	case 3:
		printk("               method/attribute combo not supported\n");
		break;
	case 7:
		printk("               invalid attribute/modifier value\n");
		break;
	}
}

static char * get_sa_attr(__be16 attr)
{
	switch(attr) {
	case IB_SA_ATTR_CLASS_PORTINFO:
		return "Class Port Info";
	case IB_SA_ATTR_NOTICE:
		return "Notice";
	case IB_SA_ATTR_INFORM_INFO:
		return "Inform Info";
	case IB_SA_ATTR_NODE_REC:
		return "Node Record";
	case IB_SA_ATTR_PORT_INFO_REC:
		return "PortInfo Record";
	case IB_SA_ATTR_SL2VL_REC:
		return "SL to VL Record";
	case IB_SA_ATTR_SWITCH_REC:
		return "Switch Record";
	case IB_SA_ATTR_LINEAR_FDB_REC:
		return "Linear FDB Record";
	case IB_SA_ATTR_RANDOM_FDB_REC:
		return "Random FDB Record";
	case IB_SA_ATTR_MCAST_FDB_REC:
		return "Multicast FDB Record";
	case IB_SA_ATTR_SM_INFO_REC:
		return "SM Info Record";
	case IB_SA_ATTR_LINK_REC:
		return "Link Record";
	case IB_SA_ATTR_GUID_INFO_REC:
		return "Guid Info Record";
	case IB_SA_ATTR_SERVICE_REC:
		return "Service Record";
	case IB_SA_ATTR_PARTITION_REC:
		return "Partition Record";
	case IB_SA_ATTR_PATH_REC:
		return "Path Record";
	case IB_SA_ATTR_VL_ARB_REC:
		return "VL Arb Record";
	case IB_SA_ATTR_MC_MEMBER_REC:
		return "MC Member Record";
	case IB_SA_ATTR_TRACE_REC:
		return "Trace Record";
	case IB_SA_ATTR_MULTI_PATH_REC:
		return "Multi Path Record";
	case IB_SA_ATTR_SERVICE_ASSOC_REC:
		return "Service Assoc Record";
	case IB_SA_ATTR_INFORM_INFO_REC:
		return "Inform Info Record";
	default:
		return "";
	}
}

static void print_mad_hdr(struct ib_mad_hdr *mad_hdr)
{
	printk("MAD version....0x%01x\n", mad_hdr->base_version);
	printk("Class..........0x%01x (%s)\n", mad_hdr->mgmt_class,
	       get_class_name(mad_hdr->mgmt_class));
	printk("Class version..0x%01x\n", mad_hdr->class_version);
	printk("Method.........0x%01x (%s)\n", mad_hdr->method,
	       get_method_name(mad_hdr->mgmt_class, mad_hdr->method));
	printk("Status.........0x%02x\n", be16_to_cpu(mad_hdr->status));
	if (mad_hdr->status)
		print_status_details(be16_to_cpu(mad_hdr->status));
	printk("Class specific.0x%02x\n", be16_to_cpu(mad_hdr->class_specific));
	printk("Trans ID.......0x%llx\n", 
		(unsigned long long)be64_to_cpu(mad_hdr->tid));
	if (mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_ADM)
		printk("Attr ID........0x%02x (%s)\n",
		       be16_to_cpu(mad_hdr->attr_id),
		       get_sa_attr(be16_to_cpu(mad_hdr->attr_id)));
	else
		printk("Attr ID........0x%02x\n",
		       be16_to_cpu(mad_hdr->attr_id));
	printk("Attr modifier..0x%04x\n", be32_to_cpu(mad_hdr->attr_mod));
}

static char * get_rmpp_type(u8 rmpp_type)
{
	switch (rmpp_type) {
	case IB_MGMT_RMPP_TYPE_DATA:
		return "Data";
	case IB_MGMT_RMPP_TYPE_ACK:
		return "Ack";
	case IB_MGMT_RMPP_TYPE_STOP:
		return "Stop";
	case IB_MGMT_RMPP_TYPE_ABORT:
		return "Abort";
	default:
		return "Unknown";
	}
}

static char * get_rmpp_flags(u8 rmpp_flags)
{
	if (rmpp_flags & IB_MGMT_RMPP_FLAG_ACTIVE)
		if (rmpp_flags & IB_MGMT_RMPP_FLAG_FIRST)
			if (rmpp_flags & IB_MGMT_RMPP_FLAG_LAST)
				return "Active - First & Last";
			else
				return "Active - First";
		else
			if (rmpp_flags & IB_MGMT_RMPP_FLAG_LAST)
				return "Active - Last";
			else
				return "Active";
	else
		return "Inactive";
}

static void print_rmpp_hdr(struct ib_rmpp_hdr *rmpp_hdr)
{
	printk("RMPP version...0x%01x\n", rmpp_hdr->rmpp_version);
	printk("RMPP type......0x%01x (%s)\n", rmpp_hdr->rmpp_type,
	       get_rmpp_type(rmpp_hdr->rmpp_type));
	printk("RMPP RRespTime.0x%01x\n", ib_get_rmpp_resptime(rmpp_hdr));
	printk("RMPP flags.....0x%01x (%s)\n", ib_get_rmpp_flags(rmpp_hdr),
	       get_rmpp_flags(ib_get_rmpp_flags(rmpp_hdr)));
	printk("RMPP status....0x%01x\n", rmpp_hdr->rmpp_status);
	printk("Seg number.....0x%04x\n", be32_to_cpu(rmpp_hdr->seg_num));
	switch (rmpp_hdr->rmpp_type) {
	case IB_MGMT_RMPP_TYPE_DATA:
		printk("Payload len....0x%04x\n",
		       be32_to_cpu(rmpp_hdr->paylen_newwin));
		break;
	case IB_MGMT_RMPP_TYPE_ACK:
		printk("New window.....0x%04x\n",
		       be32_to_cpu(rmpp_hdr->paylen_newwin));
		break;
	default:
		printk("Data 2.........0x%04x\n",
		       be32_to_cpu(rmpp_hdr->paylen_newwin));
		break;
	}
}

static char * get_smp_attr(__be16 attr)
{
	switch (attr) {
	case IB_SMP_ATTR_NOTICE:
		return "notice";
	case IB_SMP_ATTR_NODE_DESC:
		return "node description";
	case IB_SMP_ATTR_NODE_INFO:
		return "node info";
	case IB_SMP_ATTR_SWITCH_INFO:
		return "switch info";
	case IB_SMP_ATTR_GUID_INFO:
		return "GUID info";
	case IB_SMP_ATTR_PORT_INFO:
		return "port info";
	case IB_SMP_ATTR_PKEY_TABLE:
		return "pkey table";
	case IB_SMP_ATTR_SL_TO_VL_TABLE:
		return "SL to VL table";
	case IB_SMP_ATTR_VL_ARB_TABLE:
		return "VL arbitration table";
	case IB_SMP_ATTR_LINEAR_FORWARD_TABLE:
		return "linear forwarding table";
	case IB_SMP_ATTR_RANDOM_FORWARD_TABLE:
		return "random forward table";
	case IB_SMP_ATTR_MCAST_FORWARD_TABLE:
		return "multicast forward table";
	case IB_SMP_ATTR_SM_INFO:
		return "SM info";
	case IB_SMP_ATTR_VENDOR_DIAG:
		return "vendor diags";
	case IB_SMP_ATTR_LED_INFO:
		return "LED info";
	default:
		return "";
	}
}

static void print_smp(struct ib_smp *smp)
{
	int i;

	printk("MAD version....0x%01x\n", smp->base_version);
	printk("Class..........0x%01x (%s)\n", smp->mgmt_class,
	       get_class_name(smp->mgmt_class));
	printk("Class version..0x%01x\n", smp->class_version);
	printk("Method.........0x%01x (%s)\n", smp->method,
	       get_method_name(smp->mgmt_class, smp->method));
	printk("Status.........0x%02x\n", be16_to_cpu(smp->status));
	if (smp->status)
		print_status_details(be16_to_cpu(smp->status));
	printk("Hop pointer....0x%01x\n", smp->hop_ptr);
	printk("Hop counter....0x%01x\n", smp->hop_cnt);
	printk("Trans ID.......0x%llx\n", 
		(unsigned long long)be64_to_cpu(smp->tid));
	printk("Attr ID........0x%02x (%s)\n", be16_to_cpu(smp->attr_id),
		get_smp_attr(smp->attr_id));
	printk("Attr modifier..0x%04x\n", be32_to_cpu(smp->attr_mod));

	printk("Mkey...........0x%llx\n",
		(unsigned long long)be64_to_cpu(smp->mkey));
	printk("DR SLID........0x%02x\n", be16_to_cpu(smp->dr_slid));
	printk("DR DLID........0x%02x", be16_to_cpu(smp->dr_dlid));

	if (data) {
		for (i = 0; i < IB_SMP_DATA_SIZE; i++) {
			if (i % 16 == 0)
				printk("\nSMP Data.......");
			printk("%01x ", smp->data[i]);
		}
		for (i = 0; i < IB_SMP_MAX_PATH_HOPS; i++) {
			if (i % 16 == 0)
				printk("\nInitial path...");
			printk("%01x ", smp->initial_path[i]);
		}
		for (i = 0; i < IB_SMP_MAX_PATH_HOPS; i++) {
			if (i % 16 == 0)
				printk("\nReturn path....");
			printk("%01x ", smp->return_path[i]);
		}
	}
	printk("\n");
}

static void snoop_smi_handler(struct ib_mad_agent *mad_agent,
			      struct ib_mad_send_buf *send_buf,
			      struct ib_mad_send_wc *mad_send_wc)
{
	struct ib_mad_hdr *hdr = send_buf->mad;

	if (!smp && hdr->mgmt_class != mgmt_class)
		return;
	if (attr_id && be16_to_cpu(hdr->attr_id) != attr_id)
		return;

	printk("Madeye:sent SMP\n");
	print_smp(send_buf->mad);
}

static void recv_smi_handler(struct ib_mad_agent *mad_agent,
			     struct ib_mad_recv_wc *mad_recv_wc)
{
	if (!smp && mad_recv_wc->recv_buf.mad->mad_hdr.mgmt_class != mgmt_class)
		return;
	if (attr_id && be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id) != attr_id)
		return;

	printk("Madeye:recv SMP\n");
	print_smp((struct ib_smp *)&mad_recv_wc->recv_buf.mad->mad_hdr);
}

static int is_rmpp_mad(struct ib_mad_hdr *mad_hdr)
{
	if (mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
		switch (mad_hdr->method) {
		case IB_SA_METHOD_GET_TABLE:
		case IB_SA_METHOD_GET_TABLE_RESP:
		case IB_SA_METHOD_GET_MULTI_RESP:
			return 1;
		default:
			break;
		}
	} else if ((mad_hdr->mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
		   (mad_hdr->mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END))
		return 1;

	return 0;
}

static void snoop_gsi_handler(struct ib_mad_agent *mad_agent,
			      struct ib_mad_send_buf *send_buf,
			      struct ib_mad_send_wc *mad_send_wc)
{
	struct ib_mad_hdr *hdr = send_buf->mad;

	if (!gmp && hdr->mgmt_class != mgmt_class)
		return;
	if (attr_id && be16_to_cpu(hdr->attr_id) != attr_id)
		return;

	printk("Madeye:sent GMP\n");
	print_mad_hdr(hdr);

	if (is_rmpp_mad(hdr))
		print_rmpp_hdr(&((struct ib_rmpp_mad *) hdr)->rmpp_hdr);
}

static void recv_gsi_handler(struct ib_mad_agent *mad_agent,
			     struct ib_mad_recv_wc *mad_recv_wc)
{
	struct ib_mad_hdr *hdr = &mad_recv_wc->recv_buf.mad->mad_hdr;
	struct ib_rmpp_mad *mad = NULL;
	struct ib_sa_mad *sa_mad;
	struct ib_vendor_mad *vendor_mad;
	u8 *mad_data;
	int i, j;

	if (!gmp && hdr->mgmt_class != mgmt_class)
		return;
	if (attr_id && be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id) != attr_id)
		return;

	printk("Madeye:recv GMP\n");
	print_mad_hdr(hdr);

	if (is_rmpp_mad(hdr)) {
		mad = (struct ib_rmpp_mad *) hdr;
		print_rmpp_hdr(&mad->rmpp_hdr);
	}

	if (data) {
		if (hdr->mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
			j = IB_MGMT_SA_DATA;
			/* Display SA header */
			if (is_rmpp_mad(hdr) &&
			    mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_DATA)
				return;
			sa_mad = (struct ib_sa_mad *)
				 &mad_recv_wc->recv_buf.mad;
			mad_data = sa_mad->data;
		} else {
			if (is_rmpp_mad(hdr)) {
				j = IB_MGMT_VENDOR_DATA;
				/* Display OUI */
				vendor_mad = (struct ib_vendor_mad *)
					     &mad_recv_wc->recv_buf.mad;
				printk("Vendor OUI......%01x %01x %01x\n",
					vendor_mad->oui[0],
					vendor_mad->oui[1],
					vendor_mad->oui[2]);
				mad_data = vendor_mad->data;
			} else {
				j = IB_MGMT_MAD_DATA;
				mad_data = mad_recv_wc->recv_buf.mad->data;
			}
		}
		for (i = 0; i < j; i++) {
			if (i % 16 == 0)
				printk("\nData...........");
			printk("%01x ", mad_data[i]);
		}
		printk("\n");
	}
}

static void madeye_add_one(struct ib_device *device)
{
	struct madeye_port *port;
	int reg_flags;
	u8 i, s, e;

	if (device->node_type == RDMA_NODE_IB_SWITCH) {
		s = 0;
		e = 0;
	} else {
		s = 1;
		e = device->phys_port_cnt;
	}

	port = kmalloc(sizeof *port * (e - s + 1), GFP_KERNEL);
	if (!port)
		goto out;

	reg_flags = IB_MAD_SNOOP_SEND_COMPLETIONS | IB_MAD_SNOOP_RECVS;
	for (i = 0; i <= e - s; i++) {
		port[i].smi_agent = ib_register_mad_snoop(device, i + s,
							  IB_QPT_SMI,
							  reg_flags,
							  snoop_smi_handler,
							  recv_smi_handler,
							  &port[i]);
		port[i].gsi_agent = ib_register_mad_snoop(device, i + s,
							  IB_QPT_GSI,
							  reg_flags,
							  snoop_gsi_handler,
							  recv_gsi_handler,
							  &port[i]);
	}

out:
	ib_set_client_data(device, &madeye_client, port);
}

static void madeye_remove_one(struct ib_device *device)
{
	struct madeye_port *port;
	int i, s, e;

	port = (struct madeye_port *)
		ib_get_client_data(device, &madeye_client);
	if (!port)
		return;

	if (device->node_type == RDMA_NODE_IB_SWITCH) {
		s = 0;
		e = 0;
	} else {
		s = 1;
		e = device->phys_port_cnt;
	}

	for (i = 0; i <= e - s; i++) {
		if (!IS_ERR(port[i].smi_agent))
			ib_unregister_mad_agent(port[i].smi_agent);
		if (!IS_ERR(port[i].gsi_agent))
			ib_unregister_mad_agent(port[i].gsi_agent);
	}
	kfree(port);
}

static int __init ib_madeye_init(void)
{
	return ib_register_client(&madeye_client);
}

static void __exit ib_madeye_cleanup(void)
{
	ib_unregister_client(&madeye_client);
}

module_init(ib_madeye_init);
module_exit(ib_madeye_cleanup);