1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2012 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
9 * This program is free software; you can redistribute it and/or *
10 * modify it under the terms of version 2 of the GNU General *
11 * Public License as published by the Free Software Foundation. *
12 * This program is distributed in the hope that it will be useful. *
13 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
14 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
15 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
16 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
17 * TO BE LEGALLY INVALID. See the GNU General Public License for *
18 * more details, a copy of which can be found in the file COPYING *
19 * included with this package. *
20 *******************************************************************/
22 #include <linux/ctype.h>
23 #include <linux/delay.h>
24 #include <linux/pci.h>
25 #include <linux/interrupt.h>
26 #include <linux/module.h>
27 #include <linux/aer.h>
28 #include <linux/gfp.h>
29 #include <linux/kernel.h>
31 #include <scsi/scsi.h>
32 #include <scsi/scsi_device.h>
33 #include <scsi/scsi_host.h>
34 #include <scsi/scsi_tcq.h>
35 #include <scsi/scsi_transport_fc.h>
36 #include <scsi/fc/fc_fs.h>
41 #include "lpfc_sli4.h"
43 #include "lpfc_disc.h"
44 #include "lpfc_scsi.h"
46 #include "lpfc_logmsg.h"
47 #include "lpfc_version.h"
48 #include "lpfc_compat.h"
49 #include "lpfc_crtn.h"
50 #include "lpfc_vport.h"
52 #define LPFC_DEF_DEVLOSS_TMO 30
53 #define LPFC_MIN_DEVLOSS_TMO 1
54 #define LPFC_MAX_DEVLOSS_TMO 255
57 * Write key size should be multiple of 4. If write key is changed
58 * make sure that library write key is also changed.
60 #define LPFC_REG_WRITE_KEY_SIZE 4
61 #define LPFC_REG_WRITE_KEY "EMLX"
64 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
65 * @incr: integer to convert.
66 * @hdw: ascii string holding converted integer plus a string terminator.
69 * JEDEC Joint Electron Device Engineering Council.
70 * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii
71 * character string. The string is then terminated with a NULL in byte 9.
72 * Hex 0-9 becomes ascii '0' to '9'.
73 * Hex a-f becomes ascii '=' to 'B' capital B.
76 * Coded for 32 bit integers only.
79 lpfc_jedec_to_ascii(int incr
, char hdw
[])
82 for (i
= 0; i
< 8; i
++) {
85 hdw
[7 - i
] = 0x30 + j
;
87 hdw
[7 - i
] = 0x61 + j
- 10;
95 * lpfc_drvr_version_show - Return the Emulex driver string with version number
96 * @dev: class unused variable.
97 * @attr: device attribute, not used.
98 * @buf: on return contains the module description text.
100 * Returns: size of formatted string.
103 lpfc_drvr_version_show(struct device
*dev
, struct device_attribute
*attr
,
106 return snprintf(buf
, PAGE_SIZE
, LPFC_MODULE_DESC
"\n");
110 * lpfc_enable_fip_show - Return the fip mode of the HBA
111 * @dev: class unused variable.
112 * @attr: device attribute, not used.
113 * @buf: on return contains the module description text.
115 * Returns: size of formatted string.
118 lpfc_enable_fip_show(struct device
*dev
, struct device_attribute
*attr
,
121 struct Scsi_Host
*shost
= class_to_shost(dev
);
122 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
123 struct lpfc_hba
*phba
= vport
->phba
;
125 if (phba
->hba_flag
& HBA_FIP_SUPPORT
)
126 return snprintf(buf
, PAGE_SIZE
, "1\n");
128 return snprintf(buf
, PAGE_SIZE
, "0\n");
132 lpfc_bg_info_show(struct device
*dev
, struct device_attribute
*attr
,
135 struct Scsi_Host
*shost
= class_to_shost(dev
);
136 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
137 struct lpfc_hba
*phba
= vport
->phba
;
139 if (phba
->cfg_enable_bg
)
140 if (phba
->sli3_options
& LPFC_SLI3_BG_ENABLED
)
141 return snprintf(buf
, PAGE_SIZE
, "BlockGuard Enabled\n");
143 return snprintf(buf
, PAGE_SIZE
,
144 "BlockGuard Not Supported\n");
146 return snprintf(buf
, PAGE_SIZE
,
147 "BlockGuard Disabled\n");
151 lpfc_bg_guard_err_show(struct device
*dev
, struct device_attribute
*attr
,
154 struct Scsi_Host
*shost
= class_to_shost(dev
);
155 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
156 struct lpfc_hba
*phba
= vport
->phba
;
158 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
159 (unsigned long long)phba
->bg_guard_err_cnt
);
163 lpfc_bg_apptag_err_show(struct device
*dev
, struct device_attribute
*attr
,
166 struct Scsi_Host
*shost
= class_to_shost(dev
);
167 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
168 struct lpfc_hba
*phba
= vport
->phba
;
170 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
171 (unsigned long long)phba
->bg_apptag_err_cnt
);
175 lpfc_bg_reftag_err_show(struct device
*dev
, struct device_attribute
*attr
,
178 struct Scsi_Host
*shost
= class_to_shost(dev
);
179 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
180 struct lpfc_hba
*phba
= vport
->phba
;
182 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
183 (unsigned long long)phba
->bg_reftag_err_cnt
);
187 * lpfc_info_show - Return some pci info about the host in ascii
188 * @dev: class converted to a Scsi_host structure.
189 * @attr: device attribute, not used.
190 * @buf: on return contains the formatted text from lpfc_info().
192 * Returns: size of formatted string.
195 lpfc_info_show(struct device
*dev
, struct device_attribute
*attr
,
198 struct Scsi_Host
*host
= class_to_shost(dev
);
200 return snprintf(buf
, PAGE_SIZE
, "%s\n",lpfc_info(host
));
204 * lpfc_serialnum_show - Return the hba serial number in ascii
205 * @dev: class converted to a Scsi_host structure.
206 * @attr: device attribute, not used.
207 * @buf: on return contains the formatted text serial number.
209 * Returns: size of formatted string.
212 lpfc_serialnum_show(struct device
*dev
, struct device_attribute
*attr
,
215 struct Scsi_Host
*shost
= class_to_shost(dev
);
216 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
217 struct lpfc_hba
*phba
= vport
->phba
;
219 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->SerialNumber
);
223 * lpfc_temp_sensor_show - Return the temperature sensor level
224 * @dev: class converted to a Scsi_host structure.
225 * @attr: device attribute, not used.
226 * @buf: on return contains the formatted support level.
229 * Returns a number indicating the temperature sensor level currently
230 * supported, zero or one in ascii.
232 * Returns: size of formatted string.
235 lpfc_temp_sensor_show(struct device
*dev
, struct device_attribute
*attr
,
238 struct Scsi_Host
*shost
= class_to_shost(dev
);
239 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
240 struct lpfc_hba
*phba
= vport
->phba
;
241 return snprintf(buf
, PAGE_SIZE
, "%d\n",phba
->temp_sensor_support
);
245 * lpfc_modeldesc_show - Return the model description of the hba
246 * @dev: class converted to a Scsi_host structure.
247 * @attr: device attribute, not used.
248 * @buf: on return contains the scsi vpd model description.
250 * Returns: size of formatted string.
253 lpfc_modeldesc_show(struct device
*dev
, struct device_attribute
*attr
,
256 struct Scsi_Host
*shost
= class_to_shost(dev
);
257 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
258 struct lpfc_hba
*phba
= vport
->phba
;
260 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelDesc
);
264 * lpfc_modelname_show - Return the model name of the hba
265 * @dev: class converted to a Scsi_host structure.
266 * @attr: device attribute, not used.
267 * @buf: on return contains the scsi vpd model name.
269 * Returns: size of formatted string.
272 lpfc_modelname_show(struct device
*dev
, struct device_attribute
*attr
,
275 struct Scsi_Host
*shost
= class_to_shost(dev
);
276 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
277 struct lpfc_hba
*phba
= vport
->phba
;
279 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelName
);
283 * lpfc_programtype_show - Return the program type of the hba
284 * @dev: class converted to a Scsi_host structure.
285 * @attr: device attribute, not used.
286 * @buf: on return contains the scsi vpd program type.
288 * Returns: size of formatted string.
291 lpfc_programtype_show(struct device
*dev
, struct device_attribute
*attr
,
294 struct Scsi_Host
*shost
= class_to_shost(dev
);
295 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
296 struct lpfc_hba
*phba
= vport
->phba
;
298 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ProgramType
);
302 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
303 * @dev: class converted to a Scsi_host structure.
304 * @attr: device attribute, not used.
305 * @buf: on return contains the Menlo Maintenance sli flag.
307 * Returns: size of formatted string.
310 lpfc_mlomgmt_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
312 struct Scsi_Host
*shost
= class_to_shost(dev
);
313 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
314 struct lpfc_hba
*phba
= vport
->phba
;
316 return snprintf(buf
, PAGE_SIZE
, "%d\n",
317 (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
));
321 * lpfc_vportnum_show - Return the port number in ascii of the hba
322 * @dev: class converted to a Scsi_host structure.
323 * @attr: device attribute, not used.
324 * @buf: on return contains scsi vpd program type.
326 * Returns: size of formatted string.
329 lpfc_vportnum_show(struct device
*dev
, struct device_attribute
*attr
,
332 struct Scsi_Host
*shost
= class_to_shost(dev
);
333 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
334 struct lpfc_hba
*phba
= vport
->phba
;
336 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->Port
);
340 * lpfc_fwrev_show - Return the firmware rev running in the hba
341 * @dev: class converted to a Scsi_host structure.
342 * @attr: device attribute, not used.
343 * @buf: on return contains the scsi vpd program type.
345 * Returns: size of formatted string.
348 lpfc_fwrev_show(struct device
*dev
, struct device_attribute
*attr
,
351 struct Scsi_Host
*shost
= class_to_shost(dev
);
352 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
353 struct lpfc_hba
*phba
= vport
->phba
;
356 char fwrev
[FW_REV_STR_SIZE
];
359 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
360 if_type
= phba
->sli4_hba
.pc_sli4_params
.if_type
;
361 sli_family
= phba
->sli4_hba
.pc_sli4_params
.sli_family
;
363 if (phba
->sli_rev
< LPFC_SLI_REV4
)
364 len
= snprintf(buf
, PAGE_SIZE
, "%s, sli-%d\n",
365 fwrev
, phba
->sli_rev
);
367 len
= snprintf(buf
, PAGE_SIZE
, "%s, sli-%d:%d:%x\n",
368 fwrev
, phba
->sli_rev
, if_type
, sli_family
);
374 * lpfc_hdw_show - Return the jedec information about the hba
375 * @dev: class converted to a Scsi_host structure.
376 * @attr: device attribute, not used.
377 * @buf: on return contains the scsi vpd program type.
379 * Returns: size of formatted string.
382 lpfc_hdw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
385 struct Scsi_Host
*shost
= class_to_shost(dev
);
386 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
387 struct lpfc_hba
*phba
= vport
->phba
;
388 lpfc_vpd_t
*vp
= &phba
->vpd
;
390 lpfc_jedec_to_ascii(vp
->rev
.biuRev
, hdw
);
391 return snprintf(buf
, PAGE_SIZE
, "%s\n", hdw
);
395 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
396 * @dev: class converted to a Scsi_host structure.
397 * @attr: device attribute, not used.
398 * @buf: on return contains the ROM and FCode ascii strings.
400 * Returns: size of formatted string.
403 lpfc_option_rom_version_show(struct device
*dev
, struct device_attribute
*attr
,
406 struct Scsi_Host
*shost
= class_to_shost(dev
);
407 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
408 struct lpfc_hba
*phba
= vport
->phba
;
410 return snprintf(buf
, PAGE_SIZE
, "%s\n", phba
->OptionROMVersion
);
414 * lpfc_state_show - Return the link state of the port
415 * @dev: class converted to a Scsi_host structure.
416 * @attr: device attribute, not used.
417 * @buf: on return contains text describing the state of the link.
420 * The switch statement has no default so zero will be returned.
422 * Returns: size of formatted string.
425 lpfc_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
428 struct Scsi_Host
*shost
= class_to_shost(dev
);
429 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
430 struct lpfc_hba
*phba
= vport
->phba
;
433 switch (phba
->link_state
) {
434 case LPFC_LINK_UNKNOWN
:
435 case LPFC_WARM_START
:
436 case LPFC_INIT_START
:
437 case LPFC_INIT_MBX_CMDS
:
440 if (phba
->hba_flag
& LINK_DISABLED
)
441 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
442 "Link Down - User disabled\n");
444 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
450 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Link Up - ");
452 switch (vport
->port_state
) {
453 case LPFC_LOCAL_CFG_LINK
:
454 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
455 "Configuring Link\n");
459 case LPFC_FABRIC_CFG_LINK
:
462 case LPFC_BUILD_DISC_LIST
:
464 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
467 case LPFC_VPORT_READY
:
468 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Ready\n");
471 case LPFC_VPORT_FAILED
:
472 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Failed\n");
475 case LPFC_VPORT_UNKNOWN
:
476 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
480 if (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
)
481 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
482 " Menlo Maint Mode\n");
483 else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
484 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
485 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
488 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
491 if (vport
->fc_flag
& FC_FABRIC
)
492 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
495 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
504 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
505 * @dev: class unused variable.
506 * @attr: device attribute, not used.
507 * @buf: on return contains the module description text.
509 * Returns: size of formatted string.
512 lpfc_sli4_protocol_show(struct device
*dev
, struct device_attribute
*attr
,
515 struct Scsi_Host
*shost
= class_to_shost(dev
);
516 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
517 struct lpfc_hba
*phba
= vport
->phba
;
519 if (phba
->sli_rev
< LPFC_SLI_REV4
)
520 return snprintf(buf
, PAGE_SIZE
, "fc\n");
522 if (phba
->sli4_hba
.lnk_info
.lnk_dv
== LPFC_LNK_DAT_VAL
) {
523 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_GE
)
524 return snprintf(buf
, PAGE_SIZE
, "fcoe\n");
525 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_FC
)
526 return snprintf(buf
, PAGE_SIZE
, "fc\n");
528 return snprintf(buf
, PAGE_SIZE
, "unknown\n");
532 * lpfc_link_state_store - Transition the link_state on an HBA port
533 * @dev: class device that is converted into a Scsi_host.
534 * @attr: device attribute, not used.
535 * @buf: one or more lpfc_polling_flags values.
539 * -EINVAL if the buffer is not "up" or "down"
540 * return from link state change function if non-zero
541 * length of the buf on success
544 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
545 const char *buf
, size_t count
)
547 struct Scsi_Host
*shost
= class_to_shost(dev
);
548 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
549 struct lpfc_hba
*phba
= vport
->phba
;
551 int status
= -EINVAL
;
553 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
554 (phba
->link_state
== LPFC_LINK_DOWN
))
555 status
= phba
->lpfc_hba_init_link(phba
, MBX_NOWAIT
);
556 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
557 (phba
->link_state
>= LPFC_LINK_UP
))
558 status
= phba
->lpfc_hba_down_link(phba
, MBX_NOWAIT
);
567 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
568 * @dev: class device that is converted into a Scsi_host.
569 * @attr: device attribute, not used.
570 * @buf: on return contains the sum of fc mapped and unmapped.
573 * Returns the ascii text number of the sum of the fc mapped and unmapped
576 * Returns: size of formatted string.
579 lpfc_num_discovered_ports_show(struct device
*dev
,
580 struct device_attribute
*attr
, char *buf
)
582 struct Scsi_Host
*shost
= class_to_shost(dev
);
583 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
585 return snprintf(buf
, PAGE_SIZE
, "%d\n",
586 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
590 * lpfc_issue_lip - Misnomer, name carried over from long ago
591 * @shost: Scsi_Host pointer.
594 * Bring the link down gracefully then re-init the link. The firmware will
595 * re-init the fiber channel interface as required. Does not issue a LIP.
598 * -EPERM port offline or management commands are being blocked
599 * -ENOMEM cannot allocate memory for the mailbox command
600 * -EIO error sending the mailbox command
604 lpfc_issue_lip(struct Scsi_Host
*shost
)
606 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
607 struct lpfc_hba
*phba
= vport
->phba
;
608 LPFC_MBOXQ_t
*pmboxq
;
609 int mbxstatus
= MBXERR_ERROR
;
611 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
612 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
615 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
620 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
621 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
622 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
624 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
626 if ((mbxstatus
== MBX_SUCCESS
) &&
627 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
628 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
629 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
630 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
631 phba
->cfg_link_speed
);
632 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
634 if ((mbxstatus
== MBX_SUCCESS
) &&
635 (pmboxq
->u
.mb
.mbxStatus
== MBXERR_SEC_NO_PERMISSION
))
636 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
| LOG_SLI
,
637 "2859 SLI authentication is required "
638 "for INIT_LINK but has not done yet\n");
641 lpfc_set_loopback_flag(phba
);
642 if (mbxstatus
!= MBX_TIMEOUT
)
643 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
645 if (mbxstatus
== MBXERR_ERROR
)
652 * lpfc_do_offline - Issues a mailbox command to bring the link down
653 * @phba: lpfc_hba pointer.
654 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
657 * Assumes any error from lpfc_do_offline() will be negative.
658 * Can wait up to 5 seconds for the port ring buffers count
659 * to reach zero, prints a warning if it is not zero and continues.
660 * lpfc_workq_post_event() returns a non-zero return code if call fails.
663 * -EIO error posting the event
667 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
669 struct completion online_compl
;
670 struct lpfc_sli_ring
*pring
;
671 struct lpfc_sli
*psli
;
677 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
680 init_completion(&online_compl
);
681 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
682 LPFC_EVT_OFFLINE_PREP
);
686 wait_for_completion(&online_compl
);
693 /* Wait a little for things to settle down, but not
694 * long enough for dev loss timeout to expire.
696 for (i
= 0; i
< psli
->num_rings
; i
++) {
697 pring
= &psli
->ring
[i
];
698 while (!list_empty(&pring
->txcmplq
)) {
700 if (cnt
++ > 500) { /* 5 secs */
701 lpfc_printf_log(phba
,
702 KERN_WARNING
, LOG_INIT
,
703 "0466 Outstanding IO when "
704 "bringing Adapter offline\n");
710 init_completion(&online_compl
);
711 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
715 wait_for_completion(&online_compl
);
724 * lpfc_selective_reset - Offline then onlines the port
725 * @phba: lpfc_hba pointer.
728 * If the port is configured to allow a reset then the hba is brought
729 * offline then online.
732 * Assumes any error from lpfc_do_offline() will be negative.
733 * Do not make this function static.
736 * lpfc_do_offline() return code if not zero
737 * -EIO reset not configured or error posting the event
741 lpfc_selective_reset(struct lpfc_hba
*phba
)
743 struct completion online_compl
;
747 if ((!phba
->cfg_enable_hba_reset
) ||
748 (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
))
751 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
756 init_completion(&online_compl
);
757 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
762 wait_for_completion(&online_compl
);
771 * lpfc_issue_reset - Selectively resets an adapter
772 * @dev: class device that is converted into a Scsi_host.
773 * @attr: device attribute, not used.
774 * @buf: containing the string "selective".
775 * @count: unused variable.
778 * If the buf contains the string "selective" then lpfc_selective_reset()
779 * is called to perform the reset.
782 * Assumes any error from lpfc_selective_reset() will be negative.
783 * If lpfc_selective_reset() returns zero then the length of the buffer
784 * is returned which indicates success
787 * -EINVAL if the buffer does not contain the string "selective"
788 * length of buf if lpfc-selective_reset() if the call succeeds
789 * return value of lpfc_selective_reset() if the call fails
792 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
793 const char *buf
, size_t count
)
795 struct Scsi_Host
*shost
= class_to_shost(dev
);
796 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
797 struct lpfc_hba
*phba
= vport
->phba
;
798 int status
= -EINVAL
;
800 if (!phba
->cfg_enable_hba_reset
)
803 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
804 status
= phba
->lpfc_selective_reset(phba
);
813 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
814 * @phba: lpfc_hba pointer.
817 * SLI4 interface type-2 device to wait on the sliport status register for
818 * the readyness after performing a firmware reset.
821 * zero for success, -EPERM when port does not have privilage to perform the
822 * reset, -EIO when port timeout from recovering from the reset.
825 * As the caller will interpret the return code by value, be careful in making
826 * change or addition to return codes.
829 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba
*phba
)
831 struct lpfc_register portstat_reg
= {0};
835 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
836 &portstat_reg
.word0
);
838 /* verify if privilaged for the request operation */
839 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
) &&
840 !bf_get(lpfc_sliport_status_err
, &portstat_reg
))
843 /* wait for the SLI port firmware ready after firmware reset */
844 for (i
= 0; i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
; i
++) {
846 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
847 &portstat_reg
.word0
);
848 if (!bf_get(lpfc_sliport_status_err
, &portstat_reg
))
850 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
))
852 if (!bf_get(lpfc_sliport_status_rdy
, &portstat_reg
))
857 if (i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
)
864 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
865 * @phba: lpfc_hba pointer.
868 * Request SLI4 interface type-2 device to perform a physical register set
875 lpfc_sli4_pdev_reg_request(struct lpfc_hba
*phba
, uint32_t opcode
)
877 struct completion online_compl
;
878 struct pci_dev
*pdev
= phba
->pcidev
;
879 uint32_t before_fc_flag
;
880 uint32_t sriov_nr_virtfn
;
882 int status
= 0, rc
= 0;
883 int job_posted
= 1, sriov_err
;
885 if (!phba
->cfg_enable_hba_reset
)
888 if ((phba
->sli_rev
< LPFC_SLI_REV4
) ||
889 (bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
) !=
890 LPFC_SLI_INTF_IF_TYPE_2
))
893 /* Keep state if we need to restore back */
894 before_fc_flag
= phba
->pport
->fc_flag
;
895 sriov_nr_virtfn
= phba
->cfg_sriov_nr_virtfn
;
897 /* Disable SR-IOV virtual functions if enabled */
898 if (phba
->cfg_sriov_nr_virtfn
) {
899 pci_disable_sriov(pdev
);
900 phba
->cfg_sriov_nr_virtfn
= 0;
903 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
908 /* wait for the device to be quiesced before firmware reset */
911 reg_val
= readl(phba
->sli4_hba
.conf_regs_memmap_p
+
912 LPFC_CTL_PDEV_CTL_OFFSET
);
914 if (opcode
== LPFC_FW_DUMP
)
915 reg_val
|= LPFC_FW_DUMP_REQUEST
;
916 else if (opcode
== LPFC_FW_RESET
)
917 reg_val
|= LPFC_CTL_PDEV_CTL_FRST
;
918 else if (opcode
== LPFC_DV_RESET
)
919 reg_val
|= LPFC_CTL_PDEV_CTL_DRST
;
921 writel(reg_val
, phba
->sli4_hba
.conf_regs_memmap_p
+
922 LPFC_CTL_PDEV_CTL_OFFSET
);
924 readl(phba
->sli4_hba
.conf_regs_memmap_p
+ LPFC_CTL_PDEV_CTL_OFFSET
);
926 /* delay driver action following IF_TYPE_2 reset */
927 rc
= lpfc_sli4_pdev_status_reg_wait(phba
);
930 /* no privilage for reset */
931 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
932 "3150 No privilage to perform the requested "
933 "access: x%x\n", reg_val
);
934 } else if (rc
== -EIO
) {
935 /* reset failed, there is nothing more we can do */
936 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
937 "3153 Fail to perform the requested "
938 "access: x%x\n", reg_val
);
942 /* keep the original port state */
943 if (before_fc_flag
& FC_OFFLINE_MODE
)
946 init_completion(&online_compl
);
947 job_posted
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
952 wait_for_completion(&online_compl
);
955 /* in any case, restore the virtual functions enabled as before */
956 if (sriov_nr_virtfn
) {
958 lpfc_sli_probe_sriov_nr_virtfn(phba
, sriov_nr_virtfn
);
960 phba
->cfg_sriov_nr_virtfn
= sriov_nr_virtfn
;
963 /* return proper error code */
974 * lpfc_nport_evt_cnt_show - Return the number of nport events
975 * @dev: class device that is converted into a Scsi_host.
976 * @attr: device attribute, not used.
977 * @buf: on return contains the ascii number of nport events.
979 * Returns: size of formatted string.
982 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
985 struct Scsi_Host
*shost
= class_to_shost(dev
);
986 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
987 struct lpfc_hba
*phba
= vport
->phba
;
989 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
993 * lpfc_board_mode_show - Return the state of the board
994 * @dev: class device that is converted into a Scsi_host.
995 * @attr: device attribute, not used.
996 * @buf: on return contains the state of the adapter.
998 * Returns: size of formatted string.
1001 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
1004 struct Scsi_Host
*shost
= class_to_shost(dev
);
1005 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1006 struct lpfc_hba
*phba
= vport
->phba
;
1009 if (phba
->link_state
== LPFC_HBA_ERROR
)
1011 else if (phba
->link_state
== LPFC_WARM_START
)
1012 state
= "warm start";
1013 else if (phba
->link_state
== LPFC_INIT_START
)
1018 return snprintf(buf
, PAGE_SIZE
, "%s\n", state
);
1022 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1023 * @dev: class device that is converted into a Scsi_host.
1024 * @attr: device attribute, not used.
1025 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1026 * @count: unused variable.
1029 * -EACCES if enable hba reset not enabled
1030 * -EINVAL if the buffer does not contain a valid string (see above)
1031 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1032 * buf length greater than zero indicates success
1035 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
1036 const char *buf
, size_t count
)
1038 struct Scsi_Host
*shost
= class_to_shost(dev
);
1039 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1040 struct lpfc_hba
*phba
= vport
->phba
;
1041 struct completion online_compl
;
1042 char *board_mode_str
= NULL
;
1046 if (!phba
->cfg_enable_hba_reset
) {
1048 goto board_mode_out
;
1051 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1052 "3050 lpfc_board_mode set to %s\n", buf
);
1054 init_completion(&online_compl
);
1056 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
1057 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1061 goto board_mode_out
;
1063 wait_for_completion(&online_compl
);
1064 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
1065 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1066 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
1067 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1070 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
1071 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
1072 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1075 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
1076 else if (strncmp(buf
, "dump", sizeof("dump") - 1) == 0)
1077 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_DUMP
);
1078 else if (strncmp(buf
, "fw_reset", sizeof("fw_reset") - 1) == 0)
1079 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_RESET
);
1080 else if (strncmp(buf
, "dv_reset", sizeof("dv_reset") - 1) == 0)
1081 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_DV_RESET
);
1089 board_mode_str
= strchr(buf
, '\n');
1091 *board_mode_str
= '\0';
1092 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1093 "3097 Failed \"%s\", status(%d), "
1095 buf
, status
, phba
->pport
->fc_flag
);
1101 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1102 * @phba: pointer to the adapter structure.
1103 * @mxri: max xri count.
1104 * @axri: available xri count.
1105 * @mrpi: max rpi count.
1106 * @arpi: available rpi count.
1107 * @mvpi: max vpi count.
1108 * @avpi: available vpi count.
1111 * If an integer pointer for an count is not null then the value for the
1112 * count is returned.
1119 lpfc_get_hba_info(struct lpfc_hba
*phba
,
1120 uint32_t *mxri
, uint32_t *axri
,
1121 uint32_t *mrpi
, uint32_t *arpi
,
1122 uint32_t *mvpi
, uint32_t *avpi
)
1124 struct lpfc_mbx_read_config
*rd_config
;
1125 LPFC_MBOXQ_t
*pmboxq
;
1131 * prevent udev from issuing mailbox commands until the port is
1134 if (phba
->link_state
< LPFC_LINK_DOWN
||
1135 !phba
->mbox_mem_pool
||
1136 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
1139 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
1142 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1145 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1147 pmb
= &pmboxq
->u
.mb
;
1148 pmb
->mbxCommand
= MBX_READ_CONFIG
;
1149 pmb
->mbxOwner
= OWN_HOST
;
1150 pmboxq
->context1
= NULL
;
1152 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
1153 rc
= MBX_NOT_FINISHED
;
1155 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
1157 if (rc
!= MBX_SUCCESS
) {
1158 if (rc
!= MBX_TIMEOUT
)
1159 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1163 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1164 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
1166 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
1168 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
1169 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
1171 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
1173 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
1174 phba
->sli4_hba
.max_cfg_param
.xri_used
;
1176 /* Account for differences with SLI-3. Get vpi count from
1177 * mailbox data and subtract one for max vpi value.
1179 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
1180 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
1185 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
1188 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
1190 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
1192 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
1194 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
1196 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
1198 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
1201 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1206 * lpfc_max_rpi_show - Return maximum rpi
1207 * @dev: class device that is converted into a Scsi_host.
1208 * @attr: device attribute, not used.
1209 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1212 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1213 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1214 * to "Unknown" and the buffer length is returned, therefore the caller
1215 * must check for "Unknown" in the buffer to detect a failure.
1217 * Returns: size of formatted string.
1220 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1223 struct Scsi_Host
*shost
= class_to_shost(dev
);
1224 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1225 struct lpfc_hba
*phba
= vport
->phba
;
1228 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
1229 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1230 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1234 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1235 * @dev: class device that is converted into a Scsi_host.
1236 * @attr: device attribute, not used.
1237 * @buf: containing the used rpi count in decimal or "Unknown".
1240 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1241 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1242 * to "Unknown" and the buffer length is returned, therefore the caller
1243 * must check for "Unknown" in the buffer to detect a failure.
1245 * Returns: size of formatted string.
1248 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1251 struct Scsi_Host
*shost
= class_to_shost(dev
);
1252 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1253 struct lpfc_hba
*phba
= vport
->phba
;
1256 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1257 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1258 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1262 * lpfc_max_xri_show - Return maximum xri
1263 * @dev: class device that is converted into a Scsi_host.
1264 * @attr: device attribute, not used.
1265 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1268 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1269 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1270 * to "Unknown" and the buffer length is returned, therefore the caller
1271 * must check for "Unknown" in the buffer to detect a failure.
1273 * Returns: size of formatted string.
1276 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1279 struct Scsi_Host
*shost
= class_to_shost(dev
);
1280 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1281 struct lpfc_hba
*phba
= vport
->phba
;
1284 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
1285 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1286 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1290 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1291 * @dev: class device that is converted into a Scsi_host.
1292 * @attr: device attribute, not used.
1293 * @buf: on return contains the used xri count in decimal or "Unknown".
1296 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1297 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1298 * to "Unknown" and the buffer length is returned, therefore the caller
1299 * must check for "Unknown" in the buffer to detect a failure.
1301 * Returns: size of formatted string.
1304 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1307 struct Scsi_Host
*shost
= class_to_shost(dev
);
1308 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1309 struct lpfc_hba
*phba
= vport
->phba
;
1312 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
1313 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1314 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1318 * lpfc_max_vpi_show - Return maximum vpi
1319 * @dev: class device that is converted into a Scsi_host.
1320 * @attr: device attribute, not used.
1321 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1324 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1325 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1326 * to "Unknown" and the buffer length is returned, therefore the caller
1327 * must check for "Unknown" in the buffer to detect a failure.
1329 * Returns: size of formatted string.
1332 lpfc_max_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1335 struct Scsi_Host
*shost
= class_to_shost(dev
);
1336 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1337 struct lpfc_hba
*phba
= vport
->phba
;
1340 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
1341 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1342 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1346 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1347 * @dev: class device that is converted into a Scsi_host.
1348 * @attr: device attribute, not used.
1349 * @buf: on return contains the used vpi count in decimal or "Unknown".
1352 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1353 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1354 * to "Unknown" and the buffer length is returned, therefore the caller
1355 * must check for "Unknown" in the buffer to detect a failure.
1357 * Returns: size of formatted string.
1360 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1363 struct Scsi_Host
*shost
= class_to_shost(dev
);
1364 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1365 struct lpfc_hba
*phba
= vport
->phba
;
1368 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
1369 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1370 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1374 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1375 * @dev: class device that is converted into a Scsi_host.
1376 * @attr: device attribute, not used.
1377 * @buf: text that must be interpreted to determine if npiv is supported.
1380 * Buffer will contain text indicating npiv is not suppoerted on the port,
1381 * the port is an NPIV physical port, or it is an npiv virtual port with
1382 * the id of the vport.
1384 * Returns: size of formatted string.
1387 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
1390 struct Scsi_Host
*shost
= class_to_shost(dev
);
1391 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1392 struct lpfc_hba
*phba
= vport
->phba
;
1394 if (!(phba
->max_vpi
))
1395 return snprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
1396 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1397 return snprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
1398 return snprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
1402 * lpfc_poll_show - Return text about poll support for the adapter
1403 * @dev: class device that is converted into a Scsi_host.
1404 * @attr: device attribute, not used.
1405 * @buf: on return contains the cfg_poll in hex.
1408 * cfg_poll should be a lpfc_polling_flags type.
1410 * Returns: size of formatted string.
1413 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
1416 struct Scsi_Host
*shost
= class_to_shost(dev
);
1417 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1418 struct lpfc_hba
*phba
= vport
->phba
;
1420 return snprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
1424 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1425 * @dev: class device that is converted into a Scsi_host.
1426 * @attr: device attribute, not used.
1427 * @buf: one or more lpfc_polling_flags values.
1431 * buf contents converted to integer and checked for a valid value.
1434 * -EINVAL if the buffer connot be converted or is out of range
1435 * length of the buf on success
1438 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
1439 const char *buf
, size_t count
)
1441 struct Scsi_Host
*shost
= class_to_shost(dev
);
1442 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1443 struct lpfc_hba
*phba
= vport
->phba
;
1448 if (!isdigit(buf
[0]))
1451 if (sscanf(buf
, "%i", &val
) != 1)
1454 if ((val
& 0x3) != val
)
1457 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1460 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1461 "3051 lpfc_poll changed from %d to %d\n",
1462 phba
->cfg_poll
, val
);
1464 spin_lock_irq(&phba
->hbalock
);
1466 old_val
= phba
->cfg_poll
;
1468 if (val
& ENABLE_FCP_RING_POLLING
) {
1469 if ((val
& DISABLE_FCP_RING_INT
) &&
1470 !(old_val
& DISABLE_FCP_RING_INT
)) {
1471 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1472 spin_unlock_irq(&phba
->hbalock
);
1475 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
1476 writel(creg_val
, phba
->HCregaddr
);
1477 readl(phba
->HCregaddr
); /* flush */
1479 lpfc_poll_start_timer(phba
);
1481 } else if (val
!= 0x0) {
1482 spin_unlock_irq(&phba
->hbalock
);
1486 if (!(val
& DISABLE_FCP_RING_INT
) &&
1487 (old_val
& DISABLE_FCP_RING_INT
))
1489 spin_unlock_irq(&phba
->hbalock
);
1490 del_timer(&phba
->fcp_poll_timer
);
1491 spin_lock_irq(&phba
->hbalock
);
1492 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1493 spin_unlock_irq(&phba
->hbalock
);
1496 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
1497 writel(creg_val
, phba
->HCregaddr
);
1498 readl(phba
->HCregaddr
); /* flush */
1501 phba
->cfg_poll
= val
;
1503 spin_unlock_irq(&phba
->hbalock
);
1509 * lpfc_fips_level_show - Return the current FIPS level for the HBA
1510 * @dev: class unused variable.
1511 * @attr: device attribute, not used.
1512 * @buf: on return contains the module description text.
1514 * Returns: size of formatted string.
1517 lpfc_fips_level_show(struct device
*dev
, struct device_attribute
*attr
,
1520 struct Scsi_Host
*shost
= class_to_shost(dev
);
1521 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1522 struct lpfc_hba
*phba
= vport
->phba
;
1524 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_level
);
1528 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
1529 * @dev: class unused variable.
1530 * @attr: device attribute, not used.
1531 * @buf: on return contains the module description text.
1533 * Returns: size of formatted string.
1536 lpfc_fips_rev_show(struct device
*dev
, struct device_attribute
*attr
,
1539 struct Scsi_Host
*shost
= class_to_shost(dev
);
1540 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1541 struct lpfc_hba
*phba
= vport
->phba
;
1543 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_spec_rev
);
1547 * lpfc_dss_show - Return the current state of dss and the configured state
1548 * @dev: class converted to a Scsi_host structure.
1549 * @attr: device attribute, not used.
1550 * @buf: on return contains the formatted text.
1552 * Returns: size of formatted string.
1555 lpfc_dss_show(struct device
*dev
, struct device_attribute
*attr
,
1558 struct Scsi_Host
*shost
= class_to_shost(dev
);
1559 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1560 struct lpfc_hba
*phba
= vport
->phba
;
1562 return snprintf(buf
, PAGE_SIZE
, "%s - %sOperational\n",
1563 (phba
->cfg_enable_dss
) ? "Enabled" : "Disabled",
1564 (phba
->sli3_options
& LPFC_SLI3_DSS_ENABLED
) ?
1569 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
1570 * @dev: class converted to a Scsi_host structure.
1571 * @attr: device attribute, not used.
1572 * @buf: on return contains the formatted support level.
1575 * Returns the maximum number of virtual functions a physical function can
1576 * support, 0 will be returned if called on virtual function.
1578 * Returns: size of formatted string.
1581 lpfc_sriov_hw_max_virtfn_show(struct device
*dev
,
1582 struct device_attribute
*attr
,
1585 struct Scsi_Host
*shost
= class_to_shost(dev
);
1586 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1587 struct lpfc_hba
*phba
= vport
->phba
;
1588 uint16_t max_nr_virtfn
;
1590 max_nr_virtfn
= lpfc_sli_sriov_nr_virtfn_get(phba
);
1591 return snprintf(buf
, PAGE_SIZE
, "%d\n", max_nr_virtfn
);
1595 * lpfc_param_show - Return a cfg attribute value in decimal
1598 * Macro that given an attr e.g. hba_queue_depth expands
1599 * into a function with the name lpfc_hba_queue_depth_show.
1601 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
1602 * @dev: class device that is converted into a Scsi_host.
1603 * @attr: device attribute, not used.
1604 * @buf: on return contains the attribute value in decimal.
1606 * Returns: size of formatted string.
1608 #define lpfc_param_show(attr) \
1610 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1613 struct Scsi_Host *shost = class_to_shost(dev);\
1614 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1615 struct lpfc_hba *phba = vport->phba;\
1617 val = phba->cfg_##attr;\
1618 return snprintf(buf, PAGE_SIZE, "%d\n",\
1623 * lpfc_param_hex_show - Return a cfg attribute value in hex
1626 * Macro that given an attr e.g. hba_queue_depth expands
1627 * into a function with the name lpfc_hba_queue_depth_show
1629 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
1630 * @dev: class device that is converted into a Scsi_host.
1631 * @attr: device attribute, not used.
1632 * @buf: on return contains the attribute value in hexadecimal.
1634 * Returns: size of formatted string.
1636 #define lpfc_param_hex_show(attr) \
1638 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1641 struct Scsi_Host *shost = class_to_shost(dev);\
1642 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1643 struct lpfc_hba *phba = vport->phba;\
1645 val = phba->cfg_##attr;\
1646 return snprintf(buf, PAGE_SIZE, "%#x\n",\
1651 * lpfc_param_init - Initializes a cfg attribute
1654 * Macro that given an attr e.g. hba_queue_depth expands
1655 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1656 * takes a default argument, a minimum and maximum argument.
1658 * lpfc_##attr##_init: Initializes an attribute.
1659 * @phba: pointer the the adapter structure.
1660 * @val: integer attribute value.
1662 * Validates the min and max values then sets the adapter config field
1663 * accordingly, or uses the default if out of range and prints an error message.
1667 * -EINVAL if default used
1669 #define lpfc_param_init(attr, default, minval, maxval) \
1671 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1673 if (val >= minval && val <= maxval) {\
1674 phba->cfg_##attr = val;\
1677 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1678 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
1679 "allowed range is ["#minval", "#maxval"]\n", val); \
1680 phba->cfg_##attr = default;\
1685 * lpfc_param_set - Set a cfg attribute value
1688 * Macro that given an attr e.g. hba_queue_depth expands
1689 * into a function with the name lpfc_hba_queue_depth_set
1691 * lpfc_##attr##_set: Sets an attribute value.
1692 * @phba: pointer the the adapter structure.
1693 * @val: integer attribute value.
1696 * Validates the min and max values then sets the
1697 * adapter config field if in the valid range. prints error message
1698 * and does not set the parameter if invalid.
1702 * -EINVAL if val is invalid
1704 #define lpfc_param_set(attr, default, minval, maxval) \
1706 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
1708 if (val >= minval && val <= maxval) {\
1709 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1710 "3052 lpfc_" #attr " changed from %d to %d\n", \
1711 phba->cfg_##attr, val); \
1712 phba->cfg_##attr = val;\
1715 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1716 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
1717 "allowed range is ["#minval", "#maxval"]\n", val); \
1722 * lpfc_param_store - Set a vport attribute value
1725 * Macro that given an attr e.g. hba_queue_depth expands
1726 * into a function with the name lpfc_hba_queue_depth_store.
1728 * lpfc_##attr##_store: Set an sttribute value.
1729 * @dev: class device that is converted into a Scsi_host.
1730 * @attr: device attribute, not used.
1731 * @buf: contains the attribute value in ascii.
1735 * Convert the ascii text number to an integer, then
1736 * use the lpfc_##attr##_set function to set the value.
1739 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1740 * length of buffer upon success.
1742 #define lpfc_param_store(attr) \
1744 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1745 const char *buf, size_t count) \
1747 struct Scsi_Host *shost = class_to_shost(dev);\
1748 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1749 struct lpfc_hba *phba = vport->phba;\
1751 if (!isdigit(buf[0]))\
1753 if (sscanf(buf, "%i", &val) != 1)\
1755 if (lpfc_##attr##_set(phba, val) == 0) \
1756 return strlen(buf);\
1762 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
1765 * Macro that given an attr e.g. hba_queue_depth expands
1766 * into a function with the name lpfc_hba_queue_depth_show
1768 * lpfc_##attr##_show: prints the attribute value in decimal.
1769 * @dev: class device that is converted into a Scsi_host.
1770 * @attr: device attribute, not used.
1771 * @buf: on return contains the attribute value in decimal.
1773 * Returns: length of formatted string.
1775 #define lpfc_vport_param_show(attr) \
1777 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1780 struct Scsi_Host *shost = class_to_shost(dev);\
1781 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1783 val = vport->cfg_##attr;\
1784 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
1788 * lpfc_vport_param_hex_show - Return hex formatted attribute value
1791 * Macro that given an attr e.g.
1792 * hba_queue_depth expands into a function with the name
1793 * lpfc_hba_queue_depth_show
1795 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
1796 * @dev: class device that is converted into a Scsi_host.
1797 * @attr: device attribute, not used.
1798 * @buf: on return contains the attribute value in hexadecimal.
1800 * Returns: length of formatted string.
1802 #define lpfc_vport_param_hex_show(attr) \
1804 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1807 struct Scsi_Host *shost = class_to_shost(dev);\
1808 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1810 val = vport->cfg_##attr;\
1811 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
1815 * lpfc_vport_param_init - Initialize a vport cfg attribute
1818 * Macro that given an attr e.g. hba_queue_depth expands
1819 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1820 * takes a default argument, a minimum and maximum argument.
1822 * lpfc_##attr##_init: validates the min and max values then sets the
1823 * adapter config field accordingly, or uses the default if out of range
1824 * and prints an error message.
1825 * @phba: pointer the the adapter structure.
1826 * @val: integer attribute value.
1830 * -EINVAL if default used
1832 #define lpfc_vport_param_init(attr, default, minval, maxval) \
1834 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
1836 if (val >= minval && val <= maxval) {\
1837 vport->cfg_##attr = val;\
1840 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1841 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
1842 "allowed range is ["#minval", "#maxval"]\n", val); \
1843 vport->cfg_##attr = default;\
1848 * lpfc_vport_param_set - Set a vport cfg attribute
1851 * Macro that given an attr e.g. hba_queue_depth expands
1852 * into a function with the name lpfc_hba_queue_depth_set
1854 * lpfc_##attr##_set: validates the min and max values then sets the
1855 * adapter config field if in the valid range. prints error message
1856 * and does not set the parameter if invalid.
1857 * @phba: pointer the the adapter structure.
1858 * @val: integer attribute value.
1862 * -EINVAL if val is invalid
1864 #define lpfc_vport_param_set(attr, default, minval, maxval) \
1866 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
1868 if (val >= minval && val <= maxval) {\
1869 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1870 "3053 lpfc_" #attr " changed from %d to %d\n", \
1871 vport->cfg_##attr, val); \
1872 vport->cfg_##attr = val;\
1875 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1876 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
1877 "allowed range is ["#minval", "#maxval"]\n", val); \
1882 * lpfc_vport_param_store - Set a vport attribute
1885 * Macro that given an attr e.g. hba_queue_depth
1886 * expands into a function with the name lpfc_hba_queue_depth_store
1888 * lpfc_##attr##_store: convert the ascii text number to an integer, then
1889 * use the lpfc_##attr##_set function to set the value.
1890 * @cdev: class device that is converted into a Scsi_host.
1891 * @buf: contains the attribute value in decimal.
1895 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1896 * length of buffer upon success.
1898 #define lpfc_vport_param_store(attr) \
1900 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1901 const char *buf, size_t count) \
1903 struct Scsi_Host *shost = class_to_shost(dev);\
1904 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1906 if (!isdigit(buf[0]))\
1908 if (sscanf(buf, "%i", &val) != 1)\
1910 if (lpfc_##attr##_set(vport, val) == 0) \
1911 return strlen(buf);\
1917 #define LPFC_ATTR(name, defval, minval, maxval, desc) \
1918 static uint lpfc_##name = defval;\
1919 module_param(lpfc_##name, uint, S_IRUGO);\
1920 MODULE_PARM_DESC(lpfc_##name, desc);\
1921 lpfc_param_init(name, defval, minval, maxval)
1923 #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \
1924 static uint lpfc_##name = defval;\
1925 module_param(lpfc_##name, uint, S_IRUGO);\
1926 MODULE_PARM_DESC(lpfc_##name, desc);\
1927 lpfc_param_show(name)\
1928 lpfc_param_init(name, defval, minval, maxval)\
1929 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1931 #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \
1932 static uint lpfc_##name = defval;\
1933 module_param(lpfc_##name, uint, S_IRUGO);\
1934 MODULE_PARM_DESC(lpfc_##name, desc);\
1935 lpfc_param_show(name)\
1936 lpfc_param_init(name, defval, minval, maxval)\
1937 lpfc_param_set(name, defval, minval, maxval)\
1938 lpfc_param_store(name)\
1939 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1940 lpfc_##name##_show, lpfc_##name##_store)
1942 #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1943 static uint lpfc_##name = defval;\
1944 module_param(lpfc_##name, uint, S_IRUGO);\
1945 MODULE_PARM_DESC(lpfc_##name, desc);\
1946 lpfc_param_hex_show(name)\
1947 lpfc_param_init(name, defval, minval, maxval)\
1948 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1950 #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1951 static uint lpfc_##name = defval;\
1952 module_param(lpfc_##name, uint, S_IRUGO);\
1953 MODULE_PARM_DESC(lpfc_##name, desc);\
1954 lpfc_param_hex_show(name)\
1955 lpfc_param_init(name, defval, minval, maxval)\
1956 lpfc_param_set(name, defval, minval, maxval)\
1957 lpfc_param_store(name)\
1958 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1959 lpfc_##name##_show, lpfc_##name##_store)
1961 #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
1962 static uint lpfc_##name = defval;\
1963 module_param(lpfc_##name, uint, S_IRUGO);\
1964 MODULE_PARM_DESC(lpfc_##name, desc);\
1965 lpfc_vport_param_init(name, defval, minval, maxval)
1967 #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
1968 static uint lpfc_##name = defval;\
1969 module_param(lpfc_##name, uint, S_IRUGO);\
1970 MODULE_PARM_DESC(lpfc_##name, desc);\
1971 lpfc_vport_param_show(name)\
1972 lpfc_vport_param_init(name, defval, minval, maxval)\
1973 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1975 #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
1976 static uint lpfc_##name = defval;\
1977 module_param(lpfc_##name, uint, S_IRUGO);\
1978 MODULE_PARM_DESC(lpfc_##name, desc);\
1979 lpfc_vport_param_show(name)\
1980 lpfc_vport_param_init(name, defval, minval, maxval)\
1981 lpfc_vport_param_set(name, defval, minval, maxval)\
1982 lpfc_vport_param_store(name)\
1983 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1984 lpfc_##name##_show, lpfc_##name##_store)
1986 #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1987 static uint lpfc_##name = defval;\
1988 module_param(lpfc_##name, uint, S_IRUGO);\
1989 MODULE_PARM_DESC(lpfc_##name, desc);\
1990 lpfc_vport_param_hex_show(name)\
1991 lpfc_vport_param_init(name, defval, minval, maxval)\
1992 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1994 #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1995 static uint lpfc_##name = defval;\
1996 module_param(lpfc_##name, uint, S_IRUGO);\
1997 MODULE_PARM_DESC(lpfc_##name, desc);\
1998 lpfc_vport_param_hex_show(name)\
1999 lpfc_vport_param_init(name, defval, minval, maxval)\
2000 lpfc_vport_param_set(name, defval, minval, maxval)\
2001 lpfc_vport_param_store(name)\
2002 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
2003 lpfc_##name##_show, lpfc_##name##_store)
2005 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
2006 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
2007 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
2008 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
2009 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
2010 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
2011 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
2012 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
2013 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
2014 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
2015 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
2016 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
2017 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
2018 lpfc_link_state_store
);
2019 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
2020 lpfc_option_rom_version_show
, NULL
);
2021 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
2022 lpfc_num_discovered_ports_show
, NULL
);
2023 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
2024 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
2025 static DEVICE_ATTR(lpfc_drvr_version
, S_IRUGO
, lpfc_drvr_version_show
, NULL
);
2026 static DEVICE_ATTR(lpfc_enable_fip
, S_IRUGO
, lpfc_enable_fip_show
, NULL
);
2027 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
2028 lpfc_board_mode_show
, lpfc_board_mode_store
);
2029 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
2030 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
2031 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
2032 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
2033 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
2034 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
2035 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
2036 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
2037 static DEVICE_ATTR(lpfc_temp_sensor
, S_IRUGO
, lpfc_temp_sensor_show
, NULL
);
2038 static DEVICE_ATTR(lpfc_fips_level
, S_IRUGO
, lpfc_fips_level_show
, NULL
);
2039 static DEVICE_ATTR(lpfc_fips_rev
, S_IRUGO
, lpfc_fips_rev_show
, NULL
);
2040 static DEVICE_ATTR(lpfc_dss
, S_IRUGO
, lpfc_dss_show
, NULL
);
2041 static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn
, S_IRUGO
,
2042 lpfc_sriov_hw_max_virtfn_show
, NULL
);
2043 static DEVICE_ATTR(protocol
, S_IRUGO
, lpfc_sli4_protocol_show
, NULL
);
2045 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
2048 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2049 * @dev: class device that is converted into a Scsi_host.
2050 * @attr: device attribute, not used.
2051 * @buf: containing the string lpfc_soft_wwn_key.
2052 * @count: must be size of lpfc_soft_wwn_key.
2055 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2056 * length of buf indicates success
2059 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
2060 const char *buf
, size_t count
)
2062 struct Scsi_Host
*shost
= class_to_shost(dev
);
2063 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2064 struct lpfc_hba
*phba
= vport
->phba
;
2065 unsigned int cnt
= count
;
2068 * We're doing a simple sanity check for soft_wwpn setting.
2069 * We require that the user write a specific key to enable
2070 * the soft_wwpn attribute to be settable. Once the attribute
2071 * is written, the enable key resets. If further updates are
2072 * desired, the key must be written again to re-enable the
2075 * The "key" is not secret - it is a hardcoded string shown
2076 * here. The intent is to protect against the random user or
2077 * application that is just writing attributes.
2080 /* count may include a LF at end of string */
2081 if (buf
[cnt
-1] == '\n')
2084 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
2085 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
2088 phba
->soft_wwn_enable
= 1;
2091 static DEVICE_ATTR(lpfc_soft_wwn_enable
, S_IWUSR
, NULL
,
2092 lpfc_soft_wwn_enable_store
);
2095 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2096 * @dev: class device that is converted into a Scsi_host.
2097 * @attr: device attribute, not used.
2098 * @buf: on return contains the wwpn in hexadecimal.
2100 * Returns: size of formatted string.
2103 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
2106 struct Scsi_Host
*shost
= class_to_shost(dev
);
2107 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2108 struct lpfc_hba
*phba
= vport
->phba
;
2110 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2111 (unsigned long long)phba
->cfg_soft_wwpn
);
2115 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2116 * @dev class device that is converted into a Scsi_host.
2117 * @attr: device attribute, not used.
2118 * @buf: contains the wwpn in hexadecimal.
2119 * @count: number of wwpn bytes in buf
2122 * -EACCES hba reset not enabled, adapter over temp
2123 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2124 * -EIO error taking adapter offline or online
2125 * value of count on success
2128 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
2129 const char *buf
, size_t count
)
2131 struct Scsi_Host
*shost
= class_to_shost(dev
);
2132 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2133 struct lpfc_hba
*phba
= vport
->phba
;
2134 struct completion online_compl
;
2135 int stat1
=0, stat2
=0;
2136 unsigned int i
, j
, cnt
=count
;
2140 if (!phba
->cfg_enable_hba_reset
)
2142 spin_lock_irq(&phba
->hbalock
);
2143 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
2144 spin_unlock_irq(&phba
->hbalock
);
2147 spin_unlock_irq(&phba
->hbalock
);
2148 /* count may include a LF at end of string */
2149 if (buf
[cnt
-1] == '\n')
2152 if (!phba
->soft_wwn_enable
|| (cnt
< 16) || (cnt
> 18) ||
2153 ((cnt
== 17) && (*buf
++ != 'x')) ||
2154 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2157 phba
->soft_wwn_enable
= 0;
2159 memset(wwpn
, 0, sizeof(wwpn
));
2161 /* Validate and store the new name */
2162 for (i
=0, j
=0; i
< 16; i
++) {
2165 value
= hex_to_bin(*buf
++);
2167 j
= (j
<< 4) | value
;
2171 wwpn
[i
/2] = j
& 0xff;
2175 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
2176 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
2177 if (phba
->cfg_soft_wwnn
)
2178 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
2180 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2181 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
2183 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
2185 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2186 "0463 lpfc_soft_wwpn attribute set failed to "
2187 "reinit adapter - %d\n", stat1
);
2188 init_completion(&online_compl
);
2189 rc
= lpfc_workq_post_event(phba
, &stat2
, &online_compl
,
2194 wait_for_completion(&online_compl
);
2196 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2197 "0464 lpfc_soft_wwpn attribute set failed to "
2198 "reinit adapter - %d\n", stat2
);
2199 return (stat1
|| stat2
) ? -EIO
: count
;
2201 static DEVICE_ATTR(lpfc_soft_wwpn
, S_IRUGO
| S_IWUSR
,\
2202 lpfc_soft_wwpn_show
, lpfc_soft_wwpn_store
);
2205 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2206 * @dev: class device that is converted into a Scsi_host.
2207 * @attr: device attribute, not used.
2208 * @buf: on return contains the wwnn in hexadecimal.
2210 * Returns: size of formatted string.
2213 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
2216 struct Scsi_Host
*shost
= class_to_shost(dev
);
2217 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2218 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2219 (unsigned long long)phba
->cfg_soft_wwnn
);
2223 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2224 * @cdev: class device that is converted into a Scsi_host.
2225 * @buf: contains the ww node name in hexadecimal.
2226 * @count: number of wwnn bytes in buf.
2229 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2230 * value of count on success
2233 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
2234 const char *buf
, size_t count
)
2236 struct Scsi_Host
*shost
= class_to_shost(dev
);
2237 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2238 unsigned int i
, j
, cnt
=count
;
2241 /* count may include a LF at end of string */
2242 if (buf
[cnt
-1] == '\n')
2245 if (!phba
->soft_wwn_enable
|| (cnt
< 16) || (cnt
> 18) ||
2246 ((cnt
== 17) && (*buf
++ != 'x')) ||
2247 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2251 * Allow wwnn to be set many times, as long as the enable is set.
2252 * However, once the wwpn is set, everything locks.
2255 memset(wwnn
, 0, sizeof(wwnn
));
2257 /* Validate and store the new name */
2258 for (i
=0, j
=0; i
< 16; i
++) {
2261 value
= hex_to_bin(*buf
++);
2263 j
= (j
<< 4) | value
;
2267 wwnn
[i
/2] = j
& 0xff;
2271 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
2273 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2274 "lpfc%d: soft_wwnn set. Value will take effect upon "
2275 "setting of the soft_wwpn\n", phba
->brd_no
);
2279 static DEVICE_ATTR(lpfc_soft_wwnn
, S_IRUGO
| S_IWUSR
,\
2280 lpfc_soft_wwnn_show
, lpfc_soft_wwnn_store
);
2283 static int lpfc_poll
= 0;
2284 module_param(lpfc_poll
, int, S_IRUGO
);
2285 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
2287 " 1 - poll with interrupts enabled"
2288 " 3 - poll and disable FCP ring interrupts");
2290 static DEVICE_ATTR(lpfc_poll
, S_IRUGO
| S_IWUSR
,
2291 lpfc_poll_show
, lpfc_poll_store
);
2293 int lpfc_sli_mode
= 0;
2294 module_param(lpfc_sli_mode
, int, S_IRUGO
);
2295 MODULE_PARM_DESC(lpfc_sli_mode
, "SLI mode selector:"
2296 " 0 - auto (SLI-3 if supported),"
2297 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
2298 " 3 - select SLI-3");
2300 int lpfc_enable_npiv
= 1;
2301 module_param(lpfc_enable_npiv
, int, S_IRUGO
);
2302 MODULE_PARM_DESC(lpfc_enable_npiv
, "Enable NPIV functionality");
2303 lpfc_param_show(enable_npiv
);
2304 lpfc_param_init(enable_npiv
, 1, 0, 1);
2305 static DEVICE_ATTR(lpfc_enable_npiv
, S_IRUGO
, lpfc_enable_npiv_show
, NULL
);
2307 LPFC_ATTR_R(fcf_failover_policy
, 1, 1, 2,
2308 "FCF Fast failover=1 Priority failover=2");
2310 int lpfc_enable_rrq
= 2;
2311 module_param(lpfc_enable_rrq
, int, S_IRUGO
);
2312 MODULE_PARM_DESC(lpfc_enable_rrq
, "Enable RRQ functionality");
2313 lpfc_param_show(enable_rrq
);
2315 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
2316 # 0x0 = disabled, XRI/OXID use not tracked.
2317 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
2318 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
2320 lpfc_param_init(enable_rrq
, 2, 0, 2);
2321 static DEVICE_ATTR(lpfc_enable_rrq
, S_IRUGO
, lpfc_enable_rrq_show
, NULL
);
2324 # lpfc_suppress_link_up: Bring link up at initialization
2325 # 0x0 = bring link up (issue MBX_INIT_LINK)
2326 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
2327 # 0x2 = never bring up link
2328 # Default value is 0.
2330 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
2331 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
2332 "Suppress Link Up at initialization");
2334 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
2342 lpfc_iocb_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
2344 struct Scsi_Host
*shost
= class_to_shost(dev
);
2345 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2347 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->iocb_max
);
2350 static DEVICE_ATTR(iocb_hw
, S_IRUGO
,
2351 lpfc_iocb_hw_show
, NULL
);
2353 lpfc_txq_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
2355 struct Scsi_Host
*shost
= class_to_shost(dev
);
2356 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2358 return snprintf(buf
, PAGE_SIZE
, "%d\n",
2359 phba
->sli
.ring
[LPFC_ELS_RING
].txq_max
);
2362 static DEVICE_ATTR(txq_hw
, S_IRUGO
,
2363 lpfc_txq_hw_show
, NULL
);
2365 lpfc_txcmplq_hw_show(struct device
*dev
, struct device_attribute
*attr
,
2368 struct Scsi_Host
*shost
= class_to_shost(dev
);
2369 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2371 return snprintf(buf
, PAGE_SIZE
, "%d\n",
2372 phba
->sli
.ring
[LPFC_ELS_RING
].txcmplq_max
);
2375 static DEVICE_ATTR(txcmplq_hw
, S_IRUGO
,
2376 lpfc_txcmplq_hw_show
, NULL
);
2378 int lpfc_iocb_cnt
= 2;
2379 module_param(lpfc_iocb_cnt
, int, S_IRUGO
);
2380 MODULE_PARM_DESC(lpfc_iocb_cnt
,
2381 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
2382 lpfc_param_show(iocb_cnt
);
2383 lpfc_param_init(iocb_cnt
, 2, 1, 5);
2384 static DEVICE_ATTR(lpfc_iocb_cnt
, S_IRUGO
,
2385 lpfc_iocb_cnt_show
, NULL
);
2388 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
2389 # until the timer expires. Value range is [0,255]. Default value is 30.
2391 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2392 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2393 module_param(lpfc_nodev_tmo
, int, 0);
2394 MODULE_PARM_DESC(lpfc_nodev_tmo
,
2395 "Seconds driver will hold I/O waiting "
2396 "for a device to come back");
2399 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
2400 * @dev: class converted to a Scsi_host structure.
2401 * @attr: device attribute, not used.
2402 * @buf: on return contains the dev loss timeout in decimal.
2404 * Returns: size of formatted string.
2407 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
2410 struct Scsi_Host
*shost
= class_to_shost(dev
);
2411 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2413 return snprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
2417 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
2418 * @vport: lpfc vport structure pointer.
2419 * @val: contains the nodev timeout value.
2422 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
2423 * a kernel error message is printed and zero is returned.
2424 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2425 * Otherwise nodev tmo is set to the default value.
2428 * zero if already set or if val is in range
2429 * -EINVAL val out of range
2432 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
2434 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
2435 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
2436 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
2437 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2438 "0407 Ignoring nodev_tmo module "
2439 "parameter because devloss_tmo is "
2444 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2445 vport
->cfg_nodev_tmo
= val
;
2446 vport
->cfg_devloss_tmo
= val
;
2449 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2450 "0400 lpfc_nodev_tmo attribute cannot be set to"
2451 " %d, allowed range is [%d, %d]\n",
2452 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2453 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2458 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
2459 * @vport: lpfc vport structure pointer.
2462 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
2465 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
2467 struct Scsi_Host
*shost
;
2468 struct lpfc_nodelist
*ndlp
;
2470 shost
= lpfc_shost_from_vport(vport
);
2471 spin_lock_irq(shost
->host_lock
);
2472 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
)
2473 if (NLP_CHK_NODE_ACT(ndlp
) && ndlp
->rport
)
2474 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
2475 spin_unlock_irq(shost
->host_lock
);
2479 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
2480 * @vport: lpfc vport structure pointer.
2481 * @val: contains the tmo value.
2484 * If the devloss tmo is already set or the vport dev loss tmo has changed
2485 * then a kernel error message is printed and zero is returned.
2486 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2487 * Otherwise nodev tmo is set to the default value.
2490 * zero if already set or if val is in range
2491 * -EINVAL val out of range
2494 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
2496 if (vport
->dev_loss_tmo_changed
||
2497 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
2498 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2499 "0401 Ignoring change to nodev_tmo "
2500 "because devloss_tmo is set.\n");
2503 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2504 vport
->cfg_nodev_tmo
= val
;
2505 vport
->cfg_devloss_tmo
= val
;
2507 * For compat: set the fc_host dev loss so new rports
2508 * will get the value.
2510 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
2511 lpfc_update_rport_devloss_tmo(vport
);
2514 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2515 "0403 lpfc_nodev_tmo attribute cannot be set to"
2516 "%d, allowed range is [%d, %d]\n",
2517 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2521 lpfc_vport_param_store(nodev_tmo
)
2523 static DEVICE_ATTR(lpfc_nodev_tmo
, S_IRUGO
| S_IWUSR
,
2524 lpfc_nodev_tmo_show
, lpfc_nodev_tmo_store
);
2527 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
2528 # disappear until the timer expires. Value range is [0,255]. Default
2531 module_param(lpfc_devloss_tmo
, int, S_IRUGO
);
2532 MODULE_PARM_DESC(lpfc_devloss_tmo
,
2533 "Seconds driver will hold I/O waiting "
2534 "for a device to come back");
2535 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
2536 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
2537 lpfc_vport_param_show(devloss_tmo
)
2540 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
2541 * @vport: lpfc vport structure pointer.
2542 * @val: contains the tmo value.
2545 * If val is in a valid range then set the vport nodev tmo,
2546 * devloss tmo, also set the vport dev loss tmo changed flag.
2547 * Else a kernel error message is printed.
2550 * zero if val is in range
2551 * -EINVAL val out of range
2554 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
2556 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2557 vport
->cfg_nodev_tmo
= val
;
2558 vport
->cfg_devloss_tmo
= val
;
2559 vport
->dev_loss_tmo_changed
= 1;
2560 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
2561 lpfc_update_rport_devloss_tmo(vport
);
2565 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2566 "0404 lpfc_devloss_tmo attribute cannot be set to"
2567 " %d, allowed range is [%d, %d]\n",
2568 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2572 lpfc_vport_param_store(devloss_tmo
)
2573 static DEVICE_ATTR(lpfc_devloss_tmo
, S_IRUGO
| S_IWUSR
,
2574 lpfc_devloss_tmo_show
, lpfc_devloss_tmo_store
);
2577 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
2578 # deluged with LOTS of information.
2579 # You can set a bit mask to record specific types of verbose messages:
2580 # See lpfc_logmsh.h for definitions.
2582 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
2583 "Verbose logging bit-mask");
2586 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
2587 # objects that have been registered with the nameserver after login.
2589 LPFC_VPORT_ATTR_R(enable_da_id
, 1, 0, 1,
2590 "Deregister nameserver objects before LOGO");
2593 # lun_queue_depth: This parameter is used to limit the number of outstanding
2594 # commands per FCP LUN. Value range is [1,128]. Default value is 30.
2596 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 128,
2597 "Max number of FCP commands we can queue to a specific LUN");
2600 # tgt_queue_depth: This parameter is used to limit the number of outstanding
2601 # commands per target port. Value range is [10,65535]. Default value is 65535.
2603 LPFC_VPORT_ATTR_R(tgt_queue_depth
, 65535, 10, 65535,
2604 "Max number of FCP commands we can queue to a specific target port");
2607 # hba_queue_depth: This parameter is used to limit the number of outstanding
2608 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
2609 # value is greater than the maximum number of exchanges supported by the HBA,
2610 # then maximum number of exchanges supported by the HBA is used to determine
2611 # the hba_queue_depth.
2613 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
2614 "Max number of FCP commands we can queue to a lpfc HBA");
2617 # peer_port_login: This parameter allows/prevents logins
2618 # between peer ports hosted on the same physical port.
2619 # When this parameter is set 0 peer ports of same physical port
2620 # are not allowed to login to each other.
2621 # When this parameter is set 1 peer ports of same physical port
2622 # are allowed to login to each other.
2623 # Default value of this parameter is 0.
2625 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
2626 "Allow peer ports on the same physical port to login to each "
2630 # restrict_login: This parameter allows/prevents logins
2631 # between Virtual Ports and remote initiators.
2632 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
2633 # other initiators and will attempt to PLOGI all remote ports.
2634 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
2635 # remote ports and will not attempt to PLOGI to other initiators.
2636 # This parameter does not restrict to the physical port.
2637 # This parameter does not restrict logins to Fabric resident remote ports.
2638 # Default value of this parameter is 1.
2640 static int lpfc_restrict_login
= 1;
2641 module_param(lpfc_restrict_login
, int, S_IRUGO
);
2642 MODULE_PARM_DESC(lpfc_restrict_login
,
2643 "Restrict virtual ports login to remote initiators.");
2644 lpfc_vport_param_show(restrict_login
);
2647 * lpfc_restrict_login_init - Set the vport restrict login flag
2648 * @vport: lpfc vport structure pointer.
2649 * @val: contains the restrict login value.
2652 * If val is not in a valid range then log a kernel error message and set
2653 * the vport restrict login to one.
2654 * If the port type is physical clear the restrict login flag and return.
2655 * Else set the restrict login flag to val.
2658 * zero if val is in range
2659 * -EINVAL val out of range
2662 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
2664 if (val
< 0 || val
> 1) {
2665 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2666 "0422 lpfc_restrict_login attribute cannot "
2667 "be set to %d, allowed range is [0, 1]\n",
2669 vport
->cfg_restrict_login
= 1;
2672 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
2673 vport
->cfg_restrict_login
= 0;
2676 vport
->cfg_restrict_login
= val
;
2681 * lpfc_restrict_login_set - Set the vport restrict login flag
2682 * @vport: lpfc vport structure pointer.
2683 * @val: contains the restrict login value.
2686 * If val is not in a valid range then log a kernel error message and set
2687 * the vport restrict login to one.
2688 * If the port type is physical and the val is not zero log a kernel
2689 * error message, clear the restrict login flag and return zero.
2690 * Else set the restrict login flag to val.
2693 * zero if val is in range
2694 * -EINVAL val out of range
2697 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
2699 if (val
< 0 || val
> 1) {
2700 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2701 "0425 lpfc_restrict_login attribute cannot "
2702 "be set to %d, allowed range is [0, 1]\n",
2704 vport
->cfg_restrict_login
= 1;
2707 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
2708 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2709 "0468 lpfc_restrict_login must be 0 for "
2710 "Physical ports.\n");
2711 vport
->cfg_restrict_login
= 0;
2714 vport
->cfg_restrict_login
= val
;
2717 lpfc_vport_param_store(restrict_login
);
2718 static DEVICE_ATTR(lpfc_restrict_login
, S_IRUGO
| S_IWUSR
,
2719 lpfc_restrict_login_show
, lpfc_restrict_login_store
);
2722 # Some disk devices have a "select ID" or "select Target" capability.
2723 # From a protocol standpoint "select ID" usually means select the
2724 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
2725 # annex" which contains a table that maps a "select ID" (a number
2726 # between 0 and 7F) to an ALPA. By default, for compatibility with
2727 # older drivers, the lpfc driver scans this table from low ALPA to high
2730 # Turning on the scan-down variable (on = 1, off = 0) will
2731 # cause the lpfc driver to use an inverted table, effectively
2732 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
2734 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
2735 # and will not work across a fabric. Also this parameter will take
2736 # effect only in the case when ALPA map is not available.)
2738 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
2739 "Start scanning for devices from highest ALPA to lowest");
2742 # lpfc_topology: link topology for init link
2743 # 0x0 = attempt loop mode then point-to-point
2744 # 0x01 = internal loopback mode
2745 # 0x02 = attempt point-to-point mode only
2746 # 0x04 = attempt loop mode only
2747 # 0x06 = attempt point-to-point mode then loop
2748 # Set point-to-point mode if you want to run as an N_Port.
2749 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
2750 # Default value is 0.
2754 * lpfc_topology_set - Set the adapters topology field
2755 * @phba: lpfc_hba pointer.
2756 * @val: topology value.
2759 * If val is in a valid range then set the adapter's topology field and
2760 * issue a lip; if the lip fails reset the topology to the old value.
2762 * If the value is not in range log a kernel error message and return an error.
2765 * zero if val is in range and lip okay
2766 * non-zero return value from lpfc_issue_lip()
2767 * -EINVAL val out of range
2770 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
2771 const char *buf
, size_t count
)
2773 struct Scsi_Host
*shost
= class_to_shost(dev
);
2774 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2775 struct lpfc_hba
*phba
= vport
->phba
;
2778 const char *val_buf
= buf
;
2782 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
2784 val_buf
= &buf
[strlen("nolip ")];
2787 if (!isdigit(val_buf
[0]))
2789 if (sscanf(val_buf
, "%i", &val
) != 1)
2792 if (val
>= 0 && val
<= 6) {
2793 prev_val
= phba
->cfg_topology
;
2794 phba
->cfg_topology
= val
;
2795 if (phba
->cfg_link_speed
== LPFC_USER_LINK_SPEED_16G
&&
2797 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2798 "3113 Loop mode not supported at speed %d\n",
2799 phba
->cfg_link_speed
);
2800 phba
->cfg_topology
= prev_val
;
2806 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2807 "3054 lpfc_topology changed from %d to %d\n",
2809 if (prev_val
!= val
&& phba
->sli_rev
== LPFC_SLI_REV4
)
2810 phba
->fc_topology_changed
= 1;
2811 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
2813 phba
->cfg_topology
= prev_val
;
2818 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2819 "%d:0467 lpfc_topology attribute cannot be set to %d, "
2820 "allowed range is [0, 6]\n",
2824 static int lpfc_topology
= 0;
2825 module_param(lpfc_topology
, int, S_IRUGO
);
2826 MODULE_PARM_DESC(lpfc_topology
, "Select Fibre Channel topology");
2827 lpfc_param_show(topology
)
2828 lpfc_param_init(topology
, 0, 0, 6)
2829 static DEVICE_ATTR(lpfc_topology
, S_IRUGO
| S_IWUSR
,
2830 lpfc_topology_show
, lpfc_topology_store
);
2833 * lpfc_static_vport_show: Read callback function for
2834 * lpfc_static_vport sysfs file.
2835 * @dev: Pointer to class device object.
2836 * @attr: device attribute structure.
2837 * @buf: Data buffer.
2839 * This function is the read call back function for
2840 * lpfc_static_vport sysfs file. The lpfc_static_vport
2841 * sysfs file report the mageability of the vport.
2844 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
2847 struct Scsi_Host
*shost
= class_to_shost(dev
);
2848 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2849 if (vport
->vport_flag
& STATIC_VPORT
)
2850 sprintf(buf
, "1\n");
2852 sprintf(buf
, "0\n");
2858 * Sysfs attribute to control the statistical data collection.
2860 static DEVICE_ATTR(lpfc_static_vport
, S_IRUGO
,
2861 lpfc_static_vport_show
, NULL
);
2864 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
2865 * @dev: Pointer to class device.
2866 * @buf: Data buffer.
2867 * @count: Size of the data buffer.
2869 * This function get called when an user write to the lpfc_stat_data_ctrl
2870 * sysfs file. This function parse the command written to the sysfs file
2871 * and take appropriate action. These commands are used for controlling
2872 * driver statistical data collection.
2873 * Following are the command this function handles.
2875 * setbucket <bucket_type> <base> <step>
2876 * = Set the latency buckets.
2877 * destroybucket = destroy all the buckets.
2878 * start = start data collection
2879 * stop = stop data collection
2880 * reset = reset the collected data
2883 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
2884 const char *buf
, size_t count
)
2886 struct Scsi_Host
*shost
= class_to_shost(dev
);
2887 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2888 struct lpfc_hba
*phba
= vport
->phba
;
2889 #define LPFC_MAX_DATA_CTRL_LEN 1024
2890 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
2892 char *str_ptr
, *token
;
2893 struct lpfc_vport
**vports
;
2894 struct Scsi_Host
*v_shost
;
2895 char *bucket_type_str
, *base_str
, *step_str
;
2896 unsigned long base
, step
, bucket_type
;
2898 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
2899 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
2902 strcpy(bucket_data
, buf
);
2903 str_ptr
= &bucket_data
[0];
2904 /* Ignore this token - this is command token */
2905 token
= strsep(&str_ptr
, "\t ");
2909 bucket_type_str
= strsep(&str_ptr
, "\t ");
2910 if (!bucket_type_str
)
2913 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
2914 bucket_type
= LPFC_LINEAR_BUCKET
;
2915 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
2916 bucket_type
= LPFC_POWER2_BUCKET
;
2920 base_str
= strsep(&str_ptr
, "\t ");
2923 base
= simple_strtoul(base_str
, NULL
, 0);
2925 step_str
= strsep(&str_ptr
, "\t ");
2928 step
= simple_strtoul(step_str
, NULL
, 0);
2932 /* Block the data collection for every vport */
2933 vports
= lpfc_create_vport_work_array(phba
);
2937 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
2938 v_shost
= lpfc_shost_from_vport(vports
[i
]);
2939 spin_lock_irq(v_shost
->host_lock
);
2940 /* Block and reset data collection */
2941 vports
[i
]->stat_data_blocked
= 1;
2942 if (vports
[i
]->stat_data_enabled
)
2943 lpfc_vport_reset_stat_data(vports
[i
]);
2944 spin_unlock_irq(v_shost
->host_lock
);
2947 /* Set the bucket attributes */
2948 phba
->bucket_type
= bucket_type
;
2949 phba
->bucket_base
= base
;
2950 phba
->bucket_step
= step
;
2952 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
2953 v_shost
= lpfc_shost_from_vport(vports
[i
]);
2955 /* Unblock data collection */
2956 spin_lock_irq(v_shost
->host_lock
);
2957 vports
[i
]->stat_data_blocked
= 0;
2958 spin_unlock_irq(v_shost
->host_lock
);
2960 lpfc_destroy_vport_work_array(phba
, vports
);
2964 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
2965 vports
= lpfc_create_vport_work_array(phba
);
2969 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
2970 v_shost
= lpfc_shost_from_vport(vports
[i
]);
2971 spin_lock_irq(shost
->host_lock
);
2972 vports
[i
]->stat_data_blocked
= 1;
2973 lpfc_free_bucket(vport
);
2974 vport
->stat_data_enabled
= 0;
2975 vports
[i
]->stat_data_blocked
= 0;
2976 spin_unlock_irq(shost
->host_lock
);
2978 lpfc_destroy_vport_work_array(phba
, vports
);
2979 phba
->bucket_type
= LPFC_NO_BUCKET
;
2980 phba
->bucket_base
= 0;
2981 phba
->bucket_step
= 0;
2985 if (!strncmp(buf
, "start", strlen("start"))) {
2986 /* If no buckets configured return error */
2987 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
2989 spin_lock_irq(shost
->host_lock
);
2990 if (vport
->stat_data_enabled
) {
2991 spin_unlock_irq(shost
->host_lock
);
2994 lpfc_alloc_bucket(vport
);
2995 vport
->stat_data_enabled
= 1;
2996 spin_unlock_irq(shost
->host_lock
);
3000 if (!strncmp(buf
, "stop", strlen("stop"))) {
3001 spin_lock_irq(shost
->host_lock
);
3002 if (vport
->stat_data_enabled
== 0) {
3003 spin_unlock_irq(shost
->host_lock
);
3006 lpfc_free_bucket(vport
);
3007 vport
->stat_data_enabled
= 0;
3008 spin_unlock_irq(shost
->host_lock
);
3012 if (!strncmp(buf
, "reset", strlen("reset"))) {
3013 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
3014 || !vport
->stat_data_enabled
)
3016 spin_lock_irq(shost
->host_lock
);
3017 vport
->stat_data_blocked
= 1;
3018 lpfc_vport_reset_stat_data(vport
);
3019 vport
->stat_data_blocked
= 0;
3020 spin_unlock_irq(shost
->host_lock
);
3028 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
3029 * @dev: Pointer to class device object.
3030 * @buf: Data buffer.
3032 * This function is the read call back function for
3033 * lpfc_stat_data_ctrl sysfs file. This function report the
3034 * current statistical data collection state.
3037 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
3040 struct Scsi_Host
*shost
= class_to_shost(dev
);
3041 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3042 struct lpfc_hba
*phba
= vport
->phba
;
3046 unsigned long bucket_value
;
3048 switch (phba
->bucket_type
) {
3049 case LPFC_LINEAR_BUCKET
:
3050 bucket_type
= "linear";
3052 case LPFC_POWER2_BUCKET
:
3053 bucket_type
= "power2";
3056 bucket_type
= "No Bucket";
3060 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
3061 "blocked :%d, Bucket type :%s, Bucket base :%d,"
3062 " Bucket step :%d\nLatency Ranges :",
3063 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
3064 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
3065 index
= strlen(buf
);
3066 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
3067 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3068 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
3069 bucket_value
= phba
->bucket_base
+
3070 phba
->bucket_step
* i
;
3072 bucket_value
= phba
->bucket_base
+
3073 (1 << i
) * phba
->bucket_step
;
3075 if (index
+ 10 > PAGE_SIZE
)
3077 sprintf(&buf
[index
], "%08ld ", bucket_value
);
3078 index
= strlen(buf
);
3081 sprintf(&buf
[index
], "\n");
3086 * Sysfs attribute to control the statistical data collection.
3088 static DEVICE_ATTR(lpfc_stat_data_ctrl
, S_IRUGO
| S_IWUSR
,
3089 lpfc_stat_data_ctrl_show
, lpfc_stat_data_ctrl_store
);
3092 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
3096 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
3099 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
3100 #define MAX_STAT_DATA_SIZE_PER_TARGET \
3101 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
3105 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
3107 * @kobj: Pointer to the kernel object
3108 * @bin_attr: Attribute object
3109 * @buff: Buffer pointer
3111 * @count: Buffer size
3113 * This function is the read call back function for lpfc_drvr_stat_data
3114 * sysfs file. This function export the statistical data to user
3118 sysfs_drvr_stat_data_read(struct file
*filp
, struct kobject
*kobj
,
3119 struct bin_attribute
*bin_attr
,
3120 char *buf
, loff_t off
, size_t count
)
3122 struct device
*dev
= container_of(kobj
, struct device
,
3124 struct Scsi_Host
*shost
= class_to_shost(dev
);
3125 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3126 struct lpfc_hba
*phba
= vport
->phba
;
3127 int i
= 0, index
= 0;
3128 unsigned long nport_index
;
3129 struct lpfc_nodelist
*ndlp
= NULL
;
3130 nport_index
= (unsigned long)off
/
3131 MAX_STAT_DATA_SIZE_PER_TARGET
;
3133 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
3134 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
3137 spin_lock_irq(shost
->host_lock
);
3138 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3139 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
3142 if (nport_index
> 0) {
3147 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
3151 if (!ndlp
->lat_data
)
3155 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
3156 ndlp
->nlp_portname
.u
.wwn
[0],
3157 ndlp
->nlp_portname
.u
.wwn
[1],
3158 ndlp
->nlp_portname
.u
.wwn
[2],
3159 ndlp
->nlp_portname
.u
.wwn
[3],
3160 ndlp
->nlp_portname
.u
.wwn
[4],
3161 ndlp
->nlp_portname
.u
.wwn
[5],
3162 ndlp
->nlp_portname
.u
.wwn
[6],
3163 ndlp
->nlp_portname
.u
.wwn
[7]);
3165 index
= strlen(buf
);
3167 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3168 sprintf(&buf
[index
], "%010u,",
3169 ndlp
->lat_data
[i
].cmd_count
);
3170 index
= strlen(buf
);
3172 sprintf(&buf
[index
], "\n");
3173 index
= strlen(buf
);
3175 spin_unlock_irq(shost
->host_lock
);
3179 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
3181 .name
= "lpfc_drvr_stat_data",
3184 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
3185 .read
= sysfs_drvr_stat_data_read
,
3190 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
3192 # Value range is [0,16]. Default value is 0.
3195 * lpfc_link_speed_set - Set the adapters link speed
3196 * @phba: lpfc_hba pointer.
3197 * @val: link speed value.
3200 * If val is in a valid range then set the adapter's link speed field and
3201 * issue a lip; if the lip fails reset the link speed to the old value.
3204 * If the value is not in range log a kernel error message and return an error.
3207 * zero if val is in range and lip okay.
3208 * non-zero return value from lpfc_issue_lip()
3209 * -EINVAL val out of range
3212 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
3213 const char *buf
, size_t count
)
3215 struct Scsi_Host
*shost
= class_to_shost(dev
);
3216 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3217 struct lpfc_hba
*phba
= vport
->phba
;
3218 int val
= LPFC_USER_LINK_SPEED_AUTO
;
3220 const char *val_buf
= buf
;
3224 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
3226 val_buf
= &buf
[strlen("nolip ")];
3229 if (!isdigit(val_buf
[0]))
3231 if (sscanf(val_buf
, "%i", &val
) != 1)
3234 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3235 "3055 lpfc_link_speed changed from %d to %d %s\n",
3236 phba
->cfg_link_speed
, val
, nolip
? "(nolip)" : "(lip)");
3238 if (((val
== LPFC_USER_LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
3239 ((val
== LPFC_USER_LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
3240 ((val
== LPFC_USER_LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
3241 ((val
== LPFC_USER_LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
3242 ((val
== LPFC_USER_LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)) ||
3243 ((val
== LPFC_USER_LINK_SPEED_16G
) && !(phba
->lmt
& LMT_16Gb
))) {
3244 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3245 "2879 lpfc_link_speed attribute cannot be set "
3246 "to %d. Speed is not supported by this port.\n",
3250 if (val
== LPFC_USER_LINK_SPEED_16G
&&
3251 phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
3252 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3253 "3112 lpfc_link_speed attribute cannot be set "
3254 "to %d. Speed is not supported in loop mode.\n",
3258 if ((val
>= 0) && (val
<= LPFC_USER_LINK_SPEED_MAX
) &&
3259 (LPFC_USER_LINK_SPEED_BITMAP
& (1 << val
))) {
3260 prev_val
= phba
->cfg_link_speed
;
3261 phba
->cfg_link_speed
= val
;
3265 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
3267 phba
->cfg_link_speed
= prev_val
;
3272 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3273 "0469 lpfc_link_speed attribute cannot be set to %d, "
3274 "allowed values are ["LPFC_LINK_SPEED_STRING
"]\n", val
);
3278 static int lpfc_link_speed
= 0;
3279 module_param(lpfc_link_speed
, int, S_IRUGO
);
3280 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
3281 lpfc_param_show(link_speed
)
3284 * lpfc_link_speed_init - Set the adapters link speed
3285 * @phba: lpfc_hba pointer.
3286 * @val: link speed value.
3289 * If val is in a valid range then set the adapter's link speed field.
3292 * If the value is not in range log a kernel error message, clear the link
3293 * speed and return an error.
3296 * zero if val saved.
3297 * -EINVAL val out of range
3300 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
3302 if (val
== LPFC_USER_LINK_SPEED_16G
&& phba
->cfg_topology
== 4) {
3303 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3304 "3111 lpfc_link_speed of %d cannot "
3305 "support loop mode, setting topology to default.\n",
3307 phba
->cfg_topology
= 0;
3309 if ((val
>= 0) && (val
<= LPFC_USER_LINK_SPEED_MAX
) &&
3310 (LPFC_USER_LINK_SPEED_BITMAP
& (1 << val
))) {
3311 phba
->cfg_link_speed
= val
;
3314 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3315 "0405 lpfc_link_speed attribute cannot "
3316 "be set to %d, allowed values are "
3317 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
3318 phba
->cfg_link_speed
= LPFC_USER_LINK_SPEED_AUTO
;
3322 static DEVICE_ATTR(lpfc_link_speed
, S_IRUGO
| S_IWUSR
,
3323 lpfc_link_speed_show
, lpfc_link_speed_store
);
3326 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
3327 # 0 = aer disabled or not supported
3328 # 1 = aer supported and enabled (default)
3329 # Value range is [0,1]. Default value is 1.
3333 * lpfc_aer_support_store - Set the adapter for aer support
3335 * @dev: class device that is converted into a Scsi_host.
3336 * @attr: device attribute, not used.
3337 * @buf: containing enable or disable aer flag.
3338 * @count: unused variable.
3341 * If the val is 1 and currently the device's AER capability was not
3342 * enabled, invoke the kernel's enable AER helper routine, trying to
3343 * enable the device's AER capability. If the helper routine enabling
3344 * AER returns success, update the device's cfg_aer_support flag to
3345 * indicate AER is supported by the device; otherwise, if the device
3346 * AER capability is already enabled to support AER, then do nothing.
3348 * If the val is 0 and currently the device's AER support was enabled,
3349 * invoke the kernel's disable AER helper routine. After that, update
3350 * the device's cfg_aer_support flag to indicate AER is not supported
3351 * by the device; otherwise, if the device AER capability is already
3352 * disabled from supporting AER, then do nothing.
3355 * length of the buf on success if val is in range the intended mode
3357 * -EINVAL if val out of range or intended mode is not supported.
3360 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
3361 const char *buf
, size_t count
)
3363 struct Scsi_Host
*shost
= class_to_shost(dev
);
3364 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
3365 struct lpfc_hba
*phba
= vport
->phba
;
3366 int val
= 0, rc
= -EINVAL
;
3368 if (!isdigit(buf
[0]))
3370 if (sscanf(buf
, "%i", &val
) != 1)
3375 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
3376 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
3378 spin_lock_irq(&phba
->hbalock
);
3379 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
3380 spin_unlock_irq(&phba
->hbalock
);
3381 phba
->cfg_aer_support
= 0;
3386 phba
->cfg_aer_support
= 0;
3391 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
3392 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
3394 spin_lock_irq(&phba
->hbalock
);
3395 phba
->hba_flag
|= HBA_AER_ENABLED
;
3396 spin_unlock_irq(&phba
->hbalock
);
3397 phba
->cfg_aer_support
= 1;
3402 phba
->cfg_aer_support
= 1;
3413 static int lpfc_aer_support
= 1;
3414 module_param(lpfc_aer_support
, int, S_IRUGO
);
3415 MODULE_PARM_DESC(lpfc_aer_support
, "Enable PCIe device AER support");
3416 lpfc_param_show(aer_support
)
3419 * lpfc_aer_support_init - Set the initial adapters aer support flag
3420 * @phba: lpfc_hba pointer.
3421 * @val: enable aer or disable aer flag.
3424 * If val is in a valid range [0,1], then set the adapter's initial
3425 * cfg_aer_support field. It will be up to the driver's probe_one
3426 * routine to determine whether the device's AER support can be set
3430 * If the value is not in range log a kernel error message, and
3431 * choose the default value of setting AER support and return.
3434 * zero if val saved.
3435 * -EINVAL val out of range
3438 lpfc_aer_support_init(struct lpfc_hba
*phba
, int val
)
3440 if (val
== 0 || val
== 1) {
3441 phba
->cfg_aer_support
= val
;
3444 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3445 "2712 lpfc_aer_support attribute value %d out "
3446 "of range, allowed values are 0|1, setting it "
3447 "to default value of 1\n", val
);
3448 /* By default, try to enable AER on a device */
3449 phba
->cfg_aer_support
= 1;
3453 static DEVICE_ATTR(lpfc_aer_support
, S_IRUGO
| S_IWUSR
,
3454 lpfc_aer_support_show
, lpfc_aer_support_store
);
3457 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
3458 * @dev: class device that is converted into a Scsi_host.
3459 * @attr: device attribute, not used.
3460 * @buf: containing flag 1 for aer cleanup state.
3461 * @count: unused variable.
3464 * If the @buf contains 1 and the device currently has the AER support
3465 * enabled, then invokes the kernel AER helper routine
3466 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
3467 * error status register.
3472 * -EINVAL if the buf does not contain the 1 or the device is not currently
3473 * enabled with the AER support.
3476 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
3477 const char *buf
, size_t count
)
3479 struct Scsi_Host
*shost
= class_to_shost(dev
);
3480 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3481 struct lpfc_hba
*phba
= vport
->phba
;
3484 if (!isdigit(buf
[0]))
3486 if (sscanf(buf
, "%i", &val
) != 1)
3491 if (phba
->hba_flag
& HBA_AER_ENABLED
)
3492 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
3500 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
3501 lpfc_aer_cleanup_state
);
3504 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
3506 * @dev: class device that is converted into a Scsi_host.
3507 * @attr: device attribute, not used.
3508 * @buf: containing the string the number of vfs to be enabled.
3509 * @count: unused variable.
3512 * When this api is called either through user sysfs, the driver shall
3513 * try to enable or disable SR-IOV virtual functions according to the
3516 * If zero virtual function has been enabled to the physical function,
3517 * the driver shall invoke the pci enable virtual function api trying
3518 * to enable the virtual functions. If the nr_vfn provided is greater
3519 * than the maximum supported, the maximum virtual function number will
3520 * be used for invoking the api; otherwise, the nr_vfn provided shall
3521 * be used for invoking the api. If the api call returned success, the
3522 * actual number of virtual functions enabled will be set to the driver
3523 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
3524 * cfg_sriov_nr_virtfn remains zero.
3526 * If none-zero virtual functions have already been enabled to the
3527 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
3528 * -EINVAL will be returned and the driver does nothing;
3530 * If the nr_vfn provided is zero and none-zero virtual functions have
3531 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
3532 * disabling virtual function api shall be invoded to disable all the
3533 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
3534 * zero. Otherwise, if zero virtual function has been enabled, do
3538 * length of the buf on success if val is in range the intended mode
3540 * -EINVAL if val out of range or intended mode is not supported.
3543 lpfc_sriov_nr_virtfn_store(struct device
*dev
, struct device_attribute
*attr
,
3544 const char *buf
, size_t count
)
3546 struct Scsi_Host
*shost
= class_to_shost(dev
);
3547 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
3548 struct lpfc_hba
*phba
= vport
->phba
;
3549 struct pci_dev
*pdev
= phba
->pcidev
;
3550 int val
= 0, rc
= -EINVAL
;
3552 /* Sanity check on user data */
3553 if (!isdigit(buf
[0]))
3555 if (sscanf(buf
, "%i", &val
) != 1)
3560 /* Request disabling virtual functions */
3562 if (phba
->cfg_sriov_nr_virtfn
> 0) {
3563 pci_disable_sriov(pdev
);
3564 phba
->cfg_sriov_nr_virtfn
= 0;
3569 /* Request enabling virtual functions */
3570 if (phba
->cfg_sriov_nr_virtfn
> 0) {
3571 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3572 "3018 There are %d virtual functions "
3573 "enabled on physical function.\n",
3574 phba
->cfg_sriov_nr_virtfn
);
3578 if (val
<= LPFC_MAX_VFN_PER_PFN
)
3579 phba
->cfg_sriov_nr_virtfn
= val
;
3581 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3582 "3019 Enabling %d virtual functions is not "
3587 rc
= lpfc_sli_probe_sriov_nr_virtfn(phba
, phba
->cfg_sriov_nr_virtfn
);
3589 phba
->cfg_sriov_nr_virtfn
= 0;
3597 static int lpfc_sriov_nr_virtfn
= LPFC_DEF_VFN_PER_PFN
;
3598 module_param(lpfc_sriov_nr_virtfn
, int, S_IRUGO
|S_IWUSR
);
3599 MODULE_PARM_DESC(lpfc_sriov_nr_virtfn
, "Enable PCIe device SR-IOV virtual fn");
3600 lpfc_param_show(sriov_nr_virtfn
)
3603 * lpfc_sriov_nr_virtfn_init - Set the initial sr-iov virtual function enable
3604 * @phba: lpfc_hba pointer.
3605 * @val: link speed value.
3608 * If val is in a valid range [0,255], then set the adapter's initial
3609 * cfg_sriov_nr_virtfn field. If it's greater than the maximum, the maximum
3610 * number shall be used instead. It will be up to the driver's probe_one
3611 * routine to determine whether the device's SR-IOV is supported or not.
3614 * zero if val saved.
3615 * -EINVAL val out of range
3618 lpfc_sriov_nr_virtfn_init(struct lpfc_hba
*phba
, int val
)
3620 if (val
>= 0 && val
<= LPFC_MAX_VFN_PER_PFN
) {
3621 phba
->cfg_sriov_nr_virtfn
= val
;
3625 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3626 "3017 Enabling %d virtual functions is not "
3630 static DEVICE_ATTR(lpfc_sriov_nr_virtfn
, S_IRUGO
| S_IWUSR
,
3631 lpfc_sriov_nr_virtfn_show
, lpfc_sriov_nr_virtfn_store
);
3634 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
3636 * @dev: class device that is converted into a Scsi_host.
3637 * @attr: device attribute, not used.
3638 * @buf: containing the string the number of vfs to be enabled.
3639 * @count: unused variable.
3644 * length of the buf on success if val is in range the intended mode
3646 * -EINVAL if val out of range or intended mode is not supported.
3649 lpfc_request_firmware_upgrade_store(struct device
*dev
,
3650 struct device_attribute
*attr
,
3651 const char *buf
, size_t count
)
3653 struct Scsi_Host
*shost
= class_to_shost(dev
);
3654 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
3655 struct lpfc_hba
*phba
= vport
->phba
;
3656 int val
= 0, rc
= -EINVAL
;
3658 /* Sanity check on user data */
3659 if (!isdigit(buf
[0]))
3661 if (sscanf(buf
, "%i", &val
) != 1)
3666 rc
= lpfc_sli4_request_firmware_update(phba
, RUN_FW_UPGRADE
);
3674 static int lpfc_req_fw_upgrade
;
3675 module_param(lpfc_req_fw_upgrade
, int, S_IRUGO
|S_IWUSR
);
3676 MODULE_PARM_DESC(lpfc_req_fw_upgrade
, "Enable Linux generic firmware upgrade");
3677 lpfc_param_show(request_firmware_upgrade
)
3680 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
3681 * @phba: lpfc_hba pointer.
3685 * Set the initial Linux generic firmware upgrade enable or disable flag.
3688 * zero if val saved.
3689 * -EINVAL val out of range
3692 lpfc_request_firmware_upgrade_init(struct lpfc_hba
*phba
, int val
)
3694 if (val
>= 0 && val
<= 1) {
3695 phba
->cfg_request_firmware_upgrade
= val
;
3700 static DEVICE_ATTR(lpfc_req_fw_upgrade
, S_IRUGO
| S_IWUSR
,
3701 lpfc_request_firmware_upgrade_show
,
3702 lpfc_request_firmware_upgrade_store
);
3705 * lpfc_fcp_imax_store
3707 * @dev: class device that is converted into a Scsi_host.
3708 * @attr: device attribute, not used.
3709 * @buf: string with the number of fast-path FCP interrupts per second.
3710 * @count: unused variable.
3713 * If val is in a valid range [636,651042], then set the adapter's
3714 * maximum number of fast-path FCP interrupts per second.
3717 * length of the buf on success if val is in range the intended mode
3719 * -EINVAL if val out of range or intended mode is not supported.
3722 lpfc_fcp_imax_store(struct device
*dev
, struct device_attribute
*attr
,
3723 const char *buf
, size_t count
)
3725 struct Scsi_Host
*shost
= class_to_shost(dev
);
3726 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
3727 struct lpfc_hba
*phba
= vport
->phba
;
3730 /* fcp_imax is only valid for SLI4 */
3731 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
3734 /* Sanity check on user data */
3735 if (!isdigit(buf
[0]))
3737 if (sscanf(buf
, "%i", &val
) != 1)
3741 * Value range for the HBA is [5000,5000000]
3742 * The value for each EQ depends on how many EQs are configured.
3744 if (val
< LPFC_MIN_IMAX
|| val
> LPFC_MAX_IMAX
)
3747 phba
->cfg_fcp_imax
= (uint32_t)val
;
3748 for (i
= 0; i
< phba
->cfg_fcp_io_channel
; i
+= LPFC_MAX_EQ_DELAY
)
3749 lpfc_modify_fcp_eq_delay(phba
, i
);
3755 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
3758 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
3760 static int lpfc_fcp_imax
= LPFC_DEF_IMAX
;
3761 module_param(lpfc_fcp_imax
, int, S_IRUGO
|S_IWUSR
);
3762 MODULE_PARM_DESC(lpfc_fcp_imax
,
3763 "Set the maximum number of FCP interrupts per second per HBA");
3764 lpfc_param_show(fcp_imax
)
3767 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
3768 * @phba: lpfc_hba pointer.
3769 * @val: link speed value.
3772 * If val is in a valid range [636,651042], then initialize the adapter's
3773 * maximum number of fast-path FCP interrupts per second.
3776 * zero if val saved.
3777 * -EINVAL val out of range
3780 lpfc_fcp_imax_init(struct lpfc_hba
*phba
, int val
)
3782 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
3783 phba
->cfg_fcp_imax
= 0;
3787 if (val
>= LPFC_MIN_IMAX
&& val
<= LPFC_MAX_IMAX
) {
3788 phba
->cfg_fcp_imax
= val
;
3792 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3793 "3016 fcp_imax: %d out of range, using default\n", val
);
3794 phba
->cfg_fcp_imax
= LPFC_DEF_IMAX
;
3799 static DEVICE_ATTR(lpfc_fcp_imax
, S_IRUGO
| S_IWUSR
,
3800 lpfc_fcp_imax_show
, lpfc_fcp_imax_store
);
3803 * lpfc_state_show - Display current driver CPU affinity
3804 * @dev: class converted to a Scsi_host structure.
3805 * @attr: device attribute, not used.
3806 * @buf: on return contains text describing the state of the link.
3808 * Returns: size of formatted string.
3811 lpfc_fcp_cpu_map_show(struct device
*dev
, struct device_attribute
*attr
,
3814 struct Scsi_Host
*shost
= class_to_shost(dev
);
3815 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
3816 struct lpfc_hba
*phba
= vport
->phba
;
3817 struct lpfc_vector_map_info
*cpup
;
3820 if ((phba
->sli_rev
!= LPFC_SLI_REV4
) ||
3821 (phba
->intr_type
!= MSIX
))
3824 switch (phba
->cfg_fcp_cpu_map
) {
3826 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
3827 "fcp_cpu_map: No mapping (%d)\n",
3828 phba
->cfg_fcp_cpu_map
);
3831 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
3832 "fcp_cpu_map: HBA centric mapping (%d): "
3834 phba
->cfg_fcp_cpu_map
,
3835 phba
->sli4_hba
.num_online_cpu
);
3838 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
3839 "fcp_cpu_map: Driver centric mapping (%d): "
3841 phba
->cfg_fcp_cpu_map
,
3842 phba
->sli4_hba
.num_online_cpu
);
3846 cpup
= phba
->sli4_hba
.cpu_map
;
3847 for (idx
= 0; idx
< phba
->sli4_hba
.num_present_cpu
; idx
++) {
3848 if (cpup
->irq
== LPFC_VECTOR_MAP_EMPTY
)
3849 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
3850 "CPU %02d io_chan %02d "
3851 "physid %d coreid %d\n",
3852 idx
, cpup
->channel_id
, cpup
->phys_id
,
3855 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
3856 "CPU %02d io_chan %02d "
3857 "physid %d coreid %d IRQ %d\n",
3858 idx
, cpup
->channel_id
, cpup
->phys_id
,
3859 cpup
->core_id
, cpup
->irq
);
3867 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
3868 * @dev: class device that is converted into a Scsi_host.
3869 * @attr: device attribute, not used.
3870 * @buf: one or more lpfc_polling_flags values.
3874 * -EINVAL - Not implemented yet.
3877 lpfc_fcp_cpu_map_store(struct device
*dev
, struct device_attribute
*attr
,
3878 const char *buf
, size_t count
)
3880 int status
= -EINVAL
;
3885 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
3888 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
3889 # 0 - Do not affinitze IRQ vectors
3890 # 1 - Affintize HBA vectors with respect to each HBA
3891 # (start with CPU0 for each HBA)
3892 # 2 - Affintize HBA vectors with respect to the entire driver
3893 # (round robin thru all CPUs across all HBAs)
3895 static int lpfc_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
3896 module_param(lpfc_fcp_cpu_map
, int, S_IRUGO
|S_IWUSR
);
3897 MODULE_PARM_DESC(lpfc_fcp_cpu_map
,
3898 "Defines how to map CPUs to IRQ vectors per HBA");
3901 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
3902 * @phba: lpfc_hba pointer.
3903 * @val: link speed value.
3906 * If val is in a valid range [0-2], then affinitze the adapter's
3910 * zero if val saved.
3911 * -EINVAL val out of range
3914 lpfc_fcp_cpu_map_init(struct lpfc_hba
*phba
, int val
)
3916 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
3917 phba
->cfg_fcp_cpu_map
= 0;
3921 if (val
>= LPFC_MIN_CPU_MAP
&& val
<= LPFC_MAX_CPU_MAP
) {
3922 phba
->cfg_fcp_cpu_map
= val
;
3926 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3927 "3326 fcp_cpu_map: %d out of range, using default\n",
3929 phba
->cfg_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
3934 static DEVICE_ATTR(lpfc_fcp_cpu_map
, S_IRUGO
| S_IWUSR
,
3935 lpfc_fcp_cpu_map_show
, lpfc_fcp_cpu_map_store
);
3938 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
3939 # Value range is [2,3]. Default value is 3.
3941 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
3942 "Select Fibre Channel class of service for FCP sequences");
3945 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
3946 # is [0,1]. Default value is 0.
3948 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
3949 "Use ADISC on rediscovery to authenticate FCP devices");
3952 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
3953 # depth. Default value is 0. When the value of this parameter is zero the
3954 # SCSI command completion time is not used for controlling I/O queue depth. When
3955 # the parameter is set to a non-zero value, the I/O queue depth is controlled
3956 # to limit the I/O completion time to the parameter value.
3957 # The value is set in milliseconds.
3959 static int lpfc_max_scsicmpl_time
;
3960 module_param(lpfc_max_scsicmpl_time
, int, S_IRUGO
);
3961 MODULE_PARM_DESC(lpfc_max_scsicmpl_time
,
3962 "Use command completion time to control queue depth");
3963 lpfc_vport_param_show(max_scsicmpl_time
);
3964 lpfc_vport_param_init(max_scsicmpl_time
, 0, 0, 60000);
3966 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
3968 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
3969 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
3971 if (val
== vport
->cfg_max_scsicmpl_time
)
3973 if ((val
< 0) || (val
> 60000))
3975 vport
->cfg_max_scsicmpl_time
= val
;
3977 spin_lock_irq(shost
->host_lock
);
3978 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3979 if (!NLP_CHK_NODE_ACT(ndlp
))
3981 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
3983 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
3985 spin_unlock_irq(shost
->host_lock
);
3988 lpfc_vport_param_store(max_scsicmpl_time
);
3989 static DEVICE_ATTR(lpfc_max_scsicmpl_time
, S_IRUGO
| S_IWUSR
,
3990 lpfc_max_scsicmpl_time_show
,
3991 lpfc_max_scsicmpl_time_store
);
3994 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
3995 # range is [0,1]. Default value is 0.
3997 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
4000 # lpfc_fcp_io_sched: Determine scheduling algrithmn for issuing FCP cmds
4001 # range is [0,1]. Default value is 0.
4002 # For [0], FCP commands are issued to Work Queues ina round robin fashion.
4003 # For [1], FCP commands are issued to a Work Queue associated with the
4006 LPFC_ATTR_RW(fcp_io_sched
, 0, 0, 1, "Determine scheduling algrithmn for "
4007 "issuing commands [0] - Round Robin, [1] - Current CPU");
4010 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
4011 # range is [0,1]. Default value is 0.
4012 # For [0], bus reset issues target reset to ALL devices
4013 # For [1], bus reset issues target reset to non-FCP2 devices
4015 LPFC_ATTR_RW(fcp2_no_tgt_reset
, 0, 0, 1, "Determine bus reset behavior for "
4016 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
4020 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
4021 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
4022 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
4023 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
4024 # cr_delay is set to 0.
4026 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
4027 "interrupt response is generated");
4029 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
4030 "interrupt response is generated");
4033 # lpfc_multi_ring_support: Determines how many rings to spread available
4034 # cmd/rsp IOCB entries across.
4035 # Value range is [1,2]. Default value is 1.
4037 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
4038 "SLI rings to spread IOCB entries across");
4041 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
4042 # identifies what rctl value to configure the additional ring for.
4043 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
4045 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
4046 255, "Identifies RCTL for additional ring configuration");
4049 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
4050 # identifies what type value to configure the additional ring for.
4051 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
4053 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
4054 255, "Identifies TYPE for additional ring configuration");
4057 # lpfc_fdmi_on: controls FDMI support.
4058 # 0 = no FDMI support
4059 # 1 = support FDMI without attribute of hostname
4060 # 2 = support FDMI with attribute of hostname
4061 # Value range [0,2]. Default value is 0.
4063 LPFC_VPORT_ATTR_RW(fdmi_on
, 0, 0, 2, "Enable FDMI support");
4066 # Specifies the maximum number of ELS cmds we can have outstanding (for
4067 # discovery). Value range is [1,64]. Default value = 32.
4069 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
4070 "during discovery");
4073 # lpfc_max_luns: maximum allowed LUN.
4074 # Value range is [0,65535]. Default value is 255.
4075 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
4077 LPFC_VPORT_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN");
4080 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
4081 # Value range is [1,255], default value is 10.
4083 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
4084 "Milliseconds driver will wait between polling FCP ring");
4087 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
4088 # support this feature
4091 # 2 = MSI-X enabled (default)
4092 # Value range is [0,2]. Default value is 2.
4094 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
4095 "MSI-X (2), if possible");
4098 # lpfc_fcp_wq_count: Set the number of fast-path FCP work queues
4099 # This parameter is ignored and will eventually be depricated
4101 # Value range is [1,7]. Default value is 4.
4103 LPFC_ATTR_R(fcp_wq_count
, LPFC_FCP_IO_CHAN_DEF
, LPFC_FCP_IO_CHAN_MIN
,
4104 LPFC_FCP_IO_CHAN_MAX
,
4105 "Set the number of fast-path FCP work queues, if possible");
4108 # lpfc_fcp_eq_count: Set the number of FCP EQ/CQ/WQ IO channels
4110 # Value range is [1,7]. Default value is 4.
4112 LPFC_ATTR_R(fcp_eq_count
, LPFC_FCP_IO_CHAN_DEF
, LPFC_FCP_IO_CHAN_MIN
,
4113 LPFC_FCP_IO_CHAN_MAX
,
4114 "Set the number of fast-path FCP event queues, if possible");
4117 # lpfc_fcp_io_channel: Set the number of FCP EQ/CQ/WQ IO channels
4119 # Value range is [1,7]. Default value is 4.
4121 LPFC_ATTR_R(fcp_io_channel
, LPFC_FCP_IO_CHAN_DEF
, LPFC_FCP_IO_CHAN_MIN
,
4122 LPFC_FCP_IO_CHAN_MAX
,
4123 "Set the number of FCP I/O channels");
4126 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
4127 # 0 = HBA resets disabled
4128 # 1 = HBA resets enabled (default)
4129 # Value range is [0,1]. Default value is 1.
4131 LPFC_ATTR_R(enable_hba_reset
, 1, 0, 1, "Enable HBA resets from the driver.");
4134 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
4135 # 0 = HBA Heartbeat disabled
4136 # 1 = HBA Heartbeat enabled (default)
4137 # Value range is [0,1]. Default value is 1.
4139 LPFC_ATTR_R(enable_hba_heartbeat
, 0, 0, 1, "Enable HBA Heartbeat.");
4142 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
4143 # 0 = BlockGuard disabled (default)
4144 # 1 = BlockGuard enabled
4145 # Value range is [0,1]. Default value is 0.
4147 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
4150 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
4151 # 0 = disabled (default)
4153 # Value range is [0,1]. Default value is 0.
4155 # This feature in under investigation and may be supported in the future.
4157 unsigned int lpfc_fcp_look_ahead
= LPFC_LOOK_AHEAD_OFF
;
4161 # - Bit mask of host protection capabilities used to register with the
4163 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
4164 # - Allows you to ultimately specify which profiles to use
4165 # - Default will result in registering capabilities for all profiles.
4166 # - SHOST_DIF_TYPE1_PROTECTION 1
4167 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
4168 # - SHOST_DIX_TYPE0_PROTECTION 8
4169 # HBA supports DIX Type 0: Host to HBA protection only
4170 # - SHOST_DIX_TYPE1_PROTECTION 16
4171 # HBA supports DIX Type 1: Host to HBA Type 1 protection
4174 unsigned int lpfc_prot_mask
= SHOST_DIF_TYPE1_PROTECTION
|
4175 SHOST_DIX_TYPE0_PROTECTION
|
4176 SHOST_DIX_TYPE1_PROTECTION
;
4178 module_param(lpfc_prot_mask
, uint
, S_IRUGO
);
4179 MODULE_PARM_DESC(lpfc_prot_mask
, "host protection mask");
4182 # lpfc_prot_guard: i
4183 # - Bit mask of protection guard types to register with the SCSI mid-layer
4184 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
4185 # - Allows you to ultimately specify which profiles to use
4186 # - Default will result in registering capabilities for all guard types
4189 unsigned char lpfc_prot_guard
= SHOST_DIX_GUARD_IP
;
4190 module_param(lpfc_prot_guard
, byte
, S_IRUGO
);
4191 MODULE_PARM_DESC(lpfc_prot_guard
, "host protection guard type");
4194 * Delay initial NPort discovery when Clean Address bit is cleared in
4195 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
4196 * This parameter can have value 0 or 1.
4197 * When this parameter is set to 0, no delay is added to the initial
4199 * When this parameter is set to non-zero value, initial Nport discovery is
4200 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
4201 * accept and FCID/Fabric name/Fabric portname is changed.
4202 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
4203 * when Clean Address bit is cleared in FLOGI/FDISC
4204 * accept and FCID/Fabric name/Fabric portname is changed.
4205 * Default value is 0.
4207 int lpfc_delay_discovery
;
4208 module_param(lpfc_delay_discovery
, int, S_IRUGO
);
4209 MODULE_PARM_DESC(lpfc_delay_discovery
,
4210 "Delay NPort discovery when Clean Address bit is cleared. "
4211 "Allowed values: 0,1.");
4214 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
4215 * This value can be set to values between 64 and 4096. The default value is
4216 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
4217 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
4218 * Because of the additional overhead involved in setting up T10-DIF,
4219 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
4220 * and will be limited to 512 if BlockGuard is enabled under SLI3.
4222 LPFC_ATTR_R(sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
, LPFC_DEFAULT_SG_SEG_CNT
,
4223 LPFC_MAX_SG_SEG_CNT
, "Max Scatter Gather Segment Count");
4226 * This parameter will be depricated, the driver cannot limit the
4227 * protection data s/g list.
4229 LPFC_ATTR_R(prot_sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
,
4230 LPFC_DEFAULT_SG_SEG_CNT
, LPFC_MAX_SG_SEG_CNT
,
4231 "Max Protection Scatter Gather Segment Count");
4233 struct device_attribute
*lpfc_hba_attrs
[] = {
4235 &dev_attr_bg_guard_err
,
4236 &dev_attr_bg_apptag_err
,
4237 &dev_attr_bg_reftag_err
,
4239 &dev_attr_serialnum
,
4240 &dev_attr_modeldesc
,
4241 &dev_attr_modelname
,
4242 &dev_attr_programtype
,
4246 &dev_attr_option_rom_version
,
4247 &dev_attr_link_state
,
4248 &dev_attr_num_discovered_ports
,
4249 &dev_attr_menlo_mgmt_mode
,
4250 &dev_attr_lpfc_drvr_version
,
4251 &dev_attr_lpfc_enable_fip
,
4252 &dev_attr_lpfc_temp_sensor
,
4253 &dev_attr_lpfc_log_verbose
,
4254 &dev_attr_lpfc_lun_queue_depth
,
4255 &dev_attr_lpfc_tgt_queue_depth
,
4256 &dev_attr_lpfc_hba_queue_depth
,
4257 &dev_attr_lpfc_peer_port_login
,
4258 &dev_attr_lpfc_nodev_tmo
,
4259 &dev_attr_lpfc_devloss_tmo
,
4260 &dev_attr_lpfc_fcp_class
,
4261 &dev_attr_lpfc_use_adisc
,
4262 &dev_attr_lpfc_ack0
,
4263 &dev_attr_lpfc_topology
,
4264 &dev_attr_lpfc_scan_down
,
4265 &dev_attr_lpfc_link_speed
,
4266 &dev_attr_lpfc_fcp_io_sched
,
4267 &dev_attr_lpfc_fcp2_no_tgt_reset
,
4268 &dev_attr_lpfc_cr_delay
,
4269 &dev_attr_lpfc_cr_count
,
4270 &dev_attr_lpfc_multi_ring_support
,
4271 &dev_attr_lpfc_multi_ring_rctl
,
4272 &dev_attr_lpfc_multi_ring_type
,
4273 &dev_attr_lpfc_fdmi_on
,
4274 &dev_attr_lpfc_max_luns
,
4275 &dev_attr_lpfc_enable_npiv
,
4276 &dev_attr_lpfc_fcf_failover_policy
,
4277 &dev_attr_lpfc_enable_rrq
,
4278 &dev_attr_nport_evt_cnt
,
4279 &dev_attr_board_mode
,
4286 &dev_attr_npiv_info
,
4287 &dev_attr_issue_reset
,
4288 &dev_attr_lpfc_poll
,
4289 &dev_attr_lpfc_poll_tmo
,
4290 &dev_attr_lpfc_use_msi
,
4291 &dev_attr_lpfc_fcp_imax
,
4292 &dev_attr_lpfc_fcp_cpu_map
,
4293 &dev_attr_lpfc_fcp_wq_count
,
4294 &dev_attr_lpfc_fcp_eq_count
,
4295 &dev_attr_lpfc_fcp_io_channel
,
4296 &dev_attr_lpfc_enable_bg
,
4297 &dev_attr_lpfc_soft_wwnn
,
4298 &dev_attr_lpfc_soft_wwpn
,
4299 &dev_attr_lpfc_soft_wwn_enable
,
4300 &dev_attr_lpfc_enable_hba_reset
,
4301 &dev_attr_lpfc_enable_hba_heartbeat
,
4302 &dev_attr_lpfc_sg_seg_cnt
,
4303 &dev_attr_lpfc_max_scsicmpl_time
,
4304 &dev_attr_lpfc_stat_data_ctrl
,
4305 &dev_attr_lpfc_prot_sg_seg_cnt
,
4306 &dev_attr_lpfc_aer_support
,
4307 &dev_attr_lpfc_aer_state_cleanup
,
4308 &dev_attr_lpfc_sriov_nr_virtfn
,
4309 &dev_attr_lpfc_req_fw_upgrade
,
4310 &dev_attr_lpfc_suppress_link_up
,
4311 &dev_attr_lpfc_iocb_cnt
,
4314 &dev_attr_txcmplq_hw
,
4315 &dev_attr_lpfc_fips_level
,
4316 &dev_attr_lpfc_fips_rev
,
4318 &dev_attr_lpfc_sriov_hw_max_virtfn
,
4323 struct device_attribute
*lpfc_vport_attrs
[] = {
4325 &dev_attr_link_state
,
4326 &dev_attr_num_discovered_ports
,
4327 &dev_attr_lpfc_drvr_version
,
4328 &dev_attr_lpfc_log_verbose
,
4329 &dev_attr_lpfc_lun_queue_depth
,
4330 &dev_attr_lpfc_tgt_queue_depth
,
4331 &dev_attr_lpfc_nodev_tmo
,
4332 &dev_attr_lpfc_devloss_tmo
,
4333 &dev_attr_lpfc_hba_queue_depth
,
4334 &dev_attr_lpfc_peer_port_login
,
4335 &dev_attr_lpfc_restrict_login
,
4336 &dev_attr_lpfc_fcp_class
,
4337 &dev_attr_lpfc_use_adisc
,
4338 &dev_attr_lpfc_fdmi_on
,
4339 &dev_attr_lpfc_max_luns
,
4340 &dev_attr_nport_evt_cnt
,
4341 &dev_attr_npiv_info
,
4342 &dev_attr_lpfc_enable_da_id
,
4343 &dev_attr_lpfc_max_scsicmpl_time
,
4344 &dev_attr_lpfc_stat_data_ctrl
,
4345 &dev_attr_lpfc_static_vport
,
4346 &dev_attr_lpfc_fips_level
,
4347 &dev_attr_lpfc_fips_rev
,
4352 * sysfs_ctlreg_write - Write method for writing to ctlreg
4353 * @filp: open sysfs file
4354 * @kobj: kernel kobject that contains the kernel class device.
4355 * @bin_attr: kernel attributes passed to us.
4356 * @buf: contains the data to be written to the adapter IOREG space.
4357 * @off: offset into buffer to beginning of data.
4358 * @count: bytes to transfer.
4361 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
4362 * Uses the adapter io control registers to send buf contents to the adapter.
4365 * -ERANGE off and count combo out of range
4366 * -EINVAL off, count or buff address invalid
4367 * -EPERM adapter is offline
4368 * value of count, buf contents written
4371 sysfs_ctlreg_write(struct file
*filp
, struct kobject
*kobj
,
4372 struct bin_attribute
*bin_attr
,
4373 char *buf
, loff_t off
, size_t count
)
4376 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
4377 struct Scsi_Host
*shost
= class_to_shost(dev
);
4378 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4379 struct lpfc_hba
*phba
= vport
->phba
;
4381 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
4384 if ((off
+ count
) > FF_REG_AREA_SIZE
)
4387 if (count
<= LPFC_REG_WRITE_KEY_SIZE
)
4390 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
4393 /* This is to protect HBA registers from accidental writes. */
4394 if (memcmp(buf
, LPFC_REG_WRITE_KEY
, LPFC_REG_WRITE_KEY_SIZE
))
4397 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
))
4400 spin_lock_irq(&phba
->hbalock
);
4401 for (buf_off
= 0; buf_off
< count
- LPFC_REG_WRITE_KEY_SIZE
;
4402 buf_off
+= sizeof(uint32_t))
4403 writel(*((uint32_t *)(buf
+ buf_off
+ LPFC_REG_WRITE_KEY_SIZE
)),
4404 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
4406 spin_unlock_irq(&phba
->hbalock
);
4412 * sysfs_ctlreg_read - Read method for reading from ctlreg
4413 * @filp: open sysfs file
4414 * @kobj: kernel kobject that contains the kernel class device.
4415 * @bin_attr: kernel attributes passed to us.
4416 * @buf: if successful contains the data from the adapter IOREG space.
4417 * @off: offset into buffer to beginning of data.
4418 * @count: bytes to transfer.
4421 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
4422 * Uses the adapter io control registers to read data into buf.
4425 * -ERANGE off and count combo out of range
4426 * -EINVAL off, count or buff address invalid
4427 * value of count, buf contents read
4430 sysfs_ctlreg_read(struct file
*filp
, struct kobject
*kobj
,
4431 struct bin_attribute
*bin_attr
,
4432 char *buf
, loff_t off
, size_t count
)
4436 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
4437 struct Scsi_Host
*shost
= class_to_shost(dev
);
4438 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4439 struct lpfc_hba
*phba
= vport
->phba
;
4441 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
4444 if (off
> FF_REG_AREA_SIZE
)
4447 if ((off
+ count
) > FF_REG_AREA_SIZE
)
4448 count
= FF_REG_AREA_SIZE
- off
;
4450 if (count
== 0) return 0;
4452 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
4455 spin_lock_irq(&phba
->hbalock
);
4457 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
4458 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
4459 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
4462 spin_unlock_irq(&phba
->hbalock
);
4467 static struct bin_attribute sysfs_ctlreg_attr
= {
4470 .mode
= S_IRUSR
| S_IWUSR
,
4473 .read
= sysfs_ctlreg_read
,
4474 .write
= sysfs_ctlreg_write
,
4478 * sysfs_mbox_write - Write method for writing information via mbox
4479 * @filp: open sysfs file
4480 * @kobj: kernel kobject that contains the kernel class device.
4481 * @bin_attr: kernel attributes passed to us.
4482 * @buf: contains the data to be written to sysfs mbox.
4483 * @off: offset into buffer to beginning of data.
4484 * @count: bytes to transfer.
4487 * Deprecated function. All mailbox access from user space is performed via the
4491 * -EPERM operation not permitted
4494 sysfs_mbox_write(struct file
*filp
, struct kobject
*kobj
,
4495 struct bin_attribute
*bin_attr
,
4496 char *buf
, loff_t off
, size_t count
)
4502 * sysfs_mbox_read - Read method for reading information via mbox
4503 * @filp: open sysfs file
4504 * @kobj: kernel kobject that contains the kernel class device.
4505 * @bin_attr: kernel attributes passed to us.
4506 * @buf: contains the data to be read from sysfs mbox.
4507 * @off: offset into buffer to beginning of data.
4508 * @count: bytes to transfer.
4511 * Deprecated function. All mailbox access from user space is performed via the
4515 * -EPERM operation not permitted
4518 sysfs_mbox_read(struct file
*filp
, struct kobject
*kobj
,
4519 struct bin_attribute
*bin_attr
,
4520 char *buf
, loff_t off
, size_t count
)
4525 static struct bin_attribute sysfs_mbox_attr
= {
4528 .mode
= S_IRUSR
| S_IWUSR
,
4530 .size
= MAILBOX_SYSFS_MAX
,
4531 .read
= sysfs_mbox_read
,
4532 .write
= sysfs_mbox_write
,
4536 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
4537 * @vport: address of lpfc vport structure.
4541 * error return code from sysfs_create_bin_file()
4544 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
4546 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
4549 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
4550 &sysfs_drvr_stat_data_attr
);
4552 /* Virtual ports do not need ctrl_reg and mbox */
4553 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
4556 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
4557 &sysfs_ctlreg_attr
);
4559 goto out_remove_stat_attr
;
4561 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
4564 goto out_remove_ctlreg_attr
;
4567 out_remove_ctlreg_attr
:
4568 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
4569 out_remove_stat_attr
:
4570 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
4571 &sysfs_drvr_stat_data_attr
);
4577 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
4578 * @vport: address of lpfc vport structure.
4581 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
4583 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
4584 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
4585 &sysfs_drvr_stat_data_attr
);
4586 /* Virtual ports do not need ctrl_reg and mbox */
4587 if (vport
->port_type
== LPFC_NPIV_PORT
)
4589 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
4590 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
4595 * Dynamic FC Host Attributes Support
4599 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
4600 * @shost: kernel scsi host pointer.
4603 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
4605 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4607 /* note: fc_myDID already in cpu endianness */
4608 fc_host_port_id(shost
) = vport
->fc_myDID
;
4612 * lpfc_get_host_port_type - Set the value of the scsi host port type
4613 * @shost: kernel scsi host pointer.
4616 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
4618 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4619 struct lpfc_hba
*phba
= vport
->phba
;
4621 spin_lock_irq(shost
->host_lock
);
4623 if (vport
->port_type
== LPFC_NPIV_PORT
) {
4624 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
4625 } else if (lpfc_is_link_up(phba
)) {
4626 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
4627 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
4628 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
4630 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
4632 if (vport
->fc_flag
& FC_FABRIC
)
4633 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
4635 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
4638 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
4640 spin_unlock_irq(shost
->host_lock
);
4644 * lpfc_get_host_port_state - Set the value of the scsi host port state
4645 * @shost: kernel scsi host pointer.
4648 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
4650 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4651 struct lpfc_hba
*phba
= vport
->phba
;
4653 spin_lock_irq(shost
->host_lock
);
4655 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
4656 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
4658 switch (phba
->link_state
) {
4659 case LPFC_LINK_UNKNOWN
:
4660 case LPFC_LINK_DOWN
:
4661 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
4665 case LPFC_HBA_READY
:
4666 /* Links up, reports port state accordingly */
4667 if (vport
->port_state
< LPFC_VPORT_READY
)
4668 fc_host_port_state(shost
) =
4669 FC_PORTSTATE_BYPASSED
;
4671 fc_host_port_state(shost
) =
4672 FC_PORTSTATE_ONLINE
;
4674 case LPFC_HBA_ERROR
:
4675 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
4678 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
4683 spin_unlock_irq(shost
->host_lock
);
4687 * lpfc_get_host_speed - Set the value of the scsi host speed
4688 * @shost: kernel scsi host pointer.
4691 lpfc_get_host_speed(struct Scsi_Host
*shost
)
4693 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4694 struct lpfc_hba
*phba
= vport
->phba
;
4696 spin_lock_irq(shost
->host_lock
);
4698 if (lpfc_is_link_up(phba
)) {
4699 switch(phba
->fc_linkspeed
) {
4700 case LPFC_LINK_SPEED_1GHZ
:
4701 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
4703 case LPFC_LINK_SPEED_2GHZ
:
4704 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
4706 case LPFC_LINK_SPEED_4GHZ
:
4707 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
4709 case LPFC_LINK_SPEED_8GHZ
:
4710 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
4712 case LPFC_LINK_SPEED_10GHZ
:
4713 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
4715 case LPFC_LINK_SPEED_16GHZ
:
4716 fc_host_speed(shost
) = FC_PORTSPEED_16GBIT
;
4719 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
4723 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
4725 spin_unlock_irq(shost
->host_lock
);
4729 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
4730 * @shost: kernel scsi host pointer.
4733 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
4735 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4736 struct lpfc_hba
*phba
= vport
->phba
;
4739 spin_lock_irq(shost
->host_lock
);
4741 if ((vport
->port_state
> LPFC_FLOGI
) &&
4742 ((vport
->fc_flag
& FC_FABRIC
) ||
4743 ((phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) &&
4744 (vport
->fc_flag
& FC_PUBLIC_LOOP
))))
4745 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
4747 /* fabric is local port if there is no F/FL_Port */
4750 spin_unlock_irq(shost
->host_lock
);
4752 fc_host_fabric_name(shost
) = node_name
;
4756 * lpfc_get_stats - Return statistical information about the adapter
4757 * @shost: kernel scsi host pointer.
4760 * NULL on error for link down, no mbox pool, sli2 active,
4761 * management not allowed, memory allocation error, or mbox error.
4765 * address of the adapter host statistics
4767 static struct fc_host_statistics
*
4768 lpfc_get_stats(struct Scsi_Host
*shost
)
4770 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4771 struct lpfc_hba
*phba
= vport
->phba
;
4772 struct lpfc_sli
*psli
= &phba
->sli
;
4773 struct fc_host_statistics
*hs
= &phba
->link_stats
;
4774 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
4775 LPFC_MBOXQ_t
*pmboxq
;
4777 unsigned long seconds
;
4781 * prevent udev from issuing mailbox commands until the port is
4784 if (phba
->link_state
< LPFC_LINK_DOWN
||
4785 !phba
->mbox_mem_pool
||
4786 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
4789 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
4792 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
4795 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
4797 pmb
= &pmboxq
->u
.mb
;
4798 pmb
->mbxCommand
= MBX_READ_STATUS
;
4799 pmb
->mbxOwner
= OWN_HOST
;
4800 pmboxq
->context1
= NULL
;
4801 pmboxq
->vport
= vport
;
4803 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
4804 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
4806 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
4808 if (rc
!= MBX_SUCCESS
) {
4809 if (rc
!= MBX_TIMEOUT
)
4810 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4814 memset(hs
, 0, sizeof (struct fc_host_statistics
));
4816 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
4818 * The MBX_READ_STATUS returns tx_k_bytes which has to
4819 * converted to words
4821 hs
->tx_words
= (uint64_t)
4822 ((uint64_t)pmb
->un
.varRdStatus
.xmitByteCnt
4824 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
4825 hs
->rx_words
= (uint64_t)
4826 ((uint64_t)pmb
->un
.varRdStatus
.rcvByteCnt
4829 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
4830 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
4831 pmb
->mbxOwner
= OWN_HOST
;
4832 pmboxq
->context1
= NULL
;
4833 pmboxq
->vport
= vport
;
4835 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
4836 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
4838 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
4840 if (rc
!= MBX_SUCCESS
) {
4841 if (rc
!= MBX_TIMEOUT
)
4842 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4846 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
4847 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
4848 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
4849 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
4850 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
4851 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
4852 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
4854 hs
->link_failure_count
-= lso
->link_failure_count
;
4855 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
4856 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
4857 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
4858 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
4859 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
4860 hs
->error_frames
-= lso
->error_frames
;
4862 if (phba
->hba_flag
& HBA_FCOE_MODE
) {
4864 hs
->nos_count
= (phba
->link_events
>> 1);
4865 hs
->nos_count
-= lso
->link_events
;
4866 } else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
4867 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
4868 hs
->lip_count
-= lso
->link_events
;
4872 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
4873 hs
->nos_count
-= lso
->link_events
;
4876 hs
->dumped_frames
= -1;
4878 seconds
= get_seconds();
4879 if (seconds
< psli
->stats_start
)
4880 hs
->seconds_since_last_reset
= seconds
+
4881 ((unsigned long)-1 - psli
->stats_start
);
4883 hs
->seconds_since_last_reset
= seconds
- psli
->stats_start
;
4885 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4891 * lpfc_reset_stats - Copy the adapter link stats information
4892 * @shost: kernel scsi host pointer.
4895 lpfc_reset_stats(struct Scsi_Host
*shost
)
4897 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4898 struct lpfc_hba
*phba
= vport
->phba
;
4899 struct lpfc_sli
*psli
= &phba
->sli
;
4900 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
4901 LPFC_MBOXQ_t
*pmboxq
;
4905 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
4908 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
4911 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
4913 pmb
= &pmboxq
->u
.mb
;
4914 pmb
->mbxCommand
= MBX_READ_STATUS
;
4915 pmb
->mbxOwner
= OWN_HOST
;
4916 pmb
->un
.varWords
[0] = 0x1; /* reset request */
4917 pmboxq
->context1
= NULL
;
4918 pmboxq
->vport
= vport
;
4920 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
4921 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
4922 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
4924 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
4926 if (rc
!= MBX_SUCCESS
) {
4927 if (rc
!= MBX_TIMEOUT
)
4928 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4932 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
4933 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
4934 pmb
->mbxOwner
= OWN_HOST
;
4935 pmboxq
->context1
= NULL
;
4936 pmboxq
->vport
= vport
;
4938 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
4939 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
4940 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
4942 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
4944 if (rc
!= MBX_SUCCESS
) {
4945 if (rc
!= MBX_TIMEOUT
)
4946 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
4950 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
4951 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
4952 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
4953 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
4954 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
4955 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
4956 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
4957 if (phba
->hba_flag
& HBA_FCOE_MODE
)
4958 lso
->link_events
= (phba
->link_events
>> 1);
4960 lso
->link_events
= (phba
->fc_eventTag
>> 1);
4962 psli
->stats_start
= get_seconds();
4964 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4970 * The LPFC driver treats linkdown handling as target loss events so there
4971 * are no sysfs handlers for link_down_tmo.
4975 * lpfc_get_node_by_target - Return the nodelist for a target
4976 * @starget: kernel scsi target pointer.
4979 * address of the node list if found
4980 * NULL target not found
4982 static struct lpfc_nodelist
*
4983 lpfc_get_node_by_target(struct scsi_target
*starget
)
4985 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
4986 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4987 struct lpfc_nodelist
*ndlp
;
4989 spin_lock_irq(shost
->host_lock
);
4990 /* Search for this, mapped, target ID */
4991 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4992 if (NLP_CHK_NODE_ACT(ndlp
) &&
4993 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
4994 starget
->id
== ndlp
->nlp_sid
) {
4995 spin_unlock_irq(shost
->host_lock
);
4999 spin_unlock_irq(shost
->host_lock
);
5004 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
5005 * @starget: kernel scsi target pointer.
5008 lpfc_get_starget_port_id(struct scsi_target
*starget
)
5010 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5012 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
5016 * lpfc_get_starget_node_name - Set the target node name
5017 * @starget: kernel scsi target pointer.
5019 * Description: Set the target node name to the ndlp node name wwn or zero.
5022 lpfc_get_starget_node_name(struct scsi_target
*starget
)
5024 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5026 fc_starget_node_name(starget
) =
5027 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
5031 * lpfc_get_starget_port_name - Set the target port name
5032 * @starget: kernel scsi target pointer.
5034 * Description: set the target port name to the ndlp port name wwn or zero.
5037 lpfc_get_starget_port_name(struct scsi_target
*starget
)
5039 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5041 fc_starget_port_name(starget
) =
5042 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
5046 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
5047 * @rport: fc rport address.
5048 * @timeout: new value for dev loss tmo.
5051 * If timeout is non zero set the dev_loss_tmo to timeout, else set
5052 * dev_loss_tmo to one.
5055 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
5058 rport
->dev_loss_tmo
= timeout
;
5060 rport
->dev_loss_tmo
= 1;
5064 * lpfc_rport_show_function - Return rport target information
5067 * Macro that uses field to generate a function with the name lpfc_show_rport_
5069 * lpfc_show_rport_##field: returns the bytes formatted in buf
5070 * @cdev: class converted to an fc_rport.
5071 * @buf: on return contains the target_field or zero.
5073 * Returns: size of formatted string.
5075 #define lpfc_rport_show_function(field, format_string, sz, cast) \
5077 lpfc_show_rport_##field (struct device *dev, \
5078 struct device_attribute *attr, \
5081 struct fc_rport *rport = transport_class_to_rport(dev); \
5082 struct lpfc_rport_data *rdata = rport->hostdata; \
5083 return snprintf(buf, sz, format_string, \
5084 (rdata->target) ? cast rdata->target->field : 0); \
5087 #define lpfc_rport_rd_attr(field, format_string, sz) \
5088 lpfc_rport_show_function(field, format_string, sz, ) \
5089 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
5092 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
5093 * @fc_vport: The fc_vport who's symbolic name has been changed.
5096 * This function is called by the transport after the @fc_vport's symbolic name
5097 * has been changed. This function re-registers the symbolic name with the
5098 * switch to propagate the change into the fabric if the vport is active.
5101 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
5103 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
5105 if (vport
->port_state
== LPFC_VPORT_READY
)
5106 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
5110 * lpfc_hba_log_verbose_init - Set hba's log verbose level
5111 * @phba: Pointer to lpfc_hba struct.
5113 * This function is called by the lpfc_get_cfgparam() routine to set the
5114 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
5115 * log message according to the module's lpfc_log_verbose parameter setting
5116 * before hba port or vport created.
5119 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
5121 phba
->cfg_log_verbose
= verbose
;
5124 struct fc_function_template lpfc_transport_functions
= {
5125 /* fixed attributes the driver supports */
5126 .show_host_node_name
= 1,
5127 .show_host_port_name
= 1,
5128 .show_host_supported_classes
= 1,
5129 .show_host_supported_fc4s
= 1,
5130 .show_host_supported_speeds
= 1,
5131 .show_host_maxframe_size
= 1,
5132 .show_host_symbolic_name
= 1,
5134 /* dynamic attributes the driver supports */
5135 .get_host_port_id
= lpfc_get_host_port_id
,
5136 .show_host_port_id
= 1,
5138 .get_host_port_type
= lpfc_get_host_port_type
,
5139 .show_host_port_type
= 1,
5141 .get_host_port_state
= lpfc_get_host_port_state
,
5142 .show_host_port_state
= 1,
5144 /* active_fc4s is shown but doesn't change (thus no get function) */
5145 .show_host_active_fc4s
= 1,
5147 .get_host_speed
= lpfc_get_host_speed
,
5148 .show_host_speed
= 1,
5150 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
5151 .show_host_fabric_name
= 1,
5154 * The LPFC driver treats linkdown handling as target loss events
5155 * so there are no sysfs handlers for link_down_tmo.
5158 .get_fc_host_stats
= lpfc_get_stats
,
5159 .reset_fc_host_stats
= lpfc_reset_stats
,
5161 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
5162 .show_rport_maxframe_size
= 1,
5163 .show_rport_supported_classes
= 1,
5165 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
5166 .show_rport_dev_loss_tmo
= 1,
5168 .get_starget_port_id
= lpfc_get_starget_port_id
,
5169 .show_starget_port_id
= 1,
5171 .get_starget_node_name
= lpfc_get_starget_node_name
,
5172 .show_starget_node_name
= 1,
5174 .get_starget_port_name
= lpfc_get_starget_port_name
,
5175 .show_starget_port_name
= 1,
5177 .issue_fc_host_lip
= lpfc_issue_lip
,
5178 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
5179 .terminate_rport_io
= lpfc_terminate_rport_io
,
5181 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
5183 .vport_disable
= lpfc_vport_disable
,
5185 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
5187 .bsg_request
= lpfc_bsg_request
,
5188 .bsg_timeout
= lpfc_bsg_timeout
,
5191 struct fc_function_template lpfc_vport_transport_functions
= {
5192 /* fixed attributes the driver supports */
5193 .show_host_node_name
= 1,
5194 .show_host_port_name
= 1,
5195 .show_host_supported_classes
= 1,
5196 .show_host_supported_fc4s
= 1,
5197 .show_host_supported_speeds
= 1,
5198 .show_host_maxframe_size
= 1,
5199 .show_host_symbolic_name
= 1,
5201 /* dynamic attributes the driver supports */
5202 .get_host_port_id
= lpfc_get_host_port_id
,
5203 .show_host_port_id
= 1,
5205 .get_host_port_type
= lpfc_get_host_port_type
,
5206 .show_host_port_type
= 1,
5208 .get_host_port_state
= lpfc_get_host_port_state
,
5209 .show_host_port_state
= 1,
5211 /* active_fc4s is shown but doesn't change (thus no get function) */
5212 .show_host_active_fc4s
= 1,
5214 .get_host_speed
= lpfc_get_host_speed
,
5215 .show_host_speed
= 1,
5217 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
5218 .show_host_fabric_name
= 1,
5221 * The LPFC driver treats linkdown handling as target loss events
5222 * so there are no sysfs handlers for link_down_tmo.
5225 .get_fc_host_stats
= lpfc_get_stats
,
5226 .reset_fc_host_stats
= lpfc_reset_stats
,
5228 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
5229 .show_rport_maxframe_size
= 1,
5230 .show_rport_supported_classes
= 1,
5232 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
5233 .show_rport_dev_loss_tmo
= 1,
5235 .get_starget_port_id
= lpfc_get_starget_port_id
,
5236 .show_starget_port_id
= 1,
5238 .get_starget_node_name
= lpfc_get_starget_node_name
,
5239 .show_starget_node_name
= 1,
5241 .get_starget_port_name
= lpfc_get_starget_port_name
,
5242 .show_starget_port_name
= 1,
5244 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
5245 .terminate_rport_io
= lpfc_terminate_rport_io
,
5247 .vport_disable
= lpfc_vport_disable
,
5249 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
5253 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
5254 * @phba: lpfc_hba pointer.
5257 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
5259 lpfc_fcp_io_sched_init(phba
, lpfc_fcp_io_sched
);
5260 lpfc_fcp2_no_tgt_reset_init(phba
, lpfc_fcp2_no_tgt_reset
);
5261 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
5262 lpfc_cr_count_init(phba
, lpfc_cr_count
);
5263 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
5264 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
5265 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
5266 lpfc_ack0_init(phba
, lpfc_ack0
);
5267 lpfc_topology_init(phba
, lpfc_topology
);
5268 lpfc_link_speed_init(phba
, lpfc_link_speed
);
5269 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
5270 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
5271 lpfc_fcf_failover_policy_init(phba
, lpfc_fcf_failover_policy
);
5272 lpfc_enable_rrq_init(phba
, lpfc_enable_rrq
);
5273 lpfc_use_msi_init(phba
, lpfc_use_msi
);
5274 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
5275 lpfc_fcp_cpu_map_init(phba
, lpfc_fcp_cpu_map
);
5276 lpfc_fcp_wq_count_init(phba
, lpfc_fcp_wq_count
);
5277 lpfc_fcp_eq_count_init(phba
, lpfc_fcp_eq_count
);
5278 lpfc_fcp_io_channel_init(phba
, lpfc_fcp_io_channel
);
5279 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
5280 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
5281 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
5282 if (phba
->sli_rev
== LPFC_SLI_REV4
)
5285 phba
->cfg_poll
= lpfc_poll
;
5286 phba
->cfg_soft_wwnn
= 0L;
5287 phba
->cfg_soft_wwpn
= 0L;
5288 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
5289 lpfc_prot_sg_seg_cnt_init(phba
, lpfc_prot_sg_seg_cnt
);
5290 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
5291 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
5292 lpfc_aer_support_init(phba
, lpfc_aer_support
);
5293 lpfc_sriov_nr_virtfn_init(phba
, lpfc_sriov_nr_virtfn
);
5294 lpfc_request_firmware_upgrade_init(phba
, lpfc_req_fw_upgrade
);
5295 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
5296 lpfc_iocb_cnt_init(phba
, lpfc_iocb_cnt
);
5297 phba
->cfg_enable_dss
= 1;
5302 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
5303 * @vport: lpfc_vport pointer.
5306 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
5308 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
5309 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
5310 lpfc_tgt_queue_depth_init(vport
, lpfc_tgt_queue_depth
);
5311 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
5312 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
5313 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
5314 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
5315 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
5316 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
5317 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
5318 lpfc_fdmi_on_init(vport
, lpfc_fdmi_on
);
5319 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
5320 lpfc_max_luns_init(vport
, lpfc_max_luns
);
5321 lpfc_scan_down_init(vport
, lpfc_scan_down
);
5322 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);