d97f69191838239ad8132b5ab1c81b596e561fe0
[linux-flexiantxendom0-natty.git] / drivers / scsi / bfa / bfad_attr.c
1 /*
2  * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3  * All rights reserved
4  * www.brocade.com
5  *
6  * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License (GPL) Version 2 as
10  * published by the Free Software Foundation
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  */
17
18 /**
19  *  bfa_attr.c Linux driver configuration interface module.
20  */
21
22 #include "bfad_drv.h"
23 #include "bfad_im.h"
24 #include "bfad_trcmod.h"
25 #include "bfad_attr.h"
26
27 /**
28  *  FC_transport_template FC transport template
29  */
30
31 /**
32  * FC transport template entry, get SCSI target port ID.
33  */
34 void
35 bfad_im_get_starget_port_id(struct scsi_target *starget)
36 {
37         struct Scsi_Host *shost;
38         struct bfad_im_port_s *im_port;
39         struct bfad_s         *bfad;
40         struct bfad_itnim_s   *itnim = NULL;
41         u32        fc_id = -1;
42         unsigned long   flags;
43
44         shost = bfad_os_starget_to_shost(starget);
45         im_port = (struct bfad_im_port_s *) shost->hostdata[0];
46         bfad = im_port->bfad;
47         spin_lock_irqsave(&bfad->bfad_lock, flags);
48
49         itnim = bfad_os_get_itnim(im_port, starget->id);
50         if (itnim)
51                 fc_id = bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim);
52
53         fc_starget_port_id(starget) = fc_id;
54         spin_unlock_irqrestore(&bfad->bfad_lock, flags);
55 }
56
57 /**
58  * FC transport template entry, get SCSI target nwwn.
59  */
60 void
61 bfad_im_get_starget_node_name(struct scsi_target *starget)
62 {
63         struct Scsi_Host *shost;
64         struct bfad_im_port_s *im_port;
65         struct bfad_s         *bfad;
66         struct bfad_itnim_s   *itnim = NULL;
67         u64             node_name = 0;
68         unsigned long   flags;
69
70         shost = bfad_os_starget_to_shost(starget);
71         im_port = (struct bfad_im_port_s *) shost->hostdata[0];
72         bfad = im_port->bfad;
73         spin_lock_irqsave(&bfad->bfad_lock, flags);
74
75         itnim = bfad_os_get_itnim(im_port, starget->id);
76         if (itnim)
77                 node_name = bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim);
78
79         fc_starget_node_name(starget) = bfa_os_htonll(node_name);
80         spin_unlock_irqrestore(&bfad->bfad_lock, flags);
81 }
82
83 /**
84  * FC transport template entry, get SCSI target pwwn.
85  */
86 void
87 bfad_im_get_starget_port_name(struct scsi_target *starget)
88 {
89         struct Scsi_Host *shost;
90         struct bfad_im_port_s *im_port;
91         struct bfad_s         *bfad;
92         struct bfad_itnim_s   *itnim = NULL;
93         u64             port_name = 0;
94         unsigned long   flags;
95
96         shost = bfad_os_starget_to_shost(starget);
97         im_port = (struct bfad_im_port_s *) shost->hostdata[0];
98         bfad = im_port->bfad;
99         spin_lock_irqsave(&bfad->bfad_lock, flags);
100
101         itnim = bfad_os_get_itnim(im_port, starget->id);
102         if (itnim)
103                 port_name = bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim);
104
105         fc_starget_port_name(starget) = bfa_os_htonll(port_name);
106         spin_unlock_irqrestore(&bfad->bfad_lock, flags);
107 }
108
109 /**
110  * FC transport template entry, get SCSI host port ID.
111  */
112 void
113 bfad_im_get_host_port_id(struct Scsi_Host *shost)
114 {
115         struct bfad_im_port_s *im_port =
116                         (struct bfad_im_port_s *) shost->hostdata[0];
117         struct bfad_port_s    *port = im_port->port;
118
119         fc_host_port_id(shost) =
120                         bfa_os_hton3b(bfa_fcs_port_get_fcid(port->fcs_port));
121 }
122
123
124
125
126
127 struct Scsi_Host *
128 bfad_os_starget_to_shost(struct scsi_target *starget)
129 {
130         return dev_to_shost(starget->dev.parent);
131 }
132
133 /**
134  * FC transport template entry, get SCSI host port type.
135  */
136 static void
137 bfad_im_get_host_port_type(struct Scsi_Host *shost)
138 {
139         struct bfad_im_port_s *im_port =
140                         (struct bfad_im_port_s *) shost->hostdata[0];
141         struct bfad_s         *bfad = im_port->bfad;
142         struct bfa_pport_attr_s attr;
143
144         bfa_fcport_get_attr(&bfad->bfa, &attr);
145
146         switch (attr.port_type) {
147         case BFA_PPORT_TYPE_NPORT:
148                 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
149                 break;
150         case BFA_PPORT_TYPE_NLPORT:
151                 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
152                 break;
153         case BFA_PPORT_TYPE_P2P:
154                 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
155                 break;
156         case BFA_PPORT_TYPE_LPORT:
157                 fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
158                 break;
159         default:
160                 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
161                 break;
162         }
163 }
164
165 /**
166  * FC transport template entry, get SCSI host port state.
167  */
168 static void
169 bfad_im_get_host_port_state(struct Scsi_Host *shost)
170 {
171         struct bfad_im_port_s *im_port =
172                         (struct bfad_im_port_s *) shost->hostdata[0];
173         struct bfad_s         *bfad = im_port->bfad;
174         struct bfa_pport_attr_s attr;
175
176         bfa_fcport_get_attr(&bfad->bfa, &attr);
177
178         switch (attr.port_state) {
179         case BFA_PPORT_ST_LINKDOWN:
180                 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
181                 break;
182         case BFA_PPORT_ST_LINKUP:
183                 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
184                 break;
185         case BFA_PPORT_ST_UNINIT:
186         case BFA_PPORT_ST_ENABLING_QWAIT:
187         case BFA_PPORT_ST_ENABLING:
188         case BFA_PPORT_ST_DISABLING_QWAIT:
189         case BFA_PPORT_ST_DISABLING:
190         case BFA_PPORT_ST_DISABLED:
191         case BFA_PPORT_ST_STOPPED:
192         case BFA_PPORT_ST_IOCDOWN:
193         default:
194                 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
195                 break;
196         }
197 }
198
199 /**
200  * FC transport template entry, get SCSI host active fc4s.
201  */
202 static void
203 bfad_im_get_host_active_fc4s(struct Scsi_Host *shost)
204 {
205         struct bfad_im_port_s *im_port =
206                         (struct bfad_im_port_s *) shost->hostdata[0];
207         struct bfad_port_s    *port = im_port->port;
208
209         memset(fc_host_active_fc4s(shost), 0,
210                sizeof(fc_host_active_fc4s(shost)));
211
212         if (port->supported_fc4s &
213                 (BFA_PORT_ROLE_FCP_IM | BFA_PORT_ROLE_FCP_TM))
214                 fc_host_active_fc4s(shost)[2] = 1;
215
216         if (port->supported_fc4s & BFA_PORT_ROLE_FCP_IPFC)
217                 fc_host_active_fc4s(shost)[3] = 0x20;
218
219         fc_host_active_fc4s(shost)[7] = 1;
220 }
221
222 /**
223  * FC transport template entry, get SCSI host link speed.
224  */
225 static void
226 bfad_im_get_host_speed(struct Scsi_Host *shost)
227 {
228         struct bfad_im_port_s *im_port =
229                         (struct bfad_im_port_s *) shost->hostdata[0];
230         struct bfad_s         *bfad = im_port->bfad;
231         struct bfa_pport_attr_s attr;
232         unsigned long   flags;
233
234         spin_lock_irqsave(shost->host_lock, flags);
235         bfa_fcport_get_attr(&bfad->bfa, &attr);
236         switch (attr.speed) {
237         case BFA_PPORT_SPEED_8GBPS:
238                 fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
239                 break;
240         case BFA_PPORT_SPEED_4GBPS:
241                 fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
242                 break;
243         case BFA_PPORT_SPEED_2GBPS:
244                 fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
245                 break;
246         case BFA_PPORT_SPEED_1GBPS:
247                 fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
248                 break;
249         default:
250                 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
251                 break;
252         }
253         spin_unlock_irqrestore(shost->host_lock, flags);
254 }
255
256 /**
257  * FC transport template entry, get SCSI host port type.
258  */
259 static void
260 bfad_im_get_host_fabric_name(struct Scsi_Host *shost)
261 {
262         struct bfad_im_port_s *im_port =
263                         (struct bfad_im_port_s *) shost->hostdata[0];
264         struct bfad_port_s    *port = im_port->port;
265         wwn_t           fabric_nwwn = 0;
266
267         fabric_nwwn = bfa_fcs_port_get_fabric_name(port->fcs_port);
268
269         fc_host_fabric_name(shost) = bfa_os_htonll(fabric_nwwn);
270
271 }
272
273 /**
274  * FC transport template entry, get BFAD statistics.
275  */
276 static struct fc_host_statistics *
277 bfad_im_get_stats(struct Scsi_Host *shost)
278 {
279         struct bfad_im_port_s *im_port =
280                         (struct bfad_im_port_s *) shost->hostdata[0];
281         struct bfad_s         *bfad = im_port->bfad;
282         struct bfad_hal_comp fcomp;
283         struct fc_host_statistics *hstats;
284         bfa_status_t    rc;
285         unsigned long   flags;
286
287         hstats = &bfad->link_stats;
288         init_completion(&fcomp.comp);
289         spin_lock_irqsave(&bfad->bfad_lock, flags);
290         memset(hstats, 0, sizeof(struct fc_host_statistics));
291         rc =  bfa_port_get_stats(BFA_FCPORT(&bfad->bfa),
292                                      (union bfa_pport_stats_u *) hstats,
293                                      bfad_hcb_comp, &fcomp);
294         spin_unlock_irqrestore(&bfad->bfad_lock, flags);
295         if (rc != BFA_STATUS_OK)
296                 return NULL;
297
298         wait_for_completion(&fcomp.comp);
299
300         return hstats;
301 }
302
303 /**
304  * FC transport template entry, reset BFAD statistics.
305  */
306 static void
307 bfad_im_reset_stats(struct Scsi_Host *shost)
308 {
309         struct bfad_im_port_s *im_port =
310                         (struct bfad_im_port_s *) shost->hostdata[0];
311         struct bfad_s         *bfad = im_port->bfad;
312         struct bfad_hal_comp fcomp;
313         unsigned long   flags;
314         bfa_status_t    rc;
315
316         init_completion(&fcomp.comp);
317         spin_lock_irqsave(&bfad->bfad_lock, flags);
318         rc = bfa_port_clear_stats(BFA_FCPORT(&bfad->bfa), bfad_hcb_comp,
319                 &fcomp);
320         spin_unlock_irqrestore(&bfad->bfad_lock, flags);
321
322         if (rc != BFA_STATUS_OK)
323                 return;
324
325         wait_for_completion(&fcomp.comp);
326
327         return;
328 }
329
330 /**
331  * FC transport template entry, get rport loss timeout.
332  */
333 static void
334 bfad_im_get_rport_loss_tmo(struct fc_rport *rport)
335 {
336         struct bfad_itnim_data_s *itnim_data = rport->dd_data;
337         struct bfad_itnim_s   *itnim = itnim_data->itnim;
338         struct bfad_s         *bfad = itnim->im->bfad;
339         unsigned long   flags;
340
341         spin_lock_irqsave(&bfad->bfad_lock, flags);
342         rport->dev_loss_tmo = bfa_fcpim_path_tov_get(&bfad->bfa);
343         spin_unlock_irqrestore(&bfad->bfad_lock, flags);
344 }
345
346 /**
347  * FC transport template entry, set rport loss timeout.
348  */
349 static void
350 bfad_im_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout)
351 {
352         struct bfad_itnim_data_s *itnim_data = rport->dd_data;
353         struct bfad_itnim_s   *itnim = itnim_data->itnim;
354         struct bfad_s         *bfad = itnim->im->bfad;
355         unsigned long   flags;
356
357         if (timeout > 0) {
358                 spin_lock_irqsave(&bfad->bfad_lock, flags);
359                 bfa_fcpim_path_tov_set(&bfad->bfa, timeout);
360                 rport->dev_loss_tmo = bfa_fcpim_path_tov_get(&bfad->bfa);
361                 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
362         }
363
364 }
365
366 struct fc_function_template bfad_im_fc_function_template = {
367
368         /* Target dynamic attributes */
369         .get_starget_port_id = bfad_im_get_starget_port_id,
370         .show_starget_port_id = 1,
371         .get_starget_node_name = bfad_im_get_starget_node_name,
372         .show_starget_node_name = 1,
373         .get_starget_port_name = bfad_im_get_starget_port_name,
374         .show_starget_port_name = 1,
375
376         /* Host dynamic attribute */
377         .get_host_port_id = bfad_im_get_host_port_id,
378         .show_host_port_id = 1,
379
380         /* Host fixed attributes */
381         .show_host_node_name = 1,
382         .show_host_port_name = 1,
383         .show_host_supported_classes = 1,
384         .show_host_supported_fc4s = 1,
385         .show_host_supported_speeds = 1,
386         .show_host_maxframe_size = 1,
387
388         /* More host dynamic attributes */
389         .show_host_port_type = 1,
390         .get_host_port_type = bfad_im_get_host_port_type,
391         .show_host_port_state = 1,
392         .get_host_port_state = bfad_im_get_host_port_state,
393         .show_host_active_fc4s = 1,
394         .get_host_active_fc4s = bfad_im_get_host_active_fc4s,
395         .show_host_speed = 1,
396         .get_host_speed = bfad_im_get_host_speed,
397         .show_host_fabric_name = 1,
398         .get_host_fabric_name = bfad_im_get_host_fabric_name,
399
400         .show_host_symbolic_name = 1,
401
402         /* Statistics */
403         .get_fc_host_stats = bfad_im_get_stats,
404         .reset_fc_host_stats = bfad_im_reset_stats,
405
406         /* Allocation length for host specific data */
407         .dd_fcrport_size = sizeof(struct bfad_itnim_data_s *),
408
409         /* Remote port fixed attributes */
410         .show_rport_maxframe_size = 1,
411         .show_rport_supported_classes = 1,
412         .show_rport_dev_loss_tmo = 1,
413         .get_rport_dev_loss_tmo = bfad_im_get_rport_loss_tmo,
414         .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
415 };
416
417 /**
418  *  Scsi_Host_attrs SCSI host attributes
419  */
420 static ssize_t
421 bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,
422                          char *buf)
423 {
424         struct Scsi_Host *shost = class_to_shost(dev);
425         struct bfad_im_port_s *im_port =
426                         (struct bfad_im_port_s *) shost->hostdata[0];
427         struct bfad_s         *bfad = im_port->bfad;
428         char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
429
430         bfa_get_adapter_serial_num(&bfad->bfa, serial_num);
431         return snprintf(buf, PAGE_SIZE, "%s\n", serial_num);
432 }
433
434 static ssize_t
435 bfad_im_model_show(struct device *dev, struct device_attribute *attr,
436                         char *buf)
437 {
438         struct Scsi_Host *shost = class_to_shost(dev);
439         struct bfad_im_port_s *im_port =
440                         (struct bfad_im_port_s *) shost->hostdata[0];
441         struct bfad_s         *bfad = im_port->bfad;
442         char model[BFA_ADAPTER_MODEL_NAME_LEN];
443
444         bfa_get_adapter_model(&bfad->bfa, model);
445         return snprintf(buf, PAGE_SIZE, "%s\n", model);
446 }
447
448 static ssize_t
449 bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,
450                                  char *buf)
451 {
452         struct Scsi_Host *shost = class_to_shost(dev);
453         struct bfad_im_port_s *im_port =
454                         (struct bfad_im_port_s *) shost->hostdata[0];
455         struct bfad_s         *bfad = im_port->bfad;
456         char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
457
458         bfa_get_adapter_model(&bfad->bfa, model_descr);
459         return snprintf(buf, PAGE_SIZE, "%s\n", model_descr);
460 }
461
462 static ssize_t
463 bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,
464                                  char *buf)
465 {
466         struct Scsi_Host *shost = class_to_shost(dev);
467         struct bfad_im_port_s *im_port =
468                         (struct bfad_im_port_s *) shost->hostdata[0];
469         struct bfad_port_s    *port = im_port->port;
470         u64        nwwn;
471
472         nwwn = bfa_fcs_port_get_nwwn(port->fcs_port);
473         return snprintf(buf, PAGE_SIZE, "0x%llx\n", bfa_os_htonll(nwwn));
474 }
475
476 static ssize_t
477 bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
478                                  char *buf)
479 {
480         struct Scsi_Host *shost = class_to_shost(dev);
481         struct bfad_im_port_s *im_port =
482                         (struct bfad_im_port_s *) shost->hostdata[0];
483         struct bfad_s         *bfad = im_port->bfad;
484         char model[BFA_ADAPTER_MODEL_NAME_LEN];
485         char fw_ver[BFA_VERSION_LEN];
486
487         bfa_get_adapter_model(&bfad->bfa, model);
488         bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver);
489         return snprintf(buf, PAGE_SIZE, "Brocade %s FV%s DV%s\n",
490                 model, fw_ver, BFAD_DRIVER_VERSION);
491 }
492
493 static ssize_t
494 bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,
495                                 char *buf)
496 {
497         struct Scsi_Host *shost = class_to_shost(dev);
498         struct bfad_im_port_s *im_port =
499                         (struct bfad_im_port_s *) shost->hostdata[0];
500         struct bfad_s         *bfad = im_port->bfad;
501         char hw_ver[BFA_VERSION_LEN];
502
503         bfa_get_pci_chip_rev(&bfad->bfa, hw_ver);
504         return snprintf(buf, PAGE_SIZE, "%s\n", hw_ver);
505 }
506
507 static ssize_t
508 bfad_im_drv_version_show(struct device *dev, struct device_attribute *attr,
509                                 char *buf)
510 {
511         return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_VERSION);
512 }
513
514 static ssize_t
515 bfad_im_optionrom_version_show(struct device *dev,
516                          struct device_attribute *attr, char *buf)
517 {
518         struct Scsi_Host *shost = class_to_shost(dev);
519         struct bfad_im_port_s *im_port =
520                         (struct bfad_im_port_s *) shost->hostdata[0];
521         struct bfad_s         *bfad = im_port->bfad;
522         char optrom_ver[BFA_VERSION_LEN];
523
524         bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver);
525         return snprintf(buf, PAGE_SIZE, "%s\n", optrom_ver);
526 }
527
528 static ssize_t
529 bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,
530                                  char *buf)
531 {
532         struct Scsi_Host *shost = class_to_shost(dev);
533         struct bfad_im_port_s *im_port =
534                         (struct bfad_im_port_s *) shost->hostdata[0];
535         struct bfad_s         *bfad = im_port->bfad;
536         char fw_ver[BFA_VERSION_LEN];
537
538         bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver);
539         return snprintf(buf, PAGE_SIZE, "%s\n", fw_ver);
540 }
541
542 static ssize_t
543 bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr,
544                                 char *buf)
545 {
546         struct Scsi_Host *shost = class_to_shost(dev);
547         struct bfad_im_port_s *im_port =
548                         (struct bfad_im_port_s *) shost->hostdata[0];
549         struct bfad_s         *bfad = im_port->bfad;
550
551         return snprintf(buf, PAGE_SIZE, "%d\n",
552                 bfa_get_nports(&bfad->bfa));
553 }
554
555 static ssize_t
556 bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr,
557                                 char *buf)
558 {
559         return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_NAME);
560 }
561
562 static ssize_t
563 bfad_im_num_of_discovered_ports_show(struct device *dev,
564                         struct device_attribute *attr, char *buf)
565 {
566         struct Scsi_Host *shost = class_to_shost(dev);
567         struct bfad_im_port_s *im_port =
568                         (struct bfad_im_port_s *) shost->hostdata[0];
569         struct bfad_port_s    *port = im_port->port;
570         struct bfad_s         *bfad = im_port->bfad;
571         int        nrports = 2048;
572         wwn_t          *rports = NULL;
573         unsigned long   flags;
574
575         rports = kzalloc(sizeof(wwn_t) * nrports , GFP_ATOMIC);
576         if (rports == NULL)
577                 return -ENOMEM;
578
579         spin_lock_irqsave(&bfad->bfad_lock, flags);
580         bfa_fcs_port_get_rports(port->fcs_port, rports, &nrports);
581         spin_unlock_irqrestore(&bfad->bfad_lock, flags);
582         kfree(rports);
583
584         return snprintf(buf, PAGE_SIZE, "%d\n", nrports);
585 }
586
587 static          DEVICE_ATTR(serial_number, S_IRUGO,
588                                 bfad_im_serial_num_show, NULL);
589 static          DEVICE_ATTR(model, S_IRUGO, bfad_im_model_show, NULL);
590 static          DEVICE_ATTR(model_description, S_IRUGO,
591                                 bfad_im_model_desc_show, NULL);
592 static          DEVICE_ATTR(node_name, S_IRUGO, bfad_im_node_name_show, NULL);
593 static          DEVICE_ATTR(symbolic_name, S_IRUGO,
594                                 bfad_im_symbolic_name_show, NULL);
595 static          DEVICE_ATTR(hardware_version, S_IRUGO,
596                                 bfad_im_hw_version_show, NULL);
597 static          DEVICE_ATTR(driver_version, S_IRUGO,
598                                 bfad_im_drv_version_show, NULL);
599 static          DEVICE_ATTR(option_rom_version, S_IRUGO,
600                                 bfad_im_optionrom_version_show, NULL);
601 static          DEVICE_ATTR(firmware_version, S_IRUGO,
602                                 bfad_im_fw_version_show, NULL);
603 static          DEVICE_ATTR(number_of_ports, S_IRUGO,
604                                 bfad_im_num_of_ports_show, NULL);
605 static          DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL);
606 static          DEVICE_ATTR(number_of_discovered_ports, S_IRUGO,
607                                 bfad_im_num_of_discovered_ports_show, NULL);
608
609 struct device_attribute *bfad_im_host_attrs[] = {
610         &dev_attr_serial_number,
611         &dev_attr_model,
612         &dev_attr_model_description,
613         &dev_attr_node_name,
614         &dev_attr_symbolic_name,
615         &dev_attr_hardware_version,
616         &dev_attr_driver_version,
617         &dev_attr_option_rom_version,
618         &dev_attr_firmware_version,
619         &dev_attr_number_of_ports,
620         &dev_attr_driver_name,
621         &dev_attr_number_of_discovered_ports,
622         NULL,
623 };
624
625 struct device_attribute *bfad_im_vport_attrs[] = {
626     &dev_attr_serial_number,
627     &dev_attr_model,
628     &dev_attr_model_description,
629     &dev_attr_node_name,
630     &dev_attr_symbolic_name,
631     &dev_attr_hardware_version,
632     &dev_attr_driver_version,
633     &dev_attr_option_rom_version,
634     &dev_attr_firmware_version,
635     &dev_attr_number_of_ports,
636     &dev_attr_driver_name,
637     &dev_attr_number_of_discovered_ports,
638     NULL,
639 };
640
641