1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
9 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
11 * This program is free software; you can redistribute it and/or *
12 * modify it under the terms of version 2 of the GNU General *
13 * Public License as published by the Free Software Foundation. *
14 * This program is distributed in the hope that it will be useful. *
15 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
16 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
17 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
18 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
19 * TO BE LEGALLY INVALID. See the GNU General Public License for *
20 * more details, a copy of which can be found in the file COPYING *
21 * included with this package. *
22 *******************************************************************/
24 #include <linux/ctype.h>
25 #include <linux/delay.h>
26 #include <linux/pci.h>
27 #include <linux/interrupt.h>
28 #include <linux/module.h>
29 #include <linux/aer.h>
30 #include <linux/gfp.h>
31 #include <linux/kernel.h>
33 #include <scsi/scsi.h>
34 #include <scsi/scsi_device.h>
35 #include <scsi/scsi_host.h>
36 #include <scsi/scsi_tcq.h>
37 #include <scsi/scsi_transport_fc.h>
38 #include <scsi/fc/fc_fs.h>
40 #include <linux/nvme-fc-driver.h>
45 #include "lpfc_sli4.h"
47 #include "lpfc_disc.h"
49 #include "lpfc_scsi.h"
50 #include "lpfc_nvme.h"
51 #include "lpfc_nvmet.h"
52 #include "lpfc_logmsg.h"
53 #include "lpfc_version.h"
54 #include "lpfc_compat.h"
55 #include "lpfc_crtn.h"
56 #include "lpfc_vport.h"
57 #include "lpfc_attr.h"
59 #define LPFC_DEF_DEVLOSS_TMO 30
60 #define LPFC_MIN_DEVLOSS_TMO 1
61 #define LPFC_MAX_DEVLOSS_TMO 255
63 #define LPFC_DEF_MRQ_POST 512
64 #define LPFC_MIN_MRQ_POST 512
65 #define LPFC_MAX_MRQ_POST 2048
67 #define LPFC_MAX_NVME_INFO_TMP_LEN 100
68 #define LPFC_NVME_INFO_MORE_STR "\nCould be more info...\n"
71 * Write key size should be multiple of 4. If write key is changed
72 * make sure that library write key is also changed.
74 #define LPFC_REG_WRITE_KEY_SIZE 4
75 #define LPFC_REG_WRITE_KEY "EMLX"
78 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
79 * @incr: integer to convert.
80 * @hdw: ascii string holding converted integer plus a string terminator.
83 * JEDEC Joint Electron Device Engineering Council.
84 * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii
85 * character string. The string is then terminated with a NULL in byte 9.
86 * Hex 0-9 becomes ascii '0' to '9'.
87 * Hex a-f becomes ascii '=' to 'B' capital B.
90 * Coded for 32 bit integers only.
93 lpfc_jedec_to_ascii(int incr, char hdw[])
96 for (i = 0; i < 8; i++) {
99 hdw[7 - i] = 0x30 + j;
101 hdw[7 - i] = 0x61 + j - 10;
109 * lpfc_drvr_version_show - Return the Emulex driver string with version number
110 * @dev: class unused variable.
111 * @attr: device attribute, not used.
112 * @buf: on return contains the module description text.
114 * Returns: size of formatted string.
117 lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
120 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
124 * lpfc_enable_fip_show - Return the fip mode of the HBA
125 * @dev: class unused variable.
126 * @attr: device attribute, not used.
127 * @buf: on return contains the module description text.
129 * Returns: size of formatted string.
132 lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr,
135 struct Scsi_Host *shost = class_to_shost(dev);
136 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
137 struct lpfc_hba *phba = vport->phba;
139 if (phba->hba_flag & HBA_FIP_SUPPORT)
140 return snprintf(buf, PAGE_SIZE, "1\n");
142 return snprintf(buf, PAGE_SIZE, "0\n");
146 lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
149 struct Scsi_Host *shost = class_to_shost(dev);
150 struct lpfc_vport *vport = shost_priv(shost);
151 struct lpfc_hba *phba = vport->phba;
152 struct lpfc_nvmet_tgtport *tgtp;
153 struct nvme_fc_local_port *localport;
154 struct lpfc_nvme_lport *lport;
155 struct lpfc_nvme_rport *rport;
156 struct lpfc_nodelist *ndlp;
157 struct nvme_fc_remote_port *nrport;
158 struct lpfc_nvme_ctrl_stat *cstat;
159 uint64_t data1, data2, data3;
160 uint64_t totin, totout, tot;
164 char tmp[LPFC_MAX_NVME_INFO_TMP_LEN] = {0};
166 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
167 len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n");
170 if (phba->nvmet_support) {
171 if (!phba->targetport) {
172 len = scnprintf(buf, PAGE_SIZE,
173 "NVME Target: x%llx is not allocated\n",
174 wwn_to_u64(vport->fc_portname.u.wwn));
177 /* Port state is only one of two values for now. */
178 if (phba->targetport->port_id)
179 statep = "REGISTERED";
182 scnprintf(tmp, sizeof(tmp),
183 "NVME Target Enabled State %s\n",
185 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
188 scnprintf(tmp, sizeof(tmp),
189 "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
192 wwn_to_u64(vport->fc_portname.u.wwn),
193 wwn_to_u64(vport->fc_nodename.u.wwn),
194 phba->targetport->port_id);
195 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
198 if (strlcat(buf, "\nNVME Target: Statistics\n", PAGE_SIZE)
202 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
203 scnprintf(tmp, sizeof(tmp),
204 "LS: Rcv %08x Drop %08x Abort %08x\n",
205 atomic_read(&tgtp->rcv_ls_req_in),
206 atomic_read(&tgtp->rcv_ls_req_drop),
207 atomic_read(&tgtp->xmt_ls_abort));
208 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
211 if (atomic_read(&tgtp->rcv_ls_req_in) !=
212 atomic_read(&tgtp->rcv_ls_req_out)) {
213 scnprintf(tmp, sizeof(tmp),
214 "Rcv LS: in %08x != out %08x\n",
215 atomic_read(&tgtp->rcv_ls_req_in),
216 atomic_read(&tgtp->rcv_ls_req_out));
217 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
221 scnprintf(tmp, sizeof(tmp),
222 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
223 atomic_read(&tgtp->xmt_ls_rsp),
224 atomic_read(&tgtp->xmt_ls_drop),
225 atomic_read(&tgtp->xmt_ls_rsp_cmpl));
226 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
229 scnprintf(tmp, sizeof(tmp),
230 "LS: RSP Abort %08x xb %08x Err %08x\n",
231 atomic_read(&tgtp->xmt_ls_rsp_aborted),
232 atomic_read(&tgtp->xmt_ls_rsp_xb_set),
233 atomic_read(&tgtp->xmt_ls_rsp_error));
234 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
237 scnprintf(tmp, sizeof(tmp),
238 "FCP: Rcv %08x Defer %08x Release %08x "
240 atomic_read(&tgtp->rcv_fcp_cmd_in),
241 atomic_read(&tgtp->rcv_fcp_cmd_defer),
242 atomic_read(&tgtp->xmt_fcp_release),
243 atomic_read(&tgtp->rcv_fcp_cmd_drop));
244 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
247 if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
248 atomic_read(&tgtp->rcv_fcp_cmd_out)) {
249 scnprintf(tmp, sizeof(tmp),
250 "Rcv FCP: in %08x != out %08x\n",
251 atomic_read(&tgtp->rcv_fcp_cmd_in),
252 atomic_read(&tgtp->rcv_fcp_cmd_out));
253 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
257 scnprintf(tmp, sizeof(tmp),
258 "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x "
260 atomic_read(&tgtp->xmt_fcp_read),
261 atomic_read(&tgtp->xmt_fcp_read_rsp),
262 atomic_read(&tgtp->xmt_fcp_write),
263 atomic_read(&tgtp->xmt_fcp_rsp),
264 atomic_read(&tgtp->xmt_fcp_drop));
265 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
268 scnprintf(tmp, sizeof(tmp),
269 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
270 atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
271 atomic_read(&tgtp->xmt_fcp_rsp_error),
272 atomic_read(&tgtp->xmt_fcp_rsp_drop));
273 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
276 scnprintf(tmp, sizeof(tmp),
277 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
278 atomic_read(&tgtp->xmt_fcp_rsp_aborted),
279 atomic_read(&tgtp->xmt_fcp_rsp_xb_set),
280 atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));
281 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
284 scnprintf(tmp, sizeof(tmp),
285 "ABORT: Xmt %08x Cmpl %08x\n",
286 atomic_read(&tgtp->xmt_fcp_abort),
287 atomic_read(&tgtp->xmt_fcp_abort_cmpl));
288 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
291 scnprintf(tmp, sizeof(tmp),
292 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n",
293 atomic_read(&tgtp->xmt_abort_sol),
294 atomic_read(&tgtp->xmt_abort_unsol),
295 atomic_read(&tgtp->xmt_abort_rsp),
296 atomic_read(&tgtp->xmt_abort_rsp_error));
297 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
300 scnprintf(tmp, sizeof(tmp),
301 "DELAY: ctx %08x fod %08x wqfull %08x\n",
302 atomic_read(&tgtp->defer_ctx),
303 atomic_read(&tgtp->defer_fod),
304 atomic_read(&tgtp->defer_wqfull));
305 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
308 /* Calculate outstanding IOs */
309 tot = atomic_read(&tgtp->rcv_fcp_cmd_drop);
310 tot += atomic_read(&tgtp->xmt_fcp_release);
311 tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot;
313 scnprintf(tmp, sizeof(tmp),
314 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
315 "CTX Outstanding %08llx\n\n",
316 phba->sli4_hba.nvmet_xri_cnt,
317 phba->sli4_hba.nvmet_io_wait_cnt,
318 phba->sli4_hba.nvmet_io_wait_total,
320 strlcat(buf, tmp, PAGE_SIZE);
324 localport = vport->localport;
326 len = scnprintf(buf, PAGE_SIZE,
327 "NVME Initiator x%llx is not allocated\n",
328 wwn_to_u64(vport->fc_portname.u.wwn));
331 lport = (struct lpfc_nvme_lport *)localport->private;
332 if (strlcat(buf, "\nNVME Initiator Enabled\n", PAGE_SIZE) >= PAGE_SIZE)
336 scnprintf(tmp, sizeof(tmp),
337 "XRI Dist lpfc%d Total %d NVME %d SCSI %d ELS %d\n",
339 phba->sli4_hba.max_cfg_param.max_xri,
340 phba->sli4_hba.nvme_xri_max,
341 phba->sli4_hba.scsi_xri_max,
342 lpfc_sli4_get_els_iocb_cnt(phba));
343 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
346 /* Port state is only one of two values for now. */
347 if (localport->port_id)
352 scnprintf(tmp, sizeof(tmp),
353 "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
356 wwn_to_u64(vport->fc_portname.u.wwn),
357 wwn_to_u64(vport->fc_nodename.u.wwn),
358 localport->port_id, statep);
359 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
362 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
364 spin_lock(&vport->phba->hbalock);
365 rport = lpfc_ndlp_get_nrport(ndlp);
367 nrport = rport->remoteport;
368 spin_unlock(&vport->phba->hbalock);
372 /* Port state is only one of two values for now. */
373 switch (nrport->port_state) {
374 case FC_OBJSTATE_ONLINE:
377 case FC_OBJSTATE_UNKNOWN:
381 statep = "UNSUPPORTED";
385 /* Tab in to show lport ownership. */
386 if (strlcat(buf, "NVME RPORT ", PAGE_SIZE) >= PAGE_SIZE)
388 if (phba->brd_no >= 10) {
389 if (strlcat(buf, " ", PAGE_SIZE) >= PAGE_SIZE)
393 scnprintf(tmp, sizeof(tmp), "WWPN x%llx ",
395 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
398 scnprintf(tmp, sizeof(tmp), "WWNN x%llx ",
400 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
403 scnprintf(tmp, sizeof(tmp), "DID x%06x ",
405 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
408 /* An NVME rport can have multiple roles. */
409 if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) {
410 if (strlcat(buf, "INITIATOR ", PAGE_SIZE) >= PAGE_SIZE)
413 if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) {
414 if (strlcat(buf, "TARGET ", PAGE_SIZE) >= PAGE_SIZE)
417 if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) {
418 if (strlcat(buf, "DISCSRVC ", PAGE_SIZE) >= PAGE_SIZE)
421 if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |
422 FC_PORT_ROLE_NVME_TARGET |
423 FC_PORT_ROLE_NVME_DISCOVERY)) {
424 scnprintf(tmp, sizeof(tmp), "UNKNOWN ROLE x%x",
426 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
430 scnprintf(tmp, sizeof(tmp), "%s\n", statep);
431 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
439 if (strlcat(buf, "\nNVME Statistics\n", PAGE_SIZE) >= PAGE_SIZE)
442 scnprintf(tmp, sizeof(tmp),
443 "LS: Xmt %010x Cmpl %010x Abort %08x\n",
444 atomic_read(&lport->fc4NvmeLsRequests),
445 atomic_read(&lport->fc4NvmeLsCmpls),
446 atomic_read(&lport->xmt_ls_abort));
447 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
450 scnprintf(tmp, sizeof(tmp),
451 "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n",
452 atomic_read(&lport->xmt_ls_err),
453 atomic_read(&lport->cmpl_ls_xb),
454 atomic_read(&lport->cmpl_ls_err));
455 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
460 for (i = 0; i < phba->cfg_nvme_io_channel; i++) {
461 cstat = &lport->cstat[i];
462 tot = atomic_read(&cstat->fc4NvmeIoCmpls);
464 data1 = atomic_read(&cstat->fc4NvmeInputRequests);
465 data2 = atomic_read(&cstat->fc4NvmeOutputRequests);
466 data3 = atomic_read(&cstat->fc4NvmeControlRequests);
467 totout += (data1 + data2 + data3);
469 scnprintf(tmp, sizeof(tmp),
470 "Total FCP Cmpl %016llx Issue %016llx "
472 totin, totout, totout - totin);
473 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
476 scnprintf(tmp, sizeof(tmp),
477 "\tabort %08x noxri %08x nondlp %08x qdepth %08x "
478 "wqerr %08x err %08x\n",
479 atomic_read(&lport->xmt_fcp_abort),
480 atomic_read(&lport->xmt_fcp_noxri),
481 atomic_read(&lport->xmt_fcp_bad_ndlp),
482 atomic_read(&lport->xmt_fcp_qdepth),
483 atomic_read(&lport->xmt_fcp_err),
484 atomic_read(&lport->xmt_fcp_wqerr));
485 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
488 scnprintf(tmp, sizeof(tmp),
489 "FCP CMPL: xb %08x Err %08x\n",
490 atomic_read(&lport->cmpl_fcp_xb),
491 atomic_read(&lport->cmpl_fcp_err));
492 strlcat(buf, tmp, PAGE_SIZE);
495 len = strnlen(buf, PAGE_SIZE);
497 if (unlikely(len >= (PAGE_SIZE - 1))) {
498 lpfc_printf_log(phba, KERN_INFO, LOG_NVME,
499 "6314 Catching potential buffer "
500 "overflow > PAGE_SIZE = %lu bytes\n",
502 strlcpy(buf + PAGE_SIZE - 1 -
503 strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1),
504 LPFC_NVME_INFO_MORE_STR,
505 strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1)
513 lpfc_bg_info_show(struct device *dev, struct device_attribute *attr,
516 struct Scsi_Host *shost = class_to_shost(dev);
517 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
518 struct lpfc_hba *phba = vport->phba;
520 if (phba->cfg_enable_bg)
521 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED)
522 return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n");
524 return snprintf(buf, PAGE_SIZE,
525 "BlockGuard Not Supported\n");
527 return snprintf(buf, PAGE_SIZE,
528 "BlockGuard Disabled\n");
532 lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr,
535 struct Scsi_Host *shost = class_to_shost(dev);
536 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
537 struct lpfc_hba *phba = vport->phba;
539 return snprintf(buf, PAGE_SIZE, "%llu\n",
540 (unsigned long long)phba->bg_guard_err_cnt);
544 lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr,
547 struct Scsi_Host *shost = class_to_shost(dev);
548 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
549 struct lpfc_hba *phba = vport->phba;
551 return snprintf(buf, PAGE_SIZE, "%llu\n",
552 (unsigned long long)phba->bg_apptag_err_cnt);
556 lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr,
559 struct Scsi_Host *shost = class_to_shost(dev);
560 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
561 struct lpfc_hba *phba = vport->phba;
563 return snprintf(buf, PAGE_SIZE, "%llu\n",
564 (unsigned long long)phba->bg_reftag_err_cnt);
568 * lpfc_info_show - Return some pci info about the host in ascii
569 * @dev: class converted to a Scsi_host structure.
570 * @attr: device attribute, not used.
571 * @buf: on return contains the formatted text from lpfc_info().
573 * Returns: size of formatted string.
576 lpfc_info_show(struct device *dev, struct device_attribute *attr,
579 struct Scsi_Host *host = class_to_shost(dev);
581 return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host));
585 * lpfc_serialnum_show - Return the hba serial number in ascii
586 * @dev: class converted to a Scsi_host structure.
587 * @attr: device attribute, not used.
588 * @buf: on return contains the formatted text serial number.
590 * Returns: size of formatted string.
593 lpfc_serialnum_show(struct device *dev, struct device_attribute *attr,
596 struct Scsi_Host *shost = class_to_shost(dev);
597 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
598 struct lpfc_hba *phba = vport->phba;
600 return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
604 * lpfc_temp_sensor_show - Return the temperature sensor level
605 * @dev: class converted to a Scsi_host structure.
606 * @attr: device attribute, not used.
607 * @buf: on return contains the formatted support level.
610 * Returns a number indicating the temperature sensor level currently
611 * supported, zero or one in ascii.
613 * Returns: size of formatted string.
616 lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr,
619 struct Scsi_Host *shost = class_to_shost(dev);
620 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
621 struct lpfc_hba *phba = vport->phba;
622 return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
626 * lpfc_modeldesc_show - Return the model description of the hba
627 * @dev: class converted to a Scsi_host structure.
628 * @attr: device attribute, not used.
629 * @buf: on return contains the scsi vpd model description.
631 * Returns: size of formatted string.
634 lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr,
637 struct Scsi_Host *shost = class_to_shost(dev);
638 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
639 struct lpfc_hba *phba = vport->phba;
641 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc);
645 * lpfc_modelname_show - Return the model name of the hba
646 * @dev: class converted to a Scsi_host structure.
647 * @attr: device attribute, not used.
648 * @buf: on return contains the scsi vpd model name.
650 * Returns: size of formatted string.
653 lpfc_modelname_show(struct device *dev, struct device_attribute *attr,
656 struct Scsi_Host *shost = class_to_shost(dev);
657 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
658 struct lpfc_hba *phba = vport->phba;
660 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName);
664 * lpfc_programtype_show - Return the program type of the hba
665 * @dev: class converted to a Scsi_host structure.
666 * @attr: device attribute, not used.
667 * @buf: on return contains the scsi vpd program type.
669 * Returns: size of formatted string.
672 lpfc_programtype_show(struct device *dev, struct device_attribute *attr,
675 struct Scsi_Host *shost = class_to_shost(dev);
676 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
677 struct lpfc_hba *phba = vport->phba;
679 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType);
683 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
684 * @dev: class converted to a Scsi_host structure.
685 * @attr: device attribute, not used.
686 * @buf: on return contains the Menlo Maintenance sli flag.
688 * Returns: size of formatted string.
691 lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf)
693 struct Scsi_Host *shost = class_to_shost(dev);
694 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
695 struct lpfc_hba *phba = vport->phba;
697 return snprintf(buf, PAGE_SIZE, "%d\n",
698 (phba->sli.sli_flag & LPFC_MENLO_MAINT));
702 * lpfc_vportnum_show - Return the port number in ascii of the hba
703 * @dev: class converted to a Scsi_host structure.
704 * @attr: device attribute, not used.
705 * @buf: on return contains scsi vpd program type.
707 * Returns: size of formatted string.
710 lpfc_vportnum_show(struct device *dev, struct device_attribute *attr,
713 struct Scsi_Host *shost = class_to_shost(dev);
714 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
715 struct lpfc_hba *phba = vport->phba;
717 return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port);
721 * lpfc_fwrev_show - Return the firmware rev running in the hba
722 * @dev: class converted to a Scsi_host structure.
723 * @attr: device attribute, not used.
724 * @buf: on return contains the scsi vpd program type.
726 * Returns: size of formatted string.
729 lpfc_fwrev_show(struct device *dev, struct device_attribute *attr,
732 struct Scsi_Host *shost = class_to_shost(dev);
733 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
734 struct lpfc_hba *phba = vport->phba;
737 char fwrev[FW_REV_STR_SIZE];
740 lpfc_decode_firmware_rev(phba, fwrev, 1);
741 if_type = phba->sli4_hba.pc_sli4_params.if_type;
742 sli_family = phba->sli4_hba.pc_sli4_params.sli_family;
744 if (phba->sli_rev < LPFC_SLI_REV4)
745 len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n",
746 fwrev, phba->sli_rev);
748 len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n",
749 fwrev, phba->sli_rev, if_type, sli_family);
755 * lpfc_hdw_show - Return the jedec information about the hba
756 * @dev: class converted to a Scsi_host structure.
757 * @attr: device attribute, not used.
758 * @buf: on return contains the scsi vpd program type.
760 * Returns: size of formatted string.
763 lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf)
766 struct Scsi_Host *shost = class_to_shost(dev);
767 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
768 struct lpfc_hba *phba = vport->phba;
769 lpfc_vpd_t *vp = &phba->vpd;
771 lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
772 return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
776 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
777 * @dev: class converted to a Scsi_host structure.
778 * @attr: device attribute, not used.
779 * @buf: on return contains the ROM and FCode ascii strings.
781 * Returns: size of formatted string.
784 lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr,
787 struct Scsi_Host *shost = class_to_shost(dev);
788 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
789 struct lpfc_hba *phba = vport->phba;
790 char fwrev[FW_REV_STR_SIZE];
792 if (phba->sli_rev < LPFC_SLI_REV4)
793 return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
795 lpfc_decode_firmware_rev(phba, fwrev, 1);
796 return snprintf(buf, PAGE_SIZE, "%s\n", fwrev);
800 * lpfc_state_show - Return the link state of the port
801 * @dev: class converted to a Scsi_host structure.
802 * @attr: device attribute, not used.
803 * @buf: on return contains text describing the state of the link.
806 * The switch statement has no default so zero will be returned.
808 * Returns: size of formatted string.
811 lpfc_link_state_show(struct device *dev, struct device_attribute *attr,
814 struct Scsi_Host *shost = class_to_shost(dev);
815 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
816 struct lpfc_hba *phba = vport->phba;
819 switch (phba->link_state) {
820 case LPFC_LINK_UNKNOWN:
821 case LPFC_WARM_START:
822 case LPFC_INIT_START:
823 case LPFC_INIT_MBX_CMDS:
826 if (phba->hba_flag & LINK_DISABLED)
827 len += snprintf(buf + len, PAGE_SIZE-len,
828 "Link Down - User disabled\n");
830 len += snprintf(buf + len, PAGE_SIZE-len,
836 len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
838 switch (vport->port_state) {
839 case LPFC_LOCAL_CFG_LINK:
840 len += snprintf(buf + len, PAGE_SIZE-len,
841 "Configuring Link\n");
845 case LPFC_FABRIC_CFG_LINK:
848 case LPFC_BUILD_DISC_LIST:
850 len += snprintf(buf + len, PAGE_SIZE - len,
853 case LPFC_VPORT_READY:
854 len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n");
857 case LPFC_VPORT_FAILED:
858 len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n");
861 case LPFC_VPORT_UNKNOWN:
862 len += snprintf(buf + len, PAGE_SIZE - len,
866 if (phba->sli.sli_flag & LPFC_MENLO_MAINT)
867 len += snprintf(buf + len, PAGE_SIZE-len,
868 " Menlo Maint Mode\n");
869 else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
870 if (vport->fc_flag & FC_PUBLIC_LOOP)
871 len += snprintf(buf + len, PAGE_SIZE-len,
874 len += snprintf(buf + len, PAGE_SIZE-len,
877 if (vport->fc_flag & FC_FABRIC)
878 len += snprintf(buf + len, PAGE_SIZE-len,
881 len += snprintf(buf + len, PAGE_SIZE-len,
890 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
891 * @dev: class unused variable.
892 * @attr: device attribute, not used.
893 * @buf: on return contains the module description text.
895 * Returns: size of formatted string.
898 lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr,
901 struct Scsi_Host *shost = class_to_shost(dev);
902 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
903 struct lpfc_hba *phba = vport->phba;
905 if (phba->sli_rev < LPFC_SLI_REV4)
906 return snprintf(buf, PAGE_SIZE, "fc\n");
908 if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) {
909 if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE)
910 return snprintf(buf, PAGE_SIZE, "fcoe\n");
911 if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC)
912 return snprintf(buf, PAGE_SIZE, "fc\n");
914 return snprintf(buf, PAGE_SIZE, "unknown\n");
918 * lpfc_oas_supported_show - Return whether or not Optimized Access Storage
919 * (OAS) is supported.
920 * @dev: class unused variable.
921 * @attr: device attribute, not used.
922 * @buf: on return contains the module description text.
924 * Returns: size of formatted string.
927 lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr,
930 struct Scsi_Host *shost = class_to_shost(dev);
931 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
932 struct lpfc_hba *phba = vport->phba;
934 return snprintf(buf, PAGE_SIZE, "%d\n",
935 phba->sli4_hba.pc_sli4_params.oas_supported);
939 * lpfc_link_state_store - Transition the link_state on an HBA port
940 * @dev: class device that is converted into a Scsi_host.
941 * @attr: device attribute, not used.
942 * @buf: one or more lpfc_polling_flags values.
946 * -EINVAL if the buffer is not "up" or "down"
947 * return from link state change function if non-zero
948 * length of the buf on success
951 lpfc_link_state_store(struct device *dev, struct device_attribute *attr,
952 const char *buf, size_t count)
954 struct Scsi_Host *shost = class_to_shost(dev);
955 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
956 struct lpfc_hba *phba = vport->phba;
958 int status = -EINVAL;
960 if ((strncmp(buf, "up", sizeof("up") - 1) == 0) &&
961 (phba->link_state == LPFC_LINK_DOWN))
962 status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT);
963 else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) &&
964 (phba->link_state >= LPFC_LINK_UP))
965 status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT);
974 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
975 * @dev: class device that is converted into a Scsi_host.
976 * @attr: device attribute, not used.
977 * @buf: on return contains the sum of fc mapped and unmapped.
980 * Returns the ascii text number of the sum of the fc mapped and unmapped
983 * Returns: size of formatted string.
986 lpfc_num_discovered_ports_show(struct device *dev,
987 struct device_attribute *attr, char *buf)
989 struct Scsi_Host *shost = class_to_shost(dev);
990 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
992 return snprintf(buf, PAGE_SIZE, "%d\n",
993 vport->fc_map_cnt + vport->fc_unmap_cnt);
997 * lpfc_issue_lip - Misnomer, name carried over from long ago
998 * @shost: Scsi_Host pointer.
1001 * Bring the link down gracefully then re-init the link. The firmware will
1002 * re-init the fiber channel interface as required. Does not issue a LIP.
1005 * -EPERM port offline or management commands are being blocked
1006 * -ENOMEM cannot allocate memory for the mailbox command
1007 * -EIO error sending the mailbox command
1011 lpfc_issue_lip(struct Scsi_Host *shost)
1013 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1014 struct lpfc_hba *phba = vport->phba;
1015 LPFC_MBOXQ_t *pmboxq;
1016 int mbxstatus = MBXERR_ERROR;
1019 * If the link is offline, disabled or BLOCK_MGMT_IO
1020 * it doesn't make any sense to allow issue_lip
1022 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
1023 (phba->hba_flag & LINK_DISABLED) ||
1024 (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO))
1027 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
1032 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
1033 pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK;
1034 pmboxq->u.mb.mbxOwner = OWN_HOST;
1036 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2);
1038 if ((mbxstatus == MBX_SUCCESS) &&
1039 (pmboxq->u.mb.mbxStatus == 0 ||
1040 pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) {
1041 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
1042 lpfc_init_link(phba, pmboxq, phba->cfg_topology,
1043 phba->cfg_link_speed);
1044 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq,
1045 phba->fc_ratov * 2);
1046 if ((mbxstatus == MBX_SUCCESS) &&
1047 (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION))
1048 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
1049 "2859 SLI authentication is required "
1050 "for INIT_LINK but has not done yet\n");
1053 lpfc_set_loopback_flag(phba);
1054 if (mbxstatus != MBX_TIMEOUT)
1055 mempool_free(pmboxq, phba->mbox_mem_pool);
1057 if (mbxstatus == MBXERR_ERROR)
1064 lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock)
1068 spin_lock_irq(lock);
1069 while (!list_empty(q)) {
1070 spin_unlock_irq(lock);
1072 if (cnt++ > 250) { /* 5 secs */
1073 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
1075 "Outstanding IO when ",
1076 "bringing Adapter offline\n");
1079 spin_lock_irq(lock);
1081 spin_unlock_irq(lock);
1086 * lpfc_do_offline - Issues a mailbox command to bring the link down
1087 * @phba: lpfc_hba pointer.
1088 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
1091 * Assumes any error from lpfc_do_offline() will be negative.
1092 * Can wait up to 5 seconds for the port ring buffers count
1093 * to reach zero, prints a warning if it is not zero and continues.
1094 * lpfc_workq_post_event() returns a non-zero return code if call fails.
1097 * -EIO error posting the event
1101 lpfc_do_offline(struct lpfc_hba *phba, uint32_t type)
1103 struct completion online_compl;
1104 struct lpfc_queue *qp = NULL;
1105 struct lpfc_sli_ring *pring;
1106 struct lpfc_sli *psli;
1111 init_completion(&online_compl);
1112 rc = lpfc_workq_post_event(phba, &status, &online_compl,
1113 LPFC_EVT_OFFLINE_PREP);
1117 wait_for_completion(&online_compl);
1124 /* Wait a little for things to settle down, but not
1125 * long enough for dev loss timeout to expire.
1127 if (phba->sli_rev != LPFC_SLI_REV4) {
1128 for (i = 0; i < psli->num_rings; i++) {
1129 pring = &psli->sli3_ring[i];
1130 if (!lpfc_emptyq_wait(phba, &pring->txcmplq,
1135 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) {
1139 if (!lpfc_emptyq_wait(phba, &pring->txcmplq,
1145 init_completion(&online_compl);
1146 rc = lpfc_workq_post_event(phba, &status, &online_compl, type);
1150 wait_for_completion(&online_compl);
1159 * lpfc_selective_reset - Offline then onlines the port
1160 * @phba: lpfc_hba pointer.
1163 * If the port is configured to allow a reset then the hba is brought
1164 * offline then online.
1167 * Assumes any error from lpfc_do_offline() will be negative.
1168 * Do not make this function static.
1171 * lpfc_do_offline() return code if not zero
1172 * -EIO reset not configured or error posting the event
1176 lpfc_selective_reset(struct lpfc_hba *phba)
1178 struct completion online_compl;
1182 if (!phba->cfg_enable_hba_reset)
1185 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) {
1186 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
1192 init_completion(&online_compl);
1193 rc = lpfc_workq_post_event(phba, &status, &online_compl,
1198 wait_for_completion(&online_compl);
1207 * lpfc_issue_reset - Selectively resets an adapter
1208 * @dev: class device that is converted into a Scsi_host.
1209 * @attr: device attribute, not used.
1210 * @buf: containing the string "selective".
1211 * @count: unused variable.
1214 * If the buf contains the string "selective" then lpfc_selective_reset()
1215 * is called to perform the reset.
1218 * Assumes any error from lpfc_selective_reset() will be negative.
1219 * If lpfc_selective_reset() returns zero then the length of the buffer
1220 * is returned which indicates success
1223 * -EINVAL if the buffer does not contain the string "selective"
1224 * length of buf if lpfc-selective_reset() if the call succeeds
1225 * return value of lpfc_selective_reset() if the call fails
1228 lpfc_issue_reset(struct device *dev, struct device_attribute *attr,
1229 const char *buf, size_t count)
1231 struct Scsi_Host *shost = class_to_shost(dev);
1232 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1233 struct lpfc_hba *phba = vport->phba;
1234 int status = -EINVAL;
1236 if (!phba->cfg_enable_hba_reset)
1239 if (strncmp(buf, "selective", sizeof("selective") - 1) == 0)
1240 status = phba->lpfc_selective_reset(phba);
1249 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
1250 * @phba: lpfc_hba pointer.
1253 * SLI4 interface type-2 device to wait on the sliport status register for
1254 * the readyness after performing a firmware reset.
1257 * zero for success, -EPERM when port does not have privilege to perform the
1258 * reset, -EIO when port timeout from recovering from the reset.
1261 * As the caller will interpret the return code by value, be careful in making
1262 * change or addition to return codes.
1265 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba)
1267 struct lpfc_register portstat_reg = {0};
1271 lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
1272 &portstat_reg.word0);
1274 /* verify if privileged for the request operation */
1275 if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) &&
1276 !bf_get(lpfc_sliport_status_err, &portstat_reg))
1279 /* wait for the SLI port firmware ready after firmware reset */
1280 for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) {
1282 lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
1283 &portstat_reg.word0);
1284 if (!bf_get(lpfc_sliport_status_err, &portstat_reg))
1286 if (!bf_get(lpfc_sliport_status_rn, &portstat_reg))
1288 if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg))
1293 if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT)
1300 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
1301 * @phba: lpfc_hba pointer.
1304 * Request SLI4 interface type-2 device to perform a physical register set
1311 lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
1313 struct completion online_compl;
1314 struct pci_dev *pdev = phba->pcidev;
1315 uint32_t before_fc_flag;
1316 uint32_t sriov_nr_virtfn;
1318 int status = 0, rc = 0;
1319 int job_posted = 1, sriov_err;
1321 if (!phba->cfg_enable_hba_reset)
1324 if ((phba->sli_rev < LPFC_SLI_REV4) ||
1325 (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
1326 LPFC_SLI_INTF_IF_TYPE_2))
1329 /* Keep state if we need to restore back */
1330 before_fc_flag = phba->pport->fc_flag;
1331 sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn;
1333 /* Disable SR-IOV virtual functions if enabled */
1334 if (phba->cfg_sriov_nr_virtfn) {
1335 pci_disable_sriov(pdev);
1336 phba->cfg_sriov_nr_virtfn = 0;
1339 if (opcode == LPFC_FW_DUMP)
1340 phba->hba_flag |= HBA_FW_DUMP_OP;
1342 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
1345 phba->hba_flag &= ~HBA_FW_DUMP_OP;
1349 /* wait for the device to be quiesced before firmware reset */
1352 reg_val = readl(phba->sli4_hba.conf_regs_memmap_p +
1353 LPFC_CTL_PDEV_CTL_OFFSET);
1355 if (opcode == LPFC_FW_DUMP)
1356 reg_val |= LPFC_FW_DUMP_REQUEST;
1357 else if (opcode == LPFC_FW_RESET)
1358 reg_val |= LPFC_CTL_PDEV_CTL_FRST;
1359 else if (opcode == LPFC_DV_RESET)
1360 reg_val |= LPFC_CTL_PDEV_CTL_DRST;
1362 writel(reg_val, phba->sli4_hba.conf_regs_memmap_p +
1363 LPFC_CTL_PDEV_CTL_OFFSET);
1365 readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
1367 /* delay driver action following IF_TYPE_2 reset */
1368 rc = lpfc_sli4_pdev_status_reg_wait(phba);
1371 /* no privilege for reset */
1372 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1373 "3150 No privilege to perform the requested "
1374 "access: x%x\n", reg_val);
1375 } else if (rc == -EIO) {
1376 /* reset failed, there is nothing more we can do */
1377 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1378 "3153 Fail to perform the requested "
1379 "access: x%x\n", reg_val);
1383 /* keep the original port state */
1384 if (before_fc_flag & FC_OFFLINE_MODE)
1387 init_completion(&online_compl);
1388 job_posted = lpfc_workq_post_event(phba, &status, &online_compl,
1393 wait_for_completion(&online_compl);
1396 /* in any case, restore the virtual functions enabled as before */
1397 if (sriov_nr_virtfn) {
1399 lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn);
1401 phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn;
1404 /* return proper error code */
1415 * lpfc_nport_evt_cnt_show - Return the number of nport events
1416 * @dev: class device that is converted into a Scsi_host.
1417 * @attr: device attribute, not used.
1418 * @buf: on return contains the ascii number of nport events.
1420 * Returns: size of formatted string.
1423 lpfc_nport_evt_cnt_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;
1428 struct lpfc_hba *phba = vport->phba;
1430 return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
1434 * lpfc_board_mode_show - Return the state of the board
1435 * @dev: class device that is converted into a Scsi_host.
1436 * @attr: device attribute, not used.
1437 * @buf: on return contains the state of the adapter.
1439 * Returns: size of formatted string.
1442 lpfc_board_mode_show(struct device *dev, struct device_attribute *attr,
1445 struct Scsi_Host *shost = class_to_shost(dev);
1446 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1447 struct lpfc_hba *phba = vport->phba;
1450 if (phba->link_state == LPFC_HBA_ERROR)
1452 else if (phba->link_state == LPFC_WARM_START)
1453 state = "warm start";
1454 else if (phba->link_state == LPFC_INIT_START)
1459 return snprintf(buf, PAGE_SIZE, "%s\n", state);
1463 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1464 * @dev: class device that is converted into a Scsi_host.
1465 * @attr: device attribute, not used.
1466 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1467 * @count: unused variable.
1470 * -EACCES if enable hba reset not enabled
1471 * -EINVAL if the buffer does not contain a valid string (see above)
1472 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1473 * buf length greater than zero indicates success
1476 lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
1477 const char *buf, size_t count)
1479 struct Scsi_Host *shost = class_to_shost(dev);
1480 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1481 struct lpfc_hba *phba = vport->phba;
1482 struct completion online_compl;
1483 char *board_mode_str = NULL;
1487 if (!phba->cfg_enable_hba_reset) {
1489 goto board_mode_out;
1492 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1493 "3050 lpfc_board_mode set to %s\n", buf);
1495 init_completion(&online_compl);
1497 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
1498 rc = lpfc_workq_post_event(phba, &status, &online_compl,
1502 goto board_mode_out;
1504 wait_for_completion(&online_compl);
1507 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
1508 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
1509 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
1510 if (phba->sli_rev == LPFC_SLI_REV4)
1513 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START);
1514 else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
1515 if (phba->sli_rev == LPFC_SLI_REV4)
1518 status = lpfc_do_offline(phba, LPFC_EVT_KILL);
1519 else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0)
1520 status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP);
1521 else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0)
1522 status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET);
1523 else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0)
1524 status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET);
1532 board_mode_str = strchr(buf, '\n');
1534 *board_mode_str = '\0';
1535 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1536 "3097 Failed \"%s\", status(%d), "
1538 buf, status, phba->pport->fc_flag);
1544 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1545 * @phba: pointer to the adapter structure.
1546 * @mxri: max xri count.
1547 * @axri: available xri count.
1548 * @mrpi: max rpi count.
1549 * @arpi: available rpi count.
1550 * @mvpi: max vpi count.
1551 * @avpi: available vpi count.
1554 * If an integer pointer for an count is not null then the value for the
1555 * count is returned.
1562 lpfc_get_hba_info(struct lpfc_hba *phba,
1563 uint32_t *mxri, uint32_t *axri,
1564 uint32_t *mrpi, uint32_t *arpi,
1565 uint32_t *mvpi, uint32_t *avpi)
1567 struct lpfc_mbx_read_config *rd_config;
1568 LPFC_MBOXQ_t *pmboxq;
1574 * prevent udev from issuing mailbox commands until the port is
1577 if (phba->link_state < LPFC_LINK_DOWN ||
1578 !phba->mbox_mem_pool ||
1579 (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0)
1582 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
1585 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1588 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
1590 pmb = &pmboxq->u.mb;
1591 pmb->mbxCommand = MBX_READ_CONFIG;
1592 pmb->mbxOwner = OWN_HOST;
1593 pmboxq->context1 = NULL;
1595 if (phba->pport->fc_flag & FC_OFFLINE_MODE)
1596 rc = MBX_NOT_FINISHED;
1598 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
1600 if (rc != MBX_SUCCESS) {
1601 if (rc != MBX_TIMEOUT)
1602 mempool_free(pmboxq, phba->mbox_mem_pool);
1606 if (phba->sli_rev == LPFC_SLI_REV4) {
1607 rd_config = &pmboxq->u.mqe.un.rd_config;
1609 *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config);
1611 *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) -
1612 phba->sli4_hba.max_cfg_param.rpi_used;
1614 *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config);
1616 *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) -
1617 phba->sli4_hba.max_cfg_param.xri_used;
1619 /* Account for differences with SLI-3. Get vpi count from
1620 * mailbox data and subtract one for max vpi value.
1622 max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ?
1623 (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0;
1628 *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used;
1631 *mrpi = pmb->un.varRdConfig.max_rpi;
1633 *arpi = pmb->un.varRdConfig.avail_rpi;
1635 *mxri = pmb->un.varRdConfig.max_xri;
1637 *axri = pmb->un.varRdConfig.avail_xri;
1639 *mvpi = pmb->un.varRdConfig.max_vpi;
1641 *avpi = pmb->un.varRdConfig.avail_vpi;
1644 mempool_free(pmboxq, phba->mbox_mem_pool);
1649 * lpfc_max_rpi_show - Return maximum rpi
1650 * @dev: class device that is converted into a Scsi_host.
1651 * @attr: device attribute, not used.
1652 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1655 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1656 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1657 * to "Unknown" and the buffer length is returned, therefore the caller
1658 * must check for "Unknown" in the buffer to detect a failure.
1660 * Returns: size of formatted string.
1663 lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr,
1666 struct Scsi_Host *shost = class_to_shost(dev);
1667 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1668 struct lpfc_hba *phba = vport->phba;
1671 if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL))
1672 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1673 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1677 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1678 * @dev: class device that is converted into a Scsi_host.
1679 * @attr: device attribute, not used.
1680 * @buf: containing the used rpi count in decimal or "Unknown".
1683 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1684 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1685 * to "Unknown" and the buffer length is returned, therefore the caller
1686 * must check for "Unknown" in the buffer to detect a failure.
1688 * Returns: size of formatted string.
1691 lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr,
1694 struct Scsi_Host *shost = class_to_shost(dev);
1695 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1696 struct lpfc_hba *phba = vport->phba;
1699 if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL))
1700 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1701 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1705 * lpfc_max_xri_show - Return maximum xri
1706 * @dev: class device that is converted into a Scsi_host.
1707 * @attr: device attribute, not used.
1708 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1711 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1712 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1713 * to "Unknown" and the buffer length is returned, therefore the caller
1714 * must check for "Unknown" in the buffer to detect a failure.
1716 * Returns: size of formatted string.
1719 lpfc_max_xri_show(struct device *dev, struct device_attribute *attr,
1722 struct Scsi_Host *shost = class_to_shost(dev);
1723 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1724 struct lpfc_hba *phba = vport->phba;
1727 if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL))
1728 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1729 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1733 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1734 * @dev: class device that is converted into a Scsi_host.
1735 * @attr: device attribute, not used.
1736 * @buf: on return contains the used xri count in decimal or "Unknown".
1739 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1740 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1741 * to "Unknown" and the buffer length is returned, therefore the caller
1742 * must check for "Unknown" in the buffer to detect a failure.
1744 * Returns: size of formatted string.
1747 lpfc_used_xri_show(struct device *dev, struct device_attribute *attr,
1750 struct Scsi_Host *shost = class_to_shost(dev);
1751 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1752 struct lpfc_hba *phba = vport->phba;
1755 if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL))
1756 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1757 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1761 * lpfc_max_vpi_show - Return maximum vpi
1762 * @dev: class device that is converted into a Scsi_host.
1763 * @attr: device attribute, not used.
1764 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1767 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1768 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1769 * to "Unknown" and the buffer length is returned, therefore the caller
1770 * must check for "Unknown" in the buffer to detect a failure.
1772 * Returns: size of formatted string.
1775 lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr,
1778 struct Scsi_Host *shost = class_to_shost(dev);
1779 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1780 struct lpfc_hba *phba = vport->phba;
1783 if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL))
1784 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1785 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1789 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1790 * @dev: class device that is converted into a Scsi_host.
1791 * @attr: device attribute, not used.
1792 * @buf: on return contains the used vpi count in decimal or "Unknown".
1795 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1796 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1797 * to "Unknown" and the buffer length is returned, therefore the caller
1798 * must check for "Unknown" in the buffer to detect a failure.
1800 * Returns: size of formatted string.
1803 lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr,
1806 struct Scsi_Host *shost = class_to_shost(dev);
1807 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1808 struct lpfc_hba *phba = vport->phba;
1811 if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt))
1812 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1813 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1817 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1818 * @dev: class device that is converted into a Scsi_host.
1819 * @attr: device attribute, not used.
1820 * @buf: text that must be interpreted to determine if npiv is supported.
1823 * Buffer will contain text indicating npiv is not suppoerted on the port,
1824 * the port is an NPIV physical port, or it is an npiv virtual port with
1825 * the id of the vport.
1827 * Returns: size of formatted string.
1830 lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr,
1833 struct Scsi_Host *shost = class_to_shost(dev);
1834 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1835 struct lpfc_hba *phba = vport->phba;
1837 if (!(phba->max_vpi))
1838 return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n");
1839 if (vport->port_type == LPFC_PHYSICAL_PORT)
1840 return snprintf(buf, PAGE_SIZE, "NPIV Physical\n");
1841 return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi);
1845 * lpfc_poll_show - Return text about poll support for the adapter
1846 * @dev: class device that is converted into a Scsi_host.
1847 * @attr: device attribute, not used.
1848 * @buf: on return contains the cfg_poll in hex.
1851 * cfg_poll should be a lpfc_polling_flags type.
1853 * Returns: size of formatted string.
1856 lpfc_poll_show(struct device *dev, struct device_attribute *attr,
1859 struct Scsi_Host *shost = class_to_shost(dev);
1860 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1861 struct lpfc_hba *phba = vport->phba;
1863 return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
1867 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1868 * @dev: class device that is converted into a Scsi_host.
1869 * @attr: device attribute, not used.
1870 * @buf: one or more lpfc_polling_flags values.
1874 * buf contents converted to integer and checked for a valid value.
1877 * -EINVAL if the buffer connot be converted or is out of range
1878 * length of the buf on success
1881 lpfc_poll_store(struct device *dev, struct device_attribute *attr,
1882 const char *buf, size_t count)
1884 struct Scsi_Host *shost = class_to_shost(dev);
1885 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1886 struct lpfc_hba *phba = vport->phba;
1891 if (!isdigit(buf[0]))
1894 if (sscanf(buf, "%i", &val) != 1)
1897 if ((val & 0x3) != val)
1900 if (phba->sli_rev == LPFC_SLI_REV4)
1903 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1904 "3051 lpfc_poll changed from %d to %d\n",
1905 phba->cfg_poll, val);
1907 spin_lock_irq(&phba->hbalock);
1909 old_val = phba->cfg_poll;
1911 if (val & ENABLE_FCP_RING_POLLING) {
1912 if ((val & DISABLE_FCP_RING_INT) &&
1913 !(old_val & DISABLE_FCP_RING_INT)) {
1914 if (lpfc_readl(phba->HCregaddr, &creg_val)) {
1915 spin_unlock_irq(&phba->hbalock);
1918 creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
1919 writel(creg_val, phba->HCregaddr);
1920 readl(phba->HCregaddr); /* flush */
1922 lpfc_poll_start_timer(phba);
1924 } else if (val != 0x0) {
1925 spin_unlock_irq(&phba->hbalock);
1929 if (!(val & DISABLE_FCP_RING_INT) &&
1930 (old_val & DISABLE_FCP_RING_INT))
1932 spin_unlock_irq(&phba->hbalock);
1933 del_timer(&phba->fcp_poll_timer);
1934 spin_lock_irq(&phba->hbalock);
1935 if (lpfc_readl(phba->HCregaddr, &creg_val)) {
1936 spin_unlock_irq(&phba->hbalock);
1939 creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING);
1940 writel(creg_val, phba->HCregaddr);
1941 readl(phba->HCregaddr); /* flush */
1944 phba->cfg_poll = val;
1946 spin_unlock_irq(&phba->hbalock);
1952 * lpfc_fips_level_show - Return the current FIPS level for the HBA
1953 * @dev: class unused variable.
1954 * @attr: device attribute, not used.
1955 * @buf: on return contains the module description text.
1957 * Returns: size of formatted string.
1960 lpfc_fips_level_show(struct device *dev, struct device_attribute *attr,
1963 struct Scsi_Host *shost = class_to_shost(dev);
1964 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1965 struct lpfc_hba *phba = vport->phba;
1967 return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level);
1971 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
1972 * @dev: class unused variable.
1973 * @attr: device attribute, not used.
1974 * @buf: on return contains the module description text.
1976 * Returns: size of formatted string.
1979 lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr,
1982 struct Scsi_Host *shost = class_to_shost(dev);
1983 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1984 struct lpfc_hba *phba = vport->phba;
1986 return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev);
1990 * lpfc_dss_show - Return the current state of dss and the configured state
1991 * @dev: class converted to a Scsi_host structure.
1992 * @attr: device attribute, not used.
1993 * @buf: on return contains the formatted text.
1995 * Returns: size of formatted string.
1998 lpfc_dss_show(struct device *dev, struct device_attribute *attr,
2001 struct Scsi_Host *shost = class_to_shost(dev);
2002 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2003 struct lpfc_hba *phba = vport->phba;
2005 return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n",
2006 (phba->cfg_enable_dss) ? "Enabled" : "Disabled",
2007 (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ?
2012 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
2013 * @dev: class converted to a Scsi_host structure.
2014 * @attr: device attribute, not used.
2015 * @buf: on return contains the formatted support level.
2018 * Returns the maximum number of virtual functions a physical function can
2019 * support, 0 will be returned if called on virtual function.
2021 * Returns: size of formatted string.
2024 lpfc_sriov_hw_max_virtfn_show(struct device *dev,
2025 struct device_attribute *attr,
2028 struct Scsi_Host *shost = class_to_shost(dev);
2029 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2030 struct lpfc_hba *phba = vport->phba;
2031 uint16_t max_nr_virtfn;
2033 max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba);
2034 return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
2037 static inline bool lpfc_rangecheck(uint val, uint min, uint max)
2039 return val >= min && val <= max;
2043 * lpfc_enable_bbcr_set: Sets an attribute value.
2044 * @phba: pointer the the adapter structure.
2045 * @val: integer attribute value.
2048 * Validates the min and max values then sets the
2049 * adapter config field if in the valid range. prints error message
2050 * and does not set the parameter if invalid.
2054 * -EINVAL if val is invalid
2057 lpfc_enable_bbcr_set(struct lpfc_hba *phba, uint val)
2059 if (lpfc_rangecheck(val, 0, 1) && phba->sli_rev == LPFC_SLI_REV4) {
2060 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2061 "3068 %s_enable_bbcr changed from %d to %d\n",
2062 LPFC_DRIVER_NAME, phba->cfg_enable_bbcr, val);
2063 phba->cfg_enable_bbcr = val;
2066 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2067 "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n",
2068 LPFC_DRIVER_NAME, val);
2073 * lpfc_param_show - Return a cfg attribute value in decimal
2076 * Macro that given an attr e.g. hba_queue_depth expands
2077 * into a function with the name lpfc_hba_queue_depth_show.
2079 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
2080 * @dev: class device that is converted into a Scsi_host.
2081 * @attr: device attribute, not used.
2082 * @buf: on return contains the attribute value in decimal.
2084 * Returns: size of formatted string.
2086 #define lpfc_param_show(attr) \
2088 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2091 struct Scsi_Host *shost = class_to_shost(dev);\
2092 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2093 struct lpfc_hba *phba = vport->phba;\
2094 return snprintf(buf, PAGE_SIZE, "%d\n",\
2099 * lpfc_param_hex_show - Return a cfg attribute value in hex
2102 * Macro that given an attr e.g. hba_queue_depth expands
2103 * into a function with the name lpfc_hba_queue_depth_show
2105 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
2106 * @dev: class device that is converted into a Scsi_host.
2107 * @attr: device attribute, not used.
2108 * @buf: on return contains the attribute value in hexadecimal.
2110 * Returns: size of formatted string.
2112 #define lpfc_param_hex_show(attr) \
2114 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2117 struct Scsi_Host *shost = class_to_shost(dev);\
2118 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2119 struct lpfc_hba *phba = vport->phba;\
2121 val = phba->cfg_##attr;\
2122 return snprintf(buf, PAGE_SIZE, "%#x\n",\
2127 * lpfc_param_init - Initializes a cfg attribute
2130 * Macro that given an attr e.g. hba_queue_depth expands
2131 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2132 * takes a default argument, a minimum and maximum argument.
2134 * lpfc_##attr##_init: Initializes an attribute.
2135 * @phba: pointer the the adapter structure.
2136 * @val: integer attribute value.
2138 * Validates the min and max values then sets the adapter config field
2139 * accordingly, or uses the default if out of range and prints an error message.
2143 * -EINVAL if default used
2145 #define lpfc_param_init(attr, default, minval, maxval) \
2147 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
2149 if (lpfc_rangecheck(val, minval, maxval)) {\
2150 phba->cfg_##attr = val;\
2153 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2154 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
2155 "allowed range is ["#minval", "#maxval"]\n", val); \
2156 phba->cfg_##attr = default;\
2161 * lpfc_param_set - Set a cfg attribute value
2164 * Macro that given an attr e.g. hba_queue_depth expands
2165 * into a function with the name lpfc_hba_queue_depth_set
2167 * lpfc_##attr##_set: Sets an attribute value.
2168 * @phba: pointer the the adapter structure.
2169 * @val: integer attribute value.
2172 * Validates the min and max values then sets the
2173 * adapter config field if in the valid range. prints error message
2174 * and does not set the parameter if invalid.
2178 * -EINVAL if val is invalid
2180 #define lpfc_param_set(attr, default, minval, maxval) \
2182 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
2184 if (lpfc_rangecheck(val, minval, maxval)) {\
2185 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2186 "3052 lpfc_" #attr " changed from %d to %d\n", \
2187 phba->cfg_##attr, val); \
2188 phba->cfg_##attr = val;\
2191 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2192 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
2193 "allowed range is ["#minval", "#maxval"]\n", val); \
2198 * lpfc_param_store - Set a vport attribute value
2201 * Macro that given an attr e.g. hba_queue_depth expands
2202 * into a function with the name lpfc_hba_queue_depth_store.
2204 * lpfc_##attr##_store: Set an sttribute value.
2205 * @dev: class device that is converted into a Scsi_host.
2206 * @attr: device attribute, not used.
2207 * @buf: contains the attribute value in ascii.
2211 * Convert the ascii text number to an integer, then
2212 * use the lpfc_##attr##_set function to set the value.
2215 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2216 * length of buffer upon success.
2218 #define lpfc_param_store(attr) \
2220 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2221 const char *buf, size_t count) \
2223 struct Scsi_Host *shost = class_to_shost(dev);\
2224 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2225 struct lpfc_hba *phba = vport->phba;\
2227 if (!isdigit(buf[0]))\
2229 if (sscanf(buf, "%i", &val) != 1)\
2231 if (lpfc_##attr##_set(phba, val) == 0) \
2232 return strlen(buf);\
2238 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
2241 * Macro that given an attr e.g. hba_queue_depth expands
2242 * into a function with the name lpfc_hba_queue_depth_show
2244 * lpfc_##attr##_show: prints the attribute value in decimal.
2245 * @dev: class device that is converted into a Scsi_host.
2246 * @attr: device attribute, not used.
2247 * @buf: on return contains the attribute value in decimal.
2249 * Returns: length of formatted string.
2251 #define lpfc_vport_param_show(attr) \
2253 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2256 struct Scsi_Host *shost = class_to_shost(dev);\
2257 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2258 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
2262 * lpfc_vport_param_hex_show - Return hex formatted attribute value
2265 * Macro that given an attr e.g.
2266 * hba_queue_depth expands into a function with the name
2267 * lpfc_hba_queue_depth_show
2269 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
2270 * @dev: class device that is converted into a Scsi_host.
2271 * @attr: device attribute, not used.
2272 * @buf: on return contains the attribute value in hexadecimal.
2274 * Returns: length of formatted string.
2276 #define lpfc_vport_param_hex_show(attr) \
2278 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2281 struct Scsi_Host *shost = class_to_shost(dev);\
2282 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2283 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
2287 * lpfc_vport_param_init - Initialize a vport cfg attribute
2290 * Macro that given an attr e.g. hba_queue_depth expands
2291 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2292 * takes a default argument, a minimum and maximum argument.
2294 * lpfc_##attr##_init: validates the min and max values then sets the
2295 * adapter config field accordingly, or uses the default if out of range
2296 * and prints an error message.
2297 * @phba: pointer the the adapter structure.
2298 * @val: integer attribute value.
2302 * -EINVAL if default used
2304 #define lpfc_vport_param_init(attr, default, minval, maxval) \
2306 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
2308 if (lpfc_rangecheck(val, minval, maxval)) {\
2309 vport->cfg_##attr = val;\
2312 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2313 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
2314 "allowed range is ["#minval", "#maxval"]\n", val); \
2315 vport->cfg_##attr = default;\
2320 * lpfc_vport_param_set - Set a vport cfg attribute
2323 * Macro that given an attr e.g. hba_queue_depth expands
2324 * into a function with the name lpfc_hba_queue_depth_set
2326 * lpfc_##attr##_set: validates the min and max values then sets the
2327 * adapter config field if in the valid range. prints error message
2328 * and does not set the parameter if invalid.
2329 * @phba: pointer the the adapter structure.
2330 * @val: integer attribute value.
2334 * -EINVAL if val is invalid
2336 #define lpfc_vport_param_set(attr, default, minval, maxval) \
2338 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
2340 if (lpfc_rangecheck(val, minval, maxval)) {\
2341 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2342 "3053 lpfc_" #attr \
2343 " changed from %d (x%x) to %d (x%x)\n", \
2344 vport->cfg_##attr, vport->cfg_##attr, \
2346 vport->cfg_##attr = val;\
2349 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2350 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
2351 "allowed range is ["#minval", "#maxval"]\n", val); \
2356 * lpfc_vport_param_store - Set a vport attribute
2359 * Macro that given an attr e.g. hba_queue_depth
2360 * expands into a function with the name lpfc_hba_queue_depth_store
2362 * lpfc_##attr##_store: convert the ascii text number to an integer, then
2363 * use the lpfc_##attr##_set function to set the value.
2364 * @cdev: class device that is converted into a Scsi_host.
2365 * @buf: contains the attribute value in decimal.
2369 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2370 * length of buffer upon success.
2372 #define lpfc_vport_param_store(attr) \
2374 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2375 const char *buf, size_t count) \
2377 struct Scsi_Host *shost = class_to_shost(dev);\
2378 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2380 if (!isdigit(buf[0]))\
2382 if (sscanf(buf, "%i", &val) != 1)\
2384 if (lpfc_##attr##_set(vport, val) == 0) \
2385 return strlen(buf);\
2391 static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL);
2392 static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL);
2393 static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL);
2394 static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL);
2395 static DEVICE_ATTR(bg_reftag_err, S_IRUGO, lpfc_bg_reftag_err_show, NULL);
2396 static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
2397 static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
2398 static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
2399 static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL);
2400 static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL);
2401 static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL);
2402 static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL);
2403 static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL);
2404 static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show,
2405 lpfc_link_state_store);
2406 static DEVICE_ATTR(option_rom_version, S_IRUGO,
2407 lpfc_option_rom_version_show, NULL);
2408 static DEVICE_ATTR(num_discovered_ports, S_IRUGO,
2409 lpfc_num_discovered_ports_show, NULL);
2410 static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL);
2411 static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
2412 static DEVICE_ATTR_RO(lpfc_drvr_version);
2413 static DEVICE_ATTR_RO(lpfc_enable_fip);
2414 static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
2415 lpfc_board_mode_show, lpfc_board_mode_store);
2416 static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
2417 static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL);
2418 static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL);
2419 static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL);
2420 static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL);
2421 static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
2422 static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
2423 static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
2424 static DEVICE_ATTR_RO(lpfc_temp_sensor);
2425 static DEVICE_ATTR_RO(lpfc_fips_level);
2426 static DEVICE_ATTR_RO(lpfc_fips_rev);
2427 static DEVICE_ATTR_RO(lpfc_dss);
2428 static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn);
2429 static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL);
2430 static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show,
2433 static char *lpfc_soft_wwn_key = "C99G71SL8032A";
2436 * lpfc_wwn_set - Convert string to the 8 byte WWN value.
2438 * @cnt: Length of string.
2439 * @wwn: Array to receive converted wwn value.
2442 * -EINVAL if the buffer does not contain a valid wwn
2446 lpfc_wwn_set(const char *buf, size_t cnt, char wwn[])
2450 /* Count may include a LF at end of string */
2451 if (buf[cnt-1] == '\n')
2454 if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) ||
2455 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
2458 memset(wwn, 0, WWN_SZ);
2460 /* Validate and store the new name */
2461 for (i = 0, j = 0; i < 16; i++) {
2462 if ((*buf >= 'a') && (*buf <= 'f'))
2463 j = ((j << 4) | ((*buf++ - 'a') + 10));
2464 else if ((*buf >= 'A') && (*buf <= 'F'))
2465 j = ((j << 4) | ((*buf++ - 'A') + 10));
2466 else if ((*buf >= '0') && (*buf <= '9'))
2467 j = ((j << 4) | (*buf++ - '0'));
2471 wwn[i/2] = j & 0xff;
2478 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2479 * @dev: class device that is converted into a Scsi_host.
2480 * @attr: device attribute, not used.
2481 * @buf: containing the string lpfc_soft_wwn_key.
2482 * @count: must be size of lpfc_soft_wwn_key.
2485 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2486 * length of buf indicates success
2489 lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr,
2490 const char *buf, size_t count)
2492 struct Scsi_Host *shost = class_to_shost(dev);
2493 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2494 struct lpfc_hba *phba = vport->phba;
2495 unsigned int cnt = count;
2496 uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level;
2497 u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0];
2500 * We're doing a simple sanity check for soft_wwpn setting.
2501 * We require that the user write a specific key to enable
2502 * the soft_wwpn attribute to be settable. Once the attribute
2503 * is written, the enable key resets. If further updates are
2504 * desired, the key must be written again to re-enable the
2507 * The "key" is not secret - it is a hardcoded string shown
2508 * here. The intent is to protect against the random user or
2509 * application that is just writing attributes.
2511 if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) {
2512 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2513 "0051 "LPFC_DRIVER_NAME" soft wwpn can not"
2514 " be enabled: fawwpn is enabled\n");
2518 /* count may include a LF at end of string */
2519 if (buf[cnt-1] == '\n')
2522 if ((cnt != strlen(lpfc_soft_wwn_key)) ||
2523 (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0))
2526 phba->soft_wwn_enable = 1;
2528 dev_printk(KERN_WARNING, &phba->pcidev->dev,
2529 "lpfc%d: soft_wwpn assignment has been enabled.\n",
2531 dev_printk(KERN_WARNING, &phba->pcidev->dev,
2532 " The soft_wwpn feature is not supported by Broadcom.");
2536 static DEVICE_ATTR_WO(lpfc_soft_wwn_enable);
2539 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2540 * @dev: class device that is converted into a Scsi_host.
2541 * @attr: device attribute, not used.
2542 * @buf: on return contains the wwpn in hexadecimal.
2544 * Returns: size of formatted string.
2547 lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr,
2550 struct Scsi_Host *shost = class_to_shost(dev);
2551 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2552 struct lpfc_hba *phba = vport->phba;
2554 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2555 (unsigned long long)phba->cfg_soft_wwpn);
2559 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2560 * @dev class device that is converted into a Scsi_host.
2561 * @attr: device attribute, not used.
2562 * @buf: contains the wwpn in hexadecimal.
2563 * @count: number of wwpn bytes in buf
2566 * -EACCES hba reset not enabled, adapter over temp
2567 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2568 * -EIO error taking adapter offline or online
2569 * value of count on success
2572 lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr,
2573 const char *buf, size_t count)
2575 struct Scsi_Host *shost = class_to_shost(dev);
2576 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2577 struct lpfc_hba *phba = vport->phba;
2578 struct completion online_compl;
2579 int stat1 = 0, stat2 = 0;
2580 unsigned int cnt = count;
2584 if (!phba->cfg_enable_hba_reset)
2586 spin_lock_irq(&phba->hbalock);
2587 if (phba->over_temp_state == HBA_OVER_TEMP) {
2588 spin_unlock_irq(&phba->hbalock);
2591 spin_unlock_irq(&phba->hbalock);
2592 /* count may include a LF at end of string */
2593 if (buf[cnt-1] == '\n')
2596 if (!phba->soft_wwn_enable)
2599 /* lock setting wwpn, wwnn down */
2600 phba->soft_wwn_enable = 0;
2602 rc = lpfc_wwn_set(buf, cnt, wwpn);
2604 /* not able to set wwpn, unlock it */
2605 phba->soft_wwn_enable = 1;
2609 phba->cfg_soft_wwpn = wwn_to_u64(wwpn);
2610 fc_host_port_name(shost) = phba->cfg_soft_wwpn;
2611 if (phba->cfg_soft_wwnn)
2612 fc_host_node_name(shost) = phba->cfg_soft_wwnn;
2614 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
2615 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no);
2617 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
2619 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2620 "0463 lpfc_soft_wwpn attribute set failed to "
2621 "reinit adapter - %d\n", stat1);
2622 init_completion(&online_compl);
2623 rc = lpfc_workq_post_event(phba, &stat2, &online_compl,
2628 wait_for_completion(&online_compl);
2630 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2631 "0464 lpfc_soft_wwpn attribute set failed to "
2632 "reinit adapter - %d\n", stat2);
2633 return (stat1 || stat2) ? -EIO : count;
2635 static DEVICE_ATTR_RW(lpfc_soft_wwpn);
2638 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2639 * @dev: class device that is converted into a Scsi_host.
2640 * @attr: device attribute, not used.
2641 * @buf: on return contains the wwnn in hexadecimal.
2643 * Returns: size of formatted string.
2646 lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr,
2649 struct Scsi_Host *shost = class_to_shost(dev);
2650 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2651 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2652 (unsigned long long)phba->cfg_soft_wwnn);
2656 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2657 * @cdev: class device that is converted into a Scsi_host.
2658 * @buf: contains the ww node name in hexadecimal.
2659 * @count: number of wwnn bytes in buf.
2662 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2663 * value of count on success
2666 lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr,
2667 const char *buf, size_t count)
2669 struct Scsi_Host *shost = class_to_shost(dev);
2670 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2671 unsigned int cnt = count;
2675 /* count may include a LF at end of string */
2676 if (buf[cnt-1] == '\n')
2679 if (!phba->soft_wwn_enable)
2682 rc = lpfc_wwn_set(buf, cnt, wwnn);
2684 /* Allow wwnn to be set many times, as long as the enable
2685 * is set. However, once the wwpn is set, everything locks.
2690 phba->cfg_soft_wwnn = wwn_to_u64(wwnn);
2692 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
2693 "lpfc%d: soft_wwnn set. Value will take effect upon "
2694 "setting of the soft_wwpn\n", phba->brd_no);
2698 static DEVICE_ATTR_RW(lpfc_soft_wwnn);
2701 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for
2702 * Optimized Access Storage (OAS) operations.
2703 * @dev: class device that is converted into a Scsi_host.
2704 * @attr: device attribute, not used.
2705 * @buf: buffer for passing information.
2711 lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr,
2714 struct Scsi_Host *shost = class_to_shost(dev);
2715 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2717 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2718 wwn_to_u64(phba->cfg_oas_tgt_wwpn));
2722 * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for
2723 * Optimized Access Storage (OAS) operations.
2724 * @dev: class device that is converted into a Scsi_host.
2725 * @attr: device attribute, not used.
2726 * @buf: buffer for passing information.
2727 * @count: Size of the data buffer.
2730 * -EINVAL count is invalid, invalid wwpn byte invalid
2731 * -EPERM oas is not supported by hba
2732 * value of count on success
2735 lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr,
2736 const char *buf, size_t count)
2738 struct Scsi_Host *shost = class_to_shost(dev);
2739 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2740 unsigned int cnt = count;
2741 uint8_t wwpn[WWN_SZ];
2747 /* count may include a LF at end of string */
2748 if (buf[cnt-1] == '\n')
2751 rc = lpfc_wwn_set(buf, cnt, wwpn);
2755 memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t)));
2756 memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t)));
2757 if (wwn_to_u64(wwpn) == 0)
2758 phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET;
2760 phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET;
2761 phba->cfg_oas_flags &= ~OAS_LUN_VALID;
2762 phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN;
2765 static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR,
2766 lpfc_oas_tgt_show, lpfc_oas_tgt_store);
2769 * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for
2770 * Optimized Access Storage (OAS) operations.
2771 * @dev: class device that is converted into a Scsi_host.
2772 * @attr: device attribute, not used.
2773 * @buf: buffer for passing information.
2779 lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr,
2782 struct Scsi_Host *shost = class_to_shost(dev);
2783 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2785 return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority);
2789 * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for
2790 * Optimized Access Storage (OAS) operations.
2791 * @dev: class device that is converted into a Scsi_host.
2792 * @attr: device attribute, not used.
2793 * @buf: buffer for passing information.
2794 * @count: Size of the data buffer.
2797 * -EINVAL count is invalid, invalid wwpn byte invalid
2798 * -EPERM oas is not supported by hba
2799 * value of count on success
2802 lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr,
2803 const char *buf, size_t count)
2805 struct Scsi_Host *shost = class_to_shost(dev);
2806 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2807 unsigned int cnt = count;
2814 /* count may include a LF at end of string */
2815 if (buf[cnt-1] == '\n')
2818 ret = kstrtoul(buf, 0, &val);
2819 if (ret || (val > 0x7f))
2823 phba->cfg_oas_priority = (uint8_t)val;
2825 phba->cfg_oas_priority = phba->cfg_XLanePriority;
2828 static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR,
2829 lpfc_oas_priority_show, lpfc_oas_priority_store);
2832 * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled
2833 * for Optimized Access Storage (OAS) operations.
2834 * @dev: class device that is converted into a Scsi_host.
2835 * @attr: device attribute, not used.
2836 * @buf: buffer for passing information.
2839 * value of count on success
2842 lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr,
2845 struct Scsi_Host *shost = class_to_shost(dev);
2846 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2848 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2849 wwn_to_u64(phba->cfg_oas_vpt_wwpn));
2853 * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled
2854 * for Optimized Access Storage (OAS) operations.
2855 * @dev: class device that is converted into a Scsi_host.
2856 * @attr: device attribute, not used.
2857 * @buf: buffer for passing information.
2858 * @count: Size of the data buffer.
2861 * -EINVAL count is invalid, invalid wwpn byte invalid
2862 * -EPERM oas is not supported by hba
2863 * value of count on success
2866 lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr,
2867 const char *buf, size_t count)
2869 struct Scsi_Host *shost = class_to_shost(dev);
2870 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2871 unsigned int cnt = count;
2872 uint8_t wwpn[WWN_SZ];
2878 /* count may include a LF at end of string */
2879 if (buf[cnt-1] == '\n')
2882 rc = lpfc_wwn_set(buf, cnt, wwpn);
2886 memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t)));
2887 memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t)));
2888 if (wwn_to_u64(wwpn) == 0)
2889 phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT;
2891 phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT;
2892 phba->cfg_oas_flags &= ~OAS_LUN_VALID;
2893 if (phba->cfg_oas_priority == 0)
2894 phba->cfg_oas_priority = phba->cfg_XLanePriority;
2895 phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN;
2898 static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR,
2899 lpfc_oas_vpt_show, lpfc_oas_vpt_store);
2902 * lpfc_oas_lun_state_show - Return the current state (enabled or disabled)
2903 * of whether luns will be enabled or disabled
2904 * for Optimized Access Storage (OAS) operations.
2905 * @dev: class device that is converted into a Scsi_host.
2906 * @attr: device attribute, not used.
2907 * @buf: buffer for passing information.
2910 * size of formatted string.
2913 lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr,
2916 struct Scsi_Host *shost = class_to_shost(dev);
2917 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2919 return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state);
2923 * lpfc_oas_lun_state_store - Store the state (enabled or disabled)
2924 * of whether luns will be enabled or disabled
2925 * for Optimized Access Storage (OAS) operations.
2926 * @dev: class device that is converted into a Scsi_host.
2927 * @attr: device attribute, not used.
2928 * @buf: buffer for passing information.
2929 * @count: Size of the data buffer.
2932 * -EINVAL count is invalid, invalid wwpn byte invalid
2933 * -EPERM oas is not supported by hba
2934 * value of count on success
2937 lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr,
2938 const char *buf, size_t count)
2940 struct Scsi_Host *shost = class_to_shost(dev);
2941 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2947 if (!isdigit(buf[0]))
2950 if (sscanf(buf, "%i", &val) != 1)
2953 if ((val != 0) && (val != 1))
2956 phba->cfg_oas_lun_state = val;
2959 static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR,
2960 lpfc_oas_lun_state_show, lpfc_oas_lun_state_store);
2963 * lpfc_oas_lun_status_show - Return the status of the Optimized Access
2964 * Storage (OAS) lun returned by the
2965 * lpfc_oas_lun_show function.
2966 * @dev: class device that is converted into a Scsi_host.
2967 * @attr: device attribute, not used.
2968 * @buf: buffer for passing information.
2971 * size of formatted string.
2974 lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr,
2977 struct Scsi_Host *shost = class_to_shost(dev);
2978 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2980 if (!(phba->cfg_oas_flags & OAS_LUN_VALID))
2983 return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status);
2985 static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO,
2986 lpfc_oas_lun_status_show, NULL);
2990 * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage
2992 * @phba: lpfc_hba pointer.
2993 * @ndlp: pointer to fcp target node.
2994 * @lun: the fc lun for setting oas state.
2995 * @oas_state: the oas state to be set to the lun.
2999 * -EPERM OAS is not enabled or not supported by this port.
3003 lpfc_oas_lun_state_set(struct lpfc_hba *phba, uint8_t vpt_wwpn[],
3004 uint8_t tgt_wwpn[], uint64_t lun,
3005 uint32_t oas_state, uint8_t pri)
3014 if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn,
3015 (struct lpfc_name *)tgt_wwpn,
3019 lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn,
3020 (struct lpfc_name *)tgt_wwpn, lun, pri);
3027 * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized
3028 * Access Storage (OAS) operations.
3029 * @phba: lpfc_hba pointer.
3030 * @vpt_wwpn: wwpn of the vport associated with the returned lun
3031 * @tgt_wwpn: wwpn of the target associated with the returned lun
3032 * @lun_status: status of the lun returned lun
3034 * Returns the first or next lun enabled for OAS operations for the vport/target
3035 * specified. If a lun is found, its vport wwpn, target wwpn and status is
3036 * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned.
3039 * lun that is OAS enabled for the vport/target
3040 * NOT_OAS_ENABLED_LUN when no oas enabled lun found.
3043 lpfc_oas_lun_get_next(struct lpfc_hba *phba, uint8_t vpt_wwpn[],
3044 uint8_t tgt_wwpn[], uint32_t *lun_status,
3049 if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn)
3050 return NOT_OAS_ENABLED_LUN;
3051 if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *)
3052 phba->sli4_hba.oas_next_vpt_wwpn,
3053 (struct lpfc_name *)
3054 phba->sli4_hba.oas_next_tgt_wwpn,
3055 &phba->sli4_hba.oas_next_lun,
3056 (struct lpfc_name *)vpt_wwpn,
3057 (struct lpfc_name *)tgt_wwpn,
3058 &found_lun, lun_status, lun_pri))
3061 return NOT_OAS_ENABLED_LUN;
3065 * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations
3066 * @phba: lpfc_hba pointer.
3067 * @vpt_wwpn: vport wwpn by reference.
3068 * @tgt_wwpn: target wwpn by reference.
3069 * @lun: the fc lun for setting oas state.
3070 * @oas_state: the oas state to be set to the oas_lun.
3072 * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE)
3073 * a lun for OAS operations.
3077 * -ENOMEM: failed to enable an lun for OAS operations
3078 * -EPERM: OAS is not enabled
3081 lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[],
3082 uint8_t tgt_wwpn[], uint64_t lun,
3083 uint32_t oas_state, uint8_t pri)
3088 rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun,
3094 * lpfc_oas_lun_show - Return oas enabled luns from a chosen target
3095 * @dev: class device that is converted into a Scsi_host.
3096 * @attr: device attribute, not used.
3097 * @buf: buffer for passing information.
3099 * This routine returns a lun enabled for OAS each time the function
3103 * SUCCESS: size of formatted string.
3104 * -EFAULT: target or vport wwpn was not set properly.
3105 * -EPERM: oas is not enabled.
3108 lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr,
3111 struct Scsi_Host *shost = class_to_shost(dev);
3112 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
3120 if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0)
3121 if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT))
3124 if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0)
3125 if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET))
3128 oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn,
3129 phba->cfg_oas_tgt_wwpn,
3130 &phba->cfg_oas_lun_status,
3131 &phba->cfg_oas_priority);
3132 if (oas_lun != NOT_OAS_ENABLED_LUN)
3133 phba->cfg_oas_flags |= OAS_LUN_VALID;
3135 len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun);
3141 * lpfc_oas_lun_store - Sets the OAS state for lun
3142 * @dev: class device that is converted into a Scsi_host.
3143 * @attr: device attribute, not used.
3144 * @buf: buffer for passing information.
3146 * This function sets the OAS state for lun. Before this function is called,
3147 * the vport wwpn, target wwpn, and oas state need to be set.
3150 * SUCCESS: size of formatted string.
3151 * -EFAULT: target or vport wwpn was not set properly.
3152 * -EPERM: oas is not enabled.
3153 * size of formatted string.
3156 lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr,
3157 const char *buf, size_t count)
3159 struct Scsi_Host *shost = class_to_shost(dev);
3160 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
3168 if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0)
3171 if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0)
3174 if (!isdigit(buf[0]))
3177 if (sscanf(buf, "0x%llx", &scsi_lun) != 1)
3180 pri = phba->cfg_oas_priority;
3182 pri = phba->cfg_XLanePriority;
3184 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
3185 "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx "
3186 "priority 0x%x with oas state %d\n",
3187 wwn_to_u64(phba->cfg_oas_vpt_wwpn),
3188 wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun,
3189 pri, phba->cfg_oas_lun_state);
3191 rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn,
3192 phba->cfg_oas_tgt_wwpn, scsi_lun,
3193 phba->cfg_oas_lun_state, pri);
3199 static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR,
3200 lpfc_oas_lun_show, lpfc_oas_lun_store);
3202 int lpfc_enable_nvmet_cnt;
3203 unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = {
3204 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3205 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3206 module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444);
3207 MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target");
3209 static int lpfc_poll = 0;
3210 module_param(lpfc_poll, int, S_IRUGO);
3211 MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
3213 " 1 - poll with interrupts enabled"
3214 " 3 - poll and disable FCP ring interrupts");
3216 static DEVICE_ATTR_RW(lpfc_poll);
3218 int lpfc_no_hba_reset_cnt;
3219 unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = {
3220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3221 module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444);
3222 MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset");
3224 LPFC_ATTR(sli_mode, 0, 0, 3,
3225 "SLI mode selector:"
3226 " 0 - auto (SLI-3 if supported),"
3227 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
3228 " 3 - select SLI-3");
3230 LPFC_ATTR_R(enable_npiv, 1, 0, 1,
3231 "Enable NPIV functionality");
3233 LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2,
3234 "FCF Fast failover=1 Priority failover=2");
3237 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
3238 # 0x0 = disabled, XRI/OXID use not tracked.
3239 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
3240 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
3242 LPFC_ATTR_R(enable_rrq, 2, 0, 2,
3243 "Enable RRQ functionality");
3246 # lpfc_suppress_link_up: Bring link up at initialization
3247 # 0x0 = bring link up (issue MBX_INIT_LINK)
3248 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
3249 # 0x2 = never bring up link
3250 # Default value is 0.
3252 LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK,
3253 LPFC_DELAY_INIT_LINK_INDEFINITELY,
3254 "Suppress Link Up at initialization");
3256 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
3264 lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf)
3266 struct Scsi_Host *shost = class_to_shost(dev);
3267 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
3269 return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max);
3272 static DEVICE_ATTR(iocb_hw, S_IRUGO,
3273 lpfc_iocb_hw_show, NULL);
3275 lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf)
3277 struct Scsi_Host *shost = class_to_shost(dev);
3278 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
3279 struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba);
3281 return snprintf(buf, PAGE_SIZE, "%d\n",
3282 pring ? pring->txq_max : 0);
3285 static DEVICE_ATTR(txq_hw, S_IRUGO,
3286 lpfc_txq_hw_show, NULL);
3288 lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr,
3291 struct Scsi_Host *shost = class_to_shost(dev);
3292 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
3293 struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba);
3295 return snprintf(buf, PAGE_SIZE, "%d\n",
3296 pring ? pring->txcmplq_max : 0);
3299 static DEVICE_ATTR(txcmplq_hw, S_IRUGO,
3300 lpfc_txcmplq_hw_show, NULL);
3302 LPFC_ATTR_R(iocb_cnt, 2, 1, 5,
3303 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
3306 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
3307 # until the timer expires. Value range is [0,255]. Default value is 30.
3309 static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
3310 static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO;
3311 module_param(lpfc_nodev_tmo, int, 0);
3312 MODULE_PARM_DESC(lpfc_nodev_tmo,
3313 "Seconds driver will hold I/O waiting "
3314 "for a device to come back");
3317 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
3318 * @dev: class converted to a Scsi_host structure.
3319 * @attr: device attribute, not used.
3320 * @buf: on return contains the dev loss timeout in decimal.
3322 * Returns: size of formatted string.
3325 lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr,
3328 struct Scsi_Host *shost = class_to_shost(dev);
3329 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3331 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
3335 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
3336 * @vport: lpfc vport structure pointer.
3337 * @val: contains the nodev timeout value.
3340 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
3341 * a kernel error message is printed and zero is returned.
3342 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3343 * Otherwise nodev tmo is set to the default value.
3346 * zero if already set or if val is in range
3347 * -EINVAL val out of range
3350 lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
3352 if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) {
3353 vport->cfg_nodev_tmo = vport->cfg_devloss_tmo;
3354 if (val != LPFC_DEF_DEVLOSS_TMO)
3355 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3356 "0407 Ignoring lpfc_nodev_tmo module "
3357 "parameter because lpfc_devloss_tmo "
3362 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
3363 vport->cfg_nodev_tmo = val;
3364 vport->cfg_devloss_tmo = val;
3367 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3368 "0400 lpfc_nodev_tmo attribute cannot be set to"
3369 " %d, allowed range is [%d, %d]\n",
3370 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
3371 vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
3376 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
3377 * @vport: lpfc vport structure pointer.
3380 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
3383 lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
3385 struct Scsi_Host *shost;
3386 struct lpfc_nodelist *ndlp;
3387 #if (IS_ENABLED(CONFIG_NVME_FC))
3388 struct lpfc_nvme_rport *rport;
3389 struct nvme_fc_remote_port *remoteport = NULL;
3392 shost = lpfc_shost_from_vport(vport);
3393 spin_lock_irq(shost->host_lock);
3394 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
3395 if (!NLP_CHK_NODE_ACT(ndlp))
3398 ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo;
3399 #if (IS_ENABLED(CONFIG_NVME_FC))
3400 spin_lock(&vport->phba->hbalock);
3401 rport = lpfc_ndlp_get_nrport(ndlp);
3403 remoteport = rport->remoteport;
3404 spin_unlock(&vport->phba->hbalock);
3406 nvme_fc_set_remoteport_devloss(rport->remoteport,
3407 vport->cfg_devloss_tmo);
3410 spin_unlock_irq(shost->host_lock);
3414 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
3415 * @vport: lpfc vport structure pointer.
3416 * @val: contains the tmo value.
3419 * If the devloss tmo is already set or the vport dev loss tmo has changed
3420 * then a kernel error message is printed and zero is returned.
3421 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3422 * Otherwise nodev tmo is set to the default value.
3425 * zero if already set or if val is in range
3426 * -EINVAL val out of range
3429 lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
3431 if (vport->dev_loss_tmo_changed ||
3432 (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) {
3433 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3434 "0401 Ignoring change to lpfc_nodev_tmo "
3435 "because lpfc_devloss_tmo is set.\n");
3438 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
3439 vport->cfg_nodev_tmo = val;
3440 vport->cfg_devloss_tmo = val;
3442 * For compat: set the fc_host dev loss so new rports
3443 * will get the value.
3445 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val;
3446 lpfc_update_rport_devloss_tmo(vport);
3449 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3450 "0403 lpfc_nodev_tmo attribute cannot be set to "
3451 "%d, allowed range is [%d, %d]\n",
3452 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
3456 lpfc_vport_param_store(nodev_tmo)
3458 static DEVICE_ATTR_RW(lpfc_nodev_tmo);
3461 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
3462 # disappear until the timer expires. Value range is [0,255]. Default
3465 module_param(lpfc_devloss_tmo, int, S_IRUGO);
3466 MODULE_PARM_DESC(lpfc_devloss_tmo,
3467 "Seconds driver will hold I/O waiting "
3468 "for a device to come back");
3469 lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO,
3470 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO)
3471 lpfc_vport_param_show(devloss_tmo)
3474 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
3475 * @vport: lpfc vport structure pointer.
3476 * @val: contains the tmo value.
3479 * If val is in a valid range then set the vport nodev tmo,
3480 * devloss tmo, also set the vport dev loss tmo changed flag.
3481 * Else a kernel error message is printed.
3484 * zero if val is in range
3485 * -EINVAL val out of range
3488 lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
3490 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
3491 vport->cfg_nodev_tmo = val;
3492 vport->cfg_devloss_tmo = val;
3493 vport->dev_loss_tmo_changed = 1;
3494 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val;
3495 lpfc_update_rport_devloss_tmo(vport);
3499 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3500 "0404 lpfc_devloss_tmo attribute cannot be set to "
3501 "%d, allowed range is [%d, %d]\n",
3502 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
3506 lpfc_vport_param_store(devloss_tmo)
3507 static DEVICE_ATTR_RW(lpfc_devloss_tmo);
3510 * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it
3511 * lpfc_suppress_rsp = 0 Disable
3512 * lpfc_suppress_rsp = 1 Enable (default)
3515 LPFC_ATTR_R(suppress_rsp, 1, 0, 1,
3516 "Enable suppress rsp feature is firmware supports it");
3519 * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds
3520 * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs
3521 * lpfc_nvmet_mrq = 1 use a single RQ pair
3522 * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ
3525 LPFC_ATTR_R(nvmet_mrq,
3526 LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_MAX,
3527 "Specify number of RQ pairs for processing NVMET cmds");
3530 * lpfc_nvmet_mrq_post: Specify number of RQ buffer to initially post
3531 * to each NVMET RQ. Range 64 to 2048, default is 512.
3533 LPFC_ATTR_R(nvmet_mrq_post,
3534 LPFC_NVMET_RQE_DEF_POST, LPFC_NVMET_RQE_MIN_POST,
3535 LPFC_NVMET_RQE_DEF_COUNT,
3536 "Specify number of RQ buffers to initially post");
3539 * lpfc_enable_fc4_type: Defines what FC4 types are supported.
3540 * Supported Values: 1 - register just FCP
3541 * 3 - register both FCP and NVME
3542 * Supported values are [1,3]. Default value is 1
3544 LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_FCP,
3545 LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH,
3546 "Enable FC4 Protocol support - FCP / NVME");
3549 * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME
3550 * This parameter is only used if:
3551 * lpfc_enable_fc4_type is 3 - register both FCP and NVME and
3552 * port is not configured for NVMET.
3554 * ELS/CT always get 10% of XRIs, up to a maximum of 250
3555 * The remaining XRIs get split up based on lpfc_xri_split per port:
3557 * Supported Values are in percentages
3558 * the xri_split value is the percentage the SCSI port will get. The remaining
3559 * percentage will go to NVME.
3561 LPFC_ATTR_R(xri_split, 50, 10, 90,
3562 "Percentage of FCP XRI resources versus NVME");
3565 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
3566 # deluged with LOTS of information.
3567 # You can set a bit mask to record specific types of verbose messages:
3568 # See lpfc_logmsh.h for definitions.
3570 LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff,
3571 "Verbose logging bit-mask");
3574 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
3575 # objects that have been registered with the nameserver after login.
3577 LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1,
3578 "Deregister nameserver objects before LOGO");
3581 # lun_queue_depth: This parameter is used to limit the number of outstanding
3582 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
3583 # If this parameter value is greater than 1/8th the maximum number of exchanges
3584 # supported by the HBA port, then the lun queue depth will be reduced to
3585 # 1/8th the maximum number of exchanges.
3587 LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512,
3588 "Max number of FCP commands we can queue to a specific LUN");
3591 # tgt_queue_depth: This parameter is used to limit the number of outstanding
3592 # commands per target port. Value range is [10,65535]. Default value is 65535.
3594 static uint lpfc_tgt_queue_depth = LPFC_MAX_TGT_QDEPTH;
3595 module_param(lpfc_tgt_queue_depth, uint, 0444);
3596 MODULE_PARM_DESC(lpfc_tgt_queue_depth, "Set max Target queue depth");
3597 lpfc_vport_param_show(tgt_queue_depth);
3598 lpfc_vport_param_init(tgt_queue_depth, LPFC_MAX_TGT_QDEPTH,
3599 LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH);
3602 * lpfc_tgt_queue_depth_store: Sets an attribute value.
3603 * @phba: pointer the the adapter structure.
3604 * @val: integer attribute value.
3606 * Description: Sets the parameter to the new value.
3610 * -EINVAL if val is invalid
3613 lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val)
3615 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3616 struct lpfc_nodelist *ndlp;
3618 if (!lpfc_rangecheck(val, LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH))
3621 if (val == vport->cfg_tgt_queue_depth)
3624 spin_lock_irq(shost->host_lock);
3625 vport->cfg_tgt_queue_depth = val;
3627 /* Next loop thru nodelist and change cmd_qdepth */
3628 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
3629 ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth;
3631 spin_unlock_irq(shost->host_lock);
3635 lpfc_vport_param_store(tgt_queue_depth);
3636 static DEVICE_ATTR_RW(lpfc_tgt_queue_depth);
3639 # hba_queue_depth: This parameter is used to limit the number of outstanding
3640 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
3641 # value is greater than the maximum number of exchanges supported by the HBA,
3642 # then maximum number of exchanges supported by the HBA is used to determine
3643 # the hba_queue_depth.
3645 LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
3646 "Max number of FCP commands we can queue to a lpfc HBA");
3649 # peer_port_login: This parameter allows/prevents logins
3650 # between peer ports hosted on the same physical port.
3651 # When this parameter is set 0 peer ports of same physical port
3652 # are not allowed to login to each other.
3653 # When this parameter is set 1 peer ports of same physical port
3654 # are allowed to login to each other.
3655 # Default value of this parameter is 0.
3657 LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1,
3658 "Allow peer ports on the same physical port to login to each "
3662 # restrict_login: This parameter allows/prevents logins
3663 # between Virtual Ports and remote initiators.
3664 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
3665 # other initiators and will attempt to PLOGI all remote ports.
3666 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
3667 # remote ports and will not attempt to PLOGI to other initiators.
3668 # This parameter does not restrict to the physical port.
3669 # This parameter does not restrict logins to Fabric resident remote ports.
3670 # Default value of this parameter is 1.
3672 static int lpfc_restrict_login = 1;
3673 module_param(lpfc_restrict_login, int, S_IRUGO);
3674 MODULE_PARM_DESC(lpfc_restrict_login,
3675 "Restrict virtual ports login to remote initiators.");
3676 lpfc_vport_param_show(restrict_login);
3679 * lpfc_restrict_login_init - Set the vport restrict login flag
3680 * @vport: lpfc vport structure pointer.
3681 * @val: contains the restrict login value.
3684 * If val is not in a valid range then log a kernel error message and set
3685 * the vport restrict login to one.
3686 * If the port type is physical clear the restrict login flag and return.
3687 * Else set the restrict login flag to val.
3690 * zero if val is in range
3691 * -EINVAL val out of range
3694 lpfc_restrict_login_init(struct lpfc_vport *vport, int val)
3696 if (val < 0 || val > 1) {
3697 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3698 "0422 lpfc_restrict_login attribute cannot "
3699 "be set to %d, allowed range is [0, 1]\n",
3701 vport->cfg_restrict_login = 1;
3704 if (vport->port_type == LPFC_PHYSICAL_PORT) {
3705 vport->cfg_restrict_login = 0;
3708 vport->cfg_restrict_login = val;
3713 * lpfc_restrict_login_set - Set the vport restrict login flag
3714 * @vport: lpfc vport structure pointer.
3715 * @val: contains the restrict login value.
3718 * If val is not in a valid range then log a kernel error message and set
3719 * the vport restrict login to one.
3720 * If the port type is physical and the val is not zero log a kernel
3721 * error message, clear the restrict login flag and return zero.
3722 * Else set the restrict login flag to val.
3725 * zero if val is in range
3726 * -EINVAL val out of range
3729 lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
3731 if (val < 0 || val > 1) {
3732 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3733 "0425 lpfc_restrict_login attribute cannot "
3734 "be set to %d, allowed range is [0, 1]\n",
3736 vport->cfg_restrict_login = 1;
3739 if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) {
3740 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3741 "0468 lpfc_restrict_login must be 0 for "
3742 "Physical ports.\n");
3743 vport->cfg_restrict_login = 0;
3746 vport->cfg_restrict_login = val;
3749 lpfc_vport_param_store(restrict_login);
3750 static DEVICE_ATTR_RW(lpfc_restrict_login);
3753 # Some disk devices have a "select ID" or "select Target" capability.
3754 # From a protocol standpoint "select ID" usually means select the
3755 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
3756 # annex" which contains a table that maps a "select ID" (a number
3757 # between 0 and 7F) to an ALPA. By default, for compatibility with
3758 # older drivers, the lpfc driver scans this table from low ALPA to high
3761 # Turning on the scan-down variable (on = 1, off = 0) will
3762 # cause the lpfc driver to use an inverted table, effectively
3763 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
3765 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
3766 # and will not work across a fabric. Also this parameter will take
3767 # effect only in the case when ALPA map is not available.)
3769 LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1,
3770 "Start scanning for devices from highest ALPA to lowest");
3773 # lpfc_topology: link topology for init link
3774 # 0x0 = attempt loop mode then point-to-point
3775 # 0x01 = internal loopback mode
3776 # 0x02 = attempt point-to-point mode only
3777 # 0x04 = attempt loop mode only
3778 # 0x06 = attempt point-to-point mode then loop
3779 # Set point-to-point mode if you want to run as an N_Port.
3780 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
3781 # Default value is 0.
3783 LPFC_ATTR(topology, 0, 0, 6,
3784 "Select Fibre Channel topology");
3787 * lpfc_topology_set - Set the adapters topology field
3788 * @phba: lpfc_hba pointer.
3789 * @val: topology value.
3792 * If val is in a valid range then set the adapter's topology field and
3793 * issue a lip; if the lip fails reset the topology to the old value.
3795 * If the value is not in range log a kernel error message and return an error.
3798 * zero if val is in range and lip okay
3799 * non-zero return value from lpfc_issue_lip()
3800 * -EINVAL val out of range
3803 lpfc_topology_store(struct device *dev, struct device_attribute *attr,
3804 const char *buf, size_t count)
3806 struct Scsi_Host *shost = class_to_shost(dev);
3807 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3808 struct lpfc_hba *phba = vport->phba;
3811 const char *val_buf = buf;
3815 if (!strncmp(buf, "nolip ", strlen("nolip "))) {
3817 val_buf = &buf[strlen("nolip ")];
3820 if (!isdigit(val_buf[0]))
3822 if (sscanf(val_buf, "%i", &val) != 1)
3825 if (val >= 0 && val <= 6) {
3826 prev_val = phba->cfg_topology;
3827 if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G &&
3829 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3830 "3113 Loop mode not supported at speed %d\n",
3834 if (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC &&
3836 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3837 "3114 Loop mode not supported\n");
3840 phba->cfg_topology = val;
3844 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3845 "3054 lpfc_topology changed from %d to %d\n",
3847 if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4)
3848 phba->fc_topology_changed = 1;
3849 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
3851 phba->cfg_topology = prev_val;
3856 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3857 "%d:0467 lpfc_topology attribute cannot be set to %d, "
3858 "allowed range is [0, 6]\n",
3863 lpfc_param_show(topology)
3864 static DEVICE_ATTR_RW(lpfc_topology);
3867 * lpfc_static_vport_show: Read callback function for
3868 * lpfc_static_vport sysfs file.
3869 * @dev: Pointer to class device object.
3870 * @attr: device attribute structure.
3871 * @buf: Data buffer.
3873 * This function is the read call back function for
3874 * lpfc_static_vport sysfs file. The lpfc_static_vport
3875 * sysfs file report the mageability of the vport.
3878 lpfc_static_vport_show(struct device *dev, struct device_attribute *attr,
3881 struct Scsi_Host *shost = class_to_shost(dev);
3882 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3883 if (vport->vport_flag & STATIC_VPORT)
3884 sprintf(buf, "1\n");
3886 sprintf(buf, "0\n");
3892 * Sysfs attribute to control the statistical data collection.
3894 static DEVICE_ATTR_RO(lpfc_static_vport);
3897 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
3898 * @dev: Pointer to class device.
3899 * @buf: Data buffer.
3900 * @count: Size of the data buffer.
3902 * This function get called when a user write to the lpfc_stat_data_ctrl
3903 * sysfs file. This function parse the command written to the sysfs file
3904 * and take appropriate action. These commands are used for controlling
3905 * driver statistical data collection.
3906 * Following are the command this function handles.
3908 * setbucket <bucket_type> <base> <step>
3909 * = Set the latency buckets.
3910 * destroybucket = destroy all the buckets.
3911 * start = start data collection
3912 * stop = stop data collection
3913 * reset = reset the collected data
3916 lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr,
3917 const char *buf, size_t count)
3919 struct Scsi_Host *shost = class_to_shost(dev);
3920 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3921 struct lpfc_hba *phba = vport->phba;
3922 #define LPFC_MAX_DATA_CTRL_LEN 1024
3923 static char bucket_data[LPFC_MAX_DATA_CTRL_LEN];
3925 char *str_ptr, *token;
3926 struct lpfc_vport **vports;
3927 struct Scsi_Host *v_shost;
3928 char *bucket_type_str, *base_str, *step_str;
3929 unsigned long base, step, bucket_type;
3931 if (!strncmp(buf, "setbucket", strlen("setbucket"))) {
3932 if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1))
3935 strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN);
3936 str_ptr = &bucket_data[0];
3937 /* Ignore this token - this is command token */
3938 token = strsep(&str_ptr, "\t ");
3942 bucket_type_str = strsep(&str_ptr, "\t ");
3943 if (!bucket_type_str)
3946 if (!strncmp(bucket_type_str, "linear", strlen("linear")))
3947 bucket_type = LPFC_LINEAR_BUCKET;
3948 else if (!strncmp(bucket_type_str, "power2", strlen("power2")))
3949 bucket_type = LPFC_POWER2_BUCKET;
3953 base_str = strsep(&str_ptr, "\t ");
3956 base = simple_strtoul(base_str, NULL, 0);
3958 step_str = strsep(&str_ptr, "\t ");
3961 step = simple_strtoul(step_str, NULL, 0);
3965 /* Block the data collection for every vport */
3966 vports = lpfc_create_vport_work_array(phba);
3970 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
3971 v_shost = lpfc_shost_from_vport(vports[i]);
3972 spin_lock_irq(v_shost->host_lock);
3973 /* Block and reset data collection */
3974 vports[i]->stat_data_blocked = 1;
3975 if (vports[i]->stat_data_enabled)
3976 lpfc_vport_reset_stat_data(vports[i]);
3977 spin_unlock_irq(v_shost->host_lock);
3980 /* Set the bucket attributes */
3981 phba->bucket_type = bucket_type;
3982 phba->bucket_base = base;
3983 phba->bucket_step = step;
3985 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
3986 v_shost = lpfc_shost_from_vport(vports[i]);
3988 /* Unblock data collection */
3989 spin_lock_irq(v_shost->host_lock);
3990 vports[i]->stat_data_blocked = 0;
3991 spin_unlock_irq(v_shost->host_lock);
3993 lpfc_destroy_vport_work_array(phba, vports);
3997 if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) {
3998 vports = lpfc_create_vport_work_array(phba);
4002 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
4003 v_shost = lpfc_shost_from_vport(vports[i]);
4004 spin_lock_irq(shost->host_lock);
4005 vports[i]->stat_data_blocked = 1;
4006 lpfc_free_bucket(vport);
4007 vport->stat_data_enabled = 0;
4008 vports[i]->stat_data_blocked = 0;
4009 spin_unlock_irq(shost->host_lock);
4011 lpfc_destroy_vport_work_array(phba, vports);
4012 phba->bucket_type = LPFC_NO_BUCKET;
4013 phba->bucket_base = 0;
4014 phba->bucket_step = 0;
4018 if (!strncmp(buf, "start", strlen("start"))) {
4019 /* If no buckets configured return error */
4020 if (phba->bucket_type == LPFC_NO_BUCKET)
4022 spin_lock_irq(shost->host_lock);
4023 if (vport->stat_data_enabled) {
4024 spin_unlock_irq(shost->host_lock);
4027 lpfc_alloc_bucket(vport);
4028 vport->stat_data_enabled = 1;
4029 spin_unlock_irq(shost->host_lock);
4033 if (!strncmp(buf, "stop", strlen("stop"))) {
4034 spin_lock_irq(shost->host_lock);
4035 if (vport->stat_data_enabled == 0) {
4036 spin_unlock_irq(shost->host_lock);
4039 lpfc_free_bucket(vport);
4040 vport->stat_data_enabled = 0;
4041 spin_unlock_irq(shost->host_lock);
4045 if (!strncmp(buf, "reset", strlen("reset"))) {
4046 if ((phba->bucket_type == LPFC_NO_BUCKET)
4047 || !vport->stat_data_enabled)
4049 spin_lock_irq(shost->host_lock);
4050 vport->stat_data_blocked = 1;
4051 lpfc_vport_reset_stat_data(vport);
4052 vport->stat_data_blocked = 0;
4053 spin_unlock_irq(shost->host_lock);
4061 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
4062 * @dev: Pointer to class device object.
4063 * @buf: Data buffer.
4065 * This function is the read call back function for
4066 * lpfc_stat_data_ctrl sysfs file. This function report the
4067 * current statistical data collection state.
4070 lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr,
4073 struct Scsi_Host *shost = class_to_shost(dev);
4074 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4075 struct lpfc_hba *phba = vport->phba;
4079 unsigned long bucket_value;
4081 switch (phba->bucket_type) {
4082 case LPFC_LINEAR_BUCKET:
4083 bucket_type = "linear";
4085 case LPFC_POWER2_BUCKET:
4086 bucket_type = "power2";
4089 bucket_type = "No Bucket";
4093 sprintf(&buf[index], "Statistical Data enabled :%d, "
4094 "blocked :%d, Bucket type :%s, Bucket base :%d,"
4095 " Bucket step :%d\nLatency Ranges :",
4096 vport->stat_data_enabled, vport->stat_data_blocked,
4097 bucket_type, phba->bucket_base, phba->bucket_step);
4098 index = strlen(buf);
4099 if (phba->bucket_type != LPFC_NO_BUCKET) {
4100 for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) {
4101 if (phba->bucket_type == LPFC_LINEAR_BUCKET)
4102 bucket_value = phba->bucket_base +
4103 phba->bucket_step * i;
4105 bucket_value = phba->bucket_base +
4106 (1 << i) * phba->bucket_step;
4108 if (index + 10 > PAGE_SIZE)
4110 sprintf(&buf[index], "%08ld ", bucket_value);
4111 index = strlen(buf);
4114 sprintf(&buf[index], "\n");
4119 * Sysfs attribute to control the statistical data collection.
4121 static DEVICE_ATTR_RW(lpfc_stat_data_ctrl);
4124 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
4128 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
4131 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
4132 #define MAX_STAT_DATA_SIZE_PER_TARGET \
4133 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
4137 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
4139 * @kobj: Pointer to the kernel object
4140 * @bin_attr: Attribute object
4141 * @buff: Buffer pointer
4143 * @count: Buffer size
4145 * This function is the read call back function for lpfc_drvr_stat_data
4146 * sysfs file. This function export the statistical data to user
4150 sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj,
4151 struct bin_attribute *bin_attr,
4152 char *buf, loff_t off, size_t count)
4154 struct device *dev = container_of(kobj, struct device,
4156 struct Scsi_Host *shost = class_to_shost(dev);
4157 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4158 struct lpfc_hba *phba = vport->phba;
4159 int i = 0, index = 0;
4160 unsigned long nport_index;
4161 struct lpfc_nodelist *ndlp = NULL;
4162 nport_index = (unsigned long)off /
4163 MAX_STAT_DATA_SIZE_PER_TARGET;
4165 if (!vport->stat_data_enabled || vport->stat_data_blocked
4166 || (phba->bucket_type == LPFC_NO_BUCKET))
4169 spin_lock_irq(shost->host_lock);
4170 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
4171 if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data)
4174 if (nport_index > 0) {
4179 if ((index + MAX_STAT_DATA_SIZE_PER_TARGET)
4183 if (!ndlp->lat_data)
4187 sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:",
4188 ndlp->nlp_portname.u.wwn[0],
4189 ndlp->nlp_portname.u.wwn[1],
4190 ndlp->nlp_portname.u.wwn[2],
4191 ndlp->nlp_portname.u.wwn[3],
4192 ndlp->nlp_portname.u.wwn[4],
4193 ndlp->nlp_portname.u.wwn[5],
4194 ndlp->nlp_portname.u.wwn[6],
4195 ndlp->nlp_portname.u.wwn[7]);
4197 index = strlen(buf);
4199 for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) {
4200 sprintf(&buf[index], "%010u,",
4201 ndlp->lat_data[i].cmd_count);
4202 index = strlen(buf);
4204 sprintf(&buf[index], "\n");
4205 index = strlen(buf);
4207 spin_unlock_irq(shost->host_lock);
4211 static struct bin_attribute sysfs_drvr_stat_data_attr = {
4213 .name = "lpfc_drvr_stat_data",
4216 .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET,
4217 .read = sysfs_drvr_stat_data_read,
4222 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
4224 # Value range is [0,16]. Default value is 0.
4227 * lpfc_link_speed_set - Set the adapters link speed
4228 * @phba: lpfc_hba pointer.
4229 * @val: link speed value.
4232 * If val is in a valid range then set the adapter's link speed field and
4233 * issue a lip; if the lip fails reset the link speed to the old value.
4236 * If the value is not in range log a kernel error message and return an error.
4239 * zero if val is in range and lip okay.
4240 * non-zero return value from lpfc_issue_lip()
4241 * -EINVAL val out of range
4244 lpfc_link_speed_store(struct device *dev, struct device_attribute *attr,
4245 const char *buf, size_t count)
4247 struct Scsi_Host *shost = class_to_shost(dev);
4248 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4249 struct lpfc_hba *phba = vport->phba;
4250 int val = LPFC_USER_LINK_SPEED_AUTO;
4252 const char *val_buf = buf;
4254 uint32_t prev_val, if_type;
4256 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf);
4257 if (if_type == LPFC_SLI_INTF_IF_TYPE_2 &&
4258 phba->hba_flag & HBA_FORCED_LINK_SPEED)
4261 if (!strncmp(buf, "nolip ", strlen("nolip "))) {
4263 val_buf = &buf[strlen("nolip ")];
4266 if (!isdigit(val_buf[0]))
4268 if (sscanf(val_buf, "%i", &val) != 1)
4271 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
4272 "3055 lpfc_link_speed changed from %d to %d %s\n",
4273 phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)");
4275 if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) ||
4276 ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) ||
4277 ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) ||
4278 ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) ||
4279 ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) ||
4280 ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) ||
4281 ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb)) ||
4282 ((val == LPFC_USER_LINK_SPEED_64G) && !(phba->lmt & LMT_64Gb))) {
4283 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4284 "2879 lpfc_link_speed attribute cannot be set "
4285 "to %d. Speed is not supported by this port.\n",
4289 if (val >= LPFC_USER_LINK_SPEED_16G &&
4290 phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
4291 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4292 "3112 lpfc_link_speed attribute cannot be set "
4293 "to %d. Speed is not supported in loop mode.\n",
4299 case LPFC_USER_LINK_SPEED_AUTO:
4300 case LPFC_USER_LINK_SPEED_1G:
4301 case LPFC_USER_LINK_SPEED_2G:
4302 case LPFC_USER_LINK_SPEED_4G:
4303 case LPFC_USER_LINK_SPEED_8G:
4304 case LPFC_USER_LINK_SPEED_16G:
4305 case LPFC_USER_LINK_SPEED_32G:
4306 case LPFC_USER_LINK_SPEED_64G:
4307 prev_val = phba->cfg_link_speed;
4308 phba->cfg_link_speed = val;
4312 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
4314 phba->cfg_link_speed = prev_val;
4322 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4323 "0469 lpfc_link_speed attribute cannot be set to %d, "
4324 "allowed values are [%s]\n",
4325 val, LPFC_LINK_SPEED_STRING);
4330 static int lpfc_link_speed = 0;
4331 module_param(lpfc_link_speed, int, S_IRUGO);
4332 MODULE_PARM_DESC(lpfc_link_speed, "Select link speed");
4333 lpfc_param_show(link_speed)
4336 * lpfc_link_speed_init - Set the adapters link speed
4337 * @phba: lpfc_hba pointer.
4338 * @val: link speed value.
4341 * If val is in a valid range then set the adapter's link speed field.
4344 * If the value is not in range log a kernel error message, clear the link
4345 * speed and return an error.
4348 * zero if val saved.
4349 * -EINVAL val out of range
4352 lpfc_link_speed_init(struct lpfc_hba *phba, int val)
4354 if (val >= LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) {
4355 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4356 "3111 lpfc_link_speed of %d cannot "
4357 "support loop mode, setting topology to default.\n",
4359 phba->cfg_topology = 0;
4363 case LPFC_USER_LINK_SPEED_AUTO:
4364 case LPFC_USER_LINK_SPEED_1G:
4365 case LPFC_USER_LINK_SPEED_2G:
4366 case LPFC_USER_LINK_SPEED_4G:
4367 case LPFC_USER_LINK_SPEED_8G:
4368 case LPFC_USER_LINK_SPEED_16G:
4369 case LPFC_USER_LINK_SPEED_32G:
4370 case LPFC_USER_LINK_SPEED_64G:
4371 phba->cfg_link_speed = val;
4374 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4375 "0405 lpfc_link_speed attribute cannot "
4376 "be set to %d, allowed values are "
4377 "["LPFC_LINK_SPEED_STRING"]\n", val);
4378 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO;
4383 static DEVICE_ATTR_RW(lpfc_link_speed);
4386 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
4387 # 0 = aer disabled or not supported
4388 # 1 = aer supported and enabled (default)
4389 # Value range is [0,1]. Default value is 1.
4391 LPFC_ATTR(aer_support, 1, 0, 1,
4392 "Enable PCIe device AER support");
4393 lpfc_param_show(aer_support)
4396 * lpfc_aer_support_store - Set the adapter for aer support
4398 * @dev: class device that is converted into a Scsi_host.
4399 * @attr: device attribute, not used.
4400 * @buf: containing enable or disable aer flag.
4401 * @count: unused variable.
4404 * If the val is 1 and currently the device's AER capability was not
4405 * enabled, invoke the kernel's enable AER helper routine, trying to
4406 * enable the device's AER capability. If the helper routine enabling
4407 * AER returns success, update the device's cfg_aer_support flag to
4408 * indicate AER is supported by the device; otherwise, if the device
4409 * AER capability is already enabled to support AER, then do nothing.
4411 * If the val is 0 and currently the device's AER support was enabled,
4412 * invoke the kernel's disable AER helper routine. After that, update
4413 * the device's cfg_aer_support flag to indicate AER is not supported
4414 * by the device; otherwise, if the device AER capability is already
4415 * disabled from supporting AER, then do nothing.
4418 * length of the buf on success if val is in range the intended mode
4420 * -EINVAL if val out of range or intended mode is not supported.
4423 lpfc_aer_support_store(struct device *dev, struct device_attribute *attr,
4424 const char *buf, size_t count)
4426 struct Scsi_Host *shost = class_to_shost(dev);
4427 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4428 struct lpfc_hba *phba = vport->phba;
4429 int val = 0, rc = -EINVAL;
4431 if (!isdigit(buf[0]))
4433 if (sscanf(buf, "%i", &val) != 1)
4438 if (phba->hba_flag & HBA_AER_ENABLED) {
4439 rc = pci_disable_pcie_error_reporting(phba->pcidev);
4441 spin_lock_irq(&phba->hbalock);
4442 phba->hba_flag &= ~HBA_AER_ENABLED;
4443 spin_unlock_irq(&phba->hbalock);
4444 phba->cfg_aer_support = 0;
4449 phba->cfg_aer_support = 0;
4454 if (!(phba->hba_flag & HBA_AER_ENABLED)) {
4455 rc = pci_enable_pcie_error_reporting(phba->pcidev);
4457 spin_lock_irq(&phba->hbalock);
4458 phba->hba_flag |= HBA_AER_ENABLED;
4459 spin_unlock_irq(&phba->hbalock);
4460 phba->cfg_aer_support = 1;
4465 phba->cfg_aer_support = 1;
4476 static DEVICE_ATTR_RW(lpfc_aer_support);
4479 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
4480 * @dev: class device that is converted into a Scsi_host.
4481 * @attr: device attribute, not used.
4482 * @buf: containing flag 1 for aer cleanup state.
4483 * @count: unused variable.
4486 * If the @buf contains 1 and the device currently has the AER support
4487 * enabled, then invokes the kernel AER helper routine
4488 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
4489 * error status register.
4494 * -EINVAL if the buf does not contain the 1 or the device is not currently
4495 * enabled with the AER support.
4498 lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr,
4499 const char *buf, size_t count)
4501 struct Scsi_Host *shost = class_to_shost(dev);
4502 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4503 struct lpfc_hba *phba = vport->phba;
4506 if (!isdigit(buf[0]))
4508 if (sscanf(buf, "%i", &val) != 1)
4513 if (phba->hba_flag & HBA_AER_ENABLED)
4514 rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev);
4522 static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL,
4523 lpfc_aer_cleanup_state);
4526 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
4528 * @dev: class device that is converted into a Scsi_host.
4529 * @attr: device attribute, not used.
4530 * @buf: containing the string the number of vfs to be enabled.
4531 * @count: unused variable.
4534 * When this api is called either through user sysfs, the driver shall
4535 * try to enable or disable SR-IOV virtual functions according to the
4538 * If zero virtual function has been enabled to the physical function,
4539 * the driver shall invoke the pci enable virtual function api trying
4540 * to enable the virtual functions. If the nr_vfn provided is greater
4541 * than the maximum supported, the maximum virtual function number will
4542 * be used for invoking the api; otherwise, the nr_vfn provided shall
4543 * be used for invoking the api. If the api call returned success, the
4544 * actual number of virtual functions enabled will be set to the driver
4545 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
4546 * cfg_sriov_nr_virtfn remains zero.
4548 * If none-zero virtual functions have already been enabled to the
4549 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
4550 * -EINVAL will be returned and the driver does nothing;
4552 * If the nr_vfn provided is zero and none-zero virtual functions have
4553 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
4554 * disabling virtual function api shall be invoded to disable all the
4555 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
4556 * zero. Otherwise, if zero virtual function has been enabled, do
4560 * length of the buf on success if val is in range the intended mode
4562 * -EINVAL if val out of range or intended mode is not supported.
4565 lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr,
4566 const char *buf, size_t count)
4568 struct Scsi_Host *shost = class_to_shost(dev);
4569 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4570 struct lpfc_hba *phba = vport->phba;
4571 struct pci_dev *pdev = phba->pcidev;
4572 int val = 0, rc = -EINVAL;
4574 /* Sanity check on user data */
4575 if (!isdigit(buf[0]))
4577 if (sscanf(buf, "%i", &val) != 1)
4582 /* Request disabling virtual functions */
4584 if (phba->cfg_sriov_nr_virtfn > 0) {
4585 pci_disable_sriov(pdev);
4586 phba->cfg_sriov_nr_virtfn = 0;
4591 /* Request enabling virtual functions */
4592 if (phba->cfg_sriov_nr_virtfn > 0) {
4593 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4594 "3018 There are %d virtual functions "
4595 "enabled on physical function.\n",
4596 phba->cfg_sriov_nr_virtfn);
4600 if (val <= LPFC_MAX_VFN_PER_PFN)
4601 phba->cfg_sriov_nr_virtfn = val;
4603 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4604 "3019 Enabling %d virtual functions is not "
4609 rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn);
4611 phba->cfg_sriov_nr_virtfn = 0;
4619 LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN,
4620 "Enable PCIe device SR-IOV virtual fn");
4622 lpfc_param_show(sriov_nr_virtfn)
4623 static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn);
4626 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
4628 * @dev: class device that is converted into a Scsi_host.
4629 * @attr: device attribute, not used.
4630 * @buf: containing the string the number of vfs to be enabled.
4631 * @count: unused variable.
4636 * length of the buf on success if val is in range the intended mode
4638 * -EINVAL if val out of range or intended mode is not supported.
4641 lpfc_request_firmware_upgrade_store(struct device *dev,
4642 struct device_attribute *attr,
4643 const char *buf, size_t count)
4645 struct Scsi_Host *shost = class_to_shost(dev);
4646 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4647 struct lpfc_hba *phba = vport->phba;
4648 int val = 0, rc = -EINVAL;
4650 /* Sanity check on user data */
4651 if (!isdigit(buf[0]))
4653 if (sscanf(buf, "%i", &val) != 1)
4658 rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE);
4666 static int lpfc_req_fw_upgrade;
4667 module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR);
4668 MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade");
4669 lpfc_param_show(request_firmware_upgrade)
4672 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
4673 * @phba: lpfc_hba pointer.
4677 * Set the initial Linux generic firmware upgrade enable or disable flag.
4680 * zero if val saved.
4681 * -EINVAL val out of range
4684 lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val)
4686 if (val >= 0 && val <= 1) {
4687 phba->cfg_request_firmware_upgrade = val;
4692 static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR,
4693 lpfc_request_firmware_upgrade_show,
4694 lpfc_request_firmware_upgrade_store);
4697 * lpfc_fcp_imax_store
4699 * @dev: class device that is converted into a Scsi_host.
4700 * @attr: device attribute, not used.
4701 * @buf: string with the number of fast-path FCP interrupts per second.
4702 * @count: unused variable.
4705 * If val is in a valid range [636,651042], then set the adapter's
4706 * maximum number of fast-path FCP interrupts per second.
4709 * length of the buf on success if val is in range the intended mode
4711 * -EINVAL if val out of range or intended mode is not supported.
4714 lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr,
4715 const char *buf, size_t count)
4717 struct Scsi_Host *shost = class_to_shost(dev);
4718 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4719 struct lpfc_hba *phba = vport->phba;
4722 /* fcp_imax is only valid for SLI4 */
4723 if (phba->sli_rev != LPFC_SLI_REV4)
4726 /* Sanity check on user data */
4727 if (!isdigit(buf[0]))
4729 if (sscanf(buf, "%i", &val) != 1)
4733 * Value range for the HBA is [5000,5000000]
4734 * The value for each EQ depends on how many EQs are configured.
4737 if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX))
4740 phba->cfg_fcp_imax = (uint32_t)val;
4741 phba->initial_imax = phba->cfg_fcp_imax;
4743 for (i = 0; i < phba->io_channel_irqs; i += LPFC_MAX_EQ_DELAY_EQID_CNT)
4744 lpfc_modify_hba_eq_delay(phba, i, LPFC_MAX_EQ_DELAY_EQID_CNT,
4751 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
4754 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
4756 static int lpfc_fcp_imax = LPFC_DEF_IMAX;
4757 module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR);
4758 MODULE_PARM_DESC(lpfc_fcp_imax,
4759 "Set the maximum number of FCP interrupts per second per HBA");
4760 lpfc_param_show(fcp_imax)
4763 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
4764 * @phba: lpfc_hba pointer.
4765 * @val: link speed value.
4768 * If val is in a valid range [636,651042], then initialize the adapter's
4769 * maximum number of fast-path FCP interrupts per second.
4772 * zero if val saved.
4773 * -EINVAL val out of range
4776 lpfc_fcp_imax_init(struct lpfc_hba *phba, int val)
4778 if (phba->sli_rev != LPFC_SLI_REV4) {
4779 phba->cfg_fcp_imax = 0;
4783 if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) ||
4785 phba->cfg_fcp_imax = val;
4789 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4790 "3016 lpfc_fcp_imax: %d out of range, using default\n",
4792 phba->cfg_fcp_imax = LPFC_DEF_IMAX;
4797 static DEVICE_ATTR_RW(lpfc_fcp_imax);
4800 * lpfc_auto_imax: Controls Auto-interrupt coalescing values support.
4801 * 0 No auto_imax support
4803 * Auto imax will change the value of fcp_imax on a per EQ basis, using
4804 * the EQ Delay Multiplier, depending on the activity for that EQ.
4805 * Value range [0,1]. Default value is 1.
4807 LPFC_ATTR_RW(auto_imax, 1, 0, 1, "Enable Auto imax");
4810 * lpfc_state_show - Display current driver CPU affinity
4811 * @dev: class converted to a Scsi_host structure.
4812 * @attr: device attribute, not used.
4813 * @buf: on return contains text describing the state of the link.
4815 * Returns: size of formatted string.
4818 lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr,
4821 struct Scsi_Host *shost = class_to_shost(dev);
4822 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4823 struct lpfc_hba *phba = vport->phba;
4824 struct lpfc_vector_map_info *cpup;
4827 if ((phba->sli_rev != LPFC_SLI_REV4) ||
4828 (phba->intr_type != MSIX))
4831 switch (phba->cfg_fcp_cpu_map) {
4833 len += snprintf(buf + len, PAGE_SIZE-len,
4834 "fcp_cpu_map: No mapping (%d)\n",
4835 phba->cfg_fcp_cpu_map);
4838 len += snprintf(buf + len, PAGE_SIZE-len,
4839 "fcp_cpu_map: HBA centric mapping (%d): "
4841 phba->cfg_fcp_cpu_map,
4842 phba->sli4_hba.num_online_cpu);
4845 len += snprintf(buf + len, PAGE_SIZE-len,
4846 "fcp_cpu_map: Driver centric mapping (%d): "
4848 phba->cfg_fcp_cpu_map,
4849 phba->sli4_hba.num_online_cpu);
4853 while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) {
4854 cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu];
4856 /* margin should fit in this and the truncated message */
4857 if (cpup->irq == LPFC_VECTOR_MAP_EMPTY)
4858 len += snprintf(buf + len, PAGE_SIZE-len,
4859 "CPU %02d io_chan %02d "
4860 "physid %d coreid %d\n",
4861 phba->sli4_hba.curr_disp_cpu,
4862 cpup->channel_id, cpup->phys_id,
4865 len += snprintf(buf + len, PAGE_SIZE-len,
4866 "CPU %02d io_chan %02d "
4867 "physid %d coreid %d IRQ %d\n",
4868 phba->sli4_hba.curr_disp_cpu,
4869 cpup->channel_id, cpup->phys_id,
4870 cpup->core_id, cpup->irq);
4872 phba->sli4_hba.curr_disp_cpu++;
4874 /* display max number of CPUs keeping some margin */
4875 if (phba->sli4_hba.curr_disp_cpu <
4876 phba->sli4_hba.num_present_cpu &&
4877 (len >= (PAGE_SIZE - 64))) {
4878 len += snprintf(buf + len, PAGE_SIZE-len, "more...\n");
4883 if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu)
4884 phba->sli4_hba.curr_disp_cpu = 0;
4890 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
4891 * @dev: class device that is converted into a Scsi_host.
4892 * @attr: device attribute, not used.
4893 * @buf: one or more lpfc_polling_flags values.
4897 * -EINVAL - Not implemented yet.
4900 lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr,
4901 const char *buf, size_t count)
4903 int status = -EINVAL;
4908 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
4911 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
4912 # 0 - Do not affinitze IRQ vectors
4913 # 1 - Affintize HBA vectors with respect to each HBA
4914 # (start with CPU0 for each HBA)
4915 # 2 - Affintize HBA vectors with respect to the entire driver
4916 # (round robin thru all CPUs across all HBAs)
4918 static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP;
4919 module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR);
4920 MODULE_PARM_DESC(lpfc_fcp_cpu_map,
4921 "Defines how to map CPUs to IRQ vectors per HBA");
4924 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
4925 * @phba: lpfc_hba pointer.
4926 * @val: link speed value.
4929 * If val is in a valid range [0-2], then affinitze the adapter's
4933 * zero if val saved.
4934 * -EINVAL val out of range
4937 lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val)
4939 if (phba->sli_rev != LPFC_SLI_REV4) {
4940 phba->cfg_fcp_cpu_map = 0;
4944 if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) {
4945 phba->cfg_fcp_cpu_map = val;
4949 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4950 "3326 lpfc_fcp_cpu_map: %d out of range, using "
4952 phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP;
4957 static DEVICE_ATTR_RW(lpfc_fcp_cpu_map);
4960 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
4961 # Value range is [2,3]. Default value is 3.
4963 LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
4964 "Select Fibre Channel class of service for FCP sequences");
4967 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
4968 # is [0,1]. Default value is 0.
4970 LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
4971 "Use ADISC on rediscovery to authenticate FCP devices");
4974 # lpfc_first_burst_size: First burst size to use on the NPorts
4975 # that support first burst.
4976 # Value range is [0,65536]. Default value is 0.
4978 LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536,
4979 "First burst size for Targets that support first burst");
4982 * lpfc_nvmet_fb_size: NVME Target mode supported first burst size.
4983 * When the driver is configured as an NVME target, this value is
4984 * communicated to the NVME initiator in the PRLI response. It is
4985 * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support
4986 * parameters are set and the target is sending the PRLI RSP.
4987 * Parameter supported on physical port only - no NPIV support.
4988 * Value range is [0,65536]. Default value is 0.
4990 LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536,
4991 "NVME Target mode first burst size in 512B increments.");
4994 * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
4995 * For the Initiator (I), enabling this parameter means that an NVMET
4996 * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be
4997 * processed by the initiator for subsequent NVME FCP IO. For the target
4998 * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size
4999 * driver parameter as the target function's first burst size returned to the
5000 * initiator in the target's NVME PRLI response. Parameter supported on physical
5001 * port only - no NPIV support.
5002 * Value range is [0,1]. Default value is 0 (disabled).
5004 LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1,
5005 "Enable First Burst feature on I and T functions.");
5008 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
5009 # depth. Default value is 0. When the value of this parameter is zero the
5010 # SCSI command completion time is not used for controlling I/O queue depth. When
5011 # the parameter is set to a non-zero value, the I/O queue depth is controlled
5012 # to limit the I/O completion time to the parameter value.
5013 # The value is set in milliseconds.
5015 LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000,
5016 "Use command completion time to control queue depth");
5018 lpfc_vport_param_show(max_scsicmpl_time);
5020 lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val)
5022 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5023 struct lpfc_nodelist *ndlp, *next_ndlp;
5025 if (val == vport->cfg_max_scsicmpl_time)
5027 if ((val < 0) || (val > 60000))
5029 vport->cfg_max_scsicmpl_time = val;
5031 spin_lock_irq(shost->host_lock);
5032 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
5033 if (!NLP_CHK_NODE_ACT(ndlp))
5035 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
5037 ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth;
5039 spin_unlock_irq(shost->host_lock);
5042 lpfc_vport_param_store(max_scsicmpl_time);
5043 static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time);
5046 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
5047 # range is [0,1]. Default value is 0.
5049 LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");
5052 * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds
5053 * range is [0,1]. Default value is 0.
5054 * For [0], FCP commands are issued to Work Queues ina round robin fashion.
5055 * For [1], FCP commands are issued to a Work Queue associated with the
5058 * LPFC_FCP_SCHED_ROUND_ROBIN == 0
5059 * LPFC_FCP_SCHED_BY_CPU == 1
5061 * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu
5062 * affinity for FCP/NVME I/Os through Work Queues associated with the current
5063 * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os
5064 * through WQs will be used.
5066 LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_ROUND_ROBIN,
5067 LPFC_FCP_SCHED_ROUND_ROBIN,
5068 LPFC_FCP_SCHED_BY_CPU,
5069 "Determine scheduling algorithm for "
5070 "issuing commands [0] - Round Robin, [1] - Current CPU");
5073 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
5074 # range is [0,1]. Default value is 0.
5075 # For [0], bus reset issues target reset to ALL devices
5076 # For [1], bus reset issues target reset to non-FCP2 devices
5078 LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for "
5079 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
5083 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
5084 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
5085 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
5086 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
5087 # cr_delay is set to 0.
5089 LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an "
5090 "interrupt response is generated");
5092 LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an "
5093 "interrupt response is generated");
5096 # lpfc_multi_ring_support: Determines how many rings to spread available
5097 # cmd/rsp IOCB entries across.
5098 # Value range is [1,2]. Default value is 1.
5100 LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
5101 "SLI rings to spread IOCB entries across");
5104 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
5105 # identifies what rctl value to configure the additional ring for.
5106 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
5108 LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1,
5109 255, "Identifies RCTL for additional ring configuration");
5112 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
5113 # identifies what type value to configure the additional ring for.
5114 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
5116 LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1,
5117 255, "Identifies TYPE for additional ring configuration");
5120 # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN
5121 # 0 = SmartSAN functionality disabled (default)
5122 # 1 = SmartSAN functionality enabled
5123 # This parameter will override the value of lpfc_fdmi_on module parameter.
5124 # Value range is [0,1]. Default value is 0.
5126 LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality");
5129 # lpfc_fdmi_on: Controls FDMI support.
5131 # 1 Traditional FDMI support (default)
5132 # Traditional FDMI support means the driver will assume FDMI-2 support;
5133 # however, if that fails, it will fallback to FDMI-1.
5134 # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on.
5135 # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of
5137 # Value range [0,1]. Default value is 1.
5139 LPFC_ATTR_R(fdmi_on, 1, 0, 1, "Enable FDMI support");
5142 # Specifies the maximum number of ELS cmds we can have outstanding (for
5143 # discovery). Value range is [1,64]. Default value = 32.
5145 LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
5146 "during discovery");
5149 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
5150 # will be scanned by the SCSI midlayer when sequential scanning is
5151 # used; and is also the highest LUN ID allowed when the SCSI midlayer
5152 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
5153 # LUN ID limit, but the SCSI midlayer requires this field for the uses
5154 # above. The lpfc driver limits the default value to 255 for two reasons.
5155 # As it bounds the sequential scan loop, scanning for thousands of luns
5156 # on a target can take minutes of wall clock time. Additionally,
5157 # there are FC targets, such as JBODs, that only recognize 8-bits of
5158 # LUN ID. When they receive a value greater than 8 bits, they chop off
5159 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
5160 # and so on all as LUN ID 0. This causes the linux kernel, which sees
5161 # valid responses at each of the LUN IDs, to believe there are multiple
5162 # devices present, when in fact, there is only 1.
5163 # A customer that is aware of their target behaviors, and the results as
5164 # indicated above, is welcome to increase the lpfc_max_luns value.
5165 # As mentioned, this value is not used by the lpfc driver, only the
5167 # Value range is [0,65535]. Default value is 255.
5168 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
5170 LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID");
5173 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
5174 # Value range is [1,255], default value is 10.
5176 LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
5177 "Milliseconds driver will wait between polling FCP ring");
5180 # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands
5181 # to complete in seconds. Value range is [5,180], default value is 60.
5183 LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180,
5184 "Maximum time to wait for task management commands to complete");
5186 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
5187 # support this feature
5190 # 2 = MSI-X enabled (default)
5191 # Value range is [0,2]. Default value is 2.
5193 LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
5194 "MSI-X (2), if possible");
5197 * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs
5199 * 0 = NVME OAS disabled
5200 * 1 = NVME OAS enabled
5202 * Value range is [0,1]. Default value is 0.
5204 LPFC_ATTR_RW(nvme_oas, 0, 0, 1,
5205 "Use OAS bit on NVME IOs");
5208 * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs
5210 * 0 = Put NVME Command in SGL
5211 * 1 = Embed NVME Command in WQE (unless G7)
5212 * 2 = Embed NVME Command in WQE (force)
5214 * Value range is [0,2]. Default value is 1.
5216 LPFC_ATTR_RW(nvme_embed_cmd, 1, 0, 2,
5217 "Embed NVME Command in WQE");
5220 * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver
5221 * will advertise it supports to the SCSI layer. This also will map to
5222 * the number of WQs the driver will create.
5224 * 0 = Configure the number of io channels to the number of active CPUs.
5225 * 1,32 = Manually specify how many io channels to use.
5227 * Value range is [0,32]. Default value is 4.
5229 LPFC_ATTR_R(fcp_io_channel,
5230 LPFC_FCP_IO_CHAN_DEF,
5231 LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX,
5232 "Set the number of FCP I/O channels");
5235 * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver
5236 * will advertise it supports to the NVME layer. This also will map to
5237 * the number of WQs the driver will create.
5239 * This module parameter is valid when lpfc_enable_fc4_type is set
5242 * The NVME Layer will try to create this many, plus 1 administrative
5243 * hardware queue. The administrative queue will always map to WQ 0
5244 * A hardware IO queue maps (qidx) to a specific driver WQ.
5246 * 0 = Configure the number of io channels to the number of active CPUs.
5247 * 1,32 = Manually specify how many io channels to use.
5249 * Value range is [0,32]. Default value is 0.
5251 LPFC_ATTR_R(nvme_io_channel,
5252 LPFC_NVME_IO_CHAN_DEF,
5253 LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX,
5254 "Set the number of NVME I/O channels");
5257 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
5258 # 0 = HBA resets disabled
5259 # 1 = HBA resets enabled (default)
5260 # Value range is [0,1]. Default value is 1.
5262 LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver.");
5265 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
5266 # 0 = HBA Heartbeat disabled
5267 # 1 = HBA Heartbeat enabled (default)
5268 # Value range is [0,1]. Default value is 1.
5270 LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat.");
5273 # lpfc_EnableXLane: Enable Express Lane Feature
5274 # 0x0 Express Lane Feature disabled
5275 # 0x1 Express Lane Feature enabled
5276 # Value range is [0,1]. Default value is 0.
5278 LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature.");
5281 # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature
5282 # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits)
5283 # Value range is [0x0,0x7f]. Default value is 0
5285 LPFC_ATTR_RW(XLanePriority, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
5288 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
5289 # 0 = BlockGuard disabled (default)
5290 # 1 = BlockGuard enabled
5291 # Value range is [0,1]. Default value is 0.
5293 LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
5296 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
5297 # 0 = disabled (default)
5299 # Value range is [0,1]. Default value is 0.
5301 # This feature in under investigation and may be supported in the future.
5303 unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF;
5307 # - Bit mask of host protection capabilities used to register with the
5309 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
5310 # - Allows you to ultimately specify which profiles to use
5311 # - Default will result in registering capabilities for all profiles.
5312 # - SHOST_DIF_TYPE1_PROTECTION 1
5313 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
5314 # - SHOST_DIX_TYPE0_PROTECTION 8
5315 # HBA supports DIX Type 0: Host to HBA protection only
5316 # - SHOST_DIX_TYPE1_PROTECTION 16
5317 # HBA supports DIX Type 1: Host to HBA Type 1 protection
5320 LPFC_ATTR(prot_mask,
5321 (SHOST_DIF_TYPE1_PROTECTION |
5322 SHOST_DIX_TYPE0_PROTECTION |
5323 SHOST_DIX_TYPE1_PROTECTION),
5325 (SHOST_DIF_TYPE1_PROTECTION |
5326 SHOST_DIX_TYPE0_PROTECTION |
5327 SHOST_DIX_TYPE1_PROTECTION),
5328 "T10-DIF host protection capabilities mask");
5331 # lpfc_prot_guard: i
5332 # - Bit mask of protection guard types to register with the SCSI mid-layer
5333 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
5334 # - Allows you to ultimately specify which profiles to use
5335 # - Default will result in registering capabilities for all guard types
5338 LPFC_ATTR(prot_guard,
5339 SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP,
5340 "T10-DIF host protection guard type");
5343 * Delay initial NPort discovery when Clean Address bit is cleared in
5344 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
5345 * This parameter can have value 0 or 1.
5346 * When this parameter is set to 0, no delay is added to the initial
5348 * When this parameter is set to non-zero value, initial Nport discovery is
5349 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
5350 * accept and FCID/Fabric name/Fabric portname is changed.
5351 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
5352 * when Clean Address bit is cleared in FLOGI/FDISC
5353 * accept and FCID/Fabric name/Fabric portname is changed.
5354 * Default value is 0.
5356 LPFC_ATTR(delay_discovery, 0, 0, 1,
5357 "Delay NPort discovery when Clean Address bit is cleared.");
5360 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
5361 * This value can be set to values between 64 and 4096. The default value is
5362 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
5363 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
5364 * Because of the additional overhead involved in setting up T10-DIF,
5365 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
5366 * and will be limited to 512 if BlockGuard is enabled under SLI3.
5368 LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_MIN_SG_SEG_CNT,
5369 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
5372 * lpfc_enable_mds_diags: Enable MDS Diagnostics
5373 * 0 = MDS Diagnostics disabled (default)
5374 * 1 = MDS Diagnostics enabled
5375 * Value range is [0,1]. Default value is 0.
5377 LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics");
5380 * lpfc_enable_bbcr: Enable BB Credit Recovery
5381 * 0 = BB Credit Recovery disabled
5382 * 1 = BB Credit Recovery enabled (default)
5383 * Value range is [0,1]. Default value is 1.
5385 LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery");
5388 * lpfc_enable_dpp: Enable DPP on G7
5389 * 0 = DPP on G7 disabled
5390 * 1 = DPP on G7 enabled (default)
5391 * Value range is [0,1]. Default value is 1.
5393 LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push");
5395 struct device_attribute *lpfc_hba_attrs[] = {
5396 &dev_attr_nvme_info,
5398 &dev_attr_bg_guard_err,
5399 &dev_attr_bg_apptag_err,
5400 &dev_attr_bg_reftag_err,
5402 &dev_attr_serialnum,
5403 &dev_attr_modeldesc,
5404 &dev_attr_modelname,
5405 &dev_attr_programtype,
5409 &dev_attr_option_rom_version,
5410 &dev_attr_link_state,
5411 &dev_attr_num_discovered_ports,
5412 &dev_attr_menlo_mgmt_mode,
5413 &dev_attr_lpfc_drvr_version,
5414 &dev_attr_lpfc_enable_fip,
5415 &dev_attr_lpfc_temp_sensor,
5416 &dev_attr_lpfc_log_verbose,
5417 &dev_attr_lpfc_lun_queue_depth,
5418 &dev_attr_lpfc_tgt_queue_depth,
5419 &dev_attr_lpfc_hba_queue_depth,
5420 &dev_attr_lpfc_peer_port_login,
5421 &dev_attr_lpfc_nodev_tmo,
5422 &dev_attr_lpfc_devloss_tmo,
5423 &dev_attr_lpfc_enable_fc4_type,
5424 &dev_attr_lpfc_xri_split,
5425 &dev_attr_lpfc_fcp_class,
5426 &dev_attr_lpfc_use_adisc,
5427 &dev_attr_lpfc_first_burst_size,
5428 &dev_attr_lpfc_ack0,
5429 &dev_attr_lpfc_topology,
5430 &dev_attr_lpfc_scan_down,
5431 &dev_attr_lpfc_link_speed,
5432 &dev_attr_lpfc_fcp_io_sched,
5433 &dev_attr_lpfc_fcp2_no_tgt_reset,
5434 &dev_attr_lpfc_cr_delay,
5435 &dev_attr_lpfc_cr_count,
5436 &dev_attr_lpfc_multi_ring_support,
5437 &dev_attr_lpfc_multi_ring_rctl,
5438 &dev_attr_lpfc_multi_ring_type,
5439 &dev_attr_lpfc_fdmi_on,
5440 &dev_attr_lpfc_enable_SmartSAN,
5441 &dev_attr_lpfc_max_luns,
5442 &dev_attr_lpfc_enable_npiv,
5443 &dev_attr_lpfc_fcf_failover_policy,
5444 &dev_attr_lpfc_enable_rrq,
5445 &dev_attr_nport_evt_cnt,
5446 &dev_attr_board_mode,
5453 &dev_attr_npiv_info,
5454 &dev_attr_issue_reset,
5455 &dev_attr_lpfc_poll,
5456 &dev_attr_lpfc_poll_tmo,
5457 &dev_attr_lpfc_task_mgmt_tmo,
5458 &dev_attr_lpfc_use_msi,
5459 &dev_attr_lpfc_nvme_oas,
5460 &dev_attr_lpfc_nvme_embed_cmd,
5461 &dev_attr_lpfc_auto_imax,
5462 &dev_attr_lpfc_fcp_imax,
5463 &dev_attr_lpfc_fcp_cpu_map,
5464 &dev_attr_lpfc_fcp_io_channel,
5465 &dev_attr_lpfc_suppress_rsp,
5466 &dev_attr_lpfc_nvme_io_channel,
5467 &dev_attr_lpfc_nvmet_mrq,
5468 &dev_attr_lpfc_nvmet_mrq_post,
5469 &dev_attr_lpfc_nvme_enable_fb,
5470 &dev_attr_lpfc_nvmet_fb_size,
5471 &dev_attr_lpfc_enable_bg,
5472 &dev_attr_lpfc_soft_wwnn,
5473 &dev_attr_lpfc_soft_wwpn,
5474 &dev_attr_lpfc_soft_wwn_enable,
5475 &dev_attr_lpfc_enable_hba_reset,
5476 &dev_attr_lpfc_enable_hba_heartbeat,
5477 &dev_attr_lpfc_EnableXLane,
5478 &dev_attr_lpfc_XLanePriority,
5479 &dev_attr_lpfc_xlane_lun,
5480 &dev_attr_lpfc_xlane_tgt,
5481 &dev_attr_lpfc_xlane_vpt,
5482 &dev_attr_lpfc_xlane_lun_state,
5483 &dev_attr_lpfc_xlane_lun_status,
5484 &dev_attr_lpfc_xlane_priority,
5485 &dev_attr_lpfc_sg_seg_cnt,
5486 &dev_attr_lpfc_max_scsicmpl_time,
5487 &dev_attr_lpfc_stat_data_ctrl,
5488 &dev_attr_lpfc_aer_support,
5489 &dev_attr_lpfc_aer_state_cleanup,
5490 &dev_attr_lpfc_sriov_nr_virtfn,
5491 &dev_attr_lpfc_req_fw_upgrade,
5492 &dev_attr_lpfc_suppress_link_up,
5493 &dev_attr_lpfc_iocb_cnt,
5496 &dev_attr_txcmplq_hw,
5497 &dev_attr_lpfc_fips_level,
5498 &dev_attr_lpfc_fips_rev,
5500 &dev_attr_lpfc_sriov_hw_max_virtfn,
5502 &dev_attr_lpfc_xlane_supported,
5503 &dev_attr_lpfc_enable_mds_diags,
5504 &dev_attr_lpfc_enable_bbcr,
5505 &dev_attr_lpfc_enable_dpp,
5509 struct device_attribute *lpfc_vport_attrs[] = {
5511 &dev_attr_link_state,
5512 &dev_attr_num_discovered_ports,
5513 &dev_attr_lpfc_drvr_version,
5514 &dev_attr_lpfc_log_verbose,
5515 &dev_attr_lpfc_lun_queue_depth,
5516 &dev_attr_lpfc_tgt_queue_depth,
5517 &dev_attr_lpfc_nodev_tmo,
5518 &dev_attr_lpfc_devloss_tmo,
5519 &dev_attr_lpfc_hba_queue_depth,
5520 &dev_attr_lpfc_peer_port_login,
5521 &dev_attr_lpfc_restrict_login,
5522 &dev_attr_lpfc_fcp_class,
5523 &dev_attr_lpfc_use_adisc,
5524 &dev_attr_lpfc_first_burst_size,
5525 &dev_attr_lpfc_max_luns,
5526 &dev_attr_nport_evt_cnt,
5527 &dev_attr_npiv_info,
5528 &dev_attr_lpfc_enable_da_id,
5529 &dev_attr_lpfc_max_scsicmpl_time,
5530 &dev_attr_lpfc_stat_data_ctrl,
5531 &dev_attr_lpfc_static_vport,
5532 &dev_attr_lpfc_fips_level,
5533 &dev_attr_lpfc_fips_rev,
5538 * sysfs_ctlreg_write - Write method for writing to ctlreg
5539 * @filp: open sysfs file
5540 * @kobj: kernel kobject that contains the kernel class device.
5541 * @bin_attr: kernel attributes passed to us.
5542 * @buf: contains the data to be written to the adapter IOREG space.
5543 * @off: offset into buffer to beginning of data.
5544 * @count: bytes to transfer.
5547 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5548 * Uses the adapter io control registers to send buf contents to the adapter.
5551 * -ERANGE off and count combo out of range
5552 * -EINVAL off, count or buff address invalid
5553 * -EPERM adapter is offline
5554 * value of count, buf contents written
5557 sysfs_ctlreg_write(struct file *filp, struct kobject *kobj,
5558 struct bin_attribute *bin_attr,
5559 char *buf, loff_t off, size_t count)
5562 struct device *dev = container_of(kobj, struct device, kobj);
5563 struct Scsi_Host *shost = class_to_shost(dev);
5564 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5565 struct lpfc_hba *phba = vport->phba;
5567 if (phba->sli_rev >= LPFC_SLI_REV4)
5570 if ((off + count) > FF_REG_AREA_SIZE)
5573 if (count <= LPFC_REG_WRITE_KEY_SIZE)
5576 if (off % 4 || count % 4 || (unsigned long)buf % 4)
5579 /* This is to protect HBA registers from accidental writes. */
5580 if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE))
5583 if (!(vport->fc_flag & FC_OFFLINE_MODE))
5586 spin_lock_irq(&phba->hbalock);
5587 for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE;
5588 buf_off += sizeof(uint32_t))
5589 writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)),
5590 phba->ctrl_regs_memmap_p + off + buf_off);
5592 spin_unlock_irq(&phba->hbalock);
5598 * sysfs_ctlreg_read - Read method for reading from ctlreg
5599 * @filp: open sysfs file
5600 * @kobj: kernel kobject that contains the kernel class device.
5601 * @bin_attr: kernel attributes passed to us.
5602 * @buf: if successful contains the data from the adapter IOREG space.
5603 * @off: offset into buffer to beginning of data.
5604 * @count: bytes to transfer.
5607 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5608 * Uses the adapter io control registers to read data into buf.
5611 * -ERANGE off and count combo out of range
5612 * -EINVAL off, count or buff address invalid
5613 * value of count, buf contents read
5616 sysfs_ctlreg_read(struct file *filp, struct kobject *kobj,
5617 struct bin_attribute *bin_attr,
5618 char *buf, loff_t off, size_t count)
5622 struct device *dev = container_of(kobj, struct device, kobj);
5623 struct Scsi_Host *shost = class_to_shost(dev);
5624 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5625 struct lpfc_hba *phba = vport->phba;
5627 if (phba->sli_rev >= LPFC_SLI_REV4)
5630 if (off > FF_REG_AREA_SIZE)
5633 if ((off + count) > FF_REG_AREA_SIZE)
5634 count = FF_REG_AREA_SIZE - off;
5636 if (count == 0) return 0;
5638 if (off % 4 || count % 4 || (unsigned long)buf % 4)
5641 spin_lock_irq(&phba->hbalock);
5643 for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) {
5644 tmp_ptr = (uint32_t *)(buf + buf_off);
5645 *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off);
5648 spin_unlock_irq(&phba->hbalock);
5653 static struct bin_attribute sysfs_ctlreg_attr = {
5656 .mode = S_IRUSR | S_IWUSR,
5659 .read = sysfs_ctlreg_read,
5660 .write = sysfs_ctlreg_write,
5664 * sysfs_mbox_write - Write method for writing information via mbox
5665 * @filp: open sysfs file
5666 * @kobj: kernel kobject that contains the kernel class device.
5667 * @bin_attr: kernel attributes passed to us.
5668 * @buf: contains the data to be written to sysfs mbox.
5669 * @off: offset into buffer to beginning of data.
5670 * @count: bytes to transfer.
5673 * Deprecated function. All mailbox access from user space is performed via the
5677 * -EPERM operation not permitted
5680 sysfs_mbox_write(struct file *filp, struct kobject *kobj,
5681 struct bin_attribute *bin_attr,
5682 char *buf, loff_t off, size_t count)
5688 * sysfs_mbox_read - Read method for reading information via mbox
5689 * @filp: open sysfs file
5690 * @kobj: kernel kobject that contains the kernel class device.
5691 * @bin_attr: kernel attributes passed to us.
5692 * @buf: contains the data to be read from sysfs mbox.
5693 * @off: offset into buffer to beginning of data.
5694 * @count: bytes to transfer.
5697 * Deprecated function. All mailbox access from user space is performed via the
5701 * -EPERM operation not permitted
5704 sysfs_mbox_read(struct file *filp, struct kobject *kobj,
5705 struct bin_attribute *bin_attr,
5706 char *buf, loff_t off, size_t count)
5711 static struct bin_attribute sysfs_mbox_attr = {
5714 .mode = S_IRUSR | S_IWUSR,
5716 .size = MAILBOX_SYSFS_MAX,
5717 .read = sysfs_mbox_read,
5718 .write = sysfs_mbox_write,
5722 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
5723 * @vport: address of lpfc vport structure.
5727 * error return code from sysfs_create_bin_file()
5730 lpfc_alloc_sysfs_attr(struct lpfc_vport *vport)
5732 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5735 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
5736 &sysfs_drvr_stat_data_attr);
5738 /* Virtual ports do not need ctrl_reg and mbox */
5739 if (error || vport->port_type == LPFC_NPIV_PORT)
5742 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
5743 &sysfs_ctlreg_attr);
5745 goto out_remove_stat_attr;
5747 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
5750 goto out_remove_ctlreg_attr;
5753 out_remove_ctlreg_attr:
5754 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr);
5755 out_remove_stat_attr:
5756 sysfs_remove_bin_file(&shost->shost_dev.kobj,
5757 &sysfs_drvr_stat_data_attr);
5763 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
5764 * @vport: address of lpfc vport structure.
5767 lpfc_free_sysfs_attr(struct lpfc_vport *vport)
5769 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5770 sysfs_remove_bin_file(&shost->shost_dev.kobj,
5771 &sysfs_drvr_stat_data_attr);
5772 /* Virtual ports do not need ctrl_reg and mbox */
5773 if (vport->port_type == LPFC_NPIV_PORT)
5775 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr);
5776 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr);
5780 * Dynamic FC Host Attributes Support
5784 * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host
5785 * @shost: kernel scsi host pointer.
5788 lpfc_get_host_symbolic_name(struct Scsi_Host *shost)
5790 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
5792 lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost),
5793 sizeof fc_host_symbolic_name(shost));
5797 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
5798 * @shost: kernel scsi host pointer.
5801 lpfc_get_host_port_id(struct Scsi_Host *shost)
5803 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5805 /* note: fc_myDID already in cpu endianness */
5806 fc_host_port_id(shost) = vport->fc_myDID;
5810 * lpfc_get_host_port_type - Set the value of the scsi host port type
5811 * @shost: kernel scsi host pointer.
5814 lpfc_get_host_port_type(struct Scsi_Host *shost)
5816 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5817 struct lpfc_hba *phba = vport->phba;
5819 spin_lock_irq(shost->host_lock);
5821 if (vport->port_type == LPFC_NPIV_PORT) {
5822 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
5823 } else if (lpfc_is_link_up(phba)) {
5824 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
5825 if (vport->fc_flag & FC_PUBLIC_LOOP)
5826 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
5828 fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
5830 if (vport->fc_flag & FC_FABRIC)
5831 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
5833 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
5836 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
5838 spin_unlock_irq(shost->host_lock);
5842 * lpfc_get_host_port_state - Set the value of the scsi host port state
5843 * @shost: kernel scsi host pointer.
5846 lpfc_get_host_port_state(struct Scsi_Host *shost)
5848 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5849 struct lpfc_hba *phba = vport->phba;
5851 spin_lock_irq(shost->host_lock);
5853 if (vport->fc_flag & FC_OFFLINE_MODE)
5854 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
5856 switch (phba->link_state) {
5857 case LPFC_LINK_UNKNOWN:
5858 case LPFC_LINK_DOWN:
5859 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
5863 case LPFC_HBA_READY:
5864 /* Links up, reports port state accordingly */
5865 if (vport->port_state < LPFC_VPORT_READY)
5866 fc_host_port_state(shost) =
5867 FC_PORTSTATE_BYPASSED;
5869 fc_host_port_state(shost) =
5870 FC_PORTSTATE_ONLINE;
5872 case LPFC_HBA_ERROR:
5873 fc_host_port_state(shost) = FC_PORTSTATE_ERROR;
5876 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
5881 spin_unlock_irq(shost->host_lock);
5885 * lpfc_get_host_speed - Set the value of the scsi host speed
5886 * @shost: kernel scsi host pointer.
5889 lpfc_get_host_speed(struct Scsi_Host *shost)
5891 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5892 struct lpfc_hba *phba = vport->phba;
5894 spin_lock_irq(shost->host_lock);
5896 if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) {
5897 switch(phba->fc_linkspeed) {
5898 case LPFC_LINK_SPEED_1GHZ:
5899 fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
5901 case LPFC_LINK_SPEED_2GHZ:
5902 fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
5904 case LPFC_LINK_SPEED_4GHZ:
5905 fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
5907 case LPFC_LINK_SPEED_8GHZ:
5908 fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
5910 case LPFC_LINK_SPEED_10GHZ:
5911 fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
5913 case LPFC_LINK_SPEED_16GHZ:
5914 fc_host_speed(shost) = FC_PORTSPEED_16GBIT;
5916 case LPFC_LINK_SPEED_32GHZ:
5917 fc_host_speed(shost) = FC_PORTSPEED_32GBIT;
5919 case LPFC_LINK_SPEED_64GHZ:
5920 fc_host_speed(shost) = FC_PORTSPEED_64GBIT;
5923 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
5926 } else if (lpfc_is_link_up(phba) && (phba->hba_flag & HBA_FCOE_MODE)) {
5927 switch (phba->fc_linkspeed) {
5928 case LPFC_ASYNC_LINK_SPEED_10GBPS:
5929 fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
5931 case LPFC_ASYNC_LINK_SPEED_25GBPS:
5932 fc_host_speed(shost) = FC_PORTSPEED_25GBIT;
5934 case LPFC_ASYNC_LINK_SPEED_40GBPS:
5935 fc_host_speed(shost) = FC_PORTSPEED_40GBIT;
5937 case LPFC_ASYNC_LINK_SPEED_100GBPS:
5938 fc_host_speed(shost) = FC_PORTSPEED_100GBIT;
5941 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
5945 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
5947 spin_unlock_irq(shost->host_lock);
5951 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
5952 * @shost: kernel scsi host pointer.
5955 lpfc_get_host_fabric_name (struct Scsi_Host *shost)
5957 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5958 struct lpfc_hba *phba = vport->phba;
5961 spin_lock_irq(shost->host_lock);
5963 if ((vport->port_state > LPFC_FLOGI) &&
5964 ((vport->fc_flag & FC_FABRIC) ||
5965 ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) &&
5966 (vport->fc_flag & FC_PUBLIC_LOOP))))
5967 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
5969 /* fabric is local port if there is no F/FL_Port */
5972 spin_unlock_irq(shost->host_lock);
5974 fc_host_fabric_name(shost) = node_name;
5978 * lpfc_get_stats - Return statistical information about the adapter
5979 * @shost: kernel scsi host pointer.
5982 * NULL on error for link down, no mbox pool, sli2 active,
5983 * management not allowed, memory allocation error, or mbox error.
5987 * address of the adapter host statistics
5989 static struct fc_host_statistics *
5990 lpfc_get_stats(struct Scsi_Host *shost)
5992 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5993 struct lpfc_hba *phba = vport->phba;
5994 struct lpfc_sli *psli = &phba->sli;
5995 struct fc_host_statistics *hs = &phba->link_stats;
5996 struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets;
5997 LPFC_MBOXQ_t *pmboxq;
6002 * prevent udev from issuing mailbox commands until the port is
6005 if (phba->link_state < LPFC_LINK_DOWN ||
6006 !phba->mbox_mem_pool ||
6007 (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0)
6010 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
6013 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
6016 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
6018 pmb = &pmboxq->u.mb;
6019 pmb->mbxCommand = MBX_READ_STATUS;
6020 pmb->mbxOwner = OWN_HOST;
6021 pmboxq->context1 = NULL;
6022 pmboxq->vport = vport;
6024 if (vport->fc_flag & FC_OFFLINE_MODE)
6025 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
6027 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
6029 if (rc != MBX_SUCCESS) {
6030 if (rc != MBX_TIMEOUT)
6031 mempool_free(pmboxq, phba->mbox_mem_pool);
6035 memset(hs, 0, sizeof (struct fc_host_statistics));
6037 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
6039 * The MBX_READ_STATUS returns tx_k_bytes which has to
6040 * converted to words
6042 hs->tx_words = (uint64_t)
6043 ((uint64_t)pmb->un.varRdStatus.xmitByteCnt
6045 hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
6046 hs->rx_words = (uint64_t)
6047 ((uint64_t)pmb->un.varRdStatus.rcvByteCnt
6050 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
6051 pmb->mbxCommand = MBX_READ_LNK_STAT;
6052 pmb->mbxOwner = OWN_HOST;
6053 pmboxq->context1 = NULL;
6054 pmboxq->vport = vport;
6056 if (vport->fc_flag & FC_OFFLINE_MODE)
6057 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
6059 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
6061 if (rc != MBX_SUCCESS) {
6062 if (rc != MBX_TIMEOUT)
6063 mempool_free(pmboxq, phba->mbox_mem_pool);
6067 hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
6068 hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
6069 hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
6070 hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
6071 hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
6072 hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
6073 hs->error_frames = pmb->un.varRdLnk.crcCnt;
6075 hs->link_failure_count -= lso->link_failure_count;
6076 hs->loss_of_sync_count -= lso->loss_of_sync_count;
6077 hs->loss_of_signal_count -= lso->loss_of_signal_count;
6078 hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count;
6079 hs->invalid_tx_word_count -= lso->invalid_tx_word_count;
6080 hs->invalid_crc_count -= lso->invalid_crc_count;
6081 hs->error_frames -= lso->error_frames;
6083 if (phba->hba_flag & HBA_FCOE_MODE) {
6085 hs->nos_count = (phba->link_events >> 1);
6086 hs->nos_count -= lso->link_events;
6087 } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
6088 hs->lip_count = (phba->fc_eventTag >> 1);
6089 hs->lip_count -= lso->link_events;
6093 hs->nos_count = (phba->fc_eventTag >> 1);
6094 hs->nos_count -= lso->link_events;
6097 hs->dumped_frames = -1;
6099 hs->seconds_since_last_reset = ktime_get_seconds() - psli->stats_start;
6101 mempool_free(pmboxq, phba->mbox_mem_pool);
6107 * lpfc_reset_stats - Copy the adapter link stats information
6108 * @shost: kernel scsi host pointer.
6111 lpfc_reset_stats(struct Scsi_Host *shost)
6113 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
6114 struct lpfc_hba *phba = vport->phba;
6115 struct lpfc_sli *psli = &phba->sli;
6116 struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets;
6117 LPFC_MBOXQ_t *pmboxq;
6121 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
6124 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
6127 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
6129 pmb = &pmboxq->u.mb;
6130 pmb->mbxCommand = MBX_READ_STATUS;
6131 pmb->mbxOwner = OWN_HOST;
6132 pmb->un.varWords[0] = 0x1; /* reset request */
6133 pmboxq->context1 = NULL;
6134 pmboxq->vport = vport;
6136 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
6137 (!(psli->sli_flag & LPFC_SLI_ACTIVE)))
6138 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
6140 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
6142 if (rc != MBX_SUCCESS) {
6143 if (rc != MBX_TIMEOUT)
6144 mempool_free(pmboxq, phba->mbox_mem_pool);
6148 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
6149 pmb->mbxCommand = MBX_READ_LNK_STAT;
6150 pmb->mbxOwner = OWN_HOST;
6151 pmboxq->context1 = NULL;
6152 pmboxq->vport = vport;
6154 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
6155 (!(psli->sli_flag & LPFC_SLI_ACTIVE)))
6156 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
6158 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
6160 if (rc != MBX_SUCCESS) {
6161 if (rc != MBX_TIMEOUT)
6162 mempool_free( pmboxq, phba->mbox_mem_pool);
6166 lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
6167 lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
6168 lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
6169 lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
6170 lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
6171 lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
6172 lso->error_frames = pmb->un.varRdLnk.crcCnt;
6173 if (phba->hba_flag & HBA_FCOE_MODE)
6174 lso->link_events = (phba->link_events >> 1);
6176 lso->link_events = (phba->fc_eventTag >> 1);
6178 psli->stats_start = ktime_get_seconds();
6180 mempool_free(pmboxq, phba->mbox_mem_pool);
6186 * The LPFC driver treats linkdown handling as target loss events so there
6187 * are no sysfs handlers for link_down_tmo.
6191 * lpfc_get_node_by_target - Return the nodelist for a target
6192 * @starget: kernel scsi target pointer.
6195 * address of the node list if found
6196 * NULL target not found
6198 static struct lpfc_nodelist *
6199 lpfc_get_node_by_target(struct scsi_target *starget)
6201 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
6202 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
6203 struct lpfc_nodelist *ndlp;
6205 spin_lock_irq(shost->host_lock);
6206 /* Search for this, mapped, target ID */
6207 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
6208 if (NLP_CHK_NODE_ACT(ndlp) &&
6209 ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
6210 starget->id == ndlp->nlp_sid) {
6211 spin_unlock_irq(shost->host_lock);
6215 spin_unlock_irq(shost->host_lock);
6220 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
6221 * @starget: kernel scsi target pointer.
6224 lpfc_get_starget_port_id(struct scsi_target *starget)
6226 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
6228 fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1;
6232 * lpfc_get_starget_node_name - Set the target node name
6233 * @starget: kernel scsi target pointer.
6235 * Description: Set the target node name to the ndlp node name wwn or zero.
6238 lpfc_get_starget_node_name(struct scsi_target *starget)
6240 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
6242 fc_starget_node_name(starget) =
6243 ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0;
6247 * lpfc_get_starget_port_name - Set the target port name
6248 * @starget: kernel scsi target pointer.
6250 * Description: set the target port name to the ndlp port name wwn or zero.
6253 lpfc_get_starget_port_name(struct scsi_target *starget)
6255 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
6257 fc_starget_port_name(starget) =
6258 ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0;
6262 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
6263 * @rport: fc rport address.
6264 * @timeout: new value for dev loss tmo.
6267 * If timeout is non zero set the dev_loss_tmo to timeout, else set
6268 * dev_loss_tmo to one.
6271 lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
6274 rport->dev_loss_tmo = timeout;
6276 rport->dev_loss_tmo = 1;
6280 * lpfc_rport_show_function - Return rport target information
6283 * Macro that uses field to generate a function with the name lpfc_show_rport_
6285 * lpfc_show_rport_##field: returns the bytes formatted in buf
6286 * @cdev: class converted to an fc_rport.
6287 * @buf: on return contains the target_field or zero.
6289 * Returns: size of formatted string.
6291 #define lpfc_rport_show_function(field, format_string, sz, cast) \
6293 lpfc_show_rport_##field (struct device *dev, \
6294 struct device_attribute *attr, \
6297 struct fc_rport *rport = transport_class_to_rport(dev); \
6298 struct lpfc_rport_data *rdata = rport->hostdata; \
6299 return snprintf(buf, sz, format_string, \
6300 (rdata->target) ? cast rdata->target->field : 0); \
6303 #define lpfc_rport_rd_attr(field, format_string, sz) \
6304 lpfc_rport_show_function(field, format_string, sz, ) \
6305 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
6308 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
6309 * @fc_vport: The fc_vport who's symbolic name has been changed.
6312 * This function is called by the transport after the @fc_vport's symbolic name
6313 * has been changed. This function re-registers the symbolic name with the
6314 * switch to propagate the change into the fabric if the vport is active.
6317 lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport)
6319 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
6321 if (vport->port_state == LPFC_VPORT_READY)
6322 lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0);
6326 * lpfc_hba_log_verbose_init - Set hba's log verbose level
6327 * @phba: Pointer to lpfc_hba struct.
6329 * This function is called by the lpfc_get_cfgparam() routine to set the
6330 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
6331 * log message according to the module's lpfc_log_verbose parameter setting
6332 * before hba port or vport created.
6335 lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose)
6337 phba->cfg_log_verbose = verbose;
6340 struct fc_function_template lpfc_transport_functions = {
6341 /* fixed attributes the driver supports */
6342 .show_host_node_name = 1,
6343 .show_host_port_name = 1,
6344 .show_host_supported_classes = 1,
6345 .show_host_supported_fc4s = 1,
6346 .show_host_supported_speeds = 1,
6347 .show_host_maxframe_size = 1,
6349 .get_host_symbolic_name = lpfc_get_host_symbolic_name,
6350 .show_host_symbolic_name = 1,
6352 /* dynamic attributes the driver supports */
6353 .get_host_port_id = lpfc_get_host_port_id,
6354 .show_host_port_id = 1,
6356 .get_host_port_type = lpfc_get_host_port_type,
6357 .show_host_port_type = 1,
6359 .get_host_port_state = lpfc_get_host_port_state,
6360 .show_host_port_state = 1,
6362 /* active_fc4s is shown but doesn't change (thus no get function) */
6363 .show_host_active_fc4s = 1,
6365 .get_host_speed = lpfc_get_host_speed,
6366 .show_host_speed = 1,
6368 .get_host_fabric_name = lpfc_get_host_fabric_name,
6369 .show_host_fabric_name = 1,
6372 * The LPFC driver treats linkdown handling as target loss events
6373 * so there are no sysfs handlers for link_down_tmo.
6376 .get_fc_host_stats = lpfc_get_stats,
6377 .reset_fc_host_stats = lpfc_reset_stats,
6379 .dd_fcrport_size = sizeof(struct lpfc_rport_data),
6380 .show_rport_maxframe_size = 1,
6381 .show_rport_supported_classes = 1,
6383 .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
6384 .show_rport_dev_loss_tmo = 1,
6386 .get_starget_port_id = lpfc_get_starget_port_id,
6387 .show_starget_port_id = 1,
6389 .get_starget_node_name = lpfc_get_starget_node_name,
6390 .show_starget_node_name = 1,
6392 .get_starget_port_name = lpfc_get_starget_port_name,
6393 .show_starget_port_name = 1,
6395 .issue_fc_host_lip = lpfc_issue_lip,
6396 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
6397 .terminate_rport_io = lpfc_terminate_rport_io,
6399 .dd_fcvport_size = sizeof(struct lpfc_vport *),
6401 .vport_disable = lpfc_vport_disable,
6403 .set_vport_symbolic_name = lpfc_set_vport_symbolic_name,
6405 .bsg_request = lpfc_bsg_request,
6406 .bsg_timeout = lpfc_bsg_timeout,
6409 struct fc_function_template lpfc_vport_transport_functions = {
6410 /* fixed attributes the driver supports */
6411 .show_host_node_name = 1,
6412 .show_host_port_name = 1,
6413 .show_host_supported_classes = 1,
6414 .show_host_supported_fc4s = 1,
6415 .show_host_supported_speeds = 1,
6416 .show_host_maxframe_size = 1,
6418 .get_host_symbolic_name = lpfc_get_host_symbolic_name,
6419 .show_host_symbolic_name = 1,
6421 /* dynamic attributes the driver supports */
6422 .get_host_port_id = lpfc_get_host_port_id,
6423 .show_host_port_id = 1,
6425 .get_host_port_type = lpfc_get_host_port_type,
6426 .show_host_port_type = 1,
6428 .get_host_port_state = lpfc_get_host_port_state,
6429 .show_host_port_state = 1,
6431 /* active_fc4s is shown but doesn't change (thus no get function) */
6432 .show_host_active_fc4s = 1,
6434 .get_host_speed = lpfc_get_host_speed,
6435 .show_host_speed = 1,
6437 .get_host_fabric_name = lpfc_get_host_fabric_name,
6438 .show_host_fabric_name = 1,
6441 * The LPFC driver treats linkdown handling as target loss events
6442 * so there are no sysfs handlers for link_down_tmo.
6445 .get_fc_host_stats = lpfc_get_stats,
6446 .reset_fc_host_stats = lpfc_reset_stats,
6448 .dd_fcrport_size = sizeof(struct lpfc_rport_data),
6449 .show_rport_maxframe_size = 1,
6450 .show_rport_supported_classes = 1,
6452 .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
6453 .show_rport_dev_loss_tmo = 1,
6455 .get_starget_port_id = lpfc_get_starget_port_id,
6456 .show_starget_port_id = 1,
6458 .get_starget_node_name = lpfc_get_starget_node_name,
6459 .show_starget_node_name = 1,
6461 .get_starget_port_name = lpfc_get_starget_port_name,
6462 .show_starget_port_name = 1,
6464 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
6465 .terminate_rport_io = lpfc_terminate_rport_io,
6467 .vport_disable = lpfc_vport_disable,
6469 .set_vport_symbolic_name = lpfc_set_vport_symbolic_name,
6473 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
6474 * @phba: lpfc_hba pointer.
6477 lpfc_get_cfgparam(struct lpfc_hba *phba)
6479 lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched);
6480 lpfc_fcp2_no_tgt_reset_init(phba, lpfc_fcp2_no_tgt_reset);
6481 lpfc_cr_delay_init(phba, lpfc_cr_delay);
6482 lpfc_cr_count_init(phba, lpfc_cr_count);
6483 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
6484 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
6485 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
6486 lpfc_ack0_init(phba, lpfc_ack0);
6487 lpfc_topology_init(phba, lpfc_topology);
6488 lpfc_link_speed_init(phba, lpfc_link_speed);
6489 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
6490 lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo);
6491 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
6492 lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy);
6493 lpfc_enable_rrq_init(phba, lpfc_enable_rrq);
6494 lpfc_fdmi_on_init(phba, lpfc_fdmi_on);
6495 lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN);
6496 lpfc_use_msi_init(phba, lpfc_use_msi);
6497 lpfc_nvme_oas_init(phba, lpfc_nvme_oas);
6498 lpfc_nvme_embed_cmd_init(phba, lpfc_nvme_embed_cmd);
6499 lpfc_auto_imax_init(phba, lpfc_auto_imax);
6500 lpfc_fcp_imax_init(phba, lpfc_fcp_imax);
6501 lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map);
6502 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
6503 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
6505 lpfc_EnableXLane_init(phba, lpfc_EnableXLane);
6506 if (phba->sli_rev != LPFC_SLI_REV4)
6507 phba->cfg_EnableXLane = 0;
6508 lpfc_XLanePriority_init(phba, lpfc_XLanePriority);
6510 memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t)));
6511 memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t)));
6512 phba->cfg_oas_lun_state = 0;
6513 phba->cfg_oas_lun_status = 0;
6514 phba->cfg_oas_flags = 0;
6515 phba->cfg_oas_priority = 0;
6516 lpfc_enable_bg_init(phba, lpfc_enable_bg);
6517 lpfc_prot_mask_init(phba, lpfc_prot_mask);
6518 lpfc_prot_guard_init(phba, lpfc_prot_guard);
6519 if (phba->sli_rev == LPFC_SLI_REV4)
6522 phba->cfg_poll = lpfc_poll;
6524 if (phba->cfg_enable_bg)
6525 phba->sli3_options |= LPFC_SLI3_BG_ENABLED;
6527 lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp);
6529 lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type);
6530 lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq);
6531 lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post);
6533 /* Initialize first burst. Target vs Initiator are different. */
6534 lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb);
6535 lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size);
6536 lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel);
6537 lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel);
6538 lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr);
6539 lpfc_enable_dpp_init(phba, lpfc_enable_dpp);
6541 if (phba->sli_rev != LPFC_SLI_REV4) {
6542 /* NVME only supported on SLI4 */
6543 phba->nvmet_support = 0;
6544 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP;
6545 phba->cfg_enable_bbcr = 0;
6547 /* We MUST have FCP support */
6548 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
6549 phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP;
6552 if (phba->cfg_auto_imax && !phba->cfg_fcp_imax)
6553 phba->cfg_auto_imax = 0;
6554 phba->initial_imax = phba->cfg_fcp_imax;
6556 phba->cfg_enable_pbde = 0;
6558 /* A value of 0 means use the number of CPUs found in the system */
6559 if (phba->cfg_fcp_io_channel == 0)
6560 phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu;
6561 if (phba->cfg_nvme_io_channel == 0)
6562 phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu;
6564 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
6565 phba->cfg_fcp_io_channel = 0;
6567 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP)
6568 phba->cfg_nvme_io_channel = 0;
6570 if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel)
6571 phba->io_channel_irqs = phba->cfg_fcp_io_channel;
6573 phba->io_channel_irqs = phba->cfg_nvme_io_channel;
6575 phba->cfg_soft_wwnn = 0L;
6576 phba->cfg_soft_wwpn = 0L;
6577 lpfc_xri_split_init(phba, lpfc_xri_split);
6578 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
6579 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
6580 lpfc_hba_log_verbose_init(phba, lpfc_log_verbose);
6581 lpfc_aer_support_init(phba, lpfc_aer_support);
6582 lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn);
6583 lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade);
6584 lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up);
6585 lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt);
6586 lpfc_delay_discovery_init(phba, lpfc_delay_discovery);
6587 lpfc_sli_mode_init(phba, lpfc_sli_mode);
6588 phba->cfg_enable_dss = 1;
6589 lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags);
6594 * lpfc_nvme_mod_param_dep - Adjust module parameter value based on
6595 * dependencies between protocols and roles.
6596 * @phba: lpfc_hba pointer.
6599 lpfc_nvme_mod_param_dep(struct lpfc_hba *phba)
6601 if (phba->cfg_nvme_io_channel > phba->sli4_hba.num_present_cpu)
6602 phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu;
6604 if (phba->cfg_fcp_io_channel > phba->sli4_hba.num_present_cpu)
6605 phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu;
6607 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME &&
6608 phba->nvmet_support) {
6609 phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP;
6610 phba->cfg_fcp_io_channel = 0;
6612 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC,
6613 "6013 %s x%x fb_size x%x, fb_max x%x\n",
6614 "NVME Target PRLI ACC enable_fb ",
6615 phba->cfg_nvme_enable_fb,
6616 phba->cfg_nvmet_fb_size,
6617 LPFC_NVMET_FB_SZ_MAX);
6619 if (phba->cfg_nvme_enable_fb == 0)
6620 phba->cfg_nvmet_fb_size = 0;
6622 if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX)
6623 phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX;
6626 if (!phba->cfg_nvmet_mrq)
6627 phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel;
6629 /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */
6630 if (phba->cfg_nvmet_mrq > phba->cfg_nvme_io_channel) {
6631 phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel;
6632 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC,
6633 "6018 Adjust lpfc_nvmet_mrq to %d\n",
6634 phba->cfg_nvmet_mrq);
6636 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX)
6637 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX;
6640 /* Not NVME Target mode. Turn off Target parameters. */
6641 phba->nvmet_support = 0;
6642 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_OFF;
6643 phba->cfg_nvmet_fb_size = 0;
6646 if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel)
6647 phba->io_channel_irqs = phba->cfg_fcp_io_channel;
6649 phba->io_channel_irqs = phba->cfg_nvme_io_channel;
6653 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
6654 * @vport: lpfc_vport pointer.
6657 lpfc_get_vport_cfgparam(struct lpfc_vport *vport)
6659 lpfc_log_verbose_init(vport, lpfc_log_verbose);
6660 lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth);
6661 lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth);
6662 lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo);
6663 lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo);
6664 lpfc_peer_port_login_init(vport, lpfc_peer_port_login);
6665 lpfc_restrict_login_init(vport, lpfc_restrict_login);
6666 lpfc_fcp_class_init(vport, lpfc_fcp_class);
6667 lpfc_use_adisc_init(vport, lpfc_use_adisc);
6668 lpfc_first_burst_size_init(vport, lpfc_first_burst_size);
6669 lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time);
6670 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
6671 lpfc_max_luns_init(vport, lpfc_max_luns);
6672 lpfc_scan_down_init(vport, lpfc_scan_down);
6673 lpfc_enable_da_id_init(vport, lpfc_enable_da_id);