]>
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. * |
d8e93df1 | 4 | * Copyright (C) 2004-2009 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> | |
0d878419 | 26 | #include <linux/aer.h> |
dea3101e | 27 | |
91886523 | 28 | #include <scsi/scsi.h> |
dea3101e JB |
29 | #include <scsi/scsi_device.h> |
30 | #include <scsi/scsi_host.h> | |
31 | #include <scsi/scsi_tcq.h> | |
32 | #include <scsi/scsi_transport_fc.h> | |
6a9c52cf | 33 | #include <scsi/fc/fc_fs.h> |
dea3101e | 34 | |
da0436e9 | 35 | #include "lpfc_hw4.h" |
dea3101e JB |
36 | #include "lpfc_hw.h" |
37 | #include "lpfc_sli.h" | |
da0436e9 | 38 | #include "lpfc_sli4.h" |
ea2151b4 | 39 | #include "lpfc_nl.h" |
dea3101e JB |
40 | #include "lpfc_disc.h" |
41 | #include "lpfc_scsi.h" | |
42 | #include "lpfc.h" | |
43 | #include "lpfc_logmsg.h" | |
44 | #include "lpfc_version.h" | |
45 | #include "lpfc_compat.h" | |
46 | #include "lpfc_crtn.h" | |
92d7f7b0 | 47 | #include "lpfc_vport.h" |
dea3101e | 48 | |
c01f3208 JS |
49 | #define LPFC_DEF_DEVLOSS_TMO 30 |
50 | #define LPFC_MIN_DEVLOSS_TMO 1 | |
51 | #define LPFC_MAX_DEVLOSS_TMO 255 | |
dea3101e | 52 | |
83108bd3 JS |
53 | #define LPFC_MAX_LINK_SPEED 8 |
54 | #define LPFC_LINK_SPEED_BITMAP 0x00000117 | |
55 | #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8" | |
56 | ||
e59058c4 | 57 | /** |
3621a710 | 58 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
e59058c4 JS |
59 | * @incr: integer to convert. |
60 | * @hdw: ascii string holding converted integer plus a string terminator. | |
61 | * | |
62 | * Description: | |
63 | * JEDEC Joint Electron Device Engineering Council. | |
64 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii | |
65 | * character string. The string is then terminated with a NULL in byte 9. | |
66 | * Hex 0-9 becomes ascii '0' to '9'. | |
67 | * Hex a-f becomes ascii '=' to 'B' capital B. | |
68 | * | |
69 | * Notes: | |
70 | * Coded for 32 bit integers only. | |
71 | **/ | |
dea3101e JB |
72 | static void |
73 | lpfc_jedec_to_ascii(int incr, char hdw[]) | |
74 | { | |
75 | int i, j; | |
76 | for (i = 0; i < 8; i++) { | |
77 | j = (incr & 0xf); | |
78 | if (j <= 9) | |
79 | hdw[7 - i] = 0x30 + j; | |
80 | else | |
81 | hdw[7 - i] = 0x61 + j - 10; | |
82 | incr = (incr >> 4); | |
83 | } | |
84 | hdw[8] = 0; | |
85 | return; | |
86 | } | |
87 | ||
e59058c4 | 88 | /** |
3621a710 | 89 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
e59058c4 JS |
90 | * @dev: class unused variable. |
91 | * @attr: device attribute, not used. | |
92 | * @buf: on return contains the module description text. | |
93 | * | |
94 | * Returns: size of formatted string. | |
95 | **/ | |
dea3101e | 96 | static ssize_t |
ee959b00 TJ |
97 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
98 | char *buf) | |
dea3101e JB |
99 | { |
100 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); | |
101 | } | |
102 | ||
45ed1190 JS |
103 | /** |
104 | * lpfc_enable_fip_show - Return the fip mode of the HBA | |
105 | * @dev: class unused variable. | |
106 | * @attr: device attribute, not used. | |
107 | * @buf: on return contains the module description text. | |
108 | * | |
109 | * Returns: size of formatted string. | |
110 | **/ | |
111 | static ssize_t | |
112 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, | |
113 | char *buf) | |
114 | { | |
115 | struct Scsi_Host *shost = class_to_shost(dev); | |
116 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
117 | struct lpfc_hba *phba = vport->phba; | |
118 | ||
119 | if (phba->hba_flag & HBA_FIP_SUPPORT) | |
120 | return snprintf(buf, PAGE_SIZE, "1\n"); | |
121 | else | |
122 | return snprintf(buf, PAGE_SIZE, "0\n"); | |
123 | } | |
124 | ||
81301a9b JS |
125 | static ssize_t |
126 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, | |
127 | char *buf) | |
128 | { | |
129 | struct Scsi_Host *shost = class_to_shost(dev); | |
130 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
131 | struct lpfc_hba *phba = vport->phba; | |
132 | ||
133 | if (phba->cfg_enable_bg) | |
134 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) | |
135 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); | |
136 | else | |
137 | return snprintf(buf, PAGE_SIZE, | |
138 | "BlockGuard Not Supported\n"); | |
139 | else | |
140 | return snprintf(buf, PAGE_SIZE, | |
141 | "BlockGuard Disabled\n"); | |
142 | } | |
143 | ||
144 | static ssize_t | |
145 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, | |
146 | char *buf) | |
147 | { | |
148 | struct Scsi_Host *shost = class_to_shost(dev); | |
149 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
150 | struct lpfc_hba *phba = vport->phba; | |
151 | ||
87b5c328 JS |
152 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
153 | (unsigned long long)phba->bg_guard_err_cnt); | |
81301a9b JS |
154 | } |
155 | ||
156 | static ssize_t | |
157 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, | |
158 | char *buf) | |
159 | { | |
160 | struct Scsi_Host *shost = class_to_shost(dev); | |
161 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
162 | struct lpfc_hba *phba = vport->phba; | |
163 | ||
87b5c328 JS |
164 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
165 | (unsigned long long)phba->bg_apptag_err_cnt); | |
81301a9b JS |
166 | } |
167 | ||
168 | static ssize_t | |
169 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, | |
170 | char *buf) | |
171 | { | |
172 | struct Scsi_Host *shost = class_to_shost(dev); | |
173 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
174 | struct lpfc_hba *phba = vport->phba; | |
175 | ||
87b5c328 JS |
176 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
177 | (unsigned long long)phba->bg_reftag_err_cnt); | |
81301a9b JS |
178 | } |
179 | ||
e59058c4 | 180 | /** |
3621a710 | 181 | * lpfc_info_show - Return some pci info about the host in ascii |
e59058c4 JS |
182 | * @dev: class converted to a Scsi_host structure. |
183 | * @attr: device attribute, not used. | |
184 | * @buf: on return contains the formatted text from lpfc_info(). | |
185 | * | |
186 | * Returns: size of formatted string. | |
187 | **/ | |
dea3101e | 188 | static ssize_t |
ee959b00 TJ |
189 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
190 | char *buf) | |
dea3101e | 191 | { |
ee959b00 | 192 | struct Scsi_Host *host = class_to_shost(dev); |
2e0fef85 | 193 | |
dea3101e JB |
194 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
195 | } | |
196 | ||
e59058c4 | 197 | /** |
3621a710 | 198 | * lpfc_serialnum_show - Return the hba serial number in ascii |
e59058c4 JS |
199 | * @dev: class converted to a Scsi_host structure. |
200 | * @attr: device attribute, not used. | |
201 | * @buf: on return contains the formatted text serial number. | |
202 | * | |
203 | * Returns: size of formatted string. | |
204 | **/ | |
dea3101e | 205 | static ssize_t |
ee959b00 TJ |
206 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
207 | char *buf) | |
dea3101e | 208 | { |
ee959b00 | 209 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
210 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
211 | struct lpfc_hba *phba = vport->phba; | |
212 | ||
dea3101e JB |
213 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
214 | } | |
215 | ||
e59058c4 | 216 | /** |
3621a710 | 217 | * lpfc_temp_sensor_show - Return the temperature sensor level |
e59058c4 JS |
218 | * @dev: class converted to a Scsi_host structure. |
219 | * @attr: device attribute, not used. | |
220 | * @buf: on return contains the formatted support level. | |
221 | * | |
222 | * Description: | |
223 | * Returns a number indicating the temperature sensor level currently | |
224 | * supported, zero or one in ascii. | |
225 | * | |
226 | * Returns: size of formatted string. | |
227 | **/ | |
57127f15 | 228 | static ssize_t |
ee959b00 TJ |
229 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
230 | char *buf) | |
57127f15 | 231 | { |
ee959b00 | 232 | struct Scsi_Host *shost = class_to_shost(dev); |
57127f15 JS |
233 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
234 | struct lpfc_hba *phba = vport->phba; | |
235 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); | |
236 | } | |
237 | ||
e59058c4 | 238 | /** |
3621a710 | 239 | * lpfc_modeldesc_show - Return the model description of the hba |
e59058c4 JS |
240 | * @dev: class converted to a Scsi_host structure. |
241 | * @attr: device attribute, not used. | |
242 | * @buf: on return contains the scsi vpd model description. | |
243 | * | |
244 | * Returns: size of formatted string. | |
245 | **/ | |
dea3101e | 246 | static ssize_t |
ee959b00 TJ |
247 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
248 | char *buf) | |
dea3101e | 249 | { |
ee959b00 | 250 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
251 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
252 | struct lpfc_hba *phba = vport->phba; | |
253 | ||
dea3101e JB |
254 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
255 | } | |
256 | ||
e59058c4 | 257 | /** |
3621a710 | 258 | * lpfc_modelname_show - Return the model name of the hba |
e59058c4 JS |
259 | * @dev: class converted to a Scsi_host structure. |
260 | * @attr: device attribute, not used. | |
261 | * @buf: on return contains the scsi vpd model name. | |
262 | * | |
263 | * Returns: size of formatted string. | |
264 | **/ | |
dea3101e | 265 | static ssize_t |
ee959b00 TJ |
266 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
267 | char *buf) | |
dea3101e | 268 | { |
ee959b00 | 269 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
270 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
271 | struct lpfc_hba *phba = vport->phba; | |
272 | ||
dea3101e JB |
273 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
274 | } | |
275 | ||
e59058c4 | 276 | /** |
3621a710 | 277 | * lpfc_programtype_show - Return the program type of the hba |
e59058c4 JS |
278 | * @dev: class converted to a Scsi_host structure. |
279 | * @attr: device attribute, not used. | |
280 | * @buf: on return contains the scsi vpd program type. | |
281 | * | |
282 | * Returns: size of formatted string. | |
283 | **/ | |
dea3101e | 284 | static ssize_t |
ee959b00 TJ |
285 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
286 | char *buf) | |
dea3101e | 287 | { |
ee959b00 | 288 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
289 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
290 | struct lpfc_hba *phba = vport->phba; | |
291 | ||
dea3101e JB |
292 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
293 | } | |
294 | ||
84774a4d | 295 | /** |
3621a710 | 296 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
84774a4d JS |
297 | * @dev: class converted to a Scsi_host structure. |
298 | * @attr: device attribute, not used. | |
299 | * @buf: on return contains the Menlo Maintenance sli flag. | |
300 | * | |
301 | * Returns: size of formatted string. | |
302 | **/ | |
303 | static ssize_t | |
304 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) | |
305 | { | |
306 | struct Scsi_Host *shost = class_to_shost(dev); | |
307 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; | |
308 | struct lpfc_hba *phba = vport->phba; | |
309 | ||
310 | return snprintf(buf, PAGE_SIZE, "%d\n", | |
311 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); | |
312 | } | |
313 | ||
e59058c4 | 314 | /** |
3621a710 | 315 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
e59058c4 JS |
316 | * @dev: class converted to a Scsi_host structure. |
317 | * @attr: device attribute, not used. | |
318 | * @buf: on return contains scsi vpd program type. | |
319 | * | |
320 | * Returns: size of formatted string. | |
321 | **/ | |
dea3101e | 322 | static ssize_t |
ee959b00 TJ |
323 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
324 | char *buf) | |
dea3101e | 325 | { |
ee959b00 | 326 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
327 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
328 | struct lpfc_hba *phba = vport->phba; | |
329 | ||
dea3101e JB |
330 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
331 | } | |
332 | ||
e59058c4 | 333 | /** |
3621a710 | 334 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
e59058c4 JS |
335 | * @dev: class converted to a Scsi_host structure. |
336 | * @attr: device attribute, not used. | |
337 | * @buf: on return contains the scsi vpd program type. | |
338 | * | |
339 | * Returns: size of formatted string. | |
340 | **/ | |
dea3101e | 341 | static ssize_t |
ee959b00 TJ |
342 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
343 | char *buf) | |
dea3101e | 344 | { |
ee959b00 | 345 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
346 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
347 | struct lpfc_hba *phba = vport->phba; | |
dea3101e | 348 | char fwrev[32]; |
2e0fef85 | 349 | |
dea3101e | 350 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
92d7f7b0 | 351 | return snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", fwrev, phba->sli_rev); |
dea3101e JB |
352 | } |
353 | ||
e59058c4 | 354 | /** |
3621a710 | 355 | * lpfc_hdw_show - Return the jedec information about the hba |
e59058c4 JS |
356 | * @dev: class converted to a Scsi_host structure. |
357 | * @attr: device attribute, not used. | |
358 | * @buf: on return contains the scsi vpd program type. | |
359 | * | |
360 | * Returns: size of formatted string. | |
361 | **/ | |
dea3101e | 362 | static ssize_t |
ee959b00 | 363 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
dea3101e JB |
364 | { |
365 | char hdw[9]; | |
ee959b00 | 366 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
367 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
368 | struct lpfc_hba *phba = vport->phba; | |
dea3101e | 369 | lpfc_vpd_t *vp = &phba->vpd; |
2e0fef85 | 370 | |
dea3101e JB |
371 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
372 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); | |
373 | } | |
e59058c4 JS |
374 | |
375 | /** | |
3621a710 | 376 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
e59058c4 JS |
377 | * @dev: class converted to a Scsi_host structure. |
378 | * @attr: device attribute, not used. | |
379 | * @buf: on return contains the ROM and FCode ascii strings. | |
380 | * | |
381 | * Returns: size of formatted string. | |
382 | **/ | |
dea3101e | 383 | static ssize_t |
ee959b00 TJ |
384 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
385 | char *buf) | |
dea3101e | 386 | { |
ee959b00 | 387 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
388 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
389 | struct lpfc_hba *phba = vport->phba; | |
390 | ||
dea3101e JB |
391 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
392 | } | |
e59058c4 JS |
393 | |
394 | /** | |
3621a710 | 395 | * lpfc_state_show - Return the link state of the port |
e59058c4 JS |
396 | * @dev: class converted to a Scsi_host structure. |
397 | * @attr: device attribute, not used. | |
398 | * @buf: on return contains text describing the state of the link. | |
399 | * | |
400 | * Notes: | |
401 | * The switch statement has no default so zero will be returned. | |
402 | * | |
403 | * Returns: size of formatted string. | |
404 | **/ | |
dea3101e | 405 | static ssize_t |
bbd1ae41 HR |
406 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
407 | char *buf) | |
dea3101e | 408 | { |
ee959b00 | 409 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
410 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
411 | struct lpfc_hba *phba = vport->phba; | |
412 | int len = 0; | |
413 | ||
414 | switch (phba->link_state) { | |
415 | case LPFC_LINK_UNKNOWN: | |
41415862 | 416 | case LPFC_WARM_START: |
dea3101e JB |
417 | case LPFC_INIT_START: |
418 | case LPFC_INIT_MBX_CMDS: | |
419 | case LPFC_LINK_DOWN: | |
2e0fef85 | 420 | case LPFC_HBA_ERROR: |
a0c87cbd JS |
421 | if (phba->hba_flag & LINK_DISABLED) |
422 | len += snprintf(buf + len, PAGE_SIZE-len, | |
423 | "Link Down - User disabled\n"); | |
424 | else | |
425 | len += snprintf(buf + len, PAGE_SIZE-len, | |
426 | "Link Down\n"); | |
dea3101e JB |
427 | break; |
428 | case LPFC_LINK_UP: | |
dea3101e | 429 | case LPFC_CLEAR_LA: |
dea3101e | 430 | case LPFC_HBA_READY: |
a8adb832 | 431 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
2e0fef85 JS |
432 | |
433 | switch (vport->port_state) { | |
2e0fef85 JS |
434 | case LPFC_LOCAL_CFG_LINK: |
435 | len += snprintf(buf + len, PAGE_SIZE-len, | |
92d7f7b0 | 436 | "Configuring Link\n"); |
2e0fef85 | 437 | break; |
92d7f7b0 | 438 | case LPFC_FDISC: |
2e0fef85 JS |
439 | case LPFC_FLOGI: |
440 | case LPFC_FABRIC_CFG_LINK: | |
441 | case LPFC_NS_REG: | |
442 | case LPFC_NS_QRY: | |
443 | case LPFC_BUILD_DISC_LIST: | |
444 | case LPFC_DISC_AUTH: | |
445 | len += snprintf(buf + len, PAGE_SIZE - len, | |
446 | "Discovery\n"); | |
447 | break; | |
448 | case LPFC_VPORT_READY: | |
449 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); | |
450 | break; | |
451 | ||
92d7f7b0 JS |
452 | case LPFC_VPORT_FAILED: |
453 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); | |
454 | break; | |
455 | ||
456 | case LPFC_VPORT_UNKNOWN: | |
2e0fef85 JS |
457 | len += snprintf(buf + len, PAGE_SIZE - len, |
458 | "Unknown\n"); | |
459 | break; | |
460 | } | |
84774a4d JS |
461 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
462 | len += snprintf(buf + len, PAGE_SIZE-len, | |
463 | " Menlo Maint Mode\n"); | |
464 | else if (phba->fc_topology == TOPOLOGY_LOOP) { | |
2e0fef85 | 465 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
dea3101e JB |
466 | len += snprintf(buf + len, PAGE_SIZE-len, |
467 | " Public Loop\n"); | |
468 | else | |
469 | len += snprintf(buf + len, PAGE_SIZE-len, | |
470 | " Private Loop\n"); | |
471 | } else { | |
2e0fef85 | 472 | if (vport->fc_flag & FC_FABRIC) |
dea3101e JB |
473 | len += snprintf(buf + len, PAGE_SIZE-len, |
474 | " Fabric\n"); | |
475 | else | |
476 | len += snprintf(buf + len, PAGE_SIZE-len, | |
477 | " Point-2-Point\n"); | |
478 | } | |
479 | } | |
2e0fef85 | 480 | |
dea3101e JB |
481 | return len; |
482 | } | |
483 | ||
e59058c4 | 484 | /** |
3621a710 | 485 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
e59058c4 JS |
486 | * @dev: class device that is converted into a Scsi_host. |
487 | * @attr: device attribute, not used. | |
488 | * @buf: on return contains the sum of fc mapped and unmapped. | |
489 | * | |
490 | * Description: | |
491 | * Returns the ascii text number of the sum of the fc mapped and unmapped | |
492 | * vport counts. | |
493 | * | |
494 | * Returns: size of formatted string. | |
495 | **/ | |
dea3101e | 496 | static ssize_t |
ee959b00 TJ |
497 | lpfc_num_discovered_ports_show(struct device *dev, |
498 | struct device_attribute *attr, char *buf) | |
dea3101e | 499 | { |
ee959b00 | 500 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
501 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
502 | ||
503 | return snprintf(buf, PAGE_SIZE, "%d\n", | |
504 | vport->fc_map_cnt + vport->fc_unmap_cnt); | |
dea3101e JB |
505 | } |
506 | ||
e59058c4 | 507 | /** |
3621a710 | 508 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
e59058c4 JS |
509 | * @shost: Scsi_Host pointer. |
510 | * | |
511 | * Description: | |
512 | * Bring the link down gracefully then re-init the link. The firmware will | |
513 | * re-init the fiber channel interface as required. Does not issue a LIP. | |
514 | * | |
515 | * Returns: | |
516 | * -EPERM port offline or management commands are being blocked | |
517 | * -ENOMEM cannot allocate memory for the mailbox command | |
518 | * -EIO error sending the mailbox command | |
519 | * zero for success | |
520 | **/ | |
91ca7b01 | 521 | static int |
2e0fef85 | 522 | lpfc_issue_lip(struct Scsi_Host *shost) |
dea3101e | 523 | { |
2e0fef85 JS |
524 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
525 | struct lpfc_hba *phba = vport->phba; | |
dea3101e JB |
526 | LPFC_MBOXQ_t *pmboxq; |
527 | int mbxstatus = MBXERR_ERROR; | |
528 | ||
2e0fef85 | 529 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
83108bd3 | 530 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
dea3101e JB |
531 | return -EPERM; |
532 | ||
533 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); | |
534 | ||
535 | if (!pmboxq) | |
536 | return -ENOMEM; | |
537 | ||
538 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); | |
04c68496 JS |
539 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
540 | pmboxq->u.mb.mbxOwner = OWN_HOST; | |
4db621e0 | 541 | |
33ccf8d1 | 542 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
dea3101e | 543 | |
04c68496 JS |
544 | if ((mbxstatus == MBX_SUCCESS) && |
545 | (pmboxq->u.mb.mbxStatus == 0 || | |
546 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { | |
4db621e0 JS |
547 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
548 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, | |
549 | phba->cfg_link_speed); | |
550 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, | |
551 | phba->fc_ratov * 2); | |
552 | } | |
553 | ||
5b8bd0c9 | 554 | lpfc_set_loopback_flag(phba); |
858c9f6c | 555 | if (mbxstatus != MBX_TIMEOUT) |
433c3579 | 556 | mempool_free(pmboxq, phba->mbox_mem_pool); |
dea3101e JB |
557 | |
558 | if (mbxstatus == MBXERR_ERROR) | |
559 | return -EIO; | |
560 | ||
91ca7b01 | 561 | return 0; |
dea3101e JB |
562 | } |
563 | ||
e59058c4 | 564 | /** |
3621a710 | 565 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
e59058c4 JS |
566 | * @phba: lpfc_hba pointer. |
567 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. | |
568 | * | |
569 | * Notes: | |
570 | * Assumes any error from lpfc_do_offline() will be negative. | |
571 | * Can wait up to 5 seconds for the port ring buffers count | |
572 | * to reach zero, prints a warning if it is not zero and continues. | |
3621a710 | 573 | * lpfc_workq_post_event() returns a non-zero return code if call fails. |
e59058c4 JS |
574 | * |
575 | * Returns: | |
576 | * -EIO error posting the event | |
577 | * zero for success | |
578 | **/ | |
40496f07 | 579 | static int |
46fa311e | 580 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
40496f07 JS |
581 | { |
582 | struct completion online_compl; | |
46fa311e JS |
583 | struct lpfc_sli_ring *pring; |
584 | struct lpfc_sli *psli; | |
40496f07 | 585 | int status = 0; |
46fa311e JS |
586 | int cnt = 0; |
587 | int i; | |
40496f07 JS |
588 | |
589 | init_completion(&online_compl); | |
590 | lpfc_workq_post_event(phba, &status, &online_compl, | |
46fa311e JS |
591 | LPFC_EVT_OFFLINE_PREP); |
592 | wait_for_completion(&online_compl); | |
593 | ||
594 | if (status != 0) | |
595 | return -EIO; | |
596 | ||
597 | psli = &phba->sli; | |
598 | ||
09372820 JS |
599 | /* Wait a little for things to settle down, but not |
600 | * long enough for dev loss timeout to expire. | |
601 | */ | |
46fa311e JS |
602 | for (i = 0; i < psli->num_rings; i++) { |
603 | pring = &psli->ring[i]; | |
46fa311e JS |
604 | while (pring->txcmplq_cnt) { |
605 | msleep(10); | |
09372820 | 606 | if (cnt++ > 500) { /* 5 secs */ |
46fa311e JS |
607 | lpfc_printf_log(phba, |
608 | KERN_WARNING, LOG_INIT, | |
e8b62011 JS |
609 | "0466 Outstanding IO when " |
610 | "bringing Adapter offline\n"); | |
46fa311e JS |
611 | break; |
612 | } | |
613 | } | |
614 | } | |
615 | ||
616 | init_completion(&online_compl); | |
617 | lpfc_workq_post_event(phba, &status, &online_compl, type); | |
40496f07 JS |
618 | wait_for_completion(&online_compl); |
619 | ||
620 | if (status != 0) | |
621 | return -EIO; | |
622 | ||
46fa311e JS |
623 | return 0; |
624 | } | |
625 | ||
e59058c4 | 626 | /** |
3621a710 | 627 | * lpfc_selective_reset - Offline then onlines the port |
e59058c4 JS |
628 | * @phba: lpfc_hba pointer. |
629 | * | |
630 | * Description: | |
631 | * If the port is configured to allow a reset then the hba is brought | |
632 | * offline then online. | |
633 | * | |
634 | * Notes: | |
635 | * Assumes any error from lpfc_do_offline() will be negative. | |
636 | * | |
637 | * Returns: | |
638 | * lpfc_do_offline() return code if not zero | |
639 | * -EIO reset not configured or error posting the event | |
640 | * zero for success | |
641 | **/ | |
46fa311e JS |
642 | static int |
643 | lpfc_selective_reset(struct lpfc_hba *phba) | |
644 | { | |
645 | struct completion online_compl; | |
646 | int status = 0; | |
647 | ||
13815c83 JS |
648 | if (!phba->cfg_enable_hba_reset) |
649 | return -EIO; | |
650 | ||
46fa311e JS |
651 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
652 | ||
653 | if (status != 0) | |
654 | return status; | |
655 | ||
40496f07 JS |
656 | init_completion(&online_compl); |
657 | lpfc_workq_post_event(phba, &status, &online_compl, | |
658 | LPFC_EVT_ONLINE); | |
659 | wait_for_completion(&online_compl); | |
660 | ||
661 | if (status != 0) | |
662 | return -EIO; | |
663 | ||
664 | return 0; | |
665 | } | |
666 | ||
e59058c4 | 667 | /** |
3621a710 | 668 | * lpfc_issue_reset - Selectively resets an adapter |
e59058c4 JS |
669 | * @dev: class device that is converted into a Scsi_host. |
670 | * @attr: device attribute, not used. | |
671 | * @buf: containing the string "selective". | |
672 | * @count: unused variable. | |
673 | * | |
674 | * Description: | |
675 | * If the buf contains the string "selective" then lpfc_selective_reset() | |
676 | * is called to perform the reset. | |
677 | * | |
678 | * Notes: | |
679 | * Assumes any error from lpfc_selective_reset() will be negative. | |
680 | * If lpfc_selective_reset() returns zero then the length of the buffer | |
af901ca1 | 681 | * is returned which indicates success |
e59058c4 JS |
682 | * |
683 | * Returns: | |
684 | * -EINVAL if the buffer does not contain the string "selective" | |
685 | * length of buf if lpfc-selective_reset() if the call succeeds | |
686 | * return value of lpfc_selective_reset() if the call fails | |
687 | **/ | |
40496f07 | 688 | static ssize_t |
ee959b00 TJ |
689 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
690 | const char *buf, size_t count) | |
40496f07 | 691 | { |
ee959b00 | 692 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
693 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
694 | struct lpfc_hba *phba = vport->phba; | |
695 | ||
40496f07 JS |
696 | int status = -EINVAL; |
697 | ||
698 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) | |
699 | status = lpfc_selective_reset(phba); | |
700 | ||
701 | if (status == 0) | |
702 | return strlen(buf); | |
703 | else | |
704 | return status; | |
705 | } | |
706 | ||
e59058c4 | 707 | /** |
3621a710 | 708 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
e59058c4 JS |
709 | * @dev: class device that is converted into a Scsi_host. |
710 | * @attr: device attribute, not used. | |
711 | * @buf: on return contains the ascii number of nport events. | |
712 | * | |
713 | * Returns: size of formatted string. | |
714 | **/ | |
dea3101e | 715 | static ssize_t |
ee959b00 TJ |
716 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
717 | char *buf) | |
dea3101e | 718 | { |
ee959b00 | 719 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
720 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
721 | struct lpfc_hba *phba = vport->phba; | |
722 | ||
dea3101e JB |
723 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
724 | } | |
725 | ||
e59058c4 | 726 | /** |
3621a710 | 727 | * lpfc_board_mode_show - Return the state of the board |
e59058c4 JS |
728 | * @dev: class device that is converted into a Scsi_host. |
729 | * @attr: device attribute, not used. | |
730 | * @buf: on return contains the state of the adapter. | |
731 | * | |
732 | * Returns: size of formatted string. | |
733 | **/ | |
41415862 | 734 | static ssize_t |
ee959b00 TJ |
735 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
736 | char *buf) | |
41415862 | 737 | { |
ee959b00 | 738 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
739 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
740 | struct lpfc_hba *phba = vport->phba; | |
41415862 JW |
741 | char * state; |
742 | ||
2e0fef85 | 743 | if (phba->link_state == LPFC_HBA_ERROR) |
41415862 | 744 | state = "error"; |
2e0fef85 | 745 | else if (phba->link_state == LPFC_WARM_START) |
41415862 | 746 | state = "warm start"; |
2e0fef85 | 747 | else if (phba->link_state == LPFC_INIT_START) |
41415862 JW |
748 | state = "offline"; |
749 | else | |
750 | state = "online"; | |
751 | ||
752 | return snprintf(buf, PAGE_SIZE, "%s\n", state); | |
753 | } | |
754 | ||
e59058c4 | 755 | /** |
3621a710 | 756 | * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state |
e59058c4 JS |
757 | * @dev: class device that is converted into a Scsi_host. |
758 | * @attr: device attribute, not used. | |
759 | * @buf: containing one of the strings "online", "offline", "warm" or "error". | |
760 | * @count: unused variable. | |
761 | * | |
762 | * Returns: | |
763 | * -EACCES if enable hba reset not enabled | |
764 | * -EINVAL if the buffer does not contain a valid string (see above) | |
765 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails | |
766 | * buf length greater than zero indicates success | |
767 | **/ | |
41415862 | 768 | static ssize_t |
ee959b00 TJ |
769 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
770 | const char *buf, size_t count) | |
41415862 | 771 | { |
ee959b00 | 772 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
773 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
774 | struct lpfc_hba *phba = vport->phba; | |
41415862 JW |
775 | struct completion online_compl; |
776 | int status=0; | |
777 | ||
13815c83 JS |
778 | if (!phba->cfg_enable_hba_reset) |
779 | return -EACCES; | |
41415862 JW |
780 | init_completion(&online_compl); |
781 | ||
46fa311e | 782 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
41415862 JW |
783 | lpfc_workq_post_event(phba, &status, &online_compl, |
784 | LPFC_EVT_ONLINE); | |
46fa311e JS |
785 | wait_for_completion(&online_compl); |
786 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) | |
787 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); | |
41415862 | 788 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
6a9c52cf JS |
789 | if (phba->sli_rev == LPFC_SLI_REV4) |
790 | return -EINVAL; | |
791 | else | |
792 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); | |
46fa311e | 793 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
6a9c52cf JS |
794 | if (phba->sli_rev == LPFC_SLI_REV4) |
795 | return -EINVAL; | |
796 | else | |
797 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); | |
41415862 JW |
798 | else |
799 | return -EINVAL; | |
800 | ||
41415862 JW |
801 | if (!status) |
802 | return strlen(buf); | |
803 | else | |
804 | return -EIO; | |
805 | } | |
806 | ||
e59058c4 | 807 | /** |
3621a710 | 808 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
e59058c4 | 809 | * @phba: pointer to the adapter structure. |
3621a710 JS |
810 | * @mxri: max xri count. |
811 | * @axri: available xri count. | |
812 | * @mrpi: max rpi count. | |
813 | * @arpi: available rpi count. | |
814 | * @mvpi: max vpi count. | |
815 | * @avpi: available vpi count. | |
e59058c4 JS |
816 | * |
817 | * Description: | |
818 | * If an integer pointer for an count is not null then the value for the | |
819 | * count is returned. | |
820 | * | |
821 | * Returns: | |
822 | * zero on error | |
823 | * one for success | |
824 | **/ | |
311464ec | 825 | static int |
858c9f6c JS |
826 | lpfc_get_hba_info(struct lpfc_hba *phba, |
827 | uint32_t *mxri, uint32_t *axri, | |
828 | uint32_t *mrpi, uint32_t *arpi, | |
829 | uint32_t *mvpi, uint32_t *avpi) | |
92d7f7b0 | 830 | { |
04c68496 JS |
831 | struct lpfc_sli *psli = &phba->sli; |
832 | struct lpfc_mbx_read_config *rd_config; | |
92d7f7b0 JS |
833 | LPFC_MBOXQ_t *pmboxq; |
834 | MAILBOX_t *pmb; | |
835 | int rc = 0; | |
836 | ||
837 | /* | |
838 | * prevent udev from issuing mailbox commands until the port is | |
839 | * configured. | |
840 | */ | |
841 | if (phba->link_state < LPFC_LINK_DOWN || | |
842 | !phba->mbox_mem_pool || | |
f4b4c68f | 843 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
92d7f7b0 JS |
844 | return 0; |
845 | ||
846 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) | |
847 | return 0; | |
848 | ||
849 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
850 | if (!pmboxq) | |
851 | return 0; | |
852 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); | |
853 | ||
04c68496 | 854 | pmb = &pmboxq->u.mb; |
92d7f7b0 JS |
855 | pmb->mbxCommand = MBX_READ_CONFIG; |
856 | pmb->mbxOwner = OWN_HOST; | |
857 | pmboxq->context1 = NULL; | |
858 | ||
859 | if ((phba->pport->fc_flag & FC_OFFLINE_MODE) || | |
f4b4c68f | 860 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
92d7f7b0 JS |
861 | rc = MBX_NOT_FINISHED; |
862 | else | |
863 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); | |
864 | ||
865 | if (rc != MBX_SUCCESS) { | |
858c9f6c | 866 | if (rc != MBX_TIMEOUT) |
92d7f7b0 JS |
867 | mempool_free(pmboxq, phba->mbox_mem_pool); |
868 | return 0; | |
869 | } | |
870 | ||
da0436e9 JS |
871 | if (phba->sli_rev == LPFC_SLI_REV4) { |
872 | rd_config = &pmboxq->u.mqe.un.rd_config; | |
873 | if (mrpi) | |
874 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); | |
875 | if (arpi) | |
876 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - | |
877 | phba->sli4_hba.max_cfg_param.rpi_used; | |
878 | if (mxri) | |
879 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); | |
880 | if (axri) | |
881 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - | |
882 | phba->sli4_hba.max_cfg_param.xri_used; | |
883 | if (mvpi) | |
884 | *mvpi = bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config); | |
885 | if (avpi) | |
886 | *avpi = bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - | |
887 | phba->sli4_hba.max_cfg_param.vpi_used; | |
888 | } else { | |
889 | if (mrpi) | |
890 | *mrpi = pmb->un.varRdConfig.max_rpi; | |
891 | if (arpi) | |
892 | *arpi = pmb->un.varRdConfig.avail_rpi; | |
893 | if (mxri) | |
894 | *mxri = pmb->un.varRdConfig.max_xri; | |
895 | if (axri) | |
896 | *axri = pmb->un.varRdConfig.avail_xri; | |
897 | if (mvpi) | |
898 | *mvpi = pmb->un.varRdConfig.max_vpi; | |
899 | if (avpi) | |
900 | *avpi = pmb->un.varRdConfig.avail_vpi; | |
901 | } | |
92d7f7b0 JS |
902 | |
903 | mempool_free(pmboxq, phba->mbox_mem_pool); | |
904 | return 1; | |
905 | } | |
906 | ||
e59058c4 | 907 | /** |
3621a710 | 908 | * lpfc_max_rpi_show - Return maximum rpi |
e59058c4 JS |
909 | * @dev: class device that is converted into a Scsi_host. |
910 | * @attr: device attribute, not used. | |
911 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". | |
912 | * | |
913 | * Description: | |
914 | * Calls lpfc_get_hba_info() asking for just the mrpi count. | |
915 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
916 | * to "Unknown" and the buffer length is returned, therefore the caller | |
917 | * must check for "Unknown" in the buffer to detect a failure. | |
918 | * | |
919 | * Returns: size of formatted string. | |
920 | **/ | |
92d7f7b0 | 921 | static ssize_t |
ee959b00 TJ |
922 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
923 | char *buf) | |
92d7f7b0 | 924 | { |
ee959b00 | 925 | struct Scsi_Host *shost = class_to_shost(dev); |
92d7f7b0 JS |
926 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
927 | struct lpfc_hba *phba = vport->phba; | |
928 | uint32_t cnt; | |
929 | ||
858c9f6c | 930 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
92d7f7b0 JS |
931 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
932 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
933 | } | |
934 | ||
e59058c4 | 935 | /** |
3621a710 | 936 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
e59058c4 JS |
937 | * @dev: class device that is converted into a Scsi_host. |
938 | * @attr: device attribute, not used. | |
939 | * @buf: containing the used rpi count in decimal or "Unknown". | |
940 | * | |
941 | * Description: | |
942 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. | |
943 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
944 | * to "Unknown" and the buffer length is returned, therefore the caller | |
945 | * must check for "Unknown" in the buffer to detect a failure. | |
946 | * | |
947 | * Returns: size of formatted string. | |
948 | **/ | |
92d7f7b0 | 949 | static ssize_t |
ee959b00 TJ |
950 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
951 | char *buf) | |
92d7f7b0 | 952 | { |
ee959b00 | 953 | struct Scsi_Host *shost = class_to_shost(dev); |
92d7f7b0 JS |
954 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
955 | struct lpfc_hba *phba = vport->phba; | |
956 | uint32_t cnt, acnt; | |
957 | ||
858c9f6c | 958 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
92d7f7b0 JS |
959 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
960 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
961 | } | |
962 | ||
e59058c4 | 963 | /** |
3621a710 | 964 | * lpfc_max_xri_show - Return maximum xri |
e59058c4 JS |
965 | * @dev: class device that is converted into a Scsi_host. |
966 | * @attr: device attribute, not used. | |
967 | * @buf: on return contains the maximum xri count in decimal or "Unknown". | |
968 | * | |
969 | * Description: | |
970 | * Calls lpfc_get_hba_info() asking for just the mrpi count. | |
971 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
972 | * to "Unknown" and the buffer length is returned, therefore the caller | |
973 | * must check for "Unknown" in the buffer to detect a failure. | |
974 | * | |
975 | * Returns: size of formatted string. | |
976 | **/ | |
92d7f7b0 | 977 | static ssize_t |
ee959b00 TJ |
978 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
979 | char *buf) | |
92d7f7b0 | 980 | { |
ee959b00 | 981 | struct Scsi_Host *shost = class_to_shost(dev); |
92d7f7b0 JS |
982 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
983 | struct lpfc_hba *phba = vport->phba; | |
984 | uint32_t cnt; | |
985 | ||
858c9f6c | 986 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
92d7f7b0 JS |
987 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
988 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
989 | } | |
990 | ||
e59058c4 | 991 | /** |
3621a710 | 992 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
e59058c4 JS |
993 | * @dev: class device that is converted into a Scsi_host. |
994 | * @attr: device attribute, not used. | |
995 | * @buf: on return contains the used xri count in decimal or "Unknown". | |
996 | * | |
997 | * Description: | |
998 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. | |
999 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
1000 | * to "Unknown" and the buffer length is returned, therefore the caller | |
1001 | * must check for "Unknown" in the buffer to detect a failure. | |
1002 | * | |
1003 | * Returns: size of formatted string. | |
1004 | **/ | |
92d7f7b0 | 1005 | static ssize_t |
ee959b00 TJ |
1006 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
1007 | char *buf) | |
92d7f7b0 | 1008 | { |
ee959b00 | 1009 | struct Scsi_Host *shost = class_to_shost(dev); |
92d7f7b0 JS |
1010 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1011 | struct lpfc_hba *phba = vport->phba; | |
1012 | uint32_t cnt, acnt; | |
1013 | ||
858c9f6c JS |
1014 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
1015 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); | |
1016 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
1017 | } | |
1018 | ||
e59058c4 | 1019 | /** |
3621a710 | 1020 | * lpfc_max_vpi_show - Return maximum vpi |
e59058c4 JS |
1021 | * @dev: class device that is converted into a Scsi_host. |
1022 | * @attr: device attribute, not used. | |
1023 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". | |
1024 | * | |
1025 | * Description: | |
1026 | * Calls lpfc_get_hba_info() asking for just the mvpi count. | |
1027 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
1028 | * to "Unknown" and the buffer length is returned, therefore the caller | |
1029 | * must check for "Unknown" in the buffer to detect a failure. | |
1030 | * | |
1031 | * Returns: size of formatted string. | |
1032 | **/ | |
858c9f6c | 1033 | static ssize_t |
ee959b00 TJ |
1034 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
1035 | char *buf) | |
858c9f6c | 1036 | { |
ee959b00 | 1037 | struct Scsi_Host *shost = class_to_shost(dev); |
858c9f6c JS |
1038 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1039 | struct lpfc_hba *phba = vport->phba; | |
1040 | uint32_t cnt; | |
1041 | ||
1042 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) | |
1043 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); | |
1044 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
1045 | } | |
1046 | ||
e59058c4 | 1047 | /** |
3621a710 | 1048 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
e59058c4 JS |
1049 | * @dev: class device that is converted into a Scsi_host. |
1050 | * @attr: device attribute, not used. | |
1051 | * @buf: on return contains the used vpi count in decimal or "Unknown". | |
1052 | * | |
1053 | * Description: | |
1054 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. | |
1055 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
1056 | * to "Unknown" and the buffer length is returned, therefore the caller | |
1057 | * must check for "Unknown" in the buffer to detect a failure. | |
1058 | * | |
1059 | * Returns: size of formatted string. | |
1060 | **/ | |
858c9f6c | 1061 | static ssize_t |
ee959b00 TJ |
1062 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
1063 | char *buf) | |
858c9f6c | 1064 | { |
ee959b00 | 1065 | struct Scsi_Host *shost = class_to_shost(dev); |
858c9f6c JS |
1066 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1067 | struct lpfc_hba *phba = vport->phba; | |
1068 | uint32_t cnt, acnt; | |
1069 | ||
1070 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) | |
92d7f7b0 JS |
1071 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
1072 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
1073 | } | |
1074 | ||
e59058c4 | 1075 | /** |
3621a710 | 1076 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
e59058c4 JS |
1077 | * @dev: class device that is converted into a Scsi_host. |
1078 | * @attr: device attribute, not used. | |
1079 | * @buf: text that must be interpreted to determine if npiv is supported. | |
1080 | * | |
1081 | * Description: | |
1082 | * Buffer will contain text indicating npiv is not suppoerted on the port, | |
1083 | * the port is an NPIV physical port, or it is an npiv virtual port with | |
1084 | * the id of the vport. | |
1085 | * | |
1086 | * Returns: size of formatted string. | |
1087 | **/ | |
92d7f7b0 | 1088 | static ssize_t |
ee959b00 TJ |
1089 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
1090 | char *buf) | |
92d7f7b0 | 1091 | { |
ee959b00 | 1092 | struct Scsi_Host *shost = class_to_shost(dev); |
92d7f7b0 JS |
1093 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1094 | struct lpfc_hba *phba = vport->phba; | |
1095 | ||
1096 | if (!(phba->max_vpi)) | |
1097 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); | |
1098 | if (vport->port_type == LPFC_PHYSICAL_PORT) | |
1099 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); | |
1100 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); | |
1101 | } | |
1102 | ||
e59058c4 | 1103 | /** |
3621a710 | 1104 | * lpfc_poll_show - Return text about poll support for the adapter |
e59058c4 JS |
1105 | * @dev: class device that is converted into a Scsi_host. |
1106 | * @attr: device attribute, not used. | |
1107 | * @buf: on return contains the cfg_poll in hex. | |
1108 | * | |
1109 | * Notes: | |
1110 | * cfg_poll should be a lpfc_polling_flags type. | |
1111 | * | |
1112 | * Returns: size of formatted string. | |
1113 | **/ | |
875fbdfe | 1114 | static ssize_t |
ee959b00 TJ |
1115 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
1116 | char *buf) | |
875fbdfe | 1117 | { |
ee959b00 | 1118 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
1119 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1120 | struct lpfc_hba *phba = vport->phba; | |
875fbdfe JSEC |
1121 | |
1122 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); | |
1123 | } | |
1124 | ||
e59058c4 | 1125 | /** |
3621a710 | 1126 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
e59058c4 JS |
1127 | * @dev: class device that is converted into a Scsi_host. |
1128 | * @attr: device attribute, not used. | |
1129 | * @buf: one or more lpfc_polling_flags values. | |
1130 | * @count: not used. | |
1131 | * | |
1132 | * Notes: | |
1133 | * buf contents converted to integer and checked for a valid value. | |
1134 | * | |
1135 | * Returns: | |
1136 | * -EINVAL if the buffer connot be converted or is out of range | |
1137 | * length of the buf on success | |
1138 | **/ | |
875fbdfe | 1139 | static ssize_t |
ee959b00 TJ |
1140 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
1141 | const char *buf, size_t count) | |
875fbdfe | 1142 | { |
ee959b00 | 1143 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
1144 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1145 | struct lpfc_hba *phba = vport->phba; | |
875fbdfe JSEC |
1146 | uint32_t creg_val; |
1147 | uint32_t old_val; | |
1148 | int val=0; | |
1149 | ||
1150 | if (!isdigit(buf[0])) | |
1151 | return -EINVAL; | |
1152 | ||
1153 | if (sscanf(buf, "%i", &val) != 1) | |
1154 | return -EINVAL; | |
1155 | ||
1156 | if ((val & 0x3) != val) | |
1157 | return -EINVAL; | |
1158 | ||
45ed1190 JS |
1159 | if (phba->sli_rev == LPFC_SLI_REV4) |
1160 | val = 0; | |
1161 | ||
2e0fef85 | 1162 | spin_lock_irq(&phba->hbalock); |
875fbdfe JSEC |
1163 | |
1164 | old_val = phba->cfg_poll; | |
1165 | ||
1166 | if (val & ENABLE_FCP_RING_POLLING) { | |
1167 | if ((val & DISABLE_FCP_RING_INT) && | |
1168 | !(old_val & DISABLE_FCP_RING_INT)) { | |
1169 | creg_val = readl(phba->HCregaddr); | |
1170 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); | |
1171 | writel(creg_val, phba->HCregaddr); | |
1172 | readl(phba->HCregaddr); /* flush */ | |
1173 | ||
1174 | lpfc_poll_start_timer(phba); | |
1175 | } | |
1176 | } else if (val != 0x0) { | |
2e0fef85 | 1177 | spin_unlock_irq(&phba->hbalock); |
875fbdfe JSEC |
1178 | return -EINVAL; |
1179 | } | |
1180 | ||
1181 | if (!(val & DISABLE_FCP_RING_INT) && | |
1182 | (old_val & DISABLE_FCP_RING_INT)) | |
1183 | { | |
2e0fef85 | 1184 | spin_unlock_irq(&phba->hbalock); |
875fbdfe | 1185 | del_timer(&phba->fcp_poll_timer); |
2e0fef85 | 1186 | spin_lock_irq(&phba->hbalock); |
875fbdfe JSEC |
1187 | creg_val = readl(phba->HCregaddr); |
1188 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); | |
1189 | writel(creg_val, phba->HCregaddr); | |
1190 | readl(phba->HCregaddr); /* flush */ | |
1191 | } | |
1192 | ||
1193 | phba->cfg_poll = val; | |
1194 | ||
2e0fef85 | 1195 | spin_unlock_irq(&phba->hbalock); |
875fbdfe JSEC |
1196 | |
1197 | return strlen(buf); | |
1198 | } | |
dea3101e | 1199 | |
e59058c4 | 1200 | /** |
3621a710 | 1201 | * lpfc_param_show - Return a cfg attribute value in decimal |
e59058c4 JS |
1202 | * |
1203 | * Description: | |
1204 | * Macro that given an attr e.g. hba_queue_depth expands | |
1205 | * into a function with the name lpfc_hba_queue_depth_show. | |
1206 | * | |
1207 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. | |
1208 | * @dev: class device that is converted into a Scsi_host. | |
1209 | * @attr: device attribute, not used. | |
1210 | * @buf: on return contains the attribute value in decimal. | |
1211 | * | |
1212 | * Returns: size of formatted string. | |
1213 | **/ | |
dea3101e JB |
1214 | #define lpfc_param_show(attr) \ |
1215 | static ssize_t \ | |
ee959b00 TJ |
1216 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
1217 | char *buf) \ | |
dea3101e | 1218 | { \ |
ee959b00 | 1219 | struct Scsi_Host *shost = class_to_shost(dev);\ |
2e0fef85 JS |
1220 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
1221 | struct lpfc_hba *phba = vport->phba;\ | |
dea3101e | 1222 | int val = 0;\ |
7bcbb752 JSEC |
1223 | val = phba->cfg_##attr;\ |
1224 | return snprintf(buf, PAGE_SIZE, "%d\n",\ | |
1225 | phba->cfg_##attr);\ | |
1226 | } | |
1227 | ||
e59058c4 | 1228 | /** |
3621a710 | 1229 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
e59058c4 JS |
1230 | * |
1231 | * Description: | |
1232 | * Macro that given an attr e.g. hba_queue_depth expands | |
1233 | * into a function with the name lpfc_hba_queue_depth_show | |
1234 | * | |
1235 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. | |
1236 | * @dev: class device that is converted into a Scsi_host. | |
1237 | * @attr: device attribute, not used. | |
3621a710 | 1238 | * @buf: on return contains the attribute value in hexadecimal. |
e59058c4 JS |
1239 | * |
1240 | * Returns: size of formatted string. | |
1241 | **/ | |
93a20f74 JSEC |
1242 | #define lpfc_param_hex_show(attr) \ |
1243 | static ssize_t \ | |
ee959b00 TJ |
1244 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
1245 | char *buf) \ | |
93a20f74 | 1246 | { \ |
ee959b00 | 1247 | struct Scsi_Host *shost = class_to_shost(dev);\ |
2e0fef85 JS |
1248 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
1249 | struct lpfc_hba *phba = vport->phba;\ | |
93a20f74 JSEC |
1250 | int val = 0;\ |
1251 | val = phba->cfg_##attr;\ | |
1252 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ | |
1253 | phba->cfg_##attr);\ | |
1254 | } | |
1255 | ||
e59058c4 | 1256 | /** |
3621a710 | 1257 | * lpfc_param_init - Intializes a cfg attribute |
e59058c4 JS |
1258 | * |
1259 | * Description: | |
1260 | * Macro that given an attr e.g. hba_queue_depth expands | |
1261 | * into a function with the name lpfc_hba_queue_depth_init. The macro also | |
1262 | * takes a default argument, a minimum and maximum argument. | |
1263 | * | |
1264 | * lpfc_##attr##_init: Initializes an attribute. | |
1265 | * @phba: pointer the the adapter structure. | |
1266 | * @val: integer attribute value. | |
1267 | * | |
1268 | * Validates the min and max values then sets the adapter config field | |
1269 | * accordingly, or uses the default if out of range and prints an error message. | |
1270 | * | |
1271 | * Returns: | |
1272 | * zero on success | |
1273 | * -EINVAL if default used | |
1274 | **/ | |
7bcbb752 JSEC |
1275 | #define lpfc_param_init(attr, default, minval, maxval) \ |
1276 | static int \ | |
1277 | lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ | |
1278 | { \ | |
1279 | if (val >= minval && val <= maxval) {\ | |
1280 | phba->cfg_##attr = val;\ | |
1281 | return 0;\ | |
dea3101e | 1282 | }\ |
7bcbb752 | 1283 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
e8b62011 JS |
1284 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
1285 | "allowed range is ["#minval", "#maxval"]\n", val); \ | |
7bcbb752 JSEC |
1286 | phba->cfg_##attr = default;\ |
1287 | return -EINVAL;\ | |
dea3101e JB |
1288 | } |
1289 | ||
e59058c4 | 1290 | /** |
3621a710 | 1291 | * lpfc_param_set - Set a cfg attribute value |
e59058c4 JS |
1292 | * |
1293 | * Description: | |
1294 | * Macro that given an attr e.g. hba_queue_depth expands | |
1295 | * into a function with the name lpfc_hba_queue_depth_set | |
1296 | * | |
1297 | * lpfc_##attr##_set: Sets an attribute value. | |
1298 | * @phba: pointer the the adapter structure. | |
1299 | * @val: integer attribute value. | |
1300 | * | |
1301 | * Description: | |
1302 | * Validates the min and max values then sets the | |
1303 | * adapter config field if in the valid range. prints error message | |
1304 | * and does not set the parameter if invalid. | |
1305 | * | |
1306 | * Returns: | |
1307 | * zero on success | |
1308 | * -EINVAL if val is invalid | |
1309 | **/ | |
7bcbb752 JSEC |
1310 | #define lpfc_param_set(attr, default, minval, maxval) \ |
1311 | static int \ | |
1312 | lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ | |
1313 | { \ | |
1314 | if (val >= minval && val <= maxval) {\ | |
1315 | phba->cfg_##attr = val;\ | |
1316 | return 0;\ | |
1317 | }\ | |
1318 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ | |
e8b62011 JS |
1319 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
1320 | "allowed range is ["#minval", "#maxval"]\n", val); \ | |
7bcbb752 JSEC |
1321 | return -EINVAL;\ |
1322 | } | |
1323 | ||
e59058c4 | 1324 | /** |
3621a710 | 1325 | * lpfc_param_store - Set a vport attribute value |
e59058c4 JS |
1326 | * |
1327 | * Description: | |
1328 | * Macro that given an attr e.g. hba_queue_depth expands | |
1329 | * into a function with the name lpfc_hba_queue_depth_store. | |
1330 | * | |
1331 | * lpfc_##attr##_store: Set an sttribute value. | |
1332 | * @dev: class device that is converted into a Scsi_host. | |
1333 | * @attr: device attribute, not used. | |
1334 | * @buf: contains the attribute value in ascii. | |
1335 | * @count: not used. | |
1336 | * | |
1337 | * Description: | |
1338 | * Convert the ascii text number to an integer, then | |
1339 | * use the lpfc_##attr##_set function to set the value. | |
1340 | * | |
1341 | * Returns: | |
1342 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails | |
1343 | * length of buffer upon success. | |
1344 | **/ | |
7bcbb752 | 1345 | #define lpfc_param_store(attr) \ |
dea3101e | 1346 | static ssize_t \ |
ee959b00 TJ |
1347 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
1348 | const char *buf, size_t count) \ | |
dea3101e | 1349 | { \ |
ee959b00 | 1350 | struct Scsi_Host *shost = class_to_shost(dev);\ |
2e0fef85 JS |
1351 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
1352 | struct lpfc_hba *phba = vport->phba;\ | |
7bcbb752 | 1353 | int val=0;\ |
93a20f74 JSEC |
1354 | if (!isdigit(buf[0]))\ |
1355 | return -EINVAL;\ | |
1356 | if (sscanf(buf, "%i", &val) != 1)\ | |
1357 | return -EINVAL;\ | |
7bcbb752 | 1358 | if (lpfc_##attr##_set(phba, val) == 0) \ |
755c0d06 | 1359 | return strlen(buf);\ |
7bcbb752 JSEC |
1360 | else \ |
1361 | return -EINVAL;\ | |
dea3101e JB |
1362 | } |
1363 | ||
e59058c4 | 1364 | /** |
3621a710 | 1365 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
e59058c4 JS |
1366 | * |
1367 | * Description: | |
1368 | * Macro that given an attr e.g. hba_queue_depth expands | |
1369 | * into a function with the name lpfc_hba_queue_depth_show | |
1370 | * | |
1371 | * lpfc_##attr##_show: prints the attribute value in decimal. | |
1372 | * @dev: class device that is converted into a Scsi_host. | |
1373 | * @attr: device attribute, not used. | |
1374 | * @buf: on return contains the attribute value in decimal. | |
1375 | * | |
1376 | * Returns: length of formatted string. | |
1377 | **/ | |
3de2a653 JS |
1378 | #define lpfc_vport_param_show(attr) \ |
1379 | static ssize_t \ | |
ee959b00 TJ |
1380 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
1381 | char *buf) \ | |
3de2a653 | 1382 | { \ |
ee959b00 | 1383 | struct Scsi_Host *shost = class_to_shost(dev);\ |
3de2a653 JS |
1384 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
1385 | int val = 0;\ | |
1386 | val = vport->cfg_##attr;\ | |
1387 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ | |
1388 | } | |
1389 | ||
e59058c4 | 1390 | /** |
3621a710 | 1391 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
e59058c4 JS |
1392 | * |
1393 | * Description: | |
1394 | * Macro that given an attr e.g. | |
1395 | * hba_queue_depth expands into a function with the name | |
1396 | * lpfc_hba_queue_depth_show | |
1397 | * | |
3621a710 | 1398 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
e59058c4 JS |
1399 | * @dev: class device that is converted into a Scsi_host. |
1400 | * @attr: device attribute, not used. | |
3621a710 | 1401 | * @buf: on return contains the attribute value in hexadecimal. |
e59058c4 JS |
1402 | * |
1403 | * Returns: length of formatted string. | |
1404 | **/ | |
3de2a653 JS |
1405 | #define lpfc_vport_param_hex_show(attr) \ |
1406 | static ssize_t \ | |
ee959b00 TJ |
1407 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
1408 | char *buf) \ | |
3de2a653 | 1409 | { \ |
ee959b00 | 1410 | struct Scsi_Host *shost = class_to_shost(dev);\ |
3de2a653 JS |
1411 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
1412 | int val = 0;\ | |
1413 | val = vport->cfg_##attr;\ | |
1414 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ | |
1415 | } | |
1416 | ||
e59058c4 | 1417 | /** |
3621a710 | 1418 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
e59058c4 JS |
1419 | * |
1420 | * Description: | |
1421 | * Macro that given an attr e.g. hba_queue_depth expands | |
1422 | * into a function with the name lpfc_hba_queue_depth_init. The macro also | |
1423 | * takes a default argument, a minimum and maximum argument. | |
1424 | * | |
1425 | * lpfc_##attr##_init: validates the min and max values then sets the | |
1426 | * adapter config field accordingly, or uses the default if out of range | |
1427 | * and prints an error message. | |
1428 | * @phba: pointer the the adapter structure. | |
1429 | * @val: integer attribute value. | |
1430 | * | |
1431 | * Returns: | |
1432 | * zero on success | |
1433 | * -EINVAL if default used | |
1434 | **/ | |
3de2a653 JS |
1435 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
1436 | static int \ | |
1437 | lpfc_##attr##_init(struct lpfc_vport *vport, int val) \ | |
1438 | { \ | |
1439 | if (val >= minval && val <= maxval) {\ | |
1440 | vport->cfg_##attr = val;\ | |
1441 | return 0;\ | |
1442 | }\ | |
e8b62011 | 1443 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
d7c255b2 | 1444 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
e8b62011 | 1445 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
3de2a653 JS |
1446 | vport->cfg_##attr = default;\ |
1447 | return -EINVAL;\ | |
1448 | } | |
1449 | ||
e59058c4 | 1450 | /** |
3621a710 | 1451 | * lpfc_vport_param_set - Set a vport cfg attribute |
e59058c4 JS |
1452 | * |
1453 | * Description: | |
1454 | * Macro that given an attr e.g. hba_queue_depth expands | |
1455 | * into a function with the name lpfc_hba_queue_depth_set | |
1456 | * | |
1457 | * lpfc_##attr##_set: validates the min and max values then sets the | |
1458 | * adapter config field if in the valid range. prints error message | |
1459 | * and does not set the parameter if invalid. | |
1460 | * @phba: pointer the the adapter structure. | |
1461 | * @val: integer attribute value. | |
1462 | * | |
1463 | * Returns: | |
1464 | * zero on success | |
1465 | * -EINVAL if val is invalid | |
1466 | **/ | |
3de2a653 JS |
1467 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
1468 | static int \ | |
1469 | lpfc_##attr##_set(struct lpfc_vport *vport, int val) \ | |
1470 | { \ | |
1471 | if (val >= minval && val <= maxval) {\ | |
1472 | vport->cfg_##attr = val;\ | |
1473 | return 0;\ | |
1474 | }\ | |
e8b62011 | 1475 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
d7c255b2 | 1476 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
e8b62011 | 1477 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
3de2a653 JS |
1478 | return -EINVAL;\ |
1479 | } | |
1480 | ||
e59058c4 | 1481 | /** |
3621a710 | 1482 | * lpfc_vport_param_store - Set a vport attribute |
e59058c4 JS |
1483 | * |
1484 | * Description: | |
1485 | * Macro that given an attr e.g. hba_queue_depth | |
1486 | * expands into a function with the name lpfc_hba_queue_depth_store | |
1487 | * | |
1488 | * lpfc_##attr##_store: convert the ascii text number to an integer, then | |
1489 | * use the lpfc_##attr##_set function to set the value. | |
1490 | * @cdev: class device that is converted into a Scsi_host. | |
1491 | * @buf: contains the attribute value in decimal. | |
1492 | * @count: not used. | |
1493 | * | |
1494 | * Returns: | |
1495 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails | |
1496 | * length of buffer upon success. | |
1497 | **/ | |
3de2a653 JS |
1498 | #define lpfc_vport_param_store(attr) \ |
1499 | static ssize_t \ | |
ee959b00 TJ |
1500 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
1501 | const char *buf, size_t count) \ | |
3de2a653 | 1502 | { \ |
ee959b00 | 1503 | struct Scsi_Host *shost = class_to_shost(dev);\ |
3de2a653 JS |
1504 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
1505 | int val=0;\ | |
1506 | if (!isdigit(buf[0]))\ | |
1507 | return -EINVAL;\ | |
1508 | if (sscanf(buf, "%i", &val) != 1)\ | |
1509 | return -EINVAL;\ | |
1510 | if (lpfc_##attr##_set(vport, val) == 0) \ | |
1511 | return strlen(buf);\ | |
1512 | else \ | |
1513 | return -EINVAL;\ | |
1514 | } | |
1515 | ||
1516 | ||
7bcbb752 JSEC |
1517 | #define LPFC_ATTR(name, defval, minval, maxval, desc) \ |
1518 | static int lpfc_##name = defval;\ | |
dea3101e JB |
1519 | module_param(lpfc_##name, int, 0);\ |
1520 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
7bcbb752 | 1521 | lpfc_param_init(name, defval, minval, maxval) |
dea3101e JB |
1522 | |
1523 | #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \ | |
1524 | static int lpfc_##name = defval;\ | |
1525 | module_param(lpfc_##name, int, 0);\ | |
1526 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1527 | lpfc_param_show(name)\ | |
7bcbb752 | 1528 | lpfc_param_init(name, defval, minval, maxval)\ |
ee959b00 | 1529 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
dea3101e JB |
1530 | |
1531 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ | |
1532 | static int lpfc_##name = defval;\ | |
1533 | module_param(lpfc_##name, int, 0);\ | |
1534 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1535 | lpfc_param_show(name)\ | |
7bcbb752 JSEC |
1536 | lpfc_param_init(name, defval, minval, maxval)\ |
1537 | lpfc_param_set(name, defval, minval, maxval)\ | |
1538 | lpfc_param_store(name)\ | |
ee959b00 TJ |
1539 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
1540 | lpfc_##name##_show, lpfc_##name##_store) | |
dea3101e | 1541 | |
93a20f74 JSEC |
1542 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
1543 | static int lpfc_##name = defval;\ | |
1544 | module_param(lpfc_##name, int, 0);\ | |
1545 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1546 | lpfc_param_hex_show(name)\ | |
1547 | lpfc_param_init(name, defval, minval, maxval)\ | |
ee959b00 | 1548 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
93a20f74 JSEC |
1549 | |
1550 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ | |
1551 | static int lpfc_##name = defval;\ | |
1552 | module_param(lpfc_##name, int, 0);\ | |
1553 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1554 | lpfc_param_hex_show(name)\ | |
1555 | lpfc_param_init(name, defval, minval, maxval)\ | |
1556 | lpfc_param_set(name, defval, minval, maxval)\ | |
1557 | lpfc_param_store(name)\ | |
ee959b00 TJ |
1558 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
1559 | lpfc_##name##_show, lpfc_##name##_store) | |
93a20f74 | 1560 | |
3de2a653 JS |
1561 | #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ |
1562 | static int lpfc_##name = defval;\ | |
1563 | module_param(lpfc_##name, int, 0);\ | |
1564 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1565 | lpfc_vport_param_init(name, defval, minval, maxval) | |
1566 | ||
1567 | #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \ | |
1568 | static int lpfc_##name = defval;\ | |
1569 | module_param(lpfc_##name, int, 0);\ | |
1570 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1571 | lpfc_vport_param_show(name)\ | |
1572 | lpfc_vport_param_init(name, defval, minval, maxval)\ | |
ee959b00 | 1573 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
3de2a653 JS |
1574 | |
1575 | #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ | |
1576 | static int lpfc_##name = defval;\ | |
1577 | module_param(lpfc_##name, int, 0);\ | |
1578 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1579 | lpfc_vport_param_show(name)\ | |
1580 | lpfc_vport_param_init(name, defval, minval, maxval)\ | |
1581 | lpfc_vport_param_set(name, defval, minval, maxval)\ | |
1582 | lpfc_vport_param_store(name)\ | |
ee959b00 TJ |
1583 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
1584 | lpfc_##name##_show, lpfc_##name##_store) | |
3de2a653 JS |
1585 | |
1586 | #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ | |
1587 | static int lpfc_##name = defval;\ | |
1588 | module_param(lpfc_##name, int, 0);\ | |
1589 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1590 | lpfc_vport_param_hex_show(name)\ | |
1591 | lpfc_vport_param_init(name, defval, minval, maxval)\ | |
ee959b00 | 1592 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
3de2a653 JS |
1593 | |
1594 | #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ | |
1595 | static int lpfc_##name = defval;\ | |
1596 | module_param(lpfc_##name, int, 0);\ | |
1597 | MODULE_PARM_DESC(lpfc_##name, desc);\ | |
1598 | lpfc_vport_param_hex_show(name)\ | |
1599 | lpfc_vport_param_init(name, defval, minval, maxval)\ | |
1600 | lpfc_vport_param_set(name, defval, minval, maxval)\ | |
1601 | lpfc_vport_param_store(name)\ | |
ee959b00 TJ |
1602 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
1603 | lpfc_##name##_show, lpfc_##name##_store) | |
1604 | ||
81301a9b JS |
1605 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
1606 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); | |
1607 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); | |
1608 | static DEVICE_ATTR(bg_reftag_err, S_IRUGO, lpfc_bg_reftag_err_show, NULL); | |
ee959b00 TJ |
1609 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
1610 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); | |
1611 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); | |
1612 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); | |
1613 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); | |
1614 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); | |
1615 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); | |
1616 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); | |
bbd1ae41 | 1617 | static DEVICE_ATTR(link_state, S_IRUGO, lpfc_link_state_show, NULL); |
ee959b00 TJ |
1618 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
1619 | lpfc_option_rom_version_show, NULL); | |
1620 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, | |
1621 | lpfc_num_discovered_ports_show, NULL); | |
84774a4d | 1622 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
ee959b00 TJ |
1623 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
1624 | static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); | |
45ed1190 | 1625 | static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL); |
ee959b00 TJ |
1626 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
1627 | lpfc_board_mode_show, lpfc_board_mode_store); | |
1628 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); | |
1629 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); | |
1630 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); | |
1631 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); | |
1632 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); | |
1633 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); | |
1634 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); | |
1635 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); | |
1636 | static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); | |
dea3101e | 1637 | |
c3f28afa | 1638 | |
a12e07bc | 1639 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
c3f28afa | 1640 | |
e59058c4 | 1641 | /** |
3621a710 | 1642 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
e59058c4 JS |
1643 | * @dev: class device that is converted into a Scsi_host. |
1644 | * @attr: device attribute, not used. | |
1645 | * @buf: containing the string lpfc_soft_wwn_key. | |
1646 | * @count: must be size of lpfc_soft_wwn_key. | |
1647 | * | |
1648 | * Returns: | |
1649 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key | |
1650 | * length of buf indicates success | |
1651 | **/ | |
c3f28afa | 1652 | static ssize_t |
ee959b00 TJ |
1653 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
1654 | const char *buf, size_t count) | |
c3f28afa | 1655 | { |
ee959b00 | 1656 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
1657 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1658 | struct lpfc_hba *phba = vport->phba; | |
c3f28afa JS |
1659 | unsigned int cnt = count; |
1660 | ||
1661 | /* | |
1662 | * We're doing a simple sanity check for soft_wwpn setting. | |
1663 | * We require that the user write a specific key to enable | |
1664 | * the soft_wwpn attribute to be settable. Once the attribute | |
1665 | * is written, the enable key resets. If further updates are | |
1666 | * desired, the key must be written again to re-enable the | |
1667 | * attribute. | |
1668 | * | |
1669 | * The "key" is not secret - it is a hardcoded string shown | |
1670 | * here. The intent is to protect against the random user or | |
1671 | * application that is just writing attributes. | |
1672 | */ | |
1673 | ||
1674 | /* count may include a LF at end of string */ | |
1675 | if (buf[cnt-1] == '\n') | |
1676 | cnt--; | |
1677 | ||
a12e07bc JS |
1678 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
1679 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) | |
c3f28afa JS |
1680 | return -EINVAL; |
1681 | ||
a12e07bc | 1682 | phba->soft_wwn_enable = 1; |
c3f28afa JS |
1683 | return count; |
1684 | } | |
ee959b00 TJ |
1685 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
1686 | lpfc_soft_wwn_enable_store); | |
c3f28afa | 1687 | |
e59058c4 | 1688 | /** |
3621a710 | 1689 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
e59058c4 JS |
1690 | * @dev: class device that is converted into a Scsi_host. |
1691 | * @attr: device attribute, not used. | |
3621a710 | 1692 | * @buf: on return contains the wwpn in hexadecimal. |
e59058c4 JS |
1693 | * |
1694 | * Returns: size of formatted string. | |
1695 | **/ | |
c3f28afa | 1696 | static ssize_t |
ee959b00 TJ |
1697 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
1698 | char *buf) | |
c3f28afa | 1699 | { |
ee959b00 | 1700 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
1701 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1702 | struct lpfc_hba *phba = vport->phba; | |
1703 | ||
afc071e6 RD |
1704 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
1705 | (unsigned long long)phba->cfg_soft_wwpn); | |
c3f28afa JS |
1706 | } |
1707 | ||
e59058c4 | 1708 | /** |
3621a710 | 1709 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
e59058c4 JS |
1710 | * @dev class device that is converted into a Scsi_host. |
1711 | * @attr: device attribute, not used. | |
3621a710 | 1712 | * @buf: contains the wwpn in hexadecimal. |
e59058c4 JS |
1713 | * @count: number of wwpn bytes in buf |
1714 | * | |
1715 | * Returns: | |
1716 | * -EACCES hba reset not enabled, adapter over temp | |
1717 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid | |
1718 | * -EIO error taking adapter offline or online | |
1719 | * value of count on success | |
1720 | **/ | |
c3f28afa | 1721 | static ssize_t |
ee959b00 TJ |
1722 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
1723 | const char *buf, size_t count) | |
c3f28afa | 1724 | { |
ee959b00 | 1725 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 JS |
1726 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1727 | struct lpfc_hba *phba = vport->phba; | |
c3f28afa JS |
1728 | struct completion online_compl; |
1729 | int stat1=0, stat2=0; | |
1730 | unsigned int i, j, cnt=count; | |
1731 | u8 wwpn[8]; | |
1732 | ||
13815c83 JS |
1733 | if (!phba->cfg_enable_hba_reset) |
1734 | return -EACCES; | |
7af67051 JS |
1735 | spin_lock_irq(&phba->hbalock); |
1736 | if (phba->over_temp_state == HBA_OVER_TEMP) { | |
1737 | spin_unlock_irq(&phba->hbalock); | |
09372820 | 1738 | return -EACCES; |
7af67051 JS |
1739 | } |
1740 | spin_unlock_irq(&phba->hbalock); | |
c3f28afa JS |
1741 | /* count may include a LF at end of string */ |
1742 | if (buf[cnt-1] == '\n') | |
1743 | cnt--; | |
1744 | ||
a12e07bc | 1745 | if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || |
c3f28afa JS |
1746 | ((cnt == 17) && (*buf++ != 'x')) || |
1747 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) | |
1748 | return -EINVAL; | |
1749 | ||
a12e07bc | 1750 | phba->soft_wwn_enable = 0; |
c3f28afa JS |
1751 | |
1752 | memset(wwpn, 0, sizeof(wwpn)); | |
1753 | ||
1754 | /* Validate and store the new name */ | |
1755 | for (i=0, j=0; i < 16; i++) { | |
1756 | if ((*buf >= 'a') && (*buf <= 'f')) | |
1757 | j = ((j << 4) | ((*buf++ -'a') + 10)); | |
1758 | else if ((*buf >= 'A') && (*buf <= 'F')) | |
1759 | j = ((j << 4) | ((*buf++ -'A') + 10)); | |
1760 | else if ((*buf >= '0') && (*buf <= '9')) | |
1761 | j = ((j << 4) | (*buf++ -'0')); | |
1762 | else | |
1763 | return -EINVAL; | |
1764 | if (i % 2) { | |
1765 | wwpn[i/2] = j & 0xff; | |
1766 | j = 0; | |
1767 | } | |
1768 | } | |
1769 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); | |
2e0fef85 | 1770 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
a12e07bc | 1771 | if (phba->cfg_soft_wwnn) |
2e0fef85 | 1772 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
c3f28afa JS |
1773 | |
1774 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, | |
1775 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); | |
1776 | ||
46fa311e | 1777 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
c3f28afa JS |
1778 | if (stat1) |
1779 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
e8b62011 JS |
1780 | "0463 lpfc_soft_wwpn attribute set failed to " |
1781 | "reinit adapter - %d\n", stat1); | |
c3f28afa JS |
1782 | init_completion(&online_compl); |
1783 | lpfc_workq_post_event(phba, &stat2, &online_compl, LPFC_EVT_ONLINE); | |
1784 | wait_for_completion(&online_compl); | |
1785 | if (stat2) | |
1786 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
e8b62011 JS |
1787 | "0464 lpfc_soft_wwpn attribute set failed to " |
1788 | "reinit adapter - %d\n", stat2); | |
c3f28afa JS |
1789 | return (stat1 || stat2) ? -EIO : count; |
1790 | } | |
ee959b00 TJ |
1791 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ |
1792 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); | |
c3f28afa | 1793 | |
e59058c4 | 1794 | /** |
3621a710 | 1795 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
e59058c4 JS |
1796 | * @dev: class device that is converted into a Scsi_host. |
1797 | * @attr: device attribute, not used. | |
3621a710 | 1798 | * @buf: on return contains the wwnn in hexadecimal. |
e59058c4 JS |
1799 | * |
1800 | * Returns: size of formatted string. | |
1801 | **/ | |
a12e07bc | 1802 | static ssize_t |
ee959b00 TJ |
1803 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
1804 | char *buf) | |
a12e07bc | 1805 | { |
ee959b00 | 1806 | struct Scsi_Host *shost = class_to_shost(dev); |
51ef4c26 | 1807 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
a12e07bc JS |
1808 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
1809 | (unsigned long long)phba->cfg_soft_wwnn); | |
1810 | } | |
1811 | ||
e59058c4 | 1812 | /** |
3621a710 | 1813 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
e59058c4 | 1814 | * @cdev: class device that is converted into a Scsi_host. |
3621a710 | 1815 | * @buf: contains the ww node name in hexadecimal. |
e59058c4 JS |
1816 | * @count: number of wwnn bytes in buf. |
1817 | * | |
1818 | * Returns: | |
1819 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid | |
1820 | * value of count on success | |
1821 | **/ | |
a12e07bc | 1822 | static ssize_t |
ee959b00 TJ |
1823 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
1824 | const char *buf, size_t count) | |
a12e07bc | 1825 | { |
ee959b00 | 1826 | struct Scsi_Host *shost = class_to_shost(dev); |
51ef4c26 | 1827 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
a12e07bc JS |
1828 | unsigned int i, j, cnt=count; |
1829 | u8 wwnn[8]; | |
1830 | ||
1831 | /* count may include a LF at end of string */ | |
1832 | if (buf[cnt-1] == '\n') | |
1833 | cnt--; | |
1834 | ||
1835 | if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || | |
1836 | ((cnt == 17) && (*buf++ != 'x')) || | |
1837 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) | |
1838 | return -EINVAL; | |
1839 | ||
1840 | /* | |
1841 | * Allow wwnn to be set many times, as long as the enable is set. | |
1842 | * However, once the wwpn is set, everything locks. | |
1843 | */ | |
1844 | ||
1845 | memset(wwnn, 0, sizeof(wwnn)); | |
1846 | ||
1847 | /* Validate and store the new name */ | |
1848 | for (i=0, j=0; i < 16; i++) { | |
1849 | if ((*buf >= 'a') && (*buf <= 'f')) | |
1850 | j = ((j << 4) | ((*buf++ -'a') + 10)); | |
1851 | else if ((*buf >= 'A') && (*buf <= 'F')) | |
1852 | j = ((j << 4) | ((*buf++ -'A') + 10)); | |
1853 | else if ((*buf >= '0') && (*buf <= '9')) | |
1854 | j = ((j << 4) | (*buf++ -'0')); | |
1855 | else | |
1856 | return -EINVAL; | |
1857 | if (i % 2) { | |
1858 | wwnn[i/2] = j & 0xff; | |
1859 | j = 0; | |
1860 | } | |
1861 | } | |
1862 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); | |
1863 | ||
1864 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, | |
1865 | "lpfc%d: soft_wwnn set. Value will take effect upon " | |
1866 | "setting of the soft_wwpn\n", phba->brd_no); | |
1867 | ||
1868 | return count; | |
1869 | } | |
ee959b00 TJ |
1870 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ |
1871 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); | |
a12e07bc | 1872 | |
c3f28afa | 1873 | |
875fbdfe JSEC |
1874 | static int lpfc_poll = 0; |
1875 | module_param(lpfc_poll, int, 0); | |
1876 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" | |
1877 | " 0 - none," | |
1878 | " 1 - poll with interrupts enabled" | |
1879 | " 3 - poll and disable FCP ring interrupts"); | |
1880 | ||
ee959b00 TJ |
1881 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
1882 | lpfc_poll_show, lpfc_poll_store); | |
dea3101e | 1883 | |
92d7f7b0 JS |
1884 | int lpfc_sli_mode = 0; |
1885 | module_param(lpfc_sli_mode, int, 0); | |
1886 | MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" | |
1887 | " 0 - auto (SLI-3 if supported)," | |
1888 | " 2 - select SLI-2 even on SLI-3 capable HBAs," | |
1889 | " 3 - select SLI-3"); | |
1890 | ||
7ee5d43e JS |
1891 | int lpfc_enable_npiv = 0; |
1892 | module_param(lpfc_enable_npiv, int, 0); | |
1893 | MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); | |
1894 | lpfc_param_show(enable_npiv); | |
1895 | lpfc_param_init(enable_npiv, 0, 0, 1); | |
ee959b00 | 1896 | static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, |
7ee5d43e | 1897 | lpfc_enable_npiv_show, NULL); |
92d7f7b0 | 1898 | |
c01f3208 JS |
1899 | /* |
1900 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear | |
1901 | # until the timer expires. Value range is [0,255]. Default value is 30. | |
1902 | */ | |
1903 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; | |
1904 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; | |
1905 | module_param(lpfc_nodev_tmo, int, 0); | |
1906 | MODULE_PARM_DESC(lpfc_nodev_tmo, | |
1907 | "Seconds driver will hold I/O waiting " | |
1908 | "for a device to come back"); | |
e59058c4 JS |
1909 | |
1910 | /** | |
3621a710 | 1911 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
e59058c4 JS |
1912 | * @dev: class converted to a Scsi_host structure. |
1913 | * @attr: device attribute, not used. | |
1914 | * @buf: on return contains the dev loss timeout in decimal. | |
1915 | * | |
1916 | * Returns: size of formatted string. | |
1917 | **/ | |
c01f3208 | 1918 | static ssize_t |
ee959b00 TJ |
1919 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
1920 | char *buf) | |
c01f3208 | 1921 | { |
ee959b00 | 1922 | struct Scsi_Host *shost = class_to_shost(dev); |
2e0fef85 | 1923 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
c01f3208 | 1924 | int val = 0; |
3de2a653 JS |
1925 | val = vport->cfg_devloss_tmo; |
1926 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); | |
c01f3208 JS |
1927 | } |
1928 | ||
e59058c4 | 1929 | /** |
3621a710 | 1930 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
e59058c4 JS |
1931 | * @vport: lpfc vport structure pointer. |
1932 | * @val: contains the nodev timeout value. | |
1933 | * | |
1934 | * Description: | |
1935 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, | |
1936 | * a kernel error message is printed and zero is returned. | |
1937 | * Else if val is in range then nodev tmo and devloss tmo are set to val. | |
1938 | * Otherwise nodev tmo is set to the default value. | |
1939 | * | |
1940 | * Returns: | |
1941 | * zero if already set or if val is in range | |
1942 | * -EINVAL val out of range | |
1943 | **/ | |
c01f3208 | 1944 | static int |
3de2a653 JS |
1945 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
1946 | { | |
1947 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { | |
1948 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; | |
1949 | if (val != LPFC_DEF_DEVLOSS_TMO) | |
e8b62011 | 1950 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
d7c255b2 | 1951 | "0407 Ignoring nodev_tmo module " |
e8b62011 JS |
1952 | "parameter because devloss_tmo is " |
1953 | "set.\n"); | |
c01f3208 JS |
1954 | return 0; |
1955 | } | |
1956 | ||
1957 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { | |
3de2a653 JS |
1958 | vport->cfg_nodev_tmo = val; |
1959 | vport->cfg_devloss_tmo = val; | |
c01f3208 JS |
1960 | return 0; |
1961 | } | |
e8b62011 JS |
1962 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
1963 | "0400 lpfc_nodev_tmo attribute cannot be set to" | |
1964 | " %d, allowed range is [%d, %d]\n", | |
1965 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); | |
3de2a653 | 1966 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
c01f3208 JS |
1967 | return -EINVAL; |
1968 | } | |
1969 | ||
e59058c4 | 1970 | /** |
3621a710 | 1971 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
e59058c4 JS |
1972 | * @vport: lpfc vport structure pointer. |
1973 | * | |
1974 | * Description: | |
1975 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. | |
1976 | **/ | |
7054a606 | 1977 | static void |
3de2a653 | 1978 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
7054a606 | 1979 | { |
858c9f6c | 1980 | struct Scsi_Host *shost; |
7054a606 JS |
1981 | struct lpfc_nodelist *ndlp; |
1982 | ||
51ef4c26 JS |
1983 | shost = lpfc_shost_from_vport(vport); |
1984 | spin_lock_irq(shost->host_lock); | |
1985 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) | |
e47c9093 | 1986 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
51ef4c26 JS |
1987 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
1988 | spin_unlock_irq(shost->host_lock); | |
7054a606 JS |
1989 | } |
1990 | ||
e59058c4 | 1991 | /** |
3621a710 | 1992 | * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values |
e59058c4 JS |
1993 | * @vport: lpfc vport structure pointer. |
1994 | * @val: contains the tmo value. | |
1995 | * | |
1996 | * Description: | |
1997 | * If the devloss tmo is already set or the vport dev loss tmo has changed | |
1998 | * then a kernel error message is printed and zero is returned. | |
1999 | * Else if val is in range then nodev tmo and devloss tmo are set to val. | |
2000 | * Otherwise nodev tmo is set to the default value. | |
2001 | * | |
2002 | * Returns: | |
2003 | * zero if already set or if val is in range | |
2004 | * -EINVAL val out of range | |
2005 | **/ | |
c01f3208 | 2006 | static int |
3de2a653 | 2007 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
c01f3208 | 2008 | { |
3de2a653 JS |
2009 | if (vport->dev_loss_tmo_changed || |
2010 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { | |
e8b62011 JS |
2011 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
2012 | "0401 Ignoring change to nodev_tmo " | |
2013 | "because devloss_tmo is set.\n"); | |
c01f3208 JS |
2014 | return 0; |
2015 | } | |
c01f3208 | 2016 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
3de2a653 JS |
2017 | vport->cfg_nodev_tmo = val; |
2018 | vport->cfg_devloss_tmo = val; | |
2019 | lpfc_update_rport_devloss_tmo(vport); | |
c01f3208 JS |
2020 | return 0; |
2021 | } | |
e8b62011 JS |
2022 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
2023 | "0403 lpfc_nodev_tmo attribute cannot be set to" | |
2024 | "%d, allowed range is [%d, %d]\n", | |
2025 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); | |
c01f3208 JS |
2026 | return -EINVAL; |
2027 | } | |
2028 | ||
3de2a653 | 2029 | lpfc_vport_param_store(nodev_tmo) |
c01f3208 | 2030 | |
ee959b00 TJ |
2031 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
2032 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); | |
c01f3208 JS |
2033 | |
2034 | /* | |
2035 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that | |
2036 | # disappear until the timer expires. Value range is [0,255]. Default | |
2037 | # value is 30. | |
2038 | */ | |
2039 | module_param(lpfc_devloss_tmo, int, 0); | |
2040 | MODULE_PARM_DESC(lpfc_devloss_tmo, | |
2041 | "Seconds driver will hold I/O waiting " | |
2042 | "for a device to come back"); | |
3de2a653 JS |
2043 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
2044 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) | |
2045 | lpfc_vport_param_show(devloss_tmo) | |
e59058c4 JS |
2046 | |
2047 | /** | |
3621a710 | 2048 | * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit |
e59058c4 JS |
2049 | * @vport: lpfc vport structure pointer. |
2050 | * @val: contains the tmo value. | |
2051 | * | |
2052 | * Description: | |
2053 | * If val is in a valid range then set the vport nodev tmo, | |
2054 | * devloss tmo, also set the vport dev loss tmo changed flag. | |
2055 | * Else a kernel error message is printed. | |
2056 | * | |
2057 | * Returns: | |
2058 | * zero if val is in range | |
2059 | * -EINVAL val out of range | |
2060 | **/ | |
c01f3208 | 2061 | static int |
3de2a653 | 2062 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
c01f3208 JS |
2063 | { |
2064 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { | |
3de2a653 JS |
2065 | vport->cfg_nodev_tmo = val; |
2066 | vport->cfg_devloss_tmo = val; | |
2067 | vport->dev_loss_tmo_changed = 1; | |
2068 | lpfc_update_rport_devloss_tmo(vport); | |
c01f3208 JS |
2069 | return 0; |
2070 | } | |
2071 | ||
e8b62011 JS |
2072 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
2073 | "0404 lpfc_devloss_tmo attribute cannot be set to" | |
2074 | " %d, allowed range is [%d, %d]\n", | |
2075 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); | |
c01f3208 JS |
2076 | return -EINVAL; |
2077 | } | |
2078 | ||
3de2a653 | 2079 | lpfc_vport_param_store(devloss_tmo) |
ee959b00 TJ |
2080 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
2081 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); | |
c01f3208 | 2082 | |
dea3101e JB |
2083 | /* |
2084 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being | |
2085 | # deluged with LOTS of information. | |
2086 | # You can set a bit mask to record specific types of verbose messages: | |
f4b4c68f | 2087 | # See lpfc_logmsh.h for definitions. |
dea3101e | 2088 | */ |
f4b4c68f | 2089 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
e8b62011 | 2090 | "Verbose logging bit-mask"); |
dea3101e | 2091 | |
7ee5d43e JS |
2092 | /* |
2093 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters | |
2094 | # objects that have been registered with the nameserver after login. | |
2095 | */ | |
2096 | LPFC_VPORT_ATTR_R(enable_da_id, 0, 0, 1, | |
2097 | "Deregister nameserver objects before LOGO"); | |
2098 | ||
dea3101e JB |
2099 | /* |
2100 | # lun_queue_depth: This parameter is used to limit the number of outstanding | |
2101 | # commands per FCP LUN. Value range is [1,128]. Default value is 30. | |
2102 | */ | |
3de2a653 JS |
2103 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 128, |
2104 | "Max number of FCP commands we can queue to a specific LUN"); | |
dea3101e | 2105 | |
b28485ac JW |
2106 | /* |
2107 | # hba_queue_depth: This parameter is used to limit the number of outstanding | |
2108 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter | |
2109 | # value is greater than the maximum number of exchanges supported by the HBA, | |
2110 | # then maximum number of exchanges supported by the HBA is used to determine | |
2111 | # the hba_queue_depth. | |
2112 | */ | |
2113 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, | |
2114 | "Max number of FCP commands we can queue to a lpfc HBA"); | |
2115 | ||
92d7f7b0 JS |
2116 | /* |
2117 | # peer_port_login: This parameter allows/prevents logins | |
2118 | # between peer ports hosted on the same physical port. | |
2119 | # When this parameter is set 0 peer ports of same physical port | |
2120 | # are not allowed to login to each other. | |
2121 | # When this parameter is set 1 peer ports of same physical port | |
2122 | # are allowed to login to each other. | |
2123 | # Default value of this parameter is 0. | |
2124 | */ | |
3de2a653 JS |
2125 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
2126 | "Allow peer ports on the same physical port to login to each " | |
2127 | "other."); | |
92d7f7b0 JS |
2128 | |
2129 | /* | |
3de2a653 | 2130 | # restrict_login: This parameter allows/prevents logins |
92d7f7b0 JS |
2131 | # between Virtual Ports and remote initiators. |
2132 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from | |
2133 | # other initiators and will attempt to PLOGI all remote ports. | |
2134 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from | |
2135 | # remote ports and will not attempt to PLOGI to other initiators. | |
2136 | # This parameter does not restrict to the physical port. | |
2137 | # This parameter does not restrict logins to Fabric resident remote ports. | |
2138 | # Default value of this parameter is 1. | |
2139 | */ | |
3de2a653 JS |
2140 | static int lpfc_restrict_login = 1; |
2141 | module_param(lpfc_restrict_login, int, 0); | |
2142 | MODULE_PARM_DESC(lpfc_restrict_login, | |
2143 | "Restrict virtual ports login to remote initiators."); | |
2144 | lpfc_vport_param_show(restrict_login); | |
2145 | ||
e59058c4 | 2146 | /** |
3621a710 | 2147 | * lpfc_restrict_login_init - Set the vport restrict login flag |
e59058c4 JS |
2148 | * @vport: lpfc vport structure pointer. |
2149 | * @val: contains the restrict login value. | |
2150 | * | |
2151 | * Description: | |
2152 | * If val is not in a valid range then log a kernel error message and set | |
2153 | * the vport restrict login to one. | |
2154 | * If the port type is physical clear the restrict login flag and return. | |
2155 | * Else set the restrict login flag to val. | |
2156 | * | |
2157 | * Returns: | |
2158 | * zero if val is in range | |
2159 | * -EINVAL val out of range | |
2160 | **/ | |
3de2a653 JS |
2161 | static int |
2162 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) | |
2163 | { | |
2164 | if (val < 0 || val > 1) { | |
e8b62011 | 2165 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
d7c255b2 | 2166 | "0422 lpfc_restrict_login attribute cannot " |
e8b62011 JS |
2167 | "be set to %d, allowed range is [0, 1]\n", |
2168 | val); | |
3de2a653 JS |
2169 | vport->cfg_restrict_login = 1; |
2170 | return -EINVAL; | |
2171 | } | |
2172 | if (vport->port_type == LPFC_PHYSICAL_PORT) { | |
2173 | vport->cfg_restrict_login = 0; | |
2174 | return 0; | |
2175 | } | |
2176 | vport->cfg_restrict_login = val; | |
2177 | return 0; | |
2178 | } | |
2179 | ||
e59058c4 | 2180 | /** |
3621a710 | 2181 | * lpfc_restrict_login_set - Set the vport restrict login flag |
e59058c4 JS |
2182 | * @vport: lpfc vport structure pointer. |
2183 | * @val: contains the restrict login value. | |
2184 | * | |
2185 | * Description: | |
2186 | * If val is not in a valid range then log a kernel error message and set | |
2187 | * the vport restrict login to one. | |
2188 | * If the port type is physical and the val is not zero log a kernel | |
2189 | * error message, clear the restrict login flag and return zero. | |
2190 | * Else set the restrict login flag to val. | |
2191 | * | |
2192 | * Returns: | |
2193 | * zero if val is in range | |
2194 | * -EINVAL val out of range | |
2195 | **/ | |
3de2a653 JS |
2196 | static int |
2197 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) | |
2198 | { | |
2199 | if (val < 0 || val > 1) { | |
e8b62011 | 2200 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
d7c255b2 | 2201 | "0425 lpfc_restrict_login attribute cannot " |
e8b62011 JS |
2202 | "be set to %d, allowed range is [0, 1]\n", |
2203 | val); | |
3de2a653 JS |
2204 | vport->cfg_restrict_login = 1; |
2205 | return -EINVAL; | |
2206 | } | |
2207 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { | |
e8b62011 JS |
2208 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
2209 | "0468 lpfc_restrict_login must be 0 for " | |
2210 | "Physical ports.\n"); | |
3de2a653 JS |
2211 | vport->cfg_restrict_login = 0; |
2212 | return 0; | |
2213 | } | |
2214 | vport->cfg_restrict_login = val; | |
2215 | return 0; | |
2216 | } | |
2217 | lpfc_vport_param_store(restrict_login); | |
ee959b00 TJ |
2218 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
2219 | lpfc_restrict_login_show, lpfc_restrict_login_store); | |
92d7f7b0 | 2220 | |
dea3101e JB |
2221 | /* |
2222 | # Some disk devices have a "select ID" or "select Target" capability. | |
2223 | # From a protocol standpoint "select ID" usually means select the | |
2224 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative | |
2225 | # annex" which contains a table that maps a "select ID" (a number | |
2226 | # between 0 and 7F) to an ALPA. By default, for compatibility with | |
2227 | # older drivers, the lpfc driver scans this table from low ALPA to high | |
2228 | # ALPA. | |
2229 | # | |
2230 | # Turning on the scan-down variable (on = 1, off = 0) will | |
2231 | # cause the lpfc driver to use an inverted table, effectively | |
2232 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. | |
2233 | # | |
2234 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic | |
2235 | # and will not work across a fabric. Also this parameter will take | |
2236 | # effect only in the case when ALPA map is not available.) | |
2237 | */ | |
3de2a653 JS |
2238 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
2239 | "Start scanning for devices from highest ALPA to lowest"); | |
dea3101e | 2240 | |
dea3101e JB |
2241 | /* |
2242 | # lpfc_topology: link topology for init link | |
2243 | # 0x0 = attempt loop mode then point-to-point | |
367c2713 | 2244 | # 0x01 = internal loopback mode |
dea3101e JB |
2245 | # 0x02 = attempt point-to-point mode only |
2246 | # 0x04 = attempt loop mode only | |
2247 | # 0x06 = attempt point-to-point mode then loop | |
2248 | # Set point-to-point mode if you want to run as an N_Port. | |
2249 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. | |
2250 | # Default value is 0. | |
2251 | */ | |
e59058c4 JS |
2252 | |
2253 | /** | |
3621a710 | 2254 | * lpfc_topology_set - Set the adapters topology field |
e59058c4 JS |
2255 | * @phba: lpfc_hba pointer. |
2256 | * @val: topology value. | |
2257 | * | |
2258 | * Description: | |
2259 | * If val is in a valid range then set the adapter's topology field and | |
2260 | * issue a lip; if the lip fails reset the topology to the old value. | |
2261 | * | |
2262 | * If the value is not in range log a kernel error message and return an error. | |
2263 | * | |
2264 | * Returns: | |
2265 | * zero if val is in range and lip okay | |
2266 | * non-zero return value from lpfc_issue_lip() | |
2267 | * -EINVAL val out of range | |
2268 | **/ | |
a257bf90 JS |
2269 | static ssize_t |
2270 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, | |
2271 | const char *buf, size_t count) | |
83108bd3 | 2272 | { |
a257bf90 JS |
2273 | struct Scsi_Host *shost = class_to_shost(dev); |
2274 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
2275 | struct lpfc_hba *phba = vport->phba; | |
2276 | int val = 0; | |
2277 | int nolip = 0; | |
2278 | const char *val_buf = buf; | |
83108bd3 JS |
2279 | int err; |
2280 | uint32_t prev_val; | |
a257bf90 JS |
2281 | |
2282 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { | |
2283 | nolip = 1; | |
2284 | val_buf = &buf[strlen("nolip ")]; | |
2285 | } | |
2286 | ||
2287 | if (!isdigit(val_buf[0])) | |
2288 | return -EINVAL; | |
2289 | if (sscanf(val_buf, "%i", &val) != 1) | |
2290 | return -EINVAL; | |
2291 | ||
83108bd3 JS |
2292 | if (val >= 0 && val <= 6) { |
2293 | prev_val = phba->cfg_topology; | |
2294 | phba->cfg_topology = val; | |
a257bf90 JS |
2295 | if (nolip) |
2296 | return strlen(buf); | |
2297 | ||
83108bd3 | 2298 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
a257bf90 | 2299 | if (err) { |
83108bd3 | 2300 | phba->cfg_topology = prev_val; |
a257bf90 JS |
2301 | return -EINVAL; |
2302 | } else | |
2303 | return strlen(buf); | |
83108bd3 JS |
2304 | } |
2305 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
2306 | "%d:0467 lpfc_topology attribute cannot be set to %d, " | |
2307 | "allowed range is [0, 6]\n", | |
2308 | phba->brd_no, val); | |
2309 | return -EINVAL; | |
2310 | } | |
2311 | static int lpfc_topology = 0; | |
2312 | module_param(lpfc_topology, int, 0); | |
2313 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); | |
2314 | lpfc_param_show(topology) | |
2315 | lpfc_param_init(topology, 0, 0, 6) | |
ee959b00 | 2316 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
83108bd3 | 2317 | lpfc_topology_show, lpfc_topology_store); |
dea3101e | 2318 | |
21e9a0a5 JS |
2319 | /** |
2320 | * lpfc_static_vport_show: Read callback function for | |
2321 | * lpfc_static_vport sysfs file. | |
2322 | * @dev: Pointer to class device object. | |
2323 | * @attr: device attribute structure. | |
2324 | * @buf: Data buffer. | |
2325 | * | |
2326 | * This function is the read call back function for | |
2327 | * lpfc_static_vport sysfs file. The lpfc_static_vport | |
2328 | * sysfs file report the mageability of the vport. | |
2329 | **/ | |
2330 | static ssize_t | |
2331 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, | |
2332 | char *buf) | |
2333 | { | |
2334 | struct Scsi_Host *shost = class_to_shost(dev); | |
2335 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
2336 | if (vport->vport_flag & STATIC_VPORT) | |
2337 | sprintf(buf, "1\n"); | |
2338 | else | |
2339 | sprintf(buf, "0\n"); | |
2340 | ||
2341 | return strlen(buf); | |
2342 | } | |
2343 | ||
2344 | /* | |
2345 | * Sysfs attribute to control the statistical data collection. | |
2346 | */ | |
2347 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, | |
2348 | lpfc_static_vport_show, NULL); | |
ea2151b4 JS |
2349 | |
2350 | /** | |
3621a710 | 2351 | * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file |
ea2151b4 JS |
2352 | * @dev: Pointer to class device. |
2353 | * @buf: Data buffer. | |
2354 | * @count: Size of the data buffer. | |
2355 | * | |
2356 | * This function get called when an user write to the lpfc_stat_data_ctrl | |
2357 | * sysfs file. This function parse the command written to the sysfs file | |
2358 | * and take appropriate action. These commands are used for controlling | |
2359 | * driver statistical data collection. | |
2360 | * Following are the command this function handles. | |
2361 | * | |
2362 | * setbucket <bucket_type> <base> <step> | |
2363 | * = Set the latency buckets. | |
2364 | * destroybucket = destroy all the buckets. | |
2365 | * start = start data collection | |
2366 | * stop = stop data collection | |
2367 | * reset = reset the collected data | |
2368 | **/ | |
2369 | static ssize_t | |
2370 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, | |
2371 | const char *buf, size_t count) | |
2372 | { | |
2373 | struct Scsi_Host *shost = class_to_shost(dev); | |
2374 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
2375 | struct lpfc_hba *phba = vport->phba; | |
2376 | #define LPFC_MAX_DATA_CTRL_LEN 1024 | |
2377 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; | |
2378 | unsigned long i; | |
2379 | char *str_ptr, *token; | |
2380 | struct lpfc_vport **vports; | |
2381 | struct Scsi_Host *v_shost; | |
2382 | char *bucket_type_str, *base_str, *step_str; | |
2383 | unsigned long base, step, bucket_type; | |
2384 | ||
2385 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { | |
a257bf90 | 2386 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
ea2151b4 JS |
2387 | return -EINVAL; |
2388 | ||
2389 | strcpy(bucket_data, buf); | |
2390 | str_ptr = &bucket_data[0]; | |
2391 | /* Ignore this token - this is command token */ | |
2392 | token = strsep(&str_ptr, "\t "); | |
2393 | if (!token) | |
2394 | return -EINVAL; | |
2395 | ||
2396 | bucket_type_str = strsep(&str_ptr, "\t "); | |
2397 | if (!bucket_type_str) | |
2398 | return -EINVAL; | |
2399 | ||
2400 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) | |
2401 | bucket_type = LPFC_LINEAR_BUCKET; | |
2402 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) | |
2403 | bucket_type = LPFC_POWER2_BUCKET; | |
2404 | else | |
2405 | return -EINVAL; | |
2406 | ||
2407 | base_str = strsep(&str_ptr, "\t "); | |
2408 | if (!base_str) | |
2409 | return -EINVAL; | |
2410 | base = simple_strtoul(base_str, NULL, 0); | |
2411 | ||
2412 | step_str = strsep(&str_ptr, "\t "); | |
2413 | if (!step_str) | |
2414 | return -EINVAL; | |
2415 | step = simple_strtoul(step_str, NULL, 0); | |
2416 | if (!step) | |
2417 | return -EINVAL; | |
2418 | ||
2419 | /* Block the data collection for every vport */ | |
2420 | vports = lpfc_create_vport_work_array(phba); | |
2421 | if (vports == NULL) | |
2422 | return -ENOMEM; | |
2423 | ||
f4b4c68f | 2424 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
ea2151b4 JS |
2425 | v_shost = lpfc_shost_from_vport(vports[i]); |
2426 | spin_lock_irq(v_shost->host_lock); | |
2427 | /* Block and reset data collection */ | |
2428 | vports[i]->stat_data_blocked = 1; | |
2429 | if (vports[i]->stat_data_enabled) | |
2430 | lpfc_vport_reset_stat_data(vports[i]); | |
2431 | spin_unlock_irq(v_shost->host_lock); | |
2432 | } | |
2433 | ||
2434 | /* Set the bucket attributes */ | |
2435 | phba->bucket_type = bucket_type; | |
2436 | phba->bucket_base = base; | |
2437 | phba->bucket_step = step; | |
2438 | ||
f4b4c68f | 2439 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
ea2151b4 JS |
2440 | v_shost = lpfc_shost_from_vport(vports[i]); |
2441 | ||
2442 | /* Unblock data collection */ | |
2443 | spin_lock_irq(v_shost->host_lock); | |
2444 | vports[i]->stat_data_blocked = 0; | |
2445 | spin_unlock_irq(v_shost->host_lock); | |
2446 | } | |
2447 | lpfc_destroy_vport_work_array(phba, vports); | |
2448 | return strlen(buf); | |
2449 | } | |
2450 | ||
2451 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { | |
2452 | vports = lpfc_create_vport_work_array(phba); | |
2453 | if (vports == NULL) | |
2454 | return -ENOMEM; | |
2455 | ||
f4b4c68f | 2456 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
ea2151b4 JS |
2457 | v_shost = lpfc_shost_from_vport(vports[i]); |
2458 | spin_lock_irq(shost->host_lock); | |
2459 | vports[i]->stat_data_blocked = 1; | |
2460 | lpfc_free_bucket(vport); | |
2461 | vport->stat_data_enabled = 0; | |
2462 | vports[i]->stat_data_blocked = 0; | |
2463 | spin_unlock_irq(shost->host_lock); | |
2464 | } | |
2465 | lpfc_destroy_vport_work_array(phba, vports); | |
2466 | phba->bucket_type = LPFC_NO_BUCKET; | |
2467 | phba->bucket_base = 0; | |
2468 | phba->bucket_step = 0; | |
2469 | return strlen(buf); | |
2470 | } | |
2471 | ||
2472 | if (!strncmp(buf, "start", strlen("start"))) { | |
2473 | /* If no buckets configured return error */ | |
2474 | if (phba->bucket_type == LPFC_NO_BUCKET) | |
2475 | return -EINVAL; | |
2476 | spin_lock_irq(shost->host_lock); | |
2477 | if (vport->stat_data_enabled) { | |
2478 | spin_unlock_irq(shost->host_lock); | |
2479 | return strlen(buf); | |
2480 | } | |
2481 | lpfc_alloc_bucket(vport); | |
2482 | vport->stat_data_enabled = 1; | |
2483 | spin_unlock_irq(shost->host_lock); | |
2484 | return strlen(buf); | |
2485 | } | |
2486 | ||
2487 | if (!strncmp(buf, "stop", strlen("stop"))) { | |
2488 | spin_lock_irq(shost->host_lock); | |
2489 | if (vport->stat_data_enabled == 0) { | |
2490 | spin_unlock_irq(shost->host_lock); | |
2491 | return strlen(buf); | |
2492 | } | |
2493 | lpfc_free_bucket(vport); | |
2494 | vport->stat_data_enabled = 0; | |
2495 | spin_unlock_irq(shost->host_lock); | |
2496 | return strlen(buf); | |
2497 | } | |
2498 | ||
2499 | if (!strncmp(buf, "reset", strlen("reset"))) { | |
2500 | if ((phba->bucket_type == LPFC_NO_BUCKET) | |
2501 | || !vport->stat_data_enabled) | |
2502 | return strlen(buf); | |
2503 | spin_lock_irq(shost->host_lock); | |
2504 | vport->stat_data_blocked = 1; | |
2505 | lpfc_vport_reset_stat_data(vport); | |
2506 | vport->stat_data_blocked = 0; | |
2507 | spin_unlock_irq(shost->host_lock); | |
2508 | return strlen(buf); | |
2509 | } | |
2510 | return -EINVAL; | |
2511 | } | |
2512 | ||
2513 | ||
2514 | /** | |
3621a710 | 2515 | * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file |
ea2151b4 JS |
2516 | * @dev: Pointer to class device object. |
2517 | * @buf: Data buffer. | |
2518 | * | |
2519 | * This function is the read call back function for | |
2520 | * lpfc_stat_data_ctrl sysfs file. This function report the | |
2521 | * current statistical data collection state. | |
2522 | **/ | |
2523 | static ssize_t | |
2524 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, | |
2525 | char *buf) | |
2526 | { | |
2527 | struct Scsi_Host *shost = class_to_shost(dev); | |
2528 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
2529 | struct lpfc_hba *phba = vport->phba; | |
2530 | int index = 0; | |
2531 | int i; | |
2532 | char *bucket_type; | |
2533 | unsigned long bucket_value; | |
2534 | ||
2535 | switch (phba->bucket_type) { | |
2536 | case LPFC_LINEAR_BUCKET: | |
2537 | bucket_type = "linear"; | |
2538 | break; | |
2539 | case LPFC_POWER2_BUCKET: | |
2540 | bucket_type = "power2"; | |
2541 | break; | |
2542 | default: | |
2543 | bucket_type = "No Bucket"; | |
2544 | break; | |
2545 | } | |
2546 | ||
2547 | sprintf(&buf[index], "Statistical Data enabled :%d, " | |
2548 | "blocked :%d, Bucket type :%s, Bucket base :%d," | |
2549 | " Bucket step :%d\nLatency Ranges :", | |
2550 | vport->stat_data_enabled, vport->stat_data_blocked, | |
2551 | bucket_type, phba->bucket_base, phba->bucket_step); | |
2552 | index = strlen(buf); | |
2553 | if (phba->bucket_type != LPFC_NO_BUCKET) { | |
2554 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { | |
2555 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) | |
2556 | bucket_value = phba->bucket_base + | |
2557 | phba->bucket_step * i; | |
2558 | else | |
2559 | bucket_value = phba->bucket_base + | |
2560 | (1 << i) * phba->bucket_step; | |
2561 | ||
2562 | if (index + 10 > PAGE_SIZE) | |
2563 | break; | |
2564 | sprintf(&buf[index], "%08ld ", bucket_value); | |
2565 | index = strlen(buf); | |
2566 | } | |
2567 | } | |
2568 | sprintf(&buf[index], "\n"); | |
2569 | return strlen(buf); | |
2570 | } | |
2571 | ||
2572 | /* | |
2573 | * Sysfs attribute to control the statistical data collection. | |
2574 | */ | |
2575 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, | |
2576 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); | |
2577 | ||
2578 | /* | |
2579 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. | |
2580 | */ | |
2581 | ||
2582 | /* | |
2583 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN | |
2584 | * for each target. | |
2585 | */ | |
2586 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) | |
2587 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ | |
2588 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) | |
2589 | ||
2590 | ||
2591 | /** | |
3621a710 | 2592 | * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute |
ea2151b4 JS |
2593 | * @kobj: Pointer to the kernel object |
2594 | * @bin_attr: Attribute object | |
2595 | * @buff: Buffer pointer | |
2596 | * @off: File offset | |
2597 | * @count: Buffer size | |
2598 | * | |
2599 | * This function is the read call back function for lpfc_drvr_stat_data | |
2600 | * sysfs file. This function export the statistical data to user | |
2601 | * applications. | |
2602 | **/ | |
2603 | static ssize_t | |
2604 | sysfs_drvr_stat_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, | |
2605 | char *buf, loff_t off, size_t count) | |
2606 | { | |
2607 | struct device *dev = container_of(kobj, struct device, | |
2608 | kobj); | |
2609 | struct Scsi_Host *shost = class_to_shost(dev); | |
2610 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
2611 | struct lpfc_hba *phba = vport->phba; | |
2612 | int i = 0, index = 0; | |
2613 | unsigned long nport_index; | |
2614 | struct lpfc_nodelist *ndlp = NULL; | |
2615 | nport_index = (unsigned long)off / | |
2616 | MAX_STAT_DATA_SIZE_PER_TARGET; | |
2617 | ||
2618 | if (!vport->stat_data_enabled || vport->stat_data_blocked | |
2619 | || (phba->bucket_type == LPFC_NO_BUCKET)) | |
2620 | return 0; | |
2621 | ||
2622 | spin_lock_irq(shost->host_lock); | |
2623 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { | |
2624 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) | |
2625 | continue; | |
2626 | ||
2627 | if (nport_index > 0) { | |
2628 | nport_index--; | |
2629 | continue; | |
2630 | } | |
2631 | ||
2632 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) | |
2633 | > count) | |
2634 | break; | |
2635 | ||
2636 | if (!ndlp->lat_data) | |
2637 | continue; | |
2638 | ||
2639 | /* Print the WWN */ | |
2640 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", | |
2641 | ndlp->nlp_portname.u.wwn[0], | |
2642 | ndlp->nlp_portname.u.wwn[1], | |
2643 | ndlp->nlp_portname.u.wwn[2], | |
2644 | ndlp->nlp_portname.u.wwn[3], | |
2645 | ndlp->nlp_portname.u.wwn[4], | |
2646 | ndlp->nlp_portname.u.wwn[5], | |
2647 | ndlp->nlp_portname.u.wwn[6], | |
2648 | ndlp->nlp_portname.u.wwn[7]); | |
2649 | ||
2650 | index = strlen(buf); | |
2651 | ||
2652 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { | |
2653 | sprintf(&buf[index], "%010u,", | |
2654 | ndlp->lat_data[i].cmd_count); | |
2655 | index = strlen(buf); | |
2656 | } | |
2657 | sprintf(&buf[index], "\n"); | |
2658 | index = strlen(buf); | |
2659 | } | |
2660 | spin_unlock_irq(shost->host_lock); | |
2661 | return index; | |
2662 | } | |
2663 | ||
2664 | static struct bin_attribute sysfs_drvr_stat_data_attr = { | |
2665 | .attr = { | |
2666 | .name = "lpfc_drvr_stat_data", | |
2667 | .mode = S_IRUSR, | |
2668 | .owner = THIS_MODULE, | |
2669 | }, | |
2670 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, | |
2671 | .read = sysfs_drvr_stat_data_read, | |
2672 | .write = NULL, | |
2673 | }; | |
2674 | ||
dea3101e JB |
2675 | /* |
2676 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel | |
2677 | # connection. | |
2678 | # 0 = auto select (default) | |
2679 | # 1 = 1 Gigabaud | |
2680 | # 2 = 2 Gigabaud | |
2681 | # 4 = 4 Gigabaud | |
b87eab38 JS |
2682 | # 8 = 8 Gigabaud |
2683 | # Value range is [0,8]. Default value is 0. | |
dea3101e | 2684 | */ |
e59058c4 JS |
2685 | |
2686 | /** | |
3621a710 | 2687 | * lpfc_link_speed_set - Set the adapters link speed |
e59058c4 JS |
2688 | * @phba: lpfc_hba pointer. |
2689 | * @val: link speed value. | |
2690 | * | |
2691 | * Description: | |
2692 | * If val is in a valid range then set the adapter's link speed field and | |
2693 | * issue a lip; if the lip fails reset the link speed to the old value. | |
2694 | * | |
2695 | * Notes: | |
2696 | * If the value is not in range log a kernel error message and return an error. | |
2697 | * | |
2698 | * Returns: | |
2699 | * zero if val is in range and lip okay. | |
2700 | * non-zero return value from lpfc_issue_lip() | |
2701 | * -EINVAL val out of range | |
2702 | **/ | |
a257bf90 JS |
2703 | static ssize_t |
2704 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, | |
2705 | const char *buf, size_t count) | |
83108bd3 | 2706 | { |
a257bf90 JS |
2707 | struct Scsi_Host *shost = class_to_shost(dev); |
2708 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
2709 | struct lpfc_hba *phba = vport->phba; | |
2710 | int val = 0; | |
2711 | int nolip = 0; | |
2712 | const char *val_buf = buf; | |
83108bd3 JS |
2713 | int err; |
2714 | uint32_t prev_val; | |
2715 | ||
a257bf90 JS |
2716 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
2717 | nolip = 1; | |
2718 | val_buf = &buf[strlen("nolip ")]; | |
2719 | } | |
2720 | ||
2721 | if (!isdigit(val_buf[0])) | |
2722 | return -EINVAL; | |
2723 | if (sscanf(val_buf, "%i", &val) != 1) | |
2724 | return -EINVAL; | |
2725 | ||
83108bd3 JS |
2726 | if (((val == LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
2727 | ((val == LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || | |
2728 | ((val == LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || | |
2729 | ((val == LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || | |
2730 | ((val == LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb))) | |
2731 | return -EINVAL; | |
2732 | ||
a257bf90 | 2733 | if ((val >= 0 && val <= 8) |
83108bd3 JS |
2734 | && (LPFC_LINK_SPEED_BITMAP & (1 << val))) { |
2735 | prev_val = phba->cfg_link_speed; | |
2736 | phba->cfg_link_speed = val; | |
a257bf90 JS |
2737 | if (nolip) |
2738 | return strlen(buf); | |
2739 | ||
83108bd3 | 2740 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
a257bf90 | 2741 | if (err) { |
83108bd3 | 2742 | phba->cfg_link_speed = prev_val; |
a257bf90 JS |
2743 | return -EINVAL; |
2744 | } else | |
2745 | return strlen(buf); | |
83108bd3 JS |
2746 | } |
2747 | ||
2748 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
2749 | "%d:0469 lpfc_link_speed attribute cannot be set to %d, " | |
2750 | "allowed range is [0, 8]\n", | |
2751 | phba->brd_no, val); | |
2752 | return -EINVAL; | |
2753 | } | |
2754 | ||
2755 | static int lpfc_link_speed = 0; | |
2756 | module_param(lpfc_link_speed, int, 0); | |
2757 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); | |
2758 | lpfc_param_show(link_speed) | |
e59058c4 JS |
2759 | |
2760 | /** | |
3621a710 | 2761 | * lpfc_link_speed_init - Set the adapters link speed |
e59058c4 JS |
2762 | * @phba: lpfc_hba pointer. |
2763 | * @val: link speed value. | |
2764 | * | |
2765 | * Description: | |
2766 | * If val is in a valid range then set the adapter's link speed field. | |
2767 | * | |
2768 | * Notes: | |
2769 | * If the value is not in range log a kernel error message, clear the link | |
2770 | * speed and return an error. | |
2771 | * | |
2772 | * Returns: | |
2773 | * zero if val saved. | |
2774 | * -EINVAL val out of range | |
2775 | **/ | |
83108bd3 JS |
2776 | static int |
2777 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) | |
2778 | { | |
2779 | if ((val >= 0 && val <= LPFC_MAX_LINK_SPEED) | |
2780 | && (LPFC_LINK_SPEED_BITMAP & (1 << val))) { | |
2781 | phba->cfg_link_speed = val; | |
2782 | return 0; | |
2783 | } | |
2784 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
d7c255b2 | 2785 | "0405 lpfc_link_speed attribute cannot " |
83108bd3 JS |
2786 | "be set to %d, allowed values are " |
2787 | "["LPFC_LINK_SPEED_STRING"]\n", val); | |
2788 | phba->cfg_link_speed = 0; | |
2789 | return -EINVAL; | |
2790 | } | |
2791 | ||
ee959b00 | 2792 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
83108bd3 | 2793 | lpfc_link_speed_show, lpfc_link_speed_store); |
dea3101e | 2794 | |
0d878419 JS |
2795 | /* |
2796 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) | |
2797 | # 0 = aer disabled or not supported | |
2798 | # 1 = aer supported and enabled (default) | |
2799 | # Value range is [0,1]. Default value is 1. | |
2800 | */ | |
2801 | ||
2802 | /** | |
2803 | * lpfc_aer_support_store - Set the adapter for aer support | |
2804 | * | |
2805 | * @dev: class device that is converted into a Scsi_host. | |
2806 | * @attr: device attribute, not used. | |
2807 | * @buf: containing the string "selective". | |
2808 | * @count: unused variable. | |
2809 | * | |
2810 | * Description: | |
2811 | * If the val is 1 and currently the device's AER capability was not | |
2812 | * enabled, invoke the kernel's enable AER helper routine, trying to | |
2813 | * enable the device's AER capability. If the helper routine enabling | |
2814 | * AER returns success, update the device's cfg_aer_support flag to | |
2815 | * indicate AER is supported by the device; otherwise, if the device | |
2816 | * AER capability is already enabled to support AER, then do nothing. | |
2817 | * | |
2818 | * If the val is 0 and currently the device's AER support was enabled, | |
2819 | * invoke the kernel's disable AER helper routine. After that, update | |
2820 | * the device's cfg_aer_support flag to indicate AER is not supported | |
2821 | * by the device; otherwise, if the device AER capability is already | |
2822 | * disabled from supporting AER, then do nothing. | |
2823 | * | |
2824 | * Returns: | |
2825 | * length of the buf on success if val is in range the intended mode | |
2826 | * is supported. | |
2827 | * -EINVAL if val out of range or intended mode is not supported. | |
2828 | **/ | |
2829 | static ssize_t | |
2830 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, | |
2831 | const char *buf, size_t count) | |
2832 | { | |
2833 | struct Scsi_Host *shost = class_to_shost(dev); | |
2834 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; | |
2835 | struct lpfc_hba *phba = vport->phba; | |
2836 | int val = 0, rc = -EINVAL; | |
2837 | ||
891478a2 JS |
2838 | /* AER not supported on OC devices yet */ |
2839 | if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) | |
2840 | return -EPERM; | |
0d878419 JS |
2841 | if (!isdigit(buf[0])) |
2842 | return -EINVAL; | |
2843 | if (sscanf(buf, "%i", &val) != 1) | |
2844 | return -EINVAL; | |
2845 | ||
2846 | switch (val) { | |
2847 | case 0: | |
2848 | if (phba->hba_flag & HBA_AER_ENABLED) { | |
2849 | rc = pci_disable_pcie_error_reporting(phba->pcidev); | |
2850 | if (!rc) { | |
2851 | spin_lock_irq(&phba->hbalock); | |
2852 | phba->hba_flag &= ~HBA_AER_ENABLED; | |
2853 | spin_unlock_irq(&phba->hbalock); | |
2854 | phba->cfg_aer_support = 0; | |
2855 | rc = strlen(buf); | |
2856 | } else | |
891478a2 JS |
2857 | rc = -EPERM; |
2858 | } else { | |
0d878419 | 2859 | phba->cfg_aer_support = 0; |
891478a2 JS |
2860 | rc = strlen(buf); |
2861 | } | |
0d878419 JS |
2862 | break; |
2863 | case 1: | |
2864 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { | |
2865 | rc = pci_enable_pcie_error_reporting(phba->pcidev); | |
2866 | if (!rc) { | |
2867 | spin_lock_irq(&phba->hbalock); | |
2868 | phba->hba_flag |= HBA_AER_ENABLED; | |
2869 | spin_unlock_irq(&phba->hbalock); | |
2870 | phba->cfg_aer_support = 1; | |
2871 | rc = strlen(buf); | |
2872 | } else | |
891478a2 JS |
2873 | rc = -EPERM; |
2874 | } else { | |
0d878419 | 2875 | phba->cfg_aer_support = 1; |
891478a2 JS |
2876 | rc = strlen(buf); |
2877 | } | |
0d878419 JS |
2878 | break; |
2879 | default: | |
2880 | rc = -EINVAL; | |
2881 | break; | |
2882 | } | |
2883 | return rc; | |
2884 | } | |
2885 | ||
2886 | static int lpfc_aer_support = 1; | |
2887 | module_param(lpfc_aer_support, int, 1); | |
2888 | MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support"); | |
2889 | lpfc_param_show(aer_support) | |
2890 | ||
2891 | /** | |
2892 | * lpfc_aer_support_init - Set the initial adapters aer support flag | |
2893 | * @phba: lpfc_hba pointer. | |
2894 | * @val: link speed value. | |
2895 | * | |
2896 | * Description: | |
2897 | * If val is in a valid range [0,1], then set the adapter's initial | |
2898 | * cfg_aer_support field. It will be up to the driver's probe_one | |
2899 | * routine to determine whether the device's AER support can be set | |
2900 | * or not. | |
2901 | * | |
2902 | * Notes: | |
2903 | * If the value is not in range log a kernel error message, and | |
2904 | * choose the default value of setting AER support and return. | |
2905 | * | |
2906 | * Returns: | |
2907 | * zero if val saved. | |
2908 | * -EINVAL val out of range | |
2909 | **/ | |
2910 | static int | |
2911 | lpfc_aer_support_init(struct lpfc_hba *phba, int val) | |
2912 | { | |
891478a2 JS |
2913 | /* AER not supported on OC devices yet */ |
2914 | if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) { | |
2915 | phba->cfg_aer_support = 0; | |
2916 | return -EPERM; | |
2917 | } | |
2918 | ||
0d878419 JS |
2919 | if (val == 0 || val == 1) { |
2920 | phba->cfg_aer_support = val; | |
2921 | return 0; | |
2922 | } | |
2923 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
2924 | "2712 lpfc_aer_support attribute value %d out " | |
2925 | "of range, allowed values are 0|1, setting it " | |
2926 | "to default value of 1\n", val); | |
891478a2 | 2927 | /* By default, try to enable AER on a device */ |
0d878419 JS |
2928 | phba->cfg_aer_support = 1; |
2929 | return -EINVAL; | |
2930 | } | |
2931 | ||
2932 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, | |
2933 | lpfc_aer_support_show, lpfc_aer_support_store); | |
2934 | ||
2935 | /** | |
2936 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device | |
2937 | * @dev: class device that is converted into a Scsi_host. | |
2938 | * @attr: device attribute, not used. | |
2939 | * @buf: containing the string "selective". | |
2940 | * @count: unused variable. | |
2941 | * | |
2942 | * Description: | |
2943 | * If the @buf contains 1 and the device currently has the AER support | |
2944 | * enabled, then invokes the kernel AER helper routine | |
2945 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable | |
2946 | * error status register. | |
2947 | * | |
2948 | * Notes: | |
2949 | * | |
2950 | * Returns: | |
2951 | * -EINVAL if the buf does not contain the 1 or the device is not currently | |
2952 | * enabled with the AER support. | |
2953 | **/ | |
2954 | static ssize_t | |
2955 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, | |
2956 | const char *buf, size_t count) | |
2957 | { | |
2958 | struct Scsi_Host *shost = class_to_shost(dev); | |
2959 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
2960 | struct lpfc_hba *phba = vport->phba; | |
2961 | int val, rc = -1; | |
2962 | ||
891478a2 JS |
2963 | /* AER not supported on OC devices yet */ |
2964 | if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) | |
2965 | return -EPERM; | |
0d878419 JS |
2966 | if (!isdigit(buf[0])) |
2967 | return -EINVAL; | |
2968 | if (sscanf(buf, "%i", &val) != 1) | |
2969 | return -EINVAL; | |
891478a2 JS |
2970 | if (val != 1) |
2971 | return -EINVAL; | |
0d878419 | 2972 | |
891478a2 | 2973 | if (phba->hba_flag & HBA_AER_ENABLED) |
0d878419 JS |
2974 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
2975 | ||
2976 | if (rc == 0) | |
2977 | return strlen(buf); | |
2978 | else | |
891478a2 | 2979 | return -EPERM; |
0d878419 JS |
2980 | } |
2981 | ||
2982 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, | |
2983 | lpfc_aer_cleanup_state); | |
2984 | ||
dea3101e JB |
2985 | /* |
2986 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. | |
2987 | # Value range is [2,3]. Default value is 3. | |
2988 | */ | |
3de2a653 JS |
2989 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
2990 | "Select Fibre Channel class of service for FCP sequences"); | |
dea3101e JB |
2991 | |
2992 | /* | |
2993 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range | |
2994 | # is [0,1]. Default value is 0. | |
2995 | */ | |
3de2a653 JS |
2996 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
2997 | "Use ADISC on rediscovery to authenticate FCP devices"); | |
dea3101e | 2998 | |
977b5a0a JS |
2999 | /* |
3000 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue | |
3001 | # depth. Default value is 0. When the value of this parameter is zero the | |
3002 | # SCSI command completion time is not used for controlling I/O queue depth. When | |
3003 | # the parameter is set to a non-zero value, the I/O queue depth is controlled | |
3004 | # to limit the I/O completion time to the parameter value. | |
3005 | # The value is set in milliseconds. | |
3006 | */ | |
3007 | static int lpfc_max_scsicmpl_time; | |
3008 | module_param(lpfc_max_scsicmpl_time, int, 0); | |
3009 | MODULE_PARM_DESC(lpfc_max_scsicmpl_time, | |
3010 | "Use command completion time to control queue depth"); | |
3011 | lpfc_vport_param_show(max_scsicmpl_time); | |
3012 | lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000); | |
3013 | static int | |
3014 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) | |
3015 | { | |
3016 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | |
3017 | struct lpfc_nodelist *ndlp, *next_ndlp; | |
3018 | ||
3019 | if (val == vport->cfg_max_scsicmpl_time) | |
3020 | return 0; | |
3021 | if ((val < 0) || (val > 60000)) | |
3022 | return -EINVAL; | |
3023 | vport->cfg_max_scsicmpl_time = val; | |
3024 | ||
3025 | spin_lock_irq(shost->host_lock); | |
3026 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | |
3027 | if (!NLP_CHK_NODE_ACT(ndlp)) | |
3028 | continue; | |
3029 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) | |
3030 | continue; | |
3031 | ndlp->cmd_qdepth = LPFC_MAX_TGT_QDEPTH; | |
3032 | } | |
3033 | spin_unlock_irq(shost->host_lock); | |
3034 | return 0; | |
3035 | } | |
3036 | lpfc_vport_param_store(max_scsicmpl_time); | |
3037 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, | |
3038 | lpfc_max_scsicmpl_time_show, | |
3039 | lpfc_max_scsicmpl_time_store); | |
3040 | ||
dea3101e JB |
3041 | /* |
3042 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value | |
3043 | # range is [0,1]. Default value is 0. | |
3044 | */ | |
3045 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); | |
3046 | ||
3047 | /* | |
3048 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing | |
3049 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take | |
7054a606 | 3050 | # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay |
dea3101e JB |
3051 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
3052 | # cr_delay is set to 0. | |
3053 | */ | |
8189fd19 | 3054 | LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an " |
dea3101e JB |
3055 | "interrupt response is generated"); |
3056 | ||
8189fd19 | 3057 | LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an " |
dea3101e JB |
3058 | "interrupt response is generated"); |
3059 | ||
cf5bf97e JW |
3060 | /* |
3061 | # lpfc_multi_ring_support: Determines how many rings to spread available | |
3062 | # cmd/rsp IOCB entries across. | |
3063 | # Value range is [1,2]. Default value is 1. | |
3064 | */ | |
3065 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " | |
3066 | "SLI rings to spread IOCB entries across"); | |
3067 | ||
a4bc3379 JS |
3068 | /* |
3069 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this | |
3070 | # identifies what rctl value to configure the additional ring for. | |
3071 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). | |
3072 | */ | |
6a9c52cf | 3073 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
a4bc3379 JS |
3074 | 255, "Identifies RCTL for additional ring configuration"); |
3075 | ||
3076 | /* | |
3077 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this | |
3078 | # identifies what type value to configure the additional ring for. | |
3079 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). | |
3080 | */ | |
6a9c52cf | 3081 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
a4bc3379 JS |
3082 | 255, "Identifies TYPE for additional ring configuration"); |
3083 | ||
dea3101e JB |
3084 | /* |
3085 | # lpfc_fdmi_on: controls FDMI support. | |
3086 | # 0 = no FDMI support | |
3087 | # 1 = support FDMI without attribute of hostname | |
3088 | # 2 = support FDMI with attribute of hostname | |
3089 | # Value range [0,2]. Default value is 0. | |
3090 | */ | |
3de2a653 | 3091 | LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); |
dea3101e JB |
3092 | |
3093 | /* | |
3094 | # Specifies the maximum number of ELS cmds we can have outstanding (for | |
3095 | # discovery). Value range is [1,64]. Default value = 32. | |
3096 | */ | |
3de2a653 | 3097 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
dea3101e JB |
3098 | "during discovery"); |
3099 | ||
3100 | /* | |
65a29c16 JS |
3101 | # lpfc_max_luns: maximum allowed LUN. |
3102 | # Value range is [0,65535]. Default value is 255. | |
3103 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. | |
dea3101e | 3104 | */ |
3de2a653 | 3105 | LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN"); |
dea3101e | 3106 | |
875fbdfe JSEC |
3107 | /* |
3108 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. | |
3109 | # Value range is [1,255], default value is 10. | |
3110 | */ | |
3111 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, | |
3112 | "Milliseconds driver will wait between polling FCP ring"); | |
3113 | ||
4ff43246 JS |
3114 | /* |
3115 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that | |
3116 | # support this feature | |
8605c46c | 3117 | # 0 = MSI disabled |
4ff43246 | 3118 | # 1 = MSI enabled |
8605c46c GK |
3119 | # 2 = MSI-X enabled (default) |
3120 | # Value range is [0,2]. Default value is 2. | |
4ff43246 | 3121 | */ |
8605c46c | 3122 | LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or " |
db2378e0 | 3123 | "MSI-X (2), if possible"); |
4ff43246 | 3124 | |
da0436e9 JS |
3125 | /* |
3126 | # lpfc_fcp_imax: Set the maximum number of fast-path FCP interrupts per second | |
3127 | # | |
3128 | # Value range is [636,651042]. Default value is 10000. | |
3129 | */ | |
3130 | LPFC_ATTR_R(fcp_imax, LPFC_FP_DEF_IMAX, LPFC_MIM_IMAX, LPFC_DMULT_CONST, | |
3131 | "Set the maximum number of fast-path FCP interrupts per second"); | |
3132 | ||
3133 | /* | |
3134 | # lpfc_fcp_wq_count: Set the number of fast-path FCP work queues | |
3135 | # | |
3136 | # Value range is [1,31]. Default value is 4. | |
3137 | */ | |
3138 | LPFC_ATTR_R(fcp_wq_count, LPFC_FP_WQN_DEF, LPFC_FP_WQN_MIN, LPFC_FP_WQN_MAX, | |
3139 | "Set the number of fast-path FCP work queues, if possible"); | |
3140 | ||
3141 | /* | |
3142 | # lpfc_fcp_eq_count: Set the number of fast-path FCP event queues | |
3143 | # | |
3144 | # Value range is [1,7]. Default value is 1. | |
3145 | */ | |
3146 | LPFC_ATTR_R(fcp_eq_count, LPFC_FP_EQN_DEF, LPFC_FP_EQN_MIN, LPFC_FP_EQN_MAX, | |
3147 | "Set the number of fast-path FCP event queues, if possible"); | |
3148 | ||
13815c83 JS |
3149 | /* |
3150 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. | |
3151 | # 0 = HBA resets disabled | |
3152 | # 1 = HBA resets enabled (default) | |
3153 | # Value range is [0,1]. Default value is 1. | |
3154 | */ | |
3155 | LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver."); | |
c3f28afa | 3156 | |
13815c83 JS |
3157 | /* |
3158 | # lpfc_enable_hba_heartbeat: Enable HBA heartbeat timer.. | |
3159 | # 0 = HBA Heartbeat disabled | |
3160 | # 1 = HBA Heartbeat enabled (default) | |
3161 | # Value range is [0,1]. Default value is 1. | |
3162 | */ | |
3163 | LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat."); | |
92d7f7b0 | 3164 | |
81301a9b JS |
3165 | /* |
3166 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) | |
3167 | # 0 = BlockGuard disabled (default) | |
3168 | # 1 = BlockGuard enabled | |
3169 | # Value range is [0,1]. Default value is 0. | |
3170 | */ | |
3171 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); | |
3172 | ||
81301a9b JS |
3173 | /* |
3174 | # lpfc_prot_mask: i | |
3175 | # - Bit mask of host protection capabilities used to register with the | |
3176 | # SCSI mid-layer | |
3177 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). | |
3178 | # - Allows you to ultimately specify which profiles to use | |
3179 | # - Default will result in registering capabilities for all profiles. | |
3180 | # | |
3181 | */ | |
3182 | unsigned int lpfc_prot_mask = SHOST_DIX_TYPE0_PROTECTION; | |
3183 | ||
3184 | module_param(lpfc_prot_mask, uint, 0); | |
3185 | MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask"); | |
3186 | ||
3187 | /* | |
3188 | # lpfc_prot_guard: i | |
3189 | # - Bit mask of protection guard types to register with the SCSI mid-layer | |
3190 | # - Guard types are currently either 1) IP checksum 2) T10-DIF CRC | |
3191 | # - Allows you to ultimately specify which profiles to use | |
3192 | # - Default will result in registering capabilities for all guard types | |
3193 | # | |
3194 | */ | |
3195 | unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP; | |
3196 | module_param(lpfc_prot_guard, byte, 0); | |
3197 | MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type"); | |
3198 | ||
3199 | ||
83108bd3 | 3200 | /* |
3621a710 | 3201 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
83108bd3 JS |
3202 | * This value can be set to values between 64 and 256. The default value is |
3203 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer | |
3204 | * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE). | |
3205 | */ | |
3206 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, | |
3207 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); | |
3208 | ||
81301a9b JS |
3209 | LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_PROT_SG_SEG_CNT, |
3210 | LPFC_DEFAULT_PROT_SG_SEG_CNT, LPFC_MAX_PROT_SG_SEG_CNT, | |
3211 | "Max Protection Scatter Gather Segment Count"); | |
3212 | ||
ee959b00 | 3213 | struct device_attribute *lpfc_hba_attrs[] = { |
81301a9b JS |
3214 | &dev_attr_bg_info, |
3215 | &dev_attr_bg_guard_err, | |
3216 | &dev_attr_bg_apptag_err, | |
3217 | &dev_attr_bg_reftag_err, | |
ee959b00 TJ |
3218 | &dev_attr_info, |
3219 | &dev_attr_serialnum, | |
3220 | &dev_attr_modeldesc, | |
3221 | &dev_attr_modelname, | |
3222 | &dev_attr_programtype, | |
3223 | &dev_attr_portnum, | |
3224 | &dev_attr_fwrev, | |
3225 | &dev_attr_hdw, | |
3226 | &dev_attr_option_rom_version, | |
bbd1ae41 | 3227 | &dev_attr_link_state, |
ee959b00 | 3228 | &dev_attr_num_discovered_ports, |
84774a4d | 3229 | &dev_attr_menlo_mgmt_mode, |
ee959b00 | 3230 | &dev_attr_lpfc_drvr_version, |
45ed1190 | 3231 | &dev_attr_lpfc_enable_fip, |
ee959b00 TJ |
3232 | &dev_attr_lpfc_temp_sensor, |
3233 | &dev_attr_lpfc_log_verbose, | |
3234 | &dev_attr_lpfc_lun_queue_depth, | |
3235 | &dev_attr_lpfc_hba_queue_depth, | |
3236 | &dev_attr_lpfc_peer_port_login, | |
3237 | &dev_attr_lpfc_nodev_tmo, | |
3238 | &dev_attr_lpfc_devloss_tmo, | |
3239 | &dev_attr_lpfc_fcp_class, | |
3240 | &dev_attr_lpfc_use_adisc, | |
3241 | &dev_attr_lpfc_ack0, | |
3242 | &dev_attr_lpfc_topology, | |
3243 | &dev_attr_lpfc_scan_down, | |
3244 | &dev_attr_lpfc_link_speed, | |
3245 | &dev_attr_lpfc_cr_delay, | |
3246 | &dev_attr_lpfc_cr_count, | |
3247 | &dev_attr_lpfc_multi_ring_support, | |
3248 | &dev_attr_lpfc_multi_ring_rctl, | |
3249 | &dev_attr_lpfc_multi_ring_type, | |
3250 | &dev_attr_lpfc_fdmi_on, | |
3251 | &dev_attr_lpfc_max_luns, | |
3252 | &dev_attr_lpfc_enable_npiv, | |
3253 | &dev_attr_nport_evt_cnt, | |
3254 | &dev_attr_board_mode, | |
3255 | &dev_attr_max_vpi, | |
3256 | &dev_attr_used_vpi, | |
3257 | &dev_attr_max_rpi, | |
3258 | &dev_attr_used_rpi, | |
3259 | &dev_attr_max_xri, | |
3260 | &dev_attr_used_xri, | |
3261 | &dev_attr_npiv_info, | |
3262 | &dev_attr_issue_reset, | |
3263 | &dev_attr_lpfc_poll, | |
3264 | &dev_attr_lpfc_poll_tmo, | |
3265 | &dev_attr_lpfc_use_msi, | |
da0436e9 JS |
3266 | &dev_attr_lpfc_fcp_imax, |
3267 | &dev_attr_lpfc_fcp_wq_count, | |
3268 | &dev_attr_lpfc_fcp_eq_count, | |
81301a9b | 3269 | &dev_attr_lpfc_enable_bg, |
ee959b00 TJ |
3270 | &dev_attr_lpfc_soft_wwnn, |
3271 | &dev_attr_lpfc_soft_wwpn, | |
3272 | &dev_attr_lpfc_soft_wwn_enable, | |
3273 | &dev_attr_lpfc_enable_hba_reset, | |
3274 | &dev_attr_lpfc_enable_hba_heartbeat, | |
3275 | &dev_attr_lpfc_sg_seg_cnt, | |
977b5a0a | 3276 | &dev_attr_lpfc_max_scsicmpl_time, |
ea2151b4 | 3277 | &dev_attr_lpfc_stat_data_ctrl, |
81301a9b | 3278 | &dev_attr_lpfc_prot_sg_seg_cnt, |
0d878419 JS |
3279 | &dev_attr_lpfc_aer_support, |
3280 | &dev_attr_lpfc_aer_state_cleanup, | |
dea3101e JB |
3281 | NULL, |
3282 | }; | |
3283 | ||
ee959b00 TJ |
3284 | struct device_attribute *lpfc_vport_attrs[] = { |
3285 | &dev_attr_info, | |
bbd1ae41 | 3286 | &dev_attr_link_state, |
ee959b00 TJ |
3287 | &dev_attr_num_discovered_ports, |
3288 | &dev_attr_lpfc_drvr_version, | |
3289 | &dev_attr_lpfc_log_verbose, | |
3290 | &dev_attr_lpfc_lun_queue_depth, | |
3291 | &dev_attr_lpfc_nodev_tmo, | |
3292 | &dev_attr_lpfc_devloss_tmo, | |
3293 | &dev_attr_lpfc_hba_queue_depth, | |
3294 | &dev_attr_lpfc_peer_port_login, | |
3295 | &dev_attr_lpfc_restrict_login, | |
3296 | &dev_attr_lpfc_fcp_class, | |
3297 | &dev_attr_lpfc_use_adisc, | |
3298 | &dev_attr_lpfc_fdmi_on, | |
3299 | &dev_attr_lpfc_max_luns, | |
3300 | &dev_attr_nport_evt_cnt, | |
3301 | &dev_attr_npiv_info, | |
3302 | &dev_attr_lpfc_enable_da_id, | |
ea2151b4 JS |
3303 | &dev_attr_lpfc_max_scsicmpl_time, |
3304 | &dev_attr_lpfc_stat_data_ctrl, | |
21e9a0a5 | 3305 | &dev_attr_lpfc_static_vport, |
3de2a653 JS |
3306 | NULL, |
3307 | }; | |
3308 | ||
e59058c4 | 3309 | /** |
3621a710 | 3310 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
e59058c4 JS |
3311 | * @kobj: kernel kobject that contains the kernel class device. |
3312 | * @bin_attr: kernel attributes passed to us. | |
3313 | * @buf: contains the data to be written to the adapter IOREG space. | |
3314 | * @off: offset into buffer to beginning of data. | |
3315 | * @count: bytes to transfer. | |
3316 | * | |
3317 | * Description: | |
3318 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. | |
3319 | * Uses the adapter io control registers to send buf contents to the adapter. | |
3320 | * | |
3321 | * Returns: | |
3322 | * -ERANGE off and count combo out of range | |
3323 | * -EINVAL off, count or buff address invalid | |
3324 | * -EPERM adapter is offline | |
3325 | * value of count, buf contents written | |
3326 | **/ | |
dea3101e | 3327 | static ssize_t |
91a69029 ZR |
3328 | sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, |
3329 | char *buf, loff_t off, size_t count) | |
dea3101e JB |
3330 | { |
3331 | size_t buf_off; | |
ee959b00 TJ |
3332 | struct device *dev = container_of(kobj, struct device, kobj); |
3333 | struct Scsi_Host *shost = class_to_shost(dev); | |
2e0fef85 JS |
3334 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3335 | struct lpfc_hba *phba = vport->phba; | |
dea3101e | 3336 | |
f1126688 JS |
3337 | if (phba->sli_rev >= LPFC_SLI_REV4) |
3338 | return -EPERM; | |
3339 | ||
dea3101e JB |
3340 | if ((off + count) > FF_REG_AREA_SIZE) |
3341 | return -ERANGE; | |
3342 | ||
3343 | if (count == 0) return 0; | |
3344 | ||
3345 | if (off % 4 || count % 4 || (unsigned long)buf % 4) | |
3346 | return -EINVAL; | |
3347 | ||
2e0fef85 | 3348 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) { |
dea3101e JB |
3349 | return -EPERM; |
3350 | } | |
3351 | ||
2e0fef85 | 3352 | spin_lock_irq(&phba->hbalock); |
dea3101e JB |
3353 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) |
3354 | writel(*((uint32_t *)(buf + buf_off)), | |
3355 | phba->ctrl_regs_memmap_p + off + buf_off); | |
3356 | ||
2e0fef85 | 3357 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3358 | |
3359 | return count; | |
3360 | } | |
3361 | ||
e59058c4 | 3362 | /** |
3621a710 | 3363 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
e59058c4 JS |
3364 | * @kobj: kernel kobject that contains the kernel class device. |
3365 | * @bin_attr: kernel attributes passed to us. | |
af901ca1 | 3366 | * @buf: if successful contains the data from the adapter IOREG space. |
e59058c4 JS |
3367 | * @off: offset into buffer to beginning of data. |
3368 | * @count: bytes to transfer. | |
3369 | * | |
3370 | * Description: | |
3371 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. | |
3372 | * Uses the adapter io control registers to read data into buf. | |
3373 | * | |
3374 | * Returns: | |
3375 | * -ERANGE off and count combo out of range | |
3376 | * -EINVAL off, count or buff address invalid | |
3377 | * value of count, buf contents read | |
3378 | **/ | |
dea3101e | 3379 | static ssize_t |
91a69029 ZR |
3380 | sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr, |
3381 | char *buf, loff_t off, size_t count) | |
dea3101e JB |
3382 | { |
3383 | size_t buf_off; | |
3384 | uint32_t * tmp_ptr; | |
ee959b00 TJ |
3385 | struct device *dev = container_of(kobj, struct device, kobj); |
3386 | struct Scsi_Host *shost = class_to_shost(dev); | |
2e0fef85 JS |
3387 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3388 | struct lpfc_hba *phba = vport->phba; | |
dea3101e | 3389 | |
f1126688 JS |
3390 | if (phba->sli_rev >= LPFC_SLI_REV4) |
3391 | return -EPERM; | |
3392 | ||
dea3101e JB |
3393 | if (off > FF_REG_AREA_SIZE) |
3394 | return -ERANGE; | |
3395 | ||
3396 | if ((off + count) > FF_REG_AREA_SIZE) | |
3397 | count = FF_REG_AREA_SIZE - off; | |
3398 | ||
3399 | if (count == 0) return 0; | |
3400 | ||
3401 | if (off % 4 || count % 4 || (unsigned long)buf % 4) | |
3402 | return -EINVAL; | |
3403 | ||
2e0fef85 | 3404 | spin_lock_irq(&phba->hbalock); |
dea3101e JB |
3405 | |
3406 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { | |
3407 | tmp_ptr = (uint32_t *)(buf + buf_off); | |
3408 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); | |
3409 | } | |
3410 | ||
2e0fef85 | 3411 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3412 | |
3413 | return count; | |
3414 | } | |
3415 | ||
3416 | static struct bin_attribute sysfs_ctlreg_attr = { | |
3417 | .attr = { | |
3418 | .name = "ctlreg", | |
3419 | .mode = S_IRUSR | S_IWUSR, | |
dea3101e JB |
3420 | }, |
3421 | .size = 256, | |
3422 | .read = sysfs_ctlreg_read, | |
3423 | .write = sysfs_ctlreg_write, | |
3424 | }; | |
3425 | ||
e59058c4 | 3426 | /** |
3621a710 | 3427 | * sysfs_mbox_idle - frees the sysfs mailbox |
e59058c4 JS |
3428 | * @phba: lpfc_hba pointer |
3429 | **/ | |
dea3101e | 3430 | static void |
2e0fef85 | 3431 | sysfs_mbox_idle(struct lpfc_hba *phba) |
dea3101e JB |
3432 | { |
3433 | phba->sysfs_mbox.state = SMBOX_IDLE; | |
3434 | phba->sysfs_mbox.offset = 0; | |
3435 | ||
3436 | if (phba->sysfs_mbox.mbox) { | |
3437 | mempool_free(phba->sysfs_mbox.mbox, | |
3438 | phba->mbox_mem_pool); | |
3439 | phba->sysfs_mbox.mbox = NULL; | |
3440 | } | |
3441 | } | |
3442 | ||
e59058c4 | 3443 | /** |
3621a710 | 3444 | * sysfs_mbox_write - Write method for writing information via mbox |
e59058c4 JS |
3445 | * @kobj: kernel kobject that contains the kernel class device. |
3446 | * @bin_attr: kernel attributes passed to us. | |
3447 | * @buf: contains the data to be written to sysfs mbox. | |
3448 | * @off: offset into buffer to beginning of data. | |
3449 | * @count: bytes to transfer. | |
3450 | * | |
3451 | * Description: | |
3452 | * Accessed via /sys/class/scsi_host/hostxxx/mbox. | |
3453 | * Uses the sysfs mbox to send buf contents to the adapter. | |
3454 | * | |
3455 | * Returns: | |
3456 | * -ERANGE off and count combo out of range | |
3457 | * -EINVAL off, count or buff address invalid | |
3458 | * zero if count is zero | |
3459 | * -EPERM adapter is offline | |
3460 | * -ENOMEM failed to allocate memory for the mail box | |
3461 | * -EAGAIN offset, state or mbox is NULL | |
3462 | * count number of bytes transferred | |
3463 | **/ | |
dea3101e | 3464 | static ssize_t |
91a69029 ZR |
3465 | sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, |
3466 | char *buf, loff_t off, size_t count) | |
dea3101e | 3467 | { |
ee959b00 TJ |
3468 | struct device *dev = container_of(kobj, struct device, kobj); |
3469 | struct Scsi_Host *shost = class_to_shost(dev); | |
2e0fef85 JS |
3470 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3471 | struct lpfc_hba *phba = vport->phba; | |
3472 | struct lpfcMboxq *mbox = NULL; | |
dea3101e JB |
3473 | |
3474 | if ((count + off) > MAILBOX_CMD_SIZE) | |
3475 | return -ERANGE; | |
3476 | ||
3477 | if (off % 4 || count % 4 || (unsigned long)buf % 4) | |
3478 | return -EINVAL; | |
3479 | ||
3480 | if (count == 0) | |
3481 | return 0; | |
3482 | ||
3483 | if (off == 0) { | |
3484 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
3485 | if (!mbox) | |
3486 | return -ENOMEM; | |
fc6c12bc | 3487 | memset(mbox, 0, sizeof (LPFC_MBOXQ_t)); |
dea3101e JB |
3488 | } |
3489 | ||
2e0fef85 | 3490 | spin_lock_irq(&phba->hbalock); |
dea3101e JB |
3491 | |
3492 | if (off == 0) { | |
3493 | if (phba->sysfs_mbox.mbox) | |
3494 | mempool_free(mbox, phba->mbox_mem_pool); | |
3495 | else | |
3496 | phba->sysfs_mbox.mbox = mbox; | |
3497 | phba->sysfs_mbox.state = SMBOX_WRITING; | |
3498 | } else { | |
3499 | if (phba->sysfs_mbox.state != SMBOX_WRITING || | |
3500 | phba->sysfs_mbox.offset != off || | |
92d7f7b0 | 3501 | phba->sysfs_mbox.mbox == NULL) { |
dea3101e | 3502 | sysfs_mbox_idle(phba); |
2e0fef85 | 3503 | spin_unlock_irq(&phba->hbalock); |
8f6d98d2 | 3504 | return -EAGAIN; |
dea3101e JB |
3505 | } |
3506 | } | |
3507 | ||
04c68496 | 3508 | memcpy((uint8_t *) &phba->sysfs_mbox.mbox->u.mb + off, |
dea3101e JB |
3509 | buf, count); |
3510 | ||
3511 | phba->sysfs_mbox.offset = off + count; | |
3512 | ||
2e0fef85 | 3513 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3514 | |
3515 | return count; | |
3516 | } | |
3517 | ||
e59058c4 | 3518 | /** |
3621a710 | 3519 | * sysfs_mbox_read - Read method for reading information via mbox |
e59058c4 JS |
3520 | * @kobj: kernel kobject that contains the kernel class device. |
3521 | * @bin_attr: kernel attributes passed to us. | |
3522 | * @buf: contains the data to be read from sysfs mbox. | |
3523 | * @off: offset into buffer to beginning of data. | |
3524 | * @count: bytes to transfer. | |
3525 | * | |
3526 | * Description: | |
3527 | * Accessed via /sys/class/scsi_host/hostxxx/mbox. | |
3528 | * Uses the sysfs mbox to receive data from to the adapter. | |
3529 | * | |
3530 | * Returns: | |
3531 | * -ERANGE off greater than mailbox command size | |
3532 | * -EINVAL off, count or buff address invalid | |
3533 | * zero if off and count are zero | |
3534 | * -EACCES adapter over temp | |
3535 | * -EPERM garbage can value to catch a multitude of errors | |
3536 | * -EAGAIN management IO not permitted, state or off error | |
3537 | * -ETIME mailbox timeout | |
3538 | * -ENODEV mailbox error | |
3539 | * count number of bytes transferred | |
3540 | **/ | |
dea3101e | 3541 | static ssize_t |
91a69029 ZR |
3542 | sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, |
3543 | char *buf, loff_t off, size_t count) | |
dea3101e | 3544 | { |
ee959b00 TJ |
3545 | struct device *dev = container_of(kobj, struct device, kobj); |
3546 | struct Scsi_Host *shost = class_to_shost(dev); | |
2e0fef85 JS |
3547 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3548 | struct lpfc_hba *phba = vport->phba; | |
dea3101e | 3549 | int rc; |
04c68496 | 3550 | MAILBOX_t *pmb; |
dea3101e | 3551 | |
1dcb58e5 | 3552 | if (off > MAILBOX_CMD_SIZE) |
dea3101e JB |
3553 | return -ERANGE; |
3554 | ||
1dcb58e5 JS |
3555 | if ((count + off) > MAILBOX_CMD_SIZE) |
3556 | count = MAILBOX_CMD_SIZE - off; | |
dea3101e JB |
3557 | |
3558 | if (off % 4 || count % 4 || (unsigned long)buf % 4) | |
3559 | return -EINVAL; | |
3560 | ||
3561 | if (off && count == 0) | |
3562 | return 0; | |
3563 | ||
2e0fef85 | 3564 | spin_lock_irq(&phba->hbalock); |
dea3101e | 3565 | |
7af67051 JS |
3566 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
3567 | sysfs_mbox_idle(phba); | |
3568 | spin_unlock_irq(&phba->hbalock); | |
09372820 | 3569 | return -EACCES; |
7af67051 JS |
3570 | } |
3571 | ||
dea3101e JB |
3572 | if (off == 0 && |
3573 | phba->sysfs_mbox.state == SMBOX_WRITING && | |
3574 | phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) { | |
04c68496 JS |
3575 | pmb = &phba->sysfs_mbox.mbox->u.mb; |
3576 | switch (pmb->mbxCommand) { | |
dea3101e | 3577 | /* Offline only */ |
dea3101e JB |
3578 | case MBX_INIT_LINK: |
3579 | case MBX_DOWN_LINK: | |
3580 | case MBX_CONFIG_LINK: | |
3581 | case MBX_CONFIG_RING: | |
3582 | case MBX_RESET_RING: | |
3583 | case MBX_UNREG_LOGIN: | |
3584 | case MBX_CLEAR_LA: | |
3585 | case MBX_DUMP_CONTEXT: | |
3586 | case MBX_RUN_DIAGS: | |
3587 | case MBX_RESTART: | |
dea3101e | 3588 | case MBX_SET_MASK: |
dea3101e | 3589 | case MBX_SET_DEBUG: |
2e0fef85 | 3590 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) { |
dea3101e JB |
3591 | printk(KERN_WARNING "mbox_read:Command 0x%x " |
3592 | "is illegal in on-line state\n", | |
04c68496 | 3593 | pmb->mbxCommand); |
dea3101e | 3594 | sysfs_mbox_idle(phba); |
2e0fef85 | 3595 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3596 | return -EPERM; |
3597 | } | |
a8adb832 JS |
3598 | case MBX_WRITE_NV: |
3599 | case MBX_WRITE_VPARMS: | |
dea3101e JB |
3600 | case MBX_LOAD_SM: |
3601 | case MBX_READ_NV: | |
3602 | case MBX_READ_CONFIG: | |
3603 | case MBX_READ_RCONFIG: | |
3604 | case MBX_READ_STATUS: | |
3605 | case MBX_READ_XRI: | |
3606 | case MBX_READ_REV: | |
3607 | case MBX_READ_LNK_STAT: | |
3608 | case MBX_DUMP_MEMORY: | |
3609 | case MBX_DOWN_LOAD: | |
3610 | case MBX_UPDATE_CFG: | |
41415862 | 3611 | case MBX_KILL_BOARD: |
dea3101e JB |
3612 | case MBX_LOAD_AREA: |
3613 | case MBX_LOAD_EXP_ROM: | |
41415862 JW |
3614 | case MBX_BEACON: |
3615 | case MBX_DEL_LD_ENTRY: | |
09372820 JS |
3616 | case MBX_SET_VARIABLE: |
3617 | case MBX_WRITE_WWN: | |
84774a4d JS |
3618 | case MBX_PORT_CAPABILITIES: |
3619 | case MBX_PORT_IOV_CONTROL: | |
dea3101e JB |
3620 | break; |
3621 | case MBX_READ_SPARM64: | |
3622 | case MBX_READ_LA: | |
3623 | case MBX_READ_LA64: | |
3624 | case MBX_REG_LOGIN: | |
3625 | case MBX_REG_LOGIN64: | |
3626 | case MBX_CONFIG_PORT: | |
3627 | case MBX_RUN_BIU_DIAG: | |
3628 | printk(KERN_WARNING "mbox_read: Illegal Command 0x%x\n", | |
04c68496 | 3629 | pmb->mbxCommand); |
dea3101e | 3630 | sysfs_mbox_idle(phba); |
2e0fef85 | 3631 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3632 | return -EPERM; |
3633 | default: | |
3634 | printk(KERN_WARNING "mbox_read: Unknown Command 0x%x\n", | |
04c68496 | 3635 | pmb->mbxCommand); |
dea3101e | 3636 | sysfs_mbox_idle(phba); |
2e0fef85 | 3637 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3638 | return -EPERM; |
3639 | } | |
3640 | ||
09372820 | 3641 | /* If HBA encountered an error attention, allow only DUMP |
1b32f6aa | 3642 | * or RESTART mailbox commands until the HBA is restarted. |
09372820 | 3643 | */ |
d7c255b2 | 3644 | if (phba->pport->stopped && |
04c68496 JS |
3645 | pmb->mbxCommand != MBX_DUMP_MEMORY && |
3646 | pmb->mbxCommand != MBX_RESTART && | |
3647 | pmb->mbxCommand != MBX_WRITE_VPARMS && | |
3648 | pmb->mbxCommand != MBX_WRITE_WWN) | |
d7c255b2 JS |
3649 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, |
3650 | "1259 mbox: Issued mailbox cmd " | |
3651 | "0x%x while in stopped state.\n", | |
04c68496 | 3652 | pmb->mbxCommand); |
09372820 | 3653 | |
92d7f7b0 JS |
3654 | phba->sysfs_mbox.mbox->vport = vport; |
3655 | ||
58da1ffb JS |
3656 | /* Don't allow mailbox commands to be sent when blocked |
3657 | * or when in the middle of discovery | |
3658 | */ | |
495a714c | 3659 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) { |
46fa311e | 3660 | sysfs_mbox_idle(phba); |
2e0fef85 | 3661 | spin_unlock_irq(&phba->hbalock); |
46fa311e JS |
3662 | return -EAGAIN; |
3663 | } | |
3664 | ||
2e0fef85 | 3665 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
f4b4c68f | 3666 | (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE))) { |
dea3101e | 3667 | |
2e0fef85 | 3668 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3669 | rc = lpfc_sli_issue_mbox (phba, |
3670 | phba->sysfs_mbox.mbox, | |
3671 | MBX_POLL); | |
2e0fef85 | 3672 | spin_lock_irq(&phba->hbalock); |
dea3101e JB |
3673 | |
3674 | } else { | |
2e0fef85 | 3675 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3676 | rc = lpfc_sli_issue_mbox_wait (phba, |
3677 | phba->sysfs_mbox.mbox, | |
04c68496 | 3678 | lpfc_mbox_tmo_val(phba, pmb->mbxCommand) * HZ); |
2e0fef85 | 3679 | spin_lock_irq(&phba->hbalock); |
dea3101e JB |
3680 | } |
3681 | ||
3682 | if (rc != MBX_SUCCESS) { | |
1dcb58e5 | 3683 | if (rc == MBX_TIMEOUT) { |
1dcb58e5 JS |
3684 | phba->sysfs_mbox.mbox = NULL; |
3685 | } | |
dea3101e | 3686 | sysfs_mbox_idle(phba); |
2e0fef85 | 3687 | spin_unlock_irq(&phba->hbalock); |
8f6d98d2 | 3688 | return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV; |
dea3101e JB |
3689 | } |
3690 | phba->sysfs_mbox.state = SMBOX_READING; | |
3691 | } | |
3692 | else if (phba->sysfs_mbox.offset != off || | |
3693 | phba->sysfs_mbox.state != SMBOX_READING) { | |
3694 | printk(KERN_WARNING "mbox_read: Bad State\n"); | |
3695 | sysfs_mbox_idle(phba); | |
2e0fef85 | 3696 | spin_unlock_irq(&phba->hbalock); |
8f6d98d2 | 3697 | return -EAGAIN; |
dea3101e JB |
3698 | } |
3699 | ||
04c68496 | 3700 | memcpy(buf, (uint8_t *) &pmb + off, count); |
dea3101e JB |
3701 | |
3702 | phba->sysfs_mbox.offset = off + count; | |
3703 | ||
1dcb58e5 | 3704 | if (phba->sysfs_mbox.offset == MAILBOX_CMD_SIZE) |
dea3101e JB |
3705 | sysfs_mbox_idle(phba); |
3706 | ||
2e0fef85 | 3707 | spin_unlock_irq(&phba->hbalock); |
dea3101e JB |
3708 | |
3709 | return count; | |
3710 | } | |
3711 | ||
3712 | static struct bin_attribute sysfs_mbox_attr = { | |
3713 | .attr = { | |
3714 | .name = "mbox", | |
3715 | .mode = S_IRUSR | S_IWUSR, | |
dea3101e | 3716 | }, |
1dcb58e5 | 3717 | .size = MAILBOX_CMD_SIZE, |
dea3101e JB |
3718 | .read = sysfs_mbox_read, |
3719 | .write = sysfs_mbox_write, | |
3720 | }; | |
3721 | ||
e59058c4 | 3722 | /** |
3621a710 | 3723 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
e59058c4 JS |
3724 | * @vport: address of lpfc vport structure. |
3725 | * | |
3726 | * Return codes: | |
3727 | * zero on success | |
3728 | * error return code from sysfs_create_bin_file() | |
3729 | **/ | |
dea3101e | 3730 | int |
2e0fef85 | 3731 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
dea3101e | 3732 | { |
2e0fef85 | 3733 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
dea3101e JB |
3734 | int error; |
3735 | ||
ee959b00 | 3736 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
eada272d JS |
3737 | &sysfs_drvr_stat_data_attr); |
3738 | ||
3739 | /* Virtual ports do not need ctrl_reg and mbox */ | |
3740 | if (error || vport->port_type == LPFC_NPIV_PORT) | |
dea3101e JB |
3741 | goto out; |
3742 | ||
ee959b00 | 3743 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
eada272d | 3744 | &sysfs_ctlreg_attr); |
dea3101e | 3745 | if (error) |
eada272d | 3746 | goto out_remove_stat_attr; |
dea3101e | 3747 | |
ea2151b4 | 3748 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
eada272d | 3749 | &sysfs_mbox_attr); |
ea2151b4 | 3750 | if (error) |
eada272d | 3751 | goto out_remove_ctlreg_attr; |
ea2151b4 | 3752 | |
dea3101e JB |
3753 | return 0; |
3754 | out_remove_ctlreg_attr: | |
ee959b00 | 3755 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
eada272d JS |
3756 | out_remove_stat_attr: |
3757 | sysfs_remove_bin_file(&shost->shost_dev.kobj, | |
3758 | &sysfs_drvr_stat_data_attr); | |
dea3101e JB |
3759 | out: |
3760 | return error; | |
3761 | } | |
3762 | ||
e59058c4 | 3763 | /** |
3621a710 | 3764 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
e59058c4 JS |
3765 | * @vport: address of lpfc vport structure. |
3766 | **/ | |
dea3101e | 3767 | void |
2e0fef85 | 3768 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
dea3101e | 3769 | { |
2e0fef85 | 3770 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
ea2151b4 JS |
3771 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
3772 | &sysfs_drvr_stat_data_attr); | |
eada272d JS |
3773 | /* Virtual ports do not need ctrl_reg and mbox */ |
3774 | if (vport->port_type == LPFC_NPIV_PORT) | |
3775 | return; | |
ee959b00 TJ |
3776 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
3777 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); | |
dea3101e JB |
3778 | } |
3779 | ||
3780 | ||
3781 | /* | |
3782 | * Dynamic FC Host Attributes Support | |
3783 | */ | |
3784 | ||
e59058c4 | 3785 | /** |
3621a710 | 3786 | * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id |
e59058c4 JS |
3787 | * @shost: kernel scsi host pointer. |
3788 | **/ | |
dea3101e JB |
3789 | static void |
3790 | lpfc_get_host_port_id(struct Scsi_Host *shost) | |
3791 | { | |
2e0fef85 JS |
3792 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3793 | ||
dea3101e | 3794 | /* note: fc_myDID already in cpu endianness */ |
2e0fef85 | 3795 | fc_host_port_id(shost) = vport->fc_myDID; |
dea3101e JB |
3796 | } |
3797 | ||
e59058c4 | 3798 | /** |
3621a710 | 3799 | * lpfc_get_host_port_type - Set the value of the scsi host port type |
e59058c4 JS |
3800 | * @shost: kernel scsi host pointer. |
3801 | **/ | |
dea3101e JB |
3802 | static void |
3803 | lpfc_get_host_port_type(struct Scsi_Host *shost) | |
3804 | { | |
2e0fef85 JS |
3805 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3806 | struct lpfc_hba *phba = vport->phba; | |
dea3101e JB |
3807 | |
3808 | spin_lock_irq(shost->host_lock); | |
3809 | ||
92d7f7b0 JS |
3810 | if (vport->port_type == LPFC_NPIV_PORT) { |
3811 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; | |
3812 | } else if (lpfc_is_link_up(phba)) { | |
dea3101e | 3813 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
2e0fef85 | 3814 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
dea3101e JB |
3815 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
3816 | else | |
3817 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; | |
3818 | } else { | |
2e0fef85 | 3819 | if (vport->fc_flag & FC_FABRIC) |
dea3101e JB |
3820 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
3821 | else | |
3822 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; | |
3823 | } | |
3824 | } else | |
3825 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; | |
3826 | ||
3827 | spin_unlock_irq(shost->host_lock); | |
3828 | } | |
3829 | ||
e59058c4 | 3830 | /** |
3621a710 | 3831 | * lpfc_get_host_port_state - Set the value of the scsi host port state |
e59058c4 JS |
3832 | * @shost: kernel scsi host pointer. |
3833 | **/ | |
dea3101e JB |
3834 | static void |
3835 | lpfc_get_host_port_state(struct Scsi_Host *shost) | |
3836 | { | |
2e0fef85 JS |
3837 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3838 | struct lpfc_hba *phba = vport->phba; | |
dea3101e JB |
3839 | |
3840 | spin_lock_irq(shost->host_lock); | |
3841 | ||
2e0fef85 | 3842 | if (vport->fc_flag & FC_OFFLINE_MODE) |
dea3101e JB |
3843 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
3844 | else { | |
2e0fef85 JS |
3845 | switch (phba->link_state) { |
3846 | case LPFC_LINK_UNKNOWN: | |
dea3101e JB |
3847 | case LPFC_LINK_DOWN: |
3848 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; | |
3849 | break; | |
3850 | case LPFC_LINK_UP: | |
dea3101e JB |
3851 | case LPFC_CLEAR_LA: |
3852 | case LPFC_HBA_READY: | |
3853 | /* Links up, beyond this port_type reports state */ | |
3854 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; | |
3855 | break; | |
3856 | case LPFC_HBA_ERROR: | |
3857 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; | |
3858 | break; | |
3859 | default: | |
3860 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; | |
3861 | break; | |
3862 | } | |
3863 | } | |
3864 | ||
3865 | spin_unlock_irq(shost->host_lock); | |
3866 | } | |
3867 | ||
e59058c4 | 3868 | /** |
3621a710 | 3869 | * lpfc_get_host_speed - Set the value of the scsi host speed |
e59058c4 JS |
3870 | * @shost: kernel scsi host pointer. |
3871 | **/ | |
dea3101e JB |
3872 | static void |
3873 | lpfc_get_host_speed(struct Scsi_Host *shost) | |
3874 | { | |
2e0fef85 JS |
3875 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3876 | struct lpfc_hba *phba = vport->phba; | |
dea3101e JB |
3877 | |
3878 | spin_lock_irq(shost->host_lock); | |
3879 | ||
2e0fef85 | 3880 | if (lpfc_is_link_up(phba)) { |
dea3101e JB |
3881 | switch(phba->fc_linkspeed) { |
3882 | case LA_1GHZ_LINK: | |
3883 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; | |
3884 | break; | |
3885 | case LA_2GHZ_LINK: | |
3886 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; | |
3887 | break; | |
3888 | case LA_4GHZ_LINK: | |
3889 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; | |
3890 | break; | |
b87eab38 JS |
3891 | case LA_8GHZ_LINK: |
3892 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; | |
3893 | break; | |
f4b4c68f JS |
3894 | case LA_10GHZ_LINK: |
3895 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; | |
3896 | break; | |
dea3101e JB |
3897 | default: |
3898 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; | |
3899 | break; | |
3900 | } | |
09372820 JS |
3901 | } else |
3902 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; | |
dea3101e JB |
3903 | |
3904 | spin_unlock_irq(shost->host_lock); | |
3905 | } | |
3906 | ||
e59058c4 | 3907 | /** |
3621a710 | 3908 | * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name |
e59058c4 JS |
3909 | * @shost: kernel scsi host pointer. |
3910 | **/ | |
dea3101e JB |
3911 | static void |
3912 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) | |
3913 | { | |
2e0fef85 JS |
3914 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3915 | struct lpfc_hba *phba = vport->phba; | |
f631b4be | 3916 | u64 node_name; |
dea3101e JB |
3917 | |
3918 | spin_lock_irq(shost->host_lock); | |
3919 | ||
2e0fef85 | 3920 | if ((vport->fc_flag & FC_FABRIC) || |
dea3101e | 3921 | ((phba->fc_topology == TOPOLOGY_LOOP) && |
2e0fef85 | 3922 | (vport->fc_flag & FC_PUBLIC_LOOP))) |
68ce1eb5 | 3923 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
dea3101e JB |
3924 | else |
3925 | /* fabric is local port if there is no F/FL_Port */ | |
09372820 | 3926 | node_name = 0; |
dea3101e JB |
3927 | |
3928 | spin_unlock_irq(shost->host_lock); | |
3929 | ||
f631b4be | 3930 | fc_host_fabric_name(shost) = node_name; |
dea3101e JB |
3931 | } |
3932 | ||
e59058c4 | 3933 | /** |
3621a710 | 3934 | * lpfc_get_stats - Return statistical information about the adapter |
e59058c4 JS |
3935 | * @shost: kernel scsi host pointer. |
3936 | * | |
3937 | * Notes: | |
3938 | * NULL on error for link down, no mbox pool, sli2 active, | |
3939 | * management not allowed, memory allocation error, or mbox error. | |
3940 | * | |
3941 | * Returns: | |
3942 | * NULL for error | |
3943 | * address of the adapter host statistics | |
3944 | **/ | |
dea3101e JB |
3945 | static struct fc_host_statistics * |
3946 | lpfc_get_stats(struct Scsi_Host *shost) | |
3947 | { | |
2e0fef85 JS |
3948 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
3949 | struct lpfc_hba *phba = vport->phba; | |
3950 | struct lpfc_sli *psli = &phba->sli; | |
f888ba3c | 3951 | struct fc_host_statistics *hs = &phba->link_stats; |
64ba8818 | 3952 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
dea3101e JB |
3953 | LPFC_MBOXQ_t *pmboxq; |
3954 | MAILBOX_t *pmb; | |
64ba8818 | 3955 | unsigned long seconds; |
433c3579 | 3956 | int rc = 0; |
dea3101e | 3957 | |
92d7f7b0 JS |
3958 | /* |
3959 | * prevent udev from issuing mailbox commands until the port is | |
3960 | * configured. | |
3961 | */ | |
2e0fef85 JS |
3962 | if (phba->link_state < LPFC_LINK_DOWN || |
3963 | !phba->mbox_mem_pool || | |
f4b4c68f | 3964 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
92d7f7b0 | 3965 | return NULL; |
2e0fef85 JS |
3966 | |
3967 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) | |
46fa311e JS |
3968 | return NULL; |
3969 | ||
dea3101e JB |
3970 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
3971 | if (!pmboxq) | |
3972 | return NULL; | |
3973 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); | |
3974 | ||
04c68496 | 3975 | pmb = &pmboxq->u.mb; |
dea3101e JB |
3976 | pmb->mbxCommand = MBX_READ_STATUS; |
3977 | pmb->mbxOwner = OWN_HOST; | |
3978 | pmboxq->context1 = NULL; | |
92d7f7b0 | 3979 | pmboxq->vport = vport; |
dea3101e | 3980 | |
2e0fef85 | 3981 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
04c68496 | 3982 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
dea3101e | 3983 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
433c3579 | 3984 | else |
dea3101e JB |
3985 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
3986 | ||
3987 | if (rc != MBX_SUCCESS) { | |
858c9f6c | 3988 | if (rc != MBX_TIMEOUT) |
433c3579 | 3989 | mempool_free(pmboxq, phba->mbox_mem_pool); |
dea3101e JB |
3990 | return NULL; |
3991 | } | |
3992 | ||
f888ba3c JSEC |
3993 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
3994 | ||
dea3101e JB |
3995 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
3996 | hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256); | |
3997 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; | |
3998 | hs->rx_words = (pmb->un.varRdStatus.rcvByteCnt * 256); | |
3999 | ||
433c3579 | 4000 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
dea3101e JB |
4001 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
4002 | pmb->mbxOwner = OWN_HOST; | |
4003 | pmboxq->context1 = NULL; | |
92d7f7b0 | 4004 | pmboxq->vport = vport; |
dea3101e | 4005 | |
2e0fef85 | 4006 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
f4b4c68f | 4007 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
dea3101e | 4008 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
433c3579 | 4009 | else |
dea3101e JB |
4010 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
4011 | ||
4012 | if (rc != MBX_SUCCESS) { | |
858c9f6c | 4013 | if (rc != MBX_TIMEOUT) |
92d7f7b0 | 4014 | mempool_free(pmboxq, phba->mbox_mem_pool); |
dea3101e JB |
4015 | return NULL; |
4016 | } | |
4017 | ||
4018 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; | |
4019 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; | |
4020 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; | |
4021 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; | |
4022 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; | |
4023 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; | |
4024 | hs->error_frames = pmb->un.varRdLnk.crcCnt; | |
4025 | ||
64ba8818 JS |
4026 | hs->link_failure_count -= lso->link_failure_count; |
4027 | hs->loss_of_sync_count -= lso->loss_of_sync_count; | |
4028 | hs->loss_of_signal_count -= lso->loss_of_signal_count; | |
4029 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; | |
4030 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; | |
4031 | hs->invalid_crc_count -= lso->invalid_crc_count; | |
4032 | hs->error_frames -= lso->error_frames; | |
4033 | ||
4d9ab994 JS |
4034 | if (phba->hba_flag & HBA_FCOE_SUPPORT) { |
4035 | hs->lip_count = -1; | |
4036 | hs->nos_count = (phba->link_events >> 1); | |
4037 | hs->nos_count -= lso->link_events; | |
4038 | } else if (phba->fc_topology == TOPOLOGY_LOOP) { | |
dea3101e | 4039 | hs->lip_count = (phba->fc_eventTag >> 1); |
64ba8818 | 4040 | hs->lip_count -= lso->link_events; |
dea3101e JB |
4041 | hs->nos_count = -1; |
4042 | } else { | |
4043 | hs->lip_count = -1; | |
4044 | hs->nos_count = (phba->fc_eventTag >> 1); | |
64ba8818 | 4045 | hs->nos_count -= lso->link_events; |
dea3101e JB |
4046 | } |
4047 | ||
4048 | hs->dumped_frames = -1; | |
4049 | ||
64ba8818 JS |
4050 | seconds = get_seconds(); |
4051 | if (seconds < psli->stats_start) | |
4052 | hs->seconds_since_last_reset = seconds + | |
4053 | ((unsigned long)-1 - psli->stats_start); | |
4054 | else | |
4055 | hs->seconds_since_last_reset = seconds - psli->stats_start; | |
dea3101e | 4056 | |
1dcb58e5 JS |
4057 | mempool_free(pmboxq, phba->mbox_mem_pool); |
4058 | ||
dea3101e JB |
4059 | return hs; |
4060 | } | |
4061 | ||
e59058c4 | 4062 | /** |
3621a710 | 4063 | * lpfc_reset_stats - Copy the adapter link stats information |
e59058c4 JS |
4064 | * @shost: kernel scsi host pointer. |
4065 | **/ | |
64ba8818 JS |
4066 | static void |
4067 | lpfc_reset_stats(struct Scsi_Host *shost) | |
4068 | { | |
2e0fef85 JS |
4069 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
4070 | struct lpfc_hba *phba = vport->phba; | |
4071 | struct lpfc_sli *psli = &phba->sli; | |
4072 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; | |
64ba8818 JS |
4073 | LPFC_MBOXQ_t *pmboxq; |
4074 | MAILBOX_t *pmb; | |
4075 | int rc = 0; | |
4076 | ||
2e0fef85 | 4077 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
46fa311e JS |
4078 | return; |
4079 | ||
64ba8818 JS |
4080 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
4081 | if (!pmboxq) | |
4082 | return; | |
4083 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); | |
4084 | ||
04c68496 | 4085 | pmb = &pmboxq->u.mb; |
64ba8818 JS |
4086 | pmb->mbxCommand = MBX_READ_STATUS; |
4087 | pmb->mbxOwner = OWN_HOST; | |
4088 | pmb->un.varWords[0] = 0x1; /* reset request */ | |
4089 | pmboxq->context1 = NULL; | |
92d7f7b0 | 4090 | pmboxq->vport = vport; |
64ba8818 | 4091 | |
2e0fef85 | 4092 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
f4b4c68f | 4093 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
64ba8818 JS |
4094 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
4095 | else | |
4096 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); | |
4097 | ||
4098 | if (rc != MBX_SUCCESS) { | |
858c9f6c | 4099 | if (rc != MBX_TIMEOUT) |
64ba8818 JS |
4100 | mempool_free(pmboxq, phba->mbox_mem_pool); |
4101 | return; | |
4102 | } | |
4103 | ||
4104 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); | |
4105 | pmb->mbxCommand = MBX_READ_LNK_STAT; | |
4106 | pmb->mbxOwner = OWN_HOST; | |
4107 | pmboxq->context1 = NULL; | |
92d7f7b0 | 4108 | pmboxq->vport = vport; |
64ba8818 | 4109 | |
2e0fef85 | 4110 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
f4b4c68f | 4111 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
64ba8818 JS |
4112 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
4113 | else | |
4114 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); | |
4115 | ||
4116 | if (rc != MBX_SUCCESS) { | |
858c9f6c | 4117 | if (rc != MBX_TIMEOUT) |
64ba8818 JS |
4118 | mempool_free( pmboxq, phba->mbox_mem_pool); |
4119 | return; | |
4120 | } | |
4121 | ||
4122 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; | |
4123 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; | |
4124 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; | |
4125 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; | |
4126 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; | |
4127 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; | |
4128 | lso->error_frames = pmb->un.varRdLnk.crcCnt; | |
4d9ab994 JS |
4129 | if (phba->hba_flag & HBA_FCOE_SUPPORT) |
4130 | lso->link_events = (phba->link_events >> 1); | |
4131 | else | |
4132 | lso->link_events = (phba->fc_eventTag >> 1); | |
64ba8818 JS |
4133 | |
4134 | psli->stats_start = get_seconds(); | |
4135 | ||
1dcb58e5 JS |
4136 | mempool_free(pmboxq, phba->mbox_mem_pool); |
4137 | ||
64ba8818 JS |
4138 | return; |
4139 | } | |
dea3101e JB |
4140 | |
4141 | /* | |
4142 | * The LPFC driver treats linkdown handling as target loss events so there | |
4143 | * are no sysfs handlers for link_down_tmo. | |
4144 | */ | |
685f0bf7 | 4145 | |
e59058c4 | 4146 | /** |
3621a710 | 4147 | * lpfc_get_node_by_target - Return the nodelist for a target |
e59058c4 JS |
4148 | * @starget: kernel scsi target pointer. |
4149 | * | |
4150 | * Returns: | |
4151 | * address of the node list if found | |
4152 | * NULL target not found | |
4153 | **/ | |
685f0bf7 JS |
4154 | static struct lpfc_nodelist * |
4155 | lpfc_get_node_by_target(struct scsi_target *starget) | |
dea3101e | 4156 | { |
2e0fef85 JS |
4157 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
4158 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
685f0bf7 | 4159 | struct lpfc_nodelist *ndlp; |
dea3101e JB |
4160 | |
4161 | spin_lock_irq(shost->host_lock); | |
685f0bf7 | 4162 | /* Search for this, mapped, target ID */ |
2e0fef85 | 4163 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
e47c9093 JS |
4164 | if (NLP_CHK_NODE_ACT(ndlp) && |
4165 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && | |
685f0bf7 JS |
4166 | starget->id == ndlp->nlp_sid) { |
4167 | spin_unlock_irq(shost->host_lock); | |
4168 | return ndlp; | |
dea3101e JB |
4169 | } |
4170 | } | |
4171 | spin_unlock_irq(shost->host_lock); | |
685f0bf7 JS |
4172 | return NULL; |
4173 | } | |
dea3101e | 4174 | |
e59058c4 | 4175 | /** |
3621a710 | 4176 | * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1 |
e59058c4 JS |
4177 | * @starget: kernel scsi target pointer. |
4178 | **/ | |
685f0bf7 JS |
4179 | static void |
4180 | lpfc_get_starget_port_id(struct scsi_target *starget) | |
4181 | { | |
4182 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); | |
4183 | ||
4184 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; | |
dea3101e JB |
4185 | } |
4186 | ||
e59058c4 | 4187 | /** |
3621a710 | 4188 | * lpfc_get_starget_node_name - Set the target node name |
e59058c4 JS |
4189 | * @starget: kernel scsi target pointer. |
4190 | * | |
4191 | * Description: Set the target node name to the ndlp node name wwn or zero. | |
4192 | **/ | |
dea3101e JB |
4193 | static void |
4194 | lpfc_get_starget_node_name(struct scsi_target *starget) | |
4195 | { | |
685f0bf7 | 4196 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
dea3101e | 4197 | |
685f0bf7 JS |
4198 | fc_starget_node_name(starget) = |
4199 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; | |
dea3101e JB |
4200 | } |
4201 | ||
e59058c4 | 4202 | /** |
3621a710 | 4203 | * lpfc_get_starget_port_name - Set the target port name |
e59058c4 JS |
4204 | * @starget: kernel scsi target pointer. |
4205 | * | |
4206 | * Description: set the target port name to the ndlp port name wwn or zero. | |
4207 | **/ | |
dea3101e JB |
4208 | static void |
4209 | lpfc_get_starget_port_name(struct scsi_target *starget) | |
4210 | { | |
685f0bf7 | 4211 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
dea3101e | 4212 | |
685f0bf7 JS |
4213 | fc_starget_port_name(starget) = |
4214 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; | |
dea3101e JB |
4215 | } |
4216 | ||
e59058c4 | 4217 | /** |
3621a710 | 4218 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
e59058c4 JS |
4219 | * @rport: fc rport address. |
4220 | * @timeout: new value for dev loss tmo. | |
4221 | * | |
4222 | * Description: | |
4223 | * If timeout is non zero set the dev_loss_tmo to timeout, else set | |
4224 | * dev_loss_tmo to one. | |
4225 | **/ | |
dea3101e JB |
4226 | static void |
4227 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | |
4228 | { | |
dea3101e | 4229 | if (timeout) |
c01f3208 | 4230 | rport->dev_loss_tmo = timeout; |
dea3101e | 4231 | else |
c01f3208 | 4232 | rport->dev_loss_tmo = 1; |
dea3101e JB |
4233 | } |
4234 | ||
e59058c4 | 4235 | /** |
3621a710 | 4236 | * lpfc_rport_show_function - Return rport target information |
e59058c4 JS |
4237 | * |
4238 | * Description: | |
4239 | * Macro that uses field to generate a function with the name lpfc_show_rport_ | |
4240 | * | |
4241 | * lpfc_show_rport_##field: returns the bytes formatted in buf | |
4242 | * @cdev: class converted to an fc_rport. | |
4243 | * @buf: on return contains the target_field or zero. | |
4244 | * | |
4245 | * Returns: size of formatted string. | |
4246 | **/ | |
dea3101e JB |
4247 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
4248 | static ssize_t \ | |
ee959b00 TJ |
4249 | lpfc_show_rport_##field (struct device *dev, \ |
4250 | struct device_attribute *attr, \ | |
4251 | char *buf) \ | |
dea3101e | 4252 | { \ |
ee959b00 | 4253 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
dea3101e JB |
4254 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
4255 | return snprintf(buf, sz, format_string, \ | |
4256 | (rdata->target) ? cast rdata->target->field : 0); \ | |
4257 | } | |
4258 | ||
4259 | #define lpfc_rport_rd_attr(field, format_string, sz) \ | |
4260 | lpfc_rport_show_function(field, format_string, sz, ) \ | |
4261 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) | |
4262 | ||
eada272d | 4263 | /** |
3621a710 | 4264 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
eada272d JS |
4265 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
4266 | * | |
4267 | * Description: | |
4268 | * This function is called by the transport after the @fc_vport's symbolic name | |
4269 | * has been changed. This function re-registers the symbolic name with the | |
4270 | * switch to propogate the change into the fabric if the vport is active. | |
4271 | **/ | |
4272 | static void | |
4273 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) | |
4274 | { | |
4275 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; | |
4276 | ||
4277 | if (vport->port_state == LPFC_VPORT_READY) | |
4278 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); | |
4279 | } | |
dea3101e | 4280 | |
f4b4c68f JS |
4281 | /** |
4282 | * lpfc_hba_log_verbose_init - Set hba's log verbose level | |
4283 | * @phba: Pointer to lpfc_hba struct. | |
4284 | * | |
4285 | * This function is called by the lpfc_get_cfgparam() routine to set the | |
4286 | * module lpfc_log_verbose into the @phba cfg_log_verbose for use with | |
4287 | * log messsage according to the module's lpfc_log_verbose parameter setting | |
4288 | * before hba port or vport created. | |
4289 | **/ | |
4290 | static void | |
4291 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) | |
4292 | { | |
4293 | phba->cfg_log_verbose = verbose; | |
4294 | } | |
4295 | ||
dea3101e JB |
4296 | struct fc_function_template lpfc_transport_functions = { |
4297 | /* fixed attributes the driver supports */ | |
4298 | .show_host_node_name = 1, | |
4299 | .show_host_port_name = 1, | |
4300 | .show_host_supported_classes = 1, | |
4301 | .show_host_supported_fc4s = 1, | |
dea3101e JB |
4302 | .show_host_supported_speeds = 1, |
4303 | .show_host_maxframe_size = 1, | |
eada272d | 4304 | .show_host_symbolic_name = 1, |
dea3101e JB |
4305 | |
4306 | /* dynamic attributes the driver supports */ | |
4307 | .get_host_port_id = lpfc_get_host_port_id, | |
4308 | .show_host_port_id = 1, | |
4309 | ||
4310 | .get_host_port_type = lpfc_get_host_port_type, | |
4311 | .show_host_port_type = 1, | |
4312 | ||
4313 | .get_host_port_state = lpfc_get_host_port_state, | |
4314 | .show_host_port_state = 1, | |
4315 | ||
4316 | /* active_fc4s is shown but doesn't change (thus no get function) */ | |
4317 | .show_host_active_fc4s = 1, | |
4318 | ||
4319 | .get_host_speed = lpfc_get_host_speed, | |
4320 | .show_host_speed = 1, | |
4321 | ||
4322 | .get_host_fabric_name = lpfc_get_host_fabric_name, | |
4323 | .show_host_fabric_name = 1, | |
4324 | ||
4325 | /* | |
4326 | * The LPFC driver treats linkdown handling as target loss events | |
4327 | * so there are no sysfs handlers for link_down_tmo. | |
4328 | */ | |
4329 | ||
4330 | .get_fc_host_stats = lpfc_get_stats, | |
64ba8818 | 4331 | .reset_fc_host_stats = lpfc_reset_stats, |
dea3101e JB |
4332 | |
4333 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), | |
4334 | .show_rport_maxframe_size = 1, | |
4335 | .show_rport_supported_classes = 1, | |
4336 | ||
dea3101e JB |
4337 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
4338 | .show_rport_dev_loss_tmo = 1, | |
4339 | ||
4340 | .get_starget_port_id = lpfc_get_starget_port_id, | |
4341 | .show_starget_port_id = 1, | |
4342 | ||
4343 | .get_starget_node_name = lpfc_get_starget_node_name, | |
4344 | .show_starget_node_name = 1, | |
4345 | ||
4346 | .get_starget_port_name = lpfc_get_starget_port_name, | |
4347 | .show_starget_port_name = 1, | |
91ca7b01 AV |
4348 | |
4349 | .issue_fc_host_lip = lpfc_issue_lip, | |
c01f3208 JS |
4350 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
4351 | .terminate_rport_io = lpfc_terminate_rport_io, | |
92d7f7b0 | 4352 | |
92d7f7b0 | 4353 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
eada272d JS |
4354 | |
4355 | .vport_disable = lpfc_vport_disable, | |
4356 | ||
4357 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, | |
f1c3b0fc JS |
4358 | |
4359 | .bsg_request = lpfc_bsg_request, | |
4360 | .bsg_timeout = lpfc_bsg_timeout, | |
92d7f7b0 JS |
4361 | }; |
4362 | ||
98c9ea5c JS |
4363 | struct fc_function_template lpfc_vport_transport_functions = { |
4364 | /* fixed attributes the driver supports */ | |
4365 | .show_host_node_name = 1, | |
4366 | .show_host_port_name = 1, | |
4367 | .show_host_supported_classes = 1, | |
4368 | .show_host_supported_fc4s = 1, | |
4369 | .show_host_supported_speeds = 1, | |
4370 | .show_host_maxframe_size = 1, | |
eada272d | 4371 | .show_host_symbolic_name = 1, |
98c9ea5c JS |
4372 | |
4373 | /* dynamic attributes the driver supports */ | |
4374 | .get_host_port_id = lpfc_get_host_port_id, | |
4375 | .show_host_port_id = 1, | |
4376 | ||
4377 | .get_host_port_type = lpfc_get_host_port_type, | |
4378 | .show_host_port_type = 1, | |
4379 | ||
4380 | .get_host_port_state = lpfc_get_host_port_state, | |
4381 | .show_host_port_state = 1, | |
4382 | ||
4383 | /* active_fc4s is shown but doesn't change (thus no get function) */ | |
4384 | .show_host_active_fc4s = 1, | |
4385 | ||
4386 | .get_host_speed = lpfc_get_host_speed, | |
4387 | .show_host_speed = 1, | |
4388 | ||
4389 | .get_host_fabric_name = lpfc_get_host_fabric_name, | |
4390 | .show_host_fabric_name = 1, | |
4391 | ||
4392 | /* | |
4393 | * The LPFC driver treats linkdown handling as target loss events | |
4394 | * so there are no sysfs handlers for link_down_tmo. | |
4395 | */ | |
4396 | ||
4397 | .get_fc_host_stats = lpfc_get_stats, | |
4398 | .reset_fc_host_stats = lpfc_reset_stats, | |
4399 | ||
4400 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), | |
4401 | .show_rport_maxframe_size = 1, | |
4402 | .show_rport_supported_classes = 1, | |
4403 | ||
4404 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, | |
4405 | .show_rport_dev_loss_tmo = 1, | |
4406 | ||
4407 | .get_starget_port_id = lpfc_get_starget_port_id, | |
4408 | .show_starget_port_id = 1, | |
4409 | ||
4410 | .get_starget_node_name = lpfc_get_starget_node_name, | |
4411 | .show_starget_node_name = 1, | |
4412 | ||
4413 | .get_starget_port_name = lpfc_get_starget_port_name, | |
4414 | .show_starget_port_name = 1, | |
4415 | ||
4416 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, | |
4417 | .terminate_rport_io = lpfc_terminate_rport_io, | |
4418 | ||
4419 | .vport_disable = lpfc_vport_disable, | |
eada272d JS |
4420 | |
4421 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, | |
98c9ea5c JS |
4422 | }; |
4423 | ||
e59058c4 | 4424 | /** |
3621a710 | 4425 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
e59058c4 JS |
4426 | * @phba: lpfc_hba pointer. |
4427 | **/ | |
dea3101e JB |
4428 | void |
4429 | lpfc_get_cfgparam(struct lpfc_hba *phba) | |
4430 | { | |
7bcbb752 JSEC |
4431 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
4432 | lpfc_cr_count_init(phba, lpfc_cr_count); | |
cf5bf97e | 4433 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
a4bc3379 JS |
4434 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
4435 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); | |
7bcbb752 JSEC |
4436 | lpfc_ack0_init(phba, lpfc_ack0); |
4437 | lpfc_topology_init(phba, lpfc_topology); | |
7bcbb752 | 4438 | lpfc_link_speed_init(phba, lpfc_link_speed); |
875fbdfe | 4439 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
78b2d852 | 4440 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
4ff43246 | 4441 | lpfc_use_msi_init(phba, lpfc_use_msi); |
da0436e9 JS |
4442 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
4443 | lpfc_fcp_wq_count_init(phba, lpfc_fcp_wq_count); | |
4444 | lpfc_fcp_eq_count_init(phba, lpfc_fcp_eq_count); | |
13815c83 JS |
4445 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
4446 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); | |
81301a9b | 4447 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
45ed1190 JS |
4448 | if (phba->sli_rev == LPFC_SLI_REV4) |
4449 | phba->cfg_poll = 0; | |
4450 | else | |
875fbdfe | 4451 | phba->cfg_poll = lpfc_poll; |
a12e07bc | 4452 | phba->cfg_soft_wwnn = 0L; |
c3f28afa | 4453 | phba->cfg_soft_wwpn = 0L; |
83108bd3 | 4454 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
81301a9b | 4455 | lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); |
7054a606 | 4456 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
6fb120a7 | 4457 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
0d878419 | 4458 | lpfc_aer_support_init(phba, lpfc_aer_support); |
6fb120a7 | 4459 | |
3de2a653 JS |
4460 | return; |
4461 | } | |
b28485ac | 4462 | |
e59058c4 | 4463 | /** |
3621a710 | 4464 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
e59058c4 JS |
4465 | * @vport: lpfc_vport pointer. |
4466 | **/ | |
3de2a653 JS |
4467 | void |
4468 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) | |
4469 | { | |
e8b62011 | 4470 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
3de2a653 JS |
4471 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
4472 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); | |
4473 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); | |
4474 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); | |
4475 | lpfc_restrict_login_init(vport, lpfc_restrict_login); | |
4476 | lpfc_fcp_class_init(vport, lpfc_fcp_class); | |
4477 | lpfc_use_adisc_init(vport, lpfc_use_adisc); | |
977b5a0a | 4478 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
3de2a653 JS |
4479 | lpfc_fdmi_on_init(vport, lpfc_fdmi_on); |
4480 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); | |
4481 | lpfc_max_luns_init(vport, lpfc_max_luns); | |
4482 | lpfc_scan_down_init(vport, lpfc_scan_down); | |
7ee5d43e | 4483 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
dea3101e JB |
4484 | return; |
4485 | } |