1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Limited 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"
75 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
76 * @incr: integer to convert.
77 * @hdw: ascii string holding converted integer plus a string terminator.
80 * JEDEC Joint Electron Device Engineering Council.
81 * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii
82 * character string. The string is then terminated with a NULL in byte 9.
83 * Hex 0-9 becomes ascii '0' to '9'.
84 * Hex a-f becomes ascii '=' to 'B' capital B.
87 * Coded for 32 bit integers only.
90 lpfc_jedec_to_ascii(int incr
, char hdw
[])
93 for (i
= 0; i
< 8; i
++) {
96 hdw
[7 - i
] = 0x30 + j
;
98 hdw
[7 - i
] = 0x61 + j
- 10;
106 * lpfc_drvr_version_show - Return the Emulex driver string with version number
107 * @dev: class unused variable.
108 * @attr: device attribute, not used.
109 * @buf: on return contains the module description text.
111 * Returns: size of formatted string.
114 lpfc_drvr_version_show(struct device
*dev
, struct device_attribute
*attr
,
117 return snprintf(buf
, PAGE_SIZE
, LPFC_MODULE_DESC
"\n");
121 * lpfc_enable_fip_show - Return the fip mode of the HBA
122 * @dev: class unused variable.
123 * @attr: device attribute, not used.
124 * @buf: on return contains the module description text.
126 * Returns: size of formatted string.
129 lpfc_enable_fip_show(struct device
*dev
, struct device_attribute
*attr
,
132 struct Scsi_Host
*shost
= class_to_shost(dev
);
133 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
134 struct lpfc_hba
*phba
= vport
->phba
;
136 if (phba
->hba_flag
& HBA_FIP_SUPPORT
)
137 return snprintf(buf
, PAGE_SIZE
, "1\n");
139 return snprintf(buf
, PAGE_SIZE
, "0\n");
143 lpfc_nvme_info_show(struct device
*dev
, struct device_attribute
*attr
,
146 struct Scsi_Host
*shost
= class_to_shost(dev
);
147 struct lpfc_vport
*vport
= shost_priv(shost
);
148 struct lpfc_hba
*phba
= vport
->phba
;
149 struct lpfc_nvmet_tgtport
*tgtp
;
150 struct nvme_fc_local_port
*localport
;
151 struct lpfc_nvme_lport
*lport
;
152 struct lpfc_nodelist
*ndlp
;
153 struct nvme_fc_remote_port
*nrport
;
154 uint64_t data1
, data2
, data3
, tot
;
158 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
)) {
159 len
+= snprintf(buf
, PAGE_SIZE
, "NVME Disabled\n");
162 if (phba
->nvmet_support
) {
163 if (!phba
->targetport
) {
164 len
= snprintf(buf
, PAGE_SIZE
,
165 "NVME Target: x%llx is not allocated\n",
166 wwn_to_u64(vport
->fc_portname
.u
.wwn
));
169 /* Port state is only one of two values for now. */
170 if (phba
->targetport
->port_id
)
171 statep
= "REGISTERED";
174 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
175 "NVME Target Enabled State %s\n",
177 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
178 "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
181 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
182 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
183 phba
->targetport
->port_id
);
185 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
186 "\nNVME Target: Statistics\n");
187 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
188 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
189 "LS: Rcv %08x Drop %08x Abort %08x\n",
190 atomic_read(&tgtp
->rcv_ls_req_in
),
191 atomic_read(&tgtp
->rcv_ls_req_drop
),
192 atomic_read(&tgtp
->xmt_ls_abort
));
193 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
194 atomic_read(&tgtp
->rcv_ls_req_out
)) {
195 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
196 "Rcv LS: in %08x != out %08x\n",
197 atomic_read(&tgtp
->rcv_ls_req_in
),
198 atomic_read(&tgtp
->rcv_ls_req_out
));
201 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
202 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
203 atomic_read(&tgtp
->xmt_ls_rsp
),
204 atomic_read(&tgtp
->xmt_ls_drop
),
205 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
));
207 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
208 "LS: RSP Abort %08x xb %08x Err %08x\n",
209 atomic_read(&tgtp
->xmt_ls_rsp_aborted
),
210 atomic_read(&tgtp
->xmt_ls_rsp_xb_set
),
211 atomic_read(&tgtp
->xmt_ls_rsp_error
));
213 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
214 "FCP: Rcv %08x Defer %08x Release %08x "
216 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
217 atomic_read(&tgtp
->rcv_fcp_cmd_defer
),
218 atomic_read(&tgtp
->xmt_fcp_release
),
219 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
221 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
222 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
223 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
224 "Rcv FCP: in %08x != out %08x\n",
225 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
226 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
229 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
230 "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x "
232 atomic_read(&tgtp
->xmt_fcp_read
),
233 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
234 atomic_read(&tgtp
->xmt_fcp_write
),
235 atomic_read(&tgtp
->xmt_fcp_rsp
),
236 atomic_read(&tgtp
->xmt_fcp_drop
));
238 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
239 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
240 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
241 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
242 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
244 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
245 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
246 atomic_read(&tgtp
->xmt_fcp_rsp_aborted
),
247 atomic_read(&tgtp
->xmt_fcp_rsp_xb_set
),
248 atomic_read(&tgtp
->xmt_fcp_xri_abort_cqe
));
250 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
251 "ABORT: Xmt %08x Cmpl %08x\n",
252 atomic_read(&tgtp
->xmt_fcp_abort
),
253 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
255 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
256 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
257 atomic_read(&tgtp
->xmt_abort_sol
),
258 atomic_read(&tgtp
->xmt_abort_unsol
),
259 atomic_read(&tgtp
->xmt_abort_rsp
),
260 atomic_read(&tgtp
->xmt_abort_rsp_error
));
262 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
263 "DELAY: ctx %08x fod %08x wqfull %08x\n",
264 atomic_read(&tgtp
->defer_ctx
),
265 atomic_read(&tgtp
->defer_fod
),
266 atomic_read(&tgtp
->defer_wqfull
));
268 /* Calculate outstanding IOs */
269 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_drop
);
270 tot
+= atomic_read(&tgtp
->xmt_fcp_release
);
271 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_in
) - tot
;
273 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
274 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
275 "CTX Outstanding %08llx\n",
276 phba
->sli4_hba
.nvmet_xri_cnt
,
277 phba
->sli4_hba
.nvmet_io_wait_cnt
,
278 phba
->sli4_hba
.nvmet_io_wait_total
,
281 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
, "\n");
285 localport
= vport
->localport
;
287 len
= snprintf(buf
, PAGE_SIZE
,
288 "NVME Initiator x%llx is not allocated\n",
289 wwn_to_u64(vport
->fc_portname
.u
.wwn
));
292 lport
= (struct lpfc_nvme_lport
*)localport
->private;
293 len
= snprintf(buf
, PAGE_SIZE
, "NVME Initiator Enabled\n");
295 spin_lock_irq(shost
->host_lock
);
297 /* Port state is only one of two values for now. */
298 if (localport
->port_id
)
303 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
304 "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
307 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
308 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
309 localport
->port_id
, statep
);
311 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
315 /* local short-hand pointer. */
316 nrport
= ndlp
->nrport
->remoteport
;
318 /* Port state is only one of two values for now. */
319 switch (nrport
->port_state
) {
320 case FC_OBJSTATE_ONLINE
:
323 case FC_OBJSTATE_UNKNOWN
:
327 statep
= "UNSUPPORTED";
331 /* Tab in to show lport ownership. */
332 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
334 if (phba
->brd_no
>= 10)
335 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, " ");
337 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "WWPN x%llx ",
339 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "WWNN x%llx ",
341 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "DID x%06x ",
344 /* An NVME rport can have multiple roles. */
345 if (nrport
->port_role
& FC_PORT_ROLE_NVME_INITIATOR
)
346 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
348 if (nrport
->port_role
& FC_PORT_ROLE_NVME_TARGET
)
349 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
351 if (nrport
->port_role
& FC_PORT_ROLE_NVME_DISCOVERY
)
352 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
354 if (nrport
->port_role
& ~(FC_PORT_ROLE_NVME_INITIATOR
|
355 FC_PORT_ROLE_NVME_TARGET
|
356 FC_PORT_ROLE_NVME_DISCOVERY
))
357 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
361 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "%s ", statep
);
362 /* Terminate the string. */
363 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "\n");
365 spin_unlock_irq(shost
->host_lock
);
367 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "\nNVME Statistics\n");
368 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
369 "LS: Xmt %010x Cmpl %010x Abort %08x\n",
370 atomic_read(&phba
->fc4NvmeLsRequests
),
371 atomic_read(&phba
->fc4NvmeLsCmpls
),
372 atomic_read(&lport
->xmt_ls_abort
));
374 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
375 "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n",
376 atomic_read(&lport
->xmt_ls_err
),
377 atomic_read(&lport
->cmpl_ls_xb
),
378 atomic_read(&lport
->cmpl_ls_err
));
380 tot
= atomic_read(&phba
->fc4NvmeIoCmpls
);
381 data1
= atomic_read(&phba
->fc4NvmeInputRequests
);
382 data2
= atomic_read(&phba
->fc4NvmeOutputRequests
);
383 data3
= atomic_read(&phba
->fc4NvmeControlRequests
);
384 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
385 "FCP: Rd %016llx Wr %016llx IO %016llx\n",
386 data1
, data2
, data3
);
388 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
389 " noxri %08x nondlp %08x qdepth %08x "
391 atomic_read(&lport
->xmt_fcp_noxri
),
392 atomic_read(&lport
->xmt_fcp_bad_ndlp
),
393 atomic_read(&lport
->xmt_fcp_qdepth
),
394 atomic_read(&lport
->xmt_fcp_wqerr
));
396 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
397 " Cmpl %016llx Outstanding %016llx Abort %08x\n",
398 tot
, ((data1
+ data2
+ data3
) - tot
),
399 atomic_read(&lport
->xmt_fcp_abort
));
401 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
402 "FCP CMPL: xb %08x Err %08x\n",
403 atomic_read(&lport
->cmpl_fcp_xb
),
404 atomic_read(&lport
->cmpl_fcp_err
));
409 lpfc_bg_info_show(struct device
*dev
, struct device_attribute
*attr
,
412 struct Scsi_Host
*shost
= class_to_shost(dev
);
413 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
414 struct lpfc_hba
*phba
= vport
->phba
;
416 if (phba
->cfg_enable_bg
)
417 if (phba
->sli3_options
& LPFC_SLI3_BG_ENABLED
)
418 return snprintf(buf
, PAGE_SIZE
, "BlockGuard Enabled\n");
420 return snprintf(buf
, PAGE_SIZE
,
421 "BlockGuard Not Supported\n");
423 return snprintf(buf
, PAGE_SIZE
,
424 "BlockGuard Disabled\n");
428 lpfc_bg_guard_err_show(struct device
*dev
, struct device_attribute
*attr
,
431 struct Scsi_Host
*shost
= class_to_shost(dev
);
432 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
433 struct lpfc_hba
*phba
= vport
->phba
;
435 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
436 (unsigned long long)phba
->bg_guard_err_cnt
);
440 lpfc_bg_apptag_err_show(struct device
*dev
, struct device_attribute
*attr
,
443 struct Scsi_Host
*shost
= class_to_shost(dev
);
444 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
445 struct lpfc_hba
*phba
= vport
->phba
;
447 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
448 (unsigned long long)phba
->bg_apptag_err_cnt
);
452 lpfc_bg_reftag_err_show(struct device
*dev
, struct device_attribute
*attr
,
455 struct Scsi_Host
*shost
= class_to_shost(dev
);
456 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
457 struct lpfc_hba
*phba
= vport
->phba
;
459 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
460 (unsigned long long)phba
->bg_reftag_err_cnt
);
464 * lpfc_info_show - Return some pci info about the host in ascii
465 * @dev: class converted to a Scsi_host structure.
466 * @attr: device attribute, not used.
467 * @buf: on return contains the formatted text from lpfc_info().
469 * Returns: size of formatted string.
472 lpfc_info_show(struct device
*dev
, struct device_attribute
*attr
,
475 struct Scsi_Host
*host
= class_to_shost(dev
);
477 return snprintf(buf
, PAGE_SIZE
, "%s\n",lpfc_info(host
));
481 * lpfc_serialnum_show - Return the hba serial number in ascii
482 * @dev: class converted to a Scsi_host structure.
483 * @attr: device attribute, not used.
484 * @buf: on return contains the formatted text serial number.
486 * Returns: size of formatted string.
489 lpfc_serialnum_show(struct device
*dev
, struct device_attribute
*attr
,
492 struct Scsi_Host
*shost
= class_to_shost(dev
);
493 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
494 struct lpfc_hba
*phba
= vport
->phba
;
496 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->SerialNumber
);
500 * lpfc_temp_sensor_show - Return the temperature sensor level
501 * @dev: class converted to a Scsi_host structure.
502 * @attr: device attribute, not used.
503 * @buf: on return contains the formatted support level.
506 * Returns a number indicating the temperature sensor level currently
507 * supported, zero or one in ascii.
509 * Returns: size of formatted string.
512 lpfc_temp_sensor_show(struct device
*dev
, struct device_attribute
*attr
,
515 struct Scsi_Host
*shost
= class_to_shost(dev
);
516 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
517 struct lpfc_hba
*phba
= vport
->phba
;
518 return snprintf(buf
, PAGE_SIZE
, "%d\n",phba
->temp_sensor_support
);
522 * lpfc_modeldesc_show - Return the model description of the hba
523 * @dev: class converted to a Scsi_host structure.
524 * @attr: device attribute, not used.
525 * @buf: on return contains the scsi vpd model description.
527 * Returns: size of formatted string.
530 lpfc_modeldesc_show(struct device
*dev
, struct device_attribute
*attr
,
533 struct Scsi_Host
*shost
= class_to_shost(dev
);
534 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
535 struct lpfc_hba
*phba
= vport
->phba
;
537 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelDesc
);
541 * lpfc_modelname_show - Return the model name of the hba
542 * @dev: class converted to a Scsi_host structure.
543 * @attr: device attribute, not used.
544 * @buf: on return contains the scsi vpd model name.
546 * Returns: size of formatted string.
549 lpfc_modelname_show(struct device
*dev
, struct device_attribute
*attr
,
552 struct Scsi_Host
*shost
= class_to_shost(dev
);
553 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
554 struct lpfc_hba
*phba
= vport
->phba
;
556 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelName
);
560 * lpfc_programtype_show - Return the program type of the hba
561 * @dev: class converted to a Scsi_host structure.
562 * @attr: device attribute, not used.
563 * @buf: on return contains the scsi vpd program type.
565 * Returns: size of formatted string.
568 lpfc_programtype_show(struct device
*dev
, struct device_attribute
*attr
,
571 struct Scsi_Host
*shost
= class_to_shost(dev
);
572 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
573 struct lpfc_hba
*phba
= vport
->phba
;
575 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ProgramType
);
579 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
580 * @dev: class converted to a Scsi_host structure.
581 * @attr: device attribute, not used.
582 * @buf: on return contains the Menlo Maintenance sli flag.
584 * Returns: size of formatted string.
587 lpfc_mlomgmt_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
589 struct Scsi_Host
*shost
= class_to_shost(dev
);
590 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
591 struct lpfc_hba
*phba
= vport
->phba
;
593 return snprintf(buf
, PAGE_SIZE
, "%d\n",
594 (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
));
598 * lpfc_vportnum_show - Return the port number in ascii of the hba
599 * @dev: class converted to a Scsi_host structure.
600 * @attr: device attribute, not used.
601 * @buf: on return contains scsi vpd program type.
603 * Returns: size of formatted string.
606 lpfc_vportnum_show(struct device
*dev
, struct device_attribute
*attr
,
609 struct Scsi_Host
*shost
= class_to_shost(dev
);
610 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
611 struct lpfc_hba
*phba
= vport
->phba
;
613 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->Port
);
617 * lpfc_fwrev_show - Return the firmware rev running in the hba
618 * @dev: class converted to a Scsi_host structure.
619 * @attr: device attribute, not used.
620 * @buf: on return contains the scsi vpd program type.
622 * Returns: size of formatted string.
625 lpfc_fwrev_show(struct device
*dev
, struct device_attribute
*attr
,
628 struct Scsi_Host
*shost
= class_to_shost(dev
);
629 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
630 struct lpfc_hba
*phba
= vport
->phba
;
633 char fwrev
[FW_REV_STR_SIZE
];
636 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
637 if_type
= phba
->sli4_hba
.pc_sli4_params
.if_type
;
638 sli_family
= phba
->sli4_hba
.pc_sli4_params
.sli_family
;
640 if (phba
->sli_rev
< LPFC_SLI_REV4
)
641 len
= snprintf(buf
, PAGE_SIZE
, "%s, sli-%d\n",
642 fwrev
, phba
->sli_rev
);
644 len
= snprintf(buf
, PAGE_SIZE
, "%s, sli-%d:%d:%x\n",
645 fwrev
, phba
->sli_rev
, if_type
, sli_family
);
651 * lpfc_hdw_show - Return the jedec information about the hba
652 * @dev: class converted to a Scsi_host structure.
653 * @attr: device attribute, not used.
654 * @buf: on return contains the scsi vpd program type.
656 * Returns: size of formatted string.
659 lpfc_hdw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
662 struct Scsi_Host
*shost
= class_to_shost(dev
);
663 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
664 struct lpfc_hba
*phba
= vport
->phba
;
665 lpfc_vpd_t
*vp
= &phba
->vpd
;
667 lpfc_jedec_to_ascii(vp
->rev
.biuRev
, hdw
);
668 return snprintf(buf
, PAGE_SIZE
, "%s\n", hdw
);
672 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
673 * @dev: class converted to a Scsi_host structure.
674 * @attr: device attribute, not used.
675 * @buf: on return contains the ROM and FCode ascii strings.
677 * Returns: size of formatted string.
680 lpfc_option_rom_version_show(struct device
*dev
, struct device_attribute
*attr
,
683 struct Scsi_Host
*shost
= class_to_shost(dev
);
684 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
685 struct lpfc_hba
*phba
= vport
->phba
;
686 char fwrev
[FW_REV_STR_SIZE
];
688 if (phba
->sli_rev
< LPFC_SLI_REV4
)
689 return snprintf(buf
, PAGE_SIZE
, "%s\n", phba
->OptionROMVersion
);
691 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
692 return snprintf(buf
, PAGE_SIZE
, "%s\n", fwrev
);
696 * lpfc_state_show - Return the link state of the port
697 * @dev: class converted to a Scsi_host structure.
698 * @attr: device attribute, not used.
699 * @buf: on return contains text describing the state of the link.
702 * The switch statement has no default so zero will be returned.
704 * Returns: size of formatted string.
707 lpfc_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
710 struct Scsi_Host
*shost
= class_to_shost(dev
);
711 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
712 struct lpfc_hba
*phba
= vport
->phba
;
715 switch (phba
->link_state
) {
716 case LPFC_LINK_UNKNOWN
:
717 case LPFC_WARM_START
:
718 case LPFC_INIT_START
:
719 case LPFC_INIT_MBX_CMDS
:
722 if (phba
->hba_flag
& LINK_DISABLED
)
723 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
724 "Link Down - User disabled\n");
726 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
732 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Link Up - ");
734 switch (vport
->port_state
) {
735 case LPFC_LOCAL_CFG_LINK
:
736 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
737 "Configuring Link\n");
741 case LPFC_FABRIC_CFG_LINK
:
744 case LPFC_BUILD_DISC_LIST
:
746 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
749 case LPFC_VPORT_READY
:
750 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Ready\n");
753 case LPFC_VPORT_FAILED
:
754 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Failed\n");
757 case LPFC_VPORT_UNKNOWN
:
758 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
762 if (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
)
763 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
764 " Menlo Maint Mode\n");
765 else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
766 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
767 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
770 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
773 if (vport
->fc_flag
& FC_FABRIC
)
774 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
777 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
786 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
787 * @dev: class unused variable.
788 * @attr: device attribute, not used.
789 * @buf: on return contains the module description text.
791 * Returns: size of formatted string.
794 lpfc_sli4_protocol_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
;
801 if (phba
->sli_rev
< LPFC_SLI_REV4
)
802 return snprintf(buf
, PAGE_SIZE
, "fc\n");
804 if (phba
->sli4_hba
.lnk_info
.lnk_dv
== LPFC_LNK_DAT_VAL
) {
805 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_GE
)
806 return snprintf(buf
, PAGE_SIZE
, "fcoe\n");
807 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_FC
)
808 return snprintf(buf
, PAGE_SIZE
, "fc\n");
810 return snprintf(buf
, PAGE_SIZE
, "unknown\n");
814 * lpfc_oas_supported_show - Return whether or not Optimized Access Storage
815 * (OAS) is supported.
816 * @dev: class unused variable.
817 * @attr: device attribute, not used.
818 * @buf: on return contains the module description text.
820 * Returns: size of formatted string.
823 lpfc_oas_supported_show(struct device
*dev
, struct device_attribute
*attr
,
826 struct Scsi_Host
*shost
= class_to_shost(dev
);
827 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
828 struct lpfc_hba
*phba
= vport
->phba
;
830 return snprintf(buf
, PAGE_SIZE
, "%d\n",
831 phba
->sli4_hba
.pc_sli4_params
.oas_supported
);
835 * lpfc_link_state_store - Transition the link_state on an HBA port
836 * @dev: class device that is converted into a Scsi_host.
837 * @attr: device attribute, not used.
838 * @buf: one or more lpfc_polling_flags values.
842 * -EINVAL if the buffer is not "up" or "down"
843 * return from link state change function if non-zero
844 * length of the buf on success
847 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
848 const char *buf
, size_t count
)
850 struct Scsi_Host
*shost
= class_to_shost(dev
);
851 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
852 struct lpfc_hba
*phba
= vport
->phba
;
854 int status
= -EINVAL
;
856 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
857 (phba
->link_state
== LPFC_LINK_DOWN
))
858 status
= phba
->lpfc_hba_init_link(phba
, MBX_NOWAIT
);
859 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
860 (phba
->link_state
>= LPFC_LINK_UP
))
861 status
= phba
->lpfc_hba_down_link(phba
, MBX_NOWAIT
);
870 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
871 * @dev: class device that is converted into a Scsi_host.
872 * @attr: device attribute, not used.
873 * @buf: on return contains the sum of fc mapped and unmapped.
876 * Returns the ascii text number of the sum of the fc mapped and unmapped
879 * Returns: size of formatted string.
882 lpfc_num_discovered_ports_show(struct device
*dev
,
883 struct device_attribute
*attr
, char *buf
)
885 struct Scsi_Host
*shost
= class_to_shost(dev
);
886 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
888 return snprintf(buf
, PAGE_SIZE
, "%d\n",
889 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
893 * lpfc_issue_lip - Misnomer, name carried over from long ago
894 * @shost: Scsi_Host pointer.
897 * Bring the link down gracefully then re-init the link. The firmware will
898 * re-init the fiber channel interface as required. Does not issue a LIP.
901 * -EPERM port offline or management commands are being blocked
902 * -ENOMEM cannot allocate memory for the mailbox command
903 * -EIO error sending the mailbox command
907 lpfc_issue_lip(struct Scsi_Host
*shost
)
909 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
910 struct lpfc_hba
*phba
= vport
->phba
;
911 LPFC_MBOXQ_t
*pmboxq
;
912 int mbxstatus
= MBXERR_ERROR
;
915 * If the link is offline, disabled or BLOCK_MGMT_IO
916 * it doesn't make any sense to allow issue_lip
918 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
919 (phba
->hba_flag
& LINK_DISABLED
) ||
920 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
923 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
928 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
929 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
930 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
932 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
934 if ((mbxstatus
== MBX_SUCCESS
) &&
935 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
936 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
937 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
938 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
939 phba
->cfg_link_speed
);
940 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
942 if ((mbxstatus
== MBX_SUCCESS
) &&
943 (pmboxq
->u
.mb
.mbxStatus
== MBXERR_SEC_NO_PERMISSION
))
944 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
| LOG_SLI
,
945 "2859 SLI authentication is required "
946 "for INIT_LINK but has not done yet\n");
949 lpfc_set_loopback_flag(phba
);
950 if (mbxstatus
!= MBX_TIMEOUT
)
951 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
953 if (mbxstatus
== MBXERR_ERROR
)
960 lpfc_emptyq_wait(struct lpfc_hba
*phba
, struct list_head
*q
, spinlock_t
*lock
)
965 while (!list_empty(q
)) {
966 spin_unlock_irq(lock
);
968 if (cnt
++ > 250) { /* 5 secs */
969 lpfc_printf_log(phba
, KERN_WARNING
, LOG_INIT
,
971 "Outstanding IO when ",
972 "bringing Adapter offline\n");
977 spin_unlock_irq(lock
);
982 * lpfc_do_offline - Issues a mailbox command to bring the link down
983 * @phba: lpfc_hba pointer.
984 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
987 * Assumes any error from lpfc_do_offline() will be negative.
988 * Can wait up to 5 seconds for the port ring buffers count
989 * to reach zero, prints a warning if it is not zero and continues.
990 * lpfc_workq_post_event() returns a non-zero return code if call fails.
993 * -EIO error posting the event
997 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
999 struct completion online_compl
;
1000 struct lpfc_queue
*qp
= NULL
;
1001 struct lpfc_sli_ring
*pring
;
1002 struct lpfc_sli
*psli
;
1007 init_completion(&online_compl
);
1008 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1009 LPFC_EVT_OFFLINE_PREP
);
1013 wait_for_completion(&online_compl
);
1020 /* Wait a little for things to settle down, but not
1021 * long enough for dev loss timeout to expire.
1023 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
1024 for (i
= 0; i
< psli
->num_rings
; i
++) {
1025 pring
= &psli
->sli3_ring
[i
];
1026 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1031 list_for_each_entry(qp
, &phba
->sli4_hba
.lpfc_wq_list
, wq_list
) {
1035 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1041 init_completion(&online_compl
);
1042 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
1046 wait_for_completion(&online_compl
);
1055 * lpfc_selective_reset - Offline then onlines the port
1056 * @phba: lpfc_hba pointer.
1059 * If the port is configured to allow a reset then the hba is brought
1060 * offline then online.
1063 * Assumes any error from lpfc_do_offline() will be negative.
1064 * Do not make this function static.
1067 * lpfc_do_offline() return code if not zero
1068 * -EIO reset not configured or error posting the event
1072 lpfc_selective_reset(struct lpfc_hba
*phba
)
1074 struct completion online_compl
;
1078 if (!phba
->cfg_enable_hba_reset
)
1081 if (!(phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
1082 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1088 init_completion(&online_compl
);
1089 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1094 wait_for_completion(&online_compl
);
1103 * lpfc_issue_reset - Selectively resets an adapter
1104 * @dev: class device that is converted into a Scsi_host.
1105 * @attr: device attribute, not used.
1106 * @buf: containing the string "selective".
1107 * @count: unused variable.
1110 * If the buf contains the string "selective" then lpfc_selective_reset()
1111 * is called to perform the reset.
1114 * Assumes any error from lpfc_selective_reset() will be negative.
1115 * If lpfc_selective_reset() returns zero then the length of the buffer
1116 * is returned which indicates success
1119 * -EINVAL if the buffer does not contain the string "selective"
1120 * length of buf if lpfc-selective_reset() if the call succeeds
1121 * return value of lpfc_selective_reset() if the call fails
1124 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
1125 const char *buf
, size_t count
)
1127 struct Scsi_Host
*shost
= class_to_shost(dev
);
1128 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1129 struct lpfc_hba
*phba
= vport
->phba
;
1130 int status
= -EINVAL
;
1132 if (!phba
->cfg_enable_hba_reset
)
1135 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
1136 status
= phba
->lpfc_selective_reset(phba
);
1145 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
1146 * @phba: lpfc_hba pointer.
1149 * SLI4 interface type-2 device to wait on the sliport status register for
1150 * the readyness after performing a firmware reset.
1153 * zero for success, -EPERM when port does not have privilege to perform the
1154 * reset, -EIO when port timeout from recovering from the reset.
1157 * As the caller will interpret the return code by value, be careful in making
1158 * change or addition to return codes.
1161 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba
*phba
)
1163 struct lpfc_register portstat_reg
= {0};
1167 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1168 &portstat_reg
.word0
);
1170 /* verify if privileged for the request operation */
1171 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
) &&
1172 !bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1175 /* wait for the SLI port firmware ready after firmware reset */
1176 for (i
= 0; i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
; i
++) {
1178 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1179 &portstat_reg
.word0
);
1180 if (!bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1182 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
))
1184 if (!bf_get(lpfc_sliport_status_rdy
, &portstat_reg
))
1189 if (i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
)
1196 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
1197 * @phba: lpfc_hba pointer.
1200 * Request SLI4 interface type-2 device to perform a physical register set
1207 lpfc_sli4_pdev_reg_request(struct lpfc_hba
*phba
, uint32_t opcode
)
1209 struct completion online_compl
;
1210 struct pci_dev
*pdev
= phba
->pcidev
;
1211 uint32_t before_fc_flag
;
1212 uint32_t sriov_nr_virtfn
;
1214 int status
= 0, rc
= 0;
1215 int job_posted
= 1, sriov_err
;
1217 if (!phba
->cfg_enable_hba_reset
)
1220 if ((phba
->sli_rev
< LPFC_SLI_REV4
) ||
1221 (bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
) !=
1222 LPFC_SLI_INTF_IF_TYPE_2
))
1225 /* Keep state if we need to restore back */
1226 before_fc_flag
= phba
->pport
->fc_flag
;
1227 sriov_nr_virtfn
= phba
->cfg_sriov_nr_virtfn
;
1229 /* Disable SR-IOV virtual functions if enabled */
1230 if (phba
->cfg_sriov_nr_virtfn
) {
1231 pci_disable_sriov(pdev
);
1232 phba
->cfg_sriov_nr_virtfn
= 0;
1235 if (opcode
== LPFC_FW_DUMP
)
1236 phba
->hba_flag
|= HBA_FW_DUMP_OP
;
1238 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1241 phba
->hba_flag
&= ~HBA_FW_DUMP_OP
;
1245 /* wait for the device to be quiesced before firmware reset */
1248 reg_val
= readl(phba
->sli4_hba
.conf_regs_memmap_p
+
1249 LPFC_CTL_PDEV_CTL_OFFSET
);
1251 if (opcode
== LPFC_FW_DUMP
)
1252 reg_val
|= LPFC_FW_DUMP_REQUEST
;
1253 else if (opcode
== LPFC_FW_RESET
)
1254 reg_val
|= LPFC_CTL_PDEV_CTL_FRST
;
1255 else if (opcode
== LPFC_DV_RESET
)
1256 reg_val
|= LPFC_CTL_PDEV_CTL_DRST
;
1258 writel(reg_val
, phba
->sli4_hba
.conf_regs_memmap_p
+
1259 LPFC_CTL_PDEV_CTL_OFFSET
);
1261 readl(phba
->sli4_hba
.conf_regs_memmap_p
+ LPFC_CTL_PDEV_CTL_OFFSET
);
1263 /* delay driver action following IF_TYPE_2 reset */
1264 rc
= lpfc_sli4_pdev_status_reg_wait(phba
);
1267 /* no privilege for reset */
1268 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1269 "3150 No privilege to perform the requested "
1270 "access: x%x\n", reg_val
);
1271 } else if (rc
== -EIO
) {
1272 /* reset failed, there is nothing more we can do */
1273 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1274 "3153 Fail to perform the requested "
1275 "access: x%x\n", reg_val
);
1279 /* keep the original port state */
1280 if (before_fc_flag
& FC_OFFLINE_MODE
)
1283 init_completion(&online_compl
);
1284 job_posted
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1289 wait_for_completion(&online_compl
);
1292 /* in any case, restore the virtual functions enabled as before */
1293 if (sriov_nr_virtfn
) {
1295 lpfc_sli_probe_sriov_nr_virtfn(phba
, sriov_nr_virtfn
);
1297 phba
->cfg_sriov_nr_virtfn
= sriov_nr_virtfn
;
1300 /* return proper error code */
1311 * lpfc_nport_evt_cnt_show - Return the number of nport events
1312 * @dev: class device that is converted into a Scsi_host.
1313 * @attr: device attribute, not used.
1314 * @buf: on return contains the ascii number of nport events.
1316 * Returns: size of formatted string.
1319 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
1322 struct Scsi_Host
*shost
= class_to_shost(dev
);
1323 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1324 struct lpfc_hba
*phba
= vport
->phba
;
1326 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
1330 * lpfc_board_mode_show - Return the state of the board
1331 * @dev: class device that is converted into a Scsi_host.
1332 * @attr: device attribute, not used.
1333 * @buf: on return contains the state of the adapter.
1335 * Returns: size of formatted string.
1338 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
1341 struct Scsi_Host
*shost
= class_to_shost(dev
);
1342 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1343 struct lpfc_hba
*phba
= vport
->phba
;
1346 if (phba
->link_state
== LPFC_HBA_ERROR
)
1348 else if (phba
->link_state
== LPFC_WARM_START
)
1349 state
= "warm start";
1350 else if (phba
->link_state
== LPFC_INIT_START
)
1355 return snprintf(buf
, PAGE_SIZE
, "%s\n", state
);
1359 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1360 * @dev: class device that is converted into a Scsi_host.
1361 * @attr: device attribute, not used.
1362 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1363 * @count: unused variable.
1366 * -EACCES if enable hba reset not enabled
1367 * -EINVAL if the buffer does not contain a valid string (see above)
1368 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1369 * buf length greater than zero indicates success
1372 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
1373 const char *buf
, size_t count
)
1375 struct Scsi_Host
*shost
= class_to_shost(dev
);
1376 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1377 struct lpfc_hba
*phba
= vport
->phba
;
1378 struct completion online_compl
;
1379 char *board_mode_str
= NULL
;
1383 if (!phba
->cfg_enable_hba_reset
) {
1385 goto board_mode_out
;
1388 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1389 "3050 lpfc_board_mode set to %s\n", buf
);
1391 init_completion(&online_compl
);
1393 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
1394 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1398 goto board_mode_out
;
1400 wait_for_completion(&online_compl
);
1403 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
1404 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1405 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
1406 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1409 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
1410 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
1411 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1414 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
1415 else if (strncmp(buf
, "dump", sizeof("dump") - 1) == 0)
1416 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_DUMP
);
1417 else if (strncmp(buf
, "fw_reset", sizeof("fw_reset") - 1) == 0)
1418 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_RESET
);
1419 else if (strncmp(buf
, "dv_reset", sizeof("dv_reset") - 1) == 0)
1420 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_DV_RESET
);
1428 board_mode_str
= strchr(buf
, '\n');
1430 *board_mode_str
= '\0';
1431 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1432 "3097 Failed \"%s\", status(%d), "
1434 buf
, status
, phba
->pport
->fc_flag
);
1440 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1441 * @phba: pointer to the adapter structure.
1442 * @mxri: max xri count.
1443 * @axri: available xri count.
1444 * @mrpi: max rpi count.
1445 * @arpi: available rpi count.
1446 * @mvpi: max vpi count.
1447 * @avpi: available vpi count.
1450 * If an integer pointer for an count is not null then the value for the
1451 * count is returned.
1458 lpfc_get_hba_info(struct lpfc_hba
*phba
,
1459 uint32_t *mxri
, uint32_t *axri
,
1460 uint32_t *mrpi
, uint32_t *arpi
,
1461 uint32_t *mvpi
, uint32_t *avpi
)
1463 struct lpfc_mbx_read_config
*rd_config
;
1464 LPFC_MBOXQ_t
*pmboxq
;
1470 * prevent udev from issuing mailbox commands until the port is
1473 if (phba
->link_state
< LPFC_LINK_DOWN
||
1474 !phba
->mbox_mem_pool
||
1475 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
1478 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
1481 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1484 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1486 pmb
= &pmboxq
->u
.mb
;
1487 pmb
->mbxCommand
= MBX_READ_CONFIG
;
1488 pmb
->mbxOwner
= OWN_HOST
;
1489 pmboxq
->context1
= NULL
;
1491 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
1492 rc
= MBX_NOT_FINISHED
;
1494 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
1496 if (rc
!= MBX_SUCCESS
) {
1497 if (rc
!= MBX_TIMEOUT
)
1498 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1502 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1503 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
1505 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
1507 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
1508 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
1510 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
1512 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
1513 phba
->sli4_hba
.max_cfg_param
.xri_used
;
1515 /* Account for differences with SLI-3. Get vpi count from
1516 * mailbox data and subtract one for max vpi value.
1518 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
1519 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
1524 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
1527 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
1529 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
1531 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
1533 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
1535 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
1537 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
1540 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1545 * lpfc_max_rpi_show - Return maximum rpi
1546 * @dev: class device that is converted into a Scsi_host.
1547 * @attr: device attribute, not used.
1548 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1551 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1552 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1553 * to "Unknown" and the buffer length is returned, therefore the caller
1554 * must check for "Unknown" in the buffer to detect a failure.
1556 * Returns: size of formatted string.
1559 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1562 struct Scsi_Host
*shost
= class_to_shost(dev
);
1563 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1564 struct lpfc_hba
*phba
= vport
->phba
;
1567 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
1568 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1569 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1573 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1574 * @dev: class device that is converted into a Scsi_host.
1575 * @attr: device attribute, not used.
1576 * @buf: containing the used rpi count in decimal or "Unknown".
1579 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1580 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1581 * to "Unknown" and the buffer length is returned, therefore the caller
1582 * must check for "Unknown" in the buffer to detect a failure.
1584 * Returns: size of formatted string.
1587 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1590 struct Scsi_Host
*shost
= class_to_shost(dev
);
1591 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1592 struct lpfc_hba
*phba
= vport
->phba
;
1595 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1596 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1597 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1601 * lpfc_max_xri_show - Return maximum xri
1602 * @dev: class device that is converted into a Scsi_host.
1603 * @attr: device attribute, not used.
1604 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1607 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1608 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1609 * to "Unknown" and the buffer length is returned, therefore the caller
1610 * must check for "Unknown" in the buffer to detect a failure.
1612 * Returns: size of formatted string.
1615 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1618 struct Scsi_Host
*shost
= class_to_shost(dev
);
1619 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1620 struct lpfc_hba
*phba
= vport
->phba
;
1623 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
1624 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1625 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1629 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1630 * @dev: class device that is converted into a Scsi_host.
1631 * @attr: device attribute, not used.
1632 * @buf: on return contains the used xri count in decimal or "Unknown".
1635 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1636 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1637 * to "Unknown" and the buffer length is returned, therefore the caller
1638 * must check for "Unknown" in the buffer to detect a failure.
1640 * Returns: size of formatted string.
1643 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1646 struct Scsi_Host
*shost
= class_to_shost(dev
);
1647 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1648 struct lpfc_hba
*phba
= vport
->phba
;
1651 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
1652 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1653 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1657 * lpfc_max_vpi_show - Return maximum vpi
1658 * @dev: class device that is converted into a Scsi_host.
1659 * @attr: device attribute, not used.
1660 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1663 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1664 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1665 * to "Unknown" and the buffer length is returned, therefore the caller
1666 * must check for "Unknown" in the buffer to detect a failure.
1668 * Returns: size of formatted string.
1671 lpfc_max_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1674 struct Scsi_Host
*shost
= class_to_shost(dev
);
1675 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1676 struct lpfc_hba
*phba
= vport
->phba
;
1679 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
1680 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1681 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1685 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1686 * @dev: class device that is converted into a Scsi_host.
1687 * @attr: device attribute, not used.
1688 * @buf: on return contains the used vpi count in decimal or "Unknown".
1691 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1692 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1693 * to "Unknown" and the buffer length is returned, therefore the caller
1694 * must check for "Unknown" in the buffer to detect a failure.
1696 * Returns: size of formatted string.
1699 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1702 struct Scsi_Host
*shost
= class_to_shost(dev
);
1703 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1704 struct lpfc_hba
*phba
= vport
->phba
;
1707 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
1708 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1709 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1713 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1714 * @dev: class device that is converted into a Scsi_host.
1715 * @attr: device attribute, not used.
1716 * @buf: text that must be interpreted to determine if npiv is supported.
1719 * Buffer will contain text indicating npiv is not suppoerted on the port,
1720 * the port is an NPIV physical port, or it is an npiv virtual port with
1721 * the id of the vport.
1723 * Returns: size of formatted string.
1726 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
1729 struct Scsi_Host
*shost
= class_to_shost(dev
);
1730 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1731 struct lpfc_hba
*phba
= vport
->phba
;
1733 if (!(phba
->max_vpi
))
1734 return snprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
1735 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1736 return snprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
1737 return snprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
1741 * lpfc_poll_show - Return text about poll support for the adapter
1742 * @dev: class device that is converted into a Scsi_host.
1743 * @attr: device attribute, not used.
1744 * @buf: on return contains the cfg_poll in hex.
1747 * cfg_poll should be a lpfc_polling_flags type.
1749 * Returns: size of formatted string.
1752 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
1755 struct Scsi_Host
*shost
= class_to_shost(dev
);
1756 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1757 struct lpfc_hba
*phba
= vport
->phba
;
1759 return snprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
1763 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1764 * @dev: class device that is converted into a Scsi_host.
1765 * @attr: device attribute, not used.
1766 * @buf: one or more lpfc_polling_flags values.
1770 * buf contents converted to integer and checked for a valid value.
1773 * -EINVAL if the buffer connot be converted or is out of range
1774 * length of the buf on success
1777 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
1778 const char *buf
, size_t count
)
1780 struct Scsi_Host
*shost
= class_to_shost(dev
);
1781 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1782 struct lpfc_hba
*phba
= vport
->phba
;
1787 if (!isdigit(buf
[0]))
1790 if (sscanf(buf
, "%i", &val
) != 1)
1793 if ((val
& 0x3) != val
)
1796 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1799 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1800 "3051 lpfc_poll changed from %d to %d\n",
1801 phba
->cfg_poll
, val
);
1803 spin_lock_irq(&phba
->hbalock
);
1805 old_val
= phba
->cfg_poll
;
1807 if (val
& ENABLE_FCP_RING_POLLING
) {
1808 if ((val
& DISABLE_FCP_RING_INT
) &&
1809 !(old_val
& DISABLE_FCP_RING_INT
)) {
1810 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1811 spin_unlock_irq(&phba
->hbalock
);
1814 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
1815 writel(creg_val
, phba
->HCregaddr
);
1816 readl(phba
->HCregaddr
); /* flush */
1818 lpfc_poll_start_timer(phba
);
1820 } else if (val
!= 0x0) {
1821 spin_unlock_irq(&phba
->hbalock
);
1825 if (!(val
& DISABLE_FCP_RING_INT
) &&
1826 (old_val
& DISABLE_FCP_RING_INT
))
1828 spin_unlock_irq(&phba
->hbalock
);
1829 del_timer(&phba
->fcp_poll_timer
);
1830 spin_lock_irq(&phba
->hbalock
);
1831 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1832 spin_unlock_irq(&phba
->hbalock
);
1835 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
1836 writel(creg_val
, phba
->HCregaddr
);
1837 readl(phba
->HCregaddr
); /* flush */
1840 phba
->cfg_poll
= val
;
1842 spin_unlock_irq(&phba
->hbalock
);
1848 * lpfc_fips_level_show - Return the current FIPS level for the HBA
1849 * @dev: class unused variable.
1850 * @attr: device attribute, not used.
1851 * @buf: on return contains the module description text.
1853 * Returns: size of formatted string.
1856 lpfc_fips_level_show(struct device
*dev
, struct device_attribute
*attr
,
1859 struct Scsi_Host
*shost
= class_to_shost(dev
);
1860 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1861 struct lpfc_hba
*phba
= vport
->phba
;
1863 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_level
);
1867 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
1868 * @dev: class unused variable.
1869 * @attr: device attribute, not used.
1870 * @buf: on return contains the module description text.
1872 * Returns: size of formatted string.
1875 lpfc_fips_rev_show(struct device
*dev
, struct device_attribute
*attr
,
1878 struct Scsi_Host
*shost
= class_to_shost(dev
);
1879 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1880 struct lpfc_hba
*phba
= vport
->phba
;
1882 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_spec_rev
);
1886 * lpfc_dss_show - Return the current state of dss and the configured state
1887 * @dev: class converted to a Scsi_host structure.
1888 * @attr: device attribute, not used.
1889 * @buf: on return contains the formatted text.
1891 * Returns: size of formatted string.
1894 lpfc_dss_show(struct device
*dev
, struct device_attribute
*attr
,
1897 struct Scsi_Host
*shost
= class_to_shost(dev
);
1898 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1899 struct lpfc_hba
*phba
= vport
->phba
;
1901 return snprintf(buf
, PAGE_SIZE
, "%s - %sOperational\n",
1902 (phba
->cfg_enable_dss
) ? "Enabled" : "Disabled",
1903 (phba
->sli3_options
& LPFC_SLI3_DSS_ENABLED
) ?
1908 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
1909 * @dev: class converted to a Scsi_host structure.
1910 * @attr: device attribute, not used.
1911 * @buf: on return contains the formatted support level.
1914 * Returns the maximum number of virtual functions a physical function can
1915 * support, 0 will be returned if called on virtual function.
1917 * Returns: size of formatted string.
1920 lpfc_sriov_hw_max_virtfn_show(struct device
*dev
,
1921 struct device_attribute
*attr
,
1924 struct Scsi_Host
*shost
= class_to_shost(dev
);
1925 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1926 struct lpfc_hba
*phba
= vport
->phba
;
1927 uint16_t max_nr_virtfn
;
1929 max_nr_virtfn
= lpfc_sli_sriov_nr_virtfn_get(phba
);
1930 return snprintf(buf
, PAGE_SIZE
, "%d\n", max_nr_virtfn
);
1933 static inline bool lpfc_rangecheck(uint val
, uint min
, uint max
)
1935 return val
>= min
&& val
<= max
;
1939 * lpfc_enable_bbcr_set: Sets an attribute value.
1940 * @phba: pointer the the adapter structure.
1941 * @val: integer attribute value.
1944 * Validates the min and max values then sets the
1945 * adapter config field if in the valid range. prints error message
1946 * and does not set the parameter if invalid.
1950 * -EINVAL if val is invalid
1953 lpfc_enable_bbcr_set(struct lpfc_hba
*phba
, uint val
)
1955 if (lpfc_rangecheck(val
, 0, 1) && phba
->sli_rev
== LPFC_SLI_REV4
) {
1956 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1957 "3068 %s_enable_bbcr changed from %d to %d\n",
1958 LPFC_DRIVER_NAME
, phba
->cfg_enable_bbcr
, val
);
1959 phba
->cfg_enable_bbcr
= val
;
1962 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1963 "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n",
1964 LPFC_DRIVER_NAME
, val
);
1969 * lpfc_param_show - Return a cfg attribute value in decimal
1972 * Macro that given an attr e.g. hba_queue_depth expands
1973 * into a function with the name lpfc_hba_queue_depth_show.
1975 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
1976 * @dev: class device that is converted into a Scsi_host.
1977 * @attr: device attribute, not used.
1978 * @buf: on return contains the attribute value in decimal.
1980 * Returns: size of formatted string.
1982 #define lpfc_param_show(attr) \
1984 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1987 struct Scsi_Host *shost = class_to_shost(dev);\
1988 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1989 struct lpfc_hba *phba = vport->phba;\
1990 return snprintf(buf, PAGE_SIZE, "%d\n",\
1995 * lpfc_param_hex_show - Return a cfg attribute value in hex
1998 * Macro that given an attr e.g. hba_queue_depth expands
1999 * into a function with the name lpfc_hba_queue_depth_show
2001 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
2002 * @dev: class device that is converted into a Scsi_host.
2003 * @attr: device attribute, not used.
2004 * @buf: on return contains the attribute value in hexadecimal.
2006 * Returns: size of formatted string.
2008 #define lpfc_param_hex_show(attr) \
2010 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2013 struct Scsi_Host *shost = class_to_shost(dev);\
2014 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2015 struct lpfc_hba *phba = vport->phba;\
2017 val = phba->cfg_##attr;\
2018 return snprintf(buf, PAGE_SIZE, "%#x\n",\
2023 * lpfc_param_init - Initializes a cfg attribute
2026 * Macro that given an attr e.g. hba_queue_depth expands
2027 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2028 * takes a default argument, a minimum and maximum argument.
2030 * lpfc_##attr##_init: Initializes an attribute.
2031 * @phba: pointer the the adapter structure.
2032 * @val: integer attribute value.
2034 * Validates the min and max values then sets the adapter config field
2035 * accordingly, or uses the default if out of range and prints an error message.
2039 * -EINVAL if default used
2041 #define lpfc_param_init(attr, default, minval, maxval) \
2043 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
2045 if (lpfc_rangecheck(val, minval, maxval)) {\
2046 phba->cfg_##attr = val;\
2049 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2050 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
2051 "allowed range is ["#minval", "#maxval"]\n", val); \
2052 phba->cfg_##attr = default;\
2057 * lpfc_param_set - Set a cfg attribute value
2060 * Macro that given an attr e.g. hba_queue_depth expands
2061 * into a function with the name lpfc_hba_queue_depth_set
2063 * lpfc_##attr##_set: Sets an attribute value.
2064 * @phba: pointer the the adapter structure.
2065 * @val: integer attribute value.
2068 * Validates the min and max values then sets the
2069 * adapter config field if in the valid range. prints error message
2070 * and does not set the parameter if invalid.
2074 * -EINVAL if val is invalid
2076 #define lpfc_param_set(attr, default, minval, maxval) \
2078 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
2080 if (lpfc_rangecheck(val, minval, maxval)) {\
2081 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2082 "3052 lpfc_" #attr " changed from %d to %d\n", \
2083 phba->cfg_##attr, val); \
2084 phba->cfg_##attr = val;\
2087 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2088 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
2089 "allowed range is ["#minval", "#maxval"]\n", val); \
2094 * lpfc_param_store - Set a vport attribute value
2097 * Macro that given an attr e.g. hba_queue_depth expands
2098 * into a function with the name lpfc_hba_queue_depth_store.
2100 * lpfc_##attr##_store: Set an sttribute value.
2101 * @dev: class device that is converted into a Scsi_host.
2102 * @attr: device attribute, not used.
2103 * @buf: contains the attribute value in ascii.
2107 * Convert the ascii text number to an integer, then
2108 * use the lpfc_##attr##_set function to set the value.
2111 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2112 * length of buffer upon success.
2114 #define lpfc_param_store(attr) \
2116 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2117 const char *buf, size_t count) \
2119 struct Scsi_Host *shost = class_to_shost(dev);\
2120 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2121 struct lpfc_hba *phba = vport->phba;\
2123 if (!isdigit(buf[0]))\
2125 if (sscanf(buf, "%i", &val) != 1)\
2127 if (lpfc_##attr##_set(phba, val) == 0) \
2128 return strlen(buf);\
2134 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
2137 * Macro that given an attr e.g. hba_queue_depth expands
2138 * into a function with the name lpfc_hba_queue_depth_show
2140 * lpfc_##attr##_show: prints the attribute value in decimal.
2141 * @dev: class device that is converted into a Scsi_host.
2142 * @attr: device attribute, not used.
2143 * @buf: on return contains the attribute value in decimal.
2145 * Returns: length of formatted string.
2147 #define lpfc_vport_param_show(attr) \
2149 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2152 struct Scsi_Host *shost = class_to_shost(dev);\
2153 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2154 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
2158 * lpfc_vport_param_hex_show - Return hex formatted attribute value
2161 * Macro that given an attr e.g.
2162 * hba_queue_depth expands into a function with the name
2163 * lpfc_hba_queue_depth_show
2165 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
2166 * @dev: class device that is converted into a Scsi_host.
2167 * @attr: device attribute, not used.
2168 * @buf: on return contains the attribute value in hexadecimal.
2170 * Returns: length of formatted string.
2172 #define lpfc_vport_param_hex_show(attr) \
2174 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2177 struct Scsi_Host *shost = class_to_shost(dev);\
2178 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2179 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
2183 * lpfc_vport_param_init - Initialize a vport cfg attribute
2186 * Macro that given an attr e.g. hba_queue_depth expands
2187 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2188 * takes a default argument, a minimum and maximum argument.
2190 * lpfc_##attr##_init: validates the min and max values then sets the
2191 * adapter config field accordingly, or uses the default if out of range
2192 * and prints an error message.
2193 * @phba: pointer the the adapter structure.
2194 * @val: integer attribute value.
2198 * -EINVAL if default used
2200 #define lpfc_vport_param_init(attr, default, minval, maxval) \
2202 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
2204 if (lpfc_rangecheck(val, minval, maxval)) {\
2205 vport->cfg_##attr = val;\
2208 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2209 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
2210 "allowed range is ["#minval", "#maxval"]\n", val); \
2211 vport->cfg_##attr = default;\
2216 * lpfc_vport_param_set - Set a vport cfg attribute
2219 * Macro that given an attr e.g. hba_queue_depth expands
2220 * into a function with the name lpfc_hba_queue_depth_set
2222 * lpfc_##attr##_set: validates the min and max values then sets the
2223 * adapter config field if in the valid range. prints error message
2224 * and does not set the parameter if invalid.
2225 * @phba: pointer the the adapter structure.
2226 * @val: integer attribute value.
2230 * -EINVAL if val is invalid
2232 #define lpfc_vport_param_set(attr, default, minval, maxval) \
2234 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
2236 if (lpfc_rangecheck(val, minval, maxval)) {\
2237 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2238 "3053 lpfc_" #attr \
2239 " changed from %d (x%x) to %d (x%x)\n", \
2240 vport->cfg_##attr, vport->cfg_##attr, \
2242 vport->cfg_##attr = val;\
2245 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2246 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
2247 "allowed range is ["#minval", "#maxval"]\n", val); \
2252 * lpfc_vport_param_store - Set a vport attribute
2255 * Macro that given an attr e.g. hba_queue_depth
2256 * expands into a function with the name lpfc_hba_queue_depth_store
2258 * lpfc_##attr##_store: convert the ascii text number to an integer, then
2259 * use the lpfc_##attr##_set function to set the value.
2260 * @cdev: class device that is converted into a Scsi_host.
2261 * @buf: contains the attribute value in decimal.
2265 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2266 * length of buffer upon success.
2268 #define lpfc_vport_param_store(attr) \
2270 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2271 const char *buf, size_t count) \
2273 struct Scsi_Host *shost = class_to_shost(dev);\
2274 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2276 if (!isdigit(buf[0]))\
2278 if (sscanf(buf, "%i", &val) != 1)\
2280 if (lpfc_##attr##_set(vport, val) == 0) \
2281 return strlen(buf);\
2287 static DEVICE_ATTR(nvme_info
, 0444, lpfc_nvme_info_show
, NULL
);
2288 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
2289 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
2290 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
2291 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
2292 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
2293 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
2294 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
2295 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
2296 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
2297 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
2298 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
2299 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
2300 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
2301 lpfc_link_state_store
);
2302 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
2303 lpfc_option_rom_version_show
, NULL
);
2304 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
2305 lpfc_num_discovered_ports_show
, NULL
);
2306 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
2307 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
2308 static DEVICE_ATTR_RO(lpfc_drvr_version
);
2309 static DEVICE_ATTR_RO(lpfc_enable_fip
);
2310 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
2311 lpfc_board_mode_show
, lpfc_board_mode_store
);
2312 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
2313 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
2314 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
2315 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
2316 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
2317 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
2318 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
2319 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
2320 static DEVICE_ATTR_RO(lpfc_temp_sensor
);
2321 static DEVICE_ATTR_RO(lpfc_fips_level
);
2322 static DEVICE_ATTR_RO(lpfc_fips_rev
);
2323 static DEVICE_ATTR_RO(lpfc_dss
);
2324 static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn
);
2325 static DEVICE_ATTR(protocol
, S_IRUGO
, lpfc_sli4_protocol_show
, NULL
);
2326 static DEVICE_ATTR(lpfc_xlane_supported
, S_IRUGO
, lpfc_oas_supported_show
,
2329 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
2332 * lpfc_wwn_set - Convert string to the 8 byte WWN value.
2334 * @cnt: Length of string.
2335 * @wwn: Array to receive converted wwn value.
2338 * -EINVAL if the buffer does not contain a valid wwn
2342 lpfc_wwn_set(const char *buf
, size_t cnt
, char wwn
[])
2346 /* Count may include a LF at end of string */
2347 if (buf
[cnt
-1] == '\n')
2350 if ((cnt
< 16) || (cnt
> 18) || ((cnt
== 17) && (*buf
++ != 'x')) ||
2351 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2354 memset(wwn
, 0, WWN_SZ
);
2356 /* Validate and store the new name */
2357 for (i
= 0, j
= 0; i
< 16; i
++) {
2358 if ((*buf
>= 'a') && (*buf
<= 'f'))
2359 j
= ((j
<< 4) | ((*buf
++ - 'a') + 10));
2360 else if ((*buf
>= 'A') && (*buf
<= 'F'))
2361 j
= ((j
<< 4) | ((*buf
++ - 'A') + 10));
2362 else if ((*buf
>= '0') && (*buf
<= '9'))
2363 j
= ((j
<< 4) | (*buf
++ - '0'));
2367 wwn
[i
/2] = j
& 0xff;
2374 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2375 * @dev: class device that is converted into a Scsi_host.
2376 * @attr: device attribute, not used.
2377 * @buf: containing the string lpfc_soft_wwn_key.
2378 * @count: must be size of lpfc_soft_wwn_key.
2381 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2382 * length of buf indicates success
2385 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
2386 const char *buf
, size_t count
)
2388 struct Scsi_Host
*shost
= class_to_shost(dev
);
2389 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2390 struct lpfc_hba
*phba
= vport
->phba
;
2391 unsigned int cnt
= count
;
2392 uint8_t vvvl
= vport
->fc_sparam
.cmn
.valid_vendor_ver_level
;
2393 u32
*fawwpn_key
= (uint32_t *)&vport
->fc_sparam
.un
.vendorVersion
[0];
2396 * We're doing a simple sanity check for soft_wwpn setting.
2397 * We require that the user write a specific key to enable
2398 * the soft_wwpn attribute to be settable. Once the attribute
2399 * is written, the enable key resets. If further updates are
2400 * desired, the key must be written again to re-enable the
2403 * The "key" is not secret - it is a hardcoded string shown
2404 * here. The intent is to protect against the random user or
2405 * application that is just writing attributes.
2407 if (vvvl
== 1 && cpu_to_be32(*fawwpn_key
) == FAPWWN_KEY_VENDOR
) {
2408 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2409 "0051 "LPFC_DRIVER_NAME
" soft wwpn can not"
2410 " be enabled: fawwpn is enabled\n");
2414 /* count may include a LF at end of string */
2415 if (buf
[cnt
-1] == '\n')
2418 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
2419 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
2422 phba
->soft_wwn_enable
= 1;
2424 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2425 "lpfc%d: soft_wwpn assignment has been enabled.\n",
2427 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2428 " The soft_wwpn feature is not supported by Broadcom.");
2432 static DEVICE_ATTR_WO(lpfc_soft_wwn_enable
);
2435 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2436 * @dev: class device that is converted into a Scsi_host.
2437 * @attr: device attribute, not used.
2438 * @buf: on return contains the wwpn in hexadecimal.
2440 * Returns: size of formatted string.
2443 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
2446 struct Scsi_Host
*shost
= class_to_shost(dev
);
2447 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2448 struct lpfc_hba
*phba
= vport
->phba
;
2450 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2451 (unsigned long long)phba
->cfg_soft_wwpn
);
2455 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2456 * @dev class device that is converted into a Scsi_host.
2457 * @attr: device attribute, not used.
2458 * @buf: contains the wwpn in hexadecimal.
2459 * @count: number of wwpn bytes in buf
2462 * -EACCES hba reset not enabled, adapter over temp
2463 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2464 * -EIO error taking adapter offline or online
2465 * value of count on success
2468 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
2469 const char *buf
, size_t count
)
2471 struct Scsi_Host
*shost
= class_to_shost(dev
);
2472 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2473 struct lpfc_hba
*phba
= vport
->phba
;
2474 struct completion online_compl
;
2475 int stat1
= 0, stat2
= 0;
2476 unsigned int cnt
= count
;
2480 if (!phba
->cfg_enable_hba_reset
)
2482 spin_lock_irq(&phba
->hbalock
);
2483 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
2484 spin_unlock_irq(&phba
->hbalock
);
2487 spin_unlock_irq(&phba
->hbalock
);
2488 /* count may include a LF at end of string */
2489 if (buf
[cnt
-1] == '\n')
2492 if (!phba
->soft_wwn_enable
)
2495 /* lock setting wwpn, wwnn down */
2496 phba
->soft_wwn_enable
= 0;
2498 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2500 /* not able to set wwpn, unlock it */
2501 phba
->soft_wwn_enable
= 1;
2505 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
2506 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
2507 if (phba
->cfg_soft_wwnn
)
2508 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
2510 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2511 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
2513 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
2515 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2516 "0463 lpfc_soft_wwpn attribute set failed to "
2517 "reinit adapter - %d\n", stat1
);
2518 init_completion(&online_compl
);
2519 rc
= lpfc_workq_post_event(phba
, &stat2
, &online_compl
,
2524 wait_for_completion(&online_compl
);
2526 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2527 "0464 lpfc_soft_wwpn attribute set failed to "
2528 "reinit adapter - %d\n", stat2
);
2529 return (stat1
|| stat2
) ? -EIO
: count
;
2531 static DEVICE_ATTR_RW(lpfc_soft_wwpn
);
2534 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2535 * @dev: class device that is converted into a Scsi_host.
2536 * @attr: device attribute, not used.
2537 * @buf: on return contains the wwnn in hexadecimal.
2539 * Returns: size of formatted string.
2542 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
2545 struct Scsi_Host
*shost
= class_to_shost(dev
);
2546 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2547 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2548 (unsigned long long)phba
->cfg_soft_wwnn
);
2552 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2553 * @cdev: class device that is converted into a Scsi_host.
2554 * @buf: contains the ww node name in hexadecimal.
2555 * @count: number of wwnn bytes in buf.
2558 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2559 * value of count on success
2562 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
2563 const char *buf
, size_t count
)
2565 struct Scsi_Host
*shost
= class_to_shost(dev
);
2566 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2567 unsigned int cnt
= count
;
2571 /* count may include a LF at end of string */
2572 if (buf
[cnt
-1] == '\n')
2575 if (!phba
->soft_wwn_enable
)
2578 rc
= lpfc_wwn_set(buf
, cnt
, wwnn
);
2580 /* Allow wwnn to be set many times, as long as the enable
2581 * is set. However, once the wwpn is set, everything locks.
2586 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
2588 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2589 "lpfc%d: soft_wwnn set. Value will take effect upon "
2590 "setting of the soft_wwpn\n", phba
->brd_no
);
2594 static DEVICE_ATTR_RW(lpfc_soft_wwnn
);
2597 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for
2598 * Optimized Access Storage (OAS) operations.
2599 * @dev: class device that is converted into a Scsi_host.
2600 * @attr: device attribute, not used.
2601 * @buf: buffer for passing information.
2607 lpfc_oas_tgt_show(struct device
*dev
, struct device_attribute
*attr
,
2610 struct Scsi_Host
*shost
= class_to_shost(dev
);
2611 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2613 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2614 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
));
2618 * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for
2619 * Optimized Access Storage (OAS) operations.
2620 * @dev: class device that is converted into a Scsi_host.
2621 * @attr: device attribute, not used.
2622 * @buf: buffer for passing information.
2623 * @count: Size of the data buffer.
2626 * -EINVAL count is invalid, invalid wwpn byte invalid
2627 * -EPERM oas is not supported by hba
2628 * value of count on success
2631 lpfc_oas_tgt_store(struct device
*dev
, struct device_attribute
*attr
,
2632 const char *buf
, size_t count
)
2634 struct Scsi_Host
*shost
= class_to_shost(dev
);
2635 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2636 unsigned int cnt
= count
;
2637 uint8_t wwpn
[WWN_SZ
];
2643 /* count may include a LF at end of string */
2644 if (buf
[cnt
-1] == '\n')
2647 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2651 memcpy(phba
->cfg_oas_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2652 memcpy(phba
->sli4_hba
.oas_next_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2653 if (wwn_to_u64(wwpn
) == 0)
2654 phba
->cfg_oas_flags
|= OAS_FIND_ANY_TARGET
;
2656 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_TARGET
;
2657 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2658 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2661 static DEVICE_ATTR(lpfc_xlane_tgt
, S_IRUGO
| S_IWUSR
,
2662 lpfc_oas_tgt_show
, lpfc_oas_tgt_store
);
2665 * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for
2666 * Optimized Access Storage (OAS) operations.
2667 * @dev: class device that is converted into a Scsi_host.
2668 * @attr: device attribute, not used.
2669 * @buf: buffer for passing information.
2675 lpfc_oas_priority_show(struct device
*dev
, struct device_attribute
*attr
,
2678 struct Scsi_Host
*shost
= class_to_shost(dev
);
2679 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2681 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_priority
);
2685 * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for
2686 * Optimized Access Storage (OAS) operations.
2687 * @dev: class device that is converted into a Scsi_host.
2688 * @attr: device attribute, not used.
2689 * @buf: buffer for passing information.
2690 * @count: Size of the data buffer.
2693 * -EINVAL count is invalid, invalid wwpn byte invalid
2694 * -EPERM oas is not supported by hba
2695 * value of count on success
2698 lpfc_oas_priority_store(struct device
*dev
, struct device_attribute
*attr
,
2699 const char *buf
, size_t count
)
2701 struct Scsi_Host
*shost
= class_to_shost(dev
);
2702 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2703 unsigned int cnt
= count
;
2710 /* count may include a LF at end of string */
2711 if (buf
[cnt
-1] == '\n')
2714 ret
= kstrtoul(buf
, 0, &val
);
2715 if (ret
|| (val
> 0x7f))
2719 phba
->cfg_oas_priority
= (uint8_t)val
;
2721 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
2724 static DEVICE_ATTR(lpfc_xlane_priority
, S_IRUGO
| S_IWUSR
,
2725 lpfc_oas_priority_show
, lpfc_oas_priority_store
);
2728 * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled
2729 * for Optimized Access Storage (OAS) operations.
2730 * @dev: class device that is converted into a Scsi_host.
2731 * @attr: device attribute, not used.
2732 * @buf: buffer for passing information.
2735 * value of count on success
2738 lpfc_oas_vpt_show(struct device
*dev
, struct device_attribute
*attr
,
2741 struct Scsi_Host
*shost
= class_to_shost(dev
);
2742 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2744 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2745 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
));
2749 * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled
2750 * for Optimized Access Storage (OAS) operations.
2751 * @dev: class device that is converted into a Scsi_host.
2752 * @attr: device attribute, not used.
2753 * @buf: buffer for passing information.
2754 * @count: Size of the data buffer.
2757 * -EINVAL count is invalid, invalid wwpn byte invalid
2758 * -EPERM oas is not supported by hba
2759 * value of count on success
2762 lpfc_oas_vpt_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_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2767 unsigned int cnt
= count
;
2768 uint8_t wwpn
[WWN_SZ
];
2774 /* count may include a LF at end of string */
2775 if (buf
[cnt
-1] == '\n')
2778 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2782 memcpy(phba
->cfg_oas_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2783 memcpy(phba
->sli4_hba
.oas_next_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2784 if (wwn_to_u64(wwpn
) == 0)
2785 phba
->cfg_oas_flags
|= OAS_FIND_ANY_VPORT
;
2787 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_VPORT
;
2788 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2789 if (phba
->cfg_oas_priority
== 0)
2790 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
2791 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2794 static DEVICE_ATTR(lpfc_xlane_vpt
, S_IRUGO
| S_IWUSR
,
2795 lpfc_oas_vpt_show
, lpfc_oas_vpt_store
);
2798 * lpfc_oas_lun_state_show - Return the current state (enabled or disabled)
2799 * of whether luns will be enabled or disabled
2800 * for Optimized Access Storage (OAS) operations.
2801 * @dev: class device that is converted into a Scsi_host.
2802 * @attr: device attribute, not used.
2803 * @buf: buffer for passing information.
2806 * size of formatted string.
2809 lpfc_oas_lun_state_show(struct device
*dev
, struct device_attribute
*attr
,
2812 struct Scsi_Host
*shost
= class_to_shost(dev
);
2813 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2815 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_state
);
2819 * lpfc_oas_lun_state_store - Store the state (enabled or disabled)
2820 * of whether luns will be enabled or disabled
2821 * for Optimized Access Storage (OAS) operations.
2822 * @dev: class device that is converted into a Scsi_host.
2823 * @attr: device attribute, not used.
2824 * @buf: buffer for passing information.
2825 * @count: Size of the data buffer.
2828 * -EINVAL count is invalid, invalid wwpn byte invalid
2829 * -EPERM oas is not supported by hba
2830 * value of count on success
2833 lpfc_oas_lun_state_store(struct device
*dev
, struct device_attribute
*attr
,
2834 const char *buf
, size_t count
)
2836 struct Scsi_Host
*shost
= class_to_shost(dev
);
2837 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2843 if (!isdigit(buf
[0]))
2846 if (sscanf(buf
, "%i", &val
) != 1)
2849 if ((val
!= 0) && (val
!= 1))
2852 phba
->cfg_oas_lun_state
= val
;
2855 static DEVICE_ATTR(lpfc_xlane_lun_state
, S_IRUGO
| S_IWUSR
,
2856 lpfc_oas_lun_state_show
, lpfc_oas_lun_state_store
);
2859 * lpfc_oas_lun_status_show - Return the status of the Optimized Access
2860 * Storage (OAS) lun returned by the
2861 * lpfc_oas_lun_show function.
2862 * @dev: class device that is converted into a Scsi_host.
2863 * @attr: device attribute, not used.
2864 * @buf: buffer for passing information.
2867 * size of formatted string.
2870 lpfc_oas_lun_status_show(struct device
*dev
, struct device_attribute
*attr
,
2873 struct Scsi_Host
*shost
= class_to_shost(dev
);
2874 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2876 if (!(phba
->cfg_oas_flags
& OAS_LUN_VALID
))
2879 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_status
);
2881 static DEVICE_ATTR(lpfc_xlane_lun_status
, S_IRUGO
,
2882 lpfc_oas_lun_status_show
, NULL
);
2886 * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage
2888 * @phba: lpfc_hba pointer.
2889 * @ndlp: pointer to fcp target node.
2890 * @lun: the fc lun for setting oas state.
2891 * @oas_state: the oas state to be set to the lun.
2895 * -EPERM OAS is not enabled or not supported by this port.
2899 lpfc_oas_lun_state_set(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2900 uint8_t tgt_wwpn
[], uint64_t lun
,
2901 uint32_t oas_state
, uint8_t pri
)
2910 if (!lpfc_enable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2911 (struct lpfc_name
*)tgt_wwpn
,
2915 lpfc_disable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2916 (struct lpfc_name
*)tgt_wwpn
, lun
, pri
);
2923 * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized
2924 * Access Storage (OAS) operations.
2925 * @phba: lpfc_hba pointer.
2926 * @vpt_wwpn: wwpn of the vport associated with the returned lun
2927 * @tgt_wwpn: wwpn of the target associated with the returned lun
2928 * @lun_status: status of the lun returned lun
2930 * Returns the first or next lun enabled for OAS operations for the vport/target
2931 * specified. If a lun is found, its vport wwpn, target wwpn and status is
2932 * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned.
2935 * lun that is OAS enabled for the vport/target
2936 * NOT_OAS_ENABLED_LUN when no oas enabled lun found.
2939 lpfc_oas_lun_get_next(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2940 uint8_t tgt_wwpn
[], uint32_t *lun_status
,
2945 if (unlikely(!phba
) || !vpt_wwpn
|| !tgt_wwpn
)
2946 return NOT_OAS_ENABLED_LUN
;
2947 if (lpfc_find_next_oas_lun(phba
, (struct lpfc_name
*)
2948 phba
->sli4_hba
.oas_next_vpt_wwpn
,
2949 (struct lpfc_name
*)
2950 phba
->sli4_hba
.oas_next_tgt_wwpn
,
2951 &phba
->sli4_hba
.oas_next_lun
,
2952 (struct lpfc_name
*)vpt_wwpn
,
2953 (struct lpfc_name
*)tgt_wwpn
,
2954 &found_lun
, lun_status
, lun_pri
))
2957 return NOT_OAS_ENABLED_LUN
;
2961 * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations
2962 * @phba: lpfc_hba pointer.
2963 * @vpt_wwpn: vport wwpn by reference.
2964 * @tgt_wwpn: target wwpn by reference.
2965 * @lun: the fc lun for setting oas state.
2966 * @oas_state: the oas state to be set to the oas_lun.
2968 * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE)
2969 * a lun for OAS operations.
2973 * -ENOMEM: failed to enable an lun for OAS operations
2974 * -EPERM: OAS is not enabled
2977 lpfc_oas_lun_state_change(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2978 uint8_t tgt_wwpn
[], uint64_t lun
,
2979 uint32_t oas_state
, uint8_t pri
)
2984 rc
= lpfc_oas_lun_state_set(phba
, vpt_wwpn
, tgt_wwpn
, lun
,
2990 * lpfc_oas_lun_show - Return oas enabled luns from a chosen target
2991 * @dev: class device that is converted into a Scsi_host.
2992 * @attr: device attribute, not used.
2993 * @buf: buffer for passing information.
2995 * This routine returns a lun enabled for OAS each time the function
2999 * SUCCESS: size of formatted string.
3000 * -EFAULT: target or vport wwpn was not set properly.
3001 * -EPERM: oas is not enabled.
3004 lpfc_oas_lun_show(struct device
*dev
, struct device_attribute
*attr
,
3007 struct Scsi_Host
*shost
= class_to_shost(dev
);
3008 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3016 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3017 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_VPORT
))
3020 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3021 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_TARGET
))
3024 oas_lun
= lpfc_oas_lun_get_next(phba
, phba
->cfg_oas_vpt_wwpn
,
3025 phba
->cfg_oas_tgt_wwpn
,
3026 &phba
->cfg_oas_lun_status
,
3027 &phba
->cfg_oas_priority
);
3028 if (oas_lun
!= NOT_OAS_ENABLED_LUN
)
3029 phba
->cfg_oas_flags
|= OAS_LUN_VALID
;
3031 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "0x%llx", oas_lun
);
3037 * lpfc_oas_lun_store - Sets the OAS state for lun
3038 * @dev: class device that is converted into a Scsi_host.
3039 * @attr: device attribute, not used.
3040 * @buf: buffer for passing information.
3042 * This function sets the OAS state for lun. Before this function is called,
3043 * the vport wwpn, target wwpn, and oas state need to be set.
3046 * SUCCESS: size of formatted string.
3047 * -EFAULT: target or vport wwpn was not set properly.
3048 * -EPERM: oas is not enabled.
3049 * size of formatted string.
3052 lpfc_oas_lun_store(struct device
*dev
, struct device_attribute
*attr
,
3053 const char *buf
, size_t count
)
3055 struct Scsi_Host
*shost
= class_to_shost(dev
);
3056 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3064 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3067 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3070 if (!isdigit(buf
[0]))
3073 if (sscanf(buf
, "0x%llx", &scsi_lun
) != 1)
3076 pri
= phba
->cfg_oas_priority
;
3078 pri
= phba
->cfg_XLanePriority
;
3080 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
,
3081 "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx "
3082 "priority 0x%x with oas state %d\n",
3083 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
),
3084 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
), scsi_lun
,
3085 pri
, phba
->cfg_oas_lun_state
);
3087 rc
= lpfc_oas_lun_state_change(phba
, phba
->cfg_oas_vpt_wwpn
,
3088 phba
->cfg_oas_tgt_wwpn
, scsi_lun
,
3089 phba
->cfg_oas_lun_state
, pri
);
3095 static DEVICE_ATTR(lpfc_xlane_lun
, S_IRUGO
| S_IWUSR
,
3096 lpfc_oas_lun_show
, lpfc_oas_lun_store
);
3098 int lpfc_enable_nvmet_cnt
;
3099 unsigned long long lpfc_enable_nvmet
[LPFC_NVMET_MAX_PORTS
] = {
3100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3102 module_param_array(lpfc_enable_nvmet
, ullong
, &lpfc_enable_nvmet_cnt
, 0444);
3103 MODULE_PARM_DESC(lpfc_enable_nvmet
, "Enable HBA port(s) WWPN as a NVME Target");
3105 static int lpfc_poll
= 0;
3106 module_param(lpfc_poll
, int, S_IRUGO
);
3107 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
3109 " 1 - poll with interrupts enabled"
3110 " 3 - poll and disable FCP ring interrupts");
3112 static DEVICE_ATTR_RW(lpfc_poll
);
3114 int lpfc_no_hba_reset_cnt
;
3115 unsigned long lpfc_no_hba_reset
[MAX_HBAS_NO_RESET
] = {
3116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3117 module_param_array(lpfc_no_hba_reset
, ulong
, &lpfc_no_hba_reset_cnt
, 0444);
3118 MODULE_PARM_DESC(lpfc_no_hba_reset
, "WWPN of HBAs that should not be reset");
3120 LPFC_ATTR(sli_mode
, 0, 0, 3,
3121 "SLI mode selector:"
3122 " 0 - auto (SLI-3 if supported),"
3123 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
3124 " 3 - select SLI-3");
3126 LPFC_ATTR_R(enable_npiv
, 1, 0, 1,
3127 "Enable NPIV functionality");
3129 LPFC_ATTR_R(fcf_failover_policy
, 1, 1, 2,
3130 "FCF Fast failover=1 Priority failover=2");
3133 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
3134 # 0x0 = disabled, XRI/OXID use not tracked.
3135 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
3136 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
3138 LPFC_ATTR_R(enable_rrq
, 2, 0, 2,
3139 "Enable RRQ functionality");
3142 # lpfc_suppress_link_up: Bring link up at initialization
3143 # 0x0 = bring link up (issue MBX_INIT_LINK)
3144 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
3145 # 0x2 = never bring up link
3146 # Default value is 0.
3148 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
3149 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
3150 "Suppress Link Up at initialization");
3152 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
3160 lpfc_iocb_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3162 struct Scsi_Host
*shost
= class_to_shost(dev
);
3163 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3165 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->iocb_max
);
3168 static DEVICE_ATTR(iocb_hw
, S_IRUGO
,
3169 lpfc_iocb_hw_show
, NULL
);
3171 lpfc_txq_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3173 struct Scsi_Host
*shost
= class_to_shost(dev
);
3174 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3175 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3177 return snprintf(buf
, PAGE_SIZE
, "%d\n",
3178 pring
? pring
->txq_max
: 0);
3181 static DEVICE_ATTR(txq_hw
, S_IRUGO
,
3182 lpfc_txq_hw_show
, NULL
);
3184 lpfc_txcmplq_hw_show(struct device
*dev
, struct device_attribute
*attr
,
3187 struct Scsi_Host
*shost
= class_to_shost(dev
);
3188 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3189 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3191 return snprintf(buf
, PAGE_SIZE
, "%d\n",
3192 pring
? pring
->txcmplq_max
: 0);
3195 static DEVICE_ATTR(txcmplq_hw
, S_IRUGO
,
3196 lpfc_txcmplq_hw_show
, NULL
);
3198 LPFC_ATTR_R(iocb_cnt
, 2, 1, 5,
3199 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
3202 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
3203 # until the timer expires. Value range is [0,255]. Default value is 30.
3205 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3206 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3207 module_param(lpfc_nodev_tmo
, int, 0);
3208 MODULE_PARM_DESC(lpfc_nodev_tmo
,
3209 "Seconds driver will hold I/O waiting "
3210 "for a device to come back");
3213 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
3214 * @dev: class converted to a Scsi_host structure.
3215 * @attr: device attribute, not used.
3216 * @buf: on return contains the dev loss timeout in decimal.
3218 * Returns: size of formatted string.
3221 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
3224 struct Scsi_Host
*shost
= class_to_shost(dev
);
3225 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3227 return snprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
3231 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
3232 * @vport: lpfc vport structure pointer.
3233 * @val: contains the nodev timeout value.
3236 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
3237 * a kernel error message is printed and zero is returned.
3238 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3239 * Otherwise nodev tmo is set to the default value.
3242 * zero if already set or if val is in range
3243 * -EINVAL val out of range
3246 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
3248 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
3249 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
3250 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
3251 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3252 "0407 Ignoring lpfc_nodev_tmo module "
3253 "parameter because lpfc_devloss_tmo "
3258 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3259 vport
->cfg_nodev_tmo
= val
;
3260 vport
->cfg_devloss_tmo
= val
;
3263 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3264 "0400 lpfc_nodev_tmo attribute cannot be set to"
3265 " %d, allowed range is [%d, %d]\n",
3266 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3267 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3272 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
3273 * @vport: lpfc vport structure pointer.
3276 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
3279 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
3281 struct Scsi_Host
*shost
;
3282 struct lpfc_nodelist
*ndlp
;
3284 shost
= lpfc_shost_from_vport(vport
);
3285 spin_lock_irq(shost
->host_lock
);
3286 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3287 if (!NLP_CHK_NODE_ACT(ndlp
))
3290 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
3291 #if (IS_ENABLED(CONFIG_NVME_FC))
3293 nvme_fc_set_remoteport_devloss(ndlp
->nrport
->remoteport
,
3294 vport
->cfg_devloss_tmo
);
3297 spin_unlock_irq(shost
->host_lock
);
3301 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
3302 * @vport: lpfc vport structure pointer.
3303 * @val: contains the tmo value.
3306 * If the devloss tmo is already set or the vport dev loss tmo has changed
3307 * then a kernel error message is printed and zero is returned.
3308 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3309 * Otherwise nodev tmo is set to the default value.
3312 * zero if already set or if val is in range
3313 * -EINVAL val out of range
3316 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
3318 if (vport
->dev_loss_tmo_changed
||
3319 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
3320 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3321 "0401 Ignoring change to lpfc_nodev_tmo "
3322 "because lpfc_devloss_tmo is set.\n");
3325 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3326 vport
->cfg_nodev_tmo
= val
;
3327 vport
->cfg_devloss_tmo
= val
;
3329 * For compat: set the fc_host dev loss so new rports
3330 * will get the value.
3332 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3333 lpfc_update_rport_devloss_tmo(vport
);
3336 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3337 "0403 lpfc_nodev_tmo attribute cannot be set to "
3338 "%d, allowed range is [%d, %d]\n",
3339 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3343 lpfc_vport_param_store(nodev_tmo
)
3345 static DEVICE_ATTR_RW(lpfc_nodev_tmo
);
3348 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
3349 # disappear until the timer expires. Value range is [0,255]. Default
3352 module_param(lpfc_devloss_tmo
, int, S_IRUGO
);
3353 MODULE_PARM_DESC(lpfc_devloss_tmo
,
3354 "Seconds driver will hold I/O waiting "
3355 "for a device to come back");
3356 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
3357 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
3358 lpfc_vport_param_show(devloss_tmo
)
3361 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
3362 * @vport: lpfc vport structure pointer.
3363 * @val: contains the tmo value.
3366 * If val is in a valid range then set the vport nodev tmo,
3367 * devloss tmo, also set the vport dev loss tmo changed flag.
3368 * Else a kernel error message is printed.
3371 * zero if val is in range
3372 * -EINVAL val out of range
3375 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
3377 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3378 vport
->cfg_nodev_tmo
= val
;
3379 vport
->cfg_devloss_tmo
= val
;
3380 vport
->dev_loss_tmo_changed
= 1;
3381 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3382 lpfc_update_rport_devloss_tmo(vport
);
3386 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3387 "0404 lpfc_devloss_tmo attribute cannot be set to "
3388 "%d, allowed range is [%d, %d]\n",
3389 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3393 lpfc_vport_param_store(devloss_tmo
)
3394 static DEVICE_ATTR_RW(lpfc_devloss_tmo
);
3397 * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it
3398 * lpfc_suppress_rsp = 0 Disable
3399 * lpfc_suppress_rsp = 1 Enable (default)
3402 LPFC_ATTR_R(suppress_rsp
, 1, 0, 1,
3403 "Enable suppress rsp feature is firmware supports it");
3406 * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds
3407 * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs
3408 * lpfc_nvmet_mrq = 1 use a single RQ pair
3409 * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ
3412 LPFC_ATTR_R(nvmet_mrq
,
3413 LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_MAX
,
3414 "Specify number of RQ pairs for processing NVMET cmds");
3417 * lpfc_enable_fc4_type: Defines what FC4 types are supported.
3418 * Supported Values: 1 - register just FCP
3419 * 3 - register both FCP and NVME
3420 * Supported values are [1,3]. Default value is 1
3422 LPFC_ATTR_R(enable_fc4_type
, LPFC_ENABLE_FCP
,
3423 LPFC_ENABLE_FCP
, LPFC_ENABLE_BOTH
,
3424 "Enable FC4 Protocol support - FCP / NVME");
3427 * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME
3428 * This parameter is only used if:
3429 * lpfc_enable_fc4_type is 3 - register both FCP and NVME and
3430 * port is not configured for NVMET.
3432 * ELS/CT always get 10% of XRIs, up to a maximum of 250
3433 * The remaining XRIs get split up based on lpfc_xri_split per port:
3435 * Supported Values are in percentages
3436 * the xri_split value is the percentage the SCSI port will get. The remaining
3437 * percentage will go to NVME.
3439 LPFC_ATTR_R(xri_split
, 50, 10, 90,
3440 "Percentage of FCP XRI resources versus NVME");
3443 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
3444 # deluged with LOTS of information.
3445 # You can set a bit mask to record specific types of verbose messages:
3446 # See lpfc_logmsh.h for definitions.
3448 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
3449 "Verbose logging bit-mask");
3452 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
3453 # objects that have been registered with the nameserver after login.
3455 LPFC_VPORT_ATTR_R(enable_da_id
, 1, 0, 1,
3456 "Deregister nameserver objects before LOGO");
3459 # lun_queue_depth: This parameter is used to limit the number of outstanding
3460 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
3461 # If this parameter value is greater than 1/8th the maximum number of exchanges
3462 # supported by the HBA port, then the lun queue depth will be reduced to
3463 # 1/8th the maximum number of exchanges.
3465 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 512,
3466 "Max number of FCP commands we can queue to a specific LUN");
3469 # tgt_queue_depth: This parameter is used to limit the number of outstanding
3470 # commands per target port. Value range is [10,65535]. Default value is 65535.
3472 LPFC_VPORT_ATTR_RW(tgt_queue_depth
, 65535, 10, 65535,
3473 "Max number of FCP commands we can queue to a specific target port");
3476 # hba_queue_depth: This parameter is used to limit the number of outstanding
3477 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
3478 # value is greater than the maximum number of exchanges supported by the HBA,
3479 # then maximum number of exchanges supported by the HBA is used to determine
3480 # the hba_queue_depth.
3482 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
3483 "Max number of FCP commands we can queue to a lpfc HBA");
3486 # peer_port_login: This parameter allows/prevents logins
3487 # between peer ports hosted on the same physical port.
3488 # When this parameter is set 0 peer ports of same physical port
3489 # are not allowed to login to each other.
3490 # When this parameter is set 1 peer ports of same physical port
3491 # are allowed to login to each other.
3492 # Default value of this parameter is 0.
3494 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
3495 "Allow peer ports on the same physical port to login to each "
3499 # restrict_login: This parameter allows/prevents logins
3500 # between Virtual Ports and remote initiators.
3501 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
3502 # other initiators and will attempt to PLOGI all remote ports.
3503 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
3504 # remote ports and will not attempt to PLOGI to other initiators.
3505 # This parameter does not restrict to the physical port.
3506 # This parameter does not restrict logins to Fabric resident remote ports.
3507 # Default value of this parameter is 1.
3509 static int lpfc_restrict_login
= 1;
3510 module_param(lpfc_restrict_login
, int, S_IRUGO
);
3511 MODULE_PARM_DESC(lpfc_restrict_login
,
3512 "Restrict virtual ports login to remote initiators.");
3513 lpfc_vport_param_show(restrict_login
);
3516 * lpfc_restrict_login_init - Set the vport restrict login flag
3517 * @vport: lpfc vport structure pointer.
3518 * @val: contains the restrict login value.
3521 * If val is not in a valid range then log a kernel error message and set
3522 * the vport restrict login to one.
3523 * If the port type is physical clear the restrict login flag and return.
3524 * Else set the restrict login flag to val.
3527 * zero if val is in range
3528 * -EINVAL val out of range
3531 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
3533 if (val
< 0 || val
> 1) {
3534 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3535 "0422 lpfc_restrict_login attribute cannot "
3536 "be set to %d, allowed range is [0, 1]\n",
3538 vport
->cfg_restrict_login
= 1;
3541 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
3542 vport
->cfg_restrict_login
= 0;
3545 vport
->cfg_restrict_login
= val
;
3550 * lpfc_restrict_login_set - Set the vport restrict login flag
3551 * @vport: lpfc vport structure pointer.
3552 * @val: contains the restrict login value.
3555 * If val is not in a valid range then log a kernel error message and set
3556 * the vport restrict login to one.
3557 * If the port type is physical and the val is not zero log a kernel
3558 * error message, clear the restrict login flag and return zero.
3559 * Else set the restrict login flag to val.
3562 * zero if val is in range
3563 * -EINVAL val out of range
3566 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
3568 if (val
< 0 || val
> 1) {
3569 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3570 "0425 lpfc_restrict_login attribute cannot "
3571 "be set to %d, allowed range is [0, 1]\n",
3573 vport
->cfg_restrict_login
= 1;
3576 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
3577 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3578 "0468 lpfc_restrict_login must be 0 for "
3579 "Physical ports.\n");
3580 vport
->cfg_restrict_login
= 0;
3583 vport
->cfg_restrict_login
= val
;
3586 lpfc_vport_param_store(restrict_login
);
3587 static DEVICE_ATTR_RW(lpfc_restrict_login
);
3590 # Some disk devices have a "select ID" or "select Target" capability.
3591 # From a protocol standpoint "select ID" usually means select the
3592 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
3593 # annex" which contains a table that maps a "select ID" (a number
3594 # between 0 and 7F) to an ALPA. By default, for compatibility with
3595 # older drivers, the lpfc driver scans this table from low ALPA to high
3598 # Turning on the scan-down variable (on = 1, off = 0) will
3599 # cause the lpfc driver to use an inverted table, effectively
3600 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
3602 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
3603 # and will not work across a fabric. Also this parameter will take
3604 # effect only in the case when ALPA map is not available.)
3606 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
3607 "Start scanning for devices from highest ALPA to lowest");
3610 # lpfc_topology: link topology for init link
3611 # 0x0 = attempt loop mode then point-to-point
3612 # 0x01 = internal loopback mode
3613 # 0x02 = attempt point-to-point mode only
3614 # 0x04 = attempt loop mode only
3615 # 0x06 = attempt point-to-point mode then loop
3616 # Set point-to-point mode if you want to run as an N_Port.
3617 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
3618 # Default value is 0.
3620 LPFC_ATTR(topology
, 0, 0, 6,
3621 "Select Fibre Channel topology");
3624 * lpfc_topology_set - Set the adapters topology field
3625 * @phba: lpfc_hba pointer.
3626 * @val: topology value.
3629 * If val is in a valid range then set the adapter's topology field and
3630 * issue a lip; if the lip fails reset the topology to the old value.
3632 * If the value is not in range log a kernel error message and return an error.
3635 * zero if val is in range and lip okay
3636 * non-zero return value from lpfc_issue_lip()
3637 * -EINVAL val out of range
3640 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
3641 const char *buf
, size_t count
)
3643 struct Scsi_Host
*shost
= class_to_shost(dev
);
3644 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3645 struct lpfc_hba
*phba
= vport
->phba
;
3648 const char *val_buf
= buf
;
3652 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
3654 val_buf
= &buf
[strlen("nolip ")];
3657 if (!isdigit(val_buf
[0]))
3659 if (sscanf(val_buf
, "%i", &val
) != 1)
3662 if (val
>= 0 && val
<= 6) {
3663 prev_val
= phba
->cfg_topology
;
3664 if (phba
->cfg_link_speed
== LPFC_USER_LINK_SPEED_16G
&&
3666 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3667 "3113 Loop mode not supported at speed %d\n",
3671 if (phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G6_FC
&&
3673 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3674 "3114 Loop mode not supported\n");
3677 phba
->cfg_topology
= val
;
3681 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3682 "3054 lpfc_topology changed from %d to %d\n",
3684 if (prev_val
!= val
&& phba
->sli_rev
== LPFC_SLI_REV4
)
3685 phba
->fc_topology_changed
= 1;
3686 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
3688 phba
->cfg_topology
= prev_val
;
3693 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3694 "%d:0467 lpfc_topology attribute cannot be set to %d, "
3695 "allowed range is [0, 6]\n",
3700 lpfc_param_show(topology
)
3701 static DEVICE_ATTR_RW(lpfc_topology
);
3704 * lpfc_static_vport_show: Read callback function for
3705 * lpfc_static_vport sysfs file.
3706 * @dev: Pointer to class device object.
3707 * @attr: device attribute structure.
3708 * @buf: Data buffer.
3710 * This function is the read call back function for
3711 * lpfc_static_vport sysfs file. The lpfc_static_vport
3712 * sysfs file report the mageability of the vport.
3715 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
3718 struct Scsi_Host
*shost
= class_to_shost(dev
);
3719 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3720 if (vport
->vport_flag
& STATIC_VPORT
)
3721 sprintf(buf
, "1\n");
3723 sprintf(buf
, "0\n");
3729 * Sysfs attribute to control the statistical data collection.
3731 static DEVICE_ATTR_RO(lpfc_static_vport
);
3734 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
3735 * @dev: Pointer to class device.
3736 * @buf: Data buffer.
3737 * @count: Size of the data buffer.
3739 * This function get called when a user write to the lpfc_stat_data_ctrl
3740 * sysfs file. This function parse the command written to the sysfs file
3741 * and take appropriate action. These commands are used for controlling
3742 * driver statistical data collection.
3743 * Following are the command this function handles.
3745 * setbucket <bucket_type> <base> <step>
3746 * = Set the latency buckets.
3747 * destroybucket = destroy all the buckets.
3748 * start = start data collection
3749 * stop = stop data collection
3750 * reset = reset the collected data
3753 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
3754 const char *buf
, size_t count
)
3756 struct Scsi_Host
*shost
= class_to_shost(dev
);
3757 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3758 struct lpfc_hba
*phba
= vport
->phba
;
3759 #define LPFC_MAX_DATA_CTRL_LEN 1024
3760 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
3762 char *str_ptr
, *token
;
3763 struct lpfc_vport
**vports
;
3764 struct Scsi_Host
*v_shost
;
3765 char *bucket_type_str
, *base_str
, *step_str
;
3766 unsigned long base
, step
, bucket_type
;
3768 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
3769 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
3772 strncpy(bucket_data
, buf
, LPFC_MAX_DATA_CTRL_LEN
);
3773 str_ptr
= &bucket_data
[0];
3774 /* Ignore this token - this is command token */
3775 token
= strsep(&str_ptr
, "\t ");
3779 bucket_type_str
= strsep(&str_ptr
, "\t ");
3780 if (!bucket_type_str
)
3783 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
3784 bucket_type
= LPFC_LINEAR_BUCKET
;
3785 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
3786 bucket_type
= LPFC_POWER2_BUCKET
;
3790 base_str
= strsep(&str_ptr
, "\t ");
3793 base
= simple_strtoul(base_str
, NULL
, 0);
3795 step_str
= strsep(&str_ptr
, "\t ");
3798 step
= simple_strtoul(step_str
, NULL
, 0);
3802 /* Block the data collection for every vport */
3803 vports
= lpfc_create_vport_work_array(phba
);
3807 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3808 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3809 spin_lock_irq(v_shost
->host_lock
);
3810 /* Block and reset data collection */
3811 vports
[i
]->stat_data_blocked
= 1;
3812 if (vports
[i
]->stat_data_enabled
)
3813 lpfc_vport_reset_stat_data(vports
[i
]);
3814 spin_unlock_irq(v_shost
->host_lock
);
3817 /* Set the bucket attributes */
3818 phba
->bucket_type
= bucket_type
;
3819 phba
->bucket_base
= base
;
3820 phba
->bucket_step
= step
;
3822 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3823 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3825 /* Unblock data collection */
3826 spin_lock_irq(v_shost
->host_lock
);
3827 vports
[i
]->stat_data_blocked
= 0;
3828 spin_unlock_irq(v_shost
->host_lock
);
3830 lpfc_destroy_vport_work_array(phba
, vports
);
3834 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
3835 vports
= lpfc_create_vport_work_array(phba
);
3839 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3840 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3841 spin_lock_irq(shost
->host_lock
);
3842 vports
[i
]->stat_data_blocked
= 1;
3843 lpfc_free_bucket(vport
);
3844 vport
->stat_data_enabled
= 0;
3845 vports
[i
]->stat_data_blocked
= 0;
3846 spin_unlock_irq(shost
->host_lock
);
3848 lpfc_destroy_vport_work_array(phba
, vports
);
3849 phba
->bucket_type
= LPFC_NO_BUCKET
;
3850 phba
->bucket_base
= 0;
3851 phba
->bucket_step
= 0;
3855 if (!strncmp(buf
, "start", strlen("start"))) {
3856 /* If no buckets configured return error */
3857 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
3859 spin_lock_irq(shost
->host_lock
);
3860 if (vport
->stat_data_enabled
) {
3861 spin_unlock_irq(shost
->host_lock
);
3864 lpfc_alloc_bucket(vport
);
3865 vport
->stat_data_enabled
= 1;
3866 spin_unlock_irq(shost
->host_lock
);
3870 if (!strncmp(buf
, "stop", strlen("stop"))) {
3871 spin_lock_irq(shost
->host_lock
);
3872 if (vport
->stat_data_enabled
== 0) {
3873 spin_unlock_irq(shost
->host_lock
);
3876 lpfc_free_bucket(vport
);
3877 vport
->stat_data_enabled
= 0;
3878 spin_unlock_irq(shost
->host_lock
);
3882 if (!strncmp(buf
, "reset", strlen("reset"))) {
3883 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
3884 || !vport
->stat_data_enabled
)
3886 spin_lock_irq(shost
->host_lock
);
3887 vport
->stat_data_blocked
= 1;
3888 lpfc_vport_reset_stat_data(vport
);
3889 vport
->stat_data_blocked
= 0;
3890 spin_unlock_irq(shost
->host_lock
);
3898 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
3899 * @dev: Pointer to class device object.
3900 * @buf: Data buffer.
3902 * This function is the read call back function for
3903 * lpfc_stat_data_ctrl sysfs file. This function report the
3904 * current statistical data collection state.
3907 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
3910 struct Scsi_Host
*shost
= class_to_shost(dev
);
3911 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3912 struct lpfc_hba
*phba
= vport
->phba
;
3916 unsigned long bucket_value
;
3918 switch (phba
->bucket_type
) {
3919 case LPFC_LINEAR_BUCKET
:
3920 bucket_type
= "linear";
3922 case LPFC_POWER2_BUCKET
:
3923 bucket_type
= "power2";
3926 bucket_type
= "No Bucket";
3930 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
3931 "blocked :%d, Bucket type :%s, Bucket base :%d,"
3932 " Bucket step :%d\nLatency Ranges :",
3933 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
3934 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
3935 index
= strlen(buf
);
3936 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
3937 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3938 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
3939 bucket_value
= phba
->bucket_base
+
3940 phba
->bucket_step
* i
;
3942 bucket_value
= phba
->bucket_base
+
3943 (1 << i
) * phba
->bucket_step
;
3945 if (index
+ 10 > PAGE_SIZE
)
3947 sprintf(&buf
[index
], "%08ld ", bucket_value
);
3948 index
= strlen(buf
);
3951 sprintf(&buf
[index
], "\n");
3956 * Sysfs attribute to control the statistical data collection.
3958 static DEVICE_ATTR_RW(lpfc_stat_data_ctrl
);
3961 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
3965 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
3968 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
3969 #define MAX_STAT_DATA_SIZE_PER_TARGET \
3970 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
3974 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
3976 * @kobj: Pointer to the kernel object
3977 * @bin_attr: Attribute object
3978 * @buff: Buffer pointer
3980 * @count: Buffer size
3982 * This function is the read call back function for lpfc_drvr_stat_data
3983 * sysfs file. This function export the statistical data to user
3987 sysfs_drvr_stat_data_read(struct file
*filp
, struct kobject
*kobj
,
3988 struct bin_attribute
*bin_attr
,
3989 char *buf
, loff_t off
, size_t count
)
3991 struct device
*dev
= container_of(kobj
, struct device
,
3993 struct Scsi_Host
*shost
= class_to_shost(dev
);
3994 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3995 struct lpfc_hba
*phba
= vport
->phba
;
3996 int i
= 0, index
= 0;
3997 unsigned long nport_index
;
3998 struct lpfc_nodelist
*ndlp
= NULL
;
3999 nport_index
= (unsigned long)off
/
4000 MAX_STAT_DATA_SIZE_PER_TARGET
;
4002 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
4003 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
4006 spin_lock_irq(shost
->host_lock
);
4007 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4008 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
4011 if (nport_index
> 0) {
4016 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
4020 if (!ndlp
->lat_data
)
4024 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
4025 ndlp
->nlp_portname
.u
.wwn
[0],
4026 ndlp
->nlp_portname
.u
.wwn
[1],
4027 ndlp
->nlp_portname
.u
.wwn
[2],
4028 ndlp
->nlp_portname
.u
.wwn
[3],
4029 ndlp
->nlp_portname
.u
.wwn
[4],
4030 ndlp
->nlp_portname
.u
.wwn
[5],
4031 ndlp
->nlp_portname
.u
.wwn
[6],
4032 ndlp
->nlp_portname
.u
.wwn
[7]);
4034 index
= strlen(buf
);
4036 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
4037 sprintf(&buf
[index
], "%010u,",
4038 ndlp
->lat_data
[i
].cmd_count
);
4039 index
= strlen(buf
);
4041 sprintf(&buf
[index
], "\n");
4042 index
= strlen(buf
);
4044 spin_unlock_irq(shost
->host_lock
);
4048 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
4050 .name
= "lpfc_drvr_stat_data",
4053 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
4054 .read
= sysfs_drvr_stat_data_read
,
4059 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
4061 # Value range is [0,16]. Default value is 0.
4064 * lpfc_link_speed_set - Set the adapters link speed
4065 * @phba: lpfc_hba pointer.
4066 * @val: link speed value.
4069 * If val is in a valid range then set the adapter's link speed field and
4070 * issue a lip; if the lip fails reset the link speed to the old value.
4073 * If the value is not in range log a kernel error message and return an error.
4076 * zero if val is in range and lip okay.
4077 * non-zero return value from lpfc_issue_lip()
4078 * -EINVAL val out of range
4081 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
4082 const char *buf
, size_t count
)
4084 struct Scsi_Host
*shost
= class_to_shost(dev
);
4085 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4086 struct lpfc_hba
*phba
= vport
->phba
;
4087 int val
= LPFC_USER_LINK_SPEED_AUTO
;
4089 const char *val_buf
= buf
;
4091 uint32_t prev_val
, if_type
;
4093 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
4094 if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
&&
4095 phba
->hba_flag
& HBA_FORCED_LINK_SPEED
)
4098 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
4100 val_buf
= &buf
[strlen("nolip ")];
4103 if (!isdigit(val_buf
[0]))
4105 if (sscanf(val_buf
, "%i", &val
) != 1)
4108 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4109 "3055 lpfc_link_speed changed from %d to %d %s\n",
4110 phba
->cfg_link_speed
, val
, nolip
? "(nolip)" : "(lip)");
4112 if (((val
== LPFC_USER_LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
4113 ((val
== LPFC_USER_LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
4114 ((val
== LPFC_USER_LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
4115 ((val
== LPFC_USER_LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
4116 ((val
== LPFC_USER_LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)) ||
4117 ((val
== LPFC_USER_LINK_SPEED_16G
) && !(phba
->lmt
& LMT_16Gb
)) ||
4118 ((val
== LPFC_USER_LINK_SPEED_32G
) && !(phba
->lmt
& LMT_32Gb
)) ||
4119 ((val
== LPFC_USER_LINK_SPEED_64G
) && !(phba
->lmt
& LMT_64Gb
))) {
4120 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4121 "2879 lpfc_link_speed attribute cannot be set "
4122 "to %d. Speed is not supported by this port.\n",
4126 if (val
>= LPFC_USER_LINK_SPEED_16G
&&
4127 phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
4128 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4129 "3112 lpfc_link_speed attribute cannot be set "
4130 "to %d. Speed is not supported in loop mode.\n",
4136 case LPFC_USER_LINK_SPEED_AUTO
:
4137 case LPFC_USER_LINK_SPEED_1G
:
4138 case LPFC_USER_LINK_SPEED_2G
:
4139 case LPFC_USER_LINK_SPEED_4G
:
4140 case LPFC_USER_LINK_SPEED_8G
:
4141 case LPFC_USER_LINK_SPEED_16G
:
4142 case LPFC_USER_LINK_SPEED_32G
:
4143 case LPFC_USER_LINK_SPEED_64G
:
4144 prev_val
= phba
->cfg_link_speed
;
4145 phba
->cfg_link_speed
= val
;
4149 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
4151 phba
->cfg_link_speed
= prev_val
;
4159 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4160 "0469 lpfc_link_speed attribute cannot be set to %d, "
4161 "allowed values are [%s]\n",
4162 val
, LPFC_LINK_SPEED_STRING
);
4167 static int lpfc_link_speed
= 0;
4168 module_param(lpfc_link_speed
, int, S_IRUGO
);
4169 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
4170 lpfc_param_show(link_speed
)
4173 * lpfc_link_speed_init - Set the adapters link speed
4174 * @phba: lpfc_hba pointer.
4175 * @val: link speed value.
4178 * If val is in a valid range then set the adapter's link speed field.
4181 * If the value is not in range log a kernel error message, clear the link
4182 * speed and return an error.
4185 * zero if val saved.
4186 * -EINVAL val out of range
4189 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
4191 if (val
>= LPFC_USER_LINK_SPEED_16G
&& phba
->cfg_topology
== 4) {
4192 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4193 "3111 lpfc_link_speed of %d cannot "
4194 "support loop mode, setting topology to default.\n",
4196 phba
->cfg_topology
= 0;
4200 case LPFC_USER_LINK_SPEED_AUTO
:
4201 case LPFC_USER_LINK_SPEED_1G
:
4202 case LPFC_USER_LINK_SPEED_2G
:
4203 case LPFC_USER_LINK_SPEED_4G
:
4204 case LPFC_USER_LINK_SPEED_8G
:
4205 case LPFC_USER_LINK_SPEED_16G
:
4206 case LPFC_USER_LINK_SPEED_32G
:
4207 case LPFC_USER_LINK_SPEED_64G
:
4208 phba
->cfg_link_speed
= val
;
4211 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4212 "0405 lpfc_link_speed attribute cannot "
4213 "be set to %d, allowed values are "
4214 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
4215 phba
->cfg_link_speed
= LPFC_USER_LINK_SPEED_AUTO
;
4220 static DEVICE_ATTR_RW(lpfc_link_speed
);
4223 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
4224 # 0 = aer disabled or not supported
4225 # 1 = aer supported and enabled (default)
4226 # Value range is [0,1]. Default value is 1.
4228 LPFC_ATTR(aer_support
, 1, 0, 1,
4229 "Enable PCIe device AER support");
4230 lpfc_param_show(aer_support
)
4233 * lpfc_aer_support_store - Set the adapter for aer support
4235 * @dev: class device that is converted into a Scsi_host.
4236 * @attr: device attribute, not used.
4237 * @buf: containing enable or disable aer flag.
4238 * @count: unused variable.
4241 * If the val is 1 and currently the device's AER capability was not
4242 * enabled, invoke the kernel's enable AER helper routine, trying to
4243 * enable the device's AER capability. If the helper routine enabling
4244 * AER returns success, update the device's cfg_aer_support flag to
4245 * indicate AER is supported by the device; otherwise, if the device
4246 * AER capability is already enabled to support AER, then do nothing.
4248 * If the val is 0 and currently the device's AER support was enabled,
4249 * invoke the kernel's disable AER helper routine. After that, update
4250 * the device's cfg_aer_support flag to indicate AER is not supported
4251 * by the device; otherwise, if the device AER capability is already
4252 * disabled from supporting AER, then do nothing.
4255 * length of the buf on success if val is in range the intended mode
4257 * -EINVAL if val out of range or intended mode is not supported.
4260 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
4261 const char *buf
, size_t count
)
4263 struct Scsi_Host
*shost
= class_to_shost(dev
);
4264 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4265 struct lpfc_hba
*phba
= vport
->phba
;
4266 int val
= 0, rc
= -EINVAL
;
4268 if (!isdigit(buf
[0]))
4270 if (sscanf(buf
, "%i", &val
) != 1)
4275 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
4276 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
4278 spin_lock_irq(&phba
->hbalock
);
4279 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
4280 spin_unlock_irq(&phba
->hbalock
);
4281 phba
->cfg_aer_support
= 0;
4286 phba
->cfg_aer_support
= 0;
4291 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
4292 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
4294 spin_lock_irq(&phba
->hbalock
);
4295 phba
->hba_flag
|= HBA_AER_ENABLED
;
4296 spin_unlock_irq(&phba
->hbalock
);
4297 phba
->cfg_aer_support
= 1;
4302 phba
->cfg_aer_support
= 1;
4313 static DEVICE_ATTR_RW(lpfc_aer_support
);
4316 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
4317 * @dev: class device that is converted into a Scsi_host.
4318 * @attr: device attribute, not used.
4319 * @buf: containing flag 1 for aer cleanup state.
4320 * @count: unused variable.
4323 * If the @buf contains 1 and the device currently has the AER support
4324 * enabled, then invokes the kernel AER helper routine
4325 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
4326 * error status register.
4331 * -EINVAL if the buf does not contain the 1 or the device is not currently
4332 * enabled with the AER support.
4335 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
4336 const char *buf
, size_t count
)
4338 struct Scsi_Host
*shost
= class_to_shost(dev
);
4339 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4340 struct lpfc_hba
*phba
= vport
->phba
;
4343 if (!isdigit(buf
[0]))
4345 if (sscanf(buf
, "%i", &val
) != 1)
4350 if (phba
->hba_flag
& HBA_AER_ENABLED
)
4351 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
4359 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
4360 lpfc_aer_cleanup_state
);
4363 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
4365 * @dev: class device that is converted into a Scsi_host.
4366 * @attr: device attribute, not used.
4367 * @buf: containing the string the number of vfs to be enabled.
4368 * @count: unused variable.
4371 * When this api is called either through user sysfs, the driver shall
4372 * try to enable or disable SR-IOV virtual functions according to the
4375 * If zero virtual function has been enabled to the physical function,
4376 * the driver shall invoke the pci enable virtual function api trying
4377 * to enable the virtual functions. If the nr_vfn provided is greater
4378 * than the maximum supported, the maximum virtual function number will
4379 * be used for invoking the api; otherwise, the nr_vfn provided shall
4380 * be used for invoking the api. If the api call returned success, the
4381 * actual number of virtual functions enabled will be set to the driver
4382 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
4383 * cfg_sriov_nr_virtfn remains zero.
4385 * If none-zero virtual functions have already been enabled to the
4386 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
4387 * -EINVAL will be returned and the driver does nothing;
4389 * If the nr_vfn provided is zero and none-zero virtual functions have
4390 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
4391 * disabling virtual function api shall be invoded to disable all the
4392 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
4393 * zero. Otherwise, if zero virtual function has been enabled, do
4397 * length of the buf on success if val is in range the intended mode
4399 * -EINVAL if val out of range or intended mode is not supported.
4402 lpfc_sriov_nr_virtfn_store(struct device
*dev
, struct device_attribute
*attr
,
4403 const char *buf
, size_t count
)
4405 struct Scsi_Host
*shost
= class_to_shost(dev
);
4406 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4407 struct lpfc_hba
*phba
= vport
->phba
;
4408 struct pci_dev
*pdev
= phba
->pcidev
;
4409 int val
= 0, rc
= -EINVAL
;
4411 /* Sanity check on user data */
4412 if (!isdigit(buf
[0]))
4414 if (sscanf(buf
, "%i", &val
) != 1)
4419 /* Request disabling virtual functions */
4421 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4422 pci_disable_sriov(pdev
);
4423 phba
->cfg_sriov_nr_virtfn
= 0;
4428 /* Request enabling virtual functions */
4429 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4430 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4431 "3018 There are %d virtual functions "
4432 "enabled on physical function.\n",
4433 phba
->cfg_sriov_nr_virtfn
);
4437 if (val
<= LPFC_MAX_VFN_PER_PFN
)
4438 phba
->cfg_sriov_nr_virtfn
= val
;
4440 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4441 "3019 Enabling %d virtual functions is not "
4446 rc
= lpfc_sli_probe_sriov_nr_virtfn(phba
, phba
->cfg_sriov_nr_virtfn
);
4448 phba
->cfg_sriov_nr_virtfn
= 0;
4456 LPFC_ATTR(sriov_nr_virtfn
, LPFC_DEF_VFN_PER_PFN
, 0, LPFC_MAX_VFN_PER_PFN
,
4457 "Enable PCIe device SR-IOV virtual fn");
4459 lpfc_param_show(sriov_nr_virtfn
)
4460 static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn
);
4463 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
4465 * @dev: class device that is converted into a Scsi_host.
4466 * @attr: device attribute, not used.
4467 * @buf: containing the string the number of vfs to be enabled.
4468 * @count: unused variable.
4473 * length of the buf on success if val is in range the intended mode
4475 * -EINVAL if val out of range or intended mode is not supported.
4478 lpfc_request_firmware_upgrade_store(struct device
*dev
,
4479 struct device_attribute
*attr
,
4480 const char *buf
, size_t count
)
4482 struct Scsi_Host
*shost
= class_to_shost(dev
);
4483 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4484 struct lpfc_hba
*phba
= vport
->phba
;
4485 int val
= 0, rc
= -EINVAL
;
4487 /* Sanity check on user data */
4488 if (!isdigit(buf
[0]))
4490 if (sscanf(buf
, "%i", &val
) != 1)
4495 rc
= lpfc_sli4_request_firmware_update(phba
, RUN_FW_UPGRADE
);
4503 static int lpfc_req_fw_upgrade
;
4504 module_param(lpfc_req_fw_upgrade
, int, S_IRUGO
|S_IWUSR
);
4505 MODULE_PARM_DESC(lpfc_req_fw_upgrade
, "Enable Linux generic firmware upgrade");
4506 lpfc_param_show(request_firmware_upgrade
)
4509 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
4510 * @phba: lpfc_hba pointer.
4514 * Set the initial Linux generic firmware upgrade enable or disable flag.
4517 * zero if val saved.
4518 * -EINVAL val out of range
4521 lpfc_request_firmware_upgrade_init(struct lpfc_hba
*phba
, int val
)
4523 if (val
>= 0 && val
<= 1) {
4524 phba
->cfg_request_firmware_upgrade
= val
;
4529 static DEVICE_ATTR(lpfc_req_fw_upgrade
, S_IRUGO
| S_IWUSR
,
4530 lpfc_request_firmware_upgrade_show
,
4531 lpfc_request_firmware_upgrade_store
);
4534 * lpfc_fcp_imax_store
4536 * @dev: class device that is converted into a Scsi_host.
4537 * @attr: device attribute, not used.
4538 * @buf: string with the number of fast-path FCP interrupts per second.
4539 * @count: unused variable.
4542 * If val is in a valid range [636,651042], then set the adapter's
4543 * maximum number of fast-path FCP interrupts per second.
4546 * length of the buf on success if val is in range the intended mode
4548 * -EINVAL if val out of range or intended mode is not supported.
4551 lpfc_fcp_imax_store(struct device
*dev
, struct device_attribute
*attr
,
4552 const char *buf
, size_t count
)
4554 struct Scsi_Host
*shost
= class_to_shost(dev
);
4555 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4556 struct lpfc_hba
*phba
= vport
->phba
;
4559 /* fcp_imax is only valid for SLI4 */
4560 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
4563 /* Sanity check on user data */
4564 if (!isdigit(buf
[0]))
4566 if (sscanf(buf
, "%i", &val
) != 1)
4570 * Value range for the HBA is [5000,5000000]
4571 * The value for each EQ depends on how many EQs are configured.
4574 if (val
&& (val
< LPFC_MIN_IMAX
|| val
> LPFC_MAX_IMAX
))
4577 phba
->cfg_fcp_imax
= (uint32_t)val
;
4578 phba
->initial_imax
= phba
->cfg_fcp_imax
;
4580 for (i
= 0; i
< phba
->io_channel_irqs
; i
+= LPFC_MAX_EQ_DELAY_EQID_CNT
)
4581 lpfc_modify_hba_eq_delay(phba
, i
, LPFC_MAX_EQ_DELAY_EQID_CNT
,
4588 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
4591 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
4593 static int lpfc_fcp_imax
= LPFC_DEF_IMAX
;
4594 module_param(lpfc_fcp_imax
, int, S_IRUGO
|S_IWUSR
);
4595 MODULE_PARM_DESC(lpfc_fcp_imax
,
4596 "Set the maximum number of FCP interrupts per second per HBA");
4597 lpfc_param_show(fcp_imax
)
4600 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
4601 * @phba: lpfc_hba pointer.
4602 * @val: link speed value.
4605 * If val is in a valid range [636,651042], then initialize the adapter's
4606 * maximum number of fast-path FCP interrupts per second.
4609 * zero if val saved.
4610 * -EINVAL val out of range
4613 lpfc_fcp_imax_init(struct lpfc_hba
*phba
, int val
)
4615 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4616 phba
->cfg_fcp_imax
= 0;
4620 if ((val
>= LPFC_MIN_IMAX
&& val
<= LPFC_MAX_IMAX
) ||
4622 phba
->cfg_fcp_imax
= val
;
4626 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4627 "3016 lpfc_fcp_imax: %d out of range, using default\n",
4629 phba
->cfg_fcp_imax
= LPFC_DEF_IMAX
;
4634 static DEVICE_ATTR_RW(lpfc_fcp_imax
);
4637 * lpfc_auto_imax: Controls Auto-interrupt coalescing values support.
4638 * 0 No auto_imax support
4640 * Auto imax will change the value of fcp_imax on a per EQ basis, using
4641 * the EQ Delay Multiplier, depending on the activity for that EQ.
4642 * Value range [0,1]. Default value is 1.
4644 LPFC_ATTR_RW(auto_imax
, 1, 0, 1, "Enable Auto imax");
4647 * lpfc_state_show - Display current driver CPU affinity
4648 * @dev: class converted to a Scsi_host structure.
4649 * @attr: device attribute, not used.
4650 * @buf: on return contains text describing the state of the link.
4652 * Returns: size of formatted string.
4655 lpfc_fcp_cpu_map_show(struct device
*dev
, struct device_attribute
*attr
,
4658 struct Scsi_Host
*shost
= class_to_shost(dev
);
4659 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4660 struct lpfc_hba
*phba
= vport
->phba
;
4661 struct lpfc_vector_map_info
*cpup
;
4664 if ((phba
->sli_rev
!= LPFC_SLI_REV4
) ||
4665 (phba
->intr_type
!= MSIX
))
4668 switch (phba
->cfg_fcp_cpu_map
) {
4670 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4671 "fcp_cpu_map: No mapping (%d)\n",
4672 phba
->cfg_fcp_cpu_map
);
4675 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4676 "fcp_cpu_map: HBA centric mapping (%d): "
4678 phba
->cfg_fcp_cpu_map
,
4679 phba
->sli4_hba
.num_online_cpu
);
4682 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4683 "fcp_cpu_map: Driver centric mapping (%d): "
4685 phba
->cfg_fcp_cpu_map
,
4686 phba
->sli4_hba
.num_online_cpu
);
4690 while (phba
->sli4_hba
.curr_disp_cpu
< phba
->sli4_hba
.num_present_cpu
) {
4691 cpup
= &phba
->sli4_hba
.cpu_map
[phba
->sli4_hba
.curr_disp_cpu
];
4693 /* margin should fit in this and the truncated message */
4694 if (cpup
->irq
== LPFC_VECTOR_MAP_EMPTY
)
4695 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4696 "CPU %02d io_chan %02d "
4697 "physid %d coreid %d\n",
4698 phba
->sli4_hba
.curr_disp_cpu
,
4699 cpup
->channel_id
, cpup
->phys_id
,
4702 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4703 "CPU %02d io_chan %02d "
4704 "physid %d coreid %d IRQ %d\n",
4705 phba
->sli4_hba
.curr_disp_cpu
,
4706 cpup
->channel_id
, cpup
->phys_id
,
4707 cpup
->core_id
, cpup
->irq
);
4709 phba
->sli4_hba
.curr_disp_cpu
++;
4711 /* display max number of CPUs keeping some margin */
4712 if (phba
->sli4_hba
.curr_disp_cpu
<
4713 phba
->sli4_hba
.num_present_cpu
&&
4714 (len
>= (PAGE_SIZE
- 64))) {
4715 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "more...\n");
4720 if (phba
->sli4_hba
.curr_disp_cpu
== phba
->sli4_hba
.num_present_cpu
)
4721 phba
->sli4_hba
.curr_disp_cpu
= 0;
4727 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
4728 * @dev: class device that is converted into a Scsi_host.
4729 * @attr: device attribute, not used.
4730 * @buf: one or more lpfc_polling_flags values.
4734 * -EINVAL - Not implemented yet.
4737 lpfc_fcp_cpu_map_store(struct device
*dev
, struct device_attribute
*attr
,
4738 const char *buf
, size_t count
)
4740 int status
= -EINVAL
;
4745 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
4748 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
4749 # 0 - Do not affinitze IRQ vectors
4750 # 1 - Affintize HBA vectors with respect to each HBA
4751 # (start with CPU0 for each HBA)
4752 # 2 - Affintize HBA vectors with respect to the entire driver
4753 # (round robin thru all CPUs across all HBAs)
4755 static int lpfc_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4756 module_param(lpfc_fcp_cpu_map
, int, S_IRUGO
|S_IWUSR
);
4757 MODULE_PARM_DESC(lpfc_fcp_cpu_map
,
4758 "Defines how to map CPUs to IRQ vectors per HBA");
4761 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
4762 * @phba: lpfc_hba pointer.
4763 * @val: link speed value.
4766 * If val is in a valid range [0-2], then affinitze the adapter's
4770 * zero if val saved.
4771 * -EINVAL val out of range
4774 lpfc_fcp_cpu_map_init(struct lpfc_hba
*phba
, int val
)
4776 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4777 phba
->cfg_fcp_cpu_map
= 0;
4781 if (val
>= LPFC_MIN_CPU_MAP
&& val
<= LPFC_MAX_CPU_MAP
) {
4782 phba
->cfg_fcp_cpu_map
= val
;
4786 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4787 "3326 lpfc_fcp_cpu_map: %d out of range, using "
4789 phba
->cfg_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4794 static DEVICE_ATTR_RW(lpfc_fcp_cpu_map
);
4797 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
4798 # Value range is [2,3]. Default value is 3.
4800 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
4801 "Select Fibre Channel class of service for FCP sequences");
4804 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
4805 # is [0,1]. Default value is 0.
4807 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
4808 "Use ADISC on rediscovery to authenticate FCP devices");
4811 # lpfc_first_burst_size: First burst size to use on the NPorts
4812 # that support first burst.
4813 # Value range is [0,65536]. Default value is 0.
4815 LPFC_VPORT_ATTR_RW(first_burst_size
, 0, 0, 65536,
4816 "First burst size for Targets that support first burst");
4819 * lpfc_nvmet_fb_size: NVME Target mode supported first burst size.
4820 * When the driver is configured as an NVME target, this value is
4821 * communicated to the NVME initiator in the PRLI response. It is
4822 * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support
4823 * parameters are set and the target is sending the PRLI RSP.
4824 * Parameter supported on physical port only - no NPIV support.
4825 * Value range is [0,65536]. Default value is 0.
4827 LPFC_ATTR_RW(nvmet_fb_size
, 0, 0, 65536,
4828 "NVME Target mode first burst size in 512B increments.");
4831 * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
4832 * For the Initiator (I), enabling this parameter means that an NVMET
4833 * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be
4834 * processed by the initiator for subsequent NVME FCP IO. For the target
4835 * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size
4836 * driver parameter as the target function's first burst size returned to the
4837 * initiator in the target's NVME PRLI response. Parameter supported on physical
4838 * port only - no NPIV support.
4839 * Value range is [0,1]. Default value is 0 (disabled).
4841 LPFC_ATTR_RW(nvme_enable_fb
, 0, 0, 1,
4842 "Enable First Burst feature on I and T functions.");
4845 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
4846 # depth. Default value is 0. When the value of this parameter is zero the
4847 # SCSI command completion time is not used for controlling I/O queue depth. When
4848 # the parameter is set to a non-zero value, the I/O queue depth is controlled
4849 # to limit the I/O completion time to the parameter value.
4850 # The value is set in milliseconds.
4852 LPFC_VPORT_ATTR(max_scsicmpl_time
, 0, 0, 60000,
4853 "Use command completion time to control queue depth");
4855 lpfc_vport_param_show(max_scsicmpl_time
);
4857 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
4859 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
4860 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
4862 if (val
== vport
->cfg_max_scsicmpl_time
)
4864 if ((val
< 0) || (val
> 60000))
4866 vport
->cfg_max_scsicmpl_time
= val
;
4868 spin_lock_irq(shost
->host_lock
);
4869 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4870 if (!NLP_CHK_NODE_ACT(ndlp
))
4872 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
4874 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
4876 spin_unlock_irq(shost
->host_lock
);
4879 lpfc_vport_param_store(max_scsicmpl_time
);
4880 static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time
);
4883 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
4884 # range is [0,1]. Default value is 0.
4886 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
4889 * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds
4890 * range is [0,1]. Default value is 0.
4891 * For [0], FCP commands are issued to Work Queues ina round robin fashion.
4892 * For [1], FCP commands are issued to a Work Queue associated with the
4895 * LPFC_FCP_SCHED_ROUND_ROBIN == 0
4896 * LPFC_FCP_SCHED_BY_CPU == 1
4898 * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu
4899 * affinity for FCP/NVME I/Os through Work Queues associated with the current
4900 * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os
4901 * through WQs will be used.
4903 LPFC_ATTR_RW(fcp_io_sched
, LPFC_FCP_SCHED_ROUND_ROBIN
,
4904 LPFC_FCP_SCHED_ROUND_ROBIN
,
4905 LPFC_FCP_SCHED_BY_CPU
,
4906 "Determine scheduling algorithm for "
4907 "issuing commands [0] - Round Robin, [1] - Current CPU");
4910 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
4911 # range is [0,1]. Default value is 0.
4912 # For [0], bus reset issues target reset to ALL devices
4913 # For [1], bus reset issues target reset to non-FCP2 devices
4915 LPFC_ATTR_RW(fcp2_no_tgt_reset
, 0, 0, 1, "Determine bus reset behavior for "
4916 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
4920 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
4921 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
4922 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
4923 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
4924 # cr_delay is set to 0.
4926 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
4927 "interrupt response is generated");
4929 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
4930 "interrupt response is generated");
4933 # lpfc_multi_ring_support: Determines how many rings to spread available
4934 # cmd/rsp IOCB entries across.
4935 # Value range is [1,2]. Default value is 1.
4937 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
4938 "SLI rings to spread IOCB entries across");
4941 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
4942 # identifies what rctl value to configure the additional ring for.
4943 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
4945 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
4946 255, "Identifies RCTL for additional ring configuration");
4949 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
4950 # identifies what type value to configure the additional ring for.
4951 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
4953 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
4954 255, "Identifies TYPE for additional ring configuration");
4957 # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN
4958 # 0 = SmartSAN functionality disabled (default)
4959 # 1 = SmartSAN functionality enabled
4960 # This parameter will override the value of lpfc_fdmi_on module parameter.
4961 # Value range is [0,1]. Default value is 0.
4963 LPFC_ATTR_R(enable_SmartSAN
, 0, 0, 1, "Enable SmartSAN functionality");
4966 # lpfc_fdmi_on: Controls FDMI support.
4967 # 0 No FDMI support (default)
4968 # 1 Traditional FDMI support
4969 # Traditional FDMI support means the driver will assume FDMI-2 support;
4970 # however, if that fails, it will fallback to FDMI-1.
4971 # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on.
4972 # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of
4974 # Value range [0,1]. Default value is 0.
4976 LPFC_ATTR_R(fdmi_on
, 0, 0, 1, "Enable FDMI support");
4979 # Specifies the maximum number of ELS cmds we can have outstanding (for
4980 # discovery). Value range is [1,64]. Default value = 32.
4982 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
4983 "during discovery");
4986 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
4987 # will be scanned by the SCSI midlayer when sequential scanning is
4988 # used; and is also the highest LUN ID allowed when the SCSI midlayer
4989 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
4990 # LUN ID limit, but the SCSI midlayer requires this field for the uses
4991 # above. The lpfc driver limits the default value to 255 for two reasons.
4992 # As it bounds the sequential scan loop, scanning for thousands of luns
4993 # on a target can take minutes of wall clock time. Additionally,
4994 # there are FC targets, such as JBODs, that only recognize 8-bits of
4995 # LUN ID. When they receive a value greater than 8 bits, they chop off
4996 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
4997 # and so on all as LUN ID 0. This causes the linux kernel, which sees
4998 # valid responses at each of the LUN IDs, to believe there are multiple
4999 # devices present, when in fact, there is only 1.
5000 # A customer that is aware of their target behaviors, and the results as
5001 # indicated above, is welcome to increase the lpfc_max_luns value.
5002 # As mentioned, this value is not used by the lpfc driver, only the
5004 # Value range is [0,65535]. Default value is 255.
5005 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
5007 LPFC_VPORT_ULL_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN ID");
5010 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
5011 # Value range is [1,255], default value is 10.
5013 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
5014 "Milliseconds driver will wait between polling FCP ring");
5017 # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands
5018 # to complete in seconds. Value range is [5,180], default value is 60.
5020 LPFC_ATTR_RW(task_mgmt_tmo
, 60, 5, 180,
5021 "Maximum time to wait for task management commands to complete");
5023 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
5024 # support this feature
5027 # 2 = MSI-X enabled (default)
5028 # Value range is [0,2]. Default value is 2.
5030 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
5031 "MSI-X (2), if possible");
5034 * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs
5036 * 0 = NVME OAS disabled
5037 * 1 = NVME OAS enabled
5039 * Value range is [0,1]. Default value is 0.
5041 LPFC_ATTR_RW(nvme_oas
, 0, 0, 1,
5042 "Use OAS bit on NVME IOs");
5045 * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver
5046 * will advertise it supports to the SCSI layer. This also will map to
5047 * the number of WQs the driver will create.
5049 * 0 = Configure the number of io channels to the number of active CPUs.
5050 * 1,32 = Manually specify how many io channels to use.
5052 * Value range is [0,32]. Default value is 4.
5054 LPFC_ATTR_R(fcp_io_channel
,
5055 LPFC_FCP_IO_CHAN_DEF
,
5056 LPFC_HBA_IO_CHAN_MIN
, LPFC_HBA_IO_CHAN_MAX
,
5057 "Set the number of FCP I/O channels");
5060 * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver
5061 * will advertise it supports to the NVME layer. This also will map to
5062 * the number of WQs the driver will create.
5064 * This module parameter is valid when lpfc_enable_fc4_type is set
5067 * The NVME Layer will try to create this many, plus 1 administrative
5068 * hardware queue. The administrative queue will always map to WQ 0
5069 * A hardware IO queue maps (qidx) to a specific driver WQ.
5071 * 0 = Configure the number of io channels to the number of active CPUs.
5072 * 1,32 = Manually specify how many io channels to use.
5074 * Value range is [0,32]. Default value is 0.
5076 LPFC_ATTR_R(nvme_io_channel
,
5077 LPFC_NVME_IO_CHAN_DEF
,
5078 LPFC_HBA_IO_CHAN_MIN
, LPFC_HBA_IO_CHAN_MAX
,
5079 "Set the number of NVME I/O channels");
5082 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
5083 # 0 = HBA resets disabled
5084 # 1 = HBA resets enabled (default)
5085 # Value range is [0,1]. Default value is 1.
5087 LPFC_ATTR_R(enable_hba_reset
, 1, 0, 1, "Enable HBA resets from the driver.");
5090 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
5091 # 0 = HBA Heartbeat disabled
5092 # 1 = HBA Heartbeat enabled (default)
5093 # Value range is [0,1]. Default value is 1.
5095 LPFC_ATTR_R(enable_hba_heartbeat
, 0, 0, 1, "Enable HBA Heartbeat.");
5098 # lpfc_EnableXLane: Enable Express Lane Feature
5099 # 0x0 Express Lane Feature disabled
5100 # 0x1 Express Lane Feature enabled
5101 # Value range is [0,1]. Default value is 0.
5103 LPFC_ATTR_R(EnableXLane
, 0, 0, 1, "Enable Express Lane Feature.");
5106 # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature
5107 # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits)
5108 # Value range is [0x0,0x7f]. Default value is 0
5110 LPFC_ATTR_RW(XLanePriority
, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
5113 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
5114 # 0 = BlockGuard disabled (default)
5115 # 1 = BlockGuard enabled
5116 # Value range is [0,1]. Default value is 0.
5118 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
5121 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
5122 # 0 = disabled (default)
5124 # Value range is [0,1]. Default value is 0.
5126 # This feature in under investigation and may be supported in the future.
5128 unsigned int lpfc_fcp_look_ahead
= LPFC_LOOK_AHEAD_OFF
;
5132 # - Bit mask of host protection capabilities used to register with the
5134 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
5135 # - Allows you to ultimately specify which profiles to use
5136 # - Default will result in registering capabilities for all profiles.
5137 # - SHOST_DIF_TYPE1_PROTECTION 1
5138 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
5139 # - SHOST_DIX_TYPE0_PROTECTION 8
5140 # HBA supports DIX Type 0: Host to HBA protection only
5141 # - SHOST_DIX_TYPE1_PROTECTION 16
5142 # HBA supports DIX Type 1: Host to HBA Type 1 protection
5145 LPFC_ATTR(prot_mask
,
5146 (SHOST_DIF_TYPE1_PROTECTION
|
5147 SHOST_DIX_TYPE0_PROTECTION
|
5148 SHOST_DIX_TYPE1_PROTECTION
),
5150 (SHOST_DIF_TYPE1_PROTECTION
|
5151 SHOST_DIX_TYPE0_PROTECTION
|
5152 SHOST_DIX_TYPE1_PROTECTION
),
5153 "T10-DIF host protection capabilities mask");
5156 # lpfc_prot_guard: i
5157 # - Bit mask of protection guard types to register with the SCSI mid-layer
5158 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
5159 # - Allows you to ultimately specify which profiles to use
5160 # - Default will result in registering capabilities for all guard types
5163 LPFC_ATTR(prot_guard
,
5164 SHOST_DIX_GUARD_IP
, SHOST_DIX_GUARD_CRC
, SHOST_DIX_GUARD_IP
,
5165 "T10-DIF host protection guard type");
5168 * Delay initial NPort discovery when Clean Address bit is cleared in
5169 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
5170 * This parameter can have value 0 or 1.
5171 * When this parameter is set to 0, no delay is added to the initial
5173 * When this parameter is set to non-zero value, initial Nport discovery is
5174 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
5175 * accept and FCID/Fabric name/Fabric portname is changed.
5176 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
5177 * when Clean Address bit is cleared in FLOGI/FDISC
5178 * accept and FCID/Fabric name/Fabric portname is changed.
5179 * Default value is 0.
5181 LPFC_ATTR(delay_discovery
, 0, 0, 1,
5182 "Delay NPort discovery when Clean Address bit is cleared.");
5185 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
5186 * This value can be set to values between 64 and 4096. The default value is
5187 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
5188 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
5189 * Because of the additional overhead involved in setting up T10-DIF,
5190 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
5191 * and will be limited to 512 if BlockGuard is enabled under SLI3.
5193 LPFC_ATTR_R(sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
, LPFC_MIN_SG_SEG_CNT
,
5194 LPFC_MAX_SG_SEG_CNT
, "Max Scatter Gather Segment Count");
5197 * lpfc_enable_mds_diags: Enable MDS Diagnostics
5198 * 0 = MDS Diagnostics disabled (default)
5199 * 1 = MDS Diagnostics enabled
5200 * Value range is [0,1]. Default value is 0.
5202 LPFC_ATTR_R(enable_mds_diags
, 0, 0, 1, "Enable MDS Diagnostics");
5205 * lpfc_enable_bbcr: Enable BB Credit Recovery
5206 * 0 = BB Credit Recovery disabled
5207 * 1 = BB Credit Recovery enabled (default)
5208 * Value range is [0,1]. Default value is 1.
5210 LPFC_BBCR_ATTR_RW(enable_bbcr
, 1, 0, 1, "Enable BBC Recovery");
5213 * lpfc_enable_dpp: Enable DPP on G7
5214 * 0 = DPP on G7 disabled
5215 * 1 = DPP on G7 enabled (default)
5216 * Value range is [0,1]. Default value is 1.
5218 LPFC_ATTR_RW(enable_dpp
, 1, 0, 1, "Enable Direct Packet Push");
5220 struct device_attribute
*lpfc_hba_attrs
[] = {
5221 &dev_attr_nvme_info
,
5223 &dev_attr_bg_guard_err
,
5224 &dev_attr_bg_apptag_err
,
5225 &dev_attr_bg_reftag_err
,
5227 &dev_attr_serialnum
,
5228 &dev_attr_modeldesc
,
5229 &dev_attr_modelname
,
5230 &dev_attr_programtype
,
5234 &dev_attr_option_rom_version
,
5235 &dev_attr_link_state
,
5236 &dev_attr_num_discovered_ports
,
5237 &dev_attr_menlo_mgmt_mode
,
5238 &dev_attr_lpfc_drvr_version
,
5239 &dev_attr_lpfc_enable_fip
,
5240 &dev_attr_lpfc_temp_sensor
,
5241 &dev_attr_lpfc_log_verbose
,
5242 &dev_attr_lpfc_lun_queue_depth
,
5243 &dev_attr_lpfc_tgt_queue_depth
,
5244 &dev_attr_lpfc_hba_queue_depth
,
5245 &dev_attr_lpfc_peer_port_login
,
5246 &dev_attr_lpfc_nodev_tmo
,
5247 &dev_attr_lpfc_devloss_tmo
,
5248 &dev_attr_lpfc_enable_fc4_type
,
5249 &dev_attr_lpfc_xri_split
,
5250 &dev_attr_lpfc_fcp_class
,
5251 &dev_attr_lpfc_use_adisc
,
5252 &dev_attr_lpfc_first_burst_size
,
5253 &dev_attr_lpfc_ack0
,
5254 &dev_attr_lpfc_topology
,
5255 &dev_attr_lpfc_scan_down
,
5256 &dev_attr_lpfc_link_speed
,
5257 &dev_attr_lpfc_fcp_io_sched
,
5258 &dev_attr_lpfc_fcp2_no_tgt_reset
,
5259 &dev_attr_lpfc_cr_delay
,
5260 &dev_attr_lpfc_cr_count
,
5261 &dev_attr_lpfc_multi_ring_support
,
5262 &dev_attr_lpfc_multi_ring_rctl
,
5263 &dev_attr_lpfc_multi_ring_type
,
5264 &dev_attr_lpfc_fdmi_on
,
5265 &dev_attr_lpfc_enable_SmartSAN
,
5266 &dev_attr_lpfc_max_luns
,
5267 &dev_attr_lpfc_enable_npiv
,
5268 &dev_attr_lpfc_fcf_failover_policy
,
5269 &dev_attr_lpfc_enable_rrq
,
5270 &dev_attr_nport_evt_cnt
,
5271 &dev_attr_board_mode
,
5278 &dev_attr_npiv_info
,
5279 &dev_attr_issue_reset
,
5280 &dev_attr_lpfc_poll
,
5281 &dev_attr_lpfc_poll_tmo
,
5282 &dev_attr_lpfc_task_mgmt_tmo
,
5283 &dev_attr_lpfc_use_msi
,
5284 &dev_attr_lpfc_nvme_oas
,
5285 &dev_attr_lpfc_auto_imax
,
5286 &dev_attr_lpfc_fcp_imax
,
5287 &dev_attr_lpfc_fcp_cpu_map
,
5288 &dev_attr_lpfc_fcp_io_channel
,
5289 &dev_attr_lpfc_suppress_rsp
,
5290 &dev_attr_lpfc_nvme_io_channel
,
5291 &dev_attr_lpfc_nvmet_mrq
,
5292 &dev_attr_lpfc_nvme_enable_fb
,
5293 &dev_attr_lpfc_nvmet_fb_size
,
5294 &dev_attr_lpfc_enable_bg
,
5295 &dev_attr_lpfc_soft_wwnn
,
5296 &dev_attr_lpfc_soft_wwpn
,
5297 &dev_attr_lpfc_soft_wwn_enable
,
5298 &dev_attr_lpfc_enable_hba_reset
,
5299 &dev_attr_lpfc_enable_hba_heartbeat
,
5300 &dev_attr_lpfc_EnableXLane
,
5301 &dev_attr_lpfc_XLanePriority
,
5302 &dev_attr_lpfc_xlane_lun
,
5303 &dev_attr_lpfc_xlane_tgt
,
5304 &dev_attr_lpfc_xlane_vpt
,
5305 &dev_attr_lpfc_xlane_lun_state
,
5306 &dev_attr_lpfc_xlane_lun_status
,
5307 &dev_attr_lpfc_xlane_priority
,
5308 &dev_attr_lpfc_sg_seg_cnt
,
5309 &dev_attr_lpfc_max_scsicmpl_time
,
5310 &dev_attr_lpfc_stat_data_ctrl
,
5311 &dev_attr_lpfc_aer_support
,
5312 &dev_attr_lpfc_aer_state_cleanup
,
5313 &dev_attr_lpfc_sriov_nr_virtfn
,
5314 &dev_attr_lpfc_req_fw_upgrade
,
5315 &dev_attr_lpfc_suppress_link_up
,
5316 &dev_attr_lpfc_iocb_cnt
,
5319 &dev_attr_txcmplq_hw
,
5320 &dev_attr_lpfc_fips_level
,
5321 &dev_attr_lpfc_fips_rev
,
5323 &dev_attr_lpfc_sriov_hw_max_virtfn
,
5325 &dev_attr_lpfc_xlane_supported
,
5326 &dev_attr_lpfc_enable_mds_diags
,
5327 &dev_attr_lpfc_enable_bbcr
,
5328 &dev_attr_lpfc_enable_dpp
,
5332 struct device_attribute
*lpfc_vport_attrs
[] = {
5334 &dev_attr_link_state
,
5335 &dev_attr_num_discovered_ports
,
5336 &dev_attr_lpfc_drvr_version
,
5337 &dev_attr_lpfc_log_verbose
,
5338 &dev_attr_lpfc_lun_queue_depth
,
5339 &dev_attr_lpfc_tgt_queue_depth
,
5340 &dev_attr_lpfc_nodev_tmo
,
5341 &dev_attr_lpfc_devloss_tmo
,
5342 &dev_attr_lpfc_hba_queue_depth
,
5343 &dev_attr_lpfc_peer_port_login
,
5344 &dev_attr_lpfc_restrict_login
,
5345 &dev_attr_lpfc_fcp_class
,
5346 &dev_attr_lpfc_use_adisc
,
5347 &dev_attr_lpfc_first_burst_size
,
5348 &dev_attr_lpfc_max_luns
,
5349 &dev_attr_nport_evt_cnt
,
5350 &dev_attr_npiv_info
,
5351 &dev_attr_lpfc_enable_da_id
,
5352 &dev_attr_lpfc_max_scsicmpl_time
,
5353 &dev_attr_lpfc_stat_data_ctrl
,
5354 &dev_attr_lpfc_static_vport
,
5355 &dev_attr_lpfc_fips_level
,
5356 &dev_attr_lpfc_fips_rev
,
5361 * sysfs_ctlreg_write - Write method for writing to ctlreg
5362 * @filp: open sysfs file
5363 * @kobj: kernel kobject that contains the kernel class device.
5364 * @bin_attr: kernel attributes passed to us.
5365 * @buf: contains the data to be written to the adapter IOREG space.
5366 * @off: offset into buffer to beginning of data.
5367 * @count: bytes to transfer.
5370 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5371 * Uses the adapter io control registers to send buf contents to the adapter.
5374 * -ERANGE off and count combo out of range
5375 * -EINVAL off, count or buff address invalid
5376 * -EPERM adapter is offline
5377 * value of count, buf contents written
5380 sysfs_ctlreg_write(struct file
*filp
, struct kobject
*kobj
,
5381 struct bin_attribute
*bin_attr
,
5382 char *buf
, loff_t off
, size_t count
)
5385 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
5386 struct Scsi_Host
*shost
= class_to_shost(dev
);
5387 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5388 struct lpfc_hba
*phba
= vport
->phba
;
5390 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5393 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5396 if (count
<= LPFC_REG_WRITE_KEY_SIZE
)
5399 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5402 /* This is to protect HBA registers from accidental writes. */
5403 if (memcmp(buf
, LPFC_REG_WRITE_KEY
, LPFC_REG_WRITE_KEY_SIZE
))
5406 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
))
5409 spin_lock_irq(&phba
->hbalock
);
5410 for (buf_off
= 0; buf_off
< count
- LPFC_REG_WRITE_KEY_SIZE
;
5411 buf_off
+= sizeof(uint32_t))
5412 writel(*((uint32_t *)(buf
+ buf_off
+ LPFC_REG_WRITE_KEY_SIZE
)),
5413 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5415 spin_unlock_irq(&phba
->hbalock
);
5421 * sysfs_ctlreg_read - Read method for reading from ctlreg
5422 * @filp: open sysfs file
5423 * @kobj: kernel kobject that contains the kernel class device.
5424 * @bin_attr: kernel attributes passed to us.
5425 * @buf: if successful contains the data from the adapter IOREG space.
5426 * @off: offset into buffer to beginning of data.
5427 * @count: bytes to transfer.
5430 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5431 * Uses the adapter io control registers to read data into buf.
5434 * -ERANGE off and count combo out of range
5435 * -EINVAL off, count or buff address invalid
5436 * value of count, buf contents read
5439 sysfs_ctlreg_read(struct file
*filp
, struct kobject
*kobj
,
5440 struct bin_attribute
*bin_attr
,
5441 char *buf
, loff_t off
, size_t count
)
5445 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
5446 struct Scsi_Host
*shost
= class_to_shost(dev
);
5447 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5448 struct lpfc_hba
*phba
= vport
->phba
;
5450 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5453 if (off
> FF_REG_AREA_SIZE
)
5456 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5457 count
= FF_REG_AREA_SIZE
- off
;
5459 if (count
== 0) return 0;
5461 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5464 spin_lock_irq(&phba
->hbalock
);
5466 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
5467 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
5468 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5471 spin_unlock_irq(&phba
->hbalock
);
5476 static struct bin_attribute sysfs_ctlreg_attr
= {
5479 .mode
= S_IRUSR
| S_IWUSR
,
5482 .read
= sysfs_ctlreg_read
,
5483 .write
= sysfs_ctlreg_write
,
5487 * sysfs_mbox_write - Write method for writing information via mbox
5488 * @filp: open sysfs file
5489 * @kobj: kernel kobject that contains the kernel class device.
5490 * @bin_attr: kernel attributes passed to us.
5491 * @buf: contains the data to be written to sysfs mbox.
5492 * @off: offset into buffer to beginning of data.
5493 * @count: bytes to transfer.
5496 * Deprecated function. All mailbox access from user space is performed via the
5500 * -EPERM operation not permitted
5503 sysfs_mbox_write(struct file
*filp
, struct kobject
*kobj
,
5504 struct bin_attribute
*bin_attr
,
5505 char *buf
, loff_t off
, size_t count
)
5511 * sysfs_mbox_read - Read method for reading information via mbox
5512 * @filp: open sysfs file
5513 * @kobj: kernel kobject that contains the kernel class device.
5514 * @bin_attr: kernel attributes passed to us.
5515 * @buf: contains the data to be read from sysfs mbox.
5516 * @off: offset into buffer to beginning of data.
5517 * @count: bytes to transfer.
5520 * Deprecated function. All mailbox access from user space is performed via the
5524 * -EPERM operation not permitted
5527 sysfs_mbox_read(struct file
*filp
, struct kobject
*kobj
,
5528 struct bin_attribute
*bin_attr
,
5529 char *buf
, loff_t off
, size_t count
)
5534 static struct bin_attribute sysfs_mbox_attr
= {
5537 .mode
= S_IRUSR
| S_IWUSR
,
5539 .size
= MAILBOX_SYSFS_MAX
,
5540 .read
= sysfs_mbox_read
,
5541 .write
= sysfs_mbox_write
,
5545 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
5546 * @vport: address of lpfc vport structure.
5550 * error return code from sysfs_create_bin_file()
5553 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
5555 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5558 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5559 &sysfs_drvr_stat_data_attr
);
5561 /* Virtual ports do not need ctrl_reg and mbox */
5562 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
5565 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5566 &sysfs_ctlreg_attr
);
5568 goto out_remove_stat_attr
;
5570 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5573 goto out_remove_ctlreg_attr
;
5576 out_remove_ctlreg_attr
:
5577 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5578 out_remove_stat_attr
:
5579 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5580 &sysfs_drvr_stat_data_attr
);
5586 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
5587 * @vport: address of lpfc vport structure.
5590 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
5592 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5593 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5594 &sysfs_drvr_stat_data_attr
);
5595 /* Virtual ports do not need ctrl_reg and mbox */
5596 if (vport
->port_type
== LPFC_NPIV_PORT
)
5598 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
5599 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5603 * Dynamic FC Host Attributes Support
5607 * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host
5608 * @shost: kernel scsi host pointer.
5611 lpfc_get_host_symbolic_name(struct Scsi_Host
*shost
)
5613 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5615 lpfc_vport_symbolic_node_name(vport
, fc_host_symbolic_name(shost
),
5616 sizeof fc_host_symbolic_name(shost
));
5620 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
5621 * @shost: kernel scsi host pointer.
5624 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
5626 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5628 /* note: fc_myDID already in cpu endianness */
5629 fc_host_port_id(shost
) = vport
->fc_myDID
;
5633 * lpfc_get_host_port_type - Set the value of the scsi host port type
5634 * @shost: kernel scsi host pointer.
5637 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
5639 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5640 struct lpfc_hba
*phba
= vport
->phba
;
5642 spin_lock_irq(shost
->host_lock
);
5644 if (vport
->port_type
== LPFC_NPIV_PORT
) {
5645 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
5646 } else if (lpfc_is_link_up(phba
)) {
5647 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5648 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
5649 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
5651 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
5653 if (vport
->fc_flag
& FC_FABRIC
)
5654 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
5656 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
5659 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
5661 spin_unlock_irq(shost
->host_lock
);
5665 * lpfc_get_host_port_state - Set the value of the scsi host port state
5666 * @shost: kernel scsi host pointer.
5669 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
5671 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5672 struct lpfc_hba
*phba
= vport
->phba
;
5674 spin_lock_irq(shost
->host_lock
);
5676 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5677 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
5679 switch (phba
->link_state
) {
5680 case LPFC_LINK_UNKNOWN
:
5681 case LPFC_LINK_DOWN
:
5682 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
5686 case LPFC_HBA_READY
:
5687 /* Links up, reports port state accordingly */
5688 if (vport
->port_state
< LPFC_VPORT_READY
)
5689 fc_host_port_state(shost
) =
5690 FC_PORTSTATE_BYPASSED
;
5692 fc_host_port_state(shost
) =
5693 FC_PORTSTATE_ONLINE
;
5695 case LPFC_HBA_ERROR
:
5696 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
5699 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
5704 spin_unlock_irq(shost
->host_lock
);
5708 * lpfc_get_host_speed - Set the value of the scsi host speed
5709 * @shost: kernel scsi host pointer.
5712 lpfc_get_host_speed(struct Scsi_Host
*shost
)
5714 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5715 struct lpfc_hba
*phba
= vport
->phba
;
5717 spin_lock_irq(shost
->host_lock
);
5719 if ((lpfc_is_link_up(phba
)) && (!(phba
->hba_flag
& HBA_FCOE_MODE
))) {
5720 switch(phba
->fc_linkspeed
) {
5721 case LPFC_LINK_SPEED_1GHZ
:
5722 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
5724 case LPFC_LINK_SPEED_2GHZ
:
5725 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
5727 case LPFC_LINK_SPEED_4GHZ
:
5728 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
5730 case LPFC_LINK_SPEED_8GHZ
:
5731 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
5733 case LPFC_LINK_SPEED_10GHZ
:
5734 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
5736 case LPFC_LINK_SPEED_16GHZ
:
5737 fc_host_speed(shost
) = FC_PORTSPEED_16GBIT
;
5739 case LPFC_LINK_SPEED_32GHZ
:
5740 fc_host_speed(shost
) = FC_PORTSPEED_32GBIT
;
5742 case LPFC_LINK_SPEED_64GHZ
:
5743 fc_host_speed(shost
) = FC_PORTSPEED_64GBIT
;
5746 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5750 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5752 spin_unlock_irq(shost
->host_lock
);
5756 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
5757 * @shost: kernel scsi host pointer.
5760 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
5762 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5763 struct lpfc_hba
*phba
= vport
->phba
;
5766 spin_lock_irq(shost
->host_lock
);
5768 if ((vport
->port_state
> LPFC_FLOGI
) &&
5769 ((vport
->fc_flag
& FC_FABRIC
) ||
5770 ((phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) &&
5771 (vport
->fc_flag
& FC_PUBLIC_LOOP
))))
5772 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
5774 /* fabric is local port if there is no F/FL_Port */
5777 spin_unlock_irq(shost
->host_lock
);
5779 fc_host_fabric_name(shost
) = node_name
;
5783 * lpfc_get_stats - Return statistical information about the adapter
5784 * @shost: kernel scsi host pointer.
5787 * NULL on error for link down, no mbox pool, sli2 active,
5788 * management not allowed, memory allocation error, or mbox error.
5792 * address of the adapter host statistics
5794 static struct fc_host_statistics
*
5795 lpfc_get_stats(struct Scsi_Host
*shost
)
5797 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5798 struct lpfc_hba
*phba
= vport
->phba
;
5799 struct lpfc_sli
*psli
= &phba
->sli
;
5800 struct fc_host_statistics
*hs
= &phba
->link_stats
;
5801 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
5802 LPFC_MBOXQ_t
*pmboxq
;
5804 unsigned long seconds
;
5808 * prevent udev from issuing mailbox commands until the port is
5811 if (phba
->link_state
< LPFC_LINK_DOWN
||
5812 !phba
->mbox_mem_pool
||
5813 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
5816 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5819 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5822 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5824 pmb
= &pmboxq
->u
.mb
;
5825 pmb
->mbxCommand
= MBX_READ_STATUS
;
5826 pmb
->mbxOwner
= OWN_HOST
;
5827 pmboxq
->context1
= NULL
;
5828 pmboxq
->vport
= vport
;
5830 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5831 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5833 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5835 if (rc
!= MBX_SUCCESS
) {
5836 if (rc
!= MBX_TIMEOUT
)
5837 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5841 memset(hs
, 0, sizeof (struct fc_host_statistics
));
5843 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
5845 * The MBX_READ_STATUS returns tx_k_bytes which has to
5846 * converted to words
5848 hs
->tx_words
= (uint64_t)
5849 ((uint64_t)pmb
->un
.varRdStatus
.xmitByteCnt
5851 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
5852 hs
->rx_words
= (uint64_t)
5853 ((uint64_t)pmb
->un
.varRdStatus
.rcvByteCnt
5856 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5857 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5858 pmb
->mbxOwner
= OWN_HOST
;
5859 pmboxq
->context1
= NULL
;
5860 pmboxq
->vport
= vport
;
5862 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5863 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5865 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5867 if (rc
!= MBX_SUCCESS
) {
5868 if (rc
!= MBX_TIMEOUT
)
5869 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5873 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5874 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5875 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5876 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5877 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5878 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5879 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5881 hs
->link_failure_count
-= lso
->link_failure_count
;
5882 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
5883 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
5884 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
5885 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
5886 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
5887 hs
->error_frames
-= lso
->error_frames
;
5889 if (phba
->hba_flag
& HBA_FCOE_MODE
) {
5891 hs
->nos_count
= (phba
->link_events
>> 1);
5892 hs
->nos_count
-= lso
->link_events
;
5893 } else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5894 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
5895 hs
->lip_count
-= lso
->link_events
;
5899 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
5900 hs
->nos_count
-= lso
->link_events
;
5903 hs
->dumped_frames
= -1;
5905 seconds
= get_seconds();
5906 if (seconds
< psli
->stats_start
)
5907 hs
->seconds_since_last_reset
= seconds
+
5908 ((unsigned long)-1 - psli
->stats_start
);
5910 hs
->seconds_since_last_reset
= seconds
- psli
->stats_start
;
5912 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5918 * lpfc_reset_stats - Copy the adapter link stats information
5919 * @shost: kernel scsi host pointer.
5922 lpfc_reset_stats(struct Scsi_Host
*shost
)
5924 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5925 struct lpfc_hba
*phba
= vport
->phba
;
5926 struct lpfc_sli
*psli
= &phba
->sli
;
5927 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
5928 LPFC_MBOXQ_t
*pmboxq
;
5932 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5935 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5938 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5940 pmb
= &pmboxq
->u
.mb
;
5941 pmb
->mbxCommand
= MBX_READ_STATUS
;
5942 pmb
->mbxOwner
= OWN_HOST
;
5943 pmb
->un
.varWords
[0] = 0x1; /* reset request */
5944 pmboxq
->context1
= NULL
;
5945 pmboxq
->vport
= vport
;
5947 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5948 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5949 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5951 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5953 if (rc
!= MBX_SUCCESS
) {
5954 if (rc
!= MBX_TIMEOUT
)
5955 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5959 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5960 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5961 pmb
->mbxOwner
= OWN_HOST
;
5962 pmboxq
->context1
= NULL
;
5963 pmboxq
->vport
= vport
;
5965 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5966 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5967 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5969 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5971 if (rc
!= MBX_SUCCESS
) {
5972 if (rc
!= MBX_TIMEOUT
)
5973 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
5977 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5978 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5979 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5980 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5981 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5982 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5983 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5984 if (phba
->hba_flag
& HBA_FCOE_MODE
)
5985 lso
->link_events
= (phba
->link_events
>> 1);
5987 lso
->link_events
= (phba
->fc_eventTag
>> 1);
5989 psli
->stats_start
= get_seconds();
5991 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5997 * The LPFC driver treats linkdown handling as target loss events so there
5998 * are no sysfs handlers for link_down_tmo.
6002 * lpfc_get_node_by_target - Return the nodelist for a target
6003 * @starget: kernel scsi target pointer.
6006 * address of the node list if found
6007 * NULL target not found
6009 static struct lpfc_nodelist
*
6010 lpfc_get_node_by_target(struct scsi_target
*starget
)
6012 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
6013 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6014 struct lpfc_nodelist
*ndlp
;
6016 spin_lock_irq(shost
->host_lock
);
6017 /* Search for this, mapped, target ID */
6018 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
6019 if (NLP_CHK_NODE_ACT(ndlp
) &&
6020 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
6021 starget
->id
== ndlp
->nlp_sid
) {
6022 spin_unlock_irq(shost
->host_lock
);
6026 spin_unlock_irq(shost
->host_lock
);
6031 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
6032 * @starget: kernel scsi target pointer.
6035 lpfc_get_starget_port_id(struct scsi_target
*starget
)
6037 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6039 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
6043 * lpfc_get_starget_node_name - Set the target node name
6044 * @starget: kernel scsi target pointer.
6046 * Description: Set the target node name to the ndlp node name wwn or zero.
6049 lpfc_get_starget_node_name(struct scsi_target
*starget
)
6051 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6053 fc_starget_node_name(starget
) =
6054 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
6058 * lpfc_get_starget_port_name - Set the target port name
6059 * @starget: kernel scsi target pointer.
6061 * Description: set the target port name to the ndlp port name wwn or zero.
6064 lpfc_get_starget_port_name(struct scsi_target
*starget
)
6066 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6068 fc_starget_port_name(starget
) =
6069 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
6073 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
6074 * @rport: fc rport address.
6075 * @timeout: new value for dev loss tmo.
6078 * If timeout is non zero set the dev_loss_tmo to timeout, else set
6079 * dev_loss_tmo to one.
6082 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
6085 rport
->dev_loss_tmo
= timeout
;
6087 rport
->dev_loss_tmo
= 1;
6091 * lpfc_rport_show_function - Return rport target information
6094 * Macro that uses field to generate a function with the name lpfc_show_rport_
6096 * lpfc_show_rport_##field: returns the bytes formatted in buf
6097 * @cdev: class converted to an fc_rport.
6098 * @buf: on return contains the target_field or zero.
6100 * Returns: size of formatted string.
6102 #define lpfc_rport_show_function(field, format_string, sz, cast) \
6104 lpfc_show_rport_##field (struct device *dev, \
6105 struct device_attribute *attr, \
6108 struct fc_rport *rport = transport_class_to_rport(dev); \
6109 struct lpfc_rport_data *rdata = rport->hostdata; \
6110 return snprintf(buf, sz, format_string, \
6111 (rdata->target) ? cast rdata->target->field : 0); \
6114 #define lpfc_rport_rd_attr(field, format_string, sz) \
6115 lpfc_rport_show_function(field, format_string, sz, ) \
6116 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
6119 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
6120 * @fc_vport: The fc_vport who's symbolic name has been changed.
6123 * This function is called by the transport after the @fc_vport's symbolic name
6124 * has been changed. This function re-registers the symbolic name with the
6125 * switch to propagate the change into the fabric if the vport is active.
6128 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
6130 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
6132 if (vport
->port_state
== LPFC_VPORT_READY
)
6133 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
6137 * lpfc_hba_log_verbose_init - Set hba's log verbose level
6138 * @phba: Pointer to lpfc_hba struct.
6140 * This function is called by the lpfc_get_cfgparam() routine to set the
6141 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
6142 * log message according to the module's lpfc_log_verbose parameter setting
6143 * before hba port or vport created.
6146 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
6148 phba
->cfg_log_verbose
= verbose
;
6151 struct fc_function_template lpfc_transport_functions
= {
6152 /* fixed attributes the driver supports */
6153 .show_host_node_name
= 1,
6154 .show_host_port_name
= 1,
6155 .show_host_supported_classes
= 1,
6156 .show_host_supported_fc4s
= 1,
6157 .show_host_supported_speeds
= 1,
6158 .show_host_maxframe_size
= 1,
6160 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6161 .show_host_symbolic_name
= 1,
6163 /* dynamic attributes the driver supports */
6164 .get_host_port_id
= lpfc_get_host_port_id
,
6165 .show_host_port_id
= 1,
6167 .get_host_port_type
= lpfc_get_host_port_type
,
6168 .show_host_port_type
= 1,
6170 .get_host_port_state
= lpfc_get_host_port_state
,
6171 .show_host_port_state
= 1,
6173 /* active_fc4s is shown but doesn't change (thus no get function) */
6174 .show_host_active_fc4s
= 1,
6176 .get_host_speed
= lpfc_get_host_speed
,
6177 .show_host_speed
= 1,
6179 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6180 .show_host_fabric_name
= 1,
6183 * The LPFC driver treats linkdown handling as target loss events
6184 * so there are no sysfs handlers for link_down_tmo.
6187 .get_fc_host_stats
= lpfc_get_stats
,
6188 .reset_fc_host_stats
= lpfc_reset_stats
,
6190 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6191 .show_rport_maxframe_size
= 1,
6192 .show_rport_supported_classes
= 1,
6194 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6195 .show_rport_dev_loss_tmo
= 1,
6197 .get_starget_port_id
= lpfc_get_starget_port_id
,
6198 .show_starget_port_id
= 1,
6200 .get_starget_node_name
= lpfc_get_starget_node_name
,
6201 .show_starget_node_name
= 1,
6203 .get_starget_port_name
= lpfc_get_starget_port_name
,
6204 .show_starget_port_name
= 1,
6206 .issue_fc_host_lip
= lpfc_issue_lip
,
6207 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6208 .terminate_rport_io
= lpfc_terminate_rport_io
,
6210 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
6212 .vport_disable
= lpfc_vport_disable
,
6214 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6216 .bsg_request
= lpfc_bsg_request
,
6217 .bsg_timeout
= lpfc_bsg_timeout
,
6220 struct fc_function_template lpfc_vport_transport_functions
= {
6221 /* fixed attributes the driver supports */
6222 .show_host_node_name
= 1,
6223 .show_host_port_name
= 1,
6224 .show_host_supported_classes
= 1,
6225 .show_host_supported_fc4s
= 1,
6226 .show_host_supported_speeds
= 1,
6227 .show_host_maxframe_size
= 1,
6229 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6230 .show_host_symbolic_name
= 1,
6232 /* dynamic attributes the driver supports */
6233 .get_host_port_id
= lpfc_get_host_port_id
,
6234 .show_host_port_id
= 1,
6236 .get_host_port_type
= lpfc_get_host_port_type
,
6237 .show_host_port_type
= 1,
6239 .get_host_port_state
= lpfc_get_host_port_state
,
6240 .show_host_port_state
= 1,
6242 /* active_fc4s is shown but doesn't change (thus no get function) */
6243 .show_host_active_fc4s
= 1,
6245 .get_host_speed
= lpfc_get_host_speed
,
6246 .show_host_speed
= 1,
6248 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6249 .show_host_fabric_name
= 1,
6252 * The LPFC driver treats linkdown handling as target loss events
6253 * so there are no sysfs handlers for link_down_tmo.
6256 .get_fc_host_stats
= lpfc_get_stats
,
6257 .reset_fc_host_stats
= lpfc_reset_stats
,
6259 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6260 .show_rport_maxframe_size
= 1,
6261 .show_rport_supported_classes
= 1,
6263 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6264 .show_rport_dev_loss_tmo
= 1,
6266 .get_starget_port_id
= lpfc_get_starget_port_id
,
6267 .show_starget_port_id
= 1,
6269 .get_starget_node_name
= lpfc_get_starget_node_name
,
6270 .show_starget_node_name
= 1,
6272 .get_starget_port_name
= lpfc_get_starget_port_name
,
6273 .show_starget_port_name
= 1,
6275 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6276 .terminate_rport_io
= lpfc_terminate_rport_io
,
6278 .vport_disable
= lpfc_vport_disable
,
6280 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6284 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
6285 * @phba: lpfc_hba pointer.
6288 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
6290 lpfc_fcp_io_sched_init(phba
, lpfc_fcp_io_sched
);
6291 lpfc_fcp2_no_tgt_reset_init(phba
, lpfc_fcp2_no_tgt_reset
);
6292 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
6293 lpfc_cr_count_init(phba
, lpfc_cr_count
);
6294 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
6295 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
6296 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
6297 lpfc_ack0_init(phba
, lpfc_ack0
);
6298 lpfc_topology_init(phba
, lpfc_topology
);
6299 lpfc_link_speed_init(phba
, lpfc_link_speed
);
6300 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
6301 lpfc_task_mgmt_tmo_init(phba
, lpfc_task_mgmt_tmo
);
6302 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
6303 lpfc_fcf_failover_policy_init(phba
, lpfc_fcf_failover_policy
);
6304 lpfc_enable_rrq_init(phba
, lpfc_enable_rrq
);
6305 lpfc_fdmi_on_init(phba
, lpfc_fdmi_on
);
6306 lpfc_enable_SmartSAN_init(phba
, lpfc_enable_SmartSAN
);
6307 lpfc_use_msi_init(phba
, lpfc_use_msi
);
6308 lpfc_nvme_oas_init(phba
, lpfc_nvme_oas
);
6309 lpfc_auto_imax_init(phba
, lpfc_auto_imax
);
6310 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
6311 lpfc_fcp_cpu_map_init(phba
, lpfc_fcp_cpu_map
);
6312 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
6313 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
6315 lpfc_EnableXLane_init(phba
, lpfc_EnableXLane
);
6316 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
6317 phba
->cfg_EnableXLane
= 0;
6318 lpfc_XLanePriority_init(phba
, lpfc_XLanePriority
);
6320 memset(phba
->cfg_oas_tgt_wwpn
, 0, (8 * sizeof(uint8_t)));
6321 memset(phba
->cfg_oas_vpt_wwpn
, 0, (8 * sizeof(uint8_t)));
6322 phba
->cfg_oas_lun_state
= 0;
6323 phba
->cfg_oas_lun_status
= 0;
6324 phba
->cfg_oas_flags
= 0;
6325 phba
->cfg_oas_priority
= 0;
6326 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
6327 lpfc_prot_mask_init(phba
, lpfc_prot_mask
);
6328 lpfc_prot_guard_init(phba
, lpfc_prot_guard
);
6329 if (phba
->sli_rev
== LPFC_SLI_REV4
)
6332 phba
->cfg_poll
= lpfc_poll
;
6333 lpfc_suppress_rsp_init(phba
, lpfc_suppress_rsp
);
6335 lpfc_enable_fc4_type_init(phba
, lpfc_enable_fc4_type
);
6336 lpfc_nvmet_mrq_init(phba
, lpfc_nvmet_mrq
);
6338 /* Initialize first burst. Target vs Initiator are different. */
6339 lpfc_nvme_enable_fb_init(phba
, lpfc_nvme_enable_fb
);
6340 lpfc_nvmet_fb_size_init(phba
, lpfc_nvmet_fb_size
);
6341 lpfc_fcp_io_channel_init(phba
, lpfc_fcp_io_channel
);
6342 lpfc_nvme_io_channel_init(phba
, lpfc_nvme_io_channel
);
6343 lpfc_enable_bbcr_init(phba
, lpfc_enable_bbcr
);
6344 lpfc_enable_dpp_init(phba
, lpfc_enable_dpp
);
6346 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
6347 /* NVME only supported on SLI4 */
6348 phba
->nvmet_support
= 0;
6349 phba
->cfg_enable_fc4_type
= LPFC_ENABLE_FCP
;
6350 phba
->cfg_enable_bbcr
= 0;
6352 /* We MUST have FCP support */
6353 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_FCP
))
6354 phba
->cfg_enable_fc4_type
|= LPFC_ENABLE_FCP
;
6357 if (phba
->cfg_auto_imax
&& !phba
->cfg_fcp_imax
)
6358 phba
->cfg_auto_imax
= 0;
6359 phba
->initial_imax
= phba
->cfg_fcp_imax
;
6361 /* A value of 0 means use the number of CPUs found in the system */
6362 if (phba
->cfg_fcp_io_channel
== 0)
6363 phba
->cfg_fcp_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6364 if (phba
->cfg_nvme_io_channel
== 0)
6365 phba
->cfg_nvme_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6367 if (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
)
6368 phba
->cfg_fcp_io_channel
= 0;
6370 if (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_FCP
)
6371 phba
->cfg_nvme_io_channel
= 0;
6373 if (phba
->cfg_fcp_io_channel
> phba
->cfg_nvme_io_channel
)
6374 phba
->io_channel_irqs
= phba
->cfg_fcp_io_channel
;
6376 phba
->io_channel_irqs
= phba
->cfg_nvme_io_channel
;
6378 phba
->cfg_soft_wwnn
= 0L;
6379 phba
->cfg_soft_wwpn
= 0L;
6380 lpfc_xri_split_init(phba
, lpfc_xri_split
);
6381 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
6382 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
6383 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
6384 lpfc_aer_support_init(phba
, lpfc_aer_support
);
6385 lpfc_sriov_nr_virtfn_init(phba
, lpfc_sriov_nr_virtfn
);
6386 lpfc_request_firmware_upgrade_init(phba
, lpfc_req_fw_upgrade
);
6387 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
6388 lpfc_iocb_cnt_init(phba
, lpfc_iocb_cnt
);
6389 lpfc_delay_discovery_init(phba
, lpfc_delay_discovery
);
6390 lpfc_sli_mode_init(phba
, lpfc_sli_mode
);
6391 phba
->cfg_enable_dss
= 1;
6392 lpfc_enable_mds_diags_init(phba
, lpfc_enable_mds_diags
);
6397 * lpfc_nvme_mod_param_dep - Adjust module parameter value based on
6398 * dependencies between protocols and roles.
6399 * @phba: lpfc_hba pointer.
6402 lpfc_nvme_mod_param_dep(struct lpfc_hba
*phba
)
6404 if (phba
->cfg_nvme_io_channel
> phba
->sli4_hba
.num_present_cpu
)
6405 phba
->cfg_nvme_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6407 if (phba
->cfg_fcp_io_channel
> phba
->sli4_hba
.num_present_cpu
)
6408 phba
->cfg_fcp_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6410 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
&&
6411 phba
->nvmet_support
) {
6412 phba
->cfg_enable_fc4_type
&= ~LPFC_ENABLE_FCP
;
6413 phba
->cfg_fcp_io_channel
= 0;
6415 lpfc_printf_log(phba
, KERN_INFO
, LOG_NVME_DISC
,
6416 "6013 %s x%x fb_size x%x, fb_max x%x\n",
6417 "NVME Target PRLI ACC enable_fb ",
6418 phba
->cfg_nvme_enable_fb
,
6419 phba
->cfg_nvmet_fb_size
,
6420 LPFC_NVMET_FB_SZ_MAX
);
6422 if (phba
->cfg_nvme_enable_fb
== 0)
6423 phba
->cfg_nvmet_fb_size
= 0;
6425 if (phba
->cfg_nvmet_fb_size
> LPFC_NVMET_FB_SZ_MAX
)
6426 phba
->cfg_nvmet_fb_size
= LPFC_NVMET_FB_SZ_MAX
;
6429 if (!phba
->cfg_nvmet_mrq
)
6430 phba
->cfg_nvmet_mrq
= phba
->cfg_nvme_io_channel
;
6432 /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */
6433 if (phba
->cfg_nvmet_mrq
> phba
->cfg_nvme_io_channel
) {
6434 phba
->cfg_nvmet_mrq
= phba
->cfg_nvme_io_channel
;
6435 lpfc_printf_log(phba
, KERN_ERR
, LOG_NVME_DISC
,
6436 "6018 Adjust lpfc_nvmet_mrq to %d\n",
6437 phba
->cfg_nvmet_mrq
);
6439 if (phba
->cfg_nvmet_mrq
> LPFC_NVMET_MRQ_MAX
)
6440 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_MAX
;
6443 /* Not NVME Target mode. Turn off Target parameters. */
6444 phba
->nvmet_support
= 0;
6445 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_OFF
;
6446 phba
->cfg_nvmet_fb_size
= 0;
6449 if (phba
->cfg_fcp_io_channel
> phba
->cfg_nvme_io_channel
)
6450 phba
->io_channel_irqs
= phba
->cfg_fcp_io_channel
;
6452 phba
->io_channel_irqs
= phba
->cfg_nvme_io_channel
;
6456 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
6457 * @vport: lpfc_vport pointer.
6460 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
6462 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
6463 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
6464 lpfc_tgt_queue_depth_init(vport
, lpfc_tgt_queue_depth
);
6465 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
6466 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
6467 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
6468 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
6469 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
6470 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
6471 lpfc_first_burst_size_init(vport
, lpfc_first_burst_size
);
6472 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
6473 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
6474 lpfc_max_luns_init(vport
, lpfc_max_luns
);
6475 lpfc_scan_down_init(vport
, lpfc_scan_down
);
6476 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);