1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2015 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
;
409 char fwrev
[FW_REV_STR_SIZE
];
411 if (phba
->sli_rev
< LPFC_SLI_REV4
)
412 return snprintf(buf
, PAGE_SIZE
, "%s\n", phba
->OptionROMVersion
);
414 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
415 return snprintf(buf
, PAGE_SIZE
, "%s\n", fwrev
);
419 * lpfc_state_show - Return the link state of the port
420 * @dev: class converted to a Scsi_host structure.
421 * @attr: device attribute, not used.
422 * @buf: on return contains text describing the state of the link.
425 * The switch statement has no default so zero will be returned.
427 * Returns: size of formatted string.
430 lpfc_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
433 struct Scsi_Host
*shost
= class_to_shost(dev
);
434 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
435 struct lpfc_hba
*phba
= vport
->phba
;
438 switch (phba
->link_state
) {
439 case LPFC_LINK_UNKNOWN
:
440 case LPFC_WARM_START
:
441 case LPFC_INIT_START
:
442 case LPFC_INIT_MBX_CMDS
:
445 if (phba
->hba_flag
& LINK_DISABLED
)
446 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
447 "Link Down - User disabled\n");
449 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
455 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Link Up - ");
457 switch (vport
->port_state
) {
458 case LPFC_LOCAL_CFG_LINK
:
459 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
460 "Configuring Link\n");
464 case LPFC_FABRIC_CFG_LINK
:
467 case LPFC_BUILD_DISC_LIST
:
469 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
472 case LPFC_VPORT_READY
:
473 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Ready\n");
476 case LPFC_VPORT_FAILED
:
477 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Failed\n");
480 case LPFC_VPORT_UNKNOWN
:
481 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
485 if (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
)
486 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
487 " Menlo Maint Mode\n");
488 else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
489 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
490 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
493 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
496 if (vport
->fc_flag
& FC_FABRIC
)
497 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
500 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
509 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
510 * @dev: class unused variable.
511 * @attr: device attribute, not used.
512 * @buf: on return contains the module description text.
514 * Returns: size of formatted string.
517 lpfc_sli4_protocol_show(struct device
*dev
, struct device_attribute
*attr
,
520 struct Scsi_Host
*shost
= class_to_shost(dev
);
521 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
522 struct lpfc_hba
*phba
= vport
->phba
;
524 if (phba
->sli_rev
< LPFC_SLI_REV4
)
525 return snprintf(buf
, PAGE_SIZE
, "fc\n");
527 if (phba
->sli4_hba
.lnk_info
.lnk_dv
== LPFC_LNK_DAT_VAL
) {
528 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_GE
)
529 return snprintf(buf
, PAGE_SIZE
, "fcoe\n");
530 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_FC
)
531 return snprintf(buf
, PAGE_SIZE
, "fc\n");
533 return snprintf(buf
, PAGE_SIZE
, "unknown\n");
537 * lpfc_oas_supported_show - Return whether or not Optimized Access Storage
538 * (OAS) is supported.
539 * @dev: class unused variable.
540 * @attr: device attribute, not used.
541 * @buf: on return contains the module description text.
543 * Returns: size of formatted string.
546 lpfc_oas_supported_show(struct device
*dev
, struct device_attribute
*attr
,
549 struct Scsi_Host
*shost
= class_to_shost(dev
);
550 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
551 struct lpfc_hba
*phba
= vport
->phba
;
553 return snprintf(buf
, PAGE_SIZE
, "%d\n",
554 phba
->sli4_hba
.pc_sli4_params
.oas_supported
);
558 * lpfc_link_state_store - Transition the link_state on an HBA port
559 * @dev: class device that is converted into a Scsi_host.
560 * @attr: device attribute, not used.
561 * @buf: one or more lpfc_polling_flags values.
565 * -EINVAL if the buffer is not "up" or "down"
566 * return from link state change function if non-zero
567 * length of the buf on success
570 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
571 const char *buf
, size_t count
)
573 struct Scsi_Host
*shost
= class_to_shost(dev
);
574 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
575 struct lpfc_hba
*phba
= vport
->phba
;
577 int status
= -EINVAL
;
579 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
580 (phba
->link_state
== LPFC_LINK_DOWN
))
581 status
= phba
->lpfc_hba_init_link(phba
, MBX_NOWAIT
);
582 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
583 (phba
->link_state
>= LPFC_LINK_UP
))
584 status
= phba
->lpfc_hba_down_link(phba
, MBX_NOWAIT
);
593 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
594 * @dev: class device that is converted into a Scsi_host.
595 * @attr: device attribute, not used.
596 * @buf: on return contains the sum of fc mapped and unmapped.
599 * Returns the ascii text number of the sum of the fc mapped and unmapped
602 * Returns: size of formatted string.
605 lpfc_num_discovered_ports_show(struct device
*dev
,
606 struct device_attribute
*attr
, char *buf
)
608 struct Scsi_Host
*shost
= class_to_shost(dev
);
609 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
611 return snprintf(buf
, PAGE_SIZE
, "%d\n",
612 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
616 * lpfc_issue_lip - Misnomer, name carried over from long ago
617 * @shost: Scsi_Host pointer.
620 * Bring the link down gracefully then re-init the link. The firmware will
621 * re-init the fiber channel interface as required. Does not issue a LIP.
624 * -EPERM port offline or management commands are being blocked
625 * -ENOMEM cannot allocate memory for the mailbox command
626 * -EIO error sending the mailbox command
630 lpfc_issue_lip(struct Scsi_Host
*shost
)
632 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
633 struct lpfc_hba
*phba
= vport
->phba
;
634 LPFC_MBOXQ_t
*pmboxq
;
635 int mbxstatus
= MBXERR_ERROR
;
638 * If the link is offline, disabled or BLOCK_MGMT_IO
639 * it doesn't make any sense to allow issue_lip
641 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
642 (phba
->hba_flag
& LINK_DISABLED
) ||
643 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
646 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
651 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
652 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
653 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
655 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
657 if ((mbxstatus
== MBX_SUCCESS
) &&
658 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
659 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
660 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
661 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
662 phba
->cfg_link_speed
);
663 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
665 if ((mbxstatus
== MBX_SUCCESS
) &&
666 (pmboxq
->u
.mb
.mbxStatus
== MBXERR_SEC_NO_PERMISSION
))
667 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
| LOG_SLI
,
668 "2859 SLI authentication is required "
669 "for INIT_LINK but has not done yet\n");
672 lpfc_set_loopback_flag(phba
);
673 if (mbxstatus
!= MBX_TIMEOUT
)
674 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
676 if (mbxstatus
== MBXERR_ERROR
)
683 * lpfc_do_offline - Issues a mailbox command to bring the link down
684 * @phba: lpfc_hba pointer.
685 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
688 * Assumes any error from lpfc_do_offline() will be negative.
689 * Can wait up to 5 seconds for the port ring buffers count
690 * to reach zero, prints a warning if it is not zero and continues.
691 * lpfc_workq_post_event() returns a non-zero return code if call fails.
694 * -EIO error posting the event
698 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
700 struct completion online_compl
;
701 struct lpfc_sli_ring
*pring
;
702 struct lpfc_sli
*psli
;
708 init_completion(&online_compl
);
709 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
710 LPFC_EVT_OFFLINE_PREP
);
714 wait_for_completion(&online_compl
);
721 /* Wait a little for things to settle down, but not
722 * long enough for dev loss timeout to expire.
724 for (i
= 0; i
< psli
->num_rings
; i
++) {
725 pring
= &psli
->ring
[i
];
726 while (!list_empty(&pring
->txcmplq
)) {
728 if (cnt
++ > 500) { /* 5 secs */
729 lpfc_printf_log(phba
,
730 KERN_WARNING
, LOG_INIT
,
731 "0466 Outstanding IO when "
732 "bringing Adapter offline\n");
738 init_completion(&online_compl
);
739 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
743 wait_for_completion(&online_compl
);
752 * lpfc_selective_reset - Offline then onlines the port
753 * @phba: lpfc_hba pointer.
756 * If the port is configured to allow a reset then the hba is brought
757 * offline then online.
760 * Assumes any error from lpfc_do_offline() will be negative.
761 * Do not make this function static.
764 * lpfc_do_offline() return code if not zero
765 * -EIO reset not configured or error posting the event
769 lpfc_selective_reset(struct lpfc_hba
*phba
)
771 struct completion online_compl
;
775 if (!phba
->cfg_enable_hba_reset
)
778 if (!(phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
779 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
785 init_completion(&online_compl
);
786 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
791 wait_for_completion(&online_compl
);
800 * lpfc_issue_reset - Selectively resets an adapter
801 * @dev: class device that is converted into a Scsi_host.
802 * @attr: device attribute, not used.
803 * @buf: containing the string "selective".
804 * @count: unused variable.
807 * If the buf contains the string "selective" then lpfc_selective_reset()
808 * is called to perform the reset.
811 * Assumes any error from lpfc_selective_reset() will be negative.
812 * If lpfc_selective_reset() returns zero then the length of the buffer
813 * is returned which indicates success
816 * -EINVAL if the buffer does not contain the string "selective"
817 * length of buf if lpfc-selective_reset() if the call succeeds
818 * return value of lpfc_selective_reset() if the call fails
821 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
822 const char *buf
, size_t count
)
824 struct Scsi_Host
*shost
= class_to_shost(dev
);
825 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
826 struct lpfc_hba
*phba
= vport
->phba
;
827 int status
= -EINVAL
;
829 if (!phba
->cfg_enable_hba_reset
)
832 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
833 status
= phba
->lpfc_selective_reset(phba
);
842 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
843 * @phba: lpfc_hba pointer.
846 * SLI4 interface type-2 device to wait on the sliport status register for
847 * the readyness after performing a firmware reset.
850 * zero for success, -EPERM when port does not have privilege to perform the
851 * reset, -EIO when port timeout from recovering from the reset.
854 * As the caller will interpret the return code by value, be careful in making
855 * change or addition to return codes.
858 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba
*phba
)
860 struct lpfc_register portstat_reg
= {0};
864 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
865 &portstat_reg
.word0
);
867 /* verify if privileged for the request operation */
868 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
) &&
869 !bf_get(lpfc_sliport_status_err
, &portstat_reg
))
872 /* wait for the SLI port firmware ready after firmware reset */
873 for (i
= 0; i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
; i
++) {
875 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
876 &portstat_reg
.word0
);
877 if (!bf_get(lpfc_sliport_status_err
, &portstat_reg
))
879 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
))
881 if (!bf_get(lpfc_sliport_status_rdy
, &portstat_reg
))
886 if (i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
)
893 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
894 * @phba: lpfc_hba pointer.
897 * Request SLI4 interface type-2 device to perform a physical register set
904 lpfc_sli4_pdev_reg_request(struct lpfc_hba
*phba
, uint32_t opcode
)
906 struct completion online_compl
;
907 struct pci_dev
*pdev
= phba
->pcidev
;
908 uint32_t before_fc_flag
;
909 uint32_t sriov_nr_virtfn
;
911 int status
= 0, rc
= 0;
912 int job_posted
= 1, sriov_err
;
914 if (!phba
->cfg_enable_hba_reset
)
917 if ((phba
->sli_rev
< LPFC_SLI_REV4
) ||
918 (bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
) !=
919 LPFC_SLI_INTF_IF_TYPE_2
))
922 /* Keep state if we need to restore back */
923 before_fc_flag
= phba
->pport
->fc_flag
;
924 sriov_nr_virtfn
= phba
->cfg_sriov_nr_virtfn
;
926 /* Disable SR-IOV virtual functions if enabled */
927 if (phba
->cfg_sriov_nr_virtfn
) {
928 pci_disable_sriov(pdev
);
929 phba
->cfg_sriov_nr_virtfn
= 0;
932 if (opcode
== LPFC_FW_DUMP
)
933 phba
->hba_flag
|= HBA_FW_DUMP_OP
;
935 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
938 phba
->hba_flag
&= ~HBA_FW_DUMP_OP
;
942 /* wait for the device to be quiesced before firmware reset */
945 reg_val
= readl(phba
->sli4_hba
.conf_regs_memmap_p
+
946 LPFC_CTL_PDEV_CTL_OFFSET
);
948 if (opcode
== LPFC_FW_DUMP
)
949 reg_val
|= LPFC_FW_DUMP_REQUEST
;
950 else if (opcode
== LPFC_FW_RESET
)
951 reg_val
|= LPFC_CTL_PDEV_CTL_FRST
;
952 else if (opcode
== LPFC_DV_RESET
)
953 reg_val
|= LPFC_CTL_PDEV_CTL_DRST
;
955 writel(reg_val
, phba
->sli4_hba
.conf_regs_memmap_p
+
956 LPFC_CTL_PDEV_CTL_OFFSET
);
958 readl(phba
->sli4_hba
.conf_regs_memmap_p
+ LPFC_CTL_PDEV_CTL_OFFSET
);
960 /* delay driver action following IF_TYPE_2 reset */
961 rc
= lpfc_sli4_pdev_status_reg_wait(phba
);
964 /* no privilege for reset */
965 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
966 "3150 No privilege to perform the requested "
967 "access: x%x\n", reg_val
);
968 } else if (rc
== -EIO
) {
969 /* reset failed, there is nothing more we can do */
970 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
971 "3153 Fail to perform the requested "
972 "access: x%x\n", reg_val
);
976 /* keep the original port state */
977 if (before_fc_flag
& FC_OFFLINE_MODE
)
980 init_completion(&online_compl
);
981 job_posted
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
986 wait_for_completion(&online_compl
);
989 /* in any case, restore the virtual functions enabled as before */
990 if (sriov_nr_virtfn
) {
992 lpfc_sli_probe_sriov_nr_virtfn(phba
, sriov_nr_virtfn
);
994 phba
->cfg_sriov_nr_virtfn
= sriov_nr_virtfn
;
997 /* return proper error code */
1008 * lpfc_nport_evt_cnt_show - Return the number of nport events
1009 * @dev: class device that is converted into a Scsi_host.
1010 * @attr: device attribute, not used.
1011 * @buf: on return contains the ascii number of nport events.
1013 * Returns: size of formatted string.
1016 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
1019 struct Scsi_Host
*shost
= class_to_shost(dev
);
1020 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1021 struct lpfc_hba
*phba
= vport
->phba
;
1023 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
1027 * lpfc_board_mode_show - Return the state of the board
1028 * @dev: class device that is converted into a Scsi_host.
1029 * @attr: device attribute, not used.
1030 * @buf: on return contains the state of the adapter.
1032 * Returns: size of formatted string.
1035 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
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
;
1043 if (phba
->link_state
== LPFC_HBA_ERROR
)
1045 else if (phba
->link_state
== LPFC_WARM_START
)
1046 state
= "warm start";
1047 else if (phba
->link_state
== LPFC_INIT_START
)
1052 return snprintf(buf
, PAGE_SIZE
, "%s\n", state
);
1056 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1057 * @dev: class device that is converted into a Scsi_host.
1058 * @attr: device attribute, not used.
1059 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1060 * @count: unused variable.
1063 * -EACCES if enable hba reset not enabled
1064 * -EINVAL if the buffer does not contain a valid string (see above)
1065 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1066 * buf length greater than zero indicates success
1069 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
1070 const char *buf
, size_t count
)
1072 struct Scsi_Host
*shost
= class_to_shost(dev
);
1073 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1074 struct lpfc_hba
*phba
= vport
->phba
;
1075 struct completion online_compl
;
1076 char *board_mode_str
= NULL
;
1080 if (!phba
->cfg_enable_hba_reset
) {
1082 goto board_mode_out
;
1085 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1086 "3050 lpfc_board_mode set to %s\n", buf
);
1088 init_completion(&online_compl
);
1090 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
1091 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1095 goto board_mode_out
;
1097 wait_for_completion(&online_compl
);
1098 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
1099 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1100 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
1101 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1104 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
1105 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
1106 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1109 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
1110 else if (strncmp(buf
, "dump", sizeof("dump") - 1) == 0)
1111 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_DUMP
);
1112 else if (strncmp(buf
, "fw_reset", sizeof("fw_reset") - 1) == 0)
1113 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_RESET
);
1114 else if (strncmp(buf
, "dv_reset", sizeof("dv_reset") - 1) == 0)
1115 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_DV_RESET
);
1123 board_mode_str
= strchr(buf
, '\n');
1125 *board_mode_str
= '\0';
1126 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1127 "3097 Failed \"%s\", status(%d), "
1129 buf
, status
, phba
->pport
->fc_flag
);
1135 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1136 * @phba: pointer to the adapter structure.
1137 * @mxri: max xri count.
1138 * @axri: available xri count.
1139 * @mrpi: max rpi count.
1140 * @arpi: available rpi count.
1141 * @mvpi: max vpi count.
1142 * @avpi: available vpi count.
1145 * If an integer pointer for an count is not null then the value for the
1146 * count is returned.
1153 lpfc_get_hba_info(struct lpfc_hba
*phba
,
1154 uint32_t *mxri
, uint32_t *axri
,
1155 uint32_t *mrpi
, uint32_t *arpi
,
1156 uint32_t *mvpi
, uint32_t *avpi
)
1158 struct lpfc_mbx_read_config
*rd_config
;
1159 LPFC_MBOXQ_t
*pmboxq
;
1165 * prevent udev from issuing mailbox commands until the port is
1168 if (phba
->link_state
< LPFC_LINK_DOWN
||
1169 !phba
->mbox_mem_pool
||
1170 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
1173 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
1176 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1179 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1181 pmb
= &pmboxq
->u
.mb
;
1182 pmb
->mbxCommand
= MBX_READ_CONFIG
;
1183 pmb
->mbxOwner
= OWN_HOST
;
1184 pmboxq
->context1
= NULL
;
1186 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
1187 rc
= MBX_NOT_FINISHED
;
1189 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
1191 if (rc
!= MBX_SUCCESS
) {
1192 if (rc
!= MBX_TIMEOUT
)
1193 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1197 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1198 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
1200 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
1202 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
1203 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
1205 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
1207 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
1208 phba
->sli4_hba
.max_cfg_param
.xri_used
;
1210 /* Account for differences with SLI-3. Get vpi count from
1211 * mailbox data and subtract one for max vpi value.
1213 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
1214 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
1219 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
1222 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
1224 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
1226 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
1228 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
1230 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
1232 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
1235 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1240 * lpfc_max_rpi_show - Return maximum rpi
1241 * @dev: class device that is converted into a Scsi_host.
1242 * @attr: device attribute, not used.
1243 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1246 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1247 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1248 * to "Unknown" and the buffer length is returned, therefore the caller
1249 * must check for "Unknown" in the buffer to detect a failure.
1251 * Returns: size of formatted string.
1254 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1257 struct Scsi_Host
*shost
= class_to_shost(dev
);
1258 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1259 struct lpfc_hba
*phba
= vport
->phba
;
1262 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
1263 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1264 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1268 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1269 * @dev: class device that is converted into a Scsi_host.
1270 * @attr: device attribute, not used.
1271 * @buf: containing the used rpi count in decimal or "Unknown".
1274 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1275 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1276 * to "Unknown" and the buffer length is returned, therefore the caller
1277 * must check for "Unknown" in the buffer to detect a failure.
1279 * Returns: size of formatted string.
1282 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1285 struct Scsi_Host
*shost
= class_to_shost(dev
);
1286 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1287 struct lpfc_hba
*phba
= vport
->phba
;
1290 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1291 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1292 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1296 * lpfc_max_xri_show - Return maximum xri
1297 * @dev: class device that is converted into a Scsi_host.
1298 * @attr: device attribute, not used.
1299 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1302 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1303 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1304 * to "Unknown" and the buffer length is returned, therefore the caller
1305 * must check for "Unknown" in the buffer to detect a failure.
1307 * Returns: size of formatted string.
1310 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1313 struct Scsi_Host
*shost
= class_to_shost(dev
);
1314 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1315 struct lpfc_hba
*phba
= vport
->phba
;
1318 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
1319 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1320 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1324 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1325 * @dev: class device that is converted into a Scsi_host.
1326 * @attr: device attribute, not used.
1327 * @buf: on return contains the used xri count in decimal or "Unknown".
1330 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1331 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1332 * to "Unknown" and the buffer length is returned, therefore the caller
1333 * must check for "Unknown" in the buffer to detect a failure.
1335 * Returns: size of formatted string.
1338 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1341 struct Scsi_Host
*shost
= class_to_shost(dev
);
1342 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1343 struct lpfc_hba
*phba
= vport
->phba
;
1346 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
1347 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1348 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1352 * lpfc_max_vpi_show - Return maximum vpi
1353 * @dev: class device that is converted into a Scsi_host.
1354 * @attr: device attribute, not used.
1355 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1358 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1359 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1360 * to "Unknown" and the buffer length is returned, therefore the caller
1361 * must check for "Unknown" in the buffer to detect a failure.
1363 * Returns: size of formatted string.
1366 lpfc_max_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1369 struct Scsi_Host
*shost
= class_to_shost(dev
);
1370 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1371 struct lpfc_hba
*phba
= vport
->phba
;
1374 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
1375 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1376 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1380 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1381 * @dev: class device that is converted into a Scsi_host.
1382 * @attr: device attribute, not used.
1383 * @buf: on return contains the used vpi count in decimal or "Unknown".
1386 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1387 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1388 * to "Unknown" and the buffer length is returned, therefore the caller
1389 * must check for "Unknown" in the buffer to detect a failure.
1391 * Returns: size of formatted string.
1394 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1397 struct Scsi_Host
*shost
= class_to_shost(dev
);
1398 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1399 struct lpfc_hba
*phba
= vport
->phba
;
1402 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
1403 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1404 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1408 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1409 * @dev: class device that is converted into a Scsi_host.
1410 * @attr: device attribute, not used.
1411 * @buf: text that must be interpreted to determine if npiv is supported.
1414 * Buffer will contain text indicating npiv is not suppoerted on the port,
1415 * the port is an NPIV physical port, or it is an npiv virtual port with
1416 * the id of the vport.
1418 * Returns: size of formatted string.
1421 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
1424 struct Scsi_Host
*shost
= class_to_shost(dev
);
1425 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1426 struct lpfc_hba
*phba
= vport
->phba
;
1428 if (!(phba
->max_vpi
))
1429 return snprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
1430 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1431 return snprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
1432 return snprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
1436 * lpfc_poll_show - Return text about poll support for the adapter
1437 * @dev: class device that is converted into a Scsi_host.
1438 * @attr: device attribute, not used.
1439 * @buf: on return contains the cfg_poll in hex.
1442 * cfg_poll should be a lpfc_polling_flags type.
1444 * Returns: size of formatted string.
1447 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
1450 struct Scsi_Host
*shost
= class_to_shost(dev
);
1451 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1452 struct lpfc_hba
*phba
= vport
->phba
;
1454 return snprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
1458 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1459 * @dev: class device that is converted into a Scsi_host.
1460 * @attr: device attribute, not used.
1461 * @buf: one or more lpfc_polling_flags values.
1465 * buf contents converted to integer and checked for a valid value.
1468 * -EINVAL if the buffer connot be converted or is out of range
1469 * length of the buf on success
1472 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
1473 const char *buf
, size_t count
)
1475 struct Scsi_Host
*shost
= class_to_shost(dev
);
1476 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1477 struct lpfc_hba
*phba
= vport
->phba
;
1482 if (!isdigit(buf
[0]))
1485 if (sscanf(buf
, "%i", &val
) != 1)
1488 if ((val
& 0x3) != val
)
1491 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1494 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1495 "3051 lpfc_poll changed from %d to %d\n",
1496 phba
->cfg_poll
, val
);
1498 spin_lock_irq(&phba
->hbalock
);
1500 old_val
= phba
->cfg_poll
;
1502 if (val
& ENABLE_FCP_RING_POLLING
) {
1503 if ((val
& DISABLE_FCP_RING_INT
) &&
1504 !(old_val
& DISABLE_FCP_RING_INT
)) {
1505 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1506 spin_unlock_irq(&phba
->hbalock
);
1509 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
1510 writel(creg_val
, phba
->HCregaddr
);
1511 readl(phba
->HCregaddr
); /* flush */
1513 lpfc_poll_start_timer(phba
);
1515 } else if (val
!= 0x0) {
1516 spin_unlock_irq(&phba
->hbalock
);
1520 if (!(val
& DISABLE_FCP_RING_INT
) &&
1521 (old_val
& DISABLE_FCP_RING_INT
))
1523 spin_unlock_irq(&phba
->hbalock
);
1524 del_timer(&phba
->fcp_poll_timer
);
1525 spin_lock_irq(&phba
->hbalock
);
1526 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1527 spin_unlock_irq(&phba
->hbalock
);
1530 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
1531 writel(creg_val
, phba
->HCregaddr
);
1532 readl(phba
->HCregaddr
); /* flush */
1535 phba
->cfg_poll
= val
;
1537 spin_unlock_irq(&phba
->hbalock
);
1543 * lpfc_fips_level_show - Return the current FIPS level for the HBA
1544 * @dev: class unused variable.
1545 * @attr: device attribute, not used.
1546 * @buf: on return contains the module description text.
1548 * Returns: size of formatted string.
1551 lpfc_fips_level_show(struct device
*dev
, struct device_attribute
*attr
,
1554 struct Scsi_Host
*shost
= class_to_shost(dev
);
1555 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1556 struct lpfc_hba
*phba
= vport
->phba
;
1558 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_level
);
1562 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
1563 * @dev: class unused variable.
1564 * @attr: device attribute, not used.
1565 * @buf: on return contains the module description text.
1567 * Returns: size of formatted string.
1570 lpfc_fips_rev_show(struct device
*dev
, struct device_attribute
*attr
,
1573 struct Scsi_Host
*shost
= class_to_shost(dev
);
1574 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1575 struct lpfc_hba
*phba
= vport
->phba
;
1577 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_spec_rev
);
1581 * lpfc_dss_show - Return the current state of dss and the configured state
1582 * @dev: class converted to a Scsi_host structure.
1583 * @attr: device attribute, not used.
1584 * @buf: on return contains the formatted text.
1586 * Returns: size of formatted string.
1589 lpfc_dss_show(struct device
*dev
, struct device_attribute
*attr
,
1592 struct Scsi_Host
*shost
= class_to_shost(dev
);
1593 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1594 struct lpfc_hba
*phba
= vport
->phba
;
1596 return snprintf(buf
, PAGE_SIZE
, "%s - %sOperational\n",
1597 (phba
->cfg_enable_dss
) ? "Enabled" : "Disabled",
1598 (phba
->sli3_options
& LPFC_SLI3_DSS_ENABLED
) ?
1603 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
1604 * @dev: class converted to a Scsi_host structure.
1605 * @attr: device attribute, not used.
1606 * @buf: on return contains the formatted support level.
1609 * Returns the maximum number of virtual functions a physical function can
1610 * support, 0 will be returned if called on virtual function.
1612 * Returns: size of formatted string.
1615 lpfc_sriov_hw_max_virtfn_show(struct device
*dev
,
1616 struct device_attribute
*attr
,
1619 struct Scsi_Host
*shost
= class_to_shost(dev
);
1620 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1621 struct lpfc_hba
*phba
= vport
->phba
;
1622 uint16_t max_nr_virtfn
;
1624 max_nr_virtfn
= lpfc_sli_sriov_nr_virtfn_get(phba
);
1625 return snprintf(buf
, PAGE_SIZE
, "%d\n", max_nr_virtfn
);
1629 * lpfc_param_show - Return a cfg attribute value in decimal
1632 * Macro that given an attr e.g. hba_queue_depth expands
1633 * into a function with the name lpfc_hba_queue_depth_show.
1635 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
1636 * @dev: class device that is converted into a Scsi_host.
1637 * @attr: device attribute, not used.
1638 * @buf: on return contains the attribute value in decimal.
1640 * Returns: size of formatted string.
1642 #define lpfc_param_show(attr) \
1644 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1647 struct Scsi_Host *shost = class_to_shost(dev);\
1648 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1649 struct lpfc_hba *phba = vport->phba;\
1650 return snprintf(buf, PAGE_SIZE, "%d\n",\
1655 * lpfc_param_hex_show - Return a cfg attribute value in hex
1658 * Macro that given an attr e.g. hba_queue_depth expands
1659 * into a function with the name lpfc_hba_queue_depth_show
1661 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
1662 * @dev: class device that is converted into a Scsi_host.
1663 * @attr: device attribute, not used.
1664 * @buf: on return contains the attribute value in hexadecimal.
1666 * Returns: size of formatted string.
1668 #define lpfc_param_hex_show(attr) \
1670 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1673 struct Scsi_Host *shost = class_to_shost(dev);\
1674 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1675 struct lpfc_hba *phba = vport->phba;\
1677 val = phba->cfg_##attr;\
1678 return snprintf(buf, PAGE_SIZE, "%#x\n",\
1683 * lpfc_param_init - Initializes a cfg attribute
1686 * Macro that given an attr e.g. hba_queue_depth expands
1687 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1688 * takes a default argument, a minimum and maximum argument.
1690 * lpfc_##attr##_init: Initializes an attribute.
1691 * @phba: pointer the the adapter structure.
1692 * @val: integer attribute value.
1694 * Validates the min and max values then sets the adapter config field
1695 * accordingly, or uses the default if out of range and prints an error message.
1699 * -EINVAL if default used
1701 #define lpfc_param_init(attr, default, minval, maxval) \
1703 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1705 if (val >= minval && val <= maxval) {\
1706 phba->cfg_##attr = val;\
1709 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1710 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
1711 "allowed range is ["#minval", "#maxval"]\n", val); \
1712 phba->cfg_##attr = default;\
1717 * lpfc_param_set - Set a cfg attribute value
1720 * Macro that given an attr e.g. hba_queue_depth expands
1721 * into a function with the name lpfc_hba_queue_depth_set
1723 * lpfc_##attr##_set: Sets an attribute value.
1724 * @phba: pointer the the adapter structure.
1725 * @val: integer attribute value.
1728 * Validates the min and max values then sets the
1729 * adapter config field if in the valid range. prints error message
1730 * and does not set the parameter if invalid.
1734 * -EINVAL if val is invalid
1736 #define lpfc_param_set(attr, default, minval, maxval) \
1738 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
1740 if (val >= minval && val <= maxval) {\
1741 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1742 "3052 lpfc_" #attr " changed from %d to %d\n", \
1743 phba->cfg_##attr, val); \
1744 phba->cfg_##attr = val;\
1747 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1748 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
1749 "allowed range is ["#minval", "#maxval"]\n", val); \
1754 * lpfc_param_store - Set a vport attribute value
1757 * Macro that given an attr e.g. hba_queue_depth expands
1758 * into a function with the name lpfc_hba_queue_depth_store.
1760 * lpfc_##attr##_store: Set an sttribute value.
1761 * @dev: class device that is converted into a Scsi_host.
1762 * @attr: device attribute, not used.
1763 * @buf: contains the attribute value in ascii.
1767 * Convert the ascii text number to an integer, then
1768 * use the lpfc_##attr##_set function to set the value.
1771 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1772 * length of buffer upon success.
1774 #define lpfc_param_store(attr) \
1776 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1777 const char *buf, size_t count) \
1779 struct Scsi_Host *shost = class_to_shost(dev);\
1780 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1781 struct lpfc_hba *phba = vport->phba;\
1783 if (!isdigit(buf[0]))\
1785 if (sscanf(buf, "%i", &val) != 1)\
1787 if (lpfc_##attr##_set(phba, val) == 0) \
1788 return strlen(buf);\
1794 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
1797 * Macro that given an attr e.g. hba_queue_depth expands
1798 * into a function with the name lpfc_hba_queue_depth_show
1800 * lpfc_##attr##_show: prints the attribute value in decimal.
1801 * @dev: class device that is converted into a Scsi_host.
1802 * @attr: device attribute, not used.
1803 * @buf: on return contains the attribute value in decimal.
1805 * Returns: length of formatted string.
1807 #define lpfc_vport_param_show(attr) \
1809 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1812 struct Scsi_Host *shost = class_to_shost(dev);\
1813 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1814 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
1818 * lpfc_vport_param_hex_show - Return hex formatted attribute value
1821 * Macro that given an attr e.g.
1822 * hba_queue_depth expands into a function with the name
1823 * lpfc_hba_queue_depth_show
1825 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
1826 * @dev: class device that is converted into a Scsi_host.
1827 * @attr: device attribute, not used.
1828 * @buf: on return contains the attribute value in hexadecimal.
1830 * Returns: length of formatted string.
1832 #define lpfc_vport_param_hex_show(attr) \
1834 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1837 struct Scsi_Host *shost = class_to_shost(dev);\
1838 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1839 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
1843 * lpfc_vport_param_init - Initialize a vport cfg attribute
1846 * Macro that given an attr e.g. hba_queue_depth expands
1847 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1848 * takes a default argument, a minimum and maximum argument.
1850 * lpfc_##attr##_init: validates the min and max values then sets the
1851 * adapter config field accordingly, or uses the default if out of range
1852 * and prints an error message.
1853 * @phba: pointer the the adapter structure.
1854 * @val: integer attribute value.
1858 * -EINVAL if default used
1860 #define lpfc_vport_param_init(attr, default, minval, maxval) \
1862 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
1864 if (val >= minval && val <= maxval) {\
1865 vport->cfg_##attr = val;\
1868 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1869 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
1870 "allowed range is ["#minval", "#maxval"]\n", val); \
1871 vport->cfg_##attr = default;\
1876 * lpfc_vport_param_set - Set a vport cfg attribute
1879 * Macro that given an attr e.g. hba_queue_depth expands
1880 * into a function with the name lpfc_hba_queue_depth_set
1882 * lpfc_##attr##_set: validates the min and max values then sets the
1883 * adapter config field if in the valid range. prints error message
1884 * and does not set the parameter if invalid.
1885 * @phba: pointer the the adapter structure.
1886 * @val: integer attribute value.
1890 * -EINVAL if val is invalid
1892 #define lpfc_vport_param_set(attr, default, minval, maxval) \
1894 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
1896 if (val >= minval && val <= maxval) {\
1897 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1898 "3053 lpfc_" #attr \
1899 " changed from %d (x%x) to %d (x%x)\n", \
1900 vport->cfg_##attr, vport->cfg_##attr, \
1902 vport->cfg_##attr = val;\
1905 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1906 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
1907 "allowed range is ["#minval", "#maxval"]\n", val); \
1912 * lpfc_vport_param_store - Set a vport attribute
1915 * Macro that given an attr e.g. hba_queue_depth
1916 * expands into a function with the name lpfc_hba_queue_depth_store
1918 * lpfc_##attr##_store: convert the ascii text number to an integer, then
1919 * use the lpfc_##attr##_set function to set the value.
1920 * @cdev: class device that is converted into a Scsi_host.
1921 * @buf: contains the attribute value in decimal.
1925 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1926 * length of buffer upon success.
1928 #define lpfc_vport_param_store(attr) \
1930 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1931 const char *buf, size_t count) \
1933 struct Scsi_Host *shost = class_to_shost(dev);\
1934 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1936 if (!isdigit(buf[0]))\
1938 if (sscanf(buf, "%i", &val) != 1)\
1940 if (lpfc_##attr##_set(vport, val) == 0) \
1941 return strlen(buf);\
1947 #define LPFC_ATTR(name, defval, minval, maxval, desc) \
1948 static uint lpfc_##name = defval;\
1949 module_param(lpfc_##name, uint, S_IRUGO);\
1950 MODULE_PARM_DESC(lpfc_##name, desc);\
1951 lpfc_param_init(name, defval, minval, maxval)
1953 #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \
1954 static uint lpfc_##name = defval;\
1955 module_param(lpfc_##name, uint, S_IRUGO);\
1956 MODULE_PARM_DESC(lpfc_##name, desc);\
1957 lpfc_param_show(name)\
1958 lpfc_param_init(name, defval, minval, maxval)\
1959 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1961 #define LPFC_ATTR_RW(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_param_show(name)\
1966 lpfc_param_init(name, defval, minval, maxval)\
1967 lpfc_param_set(name, defval, minval, maxval)\
1968 lpfc_param_store(name)\
1969 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1970 lpfc_##name##_show, lpfc_##name##_store)
1972 #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1973 static uint lpfc_##name = defval;\
1974 module_param(lpfc_##name, uint, S_IRUGO);\
1975 MODULE_PARM_DESC(lpfc_##name, desc);\
1976 lpfc_param_hex_show(name)\
1977 lpfc_param_init(name, defval, minval, maxval)\
1978 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1980 #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1981 static uint lpfc_##name = defval;\
1982 module_param(lpfc_##name, uint, S_IRUGO);\
1983 MODULE_PARM_DESC(lpfc_##name, desc);\
1984 lpfc_param_hex_show(name)\
1985 lpfc_param_init(name, defval, minval, maxval)\
1986 lpfc_param_set(name, defval, minval, maxval)\
1987 lpfc_param_store(name)\
1988 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1989 lpfc_##name##_show, lpfc_##name##_store)
1991 #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
1992 static uint lpfc_##name = defval;\
1993 module_param(lpfc_##name, uint, S_IRUGO);\
1994 MODULE_PARM_DESC(lpfc_##name, desc);\
1995 lpfc_vport_param_init(name, defval, minval, maxval)
1997 #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
1998 static uint lpfc_##name = defval;\
1999 module_param(lpfc_##name, uint, S_IRUGO);\
2000 MODULE_PARM_DESC(lpfc_##name, desc);\
2001 lpfc_vport_param_show(name)\
2002 lpfc_vport_param_init(name, defval, minval, maxval)\
2003 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
2005 #define LPFC_VPORT_ULL_ATTR_R(name, defval, minval, maxval, desc) \
2006 static uint64_t lpfc_##name = defval;\
2007 module_param(lpfc_##name, ullong, S_IRUGO);\
2008 MODULE_PARM_DESC(lpfc_##name, desc);\
2009 lpfc_vport_param_show(name)\
2010 lpfc_vport_param_init(name, defval, minval, maxval)\
2011 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
2013 #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
2014 static uint lpfc_##name = defval;\
2015 module_param(lpfc_##name, uint, S_IRUGO);\
2016 MODULE_PARM_DESC(lpfc_##name, desc);\
2017 lpfc_vport_param_show(name)\
2018 lpfc_vport_param_init(name, defval, minval, maxval)\
2019 lpfc_vport_param_set(name, defval, minval, maxval)\
2020 lpfc_vport_param_store(name)\
2021 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
2022 lpfc_##name##_show, lpfc_##name##_store)
2024 #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
2025 static uint lpfc_##name = defval;\
2026 module_param(lpfc_##name, uint, S_IRUGO);\
2027 MODULE_PARM_DESC(lpfc_##name, desc);\
2028 lpfc_vport_param_hex_show(name)\
2029 lpfc_vport_param_init(name, defval, minval, maxval)\
2030 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
2032 #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
2033 static uint lpfc_##name = defval;\
2034 module_param(lpfc_##name, uint, S_IRUGO);\
2035 MODULE_PARM_DESC(lpfc_##name, desc);\
2036 lpfc_vport_param_hex_show(name)\
2037 lpfc_vport_param_init(name, defval, minval, maxval)\
2038 lpfc_vport_param_set(name, defval, minval, maxval)\
2039 lpfc_vport_param_store(name)\
2040 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
2041 lpfc_##name##_show, lpfc_##name##_store)
2043 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
2044 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
2045 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
2046 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
2047 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
2048 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
2049 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
2050 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
2051 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
2052 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
2053 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
2054 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
2055 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
2056 lpfc_link_state_store
);
2057 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
2058 lpfc_option_rom_version_show
, NULL
);
2059 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
2060 lpfc_num_discovered_ports_show
, NULL
);
2061 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
2062 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
2063 static DEVICE_ATTR(lpfc_drvr_version
, S_IRUGO
, lpfc_drvr_version_show
, NULL
);
2064 static DEVICE_ATTR(lpfc_enable_fip
, S_IRUGO
, lpfc_enable_fip_show
, NULL
);
2065 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
2066 lpfc_board_mode_show
, lpfc_board_mode_store
);
2067 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
2068 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
2069 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
2070 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
2071 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
2072 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
2073 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
2074 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
2075 static DEVICE_ATTR(lpfc_temp_sensor
, S_IRUGO
, lpfc_temp_sensor_show
, NULL
);
2076 static DEVICE_ATTR(lpfc_fips_level
, S_IRUGO
, lpfc_fips_level_show
, NULL
);
2077 static DEVICE_ATTR(lpfc_fips_rev
, S_IRUGO
, lpfc_fips_rev_show
, NULL
);
2078 static DEVICE_ATTR(lpfc_dss
, S_IRUGO
, lpfc_dss_show
, NULL
);
2079 static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn
, S_IRUGO
,
2080 lpfc_sriov_hw_max_virtfn_show
, NULL
);
2081 static DEVICE_ATTR(protocol
, S_IRUGO
, lpfc_sli4_protocol_show
, NULL
);
2082 static DEVICE_ATTR(lpfc_xlane_supported
, S_IRUGO
, lpfc_oas_supported_show
,
2085 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
2088 * lpfc_wwn_set - Convert string to the 8 byte WWN value.
2090 * @cnt: Length of string.
2091 * @wwn: Array to receive converted wwn value.
2094 * -EINVAL if the buffer does not contain a valid wwn
2098 lpfc_wwn_set(const char *buf
, size_t cnt
, char wwn
[])
2102 /* Count may include a LF at end of string */
2103 if (buf
[cnt
-1] == '\n')
2106 if ((cnt
< 16) || (cnt
> 18) || ((cnt
== 17) && (*buf
++ != 'x')) ||
2107 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2110 memset(wwn
, 0, WWN_SZ
);
2112 /* Validate and store the new name */
2113 for (i
= 0, j
= 0; i
< 16; i
++) {
2114 if ((*buf
>= 'a') && (*buf
<= 'f'))
2115 j
= ((j
<< 4) | ((*buf
++ - 'a') + 10));
2116 else if ((*buf
>= 'A') && (*buf
<= 'F'))
2117 j
= ((j
<< 4) | ((*buf
++ - 'A') + 10));
2118 else if ((*buf
>= '0') && (*buf
<= '9'))
2119 j
= ((j
<< 4) | (*buf
++ - '0'));
2123 wwn
[i
/2] = j
& 0xff;
2130 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2131 * @dev: class device that is converted into a Scsi_host.
2132 * @attr: device attribute, not used.
2133 * @buf: containing the string lpfc_soft_wwn_key.
2134 * @count: must be size of lpfc_soft_wwn_key.
2137 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2138 * length of buf indicates success
2141 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
2142 const char *buf
, size_t count
)
2144 struct Scsi_Host
*shost
= class_to_shost(dev
);
2145 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2146 struct lpfc_hba
*phba
= vport
->phba
;
2147 unsigned int cnt
= count
;
2150 * We're doing a simple sanity check for soft_wwpn setting.
2151 * We require that the user write a specific key to enable
2152 * the soft_wwpn attribute to be settable. Once the attribute
2153 * is written, the enable key resets. If further updates are
2154 * desired, the key must be written again to re-enable the
2157 * The "key" is not secret - it is a hardcoded string shown
2158 * here. The intent is to protect against the random user or
2159 * application that is just writing attributes.
2162 /* count may include a LF at end of string */
2163 if (buf
[cnt
-1] == '\n')
2166 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
2167 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
2170 phba
->soft_wwn_enable
= 1;
2173 static DEVICE_ATTR(lpfc_soft_wwn_enable
, S_IWUSR
, NULL
,
2174 lpfc_soft_wwn_enable_store
);
2177 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2178 * @dev: class device that is converted into a Scsi_host.
2179 * @attr: device attribute, not used.
2180 * @buf: on return contains the wwpn in hexadecimal.
2182 * Returns: size of formatted string.
2185 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
2188 struct Scsi_Host
*shost
= class_to_shost(dev
);
2189 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2190 struct lpfc_hba
*phba
= vport
->phba
;
2192 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2193 (unsigned long long)phba
->cfg_soft_wwpn
);
2197 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2198 * @dev class device that is converted into a Scsi_host.
2199 * @attr: device attribute, not used.
2200 * @buf: contains the wwpn in hexadecimal.
2201 * @count: number of wwpn bytes in buf
2204 * -EACCES hba reset not enabled, adapter over temp
2205 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2206 * -EIO error taking adapter offline or online
2207 * value of count on success
2210 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
2211 const char *buf
, size_t count
)
2213 struct Scsi_Host
*shost
= class_to_shost(dev
);
2214 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2215 struct lpfc_hba
*phba
= vport
->phba
;
2216 struct completion online_compl
;
2217 int stat1
= 0, stat2
= 0;
2218 unsigned int cnt
= count
;
2222 if (!phba
->cfg_enable_hba_reset
)
2224 spin_lock_irq(&phba
->hbalock
);
2225 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
2226 spin_unlock_irq(&phba
->hbalock
);
2229 spin_unlock_irq(&phba
->hbalock
);
2230 /* count may include a LF at end of string */
2231 if (buf
[cnt
-1] == '\n')
2234 if (!phba
->soft_wwn_enable
)
2237 /* lock setting wwpn, wwnn down */
2238 phba
->soft_wwn_enable
= 0;
2240 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2242 /* not able to set wwpn, unlock it */
2243 phba
->soft_wwn_enable
= 1;
2247 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
2248 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
2249 if (phba
->cfg_soft_wwnn
)
2250 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
2252 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2253 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
2255 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
2257 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2258 "0463 lpfc_soft_wwpn attribute set failed to "
2259 "reinit adapter - %d\n", stat1
);
2260 init_completion(&online_compl
);
2261 rc
= lpfc_workq_post_event(phba
, &stat2
, &online_compl
,
2266 wait_for_completion(&online_compl
);
2268 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2269 "0464 lpfc_soft_wwpn attribute set failed to "
2270 "reinit adapter - %d\n", stat2
);
2271 return (stat1
|| stat2
) ? -EIO
: count
;
2273 static DEVICE_ATTR(lpfc_soft_wwpn
, S_IRUGO
| S_IWUSR
,
2274 lpfc_soft_wwpn_show
, lpfc_soft_wwpn_store
);
2277 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2278 * @dev: class device that is converted into a Scsi_host.
2279 * @attr: device attribute, not used.
2280 * @buf: on return contains the wwnn in hexadecimal.
2282 * Returns: size of formatted string.
2285 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
2288 struct Scsi_Host
*shost
= class_to_shost(dev
);
2289 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2290 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2291 (unsigned long long)phba
->cfg_soft_wwnn
);
2295 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2296 * @cdev: class device that is converted into a Scsi_host.
2297 * @buf: contains the ww node name in hexadecimal.
2298 * @count: number of wwnn bytes in buf.
2301 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2302 * value of count on success
2305 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
2306 const char *buf
, size_t count
)
2308 struct Scsi_Host
*shost
= class_to_shost(dev
);
2309 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2310 unsigned int cnt
= count
;
2314 /* count may include a LF at end of string */
2315 if (buf
[cnt
-1] == '\n')
2318 if (!phba
->soft_wwn_enable
)
2321 rc
= lpfc_wwn_set(buf
, cnt
, wwnn
);
2323 /* Allow wwnn to be set many times, as long as the enable
2324 * is set. However, once the wwpn is set, everything locks.
2329 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
2331 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2332 "lpfc%d: soft_wwnn set. Value will take effect upon "
2333 "setting of the soft_wwpn\n", phba
->brd_no
);
2337 static DEVICE_ATTR(lpfc_soft_wwnn
, S_IRUGO
| S_IWUSR
,
2338 lpfc_soft_wwnn_show
, lpfc_soft_wwnn_store
);
2341 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for
2342 * Optimized Access Storage (OAS) operations.
2343 * @dev: class device that is converted into a Scsi_host.
2344 * @attr: device attribute, not used.
2345 * @buf: buffer for passing information.
2351 lpfc_oas_tgt_show(struct device
*dev
, struct device_attribute
*attr
,
2354 struct Scsi_Host
*shost
= class_to_shost(dev
);
2355 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2357 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2358 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
));
2362 * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for
2363 * Optimized Access Storage (OAS) operations.
2364 * @dev: class device that is converted into a Scsi_host.
2365 * @attr: device attribute, not used.
2366 * @buf: buffer for passing information.
2367 * @count: Size of the data buffer.
2370 * -EINVAL count is invalid, invalid wwpn byte invalid
2371 * -EPERM oas is not supported by hba
2372 * value of count on success
2375 lpfc_oas_tgt_store(struct device
*dev
, struct device_attribute
*attr
,
2376 const char *buf
, size_t count
)
2378 struct Scsi_Host
*shost
= class_to_shost(dev
);
2379 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2380 unsigned int cnt
= count
;
2381 uint8_t wwpn
[WWN_SZ
];
2387 /* count may include a LF at end of string */
2388 if (buf
[cnt
-1] == '\n')
2391 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2395 memcpy(phba
->cfg_oas_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2396 memcpy(phba
->sli4_hba
.oas_next_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2397 if (wwn_to_u64(wwpn
) == 0)
2398 phba
->cfg_oas_flags
|= OAS_FIND_ANY_TARGET
;
2400 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_TARGET
;
2401 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2402 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2405 static DEVICE_ATTR(lpfc_xlane_tgt
, S_IRUGO
| S_IWUSR
,
2406 lpfc_oas_tgt_show
, lpfc_oas_tgt_store
);
2409 * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled
2410 * for Optimized Access Storage (OAS) operations.
2411 * @dev: class device that is converted into a Scsi_host.
2412 * @attr: device attribute, not used.
2413 * @buf: buffer for passing information.
2416 * value of count on success
2419 lpfc_oas_vpt_show(struct device
*dev
, struct device_attribute
*attr
,
2422 struct Scsi_Host
*shost
= class_to_shost(dev
);
2423 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2425 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2426 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
));
2430 * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled
2431 * for Optimized Access Storage (OAS) operations.
2432 * @dev: class device that is converted into a Scsi_host.
2433 * @attr: device attribute, not used.
2434 * @buf: buffer for passing information.
2435 * @count: Size of the data buffer.
2438 * -EINVAL count is invalid, invalid wwpn byte invalid
2439 * -EPERM oas is not supported by hba
2440 * value of count on success
2443 lpfc_oas_vpt_store(struct device
*dev
, struct device_attribute
*attr
,
2444 const char *buf
, size_t count
)
2446 struct Scsi_Host
*shost
= class_to_shost(dev
);
2447 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2448 unsigned int cnt
= count
;
2449 uint8_t wwpn
[WWN_SZ
];
2455 /* count may include a LF at end of string */
2456 if (buf
[cnt
-1] == '\n')
2459 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2463 memcpy(phba
->cfg_oas_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2464 memcpy(phba
->sli4_hba
.oas_next_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2465 if (wwn_to_u64(wwpn
) == 0)
2466 phba
->cfg_oas_flags
|= OAS_FIND_ANY_VPORT
;
2468 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_VPORT
;
2469 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2470 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2473 static DEVICE_ATTR(lpfc_xlane_vpt
, S_IRUGO
| S_IWUSR
,
2474 lpfc_oas_vpt_show
, lpfc_oas_vpt_store
);
2477 * lpfc_oas_lun_state_show - Return the current state (enabled or disabled)
2478 * of whether luns will be enabled or disabled
2479 * for Optimized Access Storage (OAS) operations.
2480 * @dev: class device that is converted into a Scsi_host.
2481 * @attr: device attribute, not used.
2482 * @buf: buffer for passing information.
2485 * size of formatted string.
2488 lpfc_oas_lun_state_show(struct device
*dev
, struct device_attribute
*attr
,
2491 struct Scsi_Host
*shost
= class_to_shost(dev
);
2492 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2494 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_state
);
2498 * lpfc_oas_lun_state_store - Store the state (enabled or disabled)
2499 * of whether luns will be enabled or disabled
2500 * for Optimized Access Storage (OAS) operations.
2501 * @dev: class device that is converted into a Scsi_host.
2502 * @attr: device attribute, not used.
2503 * @buf: buffer for passing information.
2504 * @count: Size of the data buffer.
2507 * -EINVAL count is invalid, invalid wwpn byte invalid
2508 * -EPERM oas is not supported by hba
2509 * value of count on success
2512 lpfc_oas_lun_state_store(struct device
*dev
, struct device_attribute
*attr
,
2513 const char *buf
, size_t count
)
2515 struct Scsi_Host
*shost
= class_to_shost(dev
);
2516 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2522 if (!isdigit(buf
[0]))
2525 if (sscanf(buf
, "%i", &val
) != 1)
2528 if ((val
!= 0) && (val
!= 1))
2531 phba
->cfg_oas_lun_state
= val
;
2535 static DEVICE_ATTR(lpfc_xlane_lun_state
, S_IRUGO
| S_IWUSR
,
2536 lpfc_oas_lun_state_show
, lpfc_oas_lun_state_store
);
2539 * lpfc_oas_lun_status_show - Return the status of the Optimized Access
2540 * Storage (OAS) lun returned by the
2541 * lpfc_oas_lun_show function.
2542 * @dev: class device that is converted into a Scsi_host.
2543 * @attr: device attribute, not used.
2544 * @buf: buffer for passing information.
2547 * size of formatted string.
2550 lpfc_oas_lun_status_show(struct device
*dev
, struct device_attribute
*attr
,
2553 struct Scsi_Host
*shost
= class_to_shost(dev
);
2554 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2556 if (!(phba
->cfg_oas_flags
& OAS_LUN_VALID
))
2559 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_status
);
2561 static DEVICE_ATTR(lpfc_xlane_lun_status
, S_IRUGO
,
2562 lpfc_oas_lun_status_show
, NULL
);
2566 * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage
2568 * @phba: lpfc_hba pointer.
2569 * @ndlp: pointer to fcp target node.
2570 * @lun: the fc lun for setting oas state.
2571 * @oas_state: the oas state to be set to the lun.
2575 * -EPERM OAS is not enabled or not supported by this port.
2579 lpfc_oas_lun_state_set(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2580 uint8_t tgt_wwpn
[], uint64_t lun
, uint32_t oas_state
)
2589 if (!lpfc_enable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2590 (struct lpfc_name
*)tgt_wwpn
, lun
))
2593 lpfc_disable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2594 (struct lpfc_name
*)tgt_wwpn
, lun
);
2601 * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized
2602 * Access Storage (OAS) operations.
2603 * @phba: lpfc_hba pointer.
2604 * @vpt_wwpn: wwpn of the vport associated with the returned lun
2605 * @tgt_wwpn: wwpn of the target associated with the returned lun
2606 * @lun_status: status of the lun returned lun
2608 * Returns the first or next lun enabled for OAS operations for the vport/target
2609 * specified. If a lun is found, its vport wwpn, target wwpn and status is
2610 * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned.
2613 * lun that is OAS enabled for the vport/target
2614 * NOT_OAS_ENABLED_LUN when no oas enabled lun found.
2617 lpfc_oas_lun_get_next(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2618 uint8_t tgt_wwpn
[], uint32_t *lun_status
)
2622 if (unlikely(!phba
) || !vpt_wwpn
|| !tgt_wwpn
)
2623 return NOT_OAS_ENABLED_LUN
;
2624 if (lpfc_find_next_oas_lun(phba
, (struct lpfc_name
*)
2625 phba
->sli4_hba
.oas_next_vpt_wwpn
,
2626 (struct lpfc_name
*)
2627 phba
->sli4_hba
.oas_next_tgt_wwpn
,
2628 &phba
->sli4_hba
.oas_next_lun
,
2629 (struct lpfc_name
*)vpt_wwpn
,
2630 (struct lpfc_name
*)tgt_wwpn
,
2631 &found_lun
, lun_status
))
2634 return NOT_OAS_ENABLED_LUN
;
2638 * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations
2639 * @phba: lpfc_hba pointer.
2640 * @vpt_wwpn: vport wwpn by reference.
2641 * @tgt_wwpn: target wwpn by reference.
2642 * @lun: the fc lun for setting oas state.
2643 * @oas_state: the oas state to be set to the oas_lun.
2645 * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE)
2646 * a lun for OAS operations.
2650 * -ENOMEM: failed to enable an lun for OAS operations
2651 * -EPERM: OAS is not enabled
2654 lpfc_oas_lun_state_change(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2655 uint8_t tgt_wwpn
[], uint64_t lun
,
2661 rc
= lpfc_oas_lun_state_set(phba
, vpt_wwpn
, tgt_wwpn
, lun
,
2667 * lpfc_oas_lun_show - Return oas enabled luns from a chosen target
2668 * @dev: class device that is converted into a Scsi_host.
2669 * @attr: device attribute, not used.
2670 * @buf: buffer for passing information.
2672 * This routine returns a lun enabled for OAS each time the function
2676 * SUCCESS: size of formatted string.
2677 * -EFAULT: target or vport wwpn was not set properly.
2678 * -EPERM: oas is not enabled.
2681 lpfc_oas_lun_show(struct device
*dev
, struct device_attribute
*attr
,
2684 struct Scsi_Host
*shost
= class_to_shost(dev
);
2685 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2693 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
2694 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_VPORT
))
2697 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
2698 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_TARGET
))
2701 oas_lun
= lpfc_oas_lun_get_next(phba
, phba
->cfg_oas_vpt_wwpn
,
2702 phba
->cfg_oas_tgt_wwpn
,
2703 &phba
->cfg_oas_lun_status
);
2704 if (oas_lun
!= NOT_OAS_ENABLED_LUN
)
2705 phba
->cfg_oas_flags
|= OAS_LUN_VALID
;
2707 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "0x%llx", oas_lun
);
2713 * lpfc_oas_lun_store - Sets the OAS state for lun
2714 * @dev: class device that is converted into a Scsi_host.
2715 * @attr: device attribute, not used.
2716 * @buf: buffer for passing information.
2718 * This function sets the OAS state for lun. Before this function is called,
2719 * the vport wwpn, target wwpn, and oas state need to be set.
2722 * SUCCESS: size of formatted string.
2723 * -EFAULT: target or vport wwpn was not set properly.
2724 * -EPERM: oas is not enabled.
2725 * size of formatted string.
2728 lpfc_oas_lun_store(struct device
*dev
, struct device_attribute
*attr
,
2729 const char *buf
, size_t count
)
2731 struct Scsi_Host
*shost
= class_to_shost(dev
);
2732 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2739 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
2742 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
2745 if (!isdigit(buf
[0]))
2748 if (sscanf(buf
, "0x%llx", &scsi_lun
) != 1)
2751 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
,
2752 "3372 Try to set vport 0x%llx target 0x%llx lun:%lld "
2753 "with oas set to %d\n",
2754 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
),
2755 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
), scsi_lun
,
2756 phba
->cfg_oas_lun_state
);
2758 rc
= lpfc_oas_lun_state_change(phba
, phba
->cfg_oas_vpt_wwpn
,
2759 phba
->cfg_oas_tgt_wwpn
, scsi_lun
,
2760 phba
->cfg_oas_lun_state
);
2767 static DEVICE_ATTR(lpfc_xlane_lun
, S_IRUGO
| S_IWUSR
,
2768 lpfc_oas_lun_show
, lpfc_oas_lun_store
);
2770 static int lpfc_poll
= 0;
2771 module_param(lpfc_poll
, int, S_IRUGO
);
2772 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
2774 " 1 - poll with interrupts enabled"
2775 " 3 - poll and disable FCP ring interrupts");
2777 static DEVICE_ATTR(lpfc_poll
, S_IRUGO
| S_IWUSR
,
2778 lpfc_poll_show
, lpfc_poll_store
);
2780 int lpfc_sli_mode
= 0;
2781 module_param(lpfc_sli_mode
, int, S_IRUGO
);
2782 MODULE_PARM_DESC(lpfc_sli_mode
, "SLI mode selector:"
2783 " 0 - auto (SLI-3 if supported),"
2784 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
2785 " 3 - select SLI-3");
2787 int lpfc_enable_npiv
= 1;
2788 module_param(lpfc_enable_npiv
, int, S_IRUGO
);
2789 MODULE_PARM_DESC(lpfc_enable_npiv
, "Enable NPIV functionality");
2790 lpfc_param_show(enable_npiv
);
2791 lpfc_param_init(enable_npiv
, 1, 0, 1);
2792 static DEVICE_ATTR(lpfc_enable_npiv
, S_IRUGO
, lpfc_enable_npiv_show
, NULL
);
2794 LPFC_ATTR_R(fcf_failover_policy
, 1, 1, 2,
2795 "FCF Fast failover=1 Priority failover=2");
2797 int lpfc_enable_rrq
= 2;
2798 module_param(lpfc_enable_rrq
, int, S_IRUGO
);
2799 MODULE_PARM_DESC(lpfc_enable_rrq
, "Enable RRQ functionality");
2800 lpfc_param_show(enable_rrq
);
2802 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
2803 # 0x0 = disabled, XRI/OXID use not tracked.
2804 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
2805 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
2807 lpfc_param_init(enable_rrq
, 2, 0, 2);
2808 static DEVICE_ATTR(lpfc_enable_rrq
, S_IRUGO
, lpfc_enable_rrq_show
, NULL
);
2811 # lpfc_suppress_link_up: Bring link up at initialization
2812 # 0x0 = bring link up (issue MBX_INIT_LINK)
2813 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
2814 # 0x2 = never bring up link
2815 # Default value is 0.
2817 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
2818 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
2819 "Suppress Link Up at initialization");
2821 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
2829 lpfc_iocb_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
2831 struct Scsi_Host
*shost
= class_to_shost(dev
);
2832 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2834 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->iocb_max
);
2837 static DEVICE_ATTR(iocb_hw
, S_IRUGO
,
2838 lpfc_iocb_hw_show
, NULL
);
2840 lpfc_txq_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
2842 struct Scsi_Host
*shost
= class_to_shost(dev
);
2843 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2845 return snprintf(buf
, PAGE_SIZE
, "%d\n",
2846 phba
->sli
.ring
[LPFC_ELS_RING
].txq_max
);
2849 static DEVICE_ATTR(txq_hw
, S_IRUGO
,
2850 lpfc_txq_hw_show
, NULL
);
2852 lpfc_txcmplq_hw_show(struct device
*dev
, struct device_attribute
*attr
,
2855 struct Scsi_Host
*shost
= class_to_shost(dev
);
2856 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2858 return snprintf(buf
, PAGE_SIZE
, "%d\n",
2859 phba
->sli
.ring
[LPFC_ELS_RING
].txcmplq_max
);
2862 static DEVICE_ATTR(txcmplq_hw
, S_IRUGO
,
2863 lpfc_txcmplq_hw_show
, NULL
);
2865 int lpfc_iocb_cnt
= 2;
2866 module_param(lpfc_iocb_cnt
, int, S_IRUGO
);
2867 MODULE_PARM_DESC(lpfc_iocb_cnt
,
2868 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
2869 lpfc_param_show(iocb_cnt
);
2870 lpfc_param_init(iocb_cnt
, 2, 1, 5);
2871 static DEVICE_ATTR(lpfc_iocb_cnt
, S_IRUGO
,
2872 lpfc_iocb_cnt_show
, NULL
);
2875 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
2876 # until the timer expires. Value range is [0,255]. Default value is 30.
2878 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2879 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2880 module_param(lpfc_nodev_tmo
, int, 0);
2881 MODULE_PARM_DESC(lpfc_nodev_tmo
,
2882 "Seconds driver will hold I/O waiting "
2883 "for a device to come back");
2886 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
2887 * @dev: class converted to a Scsi_host structure.
2888 * @attr: device attribute, not used.
2889 * @buf: on return contains the dev loss timeout in decimal.
2891 * Returns: size of formatted string.
2894 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
2897 struct Scsi_Host
*shost
= class_to_shost(dev
);
2898 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2900 return snprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
2904 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
2905 * @vport: lpfc vport structure pointer.
2906 * @val: contains the nodev timeout value.
2909 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
2910 * a kernel error message is printed and zero is returned.
2911 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2912 * Otherwise nodev tmo is set to the default value.
2915 * zero if already set or if val is in range
2916 * -EINVAL val out of range
2919 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
2921 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
2922 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
2923 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
2924 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2925 "0407 Ignoring nodev_tmo module "
2926 "parameter because devloss_tmo is "
2931 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2932 vport
->cfg_nodev_tmo
= val
;
2933 vport
->cfg_devloss_tmo
= val
;
2936 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2937 "0400 lpfc_nodev_tmo attribute cannot be set to"
2938 " %d, allowed range is [%d, %d]\n",
2939 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2940 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2945 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
2946 * @vport: lpfc vport structure pointer.
2949 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
2952 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
2954 struct Scsi_Host
*shost
;
2955 struct lpfc_nodelist
*ndlp
;
2957 shost
= lpfc_shost_from_vport(vport
);
2958 spin_lock_irq(shost
->host_lock
);
2959 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
)
2960 if (NLP_CHK_NODE_ACT(ndlp
) && ndlp
->rport
)
2961 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
2962 spin_unlock_irq(shost
->host_lock
);
2966 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
2967 * @vport: lpfc vport structure pointer.
2968 * @val: contains the tmo value.
2971 * If the devloss tmo is already set or the vport dev loss tmo has changed
2972 * then a kernel error message is printed and zero is returned.
2973 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2974 * Otherwise nodev tmo is set to the default value.
2977 * zero if already set or if val is in range
2978 * -EINVAL val out of range
2981 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
2983 if (vport
->dev_loss_tmo_changed
||
2984 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
2985 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2986 "0401 Ignoring change to nodev_tmo "
2987 "because devloss_tmo is set.\n");
2990 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2991 vport
->cfg_nodev_tmo
= val
;
2992 vport
->cfg_devloss_tmo
= val
;
2994 * For compat: set the fc_host dev loss so new rports
2995 * will get the value.
2997 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
2998 lpfc_update_rport_devloss_tmo(vport
);
3001 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3002 "0403 lpfc_nodev_tmo attribute cannot be set to"
3003 "%d, allowed range is [%d, %d]\n",
3004 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3008 lpfc_vport_param_store(nodev_tmo
)
3010 static DEVICE_ATTR(lpfc_nodev_tmo
, S_IRUGO
| S_IWUSR
,
3011 lpfc_nodev_tmo_show
, lpfc_nodev_tmo_store
);
3014 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
3015 # disappear until the timer expires. Value range is [0,255]. Default
3018 module_param(lpfc_devloss_tmo
, int, S_IRUGO
);
3019 MODULE_PARM_DESC(lpfc_devloss_tmo
,
3020 "Seconds driver will hold I/O waiting "
3021 "for a device to come back");
3022 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
3023 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
3024 lpfc_vport_param_show(devloss_tmo
)
3027 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
3028 * @vport: lpfc vport structure pointer.
3029 * @val: contains the tmo value.
3032 * If val is in a valid range then set the vport nodev tmo,
3033 * devloss tmo, also set the vport dev loss tmo changed flag.
3034 * Else a kernel error message is printed.
3037 * zero if val is in range
3038 * -EINVAL val out of range
3041 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
3043 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3044 vport
->cfg_nodev_tmo
= val
;
3045 vport
->cfg_devloss_tmo
= val
;
3046 vport
->dev_loss_tmo_changed
= 1;
3047 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3048 lpfc_update_rport_devloss_tmo(vport
);
3052 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3053 "0404 lpfc_devloss_tmo attribute cannot be set to"
3054 " %d, allowed range is [%d, %d]\n",
3055 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3059 lpfc_vport_param_store(devloss_tmo
)
3060 static DEVICE_ATTR(lpfc_devloss_tmo
, S_IRUGO
| S_IWUSR
,
3061 lpfc_devloss_tmo_show
, lpfc_devloss_tmo_store
);
3064 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
3065 # deluged with LOTS of information.
3066 # You can set a bit mask to record specific types of verbose messages:
3067 # See lpfc_logmsh.h for definitions.
3069 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
3070 "Verbose logging bit-mask");
3073 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
3074 # objects that have been registered with the nameserver after login.
3076 LPFC_VPORT_ATTR_R(enable_da_id
, 1, 0, 1,
3077 "Deregister nameserver objects before LOGO");
3080 # lun_queue_depth: This parameter is used to limit the number of outstanding
3081 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
3082 # If this parameter value is greater than 1/8th the maximum number of exchanges
3083 # supported by the HBA port, then the lun queue depth will be reduced to
3084 # 1/8th the maximum number of exchanges.
3086 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 512,
3087 "Max number of FCP commands we can queue to a specific LUN");
3090 # tgt_queue_depth: This parameter is used to limit the number of outstanding
3091 # commands per target port. Value range is [10,65535]. Default value is 65535.
3093 LPFC_VPORT_ATTR_R(tgt_queue_depth
, 65535, 10, 65535,
3094 "Max number of FCP commands we can queue to a specific target port");
3097 # hba_queue_depth: This parameter is used to limit the number of outstanding
3098 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
3099 # value is greater than the maximum number of exchanges supported by the HBA,
3100 # then maximum number of exchanges supported by the HBA is used to determine
3101 # the hba_queue_depth.
3103 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
3104 "Max number of FCP commands we can queue to a lpfc HBA");
3107 # peer_port_login: This parameter allows/prevents logins
3108 # between peer ports hosted on the same physical port.
3109 # When this parameter is set 0 peer ports of same physical port
3110 # are not allowed to login to each other.
3111 # When this parameter is set 1 peer ports of same physical port
3112 # are allowed to login to each other.
3113 # Default value of this parameter is 0.
3115 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
3116 "Allow peer ports on the same physical port to login to each "
3120 # restrict_login: This parameter allows/prevents logins
3121 # between Virtual Ports and remote initiators.
3122 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
3123 # other initiators and will attempt to PLOGI all remote ports.
3124 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
3125 # remote ports and will not attempt to PLOGI to other initiators.
3126 # This parameter does not restrict to the physical port.
3127 # This parameter does not restrict logins to Fabric resident remote ports.
3128 # Default value of this parameter is 1.
3130 static int lpfc_restrict_login
= 1;
3131 module_param(lpfc_restrict_login
, int, S_IRUGO
);
3132 MODULE_PARM_DESC(lpfc_restrict_login
,
3133 "Restrict virtual ports login to remote initiators.");
3134 lpfc_vport_param_show(restrict_login
);
3137 * lpfc_restrict_login_init - Set the vport restrict login flag
3138 * @vport: lpfc vport structure pointer.
3139 * @val: contains the restrict login value.
3142 * If val is not in a valid range then log a kernel error message and set
3143 * the vport restrict login to one.
3144 * If the port type is physical clear the restrict login flag and return.
3145 * Else set the restrict login flag to val.
3148 * zero if val is in range
3149 * -EINVAL val out of range
3152 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
3154 if (val
< 0 || val
> 1) {
3155 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3156 "0422 lpfc_restrict_login attribute cannot "
3157 "be set to %d, allowed range is [0, 1]\n",
3159 vport
->cfg_restrict_login
= 1;
3162 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
3163 vport
->cfg_restrict_login
= 0;
3166 vport
->cfg_restrict_login
= val
;
3171 * lpfc_restrict_login_set - Set the vport restrict login flag
3172 * @vport: lpfc vport structure pointer.
3173 * @val: contains the restrict login value.
3176 * If val is not in a valid range then log a kernel error message and set
3177 * the vport restrict login to one.
3178 * If the port type is physical and the val is not zero log a kernel
3179 * error message, clear the restrict login flag and return zero.
3180 * Else set the restrict login flag to val.
3183 * zero if val is in range
3184 * -EINVAL val out of range
3187 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
3189 if (val
< 0 || val
> 1) {
3190 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3191 "0425 lpfc_restrict_login attribute cannot "
3192 "be set to %d, allowed range is [0, 1]\n",
3194 vport
->cfg_restrict_login
= 1;
3197 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
3198 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3199 "0468 lpfc_restrict_login must be 0 for "
3200 "Physical ports.\n");
3201 vport
->cfg_restrict_login
= 0;
3204 vport
->cfg_restrict_login
= val
;
3207 lpfc_vport_param_store(restrict_login
);
3208 static DEVICE_ATTR(lpfc_restrict_login
, S_IRUGO
| S_IWUSR
,
3209 lpfc_restrict_login_show
, lpfc_restrict_login_store
);
3212 # Some disk devices have a "select ID" or "select Target" capability.
3213 # From a protocol standpoint "select ID" usually means select the
3214 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
3215 # annex" which contains a table that maps a "select ID" (a number
3216 # between 0 and 7F) to an ALPA. By default, for compatibility with
3217 # older drivers, the lpfc driver scans this table from low ALPA to high
3220 # Turning on the scan-down variable (on = 1, off = 0) will
3221 # cause the lpfc driver to use an inverted table, effectively
3222 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
3224 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
3225 # and will not work across a fabric. Also this parameter will take
3226 # effect only in the case when ALPA map is not available.)
3228 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
3229 "Start scanning for devices from highest ALPA to lowest");
3232 # lpfc_topology: link topology for init link
3233 # 0x0 = attempt loop mode then point-to-point
3234 # 0x01 = internal loopback mode
3235 # 0x02 = attempt point-to-point mode only
3236 # 0x04 = attempt loop mode only
3237 # 0x06 = attempt point-to-point mode then loop
3238 # Set point-to-point mode if you want to run as an N_Port.
3239 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
3240 # Default value is 0.
3244 * lpfc_topology_set - Set the adapters topology field
3245 * @phba: lpfc_hba pointer.
3246 * @val: topology value.
3249 * If val is in a valid range then set the adapter's topology field and
3250 * issue a lip; if the lip fails reset the topology to the old value.
3252 * If the value is not in range log a kernel error message and return an error.
3255 * zero if val is in range and lip okay
3256 * non-zero return value from lpfc_issue_lip()
3257 * -EINVAL val out of range
3260 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
3261 const char *buf
, size_t count
)
3263 struct Scsi_Host
*shost
= class_to_shost(dev
);
3264 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3265 struct lpfc_hba
*phba
= vport
->phba
;
3268 const char *val_buf
= buf
;
3272 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
3274 val_buf
= &buf
[strlen("nolip ")];
3277 if (!isdigit(val_buf
[0]))
3279 if (sscanf(val_buf
, "%i", &val
) != 1)
3282 if (val
>= 0 && val
<= 6) {
3283 prev_val
= phba
->cfg_topology
;
3284 if (phba
->cfg_link_speed
== LPFC_USER_LINK_SPEED_16G
&&
3286 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3287 "3113 Loop mode not supported at speed %d\n",
3291 if (phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G6_FC
&&
3293 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3294 "3114 Loop mode not supported\n");
3297 phba
->cfg_topology
= val
;
3301 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3302 "3054 lpfc_topology changed from %d to %d\n",
3304 if (prev_val
!= val
&& phba
->sli_rev
== LPFC_SLI_REV4
)
3305 phba
->fc_topology_changed
= 1;
3306 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
3308 phba
->cfg_topology
= prev_val
;
3313 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3314 "%d:0467 lpfc_topology attribute cannot be set to %d, "
3315 "allowed range is [0, 6]\n",
3319 static int lpfc_topology
= 0;
3320 module_param(lpfc_topology
, int, S_IRUGO
);
3321 MODULE_PARM_DESC(lpfc_topology
, "Select Fibre Channel topology");
3322 lpfc_param_show(topology
)
3323 lpfc_param_init(topology
, 0, 0, 6)
3324 static DEVICE_ATTR(lpfc_topology
, S_IRUGO
| S_IWUSR
,
3325 lpfc_topology_show
, lpfc_topology_store
);
3328 * lpfc_static_vport_show: Read callback function for
3329 * lpfc_static_vport sysfs file.
3330 * @dev: Pointer to class device object.
3331 * @attr: device attribute structure.
3332 * @buf: Data buffer.
3334 * This function is the read call back function for
3335 * lpfc_static_vport sysfs file. The lpfc_static_vport
3336 * sysfs file report the mageability of the vport.
3339 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
3342 struct Scsi_Host
*shost
= class_to_shost(dev
);
3343 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3344 if (vport
->vport_flag
& STATIC_VPORT
)
3345 sprintf(buf
, "1\n");
3347 sprintf(buf
, "0\n");
3353 * Sysfs attribute to control the statistical data collection.
3355 static DEVICE_ATTR(lpfc_static_vport
, S_IRUGO
,
3356 lpfc_static_vport_show
, NULL
);
3359 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
3360 * @dev: Pointer to class device.
3361 * @buf: Data buffer.
3362 * @count: Size of the data buffer.
3364 * This function get called when an user write to the lpfc_stat_data_ctrl
3365 * sysfs file. This function parse the command written to the sysfs file
3366 * and take appropriate action. These commands are used for controlling
3367 * driver statistical data collection.
3368 * Following are the command this function handles.
3370 * setbucket <bucket_type> <base> <step>
3371 * = Set the latency buckets.
3372 * destroybucket = destroy all the buckets.
3373 * start = start data collection
3374 * stop = stop data collection
3375 * reset = reset the collected data
3378 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
3379 const char *buf
, size_t count
)
3381 struct Scsi_Host
*shost
= class_to_shost(dev
);
3382 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3383 struct lpfc_hba
*phba
= vport
->phba
;
3384 #define LPFC_MAX_DATA_CTRL_LEN 1024
3385 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
3387 char *str_ptr
, *token
;
3388 struct lpfc_vport
**vports
;
3389 struct Scsi_Host
*v_shost
;
3390 char *bucket_type_str
, *base_str
, *step_str
;
3391 unsigned long base
, step
, bucket_type
;
3393 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
3394 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
3397 strncpy(bucket_data
, buf
, LPFC_MAX_DATA_CTRL_LEN
);
3398 str_ptr
= &bucket_data
[0];
3399 /* Ignore this token - this is command token */
3400 token
= strsep(&str_ptr
, "\t ");
3404 bucket_type_str
= strsep(&str_ptr
, "\t ");
3405 if (!bucket_type_str
)
3408 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
3409 bucket_type
= LPFC_LINEAR_BUCKET
;
3410 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
3411 bucket_type
= LPFC_POWER2_BUCKET
;
3415 base_str
= strsep(&str_ptr
, "\t ");
3418 base
= simple_strtoul(base_str
, NULL
, 0);
3420 step_str
= strsep(&str_ptr
, "\t ");
3423 step
= simple_strtoul(step_str
, NULL
, 0);
3427 /* Block the data collection for every vport */
3428 vports
= lpfc_create_vport_work_array(phba
);
3432 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3433 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3434 spin_lock_irq(v_shost
->host_lock
);
3435 /* Block and reset data collection */
3436 vports
[i
]->stat_data_blocked
= 1;
3437 if (vports
[i
]->stat_data_enabled
)
3438 lpfc_vport_reset_stat_data(vports
[i
]);
3439 spin_unlock_irq(v_shost
->host_lock
);
3442 /* Set the bucket attributes */
3443 phba
->bucket_type
= bucket_type
;
3444 phba
->bucket_base
= base
;
3445 phba
->bucket_step
= step
;
3447 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3448 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3450 /* Unblock data collection */
3451 spin_lock_irq(v_shost
->host_lock
);
3452 vports
[i
]->stat_data_blocked
= 0;
3453 spin_unlock_irq(v_shost
->host_lock
);
3455 lpfc_destroy_vport_work_array(phba
, vports
);
3459 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
3460 vports
= lpfc_create_vport_work_array(phba
);
3464 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3465 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3466 spin_lock_irq(shost
->host_lock
);
3467 vports
[i
]->stat_data_blocked
= 1;
3468 lpfc_free_bucket(vport
);
3469 vport
->stat_data_enabled
= 0;
3470 vports
[i
]->stat_data_blocked
= 0;
3471 spin_unlock_irq(shost
->host_lock
);
3473 lpfc_destroy_vport_work_array(phba
, vports
);
3474 phba
->bucket_type
= LPFC_NO_BUCKET
;
3475 phba
->bucket_base
= 0;
3476 phba
->bucket_step
= 0;
3480 if (!strncmp(buf
, "start", strlen("start"))) {
3481 /* If no buckets configured return error */
3482 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
3484 spin_lock_irq(shost
->host_lock
);
3485 if (vport
->stat_data_enabled
) {
3486 spin_unlock_irq(shost
->host_lock
);
3489 lpfc_alloc_bucket(vport
);
3490 vport
->stat_data_enabled
= 1;
3491 spin_unlock_irq(shost
->host_lock
);
3495 if (!strncmp(buf
, "stop", strlen("stop"))) {
3496 spin_lock_irq(shost
->host_lock
);
3497 if (vport
->stat_data_enabled
== 0) {
3498 spin_unlock_irq(shost
->host_lock
);
3501 lpfc_free_bucket(vport
);
3502 vport
->stat_data_enabled
= 0;
3503 spin_unlock_irq(shost
->host_lock
);
3507 if (!strncmp(buf
, "reset", strlen("reset"))) {
3508 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
3509 || !vport
->stat_data_enabled
)
3511 spin_lock_irq(shost
->host_lock
);
3512 vport
->stat_data_blocked
= 1;
3513 lpfc_vport_reset_stat_data(vport
);
3514 vport
->stat_data_blocked
= 0;
3515 spin_unlock_irq(shost
->host_lock
);
3523 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
3524 * @dev: Pointer to class device object.
3525 * @buf: Data buffer.
3527 * This function is the read call back function for
3528 * lpfc_stat_data_ctrl sysfs file. This function report the
3529 * current statistical data collection state.
3532 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
3535 struct Scsi_Host
*shost
= class_to_shost(dev
);
3536 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3537 struct lpfc_hba
*phba
= vport
->phba
;
3541 unsigned long bucket_value
;
3543 switch (phba
->bucket_type
) {
3544 case LPFC_LINEAR_BUCKET
:
3545 bucket_type
= "linear";
3547 case LPFC_POWER2_BUCKET
:
3548 bucket_type
= "power2";
3551 bucket_type
= "No Bucket";
3555 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
3556 "blocked :%d, Bucket type :%s, Bucket base :%d,"
3557 " Bucket step :%d\nLatency Ranges :",
3558 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
3559 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
3560 index
= strlen(buf
);
3561 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
3562 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3563 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
3564 bucket_value
= phba
->bucket_base
+
3565 phba
->bucket_step
* i
;
3567 bucket_value
= phba
->bucket_base
+
3568 (1 << i
) * phba
->bucket_step
;
3570 if (index
+ 10 > PAGE_SIZE
)
3572 sprintf(&buf
[index
], "%08ld ", bucket_value
);
3573 index
= strlen(buf
);
3576 sprintf(&buf
[index
], "\n");
3581 * Sysfs attribute to control the statistical data collection.
3583 static DEVICE_ATTR(lpfc_stat_data_ctrl
, S_IRUGO
| S_IWUSR
,
3584 lpfc_stat_data_ctrl_show
, lpfc_stat_data_ctrl_store
);
3587 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
3591 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
3594 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
3595 #define MAX_STAT_DATA_SIZE_PER_TARGET \
3596 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
3600 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
3602 * @kobj: Pointer to the kernel object
3603 * @bin_attr: Attribute object
3604 * @buff: Buffer pointer
3606 * @count: Buffer size
3608 * This function is the read call back function for lpfc_drvr_stat_data
3609 * sysfs file. This function export the statistical data to user
3613 sysfs_drvr_stat_data_read(struct file
*filp
, struct kobject
*kobj
,
3614 struct bin_attribute
*bin_attr
,
3615 char *buf
, loff_t off
, size_t count
)
3617 struct device
*dev
= container_of(kobj
, struct device
,
3619 struct Scsi_Host
*shost
= class_to_shost(dev
);
3620 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3621 struct lpfc_hba
*phba
= vport
->phba
;
3622 int i
= 0, index
= 0;
3623 unsigned long nport_index
;
3624 struct lpfc_nodelist
*ndlp
= NULL
;
3625 nport_index
= (unsigned long)off
/
3626 MAX_STAT_DATA_SIZE_PER_TARGET
;
3628 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
3629 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
3632 spin_lock_irq(shost
->host_lock
);
3633 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3634 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
3637 if (nport_index
> 0) {
3642 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
3646 if (!ndlp
->lat_data
)
3650 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
3651 ndlp
->nlp_portname
.u
.wwn
[0],
3652 ndlp
->nlp_portname
.u
.wwn
[1],
3653 ndlp
->nlp_portname
.u
.wwn
[2],
3654 ndlp
->nlp_portname
.u
.wwn
[3],
3655 ndlp
->nlp_portname
.u
.wwn
[4],
3656 ndlp
->nlp_portname
.u
.wwn
[5],
3657 ndlp
->nlp_portname
.u
.wwn
[6],
3658 ndlp
->nlp_portname
.u
.wwn
[7]);
3660 index
= strlen(buf
);
3662 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3663 sprintf(&buf
[index
], "%010u,",
3664 ndlp
->lat_data
[i
].cmd_count
);
3665 index
= strlen(buf
);
3667 sprintf(&buf
[index
], "\n");
3668 index
= strlen(buf
);
3670 spin_unlock_irq(shost
->host_lock
);
3674 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
3676 .name
= "lpfc_drvr_stat_data",
3679 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
3680 .read
= sysfs_drvr_stat_data_read
,
3685 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
3687 # Value range is [0,16]. Default value is 0.
3690 * lpfc_link_speed_set - Set the adapters link speed
3691 * @phba: lpfc_hba pointer.
3692 * @val: link speed value.
3695 * If val is in a valid range then set the adapter's link speed field and
3696 * issue a lip; if the lip fails reset the link speed to the old value.
3699 * If the value is not in range log a kernel error message and return an error.
3702 * zero if val is in range and lip okay.
3703 * non-zero return value from lpfc_issue_lip()
3704 * -EINVAL val out of range
3707 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
3708 const char *buf
, size_t count
)
3710 struct Scsi_Host
*shost
= class_to_shost(dev
);
3711 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3712 struct lpfc_hba
*phba
= vport
->phba
;
3713 int val
= LPFC_USER_LINK_SPEED_AUTO
;
3715 const char *val_buf
= buf
;
3719 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
3721 val_buf
= &buf
[strlen("nolip ")];
3724 if (!isdigit(val_buf
[0]))
3726 if (sscanf(val_buf
, "%i", &val
) != 1)
3729 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3730 "3055 lpfc_link_speed changed from %d to %d %s\n",
3731 phba
->cfg_link_speed
, val
, nolip
? "(nolip)" : "(lip)");
3733 if (((val
== LPFC_USER_LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
3734 ((val
== LPFC_USER_LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
3735 ((val
== LPFC_USER_LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
3736 ((val
== LPFC_USER_LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
3737 ((val
== LPFC_USER_LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)) ||
3738 ((val
== LPFC_USER_LINK_SPEED_16G
) && !(phba
->lmt
& LMT_16Gb
)) ||
3739 ((val
== LPFC_USER_LINK_SPEED_32G
) && !(phba
->lmt
& LMT_32Gb
))) {
3740 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3741 "2879 lpfc_link_speed attribute cannot be set "
3742 "to %d. Speed is not supported by this port.\n",
3746 if (val
== LPFC_USER_LINK_SPEED_16G
&&
3747 phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
3748 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3749 "3112 lpfc_link_speed attribute cannot be set "
3750 "to %d. Speed is not supported in loop mode.\n",
3754 if ((val
>= 0) && (val
<= LPFC_USER_LINK_SPEED_MAX
) &&
3755 (LPFC_USER_LINK_SPEED_BITMAP
& (1 << val
))) {
3756 prev_val
= phba
->cfg_link_speed
;
3757 phba
->cfg_link_speed
= val
;
3761 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
3763 phba
->cfg_link_speed
= prev_val
;
3768 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3769 "0469 lpfc_link_speed attribute cannot be set to %d, "
3770 "allowed values are ["LPFC_LINK_SPEED_STRING
"]\n", val
);
3774 static int lpfc_link_speed
= 0;
3775 module_param(lpfc_link_speed
, int, S_IRUGO
);
3776 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
3777 lpfc_param_show(link_speed
)
3780 * lpfc_link_speed_init - Set the adapters link speed
3781 * @phba: lpfc_hba pointer.
3782 * @val: link speed value.
3785 * If val is in a valid range then set the adapter's link speed field.
3788 * If the value is not in range log a kernel error message, clear the link
3789 * speed and return an error.
3792 * zero if val saved.
3793 * -EINVAL val out of range
3796 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
3798 if (val
== LPFC_USER_LINK_SPEED_16G
&& phba
->cfg_topology
== 4) {
3799 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3800 "3111 lpfc_link_speed of %d cannot "
3801 "support loop mode, setting topology to default.\n",
3803 phba
->cfg_topology
= 0;
3805 if ((val
>= 0) && (val
<= LPFC_USER_LINK_SPEED_MAX
) &&
3806 (LPFC_USER_LINK_SPEED_BITMAP
& (1 << val
))) {
3807 phba
->cfg_link_speed
= val
;
3810 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3811 "0405 lpfc_link_speed attribute cannot "
3812 "be set to %d, allowed values are "
3813 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
3814 phba
->cfg_link_speed
= LPFC_USER_LINK_SPEED_AUTO
;
3818 static DEVICE_ATTR(lpfc_link_speed
, S_IRUGO
| S_IWUSR
,
3819 lpfc_link_speed_show
, lpfc_link_speed_store
);
3822 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
3823 # 0 = aer disabled or not supported
3824 # 1 = aer supported and enabled (default)
3825 # Value range is [0,1]. Default value is 1.
3829 * lpfc_aer_support_store - Set the adapter for aer support
3831 * @dev: class device that is converted into a Scsi_host.
3832 * @attr: device attribute, not used.
3833 * @buf: containing enable or disable aer flag.
3834 * @count: unused variable.
3837 * If the val is 1 and currently the device's AER capability was not
3838 * enabled, invoke the kernel's enable AER helper routine, trying to
3839 * enable the device's AER capability. If the helper routine enabling
3840 * AER returns success, update the device's cfg_aer_support flag to
3841 * indicate AER is supported by the device; otherwise, if the device
3842 * AER capability is already enabled to support AER, then do nothing.
3844 * If the val is 0 and currently the device's AER support was enabled,
3845 * invoke the kernel's disable AER helper routine. After that, update
3846 * the device's cfg_aer_support flag to indicate AER is not supported
3847 * by the device; otherwise, if the device AER capability is already
3848 * disabled from supporting AER, then do nothing.
3851 * length of the buf on success if val is in range the intended mode
3853 * -EINVAL if val out of range or intended mode is not supported.
3856 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
3857 const char *buf
, size_t count
)
3859 struct Scsi_Host
*shost
= class_to_shost(dev
);
3860 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
3861 struct lpfc_hba
*phba
= vport
->phba
;
3862 int val
= 0, rc
= -EINVAL
;
3864 if (!isdigit(buf
[0]))
3866 if (sscanf(buf
, "%i", &val
) != 1)
3871 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
3872 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
3874 spin_lock_irq(&phba
->hbalock
);
3875 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
3876 spin_unlock_irq(&phba
->hbalock
);
3877 phba
->cfg_aer_support
= 0;
3882 phba
->cfg_aer_support
= 0;
3887 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
3888 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
3890 spin_lock_irq(&phba
->hbalock
);
3891 phba
->hba_flag
|= HBA_AER_ENABLED
;
3892 spin_unlock_irq(&phba
->hbalock
);
3893 phba
->cfg_aer_support
= 1;
3898 phba
->cfg_aer_support
= 1;
3909 static int lpfc_aer_support
= 1;
3910 module_param(lpfc_aer_support
, int, S_IRUGO
);
3911 MODULE_PARM_DESC(lpfc_aer_support
, "Enable PCIe device AER support");
3912 lpfc_param_show(aer_support
)
3915 * lpfc_aer_support_init - Set the initial adapters aer support flag
3916 * @phba: lpfc_hba pointer.
3917 * @val: enable aer or disable aer flag.
3920 * If val is in a valid range [0,1], then set the adapter's initial
3921 * cfg_aer_support field. It will be up to the driver's probe_one
3922 * routine to determine whether the device's AER support can be set
3926 * If the value is not in range log a kernel error message, and
3927 * choose the default value of setting AER support and return.
3930 * zero if val saved.
3931 * -EINVAL val out of range
3934 lpfc_aer_support_init(struct lpfc_hba
*phba
, int val
)
3936 if (val
== 0 || val
== 1) {
3937 phba
->cfg_aer_support
= val
;
3940 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3941 "2712 lpfc_aer_support attribute value %d out "
3942 "of range, allowed values are 0|1, setting it "
3943 "to default value of 1\n", val
);
3944 /* By default, try to enable AER on a device */
3945 phba
->cfg_aer_support
= 1;
3949 static DEVICE_ATTR(lpfc_aer_support
, S_IRUGO
| S_IWUSR
,
3950 lpfc_aer_support_show
, lpfc_aer_support_store
);
3953 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
3954 * @dev: class device that is converted into a Scsi_host.
3955 * @attr: device attribute, not used.
3956 * @buf: containing flag 1 for aer cleanup state.
3957 * @count: unused variable.
3960 * If the @buf contains 1 and the device currently has the AER support
3961 * enabled, then invokes the kernel AER helper routine
3962 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
3963 * error status register.
3968 * -EINVAL if the buf does not contain the 1 or the device is not currently
3969 * enabled with the AER support.
3972 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
3973 const char *buf
, size_t count
)
3975 struct Scsi_Host
*shost
= class_to_shost(dev
);
3976 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3977 struct lpfc_hba
*phba
= vport
->phba
;
3980 if (!isdigit(buf
[0]))
3982 if (sscanf(buf
, "%i", &val
) != 1)
3987 if (phba
->hba_flag
& HBA_AER_ENABLED
)
3988 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
3996 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
3997 lpfc_aer_cleanup_state
);
4000 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
4002 * @dev: class device that is converted into a Scsi_host.
4003 * @attr: device attribute, not used.
4004 * @buf: containing the string the number of vfs to be enabled.
4005 * @count: unused variable.
4008 * When this api is called either through user sysfs, the driver shall
4009 * try to enable or disable SR-IOV virtual functions according to the
4012 * If zero virtual function has been enabled to the physical function,
4013 * the driver shall invoke the pci enable virtual function api trying
4014 * to enable the virtual functions. If the nr_vfn provided is greater
4015 * than the maximum supported, the maximum virtual function number will
4016 * be used for invoking the api; otherwise, the nr_vfn provided shall
4017 * be used for invoking the api. If the api call returned success, the
4018 * actual number of virtual functions enabled will be set to the driver
4019 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
4020 * cfg_sriov_nr_virtfn remains zero.
4022 * If none-zero virtual functions have already been enabled to the
4023 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
4024 * -EINVAL will be returned and the driver does nothing;
4026 * If the nr_vfn provided is zero and none-zero virtual functions have
4027 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
4028 * disabling virtual function api shall be invoded to disable all the
4029 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
4030 * zero. Otherwise, if zero virtual function has been enabled, do
4034 * length of the buf on success if val is in range the intended mode
4036 * -EINVAL if val out of range or intended mode is not supported.
4039 lpfc_sriov_nr_virtfn_store(struct device
*dev
, struct device_attribute
*attr
,
4040 const char *buf
, size_t count
)
4042 struct Scsi_Host
*shost
= class_to_shost(dev
);
4043 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4044 struct lpfc_hba
*phba
= vport
->phba
;
4045 struct pci_dev
*pdev
= phba
->pcidev
;
4046 int val
= 0, rc
= -EINVAL
;
4048 /* Sanity check on user data */
4049 if (!isdigit(buf
[0]))
4051 if (sscanf(buf
, "%i", &val
) != 1)
4056 /* Request disabling virtual functions */
4058 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4059 pci_disable_sriov(pdev
);
4060 phba
->cfg_sriov_nr_virtfn
= 0;
4065 /* Request enabling virtual functions */
4066 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4067 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4068 "3018 There are %d virtual functions "
4069 "enabled on physical function.\n",
4070 phba
->cfg_sriov_nr_virtfn
);
4074 if (val
<= LPFC_MAX_VFN_PER_PFN
)
4075 phba
->cfg_sriov_nr_virtfn
= val
;
4077 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4078 "3019 Enabling %d virtual functions is not "
4083 rc
= lpfc_sli_probe_sriov_nr_virtfn(phba
, phba
->cfg_sriov_nr_virtfn
);
4085 phba
->cfg_sriov_nr_virtfn
= 0;
4093 static int lpfc_sriov_nr_virtfn
= LPFC_DEF_VFN_PER_PFN
;
4094 module_param(lpfc_sriov_nr_virtfn
, int, S_IRUGO
|S_IWUSR
);
4095 MODULE_PARM_DESC(lpfc_sriov_nr_virtfn
, "Enable PCIe device SR-IOV virtual fn");
4096 lpfc_param_show(sriov_nr_virtfn
)
4099 * lpfc_sriov_nr_virtfn_init - Set the initial sr-iov virtual function enable
4100 * @phba: lpfc_hba pointer.
4101 * @val: link speed value.
4104 * If val is in a valid range [0,255], then set the adapter's initial
4105 * cfg_sriov_nr_virtfn field. If it's greater than the maximum, the maximum
4106 * number shall be used instead. It will be up to the driver's probe_one
4107 * routine to determine whether the device's SR-IOV is supported or not.
4110 * zero if val saved.
4111 * -EINVAL val out of range
4114 lpfc_sriov_nr_virtfn_init(struct lpfc_hba
*phba
, int val
)
4116 if (val
>= 0 && val
<= LPFC_MAX_VFN_PER_PFN
) {
4117 phba
->cfg_sriov_nr_virtfn
= val
;
4121 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4122 "3017 Enabling %d virtual functions is not "
4126 static DEVICE_ATTR(lpfc_sriov_nr_virtfn
, S_IRUGO
| S_IWUSR
,
4127 lpfc_sriov_nr_virtfn_show
, lpfc_sriov_nr_virtfn_store
);
4130 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
4132 * @dev: class device that is converted into a Scsi_host.
4133 * @attr: device attribute, not used.
4134 * @buf: containing the string the number of vfs to be enabled.
4135 * @count: unused variable.
4140 * length of the buf on success if val is in range the intended mode
4142 * -EINVAL if val out of range or intended mode is not supported.
4145 lpfc_request_firmware_upgrade_store(struct device
*dev
,
4146 struct device_attribute
*attr
,
4147 const char *buf
, size_t count
)
4149 struct Scsi_Host
*shost
= class_to_shost(dev
);
4150 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4151 struct lpfc_hba
*phba
= vport
->phba
;
4152 int val
= 0, rc
= -EINVAL
;
4154 /* Sanity check on user data */
4155 if (!isdigit(buf
[0]))
4157 if (sscanf(buf
, "%i", &val
) != 1)
4162 rc
= lpfc_sli4_request_firmware_update(phba
, RUN_FW_UPGRADE
);
4170 static int lpfc_req_fw_upgrade
;
4171 module_param(lpfc_req_fw_upgrade
, int, S_IRUGO
|S_IWUSR
);
4172 MODULE_PARM_DESC(lpfc_req_fw_upgrade
, "Enable Linux generic firmware upgrade");
4173 lpfc_param_show(request_firmware_upgrade
)
4176 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
4177 * @phba: lpfc_hba pointer.
4181 * Set the initial Linux generic firmware upgrade enable or disable flag.
4184 * zero if val saved.
4185 * -EINVAL val out of range
4188 lpfc_request_firmware_upgrade_init(struct lpfc_hba
*phba
, int val
)
4190 if (val
>= 0 && val
<= 1) {
4191 phba
->cfg_request_firmware_upgrade
= val
;
4196 static DEVICE_ATTR(lpfc_req_fw_upgrade
, S_IRUGO
| S_IWUSR
,
4197 lpfc_request_firmware_upgrade_show
,
4198 lpfc_request_firmware_upgrade_store
);
4201 * lpfc_fcp_imax_store
4203 * @dev: class device that is converted into a Scsi_host.
4204 * @attr: device attribute, not used.
4205 * @buf: string with the number of fast-path FCP interrupts per second.
4206 * @count: unused variable.
4209 * If val is in a valid range [636,651042], then set the adapter's
4210 * maximum number of fast-path FCP interrupts per second.
4213 * length of the buf on success if val is in range the intended mode
4215 * -EINVAL if val out of range or intended mode is not supported.
4218 lpfc_fcp_imax_store(struct device
*dev
, struct device_attribute
*attr
,
4219 const char *buf
, size_t count
)
4221 struct Scsi_Host
*shost
= class_to_shost(dev
);
4222 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4223 struct lpfc_hba
*phba
= vport
->phba
;
4226 /* fcp_imax is only valid for SLI4 */
4227 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
4230 /* Sanity check on user data */
4231 if (!isdigit(buf
[0]))
4233 if (sscanf(buf
, "%i", &val
) != 1)
4237 * Value range for the HBA is [5000,5000000]
4238 * The value for each EQ depends on how many EQs are configured.
4240 if (val
< LPFC_MIN_IMAX
|| val
> LPFC_MAX_IMAX
)
4243 phba
->cfg_fcp_imax
= (uint32_t)val
;
4244 for (i
= 0; i
< phba
->cfg_fcp_io_channel
; i
+= LPFC_MAX_EQ_DELAY
)
4245 lpfc_modify_fcp_eq_delay(phba
, i
);
4251 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
4254 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
4256 static int lpfc_fcp_imax
= LPFC_DEF_IMAX
;
4257 module_param(lpfc_fcp_imax
, int, S_IRUGO
|S_IWUSR
);
4258 MODULE_PARM_DESC(lpfc_fcp_imax
,
4259 "Set the maximum number of FCP interrupts per second per HBA");
4260 lpfc_param_show(fcp_imax
)
4263 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
4264 * @phba: lpfc_hba pointer.
4265 * @val: link speed value.
4268 * If val is in a valid range [636,651042], then initialize the adapter's
4269 * maximum number of fast-path FCP interrupts per second.
4272 * zero if val saved.
4273 * -EINVAL val out of range
4276 lpfc_fcp_imax_init(struct lpfc_hba
*phba
, int val
)
4278 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4279 phba
->cfg_fcp_imax
= 0;
4283 if (val
>= LPFC_MIN_IMAX
&& val
<= LPFC_MAX_IMAX
) {
4284 phba
->cfg_fcp_imax
= val
;
4288 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4289 "3016 fcp_imax: %d out of range, using default\n", val
);
4290 phba
->cfg_fcp_imax
= LPFC_DEF_IMAX
;
4295 static DEVICE_ATTR(lpfc_fcp_imax
, S_IRUGO
| S_IWUSR
,
4296 lpfc_fcp_imax_show
, lpfc_fcp_imax_store
);
4299 * lpfc_state_show - Display current driver CPU affinity
4300 * @dev: class converted to a Scsi_host structure.
4301 * @attr: device attribute, not used.
4302 * @buf: on return contains text describing the state of the link.
4304 * Returns: size of formatted string.
4307 lpfc_fcp_cpu_map_show(struct device
*dev
, struct device_attribute
*attr
,
4310 struct Scsi_Host
*shost
= class_to_shost(dev
);
4311 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4312 struct lpfc_hba
*phba
= vport
->phba
;
4313 struct lpfc_vector_map_info
*cpup
;
4316 if ((phba
->sli_rev
!= LPFC_SLI_REV4
) ||
4317 (phba
->intr_type
!= MSIX
))
4320 switch (phba
->cfg_fcp_cpu_map
) {
4322 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4323 "fcp_cpu_map: No mapping (%d)\n",
4324 phba
->cfg_fcp_cpu_map
);
4327 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4328 "fcp_cpu_map: HBA centric mapping (%d): "
4330 phba
->cfg_fcp_cpu_map
,
4331 phba
->sli4_hba
.num_online_cpu
);
4334 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4335 "fcp_cpu_map: Driver centric mapping (%d): "
4337 phba
->cfg_fcp_cpu_map
,
4338 phba
->sli4_hba
.num_online_cpu
);
4342 while (phba
->sli4_hba
.curr_disp_cpu
< phba
->sli4_hba
.num_present_cpu
) {
4343 cpup
= &phba
->sli4_hba
.cpu_map
[phba
->sli4_hba
.curr_disp_cpu
];
4345 /* margin should fit in this and the truncated message */
4346 if (cpup
->irq
== LPFC_VECTOR_MAP_EMPTY
)
4347 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4348 "CPU %02d io_chan %02d "
4349 "physid %d coreid %d\n",
4350 phba
->sli4_hba
.curr_disp_cpu
,
4351 cpup
->channel_id
, cpup
->phys_id
,
4354 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4355 "CPU %02d io_chan %02d "
4356 "physid %d coreid %d IRQ %d\n",
4357 phba
->sli4_hba
.curr_disp_cpu
,
4358 cpup
->channel_id
, cpup
->phys_id
,
4359 cpup
->core_id
, cpup
->irq
);
4361 phba
->sli4_hba
.curr_disp_cpu
++;
4363 /* display max number of CPUs keeping some margin */
4364 if (phba
->sli4_hba
.curr_disp_cpu
<
4365 phba
->sli4_hba
.num_present_cpu
&&
4366 (len
>= (PAGE_SIZE
- 64))) {
4367 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "more...\n");
4372 if (phba
->sli4_hba
.curr_disp_cpu
== phba
->sli4_hba
.num_present_cpu
)
4373 phba
->sli4_hba
.curr_disp_cpu
= 0;
4379 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
4380 * @dev: class device that is converted into a Scsi_host.
4381 * @attr: device attribute, not used.
4382 * @buf: one or more lpfc_polling_flags values.
4386 * -EINVAL - Not implemented yet.
4389 lpfc_fcp_cpu_map_store(struct device
*dev
, struct device_attribute
*attr
,
4390 const char *buf
, size_t count
)
4392 int status
= -EINVAL
;
4397 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
4400 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
4401 # 0 - Do not affinitze IRQ vectors
4402 # 1 - Affintize HBA vectors with respect to each HBA
4403 # (start with CPU0 for each HBA)
4404 # 2 - Affintize HBA vectors with respect to the entire driver
4405 # (round robin thru all CPUs across all HBAs)
4407 static int lpfc_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4408 module_param(lpfc_fcp_cpu_map
, int, S_IRUGO
|S_IWUSR
);
4409 MODULE_PARM_DESC(lpfc_fcp_cpu_map
,
4410 "Defines how to map CPUs to IRQ vectors per HBA");
4413 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
4414 * @phba: lpfc_hba pointer.
4415 * @val: link speed value.
4418 * If val is in a valid range [0-2], then affinitze the adapter's
4422 * zero if val saved.
4423 * -EINVAL val out of range
4426 lpfc_fcp_cpu_map_init(struct lpfc_hba
*phba
, int val
)
4428 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4429 phba
->cfg_fcp_cpu_map
= 0;
4433 if (val
>= LPFC_MIN_CPU_MAP
&& val
<= LPFC_MAX_CPU_MAP
) {
4434 phba
->cfg_fcp_cpu_map
= val
;
4438 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4439 "3326 fcp_cpu_map: %d out of range, using default\n",
4441 phba
->cfg_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4446 static DEVICE_ATTR(lpfc_fcp_cpu_map
, S_IRUGO
| S_IWUSR
,
4447 lpfc_fcp_cpu_map_show
, lpfc_fcp_cpu_map_store
);
4450 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
4451 # Value range is [2,3]. Default value is 3.
4453 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
4454 "Select Fibre Channel class of service for FCP sequences");
4457 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
4458 # is [0,1]. Default value is 0.
4460 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
4461 "Use ADISC on rediscovery to authenticate FCP devices");
4464 # lpfc_first_burst_size: First burst size to use on the NPorts
4465 # that support first burst.
4466 # Value range is [0,65536]. Default value is 0.
4468 LPFC_VPORT_ATTR_RW(first_burst_size
, 0, 0, 65536,
4469 "First burst size for Targets that support first burst");
4472 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
4473 # depth. Default value is 0. When the value of this parameter is zero the
4474 # SCSI command completion time is not used for controlling I/O queue depth. When
4475 # the parameter is set to a non-zero value, the I/O queue depth is controlled
4476 # to limit the I/O completion time to the parameter value.
4477 # The value is set in milliseconds.
4479 static int lpfc_max_scsicmpl_time
;
4480 module_param(lpfc_max_scsicmpl_time
, int, S_IRUGO
);
4481 MODULE_PARM_DESC(lpfc_max_scsicmpl_time
,
4482 "Use command completion time to control queue depth");
4483 lpfc_vport_param_show(max_scsicmpl_time
);
4484 lpfc_vport_param_init(max_scsicmpl_time
, 0, 0, 60000);
4486 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
4488 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
4489 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
4491 if (val
== vport
->cfg_max_scsicmpl_time
)
4493 if ((val
< 0) || (val
> 60000))
4495 vport
->cfg_max_scsicmpl_time
= val
;
4497 spin_lock_irq(shost
->host_lock
);
4498 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4499 if (!NLP_CHK_NODE_ACT(ndlp
))
4501 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
4503 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
4505 spin_unlock_irq(shost
->host_lock
);
4508 lpfc_vport_param_store(max_scsicmpl_time
);
4509 static DEVICE_ATTR(lpfc_max_scsicmpl_time
, S_IRUGO
| S_IWUSR
,
4510 lpfc_max_scsicmpl_time_show
,
4511 lpfc_max_scsicmpl_time_store
);
4514 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
4515 # range is [0,1]. Default value is 0.
4517 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
4520 # lpfc_fcp_io_sched: Determine scheduling algrithmn for issuing FCP cmds
4521 # range is [0,1]. Default value is 0.
4522 # For [0], FCP commands are issued to Work Queues ina round robin fashion.
4523 # For [1], FCP commands are issued to a Work Queue associated with the
4525 # It would be set to 1 by the driver if it's able to set up cpu affinity
4526 # for FCP I/Os through Work Queue associated with the current CPU. Otherwise,
4527 # roundrobin scheduling of FCP I/Os through WQs will be used.
4529 LPFC_ATTR_RW(fcp_io_sched
, 0, 0, 1, "Determine scheduling algorithm for "
4530 "issuing commands [0] - Round Robin, [1] - Current CPU");
4533 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
4534 # range is [0,1]. Default value is 0.
4535 # For [0], bus reset issues target reset to ALL devices
4536 # For [1], bus reset issues target reset to non-FCP2 devices
4538 LPFC_ATTR_RW(fcp2_no_tgt_reset
, 0, 0, 1, "Determine bus reset behavior for "
4539 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
4543 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
4544 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
4545 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
4546 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
4547 # cr_delay is set to 0.
4549 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
4550 "interrupt response is generated");
4552 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
4553 "interrupt response is generated");
4556 # lpfc_multi_ring_support: Determines how many rings to spread available
4557 # cmd/rsp IOCB entries across.
4558 # Value range is [1,2]. Default value is 1.
4560 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
4561 "SLI rings to spread IOCB entries across");
4564 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
4565 # identifies what rctl value to configure the additional ring for.
4566 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
4568 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
4569 255, "Identifies RCTL for additional ring configuration");
4572 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
4573 # identifies what type value to configure the additional ring for.
4574 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
4576 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
4577 255, "Identifies TYPE for additional ring configuration");
4580 # lpfc_fdmi_on: controls FDMI support.
4582 # bit 0 = FDMI support no FDMI support
4583 # LPFC_FDMI_SUPPORT just turns basic support on/off
4584 # bit 1 = Register delay no register delay (60 seconds)
4585 # LPFC_FDMI_REG_DELAY 60 sec registration delay after FDMI login
4586 # bit 2 = All attributes Use a attribute subset
4587 # LPFC_FDMI_ALL_ATTRIB applies to both port and HBA attributes
4588 # Port attrutes subset: 1 thru 6 OR all: 1 thru 0xd 0x101 0x102 0x103
4589 # HBA attributes subset: 1 thru 0xb OR all: 1 thru 0xc
4590 # Value range [0,7]. Default value is 0.
4592 LPFC_VPORT_ATTR_RW(fdmi_on
, 0, 0, 7, "Enable FDMI support");
4595 # Specifies the maximum number of ELS cmds we can have outstanding (for
4596 # discovery). Value range is [1,64]. Default value = 32.
4598 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
4599 "during discovery");
4602 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
4603 # will be scanned by the SCSI midlayer when sequential scanning is
4604 # used; and is also the highest LUN ID allowed when the SCSI midlayer
4605 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
4606 # LUN ID limit, but the SCSI midlayer requires this field for the uses
4607 # above. The lpfc driver limits the default value to 255 for two reasons.
4608 # As it bounds the sequential scan loop, scanning for thousands of luns
4609 # on a target can take minutes of wall clock time. Additionally,
4610 # there are FC targets, such as JBODs, that only recognize 8-bits of
4611 # LUN ID. When they receive a value greater than 8 bits, they chop off
4612 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
4613 # and so on all as LUN ID 0. This causes the linux kernel, which sees
4614 # valid responses at each of the LUN IDs, to believe there are multiple
4615 # devices present, when in fact, there is only 1.
4616 # A customer that is aware of their target behaviors, and the results as
4617 # indicated above, is welcome to increase the lpfc_max_luns value.
4618 # As mentioned, this value is not used by the lpfc driver, only the
4620 # Value range is [0,65535]. Default value is 255.
4621 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
4623 LPFC_VPORT_ULL_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN ID");
4626 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
4627 # Value range is [1,255], default value is 10.
4629 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
4630 "Milliseconds driver will wait between polling FCP ring");
4633 # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands
4634 # to complete in seconds. Value range is [5,180], default value is 60.
4636 LPFC_ATTR_RW(task_mgmt_tmo
, 60, 5, 180,
4637 "Maximum time to wait for task management commands to complete");
4639 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
4640 # support this feature
4643 # 2 = MSI-X enabled (default)
4644 # Value range is [0,2]. Default value is 2.
4646 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
4647 "MSI-X (2), if possible");
4650 # lpfc_fcp_io_channel: Set the number of FCP EQ/CQ/WQ IO channels
4652 # Value range is [1,7]. Default value is 4.
4654 LPFC_ATTR_R(fcp_io_channel
, LPFC_FCP_IO_CHAN_DEF
, LPFC_FCP_IO_CHAN_MIN
,
4655 LPFC_FCP_IO_CHAN_MAX
,
4656 "Set the number of FCP I/O channels");
4659 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
4660 # 0 = HBA resets disabled
4661 # 1 = HBA resets enabled (default)
4662 # Value range is [0,1]. Default value is 1.
4664 LPFC_ATTR_R(enable_hba_reset
, 1, 0, 1, "Enable HBA resets from the driver.");
4667 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
4668 # 0 = HBA Heartbeat disabled
4669 # 1 = HBA Heartbeat enabled (default)
4670 # Value range is [0,1]. Default value is 1.
4672 LPFC_ATTR_R(enable_hba_heartbeat
, 0, 0, 1, "Enable HBA Heartbeat.");
4675 # lpfc_EnableXLane: Enable Express Lane Feature
4676 # 0x0 Express Lane Feature disabled
4677 # 0x1 Express Lane Feature enabled
4678 # Value range is [0,1]. Default value is 0.
4680 LPFC_ATTR_R(EnableXLane
, 0, 0, 1, "Enable Express Lane Feature.");
4683 # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature
4684 # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits)
4685 # Value range is [0x0,0x7f]. Default value is 0
4687 LPFC_ATTR_RW(XLanePriority
, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
4690 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
4691 # 0 = BlockGuard disabled (default)
4692 # 1 = BlockGuard enabled
4693 # Value range is [0,1]. Default value is 0.
4695 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
4698 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
4699 # 0 = disabled (default)
4701 # Value range is [0,1]. Default value is 0.
4703 # This feature in under investigation and may be supported in the future.
4705 unsigned int lpfc_fcp_look_ahead
= LPFC_LOOK_AHEAD_OFF
;
4709 # - Bit mask of host protection capabilities used to register with the
4711 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
4712 # - Allows you to ultimately specify which profiles to use
4713 # - Default will result in registering capabilities for all profiles.
4714 # - SHOST_DIF_TYPE1_PROTECTION 1
4715 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
4716 # - SHOST_DIX_TYPE0_PROTECTION 8
4717 # HBA supports DIX Type 0: Host to HBA protection only
4718 # - SHOST_DIX_TYPE1_PROTECTION 16
4719 # HBA supports DIX Type 1: Host to HBA Type 1 protection
4722 unsigned int lpfc_prot_mask
= SHOST_DIF_TYPE1_PROTECTION
|
4723 SHOST_DIX_TYPE0_PROTECTION
|
4724 SHOST_DIX_TYPE1_PROTECTION
;
4726 module_param(lpfc_prot_mask
, uint
, S_IRUGO
);
4727 MODULE_PARM_DESC(lpfc_prot_mask
, "host protection mask");
4730 # lpfc_prot_guard: i
4731 # - Bit mask of protection guard types to register with the SCSI mid-layer
4732 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
4733 # - Allows you to ultimately specify which profiles to use
4734 # - Default will result in registering capabilities for all guard types
4737 unsigned char lpfc_prot_guard
= SHOST_DIX_GUARD_IP
;
4738 module_param(lpfc_prot_guard
, byte
, S_IRUGO
);
4739 MODULE_PARM_DESC(lpfc_prot_guard
, "host protection guard type");
4742 * Delay initial NPort discovery when Clean Address bit is cleared in
4743 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
4744 * This parameter can have value 0 or 1.
4745 * When this parameter is set to 0, no delay is added to the initial
4747 * When this parameter is set to non-zero value, initial Nport discovery is
4748 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
4749 * accept and FCID/Fabric name/Fabric portname is changed.
4750 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
4751 * when Clean Address bit is cleared in FLOGI/FDISC
4752 * accept and FCID/Fabric name/Fabric portname is changed.
4753 * Default value is 0.
4755 int lpfc_delay_discovery
;
4756 module_param(lpfc_delay_discovery
, int, S_IRUGO
);
4757 MODULE_PARM_DESC(lpfc_delay_discovery
,
4758 "Delay NPort discovery when Clean Address bit is cleared. "
4759 "Allowed values: 0,1.");
4762 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
4763 * This value can be set to values between 64 and 4096. The default value is
4764 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
4765 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
4766 * Because of the additional overhead involved in setting up T10-DIF,
4767 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
4768 * and will be limited to 512 if BlockGuard is enabled under SLI3.
4770 LPFC_ATTR_R(sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
, LPFC_DEFAULT_SG_SEG_CNT
,
4771 LPFC_MAX_SG_SEG_CNT
, "Max Scatter Gather Segment Count");
4774 * This parameter will be depricated, the driver cannot limit the
4775 * protection data s/g list.
4777 LPFC_ATTR_R(prot_sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
,
4778 LPFC_DEFAULT_SG_SEG_CNT
, LPFC_MAX_SG_SEG_CNT
,
4779 "Max Protection Scatter Gather Segment Count");
4781 struct device_attribute
*lpfc_hba_attrs
[] = {
4783 &dev_attr_bg_guard_err
,
4784 &dev_attr_bg_apptag_err
,
4785 &dev_attr_bg_reftag_err
,
4787 &dev_attr_serialnum
,
4788 &dev_attr_modeldesc
,
4789 &dev_attr_modelname
,
4790 &dev_attr_programtype
,
4794 &dev_attr_option_rom_version
,
4795 &dev_attr_link_state
,
4796 &dev_attr_num_discovered_ports
,
4797 &dev_attr_menlo_mgmt_mode
,
4798 &dev_attr_lpfc_drvr_version
,
4799 &dev_attr_lpfc_enable_fip
,
4800 &dev_attr_lpfc_temp_sensor
,
4801 &dev_attr_lpfc_log_verbose
,
4802 &dev_attr_lpfc_lun_queue_depth
,
4803 &dev_attr_lpfc_tgt_queue_depth
,
4804 &dev_attr_lpfc_hba_queue_depth
,
4805 &dev_attr_lpfc_peer_port_login
,
4806 &dev_attr_lpfc_nodev_tmo
,
4807 &dev_attr_lpfc_devloss_tmo
,
4808 &dev_attr_lpfc_fcp_class
,
4809 &dev_attr_lpfc_use_adisc
,
4810 &dev_attr_lpfc_first_burst_size
,
4811 &dev_attr_lpfc_ack0
,
4812 &dev_attr_lpfc_topology
,
4813 &dev_attr_lpfc_scan_down
,
4814 &dev_attr_lpfc_link_speed
,
4815 &dev_attr_lpfc_fcp_io_sched
,
4816 &dev_attr_lpfc_fcp2_no_tgt_reset
,
4817 &dev_attr_lpfc_cr_delay
,
4818 &dev_attr_lpfc_cr_count
,
4819 &dev_attr_lpfc_multi_ring_support
,
4820 &dev_attr_lpfc_multi_ring_rctl
,
4821 &dev_attr_lpfc_multi_ring_type
,
4822 &dev_attr_lpfc_fdmi_on
,
4823 &dev_attr_lpfc_max_luns
,
4824 &dev_attr_lpfc_enable_npiv
,
4825 &dev_attr_lpfc_fcf_failover_policy
,
4826 &dev_attr_lpfc_enable_rrq
,
4827 &dev_attr_nport_evt_cnt
,
4828 &dev_attr_board_mode
,
4835 &dev_attr_npiv_info
,
4836 &dev_attr_issue_reset
,
4837 &dev_attr_lpfc_poll
,
4838 &dev_attr_lpfc_poll_tmo
,
4839 &dev_attr_lpfc_task_mgmt_tmo
,
4840 &dev_attr_lpfc_use_msi
,
4841 &dev_attr_lpfc_fcp_imax
,
4842 &dev_attr_lpfc_fcp_cpu_map
,
4843 &dev_attr_lpfc_fcp_io_channel
,
4844 &dev_attr_lpfc_enable_bg
,
4845 &dev_attr_lpfc_soft_wwnn
,
4846 &dev_attr_lpfc_soft_wwpn
,
4847 &dev_attr_lpfc_soft_wwn_enable
,
4848 &dev_attr_lpfc_enable_hba_reset
,
4849 &dev_attr_lpfc_enable_hba_heartbeat
,
4850 &dev_attr_lpfc_EnableXLane
,
4851 &dev_attr_lpfc_XLanePriority
,
4852 &dev_attr_lpfc_xlane_lun
,
4853 &dev_attr_lpfc_xlane_tgt
,
4854 &dev_attr_lpfc_xlane_vpt
,
4855 &dev_attr_lpfc_xlane_lun_state
,
4856 &dev_attr_lpfc_xlane_lun_status
,
4857 &dev_attr_lpfc_sg_seg_cnt
,
4858 &dev_attr_lpfc_max_scsicmpl_time
,
4859 &dev_attr_lpfc_stat_data_ctrl
,
4860 &dev_attr_lpfc_prot_sg_seg_cnt
,
4861 &dev_attr_lpfc_aer_support
,
4862 &dev_attr_lpfc_aer_state_cleanup
,
4863 &dev_attr_lpfc_sriov_nr_virtfn
,
4864 &dev_attr_lpfc_req_fw_upgrade
,
4865 &dev_attr_lpfc_suppress_link_up
,
4866 &dev_attr_lpfc_iocb_cnt
,
4869 &dev_attr_txcmplq_hw
,
4870 &dev_attr_lpfc_fips_level
,
4871 &dev_attr_lpfc_fips_rev
,
4873 &dev_attr_lpfc_sriov_hw_max_virtfn
,
4875 &dev_attr_lpfc_xlane_supported
,
4879 struct device_attribute
*lpfc_vport_attrs
[] = {
4881 &dev_attr_link_state
,
4882 &dev_attr_num_discovered_ports
,
4883 &dev_attr_lpfc_drvr_version
,
4884 &dev_attr_lpfc_log_verbose
,
4885 &dev_attr_lpfc_lun_queue_depth
,
4886 &dev_attr_lpfc_tgt_queue_depth
,
4887 &dev_attr_lpfc_nodev_tmo
,
4888 &dev_attr_lpfc_devloss_tmo
,
4889 &dev_attr_lpfc_hba_queue_depth
,
4890 &dev_attr_lpfc_peer_port_login
,
4891 &dev_attr_lpfc_restrict_login
,
4892 &dev_attr_lpfc_fcp_class
,
4893 &dev_attr_lpfc_use_adisc
,
4894 &dev_attr_lpfc_first_burst_size
,
4895 &dev_attr_lpfc_fdmi_on
,
4896 &dev_attr_lpfc_max_luns
,
4897 &dev_attr_nport_evt_cnt
,
4898 &dev_attr_npiv_info
,
4899 &dev_attr_lpfc_enable_da_id
,
4900 &dev_attr_lpfc_max_scsicmpl_time
,
4901 &dev_attr_lpfc_stat_data_ctrl
,
4902 &dev_attr_lpfc_static_vport
,
4903 &dev_attr_lpfc_fips_level
,
4904 &dev_attr_lpfc_fips_rev
,
4909 * sysfs_ctlreg_write - Write method for writing to ctlreg
4910 * @filp: open sysfs file
4911 * @kobj: kernel kobject that contains the kernel class device.
4912 * @bin_attr: kernel attributes passed to us.
4913 * @buf: contains the data to be written to the adapter IOREG space.
4914 * @off: offset into buffer to beginning of data.
4915 * @count: bytes to transfer.
4918 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
4919 * Uses the adapter io control registers to send buf contents to the adapter.
4922 * -ERANGE off and count combo out of range
4923 * -EINVAL off, count or buff address invalid
4924 * -EPERM adapter is offline
4925 * value of count, buf contents written
4928 sysfs_ctlreg_write(struct file
*filp
, struct kobject
*kobj
,
4929 struct bin_attribute
*bin_attr
,
4930 char *buf
, loff_t off
, size_t count
)
4933 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
4934 struct Scsi_Host
*shost
= class_to_shost(dev
);
4935 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4936 struct lpfc_hba
*phba
= vport
->phba
;
4938 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
4941 if ((off
+ count
) > FF_REG_AREA_SIZE
)
4944 if (count
<= LPFC_REG_WRITE_KEY_SIZE
)
4947 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
4950 /* This is to protect HBA registers from accidental writes. */
4951 if (memcmp(buf
, LPFC_REG_WRITE_KEY
, LPFC_REG_WRITE_KEY_SIZE
))
4954 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
))
4957 spin_lock_irq(&phba
->hbalock
);
4958 for (buf_off
= 0; buf_off
< count
- LPFC_REG_WRITE_KEY_SIZE
;
4959 buf_off
+= sizeof(uint32_t))
4960 writel(*((uint32_t *)(buf
+ buf_off
+ LPFC_REG_WRITE_KEY_SIZE
)),
4961 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
4963 spin_unlock_irq(&phba
->hbalock
);
4969 * sysfs_ctlreg_read - Read method for reading from ctlreg
4970 * @filp: open sysfs file
4971 * @kobj: kernel kobject that contains the kernel class device.
4972 * @bin_attr: kernel attributes passed to us.
4973 * @buf: if successful contains the data from the adapter IOREG space.
4974 * @off: offset into buffer to beginning of data.
4975 * @count: bytes to transfer.
4978 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
4979 * Uses the adapter io control registers to read data into buf.
4982 * -ERANGE off and count combo out of range
4983 * -EINVAL off, count or buff address invalid
4984 * value of count, buf contents read
4987 sysfs_ctlreg_read(struct file
*filp
, struct kobject
*kobj
,
4988 struct bin_attribute
*bin_attr
,
4989 char *buf
, loff_t off
, size_t count
)
4993 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
4994 struct Scsi_Host
*shost
= class_to_shost(dev
);
4995 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4996 struct lpfc_hba
*phba
= vport
->phba
;
4998 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5001 if (off
> FF_REG_AREA_SIZE
)
5004 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5005 count
= FF_REG_AREA_SIZE
- off
;
5007 if (count
== 0) return 0;
5009 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5012 spin_lock_irq(&phba
->hbalock
);
5014 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
5015 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
5016 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5019 spin_unlock_irq(&phba
->hbalock
);
5024 static struct bin_attribute sysfs_ctlreg_attr
= {
5027 .mode
= S_IRUSR
| S_IWUSR
,
5030 .read
= sysfs_ctlreg_read
,
5031 .write
= sysfs_ctlreg_write
,
5035 * sysfs_mbox_write - Write method for writing information via mbox
5036 * @filp: open sysfs file
5037 * @kobj: kernel kobject that contains the kernel class device.
5038 * @bin_attr: kernel attributes passed to us.
5039 * @buf: contains the data to be written to sysfs mbox.
5040 * @off: offset into buffer to beginning of data.
5041 * @count: bytes to transfer.
5044 * Deprecated function. All mailbox access from user space is performed via the
5048 * -EPERM operation not permitted
5051 sysfs_mbox_write(struct file
*filp
, struct kobject
*kobj
,
5052 struct bin_attribute
*bin_attr
,
5053 char *buf
, loff_t off
, size_t count
)
5059 * sysfs_mbox_read - Read method for reading information via mbox
5060 * @filp: open sysfs file
5061 * @kobj: kernel kobject that contains the kernel class device.
5062 * @bin_attr: kernel attributes passed to us.
5063 * @buf: contains the data to be read from sysfs mbox.
5064 * @off: offset into buffer to beginning of data.
5065 * @count: bytes to transfer.
5068 * Deprecated function. All mailbox access from user space is performed via the
5072 * -EPERM operation not permitted
5075 sysfs_mbox_read(struct file
*filp
, struct kobject
*kobj
,
5076 struct bin_attribute
*bin_attr
,
5077 char *buf
, loff_t off
, size_t count
)
5082 static struct bin_attribute sysfs_mbox_attr
= {
5085 .mode
= S_IRUSR
| S_IWUSR
,
5087 .size
= MAILBOX_SYSFS_MAX
,
5088 .read
= sysfs_mbox_read
,
5089 .write
= sysfs_mbox_write
,
5093 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
5094 * @vport: address of lpfc vport structure.
5098 * error return code from sysfs_create_bin_file()
5101 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
5103 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5106 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5107 &sysfs_drvr_stat_data_attr
);
5109 /* Virtual ports do not need ctrl_reg and mbox */
5110 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
5113 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5114 &sysfs_ctlreg_attr
);
5116 goto out_remove_stat_attr
;
5118 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5121 goto out_remove_ctlreg_attr
;
5124 out_remove_ctlreg_attr
:
5125 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5126 out_remove_stat_attr
:
5127 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5128 &sysfs_drvr_stat_data_attr
);
5134 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
5135 * @vport: address of lpfc vport structure.
5138 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
5140 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5141 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5142 &sysfs_drvr_stat_data_attr
);
5143 /* Virtual ports do not need ctrl_reg and mbox */
5144 if (vport
->port_type
== LPFC_NPIV_PORT
)
5146 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
5147 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5152 * Dynamic FC Host Attributes Support
5156 * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host
5157 * @shost: kernel scsi host pointer.
5160 lpfc_get_host_symbolic_name(struct Scsi_Host
*shost
)
5162 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5164 lpfc_vport_symbolic_node_name(vport
, fc_host_symbolic_name(shost
),
5165 sizeof fc_host_symbolic_name(shost
));
5169 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
5170 * @shost: kernel scsi host pointer.
5173 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
5175 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5177 /* note: fc_myDID already in cpu endianness */
5178 fc_host_port_id(shost
) = vport
->fc_myDID
;
5182 * lpfc_get_host_port_type - Set the value of the scsi host port type
5183 * @shost: kernel scsi host pointer.
5186 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
5188 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5189 struct lpfc_hba
*phba
= vport
->phba
;
5191 spin_lock_irq(shost
->host_lock
);
5193 if (vport
->port_type
== LPFC_NPIV_PORT
) {
5194 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
5195 } else if (lpfc_is_link_up(phba
)) {
5196 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5197 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
5198 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
5200 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
5202 if (vport
->fc_flag
& FC_FABRIC
)
5203 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
5205 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
5208 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
5210 spin_unlock_irq(shost
->host_lock
);
5214 * lpfc_get_host_port_state - Set the value of the scsi host port state
5215 * @shost: kernel scsi host pointer.
5218 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
5220 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5221 struct lpfc_hba
*phba
= vport
->phba
;
5223 spin_lock_irq(shost
->host_lock
);
5225 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5226 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
5228 switch (phba
->link_state
) {
5229 case LPFC_LINK_UNKNOWN
:
5230 case LPFC_LINK_DOWN
:
5231 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
5235 case LPFC_HBA_READY
:
5236 /* Links up, reports port state accordingly */
5237 if (vport
->port_state
< LPFC_VPORT_READY
)
5238 fc_host_port_state(shost
) =
5239 FC_PORTSTATE_BYPASSED
;
5241 fc_host_port_state(shost
) =
5242 FC_PORTSTATE_ONLINE
;
5244 case LPFC_HBA_ERROR
:
5245 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
5248 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
5253 spin_unlock_irq(shost
->host_lock
);
5257 * lpfc_get_host_speed - Set the value of the scsi host speed
5258 * @shost: kernel scsi host pointer.
5261 lpfc_get_host_speed(struct Scsi_Host
*shost
)
5263 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5264 struct lpfc_hba
*phba
= vport
->phba
;
5266 spin_lock_irq(shost
->host_lock
);
5268 if (lpfc_is_link_up(phba
)) {
5269 switch(phba
->fc_linkspeed
) {
5270 case LPFC_LINK_SPEED_1GHZ
:
5271 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
5273 case LPFC_LINK_SPEED_2GHZ
:
5274 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
5276 case LPFC_LINK_SPEED_4GHZ
:
5277 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
5279 case LPFC_LINK_SPEED_8GHZ
:
5280 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
5282 case LPFC_LINK_SPEED_10GHZ
:
5283 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
5285 case LPFC_LINK_SPEED_16GHZ
:
5286 fc_host_speed(shost
) = FC_PORTSPEED_16GBIT
;
5288 case LPFC_LINK_SPEED_32GHZ
:
5289 fc_host_speed(shost
) = FC_PORTSPEED_32GBIT
;
5292 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5296 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5298 spin_unlock_irq(shost
->host_lock
);
5302 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
5303 * @shost: kernel scsi host pointer.
5306 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
5308 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5309 struct lpfc_hba
*phba
= vport
->phba
;
5312 spin_lock_irq(shost
->host_lock
);
5314 if ((vport
->port_state
> LPFC_FLOGI
) &&
5315 ((vport
->fc_flag
& FC_FABRIC
) ||
5316 ((phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) &&
5317 (vport
->fc_flag
& FC_PUBLIC_LOOP
))))
5318 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
5320 /* fabric is local port if there is no F/FL_Port */
5323 spin_unlock_irq(shost
->host_lock
);
5325 fc_host_fabric_name(shost
) = node_name
;
5329 * lpfc_get_stats - Return statistical information about the adapter
5330 * @shost: kernel scsi host pointer.
5333 * NULL on error for link down, no mbox pool, sli2 active,
5334 * management not allowed, memory allocation error, or mbox error.
5338 * address of the adapter host statistics
5340 static struct fc_host_statistics
*
5341 lpfc_get_stats(struct Scsi_Host
*shost
)
5343 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5344 struct lpfc_hba
*phba
= vport
->phba
;
5345 struct lpfc_sli
*psli
= &phba
->sli
;
5346 struct fc_host_statistics
*hs
= &phba
->link_stats
;
5347 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
5348 LPFC_MBOXQ_t
*pmboxq
;
5350 unsigned long seconds
;
5354 * prevent udev from issuing mailbox commands until the port is
5357 if (phba
->link_state
< LPFC_LINK_DOWN
||
5358 !phba
->mbox_mem_pool
||
5359 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
5362 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5365 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5368 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5370 pmb
= &pmboxq
->u
.mb
;
5371 pmb
->mbxCommand
= MBX_READ_STATUS
;
5372 pmb
->mbxOwner
= OWN_HOST
;
5373 pmboxq
->context1
= NULL
;
5374 pmboxq
->vport
= vport
;
5376 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5377 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5379 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5381 if (rc
!= MBX_SUCCESS
) {
5382 if (rc
!= MBX_TIMEOUT
)
5383 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5387 memset(hs
, 0, sizeof (struct fc_host_statistics
));
5389 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
5391 * The MBX_READ_STATUS returns tx_k_bytes which has to
5392 * converted to words
5394 hs
->tx_words
= (uint64_t)
5395 ((uint64_t)pmb
->un
.varRdStatus
.xmitByteCnt
5397 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
5398 hs
->rx_words
= (uint64_t)
5399 ((uint64_t)pmb
->un
.varRdStatus
.rcvByteCnt
5402 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5403 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5404 pmb
->mbxOwner
= OWN_HOST
;
5405 pmboxq
->context1
= NULL
;
5406 pmboxq
->vport
= vport
;
5408 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5409 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5411 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5413 if (rc
!= MBX_SUCCESS
) {
5414 if (rc
!= MBX_TIMEOUT
)
5415 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5419 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5420 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5421 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5422 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5423 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5424 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5425 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5427 hs
->link_failure_count
-= lso
->link_failure_count
;
5428 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
5429 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
5430 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
5431 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
5432 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
5433 hs
->error_frames
-= lso
->error_frames
;
5435 if (phba
->hba_flag
& HBA_FCOE_MODE
) {
5437 hs
->nos_count
= (phba
->link_events
>> 1);
5438 hs
->nos_count
-= lso
->link_events
;
5439 } else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5440 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
5441 hs
->lip_count
-= lso
->link_events
;
5445 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
5446 hs
->nos_count
-= lso
->link_events
;
5449 hs
->dumped_frames
= -1;
5451 seconds
= get_seconds();
5452 if (seconds
< psli
->stats_start
)
5453 hs
->seconds_since_last_reset
= seconds
+
5454 ((unsigned long)-1 - psli
->stats_start
);
5456 hs
->seconds_since_last_reset
= seconds
- psli
->stats_start
;
5458 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5464 * lpfc_reset_stats - Copy the adapter link stats information
5465 * @shost: kernel scsi host pointer.
5468 lpfc_reset_stats(struct Scsi_Host
*shost
)
5470 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5471 struct lpfc_hba
*phba
= vport
->phba
;
5472 struct lpfc_sli
*psli
= &phba
->sli
;
5473 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
5474 LPFC_MBOXQ_t
*pmboxq
;
5478 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5481 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5484 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5486 pmb
= &pmboxq
->u
.mb
;
5487 pmb
->mbxCommand
= MBX_READ_STATUS
;
5488 pmb
->mbxOwner
= OWN_HOST
;
5489 pmb
->un
.varWords
[0] = 0x1; /* reset request */
5490 pmboxq
->context1
= NULL
;
5491 pmboxq
->vport
= vport
;
5493 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5494 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5495 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5497 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5499 if (rc
!= MBX_SUCCESS
) {
5500 if (rc
!= MBX_TIMEOUT
)
5501 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5505 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5506 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5507 pmb
->mbxOwner
= OWN_HOST
;
5508 pmboxq
->context1
= NULL
;
5509 pmboxq
->vport
= vport
;
5511 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5512 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5513 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5515 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5517 if (rc
!= MBX_SUCCESS
) {
5518 if (rc
!= MBX_TIMEOUT
)
5519 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
5523 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5524 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5525 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5526 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5527 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5528 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5529 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5530 if (phba
->hba_flag
& HBA_FCOE_MODE
)
5531 lso
->link_events
= (phba
->link_events
>> 1);
5533 lso
->link_events
= (phba
->fc_eventTag
>> 1);
5535 psli
->stats_start
= get_seconds();
5537 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5543 * The LPFC driver treats linkdown handling as target loss events so there
5544 * are no sysfs handlers for link_down_tmo.
5548 * lpfc_get_node_by_target - Return the nodelist for a target
5549 * @starget: kernel scsi target pointer.
5552 * address of the node list if found
5553 * NULL target not found
5555 static struct lpfc_nodelist
*
5556 lpfc_get_node_by_target(struct scsi_target
*starget
)
5558 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
5559 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5560 struct lpfc_nodelist
*ndlp
;
5562 spin_lock_irq(shost
->host_lock
);
5563 /* Search for this, mapped, target ID */
5564 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
5565 if (NLP_CHK_NODE_ACT(ndlp
) &&
5566 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
5567 starget
->id
== ndlp
->nlp_sid
) {
5568 spin_unlock_irq(shost
->host_lock
);
5572 spin_unlock_irq(shost
->host_lock
);
5577 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
5578 * @starget: kernel scsi target pointer.
5581 lpfc_get_starget_port_id(struct scsi_target
*starget
)
5583 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5585 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
5589 * lpfc_get_starget_node_name - Set the target node name
5590 * @starget: kernel scsi target pointer.
5592 * Description: Set the target node name to the ndlp node name wwn or zero.
5595 lpfc_get_starget_node_name(struct scsi_target
*starget
)
5597 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5599 fc_starget_node_name(starget
) =
5600 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
5604 * lpfc_get_starget_port_name - Set the target port name
5605 * @starget: kernel scsi target pointer.
5607 * Description: set the target port name to the ndlp port name wwn or zero.
5610 lpfc_get_starget_port_name(struct scsi_target
*starget
)
5612 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5614 fc_starget_port_name(starget
) =
5615 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
5619 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
5620 * @rport: fc rport address.
5621 * @timeout: new value for dev loss tmo.
5624 * If timeout is non zero set the dev_loss_tmo to timeout, else set
5625 * dev_loss_tmo to one.
5628 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
5631 rport
->dev_loss_tmo
= timeout
;
5633 rport
->dev_loss_tmo
= 1;
5637 * lpfc_rport_show_function - Return rport target information
5640 * Macro that uses field to generate a function with the name lpfc_show_rport_
5642 * lpfc_show_rport_##field: returns the bytes formatted in buf
5643 * @cdev: class converted to an fc_rport.
5644 * @buf: on return contains the target_field or zero.
5646 * Returns: size of formatted string.
5648 #define lpfc_rport_show_function(field, format_string, sz, cast) \
5650 lpfc_show_rport_##field (struct device *dev, \
5651 struct device_attribute *attr, \
5654 struct fc_rport *rport = transport_class_to_rport(dev); \
5655 struct lpfc_rport_data *rdata = rport->hostdata; \
5656 return snprintf(buf, sz, format_string, \
5657 (rdata->target) ? cast rdata->target->field : 0); \
5660 #define lpfc_rport_rd_attr(field, format_string, sz) \
5661 lpfc_rport_show_function(field, format_string, sz, ) \
5662 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
5665 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
5666 * @fc_vport: The fc_vport who's symbolic name has been changed.
5669 * This function is called by the transport after the @fc_vport's symbolic name
5670 * has been changed. This function re-registers the symbolic name with the
5671 * switch to propagate the change into the fabric if the vport is active.
5674 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
5676 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
5678 if (vport
->port_state
== LPFC_VPORT_READY
)
5679 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
5683 * lpfc_hba_log_verbose_init - Set hba's log verbose level
5684 * @phba: Pointer to lpfc_hba struct.
5686 * This function is called by the lpfc_get_cfgparam() routine to set the
5687 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
5688 * log message according to the module's lpfc_log_verbose parameter setting
5689 * before hba port or vport created.
5692 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
5694 phba
->cfg_log_verbose
= verbose
;
5697 struct fc_function_template lpfc_transport_functions
= {
5698 /* fixed attributes the driver supports */
5699 .show_host_node_name
= 1,
5700 .show_host_port_name
= 1,
5701 .show_host_supported_classes
= 1,
5702 .show_host_supported_fc4s
= 1,
5703 .show_host_supported_speeds
= 1,
5704 .show_host_maxframe_size
= 1,
5706 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
5707 .show_host_symbolic_name
= 1,
5709 /* dynamic attributes the driver supports */
5710 .get_host_port_id
= lpfc_get_host_port_id
,
5711 .show_host_port_id
= 1,
5713 .get_host_port_type
= lpfc_get_host_port_type
,
5714 .show_host_port_type
= 1,
5716 .get_host_port_state
= lpfc_get_host_port_state
,
5717 .show_host_port_state
= 1,
5719 /* active_fc4s is shown but doesn't change (thus no get function) */
5720 .show_host_active_fc4s
= 1,
5722 .get_host_speed
= lpfc_get_host_speed
,
5723 .show_host_speed
= 1,
5725 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
5726 .show_host_fabric_name
= 1,
5729 * The LPFC driver treats linkdown handling as target loss events
5730 * so there are no sysfs handlers for link_down_tmo.
5733 .get_fc_host_stats
= lpfc_get_stats
,
5734 .reset_fc_host_stats
= lpfc_reset_stats
,
5736 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
5737 .show_rport_maxframe_size
= 1,
5738 .show_rport_supported_classes
= 1,
5740 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
5741 .show_rport_dev_loss_tmo
= 1,
5743 .get_starget_port_id
= lpfc_get_starget_port_id
,
5744 .show_starget_port_id
= 1,
5746 .get_starget_node_name
= lpfc_get_starget_node_name
,
5747 .show_starget_node_name
= 1,
5749 .get_starget_port_name
= lpfc_get_starget_port_name
,
5750 .show_starget_port_name
= 1,
5752 .issue_fc_host_lip
= lpfc_issue_lip
,
5753 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
5754 .terminate_rport_io
= lpfc_terminate_rport_io
,
5756 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
5758 .vport_disable
= lpfc_vport_disable
,
5760 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
5762 .bsg_request
= lpfc_bsg_request
,
5763 .bsg_timeout
= lpfc_bsg_timeout
,
5766 struct fc_function_template lpfc_vport_transport_functions
= {
5767 /* fixed attributes the driver supports */
5768 .show_host_node_name
= 1,
5769 .show_host_port_name
= 1,
5770 .show_host_supported_classes
= 1,
5771 .show_host_supported_fc4s
= 1,
5772 .show_host_supported_speeds
= 1,
5773 .show_host_maxframe_size
= 1,
5775 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
5776 .show_host_symbolic_name
= 1,
5778 /* dynamic attributes the driver supports */
5779 .get_host_port_id
= lpfc_get_host_port_id
,
5780 .show_host_port_id
= 1,
5782 .get_host_port_type
= lpfc_get_host_port_type
,
5783 .show_host_port_type
= 1,
5785 .get_host_port_state
= lpfc_get_host_port_state
,
5786 .show_host_port_state
= 1,
5788 /* active_fc4s is shown but doesn't change (thus no get function) */
5789 .show_host_active_fc4s
= 1,
5791 .get_host_speed
= lpfc_get_host_speed
,
5792 .show_host_speed
= 1,
5794 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
5795 .show_host_fabric_name
= 1,
5798 * The LPFC driver treats linkdown handling as target loss events
5799 * so there are no sysfs handlers for link_down_tmo.
5802 .get_fc_host_stats
= lpfc_get_stats
,
5803 .reset_fc_host_stats
= lpfc_reset_stats
,
5805 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
5806 .show_rport_maxframe_size
= 1,
5807 .show_rport_supported_classes
= 1,
5809 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
5810 .show_rport_dev_loss_tmo
= 1,
5812 .get_starget_port_id
= lpfc_get_starget_port_id
,
5813 .show_starget_port_id
= 1,
5815 .get_starget_node_name
= lpfc_get_starget_node_name
,
5816 .show_starget_node_name
= 1,
5818 .get_starget_port_name
= lpfc_get_starget_port_name
,
5819 .show_starget_port_name
= 1,
5821 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
5822 .terminate_rport_io
= lpfc_terminate_rport_io
,
5824 .vport_disable
= lpfc_vport_disable
,
5826 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
5830 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
5831 * @phba: lpfc_hba pointer.
5834 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
5836 lpfc_fcp_io_sched_init(phba
, lpfc_fcp_io_sched
);
5837 lpfc_fcp2_no_tgt_reset_init(phba
, lpfc_fcp2_no_tgt_reset
);
5838 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
5839 lpfc_cr_count_init(phba
, lpfc_cr_count
);
5840 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
5841 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
5842 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
5843 lpfc_ack0_init(phba
, lpfc_ack0
);
5844 lpfc_topology_init(phba
, lpfc_topology
);
5845 lpfc_link_speed_init(phba
, lpfc_link_speed
);
5846 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
5847 lpfc_task_mgmt_tmo_init(phba
, lpfc_task_mgmt_tmo
);
5848 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
5849 lpfc_fcf_failover_policy_init(phba
, lpfc_fcf_failover_policy
);
5850 lpfc_enable_rrq_init(phba
, lpfc_enable_rrq
);
5851 lpfc_use_msi_init(phba
, lpfc_use_msi
);
5852 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
5853 lpfc_fcp_cpu_map_init(phba
, lpfc_fcp_cpu_map
);
5854 lpfc_fcp_io_channel_init(phba
, lpfc_fcp_io_channel
);
5855 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
5856 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
5857 lpfc_EnableXLane_init(phba
, lpfc_EnableXLane
);
5858 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
5859 phba
->cfg_EnableXLane
= 0;
5860 lpfc_XLanePriority_init(phba
, lpfc_XLanePriority
);
5861 memset(phba
->cfg_oas_tgt_wwpn
, 0, (8 * sizeof(uint8_t)));
5862 memset(phba
->cfg_oas_vpt_wwpn
, 0, (8 * sizeof(uint8_t)));
5863 phba
->cfg_oas_lun_state
= 0;
5864 phba
->cfg_oas_lun_status
= 0;
5865 phba
->cfg_oas_flags
= 0;
5866 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
5867 if (phba
->sli_rev
== LPFC_SLI_REV4
)
5870 phba
->cfg_poll
= lpfc_poll
;
5871 phba
->cfg_soft_wwnn
= 0L;
5872 phba
->cfg_soft_wwpn
= 0L;
5873 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
5874 lpfc_prot_sg_seg_cnt_init(phba
, lpfc_prot_sg_seg_cnt
);
5875 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
5876 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
5877 lpfc_aer_support_init(phba
, lpfc_aer_support
);
5878 lpfc_sriov_nr_virtfn_init(phba
, lpfc_sriov_nr_virtfn
);
5879 lpfc_request_firmware_upgrade_init(phba
, lpfc_req_fw_upgrade
);
5880 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
5881 lpfc_iocb_cnt_init(phba
, lpfc_iocb_cnt
);
5882 phba
->cfg_enable_dss
= 1;
5887 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
5888 * @vport: lpfc_vport pointer.
5891 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
5893 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
5894 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
5895 lpfc_tgt_queue_depth_init(vport
, lpfc_tgt_queue_depth
);
5896 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
5897 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
5898 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
5899 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
5900 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
5901 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
5902 lpfc_first_burst_size_init(vport
, lpfc_first_burst_size
);
5903 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
5904 lpfc_fdmi_on_init(vport
, lpfc_fdmi_on
);
5905 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
5906 lpfc_max_luns_init(vport
, lpfc_max_luns
);
5907 lpfc_scan_down_init(vport
, lpfc_scan_down
);
5908 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);