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 scnprintf(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 scnprintf(buf
, PAGE_SIZE
, "1\n");
139 return scnprintf(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 scnprintf(buf
, PAGE_SIZE
,
419 "BlockGuard Enabled\n");
421 return scnprintf(buf
, PAGE_SIZE
,
422 "BlockGuard Not Supported\n");
424 return scnprintf(buf
, PAGE_SIZE
,
425 "BlockGuard Disabled\n");
429 lpfc_bg_guard_err_show(struct device
*dev
, struct device_attribute
*attr
,
432 struct Scsi_Host
*shost
= class_to_shost(dev
);
433 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
434 struct lpfc_hba
*phba
= vport
->phba
;
436 return scnprintf(buf
, PAGE_SIZE
, "%llu\n",
437 (unsigned long long)phba
->bg_guard_err_cnt
);
441 lpfc_bg_apptag_err_show(struct device
*dev
, struct device_attribute
*attr
,
444 struct Scsi_Host
*shost
= class_to_shost(dev
);
445 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
446 struct lpfc_hba
*phba
= vport
->phba
;
448 return scnprintf(buf
, PAGE_SIZE
, "%llu\n",
449 (unsigned long long)phba
->bg_apptag_err_cnt
);
453 lpfc_bg_reftag_err_show(struct device
*dev
, struct device_attribute
*attr
,
456 struct Scsi_Host
*shost
= class_to_shost(dev
);
457 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
458 struct lpfc_hba
*phba
= vport
->phba
;
460 return scnprintf(buf
, PAGE_SIZE
, "%llu\n",
461 (unsigned long long)phba
->bg_reftag_err_cnt
);
465 * lpfc_info_show - Return some pci info about the host in ascii
466 * @dev: class converted to a Scsi_host structure.
467 * @attr: device attribute, not used.
468 * @buf: on return contains the formatted text from lpfc_info().
470 * Returns: size of formatted string.
473 lpfc_info_show(struct device
*dev
, struct device_attribute
*attr
,
476 struct Scsi_Host
*host
= class_to_shost(dev
);
478 return scnprintf(buf
, PAGE_SIZE
, "%s\n", lpfc_info(host
));
482 * lpfc_serialnum_show - Return the hba serial number in ascii
483 * @dev: class converted to a Scsi_host structure.
484 * @attr: device attribute, not used.
485 * @buf: on return contains the formatted text serial number.
487 * Returns: size of formatted string.
490 lpfc_serialnum_show(struct device
*dev
, struct device_attribute
*attr
,
493 struct Scsi_Host
*shost
= class_to_shost(dev
);
494 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
495 struct lpfc_hba
*phba
= vport
->phba
;
497 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->SerialNumber
);
501 * lpfc_temp_sensor_show - Return the temperature sensor level
502 * @dev: class converted to a Scsi_host structure.
503 * @attr: device attribute, not used.
504 * @buf: on return contains the formatted support level.
507 * Returns a number indicating the temperature sensor level currently
508 * supported, zero or one in ascii.
510 * Returns: size of formatted string.
513 lpfc_temp_sensor_show(struct device
*dev
, struct device_attribute
*attr
,
516 struct Scsi_Host
*shost
= class_to_shost(dev
);
517 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
518 struct lpfc_hba
*phba
= vport
->phba
;
519 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->temp_sensor_support
);
523 * lpfc_modeldesc_show - Return the model description of the hba
524 * @dev: class converted to a Scsi_host structure.
525 * @attr: device attribute, not used.
526 * @buf: on return contains the scsi vpd model description.
528 * Returns: size of formatted string.
531 lpfc_modeldesc_show(struct device
*dev
, struct device_attribute
*attr
,
534 struct Scsi_Host
*shost
= class_to_shost(dev
);
535 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
536 struct lpfc_hba
*phba
= vport
->phba
;
538 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->ModelDesc
);
542 * lpfc_modelname_show - Return the model name of the hba
543 * @dev: class converted to a Scsi_host structure.
544 * @attr: device attribute, not used.
545 * @buf: on return contains the scsi vpd model name.
547 * Returns: size of formatted string.
550 lpfc_modelname_show(struct device
*dev
, struct device_attribute
*attr
,
553 struct Scsi_Host
*shost
= class_to_shost(dev
);
554 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
555 struct lpfc_hba
*phba
= vport
->phba
;
557 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->ModelName
);
561 * lpfc_programtype_show - Return the program type of the hba
562 * @dev: class converted to a Scsi_host structure.
563 * @attr: device attribute, not used.
564 * @buf: on return contains the scsi vpd program type.
566 * Returns: size of formatted string.
569 lpfc_programtype_show(struct device
*dev
, struct device_attribute
*attr
,
572 struct Scsi_Host
*shost
= class_to_shost(dev
);
573 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
574 struct lpfc_hba
*phba
= vport
->phba
;
576 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->ProgramType
);
580 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
581 * @dev: class converted to a Scsi_host structure.
582 * @attr: device attribute, not used.
583 * @buf: on return contains the Menlo Maintenance sli flag.
585 * Returns: size of formatted string.
588 lpfc_mlomgmt_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
590 struct Scsi_Host
*shost
= class_to_shost(dev
);
591 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
592 struct lpfc_hba
*phba
= vport
->phba
;
594 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
595 (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
));
599 * lpfc_vportnum_show - Return the port number in ascii of the hba
600 * @dev: class converted to a Scsi_host structure.
601 * @attr: device attribute, not used.
602 * @buf: on return contains scsi vpd program type.
604 * Returns: size of formatted string.
607 lpfc_vportnum_show(struct device
*dev
, struct device_attribute
*attr
,
610 struct Scsi_Host
*shost
= class_to_shost(dev
);
611 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
612 struct lpfc_hba
*phba
= vport
->phba
;
614 return scnprintf(buf
, PAGE_SIZE
, "%s\n", phba
->Port
);
618 * lpfc_fwrev_show - Return the firmware rev running in the hba
619 * @dev: class converted to a Scsi_host structure.
620 * @attr: device attribute, not used.
621 * @buf: on return contains the scsi vpd program type.
623 * Returns: size of formatted string.
626 lpfc_fwrev_show(struct device
*dev
, struct device_attribute
*attr
,
629 struct Scsi_Host
*shost
= class_to_shost(dev
);
630 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
631 struct lpfc_hba
*phba
= vport
->phba
;
634 char fwrev
[FW_REV_STR_SIZE
];
637 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
638 if_type
= phba
->sli4_hba
.pc_sli4_params
.if_type
;
639 sli_family
= phba
->sli4_hba
.pc_sli4_params
.sli_family
;
641 if (phba
->sli_rev
< LPFC_SLI_REV4
)
642 len
= scnprintf(buf
, PAGE_SIZE
, "%s, sli-%d\n",
643 fwrev
, phba
->sli_rev
);
645 len
= scnprintf(buf
, PAGE_SIZE
, "%s, sli-%d:%d:%x\n",
646 fwrev
, phba
->sli_rev
, if_type
, sli_family
);
652 * lpfc_hdw_show - Return the jedec information about the hba
653 * @dev: class converted to a Scsi_host structure.
654 * @attr: device attribute, not used.
655 * @buf: on return contains the scsi vpd program type.
657 * Returns: size of formatted string.
660 lpfc_hdw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
663 struct Scsi_Host
*shost
= class_to_shost(dev
);
664 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
665 struct lpfc_hba
*phba
= vport
->phba
;
666 lpfc_vpd_t
*vp
= &phba
->vpd
;
668 lpfc_jedec_to_ascii(vp
->rev
.biuRev
, hdw
);
669 return scnprintf(buf
, PAGE_SIZE
, "%s\n", hdw
);
673 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
674 * @dev: class converted to a Scsi_host structure.
675 * @attr: device attribute, not used.
676 * @buf: on return contains the ROM and FCode ascii strings.
678 * Returns: size of formatted string.
681 lpfc_option_rom_version_show(struct device
*dev
, struct device_attribute
*attr
,
684 struct Scsi_Host
*shost
= class_to_shost(dev
);
685 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
686 struct lpfc_hba
*phba
= vport
->phba
;
687 char fwrev
[FW_REV_STR_SIZE
];
689 if (phba
->sli_rev
< LPFC_SLI_REV4
)
690 return scnprintf(buf
, PAGE_SIZE
, "%s\n",
691 phba
->OptionROMVersion
);
693 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
694 return scnprintf(buf
, PAGE_SIZE
, "%s\n", fwrev
);
698 * lpfc_state_show - Return the link state of the port
699 * @dev: class converted to a Scsi_host structure.
700 * @attr: device attribute, not used.
701 * @buf: on return contains text describing the state of the link.
704 * The switch statement has no default so zero will be returned.
706 * Returns: size of formatted string.
709 lpfc_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
712 struct Scsi_Host
*shost
= class_to_shost(dev
);
713 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
714 struct lpfc_hba
*phba
= vport
->phba
;
717 switch (phba
->link_state
) {
718 case LPFC_LINK_UNKNOWN
:
719 case LPFC_WARM_START
:
720 case LPFC_INIT_START
:
721 case LPFC_INIT_MBX_CMDS
:
724 if (phba
->hba_flag
& LINK_DISABLED
)
725 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
726 "Link Down - User disabled\n");
728 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
734 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
, "Link Up - ");
736 switch (vport
->port_state
) {
737 case LPFC_LOCAL_CFG_LINK
:
738 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
739 "Configuring Link\n");
743 case LPFC_FABRIC_CFG_LINK
:
746 case LPFC_BUILD_DISC_LIST
:
748 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
751 case LPFC_VPORT_READY
:
752 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
756 case LPFC_VPORT_FAILED
:
757 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
761 case LPFC_VPORT_UNKNOWN
:
762 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
766 if (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
)
767 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
768 " Menlo Maint Mode\n");
769 else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
770 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
771 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
774 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
777 if (vport
->fc_flag
& FC_FABRIC
)
778 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
781 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
790 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
791 * @dev: class unused variable.
792 * @attr: device attribute, not used.
793 * @buf: on return contains the module description text.
795 * Returns: size of formatted string.
798 lpfc_sli4_protocol_show(struct device
*dev
, struct device_attribute
*attr
,
801 struct Scsi_Host
*shost
= class_to_shost(dev
);
802 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
803 struct lpfc_hba
*phba
= vport
->phba
;
805 if (phba
->sli_rev
< LPFC_SLI_REV4
)
806 return scnprintf(buf
, PAGE_SIZE
, "fc\n");
808 if (phba
->sli4_hba
.lnk_info
.lnk_dv
== LPFC_LNK_DAT_VAL
) {
809 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_GE
)
810 return scnprintf(buf
, PAGE_SIZE
, "fcoe\n");
811 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_FC
)
812 return scnprintf(buf
, PAGE_SIZE
, "fc\n");
814 return scnprintf(buf
, PAGE_SIZE
, "unknown\n");
818 * lpfc_oas_supported_show - Return whether or not Optimized Access Storage
819 * (OAS) is supported.
820 * @dev: class unused variable.
821 * @attr: device attribute, not used.
822 * @buf: on return contains the module description text.
824 * Returns: size of formatted string.
827 lpfc_oas_supported_show(struct device
*dev
, struct device_attribute
*attr
,
830 struct Scsi_Host
*shost
= class_to_shost(dev
);
831 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
832 struct lpfc_hba
*phba
= vport
->phba
;
834 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
835 phba
->sli4_hba
.pc_sli4_params
.oas_supported
);
839 * lpfc_link_state_store - Transition the link_state on an HBA port
840 * @dev: class device that is converted into a Scsi_host.
841 * @attr: device attribute, not used.
842 * @buf: one or more lpfc_polling_flags values.
846 * -EINVAL if the buffer is not "up" or "down"
847 * return from link state change function if non-zero
848 * length of the buf on success
851 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
852 const char *buf
, size_t count
)
854 struct Scsi_Host
*shost
= class_to_shost(dev
);
855 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
856 struct lpfc_hba
*phba
= vport
->phba
;
858 int status
= -EINVAL
;
860 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
861 (phba
->link_state
== LPFC_LINK_DOWN
))
862 status
= phba
->lpfc_hba_init_link(phba
, MBX_NOWAIT
);
863 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
864 (phba
->link_state
>= LPFC_LINK_UP
))
865 status
= phba
->lpfc_hba_down_link(phba
, MBX_NOWAIT
);
874 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
875 * @dev: class device that is converted into a Scsi_host.
876 * @attr: device attribute, not used.
877 * @buf: on return contains the sum of fc mapped and unmapped.
880 * Returns the ascii text number of the sum of the fc mapped and unmapped
883 * Returns: size of formatted string.
886 lpfc_num_discovered_ports_show(struct device
*dev
,
887 struct device_attribute
*attr
, char *buf
)
889 struct Scsi_Host
*shost
= class_to_shost(dev
);
890 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
892 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
893 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
897 * lpfc_issue_lip - Misnomer, name carried over from long ago
898 * @shost: Scsi_Host pointer.
901 * Bring the link down gracefully then re-init the link. The firmware will
902 * re-init the fiber channel interface as required. Does not issue a LIP.
905 * -EPERM port offline or management commands are being blocked
906 * -ENOMEM cannot allocate memory for the mailbox command
907 * -EIO error sending the mailbox command
911 lpfc_issue_lip(struct Scsi_Host
*shost
)
913 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
914 struct lpfc_hba
*phba
= vport
->phba
;
915 LPFC_MBOXQ_t
*pmboxq
;
916 int mbxstatus
= MBXERR_ERROR
;
919 * If the link is offline, disabled or BLOCK_MGMT_IO
920 * it doesn't make any sense to allow issue_lip
922 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
923 (phba
->hba_flag
& LINK_DISABLED
) ||
924 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
927 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
932 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
933 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
934 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
936 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
938 if ((mbxstatus
== MBX_SUCCESS
) &&
939 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
940 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
941 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
942 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
943 phba
->cfg_link_speed
);
944 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
946 if ((mbxstatus
== MBX_SUCCESS
) &&
947 (pmboxq
->u
.mb
.mbxStatus
== MBXERR_SEC_NO_PERMISSION
))
948 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
| LOG_SLI
,
949 "2859 SLI authentication is required "
950 "for INIT_LINK but has not done yet\n");
953 lpfc_set_loopback_flag(phba
);
954 if (mbxstatus
!= MBX_TIMEOUT
)
955 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
957 if (mbxstatus
== MBXERR_ERROR
)
964 lpfc_emptyq_wait(struct lpfc_hba
*phba
, struct list_head
*q
, spinlock_t
*lock
)
969 while (!list_empty(q
)) {
970 spin_unlock_irq(lock
);
972 if (cnt
++ > 250) { /* 5 secs */
973 lpfc_printf_log(phba
, KERN_WARNING
, LOG_INIT
,
975 "Outstanding IO when ",
976 "bringing Adapter offline\n");
981 spin_unlock_irq(lock
);
986 * lpfc_do_offline - Issues a mailbox command to bring the link down
987 * @phba: lpfc_hba pointer.
988 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
991 * Assumes any error from lpfc_do_offline() will be negative.
992 * Can wait up to 5 seconds for the port ring buffers count
993 * to reach zero, prints a warning if it is not zero and continues.
994 * lpfc_workq_post_event() returns a non-zero return code if call fails.
997 * -EIO error posting the event
1001 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
1003 struct completion online_compl
;
1004 struct lpfc_queue
*qp
= NULL
;
1005 struct lpfc_sli_ring
*pring
;
1006 struct lpfc_sli
*psli
;
1011 init_completion(&online_compl
);
1012 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1013 LPFC_EVT_OFFLINE_PREP
);
1017 wait_for_completion(&online_compl
);
1024 /* Wait a little for things to settle down, but not
1025 * long enough for dev loss timeout to expire.
1027 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
1028 for (i
= 0; i
< psli
->num_rings
; i
++) {
1029 pring
= &psli
->sli3_ring
[i
];
1030 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1035 list_for_each_entry(qp
, &phba
->sli4_hba
.lpfc_wq_list
, wq_list
) {
1039 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1045 init_completion(&online_compl
);
1046 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
1050 wait_for_completion(&online_compl
);
1059 * lpfc_selective_reset - Offline then onlines the port
1060 * @phba: lpfc_hba pointer.
1063 * If the port is configured to allow a reset then the hba is brought
1064 * offline then online.
1067 * Assumes any error from lpfc_do_offline() will be negative.
1068 * Do not make this function static.
1071 * lpfc_do_offline() return code if not zero
1072 * -EIO reset not configured or error posting the event
1076 lpfc_selective_reset(struct lpfc_hba
*phba
)
1078 struct completion online_compl
;
1082 if (!phba
->cfg_enable_hba_reset
)
1085 if (!(phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
1086 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1092 init_completion(&online_compl
);
1093 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1098 wait_for_completion(&online_compl
);
1107 * lpfc_issue_reset - Selectively resets an adapter
1108 * @dev: class device that is converted into a Scsi_host.
1109 * @attr: device attribute, not used.
1110 * @buf: containing the string "selective".
1111 * @count: unused variable.
1114 * If the buf contains the string "selective" then lpfc_selective_reset()
1115 * is called to perform the reset.
1118 * Assumes any error from lpfc_selective_reset() will be negative.
1119 * If lpfc_selective_reset() returns zero then the length of the buffer
1120 * is returned which indicates success
1123 * -EINVAL if the buffer does not contain the string "selective"
1124 * length of buf if lpfc-selective_reset() if the call succeeds
1125 * return value of lpfc_selective_reset() if the call fails
1128 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
1129 const char *buf
, size_t count
)
1131 struct Scsi_Host
*shost
= class_to_shost(dev
);
1132 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1133 struct lpfc_hba
*phba
= vport
->phba
;
1134 int status
= -EINVAL
;
1136 if (!phba
->cfg_enable_hba_reset
)
1139 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
1140 status
= phba
->lpfc_selective_reset(phba
);
1149 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
1150 * @phba: lpfc_hba pointer.
1153 * SLI4 interface type-2 device to wait on the sliport status register for
1154 * the readyness after performing a firmware reset.
1157 * zero for success, -EPERM when port does not have privilege to perform the
1158 * reset, -EIO when port timeout from recovering from the reset.
1161 * As the caller will interpret the return code by value, be careful in making
1162 * change or addition to return codes.
1165 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba
*phba
)
1167 struct lpfc_register portstat_reg
= {0};
1171 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1172 &portstat_reg
.word0
);
1174 /* verify if privileged for the request operation */
1175 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
) &&
1176 !bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1179 /* wait for the SLI port firmware ready after firmware reset */
1180 for (i
= 0; i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
; i
++) {
1182 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1183 &portstat_reg
.word0
);
1184 if (!bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1186 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
))
1188 if (!bf_get(lpfc_sliport_status_rdy
, &portstat_reg
))
1193 if (i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
)
1200 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
1201 * @phba: lpfc_hba pointer.
1204 * Request SLI4 interface type-2 device to perform a physical register set
1211 lpfc_sli4_pdev_reg_request(struct lpfc_hba
*phba
, uint32_t opcode
)
1213 struct completion online_compl
;
1214 struct pci_dev
*pdev
= phba
->pcidev
;
1215 uint32_t before_fc_flag
;
1216 uint32_t sriov_nr_virtfn
;
1218 int status
= 0, rc
= 0;
1219 int job_posted
= 1, sriov_err
;
1221 if (!phba
->cfg_enable_hba_reset
)
1224 if ((phba
->sli_rev
< LPFC_SLI_REV4
) ||
1225 (bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
) !=
1226 LPFC_SLI_INTF_IF_TYPE_2
))
1229 /* Keep state if we need to restore back */
1230 before_fc_flag
= phba
->pport
->fc_flag
;
1231 sriov_nr_virtfn
= phba
->cfg_sriov_nr_virtfn
;
1233 /* Disable SR-IOV virtual functions if enabled */
1234 if (phba
->cfg_sriov_nr_virtfn
) {
1235 pci_disable_sriov(pdev
);
1236 phba
->cfg_sriov_nr_virtfn
= 0;
1239 if (opcode
== LPFC_FW_DUMP
)
1240 phba
->hba_flag
|= HBA_FW_DUMP_OP
;
1242 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1245 phba
->hba_flag
&= ~HBA_FW_DUMP_OP
;
1249 /* wait for the device to be quiesced before firmware reset */
1252 reg_val
= readl(phba
->sli4_hba
.conf_regs_memmap_p
+
1253 LPFC_CTL_PDEV_CTL_OFFSET
);
1255 if (opcode
== LPFC_FW_DUMP
)
1256 reg_val
|= LPFC_FW_DUMP_REQUEST
;
1257 else if (opcode
== LPFC_FW_RESET
)
1258 reg_val
|= LPFC_CTL_PDEV_CTL_FRST
;
1259 else if (opcode
== LPFC_DV_RESET
)
1260 reg_val
|= LPFC_CTL_PDEV_CTL_DRST
;
1262 writel(reg_val
, phba
->sli4_hba
.conf_regs_memmap_p
+
1263 LPFC_CTL_PDEV_CTL_OFFSET
);
1265 readl(phba
->sli4_hba
.conf_regs_memmap_p
+ LPFC_CTL_PDEV_CTL_OFFSET
);
1267 /* delay driver action following IF_TYPE_2 reset */
1268 rc
= lpfc_sli4_pdev_status_reg_wait(phba
);
1271 /* no privilege for reset */
1272 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1273 "3150 No privilege to perform the requested "
1274 "access: x%x\n", reg_val
);
1275 } else if (rc
== -EIO
) {
1276 /* reset failed, there is nothing more we can do */
1277 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1278 "3153 Fail to perform the requested "
1279 "access: x%x\n", reg_val
);
1283 /* keep the original port state */
1284 if (before_fc_flag
& FC_OFFLINE_MODE
)
1287 init_completion(&online_compl
);
1288 job_posted
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1293 wait_for_completion(&online_compl
);
1296 /* in any case, restore the virtual functions enabled as before */
1297 if (sriov_nr_virtfn
) {
1299 lpfc_sli_probe_sriov_nr_virtfn(phba
, sriov_nr_virtfn
);
1301 phba
->cfg_sriov_nr_virtfn
= sriov_nr_virtfn
;
1304 /* return proper error code */
1315 * lpfc_nport_evt_cnt_show - Return the number of nport events
1316 * @dev: class device that is converted into a Scsi_host.
1317 * @attr: device attribute, not used.
1318 * @buf: on return contains the ascii number of nport events.
1320 * Returns: size of formatted string.
1323 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
1326 struct Scsi_Host
*shost
= class_to_shost(dev
);
1327 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1328 struct lpfc_hba
*phba
= vport
->phba
;
1330 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
1334 * lpfc_board_mode_show - Return the state of the board
1335 * @dev: class device that is converted into a Scsi_host.
1336 * @attr: device attribute, not used.
1337 * @buf: on return contains the state of the adapter.
1339 * Returns: size of formatted string.
1342 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
1345 struct Scsi_Host
*shost
= class_to_shost(dev
);
1346 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1347 struct lpfc_hba
*phba
= vport
->phba
;
1350 if (phba
->link_state
== LPFC_HBA_ERROR
)
1352 else if (phba
->link_state
== LPFC_WARM_START
)
1353 state
= "warm start";
1354 else if (phba
->link_state
== LPFC_INIT_START
)
1359 return scnprintf(buf
, PAGE_SIZE
, "%s\n", state
);
1363 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1364 * @dev: class device that is converted into a Scsi_host.
1365 * @attr: device attribute, not used.
1366 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1367 * @count: unused variable.
1370 * -EACCES if enable hba reset not enabled
1371 * -EINVAL if the buffer does not contain a valid string (see above)
1372 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1373 * buf length greater than zero indicates success
1376 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
1377 const char *buf
, size_t count
)
1379 struct Scsi_Host
*shost
= class_to_shost(dev
);
1380 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1381 struct lpfc_hba
*phba
= vport
->phba
;
1382 struct completion online_compl
;
1383 char *board_mode_str
= NULL
;
1387 if (!phba
->cfg_enable_hba_reset
) {
1389 goto board_mode_out
;
1392 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1393 "3050 lpfc_board_mode set to %s\n", buf
);
1395 init_completion(&online_compl
);
1397 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
1398 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1402 goto board_mode_out
;
1404 wait_for_completion(&online_compl
);
1407 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
1408 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1409 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
1410 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1413 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
1414 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
1415 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1418 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
1419 else if (strncmp(buf
, "dump", sizeof("dump") - 1) == 0)
1420 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_DUMP
);
1421 else if (strncmp(buf
, "fw_reset", sizeof("fw_reset") - 1) == 0)
1422 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_RESET
);
1423 else if (strncmp(buf
, "dv_reset", sizeof("dv_reset") - 1) == 0)
1424 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_DV_RESET
);
1432 board_mode_str
= strchr(buf
, '\n');
1434 *board_mode_str
= '\0';
1435 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1436 "3097 Failed \"%s\", status(%d), "
1438 buf
, status
, phba
->pport
->fc_flag
);
1444 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1445 * @phba: pointer to the adapter structure.
1446 * @mxri: max xri count.
1447 * @axri: available xri count.
1448 * @mrpi: max rpi count.
1449 * @arpi: available rpi count.
1450 * @mvpi: max vpi count.
1451 * @avpi: available vpi count.
1454 * If an integer pointer for an count is not null then the value for the
1455 * count is returned.
1462 lpfc_get_hba_info(struct lpfc_hba
*phba
,
1463 uint32_t *mxri
, uint32_t *axri
,
1464 uint32_t *mrpi
, uint32_t *arpi
,
1465 uint32_t *mvpi
, uint32_t *avpi
)
1467 struct lpfc_mbx_read_config
*rd_config
;
1468 LPFC_MBOXQ_t
*pmboxq
;
1474 * prevent udev from issuing mailbox commands until the port is
1477 if (phba
->link_state
< LPFC_LINK_DOWN
||
1478 !phba
->mbox_mem_pool
||
1479 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
1482 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
1485 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1488 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1490 pmb
= &pmboxq
->u
.mb
;
1491 pmb
->mbxCommand
= MBX_READ_CONFIG
;
1492 pmb
->mbxOwner
= OWN_HOST
;
1493 pmboxq
->context1
= NULL
;
1495 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
1496 rc
= MBX_NOT_FINISHED
;
1498 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
1500 if (rc
!= MBX_SUCCESS
) {
1501 if (rc
!= MBX_TIMEOUT
)
1502 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1506 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1507 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
1509 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
1511 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
1512 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
1514 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
1516 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
1517 phba
->sli4_hba
.max_cfg_param
.xri_used
;
1519 /* Account for differences with SLI-3. Get vpi count from
1520 * mailbox data and subtract one for max vpi value.
1522 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
1523 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
1528 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
1531 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
1533 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
1535 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
1537 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
1539 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
1541 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
1544 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1549 * lpfc_max_rpi_show - Return maximum rpi
1550 * @dev: class device that is converted into a Scsi_host.
1551 * @attr: device attribute, not used.
1552 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1555 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1556 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1557 * to "Unknown" and the buffer length is returned, therefore the caller
1558 * must check for "Unknown" in the buffer to detect a failure.
1560 * Returns: size of formatted string.
1563 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1566 struct Scsi_Host
*shost
= class_to_shost(dev
);
1567 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1568 struct lpfc_hba
*phba
= vport
->phba
;
1571 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
1572 return scnprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1573 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
1577 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1578 * @dev: class device that is converted into a Scsi_host.
1579 * @attr: device attribute, not used.
1580 * @buf: containing the used rpi count in decimal or "Unknown".
1583 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1584 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1585 * to "Unknown" and the buffer length is returned, therefore the caller
1586 * must check for "Unknown" in the buffer to detect a failure.
1588 * Returns: size of formatted string.
1591 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1594 struct Scsi_Host
*shost
= class_to_shost(dev
);
1595 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1596 struct lpfc_hba
*phba
= vport
->phba
;
1599 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1600 return scnprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1601 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
1605 * lpfc_max_xri_show - Return maximum xri
1606 * @dev: class device that is converted into a Scsi_host.
1607 * @attr: device attribute, not used.
1608 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1611 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1612 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1613 * to "Unknown" and the buffer length is returned, therefore the caller
1614 * must check for "Unknown" in the buffer to detect a failure.
1616 * Returns: size of formatted string.
1619 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1622 struct Scsi_Host
*shost
= class_to_shost(dev
);
1623 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1624 struct lpfc_hba
*phba
= vport
->phba
;
1627 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
1628 return scnprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1629 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
1633 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1634 * @dev: class device that is converted into a Scsi_host.
1635 * @attr: device attribute, not used.
1636 * @buf: on return contains the used xri count in decimal or "Unknown".
1639 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1640 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1641 * to "Unknown" and the buffer length is returned, therefore the caller
1642 * must check for "Unknown" in the buffer to detect a failure.
1644 * Returns: size of formatted string.
1647 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1650 struct Scsi_Host
*shost
= class_to_shost(dev
);
1651 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1652 struct lpfc_hba
*phba
= vport
->phba
;
1655 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
1656 return scnprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1657 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
1661 * lpfc_max_vpi_show - Return maximum vpi
1662 * @dev: class device that is converted into a Scsi_host.
1663 * @attr: device attribute, not used.
1664 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1667 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1668 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1669 * to "Unknown" and the buffer length is returned, therefore the caller
1670 * must check for "Unknown" in the buffer to detect a failure.
1672 * Returns: size of formatted string.
1675 lpfc_max_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1678 struct Scsi_Host
*shost
= class_to_shost(dev
);
1679 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1680 struct lpfc_hba
*phba
= vport
->phba
;
1683 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
1684 return scnprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1685 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
1689 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1690 * @dev: class device that is converted into a Scsi_host.
1691 * @attr: device attribute, not used.
1692 * @buf: on return contains the used vpi count in decimal or "Unknown".
1695 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1696 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1697 * to "Unknown" and the buffer length is returned, therefore the caller
1698 * must check for "Unknown" in the buffer to detect a failure.
1700 * Returns: size of formatted string.
1703 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1706 struct Scsi_Host
*shost
= class_to_shost(dev
);
1707 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1708 struct lpfc_hba
*phba
= vport
->phba
;
1711 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
1712 return scnprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1713 return scnprintf(buf
, PAGE_SIZE
, "Unknown\n");
1717 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1718 * @dev: class device that is converted into a Scsi_host.
1719 * @attr: device attribute, not used.
1720 * @buf: text that must be interpreted to determine if npiv is supported.
1723 * Buffer will contain text indicating npiv is not suppoerted on the port,
1724 * the port is an NPIV physical port, or it is an npiv virtual port with
1725 * the id of the vport.
1727 * Returns: size of formatted string.
1730 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
1733 struct Scsi_Host
*shost
= class_to_shost(dev
);
1734 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1735 struct lpfc_hba
*phba
= vport
->phba
;
1737 if (!(phba
->max_vpi
))
1738 return scnprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
1739 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1740 return scnprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
1741 return scnprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
1745 * lpfc_poll_show - Return text about poll support for the adapter
1746 * @dev: class device that is converted into a Scsi_host.
1747 * @attr: device attribute, not used.
1748 * @buf: on return contains the cfg_poll in hex.
1751 * cfg_poll should be a lpfc_polling_flags type.
1753 * Returns: size of formatted string.
1756 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
1759 struct Scsi_Host
*shost
= class_to_shost(dev
);
1760 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1761 struct lpfc_hba
*phba
= vport
->phba
;
1763 return scnprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
1767 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1768 * @dev: class device that is converted into a Scsi_host.
1769 * @attr: device attribute, not used.
1770 * @buf: one or more lpfc_polling_flags values.
1774 * buf contents converted to integer and checked for a valid value.
1777 * -EINVAL if the buffer connot be converted or is out of range
1778 * length of the buf on success
1781 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
1782 const char *buf
, size_t count
)
1784 struct Scsi_Host
*shost
= class_to_shost(dev
);
1785 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1786 struct lpfc_hba
*phba
= vport
->phba
;
1791 if (!isdigit(buf
[0]))
1794 if (sscanf(buf
, "%i", &val
) != 1)
1797 if ((val
& 0x3) != val
)
1800 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1803 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1804 "3051 lpfc_poll changed from %d to %d\n",
1805 phba
->cfg_poll
, val
);
1807 spin_lock_irq(&phba
->hbalock
);
1809 old_val
= phba
->cfg_poll
;
1811 if (val
& ENABLE_FCP_RING_POLLING
) {
1812 if ((val
& DISABLE_FCP_RING_INT
) &&
1813 !(old_val
& DISABLE_FCP_RING_INT
)) {
1814 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1815 spin_unlock_irq(&phba
->hbalock
);
1818 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
1819 writel(creg_val
, phba
->HCregaddr
);
1820 readl(phba
->HCregaddr
); /* flush */
1822 lpfc_poll_start_timer(phba
);
1824 } else if (val
!= 0x0) {
1825 spin_unlock_irq(&phba
->hbalock
);
1829 if (!(val
& DISABLE_FCP_RING_INT
) &&
1830 (old_val
& DISABLE_FCP_RING_INT
))
1832 spin_unlock_irq(&phba
->hbalock
);
1833 del_timer(&phba
->fcp_poll_timer
);
1834 spin_lock_irq(&phba
->hbalock
);
1835 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1836 spin_unlock_irq(&phba
->hbalock
);
1839 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
1840 writel(creg_val
, phba
->HCregaddr
);
1841 readl(phba
->HCregaddr
); /* flush */
1844 phba
->cfg_poll
= val
;
1846 spin_unlock_irq(&phba
->hbalock
);
1852 * lpfc_fips_level_show - Return the current FIPS level for the HBA
1853 * @dev: class unused variable.
1854 * @attr: device attribute, not used.
1855 * @buf: on return contains the module description text.
1857 * Returns: size of formatted string.
1860 lpfc_fips_level_show(struct device
*dev
, struct device_attribute
*attr
,
1863 struct Scsi_Host
*shost
= class_to_shost(dev
);
1864 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1865 struct lpfc_hba
*phba
= vport
->phba
;
1867 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_level
);
1871 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
1872 * @dev: class unused variable.
1873 * @attr: device attribute, not used.
1874 * @buf: on return contains the module description text.
1876 * Returns: size of formatted string.
1879 lpfc_fips_rev_show(struct device
*dev
, struct device_attribute
*attr
,
1882 struct Scsi_Host
*shost
= class_to_shost(dev
);
1883 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1884 struct lpfc_hba
*phba
= vport
->phba
;
1886 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_spec_rev
);
1890 * lpfc_dss_show - Return the current state of dss and the configured state
1891 * @dev: class converted to a Scsi_host structure.
1892 * @attr: device attribute, not used.
1893 * @buf: on return contains the formatted text.
1895 * Returns: size of formatted string.
1898 lpfc_dss_show(struct device
*dev
, struct device_attribute
*attr
,
1901 struct Scsi_Host
*shost
= class_to_shost(dev
);
1902 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1903 struct lpfc_hba
*phba
= vport
->phba
;
1905 return scnprintf(buf
, PAGE_SIZE
, "%s - %sOperational\n",
1906 (phba
->cfg_enable_dss
) ? "Enabled" : "Disabled",
1907 (phba
->sli3_options
& LPFC_SLI3_DSS_ENABLED
) ?
1912 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
1913 * @dev: class converted to a Scsi_host structure.
1914 * @attr: device attribute, not used.
1915 * @buf: on return contains the formatted support level.
1918 * Returns the maximum number of virtual functions a physical function can
1919 * support, 0 will be returned if called on virtual function.
1921 * Returns: size of formatted string.
1924 lpfc_sriov_hw_max_virtfn_show(struct device
*dev
,
1925 struct device_attribute
*attr
,
1928 struct Scsi_Host
*shost
= class_to_shost(dev
);
1929 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1930 struct lpfc_hba
*phba
= vport
->phba
;
1931 uint16_t max_nr_virtfn
;
1933 max_nr_virtfn
= lpfc_sli_sriov_nr_virtfn_get(phba
);
1934 return scnprintf(buf
, PAGE_SIZE
, "%d\n", max_nr_virtfn
);
1937 static inline bool lpfc_rangecheck(uint val
, uint min
, uint max
)
1939 return val
>= min
&& val
<= max
;
1943 * lpfc_enable_bbcr_set: Sets an attribute value.
1944 * @phba: pointer the the adapter structure.
1945 * @val: integer attribute value.
1948 * Validates the min and max values then sets the
1949 * adapter config field if in the valid range. prints error message
1950 * and does not set the parameter if invalid.
1954 * -EINVAL if val is invalid
1957 lpfc_enable_bbcr_set(struct lpfc_hba
*phba
, uint val
)
1959 if (lpfc_rangecheck(val
, 0, 1) && phba
->sli_rev
== LPFC_SLI_REV4
) {
1960 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1961 "3068 %s_enable_bbcr changed from %d to %d\n",
1962 LPFC_DRIVER_NAME
, phba
->cfg_enable_bbcr
, val
);
1963 phba
->cfg_enable_bbcr
= val
;
1966 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1967 "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n",
1968 LPFC_DRIVER_NAME
, val
);
1973 * lpfc_param_show - Return a cfg attribute value in decimal
1976 * Macro that given an attr e.g. hba_queue_depth expands
1977 * into a function with the name lpfc_hba_queue_depth_show.
1979 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
1980 * @dev: class device that is converted into a Scsi_host.
1981 * @attr: device attribute, not used.
1982 * @buf: on return contains the attribute value in decimal.
1984 * Returns: size of formatted string.
1986 #define lpfc_param_show(attr) \
1988 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1991 struct Scsi_Host *shost = class_to_shost(dev);\
1992 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1993 struct lpfc_hba *phba = vport->phba;\
1994 return scnprintf(buf, PAGE_SIZE, "%d\n",\
1999 * lpfc_param_hex_show - Return a cfg attribute value in hex
2002 * Macro that given an attr e.g. hba_queue_depth expands
2003 * into a function with the name lpfc_hba_queue_depth_show
2005 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
2006 * @dev: class device that is converted into a Scsi_host.
2007 * @attr: device attribute, not used.
2008 * @buf: on return contains the attribute value in hexadecimal.
2010 * Returns: size of formatted string.
2012 #define lpfc_param_hex_show(attr) \
2014 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2017 struct Scsi_Host *shost = class_to_shost(dev);\
2018 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2019 struct lpfc_hba *phba = vport->phba;\
2021 val = phba->cfg_##attr;\
2022 return scnprintf(buf, PAGE_SIZE, "%#x\n",\
2027 * lpfc_param_init - Initializes a cfg attribute
2030 * Macro that given an attr e.g. hba_queue_depth expands
2031 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2032 * takes a default argument, a minimum and maximum argument.
2034 * lpfc_##attr##_init: Initializes an attribute.
2035 * @phba: pointer the the adapter structure.
2036 * @val: integer attribute value.
2038 * Validates the min and max values then sets the adapter config field
2039 * accordingly, or uses the default if out of range and prints an error message.
2043 * -EINVAL if default used
2045 #define lpfc_param_init(attr, default, minval, maxval) \
2047 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
2049 if (lpfc_rangecheck(val, minval, maxval)) {\
2050 phba->cfg_##attr = val;\
2053 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2054 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
2055 "allowed range is ["#minval", "#maxval"]\n", val); \
2056 phba->cfg_##attr = default;\
2061 * lpfc_param_set - Set a cfg attribute value
2064 * Macro that given an attr e.g. hba_queue_depth expands
2065 * into a function with the name lpfc_hba_queue_depth_set
2067 * lpfc_##attr##_set: Sets an attribute value.
2068 * @phba: pointer the the adapter structure.
2069 * @val: integer attribute value.
2072 * Validates the min and max values then sets the
2073 * adapter config field if in the valid range. prints error message
2074 * and does not set the parameter if invalid.
2078 * -EINVAL if val is invalid
2080 #define lpfc_param_set(attr, default, minval, maxval) \
2082 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
2084 if (lpfc_rangecheck(val, minval, maxval)) {\
2085 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2086 "3052 lpfc_" #attr " changed from %d to %d\n", \
2087 phba->cfg_##attr, val); \
2088 phba->cfg_##attr = val;\
2091 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2092 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
2093 "allowed range is ["#minval", "#maxval"]\n", val); \
2098 * lpfc_param_store - Set a vport attribute value
2101 * Macro that given an attr e.g. hba_queue_depth expands
2102 * into a function with the name lpfc_hba_queue_depth_store.
2104 * lpfc_##attr##_store: Set an sttribute value.
2105 * @dev: class device that is converted into a Scsi_host.
2106 * @attr: device attribute, not used.
2107 * @buf: contains the attribute value in ascii.
2111 * Convert the ascii text number to an integer, then
2112 * use the lpfc_##attr##_set function to set the value.
2115 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2116 * length of buffer upon success.
2118 #define lpfc_param_store(attr) \
2120 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2121 const char *buf, size_t count) \
2123 struct Scsi_Host *shost = class_to_shost(dev);\
2124 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2125 struct lpfc_hba *phba = vport->phba;\
2127 if (!isdigit(buf[0]))\
2129 if (sscanf(buf, "%i", &val) != 1)\
2131 if (lpfc_##attr##_set(phba, val) == 0) \
2132 return strlen(buf);\
2138 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
2141 * Macro that given an attr e.g. hba_queue_depth expands
2142 * into a function with the name lpfc_hba_queue_depth_show
2144 * lpfc_##attr##_show: prints the attribute value in decimal.
2145 * @dev: class device that is converted into a Scsi_host.
2146 * @attr: device attribute, not used.
2147 * @buf: on return contains the attribute value in decimal.
2149 * Returns: length of formatted string.
2151 #define lpfc_vport_param_show(attr) \
2153 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2156 struct Scsi_Host *shost = class_to_shost(dev);\
2157 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2158 return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
2162 * lpfc_vport_param_hex_show - Return hex formatted attribute value
2165 * Macro that given an attr e.g.
2166 * hba_queue_depth expands into a function with the name
2167 * lpfc_hba_queue_depth_show
2169 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
2170 * @dev: class device that is converted into a Scsi_host.
2171 * @attr: device attribute, not used.
2172 * @buf: on return contains the attribute value in hexadecimal.
2174 * Returns: length of formatted string.
2176 #define lpfc_vport_param_hex_show(attr) \
2178 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2181 struct Scsi_Host *shost = class_to_shost(dev);\
2182 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2183 return scnprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
2187 * lpfc_vport_param_init - Initialize a vport cfg attribute
2190 * Macro that given an attr e.g. hba_queue_depth expands
2191 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2192 * takes a default argument, a minimum and maximum argument.
2194 * lpfc_##attr##_init: validates the min and max values then sets the
2195 * adapter config field accordingly, or uses the default if out of range
2196 * and prints an error message.
2197 * @phba: pointer the the adapter structure.
2198 * @val: integer attribute value.
2202 * -EINVAL if default used
2204 #define lpfc_vport_param_init(attr, default, minval, maxval) \
2206 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
2208 if (lpfc_rangecheck(val, minval, maxval)) {\
2209 vport->cfg_##attr = val;\
2212 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2213 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
2214 "allowed range is ["#minval", "#maxval"]\n", val); \
2215 vport->cfg_##attr = default;\
2220 * lpfc_vport_param_set - Set a vport cfg attribute
2223 * Macro that given an attr e.g. hba_queue_depth expands
2224 * into a function with the name lpfc_hba_queue_depth_set
2226 * lpfc_##attr##_set: validates the min and max values then sets the
2227 * adapter config field if in the valid range. prints error message
2228 * and does not set the parameter if invalid.
2229 * @phba: pointer the the adapter structure.
2230 * @val: integer attribute value.
2234 * -EINVAL if val is invalid
2236 #define lpfc_vport_param_set(attr, default, minval, maxval) \
2238 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
2240 if (lpfc_rangecheck(val, minval, maxval)) {\
2241 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2242 "3053 lpfc_" #attr \
2243 " changed from %d (x%x) to %d (x%x)\n", \
2244 vport->cfg_##attr, vport->cfg_##attr, \
2246 vport->cfg_##attr = val;\
2249 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2250 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
2251 "allowed range is ["#minval", "#maxval"]\n", val); \
2256 * lpfc_vport_param_store - Set a vport attribute
2259 * Macro that given an attr e.g. hba_queue_depth
2260 * expands into a function with the name lpfc_hba_queue_depth_store
2262 * lpfc_##attr##_store: convert the ascii text number to an integer, then
2263 * use the lpfc_##attr##_set function to set the value.
2264 * @cdev: class device that is converted into a Scsi_host.
2265 * @buf: contains the attribute value in decimal.
2269 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2270 * length of buffer upon success.
2272 #define lpfc_vport_param_store(attr) \
2274 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2275 const char *buf, size_t count) \
2277 struct Scsi_Host *shost = class_to_shost(dev);\
2278 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2280 if (!isdigit(buf[0]))\
2282 if (sscanf(buf, "%i", &val) != 1)\
2284 if (lpfc_##attr##_set(vport, val) == 0) \
2285 return strlen(buf);\
2291 static DEVICE_ATTR(nvme_info
, 0444, lpfc_nvme_info_show
, NULL
);
2292 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
2293 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
2294 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
2295 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
2296 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
2297 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
2298 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
2299 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
2300 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
2301 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
2302 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
2303 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
2304 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
2305 lpfc_link_state_store
);
2306 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
2307 lpfc_option_rom_version_show
, NULL
);
2308 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
2309 lpfc_num_discovered_ports_show
, NULL
);
2310 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
2311 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
2312 static DEVICE_ATTR_RO(lpfc_drvr_version
);
2313 static DEVICE_ATTR_RO(lpfc_enable_fip
);
2314 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
2315 lpfc_board_mode_show
, lpfc_board_mode_store
);
2316 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
2317 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
2318 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
2319 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
2320 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
2321 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
2322 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
2323 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
2324 static DEVICE_ATTR_RO(lpfc_temp_sensor
);
2325 static DEVICE_ATTR_RO(lpfc_fips_level
);
2326 static DEVICE_ATTR_RO(lpfc_fips_rev
);
2327 static DEVICE_ATTR_RO(lpfc_dss
);
2328 static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn
);
2329 static DEVICE_ATTR(protocol
, S_IRUGO
, lpfc_sli4_protocol_show
, NULL
);
2330 static DEVICE_ATTR(lpfc_xlane_supported
, S_IRUGO
, lpfc_oas_supported_show
,
2333 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
2336 * lpfc_wwn_set - Convert string to the 8 byte WWN value.
2338 * @cnt: Length of string.
2339 * @wwn: Array to receive converted wwn value.
2342 * -EINVAL if the buffer does not contain a valid wwn
2346 lpfc_wwn_set(const char *buf
, size_t cnt
, char wwn
[])
2350 /* Count may include a LF at end of string */
2351 if (buf
[cnt
-1] == '\n')
2354 if ((cnt
< 16) || (cnt
> 18) || ((cnt
== 17) && (*buf
++ != 'x')) ||
2355 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2358 memset(wwn
, 0, WWN_SZ
);
2360 /* Validate and store the new name */
2361 for (i
= 0, j
= 0; i
< 16; i
++) {
2362 if ((*buf
>= 'a') && (*buf
<= 'f'))
2363 j
= ((j
<< 4) | ((*buf
++ - 'a') + 10));
2364 else if ((*buf
>= 'A') && (*buf
<= 'F'))
2365 j
= ((j
<< 4) | ((*buf
++ - 'A') + 10));
2366 else if ((*buf
>= '0') && (*buf
<= '9'))
2367 j
= ((j
<< 4) | (*buf
++ - '0'));
2371 wwn
[i
/2] = j
& 0xff;
2378 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2379 * @dev: class device that is converted into a Scsi_host.
2380 * @attr: device attribute, not used.
2381 * @buf: containing the string lpfc_soft_wwn_key.
2382 * @count: must be size of lpfc_soft_wwn_key.
2385 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2386 * length of buf indicates success
2389 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
2390 const char *buf
, size_t count
)
2392 struct Scsi_Host
*shost
= class_to_shost(dev
);
2393 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2394 struct lpfc_hba
*phba
= vport
->phba
;
2395 unsigned int cnt
= count
;
2396 uint8_t vvvl
= vport
->fc_sparam
.cmn
.valid_vendor_ver_level
;
2397 u32
*fawwpn_key
= (uint32_t *)&vport
->fc_sparam
.un
.vendorVersion
[0];
2400 * We're doing a simple sanity check for soft_wwpn setting.
2401 * We require that the user write a specific key to enable
2402 * the soft_wwpn attribute to be settable. Once the attribute
2403 * is written, the enable key resets. If further updates are
2404 * desired, the key must be written again to re-enable the
2407 * The "key" is not secret - it is a hardcoded string shown
2408 * here. The intent is to protect against the random user or
2409 * application that is just writing attributes.
2411 if (vvvl
== 1 && cpu_to_be32(*fawwpn_key
) == FAPWWN_KEY_VENDOR
) {
2412 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2413 "0051 "LPFC_DRIVER_NAME
" soft wwpn can not"
2414 " be enabled: fawwpn is enabled\n");
2418 /* count may include a LF at end of string */
2419 if (buf
[cnt
-1] == '\n')
2422 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
2423 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
2426 phba
->soft_wwn_enable
= 1;
2428 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2429 "lpfc%d: soft_wwpn assignment has been enabled.\n",
2431 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2432 " The soft_wwpn feature is not supported by Broadcom.");
2436 static DEVICE_ATTR_WO(lpfc_soft_wwn_enable
);
2439 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2440 * @dev: class device that is converted into a Scsi_host.
2441 * @attr: device attribute, not used.
2442 * @buf: on return contains the wwpn in hexadecimal.
2444 * Returns: size of formatted string.
2447 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
2450 struct Scsi_Host
*shost
= class_to_shost(dev
);
2451 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2452 struct lpfc_hba
*phba
= vport
->phba
;
2454 return scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2455 (unsigned long long)phba
->cfg_soft_wwpn
);
2459 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2460 * @dev class device that is converted into a Scsi_host.
2461 * @attr: device attribute, not used.
2462 * @buf: contains the wwpn in hexadecimal.
2463 * @count: number of wwpn bytes in buf
2466 * -EACCES hba reset not enabled, adapter over temp
2467 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2468 * -EIO error taking adapter offline or online
2469 * value of count on success
2472 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
2473 const char *buf
, size_t count
)
2475 struct Scsi_Host
*shost
= class_to_shost(dev
);
2476 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2477 struct lpfc_hba
*phba
= vport
->phba
;
2478 struct completion online_compl
;
2479 int stat1
= 0, stat2
= 0;
2480 unsigned int cnt
= count
;
2484 if (!phba
->cfg_enable_hba_reset
)
2486 spin_lock_irq(&phba
->hbalock
);
2487 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
2488 spin_unlock_irq(&phba
->hbalock
);
2491 spin_unlock_irq(&phba
->hbalock
);
2492 /* count may include a LF at end of string */
2493 if (buf
[cnt
-1] == '\n')
2496 if (!phba
->soft_wwn_enable
)
2499 /* lock setting wwpn, wwnn down */
2500 phba
->soft_wwn_enable
= 0;
2502 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2504 /* not able to set wwpn, unlock it */
2505 phba
->soft_wwn_enable
= 1;
2509 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
2510 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
2511 if (phba
->cfg_soft_wwnn
)
2512 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
2514 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2515 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
2517 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
2519 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2520 "0463 lpfc_soft_wwpn attribute set failed to "
2521 "reinit adapter - %d\n", stat1
);
2522 init_completion(&online_compl
);
2523 rc
= lpfc_workq_post_event(phba
, &stat2
, &online_compl
,
2528 wait_for_completion(&online_compl
);
2530 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2531 "0464 lpfc_soft_wwpn attribute set failed to "
2532 "reinit adapter - %d\n", stat2
);
2533 return (stat1
|| stat2
) ? -EIO
: count
;
2535 static DEVICE_ATTR_RW(lpfc_soft_wwpn
);
2538 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2539 * @dev: class device that is converted into a Scsi_host.
2540 * @attr: device attribute, not used.
2541 * @buf: on return contains the wwnn in hexadecimal.
2543 * Returns: size of formatted string.
2546 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
2549 struct Scsi_Host
*shost
= class_to_shost(dev
);
2550 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2551 return scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2552 (unsigned long long)phba
->cfg_soft_wwnn
);
2556 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2557 * @cdev: class device that is converted into a Scsi_host.
2558 * @buf: contains the ww node name in hexadecimal.
2559 * @count: number of wwnn bytes in buf.
2562 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2563 * value of count on success
2566 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
2567 const char *buf
, size_t count
)
2569 struct Scsi_Host
*shost
= class_to_shost(dev
);
2570 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2571 unsigned int cnt
= count
;
2575 /* count may include a LF at end of string */
2576 if (buf
[cnt
-1] == '\n')
2579 if (!phba
->soft_wwn_enable
)
2582 rc
= lpfc_wwn_set(buf
, cnt
, wwnn
);
2584 /* Allow wwnn to be set many times, as long as the enable
2585 * is set. However, once the wwpn is set, everything locks.
2590 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
2592 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2593 "lpfc%d: soft_wwnn set. Value will take effect upon "
2594 "setting of the soft_wwpn\n", phba
->brd_no
);
2598 static DEVICE_ATTR_RW(lpfc_soft_wwnn
);
2601 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for
2602 * Optimized Access Storage (OAS) operations.
2603 * @dev: class device that is converted into a Scsi_host.
2604 * @attr: device attribute, not used.
2605 * @buf: buffer for passing information.
2611 lpfc_oas_tgt_show(struct device
*dev
, struct device_attribute
*attr
,
2614 struct Scsi_Host
*shost
= class_to_shost(dev
);
2615 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2617 return scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2618 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
));
2622 * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for
2623 * Optimized Access Storage (OAS) operations.
2624 * @dev: class device that is converted into a Scsi_host.
2625 * @attr: device attribute, not used.
2626 * @buf: buffer for passing information.
2627 * @count: Size of the data buffer.
2630 * -EINVAL count is invalid, invalid wwpn byte invalid
2631 * -EPERM oas is not supported by hba
2632 * value of count on success
2635 lpfc_oas_tgt_store(struct device
*dev
, struct device_attribute
*attr
,
2636 const char *buf
, size_t count
)
2638 struct Scsi_Host
*shost
= class_to_shost(dev
);
2639 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2640 unsigned int cnt
= count
;
2641 uint8_t wwpn
[WWN_SZ
];
2647 /* count may include a LF at end of string */
2648 if (buf
[cnt
-1] == '\n')
2651 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2655 memcpy(phba
->cfg_oas_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2656 memcpy(phba
->sli4_hba
.oas_next_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2657 if (wwn_to_u64(wwpn
) == 0)
2658 phba
->cfg_oas_flags
|= OAS_FIND_ANY_TARGET
;
2660 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_TARGET
;
2661 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2662 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2665 static DEVICE_ATTR(lpfc_xlane_tgt
, S_IRUGO
| S_IWUSR
,
2666 lpfc_oas_tgt_show
, lpfc_oas_tgt_store
);
2669 * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for
2670 * Optimized Access Storage (OAS) operations.
2671 * @dev: class device that is converted into a Scsi_host.
2672 * @attr: device attribute, not used.
2673 * @buf: buffer for passing information.
2679 lpfc_oas_priority_show(struct device
*dev
, struct device_attribute
*attr
,
2682 struct Scsi_Host
*shost
= class_to_shost(dev
);
2683 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2685 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_priority
);
2689 * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for
2690 * Optimized Access Storage (OAS) operations.
2691 * @dev: class device that is converted into a Scsi_host.
2692 * @attr: device attribute, not used.
2693 * @buf: buffer for passing information.
2694 * @count: Size of the data buffer.
2697 * -EINVAL count is invalid, invalid wwpn byte invalid
2698 * -EPERM oas is not supported by hba
2699 * value of count on success
2702 lpfc_oas_priority_store(struct device
*dev
, struct device_attribute
*attr
,
2703 const char *buf
, size_t count
)
2705 struct Scsi_Host
*shost
= class_to_shost(dev
);
2706 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2707 unsigned int cnt
= count
;
2714 /* count may include a LF at end of string */
2715 if (buf
[cnt
-1] == '\n')
2718 ret
= kstrtoul(buf
, 0, &val
);
2719 if (ret
|| (val
> 0x7f))
2723 phba
->cfg_oas_priority
= (uint8_t)val
;
2725 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
2728 static DEVICE_ATTR(lpfc_xlane_priority
, S_IRUGO
| S_IWUSR
,
2729 lpfc_oas_priority_show
, lpfc_oas_priority_store
);
2732 * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled
2733 * for Optimized Access Storage (OAS) operations.
2734 * @dev: class device that is converted into a Scsi_host.
2735 * @attr: device attribute, not used.
2736 * @buf: buffer for passing information.
2739 * value of count on success
2742 lpfc_oas_vpt_show(struct device
*dev
, struct device_attribute
*attr
,
2745 struct Scsi_Host
*shost
= class_to_shost(dev
);
2746 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2748 return scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2749 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
));
2753 * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled
2754 * for Optimized Access Storage (OAS) operations.
2755 * @dev: class device that is converted into a Scsi_host.
2756 * @attr: device attribute, not used.
2757 * @buf: buffer for passing information.
2758 * @count: Size of the data buffer.
2761 * -EINVAL count is invalid, invalid wwpn byte invalid
2762 * -EPERM oas is not supported by hba
2763 * value of count on success
2766 lpfc_oas_vpt_store(struct device
*dev
, struct device_attribute
*attr
,
2767 const char *buf
, size_t count
)
2769 struct Scsi_Host
*shost
= class_to_shost(dev
);
2770 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2771 unsigned int cnt
= count
;
2772 uint8_t wwpn
[WWN_SZ
];
2778 /* count may include a LF at end of string */
2779 if (buf
[cnt
-1] == '\n')
2782 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2786 memcpy(phba
->cfg_oas_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2787 memcpy(phba
->sli4_hba
.oas_next_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2788 if (wwn_to_u64(wwpn
) == 0)
2789 phba
->cfg_oas_flags
|= OAS_FIND_ANY_VPORT
;
2791 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_VPORT
;
2792 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2793 if (phba
->cfg_oas_priority
== 0)
2794 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
2795 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2798 static DEVICE_ATTR(lpfc_xlane_vpt
, S_IRUGO
| S_IWUSR
,
2799 lpfc_oas_vpt_show
, lpfc_oas_vpt_store
);
2802 * lpfc_oas_lun_state_show - Return the current state (enabled or disabled)
2803 * of whether luns will be enabled or disabled
2804 * for Optimized Access Storage (OAS) operations.
2805 * @dev: class device that is converted into a Scsi_host.
2806 * @attr: device attribute, not used.
2807 * @buf: buffer for passing information.
2810 * size of formatted string.
2813 lpfc_oas_lun_state_show(struct device
*dev
, struct device_attribute
*attr
,
2816 struct Scsi_Host
*shost
= class_to_shost(dev
);
2817 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2819 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_state
);
2823 * lpfc_oas_lun_state_store - Store the state (enabled or disabled)
2824 * of whether luns will be enabled or disabled
2825 * for Optimized Access Storage (OAS) operations.
2826 * @dev: class device that is converted into a Scsi_host.
2827 * @attr: device attribute, not used.
2828 * @buf: buffer for passing information.
2829 * @count: Size of the data buffer.
2832 * -EINVAL count is invalid, invalid wwpn byte invalid
2833 * -EPERM oas is not supported by hba
2834 * value of count on success
2837 lpfc_oas_lun_state_store(struct device
*dev
, struct device_attribute
*attr
,
2838 const char *buf
, size_t count
)
2840 struct Scsi_Host
*shost
= class_to_shost(dev
);
2841 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2847 if (!isdigit(buf
[0]))
2850 if (sscanf(buf
, "%i", &val
) != 1)
2853 if ((val
!= 0) && (val
!= 1))
2856 phba
->cfg_oas_lun_state
= val
;
2859 static DEVICE_ATTR(lpfc_xlane_lun_state
, S_IRUGO
| S_IWUSR
,
2860 lpfc_oas_lun_state_show
, lpfc_oas_lun_state_store
);
2863 * lpfc_oas_lun_status_show - Return the status of the Optimized Access
2864 * Storage (OAS) lun returned by the
2865 * lpfc_oas_lun_show function.
2866 * @dev: class device that is converted into a Scsi_host.
2867 * @attr: device attribute, not used.
2868 * @buf: buffer for passing information.
2871 * size of formatted string.
2874 lpfc_oas_lun_status_show(struct device
*dev
, struct device_attribute
*attr
,
2877 struct Scsi_Host
*shost
= class_to_shost(dev
);
2878 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2880 if (!(phba
->cfg_oas_flags
& OAS_LUN_VALID
))
2883 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_status
);
2885 static DEVICE_ATTR(lpfc_xlane_lun_status
, S_IRUGO
,
2886 lpfc_oas_lun_status_show
, NULL
);
2890 * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage
2892 * @phba: lpfc_hba pointer.
2893 * @ndlp: pointer to fcp target node.
2894 * @lun: the fc lun for setting oas state.
2895 * @oas_state: the oas state to be set to the lun.
2899 * -EPERM OAS is not enabled or not supported by this port.
2903 lpfc_oas_lun_state_set(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2904 uint8_t tgt_wwpn
[], uint64_t lun
,
2905 uint32_t oas_state
, uint8_t pri
)
2914 if (!lpfc_enable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2915 (struct lpfc_name
*)tgt_wwpn
,
2919 lpfc_disable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2920 (struct lpfc_name
*)tgt_wwpn
, lun
, pri
);
2927 * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized
2928 * Access Storage (OAS) operations.
2929 * @phba: lpfc_hba pointer.
2930 * @vpt_wwpn: wwpn of the vport associated with the returned lun
2931 * @tgt_wwpn: wwpn of the target associated with the returned lun
2932 * @lun_status: status of the lun returned lun
2934 * Returns the first or next lun enabled for OAS operations for the vport/target
2935 * specified. If a lun is found, its vport wwpn, target wwpn and status is
2936 * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned.
2939 * lun that is OAS enabled for the vport/target
2940 * NOT_OAS_ENABLED_LUN when no oas enabled lun found.
2943 lpfc_oas_lun_get_next(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2944 uint8_t tgt_wwpn
[], uint32_t *lun_status
,
2949 if (unlikely(!phba
) || !vpt_wwpn
|| !tgt_wwpn
)
2950 return NOT_OAS_ENABLED_LUN
;
2951 if (lpfc_find_next_oas_lun(phba
, (struct lpfc_name
*)
2952 phba
->sli4_hba
.oas_next_vpt_wwpn
,
2953 (struct lpfc_name
*)
2954 phba
->sli4_hba
.oas_next_tgt_wwpn
,
2955 &phba
->sli4_hba
.oas_next_lun
,
2956 (struct lpfc_name
*)vpt_wwpn
,
2957 (struct lpfc_name
*)tgt_wwpn
,
2958 &found_lun
, lun_status
, lun_pri
))
2961 return NOT_OAS_ENABLED_LUN
;
2965 * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations
2966 * @phba: lpfc_hba pointer.
2967 * @vpt_wwpn: vport wwpn by reference.
2968 * @tgt_wwpn: target wwpn by reference.
2969 * @lun: the fc lun for setting oas state.
2970 * @oas_state: the oas state to be set to the oas_lun.
2972 * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE)
2973 * a lun for OAS operations.
2977 * -ENOMEM: failed to enable an lun for OAS operations
2978 * -EPERM: OAS is not enabled
2981 lpfc_oas_lun_state_change(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2982 uint8_t tgt_wwpn
[], uint64_t lun
,
2983 uint32_t oas_state
, uint8_t pri
)
2988 rc
= lpfc_oas_lun_state_set(phba
, vpt_wwpn
, tgt_wwpn
, lun
,
2994 * lpfc_oas_lun_show - Return oas enabled luns from a chosen target
2995 * @dev: class device that is converted into a Scsi_host.
2996 * @attr: device attribute, not used.
2997 * @buf: buffer for passing information.
2999 * This routine returns a lun enabled for OAS each time the function
3003 * SUCCESS: size of formatted string.
3004 * -EFAULT: target or vport wwpn was not set properly.
3005 * -EPERM: oas is not enabled.
3008 lpfc_oas_lun_show(struct device
*dev
, struct device_attribute
*attr
,
3011 struct Scsi_Host
*shost
= class_to_shost(dev
);
3012 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3020 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3021 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_VPORT
))
3024 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3025 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_TARGET
))
3028 oas_lun
= lpfc_oas_lun_get_next(phba
, phba
->cfg_oas_vpt_wwpn
,
3029 phba
->cfg_oas_tgt_wwpn
,
3030 &phba
->cfg_oas_lun_status
,
3031 &phba
->cfg_oas_priority
);
3032 if (oas_lun
!= NOT_OAS_ENABLED_LUN
)
3033 phba
->cfg_oas_flags
|= OAS_LUN_VALID
;
3035 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
, "0x%llx", oas_lun
);
3041 * lpfc_oas_lun_store - Sets the OAS state for lun
3042 * @dev: class device that is converted into a Scsi_host.
3043 * @attr: device attribute, not used.
3044 * @buf: buffer for passing information.
3046 * This function sets the OAS state for lun. Before this function is called,
3047 * the vport wwpn, target wwpn, and oas state need to be set.
3050 * SUCCESS: size of formatted string.
3051 * -EFAULT: target or vport wwpn was not set properly.
3052 * -EPERM: oas is not enabled.
3053 * size of formatted string.
3056 lpfc_oas_lun_store(struct device
*dev
, struct device_attribute
*attr
,
3057 const char *buf
, size_t count
)
3059 struct Scsi_Host
*shost
= class_to_shost(dev
);
3060 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3068 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3071 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3074 if (!isdigit(buf
[0]))
3077 if (sscanf(buf
, "0x%llx", &scsi_lun
) != 1)
3080 pri
= phba
->cfg_oas_priority
;
3082 pri
= phba
->cfg_XLanePriority
;
3084 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
,
3085 "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx "
3086 "priority 0x%x with oas state %d\n",
3087 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
),
3088 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
), scsi_lun
,
3089 pri
, phba
->cfg_oas_lun_state
);
3091 rc
= lpfc_oas_lun_state_change(phba
, phba
->cfg_oas_vpt_wwpn
,
3092 phba
->cfg_oas_tgt_wwpn
, scsi_lun
,
3093 phba
->cfg_oas_lun_state
, pri
);
3099 static DEVICE_ATTR(lpfc_xlane_lun
, S_IRUGO
| S_IWUSR
,
3100 lpfc_oas_lun_show
, lpfc_oas_lun_store
);
3102 int lpfc_enable_nvmet_cnt
;
3103 unsigned long long lpfc_enable_nvmet
[LPFC_NVMET_MAX_PORTS
] = {
3104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3106 module_param_array(lpfc_enable_nvmet
, ullong
, &lpfc_enable_nvmet_cnt
, 0444);
3107 MODULE_PARM_DESC(lpfc_enable_nvmet
, "Enable HBA port(s) WWPN as a NVME Target");
3109 static int lpfc_poll
= 0;
3110 module_param(lpfc_poll
, int, S_IRUGO
);
3111 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
3113 " 1 - poll with interrupts enabled"
3114 " 3 - poll and disable FCP ring interrupts");
3116 static DEVICE_ATTR_RW(lpfc_poll
);
3118 int lpfc_no_hba_reset_cnt
;
3119 unsigned long lpfc_no_hba_reset
[MAX_HBAS_NO_RESET
] = {
3120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3121 module_param_array(lpfc_no_hba_reset
, ulong
, &lpfc_no_hba_reset_cnt
, 0444);
3122 MODULE_PARM_DESC(lpfc_no_hba_reset
, "WWPN of HBAs that should not be reset");
3124 LPFC_ATTR(sli_mode
, 0, 0, 3,
3125 "SLI mode selector:"
3126 " 0 - auto (SLI-3 if supported),"
3127 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
3128 " 3 - select SLI-3");
3130 LPFC_ATTR_R(enable_npiv
, 1, 0, 1,
3131 "Enable NPIV functionality");
3133 LPFC_ATTR_R(fcf_failover_policy
, 1, 1, 2,
3134 "FCF Fast failover=1 Priority failover=2");
3137 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
3138 # 0x0 = disabled, XRI/OXID use not tracked.
3139 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
3140 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
3142 LPFC_ATTR_R(enable_rrq
, 2, 0, 2,
3143 "Enable RRQ functionality");
3146 # lpfc_suppress_link_up: Bring link up at initialization
3147 # 0x0 = bring link up (issue MBX_INIT_LINK)
3148 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
3149 # 0x2 = never bring up link
3150 # Default value is 0.
3152 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
3153 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
3154 "Suppress Link Up at initialization");
3156 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
3164 lpfc_iocb_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3166 struct Scsi_Host
*shost
= class_to_shost(dev
);
3167 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3169 return scnprintf(buf
, PAGE_SIZE
, "%d\n", phba
->iocb_max
);
3172 static DEVICE_ATTR(iocb_hw
, S_IRUGO
,
3173 lpfc_iocb_hw_show
, NULL
);
3175 lpfc_txq_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3177 struct Scsi_Host
*shost
= class_to_shost(dev
);
3178 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3179 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3181 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
3182 pring
? pring
->txq_max
: 0);
3185 static DEVICE_ATTR(txq_hw
, S_IRUGO
,
3186 lpfc_txq_hw_show
, NULL
);
3188 lpfc_txcmplq_hw_show(struct device
*dev
, struct device_attribute
*attr
,
3191 struct Scsi_Host
*shost
= class_to_shost(dev
);
3192 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3193 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3195 return scnprintf(buf
, PAGE_SIZE
, "%d\n",
3196 pring
? pring
->txcmplq_max
: 0);
3199 static DEVICE_ATTR(txcmplq_hw
, S_IRUGO
,
3200 lpfc_txcmplq_hw_show
, NULL
);
3202 LPFC_ATTR_R(iocb_cnt
, 2, 1, 5,
3203 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
3206 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
3207 # until the timer expires. Value range is [0,255]. Default value is 30.
3209 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3210 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3211 module_param(lpfc_nodev_tmo
, int, 0);
3212 MODULE_PARM_DESC(lpfc_nodev_tmo
,
3213 "Seconds driver will hold I/O waiting "
3214 "for a device to come back");
3217 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
3218 * @dev: class converted to a Scsi_host structure.
3219 * @attr: device attribute, not used.
3220 * @buf: on return contains the dev loss timeout in decimal.
3222 * Returns: size of formatted string.
3225 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
3228 struct Scsi_Host
*shost
= class_to_shost(dev
);
3229 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3231 return scnprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
3235 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
3236 * @vport: lpfc vport structure pointer.
3237 * @val: contains the nodev timeout value.
3240 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
3241 * a kernel error message is printed and zero is returned.
3242 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3243 * Otherwise nodev tmo is set to the default value.
3246 * zero if already set or if val is in range
3247 * -EINVAL val out of range
3250 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
3252 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
3253 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
3254 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
3255 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3256 "0407 Ignoring lpfc_nodev_tmo module "
3257 "parameter because lpfc_devloss_tmo "
3262 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3263 vport
->cfg_nodev_tmo
= val
;
3264 vport
->cfg_devloss_tmo
= val
;
3267 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3268 "0400 lpfc_nodev_tmo attribute cannot be set to"
3269 " %d, allowed range is [%d, %d]\n",
3270 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3271 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3276 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
3277 * @vport: lpfc vport structure pointer.
3280 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
3283 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
3285 struct Scsi_Host
*shost
;
3286 struct lpfc_nodelist
*ndlp
;
3288 shost
= lpfc_shost_from_vport(vport
);
3289 spin_lock_irq(shost
->host_lock
);
3290 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3291 if (!NLP_CHK_NODE_ACT(ndlp
))
3294 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
3295 #if (IS_ENABLED(CONFIG_NVME_FC))
3297 nvme_fc_set_remoteport_devloss(ndlp
->nrport
->remoteport
,
3298 vport
->cfg_devloss_tmo
);
3301 spin_unlock_irq(shost
->host_lock
);
3305 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
3306 * @vport: lpfc vport structure pointer.
3307 * @val: contains the tmo value.
3310 * If the devloss tmo is already set or the vport dev loss tmo has changed
3311 * then a kernel error message is printed and zero is returned.
3312 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3313 * Otherwise nodev tmo is set to the default value.
3316 * zero if already set or if val is in range
3317 * -EINVAL val out of range
3320 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
3322 if (vport
->dev_loss_tmo_changed
||
3323 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
3324 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3325 "0401 Ignoring change to lpfc_nodev_tmo "
3326 "because lpfc_devloss_tmo is set.\n");
3329 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3330 vport
->cfg_nodev_tmo
= val
;
3331 vport
->cfg_devloss_tmo
= val
;
3333 * For compat: set the fc_host dev loss so new rports
3334 * will get the value.
3336 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3337 lpfc_update_rport_devloss_tmo(vport
);
3340 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3341 "0403 lpfc_nodev_tmo attribute cannot be set to "
3342 "%d, allowed range is [%d, %d]\n",
3343 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3347 lpfc_vport_param_store(nodev_tmo
)
3349 static DEVICE_ATTR_RW(lpfc_nodev_tmo
);
3352 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
3353 # disappear until the timer expires. Value range is [0,255]. Default
3356 module_param(lpfc_devloss_tmo
, int, S_IRUGO
);
3357 MODULE_PARM_DESC(lpfc_devloss_tmo
,
3358 "Seconds driver will hold I/O waiting "
3359 "for a device to come back");
3360 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
3361 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
3362 lpfc_vport_param_show(devloss_tmo
)
3365 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
3366 * @vport: lpfc vport structure pointer.
3367 * @val: contains the tmo value.
3370 * If val is in a valid range then set the vport nodev tmo,
3371 * devloss tmo, also set the vport dev loss tmo changed flag.
3372 * Else a kernel error message is printed.
3375 * zero if val is in range
3376 * -EINVAL val out of range
3379 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
3381 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3382 vport
->cfg_nodev_tmo
= val
;
3383 vport
->cfg_devloss_tmo
= val
;
3384 vport
->dev_loss_tmo_changed
= 1;
3385 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3386 lpfc_update_rport_devloss_tmo(vport
);
3390 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3391 "0404 lpfc_devloss_tmo attribute cannot be set to "
3392 "%d, allowed range is [%d, %d]\n",
3393 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3397 lpfc_vport_param_store(devloss_tmo
)
3398 static DEVICE_ATTR_RW(lpfc_devloss_tmo
);
3401 * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it
3402 * lpfc_suppress_rsp = 0 Disable
3403 * lpfc_suppress_rsp = 1 Enable (default)
3406 LPFC_ATTR_R(suppress_rsp
, 1, 0, 1,
3407 "Enable suppress rsp feature is firmware supports it");
3410 * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds
3411 * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs
3412 * lpfc_nvmet_mrq = 1 use a single RQ pair
3413 * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ
3416 LPFC_ATTR_R(nvmet_mrq
,
3417 LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_MAX
,
3418 "Specify number of RQ pairs for processing NVMET cmds");
3421 * lpfc_enable_fc4_type: Defines what FC4 types are supported.
3422 * Supported Values: 1 - register just FCP
3423 * 3 - register both FCP and NVME
3424 * Supported values are [1,3]. Default value is 1
3426 LPFC_ATTR_R(enable_fc4_type
, LPFC_ENABLE_FCP
,
3427 LPFC_ENABLE_FCP
, LPFC_ENABLE_BOTH
,
3428 "Enable FC4 Protocol support - FCP / NVME");
3431 * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME
3432 * This parameter is only used if:
3433 * lpfc_enable_fc4_type is 3 - register both FCP and NVME and
3434 * port is not configured for NVMET.
3436 * ELS/CT always get 10% of XRIs, up to a maximum of 250
3437 * The remaining XRIs get split up based on lpfc_xri_split per port:
3439 * Supported Values are in percentages
3440 * the xri_split value is the percentage the SCSI port will get. The remaining
3441 * percentage will go to NVME.
3443 LPFC_ATTR_R(xri_split
, 50, 10, 90,
3444 "Percentage of FCP XRI resources versus NVME");
3447 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
3448 # deluged with LOTS of information.
3449 # You can set a bit mask to record specific types of verbose messages:
3450 # See lpfc_logmsh.h for definitions.
3452 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
3453 "Verbose logging bit-mask");
3456 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
3457 # objects that have been registered with the nameserver after login.
3459 LPFC_VPORT_ATTR_R(enable_da_id
, 1, 0, 1,
3460 "Deregister nameserver objects before LOGO");
3463 # lun_queue_depth: This parameter is used to limit the number of outstanding
3464 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
3465 # If this parameter value is greater than 1/8th the maximum number of exchanges
3466 # supported by the HBA port, then the lun queue depth will be reduced to
3467 # 1/8th the maximum number of exchanges.
3469 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 512,
3470 "Max number of FCP commands we can queue to a specific LUN");
3473 # tgt_queue_depth: This parameter is used to limit the number of outstanding
3474 # commands per target port. Value range is [10,65535]. Default value is 65535.
3476 LPFC_VPORT_ATTR_RW(tgt_queue_depth
, 65535, 10, 65535,
3477 "Max number of FCP commands we can queue to a specific target port");
3480 # hba_queue_depth: This parameter is used to limit the number of outstanding
3481 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
3482 # value is greater than the maximum number of exchanges supported by the HBA,
3483 # then maximum number of exchanges supported by the HBA is used to determine
3484 # the hba_queue_depth.
3486 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
3487 "Max number of FCP commands we can queue to a lpfc HBA");
3490 # peer_port_login: This parameter allows/prevents logins
3491 # between peer ports hosted on the same physical port.
3492 # When this parameter is set 0 peer ports of same physical port
3493 # are not allowed to login to each other.
3494 # When this parameter is set 1 peer ports of same physical port
3495 # are allowed to login to each other.
3496 # Default value of this parameter is 0.
3498 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
3499 "Allow peer ports on the same physical port to login to each "
3503 # restrict_login: This parameter allows/prevents logins
3504 # between Virtual Ports and remote initiators.
3505 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
3506 # other initiators and will attempt to PLOGI all remote ports.
3507 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
3508 # remote ports and will not attempt to PLOGI to other initiators.
3509 # This parameter does not restrict to the physical port.
3510 # This parameter does not restrict logins to Fabric resident remote ports.
3511 # Default value of this parameter is 1.
3513 static int lpfc_restrict_login
= 1;
3514 module_param(lpfc_restrict_login
, int, S_IRUGO
);
3515 MODULE_PARM_DESC(lpfc_restrict_login
,
3516 "Restrict virtual ports login to remote initiators.");
3517 lpfc_vport_param_show(restrict_login
);
3520 * lpfc_restrict_login_init - Set the vport restrict login flag
3521 * @vport: lpfc vport structure pointer.
3522 * @val: contains the restrict login value.
3525 * If val is not in a valid range then log a kernel error message and set
3526 * the vport restrict login to one.
3527 * If the port type is physical clear the restrict login flag and return.
3528 * Else set the restrict login flag to val.
3531 * zero if val is in range
3532 * -EINVAL val out of range
3535 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
3537 if (val
< 0 || val
> 1) {
3538 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3539 "0422 lpfc_restrict_login attribute cannot "
3540 "be set to %d, allowed range is [0, 1]\n",
3542 vport
->cfg_restrict_login
= 1;
3545 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
3546 vport
->cfg_restrict_login
= 0;
3549 vport
->cfg_restrict_login
= val
;
3554 * lpfc_restrict_login_set - Set the vport restrict login flag
3555 * @vport: lpfc vport structure pointer.
3556 * @val: contains the restrict login value.
3559 * If val is not in a valid range then log a kernel error message and set
3560 * the vport restrict login to one.
3561 * If the port type is physical and the val is not zero log a kernel
3562 * error message, clear the restrict login flag and return zero.
3563 * Else set the restrict login flag to val.
3566 * zero if val is in range
3567 * -EINVAL val out of range
3570 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
3572 if (val
< 0 || val
> 1) {
3573 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3574 "0425 lpfc_restrict_login attribute cannot "
3575 "be set to %d, allowed range is [0, 1]\n",
3577 vport
->cfg_restrict_login
= 1;
3580 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
3581 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3582 "0468 lpfc_restrict_login must be 0 for "
3583 "Physical ports.\n");
3584 vport
->cfg_restrict_login
= 0;
3587 vport
->cfg_restrict_login
= val
;
3590 lpfc_vport_param_store(restrict_login
);
3591 static DEVICE_ATTR_RW(lpfc_restrict_login
);
3594 # Some disk devices have a "select ID" or "select Target" capability.
3595 # From a protocol standpoint "select ID" usually means select the
3596 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
3597 # annex" which contains a table that maps a "select ID" (a number
3598 # between 0 and 7F) to an ALPA. By default, for compatibility with
3599 # older drivers, the lpfc driver scans this table from low ALPA to high
3602 # Turning on the scan-down variable (on = 1, off = 0) will
3603 # cause the lpfc driver to use an inverted table, effectively
3604 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
3606 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
3607 # and will not work across a fabric. Also this parameter will take
3608 # effect only in the case when ALPA map is not available.)
3610 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
3611 "Start scanning for devices from highest ALPA to lowest");
3614 # lpfc_topology: link topology for init link
3615 # 0x0 = attempt loop mode then point-to-point
3616 # 0x01 = internal loopback mode
3617 # 0x02 = attempt point-to-point mode only
3618 # 0x04 = attempt loop mode only
3619 # 0x06 = attempt point-to-point mode then loop
3620 # Set point-to-point mode if you want to run as an N_Port.
3621 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
3622 # Default value is 0.
3624 LPFC_ATTR(topology
, 0, 0, 6,
3625 "Select Fibre Channel topology");
3628 * lpfc_topology_set - Set the adapters topology field
3629 * @phba: lpfc_hba pointer.
3630 * @val: topology value.
3633 * If val is in a valid range then set the adapter's topology field and
3634 * issue a lip; if the lip fails reset the topology to the old value.
3636 * If the value is not in range log a kernel error message and return an error.
3639 * zero if val is in range and lip okay
3640 * non-zero return value from lpfc_issue_lip()
3641 * -EINVAL val out of range
3644 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
3645 const char *buf
, size_t count
)
3647 struct Scsi_Host
*shost
= class_to_shost(dev
);
3648 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3649 struct lpfc_hba
*phba
= vport
->phba
;
3652 const char *val_buf
= buf
;
3656 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
3658 val_buf
= &buf
[strlen("nolip ")];
3661 if (!isdigit(val_buf
[0]))
3663 if (sscanf(val_buf
, "%i", &val
) != 1)
3666 if (val
>= 0 && val
<= 6) {
3667 prev_val
= phba
->cfg_topology
;
3668 if (phba
->cfg_link_speed
== LPFC_USER_LINK_SPEED_16G
&&
3670 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3671 "3113 Loop mode not supported at speed %d\n",
3675 if (phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G6_FC
&&
3677 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3678 "3114 Loop mode not supported\n");
3681 phba
->cfg_topology
= val
;
3685 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3686 "3054 lpfc_topology changed from %d to %d\n",
3688 if (prev_val
!= val
&& phba
->sli_rev
== LPFC_SLI_REV4
)
3689 phba
->fc_topology_changed
= 1;
3690 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
3692 phba
->cfg_topology
= prev_val
;
3697 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3698 "%d:0467 lpfc_topology attribute cannot be set to %d, "
3699 "allowed range is [0, 6]\n",
3704 lpfc_param_show(topology
)
3705 static DEVICE_ATTR_RW(lpfc_topology
);
3708 * lpfc_static_vport_show: Read callback function for
3709 * lpfc_static_vport sysfs file.
3710 * @dev: Pointer to class device object.
3711 * @attr: device attribute structure.
3712 * @buf: Data buffer.
3714 * This function is the read call back function for
3715 * lpfc_static_vport sysfs file. The lpfc_static_vport
3716 * sysfs file report the mageability of the vport.
3719 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
3722 struct Scsi_Host
*shost
= class_to_shost(dev
);
3723 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3724 if (vport
->vport_flag
& STATIC_VPORT
)
3725 sprintf(buf
, "1\n");
3727 sprintf(buf
, "0\n");
3733 * Sysfs attribute to control the statistical data collection.
3735 static DEVICE_ATTR_RO(lpfc_static_vport
);
3738 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
3739 * @dev: Pointer to class device.
3740 * @buf: Data buffer.
3741 * @count: Size of the data buffer.
3743 * This function get called when a user write to the lpfc_stat_data_ctrl
3744 * sysfs file. This function parse the command written to the sysfs file
3745 * and take appropriate action. These commands are used for controlling
3746 * driver statistical data collection.
3747 * Following are the command this function handles.
3749 * setbucket <bucket_type> <base> <step>
3750 * = Set the latency buckets.
3751 * destroybucket = destroy all the buckets.
3752 * start = start data collection
3753 * stop = stop data collection
3754 * reset = reset the collected data
3757 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
3758 const char *buf
, size_t count
)
3760 struct Scsi_Host
*shost
= class_to_shost(dev
);
3761 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3762 struct lpfc_hba
*phba
= vport
->phba
;
3763 #define LPFC_MAX_DATA_CTRL_LEN 1024
3764 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
3766 char *str_ptr
, *token
;
3767 struct lpfc_vport
**vports
;
3768 struct Scsi_Host
*v_shost
;
3769 char *bucket_type_str
, *base_str
, *step_str
;
3770 unsigned long base
, step
, bucket_type
;
3772 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
3773 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
3776 strncpy(bucket_data
, buf
, LPFC_MAX_DATA_CTRL_LEN
);
3777 str_ptr
= &bucket_data
[0];
3778 /* Ignore this token - this is command token */
3779 token
= strsep(&str_ptr
, "\t ");
3783 bucket_type_str
= strsep(&str_ptr
, "\t ");
3784 if (!bucket_type_str
)
3787 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
3788 bucket_type
= LPFC_LINEAR_BUCKET
;
3789 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
3790 bucket_type
= LPFC_POWER2_BUCKET
;
3794 base_str
= strsep(&str_ptr
, "\t ");
3797 base
= simple_strtoul(base_str
, NULL
, 0);
3799 step_str
= strsep(&str_ptr
, "\t ");
3802 step
= simple_strtoul(step_str
, NULL
, 0);
3806 /* Block the data collection for every vport */
3807 vports
= lpfc_create_vport_work_array(phba
);
3811 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3812 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3813 spin_lock_irq(v_shost
->host_lock
);
3814 /* Block and reset data collection */
3815 vports
[i
]->stat_data_blocked
= 1;
3816 if (vports
[i
]->stat_data_enabled
)
3817 lpfc_vport_reset_stat_data(vports
[i
]);
3818 spin_unlock_irq(v_shost
->host_lock
);
3821 /* Set the bucket attributes */
3822 phba
->bucket_type
= bucket_type
;
3823 phba
->bucket_base
= base
;
3824 phba
->bucket_step
= step
;
3826 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3827 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3829 /* Unblock data collection */
3830 spin_lock_irq(v_shost
->host_lock
);
3831 vports
[i
]->stat_data_blocked
= 0;
3832 spin_unlock_irq(v_shost
->host_lock
);
3834 lpfc_destroy_vport_work_array(phba
, vports
);
3838 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
3839 vports
= lpfc_create_vport_work_array(phba
);
3843 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3844 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3845 spin_lock_irq(shost
->host_lock
);
3846 vports
[i
]->stat_data_blocked
= 1;
3847 lpfc_free_bucket(vport
);
3848 vport
->stat_data_enabled
= 0;
3849 vports
[i
]->stat_data_blocked
= 0;
3850 spin_unlock_irq(shost
->host_lock
);
3852 lpfc_destroy_vport_work_array(phba
, vports
);
3853 phba
->bucket_type
= LPFC_NO_BUCKET
;
3854 phba
->bucket_base
= 0;
3855 phba
->bucket_step
= 0;
3859 if (!strncmp(buf
, "start", strlen("start"))) {
3860 /* If no buckets configured return error */
3861 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
3863 spin_lock_irq(shost
->host_lock
);
3864 if (vport
->stat_data_enabled
) {
3865 spin_unlock_irq(shost
->host_lock
);
3868 lpfc_alloc_bucket(vport
);
3869 vport
->stat_data_enabled
= 1;
3870 spin_unlock_irq(shost
->host_lock
);
3874 if (!strncmp(buf
, "stop", strlen("stop"))) {
3875 spin_lock_irq(shost
->host_lock
);
3876 if (vport
->stat_data_enabled
== 0) {
3877 spin_unlock_irq(shost
->host_lock
);
3880 lpfc_free_bucket(vport
);
3881 vport
->stat_data_enabled
= 0;
3882 spin_unlock_irq(shost
->host_lock
);
3886 if (!strncmp(buf
, "reset", strlen("reset"))) {
3887 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
3888 || !vport
->stat_data_enabled
)
3890 spin_lock_irq(shost
->host_lock
);
3891 vport
->stat_data_blocked
= 1;
3892 lpfc_vport_reset_stat_data(vport
);
3893 vport
->stat_data_blocked
= 0;
3894 spin_unlock_irq(shost
->host_lock
);
3902 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
3903 * @dev: Pointer to class device object.
3904 * @buf: Data buffer.
3906 * This function is the read call back function for
3907 * lpfc_stat_data_ctrl sysfs file. This function report the
3908 * current statistical data collection state.
3911 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
3914 struct Scsi_Host
*shost
= class_to_shost(dev
);
3915 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3916 struct lpfc_hba
*phba
= vport
->phba
;
3920 unsigned long bucket_value
;
3922 switch (phba
->bucket_type
) {
3923 case LPFC_LINEAR_BUCKET
:
3924 bucket_type
= "linear";
3926 case LPFC_POWER2_BUCKET
:
3927 bucket_type
= "power2";
3930 bucket_type
= "No Bucket";
3934 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
3935 "blocked :%d, Bucket type :%s, Bucket base :%d,"
3936 " Bucket step :%d\nLatency Ranges :",
3937 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
3938 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
3939 index
= strlen(buf
);
3940 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
3941 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3942 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
3943 bucket_value
= phba
->bucket_base
+
3944 phba
->bucket_step
* i
;
3946 bucket_value
= phba
->bucket_base
+
3947 (1 << i
) * phba
->bucket_step
;
3949 if (index
+ 10 > PAGE_SIZE
)
3951 sprintf(&buf
[index
], "%08ld ", bucket_value
);
3952 index
= strlen(buf
);
3955 sprintf(&buf
[index
], "\n");
3960 * Sysfs attribute to control the statistical data collection.
3962 static DEVICE_ATTR_RW(lpfc_stat_data_ctrl
);
3965 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
3969 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
3972 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
3973 #define MAX_STAT_DATA_SIZE_PER_TARGET \
3974 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
3978 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
3980 * @kobj: Pointer to the kernel object
3981 * @bin_attr: Attribute object
3982 * @buff: Buffer pointer
3984 * @count: Buffer size
3986 * This function is the read call back function for lpfc_drvr_stat_data
3987 * sysfs file. This function export the statistical data to user
3991 sysfs_drvr_stat_data_read(struct file
*filp
, struct kobject
*kobj
,
3992 struct bin_attribute
*bin_attr
,
3993 char *buf
, loff_t off
, size_t count
)
3995 struct device
*dev
= container_of(kobj
, struct device
,
3997 struct Scsi_Host
*shost
= class_to_shost(dev
);
3998 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3999 struct lpfc_hba
*phba
= vport
->phba
;
4000 int i
= 0, index
= 0;
4001 unsigned long nport_index
;
4002 struct lpfc_nodelist
*ndlp
= NULL
;
4003 nport_index
= (unsigned long)off
/
4004 MAX_STAT_DATA_SIZE_PER_TARGET
;
4006 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
4007 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
4010 spin_lock_irq(shost
->host_lock
);
4011 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4012 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
4015 if (nport_index
> 0) {
4020 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
4024 if (!ndlp
->lat_data
)
4028 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
4029 ndlp
->nlp_portname
.u
.wwn
[0],
4030 ndlp
->nlp_portname
.u
.wwn
[1],
4031 ndlp
->nlp_portname
.u
.wwn
[2],
4032 ndlp
->nlp_portname
.u
.wwn
[3],
4033 ndlp
->nlp_portname
.u
.wwn
[4],
4034 ndlp
->nlp_portname
.u
.wwn
[5],
4035 ndlp
->nlp_portname
.u
.wwn
[6],
4036 ndlp
->nlp_portname
.u
.wwn
[7]);
4038 index
= strlen(buf
);
4040 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
4041 sprintf(&buf
[index
], "%010u,",
4042 ndlp
->lat_data
[i
].cmd_count
);
4043 index
= strlen(buf
);
4045 sprintf(&buf
[index
], "\n");
4046 index
= strlen(buf
);
4048 spin_unlock_irq(shost
->host_lock
);
4052 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
4054 .name
= "lpfc_drvr_stat_data",
4057 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
4058 .read
= sysfs_drvr_stat_data_read
,
4063 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
4065 # Value range is [0,16]. Default value is 0.
4068 * lpfc_link_speed_set - Set the adapters link speed
4069 * @phba: lpfc_hba pointer.
4070 * @val: link speed value.
4073 * If val is in a valid range then set the adapter's link speed field and
4074 * issue a lip; if the lip fails reset the link speed to the old value.
4077 * If the value is not in range log a kernel error message and return an error.
4080 * zero if val is in range and lip okay.
4081 * non-zero return value from lpfc_issue_lip()
4082 * -EINVAL val out of range
4085 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
4086 const char *buf
, size_t count
)
4088 struct Scsi_Host
*shost
= class_to_shost(dev
);
4089 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4090 struct lpfc_hba
*phba
= vport
->phba
;
4091 int val
= LPFC_USER_LINK_SPEED_AUTO
;
4093 const char *val_buf
= buf
;
4095 uint32_t prev_val
, if_type
;
4097 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
4098 if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
&&
4099 phba
->hba_flag
& HBA_FORCED_LINK_SPEED
)
4102 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
4104 val_buf
= &buf
[strlen("nolip ")];
4107 if (!isdigit(val_buf
[0]))
4109 if (sscanf(val_buf
, "%i", &val
) != 1)
4112 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4113 "3055 lpfc_link_speed changed from %d to %d %s\n",
4114 phba
->cfg_link_speed
, val
, nolip
? "(nolip)" : "(lip)");
4116 if (((val
== LPFC_USER_LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
4117 ((val
== LPFC_USER_LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
4118 ((val
== LPFC_USER_LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
4119 ((val
== LPFC_USER_LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
4120 ((val
== LPFC_USER_LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)) ||
4121 ((val
== LPFC_USER_LINK_SPEED_16G
) && !(phba
->lmt
& LMT_16Gb
)) ||
4122 ((val
== LPFC_USER_LINK_SPEED_32G
) && !(phba
->lmt
& LMT_32Gb
)) ||
4123 ((val
== LPFC_USER_LINK_SPEED_64G
) && !(phba
->lmt
& LMT_64Gb
))) {
4124 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4125 "2879 lpfc_link_speed attribute cannot be set "
4126 "to %d. Speed is not supported by this port.\n",
4130 if (val
>= LPFC_USER_LINK_SPEED_16G
&&
4131 phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
4132 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4133 "3112 lpfc_link_speed attribute cannot be set "
4134 "to %d. Speed is not supported in loop mode.\n",
4140 case LPFC_USER_LINK_SPEED_AUTO
:
4141 case LPFC_USER_LINK_SPEED_1G
:
4142 case LPFC_USER_LINK_SPEED_2G
:
4143 case LPFC_USER_LINK_SPEED_4G
:
4144 case LPFC_USER_LINK_SPEED_8G
:
4145 case LPFC_USER_LINK_SPEED_16G
:
4146 case LPFC_USER_LINK_SPEED_32G
:
4147 case LPFC_USER_LINK_SPEED_64G
:
4148 prev_val
= phba
->cfg_link_speed
;
4149 phba
->cfg_link_speed
= val
;
4153 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
4155 phba
->cfg_link_speed
= prev_val
;
4163 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4164 "0469 lpfc_link_speed attribute cannot be set to %d, "
4165 "allowed values are [%s]\n",
4166 val
, LPFC_LINK_SPEED_STRING
);
4171 static int lpfc_link_speed
= 0;
4172 module_param(lpfc_link_speed
, int, S_IRUGO
);
4173 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
4174 lpfc_param_show(link_speed
)
4177 * lpfc_link_speed_init - Set the adapters link speed
4178 * @phba: lpfc_hba pointer.
4179 * @val: link speed value.
4182 * If val is in a valid range then set the adapter's link speed field.
4185 * If the value is not in range log a kernel error message, clear the link
4186 * speed and return an error.
4189 * zero if val saved.
4190 * -EINVAL val out of range
4193 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
4195 if (val
>= LPFC_USER_LINK_SPEED_16G
&& phba
->cfg_topology
== 4) {
4196 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4197 "3111 lpfc_link_speed of %d cannot "
4198 "support loop mode, setting topology to default.\n",
4200 phba
->cfg_topology
= 0;
4204 case LPFC_USER_LINK_SPEED_AUTO
:
4205 case LPFC_USER_LINK_SPEED_1G
:
4206 case LPFC_USER_LINK_SPEED_2G
:
4207 case LPFC_USER_LINK_SPEED_4G
:
4208 case LPFC_USER_LINK_SPEED_8G
:
4209 case LPFC_USER_LINK_SPEED_16G
:
4210 case LPFC_USER_LINK_SPEED_32G
:
4211 case LPFC_USER_LINK_SPEED_64G
:
4212 phba
->cfg_link_speed
= val
;
4215 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4216 "0405 lpfc_link_speed attribute cannot "
4217 "be set to %d, allowed values are "
4218 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
4219 phba
->cfg_link_speed
= LPFC_USER_LINK_SPEED_AUTO
;
4224 static DEVICE_ATTR_RW(lpfc_link_speed
);
4227 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
4228 # 0 = aer disabled or not supported
4229 # 1 = aer supported and enabled (default)
4230 # Value range is [0,1]. Default value is 1.
4232 LPFC_ATTR(aer_support
, 1, 0, 1,
4233 "Enable PCIe device AER support");
4234 lpfc_param_show(aer_support
)
4237 * lpfc_aer_support_store - Set the adapter for aer support
4239 * @dev: class device that is converted into a Scsi_host.
4240 * @attr: device attribute, not used.
4241 * @buf: containing enable or disable aer flag.
4242 * @count: unused variable.
4245 * If the val is 1 and currently the device's AER capability was not
4246 * enabled, invoke the kernel's enable AER helper routine, trying to
4247 * enable the device's AER capability. If the helper routine enabling
4248 * AER returns success, update the device's cfg_aer_support flag to
4249 * indicate AER is supported by the device; otherwise, if the device
4250 * AER capability is already enabled to support AER, then do nothing.
4252 * If the val is 0 and currently the device's AER support was enabled,
4253 * invoke the kernel's disable AER helper routine. After that, update
4254 * the device's cfg_aer_support flag to indicate AER is not supported
4255 * by the device; otherwise, if the device AER capability is already
4256 * disabled from supporting AER, then do nothing.
4259 * length of the buf on success if val is in range the intended mode
4261 * -EINVAL if val out of range or intended mode is not supported.
4264 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
4265 const char *buf
, size_t count
)
4267 struct Scsi_Host
*shost
= class_to_shost(dev
);
4268 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4269 struct lpfc_hba
*phba
= vport
->phba
;
4270 int val
= 0, rc
= -EINVAL
;
4272 if (!isdigit(buf
[0]))
4274 if (sscanf(buf
, "%i", &val
) != 1)
4279 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
4280 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
4282 spin_lock_irq(&phba
->hbalock
);
4283 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
4284 spin_unlock_irq(&phba
->hbalock
);
4285 phba
->cfg_aer_support
= 0;
4290 phba
->cfg_aer_support
= 0;
4295 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
4296 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
4298 spin_lock_irq(&phba
->hbalock
);
4299 phba
->hba_flag
|= HBA_AER_ENABLED
;
4300 spin_unlock_irq(&phba
->hbalock
);
4301 phba
->cfg_aer_support
= 1;
4306 phba
->cfg_aer_support
= 1;
4317 static DEVICE_ATTR_RW(lpfc_aer_support
);
4320 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
4321 * @dev: class device that is converted into a Scsi_host.
4322 * @attr: device attribute, not used.
4323 * @buf: containing flag 1 for aer cleanup state.
4324 * @count: unused variable.
4327 * If the @buf contains 1 and the device currently has the AER support
4328 * enabled, then invokes the kernel AER helper routine
4329 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
4330 * error status register.
4335 * -EINVAL if the buf does not contain the 1 or the device is not currently
4336 * enabled with the AER support.
4339 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
4340 const char *buf
, size_t count
)
4342 struct Scsi_Host
*shost
= class_to_shost(dev
);
4343 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4344 struct lpfc_hba
*phba
= vport
->phba
;
4347 if (!isdigit(buf
[0]))
4349 if (sscanf(buf
, "%i", &val
) != 1)
4354 if (phba
->hba_flag
& HBA_AER_ENABLED
)
4355 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
4363 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
4364 lpfc_aer_cleanup_state
);
4367 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
4369 * @dev: class device that is converted into a Scsi_host.
4370 * @attr: device attribute, not used.
4371 * @buf: containing the string the number of vfs to be enabled.
4372 * @count: unused variable.
4375 * When this api is called either through user sysfs, the driver shall
4376 * try to enable or disable SR-IOV virtual functions according to the
4379 * If zero virtual function has been enabled to the physical function,
4380 * the driver shall invoke the pci enable virtual function api trying
4381 * to enable the virtual functions. If the nr_vfn provided is greater
4382 * than the maximum supported, the maximum virtual function number will
4383 * be used for invoking the api; otherwise, the nr_vfn provided shall
4384 * be used for invoking the api. If the api call returned success, the
4385 * actual number of virtual functions enabled will be set to the driver
4386 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
4387 * cfg_sriov_nr_virtfn remains zero.
4389 * If none-zero virtual functions have already been enabled to the
4390 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
4391 * -EINVAL will be returned and the driver does nothing;
4393 * If the nr_vfn provided is zero and none-zero virtual functions have
4394 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
4395 * disabling virtual function api shall be invoded to disable all the
4396 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
4397 * zero. Otherwise, if zero virtual function has been enabled, do
4401 * length of the buf on success if val is in range the intended mode
4403 * -EINVAL if val out of range or intended mode is not supported.
4406 lpfc_sriov_nr_virtfn_store(struct device
*dev
, struct device_attribute
*attr
,
4407 const char *buf
, size_t count
)
4409 struct Scsi_Host
*shost
= class_to_shost(dev
);
4410 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4411 struct lpfc_hba
*phba
= vport
->phba
;
4412 struct pci_dev
*pdev
= phba
->pcidev
;
4413 int val
= 0, rc
= -EINVAL
;
4415 /* Sanity check on user data */
4416 if (!isdigit(buf
[0]))
4418 if (sscanf(buf
, "%i", &val
) != 1)
4423 /* Request disabling virtual functions */
4425 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4426 pci_disable_sriov(pdev
);
4427 phba
->cfg_sriov_nr_virtfn
= 0;
4432 /* Request enabling virtual functions */
4433 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4434 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4435 "3018 There are %d virtual functions "
4436 "enabled on physical function.\n",
4437 phba
->cfg_sriov_nr_virtfn
);
4441 if (val
<= LPFC_MAX_VFN_PER_PFN
)
4442 phba
->cfg_sriov_nr_virtfn
= val
;
4444 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4445 "3019 Enabling %d virtual functions is not "
4450 rc
= lpfc_sli_probe_sriov_nr_virtfn(phba
, phba
->cfg_sriov_nr_virtfn
);
4452 phba
->cfg_sriov_nr_virtfn
= 0;
4460 LPFC_ATTR(sriov_nr_virtfn
, LPFC_DEF_VFN_PER_PFN
, 0, LPFC_MAX_VFN_PER_PFN
,
4461 "Enable PCIe device SR-IOV virtual fn");
4463 lpfc_param_show(sriov_nr_virtfn
)
4464 static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn
);
4467 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
4469 * @dev: class device that is converted into a Scsi_host.
4470 * @attr: device attribute, not used.
4471 * @buf: containing the string the number of vfs to be enabled.
4472 * @count: unused variable.
4477 * length of the buf on success if val is in range the intended mode
4479 * -EINVAL if val out of range or intended mode is not supported.
4482 lpfc_request_firmware_upgrade_store(struct device
*dev
,
4483 struct device_attribute
*attr
,
4484 const char *buf
, size_t count
)
4486 struct Scsi_Host
*shost
= class_to_shost(dev
);
4487 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4488 struct lpfc_hba
*phba
= vport
->phba
;
4489 int val
= 0, rc
= -EINVAL
;
4491 /* Sanity check on user data */
4492 if (!isdigit(buf
[0]))
4494 if (sscanf(buf
, "%i", &val
) != 1)
4499 rc
= lpfc_sli4_request_firmware_update(phba
, RUN_FW_UPGRADE
);
4507 static int lpfc_req_fw_upgrade
;
4508 module_param(lpfc_req_fw_upgrade
, int, S_IRUGO
|S_IWUSR
);
4509 MODULE_PARM_DESC(lpfc_req_fw_upgrade
, "Enable Linux generic firmware upgrade");
4510 lpfc_param_show(request_firmware_upgrade
)
4513 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
4514 * @phba: lpfc_hba pointer.
4518 * Set the initial Linux generic firmware upgrade enable or disable flag.
4521 * zero if val saved.
4522 * -EINVAL val out of range
4525 lpfc_request_firmware_upgrade_init(struct lpfc_hba
*phba
, int val
)
4527 if (val
>= 0 && val
<= 1) {
4528 phba
->cfg_request_firmware_upgrade
= val
;
4533 static DEVICE_ATTR(lpfc_req_fw_upgrade
, S_IRUGO
| S_IWUSR
,
4534 lpfc_request_firmware_upgrade_show
,
4535 lpfc_request_firmware_upgrade_store
);
4538 * lpfc_fcp_imax_store
4540 * @dev: class device that is converted into a Scsi_host.
4541 * @attr: device attribute, not used.
4542 * @buf: string with the number of fast-path FCP interrupts per second.
4543 * @count: unused variable.
4546 * If val is in a valid range [636,651042], then set the adapter's
4547 * maximum number of fast-path FCP interrupts per second.
4550 * length of the buf on success if val is in range the intended mode
4552 * -EINVAL if val out of range or intended mode is not supported.
4555 lpfc_fcp_imax_store(struct device
*dev
, struct device_attribute
*attr
,
4556 const char *buf
, size_t count
)
4558 struct Scsi_Host
*shost
= class_to_shost(dev
);
4559 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4560 struct lpfc_hba
*phba
= vport
->phba
;
4563 /* fcp_imax is only valid for SLI4 */
4564 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
4567 /* Sanity check on user data */
4568 if (!isdigit(buf
[0]))
4570 if (sscanf(buf
, "%i", &val
) != 1)
4574 * Value range for the HBA is [5000,5000000]
4575 * The value for each EQ depends on how many EQs are configured.
4578 if (val
&& (val
< LPFC_MIN_IMAX
|| val
> LPFC_MAX_IMAX
))
4581 phba
->cfg_fcp_imax
= (uint32_t)val
;
4582 phba
->initial_imax
= phba
->cfg_fcp_imax
;
4584 for (i
= 0; i
< phba
->io_channel_irqs
; i
+= LPFC_MAX_EQ_DELAY_EQID_CNT
)
4585 lpfc_modify_hba_eq_delay(phba
, i
, LPFC_MAX_EQ_DELAY_EQID_CNT
,
4592 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
4595 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
4597 static int lpfc_fcp_imax
= LPFC_DEF_IMAX
;
4598 module_param(lpfc_fcp_imax
, int, S_IRUGO
|S_IWUSR
);
4599 MODULE_PARM_DESC(lpfc_fcp_imax
,
4600 "Set the maximum number of FCP interrupts per second per HBA");
4601 lpfc_param_show(fcp_imax
)
4604 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
4605 * @phba: lpfc_hba pointer.
4606 * @val: link speed value.
4609 * If val is in a valid range [636,651042], then initialize the adapter's
4610 * maximum number of fast-path FCP interrupts per second.
4613 * zero if val saved.
4614 * -EINVAL val out of range
4617 lpfc_fcp_imax_init(struct lpfc_hba
*phba
, int val
)
4619 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4620 phba
->cfg_fcp_imax
= 0;
4624 if ((val
>= LPFC_MIN_IMAX
&& val
<= LPFC_MAX_IMAX
) ||
4626 phba
->cfg_fcp_imax
= val
;
4630 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4631 "3016 lpfc_fcp_imax: %d out of range, using default\n",
4633 phba
->cfg_fcp_imax
= LPFC_DEF_IMAX
;
4638 static DEVICE_ATTR_RW(lpfc_fcp_imax
);
4641 * lpfc_auto_imax: Controls Auto-interrupt coalescing values support.
4642 * 0 No auto_imax support
4644 * Auto imax will change the value of fcp_imax on a per EQ basis, using
4645 * the EQ Delay Multiplier, depending on the activity for that EQ.
4646 * Value range [0,1]. Default value is 1.
4648 LPFC_ATTR_RW(auto_imax
, 1, 0, 1, "Enable Auto imax");
4651 * lpfc_state_show - Display current driver CPU affinity
4652 * @dev: class converted to a Scsi_host structure.
4653 * @attr: device attribute, not used.
4654 * @buf: on return contains text describing the state of the link.
4656 * Returns: size of formatted string.
4659 lpfc_fcp_cpu_map_show(struct device
*dev
, struct device_attribute
*attr
,
4662 struct Scsi_Host
*shost
= class_to_shost(dev
);
4663 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4664 struct lpfc_hba
*phba
= vport
->phba
;
4665 struct lpfc_vector_map_info
*cpup
;
4668 if ((phba
->sli_rev
!= LPFC_SLI_REV4
) ||
4669 (phba
->intr_type
!= MSIX
))
4672 switch (phba
->cfg_fcp_cpu_map
) {
4674 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
4675 "fcp_cpu_map: No mapping (%d)\n",
4676 phba
->cfg_fcp_cpu_map
);
4679 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
4680 "fcp_cpu_map: HBA centric mapping (%d): "
4682 phba
->cfg_fcp_cpu_map
,
4683 phba
->sli4_hba
.num_online_cpu
);
4686 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
4687 "fcp_cpu_map: Driver centric mapping (%d): "
4689 phba
->cfg_fcp_cpu_map
,
4690 phba
->sli4_hba
.num_online_cpu
);
4694 while (phba
->sli4_hba
.curr_disp_cpu
< phba
->sli4_hba
.num_present_cpu
) {
4695 cpup
= &phba
->sli4_hba
.cpu_map
[phba
->sli4_hba
.curr_disp_cpu
];
4697 /* margin should fit in this and the truncated message */
4698 if (cpup
->irq
== LPFC_VECTOR_MAP_EMPTY
)
4699 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
4700 "CPU %02d io_chan %02d "
4701 "physid %d coreid %d\n",
4702 phba
->sli4_hba
.curr_disp_cpu
,
4703 cpup
->channel_id
, cpup
->phys_id
,
4706 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
4707 "CPU %02d io_chan %02d "
4708 "physid %d coreid %d IRQ %d\n",
4709 phba
->sli4_hba
.curr_disp_cpu
,
4710 cpup
->channel_id
, cpup
->phys_id
,
4711 cpup
->core_id
, cpup
->irq
);
4713 phba
->sli4_hba
.curr_disp_cpu
++;
4715 /* display max number of CPUs keeping some margin */
4716 if (phba
->sli4_hba
.curr_disp_cpu
<
4717 phba
->sli4_hba
.num_present_cpu
&&
4718 (len
>= (PAGE_SIZE
- 64))) {
4719 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
, "more...\n");
4724 if (phba
->sli4_hba
.curr_disp_cpu
== phba
->sli4_hba
.num_present_cpu
)
4725 phba
->sli4_hba
.curr_disp_cpu
= 0;
4731 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
4732 * @dev: class device that is converted into a Scsi_host.
4733 * @attr: device attribute, not used.
4734 * @buf: one or more lpfc_polling_flags values.
4738 * -EINVAL - Not implemented yet.
4741 lpfc_fcp_cpu_map_store(struct device
*dev
, struct device_attribute
*attr
,
4742 const char *buf
, size_t count
)
4744 int status
= -EINVAL
;
4749 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
4752 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
4753 # 0 - Do not affinitze IRQ vectors
4754 # 1 - Affintize HBA vectors with respect to each HBA
4755 # (start with CPU0 for each HBA)
4756 # 2 - Affintize HBA vectors with respect to the entire driver
4757 # (round robin thru all CPUs across all HBAs)
4759 static int lpfc_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4760 module_param(lpfc_fcp_cpu_map
, int, S_IRUGO
|S_IWUSR
);
4761 MODULE_PARM_DESC(lpfc_fcp_cpu_map
,
4762 "Defines how to map CPUs to IRQ vectors per HBA");
4765 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
4766 * @phba: lpfc_hba pointer.
4767 * @val: link speed value.
4770 * If val is in a valid range [0-2], then affinitze the adapter's
4774 * zero if val saved.
4775 * -EINVAL val out of range
4778 lpfc_fcp_cpu_map_init(struct lpfc_hba
*phba
, int val
)
4780 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4781 phba
->cfg_fcp_cpu_map
= 0;
4785 if (val
>= LPFC_MIN_CPU_MAP
&& val
<= LPFC_MAX_CPU_MAP
) {
4786 phba
->cfg_fcp_cpu_map
= val
;
4790 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4791 "3326 lpfc_fcp_cpu_map: %d out of range, using "
4793 phba
->cfg_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4798 static DEVICE_ATTR_RW(lpfc_fcp_cpu_map
);
4801 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
4802 # Value range is [2,3]. Default value is 3.
4804 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
4805 "Select Fibre Channel class of service for FCP sequences");
4808 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
4809 # is [0,1]. Default value is 0.
4811 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
4812 "Use ADISC on rediscovery to authenticate FCP devices");
4815 # lpfc_first_burst_size: First burst size to use on the NPorts
4816 # that support first burst.
4817 # Value range is [0,65536]. Default value is 0.
4819 LPFC_VPORT_ATTR_RW(first_burst_size
, 0, 0, 65536,
4820 "First burst size for Targets that support first burst");
4823 * lpfc_nvmet_fb_size: NVME Target mode supported first burst size.
4824 * When the driver is configured as an NVME target, this value is
4825 * communicated to the NVME initiator in the PRLI response. It is
4826 * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support
4827 * parameters are set and the target is sending the PRLI RSP.
4828 * Parameter supported on physical port only - no NPIV support.
4829 * Value range is [0,65536]. Default value is 0.
4831 LPFC_ATTR_RW(nvmet_fb_size
, 0, 0, 65536,
4832 "NVME Target mode first burst size in 512B increments.");
4835 * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
4836 * For the Initiator (I), enabling this parameter means that an NVMET
4837 * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be
4838 * processed by the initiator for subsequent NVME FCP IO. For the target
4839 * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size
4840 * driver parameter as the target function's first burst size returned to the
4841 * initiator in the target's NVME PRLI response. Parameter supported on physical
4842 * port only - no NPIV support.
4843 * Value range is [0,1]. Default value is 0 (disabled).
4845 LPFC_ATTR_RW(nvme_enable_fb
, 0, 0, 1,
4846 "Enable First Burst feature on I and T functions.");
4849 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
4850 # depth. Default value is 0. When the value of this parameter is zero the
4851 # SCSI command completion time is not used for controlling I/O queue depth. When
4852 # the parameter is set to a non-zero value, the I/O queue depth is controlled
4853 # to limit the I/O completion time to the parameter value.
4854 # The value is set in milliseconds.
4856 LPFC_VPORT_ATTR(max_scsicmpl_time
, 0, 0, 60000,
4857 "Use command completion time to control queue depth");
4859 lpfc_vport_param_show(max_scsicmpl_time
);
4861 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
4863 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
4864 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
4866 if (val
== vport
->cfg_max_scsicmpl_time
)
4868 if ((val
< 0) || (val
> 60000))
4870 vport
->cfg_max_scsicmpl_time
= val
;
4872 spin_lock_irq(shost
->host_lock
);
4873 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4874 if (!NLP_CHK_NODE_ACT(ndlp
))
4876 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
4878 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
4880 spin_unlock_irq(shost
->host_lock
);
4883 lpfc_vport_param_store(max_scsicmpl_time
);
4884 static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time
);
4887 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
4888 # range is [0,1]. Default value is 0.
4890 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
4893 * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds
4894 * range is [0,1]. Default value is 0.
4895 * For [0], FCP commands are issued to Work Queues ina round robin fashion.
4896 * For [1], FCP commands are issued to a Work Queue associated with the
4899 * LPFC_FCP_SCHED_ROUND_ROBIN == 0
4900 * LPFC_FCP_SCHED_BY_CPU == 1
4902 * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu
4903 * affinity for FCP/NVME I/Os through Work Queues associated with the current
4904 * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os
4905 * through WQs will be used.
4907 LPFC_ATTR_RW(fcp_io_sched
, LPFC_FCP_SCHED_ROUND_ROBIN
,
4908 LPFC_FCP_SCHED_ROUND_ROBIN
,
4909 LPFC_FCP_SCHED_BY_CPU
,
4910 "Determine scheduling algorithm for "
4911 "issuing commands [0] - Round Robin, [1] - Current CPU");
4914 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
4915 # range is [0,1]. Default value is 0.
4916 # For [0], bus reset issues target reset to ALL devices
4917 # For [1], bus reset issues target reset to non-FCP2 devices
4919 LPFC_ATTR_RW(fcp2_no_tgt_reset
, 0, 0, 1, "Determine bus reset behavior for "
4920 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
4924 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
4925 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
4926 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
4927 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
4928 # cr_delay is set to 0.
4930 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
4931 "interrupt response is generated");
4933 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
4934 "interrupt response is generated");
4937 # lpfc_multi_ring_support: Determines how many rings to spread available
4938 # cmd/rsp IOCB entries across.
4939 # Value range is [1,2]. Default value is 1.
4941 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
4942 "SLI rings to spread IOCB entries across");
4945 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
4946 # identifies what rctl value to configure the additional ring for.
4947 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
4949 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
4950 255, "Identifies RCTL for additional ring configuration");
4953 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
4954 # identifies what type value to configure the additional ring for.
4955 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
4957 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
4958 255, "Identifies TYPE for additional ring configuration");
4961 # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN
4962 # 0 = SmartSAN functionality disabled (default)
4963 # 1 = SmartSAN functionality enabled
4964 # This parameter will override the value of lpfc_fdmi_on module parameter.
4965 # Value range is [0,1]. Default value is 0.
4967 LPFC_ATTR_R(enable_SmartSAN
, 0, 0, 1, "Enable SmartSAN functionality");
4970 # lpfc_fdmi_on: Controls FDMI support.
4971 # 0 No FDMI support (default)
4972 # 1 Traditional FDMI support
4973 # Traditional FDMI support means the driver will assume FDMI-2 support;
4974 # however, if that fails, it will fallback to FDMI-1.
4975 # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on.
4976 # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of
4978 # Value range [0,1]. Default value is 0.
4980 LPFC_ATTR_R(fdmi_on
, 0, 0, 1, "Enable FDMI support");
4983 # Specifies the maximum number of ELS cmds we can have outstanding (for
4984 # discovery). Value range is [1,64]. Default value = 32.
4986 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
4987 "during discovery");
4990 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
4991 # will be scanned by the SCSI midlayer when sequential scanning is
4992 # used; and is also the highest LUN ID allowed when the SCSI midlayer
4993 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
4994 # LUN ID limit, but the SCSI midlayer requires this field for the uses
4995 # above. The lpfc driver limits the default value to 255 for two reasons.
4996 # As it bounds the sequential scan loop, scanning for thousands of luns
4997 # on a target can take minutes of wall clock time. Additionally,
4998 # there are FC targets, such as JBODs, that only recognize 8-bits of
4999 # LUN ID. When they receive a value greater than 8 bits, they chop off
5000 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
5001 # and so on all as LUN ID 0. This causes the linux kernel, which sees
5002 # valid responses at each of the LUN IDs, to believe there are multiple
5003 # devices present, when in fact, there is only 1.
5004 # A customer that is aware of their target behaviors, and the results as
5005 # indicated above, is welcome to increase the lpfc_max_luns value.
5006 # As mentioned, this value is not used by the lpfc driver, only the
5008 # Value range is [0,65535]. Default value is 255.
5009 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
5011 LPFC_VPORT_ULL_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN ID");
5014 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
5015 # Value range is [1,255], default value is 10.
5017 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
5018 "Milliseconds driver will wait between polling FCP ring");
5021 # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands
5022 # to complete in seconds. Value range is [5,180], default value is 60.
5024 LPFC_ATTR_RW(task_mgmt_tmo
, 60, 5, 180,
5025 "Maximum time to wait for task management commands to complete");
5027 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
5028 # support this feature
5031 # 2 = MSI-X enabled (default)
5032 # Value range is [0,2]. Default value is 2.
5034 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
5035 "MSI-X (2), if possible");
5038 * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs
5040 * 0 = NVME OAS disabled
5041 * 1 = NVME OAS enabled
5043 * Value range is [0,1]. Default value is 0.
5045 LPFC_ATTR_RW(nvme_oas
, 0, 0, 1,
5046 "Use OAS bit on NVME IOs");
5049 * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs
5051 * 0 = Put NVME Command in SGL
5052 * 1 = Embed NVME Command in WQE (unless G7)
5053 * 2 = Embed NVME Command in WQE (force)
5055 * Value range is [0,2]. Default value is 1.
5057 LPFC_ATTR_RW(nvme_embed_cmd
, 1, 0, 2,
5058 "Embed NVME Command in WQE");
5061 * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver
5062 * will advertise it supports to the SCSI layer. This also will map to
5063 * the number of WQs the driver will create.
5065 * 0 = Configure the number of io channels to the number of active CPUs.
5066 * 1,32 = Manually specify how many io channels to use.
5068 * Value range is [0,32]. Default value is 4.
5070 LPFC_ATTR_R(fcp_io_channel
,
5071 LPFC_FCP_IO_CHAN_DEF
,
5072 LPFC_HBA_IO_CHAN_MIN
, LPFC_HBA_IO_CHAN_MAX
,
5073 "Set the number of FCP I/O channels");
5076 * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver
5077 * will advertise it supports to the NVME layer. This also will map to
5078 * the number of WQs the driver will create.
5080 * This module parameter is valid when lpfc_enable_fc4_type is set
5083 * The NVME Layer will try to create this many, plus 1 administrative
5084 * hardware queue. The administrative queue will always map to WQ 0
5085 * A hardware IO queue maps (qidx) to a specific driver WQ.
5087 * 0 = Configure the number of io channels to the number of active CPUs.
5088 * 1,32 = Manually specify how many io channels to use.
5090 * Value range is [0,32]. Default value is 0.
5092 LPFC_ATTR_R(nvme_io_channel
,
5093 LPFC_NVME_IO_CHAN_DEF
,
5094 LPFC_HBA_IO_CHAN_MIN
, LPFC_HBA_IO_CHAN_MAX
,
5095 "Set the number of NVME I/O channels");
5098 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
5099 # 0 = HBA resets disabled
5100 # 1 = HBA resets enabled (default)
5101 # Value range is [0,1]. Default value is 1.
5103 LPFC_ATTR_R(enable_hba_reset
, 1, 0, 1, "Enable HBA resets from the driver.");
5106 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
5107 # 0 = HBA Heartbeat disabled
5108 # 1 = HBA Heartbeat enabled (default)
5109 # Value range is [0,1]. Default value is 1.
5111 LPFC_ATTR_R(enable_hba_heartbeat
, 0, 0, 1, "Enable HBA Heartbeat.");
5114 # lpfc_EnableXLane: Enable Express Lane Feature
5115 # 0x0 Express Lane Feature disabled
5116 # 0x1 Express Lane Feature enabled
5117 # Value range is [0,1]. Default value is 0.
5119 LPFC_ATTR_R(EnableXLane
, 0, 0, 1, "Enable Express Lane Feature.");
5122 # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature
5123 # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits)
5124 # Value range is [0x0,0x7f]. Default value is 0
5126 LPFC_ATTR_RW(XLanePriority
, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
5129 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
5130 # 0 = BlockGuard disabled (default)
5131 # 1 = BlockGuard enabled
5132 # Value range is [0,1]. Default value is 0.
5134 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
5137 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
5138 # 0 = disabled (default)
5140 # Value range is [0,1]. Default value is 0.
5142 # This feature in under investigation and may be supported in the future.
5144 unsigned int lpfc_fcp_look_ahead
= LPFC_LOOK_AHEAD_OFF
;
5148 # - Bit mask of host protection capabilities used to register with the
5150 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
5151 # - Allows you to ultimately specify which profiles to use
5152 # - Default will result in registering capabilities for all profiles.
5153 # - SHOST_DIF_TYPE1_PROTECTION 1
5154 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
5155 # - SHOST_DIX_TYPE0_PROTECTION 8
5156 # HBA supports DIX Type 0: Host to HBA protection only
5157 # - SHOST_DIX_TYPE1_PROTECTION 16
5158 # HBA supports DIX Type 1: Host to HBA Type 1 protection
5161 LPFC_ATTR(prot_mask
,
5162 (SHOST_DIF_TYPE1_PROTECTION
|
5163 SHOST_DIX_TYPE0_PROTECTION
|
5164 SHOST_DIX_TYPE1_PROTECTION
),
5166 (SHOST_DIF_TYPE1_PROTECTION
|
5167 SHOST_DIX_TYPE0_PROTECTION
|
5168 SHOST_DIX_TYPE1_PROTECTION
),
5169 "T10-DIF host protection capabilities mask");
5172 # lpfc_prot_guard: i
5173 # - Bit mask of protection guard types to register with the SCSI mid-layer
5174 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
5175 # - Allows you to ultimately specify which profiles to use
5176 # - Default will result in registering capabilities for all guard types
5179 LPFC_ATTR(prot_guard
,
5180 SHOST_DIX_GUARD_IP
, SHOST_DIX_GUARD_CRC
, SHOST_DIX_GUARD_IP
,
5181 "T10-DIF host protection guard type");
5184 * Delay initial NPort discovery when Clean Address bit is cleared in
5185 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
5186 * This parameter can have value 0 or 1.
5187 * When this parameter is set to 0, no delay is added to the initial
5189 * When this parameter is set to non-zero value, initial Nport discovery is
5190 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
5191 * accept and FCID/Fabric name/Fabric portname is changed.
5192 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
5193 * when Clean Address bit is cleared in FLOGI/FDISC
5194 * accept and FCID/Fabric name/Fabric portname is changed.
5195 * Default value is 0.
5197 LPFC_ATTR(delay_discovery
, 0, 0, 1,
5198 "Delay NPort discovery when Clean Address bit is cleared.");
5201 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
5202 * This value can be set to values between 64 and 4096. The default value is
5203 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
5204 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
5205 * Because of the additional overhead involved in setting up T10-DIF,
5206 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
5207 * and will be limited to 512 if BlockGuard is enabled under SLI3.
5209 LPFC_ATTR_R(sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
, LPFC_MIN_SG_SEG_CNT
,
5210 LPFC_MAX_SG_SEG_CNT
, "Max Scatter Gather Segment Count");
5213 * lpfc_enable_mds_diags: Enable MDS Diagnostics
5214 * 0 = MDS Diagnostics disabled (default)
5215 * 1 = MDS Diagnostics enabled
5216 * Value range is [0,1]. Default value is 0.
5218 LPFC_ATTR_R(enable_mds_diags
, 0, 0, 1, "Enable MDS Diagnostics");
5221 * lpfc_enable_bbcr: Enable BB Credit Recovery
5222 * 0 = BB Credit Recovery disabled
5223 * 1 = BB Credit Recovery enabled (default)
5224 * Value range is [0,1]. Default value is 1.
5226 LPFC_BBCR_ATTR_RW(enable_bbcr
, 1, 0, 1, "Enable BBC Recovery");
5229 * lpfc_enable_dpp: Enable DPP on G7
5230 * 0 = DPP on G7 disabled
5231 * 1 = DPP on G7 enabled (default)
5232 * Value range is [0,1]. Default value is 1.
5234 LPFC_ATTR_RW(enable_dpp
, 1, 0, 1, "Enable Direct Packet Push");
5236 struct device_attribute
*lpfc_hba_attrs
[] = {
5237 &dev_attr_nvme_info
,
5239 &dev_attr_bg_guard_err
,
5240 &dev_attr_bg_apptag_err
,
5241 &dev_attr_bg_reftag_err
,
5243 &dev_attr_serialnum
,
5244 &dev_attr_modeldesc
,
5245 &dev_attr_modelname
,
5246 &dev_attr_programtype
,
5250 &dev_attr_option_rom_version
,
5251 &dev_attr_link_state
,
5252 &dev_attr_num_discovered_ports
,
5253 &dev_attr_menlo_mgmt_mode
,
5254 &dev_attr_lpfc_drvr_version
,
5255 &dev_attr_lpfc_enable_fip
,
5256 &dev_attr_lpfc_temp_sensor
,
5257 &dev_attr_lpfc_log_verbose
,
5258 &dev_attr_lpfc_lun_queue_depth
,
5259 &dev_attr_lpfc_tgt_queue_depth
,
5260 &dev_attr_lpfc_hba_queue_depth
,
5261 &dev_attr_lpfc_peer_port_login
,
5262 &dev_attr_lpfc_nodev_tmo
,
5263 &dev_attr_lpfc_devloss_tmo
,
5264 &dev_attr_lpfc_enable_fc4_type
,
5265 &dev_attr_lpfc_xri_split
,
5266 &dev_attr_lpfc_fcp_class
,
5267 &dev_attr_lpfc_use_adisc
,
5268 &dev_attr_lpfc_first_burst_size
,
5269 &dev_attr_lpfc_ack0
,
5270 &dev_attr_lpfc_topology
,
5271 &dev_attr_lpfc_scan_down
,
5272 &dev_attr_lpfc_link_speed
,
5273 &dev_attr_lpfc_fcp_io_sched
,
5274 &dev_attr_lpfc_fcp2_no_tgt_reset
,
5275 &dev_attr_lpfc_cr_delay
,
5276 &dev_attr_lpfc_cr_count
,
5277 &dev_attr_lpfc_multi_ring_support
,
5278 &dev_attr_lpfc_multi_ring_rctl
,
5279 &dev_attr_lpfc_multi_ring_type
,
5280 &dev_attr_lpfc_fdmi_on
,
5281 &dev_attr_lpfc_enable_SmartSAN
,
5282 &dev_attr_lpfc_max_luns
,
5283 &dev_attr_lpfc_enable_npiv
,
5284 &dev_attr_lpfc_fcf_failover_policy
,
5285 &dev_attr_lpfc_enable_rrq
,
5286 &dev_attr_nport_evt_cnt
,
5287 &dev_attr_board_mode
,
5294 &dev_attr_npiv_info
,
5295 &dev_attr_issue_reset
,
5296 &dev_attr_lpfc_poll
,
5297 &dev_attr_lpfc_poll_tmo
,
5298 &dev_attr_lpfc_task_mgmt_tmo
,
5299 &dev_attr_lpfc_use_msi
,
5300 &dev_attr_lpfc_nvme_oas
,
5301 &dev_attr_lpfc_nvme_embed_cmd
,
5302 &dev_attr_lpfc_auto_imax
,
5303 &dev_attr_lpfc_fcp_imax
,
5304 &dev_attr_lpfc_fcp_cpu_map
,
5305 &dev_attr_lpfc_fcp_io_channel
,
5306 &dev_attr_lpfc_suppress_rsp
,
5307 &dev_attr_lpfc_nvme_io_channel
,
5308 &dev_attr_lpfc_nvmet_mrq
,
5309 &dev_attr_lpfc_nvme_enable_fb
,
5310 &dev_attr_lpfc_nvmet_fb_size
,
5311 &dev_attr_lpfc_enable_bg
,
5312 &dev_attr_lpfc_soft_wwnn
,
5313 &dev_attr_lpfc_soft_wwpn
,
5314 &dev_attr_lpfc_soft_wwn_enable
,
5315 &dev_attr_lpfc_enable_hba_reset
,
5316 &dev_attr_lpfc_enable_hba_heartbeat
,
5317 &dev_attr_lpfc_EnableXLane
,
5318 &dev_attr_lpfc_XLanePriority
,
5319 &dev_attr_lpfc_xlane_lun
,
5320 &dev_attr_lpfc_xlane_tgt
,
5321 &dev_attr_lpfc_xlane_vpt
,
5322 &dev_attr_lpfc_xlane_lun_state
,
5323 &dev_attr_lpfc_xlane_lun_status
,
5324 &dev_attr_lpfc_xlane_priority
,
5325 &dev_attr_lpfc_sg_seg_cnt
,
5326 &dev_attr_lpfc_max_scsicmpl_time
,
5327 &dev_attr_lpfc_stat_data_ctrl
,
5328 &dev_attr_lpfc_aer_support
,
5329 &dev_attr_lpfc_aer_state_cleanup
,
5330 &dev_attr_lpfc_sriov_nr_virtfn
,
5331 &dev_attr_lpfc_req_fw_upgrade
,
5332 &dev_attr_lpfc_suppress_link_up
,
5333 &dev_attr_lpfc_iocb_cnt
,
5336 &dev_attr_txcmplq_hw
,
5337 &dev_attr_lpfc_fips_level
,
5338 &dev_attr_lpfc_fips_rev
,
5340 &dev_attr_lpfc_sriov_hw_max_virtfn
,
5342 &dev_attr_lpfc_xlane_supported
,
5343 &dev_attr_lpfc_enable_mds_diags
,
5344 &dev_attr_lpfc_enable_bbcr
,
5345 &dev_attr_lpfc_enable_dpp
,
5349 struct device_attribute
*lpfc_vport_attrs
[] = {
5351 &dev_attr_link_state
,
5352 &dev_attr_num_discovered_ports
,
5353 &dev_attr_lpfc_drvr_version
,
5354 &dev_attr_lpfc_log_verbose
,
5355 &dev_attr_lpfc_lun_queue_depth
,
5356 &dev_attr_lpfc_tgt_queue_depth
,
5357 &dev_attr_lpfc_nodev_tmo
,
5358 &dev_attr_lpfc_devloss_tmo
,
5359 &dev_attr_lpfc_hba_queue_depth
,
5360 &dev_attr_lpfc_peer_port_login
,
5361 &dev_attr_lpfc_restrict_login
,
5362 &dev_attr_lpfc_fcp_class
,
5363 &dev_attr_lpfc_use_adisc
,
5364 &dev_attr_lpfc_first_burst_size
,
5365 &dev_attr_lpfc_max_luns
,
5366 &dev_attr_nport_evt_cnt
,
5367 &dev_attr_npiv_info
,
5368 &dev_attr_lpfc_enable_da_id
,
5369 &dev_attr_lpfc_max_scsicmpl_time
,
5370 &dev_attr_lpfc_stat_data_ctrl
,
5371 &dev_attr_lpfc_static_vport
,
5372 &dev_attr_lpfc_fips_level
,
5373 &dev_attr_lpfc_fips_rev
,
5378 * sysfs_ctlreg_write - Write method for writing to ctlreg
5379 * @filp: open sysfs file
5380 * @kobj: kernel kobject that contains the kernel class device.
5381 * @bin_attr: kernel attributes passed to us.
5382 * @buf: contains the data to be written to the adapter IOREG space.
5383 * @off: offset into buffer to beginning of data.
5384 * @count: bytes to transfer.
5387 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5388 * Uses the adapter io control registers to send buf contents to the adapter.
5391 * -ERANGE off and count combo out of range
5392 * -EINVAL off, count or buff address invalid
5393 * -EPERM adapter is offline
5394 * value of count, buf contents written
5397 sysfs_ctlreg_write(struct file
*filp
, struct kobject
*kobj
,
5398 struct bin_attribute
*bin_attr
,
5399 char *buf
, loff_t off
, size_t count
)
5402 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
5403 struct Scsi_Host
*shost
= class_to_shost(dev
);
5404 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5405 struct lpfc_hba
*phba
= vport
->phba
;
5407 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5410 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5413 if (count
<= LPFC_REG_WRITE_KEY_SIZE
)
5416 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5419 /* This is to protect HBA registers from accidental writes. */
5420 if (memcmp(buf
, LPFC_REG_WRITE_KEY
, LPFC_REG_WRITE_KEY_SIZE
))
5423 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
))
5426 spin_lock_irq(&phba
->hbalock
);
5427 for (buf_off
= 0; buf_off
< count
- LPFC_REG_WRITE_KEY_SIZE
;
5428 buf_off
+= sizeof(uint32_t))
5429 writel(*((uint32_t *)(buf
+ buf_off
+ LPFC_REG_WRITE_KEY_SIZE
)),
5430 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5432 spin_unlock_irq(&phba
->hbalock
);
5438 * sysfs_ctlreg_read - Read method for reading from ctlreg
5439 * @filp: open sysfs file
5440 * @kobj: kernel kobject that contains the kernel class device.
5441 * @bin_attr: kernel attributes passed to us.
5442 * @buf: if successful contains the data from the adapter IOREG space.
5443 * @off: offset into buffer to beginning of data.
5444 * @count: bytes to transfer.
5447 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5448 * Uses the adapter io control registers to read data into buf.
5451 * -ERANGE off and count combo out of range
5452 * -EINVAL off, count or buff address invalid
5453 * value of count, buf contents read
5456 sysfs_ctlreg_read(struct file
*filp
, struct kobject
*kobj
,
5457 struct bin_attribute
*bin_attr
,
5458 char *buf
, loff_t off
, size_t count
)
5462 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
5463 struct Scsi_Host
*shost
= class_to_shost(dev
);
5464 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5465 struct lpfc_hba
*phba
= vport
->phba
;
5467 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5470 if (off
> FF_REG_AREA_SIZE
)
5473 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5474 count
= FF_REG_AREA_SIZE
- off
;
5476 if (count
== 0) return 0;
5478 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5481 spin_lock_irq(&phba
->hbalock
);
5483 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
5484 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
5485 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5488 spin_unlock_irq(&phba
->hbalock
);
5493 static struct bin_attribute sysfs_ctlreg_attr
= {
5496 .mode
= S_IRUSR
| S_IWUSR
,
5499 .read
= sysfs_ctlreg_read
,
5500 .write
= sysfs_ctlreg_write
,
5504 * sysfs_mbox_write - Write method for writing information via mbox
5505 * @filp: open sysfs file
5506 * @kobj: kernel kobject that contains the kernel class device.
5507 * @bin_attr: kernel attributes passed to us.
5508 * @buf: contains the data to be written to sysfs mbox.
5509 * @off: offset into buffer to beginning of data.
5510 * @count: bytes to transfer.
5513 * Deprecated function. All mailbox access from user space is performed via the
5517 * -EPERM operation not permitted
5520 sysfs_mbox_write(struct file
*filp
, struct kobject
*kobj
,
5521 struct bin_attribute
*bin_attr
,
5522 char *buf
, loff_t off
, size_t count
)
5528 * sysfs_mbox_read - Read method for reading information via mbox
5529 * @filp: open sysfs file
5530 * @kobj: kernel kobject that contains the kernel class device.
5531 * @bin_attr: kernel attributes passed to us.
5532 * @buf: contains the data to be read from sysfs mbox.
5533 * @off: offset into buffer to beginning of data.
5534 * @count: bytes to transfer.
5537 * Deprecated function. All mailbox access from user space is performed via the
5541 * -EPERM operation not permitted
5544 sysfs_mbox_read(struct file
*filp
, struct kobject
*kobj
,
5545 struct bin_attribute
*bin_attr
,
5546 char *buf
, loff_t off
, size_t count
)
5551 static struct bin_attribute sysfs_mbox_attr
= {
5554 .mode
= S_IRUSR
| S_IWUSR
,
5556 .size
= MAILBOX_SYSFS_MAX
,
5557 .read
= sysfs_mbox_read
,
5558 .write
= sysfs_mbox_write
,
5562 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
5563 * @vport: address of lpfc vport structure.
5567 * error return code from sysfs_create_bin_file()
5570 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
5572 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5575 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5576 &sysfs_drvr_stat_data_attr
);
5578 /* Virtual ports do not need ctrl_reg and mbox */
5579 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
5582 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5583 &sysfs_ctlreg_attr
);
5585 goto out_remove_stat_attr
;
5587 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5590 goto out_remove_ctlreg_attr
;
5593 out_remove_ctlreg_attr
:
5594 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5595 out_remove_stat_attr
:
5596 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5597 &sysfs_drvr_stat_data_attr
);
5603 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
5604 * @vport: address of lpfc vport structure.
5607 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
5609 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5610 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5611 &sysfs_drvr_stat_data_attr
);
5612 /* Virtual ports do not need ctrl_reg and mbox */
5613 if (vport
->port_type
== LPFC_NPIV_PORT
)
5615 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
5616 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5620 * Dynamic FC Host Attributes Support
5624 * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host
5625 * @shost: kernel scsi host pointer.
5628 lpfc_get_host_symbolic_name(struct Scsi_Host
*shost
)
5630 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5632 lpfc_vport_symbolic_node_name(vport
, fc_host_symbolic_name(shost
),
5633 sizeof fc_host_symbolic_name(shost
));
5637 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
5638 * @shost: kernel scsi host pointer.
5641 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
5643 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5645 /* note: fc_myDID already in cpu endianness */
5646 fc_host_port_id(shost
) = vport
->fc_myDID
;
5650 * lpfc_get_host_port_type - Set the value of the scsi host port type
5651 * @shost: kernel scsi host pointer.
5654 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
5656 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5657 struct lpfc_hba
*phba
= vport
->phba
;
5659 spin_lock_irq(shost
->host_lock
);
5661 if (vport
->port_type
== LPFC_NPIV_PORT
) {
5662 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
5663 } else if (lpfc_is_link_up(phba
)) {
5664 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5665 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
5666 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
5668 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
5670 if (vport
->fc_flag
& FC_FABRIC
)
5671 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
5673 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
5676 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
5678 spin_unlock_irq(shost
->host_lock
);
5682 * lpfc_get_host_port_state - Set the value of the scsi host port state
5683 * @shost: kernel scsi host pointer.
5686 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
5688 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5689 struct lpfc_hba
*phba
= vport
->phba
;
5691 spin_lock_irq(shost
->host_lock
);
5693 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5694 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
5696 switch (phba
->link_state
) {
5697 case LPFC_LINK_UNKNOWN
:
5698 case LPFC_LINK_DOWN
:
5699 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
5703 case LPFC_HBA_READY
:
5704 /* Links up, reports port state accordingly */
5705 if (vport
->port_state
< LPFC_VPORT_READY
)
5706 fc_host_port_state(shost
) =
5707 FC_PORTSTATE_BYPASSED
;
5709 fc_host_port_state(shost
) =
5710 FC_PORTSTATE_ONLINE
;
5712 case LPFC_HBA_ERROR
:
5713 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
5716 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
5721 spin_unlock_irq(shost
->host_lock
);
5725 * lpfc_get_host_speed - Set the value of the scsi host speed
5726 * @shost: kernel scsi host pointer.
5729 lpfc_get_host_speed(struct Scsi_Host
*shost
)
5731 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5732 struct lpfc_hba
*phba
= vport
->phba
;
5734 spin_lock_irq(shost
->host_lock
);
5736 if ((lpfc_is_link_up(phba
)) && (!(phba
->hba_flag
& HBA_FCOE_MODE
))) {
5737 switch(phba
->fc_linkspeed
) {
5738 case LPFC_LINK_SPEED_1GHZ
:
5739 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
5741 case LPFC_LINK_SPEED_2GHZ
:
5742 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
5744 case LPFC_LINK_SPEED_4GHZ
:
5745 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
5747 case LPFC_LINK_SPEED_8GHZ
:
5748 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
5750 case LPFC_LINK_SPEED_10GHZ
:
5751 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
5753 case LPFC_LINK_SPEED_16GHZ
:
5754 fc_host_speed(shost
) = FC_PORTSPEED_16GBIT
;
5756 case LPFC_LINK_SPEED_32GHZ
:
5757 fc_host_speed(shost
) = FC_PORTSPEED_32GBIT
;
5759 case LPFC_LINK_SPEED_64GHZ
:
5760 fc_host_speed(shost
) = FC_PORTSPEED_64GBIT
;
5763 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5767 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5769 spin_unlock_irq(shost
->host_lock
);
5773 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
5774 * @shost: kernel scsi host pointer.
5777 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
5779 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5780 struct lpfc_hba
*phba
= vport
->phba
;
5783 spin_lock_irq(shost
->host_lock
);
5785 if ((vport
->port_state
> LPFC_FLOGI
) &&
5786 ((vport
->fc_flag
& FC_FABRIC
) ||
5787 ((phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) &&
5788 (vport
->fc_flag
& FC_PUBLIC_LOOP
))))
5789 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
5791 /* fabric is local port if there is no F/FL_Port */
5794 spin_unlock_irq(shost
->host_lock
);
5796 fc_host_fabric_name(shost
) = node_name
;
5800 * lpfc_get_stats - Return statistical information about the adapter
5801 * @shost: kernel scsi host pointer.
5804 * NULL on error for link down, no mbox pool, sli2 active,
5805 * management not allowed, memory allocation error, or mbox error.
5809 * address of the adapter host statistics
5811 static struct fc_host_statistics
*
5812 lpfc_get_stats(struct Scsi_Host
*shost
)
5814 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5815 struct lpfc_hba
*phba
= vport
->phba
;
5816 struct lpfc_sli
*psli
= &phba
->sli
;
5817 struct fc_host_statistics
*hs
= &phba
->link_stats
;
5818 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
5819 LPFC_MBOXQ_t
*pmboxq
;
5821 unsigned long seconds
;
5825 * prevent udev from issuing mailbox commands until the port is
5828 if (phba
->link_state
< LPFC_LINK_DOWN
||
5829 !phba
->mbox_mem_pool
||
5830 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
5833 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5836 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5839 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5841 pmb
= &pmboxq
->u
.mb
;
5842 pmb
->mbxCommand
= MBX_READ_STATUS
;
5843 pmb
->mbxOwner
= OWN_HOST
;
5844 pmboxq
->context1
= NULL
;
5845 pmboxq
->vport
= vport
;
5847 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5848 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5850 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5852 if (rc
!= MBX_SUCCESS
) {
5853 if (rc
!= MBX_TIMEOUT
)
5854 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5858 memset(hs
, 0, sizeof (struct fc_host_statistics
));
5860 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
5862 * The MBX_READ_STATUS returns tx_k_bytes which has to
5863 * converted to words
5865 hs
->tx_words
= (uint64_t)
5866 ((uint64_t)pmb
->un
.varRdStatus
.xmitByteCnt
5868 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
5869 hs
->rx_words
= (uint64_t)
5870 ((uint64_t)pmb
->un
.varRdStatus
.rcvByteCnt
5873 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5874 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5875 pmb
->mbxOwner
= OWN_HOST
;
5876 pmboxq
->context1
= NULL
;
5877 pmboxq
->vport
= vport
;
5879 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5880 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5882 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5884 if (rc
!= MBX_SUCCESS
) {
5885 if (rc
!= MBX_TIMEOUT
)
5886 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5890 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5891 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5892 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5893 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5894 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5895 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5896 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5898 hs
->link_failure_count
-= lso
->link_failure_count
;
5899 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
5900 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
5901 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
5902 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
5903 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
5904 hs
->error_frames
-= lso
->error_frames
;
5906 if (phba
->hba_flag
& HBA_FCOE_MODE
) {
5908 hs
->nos_count
= (phba
->link_events
>> 1);
5909 hs
->nos_count
-= lso
->link_events
;
5910 } else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5911 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
5912 hs
->lip_count
-= lso
->link_events
;
5916 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
5917 hs
->nos_count
-= lso
->link_events
;
5920 hs
->dumped_frames
= -1;
5922 seconds
= get_seconds();
5923 if (seconds
< psli
->stats_start
)
5924 hs
->seconds_since_last_reset
= seconds
+
5925 ((unsigned long)-1 - psli
->stats_start
);
5927 hs
->seconds_since_last_reset
= seconds
- psli
->stats_start
;
5929 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5935 * lpfc_reset_stats - Copy the adapter link stats information
5936 * @shost: kernel scsi host pointer.
5939 lpfc_reset_stats(struct Scsi_Host
*shost
)
5941 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5942 struct lpfc_hba
*phba
= vport
->phba
;
5943 struct lpfc_sli
*psli
= &phba
->sli
;
5944 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
5945 LPFC_MBOXQ_t
*pmboxq
;
5949 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5952 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5955 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5957 pmb
= &pmboxq
->u
.mb
;
5958 pmb
->mbxCommand
= MBX_READ_STATUS
;
5959 pmb
->mbxOwner
= OWN_HOST
;
5960 pmb
->un
.varWords
[0] = 0x1; /* reset request */
5961 pmboxq
->context1
= NULL
;
5962 pmboxq
->vport
= vport
;
5964 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5965 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5966 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5968 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5970 if (rc
!= MBX_SUCCESS
) {
5971 if (rc
!= MBX_TIMEOUT
)
5972 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5976 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5977 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5978 pmb
->mbxOwner
= OWN_HOST
;
5979 pmboxq
->context1
= NULL
;
5980 pmboxq
->vport
= vport
;
5982 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5983 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5984 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5986 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5988 if (rc
!= MBX_SUCCESS
) {
5989 if (rc
!= MBX_TIMEOUT
)
5990 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
5994 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5995 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5996 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5997 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5998 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5999 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
6000 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
6001 if (phba
->hba_flag
& HBA_FCOE_MODE
)
6002 lso
->link_events
= (phba
->link_events
>> 1);
6004 lso
->link_events
= (phba
->fc_eventTag
>> 1);
6006 psli
->stats_start
= get_seconds();
6008 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
6014 * The LPFC driver treats linkdown handling as target loss events so there
6015 * are no sysfs handlers for link_down_tmo.
6019 * lpfc_get_node_by_target - Return the nodelist for a target
6020 * @starget: kernel scsi target pointer.
6023 * address of the node list if found
6024 * NULL target not found
6026 static struct lpfc_nodelist
*
6027 lpfc_get_node_by_target(struct scsi_target
*starget
)
6029 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
6030 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
6031 struct lpfc_nodelist
*ndlp
;
6033 spin_lock_irq(shost
->host_lock
);
6034 /* Search for this, mapped, target ID */
6035 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
6036 if (NLP_CHK_NODE_ACT(ndlp
) &&
6037 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
6038 starget
->id
== ndlp
->nlp_sid
) {
6039 spin_unlock_irq(shost
->host_lock
);
6043 spin_unlock_irq(shost
->host_lock
);
6048 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
6049 * @starget: kernel scsi target pointer.
6052 lpfc_get_starget_port_id(struct scsi_target
*starget
)
6054 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6056 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
6060 * lpfc_get_starget_node_name - Set the target node name
6061 * @starget: kernel scsi target pointer.
6063 * Description: Set the target node name to the ndlp node name wwn or zero.
6066 lpfc_get_starget_node_name(struct scsi_target
*starget
)
6068 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6070 fc_starget_node_name(starget
) =
6071 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
6075 * lpfc_get_starget_port_name - Set the target port name
6076 * @starget: kernel scsi target pointer.
6078 * Description: set the target port name to the ndlp port name wwn or zero.
6081 lpfc_get_starget_port_name(struct scsi_target
*starget
)
6083 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6085 fc_starget_port_name(starget
) =
6086 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
6090 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
6091 * @rport: fc rport address.
6092 * @timeout: new value for dev loss tmo.
6095 * If timeout is non zero set the dev_loss_tmo to timeout, else set
6096 * dev_loss_tmo to one.
6099 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
6102 rport
->dev_loss_tmo
= timeout
;
6104 rport
->dev_loss_tmo
= 1;
6108 * lpfc_rport_show_function - Return rport target information
6111 * Macro that uses field to generate a function with the name lpfc_show_rport_
6113 * lpfc_show_rport_##field: returns the bytes formatted in buf
6114 * @cdev: class converted to an fc_rport.
6115 * @buf: on return contains the target_field or zero.
6117 * Returns: size of formatted string.
6119 #define lpfc_rport_show_function(field, format_string, sz, cast) \
6121 lpfc_show_rport_##field (struct device *dev, \
6122 struct device_attribute *attr, \
6125 struct fc_rport *rport = transport_class_to_rport(dev); \
6126 struct lpfc_rport_data *rdata = rport->hostdata; \
6127 return scnprintf(buf, sz, format_string, \
6128 (rdata->target) ? cast rdata->target->field : 0); \
6131 #define lpfc_rport_rd_attr(field, format_string, sz) \
6132 lpfc_rport_show_function(field, format_string, sz, ) \
6133 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
6136 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
6137 * @fc_vport: The fc_vport who's symbolic name has been changed.
6140 * This function is called by the transport after the @fc_vport's symbolic name
6141 * has been changed. This function re-registers the symbolic name with the
6142 * switch to propagate the change into the fabric if the vport is active.
6145 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
6147 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
6149 if (vport
->port_state
== LPFC_VPORT_READY
)
6150 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
6154 * lpfc_hba_log_verbose_init - Set hba's log verbose level
6155 * @phba: Pointer to lpfc_hba struct.
6157 * This function is called by the lpfc_get_cfgparam() routine to set the
6158 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
6159 * log message according to the module's lpfc_log_verbose parameter setting
6160 * before hba port or vport created.
6163 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
6165 phba
->cfg_log_verbose
= verbose
;
6168 struct fc_function_template lpfc_transport_functions
= {
6169 /* fixed attributes the driver supports */
6170 .show_host_node_name
= 1,
6171 .show_host_port_name
= 1,
6172 .show_host_supported_classes
= 1,
6173 .show_host_supported_fc4s
= 1,
6174 .show_host_supported_speeds
= 1,
6175 .show_host_maxframe_size
= 1,
6177 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6178 .show_host_symbolic_name
= 1,
6180 /* dynamic attributes the driver supports */
6181 .get_host_port_id
= lpfc_get_host_port_id
,
6182 .show_host_port_id
= 1,
6184 .get_host_port_type
= lpfc_get_host_port_type
,
6185 .show_host_port_type
= 1,
6187 .get_host_port_state
= lpfc_get_host_port_state
,
6188 .show_host_port_state
= 1,
6190 /* active_fc4s is shown but doesn't change (thus no get function) */
6191 .show_host_active_fc4s
= 1,
6193 .get_host_speed
= lpfc_get_host_speed
,
6194 .show_host_speed
= 1,
6196 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6197 .show_host_fabric_name
= 1,
6200 * The LPFC driver treats linkdown handling as target loss events
6201 * so there are no sysfs handlers for link_down_tmo.
6204 .get_fc_host_stats
= lpfc_get_stats
,
6205 .reset_fc_host_stats
= lpfc_reset_stats
,
6207 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6208 .show_rport_maxframe_size
= 1,
6209 .show_rport_supported_classes
= 1,
6211 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6212 .show_rport_dev_loss_tmo
= 1,
6214 .get_starget_port_id
= lpfc_get_starget_port_id
,
6215 .show_starget_port_id
= 1,
6217 .get_starget_node_name
= lpfc_get_starget_node_name
,
6218 .show_starget_node_name
= 1,
6220 .get_starget_port_name
= lpfc_get_starget_port_name
,
6221 .show_starget_port_name
= 1,
6223 .issue_fc_host_lip
= lpfc_issue_lip
,
6224 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6225 .terminate_rport_io
= lpfc_terminate_rport_io
,
6227 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
6229 .vport_disable
= lpfc_vport_disable
,
6231 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6233 .bsg_request
= lpfc_bsg_request
,
6234 .bsg_timeout
= lpfc_bsg_timeout
,
6237 struct fc_function_template lpfc_vport_transport_functions
= {
6238 /* fixed attributes the driver supports */
6239 .show_host_node_name
= 1,
6240 .show_host_port_name
= 1,
6241 .show_host_supported_classes
= 1,
6242 .show_host_supported_fc4s
= 1,
6243 .show_host_supported_speeds
= 1,
6244 .show_host_maxframe_size
= 1,
6246 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6247 .show_host_symbolic_name
= 1,
6249 /* dynamic attributes the driver supports */
6250 .get_host_port_id
= lpfc_get_host_port_id
,
6251 .show_host_port_id
= 1,
6253 .get_host_port_type
= lpfc_get_host_port_type
,
6254 .show_host_port_type
= 1,
6256 .get_host_port_state
= lpfc_get_host_port_state
,
6257 .show_host_port_state
= 1,
6259 /* active_fc4s is shown but doesn't change (thus no get function) */
6260 .show_host_active_fc4s
= 1,
6262 .get_host_speed
= lpfc_get_host_speed
,
6263 .show_host_speed
= 1,
6265 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6266 .show_host_fabric_name
= 1,
6269 * The LPFC driver treats linkdown handling as target loss events
6270 * so there are no sysfs handlers for link_down_tmo.
6273 .get_fc_host_stats
= lpfc_get_stats
,
6274 .reset_fc_host_stats
= lpfc_reset_stats
,
6276 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6277 .show_rport_maxframe_size
= 1,
6278 .show_rport_supported_classes
= 1,
6280 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6281 .show_rport_dev_loss_tmo
= 1,
6283 .get_starget_port_id
= lpfc_get_starget_port_id
,
6284 .show_starget_port_id
= 1,
6286 .get_starget_node_name
= lpfc_get_starget_node_name
,
6287 .show_starget_node_name
= 1,
6289 .get_starget_port_name
= lpfc_get_starget_port_name
,
6290 .show_starget_port_name
= 1,
6292 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6293 .terminate_rport_io
= lpfc_terminate_rport_io
,
6295 .vport_disable
= lpfc_vport_disable
,
6297 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6301 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
6302 * @phba: lpfc_hba pointer.
6305 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
6307 lpfc_fcp_io_sched_init(phba
, lpfc_fcp_io_sched
);
6308 lpfc_fcp2_no_tgt_reset_init(phba
, lpfc_fcp2_no_tgt_reset
);
6309 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
6310 lpfc_cr_count_init(phba
, lpfc_cr_count
);
6311 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
6312 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
6313 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
6314 lpfc_ack0_init(phba
, lpfc_ack0
);
6315 lpfc_topology_init(phba
, lpfc_topology
);
6316 lpfc_link_speed_init(phba
, lpfc_link_speed
);
6317 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
6318 lpfc_task_mgmt_tmo_init(phba
, lpfc_task_mgmt_tmo
);
6319 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
6320 lpfc_fcf_failover_policy_init(phba
, lpfc_fcf_failover_policy
);
6321 lpfc_enable_rrq_init(phba
, lpfc_enable_rrq
);
6322 lpfc_fdmi_on_init(phba
, lpfc_fdmi_on
);
6323 lpfc_enable_SmartSAN_init(phba
, lpfc_enable_SmartSAN
);
6324 lpfc_use_msi_init(phba
, lpfc_use_msi
);
6325 lpfc_nvme_oas_init(phba
, lpfc_nvme_oas
);
6326 lpfc_nvme_embed_cmd_init(phba
, lpfc_nvme_embed_cmd
);
6327 lpfc_auto_imax_init(phba
, lpfc_auto_imax
);
6328 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
6329 lpfc_fcp_cpu_map_init(phba
, lpfc_fcp_cpu_map
);
6330 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
6331 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
6333 lpfc_EnableXLane_init(phba
, lpfc_EnableXLane
);
6334 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
6335 phba
->cfg_EnableXLane
= 0;
6336 lpfc_XLanePriority_init(phba
, lpfc_XLanePriority
);
6338 memset(phba
->cfg_oas_tgt_wwpn
, 0, (8 * sizeof(uint8_t)));
6339 memset(phba
->cfg_oas_vpt_wwpn
, 0, (8 * sizeof(uint8_t)));
6340 phba
->cfg_oas_lun_state
= 0;
6341 phba
->cfg_oas_lun_status
= 0;
6342 phba
->cfg_oas_flags
= 0;
6343 phba
->cfg_oas_priority
= 0;
6344 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
6345 lpfc_prot_mask_init(phba
, lpfc_prot_mask
);
6346 lpfc_prot_guard_init(phba
, lpfc_prot_guard
);
6347 if (phba
->sli_rev
== LPFC_SLI_REV4
)
6350 phba
->cfg_poll
= lpfc_poll
;
6351 lpfc_suppress_rsp_init(phba
, lpfc_suppress_rsp
);
6353 lpfc_enable_fc4_type_init(phba
, lpfc_enable_fc4_type
);
6354 lpfc_nvmet_mrq_init(phba
, lpfc_nvmet_mrq
);
6356 /* Initialize first burst. Target vs Initiator are different. */
6357 lpfc_nvme_enable_fb_init(phba
, lpfc_nvme_enable_fb
);
6358 lpfc_nvmet_fb_size_init(phba
, lpfc_nvmet_fb_size
);
6359 lpfc_fcp_io_channel_init(phba
, lpfc_fcp_io_channel
);
6360 lpfc_nvme_io_channel_init(phba
, lpfc_nvme_io_channel
);
6361 lpfc_enable_bbcr_init(phba
, lpfc_enable_bbcr
);
6362 lpfc_enable_dpp_init(phba
, lpfc_enable_dpp
);
6364 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
6365 /* NVME only supported on SLI4 */
6366 phba
->nvmet_support
= 0;
6367 phba
->cfg_enable_fc4_type
= LPFC_ENABLE_FCP
;
6368 phba
->cfg_enable_bbcr
= 0;
6370 /* We MUST have FCP support */
6371 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_FCP
))
6372 phba
->cfg_enable_fc4_type
|= LPFC_ENABLE_FCP
;
6375 if (phba
->cfg_auto_imax
&& !phba
->cfg_fcp_imax
)
6376 phba
->cfg_auto_imax
= 0;
6377 phba
->initial_imax
= phba
->cfg_fcp_imax
;
6379 /* A value of 0 means use the number of CPUs found in the system */
6380 if (phba
->cfg_fcp_io_channel
== 0)
6381 phba
->cfg_fcp_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6382 if (phba
->cfg_nvme_io_channel
== 0)
6383 phba
->cfg_nvme_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6385 if (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
)
6386 phba
->cfg_fcp_io_channel
= 0;
6388 if (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_FCP
)
6389 phba
->cfg_nvme_io_channel
= 0;
6391 if (phba
->cfg_fcp_io_channel
> phba
->cfg_nvme_io_channel
)
6392 phba
->io_channel_irqs
= phba
->cfg_fcp_io_channel
;
6394 phba
->io_channel_irqs
= phba
->cfg_nvme_io_channel
;
6396 phba
->cfg_soft_wwnn
= 0L;
6397 phba
->cfg_soft_wwpn
= 0L;
6398 lpfc_xri_split_init(phba
, lpfc_xri_split
);
6399 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
6400 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
6401 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
6402 lpfc_aer_support_init(phba
, lpfc_aer_support
);
6403 lpfc_sriov_nr_virtfn_init(phba
, lpfc_sriov_nr_virtfn
);
6404 lpfc_request_firmware_upgrade_init(phba
, lpfc_req_fw_upgrade
);
6405 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
6406 lpfc_iocb_cnt_init(phba
, lpfc_iocb_cnt
);
6407 lpfc_delay_discovery_init(phba
, lpfc_delay_discovery
);
6408 lpfc_sli_mode_init(phba
, lpfc_sli_mode
);
6409 phba
->cfg_enable_dss
= 1;
6410 lpfc_enable_mds_diags_init(phba
, lpfc_enable_mds_diags
);
6415 * lpfc_nvme_mod_param_dep - Adjust module parameter value based on
6416 * dependencies between protocols and roles.
6417 * @phba: lpfc_hba pointer.
6420 lpfc_nvme_mod_param_dep(struct lpfc_hba
*phba
)
6422 if (phba
->cfg_nvme_io_channel
> phba
->sli4_hba
.num_present_cpu
)
6423 phba
->cfg_nvme_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6425 if (phba
->cfg_fcp_io_channel
> phba
->sli4_hba
.num_present_cpu
)
6426 phba
->cfg_fcp_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6428 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
&&
6429 phba
->nvmet_support
) {
6430 phba
->cfg_enable_fc4_type
&= ~LPFC_ENABLE_FCP
;
6431 phba
->cfg_fcp_io_channel
= 0;
6433 lpfc_printf_log(phba
, KERN_INFO
, LOG_NVME_DISC
,
6434 "6013 %s x%x fb_size x%x, fb_max x%x\n",
6435 "NVME Target PRLI ACC enable_fb ",
6436 phba
->cfg_nvme_enable_fb
,
6437 phba
->cfg_nvmet_fb_size
,
6438 LPFC_NVMET_FB_SZ_MAX
);
6440 if (phba
->cfg_nvme_enable_fb
== 0)
6441 phba
->cfg_nvmet_fb_size
= 0;
6443 if (phba
->cfg_nvmet_fb_size
> LPFC_NVMET_FB_SZ_MAX
)
6444 phba
->cfg_nvmet_fb_size
= LPFC_NVMET_FB_SZ_MAX
;
6447 if (!phba
->cfg_nvmet_mrq
)
6448 phba
->cfg_nvmet_mrq
= phba
->cfg_nvme_io_channel
;
6450 /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */
6451 if (phba
->cfg_nvmet_mrq
> phba
->cfg_nvme_io_channel
) {
6452 phba
->cfg_nvmet_mrq
= phba
->cfg_nvme_io_channel
;
6453 lpfc_printf_log(phba
, KERN_ERR
, LOG_NVME_DISC
,
6454 "6018 Adjust lpfc_nvmet_mrq to %d\n",
6455 phba
->cfg_nvmet_mrq
);
6457 if (phba
->cfg_nvmet_mrq
> LPFC_NVMET_MRQ_MAX
)
6458 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_MAX
;
6461 /* Not NVME Target mode. Turn off Target parameters. */
6462 phba
->nvmet_support
= 0;
6463 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_OFF
;
6464 phba
->cfg_nvmet_fb_size
= 0;
6467 if (phba
->cfg_fcp_io_channel
> phba
->cfg_nvme_io_channel
)
6468 phba
->io_channel_irqs
= phba
->cfg_fcp_io_channel
;
6470 phba
->io_channel_irqs
= phba
->cfg_nvme_io_channel
;
6474 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
6475 * @vport: lpfc_vport pointer.
6478 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
6480 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
6481 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
6482 lpfc_tgt_queue_depth_init(vport
, lpfc_tgt_queue_depth
);
6483 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
6484 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
6485 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
6486 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
6487 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
6488 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
6489 lpfc_first_burst_size_init(vport
, lpfc_first_burst_size
);
6490 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
6491 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
6492 lpfc_max_luns_init(vport
, lpfc_max_luns
);
6493 lpfc_scan_down_init(vport
, lpfc_scan_down
);
6494 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);