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