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