1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2009 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/aer.h>
27 #include <linux/gfp.h>
29 #include <scsi/scsi.h>
30 #include <scsi/scsi_device.h>
31 #include <scsi/scsi_host.h>
32 #include <scsi/scsi_tcq.h>
33 #include <scsi/scsi_transport_fc.h>
34 #include <scsi/fc/fc_fs.h>
39 #include "lpfc_sli4.h"
41 #include "lpfc_disc.h"
42 #include "lpfc_scsi.h"
44 #include "lpfc_logmsg.h"
45 #include "lpfc_version.h"
46 #include "lpfc_compat.h"
47 #include "lpfc_crtn.h"
48 #include "lpfc_vport.h"
50 #define LPFC_DEF_DEVLOSS_TMO 30
51 #define LPFC_MIN_DEVLOSS_TMO 1
52 #define LPFC_MAX_DEVLOSS_TMO 255
54 #define LPFC_MAX_LINK_SPEED 8
55 #define LPFC_LINK_SPEED_BITMAP 0x00000117
56 #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8"
59 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
60 * @incr: integer to convert.
61 * @hdw: ascii string holding converted integer plus a string terminator.
64 * JEDEC Joint Electron Device Engineering Council.
65 * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii
66 * character string. The string is then terminated with a NULL in byte 9.
67 * Hex 0-9 becomes ascii '0' to '9'.
68 * Hex a-f becomes ascii '=' to 'B' capital B.
71 * Coded for 32 bit integers only.
74 lpfc_jedec_to_ascii(int incr
, char hdw
[])
77 for (i
= 0; i
< 8; i
++) {
80 hdw
[7 - i
] = 0x30 + j
;
82 hdw
[7 - i
] = 0x61 + j
- 10;
90 * lpfc_drvr_version_show - Return the Emulex driver string with version number
91 * @dev: class unused variable.
92 * @attr: device attribute, not used.
93 * @buf: on return contains the module description text.
95 * Returns: size of formatted string.
98 lpfc_drvr_version_show(struct device
*dev
, struct device_attribute
*attr
,
101 return snprintf(buf
, PAGE_SIZE
, LPFC_MODULE_DESC
"\n");
105 * lpfc_enable_fip_show - Return the fip mode of the HBA
106 * @dev: class unused variable.
107 * @attr: device attribute, not used.
108 * @buf: on return contains the module description text.
110 * Returns: size of formatted string.
113 lpfc_enable_fip_show(struct device
*dev
, struct device_attribute
*attr
,
116 struct Scsi_Host
*shost
= class_to_shost(dev
);
117 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
118 struct lpfc_hba
*phba
= vport
->phba
;
120 if (phba
->hba_flag
& HBA_FIP_SUPPORT
)
121 return snprintf(buf
, PAGE_SIZE
, "1\n");
123 return snprintf(buf
, PAGE_SIZE
, "0\n");
127 lpfc_bg_info_show(struct device
*dev
, struct device_attribute
*attr
,
130 struct Scsi_Host
*shost
= class_to_shost(dev
);
131 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
132 struct lpfc_hba
*phba
= vport
->phba
;
134 if (phba
->cfg_enable_bg
)
135 if (phba
->sli3_options
& LPFC_SLI3_BG_ENABLED
)
136 return snprintf(buf
, PAGE_SIZE
, "BlockGuard Enabled\n");
138 return snprintf(buf
, PAGE_SIZE
,
139 "BlockGuard Not Supported\n");
141 return snprintf(buf
, PAGE_SIZE
,
142 "BlockGuard Disabled\n");
146 lpfc_bg_guard_err_show(struct device
*dev
, struct device_attribute
*attr
,
149 struct Scsi_Host
*shost
= class_to_shost(dev
);
150 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
151 struct lpfc_hba
*phba
= vport
->phba
;
153 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
154 (unsigned long long)phba
->bg_guard_err_cnt
);
158 lpfc_bg_apptag_err_show(struct device
*dev
, struct device_attribute
*attr
,
161 struct Scsi_Host
*shost
= class_to_shost(dev
);
162 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
163 struct lpfc_hba
*phba
= vport
->phba
;
165 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
166 (unsigned long long)phba
->bg_apptag_err_cnt
);
170 lpfc_bg_reftag_err_show(struct device
*dev
, struct device_attribute
*attr
,
173 struct Scsi_Host
*shost
= class_to_shost(dev
);
174 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
175 struct lpfc_hba
*phba
= vport
->phba
;
177 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
178 (unsigned long long)phba
->bg_reftag_err_cnt
);
182 * lpfc_info_show - Return some pci info about the host in ascii
183 * @dev: class converted to a Scsi_host structure.
184 * @attr: device attribute, not used.
185 * @buf: on return contains the formatted text from lpfc_info().
187 * Returns: size of formatted string.
190 lpfc_info_show(struct device
*dev
, struct device_attribute
*attr
,
193 struct Scsi_Host
*host
= class_to_shost(dev
);
195 return snprintf(buf
, PAGE_SIZE
, "%s\n",lpfc_info(host
));
199 * lpfc_serialnum_show - Return the hba serial number in ascii
200 * @dev: class converted to a Scsi_host structure.
201 * @attr: device attribute, not used.
202 * @buf: on return contains the formatted text serial number.
204 * Returns: size of formatted string.
207 lpfc_serialnum_show(struct device
*dev
, struct device_attribute
*attr
,
210 struct Scsi_Host
*shost
= class_to_shost(dev
);
211 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
212 struct lpfc_hba
*phba
= vport
->phba
;
214 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->SerialNumber
);
218 * lpfc_temp_sensor_show - Return the temperature sensor level
219 * @dev: class converted to a Scsi_host structure.
220 * @attr: device attribute, not used.
221 * @buf: on return contains the formatted support level.
224 * Returns a number indicating the temperature sensor level currently
225 * supported, zero or one in ascii.
227 * Returns: size of formatted string.
230 lpfc_temp_sensor_show(struct device
*dev
, struct device_attribute
*attr
,
233 struct Scsi_Host
*shost
= class_to_shost(dev
);
234 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
235 struct lpfc_hba
*phba
= vport
->phba
;
236 return snprintf(buf
, PAGE_SIZE
, "%d\n",phba
->temp_sensor_support
);
240 * lpfc_modeldesc_show - Return the model description of the hba
241 * @dev: class converted to a Scsi_host structure.
242 * @attr: device attribute, not used.
243 * @buf: on return contains the scsi vpd model description.
245 * Returns: size of formatted string.
248 lpfc_modeldesc_show(struct device
*dev
, struct device_attribute
*attr
,
251 struct Scsi_Host
*shost
= class_to_shost(dev
);
252 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
253 struct lpfc_hba
*phba
= vport
->phba
;
255 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelDesc
);
259 * lpfc_modelname_show - Return the model name of the hba
260 * @dev: class converted to a Scsi_host structure.
261 * @attr: device attribute, not used.
262 * @buf: on return contains the scsi vpd model name.
264 * Returns: size of formatted string.
267 lpfc_modelname_show(struct device
*dev
, struct device_attribute
*attr
,
270 struct Scsi_Host
*shost
= class_to_shost(dev
);
271 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
272 struct lpfc_hba
*phba
= vport
->phba
;
274 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelName
);
278 * lpfc_programtype_show - Return the program type of the hba
279 * @dev: class converted to a Scsi_host structure.
280 * @attr: device attribute, not used.
281 * @buf: on return contains the scsi vpd program type.
283 * Returns: size of formatted string.
286 lpfc_programtype_show(struct device
*dev
, struct device_attribute
*attr
,
289 struct Scsi_Host
*shost
= class_to_shost(dev
);
290 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
291 struct lpfc_hba
*phba
= vport
->phba
;
293 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ProgramType
);
297 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
298 * @dev: class converted to a Scsi_host structure.
299 * @attr: device attribute, not used.
300 * @buf: on return contains the Menlo Maintenance sli flag.
302 * Returns: size of formatted string.
305 lpfc_mlomgmt_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
307 struct Scsi_Host
*shost
= class_to_shost(dev
);
308 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
309 struct lpfc_hba
*phba
= vport
->phba
;
311 return snprintf(buf
, PAGE_SIZE
, "%d\n",
312 (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
));
316 * lpfc_vportnum_show - Return the port number in ascii of the hba
317 * @dev: class converted to a Scsi_host structure.
318 * @attr: device attribute, not used.
319 * @buf: on return contains scsi vpd program type.
321 * Returns: size of formatted string.
324 lpfc_vportnum_show(struct device
*dev
, struct device_attribute
*attr
,
327 struct Scsi_Host
*shost
= class_to_shost(dev
);
328 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
329 struct lpfc_hba
*phba
= vport
->phba
;
331 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->Port
);
335 * lpfc_fwrev_show - Return the firmware rev running in the hba
336 * @dev: class converted to a Scsi_host structure.
337 * @attr: device attribute, not used.
338 * @buf: on return contains the scsi vpd program type.
340 * Returns: size of formatted string.
343 lpfc_fwrev_show(struct device
*dev
, struct device_attribute
*attr
,
346 struct Scsi_Host
*shost
= class_to_shost(dev
);
347 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
348 struct lpfc_hba
*phba
= vport
->phba
;
351 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
352 return snprintf(buf
, PAGE_SIZE
, "%s, sli-%d\n", fwrev
, phba
->sli_rev
);
356 * lpfc_hdw_show - Return the jedec information about the hba
357 * @dev: class converted to a Scsi_host structure.
358 * @attr: device attribute, not used.
359 * @buf: on return contains the scsi vpd program type.
361 * Returns: size of formatted string.
364 lpfc_hdw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
367 struct Scsi_Host
*shost
= class_to_shost(dev
);
368 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
369 struct lpfc_hba
*phba
= vport
->phba
;
370 lpfc_vpd_t
*vp
= &phba
->vpd
;
372 lpfc_jedec_to_ascii(vp
->rev
.biuRev
, hdw
);
373 return snprintf(buf
, PAGE_SIZE
, "%s\n", hdw
);
377 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
378 * @dev: class converted to a Scsi_host structure.
379 * @attr: device attribute, not used.
380 * @buf: on return contains the ROM and FCode ascii strings.
382 * Returns: size of formatted string.
385 lpfc_option_rom_version_show(struct device
*dev
, struct device_attribute
*attr
,
388 struct Scsi_Host
*shost
= class_to_shost(dev
);
389 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
390 struct lpfc_hba
*phba
= vport
->phba
;
392 return snprintf(buf
, PAGE_SIZE
, "%s\n", phba
->OptionROMVersion
);
396 * lpfc_state_show - Return the link state of the port
397 * @dev: class converted to a Scsi_host structure.
398 * @attr: device attribute, not used.
399 * @buf: on return contains text describing the state of the link.
402 * The switch statement has no default so zero will be returned.
404 * Returns: size of formatted string.
407 lpfc_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
410 struct Scsi_Host
*shost
= class_to_shost(dev
);
411 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
412 struct lpfc_hba
*phba
= vport
->phba
;
415 switch (phba
->link_state
) {
416 case LPFC_LINK_UNKNOWN
:
417 case LPFC_WARM_START
:
418 case LPFC_INIT_START
:
419 case LPFC_INIT_MBX_CMDS
:
422 if (phba
->hba_flag
& LINK_DISABLED
)
423 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
424 "Link Down - User disabled\n");
426 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
432 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Link Up - ");
434 switch (vport
->port_state
) {
435 case LPFC_LOCAL_CFG_LINK
:
436 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
437 "Configuring Link\n");
441 case LPFC_FABRIC_CFG_LINK
:
444 case LPFC_BUILD_DISC_LIST
:
446 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
449 case LPFC_VPORT_READY
:
450 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Ready\n");
453 case LPFC_VPORT_FAILED
:
454 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Failed\n");
457 case LPFC_VPORT_UNKNOWN
:
458 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
462 if (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
)
463 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
464 " Menlo Maint Mode\n");
465 else if (phba
->fc_topology
== TOPOLOGY_LOOP
) {
466 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
467 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
470 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
473 if (vport
->fc_flag
& FC_FABRIC
)
474 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
477 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
486 * lpfc_link_state_store - Transition the link_state on an HBA port
487 * @dev: class device that is converted into a Scsi_host.
488 * @attr: device attribute, not used.
489 * @buf: one or more lpfc_polling_flags values.
493 * -EINVAL if the buffer is not "up" or "down"
494 * return from link state change function if non-zero
495 * length of the buf on success
498 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
499 const char *buf
, size_t count
)
501 struct Scsi_Host
*shost
= class_to_shost(dev
);
502 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
503 struct lpfc_hba
*phba
= vport
->phba
;
505 int status
= -EINVAL
;
507 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
508 (phba
->link_state
== LPFC_LINK_DOWN
))
509 status
= phba
->lpfc_hba_init_link(phba
);
510 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
511 (phba
->link_state
>= LPFC_LINK_UP
))
512 status
= phba
->lpfc_hba_down_link(phba
);
521 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
522 * @dev: class device that is converted into a Scsi_host.
523 * @attr: device attribute, not used.
524 * @buf: on return contains the sum of fc mapped and unmapped.
527 * Returns the ascii text number of the sum of the fc mapped and unmapped
530 * Returns: size of formatted string.
533 lpfc_num_discovered_ports_show(struct device
*dev
,
534 struct device_attribute
*attr
, char *buf
)
536 struct Scsi_Host
*shost
= class_to_shost(dev
);
537 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
539 return snprintf(buf
, PAGE_SIZE
, "%d\n",
540 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
544 * lpfc_issue_lip - Misnomer, name carried over from long ago
545 * @shost: Scsi_Host pointer.
548 * Bring the link down gracefully then re-init the link. The firmware will
549 * re-init the fiber channel interface as required. Does not issue a LIP.
552 * -EPERM port offline or management commands are being blocked
553 * -ENOMEM cannot allocate memory for the mailbox command
554 * -EIO error sending the mailbox command
558 lpfc_issue_lip(struct Scsi_Host
*shost
)
560 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
561 struct lpfc_hba
*phba
= vport
->phba
;
562 LPFC_MBOXQ_t
*pmboxq
;
563 int mbxstatus
= MBXERR_ERROR
;
565 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
566 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
569 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
574 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
575 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
576 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
578 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
580 if ((mbxstatus
== MBX_SUCCESS
) &&
581 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
582 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
583 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
584 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
585 phba
->cfg_link_speed
);
586 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
590 lpfc_set_loopback_flag(phba
);
591 if (mbxstatus
!= MBX_TIMEOUT
)
592 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
594 if (mbxstatus
== MBXERR_ERROR
)
601 * lpfc_do_offline - Issues a mailbox command to bring the link down
602 * @phba: lpfc_hba pointer.
603 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
606 * Assumes any error from lpfc_do_offline() will be negative.
607 * Can wait up to 5 seconds for the port ring buffers count
608 * to reach zero, prints a warning if it is not zero and continues.
609 * lpfc_workq_post_event() returns a non-zero return code if call fails.
612 * -EIO error posting the event
616 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
618 struct completion online_compl
;
619 struct lpfc_sli_ring
*pring
;
620 struct lpfc_sli
*psli
;
625 init_completion(&online_compl
);
626 lpfc_workq_post_event(phba
, &status
, &online_compl
,
627 LPFC_EVT_OFFLINE_PREP
);
628 wait_for_completion(&online_compl
);
635 /* Wait a little for things to settle down, but not
636 * long enough for dev loss timeout to expire.
638 for (i
= 0; i
< psli
->num_rings
; i
++) {
639 pring
= &psli
->ring
[i
];
640 while (pring
->txcmplq_cnt
) {
642 if (cnt
++ > 500) { /* 5 secs */
643 lpfc_printf_log(phba
,
644 KERN_WARNING
, LOG_INIT
,
645 "0466 Outstanding IO when "
646 "bringing Adapter offline\n");
652 init_completion(&online_compl
);
653 lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
654 wait_for_completion(&online_compl
);
663 * lpfc_selective_reset - Offline then onlines the port
664 * @phba: lpfc_hba pointer.
667 * If the port is configured to allow a reset then the hba is brought
668 * offline then online.
671 * Assumes any error from lpfc_do_offline() will be negative.
674 * lpfc_do_offline() return code if not zero
675 * -EIO reset not configured or error posting the event
679 lpfc_selective_reset(struct lpfc_hba
*phba
)
681 struct completion online_compl
;
684 if (!phba
->cfg_enable_hba_reset
)
687 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
692 init_completion(&online_compl
);
693 lpfc_workq_post_event(phba
, &status
, &online_compl
,
695 wait_for_completion(&online_compl
);
704 * lpfc_issue_reset - Selectively resets an adapter
705 * @dev: class device that is converted into a Scsi_host.
706 * @attr: device attribute, not used.
707 * @buf: containing the string "selective".
708 * @count: unused variable.
711 * If the buf contains the string "selective" then lpfc_selective_reset()
712 * is called to perform the reset.
715 * Assumes any error from lpfc_selective_reset() will be negative.
716 * If lpfc_selective_reset() returns zero then the length of the buffer
717 * is returned which indicates success
720 * -EINVAL if the buffer does not contain the string "selective"
721 * length of buf if lpfc-selective_reset() if the call succeeds
722 * return value of lpfc_selective_reset() if the call fails
725 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
726 const char *buf
, size_t count
)
728 struct Scsi_Host
*shost
= class_to_shost(dev
);
729 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
730 struct lpfc_hba
*phba
= vport
->phba
;
732 int status
= -EINVAL
;
734 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
735 status
= lpfc_selective_reset(phba
);
744 * lpfc_nport_evt_cnt_show - Return the number of nport events
745 * @dev: class device that is converted into a Scsi_host.
746 * @attr: device attribute, not used.
747 * @buf: on return contains the ascii number of nport events.
749 * Returns: size of formatted string.
752 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
755 struct Scsi_Host
*shost
= class_to_shost(dev
);
756 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
757 struct lpfc_hba
*phba
= vport
->phba
;
759 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
763 * lpfc_board_mode_show - Return the state of the board
764 * @dev: class device that is converted into a Scsi_host.
765 * @attr: device attribute, not used.
766 * @buf: on return contains the state of the adapter.
768 * Returns: size of formatted string.
771 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
774 struct Scsi_Host
*shost
= class_to_shost(dev
);
775 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
776 struct lpfc_hba
*phba
= vport
->phba
;
779 if (phba
->link_state
== LPFC_HBA_ERROR
)
781 else if (phba
->link_state
== LPFC_WARM_START
)
782 state
= "warm start";
783 else if (phba
->link_state
== LPFC_INIT_START
)
788 return snprintf(buf
, PAGE_SIZE
, "%s\n", state
);
792 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
793 * @dev: class device that is converted into a Scsi_host.
794 * @attr: device attribute, not used.
795 * @buf: containing one of the strings "online", "offline", "warm" or "error".
796 * @count: unused variable.
799 * -EACCES if enable hba reset not enabled
800 * -EINVAL if the buffer does not contain a valid string (see above)
801 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
802 * buf length greater than zero indicates success
805 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
806 const char *buf
, size_t count
)
808 struct Scsi_Host
*shost
= class_to_shost(dev
);
809 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
810 struct lpfc_hba
*phba
= vport
->phba
;
811 struct completion online_compl
;
814 if (!phba
->cfg_enable_hba_reset
)
816 init_completion(&online_compl
);
818 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
819 lpfc_workq_post_event(phba
, &status
, &online_compl
,
821 wait_for_completion(&online_compl
);
822 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
823 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
824 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
825 if (phba
->sli_rev
== LPFC_SLI_REV4
)
828 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
829 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
830 if (phba
->sli_rev
== LPFC_SLI_REV4
)
833 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
844 * lpfc_get_hba_info - Return various bits of informaton about the adapter
845 * @phba: pointer to the adapter structure.
846 * @mxri: max xri count.
847 * @axri: available xri count.
848 * @mrpi: max rpi count.
849 * @arpi: available rpi count.
850 * @mvpi: max vpi count.
851 * @avpi: available vpi count.
854 * If an integer pointer for an count is not null then the value for the
862 lpfc_get_hba_info(struct lpfc_hba
*phba
,
863 uint32_t *mxri
, uint32_t *axri
,
864 uint32_t *mrpi
, uint32_t *arpi
,
865 uint32_t *mvpi
, uint32_t *avpi
)
867 struct lpfc_sli
*psli
= &phba
->sli
;
868 struct lpfc_mbx_read_config
*rd_config
;
869 LPFC_MBOXQ_t
*pmboxq
;
875 * prevent udev from issuing mailbox commands until the port is
878 if (phba
->link_state
< LPFC_LINK_DOWN
||
879 !phba
->mbox_mem_pool
||
880 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
883 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
886 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
889 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
892 pmb
->mbxCommand
= MBX_READ_CONFIG
;
893 pmb
->mbxOwner
= OWN_HOST
;
894 pmboxq
->context1
= NULL
;
896 if ((phba
->pport
->fc_flag
& FC_OFFLINE_MODE
) ||
897 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
898 rc
= MBX_NOT_FINISHED
;
900 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
902 if (rc
!= MBX_SUCCESS
) {
903 if (rc
!= MBX_TIMEOUT
)
904 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
908 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
909 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
911 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
913 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
914 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
916 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
918 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
919 phba
->sli4_hba
.max_cfg_param
.xri_used
;
921 /* Account for differences with SLI-3. Get vpi count from
922 * mailbox data and subtract one for max vpi value.
924 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
925 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
930 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
933 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
935 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
937 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
939 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
941 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
943 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
946 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
951 * lpfc_max_rpi_show - Return maximum rpi
952 * @dev: class device that is converted into a Scsi_host.
953 * @attr: device attribute, not used.
954 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
957 * Calls lpfc_get_hba_info() asking for just the mrpi count.
958 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
959 * to "Unknown" and the buffer length is returned, therefore the caller
960 * must check for "Unknown" in the buffer to detect a failure.
962 * Returns: size of formatted string.
965 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
968 struct Scsi_Host
*shost
= class_to_shost(dev
);
969 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
970 struct lpfc_hba
*phba
= vport
->phba
;
973 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
974 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
975 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
979 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
980 * @dev: class device that is converted into a Scsi_host.
981 * @attr: device attribute, not used.
982 * @buf: containing the used rpi count in decimal or "Unknown".
985 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
986 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
987 * to "Unknown" and the buffer length is returned, therefore the caller
988 * must check for "Unknown" in the buffer to detect a failure.
990 * Returns: size of formatted string.
993 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
996 struct Scsi_Host
*shost
= class_to_shost(dev
);
997 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
998 struct lpfc_hba
*phba
= vport
->phba
;
1001 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1002 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1003 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1007 * lpfc_max_xri_show - Return maximum xri
1008 * @dev: class device that is converted into a Scsi_host.
1009 * @attr: device attribute, not used.
1010 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1013 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1014 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1015 * to "Unknown" and the buffer length is returned, therefore the caller
1016 * must check for "Unknown" in the buffer to detect a failure.
1018 * Returns: size of formatted string.
1021 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1024 struct Scsi_Host
*shost
= class_to_shost(dev
);
1025 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1026 struct lpfc_hba
*phba
= vport
->phba
;
1029 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
1030 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1031 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1035 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1036 * @dev: class device that is converted into a Scsi_host.
1037 * @attr: device attribute, not used.
1038 * @buf: on return contains the used xri count in decimal or "Unknown".
1041 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1042 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1043 * to "Unknown" and the buffer length is returned, therefore the caller
1044 * must check for "Unknown" in the buffer to detect a failure.
1046 * Returns: size of formatted string.
1049 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1052 struct Scsi_Host
*shost
= class_to_shost(dev
);
1053 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1054 struct lpfc_hba
*phba
= vport
->phba
;
1057 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
1058 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1059 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1063 * lpfc_max_vpi_show - Return maximum vpi
1064 * @dev: class device that is converted into a Scsi_host.
1065 * @attr: device attribute, not used.
1066 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1069 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1070 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1071 * to "Unknown" and the buffer length is returned, therefore the caller
1072 * must check for "Unknown" in the buffer to detect a failure.
1074 * Returns: size of formatted string.
1077 lpfc_max_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1080 struct Scsi_Host
*shost
= class_to_shost(dev
);
1081 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1082 struct lpfc_hba
*phba
= vport
->phba
;
1085 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
1086 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1087 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1091 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1092 * @dev: class device that is converted into a Scsi_host.
1093 * @attr: device attribute, not used.
1094 * @buf: on return contains the used vpi count in decimal or "Unknown".
1097 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1098 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1099 * to "Unknown" and the buffer length is returned, therefore the caller
1100 * must check for "Unknown" in the buffer to detect a failure.
1102 * Returns: size of formatted string.
1105 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1108 struct Scsi_Host
*shost
= class_to_shost(dev
);
1109 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1110 struct lpfc_hba
*phba
= vport
->phba
;
1113 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
1114 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1115 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1119 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1120 * @dev: class device that is converted into a Scsi_host.
1121 * @attr: device attribute, not used.
1122 * @buf: text that must be interpreted to determine if npiv is supported.
1125 * Buffer will contain text indicating npiv is not suppoerted on the port,
1126 * the port is an NPIV physical port, or it is an npiv virtual port with
1127 * the id of the vport.
1129 * Returns: size of formatted string.
1132 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
1135 struct Scsi_Host
*shost
= class_to_shost(dev
);
1136 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1137 struct lpfc_hba
*phba
= vport
->phba
;
1139 if (!(phba
->max_vpi
))
1140 return snprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
1141 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1142 return snprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
1143 return snprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
1147 * lpfc_poll_show - Return text about poll support for the adapter
1148 * @dev: class device that is converted into a Scsi_host.
1149 * @attr: device attribute, not used.
1150 * @buf: on return contains the cfg_poll in hex.
1153 * cfg_poll should be a lpfc_polling_flags type.
1155 * Returns: size of formatted string.
1158 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
1161 struct Scsi_Host
*shost
= class_to_shost(dev
);
1162 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1163 struct lpfc_hba
*phba
= vport
->phba
;
1165 return snprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
1169 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1170 * @dev: class device that is converted into a Scsi_host.
1171 * @attr: device attribute, not used.
1172 * @buf: one or more lpfc_polling_flags values.
1176 * buf contents converted to integer and checked for a valid value.
1179 * -EINVAL if the buffer connot be converted or is out of range
1180 * length of the buf on success
1183 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
1184 const char *buf
, size_t count
)
1186 struct Scsi_Host
*shost
= class_to_shost(dev
);
1187 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1188 struct lpfc_hba
*phba
= vport
->phba
;
1193 if (!isdigit(buf
[0]))
1196 if (sscanf(buf
, "%i", &val
) != 1)
1199 if ((val
& 0x3) != val
)
1202 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1205 spin_lock_irq(&phba
->hbalock
);
1207 old_val
= phba
->cfg_poll
;
1209 if (val
& ENABLE_FCP_RING_POLLING
) {
1210 if ((val
& DISABLE_FCP_RING_INT
) &&
1211 !(old_val
& DISABLE_FCP_RING_INT
)) {
1212 creg_val
= readl(phba
->HCregaddr
);
1213 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
1214 writel(creg_val
, phba
->HCregaddr
);
1215 readl(phba
->HCregaddr
); /* flush */
1217 lpfc_poll_start_timer(phba
);
1219 } else if (val
!= 0x0) {
1220 spin_unlock_irq(&phba
->hbalock
);
1224 if (!(val
& DISABLE_FCP_RING_INT
) &&
1225 (old_val
& DISABLE_FCP_RING_INT
))
1227 spin_unlock_irq(&phba
->hbalock
);
1228 del_timer(&phba
->fcp_poll_timer
);
1229 spin_lock_irq(&phba
->hbalock
);
1230 creg_val
= readl(phba
->HCregaddr
);
1231 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
1232 writel(creg_val
, phba
->HCregaddr
);
1233 readl(phba
->HCregaddr
); /* flush */
1236 phba
->cfg_poll
= val
;
1238 spin_unlock_irq(&phba
->hbalock
);
1244 * lpfc_param_show - Return a cfg attribute value in decimal
1247 * Macro that given an attr e.g. hba_queue_depth expands
1248 * into a function with the name lpfc_hba_queue_depth_show.
1250 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
1251 * @dev: class device that is converted into a Scsi_host.
1252 * @attr: device attribute, not used.
1253 * @buf: on return contains the attribute value in decimal.
1255 * Returns: size of formatted string.
1257 #define lpfc_param_show(attr) \
1259 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1262 struct Scsi_Host *shost = class_to_shost(dev);\
1263 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1264 struct lpfc_hba *phba = vport->phba;\
1266 val = phba->cfg_##attr;\
1267 return snprintf(buf, PAGE_SIZE, "%d\n",\
1272 * lpfc_param_hex_show - Return a cfg attribute value in hex
1275 * Macro that given an attr e.g. hba_queue_depth expands
1276 * into a function with the name lpfc_hba_queue_depth_show
1278 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
1279 * @dev: class device that is converted into a Scsi_host.
1280 * @attr: device attribute, not used.
1281 * @buf: on return contains the attribute value in hexadecimal.
1283 * Returns: size of formatted string.
1285 #define lpfc_param_hex_show(attr) \
1287 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1290 struct Scsi_Host *shost = class_to_shost(dev);\
1291 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1292 struct lpfc_hba *phba = vport->phba;\
1294 val = phba->cfg_##attr;\
1295 return snprintf(buf, PAGE_SIZE, "%#x\n",\
1300 * lpfc_param_init - Intializes a cfg attribute
1303 * Macro that given an attr e.g. hba_queue_depth expands
1304 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1305 * takes a default argument, a minimum and maximum argument.
1307 * lpfc_##attr##_init: Initializes an attribute.
1308 * @phba: pointer the the adapter structure.
1309 * @val: integer attribute value.
1311 * Validates the min and max values then sets the adapter config field
1312 * accordingly, or uses the default if out of range and prints an error message.
1316 * -EINVAL if default used
1318 #define lpfc_param_init(attr, default, minval, maxval) \
1320 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1322 if (val >= minval && val <= maxval) {\
1323 phba->cfg_##attr = val;\
1326 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1327 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
1328 "allowed range is ["#minval", "#maxval"]\n", val); \
1329 phba->cfg_##attr = default;\
1334 * lpfc_param_set - Set a cfg attribute value
1337 * Macro that given an attr e.g. hba_queue_depth expands
1338 * into a function with the name lpfc_hba_queue_depth_set
1340 * lpfc_##attr##_set: Sets an attribute value.
1341 * @phba: pointer the the adapter structure.
1342 * @val: integer attribute value.
1345 * Validates the min and max values then sets the
1346 * adapter config field if in the valid range. prints error message
1347 * and does not set the parameter if invalid.
1351 * -EINVAL if val is invalid
1353 #define lpfc_param_set(attr, default, minval, maxval) \
1355 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
1357 if (val >= minval && val <= maxval) {\
1358 phba->cfg_##attr = val;\
1361 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1362 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
1363 "allowed range is ["#minval", "#maxval"]\n", val); \
1368 * lpfc_param_store - Set a vport attribute value
1371 * Macro that given an attr e.g. hba_queue_depth expands
1372 * into a function with the name lpfc_hba_queue_depth_store.
1374 * lpfc_##attr##_store: Set an sttribute value.
1375 * @dev: class device that is converted into a Scsi_host.
1376 * @attr: device attribute, not used.
1377 * @buf: contains the attribute value in ascii.
1381 * Convert the ascii text number to an integer, then
1382 * use the lpfc_##attr##_set function to set the value.
1385 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1386 * length of buffer upon success.
1388 #define lpfc_param_store(attr) \
1390 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1391 const char *buf, size_t count) \
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;\
1397 if (!isdigit(buf[0]))\
1399 if (sscanf(buf, "%i", &val) != 1)\
1401 if (lpfc_##attr##_set(phba, val) == 0) \
1402 return strlen(buf);\
1408 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
1411 * Macro that given an attr e.g. hba_queue_depth expands
1412 * into a function with the name lpfc_hba_queue_depth_show
1414 * lpfc_##attr##_show: prints the attribute value in decimal.
1415 * @dev: class device that is converted into a Scsi_host.
1416 * @attr: device attribute, not used.
1417 * @buf: on return contains the attribute value in decimal.
1419 * Returns: length of formatted string.
1421 #define lpfc_vport_param_show(attr) \
1423 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1426 struct Scsi_Host *shost = class_to_shost(dev);\
1427 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1429 val = vport->cfg_##attr;\
1430 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
1434 * lpfc_vport_param_hex_show - Return hex formatted attribute value
1437 * Macro that given an attr e.g.
1438 * hba_queue_depth expands into a function with the name
1439 * lpfc_hba_queue_depth_show
1441 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
1442 * @dev: class device that is converted into a Scsi_host.
1443 * @attr: device attribute, not used.
1444 * @buf: on return contains the attribute value in hexadecimal.
1446 * Returns: length of formatted string.
1448 #define lpfc_vport_param_hex_show(attr) \
1450 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1453 struct Scsi_Host *shost = class_to_shost(dev);\
1454 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1456 val = vport->cfg_##attr;\
1457 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
1461 * lpfc_vport_param_init - Initialize a vport cfg attribute
1464 * Macro that given an attr e.g. hba_queue_depth expands
1465 * into a function with the name lpfc_hba_queue_depth_init. The macro also
1466 * takes a default argument, a minimum and maximum argument.
1468 * lpfc_##attr##_init: validates the min and max values then sets the
1469 * adapter config field accordingly, or uses the default if out of range
1470 * and prints an error message.
1471 * @phba: pointer the the adapter structure.
1472 * @val: integer attribute value.
1476 * -EINVAL if default used
1478 #define lpfc_vport_param_init(attr, default, minval, maxval) \
1480 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
1482 if (val >= minval && val <= maxval) {\
1483 vport->cfg_##attr = val;\
1486 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1487 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
1488 "allowed range is ["#minval", "#maxval"]\n", val); \
1489 vport->cfg_##attr = default;\
1494 * lpfc_vport_param_set - Set a vport cfg attribute
1497 * Macro that given an attr e.g. hba_queue_depth expands
1498 * into a function with the name lpfc_hba_queue_depth_set
1500 * lpfc_##attr##_set: validates the min and max values then sets the
1501 * adapter config field if in the valid range. prints error message
1502 * and does not set the parameter if invalid.
1503 * @phba: pointer the the adapter structure.
1504 * @val: integer attribute value.
1508 * -EINVAL if val is invalid
1510 #define lpfc_vport_param_set(attr, default, minval, maxval) \
1512 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
1514 if (val >= minval && val <= maxval) {\
1515 vport->cfg_##attr = val;\
1518 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1519 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
1520 "allowed range is ["#minval", "#maxval"]\n", val); \
1525 * lpfc_vport_param_store - Set a vport attribute
1528 * Macro that given an attr e.g. hba_queue_depth
1529 * expands into a function with the name lpfc_hba_queue_depth_store
1531 * lpfc_##attr##_store: convert the ascii text number to an integer, then
1532 * use the lpfc_##attr##_set function to set the value.
1533 * @cdev: class device that is converted into a Scsi_host.
1534 * @buf: contains the attribute value in decimal.
1538 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
1539 * length of buffer upon success.
1541 #define lpfc_vport_param_store(attr) \
1543 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1544 const char *buf, size_t count) \
1546 struct Scsi_Host *shost = class_to_shost(dev);\
1547 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1549 if (!isdigit(buf[0]))\
1551 if (sscanf(buf, "%i", &val) != 1)\
1553 if (lpfc_##attr##_set(vport, val) == 0) \
1554 return strlen(buf);\
1560 #define LPFC_ATTR(name, defval, minval, maxval, desc) \
1561 static uint lpfc_##name = defval;\
1562 module_param(lpfc_##name, uint, 0);\
1563 MODULE_PARM_DESC(lpfc_##name, desc);\
1564 lpfc_param_init(name, defval, minval, maxval)
1566 #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \
1567 static uint lpfc_##name = defval;\
1568 module_param(lpfc_##name, uint, 0);\
1569 MODULE_PARM_DESC(lpfc_##name, desc);\
1570 lpfc_param_show(name)\
1571 lpfc_param_init(name, defval, minval, maxval)\
1572 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1574 #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \
1575 static uint lpfc_##name = defval;\
1576 module_param(lpfc_##name, uint, 0);\
1577 MODULE_PARM_DESC(lpfc_##name, desc);\
1578 lpfc_param_show(name)\
1579 lpfc_param_init(name, defval, minval, maxval)\
1580 lpfc_param_set(name, defval, minval, maxval)\
1581 lpfc_param_store(name)\
1582 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1583 lpfc_##name##_show, lpfc_##name##_store)
1585 #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1586 static uint lpfc_##name = defval;\
1587 module_param(lpfc_##name, uint, 0);\
1588 MODULE_PARM_DESC(lpfc_##name, desc);\
1589 lpfc_param_hex_show(name)\
1590 lpfc_param_init(name, defval, minval, maxval)\
1591 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1593 #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1594 static uint lpfc_##name = defval;\
1595 module_param(lpfc_##name, uint, 0);\
1596 MODULE_PARM_DESC(lpfc_##name, desc);\
1597 lpfc_param_hex_show(name)\
1598 lpfc_param_init(name, defval, minval, maxval)\
1599 lpfc_param_set(name, defval, minval, maxval)\
1600 lpfc_param_store(name)\
1601 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1602 lpfc_##name##_show, lpfc_##name##_store)
1604 #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
1605 static uint lpfc_##name = defval;\
1606 module_param(lpfc_##name, uint, 0);\
1607 MODULE_PARM_DESC(lpfc_##name, desc);\
1608 lpfc_vport_param_init(name, defval, minval, maxval)
1610 #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
1611 static uint lpfc_##name = defval;\
1612 module_param(lpfc_##name, uint, 0);\
1613 MODULE_PARM_DESC(lpfc_##name, desc);\
1614 lpfc_vport_param_show(name)\
1615 lpfc_vport_param_init(name, defval, minval, maxval)\
1616 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1618 #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
1619 static uint lpfc_##name = defval;\
1620 module_param(lpfc_##name, uint, 0);\
1621 MODULE_PARM_DESC(lpfc_##name, desc);\
1622 lpfc_vport_param_show(name)\
1623 lpfc_vport_param_init(name, defval, minval, maxval)\
1624 lpfc_vport_param_set(name, defval, minval, maxval)\
1625 lpfc_vport_param_store(name)\
1626 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1627 lpfc_##name##_show, lpfc_##name##_store)
1629 #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1630 static uint lpfc_##name = defval;\
1631 module_param(lpfc_##name, uint, 0);\
1632 MODULE_PARM_DESC(lpfc_##name, desc);\
1633 lpfc_vport_param_hex_show(name)\
1634 lpfc_vport_param_init(name, defval, minval, maxval)\
1635 static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1637 #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1638 static uint lpfc_##name = defval;\
1639 module_param(lpfc_##name, uint, 0);\
1640 MODULE_PARM_DESC(lpfc_##name, desc);\
1641 lpfc_vport_param_hex_show(name)\
1642 lpfc_vport_param_init(name, defval, minval, maxval)\
1643 lpfc_vport_param_set(name, defval, minval, maxval)\
1644 lpfc_vport_param_store(name)\
1645 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1646 lpfc_##name##_show, lpfc_##name##_store)
1648 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
1649 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
1650 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
1651 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
1652 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
1653 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
1654 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
1655 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
1656 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
1657 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
1658 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
1659 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
1660 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
1661 lpfc_link_state_store
);
1662 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
1663 lpfc_option_rom_version_show
, NULL
);
1664 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
1665 lpfc_num_discovered_ports_show
, NULL
);
1666 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
1667 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
1668 static DEVICE_ATTR(lpfc_drvr_version
, S_IRUGO
, lpfc_drvr_version_show
, NULL
);
1669 static DEVICE_ATTR(lpfc_enable_fip
, S_IRUGO
, lpfc_enable_fip_show
, NULL
);
1670 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
1671 lpfc_board_mode_show
, lpfc_board_mode_store
);
1672 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
1673 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
1674 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
1675 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
1676 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
1677 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
1678 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
1679 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
1680 static DEVICE_ATTR(lpfc_temp_sensor
, S_IRUGO
, lpfc_temp_sensor_show
, NULL
);
1683 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
1686 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
1687 * @dev: class device that is converted into a Scsi_host.
1688 * @attr: device attribute, not used.
1689 * @buf: containing the string lpfc_soft_wwn_key.
1690 * @count: must be size of lpfc_soft_wwn_key.
1693 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
1694 * length of buf indicates success
1697 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
1698 const char *buf
, size_t count
)
1700 struct Scsi_Host
*shost
= class_to_shost(dev
);
1701 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1702 struct lpfc_hba
*phba
= vport
->phba
;
1703 unsigned int cnt
= count
;
1706 * We're doing a simple sanity check for soft_wwpn setting.
1707 * We require that the user write a specific key to enable
1708 * the soft_wwpn attribute to be settable. Once the attribute
1709 * is written, the enable key resets. If further updates are
1710 * desired, the key must be written again to re-enable the
1713 * The "key" is not secret - it is a hardcoded string shown
1714 * here. The intent is to protect against the random user or
1715 * application that is just writing attributes.
1718 /* count may include a LF at end of string */
1719 if (buf
[cnt
-1] == '\n')
1722 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
1723 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
1726 phba
->soft_wwn_enable
= 1;
1729 static DEVICE_ATTR(lpfc_soft_wwn_enable
, S_IWUSR
, NULL
,
1730 lpfc_soft_wwn_enable_store
);
1733 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
1734 * @dev: class device that is converted into a Scsi_host.
1735 * @attr: device attribute, not used.
1736 * @buf: on return contains the wwpn in hexadecimal.
1738 * Returns: size of formatted string.
1741 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
1744 struct Scsi_Host
*shost
= class_to_shost(dev
);
1745 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1746 struct lpfc_hba
*phba
= vport
->phba
;
1748 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
1749 (unsigned long long)phba
->cfg_soft_wwpn
);
1753 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
1754 * @dev class device that is converted into a Scsi_host.
1755 * @attr: device attribute, not used.
1756 * @buf: contains the wwpn in hexadecimal.
1757 * @count: number of wwpn bytes in buf
1760 * -EACCES hba reset not enabled, adapter over temp
1761 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
1762 * -EIO error taking adapter offline or online
1763 * value of count on success
1766 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
1767 const char *buf
, size_t count
)
1769 struct Scsi_Host
*shost
= class_to_shost(dev
);
1770 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1771 struct lpfc_hba
*phba
= vport
->phba
;
1772 struct completion online_compl
;
1773 int stat1
=0, stat2
=0;
1774 unsigned int i
, j
, cnt
=count
;
1777 if (!phba
->cfg_enable_hba_reset
)
1779 spin_lock_irq(&phba
->hbalock
);
1780 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
1781 spin_unlock_irq(&phba
->hbalock
);
1784 spin_unlock_irq(&phba
->hbalock
);
1785 /* count may include a LF at end of string */
1786 if (buf
[cnt
-1] == '\n')
1789 if (!phba
->soft_wwn_enable
|| (cnt
< 16) || (cnt
> 18) ||
1790 ((cnt
== 17) && (*buf
++ != 'x')) ||
1791 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
1794 phba
->soft_wwn_enable
= 0;
1796 memset(wwpn
, 0, sizeof(wwpn
));
1798 /* Validate and store the new name */
1799 for (i
=0, j
=0; i
< 16; i
++) {
1800 if ((*buf
>= 'a') && (*buf
<= 'f'))
1801 j
= ((j
<< 4) | ((*buf
++ -'a') + 10));
1802 else if ((*buf
>= 'A') && (*buf
<= 'F'))
1803 j
= ((j
<< 4) | ((*buf
++ -'A') + 10));
1804 else if ((*buf
>= '0') && (*buf
<= '9'))
1805 j
= ((j
<< 4) | (*buf
++ -'0'));
1809 wwpn
[i
/2] = j
& 0xff;
1813 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
1814 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
1815 if (phba
->cfg_soft_wwnn
)
1816 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
1818 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
1819 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
1821 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1823 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1824 "0463 lpfc_soft_wwpn attribute set failed to "
1825 "reinit adapter - %d\n", stat1
);
1826 init_completion(&online_compl
);
1827 lpfc_workq_post_event(phba
, &stat2
, &online_compl
, LPFC_EVT_ONLINE
);
1828 wait_for_completion(&online_compl
);
1830 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1831 "0464 lpfc_soft_wwpn attribute set failed to "
1832 "reinit adapter - %d\n", stat2
);
1833 return (stat1
|| stat2
) ? -EIO
: count
;
1835 static DEVICE_ATTR(lpfc_soft_wwpn
, S_IRUGO
| S_IWUSR
,\
1836 lpfc_soft_wwpn_show
, lpfc_soft_wwpn_store
);
1839 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
1840 * @dev: class device that is converted into a Scsi_host.
1841 * @attr: device attribute, not used.
1842 * @buf: on return contains the wwnn in hexadecimal.
1844 * Returns: size of formatted string.
1847 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
1850 struct Scsi_Host
*shost
= class_to_shost(dev
);
1851 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
1852 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
1853 (unsigned long long)phba
->cfg_soft_wwnn
);
1857 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
1858 * @cdev: class device that is converted into a Scsi_host.
1859 * @buf: contains the ww node name in hexadecimal.
1860 * @count: number of wwnn bytes in buf.
1863 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
1864 * value of count on success
1867 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
1868 const char *buf
, size_t count
)
1870 struct Scsi_Host
*shost
= class_to_shost(dev
);
1871 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
1872 unsigned int i
, j
, cnt
=count
;
1875 /* count may include a LF at end of string */
1876 if (buf
[cnt
-1] == '\n')
1879 if (!phba
->soft_wwn_enable
|| (cnt
< 16) || (cnt
> 18) ||
1880 ((cnt
== 17) && (*buf
++ != 'x')) ||
1881 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
1885 * Allow wwnn to be set many times, as long as the enable is set.
1886 * However, once the wwpn is set, everything locks.
1889 memset(wwnn
, 0, sizeof(wwnn
));
1891 /* Validate and store the new name */
1892 for (i
=0, j
=0; i
< 16; i
++) {
1893 if ((*buf
>= 'a') && (*buf
<= 'f'))
1894 j
= ((j
<< 4) | ((*buf
++ -'a') + 10));
1895 else if ((*buf
>= 'A') && (*buf
<= 'F'))
1896 j
= ((j
<< 4) | ((*buf
++ -'A') + 10));
1897 else if ((*buf
>= '0') && (*buf
<= '9'))
1898 j
= ((j
<< 4) | (*buf
++ -'0'));
1902 wwnn
[i
/2] = j
& 0xff;
1906 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
1908 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
1909 "lpfc%d: soft_wwnn set. Value will take effect upon "
1910 "setting of the soft_wwpn\n", phba
->brd_no
);
1914 static DEVICE_ATTR(lpfc_soft_wwnn
, S_IRUGO
| S_IWUSR
,\
1915 lpfc_soft_wwnn_show
, lpfc_soft_wwnn_store
);
1918 static int lpfc_poll
= 0;
1919 module_param(lpfc_poll
, int, 0);
1920 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
1922 " 1 - poll with interrupts enabled"
1923 " 3 - poll and disable FCP ring interrupts");
1925 static DEVICE_ATTR(lpfc_poll
, S_IRUGO
| S_IWUSR
,
1926 lpfc_poll_show
, lpfc_poll_store
);
1928 int lpfc_sli_mode
= 0;
1929 module_param(lpfc_sli_mode
, int, 0);
1930 MODULE_PARM_DESC(lpfc_sli_mode
, "SLI mode selector:"
1931 " 0 - auto (SLI-3 if supported),"
1932 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
1933 " 3 - select SLI-3");
1935 int lpfc_enable_npiv
= 1;
1936 module_param(lpfc_enable_npiv
, int, 0);
1937 MODULE_PARM_DESC(lpfc_enable_npiv
, "Enable NPIV functionality");
1938 lpfc_param_show(enable_npiv
);
1939 lpfc_param_init(enable_npiv
, 1, 0, 1);
1940 static DEVICE_ATTR(lpfc_enable_npiv
, S_IRUGO
, lpfc_enable_npiv_show
, NULL
);
1943 # lpfc_suppress_link_up: Bring link up at initialization
1944 # 0x0 = bring link up (issue MBX_INIT_LINK)
1945 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
1946 # 0x2 = never bring up link
1947 # Default value is 0.
1949 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
1950 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
1951 "Suppress Link Up at initialization");
1954 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
1955 # until the timer expires. Value range is [0,255]. Default value is 30.
1957 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
1958 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
1959 module_param(lpfc_nodev_tmo
, int, 0);
1960 MODULE_PARM_DESC(lpfc_nodev_tmo
,
1961 "Seconds driver will hold I/O waiting "
1962 "for a device to come back");
1965 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
1966 * @dev: class converted to a Scsi_host structure.
1967 * @attr: device attribute, not used.
1968 * @buf: on return contains the dev loss timeout in decimal.
1970 * Returns: size of formatted string.
1973 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
1976 struct Scsi_Host
*shost
= class_to_shost(dev
);
1977 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1979 return snprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
1983 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
1984 * @vport: lpfc vport structure pointer.
1985 * @val: contains the nodev timeout value.
1988 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
1989 * a kernel error message is printed and zero is returned.
1990 * Else if val is in range then nodev tmo and devloss tmo are set to val.
1991 * Otherwise nodev tmo is set to the default value.
1994 * zero if already set or if val is in range
1995 * -EINVAL val out of range
1998 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
2000 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
2001 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
2002 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
2003 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2004 "0407 Ignoring nodev_tmo module "
2005 "parameter because devloss_tmo is "
2010 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2011 vport
->cfg_nodev_tmo
= val
;
2012 vport
->cfg_devloss_tmo
= val
;
2015 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2016 "0400 lpfc_nodev_tmo attribute cannot be set to"
2017 " %d, allowed range is [%d, %d]\n",
2018 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2019 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
2024 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
2025 * @vport: lpfc vport structure pointer.
2028 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
2031 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
2033 struct Scsi_Host
*shost
;
2034 struct lpfc_nodelist
*ndlp
;
2036 shost
= lpfc_shost_from_vport(vport
);
2037 spin_lock_irq(shost
->host_lock
);
2038 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
)
2039 if (NLP_CHK_NODE_ACT(ndlp
) && ndlp
->rport
)
2040 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
2041 spin_unlock_irq(shost
->host_lock
);
2045 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
2046 * @vport: lpfc vport structure pointer.
2047 * @val: contains the tmo value.
2050 * If the devloss tmo is already set or the vport dev loss tmo has changed
2051 * then a kernel error message is printed and zero is returned.
2052 * Else if val is in range then nodev tmo and devloss tmo are set to val.
2053 * Otherwise nodev tmo is set to the default value.
2056 * zero if already set or if val is in range
2057 * -EINVAL val out of range
2060 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
2062 if (vport
->dev_loss_tmo_changed
||
2063 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
2064 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2065 "0401 Ignoring change to nodev_tmo "
2066 "because devloss_tmo is set.\n");
2069 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2070 vport
->cfg_nodev_tmo
= val
;
2071 vport
->cfg_devloss_tmo
= val
;
2072 lpfc_update_rport_devloss_tmo(vport
);
2075 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2076 "0403 lpfc_nodev_tmo attribute cannot be set to"
2077 "%d, allowed range is [%d, %d]\n",
2078 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2082 lpfc_vport_param_store(nodev_tmo
)
2084 static DEVICE_ATTR(lpfc_nodev_tmo
, S_IRUGO
| S_IWUSR
,
2085 lpfc_nodev_tmo_show
, lpfc_nodev_tmo_store
);
2088 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
2089 # disappear until the timer expires. Value range is [0,255]. Default
2092 module_param(lpfc_devloss_tmo
, int, 0);
2093 MODULE_PARM_DESC(lpfc_devloss_tmo
,
2094 "Seconds driver will hold I/O waiting "
2095 "for a device to come back");
2096 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
2097 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
2098 lpfc_vport_param_show(devloss_tmo
)
2101 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
2102 * @vport: lpfc vport structure pointer.
2103 * @val: contains the tmo value.
2106 * If val is in a valid range then set the vport nodev tmo,
2107 * devloss tmo, also set the vport dev loss tmo changed flag.
2108 * Else a kernel error message is printed.
2111 * zero if val is in range
2112 * -EINVAL val out of range
2115 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
2117 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
2118 vport
->cfg_nodev_tmo
= val
;
2119 vport
->cfg_devloss_tmo
= val
;
2120 vport
->dev_loss_tmo_changed
= 1;
2121 lpfc_update_rport_devloss_tmo(vport
);
2125 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2126 "0404 lpfc_devloss_tmo attribute cannot be set to"
2127 " %d, allowed range is [%d, %d]\n",
2128 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
2132 lpfc_vport_param_store(devloss_tmo
)
2133 static DEVICE_ATTR(lpfc_devloss_tmo
, S_IRUGO
| S_IWUSR
,
2134 lpfc_devloss_tmo_show
, lpfc_devloss_tmo_store
);
2137 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
2138 # deluged with LOTS of information.
2139 # You can set a bit mask to record specific types of verbose messages:
2140 # See lpfc_logmsh.h for definitions.
2142 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
2143 "Verbose logging bit-mask");
2146 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
2147 # objects that have been registered with the nameserver after login.
2149 LPFC_VPORT_ATTR_R(enable_da_id
, 0, 0, 1,
2150 "Deregister nameserver objects before LOGO");
2153 # lun_queue_depth: This parameter is used to limit the number of outstanding
2154 # commands per FCP LUN. Value range is [1,128]. Default value is 30.
2156 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 128,
2157 "Max number of FCP commands we can queue to a specific LUN");
2160 # hba_queue_depth: This parameter is used to limit the number of outstanding
2161 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
2162 # value is greater than the maximum number of exchanges supported by the HBA,
2163 # then maximum number of exchanges supported by the HBA is used to determine
2164 # the hba_queue_depth.
2166 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
2167 "Max number of FCP commands we can queue to a lpfc HBA");
2170 # peer_port_login: This parameter allows/prevents logins
2171 # between peer ports hosted on the same physical port.
2172 # When this parameter is set 0 peer ports of same physical port
2173 # are not allowed to login to each other.
2174 # When this parameter is set 1 peer ports of same physical port
2175 # are allowed to login to each other.
2176 # Default value of this parameter is 0.
2178 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
2179 "Allow peer ports on the same physical port to login to each "
2183 # restrict_login: This parameter allows/prevents logins
2184 # between Virtual Ports and remote initiators.
2185 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
2186 # other initiators and will attempt to PLOGI all remote ports.
2187 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
2188 # remote ports and will not attempt to PLOGI to other initiators.
2189 # This parameter does not restrict to the physical port.
2190 # This parameter does not restrict logins to Fabric resident remote ports.
2191 # Default value of this parameter is 1.
2193 static int lpfc_restrict_login
= 1;
2194 module_param(lpfc_restrict_login
, int, 0);
2195 MODULE_PARM_DESC(lpfc_restrict_login
,
2196 "Restrict virtual ports login to remote initiators.");
2197 lpfc_vport_param_show(restrict_login
);
2200 * lpfc_restrict_login_init - Set the vport restrict login flag
2201 * @vport: lpfc vport structure pointer.
2202 * @val: contains the restrict login value.
2205 * If val is not in a valid range then log a kernel error message and set
2206 * the vport restrict login to one.
2207 * If the port type is physical clear the restrict login flag and return.
2208 * Else set the restrict login flag to val.
2211 * zero if val is in range
2212 * -EINVAL val out of range
2215 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
2217 if (val
< 0 || val
> 1) {
2218 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2219 "0422 lpfc_restrict_login attribute cannot "
2220 "be set to %d, allowed range is [0, 1]\n",
2222 vport
->cfg_restrict_login
= 1;
2225 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
2226 vport
->cfg_restrict_login
= 0;
2229 vport
->cfg_restrict_login
= val
;
2234 * lpfc_restrict_login_set - Set the vport restrict login flag
2235 * @vport: lpfc vport structure pointer.
2236 * @val: contains the restrict login value.
2239 * If val is not in a valid range then log a kernel error message and set
2240 * the vport restrict login to one.
2241 * If the port type is physical and the val is not zero log a kernel
2242 * error message, clear the restrict login flag and return zero.
2243 * Else set the restrict login flag to val.
2246 * zero if val is in range
2247 * -EINVAL val out of range
2250 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
2252 if (val
< 0 || val
> 1) {
2253 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2254 "0425 lpfc_restrict_login attribute cannot "
2255 "be set to %d, allowed range is [0, 1]\n",
2257 vport
->cfg_restrict_login
= 1;
2260 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
2261 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2262 "0468 lpfc_restrict_login must be 0 for "
2263 "Physical ports.\n");
2264 vport
->cfg_restrict_login
= 0;
2267 vport
->cfg_restrict_login
= val
;
2270 lpfc_vport_param_store(restrict_login
);
2271 static DEVICE_ATTR(lpfc_restrict_login
, S_IRUGO
| S_IWUSR
,
2272 lpfc_restrict_login_show
, lpfc_restrict_login_store
);
2275 # Some disk devices have a "select ID" or "select Target" capability.
2276 # From a protocol standpoint "select ID" usually means select the
2277 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
2278 # annex" which contains a table that maps a "select ID" (a number
2279 # between 0 and 7F) to an ALPA. By default, for compatibility with
2280 # older drivers, the lpfc driver scans this table from low ALPA to high
2283 # Turning on the scan-down variable (on = 1, off = 0) will
2284 # cause the lpfc driver to use an inverted table, effectively
2285 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
2287 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
2288 # and will not work across a fabric. Also this parameter will take
2289 # effect only in the case when ALPA map is not available.)
2291 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
2292 "Start scanning for devices from highest ALPA to lowest");
2295 # lpfc_topology: link topology for init link
2296 # 0x0 = attempt loop mode then point-to-point
2297 # 0x01 = internal loopback mode
2298 # 0x02 = attempt point-to-point mode only
2299 # 0x04 = attempt loop mode only
2300 # 0x06 = attempt point-to-point mode then loop
2301 # Set point-to-point mode if you want to run as an N_Port.
2302 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
2303 # Default value is 0.
2307 * lpfc_topology_set - Set the adapters topology field
2308 * @phba: lpfc_hba pointer.
2309 * @val: topology value.
2312 * If val is in a valid range then set the adapter's topology field and
2313 * issue a lip; if the lip fails reset the topology to the old value.
2315 * If the value is not in range log a kernel error message and return an error.
2318 * zero if val is in range and lip okay
2319 * non-zero return value from lpfc_issue_lip()
2320 * -EINVAL val out of range
2323 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
2324 const char *buf
, size_t count
)
2326 struct Scsi_Host
*shost
= class_to_shost(dev
);
2327 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2328 struct lpfc_hba
*phba
= vport
->phba
;
2331 const char *val_buf
= buf
;
2335 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
2337 val_buf
= &buf
[strlen("nolip ")];
2340 if (!isdigit(val_buf
[0]))
2342 if (sscanf(val_buf
, "%i", &val
) != 1)
2345 if (val
>= 0 && val
<= 6) {
2346 prev_val
= phba
->cfg_topology
;
2347 phba
->cfg_topology
= val
;
2351 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
2353 phba
->cfg_topology
= prev_val
;
2358 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2359 "%d:0467 lpfc_topology attribute cannot be set to %d, "
2360 "allowed range is [0, 6]\n",
2364 static int lpfc_topology
= 0;
2365 module_param(lpfc_topology
, int, 0);
2366 MODULE_PARM_DESC(lpfc_topology
, "Select Fibre Channel topology");
2367 lpfc_param_show(topology
)
2368 lpfc_param_init(topology
, 0, 0, 6)
2369 static DEVICE_ATTR(lpfc_topology
, S_IRUGO
| S_IWUSR
,
2370 lpfc_topology_show
, lpfc_topology_store
);
2373 * lpfc_static_vport_show: Read callback function for
2374 * lpfc_static_vport sysfs file.
2375 * @dev: Pointer to class device object.
2376 * @attr: device attribute structure.
2377 * @buf: Data buffer.
2379 * This function is the read call back function for
2380 * lpfc_static_vport sysfs file. The lpfc_static_vport
2381 * sysfs file report the mageability of the vport.
2384 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
2387 struct Scsi_Host
*shost
= class_to_shost(dev
);
2388 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2389 if (vport
->vport_flag
& STATIC_VPORT
)
2390 sprintf(buf
, "1\n");
2392 sprintf(buf
, "0\n");
2398 * Sysfs attribute to control the statistical data collection.
2400 static DEVICE_ATTR(lpfc_static_vport
, S_IRUGO
,
2401 lpfc_static_vport_show
, NULL
);
2404 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
2405 * @dev: Pointer to class device.
2406 * @buf: Data buffer.
2407 * @count: Size of the data buffer.
2409 * This function get called when an user write to the lpfc_stat_data_ctrl
2410 * sysfs file. This function parse the command written to the sysfs file
2411 * and take appropriate action. These commands are used for controlling
2412 * driver statistical data collection.
2413 * Following are the command this function handles.
2415 * setbucket <bucket_type> <base> <step>
2416 * = Set the latency buckets.
2417 * destroybucket = destroy all the buckets.
2418 * start = start data collection
2419 * stop = stop data collection
2420 * reset = reset the collected data
2423 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
2424 const char *buf
, size_t count
)
2426 struct Scsi_Host
*shost
= class_to_shost(dev
);
2427 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2428 struct lpfc_hba
*phba
= vport
->phba
;
2429 #define LPFC_MAX_DATA_CTRL_LEN 1024
2430 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
2432 char *str_ptr
, *token
;
2433 struct lpfc_vport
**vports
;
2434 struct Scsi_Host
*v_shost
;
2435 char *bucket_type_str
, *base_str
, *step_str
;
2436 unsigned long base
, step
, bucket_type
;
2438 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
2439 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
2442 strcpy(bucket_data
, buf
);
2443 str_ptr
= &bucket_data
[0];
2444 /* Ignore this token - this is command token */
2445 token
= strsep(&str_ptr
, "\t ");
2449 bucket_type_str
= strsep(&str_ptr
, "\t ");
2450 if (!bucket_type_str
)
2453 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
2454 bucket_type
= LPFC_LINEAR_BUCKET
;
2455 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
2456 bucket_type
= LPFC_POWER2_BUCKET
;
2460 base_str
= strsep(&str_ptr
, "\t ");
2463 base
= simple_strtoul(base_str
, NULL
, 0);
2465 step_str
= strsep(&str_ptr
, "\t ");
2468 step
= simple_strtoul(step_str
, NULL
, 0);
2472 /* Block the data collection for every vport */
2473 vports
= lpfc_create_vport_work_array(phba
);
2477 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
2478 v_shost
= lpfc_shost_from_vport(vports
[i
]);
2479 spin_lock_irq(v_shost
->host_lock
);
2480 /* Block and reset data collection */
2481 vports
[i
]->stat_data_blocked
= 1;
2482 if (vports
[i
]->stat_data_enabled
)
2483 lpfc_vport_reset_stat_data(vports
[i
]);
2484 spin_unlock_irq(v_shost
->host_lock
);
2487 /* Set the bucket attributes */
2488 phba
->bucket_type
= bucket_type
;
2489 phba
->bucket_base
= base
;
2490 phba
->bucket_step
= step
;
2492 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
2493 v_shost
= lpfc_shost_from_vport(vports
[i
]);
2495 /* Unblock data collection */
2496 spin_lock_irq(v_shost
->host_lock
);
2497 vports
[i
]->stat_data_blocked
= 0;
2498 spin_unlock_irq(v_shost
->host_lock
);
2500 lpfc_destroy_vport_work_array(phba
, vports
);
2504 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
2505 vports
= lpfc_create_vport_work_array(phba
);
2509 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
2510 v_shost
= lpfc_shost_from_vport(vports
[i
]);
2511 spin_lock_irq(shost
->host_lock
);
2512 vports
[i
]->stat_data_blocked
= 1;
2513 lpfc_free_bucket(vport
);
2514 vport
->stat_data_enabled
= 0;
2515 vports
[i
]->stat_data_blocked
= 0;
2516 spin_unlock_irq(shost
->host_lock
);
2518 lpfc_destroy_vport_work_array(phba
, vports
);
2519 phba
->bucket_type
= LPFC_NO_BUCKET
;
2520 phba
->bucket_base
= 0;
2521 phba
->bucket_step
= 0;
2525 if (!strncmp(buf
, "start", strlen("start"))) {
2526 /* If no buckets configured return error */
2527 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
2529 spin_lock_irq(shost
->host_lock
);
2530 if (vport
->stat_data_enabled
) {
2531 spin_unlock_irq(shost
->host_lock
);
2534 lpfc_alloc_bucket(vport
);
2535 vport
->stat_data_enabled
= 1;
2536 spin_unlock_irq(shost
->host_lock
);
2540 if (!strncmp(buf
, "stop", strlen("stop"))) {
2541 spin_lock_irq(shost
->host_lock
);
2542 if (vport
->stat_data_enabled
== 0) {
2543 spin_unlock_irq(shost
->host_lock
);
2546 lpfc_free_bucket(vport
);
2547 vport
->stat_data_enabled
= 0;
2548 spin_unlock_irq(shost
->host_lock
);
2552 if (!strncmp(buf
, "reset", strlen("reset"))) {
2553 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
2554 || !vport
->stat_data_enabled
)
2556 spin_lock_irq(shost
->host_lock
);
2557 vport
->stat_data_blocked
= 1;
2558 lpfc_vport_reset_stat_data(vport
);
2559 vport
->stat_data_blocked
= 0;
2560 spin_unlock_irq(shost
->host_lock
);
2568 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
2569 * @dev: Pointer to class device object.
2570 * @buf: Data buffer.
2572 * This function is the read call back function for
2573 * lpfc_stat_data_ctrl sysfs file. This function report the
2574 * current statistical data collection state.
2577 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
2580 struct Scsi_Host
*shost
= class_to_shost(dev
);
2581 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2582 struct lpfc_hba
*phba
= vport
->phba
;
2586 unsigned long bucket_value
;
2588 switch (phba
->bucket_type
) {
2589 case LPFC_LINEAR_BUCKET
:
2590 bucket_type
= "linear";
2592 case LPFC_POWER2_BUCKET
:
2593 bucket_type
= "power2";
2596 bucket_type
= "No Bucket";
2600 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
2601 "blocked :%d, Bucket type :%s, Bucket base :%d,"
2602 " Bucket step :%d\nLatency Ranges :",
2603 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
2604 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
2605 index
= strlen(buf
);
2606 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
2607 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
2608 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
2609 bucket_value
= phba
->bucket_base
+
2610 phba
->bucket_step
* i
;
2612 bucket_value
= phba
->bucket_base
+
2613 (1 << i
) * phba
->bucket_step
;
2615 if (index
+ 10 > PAGE_SIZE
)
2617 sprintf(&buf
[index
], "%08ld ", bucket_value
);
2618 index
= strlen(buf
);
2621 sprintf(&buf
[index
], "\n");
2626 * Sysfs attribute to control the statistical data collection.
2628 static DEVICE_ATTR(lpfc_stat_data_ctrl
, S_IRUGO
| S_IWUSR
,
2629 lpfc_stat_data_ctrl_show
, lpfc_stat_data_ctrl_store
);
2632 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
2636 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
2639 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
2640 #define MAX_STAT_DATA_SIZE_PER_TARGET \
2641 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
2645 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
2646 * @kobj: Pointer to the kernel object
2647 * @bin_attr: Attribute object
2648 * @buff: Buffer pointer
2650 * @count: Buffer size
2652 * This function is the read call back function for lpfc_drvr_stat_data
2653 * sysfs file. This function export the statistical data to user
2657 sysfs_drvr_stat_data_read(struct kobject
*kobj
, struct bin_attribute
*bin_attr
,
2658 char *buf
, loff_t off
, size_t count
)
2660 struct device
*dev
= container_of(kobj
, struct device
,
2662 struct Scsi_Host
*shost
= class_to_shost(dev
);
2663 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2664 struct lpfc_hba
*phba
= vport
->phba
;
2665 int i
= 0, index
= 0;
2666 unsigned long nport_index
;
2667 struct lpfc_nodelist
*ndlp
= NULL
;
2668 nport_index
= (unsigned long)off
/
2669 MAX_STAT_DATA_SIZE_PER_TARGET
;
2671 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
2672 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
2675 spin_lock_irq(shost
->host_lock
);
2676 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
2677 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
2680 if (nport_index
> 0) {
2685 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
2689 if (!ndlp
->lat_data
)
2693 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
2694 ndlp
->nlp_portname
.u
.wwn
[0],
2695 ndlp
->nlp_portname
.u
.wwn
[1],
2696 ndlp
->nlp_portname
.u
.wwn
[2],
2697 ndlp
->nlp_portname
.u
.wwn
[3],
2698 ndlp
->nlp_portname
.u
.wwn
[4],
2699 ndlp
->nlp_portname
.u
.wwn
[5],
2700 ndlp
->nlp_portname
.u
.wwn
[6],
2701 ndlp
->nlp_portname
.u
.wwn
[7]);
2703 index
= strlen(buf
);
2705 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
2706 sprintf(&buf
[index
], "%010u,",
2707 ndlp
->lat_data
[i
].cmd_count
);
2708 index
= strlen(buf
);
2710 sprintf(&buf
[index
], "\n");
2711 index
= strlen(buf
);
2713 spin_unlock_irq(shost
->host_lock
);
2717 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
2719 .name
= "lpfc_drvr_stat_data",
2721 .owner
= THIS_MODULE
,
2723 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
2724 .read
= sysfs_drvr_stat_data_read
,
2729 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
2731 # 0 = auto select (default)
2736 # Value range is [0,8]. Default value is 0.
2740 * lpfc_link_speed_set - Set the adapters link speed
2741 * @phba: lpfc_hba pointer.
2742 * @val: link speed value.
2745 * If val is in a valid range then set the adapter's link speed field and
2746 * issue a lip; if the lip fails reset the link speed to the old value.
2749 * If the value is not in range log a kernel error message and return an error.
2752 * zero if val is in range and lip okay.
2753 * non-zero return value from lpfc_issue_lip()
2754 * -EINVAL val out of range
2757 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
2758 const char *buf
, size_t count
)
2760 struct Scsi_Host
*shost
= class_to_shost(dev
);
2761 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2762 struct lpfc_hba
*phba
= vport
->phba
;
2765 const char *val_buf
= buf
;
2769 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
2771 val_buf
= &buf
[strlen("nolip ")];
2774 if (!isdigit(val_buf
[0]))
2776 if (sscanf(val_buf
, "%i", &val
) != 1)
2779 if (((val
== LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
2780 ((val
== LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
2781 ((val
== LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
2782 ((val
== LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
2783 ((val
== LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)))
2786 if ((val
>= 0 && val
<= 8)
2787 && (LPFC_LINK_SPEED_BITMAP
& (1 << val
))) {
2788 prev_val
= phba
->cfg_link_speed
;
2789 phba
->cfg_link_speed
= val
;
2793 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
2795 phba
->cfg_link_speed
= prev_val
;
2801 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2802 "%d:0469 lpfc_link_speed attribute cannot be set to %d, "
2803 "allowed range is [0, 8]\n",
2808 static int lpfc_link_speed
= 0;
2809 module_param(lpfc_link_speed
, int, 0);
2810 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
2811 lpfc_param_show(link_speed
)
2814 * lpfc_link_speed_init - Set the adapters link speed
2815 * @phba: lpfc_hba pointer.
2816 * @val: link speed value.
2819 * If val is in a valid range then set the adapter's link speed field.
2822 * If the value is not in range log a kernel error message, clear the link
2823 * speed and return an error.
2826 * zero if val saved.
2827 * -EINVAL val out of range
2830 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
2832 if ((val
>= 0 && val
<= LPFC_MAX_LINK_SPEED
)
2833 && (LPFC_LINK_SPEED_BITMAP
& (1 << val
))) {
2834 phba
->cfg_link_speed
= val
;
2837 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2838 "0405 lpfc_link_speed attribute cannot "
2839 "be set to %d, allowed values are "
2840 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
2841 phba
->cfg_link_speed
= 0;
2845 static DEVICE_ATTR(lpfc_link_speed
, S_IRUGO
| S_IWUSR
,
2846 lpfc_link_speed_show
, lpfc_link_speed_store
);
2849 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
2850 # 0 = aer disabled or not supported
2851 # 1 = aer supported and enabled (default)
2852 # Value range is [0,1]. Default value is 1.
2856 * lpfc_aer_support_store - Set the adapter for aer support
2858 * @dev: class device that is converted into a Scsi_host.
2859 * @attr: device attribute, not used.
2860 * @buf: containing the string "selective".
2861 * @count: unused variable.
2864 * If the val is 1 and currently the device's AER capability was not
2865 * enabled, invoke the kernel's enable AER helper routine, trying to
2866 * enable the device's AER capability. If the helper routine enabling
2867 * AER returns success, update the device's cfg_aer_support flag to
2868 * indicate AER is supported by the device; otherwise, if the device
2869 * AER capability is already enabled to support AER, then do nothing.
2871 * If the val is 0 and currently the device's AER support was enabled,
2872 * invoke the kernel's disable AER helper routine. After that, update
2873 * the device's cfg_aer_support flag to indicate AER is not supported
2874 * by the device; otherwise, if the device AER capability is already
2875 * disabled from supporting AER, then do nothing.
2878 * length of the buf on success if val is in range the intended mode
2880 * -EINVAL if val out of range or intended mode is not supported.
2883 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
2884 const char *buf
, size_t count
)
2886 struct Scsi_Host
*shost
= class_to_shost(dev
);
2887 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
2888 struct lpfc_hba
*phba
= vport
->phba
;
2889 int val
= 0, rc
= -EINVAL
;
2891 /* AER not supported on OC devices yet */
2892 if (phba
->pci_dev_grp
== LPFC_PCI_DEV_OC
)
2894 if (!isdigit(buf
[0]))
2896 if (sscanf(buf
, "%i", &val
) != 1)
2901 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
2902 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
2904 spin_lock_irq(&phba
->hbalock
);
2905 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
2906 spin_unlock_irq(&phba
->hbalock
);
2907 phba
->cfg_aer_support
= 0;
2912 phba
->cfg_aer_support
= 0;
2917 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
2918 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
2920 spin_lock_irq(&phba
->hbalock
);
2921 phba
->hba_flag
|= HBA_AER_ENABLED
;
2922 spin_unlock_irq(&phba
->hbalock
);
2923 phba
->cfg_aer_support
= 1;
2928 phba
->cfg_aer_support
= 1;
2939 static int lpfc_aer_support
= 1;
2940 module_param(lpfc_aer_support
, int, 1);
2941 MODULE_PARM_DESC(lpfc_aer_support
, "Enable PCIe device AER support");
2942 lpfc_param_show(aer_support
)
2945 * lpfc_aer_support_init - Set the initial adapters aer support flag
2946 * @phba: lpfc_hba pointer.
2947 * @val: link speed value.
2950 * If val is in a valid range [0,1], then set the adapter's initial
2951 * cfg_aer_support field. It will be up to the driver's probe_one
2952 * routine to determine whether the device's AER support can be set
2956 * If the value is not in range log a kernel error message, and
2957 * choose the default value of setting AER support and return.
2960 * zero if val saved.
2961 * -EINVAL val out of range
2964 lpfc_aer_support_init(struct lpfc_hba
*phba
, int val
)
2966 /* AER not supported on OC devices yet */
2967 if (phba
->pci_dev_grp
== LPFC_PCI_DEV_OC
) {
2968 phba
->cfg_aer_support
= 0;
2972 if (val
== 0 || val
== 1) {
2973 phba
->cfg_aer_support
= val
;
2976 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2977 "2712 lpfc_aer_support attribute value %d out "
2978 "of range, allowed values are 0|1, setting it "
2979 "to default value of 1\n", val
);
2980 /* By default, try to enable AER on a device */
2981 phba
->cfg_aer_support
= 1;
2985 static DEVICE_ATTR(lpfc_aer_support
, S_IRUGO
| S_IWUSR
,
2986 lpfc_aer_support_show
, lpfc_aer_support_store
);
2989 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
2990 * @dev: class device that is converted into a Scsi_host.
2991 * @attr: device attribute, not used.
2992 * @buf: containing the string "selective".
2993 * @count: unused variable.
2996 * If the @buf contains 1 and the device currently has the AER support
2997 * enabled, then invokes the kernel AER helper routine
2998 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
2999 * error status register.
3004 * -EINVAL if the buf does not contain the 1 or the device is not currently
3005 * enabled with the AER support.
3008 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
3009 const char *buf
, size_t count
)
3011 struct Scsi_Host
*shost
= class_to_shost(dev
);
3012 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3013 struct lpfc_hba
*phba
= vport
->phba
;
3016 /* AER not supported on OC devices yet */
3017 if (phba
->pci_dev_grp
== LPFC_PCI_DEV_OC
)
3019 if (!isdigit(buf
[0]))
3021 if (sscanf(buf
, "%i", &val
) != 1)
3026 if (phba
->hba_flag
& HBA_AER_ENABLED
)
3027 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
3035 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
3036 lpfc_aer_cleanup_state
);
3039 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
3040 # Value range is [2,3]. Default value is 3.
3042 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
3043 "Select Fibre Channel class of service for FCP sequences");
3046 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
3047 # is [0,1]. Default value is 0.
3049 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
3050 "Use ADISC on rediscovery to authenticate FCP devices");
3053 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
3054 # depth. Default value is 0. When the value of this parameter is zero the
3055 # SCSI command completion time is not used for controlling I/O queue depth. When
3056 # the parameter is set to a non-zero value, the I/O queue depth is controlled
3057 # to limit the I/O completion time to the parameter value.
3058 # The value is set in milliseconds.
3060 static int lpfc_max_scsicmpl_time
;
3061 module_param(lpfc_max_scsicmpl_time
, int, 0);
3062 MODULE_PARM_DESC(lpfc_max_scsicmpl_time
,
3063 "Use command completion time to control queue depth");
3064 lpfc_vport_param_show(max_scsicmpl_time
);
3065 lpfc_vport_param_init(max_scsicmpl_time
, 0, 0, 60000);
3067 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
3069 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
3070 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
3072 if (val
== vport
->cfg_max_scsicmpl_time
)
3074 if ((val
< 0) || (val
> 60000))
3076 vport
->cfg_max_scsicmpl_time
= val
;
3078 spin_lock_irq(shost
->host_lock
);
3079 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3080 if (!NLP_CHK_NODE_ACT(ndlp
))
3082 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
3084 ndlp
->cmd_qdepth
= LPFC_MAX_TGT_QDEPTH
;
3086 spin_unlock_irq(shost
->host_lock
);
3089 lpfc_vport_param_store(max_scsicmpl_time
);
3090 static DEVICE_ATTR(lpfc_max_scsicmpl_time
, S_IRUGO
| S_IWUSR
,
3091 lpfc_max_scsicmpl_time_show
,
3092 lpfc_max_scsicmpl_time_store
);
3095 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
3096 # range is [0,1]. Default value is 0.
3098 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
3101 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
3102 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
3103 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
3104 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
3105 # cr_delay is set to 0.
3107 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
3108 "interrupt response is generated");
3110 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
3111 "interrupt response is generated");
3114 # lpfc_multi_ring_support: Determines how many rings to spread available
3115 # cmd/rsp IOCB entries across.
3116 # Value range is [1,2]. Default value is 1.
3118 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
3119 "SLI rings to spread IOCB entries across");
3122 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
3123 # identifies what rctl value to configure the additional ring for.
3124 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
3126 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
3127 255, "Identifies RCTL for additional ring configuration");
3130 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
3131 # identifies what type value to configure the additional ring for.
3132 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
3134 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
3135 255, "Identifies TYPE for additional ring configuration");
3138 # lpfc_fdmi_on: controls FDMI support.
3139 # 0 = no FDMI support
3140 # 1 = support FDMI without attribute of hostname
3141 # 2 = support FDMI with attribute of hostname
3142 # Value range [0,2]. Default value is 0.
3144 LPFC_VPORT_ATTR_RW(fdmi_on
, 0, 0, 2, "Enable FDMI support");
3147 # Specifies the maximum number of ELS cmds we can have outstanding (for
3148 # discovery). Value range is [1,64]. Default value = 32.
3150 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
3151 "during discovery");
3154 # lpfc_max_luns: maximum allowed LUN.
3155 # Value range is [0,65535]. Default value is 255.
3156 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
3158 LPFC_VPORT_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN");
3161 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
3162 # Value range is [1,255], default value is 10.
3164 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
3165 "Milliseconds driver will wait between polling FCP ring");
3168 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
3169 # support this feature
3172 # 2 = MSI-X enabled (default)
3173 # Value range is [0,2]. Default value is 2.
3175 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
3176 "MSI-X (2), if possible");
3179 # lpfc_fcp_imax: Set the maximum number of fast-path FCP interrupts per second
3181 # Value range is [636,651042]. Default value is 10000.
3183 LPFC_ATTR_R(fcp_imax
, LPFC_FP_DEF_IMAX
, LPFC_MIM_IMAX
, LPFC_DMULT_CONST
,
3184 "Set the maximum number of fast-path FCP interrupts per second");
3187 # lpfc_fcp_wq_count: Set the number of fast-path FCP work queues
3189 # Value range is [1,31]. Default value is 4.
3191 LPFC_ATTR_R(fcp_wq_count
, LPFC_FP_WQN_DEF
, LPFC_FP_WQN_MIN
, LPFC_FP_WQN_MAX
,
3192 "Set the number of fast-path FCP work queues, if possible");
3195 # lpfc_fcp_eq_count: Set the number of fast-path FCP event queues
3197 # Value range is [1,7]. Default value is 1.
3199 LPFC_ATTR_R(fcp_eq_count
, LPFC_FP_EQN_DEF
, LPFC_FP_EQN_MIN
, LPFC_FP_EQN_MAX
,
3200 "Set the number of fast-path FCP event queues, if possible");
3203 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
3204 # 0 = HBA resets disabled
3205 # 1 = HBA resets enabled (default)
3206 # Value range is [0,1]. Default value is 1.
3208 LPFC_ATTR_R(enable_hba_reset
, 1, 0, 1, "Enable HBA resets from the driver.");
3211 # lpfc_enable_hba_heartbeat: Enable HBA heartbeat timer..
3212 # 0 = HBA Heartbeat disabled
3213 # 1 = HBA Heartbeat enabled (default)
3214 # Value range is [0,1]. Default value is 1.
3216 LPFC_ATTR_R(enable_hba_heartbeat
, 1, 0, 1, "Enable HBA Heartbeat.");
3219 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
3220 # 0 = BlockGuard disabled (default)
3221 # 1 = BlockGuard enabled
3222 # Value range is [0,1]. Default value is 0.
3224 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
3228 # - Bit mask of host protection capabilities used to register with the
3230 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
3231 # - Allows you to ultimately specify which profiles to use
3232 # - Default will result in registering capabilities for all profiles.
3235 unsigned int lpfc_prot_mask
= SHOST_DIX_TYPE0_PROTECTION
;
3237 module_param(lpfc_prot_mask
, uint
, 0);
3238 MODULE_PARM_DESC(lpfc_prot_mask
, "host protection mask");
3241 # lpfc_prot_guard: i
3242 # - Bit mask of protection guard types to register with the SCSI mid-layer
3243 # - Guard types are currently either 1) IP checksum 2) T10-DIF CRC
3244 # - Allows you to ultimately specify which profiles to use
3245 # - Default will result in registering capabilities for all guard types
3248 unsigned char lpfc_prot_guard
= SHOST_DIX_GUARD_IP
;
3249 module_param(lpfc_prot_guard
, byte
, 0);
3250 MODULE_PARM_DESC(lpfc_prot_guard
, "host protection guard type");
3254 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
3255 * This value can be set to values between 64 and 256. The default value is
3256 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
3257 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
3259 LPFC_ATTR_R(sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
, LPFC_DEFAULT_SG_SEG_CNT
,
3260 LPFC_MAX_SG_SEG_CNT
, "Max Scatter Gather Segment Count");
3262 LPFC_ATTR_R(prot_sg_seg_cnt
, LPFC_DEFAULT_PROT_SG_SEG_CNT
,
3263 LPFC_DEFAULT_PROT_SG_SEG_CNT
, LPFC_MAX_PROT_SG_SEG_CNT
,
3264 "Max Protection Scatter Gather Segment Count");
3266 struct device_attribute
*lpfc_hba_attrs
[] = {
3268 &dev_attr_bg_guard_err
,
3269 &dev_attr_bg_apptag_err
,
3270 &dev_attr_bg_reftag_err
,
3272 &dev_attr_serialnum
,
3273 &dev_attr_modeldesc
,
3274 &dev_attr_modelname
,
3275 &dev_attr_programtype
,
3279 &dev_attr_option_rom_version
,
3280 &dev_attr_link_state
,
3281 &dev_attr_num_discovered_ports
,
3282 &dev_attr_menlo_mgmt_mode
,
3283 &dev_attr_lpfc_drvr_version
,
3284 &dev_attr_lpfc_enable_fip
,
3285 &dev_attr_lpfc_temp_sensor
,
3286 &dev_attr_lpfc_log_verbose
,
3287 &dev_attr_lpfc_lun_queue_depth
,
3288 &dev_attr_lpfc_hba_queue_depth
,
3289 &dev_attr_lpfc_peer_port_login
,
3290 &dev_attr_lpfc_nodev_tmo
,
3291 &dev_attr_lpfc_devloss_tmo
,
3292 &dev_attr_lpfc_fcp_class
,
3293 &dev_attr_lpfc_use_adisc
,
3294 &dev_attr_lpfc_ack0
,
3295 &dev_attr_lpfc_topology
,
3296 &dev_attr_lpfc_scan_down
,
3297 &dev_attr_lpfc_link_speed
,
3298 &dev_attr_lpfc_cr_delay
,
3299 &dev_attr_lpfc_cr_count
,
3300 &dev_attr_lpfc_multi_ring_support
,
3301 &dev_attr_lpfc_multi_ring_rctl
,
3302 &dev_attr_lpfc_multi_ring_type
,
3303 &dev_attr_lpfc_fdmi_on
,
3304 &dev_attr_lpfc_max_luns
,
3305 &dev_attr_lpfc_enable_npiv
,
3306 &dev_attr_nport_evt_cnt
,
3307 &dev_attr_board_mode
,
3314 &dev_attr_npiv_info
,
3315 &dev_attr_issue_reset
,
3316 &dev_attr_lpfc_poll
,
3317 &dev_attr_lpfc_poll_tmo
,
3318 &dev_attr_lpfc_use_msi
,
3319 &dev_attr_lpfc_fcp_imax
,
3320 &dev_attr_lpfc_fcp_wq_count
,
3321 &dev_attr_lpfc_fcp_eq_count
,
3322 &dev_attr_lpfc_enable_bg
,
3323 &dev_attr_lpfc_soft_wwnn
,
3324 &dev_attr_lpfc_soft_wwpn
,
3325 &dev_attr_lpfc_soft_wwn_enable
,
3326 &dev_attr_lpfc_enable_hba_reset
,
3327 &dev_attr_lpfc_enable_hba_heartbeat
,
3328 &dev_attr_lpfc_sg_seg_cnt
,
3329 &dev_attr_lpfc_max_scsicmpl_time
,
3330 &dev_attr_lpfc_stat_data_ctrl
,
3331 &dev_attr_lpfc_prot_sg_seg_cnt
,
3332 &dev_attr_lpfc_aer_support
,
3333 &dev_attr_lpfc_aer_state_cleanup
,
3334 &dev_attr_lpfc_suppress_link_up
,
3338 struct device_attribute
*lpfc_vport_attrs
[] = {
3340 &dev_attr_link_state
,
3341 &dev_attr_num_discovered_ports
,
3342 &dev_attr_lpfc_drvr_version
,
3343 &dev_attr_lpfc_log_verbose
,
3344 &dev_attr_lpfc_lun_queue_depth
,
3345 &dev_attr_lpfc_nodev_tmo
,
3346 &dev_attr_lpfc_devloss_tmo
,
3347 &dev_attr_lpfc_hba_queue_depth
,
3348 &dev_attr_lpfc_peer_port_login
,
3349 &dev_attr_lpfc_restrict_login
,
3350 &dev_attr_lpfc_fcp_class
,
3351 &dev_attr_lpfc_use_adisc
,
3352 &dev_attr_lpfc_fdmi_on
,
3353 &dev_attr_lpfc_max_luns
,
3354 &dev_attr_nport_evt_cnt
,
3355 &dev_attr_npiv_info
,
3356 &dev_attr_lpfc_enable_da_id
,
3357 &dev_attr_lpfc_max_scsicmpl_time
,
3358 &dev_attr_lpfc_stat_data_ctrl
,
3359 &dev_attr_lpfc_static_vport
,
3364 * sysfs_ctlreg_write - Write method for writing to ctlreg
3365 * @kobj: kernel kobject that contains the kernel class device.
3366 * @bin_attr: kernel attributes passed to us.
3367 * @buf: contains the data to be written to the adapter IOREG space.
3368 * @off: offset into buffer to beginning of data.
3369 * @count: bytes to transfer.
3372 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
3373 * Uses the adapter io control registers to send buf contents to the adapter.
3376 * -ERANGE off and count combo out of range
3377 * -EINVAL off, count or buff address invalid
3378 * -EPERM adapter is offline
3379 * value of count, buf contents written
3382 sysfs_ctlreg_write(struct kobject
*kobj
, struct bin_attribute
*bin_attr
,
3383 char *buf
, loff_t off
, size_t count
)
3386 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
3387 struct Scsi_Host
*shost
= class_to_shost(dev
);
3388 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3389 struct lpfc_hba
*phba
= vport
->phba
;
3391 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
3394 if ((off
+ count
) > FF_REG_AREA_SIZE
)
3397 if (count
== 0) return 0;
3399 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
3402 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
)) {
3406 spin_lock_irq(&phba
->hbalock
);
3407 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t))
3408 writel(*((uint32_t *)(buf
+ buf_off
)),
3409 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
3411 spin_unlock_irq(&phba
->hbalock
);
3417 * sysfs_ctlreg_read - Read method for reading from ctlreg
3418 * @kobj: kernel kobject that contains the kernel class device.
3419 * @bin_attr: kernel attributes passed to us.
3420 * @buf: if successful contains the data from the adapter IOREG space.
3421 * @off: offset into buffer to beginning of data.
3422 * @count: bytes to transfer.
3425 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
3426 * Uses the adapter io control registers to read data into buf.
3429 * -ERANGE off and count combo out of range
3430 * -EINVAL off, count or buff address invalid
3431 * value of count, buf contents read
3434 sysfs_ctlreg_read(struct kobject
*kobj
, struct bin_attribute
*bin_attr
,
3435 char *buf
, loff_t off
, size_t count
)
3439 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
3440 struct Scsi_Host
*shost
= class_to_shost(dev
);
3441 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3442 struct lpfc_hba
*phba
= vport
->phba
;
3444 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
3447 if (off
> FF_REG_AREA_SIZE
)
3450 if ((off
+ count
) > FF_REG_AREA_SIZE
)
3451 count
= FF_REG_AREA_SIZE
- off
;
3453 if (count
== 0) return 0;
3455 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
3458 spin_lock_irq(&phba
->hbalock
);
3460 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
3461 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
3462 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
3465 spin_unlock_irq(&phba
->hbalock
);
3470 static struct bin_attribute sysfs_ctlreg_attr
= {
3473 .mode
= S_IRUSR
| S_IWUSR
,
3476 .read
= sysfs_ctlreg_read
,
3477 .write
= sysfs_ctlreg_write
,
3481 * sysfs_mbox_idle - frees the sysfs mailbox
3482 * @phba: lpfc_hba pointer
3485 sysfs_mbox_idle(struct lpfc_hba
*phba
)
3487 phba
->sysfs_mbox
.state
= SMBOX_IDLE
;
3488 phba
->sysfs_mbox
.offset
= 0;
3490 if (phba
->sysfs_mbox
.mbox
) {
3491 mempool_free(phba
->sysfs_mbox
.mbox
,
3492 phba
->mbox_mem_pool
);
3493 phba
->sysfs_mbox
.mbox
= NULL
;
3498 * sysfs_mbox_write - Write method for writing information via mbox
3499 * @kobj: kernel kobject that contains the kernel class device.
3500 * @bin_attr: kernel attributes passed to us.
3501 * @buf: contains the data to be written to sysfs mbox.
3502 * @off: offset into buffer to beginning of data.
3503 * @count: bytes to transfer.
3506 * Accessed via /sys/class/scsi_host/hostxxx/mbox.
3507 * Uses the sysfs mbox to send buf contents to the adapter.
3510 * -ERANGE off and count combo out of range
3511 * -EINVAL off, count or buff address invalid
3512 * zero if count is zero
3513 * -EPERM adapter is offline
3514 * -ENOMEM failed to allocate memory for the mail box
3515 * -EAGAIN offset, state or mbox is NULL
3516 * count number of bytes transferred
3519 sysfs_mbox_write(struct kobject
*kobj
, struct bin_attribute
*bin_attr
,
3520 char *buf
, loff_t off
, size_t count
)
3522 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
3523 struct Scsi_Host
*shost
= class_to_shost(dev
);
3524 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3525 struct lpfc_hba
*phba
= vport
->phba
;
3526 struct lpfcMboxq
*mbox
= NULL
;
3528 if ((count
+ off
) > MAILBOX_CMD_SIZE
)
3531 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
3538 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
3541 memset(mbox
, 0, sizeof (LPFC_MBOXQ_t
));
3544 spin_lock_irq(&phba
->hbalock
);
3547 if (phba
->sysfs_mbox
.mbox
)
3548 mempool_free(mbox
, phba
->mbox_mem_pool
);
3550 phba
->sysfs_mbox
.mbox
= mbox
;
3551 phba
->sysfs_mbox
.state
= SMBOX_WRITING
;
3553 if (phba
->sysfs_mbox
.state
!= SMBOX_WRITING
||
3554 phba
->sysfs_mbox
.offset
!= off
||
3555 phba
->sysfs_mbox
.mbox
== NULL
) {
3556 sysfs_mbox_idle(phba
);
3557 spin_unlock_irq(&phba
->hbalock
);
3562 memcpy((uint8_t *) &phba
->sysfs_mbox
.mbox
->u
.mb
+ off
,
3565 phba
->sysfs_mbox
.offset
= off
+ count
;
3567 spin_unlock_irq(&phba
->hbalock
);
3573 * sysfs_mbox_read - Read method for reading information via mbox
3574 * @kobj: kernel kobject that contains the kernel class device.
3575 * @bin_attr: kernel attributes passed to us.
3576 * @buf: contains the data to be read from sysfs mbox.
3577 * @off: offset into buffer to beginning of data.
3578 * @count: bytes to transfer.
3581 * Accessed via /sys/class/scsi_host/hostxxx/mbox.
3582 * Uses the sysfs mbox to receive data from to the adapter.
3585 * -ERANGE off greater than mailbox command size
3586 * -EINVAL off, count or buff address invalid
3587 * zero if off and count are zero
3588 * -EACCES adapter over temp
3589 * -EPERM garbage can value to catch a multitude of errors
3590 * -EAGAIN management IO not permitted, state or off error
3591 * -ETIME mailbox timeout
3592 * -ENODEV mailbox error
3593 * count number of bytes transferred
3596 sysfs_mbox_read(struct kobject
*kobj
, struct bin_attribute
*bin_attr
,
3597 char *buf
, loff_t off
, size_t count
)
3599 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
3600 struct Scsi_Host
*shost
= class_to_shost(dev
);
3601 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3602 struct lpfc_hba
*phba
= vport
->phba
;
3606 if (off
> MAILBOX_CMD_SIZE
)
3609 if ((count
+ off
) > MAILBOX_CMD_SIZE
)
3610 count
= MAILBOX_CMD_SIZE
- off
;
3612 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
3615 if (off
&& count
== 0)
3618 spin_lock_irq(&phba
->hbalock
);
3620 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
3621 sysfs_mbox_idle(phba
);
3622 spin_unlock_irq(&phba
->hbalock
);
3627 phba
->sysfs_mbox
.state
== SMBOX_WRITING
&&
3628 phba
->sysfs_mbox
.offset
>= 2 * sizeof(uint32_t)) {
3629 pmb
= &phba
->sysfs_mbox
.mbox
->u
.mb
;
3630 switch (pmb
->mbxCommand
) {
3634 case MBX_CONFIG_LINK
:
3635 case MBX_CONFIG_RING
:
3636 case MBX_RESET_RING
:
3637 case MBX_UNREG_LOGIN
:
3639 case MBX_DUMP_CONTEXT
:
3644 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
)) {
3645 printk(KERN_WARNING
"mbox_read:Command 0x%x "
3646 "is illegal in on-line state\n",
3648 sysfs_mbox_idle(phba
);
3649 spin_unlock_irq(&phba
->hbalock
);
3653 case MBX_WRITE_VPARMS
:
3656 case MBX_READ_CONFIG
:
3657 case MBX_READ_RCONFIG
:
3658 case MBX_READ_STATUS
:
3661 case MBX_READ_LNK_STAT
:
3662 case MBX_DUMP_MEMORY
:
3664 case MBX_UPDATE_CFG
:
3665 case MBX_KILL_BOARD
:
3667 case MBX_LOAD_EXP_ROM
:
3669 case MBX_DEL_LD_ENTRY
:
3670 case MBX_SET_VARIABLE
:
3672 case MBX_PORT_CAPABILITIES
:
3673 case MBX_PORT_IOV_CONTROL
:
3675 case MBX_READ_SPARM64
:
3679 case MBX_REG_LOGIN64
:
3680 case MBX_CONFIG_PORT
:
3681 case MBX_RUN_BIU_DIAG
:
3682 printk(KERN_WARNING
"mbox_read: Illegal Command 0x%x\n",
3684 sysfs_mbox_idle(phba
);
3685 spin_unlock_irq(&phba
->hbalock
);
3688 printk(KERN_WARNING
"mbox_read: Unknown Command 0x%x\n",
3690 sysfs_mbox_idle(phba
);
3691 spin_unlock_irq(&phba
->hbalock
);
3695 /* If HBA encountered an error attention, allow only DUMP
3696 * or RESTART mailbox commands until the HBA is restarted.
3698 if (phba
->pport
->stopped
&&
3699 pmb
->mbxCommand
!= MBX_DUMP_MEMORY
&&
3700 pmb
->mbxCommand
!= MBX_RESTART
&&
3701 pmb
->mbxCommand
!= MBX_WRITE_VPARMS
&&
3702 pmb
->mbxCommand
!= MBX_WRITE_WWN
)
3703 lpfc_printf_log(phba
, KERN_WARNING
, LOG_MBOX
,
3704 "1259 mbox: Issued mailbox cmd "
3705 "0x%x while in stopped state.\n",
3708 phba
->sysfs_mbox
.mbox
->vport
= vport
;
3710 /* Don't allow mailbox commands to be sent when blocked
3711 * or when in the middle of discovery
3713 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
) {
3714 sysfs_mbox_idle(phba
);
3715 spin_unlock_irq(&phba
->hbalock
);
3719 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
3720 (!(phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
))) {
3722 spin_unlock_irq(&phba
->hbalock
);
3723 rc
= lpfc_sli_issue_mbox (phba
,
3724 phba
->sysfs_mbox
.mbox
,
3726 spin_lock_irq(&phba
->hbalock
);
3729 spin_unlock_irq(&phba
->hbalock
);
3730 rc
= lpfc_sli_issue_mbox_wait (phba
,
3731 phba
->sysfs_mbox
.mbox
,
3732 lpfc_mbox_tmo_val(phba
, pmb
->mbxCommand
) * HZ
);
3733 spin_lock_irq(&phba
->hbalock
);
3736 if (rc
!= MBX_SUCCESS
) {
3737 if (rc
== MBX_TIMEOUT
) {
3738 phba
->sysfs_mbox
.mbox
= NULL
;
3740 sysfs_mbox_idle(phba
);
3741 spin_unlock_irq(&phba
->hbalock
);
3742 return (rc
== MBX_TIMEOUT
) ? -ETIME
: -ENODEV
;
3744 phba
->sysfs_mbox
.state
= SMBOX_READING
;
3746 else if (phba
->sysfs_mbox
.offset
!= off
||
3747 phba
->sysfs_mbox
.state
!= SMBOX_READING
) {
3748 printk(KERN_WARNING
"mbox_read: Bad State\n");
3749 sysfs_mbox_idle(phba
);
3750 spin_unlock_irq(&phba
->hbalock
);
3754 memcpy(buf
, (uint8_t *) &pmb
+ off
, count
);
3756 phba
->sysfs_mbox
.offset
= off
+ count
;
3758 if (phba
->sysfs_mbox
.offset
== MAILBOX_CMD_SIZE
)
3759 sysfs_mbox_idle(phba
);
3761 spin_unlock_irq(&phba
->hbalock
);
3766 static struct bin_attribute sysfs_mbox_attr
= {
3769 .mode
= S_IRUSR
| S_IWUSR
,
3771 .size
= MAILBOX_CMD_SIZE
,
3772 .read
= sysfs_mbox_read
,
3773 .write
= sysfs_mbox_write
,
3777 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
3778 * @vport: address of lpfc vport structure.
3782 * error return code from sysfs_create_bin_file()
3785 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
3787 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
3790 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
3791 &sysfs_drvr_stat_data_attr
);
3793 /* Virtual ports do not need ctrl_reg and mbox */
3794 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
3797 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
3798 &sysfs_ctlreg_attr
);
3800 goto out_remove_stat_attr
;
3802 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
3805 goto out_remove_ctlreg_attr
;
3808 out_remove_ctlreg_attr
:
3809 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
3810 out_remove_stat_attr
:
3811 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
3812 &sysfs_drvr_stat_data_attr
);
3818 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
3819 * @vport: address of lpfc vport structure.
3822 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
3824 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
3825 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
3826 &sysfs_drvr_stat_data_attr
);
3827 /* Virtual ports do not need ctrl_reg and mbox */
3828 if (vport
->port_type
== LPFC_NPIV_PORT
)
3830 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
3831 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
3836 * Dynamic FC Host Attributes Support
3840 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
3841 * @shost: kernel scsi host pointer.
3844 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
3846 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3848 /* note: fc_myDID already in cpu endianness */
3849 fc_host_port_id(shost
) = vport
->fc_myDID
;
3853 * lpfc_get_host_port_type - Set the value of the scsi host port type
3854 * @shost: kernel scsi host pointer.
3857 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
3859 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3860 struct lpfc_hba
*phba
= vport
->phba
;
3862 spin_lock_irq(shost
->host_lock
);
3864 if (vport
->port_type
== LPFC_NPIV_PORT
) {
3865 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
3866 } else if (lpfc_is_link_up(phba
)) {
3867 if (phba
->fc_topology
== TOPOLOGY_LOOP
) {
3868 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
3869 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
3871 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
3873 if (vport
->fc_flag
& FC_FABRIC
)
3874 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
3876 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
3879 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
3881 spin_unlock_irq(shost
->host_lock
);
3885 * lpfc_get_host_port_state - Set the value of the scsi host port state
3886 * @shost: kernel scsi host pointer.
3889 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
3891 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3892 struct lpfc_hba
*phba
= vport
->phba
;
3894 spin_lock_irq(shost
->host_lock
);
3896 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
3897 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
3899 switch (phba
->link_state
) {
3900 case LPFC_LINK_UNKNOWN
:
3901 case LPFC_LINK_DOWN
:
3902 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
3906 case LPFC_HBA_READY
:
3907 /* Links up, beyond this port_type reports state */
3908 fc_host_port_state(shost
) = FC_PORTSTATE_ONLINE
;
3910 case LPFC_HBA_ERROR
:
3911 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
3914 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
3919 spin_unlock_irq(shost
->host_lock
);
3923 * lpfc_get_host_speed - Set the value of the scsi host speed
3924 * @shost: kernel scsi host pointer.
3927 lpfc_get_host_speed(struct Scsi_Host
*shost
)
3929 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3930 struct lpfc_hba
*phba
= vport
->phba
;
3932 spin_lock_irq(shost
->host_lock
);
3934 if (lpfc_is_link_up(phba
)) {
3935 switch(phba
->fc_linkspeed
) {
3937 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
3940 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
3943 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
3946 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
3949 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
3952 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
3956 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
3958 spin_unlock_irq(shost
->host_lock
);
3962 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
3963 * @shost: kernel scsi host pointer.
3966 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
3968 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3969 struct lpfc_hba
*phba
= vport
->phba
;
3972 spin_lock_irq(shost
->host_lock
);
3974 if ((vport
->fc_flag
& FC_FABRIC
) ||
3975 ((phba
->fc_topology
== TOPOLOGY_LOOP
) &&
3976 (vport
->fc_flag
& FC_PUBLIC_LOOP
)))
3977 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
3979 /* fabric is local port if there is no F/FL_Port */
3982 spin_unlock_irq(shost
->host_lock
);
3984 fc_host_fabric_name(shost
) = node_name
;
3988 * lpfc_get_stats - Return statistical information about the adapter
3989 * @shost: kernel scsi host pointer.
3992 * NULL on error for link down, no mbox pool, sli2 active,
3993 * management not allowed, memory allocation error, or mbox error.
3997 * address of the adapter host statistics
3999 static struct fc_host_statistics
*
4000 lpfc_get_stats(struct Scsi_Host
*shost
)
4002 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4003 struct lpfc_hba
*phba
= vport
->phba
;
4004 struct lpfc_sli
*psli
= &phba
->sli
;
4005 struct fc_host_statistics
*hs
= &phba
->link_stats
;
4006 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
4007 LPFC_MBOXQ_t
*pmboxq
;
4009 unsigned long seconds
;
4013 * prevent udev from issuing mailbox commands until the port is
4016 if (phba
->link_state
< LPFC_LINK_DOWN
||
4017 !phba
->mbox_mem_pool
||
4018 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
4021 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
4024 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
4027 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
4029 pmb
= &pmboxq
->u
.mb
;
4030 pmb
->mbxCommand
= MBX_READ_STATUS
;
4031 pmb
->mbxOwner
= OWN_HOST
;
4032 pmboxq
->context1
= NULL
;
4033 pmboxq
->vport
= vport
;
4035 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
4036 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
4037 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
4039 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
4041 if (rc
!= MBX_SUCCESS
) {
4042 if (rc
!= MBX_TIMEOUT
)
4043 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4047 memset(hs
, 0, sizeof (struct fc_host_statistics
));
4049 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
4050 hs
->tx_words
= (pmb
->un
.varRdStatus
.xmitByteCnt
* 256);
4051 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
4052 hs
->rx_words
= (pmb
->un
.varRdStatus
.rcvByteCnt
* 256);
4054 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
4055 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
4056 pmb
->mbxOwner
= OWN_HOST
;
4057 pmboxq
->context1
= NULL
;
4058 pmboxq
->vport
= vport
;
4060 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
4061 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
4062 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
4064 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
4066 if (rc
!= MBX_SUCCESS
) {
4067 if (rc
!= MBX_TIMEOUT
)
4068 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4072 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
4073 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
4074 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
4075 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
4076 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
4077 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
4078 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
4080 hs
->link_failure_count
-= lso
->link_failure_count
;
4081 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
4082 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
4083 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
4084 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
4085 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
4086 hs
->error_frames
-= lso
->error_frames
;
4088 if (phba
->hba_flag
& HBA_FCOE_SUPPORT
) {
4090 hs
->nos_count
= (phba
->link_events
>> 1);
4091 hs
->nos_count
-= lso
->link_events
;
4092 } else if (phba
->fc_topology
== TOPOLOGY_LOOP
) {
4093 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
4094 hs
->lip_count
-= lso
->link_events
;
4098 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
4099 hs
->nos_count
-= lso
->link_events
;
4102 hs
->dumped_frames
= -1;
4104 seconds
= get_seconds();
4105 if (seconds
< psli
->stats_start
)
4106 hs
->seconds_since_last_reset
= seconds
+
4107 ((unsigned long)-1 - psli
->stats_start
);
4109 hs
->seconds_since_last_reset
= seconds
- psli
->stats_start
;
4111 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4117 * lpfc_reset_stats - Copy the adapter link stats information
4118 * @shost: kernel scsi host pointer.
4121 lpfc_reset_stats(struct Scsi_Host
*shost
)
4123 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4124 struct lpfc_hba
*phba
= vport
->phba
;
4125 struct lpfc_sli
*psli
= &phba
->sli
;
4126 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
4127 LPFC_MBOXQ_t
*pmboxq
;
4131 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
4134 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
4137 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
4139 pmb
= &pmboxq
->u
.mb
;
4140 pmb
->mbxCommand
= MBX_READ_STATUS
;
4141 pmb
->mbxOwner
= OWN_HOST
;
4142 pmb
->un
.varWords
[0] = 0x1; /* reset request */
4143 pmboxq
->context1
= NULL
;
4144 pmboxq
->vport
= vport
;
4146 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
4147 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
4148 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
4150 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
4152 if (rc
!= MBX_SUCCESS
) {
4153 if (rc
!= MBX_TIMEOUT
)
4154 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4158 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
4159 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
4160 pmb
->mbxOwner
= OWN_HOST
;
4161 pmboxq
->context1
= NULL
;
4162 pmboxq
->vport
= vport
;
4164 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
4165 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
4166 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
4168 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
4170 if (rc
!= MBX_SUCCESS
) {
4171 if (rc
!= MBX_TIMEOUT
)
4172 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
4176 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
4177 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
4178 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
4179 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
4180 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
4181 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
4182 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
4183 if (phba
->hba_flag
& HBA_FCOE_SUPPORT
)
4184 lso
->link_events
= (phba
->link_events
>> 1);
4186 lso
->link_events
= (phba
->fc_eventTag
>> 1);
4188 psli
->stats_start
= get_seconds();
4190 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
4196 * The LPFC driver treats linkdown handling as target loss events so there
4197 * are no sysfs handlers for link_down_tmo.
4201 * lpfc_get_node_by_target - Return the nodelist for a target
4202 * @starget: kernel scsi target pointer.
4205 * address of the node list if found
4206 * NULL target not found
4208 static struct lpfc_nodelist
*
4209 lpfc_get_node_by_target(struct scsi_target
*starget
)
4211 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
4212 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4213 struct lpfc_nodelist
*ndlp
;
4215 spin_lock_irq(shost
->host_lock
);
4216 /* Search for this, mapped, target ID */
4217 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4218 if (NLP_CHK_NODE_ACT(ndlp
) &&
4219 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
4220 starget
->id
== ndlp
->nlp_sid
) {
4221 spin_unlock_irq(shost
->host_lock
);
4225 spin_unlock_irq(shost
->host_lock
);
4230 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
4231 * @starget: kernel scsi target pointer.
4234 lpfc_get_starget_port_id(struct scsi_target
*starget
)
4236 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
4238 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
4242 * lpfc_get_starget_node_name - Set the target node name
4243 * @starget: kernel scsi target pointer.
4245 * Description: Set the target node name to the ndlp node name wwn or zero.
4248 lpfc_get_starget_node_name(struct scsi_target
*starget
)
4250 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
4252 fc_starget_node_name(starget
) =
4253 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
4257 * lpfc_get_starget_port_name - Set the target port name
4258 * @starget: kernel scsi target pointer.
4260 * Description: set the target port name to the ndlp port name wwn or zero.
4263 lpfc_get_starget_port_name(struct scsi_target
*starget
)
4265 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
4267 fc_starget_port_name(starget
) =
4268 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
4272 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
4273 * @rport: fc rport address.
4274 * @timeout: new value for dev loss tmo.
4277 * If timeout is non zero set the dev_loss_tmo to timeout, else set
4278 * dev_loss_tmo to one.
4281 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
4284 rport
->dev_loss_tmo
= timeout
;
4286 rport
->dev_loss_tmo
= 1;
4290 * lpfc_rport_show_function - Return rport target information
4293 * Macro that uses field to generate a function with the name lpfc_show_rport_
4295 * lpfc_show_rport_##field: returns the bytes formatted in buf
4296 * @cdev: class converted to an fc_rport.
4297 * @buf: on return contains the target_field or zero.
4299 * Returns: size of formatted string.
4301 #define lpfc_rport_show_function(field, format_string, sz, cast) \
4303 lpfc_show_rport_##field (struct device *dev, \
4304 struct device_attribute *attr, \
4307 struct fc_rport *rport = transport_class_to_rport(dev); \
4308 struct lpfc_rport_data *rdata = rport->hostdata; \
4309 return snprintf(buf, sz, format_string, \
4310 (rdata->target) ? cast rdata->target->field : 0); \
4313 #define lpfc_rport_rd_attr(field, format_string, sz) \
4314 lpfc_rport_show_function(field, format_string, sz, ) \
4315 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
4318 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
4319 * @fc_vport: The fc_vport who's symbolic name has been changed.
4322 * This function is called by the transport after the @fc_vport's symbolic name
4323 * has been changed. This function re-registers the symbolic name with the
4324 * switch to propogate the change into the fabric if the vport is active.
4327 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
4329 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
4331 if (vport
->port_state
== LPFC_VPORT_READY
)
4332 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
4336 * lpfc_hba_log_verbose_init - Set hba's log verbose level
4337 * @phba: Pointer to lpfc_hba struct.
4339 * This function is called by the lpfc_get_cfgparam() routine to set the
4340 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
4341 * log messsage according to the module's lpfc_log_verbose parameter setting
4342 * before hba port or vport created.
4345 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
4347 phba
->cfg_log_verbose
= verbose
;
4350 struct fc_function_template lpfc_transport_functions
= {
4351 /* fixed attributes the driver supports */
4352 .show_host_node_name
= 1,
4353 .show_host_port_name
= 1,
4354 .show_host_supported_classes
= 1,
4355 .show_host_supported_fc4s
= 1,
4356 .show_host_supported_speeds
= 1,
4357 .show_host_maxframe_size
= 1,
4358 .show_host_symbolic_name
= 1,
4360 /* dynamic attributes the driver supports */
4361 .get_host_port_id
= lpfc_get_host_port_id
,
4362 .show_host_port_id
= 1,
4364 .get_host_port_type
= lpfc_get_host_port_type
,
4365 .show_host_port_type
= 1,
4367 .get_host_port_state
= lpfc_get_host_port_state
,
4368 .show_host_port_state
= 1,
4370 /* active_fc4s is shown but doesn't change (thus no get function) */
4371 .show_host_active_fc4s
= 1,
4373 .get_host_speed
= lpfc_get_host_speed
,
4374 .show_host_speed
= 1,
4376 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
4377 .show_host_fabric_name
= 1,
4380 * The LPFC driver treats linkdown handling as target loss events
4381 * so there are no sysfs handlers for link_down_tmo.
4384 .get_fc_host_stats
= lpfc_get_stats
,
4385 .reset_fc_host_stats
= lpfc_reset_stats
,
4387 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
4388 .show_rport_maxframe_size
= 1,
4389 .show_rport_supported_classes
= 1,
4391 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
4392 .show_rport_dev_loss_tmo
= 1,
4394 .get_starget_port_id
= lpfc_get_starget_port_id
,
4395 .show_starget_port_id
= 1,
4397 .get_starget_node_name
= lpfc_get_starget_node_name
,
4398 .show_starget_node_name
= 1,
4400 .get_starget_port_name
= lpfc_get_starget_port_name
,
4401 .show_starget_port_name
= 1,
4403 .issue_fc_host_lip
= lpfc_issue_lip
,
4404 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
4405 .terminate_rport_io
= lpfc_terminate_rport_io
,
4407 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
4409 .vport_disable
= lpfc_vport_disable
,
4411 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
4413 .bsg_request
= lpfc_bsg_request
,
4414 .bsg_timeout
= lpfc_bsg_timeout
,
4417 struct fc_function_template lpfc_vport_transport_functions
= {
4418 /* fixed attributes the driver supports */
4419 .show_host_node_name
= 1,
4420 .show_host_port_name
= 1,
4421 .show_host_supported_classes
= 1,
4422 .show_host_supported_fc4s
= 1,
4423 .show_host_supported_speeds
= 1,
4424 .show_host_maxframe_size
= 1,
4425 .show_host_symbolic_name
= 1,
4427 /* dynamic attributes the driver supports */
4428 .get_host_port_id
= lpfc_get_host_port_id
,
4429 .show_host_port_id
= 1,
4431 .get_host_port_type
= lpfc_get_host_port_type
,
4432 .show_host_port_type
= 1,
4434 .get_host_port_state
= lpfc_get_host_port_state
,
4435 .show_host_port_state
= 1,
4437 /* active_fc4s is shown but doesn't change (thus no get function) */
4438 .show_host_active_fc4s
= 1,
4440 .get_host_speed
= lpfc_get_host_speed
,
4441 .show_host_speed
= 1,
4443 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
4444 .show_host_fabric_name
= 1,
4447 * The LPFC driver treats linkdown handling as target loss events
4448 * so there are no sysfs handlers for link_down_tmo.
4451 .get_fc_host_stats
= lpfc_get_stats
,
4452 .reset_fc_host_stats
= lpfc_reset_stats
,
4454 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
4455 .show_rport_maxframe_size
= 1,
4456 .show_rport_supported_classes
= 1,
4458 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
4459 .show_rport_dev_loss_tmo
= 1,
4461 .get_starget_port_id
= lpfc_get_starget_port_id
,
4462 .show_starget_port_id
= 1,
4464 .get_starget_node_name
= lpfc_get_starget_node_name
,
4465 .show_starget_node_name
= 1,
4467 .get_starget_port_name
= lpfc_get_starget_port_name
,
4468 .show_starget_port_name
= 1,
4470 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
4471 .terminate_rport_io
= lpfc_terminate_rport_io
,
4473 .vport_disable
= lpfc_vport_disable
,
4475 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
4479 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
4480 * @phba: lpfc_hba pointer.
4483 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
4485 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
4486 lpfc_cr_count_init(phba
, lpfc_cr_count
);
4487 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
4488 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
4489 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
4490 lpfc_ack0_init(phba
, lpfc_ack0
);
4491 lpfc_topology_init(phba
, lpfc_topology
);
4492 lpfc_link_speed_init(phba
, lpfc_link_speed
);
4493 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
4494 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
4495 lpfc_use_msi_init(phba
, lpfc_use_msi
);
4496 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
4497 lpfc_fcp_wq_count_init(phba
, lpfc_fcp_wq_count
);
4498 lpfc_fcp_eq_count_init(phba
, lpfc_fcp_eq_count
);
4499 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
4500 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
4501 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
4502 if (phba
->sli_rev
== LPFC_SLI_REV4
)
4505 phba
->cfg_poll
= lpfc_poll
;
4506 phba
->cfg_soft_wwnn
= 0L;
4507 phba
->cfg_soft_wwpn
= 0L;
4508 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
4509 lpfc_prot_sg_seg_cnt_init(phba
, lpfc_prot_sg_seg_cnt
);
4510 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
4511 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
4512 lpfc_aer_support_init(phba
, lpfc_aer_support
);
4513 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
4518 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
4519 * @vport: lpfc_vport pointer.
4522 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
4524 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
4525 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
4526 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
4527 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
4528 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
4529 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
4530 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
4531 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
4532 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
4533 lpfc_fdmi_on_init(vport
, lpfc_fdmi_on
);
4534 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
4535 lpfc_max_luns_init(vport
, lpfc_max_luns
);
4536 lpfc_scan_down_init(vport
, lpfc_scan_down
);
4537 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);