1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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>
32
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>
39
40#include <linux/nvme-fc-driver.h>
41
42#include "lpfc_hw4.h"
43#include "lpfc_hw.h"
44#include "lpfc_sli.h"
45#include "lpfc_sli4.h"
46#include "lpfc_nl.h"
47#include "lpfc_disc.h"
48#include "lpfc.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"
58
59#define LPFC_DEF_DEVLOSS_TMO 30
60#define LPFC_MIN_DEVLOSS_TMO 1
61#define LPFC_MAX_DEVLOSS_TMO 255
62
63#define LPFC_DEF_MRQ_POST 256
64#define LPFC_MIN_MRQ_POST 32
65#define LPFC_MAX_MRQ_POST 512
66
67
68
69
70
71#define LPFC_REG_WRITE_KEY_SIZE 4
72#define LPFC_REG_WRITE_KEY "EMLX"
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89static void
90lpfc_jedec_to_ascii(int incr, char hdw[])
91{
92 int i, j;
93 for (i = 0; i < 8; i++) {
94 j = (incr & 0xf);
95 if (j <= 9)
96 hdw[7 - i] = 0x30 + j;
97 else
98 hdw[7 - i] = 0x61 + j - 10;
99 incr = (incr >> 4);
100 }
101 hdw[8] = 0;
102 return;
103}
104
105
106
107
108
109
110
111
112
113static ssize_t
114lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
115 char *buf)
116{
117 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
118}
119
120
121
122
123
124
125
126
127
128static ssize_t
129lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr,
130 char *buf)
131{
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;
135
136 if (phba->hba_flag & HBA_FIP_SUPPORT)
137 return snprintf(buf, PAGE_SIZE, "1\n");
138 else
139 return snprintf(buf, PAGE_SIZE, "0\n");
140}
141
142static ssize_t
143lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
144 char *buf)
145{
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_nvme_rport *rport;
153 struct nvme_fc_remote_port *nrport;
154 char *statep;
155 int len = 0;
156
157 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
158 len += snprintf(buf, PAGE_SIZE, "NVME Disabled\n");
159 return len;
160 }
161 if (phba->nvmet_support) {
162 if (!phba->targetport) {
163 len = snprintf(buf, PAGE_SIZE,
164 "NVME Target: x%llx is not allocated\n",
165 wwn_to_u64(vport->fc_portname.u.wwn));
166 return len;
167 }
168
169 if (phba->targetport->port_id)
170 statep = "REGISTERED";
171 else
172 statep = "INIT";
173 len += snprintf(buf + len, PAGE_SIZE - len,
174 "NVME Target: Enabled State %s\n",
175 statep);
176 len += snprintf(buf + len, PAGE_SIZE - len,
177 "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
178 "NVME Target: lpfc",
179 phba->brd_no,
180 wwn_to_u64(vport->fc_portname.u.wwn),
181 wwn_to_u64(vport->fc_nodename.u.wwn),
182 phba->targetport->port_id);
183
184 len += snprintf(buf + len, PAGE_SIZE,
185 "\nNVME Target: Statistics\n");
186 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
187 len += snprintf(buf+len, PAGE_SIZE-len,
188 "LS: Rcv %08x Drop %08x Abort %08x\n",
189 atomic_read(&tgtp->rcv_ls_req_in),
190 atomic_read(&tgtp->rcv_ls_req_drop),
191 atomic_read(&tgtp->xmt_ls_abort));
192 if (atomic_read(&tgtp->rcv_ls_req_in) !=
193 atomic_read(&tgtp->rcv_ls_req_out)) {
194 len += snprintf(buf+len, PAGE_SIZE-len,
195 "Rcv LS: in %08x != out %08x\n",
196 atomic_read(&tgtp->rcv_ls_req_in),
197 atomic_read(&tgtp->rcv_ls_req_out));
198 }
199
200 len += snprintf(buf+len, PAGE_SIZE-len,
201 "LS: Xmt %08x Drop %08x Cmpl %08x Err %08x\n",
202 atomic_read(&tgtp->xmt_ls_rsp),
203 atomic_read(&tgtp->xmt_ls_drop),
204 atomic_read(&tgtp->xmt_ls_rsp_cmpl),
205 atomic_read(&tgtp->xmt_ls_rsp_error));
206
207 len += snprintf(buf+len, PAGE_SIZE-len,
208 "FCP: Rcv %08x Drop %08x\n",
209 atomic_read(&tgtp->rcv_fcp_cmd_in),
210 atomic_read(&tgtp->rcv_fcp_cmd_drop));
211
212 if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
213 atomic_read(&tgtp->rcv_fcp_cmd_out)) {
214 len += snprintf(buf+len, PAGE_SIZE-len,
215 "Rcv FCP: in %08x != out %08x\n",
216 atomic_read(&tgtp->rcv_fcp_cmd_in),
217 atomic_read(&tgtp->rcv_fcp_cmd_out));
218 }
219
220 len += snprintf(buf+len, PAGE_SIZE-len,
221 "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x\n",
222 atomic_read(&tgtp->xmt_fcp_read),
223 atomic_read(&tgtp->xmt_fcp_read_rsp),
224 atomic_read(&tgtp->xmt_fcp_write),
225 atomic_read(&tgtp->xmt_fcp_rsp));
226
227 len += snprintf(buf+len, PAGE_SIZE-len,
228 "FCP Rsp: abort %08x drop %08x\n",
229 atomic_read(&tgtp->xmt_fcp_abort),
230 atomic_read(&tgtp->xmt_fcp_drop));
231
232 len += snprintf(buf+len, PAGE_SIZE-len,
233 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
234 atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
235 atomic_read(&tgtp->xmt_fcp_rsp_error),
236 atomic_read(&tgtp->xmt_fcp_rsp_drop));
237
238 len += snprintf(buf+len, PAGE_SIZE-len,
239 "ABORT: Xmt %08x Err %08x Cmpl %08x",
240 atomic_read(&tgtp->xmt_abort_rsp),
241 atomic_read(&tgtp->xmt_abort_rsp_error),
242 atomic_read(&tgtp->xmt_abort_cmpl));
243
244 len += snprintf(buf+len, PAGE_SIZE-len, "\n");
245 return len;
246 }
247
248 localport = vport->localport;
249 if (!localport) {
250 len = snprintf(buf, PAGE_SIZE,
251 "NVME Initiator x%llx is not allocated\n",
252 wwn_to_u64(vport->fc_portname.u.wwn));
253 return len;
254 }
255 len = snprintf(buf, PAGE_SIZE, "NVME Initiator Enabled\n");
256
257 spin_lock_irq(shost->host_lock);
258 lport = (struct lpfc_nvme_lport *)localport->private;
259
260
261 if (localport->port_id)
262 statep = "ONLINE";
263 else
264 statep = "UNKNOWN ";
265
266 len += snprintf(buf + len, PAGE_SIZE - len,
267 "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
268 "NVME LPORT lpfc",
269 phba->brd_no,
270 wwn_to_u64(vport->fc_portname.u.wwn),
271 wwn_to_u64(vport->fc_nodename.u.wwn),
272 localport->port_id, statep);
273
274 list_for_each_entry(rport, &lport->rport_list, list) {
275
276 nrport = rport->remoteport;
277
278
279 switch (nrport->port_state) {
280 case FC_OBJSTATE_ONLINE:
281 statep = "ONLINE";
282 break;
283 case FC_OBJSTATE_UNKNOWN:
284 statep = "UNKNOWN ";
285 break;
286 default:
287 statep = "UNSUPPORTED";
288 break;
289 }
290
291
292 len += snprintf(buf + len, PAGE_SIZE - len,
293 "NVME RPORT ");
294 if (phba->brd_no >= 10)
295 len += snprintf(buf + len, PAGE_SIZE - len, " ");
296
297 len += snprintf(buf + len, PAGE_SIZE - len, "WWPN x%llx ",
298 nrport->port_name);
299 len += snprintf(buf + len, PAGE_SIZE - len, "WWNN x%llx ",
300 nrport->node_name);
301 len += snprintf(buf + len, PAGE_SIZE - len, "DID x%06x ",
302 nrport->port_id);
303
304 switch (nrport->port_role) {
305 case FC_PORT_ROLE_NVME_INITIATOR:
306 len += snprintf(buf + len, PAGE_SIZE - len,
307 "INITIATOR ");
308 break;
309 case FC_PORT_ROLE_NVME_TARGET:
310 len += snprintf(buf + len, PAGE_SIZE - len,
311 "TARGET ");
312 break;
313 case FC_PORT_ROLE_NVME_DISCOVERY:
314 len += snprintf(buf + len, PAGE_SIZE - len,
315 "DISCOVERY ");
316 break;
317 default:
318 len += snprintf(buf + len, PAGE_SIZE - len,
319 "UNKNOWN_ROLE x%x",
320 nrport->port_role);
321 break;
322 }
323 len += snprintf(buf + len, PAGE_SIZE - len, "%s ", statep);
324
325 len += snprintf(buf + len, PAGE_SIZE - len, "\n");
326 }
327 spin_unlock_irq(shost->host_lock);
328
329 len += snprintf(buf + len, PAGE_SIZE, "\nNVME Statistics\n");
330 len += snprintf(buf+len, PAGE_SIZE-len,
331 "LS: Xmt %016llx Cmpl %016llx\n",
332 phba->fc4NvmeLsRequests,
333 phba->fc4NvmeLsCmpls);
334
335 len += snprintf(buf+len, PAGE_SIZE-len,
336 "FCP: Rd %016llx Wr %016llx IO %016llx\n",
337 phba->fc4NvmeInputRequests,
338 phba->fc4NvmeOutputRequests,
339 phba->fc4NvmeControlRequests);
340
341 len += snprintf(buf+len, PAGE_SIZE-len,
342 " Cmpl %016llx\n", phba->fc4NvmeIoCmpls);
343
344 return len;
345}
346
347static ssize_t
348lpfc_bg_info_show(struct device *dev, struct device_attribute *attr,
349 char *buf)
350{
351 struct Scsi_Host *shost = class_to_shost(dev);
352 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
353 struct lpfc_hba *phba = vport->phba;
354
355 if (phba->cfg_enable_bg)
356 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED)
357 return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n");
358 else
359 return snprintf(buf, PAGE_SIZE,
360 "BlockGuard Not Supported\n");
361 else
362 return snprintf(buf, PAGE_SIZE,
363 "BlockGuard Disabled\n");
364}
365
366static ssize_t
367lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr,
368 char *buf)
369{
370 struct Scsi_Host *shost = class_to_shost(dev);
371 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
372 struct lpfc_hba *phba = vport->phba;
373
374 return snprintf(buf, PAGE_SIZE, "%llu\n",
375 (unsigned long long)phba->bg_guard_err_cnt);
376}
377
378static ssize_t
379lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr,
380 char *buf)
381{
382 struct Scsi_Host *shost = class_to_shost(dev);
383 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
384 struct lpfc_hba *phba = vport->phba;
385
386 return snprintf(buf, PAGE_SIZE, "%llu\n",
387 (unsigned long long)phba->bg_apptag_err_cnt);
388}
389
390static ssize_t
391lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr,
392 char *buf)
393{
394 struct Scsi_Host *shost = class_to_shost(dev);
395 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
396 struct lpfc_hba *phba = vport->phba;
397
398 return snprintf(buf, PAGE_SIZE, "%llu\n",
399 (unsigned long long)phba->bg_reftag_err_cnt);
400}
401
402
403
404
405
406
407
408
409
410static ssize_t
411lpfc_info_show(struct device *dev, struct device_attribute *attr,
412 char *buf)
413{
414 struct Scsi_Host *host = class_to_shost(dev);
415
416 return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host));
417}
418
419
420
421
422
423
424
425
426
427static ssize_t
428lpfc_serialnum_show(struct device *dev, struct device_attribute *attr,
429 char *buf)
430{
431 struct Scsi_Host *shost = class_to_shost(dev);
432 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
433 struct lpfc_hba *phba = vport->phba;
434
435 return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
436}
437
438
439
440
441
442
443
444
445
446
447
448
449
450static ssize_t
451lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr,
452 char *buf)
453{
454 struct Scsi_Host *shost = class_to_shost(dev);
455 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
456 struct lpfc_hba *phba = vport->phba;
457 return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
458}
459
460
461
462
463
464
465
466
467
468static ssize_t
469lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr,
470 char *buf)
471{
472 struct Scsi_Host *shost = class_to_shost(dev);
473 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
474 struct lpfc_hba *phba = vport->phba;
475
476 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc);
477}
478
479
480
481
482
483
484
485
486
487static ssize_t
488lpfc_modelname_show(struct device *dev, struct device_attribute *attr,
489 char *buf)
490{
491 struct Scsi_Host *shost = class_to_shost(dev);
492 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
493 struct lpfc_hba *phba = vport->phba;
494
495 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName);
496}
497
498
499
500
501
502
503
504
505
506static ssize_t
507lpfc_programtype_show(struct device *dev, struct device_attribute *attr,
508 char *buf)
509{
510 struct Scsi_Host *shost = class_to_shost(dev);
511 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
512 struct lpfc_hba *phba = vport->phba;
513
514 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType);
515}
516
517
518
519
520
521
522
523
524
525static ssize_t
526lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf)
527{
528 struct Scsi_Host *shost = class_to_shost(dev);
529 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
530 struct lpfc_hba *phba = vport->phba;
531
532 return snprintf(buf, PAGE_SIZE, "%d\n",
533 (phba->sli.sli_flag & LPFC_MENLO_MAINT));
534}
535
536
537
538
539
540
541
542
543
544static ssize_t
545lpfc_vportnum_show(struct device *dev, struct device_attribute *attr,
546 char *buf)
547{
548 struct Scsi_Host *shost = class_to_shost(dev);
549 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
550 struct lpfc_hba *phba = vport->phba;
551
552 return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port);
553}
554
555
556
557
558
559
560
561
562
563static ssize_t
564lpfc_fwrev_show(struct device *dev, struct device_attribute *attr,
565 char *buf)
566{
567 struct Scsi_Host *shost = class_to_shost(dev);
568 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
569 struct lpfc_hba *phba = vport->phba;
570 uint32_t if_type;
571 uint8_t sli_family;
572 char fwrev[FW_REV_STR_SIZE];
573 int len;
574
575 lpfc_decode_firmware_rev(phba, fwrev, 1);
576 if_type = phba->sli4_hba.pc_sli4_params.if_type;
577 sli_family = phba->sli4_hba.pc_sli4_params.sli_family;
578
579 if (phba->sli_rev < LPFC_SLI_REV4)
580 len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n",
581 fwrev, phba->sli_rev);
582 else
583 len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n",
584 fwrev, phba->sli_rev, if_type, sli_family);
585
586 return len;
587}
588
589
590
591
592
593
594
595
596
597static ssize_t
598lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf)
599{
600 char hdw[9];
601 struct Scsi_Host *shost = class_to_shost(dev);
602 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
603 struct lpfc_hba *phba = vport->phba;
604 lpfc_vpd_t *vp = &phba->vpd;
605
606 lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
607 return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
608}
609
610
611
612
613
614
615
616
617
618static ssize_t
619lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr,
620 char *buf)
621{
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;
625 char fwrev[FW_REV_STR_SIZE];
626
627 if (phba->sli_rev < LPFC_SLI_REV4)
628 return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
629
630 lpfc_decode_firmware_rev(phba, fwrev, 1);
631 return snprintf(buf, PAGE_SIZE, "%s\n", fwrev);
632}
633
634
635
636
637
638
639
640
641
642
643
644
645static ssize_t
646lpfc_link_state_show(struct device *dev, struct device_attribute *attr,
647 char *buf)
648{
649 struct Scsi_Host *shost = class_to_shost(dev);
650 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
651 struct lpfc_hba *phba = vport->phba;
652 int len = 0;
653
654 switch (phba->link_state) {
655 case LPFC_LINK_UNKNOWN:
656 case LPFC_WARM_START:
657 case LPFC_INIT_START:
658 case LPFC_INIT_MBX_CMDS:
659 case LPFC_LINK_DOWN:
660 case LPFC_HBA_ERROR:
661 if (phba->hba_flag & LINK_DISABLED)
662 len += snprintf(buf + len, PAGE_SIZE-len,
663 "Link Down - User disabled\n");
664 else
665 len += snprintf(buf + len, PAGE_SIZE-len,
666 "Link Down\n");
667 break;
668 case LPFC_LINK_UP:
669 case LPFC_CLEAR_LA:
670 case LPFC_HBA_READY:
671 len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
672
673 switch (vport->port_state) {
674 case LPFC_LOCAL_CFG_LINK:
675 len += snprintf(buf + len, PAGE_SIZE-len,
676 "Configuring Link\n");
677 break;
678 case LPFC_FDISC:
679 case LPFC_FLOGI:
680 case LPFC_FABRIC_CFG_LINK:
681 case LPFC_NS_REG:
682 case LPFC_NS_QRY:
683 case LPFC_BUILD_DISC_LIST:
684 case LPFC_DISC_AUTH:
685 len += snprintf(buf + len, PAGE_SIZE - len,
686 "Discovery\n");
687 break;
688 case LPFC_VPORT_READY:
689 len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n");
690 break;
691
692 case LPFC_VPORT_FAILED:
693 len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n");
694 break;
695
696 case LPFC_VPORT_UNKNOWN:
697 len += snprintf(buf + len, PAGE_SIZE - len,
698 "Unknown\n");
699 break;
700 }
701 if (phba->sli.sli_flag & LPFC_MENLO_MAINT)
702 len += snprintf(buf + len, PAGE_SIZE-len,
703 " Menlo Maint Mode\n");
704 else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
705 if (vport->fc_flag & FC_PUBLIC_LOOP)
706 len += snprintf(buf + len, PAGE_SIZE-len,
707 " Public Loop\n");
708 else
709 len += snprintf(buf + len, PAGE_SIZE-len,
710 " Private Loop\n");
711 } else {
712 if (vport->fc_flag & FC_FABRIC)
713 len += snprintf(buf + len, PAGE_SIZE-len,
714 " Fabric\n");
715 else
716 len += snprintf(buf + len, PAGE_SIZE-len,
717 " Point-2-Point\n");
718 }
719 }
720
721 return len;
722}
723
724
725
726
727
728
729
730
731
732static ssize_t
733lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr,
734 char *buf)
735{
736 struct Scsi_Host *shost = class_to_shost(dev);
737 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
738 struct lpfc_hba *phba = vport->phba;
739
740 if (phba->sli_rev < LPFC_SLI_REV4)
741 return snprintf(buf, PAGE_SIZE, "fc\n");
742
743 if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) {
744 if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE)
745 return snprintf(buf, PAGE_SIZE, "fcoe\n");
746 if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC)
747 return snprintf(buf, PAGE_SIZE, "fc\n");
748 }
749 return snprintf(buf, PAGE_SIZE, "unknown\n");
750}
751
752
753
754
755
756
757
758
759
760
761static ssize_t
762lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr,
763 char *buf)
764{
765 struct Scsi_Host *shost = class_to_shost(dev);
766 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
767 struct lpfc_hba *phba = vport->phba;
768
769 return snprintf(buf, PAGE_SIZE, "%d\n",
770 phba->sli4_hba.pc_sli4_params.oas_supported);
771}
772
773
774
775
776
777
778
779
780
781
782
783
784
785static ssize_t
786lpfc_link_state_store(struct device *dev, struct device_attribute *attr,
787 const char *buf, size_t count)
788{
789 struct Scsi_Host *shost = class_to_shost(dev);
790 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
791 struct lpfc_hba *phba = vport->phba;
792
793 int status = -EINVAL;
794
795 if ((strncmp(buf, "up", sizeof("up") - 1) == 0) &&
796 (phba->link_state == LPFC_LINK_DOWN))
797 status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT);
798 else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) &&
799 (phba->link_state >= LPFC_LINK_UP))
800 status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT);
801
802 if (status == 0)
803 return strlen(buf);
804 else
805 return status;
806}
807
808
809
810
811
812
813
814
815
816
817
818
819
820static ssize_t
821lpfc_num_discovered_ports_show(struct device *dev,
822 struct device_attribute *attr, char *buf)
823{
824 struct Scsi_Host *shost = class_to_shost(dev);
825 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
826
827 return snprintf(buf, PAGE_SIZE, "%d\n",
828 vport->fc_map_cnt + vport->fc_unmap_cnt);
829}
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845static int
846lpfc_issue_lip(struct Scsi_Host *shost)
847{
848 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
849 struct lpfc_hba *phba = vport->phba;
850 LPFC_MBOXQ_t *pmboxq;
851 int mbxstatus = MBXERR_ERROR;
852
853 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
854 (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO))
855 return -EPERM;
856
857 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
858
859 if (!pmboxq)
860 return -ENOMEM;
861
862 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
863 pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK;
864 pmboxq->u.mb.mbxOwner = OWN_HOST;
865
866 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2);
867
868 if ((mbxstatus == MBX_SUCCESS) &&
869 (pmboxq->u.mb.mbxStatus == 0 ||
870 pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) {
871 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
872 lpfc_init_link(phba, pmboxq, phba->cfg_topology,
873 phba->cfg_link_speed);
874 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq,
875 phba->fc_ratov * 2);
876 if ((mbxstatus == MBX_SUCCESS) &&
877 (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION))
878 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
879 "2859 SLI authentication is required "
880 "for INIT_LINK but has not done yet\n");
881 }
882
883 lpfc_set_loopback_flag(phba);
884 if (mbxstatus != MBX_TIMEOUT)
885 mempool_free(pmboxq, phba->mbox_mem_pool);
886
887 if (mbxstatus == MBXERR_ERROR)
888 return -EIO;
889
890 return 0;
891}
892
893int
894lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock)
895{
896 int cnt = 0;
897
898 spin_lock_irq(lock);
899 while (!list_empty(q)) {
900 spin_unlock_irq(lock);
901 msleep(20);
902 if (cnt++ > 250) {
903 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
904 "0466 %s %s\n",
905 "Outstanding IO when ",
906 "bringing Adapter offline\n");
907 return 0;
908 }
909 spin_lock_irq(lock);
910 }
911 spin_unlock_irq(lock);
912 return 1;
913}
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930static int
931lpfc_do_offline(struct lpfc_hba *phba, uint32_t type)
932{
933 struct completion online_compl;
934 struct lpfc_queue *qp = NULL;
935 struct lpfc_sli_ring *pring;
936 struct lpfc_sli *psli;
937 int status = 0;
938 int i;
939 int rc;
940
941 init_completion(&online_compl);
942 rc = lpfc_workq_post_event(phba, &status, &online_compl,
943 LPFC_EVT_OFFLINE_PREP);
944 if (rc == 0)
945 return -ENOMEM;
946
947 wait_for_completion(&online_compl);
948
949 if (status != 0)
950 return -EIO;
951
952 psli = &phba->sli;
953
954
955
956
957 if (phba->sli_rev != LPFC_SLI_REV4) {
958 for (i = 0; i < psli->num_rings; i++) {
959 pring = &psli->sli3_ring[i];
960 if (!lpfc_emptyq_wait(phba, &pring->txcmplq,
961 &phba->hbalock))
962 goto out;
963 }
964 } else {
965 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) {
966 pring = qp->pring;
967 if (!pring)
968 continue;
969 if (!lpfc_emptyq_wait(phba, &pring->txcmplq,
970 &pring->ring_lock))
971 goto out;
972 }
973 }
974out:
975 init_completion(&online_compl);
976 rc = lpfc_workq_post_event(phba, &status, &online_compl, type);
977 if (rc == 0)
978 return -ENOMEM;
979
980 wait_for_completion(&online_compl);
981
982 if (status != 0)
983 return -EIO;
984
985 return 0;
986}
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005int
1006lpfc_selective_reset(struct lpfc_hba *phba)
1007{
1008 struct completion online_compl;
1009 int status = 0;
1010 int rc;
1011
1012 if (!phba->cfg_enable_hba_reset)
1013 return -EACCES;
1014
1015 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) {
1016 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
1017
1018 if (status != 0)
1019 return status;
1020 }
1021
1022 init_completion(&online_compl);
1023 rc = lpfc_workq_post_event(phba, &status, &online_compl,
1024 LPFC_EVT_ONLINE);
1025 if (rc == 0)
1026 return -ENOMEM;
1027
1028 wait_for_completion(&online_compl);
1029
1030 if (status != 0)
1031 return -EIO;
1032
1033 return 0;
1034}
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057static ssize_t
1058lpfc_issue_reset(struct device *dev, struct device_attribute *attr,
1059 const char *buf, size_t count)
1060{
1061 struct Scsi_Host *shost = class_to_shost(dev);
1062 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1063 struct lpfc_hba *phba = vport->phba;
1064 int status = -EINVAL;
1065
1066 if (!phba->cfg_enable_hba_reset)
1067 return -EACCES;
1068
1069 if (strncmp(buf, "selective", sizeof("selective") - 1) == 0)
1070 status = phba->lpfc_selective_reset(phba);
1071
1072 if (status == 0)
1073 return strlen(buf);
1074 else
1075 return status;
1076}
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094int
1095lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba)
1096{
1097 struct lpfc_register portstat_reg = {0};
1098 int i;
1099
1100 msleep(100);
1101 lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
1102 &portstat_reg.word0);
1103
1104
1105 if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) &&
1106 !bf_get(lpfc_sliport_status_err, &portstat_reg))
1107 return -EPERM;
1108
1109
1110 for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) {
1111 msleep(10);
1112 lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
1113 &portstat_reg.word0);
1114 if (!bf_get(lpfc_sliport_status_err, &portstat_reg))
1115 continue;
1116 if (!bf_get(lpfc_sliport_status_rn, &portstat_reg))
1117 continue;
1118 if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg))
1119 continue;
1120 break;
1121 }
1122
1123 if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT)
1124 return 0;
1125 else
1126 return -EIO;
1127}
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140static ssize_t
1141lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
1142{
1143 struct completion online_compl;
1144 struct pci_dev *pdev = phba->pcidev;
1145 uint32_t before_fc_flag;
1146 uint32_t sriov_nr_virtfn;
1147 uint32_t reg_val;
1148 int status = 0, rc = 0;
1149 int job_posted = 1, sriov_err;
1150
1151 if (!phba->cfg_enable_hba_reset)
1152 return -EACCES;
1153
1154 if ((phba->sli_rev < LPFC_SLI_REV4) ||
1155 (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
1156 LPFC_SLI_INTF_IF_TYPE_2))
1157 return -EPERM;
1158
1159
1160 before_fc_flag = phba->pport->fc_flag;
1161 sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn;
1162
1163
1164 if (phba->cfg_sriov_nr_virtfn) {
1165 pci_disable_sriov(pdev);
1166 phba->cfg_sriov_nr_virtfn = 0;
1167 }
1168
1169 if (opcode == LPFC_FW_DUMP)
1170 phba->hba_flag |= HBA_FW_DUMP_OP;
1171
1172 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
1173
1174 if (status != 0) {
1175 phba->hba_flag &= ~HBA_FW_DUMP_OP;
1176 return status;
1177 }
1178
1179
1180 msleep(100);
1181
1182 reg_val = readl(phba->sli4_hba.conf_regs_memmap_p +
1183 LPFC_CTL_PDEV_CTL_OFFSET);
1184
1185 if (opcode == LPFC_FW_DUMP)
1186 reg_val |= LPFC_FW_DUMP_REQUEST;
1187 else if (opcode == LPFC_FW_RESET)
1188 reg_val |= LPFC_CTL_PDEV_CTL_FRST;
1189 else if (opcode == LPFC_DV_RESET)
1190 reg_val |= LPFC_CTL_PDEV_CTL_DRST;
1191
1192 writel(reg_val, phba->sli4_hba.conf_regs_memmap_p +
1193 LPFC_CTL_PDEV_CTL_OFFSET);
1194
1195 readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
1196
1197
1198 rc = lpfc_sli4_pdev_status_reg_wait(phba);
1199
1200 if (rc == -EPERM) {
1201
1202 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1203 "3150 No privilege to perform the requested "
1204 "access: x%x\n", reg_val);
1205 } else if (rc == -EIO) {
1206
1207 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1208 "3153 Fail to perform the requested "
1209 "access: x%x\n", reg_val);
1210 return rc;
1211 }
1212
1213
1214 if (before_fc_flag & FC_OFFLINE_MODE)
1215 goto out;
1216
1217 init_completion(&online_compl);
1218 job_posted = lpfc_workq_post_event(phba, &status, &online_compl,
1219 LPFC_EVT_ONLINE);
1220 if (!job_posted)
1221 goto out;
1222
1223 wait_for_completion(&online_compl);
1224
1225out:
1226
1227 if (sriov_nr_virtfn) {
1228 sriov_err =
1229 lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn);
1230 if (!sriov_err)
1231 phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn;
1232 }
1233
1234
1235 if (!rc) {
1236 if (!job_posted)
1237 rc = -ENOMEM;
1238 else if (status)
1239 rc = -EIO;
1240 }
1241 return rc;
1242}
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252static ssize_t
1253lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr,
1254 char *buf)
1255{
1256 struct Scsi_Host *shost = class_to_shost(dev);
1257 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1258 struct lpfc_hba *phba = vport->phba;
1259
1260 return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
1261}
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271static ssize_t
1272lpfc_board_mode_show(struct device *dev, struct device_attribute *attr,
1273 char *buf)
1274{
1275 struct Scsi_Host *shost = class_to_shost(dev);
1276 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1277 struct lpfc_hba *phba = vport->phba;
1278 char * state;
1279
1280 if (phba->link_state == LPFC_HBA_ERROR)
1281 state = "error";
1282 else if (phba->link_state == LPFC_WARM_START)
1283 state = "warm start";
1284 else if (phba->link_state == LPFC_INIT_START)
1285 state = "offline";
1286 else
1287 state = "online";
1288
1289 return snprintf(buf, PAGE_SIZE, "%s\n", state);
1290}
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305static ssize_t
1306lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
1307 const char *buf, size_t count)
1308{
1309 struct Scsi_Host *shost = class_to_shost(dev);
1310 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1311 struct lpfc_hba *phba = vport->phba;
1312 struct completion online_compl;
1313 char *board_mode_str = NULL;
1314 int status = 0;
1315 int rc;
1316
1317 if (!phba->cfg_enable_hba_reset) {
1318 status = -EACCES;
1319 goto board_mode_out;
1320 }
1321
1322 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1323 "3050 lpfc_board_mode set to %s\n", buf);
1324
1325 init_completion(&online_compl);
1326
1327 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
1328 rc = lpfc_workq_post_event(phba, &status, &online_compl,
1329 LPFC_EVT_ONLINE);
1330 if (rc == 0) {
1331 status = -ENOMEM;
1332 goto board_mode_out;
1333 }
1334 wait_for_completion(&online_compl);
1335 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
1336 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
1337 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
1338 if (phba->sli_rev == LPFC_SLI_REV4)
1339 status = -EINVAL;
1340 else
1341 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START);
1342 else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
1343 if (phba->sli_rev == LPFC_SLI_REV4)
1344 status = -EINVAL;
1345 else
1346 status = lpfc_do_offline(phba, LPFC_EVT_KILL);
1347 else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0)
1348 status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP);
1349 else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0)
1350 status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET);
1351 else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0)
1352 status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET);
1353 else
1354 status = -EINVAL;
1355
1356board_mode_out:
1357 if (!status)
1358 return strlen(buf);
1359 else {
1360 board_mode_str = strchr(buf, '\n');
1361 if (board_mode_str)
1362 *board_mode_str = '\0';
1363 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1364 "3097 Failed \"%s\", status(%d), "
1365 "fc_flag(x%x)\n",
1366 buf, status, phba->pport->fc_flag);
1367 return status;
1368 }
1369}
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389static int
1390lpfc_get_hba_info(struct lpfc_hba *phba,
1391 uint32_t *mxri, uint32_t *axri,
1392 uint32_t *mrpi, uint32_t *arpi,
1393 uint32_t *mvpi, uint32_t *avpi)
1394{
1395 struct lpfc_mbx_read_config *rd_config;
1396 LPFC_MBOXQ_t *pmboxq;
1397 MAILBOX_t *pmb;
1398 int rc = 0;
1399 uint32_t max_vpi;
1400
1401
1402
1403
1404
1405 if (phba->link_state < LPFC_LINK_DOWN ||
1406 !phba->mbox_mem_pool ||
1407 (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0)
1408 return 0;
1409
1410 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
1411 return 0;
1412
1413 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1414 if (!pmboxq)
1415 return 0;
1416 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
1417
1418 pmb = &pmboxq->u.mb;
1419 pmb->mbxCommand = MBX_READ_CONFIG;
1420 pmb->mbxOwner = OWN_HOST;
1421 pmboxq->context1 = NULL;
1422
1423 if (phba->pport->fc_flag & FC_OFFLINE_MODE)
1424 rc = MBX_NOT_FINISHED;
1425 else
1426 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
1427
1428 if (rc != MBX_SUCCESS) {
1429 if (rc != MBX_TIMEOUT)
1430 mempool_free(pmboxq, phba->mbox_mem_pool);
1431 return 0;
1432 }
1433
1434 if (phba->sli_rev == LPFC_SLI_REV4) {
1435 rd_config = &pmboxq->u.mqe.un.rd_config;
1436 if (mrpi)
1437 *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config);
1438 if (arpi)
1439 *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) -
1440 phba->sli4_hba.max_cfg_param.rpi_used;
1441 if (mxri)
1442 *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config);
1443 if (axri)
1444 *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) -
1445 phba->sli4_hba.max_cfg_param.xri_used;
1446
1447
1448
1449
1450 max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ?
1451 (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0;
1452
1453 if (mvpi)
1454 *mvpi = max_vpi;
1455 if (avpi)
1456 *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used;
1457 } else {
1458 if (mrpi)
1459 *mrpi = pmb->un.varRdConfig.max_rpi;
1460 if (arpi)
1461 *arpi = pmb->un.varRdConfig.avail_rpi;
1462 if (mxri)
1463 *mxri = pmb->un.varRdConfig.max_xri;
1464 if (axri)
1465 *axri = pmb->un.varRdConfig.avail_xri;
1466 if (mvpi)
1467 *mvpi = pmb->un.varRdConfig.max_vpi;
1468 if (avpi)
1469 *avpi = pmb->un.varRdConfig.avail_vpi;
1470 }
1471
1472 mempool_free(pmboxq, phba->mbox_mem_pool);
1473 return 1;
1474}
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490static ssize_t
1491lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr,
1492 char *buf)
1493{
1494 struct Scsi_Host *shost = class_to_shost(dev);
1495 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1496 struct lpfc_hba *phba = vport->phba;
1497 uint32_t cnt;
1498
1499 if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL))
1500 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1501 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1502}
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518static ssize_t
1519lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr,
1520 char *buf)
1521{
1522 struct Scsi_Host *shost = class_to_shost(dev);
1523 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1524 struct lpfc_hba *phba = vport->phba;
1525 uint32_t cnt, acnt;
1526
1527 if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL))
1528 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1529 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1530}
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546static ssize_t
1547lpfc_max_xri_show(struct device *dev, struct device_attribute *attr,
1548 char *buf)
1549{
1550 struct Scsi_Host *shost = class_to_shost(dev);
1551 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1552 struct lpfc_hba *phba = vport->phba;
1553 uint32_t cnt;
1554
1555 if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL))
1556 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1557 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1558}
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574static ssize_t
1575lpfc_used_xri_show(struct device *dev, struct device_attribute *attr,
1576 char *buf)
1577{
1578 struct Scsi_Host *shost = class_to_shost(dev);
1579 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1580 struct lpfc_hba *phba = vport->phba;
1581 uint32_t cnt, acnt;
1582
1583 if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL))
1584 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1585 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1586}
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602static ssize_t
1603lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr,
1604 char *buf)
1605{
1606 struct Scsi_Host *shost = class_to_shost(dev);
1607 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1608 struct lpfc_hba *phba = vport->phba;
1609 uint32_t cnt;
1610
1611 if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL))
1612 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1613 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1614}
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630static ssize_t
1631lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr,
1632 char *buf)
1633{
1634 struct Scsi_Host *shost = class_to_shost(dev);
1635 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1636 struct lpfc_hba *phba = vport->phba;
1637 uint32_t cnt, acnt;
1638
1639 if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt))
1640 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1641 return snprintf(buf, PAGE_SIZE, "Unknown\n");
1642}
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657static ssize_t
1658lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr,
1659 char *buf)
1660{
1661 struct Scsi_Host *shost = class_to_shost(dev);
1662 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1663 struct lpfc_hba *phba = vport->phba;
1664
1665 if (!(phba->max_vpi))
1666 return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n");
1667 if (vport->port_type == LPFC_PHYSICAL_PORT)
1668 return snprintf(buf, PAGE_SIZE, "NPIV Physical\n");
1669 return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi);
1670}
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683static ssize_t
1684lpfc_poll_show(struct device *dev, struct device_attribute *attr,
1685 char *buf)
1686{
1687 struct Scsi_Host *shost = class_to_shost(dev);
1688 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1689 struct lpfc_hba *phba = vport->phba;
1690
1691 return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
1692}
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708static ssize_t
1709lpfc_poll_store(struct device *dev, struct device_attribute *attr,
1710 const char *buf, size_t count)
1711{
1712 struct Scsi_Host *shost = class_to_shost(dev);
1713 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1714 struct lpfc_hba *phba = vport->phba;
1715 uint32_t creg_val;
1716 uint32_t old_val;
1717 int val=0;
1718
1719 if (!isdigit(buf[0]))
1720 return -EINVAL;
1721
1722 if (sscanf(buf, "%i", &val) != 1)
1723 return -EINVAL;
1724
1725 if ((val & 0x3) != val)
1726 return -EINVAL;
1727
1728 if (phba->sli_rev == LPFC_SLI_REV4)
1729 val = 0;
1730
1731 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1732 "3051 lpfc_poll changed from %d to %d\n",
1733 phba->cfg_poll, val);
1734
1735 spin_lock_irq(&phba->hbalock);
1736
1737 old_val = phba->cfg_poll;
1738
1739 if (val & ENABLE_FCP_RING_POLLING) {
1740 if ((val & DISABLE_FCP_RING_INT) &&
1741 !(old_val & DISABLE_FCP_RING_INT)) {
1742 if (lpfc_readl(phba->HCregaddr, &creg_val)) {
1743 spin_unlock_irq(&phba->hbalock);
1744 return -EINVAL;
1745 }
1746 creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
1747 writel(creg_val, phba->HCregaddr);
1748 readl(phba->HCregaddr);
1749
1750 lpfc_poll_start_timer(phba);
1751 }
1752 } else if (val != 0x0) {
1753 spin_unlock_irq(&phba->hbalock);
1754 return -EINVAL;
1755 }
1756
1757 if (!(val & DISABLE_FCP_RING_INT) &&
1758 (old_val & DISABLE_FCP_RING_INT))
1759 {
1760 spin_unlock_irq(&phba->hbalock);
1761 del_timer(&phba->fcp_poll_timer);
1762 spin_lock_irq(&phba->hbalock);
1763 if (lpfc_readl(phba->HCregaddr, &creg_val)) {
1764 spin_unlock_irq(&phba->hbalock);
1765 return -EINVAL;
1766 }
1767 creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING);
1768 writel(creg_val, phba->HCregaddr);
1769 readl(phba->HCregaddr);
1770 }
1771
1772 phba->cfg_poll = val;
1773
1774 spin_unlock_irq(&phba->hbalock);
1775
1776 return strlen(buf);
1777}
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787static ssize_t
1788lpfc_fips_level_show(struct device *dev, struct device_attribute *attr,
1789 char *buf)
1790{
1791 struct Scsi_Host *shost = class_to_shost(dev);
1792 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1793 struct lpfc_hba *phba = vport->phba;
1794
1795 return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level);
1796}
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806static ssize_t
1807lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr,
1808 char *buf)
1809{
1810 struct Scsi_Host *shost = class_to_shost(dev);
1811 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1812 struct lpfc_hba *phba = vport->phba;
1813
1814 return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev);
1815}
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825static ssize_t
1826lpfc_dss_show(struct device *dev, struct device_attribute *attr,
1827 char *buf)
1828{
1829 struct Scsi_Host *shost = class_to_shost(dev);
1830 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1831 struct lpfc_hba *phba = vport->phba;
1832
1833 return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n",
1834 (phba->cfg_enable_dss) ? "Enabled" : "Disabled",
1835 (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ?
1836 "" : "Not ");
1837}
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851static ssize_t
1852lpfc_sriov_hw_max_virtfn_show(struct device *dev,
1853 struct device_attribute *attr,
1854 char *buf)
1855{
1856 struct Scsi_Host *shost = class_to_shost(dev);
1857 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1858 struct lpfc_hba *phba = vport->phba;
1859 uint16_t max_nr_virtfn;
1860
1861 max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba);
1862 return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
1863}
1864
1865static inline bool lpfc_rangecheck(uint val, uint min, uint max)
1866{
1867 return val >= min && val <= max;
1868}
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884#define lpfc_param_show(attr) \
1885static ssize_t \
1886lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1887 char *buf) \
1888{ \
1889 struct Scsi_Host *shost = class_to_shost(dev);\
1890 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1891 struct lpfc_hba *phba = vport->phba;\
1892 return snprintf(buf, PAGE_SIZE, "%d\n",\
1893 phba->cfg_##attr);\
1894}
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910#define lpfc_param_hex_show(attr) \
1911static ssize_t \
1912lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1913 char *buf) \
1914{ \
1915 struct Scsi_Host *shost = class_to_shost(dev);\
1916 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1917 struct lpfc_hba *phba = vport->phba;\
1918 uint val = 0;\
1919 val = phba->cfg_##attr;\
1920 return snprintf(buf, PAGE_SIZE, "%#x\n",\
1921 phba->cfg_##attr);\
1922}
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943#define lpfc_param_init(attr, default, minval, maxval) \
1944static int \
1945lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1946{ \
1947 if (lpfc_rangecheck(val, minval, maxval)) {\
1948 phba->cfg_##attr = val;\
1949 return 0;\
1950 }\
1951 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1952 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
1953 "allowed range is ["#minval", "#maxval"]\n", val); \
1954 phba->cfg_##attr = default;\
1955 return -EINVAL;\
1956}
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978#define lpfc_param_set(attr, default, minval, maxval) \
1979static int \
1980lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
1981{ \
1982 if (lpfc_rangecheck(val, minval, maxval)) {\
1983 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1984 "3052 lpfc_" #attr " changed from %d to %d\n", \
1985 phba->cfg_##attr, val); \
1986 phba->cfg_##attr = val;\
1987 return 0;\
1988 }\
1989 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1990 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
1991 "allowed range is ["#minval", "#maxval"]\n", val); \
1992 return -EINVAL;\
1993}
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016#define lpfc_param_store(attr) \
2017static ssize_t \
2018lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2019 const char *buf, size_t count) \
2020{ \
2021 struct Scsi_Host *shost = class_to_shost(dev);\
2022 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2023 struct lpfc_hba *phba = vport->phba;\
2024 uint val = 0;\
2025 if (!isdigit(buf[0]))\
2026 return -EINVAL;\
2027 if (sscanf(buf, "%i", &val) != 1)\
2028 return -EINVAL;\
2029 if (lpfc_##attr##_set(phba, val) == 0) \
2030 return strlen(buf);\
2031 else \
2032 return -EINVAL;\
2033}
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049#define lpfc_vport_param_show(attr) \
2050static ssize_t \
2051lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2052 char *buf) \
2053{ \
2054 struct Scsi_Host *shost = class_to_shost(dev);\
2055 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2056 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
2057}
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074#define lpfc_vport_param_hex_show(attr) \
2075static ssize_t \
2076lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
2077 char *buf) \
2078{ \
2079 struct Scsi_Host *shost = class_to_shost(dev);\
2080 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2081 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
2082}
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102#define lpfc_vport_param_init(attr, default, minval, maxval) \
2103static int \
2104lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
2105{ \
2106 if (lpfc_rangecheck(val, minval, maxval)) {\
2107 vport->cfg_##attr = val;\
2108 return 0;\
2109 }\
2110 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2111 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
2112 "allowed range is ["#minval", "#maxval"]\n", val); \
2113 vport->cfg_##attr = default;\
2114 return -EINVAL;\
2115}
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134#define lpfc_vport_param_set(attr, default, minval, maxval) \
2135static int \
2136lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
2137{ \
2138 if (lpfc_rangecheck(val, minval, maxval)) {\
2139 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2140 "3053 lpfc_" #attr \
2141 " changed from %d (x%x) to %d (x%x)\n", \
2142 vport->cfg_##attr, vport->cfg_##attr, \
2143 val, val); \
2144 vport->cfg_##attr = val;\
2145 return 0;\
2146 }\
2147 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
2148 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
2149 "allowed range is ["#minval", "#maxval"]\n", val); \
2150 return -EINVAL;\
2151}
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170#define lpfc_vport_param_store(attr) \
2171static ssize_t \
2172lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
2173 const char *buf, size_t count) \
2174{ \
2175 struct Scsi_Host *shost = class_to_shost(dev);\
2176 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
2177 uint val = 0;\
2178 if (!isdigit(buf[0]))\
2179 return -EINVAL;\
2180 if (sscanf(buf, "%i", &val) != 1)\
2181 return -EINVAL;\
2182 if (lpfc_##attr##_set(vport, val) == 0) \
2183 return strlen(buf);\
2184 else \
2185 return -EINVAL;\
2186}
2187
2188
2189static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL);
2190static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL);
2191static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL);
2192static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL);
2193static DEVICE_ATTR(bg_reftag_err, S_IRUGO, lpfc_bg_reftag_err_show, NULL);
2194static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
2195static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
2196static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
2197static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL);
2198static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL);
2199static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL);
2200static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL);
2201static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL);
2202static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show,
2203 lpfc_link_state_store);
2204static DEVICE_ATTR(option_rom_version, S_IRUGO,
2205 lpfc_option_rom_version_show, NULL);
2206static DEVICE_ATTR(num_discovered_ports, S_IRUGO,
2207 lpfc_num_discovered_ports_show, NULL);
2208static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL);
2209static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
2210static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL);
2211static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL);
2212static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
2213 lpfc_board_mode_show, lpfc_board_mode_store);
2214static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
2215static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL);
2216static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL);
2217static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL);
2218static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL);
2219static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
2220static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
2221static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
2222static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL);
2223static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL);
2224static DEVICE_ATTR(lpfc_fips_rev, S_IRUGO, lpfc_fips_rev_show, NULL);
2225static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL);
2226static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO,
2227 lpfc_sriov_hw_max_virtfn_show, NULL);
2228static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL);
2229static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show,
2230 NULL);
2231
2232static char *lpfc_soft_wwn_key = "C99G71SL8032A";
2233#define WWN_SZ 8
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244static size_t
2245lpfc_wwn_set(const char *buf, size_t cnt, char wwn[])
2246{
2247 unsigned int i, j;
2248
2249
2250 if (buf[cnt-1] == '\n')
2251 cnt--;
2252
2253 if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) ||
2254 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
2255 return -EINVAL;
2256
2257 memset(wwn, 0, WWN_SZ);
2258
2259
2260 for (i = 0, j = 0; i < 16; i++) {
2261 if ((*buf >= 'a') && (*buf <= 'f'))
2262 j = ((j << 4) | ((*buf++ - 'a') + 10));
2263 else if ((*buf >= 'A') && (*buf <= 'F'))
2264 j = ((j << 4) | ((*buf++ - 'A') + 10));
2265 else if ((*buf >= '0') && (*buf <= '9'))
2266 j = ((j << 4) | (*buf++ - '0'));
2267 else
2268 return -EINVAL;
2269 if (i % 2) {
2270 wwn[i/2] = j & 0xff;
2271 j = 0;
2272 }
2273 }
2274 return 0;
2275}
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287static ssize_t
2288lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr,
2289 const char *buf, size_t count)
2290{
2291 struct Scsi_Host *shost = class_to_shost(dev);
2292 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2293 struct lpfc_hba *phba = vport->phba;
2294 unsigned int cnt = count;
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310 if (buf[cnt-1] == '\n')
2311 cnt--;
2312
2313 if ((cnt != strlen(lpfc_soft_wwn_key)) ||
2314 (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0))
2315 return -EINVAL;
2316
2317 phba->soft_wwn_enable = 1;
2318
2319 dev_printk(KERN_WARNING, &phba->pcidev->dev,
2320 "lpfc%d: soft_wwpn assignment has been enabled.\n",
2321 phba->brd_no);
2322 dev_printk(KERN_WARNING, &phba->pcidev->dev,
2323 " The soft_wwpn feature is not supported by Broadcom.");
2324
2325 return count;
2326}
2327static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
2328 lpfc_soft_wwn_enable_store);
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338static ssize_t
2339lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr,
2340 char *buf)
2341{
2342 struct Scsi_Host *shost = class_to_shost(dev);
2343 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2344 struct lpfc_hba *phba = vport->phba;
2345
2346 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2347 (unsigned long long)phba->cfg_soft_wwpn);
2348}
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363static ssize_t
2364lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr,
2365 const char *buf, size_t count)
2366{
2367 struct Scsi_Host *shost = class_to_shost(dev);
2368 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2369 struct lpfc_hba *phba = vport->phba;
2370 struct completion online_compl;
2371 int stat1 = 0, stat2 = 0;
2372 unsigned int cnt = count;
2373 u8 wwpn[WWN_SZ];
2374 int rc;
2375
2376 if (!phba->cfg_enable_hba_reset)
2377 return -EACCES;
2378 spin_lock_irq(&phba->hbalock);
2379 if (phba->over_temp_state == HBA_OVER_TEMP) {
2380 spin_unlock_irq(&phba->hbalock);
2381 return -EACCES;
2382 }
2383 spin_unlock_irq(&phba->hbalock);
2384
2385 if (buf[cnt-1] == '\n')
2386 cnt--;
2387
2388 if (!phba->soft_wwn_enable)
2389 return -EINVAL;
2390
2391
2392 phba->soft_wwn_enable = 0;
2393
2394 rc = lpfc_wwn_set(buf, cnt, wwpn);
2395 if (rc) {
2396
2397 phba->soft_wwn_enable = 1;
2398 return rc;
2399 }
2400
2401 phba->cfg_soft_wwpn = wwn_to_u64(wwpn);
2402 fc_host_port_name(shost) = phba->cfg_soft_wwpn;
2403 if (phba->cfg_soft_wwnn)
2404 fc_host_node_name(shost) = phba->cfg_soft_wwnn;
2405
2406 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
2407 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no);
2408
2409 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
2410 if (stat1)
2411 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2412 "0463 lpfc_soft_wwpn attribute set failed to "
2413 "reinit adapter - %d\n", stat1);
2414 init_completion(&online_compl);
2415 rc = lpfc_workq_post_event(phba, &stat2, &online_compl,
2416 LPFC_EVT_ONLINE);
2417 if (rc == 0)
2418 return -ENOMEM;
2419
2420 wait_for_completion(&online_compl);
2421 if (stat2)
2422 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2423 "0464 lpfc_soft_wwpn attribute set failed to "
2424 "reinit adapter - %d\n", stat2);
2425 return (stat1 || stat2) ? -EIO : count;
2426}
2427static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,
2428 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store);
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438static ssize_t
2439lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr,
2440 char *buf)
2441{
2442 struct Scsi_Host *shost = class_to_shost(dev);
2443 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2444 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2445 (unsigned long long)phba->cfg_soft_wwnn);
2446}
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458static ssize_t
2459lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr,
2460 const char *buf, size_t count)
2461{
2462 struct Scsi_Host *shost = class_to_shost(dev);
2463 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2464 unsigned int cnt = count;
2465 u8 wwnn[WWN_SZ];
2466 int rc;
2467
2468
2469 if (buf[cnt-1] == '\n')
2470 cnt--;
2471
2472 if (!phba->soft_wwn_enable)
2473 return -EINVAL;
2474
2475 rc = lpfc_wwn_set(buf, cnt, wwnn);
2476 if (rc) {
2477
2478
2479
2480 return rc;
2481 }
2482
2483 phba->cfg_soft_wwnn = wwn_to_u64(wwnn);
2484
2485 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
2486 "lpfc%d: soft_wwnn set. Value will take effect upon "
2487 "setting of the soft_wwpn\n", phba->brd_no);
2488
2489 return count;
2490}
2491static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,
2492 lpfc_soft_wwnn_show, lpfc_soft_wwnn_store);
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504static ssize_t
2505lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr,
2506 char *buf)
2507{
2508 struct Scsi_Host *shost = class_to_shost(dev);
2509 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2510
2511 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2512 wwn_to_u64(phba->cfg_oas_tgt_wwpn));
2513}
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528static ssize_t
2529lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr,
2530 const char *buf, size_t count)
2531{
2532 struct Scsi_Host *shost = class_to_shost(dev);
2533 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2534 unsigned int cnt = count;
2535 uint8_t wwpn[WWN_SZ];
2536 int rc;
2537
2538 if (!phba->cfg_fof)
2539 return -EPERM;
2540
2541
2542 if (buf[cnt-1] == '\n')
2543 cnt--;
2544
2545 rc = lpfc_wwn_set(buf, cnt, wwpn);
2546 if (rc)
2547 return rc;
2548
2549 memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t)));
2550 memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t)));
2551 if (wwn_to_u64(wwpn) == 0)
2552 phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET;
2553 else
2554 phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET;
2555 phba->cfg_oas_flags &= ~OAS_LUN_VALID;
2556 phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN;
2557 return count;
2558}
2559static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR,
2560 lpfc_oas_tgt_show, lpfc_oas_tgt_store);
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572static ssize_t
2573lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr,
2574 char *buf)
2575{
2576 struct Scsi_Host *shost = class_to_shost(dev);
2577 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2578
2579 return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority);
2580}
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595static ssize_t
2596lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr,
2597 const char *buf, size_t count)
2598{
2599 struct Scsi_Host *shost = class_to_shost(dev);
2600 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2601 unsigned int cnt = count;
2602 unsigned long val;
2603 int ret;
2604
2605 if (!phba->cfg_fof)
2606 return -EPERM;
2607
2608
2609 if (buf[cnt-1] == '\n')
2610 cnt--;
2611
2612 ret = kstrtoul(buf, 0, &val);
2613 if (ret || (val > 0x7f))
2614 return -EINVAL;
2615
2616 if (val)
2617 phba->cfg_oas_priority = (uint8_t)val;
2618 else
2619 phba->cfg_oas_priority = phba->cfg_XLanePriority;
2620 return count;
2621}
2622static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR,
2623 lpfc_oas_priority_show, lpfc_oas_priority_store);
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635static ssize_t
2636lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr,
2637 char *buf)
2638{
2639 struct Scsi_Host *shost = class_to_shost(dev);
2640 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2641
2642 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
2643 wwn_to_u64(phba->cfg_oas_vpt_wwpn));
2644}
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659static ssize_t
2660lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr,
2661 const char *buf, size_t count)
2662{
2663 struct Scsi_Host *shost = class_to_shost(dev);
2664 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2665 unsigned int cnt = count;
2666 uint8_t wwpn[WWN_SZ];
2667 int rc;
2668
2669 if (!phba->cfg_fof)
2670 return -EPERM;
2671
2672
2673 if (buf[cnt-1] == '\n')
2674 cnt--;
2675
2676 rc = lpfc_wwn_set(buf, cnt, wwpn);
2677 if (rc)
2678 return rc;
2679
2680 memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t)));
2681 memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t)));
2682 if (wwn_to_u64(wwpn) == 0)
2683 phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT;
2684 else
2685 phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT;
2686 phba->cfg_oas_flags &= ~OAS_LUN_VALID;
2687 if (phba->cfg_oas_priority == 0)
2688 phba->cfg_oas_priority = phba->cfg_XLanePriority;
2689 phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN;
2690 return count;
2691}
2692static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR,
2693 lpfc_oas_vpt_show, lpfc_oas_vpt_store);
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706static ssize_t
2707lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr,
2708 char *buf)
2709{
2710 struct Scsi_Host *shost = class_to_shost(dev);
2711 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2712
2713 return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state);
2714}
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730static ssize_t
2731lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr,
2732 const char *buf, size_t count)
2733{
2734 struct Scsi_Host *shost = class_to_shost(dev);
2735 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2736 int val = 0;
2737
2738 if (!phba->cfg_fof)
2739 return -EPERM;
2740
2741 if (!isdigit(buf[0]))
2742 return -EINVAL;
2743
2744 if (sscanf(buf, "%i", &val) != 1)
2745 return -EINVAL;
2746
2747 if ((val != 0) && (val != 1))
2748 return -EINVAL;
2749
2750 phba->cfg_oas_lun_state = val;
2751 return strlen(buf);
2752}
2753static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR,
2754 lpfc_oas_lun_state_show, lpfc_oas_lun_state_store);
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767static ssize_t
2768lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr,
2769 char *buf)
2770{
2771 struct Scsi_Host *shost = class_to_shost(dev);
2772 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2773
2774 if (!(phba->cfg_oas_flags & OAS_LUN_VALID))
2775 return -EFAULT;
2776
2777 return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status);
2778}
2779static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO,
2780 lpfc_oas_lun_status_show, NULL);
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796static size_t
2797lpfc_oas_lun_state_set(struct lpfc_hba *phba, uint8_t vpt_wwpn[],
2798 uint8_t tgt_wwpn[], uint64_t lun,
2799 uint32_t oas_state, uint8_t pri)
2800{
2801
2802 int rc = 0;
2803
2804 if (!phba->cfg_fof)
2805 return -EPERM;
2806
2807 if (oas_state) {
2808 if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn,
2809 (struct lpfc_name *)tgt_wwpn,
2810 lun, pri))
2811 rc = -ENOMEM;
2812 } else {
2813 lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn,
2814 (struct lpfc_name *)tgt_wwpn, lun, pri);
2815 }
2816 return rc;
2817
2818}
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836static uint64_t
2837lpfc_oas_lun_get_next(struct lpfc_hba *phba, uint8_t vpt_wwpn[],
2838 uint8_t tgt_wwpn[], uint32_t *lun_status,
2839 uint32_t *lun_pri)
2840{
2841 uint64_t found_lun;
2842
2843 if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn)
2844 return NOT_OAS_ENABLED_LUN;
2845 if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *)
2846 phba->sli4_hba.oas_next_vpt_wwpn,
2847 (struct lpfc_name *)
2848 phba->sli4_hba.oas_next_tgt_wwpn,
2849 &phba->sli4_hba.oas_next_lun,
2850 (struct lpfc_name *)vpt_wwpn,
2851 (struct lpfc_name *)tgt_wwpn,
2852 &found_lun, lun_status, lun_pri))
2853 return found_lun;
2854 else
2855 return NOT_OAS_ENABLED_LUN;
2856}
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874static ssize_t
2875lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[],
2876 uint8_t tgt_wwpn[], uint64_t lun,
2877 uint32_t oas_state, uint8_t pri)
2878{
2879
2880 int rc;
2881
2882 rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun,
2883 oas_state, pri);
2884 return rc;
2885}
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901static ssize_t
2902lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr,
2903 char *buf)
2904{
2905 struct Scsi_Host *shost = class_to_shost(dev);
2906 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2907
2908 uint64_t oas_lun;
2909 int len = 0;
2910
2911 if (!phba->cfg_fof)
2912 return -EPERM;
2913
2914 if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0)
2915 if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT))
2916 return -EFAULT;
2917
2918 if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0)
2919 if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET))
2920 return -EFAULT;
2921
2922 oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn,
2923 phba->cfg_oas_tgt_wwpn,
2924 &phba->cfg_oas_lun_status,
2925 &phba->cfg_oas_priority);
2926 if (oas_lun != NOT_OAS_ENABLED_LUN)
2927 phba->cfg_oas_flags |= OAS_LUN_VALID;
2928
2929 len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun);
2930
2931 return len;
2932}
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949static ssize_t
2950lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr,
2951 const char *buf, size_t count)
2952{
2953 struct Scsi_Host *shost = class_to_shost(dev);
2954 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2955 uint64_t scsi_lun;
2956 uint32_t pri;
2957 ssize_t rc;
2958
2959 if (!phba->cfg_fof)
2960 return -EPERM;
2961
2962 if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0)
2963 return -EFAULT;
2964
2965 if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0)
2966 return -EFAULT;
2967
2968 if (!isdigit(buf[0]))
2969 return -EINVAL;
2970
2971 if (sscanf(buf, "0x%llx", &scsi_lun) != 1)
2972 return -EINVAL;
2973
2974 pri = phba->cfg_oas_priority;
2975 if (pri == 0)
2976 pri = phba->cfg_XLanePriority;
2977
2978 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
2979 "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx "
2980 "priority 0x%x with oas state %d\n",
2981 wwn_to_u64(phba->cfg_oas_vpt_wwpn),
2982 wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun,
2983 pri, phba->cfg_oas_lun_state);
2984
2985 rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn,
2986 phba->cfg_oas_tgt_wwpn, scsi_lun,
2987 phba->cfg_oas_lun_state, pri);
2988 if (rc)
2989 return rc;
2990
2991 return count;
2992}
2993static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR,
2994 lpfc_oas_lun_show, lpfc_oas_lun_store);
2995
2996int lpfc_enable_nvmet_cnt;
2997unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = {
2998 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2999 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3000module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444);
3001MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target");
3002
3003static int lpfc_poll = 0;
3004module_param(lpfc_poll, int, S_IRUGO);
3005MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
3006 " 0 - none,"
3007 " 1 - poll with interrupts enabled"
3008 " 3 - poll and disable FCP ring interrupts");
3009
3010static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
3011 lpfc_poll_show, lpfc_poll_store);
3012
3013int lpfc_no_hba_reset_cnt;
3014unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = {
3015 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3016module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444);
3017MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset");
3018
3019LPFC_ATTR(sli_mode, 0, 0, 3,
3020 "SLI mode selector:"
3021 " 0 - auto (SLI-3 if supported),"
3022 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
3023 " 3 - select SLI-3");
3024
3025LPFC_ATTR_R(enable_npiv, 1, 0, 1,
3026 "Enable NPIV functionality");
3027
3028LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2,
3029 "FCF Fast failover=1 Priority failover=2");
3030
3031
3032
3033
3034
3035
3036
3037LPFC_ATTR_R(enable_rrq, 2, 0, 2,
3038 "Enable RRQ functionality");
3039
3040
3041
3042
3043
3044
3045
3046
3047LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK,
3048 LPFC_DELAY_INIT_LINK_INDEFINITELY,
3049 "Suppress Link Up at initialization");
3050
3051
3052
3053
3054
3055
3056
3057
3058static ssize_t
3059lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf)
3060{
3061 struct Scsi_Host *shost = class_to_shost(dev);
3062 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
3063
3064 return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max);
3065}
3066
3067static DEVICE_ATTR(iocb_hw, S_IRUGO,
3068 lpfc_iocb_hw_show, NULL);
3069static ssize_t
3070lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf)
3071{
3072 struct Scsi_Host *shost = class_to_shost(dev);
3073 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
3074 struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba);
3075
3076 return snprintf(buf, PAGE_SIZE, "%d\n", pring->txq_max);
3077}
3078
3079static DEVICE_ATTR(txq_hw, S_IRUGO,
3080 lpfc_txq_hw_show, NULL);
3081static ssize_t
3082lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr,
3083 char *buf)
3084{
3085 struct Scsi_Host *shost = class_to_shost(dev);
3086 struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
3087 struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba);
3088
3089 return snprintf(buf, PAGE_SIZE, "%d\n", pring->txcmplq_max);
3090}
3091
3092static DEVICE_ATTR(txcmplq_hw, S_IRUGO,
3093 lpfc_txcmplq_hw_show, NULL);
3094
3095LPFC_ATTR_R(iocb_cnt, 2, 1, 5,
3096 "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs");
3097
3098
3099
3100
3101
3102static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
3103static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO;
3104module_param(lpfc_nodev_tmo, int, 0);
3105MODULE_PARM_DESC(lpfc_nodev_tmo,
3106 "Seconds driver will hold I/O waiting "
3107 "for a device to come back");
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117static ssize_t
3118lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr,
3119 char *buf)
3120{
3121 struct Scsi_Host *shost = class_to_shost(dev);
3122 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3123
3124 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
3125}
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142static int
3143lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
3144{
3145 if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) {
3146 vport->cfg_nodev_tmo = vport->cfg_devloss_tmo;
3147 if (val != LPFC_DEF_DEVLOSS_TMO)
3148 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3149 "0407 Ignoring lpfc_nodev_tmo module "
3150 "parameter because lpfc_devloss_tmo "
3151 "is set.\n");
3152 return 0;
3153 }
3154
3155 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
3156 vport->cfg_nodev_tmo = val;
3157 vport->cfg_devloss_tmo = val;
3158 return 0;
3159 }
3160 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3161 "0400 lpfc_nodev_tmo attribute cannot be set to"
3162 " %d, allowed range is [%d, %d]\n",
3163 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
3164 vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
3165 return -EINVAL;
3166}
3167
3168
3169
3170
3171
3172
3173
3174
3175static void
3176lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
3177{
3178 struct Scsi_Host *shost;
3179 struct lpfc_nodelist *ndlp;
3180
3181 shost = lpfc_shost_from_vport(vport);
3182 spin_lock_irq(shost->host_lock);
3183 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
3184 if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport)
3185 ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo;
3186 spin_unlock_irq(shost->host_lock);
3187}
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204static int
3205lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
3206{
3207 if (vport->dev_loss_tmo_changed ||
3208 (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) {
3209 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3210 "0401 Ignoring change to lpfc_nodev_tmo "
3211 "because lpfc_devloss_tmo is set.\n");
3212 return 0;
3213 }
3214 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
3215 vport->cfg_nodev_tmo = val;
3216 vport->cfg_devloss_tmo = val;
3217
3218
3219
3220
3221 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val;
3222 lpfc_update_rport_devloss_tmo(vport);
3223 return 0;
3224 }
3225 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3226 "0403 lpfc_nodev_tmo attribute cannot be set to "
3227 "%d, allowed range is [%d, %d]\n",
3228 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
3229 return -EINVAL;
3230}
3231
3232lpfc_vport_param_store(nodev_tmo)
3233
3234static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR,
3235 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store);
3236
3237
3238
3239
3240
3241
3242module_param(lpfc_devloss_tmo, int, S_IRUGO);
3243MODULE_PARM_DESC(lpfc_devloss_tmo,
3244 "Seconds driver will hold I/O waiting "
3245 "for a device to come back");
3246lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO,
3247 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO)
3248lpfc_vport_param_show(devloss_tmo)
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264static int
3265lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
3266{
3267 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
3268 vport->cfg_nodev_tmo = val;
3269 vport->cfg_devloss_tmo = val;
3270 vport->dev_loss_tmo_changed = 1;
3271 fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val;
3272 lpfc_update_rport_devloss_tmo(vport);
3273 return 0;
3274 }
3275
3276 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3277 "0404 lpfc_devloss_tmo attribute cannot be set to "
3278 "%d, allowed range is [%d, %d]\n",
3279 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
3280 return -EINVAL;
3281}
3282
3283lpfc_vport_param_store(devloss_tmo)
3284static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
3285 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store);
3286
3287
3288
3289
3290
3291
3292
3293LPFC_ATTR_R(suppress_rsp, 1, 0, 1,
3294 "Enable suppress rsp feature is firmware supports it");
3295
3296
3297
3298
3299
3300
3301
3302LPFC_ATTR_R(nvmet_mrq,
3303 1, 1, 16,
3304 "Specify number of RQ pairs for processing NVMET cmds");
3305
3306
3307
3308
3309
3310LPFC_ATTR_R(nvmet_mrq_post, LPFC_DEF_MRQ_POST,
3311 LPFC_MIN_MRQ_POST, LPFC_MAX_MRQ_POST,
3312 "Specify number of buffers to post on every MRQ");
3313
3314
3315
3316
3317
3318
3319
3320LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_FCP,
3321 LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH,
3322 "Define fc4 type to register with fabric.");
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337LPFC_ATTR_R(xri_split, 50, 10, 90,
3338 "Division of XRI resources between SCSI and NVME");
3339
3340
3341
3342
3343
3344
3345
3346LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff,
3347 "Verbose logging bit-mask");
3348
3349
3350
3351
3352
3353LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1,
3354 "Deregister nameserver objects before LOGO");
3355
3356
3357
3358
3359
3360
3361
3362
3363LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512,
3364 "Max number of FCP commands we can queue to a specific LUN");
3365
3366
3367
3368
3369
3370LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535,
3371 "Max number of FCP commands we can queue to a specific target port");
3372
3373
3374
3375
3376
3377
3378
3379
3380LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
3381 "Max number of FCP commands we can queue to a lpfc HBA");
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1,
3393 "Allow peer ports on the same physical port to login to each "
3394 "other.");
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407static int lpfc_restrict_login = 1;
3408module_param(lpfc_restrict_login, int, S_IRUGO);
3409MODULE_PARM_DESC(lpfc_restrict_login,
3410 "Restrict virtual ports login to remote initiators.");
3411lpfc_vport_param_show(restrict_login);
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428static int
3429lpfc_restrict_login_init(struct lpfc_vport *vport, int val)
3430{
3431 if (val < 0 || val > 1) {
3432 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3433 "0422 lpfc_restrict_login attribute cannot "
3434 "be set to %d, allowed range is [0, 1]\n",
3435 val);
3436 vport->cfg_restrict_login = 1;
3437 return -EINVAL;
3438 }
3439 if (vport->port_type == LPFC_PHYSICAL_PORT) {
3440 vport->cfg_restrict_login = 0;
3441 return 0;
3442 }
3443 vport->cfg_restrict_login = val;
3444 return 0;
3445}
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463static int
3464lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
3465{
3466 if (val < 0 || val > 1) {
3467 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3468 "0425 lpfc_restrict_login attribute cannot "
3469 "be set to %d, allowed range is [0, 1]\n",
3470 val);
3471 vport->cfg_restrict_login = 1;
3472 return -EINVAL;
3473 }
3474 if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) {
3475 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3476 "0468 lpfc_restrict_login must be 0 for "
3477 "Physical ports.\n");
3478 vport->cfg_restrict_login = 0;
3479 return 0;
3480 }
3481 vport->cfg_restrict_login = val;
3482 return 0;
3483}
3484lpfc_vport_param_store(restrict_login);
3485static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR,
3486 lpfc_restrict_login_show, lpfc_restrict_login_store);
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1,
3506 "Start scanning for devices from highest ALPA to lowest");
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519LPFC_ATTR(topology, 0, 0, 6,
3520 "Select Fibre Channel topology");
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538static ssize_t
3539lpfc_topology_store(struct device *dev, struct device_attribute *attr,
3540 const char *buf, size_t count)
3541{
3542 struct Scsi_Host *shost = class_to_shost(dev);
3543 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3544 struct lpfc_hba *phba = vport->phba;
3545 int val = 0;
3546 int nolip = 0;
3547 const char *val_buf = buf;
3548 int err;
3549 uint32_t prev_val;
3550
3551 if (!strncmp(buf, "nolip ", strlen("nolip "))) {
3552 nolip = 1;
3553 val_buf = &buf[strlen("nolip ")];
3554 }
3555
3556 if (!isdigit(val_buf[0]))
3557 return -EINVAL;
3558 if (sscanf(val_buf, "%i", &val) != 1)
3559 return -EINVAL;
3560
3561 if (val >= 0 && val <= 6) {
3562 prev_val = phba->cfg_topology;
3563 if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G &&
3564 val == 4) {
3565 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3566 "3113 Loop mode not supported at speed %d\n",
3567 val);
3568 return -EINVAL;
3569 }
3570 if (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC &&
3571 val == 4) {
3572 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3573 "3114 Loop mode not supported\n");
3574 return -EINVAL;
3575 }
3576 phba->cfg_topology = val;
3577 if (nolip)
3578 return strlen(buf);
3579
3580 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3581 "3054 lpfc_topology changed from %d to %d\n",
3582 prev_val, val);
3583 if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4)
3584 phba->fc_topology_changed = 1;
3585 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
3586 if (err) {
3587 phba->cfg_topology = prev_val;
3588 return -EINVAL;
3589 } else
3590 return strlen(buf);
3591 }
3592 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3593 "%d:0467 lpfc_topology attribute cannot be set to %d, "
3594 "allowed range is [0, 6]\n",
3595 phba->brd_no, val);
3596 return -EINVAL;
3597}
3598
3599lpfc_param_show(topology)
3600static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR,
3601 lpfc_topology_show, lpfc_topology_store);
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614static ssize_t
3615lpfc_static_vport_show(struct device *dev, struct device_attribute *attr,
3616 char *buf)
3617{
3618 struct Scsi_Host *shost = class_to_shost(dev);
3619 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3620 if (vport->vport_flag & STATIC_VPORT)
3621 sprintf(buf, "1\n");
3622 else
3623 sprintf(buf, "0\n");
3624
3625 return strlen(buf);
3626}
3627
3628
3629
3630
3631static DEVICE_ATTR(lpfc_static_vport, S_IRUGO,
3632 lpfc_static_vport_show, NULL);
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653static ssize_t
3654lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr,
3655 const char *buf, size_t count)
3656{
3657 struct Scsi_Host *shost = class_to_shost(dev);
3658 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3659 struct lpfc_hba *phba = vport->phba;
3660#define LPFC_MAX_DATA_CTRL_LEN 1024
3661 static char bucket_data[LPFC_MAX_DATA_CTRL_LEN];
3662 unsigned long i;
3663 char *str_ptr, *token;
3664 struct lpfc_vport **vports;
3665 struct Scsi_Host *v_shost;
3666 char *bucket_type_str, *base_str, *step_str;
3667 unsigned long base, step, bucket_type;
3668
3669 if (!strncmp(buf, "setbucket", strlen("setbucket"))) {
3670 if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1))
3671 return -EINVAL;
3672
3673 strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN);
3674 str_ptr = &bucket_data[0];
3675
3676 token = strsep(&str_ptr, "\t ");
3677 if (!token)
3678 return -EINVAL;
3679
3680 bucket_type_str = strsep(&str_ptr, "\t ");
3681 if (!bucket_type_str)
3682 return -EINVAL;
3683
3684 if (!strncmp(bucket_type_str, "linear", strlen("linear")))
3685 bucket_type = LPFC_LINEAR_BUCKET;
3686 else if (!strncmp(bucket_type_str, "power2", strlen("power2")))
3687 bucket_type = LPFC_POWER2_BUCKET;
3688 else
3689 return -EINVAL;
3690
3691 base_str = strsep(&str_ptr, "\t ");
3692 if (!base_str)
3693 return -EINVAL;
3694 base = simple_strtoul(base_str, NULL, 0);
3695
3696 step_str = strsep(&str_ptr, "\t ");
3697 if (!step_str)
3698 return -EINVAL;
3699 step = simple_strtoul(step_str, NULL, 0);
3700 if (!step)
3701 return -EINVAL;
3702
3703
3704 vports = lpfc_create_vport_work_array(phba);
3705 if (vports == NULL)
3706 return -ENOMEM;
3707
3708 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
3709 v_shost = lpfc_shost_from_vport(vports[i]);
3710 spin_lock_irq(v_shost->host_lock);
3711
3712 vports[i]->stat_data_blocked = 1;
3713 if (vports[i]->stat_data_enabled)
3714 lpfc_vport_reset_stat_data(vports[i]);
3715 spin_unlock_irq(v_shost->host_lock);
3716 }
3717
3718
3719 phba->bucket_type = bucket_type;
3720 phba->bucket_base = base;
3721 phba->bucket_step = step;
3722
3723 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
3724 v_shost = lpfc_shost_from_vport(vports[i]);
3725
3726
3727 spin_lock_irq(v_shost->host_lock);
3728 vports[i]->stat_data_blocked = 0;
3729 spin_unlock_irq(v_shost->host_lock);
3730 }
3731 lpfc_destroy_vport_work_array(phba, vports);
3732 return strlen(buf);
3733 }
3734
3735 if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) {
3736 vports = lpfc_create_vport_work_array(phba);
3737 if (vports == NULL)
3738 return -ENOMEM;
3739
3740 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
3741 v_shost = lpfc_shost_from_vport(vports[i]);
3742 spin_lock_irq(shost->host_lock);
3743 vports[i]->stat_data_blocked = 1;
3744 lpfc_free_bucket(vport);
3745 vport->stat_data_enabled = 0;
3746 vports[i]->stat_data_blocked = 0;
3747 spin_unlock_irq(shost->host_lock);
3748 }
3749 lpfc_destroy_vport_work_array(phba, vports);
3750 phba->bucket_type = LPFC_NO_BUCKET;
3751 phba->bucket_base = 0;
3752 phba->bucket_step = 0;
3753 return strlen(buf);
3754 }
3755
3756 if (!strncmp(buf, "start", strlen("start"))) {
3757
3758 if (phba->bucket_type == LPFC_NO_BUCKET)
3759 return -EINVAL;
3760 spin_lock_irq(shost->host_lock);
3761 if (vport->stat_data_enabled) {
3762 spin_unlock_irq(shost->host_lock);
3763 return strlen(buf);
3764 }
3765 lpfc_alloc_bucket(vport);
3766 vport->stat_data_enabled = 1;
3767 spin_unlock_irq(shost->host_lock);
3768 return strlen(buf);
3769 }
3770
3771 if (!strncmp(buf, "stop", strlen("stop"))) {
3772 spin_lock_irq(shost->host_lock);
3773 if (vport->stat_data_enabled == 0) {
3774 spin_unlock_irq(shost->host_lock);
3775 return strlen(buf);
3776 }
3777 lpfc_free_bucket(vport);
3778 vport->stat_data_enabled = 0;
3779 spin_unlock_irq(shost->host_lock);
3780 return strlen(buf);
3781 }
3782
3783 if (!strncmp(buf, "reset", strlen("reset"))) {
3784 if ((phba->bucket_type == LPFC_NO_BUCKET)
3785 || !vport->stat_data_enabled)
3786 return strlen(buf);
3787 spin_lock_irq(shost->host_lock);
3788 vport->stat_data_blocked = 1;
3789 lpfc_vport_reset_stat_data(vport);
3790 vport->stat_data_blocked = 0;
3791 spin_unlock_irq(shost->host_lock);
3792 return strlen(buf);
3793 }
3794 return -EINVAL;
3795}
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807static ssize_t
3808lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr,
3809 char *buf)
3810{
3811 struct Scsi_Host *shost = class_to_shost(dev);
3812 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3813 struct lpfc_hba *phba = vport->phba;
3814 int index = 0;
3815 int i;
3816 char *bucket_type;
3817 unsigned long bucket_value;
3818
3819 switch (phba->bucket_type) {
3820 case LPFC_LINEAR_BUCKET:
3821 bucket_type = "linear";
3822 break;
3823 case LPFC_POWER2_BUCKET:
3824 bucket_type = "power2";
3825 break;
3826 default:
3827 bucket_type = "No Bucket";
3828 break;
3829 }
3830
3831 sprintf(&buf[index], "Statistical Data enabled :%d, "
3832 "blocked :%d, Bucket type :%s, Bucket base :%d,"
3833 " Bucket step :%d\nLatency Ranges :",
3834 vport->stat_data_enabled, vport->stat_data_blocked,
3835 bucket_type, phba->bucket_base, phba->bucket_step);
3836 index = strlen(buf);
3837 if (phba->bucket_type != LPFC_NO_BUCKET) {
3838 for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) {
3839 if (phba->bucket_type == LPFC_LINEAR_BUCKET)
3840 bucket_value = phba->bucket_base +
3841 phba->bucket_step * i;
3842 else
3843 bucket_value = phba->bucket_base +
3844 (1 << i) * phba->bucket_step;
3845
3846 if (index + 10 > PAGE_SIZE)
3847 break;
3848 sprintf(&buf[index], "%08ld ", bucket_value);
3849 index = strlen(buf);
3850 }
3851 }
3852 sprintf(&buf[index], "\n");
3853 return strlen(buf);
3854}
3855
3856
3857
3858
3859static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR,
3860 lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store);
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870#define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18)
3871#define MAX_STAT_DATA_SIZE_PER_TARGET \
3872 STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT)
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888static ssize_t
3889sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj,
3890 struct bin_attribute *bin_attr,
3891 char *buf, loff_t off, size_t count)
3892{
3893 struct device *dev = container_of(kobj, struct device,
3894 kobj);
3895 struct Scsi_Host *shost = class_to_shost(dev);
3896 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3897 struct lpfc_hba *phba = vport->phba;
3898 int i = 0, index = 0;
3899 unsigned long nport_index;
3900 struct lpfc_nodelist *ndlp = NULL;
3901 nport_index = (unsigned long)off /
3902 MAX_STAT_DATA_SIZE_PER_TARGET;
3903
3904 if (!vport->stat_data_enabled || vport->stat_data_blocked
3905 || (phba->bucket_type == LPFC_NO_BUCKET))
3906 return 0;
3907
3908 spin_lock_irq(shost->host_lock);
3909 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
3910 if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data)
3911 continue;
3912
3913 if (nport_index > 0) {
3914 nport_index--;
3915 continue;
3916 }
3917
3918 if ((index + MAX_STAT_DATA_SIZE_PER_TARGET)
3919 > count)
3920 break;
3921
3922 if (!ndlp->lat_data)
3923 continue;
3924
3925
3926 sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:",
3927 ndlp->nlp_portname.u.wwn[0],
3928 ndlp->nlp_portname.u.wwn[1],
3929 ndlp->nlp_portname.u.wwn[2],
3930 ndlp->nlp_portname.u.wwn[3],
3931 ndlp->nlp_portname.u.wwn[4],
3932 ndlp->nlp_portname.u.wwn[5],
3933 ndlp->nlp_portname.u.wwn[6],
3934 ndlp->nlp_portname.u.wwn[7]);
3935
3936 index = strlen(buf);
3937
3938 for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) {
3939 sprintf(&buf[index], "%010u,",
3940 ndlp->lat_data[i].cmd_count);
3941 index = strlen(buf);
3942 }
3943 sprintf(&buf[index], "\n");
3944 index = strlen(buf);
3945 }
3946 spin_unlock_irq(shost->host_lock);
3947 return index;
3948}
3949
3950static struct bin_attribute sysfs_drvr_stat_data_attr = {
3951 .attr = {
3952 .name = "lpfc_drvr_stat_data",
3953 .mode = S_IRUSR,
3954 },
3955 .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET,
3956 .read = sysfs_drvr_stat_data_read,
3957 .write = NULL,
3958};
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982static ssize_t
3983lpfc_link_speed_store(struct device *dev, struct device_attribute *attr,
3984 const char *buf, size_t count)
3985{
3986 struct Scsi_Host *shost = class_to_shost(dev);
3987 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3988 struct lpfc_hba *phba = vport->phba;
3989 int val = LPFC_USER_LINK_SPEED_AUTO;
3990 int nolip = 0;
3991 const char *val_buf = buf;
3992 int err;
3993 uint32_t prev_val, if_type;
3994
3995 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf);
3996 if (if_type == LPFC_SLI_INTF_IF_TYPE_2 &&
3997 phba->hba_flag & HBA_FORCED_LINK_SPEED)
3998 return -EPERM;
3999
4000 if (!strncmp(buf, "nolip ", strlen("nolip "))) {
4001 nolip = 1;
4002 val_buf = &buf[strlen("nolip ")];
4003 }
4004
4005 if (!isdigit(val_buf[0]))
4006 return -EINVAL;
4007 if (sscanf(val_buf, "%i", &val) != 1)
4008 return -EINVAL;
4009
4010 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
4011 "3055 lpfc_link_speed changed from %d to %d %s\n",
4012 phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)");
4013
4014 if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) ||
4015 ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) ||
4016 ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) ||
4017 ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) ||
4018 ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) ||
4019 ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) ||
4020 ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb))) {
4021 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4022 "2879 lpfc_link_speed attribute cannot be set "
4023 "to %d. Speed is not supported by this port.\n",
4024 val);
4025 return -EINVAL;
4026 }
4027 if (val == LPFC_USER_LINK_SPEED_16G &&
4028 phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
4029 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4030 "3112 lpfc_link_speed attribute cannot be set "
4031 "to %d. Speed is not supported in loop mode.\n",
4032 val);
4033 return -EINVAL;
4034 }
4035 if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) &&
4036 (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) {
4037 prev_val = phba->cfg_link_speed;
4038 phba->cfg_link_speed = val;
4039 if (nolip)
4040 return strlen(buf);
4041
4042 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
4043 if (err) {
4044 phba->cfg_link_speed = prev_val;
4045 return -EINVAL;
4046 } else
4047 return strlen(buf);
4048 }
4049 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4050 "0469 lpfc_link_speed attribute cannot be set to %d, "
4051 "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val);
4052 return -EINVAL;
4053}
4054
4055static int lpfc_link_speed = 0;
4056module_param(lpfc_link_speed, int, S_IRUGO);
4057MODULE_PARM_DESC(lpfc_link_speed, "Select link speed");
4058lpfc_param_show(link_speed)
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076static int
4077lpfc_link_speed_init(struct lpfc_hba *phba, int val)
4078{
4079 if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) {
4080 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4081 "3111 lpfc_link_speed of %d cannot "
4082 "support loop mode, setting topology to default.\n",
4083 val);
4084 phba->cfg_topology = 0;
4085 }
4086 if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) &&
4087 (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) {
4088 phba->cfg_link_speed = val;
4089 return 0;
4090 }
4091 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4092 "0405 lpfc_link_speed attribute cannot "
4093 "be set to %d, allowed values are "
4094 "["LPFC_LINK_SPEED_STRING"]\n", val);
4095 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO;
4096 return -EINVAL;
4097}
4098
4099static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR,
4100 lpfc_link_speed_show, lpfc_link_speed_store);
4101
4102
4103
4104
4105
4106
4107
4108LPFC_ATTR(aer_support, 1, 0, 1,
4109 "Enable PCIe device AER support");
4110lpfc_param_show(aer_support)
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139static ssize_t
4140lpfc_aer_support_store(struct device *dev, struct device_attribute *attr,
4141 const char *buf, size_t count)
4142{
4143 struct Scsi_Host *shost = class_to_shost(dev);
4144 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4145 struct lpfc_hba *phba = vport->phba;
4146 int val = 0, rc = -EINVAL;
4147
4148 if (!isdigit(buf[0]))
4149 return -EINVAL;
4150 if (sscanf(buf, "%i", &val) != 1)
4151 return -EINVAL;
4152
4153 switch (val) {
4154 case 0:
4155 if (phba->hba_flag & HBA_AER_ENABLED) {
4156 rc = pci_disable_pcie_error_reporting(phba->pcidev);
4157 if (!rc) {
4158 spin_lock_irq(&phba->hbalock);
4159 phba->hba_flag &= ~HBA_AER_ENABLED;
4160 spin_unlock_irq(&phba->hbalock);
4161 phba->cfg_aer_support = 0;
4162 rc = strlen(buf);
4163 } else
4164 rc = -EPERM;
4165 } else {
4166 phba->cfg_aer_support = 0;
4167 rc = strlen(buf);
4168 }
4169 break;
4170 case 1:
4171 if (!(phba->hba_flag & HBA_AER_ENABLED)) {
4172 rc = pci_enable_pcie_error_reporting(phba->pcidev);
4173 if (!rc) {
4174 spin_lock_irq(&phba->hbalock);
4175 phba->hba_flag |= HBA_AER_ENABLED;
4176 spin_unlock_irq(&phba->hbalock);
4177 phba->cfg_aer_support = 1;
4178 rc = strlen(buf);
4179 } else
4180 rc = -EPERM;
4181 } else {
4182 phba->cfg_aer_support = 1;
4183 rc = strlen(buf);
4184 }
4185 break;
4186 default:
4187 rc = -EINVAL;
4188 break;
4189 }
4190 return rc;
4191}
4192
4193static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR,
4194 lpfc_aer_support_show, lpfc_aer_support_store);
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215static ssize_t
4216lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr,
4217 const char *buf, size_t count)
4218{
4219 struct Scsi_Host *shost = class_to_shost(dev);
4220 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4221 struct lpfc_hba *phba = vport->phba;
4222 int val, rc = -1;
4223
4224 if (!isdigit(buf[0]))
4225 return -EINVAL;
4226 if (sscanf(buf, "%i", &val) != 1)
4227 return -EINVAL;
4228 if (val != 1)
4229 return -EINVAL;
4230
4231 if (phba->hba_flag & HBA_AER_ENABLED)
4232 rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev);
4233
4234 if (rc == 0)
4235 return strlen(buf);
4236 else
4237 return -EPERM;
4238}
4239
4240static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL,
4241 lpfc_aer_cleanup_state);
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282static ssize_t
4283lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr,
4284 const char *buf, size_t count)
4285{
4286 struct Scsi_Host *shost = class_to_shost(dev);
4287 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4288 struct lpfc_hba *phba = vport->phba;
4289 struct pci_dev *pdev = phba->pcidev;
4290 int val = 0, rc = -EINVAL;
4291
4292
4293 if (!isdigit(buf[0]))
4294 return -EINVAL;
4295 if (sscanf(buf, "%i", &val) != 1)
4296 return -EINVAL;
4297 if (val < 0)
4298 return -EINVAL;
4299
4300
4301 if (val == 0) {
4302 if (phba->cfg_sriov_nr_virtfn > 0) {
4303 pci_disable_sriov(pdev);
4304 phba->cfg_sriov_nr_virtfn = 0;
4305 }
4306 return strlen(buf);
4307 }
4308
4309
4310 if (phba->cfg_sriov_nr_virtfn > 0) {
4311 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4312 "3018 There are %d virtual functions "
4313 "enabled on physical function.\n",
4314 phba->cfg_sriov_nr_virtfn);
4315 return -EEXIST;
4316 }
4317
4318 if (val <= LPFC_MAX_VFN_PER_PFN)
4319 phba->cfg_sriov_nr_virtfn = val;
4320 else {
4321 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4322 "3019 Enabling %d virtual functions is not "
4323 "allowed.\n", val);
4324 return -EINVAL;
4325 }
4326
4327 rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn);
4328 if (rc) {
4329 phba->cfg_sriov_nr_virtfn = 0;
4330 rc = -EPERM;
4331 } else
4332 rc = strlen(buf);
4333
4334 return rc;
4335}
4336
4337LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN,
4338 "Enable PCIe device SR-IOV virtual fn");
4339
4340lpfc_param_show(sriov_nr_virtfn)
4341static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR,
4342 lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store);
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359static ssize_t
4360lpfc_request_firmware_upgrade_store(struct device *dev,
4361 struct device_attribute *attr,
4362 const char *buf, size_t count)
4363{
4364 struct Scsi_Host *shost = class_to_shost(dev);
4365 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4366 struct lpfc_hba *phba = vport->phba;
4367 int val = 0, rc = -EINVAL;
4368
4369
4370 if (!isdigit(buf[0]))
4371 return -EINVAL;
4372 if (sscanf(buf, "%i", &val) != 1)
4373 return -EINVAL;
4374 if (val != 1)
4375 return -EINVAL;
4376
4377 rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE);
4378 if (rc)
4379 rc = -EPERM;
4380 else
4381 rc = strlen(buf);
4382 return rc;
4383}
4384
4385static int lpfc_req_fw_upgrade;
4386module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR);
4387MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade");
4388lpfc_param_show(request_firmware_upgrade)
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402static int
4403lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val)
4404{
4405 if (val >= 0 && val <= 1) {
4406 phba->cfg_request_firmware_upgrade = val;
4407 return 0;
4408 }
4409 return -EINVAL;
4410}
4411static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR,
4412 lpfc_request_firmware_upgrade_show,
4413 lpfc_request_firmware_upgrade_store);
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432static ssize_t
4433lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr,
4434 const char *buf, size_t count)
4435{
4436 struct Scsi_Host *shost = class_to_shost(dev);
4437 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4438 struct lpfc_hba *phba = vport->phba;
4439 int val = 0, i;
4440
4441
4442 if (phba->sli_rev != LPFC_SLI_REV4)
4443 return -EINVAL;
4444
4445
4446 if (!isdigit(buf[0]))
4447 return -EINVAL;
4448 if (sscanf(buf, "%i", &val) != 1)
4449 return -EINVAL;
4450
4451
4452
4453
4454
4455
4456 if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX))
4457 return -EINVAL;
4458
4459 phba->cfg_fcp_imax = (uint32_t)val;
4460
4461 for (i = 0; i < phba->io_channel_irqs; i += LPFC_MAX_EQ_DELAY_EQID_CNT)
4462 lpfc_modify_hba_eq_delay(phba, i);
4463
4464 return strlen(buf);
4465}
4466
4467
4468
4469
4470
4471
4472
4473static int lpfc_fcp_imax = LPFC_DEF_IMAX;
4474module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR);
4475MODULE_PARM_DESC(lpfc_fcp_imax,
4476 "Set the maximum number of FCP interrupts per second per HBA");
4477lpfc_param_show(fcp_imax)
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492static int
4493lpfc_fcp_imax_init(struct lpfc_hba *phba, int val)
4494{
4495 if (phba->sli_rev != LPFC_SLI_REV4) {
4496 phba->cfg_fcp_imax = 0;
4497 return 0;
4498 }
4499
4500 if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) ||
4501 (val == 0)) {
4502 phba->cfg_fcp_imax = val;
4503 return 0;
4504 }
4505
4506 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4507 "3016 lpfc_fcp_imax: %d out of range, using default\n",
4508 val);
4509 phba->cfg_fcp_imax = LPFC_DEF_IMAX;
4510
4511 return 0;
4512}
4513
4514static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR,
4515 lpfc_fcp_imax_show, lpfc_fcp_imax_store);
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525static ssize_t
4526lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr,
4527 char *buf)
4528{
4529 struct Scsi_Host *shost = class_to_shost(dev);
4530 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
4531 struct lpfc_hba *phba = vport->phba;
4532 struct lpfc_vector_map_info *cpup;
4533 int len = 0;
4534
4535 if ((phba->sli_rev != LPFC_SLI_REV4) ||
4536 (phba->intr_type != MSIX))
4537 return len;
4538
4539 switch (phba->cfg_fcp_cpu_map) {
4540 case 0:
4541 len += snprintf(buf + len, PAGE_SIZE-len,
4542 "fcp_cpu_map: No mapping (%d)\n",
4543 phba->cfg_fcp_cpu_map);
4544 return len;
4545 case 1:
4546 len += snprintf(buf + len, PAGE_SIZE-len,
4547 "fcp_cpu_map: HBA centric mapping (%d): "
4548 "%d online CPUs\n",
4549 phba->cfg_fcp_cpu_map,
4550 phba->sli4_hba.num_online_cpu);
4551 break;
4552 case 2:
4553 len += snprintf(buf + len, PAGE_SIZE-len,
4554 "fcp_cpu_map: Driver centric mapping (%d): "
4555 "%d online CPUs\n",
4556 phba->cfg_fcp_cpu_map,
4557 phba->sli4_hba.num_online_cpu);
4558 break;
4559 }
4560
4561 while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) {
4562 cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu];
4563
4564
4565 if (cpup->irq == LPFC_VECTOR_MAP_EMPTY)
4566 len += snprintf(buf + len, PAGE_SIZE-len,
4567 "CPU %02d io_chan %02d "
4568 "physid %d coreid %d\n",
4569 phba->sli4_hba.curr_disp_cpu,
4570 cpup->channel_id, cpup->phys_id,
4571 cpup->core_id);
4572 else
4573 len += snprintf(buf + len, PAGE_SIZE-len,
4574 "CPU %02d io_chan %02d "
4575 "physid %d coreid %d IRQ %d\n",
4576 phba->sli4_hba.curr_disp_cpu,
4577 cpup->channel_id, cpup->phys_id,
4578 cpup->core_id, cpup->irq);
4579
4580 phba->sli4_hba.curr_disp_cpu++;
4581
4582
4583 if (phba->sli4_hba.curr_disp_cpu <
4584 phba->sli4_hba.num_present_cpu &&
4585 (len >= (PAGE_SIZE - 64))) {
4586 len += snprintf(buf + len, PAGE_SIZE-len, "more...\n");
4587 break;
4588 }
4589 }
4590
4591 if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu)
4592 phba->sli4_hba.curr_disp_cpu = 0;
4593
4594 return len;
4595}
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607static ssize_t
4608lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr,
4609 const char *buf, size_t count)
4610{
4611 int status = -EINVAL;
4612 return status;
4613}
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP;
4627module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR);
4628MODULE_PARM_DESC(lpfc_fcp_cpu_map,
4629 "Defines how to map CPUs to IRQ vectors per HBA");
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644static int
4645lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val)
4646{
4647 if (phba->sli_rev != LPFC_SLI_REV4) {
4648 phba->cfg_fcp_cpu_map = 0;
4649 return 0;
4650 }
4651
4652 if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) {
4653 phba->cfg_fcp_cpu_map = val;
4654 return 0;
4655 }
4656
4657 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4658 "3326 lpfc_fcp_cpu_map: %d out of range, using "
4659 "default\n", val);
4660 phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP;
4661
4662 return 0;
4663}
4664
4665static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR,
4666 lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store);
4667
4668
4669
4670
4671
4672LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
4673 "Select Fibre Channel class of service for FCP sequences");
4674
4675
4676
4677
4678
4679LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
4680 "Use ADISC on rediscovery to authenticate FCP devices");
4681
4682
4683
4684
4685
4686
4687LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536,
4688 "First burst size for Targets that support first burst");
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536,
4700 "NVME Target mode first burst size in 512B increments.");
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1,
4714 "Enable First Burst feature on I and T functions.");
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000,
4725 "Use command completion time to control queue depth");
4726
4727lpfc_vport_param_show(max_scsicmpl_time);
4728static int
4729lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val)
4730{
4731 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4732 struct lpfc_nodelist *ndlp, *next_ndlp;
4733
4734 if (val == vport->cfg_max_scsicmpl_time)
4735 return 0;
4736 if ((val < 0) || (val > 60000))
4737 return -EINVAL;
4738 vport->cfg_max_scsicmpl_time = val;
4739
4740 spin_lock_irq(shost->host_lock);
4741 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
4742 if (!NLP_CHK_NODE_ACT(ndlp))
4743 continue;
4744 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
4745 continue;
4746 ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth;
4747 }
4748 spin_unlock_irq(shost->host_lock);
4749 return 0;
4750}
4751lpfc_vport_param_store(max_scsicmpl_time);
4752static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR,
4753 lpfc_max_scsicmpl_time_show,
4754 lpfc_max_scsicmpl_time_store);
4755
4756
4757
4758
4759
4760LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_ROUND_ROBIN,
4778 LPFC_FCP_SCHED_ROUND_ROBIN,
4779 LPFC_FCP_SCHED_BY_CPU,
4780 "Determine scheduling algorithm for "
4781 "issuing commands [0] - Round Robin, [1] - Current CPU");
4782
4783
4784
4785
4786
4787
4788
4789LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for "
4790 "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset");
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an "
4801 "interrupt response is generated");
4802
4803LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an "
4804 "interrupt response is generated");
4805
4806
4807
4808
4809
4810
4811LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
4812 "SLI rings to spread IOCB entries across");
4813
4814
4815
4816
4817
4818
4819LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1,
4820 255, "Identifies RCTL for additional ring configuration");
4821
4822
4823
4824
4825
4826
4827LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1,
4828 255, "Identifies TYPE for additional ring configuration");
4829
4830
4831
4832
4833
4834
4835
4836
4837LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality");
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850LPFC_ATTR_R(fdmi_on, 0, 0, 1, "Enable FDMI support");
4851
4852
4853
4854
4855
4856LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
4857 "during discovery");
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID");
4882
4883
4884
4885
4886
4887LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
4888 "Milliseconds driver will wait between polling FCP ring");
4889
4890
4891
4892
4893
4894LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180,
4895 "Maximum time to wait for task management commands to complete");
4896
4897
4898
4899
4900
4901
4902
4903
4904LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
4905 "MSI-X (2), if possible");
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915LPFC_ATTR_RW(nvme_oas, 0, 0, 1,
4916 "Use OAS bit on NVME IOs");
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928LPFC_ATTR_R(fcp_io_channel,
4929 LPFC_FCP_IO_CHAN_DEF,
4930 LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX,
4931 "Set the number of FCP I/O channels");
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950LPFC_ATTR_R(nvme_io_channel,
4951 LPFC_NVME_IO_CHAN_DEF,
4952 LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX,
4953 "Set the number of NVME I/O channels");
4954
4955
4956
4957
4958
4959
4960
4961LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver.");
4962
4963
4964
4965
4966
4967
4968
4969LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat.");
4970
4971
4972
4973
4974
4975
4976
4977LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature.");
4978
4979
4980
4981
4982
4983
4984LPFC_ATTR_RW(XLanePriority, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
4985
4986
4987
4988
4989
4990
4991
4992LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF;
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019LPFC_ATTR(prot_mask,
5020 (SHOST_DIF_TYPE1_PROTECTION |
5021 SHOST_DIX_TYPE0_PROTECTION |
5022 SHOST_DIX_TYPE1_PROTECTION),
5023 0,
5024 (SHOST_DIF_TYPE1_PROTECTION |
5025 SHOST_DIX_TYPE0_PROTECTION |
5026 SHOST_DIX_TYPE1_PROTECTION),
5027 "T10-DIF host protection capabilities mask");
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037LPFC_ATTR(prot_guard,
5038 SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP,
5039 "T10-DIF host protection guard type");
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055LPFC_ATTR(delay_discovery, 0, 0, 1,
5056 "Delay NPort discovery when Clean Address bit is cleared.");
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
5068 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
5069
5070
5071
5072
5073
5074
5075
5076LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics");
5077
5078struct device_attribute *lpfc_hba_attrs[] = {
5079 &dev_attr_nvme_info,
5080 &dev_attr_bg_info,
5081 &dev_attr_bg_guard_err,
5082 &dev_attr_bg_apptag_err,
5083 &dev_attr_bg_reftag_err,
5084 &dev_attr_info,
5085 &dev_attr_serialnum,
5086 &dev_attr_modeldesc,
5087 &dev_attr_modelname,
5088 &dev_attr_programtype,
5089 &dev_attr_portnum,
5090 &dev_attr_fwrev,
5091 &dev_attr_hdw,
5092 &dev_attr_option_rom_version,
5093 &dev_attr_link_state,
5094 &dev_attr_num_discovered_ports,
5095 &dev_attr_menlo_mgmt_mode,
5096 &dev_attr_lpfc_drvr_version,
5097 &dev_attr_lpfc_enable_fip,
5098 &dev_attr_lpfc_temp_sensor,
5099 &dev_attr_lpfc_log_verbose,
5100 &dev_attr_lpfc_lun_queue_depth,
5101 &dev_attr_lpfc_tgt_queue_depth,
5102 &dev_attr_lpfc_hba_queue_depth,
5103 &dev_attr_lpfc_peer_port_login,
5104 &dev_attr_lpfc_nodev_tmo,
5105 &dev_attr_lpfc_devloss_tmo,
5106 &dev_attr_lpfc_enable_fc4_type,
5107 &dev_attr_lpfc_xri_split,
5108 &dev_attr_lpfc_fcp_class,
5109 &dev_attr_lpfc_use_adisc,
5110 &dev_attr_lpfc_first_burst_size,
5111 &dev_attr_lpfc_ack0,
5112 &dev_attr_lpfc_topology,
5113 &dev_attr_lpfc_scan_down,
5114 &dev_attr_lpfc_link_speed,
5115 &dev_attr_lpfc_fcp_io_sched,
5116 &dev_attr_lpfc_fcp2_no_tgt_reset,
5117 &dev_attr_lpfc_cr_delay,
5118 &dev_attr_lpfc_cr_count,
5119 &dev_attr_lpfc_multi_ring_support,
5120 &dev_attr_lpfc_multi_ring_rctl,
5121 &dev_attr_lpfc_multi_ring_type,
5122 &dev_attr_lpfc_fdmi_on,
5123 &dev_attr_lpfc_enable_SmartSAN,
5124 &dev_attr_lpfc_max_luns,
5125 &dev_attr_lpfc_enable_npiv,
5126 &dev_attr_lpfc_fcf_failover_policy,
5127 &dev_attr_lpfc_enable_rrq,
5128 &dev_attr_nport_evt_cnt,
5129 &dev_attr_board_mode,
5130 &dev_attr_max_vpi,
5131 &dev_attr_used_vpi,
5132 &dev_attr_max_rpi,
5133 &dev_attr_used_rpi,
5134 &dev_attr_max_xri,
5135 &dev_attr_used_xri,
5136 &dev_attr_npiv_info,
5137 &dev_attr_issue_reset,
5138 &dev_attr_lpfc_poll,
5139 &dev_attr_lpfc_poll_tmo,
5140 &dev_attr_lpfc_task_mgmt_tmo,
5141 &dev_attr_lpfc_use_msi,
5142 &dev_attr_lpfc_nvme_oas,
5143 &dev_attr_lpfc_fcp_imax,
5144 &dev_attr_lpfc_fcp_cpu_map,
5145 &dev_attr_lpfc_fcp_io_channel,
5146 &dev_attr_lpfc_suppress_rsp,
5147 &dev_attr_lpfc_nvme_io_channel,
5148 &dev_attr_lpfc_nvmet_mrq,
5149 &dev_attr_lpfc_nvmet_mrq_post,
5150 &dev_attr_lpfc_nvme_enable_fb,
5151 &dev_attr_lpfc_nvmet_fb_size,
5152 &dev_attr_lpfc_enable_bg,
5153 &dev_attr_lpfc_soft_wwnn,
5154 &dev_attr_lpfc_soft_wwpn,
5155 &dev_attr_lpfc_soft_wwn_enable,
5156 &dev_attr_lpfc_enable_hba_reset,
5157 &dev_attr_lpfc_enable_hba_heartbeat,
5158 &dev_attr_lpfc_EnableXLane,
5159 &dev_attr_lpfc_XLanePriority,
5160 &dev_attr_lpfc_xlane_lun,
5161 &dev_attr_lpfc_xlane_tgt,
5162 &dev_attr_lpfc_xlane_vpt,
5163 &dev_attr_lpfc_xlane_lun_state,
5164 &dev_attr_lpfc_xlane_lun_status,
5165 &dev_attr_lpfc_xlane_priority,
5166 &dev_attr_lpfc_sg_seg_cnt,
5167 &dev_attr_lpfc_max_scsicmpl_time,
5168 &dev_attr_lpfc_stat_data_ctrl,
5169 &dev_attr_lpfc_aer_support,
5170 &dev_attr_lpfc_aer_state_cleanup,
5171 &dev_attr_lpfc_sriov_nr_virtfn,
5172 &dev_attr_lpfc_req_fw_upgrade,
5173 &dev_attr_lpfc_suppress_link_up,
5174 &dev_attr_lpfc_iocb_cnt,
5175 &dev_attr_iocb_hw,
5176 &dev_attr_txq_hw,
5177 &dev_attr_txcmplq_hw,
5178 &dev_attr_lpfc_fips_level,
5179 &dev_attr_lpfc_fips_rev,
5180 &dev_attr_lpfc_dss,
5181 &dev_attr_lpfc_sriov_hw_max_virtfn,
5182 &dev_attr_protocol,
5183 &dev_attr_lpfc_xlane_supported,
5184 &dev_attr_lpfc_enable_mds_diags,
5185 NULL,
5186};
5187
5188struct device_attribute *lpfc_vport_attrs[] = {
5189 &dev_attr_info,
5190 &dev_attr_link_state,
5191 &dev_attr_num_discovered_ports,
5192 &dev_attr_lpfc_drvr_version,
5193 &dev_attr_lpfc_log_verbose,
5194 &dev_attr_lpfc_lun_queue_depth,
5195 &dev_attr_lpfc_tgt_queue_depth,
5196 &dev_attr_lpfc_nodev_tmo,
5197 &dev_attr_lpfc_devloss_tmo,
5198 &dev_attr_lpfc_hba_queue_depth,
5199 &dev_attr_lpfc_peer_port_login,
5200 &dev_attr_lpfc_restrict_login,
5201 &dev_attr_lpfc_fcp_class,
5202 &dev_attr_lpfc_use_adisc,
5203 &dev_attr_lpfc_first_burst_size,
5204 &dev_attr_lpfc_max_luns,
5205 &dev_attr_nport_evt_cnt,
5206 &dev_attr_npiv_info,
5207 &dev_attr_lpfc_enable_da_id,
5208 &dev_attr_lpfc_max_scsicmpl_time,
5209 &dev_attr_lpfc_stat_data_ctrl,
5210 &dev_attr_lpfc_static_vport,
5211 &dev_attr_lpfc_fips_level,
5212 &dev_attr_lpfc_fips_rev,
5213 NULL,
5214};
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235static ssize_t
5236sysfs_ctlreg_write(struct file *filp, struct kobject *kobj,
5237 struct bin_attribute *bin_attr,
5238 char *buf, loff_t off, size_t count)
5239{
5240 size_t buf_off;
5241 struct device *dev = container_of(kobj, struct device, kobj);
5242 struct Scsi_Host *shost = class_to_shost(dev);
5243 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5244 struct lpfc_hba *phba = vport->phba;
5245
5246 if (phba->sli_rev >= LPFC_SLI_REV4)
5247 return -EPERM;
5248
5249 if ((off + count) > FF_REG_AREA_SIZE)
5250 return -ERANGE;
5251
5252 if (count <= LPFC_REG_WRITE_KEY_SIZE)
5253 return 0;
5254
5255 if (off % 4 || count % 4 || (unsigned long)buf % 4)
5256 return -EINVAL;
5257
5258
5259 if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE))
5260 return -EINVAL;
5261
5262 if (!(vport->fc_flag & FC_OFFLINE_MODE))
5263 return -EPERM;
5264
5265 spin_lock_irq(&phba->hbalock);
5266 for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE;
5267 buf_off += sizeof(uint32_t))
5268 writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)),
5269 phba->ctrl_regs_memmap_p + off + buf_off);
5270
5271 spin_unlock_irq(&phba->hbalock);
5272
5273 return count;
5274}
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294static ssize_t
5295sysfs_ctlreg_read(struct file *filp, struct kobject *kobj,
5296 struct bin_attribute *bin_attr,
5297 char *buf, loff_t off, size_t count)
5298{
5299 size_t buf_off;
5300 uint32_t * tmp_ptr;
5301 struct device *dev = container_of(kobj, struct device, kobj);
5302 struct Scsi_Host *shost = class_to_shost(dev);
5303 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5304 struct lpfc_hba *phba = vport->phba;
5305
5306 if (phba->sli_rev >= LPFC_SLI_REV4)
5307 return -EPERM;
5308
5309 if (off > FF_REG_AREA_SIZE)
5310 return -ERANGE;
5311
5312 if ((off + count) > FF_REG_AREA_SIZE)
5313 count = FF_REG_AREA_SIZE - off;
5314
5315 if (count == 0) return 0;
5316
5317 if (off % 4 || count % 4 || (unsigned long)buf % 4)
5318 return -EINVAL;
5319
5320 spin_lock_irq(&phba->hbalock);
5321
5322 for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) {
5323 tmp_ptr = (uint32_t *)(buf + buf_off);
5324 *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off);
5325 }
5326
5327 spin_unlock_irq(&phba->hbalock);
5328
5329 return count;
5330}
5331
5332static struct bin_attribute sysfs_ctlreg_attr = {
5333 .attr = {
5334 .name = "ctlreg",
5335 .mode = S_IRUSR | S_IWUSR,
5336 },
5337 .size = 256,
5338 .read = sysfs_ctlreg_read,
5339 .write = sysfs_ctlreg_write,
5340};
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358static ssize_t
5359sysfs_mbox_write(struct file *filp, struct kobject *kobj,
5360 struct bin_attribute *bin_attr,
5361 char *buf, loff_t off, size_t count)
5362{
5363 return -EPERM;
5364}
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382static ssize_t
5383sysfs_mbox_read(struct file *filp, struct kobject *kobj,
5384 struct bin_attribute *bin_attr,
5385 char *buf, loff_t off, size_t count)
5386{
5387 return -EPERM;
5388}
5389
5390static struct bin_attribute sysfs_mbox_attr = {
5391 .attr = {
5392 .name = "mbox",
5393 .mode = S_IRUSR | S_IWUSR,
5394 },
5395 .size = MAILBOX_SYSFS_MAX,
5396 .read = sysfs_mbox_read,
5397 .write = sysfs_mbox_write,
5398};
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408int
5409lpfc_alloc_sysfs_attr(struct lpfc_vport *vport)
5410{
5411 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5412 int error;
5413
5414 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
5415 &sysfs_drvr_stat_data_attr);
5416
5417
5418 if (error || vport->port_type == LPFC_NPIV_PORT)
5419 goto out;
5420
5421 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
5422 &sysfs_ctlreg_attr);
5423 if (error)
5424 goto out_remove_stat_attr;
5425
5426 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
5427 &sysfs_mbox_attr);
5428 if (error)
5429 goto out_remove_ctlreg_attr;
5430
5431 return 0;
5432out_remove_ctlreg_attr:
5433 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr);
5434out_remove_stat_attr:
5435 sysfs_remove_bin_file(&shost->shost_dev.kobj,
5436 &sysfs_drvr_stat_data_attr);
5437out:
5438 return error;
5439}
5440
5441
5442
5443
5444
5445void
5446lpfc_free_sysfs_attr(struct lpfc_vport *vport)
5447{
5448 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5449 sysfs_remove_bin_file(&shost->shost_dev.kobj,
5450 &sysfs_drvr_stat_data_attr);
5451
5452 if (vport->port_type == LPFC_NPIV_PORT)
5453 return;
5454 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr);
5455 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr);
5456}
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466static void
5467lpfc_get_host_symbolic_name(struct Scsi_Host *shost)
5468{
5469 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
5470
5471 lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost),
5472 sizeof fc_host_symbolic_name(shost));
5473}
5474
5475
5476
5477
5478
5479static void
5480lpfc_get_host_port_id(struct Scsi_Host *shost)
5481{
5482 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5483
5484
5485 fc_host_port_id(shost) = vport->fc_myDID;
5486}
5487
5488
5489
5490
5491
5492static void
5493lpfc_get_host_port_type(struct Scsi_Host *shost)
5494{
5495 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5496 struct lpfc_hba *phba = vport->phba;
5497
5498 spin_lock_irq(shost->host_lock);
5499
5500 if (vport->port_type == LPFC_NPIV_PORT) {
5501 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
5502 } else if (lpfc_is_link_up(phba)) {
5503 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
5504 if (vport->fc_flag & FC_PUBLIC_LOOP)
5505 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
5506 else
5507 fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
5508 } else {
5509 if (vport->fc_flag & FC_FABRIC)
5510 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
5511 else
5512 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
5513 }
5514 } else
5515 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
5516
5517 spin_unlock_irq(shost->host_lock);
5518}
5519
5520
5521
5522
5523
5524static void
5525lpfc_get_host_port_state(struct Scsi_Host *shost)
5526{
5527 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5528 struct lpfc_hba *phba = vport->phba;
5529
5530 spin_lock_irq(shost->host_lock);
5531
5532 if (vport->fc_flag & FC_OFFLINE_MODE)
5533 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
5534 else {
5535 switch (phba->link_state) {
5536 case LPFC_LINK_UNKNOWN:
5537 case LPFC_LINK_DOWN:
5538 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
5539 break;
5540 case LPFC_LINK_UP:
5541 case LPFC_CLEAR_LA:
5542 case LPFC_HBA_READY:
5543
5544 if (vport->port_state < LPFC_VPORT_READY)
5545 fc_host_port_state(shost) =
5546 FC_PORTSTATE_BYPASSED;
5547 else
5548 fc_host_port_state(shost) =
5549 FC_PORTSTATE_ONLINE;
5550 break;
5551 case LPFC_HBA_ERROR:
5552 fc_host_port_state(shost) = FC_PORTSTATE_ERROR;
5553 break;
5554 default:
5555 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
5556 break;
5557 }
5558 }
5559
5560 spin_unlock_irq(shost->host_lock);
5561}
5562
5563
5564
5565
5566
5567static void
5568lpfc_get_host_speed(struct Scsi_Host *shost)
5569{
5570 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5571 struct lpfc_hba *phba = vport->phba;
5572
5573 spin_lock_irq(shost->host_lock);
5574
5575 if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) {
5576 switch(phba->fc_linkspeed) {
5577 case LPFC_LINK_SPEED_1GHZ:
5578 fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
5579 break;
5580 case LPFC_LINK_SPEED_2GHZ:
5581 fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
5582 break;
5583 case LPFC_LINK_SPEED_4GHZ:
5584 fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
5585 break;
5586 case LPFC_LINK_SPEED_8GHZ:
5587 fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
5588 break;
5589 case LPFC_LINK_SPEED_10GHZ:
5590 fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
5591 break;
5592 case LPFC_LINK_SPEED_16GHZ:
5593 fc_host_speed(shost) = FC_PORTSPEED_16GBIT;
5594 break;
5595 case LPFC_LINK_SPEED_32GHZ:
5596 fc_host_speed(shost) = FC_PORTSPEED_32GBIT;
5597 break;
5598 default:
5599 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
5600 break;
5601 }
5602 } else
5603 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
5604
5605 spin_unlock_irq(shost->host_lock);
5606}
5607
5608
5609
5610
5611
5612static void
5613lpfc_get_host_fabric_name (struct Scsi_Host *shost)
5614{
5615 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5616 struct lpfc_hba *phba = vport->phba;
5617 u64 node_name;
5618
5619 spin_lock_irq(shost->host_lock);
5620
5621 if ((vport->port_state > LPFC_FLOGI) &&
5622 ((vport->fc_flag & FC_FABRIC) ||
5623 ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) &&
5624 (vport->fc_flag & FC_PUBLIC_LOOP))))
5625 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
5626 else
5627
5628 node_name = 0;
5629
5630 spin_unlock_irq(shost->host_lock);
5631
5632 fc_host_fabric_name(shost) = node_name;
5633}
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647static struct fc_host_statistics *
5648lpfc_get_stats(struct Scsi_Host *shost)
5649{
5650 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5651 struct lpfc_hba *phba = vport->phba;
5652 struct lpfc_sli *psli = &phba->sli;
5653 struct fc_host_statistics *hs = &phba->link_stats;
5654 struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets;
5655 LPFC_MBOXQ_t *pmboxq;
5656 MAILBOX_t *pmb;
5657 unsigned long seconds;
5658 int rc = 0;
5659
5660
5661
5662
5663
5664 if (phba->link_state < LPFC_LINK_DOWN ||
5665 !phba->mbox_mem_pool ||
5666 (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0)
5667 return NULL;
5668
5669 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
5670 return NULL;
5671
5672 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
5673 if (!pmboxq)
5674 return NULL;
5675 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
5676
5677 pmb = &pmboxq->u.mb;
5678 pmb->mbxCommand = MBX_READ_STATUS;
5679 pmb->mbxOwner = OWN_HOST;
5680 pmboxq->context1 = NULL;
5681 pmboxq->vport = vport;
5682
5683 if (vport->fc_flag & FC_OFFLINE_MODE)
5684 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
5685 else
5686 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
5687
5688 if (rc != MBX_SUCCESS) {
5689 if (rc != MBX_TIMEOUT)
5690 mempool_free(pmboxq, phba->mbox_mem_pool);
5691 return NULL;
5692 }
5693
5694 memset(hs, 0, sizeof (struct fc_host_statistics));
5695
5696 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
5697
5698
5699
5700
5701 hs->tx_words = (uint64_t)
5702 ((uint64_t)pmb->un.varRdStatus.xmitByteCnt
5703 * (uint64_t)256);
5704 hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
5705 hs->rx_words = (uint64_t)
5706 ((uint64_t)pmb->un.varRdStatus.rcvByteCnt
5707 * (uint64_t)256);
5708
5709 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
5710 pmb->mbxCommand = MBX_READ_LNK_STAT;
5711 pmb->mbxOwner = OWN_HOST;
5712 pmboxq->context1 = NULL;
5713 pmboxq->vport = vport;
5714
5715 if (vport->fc_flag & FC_OFFLINE_MODE)
5716 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
5717 else
5718 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
5719
5720 if (rc != MBX_SUCCESS) {
5721 if (rc != MBX_TIMEOUT)
5722 mempool_free(pmboxq, phba->mbox_mem_pool);
5723 return NULL;
5724 }
5725
5726 hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
5727 hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
5728 hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
5729 hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
5730 hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
5731 hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
5732 hs->error_frames = pmb->un.varRdLnk.crcCnt;
5733
5734 hs->link_failure_count -= lso->link_failure_count;
5735 hs->loss_of_sync_count -= lso->loss_of_sync_count;
5736 hs->loss_of_signal_count -= lso->loss_of_signal_count;
5737 hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count;
5738 hs->invalid_tx_word_count -= lso->invalid_tx_word_count;
5739 hs->invalid_crc_count -= lso->invalid_crc_count;
5740 hs->error_frames -= lso->error_frames;
5741
5742 if (phba->hba_flag & HBA_FCOE_MODE) {
5743 hs->lip_count = -1;
5744 hs->nos_count = (phba->link_events >> 1);
5745 hs->nos_count -= lso->link_events;
5746 } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
5747 hs->lip_count = (phba->fc_eventTag >> 1);
5748 hs->lip_count -= lso->link_events;
5749 hs->nos_count = -1;
5750 } else {
5751 hs->lip_count = -1;
5752 hs->nos_count = (phba->fc_eventTag >> 1);
5753 hs->nos_count -= lso->link_events;
5754 }
5755
5756 hs->dumped_frames = -1;
5757
5758 seconds = get_seconds();
5759 if (seconds < psli->stats_start)
5760 hs->seconds_since_last_reset = seconds +
5761 ((unsigned long)-1 - psli->stats_start);
5762 else
5763 hs->seconds_since_last_reset = seconds - psli->stats_start;
5764
5765 mempool_free(pmboxq, phba->mbox_mem_pool);
5766
5767 return hs;
5768}
5769
5770
5771
5772
5773
5774static void
5775lpfc_reset_stats(struct Scsi_Host *shost)
5776{
5777 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5778 struct lpfc_hba *phba = vport->phba;
5779 struct lpfc_sli *psli = &phba->sli;
5780 struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets;
5781 LPFC_MBOXQ_t *pmboxq;
5782 MAILBOX_t *pmb;
5783 int rc = 0;
5784
5785 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
5786 return;
5787
5788 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
5789 if (!pmboxq)
5790 return;
5791 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
5792
5793 pmb = &pmboxq->u.mb;
5794 pmb->mbxCommand = MBX_READ_STATUS;
5795 pmb->mbxOwner = OWN_HOST;
5796 pmb->un.varWords[0] = 0x1;
5797 pmboxq->context1 = NULL;
5798 pmboxq->vport = vport;
5799
5800 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
5801 (!(psli->sli_flag & LPFC_SLI_ACTIVE)))
5802 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
5803 else
5804 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
5805
5806 if (rc != MBX_SUCCESS) {
5807 if (rc != MBX_TIMEOUT)
5808 mempool_free(pmboxq, phba->mbox_mem_pool);
5809 return;
5810 }
5811
5812 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
5813 pmb->mbxCommand = MBX_READ_LNK_STAT;
5814 pmb->mbxOwner = OWN_HOST;
5815 pmboxq->context1 = NULL;
5816 pmboxq->vport = vport;
5817
5818 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
5819 (!(psli->sli_flag & LPFC_SLI_ACTIVE)))
5820 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
5821 else
5822 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
5823
5824 if (rc != MBX_SUCCESS) {
5825 if (rc != MBX_TIMEOUT)
5826 mempool_free( pmboxq, phba->mbox_mem_pool);
5827 return;
5828 }
5829
5830 lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
5831 lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
5832 lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
5833 lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
5834 lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
5835 lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
5836 lso->error_frames = pmb->un.varRdLnk.crcCnt;
5837 if (phba->hba_flag & HBA_FCOE_MODE)
5838 lso->link_events = (phba->link_events >> 1);
5839 else
5840 lso->link_events = (phba->fc_eventTag >> 1);
5841
5842 psli->stats_start = get_seconds();
5843
5844 mempool_free(pmboxq, phba->mbox_mem_pool);
5845
5846 return;
5847}
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862static struct lpfc_nodelist *
5863lpfc_get_node_by_target(struct scsi_target *starget)
5864{
5865 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
5866 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
5867 struct lpfc_nodelist *ndlp;
5868
5869 spin_lock_irq(shost->host_lock);
5870
5871 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
5872 if (NLP_CHK_NODE_ACT(ndlp) &&
5873 ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
5874 starget->id == ndlp->nlp_sid) {
5875 spin_unlock_irq(shost->host_lock);
5876 return ndlp;
5877 }
5878 }
5879 spin_unlock_irq(shost->host_lock);
5880 return NULL;
5881}
5882
5883
5884
5885
5886
5887static void
5888lpfc_get_starget_port_id(struct scsi_target *starget)
5889{
5890 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
5891
5892 fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1;
5893}
5894
5895
5896
5897
5898
5899
5900
5901static void
5902lpfc_get_starget_node_name(struct scsi_target *starget)
5903{
5904 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
5905
5906 fc_starget_node_name(starget) =
5907 ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0;
5908}
5909
5910
5911
5912
5913
5914
5915
5916static void
5917lpfc_get_starget_port_name(struct scsi_target *starget)
5918{
5919 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
5920
5921 fc_starget_port_name(starget) =
5922 ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0;
5923}
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934static void
5935lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
5936{
5937 if (timeout)
5938 rport->dev_loss_tmo = timeout;
5939 else
5940 rport->dev_loss_tmo = 1;
5941}
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955#define lpfc_rport_show_function(field, format_string, sz, cast) \
5956static ssize_t \
5957lpfc_show_rport_##field (struct device *dev, \
5958 struct device_attribute *attr, \
5959 char *buf) \
5960{ \
5961 struct fc_rport *rport = transport_class_to_rport(dev); \
5962 struct lpfc_rport_data *rdata = rport->hostdata; \
5963 return snprintf(buf, sz, format_string, \
5964 (rdata->target) ? cast rdata->target->field : 0); \
5965}
5966
5967#define lpfc_rport_rd_attr(field, format_string, sz) \
5968 lpfc_rport_show_function(field, format_string, sz, ) \
5969static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980static void
5981lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport)
5982{
5983 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
5984
5985 if (vport->port_state == LPFC_VPORT_READY)
5986 lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0);
5987}
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998static void
5999lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose)
6000{
6001 phba->cfg_log_verbose = verbose;
6002}
6003
6004struct fc_function_template lpfc_transport_functions = {
6005
6006 .show_host_node_name = 1,
6007 .show_host_port_name = 1,
6008 .show_host_supported_classes = 1,
6009 .show_host_supported_fc4s = 1,
6010 .show_host_supported_speeds = 1,
6011 .show_host_maxframe_size = 1,
6012
6013 .get_host_symbolic_name = lpfc_get_host_symbolic_name,
6014 .show_host_symbolic_name = 1,
6015
6016
6017 .get_host_port_id = lpfc_get_host_port_id,
6018 .show_host_port_id = 1,
6019
6020 .get_host_port_type = lpfc_get_host_port_type,
6021 .show_host_port_type = 1,
6022
6023 .get_host_port_state = lpfc_get_host_port_state,
6024 .show_host_port_state = 1,
6025
6026
6027 .show_host_active_fc4s = 1,
6028
6029 .get_host_speed = lpfc_get_host_speed,
6030 .show_host_speed = 1,
6031
6032 .get_host_fabric_name = lpfc_get_host_fabric_name,
6033 .show_host_fabric_name = 1,
6034
6035
6036
6037
6038
6039
6040 .get_fc_host_stats = lpfc_get_stats,
6041 .reset_fc_host_stats = lpfc_reset_stats,
6042
6043 .dd_fcrport_size = sizeof(struct lpfc_rport_data),
6044 .show_rport_maxframe_size = 1,
6045 .show_rport_supported_classes = 1,
6046
6047 .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
6048 .show_rport_dev_loss_tmo = 1,
6049
6050 .get_starget_port_id = lpfc_get_starget_port_id,
6051 .show_starget_port_id = 1,
6052
6053 .get_starget_node_name = lpfc_get_starget_node_name,
6054 .show_starget_node_name = 1,
6055
6056 .get_starget_port_name = lpfc_get_starget_port_name,
6057 .show_starget_port_name = 1,
6058
6059 .issue_fc_host_lip = lpfc_issue_lip,
6060 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
6061 .terminate_rport_io = lpfc_terminate_rport_io,
6062
6063 .dd_fcvport_size = sizeof(struct lpfc_vport *),
6064
6065 .vport_disable = lpfc_vport_disable,
6066
6067 .set_vport_symbolic_name = lpfc_set_vport_symbolic_name,
6068
6069 .bsg_request = lpfc_bsg_request,
6070 .bsg_timeout = lpfc_bsg_timeout,
6071};
6072
6073struct fc_function_template lpfc_vport_transport_functions = {
6074
6075 .show_host_node_name = 1,
6076 .show_host_port_name = 1,
6077 .show_host_supported_classes = 1,
6078 .show_host_supported_fc4s = 1,
6079 .show_host_supported_speeds = 1,
6080 .show_host_maxframe_size = 1,
6081
6082 .get_host_symbolic_name = lpfc_get_host_symbolic_name,
6083 .show_host_symbolic_name = 1,
6084
6085
6086 .get_host_port_id = lpfc_get_host_port_id,
6087 .show_host_port_id = 1,
6088
6089 .get_host_port_type = lpfc_get_host_port_type,
6090 .show_host_port_type = 1,
6091
6092 .get_host_port_state = lpfc_get_host_port_state,
6093 .show_host_port_state = 1,
6094
6095
6096 .show_host_active_fc4s = 1,
6097
6098 .get_host_speed = lpfc_get_host_speed,
6099 .show_host_speed = 1,
6100
6101 .get_host_fabric_name = lpfc_get_host_fabric_name,
6102 .show_host_fabric_name = 1,
6103
6104
6105
6106
6107
6108
6109 .get_fc_host_stats = lpfc_get_stats,
6110 .reset_fc_host_stats = lpfc_reset_stats,
6111
6112 .dd_fcrport_size = sizeof(struct lpfc_rport_data),
6113 .show_rport_maxframe_size = 1,
6114 .show_rport_supported_classes = 1,
6115
6116 .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
6117 .show_rport_dev_loss_tmo = 1,
6118
6119 .get_starget_port_id = lpfc_get_starget_port_id,
6120 .show_starget_port_id = 1,
6121
6122 .get_starget_node_name = lpfc_get_starget_node_name,
6123 .show_starget_node_name = 1,
6124
6125 .get_starget_port_name = lpfc_get_starget_port_name,
6126 .show_starget_port_name = 1,
6127
6128 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
6129 .terminate_rport_io = lpfc_terminate_rport_io,
6130
6131 .vport_disable = lpfc_vport_disable,
6132
6133 .set_vport_symbolic_name = lpfc_set_vport_symbolic_name,
6134};
6135
6136
6137
6138
6139
6140void
6141lpfc_get_cfgparam(struct lpfc_hba *phba)
6142{
6143 lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched);
6144 lpfc_fcp2_no_tgt_reset_init(phba, lpfc_fcp2_no_tgt_reset);
6145 lpfc_cr_delay_init(phba, lpfc_cr_delay);
6146 lpfc_cr_count_init(phba, lpfc_cr_count);
6147 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
6148 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
6149 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
6150 lpfc_ack0_init(phba, lpfc_ack0);
6151 lpfc_topology_init(phba, lpfc_topology);
6152 lpfc_link_speed_init(phba, lpfc_link_speed);
6153 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
6154 lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo);
6155 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
6156 lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy);
6157 lpfc_enable_rrq_init(phba, lpfc_enable_rrq);
6158 lpfc_fdmi_on_init(phba, lpfc_fdmi_on);
6159 lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN);
6160 lpfc_use_msi_init(phba, lpfc_use_msi);
6161 lpfc_nvme_oas_init(phba, lpfc_nvme_oas);
6162 lpfc_fcp_imax_init(phba, lpfc_fcp_imax);
6163 lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map);
6164 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
6165 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
6166
6167 lpfc_EnableXLane_init(phba, lpfc_EnableXLane);
6168 if (phba->sli_rev != LPFC_SLI_REV4)
6169 phba->cfg_EnableXLane = 0;
6170 lpfc_XLanePriority_init(phba, lpfc_XLanePriority);
6171
6172 memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t)));
6173 memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t)));
6174 phba->cfg_oas_lun_state = 0;
6175 phba->cfg_oas_lun_status = 0;
6176 phba->cfg_oas_flags = 0;
6177 phba->cfg_oas_priority = 0;
6178 lpfc_enable_bg_init(phba, lpfc_enable_bg);
6179 lpfc_prot_mask_init(phba, lpfc_prot_mask);
6180 lpfc_prot_guard_init(phba, lpfc_prot_guard);
6181 if (phba->sli_rev == LPFC_SLI_REV4)
6182 phba->cfg_poll = 0;
6183 else
6184 phba->cfg_poll = lpfc_poll;
6185 lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp);
6186
6187 lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type);
6188 lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq);
6189 lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post);
6190
6191
6192 lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb);
6193 lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size);
6194 lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel);
6195 lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel);
6196
6197 if (phba->sli_rev != LPFC_SLI_REV4) {
6198
6199 phba->nvmet_support = 0;
6200 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP;
6201 } else {
6202
6203 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
6204 phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP;
6205 }
6206
6207
6208 if (phba->cfg_fcp_io_channel == 0)
6209 phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu;
6210 if (phba->cfg_nvme_io_channel == 0)
6211 phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu;
6212
6213 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
6214 phba->cfg_fcp_io_channel = 0;
6215
6216 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP)
6217 phba->cfg_nvme_io_channel = 0;
6218
6219 if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel)
6220 phba->io_channel_irqs = phba->cfg_fcp_io_channel;
6221 else
6222 phba->io_channel_irqs = phba->cfg_nvme_io_channel;
6223
6224 phba->cfg_soft_wwnn = 0L;
6225 phba->cfg_soft_wwpn = 0L;
6226 lpfc_xri_split_init(phba, lpfc_xri_split);
6227 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
6228 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
6229 lpfc_hba_log_verbose_init(phba, lpfc_log_verbose);
6230 lpfc_aer_support_init(phba, lpfc_aer_support);
6231 lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn);
6232 lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade);
6233 lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up);
6234 lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt);
6235 lpfc_delay_discovery_init(phba, lpfc_delay_discovery);
6236 lpfc_sli_mode_init(phba, lpfc_sli_mode);
6237 phba->cfg_enable_dss = 1;
6238 lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags);
6239 return;
6240}
6241
6242
6243
6244
6245
6246
6247void
6248lpfc_nvme_mod_param_dep(struct lpfc_hba *phba)
6249{
6250 if (phba->cfg_nvme_io_channel > phba->sli4_hba.num_present_cpu)
6251 phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu;
6252
6253 if (phba->cfg_fcp_io_channel > phba->sli4_hba.num_present_cpu)
6254 phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu;
6255
6256 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME &&
6257 phba->nvmet_support) {
6258 phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP;
6259 phba->cfg_fcp_io_channel = 0;
6260
6261 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC,
6262 "6013 %s x%x fb_size x%x, fb_max x%x\n",
6263 "NVME Target PRLI ACC enable_fb ",
6264 phba->cfg_nvme_enable_fb,
6265 phba->cfg_nvmet_fb_size,
6266 LPFC_NVMET_FB_SZ_MAX);
6267
6268 if (phba->cfg_nvme_enable_fb == 0)
6269 phba->cfg_nvmet_fb_size = 0;
6270 else {
6271 if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX)
6272 phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX;
6273 }
6274
6275
6276 if (phba->cfg_nvmet_mrq > phba->cfg_nvme_io_channel) {
6277 phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel;
6278 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC,
6279 "6018 Adjust lpfc_nvmet_mrq to %d\n",
6280 phba->cfg_nvmet_mrq);
6281 }
6282 } else {
6283
6284 phba->nvmet_support = 0;
6285 phba->cfg_nvmet_mrq = 0;
6286 phba->cfg_nvmet_mrq_post = 0;
6287 phba->cfg_nvmet_fb_size = 0;
6288 }
6289
6290 if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel)
6291 phba->io_channel_irqs = phba->cfg_fcp_io_channel;
6292 else
6293 phba->io_channel_irqs = phba->cfg_nvme_io_channel;
6294}
6295
6296
6297
6298
6299
6300void
6301lpfc_get_vport_cfgparam(struct lpfc_vport *vport)
6302{
6303 lpfc_log_verbose_init(vport, lpfc_log_verbose);
6304 lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth);
6305 lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth);
6306 lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo);
6307 lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo);
6308 lpfc_peer_port_login_init(vport, lpfc_peer_port_login);
6309 lpfc_restrict_login_init(vport, lpfc_restrict_login);
6310 lpfc_fcp_class_init(vport, lpfc_fcp_class);
6311 lpfc_use_adisc_init(vport, lpfc_use_adisc);
6312 lpfc_first_burst_size_init(vport, lpfc_first_burst_size);
6313 lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time);
6314 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
6315 lpfc_max_luns_init(vport, lpfc_max_luns);
6316 lpfc_scan_down_init(vport, lpfc_scan_down);
6317 lpfc_enable_da_id_init(vport, lpfc_enable_da_id);
6318 return;
6319}
6320