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
,
886 if ((phba
->sli_rev
== LPFC_SLI_REV4
) &&
887 ((bf_get(lpfc_sli_intf_if_type
,
888 &phba
->sli4_hba
.sli_intf
) ==
889 LPFC_SLI_INTF_IF_TYPE_6
))) {
890 struct lpfc_trunk_link link
= phba
->trunk_link
;
892 if (bf_get(lpfc_conf_trunk_port0
, &phba
->sli4_hba
))
893 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
894 "Trunk port 0: Link %s %s\n",
895 (link
.link0
.state
== LPFC_LINK_UP
) ?
897 trunk_errmsg
[link
.link0
.fault
]);
899 if (bf_get(lpfc_conf_trunk_port1
, &phba
->sli4_hba
))
900 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
901 "Trunk port 1: Link %s %s\n",
902 (link
.link1
.state
== LPFC_LINK_UP
) ?
904 trunk_errmsg
[link
.link1
.fault
]);
906 if (bf_get(lpfc_conf_trunk_port2
, &phba
->sli4_hba
))
907 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
908 "Trunk port 2: Link %s %s\n",
909 (link
.link2
.state
== LPFC_LINK_UP
) ?
911 trunk_errmsg
[link
.link2
.fault
]);
913 if (bf_get(lpfc_conf_trunk_port3
, &phba
->sli4_hba
))
914 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
915 "Trunk port 3: Link %s %s\n",
916 (link
.link3
.state
== LPFC_LINK_UP
) ?
918 trunk_errmsg
[link
.link3
.fault
]);
926 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
927 * @dev: class unused variable.
928 * @attr: device attribute, not used.
929 * @buf: on return contains the module description text.
931 * Returns: size of formatted string.
934 lpfc_sli4_protocol_show(struct device
*dev
, struct device_attribute
*attr
,
937 struct Scsi_Host
*shost
= class_to_shost(dev
);
938 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
939 struct lpfc_hba
*phba
= vport
->phba
;
941 if (phba
->sli_rev
< LPFC_SLI_REV4
)
942 return snprintf(buf
, PAGE_SIZE
, "fc\n");
944 if (phba
->sli4_hba
.lnk_info
.lnk_dv
== LPFC_LNK_DAT_VAL
) {
945 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_GE
)
946 return snprintf(buf
, PAGE_SIZE
, "fcoe\n");
947 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_FC
)
948 return snprintf(buf
, PAGE_SIZE
, "fc\n");
950 return snprintf(buf
, PAGE_SIZE
, "unknown\n");
954 * lpfc_oas_supported_show - Return whether or not Optimized Access Storage
955 * (OAS) is supported.
956 * @dev: class unused variable.
957 * @attr: device attribute, not used.
958 * @buf: on return contains the module description text.
960 * Returns: size of formatted string.
963 lpfc_oas_supported_show(struct device
*dev
, struct device_attribute
*attr
,
966 struct Scsi_Host
*shost
= class_to_shost(dev
);
967 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
968 struct lpfc_hba
*phba
= vport
->phba
;
970 return snprintf(buf
, PAGE_SIZE
, "%d\n",
971 phba
->sli4_hba
.pc_sli4_params
.oas_supported
);
975 * lpfc_link_state_store - Transition the link_state on an HBA port
976 * @dev: class device that is converted into a Scsi_host.
977 * @attr: device attribute, not used.
978 * @buf: one or more lpfc_polling_flags values.
982 * -EINVAL if the buffer is not "up" or "down"
983 * return from link state change function if non-zero
984 * length of the buf on success
987 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
988 const char *buf
, size_t count
)
990 struct Scsi_Host
*shost
= class_to_shost(dev
);
991 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
992 struct lpfc_hba
*phba
= vport
->phba
;
994 int status
= -EINVAL
;
996 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
997 (phba
->link_state
== LPFC_LINK_DOWN
))
998 status
= phba
->lpfc_hba_init_link(phba
, MBX_NOWAIT
);
999 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
1000 (phba
->link_state
>= LPFC_LINK_UP
))
1001 status
= phba
->lpfc_hba_down_link(phba
, MBX_NOWAIT
);
1010 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
1011 * @dev: class device that is converted into a Scsi_host.
1012 * @attr: device attribute, not used.
1013 * @buf: on return contains the sum of fc mapped and unmapped.
1016 * Returns the ascii text number of the sum of the fc mapped and unmapped
1019 * Returns: size of formatted string.
1022 lpfc_num_discovered_ports_show(struct device
*dev
,
1023 struct device_attribute
*attr
, char *buf
)
1025 struct Scsi_Host
*shost
= class_to_shost(dev
);
1026 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1028 return snprintf(buf
, PAGE_SIZE
, "%d\n",
1029 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
1033 * lpfc_issue_lip - Misnomer, name carried over from long ago
1034 * @shost: Scsi_Host pointer.
1037 * Bring the link down gracefully then re-init the link. The firmware will
1038 * re-init the fiber channel interface as required. Does not issue a LIP.
1041 * -EPERM port offline or management commands are being blocked
1042 * -ENOMEM cannot allocate memory for the mailbox command
1043 * -EIO error sending the mailbox command
1047 lpfc_issue_lip(struct Scsi_Host
*shost
)
1049 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1050 struct lpfc_hba
*phba
= vport
->phba
;
1051 LPFC_MBOXQ_t
*pmboxq
;
1052 int mbxstatus
= MBXERR_ERROR
;
1055 * If the link is offline, disabled or BLOCK_MGMT_IO
1056 * it doesn't make any sense to allow issue_lip
1058 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
1059 (phba
->hba_flag
& LINK_DISABLED
) ||
1060 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
1063 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
1068 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1069 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
1070 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
1072 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
1074 if ((mbxstatus
== MBX_SUCCESS
) &&
1075 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
1076 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
1077 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1078 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
1079 phba
->cfg_link_speed
);
1080 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
1081 phba
->fc_ratov
* 2);
1082 if ((mbxstatus
== MBX_SUCCESS
) &&
1083 (pmboxq
->u
.mb
.mbxStatus
== MBXERR_SEC_NO_PERMISSION
))
1084 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
| LOG_SLI
,
1085 "2859 SLI authentication is required "
1086 "for INIT_LINK but has not done yet\n");
1089 lpfc_set_loopback_flag(phba
);
1090 if (mbxstatus
!= MBX_TIMEOUT
)
1091 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1093 if (mbxstatus
== MBXERR_ERROR
)
1100 lpfc_emptyq_wait(struct lpfc_hba
*phba
, struct list_head
*q
, spinlock_t
*lock
)
1104 spin_lock_irq(lock
);
1105 while (!list_empty(q
)) {
1106 spin_unlock_irq(lock
);
1108 if (cnt
++ > 250) { /* 5 secs */
1109 lpfc_printf_log(phba
, KERN_WARNING
, LOG_INIT
,
1111 "Outstanding IO when ",
1112 "bringing Adapter offline\n");
1115 spin_lock_irq(lock
);
1117 spin_unlock_irq(lock
);
1122 * lpfc_do_offline - Issues a mailbox command to bring the link down
1123 * @phba: lpfc_hba pointer.
1124 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
1127 * Assumes any error from lpfc_do_offline() will be negative.
1128 * Can wait up to 5 seconds for the port ring buffers count
1129 * to reach zero, prints a warning if it is not zero and continues.
1130 * lpfc_workq_post_event() returns a non-zero return code if call fails.
1133 * -EIO error posting the event
1137 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
1139 struct completion online_compl
;
1140 struct lpfc_queue
*qp
= NULL
;
1141 struct lpfc_sli_ring
*pring
;
1142 struct lpfc_sli
*psli
;
1147 init_completion(&online_compl
);
1148 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1149 LPFC_EVT_OFFLINE_PREP
);
1153 wait_for_completion(&online_compl
);
1160 /* Wait a little for things to settle down, but not
1161 * long enough for dev loss timeout to expire.
1163 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
1164 for (i
= 0; i
< psli
->num_rings
; i
++) {
1165 pring
= &psli
->sli3_ring
[i
];
1166 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1171 list_for_each_entry(qp
, &phba
->sli4_hba
.lpfc_wq_list
, wq_list
) {
1175 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1181 init_completion(&online_compl
);
1182 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
1186 wait_for_completion(&online_compl
);
1195 * lpfc_reset_pci_bus - resets PCI bridge controller's secondary bus of an HBA
1196 * @phba: lpfc_hba pointer.
1199 * Issues a PCI secondary bus reset for the phba->pcidev.
1202 * First walks the bus_list to ensure only PCI devices with Emulex
1203 * vendor id, device ids that support hot reset, only one occurrence
1204 * of function 0, and all ports on the bus are in offline mode to ensure the
1205 * hot reset only affects one valid HBA.
1208 * -ENOTSUPP, cfg_enable_hba_reset must be of value 2
1209 * -ENODEV, NULL ptr to pcidev
1210 * -EBADSLT, detected invalid device
1211 * -EBUSY, port is not in offline state
1215 lpfc_reset_pci_bus(struct lpfc_hba
*phba
)
1217 struct pci_dev
*pdev
= phba
->pcidev
;
1218 struct Scsi_Host
*shost
= NULL
;
1219 struct lpfc_hba
*phba_other
= NULL
;
1220 struct pci_dev
*ptr
= NULL
;
1223 if (phba
->cfg_enable_hba_reset
!= 2)
1227 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
, "8345 pdev NULL!\n");
1231 res
= lpfc_check_pci_resettable(phba
);
1235 /* Walk the list of devices on the pci_dev's bus */
1236 list_for_each_entry(ptr
, &pdev
->bus
->devices
, bus_list
) {
1237 /* Check port is offline */
1238 shost
= pci_get_drvdata(ptr
);
1241 ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
1242 if (!(phba_other
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
1243 lpfc_printf_log(phba_other
, KERN_INFO
, LOG_INIT
,
1244 "8349 WWPN = 0x%02x%02x%02x%02x"
1245 "%02x%02x%02x%02x is not "
1247 phba_other
->wwpn
[0],
1248 phba_other
->wwpn
[1],
1249 phba_other
->wwpn
[2],
1250 phba_other
->wwpn
[3],
1251 phba_other
->wwpn
[4],
1252 phba_other
->wwpn
[5],
1253 phba_other
->wwpn
[6],
1254 phba_other
->wwpn
[7]);
1260 /* Issue PCI bus reset */
1261 res
= pci_reset_bus(pdev
);
1263 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1264 "8350 PCI reset bus failed: %d\n", res
);
1271 * lpfc_selective_reset - Offline then onlines the port
1272 * @phba: lpfc_hba pointer.
1275 * If the port is configured to allow a reset then the hba is brought
1276 * offline then online.
1279 * Assumes any error from lpfc_do_offline() will be negative.
1280 * Do not make this function static.
1283 * lpfc_do_offline() return code if not zero
1284 * -EIO reset not configured or error posting the event
1288 lpfc_selective_reset(struct lpfc_hba
*phba
)
1290 struct completion online_compl
;
1294 if (!phba
->cfg_enable_hba_reset
)
1297 if (!(phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
1298 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1304 init_completion(&online_compl
);
1305 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1310 wait_for_completion(&online_compl
);
1319 * lpfc_issue_reset - Selectively resets an adapter
1320 * @dev: class device that is converted into a Scsi_host.
1321 * @attr: device attribute, not used.
1322 * @buf: containing the string "selective".
1323 * @count: unused variable.
1326 * If the buf contains the string "selective" then lpfc_selective_reset()
1327 * is called to perform the reset.
1330 * Assumes any error from lpfc_selective_reset() will be negative.
1331 * If lpfc_selective_reset() returns zero then the length of the buffer
1332 * is returned which indicates success
1335 * -EINVAL if the buffer does not contain the string "selective"
1336 * length of buf if lpfc-selective_reset() if the call succeeds
1337 * return value of lpfc_selective_reset() if the call fails
1340 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
1341 const char *buf
, size_t count
)
1343 struct Scsi_Host
*shost
= class_to_shost(dev
);
1344 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1345 struct lpfc_hba
*phba
= vport
->phba
;
1346 int status
= -EINVAL
;
1348 if (!phba
->cfg_enable_hba_reset
)
1351 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
1352 status
= phba
->lpfc_selective_reset(phba
);
1361 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
1362 * @phba: lpfc_hba pointer.
1365 * SLI4 interface type-2 device to wait on the sliport status register for
1366 * the readyness after performing a firmware reset.
1369 * zero for success, -EPERM when port does not have privilege to perform the
1370 * reset, -EIO when port timeout from recovering from the reset.
1373 * As the caller will interpret the return code by value, be careful in making
1374 * change or addition to return codes.
1377 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba
*phba
)
1379 struct lpfc_register portstat_reg
= {0};
1383 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1384 &portstat_reg
.word0
);
1386 /* verify if privileged for the request operation */
1387 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
) &&
1388 !bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1391 /* wait for the SLI port firmware ready after firmware reset */
1392 for (i
= 0; i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
; i
++) {
1394 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1395 &portstat_reg
.word0
);
1396 if (!bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1398 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
))
1400 if (!bf_get(lpfc_sliport_status_rdy
, &portstat_reg
))
1405 if (i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
)
1412 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
1413 * @phba: lpfc_hba pointer.
1416 * Request SLI4 interface type-2 device to perform a physical register set
1423 lpfc_sli4_pdev_reg_request(struct lpfc_hba
*phba
, uint32_t opcode
)
1425 struct completion online_compl
;
1426 struct pci_dev
*pdev
= phba
->pcidev
;
1427 uint32_t before_fc_flag
;
1428 uint32_t sriov_nr_virtfn
;
1430 int status
= 0, rc
= 0;
1431 int job_posted
= 1, sriov_err
;
1433 if (!phba
->cfg_enable_hba_reset
)
1436 if ((phba
->sli_rev
< LPFC_SLI_REV4
) ||
1437 (bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
) <
1438 LPFC_SLI_INTF_IF_TYPE_2
))
1441 /* Keep state if we need to restore back */
1442 before_fc_flag
= phba
->pport
->fc_flag
;
1443 sriov_nr_virtfn
= phba
->cfg_sriov_nr_virtfn
;
1445 /* Disable SR-IOV virtual functions if enabled */
1446 if (phba
->cfg_sriov_nr_virtfn
) {
1447 pci_disable_sriov(pdev
);
1448 phba
->cfg_sriov_nr_virtfn
= 0;
1451 if (opcode
== LPFC_FW_DUMP
)
1452 phba
->hba_flag
|= HBA_FW_DUMP_OP
;
1454 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1457 phba
->hba_flag
&= ~HBA_FW_DUMP_OP
;
1461 /* wait for the device to be quiesced before firmware reset */
1464 reg_val
= readl(phba
->sli4_hba
.conf_regs_memmap_p
+
1465 LPFC_CTL_PDEV_CTL_OFFSET
);
1467 if (opcode
== LPFC_FW_DUMP
)
1468 reg_val
|= LPFC_FW_DUMP_REQUEST
;
1469 else if (opcode
== LPFC_FW_RESET
)
1470 reg_val
|= LPFC_CTL_PDEV_CTL_FRST
;
1471 else if (opcode
== LPFC_DV_RESET
)
1472 reg_val
|= LPFC_CTL_PDEV_CTL_DRST
;
1474 writel(reg_val
, phba
->sli4_hba
.conf_regs_memmap_p
+
1475 LPFC_CTL_PDEV_CTL_OFFSET
);
1477 readl(phba
->sli4_hba
.conf_regs_memmap_p
+ LPFC_CTL_PDEV_CTL_OFFSET
);
1479 /* delay driver action following IF_TYPE_2 reset */
1480 rc
= lpfc_sli4_pdev_status_reg_wait(phba
);
1483 /* no privilege for reset */
1484 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1485 "3150 No privilege to perform the requested "
1486 "access: x%x\n", reg_val
);
1487 } else if (rc
== -EIO
) {
1488 /* reset failed, there is nothing more we can do */
1489 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1490 "3153 Fail to perform the requested "
1491 "access: x%x\n", reg_val
);
1495 /* keep the original port state */
1496 if (before_fc_flag
& FC_OFFLINE_MODE
)
1499 init_completion(&online_compl
);
1500 job_posted
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1505 wait_for_completion(&online_compl
);
1508 /* in any case, restore the virtual functions enabled as before */
1509 if (sriov_nr_virtfn
) {
1511 lpfc_sli_probe_sriov_nr_virtfn(phba
, sriov_nr_virtfn
);
1513 phba
->cfg_sriov_nr_virtfn
= sriov_nr_virtfn
;
1516 /* return proper error code */
1527 * lpfc_nport_evt_cnt_show - Return the number of nport events
1528 * @dev: class device that is converted into a Scsi_host.
1529 * @attr: device attribute, not used.
1530 * @buf: on return contains the ascii number of nport events.
1532 * Returns: size of formatted string.
1535 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
1538 struct Scsi_Host
*shost
= class_to_shost(dev
);
1539 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1540 struct lpfc_hba
*phba
= vport
->phba
;
1542 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
1546 lpfc_set_trunking(struct lpfc_hba
*phba
, char *buff_out
)
1548 LPFC_MBOXQ_t
*mbox
= NULL
;
1549 unsigned long val
= 0;
1553 if (!strncmp("enable", buff_out
,
1554 strlen("enable"))) {
1555 pval
= buff_out
+ strlen("enable") + 1;
1556 rc
= kstrtoul(pval
, 0, &val
);
1558 return rc
; /* Invalid number */
1559 } else if (!strncmp("disable", buff_out
,
1560 strlen("disable"))) {
1563 return -EINVAL
; /* Invalid command */
1568 val
= 0x0; /* Disable */
1571 val
= 0x1; /* Enable two port trunk */
1574 val
= 0x2; /* Enable four port trunk */
1580 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
,
1581 "0070 Set trunk mode with val %ld ", val
);
1583 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1587 lpfc_sli4_config(phba
, mbox
, LPFC_MBOX_SUBSYSTEM_FCOE
,
1588 LPFC_MBOX_OPCODE_FCOE_FC_SET_TRUNK_MODE
,
1589 12, LPFC_SLI4_MBX_EMBED
);
1591 bf_set(lpfc_mbx_set_trunk_mode
,
1592 &mbox
->u
.mqe
.un
.set_trunk_mode
,
1594 rc
= lpfc_sli_issue_mbox(phba
, mbox
, MBX_POLL
);
1596 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
,
1597 "0071 Set trunk mode failed with status: %d",
1599 if (rc
!= MBX_TIMEOUT
)
1600 mempool_free(mbox
, phba
->mbox_mem_pool
);
1606 * lpfc_board_mode_show - Return the state of the board
1607 * @dev: class device that is converted into a Scsi_host.
1608 * @attr: device attribute, not used.
1609 * @buf: on return contains the state of the adapter.
1611 * Returns: size of formatted string.
1614 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
1617 struct Scsi_Host
*shost
= class_to_shost(dev
);
1618 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1619 struct lpfc_hba
*phba
= vport
->phba
;
1622 if (phba
->link_state
== LPFC_HBA_ERROR
)
1624 else if (phba
->link_state
== LPFC_WARM_START
)
1625 state
= "warm start";
1626 else if (phba
->link_state
== LPFC_INIT_START
)
1631 return snprintf(buf
, PAGE_SIZE
, "%s\n", state
);
1635 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1636 * @dev: class device that is converted into a Scsi_host.
1637 * @attr: device attribute, not used.
1638 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1639 * @count: unused variable.
1642 * -EACCES if enable hba reset not enabled
1643 * -EINVAL if the buffer does not contain a valid string (see above)
1644 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1645 * buf length greater than zero indicates success
1648 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
1649 const char *buf
, size_t count
)
1651 struct Scsi_Host
*shost
= class_to_shost(dev
);
1652 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1653 struct lpfc_hba
*phba
= vport
->phba
;
1654 struct completion online_compl
;
1655 char *board_mode_str
= NULL
;
1659 if (!phba
->cfg_enable_hba_reset
) {
1661 goto board_mode_out
;
1664 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1665 "3050 lpfc_board_mode set to %s\n", buf
);
1667 init_completion(&online_compl
);
1669 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
1670 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1674 goto board_mode_out
;
1676 wait_for_completion(&online_compl
);
1679 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
1680 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1681 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
1682 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1685 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
1686 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
1687 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1690 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
1691 else if (strncmp(buf
, "dump", sizeof("dump") - 1) == 0)
1692 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_DUMP
);
1693 else if (strncmp(buf
, "fw_reset", sizeof("fw_reset") - 1) == 0)
1694 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_RESET
);
1695 else if (strncmp(buf
, "dv_reset", sizeof("dv_reset") - 1) == 0)
1696 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_DV_RESET
);
1697 else if (strncmp(buf
, "pci_bus_reset", sizeof("pci_bus_reset") - 1)
1699 status
= lpfc_reset_pci_bus(phba
);
1700 else if (strncmp(buf
, "trunk", sizeof("trunk") - 1) == 0)
1701 status
= lpfc_set_trunking(phba
, (char *)buf
+ sizeof("trunk"));
1709 board_mode_str
= strchr(buf
, '\n');
1711 *board_mode_str
= '\0';
1712 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1713 "3097 Failed \"%s\", status(%d), "
1715 buf
, status
, phba
->pport
->fc_flag
);
1721 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1722 * @phba: pointer to the adapter structure.
1723 * @mxri: max xri count.
1724 * @axri: available xri count.
1725 * @mrpi: max rpi count.
1726 * @arpi: available rpi count.
1727 * @mvpi: max vpi count.
1728 * @avpi: available vpi count.
1731 * If an integer pointer for an count is not null then the value for the
1732 * count is returned.
1739 lpfc_get_hba_info(struct lpfc_hba
*phba
,
1740 uint32_t *mxri
, uint32_t *axri
,
1741 uint32_t *mrpi
, uint32_t *arpi
,
1742 uint32_t *mvpi
, uint32_t *avpi
)
1744 struct lpfc_mbx_read_config
*rd_config
;
1745 LPFC_MBOXQ_t
*pmboxq
;
1751 * prevent udev from issuing mailbox commands until the port is
1754 if (phba
->link_state
< LPFC_LINK_DOWN
||
1755 !phba
->mbox_mem_pool
||
1756 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
1759 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
1762 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1765 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1767 pmb
= &pmboxq
->u
.mb
;
1768 pmb
->mbxCommand
= MBX_READ_CONFIG
;
1769 pmb
->mbxOwner
= OWN_HOST
;
1770 pmboxq
->ctx_buf
= NULL
;
1772 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
1773 rc
= MBX_NOT_FINISHED
;
1775 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
1777 if (rc
!= MBX_SUCCESS
) {
1778 if (rc
!= MBX_TIMEOUT
)
1779 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1783 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1784 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
1786 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
1788 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
1789 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
1791 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
1793 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
1794 phba
->sli4_hba
.max_cfg_param
.xri_used
;
1796 /* Account for differences with SLI-3. Get vpi count from
1797 * mailbox data and subtract one for max vpi value.
1799 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
1800 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
1802 /* Limit the max we support */
1803 if (max_vpi
> LPFC_MAX_VPI
)
1804 max_vpi
= LPFC_MAX_VPI
;
1808 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
1811 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
1813 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
1815 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
1817 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
1819 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
1821 /* avail_vpi is only valid if link is up and ready */
1822 if (phba
->link_state
== LPFC_HBA_READY
)
1823 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
1825 *avpi
= pmb
->un
.varRdConfig
.max_vpi
;
1829 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1834 * lpfc_max_rpi_show - Return maximum rpi
1835 * @dev: class device that is converted into a Scsi_host.
1836 * @attr: device attribute, not used.
1837 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1840 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1841 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1842 * to "Unknown" and the buffer length is returned, therefore the caller
1843 * must check for "Unknown" in the buffer to detect a failure.
1845 * Returns: size of formatted string.
1848 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1851 struct Scsi_Host
*shost
= class_to_shost(dev
);
1852 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1853 struct lpfc_hba
*phba
= vport
->phba
;
1856 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
1857 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1858 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1862 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1863 * @dev: class device that is converted into a Scsi_host.
1864 * @attr: device attribute, not used.
1865 * @buf: containing the used rpi count in decimal or "Unknown".
1868 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1869 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1870 * to "Unknown" and the buffer length is returned, therefore the caller
1871 * must check for "Unknown" in the buffer to detect a failure.
1873 * Returns: size of formatted string.
1876 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1879 struct Scsi_Host
*shost
= class_to_shost(dev
);
1880 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1881 struct lpfc_hba
*phba
= vport
->phba
;
1884 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1885 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1886 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1890 * lpfc_max_xri_show - Return maximum xri
1891 * @dev: class device that is converted into a Scsi_host.
1892 * @attr: device attribute, not used.
1893 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1896 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1897 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1898 * to "Unknown" and the buffer length is returned, therefore the caller
1899 * must check for "Unknown" in the buffer to detect a failure.
1901 * Returns: size of formatted string.
1904 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1907 struct Scsi_Host
*shost
= class_to_shost(dev
);
1908 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1909 struct lpfc_hba
*phba
= vport
->phba
;
1912 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
1913 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1914 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1918 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1919 * @dev: class device that is converted into a Scsi_host.
1920 * @attr: device attribute, not used.
1921 * @buf: on return contains the used xri count in decimal or "Unknown".
1924 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1925 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1926 * to "Unknown" and the buffer length is returned, therefore the caller
1927 * must check for "Unknown" in the buffer to detect a failure.
1929 * Returns: size of formatted string.
1932 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1935 struct Scsi_Host
*shost
= class_to_shost(dev
);
1936 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1937 struct lpfc_hba
*phba
= vport
->phba
;
1940 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
1941 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1942 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1946 * lpfc_max_vpi_show - Return maximum vpi
1947 * @dev: class device that is converted into a Scsi_host.
1948 * @attr: device attribute, not used.
1949 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1952 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1953 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1954 * to "Unknown" and the buffer length is returned, therefore the caller
1955 * must check for "Unknown" in the buffer to detect a failure.
1957 * Returns: size of formatted string.
1960 lpfc_max_vpi_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
;
1968 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
1969 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1970 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1974 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1975 * @dev: class device that is converted into a Scsi_host.
1976 * @attr: device attribute, not used.
1977 * @buf: on return contains the used vpi count in decimal or "Unknown".
1980 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1981 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1982 * to "Unknown" and the buffer length is returned, therefore the caller
1983 * must check for "Unknown" in the buffer to detect a failure.
1985 * Returns: size of formatted string.
1988 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1991 struct Scsi_Host
*shost
= class_to_shost(dev
);
1992 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1993 struct lpfc_hba
*phba
= vport
->phba
;
1996 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
1997 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1998 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
2002 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
2003 * @dev: class device that is converted into a Scsi_host.
2004 * @attr: device attribute, not used.
2005 * @buf: text that must be interpreted to determine if npiv is supported.
2008 * Buffer will contain text indicating npiv is not suppoerted on the port,
2009 * the port is an NPIV physical port, or it is an npiv virtual port with
2010 * the id of the vport.
2012 * Returns: size of formatted string.
2015 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
2018 struct Scsi_Host
*shost
= class_to_shost(dev
);
2019 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2020 struct lpfc_hba
*phba
= vport
->phba
;
2022 if (!(phba
->max_vpi
))
2023 return snprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
2024 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
2025 return snprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
2026 return snprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
2030 * lpfc_poll_show - Return text about poll support for the adapter
2031 * @dev: class device that is converted into a Scsi_host.
2032 * @attr: device attribute, not used.
2033 * @buf: on return contains the cfg_poll in hex.
2036 * cfg_poll should be a lpfc_polling_flags type.
2038 * Returns: size of formatted string.
2041 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
2044 struct Scsi_Host
*shost
= class_to_shost(dev
);
2045 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2046 struct lpfc_hba
*phba
= vport
->phba
;
2048 return snprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
2052 * lpfc_poll_store - Set the value of cfg_poll for the adapter
2053 * @dev: class device that is converted into a Scsi_host.
2054 * @attr: device attribute, not used.
2055 * @buf: one or more lpfc_polling_flags values.
2059 * buf contents converted to integer and checked for a valid value.
2062 * -EINVAL if the buffer connot be converted or is out of range
2063 * length of the buf on success
2066 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
2067 const char *buf
, size_t count
)
2069 struct Scsi_Host
*shost
= class_to_shost(dev
);
2070 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2071 struct lpfc_hba
*phba
= vport
->phba
;
2076 if (!isdigit(buf
[0]))
2079 if (sscanf(buf
, "%i", &val
) != 1)
2082 if ((val
& 0x3) != val
)
2085 if (phba
->sli_rev
== LPFC_SLI_REV4
)
2088 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2089 "3051 lpfc_poll changed from %d to %d\n",
2090 phba
->cfg_poll
, val
);
2092 spin_lock_irq(&phba
->hbalock
);
2094 old_val
= phba
->cfg_poll
;
2096 if (val
& ENABLE_FCP_RING_POLLING
) {
2097 if ((val
& DISABLE_FCP_RING_INT
) &&
2098 !(old_val
& DISABLE_FCP_RING_INT
)) {
2099 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
2100 spin_unlock_irq(&phba
->hbalock
);
2103 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
2104 writel(creg_val
, phba
->HCregaddr
);
2105 readl(phba
->HCregaddr
); /* flush */
2107 lpfc_poll_start_timer(phba
);
2109 } else if (val
!= 0x0) {
2110 spin_unlock_irq(&phba
->hbalock
);
2114 if (!(val
& DISABLE_FCP_RING_INT
) &&
2115 (old_val
& DISABLE_FCP_RING_INT
))
2117 spin_unlock_irq(&phba
->hbalock
);
2118 del_timer(&phba
->fcp_poll_timer
);
2119 spin_lock_irq(&phba
->hbalock
);
2120 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
2121 spin_unlock_irq(&phba
->hbalock
);
2124 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
2125 writel(creg_val
, phba
->HCregaddr
);
2126 readl(phba
->HCregaddr
); /* flush */
2129 phba
->cfg_poll
= val
;
2131 spin_unlock_irq(&phba
->hbalock
);
2137 * lpfc_fips_level_show - Return the current FIPS level for the HBA
2138 * @dev: class unused variable.
2139 * @attr: device attribute, not used.
2140 * @buf: on return contains the module description text.
2142 * Returns: size of formatted string.
2145 lpfc_fips_level_show(struct device
*dev
, struct device_attribute
*attr
,
2148 struct Scsi_Host
*shost
= class_to_shost(dev
);
2149 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2150 struct lpfc_hba
*phba
= vport
->phba
;
2152 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_level
);
2156 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
2157 * @dev: class unused variable.
2158 * @attr: device attribute, not used.
2159 * @buf: on return contains the module description text.
2161 * Returns: size of formatted string.
2164 lpfc_fips_rev_show(struct device
*dev
, struct device_attribute
*attr
,
2167 struct Scsi_Host
*shost
= class_to_shost(dev
);
2168 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2169 struct lpfc_hba
*phba
= vport
->phba
;
2171 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_spec_rev
);
2175 * lpfc_dss_show - Return the current state of dss and the configured state
2176 * @dev: class converted to a Scsi_host structure.
2177 * @attr: device attribute, not used.
2178 * @buf: on return contains the formatted text.
2180 * Returns: size of formatted string.
2183 lpfc_dss_show(struct device
*dev
, struct device_attribute
*attr
,
2186 struct Scsi_Host
*shost
= class_to_shost(dev
);
2187 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2188 struct lpfc_hba
*phba
= vport
->phba
;
2190 return snprintf(buf
, PAGE_SIZE
, "%s - %sOperational\n",
2191 (phba
->cfg_enable_dss
) ? "Enabled" : "Disabled",
2192 (phba
->sli3_options
& LPFC_SLI3_DSS_ENABLED
) ?
2197 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
2198 * @dev: class converted to a Scsi_host structure.
2199 * @attr: device attribute, not used.
2200 * @buf: on return contains the formatted support level.
2203 * Returns the maximum number of virtual functions a physical function can
2204 * support, 0 will be returned if called on virtual function.
2206 * Returns: size of formatted string.
2209 lpfc_sriov_hw_max_virtfn_show(struct device
*dev
,
2210 struct device_attribute
*attr
,
2213 struct Scsi_Host
*shost
= class_to_shost(dev
);
2214 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2215 struct lpfc_hba
*phba
= vport
->phba
;
2216 uint16_t max_nr_virtfn
;
2218 max_nr_virtfn
= lpfc_sli_sriov_nr_virtfn_get(phba
);
2219 return snprintf(buf
, PAGE_SIZE
, "%d\n", max_nr_virtfn
);
2222 static inline bool lpfc_rangecheck(uint val
, uint min
, uint max
)
2224 return val
>= min
&& val
<= max
;
2228 * lpfc_enable_bbcr_set: Sets an attribute value.
2229 * @phba: pointer the the adapter structure.
2230 * @val: integer attribute value.
2233 * Validates the min and max values then sets the
2234 * adapter config field if in the valid range. prints error message
2235 * and does not set the parameter if invalid.
2239 * -EINVAL if val is invalid
2242 lpfc_enable_bbcr_set(struct lpfc_hba
*phba
, uint val
)
2244 if (lpfc_rangecheck(val
, 0, 1) && phba
->sli_rev
== LPFC_SLI_REV4
) {
2245 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2246 "3068 %s_enable_bbcr changed from %d to %d\n",
2247 LPFC_DRIVER_NAME
, phba
->cfg_enable_bbcr
, val
);
2248 phba
->cfg_enable_bbcr
= val
;
2251 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2252 "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n",
2253 LPFC_DRIVER_NAME
, val
);
2258 * lpfc_param_show - Return a cfg attribute value in decimal
2261 * Macro that given an attr e.g. hba_queue_depth expands
2262 * into a function with the name lpfc_hba_queue_depth_show.
2264 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
2265 * @dev: class device that is converted into a Scsi_host.
2266 * @attr: device attribute, not used.
2267 * @buf: on return contains the attribute value in decimal.
2269 * Returns: size of formatted string.
2271 #define lpfc_param_show(attr) \
2273 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2276 struct Scsi_Host *shost = class_to_shost(dev);\
2277 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2278 struct lpfc_hba *phba = vport->phba;\
2279 return snprintf(buf, PAGE_SIZE, "%d\n",\
2284 * lpfc_param_hex_show - Return a cfg attribute value in hex
2287 * Macro that given an attr e.g. hba_queue_depth expands
2288 * into a function with the name lpfc_hba_queue_depth_show
2290 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
2291 * @dev: class device that is converted into a Scsi_host.
2292 * @attr: device attribute, not used.
2293 * @buf: on return contains the attribute value in hexadecimal.
2295 * Returns: size of formatted string.
2297 #define lpfc_param_hex_show(attr) \
2299 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2302 struct Scsi_Host *shost = class_to_shost(dev);\
2303 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2304 struct lpfc_hba *phba = vport->phba;\
2306 val = phba->cfg_##attr;\
2307 return snprintf(buf, PAGE_SIZE, "%#x\n",\
2312 * lpfc_param_init - Initializes a cfg attribute
2315 * Macro that given an attr e.g. hba_queue_depth expands
2316 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2317 * takes a default argument, a minimum and maximum argument.
2319 * lpfc_##attr##_init: Initializes an attribute.
2320 * @phba: pointer the the adapter structure.
2321 * @val: integer attribute value.
2323 * Validates the min and max values then sets the adapter config field
2324 * accordingly, or uses the default if out of range and prints an error message.
2328 * -EINVAL if default used
2330 #define lpfc_param_init(attr, default, minval, maxval) \
2332 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
2334 if (lpfc_rangecheck(val, minval, maxval)) {\
2335 phba->cfg_##attr = val;\
2338 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2339 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
2340 "allowed range is ["#minval", "#maxval"]\n", val); \
2341 phba->cfg_##attr = default;\
2346 * lpfc_param_set - Set a cfg attribute value
2349 * Macro that given an attr e.g. hba_queue_depth expands
2350 * into a function with the name lpfc_hba_queue_depth_set
2352 * lpfc_##attr##_set: Sets an attribute value.
2353 * @phba: pointer the the adapter structure.
2354 * @val: integer attribute value.
2357 * Validates the min and max values then sets the
2358 * adapter config field if in the valid range. prints error message
2359 * and does not set the parameter if invalid.
2363 * -EINVAL if val is invalid
2365 #define lpfc_param_set(attr, default, minval, maxval) \
2367 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
2369 if (lpfc_rangecheck(val, minval, maxval)) {\
2370 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2371 "3052 lpfc_" #attr " changed from %d to %d\n", \
2372 phba->cfg_##attr, val); \
2373 phba->cfg_##attr = val;\
2376 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2377 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
2378 "allowed range is ["#minval", "#maxval"]\n", val); \
2383 * lpfc_param_store - Set a vport attribute value
2386 * Macro that given an attr e.g. hba_queue_depth expands
2387 * into a function with the name lpfc_hba_queue_depth_store.
2389 * lpfc_##attr##_store: Set an sttribute value.
2390 * @dev: class device that is converted into a Scsi_host.
2391 * @attr: device attribute, not used.
2392 * @buf: contains the attribute value in ascii.
2396 * Convert the ascii text number to an integer, then
2397 * use the lpfc_##attr##_set function to set the value.
2400 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2401 * length of buffer upon success.
2403 #define lpfc_param_store(attr) \
2405 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2406 const char *buf, size_t count) \
2408 struct Scsi_Host *shost = class_to_shost(dev);\
2409 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2410 struct lpfc_hba *phba = vport->phba;\
2412 if (!isdigit(buf[0]))\
2414 if (sscanf(buf, "%i", &val) != 1)\
2416 if (lpfc_##attr##_set(phba, val) == 0) \
2417 return strlen(buf);\
2423 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
2426 * Macro that given an attr e.g. hba_queue_depth expands
2427 * into a function with the name lpfc_hba_queue_depth_show
2429 * lpfc_##attr##_show: prints the attribute value in decimal.
2430 * @dev: class device that is converted into a Scsi_host.
2431 * @attr: device attribute, not used.
2432 * @buf: on return contains the attribute value in decimal.
2434 * Returns: length of formatted string.
2436 #define lpfc_vport_param_show(attr) \
2438 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2441 struct Scsi_Host *shost = class_to_shost(dev);\
2442 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2443 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
2447 * lpfc_vport_param_hex_show - Return hex formatted attribute value
2450 * Macro that given an attr e.g.
2451 * hba_queue_depth expands into a function with the name
2452 * lpfc_hba_queue_depth_show
2454 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
2455 * @dev: class device that is converted into a Scsi_host.
2456 * @attr: device attribute, not used.
2457 * @buf: on return contains the attribute value in hexadecimal.
2459 * Returns: length of formatted string.
2461 #define lpfc_vport_param_hex_show(attr) \
2463 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2466 struct Scsi_Host *shost = class_to_shost(dev);\
2467 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2468 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
2472 * lpfc_vport_param_init - Initialize a vport cfg attribute
2475 * Macro that given an attr e.g. hba_queue_depth expands
2476 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2477 * takes a default argument, a minimum and maximum argument.
2479 * lpfc_##attr##_init: validates the min and max values then sets the
2480 * adapter config field accordingly, or uses the default if out of range
2481 * and prints an error message.
2482 * @phba: pointer the the adapter structure.
2483 * @val: integer attribute value.
2487 * -EINVAL if default used
2489 #define lpfc_vport_param_init(attr, default, minval, maxval) \
2491 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
2493 if (lpfc_rangecheck(val, minval, maxval)) {\
2494 vport->cfg_##attr = val;\
2497 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2498 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
2499 "allowed range is ["#minval", "#maxval"]\n", val); \
2500 vport->cfg_##attr = default;\
2505 * lpfc_vport_param_set - Set a vport cfg attribute
2508 * Macro that given an attr e.g. hba_queue_depth expands
2509 * into a function with the name lpfc_hba_queue_depth_set
2511 * lpfc_##attr##_set: validates the min and max values then sets the
2512 * adapter config field if in the valid range. prints error message
2513 * and does not set the parameter if invalid.
2514 * @phba: pointer the the adapter structure.
2515 * @val: integer attribute value.
2519 * -EINVAL if val is invalid
2521 #define lpfc_vport_param_set(attr, default, minval, maxval) \
2523 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
2525 if (lpfc_rangecheck(val, minval, maxval)) {\
2526 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2527 "3053 lpfc_" #attr \
2528 " changed from %d (x%x) to %d (x%x)\n", \
2529 vport->cfg_##attr, vport->cfg_##attr, \
2531 vport->cfg_##attr = val;\
2534 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2535 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
2536 "allowed range is ["#minval", "#maxval"]\n", val); \
2541 * lpfc_vport_param_store - Set a vport attribute
2544 * Macro that given an attr e.g. hba_queue_depth
2545 * expands into a function with the name lpfc_hba_queue_depth_store
2547 * lpfc_##attr##_store: convert the ascii text number to an integer, then
2548 * use the lpfc_##attr##_set function to set the value.
2549 * @cdev: class device that is converted into a Scsi_host.
2550 * @buf: contains the attribute value in decimal.
2554 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2555 * length of buffer upon success.
2557 #define lpfc_vport_param_store(attr) \
2559 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2560 const char *buf, size_t count) \
2562 struct Scsi_Host *shost = class_to_shost(dev);\
2563 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2565 if (!isdigit(buf[0]))\
2567 if (sscanf(buf, "%i", &val) != 1)\
2569 if (lpfc_##attr##_set(vport, val) == 0) \
2570 return strlen(buf);\
2576 static DEVICE_ATTR(nvme_info
, 0444, lpfc_nvme_info_show
, NULL
);
2577 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
2578 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
2579 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
2580 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
2581 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
2582 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
2583 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
2584 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
2585 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
2586 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
2587 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
2588 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
2589 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
2590 lpfc_link_state_store
);
2591 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
2592 lpfc_option_rom_version_show
, NULL
);
2593 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
2594 lpfc_num_discovered_ports_show
, NULL
);
2595 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
2596 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
2597 static DEVICE_ATTR_RO(lpfc_drvr_version
);
2598 static DEVICE_ATTR_RO(lpfc_enable_fip
);
2599 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
2600 lpfc_board_mode_show
, lpfc_board_mode_store
);
2601 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
2602 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
2603 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
2604 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
2605 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
2606 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
2607 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
2608 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
2609 static DEVICE_ATTR_RO(lpfc_temp_sensor
);
2610 static DEVICE_ATTR_RO(lpfc_fips_level
);
2611 static DEVICE_ATTR_RO(lpfc_fips_rev
);
2612 static DEVICE_ATTR_RO(lpfc_dss
);
2613 static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn
);
2614 static DEVICE_ATTR(protocol
, S_IRUGO
, lpfc_sli4_protocol_show
, NULL
);
2615 static DEVICE_ATTR(lpfc_xlane_supported
, S_IRUGO
, lpfc_oas_supported_show
,
2618 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
2621 * lpfc_wwn_set - Convert string to the 8 byte WWN value.
2623 * @cnt: Length of string.
2624 * @wwn: Array to receive converted wwn value.
2627 * -EINVAL if the buffer does not contain a valid wwn
2631 lpfc_wwn_set(const char *buf
, size_t cnt
, char wwn
[])
2635 /* Count may include a LF at end of string */
2636 if (buf
[cnt
-1] == '\n')
2639 if ((cnt
< 16) || (cnt
> 18) || ((cnt
== 17) && (*buf
++ != 'x')) ||
2640 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2643 memset(wwn
, 0, WWN_SZ
);
2645 /* Validate and store the new name */
2646 for (i
= 0, j
= 0; i
< 16; i
++) {
2647 if ((*buf
>= 'a') && (*buf
<= 'f'))
2648 j
= ((j
<< 4) | ((*buf
++ - 'a') + 10));
2649 else if ((*buf
>= 'A') && (*buf
<= 'F'))
2650 j
= ((j
<< 4) | ((*buf
++ - 'A') + 10));
2651 else if ((*buf
>= '0') && (*buf
<= '9'))
2652 j
= ((j
<< 4) | (*buf
++ - '0'));
2656 wwn
[i
/2] = j
& 0xff;
2663 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2664 * @dev: class device that is converted into a Scsi_host.
2665 * @attr: device attribute, not used.
2666 * @buf: containing the string lpfc_soft_wwn_key.
2667 * @count: must be size of lpfc_soft_wwn_key.
2670 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2671 * length of buf indicates success
2674 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
2675 const char *buf
, size_t count
)
2677 struct Scsi_Host
*shost
= class_to_shost(dev
);
2678 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2679 struct lpfc_hba
*phba
= vport
->phba
;
2680 unsigned int cnt
= count
;
2681 uint8_t vvvl
= vport
->fc_sparam
.cmn
.valid_vendor_ver_level
;
2682 u32
*fawwpn_key
= (uint32_t *)&vport
->fc_sparam
.un
.vendorVersion
[0];
2685 * We're doing a simple sanity check for soft_wwpn setting.
2686 * We require that the user write a specific key to enable
2687 * the soft_wwpn attribute to be settable. Once the attribute
2688 * is written, the enable key resets. If further updates are
2689 * desired, the key must be written again to re-enable the
2692 * The "key" is not secret - it is a hardcoded string shown
2693 * here. The intent is to protect against the random user or
2694 * application that is just writing attributes.
2696 if (vvvl
== 1 && cpu_to_be32(*fawwpn_key
) == FAPWWN_KEY_VENDOR
) {
2697 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2698 "0051 "LPFC_DRIVER_NAME
" soft wwpn can not"
2699 " be enabled: fawwpn is enabled\n");
2703 /* count may include a LF at end of string */
2704 if (buf
[cnt
-1] == '\n')
2707 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
2708 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
2711 phba
->soft_wwn_enable
= 1;
2713 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2714 "lpfc%d: soft_wwpn assignment has been enabled.\n",
2716 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2717 " The soft_wwpn feature is not supported by Broadcom.");
2721 static DEVICE_ATTR_WO(lpfc_soft_wwn_enable
);
2724 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2725 * @dev: class device that is converted into a Scsi_host.
2726 * @attr: device attribute, not used.
2727 * @buf: on return contains the wwpn in hexadecimal.
2729 * Returns: size of formatted string.
2732 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
2735 struct Scsi_Host
*shost
= class_to_shost(dev
);
2736 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2737 struct lpfc_hba
*phba
= vport
->phba
;
2739 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2740 (unsigned long long)phba
->cfg_soft_wwpn
);
2744 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2745 * @dev class device that is converted into a Scsi_host.
2746 * @attr: device attribute, not used.
2747 * @buf: contains the wwpn in hexadecimal.
2748 * @count: number of wwpn bytes in buf
2751 * -EACCES hba reset not enabled, adapter over temp
2752 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2753 * -EIO error taking adapter offline or online
2754 * value of count on success
2757 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
2758 const char *buf
, size_t count
)
2760 struct Scsi_Host
*shost
= class_to_shost(dev
);
2761 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2762 struct lpfc_hba
*phba
= vport
->phba
;
2763 struct completion online_compl
;
2764 int stat1
= 0, stat2
= 0;
2765 unsigned int cnt
= count
;
2769 if (!phba
->cfg_enable_hba_reset
)
2771 spin_lock_irq(&phba
->hbalock
);
2772 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
2773 spin_unlock_irq(&phba
->hbalock
);
2776 spin_unlock_irq(&phba
->hbalock
);
2777 /* count may include a LF at end of string */
2778 if (buf
[cnt
-1] == '\n')
2781 if (!phba
->soft_wwn_enable
)
2784 /* lock setting wwpn, wwnn down */
2785 phba
->soft_wwn_enable
= 0;
2787 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2789 /* not able to set wwpn, unlock it */
2790 phba
->soft_wwn_enable
= 1;
2794 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
2795 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
2796 if (phba
->cfg_soft_wwnn
)
2797 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
2799 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2800 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
2802 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
2804 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2805 "0463 lpfc_soft_wwpn attribute set failed to "
2806 "reinit adapter - %d\n", stat1
);
2807 init_completion(&online_compl
);
2808 rc
= lpfc_workq_post_event(phba
, &stat2
, &online_compl
,
2813 wait_for_completion(&online_compl
);
2815 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2816 "0464 lpfc_soft_wwpn attribute set failed to "
2817 "reinit adapter - %d\n", stat2
);
2818 return (stat1
|| stat2
) ? -EIO
: count
;
2820 static DEVICE_ATTR_RW(lpfc_soft_wwpn
);
2823 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2824 * @dev: class device that is converted into a Scsi_host.
2825 * @attr: device attribute, not used.
2826 * @buf: on return contains the wwnn in hexadecimal.
2828 * Returns: size of formatted string.
2831 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
2834 struct Scsi_Host
*shost
= class_to_shost(dev
);
2835 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2836 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2837 (unsigned long long)phba
->cfg_soft_wwnn
);
2841 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2842 * @cdev: class device that is converted into a Scsi_host.
2843 * @buf: contains the ww node name in hexadecimal.
2844 * @count: number of wwnn bytes in buf.
2847 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2848 * value of count on success
2851 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
2852 const char *buf
, size_t count
)
2854 struct Scsi_Host
*shost
= class_to_shost(dev
);
2855 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2856 unsigned int cnt
= count
;
2860 /* count may include a LF at end of string */
2861 if (buf
[cnt
-1] == '\n')
2864 if (!phba
->soft_wwn_enable
)
2867 rc
= lpfc_wwn_set(buf
, cnt
, wwnn
);
2869 /* Allow wwnn to be set many times, as long as the enable
2870 * is set. However, once the wwpn is set, everything locks.
2875 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
2877 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2878 "lpfc%d: soft_wwnn set. Value will take effect upon "
2879 "setting of the soft_wwpn\n", phba
->brd_no
);
2883 static DEVICE_ATTR_RW(lpfc_soft_wwnn
);
2886 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for
2887 * Optimized Access Storage (OAS) operations.
2888 * @dev: class device that is converted into a Scsi_host.
2889 * @attr: device attribute, not used.
2890 * @buf: buffer for passing information.
2896 lpfc_oas_tgt_show(struct device
*dev
, struct device_attribute
*attr
,
2899 struct Scsi_Host
*shost
= class_to_shost(dev
);
2900 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2902 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2903 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
));
2907 * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for
2908 * Optimized Access Storage (OAS) operations.
2909 * @dev: class device that is converted into a Scsi_host.
2910 * @attr: device attribute, not used.
2911 * @buf: buffer for passing information.
2912 * @count: Size of the data buffer.
2915 * -EINVAL count is invalid, invalid wwpn byte invalid
2916 * -EPERM oas is not supported by hba
2917 * value of count on success
2920 lpfc_oas_tgt_store(struct device
*dev
, struct device_attribute
*attr
,
2921 const char *buf
, size_t count
)
2923 struct Scsi_Host
*shost
= class_to_shost(dev
);
2924 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2925 unsigned int cnt
= count
;
2926 uint8_t wwpn
[WWN_SZ
];
2932 /* count may include a LF at end of string */
2933 if (buf
[cnt
-1] == '\n')
2936 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2940 memcpy(phba
->cfg_oas_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2941 memcpy(phba
->sli4_hba
.oas_next_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2942 if (wwn_to_u64(wwpn
) == 0)
2943 phba
->cfg_oas_flags
|= OAS_FIND_ANY_TARGET
;
2945 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_TARGET
;
2946 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2947 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2950 static DEVICE_ATTR(lpfc_xlane_tgt
, S_IRUGO
| S_IWUSR
,
2951 lpfc_oas_tgt_show
, lpfc_oas_tgt_store
);
2954 * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for
2955 * Optimized Access Storage (OAS) operations.
2956 * @dev: class device that is converted into a Scsi_host.
2957 * @attr: device attribute, not used.
2958 * @buf: buffer for passing information.
2964 lpfc_oas_priority_show(struct device
*dev
, struct device_attribute
*attr
,
2967 struct Scsi_Host
*shost
= class_to_shost(dev
);
2968 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2970 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_priority
);
2974 * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for
2975 * Optimized Access Storage (OAS) operations.
2976 * @dev: class device that is converted into a Scsi_host.
2977 * @attr: device attribute, not used.
2978 * @buf: buffer for passing information.
2979 * @count: Size of the data buffer.
2982 * -EINVAL count is invalid, invalid wwpn byte invalid
2983 * -EPERM oas is not supported by hba
2984 * value of count on success
2987 lpfc_oas_priority_store(struct device
*dev
, struct device_attribute
*attr
,
2988 const char *buf
, size_t count
)
2990 struct Scsi_Host
*shost
= class_to_shost(dev
);
2991 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2992 unsigned int cnt
= count
;
2999 /* count may include a LF at end of string */
3000 if (buf
[cnt
-1] == '\n')
3003 ret
= kstrtoul(buf
, 0, &val
);
3004 if (ret
|| (val
> 0x7f))
3008 phba
->cfg_oas_priority
= (uint8_t)val
;
3010 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
3013 static DEVICE_ATTR(lpfc_xlane_priority
, S_IRUGO
| S_IWUSR
,
3014 lpfc_oas_priority_show
, lpfc_oas_priority_store
);
3017 * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled
3018 * for Optimized Access Storage (OAS) operations.
3019 * @dev: class device that is converted into a Scsi_host.
3020 * @attr: device attribute, not used.
3021 * @buf: buffer for passing information.
3024 * value of count on success
3027 lpfc_oas_vpt_show(struct device
*dev
, struct device_attribute
*attr
,
3030 struct Scsi_Host
*shost
= class_to_shost(dev
);
3031 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3033 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
3034 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
));
3038 * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled
3039 * for Optimized Access Storage (OAS) operations.
3040 * @dev: class device that is converted into a Scsi_host.
3041 * @attr: device attribute, not used.
3042 * @buf: buffer for passing information.
3043 * @count: Size of the data buffer.
3046 * -EINVAL count is invalid, invalid wwpn byte invalid
3047 * -EPERM oas is not supported by hba
3048 * value of count on success
3051 lpfc_oas_vpt_store(struct device
*dev
, struct device_attribute
*attr
,
3052 const char *buf
, size_t count
)
3054 struct Scsi_Host
*shost
= class_to_shost(dev
);
3055 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3056 unsigned int cnt
= count
;
3057 uint8_t wwpn
[WWN_SZ
];
3063 /* count may include a LF at end of string */
3064 if (buf
[cnt
-1] == '\n')
3067 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
3071 memcpy(phba
->cfg_oas_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
3072 memcpy(phba
->sli4_hba
.oas_next_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
3073 if (wwn_to_u64(wwpn
) == 0)
3074 phba
->cfg_oas_flags
|= OAS_FIND_ANY_VPORT
;
3076 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_VPORT
;
3077 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
3078 if (phba
->cfg_oas_priority
== 0)
3079 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
3080 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
3083 static DEVICE_ATTR(lpfc_xlane_vpt
, S_IRUGO
| S_IWUSR
,
3084 lpfc_oas_vpt_show
, lpfc_oas_vpt_store
);
3087 * lpfc_oas_lun_state_show - Return the current state (enabled or disabled)
3088 * of whether luns will be enabled or disabled
3089 * for Optimized Access Storage (OAS) operations.
3090 * @dev: class device that is converted into a Scsi_host.
3091 * @attr: device attribute, not used.
3092 * @buf: buffer for passing information.
3095 * size of formatted string.
3098 lpfc_oas_lun_state_show(struct device
*dev
, struct device_attribute
*attr
,
3101 struct Scsi_Host
*shost
= class_to_shost(dev
);
3102 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3104 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_state
);
3108 * lpfc_oas_lun_state_store - Store the state (enabled or disabled)
3109 * of whether luns will be enabled or disabled
3110 * for Optimized Access Storage (OAS) operations.
3111 * @dev: class device that is converted into a Scsi_host.
3112 * @attr: device attribute, not used.
3113 * @buf: buffer for passing information.
3114 * @count: Size of the data buffer.
3117 * -EINVAL count is invalid, invalid wwpn byte invalid
3118 * -EPERM oas is not supported by hba
3119 * value of count on success
3122 lpfc_oas_lun_state_store(struct device
*dev
, struct device_attribute
*attr
,
3123 const char *buf
, size_t count
)
3125 struct Scsi_Host
*shost
= class_to_shost(dev
);
3126 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3132 if (!isdigit(buf
[0]))
3135 if (sscanf(buf
, "%i", &val
) != 1)
3138 if ((val
!= 0) && (val
!= 1))
3141 phba
->cfg_oas_lun_state
= val
;
3144 static DEVICE_ATTR(lpfc_xlane_lun_state
, S_IRUGO
| S_IWUSR
,
3145 lpfc_oas_lun_state_show
, lpfc_oas_lun_state_store
);
3148 * lpfc_oas_lun_status_show - Return the status of the Optimized Access
3149 * Storage (OAS) lun returned by the
3150 * lpfc_oas_lun_show function.
3151 * @dev: class device that is converted into a Scsi_host.
3152 * @attr: device attribute, not used.
3153 * @buf: buffer for passing information.
3156 * size of formatted string.
3159 lpfc_oas_lun_status_show(struct device
*dev
, struct device_attribute
*attr
,
3162 struct Scsi_Host
*shost
= class_to_shost(dev
);
3163 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3165 if (!(phba
->cfg_oas_flags
& OAS_LUN_VALID
))
3168 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_status
);
3170 static DEVICE_ATTR(lpfc_xlane_lun_status
, S_IRUGO
,
3171 lpfc_oas_lun_status_show
, NULL
);
3175 * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage
3177 * @phba: lpfc_hba pointer.
3178 * @ndlp: pointer to fcp target node.
3179 * @lun: the fc lun for setting oas state.
3180 * @oas_state: the oas state to be set to the lun.
3184 * -EPERM OAS is not enabled or not supported by this port.
3188 lpfc_oas_lun_state_set(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
3189 uint8_t tgt_wwpn
[], uint64_t lun
,
3190 uint32_t oas_state
, uint8_t pri
)
3199 if (!lpfc_enable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
3200 (struct lpfc_name
*)tgt_wwpn
,
3204 lpfc_disable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
3205 (struct lpfc_name
*)tgt_wwpn
, lun
, pri
);
3212 * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized
3213 * Access Storage (OAS) operations.
3214 * @phba: lpfc_hba pointer.
3215 * @vpt_wwpn: wwpn of the vport associated with the returned lun
3216 * @tgt_wwpn: wwpn of the target associated with the returned lun
3217 * @lun_status: status of the lun returned lun
3219 * Returns the first or next lun enabled for OAS operations for the vport/target
3220 * specified. If a lun is found, its vport wwpn, target wwpn and status is
3221 * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned.
3224 * lun that is OAS enabled for the vport/target
3225 * NOT_OAS_ENABLED_LUN when no oas enabled lun found.
3228 lpfc_oas_lun_get_next(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
3229 uint8_t tgt_wwpn
[], uint32_t *lun_status
,
3234 if (unlikely(!phba
) || !vpt_wwpn
|| !tgt_wwpn
)
3235 return NOT_OAS_ENABLED_LUN
;
3236 if (lpfc_find_next_oas_lun(phba
, (struct lpfc_name
*)
3237 phba
->sli4_hba
.oas_next_vpt_wwpn
,
3238 (struct lpfc_name
*)
3239 phba
->sli4_hba
.oas_next_tgt_wwpn
,
3240 &phba
->sli4_hba
.oas_next_lun
,
3241 (struct lpfc_name
*)vpt_wwpn
,
3242 (struct lpfc_name
*)tgt_wwpn
,
3243 &found_lun
, lun_status
, lun_pri
))
3246 return NOT_OAS_ENABLED_LUN
;
3250 * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations
3251 * @phba: lpfc_hba pointer.
3252 * @vpt_wwpn: vport wwpn by reference.
3253 * @tgt_wwpn: target wwpn by reference.
3254 * @lun: the fc lun for setting oas state.
3255 * @oas_state: the oas state to be set to the oas_lun.
3257 * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE)
3258 * a lun for OAS operations.
3262 * -ENOMEM: failed to enable an lun for OAS operations
3263 * -EPERM: OAS is not enabled
3266 lpfc_oas_lun_state_change(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
3267 uint8_t tgt_wwpn
[], uint64_t lun
,
3268 uint32_t oas_state
, uint8_t pri
)
3273 rc
= lpfc_oas_lun_state_set(phba
, vpt_wwpn
, tgt_wwpn
, lun
,
3279 * lpfc_oas_lun_show - Return oas enabled luns from a chosen target
3280 * @dev: class device that is converted into a Scsi_host.
3281 * @attr: device attribute, not used.
3282 * @buf: buffer for passing information.
3284 * This routine returns a lun enabled for OAS each time the function
3288 * SUCCESS: size of formatted string.
3289 * -EFAULT: target or vport wwpn was not set properly.
3290 * -EPERM: oas is not enabled.
3293 lpfc_oas_lun_show(struct device
*dev
, struct device_attribute
*attr
,
3296 struct Scsi_Host
*shost
= class_to_shost(dev
);
3297 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3305 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3306 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_VPORT
))
3309 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3310 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_TARGET
))
3313 oas_lun
= lpfc_oas_lun_get_next(phba
, phba
->cfg_oas_vpt_wwpn
,
3314 phba
->cfg_oas_tgt_wwpn
,
3315 &phba
->cfg_oas_lun_status
,
3316 &phba
->cfg_oas_priority
);
3317 if (oas_lun
!= NOT_OAS_ENABLED_LUN
)
3318 phba
->cfg_oas_flags
|= OAS_LUN_VALID
;
3320 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "0x%llx", oas_lun
);
3326 * lpfc_oas_lun_store - Sets the OAS state for lun
3327 * @dev: class device that is converted into a Scsi_host.
3328 * @attr: device attribute, not used.
3329 * @buf: buffer for passing information.
3331 * This function sets the OAS state for lun. Before this function is called,
3332 * the vport wwpn, target wwpn, and oas state need to be set.
3335 * SUCCESS: size of formatted string.
3336 * -EFAULT: target or vport wwpn was not set properly.
3337 * -EPERM: oas is not enabled.
3338 * size of formatted string.
3341 lpfc_oas_lun_store(struct device
*dev
, struct device_attribute
*attr
,
3342 const char *buf
, size_t count
)
3344 struct Scsi_Host
*shost
= class_to_shost(dev
);
3345 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3353 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3356 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3359 if (!isdigit(buf
[0]))
3362 if (sscanf(buf
, "0x%llx", &scsi_lun
) != 1)
3365 pri
= phba
->cfg_oas_priority
;
3367 pri
= phba
->cfg_XLanePriority
;
3369 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
,
3370 "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx "
3371 "priority 0x%x with oas state %d\n",
3372 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
),
3373 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
), scsi_lun
,
3374 pri
, phba
->cfg_oas_lun_state
);
3376 rc
= lpfc_oas_lun_state_change(phba
, phba
->cfg_oas_vpt_wwpn
,
3377 phba
->cfg_oas_tgt_wwpn
, scsi_lun
,
3378 phba
->cfg_oas_lun_state
, pri
);
3384 static DEVICE_ATTR(lpfc_xlane_lun
, S_IRUGO
| S_IWUSR
,
3385 lpfc_oas_lun_show
, lpfc_oas_lun_store
);
3387 int lpfc_enable_nvmet_cnt
;
3388 unsigned long long lpfc_enable_nvmet
[LPFC_NVMET_MAX_PORTS
] = {
3389 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3390 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3391 module_param_array(lpfc_enable_nvmet
, ullong
, &lpfc_enable_nvmet_cnt
, 0444);
3392 MODULE_PARM_DESC(lpfc_enable_nvmet
, "Enable HBA port(s) WWPN as a NVME Target");
3394 static int lpfc_poll
= 0;
3395 module_param(lpfc_poll
, int, S_IRUGO
);
3396 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
3398 " 1 - poll with interrupts enabled"
3399 " 3 - poll and disable FCP ring interrupts");
3401 static DEVICE_ATTR_RW(lpfc_poll
);
3403 int lpfc_no_hba_reset_cnt
;
3404 unsigned long lpfc_no_hba_reset
[MAX_HBAS_NO_RESET
] = {
3405 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3406 module_param_array(lpfc_no_hba_reset
, ulong
, &lpfc_no_hba_reset_cnt
, 0444);
3407 MODULE_PARM_DESC(lpfc_no_hba_reset
, "WWPN of HBAs that should not be reset");
3409 LPFC_ATTR(sli_mode
, 0, 0, 3,
3410 "SLI mode selector:"
3411 " 0 - auto (SLI-3 if supported),"
3412 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
3413 " 3 - select SLI-3");
3415 LPFC_ATTR_R(enable_npiv
, 1, 0, 1,
3416 "Enable NPIV functionality");
3418 LPFC_ATTR_R(fcf_failover_policy
, 1, 1, 2,
3419 "FCF Fast failover=1 Priority failover=2");
3422 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
3423 # 0x0 = disabled, XRI/OXID use not tracked.
3424 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
3425 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
3427 LPFC_ATTR_R(enable_rrq
, 2, 0, 2,
3428 "Enable RRQ functionality");
3431 # lpfc_suppress_link_up: Bring link up at initialization
3432 # 0x0 = bring link up (issue MBX_INIT_LINK)
3433 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
3434 # 0x2 = never bring up link
3435 # Default value is 0.
3437 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
3438 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
3439 "Suppress Link Up at initialization");
3441 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
3449 lpfc_iocb_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3451 struct Scsi_Host
*shost
= class_to_shost(dev
);
3452 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3454 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->iocb_max
);
3457 static DEVICE_ATTR(iocb_hw
, S_IRUGO
,
3458 lpfc_iocb_hw_show
, NULL
);
3460 lpfc_txq_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3462 struct Scsi_Host
*shost
= class_to_shost(dev
);
3463 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3464 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3466 return snprintf(buf
, PAGE_SIZE
, "%d\n",
3467 pring
? pring
->txq_max
: 0);
3470 static DEVICE_ATTR(txq_hw
, S_IRUGO
,
3471 lpfc_txq_hw_show
, NULL
);
3473 lpfc_txcmplq_hw_show(struct device
*dev
, struct device_attribute
*attr
,
3476 struct Scsi_Host
*shost
= class_to_shost(dev
);
3477 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3478 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3480 return snprintf(buf
, PAGE_SIZE
, "%d\n",
3481 pring
? pring
->txcmplq_max
: 0);
3484 static DEVICE_ATTR(txcmplq_hw
, S_IRUGO
,
3485 lpfc_txcmplq_hw_show
, NULL
);
3487 LPFC_ATTR_R(iocb_cnt
, 2, 1, 5,
3488 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
3491 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
3492 # until the timer expires. Value range is [0,255]. Default value is 30.
3494 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3495 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3496 module_param(lpfc_nodev_tmo
, int, 0);
3497 MODULE_PARM_DESC(lpfc_nodev_tmo
,
3498 "Seconds driver will hold I/O waiting "
3499 "for a device to come back");
3502 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
3503 * @dev: class converted to a Scsi_host structure.
3504 * @attr: device attribute, not used.
3505 * @buf: on return contains the dev loss timeout in decimal.
3507 * Returns: size of formatted string.
3510 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
3513 struct Scsi_Host
*shost
= class_to_shost(dev
);
3514 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3516 return snprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
3520 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
3521 * @vport: lpfc vport structure pointer.
3522 * @val: contains the nodev timeout value.
3525 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
3526 * a kernel error message is printed and zero is returned.
3527 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3528 * Otherwise nodev tmo is set to the default value.
3531 * zero if already set or if val is in range
3532 * -EINVAL val out of range
3535 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
3537 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
3538 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
3539 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
3540 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3541 "0407 Ignoring lpfc_nodev_tmo module "
3542 "parameter because lpfc_devloss_tmo "
3547 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3548 vport
->cfg_nodev_tmo
= val
;
3549 vport
->cfg_devloss_tmo
= val
;
3552 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3553 "0400 lpfc_nodev_tmo attribute cannot be set to"
3554 " %d, allowed range is [%d, %d]\n",
3555 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3556 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3561 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
3562 * @vport: lpfc vport structure pointer.
3565 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
3568 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
3570 struct Scsi_Host
*shost
;
3571 struct lpfc_nodelist
*ndlp
;
3572 #if (IS_ENABLED(CONFIG_NVME_FC))
3573 struct lpfc_nvme_rport
*rport
;
3574 struct nvme_fc_remote_port
*remoteport
= NULL
;
3577 shost
= lpfc_shost_from_vport(vport
);
3578 spin_lock_irq(shost
->host_lock
);
3579 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3580 if (!NLP_CHK_NODE_ACT(ndlp
))
3583 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
3584 #if (IS_ENABLED(CONFIG_NVME_FC))
3585 spin_lock(&vport
->phba
->hbalock
);
3586 rport
= lpfc_ndlp_get_nrport(ndlp
);
3588 remoteport
= rport
->remoteport
;
3589 spin_unlock(&vport
->phba
->hbalock
);
3591 nvme_fc_set_remoteport_devloss(rport
->remoteport
,
3592 vport
->cfg_devloss_tmo
);
3595 spin_unlock_irq(shost
->host_lock
);
3599 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
3600 * @vport: lpfc vport structure pointer.
3601 * @val: contains the tmo value.
3604 * If the devloss tmo is already set or the vport dev loss tmo has changed
3605 * then a kernel error message is printed and zero is returned.
3606 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3607 * Otherwise nodev tmo is set to the default value.
3610 * zero if already set or if val is in range
3611 * -EINVAL val out of range
3614 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
3616 if (vport
->dev_loss_tmo_changed
||
3617 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
3618 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3619 "0401 Ignoring change to lpfc_nodev_tmo "
3620 "because lpfc_devloss_tmo is set.\n");
3623 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3624 vport
->cfg_nodev_tmo
= val
;
3625 vport
->cfg_devloss_tmo
= val
;
3627 * For compat: set the fc_host dev loss so new rports
3628 * will get the value.
3630 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3631 lpfc_update_rport_devloss_tmo(vport
);
3634 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3635 "0403 lpfc_nodev_tmo attribute cannot be set to "
3636 "%d, allowed range is [%d, %d]\n",
3637 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3641 lpfc_vport_param_store(nodev_tmo
)
3643 static DEVICE_ATTR_RW(lpfc_nodev_tmo
);
3646 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
3647 # disappear until the timer expires. Value range is [0,255]. Default
3650 module_param(lpfc_devloss_tmo
, int, S_IRUGO
);
3651 MODULE_PARM_DESC(lpfc_devloss_tmo
,
3652 "Seconds driver will hold I/O waiting "
3653 "for a device to come back");
3654 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
3655 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
3656 lpfc_vport_param_show(devloss_tmo
)
3659 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
3660 * @vport: lpfc vport structure pointer.
3661 * @val: contains the tmo value.
3664 * If val is in a valid range then set the vport nodev tmo,
3665 * devloss tmo, also set the vport dev loss tmo changed flag.
3666 * Else a kernel error message is printed.
3669 * zero if val is in range
3670 * -EINVAL val out of range
3673 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
3675 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3676 vport
->cfg_nodev_tmo
= val
;
3677 vport
->cfg_devloss_tmo
= val
;
3678 vport
->dev_loss_tmo_changed
= 1;
3679 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3680 lpfc_update_rport_devloss_tmo(vport
);
3684 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3685 "0404 lpfc_devloss_tmo attribute cannot be set to "
3686 "%d, allowed range is [%d, %d]\n",
3687 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3691 lpfc_vport_param_store(devloss_tmo
)
3692 static DEVICE_ATTR_RW(lpfc_devloss_tmo
);
3695 * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it
3696 * lpfc_suppress_rsp = 0 Disable
3697 * lpfc_suppress_rsp = 1 Enable (default)
3700 LPFC_ATTR_R(suppress_rsp
, 1, 0, 1,
3701 "Enable suppress rsp feature is firmware supports it");
3704 * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds
3705 * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs
3706 * lpfc_nvmet_mrq = 1 use a single RQ pair
3707 * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ
3710 LPFC_ATTR_R(nvmet_mrq
,
3711 LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_MAX
,
3712 "Specify number of RQ pairs for processing NVMET cmds");
3715 * lpfc_nvmet_mrq_post: Specify number of RQ buffer to initially post
3716 * to each NVMET RQ. Range 64 to 2048, default is 512.
3718 LPFC_ATTR_R(nvmet_mrq_post
,
3719 LPFC_NVMET_RQE_DEF_POST
, LPFC_NVMET_RQE_MIN_POST
,
3720 LPFC_NVMET_RQE_DEF_COUNT
,
3721 "Specify number of RQ buffers to initially post");
3724 * lpfc_enable_fc4_type: Defines what FC4 types are supported.
3725 * Supported Values: 1 - register just FCP
3726 * 3 - register both FCP and NVME
3727 * Supported values are [1,3]. Default value is 1
3729 LPFC_ATTR_R(enable_fc4_type
, LPFC_ENABLE_FCP
,
3730 LPFC_ENABLE_FCP
, LPFC_ENABLE_BOTH
,
3731 "Enable FC4 Protocol support - FCP / NVME");
3734 * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME
3735 * This parameter is only used if:
3736 * lpfc_enable_fc4_type is 3 - register both FCP and NVME and
3737 * port is not configured for NVMET.
3739 * ELS/CT always get 10% of XRIs, up to a maximum of 250
3740 * The remaining XRIs get split up based on lpfc_xri_split per port:
3742 * Supported Values are in percentages
3743 * the xri_split value is the percentage the SCSI port will get. The remaining
3744 * percentage will go to NVME.
3746 LPFC_ATTR_R(xri_split
, 50, 10, 90,
3747 "Percentage of FCP XRI resources versus NVME");
3750 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
3751 # deluged with LOTS of information.
3752 # You can set a bit mask to record specific types of verbose messages:
3753 # See lpfc_logmsh.h for definitions.
3755 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
3756 "Verbose logging bit-mask");
3759 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
3760 # objects that have been registered with the nameserver after login.
3762 LPFC_VPORT_ATTR_R(enable_da_id
, 1, 0, 1,
3763 "Deregister nameserver objects before LOGO");
3766 # lun_queue_depth: This parameter is used to limit the number of outstanding
3767 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
3768 # If this parameter value is greater than 1/8th the maximum number of exchanges
3769 # supported by the HBA port, then the lun queue depth will be reduced to
3770 # 1/8th the maximum number of exchanges.
3772 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 512,
3773 "Max number of FCP commands we can queue to a specific LUN");
3776 # tgt_queue_depth: This parameter is used to limit the number of outstanding
3777 # commands per target port. Value range is [10,65535]. Default value is 65535.
3779 static uint lpfc_tgt_queue_depth
= LPFC_MAX_TGT_QDEPTH
;
3780 module_param(lpfc_tgt_queue_depth
, uint
, 0444);
3781 MODULE_PARM_DESC(lpfc_tgt_queue_depth
, "Set max Target queue depth");
3782 lpfc_vport_param_show(tgt_queue_depth
);
3783 lpfc_vport_param_init(tgt_queue_depth
, LPFC_MAX_TGT_QDEPTH
,
3784 LPFC_MIN_TGT_QDEPTH
, LPFC_MAX_TGT_QDEPTH
);
3787 * lpfc_tgt_queue_depth_store: Sets an attribute value.
3788 * @phba: pointer the the adapter structure.
3789 * @val: integer attribute value.
3791 * Description: Sets the parameter to the new value.
3795 * -EINVAL if val is invalid
3798 lpfc_tgt_queue_depth_set(struct lpfc_vport
*vport
, uint val
)
3800 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
3801 struct lpfc_nodelist
*ndlp
;
3803 if (!lpfc_rangecheck(val
, LPFC_MIN_TGT_QDEPTH
, LPFC_MAX_TGT_QDEPTH
))
3806 if (val
== vport
->cfg_tgt_queue_depth
)
3809 spin_lock_irq(shost
->host_lock
);
3810 vport
->cfg_tgt_queue_depth
= val
;
3812 /* Next loop thru nodelist and change cmd_qdepth */
3813 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
)
3814 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
3816 spin_unlock_irq(shost
->host_lock
);
3820 lpfc_vport_param_store(tgt_queue_depth
);
3821 static DEVICE_ATTR_RW(lpfc_tgt_queue_depth
);
3824 # hba_queue_depth: This parameter is used to limit the number of outstanding
3825 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
3826 # value is greater than the maximum number of exchanges supported by the HBA,
3827 # then maximum number of exchanges supported by the HBA is used to determine
3828 # the hba_queue_depth.
3830 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
3831 "Max number of FCP commands we can queue to a lpfc HBA");
3834 # peer_port_login: This parameter allows/prevents logins
3835 # between peer ports hosted on the same physical port.
3836 # When this parameter is set 0 peer ports of same physical port
3837 # are not allowed to login to each other.
3838 # When this parameter is set 1 peer ports of same physical port
3839 # are allowed to login to each other.
3840 # Default value of this parameter is 0.
3842 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
3843 "Allow peer ports on the same physical port to login to each "
3847 # restrict_login: This parameter allows/prevents logins
3848 # between Virtual Ports and remote initiators.
3849 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
3850 # other initiators and will attempt to PLOGI all remote ports.
3851 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
3852 # remote ports and will not attempt to PLOGI to other initiators.
3853 # This parameter does not restrict to the physical port.
3854 # This parameter does not restrict logins to Fabric resident remote ports.
3855 # Default value of this parameter is 1.
3857 static int lpfc_restrict_login
= 1;
3858 module_param(lpfc_restrict_login
, int, S_IRUGO
);
3859 MODULE_PARM_DESC(lpfc_restrict_login
,
3860 "Restrict virtual ports login to remote initiators.");
3861 lpfc_vport_param_show(restrict_login
);
3864 * lpfc_restrict_login_init - Set the vport restrict login flag
3865 * @vport: lpfc vport structure pointer.
3866 * @val: contains the restrict login value.
3869 * If val is not in a valid range then log a kernel error message and set
3870 * the vport restrict login to one.
3871 * If the port type is physical clear the restrict login flag and return.
3872 * Else set the restrict login flag to val.
3875 * zero if val is in range
3876 * -EINVAL val out of range
3879 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
3881 if (val
< 0 || val
> 1) {
3882 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3883 "0422 lpfc_restrict_login attribute cannot "
3884 "be set to %d, allowed range is [0, 1]\n",
3886 vport
->cfg_restrict_login
= 1;
3889 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
3890 vport
->cfg_restrict_login
= 0;
3893 vport
->cfg_restrict_login
= val
;
3898 * lpfc_restrict_login_set - Set the vport restrict login flag
3899 * @vport: lpfc vport structure pointer.
3900 * @val: contains the restrict login value.
3903 * If val is not in a valid range then log a kernel error message and set
3904 * the vport restrict login to one.
3905 * If the port type is physical and the val is not zero log a kernel
3906 * error message, clear the restrict login flag and return zero.
3907 * Else set the restrict login flag to val.
3910 * zero if val is in range
3911 * -EINVAL val out of range
3914 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
3916 if (val
< 0 || val
> 1) {
3917 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3918 "0425 lpfc_restrict_login attribute cannot "
3919 "be set to %d, allowed range is [0, 1]\n",
3921 vport
->cfg_restrict_login
= 1;
3924 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
3925 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3926 "0468 lpfc_restrict_login must be 0 for "
3927 "Physical ports.\n");
3928 vport
->cfg_restrict_login
= 0;
3931 vport
->cfg_restrict_login
= val
;
3934 lpfc_vport_param_store(restrict_login
);
3935 static DEVICE_ATTR_RW(lpfc_restrict_login
);
3938 # Some disk devices have a "select ID" or "select Target" capability.
3939 # From a protocol standpoint "select ID" usually means select the
3940 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
3941 # annex" which contains a table that maps a "select ID" (a number
3942 # between 0 and 7F) to an ALPA. By default, for compatibility with
3943 # older drivers, the lpfc driver scans this table from low ALPA to high
3946 # Turning on the scan-down variable (on = 1, off = 0) will
3947 # cause the lpfc driver to use an inverted table, effectively
3948 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
3950 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
3951 # and will not work across a fabric. Also this parameter will take
3952 # effect only in the case when ALPA map is not available.)
3954 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
3955 "Start scanning for devices from highest ALPA to lowest");
3958 # lpfc_topology: link topology for init link
3959 # 0x0 = attempt loop mode then point-to-point
3960 # 0x01 = internal loopback mode
3961 # 0x02 = attempt point-to-point mode only
3962 # 0x04 = attempt loop mode only
3963 # 0x06 = attempt point-to-point mode then loop
3964 # Set point-to-point mode if you want to run as an N_Port.
3965 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
3966 # Default value is 0.
3968 LPFC_ATTR(topology
, 0, 0, 6,
3969 "Select Fibre Channel topology");
3972 * lpfc_topology_set - Set the adapters topology field
3973 * @phba: lpfc_hba pointer.
3974 * @val: topology value.
3977 * If val is in a valid range then set the adapter's topology field and
3978 * issue a lip; if the lip fails reset the topology to the old value.
3980 * If the value is not in range log a kernel error message and return an error.
3983 * zero if val is in range and lip okay
3984 * non-zero return value from lpfc_issue_lip()
3985 * -EINVAL val out of range
3988 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
3989 const char *buf
, size_t count
)
3991 struct Scsi_Host
*shost
= class_to_shost(dev
);
3992 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3993 struct lpfc_hba
*phba
= vport
->phba
;
3996 const char *val_buf
= buf
;
4000 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
4002 val_buf
= &buf
[strlen("nolip ")];
4005 if (!isdigit(val_buf
[0]))
4007 if (sscanf(val_buf
, "%i", &val
) != 1)
4010 if (val
>= 0 && val
<= 6) {
4011 prev_val
= phba
->cfg_topology
;
4012 if (phba
->cfg_link_speed
== LPFC_USER_LINK_SPEED_16G
&&
4014 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4015 "3113 Loop mode not supported at speed %d\n",
4019 if ((phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G6_FC
||
4020 phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G7_FC
) &&
4022 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4023 "3114 Loop mode not supported\n");
4026 phba
->cfg_topology
= val
;
4030 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4031 "3054 lpfc_topology changed from %d to %d\n",
4033 if (prev_val
!= val
&& phba
->sli_rev
== LPFC_SLI_REV4
)
4034 phba
->fc_topology_changed
= 1;
4035 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
4037 phba
->cfg_topology
= prev_val
;
4042 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4043 "%d:0467 lpfc_topology attribute cannot be set to %d, "
4044 "allowed range is [0, 6]\n",
4049 lpfc_param_show(topology
)
4050 static DEVICE_ATTR_RW(lpfc_topology
);
4053 * lpfc_static_vport_show: Read callback function for
4054 * lpfc_static_vport sysfs file.
4055 * @dev: Pointer to class device object.
4056 * @attr: device attribute structure.
4057 * @buf: Data buffer.
4059 * This function is the read call back function for
4060 * lpfc_static_vport sysfs file. The lpfc_static_vport
4061 * sysfs file report the mageability of the vport.
4064 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
4067 struct Scsi_Host
*shost
= class_to_shost(dev
);
4068 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4069 if (vport
->vport_flag
& STATIC_VPORT
)
4070 sprintf(buf
, "1\n");
4072 sprintf(buf
, "0\n");
4078 * Sysfs attribute to control the statistical data collection.
4080 static DEVICE_ATTR_RO(lpfc_static_vport
);
4083 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
4084 * @dev: Pointer to class device.
4085 * @buf: Data buffer.
4086 * @count: Size of the data buffer.
4088 * This function get called when a user write to the lpfc_stat_data_ctrl
4089 * sysfs file. This function parse the command written to the sysfs file
4090 * and take appropriate action. These commands are used for controlling
4091 * driver statistical data collection.
4092 * Following are the command this function handles.
4094 * setbucket <bucket_type> <base> <step>
4095 * = Set the latency buckets.
4096 * destroybucket = destroy all the buckets.
4097 * start = start data collection
4098 * stop = stop data collection
4099 * reset = reset the collected data
4102 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
4103 const char *buf
, size_t count
)
4105 struct Scsi_Host
*shost
= class_to_shost(dev
);
4106 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4107 struct lpfc_hba
*phba
= vport
->phba
;
4108 #define LPFC_MAX_DATA_CTRL_LEN 1024
4109 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
4111 char *str_ptr
, *token
;
4112 struct lpfc_vport
**vports
;
4113 struct Scsi_Host
*v_shost
;
4114 char *bucket_type_str
, *base_str
, *step_str
;
4115 unsigned long base
, step
, bucket_type
;
4117 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
4118 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
4121 strncpy(bucket_data
, buf
, LPFC_MAX_DATA_CTRL_LEN
);
4122 str_ptr
= &bucket_data
[0];
4123 /* Ignore this token - this is command token */
4124 token
= strsep(&str_ptr
, "\t ");
4128 bucket_type_str
= strsep(&str_ptr
, "\t ");
4129 if (!bucket_type_str
)
4132 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
4133 bucket_type
= LPFC_LINEAR_BUCKET
;
4134 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
4135 bucket_type
= LPFC_POWER2_BUCKET
;
4139 base_str
= strsep(&str_ptr
, "\t ");
4142 base
= simple_strtoul(base_str
, NULL
, 0);
4144 step_str
= strsep(&str_ptr
, "\t ");
4147 step
= simple_strtoul(step_str
, NULL
, 0);
4151 /* Block the data collection for every vport */
4152 vports
= lpfc_create_vport_work_array(phba
);
4156 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
4157 v_shost
= lpfc_shost_from_vport(vports
[i
]);
4158 spin_lock_irq(v_shost
->host_lock
);
4159 /* Block and reset data collection */
4160 vports
[i
]->stat_data_blocked
= 1;
4161 if (vports
[i
]->stat_data_enabled
)
4162 lpfc_vport_reset_stat_data(vports
[i
]);
4163 spin_unlock_irq(v_shost
->host_lock
);
4166 /* Set the bucket attributes */
4167 phba
->bucket_type
= bucket_type
;
4168 phba
->bucket_base
= base
;
4169 phba
->bucket_step
= step
;
4171 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
4172 v_shost
= lpfc_shost_from_vport(vports
[i
]);
4174 /* Unblock data collection */
4175 spin_lock_irq(v_shost
->host_lock
);
4176 vports
[i
]->stat_data_blocked
= 0;
4177 spin_unlock_irq(v_shost
->host_lock
);
4179 lpfc_destroy_vport_work_array(phba
, vports
);
4183 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
4184 vports
= lpfc_create_vport_work_array(phba
);
4188 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
4189 v_shost
= lpfc_shost_from_vport(vports
[i
]);
4190 spin_lock_irq(shost
->host_lock
);
4191 vports
[i
]->stat_data_blocked
= 1;
4192 lpfc_free_bucket(vport
);
4193 vport
->stat_data_enabled
= 0;
4194 vports
[i
]->stat_data_blocked
= 0;
4195 spin_unlock_irq(shost
->host_lock
);
4197 lpfc_destroy_vport_work_array(phba
, vports
);
4198 phba
->bucket_type
= LPFC_NO_BUCKET
;
4199 phba
->bucket_base
= 0;
4200 phba
->bucket_step
= 0;
4204 if (!strncmp(buf
, "start", strlen("start"))) {
4205 /* If no buckets configured return error */
4206 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
4208 spin_lock_irq(shost
->host_lock
);
4209 if (vport
->stat_data_enabled
) {
4210 spin_unlock_irq(shost
->host_lock
);
4213 lpfc_alloc_bucket(vport
);
4214 vport
->stat_data_enabled
= 1;
4215 spin_unlock_irq(shost
->host_lock
);
4219 if (!strncmp(buf
, "stop", strlen("stop"))) {
4220 spin_lock_irq(shost
->host_lock
);
4221 if (vport
->stat_data_enabled
== 0) {
4222 spin_unlock_irq(shost
->host_lock
);
4225 lpfc_free_bucket(vport
);
4226 vport
->stat_data_enabled
= 0;
4227 spin_unlock_irq(shost
->host_lock
);
4231 if (!strncmp(buf
, "reset", strlen("reset"))) {
4232 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
4233 || !vport
->stat_data_enabled
)
4235 spin_lock_irq(shost
->host_lock
);
4236 vport
->stat_data_blocked
= 1;
4237 lpfc_vport_reset_stat_data(vport
);
4238 vport
->stat_data_blocked
= 0;
4239 spin_unlock_irq(shost
->host_lock
);
4247 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
4248 * @dev: Pointer to class device object.
4249 * @buf: Data buffer.
4251 * This function is the read call back function for
4252 * lpfc_stat_data_ctrl sysfs file. This function report the
4253 * current statistical data collection state.
4256 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
4259 struct Scsi_Host
*shost
= class_to_shost(dev
);
4260 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4261 struct lpfc_hba
*phba
= vport
->phba
;
4265 unsigned long bucket_value
;
4267 switch (phba
->bucket_type
) {
4268 case LPFC_LINEAR_BUCKET
:
4269 bucket_type
= "linear";
4271 case LPFC_POWER2_BUCKET
:
4272 bucket_type
= "power2";
4275 bucket_type
= "No Bucket";
4279 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
4280 "blocked :%d, Bucket type :%s, Bucket base :%d,"
4281 " Bucket step :%d\nLatency Ranges :",
4282 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
4283 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
4284 index
= strlen(buf
);
4285 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
4286 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
4287 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
4288 bucket_value
= phba
->bucket_base
+
4289 phba
->bucket_step
* i
;
4291 bucket_value
= phba
->bucket_base
+
4292 (1 << i
) * phba
->bucket_step
;
4294 if (index
+ 10 > PAGE_SIZE
)
4296 sprintf(&buf
[index
], "%08ld ", bucket_value
);
4297 index
= strlen(buf
);
4300 sprintf(&buf
[index
], "\n");
4305 * Sysfs attribute to control the statistical data collection.
4307 static DEVICE_ATTR_RW(lpfc_stat_data_ctrl
);
4310 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
4314 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
4317 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
4318 #define MAX_STAT_DATA_SIZE_PER_TARGET \
4319 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
4323 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
4325 * @kobj: Pointer to the kernel object
4326 * @bin_attr: Attribute object
4327 * @buff: Buffer pointer
4329 * @count: Buffer size
4331 * This function is the read call back function for lpfc_drvr_stat_data
4332 * sysfs file. This function export the statistical data to user
4336 sysfs_drvr_stat_data_read(struct file
*filp
, struct kobject
*kobj
,
4337 struct bin_attribute
*bin_attr
,
4338 char *buf
, loff_t off
, size_t count
)
4340 struct device
*dev
= container_of(kobj
, struct device
,
4342 struct Scsi_Host
*shost
= class_to_shost(dev
);
4343 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4344 struct lpfc_hba
*phba
= vport
->phba
;
4345 int i
= 0, index
= 0;
4346 unsigned long nport_index
;
4347 struct lpfc_nodelist
*ndlp
= NULL
;
4348 nport_index
= (unsigned long)off
/
4349 MAX_STAT_DATA_SIZE_PER_TARGET
;
4351 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
4352 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
4355 spin_lock_irq(shost
->host_lock
);
4356 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4357 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
4360 if (nport_index
> 0) {
4365 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
4369 if (!ndlp
->lat_data
)
4373 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
4374 ndlp
->nlp_portname
.u
.wwn
[0],
4375 ndlp
->nlp_portname
.u
.wwn
[1],
4376 ndlp
->nlp_portname
.u
.wwn
[2],
4377 ndlp
->nlp_portname
.u
.wwn
[3],
4378 ndlp
->nlp_portname
.u
.wwn
[4],
4379 ndlp
->nlp_portname
.u
.wwn
[5],
4380 ndlp
->nlp_portname
.u
.wwn
[6],
4381 ndlp
->nlp_portname
.u
.wwn
[7]);
4383 index
= strlen(buf
);
4385 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
4386 sprintf(&buf
[index
], "%010u,",
4387 ndlp
->lat_data
[i
].cmd_count
);
4388 index
= strlen(buf
);
4390 sprintf(&buf
[index
], "\n");
4391 index
= strlen(buf
);
4393 spin_unlock_irq(shost
->host_lock
);
4397 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
4399 .name
= "lpfc_drvr_stat_data",
4402 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
4403 .read
= sysfs_drvr_stat_data_read
,
4408 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
4410 # Value range is [0,16]. Default value is 0.
4413 * lpfc_link_speed_set - Set the adapters link speed
4414 * @phba: lpfc_hba pointer.
4415 * @val: link speed value.
4418 * If val is in a valid range then set the adapter's link speed field and
4419 * issue a lip; if the lip fails reset the link speed to the old value.
4422 * If the value is not in range log a kernel error message and return an error.
4425 * zero if val is in range and lip okay.
4426 * non-zero return value from lpfc_issue_lip()
4427 * -EINVAL val out of range
4430 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
4431 const char *buf
, size_t count
)
4433 struct Scsi_Host
*shost
= class_to_shost(dev
);
4434 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4435 struct lpfc_hba
*phba
= vport
->phba
;
4436 int val
= LPFC_USER_LINK_SPEED_AUTO
;
4438 const char *val_buf
= buf
;
4440 uint32_t prev_val
, if_type
;
4442 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
4443 if (if_type
>= LPFC_SLI_INTF_IF_TYPE_2
&&
4444 phba
->hba_flag
& HBA_FORCED_LINK_SPEED
)
4447 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
4449 val_buf
= &buf
[strlen("nolip ")];
4452 if (!isdigit(val_buf
[0]))
4454 if (sscanf(val_buf
, "%i", &val
) != 1)
4457 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4458 "3055 lpfc_link_speed changed from %d to %d %s\n",
4459 phba
->cfg_link_speed
, val
, nolip
? "(nolip)" : "(lip)");
4461 if (((val
== LPFC_USER_LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
4462 ((val
== LPFC_USER_LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
4463 ((val
== LPFC_USER_LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
4464 ((val
== LPFC_USER_LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
4465 ((val
== LPFC_USER_LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)) ||
4466 ((val
== LPFC_USER_LINK_SPEED_16G
) && !(phba
->lmt
& LMT_16Gb
)) ||
4467 ((val
== LPFC_USER_LINK_SPEED_32G
) && !(phba
->lmt
& LMT_32Gb
)) ||
4468 ((val
== LPFC_USER_LINK_SPEED_64G
) && !(phba
->lmt
& LMT_64Gb
))) {
4469 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4470 "2879 lpfc_link_speed attribute cannot be set "
4471 "to %d. Speed is not supported by this port.\n",
4475 if (val
>= LPFC_USER_LINK_SPEED_16G
&&
4476 phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
4477 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4478 "3112 lpfc_link_speed attribute cannot be set "
4479 "to %d. Speed is not supported in loop mode.\n",
4485 case LPFC_USER_LINK_SPEED_AUTO
:
4486 case LPFC_USER_LINK_SPEED_1G
:
4487 case LPFC_USER_LINK_SPEED_2G
:
4488 case LPFC_USER_LINK_SPEED_4G
:
4489 case LPFC_USER_LINK_SPEED_8G
:
4490 case LPFC_USER_LINK_SPEED_16G
:
4491 case LPFC_USER_LINK_SPEED_32G
:
4492 case LPFC_USER_LINK_SPEED_64G
:
4493 prev_val
= phba
->cfg_link_speed
;
4494 phba
->cfg_link_speed
= val
;
4498 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
4500 phba
->cfg_link_speed
= prev_val
;
4508 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4509 "0469 lpfc_link_speed attribute cannot be set to %d, "
4510 "allowed values are [%s]\n",
4511 val
, LPFC_LINK_SPEED_STRING
);
4516 static int lpfc_link_speed
= 0;
4517 module_param(lpfc_link_speed
, int, S_IRUGO
);
4518 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
4519 lpfc_param_show(link_speed
)
4522 * lpfc_link_speed_init - Set the adapters link speed
4523 * @phba: lpfc_hba pointer.
4524 * @val: link speed value.
4527 * If val is in a valid range then set the adapter's link speed field.
4530 * If the value is not in range log a kernel error message, clear the link
4531 * speed and return an error.
4534 * zero if val saved.
4535 * -EINVAL val out of range
4538 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
4540 if (val
>= LPFC_USER_LINK_SPEED_16G
&& phba
->cfg_topology
== 4) {
4541 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4542 "3111 lpfc_link_speed of %d cannot "
4543 "support loop mode, setting topology to default.\n",
4545 phba
->cfg_topology
= 0;
4549 case LPFC_USER_LINK_SPEED_AUTO
:
4550 case LPFC_USER_LINK_SPEED_1G
:
4551 case LPFC_USER_LINK_SPEED_2G
:
4552 case LPFC_USER_LINK_SPEED_4G
:
4553 case LPFC_USER_LINK_SPEED_8G
:
4554 case LPFC_USER_LINK_SPEED_16G
:
4555 case LPFC_USER_LINK_SPEED_32G
:
4556 case LPFC_USER_LINK_SPEED_64G
:
4557 phba
->cfg_link_speed
= val
;
4560 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4561 "0405 lpfc_link_speed attribute cannot "
4562 "be set to %d, allowed values are "
4563 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
4564 phba
->cfg_link_speed
= LPFC_USER_LINK_SPEED_AUTO
;
4569 static DEVICE_ATTR_RW(lpfc_link_speed
);
4572 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
4573 # 0 = aer disabled or not supported
4574 # 1 = aer supported and enabled (default)
4575 # Value range is [0,1]. Default value is 1.
4577 LPFC_ATTR(aer_support
, 1, 0, 1,
4578 "Enable PCIe device AER support");
4579 lpfc_param_show(aer_support
)
4582 * lpfc_aer_support_store - Set the adapter for aer support
4584 * @dev: class device that is converted into a Scsi_host.
4585 * @attr: device attribute, not used.
4586 * @buf: containing enable or disable aer flag.
4587 * @count: unused variable.
4590 * If the val is 1 and currently the device's AER capability was not
4591 * enabled, invoke the kernel's enable AER helper routine, trying to
4592 * enable the device's AER capability. If the helper routine enabling
4593 * AER returns success, update the device's cfg_aer_support flag to
4594 * indicate AER is supported by the device; otherwise, if the device
4595 * AER capability is already enabled to support AER, then do nothing.
4597 * If the val is 0 and currently the device's AER support was enabled,
4598 * invoke the kernel's disable AER helper routine. After that, update
4599 * the device's cfg_aer_support flag to indicate AER is not supported
4600 * by the device; otherwise, if the device AER capability is already
4601 * disabled from supporting AER, then do nothing.
4604 * length of the buf on success if val is in range the intended mode
4606 * -EINVAL if val out of range or intended mode is not supported.
4609 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
4610 const char *buf
, size_t count
)
4612 struct Scsi_Host
*shost
= class_to_shost(dev
);
4613 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4614 struct lpfc_hba
*phba
= vport
->phba
;
4615 int val
= 0, rc
= -EINVAL
;
4617 if (!isdigit(buf
[0]))
4619 if (sscanf(buf
, "%i", &val
) != 1)
4624 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
4625 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
4627 spin_lock_irq(&phba
->hbalock
);
4628 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
4629 spin_unlock_irq(&phba
->hbalock
);
4630 phba
->cfg_aer_support
= 0;
4635 phba
->cfg_aer_support
= 0;
4640 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
4641 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
4643 spin_lock_irq(&phba
->hbalock
);
4644 phba
->hba_flag
|= HBA_AER_ENABLED
;
4645 spin_unlock_irq(&phba
->hbalock
);
4646 phba
->cfg_aer_support
= 1;
4651 phba
->cfg_aer_support
= 1;
4662 static DEVICE_ATTR_RW(lpfc_aer_support
);
4665 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
4666 * @dev: class device that is converted into a Scsi_host.
4667 * @attr: device attribute, not used.
4668 * @buf: containing flag 1 for aer cleanup state.
4669 * @count: unused variable.
4672 * If the @buf contains 1 and the device currently has the AER support
4673 * enabled, then invokes the kernel AER helper routine
4674 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
4675 * error status register.
4680 * -EINVAL if the buf does not contain the 1 or the device is not currently
4681 * enabled with the AER support.
4684 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
4685 const char *buf
, size_t count
)
4687 struct Scsi_Host
*shost
= class_to_shost(dev
);
4688 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4689 struct lpfc_hba
*phba
= vport
->phba
;
4692 if (!isdigit(buf
[0]))
4694 if (sscanf(buf
, "%i", &val
) != 1)
4699 if (phba
->hba_flag
& HBA_AER_ENABLED
)
4700 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
4708 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
4709 lpfc_aer_cleanup_state
);
4712 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
4714 * @dev: class device that is converted into a Scsi_host.
4715 * @attr: device attribute, not used.
4716 * @buf: containing the string the number of vfs to be enabled.
4717 * @count: unused variable.
4720 * When this api is called either through user sysfs, the driver shall
4721 * try to enable or disable SR-IOV virtual functions according to the
4724 * If zero virtual function has been enabled to the physical function,
4725 * the driver shall invoke the pci enable virtual function api trying
4726 * to enable the virtual functions. If the nr_vfn provided is greater
4727 * than the maximum supported, the maximum virtual function number will
4728 * be used for invoking the api; otherwise, the nr_vfn provided shall
4729 * be used for invoking the api. If the api call returned success, the
4730 * actual number of virtual functions enabled will be set to the driver
4731 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
4732 * cfg_sriov_nr_virtfn remains zero.
4734 * If none-zero virtual functions have already been enabled to the
4735 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
4736 * -EINVAL will be returned and the driver does nothing;
4738 * If the nr_vfn provided is zero and none-zero virtual functions have
4739 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
4740 * disabling virtual function api shall be invoded to disable all the
4741 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
4742 * zero. Otherwise, if zero virtual function has been enabled, do
4746 * length of the buf on success if val is in range the intended mode
4748 * -EINVAL if val out of range or intended mode is not supported.
4751 lpfc_sriov_nr_virtfn_store(struct device
*dev
, struct device_attribute
*attr
,
4752 const char *buf
, size_t count
)
4754 struct Scsi_Host
*shost
= class_to_shost(dev
);
4755 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4756 struct lpfc_hba
*phba
= vport
->phba
;
4757 struct pci_dev
*pdev
= phba
->pcidev
;
4758 int val
= 0, rc
= -EINVAL
;
4760 /* Sanity check on user data */
4761 if (!isdigit(buf
[0]))
4763 if (sscanf(buf
, "%i", &val
) != 1)
4768 /* Request disabling virtual functions */
4770 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4771 pci_disable_sriov(pdev
);
4772 phba
->cfg_sriov_nr_virtfn
= 0;
4777 /* Request enabling virtual functions */
4778 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4779 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4780 "3018 There are %d virtual functions "
4781 "enabled on physical function.\n",
4782 phba
->cfg_sriov_nr_virtfn
);
4786 if (val
<= LPFC_MAX_VFN_PER_PFN
)
4787 phba
->cfg_sriov_nr_virtfn
= val
;
4789 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4790 "3019 Enabling %d virtual functions is not "
4795 rc
= lpfc_sli_probe_sriov_nr_virtfn(phba
, phba
->cfg_sriov_nr_virtfn
);
4797 phba
->cfg_sriov_nr_virtfn
= 0;
4805 LPFC_ATTR(sriov_nr_virtfn
, LPFC_DEF_VFN_PER_PFN
, 0, LPFC_MAX_VFN_PER_PFN
,
4806 "Enable PCIe device SR-IOV virtual fn");
4808 lpfc_param_show(sriov_nr_virtfn
)
4809 static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn
);
4812 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
4814 * @dev: class device that is converted into a Scsi_host.
4815 * @attr: device attribute, not used.
4816 * @buf: containing the string the number of vfs to be enabled.
4817 * @count: unused variable.
4822 * length of the buf on success if val is in range the intended mode
4824 * -EINVAL if val out of range or intended mode is not supported.
4827 lpfc_request_firmware_upgrade_store(struct device
*dev
,
4828 struct device_attribute
*attr
,
4829 const char *buf
, size_t count
)
4831 struct Scsi_Host
*shost
= class_to_shost(dev
);
4832 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4833 struct lpfc_hba
*phba
= vport
->phba
;
4834 int val
= 0, rc
= -EINVAL
;
4836 /* Sanity check on user data */
4837 if (!isdigit(buf
[0]))
4839 if (sscanf(buf
, "%i", &val
) != 1)
4844 rc
= lpfc_sli4_request_firmware_update(phba
, RUN_FW_UPGRADE
);
4852 static int lpfc_req_fw_upgrade
;
4853 module_param(lpfc_req_fw_upgrade
, int, S_IRUGO
|S_IWUSR
);
4854 MODULE_PARM_DESC(lpfc_req_fw_upgrade
, "Enable Linux generic firmware upgrade");
4855 lpfc_param_show(request_firmware_upgrade
)
4858 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
4859 * @phba: lpfc_hba pointer.
4863 * Set the initial Linux generic firmware upgrade enable or disable flag.
4866 * zero if val saved.
4867 * -EINVAL val out of range
4870 lpfc_request_firmware_upgrade_init(struct lpfc_hba
*phba
, int val
)
4872 if (val
>= 0 && val
<= 1) {
4873 phba
->cfg_request_firmware_upgrade
= val
;
4878 static DEVICE_ATTR(lpfc_req_fw_upgrade
, S_IRUGO
| S_IWUSR
,
4879 lpfc_request_firmware_upgrade_show
,
4880 lpfc_request_firmware_upgrade_store
);
4883 * lpfc_fcp_imax_store
4885 * @dev: class device that is converted into a Scsi_host.
4886 * @attr: device attribute, not used.
4887 * @buf: string with the number of fast-path FCP interrupts per second.
4888 * @count: unused variable.
4891 * If val is in a valid range [636,651042], then set the adapter's
4892 * maximum number of fast-path FCP interrupts per second.
4895 * length of the buf on success if val is in range the intended mode
4897 * -EINVAL if val out of range or intended mode is not supported.
4900 lpfc_fcp_imax_store(struct device
*dev
, struct device_attribute
*attr
,
4901 const char *buf
, size_t count
)
4903 struct Scsi_Host
*shost
= class_to_shost(dev
);
4904 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4905 struct lpfc_hba
*phba
= vport
->phba
;
4908 /* fcp_imax is only valid for SLI4 */
4909 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
4912 /* Sanity check on user data */
4913 if (!isdigit(buf
[0]))
4915 if (sscanf(buf
, "%i", &val
) != 1)
4919 * Value range for the HBA is [5000,5000000]
4920 * The value for each EQ depends on how many EQs are configured.
4923 if (val
&& (val
< LPFC_MIN_IMAX
|| val
> LPFC_MAX_IMAX
))
4926 phba
->cfg_fcp_imax
= (uint32_t)val
;
4927 phba
->initial_imax
= phba
->cfg_fcp_imax
;
4929 for (i
= 0; i
< phba
->io_channel_irqs
; i
+= LPFC_MAX_EQ_DELAY_EQID_CNT
)
4930 lpfc_modify_hba_eq_delay(phba
, i
, LPFC_MAX_EQ_DELAY_EQID_CNT
,
4937 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
4940 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
4942 static int lpfc_fcp_imax
= LPFC_DEF_IMAX
;
4943 module_param(lpfc_fcp_imax
, int, S_IRUGO
|S_IWUSR
);
4944 MODULE_PARM_DESC(lpfc_fcp_imax
,
4945 "Set the maximum number of FCP interrupts per second per HBA");
4946 lpfc_param_show(fcp_imax
)
4949 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
4950 * @phba: lpfc_hba pointer.
4951 * @val: link speed value.
4954 * If val is in a valid range [636,651042], then initialize the adapter's
4955 * maximum number of fast-path FCP interrupts per second.
4958 * zero if val saved.
4959 * -EINVAL val out of range
4962 lpfc_fcp_imax_init(struct lpfc_hba
*phba
, int val
)
4964 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4965 phba
->cfg_fcp_imax
= 0;
4969 if ((val
>= LPFC_MIN_IMAX
&& val
<= LPFC_MAX_IMAX
) ||
4971 phba
->cfg_fcp_imax
= val
;
4975 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4976 "3016 lpfc_fcp_imax: %d out of range, using default\n",
4978 phba
->cfg_fcp_imax
= LPFC_DEF_IMAX
;
4983 static DEVICE_ATTR_RW(lpfc_fcp_imax
);
4986 * lpfc_auto_imax: Controls Auto-interrupt coalescing values support.
4987 * 0 No auto_imax support
4989 * Auto imax will change the value of fcp_imax on a per EQ basis, using
4990 * the EQ Delay Multiplier, depending on the activity for that EQ.
4991 * Value range [0,1]. Default value is 1.
4993 LPFC_ATTR_RW(auto_imax
, 1, 0, 1, "Enable Auto imax");
4996 * lpfc_state_show - Display current driver CPU affinity
4997 * @dev: class converted to a Scsi_host structure.
4998 * @attr: device attribute, not used.
4999 * @buf: on return contains text describing the state of the link.
5001 * Returns: size of formatted string.
5004 lpfc_fcp_cpu_map_show(struct device
*dev
, struct device_attribute
*attr
,
5007 struct Scsi_Host
*shost
= class_to_shost(dev
);
5008 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5009 struct lpfc_hba
*phba
= vport
->phba
;
5010 struct lpfc_vector_map_info
*cpup
;
5013 if ((phba
->sli_rev
!= LPFC_SLI_REV4
) ||
5014 (phba
->intr_type
!= MSIX
))
5017 switch (phba
->cfg_fcp_cpu_map
) {
5019 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
5020 "fcp_cpu_map: No mapping (%d)\n",
5021 phba
->cfg_fcp_cpu_map
);
5024 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
5025 "fcp_cpu_map: HBA centric mapping (%d): "
5027 phba
->cfg_fcp_cpu_map
,
5028 phba
->sli4_hba
.num_online_cpu
);
5031 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
5032 "fcp_cpu_map: Driver centric mapping (%d): "
5034 phba
->cfg_fcp_cpu_map
,
5035 phba
->sli4_hba
.num_online_cpu
);
5039 while (phba
->sli4_hba
.curr_disp_cpu
< phba
->sli4_hba
.num_present_cpu
) {
5040 cpup
= &phba
->sli4_hba
.cpu_map
[phba
->sli4_hba
.curr_disp_cpu
];
5042 /* margin should fit in this and the truncated message */
5043 if (cpup
->irq
== LPFC_VECTOR_MAP_EMPTY
)
5044 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
5045 "CPU %02d io_chan %02d "
5046 "physid %d coreid %d\n",
5047 phba
->sli4_hba
.curr_disp_cpu
,
5048 cpup
->channel_id
, cpup
->phys_id
,
5051 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
5052 "CPU %02d io_chan %02d "
5053 "physid %d coreid %d IRQ %d\n",
5054 phba
->sli4_hba
.curr_disp_cpu
,
5055 cpup
->channel_id
, cpup
->phys_id
,
5056 cpup
->core_id
, cpup
->irq
);
5058 phba
->sli4_hba
.curr_disp_cpu
++;
5060 /* display max number of CPUs keeping some margin */
5061 if (phba
->sli4_hba
.curr_disp_cpu
<
5062 phba
->sli4_hba
.num_present_cpu
&&
5063 (len
>= (PAGE_SIZE
- 64))) {
5064 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "more...\n");
5069 if (phba
->sli4_hba
.curr_disp_cpu
== phba
->sli4_hba
.num_present_cpu
)
5070 phba
->sli4_hba
.curr_disp_cpu
= 0;
5076 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
5077 * @dev: class device that is converted into a Scsi_host.
5078 * @attr: device attribute, not used.
5079 * @buf: one or more lpfc_polling_flags values.
5083 * -EINVAL - Not implemented yet.
5086 lpfc_fcp_cpu_map_store(struct device
*dev
, struct device_attribute
*attr
,
5087 const char *buf
, size_t count
)
5089 int status
= -EINVAL
;
5094 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
5097 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
5098 # 0 - Do not affinitze IRQ vectors
5099 # 1 - Affintize HBA vectors with respect to each HBA
5100 # (start with CPU0 for each HBA)
5101 # 2 - Affintize HBA vectors with respect to the entire driver
5102 # (round robin thru all CPUs across all HBAs)
5104 static int lpfc_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
5105 module_param(lpfc_fcp_cpu_map
, int, S_IRUGO
|S_IWUSR
);
5106 MODULE_PARM_DESC(lpfc_fcp_cpu_map
,
5107 "Defines how to map CPUs to IRQ vectors per HBA");
5110 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
5111 * @phba: lpfc_hba pointer.
5112 * @val: link speed value.
5115 * If val is in a valid range [0-2], then affinitze the adapter's
5119 * zero if val saved.
5120 * -EINVAL val out of range
5123 lpfc_fcp_cpu_map_init(struct lpfc_hba
*phba
, int val
)
5125 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
5126 phba
->cfg_fcp_cpu_map
= 0;
5130 if (val
>= LPFC_MIN_CPU_MAP
&& val
<= LPFC_MAX_CPU_MAP
) {
5131 phba
->cfg_fcp_cpu_map
= val
;
5135 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5136 "3326 lpfc_fcp_cpu_map: %d out of range, using "
5138 phba
->cfg_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
5143 static DEVICE_ATTR_RW(lpfc_fcp_cpu_map
);
5146 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
5147 # Value range is [2,3]. Default value is 3.
5149 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
5150 "Select Fibre Channel class of service for FCP sequences");
5153 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
5154 # is [0,1]. Default value is 0.
5156 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
5157 "Use ADISC on rediscovery to authenticate FCP devices");
5160 # lpfc_first_burst_size: First burst size to use on the NPorts
5161 # that support first burst.
5162 # Value range is [0,65536]. Default value is 0.
5164 LPFC_VPORT_ATTR_RW(first_burst_size
, 0, 0, 65536,
5165 "First burst size for Targets that support first burst");
5168 * lpfc_nvmet_fb_size: NVME Target mode supported first burst size.
5169 * When the driver is configured as an NVME target, this value is
5170 * communicated to the NVME initiator in the PRLI response. It is
5171 * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support
5172 * parameters are set and the target is sending the PRLI RSP.
5173 * Parameter supported on physical port only - no NPIV support.
5174 * Value range is [0,65536]. Default value is 0.
5176 LPFC_ATTR_RW(nvmet_fb_size
, 0, 0, 65536,
5177 "NVME Target mode first burst size in 512B increments.");
5180 * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
5181 * For the Initiator (I), enabling this parameter means that an NVMET
5182 * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be
5183 * processed by the initiator for subsequent NVME FCP IO. For the target
5184 * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size
5185 * driver parameter as the target function's first burst size returned to the
5186 * initiator in the target's NVME PRLI response. Parameter supported on physical
5187 * port only - no NPIV support.
5188 * Value range is [0,1]. Default value is 0 (disabled).
5190 LPFC_ATTR_RW(nvme_enable_fb
, 0, 0, 1,
5191 "Enable First Burst feature on I and T functions.");
5194 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
5195 # depth. Default value is 0. When the value of this parameter is zero the
5196 # SCSI command completion time is not used for controlling I/O queue depth. When
5197 # the parameter is set to a non-zero value, the I/O queue depth is controlled
5198 # to limit the I/O completion time to the parameter value.
5199 # The value is set in milliseconds.
5201 LPFC_VPORT_ATTR(max_scsicmpl_time
, 0, 0, 60000,
5202 "Use command completion time to control queue depth");
5204 lpfc_vport_param_show(max_scsicmpl_time
);
5206 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
5208 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5209 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
5211 if (val
== vport
->cfg_max_scsicmpl_time
)
5213 if ((val
< 0) || (val
> 60000))
5215 vport
->cfg_max_scsicmpl_time
= val
;
5217 spin_lock_irq(shost
->host_lock
);
5218 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
5219 if (!NLP_CHK_NODE_ACT(ndlp
))
5221 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
5223 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
5225 spin_unlock_irq(shost
->host_lock
);
5228 lpfc_vport_param_store(max_scsicmpl_time
);
5229 static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time
);
5232 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
5233 # range is [0,1]. Default value is 0.
5235 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
5238 * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds
5239 * range is [0,1]. Default value is 0.
5240 * For [0], FCP commands are issued to Work Queues ina round robin fashion.
5241 * For [1], FCP commands are issued to a Work Queue associated with the
5244 * LPFC_FCP_SCHED_ROUND_ROBIN == 0
5245 * LPFC_FCP_SCHED_BY_CPU == 1
5247 * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu
5248 * affinity for FCP/NVME I/Os through Work Queues associated with the current
5249 * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os
5250 * through WQs will be used.
5252 LPFC_ATTR_RW(fcp_io_sched
, LPFC_FCP_SCHED_ROUND_ROBIN
,
5253 LPFC_FCP_SCHED_ROUND_ROBIN
,
5254 LPFC_FCP_SCHED_BY_CPU
,
5255 "Determine scheduling algorithm for "
5256 "issuing commands [0] - Round Robin, [1] - Current CPU");
5259 * lpfc_ns_query: Determine algrithmn for NameServer queries after RSCN
5260 * range is [0,1]. Default value is 0.
5261 * For [0], GID_FT is used for NameServer queries after RSCN (default)
5262 * For [1], GID_PT is used for NameServer queries after RSCN
5265 LPFC_ATTR_RW(ns_query
, LPFC_NS_QUERY_GID_FT
,
5266 LPFC_NS_QUERY_GID_FT
, LPFC_NS_QUERY_GID_PT
,
5267 "Determine algorithm NameServer queries after RSCN "
5268 "[0] - GID_FT, [1] - GID_PT");
5271 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
5272 # range is [0,1]. Default value is 0.
5273 # For [0], bus reset issues target reset to ALL devices
5274 # For [1], bus reset issues target reset to non-FCP2 devices
5276 LPFC_ATTR_RW(fcp2_no_tgt_reset
, 0, 0, 1, "Determine bus reset behavior for "
5277 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
5281 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
5282 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
5283 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
5284 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
5285 # cr_delay is set to 0.
5287 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
5288 "interrupt response is generated");
5290 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
5291 "interrupt response is generated");
5294 # lpfc_multi_ring_support: Determines how many rings to spread available
5295 # cmd/rsp IOCB entries across.
5296 # Value range is [1,2]. Default value is 1.
5298 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
5299 "SLI rings to spread IOCB entries across");
5302 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
5303 # identifies what rctl value to configure the additional ring for.
5304 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
5306 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
5307 255, "Identifies RCTL for additional ring configuration");
5310 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
5311 # identifies what type value to configure the additional ring for.
5312 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
5314 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
5315 255, "Identifies TYPE for additional ring configuration");
5318 # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN
5319 # 0 = SmartSAN functionality disabled (default)
5320 # 1 = SmartSAN functionality enabled
5321 # This parameter will override the value of lpfc_fdmi_on module parameter.
5322 # Value range is [0,1]. Default value is 0.
5324 LPFC_ATTR_R(enable_SmartSAN
, 0, 0, 1, "Enable SmartSAN functionality");
5327 # lpfc_fdmi_on: Controls FDMI support.
5329 # 1 Traditional FDMI support (default)
5330 # Traditional FDMI support means the driver will assume FDMI-2 support;
5331 # however, if that fails, it will fallback to FDMI-1.
5332 # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on.
5333 # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of
5335 # Value range [0,1]. Default value is 1.
5337 LPFC_ATTR_R(fdmi_on
, 1, 0, 1, "Enable FDMI support");
5340 # Specifies the maximum number of ELS cmds we can have outstanding (for
5341 # discovery). Value range is [1,64]. Default value = 32.
5343 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
5344 "during discovery");
5347 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
5348 # will be scanned by the SCSI midlayer when sequential scanning is
5349 # used; and is also the highest LUN ID allowed when the SCSI midlayer
5350 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
5351 # LUN ID limit, but the SCSI midlayer requires this field for the uses
5352 # above. The lpfc driver limits the default value to 255 for two reasons.
5353 # As it bounds the sequential scan loop, scanning for thousands of luns
5354 # on a target can take minutes of wall clock time. Additionally,
5355 # there are FC targets, such as JBODs, that only recognize 8-bits of
5356 # LUN ID. When they receive a value greater than 8 bits, they chop off
5357 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
5358 # and so on all as LUN ID 0. This causes the linux kernel, which sees
5359 # valid responses at each of the LUN IDs, to believe there are multiple
5360 # devices present, when in fact, there is only 1.
5361 # A customer that is aware of their target behaviors, and the results as
5362 # indicated above, is welcome to increase the lpfc_max_luns value.
5363 # As mentioned, this value is not used by the lpfc driver, only the
5365 # Value range is [0,65535]. Default value is 255.
5366 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
5368 LPFC_VPORT_ULL_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN ID");
5371 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
5372 # Value range is [1,255], default value is 10.
5374 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
5375 "Milliseconds driver will wait between polling FCP ring");
5378 # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands
5379 # to complete in seconds. Value range is [5,180], default value is 60.
5381 LPFC_ATTR_RW(task_mgmt_tmo
, 60, 5, 180,
5382 "Maximum time to wait for task management commands to complete");
5384 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
5385 # support this feature
5388 # 2 = MSI-X enabled (default)
5389 # Value range is [0,2]. Default value is 2.
5391 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
5392 "MSI-X (2), if possible");
5395 * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs
5397 * 0 = NVME OAS disabled
5398 * 1 = NVME OAS enabled
5400 * Value range is [0,1]. Default value is 0.
5402 LPFC_ATTR_RW(nvme_oas
, 0, 0, 1,
5403 "Use OAS bit on NVME IOs");
5406 * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs
5408 * 0 = Put NVME Command in SGL
5409 * 1 = Embed NVME Command in WQE (unless G7)
5410 * 2 = Embed NVME Command in WQE (force)
5412 * Value range is [0,2]. Default value is 1.
5414 LPFC_ATTR_RW(nvme_embed_cmd
, 1, 0, 2,
5415 "Embed NVME Command in WQE");
5418 * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver
5419 * will advertise it supports to the SCSI layer. This also will map to
5420 * the number of WQs the driver will create.
5422 * 0 = Configure the number of io channels to the number of active CPUs.
5423 * 1,32 = Manually specify how many io channels to use.
5425 * Value range is [0,32]. Default value is 4.
5427 LPFC_ATTR_R(fcp_io_channel
,
5428 LPFC_FCP_IO_CHAN_DEF
,
5429 LPFC_HBA_IO_CHAN_MIN
, LPFC_HBA_IO_CHAN_MAX
,
5430 "Set the number of FCP I/O channels");
5433 * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver
5434 * will advertise it supports to the NVME layer. This also will map to
5435 * the number of WQs the driver will create.
5437 * This module parameter is valid when lpfc_enable_fc4_type is set
5440 * The NVME Layer will try to create this many, plus 1 administrative
5441 * hardware queue. The administrative queue will always map to WQ 0
5442 * A hardware IO queue maps (qidx) to a specific driver WQ.
5444 * 0 = Configure the number of io channels to the number of active CPUs.
5445 * 1,32 = Manually specify how many io channels to use.
5447 * Value range is [0,32]. Default value is 0.
5449 LPFC_ATTR_R(nvme_io_channel
,
5450 LPFC_NVME_IO_CHAN_DEF
,
5451 LPFC_HBA_IO_CHAN_MIN
, LPFC_HBA_IO_CHAN_MAX
,
5452 "Set the number of NVME I/O channels");
5455 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
5456 # 0 = HBA resets disabled
5457 # 1 = HBA resets enabled (default)
5458 # 2 = HBA reset via PCI bus reset enabled
5459 # Value range is [0,2]. Default value is 1.
5461 LPFC_ATTR_RW(enable_hba_reset
, 1, 0, 2, "Enable HBA resets from the driver.");
5464 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
5465 # 0 = HBA Heartbeat disabled
5466 # 1 = HBA Heartbeat enabled (default)
5467 # Value range is [0,1]. Default value is 1.
5469 LPFC_ATTR_R(enable_hba_heartbeat
, 0, 0, 1, "Enable HBA Heartbeat.");
5472 # lpfc_EnableXLane: Enable Express Lane Feature
5473 # 0x0 Express Lane Feature disabled
5474 # 0x1 Express Lane Feature enabled
5475 # Value range is [0,1]. Default value is 0.
5477 LPFC_ATTR_R(EnableXLane
, 0, 0, 1, "Enable Express Lane Feature.");
5480 # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature
5481 # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits)
5482 # Value range is [0x0,0x7f]. Default value is 0
5484 LPFC_ATTR_RW(XLanePriority
, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
5487 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
5488 # 0 = BlockGuard disabled (default)
5489 # 1 = BlockGuard enabled
5490 # Value range is [0,1]. Default value is 0.
5492 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
5495 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
5496 # 0 = disabled (default)
5498 # Value range is [0,1]. Default value is 0.
5500 # This feature in under investigation and may be supported in the future.
5502 unsigned int lpfc_fcp_look_ahead
= LPFC_LOOK_AHEAD_OFF
;
5506 # - Bit mask of host protection capabilities used to register with the
5508 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
5509 # - Allows you to ultimately specify which profiles to use
5510 # - Default will result in registering capabilities for all profiles.
5511 # - SHOST_DIF_TYPE1_PROTECTION 1
5512 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
5513 # - SHOST_DIX_TYPE0_PROTECTION 8
5514 # HBA supports DIX Type 0: Host to HBA protection only
5515 # - SHOST_DIX_TYPE1_PROTECTION 16
5516 # HBA supports DIX Type 1: Host to HBA Type 1 protection
5519 LPFC_ATTR(prot_mask
,
5520 (SHOST_DIF_TYPE1_PROTECTION
|
5521 SHOST_DIX_TYPE0_PROTECTION
|
5522 SHOST_DIX_TYPE1_PROTECTION
),
5524 (SHOST_DIF_TYPE1_PROTECTION
|
5525 SHOST_DIX_TYPE0_PROTECTION
|
5526 SHOST_DIX_TYPE1_PROTECTION
),
5527 "T10-DIF host protection capabilities mask");
5530 # lpfc_prot_guard: i
5531 # - Bit mask of protection guard types to register with the SCSI mid-layer
5532 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
5533 # - Allows you to ultimately specify which profiles to use
5534 # - Default will result in registering capabilities for all guard types
5537 LPFC_ATTR(prot_guard
,
5538 SHOST_DIX_GUARD_IP
, SHOST_DIX_GUARD_CRC
, SHOST_DIX_GUARD_IP
,
5539 "T10-DIF host protection guard type");
5542 * Delay initial NPort discovery when Clean Address bit is cleared in
5543 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
5544 * This parameter can have value 0 or 1.
5545 * When this parameter is set to 0, no delay is added to the initial
5547 * When this parameter is set to non-zero value, initial Nport discovery is
5548 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
5549 * accept and FCID/Fabric name/Fabric portname is changed.
5550 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
5551 * when Clean Address bit is cleared in FLOGI/FDISC
5552 * accept and FCID/Fabric name/Fabric portname is changed.
5553 * Default value is 0.
5555 LPFC_ATTR(delay_discovery
, 0, 0, 1,
5556 "Delay NPort discovery when Clean Address bit is cleared.");
5559 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
5560 * This value can be set to values between 64 and 4096. The default value
5561 * is 64, but may be increased to allow for larger Max I/O sizes. The scsi
5562 * and nvme layers will allow I/O sizes up to (MAX_SEG_COUNT * SEG_SIZE).
5563 * Because of the additional overhead involved in setting up T10-DIF,
5564 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
5565 * and will be limited to 512 if BlockGuard is enabled under SLI3.
5567 static uint lpfc_sg_seg_cnt
= LPFC_DEFAULT_SG_SEG_CNT
;
5568 module_param(lpfc_sg_seg_cnt
, uint
, 0444);
5569 MODULE_PARM_DESC(lpfc_sg_seg_cnt
, "Max Scatter Gather Segment Count");
5572 * lpfc_sg_seg_cnt_show - Display the scatter/gather list sizes
5573 * configured for the adapter
5574 * @dev: class converted to a Scsi_host structure.
5575 * @attr: device attribute, not used.
5576 * @buf: on return contains a string with the list sizes
5578 * Returns: size of formatted string.
5581 lpfc_sg_seg_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
5584 struct Scsi_Host
*shost
= class_to_shost(dev
);
5585 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5586 struct lpfc_hba
*phba
= vport
->phba
;
5589 len
= snprintf(buf
, PAGE_SIZE
, "SGL sz: %d total SGEs: %d\n",
5590 phba
->cfg_sg_dma_buf_size
, phba
->cfg_total_seg_cnt
);
5592 len
+= snprintf(buf
+ len
, PAGE_SIZE
, "Cfg: %d SCSI: %d NVME: %d\n",
5593 phba
->cfg_sg_seg_cnt
, phba
->cfg_scsi_seg_cnt
,
5594 phba
->cfg_nvme_seg_cnt
);
5598 static DEVICE_ATTR_RO(lpfc_sg_seg_cnt
);
5601 * lpfc_sg_seg_cnt_init - Set the hba sg_seg_cnt initial value
5602 * @phba: lpfc_hba pointer.
5603 * @val: contains the initial value
5606 * Validates the initial value is within range and assigns it to the
5607 * adapter. If not in range, an error message is posted and the
5608 * default value is assigned.
5611 * zero if value is in range and is set
5612 * -EINVAL if value was out of range
5615 lpfc_sg_seg_cnt_init(struct lpfc_hba
*phba
, int val
)
5617 if (val
>= LPFC_MIN_SG_SEG_CNT
&& val
<= LPFC_MAX_SG_SEG_CNT
) {
5618 phba
->cfg_sg_seg_cnt
= val
;
5621 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5622 "0409 "LPFC_DRIVER_NAME
"_sg_seg_cnt attribute cannot "
5623 "be set to %d, allowed range is [%d, %d]\n",
5624 val
, LPFC_MIN_SG_SEG_CNT
, LPFC_MAX_SG_SEG_CNT
);
5625 phba
->cfg_sg_seg_cnt
= LPFC_DEFAULT_SG_SEG_CNT
;
5630 * lpfc_enable_mds_diags: Enable MDS Diagnostics
5631 * 0 = MDS Diagnostics disabled (default)
5632 * 1 = MDS Diagnostics enabled
5633 * Value range is [0,1]. Default value is 0.
5635 LPFC_ATTR_R(enable_mds_diags
, 0, 0, 1, "Enable MDS Diagnostics");
5638 * lpfc_ras_fwlog_buffsize: Firmware logging host buffer size
5639 * 0 = Disable firmware logging (default)
5640 * [1-4] = Multiple of 1/4th Mb of host memory for FW logging
5641 * Value range [0..4]. Default value is 0
5643 LPFC_ATTR_RW(ras_fwlog_buffsize
, 0, 0, 4, "Host memory for FW logging");
5646 * lpfc_ras_fwlog_level: Firmware logging verbosity level
5647 * Valid only if firmware logging is enabled
5648 * 0(Least Verbosity) 4 (most verbosity)
5649 * Value range is [0..4]. Default value is 0
5651 LPFC_ATTR_RW(ras_fwlog_level
, 0, 0, 4, "Firmware Logging Level");
5654 * lpfc_ras_fwlog_func: Firmware logging enabled on function number
5655 * Default function which has RAS support : 0
5656 * Value Range is [0..7].
5657 * FW logging is a global action and enablement is via a specific
5660 LPFC_ATTR_RW(ras_fwlog_func
, 0, 0, 7, "Firmware Logging Enabled on Function");
5663 * lpfc_enable_bbcr: Enable BB Credit Recovery
5664 * 0 = BB Credit Recovery disabled
5665 * 1 = BB Credit Recovery enabled (default)
5666 * Value range is [0,1]. Default value is 1.
5668 LPFC_BBCR_ATTR_RW(enable_bbcr
, 1, 0, 1, "Enable BBC Recovery");
5671 * lpfc_enable_dpp: Enable DPP on G7
5672 * 0 = DPP on G7 disabled
5673 * 1 = DPP on G7 enabled (default)
5674 * Value range is [0,1]. Default value is 1.
5676 LPFC_ATTR_RW(enable_dpp
, 1, 0, 1, "Enable Direct Packet Push");
5678 struct device_attribute
*lpfc_hba_attrs
[] = {
5679 &dev_attr_nvme_info
,
5681 &dev_attr_bg_guard_err
,
5682 &dev_attr_bg_apptag_err
,
5683 &dev_attr_bg_reftag_err
,
5685 &dev_attr_serialnum
,
5686 &dev_attr_modeldesc
,
5687 &dev_attr_modelname
,
5688 &dev_attr_programtype
,
5692 &dev_attr_option_rom_version
,
5693 &dev_attr_link_state
,
5694 &dev_attr_num_discovered_ports
,
5695 &dev_attr_menlo_mgmt_mode
,
5696 &dev_attr_lpfc_drvr_version
,
5697 &dev_attr_lpfc_enable_fip
,
5698 &dev_attr_lpfc_temp_sensor
,
5699 &dev_attr_lpfc_log_verbose
,
5700 &dev_attr_lpfc_lun_queue_depth
,
5701 &dev_attr_lpfc_tgt_queue_depth
,
5702 &dev_attr_lpfc_hba_queue_depth
,
5703 &dev_attr_lpfc_peer_port_login
,
5704 &dev_attr_lpfc_nodev_tmo
,
5705 &dev_attr_lpfc_devloss_tmo
,
5706 &dev_attr_lpfc_enable_fc4_type
,
5707 &dev_attr_lpfc_xri_split
,
5708 &dev_attr_lpfc_fcp_class
,
5709 &dev_attr_lpfc_use_adisc
,
5710 &dev_attr_lpfc_first_burst_size
,
5711 &dev_attr_lpfc_ack0
,
5712 &dev_attr_lpfc_topology
,
5713 &dev_attr_lpfc_scan_down
,
5714 &dev_attr_lpfc_link_speed
,
5715 &dev_attr_lpfc_fcp_io_sched
,
5716 &dev_attr_lpfc_ns_query
,
5717 &dev_attr_lpfc_fcp2_no_tgt_reset
,
5718 &dev_attr_lpfc_cr_delay
,
5719 &dev_attr_lpfc_cr_count
,
5720 &dev_attr_lpfc_multi_ring_support
,
5721 &dev_attr_lpfc_multi_ring_rctl
,
5722 &dev_attr_lpfc_multi_ring_type
,
5723 &dev_attr_lpfc_fdmi_on
,
5724 &dev_attr_lpfc_enable_SmartSAN
,
5725 &dev_attr_lpfc_max_luns
,
5726 &dev_attr_lpfc_enable_npiv
,
5727 &dev_attr_lpfc_fcf_failover_policy
,
5728 &dev_attr_lpfc_enable_rrq
,
5729 &dev_attr_nport_evt_cnt
,
5730 &dev_attr_board_mode
,
5737 &dev_attr_npiv_info
,
5738 &dev_attr_issue_reset
,
5739 &dev_attr_lpfc_poll
,
5740 &dev_attr_lpfc_poll_tmo
,
5741 &dev_attr_lpfc_task_mgmt_tmo
,
5742 &dev_attr_lpfc_use_msi
,
5743 &dev_attr_lpfc_nvme_oas
,
5744 &dev_attr_lpfc_nvme_embed_cmd
,
5745 &dev_attr_lpfc_auto_imax
,
5746 &dev_attr_lpfc_fcp_imax
,
5747 &dev_attr_lpfc_fcp_cpu_map
,
5748 &dev_attr_lpfc_fcp_io_channel
,
5749 &dev_attr_lpfc_suppress_rsp
,
5750 &dev_attr_lpfc_nvme_io_channel
,
5751 &dev_attr_lpfc_nvmet_mrq
,
5752 &dev_attr_lpfc_nvmet_mrq_post
,
5753 &dev_attr_lpfc_nvme_enable_fb
,
5754 &dev_attr_lpfc_nvmet_fb_size
,
5755 &dev_attr_lpfc_enable_bg
,
5756 &dev_attr_lpfc_soft_wwnn
,
5757 &dev_attr_lpfc_soft_wwpn
,
5758 &dev_attr_lpfc_soft_wwn_enable
,
5759 &dev_attr_lpfc_enable_hba_reset
,
5760 &dev_attr_lpfc_enable_hba_heartbeat
,
5761 &dev_attr_lpfc_EnableXLane
,
5762 &dev_attr_lpfc_XLanePriority
,
5763 &dev_attr_lpfc_xlane_lun
,
5764 &dev_attr_lpfc_xlane_tgt
,
5765 &dev_attr_lpfc_xlane_vpt
,
5766 &dev_attr_lpfc_xlane_lun_state
,
5767 &dev_attr_lpfc_xlane_lun_status
,
5768 &dev_attr_lpfc_xlane_priority
,
5769 &dev_attr_lpfc_sg_seg_cnt
,
5770 &dev_attr_lpfc_max_scsicmpl_time
,
5771 &dev_attr_lpfc_stat_data_ctrl
,
5772 &dev_attr_lpfc_aer_support
,
5773 &dev_attr_lpfc_aer_state_cleanup
,
5774 &dev_attr_lpfc_sriov_nr_virtfn
,
5775 &dev_attr_lpfc_req_fw_upgrade
,
5776 &dev_attr_lpfc_suppress_link_up
,
5777 &dev_attr_lpfc_iocb_cnt
,
5780 &dev_attr_txcmplq_hw
,
5781 &dev_attr_lpfc_fips_level
,
5782 &dev_attr_lpfc_fips_rev
,
5784 &dev_attr_lpfc_sriov_hw_max_virtfn
,
5786 &dev_attr_lpfc_xlane_supported
,
5787 &dev_attr_lpfc_enable_mds_diags
,
5788 &dev_attr_lpfc_ras_fwlog_buffsize
,
5789 &dev_attr_lpfc_ras_fwlog_level
,
5790 &dev_attr_lpfc_ras_fwlog_func
,
5791 &dev_attr_lpfc_enable_bbcr
,
5792 &dev_attr_lpfc_enable_dpp
,
5796 struct device_attribute
*lpfc_vport_attrs
[] = {
5798 &dev_attr_link_state
,
5799 &dev_attr_num_discovered_ports
,
5800 &dev_attr_lpfc_drvr_version
,
5801 &dev_attr_lpfc_log_verbose
,
5802 &dev_attr_lpfc_lun_queue_depth
,
5803 &dev_attr_lpfc_tgt_queue_depth
,
5804 &dev_attr_lpfc_nodev_tmo
,
5805 &dev_attr_lpfc_devloss_tmo
,
5806 &dev_attr_lpfc_hba_queue_depth
,
5807 &dev_attr_lpfc_peer_port_login
,
5808 &dev_attr_lpfc_restrict_login
,
5809 &dev_attr_lpfc_fcp_class
,
5810 &dev_attr_lpfc_use_adisc
,
5811 &dev_attr_lpfc_first_burst_size
,
5812 &dev_attr_lpfc_max_luns
,
5813 &dev_attr_nport_evt_cnt
,
5814 &dev_attr_npiv_info
,
5815 &dev_attr_lpfc_enable_da_id
,
5816 &dev_attr_lpfc_max_scsicmpl_time
,
5817 &dev_attr_lpfc_stat_data_ctrl
,
5818 &dev_attr_lpfc_static_vport
,
5819 &dev_attr_lpfc_fips_level
,
5820 &dev_attr_lpfc_fips_rev
,
5825 * sysfs_ctlreg_write - Write method for writing to ctlreg
5826 * @filp: open sysfs file
5827 * @kobj: kernel kobject that contains the kernel class device.
5828 * @bin_attr: kernel attributes passed to us.
5829 * @buf: contains the data to be written to the adapter IOREG space.
5830 * @off: offset into buffer to beginning of data.
5831 * @count: bytes to transfer.
5834 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5835 * Uses the adapter io control registers to send buf contents to the adapter.
5838 * -ERANGE off and count combo out of range
5839 * -EINVAL off, count or buff address invalid
5840 * -EPERM adapter is offline
5841 * value of count, buf contents written
5844 sysfs_ctlreg_write(struct file
*filp
, struct kobject
*kobj
,
5845 struct bin_attribute
*bin_attr
,
5846 char *buf
, loff_t off
, size_t count
)
5849 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
5850 struct Scsi_Host
*shost
= class_to_shost(dev
);
5851 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5852 struct lpfc_hba
*phba
= vport
->phba
;
5854 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5857 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5860 if (count
<= LPFC_REG_WRITE_KEY_SIZE
)
5863 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5866 /* This is to protect HBA registers from accidental writes. */
5867 if (memcmp(buf
, LPFC_REG_WRITE_KEY
, LPFC_REG_WRITE_KEY_SIZE
))
5870 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
))
5873 spin_lock_irq(&phba
->hbalock
);
5874 for (buf_off
= 0; buf_off
< count
- LPFC_REG_WRITE_KEY_SIZE
;
5875 buf_off
+= sizeof(uint32_t))
5876 writel(*((uint32_t *)(buf
+ buf_off
+ LPFC_REG_WRITE_KEY_SIZE
)),
5877 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5879 spin_unlock_irq(&phba
->hbalock
);
5885 * sysfs_ctlreg_read - Read method for reading from ctlreg
5886 * @filp: open sysfs file
5887 * @kobj: kernel kobject that contains the kernel class device.
5888 * @bin_attr: kernel attributes passed to us.
5889 * @buf: if successful contains the data from the adapter IOREG space.
5890 * @off: offset into buffer to beginning of data.
5891 * @count: bytes to transfer.
5894 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5895 * Uses the adapter io control registers to read data into buf.
5898 * -ERANGE off and count combo out of range
5899 * -EINVAL off, count or buff address invalid
5900 * value of count, buf contents read
5903 sysfs_ctlreg_read(struct file
*filp
, struct kobject
*kobj
,
5904 struct bin_attribute
*bin_attr
,
5905 char *buf
, loff_t off
, size_t count
)
5909 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
5910 struct Scsi_Host
*shost
= class_to_shost(dev
);
5911 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5912 struct lpfc_hba
*phba
= vport
->phba
;
5914 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5917 if (off
> FF_REG_AREA_SIZE
)
5920 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5921 count
= FF_REG_AREA_SIZE
- off
;
5923 if (count
== 0) return 0;
5925 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5928 spin_lock_irq(&phba
->hbalock
);
5930 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
5931 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
5932 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5935 spin_unlock_irq(&phba
->hbalock
);
5940 static struct bin_attribute sysfs_ctlreg_attr
= {
5943 .mode
= S_IRUSR
| S_IWUSR
,
5946 .read
= sysfs_ctlreg_read
,
5947 .write
= sysfs_ctlreg_write
,
5951 * sysfs_mbox_write - Write method for writing information via mbox
5952 * @filp: open sysfs file
5953 * @kobj: kernel kobject that contains the kernel class device.
5954 * @bin_attr: kernel attributes passed to us.
5955 * @buf: contains the data to be written to sysfs mbox.
5956 * @off: offset into buffer to beginning of data.
5957 * @count: bytes to transfer.
5960 * Deprecated function. All mailbox access from user space is performed via the
5964 * -EPERM operation not permitted
5967 sysfs_mbox_write(struct file
*filp
, struct kobject
*kobj
,
5968 struct bin_attribute
*bin_attr
,
5969 char *buf
, loff_t off
, size_t count
)
5975 * sysfs_mbox_read - Read method for reading information via mbox
5976 * @filp: open sysfs file
5977 * @kobj: kernel kobject that contains the kernel class device.
5978 * @bin_attr: kernel attributes passed to us.
5979 * @buf: contains the data to be read from sysfs mbox.
5980 * @off: offset into buffer to beginning of data.
5981 * @count: bytes to transfer.
5984 * Deprecated function. All mailbox access from user space is performed via the
5988 * -EPERM operation not permitted
5991 sysfs_mbox_read(struct file
*filp
, struct kobject
*kobj
,
5992 struct bin_attribute
*bin_attr
,
5993 char *buf
, loff_t off
, size_t count
)
5998 static struct bin_attribute sysfs_mbox_attr
= {
6001 .mode
= S_IRUSR
| S_IWUSR
,
6003 .size
= MAILBOX_SYSFS_MAX
,
6004 .read
= sysfs_mbox_read
,
6005 .write
= sysfs_mbox_write
,
6009 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
6010 * @vport: address of lpfc vport structure.
6014 * error return code from sysfs_create_bin_file()
6017 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
6019 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
6022 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
6023 &sysfs_drvr_stat_data_attr
);
6025 /* Virtual ports do not need ctrl_reg and mbox */
6026 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
6029 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
6030 &sysfs_ctlreg_attr
);
6032 goto out_remove_stat_attr
;
6034 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
6037 goto out_remove_ctlreg_attr
;
6040 out_remove_ctlreg_attr
:
6041 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
6042 out_remove_stat_attr
:
6043 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
6044 &sysfs_drvr_stat_data_attr
);
6050 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
6051 * @vport: address of lpfc vport structure.
6054 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
6056 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
6057 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
6058 &sysfs_drvr_stat_data_attr
);
6059 /* Virtual ports do not need ctrl_reg and mbox */
6060 if (vport
->port_type
== LPFC_NPIV_PORT
)
6062 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
6063 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
6067 * Dynamic FC Host Attributes Support
6071 * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host
6072 * @shost: kernel scsi host pointer.
6075 lpfc_get_host_symbolic_name(struct Scsi_Host
*shost
)
6077 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
6079 lpfc_vport_symbolic_node_name(vport
, fc_host_symbolic_name(shost
),
6080 sizeof fc_host_symbolic_name(shost
));
6084 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
6085 * @shost: kernel scsi host pointer.
6088 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
6090 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6092 /* note: fc_myDID already in cpu endianness */
6093 fc_host_port_id(shost
) = vport
->fc_myDID
;
6097 * lpfc_get_host_port_type - Set the value of the scsi host port type
6098 * @shost: kernel scsi host pointer.
6101 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
6103 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6104 struct lpfc_hba
*phba
= vport
->phba
;
6106 spin_lock_irq(shost
->host_lock
);
6108 if (vport
->port_type
== LPFC_NPIV_PORT
) {
6109 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
6110 } else if (lpfc_is_link_up(phba
)) {
6111 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
6112 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
6113 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
6115 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
6117 if (vport
->fc_flag
& FC_FABRIC
)
6118 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
6120 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
6123 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
6125 spin_unlock_irq(shost
->host_lock
);
6129 * lpfc_get_host_port_state - Set the value of the scsi host port state
6130 * @shost: kernel scsi host pointer.
6133 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
6135 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6136 struct lpfc_hba
*phba
= vport
->phba
;
6138 spin_lock_irq(shost
->host_lock
);
6140 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
6141 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
6143 switch (phba
->link_state
) {
6144 case LPFC_LINK_UNKNOWN
:
6145 case LPFC_LINK_DOWN
:
6146 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
6150 case LPFC_HBA_READY
:
6151 /* Links up, reports port state accordingly */
6152 if (vport
->port_state
< LPFC_VPORT_READY
)
6153 fc_host_port_state(shost
) =
6154 FC_PORTSTATE_BYPASSED
;
6156 fc_host_port_state(shost
) =
6157 FC_PORTSTATE_ONLINE
;
6159 case LPFC_HBA_ERROR
:
6160 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
6163 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
6168 spin_unlock_irq(shost
->host_lock
);
6172 * lpfc_get_host_speed - Set the value of the scsi host speed
6173 * @shost: kernel scsi host pointer.
6176 lpfc_get_host_speed(struct Scsi_Host
*shost
)
6178 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6179 struct lpfc_hba
*phba
= vport
->phba
;
6181 spin_lock_irq(shost
->host_lock
);
6183 if ((lpfc_is_link_up(phba
)) && (!(phba
->hba_flag
& HBA_FCOE_MODE
))) {
6184 switch(phba
->fc_linkspeed
) {
6185 case LPFC_LINK_SPEED_1GHZ
:
6186 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
6188 case LPFC_LINK_SPEED_2GHZ
:
6189 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
6191 case LPFC_LINK_SPEED_4GHZ
:
6192 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
6194 case LPFC_LINK_SPEED_8GHZ
:
6195 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
6197 case LPFC_LINK_SPEED_10GHZ
:
6198 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
6200 case LPFC_LINK_SPEED_16GHZ
:
6201 fc_host_speed(shost
) = FC_PORTSPEED_16GBIT
;
6203 case LPFC_LINK_SPEED_32GHZ
:
6204 fc_host_speed(shost
) = FC_PORTSPEED_32GBIT
;
6206 case LPFC_LINK_SPEED_64GHZ
:
6207 fc_host_speed(shost
) = FC_PORTSPEED_64GBIT
;
6209 case LPFC_LINK_SPEED_128GHZ
:
6210 fc_host_speed(shost
) = FC_PORTSPEED_128GBIT
;
6213 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
6216 } else if (lpfc_is_link_up(phba
) && (phba
->hba_flag
& HBA_FCOE_MODE
)) {
6217 switch (phba
->fc_linkspeed
) {
6218 case LPFC_ASYNC_LINK_SPEED_10GBPS
:
6219 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
6221 case LPFC_ASYNC_LINK_SPEED_25GBPS
:
6222 fc_host_speed(shost
) = FC_PORTSPEED_25GBIT
;
6224 case LPFC_ASYNC_LINK_SPEED_40GBPS
:
6225 fc_host_speed(shost
) = FC_PORTSPEED_40GBIT
;
6227 case LPFC_ASYNC_LINK_SPEED_100GBPS
:
6228 fc_host_speed(shost
) = FC_PORTSPEED_100GBIT
;
6231 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
6235 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
6237 spin_unlock_irq(shost
->host_lock
);
6241 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
6242 * @shost: kernel scsi host pointer.
6245 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
6247 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6248 struct lpfc_hba
*phba
= vport
->phba
;
6251 spin_lock_irq(shost
->host_lock
);
6253 if ((vport
->port_state
> LPFC_FLOGI
) &&
6254 ((vport
->fc_flag
& FC_FABRIC
) ||
6255 ((phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) &&
6256 (vport
->fc_flag
& FC_PUBLIC_LOOP
))))
6257 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
6259 /* fabric is local port if there is no F/FL_Port */
6262 spin_unlock_irq(shost
->host_lock
);
6264 fc_host_fabric_name(shost
) = node_name
;
6268 * lpfc_get_stats - Return statistical information about the adapter
6269 * @shost: kernel scsi host pointer.
6272 * NULL on error for link down, no mbox pool, sli2 active,
6273 * management not allowed, memory allocation error, or mbox error.
6277 * address of the adapter host statistics
6279 static struct fc_host_statistics
*
6280 lpfc_get_stats(struct Scsi_Host
*shost
)
6282 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6283 struct lpfc_hba
*phba
= vport
->phba
;
6284 struct lpfc_sli
*psli
= &phba
->sli
;
6285 struct fc_host_statistics
*hs
= &phba
->link_stats
;
6286 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
6287 LPFC_MBOXQ_t
*pmboxq
;
6292 * prevent udev from issuing mailbox commands until the port is
6295 if (phba
->link_state
< LPFC_LINK_DOWN
||
6296 !phba
->mbox_mem_pool
||
6297 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
6300 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
6303 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
6306 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
6308 pmb
= &pmboxq
->u
.mb
;
6309 pmb
->mbxCommand
= MBX_READ_STATUS
;
6310 pmb
->mbxOwner
= OWN_HOST
;
6311 pmboxq
->ctx_buf
= NULL
;
6312 pmboxq
->vport
= vport
;
6314 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
6315 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
6317 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
6319 if (rc
!= MBX_SUCCESS
) {
6320 if (rc
!= MBX_TIMEOUT
)
6321 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6325 memset(hs
, 0, sizeof (struct fc_host_statistics
));
6327 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
6329 * The MBX_READ_STATUS returns tx_k_bytes which has to
6330 * converted to words
6332 hs
->tx_words
= (uint64_t)
6333 ((uint64_t)pmb
->un
.varRdStatus
.xmitByteCnt
6335 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
6336 hs
->rx_words
= (uint64_t)
6337 ((uint64_t)pmb
->un
.varRdStatus
.rcvByteCnt
6340 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
6341 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
6342 pmb
->mbxOwner
= OWN_HOST
;
6343 pmboxq
->ctx_buf
= NULL
;
6344 pmboxq
->vport
= vport
;
6346 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
6347 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
6349 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
6351 if (rc
!= MBX_SUCCESS
) {
6352 if (rc
!= MBX_TIMEOUT
)
6353 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6357 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
6358 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
6359 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
6360 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
6361 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
6362 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
6363 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
6365 hs
->link_failure_count
-= lso
->link_failure_count
;
6366 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
6367 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
6368 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
6369 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
6370 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
6371 hs
->error_frames
-= lso
->error_frames
;
6373 if (phba
->hba_flag
& HBA_FCOE_MODE
) {
6375 hs
->nos_count
= (phba
->link_events
>> 1);
6376 hs
->nos_count
-= lso
->link_events
;
6377 } else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
6378 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
6379 hs
->lip_count
-= lso
->link_events
;
6383 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
6384 hs
->nos_count
-= lso
->link_events
;
6387 hs
->dumped_frames
= -1;
6389 hs
->seconds_since_last_reset
= ktime_get_seconds() - psli
->stats_start
;
6391 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6397 * lpfc_reset_stats - Copy the adapter link stats information
6398 * @shost: kernel scsi host pointer.
6401 lpfc_reset_stats(struct Scsi_Host
*shost
)
6403 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6404 struct lpfc_hba
*phba
= vport
->phba
;
6405 struct lpfc_sli
*psli
= &phba
->sli
;
6406 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
6407 LPFC_MBOXQ_t
*pmboxq
;
6411 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
6414 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
6417 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
6419 pmb
= &pmboxq
->u
.mb
;
6420 pmb
->mbxCommand
= MBX_READ_STATUS
;
6421 pmb
->mbxOwner
= OWN_HOST
;
6422 pmb
->un
.varWords
[0] = 0x1; /* reset request */
6423 pmboxq
->ctx_buf
= NULL
;
6424 pmboxq
->vport
= vport
;
6426 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
6427 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
6428 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
6430 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
6432 if (rc
!= MBX_SUCCESS
) {
6433 if (rc
!= MBX_TIMEOUT
)
6434 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6438 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
6439 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
6440 pmb
->mbxOwner
= OWN_HOST
;
6441 pmboxq
->ctx_buf
= NULL
;
6442 pmboxq
->vport
= vport
;
6444 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
6445 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
6446 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
6448 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
6450 if (rc
!= MBX_SUCCESS
) {
6451 if (rc
!= MBX_TIMEOUT
)
6452 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
6456 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
6457 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
6458 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
6459 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
6460 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
6461 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
6462 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
6463 if (phba
->hba_flag
& HBA_FCOE_MODE
)
6464 lso
->link_events
= (phba
->link_events
>> 1);
6466 lso
->link_events
= (phba
->fc_eventTag
>> 1);
6468 psli
->stats_start
= ktime_get_seconds();
6470 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6476 * The LPFC driver treats linkdown handling as target loss events so there
6477 * are no sysfs handlers for link_down_tmo.
6481 * lpfc_get_node_by_target - Return the nodelist for a target
6482 * @starget: kernel scsi target pointer.
6485 * address of the node list if found
6486 * NULL target not found
6488 static struct lpfc_nodelist
*
6489 lpfc_get_node_by_target(struct scsi_target
*starget
)
6491 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
6492 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6493 struct lpfc_nodelist
*ndlp
;
6495 spin_lock_irq(shost
->host_lock
);
6496 /* Search for this, mapped, target ID */
6497 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
6498 if (NLP_CHK_NODE_ACT(ndlp
) &&
6499 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
6500 starget
->id
== ndlp
->nlp_sid
) {
6501 spin_unlock_irq(shost
->host_lock
);
6505 spin_unlock_irq(shost
->host_lock
);
6510 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
6511 * @starget: kernel scsi target pointer.
6514 lpfc_get_starget_port_id(struct scsi_target
*starget
)
6516 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6518 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
6522 * lpfc_get_starget_node_name - Set the target node name
6523 * @starget: kernel scsi target pointer.
6525 * Description: Set the target node name to the ndlp node name wwn or zero.
6528 lpfc_get_starget_node_name(struct scsi_target
*starget
)
6530 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6532 fc_starget_node_name(starget
) =
6533 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
6537 * lpfc_get_starget_port_name - Set the target port name
6538 * @starget: kernel scsi target pointer.
6540 * Description: set the target port name to the ndlp port name wwn or zero.
6543 lpfc_get_starget_port_name(struct scsi_target
*starget
)
6545 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6547 fc_starget_port_name(starget
) =
6548 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
6552 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
6553 * @rport: fc rport address.
6554 * @timeout: new value for dev loss tmo.
6557 * If timeout is non zero set the dev_loss_tmo to timeout, else set
6558 * dev_loss_tmo to one.
6561 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
6564 rport
->dev_loss_tmo
= timeout
;
6566 rport
->dev_loss_tmo
= 1;
6570 * lpfc_rport_show_function - Return rport target information
6573 * Macro that uses field to generate a function with the name lpfc_show_rport_
6575 * lpfc_show_rport_##field: returns the bytes formatted in buf
6576 * @cdev: class converted to an fc_rport.
6577 * @buf: on return contains the target_field or zero.
6579 * Returns: size of formatted string.
6581 #define lpfc_rport_show_function(field, format_string, sz, cast) \
6583 lpfc_show_rport_##field (struct device *dev, \
6584 struct device_attribute *attr, \
6587 struct fc_rport *rport = transport_class_to_rport(dev); \
6588 struct lpfc_rport_data *rdata = rport->hostdata; \
6589 return snprintf(buf, sz, format_string, \
6590 (rdata->target) ? cast rdata->target->field : 0); \
6593 #define lpfc_rport_rd_attr(field, format_string, sz) \
6594 lpfc_rport_show_function(field, format_string, sz, ) \
6595 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
6598 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
6599 * @fc_vport: The fc_vport who's symbolic name has been changed.
6602 * This function is called by the transport after the @fc_vport's symbolic name
6603 * has been changed. This function re-registers the symbolic name with the
6604 * switch to propagate the change into the fabric if the vport is active.
6607 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
6609 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
6611 if (vport
->port_state
== LPFC_VPORT_READY
)
6612 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
6616 * lpfc_hba_log_verbose_init - Set hba's log verbose level
6617 * @phba: Pointer to lpfc_hba struct.
6619 * This function is called by the lpfc_get_cfgparam() routine to set the
6620 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
6621 * log message according to the module's lpfc_log_verbose parameter setting
6622 * before hba port or vport created.
6625 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
6627 phba
->cfg_log_verbose
= verbose
;
6630 struct fc_function_template lpfc_transport_functions
= {
6631 /* fixed attributes the driver supports */
6632 .show_host_node_name
= 1,
6633 .show_host_port_name
= 1,
6634 .show_host_supported_classes
= 1,
6635 .show_host_supported_fc4s
= 1,
6636 .show_host_supported_speeds
= 1,
6637 .show_host_maxframe_size
= 1,
6639 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6640 .show_host_symbolic_name
= 1,
6642 /* dynamic attributes the driver supports */
6643 .get_host_port_id
= lpfc_get_host_port_id
,
6644 .show_host_port_id
= 1,
6646 .get_host_port_type
= lpfc_get_host_port_type
,
6647 .show_host_port_type
= 1,
6649 .get_host_port_state
= lpfc_get_host_port_state
,
6650 .show_host_port_state
= 1,
6652 /* active_fc4s is shown but doesn't change (thus no get function) */
6653 .show_host_active_fc4s
= 1,
6655 .get_host_speed
= lpfc_get_host_speed
,
6656 .show_host_speed
= 1,
6658 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6659 .show_host_fabric_name
= 1,
6662 * The LPFC driver treats linkdown handling as target loss events
6663 * so there are no sysfs handlers for link_down_tmo.
6666 .get_fc_host_stats
= lpfc_get_stats
,
6667 .reset_fc_host_stats
= lpfc_reset_stats
,
6669 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6670 .show_rport_maxframe_size
= 1,
6671 .show_rport_supported_classes
= 1,
6673 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6674 .show_rport_dev_loss_tmo
= 1,
6676 .get_starget_port_id
= lpfc_get_starget_port_id
,
6677 .show_starget_port_id
= 1,
6679 .get_starget_node_name
= lpfc_get_starget_node_name
,
6680 .show_starget_node_name
= 1,
6682 .get_starget_port_name
= lpfc_get_starget_port_name
,
6683 .show_starget_port_name
= 1,
6685 .issue_fc_host_lip
= lpfc_issue_lip
,
6686 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6687 .terminate_rport_io
= lpfc_terminate_rport_io
,
6689 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
6691 .vport_disable
= lpfc_vport_disable
,
6693 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6695 .bsg_request
= lpfc_bsg_request
,
6696 .bsg_timeout
= lpfc_bsg_timeout
,
6699 struct fc_function_template lpfc_vport_transport_functions
= {
6700 /* fixed attributes the driver supports */
6701 .show_host_node_name
= 1,
6702 .show_host_port_name
= 1,
6703 .show_host_supported_classes
= 1,
6704 .show_host_supported_fc4s
= 1,
6705 .show_host_supported_speeds
= 1,
6706 .show_host_maxframe_size
= 1,
6708 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6709 .show_host_symbolic_name
= 1,
6711 /* dynamic attributes the driver supports */
6712 .get_host_port_id
= lpfc_get_host_port_id
,
6713 .show_host_port_id
= 1,
6715 .get_host_port_type
= lpfc_get_host_port_type
,
6716 .show_host_port_type
= 1,
6718 .get_host_port_state
= lpfc_get_host_port_state
,
6719 .show_host_port_state
= 1,
6721 /* active_fc4s is shown but doesn't change (thus no get function) */
6722 .show_host_active_fc4s
= 1,
6724 .get_host_speed
= lpfc_get_host_speed
,
6725 .show_host_speed
= 1,
6727 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6728 .show_host_fabric_name
= 1,
6731 * The LPFC driver treats linkdown handling as target loss events
6732 * so there are no sysfs handlers for link_down_tmo.
6735 .get_fc_host_stats
= lpfc_get_stats
,
6736 .reset_fc_host_stats
= lpfc_reset_stats
,
6738 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6739 .show_rport_maxframe_size
= 1,
6740 .show_rport_supported_classes
= 1,
6742 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6743 .show_rport_dev_loss_tmo
= 1,
6745 .get_starget_port_id
= lpfc_get_starget_port_id
,
6746 .show_starget_port_id
= 1,
6748 .get_starget_node_name
= lpfc_get_starget_node_name
,
6749 .show_starget_node_name
= 1,
6751 .get_starget_port_name
= lpfc_get_starget_port_name
,
6752 .show_starget_port_name
= 1,
6754 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6755 .terminate_rport_io
= lpfc_terminate_rport_io
,
6757 .vport_disable
= lpfc_vport_disable
,
6759 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6763 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
6764 * @phba: lpfc_hba pointer.
6767 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
6769 lpfc_fcp_io_sched_init(phba
, lpfc_fcp_io_sched
);
6770 lpfc_ns_query_init(phba
, lpfc_ns_query
);
6771 lpfc_fcp2_no_tgt_reset_init(phba
, lpfc_fcp2_no_tgt_reset
);
6772 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
6773 lpfc_cr_count_init(phba
, lpfc_cr_count
);
6774 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
6775 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
6776 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
6777 lpfc_ack0_init(phba
, lpfc_ack0
);
6778 lpfc_topology_init(phba
, lpfc_topology
);
6779 lpfc_link_speed_init(phba
, lpfc_link_speed
);
6780 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
6781 lpfc_task_mgmt_tmo_init(phba
, lpfc_task_mgmt_tmo
);
6782 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
6783 lpfc_fcf_failover_policy_init(phba
, lpfc_fcf_failover_policy
);
6784 lpfc_enable_rrq_init(phba
, lpfc_enable_rrq
);
6785 lpfc_fdmi_on_init(phba
, lpfc_fdmi_on
);
6786 lpfc_enable_SmartSAN_init(phba
, lpfc_enable_SmartSAN
);
6787 lpfc_use_msi_init(phba
, lpfc_use_msi
);
6788 lpfc_nvme_oas_init(phba
, lpfc_nvme_oas
);
6789 lpfc_nvme_embed_cmd_init(phba
, lpfc_nvme_embed_cmd
);
6790 lpfc_auto_imax_init(phba
, lpfc_auto_imax
);
6791 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
6792 lpfc_fcp_cpu_map_init(phba
, lpfc_fcp_cpu_map
);
6793 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
6794 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
6796 lpfc_EnableXLane_init(phba
, lpfc_EnableXLane
);
6797 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
6798 phba
->cfg_EnableXLane
= 0;
6799 lpfc_XLanePriority_init(phba
, lpfc_XLanePriority
);
6801 memset(phba
->cfg_oas_tgt_wwpn
, 0, (8 * sizeof(uint8_t)));
6802 memset(phba
->cfg_oas_vpt_wwpn
, 0, (8 * sizeof(uint8_t)));
6803 phba
->cfg_oas_lun_state
= 0;
6804 phba
->cfg_oas_lun_status
= 0;
6805 phba
->cfg_oas_flags
= 0;
6806 phba
->cfg_oas_priority
= 0;
6807 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
6808 lpfc_prot_mask_init(phba
, lpfc_prot_mask
);
6809 lpfc_prot_guard_init(phba
, lpfc_prot_guard
);
6810 if (phba
->sli_rev
== LPFC_SLI_REV4
)
6813 phba
->cfg_poll
= lpfc_poll
;
6815 if (phba
->cfg_enable_bg
)
6816 phba
->sli3_options
|= LPFC_SLI3_BG_ENABLED
;
6818 lpfc_suppress_rsp_init(phba
, lpfc_suppress_rsp
);
6820 lpfc_enable_fc4_type_init(phba
, lpfc_enable_fc4_type
);
6821 lpfc_nvmet_mrq_init(phba
, lpfc_nvmet_mrq
);
6822 lpfc_nvmet_mrq_post_init(phba
, lpfc_nvmet_mrq_post
);
6824 /* Initialize first burst. Target vs Initiator are different. */
6825 lpfc_nvme_enable_fb_init(phba
, lpfc_nvme_enable_fb
);
6826 lpfc_nvmet_fb_size_init(phba
, lpfc_nvmet_fb_size
);
6827 lpfc_fcp_io_channel_init(phba
, lpfc_fcp_io_channel
);
6828 lpfc_nvme_io_channel_init(phba
, lpfc_nvme_io_channel
);
6829 lpfc_enable_bbcr_init(phba
, lpfc_enable_bbcr
);
6830 lpfc_enable_dpp_init(phba
, lpfc_enable_dpp
);
6832 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
6833 /* NVME only supported on SLI4 */
6834 phba
->nvmet_support
= 0;
6835 phba
->cfg_enable_fc4_type
= LPFC_ENABLE_FCP
;
6836 phba
->cfg_enable_bbcr
= 0;
6838 /* We MUST have FCP support */
6839 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_FCP
))
6840 phba
->cfg_enable_fc4_type
|= LPFC_ENABLE_FCP
;
6843 if (phba
->cfg_auto_imax
&& !phba
->cfg_fcp_imax
)
6844 phba
->cfg_auto_imax
= 0;
6845 phba
->initial_imax
= phba
->cfg_fcp_imax
;
6847 phba
->cfg_enable_pbde
= 0;
6849 /* A value of 0 means use the number of CPUs found in the system */
6850 if (phba
->cfg_fcp_io_channel
== 0)
6851 phba
->cfg_fcp_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6852 if (phba
->cfg_nvme_io_channel
== 0)
6853 phba
->cfg_nvme_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6855 if (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
)
6856 phba
->cfg_fcp_io_channel
= 0;
6858 if (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_FCP
)
6859 phba
->cfg_nvme_io_channel
= 0;
6861 if (phba
->cfg_fcp_io_channel
> phba
->cfg_nvme_io_channel
)
6862 phba
->io_channel_irqs
= phba
->cfg_fcp_io_channel
;
6864 phba
->io_channel_irqs
= phba
->cfg_nvme_io_channel
;
6866 phba
->cfg_soft_wwnn
= 0L;
6867 phba
->cfg_soft_wwpn
= 0L;
6868 lpfc_xri_split_init(phba
, lpfc_xri_split
);
6869 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
6870 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
6871 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
6872 lpfc_aer_support_init(phba
, lpfc_aer_support
);
6873 lpfc_sriov_nr_virtfn_init(phba
, lpfc_sriov_nr_virtfn
);
6874 lpfc_request_firmware_upgrade_init(phba
, lpfc_req_fw_upgrade
);
6875 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
6876 lpfc_iocb_cnt_init(phba
, lpfc_iocb_cnt
);
6877 lpfc_delay_discovery_init(phba
, lpfc_delay_discovery
);
6878 lpfc_sli_mode_init(phba
, lpfc_sli_mode
);
6879 phba
->cfg_enable_dss
= 1;
6880 lpfc_enable_mds_diags_init(phba
, lpfc_enable_mds_diags
);
6881 lpfc_ras_fwlog_buffsize_init(phba
, lpfc_ras_fwlog_buffsize
);
6882 lpfc_ras_fwlog_level_init(phba
, lpfc_ras_fwlog_level
);
6883 lpfc_ras_fwlog_func_init(phba
, lpfc_ras_fwlog_func
);
6886 /* If the NVME FC4 type is enabled, scale the sg_seg_cnt to
6887 * accommodate 512K and 1M IOs in a single nvme buf and supply
6888 * enough NVME LS iocb buffers for larger connectivity counts.
6890 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
) {
6891 phba
->cfg_sg_seg_cnt
= LPFC_MAX_NVME_SEG_CNT
;
6892 phba
->cfg_iocb_cnt
= 5;
6899 * lpfc_nvme_mod_param_dep - Adjust module parameter value based on
6900 * dependencies between protocols and roles.
6901 * @phba: lpfc_hba pointer.
6904 lpfc_nvme_mod_param_dep(struct lpfc_hba
*phba
)
6906 if (phba
->cfg_nvme_io_channel
> phba
->sli4_hba
.num_present_cpu
)
6907 phba
->cfg_nvme_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6909 if (phba
->cfg_fcp_io_channel
> phba
->sli4_hba
.num_present_cpu
)
6910 phba
->cfg_fcp_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6912 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
&&
6913 phba
->nvmet_support
) {
6914 phba
->cfg_enable_fc4_type
&= ~LPFC_ENABLE_FCP
;
6915 phba
->cfg_fcp_io_channel
= 0;
6917 lpfc_printf_log(phba
, KERN_INFO
, LOG_NVME_DISC
,
6918 "6013 %s x%x fb_size x%x, fb_max x%x\n",
6919 "NVME Target PRLI ACC enable_fb ",
6920 phba
->cfg_nvme_enable_fb
,
6921 phba
->cfg_nvmet_fb_size
,
6922 LPFC_NVMET_FB_SZ_MAX
);
6924 if (phba
->cfg_nvme_enable_fb
== 0)
6925 phba
->cfg_nvmet_fb_size
= 0;
6927 if (phba
->cfg_nvmet_fb_size
> LPFC_NVMET_FB_SZ_MAX
)
6928 phba
->cfg_nvmet_fb_size
= LPFC_NVMET_FB_SZ_MAX
;
6931 if (!phba
->cfg_nvmet_mrq
)
6932 phba
->cfg_nvmet_mrq
= phba
->cfg_nvme_io_channel
;
6934 /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */
6935 if (phba
->cfg_nvmet_mrq
> phba
->cfg_nvme_io_channel
) {
6936 phba
->cfg_nvmet_mrq
= phba
->cfg_nvme_io_channel
;
6937 lpfc_printf_log(phba
, KERN_ERR
, LOG_NVME_DISC
,
6938 "6018 Adjust lpfc_nvmet_mrq to %d\n",
6939 phba
->cfg_nvmet_mrq
);
6941 if (phba
->cfg_nvmet_mrq
> LPFC_NVMET_MRQ_MAX
)
6942 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_MAX
;
6945 /* Not NVME Target mode. Turn off Target parameters. */
6946 phba
->nvmet_support
= 0;
6947 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_OFF
;
6948 phba
->cfg_nvmet_fb_size
= 0;
6951 if (phba
->cfg_fcp_io_channel
> phba
->cfg_nvme_io_channel
)
6952 phba
->io_channel_irqs
= phba
->cfg_fcp_io_channel
;
6954 phba
->io_channel_irqs
= phba
->cfg_nvme_io_channel
;
6958 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
6959 * @vport: lpfc_vport pointer.
6962 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
6964 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
6965 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
6966 lpfc_tgt_queue_depth_init(vport
, lpfc_tgt_queue_depth
);
6967 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
6968 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
6969 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
6970 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
6971 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
6972 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
6973 lpfc_first_burst_size_init(vport
, lpfc_first_burst_size
);
6974 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
6975 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
6976 lpfc_max_luns_init(vport
, lpfc_max_luns
);
6977 lpfc_scan_down_init(vport
, lpfc_scan_down
);
6978 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);