1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Limited and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
9 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
11 * This program is free software; you can redistribute it and/or *
12 * modify it under the terms of version 2 of the GNU General *
13 * Public License as published by the Free Software Foundation. *
14 * This program is distributed in the hope that it will be useful. *
15 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
16 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
17 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
18 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
19 * TO BE LEGALLY INVALID. See the GNU General Public License for *
20 * more details, a copy of which can be found in the file COPYING *
21 * included with this package. *
22 *******************************************************************/
24 #include <linux/ctype.h>
25 #include <linux/delay.h>
26 #include <linux/pci.h>
27 #include <linux/interrupt.h>
28 #include <linux/module.h>
29 #include <linux/aer.h>
30 #include <linux/gfp.h>
31 #include <linux/kernel.h>
33 #include <scsi/scsi.h>
34 #include <scsi/scsi_device.h>
35 #include <scsi/scsi_host.h>
36 #include <scsi/scsi_tcq.h>
37 #include <scsi/scsi_transport_fc.h>
38 #include <scsi/fc/fc_fs.h>
40 #include <linux/nvme-fc-driver.h>
45 #include "lpfc_sli4.h"
47 #include "lpfc_disc.h"
49 #include "lpfc_scsi.h"
50 #include "lpfc_nvme.h"
51 #include "lpfc_nvmet.h"
52 #include "lpfc_logmsg.h"
53 #include "lpfc_version.h"
54 #include "lpfc_compat.h"
55 #include "lpfc_crtn.h"
56 #include "lpfc_vport.h"
57 #include "lpfc_attr.h"
59 #define LPFC_DEF_DEVLOSS_TMO 30
60 #define LPFC_MIN_DEVLOSS_TMO 1
61 #define LPFC_MAX_DEVLOSS_TMO 255
63 #define LPFC_DEF_MRQ_POST 512
64 #define LPFC_MIN_MRQ_POST 512
65 #define LPFC_MAX_MRQ_POST 2048
68 * Write key size should be multiple of 4. If write key is changed
69 * make sure that library write key is also changed.
71 #define LPFC_REG_WRITE_KEY_SIZE 4
72 #define LPFC_REG_WRITE_KEY "EMLX"
75 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
76 * @incr: integer to convert.
77 * @hdw: ascii string holding converted integer plus a string terminator.
80 * JEDEC Joint Electron Device Engineering Council.
81 * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii
82 * character string. The string is then terminated with a NULL in byte 9.
83 * Hex 0-9 becomes ascii '0' to '9'.
84 * Hex a-f becomes ascii '=' to 'B' capital B.
87 * Coded for 32 bit integers only.
90 lpfc_jedec_to_ascii(int incr
, char hdw
[])
93 for (i
= 0; i
< 8; i
++) {
96 hdw
[7 - i
] = 0x30 + j
;
98 hdw
[7 - i
] = 0x61 + j
- 10;
106 * lpfc_drvr_version_show - Return the Emulex driver string with version number
107 * @dev: class unused variable.
108 * @attr: device attribute, not used.
109 * @buf: on return contains the module description text.
111 * Returns: size of formatted string.
114 lpfc_drvr_version_show(struct device
*dev
, struct device_attribute
*attr
,
117 return snprintf(buf
, PAGE_SIZE
, LPFC_MODULE_DESC
"\n");
121 * lpfc_enable_fip_show - Return the fip mode of the HBA
122 * @dev: class unused variable.
123 * @attr: device attribute, not used.
124 * @buf: on return contains the module description text.
126 * Returns: size of formatted string.
129 lpfc_enable_fip_show(struct device
*dev
, struct device_attribute
*attr
,
132 struct Scsi_Host
*shost
= class_to_shost(dev
);
133 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
134 struct lpfc_hba
*phba
= vport
->phba
;
136 if (phba
->hba_flag
& HBA_FIP_SUPPORT
)
137 return snprintf(buf
, PAGE_SIZE
, "1\n");
139 return snprintf(buf
, PAGE_SIZE
, "0\n");
143 lpfc_nvme_info_show(struct device
*dev
, struct device_attribute
*attr
,
146 struct Scsi_Host
*shost
= class_to_shost(dev
);
147 struct lpfc_vport
*vport
= shost_priv(shost
);
148 struct lpfc_hba
*phba
= vport
->phba
;
149 struct lpfc_nvmet_tgtport
*tgtp
;
150 struct nvme_fc_local_port
*localport
;
151 struct lpfc_nvme_lport
*lport
;
152 struct lpfc_nodelist
*ndlp
;
153 struct nvme_fc_remote_port
*nrport
;
154 uint64_t data1
, data2
, data3
, tot
;
158 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
)) {
159 len
+= snprintf(buf
, PAGE_SIZE
, "NVME Disabled\n");
162 if (phba
->nvmet_support
) {
163 if (!phba
->targetport
) {
164 len
= snprintf(buf
, PAGE_SIZE
,
165 "NVME Target: x%llx is not allocated\n",
166 wwn_to_u64(vport
->fc_portname
.u
.wwn
));
169 /* Port state is only one of two values for now. */
170 if (phba
->targetport
->port_id
)
171 statep
= "REGISTERED";
174 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
175 "NVME Target Enabled State %s\n",
177 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
178 "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
181 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
182 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
183 phba
->targetport
->port_id
);
185 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
186 "\nNVME Target: Statistics\n");
187 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
188 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
189 "LS: Rcv %08x Drop %08x Abort %08x\n",
190 atomic_read(&tgtp
->rcv_ls_req_in
),
191 atomic_read(&tgtp
->rcv_ls_req_drop
),
192 atomic_read(&tgtp
->xmt_ls_abort
));
193 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
194 atomic_read(&tgtp
->rcv_ls_req_out
)) {
195 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
196 "Rcv LS: in %08x != out %08x\n",
197 atomic_read(&tgtp
->rcv_ls_req_in
),
198 atomic_read(&tgtp
->rcv_ls_req_out
));
201 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
202 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
203 atomic_read(&tgtp
->xmt_ls_rsp
),
204 atomic_read(&tgtp
->xmt_ls_drop
),
205 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
));
207 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
208 "LS: RSP Abort %08x xb %08x Err %08x\n",
209 atomic_read(&tgtp
->xmt_ls_rsp_aborted
),
210 atomic_read(&tgtp
->xmt_ls_rsp_xb_set
),
211 atomic_read(&tgtp
->xmt_ls_rsp_error
));
213 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
214 "FCP: Rcv %08x Defer %08x Release %08x "
216 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
217 atomic_read(&tgtp
->rcv_fcp_cmd_defer
),
218 atomic_read(&tgtp
->xmt_fcp_release
),
219 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
221 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
222 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
223 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
224 "Rcv FCP: in %08x != out %08x\n",
225 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
226 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
229 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
230 "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x "
232 atomic_read(&tgtp
->xmt_fcp_read
),
233 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
234 atomic_read(&tgtp
->xmt_fcp_write
),
235 atomic_read(&tgtp
->xmt_fcp_rsp
),
236 atomic_read(&tgtp
->xmt_fcp_drop
));
238 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
239 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
240 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
241 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
242 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
244 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
245 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
246 atomic_read(&tgtp
->xmt_fcp_rsp_aborted
),
247 atomic_read(&tgtp
->xmt_fcp_rsp_xb_set
),
248 atomic_read(&tgtp
->xmt_fcp_xri_abort_cqe
));
250 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
251 "ABORT: Xmt %08x Cmpl %08x\n",
252 atomic_read(&tgtp
->xmt_fcp_abort
),
253 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
255 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
256 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
257 atomic_read(&tgtp
->xmt_abort_sol
),
258 atomic_read(&tgtp
->xmt_abort_unsol
),
259 atomic_read(&tgtp
->xmt_abort_rsp
),
260 atomic_read(&tgtp
->xmt_abort_rsp_error
));
262 /* Calculate outstanding IOs */
263 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_drop
);
264 tot
+= atomic_read(&tgtp
->xmt_fcp_release
);
265 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_in
) - tot
;
267 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
268 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
269 "CTX Outstanding %08llx\n",
270 phba
->sli4_hba
.nvmet_xri_cnt
,
271 phba
->sli4_hba
.nvmet_io_wait_cnt
,
272 phba
->sli4_hba
.nvmet_io_wait_total
,
275 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
, "\n");
279 localport
= vport
->localport
;
281 len
= snprintf(buf
, PAGE_SIZE
,
282 "NVME Initiator x%llx is not allocated\n",
283 wwn_to_u64(vport
->fc_portname
.u
.wwn
));
286 lport
= (struct lpfc_nvme_lport
*)localport
->private;
287 len
= snprintf(buf
, PAGE_SIZE
, "NVME Initiator Enabled\n");
289 spin_lock_irq(shost
->host_lock
);
291 /* Port state is only one of two values for now. */
292 if (localport
->port_id
)
297 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
298 "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
301 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
302 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
303 localport
->port_id
, statep
);
305 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
309 /* local short-hand pointer. */
310 nrport
= ndlp
->nrport
->remoteport
;
312 /* Port state is only one of two values for now. */
313 switch (nrport
->port_state
) {
314 case FC_OBJSTATE_ONLINE
:
317 case FC_OBJSTATE_UNKNOWN
:
321 statep
= "UNSUPPORTED";
325 /* Tab in to show lport ownership. */
326 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
328 if (phba
->brd_no
>= 10)
329 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, " ");
331 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "WWPN x%llx ",
333 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "WWNN x%llx ",
335 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "DID x%06x ",
338 /* An NVME rport can have multiple roles. */
339 if (nrport
->port_role
& FC_PORT_ROLE_NVME_INITIATOR
)
340 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
342 if (nrport
->port_role
& FC_PORT_ROLE_NVME_TARGET
)
343 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
345 if (nrport
->port_role
& FC_PORT_ROLE_NVME_DISCOVERY
)
346 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
348 if (nrport
->port_role
& ~(FC_PORT_ROLE_NVME_INITIATOR
|
349 FC_PORT_ROLE_NVME_TARGET
|
350 FC_PORT_ROLE_NVME_DISCOVERY
))
351 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
355 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "%s ", statep
);
356 /* Terminate the string. */
357 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "\n");
359 spin_unlock_irq(shost
->host_lock
);
361 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "\nNVME Statistics\n");
362 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
363 "LS: Xmt %010x Cmpl %010x Abort %08x\n",
364 atomic_read(&phba
->fc4NvmeLsRequests
),
365 atomic_read(&phba
->fc4NvmeLsCmpls
),
366 atomic_read(&lport
->xmt_ls_abort
));
368 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
369 "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n",
370 atomic_read(&lport
->xmt_ls_err
),
371 atomic_read(&lport
->cmpl_ls_xb
),
372 atomic_read(&lport
->cmpl_ls_err
));
374 tot
= atomic_read(&phba
->fc4NvmeIoCmpls
);
375 data1
= atomic_read(&phba
->fc4NvmeInputRequests
);
376 data2
= atomic_read(&phba
->fc4NvmeOutputRequests
);
377 data3
= atomic_read(&phba
->fc4NvmeControlRequests
);
378 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
379 "FCP: Rd %016llx Wr %016llx IO %016llx\n",
380 data1
, data2
, data3
);
382 len
+= snprintf(buf
+len
, PAGE_SIZE
-len
,
383 " noxri %08x nondlp %08x qdepth %08x "
385 atomic_read(&lport
->xmt_fcp_noxri
),
386 atomic_read(&lport
->xmt_fcp_bad_ndlp
),
387 atomic_read(&lport
->xmt_fcp_qdepth
),
388 atomic_read(&lport
->xmt_fcp_wqerr
));
390 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
391 " Cmpl %016llx Outstanding %016llx Abort %08x\n",
392 tot
, ((data1
+ data2
+ data3
) - tot
),
393 atomic_read(&lport
->xmt_fcp_abort
));
395 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
396 "FCP CMPL: xb %08x Err %08x\n",
397 atomic_read(&lport
->cmpl_fcp_xb
),
398 atomic_read(&lport
->cmpl_fcp_err
));
403 lpfc_bg_info_show(struct device
*dev
, struct device_attribute
*attr
,
406 struct Scsi_Host
*shost
= class_to_shost(dev
);
407 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
408 struct lpfc_hba
*phba
= vport
->phba
;
410 if (phba
->cfg_enable_bg
)
411 if (phba
->sli3_options
& LPFC_SLI3_BG_ENABLED
)
412 return snprintf(buf
, PAGE_SIZE
, "BlockGuard Enabled\n");
414 return snprintf(buf
, PAGE_SIZE
,
415 "BlockGuard Not Supported\n");
417 return snprintf(buf
, PAGE_SIZE
,
418 "BlockGuard Disabled\n");
422 lpfc_bg_guard_err_show(struct device
*dev
, struct device_attribute
*attr
,
425 struct Scsi_Host
*shost
= class_to_shost(dev
);
426 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
427 struct lpfc_hba
*phba
= vport
->phba
;
429 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
430 (unsigned long long)phba
->bg_guard_err_cnt
);
434 lpfc_bg_apptag_err_show(struct device
*dev
, struct device_attribute
*attr
,
437 struct Scsi_Host
*shost
= class_to_shost(dev
);
438 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
439 struct lpfc_hba
*phba
= vport
->phba
;
441 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
442 (unsigned long long)phba
->bg_apptag_err_cnt
);
446 lpfc_bg_reftag_err_show(struct device
*dev
, struct device_attribute
*attr
,
449 struct Scsi_Host
*shost
= class_to_shost(dev
);
450 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
451 struct lpfc_hba
*phba
= vport
->phba
;
453 return snprintf(buf
, PAGE_SIZE
, "%llu\n",
454 (unsigned long long)phba
->bg_reftag_err_cnt
);
458 * lpfc_info_show - Return some pci info about the host in ascii
459 * @dev: class converted to a Scsi_host structure.
460 * @attr: device attribute, not used.
461 * @buf: on return contains the formatted text from lpfc_info().
463 * Returns: size of formatted string.
466 lpfc_info_show(struct device
*dev
, struct device_attribute
*attr
,
469 struct Scsi_Host
*host
= class_to_shost(dev
);
471 return snprintf(buf
, PAGE_SIZE
, "%s\n",lpfc_info(host
));
475 * lpfc_serialnum_show - Return the hba serial number in ascii
476 * @dev: class converted to a Scsi_host structure.
477 * @attr: device attribute, not used.
478 * @buf: on return contains the formatted text serial number.
480 * Returns: size of formatted string.
483 lpfc_serialnum_show(struct device
*dev
, struct device_attribute
*attr
,
486 struct Scsi_Host
*shost
= class_to_shost(dev
);
487 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
488 struct lpfc_hba
*phba
= vport
->phba
;
490 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->SerialNumber
);
494 * lpfc_temp_sensor_show - Return the temperature sensor level
495 * @dev: class converted to a Scsi_host structure.
496 * @attr: device attribute, not used.
497 * @buf: on return contains the formatted support level.
500 * Returns a number indicating the temperature sensor level currently
501 * supported, zero or one in ascii.
503 * Returns: size of formatted string.
506 lpfc_temp_sensor_show(struct device
*dev
, struct device_attribute
*attr
,
509 struct Scsi_Host
*shost
= class_to_shost(dev
);
510 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
511 struct lpfc_hba
*phba
= vport
->phba
;
512 return snprintf(buf
, PAGE_SIZE
, "%d\n",phba
->temp_sensor_support
);
516 * lpfc_modeldesc_show - Return the model description of the hba
517 * @dev: class converted to a Scsi_host structure.
518 * @attr: device attribute, not used.
519 * @buf: on return contains the scsi vpd model description.
521 * Returns: size of formatted string.
524 lpfc_modeldesc_show(struct device
*dev
, struct device_attribute
*attr
,
527 struct Scsi_Host
*shost
= class_to_shost(dev
);
528 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
529 struct lpfc_hba
*phba
= vport
->phba
;
531 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelDesc
);
535 * lpfc_modelname_show - Return the model name of the hba
536 * @dev: class converted to a Scsi_host structure.
537 * @attr: device attribute, not used.
538 * @buf: on return contains the scsi vpd model name.
540 * Returns: size of formatted string.
543 lpfc_modelname_show(struct device
*dev
, struct device_attribute
*attr
,
546 struct Scsi_Host
*shost
= class_to_shost(dev
);
547 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
548 struct lpfc_hba
*phba
= vport
->phba
;
550 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ModelName
);
554 * lpfc_programtype_show - Return the program type of the hba
555 * @dev: class converted to a Scsi_host structure.
556 * @attr: device attribute, not used.
557 * @buf: on return contains the scsi vpd program type.
559 * Returns: size of formatted string.
562 lpfc_programtype_show(struct device
*dev
, struct device_attribute
*attr
,
565 struct Scsi_Host
*shost
= class_to_shost(dev
);
566 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
567 struct lpfc_hba
*phba
= vport
->phba
;
569 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->ProgramType
);
573 * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag
574 * @dev: class converted to a Scsi_host structure.
575 * @attr: device attribute, not used.
576 * @buf: on return contains the Menlo Maintenance sli flag.
578 * Returns: size of formatted string.
581 lpfc_mlomgmt_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
583 struct Scsi_Host
*shost
= class_to_shost(dev
);
584 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
585 struct lpfc_hba
*phba
= vport
->phba
;
587 return snprintf(buf
, PAGE_SIZE
, "%d\n",
588 (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
));
592 * lpfc_vportnum_show - Return the port number in ascii of the hba
593 * @dev: class converted to a Scsi_host structure.
594 * @attr: device attribute, not used.
595 * @buf: on return contains scsi vpd program type.
597 * Returns: size of formatted string.
600 lpfc_vportnum_show(struct device
*dev
, struct device_attribute
*attr
,
603 struct Scsi_Host
*shost
= class_to_shost(dev
);
604 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
605 struct lpfc_hba
*phba
= vport
->phba
;
607 return snprintf(buf
, PAGE_SIZE
, "%s\n",phba
->Port
);
611 * lpfc_fwrev_show - Return the firmware rev running in the hba
612 * @dev: class converted to a Scsi_host structure.
613 * @attr: device attribute, not used.
614 * @buf: on return contains the scsi vpd program type.
616 * Returns: size of formatted string.
619 lpfc_fwrev_show(struct device
*dev
, struct device_attribute
*attr
,
622 struct Scsi_Host
*shost
= class_to_shost(dev
);
623 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
624 struct lpfc_hba
*phba
= vport
->phba
;
627 char fwrev
[FW_REV_STR_SIZE
];
630 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
631 if_type
= phba
->sli4_hba
.pc_sli4_params
.if_type
;
632 sli_family
= phba
->sli4_hba
.pc_sli4_params
.sli_family
;
634 if (phba
->sli_rev
< LPFC_SLI_REV4
)
635 len
= snprintf(buf
, PAGE_SIZE
, "%s, sli-%d\n",
636 fwrev
, phba
->sli_rev
);
638 len
= snprintf(buf
, PAGE_SIZE
, "%s, sli-%d:%d:%x\n",
639 fwrev
, phba
->sli_rev
, if_type
, sli_family
);
645 * lpfc_hdw_show - Return the jedec information about the hba
646 * @dev: class converted to a Scsi_host structure.
647 * @attr: device attribute, not used.
648 * @buf: on return contains the scsi vpd program type.
650 * Returns: size of formatted string.
653 lpfc_hdw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
656 struct Scsi_Host
*shost
= class_to_shost(dev
);
657 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
658 struct lpfc_hba
*phba
= vport
->phba
;
659 lpfc_vpd_t
*vp
= &phba
->vpd
;
661 lpfc_jedec_to_ascii(vp
->rev
.biuRev
, hdw
);
662 return snprintf(buf
, PAGE_SIZE
, "%s\n", hdw
);
666 * lpfc_option_rom_version_show - Return the adapter ROM FCode version
667 * @dev: class converted to a Scsi_host structure.
668 * @attr: device attribute, not used.
669 * @buf: on return contains the ROM and FCode ascii strings.
671 * Returns: size of formatted string.
674 lpfc_option_rom_version_show(struct device
*dev
, struct device_attribute
*attr
,
677 struct Scsi_Host
*shost
= class_to_shost(dev
);
678 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
679 struct lpfc_hba
*phba
= vport
->phba
;
680 char fwrev
[FW_REV_STR_SIZE
];
682 if (phba
->sli_rev
< LPFC_SLI_REV4
)
683 return snprintf(buf
, PAGE_SIZE
, "%s\n", phba
->OptionROMVersion
);
685 lpfc_decode_firmware_rev(phba
, fwrev
, 1);
686 return snprintf(buf
, PAGE_SIZE
, "%s\n", fwrev
);
690 * lpfc_state_show - Return the link state of the port
691 * @dev: class converted to a Scsi_host structure.
692 * @attr: device attribute, not used.
693 * @buf: on return contains text describing the state of the link.
696 * The switch statement has no default so zero will be returned.
698 * Returns: size of formatted string.
701 lpfc_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
704 struct Scsi_Host
*shost
= class_to_shost(dev
);
705 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
706 struct lpfc_hba
*phba
= vport
->phba
;
709 switch (phba
->link_state
) {
710 case LPFC_LINK_UNKNOWN
:
711 case LPFC_WARM_START
:
712 case LPFC_INIT_START
:
713 case LPFC_INIT_MBX_CMDS
:
716 if (phba
->hba_flag
& LINK_DISABLED
)
717 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
718 "Link Down - User disabled\n");
720 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
726 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Link Up - ");
728 switch (vport
->port_state
) {
729 case LPFC_LOCAL_CFG_LINK
:
730 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
731 "Configuring Link\n");
735 case LPFC_FABRIC_CFG_LINK
:
738 case LPFC_BUILD_DISC_LIST
:
740 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
743 case LPFC_VPORT_READY
:
744 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Ready\n");
747 case LPFC_VPORT_FAILED
:
748 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "Failed\n");
751 case LPFC_VPORT_UNKNOWN
:
752 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
756 if (phba
->sli
.sli_flag
& LPFC_MENLO_MAINT
)
757 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
758 " Menlo Maint Mode\n");
759 else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
760 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
761 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
764 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
767 if (vport
->fc_flag
& FC_FABRIC
)
768 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
771 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
780 * lpfc_sli4_protocol_show - Return the fip mode of the HBA
781 * @dev: class unused variable.
782 * @attr: device attribute, not used.
783 * @buf: on return contains the module description text.
785 * Returns: size of formatted string.
788 lpfc_sli4_protocol_show(struct device
*dev
, struct device_attribute
*attr
,
791 struct Scsi_Host
*shost
= class_to_shost(dev
);
792 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
793 struct lpfc_hba
*phba
= vport
->phba
;
795 if (phba
->sli_rev
< LPFC_SLI_REV4
)
796 return snprintf(buf
, PAGE_SIZE
, "fc\n");
798 if (phba
->sli4_hba
.lnk_info
.lnk_dv
== LPFC_LNK_DAT_VAL
) {
799 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_GE
)
800 return snprintf(buf
, PAGE_SIZE
, "fcoe\n");
801 if (phba
->sli4_hba
.lnk_info
.lnk_tp
== LPFC_LNK_TYPE_FC
)
802 return snprintf(buf
, PAGE_SIZE
, "fc\n");
804 return snprintf(buf
, PAGE_SIZE
, "unknown\n");
808 * lpfc_oas_supported_show - Return whether or not Optimized Access Storage
809 * (OAS) is supported.
810 * @dev: class unused variable.
811 * @attr: device attribute, not used.
812 * @buf: on return contains the module description text.
814 * Returns: size of formatted string.
817 lpfc_oas_supported_show(struct device
*dev
, struct device_attribute
*attr
,
820 struct Scsi_Host
*shost
= class_to_shost(dev
);
821 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
822 struct lpfc_hba
*phba
= vport
->phba
;
824 return snprintf(buf
, PAGE_SIZE
, "%d\n",
825 phba
->sli4_hba
.pc_sli4_params
.oas_supported
);
829 * lpfc_link_state_store - Transition the link_state on an HBA port
830 * @dev: class device that is converted into a Scsi_host.
831 * @attr: device attribute, not used.
832 * @buf: one or more lpfc_polling_flags values.
836 * -EINVAL if the buffer is not "up" or "down"
837 * return from link state change function if non-zero
838 * length of the buf on success
841 lpfc_link_state_store(struct device
*dev
, struct device_attribute
*attr
,
842 const char *buf
, size_t count
)
844 struct Scsi_Host
*shost
= class_to_shost(dev
);
845 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
846 struct lpfc_hba
*phba
= vport
->phba
;
848 int status
= -EINVAL
;
850 if ((strncmp(buf
, "up", sizeof("up") - 1) == 0) &&
851 (phba
->link_state
== LPFC_LINK_DOWN
))
852 status
= phba
->lpfc_hba_init_link(phba
, MBX_NOWAIT
);
853 else if ((strncmp(buf
, "down", sizeof("down") - 1) == 0) &&
854 (phba
->link_state
>= LPFC_LINK_UP
))
855 status
= phba
->lpfc_hba_down_link(phba
, MBX_NOWAIT
);
864 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
865 * @dev: class device that is converted into a Scsi_host.
866 * @attr: device attribute, not used.
867 * @buf: on return contains the sum of fc mapped and unmapped.
870 * Returns the ascii text number of the sum of the fc mapped and unmapped
873 * Returns: size of formatted string.
876 lpfc_num_discovered_ports_show(struct device
*dev
,
877 struct device_attribute
*attr
, char *buf
)
879 struct Scsi_Host
*shost
= class_to_shost(dev
);
880 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
882 return snprintf(buf
, PAGE_SIZE
, "%d\n",
883 vport
->fc_map_cnt
+ vport
->fc_unmap_cnt
);
887 * lpfc_issue_lip - Misnomer, name carried over from long ago
888 * @shost: Scsi_Host pointer.
891 * Bring the link down gracefully then re-init the link. The firmware will
892 * re-init the fiber channel interface as required. Does not issue a LIP.
895 * -EPERM port offline or management commands are being blocked
896 * -ENOMEM cannot allocate memory for the mailbox command
897 * -EIO error sending the mailbox command
901 lpfc_issue_lip(struct Scsi_Host
*shost
)
903 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
904 struct lpfc_hba
*phba
= vport
->phba
;
905 LPFC_MBOXQ_t
*pmboxq
;
906 int mbxstatus
= MBXERR_ERROR
;
908 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
909 (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
))
912 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
,GFP_KERNEL
);
917 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
918 pmboxq
->u
.mb
.mbxCommand
= MBX_DOWN_LINK
;
919 pmboxq
->u
.mb
.mbxOwner
= OWN_HOST
;
921 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, LPFC_MBOX_TMO
* 2);
923 if ((mbxstatus
== MBX_SUCCESS
) &&
924 (pmboxq
->u
.mb
.mbxStatus
== 0 ||
925 pmboxq
->u
.mb
.mbxStatus
== MBXERR_LINK_DOWN
)) {
926 memset((void *)pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
927 lpfc_init_link(phba
, pmboxq
, phba
->cfg_topology
,
928 phba
->cfg_link_speed
);
929 mbxstatus
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
,
931 if ((mbxstatus
== MBX_SUCCESS
) &&
932 (pmboxq
->u
.mb
.mbxStatus
== MBXERR_SEC_NO_PERMISSION
))
933 lpfc_printf_log(phba
, KERN_ERR
, LOG_MBOX
| LOG_SLI
,
934 "2859 SLI authentication is required "
935 "for INIT_LINK but has not done yet\n");
938 lpfc_set_loopback_flag(phba
);
939 if (mbxstatus
!= MBX_TIMEOUT
)
940 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
942 if (mbxstatus
== MBXERR_ERROR
)
949 lpfc_emptyq_wait(struct lpfc_hba
*phba
, struct list_head
*q
, spinlock_t
*lock
)
954 while (!list_empty(q
)) {
955 spin_unlock_irq(lock
);
957 if (cnt
++ > 250) { /* 5 secs */
958 lpfc_printf_log(phba
, KERN_WARNING
, LOG_INIT
,
960 "Outstanding IO when ",
961 "bringing Adapter offline\n");
966 spin_unlock_irq(lock
);
971 * lpfc_do_offline - Issues a mailbox command to bring the link down
972 * @phba: lpfc_hba pointer.
973 * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL.
976 * Assumes any error from lpfc_do_offline() will be negative.
977 * Can wait up to 5 seconds for the port ring buffers count
978 * to reach zero, prints a warning if it is not zero and continues.
979 * lpfc_workq_post_event() returns a non-zero return code if call fails.
982 * -EIO error posting the event
986 lpfc_do_offline(struct lpfc_hba
*phba
, uint32_t type
)
988 struct completion online_compl
;
989 struct lpfc_queue
*qp
= NULL
;
990 struct lpfc_sli_ring
*pring
;
991 struct lpfc_sli
*psli
;
996 init_completion(&online_compl
);
997 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
998 LPFC_EVT_OFFLINE_PREP
);
1002 wait_for_completion(&online_compl
);
1009 /* Wait a little for things to settle down, but not
1010 * long enough for dev loss timeout to expire.
1012 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
1013 for (i
= 0; i
< psli
->num_rings
; i
++) {
1014 pring
= &psli
->sli3_ring
[i
];
1015 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1020 list_for_each_entry(qp
, &phba
->sli4_hba
.lpfc_wq_list
, wq_list
) {
1024 if (!lpfc_emptyq_wait(phba
, &pring
->txcmplq
,
1030 init_completion(&online_compl
);
1031 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
, type
);
1035 wait_for_completion(&online_compl
);
1044 * lpfc_selective_reset - Offline then onlines the port
1045 * @phba: lpfc_hba pointer.
1048 * If the port is configured to allow a reset then the hba is brought
1049 * offline then online.
1052 * Assumes any error from lpfc_do_offline() will be negative.
1053 * Do not make this function static.
1056 * lpfc_do_offline() return code if not zero
1057 * -EIO reset not configured or error posting the event
1061 lpfc_selective_reset(struct lpfc_hba
*phba
)
1063 struct completion online_compl
;
1067 if (!phba
->cfg_enable_hba_reset
)
1070 if (!(phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)) {
1071 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1077 init_completion(&online_compl
);
1078 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1083 wait_for_completion(&online_compl
);
1092 * lpfc_issue_reset - Selectively resets an adapter
1093 * @dev: class device that is converted into a Scsi_host.
1094 * @attr: device attribute, not used.
1095 * @buf: containing the string "selective".
1096 * @count: unused variable.
1099 * If the buf contains the string "selective" then lpfc_selective_reset()
1100 * is called to perform the reset.
1103 * Assumes any error from lpfc_selective_reset() will be negative.
1104 * If lpfc_selective_reset() returns zero then the length of the buffer
1105 * is returned which indicates success
1108 * -EINVAL if the buffer does not contain the string "selective"
1109 * length of buf if lpfc-selective_reset() if the call succeeds
1110 * return value of lpfc_selective_reset() if the call fails
1113 lpfc_issue_reset(struct device
*dev
, struct device_attribute
*attr
,
1114 const char *buf
, size_t count
)
1116 struct Scsi_Host
*shost
= class_to_shost(dev
);
1117 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1118 struct lpfc_hba
*phba
= vport
->phba
;
1119 int status
= -EINVAL
;
1121 if (!phba
->cfg_enable_hba_reset
)
1124 if (strncmp(buf
, "selective", sizeof("selective") - 1) == 0)
1125 status
= phba
->lpfc_selective_reset(phba
);
1134 * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
1135 * @phba: lpfc_hba pointer.
1138 * SLI4 interface type-2 device to wait on the sliport status register for
1139 * the readyness after performing a firmware reset.
1142 * zero for success, -EPERM when port does not have privilege to perform the
1143 * reset, -EIO when port timeout from recovering from the reset.
1146 * As the caller will interpret the return code by value, be careful in making
1147 * change or addition to return codes.
1150 lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba
*phba
)
1152 struct lpfc_register portstat_reg
= {0};
1156 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1157 &portstat_reg
.word0
);
1159 /* verify if privileged for the request operation */
1160 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
) &&
1161 !bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1164 /* wait for the SLI port firmware ready after firmware reset */
1165 for (i
= 0; i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
; i
++) {
1167 lpfc_readl(phba
->sli4_hba
.u
.if_type2
.STATUSregaddr
,
1168 &portstat_reg
.word0
);
1169 if (!bf_get(lpfc_sliport_status_err
, &portstat_reg
))
1171 if (!bf_get(lpfc_sliport_status_rn
, &portstat_reg
))
1173 if (!bf_get(lpfc_sliport_status_rdy
, &portstat_reg
))
1178 if (i
< LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT
)
1185 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
1186 * @phba: lpfc_hba pointer.
1189 * Request SLI4 interface type-2 device to perform a physical register set
1196 lpfc_sli4_pdev_reg_request(struct lpfc_hba
*phba
, uint32_t opcode
)
1198 struct completion online_compl
;
1199 struct pci_dev
*pdev
= phba
->pcidev
;
1200 uint32_t before_fc_flag
;
1201 uint32_t sriov_nr_virtfn
;
1203 int status
= 0, rc
= 0;
1204 int job_posted
= 1, sriov_err
;
1206 if (!phba
->cfg_enable_hba_reset
)
1209 if ((phba
->sli_rev
< LPFC_SLI_REV4
) ||
1210 (bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
) !=
1211 LPFC_SLI_INTF_IF_TYPE_2
))
1214 /* Keep state if we need to restore back */
1215 before_fc_flag
= phba
->pport
->fc_flag
;
1216 sriov_nr_virtfn
= phba
->cfg_sriov_nr_virtfn
;
1218 /* Disable SR-IOV virtual functions if enabled */
1219 if (phba
->cfg_sriov_nr_virtfn
) {
1220 pci_disable_sriov(pdev
);
1221 phba
->cfg_sriov_nr_virtfn
= 0;
1224 if (opcode
== LPFC_FW_DUMP
)
1225 phba
->hba_flag
|= HBA_FW_DUMP_OP
;
1227 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1230 phba
->hba_flag
&= ~HBA_FW_DUMP_OP
;
1234 /* wait for the device to be quiesced before firmware reset */
1237 reg_val
= readl(phba
->sli4_hba
.conf_regs_memmap_p
+
1238 LPFC_CTL_PDEV_CTL_OFFSET
);
1240 if (opcode
== LPFC_FW_DUMP
)
1241 reg_val
|= LPFC_FW_DUMP_REQUEST
;
1242 else if (opcode
== LPFC_FW_RESET
)
1243 reg_val
|= LPFC_CTL_PDEV_CTL_FRST
;
1244 else if (opcode
== LPFC_DV_RESET
)
1245 reg_val
|= LPFC_CTL_PDEV_CTL_DRST
;
1247 writel(reg_val
, phba
->sli4_hba
.conf_regs_memmap_p
+
1248 LPFC_CTL_PDEV_CTL_OFFSET
);
1250 readl(phba
->sli4_hba
.conf_regs_memmap_p
+ LPFC_CTL_PDEV_CTL_OFFSET
);
1252 /* delay driver action following IF_TYPE_2 reset */
1253 rc
= lpfc_sli4_pdev_status_reg_wait(phba
);
1256 /* no privilege for reset */
1257 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1258 "3150 No privilege to perform the requested "
1259 "access: x%x\n", reg_val
);
1260 } else if (rc
== -EIO
) {
1261 /* reset failed, there is nothing more we can do */
1262 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1263 "3153 Fail to perform the requested "
1264 "access: x%x\n", reg_val
);
1268 /* keep the original port state */
1269 if (before_fc_flag
& FC_OFFLINE_MODE
)
1272 init_completion(&online_compl
);
1273 job_posted
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1278 wait_for_completion(&online_compl
);
1281 /* in any case, restore the virtual functions enabled as before */
1282 if (sriov_nr_virtfn
) {
1284 lpfc_sli_probe_sriov_nr_virtfn(phba
, sriov_nr_virtfn
);
1286 phba
->cfg_sriov_nr_virtfn
= sriov_nr_virtfn
;
1289 /* return proper error code */
1300 * lpfc_nport_evt_cnt_show - Return the number of nport events
1301 * @dev: class device that is converted into a Scsi_host.
1302 * @attr: device attribute, not used.
1303 * @buf: on return contains the ascii number of nport events.
1305 * Returns: size of formatted string.
1308 lpfc_nport_evt_cnt_show(struct device
*dev
, struct device_attribute
*attr
,
1311 struct Scsi_Host
*shost
= class_to_shost(dev
);
1312 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1313 struct lpfc_hba
*phba
= vport
->phba
;
1315 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->nport_event_cnt
);
1319 * lpfc_board_mode_show - Return the state of the board
1320 * @dev: class device that is converted into a Scsi_host.
1321 * @attr: device attribute, not used.
1322 * @buf: on return contains the state of the adapter.
1324 * Returns: size of formatted string.
1327 lpfc_board_mode_show(struct device
*dev
, struct device_attribute
*attr
,
1330 struct Scsi_Host
*shost
= class_to_shost(dev
);
1331 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1332 struct lpfc_hba
*phba
= vport
->phba
;
1335 if (phba
->link_state
== LPFC_HBA_ERROR
)
1337 else if (phba
->link_state
== LPFC_WARM_START
)
1338 state
= "warm start";
1339 else if (phba
->link_state
== LPFC_INIT_START
)
1344 return snprintf(buf
, PAGE_SIZE
, "%s\n", state
);
1348 * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state
1349 * @dev: class device that is converted into a Scsi_host.
1350 * @attr: device attribute, not used.
1351 * @buf: containing one of the strings "online", "offline", "warm" or "error".
1352 * @count: unused variable.
1355 * -EACCES if enable hba reset not enabled
1356 * -EINVAL if the buffer does not contain a valid string (see above)
1357 * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails
1358 * buf length greater than zero indicates success
1361 lpfc_board_mode_store(struct device
*dev
, struct device_attribute
*attr
,
1362 const char *buf
, size_t count
)
1364 struct Scsi_Host
*shost
= class_to_shost(dev
);
1365 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1366 struct lpfc_hba
*phba
= vport
->phba
;
1367 struct completion online_compl
;
1368 char *board_mode_str
= NULL
;
1372 if (!phba
->cfg_enable_hba_reset
) {
1374 goto board_mode_out
;
1377 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1378 "3050 lpfc_board_mode set to %s\n", buf
);
1380 init_completion(&online_compl
);
1382 if(strncmp(buf
, "online", sizeof("online") - 1) == 0) {
1383 rc
= lpfc_workq_post_event(phba
, &status
, &online_compl
,
1387 goto board_mode_out
;
1389 wait_for_completion(&online_compl
);
1392 } else if (strncmp(buf
, "offline", sizeof("offline") - 1) == 0)
1393 status
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
1394 else if (strncmp(buf
, "warm", sizeof("warm") - 1) == 0)
1395 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1398 status
= lpfc_do_offline(phba
, LPFC_EVT_WARM_START
);
1399 else if (strncmp(buf
, "error", sizeof("error") - 1) == 0)
1400 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1403 status
= lpfc_do_offline(phba
, LPFC_EVT_KILL
);
1404 else if (strncmp(buf
, "dump", sizeof("dump") - 1) == 0)
1405 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_DUMP
);
1406 else if (strncmp(buf
, "fw_reset", sizeof("fw_reset") - 1) == 0)
1407 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_FW_RESET
);
1408 else if (strncmp(buf
, "dv_reset", sizeof("dv_reset") - 1) == 0)
1409 status
= lpfc_sli4_pdev_reg_request(phba
, LPFC_DV_RESET
);
1417 board_mode_str
= strchr(buf
, '\n');
1419 *board_mode_str
= '\0';
1420 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1421 "3097 Failed \"%s\", status(%d), "
1423 buf
, status
, phba
->pport
->fc_flag
);
1429 * lpfc_get_hba_info - Return various bits of informaton about the adapter
1430 * @phba: pointer to the adapter structure.
1431 * @mxri: max xri count.
1432 * @axri: available xri count.
1433 * @mrpi: max rpi count.
1434 * @arpi: available rpi count.
1435 * @mvpi: max vpi count.
1436 * @avpi: available vpi count.
1439 * If an integer pointer for an count is not null then the value for the
1440 * count is returned.
1447 lpfc_get_hba_info(struct lpfc_hba
*phba
,
1448 uint32_t *mxri
, uint32_t *axri
,
1449 uint32_t *mrpi
, uint32_t *arpi
,
1450 uint32_t *mvpi
, uint32_t *avpi
)
1452 struct lpfc_mbx_read_config
*rd_config
;
1453 LPFC_MBOXQ_t
*pmboxq
;
1459 * prevent udev from issuing mailbox commands until the port is
1462 if (phba
->link_state
< LPFC_LINK_DOWN
||
1463 !phba
->mbox_mem_pool
||
1464 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
1467 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
1470 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1473 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
1475 pmb
= &pmboxq
->u
.mb
;
1476 pmb
->mbxCommand
= MBX_READ_CONFIG
;
1477 pmb
->mbxOwner
= OWN_HOST
;
1478 pmboxq
->context1
= NULL
;
1480 if (phba
->pport
->fc_flag
& FC_OFFLINE_MODE
)
1481 rc
= MBX_NOT_FINISHED
;
1483 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
1485 if (rc
!= MBX_SUCCESS
) {
1486 if (rc
!= MBX_TIMEOUT
)
1487 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1491 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1492 rd_config
= &pmboxq
->u
.mqe
.un
.rd_config
;
1494 *mrpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
);
1496 *arpi
= bf_get(lpfc_mbx_rd_conf_rpi_count
, rd_config
) -
1497 phba
->sli4_hba
.max_cfg_param
.rpi_used
;
1499 *mxri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
);
1501 *axri
= bf_get(lpfc_mbx_rd_conf_xri_count
, rd_config
) -
1502 phba
->sli4_hba
.max_cfg_param
.xri_used
;
1504 /* Account for differences with SLI-3. Get vpi count from
1505 * mailbox data and subtract one for max vpi value.
1507 max_vpi
= (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) > 0) ?
1508 (bf_get(lpfc_mbx_rd_conf_vpi_count
, rd_config
) - 1) : 0;
1513 *avpi
= max_vpi
- phba
->sli4_hba
.max_cfg_param
.vpi_used
;
1516 *mrpi
= pmb
->un
.varRdConfig
.max_rpi
;
1518 *arpi
= pmb
->un
.varRdConfig
.avail_rpi
;
1520 *mxri
= pmb
->un
.varRdConfig
.max_xri
;
1522 *axri
= pmb
->un
.varRdConfig
.avail_xri
;
1524 *mvpi
= pmb
->un
.varRdConfig
.max_vpi
;
1526 *avpi
= pmb
->un
.varRdConfig
.avail_vpi
;
1529 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
1534 * lpfc_max_rpi_show - Return maximum rpi
1535 * @dev: class device that is converted into a Scsi_host.
1536 * @attr: device attribute, not used.
1537 * @buf: on return contains the maximum rpi count in decimal or "Unknown".
1540 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1541 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1542 * to "Unknown" and the buffer length is returned, therefore the caller
1543 * must check for "Unknown" in the buffer to detect a failure.
1545 * Returns: size of formatted string.
1548 lpfc_max_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1551 struct Scsi_Host
*shost
= class_to_shost(dev
);
1552 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1553 struct lpfc_hba
*phba
= vport
->phba
;
1556 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, NULL
, NULL
, NULL
))
1557 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1558 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1562 * lpfc_used_rpi_show - Return maximum rpi minus available rpi
1563 * @dev: class device that is converted into a Scsi_host.
1564 * @attr: device attribute, not used.
1565 * @buf: containing the used rpi count in decimal or "Unknown".
1568 * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts.
1569 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1570 * to "Unknown" and the buffer length is returned, therefore the caller
1571 * must check for "Unknown" in the buffer to detect a failure.
1573 * Returns: size of formatted string.
1576 lpfc_used_rpi_show(struct device
*dev
, struct device_attribute
*attr
,
1579 struct Scsi_Host
*shost
= class_to_shost(dev
);
1580 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1581 struct lpfc_hba
*phba
= vport
->phba
;
1584 if (lpfc_get_hba_info(phba
, NULL
, NULL
, &cnt
, &acnt
, NULL
, NULL
))
1585 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1586 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1590 * lpfc_max_xri_show - Return maximum xri
1591 * @dev: class device that is converted into a Scsi_host.
1592 * @attr: device attribute, not used.
1593 * @buf: on return contains the maximum xri count in decimal or "Unknown".
1596 * Calls lpfc_get_hba_info() asking for just the mrpi count.
1597 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1598 * to "Unknown" and the buffer length is returned, therefore the caller
1599 * must check for "Unknown" in the buffer to detect a failure.
1601 * Returns: size of formatted string.
1604 lpfc_max_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1607 struct Scsi_Host
*shost
= class_to_shost(dev
);
1608 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1609 struct lpfc_hba
*phba
= vport
->phba
;
1612 if (lpfc_get_hba_info(phba
, &cnt
, NULL
, NULL
, NULL
, NULL
, NULL
))
1613 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1614 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1618 * lpfc_used_xri_show - Return maximum xpi minus the available xpi
1619 * @dev: class device that is converted into a Scsi_host.
1620 * @attr: device attribute, not used.
1621 * @buf: on return contains the used xri count in decimal or "Unknown".
1624 * Calls lpfc_get_hba_info() asking for just the mxri and axri counts.
1625 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1626 * to "Unknown" and the buffer length is returned, therefore the caller
1627 * must check for "Unknown" in the buffer to detect a failure.
1629 * Returns: size of formatted string.
1632 lpfc_used_xri_show(struct device
*dev
, struct device_attribute
*attr
,
1635 struct Scsi_Host
*shost
= class_to_shost(dev
);
1636 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1637 struct lpfc_hba
*phba
= vport
->phba
;
1640 if (lpfc_get_hba_info(phba
, &cnt
, &acnt
, NULL
, NULL
, NULL
, NULL
))
1641 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1642 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1646 * lpfc_max_vpi_show - Return maximum vpi
1647 * @dev: class device that is converted into a Scsi_host.
1648 * @attr: device attribute, not used.
1649 * @buf: on return contains the maximum vpi count in decimal or "Unknown".
1652 * Calls lpfc_get_hba_info() asking for just the mvpi count.
1653 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1654 * to "Unknown" and the buffer length is returned, therefore the caller
1655 * must check for "Unknown" in the buffer to detect a failure.
1657 * Returns: size of formatted string.
1660 lpfc_max_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1663 struct Scsi_Host
*shost
= class_to_shost(dev
);
1664 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1665 struct lpfc_hba
*phba
= vport
->phba
;
1668 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, NULL
))
1669 return snprintf(buf
, PAGE_SIZE
, "%d\n", cnt
);
1670 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1674 * lpfc_used_vpi_show - Return maximum vpi minus the available vpi
1675 * @dev: class device that is converted into a Scsi_host.
1676 * @attr: device attribute, not used.
1677 * @buf: on return contains the used vpi count in decimal or "Unknown".
1680 * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts.
1681 * If lpfc_get_hba_info() returns zero (failure) the buffer text is set
1682 * to "Unknown" and the buffer length is returned, therefore the caller
1683 * must check for "Unknown" in the buffer to detect a failure.
1685 * Returns: size of formatted string.
1688 lpfc_used_vpi_show(struct device
*dev
, struct device_attribute
*attr
,
1691 struct Scsi_Host
*shost
= class_to_shost(dev
);
1692 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1693 struct lpfc_hba
*phba
= vport
->phba
;
1696 if (lpfc_get_hba_info(phba
, NULL
, NULL
, NULL
, NULL
, &cnt
, &acnt
))
1697 return snprintf(buf
, PAGE_SIZE
, "%d\n", (cnt
- acnt
));
1698 return snprintf(buf
, PAGE_SIZE
, "Unknown\n");
1702 * lpfc_npiv_info_show - Return text about NPIV support for the adapter
1703 * @dev: class device that is converted into a Scsi_host.
1704 * @attr: device attribute, not used.
1705 * @buf: text that must be interpreted to determine if npiv is supported.
1708 * Buffer will contain text indicating npiv is not suppoerted on the port,
1709 * the port is an NPIV physical port, or it is an npiv virtual port with
1710 * the id of the vport.
1712 * Returns: size of formatted string.
1715 lpfc_npiv_info_show(struct device
*dev
, struct device_attribute
*attr
,
1718 struct Scsi_Host
*shost
= class_to_shost(dev
);
1719 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1720 struct lpfc_hba
*phba
= vport
->phba
;
1722 if (!(phba
->max_vpi
))
1723 return snprintf(buf
, PAGE_SIZE
, "NPIV Not Supported\n");
1724 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1725 return snprintf(buf
, PAGE_SIZE
, "NPIV Physical\n");
1726 return snprintf(buf
, PAGE_SIZE
, "NPIV Virtual (VPI %d)\n", vport
->vpi
);
1730 * lpfc_poll_show - Return text about poll support for the adapter
1731 * @dev: class device that is converted into a Scsi_host.
1732 * @attr: device attribute, not used.
1733 * @buf: on return contains the cfg_poll in hex.
1736 * cfg_poll should be a lpfc_polling_flags type.
1738 * Returns: size of formatted string.
1741 lpfc_poll_show(struct device
*dev
, struct device_attribute
*attr
,
1744 struct Scsi_Host
*shost
= class_to_shost(dev
);
1745 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1746 struct lpfc_hba
*phba
= vport
->phba
;
1748 return snprintf(buf
, PAGE_SIZE
, "%#x\n", phba
->cfg_poll
);
1752 * lpfc_poll_store - Set the value of cfg_poll for the adapter
1753 * @dev: class device that is converted into a Scsi_host.
1754 * @attr: device attribute, not used.
1755 * @buf: one or more lpfc_polling_flags values.
1759 * buf contents converted to integer and checked for a valid value.
1762 * -EINVAL if the buffer connot be converted or is out of range
1763 * length of the buf on success
1766 lpfc_poll_store(struct device
*dev
, struct device_attribute
*attr
,
1767 const char *buf
, size_t count
)
1769 struct Scsi_Host
*shost
= class_to_shost(dev
);
1770 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1771 struct lpfc_hba
*phba
= vport
->phba
;
1776 if (!isdigit(buf
[0]))
1779 if (sscanf(buf
, "%i", &val
) != 1)
1782 if ((val
& 0x3) != val
)
1785 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1788 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
1789 "3051 lpfc_poll changed from %d to %d\n",
1790 phba
->cfg_poll
, val
);
1792 spin_lock_irq(&phba
->hbalock
);
1794 old_val
= phba
->cfg_poll
;
1796 if (val
& ENABLE_FCP_RING_POLLING
) {
1797 if ((val
& DISABLE_FCP_RING_INT
) &&
1798 !(old_val
& DISABLE_FCP_RING_INT
)) {
1799 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1800 spin_unlock_irq(&phba
->hbalock
);
1803 creg_val
&= ~(HC_R0INT_ENA
<< LPFC_FCP_RING
);
1804 writel(creg_val
, phba
->HCregaddr
);
1805 readl(phba
->HCregaddr
); /* flush */
1807 lpfc_poll_start_timer(phba
);
1809 } else if (val
!= 0x0) {
1810 spin_unlock_irq(&phba
->hbalock
);
1814 if (!(val
& DISABLE_FCP_RING_INT
) &&
1815 (old_val
& DISABLE_FCP_RING_INT
))
1817 spin_unlock_irq(&phba
->hbalock
);
1818 del_timer(&phba
->fcp_poll_timer
);
1819 spin_lock_irq(&phba
->hbalock
);
1820 if (lpfc_readl(phba
->HCregaddr
, &creg_val
)) {
1821 spin_unlock_irq(&phba
->hbalock
);
1824 creg_val
|= (HC_R0INT_ENA
<< LPFC_FCP_RING
);
1825 writel(creg_val
, phba
->HCregaddr
);
1826 readl(phba
->HCregaddr
); /* flush */
1829 phba
->cfg_poll
= val
;
1831 spin_unlock_irq(&phba
->hbalock
);
1837 * lpfc_fips_level_show - Return the current FIPS level for the HBA
1838 * @dev: class unused variable.
1839 * @attr: device attribute, not used.
1840 * @buf: on return contains the module description text.
1842 * Returns: size of formatted string.
1845 lpfc_fips_level_show(struct device
*dev
, struct device_attribute
*attr
,
1848 struct Scsi_Host
*shost
= class_to_shost(dev
);
1849 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1850 struct lpfc_hba
*phba
= vport
->phba
;
1852 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_level
);
1856 * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
1857 * @dev: class unused variable.
1858 * @attr: device attribute, not used.
1859 * @buf: on return contains the module description text.
1861 * Returns: size of formatted string.
1864 lpfc_fips_rev_show(struct device
*dev
, struct device_attribute
*attr
,
1867 struct Scsi_Host
*shost
= class_to_shost(dev
);
1868 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1869 struct lpfc_hba
*phba
= vport
->phba
;
1871 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->fips_spec_rev
);
1875 * lpfc_dss_show - Return the current state of dss and the configured state
1876 * @dev: class converted to a Scsi_host structure.
1877 * @attr: device attribute, not used.
1878 * @buf: on return contains the formatted text.
1880 * Returns: size of formatted string.
1883 lpfc_dss_show(struct device
*dev
, struct device_attribute
*attr
,
1886 struct Scsi_Host
*shost
= class_to_shost(dev
);
1887 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1888 struct lpfc_hba
*phba
= vport
->phba
;
1890 return snprintf(buf
, PAGE_SIZE
, "%s - %sOperational\n",
1891 (phba
->cfg_enable_dss
) ? "Enabled" : "Disabled",
1892 (phba
->sli3_options
& LPFC_SLI3_DSS_ENABLED
) ?
1897 * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions
1898 * @dev: class converted to a Scsi_host structure.
1899 * @attr: device attribute, not used.
1900 * @buf: on return contains the formatted support level.
1903 * Returns the maximum number of virtual functions a physical function can
1904 * support, 0 will be returned if called on virtual function.
1906 * Returns: size of formatted string.
1909 lpfc_sriov_hw_max_virtfn_show(struct device
*dev
,
1910 struct device_attribute
*attr
,
1913 struct Scsi_Host
*shost
= class_to_shost(dev
);
1914 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
1915 struct lpfc_hba
*phba
= vport
->phba
;
1916 uint16_t max_nr_virtfn
;
1918 max_nr_virtfn
= lpfc_sli_sriov_nr_virtfn_get(phba
);
1919 return snprintf(buf
, PAGE_SIZE
, "%d\n", max_nr_virtfn
);
1922 static inline bool lpfc_rangecheck(uint val
, uint min
, uint max
)
1924 return val
>= min
&& val
<= max
;
1928 * lpfc_enable_bbcr_set: Sets an attribute value.
1929 * @phba: pointer the the adapter structure.
1930 * @val: integer attribute value.
1933 * Validates the min and max values then sets the
1934 * adapter config field if in the valid range. prints error message
1935 * and does not set the parameter if invalid.
1939 * -EINVAL if val is invalid
1942 lpfc_enable_bbcr_set(struct lpfc_hba
*phba
, uint val
)
1944 if (lpfc_rangecheck(val
, 0, 1) && phba
->sli_rev
== LPFC_SLI_REV4
) {
1945 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1946 "3068 %s_enable_bbcr changed from %d to %d\n",
1947 LPFC_DRIVER_NAME
, phba
->cfg_enable_bbcr
, val
);
1948 phba
->cfg_enable_bbcr
= val
;
1951 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1952 "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n",
1953 LPFC_DRIVER_NAME
, val
);
1958 * lpfc_param_show - Return a cfg attribute value in decimal
1961 * Macro that given an attr e.g. hba_queue_depth expands
1962 * into a function with the name lpfc_hba_queue_depth_show.
1964 * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field.
1965 * @dev: class device that is converted into a Scsi_host.
1966 * @attr: device attribute, not used.
1967 * @buf: on return contains the attribute value in decimal.
1969 * Returns: size of formatted string.
1971 #define lpfc_param_show(attr) \
1973 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1976 struct Scsi_Host *shost = class_to_shost(dev);\
1977 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1978 struct lpfc_hba *phba = vport->phba;\
1979 return snprintf(buf, PAGE_SIZE, "%d\n",\
1984 * lpfc_param_hex_show - Return a cfg attribute value in hex
1987 * Macro that given an attr e.g. hba_queue_depth expands
1988 * into a function with the name lpfc_hba_queue_depth_show
1990 * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field.
1991 * @dev: class device that is converted into a Scsi_host.
1992 * @attr: device attribute, not used.
1993 * @buf: on return contains the attribute value in hexadecimal.
1995 * Returns: size of formatted string.
1997 #define lpfc_param_hex_show(attr) \
1999 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2002 struct Scsi_Host *shost = class_to_shost(dev);\
2003 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2004 struct lpfc_hba *phba = vport->phba;\
2006 val = phba->cfg_##attr;\
2007 return snprintf(buf, PAGE_SIZE, "%#x\n",\
2012 * lpfc_param_init - Initializes a cfg attribute
2015 * Macro that given an attr e.g. hba_queue_depth expands
2016 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2017 * takes a default argument, a minimum and maximum argument.
2019 * lpfc_##attr##_init: Initializes an attribute.
2020 * @phba: pointer the the adapter structure.
2021 * @val: integer attribute value.
2023 * Validates the min and max values then sets the adapter config field
2024 * accordingly, or uses the default if out of range and prints an error message.
2028 * -EINVAL if default used
2030 #define lpfc_param_init(attr, default, minval, maxval) \
2032 lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
2034 if (lpfc_rangecheck(val, minval, maxval)) {\
2035 phba->cfg_##attr = val;\
2038 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2039 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
2040 "allowed range is ["#minval", "#maxval"]\n", val); \
2041 phba->cfg_##attr = default;\
2046 * lpfc_param_set - Set a cfg attribute value
2049 * Macro that given an attr e.g. hba_queue_depth expands
2050 * into a function with the name lpfc_hba_queue_depth_set
2052 * lpfc_##attr##_set: Sets an attribute value.
2053 * @phba: pointer the the adapter structure.
2054 * @val: integer attribute value.
2057 * Validates the min and max values then sets the
2058 * adapter config field if in the valid range. prints error message
2059 * and does not set the parameter if invalid.
2063 * -EINVAL if val is invalid
2065 #define lpfc_param_set(attr, default, minval, maxval) \
2067 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
2069 if (lpfc_rangecheck(val, minval, maxval)) {\
2070 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2071 "3052 lpfc_" #attr " changed from %d to %d\n", \
2072 phba->cfg_##attr, val); \
2073 phba->cfg_##attr = val;\
2076 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
2077 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
2078 "allowed range is ["#minval", "#maxval"]\n", val); \
2083 * lpfc_param_store - Set a vport attribute value
2086 * Macro that given an attr e.g. hba_queue_depth expands
2087 * into a function with the name lpfc_hba_queue_depth_store.
2089 * lpfc_##attr##_store: Set an sttribute value.
2090 * @dev: class device that is converted into a Scsi_host.
2091 * @attr: device attribute, not used.
2092 * @buf: contains the attribute value in ascii.
2096 * Convert the ascii text number to an integer, then
2097 * use the lpfc_##attr##_set function to set the value.
2100 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2101 * length of buffer upon success.
2103 #define lpfc_param_store(attr) \
2105 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2106 const char *buf, size_t count) \
2108 struct Scsi_Host *shost = class_to_shost(dev);\
2109 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2110 struct lpfc_hba *phba = vport->phba;\
2112 if (!isdigit(buf[0]))\
2114 if (sscanf(buf, "%i", &val) != 1)\
2116 if (lpfc_##attr##_set(phba, val) == 0) \
2117 return strlen(buf);\
2123 * lpfc_vport_param_show - Return decimal formatted cfg attribute value
2126 * Macro that given an attr e.g. hba_queue_depth expands
2127 * into a function with the name lpfc_hba_queue_depth_show
2129 * lpfc_##attr##_show: prints the attribute value in decimal.
2130 * @dev: class device that is converted into a Scsi_host.
2131 * @attr: device attribute, not used.
2132 * @buf: on return contains the attribute value in decimal.
2134 * Returns: length of formatted string.
2136 #define lpfc_vport_param_show(attr) \
2138 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2141 struct Scsi_Host *shost = class_to_shost(dev);\
2142 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2143 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
2147 * lpfc_vport_param_hex_show - Return hex formatted attribute value
2150 * Macro that given an attr e.g.
2151 * hba_queue_depth expands into a function with the name
2152 * lpfc_hba_queue_depth_show
2154 * lpfc_##attr##_show: prints the attribute value in hexadecimal.
2155 * @dev: class device that is converted into a Scsi_host.
2156 * @attr: device attribute, not used.
2157 * @buf: on return contains the attribute value in hexadecimal.
2159 * Returns: length of formatted string.
2161 #define lpfc_vport_param_hex_show(attr) \
2163 lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2166 struct Scsi_Host *shost = class_to_shost(dev);\
2167 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2168 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
2172 * lpfc_vport_param_init - Initialize a vport cfg attribute
2175 * Macro that given an attr e.g. hba_queue_depth expands
2176 * into a function with the name lpfc_hba_queue_depth_init. The macro also
2177 * takes a default argument, a minimum and maximum argument.
2179 * lpfc_##attr##_init: validates the min and max values then sets the
2180 * adapter config field accordingly, or uses the default if out of range
2181 * and prints an error message.
2182 * @phba: pointer the the adapter structure.
2183 * @val: integer attribute value.
2187 * -EINVAL if default used
2189 #define lpfc_vport_param_init(attr, default, minval, maxval) \
2191 lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
2193 if (lpfc_rangecheck(val, minval, maxval)) {\
2194 vport->cfg_##attr = val;\
2197 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2198 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
2199 "allowed range is ["#minval", "#maxval"]\n", val); \
2200 vport->cfg_##attr = default;\
2205 * lpfc_vport_param_set - Set a vport cfg attribute
2208 * Macro that given an attr e.g. hba_queue_depth expands
2209 * into a function with the name lpfc_hba_queue_depth_set
2211 * lpfc_##attr##_set: validates the min and max values then sets the
2212 * adapter config field if in the valid range. prints error message
2213 * and does not set the parameter if invalid.
2214 * @phba: pointer the the adapter structure.
2215 * @val: integer attribute value.
2219 * -EINVAL if val is invalid
2221 #define lpfc_vport_param_set(attr, default, minval, maxval) \
2223 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
2225 if (lpfc_rangecheck(val, minval, maxval)) {\
2226 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2227 "3053 lpfc_" #attr \
2228 " changed from %d (x%x) to %d (x%x)\n", \
2229 vport->cfg_##attr, vport->cfg_##attr, \
2231 vport->cfg_##attr = val;\
2234 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2235 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
2236 "allowed range is ["#minval", "#maxval"]\n", val); \
2241 * lpfc_vport_param_store - Set a vport attribute
2244 * Macro that given an attr e.g. hba_queue_depth
2245 * expands into a function with the name lpfc_hba_queue_depth_store
2247 * lpfc_##attr##_store: convert the ascii text number to an integer, then
2248 * use the lpfc_##attr##_set function to set the value.
2249 * @cdev: class device that is converted into a Scsi_host.
2250 * @buf: contains the attribute value in decimal.
2254 * -EINVAL if val is invalid or lpfc_##attr##_set() fails
2255 * length of buffer upon success.
2257 #define lpfc_vport_param_store(attr) \
2259 lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2260 const char *buf, size_t count) \
2262 struct Scsi_Host *shost = class_to_shost(dev);\
2263 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2265 if (!isdigit(buf[0]))\
2267 if (sscanf(buf, "%i", &val) != 1)\
2269 if (lpfc_##attr##_set(vport, val) == 0) \
2270 return strlen(buf);\
2276 static DEVICE_ATTR(nvme_info
, 0444, lpfc_nvme_info_show
, NULL
);
2277 static DEVICE_ATTR(bg_info
, S_IRUGO
, lpfc_bg_info_show
, NULL
);
2278 static DEVICE_ATTR(bg_guard_err
, S_IRUGO
, lpfc_bg_guard_err_show
, NULL
);
2279 static DEVICE_ATTR(bg_apptag_err
, S_IRUGO
, lpfc_bg_apptag_err_show
, NULL
);
2280 static DEVICE_ATTR(bg_reftag_err
, S_IRUGO
, lpfc_bg_reftag_err_show
, NULL
);
2281 static DEVICE_ATTR(info
, S_IRUGO
, lpfc_info_show
, NULL
);
2282 static DEVICE_ATTR(serialnum
, S_IRUGO
, lpfc_serialnum_show
, NULL
);
2283 static DEVICE_ATTR(modeldesc
, S_IRUGO
, lpfc_modeldesc_show
, NULL
);
2284 static DEVICE_ATTR(modelname
, S_IRUGO
, lpfc_modelname_show
, NULL
);
2285 static DEVICE_ATTR(programtype
, S_IRUGO
, lpfc_programtype_show
, NULL
);
2286 static DEVICE_ATTR(portnum
, S_IRUGO
, lpfc_vportnum_show
, NULL
);
2287 static DEVICE_ATTR(fwrev
, S_IRUGO
, lpfc_fwrev_show
, NULL
);
2288 static DEVICE_ATTR(hdw
, S_IRUGO
, lpfc_hdw_show
, NULL
);
2289 static DEVICE_ATTR(link_state
, S_IRUGO
| S_IWUSR
, lpfc_link_state_show
,
2290 lpfc_link_state_store
);
2291 static DEVICE_ATTR(option_rom_version
, S_IRUGO
,
2292 lpfc_option_rom_version_show
, NULL
);
2293 static DEVICE_ATTR(num_discovered_ports
, S_IRUGO
,
2294 lpfc_num_discovered_ports_show
, NULL
);
2295 static DEVICE_ATTR(menlo_mgmt_mode
, S_IRUGO
, lpfc_mlomgmt_show
, NULL
);
2296 static DEVICE_ATTR(nport_evt_cnt
, S_IRUGO
, lpfc_nport_evt_cnt_show
, NULL
);
2297 static DEVICE_ATTR_RO(lpfc_drvr_version
);
2298 static DEVICE_ATTR_RO(lpfc_enable_fip
);
2299 static DEVICE_ATTR(board_mode
, S_IRUGO
| S_IWUSR
,
2300 lpfc_board_mode_show
, lpfc_board_mode_store
);
2301 static DEVICE_ATTR(issue_reset
, S_IWUSR
, NULL
, lpfc_issue_reset
);
2302 static DEVICE_ATTR(max_vpi
, S_IRUGO
, lpfc_max_vpi_show
, NULL
);
2303 static DEVICE_ATTR(used_vpi
, S_IRUGO
, lpfc_used_vpi_show
, NULL
);
2304 static DEVICE_ATTR(max_rpi
, S_IRUGO
, lpfc_max_rpi_show
, NULL
);
2305 static DEVICE_ATTR(used_rpi
, S_IRUGO
, lpfc_used_rpi_show
, NULL
);
2306 static DEVICE_ATTR(max_xri
, S_IRUGO
, lpfc_max_xri_show
, NULL
);
2307 static DEVICE_ATTR(used_xri
, S_IRUGO
, lpfc_used_xri_show
, NULL
);
2308 static DEVICE_ATTR(npiv_info
, S_IRUGO
, lpfc_npiv_info_show
, NULL
);
2309 static DEVICE_ATTR_RO(lpfc_temp_sensor
);
2310 static DEVICE_ATTR_RO(lpfc_fips_level
);
2311 static DEVICE_ATTR_RO(lpfc_fips_rev
);
2312 static DEVICE_ATTR_RO(lpfc_dss
);
2313 static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn
);
2314 static DEVICE_ATTR(protocol
, S_IRUGO
, lpfc_sli4_protocol_show
, NULL
);
2315 static DEVICE_ATTR(lpfc_xlane_supported
, S_IRUGO
, lpfc_oas_supported_show
,
2318 static char *lpfc_soft_wwn_key
= "C99G71SL8032A";
2321 * lpfc_wwn_set - Convert string to the 8 byte WWN value.
2323 * @cnt: Length of string.
2324 * @wwn: Array to receive converted wwn value.
2327 * -EINVAL if the buffer does not contain a valid wwn
2331 lpfc_wwn_set(const char *buf
, size_t cnt
, char wwn
[])
2335 /* Count may include a LF at end of string */
2336 if (buf
[cnt
-1] == '\n')
2339 if ((cnt
< 16) || (cnt
> 18) || ((cnt
== 17) && (*buf
++ != 'x')) ||
2340 ((cnt
== 18) && ((*buf
++ != '0') || (*buf
++ != 'x'))))
2343 memset(wwn
, 0, WWN_SZ
);
2345 /* Validate and store the new name */
2346 for (i
= 0, j
= 0; i
< 16; i
++) {
2347 if ((*buf
>= 'a') && (*buf
<= 'f'))
2348 j
= ((j
<< 4) | ((*buf
++ - 'a') + 10));
2349 else if ((*buf
>= 'A') && (*buf
<= 'F'))
2350 j
= ((j
<< 4) | ((*buf
++ - 'A') + 10));
2351 else if ((*buf
>= '0') && (*buf
<= '9'))
2352 j
= ((j
<< 4) | (*buf
++ - '0'));
2356 wwn
[i
/2] = j
& 0xff;
2363 * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid
2364 * @dev: class device that is converted into a Scsi_host.
2365 * @attr: device attribute, not used.
2366 * @buf: containing the string lpfc_soft_wwn_key.
2367 * @count: must be size of lpfc_soft_wwn_key.
2370 * -EINVAL if the buffer does not contain lpfc_soft_wwn_key
2371 * length of buf indicates success
2374 lpfc_soft_wwn_enable_store(struct device
*dev
, struct device_attribute
*attr
,
2375 const char *buf
, size_t count
)
2377 struct Scsi_Host
*shost
= class_to_shost(dev
);
2378 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2379 struct lpfc_hba
*phba
= vport
->phba
;
2380 unsigned int cnt
= count
;
2381 uint8_t vvvl
= vport
->fc_sparam
.cmn
.valid_vendor_ver_level
;
2382 u32
*fawwpn_key
= (uint32_t *)&vport
->fc_sparam
.un
.vendorVersion
[0];
2385 * We're doing a simple sanity check for soft_wwpn setting.
2386 * We require that the user write a specific key to enable
2387 * the soft_wwpn attribute to be settable. Once the attribute
2388 * is written, the enable key resets. If further updates are
2389 * desired, the key must be written again to re-enable the
2392 * The "key" is not secret - it is a hardcoded string shown
2393 * here. The intent is to protect against the random user or
2394 * application that is just writing attributes.
2396 if (vvvl
== 1 && cpu_to_be32(*fawwpn_key
) == FAPWWN_KEY_VENDOR
) {
2397 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2398 "0051 "LPFC_DRIVER_NAME
" soft wwpn can not"
2399 " be enabled: fawwpn is enabled\n");
2403 /* count may include a LF at end of string */
2404 if (buf
[cnt
-1] == '\n')
2407 if ((cnt
!= strlen(lpfc_soft_wwn_key
)) ||
2408 (strncmp(buf
, lpfc_soft_wwn_key
, strlen(lpfc_soft_wwn_key
)) != 0))
2411 phba
->soft_wwn_enable
= 1;
2413 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2414 "lpfc%d: soft_wwpn assignment has been enabled.\n",
2416 dev_printk(KERN_WARNING
, &phba
->pcidev
->dev
,
2417 " The soft_wwpn feature is not supported by Broadcom.");
2421 static DEVICE_ATTR(lpfc_soft_wwn_enable
, S_IWUSR
, NULL
,
2422 lpfc_soft_wwn_enable_store
);
2425 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
2426 * @dev: class device that is converted into a Scsi_host.
2427 * @attr: device attribute, not used.
2428 * @buf: on return contains the wwpn in hexadecimal.
2430 * Returns: size of formatted string.
2433 lpfc_soft_wwpn_show(struct device
*dev
, struct device_attribute
*attr
,
2436 struct Scsi_Host
*shost
= class_to_shost(dev
);
2437 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2438 struct lpfc_hba
*phba
= vport
->phba
;
2440 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2441 (unsigned long long)phba
->cfg_soft_wwpn
);
2445 * lpfc_soft_wwpn_store - Set the ww port name of the adapter
2446 * @dev class device that is converted into a Scsi_host.
2447 * @attr: device attribute, not used.
2448 * @buf: contains the wwpn in hexadecimal.
2449 * @count: number of wwpn bytes in buf
2452 * -EACCES hba reset not enabled, adapter over temp
2453 * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid
2454 * -EIO error taking adapter offline or online
2455 * value of count on success
2458 lpfc_soft_wwpn_store(struct device
*dev
, struct device_attribute
*attr
,
2459 const char *buf
, size_t count
)
2461 struct Scsi_Host
*shost
= class_to_shost(dev
);
2462 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
2463 struct lpfc_hba
*phba
= vport
->phba
;
2464 struct completion online_compl
;
2465 int stat1
= 0, stat2
= 0;
2466 unsigned int cnt
= count
;
2470 if (!phba
->cfg_enable_hba_reset
)
2472 spin_lock_irq(&phba
->hbalock
);
2473 if (phba
->over_temp_state
== HBA_OVER_TEMP
) {
2474 spin_unlock_irq(&phba
->hbalock
);
2477 spin_unlock_irq(&phba
->hbalock
);
2478 /* count may include a LF at end of string */
2479 if (buf
[cnt
-1] == '\n')
2482 if (!phba
->soft_wwn_enable
)
2485 /* lock setting wwpn, wwnn down */
2486 phba
->soft_wwn_enable
= 0;
2488 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2490 /* not able to set wwpn, unlock it */
2491 phba
->soft_wwn_enable
= 1;
2495 phba
->cfg_soft_wwpn
= wwn_to_u64(wwpn
);
2496 fc_host_port_name(shost
) = phba
->cfg_soft_wwpn
;
2497 if (phba
->cfg_soft_wwnn
)
2498 fc_host_node_name(shost
) = phba
->cfg_soft_wwnn
;
2500 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2501 "lpfc%d: Reinitializing to use soft_wwpn\n", phba
->brd_no
);
2503 stat1
= lpfc_do_offline(phba
, LPFC_EVT_OFFLINE
);
2505 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2506 "0463 lpfc_soft_wwpn attribute set failed to "
2507 "reinit adapter - %d\n", stat1
);
2508 init_completion(&online_compl
);
2509 rc
= lpfc_workq_post_event(phba
, &stat2
, &online_compl
,
2514 wait_for_completion(&online_compl
);
2516 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2517 "0464 lpfc_soft_wwpn attribute set failed to "
2518 "reinit adapter - %d\n", stat2
);
2519 return (stat1
|| stat2
) ? -EIO
: count
;
2521 static DEVICE_ATTR_RW(lpfc_soft_wwpn
);
2524 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
2525 * @dev: class device that is converted into a Scsi_host.
2526 * @attr: device attribute, not used.
2527 * @buf: on return contains the wwnn in hexadecimal.
2529 * Returns: size of formatted string.
2532 lpfc_soft_wwnn_show(struct device
*dev
, struct device_attribute
*attr
,
2535 struct Scsi_Host
*shost
= class_to_shost(dev
);
2536 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2537 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2538 (unsigned long long)phba
->cfg_soft_wwnn
);
2542 * lpfc_soft_wwnn_store - sets the ww node name of the adapter
2543 * @cdev: class device that is converted into a Scsi_host.
2544 * @buf: contains the ww node name in hexadecimal.
2545 * @count: number of wwnn bytes in buf.
2548 * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid
2549 * value of count on success
2552 lpfc_soft_wwnn_store(struct device
*dev
, struct device_attribute
*attr
,
2553 const char *buf
, size_t count
)
2555 struct Scsi_Host
*shost
= class_to_shost(dev
);
2556 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2557 unsigned int cnt
= count
;
2561 /* count may include a LF at end of string */
2562 if (buf
[cnt
-1] == '\n')
2565 if (!phba
->soft_wwn_enable
)
2568 rc
= lpfc_wwn_set(buf
, cnt
, wwnn
);
2570 /* Allow wwnn to be set many times, as long as the enable
2571 * is set. However, once the wwpn is set, everything locks.
2576 phba
->cfg_soft_wwnn
= wwn_to_u64(wwnn
);
2578 dev_printk(KERN_NOTICE
, &phba
->pcidev
->dev
,
2579 "lpfc%d: soft_wwnn set. Value will take effect upon "
2580 "setting of the soft_wwpn\n", phba
->brd_no
);
2584 static DEVICE_ATTR_RW(lpfc_soft_wwnn
);
2587 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for
2588 * Optimized Access Storage (OAS) operations.
2589 * @dev: class device that is converted into a Scsi_host.
2590 * @attr: device attribute, not used.
2591 * @buf: buffer for passing information.
2597 lpfc_oas_tgt_show(struct device
*dev
, struct device_attribute
*attr
,
2600 struct Scsi_Host
*shost
= class_to_shost(dev
);
2601 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2603 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2604 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
));
2608 * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for
2609 * Optimized Access Storage (OAS) operations.
2610 * @dev: class device that is converted into a Scsi_host.
2611 * @attr: device attribute, not used.
2612 * @buf: buffer for passing information.
2613 * @count: Size of the data buffer.
2616 * -EINVAL count is invalid, invalid wwpn byte invalid
2617 * -EPERM oas is not supported by hba
2618 * value of count on success
2621 lpfc_oas_tgt_store(struct device
*dev
, struct device_attribute
*attr
,
2622 const char *buf
, size_t count
)
2624 struct Scsi_Host
*shost
= class_to_shost(dev
);
2625 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2626 unsigned int cnt
= count
;
2627 uint8_t wwpn
[WWN_SZ
];
2633 /* count may include a LF at end of string */
2634 if (buf
[cnt
-1] == '\n')
2637 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2641 memcpy(phba
->cfg_oas_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2642 memcpy(phba
->sli4_hba
.oas_next_tgt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2643 if (wwn_to_u64(wwpn
) == 0)
2644 phba
->cfg_oas_flags
|= OAS_FIND_ANY_TARGET
;
2646 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_TARGET
;
2647 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2648 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2651 static DEVICE_ATTR(lpfc_xlane_tgt
, S_IRUGO
| S_IWUSR
,
2652 lpfc_oas_tgt_show
, lpfc_oas_tgt_store
);
2655 * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for
2656 * Optimized Access Storage (OAS) operations.
2657 * @dev: class device that is converted into a Scsi_host.
2658 * @attr: device attribute, not used.
2659 * @buf: buffer for passing information.
2665 lpfc_oas_priority_show(struct device
*dev
, struct device_attribute
*attr
,
2668 struct Scsi_Host
*shost
= class_to_shost(dev
);
2669 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2671 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_priority
);
2675 * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for
2676 * Optimized Access Storage (OAS) operations.
2677 * @dev: class device that is converted into a Scsi_host.
2678 * @attr: device attribute, not used.
2679 * @buf: buffer for passing information.
2680 * @count: Size of the data buffer.
2683 * -EINVAL count is invalid, invalid wwpn byte invalid
2684 * -EPERM oas is not supported by hba
2685 * value of count on success
2688 lpfc_oas_priority_store(struct device
*dev
, struct device_attribute
*attr
,
2689 const char *buf
, size_t count
)
2691 struct Scsi_Host
*shost
= class_to_shost(dev
);
2692 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2693 unsigned int cnt
= count
;
2700 /* count may include a LF at end of string */
2701 if (buf
[cnt
-1] == '\n')
2704 ret
= kstrtoul(buf
, 0, &val
);
2705 if (ret
|| (val
> 0x7f))
2709 phba
->cfg_oas_priority
= (uint8_t)val
;
2711 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
2714 static DEVICE_ATTR(lpfc_xlane_priority
, S_IRUGO
| S_IWUSR
,
2715 lpfc_oas_priority_show
, lpfc_oas_priority_store
);
2718 * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled
2719 * for Optimized Access Storage (OAS) operations.
2720 * @dev: class device that is converted into a Scsi_host.
2721 * @attr: device attribute, not used.
2722 * @buf: buffer for passing information.
2725 * value of count on success
2728 lpfc_oas_vpt_show(struct device
*dev
, struct device_attribute
*attr
,
2731 struct Scsi_Host
*shost
= class_to_shost(dev
);
2732 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2734 return snprintf(buf
, PAGE_SIZE
, "0x%llx\n",
2735 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
));
2739 * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled
2740 * for Optimized Access Storage (OAS) operations.
2741 * @dev: class device that is converted into a Scsi_host.
2742 * @attr: device attribute, not used.
2743 * @buf: buffer for passing information.
2744 * @count: Size of the data buffer.
2747 * -EINVAL count is invalid, invalid wwpn byte invalid
2748 * -EPERM oas is not supported by hba
2749 * value of count on success
2752 lpfc_oas_vpt_store(struct device
*dev
, struct device_attribute
*attr
,
2753 const char *buf
, size_t count
)
2755 struct Scsi_Host
*shost
= class_to_shost(dev
);
2756 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2757 unsigned int cnt
= count
;
2758 uint8_t wwpn
[WWN_SZ
];
2764 /* count may include a LF at end of string */
2765 if (buf
[cnt
-1] == '\n')
2768 rc
= lpfc_wwn_set(buf
, cnt
, wwpn
);
2772 memcpy(phba
->cfg_oas_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2773 memcpy(phba
->sli4_hba
.oas_next_vpt_wwpn
, wwpn
, (8 * sizeof(uint8_t)));
2774 if (wwn_to_u64(wwpn
) == 0)
2775 phba
->cfg_oas_flags
|= OAS_FIND_ANY_VPORT
;
2777 phba
->cfg_oas_flags
&= ~OAS_FIND_ANY_VPORT
;
2778 phba
->cfg_oas_flags
&= ~OAS_LUN_VALID
;
2779 if (phba
->cfg_oas_priority
== 0)
2780 phba
->cfg_oas_priority
= phba
->cfg_XLanePriority
;
2781 phba
->sli4_hba
.oas_next_lun
= FIND_FIRST_OAS_LUN
;
2784 static DEVICE_ATTR(lpfc_xlane_vpt
, S_IRUGO
| S_IWUSR
,
2785 lpfc_oas_vpt_show
, lpfc_oas_vpt_store
);
2788 * lpfc_oas_lun_state_show - Return the current state (enabled or disabled)
2789 * of whether luns will be enabled or disabled
2790 * for Optimized Access Storage (OAS) operations.
2791 * @dev: class device that is converted into a Scsi_host.
2792 * @attr: device attribute, not used.
2793 * @buf: buffer for passing information.
2796 * size of formatted string.
2799 lpfc_oas_lun_state_show(struct device
*dev
, struct device_attribute
*attr
,
2802 struct Scsi_Host
*shost
= class_to_shost(dev
);
2803 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2805 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_state
);
2809 * lpfc_oas_lun_state_store - Store the state (enabled or disabled)
2810 * of whether luns will be enabled or disabled
2811 * for Optimized Access Storage (OAS) operations.
2812 * @dev: class device that is converted into a Scsi_host.
2813 * @attr: device attribute, not used.
2814 * @buf: buffer for passing information.
2815 * @count: Size of the data buffer.
2818 * -EINVAL count is invalid, invalid wwpn byte invalid
2819 * -EPERM oas is not supported by hba
2820 * value of count on success
2823 lpfc_oas_lun_state_store(struct device
*dev
, struct device_attribute
*attr
,
2824 const char *buf
, size_t count
)
2826 struct Scsi_Host
*shost
= class_to_shost(dev
);
2827 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2833 if (!isdigit(buf
[0]))
2836 if (sscanf(buf
, "%i", &val
) != 1)
2839 if ((val
!= 0) && (val
!= 1))
2842 phba
->cfg_oas_lun_state
= val
;
2845 static DEVICE_ATTR(lpfc_xlane_lun_state
, S_IRUGO
| S_IWUSR
,
2846 lpfc_oas_lun_state_show
, lpfc_oas_lun_state_store
);
2849 * lpfc_oas_lun_status_show - Return the status of the Optimized Access
2850 * Storage (OAS) lun returned by the
2851 * lpfc_oas_lun_show function.
2852 * @dev: class device that is converted into a Scsi_host.
2853 * @attr: device attribute, not used.
2854 * @buf: buffer for passing information.
2857 * size of formatted string.
2860 lpfc_oas_lun_status_show(struct device
*dev
, struct device_attribute
*attr
,
2863 struct Scsi_Host
*shost
= class_to_shost(dev
);
2864 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
2866 if (!(phba
->cfg_oas_flags
& OAS_LUN_VALID
))
2869 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->cfg_oas_lun_status
);
2871 static DEVICE_ATTR(lpfc_xlane_lun_status
, S_IRUGO
,
2872 lpfc_oas_lun_status_show
, NULL
);
2876 * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage
2878 * @phba: lpfc_hba pointer.
2879 * @ndlp: pointer to fcp target node.
2880 * @lun: the fc lun for setting oas state.
2881 * @oas_state: the oas state to be set to the lun.
2885 * -EPERM OAS is not enabled or not supported by this port.
2889 lpfc_oas_lun_state_set(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2890 uint8_t tgt_wwpn
[], uint64_t lun
,
2891 uint32_t oas_state
, uint8_t pri
)
2900 if (!lpfc_enable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2901 (struct lpfc_name
*)tgt_wwpn
,
2905 lpfc_disable_oas_lun(phba
, (struct lpfc_name
*)vpt_wwpn
,
2906 (struct lpfc_name
*)tgt_wwpn
, lun
, pri
);
2913 * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized
2914 * Access Storage (OAS) operations.
2915 * @phba: lpfc_hba pointer.
2916 * @vpt_wwpn: wwpn of the vport associated with the returned lun
2917 * @tgt_wwpn: wwpn of the target associated with the returned lun
2918 * @lun_status: status of the lun returned lun
2920 * Returns the first or next lun enabled for OAS operations for the vport/target
2921 * specified. If a lun is found, its vport wwpn, target wwpn and status is
2922 * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned.
2925 * lun that is OAS enabled for the vport/target
2926 * NOT_OAS_ENABLED_LUN when no oas enabled lun found.
2929 lpfc_oas_lun_get_next(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2930 uint8_t tgt_wwpn
[], uint32_t *lun_status
,
2935 if (unlikely(!phba
) || !vpt_wwpn
|| !tgt_wwpn
)
2936 return NOT_OAS_ENABLED_LUN
;
2937 if (lpfc_find_next_oas_lun(phba
, (struct lpfc_name
*)
2938 phba
->sli4_hba
.oas_next_vpt_wwpn
,
2939 (struct lpfc_name
*)
2940 phba
->sli4_hba
.oas_next_tgt_wwpn
,
2941 &phba
->sli4_hba
.oas_next_lun
,
2942 (struct lpfc_name
*)vpt_wwpn
,
2943 (struct lpfc_name
*)tgt_wwpn
,
2944 &found_lun
, lun_status
, lun_pri
))
2947 return NOT_OAS_ENABLED_LUN
;
2951 * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations
2952 * @phba: lpfc_hba pointer.
2953 * @vpt_wwpn: vport wwpn by reference.
2954 * @tgt_wwpn: target wwpn by reference.
2955 * @lun: the fc lun for setting oas state.
2956 * @oas_state: the oas state to be set to the oas_lun.
2958 * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE)
2959 * a lun for OAS operations.
2963 * -ENOMEM: failed to enable an lun for OAS operations
2964 * -EPERM: OAS is not enabled
2967 lpfc_oas_lun_state_change(struct lpfc_hba
*phba
, uint8_t vpt_wwpn
[],
2968 uint8_t tgt_wwpn
[], uint64_t lun
,
2969 uint32_t oas_state
, uint8_t pri
)
2974 rc
= lpfc_oas_lun_state_set(phba
, vpt_wwpn
, tgt_wwpn
, lun
,
2980 * lpfc_oas_lun_show - Return oas enabled luns from a chosen target
2981 * @dev: class device that is converted into a Scsi_host.
2982 * @attr: device attribute, not used.
2983 * @buf: buffer for passing information.
2985 * This routine returns a lun enabled for OAS each time the function
2989 * SUCCESS: size of formatted string.
2990 * -EFAULT: target or vport wwpn was not set properly.
2991 * -EPERM: oas is not enabled.
2994 lpfc_oas_lun_show(struct device
*dev
, struct device_attribute
*attr
,
2997 struct Scsi_Host
*shost
= class_to_shost(dev
);
2998 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3006 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3007 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_VPORT
))
3010 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3011 if (!(phba
->cfg_oas_flags
& OAS_FIND_ANY_TARGET
))
3014 oas_lun
= lpfc_oas_lun_get_next(phba
, phba
->cfg_oas_vpt_wwpn
,
3015 phba
->cfg_oas_tgt_wwpn
,
3016 &phba
->cfg_oas_lun_status
,
3017 &phba
->cfg_oas_priority
);
3018 if (oas_lun
!= NOT_OAS_ENABLED_LUN
)
3019 phba
->cfg_oas_flags
|= OAS_LUN_VALID
;
3021 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "0x%llx", oas_lun
);
3027 * lpfc_oas_lun_store - Sets the OAS state for lun
3028 * @dev: class device that is converted into a Scsi_host.
3029 * @attr: device attribute, not used.
3030 * @buf: buffer for passing information.
3032 * This function sets the OAS state for lun. Before this function is called,
3033 * the vport wwpn, target wwpn, and oas state need to be set.
3036 * SUCCESS: size of formatted string.
3037 * -EFAULT: target or vport wwpn was not set properly.
3038 * -EPERM: oas is not enabled.
3039 * size of formatted string.
3042 lpfc_oas_lun_store(struct device
*dev
, struct device_attribute
*attr
,
3043 const char *buf
, size_t count
)
3045 struct Scsi_Host
*shost
= class_to_shost(dev
);
3046 struct lpfc_hba
*phba
= ((struct lpfc_vport
*)shost
->hostdata
)->phba
;
3054 if (wwn_to_u64(phba
->cfg_oas_vpt_wwpn
) == 0)
3057 if (wwn_to_u64(phba
->cfg_oas_tgt_wwpn
) == 0)
3060 if (!isdigit(buf
[0]))
3063 if (sscanf(buf
, "0x%llx", &scsi_lun
) != 1)
3066 pri
= phba
->cfg_oas_priority
;
3068 pri
= phba
->cfg_XLanePriority
;
3070 lpfc_printf_log(phba
, KERN_INFO
, LOG_INIT
,
3071 "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx "
3072 "priority 0x%x with oas state %d\n",
3073 wwn_to_u64(phba
->cfg_oas_vpt_wwpn
),
3074 wwn_to_u64(phba
->cfg_oas_tgt_wwpn
), scsi_lun
,
3075 pri
, phba
->cfg_oas_lun_state
);
3077 rc
= lpfc_oas_lun_state_change(phba
, phba
->cfg_oas_vpt_wwpn
,
3078 phba
->cfg_oas_tgt_wwpn
, scsi_lun
,
3079 phba
->cfg_oas_lun_state
, pri
);
3085 static DEVICE_ATTR(lpfc_xlane_lun
, S_IRUGO
| S_IWUSR
,
3086 lpfc_oas_lun_show
, lpfc_oas_lun_store
);
3088 int lpfc_enable_nvmet_cnt
;
3089 unsigned long long lpfc_enable_nvmet
[LPFC_NVMET_MAX_PORTS
] = {
3090 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3091 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3092 module_param_array(lpfc_enable_nvmet
, ullong
, &lpfc_enable_nvmet_cnt
, 0444);
3093 MODULE_PARM_DESC(lpfc_enable_nvmet
, "Enable HBA port(s) WWPN as a NVME Target");
3095 static int lpfc_poll
= 0;
3096 module_param(lpfc_poll
, int, S_IRUGO
);
3097 MODULE_PARM_DESC(lpfc_poll
, "FCP ring polling mode control:"
3099 " 1 - poll with interrupts enabled"
3100 " 3 - poll and disable FCP ring interrupts");
3102 static DEVICE_ATTR_RW(lpfc_poll
);
3104 int lpfc_no_hba_reset_cnt
;
3105 unsigned long lpfc_no_hba_reset
[MAX_HBAS_NO_RESET
] = {
3106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3107 module_param_array(lpfc_no_hba_reset
, ulong
, &lpfc_no_hba_reset_cnt
, 0444);
3108 MODULE_PARM_DESC(lpfc_no_hba_reset
, "WWPN of HBAs that should not be reset");
3110 LPFC_ATTR(sli_mode
, 0, 0, 3,
3111 "SLI mode selector:"
3112 " 0 - auto (SLI-3 if supported),"
3113 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
3114 " 3 - select SLI-3");
3116 LPFC_ATTR_R(enable_npiv
, 1, 0, 1,
3117 "Enable NPIV functionality");
3119 LPFC_ATTR_R(fcf_failover_policy
, 1, 1, 2,
3120 "FCF Fast failover=1 Priority failover=2");
3123 # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures
3124 # 0x0 = disabled, XRI/OXID use not tracked.
3125 # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent.
3126 # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent.
3128 LPFC_ATTR_R(enable_rrq
, 2, 0, 2,
3129 "Enable RRQ functionality");
3132 # lpfc_suppress_link_up: Bring link up at initialization
3133 # 0x0 = bring link up (issue MBX_INIT_LINK)
3134 # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
3135 # 0x2 = never bring up link
3136 # Default value is 0.
3138 LPFC_ATTR_R(suppress_link_up
, LPFC_INITIALIZE_LINK
, LPFC_INITIALIZE_LINK
,
3139 LPFC_DELAY_INIT_LINK_INDEFINITELY
,
3140 "Suppress Link Up at initialization");
3142 # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS
3150 lpfc_iocb_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3152 struct Scsi_Host
*shost
= class_to_shost(dev
);
3153 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3155 return snprintf(buf
, PAGE_SIZE
, "%d\n", phba
->iocb_max
);
3158 static DEVICE_ATTR(iocb_hw
, S_IRUGO
,
3159 lpfc_iocb_hw_show
, NULL
);
3161 lpfc_txq_hw_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
3163 struct Scsi_Host
*shost
= class_to_shost(dev
);
3164 struct lpfc_hba
*phba
= ((struct lpfc_vport
*) shost
->hostdata
)->phba
;
3165 struct lpfc_sli_ring
*pring
= lpfc_phba_elsring(phba
);
3167 return snprintf(buf
, PAGE_SIZE
, "%d\n",
3168 pring
? pring
->txq_max
: 0);
3171 static DEVICE_ATTR(txq_hw
, S_IRUGO
,
3172 lpfc_txq_hw_show
, NULL
);
3174 lpfc_txcmplq_hw_show(struct device
*dev
, struct device_attribute
*attr
,
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 snprintf(buf
, PAGE_SIZE
, "%d\n",
3182 pring
? pring
->txcmplq_max
: 0);
3185 static DEVICE_ATTR(txcmplq_hw
, S_IRUGO
,
3186 lpfc_txcmplq_hw_show
, NULL
);
3188 LPFC_ATTR_R(iocb_cnt
, 2, 1, 5,
3189 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
3192 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
3193 # until the timer expires. Value range is [0,255]. Default value is 30.
3195 static int lpfc_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3196 static int lpfc_devloss_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3197 module_param(lpfc_nodev_tmo
, int, 0);
3198 MODULE_PARM_DESC(lpfc_nodev_tmo
,
3199 "Seconds driver will hold I/O waiting "
3200 "for a device to come back");
3203 * lpfc_nodev_tmo_show - Return the hba dev loss timeout value
3204 * @dev: class converted to a Scsi_host structure.
3205 * @attr: device attribute, not used.
3206 * @buf: on return contains the dev loss timeout in decimal.
3208 * Returns: size of formatted string.
3211 lpfc_nodev_tmo_show(struct device
*dev
, struct device_attribute
*attr
,
3214 struct Scsi_Host
*shost
= class_to_shost(dev
);
3215 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3217 return snprintf(buf
, PAGE_SIZE
, "%d\n", vport
->cfg_devloss_tmo
);
3221 * lpfc_nodev_tmo_init - Set the hba nodev timeout value
3222 * @vport: lpfc vport structure pointer.
3223 * @val: contains the nodev timeout value.
3226 * If the devloss tmo is already set then nodev tmo is set to devloss tmo,
3227 * a kernel error message is printed and zero is returned.
3228 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3229 * Otherwise nodev tmo is set to the default value.
3232 * zero if already set or if val is in range
3233 * -EINVAL val out of range
3236 lpfc_nodev_tmo_init(struct lpfc_vport
*vport
, int val
)
3238 if (vport
->cfg_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
) {
3239 vport
->cfg_nodev_tmo
= vport
->cfg_devloss_tmo
;
3240 if (val
!= LPFC_DEF_DEVLOSS_TMO
)
3241 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3242 "0407 Ignoring lpfc_nodev_tmo module "
3243 "parameter because lpfc_devloss_tmo "
3248 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3249 vport
->cfg_nodev_tmo
= val
;
3250 vport
->cfg_devloss_tmo
= val
;
3253 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3254 "0400 lpfc_nodev_tmo attribute cannot be set to"
3255 " %d, allowed range is [%d, %d]\n",
3256 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3257 vport
->cfg_nodev_tmo
= LPFC_DEF_DEVLOSS_TMO
;
3262 * lpfc_update_rport_devloss_tmo - Update dev loss tmo value
3263 * @vport: lpfc vport structure pointer.
3266 * Update all the ndlp's dev loss tmo with the vport devloss tmo value.
3269 lpfc_update_rport_devloss_tmo(struct lpfc_vport
*vport
)
3271 struct Scsi_Host
*shost
;
3272 struct lpfc_nodelist
*ndlp
;
3274 shost
= lpfc_shost_from_vport(vport
);
3275 spin_lock_irq(shost
->host_lock
);
3276 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3277 if (!NLP_CHK_NODE_ACT(ndlp
))
3280 ndlp
->rport
->dev_loss_tmo
= vport
->cfg_devloss_tmo
;
3281 #if (IS_ENABLED(CONFIG_NVME_FC))
3283 nvme_fc_set_remoteport_devloss(ndlp
->nrport
->remoteport
,
3284 vport
->cfg_devloss_tmo
);
3287 spin_unlock_irq(shost
->host_lock
);
3291 * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values
3292 * @vport: lpfc vport structure pointer.
3293 * @val: contains the tmo value.
3296 * If the devloss tmo is already set or the vport dev loss tmo has changed
3297 * then a kernel error message is printed and zero is returned.
3298 * Else if val is in range then nodev tmo and devloss tmo are set to val.
3299 * Otherwise nodev tmo is set to the default value.
3302 * zero if already set or if val is in range
3303 * -EINVAL val out of range
3306 lpfc_nodev_tmo_set(struct lpfc_vport
*vport
, int val
)
3308 if (vport
->dev_loss_tmo_changed
||
3309 (lpfc_devloss_tmo
!= LPFC_DEF_DEVLOSS_TMO
)) {
3310 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3311 "0401 Ignoring change to lpfc_nodev_tmo "
3312 "because lpfc_devloss_tmo is set.\n");
3315 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3316 vport
->cfg_nodev_tmo
= val
;
3317 vport
->cfg_devloss_tmo
= val
;
3319 * For compat: set the fc_host dev loss so new rports
3320 * will get the value.
3322 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3323 lpfc_update_rport_devloss_tmo(vport
);
3326 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3327 "0403 lpfc_nodev_tmo attribute cannot be set to "
3328 "%d, allowed range is [%d, %d]\n",
3329 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3333 lpfc_vport_param_store(nodev_tmo
)
3335 static DEVICE_ATTR_RW(lpfc_nodev_tmo
);
3338 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
3339 # disappear until the timer expires. Value range is [0,255]. Default
3342 module_param(lpfc_devloss_tmo
, int, S_IRUGO
);
3343 MODULE_PARM_DESC(lpfc_devloss_tmo
,
3344 "Seconds driver will hold I/O waiting "
3345 "for a device to come back");
3346 lpfc_vport_param_init(devloss_tmo
, LPFC_DEF_DEVLOSS_TMO
,
3347 LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
)
3348 lpfc_vport_param_show(devloss_tmo
)
3351 * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit
3352 * @vport: lpfc vport structure pointer.
3353 * @val: contains the tmo value.
3356 * If val is in a valid range then set the vport nodev tmo,
3357 * devloss tmo, also set the vport dev loss tmo changed flag.
3358 * Else a kernel error message is printed.
3361 * zero if val is in range
3362 * -EINVAL val out of range
3365 lpfc_devloss_tmo_set(struct lpfc_vport
*vport
, int val
)
3367 if (val
>= LPFC_MIN_DEVLOSS_TMO
&& val
<= LPFC_MAX_DEVLOSS_TMO
) {
3368 vport
->cfg_nodev_tmo
= val
;
3369 vport
->cfg_devloss_tmo
= val
;
3370 vport
->dev_loss_tmo_changed
= 1;
3371 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport
)) = val
;
3372 lpfc_update_rport_devloss_tmo(vport
);
3376 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3377 "0404 lpfc_devloss_tmo attribute cannot be set to "
3378 "%d, allowed range is [%d, %d]\n",
3379 val
, LPFC_MIN_DEVLOSS_TMO
, LPFC_MAX_DEVLOSS_TMO
);
3383 lpfc_vport_param_store(devloss_tmo
)
3384 static DEVICE_ATTR_RW(lpfc_devloss_tmo
);
3387 * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it
3388 * lpfc_suppress_rsp = 0 Disable
3389 * lpfc_suppress_rsp = 1 Enable (default)
3392 LPFC_ATTR_R(suppress_rsp
, 1, 0, 1,
3393 "Enable suppress rsp feature is firmware supports it");
3396 * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds
3397 * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs
3398 * lpfc_nvmet_mrq = 1 use a single RQ pair
3399 * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ
3402 LPFC_ATTR_R(nvmet_mrq
,
3403 LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_AUTO
, LPFC_NVMET_MRQ_MAX
,
3404 "Specify number of RQ pairs for processing NVMET cmds");
3407 * lpfc_enable_fc4_type: Defines what FC4 types are supported.
3408 * Supported Values: 1 - register just FCP
3409 * 3 - register both FCP and NVME
3410 * Supported values are [1,3]. Default value is 1
3412 LPFC_ATTR_R(enable_fc4_type
, LPFC_ENABLE_FCP
,
3413 LPFC_ENABLE_FCP
, LPFC_ENABLE_BOTH
,
3414 "Enable FC4 Protocol support - FCP / NVME");
3417 * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME
3418 * This parameter is only used if:
3419 * lpfc_enable_fc4_type is 3 - register both FCP and NVME and
3420 * port is not configured for NVMET.
3422 * ELS/CT always get 10% of XRIs, up to a maximum of 250
3423 * The remaining XRIs get split up based on lpfc_xri_split per port:
3425 * Supported Values are in percentages
3426 * the xri_split value is the percentage the SCSI port will get. The remaining
3427 * percentage will go to NVME.
3429 LPFC_ATTR_R(xri_split
, 50, 10, 90,
3430 "Percentage of FCP XRI resources versus NVME");
3433 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
3434 # deluged with LOTS of information.
3435 # You can set a bit mask to record specific types of verbose messages:
3436 # See lpfc_logmsh.h for definitions.
3438 LPFC_VPORT_ATTR_HEX_RW(log_verbose
, 0x0, 0x0, 0xffffffff,
3439 "Verbose logging bit-mask");
3442 # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
3443 # objects that have been registered with the nameserver after login.
3445 LPFC_VPORT_ATTR_R(enable_da_id
, 1, 0, 1,
3446 "Deregister nameserver objects before LOGO");
3449 # lun_queue_depth: This parameter is used to limit the number of outstanding
3450 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
3451 # If this parameter value is greater than 1/8th the maximum number of exchanges
3452 # supported by the HBA port, then the lun queue depth will be reduced to
3453 # 1/8th the maximum number of exchanges.
3455 LPFC_VPORT_ATTR_R(lun_queue_depth
, 30, 1, 512,
3456 "Max number of FCP commands we can queue to a specific LUN");
3459 # tgt_queue_depth: This parameter is used to limit the number of outstanding
3460 # commands per target port. Value range is [10,65535]. Default value is 65535.
3462 LPFC_VPORT_ATTR_R(tgt_queue_depth
, 65535, 10, 65535,
3463 "Max number of FCP commands we can queue to a specific target port");
3466 # hba_queue_depth: This parameter is used to limit the number of outstanding
3467 # commands per lpfc HBA. Value range is [32,8192]. If this parameter
3468 # value is greater than the maximum number of exchanges supported by the HBA,
3469 # then maximum number of exchanges supported by the HBA is used to determine
3470 # the hba_queue_depth.
3472 LPFC_ATTR_R(hba_queue_depth
, 8192, 32, 8192,
3473 "Max number of FCP commands we can queue to a lpfc HBA");
3476 # peer_port_login: This parameter allows/prevents logins
3477 # between peer ports hosted on the same physical port.
3478 # When this parameter is set 0 peer ports of same physical port
3479 # are not allowed to login to each other.
3480 # When this parameter is set 1 peer ports of same physical port
3481 # are allowed to login to each other.
3482 # Default value of this parameter is 0.
3484 LPFC_VPORT_ATTR_R(peer_port_login
, 0, 0, 1,
3485 "Allow peer ports on the same physical port to login to each "
3489 # restrict_login: This parameter allows/prevents logins
3490 # between Virtual Ports and remote initiators.
3491 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
3492 # other initiators and will attempt to PLOGI all remote ports.
3493 # When this parameter is set (1) Virtual Ports will reject PLOGIs from
3494 # remote ports and will not attempt to PLOGI to other initiators.
3495 # This parameter does not restrict to the physical port.
3496 # This parameter does not restrict logins to Fabric resident remote ports.
3497 # Default value of this parameter is 1.
3499 static int lpfc_restrict_login
= 1;
3500 module_param(lpfc_restrict_login
, int, S_IRUGO
);
3501 MODULE_PARM_DESC(lpfc_restrict_login
,
3502 "Restrict virtual ports login to remote initiators.");
3503 lpfc_vport_param_show(restrict_login
);
3506 * lpfc_restrict_login_init - Set the vport restrict login flag
3507 * @vport: lpfc vport structure pointer.
3508 * @val: contains the restrict login value.
3511 * If val is not in a valid range then log a kernel error message and set
3512 * the vport restrict login to one.
3513 * If the port type is physical clear the restrict login flag and return.
3514 * Else set the restrict login flag to val.
3517 * zero if val is in range
3518 * -EINVAL val out of range
3521 lpfc_restrict_login_init(struct lpfc_vport
*vport
, int val
)
3523 if (val
< 0 || val
> 1) {
3524 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3525 "0422 lpfc_restrict_login attribute cannot "
3526 "be set to %d, allowed range is [0, 1]\n",
3528 vport
->cfg_restrict_login
= 1;
3531 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
3532 vport
->cfg_restrict_login
= 0;
3535 vport
->cfg_restrict_login
= val
;
3540 * lpfc_restrict_login_set - Set the vport restrict login flag
3541 * @vport: lpfc vport structure pointer.
3542 * @val: contains the restrict login value.
3545 * If val is not in a valid range then log a kernel error message and set
3546 * the vport restrict login to one.
3547 * If the port type is physical and the val is not zero log a kernel
3548 * error message, clear the restrict login flag and return zero.
3549 * Else set the restrict login flag to val.
3552 * zero if val is in range
3553 * -EINVAL val out of range
3556 lpfc_restrict_login_set(struct lpfc_vport
*vport
, int val
)
3558 if (val
< 0 || val
> 1) {
3559 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3560 "0425 lpfc_restrict_login attribute cannot "
3561 "be set to %d, allowed range is [0, 1]\n",
3563 vport
->cfg_restrict_login
= 1;
3566 if (vport
->port_type
== LPFC_PHYSICAL_PORT
&& val
!= 0) {
3567 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3568 "0468 lpfc_restrict_login must be 0 for "
3569 "Physical ports.\n");
3570 vport
->cfg_restrict_login
= 0;
3573 vport
->cfg_restrict_login
= val
;
3576 lpfc_vport_param_store(restrict_login
);
3577 static DEVICE_ATTR_RW(lpfc_restrict_login
);
3580 # Some disk devices have a "select ID" or "select Target" capability.
3581 # From a protocol standpoint "select ID" usually means select the
3582 # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
3583 # annex" which contains a table that maps a "select ID" (a number
3584 # between 0 and 7F) to an ALPA. By default, for compatibility with
3585 # older drivers, the lpfc driver scans this table from low ALPA to high
3588 # Turning on the scan-down variable (on = 1, off = 0) will
3589 # cause the lpfc driver to use an inverted table, effectively
3590 # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
3592 # (Note: This "select ID" functionality is a LOOP ONLY characteristic
3593 # and will not work across a fabric. Also this parameter will take
3594 # effect only in the case when ALPA map is not available.)
3596 LPFC_VPORT_ATTR_R(scan_down
, 1, 0, 1,
3597 "Start scanning for devices from highest ALPA to lowest");
3600 # lpfc_topology: link topology for init link
3601 # 0x0 = attempt loop mode then point-to-point
3602 # 0x01 = internal loopback mode
3603 # 0x02 = attempt point-to-point mode only
3604 # 0x04 = attempt loop mode only
3605 # 0x06 = attempt point-to-point mode then loop
3606 # Set point-to-point mode if you want to run as an N_Port.
3607 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
3608 # Default value is 0.
3610 LPFC_ATTR(topology
, 0, 0, 6,
3611 "Select Fibre Channel topology");
3614 * lpfc_topology_set - Set the adapters topology field
3615 * @phba: lpfc_hba pointer.
3616 * @val: topology value.
3619 * If val is in a valid range then set the adapter's topology field and
3620 * issue a lip; if the lip fails reset the topology to the old value.
3622 * If the value is not in range log a kernel error message and return an error.
3625 * zero if val is in range and lip okay
3626 * non-zero return value from lpfc_issue_lip()
3627 * -EINVAL val out of range
3630 lpfc_topology_store(struct device
*dev
, struct device_attribute
*attr
,
3631 const char *buf
, size_t count
)
3633 struct Scsi_Host
*shost
= class_to_shost(dev
);
3634 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3635 struct lpfc_hba
*phba
= vport
->phba
;
3638 const char *val_buf
= buf
;
3642 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
3644 val_buf
= &buf
[strlen("nolip ")];
3647 if (!isdigit(val_buf
[0]))
3649 if (sscanf(val_buf
, "%i", &val
) != 1)
3652 if (val
>= 0 && val
<= 6) {
3653 prev_val
= phba
->cfg_topology
;
3654 if (phba
->cfg_link_speed
== LPFC_USER_LINK_SPEED_16G
&&
3656 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3657 "3113 Loop mode not supported at speed %d\n",
3661 if (phba
->pcidev
->device
== PCI_DEVICE_ID_LANCER_G6_FC
&&
3663 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3664 "3114 Loop mode not supported\n");
3667 phba
->cfg_topology
= val
;
3671 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3672 "3054 lpfc_topology changed from %d to %d\n",
3674 if (prev_val
!= val
&& phba
->sli_rev
== LPFC_SLI_REV4
)
3675 phba
->fc_topology_changed
= 1;
3676 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
3678 phba
->cfg_topology
= prev_val
;
3683 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3684 "%d:0467 lpfc_topology attribute cannot be set to %d, "
3685 "allowed range is [0, 6]\n",
3690 lpfc_param_show(topology
)
3691 static DEVICE_ATTR_RW(lpfc_topology
);
3694 * lpfc_static_vport_show: Read callback function for
3695 * lpfc_static_vport sysfs file.
3696 * @dev: Pointer to class device object.
3697 * @attr: device attribute structure.
3698 * @buf: Data buffer.
3700 * This function is the read call back function for
3701 * lpfc_static_vport sysfs file. The lpfc_static_vport
3702 * sysfs file report the mageability of the vport.
3705 lpfc_static_vport_show(struct device
*dev
, struct device_attribute
*attr
,
3708 struct Scsi_Host
*shost
= class_to_shost(dev
);
3709 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3710 if (vport
->vport_flag
& STATIC_VPORT
)
3711 sprintf(buf
, "1\n");
3713 sprintf(buf
, "0\n");
3719 * Sysfs attribute to control the statistical data collection.
3721 static DEVICE_ATTR_RO(lpfc_static_vport
);
3724 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
3725 * @dev: Pointer to class device.
3726 * @buf: Data buffer.
3727 * @count: Size of the data buffer.
3729 * This function get called when a user write to the lpfc_stat_data_ctrl
3730 * sysfs file. This function parse the command written to the sysfs file
3731 * and take appropriate action. These commands are used for controlling
3732 * driver statistical data collection.
3733 * Following are the command this function handles.
3735 * setbucket <bucket_type> <base> <step>
3736 * = Set the latency buckets.
3737 * destroybucket = destroy all the buckets.
3738 * start = start data collection
3739 * stop = stop data collection
3740 * reset = reset the collected data
3743 lpfc_stat_data_ctrl_store(struct device
*dev
, struct device_attribute
*attr
,
3744 const char *buf
, size_t count
)
3746 struct Scsi_Host
*shost
= class_to_shost(dev
);
3747 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3748 struct lpfc_hba
*phba
= vport
->phba
;
3749 #define LPFC_MAX_DATA_CTRL_LEN 1024
3750 static char bucket_data
[LPFC_MAX_DATA_CTRL_LEN
];
3752 char *str_ptr
, *token
;
3753 struct lpfc_vport
**vports
;
3754 struct Scsi_Host
*v_shost
;
3755 char *bucket_type_str
, *base_str
, *step_str
;
3756 unsigned long base
, step
, bucket_type
;
3758 if (!strncmp(buf
, "setbucket", strlen("setbucket"))) {
3759 if (strlen(buf
) > (LPFC_MAX_DATA_CTRL_LEN
- 1))
3762 strncpy(bucket_data
, buf
, LPFC_MAX_DATA_CTRL_LEN
);
3763 str_ptr
= &bucket_data
[0];
3764 /* Ignore this token - this is command token */
3765 token
= strsep(&str_ptr
, "\t ");
3769 bucket_type_str
= strsep(&str_ptr
, "\t ");
3770 if (!bucket_type_str
)
3773 if (!strncmp(bucket_type_str
, "linear", strlen("linear")))
3774 bucket_type
= LPFC_LINEAR_BUCKET
;
3775 else if (!strncmp(bucket_type_str
, "power2", strlen("power2")))
3776 bucket_type
= LPFC_POWER2_BUCKET
;
3780 base_str
= strsep(&str_ptr
, "\t ");
3783 base
= simple_strtoul(base_str
, NULL
, 0);
3785 step_str
= strsep(&str_ptr
, "\t ");
3788 step
= simple_strtoul(step_str
, NULL
, 0);
3792 /* Block the data collection for every vport */
3793 vports
= lpfc_create_vport_work_array(phba
);
3797 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3798 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3799 spin_lock_irq(v_shost
->host_lock
);
3800 /* Block and reset data collection */
3801 vports
[i
]->stat_data_blocked
= 1;
3802 if (vports
[i
]->stat_data_enabled
)
3803 lpfc_vport_reset_stat_data(vports
[i
]);
3804 spin_unlock_irq(v_shost
->host_lock
);
3807 /* Set the bucket attributes */
3808 phba
->bucket_type
= bucket_type
;
3809 phba
->bucket_base
= base
;
3810 phba
->bucket_step
= step
;
3812 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3813 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3815 /* Unblock data collection */
3816 spin_lock_irq(v_shost
->host_lock
);
3817 vports
[i
]->stat_data_blocked
= 0;
3818 spin_unlock_irq(v_shost
->host_lock
);
3820 lpfc_destroy_vport_work_array(phba
, vports
);
3824 if (!strncmp(buf
, "destroybucket", strlen("destroybucket"))) {
3825 vports
= lpfc_create_vport_work_array(phba
);
3829 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
; i
++) {
3830 v_shost
= lpfc_shost_from_vport(vports
[i
]);
3831 spin_lock_irq(shost
->host_lock
);
3832 vports
[i
]->stat_data_blocked
= 1;
3833 lpfc_free_bucket(vport
);
3834 vport
->stat_data_enabled
= 0;
3835 vports
[i
]->stat_data_blocked
= 0;
3836 spin_unlock_irq(shost
->host_lock
);
3838 lpfc_destroy_vport_work_array(phba
, vports
);
3839 phba
->bucket_type
= LPFC_NO_BUCKET
;
3840 phba
->bucket_base
= 0;
3841 phba
->bucket_step
= 0;
3845 if (!strncmp(buf
, "start", strlen("start"))) {
3846 /* If no buckets configured return error */
3847 if (phba
->bucket_type
== LPFC_NO_BUCKET
)
3849 spin_lock_irq(shost
->host_lock
);
3850 if (vport
->stat_data_enabled
) {
3851 spin_unlock_irq(shost
->host_lock
);
3854 lpfc_alloc_bucket(vport
);
3855 vport
->stat_data_enabled
= 1;
3856 spin_unlock_irq(shost
->host_lock
);
3860 if (!strncmp(buf
, "stop", strlen("stop"))) {
3861 spin_lock_irq(shost
->host_lock
);
3862 if (vport
->stat_data_enabled
== 0) {
3863 spin_unlock_irq(shost
->host_lock
);
3866 lpfc_free_bucket(vport
);
3867 vport
->stat_data_enabled
= 0;
3868 spin_unlock_irq(shost
->host_lock
);
3872 if (!strncmp(buf
, "reset", strlen("reset"))) {
3873 if ((phba
->bucket_type
== LPFC_NO_BUCKET
)
3874 || !vport
->stat_data_enabled
)
3876 spin_lock_irq(shost
->host_lock
);
3877 vport
->stat_data_blocked
= 1;
3878 lpfc_vport_reset_stat_data(vport
);
3879 vport
->stat_data_blocked
= 0;
3880 spin_unlock_irq(shost
->host_lock
);
3888 * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file
3889 * @dev: Pointer to class device object.
3890 * @buf: Data buffer.
3892 * This function is the read call back function for
3893 * lpfc_stat_data_ctrl sysfs file. This function report the
3894 * current statistical data collection state.
3897 lpfc_stat_data_ctrl_show(struct device
*dev
, struct device_attribute
*attr
,
3900 struct Scsi_Host
*shost
= class_to_shost(dev
);
3901 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3902 struct lpfc_hba
*phba
= vport
->phba
;
3906 unsigned long bucket_value
;
3908 switch (phba
->bucket_type
) {
3909 case LPFC_LINEAR_BUCKET
:
3910 bucket_type
= "linear";
3912 case LPFC_POWER2_BUCKET
:
3913 bucket_type
= "power2";
3916 bucket_type
= "No Bucket";
3920 sprintf(&buf
[index
], "Statistical Data enabled :%d, "
3921 "blocked :%d, Bucket type :%s, Bucket base :%d,"
3922 " Bucket step :%d\nLatency Ranges :",
3923 vport
->stat_data_enabled
, vport
->stat_data_blocked
,
3924 bucket_type
, phba
->bucket_base
, phba
->bucket_step
);
3925 index
= strlen(buf
);
3926 if (phba
->bucket_type
!= LPFC_NO_BUCKET
) {
3927 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
3928 if (phba
->bucket_type
== LPFC_LINEAR_BUCKET
)
3929 bucket_value
= phba
->bucket_base
+
3930 phba
->bucket_step
* i
;
3932 bucket_value
= phba
->bucket_base
+
3933 (1 << i
) * phba
->bucket_step
;
3935 if (index
+ 10 > PAGE_SIZE
)
3937 sprintf(&buf
[index
], "%08ld ", bucket_value
);
3938 index
= strlen(buf
);
3941 sprintf(&buf
[index
], "\n");
3946 * Sysfs attribute to control the statistical data collection.
3948 static DEVICE_ATTR_RW(lpfc_stat_data_ctrl
);
3951 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
3955 * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN
3958 #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
3959 #define MAX_STAT_DATA_SIZE_PER_TARGET \
3960 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
3964 * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute
3966 * @kobj: Pointer to the kernel object
3967 * @bin_attr: Attribute object
3968 * @buff: Buffer pointer
3970 * @count: Buffer size
3972 * This function is the read call back function for lpfc_drvr_stat_data
3973 * sysfs file. This function export the statistical data to user
3977 sysfs_drvr_stat_data_read(struct file
*filp
, struct kobject
*kobj
,
3978 struct bin_attribute
*bin_attr
,
3979 char *buf
, loff_t off
, size_t count
)
3981 struct device
*dev
= container_of(kobj
, struct device
,
3983 struct Scsi_Host
*shost
= class_to_shost(dev
);
3984 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
3985 struct lpfc_hba
*phba
= vport
->phba
;
3986 int i
= 0, index
= 0;
3987 unsigned long nport_index
;
3988 struct lpfc_nodelist
*ndlp
= NULL
;
3989 nport_index
= (unsigned long)off
/
3990 MAX_STAT_DATA_SIZE_PER_TARGET
;
3992 if (!vport
->stat_data_enabled
|| vport
->stat_data_blocked
3993 || (phba
->bucket_type
== LPFC_NO_BUCKET
))
3996 spin_lock_irq(shost
->host_lock
);
3997 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
3998 if (!NLP_CHK_NODE_ACT(ndlp
) || !ndlp
->lat_data
)
4001 if (nport_index
> 0) {
4006 if ((index
+ MAX_STAT_DATA_SIZE_PER_TARGET
)
4010 if (!ndlp
->lat_data
)
4014 sprintf(&buf
[index
], "%02x%02x%02x%02x%02x%02x%02x%02x:",
4015 ndlp
->nlp_portname
.u
.wwn
[0],
4016 ndlp
->nlp_portname
.u
.wwn
[1],
4017 ndlp
->nlp_portname
.u
.wwn
[2],
4018 ndlp
->nlp_portname
.u
.wwn
[3],
4019 ndlp
->nlp_portname
.u
.wwn
[4],
4020 ndlp
->nlp_portname
.u
.wwn
[5],
4021 ndlp
->nlp_portname
.u
.wwn
[6],
4022 ndlp
->nlp_portname
.u
.wwn
[7]);
4024 index
= strlen(buf
);
4026 for (i
= 0; i
< LPFC_MAX_BUCKET_COUNT
; i
++) {
4027 sprintf(&buf
[index
], "%010u,",
4028 ndlp
->lat_data
[i
].cmd_count
);
4029 index
= strlen(buf
);
4031 sprintf(&buf
[index
], "\n");
4032 index
= strlen(buf
);
4034 spin_unlock_irq(shost
->host_lock
);
4038 static struct bin_attribute sysfs_drvr_stat_data_attr
= {
4040 .name
= "lpfc_drvr_stat_data",
4043 .size
= LPFC_MAX_TARGET
* MAX_STAT_DATA_SIZE_PER_TARGET
,
4044 .read
= sysfs_drvr_stat_data_read
,
4049 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
4051 # Value range is [0,16]. Default value is 0.
4054 * lpfc_link_speed_set - Set the adapters link speed
4055 * @phba: lpfc_hba pointer.
4056 * @val: link speed value.
4059 * If val is in a valid range then set the adapter's link speed field and
4060 * issue a lip; if the lip fails reset the link speed to the old value.
4063 * If the value is not in range log a kernel error message and return an error.
4066 * zero if val is in range and lip okay.
4067 * non-zero return value from lpfc_issue_lip()
4068 * -EINVAL val out of range
4071 lpfc_link_speed_store(struct device
*dev
, struct device_attribute
*attr
,
4072 const char *buf
, size_t count
)
4074 struct Scsi_Host
*shost
= class_to_shost(dev
);
4075 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4076 struct lpfc_hba
*phba
= vport
->phba
;
4077 int val
= LPFC_USER_LINK_SPEED_AUTO
;
4079 const char *val_buf
= buf
;
4081 uint32_t prev_val
, if_type
;
4083 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
4084 if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
&&
4085 phba
->hba_flag
& HBA_FORCED_LINK_SPEED
)
4088 if (!strncmp(buf
, "nolip ", strlen("nolip "))) {
4090 val_buf
= &buf
[strlen("nolip ")];
4093 if (!isdigit(val_buf
[0]))
4095 if (sscanf(val_buf
, "%i", &val
) != 1)
4098 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4099 "3055 lpfc_link_speed changed from %d to %d %s\n",
4100 phba
->cfg_link_speed
, val
, nolip
? "(nolip)" : "(lip)");
4102 if (((val
== LPFC_USER_LINK_SPEED_1G
) && !(phba
->lmt
& LMT_1Gb
)) ||
4103 ((val
== LPFC_USER_LINK_SPEED_2G
) && !(phba
->lmt
& LMT_2Gb
)) ||
4104 ((val
== LPFC_USER_LINK_SPEED_4G
) && !(phba
->lmt
& LMT_4Gb
)) ||
4105 ((val
== LPFC_USER_LINK_SPEED_8G
) && !(phba
->lmt
& LMT_8Gb
)) ||
4106 ((val
== LPFC_USER_LINK_SPEED_10G
) && !(phba
->lmt
& LMT_10Gb
)) ||
4107 ((val
== LPFC_USER_LINK_SPEED_16G
) && !(phba
->lmt
& LMT_16Gb
)) ||
4108 ((val
== LPFC_USER_LINK_SPEED_32G
) && !(phba
->lmt
& LMT_32Gb
))) {
4109 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4110 "2879 lpfc_link_speed attribute cannot be set "
4111 "to %d. Speed is not supported by this port.\n",
4115 if (val
== LPFC_USER_LINK_SPEED_16G
&&
4116 phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
4117 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4118 "3112 lpfc_link_speed attribute cannot be set "
4119 "to %d. Speed is not supported in loop mode.\n",
4123 if ((val
>= 0) && (val
<= LPFC_USER_LINK_SPEED_MAX
) &&
4124 (LPFC_USER_LINK_SPEED_BITMAP
& (1 << val
))) {
4125 prev_val
= phba
->cfg_link_speed
;
4126 phba
->cfg_link_speed
= val
;
4130 err
= lpfc_issue_lip(lpfc_shost_from_vport(phba
->pport
));
4132 phba
->cfg_link_speed
= prev_val
;
4137 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4138 "0469 lpfc_link_speed attribute cannot be set to %d, "
4139 "allowed values are ["LPFC_LINK_SPEED_STRING
"]\n", val
);
4143 static int lpfc_link_speed
= 0;
4144 module_param(lpfc_link_speed
, int, S_IRUGO
);
4145 MODULE_PARM_DESC(lpfc_link_speed
, "Select link speed");
4146 lpfc_param_show(link_speed
)
4149 * lpfc_link_speed_init - Set the adapters link speed
4150 * @phba: lpfc_hba pointer.
4151 * @val: link speed value.
4154 * If val is in a valid range then set the adapter's link speed field.
4157 * If the value is not in range log a kernel error message, clear the link
4158 * speed and return an error.
4161 * zero if val saved.
4162 * -EINVAL val out of range
4165 lpfc_link_speed_init(struct lpfc_hba
*phba
, int val
)
4167 if (val
== LPFC_USER_LINK_SPEED_16G
&& phba
->cfg_topology
== 4) {
4168 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4169 "3111 lpfc_link_speed of %d cannot "
4170 "support loop mode, setting topology to default.\n",
4172 phba
->cfg_topology
= 0;
4174 if ((val
>= 0) && (val
<= LPFC_USER_LINK_SPEED_MAX
) &&
4175 (LPFC_USER_LINK_SPEED_BITMAP
& (1 << val
))) {
4176 phba
->cfg_link_speed
= val
;
4179 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4180 "0405 lpfc_link_speed attribute cannot "
4181 "be set to %d, allowed values are "
4182 "["LPFC_LINK_SPEED_STRING
"]\n", val
);
4183 phba
->cfg_link_speed
= LPFC_USER_LINK_SPEED_AUTO
;
4187 static DEVICE_ATTR_RW(lpfc_link_speed
);
4190 # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
4191 # 0 = aer disabled or not supported
4192 # 1 = aer supported and enabled (default)
4193 # Value range is [0,1]. Default value is 1.
4195 LPFC_ATTR(aer_support
, 1, 0, 1,
4196 "Enable PCIe device AER support");
4197 lpfc_param_show(aer_support
)
4200 * lpfc_aer_support_store - Set the adapter for aer support
4202 * @dev: class device that is converted into a Scsi_host.
4203 * @attr: device attribute, not used.
4204 * @buf: containing enable or disable aer flag.
4205 * @count: unused variable.
4208 * If the val is 1 and currently the device's AER capability was not
4209 * enabled, invoke the kernel's enable AER helper routine, trying to
4210 * enable the device's AER capability. If the helper routine enabling
4211 * AER returns success, update the device's cfg_aer_support flag to
4212 * indicate AER is supported by the device; otherwise, if the device
4213 * AER capability is already enabled to support AER, then do nothing.
4215 * If the val is 0 and currently the device's AER support was enabled,
4216 * invoke the kernel's disable AER helper routine. After that, update
4217 * the device's cfg_aer_support flag to indicate AER is not supported
4218 * by the device; otherwise, if the device AER capability is already
4219 * disabled from supporting AER, then do nothing.
4222 * length of the buf on success if val is in range the intended mode
4224 * -EINVAL if val out of range or intended mode is not supported.
4227 lpfc_aer_support_store(struct device
*dev
, struct device_attribute
*attr
,
4228 const char *buf
, size_t count
)
4230 struct Scsi_Host
*shost
= class_to_shost(dev
);
4231 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4232 struct lpfc_hba
*phba
= vport
->phba
;
4233 int val
= 0, rc
= -EINVAL
;
4235 if (!isdigit(buf
[0]))
4237 if (sscanf(buf
, "%i", &val
) != 1)
4242 if (phba
->hba_flag
& HBA_AER_ENABLED
) {
4243 rc
= pci_disable_pcie_error_reporting(phba
->pcidev
);
4245 spin_lock_irq(&phba
->hbalock
);
4246 phba
->hba_flag
&= ~HBA_AER_ENABLED
;
4247 spin_unlock_irq(&phba
->hbalock
);
4248 phba
->cfg_aer_support
= 0;
4253 phba
->cfg_aer_support
= 0;
4258 if (!(phba
->hba_flag
& HBA_AER_ENABLED
)) {
4259 rc
= pci_enable_pcie_error_reporting(phba
->pcidev
);
4261 spin_lock_irq(&phba
->hbalock
);
4262 phba
->hba_flag
|= HBA_AER_ENABLED
;
4263 spin_unlock_irq(&phba
->hbalock
);
4264 phba
->cfg_aer_support
= 1;
4269 phba
->cfg_aer_support
= 1;
4280 static DEVICE_ATTR_RW(lpfc_aer_support
);
4283 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
4284 * @dev: class device that is converted into a Scsi_host.
4285 * @attr: device attribute, not used.
4286 * @buf: containing flag 1 for aer cleanup state.
4287 * @count: unused variable.
4290 * If the @buf contains 1 and the device currently has the AER support
4291 * enabled, then invokes the kernel AER helper routine
4292 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
4293 * error status register.
4298 * -EINVAL if the buf does not contain the 1 or the device is not currently
4299 * enabled with the AER support.
4302 lpfc_aer_cleanup_state(struct device
*dev
, struct device_attribute
*attr
,
4303 const char *buf
, size_t count
)
4305 struct Scsi_Host
*shost
= class_to_shost(dev
);
4306 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
4307 struct lpfc_hba
*phba
= vport
->phba
;
4310 if (!isdigit(buf
[0]))
4312 if (sscanf(buf
, "%i", &val
) != 1)
4317 if (phba
->hba_flag
& HBA_AER_ENABLED
)
4318 rc
= pci_cleanup_aer_uncorrect_error_status(phba
->pcidev
);
4326 static DEVICE_ATTR(lpfc_aer_state_cleanup
, S_IWUSR
, NULL
,
4327 lpfc_aer_cleanup_state
);
4330 * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions
4332 * @dev: class device that is converted into a Scsi_host.
4333 * @attr: device attribute, not used.
4334 * @buf: containing the string the number of vfs to be enabled.
4335 * @count: unused variable.
4338 * When this api is called either through user sysfs, the driver shall
4339 * try to enable or disable SR-IOV virtual functions according to the
4342 * If zero virtual function has been enabled to the physical function,
4343 * the driver shall invoke the pci enable virtual function api trying
4344 * to enable the virtual functions. If the nr_vfn provided is greater
4345 * than the maximum supported, the maximum virtual function number will
4346 * be used for invoking the api; otherwise, the nr_vfn provided shall
4347 * be used for invoking the api. If the api call returned success, the
4348 * actual number of virtual functions enabled will be set to the driver
4349 * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver
4350 * cfg_sriov_nr_virtfn remains zero.
4352 * If none-zero virtual functions have already been enabled to the
4353 * physical function, as reflected by the driver's cfg_sriov_nr_virtfn,
4354 * -EINVAL will be returned and the driver does nothing;
4356 * If the nr_vfn provided is zero and none-zero virtual functions have
4357 * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the
4358 * disabling virtual function api shall be invoded to disable all the
4359 * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to
4360 * zero. Otherwise, if zero virtual function has been enabled, do
4364 * length of the buf on success if val is in range the intended mode
4366 * -EINVAL if val out of range or intended mode is not supported.
4369 lpfc_sriov_nr_virtfn_store(struct device
*dev
, struct device_attribute
*attr
,
4370 const char *buf
, size_t count
)
4372 struct Scsi_Host
*shost
= class_to_shost(dev
);
4373 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4374 struct lpfc_hba
*phba
= vport
->phba
;
4375 struct pci_dev
*pdev
= phba
->pcidev
;
4376 int val
= 0, rc
= -EINVAL
;
4378 /* Sanity check on user data */
4379 if (!isdigit(buf
[0]))
4381 if (sscanf(buf
, "%i", &val
) != 1)
4386 /* Request disabling virtual functions */
4388 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4389 pci_disable_sriov(pdev
);
4390 phba
->cfg_sriov_nr_virtfn
= 0;
4395 /* Request enabling virtual functions */
4396 if (phba
->cfg_sriov_nr_virtfn
> 0) {
4397 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4398 "3018 There are %d virtual functions "
4399 "enabled on physical function.\n",
4400 phba
->cfg_sriov_nr_virtfn
);
4404 if (val
<= LPFC_MAX_VFN_PER_PFN
)
4405 phba
->cfg_sriov_nr_virtfn
= val
;
4407 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4408 "3019 Enabling %d virtual functions is not "
4413 rc
= lpfc_sli_probe_sriov_nr_virtfn(phba
, phba
->cfg_sriov_nr_virtfn
);
4415 phba
->cfg_sriov_nr_virtfn
= 0;
4423 LPFC_ATTR(sriov_nr_virtfn
, LPFC_DEF_VFN_PER_PFN
, 0, LPFC_MAX_VFN_PER_PFN
,
4424 "Enable PCIe device SR-IOV virtual fn");
4426 lpfc_param_show(sriov_nr_virtfn
)
4427 static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn
);
4430 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
4432 * @dev: class device that is converted into a Scsi_host.
4433 * @attr: device attribute, not used.
4434 * @buf: containing the string the number of vfs to be enabled.
4435 * @count: unused variable.
4440 * length of the buf on success if val is in range the intended mode
4442 * -EINVAL if val out of range or intended mode is not supported.
4445 lpfc_request_firmware_upgrade_store(struct device
*dev
,
4446 struct device_attribute
*attr
,
4447 const char *buf
, size_t count
)
4449 struct Scsi_Host
*shost
= class_to_shost(dev
);
4450 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4451 struct lpfc_hba
*phba
= vport
->phba
;
4452 int val
= 0, rc
= -EINVAL
;
4454 /* Sanity check on user data */
4455 if (!isdigit(buf
[0]))
4457 if (sscanf(buf
, "%i", &val
) != 1)
4462 rc
= lpfc_sli4_request_firmware_update(phba
, RUN_FW_UPGRADE
);
4470 static int lpfc_req_fw_upgrade
;
4471 module_param(lpfc_req_fw_upgrade
, int, S_IRUGO
|S_IWUSR
);
4472 MODULE_PARM_DESC(lpfc_req_fw_upgrade
, "Enable Linux generic firmware upgrade");
4473 lpfc_param_show(request_firmware_upgrade
)
4476 * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade
4477 * @phba: lpfc_hba pointer.
4481 * Set the initial Linux generic firmware upgrade enable or disable flag.
4484 * zero if val saved.
4485 * -EINVAL val out of range
4488 lpfc_request_firmware_upgrade_init(struct lpfc_hba
*phba
, int val
)
4490 if (val
>= 0 && val
<= 1) {
4491 phba
->cfg_request_firmware_upgrade
= val
;
4496 static DEVICE_ATTR(lpfc_req_fw_upgrade
, S_IRUGO
| S_IWUSR
,
4497 lpfc_request_firmware_upgrade_show
,
4498 lpfc_request_firmware_upgrade_store
);
4501 * lpfc_fcp_imax_store
4503 * @dev: class device that is converted into a Scsi_host.
4504 * @attr: device attribute, not used.
4505 * @buf: string with the number of fast-path FCP interrupts per second.
4506 * @count: unused variable.
4509 * If val is in a valid range [636,651042], then set the adapter's
4510 * maximum number of fast-path FCP interrupts per second.
4513 * length of the buf on success if val is in range the intended mode
4515 * -EINVAL if val out of range or intended mode is not supported.
4518 lpfc_fcp_imax_store(struct device
*dev
, struct device_attribute
*attr
,
4519 const char *buf
, size_t count
)
4521 struct Scsi_Host
*shost
= class_to_shost(dev
);
4522 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4523 struct lpfc_hba
*phba
= vport
->phba
;
4526 /* fcp_imax is only valid for SLI4 */
4527 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
4530 /* Sanity check on user data */
4531 if (!isdigit(buf
[0]))
4533 if (sscanf(buf
, "%i", &val
) != 1)
4537 * Value range for the HBA is [5000,5000000]
4538 * The value for each EQ depends on how many EQs are configured.
4541 if (val
&& (val
< LPFC_MIN_IMAX
|| val
> LPFC_MAX_IMAX
))
4544 phba
->cfg_fcp_imax
= (uint32_t)val
;
4545 phba
->initial_imax
= phba
->cfg_fcp_imax
;
4547 for (i
= 0; i
< phba
->io_channel_irqs
; i
+= LPFC_MAX_EQ_DELAY_EQID_CNT
)
4548 lpfc_modify_hba_eq_delay(phba
, i
, LPFC_MAX_EQ_DELAY_EQID_CNT
,
4555 # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
4558 # Value range is [5,000 to 5,000,000]. Default value is 50,000.
4560 static int lpfc_fcp_imax
= LPFC_DEF_IMAX
;
4561 module_param(lpfc_fcp_imax
, int, S_IRUGO
|S_IWUSR
);
4562 MODULE_PARM_DESC(lpfc_fcp_imax
,
4563 "Set the maximum number of FCP interrupts per second per HBA");
4564 lpfc_param_show(fcp_imax
)
4567 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
4568 * @phba: lpfc_hba pointer.
4569 * @val: link speed value.
4572 * If val is in a valid range [636,651042], then initialize the adapter's
4573 * maximum number of fast-path FCP interrupts per second.
4576 * zero if val saved.
4577 * -EINVAL val out of range
4580 lpfc_fcp_imax_init(struct lpfc_hba
*phba
, int val
)
4582 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4583 phba
->cfg_fcp_imax
= 0;
4587 if ((val
>= LPFC_MIN_IMAX
&& val
<= LPFC_MAX_IMAX
) ||
4589 phba
->cfg_fcp_imax
= val
;
4593 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4594 "3016 lpfc_fcp_imax: %d out of range, using default\n",
4596 phba
->cfg_fcp_imax
= LPFC_DEF_IMAX
;
4601 static DEVICE_ATTR_RW(lpfc_fcp_imax
);
4604 * lpfc_auto_imax: Controls Auto-interrupt coalescing values support.
4605 * 0 No auto_imax support
4607 * Auto imax will change the value of fcp_imax on a per EQ basis, using
4608 * the EQ Delay Multiplier, depending on the activity for that EQ.
4609 * Value range [0,1]. Default value is 1.
4611 LPFC_ATTR_RW(auto_imax
, 1, 0, 1, "Enable Auto imax");
4614 * lpfc_state_show - Display current driver CPU affinity
4615 * @dev: class converted to a Scsi_host structure.
4616 * @attr: device attribute, not used.
4617 * @buf: on return contains text describing the state of the link.
4619 * Returns: size of formatted string.
4622 lpfc_fcp_cpu_map_show(struct device
*dev
, struct device_attribute
*attr
,
4625 struct Scsi_Host
*shost
= class_to_shost(dev
);
4626 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
4627 struct lpfc_hba
*phba
= vport
->phba
;
4628 struct lpfc_vector_map_info
*cpup
;
4631 if ((phba
->sli_rev
!= LPFC_SLI_REV4
) ||
4632 (phba
->intr_type
!= MSIX
))
4635 switch (phba
->cfg_fcp_cpu_map
) {
4637 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4638 "fcp_cpu_map: No mapping (%d)\n",
4639 phba
->cfg_fcp_cpu_map
);
4642 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4643 "fcp_cpu_map: HBA centric mapping (%d): "
4645 phba
->cfg_fcp_cpu_map
,
4646 phba
->sli4_hba
.num_online_cpu
);
4649 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4650 "fcp_cpu_map: Driver centric mapping (%d): "
4652 phba
->cfg_fcp_cpu_map
,
4653 phba
->sli4_hba
.num_online_cpu
);
4657 while (phba
->sli4_hba
.curr_disp_cpu
< phba
->sli4_hba
.num_present_cpu
) {
4658 cpup
= &phba
->sli4_hba
.cpu_map
[phba
->sli4_hba
.curr_disp_cpu
];
4660 /* margin should fit in this and the truncated message */
4661 if (cpup
->irq
== LPFC_VECTOR_MAP_EMPTY
)
4662 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4663 "CPU %02d io_chan %02d "
4664 "physid %d coreid %d\n",
4665 phba
->sli4_hba
.curr_disp_cpu
,
4666 cpup
->channel_id
, cpup
->phys_id
,
4669 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
4670 "CPU %02d io_chan %02d "
4671 "physid %d coreid %d IRQ %d\n",
4672 phba
->sli4_hba
.curr_disp_cpu
,
4673 cpup
->channel_id
, cpup
->phys_id
,
4674 cpup
->core_id
, cpup
->irq
);
4676 phba
->sli4_hba
.curr_disp_cpu
++;
4678 /* display max number of CPUs keeping some margin */
4679 if (phba
->sli4_hba
.curr_disp_cpu
<
4680 phba
->sli4_hba
.num_present_cpu
&&
4681 (len
>= (PAGE_SIZE
- 64))) {
4682 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "more...\n");
4687 if (phba
->sli4_hba
.curr_disp_cpu
== phba
->sli4_hba
.num_present_cpu
)
4688 phba
->sli4_hba
.curr_disp_cpu
= 0;
4694 * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors
4695 * @dev: class device that is converted into a Scsi_host.
4696 * @attr: device attribute, not used.
4697 * @buf: one or more lpfc_polling_flags values.
4701 * -EINVAL - Not implemented yet.
4704 lpfc_fcp_cpu_map_store(struct device
*dev
, struct device_attribute
*attr
,
4705 const char *buf
, size_t count
)
4707 int status
= -EINVAL
;
4712 # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors
4715 # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2).
4716 # 0 - Do not affinitze IRQ vectors
4717 # 1 - Affintize HBA vectors with respect to each HBA
4718 # (start with CPU0 for each HBA)
4719 # 2 - Affintize HBA vectors with respect to the entire driver
4720 # (round robin thru all CPUs across all HBAs)
4722 static int lpfc_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4723 module_param(lpfc_fcp_cpu_map
, int, S_IRUGO
|S_IWUSR
);
4724 MODULE_PARM_DESC(lpfc_fcp_cpu_map
,
4725 "Defines how to map CPUs to IRQ vectors per HBA");
4728 * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable
4729 * @phba: lpfc_hba pointer.
4730 * @val: link speed value.
4733 * If val is in a valid range [0-2], then affinitze the adapter's
4737 * zero if val saved.
4738 * -EINVAL val out of range
4741 lpfc_fcp_cpu_map_init(struct lpfc_hba
*phba
, int val
)
4743 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
4744 phba
->cfg_fcp_cpu_map
= 0;
4748 if (val
>= LPFC_MIN_CPU_MAP
&& val
<= LPFC_MAX_CPU_MAP
) {
4749 phba
->cfg_fcp_cpu_map
= val
;
4753 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
4754 "3326 lpfc_fcp_cpu_map: %d out of range, using "
4756 phba
->cfg_fcp_cpu_map
= LPFC_DRIVER_CPU_MAP
;
4761 static DEVICE_ATTR_RW(lpfc_fcp_cpu_map
);
4764 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
4765 # Value range is [2,3]. Default value is 3.
4767 LPFC_VPORT_ATTR_R(fcp_class
, 3, 2, 3,
4768 "Select Fibre Channel class of service for FCP sequences");
4771 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
4772 # is [0,1]. Default value is 0.
4774 LPFC_VPORT_ATTR_RW(use_adisc
, 0, 0, 1,
4775 "Use ADISC on rediscovery to authenticate FCP devices");
4778 # lpfc_first_burst_size: First burst size to use on the NPorts
4779 # that support first burst.
4780 # Value range is [0,65536]. Default value is 0.
4782 LPFC_VPORT_ATTR_RW(first_burst_size
, 0, 0, 65536,
4783 "First burst size for Targets that support first burst");
4786 * lpfc_nvmet_fb_size: NVME Target mode supported first burst size.
4787 * When the driver is configured as an NVME target, this value is
4788 * communicated to the NVME initiator in the PRLI response. It is
4789 * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support
4790 * parameters are set and the target is sending the PRLI RSP.
4791 * Parameter supported on physical port only - no NPIV support.
4792 * Value range is [0,65536]. Default value is 0.
4794 LPFC_ATTR_RW(nvmet_fb_size
, 0, 0, 65536,
4795 "NVME Target mode first burst size in 512B increments.");
4798 * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
4799 * For the Initiator (I), enabling this parameter means that an NVMET
4800 * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be
4801 * processed by the initiator for subsequent NVME FCP IO. For the target
4802 * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size
4803 * driver parameter as the target function's first burst size returned to the
4804 * initiator in the target's NVME PRLI response. Parameter supported on physical
4805 * port only - no NPIV support.
4806 * Value range is [0,1]. Default value is 0 (disabled).
4808 LPFC_ATTR_RW(nvme_enable_fb
, 0, 0, 1,
4809 "Enable First Burst feature on I and T functions.");
4812 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
4813 # depth. Default value is 0. When the value of this parameter is zero the
4814 # SCSI command completion time is not used for controlling I/O queue depth. When
4815 # the parameter is set to a non-zero value, the I/O queue depth is controlled
4816 # to limit the I/O completion time to the parameter value.
4817 # The value is set in milliseconds.
4819 LPFC_VPORT_ATTR(max_scsicmpl_time
, 0, 0, 60000,
4820 "Use command completion time to control queue depth");
4822 lpfc_vport_param_show(max_scsicmpl_time
);
4824 lpfc_max_scsicmpl_time_set(struct lpfc_vport
*vport
, int val
)
4826 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
4827 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
4829 if (val
== vport
->cfg_max_scsicmpl_time
)
4831 if ((val
< 0) || (val
> 60000))
4833 vport
->cfg_max_scsicmpl_time
= val
;
4835 spin_lock_irq(shost
->host_lock
);
4836 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
4837 if (!NLP_CHK_NODE_ACT(ndlp
))
4839 if (ndlp
->nlp_state
== NLP_STE_UNUSED_NODE
)
4841 ndlp
->cmd_qdepth
= vport
->cfg_tgt_queue_depth
;
4843 spin_unlock_irq(shost
->host_lock
);
4846 lpfc_vport_param_store(max_scsicmpl_time
);
4847 static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time
);
4850 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
4851 # range is [0,1]. Default value is 0.
4853 LPFC_ATTR_R(ack0
, 0, 0, 1, "Enable ACK0 support");
4856 * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds
4857 * range is [0,1]. Default value is 0.
4858 * For [0], FCP commands are issued to Work Queues ina round robin fashion.
4859 * For [1], FCP commands are issued to a Work Queue associated with the
4862 * LPFC_FCP_SCHED_ROUND_ROBIN == 0
4863 * LPFC_FCP_SCHED_BY_CPU == 1
4865 * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu
4866 * affinity for FCP/NVME I/Os through Work Queues associated with the current
4867 * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os
4868 * through WQs will be used.
4870 LPFC_ATTR_RW(fcp_io_sched
, LPFC_FCP_SCHED_ROUND_ROBIN
,
4871 LPFC_FCP_SCHED_ROUND_ROBIN
,
4872 LPFC_FCP_SCHED_BY_CPU
,
4873 "Determine scheduling algorithm for "
4874 "issuing commands [0] - Round Robin, [1] - Current CPU");
4877 # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior
4878 # range is [0,1]. Default value is 0.
4879 # For [0], bus reset issues target reset to ALL devices
4880 # For [1], bus reset issues target reset to non-FCP2 devices
4882 LPFC_ATTR_RW(fcp2_no_tgt_reset
, 0, 0, 1, "Determine bus reset behavior for "
4883 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
4887 # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
4888 # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
4889 # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
4890 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
4891 # cr_delay is set to 0.
4893 LPFC_ATTR_RW(cr_delay
, 0, 0, 63, "A count of milliseconds after which an "
4894 "interrupt response is generated");
4896 LPFC_ATTR_RW(cr_count
, 1, 1, 255, "A count of I/O completions after which an "
4897 "interrupt response is generated");
4900 # lpfc_multi_ring_support: Determines how many rings to spread available
4901 # cmd/rsp IOCB entries across.
4902 # Value range is [1,2]. Default value is 1.
4904 LPFC_ATTR_R(multi_ring_support
, 1, 1, 2, "Determines number of primary "
4905 "SLI rings to spread IOCB entries across");
4908 # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
4909 # identifies what rctl value to configure the additional ring for.
4910 # Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
4912 LPFC_ATTR_R(multi_ring_rctl
, FC_RCTL_DD_UNSOL_DATA
, 1,
4913 255, "Identifies RCTL for additional ring configuration");
4916 # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
4917 # identifies what type value to configure the additional ring for.
4918 # Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
4920 LPFC_ATTR_R(multi_ring_type
, FC_TYPE_IP
, 1,
4921 255, "Identifies TYPE for additional ring configuration");
4924 # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN
4925 # 0 = SmartSAN functionality disabled (default)
4926 # 1 = SmartSAN functionality enabled
4927 # This parameter will override the value of lpfc_fdmi_on module parameter.
4928 # Value range is [0,1]. Default value is 0.
4930 LPFC_ATTR_R(enable_SmartSAN
, 0, 0, 1, "Enable SmartSAN functionality");
4933 # lpfc_fdmi_on: Controls FDMI support.
4934 # 0 No FDMI support (default)
4935 # 1 Traditional FDMI support
4936 # Traditional FDMI support means the driver will assume FDMI-2 support;
4937 # however, if that fails, it will fallback to FDMI-1.
4938 # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on.
4939 # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of
4941 # Value range [0,1]. Default value is 0.
4943 LPFC_ATTR_R(fdmi_on
, 0, 0, 1, "Enable FDMI support");
4946 # Specifies the maximum number of ELS cmds we can have outstanding (for
4947 # discovery). Value range is [1,64]. Default value = 32.
4949 LPFC_VPORT_ATTR(discovery_threads
, 32, 1, 64, "Maximum number of ELS commands "
4950 "during discovery");
4953 # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that
4954 # will be scanned by the SCSI midlayer when sequential scanning is
4955 # used; and is also the highest LUN ID allowed when the SCSI midlayer
4956 # parses REPORT_LUN responses. The lpfc driver has no LUN count or
4957 # LUN ID limit, but the SCSI midlayer requires this field for the uses
4958 # above. The lpfc driver limits the default value to 255 for two reasons.
4959 # As it bounds the sequential scan loop, scanning for thousands of luns
4960 # on a target can take minutes of wall clock time. Additionally,
4961 # there are FC targets, such as JBODs, that only recognize 8-bits of
4962 # LUN ID. When they receive a value greater than 8 bits, they chop off
4963 # the high order bits. In other words, they see LUN IDs 0, 256, 512,
4964 # and so on all as LUN ID 0. This causes the linux kernel, which sees
4965 # valid responses at each of the LUN IDs, to believe there are multiple
4966 # devices present, when in fact, there is only 1.
4967 # A customer that is aware of their target behaviors, and the results as
4968 # indicated above, is welcome to increase the lpfc_max_luns value.
4969 # As mentioned, this value is not used by the lpfc driver, only the
4971 # Value range is [0,65535]. Default value is 255.
4972 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
4974 LPFC_VPORT_ULL_ATTR_R(max_luns
, 255, 0, 65535, "Maximum allowed LUN ID");
4977 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
4978 # Value range is [1,255], default value is 10.
4980 LPFC_ATTR_RW(poll_tmo
, 10, 1, 255,
4981 "Milliseconds driver will wait between polling FCP ring");
4984 # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands
4985 # to complete in seconds. Value range is [5,180], default value is 60.
4987 LPFC_ATTR_RW(task_mgmt_tmo
, 60, 5, 180,
4988 "Maximum time to wait for task management commands to complete");
4990 # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
4991 # support this feature
4994 # 2 = MSI-X enabled (default)
4995 # Value range is [0,2]. Default value is 2.
4997 LPFC_ATTR_R(use_msi
, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
4998 "MSI-X (2), if possible");
5001 * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs
5003 * 0 = NVME OAS disabled
5004 * 1 = NVME OAS enabled
5006 * Value range is [0,1]. Default value is 0.
5008 LPFC_ATTR_RW(nvme_oas
, 0, 0, 1,
5009 "Use OAS bit on NVME IOs");
5012 * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver
5013 * will advertise it supports to the SCSI layer. This also will map to
5014 * the number of WQs the driver will create.
5016 * 0 = Configure the number of io channels to the number of active CPUs.
5017 * 1,32 = Manually specify how many io channels to use.
5019 * Value range is [0,32]. Default value is 4.
5021 LPFC_ATTR_R(fcp_io_channel
,
5022 LPFC_FCP_IO_CHAN_DEF
,
5023 LPFC_HBA_IO_CHAN_MIN
, LPFC_HBA_IO_CHAN_MAX
,
5024 "Set the number of FCP I/O channels");
5027 * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver
5028 * will advertise it supports to the NVME layer. This also will map to
5029 * the number of WQs the driver will create.
5031 * This module parameter is valid when lpfc_enable_fc4_type is set
5034 * The NVME Layer will try to create this many, plus 1 administrative
5035 * hardware queue. The administrative queue will always map to WQ 0
5036 * A hardware IO queue maps (qidx) to a specific driver WQ.
5038 * 0 = Configure the number of io channels to the number of active CPUs.
5039 * 1,32 = Manually specify how many io channels to use.
5041 * Value range is [0,32]. Default value is 0.
5043 LPFC_ATTR_R(nvme_io_channel
,
5044 LPFC_NVME_IO_CHAN_DEF
,
5045 LPFC_HBA_IO_CHAN_MIN
, LPFC_HBA_IO_CHAN_MAX
,
5046 "Set the number of NVME I/O channels");
5049 # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
5050 # 0 = HBA resets disabled
5051 # 1 = HBA resets enabled (default)
5052 # Value range is [0,1]. Default value is 1.
5054 LPFC_ATTR_R(enable_hba_reset
, 1, 0, 1, "Enable HBA resets from the driver.");
5057 # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer..
5058 # 0 = HBA Heartbeat disabled
5059 # 1 = HBA Heartbeat enabled (default)
5060 # Value range is [0,1]. Default value is 1.
5062 LPFC_ATTR_R(enable_hba_heartbeat
, 0, 0, 1, "Enable HBA Heartbeat.");
5065 # lpfc_EnableXLane: Enable Express Lane Feature
5066 # 0x0 Express Lane Feature disabled
5067 # 0x1 Express Lane Feature enabled
5068 # Value range is [0,1]. Default value is 0.
5070 LPFC_ATTR_R(EnableXLane
, 0, 0, 1, "Enable Express Lane Feature.");
5073 # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature
5074 # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits)
5075 # Value range is [0x0,0x7f]. Default value is 0
5077 LPFC_ATTR_RW(XLanePriority
, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
5080 # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
5081 # 0 = BlockGuard disabled (default)
5082 # 1 = BlockGuard enabled
5083 # Value range is [0,1]. Default value is 0.
5085 LPFC_ATTR_R(enable_bg
, 0, 0, 1, "Enable BlockGuard Support");
5088 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
5089 # 0 = disabled (default)
5091 # Value range is [0,1]. Default value is 0.
5093 # This feature in under investigation and may be supported in the future.
5095 unsigned int lpfc_fcp_look_ahead
= LPFC_LOOK_AHEAD_OFF
;
5099 # - Bit mask of host protection capabilities used to register with the
5101 # - Only meaningful if BG is turned on (lpfc_enable_bg=1).
5102 # - Allows you to ultimately specify which profiles to use
5103 # - Default will result in registering capabilities for all profiles.
5104 # - SHOST_DIF_TYPE1_PROTECTION 1
5105 # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection
5106 # - SHOST_DIX_TYPE0_PROTECTION 8
5107 # HBA supports DIX Type 0: Host to HBA protection only
5108 # - SHOST_DIX_TYPE1_PROTECTION 16
5109 # HBA supports DIX Type 1: Host to HBA Type 1 protection
5112 LPFC_ATTR(prot_mask
,
5113 (SHOST_DIF_TYPE1_PROTECTION
|
5114 SHOST_DIX_TYPE0_PROTECTION
|
5115 SHOST_DIX_TYPE1_PROTECTION
),
5117 (SHOST_DIF_TYPE1_PROTECTION
|
5118 SHOST_DIX_TYPE0_PROTECTION
|
5119 SHOST_DIX_TYPE1_PROTECTION
),
5120 "T10-DIF host protection capabilities mask");
5123 # lpfc_prot_guard: i
5124 # - Bit mask of protection guard types to register with the SCSI mid-layer
5125 # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum
5126 # - Allows you to ultimately specify which profiles to use
5127 # - Default will result in registering capabilities for all guard types
5130 LPFC_ATTR(prot_guard
,
5131 SHOST_DIX_GUARD_IP
, SHOST_DIX_GUARD_CRC
, SHOST_DIX_GUARD_IP
,
5132 "T10-DIF host protection guard type");
5135 * Delay initial NPort discovery when Clean Address bit is cleared in
5136 * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed.
5137 * This parameter can have value 0 or 1.
5138 * When this parameter is set to 0, no delay is added to the initial
5140 * When this parameter is set to non-zero value, initial Nport discovery is
5141 * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC
5142 * accept and FCID/Fabric name/Fabric portname is changed.
5143 * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion
5144 * when Clean Address bit is cleared in FLOGI/FDISC
5145 * accept and FCID/Fabric name/Fabric portname is changed.
5146 * Default value is 0.
5148 LPFC_ATTR(delay_discovery
, 0, 0, 1,
5149 "Delay NPort discovery when Clean Address bit is cleared.");
5152 * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count
5153 * This value can be set to values between 64 and 4096. The default value is
5154 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
5155 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
5156 * Because of the additional overhead involved in setting up T10-DIF,
5157 * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
5158 * and will be limited to 512 if BlockGuard is enabled under SLI3.
5160 LPFC_ATTR_R(sg_seg_cnt
, LPFC_DEFAULT_SG_SEG_CNT
, LPFC_MIN_SG_SEG_CNT
,
5161 LPFC_MAX_SG_SEG_CNT
, "Max Scatter Gather Segment Count");
5164 * lpfc_enable_mds_diags: Enable MDS Diagnostics
5165 * 0 = MDS Diagnostics disabled (default)
5166 * 1 = MDS Diagnostics enabled
5167 * Value range is [0,1]. Default value is 0.
5169 LPFC_ATTR_R(enable_mds_diags
, 0, 0, 1, "Enable MDS Diagnostics");
5172 * lpfc_enable_bbcr: Enable BB Credit Recovery
5173 * 0 = BB Credit Recovery disabled
5174 * 1 = BB Credit Recovery enabled (default)
5175 * Value range is [0,1]. Default value is 1.
5177 LPFC_BBCR_ATTR_RW(enable_bbcr
, 1, 0, 1, "Enable BBC Recovery");
5179 struct device_attribute
*lpfc_hba_attrs
[] = {
5180 &dev_attr_nvme_info
,
5182 &dev_attr_bg_guard_err
,
5183 &dev_attr_bg_apptag_err
,
5184 &dev_attr_bg_reftag_err
,
5186 &dev_attr_serialnum
,
5187 &dev_attr_modeldesc
,
5188 &dev_attr_modelname
,
5189 &dev_attr_programtype
,
5193 &dev_attr_option_rom_version
,
5194 &dev_attr_link_state
,
5195 &dev_attr_num_discovered_ports
,
5196 &dev_attr_menlo_mgmt_mode
,
5197 &dev_attr_lpfc_drvr_version
,
5198 &dev_attr_lpfc_enable_fip
,
5199 &dev_attr_lpfc_temp_sensor
,
5200 &dev_attr_lpfc_log_verbose
,
5201 &dev_attr_lpfc_lun_queue_depth
,
5202 &dev_attr_lpfc_tgt_queue_depth
,
5203 &dev_attr_lpfc_hba_queue_depth
,
5204 &dev_attr_lpfc_peer_port_login
,
5205 &dev_attr_lpfc_nodev_tmo
,
5206 &dev_attr_lpfc_devloss_tmo
,
5207 &dev_attr_lpfc_enable_fc4_type
,
5208 &dev_attr_lpfc_xri_split
,
5209 &dev_attr_lpfc_fcp_class
,
5210 &dev_attr_lpfc_use_adisc
,
5211 &dev_attr_lpfc_first_burst_size
,
5212 &dev_attr_lpfc_ack0
,
5213 &dev_attr_lpfc_topology
,
5214 &dev_attr_lpfc_scan_down
,
5215 &dev_attr_lpfc_link_speed
,
5216 &dev_attr_lpfc_fcp_io_sched
,
5217 &dev_attr_lpfc_fcp2_no_tgt_reset
,
5218 &dev_attr_lpfc_cr_delay
,
5219 &dev_attr_lpfc_cr_count
,
5220 &dev_attr_lpfc_multi_ring_support
,
5221 &dev_attr_lpfc_multi_ring_rctl
,
5222 &dev_attr_lpfc_multi_ring_type
,
5223 &dev_attr_lpfc_fdmi_on
,
5224 &dev_attr_lpfc_enable_SmartSAN
,
5225 &dev_attr_lpfc_max_luns
,
5226 &dev_attr_lpfc_enable_npiv
,
5227 &dev_attr_lpfc_fcf_failover_policy
,
5228 &dev_attr_lpfc_enable_rrq
,
5229 &dev_attr_nport_evt_cnt
,
5230 &dev_attr_board_mode
,
5237 &dev_attr_npiv_info
,
5238 &dev_attr_issue_reset
,
5239 &dev_attr_lpfc_poll
,
5240 &dev_attr_lpfc_poll_tmo
,
5241 &dev_attr_lpfc_task_mgmt_tmo
,
5242 &dev_attr_lpfc_use_msi
,
5243 &dev_attr_lpfc_nvme_oas
,
5244 &dev_attr_lpfc_auto_imax
,
5245 &dev_attr_lpfc_fcp_imax
,
5246 &dev_attr_lpfc_fcp_cpu_map
,
5247 &dev_attr_lpfc_fcp_io_channel
,
5248 &dev_attr_lpfc_suppress_rsp
,
5249 &dev_attr_lpfc_nvme_io_channel
,
5250 &dev_attr_lpfc_nvmet_mrq
,
5251 &dev_attr_lpfc_nvme_enable_fb
,
5252 &dev_attr_lpfc_nvmet_fb_size
,
5253 &dev_attr_lpfc_enable_bg
,
5254 &dev_attr_lpfc_soft_wwnn
,
5255 &dev_attr_lpfc_soft_wwpn
,
5256 &dev_attr_lpfc_soft_wwn_enable
,
5257 &dev_attr_lpfc_enable_hba_reset
,
5258 &dev_attr_lpfc_enable_hba_heartbeat
,
5259 &dev_attr_lpfc_EnableXLane
,
5260 &dev_attr_lpfc_XLanePriority
,
5261 &dev_attr_lpfc_xlane_lun
,
5262 &dev_attr_lpfc_xlane_tgt
,
5263 &dev_attr_lpfc_xlane_vpt
,
5264 &dev_attr_lpfc_xlane_lun_state
,
5265 &dev_attr_lpfc_xlane_lun_status
,
5266 &dev_attr_lpfc_xlane_priority
,
5267 &dev_attr_lpfc_sg_seg_cnt
,
5268 &dev_attr_lpfc_max_scsicmpl_time
,
5269 &dev_attr_lpfc_stat_data_ctrl
,
5270 &dev_attr_lpfc_aer_support
,
5271 &dev_attr_lpfc_aer_state_cleanup
,
5272 &dev_attr_lpfc_sriov_nr_virtfn
,
5273 &dev_attr_lpfc_req_fw_upgrade
,
5274 &dev_attr_lpfc_suppress_link_up
,
5275 &dev_attr_lpfc_iocb_cnt
,
5278 &dev_attr_txcmplq_hw
,
5279 &dev_attr_lpfc_fips_level
,
5280 &dev_attr_lpfc_fips_rev
,
5282 &dev_attr_lpfc_sriov_hw_max_virtfn
,
5284 &dev_attr_lpfc_xlane_supported
,
5285 &dev_attr_lpfc_enable_mds_diags
,
5286 &dev_attr_lpfc_enable_bbcr
,
5290 struct device_attribute
*lpfc_vport_attrs
[] = {
5292 &dev_attr_link_state
,
5293 &dev_attr_num_discovered_ports
,
5294 &dev_attr_lpfc_drvr_version
,
5295 &dev_attr_lpfc_log_verbose
,
5296 &dev_attr_lpfc_lun_queue_depth
,
5297 &dev_attr_lpfc_tgt_queue_depth
,
5298 &dev_attr_lpfc_nodev_tmo
,
5299 &dev_attr_lpfc_devloss_tmo
,
5300 &dev_attr_lpfc_hba_queue_depth
,
5301 &dev_attr_lpfc_peer_port_login
,
5302 &dev_attr_lpfc_restrict_login
,
5303 &dev_attr_lpfc_fcp_class
,
5304 &dev_attr_lpfc_use_adisc
,
5305 &dev_attr_lpfc_first_burst_size
,
5306 &dev_attr_lpfc_max_luns
,
5307 &dev_attr_nport_evt_cnt
,
5308 &dev_attr_npiv_info
,
5309 &dev_attr_lpfc_enable_da_id
,
5310 &dev_attr_lpfc_max_scsicmpl_time
,
5311 &dev_attr_lpfc_stat_data_ctrl
,
5312 &dev_attr_lpfc_static_vport
,
5313 &dev_attr_lpfc_fips_level
,
5314 &dev_attr_lpfc_fips_rev
,
5319 * sysfs_ctlreg_write - Write method for writing to ctlreg
5320 * @filp: open sysfs file
5321 * @kobj: kernel kobject that contains the kernel class device.
5322 * @bin_attr: kernel attributes passed to us.
5323 * @buf: contains the data to be written to the adapter IOREG space.
5324 * @off: offset into buffer to beginning of data.
5325 * @count: bytes to transfer.
5328 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5329 * Uses the adapter io control registers to send buf contents to the adapter.
5332 * -ERANGE off and count combo out of range
5333 * -EINVAL off, count or buff address invalid
5334 * -EPERM adapter is offline
5335 * value of count, buf contents written
5338 sysfs_ctlreg_write(struct file
*filp
, struct kobject
*kobj
,
5339 struct bin_attribute
*bin_attr
,
5340 char *buf
, loff_t off
, size_t count
)
5343 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
5344 struct Scsi_Host
*shost
= class_to_shost(dev
);
5345 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5346 struct lpfc_hba
*phba
= vport
->phba
;
5348 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5351 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5354 if (count
<= LPFC_REG_WRITE_KEY_SIZE
)
5357 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5360 /* This is to protect HBA registers from accidental writes. */
5361 if (memcmp(buf
, LPFC_REG_WRITE_KEY
, LPFC_REG_WRITE_KEY_SIZE
))
5364 if (!(vport
->fc_flag
& FC_OFFLINE_MODE
))
5367 spin_lock_irq(&phba
->hbalock
);
5368 for (buf_off
= 0; buf_off
< count
- LPFC_REG_WRITE_KEY_SIZE
;
5369 buf_off
+= sizeof(uint32_t))
5370 writel(*((uint32_t *)(buf
+ buf_off
+ LPFC_REG_WRITE_KEY_SIZE
)),
5371 phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5373 spin_unlock_irq(&phba
->hbalock
);
5379 * sysfs_ctlreg_read - Read method for reading from ctlreg
5380 * @filp: open sysfs file
5381 * @kobj: kernel kobject that contains the kernel class device.
5382 * @bin_attr: kernel attributes passed to us.
5383 * @buf: if successful contains the data from the adapter IOREG space.
5384 * @off: offset into buffer to beginning of data.
5385 * @count: bytes to transfer.
5388 * Accessed via /sys/class/scsi_host/hostxxx/ctlreg.
5389 * Uses the adapter io control registers to read data into buf.
5392 * -ERANGE off and count combo out of range
5393 * -EINVAL off, count or buff address invalid
5394 * value of count, buf contents read
5397 sysfs_ctlreg_read(struct file
*filp
, struct kobject
*kobj
,
5398 struct bin_attribute
*bin_attr
,
5399 char *buf
, loff_t off
, size_t count
)
5403 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
5404 struct Scsi_Host
*shost
= class_to_shost(dev
);
5405 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5406 struct lpfc_hba
*phba
= vport
->phba
;
5408 if (phba
->sli_rev
>= LPFC_SLI_REV4
)
5411 if (off
> FF_REG_AREA_SIZE
)
5414 if ((off
+ count
) > FF_REG_AREA_SIZE
)
5415 count
= FF_REG_AREA_SIZE
- off
;
5417 if (count
== 0) return 0;
5419 if (off
% 4 || count
% 4 || (unsigned long)buf
% 4)
5422 spin_lock_irq(&phba
->hbalock
);
5424 for (buf_off
= 0; buf_off
< count
; buf_off
+= sizeof(uint32_t)) {
5425 tmp_ptr
= (uint32_t *)(buf
+ buf_off
);
5426 *tmp_ptr
= readl(phba
->ctrl_regs_memmap_p
+ off
+ buf_off
);
5429 spin_unlock_irq(&phba
->hbalock
);
5434 static struct bin_attribute sysfs_ctlreg_attr
= {
5437 .mode
= S_IRUSR
| S_IWUSR
,
5440 .read
= sysfs_ctlreg_read
,
5441 .write
= sysfs_ctlreg_write
,
5445 * sysfs_mbox_write - Write method for writing information via mbox
5446 * @filp: open sysfs file
5447 * @kobj: kernel kobject that contains the kernel class device.
5448 * @bin_attr: kernel attributes passed to us.
5449 * @buf: contains the data to be written to sysfs mbox.
5450 * @off: offset into buffer to beginning of data.
5451 * @count: bytes to transfer.
5454 * Deprecated function. All mailbox access from user space is performed via the
5458 * -EPERM operation not permitted
5461 sysfs_mbox_write(struct file
*filp
, struct kobject
*kobj
,
5462 struct bin_attribute
*bin_attr
,
5463 char *buf
, loff_t off
, size_t count
)
5469 * sysfs_mbox_read - Read method for reading information via mbox
5470 * @filp: open sysfs file
5471 * @kobj: kernel kobject that contains the kernel class device.
5472 * @bin_attr: kernel attributes passed to us.
5473 * @buf: contains the data to be read from sysfs mbox.
5474 * @off: offset into buffer to beginning of data.
5475 * @count: bytes to transfer.
5478 * Deprecated function. All mailbox access from user space is performed via the
5482 * -EPERM operation not permitted
5485 sysfs_mbox_read(struct file
*filp
, struct kobject
*kobj
,
5486 struct bin_attribute
*bin_attr
,
5487 char *buf
, loff_t off
, size_t count
)
5492 static struct bin_attribute sysfs_mbox_attr
= {
5495 .mode
= S_IRUSR
| S_IWUSR
,
5497 .size
= MAILBOX_SYSFS_MAX
,
5498 .read
= sysfs_mbox_read
,
5499 .write
= sysfs_mbox_write
,
5503 * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries
5504 * @vport: address of lpfc vport structure.
5508 * error return code from sysfs_create_bin_file()
5511 lpfc_alloc_sysfs_attr(struct lpfc_vport
*vport
)
5513 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5516 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5517 &sysfs_drvr_stat_data_attr
);
5519 /* Virtual ports do not need ctrl_reg and mbox */
5520 if (error
|| vport
->port_type
== LPFC_NPIV_PORT
)
5523 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5524 &sysfs_ctlreg_attr
);
5526 goto out_remove_stat_attr
;
5528 error
= sysfs_create_bin_file(&shost
->shost_dev
.kobj
,
5531 goto out_remove_ctlreg_attr
;
5534 out_remove_ctlreg_attr
:
5535 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5536 out_remove_stat_attr
:
5537 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5538 &sysfs_drvr_stat_data_attr
);
5544 * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries
5545 * @vport: address of lpfc vport structure.
5548 lpfc_free_sysfs_attr(struct lpfc_vport
*vport
)
5550 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
5551 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
,
5552 &sysfs_drvr_stat_data_attr
);
5553 /* Virtual ports do not need ctrl_reg and mbox */
5554 if (vport
->port_type
== LPFC_NPIV_PORT
)
5556 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_mbox_attr
);
5557 sysfs_remove_bin_file(&shost
->shost_dev
.kobj
, &sysfs_ctlreg_attr
);
5561 * Dynamic FC Host Attributes Support
5565 * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host
5566 * @shost: kernel scsi host pointer.
5569 lpfc_get_host_symbolic_name(struct Scsi_Host
*shost
)
5571 struct lpfc_vport
*vport
= (struct lpfc_vport
*)shost
->hostdata
;
5573 lpfc_vport_symbolic_node_name(vport
, fc_host_symbolic_name(shost
),
5574 sizeof fc_host_symbolic_name(shost
));
5578 * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id
5579 * @shost: kernel scsi host pointer.
5582 lpfc_get_host_port_id(struct Scsi_Host
*shost
)
5584 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5586 /* note: fc_myDID already in cpu endianness */
5587 fc_host_port_id(shost
) = vport
->fc_myDID
;
5591 * lpfc_get_host_port_type - Set the value of the scsi host port type
5592 * @shost: kernel scsi host pointer.
5595 lpfc_get_host_port_type(struct Scsi_Host
*shost
)
5597 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5598 struct lpfc_hba
*phba
= vport
->phba
;
5600 spin_lock_irq(shost
->host_lock
);
5602 if (vport
->port_type
== LPFC_NPIV_PORT
) {
5603 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
5604 } else if (lpfc_is_link_up(phba
)) {
5605 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5606 if (vport
->fc_flag
& FC_PUBLIC_LOOP
)
5607 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
5609 fc_host_port_type(shost
) = FC_PORTTYPE_LPORT
;
5611 if (vport
->fc_flag
& FC_FABRIC
)
5612 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
5614 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
5617 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
5619 spin_unlock_irq(shost
->host_lock
);
5623 * lpfc_get_host_port_state - Set the value of the scsi host port state
5624 * @shost: kernel scsi host pointer.
5627 lpfc_get_host_port_state(struct Scsi_Host
*shost
)
5629 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5630 struct lpfc_hba
*phba
= vport
->phba
;
5632 spin_lock_irq(shost
->host_lock
);
5634 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5635 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
5637 switch (phba
->link_state
) {
5638 case LPFC_LINK_UNKNOWN
:
5639 case LPFC_LINK_DOWN
:
5640 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
5644 case LPFC_HBA_READY
:
5645 /* Links up, reports port state accordingly */
5646 if (vport
->port_state
< LPFC_VPORT_READY
)
5647 fc_host_port_state(shost
) =
5648 FC_PORTSTATE_BYPASSED
;
5650 fc_host_port_state(shost
) =
5651 FC_PORTSTATE_ONLINE
;
5653 case LPFC_HBA_ERROR
:
5654 fc_host_port_state(shost
) = FC_PORTSTATE_ERROR
;
5657 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
5662 spin_unlock_irq(shost
->host_lock
);
5666 * lpfc_get_host_speed - Set the value of the scsi host speed
5667 * @shost: kernel scsi host pointer.
5670 lpfc_get_host_speed(struct Scsi_Host
*shost
)
5672 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5673 struct lpfc_hba
*phba
= vport
->phba
;
5675 spin_lock_irq(shost
->host_lock
);
5677 if ((lpfc_is_link_up(phba
)) && (!(phba
->hba_flag
& HBA_FCOE_MODE
))) {
5678 switch(phba
->fc_linkspeed
) {
5679 case LPFC_LINK_SPEED_1GHZ
:
5680 fc_host_speed(shost
) = FC_PORTSPEED_1GBIT
;
5682 case LPFC_LINK_SPEED_2GHZ
:
5683 fc_host_speed(shost
) = FC_PORTSPEED_2GBIT
;
5685 case LPFC_LINK_SPEED_4GHZ
:
5686 fc_host_speed(shost
) = FC_PORTSPEED_4GBIT
;
5688 case LPFC_LINK_SPEED_8GHZ
:
5689 fc_host_speed(shost
) = FC_PORTSPEED_8GBIT
;
5691 case LPFC_LINK_SPEED_10GHZ
:
5692 fc_host_speed(shost
) = FC_PORTSPEED_10GBIT
;
5694 case LPFC_LINK_SPEED_16GHZ
:
5695 fc_host_speed(shost
) = FC_PORTSPEED_16GBIT
;
5697 case LPFC_LINK_SPEED_32GHZ
:
5698 fc_host_speed(shost
) = FC_PORTSPEED_32GBIT
;
5701 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5705 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
5707 spin_unlock_irq(shost
->host_lock
);
5711 * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name
5712 * @shost: kernel scsi host pointer.
5715 lpfc_get_host_fabric_name (struct Scsi_Host
*shost
)
5717 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5718 struct lpfc_hba
*phba
= vport
->phba
;
5721 spin_lock_irq(shost
->host_lock
);
5723 if ((vport
->port_state
> LPFC_FLOGI
) &&
5724 ((vport
->fc_flag
& FC_FABRIC
) ||
5725 ((phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) &&
5726 (vport
->fc_flag
& FC_PUBLIC_LOOP
))))
5727 node_name
= wwn_to_u64(phba
->fc_fabparam
.nodeName
.u
.wwn
);
5729 /* fabric is local port if there is no F/FL_Port */
5732 spin_unlock_irq(shost
->host_lock
);
5734 fc_host_fabric_name(shost
) = node_name
;
5738 * lpfc_get_stats - Return statistical information about the adapter
5739 * @shost: kernel scsi host pointer.
5742 * NULL on error for link down, no mbox pool, sli2 active,
5743 * management not allowed, memory allocation error, or mbox error.
5747 * address of the adapter host statistics
5749 static struct fc_host_statistics
*
5750 lpfc_get_stats(struct Scsi_Host
*shost
)
5752 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5753 struct lpfc_hba
*phba
= vport
->phba
;
5754 struct lpfc_sli
*psli
= &phba
->sli
;
5755 struct fc_host_statistics
*hs
= &phba
->link_stats
;
5756 struct lpfc_lnk_stat
* lso
= &psli
->lnk_stat_offsets
;
5757 LPFC_MBOXQ_t
*pmboxq
;
5759 unsigned long seconds
;
5763 * prevent udev from issuing mailbox commands until the port is
5766 if (phba
->link_state
< LPFC_LINK_DOWN
||
5767 !phba
->mbox_mem_pool
||
5768 (phba
->sli
.sli_flag
& LPFC_SLI_ACTIVE
) == 0)
5771 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5774 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5777 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5779 pmb
= &pmboxq
->u
.mb
;
5780 pmb
->mbxCommand
= MBX_READ_STATUS
;
5781 pmb
->mbxOwner
= OWN_HOST
;
5782 pmboxq
->context1
= NULL
;
5783 pmboxq
->vport
= vport
;
5785 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5786 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5788 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5790 if (rc
!= MBX_SUCCESS
) {
5791 if (rc
!= MBX_TIMEOUT
)
5792 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5796 memset(hs
, 0, sizeof (struct fc_host_statistics
));
5798 hs
->tx_frames
= pmb
->un
.varRdStatus
.xmitFrameCnt
;
5800 * The MBX_READ_STATUS returns tx_k_bytes which has to
5801 * converted to words
5803 hs
->tx_words
= (uint64_t)
5804 ((uint64_t)pmb
->un
.varRdStatus
.xmitByteCnt
5806 hs
->rx_frames
= pmb
->un
.varRdStatus
.rcvFrameCnt
;
5807 hs
->rx_words
= (uint64_t)
5808 ((uint64_t)pmb
->un
.varRdStatus
.rcvByteCnt
5811 memset(pmboxq
, 0, sizeof (LPFC_MBOXQ_t
));
5812 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5813 pmb
->mbxOwner
= OWN_HOST
;
5814 pmboxq
->context1
= NULL
;
5815 pmboxq
->vport
= vport
;
5817 if (vport
->fc_flag
& FC_OFFLINE_MODE
)
5818 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5820 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5822 if (rc
!= MBX_SUCCESS
) {
5823 if (rc
!= MBX_TIMEOUT
)
5824 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5828 hs
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5829 hs
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5830 hs
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5831 hs
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5832 hs
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5833 hs
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5834 hs
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5836 hs
->link_failure_count
-= lso
->link_failure_count
;
5837 hs
->loss_of_sync_count
-= lso
->loss_of_sync_count
;
5838 hs
->loss_of_signal_count
-= lso
->loss_of_signal_count
;
5839 hs
->prim_seq_protocol_err_count
-= lso
->prim_seq_protocol_err_count
;
5840 hs
->invalid_tx_word_count
-= lso
->invalid_tx_word_count
;
5841 hs
->invalid_crc_count
-= lso
->invalid_crc_count
;
5842 hs
->error_frames
-= lso
->error_frames
;
5844 if (phba
->hba_flag
& HBA_FCOE_MODE
) {
5846 hs
->nos_count
= (phba
->link_events
>> 1);
5847 hs
->nos_count
-= lso
->link_events
;
5848 } else if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
) {
5849 hs
->lip_count
= (phba
->fc_eventTag
>> 1);
5850 hs
->lip_count
-= lso
->link_events
;
5854 hs
->nos_count
= (phba
->fc_eventTag
>> 1);
5855 hs
->nos_count
-= lso
->link_events
;
5858 hs
->dumped_frames
= -1;
5860 seconds
= get_seconds();
5861 if (seconds
< psli
->stats_start
)
5862 hs
->seconds_since_last_reset
= seconds
+
5863 ((unsigned long)-1 - psli
->stats_start
);
5865 hs
->seconds_since_last_reset
= seconds
- psli
->stats_start
;
5867 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5873 * lpfc_reset_stats - Copy the adapter link stats information
5874 * @shost: kernel scsi host pointer.
5877 lpfc_reset_stats(struct Scsi_Host
*shost
)
5879 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5880 struct lpfc_hba
*phba
= vport
->phba
;
5881 struct lpfc_sli
*psli
= &phba
->sli
;
5882 struct lpfc_lnk_stat
*lso
= &psli
->lnk_stat_offsets
;
5883 LPFC_MBOXQ_t
*pmboxq
;
5887 if (phba
->sli
.sli_flag
& LPFC_BLOCK_MGMT_IO
)
5890 pmboxq
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
5893 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5895 pmb
= &pmboxq
->u
.mb
;
5896 pmb
->mbxCommand
= MBX_READ_STATUS
;
5897 pmb
->mbxOwner
= OWN_HOST
;
5898 pmb
->un
.varWords
[0] = 0x1; /* reset request */
5899 pmboxq
->context1
= NULL
;
5900 pmboxq
->vport
= vport
;
5902 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5903 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5904 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5906 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5908 if (rc
!= MBX_SUCCESS
) {
5909 if (rc
!= MBX_TIMEOUT
)
5910 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5914 memset(pmboxq
, 0, sizeof(LPFC_MBOXQ_t
));
5915 pmb
->mbxCommand
= MBX_READ_LNK_STAT
;
5916 pmb
->mbxOwner
= OWN_HOST
;
5917 pmboxq
->context1
= NULL
;
5918 pmboxq
->vport
= vport
;
5920 if ((vport
->fc_flag
& FC_OFFLINE_MODE
) ||
5921 (!(psli
->sli_flag
& LPFC_SLI_ACTIVE
)))
5922 rc
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_POLL
);
5924 rc
= lpfc_sli_issue_mbox_wait(phba
, pmboxq
, phba
->fc_ratov
* 2);
5926 if (rc
!= MBX_SUCCESS
) {
5927 if (rc
!= MBX_TIMEOUT
)
5928 mempool_free( pmboxq
, phba
->mbox_mem_pool
);
5932 lso
->link_failure_count
= pmb
->un
.varRdLnk
.linkFailureCnt
;
5933 lso
->loss_of_sync_count
= pmb
->un
.varRdLnk
.lossSyncCnt
;
5934 lso
->loss_of_signal_count
= pmb
->un
.varRdLnk
.lossSignalCnt
;
5935 lso
->prim_seq_protocol_err_count
= pmb
->un
.varRdLnk
.primSeqErrCnt
;
5936 lso
->invalid_tx_word_count
= pmb
->un
.varRdLnk
.invalidXmitWord
;
5937 lso
->invalid_crc_count
= pmb
->un
.varRdLnk
.crcCnt
;
5938 lso
->error_frames
= pmb
->un
.varRdLnk
.crcCnt
;
5939 if (phba
->hba_flag
& HBA_FCOE_MODE
)
5940 lso
->link_events
= (phba
->link_events
>> 1);
5942 lso
->link_events
= (phba
->fc_eventTag
>> 1);
5944 psli
->stats_start
= get_seconds();
5946 mempool_free(pmboxq
, phba
->mbox_mem_pool
);
5952 * The LPFC driver treats linkdown handling as target loss events so there
5953 * are no sysfs handlers for link_down_tmo.
5957 * lpfc_get_node_by_target - Return the nodelist for a target
5958 * @starget: kernel scsi target pointer.
5961 * address of the node list if found
5962 * NULL target not found
5964 static struct lpfc_nodelist
*
5965 lpfc_get_node_by_target(struct scsi_target
*starget
)
5967 struct Scsi_Host
*shost
= dev_to_shost(starget
->dev
.parent
);
5968 struct lpfc_vport
*vport
= (struct lpfc_vport
*) shost
->hostdata
;
5969 struct lpfc_nodelist
*ndlp
;
5971 spin_lock_irq(shost
->host_lock
);
5972 /* Search for this, mapped, target ID */
5973 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
5974 if (NLP_CHK_NODE_ACT(ndlp
) &&
5975 ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
&&
5976 starget
->id
== ndlp
->nlp_sid
) {
5977 spin_unlock_irq(shost
->host_lock
);
5981 spin_unlock_irq(shost
->host_lock
);
5986 * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1
5987 * @starget: kernel scsi target pointer.
5990 lpfc_get_starget_port_id(struct scsi_target
*starget
)
5992 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
5994 fc_starget_port_id(starget
) = ndlp
? ndlp
->nlp_DID
: -1;
5998 * lpfc_get_starget_node_name - Set the target node name
5999 * @starget: kernel scsi target pointer.
6001 * Description: Set the target node name to the ndlp node name wwn or zero.
6004 lpfc_get_starget_node_name(struct scsi_target
*starget
)
6006 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6008 fc_starget_node_name(starget
) =
6009 ndlp
? wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
) : 0;
6013 * lpfc_get_starget_port_name - Set the target port name
6014 * @starget: kernel scsi target pointer.
6016 * Description: set the target port name to the ndlp port name wwn or zero.
6019 lpfc_get_starget_port_name(struct scsi_target
*starget
)
6021 struct lpfc_nodelist
*ndlp
= lpfc_get_node_by_target(starget
);
6023 fc_starget_port_name(starget
) =
6024 ndlp
? wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
) : 0;
6028 * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo
6029 * @rport: fc rport address.
6030 * @timeout: new value for dev loss tmo.
6033 * If timeout is non zero set the dev_loss_tmo to timeout, else set
6034 * dev_loss_tmo to one.
6037 lpfc_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
6040 rport
->dev_loss_tmo
= timeout
;
6042 rport
->dev_loss_tmo
= 1;
6046 * lpfc_rport_show_function - Return rport target information
6049 * Macro that uses field to generate a function with the name lpfc_show_rport_
6051 * lpfc_show_rport_##field: returns the bytes formatted in buf
6052 * @cdev: class converted to an fc_rport.
6053 * @buf: on return contains the target_field or zero.
6055 * Returns: size of formatted string.
6057 #define lpfc_rport_show_function(field, format_string, sz, cast) \
6059 lpfc_show_rport_##field (struct device *dev, \
6060 struct device_attribute *attr, \
6063 struct fc_rport *rport = transport_class_to_rport(dev); \
6064 struct lpfc_rport_data *rdata = rport->hostdata; \
6065 return snprintf(buf, sz, format_string, \
6066 (rdata->target) ? cast rdata->target->field : 0); \
6069 #define lpfc_rport_rd_attr(field, format_string, sz) \
6070 lpfc_rport_show_function(field, format_string, sz, ) \
6071 static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
6074 * lpfc_set_vport_symbolic_name - Set the vport's symbolic name
6075 * @fc_vport: The fc_vport who's symbolic name has been changed.
6078 * This function is called by the transport after the @fc_vport's symbolic name
6079 * has been changed. This function re-registers the symbolic name with the
6080 * switch to propagate the change into the fabric if the vport is active.
6083 lpfc_set_vport_symbolic_name(struct fc_vport
*fc_vport
)
6085 struct lpfc_vport
*vport
= *(struct lpfc_vport
**)fc_vport
->dd_data
;
6087 if (vport
->port_state
== LPFC_VPORT_READY
)
6088 lpfc_ns_cmd(vport
, SLI_CTNS_RSPN_ID
, 0, 0);
6092 * lpfc_hba_log_verbose_init - Set hba's log verbose level
6093 * @phba: Pointer to lpfc_hba struct.
6095 * This function is called by the lpfc_get_cfgparam() routine to set the
6096 * module lpfc_log_verbose into the @phba cfg_log_verbose for use with
6097 * log message according to the module's lpfc_log_verbose parameter setting
6098 * before hba port or vport created.
6101 lpfc_hba_log_verbose_init(struct lpfc_hba
*phba
, uint32_t verbose
)
6103 phba
->cfg_log_verbose
= verbose
;
6106 struct fc_function_template lpfc_transport_functions
= {
6107 /* fixed attributes the driver supports */
6108 .show_host_node_name
= 1,
6109 .show_host_port_name
= 1,
6110 .show_host_supported_classes
= 1,
6111 .show_host_supported_fc4s
= 1,
6112 .show_host_supported_speeds
= 1,
6113 .show_host_maxframe_size
= 1,
6115 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6116 .show_host_symbolic_name
= 1,
6118 /* dynamic attributes the driver supports */
6119 .get_host_port_id
= lpfc_get_host_port_id
,
6120 .show_host_port_id
= 1,
6122 .get_host_port_type
= lpfc_get_host_port_type
,
6123 .show_host_port_type
= 1,
6125 .get_host_port_state
= lpfc_get_host_port_state
,
6126 .show_host_port_state
= 1,
6128 /* active_fc4s is shown but doesn't change (thus no get function) */
6129 .show_host_active_fc4s
= 1,
6131 .get_host_speed
= lpfc_get_host_speed
,
6132 .show_host_speed
= 1,
6134 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6135 .show_host_fabric_name
= 1,
6138 * The LPFC driver treats linkdown handling as target loss events
6139 * so there are no sysfs handlers for link_down_tmo.
6142 .get_fc_host_stats
= lpfc_get_stats
,
6143 .reset_fc_host_stats
= lpfc_reset_stats
,
6145 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6146 .show_rport_maxframe_size
= 1,
6147 .show_rport_supported_classes
= 1,
6149 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6150 .show_rport_dev_loss_tmo
= 1,
6152 .get_starget_port_id
= lpfc_get_starget_port_id
,
6153 .show_starget_port_id
= 1,
6155 .get_starget_node_name
= lpfc_get_starget_node_name
,
6156 .show_starget_node_name
= 1,
6158 .get_starget_port_name
= lpfc_get_starget_port_name
,
6159 .show_starget_port_name
= 1,
6161 .issue_fc_host_lip
= lpfc_issue_lip
,
6162 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6163 .terminate_rport_io
= lpfc_terminate_rport_io
,
6165 .dd_fcvport_size
= sizeof(struct lpfc_vport
*),
6167 .vport_disable
= lpfc_vport_disable
,
6169 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6171 .bsg_request
= lpfc_bsg_request
,
6172 .bsg_timeout
= lpfc_bsg_timeout
,
6175 struct fc_function_template lpfc_vport_transport_functions
= {
6176 /* fixed attributes the driver supports */
6177 .show_host_node_name
= 1,
6178 .show_host_port_name
= 1,
6179 .show_host_supported_classes
= 1,
6180 .show_host_supported_fc4s
= 1,
6181 .show_host_supported_speeds
= 1,
6182 .show_host_maxframe_size
= 1,
6184 .get_host_symbolic_name
= lpfc_get_host_symbolic_name
,
6185 .show_host_symbolic_name
= 1,
6187 /* dynamic attributes the driver supports */
6188 .get_host_port_id
= lpfc_get_host_port_id
,
6189 .show_host_port_id
= 1,
6191 .get_host_port_type
= lpfc_get_host_port_type
,
6192 .show_host_port_type
= 1,
6194 .get_host_port_state
= lpfc_get_host_port_state
,
6195 .show_host_port_state
= 1,
6197 /* active_fc4s is shown but doesn't change (thus no get function) */
6198 .show_host_active_fc4s
= 1,
6200 .get_host_speed
= lpfc_get_host_speed
,
6201 .show_host_speed
= 1,
6203 .get_host_fabric_name
= lpfc_get_host_fabric_name
,
6204 .show_host_fabric_name
= 1,
6207 * The LPFC driver treats linkdown handling as target loss events
6208 * so there are no sysfs handlers for link_down_tmo.
6211 .get_fc_host_stats
= lpfc_get_stats
,
6212 .reset_fc_host_stats
= lpfc_reset_stats
,
6214 .dd_fcrport_size
= sizeof(struct lpfc_rport_data
),
6215 .show_rport_maxframe_size
= 1,
6216 .show_rport_supported_classes
= 1,
6218 .set_rport_dev_loss_tmo
= lpfc_set_rport_loss_tmo
,
6219 .show_rport_dev_loss_tmo
= 1,
6221 .get_starget_port_id
= lpfc_get_starget_port_id
,
6222 .show_starget_port_id
= 1,
6224 .get_starget_node_name
= lpfc_get_starget_node_name
,
6225 .show_starget_node_name
= 1,
6227 .get_starget_port_name
= lpfc_get_starget_port_name
,
6228 .show_starget_port_name
= 1,
6230 .dev_loss_tmo_callbk
= lpfc_dev_loss_tmo_callbk
,
6231 .terminate_rport_io
= lpfc_terminate_rport_io
,
6233 .vport_disable
= lpfc_vport_disable
,
6235 .set_vport_symbolic_name
= lpfc_set_vport_symbolic_name
,
6239 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
6240 * @phba: lpfc_hba pointer.
6243 lpfc_get_cfgparam(struct lpfc_hba
*phba
)
6245 lpfc_fcp_io_sched_init(phba
, lpfc_fcp_io_sched
);
6246 lpfc_fcp2_no_tgt_reset_init(phba
, lpfc_fcp2_no_tgt_reset
);
6247 lpfc_cr_delay_init(phba
, lpfc_cr_delay
);
6248 lpfc_cr_count_init(phba
, lpfc_cr_count
);
6249 lpfc_multi_ring_support_init(phba
, lpfc_multi_ring_support
);
6250 lpfc_multi_ring_rctl_init(phba
, lpfc_multi_ring_rctl
);
6251 lpfc_multi_ring_type_init(phba
, lpfc_multi_ring_type
);
6252 lpfc_ack0_init(phba
, lpfc_ack0
);
6253 lpfc_topology_init(phba
, lpfc_topology
);
6254 lpfc_link_speed_init(phba
, lpfc_link_speed
);
6255 lpfc_poll_tmo_init(phba
, lpfc_poll_tmo
);
6256 lpfc_task_mgmt_tmo_init(phba
, lpfc_task_mgmt_tmo
);
6257 lpfc_enable_npiv_init(phba
, lpfc_enable_npiv
);
6258 lpfc_fcf_failover_policy_init(phba
, lpfc_fcf_failover_policy
);
6259 lpfc_enable_rrq_init(phba
, lpfc_enable_rrq
);
6260 lpfc_fdmi_on_init(phba
, lpfc_fdmi_on
);
6261 lpfc_enable_SmartSAN_init(phba
, lpfc_enable_SmartSAN
);
6262 lpfc_use_msi_init(phba
, lpfc_use_msi
);
6263 lpfc_nvme_oas_init(phba
, lpfc_nvme_oas
);
6264 lpfc_auto_imax_init(phba
, lpfc_auto_imax
);
6265 lpfc_fcp_imax_init(phba
, lpfc_fcp_imax
);
6266 lpfc_fcp_cpu_map_init(phba
, lpfc_fcp_cpu_map
);
6267 lpfc_enable_hba_reset_init(phba
, lpfc_enable_hba_reset
);
6268 lpfc_enable_hba_heartbeat_init(phba
, lpfc_enable_hba_heartbeat
);
6270 lpfc_EnableXLane_init(phba
, lpfc_EnableXLane
);
6271 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
6272 phba
->cfg_EnableXLane
= 0;
6273 lpfc_XLanePriority_init(phba
, lpfc_XLanePriority
);
6275 memset(phba
->cfg_oas_tgt_wwpn
, 0, (8 * sizeof(uint8_t)));
6276 memset(phba
->cfg_oas_vpt_wwpn
, 0, (8 * sizeof(uint8_t)));
6277 phba
->cfg_oas_lun_state
= 0;
6278 phba
->cfg_oas_lun_status
= 0;
6279 phba
->cfg_oas_flags
= 0;
6280 phba
->cfg_oas_priority
= 0;
6281 lpfc_enable_bg_init(phba
, lpfc_enable_bg
);
6282 lpfc_prot_mask_init(phba
, lpfc_prot_mask
);
6283 lpfc_prot_guard_init(phba
, lpfc_prot_guard
);
6284 if (phba
->sli_rev
== LPFC_SLI_REV4
)
6287 phba
->cfg_poll
= lpfc_poll
;
6288 lpfc_suppress_rsp_init(phba
, lpfc_suppress_rsp
);
6290 lpfc_enable_fc4_type_init(phba
, lpfc_enable_fc4_type
);
6291 lpfc_nvmet_mrq_init(phba
, lpfc_nvmet_mrq
);
6293 /* Initialize first burst. Target vs Initiator are different. */
6294 lpfc_nvme_enable_fb_init(phba
, lpfc_nvme_enable_fb
);
6295 lpfc_nvmet_fb_size_init(phba
, lpfc_nvmet_fb_size
);
6296 lpfc_fcp_io_channel_init(phba
, lpfc_fcp_io_channel
);
6297 lpfc_nvme_io_channel_init(phba
, lpfc_nvme_io_channel
);
6298 lpfc_enable_bbcr_init(phba
, lpfc_enable_bbcr
);
6300 if (phba
->sli_rev
!= LPFC_SLI_REV4
) {
6301 /* NVME only supported on SLI4 */
6302 phba
->nvmet_support
= 0;
6303 phba
->cfg_enable_fc4_type
= LPFC_ENABLE_FCP
;
6304 phba
->cfg_enable_bbcr
= 0;
6306 /* We MUST have FCP support */
6307 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_FCP
))
6308 phba
->cfg_enable_fc4_type
|= LPFC_ENABLE_FCP
;
6311 if (phba
->cfg_auto_imax
&& !phba
->cfg_fcp_imax
)
6312 phba
->cfg_auto_imax
= 0;
6313 phba
->initial_imax
= phba
->cfg_fcp_imax
;
6315 /* A value of 0 means use the number of CPUs found in the system */
6316 if (phba
->cfg_fcp_io_channel
== 0)
6317 phba
->cfg_fcp_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6318 if (phba
->cfg_nvme_io_channel
== 0)
6319 phba
->cfg_nvme_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6321 if (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
)
6322 phba
->cfg_fcp_io_channel
= 0;
6324 if (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_FCP
)
6325 phba
->cfg_nvme_io_channel
= 0;
6327 if (phba
->cfg_fcp_io_channel
> phba
->cfg_nvme_io_channel
)
6328 phba
->io_channel_irqs
= phba
->cfg_fcp_io_channel
;
6330 phba
->io_channel_irqs
= phba
->cfg_nvme_io_channel
;
6332 phba
->cfg_soft_wwnn
= 0L;
6333 phba
->cfg_soft_wwpn
= 0L;
6334 lpfc_xri_split_init(phba
, lpfc_xri_split
);
6335 lpfc_sg_seg_cnt_init(phba
, lpfc_sg_seg_cnt
);
6336 lpfc_hba_queue_depth_init(phba
, lpfc_hba_queue_depth
);
6337 lpfc_hba_log_verbose_init(phba
, lpfc_log_verbose
);
6338 lpfc_aer_support_init(phba
, lpfc_aer_support
);
6339 lpfc_sriov_nr_virtfn_init(phba
, lpfc_sriov_nr_virtfn
);
6340 lpfc_request_firmware_upgrade_init(phba
, lpfc_req_fw_upgrade
);
6341 lpfc_suppress_link_up_init(phba
, lpfc_suppress_link_up
);
6342 lpfc_iocb_cnt_init(phba
, lpfc_iocb_cnt
);
6343 lpfc_delay_discovery_init(phba
, lpfc_delay_discovery
);
6344 lpfc_sli_mode_init(phba
, lpfc_sli_mode
);
6345 phba
->cfg_enable_dss
= 1;
6346 lpfc_enable_mds_diags_init(phba
, lpfc_enable_mds_diags
);
6351 * lpfc_nvme_mod_param_dep - Adjust module parameter value based on
6352 * dependencies between protocols and roles.
6353 * @phba: lpfc_hba pointer.
6356 lpfc_nvme_mod_param_dep(struct lpfc_hba
*phba
)
6358 if (phba
->cfg_nvme_io_channel
> phba
->sli4_hba
.num_present_cpu
)
6359 phba
->cfg_nvme_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6361 if (phba
->cfg_fcp_io_channel
> phba
->sli4_hba
.num_present_cpu
)
6362 phba
->cfg_fcp_io_channel
= phba
->sli4_hba
.num_present_cpu
;
6364 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
&&
6365 phba
->nvmet_support
) {
6366 phba
->cfg_enable_fc4_type
&= ~LPFC_ENABLE_FCP
;
6367 phba
->cfg_fcp_io_channel
= 0;
6369 lpfc_printf_log(phba
, KERN_INFO
, LOG_NVME_DISC
,
6370 "6013 %s x%x fb_size x%x, fb_max x%x\n",
6371 "NVME Target PRLI ACC enable_fb ",
6372 phba
->cfg_nvme_enable_fb
,
6373 phba
->cfg_nvmet_fb_size
,
6374 LPFC_NVMET_FB_SZ_MAX
);
6376 if (phba
->cfg_nvme_enable_fb
== 0)
6377 phba
->cfg_nvmet_fb_size
= 0;
6379 if (phba
->cfg_nvmet_fb_size
> LPFC_NVMET_FB_SZ_MAX
)
6380 phba
->cfg_nvmet_fb_size
= LPFC_NVMET_FB_SZ_MAX
;
6383 if (!phba
->cfg_nvmet_mrq
)
6384 phba
->cfg_nvmet_mrq
= phba
->cfg_nvme_io_channel
;
6386 /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */
6387 if (phba
->cfg_nvmet_mrq
> phba
->cfg_nvme_io_channel
) {
6388 phba
->cfg_nvmet_mrq
= phba
->cfg_nvme_io_channel
;
6389 lpfc_printf_log(phba
, KERN_ERR
, LOG_NVME_DISC
,
6390 "6018 Adjust lpfc_nvmet_mrq to %d\n",
6391 phba
->cfg_nvmet_mrq
);
6393 if (phba
->cfg_nvmet_mrq
> LPFC_NVMET_MRQ_MAX
)
6394 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_MAX
;
6397 /* Not NVME Target mode. Turn off Target parameters. */
6398 phba
->nvmet_support
= 0;
6399 phba
->cfg_nvmet_mrq
= LPFC_NVMET_MRQ_OFF
;
6400 phba
->cfg_nvmet_fb_size
= 0;
6403 if (phba
->cfg_fcp_io_channel
> phba
->cfg_nvme_io_channel
)
6404 phba
->io_channel_irqs
= phba
->cfg_fcp_io_channel
;
6406 phba
->io_channel_irqs
= phba
->cfg_nvme_io_channel
;
6410 * lpfc_get_vport_cfgparam - Used during port create, init the vport structure
6411 * @vport: lpfc_vport pointer.
6414 lpfc_get_vport_cfgparam(struct lpfc_vport
*vport
)
6416 lpfc_log_verbose_init(vport
, lpfc_log_verbose
);
6417 lpfc_lun_queue_depth_init(vport
, lpfc_lun_queue_depth
);
6418 lpfc_tgt_queue_depth_init(vport
, lpfc_tgt_queue_depth
);
6419 lpfc_devloss_tmo_init(vport
, lpfc_devloss_tmo
);
6420 lpfc_nodev_tmo_init(vport
, lpfc_nodev_tmo
);
6421 lpfc_peer_port_login_init(vport
, lpfc_peer_port_login
);
6422 lpfc_restrict_login_init(vport
, lpfc_restrict_login
);
6423 lpfc_fcp_class_init(vport
, lpfc_fcp_class
);
6424 lpfc_use_adisc_init(vport
, lpfc_use_adisc
);
6425 lpfc_first_burst_size_init(vport
, lpfc_first_burst_size
);
6426 lpfc_max_scsicmpl_time_init(vport
, lpfc_max_scsicmpl_time
);
6427 lpfc_discovery_threads_init(vport
, lpfc_discovery_threads
);
6428 lpfc_max_luns_init(vport
, lpfc_max_luns
);
6429 lpfc_scan_down_init(vport
, lpfc_scan_down
);
6430 lpfc_enable_da_id_init(vport
, lpfc_enable_da_id
);