1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2013 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
9 * This program is free software; you can redistribute it and/or *
10 * modify it under the terms of version 2 of the GNU General *
11 * Public License as published by the Free Software Foundation. *
12 * This program is distributed in the hope that it will be useful. *
13 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
14 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
15 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
16 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
17 * TO BE LEGALLY INVALID. See the GNU General Public License for *
18 * more details, a copy of which can be found in the file COPYING *
19 * included with this package. *
20 *******************************************************************/
22 #include <linux/ctype.h>
23 #include <linux/delay.h>
24 #include <linux/pci.h>
25 #include <linux/interrupt.h>
26 #include <linux/module.h>
27 #include <linux/aer.h>
28 #include <linux/gfp.h>
29 #include <linux/kernel.h>
31 #include <scsi/scsi.h>
32 #include <scsi/scsi_device.h>
33 #include <scsi/scsi_host.h>
34 #include <scsi/scsi_tcq.h>
35 #include <scsi/scsi_transport_fc.h>
36 #include <scsi/fc/fc_fs.h>
41 #include "lpfc_sli4.h"
43 #include "lpfc_disc.h"
44 #include "lpfc_scsi.h"
46 #include "lpfc_logmsg.h"
47 #include "lpfc_version.h"
48 #include "lpfc_compat.h"
49 #include "lpfc_crtn.h"
50 #include "lpfc_vport.h"
52 #define LPFC_DEF_DEVLOSS_TMO 30
53 #define LPFC_MIN_DEVLOSS_TMO 1
54 #define LPFC_MAX_DEVLOSS_TMO 255
57 * Write key size should be multiple of 4. If write key is changed
58 * make sure that library write key is also changed.
60 #define LPFC_REG_WRITE_KEY_SIZE 4
61 #define LPFC_REG_WRITE_KEY "EMLX"
64 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
65 * @incr: integer to convert.
66 * @hdw: ascii string holding converted integer plus a string terminator.
69 * JEDEC Joint Electron Device Engineering Council.
70 * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii
71 * character string. The string is then terminated with a NULL in byte 9.
72 * Hex 0-9 becomes ascii '0' to '9'.
73 * Hex a-f becomes ascii '=' to 'B' capital B.
76 * Coded for 32 bit integers only.
79 lpfc_jedec_to_ascii(int incr, char hdw[])
82 for (i = 0; i < 8; i++) {
85 hdw[7 - i] = 0x30 + j;
87 hdw[7 - i] = 0x61 + j - 10;
95 * lpfc_drvr_version_show - Return the Emulex driver string with version number
96 * @dev: class unused variable.
97 * @attr: device attribute, not used.
98 * @buf: on return contains the module description text.
100 * Returns: size of formatted string.
103 lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
106 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
110 * lpfc_enable_fip_show - Return the fip mode of the HBA
111 * @dev: class unused variable.
112 * @attr: device attribute, not used.
113 * @buf: on return contains the module description text.
115 * Returns: size of formatted string.
118 lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr,
121 struct Scsi_Host *shost = class_to_shost(dev);
122 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
123 struct lpfc_hba *phba = vport->phba;
125 if (phba->hba_flag & HBA_FIP_SUPPORT)
126 return snprintf(buf, PAGE_SIZE, "1\n");
128 return snprintf(buf, PAGE_SIZE, "0\n");
132 lpfc_bg_info_show(struct device *dev, struct device_attribute *attr,
135 struct Scsi_Host *shost = class_to_shost(dev);
136 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
137 struct lpfc_hba *phba = vport->phba;
139 if (phba->cfg_enable_bg)
140 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED)
141 return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n");
143 return snprintf(buf, PAGE_SIZE,
144 "BlockGuard Not Supported\n");
146 return snprintf(buf, PAGE_SIZE,
147 "BlockGuard Disabled\n");
151 lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr,
154 struct Scsi_Host *shost = class_to_shost(dev);
155 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
156 struct lpfc_hba *phba = vport->phba;
158 return snprintf(buf, PAGE_SIZE, "%llu\n",
159 (unsigned long long)phba->bg_guard_err_cnt);
163 lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr,
166 struct Scsi_Host *shost = class_to_shost(dev);
167 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
168 struct lpfc_hba *phba = vport->phba;
170 return snprintf(buf, PAGE_SIZE, "%llu\n",
171 (unsigned long long)phba->bg_apptag_err_cnt);
175 lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr,
178 struct Scsi_Host *shost = class_to_shost(dev);
179 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
180 struct lpfc_hba *phba = vport->phba;
182 return snprintf(buf, PAGE_SIZE, "%llu\n",
183 (unsigned long long)phba->bg_reftag_err_cnt);
187 * lpfc_info_show - Return some pci info about the host in ascii
188 * @dev: class converted to a Scsi_host structure.
189 * @attr: device attribute, not used.
190 * @buf: on return contains the formatted text from lpfc_info().
192 * Returns: size of formatted string.
195 lpfc_info_show(struct device *dev, struct device_attribute *attr,
198 struct Scsi_Host *host = class_to_shost(dev);
200 return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host));
204 * lpfc_serialnum_show - Return the hba serial number in ascii
205 * @dev: class converted to a Scsi_host structure.
206 * @attr: device attribute, not used.
207 * @buf: on return contains the formatted text serial number.
209 * Returns: size of formatted string.
212 lpfc_serialnum_show(struct device *dev, struct device_attribute *attr,
215 struct Scsi_Host *shost = class_to_shost(dev);
216 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
217 struct lpfc_hba *phba = vport->phba;
219 return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
223 * lpfc_temp_sensor_show - Return the temperature sensor level
224 * @dev: class converted to a Scsi_host structure.
225 * @attr: device attribute, not used.
226 * @buf: on return contains the formatted support level.
229 * Returns a number indicating the temperature sensor level currently
230 * supported, zero or one in ascii.
232 * Returns: size of formatted string.
235 lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr,
238 struct Scsi_Host *shost = class_to_shost(dev);
239 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
240 struct lpfc_hba *phba = vport->phba;
241 return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
245 * lpfc_modeldesc_show - Return the model description of the hba
246 * @dev: class converted to a Scsi_host structure.
247 * @attr: device attribute, not used.
248 * @buf: on return contains the scsi vpd model description.
250 * Returns: size of formatted string.
253 lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr,
256 struct Scsi_Host *shost = class_to_shost(dev);
257 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
258 struct lpfc_hba *phba = vport->phba;
260 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc);
264 * lpfc_modelname_show - Return the model name of the hba
265 * @dev: class converted to a Scsi_host structure.
266 * @attr: device attribute, not used.
267 * @buf: on return contains the scsi vpd model name.
269 * Returns: size of formatted string.
272 lpfc_modelname_show(struct device *dev, struct device_attribute *attr,
275 struct Scsi_Host *shost = class_to_shost(dev);
276 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
277 struct lpfc_hba *phba = vport->phba;
279 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName);
283 * lpfc_programtype_show - Return the program type of the hba
284 * @dev: class converted to a Scsi_host structure.
285 * @attr: device attribute, not used.
286 * @buf: on return contains the scsi vpd program type.
288 * Returns: size of formatted string.
291 lpfc_programtype_show(struct device *dev, struct device_attribute *attr,
294 struct Scsi_Host *shost = class_to_shost(dev);
295 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
296 struct lpfc_hba *phba = vport->phba;
298 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType);
302 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
303 * @dev: class converted to a Scsi_host structure.
304 * @attr: device attribute, not used.
305 * @buf: on return contains the Menlo Maintenance sli flag.
307 * Returns: size of formatted string.
310 lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf)
312 struct Scsi_Host *shost = class_to_shost(dev);
313 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
314 struct lpfc_hba *phba = vport->phba;
316 return snprintf(buf, PAGE_SIZE, "%d\n",
317 (phba->sli.sli_flag & LPFC_MENLO_MAINT));
321 * lpfc_vportnum_show - Return the port number in ascii of the hba
322 * @dev: class converted to a Scsi_host structure.
323 * @attr: device attribute, not used.
324 * @buf: on return contains scsi vpd program type.
326 * Returns: size of formatted string.
329 lpfc_vportnum_show(struct device *dev, struct device_attribute *attr,
332 struct Scsi_Host *shost = class_to_shost(dev);
333 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
334 struct lpfc_hba *phba = vport->phba;
336 return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port);
340 * lpfc_fwrev_show - Return the firmware rev running in the hba
341 * @dev: class converted to a Scsi_host structure.
342 * @attr: device attribute, not used.
343 * @buf: on return contains the scsi vpd program type.
345 * Returns: size of formatted string.
348 lpfc_fwrev_show(struct device *dev, struct device_attribute *attr,
351 struct Scsi_Host *shost = class_to_shost(dev);
352 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
353 struct lpfc_hba *phba = vport->phba;
356 char fwrev[FW_REV_STR_SIZE];
359 lpfc_decode_firmware_rev(phba, fwrev, 1);
360 if_type = phba->sli4_hba.pc_sli4_params.if_type;
361 sli_family = phba->sli4_hba.pc_sli4_params.sli_family;
363 if (phba->sli_rev < LPFC_SLI_REV4)
364 len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n",
365 fwrev, phba->sli_rev);
367 len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n",
368 fwrev, phba->sli_rev, if_type, sli_family);
374 * lpfc_hdw_show - Return the jedec information about the hba
375 * @dev: class converted to a Scsi_host structure.
376 * @attr: device attribute, not used.
377 * @buf: on return contains the scsi vpd program type.
379 * Returns: size of formatted string.
382 lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf)
385 struct Scsi_Host *shost = class_to_shost(dev);
386 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
387 struct lpfc_hba *phba = vport->phba;
388 lpfc_vpd_t *vp = &phba->vpd;
390 lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
391 return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
395 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
396 * @dev: class converted to a Scsi_host structure.
397 * @attr: device attribute, not used.
398 * @buf: on return contains the ROM and FCode ascii strings.
400 * Returns: size of formatted string.
403 lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr,
406 struct Scsi_Host *shost = class_to_shost(dev);
407 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
408 struct lpfc_hba *phba = vport->phba;
410 return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
414 * lpfc_state_show - Return the link state of the port
415 * @dev: class converted to a Scsi_host structure.
416 * @attr: device attribute, not used.
417 * @buf: on return contains text describing the state of the link.
420 * The switch statement has no default so zero will be returned.
422 * Returns: size of formatted string.
425 lpfc_link_state_show(struct device *dev, struct device_attribute *attr,
428 struct Scsi_Host *shost = class_to_shost(dev);
429 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
430 struct lpfc_hba *phba = vport->phba;
433 switch (phba->link_state) {
434 case LPFC_LINK_UNKNOWN:
435 case LPFC_WARM_START:
436 case LPFC_INIT_START:
437 case LPFC_INIT_MBX_CMDS:
440 if (phba->hba_flag & LINK_DISABLED)
441 len += snprintf(buf + len, PAGE_SIZE-len,
442 "Link Down - User disabled\n");
444 len += snprintf(buf + len, PAGE_SIZE-len,
450 len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
452 switch (vport->port_state) {
453 case LPFC_LOCAL_CFG_LINK:
454 len += snprintf(buf + len, PAGE_SIZE-len,
455 "Configuring Link\n");
459 case LPFC_FABRIC_CFG_LINK:
462 case LPFC_BUILD_DISC_LIST:
464 len += snprintf(buf + len, PAGE_SIZE - len,
467 case LPFC_VPORT_READY:
468 len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n");
471 case LPFC_VPORT_FAILED:
472 len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n");
475 case LPFC_VPORT_UNKNOWN:
476 len += snprintf(buf + len, PAGE_SIZE - len,
480 if (phba->sli.sli_flag & LPFC_MENLO_MAINT)
481 len += snprintf(buf + len, PAGE_SIZE-len,
482 " Menlo Maint Mode\n");
483 else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
484 if (vport->fc_flag & FC_PUBLIC_LOOP)
485 len += snprintf(buf + len, PAGE_SIZE-len,
488 len += snprintf(buf + len, PAGE_SIZE-len,
491 if (vport->fc_flag & FC_FABRIC)
492 len += snprintf(buf + len, PAGE_SIZE-len,
495 len += snprintf(buf + len, PAGE_SIZE-len,
504 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
505 * @dev: class unused variable.
506 * @attr: device attribute, not used.
507 * @buf: on return contains the module description text.
509 * Returns: size of formatted string.
512 lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr,
515 struct Scsi_Host *shost = class_to_shost(dev);
516 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
517 struct lpfc_hba *phba = vport->phba;
519 if (phba->sli_rev < LPFC_SLI_REV4)
520 return snprintf(buf, PAGE_SIZE, "fc\n");
522 if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) {
523 if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE)
524 return snprintf(buf, PAGE_SIZE, "fcoe\n");
525 if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC)
526 return snprintf(buf, PAGE_SIZE, "fc\n");
528 return snprintf(buf, PAGE_SIZE, "unknown\n");
532 * lpfc_link_state_store - Transition the link_state on an HBA port
533 * @dev: class device that is converted into a Scsi_host.
534 * @attr: device attribute, not used.
535 * @buf: one or more lpfc_polling_flags values.
539 * -EINVAL if the buffer is not "up" or "down"
540 * return from link state change function if non-zero
541 * length of the buf on success
544 lpfc_link_state_store(struct device *dev, struct device_attribute *attr,
545 const char *buf, size_t count)
547 struct Scsi_Host *shost = class_to_shost(dev);
548 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
549 struct lpfc_hba *phba = vport->phba;
551 int status = -EINVAL;
553 if ((strncmp(buf, "up", sizeof("up") - 1) == 0) &&
554 (phba->link_state == LPFC_LINK_DOWN))
555 status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT);
556 else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) &&
557 (phba->link_state >= LPFC_LINK_UP))
558 status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT);
567 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
568 * @dev: class device that is converted into a Scsi_host.
569 * @attr: device attribute, not used.
570 * @buf: on return contains the sum of fc mapped and unmapped.
573 * Returns the ascii text number of the sum of the fc mapped and unmapped
576 * Returns: size of formatted string.
579 lpfc_num_discovered_ports_show(struct device *dev,
580 struct device_attribute *attr, char *buf)
582 struct Scsi_Host *shost = class_to_shost(dev);
583 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
585 return snprintf(buf, PAGE_SIZE, "%d\n",
586 vport->fc_map_cnt + vport->fc_unmap_cnt);
590 * lpfc_issue_lip - Misnomer, name carried over from long ago
591 * @shost: Scsi_Host pointer.
594 * Bring the link down gracefully then re-init the link. The firmware will
595 * re-init the fiber channel interface as required. Does not issue a LIP.
598 * -EPERM port offline or management commands are being blocked
599 * -ENOMEM cannot allocate memory for the mailbox command
600 * -EIO error sending the mailbox command
604 lpfc_issue_lip(struct Scsi_Host *shost)
606 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
607 struct lpfc_hba *phba = vport->phba;
608 LPFC_MBOXQ_t *pmboxq;
609 int mbxstatus = MBXERR_ERROR;
611 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
612 (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO))
615 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
620 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
621 pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK;
622 pmboxq->u.mb.mbxOwner = OWN_HOST;
624 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2);
626 if ((mbxstatus == MBX_SUCCESS) &&
627 (pmboxq->u.mb.mbxStatus == 0 ||
628 pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) {
629 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
630 lpfc_init_link(phba, pmboxq, phba->cfg_topology,
631 phba->cfg_link_speed);
632 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq,
634 if ((mbxstatus == MBX_SUCCESS) &&
635 (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION))
636 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
637 "2859 SLI authentication is required "
638 "for INIT_LINK but has not done yet\n");
641 lpfc_set_loopback_flag(phba);
642 if (mbxstatus != MBX_TIMEOUT)
643 mempool_free(pmboxq, phba->mbox_mem_pool);
645 if (mbxstatus == MBXERR_ERROR)
652 * lpfc_do_offline - Issues a mailbox command to bring the link down
653 * @phba: lpfc_hba pointer.
654 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
657 * Assumes any error from lpfc_do_offline() will be negative.
658 * Can wait up to 5 seconds for the port ring buffers count
659 * to reach zero, prints a warning if it is not zero and continues.
660 * lpfc_workq_post_event() returns a non-zero return code if call fails.
663 * -EIO error posting the event
667 lpfc_do_offline(struct lpfc_hba *phba, uint32_t type)
669 struct completion online_compl;
670 struct lpfc_sli_ring *pring;
671 struct lpfc_sli *psli;
677 init_completion(&online_compl);
678 rc = lpfc_workq_post_event(phba, &status, &online_compl,
679 LPFC_EVT_OFFLINE_PREP);
683 wait_for_completion(&online_compl);
690 /* Wait a little for things to settle down, but not
691 * long enough for dev loss timeout to expire.
693 for (i = 0; i < psli->num_rings; i++) {
694 pring = &psli->ring[i];
695 while (!list_empty(&pring->txcmplq)) {
697 if (cnt++ > 500) { /* 5 secs */
698 lpfc_printf_log(phba,
699 KERN_WARNING, LOG_INIT,
700 "0466 Outstanding IO when "
701 "bringing Adapter offline\n");
707 init_completion(&online_compl);
708 rc = lpfc_workq_post_event(phba, &status, &online_compl, type);
712 wait_for_completion(&online_compl);
721 * lpfc_selective_reset - Offline then onlines the port
722 * @phba: lpfc_hba pointer.
725 * If the port is configured to allow a reset then the hba is brought
726 * offline then online.
729 * Assumes any error from lpfc_do_offline() will be negative.
730 * Do not make this function static.
733 * lpfc_do_offline() return code if not zero
734 * -EIO reset not configured or error posting the event
738 lpfc_selective_reset(struct lpfc_hba *phba)
740 struct completion online_compl;
744 if (!phba->cfg_enable_hba_reset)
747 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) {
748 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
754 init_completion(&online_compl);
755 rc = lpfc_workq_post_event(phba, &status, &online_compl,
760 wait_for_completion(&online_compl);
769 * lpfc_issue_reset - Selectively resets an adapter
770 * @dev: class device that is converted into a Scsi_host.
771 * @attr: device attribute, not used.
772 * @buf: containing the string "selective".
773 * @count: unused variable.
776 * If the buf contains the string "selective" then lpfc_selective_reset()
777 * is called to perform the reset.
780 * Assumes any error from lpfc_selective_reset() will be negative.
781 * If lpfc_selective_reset() returns zero then the length of the buffer
782 * is returned which indicates success
785 * -EINVAL if the buffer does not contain the string "selective"
786 * length of buf if lpfc-selective_reset() if the call succeeds
787 * return value of lpfc_selective_reset() if the call fails
790 lpfc_issue_reset(struct device *dev, struct device_attribute *attr,
791 const char *buf, size_t count)
793 struct Scsi_Host *shost = class_to_shost(dev);
794 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
795 struct lpfc_hba *phba = vport->phba;
796 int status = -EINVAL;
798 if (!phba->cfg_enable_hba_reset)
801 if (strncmp(buf, "selective", sizeof("selective") - 1) == 0)
802 status = phba->lpfc_selective_reset(phba);
811 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
812 * @phba: lpfc_hba pointer.
815 * SLI4 interface type-2 device to wait on the sliport status register for
816 * the readyness after performing a firmware reset.
819 * zero for success, -EPERM when port does not have privilage to perform the
820 * reset, -EIO when port timeout from recovering from the reset.
823 * As the caller will interpret the return code by value, be careful in making
824 * change or addition to return codes.
827 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba)
829 struct lpfc_register portstat_reg = {0};
833 lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
834 &portstat_reg.word0);
836 /* verify if privilaged for the request operation */
837 if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) &&
838 !bf_get(lpfc_sliport_status_err, &portstat_reg))
841 /* wait for the SLI port firmware ready after firmware reset */
842 for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) {
844 lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
845 &portstat_reg.word0);
846 if (!bf_get(lpfc_sliport_status_err, &portstat_reg))
848 if (!bf_get(lpfc_sliport_status_rn, &portstat_reg))
850 if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg))
855 if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT)
862 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
863 * @phba: lpfc_hba pointer.
866 * Request SLI4 interface type-2 device to perform a physical register set
873 lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
875 struct completion online_compl;
876 struct pci_dev *pdev = phba->pcidev;
877 uint32_t before_fc_flag;
878 uint32_t sriov_nr_virtfn;
880 int status = 0, rc = 0;
881 int job_posted = 1, sriov_err;
883 if (!phba->cfg_enable_hba_reset)
886 if ((phba->sli_rev < LPFC_SLI_REV4) ||
887 (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
888 LPFC_SLI_INTF_IF_TYPE_2))
891 /* Keep state if we need to restore back */
892 before_fc_flag = phba->pport->fc_flag;
893 sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn;
895 /* Disable SR-IOV virtual functions if enabled */
896 if (phba->cfg_sriov_nr_virtfn) {
897 pci_disable_sriov(pdev);
898 phba->cfg_sriov_nr_virtfn = 0;
901 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
906 /* wait for the device to be quiesced before firmware reset */
909 reg_val = readl(phba->sli4_hba.conf_regs_memmap_p +
910 LPFC_CTL_PDEV_CTL_OFFSET);
912 if (opcode == LPFC_FW_DUMP)
913 reg_val |= LPFC_FW_DUMP_REQUEST;
914 else if (opcode == LPFC_FW_RESET)
915 reg_val |= LPFC_CTL_PDEV_CTL_FRST;
916 else if (opcode == LPFC_DV_RESET)
917 reg_val |= LPFC_CTL_PDEV_CTL_DRST;
919 writel(reg_val, phba->sli4_hba.conf_regs_memmap_p +
920 LPFC_CTL_PDEV_CTL_OFFSET);
922 readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
924 /* delay driver action following IF_TYPE_2 reset */
925 rc = lpfc_sli4_pdev_status_reg_wait(phba);
928 /* no privilage for reset */
929 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
930 "3150 No privilage to perform the requested "
931 "access: x%x\n", reg_val);
932 } else if (rc == -EIO) {
933 /* reset failed, there is nothing more we can do */
934 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
935 "3153 Fail to perform the requested "
936 "access: x%x\n", reg_val);
940 /* keep the original port state */
941 if (before_fc_flag & FC_OFFLINE_MODE)
944 init_completion(&online_compl);
945 job_posted = lpfc_workq_post_event(phba, &status, &online_compl,
950 wait_for_completion(&online_compl);
953 /* in any case, restore the virtual functions enabled as before */
954 if (sriov_nr_virtfn) {
956 lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn);
958 phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn;
961 /* return proper error code */
972 * lpfc_nport_evt_cnt_show - Return the number of nport events
973 * @dev: class device that is converted into a Scsi_host.
974 * @attr: device attribute, not used.
975 * @buf: on return contains the ascii number of nport events.
977 * Returns: size of formatted string.
980 lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr,
983 struct Scsi_Host *shost = class_to_shost(dev);
984 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
985 struct lpfc_hba *phba = vport->phba;
987 return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
991 * lpfc_board_mode_show - Return the state of the board
992 * @dev: class device that is converted into a Scsi_host.
993 * @attr: device attribute, not used.
994 * @buf: on return contains the state of the adapter.
996 * Returns: size of formatted string.
999 lpfc_board_mode_show(struct device *dev, struct device_attribute *attr,
1002 struct Scsi_Host *shost = class_to_shost(dev);
1003 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1004 struct lpfc_hba *phba = vport->phba;
1007 if (phba->link_state == LPFC_HBA_ERROR)
1009 else if (phba->link_state == LPFC_WARM_START)
1010 state = "warm start";
1011 else if (phba->link_state == LPFC_INIT_START)
1016 return snprintf(buf, PAGE_SIZE, "%s\n", state);
1020 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1021 * @dev: class device that is converted into a Scsi_host.
1022 * @attr: device attribute, not used.
1023 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1024 * @count: unused variable.
1027 * -EACCES if enable hba reset not enabled
1028 * -EINVAL if the buffer does not contain a valid string (see above)
1029 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1030 * buf length greater than zero indicates success
1033 lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
1034 const char *buf, size_t count)
1036 struct Scsi_Host *shost = class_to_shost(dev);
1037 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1038 struct lpfc_hba *phba = vport->phba;
1039 struct completion online_compl;
1040 char *board_mode_str = NULL;
1044 if (!phba->cfg_enable_hba_reset) {
1046 goto board_mode_out;
1049 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1050 "3050 lpfc_board_mode set to %s\n", buf);
1052 init_completion(&online_compl);
1054 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
1055 rc = lpfc_workq_post_event(phba, &status, &online_compl,
1059 goto board_mode_out;
1061 wait_for_completion(&online_compl);
1062 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
1063 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
1064 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
1065 if (phba->sli_rev == LPFC_SLI_REV4)
1068 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START);
1069 else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
1070 if (phba->sli_rev == LPFC_SLI_REV4)
1073 status = lpfc_do_offline(phba, LPFC_EVT_KILL);
1074 else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0)
1075 status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP);
1076 else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0)
1077 status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET);
1078 else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0)
1079 status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET);
1087 board_mode_str = strchr(buf, '\n');
1089 *board_mode_str = '\0';
1090 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1091 "3097 Failed \"%s\", status(%d), "
1093 buf, status, phba->pport->fc_flag);
1099 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1100 * @phba: pointer to the adapter structure.
1101 * @mxri: max xri count.
1102 * @axri: available xri count.
1103 * @mrpi: max rpi count.
1104 * @arpi: available rpi count.
1105 * @mvpi: max vpi count.
1106 * @avpi: available vpi count.
1109 * If an integer pointer for an count is not null then the value for the
1110 * count is returned.
1117 lpfc_get_hba_info(struct lpfc_hba *phba,
1118 uint32_t *mxri, uint32_t *axri,
1119 uint32_t *mrpi, uint32_t *arpi,
1120 uint32_t *mvpi, uint32_t *avpi)
1122 struct lpfc_mbx_read_config *rd_config;
1123 LPFC_MBOXQ_t *pmboxq;
1129 * prevent udev from issuing mailbox commands until the port is
1132 if (phba->link_state < LPFC_LINK_DOWN ||
1133 !phba->mbox_mem_pool ||
1134 (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0)
1137 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
1140 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1143 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
1145 pmb = &pmboxq->u.mb;
1146 pmb->mbxCommand = MBX_READ_CONFIG;
1147 pmb->mbxOwner = OWN_HOST;
1148 pmboxq->context1 = NULL;
1150 if (phba->pport->fc_flag & FC_OFFLINE_MODE)
1151 rc = MBX_NOT_FINISHED;
1153 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
1155 if (rc != MBX_SUCCESS) {
1156 if (rc != MBX_TIMEOUT)
1157 mempool_free(pmboxq, phba->mbox_mem_pool);
1161 if (phba->sli_rev == LPFC_SLI_REV4) {
1162 rd_config = &pmboxq->u.mqe.un.rd_config;
1164 *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config);
1166 *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) -
1167 phba->sli4_hba.max_cfg_param.rpi_used;
1169 *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config);
1171 *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) -
1172 phba->sli4_hba.max_cfg_param.xri_used;
1174 /* Account for differences with SLI-3. Get vpi count from
1175 * mailbox data and subtract one for max vpi value.
1177 max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ?
1178 (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0;
1183 *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used;
1186 *mrpi = pmb->un.varRdConfig.max_rpi;
1188 *arpi = pmb->un.varRdConfig.avail_rpi;
1190 *mxri = pmb->un.varRdConfig.max_xri;
1192 *axri = pmb->un.varRdConfig.avail_xri;
1194 *mvpi = pmb->un.varRdConfig.max_vpi;
1196 *avpi = pmb->un.varRdConfig.avail_vpi;
1199 mempool_free(pmboxq, phba->mbox_mem_pool);
1204 * lpfc_max_rpi_show - Return maximum rpi
1205 * @dev: class device that is converted into a Scsi_host.
1206 * @attr: device attribute, not used.
1207 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1210 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1211 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1212 * to "Unknown" and the buffer length is returned, therefore the caller
1213 * must check for "Unknown" in the buffer to detect a failure.
1215 * Returns: size of formatted string.
1218 lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr,
1221 struct Scsi_Host *shost = class_to_shost(dev);
1222 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1223 struct lpfc_hba *phba = vport->phba;
1226 if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL))
1227 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1228 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1232 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1233 * @dev: class device that is converted into a Scsi_host.
1234 * @attr: device attribute, not used.
1235 * @buf: containing the used rpi count in decimal or "Unknown".
1238 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1239 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1240 * to "Unknown" and the buffer length is returned, therefore the caller
1241 * must check for "Unknown" in the buffer to detect a failure.
1243 * Returns: size of formatted string.
1246 lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr,
1249 struct Scsi_Host *shost = class_to_shost(dev);
1250 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1251 struct lpfc_hba *phba = vport->phba;
1254 if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL))
1255 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1256 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1260 * lpfc_max_xri_show - Return maximum xri
1261 * @dev: class device that is converted into a Scsi_host.
1262 * @attr: device attribute, not used.
1263 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1266 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1267 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1268 * to "Unknown" and the buffer length is returned, therefore the caller
1269 * must check for "Unknown" in the buffer to detect a failure.
1271 * Returns: size of formatted string.
1274 lpfc_max_xri_show(struct device *dev, struct device_attribute *attr,
1277 struct Scsi_Host *shost = class_to_shost(dev);
1278 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1279 struct lpfc_hba *phba = vport->phba;
1282 if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL))
1283 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1284 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1288 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1289 * @dev: class device that is converted into a Scsi_host.
1290 * @attr: device attribute, not used.
1291 * @buf: on return contains the used xri count in decimal or "Unknown".
1294 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1295 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1296 * to "Unknown" and the buffer length is returned, therefore the caller
1297 * must check for "Unknown" in the buffer to detect a failure.
1299 * Returns: size of formatted string.
1302 lpfc_used_xri_show(struct device *dev, struct device_attribute *attr,
1305 struct Scsi_Host *shost = class_to_shost(dev);
1306 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1307 struct lpfc_hba *phba = vport->phba;
1310 if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL))
1311 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1312 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1316 * lpfc_max_vpi_show - Return maximum vpi
1317 * @dev: class device that is converted into a Scsi_host.
1318 * @attr: device attribute, not used.
1319 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1322 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1323 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1324 * to "Unknown" and the buffer length is returned, therefore the caller
1325 * must check for "Unknown" in the buffer to detect a failure.
1327 * Returns: size of formatted string.
1330 lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr,
1333 struct Scsi_Host *shost = class_to_shost(dev);
1334 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1335 struct lpfc_hba *phba = vport->phba;
1338 if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL))
1339 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1340 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1344 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1345 * @dev: class device that is converted into a Scsi_host.
1346 * @attr: device attribute, not used.
1347 * @buf: on return contains the used vpi count in decimal or "Unknown".
1350 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1351 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1352 * to "Unknown" and the buffer length is returned, therefore the caller
1353 * must check for "Unknown" in the buffer to detect a failure.
1355 * Returns: size of formatted string.
1358 lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr,
1361 struct Scsi_Host *shost = class_to_shost(dev);
1362 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1363 struct lpfc_hba *phba = vport->phba;
1366 if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt))
1367 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1368 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1372 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1373 * @dev: class device that is converted into a Scsi_host.
1374 * @attr: device attribute, not used.
1375 * @buf: text that must be interpreted to determine if npiv is supported.
1378 * Buffer will contain text indicating npiv is not suppoerted on the port,
1379 * the port is an NPIV physical port, or it is an npiv virtual port with
1380 * the id of the vport.
1382 * Returns: size of formatted string.
1385 lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr,
1388 struct Scsi_Host *shost = class_to_shost(dev);
1389 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1390 struct lpfc_hba *phba = vport->phba;
1392 if (!(phba->max_vpi))
1393 return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n");
1394 if (vport->port_type == LPFC_PHYSICAL_PORT)
1395 return snprintf(buf, PAGE_SIZE, "NPIV Physical\n");
1396 return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi);
1400 * lpfc_poll_show - Return text about poll support for the adapter
1401 * @dev: class device that is converted into a Scsi_host.
1402 * @attr: device attribute, not used.
1403 * @buf: on return contains the cfg_poll in hex.
1406 * cfg_poll should be a lpfc_polling_flags type.
1408 * Returns: size of formatted string.
1411 lpfc_poll_show(struct device *dev, struct device_attribute *attr,
1414 struct Scsi_Host *shost = class_to_shost(dev);
1415 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1416 struct lpfc_hba *phba = vport->phba;
1418 return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
1422 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1423 * @dev: class device that is converted into a Scsi_host.
1424 * @attr: device attribute, not used.
1425 * @buf: one or more lpfc_polling_flags values.
1429 * buf contents converted to integer and checked for a valid value.
1432 * -EINVAL if the buffer connot be converted or is out of range
1433 * length of the buf on success
1436 lpfc_poll_store(struct device *dev, struct device_attribute *attr,
1437 const char *buf, size_t count)
1439 struct Scsi_Host *shost = class_to_shost(dev);
1440 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1441 struct lpfc_hba *phba = vport->phba;
1446 if (!isdigit(buf[0]))
1449 if (sscanf(buf, "%i", &val) != 1)
1452 if ((val & 0x3) != val)
1455 if (phba->sli_rev == LPFC_SLI_REV4)
1458 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1459 "3051 lpfc_poll changed from %d to %d\n",
1460 phba->cfg_poll, val);
1462 spin_lock_irq(&phba->hbalock);
1464 old_val = phba->cfg_poll;
1466 if (val & ENABLE_FCP_RING_POLLING) {
1467 if ((val & DISABLE_FCP_RING_INT) &&
1468 !(old_val & DISABLE_FCP_RING_INT)) {
1469 if (lpfc_readl(phba->HCregaddr, &creg_val)) {
1470 spin_unlock_irq(&phba->hbalock);
1473 creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
1474 writel(creg_val, phba->HCregaddr);
1475 readl(phba->HCregaddr); /* flush */
1477 lpfc_poll_start_timer(phba);
1479 } else if (val != 0x0) {
1480 spin_unlock_irq(&phba->hbalock);
1484 if (!(val & DISABLE_FCP_RING_INT) &&
1485 (old_val & DISABLE_FCP_RING_INT))
1487 spin_unlock_irq(&phba->hbalock);
1488 del_timer(&phba->fcp_poll_timer);
1489 spin_lock_irq(&phba->hbalock);
1490 if (lpfc_readl(phba->HCregaddr, &creg_val)) {
1491 spin_unlock_irq(&phba->hbalock);
1494 creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING);
1495 writel(creg_val, phba->HCregaddr);
1496 readl(phba->HCregaddr); /* flush */
1499 phba->cfg_poll = val;
1501 spin_unlock_irq(&phba->hbalock);
1507 * lpfc_fips_level_show - Return the current FIPS level for the HBA
1508 * @dev: class unused variable.
1509 * @attr: device attribute, not used.
1510 * @buf: on return contains the module description text.
1512 * Returns: size of formatted string.
1515 lpfc_fips_level_show(struct device *dev, struct device_attribute *attr,
1518 struct Scsi_Host *shost = class_to_shost(dev);
1519 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1520 struct lpfc_hba *phba = vport->phba;
1522 return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level);
1526 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
1527 * @dev: class unused variable.
1528 * @attr: device attribute, not used.
1529 * @buf: on return contains the module description text.
1531 * Returns: size of formatted string.
1534 lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr,
1537 struct Scsi_Host *shost = class_to_shost(dev);
1538 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1539 struct lpfc_hba *phba = vport->phba;
1541 return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev);
1545 * lpfc_dss_show - Return the current state of dss and the configured state
1546 * @dev: class converted to a Scsi_host structure.
1547 * @attr: device attribute, not used.
1548 * @buf: on return contains the formatted text.
1550 * Returns: size of formatted string.
1553 lpfc_dss_show(struct device *dev, struct device_attribute *attr,
1556 struct Scsi_Host *shost = class_to_shost(dev);
1557 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1558 struct lpfc_hba *phba = vport->phba;
1560 return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n",
1561 (phba->cfg_enable_dss) ? "Enabled" : "Disabled",
1562 (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ?
1567 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
1568 * @dev: class converted to a Scsi_host structure.
1569 * @attr: device attribute, not used.
1570 * @buf: on return contains the formatted support level.
1573 * Returns the maximum number of virtual functions a physical function can
1574 * support, 0 will be returned if called on virtual function.
1576 * Returns: size of formatted string.
1579 lpfc_sriov_hw_max_virtfn_show(struct device *dev,
1580 struct device_attribute *attr,
1583 struct Scsi_Host *shost = class_to_shost(dev);
1584 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1585 struct lpfc_hba *phba = vport->phba;
1586 uint16_t max_nr_virtfn;
1588 max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba);
1589 return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
1593 * lpfc_param_show - Return a cfg attribute value in decimal
1596 * Macro that given an attr e.g. hba_queue_depth expands
1597 * into a function with the name lpfc_hba_queue_depth_show.
1599 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
1600 * @dev: class device that is converted into a Scsi_host.
1601 * @attr: device attribute, not used.
1602 * @buf: on return contains the attribute value in decimal.
1604 * Returns: size of formatted string.
1606 #define lpfc_param_show(attr) \
1608 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1611 struct Scsi_Host *shost = class_to_shost(dev);\
1612 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1613 struct lpfc_hba *phba = vport->phba;\
1615 val = phba->cfg_##attr;\
1616 return snprintf(buf, PAGE_SIZE, "%d\n",\
1621 * lpfc_param_hex_show - Return a cfg attribute value in hex
1624 * Macro that given an attr e.g. hba_queue_depth expands
1625 * into a function with the name lpfc_hba_queue_depth_show
1627 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
1628 * @dev: class device that is converted into a Scsi_host.
1629 * @attr: device attribute, not used.
1630 * @buf: on return contains the attribute value in hexadecimal.
1632 * Returns: size of formatted string.
1634 #define lpfc_param_hex_show(attr) \
1636 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1639 struct Scsi_Host *shost = class_to_shost(dev);\
1640 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1641 struct lpfc_hba *phba = vport->phba;\
1643 val = phba->cfg_##attr;\
1644 return snprintf(buf, PAGE_SIZE, "%#x\n",\
1649 * lpfc_param_init - Initializes a cfg attribute
1652 * Macro that given an attr e.g. hba_queue_depth expands
1653 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1654 * takes a default argument, a minimum and maximum argument.
1656 * lpfc_##attr##_init: Initializes an attribute.
1657 * @phba: pointer the the adapter structure.
1658 * @val: integer attribute value.
1660 * Validates the min and max values then sets the adapter config field
1661 * accordingly, or uses the default if out of range and prints an error message.
1665 * -EINVAL if default used
1667 #define lpfc_param_init(attr, default, minval, maxval) \
1669 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1671 if (val >= minval && val <= maxval) {\
1672 phba->cfg_##attr = val;\
1675 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1676 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
1677 "allowed range is ["#minval", "#maxval"]\n", val); \
1678 phba->cfg_##attr = default;\
1683 * lpfc_param_set - Set a cfg attribute value
1686 * Macro that given an attr e.g. hba_queue_depth expands
1687 * into a function with the name lpfc_hba_queue_depth_set
1689 * lpfc_##attr##_set: Sets an attribute value.
1690 * @phba: pointer the the adapter structure.
1691 * @val: integer attribute value.
1694 * Validates the min and max values then sets the
1695 * adapter config field if in the valid range. prints error message
1696 * and does not set the parameter if invalid.
1700 * -EINVAL if val is invalid
1702 #define lpfc_param_set(attr, default, minval, maxval) \
1704 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
1706 if (val >= minval && val <= maxval) {\
1707 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1708 "3052 lpfc_" #attr " changed from %d to %d\n", \
1709 phba->cfg_##attr, val); \
1710 phba->cfg_##attr = val;\
1713 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1714 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
1715 "allowed range is ["#minval", "#maxval"]\n", val); \
1720 * lpfc_param_store - Set a vport attribute value
1723 * Macro that given an attr e.g. hba_queue_depth expands
1724 * into a function with the name lpfc_hba_queue_depth_store.
1726 * lpfc_##attr##_store: Set an sttribute value.
1727 * @dev: class device that is converted into a Scsi_host.
1728 * @attr: device attribute, not used.
1729 * @buf: contains the attribute value in ascii.
1733 * Convert the ascii text number to an integer, then
1734 * use the lpfc_##attr##_set function to set the value.
1737 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1738 * length of buffer upon success.
1740 #define lpfc_param_store(attr) \
1742 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1743 const char *buf, size_t count) \
1745 struct Scsi_Host *shost = class_to_shost(dev);\
1746 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1747 struct lpfc_hba *phba = vport->phba;\
1749 if (!isdigit(buf[0]))\
1751 if (sscanf(buf, "%i", &val) != 1)\
1753 if (lpfc_##attr##_set(phba, val) == 0) \
1754 return strlen(buf);\
1760 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
1763 * Macro that given an attr e.g. hba_queue_depth expands
1764 * into a function with the name lpfc_hba_queue_depth_show
1766 * lpfc_##attr##_show: prints the attribute value in decimal.
1767 * @dev: class device that is converted into a Scsi_host.
1768 * @attr: device attribute, not used.
1769 * @buf: on return contains the attribute value in decimal.
1771 * Returns: length of formatted string.
1773 #define lpfc_vport_param_show(attr) \
1775 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1778 struct Scsi_Host *shost = class_to_shost(dev);\
1779 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1781 val = vport->cfg_##attr;\
1782 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
1786 * lpfc_vport_param_hex_show - Return hex formatted attribute value
1789 * Macro that given an attr e.g.
1790 * hba_queue_depth expands into a function with the name
1791 * lpfc_hba_queue_depth_show
1793 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
1794 * @dev: class device that is converted into a Scsi_host.
1795 * @attr: device attribute, not used.
1796 * @buf: on return contains the attribute value in hexadecimal.
1798 * Returns: length of formatted string.
1800 #define lpfc_vport_param_hex_show(attr) \
1802 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1805 struct Scsi_Host *shost = class_to_shost(dev);\
1806 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1808 val = vport->cfg_##attr;\
1809 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
1813 * lpfc_vport_param_init - Initialize a vport cfg attribute
1816 * Macro that given an attr e.g. hba_queue_depth expands
1817 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1818 * takes a default argument, a minimum and maximum argument.
1820 * lpfc_##attr##_init: validates the min and max values then sets the
1821 * adapter config field accordingly, or uses the default if out of range
1822 * and prints an error message.
1823 * @phba: pointer the the adapter structure.
1824 * @val: integer attribute value.
1828 * -EINVAL if default used
1830 #define lpfc_vport_param_init(attr, default, minval, maxval) \
1832 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
1834 if (val >= minval && val <= maxval) {\
1835 vport->cfg_##attr = val;\
1838 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1839 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
1840 "allowed range is ["#minval", "#maxval"]\n", val); \
1841 vport->cfg_##attr = default;\
1846 * lpfc_vport_param_set - Set a vport cfg attribute
1849 * Macro that given an attr e.g. hba_queue_depth expands
1850 * into a function with the name lpfc_hba_queue_depth_set
1852 * lpfc_##attr##_set: validates the min and max values then sets the
1853 * adapter config field if in the valid range. prints error message
1854 * and does not set the parameter if invalid.
1855 * @phba: pointer the the adapter structure.
1856 * @val: integer attribute value.
1860 * -EINVAL if val is invalid
1862 #define lpfc_vport_param_set(attr, default, minval, maxval) \
1864 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
1866 if (val >= minval && val <= maxval) {\
1867 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1868 "3053 lpfc_" #attr " changed from %d to %d\n", \
1869 vport->cfg_##attr, val); \
1870 vport->cfg_##attr = val;\
1873 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1874 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
1875 "allowed range is ["#minval", "#maxval"]\n", val); \
1880 * lpfc_vport_param_store - Set a vport attribute
1883 * Macro that given an attr e.g. hba_queue_depth
1884 * expands into a function with the name lpfc_hba_queue_depth_store
1886 * lpfc_##attr##_store: convert the ascii text number to an integer, then
1887 * use the lpfc_##attr##_set function to set the value.
1888 * @cdev: class device that is converted into a Scsi_host.
1889 * @buf: contains the attribute value in decimal.
1893 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1894 * length of buffer upon success.
1896 #define lpfc_vport_param_store(attr) \
1898 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1899 const char *buf, size_t count) \
1901 struct Scsi_Host *shost = class_to_shost(dev);\
1902 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1904 if (!isdigit(buf[0]))\
1906 if (sscanf(buf, "%i", &val) != 1)\
1908 if (lpfc_##attr##_set(vport, val) == 0) \
1909 return strlen(buf);\
1915 #define LPFC_ATTR(name, defval, minval, maxval, desc) \
1916 static uint lpfc_##name = defval;\
1917 module_param(lpfc_##name, uint, S_IRUGO);\
1918 MODULE_PARM_DESC(lpfc_##name, desc);\
1919 lpfc_param_init(name, defval, minval, maxval)
1921 #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \
1922 static uint lpfc_##name = defval;\
1923 module_param(lpfc_##name, uint, S_IRUGO);\
1924 MODULE_PARM_DESC(lpfc_##name, desc);\
1925 lpfc_param_show(name)\
1926 lpfc_param_init(name, defval, minval, maxval)\
1927 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1929 #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \
1930 static uint lpfc_##name = defval;\
1931 module_param(lpfc_##name, uint, S_IRUGO);\
1932 MODULE_PARM_DESC(lpfc_##name, desc);\
1933 lpfc_param_show(name)\
1934 lpfc_param_init(name, defval, minval, maxval)\
1935 lpfc_param_set(name, defval, minval, maxval)\
1936 lpfc_param_store(name)\
1937 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1938 lpfc_##name##_show, lpfc_##name##_store)
1940 #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1941 static uint lpfc_##name = defval;\
1942 module_param(lpfc_##name, uint, S_IRUGO);\
1943 MODULE_PARM_DESC(lpfc_##name, desc);\
1944 lpfc_param_hex_show(name)\
1945 lpfc_param_init(name, defval, minval, maxval)\
1946 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1948 #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1949 static uint lpfc_##name = defval;\
1950 module_param(lpfc_##name, uint, S_IRUGO);\
1951 MODULE_PARM_DESC(lpfc_##name, desc);\
1952 lpfc_param_hex_show(name)\
1953 lpfc_param_init(name, defval, minval, maxval)\
1954 lpfc_param_set(name, defval, minval, maxval)\
1955 lpfc_param_store(name)\
1956 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1957 lpfc_##name##_show, lpfc_##name##_store)
1959 #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
1960 static uint lpfc_##name = defval;\
1961 module_param(lpfc_##name, uint, S_IRUGO);\
1962 MODULE_PARM_DESC(lpfc_##name, desc);\
1963 lpfc_vport_param_init(name, defval, minval, maxval)
1965 #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
1966 static uint lpfc_##name = defval;\
1967 module_param(lpfc_##name, uint, S_IRUGO);\
1968 MODULE_PARM_DESC(lpfc_##name, desc);\
1969 lpfc_vport_param_show(name)\
1970 lpfc_vport_param_init(name, defval, minval, maxval)\
1971 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1973 #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
1974 static uint lpfc_##name = defval;\
1975 module_param(lpfc_##name, uint, S_IRUGO);\
1976 MODULE_PARM_DESC(lpfc_##name, desc);\
1977 lpfc_vport_param_show(name)\
1978 lpfc_vport_param_init(name, defval, minval, maxval)\
1979 lpfc_vport_param_set(name, defval, minval, maxval)\
1980 lpfc_vport_param_store(name)\
1981 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1982 lpfc_##name##_show, lpfc_##name##_store)
1984 #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1985 static uint lpfc_##name = defval;\
1986 module_param(lpfc_##name, uint, S_IRUGO);\
1987 MODULE_PARM_DESC(lpfc_##name, desc);\
1988 lpfc_vport_param_hex_show(name)\
1989 lpfc_vport_param_init(name, defval, minval, maxval)\
1990 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1992 #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1993 static uint lpfc_##name = defval;\
1994 module_param(lpfc_##name, uint, S_IRUGO);\
1995 MODULE_PARM_DESC(lpfc_##name, desc);\
1996 lpfc_vport_param_hex_show(name)\
1997 lpfc_vport_param_init(name, defval, minval, maxval)\
1998 lpfc_vport_param_set(name, defval, minval, maxval)\
1999 lpfc_vport_param_store(name)\
2000 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
2001 lpfc_##name##_show, lpfc_##name##_store)
2003 static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL);
2004 static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL);
2005 static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL);
2006 static DEVICE_ATTR(bg_reftag_err, S_IRUGO, lpfc_bg_reftag_err_show, NULL);
2007 static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
2008 static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
2009 static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
2010 static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL);
2011 static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL);
2012 static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL);
2013 static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL);
2014 static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL);
2015 static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show,
2016 lpfc_link_state_store);
2017 static DEVICE_ATTR(option_rom_version, S_IRUGO,
2018 lpfc_option_rom_version_show, NULL);
2019 static DEVICE_ATTR(num_discovered_ports, S_IRUGO,
2020 lpfc_num_discovered_ports_show, NULL);
2021 static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL);
2022 static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
2023 static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL);
2024 static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL);
2025 static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
2026 lpfc_board_mode_show, lpfc_board_mode_store);
2027 static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
2028 static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL);
2029 static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL);
2030 static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL);
2031 static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL);
2032 static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
2033 static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
2034 static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
2035 static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL);
2036 static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL);
2037 static DEVICE_ATTR(lpfc_fips_rev, S_IRUGO, lpfc_fips_rev_show, NULL);
2038 static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL);
2039 static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO,
2040 lpfc_sriov_hw_max_virtfn_show, NULL);
2041 static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL);
2043 static char *lpfc_soft_wwn_key = "C99G71SL8032A";
2046 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2047 * @dev: class device that is converted into a Scsi_host.
2048 * @attr: device attribute, not used.
2049 * @buf: containing the string lpfc_soft_wwn_key.
2050 * @count: must be size of lpfc_soft_wwn_key.
2053 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2054 * length of buf indicates success
2057 lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr,
2058 const char *buf, size_t count)
2060 struct Scsi_Host *shost = class_to_shost(dev);
2061 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2062 struct lpfc_hba *phba = vport->phba;
2063 unsigned int cnt = count;
2066 * We're doing a simple sanity check for soft_wwpn setting.
2067 * We require that the user write a specific key to enable
2068 * the soft_wwpn attribute to be settable. Once the attribute
2069 * is written, the enable key resets. If further updates are
2070 * desired, the key must be written again to re-enable the
2073 * The "key" is not secret - it is a hardcoded string shown
2074 * here. The intent is to protect against the random user or
2075 * application that is just writing attributes.
2078 /* count may include a LF at end of string */
2079 if (buf[cnt-1] == '\n')
2082 if ((cnt != strlen(lpfc_soft_wwn_key)) ||
2083 (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0))
2086 phba->soft_wwn_enable = 1;
2089 static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
2090 lpfc_soft_wwn_enable_store);
2093 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2094 * @dev: class device that is converted into a Scsi_host.
2095 * @attr: device attribute, not used.
2096 * @buf: on return contains the wwpn in hexadecimal.
2098 * Returns: size of formatted string.
2101 lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr,
2104 struct Scsi_Host *shost = class_to_shost(dev);
2105 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2106 struct lpfc_hba *phba = vport->phba;
2108 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2109 (unsigned long long)phba->cfg_soft_wwpn);
2113 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2114 * @dev class device that is converted into a Scsi_host.
2115 * @attr: device attribute, not used.
2116 * @buf: contains the wwpn in hexadecimal.
2117 * @count: number of wwpn bytes in buf
2120 * -EACCES hba reset not enabled, adapter over temp
2121 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2122 * -EIO error taking adapter offline or online
2123 * value of count on success
2126 lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr,
2127 const char *buf, size_t count)
2129 struct Scsi_Host *shost = class_to_shost(dev);
2130 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2131 struct lpfc_hba *phba = vport->phba;
2132 struct completion online_compl;
2133 int stat1=0, stat2=0;
2134 unsigned int i, j, cnt=count;
2138 if (!phba->cfg_enable_hba_reset)
2140 spin_lock_irq(&phba->hbalock);
2141 if (phba->over_temp_state == HBA_OVER_TEMP) {
2142 spin_unlock_irq(&phba->hbalock);
2145 spin_unlock_irq(&phba->hbalock);
2146 /* count may include a LF at end of string */
2147 if (buf[cnt-1] == '\n')
2150 if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) ||
2151 ((cnt == 17) && (*buf++ != 'x')) ||
2152 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
2155 phba->soft_wwn_enable = 0;
2157 memset(wwpn, 0, sizeof(wwpn));
2159 /* Validate and store the new name */
2160 for (i=0, j=0; i < 16; i++) {
2163 value = hex_to_bin(*buf++);
2165 j = (j << 4) | value;
2169 wwpn[i/2] = j & 0xff;
2173 phba->cfg_soft_wwpn = wwn_to_u64(wwpn);
2174 fc_host_port_name(shost) = phba->cfg_soft_wwpn;
2175 if (phba->cfg_soft_wwnn)
2176 fc_host_node_name(shost) = phba->cfg_soft_wwnn;
2178 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
2179 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no);
2181 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
2183 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2184 "0463 lpfc_soft_wwpn attribute set failed to "
2185 "reinit adapter - %d\n", stat1);
2186 init_completion(&online_compl);
2187 rc = lpfc_workq_post_event(phba, &stat2, &online_compl,
2192 wait_for_completion(&online_compl);
2194 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2195 "0464 lpfc_soft_wwpn attribute set failed to "
2196 "reinit adapter - %d\n", stat2);
2197 return (stat1 || stat2) ? -EIO : count;
2199 static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
2200 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store);
2203 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2204 * @dev: class device that is converted into a Scsi_host.
2205 * @attr: device attribute, not used.
2206 * @buf: on return contains the wwnn in hexadecimal.
2208 * Returns: size of formatted string.
2211 lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr,
2214 struct Scsi_Host *shost = class_to_shost(dev);
2215 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2216 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2217 (unsigned long long)phba->cfg_soft_wwnn);
2221 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2222 * @cdev: class device that is converted into a Scsi_host.
2223 * @buf: contains the ww node name in hexadecimal.
2224 * @count: number of wwnn bytes in buf.
2227 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2228 * value of count on success
2231 lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr,
2232 const char *buf, size_t count)
2234 struct Scsi_Host *shost = class_to_shost(dev);
2235 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2236 unsigned int i, j, cnt=count;
2239 /* count may include a LF at end of string */
2240 if (buf[cnt-1] == '\n')
2243 if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) ||
2244 ((cnt == 17) && (*buf++ != 'x')) ||
2245 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
2249 * Allow wwnn to be set many times, as long as the enable is set.
2250 * However, once the wwpn is set, everything locks.
2253 memset(wwnn, 0, sizeof(wwnn));
2255 /* Validate and store the new name */
2256 for (i=0, j=0; i < 16; i++) {
2259 value = hex_to_bin(*buf++);
2261 j = (j << 4) | value;
2265 wwnn[i/2] = j & 0xff;
2269 phba->cfg_soft_wwnn = wwn_to_u64(wwnn);
2271 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
2272 "lpfc%d: soft_wwnn set. Value will take effect upon "
2273 "setting of the soft_wwpn\n", phba->brd_no);
2277 static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\
2278 lpfc_soft_wwnn_show, lpfc_soft_wwnn_store);
2281 static int lpfc_poll = 0;
2282 module_param(lpfc_poll, int, S_IRUGO);
2283 MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
2285 " 1 - poll with interrupts enabled"
2286 " 3 - poll and disable FCP ring interrupts");
2288 static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
2289 lpfc_poll_show, lpfc_poll_store);
2291 int lpfc_sli_mode = 0;
2292 module_param(lpfc_sli_mode, int, S_IRUGO);
2293 MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:"
2294 " 0 - auto (SLI-3 if supported),"
2295 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
2296 " 3 - select SLI-3");
2298 int lpfc_enable_npiv = 1;
2299 module_param(lpfc_enable_npiv, int, S_IRUGO);
2300 MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality");
2301 lpfc_param_show(enable_npiv);
2302 lpfc_param_init(enable_npiv, 1, 0, 1);
2303 static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, lpfc_enable_npiv_show, NULL);
2305 LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2,
2306 "FCF Fast failover=1 Priority failover=2");
2308 int lpfc_enable_rrq = 2;
2309 module_param(lpfc_enable_rrq, int, S_IRUGO);
2310 MODULE_PARM_DESC(lpfc_enable_rrq, "Enable RRQ functionality");
2311 lpfc_param_show(enable_rrq);
2313 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
2314 # 0x0 = disabled, XRI/OXID use not tracked.
2315 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
2316 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
2318 lpfc_param_init(enable_rrq, 2, 0, 2);
2319 static DEVICE_ATTR(lpfc_enable_rrq, S_IRUGO, lpfc_enable_rrq_show, NULL);
2322 # lpfc_suppress_link_up: Bring link up at initialization
2323 # 0x0 = bring link up (issue MBX_INIT_LINK)
2324 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
2325 # 0x2 = never bring up link
2326 # Default value is 0.
2328 LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK,
2329 LPFC_DELAY_INIT_LINK_INDEFINITELY,
2330 "Suppress Link Up at initialization");
2332 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
2340 lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf)
2342 struct Scsi_Host *shost = class_to_shost(dev);
2343 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
2345 return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max);
2348 static DEVICE_ATTR(iocb_hw, S_IRUGO,
2349 lpfc_iocb_hw_show, NULL);
2351 lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf)
2353 struct Scsi_Host *shost = class_to_shost(dev);
2354 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
2356 return snprintf(buf, PAGE_SIZE, "%d\n",
2357 phba->sli.ring[LPFC_ELS_RING].txq_max);
2360 static DEVICE_ATTR(txq_hw, S_IRUGO,
2361 lpfc_txq_hw_show, NULL);
2363 lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr,
2366 struct Scsi_Host *shost = class_to_shost(dev);
2367 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
2369 return snprintf(buf, PAGE_SIZE, "%d\n",
2370 phba->sli.ring[LPFC_ELS_RING].txcmplq_max);
2373 static DEVICE_ATTR(txcmplq_hw, S_IRUGO,
2374 lpfc_txcmplq_hw_show, NULL);
2376 int lpfc_iocb_cnt = 2;
2377 module_param(lpfc_iocb_cnt, int, S_IRUGO);
2378 MODULE_PARM_DESC(lpfc_iocb_cnt,
2379 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
2380 lpfc_param_show(iocb_cnt);
2381 lpfc_param_init(iocb_cnt, 2, 1, 5);
2382 static DEVICE_ATTR(lpfc_iocb_cnt, S_IRUGO,
2383 lpfc_iocb_cnt_show, NULL);
2386 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
2387 # until the timer expires. Value range is [0,255]. Default value is 30.
2389 static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
2390 static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO;
2391 module_param(lpfc_nodev_tmo, int, 0);
2392 MODULE_PARM_DESC(lpfc_nodev_tmo,
2393 "Seconds driver will hold I/O waiting "
2394 "for a device to come back");
2397 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
2398 * @dev: class converted to a Scsi_host structure.
2399 * @attr: device attribute, not used.
2400 * @buf: on return contains the dev loss timeout in decimal.
2402 * Returns: size of formatted string.
2405 lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr,
2408 struct Scsi_Host *shost = class_to_shost(dev);
2409 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2411 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
2415 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
2416 * @vport: lpfc vport structure pointer.
2417 * @val: contains the nodev timeout value.
2420 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
2421 * a kernel error message is printed and zero is returned.
2422 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2423 * Otherwise nodev tmo is set to the default value.
2426 * zero if already set or if val is in range
2427 * -EINVAL val out of range
2430 lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
2432 if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) {
2433 vport->cfg_nodev_tmo = vport->cfg_devloss_tmo;
2434 if (val != LPFC_DEF_DEVLOSS_TMO)
2435 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2436 "0407 Ignoring nodev_tmo module "
2437 "parameter because devloss_tmo is "
2442 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
2443 vport->cfg_nodev_tmo = val;
2444 vport->cfg_devloss_tmo = val;
2447 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2448 "0400 lpfc_nodev_tmo attribute cannot be set to"
2449 " %d, allowed range is [%d, %d]\n",
2450 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
2451 vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
2456 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
2457 * @vport: lpfc vport structure pointer.
2460 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
2463 lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
2465 struct Scsi_Host *shost;
2466 struct lpfc_nodelist *ndlp;
2468 shost = lpfc_shost_from_vport(vport);
2469 spin_lock_irq(shost->host_lock);
2470 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
2471 if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport)
2472 ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo;
2473 spin_unlock_irq(shost->host_lock);
2477 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
2478 * @vport: lpfc vport structure pointer.
2479 * @val: contains the tmo value.
2482 * If the devloss tmo is already set or the vport dev loss tmo has changed
2483 * then a kernel error message is printed and zero is returned.
2484 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2485 * Otherwise nodev tmo is set to the default value.
2488 * zero if already set or if val is in range
2489 * -EINVAL val out of range
2492 lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
2494 if (vport->dev_loss_tmo_changed ||
2495 (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) {
2496 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2497 "0401 Ignoring change to nodev_tmo "
2498 "because devloss_tmo is set.\n");
2501 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
2502 vport->cfg_nodev_tmo = val;
2503 vport->cfg_devloss_tmo = val;
2505 * For compat: set the fc_host dev loss so new rports
2506 * will get the value.
2508 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val;
2509 lpfc_update_rport_devloss_tmo(vport);
2512 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2513 "0403 lpfc_nodev_tmo attribute cannot be set to"
2514 "%d, allowed range is [%d, %d]\n",
2515 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
2519 lpfc_vport_param_store(nodev_tmo)
2521 static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR,
2522 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store);
2525 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
2526 # disappear until the timer expires. Value range is [0,255]. Default
2529 module_param(lpfc_devloss_tmo, int, S_IRUGO);
2530 MODULE_PARM_DESC(lpfc_devloss_tmo,
2531 "Seconds driver will hold I/O waiting "
2532 "for a device to come back");
2533 lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO,
2534 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO)
2535 lpfc_vport_param_show(devloss_tmo)
2538 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
2539 * @vport: lpfc vport structure pointer.
2540 * @val: contains the tmo value.
2543 * If val is in a valid range then set the vport nodev tmo,
2544 * devloss tmo, also set the vport dev loss tmo changed flag.
2545 * Else a kernel error message is printed.
2548 * zero if val is in range
2549 * -EINVAL val out of range
2552 lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
2554 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
2555 vport->cfg_nodev_tmo = val;
2556 vport->cfg_devloss_tmo = val;
2557 vport->dev_loss_tmo_changed = 1;
2558 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val;
2559 lpfc_update_rport_devloss_tmo(vport);
2563 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2564 "0404 lpfc_devloss_tmo attribute cannot be set to"
2565 " %d, allowed range is [%d, %d]\n",
2566 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
2570 lpfc_vport_param_store(devloss_tmo)
2571 static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
2572 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store);
2575 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
2576 # deluged with LOTS of information.
2577 # You can set a bit mask to record specific types of verbose messages:
2578 # See lpfc_logmsh.h for definitions.
2580 LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff,
2581 "Verbose logging bit-mask");
2584 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
2585 # objects that have been registered with the nameserver after login.
2587 LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1,
2588 "Deregister nameserver objects before LOGO");
2591 # lun_queue_depth: This parameter is used to limit the number of outstanding
2592 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
2593 # If this parameter value is greater than 1/8th the maximum number of exchanges
2594 # supported by the HBA port, then the lun queue depth will be reduced to
2595 # 1/8th the maximum number of exchanges.
2597 LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512,
2598 "Max number of FCP commands we can queue to a specific LUN");
2601 # tgt_queue_depth: This parameter is used to limit the number of outstanding
2602 # commands per target port. Value range is [10,65535]. Default value is 65535.
2604 LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535,
2605 "Max number of FCP commands we can queue to a specific target port");
2608 # hba_queue_depth: This parameter is used to limit the number of outstanding
2609 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
2610 # value is greater than the maximum number of exchanges supported by the HBA,
2611 # then maximum number of exchanges supported by the HBA is used to determine
2612 # the hba_queue_depth.
2614 LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
2615 "Max number of FCP commands we can queue to a lpfc HBA");
2618 # peer_port_login: This parameter allows/prevents logins
2619 # between peer ports hosted on the same physical port.
2620 # When this parameter is set 0 peer ports of same physical port
2621 # are not allowed to login to each other.
2622 # When this parameter is set 1 peer ports of same physical port
2623 # are allowed to login to each other.
2624 # Default value of this parameter is 0.
2626 LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1,
2627 "Allow peer ports on the same physical port to login to each "
2631 # restrict_login: This parameter allows/prevents logins
2632 # between Virtual Ports and remote initiators.
2633 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
2634 # other initiators and will attempt to PLOGI all remote ports.
2635 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
2636 # remote ports and will not attempt to PLOGI to other initiators.
2637 # This parameter does not restrict to the physical port.
2638 # This parameter does not restrict logins to Fabric resident remote ports.
2639 # Default value of this parameter is 1.
2641 static int lpfc_restrict_login = 1;
2642 module_param(lpfc_restrict_login, int, S_IRUGO);
2643 MODULE_PARM_DESC(lpfc_restrict_login,
2644 "Restrict virtual ports login to remote initiators.");
2645 lpfc_vport_param_show(restrict_login);
2648 * lpfc_restrict_login_init - Set the vport restrict login flag
2649 * @vport: lpfc vport structure pointer.
2650 * @val: contains the restrict login value.
2653 * If val is not in a valid range then log a kernel error message and set
2654 * the vport restrict login to one.
2655 * If the port type is physical clear the restrict login flag and return.
2656 * Else set the restrict login flag to val.
2659 * zero if val is in range
2660 * -EINVAL val out of range
2663 lpfc_restrict_login_init(struct lpfc_vport *vport, int val)
2665 if (val < 0 || val > 1) {
2666 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2667 "0422 lpfc_restrict_login attribute cannot "
2668 "be set to %d, allowed range is [0, 1]\n",
2670 vport->cfg_restrict_login = 1;
2673 if (vport->port_type == LPFC_PHYSICAL_PORT) {
2674 vport->cfg_restrict_login = 0;
2677 vport->cfg_restrict_login = val;
2682 * lpfc_restrict_login_set - Set the vport restrict login flag
2683 * @vport: lpfc vport structure pointer.
2684 * @val: contains the restrict login value.
2687 * If val is not in a valid range then log a kernel error message and set
2688 * the vport restrict login to one.
2689 * If the port type is physical and the val is not zero log a kernel
2690 * error message, clear the restrict login flag and return zero.
2691 * Else set the restrict login flag to val.
2694 * zero if val is in range
2695 * -EINVAL val out of range
2698 lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
2700 if (val < 0 || val > 1) {
2701 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2702 "0425 lpfc_restrict_login attribute cannot "
2703 "be set to %d, allowed range is [0, 1]\n",
2705 vport->cfg_restrict_login = 1;
2708 if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) {
2709 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2710 "0468 lpfc_restrict_login must be 0 for "
2711 "Physical ports.\n");
2712 vport->cfg_restrict_login = 0;
2715 vport->cfg_restrict_login = val;
2718 lpfc_vport_param_store(restrict_login);
2719 static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR,
2720 lpfc_restrict_login_show, lpfc_restrict_login_store);
2723 # Some disk devices have a "select ID" or "select Target" capability.
2724 # From a protocol standpoint "select ID" usually means select the
2725 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
2726 # annex" which contains a table that maps a "select ID" (a number
2727 # between 0 and 7F) to an ALPA. By default, for compatibility with
2728 # older drivers, the lpfc driver scans this table from low ALPA to high
2731 # Turning on the scan-down variable (on = 1, off = 0) will
2732 # cause the lpfc driver to use an inverted table, effectively
2733 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
2735 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
2736 # and will not work across a fabric. Also this parameter will take
2737 # effect only in the case when ALPA map is not available.)
2739 LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1,
2740 "Start scanning for devices from highest ALPA to lowest");
2743 # lpfc_topology: link topology for init link
2744 # 0x0 = attempt loop mode then point-to-point
2745 # 0x01 = internal loopback mode
2746 # 0x02 = attempt point-to-point mode only
2747 # 0x04 = attempt loop mode only
2748 # 0x06 = attempt point-to-point mode then loop
2749 # Set point-to-point mode if you want to run as an N_Port.
2750 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
2751 # Default value is 0.
2755 * lpfc_topology_set - Set the adapters topology field
2756 * @phba: lpfc_hba pointer.
2757 * @val: topology value.
2760 * If val is in a valid range then set the adapter's topology field and
2761 * issue a lip; if the lip fails reset the topology to the old value.
2763 * If the value is not in range log a kernel error message and return an error.
2766 * zero if val is in range and lip okay
2767 * non-zero return value from lpfc_issue_lip()
2768 * -EINVAL val out of range
2771 lpfc_topology_store(struct device *dev, struct device_attribute *attr,
2772 const char *buf, size_t count)
2774 struct Scsi_Host *shost = class_to_shost(dev);
2775 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2776 struct lpfc_hba *phba = vport->phba;
2779 const char *val_buf = buf;
2783 if (!strncmp(buf, "nolip ", strlen("nolip "))) {
2785 val_buf = &buf[strlen("nolip ")];
2788 if (!isdigit(val_buf[0]))
2790 if (sscanf(val_buf, "%i", &val) != 1)
2793 if (val >= 0 && val <= 6) {
2794 prev_val = phba->cfg_topology;
2795 phba->cfg_topology = val;
2796 if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G &&
2798 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2799 "3113 Loop mode not supported at speed %d\n",
2800 phba->cfg_link_speed);
2801 phba->cfg_topology = prev_val;
2807 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2808 "3054 lpfc_topology changed from %d to %d\n",
2810 if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4)
2811 phba->fc_topology_changed = 1;
2812 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
2814 phba->cfg_topology = prev_val;
2819 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2820 "%d:0467 lpfc_topology attribute cannot be set to %d, "
2821 "allowed range is [0, 6]\n",
2825 static int lpfc_topology = 0;
2826 module_param(lpfc_topology, int, S_IRUGO);
2827 MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology");
2828 lpfc_param_show(topology)
2829 lpfc_param_init(topology, 0, 0, 6)
2830 static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR,
2831 lpfc_topology_show, lpfc_topology_store);
2834 * lpfc_static_vport_show: Read callback function for
2835 * lpfc_static_vport sysfs file.
2836 * @dev: Pointer to class device object.
2837 * @attr: device attribute structure.
2838 * @buf: Data buffer.
2840 * This function is the read call back function for
2841 * lpfc_static_vport sysfs file. The lpfc_static_vport
2842 * sysfs file report the mageability of the vport.
2845 lpfc_static_vport_show(struct device *dev, struct device_attribute *attr,
2848 struct Scsi_Host *shost = class_to_shost(dev);
2849 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2850 if (vport->vport_flag & STATIC_VPORT)
2851 sprintf(buf, "1\n");
2853 sprintf(buf, "0\n");
2859 * Sysfs attribute to control the statistical data collection.
2861 static DEVICE_ATTR(lpfc_static_vport, S_IRUGO,
2862 lpfc_static_vport_show, NULL);
2865 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
2866 * @dev: Pointer to class device.
2867 * @buf: Data buffer.
2868 * @count: Size of the data buffer.
2870 * This function get called when an user write to the lpfc_stat_data_ctrl
2871 * sysfs file. This function parse the command written to the sysfs file
2872 * and take appropriate action. These commands are used for controlling
2873 * driver statistical data collection.
2874 * Following are the command this function handles.
2876 * setbucket <bucket_type> <base> <step>
2877 * = Set the latency buckets.
2878 * destroybucket = destroy all the buckets.
2879 * start = start data collection
2880 * stop = stop data collection
2881 * reset = reset the collected data
2884 lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr,
2885 const char *buf, size_t count)
2887 struct Scsi_Host *shost = class_to_shost(dev);
2888 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2889 struct lpfc_hba *phba = vport->phba;
2890 #define LPFC_MAX_DATA_CTRL_LEN 1024
2891 static char bucket_data[LPFC_MAX_DATA_CTRL_LEN];
2893 char *str_ptr, *token;
2894 struct lpfc_vport **vports;
2895 struct Scsi_Host *v_shost;
2896 char *bucket_type_str, *base_str, *step_str;
2897 unsigned long base, step, bucket_type;
2899 if (!strncmp(buf, "setbucket", strlen("setbucket"))) {
2900 if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1))
2903 strcpy(bucket_data, buf);
2904 str_ptr = &bucket_data[0];
2905 /* Ignore this token - this is command token */
2906 token = strsep(&str_ptr, "\t ");
2910 bucket_type_str = strsep(&str_ptr, "\t ");
2911 if (!bucket_type_str)
2914 if (!strncmp(bucket_type_str, "linear", strlen("linear")))
2915 bucket_type = LPFC_LINEAR_BUCKET;
2916 else if (!strncmp(bucket_type_str, "power2", strlen("power2")))
2917 bucket_type = LPFC_POWER2_BUCKET;
2921 base_str = strsep(&str_ptr, "\t ");
2924 base = simple_strtoul(base_str, NULL, 0);
2926 step_str = strsep(&str_ptr, "\t ");
2929 step = simple_strtoul(step_str, NULL, 0);
2933 /* Block the data collection for every vport */
2934 vports = lpfc_create_vport_work_array(phba);
2938 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
2939 v_shost = lpfc_shost_from_vport(vports[i]);
2940 spin_lock_irq(v_shost->host_lock);
2941 /* Block and reset data collection */
2942 vports[i]->stat_data_blocked = 1;
2943 if (vports[i]->stat_data_enabled)
2944 lpfc_vport_reset_stat_data(vports[i]);
2945 spin_unlock_irq(v_shost->host_lock);
2948 /* Set the bucket attributes */
2949 phba->bucket_type = bucket_type;
2950 phba->bucket_base = base;
2951 phba->bucket_step = step;
2953 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
2954 v_shost = lpfc_shost_from_vport(vports[i]);
2956 /* Unblock data collection */
2957 spin_lock_irq(v_shost->host_lock);
2958 vports[i]->stat_data_blocked = 0;
2959 spin_unlock_irq(v_shost->host_lock);
2961 lpfc_destroy_vport_work_array(phba, vports);
2965 if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) {
2966 vports = lpfc_create_vport_work_array(phba);
2970 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
2971 v_shost = lpfc_shost_from_vport(vports[i]);
2972 spin_lock_irq(shost->host_lock);
2973 vports[i]->stat_data_blocked = 1;
2974 lpfc_free_bucket(vport);
2975 vport->stat_data_enabled = 0;
2976 vports[i]->stat_data_blocked = 0;
2977 spin_unlock_irq(shost->host_lock);
2979 lpfc_destroy_vport_work_array(phba, vports);
2980 phba->bucket_type = LPFC_NO_BUCKET;
2981 phba->bucket_base = 0;
2982 phba->bucket_step = 0;
2986 if (!strncmp(buf, "start", strlen("start"))) {
2987 /* If no buckets configured return error */
2988 if (phba->bucket_type == LPFC_NO_BUCKET)
2990 spin_lock_irq(shost->host_lock);
2991 if (vport->stat_data_enabled) {
2992 spin_unlock_irq(shost->host_lock);
2995 lpfc_alloc_bucket(vport);
2996 vport->stat_data_enabled = 1;
2997 spin_unlock_irq(shost->host_lock);
3001 if (!strncmp(buf, "stop", strlen("stop"))) {
3002 spin_lock_irq(shost->host_lock);
3003 if (vport->stat_data_enabled == 0) {
3004 spin_unlock_irq(shost->host_lock);
3007 lpfc_free_bucket(vport);
3008 vport->stat_data_enabled = 0;
3009 spin_unlock_irq(shost->host_lock);
3013 if (!strncmp(buf, "reset", strlen("reset"))) {
3014 if ((phba->bucket_type == LPFC_NO_BUCKET)
3015 || !vport->stat_data_enabled)
3017 spin_lock_irq(shost->host_lock);
3018 vport->stat_data_blocked = 1;
3019 lpfc_vport_reset_stat_data(vport);
3020 vport->stat_data_blocked = 0;
3021 spin_unlock_irq(shost->host_lock);
3029 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
3030 * @dev: Pointer to class device object.
3031 * @buf: Data buffer.
3033 * This function is the read call back function for
3034 * lpfc_stat_data_ctrl sysfs file. This function report the
3035 * current statistical data collection state.
3038 lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr,
3041 struct Scsi_Host *shost = class_to_shost(dev);
3042 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3043 struct lpfc_hba *phba = vport->phba;
3047 unsigned long bucket_value;
3049 switch (phba->bucket_type) {
3050 case LPFC_LINEAR_BUCKET:
3051 bucket_type = "linear";
3053 case LPFC_POWER2_BUCKET:
3054 bucket_type = "power2";
3057 bucket_type = "No Bucket";
3061 sprintf(&buf[index], "Statistical Data enabled :%d, "
3062 "blocked :%d, Bucket type :%s, Bucket base :%d,"
3063 " Bucket step :%d\nLatency Ranges :",
3064 vport->stat_data_enabled, vport->stat_data_blocked,
3065 bucket_type, phba->bucket_base, phba->bucket_step);
3066 index = strlen(buf);
3067 if (phba->bucket_type != LPFC_NO_BUCKET) {
3068 for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) {
3069 if (phba->bucket_type == LPFC_LINEAR_BUCKET)
3070 bucket_value = phba->bucket_base +
3071 phba->bucket_step * i;
3073 bucket_value = phba->bucket_base +
3074 (1 << i) * phba->bucket_step;
3076 if (index + 10 > PAGE_SIZE)
3078 sprintf(&buf[index], "%08ld ", bucket_value);
3079 index = strlen(buf);
3082 sprintf(&buf[index], "\n");
3087 * Sysfs attribute to control the statistical data collection.
3089 static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR,
3090 lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store);
3093 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
3097 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
3100 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
3101 #define MAX_STAT_DATA_SIZE_PER_TARGET \
3102 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
3106 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
3108 * @kobj: Pointer to the kernel object
3109 * @bin_attr: Attribute object
3110 * @buff: Buffer pointer
3112 * @count: Buffer size
3114 * This function is the read call back function for lpfc_drvr_stat_data
3115 * sysfs file. This function export the statistical data to user
3119 sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj,
3120 struct bin_attribute *bin_attr,
3121 char *buf, loff_t off, size_t count)
3123 struct device *dev = container_of(kobj, struct device,
3125 struct Scsi_Host *shost = class_to_shost(dev);
3126 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3127 struct lpfc_hba *phba = vport->phba;
3128 int i = 0, index = 0;
3129 unsigned long nport_index;
3130 struct lpfc_nodelist *ndlp = NULL;
3131 nport_index = (unsigned long)off /
3132 MAX_STAT_DATA_SIZE_PER_TARGET;
3134 if (!vport->stat_data_enabled || vport->stat_data_blocked
3135 || (phba->bucket_type == LPFC_NO_BUCKET))
3138 spin_lock_irq(shost->host_lock);
3139 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
3140 if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data)
3143 if (nport_index > 0) {
3148 if ((index + MAX_STAT_DATA_SIZE_PER_TARGET)
3152 if (!ndlp->lat_data)
3156 sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:",
3157 ndlp->nlp_portname.u.wwn[0],
3158 ndlp->nlp_portname.u.wwn[1],
3159 ndlp->nlp_portname.u.wwn[2],
3160 ndlp->nlp_portname.u.wwn[3],
3161 ndlp->nlp_portname.u.wwn[4],
3162 ndlp->nlp_portname.u.wwn[5],
3163 ndlp->nlp_portname.u.wwn[6],
3164 ndlp->nlp_portname.u.wwn[7]);
3166 index = strlen(buf);
3168 for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) {
3169 sprintf(&buf[index], "%010u,",
3170 ndlp->lat_data[i].cmd_count);
3171 index = strlen(buf);
3173 sprintf(&buf[index], "\n");
3174 index = strlen(buf);
3176 spin_unlock_irq(shost->host_lock);
3180 static struct bin_attribute sysfs_drvr_stat_data_attr = {
3182 .name = "lpfc_drvr_stat_data",
3185 .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET,
3186 .read = sysfs_drvr_stat_data_read,
3191 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
3193 # Value range is [0,16]. Default value is 0.
3196 * lpfc_link_speed_set - Set the adapters link speed
3197 * @phba: lpfc_hba pointer.
3198 * @val: link speed value.
3201 * If val is in a valid range then set the adapter's link speed field and
3202 * issue a lip; if the lip fails reset the link speed to the old value.
3205 * If the value is not in range log a kernel error message and return an error.
3208 * zero if val is in range and lip okay.
3209 * non-zero return value from lpfc_issue_lip()
3210 * -EINVAL val out of range
3213 lpfc_link_speed_store(struct device *dev, struct device_attribute *attr,
3214 const char *buf, size_t count)
3216 struct Scsi_Host *shost = class_to_shost(dev);
3217 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3218 struct lpfc_hba *phba = vport->phba;
3219 int val = LPFC_USER_LINK_SPEED_AUTO;
3221 const char *val_buf = buf;
3225 if (!strncmp(buf, "nolip ", strlen("nolip "))) {
3227 val_buf = &buf[strlen("nolip ")];
3230 if (!isdigit(val_buf[0]))
3232 if (sscanf(val_buf, "%i", &val) != 1)
3235 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3236 "3055 lpfc_link_speed changed from %d to %d %s\n",
3237 phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)");
3239 if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) ||
3240 ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) ||
3241 ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) ||
3242 ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) ||
3243 ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) ||
3244 ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb))) {
3245 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3246 "2879 lpfc_link_speed attribute cannot be set "
3247 "to %d. Speed is not supported by this port.\n",
3251 if (val == LPFC_USER_LINK_SPEED_16G &&
3252 phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
3253 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3254 "3112 lpfc_link_speed attribute cannot be set "
3255 "to %d. Speed is not supported in loop mode.\n",
3259 if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) &&
3260 (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) {
3261 prev_val = phba->cfg_link_speed;
3262 phba->cfg_link_speed = val;
3266 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
3268 phba->cfg_link_speed = prev_val;
3273 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3274 "0469 lpfc_link_speed attribute cannot be set to %d, "
3275 "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val);
3279 static int lpfc_link_speed = 0;
3280 module_param(lpfc_link_speed, int, S_IRUGO);
3281 MODULE_PARM_DESC(lpfc_link_speed, "Select link speed");
3282 lpfc_param_show(link_speed)
3285 * lpfc_link_speed_init - Set the adapters link speed
3286 * @phba: lpfc_hba pointer.
3287 * @val: link speed value.
3290 * If val is in a valid range then set the adapter's link speed field.
3293 * If the value is not in range log a kernel error message, clear the link
3294 * speed and return an error.
3297 * zero if val saved.
3298 * -EINVAL val out of range
3301 lpfc_link_speed_init(struct lpfc_hba *phba, int val)
3303 if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) {
3304 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3305 "3111 lpfc_link_speed of %d cannot "
3306 "support loop mode, setting topology to default.\n",
3308 phba->cfg_topology = 0;
3310 if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) &&
3311 (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) {
3312 phba->cfg_link_speed = val;
3315 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3316 "0405 lpfc_link_speed attribute cannot "
3317 "be set to %d, allowed values are "
3318 "["LPFC_LINK_SPEED_STRING"]\n", val);
3319 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO;
3323 static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR,
3324 lpfc_link_speed_show, lpfc_link_speed_store);
3327 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
3328 # 0 = aer disabled or not supported
3329 # 1 = aer supported and enabled (default)
3330 # Value range is [0,1]. Default value is 1.
3334 * lpfc_aer_support_store - Set the adapter for aer support
3336 * @dev: class device that is converted into a Scsi_host.
3337 * @attr: device attribute, not used.
3338 * @buf: containing enable or disable aer flag.
3339 * @count: unused variable.
3342 * If the val is 1 and currently the device's AER capability was not
3343 * enabled, invoke the kernel's enable AER helper routine, trying to
3344 * enable the device's AER capability. If the helper routine enabling
3345 * AER returns success, update the device's cfg_aer_support flag to
3346 * indicate AER is supported by the device; otherwise, if the device
3347 * AER capability is already enabled to support AER, then do nothing.
3349 * If the val is 0 and currently the device's AER support was enabled,
3350 * invoke the kernel's disable AER helper routine. After that, update
3351 * the device's cfg_aer_support flag to indicate AER is not supported
3352 * by the device; otherwise, if the device AER capability is already
3353 * disabled from supporting AER, then do nothing.
3356 * length of the buf on success if val is in range the intended mode
3358 * -EINVAL if val out of range or intended mode is not supported.
3361 lpfc_aer_support_store(struct device *dev, struct device_attribute *attr,
3362 const char *buf, size_t count)
3364 struct Scsi_Host *shost = class_to_shost(dev);
3365 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
3366 struct lpfc_hba *phba = vport->phba;
3367 int val = 0, rc = -EINVAL;
3369 if (!isdigit(buf[0]))
3371 if (sscanf(buf, "%i", &val) != 1)
3376 if (phba->hba_flag & HBA_AER_ENABLED) {
3377 rc = pci_disable_pcie_error_reporting(phba->pcidev);
3379 spin_lock_irq(&phba->hbalock);
3380 phba->hba_flag &= ~HBA_AER_ENABLED;
3381 spin_unlock_irq(&phba->hbalock);
3382 phba->cfg_aer_support = 0;
3387 phba->cfg_aer_support = 0;
3392 if (!(phba->hba_flag & HBA_AER_ENABLED)) {
3393 rc = pci_enable_pcie_error_reporting(phba->pcidev);
3395 spin_lock_irq(&phba->hbalock);
3396 phba->hba_flag |= HBA_AER_ENABLED;
3397 spin_unlock_irq(&phba->hbalock);
3398 phba->cfg_aer_support = 1;
3403 phba->cfg_aer_support = 1;
3414 static int lpfc_aer_support = 1;
3415 module_param(lpfc_aer_support, int, S_IRUGO);
3416 MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support");
3417 lpfc_param_show(aer_support)
3420 * lpfc_aer_support_init - Set the initial adapters aer support flag
3421 * @phba: lpfc_hba pointer.
3422 * @val: enable aer or disable aer flag.
3425 * If val is in a valid range [0,1], then set the adapter's initial
3426 * cfg_aer_support field. It will be up to the driver's probe_one
3427 * routine to determine whether the device's AER support can be set
3431 * If the value is not in range log a kernel error message, and
3432 * choose the default value of setting AER support and return.
3435 * zero if val saved.
3436 * -EINVAL val out of range
3439 lpfc_aer_support_init(struct lpfc_hba *phba, int val)
3441 if (val == 0 || val == 1) {
3442 phba->cfg_aer_support = val;
3445 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3446 "2712 lpfc_aer_support attribute value %d out "
3447 "of range, allowed values are 0|1, setting it "
3448 "to default value of 1\n", val);
3449 /* By default, try to enable AER on a device */
3450 phba->cfg_aer_support = 1;
3454 static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR,
3455 lpfc_aer_support_show, lpfc_aer_support_store);
3458 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
3459 * @dev: class device that is converted into a Scsi_host.
3460 * @attr: device attribute, not used.
3461 * @buf: containing flag 1 for aer cleanup state.
3462 * @count: unused variable.
3465 * If the @buf contains 1 and the device currently has the AER support
3466 * enabled, then invokes the kernel AER helper routine
3467 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
3468 * error status register.
3473 * -EINVAL if the buf does not contain the 1 or the device is not currently
3474 * enabled with the AER support.
3477 lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr,
3478 const char *buf, size_t count)
3480 struct Scsi_Host *shost = class_to_shost(dev);
3481 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3482 struct lpfc_hba *phba = vport->phba;
3485 if (!isdigit(buf[0]))
3487 if (sscanf(buf, "%i", &val) != 1)
3492 if (phba->hba_flag & HBA_AER_ENABLED)
3493 rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev);
3501 static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL,
3502 lpfc_aer_cleanup_state);
3505 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
3507 * @dev: class device that is converted into a Scsi_host.
3508 * @attr: device attribute, not used.
3509 * @buf: containing the string the number of vfs to be enabled.
3510 * @count: unused variable.
3513 * When this api is called either through user sysfs, the driver shall
3514 * try to enable or disable SR-IOV virtual functions according to the
3517 * If zero virtual function has been enabled to the physical function,
3518 * the driver shall invoke the pci enable virtual function api trying
3519 * to enable the virtual functions. If the nr_vfn provided is greater
3520 * than the maximum supported, the maximum virtual function number will
3521 * be used for invoking the api; otherwise, the nr_vfn provided shall
3522 * be used for invoking the api. If the api call returned success, the
3523 * actual number of virtual functions enabled will be set to the driver
3524 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
3525 * cfg_sriov_nr_virtfn remains zero.
3527 * If none-zero virtual functions have already been enabled to the
3528 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
3529 * -EINVAL will be returned and the driver does nothing;
3531 * If the nr_vfn provided is zero and none-zero virtual functions have
3532 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
3533 * disabling virtual function api shall be invoded to disable all the
3534 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
3535 * zero. Otherwise, if zero virtual function has been enabled, do
3539 * length of the buf on success if val is in range the intended mode
3541 * -EINVAL if val out of range or intended mode is not supported.
3544 lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr,
3545 const char *buf, size_t count)
3547 struct Scsi_Host *shost = class_to_shost(dev);
3548 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
3549 struct lpfc_hba *phba = vport->phba;
3550 struct pci_dev *pdev = phba->pcidev;
3551 int val = 0, rc = -EINVAL;
3553 /* Sanity check on user data */
3554 if (!isdigit(buf[0]))
3556 if (sscanf(buf, "%i", &val) != 1)
3561 /* Request disabling virtual functions */
3563 if (phba->cfg_sriov_nr_virtfn > 0) {
3564 pci_disable_sriov(pdev);
3565 phba->cfg_sriov_nr_virtfn = 0;
3570 /* Request enabling virtual functions */
3571 if (phba->cfg_sriov_nr_virtfn > 0) {
3572 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3573 "3018 There are %d virtual functions "
3574 "enabled on physical function.\n",
3575 phba->cfg_sriov_nr_virtfn);
3579 if (val <= LPFC_MAX_VFN_PER_PFN)
3580 phba->cfg_sriov_nr_virtfn = val;
3582 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3583 "3019 Enabling %d virtual functions is not "
3588 rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn);
3590 phba->cfg_sriov_nr_virtfn = 0;
3598 static int lpfc_sriov_nr_virtfn = LPFC_DEF_VFN_PER_PFN;
3599 module_param(lpfc_sriov_nr_virtfn, int, S_IRUGO|S_IWUSR);
3600 MODULE_PARM_DESC(lpfc_sriov_nr_virtfn, "Enable PCIe device SR-IOV virtual fn");
3601 lpfc_param_show(sriov_nr_virtfn)
3604 * lpfc_sriov_nr_virtfn_init - Set the initial sr-iov virtual function enable
3605 * @phba: lpfc_hba pointer.
3606 * @val: link speed value.
3609 * If val is in a valid range [0,255], then set the adapter's initial
3610 * cfg_sriov_nr_virtfn field. If it's greater than the maximum, the maximum
3611 * number shall be used instead. It will be up to the driver's probe_one
3612 * routine to determine whether the device's SR-IOV is supported or not.
3615 * zero if val saved.
3616 * -EINVAL val out of range
3619 lpfc_sriov_nr_virtfn_init(struct lpfc_hba *phba, int val)
3621 if (val >= 0 && val <= LPFC_MAX_VFN_PER_PFN) {
3622 phba->cfg_sriov_nr_virtfn = val;
3626 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3627 "3017 Enabling %d virtual functions is not "
3631 static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR,
3632 lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store);
3635 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
3637 * @dev: class device that is converted into a Scsi_host.
3638 * @attr: device attribute, not used.
3639 * @buf: containing the string the number of vfs to be enabled.
3640 * @count: unused variable.
3645 * length of the buf on success if val is in range the intended mode
3647 * -EINVAL if val out of range or intended mode is not supported.
3650 lpfc_request_firmware_upgrade_store(struct device *dev,
3651 struct device_attribute *attr,
3652 const char *buf, size_t count)
3654 struct Scsi_Host *shost = class_to_shost(dev);
3655 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
3656 struct lpfc_hba *phba = vport->phba;
3657 int val = 0, rc = -EINVAL;
3659 /* Sanity check on user data */
3660 if (!isdigit(buf[0]))
3662 if (sscanf(buf, "%i", &val) != 1)
3667 rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE);
3675 static int lpfc_req_fw_upgrade;
3676 module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR);
3677 MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade");
3678 lpfc_param_show(request_firmware_upgrade)
3681 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
3682 * @phba: lpfc_hba pointer.
3686 * Set the initial Linux generic firmware upgrade enable or disable flag.
3689 * zero if val saved.
3690 * -EINVAL val out of range
3693 lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val)
3695 if (val >= 0 && val <= 1) {
3696 phba->cfg_request_firmware_upgrade = val;
3701 static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR,
3702 lpfc_request_firmware_upgrade_show,
3703 lpfc_request_firmware_upgrade_store);
3706 * lpfc_fcp_imax_store
3708 * @dev: class device that is converted into a Scsi_host.
3709 * @attr: device attribute, not used.
3710 * @buf: string with the number of fast-path FCP interrupts per second.
3711 * @count: unused variable.
3714 * If val is in a valid range [636,651042], then set the adapter's
3715 * maximum number of fast-path FCP interrupts per second.
3718 * length of the buf on success if val is in range the intended mode
3720 * -EINVAL if val out of range or intended mode is not supported.
3723 lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr,
3724 const char *buf, size_t count)
3726 struct Scsi_Host *shost = class_to_shost(dev);
3727 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
3728 struct lpfc_hba *phba = vport->phba;
3731 /* fcp_imax is only valid for SLI4 */
3732 if (phba->sli_rev != LPFC_SLI_REV4)
3735 /* Sanity check on user data */
3736 if (!isdigit(buf[0]))
3738 if (sscanf(buf, "%i", &val) != 1)
3742 * Value range for the HBA is [5000,5000000]
3743 * The value for each EQ depends on how many EQs are configured.
3745 if (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)
3748 phba->cfg_fcp_imax = (uint32_t)val;
3749 for (i = 0; i < phba->cfg_fcp_io_channel; i += LPFC_MAX_EQ_DELAY)
3750 lpfc_modify_fcp_eq_delay(phba, i);
3756 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
3759 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
3761 static int lpfc_fcp_imax = LPFC_DEF_IMAX;
3762 module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR);
3763 MODULE_PARM_DESC(lpfc_fcp_imax,
3764 "Set the maximum number of FCP interrupts per second per HBA");
3765 lpfc_param_show(fcp_imax)
3768 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
3769 * @phba: lpfc_hba pointer.
3770 * @val: link speed value.
3773 * If val is in a valid range [636,651042], then initialize the adapter's
3774 * maximum number of fast-path FCP interrupts per second.
3777 * zero if val saved.
3778 * -EINVAL val out of range
3781 lpfc_fcp_imax_init(struct lpfc_hba *phba, int val)
3783 if (phba->sli_rev != LPFC_SLI_REV4) {
3784 phba->cfg_fcp_imax = 0;
3788 if (val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) {
3789 phba->cfg_fcp_imax = val;
3793 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3794 "3016 fcp_imax: %d out of range, using default\n", val);
3795 phba->cfg_fcp_imax = LPFC_DEF_IMAX;
3800 static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR,
3801 lpfc_fcp_imax_show, lpfc_fcp_imax_store);
3804 * lpfc_state_show - Display current driver CPU affinity
3805 * @dev: class converted to a Scsi_host structure.
3806 * @attr: device attribute, not used.
3807 * @buf: on return contains text describing the state of the link.
3809 * Returns: size of formatted string.
3812 lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr,
3815 struct Scsi_Host *shost = class_to_shost(dev);
3816 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
3817 struct lpfc_hba *phba = vport->phba;
3818 struct lpfc_vector_map_info *cpup;
3821 if ((phba->sli_rev != LPFC_SLI_REV4) ||
3822 (phba->intr_type != MSIX))
3825 switch (phba->cfg_fcp_cpu_map) {
3827 len += snprintf(buf + len, PAGE_SIZE-len,
3828 "fcp_cpu_map: No mapping (%d)\n",
3829 phba->cfg_fcp_cpu_map);
3832 len += snprintf(buf + len, PAGE_SIZE-len,
3833 "fcp_cpu_map: HBA centric mapping (%d): "
3835 phba->cfg_fcp_cpu_map,
3836 phba->sli4_hba.num_online_cpu);
3839 len += snprintf(buf + len, PAGE_SIZE-len,
3840 "fcp_cpu_map: Driver centric mapping (%d): "
3842 phba->cfg_fcp_cpu_map,
3843 phba->sli4_hba.num_online_cpu);
3847 cpup = phba->sli4_hba.cpu_map;
3848 for (idx = 0; idx < phba->sli4_hba.num_present_cpu; idx++) {
3849 if (cpup->irq == LPFC_VECTOR_MAP_EMPTY)
3850 len += snprintf(buf + len, PAGE_SIZE-len,
3851 "CPU %02d io_chan %02d "
3852 "physid %d coreid %d\n",
3853 idx, cpup->channel_id, cpup->phys_id,
3856 len += snprintf(buf + len, PAGE_SIZE-len,
3857 "CPU %02d io_chan %02d "
3858 "physid %d coreid %d IRQ %d\n",
3859 idx, cpup->channel_id, cpup->phys_id,
3860 cpup->core_id, cpup->irq);
3868 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
3869 * @dev: class device that is converted into a Scsi_host.
3870 * @attr: device attribute, not used.
3871 * @buf: one or more lpfc_polling_flags values.
3875 * -EINVAL - Not implemented yet.
3878 lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr,
3879 const char *buf, size_t count)
3881 int status = -EINVAL;
3886 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
3889 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
3890 # 0 - Do not affinitze IRQ vectors
3891 # 1 - Affintize HBA vectors with respect to each HBA
3892 # (start with CPU0 for each HBA)
3893 # 2 - Affintize HBA vectors with respect to the entire driver
3894 # (round robin thru all CPUs across all HBAs)
3896 static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP;
3897 module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR);
3898 MODULE_PARM_DESC(lpfc_fcp_cpu_map,
3899 "Defines how to map CPUs to IRQ vectors per HBA");
3902 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
3903 * @phba: lpfc_hba pointer.
3904 * @val: link speed value.
3907 * If val is in a valid range [0-2], then affinitze the adapter's
3911 * zero if val saved.
3912 * -EINVAL val out of range
3915 lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val)
3917 if (phba->sli_rev != LPFC_SLI_REV4) {
3918 phba->cfg_fcp_cpu_map = 0;
3922 if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) {
3923 phba->cfg_fcp_cpu_map = val;
3927 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3928 "3326 fcp_cpu_map: %d out of range, using default\n",
3930 phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP;
3935 static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR,
3936 lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store);
3939 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
3940 # Value range is [2,3]. Default value is 3.
3942 LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
3943 "Select Fibre Channel class of service for FCP sequences");
3946 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
3947 # is [0,1]. Default value is 0.
3949 LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
3950 "Use ADISC on rediscovery to authenticate FCP devices");
3953 # lpfc_first_burst_size: First burst size to use on the NPorts
3954 # that support first burst.
3955 # Value range is [0,65536]. Default value is 0.
3957 LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536,
3958 "First burst size for Targets that support first burst");
3961 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
3962 # depth. Default value is 0. When the value of this parameter is zero the
3963 # SCSI command completion time is not used for controlling I/O queue depth. When
3964 # the parameter is set to a non-zero value, the I/O queue depth is controlled
3965 # to limit the I/O completion time to the parameter value.
3966 # The value is set in milliseconds.
3968 static int lpfc_max_scsicmpl_time;
3969 module_param(lpfc_max_scsicmpl_time, int, S_IRUGO);
3970 MODULE_PARM_DESC(lpfc_max_scsicmpl_time,
3971 "Use command completion time to control queue depth");
3972 lpfc_vport_param_show(max_scsicmpl_time);
3973 lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000);
3975 lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val)
3977 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3978 struct lpfc_nodelist *ndlp, *next_ndlp;
3980 if (val == vport->cfg_max_scsicmpl_time)
3982 if ((val < 0) || (val > 60000))
3984 vport->cfg_max_scsicmpl_time = val;
3986 spin_lock_irq(shost->host_lock);
3987 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
3988 if (!NLP_CHK_NODE_ACT(ndlp))
3990 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
3992 ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth;
3994 spin_unlock_irq(shost->host_lock);
3997 lpfc_vport_param_store(max_scsicmpl_time);
3998 static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR,
3999 lpfc_max_scsicmpl_time_show,
4000 lpfc_max_scsicmpl_time_store);
4003 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
4004 # range is [0,1]. Default value is 0.
4006 LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");
4009 # lpfc_fcp_io_sched: Determine scheduling algrithmn for issuing FCP cmds
4010 # range is [0,1]. Default value is 0.
4011 # For [0], FCP commands are issued to Work Queues ina round robin fashion.
4012 # For [1], FCP commands are issued to a Work Queue associated with the
4015 LPFC_ATTR_RW(fcp_io_sched, 0, 0, 1, "Determine scheduling algrithmn for "
4016 "issuing commands [0] - Round Robin, [1] - Current CPU");
4019 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
4020 # range is [0,1]. Default value is 0.
4021 # For [0], bus reset issues target reset to ALL devices
4022 # For [1], bus reset issues target reset to non-FCP2 devices
4024 LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for "
4025 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
4029 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
4030 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
4031 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
4032 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
4033 # cr_delay is set to 0.
4035 LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an "
4036 "interrupt response is generated");
4038 LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an "
4039 "interrupt response is generated");
4042 # lpfc_multi_ring_support: Determines how many rings to spread available
4043 # cmd/rsp IOCB entries across.
4044 # Value range is [1,2]. Default value is 1.
4046 LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
4047 "SLI rings to spread IOCB entries across");
4050 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
4051 # identifies what rctl value to configure the additional ring for.
4052 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
4054 LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1,
4055 255, "Identifies RCTL for additional ring configuration");
4058 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
4059 # identifies what type value to configure the additional ring for.
4060 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
4062 LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1,
4063 255, "Identifies TYPE for additional ring configuration");
4066 # lpfc_fdmi_on: controls FDMI support.
4067 # 0 = no FDMI support
4068 # 1 = support FDMI without attribute of hostname
4069 # 2 = support FDMI with attribute of hostname
4070 # Value range [0,2]. Default value is 0.
4072 LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support");
4075 # Specifies the maximum number of ELS cmds we can have outstanding (for
4076 # discovery). Value range is [1,64]. Default value = 32.
4078 LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
4079 "during discovery");
4082 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
4083 # will be scanned by the SCSI midlayer when sequential scanning is
4084 # used; and is also the highest LUN ID allowed when the SCSI midlayer
4085 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
4086 # LUN ID limit, but the SCSI midlayer requires this field for the uses
4087 # above. The lpfc driver limits the default value to 255 for two reasons.
4088 # As it bounds the sequential scan loop, scanning for thousands of luns
4089 # on a target can take minutes of wall clock time. Additionally,
4090 # there are FC targets, such as JBODs, that only recognize 8-bits of
4091 # LUN ID. When they receive a value greater than 8 bits, they chop off
4092 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
4093 # and so on all as LUN ID 0. This causes the linux kernel, which sees
4094 # valid responses at each of the LUN IDs, to believe there are multiple
4095 # devices present, when in fact, there is only 1.
4096 # A customer that is aware of their target behaviors, and the results as
4097 # indicated above, is welcome to increase the lpfc_max_luns value.
4098 # As mentioned, this value is not used by the lpfc driver, only the
4100 # Value range is [0,65535]. Default value is 255.
4101 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
4103 LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID");
4106 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
4107 # Value range is [1,255], default value is 10.
4109 LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
4110 "Milliseconds driver will wait between polling FCP ring");
4113 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
4114 # support this feature
4117 # 2 = MSI-X enabled (default)
4118 # Value range is [0,2]. Default value is 2.
4120 LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
4121 "MSI-X (2), if possible");
4124 # lpfc_fcp_wq_count: Set the number of fast-path FCP work queues
4125 # This parameter is ignored and will eventually be depricated
4127 # Value range is [1,7]. Default value is 4.
4129 LPFC_ATTR_R(fcp_wq_count, LPFC_FCP_IO_CHAN_DEF, LPFC_FCP_IO_CHAN_MIN,
4130 LPFC_FCP_IO_CHAN_MAX,
4131 "Set the number of fast-path FCP work queues, if possible");
4134 # lpfc_fcp_eq_count: Set the number of FCP EQ/CQ/WQ IO channels
4136 # Value range is [1,7]. Default value is 4.
4138 LPFC_ATTR_R(fcp_eq_count, LPFC_FCP_IO_CHAN_DEF, LPFC_FCP_IO_CHAN_MIN,
4139 LPFC_FCP_IO_CHAN_MAX,
4140 "Set the number of fast-path FCP event queues, if possible");
4143 # lpfc_fcp_io_channel: Set the number of FCP EQ/CQ/WQ IO channels
4145 # Value range is [1,7]. Default value is 4.
4147 LPFC_ATTR_R(fcp_io_channel, LPFC_FCP_IO_CHAN_DEF, LPFC_FCP_IO_CHAN_MIN,
4148 LPFC_FCP_IO_CHAN_MAX,
4149 "Set the number of FCP I/O channels");
4152 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
4153 # 0 = HBA resets disabled
4154 # 1 = HBA resets enabled (default)
4155 # Value range is [0,1]. Default value is 1.
4157 LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver.");
4160 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
4161 # 0 = HBA Heartbeat disabled
4162 # 1 = HBA Heartbeat enabled (default)
4163 # Value range is [0,1]. Default value is 1.
4165 LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat.");
4168 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
4169 # 0 = BlockGuard disabled (default)
4170 # 1 = BlockGuard enabled
4171 # Value range is [0,1]. Default value is 0.
4173 LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
4176 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
4177 # 0 = disabled (default)
4179 # Value range is [0,1]. Default value is 0.
4181 # This feature in under investigation and may be supported in the future.
4183 unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF;
4187 # - Bit mask of host protection capabilities used to register with the
4189 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
4190 # - Allows you to ultimately specify which profiles to use
4191 # - Default will result in registering capabilities for all profiles.
4192 # - SHOST_DIF_TYPE1_PROTECTION 1
4193 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
4194 # - SHOST_DIX_TYPE0_PROTECTION 8
4195 # HBA supports DIX Type 0: Host to HBA protection only
4196 # - SHOST_DIX_TYPE1_PROTECTION 16
4197 # HBA supports DIX Type 1: Host to HBA Type 1 protection
4200 unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION |
4201 SHOST_DIX_TYPE0_PROTECTION |
4202 SHOST_DIX_TYPE1_PROTECTION;
4204 module_param(lpfc_prot_mask, uint, S_IRUGO);
4205 MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask");
4208 # lpfc_prot_guard: i
4209 # - Bit mask of protection guard types to register with the SCSI mid-layer
4210 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
4211 # - Allows you to ultimately specify which profiles to use
4212 # - Default will result in registering capabilities for all guard types
4215 unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP;
4216 module_param(lpfc_prot_guard, byte, S_IRUGO);
4217 MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type");
4220 * Delay initial NPort discovery when Clean Address bit is cleared in
4221 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
4222 * This parameter can have value 0 or 1.
4223 * When this parameter is set to 0, no delay is added to the initial
4225 * When this parameter is set to non-zero value, initial Nport discovery is
4226 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
4227 * accept and FCID/Fabric name/Fabric portname is changed.
4228 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
4229 * when Clean Address bit is cleared in FLOGI/FDISC
4230 * accept and FCID/Fabric name/Fabric portname is changed.
4231 * Default value is 0.
4233 int lpfc_delay_discovery;
4234 module_param(lpfc_delay_discovery, int, S_IRUGO);
4235 MODULE_PARM_DESC(lpfc_delay_discovery,
4236 "Delay NPort discovery when Clean Address bit is cleared. "
4237 "Allowed values: 0,1.");
4240 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
4241 * This value can be set to values between 64 and 4096. The default value is
4242 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
4243 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
4244 * Because of the additional overhead involved in setting up T10-DIF,
4245 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
4246 * and will be limited to 512 if BlockGuard is enabled under SLI3.
4248 LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
4249 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
4252 * This parameter will be depricated, the driver cannot limit the
4253 * protection data s/g list.
4255 LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT,
4256 LPFC_DEFAULT_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT,
4257 "Max Protection Scatter Gather Segment Count");
4259 struct device_attribute *lpfc_hba_attrs[] = {
4261 &dev_attr_bg_guard_err,
4262 &dev_attr_bg_apptag_err,
4263 &dev_attr_bg_reftag_err,
4265 &dev_attr_serialnum,
4266 &dev_attr_modeldesc,
4267 &dev_attr_modelname,
4268 &dev_attr_programtype,
4272 &dev_attr_option_rom_version,
4273 &dev_attr_link_state,
4274 &dev_attr_num_discovered_ports,
4275 &dev_attr_menlo_mgmt_mode,
4276 &dev_attr_lpfc_drvr_version,
4277 &dev_attr_lpfc_enable_fip,
4278 &dev_attr_lpfc_temp_sensor,
4279 &dev_attr_lpfc_log_verbose,
4280 &dev_attr_lpfc_lun_queue_depth,
4281 &dev_attr_lpfc_tgt_queue_depth,
4282 &dev_attr_lpfc_hba_queue_depth,
4283 &dev_attr_lpfc_peer_port_login,
4284 &dev_attr_lpfc_nodev_tmo,
4285 &dev_attr_lpfc_devloss_tmo,
4286 &dev_attr_lpfc_fcp_class,
4287 &dev_attr_lpfc_use_adisc,
4288 &dev_attr_lpfc_first_burst_size,
4289 &dev_attr_lpfc_ack0,
4290 &dev_attr_lpfc_topology,
4291 &dev_attr_lpfc_scan_down,
4292 &dev_attr_lpfc_link_speed,
4293 &dev_attr_lpfc_fcp_io_sched,
4294 &dev_attr_lpfc_fcp2_no_tgt_reset,
4295 &dev_attr_lpfc_cr_delay,
4296 &dev_attr_lpfc_cr_count,
4297 &dev_attr_lpfc_multi_ring_support,
4298 &dev_attr_lpfc_multi_ring_rctl,
4299 &dev_attr_lpfc_multi_ring_type,
4300 &dev_attr_lpfc_fdmi_on,
4301 &dev_attr_lpfc_max_luns,
4302 &dev_attr_lpfc_enable_npiv,
4303 &dev_attr_lpfc_fcf_failover_policy,
4304 &dev_attr_lpfc_enable_rrq,
4305 &dev_attr_nport_evt_cnt,
4306 &dev_attr_board_mode,
4313 &dev_attr_npiv_info,
4314 &dev_attr_issue_reset,
4315 &dev_attr_lpfc_poll,
4316 &dev_attr_lpfc_poll_tmo,
4317 &dev_attr_lpfc_use_msi,
4318 &dev_attr_lpfc_fcp_imax,
4319 &dev_attr_lpfc_fcp_cpu_map,
4320 &dev_attr_lpfc_fcp_wq_count,
4321 &dev_attr_lpfc_fcp_eq_count,
4322 &dev_attr_lpfc_fcp_io_channel,
4323 &dev_attr_lpfc_enable_bg,
4324 &dev_attr_lpfc_soft_wwnn,
4325 &dev_attr_lpfc_soft_wwpn,
4326 &dev_attr_lpfc_soft_wwn_enable,
4327 &dev_attr_lpfc_enable_hba_reset,
4328 &dev_attr_lpfc_enable_hba_heartbeat,
4329 &dev_attr_lpfc_sg_seg_cnt,
4330 &dev_attr_lpfc_max_scsicmpl_time,
4331 &dev_attr_lpfc_stat_data_ctrl,
4332 &dev_attr_lpfc_prot_sg_seg_cnt,
4333 &dev_attr_lpfc_aer_support,
4334 &dev_attr_lpfc_aer_state_cleanup,
4335 &dev_attr_lpfc_sriov_nr_virtfn,
4336 &dev_attr_lpfc_req_fw_upgrade,
4337 &dev_attr_lpfc_suppress_link_up,
4338 &dev_attr_lpfc_iocb_cnt,
4341 &dev_attr_txcmplq_hw,
4342 &dev_attr_lpfc_fips_level,
4343 &dev_attr_lpfc_fips_rev,
4345 &dev_attr_lpfc_sriov_hw_max_virtfn,
4350 struct device_attribute *lpfc_vport_attrs[] = {
4352 &dev_attr_link_state,
4353 &dev_attr_num_discovered_ports,
4354 &dev_attr_lpfc_drvr_version,
4355 &dev_attr_lpfc_log_verbose,
4356 &dev_attr_lpfc_lun_queue_depth,
4357 &dev_attr_lpfc_tgt_queue_depth,
4358 &dev_attr_lpfc_nodev_tmo,
4359 &dev_attr_lpfc_devloss_tmo,
4360 &dev_attr_lpfc_hba_queue_depth,
4361 &dev_attr_lpfc_peer_port_login,
4362 &dev_attr_lpfc_restrict_login,
4363 &dev_attr_lpfc_fcp_class,
4364 &dev_attr_lpfc_use_adisc,
4365 &dev_attr_lpfc_first_burst_size,
4366 &dev_attr_lpfc_fdmi_on,
4367 &dev_attr_lpfc_max_luns,
4368 &dev_attr_nport_evt_cnt,
4369 &dev_attr_npiv_info,
4370 &dev_attr_lpfc_enable_da_id,
4371 &dev_attr_lpfc_max_scsicmpl_time,
4372 &dev_attr_lpfc_stat_data_ctrl,
4373 &dev_attr_lpfc_static_vport,
4374 &dev_attr_lpfc_fips_level,
4375 &dev_attr_lpfc_fips_rev,
4380 * sysfs_ctlreg_write - Write method for writing to ctlreg
4381 * @filp: open sysfs file
4382 * @kobj: kernel kobject that contains the kernel class device.
4383 * @bin_attr: kernel attributes passed to us.
4384 * @buf: contains the data to be written to the adapter IOREG space.
4385 * @off: offset into buffer to beginning of data.
4386 * @count: bytes to transfer.
4389 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
4390 * Uses the adapter io control registers to send buf contents to the adapter.
4393 * -ERANGE off and count combo out of range
4394 * -EINVAL off, count or buff address invalid
4395 * -EPERM adapter is offline
4396 * value of count, buf contents written
4399 sysfs_ctlreg_write(struct file *filp, struct kobject *kobj,
4400 struct bin_attribute *bin_attr,
4401 char *buf, loff_t off, size_t count)
4404 struct device *dev = container_of(kobj, struct device, kobj);
4405 struct Scsi_Host *shost = class_to_shost(dev);
4406 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4407 struct lpfc_hba *phba = vport->phba;
4409 if (phba->sli_rev >= LPFC_SLI_REV4)
4412 if ((off + count) > FF_REG_AREA_SIZE)
4415 if (count <= LPFC_REG_WRITE_KEY_SIZE)
4418 if (off % 4 || count % 4 || (unsigned long)buf % 4)
4421 /* This is to protect HBA registers from accidental writes. */
4422 if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE))
4425 if (!(vport->fc_flag & FC_OFFLINE_MODE))
4428 spin_lock_irq(&phba->hbalock);
4429 for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE;
4430 buf_off += sizeof(uint32_t))
4431 writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)),
4432 phba->ctrl_regs_memmap_p + off + buf_off);
4434 spin_unlock_irq(&phba->hbalock);
4440 * sysfs_ctlreg_read - Read method for reading from ctlreg
4441 * @filp: open sysfs file
4442 * @kobj: kernel kobject that contains the kernel class device.
4443 * @bin_attr: kernel attributes passed to us.
4444 * @buf: if successful contains the data from the adapter IOREG space.
4445 * @off: offset into buffer to beginning of data.
4446 * @count: bytes to transfer.
4449 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
4450 * Uses the adapter io control registers to read data into buf.
4453 * -ERANGE off and count combo out of range
4454 * -EINVAL off, count or buff address invalid
4455 * value of count, buf contents read
4458 sysfs_ctlreg_read(struct file *filp, struct kobject *kobj,
4459 struct bin_attribute *bin_attr,
4460 char *buf, loff_t off, size_t count)
4464 struct device *dev = container_of(kobj, struct device, kobj);
4465 struct Scsi_Host *shost = class_to_shost(dev);
4466 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4467 struct lpfc_hba *phba = vport->phba;
4469 if (phba->sli_rev >= LPFC_SLI_REV4)
4472 if (off > FF_REG_AREA_SIZE)
4475 if ((off + count) > FF_REG_AREA_SIZE)
4476 count = FF_REG_AREA_SIZE - off;
4478 if (count == 0) return 0;
4480 if (off % 4 || count % 4 || (unsigned long)buf % 4)
4483 spin_lock_irq(&phba->hbalock);
4485 for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) {
4486 tmp_ptr = (uint32_t *)(buf + buf_off);
4487 *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off);
4490 spin_unlock_irq(&phba->hbalock);
4495 static struct bin_attribute sysfs_ctlreg_attr = {
4498 .mode = S_IRUSR | S_IWUSR,
4501 .read = sysfs_ctlreg_read,
4502 .write = sysfs_ctlreg_write,
4506 * sysfs_mbox_write - Write method for writing information via mbox
4507 * @filp: open sysfs file
4508 * @kobj: kernel kobject that contains the kernel class device.
4509 * @bin_attr: kernel attributes passed to us.
4510 * @buf: contains the data to be written to sysfs mbox.
4511 * @off: offset into buffer to beginning of data.
4512 * @count: bytes to transfer.
4515 * Deprecated function. All mailbox access from user space is performed via the
4519 * -EPERM operation not permitted
4522 sysfs_mbox_write(struct file *filp, struct kobject *kobj,
4523 struct bin_attribute *bin_attr,
4524 char *buf, loff_t off, size_t count)
4530 * sysfs_mbox_read - Read method for reading information via mbox
4531 * @filp: open sysfs file
4532 * @kobj: kernel kobject that contains the kernel class device.
4533 * @bin_attr: kernel attributes passed to us.
4534 * @buf: contains the data to be read from sysfs mbox.
4535 * @off: offset into buffer to beginning of data.
4536 * @count: bytes to transfer.
4539 * Deprecated function. All mailbox access from user space is performed via the
4543 * -EPERM operation not permitted
4546 sysfs_mbox_read(struct file *filp, struct kobject *kobj,
4547 struct bin_attribute *bin_attr,
4548 char *buf, loff_t off, size_t count)
4553 static struct bin_attribute sysfs_mbox_attr = {
4556 .mode = S_IRUSR | S_IWUSR,
4558 .size = MAILBOX_SYSFS_MAX,
4559 .read = sysfs_mbox_read,
4560 .write = sysfs_mbox_write,
4564 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
4565 * @vport: address of lpfc vport structure.
4569 * error return code from sysfs_create_bin_file()
4572 lpfc_alloc_sysfs_attr(struct lpfc_vport *vport)
4574 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4577 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
4578 &sysfs_drvr_stat_data_attr);
4580 /* Virtual ports do not need ctrl_reg and mbox */
4581 if (error || vport->port_type == LPFC_NPIV_PORT)
4584 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
4585 &sysfs_ctlreg_attr);
4587 goto out_remove_stat_attr;
4589 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
4592 goto out_remove_ctlreg_attr;
4595 out_remove_ctlreg_attr:
4596 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr);
4597 out_remove_stat_attr:
4598 sysfs_remove_bin_file(&shost->shost_dev.kobj,
4599 &sysfs_drvr_stat_data_attr);
4605 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
4606 * @vport: address of lpfc vport structure.
4609 lpfc_free_sysfs_attr(struct lpfc_vport *vport)
4611 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4612 sysfs_remove_bin_file(&shost->shost_dev.kobj,
4613 &sysfs_drvr_stat_data_attr);
4614 /* Virtual ports do not need ctrl_reg and mbox */
4615 if (vport->port_type == LPFC_NPIV_PORT)
4617 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr);
4618 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr);
4623 * Dynamic FC Host Attributes Support
4627 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
4628 * @shost: kernel scsi host pointer.
4631 lpfc_get_host_port_id(struct Scsi_Host *shost)
4633 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4635 /* note: fc_myDID already in cpu endianness */
4636 fc_host_port_id(shost) = vport->fc_myDID;
4640 * lpfc_get_host_port_type - Set the value of the scsi host port type
4641 * @shost: kernel scsi host pointer.
4644 lpfc_get_host_port_type(struct Scsi_Host *shost)
4646 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4647 struct lpfc_hba *phba = vport->phba;
4649 spin_lock_irq(shost->host_lock);
4651 if (vport->port_type == LPFC_NPIV_PORT) {
4652 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
4653 } else if (lpfc_is_link_up(phba)) {
4654 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
4655 if (vport->fc_flag & FC_PUBLIC_LOOP)
4656 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
4658 fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
4660 if (vport->fc_flag & FC_FABRIC)
4661 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
4663 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
4666 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
4668 spin_unlock_irq(shost->host_lock);
4672 * lpfc_get_host_port_state - Set the value of the scsi host port state
4673 * @shost: kernel scsi host pointer.
4676 lpfc_get_host_port_state(struct Scsi_Host *shost)
4678 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4679 struct lpfc_hba *phba = vport->phba;
4681 spin_lock_irq(shost->host_lock);
4683 if (vport->fc_flag & FC_OFFLINE_MODE)
4684 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
4686 switch (phba->link_state) {
4687 case LPFC_LINK_UNKNOWN:
4688 case LPFC_LINK_DOWN:
4689 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
4693 case LPFC_HBA_READY:
4694 /* Links up, reports port state accordingly */
4695 if (vport->port_state < LPFC_VPORT_READY)
4696 fc_host_port_state(shost) =
4697 FC_PORTSTATE_BYPASSED;
4699 fc_host_port_state(shost) =
4700 FC_PORTSTATE_ONLINE;
4702 case LPFC_HBA_ERROR:
4703 fc_host_port_state(shost) = FC_PORTSTATE_ERROR;
4706 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
4711 spin_unlock_irq(shost->host_lock);
4715 * lpfc_get_host_speed - Set the value of the scsi host speed
4716 * @shost: kernel scsi host pointer.
4719 lpfc_get_host_speed(struct Scsi_Host *shost)
4721 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4722 struct lpfc_hba *phba = vport->phba;
4724 spin_lock_irq(shost->host_lock);
4726 if (lpfc_is_link_up(phba)) {
4727 switch(phba->fc_linkspeed) {
4728 case LPFC_LINK_SPEED_1GHZ:
4729 fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
4731 case LPFC_LINK_SPEED_2GHZ:
4732 fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
4734 case LPFC_LINK_SPEED_4GHZ:
4735 fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
4737 case LPFC_LINK_SPEED_8GHZ:
4738 fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
4740 case LPFC_LINK_SPEED_10GHZ:
4741 fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
4743 case LPFC_LINK_SPEED_16GHZ:
4744 fc_host_speed(shost) = FC_PORTSPEED_16GBIT;
4747 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
4751 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
4753 spin_unlock_irq(shost->host_lock);
4757 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
4758 * @shost: kernel scsi host pointer.
4761 lpfc_get_host_fabric_name (struct Scsi_Host *shost)
4763 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4764 struct lpfc_hba *phba = vport->phba;
4767 spin_lock_irq(shost->host_lock);
4769 if ((vport->port_state > LPFC_FLOGI) &&
4770 ((vport->fc_flag & FC_FABRIC) ||
4771 ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) &&
4772 (vport->fc_flag & FC_PUBLIC_LOOP))))
4773 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
4775 /* fabric is local port if there is no F/FL_Port */
4778 spin_unlock_irq(shost->host_lock);
4780 fc_host_fabric_name(shost) = node_name;
4784 * lpfc_get_stats - Return statistical information about the adapter
4785 * @shost: kernel scsi host pointer.
4788 * NULL on error for link down, no mbox pool, sli2 active,
4789 * management not allowed, memory allocation error, or mbox error.
4793 * address of the adapter host statistics
4795 static struct fc_host_statistics *
4796 lpfc_get_stats(struct Scsi_Host *shost)
4798 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4799 struct lpfc_hba *phba = vport->phba;
4800 struct lpfc_sli *psli = &phba->sli;
4801 struct fc_host_statistics *hs = &phba->link_stats;
4802 struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets;
4803 LPFC_MBOXQ_t *pmboxq;
4805 unsigned long seconds;
4809 * prevent udev from issuing mailbox commands until the port is
4812 if (phba->link_state < LPFC_LINK_DOWN ||
4813 !phba->mbox_mem_pool ||
4814 (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0)
4817 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
4820 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4823 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
4825 pmb = &pmboxq->u.mb;
4826 pmb->mbxCommand = MBX_READ_STATUS;
4827 pmb->mbxOwner = OWN_HOST;
4828 pmboxq->context1 = NULL;
4829 pmboxq->vport = vport;
4831 if (vport->fc_flag & FC_OFFLINE_MODE)
4832 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
4834 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
4836 if (rc != MBX_SUCCESS) {
4837 if (rc != MBX_TIMEOUT)
4838 mempool_free(pmboxq, phba->mbox_mem_pool);
4842 memset(hs, 0, sizeof (struct fc_host_statistics));
4844 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
4846 * The MBX_READ_STATUS returns tx_k_bytes which has to
4847 * converted to words
4849 hs->tx_words = (uint64_t)
4850 ((uint64_t)pmb->un.varRdStatus.xmitByteCnt
4852 hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
4853 hs->rx_words = (uint64_t)
4854 ((uint64_t)pmb->un.varRdStatus.rcvByteCnt
4857 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
4858 pmb->mbxCommand = MBX_READ_LNK_STAT;
4859 pmb->mbxOwner = OWN_HOST;
4860 pmboxq->context1 = NULL;
4861 pmboxq->vport = vport;
4863 if (vport->fc_flag & FC_OFFLINE_MODE)
4864 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
4866 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
4868 if (rc != MBX_SUCCESS) {
4869 if (rc != MBX_TIMEOUT)
4870 mempool_free(pmboxq, phba->mbox_mem_pool);
4874 hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
4875 hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
4876 hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
4877 hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
4878 hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
4879 hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
4880 hs->error_frames = pmb->un.varRdLnk.crcCnt;
4882 hs->link_failure_count -= lso->link_failure_count;
4883 hs->loss_of_sync_count -= lso->loss_of_sync_count;
4884 hs->loss_of_signal_count -= lso->loss_of_signal_count;
4885 hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count;
4886 hs->invalid_tx_word_count -= lso->invalid_tx_word_count;
4887 hs->invalid_crc_count -= lso->invalid_crc_count;
4888 hs->error_frames -= lso->error_frames;
4890 if (phba->hba_flag & HBA_FCOE_MODE) {
4892 hs->nos_count = (phba->link_events >> 1);
4893 hs->nos_count -= lso->link_events;
4894 } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
4895 hs->lip_count = (phba->fc_eventTag >> 1);
4896 hs->lip_count -= lso->link_events;
4900 hs->nos_count = (phba->fc_eventTag >> 1);
4901 hs->nos_count -= lso->link_events;
4904 hs->dumped_frames = -1;
4906 seconds = get_seconds();
4907 if (seconds < psli->stats_start)
4908 hs->seconds_since_last_reset = seconds +
4909 ((unsigned long)-1 - psli->stats_start);
4911 hs->seconds_since_last_reset = seconds - psli->stats_start;
4913 mempool_free(pmboxq, phba->mbox_mem_pool);
4919 * lpfc_reset_stats - Copy the adapter link stats information
4920 * @shost: kernel scsi host pointer.
4923 lpfc_reset_stats(struct Scsi_Host *shost)
4925 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4926 struct lpfc_hba *phba = vport->phba;
4927 struct lpfc_sli *psli = &phba->sli;
4928 struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets;
4929 LPFC_MBOXQ_t *pmboxq;
4933 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
4936 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4939 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
4941 pmb = &pmboxq->u.mb;
4942 pmb->mbxCommand = MBX_READ_STATUS;
4943 pmb->mbxOwner = OWN_HOST;
4944 pmb->un.varWords[0] = 0x1; /* reset request */
4945 pmboxq->context1 = NULL;
4946 pmboxq->vport = vport;
4948 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
4949 (!(psli->sli_flag & LPFC_SLI_ACTIVE)))
4950 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
4952 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
4954 if (rc != MBX_SUCCESS) {
4955 if (rc != MBX_TIMEOUT)
4956 mempool_free(pmboxq, phba->mbox_mem_pool);
4960 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
4961 pmb->mbxCommand = MBX_READ_LNK_STAT;
4962 pmb->mbxOwner = OWN_HOST;
4963 pmboxq->context1 = NULL;
4964 pmboxq->vport = vport;
4966 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
4967 (!(psli->sli_flag & LPFC_SLI_ACTIVE)))
4968 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
4970 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
4972 if (rc != MBX_SUCCESS) {
4973 if (rc != MBX_TIMEOUT)
4974 mempool_free( pmboxq, phba->mbox_mem_pool);
4978 lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
4979 lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
4980 lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
4981 lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
4982 lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
4983 lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
4984 lso->error_frames = pmb->un.varRdLnk.crcCnt;
4985 if (phba->hba_flag & HBA_FCOE_MODE)
4986 lso->link_events = (phba->link_events >> 1);
4988 lso->link_events = (phba->fc_eventTag >> 1);
4990 psli->stats_start = get_seconds();
4992 mempool_free(pmboxq, phba->mbox_mem_pool);
4998 * The LPFC driver treats linkdown handling as target loss events so there
4999 * are no sysfs handlers for link_down_tmo.
5003 * lpfc_get_node_by_target - Return the nodelist for a target
5004 * @starget: kernel scsi target pointer.
5007 * address of the node list if found
5008 * NULL target not found
5010 static struct lpfc_nodelist *
5011 lpfc_get_node_by_target(struct scsi_target *starget)
5013 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
5014 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5015 struct lpfc_nodelist *ndlp;
5017 spin_lock_irq(shost->host_lock);
5018 /* Search for this, mapped, target ID */
5019 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
5020 if (NLP_CHK_NODE_ACT(ndlp) &&
5021 ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
5022 starget->id == ndlp->nlp_sid) {
5023 spin_unlock_irq(shost->host_lock);
5027 spin_unlock_irq(shost->host_lock);
5032 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
5033 * @starget: kernel scsi target pointer.
5036 lpfc_get_starget_port_id(struct scsi_target *starget)
5038 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
5040 fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1;
5044 * lpfc_get_starget_node_name - Set the target node name
5045 * @starget: kernel scsi target pointer.
5047 * Description: Set the target node name to the ndlp node name wwn or zero.
5050 lpfc_get_starget_node_name(struct scsi_target *starget)
5052 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
5054 fc_starget_node_name(starget) =
5055 ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0;
5059 * lpfc_get_starget_port_name - Set the target port name
5060 * @starget: kernel scsi target pointer.
5062 * Description: set the target port name to the ndlp port name wwn or zero.
5065 lpfc_get_starget_port_name(struct scsi_target *starget)
5067 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
5069 fc_starget_port_name(starget) =
5070 ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0;
5074 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
5075 * @rport: fc rport address.
5076 * @timeout: new value for dev loss tmo.
5079 * If timeout is non zero set the dev_loss_tmo to timeout, else set
5080 * dev_loss_tmo to one.
5083 lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
5086 rport->dev_loss_tmo = timeout;
5088 rport->dev_loss_tmo = 1;
5092 * lpfc_rport_show_function - Return rport target information
5095 * Macro that uses field to generate a function with the name lpfc_show_rport_
5097 * lpfc_show_rport_##field: returns the bytes formatted in buf
5098 * @cdev: class converted to an fc_rport.
5099 * @buf: on return contains the target_field or zero.
5101 * Returns: size of formatted string.
5103 #define lpfc_rport_show_function(field, format_string, sz, cast) \
5105 lpfc_show_rport_##field (struct device *dev, \
5106 struct device_attribute *attr, \
5109 struct fc_rport *rport = transport_class_to_rport(dev); \
5110 struct lpfc_rport_data *rdata = rport->hostdata; \
5111 return snprintf(buf, sz, format_string, \
5112 (rdata->target) ? cast rdata->target->field : 0); \
5115 #define lpfc_rport_rd_attr(field, format_string, sz) \
5116 lpfc_rport_show_function(field, format_string, sz, ) \
5117 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
5120 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
5121 * @fc_vport: The fc_vport who's symbolic name has been changed.
5124 * This function is called by the transport after the @fc_vport's symbolic name
5125 * has been changed. This function re-registers the symbolic name with the
5126 * switch to propagate the change into the fabric if the vport is active.
5129 lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport)
5131 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
5133 if (vport->port_state == LPFC_VPORT_READY)
5134 lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0);
5138 * lpfc_hba_log_verbose_init - Set hba's log verbose level
5139 * @phba: Pointer to lpfc_hba struct.
5141 * This function is called by the lpfc_get_cfgparam() routine to set the
5142 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
5143 * log message according to the module's lpfc_log_verbose parameter setting
5144 * before hba port or vport created.
5147 lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose)
5149 phba->cfg_log_verbose = verbose;
5152 struct fc_function_template lpfc_transport_functions = {
5153 /* fixed attributes the driver supports */
5154 .show_host_node_name = 1,
5155 .show_host_port_name = 1,
5156 .show_host_supported_classes = 1,
5157 .show_host_supported_fc4s = 1,
5158 .show_host_supported_speeds = 1,
5159 .show_host_maxframe_size = 1,
5160 .show_host_symbolic_name = 1,
5162 /* dynamic attributes the driver supports */
5163 .get_host_port_id = lpfc_get_host_port_id,
5164 .show_host_port_id = 1,
5166 .get_host_port_type = lpfc_get_host_port_type,
5167 .show_host_port_type = 1,
5169 .get_host_port_state = lpfc_get_host_port_state,
5170 .show_host_port_state = 1,
5172 /* active_fc4s is shown but doesn't change (thus no get function) */
5173 .show_host_active_fc4s = 1,
5175 .get_host_speed = lpfc_get_host_speed,
5176 .show_host_speed = 1,
5178 .get_host_fabric_name = lpfc_get_host_fabric_name,
5179 .show_host_fabric_name = 1,
5182 * The LPFC driver treats linkdown handling as target loss events
5183 * so there are no sysfs handlers for link_down_tmo.
5186 .get_fc_host_stats = lpfc_get_stats,
5187 .reset_fc_host_stats = lpfc_reset_stats,
5189 .dd_fcrport_size = sizeof(struct lpfc_rport_data),
5190 .show_rport_maxframe_size = 1,
5191 .show_rport_supported_classes = 1,
5193 .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
5194 .show_rport_dev_loss_tmo = 1,
5196 .get_starget_port_id = lpfc_get_starget_port_id,
5197 .show_starget_port_id = 1,
5199 .get_starget_node_name = lpfc_get_starget_node_name,
5200 .show_starget_node_name = 1,
5202 .get_starget_port_name = lpfc_get_starget_port_name,
5203 .show_starget_port_name = 1,
5205 .issue_fc_host_lip = lpfc_issue_lip,
5206 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
5207 .terminate_rport_io = lpfc_terminate_rport_io,
5209 .dd_fcvport_size = sizeof(struct lpfc_vport *),
5211 .vport_disable = lpfc_vport_disable,
5213 .set_vport_symbolic_name = lpfc_set_vport_symbolic_name,
5215 .bsg_request = lpfc_bsg_request,
5216 .bsg_timeout = lpfc_bsg_timeout,
5219 struct fc_function_template lpfc_vport_transport_functions = {
5220 /* fixed attributes the driver supports */
5221 .show_host_node_name = 1,
5222 .show_host_port_name = 1,
5223 .show_host_supported_classes = 1,
5224 .show_host_supported_fc4s = 1,
5225 .show_host_supported_speeds = 1,
5226 .show_host_maxframe_size = 1,
5227 .show_host_symbolic_name = 1,
5229 /* dynamic attributes the driver supports */
5230 .get_host_port_id = lpfc_get_host_port_id,
5231 .show_host_port_id = 1,
5233 .get_host_port_type = lpfc_get_host_port_type,
5234 .show_host_port_type = 1,
5236 .get_host_port_state = lpfc_get_host_port_state,
5237 .show_host_port_state = 1,
5239 /* active_fc4s is shown but doesn't change (thus no get function) */
5240 .show_host_active_fc4s = 1,
5242 .get_host_speed = lpfc_get_host_speed,
5243 .show_host_speed = 1,
5245 .get_host_fabric_name = lpfc_get_host_fabric_name,
5246 .show_host_fabric_name = 1,
5249 * The LPFC driver treats linkdown handling as target loss events
5250 * so there are no sysfs handlers for link_down_tmo.
5253 .get_fc_host_stats = lpfc_get_stats,
5254 .reset_fc_host_stats = lpfc_reset_stats,
5256 .dd_fcrport_size = sizeof(struct lpfc_rport_data),
5257 .show_rport_maxframe_size = 1,
5258 .show_rport_supported_classes = 1,
5260 .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
5261 .show_rport_dev_loss_tmo = 1,
5263 .get_starget_port_id = lpfc_get_starget_port_id,
5264 .show_starget_port_id = 1,
5266 .get_starget_node_name = lpfc_get_starget_node_name,
5267 .show_starget_node_name = 1,
5269 .get_starget_port_name = lpfc_get_starget_port_name,
5270 .show_starget_port_name = 1,
5272 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
5273 .terminate_rport_io = lpfc_terminate_rport_io,
5275 .vport_disable = lpfc_vport_disable,
5277 .set_vport_symbolic_name = lpfc_set_vport_symbolic_name,
5281 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
5282 * @phba: lpfc_hba pointer.
5285 lpfc_get_cfgparam(struct lpfc_hba *phba)
5287 lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched);
5288 lpfc_fcp2_no_tgt_reset_init(phba, lpfc_fcp2_no_tgt_reset);
5289 lpfc_cr_delay_init(phba, lpfc_cr_delay);
5290 lpfc_cr_count_init(phba, lpfc_cr_count);
5291 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
5292 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
5293 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
5294 lpfc_ack0_init(phba, lpfc_ack0);
5295 lpfc_topology_init(phba, lpfc_topology);
5296 lpfc_link_speed_init(phba, lpfc_link_speed);
5297 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
5298 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
5299 lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy);
5300 lpfc_enable_rrq_init(phba, lpfc_enable_rrq);
5301 lpfc_use_msi_init(phba, lpfc_use_msi);
5302 lpfc_fcp_imax_init(phba, lpfc_fcp_imax);
5303 lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map);
5304 lpfc_fcp_wq_count_init(phba, lpfc_fcp_wq_count);
5305 lpfc_fcp_eq_count_init(phba, lpfc_fcp_eq_count);
5306 lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel);
5307 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
5308 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
5309 lpfc_enable_bg_init(phba, lpfc_enable_bg);
5310 if (phba->sli_rev == LPFC_SLI_REV4)
5313 phba->cfg_poll = lpfc_poll;
5314 phba->cfg_soft_wwnn = 0L;
5315 phba->cfg_soft_wwpn = 0L;
5316 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
5317 lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt);
5318 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
5319 lpfc_hba_log_verbose_init(phba, lpfc_log_verbose);
5320 lpfc_aer_support_init(phba, lpfc_aer_support);
5321 lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn);
5322 lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade);
5323 lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up);
5324 lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt);
5325 phba->cfg_enable_dss = 1;
5330 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
5331 * @vport: lpfc_vport pointer.
5334 lpfc_get_vport_cfgparam(struct lpfc_vport *vport)
5336 lpfc_log_verbose_init(vport, lpfc_log_verbose);
5337 lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth);
5338 lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth);
5339 lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo);
5340 lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo);
5341 lpfc_peer_port_login_init(vport, lpfc_peer_port_login);
5342 lpfc_restrict_login_init(vport, lpfc_restrict_login);
5343 lpfc_fcp_class_init(vport, lpfc_fcp_class);
5344 lpfc_use_adisc_init(vport, lpfc_use_adisc);
5345 lpfc_first_burst_size_init(vport, lpfc_first_burst_size);
5346 lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time);
5347 lpfc_fdmi_on_init(vport, lpfc_fdmi_on);
5348 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
5349 lpfc_max_luns_init(vport, lpfc_max_luns);
5350 lpfc_scan_down_init(vport, lpfc_scan_down);
5351 lpfc_enable_da_id_init(vport, lpfc_enable_da_id);