1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2019 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
68 * Write key size should be multiple of 4. If write key is changed
69 * make sure that library write key is also changed.
71 #define LPFC_REG_WRITE_KEY_SIZE 4
72 #define LPFC_REG_WRITE_KEY "EMLX"
74 const char *const trunk_errmsg
[] = { /* map errcode */
75 "", /* There is no such error code at index 0*/
76 "link negotiated speed does not match existing"
77 " trunk - link was \"low\" speed",
78 "link negotiated speed does not match"
79 " existing trunk - link was \"middle\" speed",
80 "link negotiated speed does not match existing"
81 " trunk - link was \"high\" speed",
82 "Attached to non-trunking port - F_Port",
83 "Attached to non-trunking port - N_Port",
84 "FLOGI response timeout",
85 "non-FLOGI frame received",
86 "Invalid FLOGI response",
87 "Trunking initialization protocol",
88 "Trunk peer device mismatch",
92 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
93 * @incr: integer to convert.
94 * @hdw: ascii string holding converted integer plus a string terminator.
97 * JEDEC Joint Electron Device Engineering Council.
98 * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii
99 * character string. The string is then terminated with a NULL in byte 9.
100 * Hex 0-9 becomes ascii '0' to '9'.
101 * Hex a-f becomes ascii '=' to 'B' capital B.
104 * Coded for 32 bit integers only.
107 lpfc_jedec_to_ascii(int incr
, char hdw
[])
110 for (i
= 0; i
< 8; i
++) {
113 hdw
[7 - i
] = 0x30 + j
;
115 hdw
[7 - i
] = 0x61 + j
- 10;
123 * lpfc_drvr_version_show - Return the Emulex driver string with version number
124 * @dev: class unused variable.
125 * @attr: device attribute, not used.
126 * @buf: on return contains the module description text.
128 * Returns: size of formatted string.
131 lpfc_drvr_version_show(struct device
*dev
, struct device_attribute
*attr
,
134 return scnprintf(buf
, PAGE_SIZE
, LPFC_MODULE_DESC
"\n");
138 * lpfc_enable_fip_show - Return the fip mode of the HBA
139 * @dev: class unused variable.
140 * @attr: device attribute, not used.
141 * @buf: on return contains the module description text.
143 * Returns: size of formatted string.
146 lpfc_enable_fip_show(struct device
*dev
, struct device_attribute
*attr
,
149 struct Scsi_Host
*shost
= class_to_shost(dev
);
150 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
151 struct lpfc_hba
*phba
= vport
->phba
;
153 if (phba
->hba_flag
& HBA_FIP_SUPPORT
)
154 return scnprintf(buf
, PAGE_SIZE
, "1\n");
156 return scnprintf(buf
, PAGE_SIZE
, "0\n");
160 lpfc_nvme_info_show(struct device
*dev
, struct device_attribute
*attr
,
163 struct Scsi_Host
*shost
= class_to_shost(dev
);
164 struct lpfc_vport
*vport
= shost_priv(shost
);
165 struct lpfc_hba
*phba
= vport
->phba
;
166 struct lpfc_nvmet_tgtport
*tgtp
;
167 struct nvme_fc_local_port
*localport
;
168 struct lpfc_nvme_lport
*lport
;
169 struct lpfc_nvme_rport
*rport
;
170 struct lpfc_nodelist
*ndlp
;
171 struct nvme_fc_remote_port
*nrport
;
172 struct lpfc_fc4_ctrl_stat
*cstat
;
173 uint64_t data1
, data2
, data3
;
174 uint64_t totin
, totout
, tot
;
178 char tmp
[LPFC_MAX_NVME_INFO_TMP_LEN
] = {0};
180 if (!(vport
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
)) {
181 len
= scnprintf(buf
, PAGE_SIZE
, "NVME Disabled\n");
184 if (phba
->nvmet_support
) {
185 if (!phba
->targetport
) {
186 len
= scnprintf(buf
, PAGE_SIZE
,
187 "NVME Target: x%llx is not allocated\n",
188 wwn_to_u64(vport
->fc_portname
.u
.wwn
));
191 /* Port state is only one of two values for now. */
192 if (phba
->targetport
->port_id
)
193 statep
= "REGISTERED";
196 scnprintf(tmp
, sizeof(tmp
),
197 "NVME Target Enabled State %s\n",
199 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
202 scnprintf(tmp
, sizeof(tmp
),
203 "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
206 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
207 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
208 phba
->targetport
->port_id
);
209 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
212 if (strlcat(buf
, "\nNVME Target: Statistics\n", PAGE_SIZE
)
216 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
217 scnprintf(tmp
, sizeof(tmp
),
218 "LS: Rcv %08x Drop %08x Abort %08x\n",
219 atomic_read(&tgtp
->rcv_ls_req_in
),
220 atomic_read(&tgtp
->rcv_ls_req_drop
),
221 atomic_read(&tgtp
->xmt_ls_abort
));
222 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
225 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
226 atomic_read(&tgtp
->rcv_ls_req_out
)) {
227 scnprintf(tmp
, sizeof(tmp
),
228 "Rcv LS: in %08x != out %08x\n",
229 atomic_read(&tgtp
->rcv_ls_req_in
),
230 atomic_read(&tgtp
->rcv_ls_req_out
));
231 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
235 scnprintf(tmp
, sizeof(tmp
),
236 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
237 atomic_read(&tgtp
->xmt_ls_rsp
),
238 atomic_read(&tgtp
->xmt_ls_drop
),
239 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
));
240 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
243 scnprintf(tmp
, sizeof(tmp
),
244 "LS: RSP Abort %08x xb %08x Err %08x\n",
245 atomic_read(&tgtp
->xmt_ls_rsp_aborted
),
246 atomic_read(&tgtp
->xmt_ls_rsp_xb_set
),
247 atomic_read(&tgtp
->xmt_ls_rsp_error
));
248 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
251 scnprintf(tmp
, sizeof(tmp
),
252 "FCP: Rcv %08x Defer %08x Release %08x "
254 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
255 atomic_read(&tgtp
->rcv_fcp_cmd_defer
),
256 atomic_read(&tgtp
->xmt_fcp_release
),
257 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
258 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
261 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
262 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
263 scnprintf(tmp
, sizeof(tmp
),
264 "Rcv FCP: in %08x != out %08x\n",
265 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
266 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
267 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
271 scnprintf(tmp
, sizeof(tmp
),
272 "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x "
274 atomic_read(&tgtp
->xmt_fcp_read
),
275 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
276 atomic_read(&tgtp
->xmt_fcp_write
),
277 atomic_read(&tgtp
->xmt_fcp_rsp
),
278 atomic_read(&tgtp
->xmt_fcp_drop
));
279 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
282 scnprintf(tmp
, sizeof(tmp
),
283 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
284 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
285 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
286 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
287 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
290 scnprintf(tmp
, sizeof(tmp
),
291 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
292 atomic_read(&tgtp
->xmt_fcp_rsp_aborted
),
293 atomic_read(&tgtp
->xmt_fcp_rsp_xb_set
),
294 atomic_read(&tgtp
->xmt_fcp_xri_abort_cqe
));
295 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
298 scnprintf(tmp
, sizeof(tmp
),
299 "ABORT: Xmt %08x Cmpl %08x\n",
300 atomic_read(&tgtp
->xmt_fcp_abort
),
301 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
302 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
305 scnprintf(tmp
, sizeof(tmp
),
306 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n",
307 atomic_read(&tgtp
->xmt_abort_sol
),
308 atomic_read(&tgtp
->xmt_abort_unsol
),
309 atomic_read(&tgtp
->xmt_abort_rsp
),
310 atomic_read(&tgtp
->xmt_abort_rsp_error
));
311 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
314 scnprintf(tmp
, sizeof(tmp
),
315 "DELAY: ctx %08x fod %08x wqfull %08x\n",
316 atomic_read(&tgtp
->defer_ctx
),
317 atomic_read(&tgtp
->defer_fod
),
318 atomic_read(&tgtp
->defer_wqfull
));
319 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
322 /* Calculate outstanding IOs */
323 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_drop
);
324 tot
+= atomic_read(&tgtp
->xmt_fcp_release
);
325 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_in
) - tot
;
327 scnprintf(tmp
, sizeof(tmp
),
328 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
329 "CTX Outstanding %08llx\n\n",
330 phba
->sli4_hba
.nvmet_xri_cnt
,
331 phba
->sli4_hba
.nvmet_io_wait_cnt
,
332 phba
->sli4_hba
.nvmet_io_wait_total
,
334 strlcat(buf
, tmp
, PAGE_SIZE
);
338 localport
= vport
->localport
;
340 len
= scnprintf(buf
, PAGE_SIZE
,
341 "NVME Initiator x%llx is not allocated\n",
342 wwn_to_u64(vport
->fc_portname
.u
.wwn
));
345 lport
= (struct lpfc_nvme_lport
*)localport
->private;
346 if (strlcat(buf
, "\nNVME Initiator Enabled\n", PAGE_SIZE
) >= PAGE_SIZE
)
350 scnprintf(tmp
, sizeof(tmp
),
351 "XRI Dist lpfc%d Total %d IO %d ELS %d\n",
353 phba
->sli4_hba
.max_cfg_param
.max_xri
,
354 phba
->sli4_hba
.io_xri_max
,
355 lpfc_sli4_get_els_iocb_cnt(phba
));
356 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
359 /* Port state is only one of two values for now. */
360 if (localport
->port_id
)
365 scnprintf(tmp
, sizeof(tmp
),
366 "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
369 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
370 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
371 localport
->port_id
, statep
);
372 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
375 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
377 spin_lock(&vport
->phba
->hbalock
);
378 rport
= lpfc_ndlp_get_nrport(ndlp
);
380 nrport
= rport
->remoteport
;
381 spin_unlock(&vport
->phba
->hbalock
);
385 /* Port state is only one of two values for now. */
386 switch (nrport
->port_state
) {
387 case FC_OBJSTATE_ONLINE
:
390 case FC_OBJSTATE_UNKNOWN
:
394 statep
= "UNSUPPORTED";
398 /* Tab in to show lport ownership. */
399 if (strlcat(buf
, "NVME RPORT ", PAGE_SIZE
) >= PAGE_SIZE
)
401 if (phba
->brd_no
>= 10) {
402 if (strlcat(buf
, " ", PAGE_SIZE
) >= PAGE_SIZE
)
406 scnprintf(tmp
, sizeof(tmp
), "WWPN x%llx ",
408 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
411 scnprintf(tmp
, sizeof(tmp
), "WWNN x%llx ",
413 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
416 scnprintf(tmp
, sizeof(tmp
), "DID x%06x ",
418 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
421 /* An NVME rport can have multiple roles. */
422 if (nrport
->port_role
& FC_PORT_ROLE_NVME_INITIATOR
) {
423 if (strlcat(buf
, "INITIATOR ", PAGE_SIZE
) >= PAGE_SIZE
)
426 if (nrport
->port_role
& FC_PORT_ROLE_NVME_TARGET
) {
427 if (strlcat(buf
, "TARGET ", PAGE_SIZE
) >= PAGE_SIZE
)
430 if (nrport
->port_role
& FC_PORT_ROLE_NVME_DISCOVERY
) {
431 if (strlcat(buf
, "DISCSRVC ", PAGE_SIZE
) >= PAGE_SIZE
)
434 if (nrport
->port_role
& ~(FC_PORT_ROLE_NVME_INITIATOR
|
435 FC_PORT_ROLE_NVME_TARGET
|
436 FC_PORT_ROLE_NVME_DISCOVERY
)) {
437 scnprintf(tmp
, sizeof(tmp
), "UNKNOWN ROLE x%x",
439 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
443 scnprintf(tmp
, sizeof(tmp
), "%s\n", statep
);
444 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
452 if (strlcat(buf
, "\nNVME Statistics\n", PAGE_SIZE
) >= PAGE_SIZE
)
455 scnprintf(tmp
, sizeof(tmp
),
456 "LS: Xmt %010x Cmpl %010x Abort %08x\n",
457 atomic_read(&lport
->fc4NvmeLsRequests
),
458 atomic_read(&lport
->fc4NvmeLsCmpls
),
459 atomic_read(&lport
->xmt_ls_abort
));
460 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
463 scnprintf(tmp
, sizeof(tmp
),
464 "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n",
465 atomic_read(&lport
->xmt_ls_err
),
466 atomic_read(&lport
->cmpl_ls_xb
),
467 atomic_read(&lport
->cmpl_ls_err
));
468 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
473 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
474 cstat
= &phba
->sli4_hba
.hdwq
[i
].nvme_cstat
;
475 tot
= cstat
->io_cmpls
;
477 data1
= cstat
->input_requests
;
478 data2
= cstat
->output_requests
;
479 data3
= cstat
->control_requests
;
480 totout
+= (data1
+ data2
+ data3
);
482 scnprintf(tmp
, sizeof(tmp
),
483 "Total FCP Cmpl %016llx Issue %016llx "
485 totin
, totout
, totout
- totin
);
486 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
489 scnprintf(tmp
, sizeof(tmp
),
490 "\tabort %08x noxri %08x nondlp %08x qdepth %08x "
491 "wqerr %08x err %08x\n",
492 atomic_read(&lport
->xmt_fcp_abort
),
493 atomic_read(&lport
->xmt_fcp_noxri
),
494 atomic_read(&lport
->xmt_fcp_bad_ndlp
),
495 atomic_read(&lport
->xmt_fcp_qdepth
),
496 atomic_read(&lport
->xmt_fcp_err
),
497 atomic_read(&lport
->xmt_fcp_wqerr
));
498 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
501 scnprintf(tmp
, sizeof(tmp
),
502 "FCP CMPL: xb %08x Err %08x\n",
503 atomic_read(&lport
->cmpl_fcp_xb
),
504 atomic_read(&lport
->cmpl_fcp_err
));
505 strlcat(buf
, tmp
, PAGE_SIZE
);
508 len
= strnlen(buf
, PAGE_SIZE
);
510 if (unlikely(len
>= (PAGE_SIZE
- 1))) {
511 lpfc_printf_log(phba
, KERN_INFO
, LOG_NVME
,
512 "6314 Catching potential buffer "
513 "overflow > PAGE_SIZE = %lu bytes\n",
515 strlcpy(buf
+ PAGE_SIZE
- 1 -
516 strnlen(LPFC_NVME_INFO_MORE_STR
, PAGE_SIZE
- 1),
517 LPFC_NVME_INFO_MORE_STR
,
518 strnlen(LPFC_NVME_INFO_MORE_STR
, PAGE_SIZE
- 1)
526 lpfc_scsi_stat_show(struct device
*dev
, struct device_attribute
*attr
,
529 struct Scsi_Host
*shost
= class_to_shost(dev
);
530 struct lpfc_vport
*vport
= shost_priv(shost
);
531 struct lpfc_hba
*phba
= vport
->phba
;
533 struct lpfc_fc4_ctrl_stat
*cstat
;
534 u64 data1
, data2
, data3
;
535 u64 tot
, totin
, totout
;
537 char tmp
[LPFC_MAX_SCSI_INFO_TMP_LEN
] = {0};
539 if (!(vport
->cfg_enable_fc4_type
& LPFC_ENABLE_FCP
) ||
540 (phba
->sli_rev
!= LPFC_SLI_REV4
))
543 scnprintf(buf
, PAGE_SIZE
, "SCSI HDWQ Statistics\n");
547 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
548 cstat
= &phba
->sli4_hba
.hdwq
[i
].scsi_cstat
;
549 tot
= cstat
->io_cmpls
;
551 data1
= cstat
->input_requests
;
552 data2
= cstat
->output_requests
;
553 data3
= cstat
->control_requests
;
554 totout
+= (data1
+ data2
+ data3
);
556 scnprintf(tmp
, sizeof(tmp
), "HDWQ (%d): Rd %016llx Wr %016llx "
557 "IO %016llx ", i
, data1
, data2
, data3
);
558 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
561 scnprintf(tmp
, sizeof(tmp
), "Cmpl %016llx OutIO %016llx\n",
562 tot
, ((data1
+ data2
+ data3
) - tot
));
563 if (strlcat(buf
, tmp
, PAGE_SIZE
) >= PAGE_SIZE
)
566 scnprintf(tmp
, sizeof(tmp
), "Total FCP Cmpl %016llx Issue %016llx "
567 "OutIO %016llx\n", totin
, totout
, totout
- totin
);
568 strlcat(buf
, tmp
, PAGE_SIZE
);
571 len
= strnlen(buf
, PAGE_SIZE
);
577 lpfc_bg_info_show(struct device
*dev
, struct device_attribute
*attr
,
580 struct Scsi_Host
*shost
= class_to_shost(dev
);
581 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
582 struct lpfc_hba
*phba
= vport
->phba
;
584 if (phba
->cfg_enable_bg
) {
585 if (phba
->sli3_options
& LPFC_SLI3_BG_ENABLED
)
586 return scnprintf(buf
, PAGE_SIZE
,
587 "BlockGuard Enabled\n");
589 return scnprintf(buf
, PAGE_SIZE
,
590 "BlockGuard Not Supported\n");
592 return scnprintf(buf
, PAGE_SIZE
,
593 "BlockGuard Disabled\n");
597 lpfc_bg_guard_err_show(struct device
*dev
, struct device_attribute
*attr
,
600 struct Scsi_Host
*shost
= class_to_shost(dev
);
601 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
602 struct lpfc_hba
*phba
= vport
->phba
;
604 return scnprintf(buf
, PAGE_SIZE
, "%llu\n",
605 (unsigned long long)phba
->bg_guard_err_cnt
);
609 lpfc_bg_apptag_err_show(struct device
*dev
, struct device_attribute
*attr
,
612 struct Scsi_Host
*shost
= class_to_shost(dev
);
613 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
614 struct lpfc_hba
*phba
= vport
->phba
;
616 return scnprintf(buf
, PAGE_SIZE
, "%llu\n",
617 (unsigned long long)phba
->bg_apptag_err_cnt
);
621 lpfc_bg_reftag_err_show(struct device
*dev
, struct device_attribute
*attr
,
624 struct Scsi_Host
*shost
= class_to_shost(dev
);
625 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
626 struct lpfc_hba
*phba
= vport
->phba
;
628 return scnprintf(buf
, PAGE_SIZE
, "%llu\n",
629 (unsigned long long)phba
->bg_reftag_err_cnt
);
633 * lpfc_info_show - Return some pci info about the host in ascii
634 * @dev: class converted to a Scsi_host structure.
635 * @attr: device attribute, not used.
636 * @buf: on return contains the formatted text from lpfc_info().
638 * Returns: size of formatted string.
641 lpfc_info_show(struct device
*dev
, struct device_attribute
*attr
,
644 struct Scsi_Host
*host
= class_to_shost(dev
);
646 return scnprintf(buf
, PAGE_SIZE
, "%s\n", lpfc_info(host
));
650 * lpfc_serialnum_show - Return the hba serial number in ascii
651 * @dev: class converted to a Scsi_host structure.
652 * @attr: device attribute, not used.
653 * @buf: on return contains the formatted text serial number.
655 * Returns: size of formatted string.
658 lpfc_serialnum_show(struct device
*dev
, struct device_attribute
*attr
,
661 struct Scsi_Host
*shost
= class_to_shost(dev
);
662 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
663 struct lpfc_hba
*phba
= vport
->phba
;
665 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->SerialNumber
);
669 * lpfc_temp_sensor_show - Return the temperature sensor level
670 * @dev: class converted to a Scsi_host structure.
671 * @attr: device attribute, not used.
672 * @buf: on return contains the formatted support level.
675 * Returns a number indicating the temperature sensor level currently
676 * supported, zero or one in ascii.
678 * Returns: size of formatted string.
681 lpfc_temp_sensor_show(struct device
*dev
, struct device_attribute
*attr
,
684 struct Scsi_Host
*shost
= class_to_shost(dev
);
685 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
686 struct lpfc_hba
*phba
= vport
->phba
;
687 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->temp_sensor_support
);
691 * lpfc_modeldesc_show - Return the model description of the hba
692 * @dev: class converted to a Scsi_host structure.
693 * @attr: device attribute, not used.
694 * @buf: on return contains the scsi vpd model description.
696 * Returns: size of formatted string.
699 lpfc_modeldesc_show(struct device
*dev
, struct device_attribute
*attr
,
702 struct Scsi_Host
*shost
= class_to_shost(dev
);
703 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
704 struct lpfc_hba
*phba
= vport
->phba
;
706 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->ModelDesc
);
710 * lpfc_modelname_show - Return the model name of the hba
711 * @dev: class converted to a Scsi_host structure.
712 * @attr: device attribute, not used.
713 * @buf: on return contains the scsi vpd model name.
715 * Returns: size of formatted string.
718 lpfc_modelname_show(struct device
*dev
, struct device_attribute
*attr
,
721 struct Scsi_Host
*shost
= class_to_shost(dev
);
722 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
723 struct lpfc_hba
*phba
= vport
->phba
;
725 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->ModelName
);
729 * lpfc_programtype_show - Return the program type of the hba
730 * @dev: class converted to a Scsi_host structure.
731 * @attr: device attribute, not used.
732 * @buf: on return contains the scsi vpd program type.
734 * Returns: size of formatted string.
737 lpfc_programtype_show(struct device
*dev
, struct device_attribute
*attr
,
740 struct Scsi_Host
*shost
= class_to_shost(dev
);
741 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
742 struct lpfc_hba
*phba
= vport
->phba
;
744 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->ProgramType
);
748 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
749 * @dev: class converted to a Scsi_host structure.
750 * @attr: device attribute, not used.
751 * @buf: on return contains the Menlo Maintenance sli flag.
753 * Returns: size of formatted string.
756 lpfc_mlomgmt_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
758 struct Scsi_Host
*shost
= class_to_shost(dev
);
759 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
760 struct lpfc_hba
*phba
= vport
->phba
;
762 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
763 (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
));
767 * lpfc_vportnum_show - Return the port number in ascii of the hba
768 * @dev: class converted to a Scsi_host structure.
769 * @attr: device attribute, not used.
770 * @buf: on return contains scsi vpd program type.
772 * Returns: size of formatted string.
775 lpfc_vportnum_show(struct device
*dev
, struct device_attribute
*attr
,
778 struct Scsi_Host
*shost
= class_to_shost(dev
);
779 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
780 struct lpfc_hba
*phba
= vport
->phba
;
782 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->Port
);
786 * lpfc_fwrev_show - Return the firmware rev running in the hba
787 * @dev: class converted to a Scsi_host structure.
788 * @attr: device attribute, not used.
789 * @buf: on return contains the scsi vpd program type.
791 * Returns: size of formatted string.
794 lpfc_fwrev_show(struct device
*dev
, struct device_attribute
*attr
,
797 struct Scsi_Host
*shost
= class_to_shost(dev
);
798 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
799 struct lpfc_hba
*phba
= vport
->phba
;
802 char fwrev
[FW_REV_STR_SIZE
];
805 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
806 if_type
= phba
->sli4_hba
.pc_sli4_params
.if_type
;
807 sli_family
= phba
->sli4_hba
.pc_sli4_params
.sli_family
;
809 if (phba
->sli_rev
< LPFC_SLI_REV4
)
810 len
= scnprintf(buf
, PAGE_SIZE
, "%s, sli-%d\n",
811 fwrev
, phba
->sli_rev
);
813 len
= scnprintf(buf
, PAGE_SIZE
, "%s, sli-%d:%d:%x\n",
814 fwrev
, phba
->sli_rev
, if_type
, sli_family
);
820 * lpfc_hdw_show - Return the jedec information about the hba
821 * @dev: class converted to a Scsi_host structure.
822 * @attr: device attribute, not used.
823 * @buf: on return contains the scsi vpd program type.
825 * Returns: size of formatted string.
828 lpfc_hdw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
831 struct Scsi_Host
*shost
= class_to_shost(dev
);
832 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
833 struct lpfc_hba
*phba
= vport
->phba
;
834 lpfc_vpd_t
*vp
= &phba
->vpd
;
836 lpfc_jedec_to_ascii(vp
->rev
.biuRev
, hdw
);
837 return scnprintf(buf
, PAGE_SIZE
, "%s\n", hdw
);
841 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
842 * @dev: class converted to a Scsi_host structure.
843 * @attr: device attribute, not used.
844 * @buf: on return contains the ROM and FCode ascii strings.
846 * Returns: size of formatted string.
849 lpfc_option_rom_version_show(struct device
*dev
, struct device_attribute
*attr
,
852 struct Scsi_Host
*shost
= class_to_shost(dev
);
853 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
854 struct lpfc_hba
*phba
= vport
->phba
;
855 char fwrev
[FW_REV_STR_SIZE
];
857 if (phba
->sli_rev
< LPFC_SLI_REV4
)
858 return scnprintf(buf
, PAGE_SIZE
, "%s\n",
859 phba
->OptionROMVersion
);
861 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
862 return scnprintf(buf
, PAGE_SIZE
, "%s\n", fwrev
);
866 * lpfc_state_show - Return the link state of the port
867 * @dev: class converted to a Scsi_host structure.
868 * @attr: device attribute, not used.
869 * @buf: on return contains text describing the state of the link.
872 * The switch statement has no default so zero will be returned.
874 * Returns: size of formatted string.
877 lpfc_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
880 struct Scsi_Host
*shost
= class_to_shost(dev
);
881 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
882 struct lpfc_hba
*phba
= vport
->phba
;
885 switch (phba
->link_state
) {
886 case LPFC_LINK_UNKNOWN
:
887 case LPFC_WARM_START
:
888 case LPFC_INIT_START
:
889 case LPFC_INIT_MBX_CMDS
:
892 if (phba
->hba_flag
& LINK_DISABLED
)
893 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
894 "Link Down - User disabled\n");
896 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
902 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
, "Link Up - ");
904 switch (vport
->port_state
) {
905 case LPFC_LOCAL_CFG_LINK
:
906 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
907 "Configuring Link\n");
911 case LPFC_FABRIC_CFG_LINK
:
914 case LPFC_BUILD_DISC_LIST
:
916 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
919 case LPFC_VPORT_READY
:
920 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
924 case LPFC_VPORT_FAILED
:
925 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
929 case LPFC_VPORT_UNKNOWN
:
930 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
934 if (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
)
935 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
936 " Menlo Maint Mode\n");
937 else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
938 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
939 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
942 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
945 if (vport
->fc_flag
& FC_FABRIC
)
946 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
949 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
954 if ((phba
->sli_rev
== LPFC_SLI_REV4
) &&
955 ((bf_get(lpfc_sli_intf_if_type
,
956 &phba
->sli4_hba
.sli_intf
) ==
957 LPFC_SLI_INTF_IF_TYPE_6
))) {
958 struct lpfc_trunk_link link
= phba
->trunk_link
;
960 if (bf_get(lpfc_conf_trunk_port0
, &phba
->sli4_hba
))
961 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
962 "Trunk port 0: Link %s %s\n",
963 (link
.link0
.state
== LPFC_LINK_UP
) ?
965 trunk_errmsg
[link
.link0
.fault
]);
967 if (bf_get(lpfc_conf_trunk_port1
, &phba
->sli4_hba
))
968 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
969 "Trunk port 1: Link %s %s\n",
970 (link
.link1
.state
== LPFC_LINK_UP
) ?
972 trunk_errmsg
[link
.link1
.fault
]);
974 if (bf_get(lpfc_conf_trunk_port2
, &phba
->sli4_hba
))
975 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
976 "Trunk port 2: Link %s %s\n",
977 (link
.link2
.state
== LPFC_LINK_UP
) ?
979 trunk_errmsg
[link
.link2
.fault
]);
981 if (bf_get(lpfc_conf_trunk_port3
, &phba
->sli4_hba
))
982 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
983 "Trunk port 3: Link %s %s\n",
984 (link
.link3
.state
== LPFC_LINK_UP
) ?
986 trunk_errmsg
[link
.link3
.fault
]);
994 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
995 * @dev: class unused variable.
996 * @attr: device attribute, not used.
997 * @buf: on return contains the module description text.
999 * Returns: size of formatted string.
1002 lpfc_sli4_protocol_show(struct device
*dev
, struct device_attribute
*attr
,
1005 struct Scsi_Host
*shost
= class_to_shost(dev
);
1006 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1007 struct lpfc_hba
*phba
= vport
->phba
;
1009 if (phba
->sli_rev
< LPFC_SLI_REV4
)
1010 return scnprintf(buf
, PAGE_SIZE
, "fc\n");
1012 if (phba
->sli4_hba
.lnk_info
.lnk_dv
== LPFC_LNK_DAT_VAL
) {
1013 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_GE
)
1014 return scnprintf(buf
, PAGE_SIZE
, "fcoe\n");
1015 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_FC
)
1016 return scnprintf(buf
, PAGE_SIZE
, "fc\n");
1018 return scnprintf(buf
, PAGE_SIZE
, "unknown\n");
1022 * lpfc_oas_supported_show - Return whether or not Optimized Access Storage
1023 * (OAS) is supported.
1024 * @dev: class unused variable.
1025 * @attr: device attribute, not used.
1026 * @buf: on return contains the module description text.
1028 * Returns: size of formatted string.
1031 lpfc_oas_supported_show(struct device
*dev
, struct device_attribute
*attr
,
1034 struct Scsi_Host
*shost
= class_to_shost(dev
);
1035 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
1036 struct lpfc_hba
*phba
= vport
->phba
;
1038 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
1039 phba
->sli4_hba
.pc_sli4_params
.oas_supported
);
1043 * lpfc_link_state_store - Transition the link_state on an HBA port
1044 * @dev: class device that is converted into a Scsi_host.
1045 * @attr: device attribute, not used.
1046 * @buf: one or more lpfc_polling_flags values.
1050 * -EINVAL if the buffer is not "up" or "down"
1051 * return from link state change function if non-zero
1052 * length of the buf on success
1055 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
1056 const char *buf
, size_t count
)
1058 struct Scsi_Host
*shost
= class_to_shost(dev
);
1059 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1060 struct lpfc_hba
*phba
= vport
->phba
;
1062 int status
= -EINVAL
;
1064 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
1065 (phba
->link_state
== LPFC_LINK_DOWN
))
1066 status
= phba
->lpfc_hba_init_link(phba
, MBX_NOWAIT
);
1067 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
1068 (phba
->link_state
>= LPFC_LINK_UP
))
1069 status
= phba
->lpfc_hba_down_link(phba
, MBX_NOWAIT
);
1078 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
1079 * @dev: class device that is converted into a Scsi_host.
1080 * @attr: device attribute, not used.
1081 * @buf: on return contains the sum of fc mapped and unmapped.
1084 * Returns the ascii text number of the sum of the fc mapped and unmapped
1087 * Returns: size of formatted string.
1090 lpfc_num_discovered_ports_show(struct device
*dev
,
1091 struct device_attribute
*attr
, char *buf
)
1093 struct Scsi_Host
*shost
= class_to_shost(dev
);
1094 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1096 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
1097 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
1101 * lpfc_issue_lip - Misnomer, name carried over from long ago
1102 * @shost: Scsi_Host pointer.
1105 * Bring the link down gracefully then re-init the link. The firmware will
1106 * re-init the fiber channel interface as required. Does not issue a LIP.
1109 * -EPERM port offline or management commands are being blocked
1110 * -ENOMEM cannot allocate memory for the mailbox command
1111 * -EIO error sending the mailbox command
1115 lpfc_issue_lip(struct Scsi_Host
*shost
)
1117 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1118 struct lpfc_hba
*phba
= vport
->phba
;
1119 LPFC_MBOXQ_t
*pmboxq
;
1120 int mbxstatus
= MBXERR_ERROR
;
1123 * If the link is offline, disabled or BLOCK_MGMT_IO
1124 * it doesn't make any sense to allow issue_lip
1126 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
1127 (phba
->hba_flag
& LINK_DISABLED
) ||
1128 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
1131 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
1136 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1137 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
1138 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
1140 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
1142 if ((mbxstatus
== MBX_SUCCESS
) &&
1143 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
1144 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
1145 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1146 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
1147 phba
->cfg_link_speed
);
1148 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
1149 phba
->fc_ratov
* 2);
1150 if ((mbxstatus
== MBX_SUCCESS
) &&
1151 (pmboxq
->u
.mb
.mbxStatus
== MBXERR_SEC_NO_PERMISSION
))
1152 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
| LOG_SLI
,
1153 "2859 SLI authentication is required "
1154 "for INIT_LINK but has not done yet\n");
1157 lpfc_set_loopback_flag(phba
);
1158 if (mbxstatus
!= MBX_TIMEOUT
)
1159 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1161 if (mbxstatus
== MBXERR_ERROR
)
1168 lpfc_emptyq_wait(struct lpfc_hba
*phba
, struct list_head
*q
, spinlock_t
*lock
)
1172 spin_lock_irq(lock
);
1173 while (!list_empty(q
)) {
1174 spin_unlock_irq(lock
);
1176 if (cnt
++ > 250) { /* 5 secs */
1177 lpfc_printf_log(phba
, KERN_WARNING
, LOG_INIT
,
1179 "Outstanding IO when ",
1180 "bringing Adapter offline\n");
1183 spin_lock_irq(lock
);
1185 spin_unlock_irq(lock
);
1190 * lpfc_do_offline - Issues a mailbox command to bring the link down
1191 * @phba: lpfc_hba pointer.
1192 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
1195 * Assumes any error from lpfc_do_offline() will be negative.
1196 * Can wait up to 5 seconds for the port ring buffers count
1197 * to reach zero, prints a warning if it is not zero and continues.
1198 * lpfc_workq_post_event() returns a non-zero return code if call fails.
1201 * -EIO error posting the event
1205 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
1207 struct completion online_compl
;
1208 struct lpfc_queue
*qp
= NULL
;
1209 struct lpfc_sli_ring
*pring
;
1210 struct lpfc_sli
*psli
;
1215 init_completion(&online_compl
);
1216 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1217 LPFC_EVT_OFFLINE_PREP
);
1221 wait_for_completion(&online_compl
);
1229 * If freeing the queues have already started, don't access them.
1230 * Otherwise set FREE_WAIT to indicate that queues are being used
1231 * to hold the freeing process until we finish.
1233 spin_lock_irq(&phba
->hbalock
);
1234 if (!(psli
->sli_flag
& LPFC_QUEUE_FREE_INIT
)) {
1235 psli
->sli_flag
|= LPFC_QUEUE_FREE_WAIT
;
1237 spin_unlock_irq(&phba
->hbalock
);
1240 spin_unlock_irq(&phba
->hbalock
);
1242 /* Wait a little for things to settle down, but not
1243 * long enough for dev loss timeout to expire.
1245 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
1246 for (i
= 0; i
< psli
->num_rings
; i
++) {
1247 pring
= &psli
->sli3_ring
[i
];
1248 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1253 list_for_each_entry(qp
, &phba
->sli4_hba
.lpfc_wq_list
, wq_list
) {
1257 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1263 spin_lock_irq(&phba
->hbalock
);
1264 psli
->sli_flag
&= ~LPFC_QUEUE_FREE_WAIT
;
1265 spin_unlock_irq(&phba
->hbalock
);
1268 init_completion(&online_compl
);
1269 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
1273 wait_for_completion(&online_compl
);
1282 * lpfc_reset_pci_bus - resets PCI bridge controller's secondary bus of an HBA
1283 * @phba: lpfc_hba pointer.
1286 * Issues a PCI secondary bus reset for the phba->pcidev.
1289 * First walks the bus_list to ensure only PCI devices with Emulex
1290 * vendor id, device ids that support hot reset, only one occurrence
1291 * of function 0, and all ports on the bus are in offline mode to ensure the
1292 * hot reset only affects one valid HBA.
1295 * -ENOTSUPP, cfg_enable_hba_reset must be of value 2
1296 * -ENODEV, NULL ptr to pcidev
1297 * -EBADSLT, detected invalid device
1298 * -EBUSY, port is not in offline state
1302 lpfc_reset_pci_bus(struct lpfc_hba
*phba
)
1304 struct pci_dev
*pdev
= phba
->pcidev
;
1305 struct Scsi_Host
*shost
= NULL
;
1306 struct lpfc_hba
*phba_other
= NULL
;
1307 struct pci_dev
*ptr
= NULL
;
1310 if (phba
->cfg_enable_hba_reset
!= 2)
1314 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
, "8345 pdev NULL!\n");
1318 res
= lpfc_check_pci_resettable(phba
);
1322 /* Walk the list of devices on the pci_dev's bus */
1323 list_for_each_entry(ptr
, &pdev
->bus
->devices
, bus_list
) {
1324 /* Check port is offline */
1325 shost
= pci_get_drvdata(ptr
);
1328 ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
1329 if (!(phba_other
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
1330 lpfc_printf_log(phba_other
, KERN_INFO
, LOG_INIT
,
1331 "8349 WWPN = 0x%02x%02x%02x%02x"
1332 "%02x%02x%02x%02x is not "
1334 phba_other
->wwpn
[0],
1335 phba_other
->wwpn
[1],
1336 phba_other
->wwpn
[2],
1337 phba_other
->wwpn
[3],
1338 phba_other
->wwpn
[4],
1339 phba_other
->wwpn
[5],
1340 phba_other
->wwpn
[6],
1341 phba_other
->wwpn
[7]);
1347 /* Issue PCI bus reset */
1348 res
= pci_reset_bus(pdev
);
1350 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1351 "8350 PCI reset bus failed: %d\n", res
);
1358 * lpfc_selective_reset - Offline then onlines the port
1359 * @phba: lpfc_hba pointer.
1362 * If the port is configured to allow a reset then the hba is brought
1363 * offline then online.
1366 * Assumes any error from lpfc_do_offline() will be negative.
1367 * Do not make this function static.
1370 * lpfc_do_offline() return code if not zero
1371 * -EIO reset not configured or error posting the event
1375 lpfc_selective_reset(struct lpfc_hba
*phba
)
1377 struct completion online_compl
;
1381 if (!phba
->cfg_enable_hba_reset
)
1384 if (!(phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
1385 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1391 init_completion(&online_compl
);
1392 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1397 wait_for_completion(&online_compl
);
1406 * lpfc_issue_reset - Selectively resets an adapter
1407 * @dev: class device that is converted into a Scsi_host.
1408 * @attr: device attribute, not used.
1409 * @buf: containing the string "selective".
1410 * @count: unused variable.
1413 * If the buf contains the string "selective" then lpfc_selective_reset()
1414 * is called to perform the reset.
1417 * Assumes any error from lpfc_selective_reset() will be negative.
1418 * If lpfc_selective_reset() returns zero then the length of the buffer
1419 * is returned which indicates success
1422 * -EINVAL if the buffer does not contain the string "selective"
1423 * length of buf if lpfc-selective_reset() if the call succeeds
1424 * return value of lpfc_selective_reset() if the call fails
1427 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
1428 const char *buf
, size_t count
)
1430 struct Scsi_Host
*shost
= class_to_shost(dev
);
1431 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1432 struct lpfc_hba
*phba
= vport
->phba
;
1433 int status
= -EINVAL
;
1435 if (!phba
->cfg_enable_hba_reset
)
1438 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
1439 status
= phba
->lpfc_selective_reset(phba
);
1448 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
1449 * @phba: lpfc_hba pointer.
1452 * SLI4 interface type-2 device to wait on the sliport status register for
1453 * the readyness after performing a firmware reset.
1456 * zero for success, -EPERM when port does not have privilege to perform the
1457 * reset, -EIO when port timeout from recovering from the reset.
1460 * As the caller will interpret the return code by value, be careful in making
1461 * change or addition to return codes.
1464 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba
*phba
)
1466 struct lpfc_register portstat_reg
= {0};
1470 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1471 &portstat_reg
.word0
);
1473 /* verify if privileged for the request operation */
1474 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
) &&
1475 !bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1478 /* wait for the SLI port firmware ready after firmware reset */
1479 for (i
= 0; i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
; i
++) {
1481 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1482 &portstat_reg
.word0
);
1483 if (!bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1485 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
))
1487 if (!bf_get(lpfc_sliport_status_rdy
, &portstat_reg
))
1492 if (i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
)
1499 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
1500 * @phba: lpfc_hba pointer.
1503 * Request SLI4 interface type-2 device to perform a physical register set
1510 lpfc_sli4_pdev_reg_request(struct lpfc_hba
*phba
, uint32_t opcode
)
1512 struct completion online_compl
;
1513 struct pci_dev
*pdev
= phba
->pcidev
;
1514 uint32_t before_fc_flag
;
1515 uint32_t sriov_nr_virtfn
;
1517 int status
= 0, rc
= 0;
1518 int job_posted
= 1, sriov_err
;
1520 if (!phba
->cfg_enable_hba_reset
)
1523 if ((phba
->sli_rev
< LPFC_SLI_REV4
) ||
1524 (bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
) <
1525 LPFC_SLI_INTF_IF_TYPE_2
))
1528 /* Keep state if we need to restore back */
1529 before_fc_flag
= phba
->pport
->fc_flag
;
1530 sriov_nr_virtfn
= phba
->cfg_sriov_nr_virtfn
;
1532 /* Disable SR-IOV virtual functions if enabled */
1533 if (phba
->cfg_sriov_nr_virtfn
) {
1534 pci_disable_sriov(pdev
);
1535 phba
->cfg_sriov_nr_virtfn
= 0;
1538 if (opcode
== LPFC_FW_DUMP
)
1539 phba
->hba_flag
|= HBA_FW_DUMP_OP
;
1541 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1544 phba
->hba_flag
&= ~HBA_FW_DUMP_OP
;
1548 /* wait for the device to be quiesced before firmware reset */
1551 reg_val
= readl(phba
->sli4_hba
.conf_regs_memmap_p
+
1552 LPFC_CTL_PDEV_CTL_OFFSET
);
1554 if (opcode
== LPFC_FW_DUMP
)
1555 reg_val
|= LPFC_FW_DUMP_REQUEST
;
1556 else if (opcode
== LPFC_FW_RESET
)
1557 reg_val
|= LPFC_CTL_PDEV_CTL_FRST
;
1558 else if (opcode
== LPFC_DV_RESET
)
1559 reg_val
|= LPFC_CTL_PDEV_CTL_DRST
;
1561 writel(reg_val
, phba
->sli4_hba
.conf_regs_memmap_p
+
1562 LPFC_CTL_PDEV_CTL_OFFSET
);
1564 readl(phba
->sli4_hba
.conf_regs_memmap_p
+ LPFC_CTL_PDEV_CTL_OFFSET
);
1566 /* delay driver action following IF_TYPE_2 reset */
1567 rc
= lpfc_sli4_pdev_status_reg_wait(phba
);
1570 /* no privilege for reset */
1571 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1572 "3150 No privilege to perform the requested "
1573 "access: x%x\n", reg_val
);
1574 } else if (rc
== -EIO
) {
1575 /* reset failed, there is nothing more we can do */
1576 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1577 "3153 Fail to perform the requested "
1578 "access: x%x\n", reg_val
);
1582 /* keep the original port state */
1583 if (before_fc_flag
& FC_OFFLINE_MODE
)
1586 init_completion(&online_compl
);
1587 job_posted
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1592 wait_for_completion(&online_compl
);
1595 /* in any case, restore the virtual functions enabled as before */
1596 if (sriov_nr_virtfn
) {
1598 lpfc_sli_probe_sriov_nr_virtfn(phba
, sriov_nr_virtfn
);
1600 phba
->cfg_sriov_nr_virtfn
= sriov_nr_virtfn
;
1603 /* return proper error code */
1614 * lpfc_nport_evt_cnt_show - Return the number of nport events
1615 * @dev: class device that is converted into a Scsi_host.
1616 * @attr: device attribute, not used.
1617 * @buf: on return contains the ascii number of nport events.
1619 * Returns: size of formatted string.
1622 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
1625 struct Scsi_Host
*shost
= class_to_shost(dev
);
1626 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1627 struct lpfc_hba
*phba
= vport
->phba
;
1629 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
1633 lpfc_set_trunking(struct lpfc_hba
*phba
, char *buff_out
)
1635 LPFC_MBOXQ_t
*mbox
= NULL
;
1636 unsigned long val
= 0;
1640 if (!strncmp("enable", buff_out
,
1641 strlen("enable"))) {
1642 pval
= buff_out
+ strlen("enable") + 1;
1643 rc
= kstrtoul(pval
, 0, &val
);
1645 return rc
; /* Invalid number */
1646 } else if (!strncmp("disable", buff_out
,
1647 strlen("disable"))) {
1650 return -EINVAL
; /* Invalid command */
1655 val
= 0x0; /* Disable */
1658 val
= 0x1; /* Enable two port trunk */
1661 val
= 0x2; /* Enable four port trunk */
1667 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
,
1668 "0070 Set trunk mode with val %ld ", val
);
1670 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1674 lpfc_sli4_config(phba
, mbox
, LPFC_MBOX_SUBSYSTEM_FCOE
,
1675 LPFC_MBOX_OPCODE_FCOE_FC_SET_TRUNK_MODE
,
1676 12, LPFC_SLI4_MBX_EMBED
);
1678 bf_set(lpfc_mbx_set_trunk_mode
,
1679 &mbox
->u
.mqe
.un
.set_trunk_mode
,
1681 rc
= lpfc_sli_issue_mbox(phba
, mbox
, MBX_POLL
);
1683 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
,
1684 "0071 Set trunk mode failed with status: %d",
1686 if (rc
!= MBX_TIMEOUT
)
1687 mempool_free(mbox
, phba
->mbox_mem_pool
);
1693 * lpfc_board_mode_show - Return the state of the board
1694 * @dev: class device that is converted into a Scsi_host.
1695 * @attr: device attribute, not used.
1696 * @buf: on return contains the state of the adapter.
1698 * Returns: size of formatted string.
1701 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
1704 struct Scsi_Host
*shost
= class_to_shost(dev
);
1705 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1706 struct lpfc_hba
*phba
= vport
->phba
;
1709 if (phba
->link_state
== LPFC_HBA_ERROR
)
1711 else if (phba
->link_state
== LPFC_WARM_START
)
1712 state
= "warm start";
1713 else if (phba
->link_state
== LPFC_INIT_START
)
1718 return scnprintf(buf
, PAGE_SIZE
, "%s\n", state
);
1722 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1723 * @dev: class device that is converted into a Scsi_host.
1724 * @attr: device attribute, not used.
1725 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1726 * @count: unused variable.
1729 * -EACCES if enable hba reset not enabled
1730 * -EINVAL if the buffer does not contain a valid string (see above)
1731 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1732 * buf length greater than zero indicates success
1735 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
1736 const char *buf
, size_t count
)
1738 struct Scsi_Host
*shost
= class_to_shost(dev
);
1739 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1740 struct lpfc_hba
*phba
= vport
->phba
;
1741 struct completion online_compl
;
1742 char *board_mode_str
= NULL
;
1746 if (!phba
->cfg_enable_hba_reset
) {
1748 goto board_mode_out
;
1751 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1752 "3050 lpfc_board_mode set to %s\n", buf
);
1754 init_completion(&online_compl
);
1756 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
1757 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1761 goto board_mode_out
;
1763 wait_for_completion(&online_compl
);
1766 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
1767 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1768 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
1769 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1772 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
1773 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
1774 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1777 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
1778 else if (strncmp(buf
, "dump", sizeof("dump") - 1) == 0)
1779 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_DUMP
);
1780 else if (strncmp(buf
, "fw_reset", sizeof("fw_reset") - 1) == 0)
1781 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_RESET
);
1782 else if (strncmp(buf
, "dv_reset", sizeof("dv_reset") - 1) == 0)
1783 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_DV_RESET
);
1784 else if (strncmp(buf
, "pci_bus_reset", sizeof("pci_bus_reset") - 1)
1786 status
= lpfc_reset_pci_bus(phba
);
1787 else if (strncmp(buf
, "trunk", sizeof("trunk") - 1) == 0)
1788 status
= lpfc_set_trunking(phba
, (char *)buf
+ sizeof("trunk"));
1796 board_mode_str
= strchr(buf
, '\n');
1798 *board_mode_str
= '\0';
1799 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1800 "3097 Failed \"%s\", status(%d), "
1802 buf
, status
, phba
->pport
->fc_flag
);
1808 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1809 * @phba: pointer to the adapter structure.
1810 * @mxri: max xri count.
1811 * @axri: available xri count.
1812 * @mrpi: max rpi count.
1813 * @arpi: available rpi count.
1814 * @mvpi: max vpi count.
1815 * @avpi: available vpi count.
1818 * If an integer pointer for an count is not null then the value for the
1819 * count is returned.
1826 lpfc_get_hba_info(struct lpfc_hba
*phba
,
1827 uint32_t *mxri
, uint32_t *axri
,
1828 uint32_t *mrpi
, uint32_t *arpi
,
1829 uint32_t *mvpi
, uint32_t *avpi
)
1831 struct lpfc_mbx_read_config
*rd_config
;
1832 LPFC_MBOXQ_t
*pmboxq
;
1838 * prevent udev from issuing mailbox commands until the port is
1841 if (phba
->link_state
< LPFC_LINK_DOWN
||
1842 !phba
->mbox_mem_pool
||
1843 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
1846 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
1849 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1852 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1854 pmb
= &pmboxq
->u
.mb
;
1855 pmb
->mbxCommand
= MBX_READ_CONFIG
;
1856 pmb
->mbxOwner
= OWN_HOST
;
1857 pmboxq
->ctx_buf
= NULL
;
1859 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
1860 rc
= MBX_NOT_FINISHED
;
1862 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
1864 if (rc
!= MBX_SUCCESS
) {
1865 if (rc
!= MBX_TIMEOUT
)
1866 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1870 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1871 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
1873 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
1875 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
1876 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
1878 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
1880 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
1881 phba
->sli4_hba
.max_cfg_param
.xri_used
;
1883 /* Account for differences with SLI-3. Get vpi count from
1884 * mailbox data and subtract one for max vpi value.
1886 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
1887 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
1889 /* Limit the max we support */
1890 if (max_vpi
> LPFC_MAX_VPI
)
1891 max_vpi
= LPFC_MAX_VPI
;
1895 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
1898 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
1900 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
1902 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
1904 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
1906 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
1908 /* avail_vpi is only valid if link is up and ready */
1909 if (phba
->link_state
== LPFC_HBA_READY
)
1910 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
1912 *avpi
= pmb
->un
.varRdConfig
.max_vpi
;
1916 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1921 * lpfc_max_rpi_show - Return maximum rpi
1922 * @dev: class device that is converted into a Scsi_host.
1923 * @attr: device attribute, not used.
1924 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1927 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1928 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1929 * to "Unknown" and the buffer length is returned, therefore the caller
1930 * must check for "Unknown" in the buffer to detect a failure.
1932 * Returns: size of formatted string.
1935 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1938 struct Scsi_Host
*shost
= class_to_shost(dev
);
1939 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1940 struct lpfc_hba
*phba
= vport
->phba
;
1943 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
1944 return scnprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1945 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
1949 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1950 * @dev: class device that is converted into a Scsi_host.
1951 * @attr: device attribute, not used.
1952 * @buf: containing the used rpi count in decimal or "Unknown".
1955 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1956 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1957 * to "Unknown" and the buffer length is returned, therefore the caller
1958 * must check for "Unknown" in the buffer to detect a failure.
1960 * Returns: size of formatted string.
1963 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1966 struct Scsi_Host
*shost
= class_to_shost(dev
);
1967 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1968 struct lpfc_hba
*phba
= vport
->phba
;
1971 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1972 return scnprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1973 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
1977 * lpfc_max_xri_show - Return maximum xri
1978 * @dev: class device that is converted into a Scsi_host.
1979 * @attr: device attribute, not used.
1980 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1983 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1984 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1985 * to "Unknown" and the buffer length is returned, therefore the caller
1986 * must check for "Unknown" in the buffer to detect a failure.
1988 * Returns: size of formatted string.
1991 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1994 struct Scsi_Host
*shost
= class_to_shost(dev
);
1995 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1996 struct lpfc_hba
*phba
= vport
->phba
;
1999 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
2000 return scnprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
2001 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
2005 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
2006 * @dev: class device that is converted into a Scsi_host.
2007 * @attr: device attribute, not used.
2008 * @buf: on return contains the used xri count in decimal or "Unknown".
2011 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
2012 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
2013 * to "Unknown" and the buffer length is returned, therefore the caller
2014 * must check for "Unknown" in the buffer to detect a failure.
2016 * Returns: size of formatted string.
2019 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
2022 struct Scsi_Host
*shost
= class_to_shost(dev
);
2023 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2024 struct lpfc_hba
*phba
= vport
->phba
;
2027 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
2028 return scnprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
2029 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
2033 * lpfc_max_vpi_show - Return maximum vpi
2034 * @dev: class device that is converted into a Scsi_host.
2035 * @attr: device attribute, not used.
2036 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
2039 * Calls lpfc_get_hba_info() asking for just the mvpi count.
2040 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
2041 * to "Unknown" and the buffer length is returned, therefore the caller
2042 * must check for "Unknown" in the buffer to detect a failure.
2044 * Returns: size of formatted string.
2047 lpfc_max_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
2050 struct Scsi_Host
*shost
= class_to_shost(dev
);
2051 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2052 struct lpfc_hba
*phba
= vport
->phba
;
2055 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
2056 return scnprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
2057 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
2061 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
2062 * @dev: class device that is converted into a Scsi_host.
2063 * @attr: device attribute, not used.
2064 * @buf: on return contains the used vpi count in decimal or "Unknown".
2067 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
2068 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
2069 * to "Unknown" and the buffer length is returned, therefore the caller
2070 * must check for "Unknown" in the buffer to detect a failure.
2072 * Returns: size of formatted string.
2075 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
2078 struct Scsi_Host
*shost
= class_to_shost(dev
);
2079 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2080 struct lpfc_hba
*phba
= vport
->phba
;
2083 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
2084 return scnprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
2085 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
2089 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
2090 * @dev: class device that is converted into a Scsi_host.
2091 * @attr: device attribute, not used.
2092 * @buf: text that must be interpreted to determine if npiv is supported.
2095 * Buffer will contain text indicating npiv is not suppoerted on the port,
2096 * the port is an NPIV physical port, or it is an npiv virtual port with
2097 * the id of the vport.
2099 * Returns: size of formatted string.
2102 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
2105 struct Scsi_Host
*shost
= class_to_shost(dev
);
2106 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2107 struct lpfc_hba
*phba
= vport
->phba
;
2109 if (!(phba
->max_vpi
))
2110 return scnprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
2111 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
2112 return scnprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
2113 return scnprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
2117 * lpfc_poll_show - Return text about poll support for the adapter
2118 * @dev: class device that is converted into a Scsi_host.
2119 * @attr: device attribute, not used.
2120 * @buf: on return contains the cfg_poll in hex.
2123 * cfg_poll should be a lpfc_polling_flags type.
2125 * Returns: size of formatted string.
2128 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
2131 struct Scsi_Host
*shost
= class_to_shost(dev
);
2132 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2133 struct lpfc_hba
*phba
= vport
->phba
;
2135 return scnprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
2139 * lpfc_poll_store - Set the value of cfg_poll for the adapter
2140 * @dev: class device that is converted into a Scsi_host.
2141 * @attr: device attribute, not used.
2142 * @buf: one or more lpfc_polling_flags values.
2146 * buf contents converted to integer and checked for a valid value.
2149 * -EINVAL if the buffer connot be converted or is out of range
2150 * length of the buf on success
2153 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
2154 const char *buf
, size_t count
)
2156 struct Scsi_Host
*shost
= class_to_shost(dev
);
2157 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2158 struct lpfc_hba
*phba
= vport
->phba
;
2163 if (!isdigit(buf
[0]))
2166 if (sscanf(buf
, "%i", &val
) != 1)
2169 if ((val
& 0x3) != val
)
2172 if (phba
->sli_rev
== LPFC_SLI_REV4
)
2175 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
2176 "3051 lpfc_poll changed from %d to %d\n",
2177 phba
->cfg_poll
, val
);
2179 spin_lock_irq(&phba
->hbalock
);
2181 old_val
= phba
->cfg_poll
;
2183 if (val
& ENABLE_FCP_RING_POLLING
) {
2184 if ((val
& DISABLE_FCP_RING_INT
) &&
2185 !(old_val
& DISABLE_FCP_RING_INT
)) {
2186 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
2187 spin_unlock_irq(&phba
->hbalock
);
2190 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
2191 writel(creg_val
, phba
->HCregaddr
);
2192 readl(phba
->HCregaddr
); /* flush */
2194 lpfc_poll_start_timer(phba
);
2196 } else if (val
!= 0x0) {
2197 spin_unlock_irq(&phba
->hbalock
);
2201 if (!(val
& DISABLE_FCP_RING_INT
) &&
2202 (old_val
& DISABLE_FCP_RING_INT
))
2204 spin_unlock_irq(&phba
->hbalock
);
2205 del_timer(&phba
->fcp_poll_timer
);
2206 spin_lock_irq(&phba
->hbalock
);
2207 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
2208 spin_unlock_irq(&phba
->hbalock
);
2211 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
2212 writel(creg_val
, phba
->HCregaddr
);
2213 readl(phba
->HCregaddr
); /* flush */
2216 phba
->cfg_poll
= val
;
2218 spin_unlock_irq(&phba
->hbalock
);
2224 * lpfc_fips_level_show - Return the current FIPS level for the HBA
2225 * @dev: class unused variable.
2226 * @attr: device attribute, not used.
2227 * @buf: on return contains the module description text.
2229 * Returns: size of formatted string.
2232 lpfc_fips_level_show(struct device
*dev
, struct device_attribute
*attr
,
2235 struct Scsi_Host
*shost
= class_to_shost(dev
);
2236 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2237 struct lpfc_hba
*phba
= vport
->phba
;
2239 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_level
);
2243 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
2244 * @dev: class unused variable.
2245 * @attr: device attribute, not used.
2246 * @buf: on return contains the module description text.
2248 * Returns: size of formatted string.
2251 lpfc_fips_rev_show(struct device
*dev
, struct device_attribute
*attr
,
2254 struct Scsi_Host
*shost
= class_to_shost(dev
);
2255 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2256 struct lpfc_hba
*phba
= vport
->phba
;
2258 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_spec_rev
);
2262 * lpfc_dss_show - Return the current state of dss and the configured state
2263 * @dev: class converted to a Scsi_host structure.
2264 * @attr: device attribute, not used.
2265 * @buf: on return contains the formatted text.
2267 * Returns: size of formatted string.
2270 lpfc_dss_show(struct device
*dev
, struct device_attribute
*attr
,
2273 struct Scsi_Host
*shost
= class_to_shost(dev
);
2274 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2275 struct lpfc_hba
*phba
= vport
->phba
;
2277 return scnprintf(buf
, PAGE_SIZE
, "%s - %sOperational\n",
2278 (phba
->cfg_enable_dss
) ? "Enabled" : "Disabled",
2279 (phba
->sli3_options
& LPFC_SLI3_DSS_ENABLED
) ?
2284 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
2285 * @dev: class converted to a Scsi_host structure.
2286 * @attr: device attribute, not used.
2287 * @buf: on return contains the formatted support level.
2290 * Returns the maximum number of virtual functions a physical function can
2291 * support, 0 will be returned if called on virtual function.
2293 * Returns: size of formatted string.
2296 lpfc_sriov_hw_max_virtfn_show(struct device
*dev
,
2297 struct device_attribute
*attr
,
2300 struct Scsi_Host
*shost
= class_to_shost(dev
);
2301 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2302 struct lpfc_hba
*phba
= vport
->phba
;
2303 uint16_t max_nr_virtfn
;
2305 max_nr_virtfn
= lpfc_sli_sriov_nr_virtfn_get(phba
);
2306 return scnprintf(buf
, PAGE_SIZE
, "%d\n", max_nr_virtfn
);
2309 static inline bool lpfc_rangecheck(uint val
, uint min
, uint max
)
2311 return val
>= min
&& val
<= max
;
2315 * lpfc_enable_bbcr_set: Sets an attribute value.
2316 * @phba: pointer the the adapter structure.
2317 * @val: integer attribute value.
2320 * Validates the min and max values then sets the
2321 * adapter config field if in the valid range. prints error message
2322 * and does not set the parameter if invalid.
2326 * -EINVAL if val is invalid
2329 lpfc_enable_bbcr_set(struct lpfc_hba
*phba
, uint val
)
2331 if (lpfc_rangecheck(val
, 0, 1) && phba
->sli_rev
== LPFC_SLI_REV4
) {
2332 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2333 "3068 %s_enable_bbcr changed from %d to %d\n",
2334 LPFC_DRIVER_NAME
, phba
->cfg_enable_bbcr
, val
);
2335 phba
->cfg_enable_bbcr
= val
;
2338 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2339 "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n",
2340 LPFC_DRIVER_NAME
, val
);
2345 * lpfc_param_show - Return a cfg attribute value in decimal
2348 * Macro that given an attr e.g. hba_queue_depth expands
2349 * into a function with the name lpfc_hba_queue_depth_show.
2351 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
2352 * @dev: class device that is converted into a Scsi_host.
2353 * @attr: device attribute, not used.
2354 * @buf: on return contains the attribute value in decimal.
2356 * Returns: size of formatted string.
2358 #define lpfc_param_show(attr) \
2360 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2363 struct Scsi_Host *shost = class_to_shost(dev);\
2364 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2365 struct lpfc_hba *phba = vport->phba;\
2366 return scnprintf(buf, PAGE_SIZE, "%d\n",\
2371 * lpfc_param_hex_show - Return a cfg attribute value in hex
2374 * Macro that given an attr e.g. hba_queue_depth expands
2375 * into a function with the name lpfc_hba_queue_depth_show
2377 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
2378 * @dev: class device that is converted into a Scsi_host.
2379 * @attr: device attribute, not used.
2380 * @buf: on return contains the attribute value in hexadecimal.
2382 * Returns: size of formatted string.
2384 #define lpfc_param_hex_show(attr) \
2386 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2389 struct Scsi_Host *shost = class_to_shost(dev);\
2390 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2391 struct lpfc_hba *phba = vport->phba;\
2393 val = phba->cfg_##attr;\
2394 return scnprintf(buf, PAGE_SIZE, "%#x\n",\
2399 * lpfc_param_init - Initializes a cfg attribute
2402 * Macro that given an attr e.g. hba_queue_depth expands
2403 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2404 * takes a default argument, a minimum and maximum argument.
2406 * lpfc_##attr##_init: Initializes an attribute.
2407 * @phba: pointer the the adapter structure.
2408 * @val: integer attribute value.
2410 * Validates the min and max values then sets the adapter config field
2411 * accordingly, or uses the default if out of range and prints an error message.
2415 * -EINVAL if default used
2417 #define lpfc_param_init(attr, default, minval, maxval) \
2419 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
2421 if (lpfc_rangecheck(val, minval, maxval)) {\
2422 phba->cfg_##attr = val;\
2425 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2426 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
2427 "allowed range is ["#minval", "#maxval"]\n", val); \
2428 phba->cfg_##attr = default;\
2433 * lpfc_param_set - Set a cfg attribute value
2436 * Macro that given an attr e.g. hba_queue_depth expands
2437 * into a function with the name lpfc_hba_queue_depth_set
2439 * lpfc_##attr##_set: Sets an attribute value.
2440 * @phba: pointer the the adapter structure.
2441 * @val: integer attribute value.
2444 * Validates the min and max values then sets the
2445 * adapter config field if in the valid range. prints error message
2446 * and does not set the parameter if invalid.
2450 * -EINVAL if val is invalid
2452 #define lpfc_param_set(attr, default, minval, maxval) \
2454 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
2456 if (lpfc_rangecheck(val, minval, maxval)) {\
2457 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2458 "3052 lpfc_" #attr " changed from %d to %d\n", \
2459 phba->cfg_##attr, val); \
2460 phba->cfg_##attr = val;\
2463 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2464 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
2465 "allowed range is ["#minval", "#maxval"]\n", val); \
2470 * lpfc_param_store - Set a vport attribute value
2473 * Macro that given an attr e.g. hba_queue_depth expands
2474 * into a function with the name lpfc_hba_queue_depth_store.
2476 * lpfc_##attr##_store: Set an sttribute value.
2477 * @dev: class device that is converted into a Scsi_host.
2478 * @attr: device attribute, not used.
2479 * @buf: contains the attribute value in ascii.
2483 * Convert the ascii text number to an integer, then
2484 * use the lpfc_##attr##_set function to set the value.
2487 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2488 * length of buffer upon success.
2490 #define lpfc_param_store(attr) \
2492 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2493 const char *buf, size_t count) \
2495 struct Scsi_Host *shost = class_to_shost(dev);\
2496 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2497 struct lpfc_hba *phba = vport->phba;\
2499 if (!isdigit(buf[0]))\
2501 if (sscanf(buf, "%i", &val) != 1)\
2503 if (lpfc_##attr##_set(phba, val) == 0) \
2504 return strlen(buf);\
2510 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
2513 * Macro that given an attr e.g. hba_queue_depth expands
2514 * into a function with the name lpfc_hba_queue_depth_show
2516 * lpfc_##attr##_show: prints the attribute value in decimal.
2517 * @dev: class device that is converted into a Scsi_host.
2518 * @attr: device attribute, not used.
2519 * @buf: on return contains the attribute value in decimal.
2521 * Returns: length of formatted string.
2523 #define lpfc_vport_param_show(attr) \
2525 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2528 struct Scsi_Host *shost = class_to_shost(dev);\
2529 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2530 return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
2534 * lpfc_vport_param_hex_show - Return hex formatted attribute value
2537 * Macro that given an attr e.g.
2538 * hba_queue_depth expands into a function with the name
2539 * lpfc_hba_queue_depth_show
2541 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
2542 * @dev: class device that is converted into a Scsi_host.
2543 * @attr: device attribute, not used.
2544 * @buf: on return contains the attribute value in hexadecimal.
2546 * Returns: length of formatted string.
2548 #define lpfc_vport_param_hex_show(attr) \
2550 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2553 struct Scsi_Host *shost = class_to_shost(dev);\
2554 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2555 return scnprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
2559 * lpfc_vport_param_init - Initialize a vport cfg attribute
2562 * Macro that given an attr e.g. hba_queue_depth expands
2563 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2564 * takes a default argument, a minimum and maximum argument.
2566 * lpfc_##attr##_init: validates the min and max values then sets the
2567 * adapter config field accordingly, or uses the default if out of range
2568 * and prints an error message.
2569 * @phba: pointer the the adapter structure.
2570 * @val: integer attribute value.
2574 * -EINVAL if default used
2576 #define lpfc_vport_param_init(attr, default, minval, maxval) \
2578 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
2580 if (lpfc_rangecheck(val, minval, maxval)) {\
2581 vport->cfg_##attr = val;\
2584 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2585 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
2586 "allowed range is ["#minval", "#maxval"]\n", val); \
2587 vport->cfg_##attr = default;\
2592 * lpfc_vport_param_set - Set a vport cfg attribute
2595 * Macro that given an attr e.g. hba_queue_depth expands
2596 * into a function with the name lpfc_hba_queue_depth_set
2598 * lpfc_##attr##_set: validates the min and max values then sets the
2599 * adapter config field if in the valid range. prints error message
2600 * and does not set the parameter if invalid.
2601 * @phba: pointer the the adapter structure.
2602 * @val: integer attribute value.
2606 * -EINVAL if val is invalid
2608 #define lpfc_vport_param_set(attr, default, minval, maxval) \
2610 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
2612 if (lpfc_rangecheck(val, minval, maxval)) {\
2613 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2614 "3053 lpfc_" #attr \
2615 " changed from %d (x%x) to %d (x%x)\n", \
2616 vport->cfg_##attr, vport->cfg_##attr, \
2618 vport->cfg_##attr = val;\
2621 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2622 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
2623 "allowed range is ["#minval", "#maxval"]\n", val); \
2628 * lpfc_vport_param_store - Set a vport attribute
2631 * Macro that given an attr e.g. hba_queue_depth
2632 * expands into a function with the name lpfc_hba_queue_depth_store
2634 * lpfc_##attr##_store: convert the ascii text number to an integer, then
2635 * use the lpfc_##attr##_set function to set the value.
2636 * @cdev: class device that is converted into a Scsi_host.
2637 * @buf: contains the attribute value in decimal.
2641 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2642 * length of buffer upon success.
2644 #define lpfc_vport_param_store(attr) \
2646 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2647 const char *buf, size_t count) \
2649 struct Scsi_Host *shost = class_to_shost(dev);\
2650 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2652 if (!isdigit(buf[0]))\
2654 if (sscanf(buf, "%i", &val) != 1)\
2656 if (lpfc_##attr##_set(vport, val) == 0) \
2657 return strlen(buf);\
2663 static DEVICE_ATTR(nvme_info
, 0444, lpfc_nvme_info_show
, NULL
);
2664 static DEVICE_ATTR(scsi_stat
, 0444, lpfc_scsi_stat_show
, NULL
);
2665 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
2666 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
2667 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
2668 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
2669 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
2670 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
2671 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
2672 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
2673 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
2674 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
2675 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
2676 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
2677 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
2678 lpfc_link_state_store
);
2679 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
2680 lpfc_option_rom_version_show
, NULL
);
2681 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
2682 lpfc_num_discovered_ports_show
, NULL
);
2683 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
2684 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
2685 static DEVICE_ATTR_RO(lpfc_drvr_version
);
2686 static DEVICE_ATTR_RO(lpfc_enable_fip
);
2687 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
2688 lpfc_board_mode_show
, lpfc_board_mode_store
);
2689 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
2690 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
2691 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
2692 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
2693 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
2694 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
2695 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
2696 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
2697 static DEVICE_ATTR_RO(lpfc_temp_sensor
);
2698 static DEVICE_ATTR_RO(lpfc_fips_level
);
2699 static DEVICE_ATTR_RO(lpfc_fips_rev
);
2700 static DEVICE_ATTR_RO(lpfc_dss
);
2701 static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn
);
2702 static DEVICE_ATTR(protocol
, S_IRUGO
, lpfc_sli4_protocol_show
, NULL
);
2703 static DEVICE_ATTR(lpfc_xlane_supported
, S_IRUGO
, lpfc_oas_supported_show
,
2706 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
2709 * lpfc_wwn_set - Convert string to the 8 byte WWN value.
2711 * @cnt: Length of string.
2712 * @wwn: Array to receive converted wwn value.
2715 * -EINVAL if the buffer does not contain a valid wwn
2719 lpfc_wwn_set(const char *buf
, size_t cnt
, char wwn
[])
2723 /* Count may include a LF at end of string */
2724 if (buf
[cnt
-1] == '\n')
2727 if ((cnt
< 16) || (cnt
> 18) || ((cnt
== 17) && (*buf
++ != 'x')) ||
2728 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2731 memset(wwn
, 0, WWN_SZ
);
2733 /* Validate and store the new name */
2734 for (i
= 0, j
= 0; i
< 16; i
++) {
2735 if ((*buf
>= 'a') && (*buf
<= 'f'))
2736 j
= ((j
<< 4) | ((*buf
++ - 'a') + 10));
2737 else if ((*buf
>= 'A') && (*buf
<= 'F'))
2738 j
= ((j
<< 4) | ((*buf
++ - 'A') + 10));
2739 else if ((*buf
>= '0') && (*buf
<= '9'))
2740 j
= ((j
<< 4) | (*buf
++ - '0'));
2744 wwn
[i
/2] = j
& 0xff;
2751 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2752 * @dev: class device that is converted into a Scsi_host.
2753 * @attr: device attribute, not used.
2754 * @buf: containing the string lpfc_soft_wwn_key.
2755 * @count: must be size of lpfc_soft_wwn_key.
2758 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2759 * length of buf indicates success
2762 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
2763 const char *buf
, size_t count
)
2765 struct Scsi_Host
*shost
= class_to_shost(dev
);
2766 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2767 struct lpfc_hba
*phba
= vport
->phba
;
2768 unsigned int cnt
= count
;
2769 uint8_t vvvl
= vport
->fc_sparam
.cmn
.valid_vendor_ver_level
;
2770 u32
*fawwpn_key
= (uint32_t *)&vport
->fc_sparam
.un
.vendorVersion
[0];
2773 * We're doing a simple sanity check for soft_wwpn setting.
2774 * We require that the user write a specific key to enable
2775 * the soft_wwpn attribute to be settable. Once the attribute
2776 * is written, the enable key resets. If further updates are
2777 * desired, the key must be written again to re-enable the
2780 * The "key" is not secret - it is a hardcoded string shown
2781 * here. The intent is to protect against the random user or
2782 * application that is just writing attributes.
2784 if (vvvl
== 1 && cpu_to_be32(*fawwpn_key
) == FAPWWN_KEY_VENDOR
) {
2785 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2786 "0051 "LPFC_DRIVER_NAME
" soft wwpn can not"
2787 " be enabled: fawwpn is enabled\n");
2791 /* count may include a LF at end of string */
2792 if (buf
[cnt
-1] == '\n')
2795 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
2796 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
2799 phba
->soft_wwn_enable
= 1;
2801 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2802 "lpfc%d: soft_wwpn assignment has been enabled.\n",
2804 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2805 " The soft_wwpn feature is not supported by Broadcom.");
2809 static DEVICE_ATTR_WO(lpfc_soft_wwn_enable
);
2812 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2813 * @dev: class device that is converted into a Scsi_host.
2814 * @attr: device attribute, not used.
2815 * @buf: on return contains the wwpn in hexadecimal.
2817 * Returns: size of formatted string.
2820 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
2823 struct Scsi_Host
*shost
= class_to_shost(dev
);
2824 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2825 struct lpfc_hba
*phba
= vport
->phba
;
2827 return scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2828 (unsigned long long)phba
->cfg_soft_wwpn
);
2832 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2833 * @dev class device that is converted into a Scsi_host.
2834 * @attr: device attribute, not used.
2835 * @buf: contains the wwpn in hexadecimal.
2836 * @count: number of wwpn bytes in buf
2839 * -EACCES hba reset not enabled, adapter over temp
2840 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2841 * -EIO error taking adapter offline or online
2842 * value of count on success
2845 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
2846 const char *buf
, size_t count
)
2848 struct Scsi_Host
*shost
= class_to_shost(dev
);
2849 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2850 struct lpfc_hba
*phba
= vport
->phba
;
2851 struct completion online_compl
;
2852 int stat1
= 0, stat2
= 0;
2853 unsigned int cnt
= count
;
2857 if (!phba
->cfg_enable_hba_reset
)
2859 spin_lock_irq(&phba
->hbalock
);
2860 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
2861 spin_unlock_irq(&phba
->hbalock
);
2864 spin_unlock_irq(&phba
->hbalock
);
2865 /* count may include a LF at end of string */
2866 if (buf
[cnt
-1] == '\n')
2869 if (!phba
->soft_wwn_enable
)
2872 /* lock setting wwpn, wwnn down */
2873 phba
->soft_wwn_enable
= 0;
2875 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2877 /* not able to set wwpn, unlock it */
2878 phba
->soft_wwn_enable
= 1;
2882 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
2883 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
2884 if (phba
->cfg_soft_wwnn
)
2885 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
2887 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2888 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
2890 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
2892 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2893 "0463 lpfc_soft_wwpn attribute set failed to "
2894 "reinit adapter - %d\n", stat1
);
2895 init_completion(&online_compl
);
2896 rc
= lpfc_workq_post_event(phba
, &stat2
, &online_compl
,
2901 wait_for_completion(&online_compl
);
2903 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2904 "0464 lpfc_soft_wwpn attribute set failed to "
2905 "reinit adapter - %d\n", stat2
);
2906 return (stat1
|| stat2
) ? -EIO
: count
;
2908 static DEVICE_ATTR_RW(lpfc_soft_wwpn
);
2911 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2912 * @dev: class device that is converted into a Scsi_host.
2913 * @attr: device attribute, not used.
2914 * @buf: on return contains the wwnn in hexadecimal.
2916 * Returns: size of formatted string.
2919 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
2922 struct Scsi_Host
*shost
= class_to_shost(dev
);
2923 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2924 return scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2925 (unsigned long long)phba
->cfg_soft_wwnn
);
2929 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2930 * @cdev: class device that is converted into a Scsi_host.
2931 * @buf: contains the ww node name in hexadecimal.
2932 * @count: number of wwnn bytes in buf.
2935 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2936 * value of count on success
2939 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
2940 const char *buf
, size_t count
)
2942 struct Scsi_Host
*shost
= class_to_shost(dev
);
2943 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2944 unsigned int cnt
= count
;
2948 /* count may include a LF at end of string */
2949 if (buf
[cnt
-1] == '\n')
2952 if (!phba
->soft_wwn_enable
)
2955 rc
= lpfc_wwn_set(buf
, cnt
, wwnn
);
2957 /* Allow wwnn to be set many times, as long as the enable
2958 * is set. However, once the wwpn is set, everything locks.
2963 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
2965 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2966 "lpfc%d: soft_wwnn set. Value will take effect upon "
2967 "setting of the soft_wwpn\n", phba
->brd_no
);
2971 static DEVICE_ATTR_RW(lpfc_soft_wwnn
);
2974 * lpfc_oas_tgt_show - Return 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.
2984 lpfc_oas_tgt_show(struct device
*dev
, struct device_attribute
*attr
,
2987 struct Scsi_Host
*shost
= class_to_shost(dev
);
2988 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2990 return scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2991 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
));
2995 * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for
2996 * Optimized Access Storage (OAS) operations.
2997 * @dev: class device that is converted into a Scsi_host.
2998 * @attr: device attribute, not used.
2999 * @buf: buffer for passing information.
3000 * @count: Size of the data buffer.
3003 * -EINVAL count is invalid, invalid wwpn byte invalid
3004 * -EPERM oas is not supported by hba
3005 * value of count on success
3008 lpfc_oas_tgt_store(struct device
*dev
, struct device_attribute
*attr
,
3009 const char *buf
, size_t count
)
3011 struct Scsi_Host
*shost
= class_to_shost(dev
);
3012 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3013 unsigned int cnt
= count
;
3014 uint8_t wwpn
[WWN_SZ
];
3020 /* count may include a LF at end of string */
3021 if (buf
[cnt
-1] == '\n')
3024 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
3028 memcpy(phba
->cfg_oas_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
3029 memcpy(phba
->sli4_hba
.oas_next_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
3030 if (wwn_to_u64(wwpn
) == 0)
3031 phba
->cfg_oas_flags
|= OAS_FIND_ANY_TARGET
;
3033 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_TARGET
;
3034 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
3035 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
3038 static DEVICE_ATTR(lpfc_xlane_tgt
, S_IRUGO
| S_IWUSR
,
3039 lpfc_oas_tgt_show
, lpfc_oas_tgt_store
);
3042 * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for
3043 * Optimized Access Storage (OAS) operations.
3044 * @dev: class device that is converted into a Scsi_host.
3045 * @attr: device attribute, not used.
3046 * @buf: buffer for passing information.
3052 lpfc_oas_priority_show(struct device
*dev
, struct device_attribute
*attr
,
3055 struct Scsi_Host
*shost
= class_to_shost(dev
);
3056 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3058 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_priority
);
3062 * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for
3063 * Optimized Access Storage (OAS) operations.
3064 * @dev: class device that is converted into a Scsi_host.
3065 * @attr: device attribute, not used.
3066 * @buf: buffer for passing information.
3067 * @count: Size of the data buffer.
3070 * -EINVAL count is invalid, invalid wwpn byte invalid
3071 * -EPERM oas is not supported by hba
3072 * value of count on success
3075 lpfc_oas_priority_store(struct device
*dev
, struct device_attribute
*attr
,
3076 const char *buf
, size_t count
)
3078 struct Scsi_Host
*shost
= class_to_shost(dev
);
3079 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3080 unsigned int cnt
= count
;
3087 /* count may include a LF at end of string */
3088 if (buf
[cnt
-1] == '\n')
3091 ret
= kstrtoul(buf
, 0, &val
);
3092 if (ret
|| (val
> 0x7f))
3096 phba
->cfg_oas_priority
= (uint8_t)val
;
3098 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
3101 static DEVICE_ATTR(lpfc_xlane_priority
, S_IRUGO
| S_IWUSR
,
3102 lpfc_oas_priority_show
, lpfc_oas_priority_store
);
3105 * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled
3106 * for Optimized Access Storage (OAS) operations.
3107 * @dev: class device that is converted into a Scsi_host.
3108 * @attr: device attribute, not used.
3109 * @buf: buffer for passing information.
3112 * value of count on success
3115 lpfc_oas_vpt_show(struct device
*dev
, struct device_attribute
*attr
,
3118 struct Scsi_Host
*shost
= class_to_shost(dev
);
3119 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3121 return scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
3122 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
));
3126 * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled
3127 * for Optimized Access Storage (OAS) operations.
3128 * @dev: class device that is converted into a Scsi_host.
3129 * @attr: device attribute, not used.
3130 * @buf: buffer for passing information.
3131 * @count: Size of the data buffer.
3134 * -EINVAL count is invalid, invalid wwpn byte invalid
3135 * -EPERM oas is not supported by hba
3136 * value of count on success
3139 lpfc_oas_vpt_store(struct device
*dev
, struct device_attribute
*attr
,
3140 const char *buf
, size_t count
)
3142 struct Scsi_Host
*shost
= class_to_shost(dev
);
3143 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3144 unsigned int cnt
= count
;
3145 uint8_t wwpn
[WWN_SZ
];
3151 /* count may include a LF at end of string */
3152 if (buf
[cnt
-1] == '\n')
3155 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
3159 memcpy(phba
->cfg_oas_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
3160 memcpy(phba
->sli4_hba
.oas_next_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
3161 if (wwn_to_u64(wwpn
) == 0)
3162 phba
->cfg_oas_flags
|= OAS_FIND_ANY_VPORT
;
3164 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_VPORT
;
3165 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
3166 if (phba
->cfg_oas_priority
== 0)
3167 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
3168 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
3171 static DEVICE_ATTR(lpfc_xlane_vpt
, S_IRUGO
| S_IWUSR
,
3172 lpfc_oas_vpt_show
, lpfc_oas_vpt_store
);
3175 * lpfc_oas_lun_state_show - Return the current state (enabled or disabled)
3176 * of whether luns will be enabled or disabled
3177 * for Optimized Access Storage (OAS) operations.
3178 * @dev: class device that is converted into a Scsi_host.
3179 * @attr: device attribute, not used.
3180 * @buf: buffer for passing information.
3183 * size of formatted string.
3186 lpfc_oas_lun_state_show(struct device
*dev
, struct device_attribute
*attr
,
3189 struct Scsi_Host
*shost
= class_to_shost(dev
);
3190 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3192 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_state
);
3196 * lpfc_oas_lun_state_store - Store the state (enabled or disabled)
3197 * of whether luns will be enabled or disabled
3198 * for Optimized Access Storage (OAS) operations.
3199 * @dev: class device that is converted into a Scsi_host.
3200 * @attr: device attribute, not used.
3201 * @buf: buffer for passing information.
3202 * @count: Size of the data buffer.
3205 * -EINVAL count is invalid, invalid wwpn byte invalid
3206 * -EPERM oas is not supported by hba
3207 * value of count on success
3210 lpfc_oas_lun_state_store(struct device
*dev
, struct device_attribute
*attr
,
3211 const char *buf
, size_t count
)
3213 struct Scsi_Host
*shost
= class_to_shost(dev
);
3214 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3220 if (!isdigit(buf
[0]))
3223 if (sscanf(buf
, "%i", &val
) != 1)
3226 if ((val
!= 0) && (val
!= 1))
3229 phba
->cfg_oas_lun_state
= val
;
3232 static DEVICE_ATTR(lpfc_xlane_lun_state
, S_IRUGO
| S_IWUSR
,
3233 lpfc_oas_lun_state_show
, lpfc_oas_lun_state_store
);
3236 * lpfc_oas_lun_status_show - Return the status of the Optimized Access
3237 * Storage (OAS) lun returned by the
3238 * lpfc_oas_lun_show function.
3239 * @dev: class device that is converted into a Scsi_host.
3240 * @attr: device attribute, not used.
3241 * @buf: buffer for passing information.
3244 * size of formatted string.
3247 lpfc_oas_lun_status_show(struct device
*dev
, struct device_attribute
*attr
,
3250 struct Scsi_Host
*shost
= class_to_shost(dev
);
3251 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3253 if (!(phba
->cfg_oas_flags
& OAS_LUN_VALID
))
3256 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_status
);
3258 static DEVICE_ATTR(lpfc_xlane_lun_status
, S_IRUGO
,
3259 lpfc_oas_lun_status_show
, NULL
);
3263 * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage
3265 * @phba: lpfc_hba pointer.
3266 * @ndlp: pointer to fcp target node.
3267 * @lun: the fc lun for setting oas state.
3268 * @oas_state: the oas state to be set to the lun.
3272 * -EPERM OAS is not enabled or not supported by this port.
3276 lpfc_oas_lun_state_set(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
3277 uint8_t tgt_wwpn
[], uint64_t lun
,
3278 uint32_t oas_state
, uint8_t pri
)
3287 if (!lpfc_enable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
3288 (struct lpfc_name
*)tgt_wwpn
,
3292 lpfc_disable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
3293 (struct lpfc_name
*)tgt_wwpn
, lun
, pri
);
3300 * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized
3301 * Access Storage (OAS) operations.
3302 * @phba: lpfc_hba pointer.
3303 * @vpt_wwpn: wwpn of the vport associated with the returned lun
3304 * @tgt_wwpn: wwpn of the target associated with the returned lun
3305 * @lun_status: status of the lun returned lun
3307 * Returns the first or next lun enabled for OAS operations for the vport/target
3308 * specified. If a lun is found, its vport wwpn, target wwpn and status is
3309 * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned.
3312 * lun that is OAS enabled for the vport/target
3313 * NOT_OAS_ENABLED_LUN when no oas enabled lun found.
3316 lpfc_oas_lun_get_next(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
3317 uint8_t tgt_wwpn
[], uint32_t *lun_status
,
3322 if (unlikely(!phba
) || !vpt_wwpn
|| !tgt_wwpn
)
3323 return NOT_OAS_ENABLED_LUN
;
3324 if (lpfc_find_next_oas_lun(phba
, (struct lpfc_name
*)
3325 phba
->sli4_hba
.oas_next_vpt_wwpn
,
3326 (struct lpfc_name
*)
3327 phba
->sli4_hba
.oas_next_tgt_wwpn
,
3328 &phba
->sli4_hba
.oas_next_lun
,
3329 (struct lpfc_name
*)vpt_wwpn
,
3330 (struct lpfc_name
*)tgt_wwpn
,
3331 &found_lun
, lun_status
, lun_pri
))
3334 return NOT_OAS_ENABLED_LUN
;
3338 * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations
3339 * @phba: lpfc_hba pointer.
3340 * @vpt_wwpn: vport wwpn by reference.
3341 * @tgt_wwpn: target wwpn by reference.
3342 * @lun: the fc lun for setting oas state.
3343 * @oas_state: the oas state to be set to the oas_lun.
3345 * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE)
3346 * a lun for OAS operations.
3350 * -ENOMEM: failed to enable an lun for OAS operations
3351 * -EPERM: OAS is not enabled
3354 lpfc_oas_lun_state_change(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
3355 uint8_t tgt_wwpn
[], uint64_t lun
,
3356 uint32_t oas_state
, uint8_t pri
)
3361 rc
= lpfc_oas_lun_state_set(phba
, vpt_wwpn
, tgt_wwpn
, lun
,
3367 * lpfc_oas_lun_show - Return oas enabled luns from a chosen target
3368 * @dev: class device that is converted into a Scsi_host.
3369 * @attr: device attribute, not used.
3370 * @buf: buffer for passing information.
3372 * This routine returns a lun enabled for OAS each time the function
3376 * SUCCESS: size of formatted string.
3377 * -EFAULT: target or vport wwpn was not set properly.
3378 * -EPERM: oas is not enabled.
3381 lpfc_oas_lun_show(struct device
*dev
, struct device_attribute
*attr
,
3384 struct Scsi_Host
*shost
= class_to_shost(dev
);
3385 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3393 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3394 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_VPORT
))
3397 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3398 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_TARGET
))
3401 oas_lun
= lpfc_oas_lun_get_next(phba
, phba
->cfg_oas_vpt_wwpn
,
3402 phba
->cfg_oas_tgt_wwpn
,
3403 &phba
->cfg_oas_lun_status
,
3404 &phba
->cfg_oas_priority
);
3405 if (oas_lun
!= NOT_OAS_ENABLED_LUN
)
3406 phba
->cfg_oas_flags
|= OAS_LUN_VALID
;
3408 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
, "0x%llx", oas_lun
);
3414 * lpfc_oas_lun_store - Sets the OAS state for lun
3415 * @dev: class device that is converted into a Scsi_host.
3416 * @attr: device attribute, not used.
3417 * @buf: buffer for passing information.
3419 * This function sets the OAS state for lun. Before this function is called,
3420 * the vport wwpn, target wwpn, and oas state need to be set.
3423 * SUCCESS: size of formatted string.
3424 * -EFAULT: target or vport wwpn was not set properly.
3425 * -EPERM: oas is not enabled.
3426 * size of formatted string.
3429 lpfc_oas_lun_store(struct device
*dev
, struct device_attribute
*attr
,
3430 const char *buf
, size_t count
)
3432 struct Scsi_Host
*shost
= class_to_shost(dev
);
3433 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3441 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3444 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3447 if (!isdigit(buf
[0]))
3450 if (sscanf(buf
, "0x%llx", &scsi_lun
) != 1)
3453 pri
= phba
->cfg_oas_priority
;
3455 pri
= phba
->cfg_XLanePriority
;
3457 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
,
3458 "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx "
3459 "priority 0x%x with oas state %d\n",
3460 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
),
3461 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
), scsi_lun
,
3462 pri
, phba
->cfg_oas_lun_state
);
3464 rc
= lpfc_oas_lun_state_change(phba
, phba
->cfg_oas_vpt_wwpn
,
3465 phba
->cfg_oas_tgt_wwpn
, scsi_lun
,
3466 phba
->cfg_oas_lun_state
, pri
);
3472 static DEVICE_ATTR(lpfc_xlane_lun
, S_IRUGO
| S_IWUSR
,
3473 lpfc_oas_lun_show
, lpfc_oas_lun_store
);
3475 int lpfc_enable_nvmet_cnt
;
3476 unsigned long long lpfc_enable_nvmet
[LPFC_NVMET_MAX_PORTS
] = {
3477 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3478 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3479 module_param_array(lpfc_enable_nvmet
, ullong
, &lpfc_enable_nvmet_cnt
, 0444);
3480 MODULE_PARM_DESC(lpfc_enable_nvmet
, "Enable HBA port(s) WWPN as a NVME Target");
3482 static int lpfc_poll
= 0;
3483 module_param(lpfc_poll
, int, S_IRUGO
);
3484 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
3486 " 1 - poll with interrupts enabled"
3487 " 3 - poll and disable FCP ring interrupts");
3489 static DEVICE_ATTR_RW(lpfc_poll
);
3491 int lpfc_no_hba_reset_cnt
;
3492 unsigned long lpfc_no_hba_reset
[MAX_HBAS_NO_RESET
] = {
3493 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3494 module_param_array(lpfc_no_hba_reset
, ulong
, &lpfc_no_hba_reset_cnt
, 0444);
3495 MODULE_PARM_DESC(lpfc_no_hba_reset
, "WWPN of HBAs that should not be reset");
3497 LPFC_ATTR(sli_mode
, 0, 0, 3,
3498 "SLI mode selector:"
3499 " 0 - auto (SLI-3 if supported),"
3500 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
3501 " 3 - select SLI-3");
3503 LPFC_ATTR_R(enable_npiv
, 1, 0, 1,
3504 "Enable NPIV functionality");
3506 LPFC_ATTR_R(fcf_failover_policy
, 1, 1, 2,
3507 "FCF Fast failover=1 Priority failover=2");
3510 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
3511 # 0x0 = disabled, XRI/OXID use not tracked.
3512 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
3513 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
3515 LPFC_ATTR_R(enable_rrq
, 2, 0, 2,
3516 "Enable RRQ functionality");
3519 # lpfc_suppress_link_up: Bring link up at initialization
3520 # 0x0 = bring link up (issue MBX_INIT_LINK)
3521 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
3522 # 0x2 = never bring up link
3523 # Default value is 0.
3525 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
3526 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
3527 "Suppress Link Up at initialization");
3529 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
3537 lpfc_iocb_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3539 struct Scsi_Host
*shost
= class_to_shost(dev
);
3540 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3542 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->iocb_max
);
3545 static DEVICE_ATTR(iocb_hw
, S_IRUGO
,
3546 lpfc_iocb_hw_show
, NULL
);
3548 lpfc_txq_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3550 struct Scsi_Host
*shost
= class_to_shost(dev
);
3551 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3552 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3554 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
3555 pring
? pring
->txq_max
: 0);
3558 static DEVICE_ATTR(txq_hw
, S_IRUGO
,
3559 lpfc_txq_hw_show
, NULL
);
3561 lpfc_txcmplq_hw_show(struct device
*dev
, struct device_attribute
*attr
,
3564 struct Scsi_Host
*shost
= class_to_shost(dev
);
3565 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3566 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3568 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
3569 pring
? pring
->txcmplq_max
: 0);
3572 static DEVICE_ATTR(txcmplq_hw
, S_IRUGO
,
3573 lpfc_txcmplq_hw_show
, NULL
);
3575 LPFC_ATTR_R(iocb_cnt
, 2, 1, 5,
3576 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
3579 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
3580 # until the timer expires. Value range is [0,255]. Default value is 30.
3582 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3583 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3584 module_param(lpfc_nodev_tmo
, int, 0);
3585 MODULE_PARM_DESC(lpfc_nodev_tmo
,
3586 "Seconds driver will hold I/O waiting "
3587 "for a device to come back");
3590 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
3591 * @dev: class converted to a Scsi_host structure.
3592 * @attr: device attribute, not used.
3593 * @buf: on return contains the dev loss timeout in decimal.
3595 * Returns: size of formatted string.
3598 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
3601 struct Scsi_Host
*shost
= class_to_shost(dev
);
3602 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3604 return scnprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
3608 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
3609 * @vport: lpfc vport structure pointer.
3610 * @val: contains the nodev timeout value.
3613 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
3614 * a kernel error message is printed and zero is returned.
3615 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3616 * Otherwise nodev tmo is set to the default value.
3619 * zero if already set or if val is in range
3620 * -EINVAL val out of range
3623 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
3625 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
3626 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
3627 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
3628 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3629 "0407 Ignoring lpfc_nodev_tmo module "
3630 "parameter because lpfc_devloss_tmo "
3635 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3636 vport
->cfg_nodev_tmo
= val
;
3637 vport
->cfg_devloss_tmo
= val
;
3640 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3641 "0400 lpfc_nodev_tmo attribute cannot be set to"
3642 " %d, allowed range is [%d, %d]\n",
3643 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3644 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3649 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
3650 * @vport: lpfc vport structure pointer.
3653 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
3656 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
3658 struct Scsi_Host
*shost
;
3659 struct lpfc_nodelist
*ndlp
;
3660 #if (IS_ENABLED(CONFIG_NVME_FC))
3661 struct lpfc_nvme_rport
*rport
;
3662 struct nvme_fc_remote_port
*remoteport
= NULL
;
3665 shost
= lpfc_shost_from_vport(vport
);
3666 spin_lock_irq(shost
->host_lock
);
3667 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3668 if (!NLP_CHK_NODE_ACT(ndlp
))
3671 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
3672 #if (IS_ENABLED(CONFIG_NVME_FC))
3673 spin_lock(&vport
->phba
->hbalock
);
3674 rport
= lpfc_ndlp_get_nrport(ndlp
);
3676 remoteport
= rport
->remoteport
;
3677 spin_unlock(&vport
->phba
->hbalock
);
3679 nvme_fc_set_remoteport_devloss(rport
->remoteport
,
3680 vport
->cfg_devloss_tmo
);
3683 spin_unlock_irq(shost
->host_lock
);
3687 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
3688 * @vport: lpfc vport structure pointer.
3689 * @val: contains the tmo value.
3692 * If the devloss tmo is already set or the vport dev loss tmo has changed
3693 * then a kernel error message is printed and zero is returned.
3694 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3695 * Otherwise nodev tmo is set to the default value.
3698 * zero if already set or if val is in range
3699 * -EINVAL val out of range
3702 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
3704 if (vport
->dev_loss_tmo_changed
||
3705 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
3706 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3707 "0401 Ignoring change to lpfc_nodev_tmo "
3708 "because lpfc_devloss_tmo is set.\n");
3711 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3712 vport
->cfg_nodev_tmo
= val
;
3713 vport
->cfg_devloss_tmo
= val
;
3715 * For compat: set the fc_host dev loss so new rports
3716 * will get the value.
3718 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3719 lpfc_update_rport_devloss_tmo(vport
);
3722 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3723 "0403 lpfc_nodev_tmo attribute cannot be set to "
3724 "%d, allowed range is [%d, %d]\n",
3725 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3729 lpfc_vport_param_store(nodev_tmo
)
3731 static DEVICE_ATTR_RW(lpfc_nodev_tmo
);
3734 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
3735 # disappear until the timer expires. Value range is [0,255]. Default
3738 module_param(lpfc_devloss_tmo
, int, S_IRUGO
);
3739 MODULE_PARM_DESC(lpfc_devloss_tmo
,
3740 "Seconds driver will hold I/O waiting "
3741 "for a device to come back");
3742 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
3743 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
3744 lpfc_vport_param_show(devloss_tmo
)
3747 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
3748 * @vport: lpfc vport structure pointer.
3749 * @val: contains the tmo value.
3752 * If val is in a valid range then set the vport nodev tmo,
3753 * devloss tmo, also set the vport dev loss tmo changed flag.
3754 * Else a kernel error message is printed.
3757 * zero if val is in range
3758 * -EINVAL val out of range
3761 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
3763 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3764 vport
->cfg_nodev_tmo
= val
;
3765 vport
->cfg_devloss_tmo
= val
;
3766 vport
->dev_loss_tmo_changed
= 1;
3767 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3768 lpfc_update_rport_devloss_tmo(vport
);
3772 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3773 "0404 lpfc_devloss_tmo attribute cannot be set to "
3774 "%d, allowed range is [%d, %d]\n",
3775 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3779 lpfc_vport_param_store(devloss_tmo
)
3780 static DEVICE_ATTR_RW(lpfc_devloss_tmo
);
3783 * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it
3784 * lpfc_suppress_rsp = 0 Disable
3785 * lpfc_suppress_rsp = 1 Enable (default)
3788 LPFC_ATTR_R(suppress_rsp
, 1, 0, 1,
3789 "Enable suppress rsp feature is firmware supports it");
3792 * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds
3793 * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs
3794 * lpfc_nvmet_mrq = 1 use a single RQ pair
3795 * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ
3798 LPFC_ATTR_R(nvmet_mrq
,
3799 LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_MAX
,
3800 "Specify number of RQ pairs for processing NVMET cmds");
3803 * lpfc_nvmet_mrq_post: Specify number of RQ buffer to initially post
3804 * to each NVMET RQ. Range 64 to 2048, default is 512.
3806 LPFC_ATTR_R(nvmet_mrq_post
,
3807 LPFC_NVMET_RQE_DEF_POST
, LPFC_NVMET_RQE_MIN_POST
,
3808 LPFC_NVMET_RQE_DEF_COUNT
,
3809 "Specify number of RQ buffers to initially post");
3812 * lpfc_enable_fc4_type: Defines what FC4 types are supported.
3813 * Supported Values: 1 - register just FCP
3814 * 3 - register both FCP and NVME
3815 * Supported values are [1,3]. Default value is 3
3817 LPFC_ATTR_R(enable_fc4_type
, LPFC_ENABLE_BOTH
,
3818 LPFC_ENABLE_FCP
, LPFC_ENABLE_BOTH
,
3819 "Enable FC4 Protocol support - FCP / NVME");
3822 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
3823 # deluged with LOTS of information.
3824 # You can set a bit mask to record specific types of verbose messages:
3825 # See lpfc_logmsh.h for definitions.
3827 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
3828 "Verbose logging bit-mask");
3831 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
3832 # objects that have been registered with the nameserver after login.
3834 LPFC_VPORT_ATTR_R(enable_da_id
, 1, 0, 1,
3835 "Deregister nameserver objects before LOGO");
3838 # lun_queue_depth: This parameter is used to limit the number of outstanding
3839 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
3840 # If this parameter value is greater than 1/8th the maximum number of exchanges
3841 # supported by the HBA port, then the lun queue depth will be reduced to
3842 # 1/8th the maximum number of exchanges.
3844 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 512,
3845 "Max number of FCP commands we can queue to a specific LUN");
3848 # tgt_queue_depth: This parameter is used to limit the number of outstanding
3849 # commands per target port. Value range is [10,65535]. Default value is 65535.
3851 static uint lpfc_tgt_queue_depth
= LPFC_MAX_TGT_QDEPTH
;
3852 module_param(lpfc_tgt_queue_depth
, uint
, 0444);
3853 MODULE_PARM_DESC(lpfc_tgt_queue_depth
, "Set max Target queue depth");
3854 lpfc_vport_param_show(tgt_queue_depth
);
3855 lpfc_vport_param_init(tgt_queue_depth
, LPFC_MAX_TGT_QDEPTH
,
3856 LPFC_MIN_TGT_QDEPTH
, LPFC_MAX_TGT_QDEPTH
);
3859 * lpfc_tgt_queue_depth_store: Sets an attribute value.
3860 * @phba: pointer the the adapter structure.
3861 * @val: integer attribute value.
3863 * Description: Sets the parameter to the new value.
3867 * -EINVAL if val is invalid
3870 lpfc_tgt_queue_depth_set(struct lpfc_vport
*vport
, uint val
)
3872 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
3873 struct lpfc_nodelist
*ndlp
;
3875 if (!lpfc_rangecheck(val
, LPFC_MIN_TGT_QDEPTH
, LPFC_MAX_TGT_QDEPTH
))
3878 if (val
== vport
->cfg_tgt_queue_depth
)
3881 spin_lock_irq(shost
->host_lock
);
3882 vport
->cfg_tgt_queue_depth
= val
;
3884 /* Next loop thru nodelist and change cmd_qdepth */
3885 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
)
3886 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
3888 spin_unlock_irq(shost
->host_lock
);
3892 lpfc_vport_param_store(tgt_queue_depth
);
3893 static DEVICE_ATTR_RW(lpfc_tgt_queue_depth
);
3896 # hba_queue_depth: This parameter is used to limit the number of outstanding
3897 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
3898 # value is greater than the maximum number of exchanges supported by the HBA,
3899 # then maximum number of exchanges supported by the HBA is used to determine
3900 # the hba_queue_depth.
3902 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
3903 "Max number of FCP commands we can queue to a lpfc HBA");
3906 # peer_port_login: This parameter allows/prevents logins
3907 # between peer ports hosted on the same physical port.
3908 # When this parameter is set 0 peer ports of same physical port
3909 # are not allowed to login to each other.
3910 # When this parameter is set 1 peer ports of same physical port
3911 # are allowed to login to each other.
3912 # Default value of this parameter is 0.
3914 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
3915 "Allow peer ports on the same physical port to login to each "
3919 # restrict_login: This parameter allows/prevents logins
3920 # between Virtual Ports and remote initiators.
3921 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
3922 # other initiators and will attempt to PLOGI all remote ports.
3923 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
3924 # remote ports and will not attempt to PLOGI to other initiators.
3925 # This parameter does not restrict to the physical port.
3926 # This parameter does not restrict logins to Fabric resident remote ports.
3927 # Default value of this parameter is 1.
3929 static int lpfc_restrict_login
= 1;
3930 module_param(lpfc_restrict_login
, int, S_IRUGO
);
3931 MODULE_PARM_DESC(lpfc_restrict_login
,
3932 "Restrict virtual ports login to remote initiators.");
3933 lpfc_vport_param_show(restrict_login
);
3936 * lpfc_restrict_login_init - Set the vport restrict login flag
3937 * @vport: lpfc vport structure pointer.
3938 * @val: contains the restrict login value.
3941 * If val is not in a valid range then log a kernel error message and set
3942 * the vport restrict login to one.
3943 * If the port type is physical clear the restrict login flag and return.
3944 * Else set the restrict login flag to val.
3947 * zero if val is in range
3948 * -EINVAL val out of range
3951 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
3953 if (val
< 0 || val
> 1) {
3954 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3955 "0422 lpfc_restrict_login attribute cannot "
3956 "be set to %d, allowed range is [0, 1]\n",
3958 vport
->cfg_restrict_login
= 1;
3961 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
3962 vport
->cfg_restrict_login
= 0;
3965 vport
->cfg_restrict_login
= val
;
3970 * lpfc_restrict_login_set - Set the vport restrict login flag
3971 * @vport: lpfc vport structure pointer.
3972 * @val: contains the restrict login value.
3975 * If val is not in a valid range then log a kernel error message and set
3976 * the vport restrict login to one.
3977 * If the port type is physical and the val is not zero log a kernel
3978 * error message, clear the restrict login flag and return zero.
3979 * Else set the restrict login flag to val.
3982 * zero if val is in range
3983 * -EINVAL val out of range
3986 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
3988 if (val
< 0 || val
> 1) {
3989 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3990 "0425 lpfc_restrict_login attribute cannot "
3991 "be set to %d, allowed range is [0, 1]\n",
3993 vport
->cfg_restrict_login
= 1;
3996 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
3997 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3998 "0468 lpfc_restrict_login must be 0 for "
3999 "Physical ports.\n");
4000 vport
->cfg_restrict_login
= 0;
4003 vport
->cfg_restrict_login
= val
;
4006 lpfc_vport_param_store(restrict_login
);
4007 static DEVICE_ATTR_RW(lpfc_restrict_login
);
4010 # Some disk devices have a "select ID" or "select Target" capability.
4011 # From a protocol standpoint "select ID" usually means select the
4012 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
4013 # annex" which contains a table that maps a "select ID" (a number
4014 # between 0 and 7F) to an ALPA. By default, for compatibility with
4015 # older drivers, the lpfc driver scans this table from low ALPA to high
4018 # Turning on the scan-down variable (on = 1, off = 0) will
4019 # cause the lpfc driver to use an inverted table, effectively
4020 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
4022 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
4023 # and will not work across a fabric. Also this parameter will take
4024 # effect only in the case when ALPA map is not available.)
4026 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
4027 "Start scanning for devices from highest ALPA to lowest");
4030 # lpfc_topology: link topology for init link
4031 # 0x0 = attempt loop mode then point-to-point
4032 # 0x01 = internal loopback mode
4033 # 0x02 = attempt point-to-point mode only
4034 # 0x04 = attempt loop mode only
4035 # 0x06 = attempt point-to-point mode then loop
4036 # Set point-to-point mode if you want to run as an N_Port.
4037 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
4038 # Default value is 0.
4040 LPFC_ATTR(topology
, 0, 0, 6,
4041 "Select Fibre Channel topology");
4044 * lpfc_topology_set - Set the adapters topology field
4045 * @phba: lpfc_hba pointer.
4046 * @val: topology value.
4049 * If val is in a valid range then set the adapter's topology field and
4050 * issue a lip; if the lip fails reset the topology to the old value.
4052 * If the value is not in range log a kernel error message and return an error.
4055 * zero if val is in range and lip okay
4056 * non-zero return value from lpfc_issue_lip()
4057 * -EINVAL val out of range
4060 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
4061 const char *buf
, size_t count
)
4063 struct Scsi_Host
*shost
= class_to_shost(dev
);
4064 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4065 struct lpfc_hba
*phba
= vport
->phba
;
4068 const char *val_buf
= buf
;
4072 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
4074 val_buf
= &buf
[strlen("nolip ")];
4077 if (!isdigit(val_buf
[0]))
4079 if (sscanf(val_buf
, "%i", &val
) != 1)
4082 if (val
>= 0 && val
<= 6) {
4083 prev_val
= phba
->cfg_topology
;
4084 if (phba
->cfg_link_speed
== LPFC_USER_LINK_SPEED_16G
&&
4086 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4087 "3113 Loop mode not supported at speed %d\n",
4091 if ((phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G6_FC
||
4092 phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G7_FC
) &&
4093 val
!= FLAGS_TOPOLOGY_MODE_PT_PT
) {
4094 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4095 "3114 Only non-FC-AL mode is supported\n");
4098 phba
->cfg_topology
= val
;
4102 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4103 "3054 lpfc_topology changed from %d to %d\n",
4105 if (prev_val
!= val
&& phba
->sli_rev
== LPFC_SLI_REV4
)
4106 phba
->fc_topology_changed
= 1;
4107 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
4109 phba
->cfg_topology
= prev_val
;
4114 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4115 "%d:0467 lpfc_topology attribute cannot be set to %d, "
4116 "allowed range is [0, 6]\n",
4121 lpfc_param_show(topology
)
4122 static DEVICE_ATTR_RW(lpfc_topology
);
4125 * lpfc_static_vport_show: Read callback function for
4126 * lpfc_static_vport sysfs file.
4127 * @dev: Pointer to class device object.
4128 * @attr: device attribute structure.
4129 * @buf: Data buffer.
4131 * This function is the read call back function for
4132 * lpfc_static_vport sysfs file. The lpfc_static_vport
4133 * sysfs file report the mageability of the vport.
4136 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
4139 struct Scsi_Host
*shost
= class_to_shost(dev
);
4140 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4141 if (vport
->vport_flag
& STATIC_VPORT
)
4142 sprintf(buf
, "1\n");
4144 sprintf(buf
, "0\n");
4150 * Sysfs attribute to control the statistical data collection.
4152 static DEVICE_ATTR_RO(lpfc_static_vport
);
4155 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
4156 * @dev: Pointer to class device.
4157 * @buf: Data buffer.
4158 * @count: Size of the data buffer.
4160 * This function get called when a user write to the lpfc_stat_data_ctrl
4161 * sysfs file. This function parse the command written to the sysfs file
4162 * and take appropriate action. These commands are used for controlling
4163 * driver statistical data collection.
4164 * Following are the command this function handles.
4166 * setbucket <bucket_type> <base> <step>
4167 * = Set the latency buckets.
4168 * destroybucket = destroy all the buckets.
4169 * start = start data collection
4170 * stop = stop data collection
4171 * reset = reset the collected data
4174 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
4175 const char *buf
, size_t count
)
4177 struct Scsi_Host
*shost
= class_to_shost(dev
);
4178 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4179 struct lpfc_hba
*phba
= vport
->phba
;
4180 #define LPFC_MAX_DATA_CTRL_LEN 1024
4181 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
4183 char *str_ptr
, *token
;
4184 struct lpfc_vport
**vports
;
4185 struct Scsi_Host
*v_shost
;
4186 char *bucket_type_str
, *base_str
, *step_str
;
4187 unsigned long base
, step
, bucket_type
;
4189 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
4190 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
4193 strncpy(bucket_data
, buf
, LPFC_MAX_DATA_CTRL_LEN
);
4194 str_ptr
= &bucket_data
[0];
4195 /* Ignore this token - this is command token */
4196 token
= strsep(&str_ptr
, "\t ");
4200 bucket_type_str
= strsep(&str_ptr
, "\t ");
4201 if (!bucket_type_str
)
4204 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
4205 bucket_type
= LPFC_LINEAR_BUCKET
;
4206 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
4207 bucket_type
= LPFC_POWER2_BUCKET
;
4211 base_str
= strsep(&str_ptr
, "\t ");
4214 base
= simple_strtoul(base_str
, NULL
, 0);
4216 step_str
= strsep(&str_ptr
, "\t ");
4219 step
= simple_strtoul(step_str
, NULL
, 0);
4223 /* Block the data collection for every vport */
4224 vports
= lpfc_create_vport_work_array(phba
);
4228 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
4229 v_shost
= lpfc_shost_from_vport(vports
[i
]);
4230 spin_lock_irq(v_shost
->host_lock
);
4231 /* Block and reset data collection */
4232 vports
[i
]->stat_data_blocked
= 1;
4233 if (vports
[i
]->stat_data_enabled
)
4234 lpfc_vport_reset_stat_data(vports
[i
]);
4235 spin_unlock_irq(v_shost
->host_lock
);
4238 /* Set the bucket attributes */
4239 phba
->bucket_type
= bucket_type
;
4240 phba
->bucket_base
= base
;
4241 phba
->bucket_step
= step
;
4243 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
4244 v_shost
= lpfc_shost_from_vport(vports
[i
]);
4246 /* Unblock data collection */
4247 spin_lock_irq(v_shost
->host_lock
);
4248 vports
[i
]->stat_data_blocked
= 0;
4249 spin_unlock_irq(v_shost
->host_lock
);
4251 lpfc_destroy_vport_work_array(phba
, vports
);
4255 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
4256 vports
= lpfc_create_vport_work_array(phba
);
4260 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
4261 v_shost
= lpfc_shost_from_vport(vports
[i
]);
4262 spin_lock_irq(shost
->host_lock
);
4263 vports
[i
]->stat_data_blocked
= 1;
4264 lpfc_free_bucket(vport
);
4265 vport
->stat_data_enabled
= 0;
4266 vports
[i
]->stat_data_blocked
= 0;
4267 spin_unlock_irq(shost
->host_lock
);
4269 lpfc_destroy_vport_work_array(phba
, vports
);
4270 phba
->bucket_type
= LPFC_NO_BUCKET
;
4271 phba
->bucket_base
= 0;
4272 phba
->bucket_step
= 0;
4276 if (!strncmp(buf
, "start", strlen("start"))) {
4277 /* If no buckets configured return error */
4278 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
4280 spin_lock_irq(shost
->host_lock
);
4281 if (vport
->stat_data_enabled
) {
4282 spin_unlock_irq(shost
->host_lock
);
4285 lpfc_alloc_bucket(vport
);
4286 vport
->stat_data_enabled
= 1;
4287 spin_unlock_irq(shost
->host_lock
);
4291 if (!strncmp(buf
, "stop", strlen("stop"))) {
4292 spin_lock_irq(shost
->host_lock
);
4293 if (vport
->stat_data_enabled
== 0) {
4294 spin_unlock_irq(shost
->host_lock
);
4297 lpfc_free_bucket(vport
);
4298 vport
->stat_data_enabled
= 0;
4299 spin_unlock_irq(shost
->host_lock
);
4303 if (!strncmp(buf
, "reset", strlen("reset"))) {
4304 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
4305 || !vport
->stat_data_enabled
)
4307 spin_lock_irq(shost
->host_lock
);
4308 vport
->stat_data_blocked
= 1;
4309 lpfc_vport_reset_stat_data(vport
);
4310 vport
->stat_data_blocked
= 0;
4311 spin_unlock_irq(shost
->host_lock
);
4319 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
4320 * @dev: Pointer to class device object.
4321 * @buf: Data buffer.
4323 * This function is the read call back function for
4324 * lpfc_stat_data_ctrl sysfs file. This function report the
4325 * current statistical data collection state.
4328 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
4331 struct Scsi_Host
*shost
= class_to_shost(dev
);
4332 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4333 struct lpfc_hba
*phba
= vport
->phba
;
4337 unsigned long bucket_value
;
4339 switch (phba
->bucket_type
) {
4340 case LPFC_LINEAR_BUCKET
:
4341 bucket_type
= "linear";
4343 case LPFC_POWER2_BUCKET
:
4344 bucket_type
= "power2";
4347 bucket_type
= "No Bucket";
4351 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
4352 "blocked :%d, Bucket type :%s, Bucket base :%d,"
4353 " Bucket step :%d\nLatency Ranges :",
4354 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
4355 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
4356 index
= strlen(buf
);
4357 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
4358 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
4359 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
4360 bucket_value
= phba
->bucket_base
+
4361 phba
->bucket_step
* i
;
4363 bucket_value
= phba
->bucket_base
+
4364 (1 << i
) * phba
->bucket_step
;
4366 if (index
+ 10 > PAGE_SIZE
)
4368 sprintf(&buf
[index
], "%08ld ", bucket_value
);
4369 index
= strlen(buf
);
4372 sprintf(&buf
[index
], "\n");
4377 * Sysfs attribute to control the statistical data collection.
4379 static DEVICE_ATTR_RW(lpfc_stat_data_ctrl
);
4382 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
4386 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
4389 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
4390 #define MAX_STAT_DATA_SIZE_PER_TARGET \
4391 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
4395 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
4397 * @kobj: Pointer to the kernel object
4398 * @bin_attr: Attribute object
4399 * @buff: Buffer pointer
4401 * @count: Buffer size
4403 * This function is the read call back function for lpfc_drvr_stat_data
4404 * sysfs file. This function export the statistical data to user
4408 sysfs_drvr_stat_data_read(struct file
*filp
, struct kobject
*kobj
,
4409 struct bin_attribute
*bin_attr
,
4410 char *buf
, loff_t off
, size_t count
)
4412 struct device
*dev
= container_of(kobj
, struct device
,
4414 struct Scsi_Host
*shost
= class_to_shost(dev
);
4415 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4416 struct lpfc_hba
*phba
= vport
->phba
;
4417 int i
= 0, index
= 0;
4418 unsigned long nport_index
;
4419 struct lpfc_nodelist
*ndlp
= NULL
;
4420 nport_index
= (unsigned long)off
/
4421 MAX_STAT_DATA_SIZE_PER_TARGET
;
4423 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
4424 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
4427 spin_lock_irq(shost
->host_lock
);
4428 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4429 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
4432 if (nport_index
> 0) {
4437 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
4441 if (!ndlp
->lat_data
)
4445 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
4446 ndlp
->nlp_portname
.u
.wwn
[0],
4447 ndlp
->nlp_portname
.u
.wwn
[1],
4448 ndlp
->nlp_portname
.u
.wwn
[2],
4449 ndlp
->nlp_portname
.u
.wwn
[3],
4450 ndlp
->nlp_portname
.u
.wwn
[4],
4451 ndlp
->nlp_portname
.u
.wwn
[5],
4452 ndlp
->nlp_portname
.u
.wwn
[6],
4453 ndlp
->nlp_portname
.u
.wwn
[7]);
4455 index
= strlen(buf
);
4457 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
4458 sprintf(&buf
[index
], "%010u,",
4459 ndlp
->lat_data
[i
].cmd_count
);
4460 index
= strlen(buf
);
4462 sprintf(&buf
[index
], "\n");
4463 index
= strlen(buf
);
4465 spin_unlock_irq(shost
->host_lock
);
4469 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
4471 .name
= "lpfc_drvr_stat_data",
4474 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
4475 .read
= sysfs_drvr_stat_data_read
,
4480 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
4482 # Value range is [0,16]. Default value is 0.
4485 * lpfc_link_speed_set - Set the adapters link speed
4486 * @phba: lpfc_hba pointer.
4487 * @val: link speed value.
4490 * If val is in a valid range then set the adapter's link speed field and
4491 * issue a lip; if the lip fails reset the link speed to the old value.
4494 * If the value is not in range log a kernel error message and return an error.
4497 * zero if val is in range and lip okay.
4498 * non-zero return value from lpfc_issue_lip()
4499 * -EINVAL val out of range
4502 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
4503 const char *buf
, size_t count
)
4505 struct Scsi_Host
*shost
= class_to_shost(dev
);
4506 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4507 struct lpfc_hba
*phba
= vport
->phba
;
4508 int val
= LPFC_USER_LINK_SPEED_AUTO
;
4510 const char *val_buf
= buf
;
4512 uint32_t prev_val
, if_type
;
4514 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
4515 if (if_type
>= LPFC_SLI_INTF_IF_TYPE_2
&&
4516 phba
->hba_flag
& HBA_FORCED_LINK_SPEED
)
4519 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
4521 val_buf
= &buf
[strlen("nolip ")];
4524 if (!isdigit(val_buf
[0]))
4526 if (sscanf(val_buf
, "%i", &val
) != 1)
4529 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4530 "3055 lpfc_link_speed changed from %d to %d %s\n",
4531 phba
->cfg_link_speed
, val
, nolip
? "(nolip)" : "(lip)");
4533 if (((val
== LPFC_USER_LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
4534 ((val
== LPFC_USER_LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
4535 ((val
== LPFC_USER_LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
4536 ((val
== LPFC_USER_LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
4537 ((val
== LPFC_USER_LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)) ||
4538 ((val
== LPFC_USER_LINK_SPEED_16G
) && !(phba
->lmt
& LMT_16Gb
)) ||
4539 ((val
== LPFC_USER_LINK_SPEED_32G
) && !(phba
->lmt
& LMT_32Gb
)) ||
4540 ((val
== LPFC_USER_LINK_SPEED_64G
) && !(phba
->lmt
& LMT_64Gb
))) {
4541 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4542 "2879 lpfc_link_speed attribute cannot be set "
4543 "to %d. Speed is not supported by this port.\n",
4547 if (val
>= LPFC_USER_LINK_SPEED_16G
&&
4548 phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
4549 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4550 "3112 lpfc_link_speed attribute cannot be set "
4551 "to %d. Speed is not supported in loop mode.\n",
4557 case LPFC_USER_LINK_SPEED_AUTO
:
4558 case LPFC_USER_LINK_SPEED_1G
:
4559 case LPFC_USER_LINK_SPEED_2G
:
4560 case LPFC_USER_LINK_SPEED_4G
:
4561 case LPFC_USER_LINK_SPEED_8G
:
4562 case LPFC_USER_LINK_SPEED_16G
:
4563 case LPFC_USER_LINK_SPEED_32G
:
4564 case LPFC_USER_LINK_SPEED_64G
:
4565 prev_val
= phba
->cfg_link_speed
;
4566 phba
->cfg_link_speed
= val
;
4570 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
4572 phba
->cfg_link_speed
= prev_val
;
4580 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4581 "0469 lpfc_link_speed attribute cannot be set to %d, "
4582 "allowed values are [%s]\n",
4583 val
, LPFC_LINK_SPEED_STRING
);
4588 static int lpfc_link_speed
= 0;
4589 module_param(lpfc_link_speed
, int, S_IRUGO
);
4590 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
4591 lpfc_param_show(link_speed
)
4594 * lpfc_link_speed_init - Set the adapters link speed
4595 * @phba: lpfc_hba pointer.
4596 * @val: link speed value.
4599 * If val is in a valid range then set the adapter's link speed field.
4602 * If the value is not in range log a kernel error message, clear the link
4603 * speed and return an error.
4606 * zero if val saved.
4607 * -EINVAL val out of range
4610 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
4612 if (val
>= LPFC_USER_LINK_SPEED_16G
&& phba
->cfg_topology
== 4) {
4613 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4614 "3111 lpfc_link_speed of %d cannot "
4615 "support loop mode, setting topology to default.\n",
4617 phba
->cfg_topology
= 0;
4621 case LPFC_USER_LINK_SPEED_AUTO
:
4622 case LPFC_USER_LINK_SPEED_1G
:
4623 case LPFC_USER_LINK_SPEED_2G
:
4624 case LPFC_USER_LINK_SPEED_4G
:
4625 case LPFC_USER_LINK_SPEED_8G
:
4626 case LPFC_USER_LINK_SPEED_16G
:
4627 case LPFC_USER_LINK_SPEED_32G
:
4628 case LPFC_USER_LINK_SPEED_64G
:
4629 phba
->cfg_link_speed
= val
;
4632 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4633 "0405 lpfc_link_speed attribute cannot "
4634 "be set to %d, allowed values are "
4635 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
4636 phba
->cfg_link_speed
= LPFC_USER_LINK_SPEED_AUTO
;
4641 static DEVICE_ATTR_RW(lpfc_link_speed
);
4644 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
4645 # 0 = aer disabled or not supported
4646 # 1 = aer supported and enabled (default)
4647 # Value range is [0,1]. Default value is 1.
4649 LPFC_ATTR(aer_support
, 1, 0, 1,
4650 "Enable PCIe device AER support");
4651 lpfc_param_show(aer_support
)
4654 * lpfc_aer_support_store - Set the adapter for aer support
4656 * @dev: class device that is converted into a Scsi_host.
4657 * @attr: device attribute, not used.
4658 * @buf: containing enable or disable aer flag.
4659 * @count: unused variable.
4662 * If the val is 1 and currently the device's AER capability was not
4663 * enabled, invoke the kernel's enable AER helper routine, trying to
4664 * enable the device's AER capability. If the helper routine enabling
4665 * AER returns success, update the device's cfg_aer_support flag to
4666 * indicate AER is supported by the device; otherwise, if the device
4667 * AER capability is already enabled to support AER, then do nothing.
4669 * If the val is 0 and currently the device's AER support was enabled,
4670 * invoke the kernel's disable AER helper routine. After that, update
4671 * the device's cfg_aer_support flag to indicate AER is not supported
4672 * by the device; otherwise, if the device AER capability is already
4673 * disabled from supporting AER, then do nothing.
4676 * length of the buf on success if val is in range the intended mode
4678 * -EINVAL if val out of range or intended mode is not supported.
4681 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
4682 const char *buf
, size_t count
)
4684 struct Scsi_Host
*shost
= class_to_shost(dev
);
4685 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4686 struct lpfc_hba
*phba
= vport
->phba
;
4687 int val
= 0, rc
= -EINVAL
;
4689 if (!isdigit(buf
[0]))
4691 if (sscanf(buf
, "%i", &val
) != 1)
4696 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
4697 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
4699 spin_lock_irq(&phba
->hbalock
);
4700 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
4701 spin_unlock_irq(&phba
->hbalock
);
4702 phba
->cfg_aer_support
= 0;
4707 phba
->cfg_aer_support
= 0;
4712 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
4713 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
4715 spin_lock_irq(&phba
->hbalock
);
4716 phba
->hba_flag
|= HBA_AER_ENABLED
;
4717 spin_unlock_irq(&phba
->hbalock
);
4718 phba
->cfg_aer_support
= 1;
4723 phba
->cfg_aer_support
= 1;
4734 static DEVICE_ATTR_RW(lpfc_aer_support
);
4737 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
4738 * @dev: class device that is converted into a Scsi_host.
4739 * @attr: device attribute, not used.
4740 * @buf: containing flag 1 for aer cleanup state.
4741 * @count: unused variable.
4744 * If the @buf contains 1 and the device currently has the AER support
4745 * enabled, then invokes the kernel AER helper routine
4746 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
4747 * error status register.
4752 * -EINVAL if the buf does not contain the 1 or the device is not currently
4753 * enabled with the AER support.
4756 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
4757 const char *buf
, size_t count
)
4759 struct Scsi_Host
*shost
= class_to_shost(dev
);
4760 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4761 struct lpfc_hba
*phba
= vport
->phba
;
4764 if (!isdigit(buf
[0]))
4766 if (sscanf(buf
, "%i", &val
) != 1)
4771 if (phba
->hba_flag
& HBA_AER_ENABLED
)
4772 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
4780 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
4781 lpfc_aer_cleanup_state
);
4784 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
4786 * @dev: class device that is converted into a Scsi_host.
4787 * @attr: device attribute, not used.
4788 * @buf: containing the string the number of vfs to be enabled.
4789 * @count: unused variable.
4792 * When this api is called either through user sysfs, the driver shall
4793 * try to enable or disable SR-IOV virtual functions according to the
4796 * If zero virtual function has been enabled to the physical function,
4797 * the driver shall invoke the pci enable virtual function api trying
4798 * to enable the virtual functions. If the nr_vfn provided is greater
4799 * than the maximum supported, the maximum virtual function number will
4800 * be used for invoking the api; otherwise, the nr_vfn provided shall
4801 * be used for invoking the api. If the api call returned success, the
4802 * actual number of virtual functions enabled will be set to the driver
4803 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
4804 * cfg_sriov_nr_virtfn remains zero.
4806 * If none-zero virtual functions have already been enabled to the
4807 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
4808 * -EINVAL will be returned and the driver does nothing;
4810 * If the nr_vfn provided is zero and none-zero virtual functions have
4811 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
4812 * disabling virtual function api shall be invoded to disable all the
4813 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
4814 * zero. Otherwise, if zero virtual function has been enabled, do
4818 * length of the buf on success if val is in range the intended mode
4820 * -EINVAL if val out of range or intended mode is not supported.
4823 lpfc_sriov_nr_virtfn_store(struct device
*dev
, struct device_attribute
*attr
,
4824 const char *buf
, size_t count
)
4826 struct Scsi_Host
*shost
= class_to_shost(dev
);
4827 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4828 struct lpfc_hba
*phba
= vport
->phba
;
4829 struct pci_dev
*pdev
= phba
->pcidev
;
4830 int val
= 0, rc
= -EINVAL
;
4832 /* Sanity check on user data */
4833 if (!isdigit(buf
[0]))
4835 if (sscanf(buf
, "%i", &val
) != 1)
4840 /* Request disabling virtual functions */
4842 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4843 pci_disable_sriov(pdev
);
4844 phba
->cfg_sriov_nr_virtfn
= 0;
4849 /* Request enabling virtual functions */
4850 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4851 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4852 "3018 There are %d virtual functions "
4853 "enabled on physical function.\n",
4854 phba
->cfg_sriov_nr_virtfn
);
4858 if (val
<= LPFC_MAX_VFN_PER_PFN
)
4859 phba
->cfg_sriov_nr_virtfn
= val
;
4861 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4862 "3019 Enabling %d virtual functions is not "
4867 rc
= lpfc_sli_probe_sriov_nr_virtfn(phba
, phba
->cfg_sriov_nr_virtfn
);
4869 phba
->cfg_sriov_nr_virtfn
= 0;
4877 LPFC_ATTR(sriov_nr_virtfn
, LPFC_DEF_VFN_PER_PFN
, 0, LPFC_MAX_VFN_PER_PFN
,
4878 "Enable PCIe device SR-IOV virtual fn");
4880 lpfc_param_show(sriov_nr_virtfn
)
4881 static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn
);
4884 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
4886 * @dev: class device that is converted into a Scsi_host.
4887 * @attr: device attribute, not used.
4888 * @buf: containing the string the number of vfs to be enabled.
4889 * @count: unused variable.
4894 * length of the buf on success if val is in range the intended mode
4896 * -EINVAL if val out of range or intended mode is not supported.
4899 lpfc_request_firmware_upgrade_store(struct device
*dev
,
4900 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
;
4906 int val
= 0, rc
= -EINVAL
;
4908 /* Sanity check on user data */
4909 if (!isdigit(buf
[0]))
4911 if (sscanf(buf
, "%i", &val
) != 1)
4916 rc
= lpfc_sli4_request_firmware_update(phba
, RUN_FW_UPGRADE
);
4924 static int lpfc_req_fw_upgrade
;
4925 module_param(lpfc_req_fw_upgrade
, int, S_IRUGO
|S_IWUSR
);
4926 MODULE_PARM_DESC(lpfc_req_fw_upgrade
, "Enable Linux generic firmware upgrade");
4927 lpfc_param_show(request_firmware_upgrade
)
4930 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
4931 * @phba: lpfc_hba pointer.
4935 * Set the initial Linux generic firmware upgrade enable or disable flag.
4938 * zero if val saved.
4939 * -EINVAL val out of range
4942 lpfc_request_firmware_upgrade_init(struct lpfc_hba
*phba
, int val
)
4944 if (val
>= 0 && val
<= 1) {
4945 phba
->cfg_request_firmware_upgrade
= val
;
4950 static DEVICE_ATTR(lpfc_req_fw_upgrade
, S_IRUGO
| S_IWUSR
,
4951 lpfc_request_firmware_upgrade_show
,
4952 lpfc_request_firmware_upgrade_store
);
4955 * lpfc_fcp_imax_store
4957 * @dev: class device that is converted into a Scsi_host.
4958 * @attr: device attribute, not used.
4959 * @buf: string with the number of fast-path FCP interrupts per second.
4960 * @count: unused variable.
4963 * If val is in a valid range [636,651042], then set the adapter's
4964 * maximum number of fast-path FCP interrupts per second.
4967 * length of the buf on success if val is in range the intended mode
4969 * -EINVAL if val out of range or intended mode is not supported.
4972 lpfc_fcp_imax_store(struct device
*dev
, struct device_attribute
*attr
,
4973 const char *buf
, size_t count
)
4975 struct Scsi_Host
*shost
= class_to_shost(dev
);
4976 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4977 struct lpfc_hba
*phba
= vport
->phba
;
4978 struct lpfc_eq_intr_info
*eqi
;
4982 /* fcp_imax is only valid for SLI4 */
4983 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
4986 /* Sanity check on user data */
4987 if (!isdigit(buf
[0]))
4989 if (sscanf(buf
, "%i", &val
) != 1)
4993 * Value range for the HBA is [5000,5000000]
4994 * The value for each EQ depends on how many EQs are configured.
4997 if (val
&& (val
< LPFC_MIN_IMAX
|| val
> LPFC_MAX_IMAX
))
5000 phba
->cfg_auto_imax
= (val
) ? 0 : 1;
5001 if (phba
->cfg_fcp_imax
&& !val
) {
5002 queue_delayed_work(phba
->wq
, &phba
->eq_delay_work
,
5003 msecs_to_jiffies(LPFC_EQ_DELAY_MSECS
));
5005 for_each_present_cpu(i
) {
5006 eqi
= per_cpu_ptr(phba
->sli4_hba
.eq_info
, i
);
5011 phba
->cfg_fcp_imax
= (uint32_t)val
;
5013 if (phba
->cfg_fcp_imax
)
5014 usdelay
= LPFC_SEC_TO_USEC
/ phba
->cfg_fcp_imax
;
5018 for (i
= 0; i
< phba
->cfg_irq_chann
; i
+= LPFC_MAX_EQ_DELAY_EQID_CNT
)
5019 lpfc_modify_hba_eq_delay(phba
, i
, LPFC_MAX_EQ_DELAY_EQID_CNT
,
5026 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
5029 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
5031 static int lpfc_fcp_imax
= LPFC_DEF_IMAX
;
5032 module_param(lpfc_fcp_imax
, int, S_IRUGO
|S_IWUSR
);
5033 MODULE_PARM_DESC(lpfc_fcp_imax
,
5034 "Set the maximum number of FCP interrupts per second per HBA");
5035 lpfc_param_show(fcp_imax
)
5038 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
5039 * @phba: lpfc_hba pointer.
5040 * @val: link speed value.
5043 * If val is in a valid range [636,651042], then initialize the adapter's
5044 * maximum number of fast-path FCP interrupts per second.
5047 * zero if val saved.
5048 * -EINVAL val out of range
5051 lpfc_fcp_imax_init(struct lpfc_hba
*phba
, int val
)
5053 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
5054 phba
->cfg_fcp_imax
= 0;
5058 if ((val
>= LPFC_MIN_IMAX
&& val
<= LPFC_MAX_IMAX
) ||
5060 phba
->cfg_fcp_imax
= val
;
5064 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5065 "3016 lpfc_fcp_imax: %d out of range, using default\n",
5067 phba
->cfg_fcp_imax
= LPFC_DEF_IMAX
;
5072 static DEVICE_ATTR_RW(lpfc_fcp_imax
);
5075 * lpfc_cq_max_proc_limit_store
5077 * @dev: class device that is converted into a Scsi_host.
5078 * @attr: device attribute, not used.
5079 * @buf: string with the cq max processing limit of cqes
5080 * @count: unused variable.
5083 * If val is in a valid range, then set value on each cq
5086 * The length of the buf: if successful
5087 * -ERANGE: if val is not in the valid range
5088 * -EINVAL: if bad value format or intended mode is not supported.
5091 lpfc_cq_max_proc_limit_store(struct device
*dev
, struct device_attribute
*attr
,
5092 const char *buf
, size_t count
)
5094 struct Scsi_Host
*shost
= class_to_shost(dev
);
5095 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5096 struct lpfc_hba
*phba
= vport
->phba
;
5097 struct lpfc_queue
*eq
, *cq
;
5101 /* cq_max_proc_limit is only valid for SLI4 */
5102 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
5105 /* Sanity check on user data */
5106 if (!isdigit(buf
[0]))
5108 if (kstrtoul(buf
, 0, &val
))
5111 if (val
< LPFC_CQ_MIN_PROC_LIMIT
|| val
> LPFC_CQ_MAX_PROC_LIMIT
)
5114 phba
->cfg_cq_max_proc_limit
= (uint32_t)val
;
5116 /* set the values on the cq's */
5117 for (i
= 0; i
< phba
->cfg_irq_chann
; i
++) {
5118 eq
= phba
->sli4_hba
.hdwq
[i
].hba_eq
;
5122 list_for_each_entry(cq
, &eq
->child_list
, list
)
5123 cq
->max_proc_limit
= min(phba
->cfg_cq_max_proc_limit
,
5131 * lpfc_cq_max_proc_limit: The maximum number CQE entries processed in an
5132 * itteration of CQ processing.
5134 static int lpfc_cq_max_proc_limit
= LPFC_CQ_DEF_MAX_PROC_LIMIT
;
5135 module_param(lpfc_cq_max_proc_limit
, int, 0644);
5136 MODULE_PARM_DESC(lpfc_cq_max_proc_limit
,
5137 "Set the maximum number CQEs processed in an iteration of "
5139 lpfc_param_show(cq_max_proc_limit
)
5142 * lpfc_cq_poll_threshold: Set the threshold of CQE completions in a
5143 * single handler call which should request a polled completion rather
5144 * than re-enabling interrupts.
5146 LPFC_ATTR_RW(cq_poll_threshold
, LPFC_CQ_DEF_THRESHOLD_TO_POLL
,
5147 LPFC_CQ_MIN_THRESHOLD_TO_POLL
,
5148 LPFC_CQ_MAX_THRESHOLD_TO_POLL
,
5149 "CQE Processing Threshold to enable Polling");
5152 * lpfc_cq_max_proc_limit_init - Set the initial cq max_proc_limit
5153 * @phba: lpfc_hba pointer.
5157 * If val is in a valid range, then initialize the adapter's maximum
5161 * Always returns 0 for success, even if value not always set to
5162 * requested value. If value out of range or not supported, will fall
5166 lpfc_cq_max_proc_limit_init(struct lpfc_hba
*phba
, int val
)
5168 phba
->cfg_cq_max_proc_limit
= LPFC_CQ_DEF_MAX_PROC_LIMIT
;
5170 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
5173 if (val
>= LPFC_CQ_MIN_PROC_LIMIT
&& val
<= LPFC_CQ_MAX_PROC_LIMIT
) {
5174 phba
->cfg_cq_max_proc_limit
= val
;
5178 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5179 "0371 "LPFC_DRIVER_NAME
"_cq_max_proc_limit: "
5180 "%d out of range, using default\n",
5181 phba
->cfg_cq_max_proc_limit
);
5186 static DEVICE_ATTR_RW(lpfc_cq_max_proc_limit
);
5189 * lpfc_state_show - Display current driver CPU affinity
5190 * @dev: class converted to a Scsi_host structure.
5191 * @attr: device attribute, not used.
5192 * @buf: on return contains text describing the state of the link.
5194 * Returns: size of formatted string.
5197 lpfc_fcp_cpu_map_show(struct device
*dev
, struct device_attribute
*attr
,
5200 struct Scsi_Host
*shost
= class_to_shost(dev
);
5201 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5202 struct lpfc_hba
*phba
= vport
->phba
;
5203 struct lpfc_vector_map_info
*cpup
;
5206 if ((phba
->sli_rev
!= LPFC_SLI_REV4
) ||
5207 (phba
->intr_type
!= MSIX
))
5210 switch (phba
->cfg_fcp_cpu_map
) {
5212 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
5213 "fcp_cpu_map: No mapping (%d)\n",
5214 phba
->cfg_fcp_cpu_map
);
5217 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
5218 "fcp_cpu_map: HBA centric mapping (%d): "
5219 "%d of %d CPUs online from %d possible CPUs\n",
5220 phba
->cfg_fcp_cpu_map
, num_online_cpus(),
5222 phba
->sli4_hba
.num_possible_cpu
);
5226 while (phba
->sli4_hba
.curr_disp_cpu
<
5227 phba
->sli4_hba
.num_possible_cpu
) {
5228 cpup
= &phba
->sli4_hba
.cpu_map
[phba
->sli4_hba
.curr_disp_cpu
];
5230 if (!cpu_present(phba
->sli4_hba
.curr_disp_cpu
))
5231 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
5232 "CPU %02d not present\n",
5233 phba
->sli4_hba
.curr_disp_cpu
);
5234 else if (cpup
->irq
== LPFC_VECTOR_MAP_EMPTY
) {
5235 if (cpup
->hdwq
== LPFC_VECTOR_MAP_EMPTY
)
5237 buf
+ len
, PAGE_SIZE
- len
,
5238 "CPU %02d hdwq None "
5239 "physid %d coreid %d ht %d\n",
5240 phba
->sli4_hba
.curr_disp_cpu
,
5242 cpup
->core_id
, cpup
->hyper
);
5245 buf
+ len
, PAGE_SIZE
- len
,
5246 "CPU %02d EQ %04d hdwq %04d "
5247 "physid %d coreid %d ht %d\n",
5248 phba
->sli4_hba
.curr_disp_cpu
,
5249 cpup
->eq
, cpup
->hdwq
, cpup
->phys_id
,
5250 cpup
->core_id
, cpup
->hyper
);
5252 if (cpup
->hdwq
== LPFC_VECTOR_MAP_EMPTY
)
5254 buf
+ len
, PAGE_SIZE
- len
,
5255 "CPU %02d hdwq None "
5256 "physid %d coreid %d ht %d IRQ %d\n",
5257 phba
->sli4_hba
.curr_disp_cpu
,
5259 cpup
->core_id
, cpup
->hyper
, cpup
->irq
);
5262 buf
+ len
, PAGE_SIZE
- len
,
5263 "CPU %02d EQ %04d hdwq %04d "
5264 "physid %d coreid %d ht %d IRQ %d\n",
5265 phba
->sli4_hba
.curr_disp_cpu
,
5266 cpup
->eq
, cpup
->hdwq
, cpup
->phys_id
,
5267 cpup
->core_id
, cpup
->hyper
, cpup
->irq
);
5270 phba
->sli4_hba
.curr_disp_cpu
++;
5272 /* display max number of CPUs keeping some margin */
5273 if (phba
->sli4_hba
.curr_disp_cpu
<
5274 phba
->sli4_hba
.num_possible_cpu
&&
5275 (len
>= (PAGE_SIZE
- 64))) {
5276 len
+= scnprintf(buf
+ len
,
5277 PAGE_SIZE
- len
, "more...\n");
5282 if (phba
->sli4_hba
.curr_disp_cpu
== phba
->sli4_hba
.num_possible_cpu
)
5283 phba
->sli4_hba
.curr_disp_cpu
= 0;
5289 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
5290 * @dev: class device that is converted into a Scsi_host.
5291 * @attr: device attribute, not used.
5292 * @buf: one or more lpfc_polling_flags values.
5296 * -EINVAL - Not implemented yet.
5299 lpfc_fcp_cpu_map_store(struct device
*dev
, struct device_attribute
*attr
,
5300 const char *buf
, size_t count
)
5302 int status
= -EINVAL
;
5307 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
5310 # Value range is [0 to 1]. Default value is LPFC_HBA_CPU_MAP (1).
5311 # 0 - Do not affinitze IRQ vectors
5312 # 1 - Affintize HBA vectors with respect to each HBA
5313 # (start with CPU0 for each HBA)
5314 # This also defines how Hardware Queues are mapped to specific CPUs.
5316 static int lpfc_fcp_cpu_map
= LPFC_HBA_CPU_MAP
;
5317 module_param(lpfc_fcp_cpu_map
, int, S_IRUGO
|S_IWUSR
);
5318 MODULE_PARM_DESC(lpfc_fcp_cpu_map
,
5319 "Defines how to map CPUs to IRQ vectors per HBA");
5322 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
5323 * @phba: lpfc_hba pointer.
5324 * @val: link speed value.
5327 * If val is in a valid range [0-2], then affinitze the adapter's
5331 * zero if val saved.
5332 * -EINVAL val out of range
5335 lpfc_fcp_cpu_map_init(struct lpfc_hba
*phba
, int val
)
5337 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
5338 phba
->cfg_fcp_cpu_map
= 0;
5342 if (val
>= LPFC_MIN_CPU_MAP
&& val
<= LPFC_MAX_CPU_MAP
) {
5343 phba
->cfg_fcp_cpu_map
= val
;
5347 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5348 "3326 lpfc_fcp_cpu_map: %d out of range, using "
5350 phba
->cfg_fcp_cpu_map
= LPFC_HBA_CPU_MAP
;
5355 static DEVICE_ATTR_RW(lpfc_fcp_cpu_map
);
5358 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
5359 # Value range is [2,3]. Default value is 3.
5361 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
5362 "Select Fibre Channel class of service for FCP sequences");
5365 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
5366 # is [0,1]. Default value is 0.
5368 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
5369 "Use ADISC on rediscovery to authenticate FCP devices");
5372 # lpfc_first_burst_size: First burst size to use on the NPorts
5373 # that support first burst.
5374 # Value range is [0,65536]. Default value is 0.
5376 LPFC_VPORT_ATTR_RW(first_burst_size
, 0, 0, 65536,
5377 "First burst size for Targets that support first burst");
5380 * lpfc_nvmet_fb_size: NVME Target mode supported first burst size.
5381 * When the driver is configured as an NVME target, this value is
5382 * communicated to the NVME initiator in the PRLI response. It is
5383 * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support
5384 * parameters are set and the target is sending the PRLI RSP.
5385 * Parameter supported on physical port only - no NPIV support.
5386 * Value range is [0,65536]. Default value is 0.
5388 LPFC_ATTR_RW(nvmet_fb_size
, 0, 0, 65536,
5389 "NVME Target mode first burst size in 512B increments.");
5392 * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
5393 * For the Initiator (I), enabling this parameter means that an NVMET
5394 * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be
5395 * processed by the initiator for subsequent NVME FCP IO. For the target
5396 * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size
5397 * driver parameter as the target function's first burst size returned to the
5398 * initiator in the target's NVME PRLI response. Parameter supported on physical
5399 * port only - no NPIV support.
5400 * Value range is [0,1]. Default value is 0 (disabled).
5402 LPFC_ATTR_RW(nvme_enable_fb
, 0, 0, 1,
5403 "Enable First Burst feature on I and T functions.");
5406 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
5407 # depth. Default value is 0. When the value of this parameter is zero the
5408 # SCSI command completion time is not used for controlling I/O queue depth. When
5409 # the parameter is set to a non-zero value, the I/O queue depth is controlled
5410 # to limit the I/O completion time to the parameter value.
5411 # The value is set in milliseconds.
5413 LPFC_VPORT_ATTR(max_scsicmpl_time
, 0, 0, 60000,
5414 "Use command completion time to control queue depth");
5416 lpfc_vport_param_show(max_scsicmpl_time
);
5418 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
5420 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5421 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
5423 if (val
== vport
->cfg_max_scsicmpl_time
)
5425 if ((val
< 0) || (val
> 60000))
5427 vport
->cfg_max_scsicmpl_time
= val
;
5429 spin_lock_irq(shost
->host_lock
);
5430 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
5431 if (!NLP_CHK_NODE_ACT(ndlp
))
5433 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
5435 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
5437 spin_unlock_irq(shost
->host_lock
);
5440 lpfc_vport_param_store(max_scsicmpl_time
);
5441 static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time
);
5444 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
5445 # range is [0,1]. Default value is 0.
5447 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
5450 # lpfc_xri_rebalancing: enable or disable XRI rebalancing feature
5451 # range is [0,1]. Default value is 1.
5453 LPFC_ATTR_R(xri_rebalancing
, 1, 0, 1, "Enable/Disable XRI rebalancing");
5456 * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds
5457 * range is [0,1]. Default value is 0.
5458 * For [0], FCP commands are issued to Work Queues based on upper layer
5459 * hardware queue index.
5460 * For [1], FCP commands are issued to a Work Queue associated with the
5463 * LPFC_FCP_SCHED_BY_HDWQ == 0
5464 * LPFC_FCP_SCHED_BY_CPU == 1
5466 * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu
5467 * affinity for FCP/NVME I/Os through Work Queues associated with the current
5468 * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os
5469 * through WQs will be used.
5471 LPFC_ATTR_RW(fcp_io_sched
, LPFC_FCP_SCHED_BY_CPU
,
5472 LPFC_FCP_SCHED_BY_HDWQ
,
5473 LPFC_FCP_SCHED_BY_CPU
,
5474 "Determine scheduling algorithm for "
5475 "issuing commands [0] - Hardware Queue, [1] - Current CPU");
5478 * lpfc_ns_query: Determine algrithmn for NameServer queries after RSCN
5479 * range is [0,1]. Default value is 0.
5480 * For [0], GID_FT is used for NameServer queries after RSCN (default)
5481 * For [1], GID_PT is used for NameServer queries after RSCN
5484 LPFC_ATTR_RW(ns_query
, LPFC_NS_QUERY_GID_FT
,
5485 LPFC_NS_QUERY_GID_FT
, LPFC_NS_QUERY_GID_PT
,
5486 "Determine algorithm NameServer queries after RSCN "
5487 "[0] - GID_FT, [1] - GID_PT");
5490 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
5491 # range is [0,1]. Default value is 0.
5492 # For [0], bus reset issues target reset to ALL devices
5493 # For [1], bus reset issues target reset to non-FCP2 devices
5495 LPFC_ATTR_RW(fcp2_no_tgt_reset
, 0, 0, 1, "Determine bus reset behavior for "
5496 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
5500 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
5501 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
5502 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
5503 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
5504 # cr_delay is set to 0.
5506 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
5507 "interrupt response is generated");
5509 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
5510 "interrupt response is generated");
5513 # lpfc_multi_ring_support: Determines how many rings to spread available
5514 # cmd/rsp IOCB entries across.
5515 # Value range is [1,2]. Default value is 1.
5517 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
5518 "SLI rings to spread IOCB entries across");
5521 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
5522 # identifies what rctl value to configure the additional ring for.
5523 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
5525 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
5526 255, "Identifies RCTL for additional ring configuration");
5529 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
5530 # identifies what type value to configure the additional ring for.
5531 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
5533 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
5534 255, "Identifies TYPE for additional ring configuration");
5537 # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN
5538 # 0 = SmartSAN functionality disabled (default)
5539 # 1 = SmartSAN functionality enabled
5540 # This parameter will override the value of lpfc_fdmi_on module parameter.
5541 # Value range is [0,1]. Default value is 0.
5543 LPFC_ATTR_R(enable_SmartSAN
, 0, 0, 1, "Enable SmartSAN functionality");
5546 # lpfc_fdmi_on: Controls FDMI support.
5548 # 1 Traditional FDMI support (default)
5549 # Traditional FDMI support means the driver will assume FDMI-2 support;
5550 # however, if that fails, it will fallback to FDMI-1.
5551 # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on.
5552 # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of
5554 # Value range [0,1]. Default value is 1.
5556 LPFC_ATTR_R(fdmi_on
, 1, 0, 1, "Enable FDMI support");
5559 # Specifies the maximum number of ELS cmds we can have outstanding (for
5560 # discovery). Value range is [1,64]. Default value = 32.
5562 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
5563 "during discovery");
5566 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
5567 # will be scanned by the SCSI midlayer when sequential scanning is
5568 # used; and is also the highest LUN ID allowed when the SCSI midlayer
5569 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
5570 # LUN ID limit, but the SCSI midlayer requires this field for the uses
5571 # above. The lpfc driver limits the default value to 255 for two reasons.
5572 # As it bounds the sequential scan loop, scanning for thousands of luns
5573 # on a target can take minutes of wall clock time. Additionally,
5574 # there are FC targets, such as JBODs, that only recognize 8-bits of
5575 # LUN ID. When they receive a value greater than 8 bits, they chop off
5576 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
5577 # and so on all as LUN ID 0. This causes the linux kernel, which sees
5578 # valid responses at each of the LUN IDs, to believe there are multiple
5579 # devices present, when in fact, there is only 1.
5580 # A customer that is aware of their target behaviors, and the results as
5581 # indicated above, is welcome to increase the lpfc_max_luns value.
5582 # As mentioned, this value is not used by the lpfc driver, only the
5584 # Value range is [0,65535]. Default value is 255.
5585 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
5587 LPFC_VPORT_ULL_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN ID");
5590 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
5591 # Value range is [1,255], default value is 10.
5593 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
5594 "Milliseconds driver will wait between polling FCP ring");
5597 # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands
5598 # to complete in seconds. Value range is [5,180], default value is 60.
5600 LPFC_ATTR_RW(task_mgmt_tmo
, 60, 5, 180,
5601 "Maximum time to wait for task management commands to complete");
5603 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
5604 # support this feature
5607 # 2 = MSI-X enabled (default)
5608 # Value range is [0,2]. Default value is 2.
5610 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
5611 "MSI-X (2), if possible");
5614 * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs
5616 * 0 = NVME OAS disabled
5617 * 1 = NVME OAS enabled
5619 * Value range is [0,1]. Default value is 0.
5621 LPFC_ATTR_RW(nvme_oas
, 0, 0, 1,
5622 "Use OAS bit on NVME IOs");
5625 * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs
5627 * 0 = Put NVME Command in SGL
5628 * 1 = Embed NVME Command in WQE (unless G7)
5629 * 2 = Embed NVME Command in WQE (force)
5631 * Value range is [0,2]. Default value is 1.
5633 LPFC_ATTR_RW(nvme_embed_cmd
, 1, 0, 2,
5634 "Embed NVME Command in WQE");
5637 * lpfc_hdw_queue: Set the number of Hardware Queues the driver
5638 * will advertise it supports to the NVME and SCSI layers. This also
5639 * will map to the number of CQ/WQ pairs the driver will create.
5641 * The NVME Layer will try to create this many, plus 1 administrative
5642 * hardware queue. The administrative queue will always map to WQ 0
5643 * A hardware IO queue maps (qidx) to a specific driver CQ/WQ.
5645 * 0 = Configure the number of hdw queues to the number of active CPUs.
5646 * 1,128 = Manually specify how many hdw queues to use.
5648 * Value range is [0,128]. Default value is 0.
5650 LPFC_ATTR_R(hdw_queue
,
5652 LPFC_HBA_HDWQ_MIN
, LPFC_HBA_HDWQ_MAX
,
5653 "Set the number of I/O Hardware Queues");
5656 * lpfc_irq_chann: Set the number of IRQ vectors that are available
5657 * for Hardware Queues to utilize. This also will map to the number
5658 * of EQ / MSI-X vectors the driver will create. This should never be
5659 * more than the number of Hardware Queues
5661 * 0 = Configure number of IRQ Channels to the number of active CPUs.
5662 * 1,128 = Manually specify how many IRQ Channels to use.
5664 * Value range is [0,128]. Default value is 0.
5666 LPFC_ATTR_R(irq_chann
,
5668 LPFC_HBA_HDWQ_MIN
, LPFC_HBA_HDWQ_MAX
,
5669 "Set the number of I/O IRQ Channels");
5672 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
5673 # 0 = HBA resets disabled
5674 # 1 = HBA resets enabled (default)
5675 # 2 = HBA reset via PCI bus reset enabled
5676 # Value range is [0,2]. Default value is 1.
5678 LPFC_ATTR_RW(enable_hba_reset
, 1, 0, 2, "Enable HBA resets from the driver.");
5681 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
5682 # 0 = HBA Heartbeat disabled
5683 # 1 = HBA Heartbeat enabled (default)
5684 # Value range is [0,1]. Default value is 1.
5686 LPFC_ATTR_R(enable_hba_heartbeat
, 0, 0, 1, "Enable HBA Heartbeat.");
5689 # lpfc_EnableXLane: Enable Express Lane Feature
5690 # 0x0 Express Lane Feature disabled
5691 # 0x1 Express Lane Feature enabled
5692 # Value range is [0,1]. Default value is 0.
5694 LPFC_ATTR_R(EnableXLane
, 0, 0, 1, "Enable Express Lane Feature.");
5697 # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature
5698 # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits)
5699 # Value range is [0x0,0x7f]. Default value is 0
5701 LPFC_ATTR_RW(XLanePriority
, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
5704 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
5705 # 0 = BlockGuard disabled (default)
5706 # 1 = BlockGuard enabled
5707 # Value range is [0,1]. Default value is 0.
5709 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
5713 # - Bit mask of host protection capabilities used to register with the
5715 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
5716 # - Allows you to ultimately specify which profiles to use
5717 # - Default will result in registering capabilities for all profiles.
5718 # - SHOST_DIF_TYPE1_PROTECTION 1
5719 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
5720 # - SHOST_DIX_TYPE0_PROTECTION 8
5721 # HBA supports DIX Type 0: Host to HBA protection only
5722 # - SHOST_DIX_TYPE1_PROTECTION 16
5723 # HBA supports DIX Type 1: Host to HBA Type 1 protection
5726 LPFC_ATTR(prot_mask
,
5727 (SHOST_DIF_TYPE1_PROTECTION
|
5728 SHOST_DIX_TYPE0_PROTECTION
|
5729 SHOST_DIX_TYPE1_PROTECTION
),
5731 (SHOST_DIF_TYPE1_PROTECTION
|
5732 SHOST_DIX_TYPE0_PROTECTION
|
5733 SHOST_DIX_TYPE1_PROTECTION
),
5734 "T10-DIF host protection capabilities mask");
5737 # lpfc_prot_guard: i
5738 # - Bit mask of protection guard types to register with the SCSI mid-layer
5739 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
5740 # - Allows you to ultimately specify which profiles to use
5741 # - Default will result in registering capabilities for all guard types
5744 LPFC_ATTR(prot_guard
,
5745 SHOST_DIX_GUARD_IP
, SHOST_DIX_GUARD_CRC
, SHOST_DIX_GUARD_IP
,
5746 "T10-DIF host protection guard type");
5749 * Delay initial NPort discovery when Clean Address bit is cleared in
5750 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
5751 * This parameter can have value 0 or 1.
5752 * When this parameter is set to 0, no delay is added to the initial
5754 * When this parameter is set to non-zero value, initial Nport discovery is
5755 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
5756 * accept and FCID/Fabric name/Fabric portname is changed.
5757 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
5758 * when Clean Address bit is cleared in FLOGI/FDISC
5759 * accept and FCID/Fabric name/Fabric portname is changed.
5760 * Default value is 0.
5762 LPFC_ATTR(delay_discovery
, 0, 0, 1,
5763 "Delay NPort discovery when Clean Address bit is cleared.");
5766 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
5767 * This value can be set to values between 64 and 4096. The default value
5768 * is 64, but may be increased to allow for larger Max I/O sizes. The scsi
5769 * and nvme layers will allow I/O sizes up to (MAX_SEG_COUNT * SEG_SIZE).
5770 * Because of the additional overhead involved in setting up T10-DIF,
5771 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
5772 * and will be limited to 512 if BlockGuard is enabled under SLI3.
5774 static uint lpfc_sg_seg_cnt
= LPFC_DEFAULT_SG_SEG_CNT
;
5775 module_param(lpfc_sg_seg_cnt
, uint
, 0444);
5776 MODULE_PARM_DESC(lpfc_sg_seg_cnt
, "Max Scatter Gather Segment Count");
5779 * lpfc_sg_seg_cnt_show - Display the scatter/gather list sizes
5780 * configured for the adapter
5781 * @dev: class converted to a Scsi_host structure.
5782 * @attr: device attribute, not used.
5783 * @buf: on return contains a string with the list sizes
5785 * Returns: size of formatted string.
5788 lpfc_sg_seg_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
5791 struct Scsi_Host
*shost
= class_to_shost(dev
);
5792 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5793 struct lpfc_hba
*phba
= vport
->phba
;
5796 len
= scnprintf(buf
, PAGE_SIZE
, "SGL sz: %d total SGEs: %d\n",
5797 phba
->cfg_sg_dma_buf_size
, phba
->cfg_total_seg_cnt
);
5799 len
+= scnprintf(buf
+ len
, PAGE_SIZE
, "Cfg: %d SCSI: %d NVME: %d\n",
5800 phba
->cfg_sg_seg_cnt
, phba
->cfg_scsi_seg_cnt
,
5801 phba
->cfg_nvme_seg_cnt
);
5805 static DEVICE_ATTR_RO(lpfc_sg_seg_cnt
);
5808 * lpfc_sg_seg_cnt_init - Set the hba sg_seg_cnt initial value
5809 * @phba: lpfc_hba pointer.
5810 * @val: contains the initial value
5813 * Validates the initial value is within range and assigns it to the
5814 * adapter. If not in range, an error message is posted and the
5815 * default value is assigned.
5818 * zero if value is in range and is set
5819 * -EINVAL if value was out of range
5822 lpfc_sg_seg_cnt_init(struct lpfc_hba
*phba
, int val
)
5824 if (val
>= LPFC_MIN_SG_SEG_CNT
&& val
<= LPFC_MAX_SG_SEG_CNT
) {
5825 phba
->cfg_sg_seg_cnt
= val
;
5828 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5829 "0409 "LPFC_DRIVER_NAME
"_sg_seg_cnt attribute cannot "
5830 "be set to %d, allowed range is [%d, %d]\n",
5831 val
, LPFC_MIN_SG_SEG_CNT
, LPFC_MAX_SG_SEG_CNT
);
5832 phba
->cfg_sg_seg_cnt
= LPFC_DEFAULT_SG_SEG_CNT
;
5837 * lpfc_enable_mds_diags: Enable MDS Diagnostics
5838 * 0 = MDS Diagnostics disabled (default)
5839 * 1 = MDS Diagnostics enabled
5840 * Value range is [0,1]. Default value is 0.
5842 LPFC_ATTR_R(enable_mds_diags
, 0, 0, 1, "Enable MDS Diagnostics");
5845 * lpfc_ras_fwlog_buffsize: Firmware logging host buffer size
5846 * 0 = Disable firmware logging (default)
5847 * [1-4] = Multiple of 1/4th Mb of host memory for FW logging
5848 * Value range [0..4]. Default value is 0
5850 LPFC_ATTR_RW(ras_fwlog_buffsize
, 0, 0, 4, "Host memory for FW logging");
5853 * lpfc_ras_fwlog_level: Firmware logging verbosity level
5854 * Valid only if firmware logging is enabled
5855 * 0(Least Verbosity) 4 (most verbosity)
5856 * Value range is [0..4]. Default value is 0
5858 LPFC_ATTR_RW(ras_fwlog_level
, 0, 0, 4, "Firmware Logging Level");
5861 * lpfc_ras_fwlog_func: Firmware logging enabled on function number
5862 * Default function which has RAS support : 0
5863 * Value Range is [0..7].
5864 * FW logging is a global action and enablement is via a specific
5867 LPFC_ATTR_RW(ras_fwlog_func
, 0, 0, 7, "Firmware Logging Enabled on Function");
5870 * lpfc_enable_bbcr: Enable BB Credit Recovery
5871 * 0 = BB Credit Recovery disabled
5872 * 1 = BB Credit Recovery enabled (default)
5873 * Value range is [0,1]. Default value is 1.
5875 LPFC_BBCR_ATTR_RW(enable_bbcr
, 1, 0, 1, "Enable BBC Recovery");
5878 * lpfc_enable_dpp: Enable DPP on G7
5879 * 0 = DPP on G7 disabled
5880 * 1 = DPP on G7 enabled (default)
5881 * Value range is [0,1]. Default value is 1.
5883 LPFC_ATTR_RW(enable_dpp
, 1, 0, 1, "Enable Direct Packet Push");
5885 struct device_attribute
*lpfc_hba_attrs
[] = {
5886 &dev_attr_nvme_info
,
5887 &dev_attr_scsi_stat
,
5889 &dev_attr_bg_guard_err
,
5890 &dev_attr_bg_apptag_err
,
5891 &dev_attr_bg_reftag_err
,
5893 &dev_attr_serialnum
,
5894 &dev_attr_modeldesc
,
5895 &dev_attr_modelname
,
5896 &dev_attr_programtype
,
5900 &dev_attr_option_rom_version
,
5901 &dev_attr_link_state
,
5902 &dev_attr_num_discovered_ports
,
5903 &dev_attr_menlo_mgmt_mode
,
5904 &dev_attr_lpfc_drvr_version
,
5905 &dev_attr_lpfc_enable_fip
,
5906 &dev_attr_lpfc_temp_sensor
,
5907 &dev_attr_lpfc_log_verbose
,
5908 &dev_attr_lpfc_lun_queue_depth
,
5909 &dev_attr_lpfc_tgt_queue_depth
,
5910 &dev_attr_lpfc_hba_queue_depth
,
5911 &dev_attr_lpfc_peer_port_login
,
5912 &dev_attr_lpfc_nodev_tmo
,
5913 &dev_attr_lpfc_devloss_tmo
,
5914 &dev_attr_lpfc_enable_fc4_type
,
5915 &dev_attr_lpfc_fcp_class
,
5916 &dev_attr_lpfc_use_adisc
,
5917 &dev_attr_lpfc_first_burst_size
,
5918 &dev_attr_lpfc_ack0
,
5919 &dev_attr_lpfc_xri_rebalancing
,
5920 &dev_attr_lpfc_topology
,
5921 &dev_attr_lpfc_scan_down
,
5922 &dev_attr_lpfc_link_speed
,
5923 &dev_attr_lpfc_fcp_io_sched
,
5924 &dev_attr_lpfc_ns_query
,
5925 &dev_attr_lpfc_fcp2_no_tgt_reset
,
5926 &dev_attr_lpfc_cr_delay
,
5927 &dev_attr_lpfc_cr_count
,
5928 &dev_attr_lpfc_multi_ring_support
,
5929 &dev_attr_lpfc_multi_ring_rctl
,
5930 &dev_attr_lpfc_multi_ring_type
,
5931 &dev_attr_lpfc_fdmi_on
,
5932 &dev_attr_lpfc_enable_SmartSAN
,
5933 &dev_attr_lpfc_max_luns
,
5934 &dev_attr_lpfc_enable_npiv
,
5935 &dev_attr_lpfc_fcf_failover_policy
,
5936 &dev_attr_lpfc_enable_rrq
,
5937 &dev_attr_nport_evt_cnt
,
5938 &dev_attr_board_mode
,
5945 &dev_attr_npiv_info
,
5946 &dev_attr_issue_reset
,
5947 &dev_attr_lpfc_poll
,
5948 &dev_attr_lpfc_poll_tmo
,
5949 &dev_attr_lpfc_task_mgmt_tmo
,
5950 &dev_attr_lpfc_use_msi
,
5951 &dev_attr_lpfc_nvme_oas
,
5952 &dev_attr_lpfc_nvme_embed_cmd
,
5953 &dev_attr_lpfc_fcp_imax
,
5954 &dev_attr_lpfc_cq_poll_threshold
,
5955 &dev_attr_lpfc_cq_max_proc_limit
,
5956 &dev_attr_lpfc_fcp_cpu_map
,
5957 &dev_attr_lpfc_hdw_queue
,
5958 &dev_attr_lpfc_irq_chann
,
5959 &dev_attr_lpfc_suppress_rsp
,
5960 &dev_attr_lpfc_nvmet_mrq
,
5961 &dev_attr_lpfc_nvmet_mrq_post
,
5962 &dev_attr_lpfc_nvme_enable_fb
,
5963 &dev_attr_lpfc_nvmet_fb_size
,
5964 &dev_attr_lpfc_enable_bg
,
5965 &dev_attr_lpfc_soft_wwnn
,
5966 &dev_attr_lpfc_soft_wwpn
,
5967 &dev_attr_lpfc_soft_wwn_enable
,
5968 &dev_attr_lpfc_enable_hba_reset
,
5969 &dev_attr_lpfc_enable_hba_heartbeat
,
5970 &dev_attr_lpfc_EnableXLane
,
5971 &dev_attr_lpfc_XLanePriority
,
5972 &dev_attr_lpfc_xlane_lun
,
5973 &dev_attr_lpfc_xlane_tgt
,
5974 &dev_attr_lpfc_xlane_vpt
,
5975 &dev_attr_lpfc_xlane_lun_state
,
5976 &dev_attr_lpfc_xlane_lun_status
,
5977 &dev_attr_lpfc_xlane_priority
,
5978 &dev_attr_lpfc_sg_seg_cnt
,
5979 &dev_attr_lpfc_max_scsicmpl_time
,
5980 &dev_attr_lpfc_stat_data_ctrl
,
5981 &dev_attr_lpfc_aer_support
,
5982 &dev_attr_lpfc_aer_state_cleanup
,
5983 &dev_attr_lpfc_sriov_nr_virtfn
,
5984 &dev_attr_lpfc_req_fw_upgrade
,
5985 &dev_attr_lpfc_suppress_link_up
,
5986 &dev_attr_lpfc_iocb_cnt
,
5989 &dev_attr_txcmplq_hw
,
5990 &dev_attr_lpfc_fips_level
,
5991 &dev_attr_lpfc_fips_rev
,
5993 &dev_attr_lpfc_sriov_hw_max_virtfn
,
5995 &dev_attr_lpfc_xlane_supported
,
5996 &dev_attr_lpfc_enable_mds_diags
,
5997 &dev_attr_lpfc_ras_fwlog_buffsize
,
5998 &dev_attr_lpfc_ras_fwlog_level
,
5999 &dev_attr_lpfc_ras_fwlog_func
,
6000 &dev_attr_lpfc_enable_bbcr
,
6001 &dev_attr_lpfc_enable_dpp
,
6005 struct device_attribute
*lpfc_vport_attrs
[] = {
6007 &dev_attr_link_state
,
6008 &dev_attr_num_discovered_ports
,
6009 &dev_attr_lpfc_drvr_version
,
6010 &dev_attr_lpfc_log_verbose
,
6011 &dev_attr_lpfc_lun_queue_depth
,
6012 &dev_attr_lpfc_tgt_queue_depth
,
6013 &dev_attr_lpfc_nodev_tmo
,
6014 &dev_attr_lpfc_devloss_tmo
,
6015 &dev_attr_lpfc_hba_queue_depth
,
6016 &dev_attr_lpfc_peer_port_login
,
6017 &dev_attr_lpfc_restrict_login
,
6018 &dev_attr_lpfc_fcp_class
,
6019 &dev_attr_lpfc_use_adisc
,
6020 &dev_attr_lpfc_first_burst_size
,
6021 &dev_attr_lpfc_max_luns
,
6022 &dev_attr_nport_evt_cnt
,
6023 &dev_attr_npiv_info
,
6024 &dev_attr_lpfc_enable_da_id
,
6025 &dev_attr_lpfc_max_scsicmpl_time
,
6026 &dev_attr_lpfc_stat_data_ctrl
,
6027 &dev_attr_lpfc_static_vport
,
6028 &dev_attr_lpfc_fips_level
,
6029 &dev_attr_lpfc_fips_rev
,
6034 * sysfs_ctlreg_write - Write method for writing to ctlreg
6035 * @filp: open sysfs file
6036 * @kobj: kernel kobject that contains the kernel class device.
6037 * @bin_attr: kernel attributes passed to us.
6038 * @buf: contains the data to be written to the adapter IOREG space.
6039 * @off: offset into buffer to beginning of data.
6040 * @count: bytes to transfer.
6043 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
6044 * Uses the adapter io control registers to send buf contents to the adapter.
6047 * -ERANGE off and count combo out of range
6048 * -EINVAL off, count or buff address invalid
6049 * -EPERM adapter is offline
6050 * value of count, buf contents written
6053 sysfs_ctlreg_write(struct file
*filp
, struct kobject
*kobj
,
6054 struct bin_attribute
*bin_attr
,
6055 char *buf
, loff_t off
, size_t count
)
6058 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
6059 struct Scsi_Host
*shost
= class_to_shost(dev
);
6060 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6061 struct lpfc_hba
*phba
= vport
->phba
;
6063 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
6066 if ((off
+ count
) > FF_REG_AREA_SIZE
)
6069 if (count
<= LPFC_REG_WRITE_KEY_SIZE
)
6072 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
6075 /* This is to protect HBA registers from accidental writes. */
6076 if (memcmp(buf
, LPFC_REG_WRITE_KEY
, LPFC_REG_WRITE_KEY_SIZE
))
6079 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
))
6082 spin_lock_irq(&phba
->hbalock
);
6083 for (buf_off
= 0; buf_off
< count
- LPFC_REG_WRITE_KEY_SIZE
;
6084 buf_off
+= sizeof(uint32_t))
6085 writel(*((uint32_t *)(buf
+ buf_off
+ LPFC_REG_WRITE_KEY_SIZE
)),
6086 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
6088 spin_unlock_irq(&phba
->hbalock
);
6094 * sysfs_ctlreg_read - Read method for reading from ctlreg
6095 * @filp: open sysfs file
6096 * @kobj: kernel kobject that contains the kernel class device.
6097 * @bin_attr: kernel attributes passed to us.
6098 * @buf: if successful contains the data from the adapter IOREG space.
6099 * @off: offset into buffer to beginning of data.
6100 * @count: bytes to transfer.
6103 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
6104 * Uses the adapter io control registers to read data into buf.
6107 * -ERANGE off and count combo out of range
6108 * -EINVAL off, count or buff address invalid
6109 * value of count, buf contents read
6112 sysfs_ctlreg_read(struct file
*filp
, struct kobject
*kobj
,
6113 struct bin_attribute
*bin_attr
,
6114 char *buf
, loff_t off
, size_t count
)
6118 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
6119 struct Scsi_Host
*shost
= class_to_shost(dev
);
6120 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6121 struct lpfc_hba
*phba
= vport
->phba
;
6123 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
6126 if (off
> FF_REG_AREA_SIZE
)
6129 if ((off
+ count
) > FF_REG_AREA_SIZE
)
6130 count
= FF_REG_AREA_SIZE
- off
;
6132 if (count
== 0) return 0;
6134 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
6137 spin_lock_irq(&phba
->hbalock
);
6139 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
6140 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
6141 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
6144 spin_unlock_irq(&phba
->hbalock
);
6149 static struct bin_attribute sysfs_ctlreg_attr
= {
6152 .mode
= S_IRUSR
| S_IWUSR
,
6155 .read
= sysfs_ctlreg_read
,
6156 .write
= sysfs_ctlreg_write
,
6160 * sysfs_mbox_write - Write method for writing information via mbox
6161 * @filp: open sysfs file
6162 * @kobj: kernel kobject that contains the kernel class device.
6163 * @bin_attr: kernel attributes passed to us.
6164 * @buf: contains the data to be written to sysfs mbox.
6165 * @off: offset into buffer to beginning of data.
6166 * @count: bytes to transfer.
6169 * Deprecated function. All mailbox access from user space is performed via the
6173 * -EPERM operation not permitted
6176 sysfs_mbox_write(struct file
*filp
, struct kobject
*kobj
,
6177 struct bin_attribute
*bin_attr
,
6178 char *buf
, loff_t off
, size_t count
)
6184 * sysfs_mbox_read - Read method for reading information via mbox
6185 * @filp: open sysfs file
6186 * @kobj: kernel kobject that contains the kernel class device.
6187 * @bin_attr: kernel attributes passed to us.
6188 * @buf: contains the data to be read from sysfs mbox.
6189 * @off: offset into buffer to beginning of data.
6190 * @count: bytes to transfer.
6193 * Deprecated function. All mailbox access from user space is performed via the
6197 * -EPERM operation not permitted
6200 sysfs_mbox_read(struct file
*filp
, struct kobject
*kobj
,
6201 struct bin_attribute
*bin_attr
,
6202 char *buf
, loff_t off
, size_t count
)
6207 static struct bin_attribute sysfs_mbox_attr
= {
6210 .mode
= S_IRUSR
| S_IWUSR
,
6212 .size
= MAILBOX_SYSFS_MAX
,
6213 .read
= sysfs_mbox_read
,
6214 .write
= sysfs_mbox_write
,
6218 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
6219 * @vport: address of lpfc vport structure.
6223 * error return code from sysfs_create_bin_file()
6226 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
6228 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
6231 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
6232 &sysfs_drvr_stat_data_attr
);
6234 /* Virtual ports do not need ctrl_reg and mbox */
6235 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
6238 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
6239 &sysfs_ctlreg_attr
);
6241 goto out_remove_stat_attr
;
6243 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
6246 goto out_remove_ctlreg_attr
;
6249 out_remove_ctlreg_attr
:
6250 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
6251 out_remove_stat_attr
:
6252 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
6253 &sysfs_drvr_stat_data_attr
);
6259 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
6260 * @vport: address of lpfc vport structure.
6263 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
6265 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
6266 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
6267 &sysfs_drvr_stat_data_attr
);
6268 /* Virtual ports do not need ctrl_reg and mbox */
6269 if (vport
->port_type
== LPFC_NPIV_PORT
)
6271 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
6272 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
6276 * Dynamic FC Host Attributes Support
6280 * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host
6281 * @shost: kernel scsi host pointer.
6284 lpfc_get_host_symbolic_name(struct Scsi_Host
*shost
)
6286 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
6288 lpfc_vport_symbolic_node_name(vport
, fc_host_symbolic_name(shost
),
6289 sizeof fc_host_symbolic_name(shost
));
6293 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
6294 * @shost: kernel scsi host pointer.
6297 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
6299 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6301 /* note: fc_myDID already in cpu endianness */
6302 fc_host_port_id(shost
) = vport
->fc_myDID
;
6306 * lpfc_get_host_port_type - Set the value of the scsi host port type
6307 * @shost: kernel scsi host pointer.
6310 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
6312 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6313 struct lpfc_hba
*phba
= vport
->phba
;
6315 spin_lock_irq(shost
->host_lock
);
6317 if (vport
->port_type
== LPFC_NPIV_PORT
) {
6318 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
6319 } else if (lpfc_is_link_up(phba
)) {
6320 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
6321 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
6322 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
6324 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
6326 if (vport
->fc_flag
& FC_FABRIC
)
6327 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
6329 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
6332 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
6334 spin_unlock_irq(shost
->host_lock
);
6338 * lpfc_get_host_port_state - Set the value of the scsi host port state
6339 * @shost: kernel scsi host pointer.
6342 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
6344 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6345 struct lpfc_hba
*phba
= vport
->phba
;
6347 spin_lock_irq(shost
->host_lock
);
6349 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
6350 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
6352 switch (phba
->link_state
) {
6353 case LPFC_LINK_UNKNOWN
:
6354 case LPFC_LINK_DOWN
:
6355 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
6359 case LPFC_HBA_READY
:
6360 /* Links up, reports port state accordingly */
6361 if (vport
->port_state
< LPFC_VPORT_READY
)
6362 fc_host_port_state(shost
) =
6363 FC_PORTSTATE_BYPASSED
;
6365 fc_host_port_state(shost
) =
6366 FC_PORTSTATE_ONLINE
;
6368 case LPFC_HBA_ERROR
:
6369 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
6372 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
6377 spin_unlock_irq(shost
->host_lock
);
6381 * lpfc_get_host_speed - Set the value of the scsi host speed
6382 * @shost: kernel scsi host pointer.
6385 lpfc_get_host_speed(struct Scsi_Host
*shost
)
6387 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6388 struct lpfc_hba
*phba
= vport
->phba
;
6390 spin_lock_irq(shost
->host_lock
);
6392 if ((lpfc_is_link_up(phba
)) && (!(phba
->hba_flag
& HBA_FCOE_MODE
))) {
6393 switch(phba
->fc_linkspeed
) {
6394 case LPFC_LINK_SPEED_1GHZ
:
6395 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
6397 case LPFC_LINK_SPEED_2GHZ
:
6398 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
6400 case LPFC_LINK_SPEED_4GHZ
:
6401 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
6403 case LPFC_LINK_SPEED_8GHZ
:
6404 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
6406 case LPFC_LINK_SPEED_10GHZ
:
6407 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
6409 case LPFC_LINK_SPEED_16GHZ
:
6410 fc_host_speed(shost
) = FC_PORTSPEED_16GBIT
;
6412 case LPFC_LINK_SPEED_32GHZ
:
6413 fc_host_speed(shost
) = FC_PORTSPEED_32GBIT
;
6415 case LPFC_LINK_SPEED_64GHZ
:
6416 fc_host_speed(shost
) = FC_PORTSPEED_64GBIT
;
6418 case LPFC_LINK_SPEED_128GHZ
:
6419 fc_host_speed(shost
) = FC_PORTSPEED_128GBIT
;
6422 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
6425 } else if (lpfc_is_link_up(phba
) && (phba
->hba_flag
& HBA_FCOE_MODE
)) {
6426 switch (phba
->fc_linkspeed
) {
6427 case LPFC_ASYNC_LINK_SPEED_10GBPS
:
6428 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
6430 case LPFC_ASYNC_LINK_SPEED_25GBPS
:
6431 fc_host_speed(shost
) = FC_PORTSPEED_25GBIT
;
6433 case LPFC_ASYNC_LINK_SPEED_40GBPS
:
6434 fc_host_speed(shost
) = FC_PORTSPEED_40GBIT
;
6436 case LPFC_ASYNC_LINK_SPEED_100GBPS
:
6437 fc_host_speed(shost
) = FC_PORTSPEED_100GBIT
;
6440 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
6444 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
6446 spin_unlock_irq(shost
->host_lock
);
6450 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
6451 * @shost: kernel scsi host pointer.
6454 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
6456 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6457 struct lpfc_hba
*phba
= vport
->phba
;
6460 spin_lock_irq(shost
->host_lock
);
6462 if ((vport
->port_state
> LPFC_FLOGI
) &&
6463 ((vport
->fc_flag
& FC_FABRIC
) ||
6464 ((phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) &&
6465 (vport
->fc_flag
& FC_PUBLIC_LOOP
))))
6466 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
6468 /* fabric is local port if there is no F/FL_Port */
6471 spin_unlock_irq(shost
->host_lock
);
6473 fc_host_fabric_name(shost
) = node_name
;
6477 * lpfc_get_stats - Return statistical information about the adapter
6478 * @shost: kernel scsi host pointer.
6481 * NULL on error for link down, no mbox pool, sli2 active,
6482 * management not allowed, memory allocation error, or mbox error.
6486 * address of the adapter host statistics
6488 static struct fc_host_statistics
*
6489 lpfc_get_stats(struct Scsi_Host
*shost
)
6491 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6492 struct lpfc_hba
*phba
= vport
->phba
;
6493 struct lpfc_sli
*psli
= &phba
->sli
;
6494 struct fc_host_statistics
*hs
= &phba
->link_stats
;
6495 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
6496 LPFC_MBOXQ_t
*pmboxq
;
6501 * prevent udev from issuing mailbox commands until the port is
6504 if (phba
->link_state
< LPFC_LINK_DOWN
||
6505 !phba
->mbox_mem_pool
||
6506 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
6509 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
6512 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
6515 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
6517 pmb
= &pmboxq
->u
.mb
;
6518 pmb
->mbxCommand
= MBX_READ_STATUS
;
6519 pmb
->mbxOwner
= OWN_HOST
;
6520 pmboxq
->ctx_buf
= NULL
;
6521 pmboxq
->vport
= vport
;
6523 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
6524 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
6526 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
6528 if (rc
!= MBX_SUCCESS
) {
6529 if (rc
!= MBX_TIMEOUT
)
6530 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6534 memset(hs
, 0, sizeof (struct fc_host_statistics
));
6536 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
6538 * The MBX_READ_STATUS returns tx_k_bytes which has to
6539 * converted to words
6541 hs
->tx_words
= (uint64_t)
6542 ((uint64_t)pmb
->un
.varRdStatus
.xmitByteCnt
6544 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
6545 hs
->rx_words
= (uint64_t)
6546 ((uint64_t)pmb
->un
.varRdStatus
.rcvByteCnt
6549 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
6550 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
6551 pmb
->mbxOwner
= OWN_HOST
;
6552 pmboxq
->ctx_buf
= NULL
;
6553 pmboxq
->vport
= vport
;
6555 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
6556 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
6558 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
6560 if (rc
!= MBX_SUCCESS
) {
6561 if (rc
!= MBX_TIMEOUT
)
6562 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6566 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
6567 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
6568 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
6569 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
6570 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
6571 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
6572 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
6574 hs
->link_failure_count
-= lso
->link_failure_count
;
6575 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
6576 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
6577 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
6578 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
6579 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
6580 hs
->error_frames
-= lso
->error_frames
;
6582 if (phba
->hba_flag
& HBA_FCOE_MODE
) {
6584 hs
->nos_count
= (phba
->link_events
>> 1);
6585 hs
->nos_count
-= lso
->link_events
;
6586 } else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
6587 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
6588 hs
->lip_count
-= lso
->link_events
;
6592 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
6593 hs
->nos_count
-= lso
->link_events
;
6596 hs
->dumped_frames
= -1;
6598 hs
->seconds_since_last_reset
= ktime_get_seconds() - psli
->stats_start
;
6600 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6606 * lpfc_reset_stats - Copy the adapter link stats information
6607 * @shost: kernel scsi host pointer.
6610 lpfc_reset_stats(struct Scsi_Host
*shost
)
6612 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6613 struct lpfc_hba
*phba
= vport
->phba
;
6614 struct lpfc_sli
*psli
= &phba
->sli
;
6615 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
6616 LPFC_MBOXQ_t
*pmboxq
;
6620 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
6623 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
6626 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
6628 pmb
= &pmboxq
->u
.mb
;
6629 pmb
->mbxCommand
= MBX_READ_STATUS
;
6630 pmb
->mbxOwner
= OWN_HOST
;
6631 pmb
->un
.varWords
[0] = 0x1; /* reset request */
6632 pmboxq
->ctx_buf
= NULL
;
6633 pmboxq
->vport
= vport
;
6635 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
6636 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
6637 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
6639 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
6641 if (rc
!= MBX_SUCCESS
) {
6642 if (rc
!= MBX_TIMEOUT
)
6643 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6647 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
6648 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
6649 pmb
->mbxOwner
= OWN_HOST
;
6650 pmboxq
->ctx_buf
= NULL
;
6651 pmboxq
->vport
= vport
;
6653 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
6654 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
6655 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
6657 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
6659 if (rc
!= MBX_SUCCESS
) {
6660 if (rc
!= MBX_TIMEOUT
)
6661 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
6665 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
6666 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
6667 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
6668 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
6669 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
6670 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
6671 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
6672 if (phba
->hba_flag
& HBA_FCOE_MODE
)
6673 lso
->link_events
= (phba
->link_events
>> 1);
6675 lso
->link_events
= (phba
->fc_eventTag
>> 1);
6677 psli
->stats_start
= ktime_get_seconds();
6679 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6685 * The LPFC driver treats linkdown handling as target loss events so there
6686 * are no sysfs handlers for link_down_tmo.
6690 * lpfc_get_node_by_target - Return the nodelist for a target
6691 * @starget: kernel scsi target pointer.
6694 * address of the node list if found
6695 * NULL target not found
6697 static struct lpfc_nodelist
*
6698 lpfc_get_node_by_target(struct scsi_target
*starget
)
6700 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
6701 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6702 struct lpfc_nodelist
*ndlp
;
6704 spin_lock_irq(shost
->host_lock
);
6705 /* Search for this, mapped, target ID */
6706 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
6707 if (NLP_CHK_NODE_ACT(ndlp
) &&
6708 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
6709 starget
->id
== ndlp
->nlp_sid
) {
6710 spin_unlock_irq(shost
->host_lock
);
6714 spin_unlock_irq(shost
->host_lock
);
6719 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
6720 * @starget: kernel scsi target pointer.
6723 lpfc_get_starget_port_id(struct scsi_target
*starget
)
6725 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6727 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
6731 * lpfc_get_starget_node_name - Set the target node name
6732 * @starget: kernel scsi target pointer.
6734 * Description: Set the target node name to the ndlp node name wwn or zero.
6737 lpfc_get_starget_node_name(struct scsi_target
*starget
)
6739 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6741 fc_starget_node_name(starget
) =
6742 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
6746 * lpfc_get_starget_port_name - Set the target port name
6747 * @starget: kernel scsi target pointer.
6749 * Description: set the target port name to the ndlp port name wwn or zero.
6752 lpfc_get_starget_port_name(struct scsi_target
*starget
)
6754 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6756 fc_starget_port_name(starget
) =
6757 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
6761 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
6762 * @rport: fc rport address.
6763 * @timeout: new value for dev loss tmo.
6766 * If timeout is non zero set the dev_loss_tmo to timeout, else set
6767 * dev_loss_tmo to one.
6770 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
6773 rport
->dev_loss_tmo
= timeout
;
6775 rport
->dev_loss_tmo
= 1;
6779 * lpfc_rport_show_function - Return rport target information
6782 * Macro that uses field to generate a function with the name lpfc_show_rport_
6784 * lpfc_show_rport_##field: returns the bytes formatted in buf
6785 * @cdev: class converted to an fc_rport.
6786 * @buf: on return contains the target_field or zero.
6788 * Returns: size of formatted string.
6790 #define lpfc_rport_show_function(field, format_string, sz, cast) \
6792 lpfc_show_rport_##field (struct device *dev, \
6793 struct device_attribute *attr, \
6796 struct fc_rport *rport = transport_class_to_rport(dev); \
6797 struct lpfc_rport_data *rdata = rport->hostdata; \
6798 return scnprintf(buf, sz, format_string, \
6799 (rdata->target) ? cast rdata->target->field : 0); \
6802 #define lpfc_rport_rd_attr(field, format_string, sz) \
6803 lpfc_rport_show_function(field, format_string, sz, ) \
6804 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
6807 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
6808 * @fc_vport: The fc_vport who's symbolic name has been changed.
6811 * This function is called by the transport after the @fc_vport's symbolic name
6812 * has been changed. This function re-registers the symbolic name with the
6813 * switch to propagate the change into the fabric if the vport is active.
6816 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
6818 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
6820 if (vport
->port_state
== LPFC_VPORT_READY
)
6821 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
6825 * lpfc_hba_log_verbose_init - Set hba's log verbose level
6826 * @phba: Pointer to lpfc_hba struct.
6828 * This function is called by the lpfc_get_cfgparam() routine to set the
6829 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
6830 * log message according to the module's lpfc_log_verbose parameter setting
6831 * before hba port or vport created.
6834 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
6836 phba
->cfg_log_verbose
= verbose
;
6839 struct fc_function_template lpfc_transport_functions
= {
6840 /* fixed attributes the driver supports */
6841 .show_host_node_name
= 1,
6842 .show_host_port_name
= 1,
6843 .show_host_supported_classes
= 1,
6844 .show_host_supported_fc4s
= 1,
6845 .show_host_supported_speeds
= 1,
6846 .show_host_maxframe_size
= 1,
6848 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6849 .show_host_symbolic_name
= 1,
6851 /* dynamic attributes the driver supports */
6852 .get_host_port_id
= lpfc_get_host_port_id
,
6853 .show_host_port_id
= 1,
6855 .get_host_port_type
= lpfc_get_host_port_type
,
6856 .show_host_port_type
= 1,
6858 .get_host_port_state
= lpfc_get_host_port_state
,
6859 .show_host_port_state
= 1,
6861 /* active_fc4s is shown but doesn't change (thus no get function) */
6862 .show_host_active_fc4s
= 1,
6864 .get_host_speed
= lpfc_get_host_speed
,
6865 .show_host_speed
= 1,
6867 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6868 .show_host_fabric_name
= 1,
6871 * The LPFC driver treats linkdown handling as target loss events
6872 * so there are no sysfs handlers for link_down_tmo.
6875 .get_fc_host_stats
= lpfc_get_stats
,
6876 .reset_fc_host_stats
= lpfc_reset_stats
,
6878 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6879 .show_rport_maxframe_size
= 1,
6880 .show_rport_supported_classes
= 1,
6882 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6883 .show_rport_dev_loss_tmo
= 1,
6885 .get_starget_port_id
= lpfc_get_starget_port_id
,
6886 .show_starget_port_id
= 1,
6888 .get_starget_node_name
= lpfc_get_starget_node_name
,
6889 .show_starget_node_name
= 1,
6891 .get_starget_port_name
= lpfc_get_starget_port_name
,
6892 .show_starget_port_name
= 1,
6894 .issue_fc_host_lip
= lpfc_issue_lip
,
6895 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6896 .terminate_rport_io
= lpfc_terminate_rport_io
,
6898 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
6900 .vport_disable
= lpfc_vport_disable
,
6902 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6904 .bsg_request
= lpfc_bsg_request
,
6905 .bsg_timeout
= lpfc_bsg_timeout
,
6908 struct fc_function_template lpfc_vport_transport_functions
= {
6909 /* fixed attributes the driver supports */
6910 .show_host_node_name
= 1,
6911 .show_host_port_name
= 1,
6912 .show_host_supported_classes
= 1,
6913 .show_host_supported_fc4s
= 1,
6914 .show_host_supported_speeds
= 1,
6915 .show_host_maxframe_size
= 1,
6917 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6918 .show_host_symbolic_name
= 1,
6920 /* dynamic attributes the driver supports */
6921 .get_host_port_id
= lpfc_get_host_port_id
,
6922 .show_host_port_id
= 1,
6924 .get_host_port_type
= lpfc_get_host_port_type
,
6925 .show_host_port_type
= 1,
6927 .get_host_port_state
= lpfc_get_host_port_state
,
6928 .show_host_port_state
= 1,
6930 /* active_fc4s is shown but doesn't change (thus no get function) */
6931 .show_host_active_fc4s
= 1,
6933 .get_host_speed
= lpfc_get_host_speed
,
6934 .show_host_speed
= 1,
6936 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6937 .show_host_fabric_name
= 1,
6940 * The LPFC driver treats linkdown handling as target loss events
6941 * so there are no sysfs handlers for link_down_tmo.
6944 .get_fc_host_stats
= lpfc_get_stats
,
6945 .reset_fc_host_stats
= lpfc_reset_stats
,
6947 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6948 .show_rport_maxframe_size
= 1,
6949 .show_rport_supported_classes
= 1,
6951 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6952 .show_rport_dev_loss_tmo
= 1,
6954 .get_starget_port_id
= lpfc_get_starget_port_id
,
6955 .show_starget_port_id
= 1,
6957 .get_starget_node_name
= lpfc_get_starget_node_name
,
6958 .show_starget_node_name
= 1,
6960 .get_starget_port_name
= lpfc_get_starget_port_name
,
6961 .show_starget_port_name
= 1,
6963 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6964 .terminate_rport_io
= lpfc_terminate_rport_io
,
6966 .vport_disable
= lpfc_vport_disable
,
6968 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6972 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
6973 * @phba: lpfc_hba pointer.
6976 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
6978 lpfc_fcp_io_sched_init(phba
, lpfc_fcp_io_sched
);
6979 lpfc_ns_query_init(phba
, lpfc_ns_query
);
6980 lpfc_fcp2_no_tgt_reset_init(phba
, lpfc_fcp2_no_tgt_reset
);
6981 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
6982 lpfc_cr_count_init(phba
, lpfc_cr_count
);
6983 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
6984 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
6985 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
6986 lpfc_ack0_init(phba
, lpfc_ack0
);
6987 lpfc_xri_rebalancing_init(phba
, lpfc_xri_rebalancing
);
6988 lpfc_topology_init(phba
, lpfc_topology
);
6989 lpfc_link_speed_init(phba
, lpfc_link_speed
);
6990 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
6991 lpfc_task_mgmt_tmo_init(phba
, lpfc_task_mgmt_tmo
);
6992 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
6993 lpfc_fcf_failover_policy_init(phba
, lpfc_fcf_failover_policy
);
6994 lpfc_enable_rrq_init(phba
, lpfc_enable_rrq
);
6995 lpfc_fdmi_on_init(phba
, lpfc_fdmi_on
);
6996 lpfc_enable_SmartSAN_init(phba
, lpfc_enable_SmartSAN
);
6997 lpfc_use_msi_init(phba
, lpfc_use_msi
);
6998 lpfc_nvme_oas_init(phba
, lpfc_nvme_oas
);
6999 lpfc_nvme_embed_cmd_init(phba
, lpfc_nvme_embed_cmd
);
7000 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
7001 lpfc_cq_poll_threshold_init(phba
, lpfc_cq_poll_threshold
);
7002 lpfc_cq_max_proc_limit_init(phba
, lpfc_cq_max_proc_limit
);
7003 lpfc_fcp_cpu_map_init(phba
, lpfc_fcp_cpu_map
);
7004 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
7005 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
7007 lpfc_EnableXLane_init(phba
, lpfc_EnableXLane
);
7008 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
7009 phba
->cfg_EnableXLane
= 0;
7010 lpfc_XLanePriority_init(phba
, lpfc_XLanePriority
);
7012 memset(phba
->cfg_oas_tgt_wwpn
, 0, (8 * sizeof(uint8_t)));
7013 memset(phba
->cfg_oas_vpt_wwpn
, 0, (8 * sizeof(uint8_t)));
7014 phba
->cfg_oas_lun_state
= 0;
7015 phba
->cfg_oas_lun_status
= 0;
7016 phba
->cfg_oas_flags
= 0;
7017 phba
->cfg_oas_priority
= 0;
7018 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
7019 lpfc_prot_mask_init(phba
, lpfc_prot_mask
);
7020 lpfc_prot_guard_init(phba
, lpfc_prot_guard
);
7021 if (phba
->sli_rev
== LPFC_SLI_REV4
)
7024 phba
->cfg_poll
= lpfc_poll
;
7026 if (phba
->cfg_enable_bg
)
7027 phba
->sli3_options
|= LPFC_SLI3_BG_ENABLED
;
7029 lpfc_suppress_rsp_init(phba
, lpfc_suppress_rsp
);
7031 lpfc_enable_fc4_type_init(phba
, lpfc_enable_fc4_type
);
7032 lpfc_nvmet_mrq_init(phba
, lpfc_nvmet_mrq
);
7033 lpfc_nvmet_mrq_post_init(phba
, lpfc_nvmet_mrq_post
);
7035 /* Initialize first burst. Target vs Initiator are different. */
7036 lpfc_nvme_enable_fb_init(phba
, lpfc_nvme_enable_fb
);
7037 lpfc_nvmet_fb_size_init(phba
, lpfc_nvmet_fb_size
);
7038 lpfc_hdw_queue_init(phba
, lpfc_hdw_queue
);
7039 lpfc_irq_chann_init(phba
, lpfc_irq_chann
);
7040 lpfc_enable_bbcr_init(phba
, lpfc_enable_bbcr
);
7041 lpfc_enable_dpp_init(phba
, lpfc_enable_dpp
);
7043 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
7044 /* NVME only supported on SLI4 */
7045 phba
->nvmet_support
= 0;
7046 phba
->cfg_nvmet_mrq
= 0;
7047 phba
->cfg_enable_fc4_type
= LPFC_ENABLE_FCP
;
7048 phba
->cfg_enable_bbcr
= 0;
7049 phba
->cfg_xri_rebalancing
= 0;
7051 /* We MUST have FCP support */
7052 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_FCP
))
7053 phba
->cfg_enable_fc4_type
|= LPFC_ENABLE_FCP
;
7056 phba
->cfg_auto_imax
= (phba
->cfg_fcp_imax
) ? 0 : 1;
7058 phba
->cfg_enable_pbde
= 0;
7060 /* A value of 0 means use the number of CPUs found in the system */
7061 if (phba
->cfg_hdw_queue
== 0)
7062 phba
->cfg_hdw_queue
= phba
->sli4_hba
.num_present_cpu
;
7063 if (phba
->cfg_irq_chann
== 0)
7064 phba
->cfg_irq_chann
= phba
->sli4_hba
.num_present_cpu
;
7065 if (phba
->cfg_irq_chann
> phba
->cfg_hdw_queue
)
7066 phba
->cfg_irq_chann
= phba
->cfg_hdw_queue
;
7068 phba
->cfg_soft_wwnn
= 0L;
7069 phba
->cfg_soft_wwpn
= 0L;
7070 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
7071 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
7072 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
7073 lpfc_aer_support_init(phba
, lpfc_aer_support
);
7074 lpfc_sriov_nr_virtfn_init(phba
, lpfc_sriov_nr_virtfn
);
7075 lpfc_request_firmware_upgrade_init(phba
, lpfc_req_fw_upgrade
);
7076 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
7077 lpfc_iocb_cnt_init(phba
, lpfc_iocb_cnt
);
7078 lpfc_delay_discovery_init(phba
, lpfc_delay_discovery
);
7079 lpfc_sli_mode_init(phba
, lpfc_sli_mode
);
7080 phba
->cfg_enable_dss
= 1;
7081 lpfc_enable_mds_diags_init(phba
, lpfc_enable_mds_diags
);
7082 lpfc_ras_fwlog_buffsize_init(phba
, lpfc_ras_fwlog_buffsize
);
7083 lpfc_ras_fwlog_level_init(phba
, lpfc_ras_fwlog_level
);
7084 lpfc_ras_fwlog_func_init(phba
, lpfc_ras_fwlog_func
);
7087 /* If the NVME FC4 type is enabled, scale the sg_seg_cnt to
7088 * accommodate 512K and 1M IOs in a single nvme buf and supply
7089 * enough NVME LS iocb buffers for larger connectivity counts.
7091 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
) {
7092 phba
->cfg_sg_seg_cnt
= LPFC_MAX_NVME_SEG_CNT
;
7093 phba
->cfg_iocb_cnt
= 5;
7100 * lpfc_nvme_mod_param_dep - Adjust module parameter value based on
7101 * dependencies between protocols and roles.
7102 * @phba: lpfc_hba pointer.
7105 lpfc_nvme_mod_param_dep(struct lpfc_hba
*phba
)
7107 if (phba
->cfg_hdw_queue
> phba
->sli4_hba
.num_present_cpu
)
7108 phba
->cfg_hdw_queue
= phba
->sli4_hba
.num_present_cpu
;
7109 if (phba
->cfg_irq_chann
> phba
->sli4_hba
.num_present_cpu
)
7110 phba
->cfg_irq_chann
= phba
->sli4_hba
.num_present_cpu
;
7111 if (phba
->cfg_irq_chann
> phba
->cfg_hdw_queue
)
7112 phba
->cfg_irq_chann
= phba
->cfg_hdw_queue
;
7114 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
&&
7115 phba
->nvmet_support
) {
7116 phba
->cfg_enable_fc4_type
&= ~LPFC_ENABLE_FCP
;
7118 lpfc_printf_log(phba
, KERN_INFO
, LOG_NVME_DISC
,
7119 "6013 %s x%x fb_size x%x, fb_max x%x\n",
7120 "NVME Target PRLI ACC enable_fb ",
7121 phba
->cfg_nvme_enable_fb
,
7122 phba
->cfg_nvmet_fb_size
,
7123 LPFC_NVMET_FB_SZ_MAX
);
7125 if (phba
->cfg_nvme_enable_fb
== 0)
7126 phba
->cfg_nvmet_fb_size
= 0;
7128 if (phba
->cfg_nvmet_fb_size
> LPFC_NVMET_FB_SZ_MAX
)
7129 phba
->cfg_nvmet_fb_size
= LPFC_NVMET_FB_SZ_MAX
;
7132 if (!phba
->cfg_nvmet_mrq
)
7133 phba
->cfg_nvmet_mrq
= phba
->cfg_irq_chann
;
7135 /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */
7136 if (phba
->cfg_nvmet_mrq
> phba
->cfg_irq_chann
) {
7137 phba
->cfg_nvmet_mrq
= phba
->cfg_irq_chann
;
7138 lpfc_printf_log(phba
, KERN_ERR
, LOG_NVME_DISC
,
7139 "6018 Adjust lpfc_nvmet_mrq to %d\n",
7140 phba
->cfg_nvmet_mrq
);
7142 if (phba
->cfg_nvmet_mrq
> LPFC_NVMET_MRQ_MAX
)
7143 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_MAX
;
7146 /* Not NVME Target mode. Turn off Target parameters. */
7147 phba
->nvmet_support
= 0;
7148 phba
->cfg_nvmet_mrq
= 0;
7149 phba
->cfg_nvmet_fb_size
= 0;
7154 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
7155 * @vport: lpfc_vport pointer.
7158 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
7160 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
7161 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
7162 lpfc_tgt_queue_depth_init(vport
, lpfc_tgt_queue_depth
);
7163 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
7164 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
7165 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
7166 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
7167 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
7168 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
7169 lpfc_first_burst_size_init(vport
, lpfc_first_burst_size
);
7170 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
7171 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
7172 lpfc_max_luns_init(vport
, lpfc_max_luns
);
7173 lpfc_scan_down_init(vport
, lpfc_scan_down
);
7174 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);