1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2016 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"
51 #include "lpfc_attr.h"
53 #define LPFC_DEF_DEVLOSS_TMO 30
54 #define LPFC_MIN_DEVLOSS_TMO 1
55 #define LPFC_MAX_DEVLOSS_TMO 255
58 * Write key size should be multiple of 4. If write key is changed
59 * make sure that library write key is also changed.
61 #define LPFC_REG_WRITE_KEY_SIZE 4
62 #define LPFC_REG_WRITE_KEY "EMLX"
65 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
66 * @incr: integer to convert.
67 * @hdw: ascii string holding converted integer plus a string terminator.
70 * JEDEC Joint Electron Device Engineering Council.
71 * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii
72 * character string. The string is then terminated with a NULL in byte 9.
73 * Hex 0-9 becomes ascii '0' to '9'.
74 * Hex a-f becomes ascii '=' to 'B' capital B.
77 * Coded for 32 bit integers only.
80 lpfc_jedec_to_ascii(int incr
, char hdw
[])
83 for (i
= 0; i
< 8; i
++) {
86 hdw
[7 - i
] = 0x30 + j
;
88 hdw
[7 - i
] = 0x61 + j
- 10;
96 * lpfc_drvr_version_show - Return the Emulex driver string with version number
97 * @dev: class unused variable.
98 * @attr: device attribute, not used.
99 * @buf: on return contains the module description text.
101 * Returns: size of formatted string.
104 lpfc_drvr_version_show(struct device
*dev
, struct device_attribute
*attr
,
107 return snprintf(buf
, PAGE_SIZE
, LPFC_MODULE_DESC
"\n");
111 * lpfc_enable_fip_show - Return the fip mode of the HBA
112 * @dev: class unused variable.
113 * @attr: device attribute, not used.
114 * @buf: on return contains the module description text.
116 * Returns: size of formatted string.
119 lpfc_enable_fip_show(struct device
*dev
, struct device_attribute
*attr
,
122 struct Scsi_Host
*shost
= class_to_shost(dev
);
123 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
124 struct lpfc_hba
*phba
= vport
->phba
;
126 if (phba
->hba_flag
& HBA_FIP_SUPPORT
)
127 return snprintf(buf
, PAGE_SIZE
, "1\n");
129 return snprintf(buf
, PAGE_SIZE
, "0\n");
133 lpfc_bg_info_show(struct device
*dev
, struct device_attribute
*attr
,
136 struct Scsi_Host
*shost
= class_to_shost(dev
);
137 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
138 struct lpfc_hba
*phba
= vport
->phba
;
140 if (phba
->cfg_enable_bg
)
141 if (phba
->sli3_options
& LPFC_SLI3_BG_ENABLED
)
142 return snprintf(buf
, PAGE_SIZE
, "BlockGuard Enabled\n");
144 return snprintf(buf
, PAGE_SIZE
,
145 "BlockGuard Not Supported\n");
147 return snprintf(buf
, PAGE_SIZE
,
148 "BlockGuard Disabled\n");
152 lpfc_bg_guard_err_show(struct device
*dev
, struct device_attribute
*attr
,
155 struct Scsi_Host
*shost
= class_to_shost(dev
);
156 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
157 struct lpfc_hba
*phba
= vport
->phba
;
159 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
160 (unsigned long long)phba
->bg_guard_err_cnt
);
164 lpfc_bg_apptag_err_show(struct device
*dev
, struct device_attribute
*attr
,
167 struct Scsi_Host
*shost
= class_to_shost(dev
);
168 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
169 struct lpfc_hba
*phba
= vport
->phba
;
171 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
172 (unsigned long long)phba
->bg_apptag_err_cnt
);
176 lpfc_bg_reftag_err_show(struct device
*dev
, struct device_attribute
*attr
,
179 struct Scsi_Host
*shost
= class_to_shost(dev
);
180 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
181 struct lpfc_hba
*phba
= vport
->phba
;
183 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
184 (unsigned long long)phba
->bg_reftag_err_cnt
);
188 * lpfc_info_show - Return some pci info about the host in ascii
189 * @dev: class converted to a Scsi_host structure.
190 * @attr: device attribute, not used.
191 * @buf: on return contains the formatted text from lpfc_info().
193 * Returns: size of formatted string.
196 lpfc_info_show(struct device
*dev
, struct device_attribute
*attr
,
199 struct Scsi_Host
*host
= class_to_shost(dev
);
201 return snprintf(buf
, PAGE_SIZE
, "%s\n",lpfc_info(host
));
205 * lpfc_serialnum_show - Return the hba serial number in ascii
206 * @dev: class converted to a Scsi_host structure.
207 * @attr: device attribute, not used.
208 * @buf: on return contains the formatted text serial number.
210 * Returns: size of formatted string.
213 lpfc_serialnum_show(struct device
*dev
, struct device_attribute
*attr
,
216 struct Scsi_Host
*shost
= class_to_shost(dev
);
217 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
218 struct lpfc_hba
*phba
= vport
->phba
;
220 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->SerialNumber
);
224 * lpfc_temp_sensor_show - Return the temperature sensor level
225 * @dev: class converted to a Scsi_host structure.
226 * @attr: device attribute, not used.
227 * @buf: on return contains the formatted support level.
230 * Returns a number indicating the temperature sensor level currently
231 * supported, zero or one in ascii.
233 * Returns: size of formatted string.
236 lpfc_temp_sensor_show(struct device
*dev
, struct device_attribute
*attr
,
239 struct Scsi_Host
*shost
= class_to_shost(dev
);
240 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
241 struct lpfc_hba
*phba
= vport
->phba
;
242 return snprintf(buf
, PAGE_SIZE
, "%d\n",phba
->temp_sensor_support
);
246 * lpfc_modeldesc_show - Return the model description of the hba
247 * @dev: class converted to a Scsi_host structure.
248 * @attr: device attribute, not used.
249 * @buf: on return contains the scsi vpd model description.
251 * Returns: size of formatted string.
254 lpfc_modeldesc_show(struct device
*dev
, struct device_attribute
*attr
,
257 struct Scsi_Host
*shost
= class_to_shost(dev
);
258 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
259 struct lpfc_hba
*phba
= vport
->phba
;
261 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelDesc
);
265 * lpfc_modelname_show - Return the model name of the hba
266 * @dev: class converted to a Scsi_host structure.
267 * @attr: device attribute, not used.
268 * @buf: on return contains the scsi vpd model name.
270 * Returns: size of formatted string.
273 lpfc_modelname_show(struct device
*dev
, struct device_attribute
*attr
,
276 struct Scsi_Host
*shost
= class_to_shost(dev
);
277 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
278 struct lpfc_hba
*phba
= vport
->phba
;
280 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelName
);
284 * lpfc_programtype_show - Return the program type of the hba
285 * @dev: class converted to a Scsi_host structure.
286 * @attr: device attribute, not used.
287 * @buf: on return contains the scsi vpd program type.
289 * Returns: size of formatted string.
292 lpfc_programtype_show(struct device
*dev
, struct device_attribute
*attr
,
295 struct Scsi_Host
*shost
= class_to_shost(dev
);
296 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
297 struct lpfc_hba
*phba
= vport
->phba
;
299 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ProgramType
);
303 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
304 * @dev: class converted to a Scsi_host structure.
305 * @attr: device attribute, not used.
306 * @buf: on return contains the Menlo Maintenance sli flag.
308 * Returns: size of formatted string.
311 lpfc_mlomgmt_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
313 struct Scsi_Host
*shost
= class_to_shost(dev
);
314 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
315 struct lpfc_hba
*phba
= vport
->phba
;
317 return snprintf(buf
, PAGE_SIZE
, "%d\n",
318 (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
));
322 * lpfc_vportnum_show - Return the port number in ascii of the hba
323 * @dev: class converted to a Scsi_host structure.
324 * @attr: device attribute, not used.
325 * @buf: on return contains scsi vpd program type.
327 * Returns: size of formatted string.
330 lpfc_vportnum_show(struct device
*dev
, struct device_attribute
*attr
,
333 struct Scsi_Host
*shost
= class_to_shost(dev
);
334 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
335 struct lpfc_hba
*phba
= vport
->phba
;
337 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->Port
);
341 * lpfc_fwrev_show - Return the firmware rev running in the hba
342 * @dev: class converted to a Scsi_host structure.
343 * @attr: device attribute, not used.
344 * @buf: on return contains the scsi vpd program type.
346 * Returns: size of formatted string.
349 lpfc_fwrev_show(struct device
*dev
, struct device_attribute
*attr
,
352 struct Scsi_Host
*shost
= class_to_shost(dev
);
353 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
354 struct lpfc_hba
*phba
= vport
->phba
;
357 char fwrev
[FW_REV_STR_SIZE
];
360 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
361 if_type
= phba
->sli4_hba
.pc_sli4_params
.if_type
;
362 sli_family
= phba
->sli4_hba
.pc_sli4_params
.sli_family
;
364 if (phba
->sli_rev
< LPFC_SLI_REV4
)
365 len
= snprintf(buf
, PAGE_SIZE
, "%s, sli-%d\n",
366 fwrev
, phba
->sli_rev
);
368 len
= snprintf(buf
, PAGE_SIZE
, "%s, sli-%d:%d:%x\n",
369 fwrev
, phba
->sli_rev
, if_type
, sli_family
);
375 * lpfc_hdw_show - Return the jedec information about the hba
376 * @dev: class converted to a Scsi_host structure.
377 * @attr: device attribute, not used.
378 * @buf: on return contains the scsi vpd program type.
380 * Returns: size of formatted string.
383 lpfc_hdw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
386 struct Scsi_Host
*shost
= class_to_shost(dev
);
387 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
388 struct lpfc_hba
*phba
= vport
->phba
;
389 lpfc_vpd_t
*vp
= &phba
->vpd
;
391 lpfc_jedec_to_ascii(vp
->rev
.biuRev
, hdw
);
392 return snprintf(buf
, PAGE_SIZE
, "%s\n", hdw
);
396 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
397 * @dev: class converted to a Scsi_host structure.
398 * @attr: device attribute, not used.
399 * @buf: on return contains the ROM and FCode ascii strings.
401 * Returns: size of formatted string.
404 lpfc_option_rom_version_show(struct device
*dev
, struct device_attribute
*attr
,
407 struct Scsi_Host
*shost
= class_to_shost(dev
);
408 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
409 struct lpfc_hba
*phba
= vport
->phba
;
410 char fwrev
[FW_REV_STR_SIZE
];
412 if (phba
->sli_rev
< LPFC_SLI_REV4
)
413 return snprintf(buf
, PAGE_SIZE
, "%s\n", phba
->OptionROMVersion
);
415 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
416 return snprintf(buf
, PAGE_SIZE
, "%s\n", fwrev
);
420 * lpfc_state_show - Return the link state of the port
421 * @dev: class converted to a Scsi_host structure.
422 * @attr: device attribute, not used.
423 * @buf: on return contains text describing the state of the link.
426 * The switch statement has no default so zero will be returned.
428 * Returns: size of formatted string.
431 lpfc_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
434 struct Scsi_Host
*shost
= class_to_shost(dev
);
435 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
436 struct lpfc_hba
*phba
= vport
->phba
;
439 switch (phba
->link_state
) {
440 case LPFC_LINK_UNKNOWN
:
441 case LPFC_WARM_START
:
442 case LPFC_INIT_START
:
443 case LPFC_INIT_MBX_CMDS
:
446 if (phba
->hba_flag
& LINK_DISABLED
)
447 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
448 "Link Down - User disabled\n");
450 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
456 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Link Up - ");
458 switch (vport
->port_state
) {
459 case LPFC_LOCAL_CFG_LINK
:
460 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
461 "Configuring Link\n");
465 case LPFC_FABRIC_CFG_LINK
:
468 case LPFC_BUILD_DISC_LIST
:
470 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
473 case LPFC_VPORT_READY
:
474 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Ready\n");
477 case LPFC_VPORT_FAILED
:
478 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Failed\n");
481 case LPFC_VPORT_UNKNOWN
:
482 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
486 if (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
)
487 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
488 " Menlo Maint Mode\n");
489 else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
490 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
491 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
494 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
497 if (vport
->fc_flag
& FC_FABRIC
)
498 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
501 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
510 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
511 * @dev: class unused variable.
512 * @attr: device attribute, not used.
513 * @buf: on return contains the module description text.
515 * Returns: size of formatted string.
518 lpfc_sli4_protocol_show(struct device
*dev
, struct device_attribute
*attr
,
521 struct Scsi_Host
*shost
= class_to_shost(dev
);
522 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
523 struct lpfc_hba
*phba
= vport
->phba
;
525 if (phba
->sli_rev
< LPFC_SLI_REV4
)
526 return snprintf(buf
, PAGE_SIZE
, "fc\n");
528 if (phba
->sli4_hba
.lnk_info
.lnk_dv
== LPFC_LNK_DAT_VAL
) {
529 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_GE
)
530 return snprintf(buf
, PAGE_SIZE
, "fcoe\n");
531 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_FC
)
532 return snprintf(buf
, PAGE_SIZE
, "fc\n");
534 return snprintf(buf
, PAGE_SIZE
, "unknown\n");
538 * lpfc_oas_supported_show - Return whether or not Optimized Access Storage
539 * (OAS) is supported.
540 * @dev: class unused variable.
541 * @attr: device attribute, not used.
542 * @buf: on return contains the module description text.
544 * Returns: size of formatted string.
547 lpfc_oas_supported_show(struct device
*dev
, struct device_attribute
*attr
,
550 struct Scsi_Host
*shost
= class_to_shost(dev
);
551 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
552 struct lpfc_hba
*phba
= vport
->phba
;
554 return snprintf(buf
, PAGE_SIZE
, "%d\n",
555 phba
->sli4_hba
.pc_sli4_params
.oas_supported
);
559 * lpfc_link_state_store - Transition the link_state on an HBA port
560 * @dev: class device that is converted into a Scsi_host.
561 * @attr: device attribute, not used.
562 * @buf: one or more lpfc_polling_flags values.
566 * -EINVAL if the buffer is not "up" or "down"
567 * return from link state change function if non-zero
568 * length of the buf on success
571 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
572 const char *buf
, size_t count
)
574 struct Scsi_Host
*shost
= class_to_shost(dev
);
575 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
576 struct lpfc_hba
*phba
= vport
->phba
;
578 int status
= -EINVAL
;
580 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
581 (phba
->link_state
== LPFC_LINK_DOWN
))
582 status
= phba
->lpfc_hba_init_link(phba
, MBX_NOWAIT
);
583 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
584 (phba
->link_state
>= LPFC_LINK_UP
))
585 status
= phba
->lpfc_hba_down_link(phba
, MBX_NOWAIT
);
594 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
595 * @dev: class device that is converted into a Scsi_host.
596 * @attr: device attribute, not used.
597 * @buf: on return contains the sum of fc mapped and unmapped.
600 * Returns the ascii text number of the sum of the fc mapped and unmapped
603 * Returns: size of formatted string.
606 lpfc_num_discovered_ports_show(struct device
*dev
,
607 struct device_attribute
*attr
, char *buf
)
609 struct Scsi_Host
*shost
= class_to_shost(dev
);
610 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
612 return snprintf(buf
, PAGE_SIZE
, "%d\n",
613 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
617 * lpfc_issue_lip - Misnomer, name carried over from long ago
618 * @shost: Scsi_Host pointer.
621 * Bring the link down gracefully then re-init the link. The firmware will
622 * re-init the fiber channel interface as required. Does not issue a LIP.
625 * -EPERM port offline or management commands are being blocked
626 * -ENOMEM cannot allocate memory for the mailbox command
627 * -EIO error sending the mailbox command
631 lpfc_issue_lip(struct Scsi_Host
*shost
)
633 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
634 struct lpfc_hba
*phba
= vport
->phba
;
635 LPFC_MBOXQ_t
*pmboxq
;
636 int mbxstatus
= MBXERR_ERROR
;
638 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
639 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
642 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
647 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
648 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
649 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
651 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
653 if ((mbxstatus
== MBX_SUCCESS
) &&
654 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
655 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
656 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
657 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
658 phba
->cfg_link_speed
);
659 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
661 if ((mbxstatus
== MBX_SUCCESS
) &&
662 (pmboxq
->u
.mb
.mbxStatus
== MBXERR_SEC_NO_PERMISSION
))
663 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
| LOG_SLI
,
664 "2859 SLI authentication is required "
665 "for INIT_LINK but has not done yet\n");
668 lpfc_set_loopback_flag(phba
);
669 if (mbxstatus
!= MBX_TIMEOUT
)
670 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
672 if (mbxstatus
== MBXERR_ERROR
)
679 * lpfc_do_offline - Issues a mailbox command to bring the link down
680 * @phba: lpfc_hba pointer.
681 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
684 * Assumes any error from lpfc_do_offline() will be negative.
685 * Can wait up to 5 seconds for the port ring buffers count
686 * to reach zero, prints a warning if it is not zero and continues.
687 * lpfc_workq_post_event() returns a non-zero return code if call fails.
690 * -EIO error posting the event
694 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
696 struct completion online_compl
;
697 struct lpfc_sli_ring
*pring
;
698 struct lpfc_sli
*psli
;
704 init_completion(&online_compl
);
705 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
706 LPFC_EVT_OFFLINE_PREP
);
710 wait_for_completion(&online_compl
);
717 /* Wait a little for things to settle down, but not
718 * long enough for dev loss timeout to expire.
720 for (i
= 0; i
< psli
->num_rings
; i
++) {
721 pring
= &psli
->ring
[i
];
722 while (!list_empty(&pring
->txcmplq
)) {
724 if (cnt
++ > 500) { /* 5 secs */
725 lpfc_printf_log(phba
,
726 KERN_WARNING
, LOG_INIT
,
727 "0466 Outstanding IO when "
728 "bringing Adapter offline\n");
734 init_completion(&online_compl
);
735 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
739 wait_for_completion(&online_compl
);
748 * lpfc_selective_reset - Offline then onlines the port
749 * @phba: lpfc_hba pointer.
752 * If the port is configured to allow a reset then the hba is brought
753 * offline then online.
756 * Assumes any error from lpfc_do_offline() will be negative.
757 * Do not make this function static.
760 * lpfc_do_offline() return code if not zero
761 * -EIO reset not configured or error posting the event
765 lpfc_selective_reset(struct lpfc_hba
*phba
)
767 struct completion online_compl
;
771 if (!phba
->cfg_enable_hba_reset
)
774 if (!(phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
775 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
781 init_completion(&online_compl
);
782 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
787 wait_for_completion(&online_compl
);
796 * lpfc_issue_reset - Selectively resets an adapter
797 * @dev: class device that is converted into a Scsi_host.
798 * @attr: device attribute, not used.
799 * @buf: containing the string "selective".
800 * @count: unused variable.
803 * If the buf contains the string "selective" then lpfc_selective_reset()
804 * is called to perform the reset.
807 * Assumes any error from lpfc_selective_reset() will be negative.
808 * If lpfc_selective_reset() returns zero then the length of the buffer
809 * is returned which indicates success
812 * -EINVAL if the buffer does not contain the string "selective"
813 * length of buf if lpfc-selective_reset() if the call succeeds
814 * return value of lpfc_selective_reset() if the call fails
817 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
818 const char *buf
, size_t count
)
820 struct Scsi_Host
*shost
= class_to_shost(dev
);
821 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
822 struct lpfc_hba
*phba
= vport
->phba
;
823 int status
= -EINVAL
;
825 if (!phba
->cfg_enable_hba_reset
)
828 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
829 status
= phba
->lpfc_selective_reset(phba
);
838 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
839 * @phba: lpfc_hba pointer.
842 * SLI4 interface type-2 device to wait on the sliport status register for
843 * the readyness after performing a firmware reset.
846 * zero for success, -EPERM when port does not have privilege to perform the
847 * reset, -EIO when port timeout from recovering from the reset.
850 * As the caller will interpret the return code by value, be careful in making
851 * change or addition to return codes.
854 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba
*phba
)
856 struct lpfc_register portstat_reg
= {0};
860 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
861 &portstat_reg
.word0
);
863 /* verify if privileged for the request operation */
864 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
) &&
865 !bf_get(lpfc_sliport_status_err
, &portstat_reg
))
868 /* wait for the SLI port firmware ready after firmware reset */
869 for (i
= 0; i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
; i
++) {
871 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
872 &portstat_reg
.word0
);
873 if (!bf_get(lpfc_sliport_status_err
, &portstat_reg
))
875 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
))
877 if (!bf_get(lpfc_sliport_status_rdy
, &portstat_reg
))
882 if (i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
)
889 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
890 * @phba: lpfc_hba pointer.
893 * Request SLI4 interface type-2 device to perform a physical register set
900 lpfc_sli4_pdev_reg_request(struct lpfc_hba
*phba
, uint32_t opcode
)
902 struct completion online_compl
;
903 struct pci_dev
*pdev
= phba
->pcidev
;
904 uint32_t before_fc_flag
;
905 uint32_t sriov_nr_virtfn
;
907 int status
= 0, rc
= 0;
908 int job_posted
= 1, sriov_err
;
910 if (!phba
->cfg_enable_hba_reset
)
913 if ((phba
->sli_rev
< LPFC_SLI_REV4
) ||
914 (bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
) !=
915 LPFC_SLI_INTF_IF_TYPE_2
))
918 /* Keep state if we need to restore back */
919 before_fc_flag
= phba
->pport
->fc_flag
;
920 sriov_nr_virtfn
= phba
->cfg_sriov_nr_virtfn
;
922 /* Disable SR-IOV virtual functions if enabled */
923 if (phba
->cfg_sriov_nr_virtfn
) {
924 pci_disable_sriov(pdev
);
925 phba
->cfg_sriov_nr_virtfn
= 0;
928 if (opcode
== LPFC_FW_DUMP
)
929 phba
->hba_flag
|= HBA_FW_DUMP_OP
;
931 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
934 phba
->hba_flag
&= ~HBA_FW_DUMP_OP
;
938 /* wait for the device to be quiesced before firmware reset */
941 reg_val
= readl(phba
->sli4_hba
.conf_regs_memmap_p
+
942 LPFC_CTL_PDEV_CTL_OFFSET
);
944 if (opcode
== LPFC_FW_DUMP
)
945 reg_val
|= LPFC_FW_DUMP_REQUEST
;
946 else if (opcode
== LPFC_FW_RESET
)
947 reg_val
|= LPFC_CTL_PDEV_CTL_FRST
;
948 else if (opcode
== LPFC_DV_RESET
)
949 reg_val
|= LPFC_CTL_PDEV_CTL_DRST
;
951 writel(reg_val
, phba
->sli4_hba
.conf_regs_memmap_p
+
952 LPFC_CTL_PDEV_CTL_OFFSET
);
954 readl(phba
->sli4_hba
.conf_regs_memmap_p
+ LPFC_CTL_PDEV_CTL_OFFSET
);
956 /* delay driver action following IF_TYPE_2 reset */
957 rc
= lpfc_sli4_pdev_status_reg_wait(phba
);
960 /* no privilege for reset */
961 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
962 "3150 No privilege to perform the requested "
963 "access: x%x\n", reg_val
);
964 } else if (rc
== -EIO
) {
965 /* reset failed, there is nothing more we can do */
966 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
967 "3153 Fail to perform the requested "
968 "access: x%x\n", reg_val
);
972 /* keep the original port state */
973 if (before_fc_flag
& FC_OFFLINE_MODE
)
976 init_completion(&online_compl
);
977 job_posted
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
982 wait_for_completion(&online_compl
);
985 /* in any case, restore the virtual functions enabled as before */
986 if (sriov_nr_virtfn
) {
988 lpfc_sli_probe_sriov_nr_virtfn(phba
, sriov_nr_virtfn
);
990 phba
->cfg_sriov_nr_virtfn
= sriov_nr_virtfn
;
993 /* return proper error code */
1004 * lpfc_nport_evt_cnt_show - Return the number of nport events
1005 * @dev: class device that is converted into a Scsi_host.
1006 * @attr: device attribute, not used.
1007 * @buf: on return contains the ascii number of nport events.
1009 * Returns: size of formatted string.
1012 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
1015 struct Scsi_Host
*shost
= class_to_shost(dev
);
1016 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1017 struct lpfc_hba
*phba
= vport
->phba
;
1019 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
1023 * lpfc_board_mode_show - Return the state of the board
1024 * @dev: class device that is converted into a Scsi_host.
1025 * @attr: device attribute, not used.
1026 * @buf: on return contains the state of the adapter.
1028 * Returns: size of formatted string.
1031 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
1034 struct Scsi_Host
*shost
= class_to_shost(dev
);
1035 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1036 struct lpfc_hba
*phba
= vport
->phba
;
1039 if (phba
->link_state
== LPFC_HBA_ERROR
)
1041 else if (phba
->link_state
== LPFC_WARM_START
)
1042 state
= "warm start";
1043 else if (phba
->link_state
== LPFC_INIT_START
)
1048 return snprintf(buf
, PAGE_SIZE
, "%s\n", state
);
1052 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1053 * @dev: class device that is converted into a Scsi_host.
1054 * @attr: device attribute, not used.
1055 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1056 * @count: unused variable.
1059 * -EACCES if enable hba reset not enabled
1060 * -EINVAL if the buffer does not contain a valid string (see above)
1061 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1062 * buf length greater than zero indicates success
1065 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
1066 const char *buf
, size_t count
)
1068 struct Scsi_Host
*shost
= class_to_shost(dev
);
1069 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1070 struct lpfc_hba
*phba
= vport
->phba
;
1071 struct completion online_compl
;
1072 char *board_mode_str
= NULL
;
1076 if (!phba
->cfg_enable_hba_reset
) {
1078 goto board_mode_out
;
1081 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1082 "3050 lpfc_board_mode set to %s\n", buf
);
1084 init_completion(&online_compl
);
1086 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
1087 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1091 goto board_mode_out
;
1093 wait_for_completion(&online_compl
);
1094 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
1095 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1096 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
1097 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1100 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
1101 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
1102 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1105 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
1106 else if (strncmp(buf
, "dump", sizeof("dump") - 1) == 0)
1107 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_DUMP
);
1108 else if (strncmp(buf
, "fw_reset", sizeof("fw_reset") - 1) == 0)
1109 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_RESET
);
1110 else if (strncmp(buf
, "dv_reset", sizeof("dv_reset") - 1) == 0)
1111 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_DV_RESET
);
1119 board_mode_str
= strchr(buf
, '\n');
1121 *board_mode_str
= '\0';
1122 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1123 "3097 Failed \"%s\", status(%d), "
1125 buf
, status
, phba
->pport
->fc_flag
);
1131 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1132 * @phba: pointer to the adapter structure.
1133 * @mxri: max xri count.
1134 * @axri: available xri count.
1135 * @mrpi: max rpi count.
1136 * @arpi: available rpi count.
1137 * @mvpi: max vpi count.
1138 * @avpi: available vpi count.
1141 * If an integer pointer for an count is not null then the value for the
1142 * count is returned.
1149 lpfc_get_hba_info(struct lpfc_hba
*phba
,
1150 uint32_t *mxri
, uint32_t *axri
,
1151 uint32_t *mrpi
, uint32_t *arpi
,
1152 uint32_t *mvpi
, uint32_t *avpi
)
1154 struct lpfc_mbx_read_config
*rd_config
;
1155 LPFC_MBOXQ_t
*pmboxq
;
1161 * prevent udev from issuing mailbox commands until the port is
1164 if (phba
->link_state
< LPFC_LINK_DOWN
||
1165 !phba
->mbox_mem_pool
||
1166 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
1169 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
1172 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1175 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1177 pmb
= &pmboxq
->u
.mb
;
1178 pmb
->mbxCommand
= MBX_READ_CONFIG
;
1179 pmb
->mbxOwner
= OWN_HOST
;
1180 pmboxq
->context1
= NULL
;
1182 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
1183 rc
= MBX_NOT_FINISHED
;
1185 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
1187 if (rc
!= MBX_SUCCESS
) {
1188 if (rc
!= MBX_TIMEOUT
)
1189 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1193 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1194 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
1196 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
1198 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
1199 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
1201 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
1203 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
1204 phba
->sli4_hba
.max_cfg_param
.xri_used
;
1206 /* Account for differences with SLI-3. Get vpi count from
1207 * mailbox data and subtract one for max vpi value.
1209 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
1210 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
1215 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
1218 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
1220 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
1222 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
1224 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
1226 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
1228 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
1231 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1236 * lpfc_max_rpi_show - Return maximum rpi
1237 * @dev: class device that is converted into a Scsi_host.
1238 * @attr: device attribute, not used.
1239 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1242 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1243 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1244 * to "Unknown" and the buffer length is returned, therefore the caller
1245 * must check for "Unknown" in the buffer to detect a failure.
1247 * Returns: size of formatted string.
1250 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1253 struct Scsi_Host
*shost
= class_to_shost(dev
);
1254 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1255 struct lpfc_hba
*phba
= vport
->phba
;
1258 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
1259 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1260 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1264 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1265 * @dev: class device that is converted into a Scsi_host.
1266 * @attr: device attribute, not used.
1267 * @buf: containing the used rpi count in decimal or "Unknown".
1270 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1271 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1272 * to "Unknown" and the buffer length is returned, therefore the caller
1273 * must check for "Unknown" in the buffer to detect a failure.
1275 * Returns: size of formatted string.
1278 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1281 struct Scsi_Host
*shost
= class_to_shost(dev
);
1282 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1283 struct lpfc_hba
*phba
= vport
->phba
;
1286 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1287 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1288 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1292 * lpfc_max_xri_show - Return maximum xri
1293 * @dev: class device that is converted into a Scsi_host.
1294 * @attr: device attribute, not used.
1295 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1298 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1299 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1300 * to "Unknown" and the buffer length is returned, therefore the caller
1301 * must check for "Unknown" in the buffer to detect a failure.
1303 * Returns: size of formatted string.
1306 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1309 struct Scsi_Host
*shost
= class_to_shost(dev
);
1310 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1311 struct lpfc_hba
*phba
= vport
->phba
;
1314 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
1315 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1316 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1320 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1321 * @dev: class device that is converted into a Scsi_host.
1322 * @attr: device attribute, not used.
1323 * @buf: on return contains the used xri count in decimal or "Unknown".
1326 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1327 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1328 * to "Unknown" and the buffer length is returned, therefore the caller
1329 * must check for "Unknown" in the buffer to detect a failure.
1331 * Returns: size of formatted string.
1334 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1337 struct Scsi_Host
*shost
= class_to_shost(dev
);
1338 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1339 struct lpfc_hba
*phba
= vport
->phba
;
1342 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
1343 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1344 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1348 * lpfc_max_vpi_show - Return maximum vpi
1349 * @dev: class device that is converted into a Scsi_host.
1350 * @attr: device attribute, not used.
1351 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1354 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1355 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1356 * to "Unknown" and the buffer length is returned, therefore the caller
1357 * must check for "Unknown" in the buffer to detect a failure.
1359 * Returns: size of formatted string.
1362 lpfc_max_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1365 struct Scsi_Host
*shost
= class_to_shost(dev
);
1366 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1367 struct lpfc_hba
*phba
= vport
->phba
;
1370 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
1371 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1372 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1376 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1377 * @dev: class device that is converted into a Scsi_host.
1378 * @attr: device attribute, not used.
1379 * @buf: on return contains the used vpi count in decimal or "Unknown".
1382 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1383 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1384 * to "Unknown" and the buffer length is returned, therefore the caller
1385 * must check for "Unknown" in the buffer to detect a failure.
1387 * Returns: size of formatted string.
1390 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1393 struct Scsi_Host
*shost
= class_to_shost(dev
);
1394 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1395 struct lpfc_hba
*phba
= vport
->phba
;
1398 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
1399 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1400 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1404 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1405 * @dev: class device that is converted into a Scsi_host.
1406 * @attr: device attribute, not used.
1407 * @buf: text that must be interpreted to determine if npiv is supported.
1410 * Buffer will contain text indicating npiv is not suppoerted on the port,
1411 * the port is an NPIV physical port, or it is an npiv virtual port with
1412 * the id of the vport.
1414 * Returns: size of formatted string.
1417 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
1420 struct Scsi_Host
*shost
= class_to_shost(dev
);
1421 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1422 struct lpfc_hba
*phba
= vport
->phba
;
1424 if (!(phba
->max_vpi
))
1425 return snprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
1426 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1427 return snprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
1428 return snprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
1432 * lpfc_poll_show - Return text about poll support for the adapter
1433 * @dev: class device that is converted into a Scsi_host.
1434 * @attr: device attribute, not used.
1435 * @buf: on return contains the cfg_poll in hex.
1438 * cfg_poll should be a lpfc_polling_flags type.
1440 * Returns: size of formatted string.
1443 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
1446 struct Scsi_Host
*shost
= class_to_shost(dev
);
1447 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1448 struct lpfc_hba
*phba
= vport
->phba
;
1450 return snprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
1454 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1455 * @dev: class device that is converted into a Scsi_host.
1456 * @attr: device attribute, not used.
1457 * @buf: one or more lpfc_polling_flags values.
1461 * buf contents converted to integer and checked for a valid value.
1464 * -EINVAL if the buffer connot be converted or is out of range
1465 * length of the buf on success
1468 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
1469 const char *buf
, size_t count
)
1471 struct Scsi_Host
*shost
= class_to_shost(dev
);
1472 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1473 struct lpfc_hba
*phba
= vport
->phba
;
1478 if (!isdigit(buf
[0]))
1481 if (sscanf(buf
, "%i", &val
) != 1)
1484 if ((val
& 0x3) != val
)
1487 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1490 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1491 "3051 lpfc_poll changed from %d to %d\n",
1492 phba
->cfg_poll
, val
);
1494 spin_lock_irq(&phba
->hbalock
);
1496 old_val
= phba
->cfg_poll
;
1498 if (val
& ENABLE_FCP_RING_POLLING
) {
1499 if ((val
& DISABLE_FCP_RING_INT
) &&
1500 !(old_val
& DISABLE_FCP_RING_INT
)) {
1501 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1502 spin_unlock_irq(&phba
->hbalock
);
1505 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
1506 writel(creg_val
, phba
->HCregaddr
);
1507 readl(phba
->HCregaddr
); /* flush */
1509 lpfc_poll_start_timer(phba
);
1511 } else if (val
!= 0x0) {
1512 spin_unlock_irq(&phba
->hbalock
);
1516 if (!(val
& DISABLE_FCP_RING_INT
) &&
1517 (old_val
& DISABLE_FCP_RING_INT
))
1519 spin_unlock_irq(&phba
->hbalock
);
1520 del_timer(&phba
->fcp_poll_timer
);
1521 spin_lock_irq(&phba
->hbalock
);
1522 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1523 spin_unlock_irq(&phba
->hbalock
);
1526 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
1527 writel(creg_val
, phba
->HCregaddr
);
1528 readl(phba
->HCregaddr
); /* flush */
1531 phba
->cfg_poll
= val
;
1533 spin_unlock_irq(&phba
->hbalock
);
1539 * lpfc_fips_level_show - Return the current FIPS level for the HBA
1540 * @dev: class unused variable.
1541 * @attr: device attribute, not used.
1542 * @buf: on return contains the module description text.
1544 * Returns: size of formatted string.
1547 lpfc_fips_level_show(struct device
*dev
, struct device_attribute
*attr
,
1550 struct Scsi_Host
*shost
= class_to_shost(dev
);
1551 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1552 struct lpfc_hba
*phba
= vport
->phba
;
1554 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_level
);
1558 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
1559 * @dev: class unused variable.
1560 * @attr: device attribute, not used.
1561 * @buf: on return contains the module description text.
1563 * Returns: size of formatted string.
1566 lpfc_fips_rev_show(struct device
*dev
, struct device_attribute
*attr
,
1569 struct Scsi_Host
*shost
= class_to_shost(dev
);
1570 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1571 struct lpfc_hba
*phba
= vport
->phba
;
1573 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_spec_rev
);
1577 * lpfc_dss_show - Return the current state of dss and the configured state
1578 * @dev: class converted to a Scsi_host structure.
1579 * @attr: device attribute, not used.
1580 * @buf: on return contains the formatted text.
1582 * Returns: size of formatted string.
1585 lpfc_dss_show(struct device
*dev
, struct device_attribute
*attr
,
1588 struct Scsi_Host
*shost
= class_to_shost(dev
);
1589 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1590 struct lpfc_hba
*phba
= vport
->phba
;
1592 return snprintf(buf
, PAGE_SIZE
, "%s - %sOperational\n",
1593 (phba
->cfg_enable_dss
) ? "Enabled" : "Disabled",
1594 (phba
->sli3_options
& LPFC_SLI3_DSS_ENABLED
) ?
1599 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
1600 * @dev: class converted to a Scsi_host structure.
1601 * @attr: device attribute, not used.
1602 * @buf: on return contains the formatted support level.
1605 * Returns the maximum number of virtual functions a physical function can
1606 * support, 0 will be returned if called on virtual function.
1608 * Returns: size of formatted string.
1611 lpfc_sriov_hw_max_virtfn_show(struct device
*dev
,
1612 struct device_attribute
*attr
,
1615 struct Scsi_Host
*shost
= class_to_shost(dev
);
1616 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1617 struct lpfc_hba
*phba
= vport
->phba
;
1618 uint16_t max_nr_virtfn
;
1620 max_nr_virtfn
= lpfc_sli_sriov_nr_virtfn_get(phba
);
1621 return snprintf(buf
, PAGE_SIZE
, "%d\n", max_nr_virtfn
);
1624 static inline bool lpfc_rangecheck(uint val
, uint min
, uint max
)
1626 return val
>= min
&& val
<= max
;
1630 * lpfc_param_show - Return a cfg attribute value in decimal
1633 * Macro that given an attr e.g. hba_queue_depth expands
1634 * into a function with the name lpfc_hba_queue_depth_show.
1636 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
1637 * @dev: class device that is converted into a Scsi_host.
1638 * @attr: device attribute, not used.
1639 * @buf: on return contains the attribute value in decimal.
1641 * Returns: size of formatted string.
1643 #define lpfc_param_show(attr) \
1645 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1648 struct Scsi_Host *shost = class_to_shost(dev);\
1649 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1650 struct lpfc_hba *phba = vport->phba;\
1651 return snprintf(buf, PAGE_SIZE, "%d\n",\
1656 * lpfc_param_hex_show - Return a cfg attribute value in hex
1659 * Macro that given an attr e.g. hba_queue_depth expands
1660 * into a function with the name lpfc_hba_queue_depth_show
1662 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
1663 * @dev: class device that is converted into a Scsi_host.
1664 * @attr: device attribute, not used.
1665 * @buf: on return contains the attribute value in hexadecimal.
1667 * Returns: size of formatted string.
1669 #define lpfc_param_hex_show(attr) \
1671 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1674 struct Scsi_Host *shost = class_to_shost(dev);\
1675 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1676 struct lpfc_hba *phba = vport->phba;\
1678 val = phba->cfg_##attr;\
1679 return snprintf(buf, PAGE_SIZE, "%#x\n",\
1684 * lpfc_param_init - Initializes a cfg attribute
1687 * Macro that given an attr e.g. hba_queue_depth expands
1688 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1689 * takes a default argument, a minimum and maximum argument.
1691 * lpfc_##attr##_init: Initializes an attribute.
1692 * @phba: pointer the the adapter structure.
1693 * @val: integer attribute value.
1695 * Validates the min and max values then sets the adapter config field
1696 * accordingly, or uses the default if out of range and prints an error message.
1700 * -EINVAL if default used
1702 #define lpfc_param_init(attr, default, minval, maxval) \
1704 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1706 if (lpfc_rangecheck(val, minval, maxval)) {\
1707 phba->cfg_##attr = val;\
1710 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1711 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
1712 "allowed range is ["#minval", "#maxval"]\n", val); \
1713 phba->cfg_##attr = default;\
1718 * lpfc_param_set - Set a cfg attribute value
1721 * Macro that given an attr e.g. hba_queue_depth expands
1722 * into a function with the name lpfc_hba_queue_depth_set
1724 * lpfc_##attr##_set: Sets an attribute value.
1725 * @phba: pointer the the adapter structure.
1726 * @val: integer attribute value.
1729 * Validates the min and max values then sets the
1730 * adapter config field if in the valid range. prints error message
1731 * and does not set the parameter if invalid.
1735 * -EINVAL if val is invalid
1737 #define lpfc_param_set(attr, default, minval, maxval) \
1739 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
1741 if (lpfc_rangecheck(val, minval, maxval)) {\
1742 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1743 "3052 lpfc_" #attr " changed from %d to %d\n", \
1744 phba->cfg_##attr, val); \
1745 phba->cfg_##attr = val;\
1748 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1749 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
1750 "allowed range is ["#minval", "#maxval"]\n", val); \
1755 * lpfc_param_store - Set a vport attribute value
1758 * Macro that given an attr e.g. hba_queue_depth expands
1759 * into a function with the name lpfc_hba_queue_depth_store.
1761 * lpfc_##attr##_store: Set an sttribute value.
1762 * @dev: class device that is converted into a Scsi_host.
1763 * @attr: device attribute, not used.
1764 * @buf: contains the attribute value in ascii.
1768 * Convert the ascii text number to an integer, then
1769 * use the lpfc_##attr##_set function to set the value.
1772 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1773 * length of buffer upon success.
1775 #define lpfc_param_store(attr) \
1777 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1778 const char *buf, size_t count) \
1780 struct Scsi_Host *shost = class_to_shost(dev);\
1781 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1782 struct lpfc_hba *phba = vport->phba;\
1784 if (!isdigit(buf[0]))\
1786 if (sscanf(buf, "%i", &val) != 1)\
1788 if (lpfc_##attr##_set(phba, val) == 0) \
1789 return strlen(buf);\
1795 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
1798 * Macro that given an attr e.g. hba_queue_depth expands
1799 * into a function with the name lpfc_hba_queue_depth_show
1801 * lpfc_##attr##_show: prints the attribute value in decimal.
1802 * @dev: class device that is converted into a Scsi_host.
1803 * @attr: device attribute, not used.
1804 * @buf: on return contains the attribute value in decimal.
1806 * Returns: length of formatted string.
1808 #define lpfc_vport_param_show(attr) \
1810 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1813 struct Scsi_Host *shost = class_to_shost(dev);\
1814 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1815 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
1819 * lpfc_vport_param_hex_show - Return hex formatted attribute value
1822 * Macro that given an attr e.g.
1823 * hba_queue_depth expands into a function with the name
1824 * lpfc_hba_queue_depth_show
1826 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
1827 * @dev: class device that is converted into a Scsi_host.
1828 * @attr: device attribute, not used.
1829 * @buf: on return contains the attribute value in hexadecimal.
1831 * Returns: length of formatted string.
1833 #define lpfc_vport_param_hex_show(attr) \
1835 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1838 struct Scsi_Host *shost = class_to_shost(dev);\
1839 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1840 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
1844 * lpfc_vport_param_init - Initialize a vport cfg attribute
1847 * Macro that given an attr e.g. hba_queue_depth expands
1848 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1849 * takes a default argument, a minimum and maximum argument.
1851 * lpfc_##attr##_init: validates the min and max values then sets the
1852 * adapter config field accordingly, or uses the default if out of range
1853 * and prints an error message.
1854 * @phba: pointer the the adapter structure.
1855 * @val: integer attribute value.
1859 * -EINVAL if default used
1861 #define lpfc_vport_param_init(attr, default, minval, maxval) \
1863 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
1865 if (lpfc_rangecheck(val, minval, maxval)) {\
1866 vport->cfg_##attr = val;\
1869 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1870 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
1871 "allowed range is ["#minval", "#maxval"]\n", val); \
1872 vport->cfg_##attr = default;\
1877 * lpfc_vport_param_set - Set a vport cfg attribute
1880 * Macro that given an attr e.g. hba_queue_depth expands
1881 * into a function with the name lpfc_hba_queue_depth_set
1883 * lpfc_##attr##_set: validates the min and max values then sets the
1884 * adapter config field if in the valid range. prints error message
1885 * and does not set the parameter if invalid.
1886 * @phba: pointer the the adapter structure.
1887 * @val: integer attribute value.
1891 * -EINVAL if val is invalid
1893 #define lpfc_vport_param_set(attr, default, minval, maxval) \
1895 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
1897 if (lpfc_rangecheck(val, minval, maxval)) {\
1898 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1899 "3053 lpfc_" #attr \
1900 " changed from %d (x%x) to %d (x%x)\n", \
1901 vport->cfg_##attr, vport->cfg_##attr, \
1903 vport->cfg_##attr = val;\
1906 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1907 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
1908 "allowed range is ["#minval", "#maxval"]\n", val); \
1913 * lpfc_vport_param_store - Set a vport attribute
1916 * Macro that given an attr e.g. hba_queue_depth
1917 * expands into a function with the name lpfc_hba_queue_depth_store
1919 * lpfc_##attr##_store: convert the ascii text number to an integer, then
1920 * use the lpfc_##attr##_set function to set the value.
1921 * @cdev: class device that is converted into a Scsi_host.
1922 * @buf: contains the attribute value in decimal.
1926 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1927 * length of buffer upon success.
1929 #define lpfc_vport_param_store(attr) \
1931 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1932 const char *buf, size_t count) \
1934 struct Scsi_Host *shost = class_to_shost(dev);\
1935 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1937 if (!isdigit(buf[0]))\
1939 if (sscanf(buf, "%i", &val) != 1)\
1941 if (lpfc_##attr##_set(vport, val) == 0) \
1942 return strlen(buf);\
1948 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
1949 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
1950 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
1951 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
1952 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
1953 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
1954 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
1955 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
1956 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
1957 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
1958 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
1959 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
1960 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
1961 lpfc_link_state_store
);
1962 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
1963 lpfc_option_rom_version_show
, NULL
);
1964 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
1965 lpfc_num_discovered_ports_show
, NULL
);
1966 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
1967 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
1968 static DEVICE_ATTR(lpfc_drvr_version
, S_IRUGO
, lpfc_drvr_version_show
, NULL
);
1969 static DEVICE_ATTR(lpfc_enable_fip
, S_IRUGO
, lpfc_enable_fip_show
, NULL
);
1970 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
1971 lpfc_board_mode_show
, lpfc_board_mode_store
);
1972 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
1973 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
1974 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
1975 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
1976 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
1977 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
1978 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
1979 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
1980 static DEVICE_ATTR(lpfc_temp_sensor
, S_IRUGO
, lpfc_temp_sensor_show
, NULL
);
1981 static DEVICE_ATTR(lpfc_fips_level
, S_IRUGO
, lpfc_fips_level_show
, NULL
);
1982 static DEVICE_ATTR(lpfc_fips_rev
, S_IRUGO
, lpfc_fips_rev_show
, NULL
);
1983 static DEVICE_ATTR(lpfc_dss
, S_IRUGO
, lpfc_dss_show
, NULL
);
1984 static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn
, S_IRUGO
,
1985 lpfc_sriov_hw_max_virtfn_show
, NULL
);
1986 static DEVICE_ATTR(protocol
, S_IRUGO
, lpfc_sli4_protocol_show
, NULL
);
1987 static DEVICE_ATTR(lpfc_xlane_supported
, S_IRUGO
, lpfc_oas_supported_show
,
1990 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
1993 * lpfc_wwn_set - Convert string to the 8 byte WWN value.
1995 * @cnt: Length of string.
1996 * @wwn: Array to receive converted wwn value.
1999 * -EINVAL if the buffer does not contain a valid wwn
2003 lpfc_wwn_set(const char *buf
, size_t cnt
, char wwn
[])
2007 /* Count may include a LF at end of string */
2008 if (buf
[cnt
-1] == '\n')
2011 if ((cnt
< 16) || (cnt
> 18) || ((cnt
== 17) && (*buf
++ != 'x')) ||
2012 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2015 memset(wwn
, 0, WWN_SZ
);
2017 /* Validate and store the new name */
2018 for (i
= 0, j
= 0; i
< 16; i
++) {
2019 if ((*buf
>= 'a') && (*buf
<= 'f'))
2020 j
= ((j
<< 4) | ((*buf
++ - 'a') + 10));
2021 else if ((*buf
>= 'A') && (*buf
<= 'F'))
2022 j
= ((j
<< 4) | ((*buf
++ - 'A') + 10));
2023 else if ((*buf
>= '0') && (*buf
<= '9'))
2024 j
= ((j
<< 4) | (*buf
++ - '0'));
2028 wwn
[i
/2] = j
& 0xff;
2035 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2036 * @dev: class device that is converted into a Scsi_host.
2037 * @attr: device attribute, not used.
2038 * @buf: containing the string lpfc_soft_wwn_key.
2039 * @count: must be size of lpfc_soft_wwn_key.
2042 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2043 * length of buf indicates success
2046 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
2047 const char *buf
, size_t count
)
2049 struct Scsi_Host
*shost
= class_to_shost(dev
);
2050 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2051 struct lpfc_hba
*phba
= vport
->phba
;
2052 unsigned int cnt
= count
;
2055 * We're doing a simple sanity check for soft_wwpn setting.
2056 * We require that the user write a specific key to enable
2057 * the soft_wwpn attribute to be settable. Once the attribute
2058 * is written, the enable key resets. If further updates are
2059 * desired, the key must be written again to re-enable the
2062 * The "key" is not secret - it is a hardcoded string shown
2063 * here. The intent is to protect against the random user or
2064 * application that is just writing attributes.
2067 /* count may include a LF at end of string */
2068 if (buf
[cnt
-1] == '\n')
2071 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
2072 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
2075 phba
->soft_wwn_enable
= 1;
2078 static DEVICE_ATTR(lpfc_soft_wwn_enable
, S_IWUSR
, NULL
,
2079 lpfc_soft_wwn_enable_store
);
2082 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2083 * @dev: class device that is converted into a Scsi_host.
2084 * @attr: device attribute, not used.
2085 * @buf: on return contains the wwpn in hexadecimal.
2087 * Returns: size of formatted string.
2090 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
2093 struct Scsi_Host
*shost
= class_to_shost(dev
);
2094 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2095 struct lpfc_hba
*phba
= vport
->phba
;
2097 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2098 (unsigned long long)phba
->cfg_soft_wwpn
);
2102 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2103 * @dev class device that is converted into a Scsi_host.
2104 * @attr: device attribute, not used.
2105 * @buf: contains the wwpn in hexadecimal.
2106 * @count: number of wwpn bytes in buf
2109 * -EACCES hba reset not enabled, adapter over temp
2110 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2111 * -EIO error taking adapter offline or online
2112 * value of count on success
2115 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
2116 const char *buf
, size_t count
)
2118 struct Scsi_Host
*shost
= class_to_shost(dev
);
2119 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2120 struct lpfc_hba
*phba
= vport
->phba
;
2121 struct completion online_compl
;
2122 int stat1
= 0, stat2
= 0;
2123 unsigned int cnt
= count
;
2127 if (!phba
->cfg_enable_hba_reset
)
2129 spin_lock_irq(&phba
->hbalock
);
2130 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
2131 spin_unlock_irq(&phba
->hbalock
);
2134 spin_unlock_irq(&phba
->hbalock
);
2135 /* count may include a LF at end of string */
2136 if (buf
[cnt
-1] == '\n')
2139 if (!phba
->soft_wwn_enable
)
2142 /* lock setting wwpn, wwnn down */
2143 phba
->soft_wwn_enable
= 0;
2145 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2147 /* not able to set wwpn, unlock it */
2148 phba
->soft_wwn_enable
= 1;
2152 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
2153 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
2154 if (phba
->cfg_soft_wwnn
)
2155 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
2157 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2158 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
2160 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
2162 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2163 "0463 lpfc_soft_wwpn attribute set failed to "
2164 "reinit adapter - %d\n", stat1
);
2165 init_completion(&online_compl
);
2166 rc
= lpfc_workq_post_event(phba
, &stat2
, &online_compl
,
2171 wait_for_completion(&online_compl
);
2173 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2174 "0464 lpfc_soft_wwpn attribute set failed to "
2175 "reinit adapter - %d\n", stat2
);
2176 return (stat1
|| stat2
) ? -EIO
: count
;
2178 static DEVICE_ATTR(lpfc_soft_wwpn
, S_IRUGO
| S_IWUSR
,
2179 lpfc_soft_wwpn_show
, lpfc_soft_wwpn_store
);
2182 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2183 * @dev: class device that is converted into a Scsi_host.
2184 * @attr: device attribute, not used.
2185 * @buf: on return contains the wwnn in hexadecimal.
2187 * Returns: size of formatted string.
2190 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
2193 struct Scsi_Host
*shost
= class_to_shost(dev
);
2194 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2195 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2196 (unsigned long long)phba
->cfg_soft_wwnn
);
2200 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2201 * @cdev: class device that is converted into a Scsi_host.
2202 * @buf: contains the ww node name in hexadecimal.
2203 * @count: number of wwnn bytes in buf.
2206 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2207 * value of count on success
2210 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
2211 const char *buf
, size_t count
)
2213 struct Scsi_Host
*shost
= class_to_shost(dev
);
2214 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2215 unsigned int cnt
= count
;
2219 /* count may include a LF at end of string */
2220 if (buf
[cnt
-1] == '\n')
2223 if (!phba
->soft_wwn_enable
)
2226 rc
= lpfc_wwn_set(buf
, cnt
, wwnn
);
2228 /* Allow wwnn to be set many times, as long as the enable
2229 * is set. However, once the wwpn is set, everything locks.
2234 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
2236 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2237 "lpfc%d: soft_wwnn set. Value will take effect upon "
2238 "setting of the soft_wwpn\n", phba
->brd_no
);
2242 static DEVICE_ATTR(lpfc_soft_wwnn
, S_IRUGO
| S_IWUSR
,
2243 lpfc_soft_wwnn_show
, lpfc_soft_wwnn_store
);
2246 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for
2247 * Optimized Access Storage (OAS) operations.
2248 * @dev: class device that is converted into a Scsi_host.
2249 * @attr: device attribute, not used.
2250 * @buf: buffer for passing information.
2256 lpfc_oas_tgt_show(struct device
*dev
, struct device_attribute
*attr
,
2259 struct Scsi_Host
*shost
= class_to_shost(dev
);
2260 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2262 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2263 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
));
2267 * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for
2268 * Optimized Access Storage (OAS) operations.
2269 * @dev: class device that is converted into a Scsi_host.
2270 * @attr: device attribute, not used.
2271 * @buf: buffer for passing information.
2272 * @count: Size of the data buffer.
2275 * -EINVAL count is invalid, invalid wwpn byte invalid
2276 * -EPERM oas is not supported by hba
2277 * value of count on success
2280 lpfc_oas_tgt_store(struct device
*dev
, struct device_attribute
*attr
,
2281 const char *buf
, size_t count
)
2283 struct Scsi_Host
*shost
= class_to_shost(dev
);
2284 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2285 unsigned int cnt
= count
;
2286 uint8_t wwpn
[WWN_SZ
];
2292 /* count may include a LF at end of string */
2293 if (buf
[cnt
-1] == '\n')
2296 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2300 memcpy(phba
->cfg_oas_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2301 memcpy(phba
->sli4_hba
.oas_next_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2302 if (wwn_to_u64(wwpn
) == 0)
2303 phba
->cfg_oas_flags
|= OAS_FIND_ANY_TARGET
;
2305 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_TARGET
;
2306 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2307 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2310 static DEVICE_ATTR(lpfc_xlane_tgt
, S_IRUGO
| S_IWUSR
,
2311 lpfc_oas_tgt_show
, lpfc_oas_tgt_store
);
2314 * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for
2315 * Optimized Access Storage (OAS) operations.
2316 * @dev: class device that is converted into a Scsi_host.
2317 * @attr: device attribute, not used.
2318 * @buf: buffer for passing information.
2324 lpfc_oas_priority_show(struct device
*dev
, struct device_attribute
*attr
,
2327 struct Scsi_Host
*shost
= class_to_shost(dev
);
2328 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2330 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_priority
);
2334 * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for
2335 * Optimized Access Storage (OAS) operations.
2336 * @dev: class device that is converted into a Scsi_host.
2337 * @attr: device attribute, not used.
2338 * @buf: buffer for passing information.
2339 * @count: Size of the data buffer.
2342 * -EINVAL count is invalid, invalid wwpn byte invalid
2343 * -EPERM oas is not supported by hba
2344 * value of count on success
2347 lpfc_oas_priority_store(struct device
*dev
, struct device_attribute
*attr
,
2348 const char *buf
, size_t count
)
2350 struct Scsi_Host
*shost
= class_to_shost(dev
);
2351 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2352 unsigned int cnt
= count
;
2359 /* count may include a LF at end of string */
2360 if (buf
[cnt
-1] == '\n')
2363 ret
= kstrtoul(buf
, 0, &val
);
2364 if (ret
|| (val
> 0x7f))
2368 phba
->cfg_oas_priority
= (uint8_t)val
;
2370 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
2373 static DEVICE_ATTR(lpfc_xlane_priority
, S_IRUGO
| S_IWUSR
,
2374 lpfc_oas_priority_show
, lpfc_oas_priority_store
);
2377 * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled
2378 * for Optimized Access Storage (OAS) operations.
2379 * @dev: class device that is converted into a Scsi_host.
2380 * @attr: device attribute, not used.
2381 * @buf: buffer for passing information.
2384 * value of count on success
2387 lpfc_oas_vpt_show(struct device
*dev
, struct device_attribute
*attr
,
2390 struct Scsi_Host
*shost
= class_to_shost(dev
);
2391 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2393 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2394 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
));
2398 * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled
2399 * for Optimized Access Storage (OAS) operations.
2400 * @dev: class device that is converted into a Scsi_host.
2401 * @attr: device attribute, not used.
2402 * @buf: buffer for passing information.
2403 * @count: Size of the data buffer.
2406 * -EINVAL count is invalid, invalid wwpn byte invalid
2407 * -EPERM oas is not supported by hba
2408 * value of count on success
2411 lpfc_oas_vpt_store(struct device
*dev
, struct device_attribute
*attr
,
2412 const char *buf
, size_t count
)
2414 struct Scsi_Host
*shost
= class_to_shost(dev
);
2415 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2416 unsigned int cnt
= count
;
2417 uint8_t wwpn
[WWN_SZ
];
2423 /* count may include a LF at end of string */
2424 if (buf
[cnt
-1] == '\n')
2427 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2431 memcpy(phba
->cfg_oas_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2432 memcpy(phba
->sli4_hba
.oas_next_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2433 if (wwn_to_u64(wwpn
) == 0)
2434 phba
->cfg_oas_flags
|= OAS_FIND_ANY_VPORT
;
2436 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_VPORT
;
2437 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2438 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
2439 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2442 static DEVICE_ATTR(lpfc_xlane_vpt
, S_IRUGO
| S_IWUSR
,
2443 lpfc_oas_vpt_show
, lpfc_oas_vpt_store
);
2446 * lpfc_oas_lun_state_show - Return the current state (enabled or disabled)
2447 * of whether luns will be enabled or disabled
2448 * for Optimized Access Storage (OAS) operations.
2449 * @dev: class device that is converted into a Scsi_host.
2450 * @attr: device attribute, not used.
2451 * @buf: buffer for passing information.
2454 * size of formatted string.
2457 lpfc_oas_lun_state_show(struct device
*dev
, struct device_attribute
*attr
,
2460 struct Scsi_Host
*shost
= class_to_shost(dev
);
2461 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2463 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_state
);
2467 * lpfc_oas_lun_state_store - Store the state (enabled or disabled)
2468 * of whether luns will be enabled or disabled
2469 * for Optimized Access Storage (OAS) operations.
2470 * @dev: class device that is converted into a Scsi_host.
2471 * @attr: device attribute, not used.
2472 * @buf: buffer for passing information.
2473 * @count: Size of the data buffer.
2476 * -EINVAL count is invalid, invalid wwpn byte invalid
2477 * -EPERM oas is not supported by hba
2478 * value of count on success
2481 lpfc_oas_lun_state_store(struct device
*dev
, struct device_attribute
*attr
,
2482 const char *buf
, size_t count
)
2484 struct Scsi_Host
*shost
= class_to_shost(dev
);
2485 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2491 if (!isdigit(buf
[0]))
2494 if (sscanf(buf
, "%i", &val
) != 1)
2497 if ((val
!= 0) && (val
!= 1))
2500 phba
->cfg_oas_lun_state
= val
;
2503 static DEVICE_ATTR(lpfc_xlane_lun_state
, S_IRUGO
| S_IWUSR
,
2504 lpfc_oas_lun_state_show
, lpfc_oas_lun_state_store
);
2507 * lpfc_oas_lun_status_show - Return the status of the Optimized Access
2508 * Storage (OAS) lun returned by the
2509 * lpfc_oas_lun_show function.
2510 * @dev: class device that is converted into a Scsi_host.
2511 * @attr: device attribute, not used.
2512 * @buf: buffer for passing information.
2515 * size of formatted string.
2518 lpfc_oas_lun_status_show(struct device
*dev
, struct device_attribute
*attr
,
2521 struct Scsi_Host
*shost
= class_to_shost(dev
);
2522 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2524 if (!(phba
->cfg_oas_flags
& OAS_LUN_VALID
))
2527 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_status
);
2529 static DEVICE_ATTR(lpfc_xlane_lun_status
, S_IRUGO
,
2530 lpfc_oas_lun_status_show
, NULL
);
2534 * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage
2536 * @phba: lpfc_hba pointer.
2537 * @ndlp: pointer to fcp target node.
2538 * @lun: the fc lun for setting oas state.
2539 * @oas_state: the oas state to be set to the lun.
2543 * -EPERM OAS is not enabled or not supported by this port.
2547 lpfc_oas_lun_state_set(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2548 uint8_t tgt_wwpn
[], uint64_t lun
,
2549 uint32_t oas_state
, uint8_t pri
)
2558 if (!lpfc_enable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2559 (struct lpfc_name
*)tgt_wwpn
,
2563 lpfc_disable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2564 (struct lpfc_name
*)tgt_wwpn
, lun
);
2571 * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized
2572 * Access Storage (OAS) operations.
2573 * @phba: lpfc_hba pointer.
2574 * @vpt_wwpn: wwpn of the vport associated with the returned lun
2575 * @tgt_wwpn: wwpn of the target associated with the returned lun
2576 * @lun_status: status of the lun returned lun
2578 * Returns the first or next lun enabled for OAS operations for the vport/target
2579 * specified. If a lun is found, its vport wwpn, target wwpn and status is
2580 * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned.
2583 * lun that is OAS enabled for the vport/target
2584 * NOT_OAS_ENABLED_LUN when no oas enabled lun found.
2587 lpfc_oas_lun_get_next(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2588 uint8_t tgt_wwpn
[], uint32_t *lun_status
)
2592 if (unlikely(!phba
) || !vpt_wwpn
|| !tgt_wwpn
)
2593 return NOT_OAS_ENABLED_LUN
;
2594 if (lpfc_find_next_oas_lun(phba
, (struct lpfc_name
*)
2595 phba
->sli4_hba
.oas_next_vpt_wwpn
,
2596 (struct lpfc_name
*)
2597 phba
->sli4_hba
.oas_next_tgt_wwpn
,
2598 &phba
->sli4_hba
.oas_next_lun
,
2599 (struct lpfc_name
*)vpt_wwpn
,
2600 (struct lpfc_name
*)tgt_wwpn
,
2601 &found_lun
, lun_status
))
2604 return NOT_OAS_ENABLED_LUN
;
2608 * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations
2609 * @phba: lpfc_hba pointer.
2610 * @vpt_wwpn: vport wwpn by reference.
2611 * @tgt_wwpn: target wwpn by reference.
2612 * @lun: the fc lun for setting oas state.
2613 * @oas_state: the oas state to be set to the oas_lun.
2615 * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE)
2616 * a lun for OAS operations.
2620 * -ENOMEM: failed to enable an lun for OAS operations
2621 * -EPERM: OAS is not enabled
2624 lpfc_oas_lun_state_change(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2625 uint8_t tgt_wwpn
[], uint64_t lun
,
2626 uint32_t oas_state
, uint8_t pri
)
2631 rc
= lpfc_oas_lun_state_set(phba
, vpt_wwpn
, tgt_wwpn
, lun
,
2637 * lpfc_oas_lun_show - Return oas enabled luns from a chosen target
2638 * @dev: class device that is converted into a Scsi_host.
2639 * @attr: device attribute, not used.
2640 * @buf: buffer for passing information.
2642 * This routine returns a lun enabled for OAS each time the function
2646 * SUCCESS: size of formatted string.
2647 * -EFAULT: target or vport wwpn was not set properly.
2648 * -EPERM: oas is not enabled.
2651 lpfc_oas_lun_show(struct device
*dev
, struct device_attribute
*attr
,
2654 struct Scsi_Host
*shost
= class_to_shost(dev
);
2655 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2663 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
2664 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_VPORT
))
2667 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
2668 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_TARGET
))
2671 oas_lun
= lpfc_oas_lun_get_next(phba
, phba
->cfg_oas_vpt_wwpn
,
2672 phba
->cfg_oas_tgt_wwpn
,
2673 &phba
->cfg_oas_lun_status
);
2674 if (oas_lun
!= NOT_OAS_ENABLED_LUN
)
2675 phba
->cfg_oas_flags
|= OAS_LUN_VALID
;
2677 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "0x%llx", oas_lun
);
2683 * lpfc_oas_lun_store - Sets the OAS state for lun
2684 * @dev: class device that is converted into a Scsi_host.
2685 * @attr: device attribute, not used.
2686 * @buf: buffer for passing information.
2688 * This function sets the OAS state for lun. Before this function is called,
2689 * the vport wwpn, target wwpn, and oas state need to be set.
2692 * SUCCESS: size of formatted string.
2693 * -EFAULT: target or vport wwpn was not set properly.
2694 * -EPERM: oas is not enabled.
2695 * size of formatted string.
2698 lpfc_oas_lun_store(struct device
*dev
, struct device_attribute
*attr
,
2699 const char *buf
, size_t count
)
2701 struct Scsi_Host
*shost
= class_to_shost(dev
);
2702 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2709 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
2712 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
2715 if (!isdigit(buf
[0]))
2718 if (sscanf(buf
, "0x%llx", &scsi_lun
) != 1)
2721 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
,
2722 "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx "
2723 "priority 0x%x with oas state %d\n",
2724 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
),
2725 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
), scsi_lun
,
2726 phba
->cfg_oas_priority
, phba
->cfg_oas_lun_state
);
2728 rc
= lpfc_oas_lun_state_change(phba
, phba
->cfg_oas_vpt_wwpn
,
2729 phba
->cfg_oas_tgt_wwpn
, scsi_lun
,
2730 phba
->cfg_oas_lun_state
,
2731 phba
->cfg_oas_priority
);
2737 static DEVICE_ATTR(lpfc_xlane_lun
, S_IRUGO
| S_IWUSR
,
2738 lpfc_oas_lun_show
, lpfc_oas_lun_store
);
2740 static int lpfc_poll
= 0;
2741 module_param(lpfc_poll
, int, S_IRUGO
);
2742 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
2744 " 1 - poll with interrupts enabled"
2745 " 3 - poll and disable FCP ring interrupts");
2747 static DEVICE_ATTR(lpfc_poll
, S_IRUGO
| S_IWUSR
,
2748 lpfc_poll_show
, lpfc_poll_store
);
2750 LPFC_ATTR(sli_mode
, 0, 0, 3,
2751 "SLI mode selector:"
2752 " 0 - auto (SLI-3 if supported),"
2753 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
2754 " 3 - select SLI-3");
2756 LPFC_ATTR_R(enable_npiv
, 1, 0, 1,
2757 "Enable NPIV functionality");
2759 LPFC_ATTR_R(fcf_failover_policy
, 1, 1, 2,
2760 "FCF Fast failover=1 Priority failover=2");
2763 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
2764 # 0x0 = disabled, XRI/OXID use not tracked.
2765 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
2766 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
2768 LPFC_ATTR_R(enable_rrq
, 2, 0, 2,
2769 "Enable RRQ functionality");
2772 # lpfc_suppress_link_up: Bring link up at initialization
2773 # 0x0 = bring link up (issue MBX_INIT_LINK)
2774 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
2775 # 0x2 = never bring up link
2776 # Default value is 0.
2778 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
2779 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
2780 "Suppress Link Up at initialization");
2782 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
2790 lpfc_iocb_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
2792 struct Scsi_Host
*shost
= class_to_shost(dev
);
2793 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2795 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->iocb_max
);
2798 static DEVICE_ATTR(iocb_hw
, S_IRUGO
,
2799 lpfc_iocb_hw_show
, NULL
);
2801 lpfc_txq_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
2803 struct Scsi_Host
*shost
= class_to_shost(dev
);
2804 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2806 return snprintf(buf
, PAGE_SIZE
, "%d\n",
2807 phba
->sli
.ring
[LPFC_ELS_RING
].txq_max
);
2810 static DEVICE_ATTR(txq_hw
, S_IRUGO
,
2811 lpfc_txq_hw_show
, NULL
);
2813 lpfc_txcmplq_hw_show(struct device
*dev
, struct device_attribute
*attr
,
2816 struct Scsi_Host
*shost
= class_to_shost(dev
);
2817 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
2819 return snprintf(buf
, PAGE_SIZE
, "%d\n",
2820 phba
->sli
.ring
[LPFC_ELS_RING
].txcmplq_max
);
2823 static DEVICE_ATTR(txcmplq_hw
, S_IRUGO
,
2824 lpfc_txcmplq_hw_show
, NULL
);
2826 LPFC_ATTR_R(iocb_cnt
, 2, 1, 5,
2827 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
2830 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
2831 # until the timer expires. Value range is [0,255]. Default value is 30.
2833 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2834 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2835 module_param(lpfc_nodev_tmo
, int, 0);
2836 MODULE_PARM_DESC(lpfc_nodev_tmo
,
2837 "Seconds driver will hold I/O waiting "
2838 "for a device to come back");
2841 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
2842 * @dev: class converted to a Scsi_host structure.
2843 * @attr: device attribute, not used.
2844 * @buf: on return contains the dev loss timeout in decimal.
2846 * Returns: size of formatted string.
2849 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
2852 struct Scsi_Host
*shost
= class_to_shost(dev
);
2853 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2855 return snprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
2859 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
2860 * @vport: lpfc vport structure pointer.
2861 * @val: contains the nodev timeout value.
2864 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
2865 * a kernel error message is printed and zero is returned.
2866 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2867 * Otherwise nodev tmo is set to the default value.
2870 * zero if already set or if val is in range
2871 * -EINVAL val out of range
2874 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
2876 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
2877 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
2878 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
2879 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2880 "0407 Ignoring lpfc_nodev_tmo module "
2881 "parameter because lpfc_devloss_tmo "
2886 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2887 vport
->cfg_nodev_tmo
= val
;
2888 vport
->cfg_devloss_tmo
= val
;
2891 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2892 "0400 lpfc_nodev_tmo attribute cannot be set to"
2893 " %d, allowed range is [%d, %d]\n",
2894 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2895 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2900 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
2901 * @vport: lpfc vport structure pointer.
2904 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
2907 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
2909 struct Scsi_Host
*shost
;
2910 struct lpfc_nodelist
*ndlp
;
2912 shost
= lpfc_shost_from_vport(vport
);
2913 spin_lock_irq(shost
->host_lock
);
2914 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
)
2915 if (NLP_CHK_NODE_ACT(ndlp
) && ndlp
->rport
)
2916 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
2917 spin_unlock_irq(shost
->host_lock
);
2921 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
2922 * @vport: lpfc vport structure pointer.
2923 * @val: contains the tmo value.
2926 * If the devloss tmo is already set or the vport dev loss tmo has changed
2927 * then a kernel error message is printed and zero is returned.
2928 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2929 * Otherwise nodev tmo is set to the default value.
2932 * zero if already set or if val is in range
2933 * -EINVAL val out of range
2936 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
2938 if (vport
->dev_loss_tmo_changed
||
2939 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
2940 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2941 "0401 Ignoring change to lpfc_nodev_tmo "
2942 "because lpfc_devloss_tmo is set.\n");
2945 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2946 vport
->cfg_nodev_tmo
= val
;
2947 vport
->cfg_devloss_tmo
= val
;
2949 * For compat: set the fc_host dev loss so new rports
2950 * will get the value.
2952 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
2953 lpfc_update_rport_devloss_tmo(vport
);
2956 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2957 "0403 lpfc_nodev_tmo attribute cannot be set to "
2958 "%d, allowed range is [%d, %d]\n",
2959 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2963 lpfc_vport_param_store(nodev_tmo
)
2965 static DEVICE_ATTR(lpfc_nodev_tmo
, S_IRUGO
| S_IWUSR
,
2966 lpfc_nodev_tmo_show
, lpfc_nodev_tmo_store
);
2969 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
2970 # disappear until the timer expires. Value range is [0,255]. Default
2973 module_param(lpfc_devloss_tmo
, int, S_IRUGO
);
2974 MODULE_PARM_DESC(lpfc_devloss_tmo
,
2975 "Seconds driver will hold I/O waiting "
2976 "for a device to come back");
2977 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
2978 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
2979 lpfc_vport_param_show(devloss_tmo
)
2982 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
2983 * @vport: lpfc vport structure pointer.
2984 * @val: contains the tmo value.
2987 * If val is in a valid range then set the vport nodev tmo,
2988 * devloss tmo, also set the vport dev loss tmo changed flag.
2989 * Else a kernel error message is printed.
2992 * zero if val is in range
2993 * -EINVAL val out of range
2996 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
2998 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2999 vport
->cfg_nodev_tmo
= val
;
3000 vport
->cfg_devloss_tmo
= val
;
3001 vport
->dev_loss_tmo_changed
= 1;
3002 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3003 lpfc_update_rport_devloss_tmo(vport
);
3007 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3008 "0404 lpfc_devloss_tmo attribute cannot be set to "
3009 "%d, allowed range is [%d, %d]\n",
3010 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3014 lpfc_vport_param_store(devloss_tmo
)
3015 static DEVICE_ATTR(lpfc_devloss_tmo
, S_IRUGO
| S_IWUSR
,
3016 lpfc_devloss_tmo_show
, lpfc_devloss_tmo_store
);
3019 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
3020 # deluged with LOTS of information.
3021 # You can set a bit mask to record specific types of verbose messages:
3022 # See lpfc_logmsh.h for definitions.
3024 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
3025 "Verbose logging bit-mask");
3028 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
3029 # objects that have been registered with the nameserver after login.
3031 LPFC_VPORT_ATTR_R(enable_da_id
, 1, 0, 1,
3032 "Deregister nameserver objects before LOGO");
3035 # lun_queue_depth: This parameter is used to limit the number of outstanding
3036 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
3037 # If this parameter value is greater than 1/8th the maximum number of exchanges
3038 # supported by the HBA port, then the lun queue depth will be reduced to
3039 # 1/8th the maximum number of exchanges.
3041 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 512,
3042 "Max number of FCP commands we can queue to a specific LUN");
3045 # tgt_queue_depth: This parameter is used to limit the number of outstanding
3046 # commands per target port. Value range is [10,65535]. Default value is 65535.
3048 LPFC_VPORT_ATTR_R(tgt_queue_depth
, 65535, 10, 65535,
3049 "Max number of FCP commands we can queue to a specific target port");
3052 # hba_queue_depth: This parameter is used to limit the number of outstanding
3053 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
3054 # value is greater than the maximum number of exchanges supported by the HBA,
3055 # then maximum number of exchanges supported by the HBA is used to determine
3056 # the hba_queue_depth.
3058 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
3059 "Max number of FCP commands we can queue to a lpfc HBA");
3062 # peer_port_login: This parameter allows/prevents logins
3063 # between peer ports hosted on the same physical port.
3064 # When this parameter is set 0 peer ports of same physical port
3065 # are not allowed to login to each other.
3066 # When this parameter is set 1 peer ports of same physical port
3067 # are allowed to login to each other.
3068 # Default value of this parameter is 0.
3070 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
3071 "Allow peer ports on the same physical port to login to each "
3075 # restrict_login: This parameter allows/prevents logins
3076 # between Virtual Ports and remote initiators.
3077 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
3078 # other initiators and will attempt to PLOGI all remote ports.
3079 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
3080 # remote ports and will not attempt to PLOGI to other initiators.
3081 # This parameter does not restrict to the physical port.
3082 # This parameter does not restrict logins to Fabric resident remote ports.
3083 # Default value of this parameter is 1.
3085 static int lpfc_restrict_login
= 1;
3086 module_param(lpfc_restrict_login
, int, S_IRUGO
);
3087 MODULE_PARM_DESC(lpfc_restrict_login
,
3088 "Restrict virtual ports login to remote initiators.");
3089 lpfc_vport_param_show(restrict_login
);
3092 * lpfc_restrict_login_init - Set the vport restrict login flag
3093 * @vport: lpfc vport structure pointer.
3094 * @val: contains the restrict login value.
3097 * If val is not in a valid range then log a kernel error message and set
3098 * the vport restrict login to one.
3099 * If the port type is physical clear the restrict login flag and return.
3100 * Else set the restrict login flag to val.
3103 * zero if val is in range
3104 * -EINVAL val out of range
3107 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
3109 if (val
< 0 || val
> 1) {
3110 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3111 "0422 lpfc_restrict_login attribute cannot "
3112 "be set to %d, allowed range is [0, 1]\n",
3114 vport
->cfg_restrict_login
= 1;
3117 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
3118 vport
->cfg_restrict_login
= 0;
3121 vport
->cfg_restrict_login
= val
;
3126 * lpfc_restrict_login_set - Set the vport restrict login flag
3127 * @vport: lpfc vport structure pointer.
3128 * @val: contains the restrict login value.
3131 * If val is not in a valid range then log a kernel error message and set
3132 * the vport restrict login to one.
3133 * If the port type is physical and the val is not zero log a kernel
3134 * error message, clear the restrict login flag and return zero.
3135 * Else set the restrict login flag to val.
3138 * zero if val is in range
3139 * -EINVAL val out of range
3142 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
3144 if (val
< 0 || val
> 1) {
3145 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3146 "0425 lpfc_restrict_login attribute cannot "
3147 "be set to %d, allowed range is [0, 1]\n",
3149 vport
->cfg_restrict_login
= 1;
3152 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
3153 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3154 "0468 lpfc_restrict_login must be 0 for "
3155 "Physical ports.\n");
3156 vport
->cfg_restrict_login
= 0;
3159 vport
->cfg_restrict_login
= val
;
3162 lpfc_vport_param_store(restrict_login
);
3163 static DEVICE_ATTR(lpfc_restrict_login
, S_IRUGO
| S_IWUSR
,
3164 lpfc_restrict_login_show
, lpfc_restrict_login_store
);
3167 # Some disk devices have a "select ID" or "select Target" capability.
3168 # From a protocol standpoint "select ID" usually means select the
3169 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
3170 # annex" which contains a table that maps a "select ID" (a number
3171 # between 0 and 7F) to an ALPA. By default, for compatibility with
3172 # older drivers, the lpfc driver scans this table from low ALPA to high
3175 # Turning on the scan-down variable (on = 1, off = 0) will
3176 # cause the lpfc driver to use an inverted table, effectively
3177 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
3179 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
3180 # and will not work across a fabric. Also this parameter will take
3181 # effect only in the case when ALPA map is not available.)
3183 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
3184 "Start scanning for devices from highest ALPA to lowest");
3187 # lpfc_topology: link topology for init link
3188 # 0x0 = attempt loop mode then point-to-point
3189 # 0x01 = internal loopback mode
3190 # 0x02 = attempt point-to-point mode only
3191 # 0x04 = attempt loop mode only
3192 # 0x06 = attempt point-to-point mode then loop
3193 # Set point-to-point mode if you want to run as an N_Port.
3194 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
3195 # Default value is 0.
3197 LPFC_ATTR(topology
, 0, 0, 6,
3198 "Select Fibre Channel topology");
3201 * lpfc_topology_set - Set the adapters topology field
3202 * @phba: lpfc_hba pointer.
3203 * @val: topology value.
3206 * If val is in a valid range then set the adapter's topology field and
3207 * issue a lip; if the lip fails reset the topology to the old value.
3209 * If the value is not in range log a kernel error message and return an error.
3212 * zero if val is in range and lip okay
3213 * non-zero return value from lpfc_issue_lip()
3214 * -EINVAL val out of range
3217 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
3218 const char *buf
, size_t count
)
3220 struct Scsi_Host
*shost
= class_to_shost(dev
);
3221 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3222 struct lpfc_hba
*phba
= vport
->phba
;
3225 const char *val_buf
= buf
;
3229 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
3231 val_buf
= &buf
[strlen("nolip ")];
3234 if (!isdigit(val_buf
[0]))
3236 if (sscanf(val_buf
, "%i", &val
) != 1)
3239 if (val
>= 0 && val
<= 6) {
3240 prev_val
= phba
->cfg_topology
;
3241 if (phba
->cfg_link_speed
== LPFC_USER_LINK_SPEED_16G
&&
3243 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3244 "3113 Loop mode not supported at speed %d\n",
3248 if (phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G6_FC
&&
3250 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3251 "3114 Loop mode not supported\n");
3254 phba
->cfg_topology
= val
;
3258 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3259 "3054 lpfc_topology changed from %d to %d\n",
3261 if (prev_val
!= val
&& phba
->sli_rev
== LPFC_SLI_REV4
)
3262 phba
->fc_topology_changed
= 1;
3263 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
3265 phba
->cfg_topology
= prev_val
;
3270 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3271 "%d:0467 lpfc_topology attribute cannot be set to %d, "
3272 "allowed range is [0, 6]\n",
3277 lpfc_param_show(topology
)
3278 static DEVICE_ATTR(lpfc_topology
, S_IRUGO
| S_IWUSR
,
3279 lpfc_topology_show
, lpfc_topology_store
);
3282 * lpfc_static_vport_show: Read callback function for
3283 * lpfc_static_vport sysfs file.
3284 * @dev: Pointer to class device object.
3285 * @attr: device attribute structure.
3286 * @buf: Data buffer.
3288 * This function is the read call back function for
3289 * lpfc_static_vport sysfs file. The lpfc_static_vport
3290 * sysfs file report the mageability of the vport.
3293 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
3296 struct Scsi_Host
*shost
= class_to_shost(dev
);
3297 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3298 if (vport
->vport_flag
& STATIC_VPORT
)
3299 sprintf(buf
, "1\n");
3301 sprintf(buf
, "0\n");
3307 * Sysfs attribute to control the statistical data collection.
3309 static DEVICE_ATTR(lpfc_static_vport
, S_IRUGO
,
3310 lpfc_static_vport_show
, NULL
);
3313 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
3314 * @dev: Pointer to class device.
3315 * @buf: Data buffer.
3316 * @count: Size of the data buffer.
3318 * This function get called when an user write to the lpfc_stat_data_ctrl
3319 * sysfs file. This function parse the command written to the sysfs file
3320 * and take appropriate action. These commands are used for controlling
3321 * driver statistical data collection.
3322 * Following are the command this function handles.
3324 * setbucket <bucket_type> <base> <step>
3325 * = Set the latency buckets.
3326 * destroybucket = destroy all the buckets.
3327 * start = start data collection
3328 * stop = stop data collection
3329 * reset = reset the collected data
3332 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
3333 const char *buf
, size_t count
)
3335 struct Scsi_Host
*shost
= class_to_shost(dev
);
3336 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3337 struct lpfc_hba
*phba
= vport
->phba
;
3338 #define LPFC_MAX_DATA_CTRL_LEN 1024
3339 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
3341 char *str_ptr
, *token
;
3342 struct lpfc_vport
**vports
;
3343 struct Scsi_Host
*v_shost
;
3344 char *bucket_type_str
, *base_str
, *step_str
;
3345 unsigned long base
, step
, bucket_type
;
3347 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
3348 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
3351 strncpy(bucket_data
, buf
, LPFC_MAX_DATA_CTRL_LEN
);
3352 str_ptr
= &bucket_data
[0];
3353 /* Ignore this token - this is command token */
3354 token
= strsep(&str_ptr
, "\t ");
3358 bucket_type_str
= strsep(&str_ptr
, "\t ");
3359 if (!bucket_type_str
)
3362 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
3363 bucket_type
= LPFC_LINEAR_BUCKET
;
3364 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
3365 bucket_type
= LPFC_POWER2_BUCKET
;
3369 base_str
= strsep(&str_ptr
, "\t ");
3372 base
= simple_strtoul(base_str
, NULL
, 0);
3374 step_str
= strsep(&str_ptr
, "\t ");
3377 step
= simple_strtoul(step_str
, NULL
, 0);
3381 /* Block the data collection for every vport */
3382 vports
= lpfc_create_vport_work_array(phba
);
3386 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3387 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3388 spin_lock_irq(v_shost
->host_lock
);
3389 /* Block and reset data collection */
3390 vports
[i
]->stat_data_blocked
= 1;
3391 if (vports
[i
]->stat_data_enabled
)
3392 lpfc_vport_reset_stat_data(vports
[i
]);
3393 spin_unlock_irq(v_shost
->host_lock
);
3396 /* Set the bucket attributes */
3397 phba
->bucket_type
= bucket_type
;
3398 phba
->bucket_base
= base
;
3399 phba
->bucket_step
= step
;
3401 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3402 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3404 /* Unblock data collection */
3405 spin_lock_irq(v_shost
->host_lock
);
3406 vports
[i
]->stat_data_blocked
= 0;
3407 spin_unlock_irq(v_shost
->host_lock
);
3409 lpfc_destroy_vport_work_array(phba
, vports
);
3413 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
3414 vports
= lpfc_create_vport_work_array(phba
);
3418 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3419 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3420 spin_lock_irq(shost
->host_lock
);
3421 vports
[i
]->stat_data_blocked
= 1;
3422 lpfc_free_bucket(vport
);
3423 vport
->stat_data_enabled
= 0;
3424 vports
[i
]->stat_data_blocked
= 0;
3425 spin_unlock_irq(shost
->host_lock
);
3427 lpfc_destroy_vport_work_array(phba
, vports
);
3428 phba
->bucket_type
= LPFC_NO_BUCKET
;
3429 phba
->bucket_base
= 0;
3430 phba
->bucket_step
= 0;
3434 if (!strncmp(buf
, "start", strlen("start"))) {
3435 /* If no buckets configured return error */
3436 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
3438 spin_lock_irq(shost
->host_lock
);
3439 if (vport
->stat_data_enabled
) {
3440 spin_unlock_irq(shost
->host_lock
);
3443 lpfc_alloc_bucket(vport
);
3444 vport
->stat_data_enabled
= 1;
3445 spin_unlock_irq(shost
->host_lock
);
3449 if (!strncmp(buf
, "stop", strlen("stop"))) {
3450 spin_lock_irq(shost
->host_lock
);
3451 if (vport
->stat_data_enabled
== 0) {
3452 spin_unlock_irq(shost
->host_lock
);
3455 lpfc_free_bucket(vport
);
3456 vport
->stat_data_enabled
= 0;
3457 spin_unlock_irq(shost
->host_lock
);
3461 if (!strncmp(buf
, "reset", strlen("reset"))) {
3462 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
3463 || !vport
->stat_data_enabled
)
3465 spin_lock_irq(shost
->host_lock
);
3466 vport
->stat_data_blocked
= 1;
3467 lpfc_vport_reset_stat_data(vport
);
3468 vport
->stat_data_blocked
= 0;
3469 spin_unlock_irq(shost
->host_lock
);
3477 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
3478 * @dev: Pointer to class device object.
3479 * @buf: Data buffer.
3481 * This function is the read call back function for
3482 * lpfc_stat_data_ctrl sysfs file. This function report the
3483 * current statistical data collection state.
3486 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
3489 struct Scsi_Host
*shost
= class_to_shost(dev
);
3490 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3491 struct lpfc_hba
*phba
= vport
->phba
;
3495 unsigned long bucket_value
;
3497 switch (phba
->bucket_type
) {
3498 case LPFC_LINEAR_BUCKET
:
3499 bucket_type
= "linear";
3501 case LPFC_POWER2_BUCKET
:
3502 bucket_type
= "power2";
3505 bucket_type
= "No Bucket";
3509 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
3510 "blocked :%d, Bucket type :%s, Bucket base :%d,"
3511 " Bucket step :%d\nLatency Ranges :",
3512 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
3513 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
3514 index
= strlen(buf
);
3515 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
3516 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3517 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
3518 bucket_value
= phba
->bucket_base
+
3519 phba
->bucket_step
* i
;
3521 bucket_value
= phba
->bucket_base
+
3522 (1 << i
) * phba
->bucket_step
;
3524 if (index
+ 10 > PAGE_SIZE
)
3526 sprintf(&buf
[index
], "%08ld ", bucket_value
);
3527 index
= strlen(buf
);
3530 sprintf(&buf
[index
], "\n");
3535 * Sysfs attribute to control the statistical data collection.
3537 static DEVICE_ATTR(lpfc_stat_data_ctrl
, S_IRUGO
| S_IWUSR
,
3538 lpfc_stat_data_ctrl_show
, lpfc_stat_data_ctrl_store
);
3541 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
3545 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
3548 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
3549 #define MAX_STAT_DATA_SIZE_PER_TARGET \
3550 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
3554 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
3556 * @kobj: Pointer to the kernel object
3557 * @bin_attr: Attribute object
3558 * @buff: Buffer pointer
3560 * @count: Buffer size
3562 * This function is the read call back function for lpfc_drvr_stat_data
3563 * sysfs file. This function export the statistical data to user
3567 sysfs_drvr_stat_data_read(struct file
*filp
, struct kobject
*kobj
,
3568 struct bin_attribute
*bin_attr
,
3569 char *buf
, loff_t off
, size_t count
)
3571 struct device
*dev
= container_of(kobj
, struct device
,
3573 struct Scsi_Host
*shost
= class_to_shost(dev
);
3574 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3575 struct lpfc_hba
*phba
= vport
->phba
;
3576 int i
= 0, index
= 0;
3577 unsigned long nport_index
;
3578 struct lpfc_nodelist
*ndlp
= NULL
;
3579 nport_index
= (unsigned long)off
/
3580 MAX_STAT_DATA_SIZE_PER_TARGET
;
3582 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
3583 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
3586 spin_lock_irq(shost
->host_lock
);
3587 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3588 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
3591 if (nport_index
> 0) {
3596 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
3600 if (!ndlp
->lat_data
)
3604 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
3605 ndlp
->nlp_portname
.u
.wwn
[0],
3606 ndlp
->nlp_portname
.u
.wwn
[1],
3607 ndlp
->nlp_portname
.u
.wwn
[2],
3608 ndlp
->nlp_portname
.u
.wwn
[3],
3609 ndlp
->nlp_portname
.u
.wwn
[4],
3610 ndlp
->nlp_portname
.u
.wwn
[5],
3611 ndlp
->nlp_portname
.u
.wwn
[6],
3612 ndlp
->nlp_portname
.u
.wwn
[7]);
3614 index
= strlen(buf
);
3616 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3617 sprintf(&buf
[index
], "%010u,",
3618 ndlp
->lat_data
[i
].cmd_count
);
3619 index
= strlen(buf
);
3621 sprintf(&buf
[index
], "\n");
3622 index
= strlen(buf
);
3624 spin_unlock_irq(shost
->host_lock
);
3628 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
3630 .name
= "lpfc_drvr_stat_data",
3633 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
3634 .read
= sysfs_drvr_stat_data_read
,
3639 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
3641 # Value range is [0,16]. Default value is 0.
3644 * lpfc_link_speed_set - Set the adapters link speed
3645 * @phba: lpfc_hba pointer.
3646 * @val: link speed value.
3649 * If val is in a valid range then set the adapter's link speed field and
3650 * issue a lip; if the lip fails reset the link speed to the old value.
3653 * If the value is not in range log a kernel error message and return an error.
3656 * zero if val is in range and lip okay.
3657 * non-zero return value from lpfc_issue_lip()
3658 * -EINVAL val out of range
3661 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
3662 const char *buf
, size_t count
)
3664 struct Scsi_Host
*shost
= class_to_shost(dev
);
3665 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3666 struct lpfc_hba
*phba
= vport
->phba
;
3667 int val
= LPFC_USER_LINK_SPEED_AUTO
;
3669 const char *val_buf
= buf
;
3671 uint32_t prev_val
, if_type
;
3673 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
3674 if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
&&
3675 phba
->hba_flag
& HBA_FORCED_LINK_SPEED
)
3678 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
3680 val_buf
= &buf
[strlen("nolip ")];
3683 if (!isdigit(val_buf
[0]))
3685 if (sscanf(val_buf
, "%i", &val
) != 1)
3688 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3689 "3055 lpfc_link_speed changed from %d to %d %s\n",
3690 phba
->cfg_link_speed
, val
, nolip
? "(nolip)" : "(lip)");
3692 if (((val
== LPFC_USER_LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
3693 ((val
== LPFC_USER_LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
3694 ((val
== LPFC_USER_LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
3695 ((val
== LPFC_USER_LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
3696 ((val
== LPFC_USER_LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)) ||
3697 ((val
== LPFC_USER_LINK_SPEED_16G
) && !(phba
->lmt
& LMT_16Gb
)) ||
3698 ((val
== LPFC_USER_LINK_SPEED_32G
) && !(phba
->lmt
& LMT_32Gb
))) {
3699 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3700 "2879 lpfc_link_speed attribute cannot be set "
3701 "to %d. Speed is not supported by this port.\n",
3705 if (val
== LPFC_USER_LINK_SPEED_16G
&&
3706 phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
3707 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3708 "3112 lpfc_link_speed attribute cannot be set "
3709 "to %d. Speed is not supported in loop mode.\n",
3713 if ((val
>= 0) && (val
<= LPFC_USER_LINK_SPEED_MAX
) &&
3714 (LPFC_USER_LINK_SPEED_BITMAP
& (1 << val
))) {
3715 prev_val
= phba
->cfg_link_speed
;
3716 phba
->cfg_link_speed
= val
;
3720 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
3722 phba
->cfg_link_speed
= prev_val
;
3727 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3728 "0469 lpfc_link_speed attribute cannot be set to %d, "
3729 "allowed values are ["LPFC_LINK_SPEED_STRING
"]\n", val
);
3733 static int lpfc_link_speed
= 0;
3734 module_param(lpfc_link_speed
, int, S_IRUGO
);
3735 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
3736 lpfc_param_show(link_speed
)
3739 * lpfc_link_speed_init - Set the adapters link speed
3740 * @phba: lpfc_hba pointer.
3741 * @val: link speed value.
3744 * If val is in a valid range then set the adapter's link speed field.
3747 * If the value is not in range log a kernel error message, clear the link
3748 * speed and return an error.
3751 * zero if val saved.
3752 * -EINVAL val out of range
3755 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
3757 if (val
== LPFC_USER_LINK_SPEED_16G
&& phba
->cfg_topology
== 4) {
3758 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3759 "3111 lpfc_link_speed of %d cannot "
3760 "support loop mode, setting topology to default.\n",
3762 phba
->cfg_topology
= 0;
3764 if ((val
>= 0) && (val
<= LPFC_USER_LINK_SPEED_MAX
) &&
3765 (LPFC_USER_LINK_SPEED_BITMAP
& (1 << val
))) {
3766 phba
->cfg_link_speed
= val
;
3769 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3770 "0405 lpfc_link_speed attribute cannot "
3771 "be set to %d, allowed values are "
3772 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
3773 phba
->cfg_link_speed
= LPFC_USER_LINK_SPEED_AUTO
;
3777 static DEVICE_ATTR(lpfc_link_speed
, S_IRUGO
| S_IWUSR
,
3778 lpfc_link_speed_show
, lpfc_link_speed_store
);
3781 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
3782 # 0 = aer disabled or not supported
3783 # 1 = aer supported and enabled (default)
3784 # Value range is [0,1]. Default value is 1.
3786 LPFC_ATTR(aer_support
, 1, 0, 1,
3787 "Enable PCIe device AER support");
3788 lpfc_param_show(aer_support
)
3791 * lpfc_aer_support_store - Set the adapter for aer support
3793 * @dev: class device that is converted into a Scsi_host.
3794 * @attr: device attribute, not used.
3795 * @buf: containing enable or disable aer flag.
3796 * @count: unused variable.
3799 * If the val is 1 and currently the device's AER capability was not
3800 * enabled, invoke the kernel's enable AER helper routine, trying to
3801 * enable the device's AER capability. If the helper routine enabling
3802 * AER returns success, update the device's cfg_aer_support flag to
3803 * indicate AER is supported by the device; otherwise, if the device
3804 * AER capability is already enabled to support AER, then do nothing.
3806 * If the val is 0 and currently the device's AER support was enabled,
3807 * invoke the kernel's disable AER helper routine. After that, update
3808 * the device's cfg_aer_support flag to indicate AER is not supported
3809 * by the device; otherwise, if the device AER capability is already
3810 * disabled from supporting AER, then do nothing.
3813 * length of the buf on success if val is in range the intended mode
3815 * -EINVAL if val out of range or intended mode is not supported.
3818 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
3819 const char *buf
, size_t count
)
3821 struct Scsi_Host
*shost
= class_to_shost(dev
);
3822 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
3823 struct lpfc_hba
*phba
= vport
->phba
;
3824 int val
= 0, rc
= -EINVAL
;
3826 if (!isdigit(buf
[0]))
3828 if (sscanf(buf
, "%i", &val
) != 1)
3833 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
3834 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
3836 spin_lock_irq(&phba
->hbalock
);
3837 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
3838 spin_unlock_irq(&phba
->hbalock
);
3839 phba
->cfg_aer_support
= 0;
3844 phba
->cfg_aer_support
= 0;
3849 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
3850 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
3852 spin_lock_irq(&phba
->hbalock
);
3853 phba
->hba_flag
|= HBA_AER_ENABLED
;
3854 spin_unlock_irq(&phba
->hbalock
);
3855 phba
->cfg_aer_support
= 1;
3860 phba
->cfg_aer_support
= 1;
3871 static DEVICE_ATTR(lpfc_aer_support
, S_IRUGO
| S_IWUSR
,
3872 lpfc_aer_support_show
, lpfc_aer_support_store
);
3875 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
3876 * @dev: class device that is converted into a Scsi_host.
3877 * @attr: device attribute, not used.
3878 * @buf: containing flag 1 for aer cleanup state.
3879 * @count: unused variable.
3882 * If the @buf contains 1 and the device currently has the AER support
3883 * enabled, then invokes the kernel AER helper routine
3884 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
3885 * error status register.
3890 * -EINVAL if the buf does not contain the 1 or the device is not currently
3891 * enabled with the AER support.
3894 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
3895 const char *buf
, size_t count
)
3897 struct Scsi_Host
*shost
= class_to_shost(dev
);
3898 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3899 struct lpfc_hba
*phba
= vport
->phba
;
3902 if (!isdigit(buf
[0]))
3904 if (sscanf(buf
, "%i", &val
) != 1)
3909 if (phba
->hba_flag
& HBA_AER_ENABLED
)
3910 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
3918 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
3919 lpfc_aer_cleanup_state
);
3922 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
3924 * @dev: class device that is converted into a Scsi_host.
3925 * @attr: device attribute, not used.
3926 * @buf: containing the string the number of vfs to be enabled.
3927 * @count: unused variable.
3930 * When this api is called either through user sysfs, the driver shall
3931 * try to enable or disable SR-IOV virtual functions according to the
3934 * If zero virtual function has been enabled to the physical function,
3935 * the driver shall invoke the pci enable virtual function api trying
3936 * to enable the virtual functions. If the nr_vfn provided is greater
3937 * than the maximum supported, the maximum virtual function number will
3938 * be used for invoking the api; otherwise, the nr_vfn provided shall
3939 * be used for invoking the api. If the api call returned success, the
3940 * actual number of virtual functions enabled will be set to the driver
3941 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
3942 * cfg_sriov_nr_virtfn remains zero.
3944 * If none-zero virtual functions have already been enabled to the
3945 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
3946 * -EINVAL will be returned and the driver does nothing;
3948 * If the nr_vfn provided is zero and none-zero virtual functions have
3949 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
3950 * disabling virtual function api shall be invoded to disable all the
3951 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
3952 * zero. Otherwise, if zero virtual function has been enabled, do
3956 * length of the buf on success if val is in range the intended mode
3958 * -EINVAL if val out of range or intended mode is not supported.
3961 lpfc_sriov_nr_virtfn_store(struct device
*dev
, struct device_attribute
*attr
,
3962 const char *buf
, size_t count
)
3964 struct Scsi_Host
*shost
= class_to_shost(dev
);
3965 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
3966 struct lpfc_hba
*phba
= vport
->phba
;
3967 struct pci_dev
*pdev
= phba
->pcidev
;
3968 int val
= 0, rc
= -EINVAL
;
3970 /* Sanity check on user data */
3971 if (!isdigit(buf
[0]))
3973 if (sscanf(buf
, "%i", &val
) != 1)
3978 /* Request disabling virtual functions */
3980 if (phba
->cfg_sriov_nr_virtfn
> 0) {
3981 pci_disable_sriov(pdev
);
3982 phba
->cfg_sriov_nr_virtfn
= 0;
3987 /* Request enabling virtual functions */
3988 if (phba
->cfg_sriov_nr_virtfn
> 0) {
3989 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3990 "3018 There are %d virtual functions "
3991 "enabled on physical function.\n",
3992 phba
->cfg_sriov_nr_virtfn
);
3996 if (val
<= LPFC_MAX_VFN_PER_PFN
)
3997 phba
->cfg_sriov_nr_virtfn
= val
;
3999 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4000 "3019 Enabling %d virtual functions is not "
4005 rc
= lpfc_sli_probe_sriov_nr_virtfn(phba
, phba
->cfg_sriov_nr_virtfn
);
4007 phba
->cfg_sriov_nr_virtfn
= 0;
4015 LPFC_ATTR(sriov_nr_virtfn
, LPFC_DEF_VFN_PER_PFN
, 0, LPFC_MAX_VFN_PER_PFN
,
4016 "Enable PCIe device SR-IOV virtual fn");
4018 lpfc_param_show(sriov_nr_virtfn
)
4019 static DEVICE_ATTR(lpfc_sriov_nr_virtfn
, S_IRUGO
| S_IWUSR
,
4020 lpfc_sriov_nr_virtfn_show
, lpfc_sriov_nr_virtfn_store
);
4023 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
4025 * @dev: class device that is converted into a Scsi_host.
4026 * @attr: device attribute, not used.
4027 * @buf: containing the string the number of vfs to be enabled.
4028 * @count: unused variable.
4033 * length of the buf on success if val is in range the intended mode
4035 * -EINVAL if val out of range or intended mode is not supported.
4038 lpfc_request_firmware_upgrade_store(struct device
*dev
,
4039 struct device_attribute
*attr
,
4040 const char *buf
, size_t count
)
4042 struct Scsi_Host
*shost
= class_to_shost(dev
);
4043 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4044 struct lpfc_hba
*phba
= vport
->phba
;
4045 int val
= 0, rc
= -EINVAL
;
4047 /* Sanity check on user data */
4048 if (!isdigit(buf
[0]))
4050 if (sscanf(buf
, "%i", &val
) != 1)
4055 rc
= lpfc_sli4_request_firmware_update(phba
, RUN_FW_UPGRADE
);
4063 static int lpfc_req_fw_upgrade
;
4064 module_param(lpfc_req_fw_upgrade
, int, S_IRUGO
|S_IWUSR
);
4065 MODULE_PARM_DESC(lpfc_req_fw_upgrade
, "Enable Linux generic firmware upgrade");
4066 lpfc_param_show(request_firmware_upgrade
)
4069 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
4070 * @phba: lpfc_hba pointer.
4074 * Set the initial Linux generic firmware upgrade enable or disable flag.
4077 * zero if val saved.
4078 * -EINVAL val out of range
4081 lpfc_request_firmware_upgrade_init(struct lpfc_hba
*phba
, int val
)
4083 if (val
>= 0 && val
<= 1) {
4084 phba
->cfg_request_firmware_upgrade
= val
;
4089 static DEVICE_ATTR(lpfc_req_fw_upgrade
, S_IRUGO
| S_IWUSR
,
4090 lpfc_request_firmware_upgrade_show
,
4091 lpfc_request_firmware_upgrade_store
);
4094 * lpfc_fcp_imax_store
4096 * @dev: class device that is converted into a Scsi_host.
4097 * @attr: device attribute, not used.
4098 * @buf: string with the number of fast-path FCP interrupts per second.
4099 * @count: unused variable.
4102 * If val is in a valid range [636,651042], then set the adapter's
4103 * maximum number of fast-path FCP interrupts per second.
4106 * length of the buf on success if val is in range the intended mode
4108 * -EINVAL if val out of range or intended mode is not supported.
4111 lpfc_fcp_imax_store(struct device
*dev
, struct device_attribute
*attr
,
4112 const char *buf
, size_t count
)
4114 struct Scsi_Host
*shost
= class_to_shost(dev
);
4115 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4116 struct lpfc_hba
*phba
= vport
->phba
;
4119 /* fcp_imax is only valid for SLI4 */
4120 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
4123 /* Sanity check on user data */
4124 if (!isdigit(buf
[0]))
4126 if (sscanf(buf
, "%i", &val
) != 1)
4130 * Value range for the HBA is [5000,5000000]
4131 * The value for each EQ depends on how many EQs are configured.
4133 if (val
< LPFC_MIN_IMAX
|| val
> LPFC_MAX_IMAX
)
4136 phba
->cfg_fcp_imax
= (uint32_t)val
;
4137 for (i
= 0; i
< phba
->cfg_fcp_io_channel
; i
+= LPFC_MAX_EQ_DELAY
)
4138 lpfc_modify_fcp_eq_delay(phba
, i
);
4144 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
4147 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
4149 static int lpfc_fcp_imax
= LPFC_DEF_IMAX
;
4150 module_param(lpfc_fcp_imax
, int, S_IRUGO
|S_IWUSR
);
4151 MODULE_PARM_DESC(lpfc_fcp_imax
,
4152 "Set the maximum number of FCP interrupts per second per HBA");
4153 lpfc_param_show(fcp_imax
)
4156 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
4157 * @phba: lpfc_hba pointer.
4158 * @val: link speed value.
4161 * If val is in a valid range [636,651042], then initialize the adapter's
4162 * maximum number of fast-path FCP interrupts per second.
4165 * zero if val saved.
4166 * -EINVAL val out of range
4169 lpfc_fcp_imax_init(struct lpfc_hba
*phba
, int val
)
4171 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4172 phba
->cfg_fcp_imax
= 0;
4176 if (val
>= LPFC_MIN_IMAX
&& val
<= LPFC_MAX_IMAX
) {
4177 phba
->cfg_fcp_imax
= val
;
4181 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4182 "3016 lpfc_fcp_imax: %d out of range, using default\n",
4184 phba
->cfg_fcp_imax
= LPFC_DEF_IMAX
;
4189 static DEVICE_ATTR(lpfc_fcp_imax
, S_IRUGO
| S_IWUSR
,
4190 lpfc_fcp_imax_show
, lpfc_fcp_imax_store
);
4193 * lpfc_state_show - Display current driver CPU affinity
4194 * @dev: class converted to a Scsi_host structure.
4195 * @attr: device attribute, not used.
4196 * @buf: on return contains text describing the state of the link.
4198 * Returns: size of formatted string.
4201 lpfc_fcp_cpu_map_show(struct device
*dev
, struct device_attribute
*attr
,
4204 struct Scsi_Host
*shost
= class_to_shost(dev
);
4205 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4206 struct lpfc_hba
*phba
= vport
->phba
;
4207 struct lpfc_vector_map_info
*cpup
;
4210 if ((phba
->sli_rev
!= LPFC_SLI_REV4
) ||
4211 (phba
->intr_type
!= MSIX
))
4214 switch (phba
->cfg_fcp_cpu_map
) {
4216 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4217 "fcp_cpu_map: No mapping (%d)\n",
4218 phba
->cfg_fcp_cpu_map
);
4221 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4222 "fcp_cpu_map: HBA centric mapping (%d): "
4224 phba
->cfg_fcp_cpu_map
,
4225 phba
->sli4_hba
.num_online_cpu
);
4228 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4229 "fcp_cpu_map: Driver centric mapping (%d): "
4231 phba
->cfg_fcp_cpu_map
,
4232 phba
->sli4_hba
.num_online_cpu
);
4236 while (phba
->sli4_hba
.curr_disp_cpu
< phba
->sli4_hba
.num_present_cpu
) {
4237 cpup
= &phba
->sli4_hba
.cpu_map
[phba
->sli4_hba
.curr_disp_cpu
];
4239 /* margin should fit in this and the truncated message */
4240 if (cpup
->irq
== LPFC_VECTOR_MAP_EMPTY
)
4241 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4242 "CPU %02d io_chan %02d "
4243 "physid %d coreid %d\n",
4244 phba
->sli4_hba
.curr_disp_cpu
,
4245 cpup
->channel_id
, cpup
->phys_id
,
4248 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4249 "CPU %02d io_chan %02d "
4250 "physid %d coreid %d IRQ %d\n",
4251 phba
->sli4_hba
.curr_disp_cpu
,
4252 cpup
->channel_id
, cpup
->phys_id
,
4253 cpup
->core_id
, cpup
->irq
);
4255 phba
->sli4_hba
.curr_disp_cpu
++;
4257 /* display max number of CPUs keeping some margin */
4258 if (phba
->sli4_hba
.curr_disp_cpu
<
4259 phba
->sli4_hba
.num_present_cpu
&&
4260 (len
>= (PAGE_SIZE
- 64))) {
4261 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "more...\n");
4266 if (phba
->sli4_hba
.curr_disp_cpu
== phba
->sli4_hba
.num_present_cpu
)
4267 phba
->sli4_hba
.curr_disp_cpu
= 0;
4273 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
4274 * @dev: class device that is converted into a Scsi_host.
4275 * @attr: device attribute, not used.
4276 * @buf: one or more lpfc_polling_flags values.
4280 * -EINVAL - Not implemented yet.
4283 lpfc_fcp_cpu_map_store(struct device
*dev
, struct device_attribute
*attr
,
4284 const char *buf
, size_t count
)
4286 int status
= -EINVAL
;
4291 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
4294 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
4295 # 0 - Do not affinitze IRQ vectors
4296 # 1 - Affintize HBA vectors with respect to each HBA
4297 # (start with CPU0 for each HBA)
4298 # 2 - Affintize HBA vectors with respect to the entire driver
4299 # (round robin thru all CPUs across all HBAs)
4301 static int lpfc_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4302 module_param(lpfc_fcp_cpu_map
, int, S_IRUGO
|S_IWUSR
);
4303 MODULE_PARM_DESC(lpfc_fcp_cpu_map
,
4304 "Defines how to map CPUs to IRQ vectors per HBA");
4307 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
4308 * @phba: lpfc_hba pointer.
4309 * @val: link speed value.
4312 * If val is in a valid range [0-2], then affinitze the adapter's
4316 * zero if val saved.
4317 * -EINVAL val out of range
4320 lpfc_fcp_cpu_map_init(struct lpfc_hba
*phba
, int val
)
4322 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4323 phba
->cfg_fcp_cpu_map
= 0;
4327 if (val
>= LPFC_MIN_CPU_MAP
&& val
<= LPFC_MAX_CPU_MAP
) {
4328 phba
->cfg_fcp_cpu_map
= val
;
4332 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4333 "3326 lpfc_fcp_cpu_map: %d out of range, using "
4335 phba
->cfg_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4340 static DEVICE_ATTR(lpfc_fcp_cpu_map
, S_IRUGO
| S_IWUSR
,
4341 lpfc_fcp_cpu_map_show
, lpfc_fcp_cpu_map_store
);
4344 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
4345 # Value range is [2,3]. Default value is 3.
4347 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
4348 "Select Fibre Channel class of service for FCP sequences");
4351 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
4352 # is [0,1]. Default value is 0.
4354 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
4355 "Use ADISC on rediscovery to authenticate FCP devices");
4358 # lpfc_first_burst_size: First burst size to use on the NPorts
4359 # that support first burst.
4360 # Value range is [0,65536]. Default value is 0.
4362 LPFC_VPORT_ATTR_RW(first_burst_size
, 0, 0, 65536,
4363 "First burst size for Targets that support first burst");
4366 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
4367 # depth. Default value is 0. When the value of this parameter is zero the
4368 # SCSI command completion time is not used for controlling I/O queue depth. When
4369 # the parameter is set to a non-zero value, the I/O queue depth is controlled
4370 # to limit the I/O completion time to the parameter value.
4371 # The value is set in milliseconds.
4373 LPFC_VPORT_ATTR(max_scsicmpl_time
, 0, 0, 60000,
4374 "Use command completion time to control queue depth");
4376 lpfc_vport_param_show(max_scsicmpl_time
);
4378 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
4380 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
4381 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
4383 if (val
== vport
->cfg_max_scsicmpl_time
)
4385 if ((val
< 0) || (val
> 60000))
4387 vport
->cfg_max_scsicmpl_time
= val
;
4389 spin_lock_irq(shost
->host_lock
);
4390 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4391 if (!NLP_CHK_NODE_ACT(ndlp
))
4393 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
4395 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
4397 spin_unlock_irq(shost
->host_lock
);
4400 lpfc_vport_param_store(max_scsicmpl_time
);
4401 static DEVICE_ATTR(lpfc_max_scsicmpl_time
, S_IRUGO
| S_IWUSR
,
4402 lpfc_max_scsicmpl_time_show
,
4403 lpfc_max_scsicmpl_time_store
);
4406 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
4407 # range is [0,1]. Default value is 0.
4409 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
4412 # lpfc_fcp_io_sched: Determine scheduling algrithmn for issuing FCP cmds
4413 # range is [0,1]. Default value is 0.
4414 # For [0], FCP commands are issued to Work Queues ina round robin fashion.
4415 # For [1], FCP commands are issued to a Work Queue associated with the
4417 # It would be set to 1 by the driver if it's able to set up cpu affinity
4418 # for FCP I/Os through Work Queue associated with the current CPU. Otherwise,
4419 # roundrobin scheduling of FCP I/Os through WQs will be used.
4421 LPFC_ATTR_RW(fcp_io_sched
, 0, 0, 1, "Determine scheduling algorithm for "
4422 "issuing commands [0] - Round Robin, [1] - Current CPU");
4425 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
4426 # range is [0,1]. Default value is 0.
4427 # For [0], bus reset issues target reset to ALL devices
4428 # For [1], bus reset issues target reset to non-FCP2 devices
4430 LPFC_ATTR_RW(fcp2_no_tgt_reset
, 0, 0, 1, "Determine bus reset behavior for "
4431 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
4435 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
4436 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
4437 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
4438 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
4439 # cr_delay is set to 0.
4441 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
4442 "interrupt response is generated");
4444 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
4445 "interrupt response is generated");
4448 # lpfc_multi_ring_support: Determines how many rings to spread available
4449 # cmd/rsp IOCB entries across.
4450 # Value range is [1,2]. Default value is 1.
4452 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
4453 "SLI rings to spread IOCB entries across");
4456 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
4457 # identifies what rctl value to configure the additional ring for.
4458 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
4460 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
4461 255, "Identifies RCTL for additional ring configuration");
4464 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
4465 # identifies what type value to configure the additional ring for.
4466 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
4468 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
4469 255, "Identifies TYPE for additional ring configuration");
4472 # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN
4473 # 0 = SmartSAN functionality disabled (default)
4474 # 1 = SmartSAN functionality enabled
4475 # This parameter will override the value of lpfc_fdmi_on module parameter.
4476 # Value range is [0,1]. Default value is 0.
4478 LPFC_ATTR_R(enable_SmartSAN
, 0, 0, 1, "Enable SmartSAN functionality");
4481 # lpfc_fdmi_on: Controls FDMI support.
4482 # 0 No FDMI support (default)
4483 # 1 Traditional FDMI support
4484 # Traditional FDMI support means the driver will assume FDMI-2 support;
4485 # however, if that fails, it will fallback to FDMI-1.
4486 # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on.
4487 # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of
4489 # Value range [0,1]. Default value is 0.
4491 LPFC_ATTR_R(fdmi_on
, 0, 0, 1, "Enable FDMI support");
4494 # Specifies the maximum number of ELS cmds we can have outstanding (for
4495 # discovery). Value range is [1,64]. Default value = 32.
4497 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
4498 "during discovery");
4501 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
4502 # will be scanned by the SCSI midlayer when sequential scanning is
4503 # used; and is also the highest LUN ID allowed when the SCSI midlayer
4504 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
4505 # LUN ID limit, but the SCSI midlayer requires this field for the uses
4506 # above. The lpfc driver limits the default value to 255 for two reasons.
4507 # As it bounds the sequential scan loop, scanning for thousands of luns
4508 # on a target can take minutes of wall clock time. Additionally,
4509 # there are FC targets, such as JBODs, that only recognize 8-bits of
4510 # LUN ID. When they receive a value greater than 8 bits, they chop off
4511 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
4512 # and so on all as LUN ID 0. This causes the linux kernel, which sees
4513 # valid responses at each of the LUN IDs, to believe there are multiple
4514 # devices present, when in fact, there is only 1.
4515 # A customer that is aware of their target behaviors, and the results as
4516 # indicated above, is welcome to increase the lpfc_max_luns value.
4517 # As mentioned, this value is not used by the lpfc driver, only the
4519 # Value range is [0,65535]. Default value is 255.
4520 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
4522 LPFC_VPORT_ULL_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN ID");
4525 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
4526 # Value range is [1,255], default value is 10.
4528 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
4529 "Milliseconds driver will wait between polling FCP ring");
4532 # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands
4533 # to complete in seconds. Value range is [5,180], default value is 60.
4535 LPFC_ATTR_RW(task_mgmt_tmo
, 60, 5, 180,
4536 "Maximum time to wait for task management commands to complete");
4538 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
4539 # support this feature
4542 # 2 = MSI-X enabled (default)
4543 # Value range is [0,2]. Default value is 2.
4545 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
4546 "MSI-X (2), if possible");
4549 # lpfc_fcp_io_channel: Set the number of FCP EQ/CQ/WQ IO channels
4551 # Value range is [1,7]. Default value is 4.
4553 LPFC_ATTR_R(fcp_io_channel
, LPFC_FCP_IO_CHAN_DEF
, LPFC_FCP_IO_CHAN_MIN
,
4554 LPFC_FCP_IO_CHAN_MAX
,
4555 "Set the number of FCP I/O channels");
4558 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
4559 # 0 = HBA resets disabled
4560 # 1 = HBA resets enabled (default)
4561 # Value range is [0,1]. Default value is 1.
4563 LPFC_ATTR_R(enable_hba_reset
, 1, 0, 1, "Enable HBA resets from the driver.");
4566 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
4567 # 0 = HBA Heartbeat disabled
4568 # 1 = HBA Heartbeat enabled (default)
4569 # Value range is [0,1]. Default value is 1.
4571 LPFC_ATTR_R(enable_hba_heartbeat
, 0, 0, 1, "Enable HBA Heartbeat.");
4574 # lpfc_EnableXLane: Enable Express Lane Feature
4575 # 0x0 Express Lane Feature disabled
4576 # 0x1 Express Lane Feature enabled
4577 # Value range is [0,1]. Default value is 0.
4579 LPFC_ATTR_R(EnableXLane
, 0, 0, 1, "Enable Express Lane Feature.");
4582 # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature
4583 # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits)
4584 # Value range is [0x0,0x7f]. Default value is 0
4586 LPFC_ATTR_RW(XLanePriority
, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
4589 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
4590 # 0 = BlockGuard disabled (default)
4591 # 1 = BlockGuard enabled
4592 # Value range is [0,1]. Default value is 0.
4594 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
4597 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
4598 # 0 = disabled (default)
4600 # Value range is [0,1]. Default value is 0.
4602 # This feature in under investigation and may be supported in the future.
4604 unsigned int lpfc_fcp_look_ahead
= LPFC_LOOK_AHEAD_OFF
;
4608 # - Bit mask of host protection capabilities used to register with the
4610 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
4611 # - Allows you to ultimately specify which profiles to use
4612 # - Default will result in registering capabilities for all profiles.
4613 # - SHOST_DIF_TYPE1_PROTECTION 1
4614 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
4615 # - SHOST_DIX_TYPE0_PROTECTION 8
4616 # HBA supports DIX Type 0: Host to HBA protection only
4617 # - SHOST_DIX_TYPE1_PROTECTION 16
4618 # HBA supports DIX Type 1: Host to HBA Type 1 protection
4621 LPFC_ATTR(prot_mask
,
4622 (SHOST_DIF_TYPE1_PROTECTION
|
4623 SHOST_DIX_TYPE0_PROTECTION
|
4624 SHOST_DIX_TYPE1_PROTECTION
),
4626 (SHOST_DIF_TYPE1_PROTECTION
|
4627 SHOST_DIX_TYPE0_PROTECTION
|
4628 SHOST_DIX_TYPE1_PROTECTION
),
4629 "T10-DIF host protection capabilities mask");
4632 # lpfc_prot_guard: i
4633 # - Bit mask of protection guard types to register with the SCSI mid-layer
4634 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
4635 # - Allows you to ultimately specify which profiles to use
4636 # - Default will result in registering capabilities for all guard types
4639 LPFC_ATTR(prot_guard
,
4640 SHOST_DIX_GUARD_IP
, SHOST_DIX_GUARD_CRC
, SHOST_DIX_GUARD_IP
,
4641 "T10-DIF host protection guard type");
4644 * Delay initial NPort discovery when Clean Address bit is cleared in
4645 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
4646 * This parameter can have value 0 or 1.
4647 * When this parameter is set to 0, no delay is added to the initial
4649 * When this parameter is set to non-zero value, initial Nport discovery is
4650 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
4651 * accept and FCID/Fabric name/Fabric portname is changed.
4652 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
4653 * when Clean Address bit is cleared in FLOGI/FDISC
4654 * accept and FCID/Fabric name/Fabric portname is changed.
4655 * Default value is 0.
4657 LPFC_ATTR(delay_discovery
, 0, 0, 1,
4658 "Delay NPort discovery when Clean Address bit is cleared.");
4661 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
4662 * This value can be set to values between 64 and 4096. The default value is
4663 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
4664 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
4665 * Because of the additional overhead involved in setting up T10-DIF,
4666 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
4667 * and will be limited to 512 if BlockGuard is enabled under SLI3.
4669 LPFC_ATTR_R(sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
, LPFC_DEFAULT_SG_SEG_CNT
,
4670 LPFC_MAX_SG_SEG_CNT
, "Max Scatter Gather Segment Count");
4673 * This parameter will be depricated, the driver cannot limit the
4674 * protection data s/g list.
4676 LPFC_ATTR_R(prot_sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
,
4677 LPFC_DEFAULT_SG_SEG_CNT
, LPFC_MAX_SG_SEG_CNT
,
4678 "Max Protection Scatter Gather Segment Count");
4681 * lpfc_enable_mds_diags: Enable MDS Diagnostics
4682 * 0 = MDS Diagnostics disabled (default)
4683 * 1 = MDS Diagnostics enabled
4684 * Value range is [0,1]. Default value is 0.
4686 LPFC_ATTR_R(enable_mds_diags
, 0, 0, 1, "Enable MDS Diagnostics");
4688 struct device_attribute
*lpfc_hba_attrs
[] = {
4690 &dev_attr_bg_guard_err
,
4691 &dev_attr_bg_apptag_err
,
4692 &dev_attr_bg_reftag_err
,
4694 &dev_attr_serialnum
,
4695 &dev_attr_modeldesc
,
4696 &dev_attr_modelname
,
4697 &dev_attr_programtype
,
4701 &dev_attr_option_rom_version
,
4702 &dev_attr_link_state
,
4703 &dev_attr_num_discovered_ports
,
4704 &dev_attr_menlo_mgmt_mode
,
4705 &dev_attr_lpfc_drvr_version
,
4706 &dev_attr_lpfc_enable_fip
,
4707 &dev_attr_lpfc_temp_sensor
,
4708 &dev_attr_lpfc_log_verbose
,
4709 &dev_attr_lpfc_lun_queue_depth
,
4710 &dev_attr_lpfc_tgt_queue_depth
,
4711 &dev_attr_lpfc_hba_queue_depth
,
4712 &dev_attr_lpfc_peer_port_login
,
4713 &dev_attr_lpfc_nodev_tmo
,
4714 &dev_attr_lpfc_devloss_tmo
,
4715 &dev_attr_lpfc_fcp_class
,
4716 &dev_attr_lpfc_use_adisc
,
4717 &dev_attr_lpfc_first_burst_size
,
4718 &dev_attr_lpfc_ack0
,
4719 &dev_attr_lpfc_topology
,
4720 &dev_attr_lpfc_scan_down
,
4721 &dev_attr_lpfc_link_speed
,
4722 &dev_attr_lpfc_fcp_io_sched
,
4723 &dev_attr_lpfc_fcp2_no_tgt_reset
,
4724 &dev_attr_lpfc_cr_delay
,
4725 &dev_attr_lpfc_cr_count
,
4726 &dev_attr_lpfc_multi_ring_support
,
4727 &dev_attr_lpfc_multi_ring_rctl
,
4728 &dev_attr_lpfc_multi_ring_type
,
4729 &dev_attr_lpfc_fdmi_on
,
4730 &dev_attr_lpfc_enable_SmartSAN
,
4731 &dev_attr_lpfc_max_luns
,
4732 &dev_attr_lpfc_enable_npiv
,
4733 &dev_attr_lpfc_fcf_failover_policy
,
4734 &dev_attr_lpfc_enable_rrq
,
4735 &dev_attr_nport_evt_cnt
,
4736 &dev_attr_board_mode
,
4743 &dev_attr_npiv_info
,
4744 &dev_attr_issue_reset
,
4745 &dev_attr_lpfc_poll
,
4746 &dev_attr_lpfc_poll_tmo
,
4747 &dev_attr_lpfc_task_mgmt_tmo
,
4748 &dev_attr_lpfc_use_msi
,
4749 &dev_attr_lpfc_fcp_imax
,
4750 &dev_attr_lpfc_fcp_cpu_map
,
4751 &dev_attr_lpfc_fcp_io_channel
,
4752 &dev_attr_lpfc_enable_bg
,
4753 &dev_attr_lpfc_soft_wwnn
,
4754 &dev_attr_lpfc_soft_wwpn
,
4755 &dev_attr_lpfc_soft_wwn_enable
,
4756 &dev_attr_lpfc_enable_hba_reset
,
4757 &dev_attr_lpfc_enable_hba_heartbeat
,
4758 &dev_attr_lpfc_EnableXLane
,
4759 &dev_attr_lpfc_XLanePriority
,
4760 &dev_attr_lpfc_xlane_lun
,
4761 &dev_attr_lpfc_xlane_tgt
,
4762 &dev_attr_lpfc_xlane_vpt
,
4763 &dev_attr_lpfc_xlane_lun_state
,
4764 &dev_attr_lpfc_xlane_lun_status
,
4765 &dev_attr_lpfc_xlane_priority
,
4766 &dev_attr_lpfc_sg_seg_cnt
,
4767 &dev_attr_lpfc_max_scsicmpl_time
,
4768 &dev_attr_lpfc_stat_data_ctrl
,
4769 &dev_attr_lpfc_prot_sg_seg_cnt
,
4770 &dev_attr_lpfc_aer_support
,
4771 &dev_attr_lpfc_aer_state_cleanup
,
4772 &dev_attr_lpfc_sriov_nr_virtfn
,
4773 &dev_attr_lpfc_req_fw_upgrade
,
4774 &dev_attr_lpfc_suppress_link_up
,
4775 &dev_attr_lpfc_iocb_cnt
,
4778 &dev_attr_txcmplq_hw
,
4779 &dev_attr_lpfc_fips_level
,
4780 &dev_attr_lpfc_fips_rev
,
4782 &dev_attr_lpfc_sriov_hw_max_virtfn
,
4784 &dev_attr_lpfc_xlane_supported
,
4785 &dev_attr_lpfc_enable_mds_diags
,
4789 struct device_attribute
*lpfc_vport_attrs
[] = {
4791 &dev_attr_link_state
,
4792 &dev_attr_num_discovered_ports
,
4793 &dev_attr_lpfc_drvr_version
,
4794 &dev_attr_lpfc_log_verbose
,
4795 &dev_attr_lpfc_lun_queue_depth
,
4796 &dev_attr_lpfc_tgt_queue_depth
,
4797 &dev_attr_lpfc_nodev_tmo
,
4798 &dev_attr_lpfc_devloss_tmo
,
4799 &dev_attr_lpfc_hba_queue_depth
,
4800 &dev_attr_lpfc_peer_port_login
,
4801 &dev_attr_lpfc_restrict_login
,
4802 &dev_attr_lpfc_fcp_class
,
4803 &dev_attr_lpfc_use_adisc
,
4804 &dev_attr_lpfc_first_burst_size
,
4805 &dev_attr_lpfc_max_luns
,
4806 &dev_attr_nport_evt_cnt
,
4807 &dev_attr_npiv_info
,
4808 &dev_attr_lpfc_enable_da_id
,
4809 &dev_attr_lpfc_max_scsicmpl_time
,
4810 &dev_attr_lpfc_stat_data_ctrl
,
4811 &dev_attr_lpfc_static_vport
,
4812 &dev_attr_lpfc_fips_level
,
4813 &dev_attr_lpfc_fips_rev
,
4818 * sysfs_ctlreg_write - Write method for writing to ctlreg
4819 * @filp: open sysfs file
4820 * @kobj: kernel kobject that contains the kernel class device.
4821 * @bin_attr: kernel attributes passed to us.
4822 * @buf: contains the data to be written to the adapter IOREG space.
4823 * @off: offset into buffer to beginning of data.
4824 * @count: bytes to transfer.
4827 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
4828 * Uses the adapter io control registers to send buf contents to the adapter.
4831 * -ERANGE off and count combo out of range
4832 * -EINVAL off, count or buff address invalid
4833 * -EPERM adapter is offline
4834 * value of count, buf contents written
4837 sysfs_ctlreg_write(struct file
*filp
, struct kobject
*kobj
,
4838 struct bin_attribute
*bin_attr
,
4839 char *buf
, loff_t off
, size_t count
)
4842 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
4843 struct Scsi_Host
*shost
= class_to_shost(dev
);
4844 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4845 struct lpfc_hba
*phba
= vport
->phba
;
4847 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
4850 if ((off
+ count
) > FF_REG_AREA_SIZE
)
4853 if (count
<= LPFC_REG_WRITE_KEY_SIZE
)
4856 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
4859 /* This is to protect HBA registers from accidental writes. */
4860 if (memcmp(buf
, LPFC_REG_WRITE_KEY
, LPFC_REG_WRITE_KEY_SIZE
))
4863 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
))
4866 spin_lock_irq(&phba
->hbalock
);
4867 for (buf_off
= 0; buf_off
< count
- LPFC_REG_WRITE_KEY_SIZE
;
4868 buf_off
+= sizeof(uint32_t))
4869 writel(*((uint32_t *)(buf
+ buf_off
+ LPFC_REG_WRITE_KEY_SIZE
)),
4870 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
4872 spin_unlock_irq(&phba
->hbalock
);
4878 * sysfs_ctlreg_read - Read method for reading from ctlreg
4879 * @filp: open sysfs file
4880 * @kobj: kernel kobject that contains the kernel class device.
4881 * @bin_attr: kernel attributes passed to us.
4882 * @buf: if successful contains the data from the adapter IOREG space.
4883 * @off: offset into buffer to beginning of data.
4884 * @count: bytes to transfer.
4887 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
4888 * Uses the adapter io control registers to read data into buf.
4891 * -ERANGE off and count combo out of range
4892 * -EINVAL off, count or buff address invalid
4893 * value of count, buf contents read
4896 sysfs_ctlreg_read(struct file
*filp
, struct kobject
*kobj
,
4897 struct bin_attribute
*bin_attr
,
4898 char *buf
, loff_t off
, size_t count
)
4902 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
4903 struct Scsi_Host
*shost
= class_to_shost(dev
);
4904 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4905 struct lpfc_hba
*phba
= vport
->phba
;
4907 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
4910 if (off
> FF_REG_AREA_SIZE
)
4913 if ((off
+ count
) > FF_REG_AREA_SIZE
)
4914 count
= FF_REG_AREA_SIZE
- off
;
4916 if (count
== 0) return 0;
4918 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
4921 spin_lock_irq(&phba
->hbalock
);
4923 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
4924 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
4925 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
4928 spin_unlock_irq(&phba
->hbalock
);
4933 static struct bin_attribute sysfs_ctlreg_attr
= {
4936 .mode
= S_IRUSR
| S_IWUSR
,
4939 .read
= sysfs_ctlreg_read
,
4940 .write
= sysfs_ctlreg_write
,
4944 * sysfs_mbox_write - Write method for writing information via mbox
4945 * @filp: open sysfs file
4946 * @kobj: kernel kobject that contains the kernel class device.
4947 * @bin_attr: kernel attributes passed to us.
4948 * @buf: contains the data to be written to sysfs mbox.
4949 * @off: offset into buffer to beginning of data.
4950 * @count: bytes to transfer.
4953 * Deprecated function. All mailbox access from user space is performed via the
4957 * -EPERM operation not permitted
4960 sysfs_mbox_write(struct file
*filp
, struct kobject
*kobj
,
4961 struct bin_attribute
*bin_attr
,
4962 char *buf
, loff_t off
, size_t count
)
4968 * sysfs_mbox_read - Read method for reading information via mbox
4969 * @filp: open sysfs file
4970 * @kobj: kernel kobject that contains the kernel class device.
4971 * @bin_attr: kernel attributes passed to us.
4972 * @buf: contains the data to be read from sysfs mbox.
4973 * @off: offset into buffer to beginning of data.
4974 * @count: bytes to transfer.
4977 * Deprecated function. All mailbox access from user space is performed via the
4981 * -EPERM operation not permitted
4984 sysfs_mbox_read(struct file
*filp
, struct kobject
*kobj
,
4985 struct bin_attribute
*bin_attr
,
4986 char *buf
, loff_t off
, size_t count
)
4991 static struct bin_attribute sysfs_mbox_attr
= {
4994 .mode
= S_IRUSR
| S_IWUSR
,
4996 .size
= MAILBOX_SYSFS_MAX
,
4997 .read
= sysfs_mbox_read
,
4998 .write
= sysfs_mbox_write
,
5002 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
5003 * @vport: address of lpfc vport structure.
5007 * error return code from sysfs_create_bin_file()
5010 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
5012 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5015 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5016 &sysfs_drvr_stat_data_attr
);
5018 /* Virtual ports do not need ctrl_reg and mbox */
5019 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
5022 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5023 &sysfs_ctlreg_attr
);
5025 goto out_remove_stat_attr
;
5027 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5030 goto out_remove_ctlreg_attr
;
5033 out_remove_ctlreg_attr
:
5034 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5035 out_remove_stat_attr
:
5036 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5037 &sysfs_drvr_stat_data_attr
);
5043 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
5044 * @vport: address of lpfc vport structure.
5047 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
5049 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5050 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5051 &sysfs_drvr_stat_data_attr
);
5052 /* Virtual ports do not need ctrl_reg and mbox */
5053 if (vport
->port_type
== LPFC_NPIV_PORT
)
5055 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
5056 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5060 * Dynamic FC Host Attributes Support
5064 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
5065 * @shost: kernel scsi host pointer.
5068 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
5070 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5072 /* note: fc_myDID already in cpu endianness */
5073 fc_host_port_id(shost
) = vport
->fc_myDID
;
5077 * lpfc_get_host_port_type - Set the value of the scsi host port type
5078 * @shost: kernel scsi host pointer.
5081 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
5083 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5084 struct lpfc_hba
*phba
= vport
->phba
;
5086 spin_lock_irq(shost
->host_lock
);
5088 if (vport
->port_type
== LPFC_NPIV_PORT
) {
5089 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
5090 } else if (lpfc_is_link_up(phba
)) {
5091 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5092 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
5093 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
5095 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
5097 if (vport
->fc_flag
& FC_FABRIC
)
5098 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
5100 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
5103 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
5105 spin_unlock_irq(shost
->host_lock
);
5109 * lpfc_get_host_port_state - Set the value of the scsi host port state
5110 * @shost: kernel scsi host pointer.
5113 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
5115 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5116 struct lpfc_hba
*phba
= vport
->phba
;
5118 spin_lock_irq(shost
->host_lock
);
5120 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5121 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
5123 switch (phba
->link_state
) {
5124 case LPFC_LINK_UNKNOWN
:
5125 case LPFC_LINK_DOWN
:
5126 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
5130 case LPFC_HBA_READY
:
5131 /* Links up, reports port state accordingly */
5132 if (vport
->port_state
< LPFC_VPORT_READY
)
5133 fc_host_port_state(shost
) =
5134 FC_PORTSTATE_BYPASSED
;
5136 fc_host_port_state(shost
) =
5137 FC_PORTSTATE_ONLINE
;
5139 case LPFC_HBA_ERROR
:
5140 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
5143 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
5148 spin_unlock_irq(shost
->host_lock
);
5152 * lpfc_get_host_speed - Set the value of the scsi host speed
5153 * @shost: kernel scsi host pointer.
5156 lpfc_get_host_speed(struct Scsi_Host
*shost
)
5158 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5159 struct lpfc_hba
*phba
= vport
->phba
;
5161 spin_lock_irq(shost
->host_lock
);
5163 if ((lpfc_is_link_up(phba
)) && (!(phba
->hba_flag
& HBA_FCOE_MODE
))) {
5164 switch(phba
->fc_linkspeed
) {
5165 case LPFC_LINK_SPEED_1GHZ
:
5166 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
5168 case LPFC_LINK_SPEED_2GHZ
:
5169 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
5171 case LPFC_LINK_SPEED_4GHZ
:
5172 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
5174 case LPFC_LINK_SPEED_8GHZ
:
5175 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
5177 case LPFC_LINK_SPEED_10GHZ
:
5178 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
5180 case LPFC_LINK_SPEED_16GHZ
:
5181 fc_host_speed(shost
) = FC_PORTSPEED_16GBIT
;
5183 case LPFC_LINK_SPEED_32GHZ
:
5184 fc_host_speed(shost
) = FC_PORTSPEED_32GBIT
;
5187 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5191 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5193 spin_unlock_irq(shost
->host_lock
);
5197 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
5198 * @shost: kernel scsi host pointer.
5201 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
5203 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5204 struct lpfc_hba
*phba
= vport
->phba
;
5207 spin_lock_irq(shost
->host_lock
);
5209 if ((vport
->port_state
> LPFC_FLOGI
) &&
5210 ((vport
->fc_flag
& FC_FABRIC
) ||
5211 ((phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) &&
5212 (vport
->fc_flag
& FC_PUBLIC_LOOP
))))
5213 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
5215 /* fabric is local port if there is no F/FL_Port */
5218 spin_unlock_irq(shost
->host_lock
);
5220 fc_host_fabric_name(shost
) = node_name
;
5224 * lpfc_get_stats - Return statistical information about the adapter
5225 * @shost: kernel scsi host pointer.
5228 * NULL on error for link down, no mbox pool, sli2 active,
5229 * management not allowed, memory allocation error, or mbox error.
5233 * address of the adapter host statistics
5235 static struct fc_host_statistics
*
5236 lpfc_get_stats(struct Scsi_Host
*shost
)
5238 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5239 struct lpfc_hba
*phba
= vport
->phba
;
5240 struct lpfc_sli
*psli
= &phba
->sli
;
5241 struct fc_host_statistics
*hs
= &phba
->link_stats
;
5242 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
5243 LPFC_MBOXQ_t
*pmboxq
;
5245 unsigned long seconds
;
5249 * prevent udev from issuing mailbox commands until the port is
5252 if (phba
->link_state
< LPFC_LINK_DOWN
||
5253 !phba
->mbox_mem_pool
||
5254 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
5257 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5260 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5263 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5265 pmb
= &pmboxq
->u
.mb
;
5266 pmb
->mbxCommand
= MBX_READ_STATUS
;
5267 pmb
->mbxOwner
= OWN_HOST
;
5268 pmboxq
->context1
= NULL
;
5269 pmboxq
->vport
= vport
;
5271 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5272 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5274 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5276 if (rc
!= MBX_SUCCESS
) {
5277 if (rc
!= MBX_TIMEOUT
)
5278 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5282 memset(hs
, 0, sizeof (struct fc_host_statistics
));
5284 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
5286 * The MBX_READ_STATUS returns tx_k_bytes which has to
5287 * converted to words
5289 hs
->tx_words
= (uint64_t)
5290 ((uint64_t)pmb
->un
.varRdStatus
.xmitByteCnt
5292 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
5293 hs
->rx_words
= (uint64_t)
5294 ((uint64_t)pmb
->un
.varRdStatus
.rcvByteCnt
5297 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5298 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5299 pmb
->mbxOwner
= OWN_HOST
;
5300 pmboxq
->context1
= NULL
;
5301 pmboxq
->vport
= vport
;
5303 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5304 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5306 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5308 if (rc
!= MBX_SUCCESS
) {
5309 if (rc
!= MBX_TIMEOUT
)
5310 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5314 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5315 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5316 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5317 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5318 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5319 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5320 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5322 hs
->link_failure_count
-= lso
->link_failure_count
;
5323 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
5324 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
5325 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
5326 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
5327 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
5328 hs
->error_frames
-= lso
->error_frames
;
5330 if (phba
->hba_flag
& HBA_FCOE_MODE
) {
5332 hs
->nos_count
= (phba
->link_events
>> 1);
5333 hs
->nos_count
-= lso
->link_events
;
5334 } else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5335 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
5336 hs
->lip_count
-= lso
->link_events
;
5340 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
5341 hs
->nos_count
-= lso
->link_events
;
5344 hs
->dumped_frames
= -1;
5346 seconds
= get_seconds();
5347 if (seconds
< psli
->stats_start
)
5348 hs
->seconds_since_last_reset
= seconds
+
5349 ((unsigned long)-1 - psli
->stats_start
);
5351 hs
->seconds_since_last_reset
= seconds
- psli
->stats_start
;
5353 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5359 * lpfc_reset_stats - Copy the adapter link stats information
5360 * @shost: kernel scsi host pointer.
5363 lpfc_reset_stats(struct Scsi_Host
*shost
)
5365 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5366 struct lpfc_hba
*phba
= vport
->phba
;
5367 struct lpfc_sli
*psli
= &phba
->sli
;
5368 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
5369 LPFC_MBOXQ_t
*pmboxq
;
5373 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5376 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5379 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5381 pmb
= &pmboxq
->u
.mb
;
5382 pmb
->mbxCommand
= MBX_READ_STATUS
;
5383 pmb
->mbxOwner
= OWN_HOST
;
5384 pmb
->un
.varWords
[0] = 0x1; /* reset request */
5385 pmboxq
->context1
= NULL
;
5386 pmboxq
->vport
= vport
;
5388 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5389 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5390 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5392 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5394 if (rc
!= MBX_SUCCESS
) {
5395 if (rc
!= MBX_TIMEOUT
)
5396 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5400 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5401 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5402 pmb
->mbxOwner
= OWN_HOST
;
5403 pmboxq
->context1
= NULL
;
5404 pmboxq
->vport
= vport
;
5406 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5407 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5408 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5410 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5412 if (rc
!= MBX_SUCCESS
) {
5413 if (rc
!= MBX_TIMEOUT
)
5414 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
5418 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5419 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5420 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5421 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5422 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5423 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5424 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5425 if (phba
->hba_flag
& HBA_FCOE_MODE
)
5426 lso
->link_events
= (phba
->link_events
>> 1);
5428 lso
->link_events
= (phba
->fc_eventTag
>> 1);
5430 psli
->stats_start
= get_seconds();
5432 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5438 * The LPFC driver treats linkdown handling as target loss events so there
5439 * are no sysfs handlers for link_down_tmo.
5443 * lpfc_get_node_by_target - Return the nodelist for a target
5444 * @starget: kernel scsi target pointer.
5447 * address of the node list if found
5448 * NULL target not found
5450 static struct lpfc_nodelist
*
5451 lpfc_get_node_by_target(struct scsi_target
*starget
)
5453 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
5454 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5455 struct lpfc_nodelist
*ndlp
;
5457 spin_lock_irq(shost
->host_lock
);
5458 /* Search for this, mapped, target ID */
5459 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
5460 if (NLP_CHK_NODE_ACT(ndlp
) &&
5461 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
5462 starget
->id
== ndlp
->nlp_sid
) {
5463 spin_unlock_irq(shost
->host_lock
);
5467 spin_unlock_irq(shost
->host_lock
);
5472 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
5473 * @starget: kernel scsi target pointer.
5476 lpfc_get_starget_port_id(struct scsi_target
*starget
)
5478 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5480 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
5484 * lpfc_get_starget_node_name - Set the target node name
5485 * @starget: kernel scsi target pointer.
5487 * Description: Set the target node name to the ndlp node name wwn or zero.
5490 lpfc_get_starget_node_name(struct scsi_target
*starget
)
5492 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5494 fc_starget_node_name(starget
) =
5495 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
5499 * lpfc_get_starget_port_name - Set the target port name
5500 * @starget: kernel scsi target pointer.
5502 * Description: set the target port name to the ndlp port name wwn or zero.
5505 lpfc_get_starget_port_name(struct scsi_target
*starget
)
5507 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5509 fc_starget_port_name(starget
) =
5510 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
5514 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
5515 * @rport: fc rport address.
5516 * @timeout: new value for dev loss tmo.
5519 * If timeout is non zero set the dev_loss_tmo to timeout, else set
5520 * dev_loss_tmo to one.
5523 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
5526 rport
->dev_loss_tmo
= timeout
;
5528 rport
->dev_loss_tmo
= 1;
5532 * lpfc_rport_show_function - Return rport target information
5535 * Macro that uses field to generate a function with the name lpfc_show_rport_
5537 * lpfc_show_rport_##field: returns the bytes formatted in buf
5538 * @cdev: class converted to an fc_rport.
5539 * @buf: on return contains the target_field or zero.
5541 * Returns: size of formatted string.
5543 #define lpfc_rport_show_function(field, format_string, sz, cast) \
5545 lpfc_show_rport_##field (struct device *dev, \
5546 struct device_attribute *attr, \
5549 struct fc_rport *rport = transport_class_to_rport(dev); \
5550 struct lpfc_rport_data *rdata = rport->hostdata; \
5551 return snprintf(buf, sz, format_string, \
5552 (rdata->target) ? cast rdata->target->field : 0); \
5555 #define lpfc_rport_rd_attr(field, format_string, sz) \
5556 lpfc_rport_show_function(field, format_string, sz, ) \
5557 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
5560 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
5561 * @fc_vport: The fc_vport who's symbolic name has been changed.
5564 * This function is called by the transport after the @fc_vport's symbolic name
5565 * has been changed. This function re-registers the symbolic name with the
5566 * switch to propagate the change into the fabric if the vport is active.
5569 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
5571 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
5573 if (vport
->port_state
== LPFC_VPORT_READY
)
5574 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
5578 * lpfc_hba_log_verbose_init - Set hba's log verbose level
5579 * @phba: Pointer to lpfc_hba struct.
5581 * This function is called by the lpfc_get_cfgparam() routine to set the
5582 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
5583 * log message according to the module's lpfc_log_verbose parameter setting
5584 * before hba port or vport created.
5587 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
5589 phba
->cfg_log_verbose
= verbose
;
5592 struct fc_function_template lpfc_transport_functions
= {
5593 /* fixed attributes the driver supports */
5594 .show_host_node_name
= 1,
5595 .show_host_port_name
= 1,
5596 .show_host_supported_classes
= 1,
5597 .show_host_supported_fc4s
= 1,
5598 .show_host_supported_speeds
= 1,
5599 .show_host_maxframe_size
= 1,
5600 .show_host_symbolic_name
= 1,
5602 /* dynamic attributes the driver supports */
5603 .get_host_port_id
= lpfc_get_host_port_id
,
5604 .show_host_port_id
= 1,
5606 .get_host_port_type
= lpfc_get_host_port_type
,
5607 .show_host_port_type
= 1,
5609 .get_host_port_state
= lpfc_get_host_port_state
,
5610 .show_host_port_state
= 1,
5612 /* active_fc4s is shown but doesn't change (thus no get function) */
5613 .show_host_active_fc4s
= 1,
5615 .get_host_speed
= lpfc_get_host_speed
,
5616 .show_host_speed
= 1,
5618 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
5619 .show_host_fabric_name
= 1,
5622 * The LPFC driver treats linkdown handling as target loss events
5623 * so there are no sysfs handlers for link_down_tmo.
5626 .get_fc_host_stats
= lpfc_get_stats
,
5627 .reset_fc_host_stats
= lpfc_reset_stats
,
5629 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
5630 .show_rport_maxframe_size
= 1,
5631 .show_rport_supported_classes
= 1,
5633 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
5634 .show_rport_dev_loss_tmo
= 1,
5636 .get_starget_port_id
= lpfc_get_starget_port_id
,
5637 .show_starget_port_id
= 1,
5639 .get_starget_node_name
= lpfc_get_starget_node_name
,
5640 .show_starget_node_name
= 1,
5642 .get_starget_port_name
= lpfc_get_starget_port_name
,
5643 .show_starget_port_name
= 1,
5645 .issue_fc_host_lip
= lpfc_issue_lip
,
5646 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
5647 .terminate_rport_io
= lpfc_terminate_rport_io
,
5649 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
5651 .vport_disable
= lpfc_vport_disable
,
5653 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
5655 .bsg_request
= lpfc_bsg_request
,
5656 .bsg_timeout
= lpfc_bsg_timeout
,
5659 struct fc_function_template lpfc_vport_transport_functions
= {
5660 /* fixed attributes the driver supports */
5661 .show_host_node_name
= 1,
5662 .show_host_port_name
= 1,
5663 .show_host_supported_classes
= 1,
5664 .show_host_supported_fc4s
= 1,
5665 .show_host_supported_speeds
= 1,
5666 .show_host_maxframe_size
= 1,
5667 .show_host_symbolic_name
= 1,
5669 /* dynamic attributes the driver supports */
5670 .get_host_port_id
= lpfc_get_host_port_id
,
5671 .show_host_port_id
= 1,
5673 .get_host_port_type
= lpfc_get_host_port_type
,
5674 .show_host_port_type
= 1,
5676 .get_host_port_state
= lpfc_get_host_port_state
,
5677 .show_host_port_state
= 1,
5679 /* active_fc4s is shown but doesn't change (thus no get function) */
5680 .show_host_active_fc4s
= 1,
5682 .get_host_speed
= lpfc_get_host_speed
,
5683 .show_host_speed
= 1,
5685 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
5686 .show_host_fabric_name
= 1,
5689 * The LPFC driver treats linkdown handling as target loss events
5690 * so there are no sysfs handlers for link_down_tmo.
5693 .get_fc_host_stats
= lpfc_get_stats
,
5694 .reset_fc_host_stats
= lpfc_reset_stats
,
5696 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
5697 .show_rport_maxframe_size
= 1,
5698 .show_rport_supported_classes
= 1,
5700 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
5701 .show_rport_dev_loss_tmo
= 1,
5703 .get_starget_port_id
= lpfc_get_starget_port_id
,
5704 .show_starget_port_id
= 1,
5706 .get_starget_node_name
= lpfc_get_starget_node_name
,
5707 .show_starget_node_name
= 1,
5709 .get_starget_port_name
= lpfc_get_starget_port_name
,
5710 .show_starget_port_name
= 1,
5712 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
5713 .terminate_rport_io
= lpfc_terminate_rport_io
,
5715 .vport_disable
= lpfc_vport_disable
,
5717 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
5721 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
5722 * @phba: lpfc_hba pointer.
5725 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
5727 lpfc_fcp_io_sched_init(phba
, lpfc_fcp_io_sched
);
5728 lpfc_fcp2_no_tgt_reset_init(phba
, lpfc_fcp2_no_tgt_reset
);
5729 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
5730 lpfc_cr_count_init(phba
, lpfc_cr_count
);
5731 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
5732 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
5733 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
5734 lpfc_ack0_init(phba
, lpfc_ack0
);
5735 lpfc_topology_init(phba
, lpfc_topology
);
5736 lpfc_link_speed_init(phba
, lpfc_link_speed
);
5737 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
5738 lpfc_task_mgmt_tmo_init(phba
, lpfc_task_mgmt_tmo
);
5739 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
5740 lpfc_fcf_failover_policy_init(phba
, lpfc_fcf_failover_policy
);
5741 lpfc_enable_rrq_init(phba
, lpfc_enable_rrq
);
5742 lpfc_fdmi_on_init(phba
, lpfc_fdmi_on
);
5743 lpfc_enable_SmartSAN_init(phba
, lpfc_enable_SmartSAN
);
5744 lpfc_use_msi_init(phba
, lpfc_use_msi
);
5745 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
5746 lpfc_fcp_cpu_map_init(phba
, lpfc_fcp_cpu_map
);
5747 lpfc_fcp_io_channel_init(phba
, lpfc_fcp_io_channel
);
5748 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
5749 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
5750 lpfc_EnableXLane_init(phba
, lpfc_EnableXLane
);
5751 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
5752 phba
->cfg_EnableXLane
= 0;
5753 lpfc_XLanePriority_init(phba
, lpfc_XLanePriority
);
5754 memset(phba
->cfg_oas_tgt_wwpn
, 0, (8 * sizeof(uint8_t)));
5755 memset(phba
->cfg_oas_vpt_wwpn
, 0, (8 * sizeof(uint8_t)));
5756 phba
->cfg_oas_lun_state
= 0;
5757 phba
->cfg_oas_lun_status
= 0;
5758 phba
->cfg_oas_flags
= 0;
5759 phba
->cfg_oas_priority
= 0;
5760 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
5761 lpfc_prot_mask_init(phba
, lpfc_prot_mask
);
5762 lpfc_prot_guard_init(phba
, lpfc_prot_guard
);
5763 if (phba
->sli_rev
== LPFC_SLI_REV4
)
5766 phba
->cfg_poll
= lpfc_poll
;
5768 phba
->cfg_soft_wwnn
= 0L;
5769 phba
->cfg_soft_wwpn
= 0L;
5770 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
5771 lpfc_prot_sg_seg_cnt_init(phba
, lpfc_prot_sg_seg_cnt
);
5772 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
5773 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
5774 lpfc_aer_support_init(phba
, lpfc_aer_support
);
5775 lpfc_sriov_nr_virtfn_init(phba
, lpfc_sriov_nr_virtfn
);
5776 lpfc_request_firmware_upgrade_init(phba
, lpfc_req_fw_upgrade
);
5777 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
5778 lpfc_iocb_cnt_init(phba
, lpfc_iocb_cnt
);
5779 lpfc_delay_discovery_init(phba
, lpfc_delay_discovery
);
5780 lpfc_sli_mode_init(phba
, lpfc_sli_mode
);
5781 phba
->cfg_enable_dss
= 1;
5782 lpfc_enable_mds_diags_init(phba
, lpfc_enable_mds_diags
);
5787 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
5788 * @vport: lpfc_vport pointer.
5791 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
5793 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
5794 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
5795 lpfc_tgt_queue_depth_init(vport
, lpfc_tgt_queue_depth
);
5796 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
5797 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
5798 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
5799 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
5800 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
5801 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
5802 lpfc_first_burst_size_init(vport
, lpfc_first_burst_size
);
5803 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
5804 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
5805 lpfc_max_luns_init(vport
, lpfc_max_luns
);
5806 lpfc_scan_down_init(vport
, lpfc_scan_down
);
5807 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);