]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Jamie Wellnitz <jamie.wellnitz@emulex.com> |
2 | Subject: Emulex lpfc driver update to 8.2.8 | |
3 | References: FATE#303485,bnc#420767 | |
4 | ||
5 | Update Emulex lpfc driver from 8.2.7 to 8.2.8 | |
6 | ||
7 | Signed-off-by: Hannes Reinecke <hare@suse.de> | |
8 | ||
9 | --- | |
10 | drivers/scsi/lpfc/lpfc.h | 96 +- | |
11 | drivers/scsi/lpfc/lpfc_attr.c | 1375 +++++++++++++++++++++++++++++ | |
12 | drivers/scsi/lpfc/lpfc_crtn.h | 51 - | |
13 | drivers/scsi/lpfc/lpfc_ct.c | 20 | |
14 | drivers/scsi/lpfc/lpfc_debugfs.c | 400 +++++++- | |
15 | drivers/scsi/lpfc/lpfc_disc.h | 23 | |
16 | drivers/scsi/lpfc/lpfc_els.c | 1712 ++++++++++++++++++++++++++++++++++-- | |
17 | drivers/scsi/lpfc/lpfc_hbadisc.c | 233 ++++- | |
18 | drivers/scsi/lpfc/lpfc_hw.h | 183 +++ | |
19 | drivers/scsi/lpfc/lpfc_init.c | 924 +++++++++++++++---- | |
20 | drivers/scsi/lpfc/lpfc_mbox.c | 624 +++++++++++-- | |
21 | drivers/scsi/lpfc/lpfc_mem.c | 116 ++ | |
22 | drivers/scsi/lpfc/lpfc_nl.h | 163 +++ | |
23 | drivers/scsi/lpfc/lpfc_nportdisc.c | 24 | |
24 | drivers/scsi/lpfc/lpfc_scsi.c | 516 ++++++++++- | |
25 | drivers/scsi/lpfc/lpfc_scsi.h | 5 | |
26 | drivers/scsi/lpfc/lpfc_sli.c | 1715 ++++++++++++++++++++++++++++++++----- | |
27 | drivers/scsi/lpfc/lpfc_sli.h | 1 | |
28 | drivers/scsi/lpfc/lpfc_version.h | 6 | |
29 | drivers/scsi/lpfc/lpfc_vport.c | 168 +++ | |
30 | drivers/scsi/lpfc/lpfc_vport.h | 4 | |
31 | 21 files changed, 7464 insertions(+), 895 deletions(-) | |
32 | ||
33 | --- a/drivers/scsi/lpfc/lpfc_attr.c | |
34 | +++ b/drivers/scsi/lpfc/lpfc_attr.c | |
35 | @@ -32,6 +32,7 @@ | |
36 | ||
37 | #include "lpfc_hw.h" | |
38 | #include "lpfc_sli.h" | |
39 | +#include "lpfc_nl.h" | |
40 | #include "lpfc_disc.h" | |
41 | #include "lpfc_scsi.h" | |
42 | #include "lpfc.h" | |
43 | @@ -49,6 +50,21 @@ | |
44 | #define LPFC_LINK_SPEED_BITMAP 0x00000117 | |
45 | #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8" | |
46 | ||
47 | +/** | |
48 | + * lpfc_jedec_to_ascii: Hex to ascii convertor according to JEDEC rules. | |
49 | + * @incr: integer to convert. | |
50 | + * @hdw: ascii string holding converted integer plus a string terminator. | |
51 | + * | |
52 | + * Description: | |
53 | + * JEDEC Joint Electron Device Engineering Council. | |
54 | + * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii | |
55 | + * character string. The string is then terminated with a NULL in byte 9. | |
56 | + * Hex 0-9 becomes ascii '0' to '9'. | |
57 | + * Hex a-f becomes ascii '=' to 'B' capital B. | |
58 | + * | |
59 | + * Notes: | |
60 | + * Coded for 32 bit integers only. | |
61 | + **/ | |
62 | static void | |
63 | lpfc_jedec_to_ascii(int incr, char hdw[]) | |
64 | { | |
65 | @@ -65,6 +81,14 @@ lpfc_jedec_to_ascii(int incr, char hdw[] | |
66 | return; | |
67 | } | |
68 | ||
69 | +/** | |
70 | + * lpfc_drvr_version_show: Return the Emulex driver string with version number. | |
71 | + * @dev: class unused variable. | |
72 | + * @attr: device attribute, not used. | |
73 | + * @buf: on return contains the module description text. | |
74 | + * | |
75 | + * Returns: size of formatted string. | |
76 | + **/ | |
77 | static ssize_t | |
78 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, | |
79 | char *buf) | |
80 | @@ -72,6 +96,14 @@ lpfc_drvr_version_show(struct device *de | |
81 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); | |
82 | } | |
83 | ||
84 | +/** | |
85 | + * lpfc_info_show: Return some pci info about the host in ascii. | |
86 | + * @dev: class converted to a Scsi_host structure. | |
87 | + * @attr: device attribute, not used. | |
88 | + * @buf: on return contains the formatted text from lpfc_info(). | |
89 | + * | |
90 | + * Returns: size of formatted string. | |
91 | + **/ | |
92 | static ssize_t | |
93 | lpfc_info_show(struct device *dev, struct device_attribute *attr, | |
94 | char *buf) | |
95 | @@ -81,6 +113,14 @@ lpfc_info_show(struct device *dev, struc | |
96 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); | |
97 | } | |
98 | ||
99 | +/** | |
100 | + * lpfc_serialnum_show: Return the hba serial number in ascii. | |
101 | + * @dev: class converted to a Scsi_host structure. | |
102 | + * @attr: device attribute, not used. | |
103 | + * @buf: on return contains the formatted text serial number. | |
104 | + * | |
105 | + * Returns: size of formatted string. | |
106 | + **/ | |
107 | static ssize_t | |
108 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, | |
109 | char *buf) | |
110 | @@ -92,6 +132,18 @@ lpfc_serialnum_show(struct device *dev, | |
111 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); | |
112 | } | |
113 | ||
114 | +/** | |
115 | + * lpfc_temp_sensor_show: Return the temperature sensor level. | |
116 | + * @dev: class converted to a Scsi_host structure. | |
117 | + * @attr: device attribute, not used. | |
118 | + * @buf: on return contains the formatted support level. | |
119 | + * | |
120 | + * Description: | |
121 | + * Returns a number indicating the temperature sensor level currently | |
122 | + * supported, zero or one in ascii. | |
123 | + * | |
124 | + * Returns: size of formatted string. | |
125 | + **/ | |
126 | static ssize_t | |
127 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, | |
128 | char *buf) | |
129 | @@ -102,6 +154,14 @@ lpfc_temp_sensor_show(struct device *dev | |
130 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); | |
131 | } | |
132 | ||
133 | +/** | |
134 | + * lpfc_modeldesc_show: Return the model description of the hba. | |
135 | + * @dev: class converted to a Scsi_host structure. | |
136 | + * @attr: device attribute, not used. | |
137 | + * @buf: on return contains the scsi vpd model description. | |
138 | + * | |
139 | + * Returns: size of formatted string. | |
140 | + **/ | |
141 | static ssize_t | |
142 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, | |
143 | char *buf) | |
144 | @@ -113,6 +173,14 @@ lpfc_modeldesc_show(struct device *dev, | |
145 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); | |
146 | } | |
147 | ||
148 | +/** | |
149 | + * lpfc_modelname_show: Return the model name of the hba. | |
150 | + * @dev: class converted to a Scsi_host structure. | |
151 | + * @attr: device attribute, not used. | |
152 | + * @buf: on return contains the scsi vpd model name. | |
153 | + * | |
154 | + * Returns: size of formatted string. | |
155 | + **/ | |
156 | static ssize_t | |
157 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, | |
158 | char *buf) | |
159 | @@ -124,6 +192,14 @@ lpfc_modelname_show(struct device *dev, | |
160 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); | |
161 | } | |
162 | ||
163 | +/** | |
164 | + * lpfc_programtype_show: Return the program type of the hba. | |
165 | + * @dev: class converted to a Scsi_host structure. | |
166 | + * @attr: device attribute, not used. | |
167 | + * @buf: on return contains the scsi vpd program type. | |
168 | + * | |
169 | + * Returns: size of formatted string. | |
170 | + **/ | |
171 | static ssize_t | |
172 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, | |
173 | char *buf) | |
174 | @@ -135,6 +211,33 @@ lpfc_programtype_show(struct device *dev | |
175 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); | |
176 | } | |
177 | ||
178 | +/** | |
179 | + * lpfc_mlomgmt_show: Return the Menlo Maintenance sli flag. | |
180 | + * @dev: class converted to a Scsi_host structure. | |
181 | + * @attr: device attribute, not used. | |
182 | + * @buf: on return contains the Menlo Maintenance sli flag. | |
183 | + * | |
184 | + * Returns: size of formatted string. | |
185 | + **/ | |
186 | +static ssize_t | |
187 | +lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) | |
188 | +{ | |
189 | + struct Scsi_Host *shost = class_to_shost(dev); | |
190 | + struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; | |
191 | + struct lpfc_hba *phba = vport->phba; | |
192 | + | |
193 | + return snprintf(buf, PAGE_SIZE, "%d\n", | |
194 | + (phba->sli.sli_flag & LPFC_MENLO_MAINT)); | |
195 | +} | |
196 | + | |
197 | +/** | |
198 | + * lpfc_vportnum_show: Return the port number in ascii of the hba. | |
199 | + * @dev: class converted to a Scsi_host structure. | |
200 | + * @attr: device attribute, not used. | |
201 | + * @buf: on return contains scsi vpd program type. | |
202 | + * | |
203 | + * Returns: size of formatted string. | |
204 | + **/ | |
205 | static ssize_t | |
206 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, | |
207 | char *buf) | |
208 | @@ -146,6 +249,14 @@ lpfc_vportnum_show(struct device *dev, s | |
209 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); | |
210 | } | |
211 | ||
212 | +/** | |
213 | + * lpfc_fwrev_show: Return the firmware rev running in the hba. | |
214 | + * @dev: class converted to a Scsi_host structure. | |
215 | + * @attr: device attribute, not used. | |
216 | + * @buf: on return contains the scsi vpd program type. | |
217 | + * | |
218 | + * Returns: size of formatted string. | |
219 | + **/ | |
220 | static ssize_t | |
221 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, | |
222 | char *buf) | |
223 | @@ -159,6 +270,14 @@ lpfc_fwrev_show(struct device *dev, stru | |
224 | return snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", fwrev, phba->sli_rev); | |
225 | } | |
226 | ||
227 | +/** | |
228 | + * lpfc_hdw_show: Return the jedec information about the hba. | |
229 | + * @dev: class converted to a Scsi_host structure. | |
230 | + * @attr: device attribute, not used. | |
231 | + * @buf: on return contains the scsi vpd program type. | |
232 | + * | |
233 | + * Returns: size of formatted string. | |
234 | + **/ | |
235 | static ssize_t | |
236 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) | |
237 | { | |
238 | @@ -171,6 +290,15 @@ lpfc_hdw_show(struct device *dev, struct | |
239 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); | |
240 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); | |
241 | } | |
242 | + | |
243 | +/** | |
244 | + * lpfc_option_rom_version_show: Return the adapter ROM FCode version. | |
245 | + * @dev: class converted to a Scsi_host structure. | |
246 | + * @attr: device attribute, not used. | |
247 | + * @buf: on return contains the ROM and FCode ascii strings. | |
248 | + * | |
249 | + * Returns: size of formatted string. | |
250 | + **/ | |
251 | static ssize_t | |
252 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, | |
253 | char *buf) | |
254 | @@ -181,6 +309,18 @@ lpfc_option_rom_version_show(struct devi | |
255 | ||
256 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); | |
257 | } | |
258 | + | |
259 | +/** | |
260 | + * lpfc_state_show: Return the link state of the port. | |
261 | + * @dev: class converted to a Scsi_host structure. | |
262 | + * @attr: device attribute, not used. | |
263 | + * @buf: on return contains text describing the state of the link. | |
264 | + * | |
265 | + * Notes: | |
266 | + * The switch statement has no default so zero will be returned. | |
267 | + * | |
268 | + * Returns: size of formatted string. | |
269 | + **/ | |
270 | static ssize_t | |
271 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, | |
272 | char *buf) | |
273 | @@ -232,8 +372,10 @@ lpfc_link_state_show(struct device *dev, | |
274 | "Unknown\n"); | |
275 | break; | |
276 | } | |
277 | - | |
278 | - if (phba->fc_topology == TOPOLOGY_LOOP) { | |
279 | + if (phba->sli.sli_flag & LPFC_MENLO_MAINT) | |
280 | + len += snprintf(buf + len, PAGE_SIZE-len, | |
281 | + " Menlo Maint Mode\n"); | |
282 | + else if (phba->fc_topology == TOPOLOGY_LOOP) { | |
283 | if (vport->fc_flag & FC_PUBLIC_LOOP) | |
284 | len += snprintf(buf + len, PAGE_SIZE-len, | |
285 | " Public Loop\n"); | |
286 | @@ -253,6 +395,18 @@ lpfc_link_state_show(struct device *dev, | |
287 | return len; | |
288 | } | |
289 | ||
290 | +/** | |
291 | + * lpfc_num_discovered_ports_show: Return sum of mapped and unmapped vports. | |
292 | + * @dev: class device that is converted into a Scsi_host. | |
293 | + * @attr: device attribute, not used. | |
294 | + * @buf: on return contains the sum of fc mapped and unmapped. | |
295 | + * | |
296 | + * Description: | |
297 | + * Returns the ascii text number of the sum of the fc mapped and unmapped | |
298 | + * vport counts. | |
299 | + * | |
300 | + * Returns: size of formatted string. | |
301 | + **/ | |
302 | static ssize_t | |
303 | lpfc_num_discovered_ports_show(struct device *dev, | |
304 | struct device_attribute *attr, char *buf) | |
305 | @@ -264,7 +418,20 @@ lpfc_num_discovered_ports_show(struct de | |
306 | vport->fc_map_cnt + vport->fc_unmap_cnt); | |
307 | } | |
308 | ||
309 | - | |
310 | +/** | |
311 | + * lpfc_issue_lip: Misnomer, name carried over from long ago. | |
312 | + * @shost: Scsi_Host pointer. | |
313 | + * | |
314 | + * Description: | |
315 | + * Bring the link down gracefully then re-init the link. The firmware will | |
316 | + * re-init the fiber channel interface as required. Does not issue a LIP. | |
317 | + * | |
318 | + * Returns: | |
319 | + * -EPERM port offline or management commands are being blocked | |
320 | + * -ENOMEM cannot allocate memory for the mailbox command | |
321 | + * -EIO error sending the mailbox command | |
322 | + * zero for success | |
323 | + **/ | |
324 | static int | |
325 | lpfc_issue_lip(struct Scsi_Host *shost) | |
326 | { | |
327 | @@ -306,6 +473,21 @@ lpfc_issue_lip(struct Scsi_Host *shost) | |
328 | return 0; | |
329 | } | |
330 | ||
331 | +/** | |
332 | + * lpfc_do_offline: Issues a mailbox command to bring the link down. | |
333 | + * @phba: lpfc_hba pointer. | |
334 | + * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. | |
335 | + * | |
336 | + * Notes: | |
337 | + * Assumes any error from lpfc_do_offline() will be negative. | |
338 | + * Can wait up to 5 seconds for the port ring buffers count | |
339 | + * to reach zero, prints a warning if it is not zero and continues. | |
340 | + * lpfc_workq_post_event() returns a non-zero return coce if call fails. | |
341 | + * | |
342 | + * Returns: | |
343 | + * -EIO error posting the event | |
344 | + * zero for success | |
345 | + **/ | |
346 | static int | |
347 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) | |
348 | { | |
349 | @@ -353,6 +535,22 @@ lpfc_do_offline(struct lpfc_hba *phba, u | |
350 | return 0; | |
351 | } | |
352 | ||
353 | +/** | |
354 | + * lpfc_selective_reset: Offline then onlines the port. | |
355 | + * @phba: lpfc_hba pointer. | |
356 | + * | |
357 | + * Description: | |
358 | + * If the port is configured to allow a reset then the hba is brought | |
359 | + * offline then online. | |
360 | + * | |
361 | + * Notes: | |
362 | + * Assumes any error from lpfc_do_offline() will be negative. | |
363 | + * | |
364 | + * Returns: | |
365 | + * lpfc_do_offline() return code if not zero | |
366 | + * -EIO reset not configured or error posting the event | |
367 | + * zero for success | |
368 | + **/ | |
369 | static int | |
370 | lpfc_selective_reset(struct lpfc_hba *phba) | |
371 | { | |
372 | @@ -378,6 +576,27 @@ lpfc_selective_reset(struct lpfc_hba *ph | |
373 | return 0; | |
374 | } | |
375 | ||
376 | +/** | |
377 | + * lpfc_issue_reset: Selectively resets an adapter. | |
378 | + * @dev: class device that is converted into a Scsi_host. | |
379 | + * @attr: device attribute, not used. | |
380 | + * @buf: containing the string "selective". | |
381 | + * @count: unused variable. | |
382 | + * | |
383 | + * Description: | |
384 | + * If the buf contains the string "selective" then lpfc_selective_reset() | |
385 | + * is called to perform the reset. | |
386 | + * | |
387 | + * Notes: | |
388 | + * Assumes any error from lpfc_selective_reset() will be negative. | |
389 | + * If lpfc_selective_reset() returns zero then the length of the buffer | |
390 | + * is returned which indicates succcess | |
391 | + * | |
392 | + * Returns: | |
393 | + * -EINVAL if the buffer does not contain the string "selective" | |
394 | + * length of buf if lpfc-selective_reset() if the call succeeds | |
395 | + * return value of lpfc_selective_reset() if the call fails | |
396 | +**/ | |
397 | static ssize_t | |
398 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, | |
399 | const char *buf, size_t count) | |
400 | @@ -397,6 +616,14 @@ lpfc_issue_reset(struct device *dev, str | |
401 | return status; | |
402 | } | |
403 | ||
404 | +/** | |
405 | + * lpfc_nport_evt_cnt_show: Return the number of nport events. | |
406 | + * @dev: class device that is converted into a Scsi_host. | |
407 | + * @attr: device attribute, not used. | |
408 | + * @buf: on return contains the ascii number of nport events. | |
409 | + * | |
410 | + * Returns: size of formatted string. | |
411 | + **/ | |
412 | static ssize_t | |
413 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, | |
414 | char *buf) | |
415 | @@ -408,6 +635,14 @@ lpfc_nport_evt_cnt_show(struct device *d | |
416 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); | |
417 | } | |
418 | ||
419 | +/** | |
420 | + * lpfc_board_mode_show: Return the state of the board. | |
421 | + * @dev: class device that is converted into a Scsi_host. | |
422 | + * @attr: device attribute, not used. | |
423 | + * @buf: on return contains the state of the adapter. | |
424 | + * | |
425 | + * Returns: size of formatted string. | |
426 | + **/ | |
427 | static ssize_t | |
428 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, | |
429 | char *buf) | |
430 | @@ -429,6 +664,19 @@ lpfc_board_mode_show(struct device *dev, | |
431 | return snprintf(buf, PAGE_SIZE, "%s\n", state); | |
432 | } | |
433 | ||
434 | +/** | |
435 | + * lpfc_board_mode_store: Puts the hba in online, offline, warm or error state. | |
436 | + * @dev: class device that is converted into a Scsi_host. | |
437 | + * @attr: device attribute, not used. | |
438 | + * @buf: containing one of the strings "online", "offline", "warm" or "error". | |
439 | + * @count: unused variable. | |
440 | + * | |
441 | + * Returns: | |
442 | + * -EACCES if enable hba reset not enabled | |
443 | + * -EINVAL if the buffer does not contain a valid string (see above) | |
444 | + * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails | |
445 | + * buf length greater than zero indicates success | |
446 | + **/ | |
447 | static ssize_t | |
448 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, | |
449 | const char *buf, size_t count) | |
450 | @@ -462,6 +710,24 @@ lpfc_board_mode_store(struct device *dev | |
451 | return -EIO; | |
452 | } | |
453 | ||
454 | +/** | |
455 | + * lpfc_get_hba_info: Return various bits of informaton about the adapter. | |
456 | + * @phba: pointer to the adapter structure. | |
457 | + * @mxri max xri count. | |
458 | + * @axri available xri count. | |
459 | + * @mrpi max rpi count. | |
460 | + * @arpi available rpi count. | |
461 | + * @mvpi max vpi count. | |
462 | + * @avpi available vpi count. | |
463 | + * | |
464 | + * Description: | |
465 | + * If an integer pointer for an count is not null then the value for the | |
466 | + * count is returned. | |
467 | + * | |
468 | + * Returns: | |
469 | + * zero on error | |
470 | + * one for success | |
471 | + **/ | |
472 | static int | |
473 | lpfc_get_hba_info(struct lpfc_hba *phba, | |
474 | uint32_t *mxri, uint32_t *axri, | |
475 | @@ -524,6 +790,20 @@ lpfc_get_hba_info(struct lpfc_hba *phba, | |
476 | return 1; | |
477 | } | |
478 | ||
479 | +/** | |
480 | + * lpfc_max_rpi_show: Return maximum rpi. | |
481 | + * @dev: class device that is converted into a Scsi_host. | |
482 | + * @attr: device attribute, not used. | |
483 | + * @buf: on return contains the maximum rpi count in decimal or "Unknown". | |
484 | + * | |
485 | + * Description: | |
486 | + * Calls lpfc_get_hba_info() asking for just the mrpi count. | |
487 | + * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
488 | + * to "Unknown" and the buffer length is returned, therefore the caller | |
489 | + * must check for "Unknown" in the buffer to detect a failure. | |
490 | + * | |
491 | + * Returns: size of formatted string. | |
492 | + **/ | |
493 | static ssize_t | |
494 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, | |
495 | char *buf) | |
496 | @@ -538,6 +818,20 @@ lpfc_max_rpi_show(struct device *dev, st | |
497 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
498 | } | |
499 | ||
500 | +/** | |
501 | + * lpfc_used_rpi_show: Return maximum rpi minus available rpi. | |
502 | + * @dev: class device that is converted into a Scsi_host. | |
503 | + * @attr: device attribute, not used. | |
504 | + * @buf: containing the used rpi count in decimal or "Unknown". | |
505 | + * | |
506 | + * Description: | |
507 | + * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. | |
508 | + * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
509 | + * to "Unknown" and the buffer length is returned, therefore the caller | |
510 | + * must check for "Unknown" in the buffer to detect a failure. | |
511 | + * | |
512 | + * Returns: size of formatted string. | |
513 | + **/ | |
514 | static ssize_t | |
515 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, | |
516 | char *buf) | |
517 | @@ -552,6 +846,20 @@ lpfc_used_rpi_show(struct device *dev, s | |
518 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
519 | } | |
520 | ||
521 | +/** | |
522 | + * lpfc_max_xri_show: Return maximum xri. | |
523 | + * @dev: class device that is converted into a Scsi_host. | |
524 | + * @attr: device attribute, not used. | |
525 | + * @buf: on return contains the maximum xri count in decimal or "Unknown". | |
526 | + * | |
527 | + * Description: | |
528 | + * Calls lpfc_get_hba_info() asking for just the mrpi count. | |
529 | + * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
530 | + * to "Unknown" and the buffer length is returned, therefore the caller | |
531 | + * must check for "Unknown" in the buffer to detect a failure. | |
532 | + * | |
533 | + * Returns: size of formatted string. | |
534 | + **/ | |
535 | static ssize_t | |
536 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, | |
537 | char *buf) | |
538 | @@ -566,6 +874,20 @@ lpfc_max_xri_show(struct device *dev, st | |
539 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
540 | } | |
541 | ||
542 | +/** | |
543 | + * lpfc_used_xri_show: Return maximum xpi minus the available xpi. | |
544 | + * @dev: class device that is converted into a Scsi_host. | |
545 | + * @attr: device attribute, not used. | |
546 | + * @buf: on return contains the used xri count in decimal or "Unknown". | |
547 | + * | |
548 | + * Description: | |
549 | + * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. | |
550 | + * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
551 | + * to "Unknown" and the buffer length is returned, therefore the caller | |
552 | + * must check for "Unknown" in the buffer to detect a failure. | |
553 | + * | |
554 | + * Returns: size of formatted string. | |
555 | + **/ | |
556 | static ssize_t | |
557 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, | |
558 | char *buf) | |
559 | @@ -580,6 +902,20 @@ lpfc_used_xri_show(struct device *dev, s | |
560 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
561 | } | |
562 | ||
563 | +/** | |
564 | + * lpfc_max_vpi_show: Return maximum vpi. | |
565 | + * @dev: class device that is converted into a Scsi_host. | |
566 | + * @attr: device attribute, not used. | |
567 | + * @buf: on return contains the maximum vpi count in decimal or "Unknown". | |
568 | + * | |
569 | + * Description: | |
570 | + * Calls lpfc_get_hba_info() asking for just the mvpi count. | |
571 | + * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
572 | + * to "Unknown" and the buffer length is returned, therefore the caller | |
573 | + * must check for "Unknown" in the buffer to detect a failure. | |
574 | + * | |
575 | + * Returns: size of formatted string. | |
576 | + **/ | |
577 | static ssize_t | |
578 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, | |
579 | char *buf) | |
580 | @@ -594,6 +930,20 @@ lpfc_max_vpi_show(struct device *dev, st | |
581 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
582 | } | |
583 | ||
584 | +/** | |
585 | + * lpfc_used_vpi_show: Return maximum vpi minus the available vpi. | |
586 | + * @dev: class device that is converted into a Scsi_host. | |
587 | + * @attr: device attribute, not used. | |
588 | + * @buf: on return contains the used vpi count in decimal or "Unknown". | |
589 | + * | |
590 | + * Description: | |
591 | + * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. | |
592 | + * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | |
593 | + * to "Unknown" and the buffer length is returned, therefore the caller | |
594 | + * must check for "Unknown" in the buffer to detect a failure. | |
595 | + * | |
596 | + * Returns: size of formatted string. | |
597 | + **/ | |
598 | static ssize_t | |
599 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, | |
600 | char *buf) | |
601 | @@ -608,6 +958,19 @@ lpfc_used_vpi_show(struct device *dev, s | |
602 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | |
603 | } | |
604 | ||
605 | +/** | |
606 | + * lpfc_npiv_info_show: Return text about NPIV support for the adapter. | |
607 | + * @dev: class device that is converted into a Scsi_host. | |
608 | + * @attr: device attribute, not used. | |
609 | + * @buf: text that must be interpreted to determine if npiv is supported. | |
610 | + * | |
611 | + * Description: | |
612 | + * Buffer will contain text indicating npiv is not suppoerted on the port, | |
613 | + * the port is an NPIV physical port, or it is an npiv virtual port with | |
614 | + * the id of the vport. | |
615 | + * | |
616 | + * Returns: size of formatted string. | |
617 | + **/ | |
618 | static ssize_t | |
619 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, | |
620 | char *buf) | |
621 | @@ -623,6 +986,17 @@ lpfc_npiv_info_show(struct device *dev, | |
622 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); | |
623 | } | |
624 | ||
625 | +/** | |
626 | + * lpfc_poll_show: Return text about poll support for the adapter. | |
627 | + * @dev: class device that is converted into a Scsi_host. | |
628 | + * @attr: device attribute, not used. | |
629 | + * @buf: on return contains the cfg_poll in hex. | |
630 | + * | |
631 | + * Notes: | |
632 | + * cfg_poll should be a lpfc_polling_flags type. | |
633 | + * | |
634 | + * Returns: size of formatted string. | |
635 | + **/ | |
636 | static ssize_t | |
637 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, | |
638 | char *buf) | |
639 | @@ -634,6 +1008,20 @@ lpfc_poll_show(struct device *dev, struc | |
640 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); | |
641 | } | |
642 | ||
643 | +/** | |
644 | + * lpfc_poll_store: Set the value of cfg_poll for the adapter. | |
645 | + * @dev: class device that is converted into a Scsi_host. | |
646 | + * @attr: device attribute, not used. | |
647 | + * @buf: one or more lpfc_polling_flags values. | |
648 | + * @count: not used. | |
649 | + * | |
650 | + * Notes: | |
651 | + * buf contents converted to integer and checked for a valid value. | |
652 | + * | |
653 | + * Returns: | |
654 | + * -EINVAL if the buffer connot be converted or is out of range | |
655 | + * length of the buf on success | |
656 | + **/ | |
657 | static ssize_t | |
658 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, | |
659 | const char *buf, size_t count) | |
660 | @@ -692,6 +1080,20 @@ lpfc_poll_store(struct device *dev, stru | |
661 | return strlen(buf); | |
662 | } | |
663 | ||
664 | +/** | |
665 | + * lpfc_param_show: Return a cfg attribute value in decimal. | |
666 | + * | |
667 | + * Description: | |
668 | + * Macro that given an attr e.g. hba_queue_depth expands | |
669 | + * into a function with the name lpfc_hba_queue_depth_show. | |
670 | + * | |
671 | + * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. | |
672 | + * @dev: class device that is converted into a Scsi_host. | |
673 | + * @attr: device attribute, not used. | |
674 | + * @buf: on return contains the attribute value in decimal. | |
675 | + * | |
676 | + * Returns: size of formatted string. | |
677 | + **/ | |
678 | #define lpfc_param_show(attr) \ | |
679 | static ssize_t \ | |
680 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |
681 | @@ -706,6 +1108,20 @@ lpfc_##attr##_show(struct device *dev, s | |
682 | phba->cfg_##attr);\ | |
683 | } | |
684 | ||
685 | +/** | |
686 | + * lpfc_param_hex_show: Return a cfg attribute value in hex. | |
687 | + * | |
688 | + * Description: | |
689 | + * Macro that given an attr e.g. hba_queue_depth expands | |
690 | + * into a function with the name lpfc_hba_queue_depth_show | |
691 | + * | |
692 | + * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. | |
693 | + * @dev: class device that is converted into a Scsi_host. | |
694 | + * @attr: device attribute, not used. | |
695 | + * @buf: on return contains the attribute value in hexidecimal. | |
696 | + * | |
697 | + * Returns: size of formatted string. | |
698 | + **/ | |
699 | #define lpfc_param_hex_show(attr) \ | |
700 | static ssize_t \ | |
701 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |
702 | @@ -720,6 +1136,25 @@ lpfc_##attr##_show(struct device *dev, s | |
703 | phba->cfg_##attr);\ | |
704 | } | |
705 | ||
706 | +/** | |
707 | + * lpfc_param_init: Intializes a cfg attribute. | |
708 | + * | |
709 | + * Description: | |
710 | + * Macro that given an attr e.g. hba_queue_depth expands | |
711 | + * into a function with the name lpfc_hba_queue_depth_init. The macro also | |
712 | + * takes a default argument, a minimum and maximum argument. | |
713 | + * | |
714 | + * lpfc_##attr##_init: Initializes an attribute. | |
715 | + * @phba: pointer the the adapter structure. | |
716 | + * @val: integer attribute value. | |
717 | + * | |
718 | + * Validates the min and max values then sets the adapter config field | |
719 | + * accordingly, or uses the default if out of range and prints an error message. | |
720 | + * | |
721 | + * Returns: | |
722 | + * zero on success | |
723 | + * -EINVAL if default used | |
724 | + **/ | |
725 | #define lpfc_param_init(attr, default, minval, maxval) \ | |
726 | static int \ | |
727 | lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ | |
728 | @@ -735,6 +1170,26 @@ lpfc_##attr##_init(struct lpfc_hba *phba | |
729 | return -EINVAL;\ | |
730 | } | |
731 | ||
732 | +/** | |
733 | + * lpfc_param_set: Set a cfg attribute value. | |
734 | + * | |
735 | + * Description: | |
736 | + * Macro that given an attr e.g. hba_queue_depth expands | |
737 | + * into a function with the name lpfc_hba_queue_depth_set | |
738 | + * | |
739 | + * lpfc_##attr##_set: Sets an attribute value. | |
740 | + * @phba: pointer the the adapter structure. | |
741 | + * @val: integer attribute value. | |
742 | + * | |
743 | + * Description: | |
744 | + * Validates the min and max values then sets the | |
745 | + * adapter config field if in the valid range. prints error message | |
746 | + * and does not set the parameter if invalid. | |
747 | + * | |
748 | + * Returns: | |
749 | + * zero on success | |
750 | + * -EINVAL if val is invalid | |
751 | + **/ | |
752 | #define lpfc_param_set(attr, default, minval, maxval) \ | |
753 | static int \ | |
754 | lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ | |
755 | @@ -749,6 +1204,27 @@ lpfc_##attr##_set(struct lpfc_hba *phba, | |
756 | return -EINVAL;\ | |
757 | } | |
758 | ||
759 | +/** | |
760 | + * lpfc_param_store: Set a vport attribute value. | |
761 | + * | |
762 | + * Description: | |
763 | + * Macro that given an attr e.g. hba_queue_depth expands | |
764 | + * into a function with the name lpfc_hba_queue_depth_store. | |
765 | + * | |
766 | + * lpfc_##attr##_store: Set an sttribute value. | |
767 | + * @dev: class device that is converted into a Scsi_host. | |
768 | + * @attr: device attribute, not used. | |
769 | + * @buf: contains the attribute value in ascii. | |
770 | + * @count: not used. | |
771 | + * | |
772 | + * Description: | |
773 | + * Convert the ascii text number to an integer, then | |
774 | + * use the lpfc_##attr##_set function to set the value. | |
775 | + * | |
776 | + * Returns: | |
777 | + * -EINVAL if val is invalid or lpfc_##attr##_set() fails | |
778 | + * length of buffer upon success. | |
779 | + **/ | |
780 | #define lpfc_param_store(attr) \ | |
781 | static ssize_t \ | |
782 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ | |
783 | @@ -768,6 +1244,20 @@ lpfc_##attr##_store(struct device *dev, | |
784 | return -EINVAL;\ | |
785 | } | |
786 | ||
787 | +/** | |
788 | + * lpfc_vport_param_show: Return decimal formatted cfg attribute value. | |
789 | + * | |
790 | + * Description: | |
791 | + * Macro that given an attr e.g. hba_queue_depth expands | |
792 | + * into a function with the name lpfc_hba_queue_depth_show | |
793 | + * | |
794 | + * lpfc_##attr##_show: prints the attribute value in decimal. | |
795 | + * @dev: class device that is converted into a Scsi_host. | |
796 | + * @attr: device attribute, not used. | |
797 | + * @buf: on return contains the attribute value in decimal. | |
798 | + * | |
799 | + * Returns: length of formatted string. | |
800 | + **/ | |
801 | #define lpfc_vport_param_show(attr) \ | |
802 | static ssize_t \ | |
803 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |
804 | @@ -780,6 +1270,21 @@ lpfc_##attr##_show(struct device *dev, s | |
805 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ | |
806 | } | |
807 | ||
808 | +/** | |
809 | + * lpfc_vport_param_hex_show: Return hex formatted attribute value. | |
810 | + * | |
811 | + * Description: | |
812 | + * Macro that given an attr e.g. | |
813 | + * hba_queue_depth expands into a function with the name | |
814 | + * lpfc_hba_queue_depth_show | |
815 | + * | |
816 | + * lpfc_##attr##_show: prints the attribute value in hexidecimal. | |
817 | + * @dev: class device that is converted into a Scsi_host. | |
818 | + * @attr: device attribute, not used. | |
819 | + * @buf: on return contains the attribute value in hexidecimal. | |
820 | + * | |
821 | + * Returns: length of formatted string. | |
822 | + **/ | |
823 | #define lpfc_vport_param_hex_show(attr) \ | |
824 | static ssize_t \ | |
825 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |
826 | @@ -792,6 +1297,24 @@ lpfc_##attr##_show(struct device *dev, s | |
827 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ | |
828 | } | |
829 | ||
830 | +/** | |
831 | + * lpfc_vport_param_init: Initialize a vport cfg attribute. | |
832 | + * | |
833 | + * Description: | |
834 | + * Macro that given an attr e.g. hba_queue_depth expands | |
835 | + * into a function with the name lpfc_hba_queue_depth_init. The macro also | |
836 | + * takes a default argument, a minimum and maximum argument. | |
837 | + * | |
838 | + * lpfc_##attr##_init: validates the min and max values then sets the | |
839 | + * adapter config field accordingly, or uses the default if out of range | |
840 | + * and prints an error message. | |
841 | + * @phba: pointer the the adapter structure. | |
842 | + * @val: integer attribute value. | |
843 | + * | |
844 | + * Returns: | |
845 | + * zero on success | |
846 | + * -EINVAL if default used | |
847 | + **/ | |
848 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ | |
849 | static int \ | |
850 | lpfc_##attr##_init(struct lpfc_vport *vport, int val) \ | |
851 | @@ -801,12 +1324,29 @@ lpfc_##attr##_init(struct lpfc_vport *vp | |
852 | return 0;\ | |
853 | }\ | |
854 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ | |
855 | - "0449 lpfc_"#attr" attribute cannot be set to %d, "\ | |
856 | + "0423 lpfc_"#attr" attribute cannot be set to %d, "\ | |
857 | "allowed range is ["#minval", "#maxval"]\n", val); \ | |
858 | vport->cfg_##attr = default;\ | |
859 | return -EINVAL;\ | |
860 | } | |
861 | ||
862 | +/** | |
863 | + * lpfc_vport_param_set: Set a vport cfg attribute. | |
864 | + * | |
865 | + * Description: | |
866 | + * Macro that given an attr e.g. hba_queue_depth expands | |
867 | + * into a function with the name lpfc_hba_queue_depth_set | |
868 | + * | |
869 | + * lpfc_##attr##_set: validates the min and max values then sets the | |
870 | + * adapter config field if in the valid range. prints error message | |
871 | + * and does not set the parameter if invalid. | |
872 | + * @phba: pointer the the adapter structure. | |
873 | + * @val: integer attribute value. | |
874 | + * | |
875 | + * Returns: | |
876 | + * zero on success | |
877 | + * -EINVAL if val is invalid | |
878 | + **/ | |
879 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ | |
880 | static int \ | |
881 | lpfc_##attr##_set(struct lpfc_vport *vport, int val) \ | |
882 | @@ -816,11 +1356,28 @@ lpfc_##attr##_set(struct lpfc_vport *vpo | |
883 | return 0;\ | |
884 | }\ | |
885 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ | |
886 | - "0450 lpfc_"#attr" attribute cannot be set to %d, "\ | |
887 | + "0424 lpfc_"#attr" attribute cannot be set to %d, "\ | |
888 | "allowed range is ["#minval", "#maxval"]\n", val); \ | |
889 | return -EINVAL;\ | |
890 | } | |
891 | ||
892 | +/** | |
893 | + * lpfc_vport_param_store: Set a vport attribute. | |
894 | + * | |
895 | + * Description: | |
896 | + * Macro that given an attr e.g. hba_queue_depth | |
897 | + * expands into a function with the name lpfc_hba_queue_depth_store | |
898 | + * | |
899 | + * lpfc_##attr##_store: convert the ascii text number to an integer, then | |
900 | + * use the lpfc_##attr##_set function to set the value. | |
901 | + * @cdev: class device that is converted into a Scsi_host. | |
902 | + * @buf: contains the attribute value in decimal. | |
903 | + * @count: not used. | |
904 | + * | |
905 | + * Returns: | |
906 | + * -EINVAL if val is invalid or lpfc_##attr##_set() fails | |
907 | + * length of buffer upon success. | |
908 | + **/ | |
909 | #define lpfc_vport_param_store(attr) \ | |
910 | static ssize_t \ | |
911 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ | |
912 | @@ -941,6 +1498,7 @@ static DEVICE_ATTR(option_rom_version, S | |
913 | lpfc_option_rom_version_show, NULL); | |
914 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, | |
915 | lpfc_num_discovered_ports_show, NULL); | |
916 | +static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); | |
917 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); | |
918 | static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); | |
919 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, | |
920 | @@ -958,6 +1516,17 @@ static DEVICE_ATTR(lpfc_temp_sensor, S_I | |
921 | ||
922 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; | |
923 | ||
924 | +/** | |
925 | + * lpfc_soft_wwn_enable_store: Allows setting of the wwn if the key is valid. | |
926 | + * @dev: class device that is converted into a Scsi_host. | |
927 | + * @attr: device attribute, not used. | |
928 | + * @buf: containing the string lpfc_soft_wwn_key. | |
929 | + * @count: must be size of lpfc_soft_wwn_key. | |
930 | + * | |
931 | + * Returns: | |
932 | + * -EINVAL if the buffer does not contain lpfc_soft_wwn_key | |
933 | + * length of buf indicates success | |
934 | + **/ | |
935 | static ssize_t | |
936 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, | |
937 | const char *buf, size_t count) | |
938 | @@ -994,6 +1563,14 @@ lpfc_soft_wwn_enable_store(struct device | |
939 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, | |
940 | lpfc_soft_wwn_enable_store); | |
941 | ||
942 | +/** | |
943 | + * lpfc_soft_wwpn_show: Return the cfg soft ww port name of the adapter. | |
944 | + * @dev: class device that is converted into a Scsi_host. | |
945 | + * @attr: device attribute, not used. | |
946 | + * @buf: on return contains the wwpn in hexidecimal. | |
947 | + * | |
948 | + * Returns: size of formatted string. | |
949 | + **/ | |
950 | static ssize_t | |
951 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, | |
952 | char *buf) | |
953 | @@ -1006,7 +1583,19 @@ lpfc_soft_wwpn_show(struct device *dev, | |
954 | (unsigned long long)phba->cfg_soft_wwpn); | |
955 | } | |
956 | ||
957 | - | |
958 | +/** | |
959 | + * lpfc_soft_wwpn_store: Set the ww port name of the adapter. | |
960 | + * @dev class device that is converted into a Scsi_host. | |
961 | + * @attr: device attribute, not used. | |
962 | + * @buf: contains the wwpn in hexidecimal. | |
963 | + * @count: number of wwpn bytes in buf | |
964 | + * | |
965 | + * Returns: | |
966 | + * -EACCES hba reset not enabled, adapter over temp | |
967 | + * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid | |
968 | + * -EIO error taking adapter offline or online | |
969 | + * value of count on success | |
970 | + **/ | |
971 | static ssize_t | |
972 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, | |
973 | const char *buf, size_t count) | |
974 | @@ -1080,6 +1669,14 @@ lpfc_soft_wwpn_store(struct device *dev, | |
975 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ | |
976 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); | |
977 | ||
978 | +/** | |
979 | + * lpfc_soft_wwnn_show: Return the cfg soft ww node name for the adapter. | |
980 | + * @dev: class device that is converted into a Scsi_host. | |
981 | + * @attr: device attribute, not used. | |
982 | + * @buf: on return contains the wwnn in hexidecimal. | |
983 | + * | |
984 | + * Returns: size of formatted string. | |
985 | + **/ | |
986 | static ssize_t | |
987 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, | |
988 | char *buf) | |
989 | @@ -1090,7 +1687,16 @@ lpfc_soft_wwnn_show(struct device *dev, | |
990 | (unsigned long long)phba->cfg_soft_wwnn); | |
991 | } | |
992 | ||
993 | - | |
994 | +/** | |
995 | + * lpfc_soft_wwnn_store: sets the ww node name of the adapter. | |
996 | + * @cdev: class device that is converted into a Scsi_host. | |
997 | + * @buf: contains the ww node name in hexidecimal. | |
998 | + * @count: number of wwnn bytes in buf. | |
999 | + * | |
1000 | + * Returns: | |
1001 | + * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid | |
1002 | + * value of count on success | |
1003 | + **/ | |
1004 | static ssize_t | |
1005 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, | |
1006 | const char *buf, size_t count) | |
1007 | @@ -1178,6 +1784,15 @@ module_param(lpfc_nodev_tmo, int, 0); | |
1008 | MODULE_PARM_DESC(lpfc_nodev_tmo, | |
1009 | "Seconds driver will hold I/O waiting " | |
1010 | "for a device to come back"); | |
1011 | + | |
1012 | +/** | |
1013 | + * lpfc_nodev_tmo_show: Return the hba dev loss timeout value. | |
1014 | + * @dev: class converted to a Scsi_host structure. | |
1015 | + * @attr: device attribute, not used. | |
1016 | + * @buf: on return contains the dev loss timeout in decimal. | |
1017 | + * | |
1018 | + * Returns: size of formatted string. | |
1019 | + **/ | |
1020 | static ssize_t | |
1021 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, | |
1022 | char *buf) | |
1023 | @@ -1189,6 +1804,21 @@ lpfc_nodev_tmo_show(struct device *dev, | |
1024 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); | |
1025 | } | |
1026 | ||
1027 | +/** | |
1028 | + * lpfc_nodev_tmo_init: Set the hba nodev timeout value. | |
1029 | + * @vport: lpfc vport structure pointer. | |
1030 | + * @val: contains the nodev timeout value. | |
1031 | + * | |
1032 | + * Description: | |
1033 | + * If the devloss tmo is already set then nodev tmo is set to devloss tmo, | |
1034 | + * a kernel error message is printed and zero is returned. | |
1035 | + * Else if val is in range then nodev tmo and devloss tmo are set to val. | |
1036 | + * Otherwise nodev tmo is set to the default value. | |
1037 | + * | |
1038 | + * Returns: | |
1039 | + * zero if already set or if val is in range | |
1040 | + * -EINVAL val out of range | |
1041 | + **/ | |
1042 | static int | |
1043 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) | |
1044 | { | |
1045 | @@ -1196,7 +1826,7 @@ lpfc_nodev_tmo_init(struct lpfc_vport *v | |
1046 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; | |
1047 | if (val != LPFC_DEF_DEVLOSS_TMO) | |
1048 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
1049 | - "0402 Ignoring nodev_tmo module " | |
1050 | + "0407 Ignoring nodev_tmo module " | |
1051 | "parameter because devloss_tmo is " | |
1052 | "set.\n"); | |
1053 | return 0; | |
1054 | @@ -1215,6 +1845,13 @@ lpfc_nodev_tmo_init(struct lpfc_vport *v | |
1055 | return -EINVAL; | |
1056 | } | |
1057 | ||
1058 | +/** | |
1059 | + * lpfc_update_rport_devloss_tmo: Update dev loss tmo value. | |
1060 | + * @vport: lpfc vport structure pointer. | |
1061 | + * | |
1062 | + * Description: | |
1063 | + * Update all the ndlp's dev loss tmo with the vport devloss tmo value. | |
1064 | + **/ | |
1065 | static void | |
1066 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) | |
1067 | { | |
1068 | @@ -1229,6 +1866,21 @@ lpfc_update_rport_devloss_tmo(struct lpf | |
1069 | spin_unlock_irq(shost->host_lock); | |
1070 | } | |
1071 | ||
1072 | +/** | |
1073 | + * lpfc_nodev_tmo_set: Set the vport nodev tmo and devloss tmo values. | |
1074 | + * @vport: lpfc vport structure pointer. | |
1075 | + * @val: contains the tmo value. | |
1076 | + * | |
1077 | + * Description: | |
1078 | + * If the devloss tmo is already set or the vport dev loss tmo has changed | |
1079 | + * then a kernel error message is printed and zero is returned. | |
1080 | + * Else if val is in range then nodev tmo and devloss tmo are set to val. | |
1081 | + * Otherwise nodev tmo is set to the default value. | |
1082 | + * | |
1083 | + * Returns: | |
1084 | + * zero if already set or if val is in range | |
1085 | + * -EINVAL val out of range | |
1086 | + **/ | |
1087 | static int | |
1088 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) | |
1089 | { | |
1090 | @@ -1269,6 +1921,21 @@ MODULE_PARM_DESC(lpfc_devloss_tmo, | |
1091 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, | |
1092 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) | |
1093 | lpfc_vport_param_show(devloss_tmo) | |
1094 | + | |
1095 | +/** | |
1096 | + * lpfc_devloss_tmo_set: Sets vport nodev tmo, devloss tmo values, changed bit. | |
1097 | + * @vport: lpfc vport structure pointer. | |
1098 | + * @val: contains the tmo value. | |
1099 | + * | |
1100 | + * Description: | |
1101 | + * If val is in a valid range then set the vport nodev tmo, | |
1102 | + * devloss tmo, also set the vport dev loss tmo changed flag. | |
1103 | + * Else a kernel error message is printed. | |
1104 | + * | |
1105 | + * Returns: | |
1106 | + * zero if val is in range | |
1107 | + * -EINVAL val out of range | |
1108 | + **/ | |
1109 | static int | |
1110 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) | |
1111 | { | |
1112 | @@ -1366,12 +2033,27 @@ MODULE_PARM_DESC(lpfc_restrict_login, | |
1113 | "Restrict virtual ports login to remote initiators."); | |
1114 | lpfc_vport_param_show(restrict_login); | |
1115 | ||
1116 | +/** | |
1117 | + * lpfc_restrict_login_init: Set the vport restrict login flag. | |
1118 | + * @vport: lpfc vport structure pointer. | |
1119 | + * @val: contains the restrict login value. | |
1120 | + * | |
1121 | + * Description: | |
1122 | + * If val is not in a valid range then log a kernel error message and set | |
1123 | + * the vport restrict login to one. | |
1124 | + * If the port type is physical clear the restrict login flag and return. | |
1125 | + * Else set the restrict login flag to val. | |
1126 | + * | |
1127 | + * Returns: | |
1128 | + * zero if val is in range | |
1129 | + * -EINVAL val out of range | |
1130 | + **/ | |
1131 | static int | |
1132 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) | |
1133 | { | |
1134 | if (val < 0 || val > 1) { | |
1135 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
1136 | - "0449 lpfc_restrict_login attribute cannot " | |
1137 | + "0422 lpfc_restrict_login attribute cannot " | |
1138 | "be set to %d, allowed range is [0, 1]\n", | |
1139 | val); | |
1140 | vport->cfg_restrict_login = 1; | |
1141 | @@ -1385,12 +2067,28 @@ lpfc_restrict_login_init(struct lpfc_vpo | |
1142 | return 0; | |
1143 | } | |
1144 | ||
1145 | +/** | |
1146 | + * lpfc_restrict_login_set: Set the vport restrict login flag. | |
1147 | + * @vport: lpfc vport structure pointer. | |
1148 | + * @val: contains the restrict login value. | |
1149 | + * | |
1150 | + * Description: | |
1151 | + * If val is not in a valid range then log a kernel error message and set | |
1152 | + * the vport restrict login to one. | |
1153 | + * If the port type is physical and the val is not zero log a kernel | |
1154 | + * error message, clear the restrict login flag and return zero. | |
1155 | + * Else set the restrict login flag to val. | |
1156 | + * | |
1157 | + * Returns: | |
1158 | + * zero if val is in range | |
1159 | + * -EINVAL val out of range | |
1160 | + **/ | |
1161 | static int | |
1162 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) | |
1163 | { | |
1164 | if (val < 0 || val > 1) { | |
1165 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
1166 | - "0450 lpfc_restrict_login attribute cannot " | |
1167 | + "0425 lpfc_restrict_login attribute cannot " | |
1168 | "be set to %d, allowed range is [0, 1]\n", | |
1169 | val); | |
1170 | vport->cfg_restrict_login = 1; | |
1171 | @@ -1441,6 +2139,23 @@ LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, | |
1172 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. | |
1173 | # Default value is 0. | |
1174 | */ | |
1175 | + | |
1176 | +/** | |
1177 | + * lpfc_topology_set: Set the adapters topology field. | |
1178 | + * @phba: lpfc_hba pointer. | |
1179 | + * @val: topology value. | |
1180 | + * | |
1181 | + * Description: | |
1182 | + * If val is in a valid range then set the adapter's topology field and | |
1183 | + * issue a lip; if the lip fails reset the topology to the old value. | |
1184 | + * | |
1185 | + * If the value is not in range log a kernel error message and return an error. | |
1186 | + * | |
1187 | + * Returns: | |
1188 | + * zero if val is in range and lip okay | |
1189 | + * non-zero return value from lpfc_issue_lip() | |
1190 | + * -EINVAL val out of range | |
1191 | + **/ | |
1192 | static int | |
1193 | lpfc_topology_set(struct lpfc_hba *phba, int val) | |
1194 | { | |
1195 | @@ -1469,6 +2184,335 @@ lpfc_param_store(topology) | |
1196 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, | |
1197 | lpfc_topology_show, lpfc_topology_store); | |
1198 | ||
1199 | + | |
1200 | +/** | |
1201 | + * lpfc_stat_data_ctrl_store: write call back for lpfc_stat_data_ctrl | |
1202 | + * sysfs file. | |
1203 | + * @dev: Pointer to class device. | |
1204 | + * @buf: Data buffer. | |
1205 | + * @count: Size of the data buffer. | |
1206 | + * | |
1207 | + * This function get called when an user write to the lpfc_stat_data_ctrl | |
1208 | + * sysfs file. This function parse the command written to the sysfs file | |
1209 | + * and take appropriate action. These commands are used for controlling | |
1210 | + * driver statistical data collection. | |
1211 | + * Following are the command this function handles. | |
1212 | + * | |
1213 | + * setbucket <bucket_type> <base> <step> | |
1214 | + * = Set the latency buckets. | |
1215 | + * destroybucket = destroy all the buckets. | |
1216 | + * start = start data collection | |
1217 | + * stop = stop data collection | |
1218 | + * reset = reset the collected data | |
1219 | + **/ | |
1220 | +static ssize_t | |
1221 | +lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, | |
1222 | + const char *buf, size_t count) | |
1223 | +{ | |
1224 | + struct Scsi_Host *shost = class_to_shost(dev); | |
1225 | + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
1226 | + struct lpfc_hba *phba = vport->phba; | |
1227 | +#define LPFC_MAX_DATA_CTRL_LEN 1024 | |
1228 | + static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; | |
1229 | + unsigned long i; | |
1230 | + char *str_ptr, *token; | |
1231 | + struct lpfc_vport **vports; | |
1232 | + struct Scsi_Host *v_shost; | |
1233 | + char *bucket_type_str, *base_str, *step_str; | |
1234 | + unsigned long base, step, bucket_type; | |
1235 | + | |
1236 | + if (!strncmp(buf, "setbucket", strlen("setbucket"))) { | |
1237 | + if (strlen(buf) > LPFC_MAX_DATA_CTRL_LEN) | |
1238 | + return -EINVAL; | |
1239 | + | |
1240 | + strcpy(bucket_data, buf); | |
1241 | + str_ptr = &bucket_data[0]; | |
1242 | + /* Ignore this token - this is command token */ | |
1243 | + token = strsep(&str_ptr, "\t "); | |
1244 | + if (!token) | |
1245 | + return -EINVAL; | |
1246 | + | |
1247 | + bucket_type_str = strsep(&str_ptr, "\t "); | |
1248 | + if (!bucket_type_str) | |
1249 | + return -EINVAL; | |
1250 | + | |
1251 | + if (!strncmp(bucket_type_str, "linear", strlen("linear"))) | |
1252 | + bucket_type = LPFC_LINEAR_BUCKET; | |
1253 | + else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) | |
1254 | + bucket_type = LPFC_POWER2_BUCKET; | |
1255 | + else | |
1256 | + return -EINVAL; | |
1257 | + | |
1258 | + base_str = strsep(&str_ptr, "\t "); | |
1259 | + if (!base_str) | |
1260 | + return -EINVAL; | |
1261 | + base = simple_strtoul(base_str, NULL, 0); | |
1262 | + | |
1263 | + step_str = strsep(&str_ptr, "\t "); | |
1264 | + if (!step_str) | |
1265 | + return -EINVAL; | |
1266 | + step = simple_strtoul(step_str, NULL, 0); | |
1267 | + if (!step) | |
1268 | + return -EINVAL; | |
1269 | + | |
1270 | + /* Block the data collection for every vport */ | |
1271 | + vports = lpfc_create_vport_work_array(phba); | |
1272 | + if (vports == NULL) | |
1273 | + return -ENOMEM; | |
1274 | + | |
1275 | + for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { | |
1276 | + v_shost = lpfc_shost_from_vport(vports[i]); | |
1277 | + spin_lock_irq(v_shost->host_lock); | |
1278 | + /* Block and reset data collection */ | |
1279 | + vports[i]->stat_data_blocked = 1; | |
1280 | + if (vports[i]->stat_data_enabled) | |
1281 | + lpfc_vport_reset_stat_data(vports[i]); | |
1282 | + spin_unlock_irq(v_shost->host_lock); | |
1283 | + } | |
1284 | + | |
1285 | + /* Set the bucket attributes */ | |
1286 | + phba->bucket_type = bucket_type; | |
1287 | + phba->bucket_base = base; | |
1288 | + phba->bucket_step = step; | |
1289 | + | |
1290 | + for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { | |
1291 | + v_shost = lpfc_shost_from_vport(vports[i]); | |
1292 | + | |
1293 | + /* Unblock data collection */ | |
1294 | + spin_lock_irq(v_shost->host_lock); | |
1295 | + vports[i]->stat_data_blocked = 0; | |
1296 | + spin_unlock_irq(v_shost->host_lock); | |
1297 | + } | |
1298 | + lpfc_destroy_vport_work_array(phba, vports); | |
1299 | + return strlen(buf); | |
1300 | + } | |
1301 | + | |
1302 | + if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { | |
1303 | + vports = lpfc_create_vport_work_array(phba); | |
1304 | + if (vports == NULL) | |
1305 | + return -ENOMEM; | |
1306 | + | |
1307 | + for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { | |
1308 | + v_shost = lpfc_shost_from_vport(vports[i]); | |
1309 | + spin_lock_irq(shost->host_lock); | |
1310 | + vports[i]->stat_data_blocked = 1; | |
1311 | + lpfc_free_bucket(vport); | |
1312 | + vport->stat_data_enabled = 0; | |
1313 | + vports[i]->stat_data_blocked = 0; | |
1314 | + spin_unlock_irq(shost->host_lock); | |
1315 | + } | |
1316 | + lpfc_destroy_vport_work_array(phba, vports); | |
1317 | + phba->bucket_type = LPFC_NO_BUCKET; | |
1318 | + phba->bucket_base = 0; | |
1319 | + phba->bucket_step = 0; | |
1320 | + return strlen(buf); | |
1321 | + } | |
1322 | + | |
1323 | + if (!strncmp(buf, "start", strlen("start"))) { | |
1324 | + /* If no buckets configured return error */ | |
1325 | + if (phba->bucket_type == LPFC_NO_BUCKET) | |
1326 | + return -EINVAL; | |
1327 | + spin_lock_irq(shost->host_lock); | |
1328 | + if (vport->stat_data_enabled) { | |
1329 | + spin_unlock_irq(shost->host_lock); | |
1330 | + return strlen(buf); | |
1331 | + } | |
1332 | + lpfc_alloc_bucket(vport); | |
1333 | + vport->stat_data_enabled = 1; | |
1334 | + spin_unlock_irq(shost->host_lock); | |
1335 | + return strlen(buf); | |
1336 | + } | |
1337 | + | |
1338 | + if (!strncmp(buf, "stop", strlen("stop"))) { | |
1339 | + spin_lock_irq(shost->host_lock); | |
1340 | + if (vport->stat_data_enabled == 0) { | |
1341 | + spin_unlock_irq(shost->host_lock); | |
1342 | + return strlen(buf); | |
1343 | + } | |
1344 | + lpfc_free_bucket(vport); | |
1345 | + vport->stat_data_enabled = 0; | |
1346 | + spin_unlock_irq(shost->host_lock); | |
1347 | + return strlen(buf); | |
1348 | + } | |
1349 | + | |
1350 | + if (!strncmp(buf, "reset", strlen("reset"))) { | |
1351 | + if ((phba->bucket_type == LPFC_NO_BUCKET) | |
1352 | + || !vport->stat_data_enabled) | |
1353 | + return strlen(buf); | |
1354 | + spin_lock_irq(shost->host_lock); | |
1355 | + vport->stat_data_blocked = 1; | |
1356 | + lpfc_vport_reset_stat_data(vport); | |
1357 | + vport->stat_data_blocked = 0; | |
1358 | + spin_unlock_irq(shost->host_lock); | |
1359 | + return strlen(buf); | |
1360 | + } | |
1361 | + return -EINVAL; | |
1362 | +} | |
1363 | + | |
1364 | + | |
1365 | +/** | |
1366 | + * lpfc_stat_data_ctrl_show: Read callback function for | |
1367 | + * lpfc_stat_data_ctrl sysfs file. | |
1368 | + * @dev: Pointer to class device object. | |
1369 | + * @buf: Data buffer. | |
1370 | + * | |
1371 | + * This function is the read call back function for | |
1372 | + * lpfc_stat_data_ctrl sysfs file. This function report the | |
1373 | + * current statistical data collection state. | |
1374 | + **/ | |
1375 | +static ssize_t | |
1376 | +lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, | |
1377 | + char *buf) | |
1378 | +{ | |
1379 | + struct Scsi_Host *shost = class_to_shost(dev); | |
1380 | + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
1381 | + struct lpfc_hba *phba = vport->phba; | |
1382 | + int index = 0; | |
1383 | + int i; | |
1384 | + char *bucket_type; | |
1385 | + unsigned long bucket_value; | |
1386 | + | |
1387 | + switch (phba->bucket_type) { | |
1388 | + case LPFC_LINEAR_BUCKET: | |
1389 | + bucket_type = "linear"; | |
1390 | + break; | |
1391 | + case LPFC_POWER2_BUCKET: | |
1392 | + bucket_type = "power2"; | |
1393 | + break; | |
1394 | + default: | |
1395 | + bucket_type = "No Bucket"; | |
1396 | + break; | |
1397 | + } | |
1398 | + | |
1399 | + sprintf(&buf[index], "Statistical Data enabled :%d, " | |
1400 | + "blocked :%d, Bucket type :%s, Bucket base :%d," | |
1401 | + " Bucket step :%d\nLatency Ranges :", | |
1402 | + vport->stat_data_enabled, vport->stat_data_blocked, | |
1403 | + bucket_type, phba->bucket_base, phba->bucket_step); | |
1404 | + index = strlen(buf); | |
1405 | + if (phba->bucket_type != LPFC_NO_BUCKET) { | |
1406 | + for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { | |
1407 | + if (phba->bucket_type == LPFC_LINEAR_BUCKET) | |
1408 | + bucket_value = phba->bucket_base + | |
1409 | + phba->bucket_step * i; | |
1410 | + else | |
1411 | + bucket_value = phba->bucket_base + | |
1412 | + (1 << i) * phba->bucket_step; | |
1413 | + | |
1414 | + if (index + 10 > PAGE_SIZE) | |
1415 | + break; | |
1416 | + sprintf(&buf[index], "%08ld ", bucket_value); | |
1417 | + index = strlen(buf); | |
1418 | + } | |
1419 | + } | |
1420 | + sprintf(&buf[index], "\n"); | |
1421 | + return strlen(buf); | |
1422 | +} | |
1423 | + | |
1424 | +/* | |
1425 | + * Sysfs attribute to control the statistical data collection. | |
1426 | + */ | |
1427 | +static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, | |
1428 | + lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); | |
1429 | + | |
1430 | +/* | |
1431 | + * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. | |
1432 | + */ | |
1433 | + | |
1434 | +/* | |
1435 | + * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN | |
1436 | + * for each target. | |
1437 | + */ | |
1438 | +#define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) | |
1439 | +#define MAX_STAT_DATA_SIZE_PER_TARGET \ | |
1440 | + STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) | |
1441 | + | |
1442 | + | |
1443 | +/** | |
1444 | + * sysfs_drvr_stat_data_read: Read callback function for lpfc_drvr_stat_data | |
1445 | + * sysfs attribute. | |
1446 | + * @kobj: Pointer to the kernel object | |
1447 | + * @bin_attr: Attribute object | |
1448 | + * @buff: Buffer pointer | |
1449 | + * @off: File offset | |
1450 | + * @count: Buffer size | |
1451 | + * | |
1452 | + * This function is the read call back function for lpfc_drvr_stat_data | |
1453 | + * sysfs file. This function export the statistical data to user | |
1454 | + * applications. | |
1455 | + **/ | |
1456 | +static ssize_t | |
1457 | +sysfs_drvr_stat_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, | |
1458 | + char *buf, loff_t off, size_t count) | |
1459 | +{ | |
1460 | + struct device *dev = container_of(kobj, struct device, | |
1461 | + kobj); | |
1462 | + struct Scsi_Host *shost = class_to_shost(dev); | |
1463 | + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
1464 | + struct lpfc_hba *phba = vport->phba; | |
1465 | + int i = 0, index = 0; | |
1466 | + unsigned long nport_index; | |
1467 | + struct lpfc_nodelist *ndlp = NULL; | |
1468 | + nport_index = (unsigned long)off / | |
1469 | + MAX_STAT_DATA_SIZE_PER_TARGET; | |
1470 | + | |
1471 | + if (!vport->stat_data_enabled || vport->stat_data_blocked | |
1472 | + || (phba->bucket_type == LPFC_NO_BUCKET)) | |
1473 | + return 0; | |
1474 | + | |
1475 | + spin_lock_irq(shost->host_lock); | |
1476 | + list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { | |
1477 | + if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) | |
1478 | + continue; | |
1479 | + | |
1480 | + if (nport_index > 0) { | |
1481 | + nport_index--; | |
1482 | + continue; | |
1483 | + } | |
1484 | + | |
1485 | + if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) | |
1486 | + > count) | |
1487 | + break; | |
1488 | + | |
1489 | + if (!ndlp->lat_data) | |
1490 | + continue; | |
1491 | + | |
1492 | + /* Print the WWN */ | |
1493 | + sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", | |
1494 | + ndlp->nlp_portname.u.wwn[0], | |
1495 | + ndlp->nlp_portname.u.wwn[1], | |
1496 | + ndlp->nlp_portname.u.wwn[2], | |
1497 | + ndlp->nlp_portname.u.wwn[3], | |
1498 | + ndlp->nlp_portname.u.wwn[4], | |
1499 | + ndlp->nlp_portname.u.wwn[5], | |
1500 | + ndlp->nlp_portname.u.wwn[6], | |
1501 | + ndlp->nlp_portname.u.wwn[7]); | |
1502 | + | |
1503 | + index = strlen(buf); | |
1504 | + | |
1505 | + for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { | |
1506 | + sprintf(&buf[index], "%010u,", | |
1507 | + ndlp->lat_data[i].cmd_count); | |
1508 | + index = strlen(buf); | |
1509 | + } | |
1510 | + sprintf(&buf[index], "\n"); | |
1511 | + index = strlen(buf); | |
1512 | + } | |
1513 | + spin_unlock_irq(shost->host_lock); | |
1514 | + return index; | |
1515 | +} | |
1516 | + | |
1517 | +static struct bin_attribute sysfs_drvr_stat_data_attr = { | |
1518 | + .attr = { | |
1519 | + .name = "lpfc_drvr_stat_data", | |
1520 | + .mode = S_IRUSR, | |
1521 | + .owner = THIS_MODULE, | |
1522 | + }, | |
1523 | + .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, | |
1524 | + .read = sysfs_drvr_stat_data_read, | |
1525 | + .write = NULL, | |
1526 | +}; | |
1527 | + | |
1528 | /* | |
1529 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel | |
1530 | # connection. | |
1531 | @@ -1479,6 +2523,24 @@ static DEVICE_ATTR(lpfc_topology, S_IRUG | |
1532 | # 8 = 8 Gigabaud | |
1533 | # Value range is [0,8]. Default value is 0. | |
1534 | */ | |
1535 | + | |
1536 | +/** | |
1537 | + * lpfc_link_speed_set: Set the adapters link speed. | |
1538 | + * @phba: lpfc_hba pointer. | |
1539 | + * @val: link speed value. | |
1540 | + * | |
1541 | + * Description: | |
1542 | + * If val is in a valid range then set the adapter's link speed field and | |
1543 | + * issue a lip; if the lip fails reset the link speed to the old value. | |
1544 | + * | |
1545 | + * Notes: | |
1546 | + * If the value is not in range log a kernel error message and return an error. | |
1547 | + * | |
1548 | + * Returns: | |
1549 | + * zero if val is in range and lip okay. | |
1550 | + * non-zero return value from lpfc_issue_lip() | |
1551 | + * -EINVAL val out of range | |
1552 | + **/ | |
1553 | static int | |
1554 | lpfc_link_speed_set(struct lpfc_hba *phba, int val) | |
1555 | { | |
1556 | @@ -1513,6 +2575,23 @@ static int lpfc_link_speed = 0; | |
1557 | module_param(lpfc_link_speed, int, 0); | |
1558 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); | |
1559 | lpfc_param_show(link_speed) | |
1560 | + | |
1561 | +/** | |
1562 | + * lpfc_link_speed_init: Set the adapters link speed. | |
1563 | + * @phba: lpfc_hba pointer. | |
1564 | + * @val: link speed value. | |
1565 | + * | |
1566 | + * Description: | |
1567 | + * If val is in a valid range then set the adapter's link speed field. | |
1568 | + * | |
1569 | + * Notes: | |
1570 | + * If the value is not in range log a kernel error message, clear the link | |
1571 | + * speed and return an error. | |
1572 | + * | |
1573 | + * Returns: | |
1574 | + * zero if val saved. | |
1575 | + * -EINVAL val out of range | |
1576 | + **/ | |
1577 | static int | |
1578 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) | |
1579 | { | |
1580 | @@ -1522,7 +2601,7 @@ lpfc_link_speed_init(struct lpfc_hba *ph | |
1581 | return 0; | |
1582 | } | |
1583 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
1584 | - "0454 lpfc_link_speed attribute cannot " | |
1585 | + "0405 lpfc_link_speed attribute cannot " | |
1586 | "be set to %d, allowed values are " | |
1587 | "["LPFC_LINK_SPEED_STRING"]\n", val); | |
1588 | phba->cfg_link_speed = 0; | |
1589 | @@ -1548,6 +2627,48 @@ LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, | |
1590 | "Use ADISC on rediscovery to authenticate FCP devices"); | |
1591 | ||
1592 | /* | |
1593 | +# lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue | |
1594 | +# depth. Default value is 0. When the value of this parameter is zero the | |
1595 | +# SCSI command completion time is not used for controlling I/O queue depth. When | |
1596 | +# the parameter is set to a non-zero value, the I/O queue depth is controlled | |
1597 | +# to limit the I/O completion time to the parameter value. | |
1598 | +# The value is set in milliseconds. | |
1599 | +*/ | |
1600 | +static int lpfc_max_scsicmpl_time; | |
1601 | +module_param(lpfc_max_scsicmpl_time, int, 0); | |
1602 | +MODULE_PARM_DESC(lpfc_max_scsicmpl_time, | |
1603 | + "Use command completion time to control queue depth"); | |
1604 | +lpfc_vport_param_show(max_scsicmpl_time); | |
1605 | +lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000); | |
1606 | +static int | |
1607 | +lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) | |
1608 | +{ | |
1609 | + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | |
1610 | + struct lpfc_nodelist *ndlp, *next_ndlp; | |
1611 | + | |
1612 | + if (val == vport->cfg_max_scsicmpl_time) | |
1613 | + return 0; | |
1614 | + if ((val < 0) || (val > 60000)) | |
1615 | + return -EINVAL; | |
1616 | + vport->cfg_max_scsicmpl_time = val; | |
1617 | + | |
1618 | + spin_lock_irq(shost->host_lock); | |
1619 | + list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | |
1620 | + if (!NLP_CHK_NODE_ACT(ndlp)) | |
1621 | + continue; | |
1622 | + if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) | |
1623 | + continue; | |
1624 | + ndlp->cmd_qdepth = LPFC_MAX_TGT_QDEPTH; | |
1625 | + } | |
1626 | + spin_unlock_irq(shost->host_lock); | |
1627 | + return 0; | |
1628 | +} | |
1629 | +lpfc_vport_param_store(max_scsicmpl_time); | |
1630 | +static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, | |
1631 | + lpfc_max_scsicmpl_time_show, | |
1632 | + lpfc_max_scsicmpl_time_store); | |
1633 | + | |
1634 | +/* | |
1635 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value | |
1636 | # range is [0,1]. Default value is 0. | |
1637 | */ | |
1638 | @@ -1623,12 +2744,12 @@ LPFC_ATTR_RW(poll_tmo, 10, 1, 255, | |
1639 | /* | |
1640 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that | |
1641 | # support this feature | |
1642 | -# 0 = MSI disabled (default) | |
1643 | +# 0 = MSI disabled | |
1644 | # 1 = MSI enabled | |
1645 | -# 2 = MSI-X enabled | |
1646 | -# Value range is [0,2]. Default value is 0. | |
1647 | +# 2 = MSI-X enabled (default) | |
1648 | +# Value range is [0,2]. Default value is 2. | |
1649 | */ | |
1650 | -LPFC_ATTR_R(use_msi, 0, 0, 2, "Use Message Signaled Interrupts (1) or " | |
1651 | +LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or " | |
1652 | "MSI-X (2), if possible"); | |
1653 | ||
1654 | /* | |
1655 | @@ -1668,6 +2789,7 @@ struct device_attribute *lpfc_hba_attrs[ | |
1656 | &dev_attr_option_rom_version, | |
1657 | &dev_attr_link_state, | |
1658 | &dev_attr_num_discovered_ports, | |
1659 | + &dev_attr_menlo_mgmt_mode, | |
1660 | &dev_attr_lpfc_drvr_version, | |
1661 | &dev_attr_lpfc_temp_sensor, | |
1662 | &dev_attr_lpfc_log_verbose, | |
1663 | @@ -1709,6 +2831,8 @@ struct device_attribute *lpfc_hba_attrs[ | |
1664 | &dev_attr_lpfc_enable_hba_reset, | |
1665 | &dev_attr_lpfc_enable_hba_heartbeat, | |
1666 | &dev_attr_lpfc_sg_seg_cnt, | |
1667 | + &dev_attr_lpfc_max_scsicmpl_time, | |
1668 | + &dev_attr_lpfc_stat_data_ctrl, | |
1669 | NULL, | |
1670 | }; | |
1671 | ||
1672 | @@ -1731,9 +2855,29 @@ struct device_attribute *lpfc_vport_attr | |
1673 | &dev_attr_nport_evt_cnt, | |
1674 | &dev_attr_npiv_info, | |
1675 | &dev_attr_lpfc_enable_da_id, | |
1676 | + &dev_attr_lpfc_max_scsicmpl_time, | |
1677 | + &dev_attr_lpfc_stat_data_ctrl, | |
1678 | NULL, | |
1679 | }; | |
1680 | ||
1681 | +/** | |
1682 | + * sysfs_ctlreg_write: Write method for writing to ctlreg. | |
1683 | + * @kobj: kernel kobject that contains the kernel class device. | |
1684 | + * @bin_attr: kernel attributes passed to us. | |
1685 | + * @buf: contains the data to be written to the adapter IOREG space. | |
1686 | + * @off: offset into buffer to beginning of data. | |
1687 | + * @count: bytes to transfer. | |
1688 | + * | |
1689 | + * Description: | |
1690 | + * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. | |
1691 | + * Uses the adapter io control registers to send buf contents to the adapter. | |
1692 | + * | |
1693 | + * Returns: | |
1694 | + * -ERANGE off and count combo out of range | |
1695 | + * -EINVAL off, count or buff address invalid | |
1696 | + * -EPERM adapter is offline | |
1697 | + * value of count, buf contents written | |
1698 | + **/ | |
1699 | static ssize_t | |
1700 | sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |
1701 | char *buf, loff_t off, size_t count) | |
1702 | @@ -1766,6 +2910,23 @@ sysfs_ctlreg_write(struct kobject *kobj, | |
1703 | return count; | |
1704 | } | |
1705 | ||
1706 | +/** | |
1707 | + * sysfs_ctlreg_read: Read method for reading from ctlreg. | |
1708 | + * @kobj: kernel kobject that contains the kernel class device. | |
1709 | + * @bin_attr: kernel attributes passed to us. | |
1710 | + * @buf: if succesful contains the data from the adapter IOREG space. | |
1711 | + * @off: offset into buffer to beginning of data. | |
1712 | + * @count: bytes to transfer. | |
1713 | + * | |
1714 | + * Description: | |
1715 | + * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. | |
1716 | + * Uses the adapter io control registers to read data into buf. | |
1717 | + * | |
1718 | + * Returns: | |
1719 | + * -ERANGE off and count combo out of range | |
1720 | + * -EINVAL off, count or buff address invalid | |
1721 | + * value of count, buf contents read | |
1722 | + **/ | |
1723 | static ssize_t | |
1724 | sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr, | |
1725 | char *buf, loff_t off, size_t count) | |
1726 | @@ -1810,7 +2971,10 @@ static struct bin_attribute sysfs_ctlreg | |
1727 | .write = sysfs_ctlreg_write, | |
1728 | }; | |
1729 | ||
1730 | - | |
1731 | +/** | |
1732 | + * sysfs_mbox_idle: frees the sysfs mailbox. | |
1733 | + * @phba: lpfc_hba pointer | |
1734 | + **/ | |
1735 | static void | |
1736 | sysfs_mbox_idle(struct lpfc_hba *phba) | |
1737 | { | |
1738 | @@ -1824,6 +2988,27 @@ sysfs_mbox_idle(struct lpfc_hba *phba) | |
1739 | } | |
1740 | } | |
1741 | ||
1742 | +/** | |
1743 | + * sysfs_mbox_write: Write method for writing information via mbox. | |
1744 | + * @kobj: kernel kobject that contains the kernel class device. | |
1745 | + * @bin_attr: kernel attributes passed to us. | |
1746 | + * @buf: contains the data to be written to sysfs mbox. | |
1747 | + * @off: offset into buffer to beginning of data. | |
1748 | + * @count: bytes to transfer. | |
1749 | + * | |
1750 | + * Description: | |
1751 | + * Accessed via /sys/class/scsi_host/hostxxx/mbox. | |
1752 | + * Uses the sysfs mbox to send buf contents to the adapter. | |
1753 | + * | |
1754 | + * Returns: | |
1755 | + * -ERANGE off and count combo out of range | |
1756 | + * -EINVAL off, count or buff address invalid | |
1757 | + * zero if count is zero | |
1758 | + * -EPERM adapter is offline | |
1759 | + * -ENOMEM failed to allocate memory for the mail box | |
1760 | + * -EAGAIN offset, state or mbox is NULL | |
1761 | + * count number of bytes transferred | |
1762 | + **/ | |
1763 | static ssize_t | |
1764 | sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |
1765 | char *buf, loff_t off, size_t count) | |
1766 | @@ -1878,6 +3063,29 @@ sysfs_mbox_write(struct kobject *kobj, s | |
1767 | return count; | |
1768 | } | |
1769 | ||
1770 | +/** | |
1771 | + * sysfs_mbox_read: Read method for reading information via mbox. | |
1772 | + * @kobj: kernel kobject that contains the kernel class device. | |
1773 | + * @bin_attr: kernel attributes passed to us. | |
1774 | + * @buf: contains the data to be read from sysfs mbox. | |
1775 | + * @off: offset into buffer to beginning of data. | |
1776 | + * @count: bytes to transfer. | |
1777 | + * | |
1778 | + * Description: | |
1779 | + * Accessed via /sys/class/scsi_host/hostxxx/mbox. | |
1780 | + * Uses the sysfs mbox to receive data from to the adapter. | |
1781 | + * | |
1782 | + * Returns: | |
1783 | + * -ERANGE off greater than mailbox command size | |
1784 | + * -EINVAL off, count or buff address invalid | |
1785 | + * zero if off and count are zero | |
1786 | + * -EACCES adapter over temp | |
1787 | + * -EPERM garbage can value to catch a multitude of errors | |
1788 | + * -EAGAIN management IO not permitted, state or off error | |
1789 | + * -ETIME mailbox timeout | |
1790 | + * -ENODEV mailbox error | |
1791 | + * count number of bytes transferred | |
1792 | + **/ | |
1793 | static ssize_t | |
1794 | sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, | |
1795 | char *buf, loff_t off, size_t count) | |
1796 | @@ -1954,6 +3162,8 @@ sysfs_mbox_read(struct kobject *kobj, st | |
1797 | case MBX_DEL_LD_ENTRY: | |
1798 | case MBX_SET_VARIABLE: | |
1799 | case MBX_WRITE_WWN: | |
1800 | + case MBX_PORT_CAPABILITIES: | |
1801 | + case MBX_PORT_IOV_CONTROL: | |
1802 | break; | |
1803 | case MBX_READ_SPARM64: | |
1804 | case MBX_READ_LA: | |
1805 | @@ -1978,17 +3188,15 @@ sysfs_mbox_read(struct kobject *kobj, st | |
1806 | /* If HBA encountered an error attention, allow only DUMP | |
1807 | * or RESTART mailbox commands until the HBA is restarted. | |
1808 | */ | |
1809 | - if ((phba->pport->stopped) && | |
1810 | - (phba->sysfs_mbox.mbox->mb.mbxCommand != | |
1811 | - MBX_DUMP_MEMORY && | |
1812 | - phba->sysfs_mbox.mbox->mb.mbxCommand != | |
1813 | - MBX_RESTART && | |
1814 | - phba->sysfs_mbox.mbox->mb.mbxCommand != | |
1815 | - MBX_WRITE_VPARMS)) { | |
1816 | - sysfs_mbox_idle(phba); | |
1817 | - spin_unlock_irq(&phba->hbalock); | |
1818 | - return -EPERM; | |
1819 | - } | |
1820 | + if (phba->pport->stopped && | |
1821 | + phba->sysfs_mbox.mbox->mb.mbxCommand != MBX_DUMP_MEMORY && | |
1822 | + phba->sysfs_mbox.mbox->mb.mbxCommand != MBX_RESTART && | |
1823 | + phba->sysfs_mbox.mbox->mb.mbxCommand != MBX_WRITE_VPARMS && | |
1824 | + phba->sysfs_mbox.mbox->mb.mbxCommand != MBX_WRITE_WWN) | |
1825 | + lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, | |
1826 | + "1259 mbox: Issued mailbox cmd " | |
1827 | + "0x%x while in stopped state.\n", | |
1828 | + phba->sysfs_mbox.mbox->mb.mbxCommand); | |
1829 | ||
1830 | phba->sysfs_mbox.mbox->vport = vport; | |
1831 | ||
1832 | @@ -2059,6 +3267,14 @@ static struct bin_attribute sysfs_mbox_a | |
1833 | .write = sysfs_mbox_write, | |
1834 | }; | |
1835 | ||
1836 | +/** | |
1837 | + * lpfc_alloc_sysfs_attr: Creates the ctlreg and mbox entries. | |
1838 | + * @vport: address of lpfc vport structure. | |
1839 | + * | |
1840 | + * Return codes: | |
1841 | + * zero on success | |
1842 | + * error return code from sysfs_create_bin_file() | |
1843 | + **/ | |
1844 | int | |
1845 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) | |
1846 | { | |
1847 | @@ -2075,18 +3291,30 @@ lpfc_alloc_sysfs_attr(struct lpfc_vport | |
1848 | if (error) | |
1849 | goto out_remove_ctlreg_attr; | |
1850 | ||
1851 | + error = sysfs_create_bin_file(&shost->shost_dev.kobj, | |
1852 | + &sysfs_drvr_stat_data_attr); | |
1853 | + if (error) | |
1854 | + goto out_remove_mbox_attr; | |
1855 | + | |
1856 | return 0; | |
1857 | +out_remove_mbox_attr: | |
1858 | + sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); | |
1859 | out_remove_ctlreg_attr: | |
1860 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); | |
1861 | out: | |
1862 | return error; | |
1863 | } | |
1864 | ||
1865 | +/** | |
1866 | + * lpfc_free_sysfs_attr: Removes the ctlreg and mbox entries. | |
1867 | + * @vport: address of lpfc vport structure. | |
1868 | + **/ | |
1869 | void | |
1870 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) | |
1871 | { | |
1872 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | |
1873 | - | |
1874 | + sysfs_remove_bin_file(&shost->shost_dev.kobj, | |
1875 | + &sysfs_drvr_stat_data_attr); | |
1876 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); | |
1877 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); | |
1878 | } | |
1879 | @@ -2096,6 +3324,10 @@ lpfc_free_sysfs_attr(struct lpfc_vport * | |
1880 | * Dynamic FC Host Attributes Support | |
1881 | */ | |
1882 | ||
1883 | +/** | |
1884 | + * lpfc_get_host_port_id: Copy the vport DID into the scsi host port id. | |
1885 | + * @shost: kernel scsi host pointer. | |
1886 | + **/ | |
1887 | static void | |
1888 | lpfc_get_host_port_id(struct Scsi_Host *shost) | |
1889 | { | |
1890 | @@ -2105,6 +3337,10 @@ lpfc_get_host_port_id(struct Scsi_Host * | |
1891 | fc_host_port_id(shost) = vport->fc_myDID; | |
1892 | } | |
1893 | ||
1894 | +/** | |
1895 | + * lpfc_get_host_port_type: Set the value of the scsi host port type. | |
1896 | + * @shost: kernel scsi host pointer. | |
1897 | + **/ | |
1898 | static void | |
1899 | lpfc_get_host_port_type(struct Scsi_Host *shost) | |
1900 | { | |
1901 | @@ -2133,6 +3369,10 @@ lpfc_get_host_port_type(struct Scsi_Host | |
1902 | spin_unlock_irq(shost->host_lock); | |
1903 | } | |
1904 | ||
1905 | +/** | |
1906 | + * lpfc_get_host_port_state: Set the value of the scsi host port state. | |
1907 | + * @shost: kernel scsi host pointer. | |
1908 | + **/ | |
1909 | static void | |
1910 | lpfc_get_host_port_state(struct Scsi_Host *shost) | |
1911 | { | |
1912 | @@ -2167,6 +3407,10 @@ lpfc_get_host_port_state(struct Scsi_Hos | |
1913 | spin_unlock_irq(shost->host_lock); | |
1914 | } | |
1915 | ||
1916 | +/** | |
1917 | + * lpfc_get_host_speed: Set the value of the scsi host speed. | |
1918 | + * @shost: kernel scsi host pointer. | |
1919 | + **/ | |
1920 | static void | |
1921 | lpfc_get_host_speed(struct Scsi_Host *shost) | |
1922 | { | |
1923 | @@ -2199,6 +3443,10 @@ lpfc_get_host_speed(struct Scsi_Host *sh | |
1924 | spin_unlock_irq(shost->host_lock); | |
1925 | } | |
1926 | ||
1927 | +/** | |
1928 | + * lpfc_get_host_fabric_name: Set the value of the scsi host fabric name. | |
1929 | + * @shost: kernel scsi host pointer. | |
1930 | + **/ | |
1931 | static void | |
1932 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) | |
1933 | { | |
1934 | @@ -2221,6 +3469,18 @@ lpfc_get_host_fabric_name (struct Scsi_H | |
1935 | fc_host_fabric_name(shost) = node_name; | |
1936 | } | |
1937 | ||
1938 | +/** | |
1939 | + * lpfc_get_stats: Return statistical information about the adapter. | |
1940 | + * @shost: kernel scsi host pointer. | |
1941 | + * | |
1942 | + * Notes: | |
1943 | + * NULL on error for link down, no mbox pool, sli2 active, | |
1944 | + * management not allowed, memory allocation error, or mbox error. | |
1945 | + * | |
1946 | + * Returns: | |
1947 | + * NULL for error | |
1948 | + * address of the adapter host statistics | |
1949 | + **/ | |
1950 | static struct fc_host_statistics * | |
1951 | lpfc_get_stats(struct Scsi_Host *shost) | |
1952 | { | |
1953 | @@ -2334,6 +3594,10 @@ lpfc_get_stats(struct Scsi_Host *shost) | |
1954 | return hs; | |
1955 | } | |
1956 | ||
1957 | +/** | |
1958 | + * lpfc_reset_stats: Copy the adapter link stats information. | |
1959 | + * @shost: kernel scsi host pointer. | |
1960 | + **/ | |
1961 | static void | |
1962 | lpfc_reset_stats(struct Scsi_Host *shost) | |
1963 | { | |
1964 | @@ -2411,6 +3675,14 @@ lpfc_reset_stats(struct Scsi_Host *shost | |
1965 | * are no sysfs handlers for link_down_tmo. | |
1966 | */ | |
1967 | ||
1968 | +/** | |
1969 | + * lpfc_get_node_by_target: Return the nodelist for a target. | |
1970 | + * @starget: kernel scsi target pointer. | |
1971 | + * | |
1972 | + * Returns: | |
1973 | + * address of the node list if found | |
1974 | + * NULL target not found | |
1975 | + **/ | |
1976 | static struct lpfc_nodelist * | |
1977 | lpfc_get_node_by_target(struct scsi_target *starget) | |
1978 | { | |
1979 | @@ -2432,6 +3704,10 @@ lpfc_get_node_by_target(struct scsi_targ | |
1980 | return NULL; | |
1981 | } | |
1982 | ||
1983 | +/** | |
1984 | + * lpfc_get_starget_port_id: Set the target port id to the ndlp DID or -1. | |
1985 | + * @starget: kernel scsi target pointer. | |
1986 | + **/ | |
1987 | static void | |
1988 | lpfc_get_starget_port_id(struct scsi_target *starget) | |
1989 | { | |
1990 | @@ -2440,6 +3716,12 @@ lpfc_get_starget_port_id(struct scsi_tar | |
1991 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; | |
1992 | } | |
1993 | ||
1994 | +/** | |
1995 | + * lpfc_get_starget_node_name: Set the target node name. | |
1996 | + * @starget: kernel scsi target pointer. | |
1997 | + * | |
1998 | + * Description: Set the target node name to the ndlp node name wwn or zero. | |
1999 | + **/ | |
2000 | static void | |
2001 | lpfc_get_starget_node_name(struct scsi_target *starget) | |
2002 | { | |
2003 | @@ -2449,6 +3731,12 @@ lpfc_get_starget_node_name(struct scsi_t | |
2004 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; | |
2005 | } | |
2006 | ||
2007 | +/** | |
2008 | + * lpfc_get_starget_port_name: Set the target port name. | |
2009 | + * @starget: kernel scsi target pointer. | |
2010 | + * | |
2011 | + * Description: set the target port name to the ndlp port name wwn or zero. | |
2012 | + **/ | |
2013 | static void | |
2014 | lpfc_get_starget_port_name(struct scsi_target *starget) | |
2015 | { | |
2016 | @@ -2458,6 +3746,15 @@ lpfc_get_starget_port_name(struct scsi_t | |
2017 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; | |
2018 | } | |
2019 | ||
2020 | +/** | |
2021 | + * lpfc_set_rport_loss_tmo: Set the rport dev loss tmo. | |
2022 | + * @rport: fc rport address. | |
2023 | + * @timeout: new value for dev loss tmo. | |
2024 | + * | |
2025 | + * Description: | |
2026 | + * If timeout is non zero set the dev_loss_tmo to timeout, else set | |
2027 | + * dev_loss_tmo to one. | |
2028 | + **/ | |
2029 | static void | |
2030 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | |
2031 | { | |
2032 | @@ -2467,7 +3764,18 @@ lpfc_set_rport_loss_tmo(struct fc_rport | |
2033 | rport->dev_loss_tmo = 1; | |
2034 | } | |
2035 | ||
2036 | - | |
2037 | +/** | |
2038 | + * lpfc_rport_show_function: Return rport target information. | |
2039 | + * | |
2040 | + * Description: | |
2041 | + * Macro that uses field to generate a function with the name lpfc_show_rport_ | |
2042 | + * | |
2043 | + * lpfc_show_rport_##field: returns the bytes formatted in buf | |
2044 | + * @cdev: class converted to an fc_rport. | |
2045 | + * @buf: on return contains the target_field or zero. | |
2046 | + * | |
2047 | + * Returns: size of formatted string. | |
2048 | + **/ | |
2049 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ | |
2050 | static ssize_t \ | |
2051 | lpfc_show_rport_##field (struct device *dev, \ | |
2052 | @@ -2602,6 +3910,10 @@ struct fc_function_template lpfc_vport_t | |
2053 | .vport_disable = lpfc_vport_disable, | |
2054 | }; | |
2055 | ||
2056 | +/** | |
2057 | + * lpfc_get_cfgparam: Used during probe_one to init the adapter structure. | |
2058 | + * @phba: lpfc_hba pointer. | |
2059 | + **/ | |
2060 | void | |
2061 | lpfc_get_cfgparam(struct lpfc_hba *phba) | |
2062 | { | |
2063 | @@ -2637,6 +3949,10 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) | |
2064 | return; | |
2065 | } | |
2066 | ||
2067 | +/** | |
2068 | + * lpfc_get_vport_cfgparam: Used during port create, init the vport structure. | |
2069 | + * @vport: lpfc_vport pointer. | |
2070 | + **/ | |
2071 | void | |
2072 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) | |
2073 | { | |
2074 | @@ -2648,6 +3964,7 @@ lpfc_get_vport_cfgparam(struct lpfc_vpor | |
2075 | lpfc_restrict_login_init(vport, lpfc_restrict_login); | |
2076 | lpfc_fcp_class_init(vport, lpfc_fcp_class); | |
2077 | lpfc_use_adisc_init(vport, lpfc_use_adisc); | |
2078 | + lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); | |
2079 | lpfc_fdmi_on_init(vport, lpfc_fdmi_on); | |
2080 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); | |
2081 | lpfc_max_luns_init(vport, lpfc_max_luns); | |
2082 | --- a/drivers/scsi/lpfc/lpfc_crtn.h | |
2083 | +++ b/drivers/scsi/lpfc/lpfc_crtn.h | |
2084 | @@ -18,7 +18,7 @@ | |
2085 | * included with this package. * | |
2086 | *******************************************************************/ | |
2087 | ||
2088 | -typedef int (*node_filter)(struct lpfc_nodelist *ndlp, void *param); | |
2089 | +typedef int (*node_filter)(struct lpfc_nodelist *, void *); | |
2090 | ||
2091 | struct fc_rport; | |
2092 | void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t); | |
2093 | @@ -26,11 +26,11 @@ void lpfc_read_nv(struct lpfc_hba *, LPF | |
2094 | void lpfc_config_async(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t); | |
2095 | ||
2096 | void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2097 | -int lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, | |
2098 | - struct lpfc_dmabuf *mp); | |
2099 | +int lpfc_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *, struct lpfc_dmabuf *); | |
2100 | void lpfc_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2101 | -void lpfc_issue_clear_la(struct lpfc_hba *phba, struct lpfc_vport *vport); | |
2102 | +void lpfc_issue_clear_la(struct lpfc_hba *, struct lpfc_vport *); | |
2103 | void lpfc_config_link(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2104 | +int lpfc_config_msi(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2105 | int lpfc_read_sparam(struct lpfc_hba *, LPFC_MBOXQ_t *, int); | |
2106 | void lpfc_read_config(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2107 | void lpfc_read_lnk_stat(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2108 | @@ -43,7 +43,7 @@ void lpfc_unreg_vpi(struct lpfc_hba *, u | |
2109 | void lpfc_init_link(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t); | |
2110 | ||
2111 | struct lpfc_vport *lpfc_find_vport_by_did(struct lpfc_hba *, uint32_t); | |
2112 | -void lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove); | |
2113 | +void lpfc_cleanup_rpis(struct lpfc_vport *, int); | |
2114 | int lpfc_linkdown(struct lpfc_hba *); | |
2115 | void lpfc_port_link_failure(struct lpfc_vport *); | |
2116 | void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2117 | @@ -135,7 +135,7 @@ void lpfc_ct_unsol_event(struct lpfc_hba | |
2118 | int lpfc_ns_cmd(struct lpfc_vport *, int, uint8_t, uint32_t); | |
2119 | int lpfc_fdmi_cmd(struct lpfc_vport *, struct lpfc_nodelist *, int); | |
2120 | void lpfc_fdmi_tmo(unsigned long); | |
2121 | -void lpfc_fdmi_timeout_handler(struct lpfc_vport *vport); | |
2122 | +void lpfc_fdmi_timeout_handler(struct lpfc_vport *); | |
2123 | ||
2124 | int lpfc_config_port_prep(struct lpfc_hba *); | |
2125 | int lpfc_config_port_post(struct lpfc_hba *); | |
2126 | @@ -155,6 +155,8 @@ int lpfc_sli_queue_setup(struct lpfc_hba | |
2127 | void lpfc_handle_eratt(struct lpfc_hba *); | |
2128 | void lpfc_handle_latt(struct lpfc_hba *); | |
2129 | irqreturn_t lpfc_intr_handler(int, void *); | |
2130 | +irqreturn_t lpfc_sp_intr_handler(int, void *); | |
2131 | +irqreturn_t lpfc_fp_intr_handler(int, void *); | |
2132 | ||
2133 | void lpfc_read_rev(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2134 | void lpfc_config_ring(struct lpfc_hba *, int, LPFC_MBOXQ_t *); | |
2135 | @@ -175,11 +177,12 @@ void lpfc_mem_free(struct lpfc_hba *); | |
2136 | void lpfc_stop_vport_timers(struct lpfc_vport *); | |
2137 | ||
2138 | void lpfc_poll_timeout(unsigned long ptr); | |
2139 | -void lpfc_poll_start_timer(struct lpfc_hba * phba); | |
2140 | -void lpfc_sli_poll_fcp_ring(struct lpfc_hba * hba); | |
2141 | +void lpfc_poll_start_timer(struct lpfc_hba *); | |
2142 | +void lpfc_poll_eratt(unsigned long); | |
2143 | +void lpfc_sli_poll_fcp_ring(struct lpfc_hba *); | |
2144 | struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *); | |
2145 | -void lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb); | |
2146 | -uint16_t lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocb); | |
2147 | +void lpfc_sli_release_iocbq(struct lpfc_hba *, struct lpfc_iocbq *); | |
2148 | +uint16_t lpfc_sli_next_iotag(struct lpfc_hba *, struct lpfc_iocbq *); | |
2149 | ||
2150 | void lpfc_reset_barrier(struct lpfc_hba * phba); | |
2151 | int lpfc_sli_brdready(struct lpfc_hba *, uint32_t); | |
2152 | @@ -187,11 +190,13 @@ int lpfc_sli_brdkill(struct lpfc_hba *); | |
2153 | int lpfc_sli_brdreset(struct lpfc_hba *); | |
2154 | int lpfc_sli_brdrestart(struct lpfc_hba *); | |
2155 | int lpfc_sli_hba_setup(struct lpfc_hba *); | |
2156 | +int lpfc_sli_config_port(struct lpfc_hba *, int); | |
2157 | int lpfc_sli_host_down(struct lpfc_vport *); | |
2158 | int lpfc_sli_hba_down(struct lpfc_hba *); | |
2159 | int lpfc_sli_issue_mbox(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t); | |
2160 | int lpfc_sli_handle_mb_event(struct lpfc_hba *); | |
2161 | int lpfc_sli_flush_mbox_queue(struct lpfc_hba *); | |
2162 | +int lpfc_sli_check_eratt(struct lpfc_hba *); | |
2163 | int lpfc_sli_handle_slow_ring_event(struct lpfc_hba *, | |
2164 | struct lpfc_sli_ring *, uint32_t); | |
2165 | void lpfc_sli_def_mbox_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *); | |
2166 | @@ -199,6 +204,7 @@ int lpfc_sli_issue_iocb(struct lpfc_hba | |
2167 | struct lpfc_iocbq *, uint32_t); | |
2168 | void lpfc_sli_pcimem_bcopy(void *, void *, uint32_t); | |
2169 | void lpfc_sli_abort_iocb_ring(struct lpfc_hba *, struct lpfc_sli_ring *); | |
2170 | +void lpfc_sli_flush_fcp_rings(struct lpfc_hba *); | |
2171 | int lpfc_sli_ringpostbuf_put(struct lpfc_hba *, struct lpfc_sli_ring *, | |
2172 | struct lpfc_dmabuf *); | |
2173 | struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *, | |
2174 | @@ -226,17 +232,13 @@ struct lpfc_nodelist *lpfc_findnode_did( | |
2175 | struct lpfc_nodelist *lpfc_findnode_wwpn(struct lpfc_vport *, | |
2176 | struct lpfc_name *); | |
2177 | ||
2178 | -int lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, | |
2179 | - uint32_t timeout); | |
2180 | +int lpfc_sli_issue_mbox_wait(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t); | |
2181 | ||
2182 | -int lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba, | |
2183 | - struct lpfc_sli_ring * pring, | |
2184 | - struct lpfc_iocbq * piocb, | |
2185 | - struct lpfc_iocbq * prspiocbq, | |
2186 | - uint32_t timeout); | |
2187 | -void lpfc_sli_abort_fcp_cmpl(struct lpfc_hba * phba, | |
2188 | - struct lpfc_iocbq * cmdiocb, | |
2189 | - struct lpfc_iocbq * rspiocb); | |
2190 | +int lpfc_sli_issue_iocb_wait(struct lpfc_hba *, struct lpfc_sli_ring *, | |
2191 | + struct lpfc_iocbq *, struct lpfc_iocbq *, | |
2192 | + uint32_t); | |
2193 | +void lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *, struct lpfc_iocbq *, | |
2194 | + struct lpfc_iocbq *); | |
2195 | ||
2196 | void lpfc_sli_free_hbq(struct lpfc_hba *, struct hbq_dmabuf *); | |
2197 | ||
2198 | @@ -269,7 +271,7 @@ void lpfc_dev_loss_tmo_callbk(struct fc_ | |
2199 | ||
2200 | struct lpfc_vport *lpfc_create_port(struct lpfc_hba *, int, struct device *); | |
2201 | int lpfc_vport_disable(struct fc_vport *fc_vport, bool disable); | |
2202 | -void lpfc_mbx_unreg_vpi(struct lpfc_vport *); | |
2203 | +int lpfc_mbx_unreg_vpi(struct lpfc_vport *); | |
2204 | void destroy_port(struct lpfc_vport *); | |
2205 | int lpfc_get_instance(void); | |
2206 | void lpfc_host_attrib_init(struct Scsi_Host *); | |
2207 | @@ -290,6 +292,13 @@ void lpfc_unblock_fabric_iocbs(struct lp | |
2208 | void lpfc_adjust_queue_depth(struct lpfc_hba *); | |
2209 | void lpfc_ramp_down_queue_handler(struct lpfc_hba *); | |
2210 | void lpfc_ramp_up_queue_handler(struct lpfc_hba *); | |
2211 | +void lpfc_scsi_dev_block(struct lpfc_hba *); | |
2212 | + | |
2213 | +void | |
2214 | +lpfc_send_els_failure_event(struct lpfc_hba *, struct lpfc_iocbq *, | |
2215 | + struct lpfc_iocbq *); | |
2216 | +struct lpfc_fast_path_event *lpfc_alloc_fast_evt(struct lpfc_hba *); | |
2217 | +void lpfc_free_fast_evt(struct lpfc_hba *, struct lpfc_fast_path_event *); | |
2218 | ||
2219 | #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code) | |
2220 | #define HBA_EVENT_RSCN 5 | |
2221 | --- a/drivers/scsi/lpfc/lpfc_ct.c | |
2222 | +++ b/drivers/scsi/lpfc/lpfc_ct.c | |
2223 | @@ -34,6 +34,7 @@ | |
2224 | ||
2225 | #include "lpfc_hw.h" | |
2226 | #include "lpfc_sli.h" | |
2227 | +#include "lpfc_nl.h" | |
2228 | #include "lpfc_disc.h" | |
2229 | #include "lpfc_scsi.h" | |
2230 | #include "lpfc.h" | |
2231 | @@ -134,25 +135,24 @@ lpfc_ct_unsol_event(struct lpfc_hba *phb | |
2232 | } | |
2233 | list_del(&head); | |
2234 | } else { | |
2235 | - struct lpfc_iocbq *next; | |
2236 | - | |
2237 | - list_for_each_entry_safe(iocbq, next, &piocbq->list, list) { | |
2238 | + INIT_LIST_HEAD(&head); | |
2239 | + list_add_tail(&head, &piocbq->list); | |
2240 | + list_for_each_entry(iocbq, &head, list) { | |
2241 | icmd = &iocbq->iocb; | |
2242 | if (icmd->ulpBdeCount == 0) | |
2243 | - lpfc_ct_unsol_buffer(phba, piocbq, NULL, 0); | |
2244 | + lpfc_ct_unsol_buffer(phba, iocbq, NULL, 0); | |
2245 | for (i = 0; i < icmd->ulpBdeCount; i++) { | |
2246 | paddr = getPaddr(icmd->un.cont64[i].addrHigh, | |
2247 | icmd->un.cont64[i].addrLow); | |
2248 | mp = lpfc_sli_ringpostbuf_get(phba, pring, | |
2249 | paddr); | |
2250 | size = icmd->un.cont64[i].tus.f.bdeSize; | |
2251 | - lpfc_ct_unsol_buffer(phba, piocbq, mp, size); | |
2252 | + lpfc_ct_unsol_buffer(phba, iocbq, mp, size); | |
2253 | lpfc_in_buf_free(phba, mp); | |
2254 | } | |
2255 | - list_del(&iocbq->list); | |
2256 | - lpfc_sli_release_iocbq(phba, iocbq); | |
2257 | lpfc_post_buffer(phba, pring, i); | |
2258 | } | |
2259 | + list_del(&head); | |
2260 | } | |
2261 | } | |
2262 | ||
2263 | @@ -212,7 +212,7 @@ lpfc_alloc_ct_rsp(struct lpfc_hba *phba, | |
2264 | else | |
2265 | list_add_tail(&mp->list, &mlist->list); | |
2266 | ||
2267 | - bpl->tus.f.bdeFlags = BUFF_USE_RCV; | |
2268 | + bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I; | |
2269 | /* build buffer ptr list for IOCB */ | |
2270 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); | |
2271 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); | |
2272 | @@ -283,7 +283,7 @@ lpfc_gen_req(struct lpfc_vport *vport, s | |
2273 | icmd->un.genreq64.bdl.ulpIoTag32 = 0; | |
2274 | icmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); | |
2275 | icmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); | |
2276 | - icmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BDL; | |
2277 | + icmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; | |
2278 | icmd->un.genreq64.bdl.bdeSize = (num_entry * sizeof (struct ulp_bde64)); | |
2279 | ||
2280 | if (usr_flg) | |
2281 | @@ -861,7 +861,7 @@ lpfc_cmpl_ct(struct lpfc_hba *phba, stru | |
2282 | ||
2283 | retry++; | |
2284 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | |
2285 | - "0216 Retrying NS cmd %x\n", cmdcode); | |
2286 | + "0250 Retrying NS cmd %x\n", cmdcode); | |
2287 | rc = lpfc_ns_cmd(vport, cmdcode, retry, 0); | |
2288 | if (rc == 0) | |
2289 | goto out; | |
2290 | --- a/drivers/scsi/lpfc/lpfc_debugfs.c | |
2291 | +++ b/drivers/scsi/lpfc/lpfc_debugfs.c | |
2292 | @@ -1,7 +1,7 @@ | |
2293 | /******************************************************************* | |
2294 | * This file is part of the Emulex Linux Device Driver for * | |
2295 | * Fibre Channel Host Bus Adapters. * | |
2296 | - * Copyright (C) 2007 Emulex. All rights reserved. * | |
2297 | + * Copyright (C) 2007-2008 Emulex. All rights reserved. * | |
2298 | * EMULEX and SLI are trademarks of Emulex. * | |
2299 | * www.emulex.com * | |
2300 | * * | |
2301 | @@ -35,6 +35,7 @@ | |
2302 | ||
2303 | #include "lpfc_hw.h" | |
2304 | #include "lpfc_sli.h" | |
2305 | +#include "lpfc_nl.h" | |
2306 | #include "lpfc_disc.h" | |
2307 | #include "lpfc_scsi.h" | |
2308 | #include "lpfc.h" | |
2309 | @@ -46,13 +47,14 @@ | |
2310 | #include "lpfc_debugfs.h" | |
2311 | ||
2312 | #ifdef CONFIG_LPFC_DEBUG_FS | |
2313 | -/* debugfs interface | |
2314 | +/** | |
2315 | + * debugfs interface | |
2316 | * | |
2317 | * To access this interface the user should: | |
2318 | * # mkdir /debug | |
2319 | * # mount -t debugfs none /debug | |
2320 | * | |
2321 | - * The lpfc debugfs directory hierachy is: | |
2322 | + * The lpfc debugfs directory hierarchy is: | |
2323 | * lpfc/lpfcX/vportY | |
2324 | * where X is the lpfc hba unique_id | |
2325 | * where Y is the vport VPI on that hba | |
2326 | @@ -61,14 +63,21 @@ | |
2327 | * discovery_trace | |
2328 | * This is an ACSII readable file that contains a trace of the last | |
2329 | * lpfc_debugfs_max_disc_trc events that happened on a specific vport. | |
2330 | - * See lpfc_debugfs.h for different categories of | |
2331 | - * discovery events. To enable the discovery trace, the following | |
2332 | - * module parameters must be set: | |
2333 | + * See lpfc_debugfs.h for different categories of discovery events. | |
2334 | + * To enable the discovery trace, the following module parameters must be set: | |
2335 | * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support | |
2336 | * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for | |
2337 | * EACH vport. X MUST also be a power of 2. | |
2338 | * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in | |
2339 | * lpfc_debugfs.h . | |
2340 | + * | |
2341 | + * slow_ring_trace | |
2342 | + * This is an ACSII readable file that contains a trace of the last | |
2343 | + * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA. | |
2344 | + * To enable the slow ring trace, the following module parameters must be set: | |
2345 | + * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support | |
2346 | + * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for | |
2347 | + * the HBA. X MUST also be a power of 2. | |
2348 | */ | |
2349 | static int lpfc_debugfs_enable = 1; | |
2350 | module_param(lpfc_debugfs_enable, int, 0); | |
2351 | @@ -117,6 +126,25 @@ struct lpfc_debug { | |
2352 | static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0); | |
2353 | static unsigned long lpfc_debugfs_start_time = 0L; | |
2354 | ||
2355 | +/** | |
2356 | + * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer. | |
2357 | + * @vport: The vport to gather the log info from. | |
2358 | + * @buf: The buffer to dump log into. | |
2359 | + * @size: The maximum amount of data to process. | |
2360 | + * | |
2361 | + * Description: | |
2362 | + * This routine gathers the lpfc discovery debugfs data from the @vport and | |
2363 | + * dumps it to @buf up to @size number of bytes. It will start at the next entry | |
2364 | + * in the log and process the log until the end of the buffer. Then it will | |
2365 | + * gather from the beginning of the log and process until the current entry. | |
2366 | + * | |
2367 | + * Notes: | |
2368 | + * Discovery logging will be disabled while while this routine dumps the log. | |
2369 | + * | |
2370 | + * Return Value: | |
2371 | + * This routine returns the amount of bytes that were dumped into @buf and will | |
2372 | + * not exceed @size. | |
2373 | + **/ | |
2374 | static int | |
2375 | lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size) | |
2376 | { | |
2377 | @@ -125,7 +153,6 @@ lpfc_debugfs_disc_trc_data(struct lpfc_v | |
2378 | struct lpfc_debugfs_trc *dtp; | |
2379 | char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE]; | |
2380 | ||
2381 | - | |
2382 | enable = lpfc_debugfs_enable; | |
2383 | lpfc_debugfs_enable = 0; | |
2384 | ||
2385 | @@ -159,6 +186,25 @@ lpfc_debugfs_disc_trc_data(struct lpfc_v | |
2386 | return len; | |
2387 | } | |
2388 | ||
2389 | +/** | |
2390 | + * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer. | |
2391 | + * @phba: The HBA to gather the log info from. | |
2392 | + * @buf: The buffer to dump log into. | |
2393 | + * @size: The maximum amount of data to process. | |
2394 | + * | |
2395 | + * Description: | |
2396 | + * This routine gathers the lpfc slow ring debugfs data from the @phba and | |
2397 | + * dumps it to @buf up to @size number of bytes. It will start at the next entry | |
2398 | + * in the log and process the log until the end of the buffer. Then it will | |
2399 | + * gather from the beginning of the log and process until the current entry. | |
2400 | + * | |
2401 | + * Notes: | |
2402 | + * Slow ring logging will be disabled while while this routine dumps the log. | |
2403 | + * | |
2404 | + * Return Value: | |
2405 | + * This routine returns the amount of bytes that were dumped into @buf and will | |
2406 | + * not exceed @size. | |
2407 | + **/ | |
2408 | static int | |
2409 | lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size) | |
2410 | { | |
2411 | @@ -203,6 +249,25 @@ lpfc_debugfs_slow_ring_trc_data(struct l | |
2412 | ||
2413 | static int lpfc_debugfs_last_hbq = -1; | |
2414 | ||
2415 | +/** | |
2416 | + * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer. | |
2417 | + * @phba: The HBA to gather host buffer info from. | |
2418 | + * @buf: The buffer to dump log into. | |
2419 | + * @size: The maximum amount of data to process. | |
2420 | + * | |
2421 | + * Description: | |
2422 | + * This routine dumps the host buffer queue info from the @phba to @buf up to | |
2423 | + * @size number of bytes. A header that describes the current hbq state will be | |
2424 | + * dumped to @buf first and then info on each hbq entry will be dumped to @buf | |
2425 | + * until @size bytes have been dumped or all the hbq info has been dumped. | |
2426 | + * | |
2427 | + * Notes: | |
2428 | + * This routine will rotate through each configured HBQ each time called. | |
2429 | + * | |
2430 | + * Return Value: | |
2431 | + * This routine returns the amount of bytes that were dumped into @buf and will | |
2432 | + * not exceed @size. | |
2433 | + **/ | |
2434 | static int | |
2435 | lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) | |
2436 | { | |
2437 | @@ -303,6 +368,24 @@ skipit: | |
2438 | ||
2439 | static int lpfc_debugfs_last_hba_slim_off; | |
2440 | ||
2441 | +/** | |
2442 | + * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer. | |
2443 | + * @phba: The HBA to gather SLIM info from. | |
2444 | + * @buf: The buffer to dump log into. | |
2445 | + * @size: The maximum amount of data to process. | |
2446 | + * | |
2447 | + * Description: | |
2448 | + * This routine dumps the current contents of HBA SLIM for the HBA associated | |
2449 | + * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data. | |
2450 | + * | |
2451 | + * Notes: | |
2452 | + * This routine will only dump up to 1024 bytes of data each time called and | |
2453 | + * should be called multiple times to dump the entire HBA SLIM. | |
2454 | + * | |
2455 | + * Return Value: | |
2456 | + * This routine returns the amount of bytes that were dumped into @buf and will | |
2457 | + * not exceed @size. | |
2458 | + **/ | |
2459 | static int | |
2460 | lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size) | |
2461 | { | |
2462 | @@ -342,6 +425,21 @@ lpfc_debugfs_dumpHBASlim_data(struct lpf | |
2463 | return len; | |
2464 | } | |
2465 | ||
2466 | +/** | |
2467 | + * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer. | |
2468 | + * @phba: The HBA to gather Host SLIM info from. | |
2469 | + * @buf: The buffer to dump log into. | |
2470 | + * @size: The maximum amount of data to process. | |
2471 | + * | |
2472 | + * Description: | |
2473 | + * This routine dumps the current contents of host SLIM for the host associated | |
2474 | + * with @phba to @buf up to @size bytes of data. The dump will contain the | |
2475 | + * Mailbox, PCB, Rings, and Registers that are located in host memory. | |
2476 | + * | |
2477 | + * Return Value: | |
2478 | + * This routine returns the amount of bytes that were dumped into @buf and will | |
2479 | + * not exceed @size. | |
2480 | + **/ | |
2481 | static int | |
2482 | lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size) | |
2483 | { | |
2484 | @@ -357,7 +455,7 @@ lpfc_debugfs_dumpHostSlim_data(struct lp | |
2485 | spin_lock_irq(&phba->hbalock); | |
2486 | ||
2487 | len += snprintf(buf+len, size-len, "SLIM Mailbox\n"); | |
2488 | - ptr = (uint32_t *)phba->slim2p; | |
2489 | + ptr = (uint32_t *)phba->slim2p.virt; | |
2490 | i = sizeof(MAILBOX_t); | |
2491 | while (i > 0) { | |
2492 | len += snprintf(buf+len, size-len, | |
2493 | @@ -370,7 +468,7 @@ lpfc_debugfs_dumpHostSlim_data(struct lp | |
2494 | } | |
2495 | ||
2496 | len += snprintf(buf+len, size-len, "SLIM PCB\n"); | |
2497 | - ptr = (uint32_t *)&phba->slim2p->pcb; | |
2498 | + ptr = (uint32_t *)phba->pcb; | |
2499 | i = sizeof(PCB_t); | |
2500 | while (i > 0) { | |
2501 | len += snprintf(buf+len, size-len, | |
2502 | @@ -382,44 +480,16 @@ lpfc_debugfs_dumpHostSlim_data(struct lp | |
2503 | off += (8 * sizeof(uint32_t)); | |
2504 | } | |
2505 | ||
2506 | - pgpp = (struct lpfc_pgp *)&phba->slim2p->mbx.us.s3_pgp.port; | |
2507 | - pring = &psli->ring[0]; | |
2508 | - len += snprintf(buf+len, size-len, | |
2509 | - "Ring 0: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) " | |
2510 | - "RSP PutInx:%d Max:%d\n", | |
2511 | - pgpp->cmdGetInx, pring->numCiocb, | |
2512 | - pring->next_cmdidx, pring->local_getidx, pring->flag, | |
2513 | - pgpp->rspPutInx, pring->numRiocb); | |
2514 | - pgpp++; | |
2515 | - | |
2516 | - pring = &psli->ring[1]; | |
2517 | - len += snprintf(buf+len, size-len, | |
2518 | - "Ring 1: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) " | |
2519 | - "RSP PutInx:%d Max:%d\n", | |
2520 | - pgpp->cmdGetInx, pring->numCiocb, | |
2521 | - pring->next_cmdidx, pring->local_getidx, pring->flag, | |
2522 | - pgpp->rspPutInx, pring->numRiocb); | |
2523 | - pgpp++; | |
2524 | - | |
2525 | - pring = &psli->ring[2]; | |
2526 | - len += snprintf(buf+len, size-len, | |
2527 | - "Ring 2: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) " | |
2528 | - "RSP PutInx:%d Max:%d\n", | |
2529 | - pgpp->cmdGetInx, pring->numCiocb, | |
2530 | - pring->next_cmdidx, pring->local_getidx, pring->flag, | |
2531 | - pgpp->rspPutInx, pring->numRiocb); | |
2532 | - pgpp++; | |
2533 | - | |
2534 | - pring = &psli->ring[3]; | |
2535 | - len += snprintf(buf+len, size-len, | |
2536 | - "Ring 3: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) " | |
2537 | - "RSP PutInx:%d Max:%d\n", | |
2538 | - pgpp->cmdGetInx, pring->numCiocb, | |
2539 | - pring->next_cmdidx, pring->local_getidx, pring->flag, | |
2540 | - pgpp->rspPutInx, pring->numRiocb); | |
2541 | - | |
2542 | - | |
2543 | - ptr = (uint32_t *)&phba->slim2p->mbx.us.s3_pgp.hbq_get; | |
2544 | + for (i = 0; i < 4; i++) { | |
2545 | + pgpp = &phba->port_gp[i]; | |
2546 | + pring = &psli->ring[i]; | |
2547 | + len += snprintf(buf+len, size-len, | |
2548 | + "Ring %d: CMD GetInx:%d (Max:%d Next:%d " | |
2549 | + "Local:%d flg:x%x) RSP PutInx:%d Max:%d\n", | |
2550 | + i, pgpp->cmdGetInx, pring->numCiocb, | |
2551 | + pring->next_cmdidx, pring->local_getidx, | |
2552 | + pring->flag, pgpp->rspPutInx, pring->numRiocb); | |
2553 | + } | |
2554 | word0 = readl(phba->HAregaddr); | |
2555 | word1 = readl(phba->CAregaddr); | |
2556 | word2 = readl(phba->HSregaddr); | |
2557 | @@ -430,6 +500,21 @@ lpfc_debugfs_dumpHostSlim_data(struct lp | |
2558 | return len; | |
2559 | } | |
2560 | ||
2561 | +/** | |
2562 | + * lpfc_debugfs_nodelist_data - Dump target node list to a buffer. | |
2563 | + * @vport: The vport to gather target node info from. | |
2564 | + * @buf: The buffer to dump log into. | |
2565 | + * @size: The maximum amount of data to process. | |
2566 | + * | |
2567 | + * Description: | |
2568 | + * This routine dumps the current target node list associated with @vport to | |
2569 | + * @buf up to @size bytes of data. Each node entry in the dump will contain a | |
2570 | + * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields. | |
2571 | + * | |
2572 | + * Return Value: | |
2573 | + * This routine returns the amount of bytes that were dumped into @buf and will | |
2574 | + * not exceed @size. | |
2575 | + **/ | |
2576 | static int | |
2577 | lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size) | |
2578 | { | |
2579 | @@ -513,7 +598,22 @@ lpfc_debugfs_nodelist_data(struct lpfc_v | |
2580 | } | |
2581 | #endif | |
2582 | ||
2583 | - | |
2584 | +/** | |
2585 | + * lpfc_debugfs_disc_trc - Store discovery trace log. | |
2586 | + * @vport: The vport to associate this trace string with for retrieval. | |
2587 | + * @mask: Log entry classification. | |
2588 | + * @fmt: Format string to be displayed when dumping the log. | |
2589 | + * @data1: 1st data parameter to be applied to @fmt. | |
2590 | + * @data2: 2nd data parameter to be applied to @fmt. | |
2591 | + * @data3: 3rd data parameter to be applied to @fmt. | |
2592 | + * | |
2593 | + * Description: | |
2594 | + * This routine is used by the driver code to add a debugfs log entry to the | |
2595 | + * discovery trace buffer associated with @vport. Only entries with a @mask that | |
2596 | + * match the current debugfs discovery mask will be saved. Entries that do not | |
2597 | + * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like | |
2598 | + * printf when displaying the log. | |
2599 | + **/ | |
2600 | inline void | |
2601 | lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt, | |
2602 | uint32_t data1, uint32_t data2, uint32_t data3) | |
2603 | @@ -542,6 +642,19 @@ lpfc_debugfs_disc_trc(struct lpfc_vport | |
2604 | return; | |
2605 | } | |
2606 | ||
2607 | +/** | |
2608 | + * lpfc_debugfs_slow_ring_trc - Store slow ring trace log. | |
2609 | + * @phba: The phba to associate this trace string with for retrieval. | |
2610 | + * @fmt: Format string to be displayed when dumping the log. | |
2611 | + * @data1: 1st data parameter to be applied to @fmt. | |
2612 | + * @data2: 2nd data parameter to be applied to @fmt. | |
2613 | + * @data3: 3rd data parameter to be applied to @fmt. | |
2614 | + * | |
2615 | + * Description: | |
2616 | + * This routine is used by the driver code to add a debugfs log entry to the | |
2617 | + * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and | |
2618 | + * @data3 are used like printf when displaying the log. | |
2619 | + **/ | |
2620 | inline void | |
2621 | lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt, | |
2622 | uint32_t data1, uint32_t data2, uint32_t data3) | |
2623 | @@ -568,6 +681,21 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_h | |
2624 | } | |
2625 | ||
2626 | #ifdef CONFIG_LPFC_DEBUG_FS | |
2627 | +/** | |
2628 | + * lpfc_debugfs_disc_trc_open - Open the discovery trace log. | |
2629 | + * @inode: The inode pointer that contains a vport pointer. | |
2630 | + * @file: The file pointer to attach the log output. | |
2631 | + * | |
2632 | + * Description: | |
2633 | + * This routine is the entry point for the debugfs open file operation. It gets | |
2634 | + * the vport from the i_private field in @inode, allocates the necessary buffer | |
2635 | + * for the log, fills the buffer from the in-memory log for this vport, and then | |
2636 | + * returns a pointer to that log in the private_data field in @file. | |
2637 | + * | |
2638 | + * Returns: | |
2639 | + * This function returns zero if successful. On error it will return an negative | |
2640 | + * error value. | |
2641 | + **/ | |
2642 | static int | |
2643 | lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file) | |
2644 | { | |
2645 | @@ -585,7 +713,7 @@ lpfc_debugfs_disc_trc_open(struct inode | |
2646 | if (!debug) | |
2647 | goto out; | |
2648 | ||
2649 | - /* Round to page boundry */ | |
2650 | + /* Round to page boundary */ | |
2651 | size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE); | |
2652 | size = PAGE_ALIGN(size); | |
2653 | ||
2654 | @@ -603,6 +731,21 @@ out: | |
2655 | return rc; | |
2656 | } | |
2657 | ||
2658 | +/** | |
2659 | + * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log. | |
2660 | + * @inode: The inode pointer that contains a vport pointer. | |
2661 | + * @file: The file pointer to attach the log output. | |
2662 | + * | |
2663 | + * Description: | |
2664 | + * This routine is the entry point for the debugfs open file operation. It gets | |
2665 | + * the vport from the i_private field in @inode, allocates the necessary buffer | |
2666 | + * for the log, fills the buffer from the in-memory log for this vport, and then | |
2667 | + * returns a pointer to that log in the private_data field in @file. | |
2668 | + * | |
2669 | + * Returns: | |
2670 | + * This function returns zero if successful. On error it will return an negative | |
2671 | + * error value. | |
2672 | + **/ | |
2673 | static int | |
2674 | lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file) | |
2675 | { | |
2676 | @@ -620,7 +763,7 @@ lpfc_debugfs_slow_ring_trc_open(struct i | |
2677 | if (!debug) | |
2678 | goto out; | |
2679 | ||
2680 | - /* Round to page boundry */ | |
2681 | + /* Round to page boundary */ | |
2682 | size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE); | |
2683 | size = PAGE_ALIGN(size); | |
2684 | ||
2685 | @@ -638,6 +781,21 @@ out: | |
2686 | return rc; | |
2687 | } | |
2688 | ||
2689 | +/** | |
2690 | + * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer. | |
2691 | + * @inode: The inode pointer that contains a vport pointer. | |
2692 | + * @file: The file pointer to attach the log output. | |
2693 | + * | |
2694 | + * Description: | |
2695 | + * This routine is the entry point for the debugfs open file operation. It gets | |
2696 | + * the vport from the i_private field in @inode, allocates the necessary buffer | |
2697 | + * for the log, fills the buffer from the in-memory log for this vport, and then | |
2698 | + * returns a pointer to that log in the private_data field in @file. | |
2699 | + * | |
2700 | + * Returns: | |
2701 | + * This function returns zero if successful. On error it will return an negative | |
2702 | + * error value. | |
2703 | + **/ | |
2704 | static int | |
2705 | lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file) | |
2706 | { | |
2707 | @@ -649,7 +807,7 @@ lpfc_debugfs_hbqinfo_open(struct inode * | |
2708 | if (!debug) | |
2709 | goto out; | |
2710 | ||
2711 | - /* Round to page boundry */ | |
2712 | + /* Round to page boundary */ | |
2713 | debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL); | |
2714 | if (!debug->buffer) { | |
2715 | kfree(debug); | |
2716 | @@ -665,6 +823,21 @@ out: | |
2717 | return rc; | |
2718 | } | |
2719 | ||
2720 | +/** | |
2721 | + * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer. | |
2722 | + * @inode: The inode pointer that contains a vport pointer. | |
2723 | + * @file: The file pointer to attach the log output. | |
2724 | + * | |
2725 | + * Description: | |
2726 | + * This routine is the entry point for the debugfs open file operation. It gets | |
2727 | + * the vport from the i_private field in @inode, allocates the necessary buffer | |
2728 | + * for the log, fills the buffer from the in-memory log for this vport, and then | |
2729 | + * returns a pointer to that log in the private_data field in @file. | |
2730 | + * | |
2731 | + * Returns: | |
2732 | + * This function returns zero if successful. On error it will return an negative | |
2733 | + * error value. | |
2734 | + **/ | |
2735 | static int | |
2736 | lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file) | |
2737 | { | |
2738 | @@ -676,7 +849,7 @@ lpfc_debugfs_dumpHBASlim_open(struct ino | |
2739 | if (!debug) | |
2740 | goto out; | |
2741 | ||
2742 | - /* Round to page boundry */ | |
2743 | + /* Round to page boundary */ | |
2744 | debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL); | |
2745 | if (!debug->buffer) { | |
2746 | kfree(debug); | |
2747 | @@ -692,6 +865,21 @@ out: | |
2748 | return rc; | |
2749 | } | |
2750 | ||
2751 | +/** | |
2752 | + * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer. | |
2753 | + * @inode: The inode pointer that contains a vport pointer. | |
2754 | + * @file: The file pointer to attach the log output. | |
2755 | + * | |
2756 | + * Description: | |
2757 | + * This routine is the entry point for the debugfs open file operation. It gets | |
2758 | + * the vport from the i_private field in @inode, allocates the necessary buffer | |
2759 | + * for the log, fills the buffer from the in-memory log for this vport, and then | |
2760 | + * returns a pointer to that log in the private_data field in @file. | |
2761 | + * | |
2762 | + * Returns: | |
2763 | + * This function returns zero if successful. On error it will return an negative | |
2764 | + * error value. | |
2765 | + **/ | |
2766 | static int | |
2767 | lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file) | |
2768 | { | |
2769 | @@ -703,7 +891,7 @@ lpfc_debugfs_dumpHostSlim_open(struct in | |
2770 | if (!debug) | |
2771 | goto out; | |
2772 | ||
2773 | - /* Round to page boundry */ | |
2774 | + /* Round to page boundary */ | |
2775 | debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL); | |
2776 | if (!debug->buffer) { | |
2777 | kfree(debug); | |
2778 | @@ -719,6 +907,21 @@ out: | |
2779 | return rc; | |
2780 | } | |
2781 | ||
2782 | +/** | |
2783 | + * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file. | |
2784 | + * @inode: The inode pointer that contains a vport pointer. | |
2785 | + * @file: The file pointer to attach the log output. | |
2786 | + * | |
2787 | + * Description: | |
2788 | + * This routine is the entry point for the debugfs open file operation. It gets | |
2789 | + * the vport from the i_private field in @inode, allocates the necessary buffer | |
2790 | + * for the log, fills the buffer from the in-memory log for this vport, and then | |
2791 | + * returns a pointer to that log in the private_data field in @file. | |
2792 | + * | |
2793 | + * Returns: | |
2794 | + * This function returns zero if successful. On error it will return an negative | |
2795 | + * error value. | |
2796 | + **/ | |
2797 | static int | |
2798 | lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file) | |
2799 | { | |
2800 | @@ -730,7 +933,7 @@ lpfc_debugfs_nodelist_open(struct inode | |
2801 | if (!debug) | |
2802 | goto out; | |
2803 | ||
2804 | - /* Round to page boundry */ | |
2805 | + /* Round to page boundary */ | |
2806 | debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL); | |
2807 | if (!debug->buffer) { | |
2808 | kfree(debug); | |
2809 | @@ -746,6 +949,23 @@ out: | |
2810 | return rc; | |
2811 | } | |
2812 | ||
2813 | +/** | |
2814 | + * lpfc_debugfs_lseek - Seek through a debugfs file. | |
2815 | + * @file: The file pointer to seek through. | |
2816 | + * @off: The offset to seek to or the amount to seek by. | |
2817 | + * @whence: Indicates how to seek. | |
2818 | + * | |
2819 | + * Description: | |
2820 | + * This routine is the entry point for the debugfs lseek file operation. The | |
2821 | + * @whence parameter indicates whether @off is the offset to directly seek to, | |
2822 | + * or if it is a value to seek forward or reverse by. This function figures out | |
2823 | + * what the new offset of the debugfs file will be and assigns that value to the | |
2824 | + * f_pos field of @file. | |
2825 | + * | |
2826 | + * Returns: | |
2827 | + * This function returns the new offset if successful and returns a negative | |
2828 | + * error if unable to process the seek. | |
2829 | + **/ | |
2830 | static loff_t | |
2831 | lpfc_debugfs_lseek(struct file *file, loff_t off, int whence) | |
2832 | { | |
2833 | @@ -767,6 +987,22 @@ lpfc_debugfs_lseek(struct file *file, lo | |
2834 | return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos); | |
2835 | } | |
2836 | ||
2837 | +/** | |
2838 | + * lpfc_debugfs_read - Read a debugfs file. | |
2839 | + * @file: The file pointer to read from. | |
2840 | + * @buf: The buffer to copy the data to. | |
2841 | + * @nbytes: The number of bytes to read. | |
2842 | + * @ppos: The position in the file to start reading from. | |
2843 | + * | |
2844 | + * Description: | |
2845 | + * This routine reads data from from the buffer indicated in the private_data | |
2846 | + * field of @file. It will start reading at @ppos and copy up to @nbytes of | |
2847 | + * data to @buf. | |
2848 | + * | |
2849 | + * Returns: | |
2850 | + * This function returns the amount of data that was read (this could be less | |
2851 | + * than @nbytes if the end of the file was reached) or a negative error value. | |
2852 | + **/ | |
2853 | static ssize_t | |
2854 | lpfc_debugfs_read(struct file *file, char __user *buf, | |
2855 | size_t nbytes, loff_t *ppos) | |
2856 | @@ -776,6 +1012,18 @@ lpfc_debugfs_read(struct file *file, cha | |
2857 | debug->len); | |
2858 | } | |
2859 | ||
2860 | +/** | |
2861 | + * lpfc_debugfs_release - Release the buffer used to store debugfs file data. | |
2862 | + * @inode: The inode pointer that contains a vport pointer. (unused) | |
2863 | + * @file: The file pointer that contains the buffer to release. | |
2864 | + * | |
2865 | + * Description: | |
2866 | + * This routine frees the buffer that was allocated when the debugfs file was | |
2867 | + * opened. | |
2868 | + * | |
2869 | + * Returns: | |
2870 | + * This function returns zero. | |
2871 | + **/ | |
2872 | static int | |
2873 | lpfc_debugfs_release(struct inode *inode, struct file *file) | |
2874 | { | |
2875 | @@ -845,6 +1093,16 @@ static struct dentry *lpfc_debugfs_root | |
2876 | static atomic_t lpfc_debugfs_hba_count; | |
2877 | #endif | |
2878 | ||
2879 | +/** | |
2880 | + * lpfc_debugfs_initialize - Initialize debugfs for a vport. | |
2881 | + * @vport: The vport pointer to initialize. | |
2882 | + * | |
2883 | + * Description: | |
2884 | + * When Debugfs is configured this routine sets up the lpfc debugfs file system. | |
2885 | + * If not already created, this routine will create the lpfc directory, and | |
2886 | + * lpfcX directory (for this HBA), and vportX directory for this vport. It will | |
2887 | + * also create each file used to access lpfc specific debugfs information. | |
2888 | + **/ | |
2889 | inline void | |
2890 | lpfc_debugfs_initialize(struct lpfc_vport *vport) | |
2891 | { | |
2892 | @@ -862,7 +1120,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2893 | atomic_set(&lpfc_debugfs_hba_count, 0); | |
2894 | if (!lpfc_debugfs_root) { | |
2895 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2896 | - "0409 Cannot create debugfs root\n"); | |
2897 | + "0408 Cannot create debugfs root\n"); | |
2898 | goto debug_failed; | |
2899 | } | |
2900 | } | |
2901 | @@ -876,7 +1134,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2902 | debugfs_create_dir(name, lpfc_debugfs_root); | |
2903 | if (!phba->hba_debugfs_root) { | |
2904 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2905 | - "0409 Cannot create debugfs hba\n"); | |
2906 | + "0412 Cannot create debugfs hba\n"); | |
2907 | goto debug_failed; | |
2908 | } | |
2909 | atomic_inc(&lpfc_debugfs_hba_count); | |
2910 | @@ -890,7 +1148,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2911 | phba, &lpfc_debugfs_op_hbqinfo); | |
2912 | if (!phba->debug_hbqinfo) { | |
2913 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2914 | - "0409 Cannot create debugfs hbqinfo\n"); | |
2915 | + "0411 Cannot create debugfs hbqinfo\n"); | |
2916 | goto debug_failed; | |
2917 | } | |
2918 | ||
2919 | @@ -902,7 +1160,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2920 | phba, &lpfc_debugfs_op_dumpHBASlim); | |
2921 | if (!phba->debug_dumpHBASlim) { | |
2922 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2923 | - "0409 Cannot create debugfs dumpHBASlim\n"); | |
2924 | + "0413 Cannot create debugfs dumpHBASlim\n"); | |
2925 | goto debug_failed; | |
2926 | } | |
2927 | ||
2928 | @@ -914,7 +1172,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2929 | phba, &lpfc_debugfs_op_dumpHostSlim); | |
2930 | if (!phba->debug_dumpHostSlim) { | |
2931 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2932 | - "0409 Cannot create debugfs dumpHostSlim\n"); | |
2933 | + "0414 Cannot create debugfs dumpHostSlim\n"); | |
2934 | goto debug_failed; | |
2935 | } | |
2936 | ||
2937 | @@ -944,7 +1202,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2938 | phba, &lpfc_debugfs_op_slow_ring_trc); | |
2939 | if (!phba->debug_slow_ring_trc) { | |
2940 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2941 | - "0409 Cannot create debugfs " | |
2942 | + "0415 Cannot create debugfs " | |
2943 | "slow_ring_trace\n"); | |
2944 | goto debug_failed; | |
2945 | } | |
2946 | @@ -955,7 +1213,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2947 | GFP_KERNEL); | |
2948 | if (!phba->slow_ring_trc) { | |
2949 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2950 | - "0409 Cannot create debugfs " | |
2951 | + "0416 Cannot create debugfs " | |
2952 | "slow_ring buffer\n"); | |
2953 | goto debug_failed; | |
2954 | } | |
2955 | @@ -972,7 +1230,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2956 | debugfs_create_dir(name, phba->hba_debugfs_root); | |
2957 | if (!vport->vport_debugfs_root) { | |
2958 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2959 | - "0409 Cant create debugfs"); | |
2960 | + "0417 Cant create debugfs"); | |
2961 | goto debug_failed; | |
2962 | } | |
2963 | atomic_inc(&phba->debugfs_vport_count); | |
2964 | @@ -1001,7 +1259,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2965 | ||
2966 | if (!vport->disc_trc) { | |
2967 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2968 | - "0409 Cannot create debugfs disc trace " | |
2969 | + "0418 Cannot create debugfs disc trace " | |
2970 | "buffer\n"); | |
2971 | goto debug_failed; | |
2972 | } | |
2973 | @@ -1014,7 +1272,7 @@ lpfc_debugfs_initialize(struct lpfc_vpor | |
2974 | vport, &lpfc_debugfs_op_disc_trc); | |
2975 | if (!vport->debug_disc_trc) { | |
2976 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, | |
2977 | - "0409 Cannot create debugfs " | |
2978 | + "0419 Cannot create debugfs " | |
2979 | "discovery_trace\n"); | |
2980 | goto debug_failed; | |
2981 | } | |
2982 | @@ -1033,7 +1291,17 @@ debug_failed: | |
2983 | #endif | |
2984 | } | |
2985 | ||
2986 | - | |
2987 | +/** | |
2988 | + * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport. | |
2989 | + * @vport: The vport pointer to remove from debugfs. | |
2990 | + * | |
2991 | + * Description: | |
2992 | + * When Debugfs is configured this routine removes debugfs file system elements | |
2993 | + * that are specific to this vport. It also checks to see if there are any | |
2994 | + * users left for the debugfs directories associated with the HBA and driver. If | |
2995 | + * this is the last user of the HBA directory or driver directory then it will | |
2996 | + * remove those from the debugfs infrastructure as well. | |
2997 | + **/ | |
2998 | inline void | |
2999 | lpfc_debugfs_terminate(struct lpfc_vport *vport) | |
3000 | { | |
3001 | @@ -1096,5 +1364,3 @@ lpfc_debugfs_terminate(struct lpfc_vport | |
3002 | #endif | |
3003 | return; | |
3004 | } | |
3005 | - | |
3006 | - | |
3007 | --- a/drivers/scsi/lpfc/lpfc_disc.h | |
3008 | +++ b/drivers/scsi/lpfc/lpfc_disc.h | |
3009 | @@ -37,6 +37,7 @@ enum lpfc_work_type { | |
3010 | LPFC_EVT_KILL, | |
3011 | LPFC_EVT_ELS_RETRY, | |
3012 | LPFC_EVT_DEV_LOSS, | |
3013 | + LPFC_EVT_FASTPATH_MGMT_EVT, | |
3014 | }; | |
3015 | ||
3016 | /* structure used to queue event to the discovery tasklet */ | |
3017 | @@ -47,6 +48,24 @@ struct lpfc_work_evt { | |
3018 | enum lpfc_work_type evt; | |
3019 | }; | |
3020 | ||
3021 | +struct lpfc_scsi_check_condition_event; | |
3022 | +struct lpfc_scsi_varqueuedepth_event; | |
3023 | +struct lpfc_scsi_event_header; | |
3024 | +struct lpfc_fabric_event_header; | |
3025 | +struct lpfc_fcprdchkerr_event; | |
3026 | + | |
3027 | +/* structure used for sending events from fast path */ | |
3028 | +struct lpfc_fast_path_event { | |
3029 | + struct lpfc_work_evt work_evt; | |
3030 | + struct lpfc_vport *vport; | |
3031 | + union { | |
3032 | + struct lpfc_scsi_check_condition_event check_cond_evt; | |
3033 | + struct lpfc_scsi_varqueuedepth_event queue_depth_evt; | |
3034 | + struct lpfc_scsi_event_header scsi_evt; | |
3035 | + struct lpfc_fabric_event_header fabric_evt; | |
3036 | + struct lpfc_fcprdchkerr_event read_check_error; | |
3037 | + } un; | |
3038 | +}; | |
3039 | ||
3040 | struct lpfc_nodelist { | |
3041 | struct list_head nlp_listp; | |
3042 | @@ -88,6 +107,10 @@ struct lpfc_nodelist { | |
3043 | unsigned long last_ramp_up_time; /* jiffy of last ramp up */ | |
3044 | unsigned long last_q_full_time; /* jiffy of last queue full */ | |
3045 | struct kref kref; | |
3046 | + atomic_t cmd_pending; | |
3047 | + uint32_t cmd_qdepth; | |
3048 | + unsigned long last_change_time; | |
3049 | + struct lpfc_scsicmd_bkt *lat_data; /* Latency data */ | |
3050 | }; | |
3051 | ||
3052 | /* Defines for nlp_flag (uint32) */ | |
3053 | --- a/drivers/scsi/lpfc/lpfc_els.c | |
3054 | +++ b/drivers/scsi/lpfc/lpfc_els.c | |
3055 | @@ -30,6 +30,7 @@ | |
3056 | ||
3057 | #include "lpfc_hw.h" | |
3058 | #include "lpfc_sli.h" | |
3059 | +#include "lpfc_nl.h" | |
3060 | #include "lpfc_disc.h" | |
3061 | #include "lpfc_scsi.h" | |
3062 | #include "lpfc.h" | |
3063 | @@ -53,6 +54,28 @@ static void lpfc_register_new_vport(stru | |
3064 | ||
3065 | static int lpfc_max_els_tries = 3; | |
3066 | ||
3067 | +/** | |
3068 | + * lpfc_els_chk_latt: Check host link attention event for a vport. | |
3069 | + * @vport: pointer to a host virtual N_Port data structure. | |
3070 | + * | |
3071 | + * This routine checks whether there is an outstanding host link | |
3072 | + * attention event during the discovery process with the @vport. It is done | |
3073 | + * by reading the HBA's Host Attention (HA) register. If there is any host | |
3074 | + * link attention events during this @vport's discovery process, the @vport | |
3075 | + * shall be marked as FC_ABORT_DISCOVERY, a host link attention clear shall | |
3076 | + * be issued if the link state is not already in host link cleared state, | |
3077 | + * and a return code shall indicate whether the host link attention event | |
3078 | + * had happened. | |
3079 | + * | |
3080 | + * Note that, if either the host link is in state LPFC_LINK_DOWN or @vport | |
3081 | + * state in LPFC_VPORT_READY, the request for checking host link attention | |
3082 | + * event will be ignored and a return code shall indicate no host link | |
3083 | + * attention event had happened. | |
3084 | + * | |
3085 | + * Return codes | |
3086 | + * 0 - no host link attention event happened | |
3087 | + * 1 - host link attention event happened | |
3088 | + **/ | |
3089 | int | |
3090 | lpfc_els_chk_latt(struct lpfc_vport *vport) | |
3091 | { | |
3092 | @@ -92,6 +115,34 @@ lpfc_els_chk_latt(struct lpfc_vport *vpo | |
3093 | return 1; | |
3094 | } | |
3095 | ||
3096 | +/** | |
3097 | + * lpfc_prep_els_iocb: Allocate and prepare a lpfc iocb data structure. | |
3098 | + * @vport: pointer to a host virtual N_Port data structure. | |
3099 | + * @expectRsp: flag indicating whether response is expected. | |
3100 | + * @cmdSize: size of the ELS command. | |
3101 | + * @retry: number of retries to the command IOCB when it fails. | |
3102 | + * @ndlp: pointer to a node-list data structure. | |
3103 | + * @did: destination identifier. | |
3104 | + * @elscmd: the ELS command code. | |
3105 | + * | |
3106 | + * This routine is used for allocating a lpfc-IOCB data structure from | |
3107 | + * the driver lpfc-IOCB free-list and prepare the IOCB with the parameters | |
3108 | + * passed into the routine for discovery state machine to issue an Extended | |
3109 | + * Link Service (ELS) commands. It is a generic lpfc-IOCB allocation | |
3110 | + * and preparation routine that is used by all the discovery state machine | |
3111 | + * routines and the ELS command-specific fields will be later set up by | |
3112 | + * the individual discovery machine routines after calling this routine | |
3113 | + * allocating and preparing a generic IOCB data structure. It fills in the | |
3114 | + * Buffer Descriptor Entries (BDEs), allocates buffers for both command | |
3115 | + * payload and response payload (if expected). The reference count on the | |
3116 | + * ndlp is incremented by 1 and the reference to the ndlp is put into | |
3117 | + * context1 of the IOCB data structure for this IOCB to hold the ndlp | |
3118 | + * reference for the command's callback function to access later. | |
3119 | + * | |
3120 | + * Return code | |
3121 | + * Pointer to the newly allocated/prepared els iocb data structure | |
3122 | + * NULL - when els iocb data structure allocation/preparation failed | |
3123 | + **/ | |
3124 | static struct lpfc_iocbq * | |
3125 | lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, | |
3126 | uint16_t cmdSize, uint8_t retry, | |
3127 | @@ -150,7 +201,7 @@ lpfc_prep_els_iocb(struct lpfc_vport *vp | |
3128 | ||
3129 | icmd->un.elsreq64.bdl.addrHigh = putPaddrHigh(pbuflist->phys); | |
3130 | icmd->un.elsreq64.bdl.addrLow = putPaddrLow(pbuflist->phys); | |
3131 | - icmd->un.elsreq64.bdl.bdeFlags = BUFF_TYPE_BDL; | |
3132 | + icmd->un.elsreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; | |
3133 | icmd->un.elsreq64.remoteID = did; /* DID */ | |
3134 | if (expectRsp) { | |
3135 | icmd->un.elsreq64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64)); | |
3136 | @@ -185,7 +236,7 @@ lpfc_prep_els_iocb(struct lpfc_vport *vp | |
3137 | bpl->addrLow = le32_to_cpu(putPaddrLow(prsp->phys)); | |
3138 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(prsp->phys)); | |
3139 | bpl->tus.f.bdeSize = FCELSSIZE; | |
3140 | - bpl->tus.f.bdeFlags = BUFF_USE_RCV; | |
3141 | + bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64; | |
3142 | bpl->tus.w = le32_to_cpu(bpl->tus.w); | |
3143 | } | |
3144 | ||
3145 | @@ -233,6 +284,22 @@ els_iocb_free_pcmb_exit: | |
3146 | return NULL; | |
3147 | } | |
3148 | ||
3149 | +/** | |
3150 | + * lpfc_issue_fabric_reglogin: Issue fabric registration login for a vport. | |
3151 | + * @vport: pointer to a host virtual N_Port data structure. | |
3152 | + * | |
3153 | + * This routine issues a fabric registration login for a @vport. An | |
3154 | + * active ndlp node with Fabric_DID must already exist for this @vport. | |
3155 | + * The routine invokes two mailbox commands to carry out fabric registration | |
3156 | + * login through the HBA firmware: the first mailbox command requests the | |
3157 | + * HBA to perform link configuration for the @vport; and the second mailbox | |
3158 | + * command requests the HBA to perform the actual fabric registration login | |
3159 | + * with the @vport. | |
3160 | + * | |
3161 | + * Return code | |
3162 | + * 0 - successfully issued fabric registration login for @vport | |
3163 | + * -ENXIO -- failed to issue fabric registration login for @vport | |
3164 | + **/ | |
3165 | static int | |
3166 | lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) | |
3167 | { | |
3168 | @@ -313,6 +380,26 @@ fail: | |
3169 | return -ENXIO; | |
3170 | } | |
3171 | ||
3172 | +/** | |
3173 | + * lpfc_cmpl_els_flogi_fabric: Completion function for flogi to a fabric port. | |
3174 | + * @vport: pointer to a host virtual N_Port data structure. | |
3175 | + * @ndlp: pointer to a node-list data structure. | |
3176 | + * @sp: pointer to service parameter data structure. | |
3177 | + * @irsp: pointer to the IOCB within the lpfc response IOCB. | |
3178 | + * | |
3179 | + * This routine is invoked by the lpfc_cmpl_els_flogi() completion callback | |
3180 | + * function to handle the completion of a Fabric Login (FLOGI) into a fabric | |
3181 | + * port in a fabric topology. It properly sets up the parameters to the @ndlp | |
3182 | + * from the IOCB response. It also check the newly assigned N_Port ID to the | |
3183 | + * @vport against the previously assigned N_Port ID. If it is different from | |
3184 | + * the previously assigned Destination ID (DID), the lpfc_unreg_rpi() routine | |
3185 | + * is invoked on all the remaining nodes with the @vport to unregister the | |
3186 | + * Remote Port Indicators (RPIs). Finally, the lpfc_issue_fabric_reglogin() | |
3187 | + * is invoked to register login to the fabric. | |
3188 | + * | |
3189 | + * Return code | |
3190 | + * 0 - Success (currently, always return 0) | |
3191 | + **/ | |
3192 | static int | |
3193 | lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
3194 | struct serv_parm *sp, IOCB_t *irsp) | |
3195 | @@ -387,7 +474,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_v | |
3196 | */ | |
3197 | list_for_each_entry_safe(np, next_np, | |
3198 | &vport->fc_nodes, nlp_listp) { | |
3199 | - if (!NLP_CHK_NODE_ACT(ndlp)) | |
3200 | + if (!NLP_CHK_NODE_ACT(np)) | |
3201 | continue; | |
3202 | if ((np->nlp_state != NLP_STE_NPR_NODE) || | |
3203 | !(np->nlp_flag & NLP_NPR_ADISC)) | |
3204 | @@ -416,9 +503,26 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_v | |
3205 | return 0; | |
3206 | } | |
3207 | ||
3208 | -/* | |
3209 | - * We FLOGIed into an NPort, initiate pt2pt protocol | |
3210 | - */ | |
3211 | +/** | |
3212 | + * lpfc_cmpl_els_flogi_nport: Completion function for flogi to an N_Port. | |
3213 | + * @vport: pointer to a host virtual N_Port data structure. | |
3214 | + * @ndlp: pointer to a node-list data structure. | |
3215 | + * @sp: pointer to service parameter data structure. | |
3216 | + * | |
3217 | + * This routine is invoked by the lpfc_cmpl_els_flogi() completion callback | |
3218 | + * function to handle the completion of a Fabric Login (FLOGI) into an N_Port | |
3219 | + * in a point-to-point topology. First, the @vport's N_Port Name is compared | |
3220 | + * with the received N_Port Name: if the @vport's N_Port Name is greater than | |
3221 | + * the received N_Port Name lexicographically, this node shall assign local | |
3222 | + * N_Port ID (PT2PT_LocalID: 1) and remote N_Port ID (PT2PT_RemoteID: 2) and | |
3223 | + * will send out Port Login (PLOGI) with the N_Port IDs assigned. Otherwise, | |
3224 | + * this node shall just wait for the remote node to issue PLOGI and assign | |
3225 | + * N_Port IDs. | |
3226 | + * | |
3227 | + * Return code | |
3228 | + * 0 - Success | |
3229 | + * -ENXIO - Fail | |
3230 | + **/ | |
3231 | static int | |
3232 | lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
3233 | struct serv_parm *sp) | |
3234 | @@ -516,6 +620,29 @@ fail: | |
3235 | return -ENXIO; | |
3236 | } | |
3237 | ||
3238 | +/** | |
3239 | + * lpfc_cmpl_els_flogi: Completion callback function for flogi. | |
3240 | + * @phba: pointer to lpfc hba data structure. | |
3241 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
3242 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
3243 | + * | |
3244 | + * This routine is the top-level completion callback function for issuing | |
3245 | + * a Fabric Login (FLOGI) command. If the response IOCB reported error, | |
3246 | + * the lpfc_els_retry() routine shall be invoked to retry the FLOGI. If | |
3247 | + * retry has been made (either immediately or delayed with lpfc_els_retry() | |
3248 | + * returning 1), the command IOCB will be released and function returned. | |
3249 | + * If the retry attempt has been given up (possibly reach the maximum | |
3250 | + * number of retries), one additional decrement of ndlp reference shall be | |
3251 | + * invoked before going out after releasing the command IOCB. This will | |
3252 | + * actually release the remote node (Note, lpfc_els_free_iocb() will also | |
3253 | + * invoke one decrement of ndlp reference count). If no error reported in | |
3254 | + * the IOCB status, the command Port ID field is used to determine whether | |
3255 | + * this is a point-to-point topology or a fabric topology: if the Port ID | |
3256 | + * field is assigned, it is a fabric topology; otherwise, it is a | |
3257 | + * point-to-point topology. The routine lpfc_cmpl_els_flogi_fabric() or | |
3258 | + * lpfc_cmpl_els_flogi_nport() shall be invoked accordingly to handle the | |
3259 | + * specific topology completion conditions. | |
3260 | + **/ | |
3261 | static void | |
3262 | lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
3263 | struct lpfc_iocbq *rspiocb) | |
3264 | @@ -618,6 +745,28 @@ out: | |
3265 | lpfc_els_free_iocb(phba, cmdiocb); | |
3266 | } | |
3267 | ||
3268 | +/** | |
3269 | + * lpfc_issue_els_flogi: Issue an flogi iocb command for a vport. | |
3270 | + * @vport: pointer to a host virtual N_Port data structure. | |
3271 | + * @ndlp: pointer to a node-list data structure. | |
3272 | + * @retry: number of retries to the command IOCB. | |
3273 | + * | |
3274 | + * This routine issues a Fabric Login (FLOGI) Request ELS command | |
3275 | + * for a @vport. The initiator service parameters are put into the payload | |
3276 | + * of the FLOGI Request IOCB and the top-level callback function pointer | |
3277 | + * to lpfc_cmpl_els_flogi() routine is put to the IOCB completion callback | |
3278 | + * function field. The lpfc_issue_fabric_iocb routine is invoked to send | |
3279 | + * out FLOGI ELS command with one outstanding fabric IOCB at a time. | |
3280 | + * | |
3281 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
3282 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
3283 | + * will be stored into the context1 field of the IOCB for the completion | |
3284 | + * callback function to the FLOGI ELS command. | |
3285 | + * | |
3286 | + * Return code | |
3287 | + * 0 - successfully issued flogi iocb for @vport | |
3288 | + * 1 - failed to issue flogi iocb for @vport | |
3289 | + **/ | |
3290 | static int | |
3291 | lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
3292 | uint8_t retry) | |
3293 | @@ -694,6 +843,20 @@ lpfc_issue_els_flogi(struct lpfc_vport * | |
3294 | return 0; | |
3295 | } | |
3296 | ||
3297 | +/** | |
3298 | + * lpfc_els_abort_flogi: Abort all outstanding flogi iocbs. | |
3299 | + * @phba: pointer to lpfc hba data structure. | |
3300 | + * | |
3301 | + * This routine aborts all the outstanding Fabric Login (FLOGI) IOCBs | |
3302 | + * with a @phba. This routine walks all the outstanding IOCBs on the txcmplq | |
3303 | + * list and issues an abort IOCB commond on each outstanding IOCB that | |
3304 | + * contains a active Fabric_DID ndlp. Note that this function is to issue | |
3305 | + * the abort IOCB command on all the outstanding IOCBs, thus when this | |
3306 | + * function returns, it does not guarantee all the IOCBs are actually aborted. | |
3307 | + * | |
3308 | + * Return code | |
3309 | + * 0 - Sucessfully issued abort iocb on all outstanding flogis (Always 0) | |
3310 | + **/ | |
3311 | int | |
3312 | lpfc_els_abort_flogi(struct lpfc_hba *phba) | |
3313 | { | |
3314 | @@ -729,6 +892,22 @@ lpfc_els_abort_flogi(struct lpfc_hba *ph | |
3315 | return 0; | |
3316 | } | |
3317 | ||
3318 | +/** | |
3319 | + * lpfc_initial_flogi: Issue an initial fabric login for a vport. | |
3320 | + * @vport: pointer to a host virtual N_Port data structure. | |
3321 | + * | |
3322 | + * This routine issues an initial Fabric Login (FLOGI) for the @vport | |
3323 | + * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from | |
3324 | + * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and | |
3325 | + * put it into the @vport's ndlp list. If an inactive ndlp found on the list, | |
3326 | + * it will just be enabled and made active. The lpfc_issue_els_flogi() routine | |
3327 | + * is then invoked with the @vport and the ndlp to perform the FLOGI for the | |
3328 | + * @vport. | |
3329 | + * | |
3330 | + * Return code | |
3331 | + * 0 - failed to issue initial flogi for @vport | |
3332 | + * 1 - successfully issued initial flogi for @vport | |
3333 | + **/ | |
3334 | int | |
3335 | lpfc_initial_flogi(struct lpfc_vport *vport) | |
3336 | { | |
3337 | @@ -764,6 +943,22 @@ lpfc_initial_flogi(struct lpfc_vport *vp | |
3338 | return 1; | |
3339 | } | |
3340 | ||
3341 | +/** | |
3342 | + * lpfc_initial_fdisc: Issue an initial fabric discovery for a vport. | |
3343 | + * @vport: pointer to a host virtual N_Port data structure. | |
3344 | + * | |
3345 | + * This routine issues an initial Fabric Discover (FDISC) for the @vport | |
3346 | + * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from | |
3347 | + * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and | |
3348 | + * put it into the @vport's ndlp list. If an inactive ndlp found on the list, | |
3349 | + * it will just be enabled and made active. The lpfc_issue_els_fdisc() routine | |
3350 | + * is then invoked with the @vport and the ndlp to perform the FDISC for the | |
3351 | + * @vport. | |
3352 | + * | |
3353 | + * Return code | |
3354 | + * 0 - failed to issue initial fdisc for @vport | |
3355 | + * 1 - successfully issued initial fdisc for @vport | |
3356 | + **/ | |
3357 | int | |
3358 | lpfc_initial_fdisc(struct lpfc_vport *vport) | |
3359 | { | |
3360 | @@ -797,6 +992,17 @@ lpfc_initial_fdisc(struct lpfc_vport *vp | |
3361 | return 1; | |
3362 | } | |
3363 | ||
3364 | +/** | |
3365 | + * lpfc_more_plogi: Check and issue remaining plogis for a vport. | |
3366 | + * @vport: pointer to a host virtual N_Port data structure. | |
3367 | + * | |
3368 | + * This routine checks whether there are more remaining Port Logins | |
3369 | + * (PLOGI) to be issued for the @vport. If so, it will invoke the routine | |
3370 | + * lpfc_els_disc_plogi() to go through the Node Port Recovery (NPR) nodes | |
3371 | + * to issue ELS PLOGIs up to the configured discover threads with the | |
3372 | + * @vport (@vport->cfg_discovery_threads). The function also decrement | |
3373 | + * the @vport's num_disc_node by 1 if it is not already 0. | |
3374 | + **/ | |
3375 | void | |
3376 | lpfc_more_plogi(struct lpfc_vport *vport) | |
3377 | { | |
3378 | @@ -819,6 +1025,37 @@ lpfc_more_plogi(struct lpfc_vport *vport | |
3379 | return; | |
3380 | } | |
3381 | ||
3382 | +/** | |
3383 | + * lpfc_plogi_confirm_nport: Confirm pologi wwpn matches stored ndlp. | |
3384 | + * @phba: pointer to lpfc hba data structure. | |
3385 | + * @prsp: pointer to response IOCB payload. | |
3386 | + * @ndlp: pointer to a node-list data structure. | |
3387 | + * | |
3388 | + * This routine checks and indicates whether the WWPN of an N_Port, retrieved | |
3389 | + * from a PLOGI, matches the WWPN that is stored in the @ndlp for that N_POrt. | |
3390 | + * The following cases are considered N_Port confirmed: | |
3391 | + * 1) The N_Port is a Fabric ndlp; 2) The @ndlp is on vport list and matches | |
3392 | + * the WWPN of the N_Port logged into; 3) The @ndlp is not on vport list but | |
3393 | + * it does not have WWPN assigned either. If the WWPN is confirmed, the | |
3394 | + * pointer to the @ndlp will be returned. If the WWPN is not confirmed: | |
3395 | + * 1) if there is a node on vport list other than the @ndlp with the same | |
3396 | + * WWPN of the N_Port PLOGI logged into, the lpfc_unreg_rpi() will be invoked | |
3397 | + * on that node to release the RPI associated with the node; 2) if there is | |
3398 | + * no node found on vport list with the same WWPN of the N_Port PLOGI logged | |
3399 | + * into, a new node shall be allocated (or activated). In either case, the | |
3400 | + * parameters of the @ndlp shall be copied to the new_ndlp, the @ndlp shall | |
3401 | + * be released and the new_ndlp shall be put on to the vport node list and | |
3402 | + * its pointer returned as the confirmed node. | |
3403 | + * | |
3404 | + * Note that before the @ndlp got "released", the keepDID from not-matching | |
3405 | + * or inactive "new_ndlp" on the vport node list is assigned to the nlp_DID | |
3406 | + * of the @ndlp. This is because the release of @ndlp is actually to put it | |
3407 | + * into an inactive state on the vport node list and the vport node list | |
3408 | + * management algorithm does not allow two node with a same DID. | |
3409 | + * | |
3410 | + * Return code | |
3411 | + * pointer to the PLOGI N_Port @ndlp | |
3412 | + **/ | |
3413 | static struct lpfc_nodelist * | |
3414 | lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, | |
3415 | struct lpfc_nodelist *ndlp) | |
3416 | @@ -922,6 +1159,17 @@ lpfc_plogi_confirm_nport(struct lpfc_hba | |
3417 | return new_ndlp; | |
3418 | } | |
3419 | ||
3420 | +/** | |
3421 | + * lpfc_end_rscn: Check and handle more rscn for a vport. | |
3422 | + * @vport: pointer to a host virtual N_Port data structure. | |
3423 | + * | |
3424 | + * This routine checks whether more Registration State Change | |
3425 | + * Notifications (RSCNs) came in while the discovery state machine was in | |
3426 | + * the FC_RSCN_MODE. If so, the lpfc_els_handle_rscn() routine will be | |
3427 | + * invoked to handle the additional RSCNs for the @vport. Otherwise, the | |
3428 | + * FC_RSCN_MODE bit will be cleared with the @vport to mark as the end of | |
3429 | + * handling the RSCNs. | |
3430 | + **/ | |
3431 | void | |
3432 | lpfc_end_rscn(struct lpfc_vport *vport) | |
3433 | { | |
3434 | @@ -943,6 +1191,26 @@ lpfc_end_rscn(struct lpfc_vport *vport) | |
3435 | } | |
3436 | } | |
3437 | ||
3438 | +/** | |
3439 | + * lpfc_cmpl_els_plogi: Completion callback function for plogi. | |
3440 | + * @phba: pointer to lpfc hba data structure. | |
3441 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
3442 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
3443 | + * | |
3444 | + * This routine is the completion callback function for issuing the Port | |
3445 | + * Login (PLOGI) command. For PLOGI completion, there must be an active | |
3446 | + * ndlp on the vport node list that matches the remote node ID from the | |
3447 | + * PLOGI reponse IOCB. If such ndlp does not exist, the PLOGI is simply | |
3448 | + * ignored and command IOCB released. The PLOGI response IOCB status is | |
3449 | + * checked for error conditons. If there is error status reported, PLOGI | |
3450 | + * retry shall be attempted by invoking the lpfc_els_retry() routine. | |
3451 | + * Otherwise, the lpfc_plogi_confirm_nport() routine shall be invoked on | |
3452 | + * the ndlp and the NLP_EVT_CMPL_PLOGI state to the Discover State Machine | |
3453 | + * (DSM) is set for this PLOGI completion. Finally, it checks whether | |
3454 | + * there are additional N_Port nodes with the vport that need to perform | |
3455 | + * PLOGI. If so, the lpfc_more_plogi() routine is invoked to issue addition | |
3456 | + * PLOGIs. | |
3457 | + **/ | |
3458 | static void | |
3459 | lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
3460 | struct lpfc_iocbq *rspiocb) | |
3461 | @@ -1048,6 +1316,27 @@ out: | |
3462 | return; | |
3463 | } | |
3464 | ||
3465 | +/** | |
3466 | + * lpfc_issue_els_plogi: Issue an plogi iocb command for a vport. | |
3467 | + * @vport: pointer to a host virtual N_Port data structure. | |
3468 | + * @did: destination port identifier. | |
3469 | + * @retry: number of retries to the command IOCB. | |
3470 | + * | |
3471 | + * This routine issues a Port Login (PLOGI) command to a remote N_Port | |
3472 | + * (with the @did) for a @vport. Before issuing a PLOGI to a remote N_Port, | |
3473 | + * the ndlp with the remote N_Port DID must exist on the @vport's ndlp list. | |
3474 | + * This routine constructs the proper feilds of the PLOGI IOCB and invokes | |
3475 | + * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command. | |
3476 | + * | |
3477 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
3478 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
3479 | + * will be stored into the context1 field of the IOCB for the completion | |
3480 | + * callback function to the PLOGI ELS command. | |
3481 | + * | |
3482 | + * Return code | |
3483 | + * 0 - Successfully issued a plogi for @vport | |
3484 | + * 1 - failed to issue a plogi for @vport | |
3485 | + **/ | |
3486 | int | |
3487 | lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) | |
3488 | { | |
3489 | @@ -1106,6 +1395,19 @@ lpfc_issue_els_plogi(struct lpfc_vport * | |
3490 | return 0; | |
3491 | } | |
3492 | ||
3493 | +/** | |
3494 | + * lpfc_cmpl_els_prli: Completion callback function for prli. | |
3495 | + * @phba: pointer to lpfc hba data structure. | |
3496 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
3497 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
3498 | + * | |
3499 | + * This routine is the completion callback function for a Process Login | |
3500 | + * (PRLI) ELS command. The PRLI response IOCB status is checked for error | |
3501 | + * status. If there is error status reported, PRLI retry shall be attempted | |
3502 | + * by invoking the lpfc_els_retry() routine. Otherwise, the state | |
3503 | + * NLP_EVT_CMPL_PRLI is sent to the Discover State Machine (DSM) for this | |
3504 | + * ndlp to mark the PRLI completion. | |
3505 | + **/ | |
3506 | static void | |
3507 | lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
3508 | struct lpfc_iocbq *rspiocb) | |
3509 | @@ -1164,6 +1466,27 @@ out: | |
3510 | return; | |
3511 | } | |
3512 | ||
3513 | +/** | |
3514 | + * lpfc_issue_els_prli: Issue a prli iocb command for a vport. | |
3515 | + * @vport: pointer to a host virtual N_Port data structure. | |
3516 | + * @ndlp: pointer to a node-list data structure. | |
3517 | + * @retry: number of retries to the command IOCB. | |
3518 | + * | |
3519 | + * This routine issues a Process Login (PRLI) ELS command for the | |
3520 | + * @vport. The PRLI service parameters are set up in the payload of the | |
3521 | + * PRLI Request command and the pointer to lpfc_cmpl_els_prli() routine | |
3522 | + * is put to the IOCB completion callback func field before invoking the | |
3523 | + * routine lpfc_sli_issue_iocb() to send out PRLI command. | |
3524 | + * | |
3525 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
3526 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
3527 | + * will be stored into the context1 field of the IOCB for the completion | |
3528 | + * callback function to the PRLI ELS command. | |
3529 | + * | |
3530 | + * Return code | |
3531 | + * 0 - successfully issued prli iocb command for @vport | |
3532 | + * 1 - failed to issue prli iocb command for @vport | |
3533 | + **/ | |
3534 | int | |
3535 | lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
3536 | uint8_t retry) | |
3537 | @@ -1233,6 +1556,92 @@ lpfc_issue_els_prli(struct lpfc_vport *v | |
3538 | return 0; | |
3539 | } | |
3540 | ||
3541 | +/** | |
3542 | + * lpfc_rscn_disc: Perform rscn discovery for a vport. | |
3543 | + * @vport: pointer to a host virtual N_Port data structure. | |
3544 | + * | |
3545 | + * This routine performs Registration State Change Notification (RSCN) | |
3546 | + * discovery for a @vport. If the @vport's node port recovery count is not | |
3547 | + * zero, it will invoke the lpfc_els_disc_plogi() to perform PLOGI for all | |
3548 | + * the nodes that need recovery. If none of the PLOGI were needed through | |
3549 | + * the lpfc_els_disc_plogi() routine, the lpfc_end_rscn() routine shall be | |
3550 | + * invoked to check and handle possible more RSCN came in during the period | |
3551 | + * of processing the current ones. | |
3552 | + **/ | |
3553 | +static void | |
3554 | +lpfc_rscn_disc(struct lpfc_vport *vport) | |
3555 | +{ | |
3556 | + lpfc_can_disctmo(vport); | |
3557 | + | |
3558 | + /* RSCN discovery */ | |
3559 | + /* go thru NPR nodes and issue ELS PLOGIs */ | |
3560 | + if (vport->fc_npr_cnt) | |
3561 | + if (lpfc_els_disc_plogi(vport)) | |
3562 | + return; | |
3563 | + | |
3564 | + lpfc_end_rscn(vport); | |
3565 | +} | |
3566 | + | |
3567 | +/** | |
3568 | + * lpfc_adisc_done: Complete the adisc phase of discovery. | |
3569 | + * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs. | |
3570 | + * | |
3571 | + * This function is called when the final ADISC is completed during discovery. | |
3572 | + * This function handles clearing link attention or issuing reg_vpi depending | |
3573 | + * on whether npiv is enabled. This function also kicks off the PLOGI phase of | |
3574 | + * discovery. | |
3575 | + * This function is called with no locks held. | |
3576 | + **/ | |
3577 | +static void | |
3578 | +lpfc_adisc_done(struct lpfc_vport *vport) | |
3579 | +{ | |
3580 | + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | |
3581 | + struct lpfc_hba *phba = vport->phba; | |
3582 | + | |
3583 | + /* | |
3584 | + * For NPIV, cmpl_reg_vpi will set port_state to READY, | |
3585 | + * and continue discovery. | |
3586 | + */ | |
3587 | + if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && | |
3588 | + !(vport->fc_flag & FC_RSCN_MODE)) { | |
3589 | + lpfc_issue_reg_vpi(phba, vport); | |
3590 | + return; | |
3591 | + } | |
3592 | + /* | |
3593 | + * For SLI2, we need to set port_state to READY | |
3594 | + * and continue discovery. | |
3595 | + */ | |
3596 | + if (vport->port_state < LPFC_VPORT_READY) { | |
3597 | + /* If we get here, there is nothing to ADISC */ | |
3598 | + if (vport->port_type == LPFC_PHYSICAL_PORT) | |
3599 | + lpfc_issue_clear_la(phba, vport); | |
3600 | + if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) { | |
3601 | + vport->num_disc_nodes = 0; | |
3602 | + /* go thru NPR list, issue ELS PLOGIs */ | |
3603 | + if (vport->fc_npr_cnt) | |
3604 | + lpfc_els_disc_plogi(vport); | |
3605 | + if (!vport->num_disc_nodes) { | |
3606 | + spin_lock_irq(shost->host_lock); | |
3607 | + vport->fc_flag &= ~FC_NDISC_ACTIVE; | |
3608 | + spin_unlock_irq(shost->host_lock); | |
3609 | + lpfc_can_disctmo(vport); | |
3610 | + lpfc_end_rscn(vport); | |
3611 | + } | |
3612 | + } | |
3613 | + vport->port_state = LPFC_VPORT_READY; | |
3614 | + } else | |
3615 | + lpfc_rscn_disc(vport); | |
3616 | +} | |
3617 | + | |
3618 | +/** | |
3619 | + * lpfc_more_adisc: Issue more adisc as needed. | |
3620 | + * @vport: pointer to a host virtual N_Port data structure. | |
3621 | + * | |
3622 | + * This routine determines whether there are more ndlps on a @vport | |
3623 | + * node list need to have Address Discover (ADISC) issued. If so, it will | |
3624 | + * invoke the lpfc_els_disc_adisc() routine to issue ADISC on the @vport's | |
3625 | + * remaining nodes which need to have ADISC sent. | |
3626 | + **/ | |
3627 | void | |
3628 | lpfc_more_adisc(struct lpfc_vport *vport) | |
3629 | { | |
3630 | @@ -1252,23 +1661,27 @@ lpfc_more_adisc(struct lpfc_vport *vport | |
3631 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ | |
3632 | sentadisc = lpfc_els_disc_adisc(vport); | |
3633 | } | |
3634 | + if (!vport->num_disc_nodes) | |
3635 | + lpfc_adisc_done(vport); | |
3636 | return; | |
3637 | } | |
3638 | ||
3639 | -static void | |
3640 | -lpfc_rscn_disc(struct lpfc_vport *vport) | |
3641 | -{ | |
3642 | - lpfc_can_disctmo(vport); | |
3643 | - | |
3644 | - /* RSCN discovery */ | |
3645 | - /* go thru NPR nodes and issue ELS PLOGIs */ | |
3646 | - if (vport->fc_npr_cnt) | |
3647 | - if (lpfc_els_disc_plogi(vport)) | |
3648 | - return; | |
3649 | - | |
3650 | - lpfc_end_rscn(vport); | |
3651 | -} | |
3652 | - | |
3653 | +/** | |
3654 | + * lpfc_cmpl_els_adisc: Completion callback function for adisc. | |
3655 | + * @phba: pointer to lpfc hba data structure. | |
3656 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
3657 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
3658 | + * | |
3659 | + * This routine is the completion function for issuing the Address Discover | |
3660 | + * (ADISC) command. It first checks to see whether link went down during | |
3661 | + * the discovery process. If so, the node will be marked as node port | |
3662 | + * recovery for issuing discover IOCB by the link attention handler and | |
3663 | + * exit. Otherwise, the response status is checked. If error was reported | |
3664 | + * in the response status, the ADISC command shall be retried by invoking | |
3665 | + * the lpfc_els_retry() routine. Otherwise, if no error was reported in | |
3666 | + * the response status, the state machine is invoked to set transition | |
3667 | + * with respect to NLP_EVT_CMPL_ADISC event. | |
3668 | + **/ | |
3669 | static void | |
3670 | lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
3671 | struct lpfc_iocbq *rspiocb) | |
3672 | @@ -1333,57 +1746,34 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phb | |
3673 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, | |
3674 | NLP_EVT_CMPL_ADISC); | |
3675 | ||
3676 | - if (disc && vport->num_disc_nodes) { | |
3677 | - /* Check to see if there are more ADISCs to be sent */ | |
3678 | + /* Check to see if there are more ADISCs to be sent */ | |
3679 | + if (disc && vport->num_disc_nodes) | |
3680 | lpfc_more_adisc(vport); | |
3681 | - | |
3682 | - /* Check to see if we are done with ADISC authentication */ | |
3683 | - if (vport->num_disc_nodes == 0) { | |
3684 | - /* If we get here, there is nothing left to ADISC */ | |
3685 | - /* | |
3686 | - * For NPIV, cmpl_reg_vpi will set port_state to READY, | |
3687 | - * and continue discovery. | |
3688 | - */ | |
3689 | - if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && | |
3690 | - !(vport->fc_flag & FC_RSCN_MODE)) { | |
3691 | - lpfc_issue_reg_vpi(phba, vport); | |
3692 | - goto out; | |
3693 | - } | |
3694 | - /* | |
3695 | - * For SLI2, we need to set port_state to READY | |
3696 | - * and continue discovery. | |
3697 | - */ | |
3698 | - if (vport->port_state < LPFC_VPORT_READY) { | |
3699 | - /* If we get here, there is nothing to ADISC */ | |
3700 | - if (vport->port_type == LPFC_PHYSICAL_PORT) | |
3701 | - lpfc_issue_clear_la(phba, vport); | |
3702 | - | |
3703 | - if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) { | |
3704 | - vport->num_disc_nodes = 0; | |
3705 | - /* go thru NPR list, issue ELS PLOGIs */ | |
3706 | - if (vport->fc_npr_cnt) | |
3707 | - lpfc_els_disc_plogi(vport); | |
3708 | - | |
3709 | - if (!vport->num_disc_nodes) { | |
3710 | - spin_lock_irq(shost->host_lock); | |
3711 | - vport->fc_flag &= | |
3712 | - ~FC_NDISC_ACTIVE; | |
3713 | - spin_unlock_irq( | |
3714 | - shost->host_lock); | |
3715 | - lpfc_can_disctmo(vport); | |
3716 | - } | |
3717 | - } | |
3718 | - vport->port_state = LPFC_VPORT_READY; | |
3719 | - } else { | |
3720 | - lpfc_rscn_disc(vport); | |
3721 | - } | |
3722 | - } | |
3723 | - } | |
3724 | out: | |
3725 | lpfc_els_free_iocb(phba, cmdiocb); | |
3726 | return; | |
3727 | } | |
3728 | ||
3729 | +/** | |
3730 | + * lpfc_issue_els_adisc: Issue an address discover iocb to an node on a vport. | |
3731 | + * @vport: pointer to a virtual N_Port data structure. | |
3732 | + * @ndlp: pointer to a node-list data structure. | |
3733 | + * @retry: number of retries to the command IOCB. | |
3734 | + * | |
3735 | + * This routine issues an Address Discover (ADISC) for an @ndlp on a | |
3736 | + * @vport. It prepares the payload of the ADISC ELS command, updates the | |
3737 | + * and states of the ndlp, and invokes the lpfc_sli_issue_iocb() routine | |
3738 | + * to issue the ADISC ELS command. | |
3739 | + * | |
3740 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
3741 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
3742 | + * will be stored into the context1 field of the IOCB for the completion | |
3743 | + * callback function to the ADISC ELS command. | |
3744 | + * | |
3745 | + * Return code | |
3746 | + * 0 - successfully issued adisc | |
3747 | + * 1 - failed to issue adisc | |
3748 | + **/ | |
3749 | int | |
3750 | lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
3751 | uint8_t retry) | |
3752 | @@ -1437,6 +1827,18 @@ lpfc_issue_els_adisc(struct lpfc_vport * | |
3753 | return 0; | |
3754 | } | |
3755 | ||
3756 | +/** | |
3757 | + * lpfc_cmpl_els_logo: Completion callback function for logo. | |
3758 | + * @phba: pointer to lpfc hba data structure. | |
3759 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
3760 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
3761 | + * | |
3762 | + * This routine is the completion function for issuing the ELS Logout (LOGO) | |
3763 | + * command. If no error status was reported from the LOGO response, the | |
3764 | + * state machine of the associated ndlp shall be invoked for transition with | |
3765 | + * respect to NLP_EVT_CMPL_LOGO event. Otherwise, if error status was reported, | |
3766 | + * the lpfc_els_retry() routine will be invoked to retry the LOGO command. | |
3767 | + **/ | |
3768 | static void | |
3769 | lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
3770 | struct lpfc_iocbq *rspiocb) | |
3771 | @@ -1502,6 +1904,26 @@ out: | |
3772 | return; | |
3773 | } | |
3774 | ||
3775 | +/** | |
3776 | + * lpfc_issue_els_logo: Issue a logo to an node on a vport. | |
3777 | + * @vport: pointer to a virtual N_Port data structure. | |
3778 | + * @ndlp: pointer to a node-list data structure. | |
3779 | + * @retry: number of retries to the command IOCB. | |
3780 | + * | |
3781 | + * This routine constructs and issues an ELS Logout (LOGO) iocb command | |
3782 | + * to a remote node, referred by an @ndlp on a @vport. It constructs the | |
3783 | + * payload of the IOCB, properly sets up the @ndlp state, and invokes the | |
3784 | + * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command. | |
3785 | + * | |
3786 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
3787 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
3788 | + * will be stored into the context1 field of the IOCB for the completion | |
3789 | + * callback function to the LOGO ELS command. | |
3790 | + * | |
3791 | + * Return code | |
3792 | + * 0 - successfully issued logo | |
3793 | + * 1 - failed to issue logo | |
3794 | + **/ | |
3795 | int | |
3796 | lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
3797 | uint8_t retry) | |
3798 | @@ -1563,6 +1985,22 @@ lpfc_issue_els_logo(struct lpfc_vport *v | |
3799 | return 0; | |
3800 | } | |
3801 | ||
3802 | +/** | |
3803 | + * lpfc_cmpl_els_cmd: Completion callback function for generic els command. | |
3804 | + * @phba: pointer to lpfc hba data structure. | |
3805 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
3806 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
3807 | + * | |
3808 | + * This routine is a generic completion callback function for ELS commands. | |
3809 | + * Specifically, it is the callback function which does not need to perform | |
3810 | + * any command specific operations. It is currently used by the ELS command | |
3811 | + * issuing routines for the ELS State Change Request (SCR), | |
3812 | + * lpfc_issue_els_scr(), and the ELS Fibre Channel Address Resolution | |
3813 | + * Protocol Response (FARPR) routine, lpfc_issue_els_farpr(). Other than | |
3814 | + * certain debug loggings, this callback function simply invokes the | |
3815 | + * lpfc_els_chk_latt() routine to check whether link went down during the | |
3816 | + * discovery process. | |
3817 | + **/ | |
3818 | static void | |
3819 | lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
3820 | struct lpfc_iocbq *rspiocb) | |
3821 | @@ -1587,6 +2025,28 @@ lpfc_cmpl_els_cmd(struct lpfc_hba *phba, | |
3822 | return; | |
3823 | } | |
3824 | ||
3825 | +/** | |
3826 | + * lpfc_issue_els_scr: Issue a scr to an node on a vport. | |
3827 | + * @vport: pointer to a host virtual N_Port data structure. | |
3828 | + * @nportid: N_Port identifier to the remote node. | |
3829 | + * @retry: number of retries to the command IOCB. | |
3830 | + * | |
3831 | + * This routine issues a State Change Request (SCR) to a fabric node | |
3832 | + * on a @vport. The remote node @nportid is passed into the function. It | |
3833 | + * first search the @vport node list to find the matching ndlp. If no such | |
3834 | + * ndlp is found, a new ndlp shall be created for this (SCR) purpose. An | |
3835 | + * IOCB is allocated, payload prepared, and the lpfc_sli_issue_iocb() | |
3836 | + * routine is invoked to send the SCR IOCB. | |
3837 | + * | |
3838 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
3839 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
3840 | + * will be stored into the context1 field of the IOCB for the completion | |
3841 | + * callback function to the SCR ELS command. | |
3842 | + * | |
3843 | + * Return code | |
3844 | + * 0 - Successfully issued scr command | |
3845 | + * 1 - Failed to issue scr command | |
3846 | + **/ | |
3847 | int | |
3848 | lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) | |
3849 | { | |
3850 | @@ -1659,6 +2119,28 @@ lpfc_issue_els_scr(struct lpfc_vport *vp | |
3851 | return 0; | |
3852 | } | |
3853 | ||
3854 | +/** | |
3855 | + * lpfc_issue_els_farpr: Issue a farp to an node on a vport. | |
3856 | + * @vport: pointer to a host virtual N_Port data structure. | |
3857 | + * @nportid: N_Port identifier to the remote node. | |
3858 | + * @retry: number of retries to the command IOCB. | |
3859 | + * | |
3860 | + * This routine issues a Fibre Channel Address Resolution Response | |
3861 | + * (FARPR) to a node on a vport. The remote node N_Port identifier (@nportid) | |
3862 | + * is passed into the function. It first search the @vport node list to find | |
3863 | + * the matching ndlp. If no such ndlp is found, a new ndlp shall be created | |
3864 | + * for this (FARPR) purpose. An IOCB is allocated, payload prepared, and the | |
3865 | + * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command. | |
3866 | + * | |
3867 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
3868 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
3869 | + * will be stored into the context1 field of the IOCB for the completion | |
3870 | + * callback function to the PARPR ELS command. | |
3871 | + * | |
3872 | + * Return code | |
3873 | + * 0 - Successfully issued farpr command | |
3874 | + * 1 - Failed to issue farpr command | |
3875 | + **/ | |
3876 | static int | |
3877 | lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) | |
3878 | { | |
3879 | @@ -1748,6 +2230,18 @@ lpfc_issue_els_farpr(struct lpfc_vport * | |
3880 | return 0; | |
3881 | } | |
3882 | ||
3883 | +/** | |
3884 | + * lpfc_cancel_retry_delay_tmo: Cancel the timer with delayed iocb-cmd retry. | |
3885 | + * @vport: pointer to a host virtual N_Port data structure. | |
3886 | + * @nlp: pointer to a node-list data structure. | |
3887 | + * | |
3888 | + * This routine cancels the timer with a delayed IOCB-command retry for | |
3889 | + * a @vport's @ndlp. It stops the timer for the delayed function retrial and | |
3890 | + * removes the ELS retry event if it presents. In addition, if the | |
3891 | + * NLP_NPR_2B_DISC bit is set in the @nlp's nlp_flag bitmap, ADISC IOCB | |
3892 | + * commands are sent for the @vport's nodes that require issuing discovery | |
3893 | + * ADISC. | |
3894 | + **/ | |
3895 | void | |
3896 | lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp) | |
3897 | { | |
3898 | @@ -1775,25 +2269,36 @@ lpfc_cancel_retry_delay_tmo(struct lpfc_ | |
3899 | if (vport->port_state < LPFC_VPORT_READY) { | |
3900 | /* Check if there are more ADISCs to be sent */ | |
3901 | lpfc_more_adisc(vport); | |
3902 | - if ((vport->num_disc_nodes == 0) && | |
3903 | - (vport->fc_npr_cnt)) | |
3904 | - lpfc_els_disc_plogi(vport); | |
3905 | } else { | |
3906 | /* Check if there are more PLOGIs to be sent */ | |
3907 | lpfc_more_plogi(vport); | |
3908 | - } | |
3909 | - if (vport->num_disc_nodes == 0) { | |
3910 | - spin_lock_irq(shost->host_lock); | |
3911 | - vport->fc_flag &= ~FC_NDISC_ACTIVE; | |
3912 | - spin_unlock_irq(shost->host_lock); | |
3913 | - lpfc_can_disctmo(vport); | |
3914 | - lpfc_end_rscn(vport); | |
3915 | + if (vport->num_disc_nodes == 0) { | |
3916 | + spin_lock_irq(shost->host_lock); | |
3917 | + vport->fc_flag &= ~FC_NDISC_ACTIVE; | |
3918 | + spin_unlock_irq(shost->host_lock); | |
3919 | + lpfc_can_disctmo(vport); | |
3920 | + lpfc_end_rscn(vport); | |
3921 | + } | |
3922 | } | |
3923 | } | |
3924 | } | |
3925 | return; | |
3926 | } | |
3927 | ||
3928 | +/** | |
3929 | + * lpfc_els_retry_delay: Timer function with a ndlp delayed function timer. | |
3930 | + * @ptr: holder for the pointer to the timer function associated data (ndlp). | |
3931 | + * | |
3932 | + * This routine is invoked by the ndlp delayed-function timer to check | |
3933 | + * whether there is any pending ELS retry event(s) with the node. If not, it | |
3934 | + * simply returns. Otherwise, if there is at least one ELS delayed event, it | |
3935 | + * adds the delayed events to the HBA work list and invokes the | |
3936 | + * lpfc_worker_wake_up() routine to wake up worker thread to process the | |
3937 | + * event. Note that lpfc_nlp_get() is called before posting the event to | |
3938 | + * the work list to hold reference count of ndlp so that it guarantees the | |
3939 | + * reference to ndlp will still be available when the worker thread gets | |
3940 | + * to the event associated with the ndlp. | |
3941 | + **/ | |
3942 | void | |
3943 | lpfc_els_retry_delay(unsigned long ptr) | |
3944 | { | |
3945 | @@ -1822,6 +2327,15 @@ lpfc_els_retry_delay(unsigned long ptr) | |
3946 | return; | |
3947 | } | |
3948 | ||
3949 | +/** | |
3950 | + * lpfc_els_retry_delay_handler: Work thread handler for ndlp delayed function. | |
3951 | + * @ndlp: pointer to a node-list data structure. | |
3952 | + * | |
3953 | + * This routine is the worker-thread handler for processing the @ndlp delayed | |
3954 | + * event(s), posted by the lpfc_els_retry_delay() routine. It simply retrieves | |
3955 | + * the last ELS command from the associated ndlp and invokes the proper ELS | |
3956 | + * function according to the delayed ELS command to retry the command. | |
3957 | + **/ | |
3958 | void | |
3959 | lpfc_els_retry_delay_handler(struct lpfc_nodelist *ndlp) | |
3960 | { | |
3961 | @@ -1884,6 +2398,27 @@ lpfc_els_retry_delay_handler(struct lpfc | |
3962 | return; | |
3963 | } | |
3964 | ||
3965 | +/** | |
3966 | + * lpfc_els_retry: Make retry decision on an els command iocb. | |
3967 | + * @phba: pointer to lpfc hba data structure. | |
3968 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
3969 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
3970 | + * | |
3971 | + * This routine makes a retry decision on an ELS command IOCB, which has | |
3972 | + * failed. The following ELS IOCBs use this function for retrying the command | |
3973 | + * when previously issued command responsed with error status: FLOGI, PLOGI, | |
3974 | + * PRLI, ADISC, LOGO, and FDISC. Based on the ELS command type and the | |
3975 | + * returned error status, it makes the decision whether a retry shall be | |
3976 | + * issued for the command, and whether a retry shall be made immediately or | |
3977 | + * delayed. In the former case, the corresponding ELS command issuing-function | |
3978 | + * is called to retry the command. In the later case, the ELS command shall | |
3979 | + * be posted to the ndlp delayed event and delayed function timer set to the | |
3980 | + * ndlp for the delayed command issusing. | |
3981 | + * | |
3982 | + * Return code | |
3983 | + * 0 - No retry of els command is made | |
3984 | + * 1 - Immediate or delayed retry of els command is made | |
3985 | + **/ | |
3986 | static int | |
3987 | lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
3988 | struct lpfc_iocbq *rspiocb) | |
3989 | @@ -2051,7 +2586,7 @@ lpfc_els_retry(struct lpfc_hba *phba, st | |
3990 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID)) | |
3991 | ) { | |
3992 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, | |
3993 | - "0123 FDISC Failed (x%x). " | |
3994 | + "0122 FDISC Failed (x%x). " | |
3995 | "Fabric Detected Bad WWN\n", | |
3996 | stat.un.lsRjtError); | |
3997 | lpfc_vport_set_state(vport, | |
3998 | @@ -2182,12 +2717,26 @@ lpfc_els_retry(struct lpfc_hba *phba, st | |
3999 | return 0; | |
4000 | } | |
4001 | ||
4002 | +/** | |
4003 | + * lpfc_els_free_data: Free lpfc dma buffer and data structure with an iocb. | |
4004 | + * @phba: pointer to lpfc hba data structure. | |
4005 | + * @buf_ptr1: pointer to the lpfc DMA buffer data structure. | |
4006 | + * | |
4007 | + * This routine releases the lpfc DMA (Direct Memory Access) buffer(s) | |
4008 | + * associated with a command IOCB back to the lpfc DMA buffer pool. It first | |
4009 | + * checks to see whether there is a lpfc DMA buffer associated with the | |
4010 | + * response of the command IOCB. If so, it will be released before releasing | |
4011 | + * the lpfc DMA buffer associated with the IOCB itself. | |
4012 | + * | |
4013 | + * Return code | |
4014 | + * 0 - Successfully released lpfc DMA buffer (currently, always return 0) | |
4015 | + **/ | |
4016 | static int | |
4017 | lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1) | |
4018 | { | |
4019 | struct lpfc_dmabuf *buf_ptr; | |
4020 | ||
4021 | - /* Free the response before processing the command. */ | |
4022 | + /* Free the response before processing the command. */ | |
4023 | if (!list_empty(&buf_ptr1->list)) { | |
4024 | list_remove_head(&buf_ptr1->list, buf_ptr, | |
4025 | struct lpfc_dmabuf, | |
4026 | @@ -2200,6 +2749,18 @@ lpfc_els_free_data(struct lpfc_hba *phba | |
4027 | return 0; | |
4028 | } | |
4029 | ||
4030 | +/** | |
4031 | + * lpfc_els_free_bpl: Free lpfc dma buffer and data structure with bpl. | |
4032 | + * @phba: pointer to lpfc hba data structure. | |
4033 | + * @buf_ptr: pointer to the lpfc dma buffer data structure. | |
4034 | + * | |
4035 | + * This routine releases the lpfc Direct Memory Access (DMA) buffer | |
4036 | + * associated with a Buffer Pointer List (BPL) back to the lpfc DMA buffer | |
4037 | + * pool. | |
4038 | + * | |
4039 | + * Return code | |
4040 | + * 0 - Successfully released lpfc DMA buffer (currently, always return 0) | |
4041 | + **/ | |
4042 | static int | |
4043 | lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) | |
4044 | { | |
4045 | @@ -2208,6 +2769,33 @@ lpfc_els_free_bpl(struct lpfc_hba *phba, | |
4046 | return 0; | |
4047 | } | |
4048 | ||
4049 | +/** | |
4050 | + * lpfc_els_free_iocb: Free a command iocb and its associated resources. | |
4051 | + * @phba: pointer to lpfc hba data structure. | |
4052 | + * @elsiocb: pointer to lpfc els command iocb data structure. | |
4053 | + * | |
4054 | + * This routine frees a command IOCB and its associated resources. The | |
4055 | + * command IOCB data structure contains the reference to various associated | |
4056 | + * resources, these fields must be set to NULL if the associated reference | |
4057 | + * not present: | |
4058 | + * context1 - reference to ndlp | |
4059 | + * context2 - reference to cmd | |
4060 | + * context2->next - reference to rsp | |
4061 | + * context3 - reference to bpl | |
4062 | + * | |
4063 | + * It first properly decrements the reference count held on ndlp for the | |
4064 | + * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not | |
4065 | + * set, it invokes the lpfc_els_free_data() routine to release the Direct | |
4066 | + * Memory Access (DMA) buffers associated with the IOCB. Otherwise, it | |
4067 | + * adds the DMA buffer the @phba data structure for the delayed release. | |
4068 | + * If reference to the Buffer Pointer List (BPL) is present, the | |
4069 | + * lpfc_els_free_bpl() routine is invoked to release the DMA memory | |
4070 | + * associated with BPL. Finally, the lpfc_sli_release_iocbq() routine is | |
4071 | + * invoked to release the IOCB data structure back to @phba IOCBQ list. | |
4072 | + * | |
4073 | + * Return code | |
4074 | + * 0 - Success (currently, always return 0) | |
4075 | + **/ | |
4076 | int | |
4077 | lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) | |
4078 | { | |
4079 | @@ -2274,6 +2862,23 @@ lpfc_els_free_iocb(struct lpfc_hba *phba | |
4080 | return 0; | |
4081 | } | |
4082 | ||
4083 | +/** | |
4084 | + * lpfc_cmpl_els_logo_acc: Completion callback function to logo acc response. | |
4085 | + * @phba: pointer to lpfc hba data structure. | |
4086 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4087 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
4088 | + * | |
4089 | + * This routine is the completion callback function to the Logout (LOGO) | |
4090 | + * Accept (ACC) Response ELS command. This routine is invoked to indicate | |
4091 | + * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to | |
4092 | + * release the ndlp if it has the last reference remaining (reference count | |
4093 | + * is 1). If succeeded (meaning ndlp released), it sets the IOCB context1 | |
4094 | + * field to NULL to inform the following lpfc_els_free_iocb() routine no | |
4095 | + * ndlp reference count needs to be decremented. Otherwise, the ndlp | |
4096 | + * reference use-count shall be decremented by the lpfc_els_free_iocb() | |
4097 | + * routine. Finally, the lpfc_els_free_iocb() is invoked to release the | |
4098 | + * IOCB data structure. | |
4099 | + **/ | |
4100 | static void | |
4101 | lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
4102 | struct lpfc_iocbq *rspiocb) | |
4103 | @@ -2311,6 +2916,19 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba * | |
4104 | return; | |
4105 | } | |
4106 | ||
4107 | +/** | |
4108 | + * lpfc_mbx_cmpl_dflt_rpi: Completion callbk func for unreg dflt rpi mbox cmd. | |
4109 | + * @phba: pointer to lpfc hba data structure. | |
4110 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
4111 | + * | |
4112 | + * This routine is the completion callback function for unregister default | |
4113 | + * RPI (Remote Port Index) mailbox command to the @phba. It simply releases | |
4114 | + * the associated lpfc Direct Memory Access (DMA) buffer back to the pool and | |
4115 | + * decrements the ndlp reference count held for this completion callback | |
4116 | + * function. After that, it invokes the lpfc_nlp_not_used() to check | |
4117 | + * whether there is only one reference left on the ndlp. If so, it will | |
4118 | + * perform one more decrement and trigger the release of the ndlp. | |
4119 | + **/ | |
4120 | void | |
4121 | lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |
4122 | { | |
4123 | @@ -2332,6 +2950,22 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba * | |
4124 | return; | |
4125 | } | |
4126 | ||
4127 | +/** | |
4128 | + * lpfc_cmpl_els_rsp: Completion callback function for els response iocb cmd. | |
4129 | + * @phba: pointer to lpfc hba data structure. | |
4130 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4131 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
4132 | + * | |
4133 | + * This routine is the completion callback function for ELS Response IOCB | |
4134 | + * command. In normal case, this callback function just properly sets the | |
4135 | + * nlp_flag bitmap in the ndlp data structure, if the mbox command reference | |
4136 | + * field in the command IOCB is not NULL, the referred mailbox command will | |
4137 | + * be send out, and then invokes the lpfc_els_free_iocb() routine to release | |
4138 | + * the IOCB. Under error conditions, such as when a LS_RJT is returned or a | |
4139 | + * link down event occurred during the discovery, the lpfc_nlp_not_used() | |
4140 | + * routine shall be invoked trying to release the ndlp if no other threads | |
4141 | + * are currently referring it. | |
4142 | + **/ | |
4143 | static void | |
4144 | lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
4145 | struct lpfc_iocbq *rspiocb) | |
4146 | @@ -2487,6 +3121,31 @@ out: | |
4147 | return; | |
4148 | } | |
4149 | ||
4150 | +/** | |
4151 | + * lpfc_els_rsp_acc: Prepare and issue an acc response iocb command. | |
4152 | + * @vport: pointer to a host virtual N_Port data structure. | |
4153 | + * @flag: the els command code to be accepted. | |
4154 | + * @oldiocb: pointer to the original lpfc command iocb data structure. | |
4155 | + * @ndlp: pointer to a node-list data structure. | |
4156 | + * @mbox: pointer to the driver internal queue element for mailbox command. | |
4157 | + * | |
4158 | + * This routine prepares and issues an Accept (ACC) response IOCB | |
4159 | + * command. It uses the @flag to properly set up the IOCB field for the | |
4160 | + * specific ACC response command to be issued and invokes the | |
4161 | + * lpfc_sli_issue_iocb() routine to send out ACC response IOCB. If a | |
4162 | + * @mbox pointer is passed in, it will be put into the context_un.mbox | |
4163 | + * field of the IOCB for the completion callback function to issue the | |
4164 | + * mailbox command to the HBA later when callback is invoked. | |
4165 | + * | |
4166 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
4167 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
4168 | + * will be stored into the context1 field of the IOCB for the completion | |
4169 | + * callback function to the corresponding response ELS IOCB command. | |
4170 | + * | |
4171 | + * Return code | |
4172 | + * 0 - Successfully issued acc response | |
4173 | + * 1 - Failed to issue acc response | |
4174 | + **/ | |
4175 | int | |
4176 | lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, | |
4177 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, | |
4178 | @@ -2601,6 +3260,28 @@ lpfc_els_rsp_acc(struct lpfc_vport *vpor | |
4179 | return 0; | |
4180 | } | |
4181 | ||
4182 | +/** | |
4183 | + * lpfc_els_rsp_reject: Propare and issue a rjt response iocb command. | |
4184 | + * @vport: pointer to a virtual N_Port data structure. | |
4185 | + * @rejectError: | |
4186 | + * @oldiocb: pointer to the original lpfc command iocb data structure. | |
4187 | + * @ndlp: pointer to a node-list data structure. | |
4188 | + * @mbox: pointer to the driver internal queue element for mailbox command. | |
4189 | + * | |
4190 | + * This routine prepares and issue an Reject (RJT) response IOCB | |
4191 | + * command. If a @mbox pointer is passed in, it will be put into the | |
4192 | + * context_un.mbox field of the IOCB for the completion callback function | |
4193 | + * to issue to the HBA later. | |
4194 | + * | |
4195 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
4196 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
4197 | + * will be stored into the context1 field of the IOCB for the completion | |
4198 | + * callback function to the reject response ELS IOCB command. | |
4199 | + * | |
4200 | + * Return code | |
4201 | + * 0 - Successfully issued reject response | |
4202 | + * 1 - Failed to issue reject response | |
4203 | + **/ | |
4204 | int | |
4205 | lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, | |
4206 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, | |
4207 | @@ -2660,6 +3341,25 @@ lpfc_els_rsp_reject(struct lpfc_vport *v | |
4208 | return 0; | |
4209 | } | |
4210 | ||
4211 | +/** | |
4212 | + * lpfc_els_rsp_adisc_acc: Prepare and issue acc response to adisc iocb cmd. | |
4213 | + * @vport: pointer to a virtual N_Port data structure. | |
4214 | + * @oldiocb: pointer to the original lpfc command iocb data structure. | |
4215 | + * @ndlp: pointer to a node-list data structure. | |
4216 | + * | |
4217 | + * This routine prepares and issues an Accept (ACC) response to Address | |
4218 | + * Discover (ADISC) ELS command. It simply prepares the payload of the IOCB | |
4219 | + * and invokes the lpfc_sli_issue_iocb() routine to send out the command. | |
4220 | + * | |
4221 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
4222 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
4223 | + * will be stored into the context1 field of the IOCB for the completion | |
4224 | + * callback function to the ADISC Accept response ELS IOCB command. | |
4225 | + * | |
4226 | + * Return code | |
4227 | + * 0 - Successfully issued acc adisc response | |
4228 | + * 1 - Failed to issue adisc acc response | |
4229 | + **/ | |
4230 | int | |
4231 | lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, | |
4232 | struct lpfc_nodelist *ndlp) | |
4233 | @@ -2716,6 +3416,25 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport | |
4234 | return 0; | |
4235 | } | |
4236 | ||
4237 | +/** | |
4238 | + * lpfc_els_rsp_prli_acc: Prepare and issue acc response to prli iocb cmd. | |
4239 | + * @vport: pointer to a virtual N_Port data structure. | |
4240 | + * @oldiocb: pointer to the original lpfc command iocb data structure. | |
4241 | + * @ndlp: pointer to a node-list data structure. | |
4242 | + * | |
4243 | + * This routine prepares and issues an Accept (ACC) response to Process | |
4244 | + * Login (PRLI) ELS command. It simply prepares the payload of the IOCB | |
4245 | + * and invokes the lpfc_sli_issue_iocb() routine to send out the command. | |
4246 | + * | |
4247 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
4248 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
4249 | + * will be stored into the context1 field of the IOCB for the completion | |
4250 | + * callback function to the PRLI Accept response ELS IOCB command. | |
4251 | + * | |
4252 | + * Return code | |
4253 | + * 0 - Successfully issued acc prli response | |
4254 | + * 1 - Failed to issue acc prli response | |
4255 | + **/ | |
4256 | int | |
4257 | lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, | |
4258 | struct lpfc_nodelist *ndlp) | |
4259 | @@ -2795,6 +3514,32 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport | |
4260 | return 0; | |
4261 | } | |
4262 | ||
4263 | +/** | |
4264 | + * lpfc_els_rsp_rnid_acc: Issue rnid acc response iocb command. | |
4265 | + * @vport: pointer to a virtual N_Port data structure. | |
4266 | + * @format: rnid command format. | |
4267 | + * @oldiocb: pointer to the original lpfc command iocb data structure. | |
4268 | + * @ndlp: pointer to a node-list data structure. | |
4269 | + * | |
4270 | + * This routine issues a Request Node Identification Data (RNID) Accept | |
4271 | + * (ACC) response. It constructs the RNID ACC response command according to | |
4272 | + * the proper @format and then calls the lpfc_sli_issue_iocb() routine to | |
4273 | + * issue the response. Note that this command does not need to hold the ndlp | |
4274 | + * reference count for the callback. So, the ndlp reference count taken by | |
4275 | + * the lpfc_prep_els_iocb() routine is put back and the context1 field of | |
4276 | + * IOCB is set to NULL to indicate to the lpfc_els_free_iocb() routine that | |
4277 | + * there is no ndlp reference available. | |
4278 | + * | |
4279 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
4280 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
4281 | + * will be stored into the context1 field of the IOCB for the completion | |
4282 | + * callback function. However, for the RNID Accept Response ELS command, | |
4283 | + * this is undone later by this routine after the IOCB is allocated. | |
4284 | + * | |
4285 | + * Return code | |
4286 | + * 0 - Successfully issued acc rnid response | |
4287 | + * 1 - Failed to issue acc rnid response | |
4288 | + **/ | |
4289 | static int | |
4290 | lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, | |
4291 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) | |
4292 | @@ -2875,6 +3620,25 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport | |
4293 | return 0; | |
4294 | } | |
4295 | ||
4296 | +/** | |
4297 | + * lpfc_els_disc_adisc: Issue remaining adisc iocbs to npr nodes of a vport. | |
4298 | + * @vport: pointer to a host virtual N_Port data structure. | |
4299 | + * | |
4300 | + * This routine issues Address Discover (ADISC) ELS commands to those | |
4301 | + * N_Ports which are in node port recovery state and ADISC has not been issued | |
4302 | + * for the @vport. Each time an ELS ADISC IOCB is issued by invoking the | |
4303 | + * lpfc_issue_els_adisc() routine, the per @vport number of discover count | |
4304 | + * (num_disc_nodes) shall be incremented. If the num_disc_nodes reaches a | |
4305 | + * pre-configured threshold (cfg_discovery_threads), the @vport fc_flag will | |
4306 | + * be marked with FC_NLP_MORE bit and the process of issuing remaining ADISC | |
4307 | + * IOCBs quit for later pick up. On the other hand, after walking through | |
4308 | + * all the ndlps with the @vport and there is none ADISC IOCB issued, the | |
4309 | + * @vport fc_flag shall be cleared with FC_NLP_MORE bit indicating there is | |
4310 | + * no more ADISC need to be sent. | |
4311 | + * | |
4312 | + * Return code | |
4313 | + * The number of N_Ports with adisc issued. | |
4314 | + **/ | |
4315 | int | |
4316 | lpfc_els_disc_adisc(struct lpfc_vport *vport) | |
4317 | { | |
4318 | @@ -2914,6 +3678,25 @@ lpfc_els_disc_adisc(struct lpfc_vport *v | |
4319 | return sentadisc; | |
4320 | } | |
4321 | ||
4322 | +/** | |
4323 | + * lpfc_els_disc_plogi: Issue plogi for all npr nodes of a vport before adisc. | |
4324 | + * @vport: pointer to a host virtual N_Port data structure. | |
4325 | + * | |
4326 | + * This routine issues Port Login (PLOGI) ELS commands to all the N_Ports | |
4327 | + * which are in node port recovery state, with a @vport. Each time an ELS | |
4328 | + * ADISC PLOGI IOCB is issued by invoking the lpfc_issue_els_plogi() routine, | |
4329 | + * the per @vport number of discover count (num_disc_nodes) shall be | |
4330 | + * incremented. If the num_disc_nodes reaches a pre-configured threshold | |
4331 | + * (cfg_discovery_threads), the @vport fc_flag will be marked with FC_NLP_MORE | |
4332 | + * bit set and quit the process of issuing remaining ADISC PLOGIN IOCBs for | |
4333 | + * later pick up. On the other hand, after walking through all the ndlps with | |
4334 | + * the @vport and there is none ADISC PLOGI IOCB issued, the @vport fc_flag | |
4335 | + * shall be cleared with the FC_NLP_MORE bit indicating there is no more ADISC | |
4336 | + * PLOGI need to be sent. | |
4337 | + * | |
4338 | + * Return code | |
4339 | + * The number of N_Ports with plogi issued. | |
4340 | + **/ | |
4341 | int | |
4342 | lpfc_els_disc_plogi(struct lpfc_vport *vport) | |
4343 | { | |
4344 | @@ -2954,6 +3737,15 @@ lpfc_els_disc_plogi(struct lpfc_vport *v | |
4345 | return sentplogi; | |
4346 | } | |
4347 | ||
4348 | +/** | |
4349 | + * lpfc_els_flush_rscn: Clean up any rscn activities with a vport. | |
4350 | + * @vport: pointer to a host virtual N_Port data structure. | |
4351 | + * | |
4352 | + * This routine cleans up any Registration State Change Notification | |
4353 | + * (RSCN) activity with a @vport. Note that the fc_rscn_flush flag of the | |
4354 | + * @vport together with the host_lock is used to prevent multiple thread | |
4355 | + * trying to access the RSCN array on a same @vport at the same time. | |
4356 | + **/ | |
4357 | void | |
4358 | lpfc_els_flush_rscn(struct lpfc_vport *vport) | |
4359 | { | |
4360 | @@ -2984,6 +3776,18 @@ lpfc_els_flush_rscn(struct lpfc_vport *v | |
4361 | vport->fc_rscn_flush = 0; | |
4362 | } | |
4363 | ||
4364 | +/** | |
4365 | + * lpfc_rscn_payload_check: Check whether there is a pending rscn to a did. | |
4366 | + * @vport: pointer to a host virtual N_Port data structure. | |
4367 | + * @did: remote destination port identifier. | |
4368 | + * | |
4369 | + * This routine checks whether there is any pending Registration State | |
4370 | + * Configuration Notification (RSCN) to a @did on @vport. | |
4371 | + * | |
4372 | + * Return code | |
4373 | + * None zero - The @did matched with a pending rscn | |
4374 | + * 0 - not able to match @did with a pending rscn | |
4375 | + **/ | |
4376 | int | |
4377 | lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) | |
4378 | { | |
4379 | @@ -3053,6 +3857,17 @@ return_did_out: | |
4380 | return did; | |
4381 | } | |
4382 | ||
4383 | +/** | |
4384 | + * lpfc_rscn_recovery_check: Send recovery event to vport nodes matching rscn | |
4385 | + * @vport: pointer to a host virtual N_Port data structure. | |
4386 | + * | |
4387 | + * This routine sends recovery (NLP_EVT_DEVICE_RECOVERY) event to the | |
4388 | + * state machine for a @vport's nodes that are with pending RSCN (Registration | |
4389 | + * State Change Notification). | |
4390 | + * | |
4391 | + * Return code | |
4392 | + * 0 - Successful (currently alway return 0) | |
4393 | + **/ | |
4394 | static int | |
4395 | lpfc_rscn_recovery_check(struct lpfc_vport *vport) | |
4396 | { | |
4397 | @@ -3071,6 +3886,28 @@ lpfc_rscn_recovery_check(struct lpfc_vpo | |
4398 | return 0; | |
4399 | } | |
4400 | ||
4401 | +/** | |
4402 | + * lpfc_els_rcv_rscn: Process an unsolicited rscn iocb. | |
4403 | + * @vport: pointer to a host virtual N_Port data structure. | |
4404 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4405 | + * @ndlp: pointer to a node-list data structure. | |
4406 | + * | |
4407 | + * This routine processes an unsolicited RSCN (Registration State Change | |
4408 | + * Notification) IOCB. First, the payload of the unsolicited RSCN is walked | |
4409 | + * to invoke fc_host_post_event() routine to the FC transport layer. If the | |
4410 | + * discover state machine is about to begin discovery, it just accepts the | |
4411 | + * RSCN and the discovery process will satisfy the RSCN. If this RSCN only | |
4412 | + * contains N_Port IDs for other vports on this HBA, it just accepts the | |
4413 | + * RSCN and ignore processing it. If the state machine is in the recovery | |
4414 | + * state, the fc_rscn_id_list of this @vport is walked and the | |
4415 | + * lpfc_rscn_recovery_check() routine is invoked to send recovery event for | |
4416 | + * all nodes that match RSCN payload. Otherwise, the lpfc_els_handle_rscn() | |
4417 | + * routine is invoked to handle the RSCN event. | |
4418 | + * | |
4419 | + * Return code | |
4420 | + * 0 - Just sent the acc response | |
4421 | + * 1 - Sent the acc response and waited for name server completion | |
4422 | + **/ | |
4423 | static int | |
4424 | lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4425 | struct lpfc_nodelist *ndlp) | |
4426 | @@ -3130,7 +3967,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vpo | |
4427 | if (rscn_id == hba_id) { | |
4428 | /* ALL NPortIDs in RSCN are on HBA */ | |
4429 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | |
4430 | - "0214 Ignore RSCN " | |
4431 | + "0219 Ignore RSCN " | |
4432 | "Data: x%x x%x x%x x%x\n", | |
4433 | vport->fc_flag, payload_len, | |
4434 | *lp, vport->fc_rscn_id_cnt); | |
4435 | @@ -3241,6 +4078,22 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vpo | |
4436 | return lpfc_els_handle_rscn(vport); | |
4437 | } | |
4438 | ||
4439 | +/** | |
4440 | + * lpfc_els_handle_rscn: Handle rscn for a vport. | |
4441 | + * @vport: pointer to a host virtual N_Port data structure. | |
4442 | + * | |
4443 | + * This routine handles the Registration State Configuration Notification | |
4444 | + * (RSCN) for a @vport. If login to NameServer does not exist, a new ndlp shall | |
4445 | + * be created and a Port Login (PLOGI) to the NameServer is issued. Otherwise, | |
4446 | + * if the ndlp to NameServer exists, a Common Transport (CT) command to the | |
4447 | + * NameServer shall be issued. If CT command to the NameServer fails to be | |
4448 | + * issued, the lpfc_els_flush_rscn() routine shall be invoked to clean up any | |
4449 | + * RSCN activities with the @vport. | |
4450 | + * | |
4451 | + * Return code | |
4452 | + * 0 - Cleaned up rscn on the @vport | |
4453 | + * 1 - Wait for plogi to name server before proceed | |
4454 | + **/ | |
4455 | int | |
4456 | lpfc_els_handle_rscn(struct lpfc_vport *vport) | |
4457 | { | |
4458 | @@ -3313,6 +4166,31 @@ lpfc_els_handle_rscn(struct lpfc_vport * | |
4459 | return 0; | |
4460 | } | |
4461 | ||
4462 | +/** | |
4463 | + * lpfc_els_rcv_flogi: Process an unsolicited flogi iocb. | |
4464 | + * @vport: pointer to a host virtual N_Port data structure. | |
4465 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4466 | + * @ndlp: pointer to a node-list data structure. | |
4467 | + * | |
4468 | + * This routine processes Fabric Login (FLOGI) IOCB received as an ELS | |
4469 | + * unsolicited event. An unsolicited FLOGI can be received in a point-to- | |
4470 | + * point topology. As an unsolicited FLOGI should not be received in a loop | |
4471 | + * mode, any unsolicited FLOGI received in loop mode shall be ignored. The | |
4472 | + * lpfc_check_sparm() routine is invoked to check the parameters in the | |
4473 | + * unsolicited FLOGI. If parameters validation failed, the routine | |
4474 | + * lpfc_els_rsp_reject() shall be called with reject reason code set to | |
4475 | + * LSEXP_SPARM_OPTIONS to reject the FLOGI. Otherwise, the Port WWN in the | |
4476 | + * FLOGI shall be compared with the Port WWN of the @vport to determine who | |
4477 | + * will initiate PLOGI. The higher lexicographical value party shall has | |
4478 | + * higher priority (as the winning port) and will initiate PLOGI and | |
4479 | + * communicate Port_IDs (Addresses) for both nodes in PLOGI. The result | |
4480 | + * of this will be marked in the @vport fc_flag field with FC_PT2PT_PLOGI | |
4481 | + * and then the lpfc_els_rsp_acc() routine is invoked to accept the FLOGI. | |
4482 | + * | |
4483 | + * Return code | |
4484 | + * 0 - Successfully processed the unsolicited flogi | |
4485 | + * 1 - Failed to process the unsolicited flogi | |
4486 | + **/ | |
4487 | static int | |
4488 | lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4489 | struct lpfc_nodelist *ndlp) | |
4490 | @@ -3402,6 +4280,22 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vp | |
4491 | return 0; | |
4492 | } | |
4493 | ||
4494 | +/** | |
4495 | + * lpfc_els_rcv_rnid: Process an unsolicited rnid iocb. | |
4496 | + * @vport: pointer to a host virtual N_Port data structure. | |
4497 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4498 | + * @ndlp: pointer to a node-list data structure. | |
4499 | + * | |
4500 | + * This routine processes Request Node Identification Data (RNID) IOCB | |
4501 | + * received as an ELS unsolicited event. Only when the RNID specified format | |
4502 | + * 0x0 or 0xDF (Topology Discovery Specific Node Identification Data) | |
4503 | + * present, this routine will invoke the lpfc_els_rsp_rnid_acc() routine to | |
4504 | + * Accept (ACC) the RNID ELS command. All the other RNID formats are | |
4505 | + * rejected by invoking the lpfc_els_rsp_reject() routine. | |
4506 | + * | |
4507 | + * Return code | |
4508 | + * 0 - Successfully processed rnid iocb (currently always return 0) | |
4509 | + **/ | |
4510 | static int | |
4511 | lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4512 | struct lpfc_nodelist *ndlp) | |
4513 | @@ -3441,6 +4335,19 @@ lpfc_els_rcv_rnid(struct lpfc_vport *vpo | |
4514 | return 0; | |
4515 | } | |
4516 | ||
4517 | +/** | |
4518 | + * lpfc_els_rcv_lirr: Process an unsolicited lirr iocb. | |
4519 | + * @vport: pointer to a host virtual N_Port data structure. | |
4520 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4521 | + * @ndlp: pointer to a node-list data structure. | |
4522 | + * | |
4523 | + * This routine processes a Link Incident Report Registration(LIRR) IOCB | |
4524 | + * received as an ELS unsolicited event. Currently, this function just invokes | |
4525 | + * the lpfc_els_rsp_reject() routine to reject the LIRR IOCB unconditionally. | |
4526 | + * | |
4527 | + * Return code | |
4528 | + * 0 - Successfully processed lirr iocb (currently always return 0) | |
4529 | + **/ | |
4530 | static int | |
4531 | lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4532 | struct lpfc_nodelist *ndlp) | |
4533 | @@ -3456,6 +4363,25 @@ lpfc_els_rcv_lirr(struct lpfc_vport *vpo | |
4534 | return 0; | |
4535 | } | |
4536 | ||
4537 | +/** | |
4538 | + * lpfc_els_rsp_rps_acc: Completion callbk func for MBX_READ_LNK_STAT mbox cmd. | |
4539 | + * @phba: pointer to lpfc hba data structure. | |
4540 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
4541 | + * | |
4542 | + * This routine is the completion callback function for the MBX_READ_LNK_STAT | |
4543 | + * mailbox command. This callback function is to actually send the Accept | |
4544 | + * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It | |
4545 | + * collects the link statistics from the completion of the MBX_READ_LNK_STAT | |
4546 | + * mailbox command, constructs the RPS response with the link statistics | |
4547 | + * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC | |
4548 | + * response to the RPS. | |
4549 | + * | |
4550 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
4551 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
4552 | + * will be stored into the context1 field of the IOCB for the completion | |
4553 | + * callback function to the RPS Accept Response ELS IOCB command. | |
4554 | + * | |
4555 | + **/ | |
4556 | static void | |
4557 | lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |
4558 | { | |
4559 | @@ -3531,6 +4457,24 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *ph | |
4560 | return; | |
4561 | } | |
4562 | ||
4563 | +/** | |
4564 | + * lpfc_els_rcv_rps: Process an unsolicited rps iocb. | |
4565 | + * @vport: pointer to a host virtual N_Port data structure. | |
4566 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4567 | + * @ndlp: pointer to a node-list data structure. | |
4568 | + * | |
4569 | + * This routine processes Read Port Status (RPS) IOCB received as an | |
4570 | + * ELS unsolicited event. It first checks the remote port state. If the | |
4571 | + * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE | |
4572 | + * state, it invokes the lpfc_els_rsp_reject() routine to send the reject | |
4573 | + * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command | |
4574 | + * for reading the HBA link statistics. It is for the callback function, | |
4575 | + * lpfc_els_rsp_rps_acc(), set to the MBX_READ_LNK_STAT mailbox command | |
4576 | + * to actually sending out RPS Accept (ACC) response. | |
4577 | + * | |
4578 | + * Return codes | |
4579 | + * 0 - Successfully processed rps iocb (currently always return 0) | |
4580 | + **/ | |
4581 | static int | |
4582 | lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4583 | struct lpfc_nodelist *ndlp) | |
4584 | @@ -3544,14 +4488,9 @@ lpfc_els_rcv_rps(struct lpfc_vport *vpor | |
4585 | struct ls_rjt stat; | |
4586 | ||
4587 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && | |
4588 | - (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { | |
4589 | - stat.un.b.lsRjtRsvd0 = 0; | |
4590 | - stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
4591 | - stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; | |
4592 | - stat.un.b.vendorUnique = 0; | |
4593 | - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, | |
4594 | - NULL); | |
4595 | - } | |
4596 | + (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) | |
4597 | + /* reject the unsolicited RPS request and done with it */ | |
4598 | + goto reject_out; | |
4599 | ||
4600 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; | |
4601 | lp = (uint32_t *) pcmd->virt; | |
4602 | @@ -3584,6 +4523,9 @@ lpfc_els_rcv_rps(struct lpfc_vport *vpor | |
4603 | mempool_free(mbox, phba->mbox_mem_pool); | |
4604 | } | |
4605 | } | |
4606 | + | |
4607 | +reject_out: | |
4608 | + /* issue rejection response */ | |
4609 | stat.un.b.lsRjtRsvd0 = 0; | |
4610 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
4611 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; | |
4612 | @@ -3592,6 +4534,25 @@ lpfc_els_rcv_rps(struct lpfc_vport *vpor | |
4613 | return 0; | |
4614 | } | |
4615 | ||
4616 | +/** | |
4617 | + * lpfc_els_rsp_rpl_acc: Issue an accept rpl els command. | |
4618 | + * @vport: pointer to a host virtual N_Port data structure. | |
4619 | + * @cmdsize: size of the ELS command. | |
4620 | + * @oldiocb: pointer to the original lpfc command iocb data structure. | |
4621 | + * @ndlp: pointer to a node-list data structure. | |
4622 | + * | |
4623 | + * This routine issuees an Accept (ACC) Read Port List (RPL) ELS command. | |
4624 | + * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL. | |
4625 | + * | |
4626 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
4627 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
4628 | + * will be stored into the context1 field of the IOCB for the completion | |
4629 | + * callback function to the RPL Accept Response ELS command. | |
4630 | + * | |
4631 | + * Return code | |
4632 | + * 0 - Successfully issued ACC RPL ELS command | |
4633 | + * 1 - Failed to issue ACC RPL ELS command | |
4634 | + **/ | |
4635 | static int | |
4636 | lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, | |
4637 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) | |
4638 | @@ -3645,6 +4606,22 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport * | |
4639 | return 0; | |
4640 | } | |
4641 | ||
4642 | +/** | |
4643 | + * lpfc_els_rcv_rpl: Process an unsolicited rpl iocb. | |
4644 | + * @vport: pointer to a host virtual N_Port data structure. | |
4645 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4646 | + * @ndlp: pointer to a node-list data structure. | |
4647 | + * | |
4648 | + * This routine processes Read Port List (RPL) IOCB received as an ELS | |
4649 | + * unsolicited event. It first checks the remote port state. If the remote | |
4650 | + * port is not in NLP_STE_UNMAPPED_NODE and NLP_STE_MAPPED_NODE states, it | |
4651 | + * invokes the lpfc_els_rsp_reject() routine to send reject response. | |
4652 | + * Otherwise, this routine then invokes the lpfc_els_rsp_rpl_acc() routine | |
4653 | + * to accept the RPL. | |
4654 | + * | |
4655 | + * Return code | |
4656 | + * 0 - Successfully processed rpl iocb (currently always return 0) | |
4657 | + **/ | |
4658 | static int | |
4659 | lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4660 | struct lpfc_nodelist *ndlp) | |
4661 | @@ -3658,12 +4635,15 @@ lpfc_els_rcv_rpl(struct lpfc_vport *vpor | |
4662 | ||
4663 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && | |
4664 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { | |
4665 | + /* issue rejection response */ | |
4666 | stat.un.b.lsRjtRsvd0 = 0; | |
4667 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
4668 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; | |
4669 | stat.un.b.vendorUnique = 0; | |
4670 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, | |
4671 | NULL); | |
4672 | + /* rejected the unsolicited RPL request and done with it */ | |
4673 | + return 0; | |
4674 | } | |
4675 | ||
4676 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; | |
4677 | @@ -3685,6 +4665,30 @@ lpfc_els_rcv_rpl(struct lpfc_vport *vpor | |
4678 | return 0; | |
4679 | } | |
4680 | ||
4681 | +/** | |
4682 | + * lpfc_els_rcv_farp: Process an unsolicited farp request els command. | |
4683 | + * @vport: pointer to a virtual N_Port data structure. | |
4684 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4685 | + * @ndlp: pointer to a node-list data structure. | |
4686 | + * | |
4687 | + * This routine processes Fibre Channel Address Resolution Protocol | |
4688 | + * (FARP) Request IOCB received as an ELS unsolicited event. Currently, | |
4689 | + * the lpfc driver only supports matching on WWPN or WWNN for FARP. As such, | |
4690 | + * FARP_MATCH_PORT flag and FARP_MATCH_NODE flag are checked against the | |
4691 | + * Match Flag in the FARP request IOCB: if FARP_MATCH_PORT flag is set, the | |
4692 | + * remote PortName is compared against the FC PortName stored in the @vport | |
4693 | + * data structure; if FARP_MATCH_NODE flag is set, the remote NodeName is | |
4694 | + * compared against the FC NodeName stored in the @vport data structure. | |
4695 | + * If any of these matches and the FARP_REQUEST_FARPR flag is set in the | |
4696 | + * FARP request IOCB Response Flag, the lpfc_issue_els_farpr() routine is | |
4697 | + * invoked to send out FARP Response to the remote node. Before sending the | |
4698 | + * FARP Response, however, the FARP_REQUEST_PLOGI flag is check in the FARP | |
4699 | + * request IOCB Response Flag and, if it is set, the lpfc_issue_els_plogi() | |
4700 | + * routine is invoked to log into the remote port first. | |
4701 | + * | |
4702 | + * Return code | |
4703 | + * 0 - Either the FARP Match Mode not supported or successfully processed | |
4704 | + **/ | |
4705 | static int | |
4706 | lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4707 | struct lpfc_nodelist *ndlp) | |
4708 | @@ -3744,6 +4748,20 @@ lpfc_els_rcv_farp(struct lpfc_vport *vpo | |
4709 | return 0; | |
4710 | } | |
4711 | ||
4712 | +/** | |
4713 | + * lpfc_els_rcv_farpr: Process an unsolicited farp response iocb. | |
4714 | + * @vport: pointer to a host virtual N_Port data structure. | |
4715 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4716 | + * @ndlp: pointer to a node-list data structure. | |
4717 | + * | |
4718 | + * This routine processes Fibre Channel Address Resolution Protocol | |
4719 | + * Response (FARPR) IOCB received as an ELS unsolicited event. It simply | |
4720 | + * invokes the lpfc_els_rsp_acc() routine to the remote node to accept | |
4721 | + * the FARP response request. | |
4722 | + * | |
4723 | + * Return code | |
4724 | + * 0 - Successfully processed FARPR IOCB (currently always return 0) | |
4725 | + **/ | |
4726 | static int | |
4727 | lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4728 | struct lpfc_nodelist *ndlp) | |
4729 | @@ -3768,6 +4786,25 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vp | |
4730 | return 0; | |
4731 | } | |
4732 | ||
4733 | +/** | |
4734 | + * lpfc_els_rcv_fan: Process an unsolicited fan iocb command. | |
4735 | + * @vport: pointer to a host virtual N_Port data structure. | |
4736 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
4737 | + * @fan_ndlp: pointer to a node-list data structure. | |
4738 | + * | |
4739 | + * This routine processes a Fabric Address Notification (FAN) IOCB | |
4740 | + * command received as an ELS unsolicited event. The FAN ELS command will | |
4741 | + * only be processed on a physical port (i.e., the @vport represents the | |
4742 | + * physical port). The fabric NodeName and PortName from the FAN IOCB are | |
4743 | + * compared against those in the phba data structure. If any of those is | |
4744 | + * different, the lpfc_initial_flogi() routine is invoked to initialize | |
4745 | + * Fabric Login (FLOGI) to the fabric to start the discover over. Otherwise, | |
4746 | + * if both of those are identical, the lpfc_issue_fabric_reglogin() routine | |
4747 | + * is invoked to register login to the fabric. | |
4748 | + * | |
4749 | + * Return code | |
4750 | + * 0 - Successfully processed fan iocb (currently always return 0). | |
4751 | + **/ | |
4752 | static int | |
4753 | lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |
4754 | struct lpfc_nodelist *fan_ndlp) | |
4755 | @@ -3797,6 +4834,16 @@ lpfc_els_rcv_fan(struct lpfc_vport *vpor | |
4756 | return 0; | |
4757 | } | |
4758 | ||
4759 | +/** | |
4760 | + * lpfc_els_timeout: Handler funciton to the els timer. | |
4761 | + * @ptr: holder for the timer function associated data. | |
4762 | + * | |
4763 | + * This routine is invoked by the ELS timer after timeout. It posts the ELS | |
4764 | + * timer timeout event by setting the WORKER_ELS_TMO bit to the work port | |
4765 | + * event bitmap and then invokes the lpfc_worker_wake_up() routine to wake | |
4766 | + * up the worker thread. It is for the worker thread to invoke the routine | |
4767 | + * lpfc_els_timeout_handler() to work on the posted event WORKER_ELS_TMO. | |
4768 | + **/ | |
4769 | void | |
4770 | lpfc_els_timeout(unsigned long ptr) | |
4771 | { | |
4772 | @@ -3816,6 +4863,15 @@ lpfc_els_timeout(unsigned long ptr) | |
4773 | return; | |
4774 | } | |
4775 | ||
4776 | +/** | |
4777 | + * lpfc_els_timeout_handler: Process an els timeout event. | |
4778 | + * @vport: pointer to a virtual N_Port data structure. | |
4779 | + * | |
4780 | + * This routine is the actual handler function that processes an ELS timeout | |
4781 | + * event. It walks the ELS ring to get and abort all the IOCBs (except the | |
4782 | + * ABORT/CLOSE/FARP/FARPR/FDISC), which are associated with the @vport by | |
4783 | + * invoking the lpfc_sli_issue_abort_iotag() routine. | |
4784 | + **/ | |
4785 | void | |
4786 | lpfc_els_timeout_handler(struct lpfc_vport *vport) | |
4787 | { | |
4788 | @@ -3886,6 +4942,26 @@ lpfc_els_timeout_handler(struct lpfc_vpo | |
4789 | mod_timer(&vport->els_tmofunc, jiffies + HZ * timeout); | |
4790 | } | |
4791 | ||
4792 | +/** | |
4793 | + * lpfc_els_flush_cmd: Clean up the outstanding els commands to a vport. | |
4794 | + * @vport: pointer to a host virtual N_Port data structure. | |
4795 | + * | |
4796 | + * This routine is used to clean up all the outstanding ELS commands on a | |
4797 | + * @vport. It first aborts the @vport by invoking lpfc_fabric_abort_vport() | |
4798 | + * routine. After that, it walks the ELS transmit queue to remove all the | |
4799 | + * IOCBs with the @vport other than the QUE_RING and ABORT/CLOSE IOCBs. For | |
4800 | + * the IOCBs with a non-NULL completion callback function, the callback | |
4801 | + * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and | |
4802 | + * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs with a NULL completion | |
4803 | + * callback function, the IOCB will simply be released. Finally, it walks | |
4804 | + * the ELS transmit completion queue to issue an abort IOCB to any transmit | |
4805 | + * completion queue IOCB that is associated with the @vport and is not | |
4806 | + * an IOCB from libdfc (i.e., the management plane IOCBs that are not | |
4807 | + * part of the discovery state machine) out to HBA by invoking the | |
4808 | + * lpfc_sli_issue_abort_iotag() routine. Note that this function issues the | |
4809 | + * abort IOCB to any transmit completion queueed IOCB, it does not guarantee | |
4810 | + * the IOCBs are aborted when this function returns. | |
4811 | + **/ | |
4812 | void | |
4813 | lpfc_els_flush_cmd(struct lpfc_vport *vport) | |
4814 | { | |
4815 | @@ -3948,6 +5024,23 @@ lpfc_els_flush_cmd(struct lpfc_vport *vp | |
4816 | return; | |
4817 | } | |
4818 | ||
4819 | +/** | |
4820 | + * lpfc_els_flush_all_cmd: Clean up all the outstanding els commands to a HBA. | |
4821 | + * @phba: pointer to lpfc hba data structure. | |
4822 | + * | |
4823 | + * This routine is used to clean up all the outstanding ELS commands on a | |
4824 | + * @phba. It first aborts the @phba by invoking the lpfc_fabric_abort_hba() | |
4825 | + * routine. After that, it walks the ELS transmit queue to remove all the | |
4826 | + * IOCBs to the @phba other than the QUE_RING and ABORT/CLOSE IOCBs. For | |
4827 | + * the IOCBs with the completion callback function associated, the callback | |
4828 | + * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and | |
4829 | + * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs without the completion | |
4830 | + * callback function associated, the IOCB will simply be released. Finally, | |
4831 | + * it walks the ELS transmit completion queue to issue an abort IOCB to any | |
4832 | + * transmit completion queue IOCB that is not an IOCB from libdfc (i.e., the | |
4833 | + * management plane IOCBs that are not part of the discovery state machine) | |
4834 | + * out to HBA by invoking the lpfc_sli_issue_abort_iotag() routine. | |
4835 | + **/ | |
4836 | void | |
4837 | lpfc_els_flush_all_cmd(struct lpfc_hba *phba) | |
4838 | { | |
4839 | @@ -3992,6 +5085,130 @@ lpfc_els_flush_all_cmd(struct lpfc_hba | |
4840 | return; | |
4841 | } | |
4842 | ||
4843 | +/** | |
4844 | + * lpfc_send_els_failure_event: Posts an ELS command failure event. | |
4845 | + * @phba: Pointer to hba context object. | |
4846 | + * @cmdiocbp: Pointer to command iocb which reported error. | |
4847 | + * @rspiocbp: Pointer to response iocb which reported error. | |
4848 | + * | |
4849 | + * This function sends an event when there is an ELS command | |
4850 | + * failure. | |
4851 | + **/ | |
4852 | +void | |
4853 | +lpfc_send_els_failure_event(struct lpfc_hba *phba, | |
4854 | + struct lpfc_iocbq *cmdiocbp, | |
4855 | + struct lpfc_iocbq *rspiocbp) | |
4856 | +{ | |
4857 | + struct lpfc_vport *vport = cmdiocbp->vport; | |
4858 | + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | |
4859 | + struct lpfc_lsrjt_event lsrjt_event; | |
4860 | + struct lpfc_fabric_event_header fabric_event; | |
4861 | + struct ls_rjt stat; | |
4862 | + struct lpfc_nodelist *ndlp; | |
4863 | + uint32_t *pcmd; | |
4864 | + | |
4865 | + ndlp = cmdiocbp->context1; | |
4866 | + if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) | |
4867 | + return; | |
4868 | + | |
4869 | + if (rspiocbp->iocb.ulpStatus == IOSTAT_LS_RJT) { | |
4870 | + lsrjt_event.header.event_type = FC_REG_ELS_EVENT; | |
4871 | + lsrjt_event.header.subcategory = LPFC_EVENT_LSRJT_RCV; | |
4872 | + memcpy(lsrjt_event.header.wwpn, &ndlp->nlp_portname, | |
4873 | + sizeof(struct lpfc_name)); | |
4874 | + memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename, | |
4875 | + sizeof(struct lpfc_name)); | |
4876 | + pcmd = (uint32_t *) (((struct lpfc_dmabuf *) | |
4877 | + cmdiocbp->context2)->virt); | |
4878 | + lsrjt_event.command = *pcmd; | |
4879 | + stat.un.lsRjtError = be32_to_cpu(rspiocbp->iocb.un.ulpWord[4]); | |
4880 | + lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode; | |
4881 | + lsrjt_event.explanation = stat.un.b.lsRjtRsnCodeExp; | |
4882 | + fc_host_post_vendor_event(shost, | |
4883 | + fc_get_event_number(), | |
4884 | + sizeof(lsrjt_event), | |
4885 | + (char *)&lsrjt_event, | |
4886 | + SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
4887 | + return; | |
4888 | + } | |
4889 | + if ((rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) || | |
4890 | + (rspiocbp->iocb.ulpStatus == IOSTAT_FABRIC_BSY)) { | |
4891 | + fabric_event.event_type = FC_REG_FABRIC_EVENT; | |
4892 | + if (rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) | |
4893 | + fabric_event.subcategory = LPFC_EVENT_PORT_BUSY; | |
4894 | + else | |
4895 | + fabric_event.subcategory = LPFC_EVENT_FABRIC_BUSY; | |
4896 | + memcpy(fabric_event.wwpn, &ndlp->nlp_portname, | |
4897 | + sizeof(struct lpfc_name)); | |
4898 | + memcpy(fabric_event.wwnn, &ndlp->nlp_nodename, | |
4899 | + sizeof(struct lpfc_name)); | |
4900 | + fc_host_post_vendor_event(shost, | |
4901 | + fc_get_event_number(), | |
4902 | + sizeof(fabric_event), | |
4903 | + (char *)&fabric_event, | |
4904 | + SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
4905 | + return; | |
4906 | + } | |
4907 | + | |
4908 | +} | |
4909 | + | |
4910 | +/** | |
4911 | + * lpfc_send_els_event: Posts unsolicited els event. | |
4912 | + * @vport: Pointer to vport object. | |
4913 | + * @ndlp: Pointer FC node object. | |
4914 | + * @cmd: ELS command code. | |
4915 | + * | |
4916 | + * This function posts an event when there is an incoming | |
4917 | + * unsolicited ELS command. | |
4918 | + **/ | |
4919 | +static void | |
4920 | +lpfc_send_els_event(struct lpfc_vport *vport, | |
4921 | + struct lpfc_nodelist *ndlp, | |
4922 | + uint32_t cmd) | |
4923 | +{ | |
4924 | + struct lpfc_els_event_header els_data; | |
4925 | + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | |
4926 | + | |
4927 | + els_data.event_type = FC_REG_ELS_EVENT; | |
4928 | + switch (cmd) { | |
4929 | + case ELS_CMD_PLOGI: | |
4930 | + els_data.subcategory = LPFC_EVENT_PLOGI_RCV; | |
4931 | + break; | |
4932 | + case ELS_CMD_PRLO: | |
4933 | + els_data.subcategory = LPFC_EVENT_PRLO_RCV; | |
4934 | + break; | |
4935 | + case ELS_CMD_ADISC: | |
4936 | + els_data.subcategory = LPFC_EVENT_ADISC_RCV; | |
4937 | + break; | |
4938 | + default: | |
4939 | + return; | |
4940 | + } | |
4941 | + memcpy(els_data.wwpn, &ndlp->nlp_portname, sizeof(struct lpfc_name)); | |
4942 | + memcpy(els_data.wwnn, &ndlp->nlp_nodename, sizeof(struct lpfc_name)); | |
4943 | + fc_host_post_vendor_event(shost, | |
4944 | + fc_get_event_number(), | |
4945 | + sizeof(els_data), | |
4946 | + (char *)&els_data, | |
4947 | + SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
4948 | + | |
4949 | + return; | |
4950 | +} | |
4951 | + | |
4952 | + | |
4953 | +/** | |
4954 | + * lpfc_els_unsol_buffer: Process an unsolicited event data buffer. | |
4955 | + * @phba: pointer to lpfc hba data structure. | |
4956 | + * @pring: pointer to a SLI ring. | |
4957 | + * @vport: pointer to a host virtual N_Port data structure. | |
4958 | + * @elsiocb: pointer to lpfc els command iocb data structure. | |
4959 | + * | |
4960 | + * This routine is used for processing the IOCB associated with a unsolicited | |
4961 | + * event. It first determines whether there is an existing ndlp that matches | |
4962 | + * the DID from the unsolicited IOCB. If not, it will create a new one with | |
4963 | + * the DID from the unsolicited IOCB. The ELS command from the unsolicited | |
4964 | + * IOCB is then used to invoke the proper routine and to set up proper state | |
4965 | + * of the discovery state machine. | |
4966 | + **/ | |
4967 | static void | |
4968 | lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
4969 | struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb) | |
4970 | @@ -4059,8 +5276,6 @@ lpfc_els_unsol_buffer(struct lpfc_hba *p | |
4971 | } | |
4972 | ||
4973 | phba->fc_stat.elsRcvFrame++; | |
4974 | - if (elsiocb->context1) | |
4975 | - lpfc_nlp_put(elsiocb->context1); | |
4976 | ||
4977 | elsiocb->context1 = lpfc_nlp_get(ndlp); | |
4978 | elsiocb->vport = vport; | |
4979 | @@ -4081,6 +5296,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *p | |
4980 | phba->fc_stat.elsRcvPLOGI++; | |
4981 | ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); | |
4982 | ||
4983 | + lpfc_send_els_event(vport, ndlp, cmd); | |
4984 | if (vport->port_state < LPFC_DISC_AUTH) { | |
4985 | if (!(phba->pport->fc_flag & FC_PT2PT) || | |
4986 | (phba->pport->fc_flag & FC_PT2PT_PLOGI)) { | |
4987 | @@ -4130,6 +5346,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *p | |
4988 | did, vport->port_state, ndlp->nlp_flag); | |
4989 | ||
4990 | phba->fc_stat.elsRcvPRLO++; | |
4991 | + lpfc_send_els_event(vport, ndlp, cmd); | |
4992 | if (vport->port_state < LPFC_DISC_AUTH) { | |
4993 | rjt_err = LSRJT_UNABLE_TPC; | |
4994 | break; | |
4995 | @@ -4147,6 +5364,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *p | |
4996 | "RCV ADISC: did:x%x/ste:x%x flg:x%x", | |
4997 | did, vport->port_state, ndlp->nlp_flag); | |
4998 | ||
4999 | + lpfc_send_els_event(vport, ndlp, cmd); | |
5000 | phba->fc_stat.elsRcvADISC++; | |
5001 | if (vport->port_state < LPFC_DISC_AUTH) { | |
5002 | rjt_err = LSRJT_UNABLE_TPC; | |
5003 | @@ -4270,6 +5488,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *p | |
5004 | NULL); | |
5005 | } | |
5006 | ||
5007 | + lpfc_nlp_put(elsiocb->context1); | |
5008 | + elsiocb->context1 = NULL; | |
5009 | return; | |
5010 | ||
5011 | dropit: | |
5012 | @@ -4282,6 +5502,19 @@ dropit: | |
5013 | phba->fc_stat.elsRcvDrop++; | |
5014 | } | |
5015 | ||
5016 | +/** | |
5017 | + * lpfc_find_vport_by_vpid: Find a vport on a HBA through vport identifier. | |
5018 | + * @phba: pointer to lpfc hba data structure. | |
5019 | + * @vpi: host virtual N_Port identifier. | |
5020 | + * | |
5021 | + * This routine finds a vport on a HBA (referred by @phba) through a | |
5022 | + * @vpi. The function walks the HBA's vport list and returns the address | |
5023 | + * of the vport with the matching @vpi. | |
5024 | + * | |
5025 | + * Return code | |
5026 | + * NULL - No vport with the matching @vpi found | |
5027 | + * Otherwise - Address to the vport with the matching @vpi. | |
5028 | + **/ | |
5029 | static struct lpfc_vport * | |
5030 | lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi) | |
5031 | { | |
5032 | @@ -4299,6 +5532,18 @@ lpfc_find_vport_by_vpid(struct lpfc_hba | |
5033 | return NULL; | |
5034 | } | |
5035 | ||
5036 | +/** | |
5037 | + * lpfc_els_unsol_event: Process an unsolicited event from an els sli ring. | |
5038 | + * @phba: pointer to lpfc hba data structure. | |
5039 | + * @pring: pointer to a SLI ring. | |
5040 | + * @elsiocb: pointer to lpfc els iocb data structure. | |
5041 | + * | |
5042 | + * This routine is used to process an unsolicited event received from a SLI | |
5043 | + * (Service Level Interface) ring. The actual processing of the data buffer | |
5044 | + * associated with the unsolicited event is done by invoking the routine | |
5045 | + * lpfc_els_unsol_buffer() after properly set up the iocb buffer from the | |
5046 | + * SLI ring on which the unsolicited event was received. | |
5047 | + **/ | |
5048 | void | |
5049 | lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
5050 | struct lpfc_iocbq *elsiocb) | |
5051 | @@ -4309,6 +5554,7 @@ lpfc_els_unsol_event(struct lpfc_hba *ph | |
5052 | struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2; | |
5053 | struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3; | |
5054 | ||
5055 | + elsiocb->context1 = NULL; | |
5056 | elsiocb->context2 = NULL; | |
5057 | elsiocb->context3 = NULL; | |
5058 | ||
5059 | @@ -4356,8 +5602,6 @@ lpfc_els_unsol_event(struct lpfc_hba *ph | |
5060 | * The different unsolicited event handlers would tell us | |
5061 | * if they are done with "mp" by setting context2 to NULL. | |
5062 | */ | |
5063 | - lpfc_nlp_put(elsiocb->context1); | |
5064 | - elsiocb->context1 = NULL; | |
5065 | if (elsiocb->context2) { | |
5066 | lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2); | |
5067 | elsiocb->context2 = NULL; | |
5068 | @@ -4376,6 +5620,19 @@ lpfc_els_unsol_event(struct lpfc_hba *ph | |
5069 | } | |
5070 | } | |
5071 | ||
5072 | +/** | |
5073 | + * lpfc_do_scr_ns_plogi: Issue a plogi to the name server for scr. | |
5074 | + * @phba: pointer to lpfc hba data structure. | |
5075 | + * @vport: pointer to a virtual N_Port data structure. | |
5076 | + * | |
5077 | + * This routine issues a Port Login (PLOGI) to the Name Server with | |
5078 | + * State Change Request (SCR) for a @vport. This routine will create an | |
5079 | + * ndlp for the Name Server associated to the @vport if such node does | |
5080 | + * not already exist. The PLOGI to Name Server is issued by invoking the | |
5081 | + * lpfc_issue_els_plogi() routine. If Fabric-Device Management Interface | |
5082 | + * (FDMI) is configured to the @vport, a FDMI node will be created and | |
5083 | + * the PLOGI to FDMI is issued by invoking lpfc_issue_els_plogi() routine. | |
5084 | + **/ | |
5085 | void | |
5086 | lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport) | |
5087 | { | |
5088 | @@ -4434,6 +5691,18 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *ph | |
5089 | return; | |
5090 | } | |
5091 | ||
5092 | +/** | |
5093 | + * lpfc_cmpl_reg_new_vport: Completion callback function to register new vport. | |
5094 | + * @phba: pointer to lpfc hba data structure. | |
5095 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
5096 | + * | |
5097 | + * This routine is the completion callback function to register new vport | |
5098 | + * mailbox command. If the new vport mailbox command completes successfully, | |
5099 | + * the fabric registration login shall be performed on physical port (the | |
5100 | + * new vport created is actually a physical port, with VPI 0) or the port | |
5101 | + * login to Name Server for State Change Request (SCR) will be performed | |
5102 | + * on virtual port (real virtual port, with VPI greater than 0). | |
5103 | + **/ | |
5104 | static void | |
5105 | lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |
5106 | { | |
5107 | @@ -4491,6 +5760,15 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba | |
5108 | return; | |
5109 | } | |
5110 | ||
5111 | +/** | |
5112 | + * lpfc_register_new_vport: Register a new vport with a HBA. | |
5113 | + * @phba: pointer to lpfc hba data structure. | |
5114 | + * @vport: pointer to a host virtual N_Port data structure. | |
5115 | + * @ndlp: pointer to a node-list data structure. | |
5116 | + * | |
5117 | + * This routine registers the @vport as a new virtual port with a HBA. | |
5118 | + * It is done through a registering vpi mailbox command. | |
5119 | + **/ | |
5120 | static void | |
5121 | lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport, | |
5122 | struct lpfc_nodelist *ndlp) | |
5123 | @@ -4531,6 +5809,26 @@ mbox_err_exit: | |
5124 | return; | |
5125 | } | |
5126 | ||
5127 | +/** | |
5128 | + * lpfc_cmpl_els_fdisc: Completion function for fdisc iocb command. | |
5129 | + * @phba: pointer to lpfc hba data structure. | |
5130 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
5131 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
5132 | + * | |
5133 | + * This routine is the completion callback function to a Fabric Discover | |
5134 | + * (FDISC) ELS command. Since all the FDISC ELS commands are issued | |
5135 | + * single threaded, each FDISC completion callback function will reset | |
5136 | + * the discovery timer for all vports such that the timers will not get | |
5137 | + * unnecessary timeout. The function checks the FDISC IOCB status. If error | |
5138 | + * detected, the vport will be set to FC_VPORT_FAILED state. Otherwise,the | |
5139 | + * vport will set to FC_VPORT_ACTIVE state. It then checks whether the DID | |
5140 | + * assigned to the vport has been changed with the completion of the FDISC | |
5141 | + * command. If so, both RPI (Remote Port Index) and VPI (Virtual Port Index) | |
5142 | + * are unregistered from the HBA, and then the lpfc_register_new_vport() | |
5143 | + * routine is invoked to register new vport with the HBA. Otherwise, the | |
5144 | + * lpfc_do_scr_ns_plogi() routine is invoked to issue a PLOGI to the Name | |
5145 | + * Server for State Change Request (SCR). | |
5146 | + **/ | |
5147 | static void | |
5148 | lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
5149 | struct lpfc_iocbq *rspiocb) | |
5150 | @@ -4565,58 +5863,80 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phb | |
5151 | goto out; | |
5152 | /* FDISC failed */ | |
5153 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, | |
5154 | - "0124 FDISC failed. (%d/%d)\n", | |
5155 | + "0126 FDISC failed. (%d/%d)\n", | |
5156 | irsp->ulpStatus, irsp->un.ulpWord[4]); | |
5157 | + goto fdisc_failed; | |
5158 | + } | |
5159 | if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING) | |
5160 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); | |
5161 | lpfc_nlp_put(ndlp); | |
5162 | /* giving up on FDISC. Cancel discovery timer */ | |
5163 | lpfc_can_disctmo(vport); | |
5164 | - } else { | |
5165 | - spin_lock_irq(shost->host_lock); | |
5166 | - vport->fc_flag |= FC_FABRIC; | |
5167 | - if (vport->phba->fc_topology == TOPOLOGY_LOOP) | |
5168 | - vport->fc_flag |= FC_PUBLIC_LOOP; | |
5169 | - spin_unlock_irq(shost->host_lock); | |
5170 | + spin_lock_irq(shost->host_lock); | |
5171 | + vport->fc_flag |= FC_FABRIC; | |
5172 | + if (vport->phba->fc_topology == TOPOLOGY_LOOP) | |
5173 | + vport->fc_flag |= FC_PUBLIC_LOOP; | |
5174 | + spin_unlock_irq(shost->host_lock); | |
5175 | ||
5176 | - vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; | |
5177 | - lpfc_vport_set_state(vport, FC_VPORT_ACTIVE); | |
5178 | - if ((vport->fc_prevDID != vport->fc_myDID) && | |
5179 | - !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { | |
5180 | - /* If our NportID changed, we need to ensure all | |
5181 | - * remaining NPORTs get unreg_login'ed so we can | |
5182 | - * issue unreg_vpi. | |
5183 | - */ | |
5184 | - list_for_each_entry_safe(np, next_np, | |
5185 | - &vport->fc_nodes, nlp_listp) { | |
5186 | - if (!NLP_CHK_NODE_ACT(ndlp) || | |
5187 | - (np->nlp_state != NLP_STE_NPR_NODE) || | |
5188 | - !(np->nlp_flag & NLP_NPR_ADISC)) | |
5189 | - continue; | |
5190 | - spin_lock_irq(shost->host_lock); | |
5191 | - np->nlp_flag &= ~NLP_NPR_ADISC; | |
5192 | - spin_unlock_irq(shost->host_lock); | |
5193 | - lpfc_unreg_rpi(vport, np); | |
5194 | - } | |
5195 | - lpfc_mbx_unreg_vpi(vport); | |
5196 | + vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; | |
5197 | + lpfc_vport_set_state(vport, FC_VPORT_ACTIVE); | |
5198 | + if ((vport->fc_prevDID != vport->fc_myDID) && | |
5199 | + !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { | |
5200 | + /* If our NportID changed, we need to ensure all | |
5201 | + * remaining NPORTs get unreg_login'ed so we can | |
5202 | + * issue unreg_vpi. | |
5203 | + */ | |
5204 | + list_for_each_entry_safe(np, next_np, | |
5205 | + &vport->fc_nodes, nlp_listp) { | |
5206 | + if (!NLP_CHK_NODE_ACT(ndlp) || | |
5207 | + (np->nlp_state != NLP_STE_NPR_NODE) || | |
5208 | + !(np->nlp_flag & NLP_NPR_ADISC)) | |
5209 | + continue; | |
5210 | spin_lock_irq(shost->host_lock); | |
5211 | - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | |
5212 | + np->nlp_flag &= ~NLP_NPR_ADISC; | |
5213 | spin_unlock_irq(shost->host_lock); | |
5214 | + lpfc_unreg_rpi(vport, np); | |
5215 | } | |
5216 | - | |
5217 | - if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) | |
5218 | - lpfc_register_new_vport(phba, vport, ndlp); | |
5219 | - else | |
5220 | - lpfc_do_scr_ns_plogi(phba, vport); | |
5221 | - | |
5222 | - /* Unconditionaly kick off releasing fabric node for vports */ | |
5223 | - lpfc_nlp_put(ndlp); | |
5224 | + lpfc_mbx_unreg_vpi(vport); | |
5225 | + spin_lock_irq(shost->host_lock); | |
5226 | + vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | |
5227 | + spin_unlock_irq(shost->host_lock); | |
5228 | } | |
5229 | ||
5230 | + if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) | |
5231 | + lpfc_register_new_vport(phba, vport, ndlp); | |
5232 | + else | |
5233 | + lpfc_do_scr_ns_plogi(phba, vport); | |
5234 | + goto out; | |
5235 | +fdisc_failed: | |
5236 | + lpfc_vport_set_state(vport, FC_VPORT_FAILED); | |
5237 | + /* Cancel discovery timer */ | |
5238 | + lpfc_can_disctmo(vport); | |
5239 | + lpfc_nlp_put(ndlp); | |
5240 | out: | |
5241 | lpfc_els_free_iocb(phba, cmdiocb); | |
5242 | } | |
5243 | ||
5244 | +/** | |
5245 | + * lpfc_issue_els_fdisc: Issue a fdisc iocb command. | |
5246 | + * @vport: pointer to a virtual N_Port data structure. | |
5247 | + * @ndlp: pointer to a node-list data structure. | |
5248 | + * @retry: number of retries to the command IOCB. | |
5249 | + * | |
5250 | + * This routine prepares and issues a Fabric Discover (FDISC) IOCB to | |
5251 | + * a remote node (@ndlp) off a @vport. It uses the lpfc_issue_fabric_iocb() | |
5252 | + * routine to issue the IOCB, which makes sure only one outstanding fabric | |
5253 | + * IOCB will be sent off HBA at any given time. | |
5254 | + * | |
5255 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
5256 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
5257 | + * will be stored into the context1 field of the IOCB for the completion | |
5258 | + * callback function to the FDISC ELS command. | |
5259 | + * | |
5260 | + * Return code | |
5261 | + * 0 - Successfully issued fdisc iocb command | |
5262 | + * 1 - Failed to issue fdisc iocb command | |
5263 | + **/ | |
5264 | static int | |
5265 | lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
5266 | uint8_t retry) | |
5267 | @@ -4691,6 +6011,20 @@ lpfc_issue_els_fdisc(struct lpfc_vport * | |
5268 | return 0; | |
5269 | } | |
5270 | ||
5271 | +/** | |
5272 | + * lpfc_cmpl_els_npiv_logo: Completion function with vport logo. | |
5273 | + * @phba: pointer to lpfc hba data structure. | |
5274 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
5275 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
5276 | + * | |
5277 | + * This routine is the completion callback function to the issuing of a LOGO | |
5278 | + * ELS command off a vport. It frees the command IOCB and then decrement the | |
5279 | + * reference count held on ndlp for this completion function, indicating that | |
5280 | + * the reference to the ndlp is no long needed. Note that the | |
5281 | + * lpfc_els_free_iocb() routine decrements the ndlp reference held for this | |
5282 | + * callback function and an additional explicit ndlp reference decrementation | |
5283 | + * will trigger the actual release of the ndlp. | |
5284 | + **/ | |
5285 | static void | |
5286 | lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
5287 | struct lpfc_iocbq *rspiocb) | |
5288 | @@ -4712,6 +6046,22 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba | |
5289 | lpfc_nlp_put(ndlp); | |
5290 | } | |
5291 | ||
5292 | +/** | |
5293 | + * lpfc_issue_els_npiv_logo: Issue a logo off a vport. | |
5294 | + * @vport: pointer to a virtual N_Port data structure. | |
5295 | + * @ndlp: pointer to a node-list data structure. | |
5296 | + * | |
5297 | + * This routine issues a LOGO ELS command to an @ndlp off a @vport. | |
5298 | + * | |
5299 | + * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp | |
5300 | + * will be incremented by 1 for holding the ndlp and the reference to ndlp | |
5301 | + * will be stored into the context1 field of the IOCB for the completion | |
5302 | + * callback function to the LOGO ELS command. | |
5303 | + * | |
5304 | + * Return codes | |
5305 | + * 0 - Successfully issued logo off the @vport | |
5306 | + * 1 - Failed to issue logo off the @vport | |
5307 | + **/ | |
5308 | int | |
5309 | lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |
5310 | { | |
5311 | @@ -4757,6 +6107,17 @@ lpfc_issue_els_npiv_logo(struct lpfc_vpo | |
5312 | return 0; | |
5313 | } | |
5314 | ||
5315 | +/** | |
5316 | + * lpfc_fabric_block_timeout: Handler function to the fabric block timer. | |
5317 | + * @ptr: holder for the timer function associated data. | |
5318 | + * | |
5319 | + * This routine is invoked by the fabric iocb block timer after | |
5320 | + * timeout. It posts the fabric iocb block timeout event by setting the | |
5321 | + * WORKER_FABRIC_BLOCK_TMO bit to work port event bitmap and then invokes | |
5322 | + * lpfc_worker_wake_up() routine to wake up the worker thread. It is for | |
5323 | + * the worker thread to invoke the lpfc_unblock_fabric_iocbs() on the | |
5324 | + * posted event WORKER_FABRIC_BLOCK_TMO. | |
5325 | + **/ | |
5326 | void | |
5327 | lpfc_fabric_block_timeout(unsigned long ptr) | |
5328 | { | |
5329 | @@ -4775,6 +6136,16 @@ lpfc_fabric_block_timeout(unsigned long | |
5330 | return; | |
5331 | } | |
5332 | ||
5333 | +/** | |
5334 | + * lpfc_resume_fabric_iocbs: Issue a fabric iocb from driver internal list. | |
5335 | + * @phba: pointer to lpfc hba data structure. | |
5336 | + * | |
5337 | + * This routine issues one fabric iocb from the driver internal list to | |
5338 | + * the HBA. It first checks whether it's ready to issue one fabric iocb to | |
5339 | + * the HBA (whether there is no outstanding fabric iocb). If so, it shall | |
5340 | + * remove one pending fabric iocb from the driver internal list and invokes | |
5341 | + * lpfc_sli_issue_iocb() routine to send the fabric iocb to the HBA. | |
5342 | + **/ | |
5343 | static void | |
5344 | lpfc_resume_fabric_iocbs(struct lpfc_hba *phba) | |
5345 | { | |
5346 | @@ -4824,6 +6195,15 @@ repeat: | |
5347 | return; | |
5348 | } | |
5349 | ||
5350 | +/** | |
5351 | + * lpfc_unblock_fabric_iocbs: Unblock issuing fabric iocb command. | |
5352 | + * @phba: pointer to lpfc hba data structure. | |
5353 | + * | |
5354 | + * This routine unblocks the issuing fabric iocb command. The function | |
5355 | + * will clear the fabric iocb block bit and then invoke the routine | |
5356 | + * lpfc_resume_fabric_iocbs() to issue one of the pending fabric iocb | |
5357 | + * from the driver internal fabric iocb list. | |
5358 | + **/ | |
5359 | void | |
5360 | lpfc_unblock_fabric_iocbs(struct lpfc_hba *phba) | |
5361 | { | |
5362 | @@ -4833,6 +6213,15 @@ lpfc_unblock_fabric_iocbs(struct lpfc_hb | |
5363 | return; | |
5364 | } | |
5365 | ||
5366 | +/** | |
5367 | + * lpfc_block_fabric_iocbs: Block issuing fabric iocb command. | |
5368 | + * @phba: pointer to lpfc hba data structure. | |
5369 | + * | |
5370 | + * This routine blocks the issuing fabric iocb for a specified amount of | |
5371 | + * time (currently 100 ms). This is done by set the fabric iocb block bit | |
5372 | + * and set up a timeout timer for 100ms. When the block bit is set, no more | |
5373 | + * fabric iocb will be issued out of the HBA. | |
5374 | + **/ | |
5375 | static void | |
5376 | lpfc_block_fabric_iocbs(struct lpfc_hba *phba) | |
5377 | { | |
5378 | @@ -4846,6 +6235,19 @@ lpfc_block_fabric_iocbs(struct lpfc_hba | |
5379 | return; | |
5380 | } | |
5381 | ||
5382 | +/** | |
5383 | + * lpfc_cmpl_fabric_iocb: Completion callback function for fabric iocb. | |
5384 | + * @phba: pointer to lpfc hba data structure. | |
5385 | + * @cmdiocb: pointer to lpfc command iocb data structure. | |
5386 | + * @rspiocb: pointer to lpfc response iocb data structure. | |
5387 | + * | |
5388 | + * This routine is the callback function that is put to the fabric iocb's | |
5389 | + * callback function pointer (iocb->iocb_cmpl). The original iocb's callback | |
5390 | + * function pointer has been stored in iocb->fabric_iocb_cmpl. This callback | |
5391 | + * function first restores and invokes the original iocb's callback function | |
5392 | + * and then invokes the lpfc_resume_fabric_iocbs() routine to issue the next | |
5393 | + * fabric bound iocb from the driver internal fabric iocb list onto the wire. | |
5394 | + **/ | |
5395 | static void | |
5396 | lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
5397 | struct lpfc_iocbq *rspiocb) | |
5398 | @@ -4892,6 +6294,30 @@ lpfc_cmpl_fabric_iocb(struct lpfc_hba *p | |
5399 | } | |
5400 | } | |
5401 | ||
5402 | +/** | |
5403 | + * lpfc_issue_fabric_iocb: Issue a fabric iocb command. | |
5404 | + * @phba: pointer to lpfc hba data structure. | |
5405 | + * @iocb: pointer to lpfc command iocb data structure. | |
5406 | + * | |
5407 | + * This routine is used as the top-level API for issuing a fabric iocb command | |
5408 | + * such as FLOGI and FDISC. To accommodate certain switch fabric, this driver | |
5409 | + * function makes sure that only one fabric bound iocb will be outstanding at | |
5410 | + * any given time. As such, this function will first check to see whether there | |
5411 | + * is already an outstanding fabric iocb on the wire. If so, it will put the | |
5412 | + * newly issued iocb onto the driver internal fabric iocb list, waiting to be | |
5413 | + * issued later. Otherwise, it will issue the iocb on the wire and update the | |
5414 | + * fabric iocb count it indicate that there is one fabric iocb on the wire. | |
5415 | + * | |
5416 | + * Note, this implementation has a potential sending out fabric IOCBs out of | |
5417 | + * order. The problem is caused by the construction of the "ready" boolen does | |
5418 | + * not include the condition that the internal fabric IOCB list is empty. As | |
5419 | + * such, it is possible a fabric IOCB issued by this routine might be "jump" | |
5420 | + * ahead of the fabric IOCBs in the internal list. | |
5421 | + * | |
5422 | + * Return code | |
5423 | + * IOCB_SUCCESS - either fabric iocb put on the list or issued successfully | |
5424 | + * IOCB_ERROR - failed to issue fabric iocb | |
5425 | + **/ | |
5426 | static int | |
5427 | lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) | |
5428 | { | |
5429 | @@ -4937,7 +6363,17 @@ lpfc_issue_fabric_iocb(struct lpfc_hba * | |
5430 | return ret; | |
5431 | } | |
5432 | ||
5433 | - | |
5434 | +/** | |
5435 | + * lpfc_fabric_abort_vport: Abort a vport's iocbs from driver fabric iocb list. | |
5436 | + * @vport: pointer to a virtual N_Port data structure. | |
5437 | + * | |
5438 | + * This routine aborts all the IOCBs associated with a @vport from the | |
5439 | + * driver internal fabric IOCB list. The list contains fabric IOCBs to be | |
5440 | + * issued to the ELS IOCB ring. This abort function walks the fabric IOCB | |
5441 | + * list, removes each IOCB associated with the @vport off the list, set the | |
5442 | + * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function | |
5443 | + * associated with the IOCB. | |
5444 | + **/ | |
5445 | static void lpfc_fabric_abort_vport(struct lpfc_vport *vport) | |
5446 | { | |
5447 | LIST_HEAD(completions); | |
5448 | @@ -4967,6 +6403,17 @@ static void lpfc_fabric_abort_vport(stru | |
5449 | } | |
5450 | } | |
5451 | ||
5452 | +/** | |
5453 | + * lpfc_fabric_abort_nport: Abort a ndlp's iocbs from driver fabric iocb list. | |
5454 | + * @ndlp: pointer to a node-list data structure. | |
5455 | + * | |
5456 | + * This routine aborts all the IOCBs associated with an @ndlp from the | |
5457 | + * driver internal fabric IOCB list. The list contains fabric IOCBs to be | |
5458 | + * issued to the ELS IOCB ring. This abort function walks the fabric IOCB | |
5459 | + * list, removes each IOCB associated with the @ndlp off the list, set the | |
5460 | + * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function | |
5461 | + * associated with the IOCB. | |
5462 | + **/ | |
5463 | void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) | |
5464 | { | |
5465 | LIST_HEAD(completions); | |
5466 | @@ -4996,6 +6443,17 @@ void lpfc_fabric_abort_nport(struct lpfc | |
5467 | } | |
5468 | } | |
5469 | ||
5470 | +/** | |
5471 | + * lpfc_fabric_abort_hba: Abort all iocbs on driver fabric iocb list. | |
5472 | + * @phba: pointer to lpfc hba data structure. | |
5473 | + * | |
5474 | + * This routine aborts all the IOCBs currently on the driver internal | |
5475 | + * fabric IOCB list. The list contains fabric IOCBs to be issued to the ELS | |
5476 | + * IOCB ring. This function takes the entire IOCB list off the fabric IOCB | |
5477 | + * list, removes IOCBs off the list, set the status feild to | |
5478 | + * IOSTAT_LOCAL_REJECT, and invokes the callback function associated with | |
5479 | + * the IOCB. | |
5480 | + **/ | |
5481 | void lpfc_fabric_abort_hba(struct lpfc_hba *phba) | |
5482 | { | |
5483 | LIST_HEAD(completions); | |
5484 | --- a/drivers/scsi/lpfc/lpfc.h | |
5485 | +++ b/drivers/scsi/lpfc/lpfc.h | |
5486 | @@ -34,7 +34,14 @@ struct lpfc_sli2_slim; | |
5487 | #define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */ | |
5488 | #define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */ | |
5489 | #define LPFC_VNAME_LEN 100 /* vport symbolic name length */ | |
5490 | +#define LPFC_TGTQ_INTERVAL 40000 /* Min amount of time between tgt | |
5491 | + queue depth change in millisecs */ | |
5492 | +#define LPFC_TGTQ_RAMPUP_PCENT 5 /* Target queue rampup in percentage */ | |
5493 | +#define LPFC_MIN_TGT_QDEPTH 100 | |
5494 | +#define LPFC_MAX_TGT_QDEPTH 0xFFFF | |
5495 | ||
5496 | +#define LPFC_MAX_BUCKET_COUNT 20 /* Maximum no. of buckets for stat data | |
5497 | + collection. */ | |
5498 | /* | |
5499 | * Following time intervals are used of adjusting SCSI device | |
5500 | * queue depths when there are driver resource error or Firmware | |
5501 | @@ -49,6 +56,9 @@ struct lpfc_sli2_slim; | |
5502 | #define LPFC_HB_MBOX_INTERVAL 5 /* Heart beat interval in seconds. */ | |
5503 | #define LPFC_HB_MBOX_TIMEOUT 30 /* Heart beat timeout in seconds. */ | |
5504 | ||
5505 | +/* Error Attention event polling interval */ | |
5506 | +#define LPFC_ERATT_POLL_INTERVAL 5 /* EATT poll interval in seconds */ | |
5507 | + | |
5508 | /* Define macros for 64 bit support */ | |
5509 | #define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr))) | |
5510 | #define putPaddrHigh(addr) ((uint32_t) (0xffffffff & (((u64)(addr))>>32))) | |
5511 | @@ -60,6 +70,9 @@ struct lpfc_sli2_slim; | |
5512 | ||
5513 | #define MAX_HBAEVT 32 | |
5514 | ||
5515 | +/* Number of MSI-X vectors the driver uses */ | |
5516 | +#define LPFC_MSIX_VECTORS 2 | |
5517 | + | |
5518 | /* lpfc wait event data ready flag */ | |
5519 | #define LPFC_DATA_READY (1<<0) | |
5520 | ||
5521 | @@ -357,6 +370,7 @@ struct lpfc_vport { | |
5522 | uint32_t cfg_log_verbose; | |
5523 | uint32_t cfg_max_luns; | |
5524 | uint32_t cfg_enable_da_id; | |
5525 | + uint32_t cfg_max_scsicmpl_time; | |
5526 | ||
5527 | uint32_t dev_loss_tmo_changed; | |
5528 | ||
5529 | @@ -369,6 +383,8 @@ struct lpfc_vport { | |
5530 | struct lpfc_debugfs_trc *disc_trc; | |
5531 | atomic_t disc_trc_cnt; | |
5532 | #endif | |
5533 | + uint8_t stat_data_enabled; | |
5534 | + uint8_t stat_data_blocked; | |
5535 | }; | |
5536 | ||
5537 | struct hbq_s { | |
5538 | @@ -407,10 +423,11 @@ struct lpfc_hba { | |
5539 | struct lpfc_sli sli; | |
5540 | uint32_t sli_rev; /* SLI2 or SLI3 */ | |
5541 | uint32_t sli3_options; /* Mask of enabled SLI3 options */ | |
5542 | -#define LPFC_SLI3_ENABLED 0x01 | |
5543 | -#define LPFC_SLI3_HBQ_ENABLED 0x02 | |
5544 | -#define LPFC_SLI3_NPIV_ENABLED 0x04 | |
5545 | -#define LPFC_SLI3_VPORT_TEARDOWN 0x08 | |
5546 | +#define LPFC_SLI3_HBQ_ENABLED 0x01 | |
5547 | +#define LPFC_SLI3_NPIV_ENABLED 0x02 | |
5548 | +#define LPFC_SLI3_VPORT_TEARDOWN 0x04 | |
5549 | +#define LPFC_SLI3_CRP_ENABLED 0x08 | |
5550 | +#define LPFC_SLI3_INB_ENABLED 0x10 | |
5551 | uint32_t iocb_cmd_size; | |
5552 | uint32_t iocb_rsp_size; | |
5553 | ||
5554 | @@ -422,10 +439,20 @@ struct lpfc_hba { | |
5555 | #define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */ | |
5556 | #define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */ | |
5557 | ||
5558 | - struct lpfc_sli2_slim *slim2p; | |
5559 | - struct lpfc_dmabuf hbqslimp; | |
5560 | + uint32_t hba_flag; /* hba generic flags */ | |
5561 | +#define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */ | |
5562 | ||
5563 | - dma_addr_t slim2p_mapping; | |
5564 | + struct lpfc_dmabuf slim2p; | |
5565 | + | |
5566 | + MAILBOX_t *mbox; | |
5567 | + uint32_t *inb_ha_copy; | |
5568 | + uint32_t *inb_counter; | |
5569 | + uint32_t inb_last_counter; | |
5570 | + uint32_t ha_copy; | |
5571 | + struct _PCB *pcb; | |
5572 | + struct _IOCB *IOCBs; | |
5573 | + | |
5574 | + struct lpfc_dmabuf hbqslimp; | |
5575 | ||
5576 | uint16_t pci_cfg_value; | |
5577 | ||
5578 | @@ -492,7 +519,7 @@ struct lpfc_hba { | |
5579 | ||
5580 | wait_queue_head_t work_waitq; | |
5581 | struct task_struct *worker_thread; | |
5582 | - long data_flags; | |
5583 | + unsigned long data_flags; | |
5584 | ||
5585 | uint32_t hbq_in_use; /* HBQs in use flag */ | |
5586 | struct list_head hbqbuf_in_list; /* in-fly hbq buffer list */ | |
5587 | @@ -514,6 +541,7 @@ struct lpfc_hba { | |
5588 | void __iomem *HCregaddr; /* virtual address for host ctl reg */ | |
5589 | ||
5590 | struct lpfc_hgp __iomem *host_gp; /* Host side get/put pointers */ | |
5591 | + struct lpfc_pgp *port_gp; | |
5592 | uint32_t __iomem *hbq_put; /* Address in SLIM to HBQ put ptrs */ | |
5593 | uint32_t *hbq_get; /* Host mem address of HBQ get ptrs */ | |
5594 | ||
5595 | @@ -536,6 +564,7 @@ struct lpfc_hba { | |
5596 | uint8_t soft_wwn_enable; | |
5597 | ||
5598 | struct timer_list fcp_poll_timer; | |
5599 | + struct timer_list eratt_poll; | |
5600 | ||
5601 | /* | |
5602 | * stat counters | |
5603 | @@ -565,7 +594,7 @@ struct lpfc_hba { | |
5604 | ||
5605 | struct fc_host_statistics link_stats; | |
5606 | enum intr_type_t intr_type; | |
5607 | - struct msix_entry msix_entries[1]; | |
5608 | + struct msix_entry msix_entries[LPFC_MSIX_VECTORS]; | |
5609 | ||
5610 | struct list_head port_list; | |
5611 | struct lpfc_vport *pport; /* physical lpfc_vport pointer */ | |
5612 | @@ -605,6 +634,7 @@ struct lpfc_hba { | |
5613 | unsigned long last_completion_time; | |
5614 | struct timer_list hb_tmofunc; | |
5615 | uint8_t hb_outstanding; | |
5616 | + enum hba_temp_state over_temp_state; | |
5617 | /* ndlp reference management */ | |
5618 | spinlock_t ndlp_lock; | |
5619 | /* | |
5620 | @@ -613,7 +643,19 @@ struct lpfc_hba { | |
5621 | */ | |
5622 | #define QUE_BUFTAG_BIT (1<<31) | |
5623 | uint32_t buffer_tag_count; | |
5624 | - enum hba_temp_state over_temp_state; | |
5625 | + int wait_4_mlo_maint_flg; | |
5626 | + wait_queue_head_t wait_4_mlo_m_q; | |
5627 | + /* data structure used for latency data collection */ | |
5628 | +#define LPFC_NO_BUCKET 0 | |
5629 | +#define LPFC_LINEAR_BUCKET 1 | |
5630 | +#define LPFC_POWER2_BUCKET 2 | |
5631 | + uint8_t bucket_type; | |
5632 | + uint32_t bucket_base; | |
5633 | + uint32_t bucket_step; | |
5634 | + | |
5635 | +/* Maximum number of events that can be outstanding at any time*/ | |
5636 | +#define LPFC_MAX_EVT_COUNT 512 | |
5637 | + atomic_t fast_event_count; | |
5638 | }; | |
5639 | ||
5640 | static inline struct Scsi_Host * | |
5641 | @@ -650,15 +692,25 @@ lpfc_worker_wake_up(struct lpfc_hba *phb | |
5642 | return; | |
5643 | } | |
5644 | ||
5645 | -#define FC_REG_DUMP_EVENT 0x10 /* Register for Dump events */ | |
5646 | -#define FC_REG_TEMPERATURE_EVENT 0x20 /* Register for temperature | |
5647 | - event */ | |
5648 | - | |
5649 | -struct temp_event { | |
5650 | - uint32_t event_type; | |
5651 | - uint32_t event_code; | |
5652 | - uint32_t data; | |
5653 | -}; | |
5654 | -#define LPFC_CRIT_TEMP 0x1 | |
5655 | -#define LPFC_THRESHOLD_TEMP 0x2 | |
5656 | -#define LPFC_NORMAL_TEMP 0x3 | |
5657 | +static inline void | |
5658 | +lpfc_sli_read_hs(struct lpfc_hba *phba) | |
5659 | +{ | |
5660 | + /* | |
5661 | + * There was a link/board error. Read the status register to retrieve | |
5662 | + * the error event and process it. | |
5663 | + */ | |
5664 | + phba->sli.slistat.err_attn_event++; | |
5665 | + | |
5666 | + /* Save status info */ | |
5667 | + phba->work_hs = readl(phba->HSregaddr); | |
5668 | + phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); | |
5669 | + phba->work_status[1] = readl(phba->MBslimaddr + 0xac); | |
5670 | + | |
5671 | + /* Clear chip Host Attention error bit */ | |
5672 | + writel(HA_ERATT, phba->HAregaddr); | |
5673 | + readl(phba->HAregaddr); /* flush */ | |
5674 | + phba->pport->stopped = 1; | |
5675 | + | |
5676 | + return; | |
5677 | +} | |
5678 | + | |
5679 | --- a/drivers/scsi/lpfc/lpfc_hbadisc.c | |
5680 | +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |
5681 | @@ -30,6 +30,7 @@ | |
5682 | #include <scsi/scsi_transport_fc.h> | |
5683 | ||
5684 | #include "lpfc_hw.h" | |
5685 | +#include "lpfc_nl.h" | |
5686 | #include "lpfc_disc.h" | |
5687 | #include "lpfc_sli.h" | |
5688 | #include "lpfc_scsi.h" | |
5689 | @@ -207,8 +208,16 @@ lpfc_dev_loss_tmo_handler(struct lpfc_no | |
5690 | return; | |
5691 | } | |
5692 | ||
5693 | - if (ndlp->nlp_state == NLP_STE_MAPPED_NODE) | |
5694 | + if (ndlp->nlp_state == NLP_STE_MAPPED_NODE) { | |
5695 | + lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | |
5696 | + "0284 Devloss timeout Ignored on " | |
5697 | + "WWPN %x:%x:%x:%x:%x:%x:%x:%x " | |
5698 | + "NPort x%x\n", | |
5699 | + *name, *(name+1), *(name+2), *(name+3), | |
5700 | + *(name+4), *(name+5), *(name+6), *(name+7), | |
5701 | + ndlp->nlp_DID); | |
5702 | return; | |
5703 | + } | |
5704 | ||
5705 | if (ndlp->nlp_type & NLP_FABRIC) { | |
5706 | /* We will clean up these Nodes in linkup */ | |
5707 | @@ -229,8 +238,6 @@ lpfc_dev_loss_tmo_handler(struct lpfc_no | |
5708 | lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring], | |
5709 | ndlp->nlp_sid, 0, LPFC_CTX_TGT); | |
5710 | } | |
5711 | - if (vport->load_flag & FC_UNLOADING) | |
5712 | - warn_on = 0; | |
5713 | ||
5714 | if (warn_on) { | |
5715 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, | |
5716 | @@ -268,6 +275,124 @@ lpfc_dev_loss_tmo_handler(struct lpfc_no | |
5717 | lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM); | |
5718 | } | |
5719 | ||
5720 | +/** | |
5721 | + * lpfc_alloc_fast_evt: Allocates data structure for posting event. | |
5722 | + * @phba: Pointer to hba context object. | |
5723 | + * | |
5724 | + * This function is called from the functions which need to post | |
5725 | + * events from interrupt context. This function allocates data | |
5726 | + * structure required for posting event. It also keeps track of | |
5727 | + * number of events pending and prevent event storm when there are | |
5728 | + * too many events. | |
5729 | + **/ | |
5730 | +struct lpfc_fast_path_event * | |
5731 | +lpfc_alloc_fast_evt(struct lpfc_hba *phba) { | |
5732 | + struct lpfc_fast_path_event *ret; | |
5733 | + | |
5734 | + /* If there are lot of fast event do not exhaust memory due to this */ | |
5735 | + if (atomic_read(&phba->fast_event_count) > LPFC_MAX_EVT_COUNT) | |
5736 | + return NULL; | |
5737 | + | |
5738 | + ret = kzalloc(sizeof(struct lpfc_fast_path_event), | |
5739 | + GFP_ATOMIC); | |
5740 | + if (ret) | |
5741 | + atomic_inc(&phba->fast_event_count); | |
5742 | + INIT_LIST_HEAD(&ret->work_evt.evt_listp); | |
5743 | + ret->work_evt.evt = LPFC_EVT_FASTPATH_MGMT_EVT; | |
5744 | + return ret; | |
5745 | +} | |
5746 | + | |
5747 | +/** | |
5748 | + * lpfc_free_fast_evt: Frees event data structure. | |
5749 | + * @phba: Pointer to hba context object. | |
5750 | + * @evt: Event object which need to be freed. | |
5751 | + * | |
5752 | + * This function frees the data structure required for posting | |
5753 | + * events. | |
5754 | + **/ | |
5755 | +void | |
5756 | +lpfc_free_fast_evt(struct lpfc_hba *phba, | |
5757 | + struct lpfc_fast_path_event *evt) { | |
5758 | + | |
5759 | + atomic_dec(&phba->fast_event_count); | |
5760 | + kfree(evt); | |
5761 | +} | |
5762 | + | |
5763 | +/** | |
5764 | + * lpfc_send_fastpath_evt: Posts events generated from fast path. | |
5765 | + * @phba: Pointer to hba context object. | |
5766 | + * @evtp: Event data structure. | |
5767 | + * | |
5768 | + * This function is called from worker thread, when the interrupt | |
5769 | + * context need to post an event. This function posts the event | |
5770 | + * to fc transport netlink interface. | |
5771 | + **/ | |
5772 | +static void | |
5773 | +lpfc_send_fastpath_evt(struct lpfc_hba *phba, | |
5774 | + struct lpfc_work_evt *evtp) | |
5775 | +{ | |
5776 | + unsigned long evt_category, evt_sub_category; | |
5777 | + struct lpfc_fast_path_event *fast_evt_data; | |
5778 | + char *evt_data; | |
5779 | + uint32_t evt_data_size; | |
5780 | + struct Scsi_Host *shost; | |
5781 | + | |
5782 | + fast_evt_data = container_of(evtp, struct lpfc_fast_path_event, | |
5783 | + work_evt); | |
5784 | + | |
5785 | + evt_category = (unsigned long) fast_evt_data->un.fabric_evt.event_type; | |
5786 | + evt_sub_category = (unsigned long) fast_evt_data->un. | |
5787 | + fabric_evt.subcategory; | |
5788 | + shost = lpfc_shost_from_vport(fast_evt_data->vport); | |
5789 | + if (evt_category == FC_REG_FABRIC_EVENT) { | |
5790 | + if (evt_sub_category == LPFC_EVENT_FCPRDCHKERR) { | |
5791 | + evt_data = (char *) &fast_evt_data->un.read_check_error; | |
5792 | + evt_data_size = sizeof(fast_evt_data->un. | |
5793 | + read_check_error); | |
5794 | + } else if ((evt_sub_category == LPFC_EVENT_FABRIC_BUSY) || | |
5795 | + (evt_sub_category == IOSTAT_NPORT_BSY)) { | |
5796 | + evt_data = (char *) &fast_evt_data->un.fabric_evt; | |
5797 | + evt_data_size = sizeof(fast_evt_data->un.fabric_evt); | |
5798 | + } else { | |
5799 | + lpfc_free_fast_evt(phba, fast_evt_data); | |
5800 | + return; | |
5801 | + } | |
5802 | + } else if (evt_category == FC_REG_SCSI_EVENT) { | |
5803 | + switch (evt_sub_category) { | |
5804 | + case LPFC_EVENT_QFULL: | |
5805 | + case LPFC_EVENT_DEVBSY: | |
5806 | + evt_data = (char *) &fast_evt_data->un.scsi_evt; | |
5807 | + evt_data_size = sizeof(fast_evt_data->un.scsi_evt); | |
5808 | + break; | |
5809 | + case LPFC_EVENT_CHECK_COND: | |
5810 | + evt_data = (char *) &fast_evt_data->un.check_cond_evt; | |
5811 | + evt_data_size = sizeof(fast_evt_data->un. | |
5812 | + check_cond_evt); | |
5813 | + break; | |
5814 | + case LPFC_EVENT_VARQUEDEPTH: | |
5815 | + evt_data = (char *) &fast_evt_data->un.queue_depth_evt; | |
5816 | + evt_data_size = sizeof(fast_evt_data->un. | |
5817 | + queue_depth_evt); | |
5818 | + break; | |
5819 | + default: | |
5820 | + lpfc_free_fast_evt(phba, fast_evt_data); | |
5821 | + return; | |
5822 | + } | |
5823 | + } else { | |
5824 | + lpfc_free_fast_evt(phba, fast_evt_data); | |
5825 | + return; | |
5826 | + } | |
5827 | + | |
5828 | + fc_host_post_vendor_event(shost, | |
5829 | + fc_get_event_number(), | |
5830 | + evt_data_size, | |
5831 | + evt_data, | |
5832 | + SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
5833 | + | |
5834 | + lpfc_free_fast_evt(phba, fast_evt_data); | |
5835 | + return; | |
5836 | +} | |
5837 | + | |
5838 | static void | |
5839 | lpfc_work_list_done(struct lpfc_hba *phba) | |
5840 | { | |
5841 | @@ -339,6 +464,10 @@ lpfc_work_list_done(struct lpfc_hba *phb | |
5842 | lpfc_unblock_mgmt_io(phba); | |
5843 | complete((struct completion *)(evtp->evt_arg2)); | |
5844 | break; | |
5845 | + case LPFC_EVT_FASTPATH_MGMT_EVT: | |
5846 | + lpfc_send_fastpath_evt(phba, evtp); | |
5847 | + free_evt = 0; | |
5848 | + break; | |
5849 | } | |
5850 | if (free_evt) | |
5851 | kfree(evtp); | |
5852 | @@ -363,6 +492,7 @@ lpfc_work_done(struct lpfc_hba *phba) | |
5853 | spin_unlock_irq(&phba->hbalock); | |
5854 | ||
5855 | if (ha_copy & HA_ERATT) | |
5856 | + /* Handle the error attention event */ | |
5857 | lpfc_handle_eratt(phba); | |
5858 | ||
5859 | if (ha_copy & HA_MBATT) | |
5860 | @@ -370,6 +500,7 @@ lpfc_work_done(struct lpfc_hba *phba) | |
5861 | ||
5862 | if (ha_copy & HA_LATT) | |
5863 | lpfc_handle_latt(phba); | |
5864 | + | |
5865 | vports = lpfc_create_vport_work_array(phba); | |
5866 | if (vports != NULL) | |
5867 | for(i = 0; i <= phba->max_vpi; i++) { | |
5868 | @@ -1005,14 +1136,10 @@ out: | |
5869 | } | |
5870 | ||
5871 | static void | |
5872 | -lpfc_mbx_issue_link_down(struct lpfc_hba *phba) | |
5873 | +lpfc_enable_la(struct lpfc_hba *phba) | |
5874 | { | |
5875 | uint32_t control; | |
5876 | struct lpfc_sli *psli = &phba->sli; | |
5877 | - | |
5878 | - lpfc_linkdown(phba); | |
5879 | - | |
5880 | - /* turn on Link Attention interrupts - no CLEAR_LA needed */ | |
5881 | spin_lock_irq(&phba->hbalock); | |
5882 | psli->sli_flag |= LPFC_PROCESS_LA; | |
5883 | control = readl(phba->HCregaddr); | |
5884 | @@ -1022,6 +1149,15 @@ lpfc_mbx_issue_link_down(struct lpfc_hba | |
5885 | spin_unlock_irq(&phba->hbalock); | |
5886 | } | |
5887 | ||
5888 | +static void | |
5889 | +lpfc_mbx_issue_link_down(struct lpfc_hba *phba) | |
5890 | +{ | |
5891 | + lpfc_linkdown(phba); | |
5892 | + lpfc_enable_la(phba); | |
5893 | + /* turn on Link Attention interrupts - no CLEAR_LA needed */ | |
5894 | +} | |
5895 | + | |
5896 | + | |
5897 | /* | |
5898 | * This routine handles processing a READ_LA mailbox | |
5899 | * command upon completion. It is setup in the LPFC_MBOXQ | |
5900 | @@ -1069,8 +1205,12 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *p | |
5901 | } | |
5902 | ||
5903 | phba->fc_eventTag = la->eventTag; | |
5904 | + if (la->mm) | |
5905 | + phba->sli.sli_flag |= LPFC_MENLO_MAINT; | |
5906 | + else | |
5907 | + phba->sli.sli_flag &= ~LPFC_MENLO_MAINT; | |
5908 | ||
5909 | - if (la->attType == AT_LINK_UP) { | |
5910 | + if (la->attType == AT_LINK_UP && (!la->mm)) { | |
5911 | phba->fc_stat.LinkUp++; | |
5912 | if (phba->link_flag & LS_LOOPBACK_MODE) { | |
5913 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
5914 | @@ -1082,13 +1222,15 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *p | |
5915 | } else { | |
5916 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
5917 | "1303 Link Up Event x%x received " | |
5918 | - "Data: x%x x%x x%x x%x\n", | |
5919 | + "Data: x%x x%x x%x x%x x%x x%x %d\n", | |
5920 | la->eventTag, phba->fc_eventTag, | |
5921 | la->granted_AL_PA, la->UlnkSpeed, | |
5922 | - phba->alpa_map[0]); | |
5923 | + phba->alpa_map[0], | |
5924 | + la->mm, la->fa, | |
5925 | + phba->wait_4_mlo_maint_flg); | |
5926 | } | |
5927 | lpfc_mbx_process_link_up(phba, la); | |
5928 | - } else { | |
5929 | + } else if (la->attType == AT_LINK_DOWN) { | |
5930 | phba->fc_stat.LinkDown++; | |
5931 | if (phba->link_flag & LS_LOOPBACK_MODE) { | |
5932 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
5933 | @@ -1101,11 +1243,46 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *p | |
5934 | else { | |
5935 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
5936 | "1305 Link Down Event x%x received " | |
5937 | + "Data: x%x x%x x%x x%x x%x\n", | |
5938 | + la->eventTag, phba->fc_eventTag, | |
5939 | + phba->pport->port_state, vport->fc_flag, | |
5940 | + la->mm, la->fa); | |
5941 | + } | |
5942 | + lpfc_mbx_issue_link_down(phba); | |
5943 | + } | |
5944 | + if (la->mm && la->attType == AT_LINK_UP) { | |
5945 | + if (phba->link_state != LPFC_LINK_DOWN) { | |
5946 | + phba->fc_stat.LinkDown++; | |
5947 | + lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
5948 | + "1312 Link Down Event x%x received " | |
5949 | + "Data: x%x x%x x%x\n", | |
5950 | + la->eventTag, phba->fc_eventTag, | |
5951 | + phba->pport->port_state, vport->fc_flag); | |
5952 | + lpfc_mbx_issue_link_down(phba); | |
5953 | + } else | |
5954 | + lpfc_enable_la(phba); | |
5955 | + | |
5956 | + lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
5957 | + "1310 Menlo Maint Mode Link up Event x%x rcvd " | |
5958 | "Data: x%x x%x x%x\n", | |
5959 | la->eventTag, phba->fc_eventTag, | |
5960 | phba->pport->port_state, vport->fc_flag); | |
5961 | + /* | |
5962 | + * The cmnd that triggered this will be waiting for this | |
5963 | + * signal. | |
5964 | + */ | |
5965 | + /* WAKEUP for MENLO_SET_MODE or MENLO_RESET command. */ | |
5966 | + if (phba->wait_4_mlo_maint_flg) { | |
5967 | + phba->wait_4_mlo_maint_flg = 0; | |
5968 | + wake_up_interruptible(&phba->wait_4_mlo_m_q); | |
5969 | } | |
5970 | - lpfc_mbx_issue_link_down(phba); | |
5971 | + } | |
5972 | + | |
5973 | + if (la->fa) { | |
5974 | + if (la->mm) | |
5975 | + lpfc_issue_clear_la(phba, vport); | |
5976 | + lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, | |
5977 | + "1311 fa %d\n", la->fa); | |
5978 | } | |
5979 | ||
5980 | lpfc_mbx_cmpl_read_la_free_mbuf: | |
5981 | @@ -1169,7 +1346,7 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba | |
5982 | scsi_host_put(shost); | |
5983 | } | |
5984 | ||
5985 | -void | |
5986 | +int | |
5987 | lpfc_mbx_unreg_vpi(struct lpfc_vport *vport) | |
5988 | { | |
5989 | struct lpfc_hba *phba = vport->phba; | |
5990 | @@ -1178,7 +1355,7 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vp | |
5991 | ||
5992 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
5993 | if (!mbox) | |
5994 | - return; | |
5995 | + return 1; | |
5996 | ||
5997 | lpfc_unreg_vpi(phba, vport->vpi, mbox); | |
5998 | mbox->vport = vport; | |
5999 | @@ -1189,7 +1366,9 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vp | |
6000 | "1800 Could not issue unreg_vpi\n"); | |
6001 | mempool_free(mbox, phba->mbox_mem_pool); | |
6002 | vport->unreg_vpi_cmpl = VPORT_ERROR; | |
6003 | + return rc; | |
6004 | } | |
6005 | + return 0; | |
6006 | } | |
6007 | ||
6008 | static void | |
6009 | @@ -1545,6 +1724,22 @@ lpfc_nlp_state_cleanup(struct lpfc_vport | |
6010 | */ | |
6011 | lpfc_register_remote_port(vport, ndlp); | |
6012 | } | |
6013 | + if ((new_state == NLP_STE_MAPPED_NODE) && | |
6014 | + (vport->stat_data_enabled)) { | |
6015 | + /* | |
6016 | + * A new target is discovered, if there is no buffer for | |
6017 | + * statistical data collection allocate buffer. | |
6018 | + */ | |
6019 | + ndlp->lat_data = kcalloc(LPFC_MAX_BUCKET_COUNT, | |
6020 | + sizeof(struct lpfc_scsicmd_bkt), | |
6021 | + GFP_KERNEL); | |
6022 | + | |
6023 | + if (!ndlp->lat_data) | |
6024 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE, | |
6025 | + "0286 lpfc_nlp_state_cleanup failed to " | |
6026 | + "allocate statistical data buffer DID " | |
6027 | + "0x%x\n", ndlp->nlp_DID); | |
6028 | + } | |
6029 | /* | |
6030 | * if we added to Mapped list, but the remote port | |
6031 | * registration failed or assigned a target id outside | |
6032 | @@ -2778,7 +2973,7 @@ restart_disc: | |
6033 | ||
6034 | default: | |
6035 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, | |
6036 | - "0229 Unexpected discovery timeout, " | |
6037 | + "0273 Unexpected discovery timeout, " | |
6038 | "vport State x%x\n", vport->port_state); | |
6039 | break; | |
6040 | } | |
6041 | @@ -2932,6 +3127,8 @@ lpfc_nlp_init(struct lpfc_vport *vport, | |
6042 | INIT_LIST_HEAD(&ndlp->nlp_listp); | |
6043 | kref_init(&ndlp->kref); | |
6044 | NLP_INT_NODE_ACT(ndlp); | |
6045 | + atomic_set(&ndlp->cmd_pending, 0); | |
6046 | + ndlp->cmd_qdepth = LPFC_MAX_TGT_QDEPTH; | |
6047 | ||
6048 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE, | |
6049 | "node init: did:x%x", | |
6050 | @@ -2971,8 +3168,10 @@ lpfc_nlp_release(struct kref *kref) | |
6051 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | |
6052 | ||
6053 | /* free ndlp memory for final ndlp release */ | |
6054 | - if (NLP_CHK_FREE_REQ(ndlp)) | |
6055 | + if (NLP_CHK_FREE_REQ(ndlp)) { | |
6056 | + kfree(ndlp->lat_data); | |
6057 | mempool_free(ndlp, ndlp->vport->phba->nlp_mem_pool); | |
6058 | + } | |
6059 | } | |
6060 | ||
6061 | /* This routine bumps the reference count for a ndlp structure to ensure | |
6062 | --- a/drivers/scsi/lpfc/lpfc_hw.h | |
6063 | +++ b/drivers/scsi/lpfc/lpfc_hw.h | |
6064 | @@ -1107,6 +1107,8 @@ typedef struct { | |
6065 | /* Start FireFly Register definitions */ | |
6066 | #define PCI_VENDOR_ID_EMULEX 0x10df | |
6067 | #define PCI_DEVICE_ID_FIREFLY 0x1ae5 | |
6068 | +#define PCI_DEVICE_ID_PROTEUS_VF 0xe100 | |
6069 | +#define PCI_DEVICE_ID_PROTEUS_PF 0xe180 | |
6070 | #define PCI_DEVICE_ID_SAT_SMB 0xf011 | |
6071 | #define PCI_DEVICE_ID_SAT_MID 0xf015 | |
6072 | #define PCI_DEVICE_ID_RFLY 0xf095 | |
6073 | @@ -1133,10 +1135,12 @@ typedef struct { | |
6074 | #define PCI_DEVICE_ID_LP11000S 0xfc10 | |
6075 | #define PCI_DEVICE_ID_LPE11000S 0xfc20 | |
6076 | #define PCI_DEVICE_ID_SAT_S 0xfc40 | |
6077 | +#define PCI_DEVICE_ID_PROTEUS_S 0xfc50 | |
6078 | #define PCI_DEVICE_ID_HELIOS 0xfd00 | |
6079 | #define PCI_DEVICE_ID_HELIOS_SCSP 0xfd11 | |
6080 | #define PCI_DEVICE_ID_HELIOS_DCSP 0xfd12 | |
6081 | #define PCI_DEVICE_ID_ZEPHYR 0xfe00 | |
6082 | +#define PCI_DEVICE_ID_HORNET 0xfe05 | |
6083 | #define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11 | |
6084 | #define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12 | |
6085 | ||
6086 | @@ -1154,6 +1158,7 @@ typedef struct { | |
6087 | #define ZEPHYR_JEDEC_ID 0x0577 | |
6088 | #define VIPER_JEDEC_ID 0x4838 | |
6089 | #define SATURN_JEDEC_ID 0x1004 | |
6090 | +#define HORNET_JDEC_ID 0x2057706D | |
6091 | ||
6092 | #define JEDEC_ID_MASK 0x0FFFF000 | |
6093 | #define JEDEC_ID_SHIFT 12 | |
6094 | @@ -1198,6 +1203,18 @@ typedef struct { /* FireFly BIU registe | |
6095 | #define HA_RXATT 0x00000008 /* Bit 3 */ | |
6096 | #define HA_RXMASK 0x0000000f | |
6097 | ||
6098 | +#define HA_R0_CLR_MSK (HA_R0RE_REQ | HA_R0CE_RSP | HA_R0ATT) | |
6099 | +#define HA_R1_CLR_MSK (HA_R1RE_REQ | HA_R1CE_RSP | HA_R1ATT) | |
6100 | +#define HA_R2_CLR_MSK (HA_R2RE_REQ | HA_R2CE_RSP | HA_R2ATT) | |
6101 | +#define HA_R3_CLR_MSK (HA_R3RE_REQ | HA_R3CE_RSP | HA_R3ATT) | |
6102 | + | |
6103 | +#define HA_R0_POS 3 | |
6104 | +#define HA_R1_POS 7 | |
6105 | +#define HA_R2_POS 11 | |
6106 | +#define HA_R3_POS 15 | |
6107 | +#define HA_LE_POS 29 | |
6108 | +#define HA_MB_POS 30 | |
6109 | +#define HA_ER_POS 31 | |
6110 | /* Chip Attention Register */ | |
6111 | ||
6112 | #define CA_REG_OFFSET 4 /* Byte offset from register base address */ | |
6113 | @@ -1235,7 +1252,7 @@ typedef struct { /* FireFly BIU registe | |
6114 | ||
6115 | /* Host Control Register */ | |
6116 | ||
6117 | -#define HC_REG_OFFSET 12 /* Word offset from register base address */ | |
6118 | +#define HC_REG_OFFSET 12 /* Byte offset from register base address */ | |
6119 | ||
6120 | #define HC_MBINT_ENA 0x00000001 /* Bit 0 */ | |
6121 | #define HC_R0INT_ENA 0x00000002 /* Bit 1 */ | |
6122 | @@ -1248,6 +1265,19 @@ typedef struct { /* FireFly BIU registe | |
6123 | #define HC_LAINT_ENA 0x20000000 /* Bit 29 */ | |
6124 | #define HC_ERINT_ENA 0x80000000 /* Bit 31 */ | |
6125 | ||
6126 | +/* Message Signaled Interrupt eXtension (MSI-X) message identifiers */ | |
6127 | +#define MSIX_DFLT_ID 0 | |
6128 | +#define MSIX_RNG0_ID 0 | |
6129 | +#define MSIX_RNG1_ID 1 | |
6130 | +#define MSIX_RNG2_ID 2 | |
6131 | +#define MSIX_RNG3_ID 3 | |
6132 | + | |
6133 | +#define MSIX_LINK_ID 4 | |
6134 | +#define MSIX_MBOX_ID 5 | |
6135 | + | |
6136 | +#define MSIX_SPARE0_ID 6 | |
6137 | +#define MSIX_SPARE1_ID 7 | |
6138 | + | |
6139 | /* Mailbox Commands */ | |
6140 | #define MBX_SHUTDOWN 0x00 /* terminate testing */ | |
6141 | #define MBX_LOAD_SM 0x01 | |
6142 | @@ -1285,10 +1315,14 @@ typedef struct { /* FireFly BIU registe | |
6143 | #define MBX_KILL_BOARD 0x24 | |
6144 | #define MBX_CONFIG_FARP 0x25 | |
6145 | #define MBX_BEACON 0x2A | |
6146 | +#define MBX_CONFIG_MSI 0x30 | |
6147 | #define MBX_HEARTBEAT 0x31 | |
6148 | #define MBX_WRITE_VPARMS 0x32 | |
6149 | #define MBX_ASYNCEVT_ENABLE 0x33 | |
6150 | ||
6151 | +#define MBX_PORT_CAPABILITIES 0x3B | |
6152 | +#define MBX_PORT_IOV_CONTROL 0x3C | |
6153 | + | |
6154 | #define MBX_CONFIG_HBQ 0x7C | |
6155 | #define MBX_LOAD_AREA 0x81 | |
6156 | #define MBX_RUN_BIU_DIAG64 0x84 | |
6157 | @@ -1474,24 +1508,18 @@ struct ulp_bde64 { /* SLI-2 */ | |
6158 | uint32_t bdeFlags:8; /* BDE Flags 0 IS A SUPPORTED | |
6159 | VALUE !! */ | |
6160 | #endif | |
6161 | - | |
6162 | -#define BUFF_USE_RSVD 0x01 /* bdeFlags */ | |
6163 | -#define BUFF_USE_INTRPT 0x02 /* Not Implemented with LP6000 */ | |
6164 | -#define BUFF_USE_CMND 0x04 /* Optional, 1=cmd/rsp 0=data buffer */ | |
6165 | -#define BUFF_USE_RCV 0x08 /* "" "", 1=rcv buffer, 0=xmit | |
6166 | - buffer */ | |
6167 | -#define BUFF_TYPE_32BIT 0x10 /* "" "", 1=32 bit addr 0=64 bit | |
6168 | - addr */ | |
6169 | -#define BUFF_TYPE_SPECIAL 0x20 /* Not Implemented with LP6000 */ | |
6170 | -#define BUFF_TYPE_BDL 0x40 /* Optional, may be set in BDL */ | |
6171 | -#define BUFF_TYPE_INVALID 0x80 /* "" "" */ | |
6172 | +#define BUFF_TYPE_BDE_64 0x00 /* BDE (Host_resident) */ | |
6173 | +#define BUFF_TYPE_BDE_IMMED 0x01 /* Immediate Data BDE */ | |
6174 | +#define BUFF_TYPE_BDE_64P 0x02 /* BDE (Port-resident) */ | |
6175 | +#define BUFF_TYPE_BDE_64I 0x08 /* Input BDE (Host-resident) */ | |
6176 | +#define BUFF_TYPE_BDE_64IP 0x0A /* Input BDE (Port-resident) */ | |
6177 | +#define BUFF_TYPE_BLP_64 0x40 /* BLP (Host-resident) */ | |
6178 | +#define BUFF_TYPE_BLP_64P 0x42 /* BLP (Port-resident) */ | |
6179 | } f; | |
6180 | } tus; | |
6181 | uint32_t addrLow; | |
6182 | uint32_t addrHigh; | |
6183 | }; | |
6184 | -#define BDE64_SIZE_WORD 0 | |
6185 | -#define BPL64_SIZE_WORD 0x40 | |
6186 | ||
6187 | typedef struct ULP_BDL { /* SLI-2 */ | |
6188 | #ifdef __BIG_ENDIAN_BITFIELD | |
6189 | @@ -2201,7 +2229,10 @@ typedef struct { | |
6190 | typedef struct { | |
6191 | uint32_t eventTag; /* Event tag */ | |
6192 | #ifdef __BIG_ENDIAN_BITFIELD | |
6193 | - uint32_t rsvd1:22; | |
6194 | + uint32_t rsvd1:19; | |
6195 | + uint32_t fa:1; | |
6196 | + uint32_t mm:1; /* Menlo Maintenance mode enabled */ | |
6197 | + uint32_t rx:1; | |
6198 | uint32_t pb:1; | |
6199 | uint32_t il:1; | |
6200 | uint32_t attType:8; | |
6201 | @@ -2209,7 +2240,10 @@ typedef struct { | |
6202 | uint32_t attType:8; | |
6203 | uint32_t il:1; | |
6204 | uint32_t pb:1; | |
6205 | - uint32_t rsvd1:22; | |
6206 | + uint32_t rx:1; | |
6207 | + uint32_t mm:1; | |
6208 | + uint32_t fa:1; | |
6209 | + uint32_t rsvd1:19; | |
6210 | #endif | |
6211 | ||
6212 | #define AT_RESERVED 0x00 /* Reserved - attType */ | |
6213 | @@ -2230,6 +2264,7 @@ typedef struct { | |
6214 | ||
6215 | #define TOPOLOGY_PT_PT 0x01 /* Topology is pt-pt / pt-fabric */ | |
6216 | #define TOPOLOGY_LOOP 0x02 /* Topology is FC-AL */ | |
6217 | +#define TOPOLOGY_LNK_MENLO_MAINTENANCE 0x05 /* maint mode zephtr to menlo */ | |
6218 | ||
6219 | union { | |
6220 | struct ulp_bde lilpBde; /* This BDE points to a 128 byte buffer | |
6221 | @@ -2324,6 +2359,36 @@ typedef struct { | |
6222 | #define DMP_RSP_OFFSET 0x14 /* word 5 contains first word of rsp */ | |
6223 | #define DMP_RSP_SIZE 0x6C /* maximum of 27 words of rsp data */ | |
6224 | ||
6225 | +/* Structure for MB Command UPDATE_CFG (0x1B) */ | |
6226 | + | |
6227 | +struct update_cfg_var { | |
6228 | +#ifdef __BIG_ENDIAN_BITFIELD | |
6229 | + uint32_t rsvd2:16; | |
6230 | + uint32_t type:8; | |
6231 | + uint32_t rsvd:1; | |
6232 | + uint32_t ra:1; | |
6233 | + uint32_t co:1; | |
6234 | + uint32_t cv:1; | |
6235 | + uint32_t req:4; | |
6236 | + uint32_t entry_length:16; | |
6237 | + uint32_t region_id:16; | |
6238 | +#else /* __LITTLE_ENDIAN_BITFIELD */ | |
6239 | + uint32_t req:4; | |
6240 | + uint32_t cv:1; | |
6241 | + uint32_t co:1; | |
6242 | + uint32_t ra:1; | |
6243 | + uint32_t rsvd:1; | |
6244 | + uint32_t type:8; | |
6245 | + uint32_t rsvd2:16; | |
6246 | + uint32_t region_id:16; | |
6247 | + uint32_t entry_length:16; | |
6248 | +#endif | |
6249 | + | |
6250 | + uint32_t resp_info; | |
6251 | + uint32_t byte_cnt; | |
6252 | + uint32_t data_offset; | |
6253 | +}; | |
6254 | + | |
6255 | struct hbq_mask { | |
6256 | #ifdef __BIG_ENDIAN_BITFIELD | |
6257 | uint8_t tmatch; | |
6258 | @@ -2560,6 +2625,40 @@ typedef struct { | |
6259 | ||
6260 | } CONFIG_PORT_VAR; | |
6261 | ||
6262 | +/* Structure for MB Command CONFIG_MSI (0x30) */ | |
6263 | +struct config_msi_var { | |
6264 | +#ifdef __BIG_ENDIAN_BITFIELD | |
6265 | + uint32_t dfltMsgNum:8; /* Default message number */ | |
6266 | + uint32_t rsvd1:11; /* Reserved */ | |
6267 | + uint32_t NID:5; /* Number of secondary attention IDs */ | |
6268 | + uint32_t rsvd2:5; /* Reserved */ | |
6269 | + uint32_t dfltPresent:1; /* Default message number present */ | |
6270 | + uint32_t addFlag:1; /* Add association flag */ | |
6271 | + uint32_t reportFlag:1; /* Report association flag */ | |
6272 | +#else /* __LITTLE_ENDIAN_BITFIELD */ | |
6273 | + uint32_t reportFlag:1; /* Report association flag */ | |
6274 | + uint32_t addFlag:1; /* Add association flag */ | |
6275 | + uint32_t dfltPresent:1; /* Default message number present */ | |
6276 | + uint32_t rsvd2:5; /* Reserved */ | |
6277 | + uint32_t NID:5; /* Number of secondary attention IDs */ | |
6278 | + uint32_t rsvd1:11; /* Reserved */ | |
6279 | + uint32_t dfltMsgNum:8; /* Default message number */ | |
6280 | +#endif | |
6281 | + uint32_t attentionConditions[2]; | |
6282 | + uint8_t attentionId[16]; | |
6283 | + uint8_t messageNumberByHA[64]; | |
6284 | + uint8_t messageNumberByID[16]; | |
6285 | + uint32_t autoClearHA[2]; | |
6286 | +#ifdef __BIG_ENDIAN_BITFIELD | |
6287 | + uint32_t rsvd3:16; | |
6288 | + uint32_t autoClearID:16; | |
6289 | +#else /* __LITTLE_ENDIAN_BITFIELD */ | |
6290 | + uint32_t autoClearID:16; | |
6291 | + uint32_t rsvd3:16; | |
6292 | +#endif | |
6293 | + uint32_t rsvd4; | |
6294 | +}; | |
6295 | + | |
6296 | /* SLI-2 Port Control Block */ | |
6297 | ||
6298 | /* SLIM POINTER */ | |
6299 | @@ -2678,10 +2777,12 @@ typedef union { | |
6300 | * NEW_FEATURE | |
6301 | */ | |
6302 | struct config_hbq_var varCfgHbq;/* cmd = 0x7c (CONFIG_HBQ) */ | |
6303 | + struct update_cfg_var varUpdateCfg; /* cmd = 0x1B (UPDATE_CFG)*/ | |
6304 | CONFIG_PORT_VAR varCfgPort; /* cmd = 0x88 (CONFIG_PORT) */ | |
6305 | REG_VPI_VAR varRegVpi; /* cmd = 0x96 (REG_VPI) */ | |
6306 | UNREG_VPI_VAR varUnregVpi; /* cmd = 0x97 (UNREG_VPI) */ | |
6307 | ASYNCEVT_ENABLE_VAR varCfgAsyncEvent; /*cmd = x33 (CONFIG_ASYNC) */ | |
6308 | + struct config_msi_var varCfgMSI;/* cmd = x30 (CONFIG_MSI) */ | |
6309 | } MAILVARIANTS; | |
6310 | ||
6311 | /* | |
6312 | @@ -2715,11 +2816,19 @@ struct sli3_pgp { | |
6313 | uint32_t hbq_get[16]; | |
6314 | }; | |
6315 | ||
6316 | -typedef union { | |
6317 | - struct sli2_desc s2; | |
6318 | - struct sli3_desc s3; | |
6319 | - struct sli3_pgp s3_pgp; | |
6320 | -} SLI_VAR; | |
6321 | +struct sli3_inb_pgp { | |
6322 | + uint32_t ha_copy; | |
6323 | + uint32_t counter; | |
6324 | + struct lpfc_pgp port[MAX_RINGS]; | |
6325 | + uint32_t hbq_get[16]; | |
6326 | +}; | |
6327 | + | |
6328 | +union sli_var { | |
6329 | + struct sli2_desc s2; | |
6330 | + struct sli3_desc s3; | |
6331 | + struct sli3_pgp s3_pgp; | |
6332 | + struct sli3_inb_pgp s3_inb_pgp; | |
6333 | +}; | |
6334 | ||
6335 | typedef struct { | |
6336 | #ifdef __BIG_ENDIAN_BITFIELD | |
6337 | @@ -2737,7 +2846,7 @@ typedef struct { | |
6338 | #endif | |
6339 | ||
6340 | MAILVARIANTS un; | |
6341 | - SLI_VAR us; | |
6342 | + union sli_var us; | |
6343 | } MAILBOX_t; | |
6344 | ||
6345 | /* | |
6346 | @@ -3105,6 +3214,27 @@ struct que_xri64cx_ext_fields { | |
6347 | struct lpfc_hbq_entry buff[5]; | |
6348 | }; | |
6349 | ||
6350 | +#define LPFC_EXT_DATA_BDE_COUNT 3 | |
6351 | +struct fcp_irw_ext { | |
6352 | + uint32_t io_tag64_low; | |
6353 | + uint32_t io_tag64_high; | |
6354 | +#ifdef __BIG_ENDIAN_BITFIELD | |
6355 | + uint8_t reserved1; | |
6356 | + uint8_t reserved2; | |
6357 | + uint8_t reserved3; | |
6358 | + uint8_t ebde_count; | |
6359 | +#else /* __LITTLE_ENDIAN */ | |
6360 | + uint8_t ebde_count; | |
6361 | + uint8_t reserved3; | |
6362 | + uint8_t reserved2; | |
6363 | + uint8_t reserved1; | |
6364 | +#endif | |
6365 | + uint32_t reserved4; | |
6366 | + struct ulp_bde64 rbde; /* response bde */ | |
6367 | + struct ulp_bde64 dbde[LPFC_EXT_DATA_BDE_COUNT]; /* data BDE or BPL */ | |
6368 | + uint8_t icd[32]; /* immediate command data (32 bytes) */ | |
6369 | +}; | |
6370 | + | |
6371 | typedef struct _IOCB { /* IOCB structure */ | |
6372 | union { | |
6373 | GENERIC_RSP grsp; /* Generic response */ | |
6374 | @@ -3190,7 +3320,7 @@ typedef struct _IOCB { /* IOCB structure | |
6375 | ||
6376 | /* words 8-31 used for que_xri_cx iocb */ | |
6377 | struct que_xri64cx_ext_fields que_xri64cx_ext_words; | |
6378 | - | |
6379 | + struct fcp_irw_ext fcp_ext; | |
6380 | uint32_t sli3Words[24]; /* 96 extra bytes for SLI-3 */ | |
6381 | } unsli3; | |
6382 | ||
6383 | @@ -3292,3 +3422,10 @@ lpfc_error_lost_link(IOCB_t *iocbp) | |
6384 | iocbp->un.ulpWord[4] == IOERR_LINK_DOWN || | |
6385 | iocbp->un.ulpWord[4] == IOERR_SLI_DOWN)); | |
6386 | } | |
6387 | + | |
6388 | +#define MENLO_TRANSPORT_TYPE 0xfe | |
6389 | +#define MENLO_CONTEXT 0 | |
6390 | +#define MENLO_PU 3 | |
6391 | +#define MENLO_TIMEOUT 30 | |
6392 | +#define SETVAR_MLOMNT 0x103107 | |
6393 | +#define SETVAR_MLORST 0x103007 | |
6394 | --- a/drivers/scsi/lpfc/lpfc_init.c | |
6395 | +++ b/drivers/scsi/lpfc/lpfc_init.c | |
6396 | @@ -36,6 +36,7 @@ | |
6397 | ||
6398 | #include "lpfc_hw.h" | |
6399 | #include "lpfc_sli.h" | |
6400 | +#include "lpfc_nl.h" | |
6401 | #include "lpfc_disc.h" | |
6402 | #include "lpfc_scsi.h" | |
6403 | #include "lpfc.h" | |
6404 | @@ -52,17 +53,20 @@ static struct scsi_transport_template *l | |
6405 | static struct scsi_transport_template *lpfc_vport_transport_template = NULL; | |
6406 | static DEFINE_IDR(lpfc_hba_index); | |
6407 | ||
6408 | -/************************************************************************/ | |
6409 | -/* */ | |
6410 | -/* lpfc_config_port_prep */ | |
6411 | -/* This routine will do LPFC initialization prior to the */ | |
6412 | -/* CONFIG_PORT mailbox command. This will be initialized */ | |
6413 | -/* as a SLI layer callback routine. */ | |
6414 | -/* This routine returns 0 on success or -ERESTART if it wants */ | |
6415 | -/* the SLI layer to reset the HBA and try again. Any */ | |
6416 | -/* other return value indicates an error. */ | |
6417 | -/* */ | |
6418 | -/************************************************************************/ | |
6419 | +/** | |
6420 | + * lpfc_config_port_prep: Perform lpfc initialization prior to config port. | |
6421 | + * @phba: pointer to lpfc hba data structure. | |
6422 | + * | |
6423 | + * This routine will do LPFC initialization prior to issuing the CONFIG_PORT | |
6424 | + * mailbox command. It retrieves the revision information from the HBA and | |
6425 | + * collects the Vital Product Data (VPD) about the HBA for preparing the | |
6426 | + * configuration of the HBA. | |
6427 | + * | |
6428 | + * Return codes: | |
6429 | + * 0 - success. | |
6430 | + * -ERESTART - requests the SLI layer to reset the HBA and try again. | |
6431 | + * Any other value - indicates an error. | |
6432 | + **/ | |
6433 | int | |
6434 | lpfc_config_port_prep(struct lpfc_hba *phba) | |
6435 | { | |
6436 | @@ -180,12 +184,9 @@ lpfc_config_port_prep(struct lpfc_hba *p | |
6437 | sizeof (phba->RandomData)); | |
6438 | ||
6439 | /* Get adapter VPD information */ | |
6440 | - pmb->context2 = kmalloc(DMP_RSP_SIZE, GFP_KERNEL); | |
6441 | - if (!pmb->context2) | |
6442 | - goto out_free_mbox; | |
6443 | lpfc_vpd_data = kmalloc(DMP_VPD_SIZE, GFP_KERNEL); | |
6444 | if (!lpfc_vpd_data) | |
6445 | - goto out_free_context2; | |
6446 | + goto out_free_mbox; | |
6447 | ||
6448 | do { | |
6449 | lpfc_dump_mem(phba, pmb, offset); | |
6450 | @@ -200,21 +201,29 @@ lpfc_config_port_prep(struct lpfc_hba *p | |
6451 | } | |
6452 | if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset) | |
6453 | mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset; | |
6454 | - lpfc_sli_pcimem_bcopy(pmb->context2, lpfc_vpd_data + offset, | |
6455 | + lpfc_sli_pcimem_bcopy(((uint8_t *)mb) + DMP_RSP_OFFSET, | |
6456 | + lpfc_vpd_data + offset, | |
6457 | mb->un.varDmp.word_cnt); | |
6458 | offset += mb->un.varDmp.word_cnt; | |
6459 | } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE); | |
6460 | lpfc_parse_vpd(phba, lpfc_vpd_data, offset); | |
6461 | ||
6462 | kfree(lpfc_vpd_data); | |
6463 | -out_free_context2: | |
6464 | - kfree(pmb->context2); | |
6465 | out_free_mbox: | |
6466 | mempool_free(pmb, phba->mbox_mem_pool); | |
6467 | return 0; | |
6468 | } | |
6469 | ||
6470 | -/* Completion handler for config async event mailbox command. */ | |
6471 | +/** | |
6472 | + * lpfc_config_async_cmpl: Completion handler for config async event mbox cmd. | |
6473 | + * @phba: pointer to lpfc hba data structure. | |
6474 | + * @pmboxq: pointer to the driver internal queue element for mailbox command. | |
6475 | + * | |
6476 | + * This is the completion handler for driver's configuring asynchronous event | |
6477 | + * mailbox command to the device. If the mailbox command returns successfully, | |
6478 | + * it will set internal async event support flag to 1; otherwise, it will | |
6479 | + * set internal async event support flag to 0. | |
6480 | + **/ | |
6481 | static void | |
6482 | lpfc_config_async_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq) | |
6483 | { | |
6484 | @@ -226,16 +235,19 @@ lpfc_config_async_cmpl(struct lpfc_hba * | |
6485 | return; | |
6486 | } | |
6487 | ||
6488 | -/************************************************************************/ | |
6489 | -/* */ | |
6490 | -/* lpfc_config_port_post */ | |
6491 | -/* This routine will do LPFC initialization after the */ | |
6492 | -/* CONFIG_PORT mailbox command. This will be initialized */ | |
6493 | -/* as a SLI layer callback routine. */ | |
6494 | -/* This routine returns 0 on success. Any other return value */ | |
6495 | -/* indicates an error. */ | |
6496 | -/* */ | |
6497 | -/************************************************************************/ | |
6498 | +/** | |
6499 | + * lpfc_config_port_post: Perform lpfc initialization after config port. | |
6500 | + * @phba: pointer to lpfc hba data structure. | |
6501 | + * | |
6502 | + * This routine will do LPFC initialization after the CONFIG_PORT mailbox | |
6503 | + * command call. It performs all internal resource and state setups on the | |
6504 | + * port: post IOCB buffers, enable appropriate host interrupt attentions, | |
6505 | + * ELS ring timers, etc. | |
6506 | + * | |
6507 | + * Return codes | |
6508 | + * 0 - success. | |
6509 | + * Any other value - error. | |
6510 | + **/ | |
6511 | int | |
6512 | lpfc_config_port_post(struct lpfc_hba *phba) | |
6513 | { | |
6514 | @@ -378,6 +390,29 @@ lpfc_config_port_post(struct lpfc_hba *p | |
6515 | if (phba->sli_rev != 3) | |
6516 | lpfc_post_rcv_buf(phba); | |
6517 | ||
6518 | + /* | |
6519 | + * Configure HBA MSI-X attention conditions to messages if MSI-X mode | |
6520 | + */ | |
6521 | + if (phba->intr_type == MSIX) { | |
6522 | + rc = lpfc_config_msi(phba, pmb); | |
6523 | + if (rc) { | |
6524 | + mempool_free(pmb, phba->mbox_mem_pool); | |
6525 | + return -EIO; | |
6526 | + } | |
6527 | + rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); | |
6528 | + if (rc != MBX_SUCCESS) { | |
6529 | + lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | |
6530 | + "0352 Config MSI mailbox command " | |
6531 | + "failed, mbxCmd x%x, mbxStatus x%x\n", | |
6532 | + pmb->mb.mbxCommand, pmb->mb.mbxStatus); | |
6533 | + mempool_free(pmb, phba->mbox_mem_pool); | |
6534 | + return -EIO; | |
6535 | + } | |
6536 | + } | |
6537 | + | |
6538 | + /* Initialize ERATT handling flag */ | |
6539 | + phba->hba_flag &= ~HBA_ERATT_HANDLED; | |
6540 | + | |
6541 | /* Enable appropriate host interrupts */ | |
6542 | spin_lock_irq(&phba->hbalock); | |
6543 | status = readl(phba->HCregaddr); | |
6544 | @@ -393,26 +428,26 @@ lpfc_config_port_post(struct lpfc_hba *p | |
6545 | ||
6546 | if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && | |
6547 | (phba->cfg_poll & DISABLE_FCP_RING_INT)) | |
6548 | - status &= ~(HC_R0INT_ENA << LPFC_FCP_RING); | |
6549 | + status &= ~(HC_R0INT_ENA); | |
6550 | ||
6551 | writel(status, phba->HCregaddr); | |
6552 | readl(phba->HCregaddr); /* flush */ | |
6553 | spin_unlock_irq(&phba->hbalock); | |
6554 | ||
6555 | - /* | |
6556 | - * Setup the ring 0 (els) timeout handler | |
6557 | - */ | |
6558 | - timeout = phba->fc_ratov << 1; | |
6559 | + /* Set up ring-0 (ELS) timer */ | |
6560 | + timeout = phba->fc_ratov * 2; | |
6561 | mod_timer(&vport->els_tmofunc, jiffies + HZ * timeout); | |
6562 | + /* Set up heart beat (HB) timer */ | |
6563 | mod_timer(&phba->hb_tmofunc, jiffies + HZ * LPFC_HB_MBOX_INTERVAL); | |
6564 | phba->hb_outstanding = 0; | |
6565 | phba->last_completion_time = jiffies; | |
6566 | + /* Set up error attention (ERATT) polling timer */ | |
6567 | + mod_timer(&phba->eratt_poll, jiffies + HZ * LPFC_ERATT_POLL_INTERVAL); | |
6568 | ||
6569 | lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); | |
6570 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | |
6571 | - pmb->vport = vport; | |
6572 | - rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | |
6573 | lpfc_set_loopback_flag(phba); | |
6574 | + rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | |
6575 | if (rc != MBX_SUCCESS) { | |
6576 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
6577 | "0454 Adapter failed to init, mbxCmd x%x " | |
6578 | @@ -447,19 +482,20 @@ lpfc_config_port_post(struct lpfc_hba *p | |
6579 | rc); | |
6580 | mempool_free(pmb, phba->mbox_mem_pool); | |
6581 | } | |
6582 | - return (0); | |
6583 | + return 0; | |
6584 | } | |
6585 | ||
6586 | -/************************************************************************/ | |
6587 | -/* */ | |
6588 | -/* lpfc_hba_down_prep */ | |
6589 | -/* This routine will do LPFC uninitialization before the */ | |
6590 | -/* HBA is reset when bringing down the SLI Layer. This will be */ | |
6591 | -/* initialized as a SLI layer callback routine. */ | |
6592 | -/* This routine returns 0 on success. Any other return value */ | |
6593 | -/* indicates an error. */ | |
6594 | -/* */ | |
6595 | -/************************************************************************/ | |
6596 | +/** | |
6597 | + * lpfc_hba_down_prep: Perform lpfc uninitialization prior to HBA reset. | |
6598 | + * @phba: pointer to lpfc HBA data structure. | |
6599 | + * | |
6600 | + * This routine will do LPFC uninitialization before the HBA is reset when | |
6601 | + * bringing down the SLI Layer. | |
6602 | + * | |
6603 | + * Return codes | |
6604 | + * 0 - success. | |
6605 | + * Any other value - error. | |
6606 | + **/ | |
6607 | int | |
6608 | lpfc_hba_down_prep(struct lpfc_hba *phba) | |
6609 | { | |
6610 | @@ -481,15 +517,17 @@ lpfc_hba_down_prep(struct lpfc_hba *phba | |
6611 | return 0; | |
6612 | } | |
6613 | ||
6614 | -/************************************************************************/ | |
6615 | -/* */ | |
6616 | -/* lpfc_hba_down_post */ | |
6617 | -/* This routine will do uninitialization after the HBA is reset */ | |
6618 | -/* when bringing down the SLI Layer. */ | |
6619 | -/* This routine returns 0 on success. Any other return value */ | |
6620 | -/* indicates an error. */ | |
6621 | -/* */ | |
6622 | -/************************************************************************/ | |
6623 | +/** | |
6624 | + * lpfc_hba_down_post: Perform lpfc uninitialization after HBA reset. | |
6625 | + * @phba: pointer to lpfc HBA data structure. | |
6626 | + * | |
6627 | + * This routine will do uninitialization after the HBA is reset when bring | |
6628 | + * down the SLI Layer. | |
6629 | + * | |
6630 | + * Return codes | |
6631 | + * 0 - sucess. | |
6632 | + * Any other value - error. | |
6633 | + **/ | |
6634 | int | |
6635 | lpfc_hba_down_post(struct lpfc_hba *phba) | |
6636 | { | |
6637 | @@ -548,7 +586,18 @@ lpfc_hba_down_post(struct lpfc_hba *phba | |
6638 | return 0; | |
6639 | } | |
6640 | ||
6641 | -/* HBA heart beat timeout handler */ | |
6642 | +/** | |
6643 | + * lpfc_hb_timeout: The HBA-timer timeout handler. | |
6644 | + * @ptr: unsigned long holds the pointer to lpfc hba data structure. | |
6645 | + * | |
6646 | + * This is the HBA-timer timeout handler registered to the lpfc driver. When | |
6647 | + * this timer fires, a HBA timeout event shall be posted to the lpfc driver | |
6648 | + * work-port-events bitmap and the worker thread is notified. This timeout | |
6649 | + * event will be used by the worker thread to invoke the actual timeout | |
6650 | + * handler routine, lpfc_hb_timeout_handler. Any periodical operations will | |
6651 | + * be performed in the timeout handler and the HBA timeout event bit shall | |
6652 | + * be cleared by the worker thread after it has taken the event bitmap out. | |
6653 | + **/ | |
6654 | static void | |
6655 | lpfc_hb_timeout(unsigned long ptr) | |
6656 | { | |
6657 | @@ -557,17 +606,36 @@ lpfc_hb_timeout(unsigned long ptr) | |
6658 | unsigned long iflag; | |
6659 | ||
6660 | phba = (struct lpfc_hba *)ptr; | |
6661 | + | |
6662 | + /* Check for heart beat timeout conditions */ | |
6663 | spin_lock_irqsave(&phba->pport->work_port_lock, iflag); | |
6664 | tmo_posted = phba->pport->work_port_events & WORKER_HB_TMO; | |
6665 | if (!tmo_posted) | |
6666 | phba->pport->work_port_events |= WORKER_HB_TMO; | |
6667 | spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); | |
6668 | ||
6669 | + /* Tell the worker thread there is work to do */ | |
6670 | if (!tmo_posted) | |
6671 | lpfc_worker_wake_up(phba); | |
6672 | return; | |
6673 | } | |
6674 | ||
6675 | +/** | |
6676 | + * lpfc_hb_mbox_cmpl: The lpfc heart-beat mailbox command callback function. | |
6677 | + * @phba: pointer to lpfc hba data structure. | |
6678 | + * @pmboxq: pointer to the driver internal queue element for mailbox command. | |
6679 | + * | |
6680 | + * This is the callback function to the lpfc heart-beat mailbox command. | |
6681 | + * If configured, the lpfc driver issues the heart-beat mailbox command to | |
6682 | + * the HBA every LPFC_HB_MBOX_INTERVAL (current 5) seconds. At the time the | |
6683 | + * heart-beat mailbox command is issued, the driver shall set up heart-beat | |
6684 | + * timeout timer to LPFC_HB_MBOX_TIMEOUT (current 30) seconds and marks | |
6685 | + * heart-beat outstanding state. Once the mailbox command comes back and | |
6686 | + * no error conditions detected, the heart-beat mailbox command timer is | |
6687 | + * reset to LPFC_HB_MBOX_INTERVAL seconds and the heart-beat outstanding | |
6688 | + * state is cleared for the next heart-beat. If the timer expired with the | |
6689 | + * heart-beat outstanding state set, the driver will put the HBA offline. | |
6690 | + **/ | |
6691 | static void | |
6692 | lpfc_hb_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq) | |
6693 | { | |
6694 | @@ -577,6 +645,7 @@ lpfc_hb_mbox_cmpl(struct lpfc_hba * phba | |
6695 | phba->hb_outstanding = 0; | |
6696 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); | |
6697 | ||
6698 | + /* Check and reset heart-beat timer is necessary */ | |
6699 | mempool_free(pmboxq, phba->mbox_mem_pool); | |
6700 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) && | |
6701 | !(phba->link_state == LPFC_HBA_ERROR) && | |
6702 | @@ -586,6 +655,22 @@ lpfc_hb_mbox_cmpl(struct lpfc_hba * phba | |
6703 | return; | |
6704 | } | |
6705 | ||
6706 | +/** | |
6707 | + * lpfc_hb_timeout_handler: The HBA-timer timeout handler. | |
6708 | + * @phba: pointer to lpfc hba data structure. | |
6709 | + * | |
6710 | + * This is the actual HBA-timer timeout handler to be invoked by the worker | |
6711 | + * thread whenever the HBA timer fired and HBA-timeout event posted. This | |
6712 | + * handler performs any periodic operations needed for the device. If such | |
6713 | + * periodic event has already been attended to either in the interrupt handler | |
6714 | + * or by processing slow-ring or fast-ring events within the HBA-timer | |
6715 | + * timeout window (LPFC_HB_MBOX_INTERVAL), this handler just simply resets | |
6716 | + * the timer for the next timeout period. If lpfc heart-beat mailbox command | |
6717 | + * is configured and there is no heart-beat mailbox command outstanding, a | |
6718 | + * heart-beat mailbox is issued and timer set properly. Otherwise, if there | |
6719 | + * has been a heart-beat mailbox command outstanding, the HBA shall be put | |
6720 | + * to offline. | |
6721 | + **/ | |
6722 | void | |
6723 | lpfc_hb_timeout_handler(struct lpfc_hba *phba) | |
6724 | { | |
6725 | @@ -684,6 +769,13 @@ lpfc_hb_timeout_handler(struct lpfc_hba | |
6726 | } | |
6727 | } | |
6728 | ||
6729 | +/** | |
6730 | + * lpfc_offline_eratt: Bring lpfc offline on hardware error attention. | |
6731 | + * @phba: pointer to lpfc hba data structure. | |
6732 | + * | |
6733 | + * This routine is called to bring the HBA offline when HBA hardware error | |
6734 | + * other than Port Error 6 has been detected. | |
6735 | + **/ | |
6736 | static void | |
6737 | lpfc_offline_eratt(struct lpfc_hba *phba) | |
6738 | { | |
6739 | @@ -704,14 +796,16 @@ lpfc_offline_eratt(struct lpfc_hba *phba | |
6740 | return; | |
6741 | } | |
6742 | ||
6743 | -/************************************************************************/ | |
6744 | -/* */ | |
6745 | -/* lpfc_handle_eratt */ | |
6746 | -/* This routine will handle processing a Host Attention */ | |
6747 | -/* Error Status event. This will be initialized */ | |
6748 | -/* as a SLI layer callback routine. */ | |
6749 | -/* */ | |
6750 | -/************************************************************************/ | |
6751 | +/** | |
6752 | + * lpfc_handle_eratt: The HBA hardware error handler. | |
6753 | + * @phba: pointer to lpfc hba data structure. | |
6754 | + * | |
6755 | + * This routine is invoked to handle the following HBA hardware error | |
6756 | + * conditions: | |
6757 | + * 1 - HBA error attention interrupt | |
6758 | + * 2 - DMA ring index out of range | |
6759 | + * 3 - Mailbox command came back as unknown | |
6760 | + **/ | |
6761 | void | |
6762 | lpfc_handle_eratt(struct lpfc_hba *phba) | |
6763 | { | |
6764 | @@ -722,6 +816,7 @@ lpfc_handle_eratt(struct lpfc_hba *phba) | |
6765 | unsigned long temperature; | |
6766 | struct temp_event temp_event_data; | |
6767 | struct Scsi_Host *shost; | |
6768 | + struct lpfc_board_event_header board_event; | |
6769 | ||
6770 | /* If the pci channel is offline, ignore possible errors, | |
6771 | * since we cannot communicate with the pci card anyway. */ | |
6772 | @@ -731,6 +826,16 @@ lpfc_handle_eratt(struct lpfc_hba *phba) | |
6773 | if (!phba->cfg_enable_hba_reset) | |
6774 | return; | |
6775 | ||
6776 | + /* Send an internal error event to mgmt application */ | |
6777 | + board_event.event_type = FC_REG_BOARD_EVENT; | |
6778 | + board_event.subcategory = LPFC_EVENT_PORTINTERR; | |
6779 | + shost = lpfc_shost_from_vport(phba->pport); | |
6780 | + fc_host_post_vendor_event(shost, fc_get_event_number(), | |
6781 | + sizeof(board_event), | |
6782 | + (char *) &board_event, | |
6783 | + SCSI_NL_VID_TYPE_PCI | |
6784 | + | PCI_VENDOR_ID_EMULEX); | |
6785 | + | |
6786 | if (phba->work_hs & HS_FFER6) { | |
6787 | /* Re-establishing Link */ | |
6788 | lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, | |
6789 | @@ -771,7 +876,7 @@ lpfc_handle_eratt(struct lpfc_hba *phba) | |
6790 | temp_event_data.data = (uint32_t)temperature; | |
6791 | ||
6792 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
6793 | - "0459 Adapter maximum temperature exceeded " | |
6794 | + "0406 Adapter maximum temperature exceeded " | |
6795 | "(%ld), taking this port offline " | |
6796 | "Data: x%x x%x x%x\n", | |
6797 | temperature, phba->work_hs, | |
6798 | @@ -791,8 +896,8 @@ lpfc_handle_eratt(struct lpfc_hba *phba) | |
6799 | ||
6800 | } else { | |
6801 | /* The if clause above forces this code path when the status | |
6802 | - * failure is a value other than FFER6. Do not call the offline | |
6803 | - * twice. This is the adapter hardware error path. | |
6804 | + * failure is a value other than FFER6. Do not call the offline | |
6805 | + * twice. This is the adapter hardware error path. | |
6806 | */ | |
6807 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
6808 | "0457 Adapter Hardware Error " | |
6809 | @@ -808,16 +913,16 @@ lpfc_handle_eratt(struct lpfc_hba *phba) | |
6810 | ||
6811 | lpfc_offline_eratt(phba); | |
6812 | } | |
6813 | + return; | |
6814 | } | |
6815 | ||
6816 | -/************************************************************************/ | |
6817 | -/* */ | |
6818 | -/* lpfc_handle_latt */ | |
6819 | -/* This routine will handle processing a Host Attention */ | |
6820 | -/* Link Status event. This will be initialized */ | |
6821 | -/* as a SLI layer callback routine. */ | |
6822 | -/* */ | |
6823 | -/************************************************************************/ | |
6824 | +/** | |
6825 | + * lpfc_handle_latt: The HBA link event handler. | |
6826 | + * @phba: pointer to lpfc hba data structure. | |
6827 | + * | |
6828 | + * This routine is invoked from the worker thread to handle a HBA host | |
6829 | + * attention link event. | |
6830 | + **/ | |
6831 | void | |
6832 | lpfc_handle_latt(struct lpfc_hba *phba) | |
6833 | { | |
6834 | @@ -898,12 +1003,20 @@ lpfc_handle_latt_err_exit: | |
6835 | return; | |
6836 | } | |
6837 | ||
6838 | -/************************************************************************/ | |
6839 | -/* */ | |
6840 | -/* lpfc_parse_vpd */ | |
6841 | -/* This routine will parse the VPD data */ | |
6842 | -/* */ | |
6843 | -/************************************************************************/ | |
6844 | +/** | |
6845 | + * lpfc_parse_vpd: Parse VPD (Vital Product Data). | |
6846 | + * @phba: pointer to lpfc hba data structure. | |
6847 | + * @vpd: pointer to the vital product data. | |
6848 | + * @len: length of the vital product data in bytes. | |
6849 | + * | |
6850 | + * This routine parses the Vital Product Data (VPD). The VPD is treated as | |
6851 | + * an array of characters. In this routine, the ModelName, ProgramType, and | |
6852 | + * ModelDesc, etc. fields of the phba data structure will be populated. | |
6853 | + * | |
6854 | + * Return codes | |
6855 | + * 0 - pointer to the VPD passed in is NULL | |
6856 | + * 1 - success | |
6857 | + **/ | |
6858 | static int | |
6859 | lpfc_parse_vpd(struct lpfc_hba *phba, uint8_t *vpd, int len) | |
6860 | { | |
6861 | @@ -1040,12 +1153,25 @@ lpfc_parse_vpd(struct lpfc_hba *phba, ui | |
6862 | return(1); | |
6863 | } | |
6864 | ||
6865 | +/** | |
6866 | + * lpfc_get_hba_model_desc: Retrieve HBA device model name and description. | |
6867 | + * @phba: pointer to lpfc hba data structure. | |
6868 | + * @mdp: pointer to the data structure to hold the derived model name. | |
6869 | + * @descp: pointer to the data structure to hold the derived description. | |
6870 | + * | |
6871 | + * This routine retrieves HBA's description based on its registered PCI device | |
6872 | + * ID. The @descp passed into this function points to an array of 256 chars. It | |
6873 | + * shall be returned with the model name, maximum speed, and the host bus type. | |
6874 | + * The @mdp passed into this function points to an array of 80 chars. When the | |
6875 | + * function returns, the @mdp will be filled with the model name. | |
6876 | + **/ | |
6877 | static void | |
6878 | lpfc_get_hba_model_desc(struct lpfc_hba *phba, uint8_t *mdp, uint8_t *descp) | |
6879 | { | |
6880 | lpfc_vpd_t *vp; | |
6881 | uint16_t dev_id = phba->pcidev->device; | |
6882 | int max_speed; | |
6883 | + int GE = 0; | |
6884 | struct { | |
6885 | char * name; | |
6886 | int max_speed; | |
6887 | @@ -1177,6 +1303,19 @@ lpfc_get_hba_model_desc(struct lpfc_hba | |
6888 | case PCI_DEVICE_ID_SAT_S: | |
6889 | m = (typeof(m)){"LPe12000-S", max_speed, "PCIe"}; | |
6890 | break; | |
6891 | + case PCI_DEVICE_ID_HORNET: | |
6892 | + m = (typeof(m)){"LP21000", max_speed, "PCIe"}; | |
6893 | + GE = 1; | |
6894 | + break; | |
6895 | + case PCI_DEVICE_ID_PROTEUS_VF: | |
6896 | + m = (typeof(m)) {"LPev12000", max_speed, "PCIe IOV"}; | |
6897 | + break; | |
6898 | + case PCI_DEVICE_ID_PROTEUS_PF: | |
6899 | + m = (typeof(m)) {"LPev12000", max_speed, "PCIe IOV"}; | |
6900 | + break; | |
6901 | + case PCI_DEVICE_ID_PROTEUS_S: | |
6902 | + m = (typeof(m)) {"LPemv12002-S", max_speed, "PCIe IOV"}; | |
6903 | + break; | |
6904 | default: | |
6905 | m = (typeof(m)){ NULL }; | |
6906 | break; | |
6907 | @@ -1186,18 +1325,25 @@ lpfc_get_hba_model_desc(struct lpfc_hba | |
6908 | snprintf(mdp, 79,"%s", m.name); | |
6909 | if (descp && descp[0] == '\0') | |
6910 | snprintf(descp, 255, | |
6911 | - "Emulex %s %dGb %s Fibre Channel Adapter", | |
6912 | - m.name, m.max_speed, m.bus); | |
6913 | + "Emulex %s %d%s %s %s", | |
6914 | + m.name, m.max_speed, | |
6915 | + (GE) ? "GE" : "Gb", | |
6916 | + m.bus, | |
6917 | + (GE) ? "FCoE Adapter" : "Fibre Channel Adapter"); | |
6918 | } | |
6919 | ||
6920 | -/**************************************************/ | |
6921 | -/* lpfc_post_buffer */ | |
6922 | -/* */ | |
6923 | -/* This routine will post count buffers to the */ | |
6924 | -/* ring with the QUE_RING_BUF_CN command. This */ | |
6925 | -/* allows 3 buffers / command to be posted. */ | |
6926 | -/* Returns the number of buffers NOT posted. */ | |
6927 | -/**************************************************/ | |
6928 | +/** | |
6929 | + * lpfc_post_buffer: Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring. | |
6930 | + * @phba: pointer to lpfc hba data structure. | |
6931 | + * @pring: pointer to a IOCB ring. | |
6932 | + * @cnt: the number of IOCBs to be posted to the IOCB ring. | |
6933 | + * | |
6934 | + * This routine posts a given number of IOCBs with the associated DMA buffer | |
6935 | + * descriptors specified by the cnt argument to the given IOCB ring. | |
6936 | + * | |
6937 | + * Return codes | |
6938 | + * The number of IOCBs NOT able to be posted to the IOCB ring. | |
6939 | + **/ | |
6940 | int | |
6941 | lpfc_post_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, int cnt) | |
6942 | { | |
6943 | @@ -1287,12 +1433,17 @@ lpfc_post_buffer(struct lpfc_hba *phba, | |
6944 | return 0; | |
6945 | } | |
6946 | ||
6947 | -/************************************************************************/ | |
6948 | -/* */ | |
6949 | -/* lpfc_post_rcv_buf */ | |
6950 | -/* This routine post initial rcv buffers to the configured rings */ | |
6951 | -/* */ | |
6952 | -/************************************************************************/ | |
6953 | +/** | |
6954 | + * lpfc_post_rcv_buf: Post the initial receive IOCB buffers to ELS ring. | |
6955 | + * @phba: pointer to lpfc hba data structure. | |
6956 | + * | |
6957 | + * This routine posts initial receive IOCB buffers to the ELS ring. The | |
6958 | + * current number of initial IOCB buffers specified by LPFC_BUF_RING0 is | |
6959 | + * set to 64 IOCBs. | |
6960 | + * | |
6961 | + * Return codes | |
6962 | + * 0 - success (currently always success) | |
6963 | + **/ | |
6964 | static int | |
6965 | lpfc_post_rcv_buf(struct lpfc_hba *phba) | |
6966 | { | |
6967 | @@ -1307,11 +1458,13 @@ lpfc_post_rcv_buf(struct lpfc_hba *phba) | |
6968 | ||
6969 | #define S(N,V) (((V)<<(N))|((V)>>(32-(N)))) | |
6970 | ||
6971 | -/************************************************************************/ | |
6972 | -/* */ | |
6973 | -/* lpfc_sha_init */ | |
6974 | -/* */ | |
6975 | -/************************************************************************/ | |
6976 | +/** | |
6977 | + * lpfc_sha_init: Set up initial array of hash table entries. | |
6978 | + * @HashResultPointer: pointer to an array as hash table. | |
6979 | + * | |
6980 | + * This routine sets up the initial values to the array of hash table entries | |
6981 | + * for the LC HBAs. | |
6982 | + **/ | |
6983 | static void | |
6984 | lpfc_sha_init(uint32_t * HashResultPointer) | |
6985 | { | |
6986 | @@ -1322,11 +1475,16 @@ lpfc_sha_init(uint32_t * HashResultPoint | |
6987 | HashResultPointer[4] = 0xC3D2E1F0; | |
6988 | } | |
6989 | ||
6990 | -/************************************************************************/ | |
6991 | -/* */ | |
6992 | -/* lpfc_sha_iterate */ | |
6993 | -/* */ | |
6994 | -/************************************************************************/ | |
6995 | +/** | |
6996 | + * lpfc_sha_iterate: Iterate initial hash table with the working hash table. | |
6997 | + * @HashResultPointer: pointer to an initial/result hash table. | |
6998 | + * @HashWorkingPointer: pointer to an working hash table. | |
6999 | + * | |
7000 | + * This routine iterates an initial hash table pointed by @HashResultPointer | |
7001 | + * with the values from the working hash table pointeed by @HashWorkingPointer. | |
7002 | + * The results are putting back to the initial hash table, returned through | |
7003 | + * the @HashResultPointer as the result hash table. | |
7004 | + **/ | |
7005 | static void | |
7006 | lpfc_sha_iterate(uint32_t * HashResultPointer, uint32_t * HashWorkingPointer) | |
7007 | { | |
7008 | @@ -1374,22 +1532,29 @@ lpfc_sha_iterate(uint32_t * HashResultPo | |
7009 | ||
7010 | } | |
7011 | ||
7012 | -/************************************************************************/ | |
7013 | -/* */ | |
7014 | -/* lpfc_challenge_key */ | |
7015 | -/* */ | |
7016 | -/************************************************************************/ | |
7017 | +/** | |
7018 | + * lpfc_challenge_key: Create challenge key based on WWPN of the HBA. | |
7019 | + * @RandomChallenge: pointer to the entry of host challenge random number array. | |
7020 | + * @HashWorking: pointer to the entry of the working hash array. | |
7021 | + * | |
7022 | + * This routine calculates the working hash array referred by @HashWorking | |
7023 | + * from the challenge random numbers associated with the host, referred by | |
7024 | + * @RandomChallenge. The result is put into the entry of the working hash | |
7025 | + * array and returned by reference through @HashWorking. | |
7026 | + **/ | |
7027 | static void | |
7028 | lpfc_challenge_key(uint32_t * RandomChallenge, uint32_t * HashWorking) | |
7029 | { | |
7030 | *HashWorking = (*RandomChallenge ^ *HashWorking); | |
7031 | } | |
7032 | ||
7033 | -/************************************************************************/ | |
7034 | -/* */ | |
7035 | -/* lpfc_hba_init */ | |
7036 | -/* */ | |
7037 | -/************************************************************************/ | |
7038 | +/** | |
7039 | + * lpfc_hba_init: Perform special handling for LC HBA initialization. | |
7040 | + * @phba: pointer to lpfc hba data structure. | |
7041 | + * @hbainit: pointer to an array of unsigned 32-bit integers. | |
7042 | + * | |
7043 | + * This routine performs the special handling for LC HBA initialization. | |
7044 | + **/ | |
7045 | void | |
7046 | lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit) | |
7047 | { | |
7048 | @@ -1412,6 +1577,15 @@ lpfc_hba_init(struct lpfc_hba *phba, uin | |
7049 | kfree(HashWorking); | |
7050 | } | |
7051 | ||
7052 | +/** | |
7053 | + * lpfc_cleanup: Performs vport cleanups before deleting a vport. | |
7054 | + * @vport: pointer to a virtual N_Port data structure. | |
7055 | + * | |
7056 | + * This routine performs the necessary cleanups before deleting the @vport. | |
7057 | + * It invokes the discovery state machine to perform necessary state | |
7058 | + * transitions and to release the ndlps associated with the @vport. Note, | |
7059 | + * the physical port is treated as @vport 0. | |
7060 | + **/ | |
7061 | void | |
7062 | lpfc_cleanup(struct lpfc_vport *vport) | |
7063 | { | |
7064 | @@ -1459,14 +1633,6 @@ lpfc_cleanup(struct lpfc_vport *vport) | |
7065 | lpfc_disc_state_machine(vport, ndlp, NULL, | |
7066 | NLP_EVT_DEVICE_RM); | |
7067 | ||
7068 | - /* nlp_type zero is not defined, nlp_flag zero also not defined, | |
7069 | - * nlp_state is unused, this happens when | |
7070 | - * an initiator has logged | |
7071 | - * into us so cleanup this ndlp. | |
7072 | - */ | |
7073 | - if ((ndlp->nlp_type == 0) && (ndlp->nlp_flag == 0) && | |
7074 | - (ndlp->nlp_state == 0)) | |
7075 | - lpfc_nlp_put(ndlp); | |
7076 | } | |
7077 | ||
7078 | /* At this point, ALL ndlp's should be gone | |
7079 | @@ -1482,7 +1648,7 @@ lpfc_cleanup(struct lpfc_vport *vport) | |
7080 | &vport->fc_nodes, nlp_listp) { | |
7081 | lpfc_printf_vlog(ndlp->vport, KERN_ERR, | |
7082 | LOG_NODE, | |
7083 | - "0282: did:x%x ndlp:x%p " | |
7084 | + "0282 did:x%x ndlp:x%p " | |
7085 | "usgmap:x%x refcnt:%d\n", | |
7086 | ndlp->nlp_DID, (void *)ndlp, | |
7087 | ndlp->nlp_usg_map, | |
7088 | @@ -1498,6 +1664,14 @@ lpfc_cleanup(struct lpfc_vport *vport) | |
7089 | return; | |
7090 | } | |
7091 | ||
7092 | +/** | |
7093 | + * lpfc_stop_vport_timers: Stop all the timers associated with a vport. | |
7094 | + * @vport: pointer to a virtual N_Port data structure. | |
7095 | + * | |
7096 | + * This routine stops all the timers associated with a @vport. This function | |
7097 | + * is invoked before disabling or deleting a @vport. Note that the physical | |
7098 | + * port is treated as @vport 0. | |
7099 | + **/ | |
7100 | void | |
7101 | lpfc_stop_vport_timers(struct lpfc_vport *vport) | |
7102 | { | |
7103 | @@ -1507,6 +1681,13 @@ lpfc_stop_vport_timers(struct lpfc_vport | |
7104 | return; | |
7105 | } | |
7106 | ||
7107 | +/** | |
7108 | + * lpfc_stop_phba_timers: Stop all the timers associated with an HBA. | |
7109 | + * @phba: pointer to lpfc hba data structure. | |
7110 | + * | |
7111 | + * This routine stops all the timers associated with a HBA. This function is | |
7112 | + * invoked before either putting a HBA offline or unloading the driver. | |
7113 | + **/ | |
7114 | static void | |
7115 | lpfc_stop_phba_timers(struct lpfc_hba *phba) | |
7116 | { | |
7117 | @@ -1516,9 +1697,20 @@ lpfc_stop_phba_timers(struct lpfc_hba *p | |
7118 | del_timer_sync(&phba->fabric_block_timer); | |
7119 | phba->hb_outstanding = 0; | |
7120 | del_timer_sync(&phba->hb_tmofunc); | |
7121 | + del_timer_sync(&phba->eratt_poll); | |
7122 | return; | |
7123 | } | |
7124 | ||
7125 | +/** | |
7126 | + * lpfc_block_mgmt_io: Mark a HBA's management interface as blocked. | |
7127 | + * @phba: pointer to lpfc hba data structure. | |
7128 | + * | |
7129 | + * This routine marks a HBA's management interface as blocked. Once the HBA's | |
7130 | + * management interface is marked as blocked, all the user space access to | |
7131 | + * the HBA, whether they are from sysfs interface or libdfc interface will | |
7132 | + * all be blocked. The HBA is set to block the management interface when the | |
7133 | + * driver prepares the HBA interface for online or offline. | |
7134 | + **/ | |
7135 | static void | |
7136 | lpfc_block_mgmt_io(struct lpfc_hba * phba) | |
7137 | { | |
7138 | @@ -1529,6 +1721,18 @@ lpfc_block_mgmt_io(struct lpfc_hba * phb | |
7139 | spin_unlock_irqrestore(&phba->hbalock, iflag); | |
7140 | } | |
7141 | ||
7142 | +/** | |
7143 | + * lpfc_online: Initialize and bring a HBA online. | |
7144 | + * @phba: pointer to lpfc hba data structure. | |
7145 | + * | |
7146 | + * This routine initializes the HBA and brings a HBA online. During this | |
7147 | + * process, the management interface is blocked to prevent user space access | |
7148 | + * to the HBA interfering with the driver initialization. | |
7149 | + * | |
7150 | + * Return codes | |
7151 | + * 0 - successful | |
7152 | + * 1 - failed | |
7153 | + **/ | |
7154 | int | |
7155 | lpfc_online(struct lpfc_hba *phba) | |
7156 | { | |
7157 | @@ -1574,6 +1778,17 @@ lpfc_online(struct lpfc_hba *phba) | |
7158 | return 0; | |
7159 | } | |
7160 | ||
7161 | +/** | |
7162 | + * lpfc_unblock_mgmt_io: Mark a HBA's management interface to be not blocked. | |
7163 | + * @phba: pointer to lpfc hba data structure. | |
7164 | + * | |
7165 | + * This routine marks a HBA's management interface as not blocked. Once the | |
7166 | + * HBA's management interface is marked as not blocked, all the user space | |
7167 | + * access to the HBA, whether they are from sysfs interface or libdfc | |
7168 | + * interface will be allowed. The HBA is set to block the management interface | |
7169 | + * when the driver prepares the HBA interface for online or offline and then | |
7170 | + * set to unblock the management interface afterwards. | |
7171 | + **/ | |
7172 | void | |
7173 | lpfc_unblock_mgmt_io(struct lpfc_hba * phba) | |
7174 | { | |
7175 | @@ -1584,6 +1799,14 @@ lpfc_unblock_mgmt_io(struct lpfc_hba * p | |
7176 | spin_unlock_irqrestore(&phba->hbalock, iflag); | |
7177 | } | |
7178 | ||
7179 | +/** | |
7180 | + * lpfc_offline_prep: Prepare a HBA to be brought offline. | |
7181 | + * @phba: pointer to lpfc hba data structure. | |
7182 | + * | |
7183 | + * This routine is invoked to prepare a HBA to be brought offline. It performs | |
7184 | + * unregistration login to all the nodes on all vports and flushes the mailbox | |
7185 | + * queue to make it ready to be brought offline. | |
7186 | + **/ | |
7187 | void | |
7188 | lpfc_offline_prep(struct lpfc_hba * phba) | |
7189 | { | |
7190 | @@ -1633,6 +1856,14 @@ lpfc_offline_prep(struct lpfc_hba * phba | |
7191 | lpfc_sli_flush_mbox_queue(phba); | |
7192 | } | |
7193 | ||
7194 | +/** | |
7195 | + * lpfc_offline: Bring a HBA offline. | |
7196 | + * @phba: pointer to lpfc hba data structure. | |
7197 | + * | |
7198 | + * This routine actually brings a HBA offline. It stops all the timers | |
7199 | + * associated with the HBA, brings down the SLI layer, and eventually | |
7200 | + * marks the HBA as in offline state for the upper layer protocol. | |
7201 | + **/ | |
7202 | void | |
7203 | lpfc_offline(struct lpfc_hba *phba) | |
7204 | { | |
7205 | @@ -1670,12 +1901,17 @@ lpfc_offline(struct lpfc_hba *phba) | |
7206 | lpfc_destroy_vport_work_array(phba, vports); | |
7207 | } | |
7208 | ||
7209 | -/****************************************************************************** | |
7210 | -* Function name: lpfc_scsi_free | |
7211 | -* | |
7212 | -* Description: Called from lpfc_pci_remove_one free internal driver resources | |
7213 | -* | |
7214 | -******************************************************************************/ | |
7215 | +/** | |
7216 | + * lpfc_scsi_free: Free all the SCSI buffers and IOCBs from driver lists. | |
7217 | + * @phba: pointer to lpfc hba data structure. | |
7218 | + * | |
7219 | + * This routine is to free all the SCSI buffers and IOCBs from the driver | |
7220 | + * list back to kernel. It is called from lpfc_pci_remove_one to free | |
7221 | + * the internal resources before the device is removed from the system. | |
7222 | + * | |
7223 | + * Return codes | |
7224 | + * 0 - successful (for now, it always returns 0) | |
7225 | + **/ | |
7226 | static int | |
7227 | lpfc_scsi_free(struct lpfc_hba *phba) | |
7228 | { | |
7229 | @@ -1704,6 +1940,22 @@ lpfc_scsi_free(struct lpfc_hba *phba) | |
7230 | return 0; | |
7231 | } | |
7232 | ||
7233 | +/** | |
7234 | + * lpfc_create_port: Create an FC port. | |
7235 | + * @phba: pointer to lpfc hba data structure. | |
7236 | + * @instance: a unique integer ID to this FC port. | |
7237 | + * @dev: pointer to the device data structure. | |
7238 | + * | |
7239 | + * This routine creates a FC port for the upper layer protocol. The FC port | |
7240 | + * can be created on top of either a physical port or a virtual port provided | |
7241 | + * by the HBA. This routine also allocates a SCSI host data structure (shost) | |
7242 | + * and associates the FC port created before adding the shost into the SCSI | |
7243 | + * layer. | |
7244 | + * | |
7245 | + * Return codes | |
7246 | + * @vport - pointer to the virtual N_Port data structure. | |
7247 | + * NULL - port create failed. | |
7248 | + **/ | |
7249 | struct lpfc_vport * | |
7250 | lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev) | |
7251 | { | |
7252 | @@ -1777,6 +2029,13 @@ out: | |
7253 | return NULL; | |
7254 | } | |
7255 | ||
7256 | +/** | |
7257 | + * destroy_port: Destroy an FC port. | |
7258 | + * @vport: pointer to an lpfc virtual N_Port data structure. | |
7259 | + * | |
7260 | + * This routine destroys a FC port from the upper layer protocol. All the | |
7261 | + * resources associated with the port are released. | |
7262 | + **/ | |
7263 | void | |
7264 | destroy_port(struct lpfc_vport *vport) | |
7265 | { | |
7266 | @@ -1797,6 +2056,16 @@ destroy_port(struct lpfc_vport *vport) | |
7267 | return; | |
7268 | } | |
7269 | ||
7270 | +/** | |
7271 | + * lpfc_get_instance: Get a unique integer ID. | |
7272 | + * | |
7273 | + * This routine allocates a unique integer ID from lpfc_hba_index pool. It | |
7274 | + * uses the kernel idr facility to perform the task. | |
7275 | + * | |
7276 | + * Return codes: | |
7277 | + * instance - a unique integer ID allocated as the new instance. | |
7278 | + * -1 - lpfc get instance failed. | |
7279 | + **/ | |
7280 | int | |
7281 | lpfc_get_instance(void) | |
7282 | { | |
7283 | @@ -1810,11 +2079,21 @@ lpfc_get_instance(void) | |
7284 | return instance; | |
7285 | } | |
7286 | ||
7287 | -/* | |
7288 | - * Note: there is no scan_start function as adapter initialization | |
7289 | - * will have asynchronously kicked off the link initialization. | |
7290 | - */ | |
7291 | - | |
7292 | +/** | |
7293 | + * lpfc_scan_finished: method for SCSI layer to detect whether scan is done. | |
7294 | + * @shost: pointer to SCSI host data structure. | |
7295 | + * @time: elapsed time of the scan in jiffies. | |
7296 | + * | |
7297 | + * This routine is called by the SCSI layer with a SCSI host to determine | |
7298 | + * whether the scan host is finished. | |
7299 | + * | |
7300 | + * Note: there is no scan_start function as adapter initialization will have | |
7301 | + * asynchronously kicked off the link initialization. | |
7302 | + * | |
7303 | + * Return codes | |
7304 | + * 0 - SCSI host scan is not over yet. | |
7305 | + * 1 - SCSI host scan is over. | |
7306 | + **/ | |
7307 | int lpfc_scan_finished(struct Scsi_Host *shost, unsigned long time) | |
7308 | { | |
7309 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
7310 | @@ -1858,6 +2137,13 @@ finished: | |
7311 | return stat; | |
7312 | } | |
7313 | ||
7314 | +/** | |
7315 | + * lpfc_host_attrib_init: Initialize SCSI host attributes on a FC port. | |
7316 | + * @shost: pointer to SCSI host data structure. | |
7317 | + * | |
7318 | + * This routine initializes a given SCSI host attributes on a FC port. The | |
7319 | + * SCSI host can be either on top of a physical port or a virtual port. | |
7320 | + **/ | |
7321 | void lpfc_host_attrib_init(struct Scsi_Host *shost) | |
7322 | { | |
7323 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
7324 | @@ -1906,42 +2192,157 @@ void lpfc_host_attrib_init(struct Scsi_H | |
7325 | spin_unlock_irq(shost->host_lock); | |
7326 | } | |
7327 | ||
7328 | +/** | |
7329 | + * lpfc_enable_msix: Enable MSI-X interrupt mode. | |
7330 | + * @phba: pointer to lpfc hba data structure. | |
7331 | + * | |
7332 | + * This routine is invoked to enable the MSI-X interrupt vectors. The kernel | |
7333 | + * function pci_enable_msix() is called to enable the MSI-X vectors. Note that | |
7334 | + * pci_enable_msix(), once invoked, enables either all or nothing, depending | |
7335 | + * on the current availability of PCI vector resources. The device driver is | |
7336 | + * responsible for calling the individual request_irq() to register each MSI-X | |
7337 | + * vector with a interrupt handler, which is done in this function. Note that | |
7338 | + * later when device is unloading, the driver should always call free_irq() | |
7339 | + * on all MSI-X vectors it has done request_irq() on before calling | |
7340 | + * pci_disable_msix(). Failure to do so results in a BUG_ON() and a device | |
7341 | + * will be left with MSI-X enabled and leaks its vectors. | |
7342 | + * | |
7343 | + * Return codes | |
7344 | + * 0 - sucessful | |
7345 | + * other values - error | |
7346 | + **/ | |
7347 | static int | |
7348 | lpfc_enable_msix(struct lpfc_hba *phba) | |
7349 | { | |
7350 | - int error; | |
7351 | + int rc, i; | |
7352 | + LPFC_MBOXQ_t *pmb; | |
7353 | ||
7354 | - phba->msix_entries[0].entry = 0; | |
7355 | - phba->msix_entries[0].vector = 0; | |
7356 | + /* Set up MSI-X multi-message vectors */ | |
7357 | + for (i = 0; i < LPFC_MSIX_VECTORS; i++) | |
7358 | + phba->msix_entries[i].entry = i; | |
7359 | ||
7360 | - error = pci_enable_msix(phba->pcidev, phba->msix_entries, | |
7361 | + /* Configure MSI-X capability structure */ | |
7362 | + rc = pci_enable_msix(phba->pcidev, phba->msix_entries, | |
7363 | ARRAY_SIZE(phba->msix_entries)); | |
7364 | - if (error) { | |
7365 | + if (rc) { | |
7366 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7367 | "0420 Enable MSI-X failed (%d), continuing " | |
7368 | - "with MSI\n", error); | |
7369 | - pci_disable_msix(phba->pcidev); | |
7370 | - return error; | |
7371 | + "with MSI\n", rc); | |
7372 | + goto msi_fail_out; | |
7373 | + } else | |
7374 | + for (i = 0; i < LPFC_MSIX_VECTORS; i++) | |
7375 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7376 | + "0477 MSI-X entry[%d]: vector=x%x " | |
7377 | + "message=%d\n", i, | |
7378 | + phba->msix_entries[i].vector, | |
7379 | + phba->msix_entries[i].entry); | |
7380 | + /* | |
7381 | + * Assign MSI-X vectors to interrupt handlers | |
7382 | + */ | |
7383 | + | |
7384 | + /* vector-0 is associated to slow-path handler */ | |
7385 | + rc = request_irq(phba->msix_entries[0].vector, &lpfc_sp_intr_handler, | |
7386 | + IRQF_SHARED, LPFC_SP_DRIVER_HANDLER_NAME, phba); | |
7387 | + if (rc) { | |
7388 | + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
7389 | + "0421 MSI-X slow-path request_irq failed " | |
7390 | + "(%d), continuing with MSI\n", rc); | |
7391 | + goto msi_fail_out; | |
7392 | } | |
7393 | ||
7394 | - error = request_irq(phba->msix_entries[0].vector, lpfc_intr_handler, 0, | |
7395 | - LPFC_DRIVER_NAME, phba); | |
7396 | - if (error) { | |
7397 | + /* vector-1 is associated to fast-path handler */ | |
7398 | + rc = request_irq(phba->msix_entries[1].vector, &lpfc_fp_intr_handler, | |
7399 | + IRQF_SHARED, LPFC_FP_DRIVER_HANDLER_NAME, phba); | |
7400 | + | |
7401 | + if (rc) { | |
7402 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
7403 | - "0421 MSI-X request_irq failed (%d), " | |
7404 | - "continuing with MSI\n", error); | |
7405 | - pci_disable_msix(phba->pcidev); | |
7406 | + "0429 MSI-X fast-path request_irq failed " | |
7407 | + "(%d), continuing with MSI\n", rc); | |
7408 | + goto irq_fail_out; | |
7409 | } | |
7410 | - return error; | |
7411 | + | |
7412 | + /* | |
7413 | + * Configure HBA MSI-X attention conditions to messages | |
7414 | + */ | |
7415 | + pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
7416 | + | |
7417 | + if (!pmb) { | |
7418 | + rc = -ENOMEM; | |
7419 | + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
7420 | + "0474 Unable to allocate memory for issuing " | |
7421 | + "MBOX_CONFIG_MSI command\n"); | |
7422 | + goto mem_fail_out; | |
7423 | + } | |
7424 | + rc = lpfc_config_msi(phba, pmb); | |
7425 | + if (rc) | |
7426 | + goto mbx_fail_out; | |
7427 | + rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); | |
7428 | + if (rc != MBX_SUCCESS) { | |
7429 | + lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | |
7430 | + "0351 Config MSI mailbox command failed, " | |
7431 | + "mbxCmd x%x, mbxStatus x%x\n", | |
7432 | + pmb->mb.mbxCommand, pmb->mb.mbxStatus); | |
7433 | + goto mbx_fail_out; | |
7434 | + } | |
7435 | + | |
7436 | + /* Free memory allocated for mailbox command */ | |
7437 | + mempool_free(pmb, phba->mbox_mem_pool); | |
7438 | + return rc; | |
7439 | + | |
7440 | +mbx_fail_out: | |
7441 | + /* Free memory allocated for mailbox command */ | |
7442 | + mempool_free(pmb, phba->mbox_mem_pool); | |
7443 | + | |
7444 | +mem_fail_out: | |
7445 | + /* free the irq already requested */ | |
7446 | + free_irq(phba->msix_entries[1].vector, phba); | |
7447 | + | |
7448 | +irq_fail_out: | |
7449 | + /* free the irq already requested */ | |
7450 | + free_irq(phba->msix_entries[0].vector, phba); | |
7451 | + | |
7452 | +msi_fail_out: | |
7453 | + /* Unconfigure MSI-X capability structure */ | |
7454 | + pci_disable_msix(phba->pcidev); | |
7455 | + return rc; | |
7456 | } | |
7457 | ||
7458 | +/** | |
7459 | + * lpfc_disable_msix: Disable MSI-X interrupt mode. | |
7460 | + * @phba: pointer to lpfc hba data structure. | |
7461 | + * | |
7462 | + * This routine is invoked to release the MSI-X vectors and then disable the | |
7463 | + * MSI-X interrupt mode. | |
7464 | + **/ | |
7465 | static void | |
7466 | lpfc_disable_msix(struct lpfc_hba *phba) | |
7467 | { | |
7468 | - free_irq(phba->msix_entries[0].vector, phba); | |
7469 | + int i; | |
7470 | + | |
7471 | + /* Free up MSI-X multi-message vectors */ | |
7472 | + for (i = 0; i < LPFC_MSIX_VECTORS; i++) | |
7473 | + free_irq(phba->msix_entries[i].vector, phba); | |
7474 | + /* Disable MSI-X */ | |
7475 | pci_disable_msix(phba->pcidev); | |
7476 | } | |
7477 | ||
7478 | +/** | |
7479 | + * lpfc_pci_probe_one: lpfc PCI probe func to register device to PCI subsystem. | |
7480 | + * @pdev: pointer to PCI device | |
7481 | + * @pid: pointer to PCI device identifier | |
7482 | + * | |
7483 | + * This routine is to be registered to the kernel's PCI subsystem. When an | |
7484 | + * Emulex HBA is presented in PCI bus, the kernel PCI subsystem looks at | |
7485 | + * PCI device-specific information of the device and driver to see if the | |
7486 | + * driver state that it can support this kind of device. If the match is | |
7487 | + * successful, the driver core invokes this routine. If this routine | |
7488 | + * determines it can claim the HBA, it does all the initialization that it | |
7489 | + * needs to do to handle the HBA properly. | |
7490 | + * | |
7491 | + * Return code | |
7492 | + * 0 - driver can claim the device | |
7493 | + * negative value - driver can not claim the device | |
7494 | + **/ | |
7495 | static int __devinit | |
7496 | lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |
7497 | { | |
7498 | @@ -1956,6 +2357,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7499 | int i, hbq_count; | |
7500 | uint16_t iotag; | |
7501 | int bars = pci_select_bars(pdev, IORESOURCE_MEM); | |
7502 | + struct lpfc_adapter_event_header adapter_event; | |
7503 | ||
7504 | if (pci_enable_device_mem(pdev)) | |
7505 | goto out; | |
7506 | @@ -1966,6 +2368,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7507 | if (!phba) | |
7508 | goto out_release_regions; | |
7509 | ||
7510 | + atomic_set(&phba->fast_event_count, 0); | |
7511 | spin_lock_init(&phba->hbalock); | |
7512 | ||
7513 | /* Initialize ndlp management spinlock */ | |
7514 | @@ -1978,6 +2381,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7515 | goto out_free_phba; | |
7516 | ||
7517 | INIT_LIST_HEAD(&phba->port_list); | |
7518 | + init_waitqueue_head(&phba->wait_4_mlo_m_q); | |
7519 | /* | |
7520 | * Get all the module params for configuring this host and then | |
7521 | * establish the host. | |
7522 | @@ -2000,6 +2404,9 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7523 | init_timer(&phba->fabric_block_timer); | |
7524 | phba->fabric_block_timer.function = lpfc_fabric_block_timeout; | |
7525 | phba->fabric_block_timer.data = (unsigned long) phba; | |
7526 | + init_timer(&phba->eratt_poll); | |
7527 | + phba->eratt_poll.function = lpfc_poll_eratt; | |
7528 | + phba->eratt_poll.data = (unsigned long) phba; | |
7529 | ||
7530 | pci_set_master(pdev); | |
7531 | pci_try_set_mwi(pdev); | |
7532 | @@ -2019,7 +2426,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7533 | bar2map_len = pci_resource_len(phba->pcidev, 2); | |
7534 | ||
7535 | /* Map HBA SLIM to a kernel virtual address. */ | |
7536 | - phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); | |
7537 | + phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); | |
7538 | if (!phba->slim_memmap_p) { | |
7539 | error = -ENODEV; | |
7540 | dev_printk(KERN_ERR, &pdev->dev, | |
7541 | @@ -2037,12 +2444,18 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7542 | } | |
7543 | ||
7544 | /* Allocate memory for SLI-2 structures */ | |
7545 | - phba->slim2p = dma_alloc_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE, | |
7546 | - &phba->slim2p_mapping, GFP_KERNEL); | |
7547 | - if (!phba->slim2p) | |
7548 | + phba->slim2p.virt = dma_alloc_coherent(&phba->pcidev->dev, | |
7549 | + SLI2_SLIM_SIZE, | |
7550 | + &phba->slim2p.phys, | |
7551 | + GFP_KERNEL); | |
7552 | + if (!phba->slim2p.virt) | |
7553 | goto out_iounmap; | |
7554 | ||
7555 | - memset(phba->slim2p, 0, SLI2_SLIM_SIZE); | |
7556 | + memset(phba->slim2p.virt, 0, SLI2_SLIM_SIZE); | |
7557 | + phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); | |
7558 | + phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); | |
7559 | + phba->IOCBs = (phba->slim2p.virt + | |
7560 | + offsetof(struct lpfc_sli2_slim, IOCBs)); | |
7561 | ||
7562 | phba->hbqslimp.virt = dma_alloc_coherent(&phba->pcidev->dev, | |
7563 | lpfc_sli_hbq_size(), | |
7564 | @@ -2111,7 +2524,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7565 | phba->fc_arbtov = FF_DEF_ARBTOV; | |
7566 | ||
7567 | INIT_LIST_HEAD(&phba->work_list); | |
7568 | - phba->work_ha_mask = (HA_ERATT|HA_MBATT|HA_LATT); | |
7569 | + phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); | |
7570 | phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); | |
7571 | ||
7572 | /* Initialize the wait queue head for the kernel thread */ | |
7573 | @@ -2146,21 +2559,42 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7574 | pci_set_drvdata(pdev, shost); | |
7575 | phba->intr_type = NONE; | |
7576 | ||
7577 | + phba->MBslimaddr = phba->slim_memmap_p; | |
7578 | + phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; | |
7579 | + phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; | |
7580 | + phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; | |
7581 | + phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; | |
7582 | + | |
7583 | + /* Configure and enable interrupt */ | |
7584 | if (phba->cfg_use_msi == 2) { | |
7585 | - error = lpfc_enable_msix(phba); | |
7586 | - if (!error) | |
7587 | - phba->intr_type = MSIX; | |
7588 | + /* Need to issue conf_port mbox cmd before conf_msi mbox cmd */ | |
7589 | + error = lpfc_sli_config_port(phba, 3); | |
7590 | + if (error) | |
7591 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7592 | + "0427 Firmware not capable of SLI 3 mode.\n"); | |
7593 | + else { | |
7594 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7595 | + "0426 Firmware capable of SLI 3 mode.\n"); | |
7596 | + /* Now, try to enable MSI-X interrupt mode */ | |
7597 | + error = lpfc_enable_msix(phba); | |
7598 | + if (!error) { | |
7599 | + phba->intr_type = MSIX; | |
7600 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7601 | + "0430 enable MSI-X mode.\n"); | |
7602 | + } | |
7603 | + } | |
7604 | } | |
7605 | ||
7606 | /* Fallback to MSI if MSI-X initialization failed */ | |
7607 | if (phba->cfg_use_msi >= 1 && phba->intr_type == NONE) { | |
7608 | retval = pci_enable_msi(phba->pcidev); | |
7609 | - if (!retval) | |
7610 | + if (!retval) { | |
7611 | phba->intr_type = MSI; | |
7612 | - else | |
7613 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7614 | - "0452 Enable MSI failed, continuing " | |
7615 | - "with IRQ\n"); | |
7616 | + "0473 enable MSI mode.\n"); | |
7617 | + } else | |
7618 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7619 | + "0452 enable IRQ mode.\n"); | |
7620 | } | |
7621 | ||
7622 | /* MSI-X is the only case the doesn't need to call request_irq */ | |
7623 | @@ -2176,18 +2610,16 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7624 | phba->intr_type = INTx; | |
7625 | } | |
7626 | ||
7627 | - phba->MBslimaddr = phba->slim_memmap_p; | |
7628 | - phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; | |
7629 | - phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; | |
7630 | - phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; | |
7631 | - phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; | |
7632 | - | |
7633 | if (lpfc_alloc_sysfs_attr(vport)) { | |
7634 | + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
7635 | + "1476 Failed to allocate sysfs attr\n"); | |
7636 | error = -ENOMEM; | |
7637 | goto out_free_irq; | |
7638 | } | |
7639 | ||
7640 | if (lpfc_sli_hba_setup(phba)) { | |
7641 | + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
7642 | + "1477 Failed to set up hba\n"); | |
7643 | error = -ENODEV; | |
7644 | goto out_remove_device; | |
7645 | } | |
7646 | @@ -2206,6 +2638,16 @@ lpfc_pci_probe_one(struct pci_dev *pdev, | |
7647 | spin_unlock_irq(shost->host_lock); | |
7648 | } | |
7649 | ||
7650 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7651 | + "0428 Perform SCSI scan\n"); | |
7652 | + /* Send board arrival event to upper layer */ | |
7653 | + adapter_event.event_type = FC_REG_ADAPTER_EVENT; | |
7654 | + adapter_event.subcategory = LPFC_EVENT_ARRIVAL; | |
7655 | + fc_host_post_vendor_event(shost, fc_get_event_number(), | |
7656 | + sizeof(adapter_event), | |
7657 | + (char *) &adapter_event, | |
7658 | + SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
7659 | + | |
7660 | scsi_scan_host(shost); | |
7661 | ||
7662 | return 0; | |
7663 | @@ -2238,11 +2680,11 @@ out_free_iocbq: | |
7664 | } | |
7665 | lpfc_mem_free(phba); | |
7666 | out_free_hbqslimp: | |
7667 | - dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), phba->hbqslimp.virt, | |
7668 | - phba->hbqslimp.phys); | |
7669 | + dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), | |
7670 | + phba->hbqslimp.virt, phba->hbqslimp.phys); | |
7671 | out_free_slim: | |
7672 | - dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, phba->slim2p, | |
7673 | - phba->slim2p_mapping); | |
7674 | + dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, | |
7675 | + phba->slim2p.virt, phba->slim2p.phys); | |
7676 | out_iounmap: | |
7677 | iounmap(phba->ctrl_regs_memmap_p); | |
7678 | out_iounmap_slim: | |
7679 | @@ -2262,6 +2704,14 @@ out: | |
7680 | return error; | |
7681 | } | |
7682 | ||
7683 | +/** | |
7684 | + * lpfc_pci_remove_one: lpfc PCI func to unregister device from PCI subsystem. | |
7685 | + * @pdev: pointer to PCI device | |
7686 | + * | |
7687 | + * This routine is to be registered to the kernel's PCI subsystem. When an | |
7688 | + * Emulex HBA is removed from PCI bus. It perform all the necessary cleanup | |
7689 | + * for the HBA device to be removed from the PCI subsystem properly. | |
7690 | + **/ | |
7691 | static void __devexit | |
7692 | lpfc_pci_remove_one(struct pci_dev *pdev) | |
7693 | { | |
7694 | @@ -2316,12 +2766,12 @@ lpfc_pci_remove_one(struct pci_dev *pdev | |
7695 | lpfc_scsi_free(phba); | |
7696 | lpfc_mem_free(phba); | |
7697 | ||
7698 | - dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), phba->hbqslimp.virt, | |
7699 | - phba->hbqslimp.phys); | |
7700 | + dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), | |
7701 | + phba->hbqslimp.virt, phba->hbqslimp.phys); | |
7702 | ||
7703 | /* Free resources associated with SLI2 interface */ | |
7704 | dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, | |
7705 | - phba->slim2p, phba->slim2p_mapping); | |
7706 | + phba->slim2p.virt, phba->slim2p.phys); | |
7707 | ||
7708 | /* unmap adapter SLIM and Control Registers */ | |
7709 | iounmap(phba->ctrl_regs_memmap_p); | |
7710 | @@ -2336,13 +2786,21 @@ lpfc_pci_remove_one(struct pci_dev *pdev | |
7711 | } | |
7712 | ||
7713 | /** | |
7714 | - * lpfc_io_error_detected - called when PCI error is detected | |
7715 | - * @pdev: Pointer to PCI device | |
7716 | - * @state: The current pci conneection state | |
7717 | + * lpfc_io_error_detected: Driver method for handling PCI I/O error detected. | |
7718 | + * @pdev: pointer to PCI device. | |
7719 | + * @state: the current PCI connection state. | |
7720 | * | |
7721 | - * This function is called after a PCI bus error affecting | |
7722 | - * this device has been detected. | |
7723 | - */ | |
7724 | + * This routine is registered to the PCI subsystem for error handling. This | |
7725 | + * function is called by the PCI subsystem after a PCI bus error affecting | |
7726 | + * this device has been detected. When this function is invoked, it will | |
7727 | + * need to stop all the I/Os and interrupt(s) to the device. Once that is | |
7728 | + * done, it will return PCI_ERS_RESULT_NEED_RESET for the PCI subsystem to | |
7729 | + * perform proper recovery as desired. | |
7730 | + * | |
7731 | + * Return codes | |
7732 | + * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery | |
7733 | + * PCI_ERS_RESULT_DISCONNECT - device could not be recovered | |
7734 | + **/ | |
7735 | static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev, | |
7736 | pci_channel_state_t state) | |
7737 | { | |
7738 | @@ -2351,8 +2809,15 @@ static pci_ers_result_t lpfc_io_error_de | |
7739 | struct lpfc_sli *psli = &phba->sli; | |
7740 | struct lpfc_sli_ring *pring; | |
7741 | ||
7742 | - if (state == pci_channel_io_perm_failure) | |
7743 | + if (state == pci_channel_io_perm_failure) { | |
7744 | + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
7745 | + "0472 PCI channel I/O permanent failure\n"); | |
7746 | + /* Block all SCSI devices' I/Os on the host */ | |
7747 | + lpfc_scsi_dev_block(phba); | |
7748 | + /* Clean up all driver's outstanding SCSI I/Os */ | |
7749 | + lpfc_sli_flush_fcp_rings(phba); | |
7750 | return PCI_ERS_RESULT_DISCONNECT; | |
7751 | + } | |
7752 | ||
7753 | pci_disable_device(pdev); | |
7754 | /* | |
7755 | @@ -2376,10 +2841,21 @@ static pci_ers_result_t lpfc_io_error_de | |
7756 | } | |
7757 | ||
7758 | /** | |
7759 | - * lpfc_io_slot_reset - called after the pci bus has been reset. | |
7760 | - * @pdev: Pointer to PCI device | |
7761 | + * lpfc_io_slot_reset: Restart a PCI device from scratch. | |
7762 | + * @pdev: pointer to PCI device. | |
7763 | + * | |
7764 | + * This routine is registered to the PCI subsystem for error handling. This is | |
7765 | + * called after PCI bus has been reset to restart the PCI card from scratch, | |
7766 | + * as if from a cold-boot. During the PCI subsystem error recovery, after the | |
7767 | + * driver returns PCI_ERS_RESULT_NEED_RESET, the PCI subsystem will perform | |
7768 | + * proper error recovery and then call this routine before calling the .resume | |
7769 | + * method to recover the device. This function will initialize the HBA device, | |
7770 | + * enable the interrupt, but it will just put the HBA to offline state without | |
7771 | + * passing any I/O traffic. | |
7772 | * | |
7773 | - * Restart the card from scratch, as if from a cold-boot. | |
7774 | + * Return codes | |
7775 | + * PCI_ERS_RESULT_RECOVERED - the device has been recovered | |
7776 | + * PCI_ERS_RESULT_DISCONNECT - device could not be recovered | |
7777 | */ | |
7778 | static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev) | |
7779 | { | |
7780 | @@ -2404,20 +2880,34 @@ static pci_ers_result_t lpfc_io_slot_res | |
7781 | /* Enable configured interrupt method */ | |
7782 | phba->intr_type = NONE; | |
7783 | if (phba->cfg_use_msi == 2) { | |
7784 | - error = lpfc_enable_msix(phba); | |
7785 | - if (!error) | |
7786 | - phba->intr_type = MSIX; | |
7787 | + /* Need to issue conf_port mbox cmd before conf_msi mbox cmd */ | |
7788 | + error = lpfc_sli_config_port(phba, 3); | |
7789 | + if (error) | |
7790 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7791 | + "0478 Firmware not capable of SLI 3 mode.\n"); | |
7792 | + else { | |
7793 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7794 | + "0479 Firmware capable of SLI 3 mode.\n"); | |
7795 | + /* Now, try to enable MSI-X interrupt mode */ | |
7796 | + error = lpfc_enable_msix(phba); | |
7797 | + if (!error) { | |
7798 | + phba->intr_type = MSIX; | |
7799 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7800 | + "0480 enable MSI-X mode.\n"); | |
7801 | + } | |
7802 | + } | |
7803 | } | |
7804 | ||
7805 | /* Fallback to MSI if MSI-X initialization failed */ | |
7806 | if (phba->cfg_use_msi >= 1 && phba->intr_type == NONE) { | |
7807 | retval = pci_enable_msi(phba->pcidev); | |
7808 | - if (!retval) | |
7809 | + if (!retval) { | |
7810 | phba->intr_type = MSI; | |
7811 | - else | |
7812 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7813 | - "0470 Enable MSI failed, continuing " | |
7814 | - "with IRQ\n"); | |
7815 | + "0481 enable MSI mode.\n"); | |
7816 | + } else | |
7817 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | |
7818 | + "0470 enable IRQ mode.\n"); | |
7819 | } | |
7820 | ||
7821 | /* MSI-X is the only case the doesn't need to call request_irq */ | |
7822 | @@ -2440,11 +2930,13 @@ static pci_ers_result_t lpfc_io_slot_res | |
7823 | } | |
7824 | ||
7825 | /** | |
7826 | - * lpfc_io_resume - called when traffic can start flowing again. | |
7827 | - * @pdev: Pointer to PCI device | |
7828 | + * lpfc_io_resume: Resume PCI I/O operation. | |
7829 | + * @pdev: pointer to PCI device | |
7830 | * | |
7831 | - * This callback is called when the error recovery driver tells us that | |
7832 | - * its OK to resume normal operation. | |
7833 | + * This routine is registered to the PCI subsystem for error handling. It is | |
7834 | + * called when kernel error recovery tells the lpfc driver that it is ok to | |
7835 | + * resume normal PCI operation after PCI bus error recovery. After this call, | |
7836 | + * traffic can start to flow from this device again. | |
7837 | */ | |
7838 | static void lpfc_io_resume(struct pci_dev *pdev) | |
7839 | { | |
7840 | @@ -2491,6 +2983,8 @@ static struct pci_device_id lpfc_id_tabl | |
7841 | PCI_ANY_ID, PCI_ANY_ID, }, | |
7842 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR, | |
7843 | PCI_ANY_ID, PCI_ANY_ID, }, | |
7844 | + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HORNET, | |
7845 | + PCI_ANY_ID, PCI_ANY_ID, }, | |
7846 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_SCSP, | |
7847 | PCI_ANY_ID, PCI_ANY_ID, }, | |
7848 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_DCSP, | |
7849 | @@ -2521,6 +3015,12 @@ static struct pci_device_id lpfc_id_tabl | |
7850 | PCI_ANY_ID, PCI_ANY_ID, }, | |
7851 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_S, | |
7852 | PCI_ANY_ID, PCI_ANY_ID, }, | |
7853 | + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PROTEUS_VF, | |
7854 | + PCI_ANY_ID, PCI_ANY_ID, }, | |
7855 | + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PROTEUS_PF, | |
7856 | + PCI_ANY_ID, PCI_ANY_ID, }, | |
7857 | + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PROTEUS_S, | |
7858 | + PCI_ANY_ID, PCI_ANY_ID, }, | |
7859 | { 0 } | |
7860 | }; | |
7861 | ||
7862 | @@ -2540,6 +3040,18 @@ static struct pci_driver lpfc_driver = { | |
7863 | .err_handler = &lpfc_err_handler, | |
7864 | }; | |
7865 | ||
7866 | +/** | |
7867 | + * lpfc_init: lpfc module initialization routine. | |
7868 | + * | |
7869 | + * This routine is to be invoked when the lpfc module is loaded into the | |
7870 | + * kernel. The special kernel macro module_init() is used to indicate the | |
7871 | + * role of this routine to the kernel as lpfc module entry point. | |
7872 | + * | |
7873 | + * Return codes | |
7874 | + * 0 - successful | |
7875 | + * -ENOMEM - FC attach transport failed | |
7876 | + * all others - failed | |
7877 | + */ | |
7878 | static int __init | |
7879 | lpfc_init(void) | |
7880 | { | |
7881 | @@ -2567,12 +3079,20 @@ lpfc_init(void) | |
7882 | error = pci_register_driver(&lpfc_driver); | |
7883 | if (error) { | |
7884 | fc_release_transport(lpfc_transport_template); | |
7885 | - fc_release_transport(lpfc_vport_transport_template); | |
7886 | + if (lpfc_enable_npiv) | |
7887 | + fc_release_transport(lpfc_vport_transport_template); | |
7888 | } | |
7889 | ||
7890 | return error; | |
7891 | } | |
7892 | ||
7893 | +/** | |
7894 | + * lpfc_exit: lpfc module removal routine. | |
7895 | + * | |
7896 | + * This routine is invoked when the lpfc module is removed from the kernel. | |
7897 | + * The special kernel macro module_exit() is used to indicate the role of | |
7898 | + * this routine to the kernel as lpfc module exit point. | |
7899 | + */ | |
7900 | static void __exit | |
7901 | lpfc_exit(void) | |
7902 | { | |
7903 | --- a/drivers/scsi/lpfc/lpfc_mbox.c | |
7904 | +++ b/drivers/scsi/lpfc/lpfc_mbox.c | |
7905 | @@ -1,7 +1,7 @@ | |
7906 | /******************************************************************* | |
7907 | * This file is part of the Emulex Linux Device Driver for * | |
7908 | * Fibre Channel Host Bus Adapters. * | |
7909 | - * Copyright (C) 2004-2007 Emulex. All rights reserved. * | |
7910 | + * Copyright (C) 2004-2008 Emulex. All rights reserved. * | |
7911 | * EMULEX and SLI are trademarks of Emulex. * | |
7912 | * www.emulex.com * | |
7913 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | |
7914 | @@ -30,6 +30,7 @@ | |
7915 | ||
7916 | #include "lpfc_hw.h" | |
7917 | #include "lpfc_sli.h" | |
7918 | +#include "lpfc_nl.h" | |
7919 | #include "lpfc_disc.h" | |
7920 | #include "lpfc_scsi.h" | |
7921 | #include "lpfc.h" | |
7922 | @@ -37,10 +38,20 @@ | |
7923 | #include "lpfc_crtn.h" | |
7924 | #include "lpfc_compat.h" | |
7925 | ||
7926 | -/**********************************************/ | |
7927 | - | |
7928 | -/* mailbox command */ | |
7929 | -/**********************************************/ | |
7930 | +/** | |
7931 | + * lpfc_dump_mem: Prepare a mailbox command for retrieving HBA's VPD memory. | |
7932 | + * @phba: pointer to lpfc hba data structure. | |
7933 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
7934 | + * @offset: offset for dumping VPD memory mailbox command. | |
7935 | + * | |
7936 | + * The dump mailbox command provides a method for the device driver to obtain | |
7937 | + * various types of information from the HBA device. | |
7938 | + * | |
7939 | + * This routine prepares the mailbox command for dumping HBA Vital Product | |
7940 | + * Data (VPD) memory. This mailbox command is to be used for retrieving a | |
7941 | + * portion (DMP_RSP_SIZE bytes) of a HBA's VPD from the HBA at an address | |
7942 | + * offset specified by the offset parameter. | |
7943 | + **/ | |
7944 | void | |
7945 | lpfc_dump_mem(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint16_t offset) | |
7946 | { | |
7947 | @@ -65,10 +76,17 @@ lpfc_dump_mem(struct lpfc_hba * phba, LP | |
7948 | return; | |
7949 | } | |
7950 | ||
7951 | -/**********************************************/ | |
7952 | -/* lpfc_read_nv Issue a READ NVPARAM */ | |
7953 | -/* mailbox command */ | |
7954 | -/**********************************************/ | |
7955 | +/** | |
7956 | + * lpfc_read_nv: Prepare a mailbox command for reading HBA's NVRAM param. | |
7957 | + * @phba: pointer to lpfc hba data structure. | |
7958 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
7959 | + * | |
7960 | + * The read NVRAM mailbox command returns the HBA's non-volatile parameters | |
7961 | + * that are used as defaults when the Fibre Channel link is brought on-line. | |
7962 | + * | |
7963 | + * This routine prepares the mailbox command for reading information stored | |
7964 | + * in the HBA's NVRAM. Specifically, the HBA's WWNN and WWPN. | |
7965 | + **/ | |
7966 | void | |
7967 | lpfc_read_nv(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
7968 | { | |
7969 | @@ -81,10 +99,19 @@ lpfc_read_nv(struct lpfc_hba * phba, LPF | |
7970 | return; | |
7971 | } | |
7972 | ||
7973 | -/**********************************************/ | |
7974 | -/* lpfc_config_async Issue a */ | |
7975 | -/* MBX_ASYNC_EVT_ENABLE mailbox command */ | |
7976 | -/**********************************************/ | |
7977 | +/** | |
7978 | + * lpfc_config_async: Prepare a mailbox command for enabling HBA async event. | |
7979 | + * @phba: pointer to lpfc hba data structure. | |
7980 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
7981 | + * @ring: ring number for the asynchronous event to be configured. | |
7982 | + * | |
7983 | + * The asynchronous event enable mailbox command is used to enable the | |
7984 | + * asynchronous event posting via the ASYNC_STATUS_CN IOCB response and | |
7985 | + * specifies the default ring to which events are posted. | |
7986 | + * | |
7987 | + * This routine prepares the mailbox command for enabling HBA asynchronous | |
7988 | + * event support on a IOCB ring. | |
7989 | + **/ | |
7990 | void | |
7991 | lpfc_config_async(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, | |
7992 | uint32_t ring) | |
7993 | @@ -99,10 +126,19 @@ lpfc_config_async(struct lpfc_hba * phba | |
7994 | return; | |
7995 | } | |
7996 | ||
7997 | -/**********************************************/ | |
7998 | -/* lpfc_heart_beat Issue a HEART_BEAT */ | |
7999 | -/* mailbox command */ | |
8000 | -/**********************************************/ | |
8001 | +/** | |
8002 | + * lpfc_heart_beat: Prepare a mailbox command for heart beat. | |
8003 | + * @phba: pointer to lpfc hba data structure. | |
8004 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8005 | + * | |
8006 | + * The heart beat mailbox command is used to detect an unresponsive HBA, which | |
8007 | + * is defined as any device where no error attention is sent and both mailbox | |
8008 | + * and rings are not processed. | |
8009 | + * | |
8010 | + * This routine prepares the mailbox command for issuing a heart beat in the | |
8011 | + * form of mailbox command to the HBA. The timely completion of the heart | |
8012 | + * beat mailbox command indicates the health of the HBA. | |
8013 | + **/ | |
8014 | void | |
8015 | lpfc_heart_beat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
8016 | { | |
8017 | @@ -115,10 +151,26 @@ lpfc_heart_beat(struct lpfc_hba * phba, | |
8018 | return; | |
8019 | } | |
8020 | ||
8021 | -/**********************************************/ | |
8022 | -/* lpfc_read_la Issue a READ LA */ | |
8023 | -/* mailbox command */ | |
8024 | -/**********************************************/ | |
8025 | +/** | |
8026 | + * lpfc_read_la: Prepare a mailbox command for reading HBA link attention. | |
8027 | + * @phba: pointer to lpfc hba data structure. | |
8028 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8029 | + * @mp: DMA buffer memory for reading the link attention information into. | |
8030 | + * | |
8031 | + * The read link attention mailbox command is issued to read the Link Event | |
8032 | + * Attention information indicated by the HBA port when the Link Event bit | |
8033 | + * of the Host Attention (HSTATT) register is set to 1. A Link Event | |
8034 | + * Attention occurs based on an exception detected at the Fibre Channel link | |
8035 | + * interface. | |
8036 | + * | |
8037 | + * This routine prepares the mailbox command for reading HBA link attention | |
8038 | + * information. A DMA memory has been set aside and address passed to the | |
8039 | + * HBA through @mp for the HBA to DMA link attention information into the | |
8040 | + * memory as part of the execution of the mailbox command. | |
8041 | + * | |
8042 | + * Return codes | |
8043 | + * 0 - Success (currently always return 0) | |
8044 | + **/ | |
8045 | int | |
8046 | lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, struct lpfc_dmabuf *mp) | |
8047 | { | |
8048 | @@ -143,10 +195,21 @@ lpfc_read_la(struct lpfc_hba * phba, LPF | |
8049 | return (0); | |
8050 | } | |
8051 | ||
8052 | -/**********************************************/ | |
8053 | -/* lpfc_clear_la Issue a CLEAR LA */ | |
8054 | -/* mailbox command */ | |
8055 | -/**********************************************/ | |
8056 | +/** | |
8057 | + * lpfc_clear_la: Prepare a mailbox command for clearing HBA link attention. | |
8058 | + * @phba: pointer to lpfc hba data structure. | |
8059 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8060 | + * | |
8061 | + * The clear link attention mailbox command is issued to clear the link event | |
8062 | + * attention condition indicated by the Link Event bit of the Host Attention | |
8063 | + * (HSTATT) register. The link event attention condition is cleared only if | |
8064 | + * the event tag specified matches that of the current link event counter. | |
8065 | + * The current event tag is read using the read link attention event mailbox | |
8066 | + * command. | |
8067 | + * | |
8068 | + * This routine prepares the mailbox command for clearing HBA link attention | |
8069 | + * information. | |
8070 | + **/ | |
8071 | void | |
8072 | lpfc_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
8073 | { | |
8074 | @@ -161,10 +224,20 @@ lpfc_clear_la(struct lpfc_hba * phba, LP | |
8075 | return; | |
8076 | } | |
8077 | ||
8078 | -/**************************************************/ | |
8079 | -/* lpfc_config_link Issue a CONFIG LINK */ | |
8080 | -/* mailbox command */ | |
8081 | -/**************************************************/ | |
8082 | +/** | |
8083 | + * lpfc_config_link: Prepare a mailbox command for configuring link on a HBA. | |
8084 | + * @phba: pointer to lpfc hba data structure. | |
8085 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8086 | + * | |
8087 | + * The configure link mailbox command is used before the initialize link | |
8088 | + * mailbox command to override default value and to configure link-oriented | |
8089 | + * parameters such as DID address and various timers. Typically, this | |
8090 | + * command would be used after an F_Port login to set the returned DID address | |
8091 | + * and the fabric timeout values. This command is not valid before a configure | |
8092 | + * port command has configured the HBA port. | |
8093 | + * | |
8094 | + * This routine prepares the mailbox command for configuring link on a HBA. | |
8095 | + **/ | |
8096 | void | |
8097 | lpfc_config_link(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
8098 | { | |
8099 | @@ -199,10 +272,98 @@ lpfc_config_link(struct lpfc_hba * phba, | |
8100 | return; | |
8101 | } | |
8102 | ||
8103 | -/**********************************************/ | |
8104 | -/* lpfc_init_link Issue an INIT LINK */ | |
8105 | -/* mailbox command */ | |
8106 | -/**********************************************/ | |
8107 | +/** | |
8108 | + * lpfc_config_msi: Prepare a mailbox command for configuring msi-x. | |
8109 | + * @phba: pointer to lpfc hba data structure. | |
8110 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8111 | + * | |
8112 | + * The configure MSI-X mailbox command is used to configure the HBA's SLI-3 | |
8113 | + * MSI-X multi-message interrupt vector association to interrupt attention | |
8114 | + * conditions. | |
8115 | + * | |
8116 | + * Return codes | |
8117 | + * 0 - Success | |
8118 | + * -EINVAL - Failure | |
8119 | + **/ | |
8120 | +int | |
8121 | +lpfc_config_msi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |
8122 | +{ | |
8123 | + MAILBOX_t *mb = &pmb->mb; | |
8124 | + uint32_t attentionConditions[2]; | |
8125 | + | |
8126 | + /* Sanity check */ | |
8127 | + if (phba->cfg_use_msi != 2) { | |
8128 | + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
8129 | + "0475 Not configured for supporting MSI-X " | |
8130 | + "cfg_use_msi: 0x%x\n", phba->cfg_use_msi); | |
8131 | + return -EINVAL; | |
8132 | + } | |
8133 | + | |
8134 | + if (phba->sli_rev < 3) { | |
8135 | + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
8136 | + "0476 HBA not supporting SLI-3 or later " | |
8137 | + "SLI Revision: 0x%x\n", phba->sli_rev); | |
8138 | + return -EINVAL; | |
8139 | + } | |
8140 | + | |
8141 | + /* Clear mailbox command fields */ | |
8142 | + memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); | |
8143 | + | |
8144 | + /* | |
8145 | + * SLI-3, Message Signaled Interrupt Fearure. | |
8146 | + */ | |
8147 | + | |
8148 | + /* Multi-message attention configuration */ | |
8149 | + attentionConditions[0] = (HA_R0ATT | HA_R1ATT | HA_R2ATT | HA_ERATT | | |
8150 | + HA_LATT | HA_MBATT); | |
8151 | + attentionConditions[1] = 0; | |
8152 | + | |
8153 | + mb->un.varCfgMSI.attentionConditions[0] = attentionConditions[0]; | |
8154 | + mb->un.varCfgMSI.attentionConditions[1] = attentionConditions[1]; | |
8155 | + | |
8156 | + /* | |
8157 | + * Set up message number to HA bit association | |
8158 | + */ | |
8159 | +#ifdef __BIG_ENDIAN_BITFIELD | |
8160 | + /* RA0 (FCP Ring) */ | |
8161 | + mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS] = 1; | |
8162 | + /* RA1 (Other Protocol Extra Ring) */ | |
8163 | + mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS] = 1; | |
8164 | +#else /* __LITTLE_ENDIAN_BITFIELD */ | |
8165 | + /* RA0 (FCP Ring) */ | |
8166 | + mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS^3] = 1; | |
8167 | + /* RA1 (Other Protocol Extra Ring) */ | |
8168 | + mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS^3] = 1; | |
8169 | +#endif | |
8170 | + /* Multi-message interrupt autoclear configuration*/ | |
8171 | + mb->un.varCfgMSI.autoClearHA[0] = attentionConditions[0]; | |
8172 | + mb->un.varCfgMSI.autoClearHA[1] = attentionConditions[1]; | |
8173 | + | |
8174 | + /* For now, HBA autoclear does not work reliably, disable it */ | |
8175 | + mb->un.varCfgMSI.autoClearHA[0] = 0; | |
8176 | + mb->un.varCfgMSI.autoClearHA[1] = 0; | |
8177 | + | |
8178 | + /* Set command and owner bit */ | |
8179 | + mb->mbxCommand = MBX_CONFIG_MSI; | |
8180 | + mb->mbxOwner = OWN_HOST; | |
8181 | + | |
8182 | + return 0; | |
8183 | +} | |
8184 | + | |
8185 | +/** | |
8186 | + * lpfc_init_link: Prepare a mailbox command for initialize link on a HBA. | |
8187 | + * @phba: pointer to lpfc hba data structure. | |
8188 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8189 | + * @topology: the link topology for the link to be initialized to. | |
8190 | + * @linkspeed: the link speed for the link to be initialized to. | |
8191 | + * | |
8192 | + * The initialize link mailbox command is used to initialize the Fibre | |
8193 | + * Channel link. This command must follow a configure port command that | |
8194 | + * establishes the mode of operation. | |
8195 | + * | |
8196 | + * This routine prepares the mailbox command for initializing link on a HBA | |
8197 | + * with the specified link topology and speed. | |
8198 | + **/ | |
8199 | void | |
8200 | lpfc_init_link(struct lpfc_hba * phba, | |
8201 | LPFC_MBOXQ_t * pmb, uint32_t topology, uint32_t linkspeed) | |
8202 | @@ -269,10 +430,27 @@ lpfc_init_link(struct lpfc_hba * phba, | |
8203 | return; | |
8204 | } | |
8205 | ||
8206 | -/**********************************************/ | |
8207 | -/* lpfc_read_sparam Issue a READ SPARAM */ | |
8208 | -/* mailbox command */ | |
8209 | -/**********************************************/ | |
8210 | +/** | |
8211 | + * lpfc_read_sparam: Prepare a mailbox command for reading HBA parameters. | |
8212 | + * @phba: pointer to lpfc hba data structure. | |
8213 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8214 | + * @vpi: virtual N_Port identifier. | |
8215 | + * | |
8216 | + * The read service parameter mailbox command is used to read the HBA port | |
8217 | + * service parameters. The service parameters are read into the buffer | |
8218 | + * specified directly by a BDE in the mailbox command. These service | |
8219 | + * parameters may then be used to build the payload of an N_Port/F_POrt | |
8220 | + * login request and reply (LOGI/ACC). | |
8221 | + * | |
8222 | + * This routine prepares the mailbox command for reading HBA port service | |
8223 | + * parameters. The DMA memory is allocated in this function and the addresses | |
8224 | + * are populated into the mailbox command for the HBA to DMA the service | |
8225 | + * parameters into. | |
8226 | + * | |
8227 | + * Return codes | |
8228 | + * 0 - Success | |
8229 | + * 1 - DMA memory allocation failed | |
8230 | + **/ | |
8231 | int | |
8232 | lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) | |
8233 | { | |
8234 | @@ -312,10 +490,21 @@ lpfc_read_sparam(struct lpfc_hba *phba, | |
8235 | return (0); | |
8236 | } | |
8237 | ||
8238 | -/********************************************/ | |
8239 | -/* lpfc_unreg_did Issue a UNREG_DID */ | |
8240 | -/* mailbox command */ | |
8241 | -/********************************************/ | |
8242 | +/** | |
8243 | + * lpfc_unreg_did: Prepare a mailbox command for unregistering DID. | |
8244 | + * @phba: pointer to lpfc hba data structure. | |
8245 | + * @vpi: virtual N_Port identifier. | |
8246 | + * @did: remote port identifier. | |
8247 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8248 | + * | |
8249 | + * The unregister DID mailbox command is used to unregister an N_Port/F_Port | |
8250 | + * login for an unknown RPI by specifying the DID of a remote port. This | |
8251 | + * command frees an RPI context in the HBA port. This has the effect of | |
8252 | + * performing an implicit N_Port/F_Port logout. | |
8253 | + * | |
8254 | + * This routine prepares the mailbox command for unregistering a remote | |
8255 | + * N_Port/F_Port (DID) login. | |
8256 | + **/ | |
8257 | void | |
8258 | lpfc_unreg_did(struct lpfc_hba * phba, uint16_t vpi, uint32_t did, | |
8259 | LPFC_MBOXQ_t * pmb) | |
8260 | @@ -333,10 +522,19 @@ lpfc_unreg_did(struct lpfc_hba * phba, u | |
8261 | return; | |
8262 | } | |
8263 | ||
8264 | -/**********************************************/ | |
8265 | -/* lpfc_read_nv Issue a READ CONFIG */ | |
8266 | -/* mailbox command */ | |
8267 | -/**********************************************/ | |
8268 | +/** | |
8269 | + * lpfc_read_config: Prepare a mailbox command for reading HBA configuration. | |
8270 | + * @phba: pointer to lpfc hba data structure. | |
8271 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8272 | + * | |
8273 | + * The read configuration mailbox command is used to read the HBA port | |
8274 | + * configuration parameters. This mailbox command provides a method for | |
8275 | + * seeing any parameters that may have changed via various configuration | |
8276 | + * mailbox commands. | |
8277 | + * | |
8278 | + * This routine prepares the mailbox command for reading out HBA configuration | |
8279 | + * parameters. | |
8280 | + **/ | |
8281 | void | |
8282 | lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
8283 | { | |
8284 | @@ -350,10 +548,18 @@ lpfc_read_config(struct lpfc_hba * phba, | |
8285 | return; | |
8286 | } | |
8287 | ||
8288 | -/*************************************************/ | |
8289 | -/* lpfc_read_lnk_stat Issue a READ LINK STATUS */ | |
8290 | -/* mailbox command */ | |
8291 | -/*************************************************/ | |
8292 | +/** | |
8293 | + * lpfc_read_lnk_stat: Prepare a mailbox command for reading HBA link stats. | |
8294 | + * @phba: pointer to lpfc hba data structure. | |
8295 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8296 | + * | |
8297 | + * The read link status mailbox command is used to read the link status from | |
8298 | + * the HBA. Link status includes all link-related error counters. These | |
8299 | + * counters are maintained by the HBA and originated in the link hardware | |
8300 | + * unit. Note that all of these counters wrap. | |
8301 | + * | |
8302 | + * This routine prepares the mailbox command for reading out HBA link status. | |
8303 | + **/ | |
8304 | void | |
8305 | lpfc_read_lnk_stat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
8306 | { | |
8307 | @@ -367,10 +573,30 @@ lpfc_read_lnk_stat(struct lpfc_hba * phb | |
8308 | return; | |
8309 | } | |
8310 | ||
8311 | -/********************************************/ | |
8312 | -/* lpfc_reg_login Issue a REG_LOGIN */ | |
8313 | -/* mailbox command */ | |
8314 | -/********************************************/ | |
8315 | +/** | |
8316 | + * lpfc_reg_login: Prepare a mailbox command for registering remote login. | |
8317 | + * @phba: pointer to lpfc hba data structure. | |
8318 | + * @vpi: virtual N_Port identifier. | |
8319 | + * @did: remote port identifier. | |
8320 | + * @param: pointer to memory holding the server parameters. | |
8321 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8322 | + * @flag: action flag to be passed back for the complete function. | |
8323 | + * | |
8324 | + * The registration login mailbox command is used to register an N_Port or | |
8325 | + * F_Port login. This registration allows the HBA to cache the remote N_Port | |
8326 | + * service parameters internally and thereby make the appropriate FC-2 | |
8327 | + * decisions. The remote port service parameters are handed off by the driver | |
8328 | + * to the HBA using a descriptor entry that directly identifies a buffer in | |
8329 | + * host memory. In exchange, the HBA returns an RPI identifier. | |
8330 | + * | |
8331 | + * This routine prepares the mailbox command for registering remote port login. | |
8332 | + * The function allocates DMA buffer for passing the service parameters to the | |
8333 | + * HBA with the mailbox command. | |
8334 | + * | |
8335 | + * Return codes | |
8336 | + * 0 - Success | |
8337 | + * 1 - DMA memory allocation failed | |
8338 | + **/ | |
8339 | int | |
8340 | lpfc_reg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, | |
8341 | uint8_t *param, LPFC_MBOXQ_t *pmb, uint32_t flag) | |
8342 | @@ -418,10 +644,20 @@ lpfc_reg_login(struct lpfc_hba *phba, ui | |
8343 | return (0); | |
8344 | } | |
8345 | ||
8346 | -/**********************************************/ | |
8347 | -/* lpfc_unreg_login Issue a UNREG_LOGIN */ | |
8348 | -/* mailbox command */ | |
8349 | -/**********************************************/ | |
8350 | +/** | |
8351 | + * lpfc_unreg_login: Prepare a mailbox command for unregistering remote login. | |
8352 | + * @phba: pointer to lpfc hba data structure. | |
8353 | + * @vpi: virtual N_Port identifier. | |
8354 | + * @rpi: remote port identifier | |
8355 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8356 | + * | |
8357 | + * The unregistration login mailbox command is used to unregister an N_Port | |
8358 | + * or F_Port login. This command frees an RPI context in the HBA. It has the | |
8359 | + * effect of performing an implicit N_Port/F_Port logout. | |
8360 | + * | |
8361 | + * This routine prepares the mailbox command for unregistering remote port | |
8362 | + * login. | |
8363 | + **/ | |
8364 | void | |
8365 | lpfc_unreg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t rpi, | |
8366 | LPFC_MBOXQ_t * pmb) | |
8367 | @@ -440,10 +676,21 @@ lpfc_unreg_login(struct lpfc_hba *phba, | |
8368 | return; | |
8369 | } | |
8370 | ||
8371 | -/**************************************************/ | |
8372 | -/* lpfc_reg_vpi Issue a REG_VPI */ | |
8373 | -/* mailbox command */ | |
8374 | -/**************************************************/ | |
8375 | +/** | |
8376 | + * lpfc_reg_vpi: Prepare a mailbox command for registering vport identifier. | |
8377 | + * @phba: pointer to lpfc hba data structure. | |
8378 | + * @vpi: virtual N_Port identifier. | |
8379 | + * @sid: Fibre Channel S_ID (N_Port_ID assigned to a virtual N_Port). | |
8380 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8381 | + * | |
8382 | + * The registration vport identifier mailbox command is used to activate a | |
8383 | + * virtual N_Port after it has acquired an N_Port_ID. The HBA validates the | |
8384 | + * N_Port_ID against the information in the selected virtual N_Port context | |
8385 | + * block and marks it active to allow normal processing of IOCB commands and | |
8386 | + * received unsolicited exchanges. | |
8387 | + * | |
8388 | + * This routine prepares the mailbox command for registering a virtual N_Port. | |
8389 | + **/ | |
8390 | void | |
8391 | lpfc_reg_vpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t sid, | |
8392 | LPFC_MBOXQ_t *pmb) | |
8393 | @@ -461,10 +708,22 @@ lpfc_reg_vpi(struct lpfc_hba *phba, uint | |
8394 | ||
8395 | } | |
8396 | ||
8397 | -/**************************************************/ | |
8398 | -/* lpfc_unreg_vpi Issue a UNREG_VNPI */ | |
8399 | -/* mailbox command */ | |
8400 | -/**************************************************/ | |
8401 | +/** | |
8402 | + * lpfc_unreg_vpi: Prepare a mailbox command for unregistering vport id. | |
8403 | + * @phba: pointer to lpfc hba data structure. | |
8404 | + * @vpi: virtual N_Port identifier. | |
8405 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8406 | + * | |
8407 | + * The unregistration vport identifier mailbox command is used to inactivate | |
8408 | + * a virtual N_Port. The driver must have logged out and unregistered all | |
8409 | + * remote N_Ports to abort any activity on the virtual N_Port. The HBA will | |
8410 | + * unregisters any default RPIs associated with the specified vpi, aborting | |
8411 | + * any active exchanges. The HBA will post the mailbox response after making | |
8412 | + * the virtual N_Port inactive. | |
8413 | + * | |
8414 | + * This routine prepares the mailbox command for unregistering a virtual | |
8415 | + * N_Port. | |
8416 | + **/ | |
8417 | void | |
8418 | lpfc_unreg_vpi(struct lpfc_hba *phba, uint16_t vpi, LPFC_MBOXQ_t *pmb) | |
8419 | { | |
8420 | @@ -479,12 +738,19 @@ lpfc_unreg_vpi(struct lpfc_hba *phba, ui | |
8421 | ||
8422 | } | |
8423 | ||
8424 | +/** | |
8425 | + * lpfc_config_pcb_setup: Set up IOCB rings in the Port Control Block (PCB) | |
8426 | + * @phba: pointer to lpfc hba data structure. | |
8427 | + * | |
8428 | + * This routine sets up and initializes the IOCB rings in the Port Control | |
8429 | + * Block (PCB). | |
8430 | + **/ | |
8431 | static void | |
8432 | lpfc_config_pcb_setup(struct lpfc_hba * phba) | |
8433 | { | |
8434 | struct lpfc_sli *psli = &phba->sli; | |
8435 | struct lpfc_sli_ring *pring; | |
8436 | - PCB_t *pcbp = &phba->slim2p->pcb; | |
8437 | + PCB_t *pcbp = phba->pcb; | |
8438 | dma_addr_t pdma_addr; | |
8439 | uint32_t offset; | |
8440 | uint32_t iocbCnt = 0; | |
8441 | @@ -513,29 +779,43 @@ lpfc_config_pcb_setup(struct lpfc_hba * | |
8442 | continue; | |
8443 | } | |
8444 | /* Command ring setup for ring */ | |
8445 | - pring->cmdringaddr = (void *) &phba->slim2p->IOCBs[iocbCnt]; | |
8446 | + pring->cmdringaddr = (void *)&phba->IOCBs[iocbCnt]; | |
8447 | pcbp->rdsc[i].cmdEntries = pring->numCiocb; | |
8448 | ||
8449 | - offset = (uint8_t *) &phba->slim2p->IOCBs[iocbCnt] - | |
8450 | - (uint8_t *) phba->slim2p; | |
8451 | - pdma_addr = phba->slim2p_mapping + offset; | |
8452 | + offset = (uint8_t *) &phba->IOCBs[iocbCnt] - | |
8453 | + (uint8_t *) phba->slim2p.virt; | |
8454 | + pdma_addr = phba->slim2p.phys + offset; | |
8455 | pcbp->rdsc[i].cmdAddrHigh = putPaddrHigh(pdma_addr); | |
8456 | pcbp->rdsc[i].cmdAddrLow = putPaddrLow(pdma_addr); | |
8457 | iocbCnt += pring->numCiocb; | |
8458 | ||
8459 | /* Response ring setup for ring */ | |
8460 | - pring->rspringaddr = (void *) &phba->slim2p->IOCBs[iocbCnt]; | |
8461 | + pring->rspringaddr = (void *) &phba->IOCBs[iocbCnt]; | |
8462 | ||
8463 | pcbp->rdsc[i].rspEntries = pring->numRiocb; | |
8464 | - offset = (uint8_t *)&phba->slim2p->IOCBs[iocbCnt] - | |
8465 | - (uint8_t *)phba->slim2p; | |
8466 | - pdma_addr = phba->slim2p_mapping + offset; | |
8467 | + offset = (uint8_t *)&phba->IOCBs[iocbCnt] - | |
8468 | + (uint8_t *)phba->slim2p.virt; | |
8469 | + pdma_addr = phba->slim2p.phys + offset; | |
8470 | pcbp->rdsc[i].rspAddrHigh = putPaddrHigh(pdma_addr); | |
8471 | pcbp->rdsc[i].rspAddrLow = putPaddrLow(pdma_addr); | |
8472 | iocbCnt += pring->numRiocb; | |
8473 | } | |
8474 | } | |
8475 | ||
8476 | +/** | |
8477 | + * lpfc_read_rev: Prepare a mailbox command for reading HBA revision. | |
8478 | + * @phba: pointer to lpfc hba data structure. | |
8479 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8480 | + * | |
8481 | + * The read revision mailbox command is used to read the revision levels of | |
8482 | + * the HBA components. These components include hardware units, resident | |
8483 | + * firmware, and available firmware. HBAs that supports SLI-3 mode of | |
8484 | + * operation provide different response information depending on the version | |
8485 | + * requested by the driver. | |
8486 | + * | |
8487 | + * This routine prepares the mailbox command for reading HBA revision | |
8488 | + * information. | |
8489 | + **/ | |
8490 | void | |
8491 | lpfc_read_rev(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
8492 | { | |
8493 | @@ -548,6 +828,16 @@ lpfc_read_rev(struct lpfc_hba * phba, LP | |
8494 | return; | |
8495 | } | |
8496 | ||
8497 | +/** | |
8498 | + * lpfc_build_hbq_profile2: Set up the HBQ Selection Profile 2. | |
8499 | + * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | |
8500 | + * @hbq_desc: pointer to the HBQ selection profile descriptor. | |
8501 | + * | |
8502 | + * The Host Buffer Queue (HBQ) Selection Profile 2 specifies that the HBA | |
8503 | + * tests the incoming frames' R_CTL/TYPE fields with works 10:15 and performs | |
8504 | + * the Sequence Length Test using the fields in the Selection Profile 2 | |
8505 | + * extension in words 20:31. | |
8506 | + **/ | |
8507 | static void | |
8508 | lpfc_build_hbq_profile2(struct config_hbq_var *hbqmb, | |
8509 | struct lpfc_hbq_init *hbq_desc) | |
8510 | @@ -557,6 +847,16 @@ lpfc_build_hbq_profile2(struct config_hb | |
8511 | hbqmb->profiles.profile2.seqlenoff = hbq_desc->seqlenoff; | |
8512 | } | |
8513 | ||
8514 | +/** | |
8515 | + * lpfc_build_hbq_profile3: Set up the HBQ Selection Profile 3. | |
8516 | + * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | |
8517 | + * @hbq_desc: pointer to the HBQ selection profile descriptor. | |
8518 | + * | |
8519 | + * The Host Buffer Queue (HBQ) Selection Profile 3 specifies that the HBA | |
8520 | + * tests the incoming frame's R_CTL/TYPE fields with words 10:15 and performs | |
8521 | + * the Sequence Length Test and Byte Field Test using the fields in the | |
8522 | + * Selection Profile 3 extension in words 20:31. | |
8523 | + **/ | |
8524 | static void | |
8525 | lpfc_build_hbq_profile3(struct config_hbq_var *hbqmb, | |
8526 | struct lpfc_hbq_init *hbq_desc) | |
8527 | @@ -569,6 +869,17 @@ lpfc_build_hbq_profile3(struct config_hb | |
8528 | sizeof(hbqmb->profiles.profile3.cmdmatch)); | |
8529 | } | |
8530 | ||
8531 | +/** | |
8532 | + * lpfc_build_hbq_profile5: Set up the HBQ Selection Profile 5. | |
8533 | + * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | |
8534 | + * @hbq_desc: pointer to the HBQ selection profile descriptor. | |
8535 | + * | |
8536 | + * The Host Buffer Queue (HBQ) Selection Profile 5 specifies a header HBQ. The | |
8537 | + * HBA tests the initial frame of an incoming sequence using the frame's | |
8538 | + * R_CTL/TYPE fields with words 10:15 and performs the Sequence Length Test | |
8539 | + * and Byte Field Test using the fields in the Selection Profile 5 extension | |
8540 | + * words 20:31. | |
8541 | + **/ | |
8542 | static void | |
8543 | lpfc_build_hbq_profile5(struct config_hbq_var *hbqmb, | |
8544 | struct lpfc_hbq_init *hbq_desc) | |
8545 | @@ -581,6 +892,20 @@ lpfc_build_hbq_profile5(struct config_hb | |
8546 | sizeof(hbqmb->profiles.profile5.cmdmatch)); | |
8547 | } | |
8548 | ||
8549 | +/** | |
8550 | + * lpfc_config_hbq: Prepare a mailbox command for configuring an HBQ. | |
8551 | + * @phba: pointer to lpfc hba data structure. | |
8552 | + * @id: HBQ identifier. | |
8553 | + * @hbq_desc: pointer to the HBA descriptor data structure. | |
8554 | + * @hbq_entry_index: index of the HBQ entry data structures. | |
8555 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8556 | + * | |
8557 | + * The configure HBQ (Host Buffer Queue) mailbox command is used to configure | |
8558 | + * an HBQ. The configuration binds events that require buffers to a particular | |
8559 | + * ring and HBQ based on a selection profile. | |
8560 | + * | |
8561 | + * This routine prepares the mailbox command for configuring an HBQ. | |
8562 | + **/ | |
8563 | void | |
8564 | lpfc_config_hbq(struct lpfc_hba *phba, uint32_t id, | |
8565 | struct lpfc_hbq_init *hbq_desc, | |
8566 | @@ -641,8 +966,23 @@ lpfc_config_hbq(struct lpfc_hba *phba, u | |
8567 | return; | |
8568 | } | |
8569 | ||
8570 | - | |
8571 | - | |
8572 | +/** | |
8573 | + * lpfc_config_ring: Prepare a mailbox command for configuring an IOCB ring. | |
8574 | + * @phba: pointer to lpfc hba data structure. | |
8575 | + * @ring: | |
8576 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8577 | + * | |
8578 | + * The configure ring mailbox command is used to configure an IOCB ring. This | |
8579 | + * configuration binds from one to six of HBA RC_CTL/TYPE mask entries to the | |
8580 | + * ring. This is used to map incoming sequences to a particular ring whose | |
8581 | + * RC_CTL/TYPE mask entry matches that of the sequence. The driver should not | |
8582 | + * attempt to configure a ring whose number is greater than the number | |
8583 | + * specified in the Port Control Block (PCB). It is an error to issue the | |
8584 | + * configure ring command more than once with the same ring number. The HBA | |
8585 | + * returns an error if the driver attempts this. | |
8586 | + * | |
8587 | + * This routine prepares the mailbox command for configuring IOCB ring. | |
8588 | + **/ | |
8589 | void | |
8590 | lpfc_config_ring(struct lpfc_hba * phba, int ring, LPFC_MBOXQ_t * pmb) | |
8591 | { | |
8592 | @@ -684,6 +1024,20 @@ lpfc_config_ring(struct lpfc_hba * phba, | |
8593 | return; | |
8594 | } | |
8595 | ||
8596 | +/** | |
8597 | + * lpfc_config_port: Prepare a mailbox command for configuring port. | |
8598 | + * @phba: pointer to lpfc hba data structure. | |
8599 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8600 | + * | |
8601 | + * The configure port mailbox command is used to identify the Port Control | |
8602 | + * Block (PCB) in the driver memory. After this command is issued, the | |
8603 | + * driver must not access the mailbox in the HBA without first resetting | |
8604 | + * the HBA. The HBA may copy the PCB information to internal storage for | |
8605 | + * subsequent use; the driver can not change the PCB information unless it | |
8606 | + * resets the HBA. | |
8607 | + * | |
8608 | + * This routine prepares the mailbox command for configuring port. | |
8609 | + **/ | |
8610 | void | |
8611 | lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |
8612 | { | |
8613 | @@ -702,8 +1056,8 @@ lpfc_config_port(struct lpfc_hba *phba, | |
8614 | ||
8615 | mb->un.varCfgPort.pcbLen = sizeof(PCB_t); | |
8616 | ||
8617 | - offset = (uint8_t *)&phba->slim2p->pcb - (uint8_t *)phba->slim2p; | |
8618 | - pdma_addr = phba->slim2p_mapping + offset; | |
8619 | + offset = (uint8_t *)phba->pcb - (uint8_t *)phba->slim2p.virt; | |
8620 | + pdma_addr = phba->slim2p.phys + offset; | |
8621 | mb->un.varCfgPort.pcbLow = putPaddrLow(pdma_addr); | |
8622 | mb->un.varCfgPort.pcbHigh = putPaddrHigh(pdma_addr); | |
8623 | ||
8624 | @@ -711,12 +1065,13 @@ lpfc_config_port(struct lpfc_hba *phba, | |
8625 | ||
8626 | if (phba->sli_rev == 3 && phba->vpd.sli3Feat.cerbm) { | |
8627 | mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ | |
8628 | + mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */ | |
8629 | + mb->un.varCfgPort.cinb = 1; /* Interrupt Notification Block */ | |
8630 | mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count(); | |
8631 | if (phba->max_vpi && phba->cfg_enable_npiv && | |
8632 | phba->vpd.sli3Feat.cmv) { | |
8633 | mb->un.varCfgPort.max_vpi = phba->max_vpi; | |
8634 | mb->un.varCfgPort.cmv = 1; | |
8635 | - phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; | |
8636 | } else | |
8637 | mb->un.varCfgPort.max_vpi = phba->max_vpi = 0; | |
8638 | } else | |
8639 | @@ -724,16 +1079,15 @@ lpfc_config_port(struct lpfc_hba *phba, | |
8640 | mb->un.varCfgPort.sli_mode = phba->sli_rev; | |
8641 | ||
8642 | /* Now setup pcb */ | |
8643 | - phba->slim2p->pcb.type = TYPE_NATIVE_SLI2; | |
8644 | - phba->slim2p->pcb.feature = FEATURE_INITIAL_SLI2; | |
8645 | + phba->pcb->type = TYPE_NATIVE_SLI2; | |
8646 | + phba->pcb->feature = FEATURE_INITIAL_SLI2; | |
8647 | ||
8648 | /* Setup Mailbox pointers */ | |
8649 | - phba->slim2p->pcb.mailBoxSize = offsetof(MAILBOX_t, us) + | |
8650 | - sizeof(struct sli2_desc); | |
8651 | - offset = (uint8_t *)&phba->slim2p->mbx - (uint8_t *)phba->slim2p; | |
8652 | - pdma_addr = phba->slim2p_mapping + offset; | |
8653 | - phba->slim2p->pcb.mbAddrHigh = putPaddrHigh(pdma_addr); | |
8654 | - phba->slim2p->pcb.mbAddrLow = putPaddrLow(pdma_addr); | |
8655 | + phba->pcb->mailBoxSize = sizeof(MAILBOX_t); | |
8656 | + offset = (uint8_t *)phba->mbox - (uint8_t *)phba->slim2p.virt; | |
8657 | + pdma_addr = phba->slim2p.phys + offset; | |
8658 | + phba->pcb->mbAddrHigh = putPaddrHigh(pdma_addr); | |
8659 | + phba->pcb->mbAddrLow = putPaddrLow(pdma_addr); | |
8660 | ||
8661 | /* | |
8662 | * Setup Host Group ring pointer. | |
8663 | @@ -794,13 +1148,13 @@ lpfc_config_port(struct lpfc_hba *phba, | |
8664 | } | |
8665 | ||
8666 | /* mask off BAR0's flag bits 0 - 3 */ | |
8667 | - phba->slim2p->pcb.hgpAddrLow = (bar_low & PCI_BASE_ADDRESS_MEM_MASK) + | |
8668 | - (void __iomem *) phba->host_gp - | |
8669 | + phba->pcb->hgpAddrLow = (bar_low & PCI_BASE_ADDRESS_MEM_MASK) + | |
8670 | + (void __iomem *)phba->host_gp - | |
8671 | (void __iomem *)phba->MBslimaddr; | |
8672 | if (bar_low & PCI_BASE_ADDRESS_MEM_TYPE_64) | |
8673 | - phba->slim2p->pcb.hgpAddrHigh = bar_high; | |
8674 | + phba->pcb->hgpAddrHigh = bar_high; | |
8675 | else | |
8676 | - phba->slim2p->pcb.hgpAddrHigh = 0; | |
8677 | + phba->pcb->hgpAddrHigh = 0; | |
8678 | /* write HGP data to SLIM at the required longword offset */ | |
8679 | memset(&hgp, 0, sizeof(struct lpfc_hgp)); | |
8680 | ||
8681 | @@ -810,17 +1164,19 @@ lpfc_config_port(struct lpfc_hba *phba, | |
8682 | } | |
8683 | ||
8684 | /* Setup Port Group ring pointer */ | |
8685 | - if (phba->sli_rev == 3) | |
8686 | - pgp_offset = (uint8_t *)&phba->slim2p->mbx.us.s3_pgp.port - | |
8687 | - (uint8_t *)phba->slim2p; | |
8688 | - else | |
8689 | - pgp_offset = (uint8_t *)&phba->slim2p->mbx.us.s2.port - | |
8690 | - (uint8_t *)phba->slim2p; | |
8691 | - | |
8692 | - pdma_addr = phba->slim2p_mapping + pgp_offset; | |
8693 | - phba->slim2p->pcb.pgpAddrHigh = putPaddrHigh(pdma_addr); | |
8694 | - phba->slim2p->pcb.pgpAddrLow = putPaddrLow(pdma_addr); | |
8695 | - phba->hbq_get = &phba->slim2p->mbx.us.s3_pgp.hbq_get[0]; | |
8696 | + if (phba->sli3_options & LPFC_SLI3_INB_ENABLED) { | |
8697 | + pgp_offset = offsetof(struct lpfc_sli2_slim, | |
8698 | + mbx.us.s3_inb_pgp.port); | |
8699 | + phba->hbq_get = phba->mbox->us.s3_inb_pgp.hbq_get; | |
8700 | + } else if (phba->sli_rev == 3) { | |
8701 | + pgp_offset = offsetof(struct lpfc_sli2_slim, | |
8702 | + mbx.us.s3_pgp.port); | |
8703 | + phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get; | |
8704 | + } else | |
8705 | + pgp_offset = offsetof(struct lpfc_sli2_slim, mbx.us.s2.port); | |
8706 | + pdma_addr = phba->slim2p.phys + pgp_offset; | |
8707 | + phba->pcb->pgpAddrHigh = putPaddrHigh(pdma_addr); | |
8708 | + phba->pcb->pgpAddrLow = putPaddrLow(pdma_addr); | |
8709 | ||
8710 | /* Use callback routine to setp rings in the pcb */ | |
8711 | lpfc_config_pcb_setup(phba); | |
8712 | @@ -835,10 +1191,24 @@ lpfc_config_port(struct lpfc_hba *phba, | |
8713 | } | |
8714 | ||
8715 | /* Swap PCB if needed */ | |
8716 | - lpfc_sli_pcimem_bcopy(&phba->slim2p->pcb, &phba->slim2p->pcb, | |
8717 | - sizeof(PCB_t)); | |
8718 | + lpfc_sli_pcimem_bcopy(phba->pcb, phba->pcb, sizeof(PCB_t)); | |
8719 | } | |
8720 | ||
8721 | +/** | |
8722 | + * lpfc_kill_board: Prepare a mailbox command for killing board. | |
8723 | + * @phba: pointer to lpfc hba data structure. | |
8724 | + * @pmb: pointer to the driver internal queue element for mailbox command. | |
8725 | + * | |
8726 | + * The kill board mailbox command is used to tell firmware to perform a | |
8727 | + * graceful shutdown of a channel on a specified board to prepare for reset. | |
8728 | + * When the kill board mailbox command is received, the ER3 bit is set to 1 | |
8729 | + * in the Host Status register and the ER Attention bit is set to 1 in the | |
8730 | + * Host Attention register of the HBA function that received the kill board | |
8731 | + * command. | |
8732 | + * | |
8733 | + * This routine prepares the mailbox command for killing the board in | |
8734 | + * preparation for a graceful shutdown. | |
8735 | + **/ | |
8736 | void | |
8737 | lpfc_kill_board(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
8738 | { | |
8739 | @@ -850,6 +1220,16 @@ lpfc_kill_board(struct lpfc_hba * phba, | |
8740 | return; | |
8741 | } | |
8742 | ||
8743 | +/** | |
8744 | + * lpfc_mbox_put: Put a mailbox cmd into the tail of driver's mailbox queue. | |
8745 | + * @phba: pointer to lpfc hba data structure. | |
8746 | + * @mbq: pointer to the driver internal queue element for mailbox command. | |
8747 | + * | |
8748 | + * Driver maintains a internal mailbox command queue implemented as a linked | |
8749 | + * list. When a mailbox command is issued, it shall be put into the mailbox | |
8750 | + * command queue such that they shall be processed orderly as HBA can process | |
8751 | + * one mailbox command at a time. | |
8752 | + **/ | |
8753 | void | |
8754 | lpfc_mbox_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | |
8755 | { | |
8756 | @@ -864,6 +1244,20 @@ lpfc_mbox_put(struct lpfc_hba * phba, LP | |
8757 | return; | |
8758 | } | |
8759 | ||
8760 | +/** | |
8761 | + * lpfc_mbox_get: Remove a mailbox cmd from the head of driver's mailbox queue. | |
8762 | + * @phba: pointer to lpfc hba data structure. | |
8763 | + * | |
8764 | + * Driver maintains a internal mailbox command queue implemented as a linked | |
8765 | + * list. When a mailbox command is issued, it shall be put into the mailbox | |
8766 | + * command queue such that they shall be processed orderly as HBA can process | |
8767 | + * one mailbox command at a time. After HBA finished processing a mailbox | |
8768 | + * command, the driver will remove a pending mailbox command from the head of | |
8769 | + * the mailbox command queue and send to the HBA for processing. | |
8770 | + * | |
8771 | + * Return codes | |
8772 | + * pointer to the driver internal queue element for mailbox command. | |
8773 | + **/ | |
8774 | LPFC_MBOXQ_t * | |
8775 | lpfc_mbox_get(struct lpfc_hba * phba) | |
8776 | { | |
8777 | @@ -877,6 +1271,17 @@ lpfc_mbox_get(struct lpfc_hba * phba) | |
8778 | return mbq; | |
8779 | } | |
8780 | ||
8781 | +/** | |
8782 | + * lpfc_mbox_cmpl_put: Put mailbox command into mailbox command complete list. | |
8783 | + * @phba: pointer to lpfc hba data structure. | |
8784 | + * @mbq: pointer to the driver internal queue element for mailbox command. | |
8785 | + * | |
8786 | + * This routine put the completed mailbox command into the mailbox command | |
8787 | + * complete list. This routine is called from driver interrupt handler | |
8788 | + * context.The mailbox complete list is used by the driver worker thread | |
8789 | + * to process mailbox complete callback functions outside the driver interrupt | |
8790 | + * handler. | |
8791 | + **/ | |
8792 | void | |
8793 | lpfc_mbox_cmpl_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | |
8794 | { | |
8795 | @@ -887,6 +1292,17 @@ lpfc_mbox_cmpl_put(struct lpfc_hba * phb | |
8796 | return; | |
8797 | } | |
8798 | ||
8799 | +/** | |
8800 | + * lpfc_mbox_tmo_val: Retrieve mailbox command timeout value. | |
8801 | + * @phba: pointer to lpfc hba data structure. | |
8802 | + * @cmd: mailbox command code. | |
8803 | + * | |
8804 | + * This routine retrieves the proper timeout value according to the mailbox | |
8805 | + * command code. | |
8806 | + * | |
8807 | + * Return codes | |
8808 | + * Timeout value to be used for the given mailbox command | |
8809 | + **/ | |
8810 | int | |
8811 | lpfc_mbox_tmo_val(struct lpfc_hba *phba, int cmd) | |
8812 | { | |
8813 | --- a/drivers/scsi/lpfc/lpfc_mem.c | |
8814 | +++ b/drivers/scsi/lpfc/lpfc_mem.c | |
8815 | @@ -1,7 +1,7 @@ | |
8816 | /******************************************************************* | |
8817 | * This file is part of the Emulex Linux Device Driver for * | |
8818 | * Fibre Channel Host Bus Adapters. * | |
8819 | - * Copyright (C) 2004-2006 Emulex. All rights reserved. * | |
8820 | + * Copyright (C) 2004-2008 Emulex. All rights reserved. * | |
8821 | * EMULEX and SLI are trademarks of Emulex. * | |
8822 | * www.emulex.com * | |
8823 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | |
8824 | @@ -30,6 +30,7 @@ | |
8825 | ||
8826 | #include "lpfc_hw.h" | |
8827 | #include "lpfc_sli.h" | |
8828 | +#include "lpfc_nl.h" | |
8829 | #include "lpfc_disc.h" | |
8830 | #include "lpfc_scsi.h" | |
8831 | #include "lpfc.h" | |
8832 | @@ -39,7 +40,21 @@ | |
8833 | #define LPFC_MEM_POOL_SIZE 64 /* max elem in non-DMA safety pool */ | |
8834 | ||
8835 | ||
8836 | - | |
8837 | +/** | |
8838 | + * lpfc_mem_alloc: create and allocate all PCI and memory pools | |
8839 | + * @phba: HBA to allocate pools for | |
8840 | + * | |
8841 | + * Description: Creates and allocates PCI pools lpfc_scsi_dma_buf_pool, | |
8842 | + * lpfc_mbuf_pool, lpfc_hbq_pool. Creates and allocates kmalloc-backed mempools | |
8843 | + * for LPFC_MBOXQ_t and lpfc_nodelist. Also allocates the VPI bitmask. | |
8844 | + * | |
8845 | + * Notes: Not interrupt-safe. Must be called with no locks held. If any | |
8846 | + * allocation fails, frees all successfully allocated memory before returning. | |
8847 | + * | |
8848 | + * Returns: | |
8849 | + * 0 on success | |
8850 | + * -ENOMEM on failure (if any memory allocations fail) | |
8851 | + **/ | |
8852 | int | |
8853 | lpfc_mem_alloc(struct lpfc_hba * phba) | |
8854 | { | |
8855 | @@ -120,6 +135,16 @@ lpfc_mem_alloc(struct lpfc_hba * phba) | |
8856 | return -ENOMEM; | |
8857 | } | |
8858 | ||
8859 | +/** | |
8860 | + * lpfc_mem_free: Frees all PCI and memory allocated by lpfc_mem_alloc | |
8861 | + * @phba: HBA to free memory for | |
8862 | + * | |
8863 | + * Description: Frees PCI pools lpfc_scsi_dma_buf_pool, lpfc_mbuf_pool, | |
8864 | + * lpfc_hbq_pool. Frees kmalloc-backed mempools for LPFC_MBOXQ_t and | |
8865 | + * lpfc_nodelist. Also frees the VPI bitmask. | |
8866 | + * | |
8867 | + * Returns: None | |
8868 | + **/ | |
8869 | void | |
8870 | lpfc_mem_free(struct lpfc_hba * phba) | |
8871 | { | |
8872 | @@ -181,12 +206,29 @@ lpfc_mem_free(struct lpfc_hba * phba) | |
8873 | phba->lpfc_scsi_dma_buf_pool = NULL; | |
8874 | phba->lpfc_mbuf_pool = NULL; | |
8875 | ||
8876 | - /* Free the iocb lookup array */ | |
8877 | + /* Free the iocb lookup array */ | |
8878 | kfree(psli->iocbq_lookup); | |
8879 | psli->iocbq_lookup = NULL; | |
8880 | - | |
8881 | } | |
8882 | ||
8883 | +/** | |
8884 | + * lpfc_mbuf_alloc: Allocate an mbuf from the lpfc_mbuf_pool PCI pool | |
8885 | + * @phba: HBA which owns the pool to allocate from | |
8886 | + * @mem_flags: indicates if this is a priority (MEM_PRI) allocation | |
8887 | + * @handle: used to return the DMA-mapped address of the mbuf | |
8888 | + * | |
8889 | + * Description: Allocates a DMA-mapped buffer from the lpfc_mbuf_pool PCI pool. | |
8890 | + * Allocates from generic pci_pool_alloc function first and if that fails and | |
8891 | + * mem_flags has MEM_PRI set (the only defined flag), returns an mbuf from the | |
8892 | + * HBA's pool. | |
8893 | + * | |
8894 | + * Notes: Not interrupt-safe. Must be called with no locks held. Takes | |
8895 | + * phba->hbalock. | |
8896 | + * | |
8897 | + * Returns: | |
8898 | + * pointer to the allocated mbuf on success | |
8899 | + * NULL on failure | |
8900 | + **/ | |
8901 | void * | |
8902 | lpfc_mbuf_alloc(struct lpfc_hba *phba, int mem_flags, dma_addr_t *handle) | |
8903 | { | |
8904 | @@ -206,6 +248,20 @@ lpfc_mbuf_alloc(struct lpfc_hba *phba, i | |
8905 | return ret; | |
8906 | } | |
8907 | ||
8908 | +/** | |
8909 | + * __lpfc_mem_free: Free an mbuf from the lpfc_mbuf_pool PCI pool (locked) | |
8910 | + * @phba: HBA which owns the pool to return to | |
8911 | + * @virt: mbuf to free | |
8912 | + * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed | |
8913 | + * | |
8914 | + * Description: Returns an mbuf lpfc_mbuf_pool to the lpfc_mbuf_safety_pool if | |
8915 | + * it is below its max_count, frees the mbuf otherwise. | |
8916 | + * | |
8917 | + * Notes: Must be called with phba->hbalock held to synchronize access to | |
8918 | + * lpfc_mbuf_safety_pool. | |
8919 | + * | |
8920 | + * Returns: None | |
8921 | + **/ | |
8922 | void | |
8923 | __lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | |
8924 | { | |
8925 | @@ -221,7 +277,21 @@ __lpfc_mbuf_free(struct lpfc_hba * phba, | |
8926 | return; | |
8927 | } | |
8928 | ||
8929 | +/** | |
8930 | + * lpfc_mem_free: Free an mbuf from the lpfc_mbuf_pool PCI pool (unlocked) | |
8931 | + * @phba: HBA which owns the pool to return to | |
8932 | + * @virt: mbuf to free | |
8933 | + * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed | |
8934 | + * | |
8935 | + * Description: Returns an mbuf lpfc_mbuf_pool to the lpfc_mbuf_safety_pool if | |
8936 | + * it is below its max_count, frees the mbuf otherwise. | |
8937 | + * | |
8938 | + * Notes: Takes phba->hbalock. Can be called with or without other locks held. | |
8939 | + * | |
8940 | + * Returns: None | |
8941 | + **/ | |
8942 | void | |
8943 | + | |
8944 | lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | |
8945 | { | |
8946 | unsigned long iflags; | |
8947 | @@ -232,6 +302,19 @@ lpfc_mbuf_free(struct lpfc_hba * phba, v | |
8948 | return; | |
8949 | } | |
8950 | ||
8951 | +/** | |
8952 | + * lpfc_els_hbq_alloc: Allocate an HBQ buffer | |
8953 | + * @phba: HBA to allocate HBQ buffer for | |
8954 | + * | |
8955 | + * Description: Allocates a DMA-mapped HBQ buffer from the lpfc_hbq_pool PCI | |
8956 | + * pool along a non-DMA-mapped container for it. | |
8957 | + * | |
8958 | + * Notes: Not interrupt-safe. Must be called with no locks held. | |
8959 | + * | |
8960 | + * Returns: | |
8961 | + * pointer to HBQ on success | |
8962 | + * NULL on failure | |
8963 | + **/ | |
8964 | struct hbq_dmabuf * | |
8965 | lpfc_els_hbq_alloc(struct lpfc_hba *phba) | |
8966 | { | |
8967 | @@ -251,6 +334,18 @@ lpfc_els_hbq_alloc(struct lpfc_hba *phba | |
8968 | return hbqbp; | |
8969 | } | |
8970 | ||
8971 | +/** | |
8972 | + * lpfc_mem_hbq_free: Frees an HBQ buffer allocated with lpfc_els_hbq_alloc | |
8973 | + * @phba: HBA buffer was allocated for | |
8974 | + * @hbqbp: HBQ container returned by lpfc_els_hbq_alloc | |
8975 | + * | |
8976 | + * Description: Frees both the container and the DMA-mapped buffer returned by | |
8977 | + * lpfc_els_hbq_alloc. | |
8978 | + * | |
8979 | + * Notes: Can be called with or without locks held. | |
8980 | + * | |
8981 | + * Returns: None | |
8982 | + **/ | |
8983 | void | |
8984 | lpfc_els_hbq_free(struct lpfc_hba *phba, struct hbq_dmabuf *hbqbp) | |
8985 | { | |
8986 | @@ -259,7 +354,18 @@ lpfc_els_hbq_free(struct lpfc_hba *phba, | |
8987 | return; | |
8988 | } | |
8989 | ||
8990 | -/* This is ONLY called for the LPFC_ELS_HBQ */ | |
8991 | +/** | |
8992 | + * lpfc_in_buf_free: Free a DMA buffer | |
8993 | + * @phba: HBA buffer is associated with | |
8994 | + * @mp: Buffer to free | |
8995 | + * | |
8996 | + * Description: Frees the given DMA buffer in the appropriate way given if the | |
8997 | + * HBA is running in SLI3 mode with HBQs enabled. | |
8998 | + * | |
8999 | + * Notes: Takes phba->hbalock. Can be called with or without other locks held. | |
9000 | + * | |
9001 | + * Returns: None | |
9002 | + **/ | |
9003 | void | |
9004 | lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp) | |
9005 | { | |
9006 | --- /dev/null | |
9007 | +++ b/drivers/scsi/lpfc/lpfc_nl.h | |
9008 | @@ -0,0 +1,163 @@ | |
9009 | +/******************************************************************* | |
9010 | + * This file is part of the Emulex Linux Device Driver for * | |
9011 | + * Fibre Channel Host Bus Adapters. * | |
9012 | + * Copyright (C) 2008 Emulex. All rights reserved. * | |
9013 | + * EMULEX and SLI are trademarks of Emulex. * | |
9014 | + * www.emulex.com * | |
9015 | + * * | |
9016 | + * This program is free software; you can redistribute it and/or * | |
9017 | + * modify it under the terms of version 2 of the GNU General * | |
9018 | + * Public License as published by the Free Software Foundation. * | |
9019 | + * This program is distributed in the hope that it will be useful. * | |
9020 | + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * | |
9021 | + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * | |
9022 | + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * | |
9023 | + * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * | |
9024 | + * TO BE LEGALLY INVALID. See the GNU General Public License for * | |
9025 | + * more details, a copy of which can be found in the file COPYING * | |
9026 | + * included with this package. * | |
9027 | + *******************************************************************/ | |
9028 | + | |
9029 | +/* Event definitions for RegisterForEvent */ | |
9030 | +#define FC_REG_LINK_EVENT 0x0001 /* link up / down events */ | |
9031 | +#define FC_REG_RSCN_EVENT 0x0002 /* RSCN events */ | |
9032 | +#define FC_REG_CT_EVENT 0x0004 /* CT request events */ | |
9033 | +#define FC_REG_DUMP_EVENT 0x0008 /* Dump events */ | |
9034 | +#define FC_REG_TEMPERATURE_EVENT 0x0010 /* temperature events */ | |
9035 | +#define FC_REG_ELS_EVENT 0x0020 /* lpfc els events */ | |
9036 | +#define FC_REG_FABRIC_EVENT 0x0040 /* lpfc fabric events */ | |
9037 | +#define FC_REG_SCSI_EVENT 0x0080 /* lpfc scsi events */ | |
9038 | +#define FC_REG_BOARD_EVENT 0x0100 /* lpfc board events */ | |
9039 | +#define FC_REG_ADAPTER_EVENT 0x0200 /* lpfc adapter events */ | |
9040 | +#define FC_REG_EVENT_MASK (FC_REG_LINK_EVENT | \ | |
9041 | + FC_REG_RSCN_EVENT | \ | |
9042 | + FC_REG_CT_EVENT | \ | |
9043 | + FC_REG_DUMP_EVENT | \ | |
9044 | + FC_REG_TEMPERATURE_EVENT | \ | |
9045 | + FC_REG_ELS_EVENT | \ | |
9046 | + FC_REG_FABRIC_EVENT | \ | |
9047 | + FC_REG_SCSI_EVENT | \ | |
9048 | + FC_REG_BOARD_EVENT | \ | |
9049 | + FC_REG_ADAPTER_EVENT) | |
9050 | +/* Temperature events */ | |
9051 | +#define LPFC_CRIT_TEMP 0x1 | |
9052 | +#define LPFC_THRESHOLD_TEMP 0x2 | |
9053 | +#define LPFC_NORMAL_TEMP 0x3 | |
9054 | +/* | |
9055 | + * All net link event payloads will begin with and event type | |
9056 | + * and subcategory. The event type must come first. | |
9057 | + * The subcategory further defines the data that follows in the rest | |
9058 | + * of the payload. Each category will have its own unique header plus | |
9059 | + * any addtional data unique to the subcategory. | |
9060 | + * The payload sent via the fc transport is one-way driver->application. | |
9061 | + */ | |
9062 | + | |
9063 | +/* els event header */ | |
9064 | +struct lpfc_els_event_header { | |
9065 | + uint32_t event_type; | |
9066 | + uint32_t subcategory; | |
9067 | + uint8_t wwpn[8]; | |
9068 | + uint8_t wwnn[8]; | |
9069 | +}; | |
9070 | + | |
9071 | +/* subcategory codes for FC_REG_ELS_EVENT */ | |
9072 | +#define LPFC_EVENT_PLOGI_RCV 0x01 | |
9073 | +#define LPFC_EVENT_PRLO_RCV 0x02 | |
9074 | +#define LPFC_EVENT_ADISC_RCV 0x04 | |
9075 | +#define LPFC_EVENT_LSRJT_RCV 0x08 | |
9076 | + | |
9077 | +/* special els lsrjt event */ | |
9078 | +struct lpfc_lsrjt_event { | |
9079 | + struct lpfc_els_event_header header; | |
9080 | + uint32_t command; | |
9081 | + uint32_t reason_code; | |
9082 | + uint32_t explanation; | |
9083 | +}; | |
9084 | + | |
9085 | + | |
9086 | +/* fabric event header */ | |
9087 | +struct lpfc_fabric_event_header { | |
9088 | + uint32_t event_type; | |
9089 | + uint32_t subcategory; | |
9090 | + uint8_t wwpn[8]; | |
9091 | + uint8_t wwnn[8]; | |
9092 | +}; | |
9093 | + | |
9094 | +/* subcategory codes for FC_REG_FABRIC_EVENT */ | |
9095 | +#define LPFC_EVENT_FABRIC_BUSY 0x01 | |
9096 | +#define LPFC_EVENT_PORT_BUSY 0x02 | |
9097 | +#define LPFC_EVENT_FCPRDCHKERR 0x04 | |
9098 | + | |
9099 | +/* special case fabric fcprdchkerr event */ | |
9100 | +struct lpfc_fcprdchkerr_event { | |
9101 | + struct lpfc_fabric_event_header header; | |
9102 | + uint32_t lun; | |
9103 | + uint32_t opcode; | |
9104 | + uint32_t fcpiparam; | |
9105 | +}; | |
9106 | + | |
9107 | + | |
9108 | +/* scsi event header */ | |
9109 | +struct lpfc_scsi_event_header { | |
9110 | + uint32_t event_type; | |
9111 | + uint32_t subcategory; | |
9112 | + uint32_t lun; | |
9113 | + uint8_t wwpn[8]; | |
9114 | + uint8_t wwnn[8]; | |
9115 | +}; | |
9116 | + | |
9117 | +/* subcategory codes for FC_REG_SCSI_EVENT */ | |
9118 | +#define LPFC_EVENT_QFULL 0x0001 | |
9119 | +#define LPFC_EVENT_DEVBSY 0x0002 | |
9120 | +#define LPFC_EVENT_CHECK_COND 0x0004 | |
9121 | +#define LPFC_EVENT_LUNRESET 0x0008 | |
9122 | +#define LPFC_EVENT_TGTRESET 0x0010 | |
9123 | +#define LPFC_EVENT_BUSRESET 0x0020 | |
9124 | +#define LPFC_EVENT_VARQUEDEPTH 0x0040 | |
9125 | + | |
9126 | +/* special case scsi varqueuedepth event */ | |
9127 | +struct lpfc_scsi_varqueuedepth_event { | |
9128 | + struct lpfc_scsi_event_header scsi_event; | |
9129 | + uint32_t oldval; | |
9130 | + uint32_t newval; | |
9131 | +}; | |
9132 | + | |
9133 | +/* special case scsi check condition event */ | |
9134 | +struct lpfc_scsi_check_condition_event { | |
9135 | + struct lpfc_scsi_event_header scsi_event; | |
9136 | + uint8_t sense_key; | |
9137 | + uint8_t asc; | |
9138 | + uint8_t ascq; | |
9139 | +}; | |
9140 | + | |
9141 | +/* event codes for FC_REG_BOARD_EVENT */ | |
9142 | +#define LPFC_EVENT_PORTINTERR 0x01 | |
9143 | + | |
9144 | +/* board event header */ | |
9145 | +struct lpfc_board_event_header { | |
9146 | + uint32_t event_type; | |
9147 | + uint32_t subcategory; | |
9148 | +}; | |
9149 | + | |
9150 | + | |
9151 | +/* event codes for FC_REG_ADAPTER_EVENT */ | |
9152 | +#define LPFC_EVENT_ARRIVAL 0x01 | |
9153 | + | |
9154 | +/* adapter event header */ | |
9155 | +struct lpfc_adapter_event_header { | |
9156 | + uint32_t event_type; | |
9157 | + uint32_t subcategory; | |
9158 | +}; | |
9159 | + | |
9160 | + | |
9161 | +/* event codes for temp_event */ | |
9162 | +#define LPFC_CRIT_TEMP 0x1 | |
9163 | +#define LPFC_THRESHOLD_TEMP 0x2 | |
9164 | +#define LPFC_NORMAL_TEMP 0x3 | |
9165 | + | |
9166 | +struct temp_event { | |
9167 | + uint32_t event_type; | |
9168 | + uint32_t event_code; | |
9169 | + uint32_t data; | |
9170 | +}; | |
9171 | + | |
9172 | --- a/drivers/scsi/lpfc/lpfc_nportdisc.c | |
9173 | +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c | |
9174 | @@ -30,6 +30,7 @@ | |
9175 | ||
9176 | #include "lpfc_hw.h" | |
9177 | #include "lpfc_sli.h" | |
9178 | +#include "lpfc_nl.h" | |
9179 | #include "lpfc_disc.h" | |
9180 | #include "lpfc_scsi.h" | |
9181 | #include "lpfc.h" | |
9182 | @@ -1003,20 +1004,8 @@ lpfc_rcv_plogi_adisc_issue(struct lpfc_v | |
9183 | spin_lock_irq(shost->host_lock); | |
9184 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | |
9185 | spin_unlock_irq(shost->host_lock); | |
9186 | - | |
9187 | - if (vport->num_disc_nodes) { | |
9188 | + if (vport->num_disc_nodes) | |
9189 | lpfc_more_adisc(vport); | |
9190 | - if ((vport->num_disc_nodes == 0) && | |
9191 | - (vport->fc_npr_cnt)) | |
9192 | - lpfc_els_disc_plogi(vport); | |
9193 | - if (vport->num_disc_nodes == 0) { | |
9194 | - spin_lock_irq(shost->host_lock); | |
9195 | - vport->fc_flag &= ~FC_NDISC_ACTIVE; | |
9196 | - spin_unlock_irq(shost->host_lock); | |
9197 | - lpfc_can_disctmo(vport); | |
9198 | - lpfc_end_rscn(vport); | |
9199 | - } | |
9200 | - } | |
9201 | } | |
9202 | return ndlp->nlp_state; | |
9203 | } | |
9204 | @@ -1865,8 +1854,13 @@ static uint32_t | |
9205 | lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
9206 | void *arg, uint32_t evt) | |
9207 | { | |
9208 | + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | |
9209 | + if (ndlp->nlp_DID == Fabric_DID) { | |
9210 | + spin_lock_irq(shost->host_lock); | |
9211 | + vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); | |
9212 | + spin_unlock_irq(shost->host_lock); | |
9213 | + } | |
9214 | lpfc_unreg_rpi(vport, ndlp); | |
9215 | - /* This routine does nothing, just return the current state */ | |
9216 | return ndlp->nlp_state; | |
9217 | } | |
9218 | ||
9219 | @@ -2155,7 +2149,7 @@ lpfc_disc_state_machine(struct lpfc_vpor | |
9220 | lpfc_nlp_put(ndlp); | |
9221 | } else { | |
9222 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | |
9223 | - "0212 DSM out state %d on NPort free\n", rc); | |
9224 | + "0213 DSM out state %d on NPort free\n", rc); | |
9225 | ||
9226 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, | |
9227 | "DSM out: ste:%d did:x%x flg:x%x", | |
9228 | diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c | |
9229 | index a22bdf9..e1d5421 100644 | |
9230 | --- a/drivers/scsi/lpfc/lpfc_scsi.c | |
9231 | +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |
9232 | @@ -32,6 +32,7 @@ | |
9233 | #include "lpfc_version.h" | |
9234 | #include "lpfc_hw.h" | |
9235 | #include "lpfc_sli.h" | |
9236 | +#include "lpfc_nl.h" | |
9237 | #include "lpfc_disc.h" | |
9238 | #include "lpfc_scsi.h" | |
9239 | #include "lpfc.h" | |
9240 | @@ -42,6 +43,111 @@ | |
9241 | #define LPFC_RESET_WAIT 2 | |
9242 | #define LPFC_ABORT_WAIT 2 | |
9243 | ||
9244 | +/** | |
9245 | + * lpfc_update_stats: Update statistical data for the command completion. | |
9246 | + * @phba: Pointer to HBA object. | |
9247 | + * @lpfc_cmd: lpfc scsi command object pointer. | |
9248 | + * | |
9249 | + * This function is called when there is a command completion and this | |
9250 | + * function updates the statistical data for the command completion. | |
9251 | + **/ | |
9252 | +static void | |
9253 | +lpfc_update_stats(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |
9254 | +{ | |
9255 | + struct lpfc_rport_data *rdata = lpfc_cmd->rdata; | |
9256 | + struct lpfc_nodelist *pnode = rdata->pnode; | |
9257 | + struct scsi_cmnd *cmd = lpfc_cmd->pCmd; | |
9258 | + unsigned long flags; | |
9259 | + struct Scsi_Host *shost = cmd->device->host; | |
9260 | + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | |
9261 | + unsigned long latency; | |
9262 | + int i; | |
9263 | + | |
9264 | + if (cmd->result) | |
9265 | + return; | |
9266 | + | |
9267 | + spin_lock_irqsave(shost->host_lock, flags); | |
9268 | + if (!vport->stat_data_enabled || | |
9269 | + vport->stat_data_blocked || | |
9270 | + !pnode->lat_data || | |
9271 | + (phba->bucket_type == LPFC_NO_BUCKET)) { | |
9272 | + spin_unlock_irqrestore(shost->host_lock, flags); | |
9273 | + return; | |
9274 | + } | |
9275 | + latency = jiffies_to_msecs(jiffies - lpfc_cmd->start_time); | |
9276 | + | |
9277 | + if (phba->bucket_type == LPFC_LINEAR_BUCKET) { | |
9278 | + i = (latency + phba->bucket_step - 1 - phba->bucket_base)/ | |
9279 | + phba->bucket_step; | |
9280 | + if (i >= LPFC_MAX_BUCKET_COUNT) | |
9281 | + i = LPFC_MAX_BUCKET_COUNT; | |
9282 | + } else { | |
9283 | + for (i = 0; i < LPFC_MAX_BUCKET_COUNT-1; i++) | |
9284 | + if (latency <= (phba->bucket_base + | |
9285 | + ((1<<i)*phba->bucket_step))) | |
9286 | + break; | |
9287 | + } | |
9288 | + | |
9289 | + pnode->lat_data[i].cmd_count++; | |
9290 | + spin_unlock_irqrestore(shost->host_lock, flags); | |
9291 | +} | |
9292 | + | |
9293 | + | |
9294 | +/** | |
9295 | + * lpfc_send_sdev_queuedepth_change_event: Posts a queuedepth change | |
9296 | + * event. | |
9297 | + * @phba: Pointer to HBA context object. | |
9298 | + * @vport: Pointer to vport object. | |
9299 | + * @ndlp: Pointer to FC node associated with the target. | |
9300 | + * @lun: Lun number of the scsi device. | |
9301 | + * @old_val: Old value of the queue depth. | |
9302 | + * @new_val: New value of the queue depth. | |
9303 | + * | |
9304 | + * This function sends an event to the mgmt application indicating | |
9305 | + * there is a change in the scsi device queue depth. | |
9306 | + **/ | |
9307 | +static void | |
9308 | +lpfc_send_sdev_queuedepth_change_event(struct lpfc_hba *phba, | |
9309 | + struct lpfc_vport *vport, | |
9310 | + struct lpfc_nodelist *ndlp, | |
9311 | + uint32_t lun, | |
9312 | + uint32_t old_val, | |
9313 | + uint32_t new_val) | |
9314 | +{ | |
9315 | + struct lpfc_fast_path_event *fast_path_evt; | |
9316 | + unsigned long flags; | |
9317 | + | |
9318 | + fast_path_evt = lpfc_alloc_fast_evt(phba); | |
9319 | + if (!fast_path_evt) | |
9320 | + return; | |
9321 | + | |
9322 | + fast_path_evt->un.queue_depth_evt.scsi_event.event_type = | |
9323 | + FC_REG_SCSI_EVENT; | |
9324 | + fast_path_evt->un.queue_depth_evt.scsi_event.subcategory = | |
9325 | + LPFC_EVENT_VARQUEDEPTH; | |
9326 | + | |
9327 | + /* Report all luns with change in queue depth */ | |
9328 | + fast_path_evt->un.queue_depth_evt.scsi_event.lun = lun; | |
9329 | + if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { | |
9330 | + memcpy(&fast_path_evt->un.queue_depth_evt.scsi_event.wwpn, | |
9331 | + &ndlp->nlp_portname, sizeof(struct lpfc_name)); | |
9332 | + memcpy(&fast_path_evt->un.queue_depth_evt.scsi_event.wwnn, | |
9333 | + &ndlp->nlp_nodename, sizeof(struct lpfc_name)); | |
9334 | + } | |
9335 | + | |
9336 | + fast_path_evt->un.queue_depth_evt.oldval = old_val; | |
9337 | + fast_path_evt->un.queue_depth_evt.newval = new_val; | |
9338 | + fast_path_evt->vport = vport; | |
9339 | + | |
9340 | + fast_path_evt->work_evt.evt = LPFC_EVT_FASTPATH_MGMT_EVT; | |
9341 | + spin_lock_irqsave(&phba->hbalock, flags); | |
9342 | + list_add_tail(&fast_path_evt->work_evt.evt_listp, &phba->work_list); | |
9343 | + spin_unlock_irqrestore(&phba->hbalock, flags); | |
9344 | + lpfc_worker_wake_up(phba); | |
9345 | + | |
9346 | + return; | |
9347 | +} | |
9348 | + | |
9349 | /* | |
9350 | * This function is called with no lock held when there is a resource | |
9351 | * error in driver or in firmware. | |
9352 | @@ -117,9 +223,10 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) | |
9353 | struct lpfc_vport **vports; | |
9354 | struct Scsi_Host *shost; | |
9355 | struct scsi_device *sdev; | |
9356 | - unsigned long new_queue_depth; | |
9357 | + unsigned long new_queue_depth, old_queue_depth; | |
9358 | unsigned long num_rsrc_err, num_cmd_success; | |
9359 | int i; | |
9360 | + struct lpfc_rport_data *rdata; | |
9361 | ||
9362 | num_rsrc_err = atomic_read(&phba->num_rsrc_err); | |
9363 | num_cmd_success = atomic_read(&phba->num_cmd_success); | |
9364 | @@ -137,6 +244,7 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) | |
9365 | else | |
9366 | new_queue_depth = sdev->queue_depth - | |
9367 | new_queue_depth; | |
9368 | + old_queue_depth = sdev->queue_depth; | |
9369 | if (sdev->ordered_tags) | |
9370 | scsi_adjust_queue_depth(sdev, | |
9371 | MSG_ORDERED_TAG, | |
9372 | @@ -145,6 +253,13 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) | |
9373 | scsi_adjust_queue_depth(sdev, | |
9374 | MSG_SIMPLE_TAG, | |
9375 | new_queue_depth); | |
9376 | + rdata = sdev->hostdata; | |
9377 | + if (rdata) | |
9378 | + lpfc_send_sdev_queuedepth_change_event( | |
9379 | + phba, vports[i], | |
9380 | + rdata->pnode, | |
9381 | + sdev->lun, old_queue_depth, | |
9382 | + new_queue_depth); | |
9383 | } | |
9384 | } | |
9385 | lpfc_destroy_vport_work_array(phba, vports); | |
9386 | @@ -159,6 +274,7 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba) | |
9387 | struct Scsi_Host *shost; | |
9388 | struct scsi_device *sdev; | |
9389 | int i; | |
9390 | + struct lpfc_rport_data *rdata; | |
9391 | ||
9392 | vports = lpfc_create_vport_work_array(phba); | |
9393 | if (vports != NULL) | |
9394 | @@ -176,6 +292,14 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba) | |
9395 | scsi_adjust_queue_depth(sdev, | |
9396 | MSG_SIMPLE_TAG, | |
9397 | sdev->queue_depth+1); | |
9398 | + rdata = sdev->hostdata; | |
9399 | + if (rdata) | |
9400 | + lpfc_send_sdev_queuedepth_change_event( | |
9401 | + phba, vports[i], | |
9402 | + rdata->pnode, | |
9403 | + sdev->lun, | |
9404 | + sdev->queue_depth - 1, | |
9405 | + sdev->queue_depth); | |
9406 | } | |
9407 | } | |
9408 | lpfc_destroy_vport_work_array(phba, vports); | |
9409 | @@ -183,6 +307,35 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba) | |
9410 | atomic_set(&phba->num_cmd_success, 0); | |
9411 | } | |
9412 | ||
9413 | +/** | |
9414 | + * lpfc_scsi_dev_block: set all scsi hosts to block state. | |
9415 | + * @phba: Pointer to HBA context object. | |
9416 | + * | |
9417 | + * This function walks vport list and set each SCSI host to block state | |
9418 | + * by invoking fc_remote_port_delete() routine. This function is invoked | |
9419 | + * with EEH when device's PCI slot has been permanently disabled. | |
9420 | + **/ | |
9421 | +void | |
9422 | +lpfc_scsi_dev_block(struct lpfc_hba *phba) | |
9423 | +{ | |
9424 | + struct lpfc_vport **vports; | |
9425 | + struct Scsi_Host *shost; | |
9426 | + struct scsi_device *sdev; | |
9427 | + struct fc_rport *rport; | |
9428 | + int i; | |
9429 | + | |
9430 | + vports = lpfc_create_vport_work_array(phba); | |
9431 | + if (vports != NULL) | |
9432 | + for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { | |
9433 | + shost = lpfc_shost_from_vport(vports[i]); | |
9434 | + shost_for_each_device(sdev, shost) { | |
9435 | + rport = starget_to_rport(scsi_target(sdev)); | |
9436 | + fc_remote_port_delete(rport); | |
9437 | + } | |
9438 | + } | |
9439 | + lpfc_destroy_vport_work_array(phba, vports); | |
9440 | +} | |
9441 | + | |
9442 | /* | |
9443 | * This routine allocates a scsi buffer, which contains all the necessary | |
9444 | * information needed to initiate a SCSI I/O. The non-DMAable buffer region | |
9445 | @@ -198,7 +351,9 @@ lpfc_new_scsi_buf(struct lpfc_vport *vport) | |
9446 | struct lpfc_scsi_buf *psb; | |
9447 | struct ulp_bde64 *bpl; | |
9448 | IOCB_t *iocb; | |
9449 | - dma_addr_t pdma_phys; | |
9450 | + dma_addr_t pdma_phys_fcp_cmd; | |
9451 | + dma_addr_t pdma_phys_fcp_rsp; | |
9452 | + dma_addr_t pdma_phys_bpl; | |
9453 | uint16_t iotag; | |
9454 | ||
9455 | psb = kzalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL); | |
9456 | @@ -238,40 +393,60 @@ lpfc_new_scsi_buf(struct lpfc_vport *vport) | |
9457 | ||
9458 | /* Initialize local short-hand pointers. */ | |
9459 | bpl = psb->fcp_bpl; | |
9460 | - pdma_phys = psb->dma_handle; | |
9461 | + pdma_phys_fcp_cmd = psb->dma_handle; | |
9462 | + pdma_phys_fcp_rsp = psb->dma_handle + sizeof(struct fcp_cmnd); | |
9463 | + pdma_phys_bpl = psb->dma_handle + sizeof(struct fcp_cmnd) + | |
9464 | + sizeof(struct fcp_rsp); | |
9465 | ||
9466 | /* | |
9467 | * The first two bdes are the FCP_CMD and FCP_RSP. The balance are sg | |
9468 | * list bdes. Initialize the first two and leave the rest for | |
9469 | * queuecommand. | |
9470 | */ | |
9471 | - bpl->addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys)); | |
9472 | - bpl->addrLow = le32_to_cpu(putPaddrLow(pdma_phys)); | |
9473 | - bpl->tus.f.bdeSize = sizeof (struct fcp_cmnd); | |
9474 | - bpl->tus.f.bdeFlags = BUFF_USE_CMND; | |
9475 | - bpl->tus.w = le32_to_cpu(bpl->tus.w); | |
9476 | - bpl++; | |
9477 | + bpl[0].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_cmd)); | |
9478 | + bpl[0].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_cmd)); | |
9479 | + bpl[0].tus.f.bdeSize = sizeof(struct fcp_cmnd); | |
9480 | + bpl[0].tus.f.bdeFlags = BUFF_TYPE_BDE_64; | |
9481 | + bpl[0].tus.w = le32_to_cpu(bpl->tus.w); | |
9482 | ||
9483 | /* Setup the physical region for the FCP RSP */ | |
9484 | - pdma_phys += sizeof (struct fcp_cmnd); | |
9485 | - bpl->addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys)); | |
9486 | - bpl->addrLow = le32_to_cpu(putPaddrLow(pdma_phys)); | |
9487 | - bpl->tus.f.bdeSize = sizeof (struct fcp_rsp); | |
9488 | - bpl->tus.f.bdeFlags = (BUFF_USE_CMND | BUFF_USE_RCV); | |
9489 | - bpl->tus.w = le32_to_cpu(bpl->tus.w); | |
9490 | + bpl[1].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_rsp)); | |
9491 | + bpl[1].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_rsp)); | |
9492 | + bpl[1].tus.f.bdeSize = sizeof(struct fcp_rsp); | |
9493 | + bpl[1].tus.f.bdeFlags = BUFF_TYPE_BDE_64; | |
9494 | + bpl[1].tus.w = le32_to_cpu(bpl->tus.w); | |
9495 | ||
9496 | /* | |
9497 | * Since the IOCB for the FCP I/O is built into this lpfc_scsi_buf, | |
9498 | * initialize it with all known data now. | |
9499 | */ | |
9500 | - pdma_phys += (sizeof (struct fcp_rsp)); | |
9501 | iocb = &psb->cur_iocbq.iocb; | |
9502 | iocb->un.fcpi64.bdl.ulpIoTag32 = 0; | |
9503 | - iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys); | |
9504 | - iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys); | |
9505 | - iocb->un.fcpi64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64)); | |
9506 | - iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDL; | |
9507 | - iocb->ulpBdeCount = 1; | |
9508 | + if (phba->sli_rev == 3) { | |
9509 | + /* fill in immediate fcp command BDE */ | |
9510 | + iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDE_IMMED; | |
9511 | + iocb->un.fcpi64.bdl.bdeSize = sizeof(struct fcp_cmnd); | |
9512 | + iocb->un.fcpi64.bdl.addrLow = offsetof(IOCB_t, | |
9513 | + unsli3.fcp_ext.icd); | |
9514 | + iocb->un.fcpi64.bdl.addrHigh = 0; | |
9515 | + iocb->ulpBdeCount = 0; | |
9516 | + iocb->ulpLe = 0; | |
9517 | + /* fill in responce BDE */ | |
9518 | + iocb->unsli3.fcp_ext.rbde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; | |
9519 | + iocb->unsli3.fcp_ext.rbde.tus.f.bdeSize = | |
9520 | + sizeof(struct fcp_rsp); | |
9521 | + iocb->unsli3.fcp_ext.rbde.addrLow = | |
9522 | + putPaddrLow(pdma_phys_fcp_rsp); | |
9523 | + iocb->unsli3.fcp_ext.rbde.addrHigh = | |
9524 | + putPaddrHigh(pdma_phys_fcp_rsp); | |
9525 | + } else { | |
9526 | + iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BLP_64; | |
9527 | + iocb->un.fcpi64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64)); | |
9528 | + iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys_bpl); | |
9529 | + iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys_bpl); | |
9530 | + iocb->ulpBdeCount = 1; | |
9531 | + iocb->ulpLe = 1; | |
9532 | + } | |
9533 | iocb->ulpClass = CLASS3; | |
9534 | ||
9535 | return psb; | |
9536 | @@ -313,8 +488,9 @@ lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |
9537 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; | |
9538 | struct ulp_bde64 *bpl = lpfc_cmd->fcp_bpl; | |
9539 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; | |
9540 | + struct ulp_bde64 *data_bde = iocb_cmd->unsli3.fcp_ext.dbde; | |
9541 | dma_addr_t physaddr; | |
9542 | - uint32_t i, num_bde = 0; | |
9543 | + uint32_t num_bde = 0; | |
9544 | int nseg, datadir = scsi_cmnd->sc_data_direction; | |
9545 | ||
9546 | /* | |
9547 | @@ -352,37 +528,159 @@ lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |
9548 | * during probe that limits the number of sg elements in any | |
9549 | * single scsi command. Just run through the seg_cnt and format | |
9550 | * the bde's. | |
9551 | + * When using SLI-3 the driver will try to fit all the BDEs into | |
9552 | + * the IOCB. If it can't then the BDEs get added to a BPL as it | |
9553 | + * does for SLI-2 mode. | |
9554 | */ | |
9555 | - scsi_for_each_sg(scsi_cmnd, sgel, nseg, i) { | |
9556 | + scsi_for_each_sg(scsi_cmnd, sgel, nseg, num_bde) { | |
9557 | physaddr = sg_dma_address(sgel); | |
9558 | - bpl->addrLow = le32_to_cpu(putPaddrLow(physaddr)); | |
9559 | - bpl->addrHigh = le32_to_cpu(putPaddrHigh(physaddr)); | |
9560 | - bpl->tus.f.bdeSize = sg_dma_len(sgel); | |
9561 | - if (datadir == DMA_TO_DEVICE) | |
9562 | - bpl->tus.f.bdeFlags = 0; | |
9563 | - else | |
9564 | - bpl->tus.f.bdeFlags = BUFF_USE_RCV; | |
9565 | - bpl->tus.w = le32_to_cpu(bpl->tus.w); | |
9566 | - bpl++; | |
9567 | - num_bde++; | |
9568 | + if (phba->sli_rev == 3 && | |
9569 | + nseg <= LPFC_EXT_DATA_BDE_COUNT) { | |
9570 | + data_bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64; | |
9571 | + data_bde->tus.f.bdeSize = sg_dma_len(sgel); | |
9572 | + data_bde->addrLow = putPaddrLow(physaddr); | |
9573 | + data_bde->addrHigh = putPaddrHigh(physaddr); | |
9574 | + data_bde++; | |
9575 | + } else { | |
9576 | + bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64; | |
9577 | + bpl->tus.f.bdeSize = sg_dma_len(sgel); | |
9578 | + bpl->tus.w = le32_to_cpu(bpl->tus.w); | |
9579 | + bpl->addrLow = | |
9580 | + le32_to_cpu(putPaddrLow(physaddr)); | |
9581 | + bpl->addrHigh = | |
9582 | + le32_to_cpu(putPaddrHigh(physaddr)); | |
9583 | + bpl++; | |
9584 | + } | |
9585 | } | |
9586 | } | |
9587 | ||
9588 | /* | |
9589 | * Finish initializing those IOCB fields that are dependent on the | |
9590 | - * scsi_cmnd request_buffer. Note that the bdeSize is explicitly | |
9591 | - * reinitialized since all iocb memory resources are used many times | |
9592 | - * for transmit, receive, and continuation bpl's. | |
9593 | + * scsi_cmnd request_buffer. Note that for SLI-2 the bdeSize is | |
9594 | + * explicitly reinitialized and for SLI-3 the extended bde count is | |
9595 | + * explicitly reinitialized since all iocb memory resources are reused. | |
9596 | */ | |
9597 | - iocb_cmd->un.fcpi64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64)); | |
9598 | - iocb_cmd->un.fcpi64.bdl.bdeSize += | |
9599 | - (num_bde * sizeof (struct ulp_bde64)); | |
9600 | - iocb_cmd->ulpBdeCount = 1; | |
9601 | - iocb_cmd->ulpLe = 1; | |
9602 | + if (phba->sli_rev == 3) { | |
9603 | + if (num_bde > LPFC_EXT_DATA_BDE_COUNT) { | |
9604 | + /* | |
9605 | + * The extended IOCB format can only fit 3 BDE or a BPL. | |
9606 | + * This I/O has more than 3 BDE so the 1st data bde will | |
9607 | + * be a BPL that is filled in here. | |
9608 | + */ | |
9609 | + physaddr = lpfc_cmd->dma_handle; | |
9610 | + data_bde->tus.f.bdeFlags = BUFF_TYPE_BLP_64; | |
9611 | + data_bde->tus.f.bdeSize = (num_bde * | |
9612 | + sizeof(struct ulp_bde64)); | |
9613 | + physaddr += (sizeof(struct fcp_cmnd) + | |
9614 | + sizeof(struct fcp_rsp) + | |
9615 | + (2 * sizeof(struct ulp_bde64))); | |
9616 | + data_bde->addrHigh = putPaddrHigh(physaddr); | |
9617 | + data_bde->addrLow = putPaddrLow(physaddr); | |
9618 | + /* ebde count includes the responce bde and data bpl */ | |
9619 | + iocb_cmd->unsli3.fcp_ext.ebde_count = 2; | |
9620 | + } else { | |
9621 | + /* ebde count includes the responce bde and data bdes */ | |
9622 | + iocb_cmd->unsli3.fcp_ext.ebde_count = (num_bde + 1); | |
9623 | + } | |
9624 | + } else { | |
9625 | + iocb_cmd->un.fcpi64.bdl.bdeSize = | |
9626 | + ((num_bde + 2) * sizeof(struct ulp_bde64)); | |
9627 | + } | |
9628 | fcp_cmnd->fcpDl = cpu_to_be32(scsi_bufflen(scsi_cmnd)); | |
9629 | return 0; | |
9630 | } | |
9631 | ||
9632 | +/** | |
9633 | + * lpfc_send_scsi_error_event: Posts an event when there is SCSI error. | |
9634 | + * @phba: Pointer to hba context object. | |
9635 | + * @vport: Pointer to vport object. | |
9636 | + * @lpfc_cmd: Pointer to lpfc scsi command which reported the error. | |
9637 | + * @rsp_iocb: Pointer to response iocb object which reported error. | |
9638 | + * | |
9639 | + * This function posts an event when there is a SCSI command reporting | |
9640 | + * error from the scsi device. | |
9641 | + **/ | |
9642 | +static void | |
9643 | +lpfc_send_scsi_error_event(struct lpfc_hba *phba, struct lpfc_vport *vport, | |
9644 | + struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_iocbq *rsp_iocb) { | |
9645 | + struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; | |
9646 | + struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp; | |
9647 | + uint32_t resp_info = fcprsp->rspStatus2; | |
9648 | + uint32_t scsi_status = fcprsp->rspStatus3; | |
9649 | + uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm; | |
9650 | + struct lpfc_fast_path_event *fast_path_evt = NULL; | |
9651 | + struct lpfc_nodelist *pnode = lpfc_cmd->rdata->pnode; | |
9652 | + unsigned long flags; | |
9653 | + | |
9654 | + /* If there is queuefull or busy condition send a scsi event */ | |
9655 | + if ((cmnd->result == SAM_STAT_TASK_SET_FULL) || | |
9656 | + (cmnd->result == SAM_STAT_BUSY)) { | |
9657 | + fast_path_evt = lpfc_alloc_fast_evt(phba); | |
9658 | + if (!fast_path_evt) | |
9659 | + return; | |
9660 | + fast_path_evt->un.scsi_evt.event_type = | |
9661 | + FC_REG_SCSI_EVENT; | |
9662 | + fast_path_evt->un.scsi_evt.subcategory = | |
9663 | + (cmnd->result == SAM_STAT_TASK_SET_FULL) ? | |
9664 | + LPFC_EVENT_QFULL : LPFC_EVENT_DEVBSY; | |
9665 | + fast_path_evt->un.scsi_evt.lun = cmnd->device->lun; | |
9666 | + memcpy(&fast_path_evt->un.scsi_evt.wwpn, | |
9667 | + &pnode->nlp_portname, sizeof(struct lpfc_name)); | |
9668 | + memcpy(&fast_path_evt->un.scsi_evt.wwnn, | |
9669 | + &pnode->nlp_nodename, sizeof(struct lpfc_name)); | |
9670 | + } else if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen && | |
9671 | + ((cmnd->cmnd[0] == READ_10) || (cmnd->cmnd[0] == WRITE_10))) { | |
9672 | + fast_path_evt = lpfc_alloc_fast_evt(phba); | |
9673 | + if (!fast_path_evt) | |
9674 | + return; | |
9675 | + fast_path_evt->un.check_cond_evt.scsi_event.event_type = | |
9676 | + FC_REG_SCSI_EVENT; | |
9677 | + fast_path_evt->un.check_cond_evt.scsi_event.subcategory = | |
9678 | + LPFC_EVENT_CHECK_COND; | |
9679 | + fast_path_evt->un.check_cond_evt.scsi_event.lun = | |
9680 | + cmnd->device->lun; | |
9681 | + memcpy(&fast_path_evt->un.check_cond_evt.scsi_event.wwpn, | |
9682 | + &pnode->nlp_portname, sizeof(struct lpfc_name)); | |
9683 | + memcpy(&fast_path_evt->un.check_cond_evt.scsi_event.wwnn, | |
9684 | + &pnode->nlp_nodename, sizeof(struct lpfc_name)); | |
9685 | + fast_path_evt->un.check_cond_evt.sense_key = | |
9686 | + cmnd->sense_buffer[2] & 0xf; | |
9687 | + fast_path_evt->un.check_cond_evt.asc = cmnd->sense_buffer[12]; | |
9688 | + fast_path_evt->un.check_cond_evt.ascq = cmnd->sense_buffer[13]; | |
9689 | + } else if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) && | |
9690 | + fcpi_parm && | |
9691 | + ((be32_to_cpu(fcprsp->rspResId) != fcpi_parm) || | |
9692 | + ((scsi_status == SAM_STAT_GOOD) && | |
9693 | + !(resp_info & (RESID_UNDER | RESID_OVER))))) { | |
9694 | + /* | |
9695 | + * If status is good or resid does not match with fcp_param and | |
9696 | + * there is valid fcpi_parm, then there is a read_check error | |
9697 | + */ | |
9698 | + fast_path_evt = lpfc_alloc_fast_evt(phba); | |
9699 | + if (!fast_path_evt) | |
9700 | + return; | |
9701 | + fast_path_evt->un.read_check_error.header.event_type = | |
9702 | + FC_REG_FABRIC_EVENT; | |
9703 | + fast_path_evt->un.read_check_error.header.subcategory = | |
9704 | + LPFC_EVENT_FCPRDCHKERR; | |
9705 | + memcpy(&fast_path_evt->un.read_check_error.header.wwpn, | |
9706 | + &pnode->nlp_portname, sizeof(struct lpfc_name)); | |
9707 | + memcpy(&fast_path_evt->un.read_check_error.header.wwnn, | |
9708 | + &pnode->nlp_nodename, sizeof(struct lpfc_name)); | |
9709 | + fast_path_evt->un.read_check_error.lun = cmnd->device->lun; | |
9710 | + fast_path_evt->un.read_check_error.opcode = cmnd->cmnd[0]; | |
9711 | + fast_path_evt->un.read_check_error.fcpiparam = | |
9712 | + fcpi_parm; | |
9713 | + } else | |
9714 | + return; | |
9715 | + | |
9716 | + fast_path_evt->vport = vport; | |
9717 | + spin_lock_irqsave(&phba->hbalock, flags); | |
9718 | + list_add_tail(&fast_path_evt->work_evt.evt_listp, &phba->work_list); | |
9719 | + spin_unlock_irqrestore(&phba->hbalock, flags); | |
9720 | + lpfc_worker_wake_up(phba); | |
9721 | + return; | |
9722 | +} | |
9723 | static void | |
9724 | lpfc_scsi_unprep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) | |
9725 | { | |
9726 | @@ -411,6 +709,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | |
9727 | uint32_t rsplen = 0; | |
9728 | uint32_t logit = LOG_FCP | LOG_FCP_ERROR; | |
9729 | ||
9730 | + | |
9731 | /* | |
9732 | * If this is a task management command, there is no | |
9733 | * scsi packet associated with this lpfc_cmd. The driver | |
9734 | @@ -526,6 +825,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | |
9735 | ||
9736 | out: | |
9737 | cmnd->result = ScsiResult(host_status, scsi_status); | |
9738 | + lpfc_send_scsi_error_event(vport->phba, vport, lpfc_cmd, rsp_iocb); | |
9739 | } | |
9740 | ||
9741 | static void | |
9742 | @@ -542,9 +842,11 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |
9743 | struct scsi_device *sdev, *tmp_sdev; | |
9744 | int depth = 0; | |
9745 | unsigned long flags; | |
9746 | + struct lpfc_fast_path_event *fast_path_evt; | |
9747 | ||
9748 | lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; | |
9749 | lpfc_cmd->status = pIocbOut->iocb.ulpStatus; | |
9750 | + atomic_dec(&pnode->cmd_pending); | |
9751 | ||
9752 | if (lpfc_cmd->status) { | |
9753 | if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT && | |
9754 | @@ -570,12 +872,36 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |
9755 | break; | |
9756 | case IOSTAT_NPORT_BSY: | |
9757 | case IOSTAT_FABRIC_BSY: | |
9758 | - cmd->result = ScsiResult(DID_BUS_BUSY, 0); | |
9759 | + cmd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, 0); | |
9760 | + fast_path_evt = lpfc_alloc_fast_evt(phba); | |
9761 | + if (!fast_path_evt) | |
9762 | + break; | |
9763 | + fast_path_evt->un.fabric_evt.event_type = | |
9764 | + FC_REG_FABRIC_EVENT; | |
9765 | + fast_path_evt->un.fabric_evt.subcategory = | |
9766 | + (lpfc_cmd->status == IOSTAT_NPORT_BSY) ? | |
9767 | + LPFC_EVENT_PORT_BUSY : LPFC_EVENT_FABRIC_BUSY; | |
9768 | + if (pnode && NLP_CHK_NODE_ACT(pnode)) { | |
9769 | + memcpy(&fast_path_evt->un.fabric_evt.wwpn, | |
9770 | + &pnode->nlp_portname, | |
9771 | + sizeof(struct lpfc_name)); | |
9772 | + memcpy(&fast_path_evt->un.fabric_evt.wwnn, | |
9773 | + &pnode->nlp_nodename, | |
9774 | + sizeof(struct lpfc_name)); | |
9775 | + } | |
9776 | + fast_path_evt->vport = vport; | |
9777 | + fast_path_evt->work_evt.evt = | |
9778 | + LPFC_EVT_FASTPATH_MGMT_EVT; | |
9779 | + spin_lock_irqsave(&phba->hbalock, flags); | |
9780 | + list_add_tail(&fast_path_evt->work_evt.evt_listp, | |
9781 | + &phba->work_list); | |
9782 | + spin_unlock_irqrestore(&phba->hbalock, flags); | |
9783 | + lpfc_worker_wake_up(phba); | |
9784 | break; | |
9785 | case IOSTAT_LOCAL_REJECT: | |
9786 | - if (lpfc_cmd->result == RJT_UNAVAIL_PERM || | |
9787 | + if (lpfc_cmd->result == IOERR_INVALID_RPI || | |
9788 | lpfc_cmd->result == IOERR_NO_RESOURCES || | |
9789 | - lpfc_cmd->result == RJT_LOGIN_REQUIRED) { | |
9790 | + lpfc_cmd->result == IOERR_ABORT_REQUESTED) { | |
9791 | cmd->result = ScsiResult(DID_REQUEUE, 0); | |
9792 | break; | |
9793 | } /* else: fall through */ | |
9794 | @@ -586,7 +912,8 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |
9795 | ||
9796 | if (!pnode || !NLP_CHK_NODE_ACT(pnode) | |
9797 | || (pnode->nlp_state != NLP_STE_MAPPED_NODE)) | |
9798 | - cmd->result = ScsiResult(DID_BUS_BUSY, SAM_STAT_BUSY); | |
9799 | + cmd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, | |
9800 | + SAM_STAT_BUSY); | |
9801 | } else { | |
9802 | cmd->result = ScsiResult(DID_OK, 0); | |
9803 | } | |
9804 | @@ -602,8 +929,32 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |
9805 | scsi_get_resid(cmd)); | |
9806 | } | |
9807 | ||
9808 | + lpfc_update_stats(phba, lpfc_cmd); | |
9809 | result = cmd->result; | |
9810 | sdev = cmd->device; | |
9811 | + if (vport->cfg_max_scsicmpl_time && | |
9812 | + time_after(jiffies, lpfc_cmd->start_time + | |
9813 | + msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) { | |
9814 | + spin_lock_irqsave(sdev->host->host_lock, flags); | |
9815 | + if ((pnode->cmd_qdepth > atomic_read(&pnode->cmd_pending) && | |
9816 | + (atomic_read(&pnode->cmd_pending) > LPFC_MIN_TGT_QDEPTH) && | |
9817 | + ((cmd->cmnd[0] == READ_10) || (cmd->cmnd[0] == WRITE_10)))) | |
9818 | + pnode->cmd_qdepth = atomic_read(&pnode->cmd_pending); | |
9819 | + | |
9820 | + pnode->last_change_time = jiffies; | |
9821 | + spin_unlock_irqrestore(sdev->host->host_lock, flags); | |
9822 | + } else if ((pnode->cmd_qdepth < LPFC_MAX_TGT_QDEPTH) && | |
9823 | + time_after(jiffies, pnode->last_change_time + | |
9824 | + msecs_to_jiffies(LPFC_TGTQ_INTERVAL))) { | |
9825 | + spin_lock_irqsave(sdev->host->host_lock, flags); | |
9826 | + pnode->cmd_qdepth += pnode->cmd_qdepth * | |
9827 | + LPFC_TGTQ_RAMPUP_PCENT / 100; | |
9828 | + if (pnode->cmd_qdepth > LPFC_MAX_TGT_QDEPTH) | |
9829 | + pnode->cmd_qdepth = LPFC_MAX_TGT_QDEPTH; | |
9830 | + pnode->last_change_time = jiffies; | |
9831 | + spin_unlock_irqrestore(sdev->host->host_lock, flags); | |
9832 | + } | |
9833 | + | |
9834 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); | |
9835 | cmd->scsi_done(cmd); | |
9836 | ||
9837 | @@ -647,6 +998,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |
9838 | pnode->last_ramp_up_time = jiffies; | |
9839 | } | |
9840 | } | |
9841 | + lpfc_send_sdev_queuedepth_change_event(phba, vport, pnode, | |
9842 | + 0xFFFFFFFF, | |
9843 | + sdev->queue_depth - 1, sdev->queue_depth); | |
9844 | } | |
9845 | ||
9846 | /* | |
9847 | @@ -676,6 +1030,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |
9848 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, | |
9849 | "0711 detected queue full - lun queue " | |
9850 | "depth adjusted to %d.\n", depth); | |
9851 | + lpfc_send_sdev_queuedepth_change_event(phba, vport, | |
9852 | + pnode, 0xFFFFFFFF, | |
9853 | + depth+1, depth); | |
9854 | } | |
9855 | } | |
9856 | ||
9857 | @@ -692,6 +1049,24 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |
9858 | lpfc_release_scsi_buf(phba, lpfc_cmd); | |
9859 | } | |
9860 | ||
9861 | +/** | |
9862 | + * lpfc_fcpcmd_to_iocb - copy the fcp_cmd data into the IOCB. | |
9863 | + * @data: A pointer to the immediate command data portion of the IOCB. | |
9864 | + * @fcp_cmnd: The FCP Command that is provided by the SCSI layer. | |
9865 | + * | |
9866 | + * The routine copies the entire FCP command from @fcp_cmnd to @data while | |
9867 | + * byte swapping the data to big endian format for transmission on the wire. | |
9868 | + **/ | |
9869 | +static void | |
9870 | +lpfc_fcpcmd_to_iocb(uint8_t *data, struct fcp_cmnd *fcp_cmnd) | |
9871 | +{ | |
9872 | + int i, j; | |
9873 | + for (i = 0, j = 0; i < sizeof(struct fcp_cmnd); | |
9874 | + i += sizeof(uint32_t), j++) { | |
9875 | + ((uint32_t *)data)[j] = cpu_to_be32(((uint32_t *)fcp_cmnd)[j]); | |
9876 | + } | |
9877 | +} | |
9878 | + | |
9879 | static void | |
9880 | lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | |
9881 | struct lpfc_nodelist *pnode) | |
9882 | @@ -758,7 +1133,8 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | |
9883 | fcp_cmnd->fcpCntl3 = 0; | |
9884 | phba->fc4ControlRequests++; | |
9885 | } | |
9886 | - | |
9887 | + if (phba->sli_rev == 3) | |
9888 | + lpfc_fcpcmd_to_iocb(iocb_cmd->unsli3.fcp_ext.icd, fcp_cmnd); | |
9889 | /* | |
9890 | * Finish initializing those IOCB fields that are independent | |
9891 | * of the scsi_cmnd request_buffer | |
9892 | @@ -798,11 +1174,13 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport, | |
9893 | piocb = &piocbq->iocb; | |
9894 | ||
9895 | fcp_cmnd = lpfc_cmd->fcp_cmnd; | |
9896 | - int_to_scsilun(lun, &lpfc_cmd->fcp_cmnd->fcp_lun); | |
9897 | + /* Clear out any old data in the FCP command area */ | |
9898 | + memset(fcp_cmnd, 0, sizeof(struct fcp_cmnd)); | |
9899 | + int_to_scsilun(lun, &fcp_cmnd->fcp_lun); | |
9900 | fcp_cmnd->fcpCntl2 = task_mgmt_cmd; | |
9901 | - | |
9902 | + if (vport->phba->sli_rev == 3) | |
9903 | + lpfc_fcpcmd_to_iocb(piocb->unsli3.fcp_ext.icd, fcp_cmnd); | |
9904 | piocb->ulpCommand = CMD_FCP_ICMND64_CR; | |
9905 | - | |
9906 | piocb->ulpContext = ndlp->nlp_rpi; | |
9907 | if (ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) { | |
9908 | piocb->ulpFCP2Rcvy = 1; | |
9909 | @@ -966,8 +1344,13 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |
9910 | * Catch race where our node has transitioned, but the | |
9911 | * transport is still transitioning. | |
9912 | */ | |
9913 | - if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) | |
9914 | - goto out_target_busy; | |
9915 | + if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { | |
9916 | + cmnd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, 0); | |
9917 | + goto out_fail_command; | |
9918 | + } | |
9919 | + | |
9920 | + if (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) | |
9921 | + goto out_host_busy; | |
9922 | ||
9923 | lpfc_cmd = lpfc_get_scsi_buf(phba); | |
9924 | if (lpfc_cmd == NULL) { | |
9925 | @@ -986,6 +1370,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |
9926 | lpfc_cmd->pCmd = cmnd; | |
9927 | lpfc_cmd->rdata = rdata; | |
9928 | lpfc_cmd->timeout = 0; | |
9929 | + lpfc_cmd->start_time = jiffies; | |
9930 | cmnd->host_scribble = (unsigned char *)lpfc_cmd; | |
9931 | cmnd->scsi_done = done; | |
9932 | ||
9933 | @@ -995,6 +1380,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |
9934 | ||
9935 | lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp); | |
9936 | ||
9937 | + atomic_inc(&ndlp->cmd_pending); | |
9938 | err = lpfc_sli_issue_iocb(phba, &phba->sli.ring[psli->fcp_ring], | |
9939 | &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB); | |
9940 | if (err) | |
9941 | @@ -1009,12 +1395,11 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |
9942 | return 0; | |
9943 | ||
9944 | out_host_busy_free_buf: | |
9945 | + atomic_dec(&ndlp->cmd_pending); | |
9946 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); | |
9947 | lpfc_release_scsi_buf(phba, lpfc_cmd); | |
9948 | out_host_busy: | |
9949 | return SCSI_MLQUEUE_HOST_BUSY; | |
9950 | - out_target_busy: | |
9951 | - return SCSI_MLQUEUE_TARGET_BUSY; | |
9952 | ||
9953 | out_fail_command: | |
9954 | done(cmnd); | |
9955 | @@ -1146,6 +1531,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) | |
9956 | int ret = SUCCESS; | |
9957 | int status; | |
9958 | int cnt; | |
9959 | + struct lpfc_scsi_event_header scsi_event; | |
9960 | ||
9961 | lpfc_block_error_handler(cmnd); | |
9962 | /* | |
9963 | @@ -1164,6 +1550,19 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) | |
9964 | break; | |
9965 | pnode = rdata->pnode; | |
9966 | } | |
9967 | + | |
9968 | + scsi_event.event_type = FC_REG_SCSI_EVENT; | |
9969 | + scsi_event.subcategory = LPFC_EVENT_TGTRESET; | |
9970 | + scsi_event.lun = 0; | |
9971 | + memcpy(scsi_event.wwpn, &pnode->nlp_portname, sizeof(struct lpfc_name)); | |
9972 | + memcpy(scsi_event.wwnn, &pnode->nlp_nodename, sizeof(struct lpfc_name)); | |
9973 | + | |
9974 | + fc_host_post_vendor_event(shost, | |
9975 | + fc_get_event_number(), | |
9976 | + sizeof(scsi_event), | |
9977 | + (char *)&scsi_event, | |
9978 | + SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
9979 | + | |
9980 | if (!rdata || pnode->nlp_state != NLP_STE_MAPPED_NODE) { | |
9981 | lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, | |
9982 | "0721 LUN Reset rport " | |
9983 | @@ -1243,10 +1642,23 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) | |
9984 | struct lpfc_hba *phba = vport->phba; | |
9985 | struct lpfc_nodelist *ndlp = NULL; | |
9986 | int match; | |
9987 | - int ret = SUCCESS, status, i; | |
9988 | + int ret = SUCCESS, status = SUCCESS, i; | |
9989 | int cnt; | |
9990 | struct lpfc_scsi_buf * lpfc_cmd; | |
9991 | unsigned long later; | |
9992 | + struct lpfc_scsi_event_header scsi_event; | |
9993 | + | |
9994 | + scsi_event.event_type = FC_REG_SCSI_EVENT; | |
9995 | + scsi_event.subcategory = LPFC_EVENT_BUSRESET; | |
9996 | + scsi_event.lun = 0; | |
9997 | + memcpy(scsi_event.wwpn, &vport->fc_portname, sizeof(struct lpfc_name)); | |
9998 | + memcpy(scsi_event.wwnn, &vport->fc_nodename, sizeof(struct lpfc_name)); | |
9999 | + | |
10000 | + fc_host_post_vendor_event(shost, | |
10001 | + fc_get_event_number(), | |
10002 | + sizeof(scsi_event), | |
10003 | + (char *)&scsi_event, | |
10004 | + SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
10005 | ||
10006 | lpfc_block_error_handler(cmnd); | |
10007 | /* | |
10008 | --- a/drivers/scsi/lpfc/lpfc_scsi.h | |
10009 | +++ b/drivers/scsi/lpfc/lpfc_scsi.h | |
10010 | @@ -107,6 +107,10 @@ struct fcp_cmnd { | |
10011 | ||
10012 | }; | |
10013 | ||
10014 | +struct lpfc_scsicmd_bkt { | |
10015 | + uint32_t cmd_count; | |
10016 | +}; | |
10017 | + | |
10018 | struct lpfc_scsi_buf { | |
10019 | struct list_head list; | |
10020 | struct scsi_cmnd *pCmd; | |
10021 | @@ -139,6 +143,7 @@ struct lpfc_scsi_buf { | |
10022 | */ | |
10023 | struct lpfc_iocbq cur_iocbq; | |
10024 | wait_queue_head_t *waitq; | |
10025 | + unsigned long start_time; | |
10026 | }; | |
10027 | ||
10028 | #define LPFC_SCSI_DMA_EXT_SIZE 264 | |
10029 | --- a/drivers/scsi/lpfc/lpfc_sli.c | |
10030 | +++ b/drivers/scsi/lpfc/lpfc_sli.c | |
10031 | @@ -32,6 +32,7 @@ | |
10032 | ||
10033 | #include "lpfc_hw.h" | |
10034 | #include "lpfc_sli.h" | |
10035 | +#include "lpfc_nl.h" | |
10036 | #include "lpfc_disc.h" | |
10037 | #include "lpfc_scsi.h" | |
10038 | #include "lpfc.h" | |
10039 | @@ -66,10 +67,16 @@ typedef enum _lpfc_iocb_type { | |
10040 | LPFC_ABORT_IOCB | |
10041 | } lpfc_iocb_type; | |
10042 | ||
10043 | - /* SLI-2/SLI-3 provide different sized iocbs. Given a pointer | |
10044 | - * to the start of the ring, and the slot number of the | |
10045 | - * desired iocb entry, calc a pointer to that entry. | |
10046 | - */ | |
10047 | +/** | |
10048 | + * lpfc_cmd_iocb: Get next command iocb entry in the ring. | |
10049 | + * @phba: Pointer to HBA context object. | |
10050 | + * @pring: Pointer to driver SLI ring object. | |
10051 | + * | |
10052 | + * This function returns pointer to next command iocb entry | |
10053 | + * in the command ring. The caller must hold hbalock to prevent | |
10054 | + * other threads consume the next command iocb. | |
10055 | + * SLI-2/SLI-3 provide different sized iocbs. | |
10056 | + **/ | |
10057 | static inline IOCB_t * | |
10058 | lpfc_cmd_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
10059 | { | |
10060 | @@ -77,6 +84,16 @@ lpfc_cmd_iocb(struct lpfc_hba *phba, str | |
10061 | pring->cmdidx * phba->iocb_cmd_size); | |
10062 | } | |
10063 | ||
10064 | +/** | |
10065 | + * lpfc_resp_iocb: Get next response iocb entry in the ring. | |
10066 | + * @phba: Pointer to HBA context object. | |
10067 | + * @pring: Pointer to driver SLI ring object. | |
10068 | + * | |
10069 | + * This function returns pointer to next response iocb entry | |
10070 | + * in the response ring. The caller must hold hbalock to make sure | |
10071 | + * that no other thread consume the next response iocb. | |
10072 | + * SLI-2/SLI-3 provide different sized iocbs. | |
10073 | + **/ | |
10074 | static inline IOCB_t * | |
10075 | lpfc_resp_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
10076 | { | |
10077 | @@ -84,6 +101,15 @@ lpfc_resp_iocb(struct lpfc_hba *phba, st | |
10078 | pring->rspidx * phba->iocb_rsp_size); | |
10079 | } | |
10080 | ||
10081 | +/** | |
10082 | + * __lpfc_sli_get_iocbq: Allocates an iocb object from iocb pool. | |
10083 | + * @phba: Pointer to HBA context object. | |
10084 | + * | |
10085 | + * This function is called with hbalock held. This function | |
10086 | + * allocates a new driver iocb object from the iocb pool. If the | |
10087 | + * allocation is successful, it returns pointer to the newly | |
10088 | + * allocated iocb object else it returns NULL. | |
10089 | + **/ | |
10090 | static struct lpfc_iocbq * | |
10091 | __lpfc_sli_get_iocbq(struct lpfc_hba *phba) | |
10092 | { | |
10093 | @@ -94,6 +120,15 @@ __lpfc_sli_get_iocbq(struct lpfc_hba *ph | |
10094 | return iocbq; | |
10095 | } | |
10096 | ||
10097 | +/** | |
10098 | + * lpfc_sli_get_iocbq: Allocates an iocb object from iocb pool. | |
10099 | + * @phba: Pointer to HBA context object. | |
10100 | + * | |
10101 | + * This function is called with no lock held. This function | |
10102 | + * allocates a new driver iocb object from the iocb pool. If the | |
10103 | + * allocation is successful, it returns pointer to the newly | |
10104 | + * allocated iocb object else it returns NULL. | |
10105 | + **/ | |
10106 | struct lpfc_iocbq * | |
10107 | lpfc_sli_get_iocbq(struct lpfc_hba *phba) | |
10108 | { | |
10109 | @@ -106,6 +141,16 @@ lpfc_sli_get_iocbq(struct lpfc_hba *phba | |
10110 | return iocbq; | |
10111 | } | |
10112 | ||
10113 | +/** | |
10114 | + * __lpfc_sli_release_iocbq: Release iocb to the iocb pool. | |
10115 | + * @phba: Pointer to HBA context object. | |
10116 | + * @iocbq: Pointer to driver iocb object. | |
10117 | + * | |
10118 | + * This function is called with hbalock held to release driver | |
10119 | + * iocb object to the iocb pool. The iotag in the iocb object | |
10120 | + * does not change for each use of the iocb object. This function | |
10121 | + * clears all other fields of the iocb object when it is freed. | |
10122 | + **/ | |
10123 | static void | |
10124 | __lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |
10125 | { | |
10126 | @@ -118,6 +163,14 @@ __lpfc_sli_release_iocbq(struct lpfc_hba | |
10127 | list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); | |
10128 | } | |
10129 | ||
10130 | +/** | |
10131 | + * lpfc_sli_release_iocbq: Release iocb to the iocb pool. | |
10132 | + * @phba: Pointer to HBA context object. | |
10133 | + * @iocbq: Pointer to driver iocb object. | |
10134 | + * | |
10135 | + * This function is called with no lock held to release the iocb to | |
10136 | + * iocb pool. | |
10137 | + **/ | |
10138 | void | |
10139 | lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |
10140 | { | |
10141 | @@ -131,10 +184,21 @@ lpfc_sli_release_iocbq(struct lpfc_hba * | |
10142 | spin_unlock_irqrestore(&phba->hbalock, iflags); | |
10143 | } | |
10144 | ||
10145 | -/* | |
10146 | - * Translate the iocb command to an iocb command type used to decide the final | |
10147 | - * disposition of each completed IOCB. | |
10148 | - */ | |
10149 | +/** | |
10150 | + * lpfc_sli_iocb_cmd_type: Get the iocb type. | |
10151 | + * @iocb_cmnd : iocb command code. | |
10152 | + * | |
10153 | + * This function is called by ring event handler function to get the iocb type. | |
10154 | + * This function translates the iocb command to an iocb command type used to | |
10155 | + * decide the final disposition of each completed IOCB. | |
10156 | + * The function returns | |
10157 | + * LPFC_UNKNOWN_IOCB if it is an unsupported iocb | |
10158 | + * LPFC_SOL_IOCB if it is a solicited iocb completion | |
10159 | + * LPFC_ABORT_IOCB if it is an abort iocb | |
10160 | + * LPFC_UNSOL_IOCB if it is an unsolicited iocb | |
10161 | + * | |
10162 | + * The caller is not required to hold any lock. | |
10163 | + **/ | |
10164 | static lpfc_iocb_type | |
10165 | lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd) | |
10166 | { | |
10167 | @@ -230,6 +294,17 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd | |
10168 | return type; | |
10169 | } | |
10170 | ||
10171 | +/** | |
10172 | + * lpfc_sli_ring_map: Issue config_ring mbox for all rings. | |
10173 | + * @phba: Pointer to HBA context object. | |
10174 | + * | |
10175 | + * This function is called from SLI initialization code | |
10176 | + * to configure every ring of the HBA's SLI interface. The | |
10177 | + * caller is not required to hold any lock. This function issues | |
10178 | + * a config_ring mailbox command for each ring. | |
10179 | + * This function returns zero if successful else returns a negative | |
10180 | + * error code. | |
10181 | + **/ | |
10182 | static int | |
10183 | lpfc_sli_ring_map(struct lpfc_hba *phba) | |
10184 | { | |
10185 | @@ -262,6 +337,18 @@ lpfc_sli_ring_map(struct lpfc_hba *phba) | |
10186 | return ret; | |
10187 | } | |
10188 | ||
10189 | +/** | |
10190 | + * lpfc_sli_ringtxcmpl_put: Adds new iocb to the txcmplq. | |
10191 | + * @phba: Pointer to HBA context object. | |
10192 | + * @pring: Pointer to driver SLI ring object. | |
10193 | + * @piocb: Pointer to the driver iocb object. | |
10194 | + * | |
10195 | + * This function is called with hbalock held. The function adds the | |
10196 | + * new iocb to txcmplq of the given ring. This function always returns | |
10197 | + * 0. If this function is called for ELS ring, this function checks if | |
10198 | + * there is a vport associated with the ELS command. This function also | |
10199 | + * starts els_tmofunc timer if this is an ELS command. | |
10200 | + **/ | |
10201 | static int | |
10202 | lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
10203 | struct lpfc_iocbq *piocb) | |
10204 | @@ -282,6 +369,16 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba | |
10205 | return 0; | |
10206 | } | |
10207 | ||
10208 | +/** | |
10209 | + * lpfc_sli_ringtx_get: Get first element of the txq. | |
10210 | + * @phba: Pointer to HBA context object. | |
10211 | + * @pring: Pointer to driver SLI ring object. | |
10212 | + * | |
10213 | + * This function is called with hbalock held to get next | |
10214 | + * iocb in txq of the given ring. If there is any iocb in | |
10215 | + * the txq, the function returns first iocb in the list after | |
10216 | + * removing the iocb from the list, else it returns NULL. | |
10217 | + **/ | |
10218 | static struct lpfc_iocbq * | |
10219 | lpfc_sli_ringtx_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
10220 | { | |
10221 | @@ -293,14 +390,25 @@ lpfc_sli_ringtx_get(struct lpfc_hba *phb | |
10222 | return cmd_iocb; | |
10223 | } | |
10224 | ||
10225 | +/** | |
10226 | + * lpfc_sli_next_iocb_slot: Get next iocb slot in the ring. | |
10227 | + * @phba: Pointer to HBA context object. | |
10228 | + * @pring: Pointer to driver SLI ring object. | |
10229 | + * | |
10230 | + * This function is called with hbalock held and the caller must post the | |
10231 | + * iocb without releasing the lock. If the caller releases the lock, | |
10232 | + * iocb slot returned by the function is not guaranteed to be available. | |
10233 | + * The function returns pointer to the next available iocb slot if there | |
10234 | + * is available slot in the ring, else it returns NULL. | |
10235 | + * If the get index of the ring is ahead of the put index, the function | |
10236 | + * will post an error attention event to the worker thread to take the | |
10237 | + * HBA to offline state. | |
10238 | + **/ | |
10239 | static IOCB_t * | |
10240 | lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
10241 | { | |
10242 | - struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? | |
10243 | - &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | |
10244 | - &phba->slim2p->mbx.us.s2.port[pring->ringno]; | |
10245 | + struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; | |
10246 | uint32_t max_cmd_idx = pring->numCiocb; | |
10247 | - | |
10248 | if ((pring->next_cmdidx == pring->cmdidx) && | |
10249 | (++pring->next_cmdidx >= max_cmd_idx)) | |
10250 | pring->next_cmdidx = 0; | |
10251 | @@ -336,6 +444,18 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba | |
10252 | return lpfc_cmd_iocb(phba, pring); | |
10253 | } | |
10254 | ||
10255 | +/** | |
10256 | + * lpfc_sli_next_iotag: Get an iotag for the iocb. | |
10257 | + * @phba: Pointer to HBA context object. | |
10258 | + * @iocbq: Pointer to driver iocb object. | |
10259 | + * | |
10260 | + * This function gets an iotag for the iocb. If there is no unused iotag and | |
10261 | + * the iocbq_lookup_len < 0xffff, this function allocates a bigger iotag_lookup | |
10262 | + * array and assigns a new iotag. | |
10263 | + * The function returns the allocated iotag if successful, else returns zero. | |
10264 | + * Zero is not a valid iotag. | |
10265 | + * The caller is not required to hold any lock. | |
10266 | + **/ | |
10267 | uint16_t | |
10268 | lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |
10269 | { | |
10270 | @@ -399,6 +519,20 @@ lpfc_sli_next_iotag(struct lpfc_hba *phb | |
10271 | return 0; | |
10272 | } | |
10273 | ||
10274 | +/** | |
10275 | + * lpfc_sli_submit_iocb: Submit an iocb to the firmware. | |
10276 | + * @phba: Pointer to HBA context object. | |
10277 | + * @pring: Pointer to driver SLI ring object. | |
10278 | + * @iocb: Pointer to iocb slot in the ring. | |
10279 | + * @nextiocb: Pointer to driver iocb object which need to be | |
10280 | + * posted to firmware. | |
10281 | + * | |
10282 | + * This function is called with hbalock held to post a new iocb to | |
10283 | + * the firmware. This function copies the new iocb to ring iocb slot and | |
10284 | + * updates the ring pointers. It adds the new iocb to txcmplq if there is | |
10285 | + * a completion call back for this iocb else the function will free the | |
10286 | + * iocb object. | |
10287 | + **/ | |
10288 | static void | |
10289 | lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
10290 | IOCB_t *iocb, struct lpfc_iocbq *nextiocb) | |
10291 | @@ -441,6 +575,18 @@ lpfc_sli_submit_iocb(struct lpfc_hba *ph | |
10292 | writel(pring->cmdidx, &phba->host_gp[pring->ringno].cmdPutInx); | |
10293 | } | |
10294 | ||
10295 | +/** | |
10296 | + * lpfc_sli_update_full_ring: Update the chip attention register. | |
10297 | + * @phba: Pointer to HBA context object. | |
10298 | + * @pring: Pointer to driver SLI ring object. | |
10299 | + * | |
10300 | + * The caller is not required to hold any lock for calling this function. | |
10301 | + * This function updates the chip attention bits for the ring to inform firmware | |
10302 | + * that there are pending work to be done for this ring and requests an | |
10303 | + * interrupt when there is space available in the ring. This function is | |
10304 | + * called when the driver is unable to post more iocbs to the ring due | |
10305 | + * to unavailability of space in the ring. | |
10306 | + **/ | |
10307 | static void | |
10308 | lpfc_sli_update_full_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
10309 | { | |
10310 | @@ -460,6 +606,15 @@ lpfc_sli_update_full_ring(struct lpfc_hb | |
10311 | pring->stats.iocb_cmd_full++; | |
10312 | } | |
10313 | ||
10314 | +/** | |
10315 | + * lpfc_sli_update_ring: Update chip attention register. | |
10316 | + * @phba: Pointer to HBA context object. | |
10317 | + * @pring: Pointer to driver SLI ring object. | |
10318 | + * | |
10319 | + * This function updates the chip attention register bit for the | |
10320 | + * given ring to inform HBA that there is more work to be done | |
10321 | + * in this ring. The caller is not required to hold any lock. | |
10322 | + **/ | |
10323 | static void | |
10324 | lpfc_sli_update_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
10325 | { | |
10326 | @@ -468,11 +623,22 @@ lpfc_sli_update_ring(struct lpfc_hba *ph | |
10327 | /* | |
10328 | * Tell the HBA that there is work to do in this ring. | |
10329 | */ | |
10330 | - wmb(); | |
10331 | - writel(CA_R0ATT << (ringno * 4), phba->CAregaddr); | |
10332 | - readl(phba->CAregaddr); /* flush */ | |
10333 | + if (!(phba->sli3_options & LPFC_SLI3_CRP_ENABLED)) { | |
10334 | + wmb(); | |
10335 | + writel(CA_R0ATT << (ringno * 4), phba->CAregaddr); | |
10336 | + readl(phba->CAregaddr); /* flush */ | |
10337 | + } | |
10338 | } | |
10339 | ||
10340 | +/** | |
10341 | + * lpfc_sli_resume_iocb: Process iocbs in the txq. | |
10342 | + * @phba: Pointer to HBA context object. | |
10343 | + * @pring: Pointer to driver SLI ring object. | |
10344 | + * | |
10345 | + * This function is called with hbalock held to post pending iocbs | |
10346 | + * in the txq to the firmware. This function is called when driver | |
10347 | + * detects space available in the ring. | |
10348 | + **/ | |
10349 | static void | |
10350 | lpfc_sli_resume_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
10351 | { | |
10352 | @@ -504,6 +670,16 @@ lpfc_sli_resume_iocb(struct lpfc_hba *ph | |
10353 | return; | |
10354 | } | |
10355 | ||
10356 | +/** | |
10357 | + * lpfc_sli_next_hbq_slot: Get next hbq entry for the HBQ. | |
10358 | + * @phba: Pointer to HBA context object. | |
10359 | + * @hbqno: HBQ number. | |
10360 | + * | |
10361 | + * This function is called with hbalock held to get the next | |
10362 | + * available slot for the given HBQ. If there is free slot | |
10363 | + * available for the HBQ it will return pointer to the next available | |
10364 | + * HBQ entry else it will return NULL. | |
10365 | + **/ | |
10366 | static struct lpfc_hbq_entry * | |
10367 | lpfc_sli_next_hbq_slot(struct lpfc_hba *phba, uint32_t hbqno) | |
10368 | { | |
10369 | @@ -539,6 +715,15 @@ lpfc_sli_next_hbq_slot(struct lpfc_hba * | |
10370 | hbqp->hbqPutIdx; | |
10371 | } | |
10372 | ||
10373 | +/** | |
10374 | + * lpfc_sli_hbqbuf_free_all: Free all the hbq buffers. | |
10375 | + * @phba: Pointer to HBA context object. | |
10376 | + * | |
10377 | + * This function is called with no lock held to free all the | |
10378 | + * hbq buffers while uninitializing the SLI interface. It also | |
10379 | + * frees the HBQ buffers returned by the firmware but not yet | |
10380 | + * processed by the upper layers. | |
10381 | + **/ | |
10382 | void | |
10383 | lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba) | |
10384 | { | |
10385 | @@ -584,6 +769,18 @@ lpfc_sli_hbqbuf_free_all(struct lpfc_hba | |
10386 | spin_unlock_irqrestore(&phba->hbalock, flags); | |
10387 | } | |
10388 | ||
10389 | +/** | |
10390 | + * lpfc_sli_hbq_to_firmware: Post the hbq buffer to firmware. | |
10391 | + * @phba: Pointer to HBA context object. | |
10392 | + * @hbqno: HBQ number. | |
10393 | + * @hbq_buf: Pointer to HBQ buffer. | |
10394 | + * | |
10395 | + * This function is called with the hbalock held to post a | |
10396 | + * hbq buffer to the firmware. If the function finds an empty | |
10397 | + * slot in the HBQ, it will post the buffer. The function will return | |
10398 | + * pointer to the hbq entry if it successfully post the buffer | |
10399 | + * else it will return NULL. | |
10400 | + **/ | |
10401 | static struct lpfc_hbq_entry * | |
10402 | lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno, | |
10403 | struct hbq_dmabuf *hbq_buf) | |
10404 | @@ -612,6 +809,7 @@ lpfc_sli_hbq_to_firmware(struct lpfc_hba | |
10405 | return hbqe; | |
10406 | } | |
10407 | ||
10408 | +/* HBQ for ELS and CT traffic. */ | |
10409 | static struct lpfc_hbq_init lpfc_els_hbq = { | |
10410 | .rn = 1, | |
10411 | .entry_count = 200, | |
10412 | @@ -623,6 +821,7 @@ static struct lpfc_hbq_init lpfc_els_hbq | |
10413 | .add_count = 5, | |
10414 | }; | |
10415 | ||
10416 | +/* HBQ for the extra ring if needed */ | |
10417 | static struct lpfc_hbq_init lpfc_extra_hbq = { | |
10418 | .rn = 1, | |
10419 | .entry_count = 200, | |
10420 | @@ -634,51 +833,81 @@ static struct lpfc_hbq_init lpfc_extra_h | |
10421 | .add_count = 5, | |
10422 | }; | |
10423 | ||
10424 | +/* Array of HBQs */ | |
10425 | struct lpfc_hbq_init *lpfc_hbq_defs[] = { | |
10426 | &lpfc_els_hbq, | |
10427 | &lpfc_extra_hbq, | |
10428 | }; | |
10429 | ||
10430 | +/** | |
10431 | + * lpfc_sli_hbqbuf_fill_hbqs: Post more hbq buffers to HBQ. | |
10432 | + * @phba: Pointer to HBA context object. | |
10433 | + * @hbqno: HBQ number. | |
10434 | + * @count: Number of HBQ buffers to be posted. | |
10435 | + * | |
10436 | + * This function is called with no lock held to post more hbq buffers to the | |
10437 | + * given HBQ. The function returns the number of HBQ buffers successfully | |
10438 | + * posted. | |
10439 | + **/ | |
10440 | static int | |
10441 | lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) | |
10442 | { | |
10443 | - uint32_t i, start, end; | |
10444 | + uint32_t i, posted = 0; | |
10445 | unsigned long flags; | |
10446 | struct hbq_dmabuf *hbq_buffer; | |
10447 | - | |
10448 | + LIST_HEAD(hbq_buf_list); | |
10449 | if (!phba->hbqs[hbqno].hbq_alloc_buffer) | |
10450 | return 0; | |
10451 | ||
10452 | - start = phba->hbqs[hbqno].buffer_count; | |
10453 | - end = count + start; | |
10454 | - if (end > lpfc_hbq_defs[hbqno]->entry_count) | |
10455 | - end = lpfc_hbq_defs[hbqno]->entry_count; | |
10456 | - | |
10457 | + if ((phba->hbqs[hbqno].buffer_count + count) > | |
10458 | + lpfc_hbq_defs[hbqno]->entry_count) | |
10459 | + count = lpfc_hbq_defs[hbqno]->entry_count - | |
10460 | + phba->hbqs[hbqno].buffer_count; | |
10461 | + if (!count) | |
10462 | + return 0; | |
10463 | + /* Allocate HBQ entries */ | |
10464 | + for (i = 0; i < count; i++) { | |
10465 | + hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | |
10466 | + if (!hbq_buffer) | |
10467 | + break; | |
10468 | + list_add_tail(&hbq_buffer->dbuf.list, &hbq_buf_list); | |
10469 | + } | |
10470 | /* Check whether HBQ is still in use */ | |
10471 | spin_lock_irqsave(&phba->hbalock, flags); | |
10472 | if (!phba->hbq_in_use) | |
10473 | - goto out; | |
10474 | - | |
10475 | - /* Populate HBQ entries */ | |
10476 | - for (i = start; i < end; i++) { | |
10477 | - hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | |
10478 | - if (!hbq_buffer) | |
10479 | - goto err; | |
10480 | - hbq_buffer->tag = (i | (hbqno << 16)); | |
10481 | - if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer)) | |
10482 | + goto err; | |
10483 | + while (!list_empty(&hbq_buf_list)) { | |
10484 | + list_remove_head(&hbq_buf_list, hbq_buffer, struct hbq_dmabuf, | |
10485 | + dbuf.list); | |
10486 | + hbq_buffer->tag = (phba->hbqs[hbqno].buffer_count | | |
10487 | + (hbqno << 16)); | |
10488 | + if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer)) { | |
10489 | phba->hbqs[hbqno].buffer_count++; | |
10490 | - else | |
10491 | + posted++; | |
10492 | + } else | |
10493 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); | |
10494 | } | |
10495 | - | |
10496 | - out: | |
10497 | spin_unlock_irqrestore(&phba->hbalock, flags); | |
10498 | - return 0; | |
10499 | - err: | |
10500 | + return posted; | |
10501 | +err: | |
10502 | spin_unlock_irqrestore(&phba->hbalock, flags); | |
10503 | - return 1; | |
10504 | + while (!list_empty(&hbq_buf_list)) { | |
10505 | + list_remove_head(&hbq_buf_list, hbq_buffer, struct hbq_dmabuf, | |
10506 | + dbuf.list); | |
10507 | + (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); | |
10508 | + } | |
10509 | + return 0; | |
10510 | } | |
10511 | ||
10512 | +/** | |
10513 | + * lpfc_sli_hbqbuf_add_hbqs: Post more HBQ buffers to firmware. | |
10514 | + * @phba: Pointer to HBA context object. | |
10515 | + * @qno: HBQ number. | |
10516 | + * | |
10517 | + * This function posts more buffers to the HBQ. This function | |
10518 | + * is called with no lock held. The function returns the number of HBQ entries | |
10519 | + * successfully allocated. | |
10520 | + **/ | |
10521 | int | |
10522 | lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) | |
10523 | { | |
10524 | @@ -686,6 +915,15 @@ lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba | |
10525 | lpfc_hbq_defs[qno]->add_count)); | |
10526 | } | |
10527 | ||
10528 | +/** | |
10529 | + * lpfc_sli_hbqbuf_init_hbqs: Post initial buffers to the HBQ. | |
10530 | + * @phba: Pointer to HBA context object. | |
10531 | + * @qno: HBQ queue number. | |
10532 | + * | |
10533 | + * This function is called from SLI initialization code path with | |
10534 | + * no lock held to post initial HBQ buffers to firmware. The | |
10535 | + * function returns the number of HBQ entries successfully allocated. | |
10536 | + **/ | |
10537 | static int | |
10538 | lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) | |
10539 | { | |
10540 | @@ -693,6 +931,16 @@ lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hb | |
10541 | lpfc_hbq_defs[qno]->init_count)); | |
10542 | } | |
10543 | ||
10544 | +/** | |
10545 | + * lpfc_sli_hbqbuf_find: Find the hbq buffer associated with a tag. | |
10546 | + * @phba: Pointer to HBA context object. | |
10547 | + * @tag: Tag of the hbq buffer. | |
10548 | + * | |
10549 | + * This function is called with hbalock held. This function searches | |
10550 | + * for the hbq buffer associated with the given tag in the hbq buffer | |
10551 | + * list. If it finds the hbq buffer, it returns the hbq_buffer other wise | |
10552 | + * it returns NULL. | |
10553 | + **/ | |
10554 | static struct hbq_dmabuf * | |
10555 | lpfc_sli_hbqbuf_find(struct lpfc_hba *phba, uint32_t tag) | |
10556 | { | |
10557 | @@ -716,6 +964,15 @@ lpfc_sli_hbqbuf_find(struct lpfc_hba *ph | |
10558 | return NULL; | |
10559 | } | |
10560 | ||
10561 | +/** | |
10562 | + * lpfc_sli_free_hbq: Give back the hbq buffer to firmware. | |
10563 | + * @phba: Pointer to HBA context object. | |
10564 | + * @hbq_buffer: Pointer to HBQ buffer. | |
10565 | + * | |
10566 | + * This function is called with hbalock. This function gives back | |
10567 | + * the hbq buffer to firmware. If the HBQ does not have space to | |
10568 | + * post the buffer, it will free the buffer. | |
10569 | + **/ | |
10570 | void | |
10571 | lpfc_sli_free_hbq(struct lpfc_hba *phba, struct hbq_dmabuf *hbq_buffer) | |
10572 | { | |
10573 | @@ -729,6 +986,15 @@ lpfc_sli_free_hbq(struct lpfc_hba *phba, | |
10574 | } | |
10575 | } | |
10576 | ||
10577 | +/** | |
10578 | + * lpfc_sli_chk_mbx_command: Check if the mailbox is a legitimate mailbox. | |
10579 | + * @mbxCommand: mailbox command code. | |
10580 | + * | |
10581 | + * This function is called by the mailbox event handler function to verify | |
10582 | + * that the completed mailbox command is a legitimate mailbox command. If the | |
10583 | + * completed mailbox is not known to the function, it will return MBX_SHUTDOWN | |
10584 | + * and the mailbox event handler will take the HBA offline. | |
10585 | + **/ | |
10586 | static int | |
10587 | lpfc_sli_chk_mbx_command(uint8_t mbxCommand) | |
10588 | { | |
10589 | @@ -785,6 +1051,8 @@ lpfc_sli_chk_mbx_command(uint8_t mbxComm | |
10590 | case MBX_REG_VPI: | |
10591 | case MBX_UNREG_VPI: | |
10592 | case MBX_HEARTBEAT: | |
10593 | + case MBX_PORT_CAPABILITIES: | |
10594 | + case MBX_PORT_IOV_CONTROL: | |
10595 | ret = mbxCommand; | |
10596 | break; | |
10597 | default: | |
10598 | @@ -793,6 +1061,19 @@ lpfc_sli_chk_mbx_command(uint8_t mbxComm | |
10599 | } | |
10600 | return ret; | |
10601 | } | |
10602 | + | |
10603 | +/** | |
10604 | + * lpfc_sli_wake_mbox_wait: Completion handler for mbox issued from | |
10605 | + * lpfc_sli_issue_mbox_wait. | |
10606 | + * @phba: Pointer to HBA context object. | |
10607 | + * @pmboxq: Pointer to mailbox command. | |
10608 | + * | |
10609 | + * This is completion handler function for mailbox commands issued from | |
10610 | + * lpfc_sli_issue_mbox_wait function. This function is called by the | |
10611 | + * mailbox event handler function with no lock held. This function | |
10612 | + * will wake up thread waiting on the wait queue pointed by context1 | |
10613 | + * of the mailbox. | |
10614 | + **/ | |
10615 | static void | |
10616 | lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) | |
10617 | { | |
10618 | @@ -812,6 +1093,17 @@ lpfc_sli_wake_mbox_wait(struct lpfc_hba | |
10619 | return; | |
10620 | } | |
10621 | ||
10622 | + | |
10623 | +/** | |
10624 | + * lpfc_sli_def_mbox_cmpl: Default mailbox completion handler. | |
10625 | + * @phba: Pointer to HBA context object. | |
10626 | + * @pmb: Pointer to mailbox object. | |
10627 | + * | |
10628 | + * This function is the default mailbox completion handler. It | |
10629 | + * frees the memory resources associated with the completed mailbox | |
10630 | + * command. If the completed command is a REG_LOGIN mailbox command, | |
10631 | + * this function will issue a UREG_LOGIN to re-claim the RPI. | |
10632 | + **/ | |
10633 | void | |
10634 | lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |
10635 | { | |
10636 | @@ -846,6 +1138,19 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba * | |
10637 | return; | |
10638 | } | |
10639 | ||
10640 | +/** | |
10641 | + * lpfc_sli_handle_mb_event: Handle mailbox completions from firmware. | |
10642 | + * @phba: Pointer to HBA context object. | |
10643 | + * | |
10644 | + * This function is called with no lock held. This function processes all | |
10645 | + * the completed mailbox commands and gives it to upper layers. The interrupt | |
10646 | + * service routine processes mailbox completion interrupt and adds completed | |
10647 | + * mailbox commands to the mboxq_cmpl queue and signals the worker thread. | |
10648 | + * Worker thread call lpfc_sli_handle_mb_event, which will return the | |
10649 | + * completed mailbox commands in mboxq_cmpl queue to the upper layers. This | |
10650 | + * function returns the mailbox commands to the upper layer by calling the | |
10651 | + * completion handler function of each mailbox. | |
10652 | + **/ | |
10653 | int | |
10654 | lpfc_sli_handle_mb_event(struct lpfc_hba *phba) | |
10655 | { | |
10656 | @@ -953,6 +1258,18 @@ lpfc_sli_handle_mb_event(struct lpfc_hba | |
10657 | return 0; | |
10658 | } | |
10659 | ||
10660 | +/** | |
10661 | + * lpfc_sli_replace_hbqbuff: Replace the HBQ buffer with a new buffer. | |
10662 | + * @phba: Pointer to HBA context object. | |
10663 | + * @tag: Tag for the HBQ buffer. | |
10664 | + * | |
10665 | + * This function is called from unsolicited event handler code path to get the | |
10666 | + * HBQ buffer associated with an unsolicited iocb. This function is called with | |
10667 | + * no lock held. It returns the buffer associated with the given tag and posts | |
10668 | + * another buffer to the firmware. Note that the new buffer must be allocated | |
10669 | + * before taking the hbalock and that the hba lock must be held until it is | |
10670 | + * finished with the hbq entry swap. | |
10671 | + **/ | |
10672 | static struct lpfc_dmabuf * | |
10673 | lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) | |
10674 | { | |
10675 | @@ -962,22 +1279,28 @@ lpfc_sli_replace_hbqbuff(struct lpfc_hba | |
10676 | dma_addr_t phys; /* mapped address */ | |
10677 | unsigned long flags; | |
10678 | ||
10679 | + hbqno = tag >> 16; | |
10680 | + new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | |
10681 | /* Check whether HBQ is still in use */ | |
10682 | spin_lock_irqsave(&phba->hbalock, flags); | |
10683 | if (!phba->hbq_in_use) { | |
10684 | + if (new_hbq_entry) | |
10685 | + (phba->hbqs[hbqno].hbq_free_buffer)(phba, | |
10686 | + new_hbq_entry); | |
10687 | spin_unlock_irqrestore(&phba->hbalock, flags); | |
10688 | return NULL; | |
10689 | } | |
10690 | ||
10691 | hbq_entry = lpfc_sli_hbqbuf_find(phba, tag); | |
10692 | if (hbq_entry == NULL) { | |
10693 | + if (new_hbq_entry) | |
10694 | + (phba->hbqs[hbqno].hbq_free_buffer)(phba, | |
10695 | + new_hbq_entry); | |
10696 | spin_unlock_irqrestore(&phba->hbalock, flags); | |
10697 | return NULL; | |
10698 | } | |
10699 | list_del(&hbq_entry->dbuf.list); | |
10700 | ||
10701 | - hbqno = tag >> 16; | |
10702 | - new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | |
10703 | if (new_hbq_entry == NULL) { | |
10704 | list_add_tail(&hbq_entry->dbuf.list, &phba->hbqbuf_in_list); | |
10705 | spin_unlock_irqrestore(&phba->hbalock, flags); | |
10706 | @@ -997,6 +1320,18 @@ lpfc_sli_replace_hbqbuff(struct lpfc_hba | |
10707 | return &new_hbq_entry->dbuf; | |
10708 | } | |
10709 | ||
10710 | +/** | |
10711 | + * lpfc_sli_get_buff: Get the buffer associated with the buffer tag. | |
10712 | + * @phba: Pointer to HBA context object. | |
10713 | + * @pring: Pointer to driver SLI ring object. | |
10714 | + * @tag: buffer tag. | |
10715 | + * | |
10716 | + * This function is called with no lock held. When QUE_BUFTAG_BIT bit | |
10717 | + * is set in the tag the buffer is posted for a particular exchange, | |
10718 | + * the function will return the buffer without replacing the buffer. | |
10719 | + * If the buffer is for unsolicited ELS or CT traffic, this function | |
10720 | + * returns the buffer and also posts another buffer to the firmware. | |
10721 | + **/ | |
10722 | static struct lpfc_dmabuf * | |
10723 | lpfc_sli_get_buff(struct lpfc_hba *phba, | |
10724 | struct lpfc_sli_ring *pring, | |
10725 | @@ -1008,6 +1343,21 @@ lpfc_sli_get_buff(struct lpfc_hba *phba, | |
10726 | return lpfc_sli_replace_hbqbuff(phba, tag); | |
10727 | } | |
10728 | ||
10729 | + | |
10730 | +/** | |
10731 | + * lpfc_sli_process_unsol_iocb: Unsolicited iocb handler. | |
10732 | + * @phba: Pointer to HBA context object. | |
10733 | + * @pring: Pointer to driver SLI ring object. | |
10734 | + * @saveq: Pointer to the unsolicited iocb. | |
10735 | + * | |
10736 | + * This function is called with no lock held by the ring event handler | |
10737 | + * when there is an unsolicited iocb posted to the response ring by the | |
10738 | + * firmware. This function gets the buffer associated with the iocbs | |
10739 | + * and calls the event handler for the ring. This function handles both | |
10740 | + * qring buffers and hbq buffers. | |
10741 | + * When the function returns 1 the caller can free the iocb object otherwise | |
10742 | + * upper layer functions will free the iocb objects. | |
10743 | + **/ | |
10744 | static int | |
10745 | lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
10746 | struct lpfc_iocbq *saveq) | |
10747 | @@ -1192,6 +1542,18 @@ lpfc_sli_process_unsol_iocb(struct lpfc_ | |
10748 | return 1; | |
10749 | } | |
10750 | ||
10751 | +/** | |
10752 | + * lpfc_sli_iocbq_lookup: Find command iocb for the given response iocb. | |
10753 | + * @phba: Pointer to HBA context object. | |
10754 | + * @pring: Pointer to driver SLI ring object. | |
10755 | + * @prspiocb: Pointer to response iocb object. | |
10756 | + * | |
10757 | + * This function looks up the iocb_lookup table to get the command iocb | |
10758 | + * corresponding to the given response iocb using the iotag of the | |
10759 | + * response iocb. This function is called with the hbalock held. | |
10760 | + * This function returns the command iocb object if it finds the command | |
10761 | + * iocb else returns NULL. | |
10762 | + **/ | |
10763 | static struct lpfc_iocbq * | |
10764 | lpfc_sli_iocbq_lookup(struct lpfc_hba *phba, | |
10765 | struct lpfc_sli_ring *pring, | |
10766 | @@ -1217,6 +1579,23 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba *p | |
10767 | return NULL; | |
10768 | } | |
10769 | ||
10770 | +/** | |
10771 | + * lpfc_sli_process_sol_iocb: process solicited iocb completion. | |
10772 | + * @phba: Pointer to HBA context object. | |
10773 | + * @pring: Pointer to driver SLI ring object. | |
10774 | + * @saveq: Pointer to the response iocb to be processed. | |
10775 | + * | |
10776 | + * This function is called by the ring event handler for non-fcp | |
10777 | + * rings when there is a new response iocb in the response ring. | |
10778 | + * The caller is not required to hold any locks. This function | |
10779 | + * gets the command iocb associated with the response iocb and | |
10780 | + * calls the completion handler for the command iocb. If there | |
10781 | + * is no completion handler, the function will free the resources | |
10782 | + * associated with command iocb. If the response iocb is for | |
10783 | + * an already aborted command iocb, the status of the completion | |
10784 | + * is changed to IOSTAT_LOCAL_REJECT/IOERR_SLI_ABORTED. | |
10785 | + * This function always returns 1. | |
10786 | + **/ | |
10787 | static int | |
10788 | lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
10789 | struct lpfc_iocbq *saveq) | |
10790 | @@ -1233,6 +1612,17 @@ lpfc_sli_process_sol_iocb(struct lpfc_hb | |
10791 | if (cmdiocbp) { | |
10792 | if (cmdiocbp->iocb_cmpl) { | |
10793 | /* | |
10794 | + * If an ELS command failed send an event to mgmt | |
10795 | + * application. | |
10796 | + */ | |
10797 | + if (saveq->iocb.ulpStatus && | |
10798 | + (pring->ringno == LPFC_ELS_RING) && | |
10799 | + (cmdiocbp->iocb.ulpCommand == | |
10800 | + CMD_ELS_REQUEST64_CR)) | |
10801 | + lpfc_send_els_failure_event(phba, | |
10802 | + cmdiocbp, saveq); | |
10803 | + | |
10804 | + /* | |
10805 | * Post all ELS completions to the worker thread. | |
10806 | * All other are passed to the completion callback. | |
10807 | */ | |
10808 | @@ -1282,12 +1672,20 @@ lpfc_sli_process_sol_iocb(struct lpfc_hb | |
10809 | return rc; | |
10810 | } | |
10811 | ||
10812 | +/** | |
10813 | + * lpfc_sli_rsp_pointers_error: Response ring pointer error handler. | |
10814 | + * @phba: Pointer to HBA context object. | |
10815 | + * @pring: Pointer to driver SLI ring object. | |
10816 | + * | |
10817 | + * This function is called from the iocb ring event handlers when | |
10818 | + * put pointer is ahead of the get pointer for a ring. This function signal | |
10819 | + * an error attention condition to the worker thread and the worker | |
10820 | + * thread will transition the HBA to offline state. | |
10821 | + **/ | |
10822 | static void | |
10823 | lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
10824 | { | |
10825 | - struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? | |
10826 | - &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | |
10827 | - &phba->slim2p->mbx.us.s2.port[pring->ringno]; | |
10828 | + struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; | |
10829 | /* | |
10830 | * Ring <ringno> handler: portRspPut <portRspPut> is bigger then | |
10831 | * rsp ring <portRspMax> | |
10832 | @@ -1312,6 +1710,51 @@ lpfc_sli_rsp_pointers_error(struct lpfc_ | |
10833 | return; | |
10834 | } | |
10835 | ||
10836 | +/** | |
10837 | + * lpfc_poll_eratt: Error attention polling timer timeout handler. | |
10838 | + * @ptr: Pointer to address of HBA context object. | |
10839 | + * | |
10840 | + * This function is invoked by the Error Attention polling timer when the | |
10841 | + * timer times out. It will check the SLI Error Attention register for | |
10842 | + * possible attention events. If so, it will post an Error Attention event | |
10843 | + * and wake up worker thread to process it. Otherwise, it will set up the | |
10844 | + * Error Attention polling timer for the next poll. | |
10845 | + **/ | |
10846 | +void lpfc_poll_eratt(unsigned long ptr) | |
10847 | +{ | |
10848 | + struct lpfc_hba *phba; | |
10849 | + uint32_t eratt = 0; | |
10850 | + | |
10851 | + phba = (struct lpfc_hba *)ptr; | |
10852 | + | |
10853 | + /* Check chip HA register for error event */ | |
10854 | + eratt = lpfc_sli_check_eratt(phba); | |
10855 | + | |
10856 | + if (eratt) | |
10857 | + /* Tell the worker thread there is work to do */ | |
10858 | + lpfc_worker_wake_up(phba); | |
10859 | + else | |
10860 | + /* Restart the timer for next eratt poll */ | |
10861 | + mod_timer(&phba->eratt_poll, jiffies + | |
10862 | + HZ * LPFC_ERATT_POLL_INTERVAL); | |
10863 | + return; | |
10864 | +} | |
10865 | + | |
10866 | +/** | |
10867 | + * lpfc_sli_poll_fcp_ring: Handle FCP ring completion in polling mode. | |
10868 | + * @phba: Pointer to HBA context object. | |
10869 | + * | |
10870 | + * This function is called from lpfc_queuecommand, lpfc_poll_timeout, | |
10871 | + * lpfc_abort_handler and lpfc_slave_configure when FCP_RING_POLLING | |
10872 | + * is enabled. | |
10873 | + * | |
10874 | + * The caller does not hold any lock. | |
10875 | + * The function processes each response iocb in the response ring until it | |
10876 | + * finds an iocb with LE bit set and chains all the iocbs upto the iocb with | |
10877 | + * LE bit set. The function will call the completion handler of the command iocb | |
10878 | + * if the response iocb indicates a completion for a command iocb or it is | |
10879 | + * an abort completion. | |
10880 | + **/ | |
10881 | void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba) | |
10882 | { | |
10883 | struct lpfc_sli *psli = &phba->sli; | |
10884 | @@ -1320,7 +1763,7 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_ | |
10885 | IOCB_t *entry = NULL; | |
10886 | struct lpfc_iocbq *cmdiocbq = NULL; | |
10887 | struct lpfc_iocbq rspiocbq; | |
10888 | - struct lpfc_pgp *pgp; | |
10889 | + struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; | |
10890 | uint32_t status; | |
10891 | uint32_t portRspPut, portRspMax; | |
10892 | int type; | |
10893 | @@ -1330,11 +1773,6 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_ | |
10894 | ||
10895 | pring->stats.iocb_event++; | |
10896 | ||
10897 | - pgp = (phba->sli_rev == 3) ? | |
10898 | - &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | |
10899 | - &phba->slim2p->mbx.us.s2.port[pring->ringno]; | |
10900 | - | |
10901 | - | |
10902 | /* | |
10903 | * The next available response entry should never exceed the maximum | |
10904 | * entries. If it does, treat it as an adapter hardware error. | |
10905 | @@ -1372,8 +1810,8 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_ | |
10906 | irsp->un.ulpWord[3], | |
10907 | irsp->un.ulpWord[4], | |
10908 | irsp->un.ulpWord[5], | |
10909 | - *(((uint32_t *) irsp) + 6), | |
10910 | - *(((uint32_t *) irsp) + 7)); | |
10911 | + *(uint32_t *)&irsp->un1, | |
10912 | + *((uint32_t *)&irsp->un1 + 1)); | |
10913 | } | |
10914 | ||
10915 | switch (type) { | |
10916 | @@ -1465,17 +1903,28 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_ | |
10917 | return; | |
10918 | } | |
10919 | ||
10920 | -/* | |
10921 | +/** | |
10922 | + * lpfc_sli_handle_fast_ring_event: Handle ring events on FCP ring. | |
10923 | + * @phba: Pointer to HBA context object. | |
10924 | + * @pring: Pointer to driver SLI ring object. | |
10925 | + * @mask: Host attention register mask for this ring. | |
10926 | + * | |
10927 | + * This function is called from the interrupt context when there is a ring | |
10928 | + * event for the fcp ring. The caller does not hold any lock. | |
10929 | + * The function processes each response iocb in the response ring until it | |
10930 | + * finds an iocb with LE bit set and chains all the iocbs upto the iocb with | |
10931 | + * LE bit set. The function will call the completion handler of the command iocb | |
10932 | + * if the response iocb indicates a completion for a command iocb or it is | |
10933 | + * an abort completion. The function will call lpfc_sli_process_unsol_iocb | |
10934 | + * function if this is an unsolicited iocb. | |
10935 | * This routine presumes LPFC_FCP_RING handling and doesn't bother | |
10936 | - * to check it explicitly. | |
10937 | - */ | |
10938 | + * to check it explicitly. This function always returns 1. | |
10939 | + **/ | |
10940 | static int | |
10941 | lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, | |
10942 | struct lpfc_sli_ring *pring, uint32_t mask) | |
10943 | { | |
10944 | - struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? | |
10945 | - &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | |
10946 | - &phba->slim2p->mbx.us.s2.port[pring->ringno]; | |
10947 | + struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; | |
10948 | IOCB_t *irsp = NULL; | |
10949 | IOCB_t *entry = NULL; | |
10950 | struct lpfc_iocbq *cmdiocbq = NULL; | |
10951 | @@ -1548,8 +1997,8 @@ lpfc_sli_handle_fast_ring_event(struct l | |
10952 | irsp->un.ulpWord[3], | |
10953 | irsp->un.ulpWord[4], | |
10954 | irsp->un.ulpWord[5], | |
10955 | - *(((uint32_t *) irsp) + 6), | |
10956 | - *(((uint32_t *) irsp) + 7)); | |
10957 | + *(uint32_t *)&irsp->un1, | |
10958 | + *((uint32_t *)&irsp->un1 + 1)); | |
10959 | } | |
10960 | ||
10961 | switch (type) { | |
10962 | @@ -1646,13 +2095,28 @@ lpfc_sli_handle_fast_ring_event(struct l | |
10963 | return rc; | |
10964 | } | |
10965 | ||
10966 | +/** | |
10967 | + * lpfc_sli_handle_slow_ring_event: Handle ring events for non-FCP rings. | |
10968 | + * @phba: Pointer to HBA context object. | |
10969 | + * @pring: Pointer to driver SLI ring object. | |
10970 | + * @mask: Host attention register mask for this ring. | |
10971 | + * | |
10972 | + * This function is called from the worker thread when there is a ring | |
10973 | + * event for non-fcp rings. The caller does not hold any lock . | |
10974 | + * The function processes each response iocb in the response ring until it | |
10975 | + * finds an iocb with LE bit set and chains all the iocbs upto the iocb with | |
10976 | + * LE bit set. The function will call lpfc_sli_process_sol_iocb function if the | |
10977 | + * response iocb indicates a completion of a command iocb. The function | |
10978 | + * will call lpfc_sli_process_unsol_iocb function if this is an unsolicited | |
10979 | + * iocb. The function frees the resources or calls the completion handler if | |
10980 | + * this iocb is an abort completion. The function returns 0 when the allocated | |
10981 | + * iocbs are not freed, otherwise returns 1. | |
10982 | + **/ | |
10983 | int | |
10984 | lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba, | |
10985 | struct lpfc_sli_ring *pring, uint32_t mask) | |
10986 | { | |
10987 | - struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? | |
10988 | - &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | |
10989 | - &phba->slim2p->mbx.us.s2.port[pring->ringno]; | |
10990 | + struct lpfc_pgp *pgp; | |
10991 | IOCB_t *entry; | |
10992 | IOCB_t *irsp = NULL; | |
10993 | struct lpfc_iocbq *rspiocbp = NULL; | |
10994 | @@ -1666,6 +2130,7 @@ lpfc_sli_handle_slow_ring_event(struct l | |
10995 | int rc = 1; | |
10996 | unsigned long iflag; | |
10997 | ||
10998 | + pgp = &phba->port_gp[pring->ringno]; | |
10999 | spin_lock_irqsave(&phba->hbalock, iflag); | |
11000 | pring->stats.iocb_event++; | |
11001 | ||
11002 | @@ -1904,6 +2369,16 @@ lpfc_sli_handle_slow_ring_event(struct l | |
11003 | return rc; | |
11004 | } | |
11005 | ||
11006 | +/** | |
11007 | + * lpfc_sli_abort_iocb_ring: Abort all iocbs in the ring. | |
11008 | + * @phba: Pointer to HBA context object. | |
11009 | + * @pring: Pointer to driver SLI ring object. | |
11010 | + * | |
11011 | + * This function aborts all iocbs in the given ring and frees all the iocb | |
11012 | + * objects in txq. This function issues an abort iocb for all the iocb commands | |
11013 | + * in txcmplq. The iocbs in the txcmplq is not guaranteed to complete before | |
11014 | + * the return of this function. The caller is not required to hold any locks. | |
11015 | + **/ | |
11016 | void | |
11017 | lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |
11018 | { | |
11019 | @@ -1943,6 +2418,83 @@ lpfc_sli_abort_iocb_ring(struct lpfc_hba | |
11020 | } | |
11021 | } | |
11022 | ||
11023 | +/** | |
11024 | + * lpfc_sli_flush_fcp_rings: flush all iocbs in the fcp ring. | |
11025 | + * @phba: Pointer to HBA context object. | |
11026 | + * | |
11027 | + * This function flushes all iocbs in the fcp ring and frees all the iocb | |
11028 | + * objects in txq and txcmplq. This function will not issue abort iocbs | |
11029 | + * for all the iocb commands in txcmplq, they will just be returned with | |
11030 | + * IOERR_SLI_DOWN. This function is invoked with EEH when device's PCI | |
11031 | + * slot has been permanently disabled. | |
11032 | + **/ | |
11033 | +void | |
11034 | +lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) | |
11035 | +{ | |
11036 | + LIST_HEAD(txq); | |
11037 | + LIST_HEAD(txcmplq); | |
11038 | + struct lpfc_iocbq *iocb; | |
11039 | + IOCB_t *cmd = NULL; | |
11040 | + struct lpfc_sli *psli = &phba->sli; | |
11041 | + struct lpfc_sli_ring *pring; | |
11042 | + | |
11043 | + /* Currently, only one fcp ring */ | |
11044 | + pring = &psli->ring[psli->fcp_ring]; | |
11045 | + | |
11046 | + spin_lock_irq(&phba->hbalock); | |
11047 | + /* Retrieve everything on txq */ | |
11048 | + list_splice_init(&pring->txq, &txq); | |
11049 | + pring->txq_cnt = 0; | |
11050 | + | |
11051 | + /* Retrieve everything on the txcmplq */ | |
11052 | + list_splice_init(&pring->txcmplq, &txcmplq); | |
11053 | + pring->txcmplq_cnt = 0; | |
11054 | + spin_unlock_irq(&phba->hbalock); | |
11055 | + | |
11056 | + /* Flush the txq */ | |
11057 | + while (!list_empty(&txq)) { | |
11058 | + iocb = list_get_first(&txq, struct lpfc_iocbq, list); | |
11059 | + cmd = &iocb->iocb; | |
11060 | + list_del_init(&iocb->list); | |
11061 | + | |
11062 | + if (!iocb->iocb_cmpl) | |
11063 | + lpfc_sli_release_iocbq(phba, iocb); | |
11064 | + else { | |
11065 | + cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | |
11066 | + cmd->un.ulpWord[4] = IOERR_SLI_DOWN; | |
11067 | + (iocb->iocb_cmpl) (phba, iocb, iocb); | |
11068 | + } | |
11069 | + } | |
11070 | + | |
11071 | + /* Flush the txcmpq */ | |
11072 | + while (!list_empty(&txcmplq)) { | |
11073 | + iocb = list_get_first(&txcmplq, struct lpfc_iocbq, list); | |
11074 | + cmd = &iocb->iocb; | |
11075 | + list_del_init(&iocb->list); | |
11076 | + | |
11077 | + if (!iocb->iocb_cmpl) | |
11078 | + lpfc_sli_release_iocbq(phba, iocb); | |
11079 | + else { | |
11080 | + cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | |
11081 | + cmd->un.ulpWord[4] = IOERR_SLI_DOWN; | |
11082 | + (iocb->iocb_cmpl) (phba, iocb, iocb); | |
11083 | + } | |
11084 | + } | |
11085 | +} | |
11086 | + | |
11087 | +/** | |
11088 | + * lpfc_sli_brdready: Check for host status bits. | |
11089 | + * @phba: Pointer to HBA context object. | |
11090 | + * @mask: Bit mask to be checked. | |
11091 | + * | |
11092 | + * This function reads the host status register and compares | |
11093 | + * with the provided bit mask to check if HBA completed | |
11094 | + * the restart. This function will wait in a loop for the | |
11095 | + * HBA to complete restart. If the HBA does not restart within | |
11096 | + * 15 iterations, the function will reset the HBA again. The | |
11097 | + * function returns 1 when HBA fail to restart otherwise returns | |
11098 | + * zero. | |
11099 | + **/ | |
11100 | int | |
11101 | lpfc_sli_brdready(struct lpfc_hba *phba, uint32_t mask) | |
11102 | { | |
11103 | @@ -1990,6 +2542,13 @@ lpfc_sli_brdready(struct lpfc_hba *phba, | |
11104 | ||
11105 | #define BARRIER_TEST_PATTERN (0xdeadbeef) | |
11106 | ||
11107 | +/** | |
11108 | + * lpfc_reset_barrier: Make HBA ready for HBA reset. | |
11109 | + * @phba: Pointer to HBA context object. | |
11110 | + * | |
11111 | + * This function is called before resetting an HBA. This | |
11112 | + * function requests HBA to quiesce DMAs before a reset. | |
11113 | + **/ | |
11114 | void lpfc_reset_barrier(struct lpfc_hba *phba) | |
11115 | { | |
11116 | uint32_t __iomem *resp_buf; | |
11117 | @@ -2063,6 +2622,17 @@ restore_hc: | |
11118 | readl(phba->HCregaddr); /* flush */ | |
11119 | } | |
11120 | ||
11121 | +/** | |
11122 | + * lpfc_sli_brdkill: Issue a kill_board mailbox command. | |
11123 | + * @phba: Pointer to HBA context object. | |
11124 | + * | |
11125 | + * This function issues a kill_board mailbox command and waits for | |
11126 | + * the error attention interrupt. This function is called for stopping | |
11127 | + * the firmware processing. The caller is not required to hold any | |
11128 | + * locks. This function calls lpfc_hba_down_post function to free | |
11129 | + * any pending commands after the kill. The function will return 1 when it | |
11130 | + * fails to kill the board else will return 0. | |
11131 | + **/ | |
11132 | int | |
11133 | lpfc_sli_brdkill(struct lpfc_hba *phba) | |
11134 | { | |
11135 | @@ -2139,6 +2709,17 @@ lpfc_sli_brdkill(struct lpfc_hba *phba) | |
11136 | return ha_copy & HA_ERATT ? 0 : 1; | |
11137 | } | |
11138 | ||
11139 | +/** | |
11140 | + * lpfc_sli_brdreset: Reset the HBA. | |
11141 | + * @phba: Pointer to HBA context object. | |
11142 | + * | |
11143 | + * This function resets the HBA by writing HC_INITFF to the control | |
11144 | + * register. After the HBA resets, this function resets all the iocb ring | |
11145 | + * indices. This function disables PCI layer parity checking during | |
11146 | + * the reset. | |
11147 | + * This function returns 0 always. | |
11148 | + * The caller is not required to hold any locks. | |
11149 | + **/ | |
11150 | int | |
11151 | lpfc_sli_brdreset(struct lpfc_hba *phba) | |
11152 | { | |
11153 | @@ -2191,6 +2772,19 @@ lpfc_sli_brdreset(struct lpfc_hba *phba) | |
11154 | return 0; | |
11155 | } | |
11156 | ||
11157 | +/** | |
11158 | + * lpfc_sli_brdrestart: Restart the HBA. | |
11159 | + * @phba: Pointer to HBA context object. | |
11160 | + * | |
11161 | + * This function is called in the SLI initialization code path to | |
11162 | + * restart the HBA. The caller is not required to hold any lock. | |
11163 | + * This function writes MBX_RESTART mailbox command to the SLIM and | |
11164 | + * resets the HBA. At the end of the function, it calls lpfc_hba_down_post | |
11165 | + * function to free any pending commands. The function enables | |
11166 | + * POST only during the first initialization. The function returns zero. | |
11167 | + * The function does not guarantee completion of MBX_RESTART mailbox | |
11168 | + * command before the return of this function. | |
11169 | + **/ | |
11170 | int | |
11171 | lpfc_sli_brdrestart(struct lpfc_hba *phba) | |
11172 | { | |
11173 | @@ -2251,6 +2845,16 @@ lpfc_sli_brdrestart(struct lpfc_hba *phb | |
11174 | return 0; | |
11175 | } | |
11176 | ||
11177 | +/** | |
11178 | + * lpfc_sli_chipset_init: Wait for the restart of the HBA after a restart. | |
11179 | + * @phba: Pointer to HBA context object. | |
11180 | + * | |
11181 | + * This function is called after a HBA restart to wait for successful | |
11182 | + * restart of the HBA. Successful restart of the HBA is indicated by | |
11183 | + * HS_FFRDY and HS_MBRDY bits. If the HBA fails to restart even after 15 | |
11184 | + * iteration, the function will restart the HBA again. The function returns | |
11185 | + * zero if HBA successfully restarted else returns negative error code. | |
11186 | + **/ | |
11187 | static int | |
11188 | lpfc_sli_chipset_init(struct lpfc_hba *phba) | |
11189 | { | |
11190 | @@ -2336,12 +2940,25 @@ lpfc_sli_chipset_init(struct lpfc_hba *p | |
11191 | return 0; | |
11192 | } | |
11193 | ||
11194 | +/** | |
11195 | + * lpfc_sli_hbq_count: Get the number of HBQs to be configured. | |
11196 | + * | |
11197 | + * This function calculates and returns the number of HBQs required to be | |
11198 | + * configured. | |
11199 | + **/ | |
11200 | int | |
11201 | lpfc_sli_hbq_count(void) | |
11202 | { | |
11203 | return ARRAY_SIZE(lpfc_hbq_defs); | |
11204 | } | |
11205 | ||
11206 | +/** | |
11207 | + * lpfc_sli_hbq_entry_count: Calculate total number of hbq entries. | |
11208 | + * | |
11209 | + * This function adds the number of hbq entries in every HBQ to get | |
11210 | + * the total number of hbq entries required for the HBA and returns | |
11211 | + * the total count. | |
11212 | + **/ | |
11213 | static int | |
11214 | lpfc_sli_hbq_entry_count(void) | |
11215 | { | |
11216 | @@ -2354,12 +2971,27 @@ lpfc_sli_hbq_entry_count(void) | |
11217 | return count; | |
11218 | } | |
11219 | ||
11220 | +/** | |
11221 | + * lpfc_sli_hbq_size: Calculate memory required for all hbq entries. | |
11222 | + * | |
11223 | + * This function calculates amount of memory required for all hbq entries | |
11224 | + * to be configured and returns the total memory required. | |
11225 | + **/ | |
11226 | int | |
11227 | lpfc_sli_hbq_size(void) | |
11228 | { | |
11229 | return lpfc_sli_hbq_entry_count() * sizeof(struct lpfc_hbq_entry); | |
11230 | } | |
11231 | ||
11232 | +/** | |
11233 | + * lpfc_sli_hbq_setup: configure and initialize HBQs. | |
11234 | + * @phba: Pointer to HBA context object. | |
11235 | + * | |
11236 | + * This function is called during the SLI initialization to configure | |
11237 | + * all the HBQs and post buffers to the HBQ. The caller is not | |
11238 | + * required to hold any locks. This function will return zero if successful | |
11239 | + * else it will return negative error code. | |
11240 | + **/ | |
11241 | static int | |
11242 | lpfc_sli_hbq_setup(struct lpfc_hba *phba) | |
11243 | { | |
11244 | @@ -2415,15 +3047,26 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba | |
11245 | mempool_free(pmb, phba->mbox_mem_pool); | |
11246 | ||
11247 | /* Initially populate or replenish the HBQs */ | |
11248 | - for (hbqno = 0; hbqno < hbq_count; ++hbqno) { | |
11249 | - if (lpfc_sli_hbqbuf_init_hbqs(phba, hbqno)) | |
11250 | - return -ENOMEM; | |
11251 | - } | |
11252 | + for (hbqno = 0; hbqno < hbq_count; ++hbqno) | |
11253 | + lpfc_sli_hbqbuf_init_hbqs(phba, hbqno); | |
11254 | return 0; | |
11255 | } | |
11256 | ||
11257 | -static int | |
11258 | -lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode) | |
11259 | +/** | |
11260 | + * lpfc_sli_config_port: Issue config port mailbox command. | |
11261 | + * @phba: Pointer to HBA context object. | |
11262 | + * @sli_mode: sli mode - 2/3 | |
11263 | + * | |
11264 | + * This function is called by the sli intialization code path | |
11265 | + * to issue config_port mailbox command. This function restarts the | |
11266 | + * HBA firmware and issues a config_port mailbox command to configure | |
11267 | + * the SLI interface in the sli mode specified by sli_mode | |
11268 | + * variable. The caller is not required to hold any locks. | |
11269 | + * The function returns 0 if successful, else returns negative error | |
11270 | + * code. | |
11271 | + **/ | |
11272 | +int | |
11273 | +lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode) | |
11274 | { | |
11275 | LPFC_MBOXQ_t *pmb; | |
11276 | uint32_t resetcount = 0, rc = 0, done = 0; | |
11277 | @@ -2460,13 +3103,15 @@ lpfc_do_config_port(struct lpfc_hba *phb | |
11278 | if (rc == -ERESTART) { | |
11279 | phba->link_state = LPFC_LINK_UNKNOWN; | |
11280 | continue; | |
11281 | - } else if (rc) { | |
11282 | + } else if (rc) | |
11283 | break; | |
11284 | - } | |
11285 | - | |
11286 | phba->link_state = LPFC_INIT_MBX_CMDS; | |
11287 | lpfc_config_port(phba, pmb); | |
11288 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); | |
11289 | + phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED | | |
11290 | + LPFC_SLI3_HBQ_ENABLED | | |
11291 | + LPFC_SLI3_CRP_ENABLED | | |
11292 | + LPFC_SLI3_INB_ENABLED); | |
11293 | if (rc != MBX_SUCCESS) { | |
11294 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
11295 | "0442 Adapter failed to init, mbxCmd x%x " | |
11296 | @@ -2476,30 +3121,64 @@ lpfc_do_config_port(struct lpfc_hba *phb | |
11297 | phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE; | |
11298 | spin_unlock_irq(&phba->hbalock); | |
11299 | rc = -ENXIO; | |
11300 | - } else { | |
11301 | + } else | |
11302 | done = 1; | |
11303 | - phba->max_vpi = (phba->max_vpi && | |
11304 | - pmb->mb.un.varCfgPort.gmv) != 0 | |
11305 | - ? pmb->mb.un.varCfgPort.max_vpi | |
11306 | - : 0; | |
11307 | - } | |
11308 | } | |
11309 | - | |
11310 | if (!done) { | |
11311 | rc = -EINVAL; | |
11312 | goto do_prep_failed; | |
11313 | } | |
11314 | - | |
11315 | - if ((pmb->mb.un.varCfgPort.sli_mode == 3) && | |
11316 | - (!pmb->mb.un.varCfgPort.cMA)) { | |
11317 | - rc = -ENXIO; | |
11318 | + if (pmb->mb.un.varCfgPort.sli_mode == 3) { | |
11319 | + if (!pmb->mb.un.varCfgPort.cMA) { | |
11320 | + rc = -ENXIO; | |
11321 | + goto do_prep_failed; | |
11322 | + } | |
11323 | + if (phba->max_vpi && pmb->mb.un.varCfgPort.gmv) { | |
11324 | + phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; | |
11325 | + phba->max_vpi = pmb->mb.un.varCfgPort.max_vpi; | |
11326 | + } else | |
11327 | + phba->max_vpi = 0; | |
11328 | + if (pmb->mb.un.varCfgPort.gerbm) | |
11329 | + phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED; | |
11330 | + if (pmb->mb.un.varCfgPort.gcrp) | |
11331 | + phba->sli3_options |= LPFC_SLI3_CRP_ENABLED; | |
11332 | + if (pmb->mb.un.varCfgPort.ginb) { | |
11333 | + phba->sli3_options |= LPFC_SLI3_INB_ENABLED; | |
11334 | + phba->port_gp = phba->mbox->us.s3_inb_pgp.port; | |
11335 | + phba->inb_ha_copy = &phba->mbox->us.s3_inb_pgp.ha_copy; | |
11336 | + phba->inb_counter = &phba->mbox->us.s3_inb_pgp.counter; | |
11337 | + phba->inb_last_counter = | |
11338 | + phba->mbox->us.s3_inb_pgp.counter; | |
11339 | + } else { | |
11340 | + phba->port_gp = phba->mbox->us.s3_pgp.port; | |
11341 | + phba->inb_ha_copy = NULL; | |
11342 | + phba->inb_counter = NULL; | |
11343 | + } | |
11344 | + } else { | |
11345 | + phba->port_gp = phba->mbox->us.s2.port; | |
11346 | + phba->inb_ha_copy = NULL; | |
11347 | + phba->inb_counter = NULL; | |
11348 | + phba->max_vpi = 0; | |
11349 | } | |
11350 | - | |
11351 | do_prep_failed: | |
11352 | mempool_free(pmb, phba->mbox_mem_pool); | |
11353 | return rc; | |
11354 | } | |
11355 | ||
11356 | + | |
11357 | +/** | |
11358 | + * lpfc_sli_hba_setup: SLI intialization function. | |
11359 | + * @phba: Pointer to HBA context object. | |
11360 | + * | |
11361 | + * This function is the main SLI intialization function. This function | |
11362 | + * is called by the HBA intialization code, HBA reset code and HBA | |
11363 | + * error attention handler code. Caller is not required to hold any | |
11364 | + * locks. This function issues config_port mailbox command to configure | |
11365 | + * the SLI, setup iocb rings and HBQ rings. In the end the function | |
11366 | + * calls the config_port_post function to issue init_link mailbox | |
11367 | + * command and to start the discovery. The function will return zero | |
11368 | + * if successful, else it will return negative error code. | |
11369 | + **/ | |
11370 | int | |
11371 | lpfc_sli_hba_setup(struct lpfc_hba *phba) | |
11372 | { | |
11373 | @@ -2528,22 +3207,20 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba | |
11374 | break; | |
11375 | } | |
11376 | ||
11377 | - rc = lpfc_do_config_port(phba, mode); | |
11378 | + rc = lpfc_sli_config_port(phba, mode); | |
11379 | + | |
11380 | if (rc && lpfc_sli_mode == 3) | |
11381 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, | |
11382 | "1820 Unable to select SLI-3. " | |
11383 | "Not supported by adapter.\n"); | |
11384 | if (rc && mode != 2) | |
11385 | - rc = lpfc_do_config_port(phba, 2); | |
11386 | + rc = lpfc_sli_config_port(phba, 2); | |
11387 | if (rc) | |
11388 | goto lpfc_sli_hba_setup_error; | |
11389 | ||
11390 | if (phba->sli_rev == 3) { | |
11391 | phba->iocb_cmd_size = SLI3_IOCB_CMD_SIZE; | |
11392 | phba->iocb_rsp_size = SLI3_IOCB_RSP_SIZE; | |
11393 | - phba->sli3_options |= LPFC_SLI3_ENABLED; | |
11394 | - phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED; | |
11395 | - | |
11396 | } else { | |
11397 | phba->iocb_cmd_size = SLI2_IOCB_CMD_SIZE; | |
11398 | phba->iocb_rsp_size = SLI2_IOCB_RSP_SIZE; | |
11399 | @@ -2558,8 +3235,7 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba | |
11400 | if (rc) | |
11401 | goto lpfc_sli_hba_setup_error; | |
11402 | ||
11403 | - /* Init HBQs */ | |
11404 | - | |
11405 | + /* Init HBQs */ | |
11406 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { | |
11407 | rc = lpfc_sli_hbq_setup(phba); | |
11408 | if (rc) | |
11409 | @@ -2581,19 +3257,19 @@ lpfc_sli_hba_setup_error: | |
11410 | return rc; | |
11411 | } | |
11412 | ||
11413 | -/*! lpfc_mbox_timeout | |
11414 | - * | |
11415 | - * \pre | |
11416 | - * \post | |
11417 | - * \param hba Pointer to per struct lpfc_hba structure | |
11418 | - * \param l1 Pointer to the driver's mailbox queue. | |
11419 | - * \return | |
11420 | - * void | |
11421 | - * | |
11422 | - * \b Description: | |
11423 | + | |
11424 | +/** | |
11425 | + * lpfc_mbox_timeout: Timeout call back function for mbox timer. | |
11426 | + * @ptr: context object - pointer to hba structure. | |
11427 | * | |
11428 | - * This routine handles mailbox timeout events at timer interrupt context. | |
11429 | - */ | |
11430 | + * This is the callback function for mailbox timer. The mailbox | |
11431 | + * timer is armed when a new mailbox command is issued and the timer | |
11432 | + * is deleted when the mailbox complete. The function is called by | |
11433 | + * the kernel timer code when a mailbox does not complete within | |
11434 | + * expected time. This function wakes up the worker thread to | |
11435 | + * process the mailbox timeout and returns. All the processing is | |
11436 | + * done by the worker thread function lpfc_mbox_timeout_handler. | |
11437 | + **/ | |
11438 | void | |
11439 | lpfc_mbox_timeout(unsigned long ptr) | |
11440 | { | |
11441 | @@ -2612,6 +3288,15 @@ lpfc_mbox_timeout(unsigned long ptr) | |
11442 | return; | |
11443 | } | |
11444 | ||
11445 | + | |
11446 | +/** | |
11447 | + * lpfc_mbox_timeout_handler: Worker thread function to handle mailbox timeout. | |
11448 | + * @phba: Pointer to HBA context object. | |
11449 | + * | |
11450 | + * This function is called from worker thread when a mailbox command times out. | |
11451 | + * The caller is not required to hold any locks. This function will reset the | |
11452 | + * HBA and recover all the pending commands. | |
11453 | + **/ | |
11454 | void | |
11455 | lpfc_mbox_timeout_handler(struct lpfc_hba *phba) | |
11456 | { | |
11457 | @@ -2666,6 +3351,32 @@ lpfc_mbox_timeout_handler(struct lpfc_hb | |
11458 | return; | |
11459 | } | |
11460 | ||
11461 | +/** | |
11462 | + * lpfc_sli_issue_mbox: Issue a mailbox command to firmware. | |
11463 | + * @phba: Pointer to HBA context object. | |
11464 | + * @pmbox: Pointer to mailbox object. | |
11465 | + * @flag: Flag indicating how the mailbox need to be processed. | |
11466 | + * | |
11467 | + * This function is called by discovery code and HBA management code | |
11468 | + * to submit a mailbox command to firmware. This function gets the | |
11469 | + * hbalock to protect the data structures. | |
11470 | + * The mailbox command can be submitted in polling mode, in which case | |
11471 | + * this function will wait in a polling loop for the completion of the | |
11472 | + * mailbox. | |
11473 | + * If the mailbox is submitted in no_wait mode (not polling) the | |
11474 | + * function will submit the command and returns immediately without waiting | |
11475 | + * for the mailbox completion. The no_wait is supported only when HBA | |
11476 | + * is in SLI2/SLI3 mode - interrupts are enabled. | |
11477 | + * The SLI interface allows only one mailbox pending at a time. If the | |
11478 | + * mailbox is issued in polling mode and there is already a mailbox | |
11479 | + * pending, then the function will return an error. If the mailbox is issued | |
11480 | + * in NO_WAIT mode and there is a mailbox pending already, the function | |
11481 | + * will return MBX_BUSY after queuing the mailbox into mailbox queue. | |
11482 | + * The sli layer owns the mailbox object until the completion of mailbox | |
11483 | + * command if this function return MBX_BUSY or MBX_SUCCESS. For all other | |
11484 | + * return codes the caller owns the mailbox command after the return of | |
11485 | + * the function. | |
11486 | + **/ | |
11487 | int | |
11488 | lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag) | |
11489 | { | |
11490 | @@ -2676,7 +3387,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phb | |
11491 | int i; | |
11492 | unsigned long timeout; | |
11493 | unsigned long drvr_flag = 0; | |
11494 | - volatile uint32_t word0, ldata; | |
11495 | + uint32_t word0, ldata; | |
11496 | void __iomem *to_slim; | |
11497 | int processing_queue = 0; | |
11498 | ||
11499 | @@ -2836,12 +3547,11 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phb | |
11500 | ||
11501 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) { | |
11502 | /* First copy command data to host SLIM area */ | |
11503 | - lpfc_sli_pcimem_bcopy(mb, &phba->slim2p->mbx, MAILBOX_CMD_SIZE); | |
11504 | + lpfc_sli_pcimem_bcopy(mb, phba->mbox, MAILBOX_CMD_SIZE); | |
11505 | } else { | |
11506 | if (mb->mbxCommand == MBX_CONFIG_PORT) { | |
11507 | /* copy command data into host mbox for cmpl */ | |
11508 | - lpfc_sli_pcimem_bcopy(mb, &phba->slim2p->mbx, | |
11509 | - MAILBOX_CMD_SIZE); | |
11510 | + lpfc_sli_pcimem_bcopy(mb, phba->mbox, MAILBOX_CMD_SIZE); | |
11511 | } | |
11512 | ||
11513 | /* First copy mbox command data to HBA SLIM, skip past first | |
11514 | @@ -2851,7 +3561,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phb | |
11515 | MAILBOX_CMD_SIZE - sizeof (uint32_t)); | |
11516 | ||
11517 | /* Next copy over first word, with mbxOwner set */ | |
11518 | - ldata = *((volatile uint32_t *)mb); | |
11519 | + ldata = *((uint32_t *)mb); | |
11520 | to_slim = phba->MBslimaddr; | |
11521 | writel(ldata, to_slim); | |
11522 | readl(to_slim); /* flush */ | |
11523 | @@ -2883,7 +3593,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phb | |
11524 | ||
11525 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) { | |
11526 | /* First read mbox status word */ | |
11527 | - word0 = *((volatile uint32_t *)&phba->slim2p->mbx); | |
11528 | + word0 = *((uint32_t *)phba->mbox); | |
11529 | word0 = le32_to_cpu(word0); | |
11530 | } else { | |
11531 | /* First read mbox status word */ | |
11532 | @@ -2922,12 +3632,11 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phb | |
11533 | ||
11534 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) { | |
11535 | /* First copy command data */ | |
11536 | - word0 = *((volatile uint32_t *) | |
11537 | - &phba->slim2p->mbx); | |
11538 | + word0 = *((uint32_t *)phba->mbox); | |
11539 | word0 = le32_to_cpu(word0); | |
11540 | if (mb->mbxCommand == MBX_CONFIG_PORT) { | |
11541 | MAILBOX_t *slimmb; | |
11542 | - volatile uint32_t slimword0; | |
11543 | + uint32_t slimword0; | |
11544 | /* Check real SLIM for any errors */ | |
11545 | slimword0 = readl(phba->MBslimaddr); | |
11546 | slimmb = (MAILBOX_t *) & slimword0; | |
11547 | @@ -2948,8 +3657,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phb | |
11548 | ||
11549 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) { | |
11550 | /* copy results back to user */ | |
11551 | - lpfc_sli_pcimem_bcopy(&phba->slim2p->mbx, mb, | |
11552 | - MAILBOX_CMD_SIZE); | |
11553 | + lpfc_sli_pcimem_bcopy(phba->mbox, mb, MAILBOX_CMD_SIZE); | |
11554 | } else { | |
11555 | /* First copy command data */ | |
11556 | lpfc_memcpy_from_slim(mb, phba->MBslimaddr, | |
11557 | @@ -2980,9 +3688,16 @@ out_not_finished: | |
11558 | return MBX_NOT_FINISHED; | |
11559 | } | |
11560 | ||
11561 | -/* | |
11562 | - * Caller needs to hold lock. | |
11563 | - */ | |
11564 | +/** | |
11565 | + * __lpfc_sli_ringtx_put: Add an iocb to the txq. | |
11566 | + * @phba: Pointer to HBA context object. | |
11567 | + * @pring: Pointer to driver SLI ring object. | |
11568 | + * @piocb: Pointer to address of newly added command iocb. | |
11569 | + * | |
11570 | + * This function is called with hbalock held to add a command | |
11571 | + * iocb to the txq when SLI layer cannot submit the command iocb | |
11572 | + * to the ring. | |
11573 | + **/ | |
11574 | static void | |
11575 | __lpfc_sli_ringtx_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
11576 | struct lpfc_iocbq *piocb) | |
11577 | @@ -2992,6 +3707,23 @@ __lpfc_sli_ringtx_put(struct lpfc_hba *p | |
11578 | pring->txq_cnt++; | |
11579 | } | |
11580 | ||
11581 | +/** | |
11582 | + * lpfc_sli_next_iocb: Get the next iocb in the txq. | |
11583 | + * @phba: Pointer to HBA context object. | |
11584 | + * @pring: Pointer to driver SLI ring object. | |
11585 | + * @piocb: Pointer to address of newly added command iocb. | |
11586 | + * | |
11587 | + * This function is called with hbalock held before a new | |
11588 | + * iocb is submitted to the firmware. This function checks | |
11589 | + * txq to flush the iocbs in txq to Firmware before | |
11590 | + * submitting new iocbs to the Firmware. | |
11591 | + * If there are iocbs in the txq which need to be submitted | |
11592 | + * to firmware, lpfc_sli_next_iocb returns the first element | |
11593 | + * of the txq after dequeuing it from txq. | |
11594 | + * If there is no iocb in the txq then the function will return | |
11595 | + * *piocb and *piocb is set to NULL. Caller needs to check | |
11596 | + * *piocb to find if there are more commands in the txq. | |
11597 | + **/ | |
11598 | static struct lpfc_iocbq * | |
11599 | lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
11600 | struct lpfc_iocbq **piocb) | |
11601 | @@ -3007,9 +3739,30 @@ lpfc_sli_next_iocb(struct lpfc_hba *phba | |
11602 | return nextiocb; | |
11603 | } | |
11604 | ||
11605 | -/* | |
11606 | - * Lockless version of lpfc_sli_issue_iocb. | |
11607 | - */ | |
11608 | +/** | |
11609 | + * __lpfc_sli_issue_iocb: Lockless version of lpfc_sli_issue_iocb. | |
11610 | + * @phba: Pointer to HBA context object. | |
11611 | + * @pring: Pointer to driver SLI ring object. | |
11612 | + * @piocb: Pointer to command iocb. | |
11613 | + * @flag: Flag indicating if this command can be put into txq. | |
11614 | + * | |
11615 | + * __lpfc_sli_issue_iocb is used by other functions in the driver | |
11616 | + * to issue an iocb command to the HBA. If the PCI slot is recovering | |
11617 | + * from error state or if HBA is resetting or if LPFC_STOP_IOCB_EVENT | |
11618 | + * flag is turned on, the function returns IOCB_ERROR. | |
11619 | + * When the link is down, this function allows only iocbs for | |
11620 | + * posting buffers. | |
11621 | + * This function finds next available slot in the command ring and | |
11622 | + * posts the command to the available slot and writes the port | |
11623 | + * attention register to request HBA start processing new iocb. | |
11624 | + * If there is no slot available in the ring and | |
11625 | + * flag & SLI_IOCB_RET_IOCB is set, the new iocb is added to the | |
11626 | + * txq, otherwise the function returns IOCB_BUSY. | |
11627 | + * | |
11628 | + * This function is called with hbalock held. | |
11629 | + * The function will return success after it successfully submit the | |
11630 | + * iocb to firmware or after adding to the txq. | |
11631 | + **/ | |
11632 | static int | |
11633 | __lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
11634 | struct lpfc_iocbq *piocb, uint32_t flag) | |
11635 | @@ -3052,6 +3805,16 @@ __lpfc_sli_issue_iocb(struct lpfc_hba *p | |
11636 | * can be issued if the link is not up. | |
11637 | */ | |
11638 | switch (piocb->iocb.ulpCommand) { | |
11639 | + case CMD_GEN_REQUEST64_CR: | |
11640 | + case CMD_GEN_REQUEST64_CX: | |
11641 | + if (!(phba->sli.sli_flag & LPFC_MENLO_MAINT) || | |
11642 | + (piocb->iocb.un.genreq64.w5.hcsw.Rctl != | |
11643 | + FC_FCP_CMND) || | |
11644 | + (piocb->iocb.un.genreq64.w5.hcsw.Type != | |
11645 | + MENLO_TRANSPORT_TYPE)) | |
11646 | + | |
11647 | + goto iocb_busy; | |
11648 | + break; | |
11649 | case CMD_QUE_RING_BUF_CN: | |
11650 | case CMD_QUE_RING_BUF64_CN: | |
11651 | /* | |
11652 | @@ -3106,6 +3869,19 @@ __lpfc_sli_issue_iocb(struct lpfc_hba *p | |
11653 | } | |
11654 | ||
11655 | ||
11656 | +/** | |
11657 | + * lpfc_sli_issue_iocb: Wrapper function for __lpfc_sli_issue_iocb. | |
11658 | + * @phba: Pointer to HBA context object. | |
11659 | + * @pring: Pointer to driver SLI ring object. | |
11660 | + * @piocb: Pointer to command iocb. | |
11661 | + * @flag: Flag indicating if this command can be put into txq. | |
11662 | + * | |
11663 | + * lpfc_sli_issue_iocb is a wrapper around __lpfc_sli_issue_iocb | |
11664 | + * function. This function gets the hbalock and calls | |
11665 | + * __lpfc_sli_issue_iocb function and will return the error returned | |
11666 | + * by __lpfc_sli_issue_iocb function. This wrapper is used by | |
11667 | + * functions which do not hold hbalock. | |
11668 | + **/ | |
11669 | int | |
11670 | lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
11671 | struct lpfc_iocbq *piocb, uint32_t flag) | |
11672 | @@ -3120,6 +3896,17 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phb | |
11673 | return rc; | |
11674 | } | |
11675 | ||
11676 | +/** | |
11677 | + * lpfc_extra_ring_setup: Extra ring setup function. | |
11678 | + * @phba: Pointer to HBA context object. | |
11679 | + * | |
11680 | + * This function is called while driver attaches with the | |
11681 | + * HBA to setup the extra ring. The extra ring is used | |
11682 | + * only when driver needs to support target mode functionality | |
11683 | + * or IP over FC functionalities. | |
11684 | + * | |
11685 | + * This function is called with no lock held. | |
11686 | + **/ | |
11687 | static int | |
11688 | lpfc_extra_ring_setup( struct lpfc_hba *phba) | |
11689 | { | |
11690 | @@ -3155,6 +3942,19 @@ lpfc_extra_ring_setup( struct lpfc_hba * | |
11691 | return 0; | |
11692 | } | |
11693 | ||
11694 | +/** | |
11695 | + * lpfc_sli_async_event_handler: ASYNC iocb handler function. | |
11696 | + * @phba: Pointer to HBA context object. | |
11697 | + * @pring: Pointer to driver SLI ring object. | |
11698 | + * @iocbq: Pointer to iocb object. | |
11699 | + * | |
11700 | + * This function is called by the slow ring event handler | |
11701 | + * function when there is an ASYNC event iocb in the ring. | |
11702 | + * This function is called with no lock held. | |
11703 | + * Currently this function handles only temperature related | |
11704 | + * ASYNC events. The function decodes the temperature sensor | |
11705 | + * event message and posts events for the management applications. | |
11706 | + **/ | |
11707 | static void | |
11708 | lpfc_sli_async_event_handler(struct lpfc_hba * phba, | |
11709 | struct lpfc_sli_ring * pring, struct lpfc_iocbq * iocbq) | |
11710 | @@ -3210,6 +4010,17 @@ lpfc_sli_async_event_handler(struct lpfc | |
11711 | } | |
11712 | ||
11713 | ||
11714 | +/** | |
11715 | + * lpfc_sli_setup: SLI ring setup function. | |
11716 | + * @phba: Pointer to HBA context object. | |
11717 | + * | |
11718 | + * lpfc_sli_setup sets up rings of the SLI interface with | |
11719 | + * number of iocbs per ring and iotags. This function is | |
11720 | + * called while driver attach to the HBA and before the | |
11721 | + * interrupts are enabled. So there is no need for locking. | |
11722 | + * | |
11723 | + * This function always returns 0. | |
11724 | + **/ | |
11725 | int | |
11726 | lpfc_sli_setup(struct lpfc_hba *phba) | |
11727 | { | |
11728 | @@ -3321,6 +4132,17 @@ lpfc_sli_setup(struct lpfc_hba *phba) | |
11729 | return 0; | |
11730 | } | |
11731 | ||
11732 | +/** | |
11733 | + * lpfc_sli_queue_setup: Queue initialization function. | |
11734 | + * @phba: Pointer to HBA context object. | |
11735 | + * | |
11736 | + * lpfc_sli_queue_setup sets up mailbox queues and iocb queues for each | |
11737 | + * ring. This function also initializes ring indices of each ring. | |
11738 | + * This function is called during the initialization of the SLI | |
11739 | + * interface of an HBA. | |
11740 | + * This function is called with no lock held and always returns | |
11741 | + * 1. | |
11742 | + **/ | |
11743 | int | |
11744 | lpfc_sli_queue_setup(struct lpfc_hba *phba) | |
11745 | { | |
11746 | @@ -3349,6 +4171,23 @@ lpfc_sli_queue_setup(struct lpfc_hba *ph | |
11747 | return 1; | |
11748 | } | |
11749 | ||
11750 | +/** | |
11751 | + * lpfc_sli_host_down: Vport cleanup function. | |
11752 | + * @vport: Pointer to virtual port object. | |
11753 | + * | |
11754 | + * lpfc_sli_host_down is called to clean up the resources | |
11755 | + * associated with a vport before destroying virtual | |
11756 | + * port data structures. | |
11757 | + * This function does following operations: | |
11758 | + * - Free discovery resources associated with this virtual | |
11759 | + * port. | |
11760 | + * - Free iocbs associated with this virtual port in | |
11761 | + * the txq. | |
11762 | + * - Send abort for all iocb commands associated with this | |
11763 | + * vport in txcmplq. | |
11764 | + * | |
11765 | + * This function is called with no lock held and always returns 1. | |
11766 | + **/ | |
11767 | int | |
11768 | lpfc_sli_host_down(struct lpfc_vport *vport) | |
11769 | { | |
11770 | @@ -3411,6 +4250,21 @@ lpfc_sli_host_down(struct lpfc_vport *vp | |
11771 | return 1; | |
11772 | } | |
11773 | ||
11774 | +/** | |
11775 | + * lpfc_sli_hba_down: Resource cleanup function for the HBA. | |
11776 | + * @phba: Pointer to HBA context object. | |
11777 | + * | |
11778 | + * This function cleans up all iocb, buffers, mailbox commands | |
11779 | + * while shutting down the HBA. This function is called with no | |
11780 | + * lock held and always returns 1. | |
11781 | + * This function does the following to cleanup driver resources: | |
11782 | + * - Free discovery resources for each virtual port | |
11783 | + * - Cleanup any pending fabric iocbs | |
11784 | + * - Iterate through the iocb txq and free each entry | |
11785 | + * in the list. | |
11786 | + * - Free up any buffer posted to the HBA | |
11787 | + * - Free mailbox commands in the mailbox queue. | |
11788 | + **/ | |
11789 | int | |
11790 | lpfc_sli_hba_down(struct lpfc_hba *phba) | |
11791 | { | |
11792 | @@ -3501,6 +4355,18 @@ lpfc_sli_hba_down(struct lpfc_hba *phba) | |
11793 | return 1; | |
11794 | } | |
11795 | ||
11796 | +/** | |
11797 | + * lpfc_sli_pcimem_bcopy: SLI memory copy function. | |
11798 | + * @srcp: Source memory pointer. | |
11799 | + * @destp: Destination memory pointer. | |
11800 | + * @cnt: Number of words required to be copied. | |
11801 | + * | |
11802 | + * This function is used for copying data between driver memory | |
11803 | + * and the SLI memory. This function also changes the endianness | |
11804 | + * of each word if native endianness is different from SLI | |
11805 | + * endianness. This function can be called with or without | |
11806 | + * lock. | |
11807 | + **/ | |
11808 | void | |
11809 | lpfc_sli_pcimem_bcopy(void *srcp, void *destp, uint32_t cnt) | |
11810 | { | |
11811 | @@ -3518,6 +4384,17 @@ lpfc_sli_pcimem_bcopy(void *srcp, void * | |
11812 | } | |
11813 | } | |
11814 | ||
11815 | + | |
11816 | +/** | |
11817 | + * lpfc_sli_ringpostbuf_put: Function to add a buffer to postbufq. | |
11818 | + * @phba: Pointer to HBA context object. | |
11819 | + * @pring: Pointer to driver SLI ring object. | |
11820 | + * @mp: Pointer to driver buffer object. | |
11821 | + * | |
11822 | + * This function is called with no lock held. | |
11823 | + * It always return zero after adding the buffer to the postbufq | |
11824 | + * buffer list. | |
11825 | + **/ | |
11826 | int | |
11827 | lpfc_sli_ringpostbuf_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
11828 | struct lpfc_dmabuf *mp) | |
11829 | @@ -3531,6 +4408,18 @@ lpfc_sli_ringpostbuf_put(struct lpfc_hba | |
11830 | return 0; | |
11831 | } | |
11832 | ||
11833 | +/** | |
11834 | + * lpfc_sli_get_buffer_tag: Tag allocation function for a buffer posted | |
11835 | + * using CMD_QUE_XRI64_CX iocb. | |
11836 | + * @phba: Pointer to HBA context object. | |
11837 | + * | |
11838 | + * When HBQ is enabled, buffers are searched based on tags. This function | |
11839 | + * allocates a tag for buffer posted using CMD_QUE_XRI64_CX iocb. The | |
11840 | + * tag is bit wise or-ed with QUE_BUFTAG_BIT to make sure that the tag | |
11841 | + * does not conflict with tags of buffer posted for unsolicited events. | |
11842 | + * The function returns the allocated tag. The function is called with | |
11843 | + * no locks held. | |
11844 | + **/ | |
11845 | uint32_t | |
11846 | lpfc_sli_get_buffer_tag(struct lpfc_hba *phba) | |
11847 | { | |
11848 | @@ -3545,6 +4434,22 @@ lpfc_sli_get_buffer_tag(struct lpfc_hba | |
11849 | return phba->buffer_tag_count; | |
11850 | } | |
11851 | ||
11852 | +/** | |
11853 | + * lpfc_sli_ring_taggedbuf_get: Search HBQ buffer associated with | |
11854 | + * posted using CMD_QUE_XRI64_CX iocb. | |
11855 | + * @phba: Pointer to HBA context object. | |
11856 | + * @pring: Pointer to driver SLI ring object. | |
11857 | + * @tag: Buffer tag. | |
11858 | + * | |
11859 | + * Buffers posted using CMD_QUE_XRI64_CX iocb are in pring->postbufq | |
11860 | + * list. After HBA DMA data to these buffers, CMD_IOCB_RET_XRI64_CX | |
11861 | + * iocb is posted to the response ring with the tag of the buffer. | |
11862 | + * This function searches the pring->postbufq list using the tag | |
11863 | + * to find buffer associated with CMD_IOCB_RET_XRI64_CX | |
11864 | + * iocb. If the buffer is found then lpfc_dmabuf object of the | |
11865 | + * buffer is returned to the caller else NULL is returned. | |
11866 | + * This function is called with no lock held. | |
11867 | + **/ | |
11868 | struct lpfc_dmabuf * | |
11869 | lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
11870 | uint32_t tag) | |
11871 | @@ -3565,7 +4470,7 @@ lpfc_sli_ring_taggedbuf_get(struct lpfc_ | |
11872 | ||
11873 | spin_unlock_irq(&phba->hbalock); | |
11874 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
11875 | - "0410 Cannot find virtual addr for buffer tag on " | |
11876 | + "0402 Cannot find virtual addr for buffer tag on " | |
11877 | "ring %d Data x%lx x%p x%p x%x\n", | |
11878 | pring->ringno, (unsigned long) tag, | |
11879 | slp->next, slp->prev, pring->postbufq_cnt); | |
11880 | @@ -3573,6 +4478,23 @@ lpfc_sli_ring_taggedbuf_get(struct lpfc_ | |
11881 | return NULL; | |
11882 | } | |
11883 | ||
11884 | +/** | |
11885 | + * lpfc_sli_ringpostbuf_get: SLI2 buffer search function for | |
11886 | + * unsolicited ct and els events. | |
11887 | + * @phba: Pointer to HBA context object. | |
11888 | + * @pring: Pointer to driver SLI ring object. | |
11889 | + * @phys: DMA address of the buffer. | |
11890 | + * | |
11891 | + * This function searches the buffer list using the dma_address | |
11892 | + * of unsolicited event to find the driver's lpfc_dmabuf object | |
11893 | + * corresponding to the dma_address. The function returns the | |
11894 | + * lpfc_dmabuf object if a buffer is found else it returns NULL. | |
11895 | + * This function is called by the ct and els unsolicited event | |
11896 | + * handlers to get the buffer associated with the unsolicited | |
11897 | + * event. | |
11898 | + * | |
11899 | + * This function is called with no lock held. | |
11900 | + **/ | |
11901 | struct lpfc_dmabuf * | |
11902 | lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
11903 | dma_addr_t phys) | |
11904 | @@ -3600,6 +4522,17 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba | |
11905 | return NULL; | |
11906 | } | |
11907 | ||
11908 | +/** | |
11909 | + * lpfc_sli_abort_els_cmpl: Completion handler for the els abort iocbs. | |
11910 | + * @phba: Pointer to HBA context object. | |
11911 | + * @cmdiocb: Pointer to driver command iocb object. | |
11912 | + * @rspiocb: Pointer to driver response iocb object. | |
11913 | + * | |
11914 | + * This function is the completion handler for the abort iocbs for | |
11915 | + * ELS commands. This function is called from the ELS ring event | |
11916 | + * handler with no lock held. This function frees memory resources | |
11917 | + * associated with the abort iocb. | |
11918 | + **/ | |
11919 | static void | |
11920 | lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
11921 | struct lpfc_iocbq *rspiocb) | |
11922 | @@ -3665,6 +4598,17 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba | |
11923 | return; | |
11924 | } | |
11925 | ||
11926 | +/** | |
11927 | + * lpfc_ignore_els_cmpl: Completion handler for aborted ELS command. | |
11928 | + * @phba: Pointer to HBA context object. | |
11929 | + * @cmdiocb: Pointer to driver command iocb object. | |
11930 | + * @rspiocb: Pointer to driver response iocb object. | |
11931 | + * | |
11932 | + * The function is called from SLI ring event handler with no | |
11933 | + * lock held. This function is the completion handler for ELS commands | |
11934 | + * which are aborted. The function frees memory resources used for | |
11935 | + * the aborted ELS commands. | |
11936 | + **/ | |
11937 | static void | |
11938 | lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
11939 | struct lpfc_iocbq *rspiocb) | |
11940 | @@ -3673,7 +4617,7 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *ph | |
11941 | ||
11942 | /* ELS cmd tag <ulpIoTag> completes */ | |
11943 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, | |
11944 | - "0133 Ignoring ELS cmd tag x%x completion Data: " | |
11945 | + "0139 Ignoring ELS cmd tag x%x completion Data: " | |
11946 | "x%x x%x x%x\n", | |
11947 | irsp->ulpIoTag, irsp->ulpStatus, | |
11948 | irsp->un.ulpWord[4], irsp->ulpTimeout); | |
11949 | @@ -3684,6 +4628,17 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *ph | |
11950 | return; | |
11951 | } | |
11952 | ||
11953 | +/** | |
11954 | + * lpfc_sli_issue_abort_iotag: Abort function for a command iocb. | |
11955 | + * @phba: Pointer to HBA context object. | |
11956 | + * @pring: Pointer to driver SLI ring object. | |
11957 | + * @cmdiocb: Pointer to driver command iocb object. | |
11958 | + * | |
11959 | + * This function issues an abort iocb for the provided command | |
11960 | + * iocb. This function is called with hbalock held. | |
11961 | + * The function returns 0 when it fails due to memory allocation | |
11962 | + * failure or when the command iocb is an abort request. | |
11963 | + **/ | |
11964 | int | |
11965 | lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |
11966 | struct lpfc_iocbq *cmdiocb) | |
11967 | @@ -3748,6 +4703,8 @@ lpfc_sli_issue_abort_iotag(struct lpfc_h | |
11968 | iabt->un.acxri.abortIoTag, abtsiocbp->iotag); | |
11969 | retval = __lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0); | |
11970 | ||
11971 | + if (retval) | |
11972 | + __lpfc_sli_release_iocbq(phba, abtsiocbp); | |
11973 | abort_iotag_exit: | |
11974 | /* | |
11975 | * Caller to this routine should check for IOCB_ERROR | |
11976 | @@ -3757,6 +4714,29 @@ abort_iotag_exit: | |
11977 | return retval; | |
11978 | } | |
11979 | ||
11980 | +/** | |
11981 | + * lpfc_sli_validate_fcp_iocb: Filtering function, used to find commands | |
11982 | + * associated with a vport/SCSI target/lun. | |
11983 | + * @iocbq: Pointer to driver iocb object. | |
11984 | + * @vport: Pointer to driver virtual port object. | |
11985 | + * @tgt_id: SCSI ID of the target. | |
11986 | + * @lun_id: LUN ID of the scsi device. | |
11987 | + * @ctx_cmd: LPFC_CTX_LUN/LPFC_CTX_TGT/LPFC_CTX_HOST | |
11988 | + * | |
11989 | + * This function acts as iocb filter for functions which abort or count | |
11990 | + * all FCP iocbs pending on a lun/SCSI target/SCSI host. It will return | |
11991 | + * 0 if the filtering criteria is met for the given iocb and will return | |
11992 | + * 1 if the filtering criteria is not met. | |
11993 | + * If ctx_cmd == LPFC_CTX_LUN, the function returns 0 only if the | |
11994 | + * given iocb is for the SCSI device specified by vport, tgt_id and | |
11995 | + * lun_id parameter. | |
11996 | + * If ctx_cmd == LPFC_CTX_TGT, the function returns 0 only if the | |
11997 | + * given iocb is for the SCSI target specified by vport and tgt_id | |
11998 | + * parameters. | |
11999 | + * If ctx_cmd == LPFC_CTX_HOST, the function returns 0 only if the | |
12000 | + * given iocb is for the SCSI host associated with the given vport. | |
12001 | + * This function is called with no locks held. | |
12002 | + **/ | |
12003 | static int | |
12004 | lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, struct lpfc_vport *vport, | |
12005 | uint16_t tgt_id, uint64_t lun_id, | |
12006 | @@ -3800,6 +4780,25 @@ lpfc_sli_validate_fcp_iocb(struct lpfc_i | |
12007 | return rc; | |
12008 | } | |
12009 | ||
12010 | +/** | |
12011 | + * lpfc_sli_sum_iocb: Function to count the number of FCP iocbs pending. | |
12012 | + * @vport: Pointer to virtual port. | |
12013 | + * @tgt_id: SCSI ID of the target. | |
12014 | + * @lun_id: LUN ID of the scsi device. | |
12015 | + * @ctx_cmd: LPFC_CTX_LUN/LPFC_CTX_TGT/LPFC_CTX_HOST. | |
12016 | + * | |
12017 | + * This function returns number of FCP commands pending for the vport. | |
12018 | + * When ctx_cmd == LPFC_CTX_LUN, the function returns number of FCP | |
12019 | + * commands pending on the vport associated with SCSI device specified | |
12020 | + * by tgt_id and lun_id parameters. | |
12021 | + * When ctx_cmd == LPFC_CTX_TGT, the function returns number of FCP | |
12022 | + * commands pending on the vport associated with SCSI target specified | |
12023 | + * by tgt_id parameter. | |
12024 | + * When ctx_cmd == LPFC_CTX_HOST, the function returns number of FCP | |
12025 | + * commands pending on the vport. | |
12026 | + * This function returns the number of iocbs which satisfy the filter. | |
12027 | + * This function is called without any lock held. | |
12028 | + **/ | |
12029 | int | |
12030 | lpfc_sli_sum_iocb(struct lpfc_vport *vport, uint16_t tgt_id, uint64_t lun_id, | |
12031 | lpfc_ctx_cmd ctx_cmd) | |
12032 | @@ -3819,6 +4818,17 @@ lpfc_sli_sum_iocb(struct lpfc_vport *vpo | |
12033 | return sum; | |
12034 | } | |
12035 | ||
12036 | +/** | |
12037 | + * lpfc_sli_abort_fcp_cmpl: Completion handler function for an aborted | |
12038 | + * FCP iocb. | |
12039 | + * @phba: Pointer to HBA context object | |
12040 | + * @cmdiocb: Pointer to command iocb object. | |
12041 | + * @rspiocb: Pointer to response iocb object. | |
12042 | + * | |
12043 | + * This function is called when an aborted FCP iocb completes. This | |
12044 | + * function is called by the ring event handler with no lock held. | |
12045 | + * This function frees the iocb. | |
12046 | + **/ | |
12047 | void | |
12048 | lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
12049 | struct lpfc_iocbq *rspiocb) | |
12050 | @@ -3827,6 +4837,28 @@ lpfc_sli_abort_fcp_cmpl(struct lpfc_hba | |
12051 | return; | |
12052 | } | |
12053 | ||
12054 | +/** | |
12055 | + * lpfc_sli_abort_iocb: This function issue abort for all SCSI commands | |
12056 | + * pending on a SCSI host(vport)/target/lun. | |
12057 | + * @vport: Pointer to virtual port. | |
12058 | + * @pring: Pointer to driver SLI ring object. | |
12059 | + * @tgt_id: SCSI ID of the target. | |
12060 | + * @lun_id: LUN ID of the scsi device. | |
12061 | + * @abort_cmd: LPFC_CTX_LUN/LPFC_CTX_TGT/LPFC_CTX_HOST. | |
12062 | + * | |
12063 | + * This function sends an abort command for every SCSI command | |
12064 | + * associated with the given virtual port pending on the ring | |
12065 | + * filtered by lpfc_sli_validate_fcp_iocb function. | |
12066 | + * When abort_cmd == LPFC_CTX_LUN, the function sends abort only to the | |
12067 | + * FCP iocbs associated with lun specified by tgt_id and lun_id | |
12068 | + * parameters | |
12069 | + * When abort_cmd == LPFC_CTX_TGT, the function sends abort only to the | |
12070 | + * FCP iocbs associated with SCSI target specified by tgt_id parameter. | |
12071 | + * When abort_cmd == LPFC_CTX_HOST, the function sends abort to all | |
12072 | + * FCP iocbs associated with virtual port. | |
12073 | + * This function returns number of iocbs it failed to abort. | |
12074 | + * This function is called with no locks held. | |
12075 | + **/ | |
12076 | int | |
12077 | lpfc_sli_abort_iocb(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, | |
12078 | uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd abort_cmd) | |
12079 | @@ -3878,6 +4910,24 @@ lpfc_sli_abort_iocb(struct lpfc_vport *v | |
12080 | return errcnt; | |
12081 | } | |
12082 | ||
12083 | +/** | |
12084 | + * lpfc_sli_wake_iocb_wait: iocb completion handler for iocb issued using | |
12085 | + * lpfc_sli_issue_iocb_wait. | |
12086 | + * @phba: Pointer to HBA context object. | |
12087 | + * @cmdiocbq: Pointer to command iocb. | |
12088 | + * @rspiocbq: Pointer to response iocb. | |
12089 | + * | |
12090 | + * This function is the completion handler for iocbs issued using | |
12091 | + * lpfc_sli_issue_iocb_wait function. This function is called by the | |
12092 | + * ring event handler function without any lock held. This function | |
12093 | + * can be called from both worker thread context and interrupt | |
12094 | + * context. This function also can be called from other thread which | |
12095 | + * cleans up the SLI layer objects. | |
12096 | + * This function copy the contents of the response iocb to the | |
12097 | + * response iocb memory object provided by the caller of | |
12098 | + * lpfc_sli_issue_iocb_wait and then wakes up the thread which | |
12099 | + * sleeps for the iocb completion. | |
12100 | + **/ | |
12101 | static void | |
12102 | lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, | |
12103 | struct lpfc_iocbq *cmdiocbq, | |
12104 | @@ -3899,13 +4949,36 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba | |
12105 | return; | |
12106 | } | |
12107 | ||
12108 | -/* | |
12109 | - * Issue the caller's iocb and wait for its completion, but no longer than the | |
12110 | - * caller's timeout. Note that iocb_flags is cleared before the | |
12111 | - * lpfc_sli_issue_call since the wake routine sets a unique value and by | |
12112 | - * definition this is a wait function. | |
12113 | - */ | |
12114 | - | |
12115 | +/** | |
12116 | + * lpfc_sli_issue_iocb_wait: Synchronous function to issue iocb commands. | |
12117 | + * @phba: Pointer to HBA context object.. | |
12118 | + * @pring: Pointer to sli ring. | |
12119 | + * @piocb: Pointer to command iocb. | |
12120 | + * @prspiocbq: Pointer to response iocb. | |
12121 | + * @timeout: Timeout in number of seconds. | |
12122 | + * | |
12123 | + * This function issues the iocb to firmware and waits for the | |
12124 | + * iocb to complete. If the iocb command is not | |
12125 | + * completed within timeout seconds, it returns IOCB_TIMEDOUT. | |
12126 | + * Caller should not free the iocb resources if this function | |
12127 | + * returns IOCB_TIMEDOUT. | |
12128 | + * The function waits for the iocb completion using an | |
12129 | + * non-interruptible wait. | |
12130 | + * This function will sleep while waiting for iocb completion. | |
12131 | + * So, this function should not be called from any context which | |
12132 | + * does not allow sleeping. Due to the same reason, this function | |
12133 | + * cannot be called with interrupt disabled. | |
12134 | + * This function assumes that the iocb completions occur while | |
12135 | + * this function sleep. So, this function cannot be called from | |
12136 | + * the thread which process iocb completion for this ring. | |
12137 | + * This function clears the iocb_flag of the iocb object before | |
12138 | + * issuing the iocb and the iocb completion handler sets this | |
12139 | + * flag and wakes this thread when the iocb completes. | |
12140 | + * The contents of the response iocb will be copied to prspiocbq | |
12141 | + * by the completion handler when the command completes. | |
12142 | + * This function returns IOCB_SUCCESS when success. | |
12143 | + * This function is called with no lock held. | |
12144 | + **/ | |
12145 | int | |
12146 | lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, | |
12147 | struct lpfc_sli_ring *pring, | |
12148 | @@ -3963,7 +5036,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba | |
12149 | } | |
12150 | } else { | |
12151 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | |
12152 | - ":0332 IOCB wait issue failed, Data x%x\n", | |
12153 | + "0332 IOCB wait issue failed, Data x%x\n", | |
12154 | retval); | |
12155 | retval = IOCB_ERROR; | |
12156 | } | |
12157 | @@ -3983,6 +5056,32 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba | |
12158 | return retval; | |
12159 | } | |
12160 | ||
12161 | +/** | |
12162 | + * lpfc_sli_issue_mbox_wait: Synchronous function to issue mailbox. | |
12163 | + * @phba: Pointer to HBA context object. | |
12164 | + * @pmboxq: Pointer to driver mailbox object. | |
12165 | + * @timeout: Timeout in number of seconds. | |
12166 | + * | |
12167 | + * This function issues the mailbox to firmware and waits for the | |
12168 | + * mailbox command to complete. If the mailbox command is not | |
12169 | + * completed within timeout seconds, it returns MBX_TIMEOUT. | |
12170 | + * The function waits for the mailbox completion using an | |
12171 | + * interruptible wait. If the thread is woken up due to a | |
12172 | + * signal, MBX_TIMEOUT error is returned to the caller. Caller | |
12173 | + * should not free the mailbox resources, if this function returns | |
12174 | + * MBX_TIMEOUT. | |
12175 | + * This function will sleep while waiting for mailbox completion. | |
12176 | + * So, this function should not be called from any context which | |
12177 | + * does not allow sleeping. Due to the same reason, this function | |
12178 | + * cannot be called with interrupt disabled. | |
12179 | + * This function assumes that the mailbox completion occurs while | |
12180 | + * this function sleep. So, this function cannot be called from | |
12181 | + * the worker thread which processes mailbox completion. | |
12182 | + * This function is called in the context of HBA management | |
12183 | + * applications. | |
12184 | + * This function returns MBX_SUCCESS when successful. | |
12185 | + * This function is called with no lock held. | |
12186 | + **/ | |
12187 | int | |
12188 | lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq, | |
12189 | uint32_t timeout) | |
12190 | @@ -4027,6 +5126,18 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba | |
12191 | return retval; | |
12192 | } | |
12193 | ||
12194 | +/** | |
12195 | + * lpfc_sli_flush_mbox_queue: mailbox queue cleanup function. | |
12196 | + * @phba: Pointer to HBA context. | |
12197 | + * | |
12198 | + * This function is called to cleanup any pending mailbox | |
12199 | + * objects in the driver queue before bringing the HBA offline. | |
12200 | + * This function is called while resetting the HBA. | |
12201 | + * The function is called without any lock held. The function | |
12202 | + * takes hbalock to update SLI data structure. | |
12203 | + * This function returns 1 when there is an active mailbox | |
12204 | + * command pending else returns 0. | |
12205 | + **/ | |
12206 | int | |
12207 | lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba) | |
12208 | { | |
12209 | @@ -4058,8 +5169,74 @@ lpfc_sli_flush_mbox_queue(struct lpfc_hb | |
12210 | return (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) ? 1 : 0; | |
12211 | } | |
12212 | ||
12213 | +/** | |
12214 | + * lpfc_sli_check_eratt: check error attention events | |
12215 | + * @phba: Pointer to HBA context. | |
12216 | + * | |
12217 | + * This function is called form timer soft interrupt context to check HBA's | |
12218 | + * error attention register bit for error attention events. | |
12219 | + * | |
12220 | + * This fucntion returns 1 when there is Error Attention in the Host Attention | |
12221 | + * Register and returns 0 otherwise. | |
12222 | + **/ | |
12223 | +int | |
12224 | +lpfc_sli_check_eratt(struct lpfc_hba *phba) | |
12225 | +{ | |
12226 | + uint32_t ha_copy; | |
12227 | + | |
12228 | + /* If somebody is waiting to handle an eratt, don't process it | |
12229 | + * here. The brdkill function will do this. | |
12230 | + */ | |
12231 | + if (phba->link_flag & LS_IGNORE_ERATT) | |
12232 | + return 0; | |
12233 | + | |
12234 | + /* Check if interrupt handler handles this ERATT */ | |
12235 | + spin_lock_irq(&phba->hbalock); | |
12236 | + if (phba->hba_flag & HBA_ERATT_HANDLED) { | |
12237 | + /* Interrupt handler has handled ERATT */ | |
12238 | + spin_unlock_irq(&phba->hbalock); | |
12239 | + return 0; | |
12240 | + } | |
12241 | + | |
12242 | + /* Read chip Host Attention (HA) register */ | |
12243 | + ha_copy = readl(phba->HAregaddr); | |
12244 | + if (ha_copy & HA_ERATT) { | |
12245 | + /* Read host status register to retrieve error event */ | |
12246 | + lpfc_sli_read_hs(phba); | |
12247 | + /* Set the driver HA work bitmap */ | |
12248 | + phba->work_ha |= HA_ERATT; | |
12249 | + /* Indicate polling handles this ERATT */ | |
12250 | + phba->hba_flag |= HBA_ERATT_HANDLED; | |
12251 | + spin_unlock_irq(&phba->hbalock); | |
12252 | + return 1; | |
12253 | + } | |
12254 | + spin_unlock_irq(&phba->hbalock); | |
12255 | + return 0; | |
12256 | +} | |
12257 | + | |
12258 | +/** | |
12259 | + * lpfc_sp_intr_handler: The slow-path interrupt handler of lpfc driver. | |
12260 | + * @irq: Interrupt number. | |
12261 | + * @dev_id: The device context pointer. | |
12262 | + * | |
12263 | + * This function is directly called from the PCI layer as an interrupt | |
12264 | + * service routine when the device is enabled with MSI-X multi-message | |
12265 | + * interrupt mode and there are slow-path events in the HBA. However, | |
12266 | + * when the device is enabled with either MSI or Pin-IRQ interrupt mode, | |
12267 | + * this function is called as part of the device-level interrupt handler. | |
12268 | + * When the PCI slot is in error recovery or the HBA is undergoing | |
12269 | + * initialization, the interrupt handler will not process the interrupt. | |
12270 | + * The link attention and ELS ring attention events are handled by the | |
12271 | + * worker thread. The interrupt handler signals the worker thread and | |
12272 | + * and returns for these events. This function is called without any | |
12273 | + * lock held. It gets the hbalock to access and update SLI data | |
12274 | + * structures. | |
12275 | + * | |
12276 | + * This function returns IRQ_HANDLED when interrupt is handled else it | |
12277 | + * returns IRQ_NONE. | |
12278 | + **/ | |
12279 | irqreturn_t | |
12280 | -lpfc_intr_handler(int irq, void *dev_id) | |
12281 | +lpfc_sp_intr_handler(int irq, void *dev_id) | |
12282 | { | |
12283 | struct lpfc_hba *phba; | |
12284 | uint32_t ha_copy; | |
12285 | @@ -4078,48 +5255,52 @@ lpfc_intr_handler(int irq, void *dev_id) | |
12286 | * Get the driver's phba structure from the dev_id and | |
12287 | * assume the HBA is not interrupting. | |
12288 | */ | |
12289 | - phba = (struct lpfc_hba *) dev_id; | |
12290 | + phba = (struct lpfc_hba *)dev_id; | |
12291 | ||
12292 | if (unlikely(!phba)) | |
12293 | return IRQ_NONE; | |
12294 | ||
12295 | - /* If the pci channel is offline, ignore all the interrupts. */ | |
12296 | - if (unlikely(pci_channel_offline(phba->pcidev))) | |
12297 | - return IRQ_NONE; | |
12298 | - | |
12299 | - phba->sli.slistat.sli_intr++; | |
12300 | - | |
12301 | /* | |
12302 | - * Call the HBA to see if it is interrupting. If not, don't claim | |
12303 | - * the interrupt | |
12304 | - */ | |
12305 | - | |
12306 | - /* Ignore all interrupts during initialization. */ | |
12307 | - if (unlikely(phba->link_state < LPFC_LINK_DOWN)) | |
12308 | - return IRQ_NONE; | |
12309 | - | |
12310 | - /* | |
12311 | - * Read host attention register to determine interrupt source | |
12312 | - * Clear Attention Sources, except Error Attention (to | |
12313 | - * preserve status) and Link Attention | |
12314 | - */ | |
12315 | - spin_lock(&phba->hbalock); | |
12316 | - ha_copy = readl(phba->HAregaddr); | |
12317 | - /* If somebody is waiting to handle an eratt don't process it | |
12318 | - * here. The brdkill function will do this. | |
12319 | + * Stuff needs to be attented to when this function is invoked as an | |
12320 | + * individual interrupt handler in MSI-X multi-message interrupt mode | |
12321 | */ | |
12322 | - if (phba->link_flag & LS_IGNORE_ERATT) | |
12323 | - ha_copy &= ~HA_ERATT; | |
12324 | - writel((ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); | |
12325 | - readl(phba->HAregaddr); /* flush */ | |
12326 | - spin_unlock(&phba->hbalock); | |
12327 | - | |
12328 | - if (unlikely(!ha_copy)) | |
12329 | - return IRQ_NONE; | |
12330 | + if (phba->intr_type == MSIX) { | |
12331 | + /* If the pci channel is offline, ignore all the interrupts */ | |
12332 | + if (unlikely(pci_channel_offline(phba->pcidev))) | |
12333 | + return IRQ_NONE; | |
12334 | + /* Update device-level interrupt statistics */ | |
12335 | + phba->sli.slistat.sli_intr++; | |
12336 | + /* Ignore all interrupts during initialization. */ | |
12337 | + if (unlikely(phba->link_state < LPFC_LINK_DOWN)) | |
12338 | + return IRQ_NONE; | |
12339 | + /* Need to read HA REG for slow-path events */ | |
12340 | + spin_lock(&phba->hbalock); | |
12341 | + ha_copy = readl(phba->HAregaddr); | |
12342 | + /* If somebody is waiting to handle an eratt don't process it | |
12343 | + * here. The brdkill function will do this. | |
12344 | + */ | |
12345 | + if (phba->link_flag & LS_IGNORE_ERATT) | |
12346 | + ha_copy &= ~HA_ERATT; | |
12347 | + /* Check the need for handling ERATT in interrupt handler */ | |
12348 | + if (ha_copy & HA_ERATT) { | |
12349 | + if (phba->hba_flag & HBA_ERATT_HANDLED) | |
12350 | + /* ERATT polling has handled ERATT */ | |
12351 | + ha_copy &= ~HA_ERATT; | |
12352 | + else | |
12353 | + /* Indicate interrupt handler handles ERATT */ | |
12354 | + phba->hba_flag |= HBA_ERATT_HANDLED; | |
12355 | + } | |
12356 | + /* Clear up only attention source related to slow-path */ | |
12357 | + writel((ha_copy & (HA_MBATT | HA_R2_CLR_MSK)), | |
12358 | + phba->HAregaddr); | |
12359 | + readl(phba->HAregaddr); /* flush */ | |
12360 | + spin_unlock(&phba->hbalock); | |
12361 | + } else | |
12362 | + ha_copy = phba->ha_copy; | |
12363 | ||
12364 | work_ha_copy = ha_copy & phba->work_ha_mask; | |
12365 | ||
12366 | - if (unlikely(work_ha_copy)) { | |
12367 | + if (work_ha_copy) { | |
12368 | if (work_ha_copy & HA_LATT) { | |
12369 | if (phba->sli.sli_flag & LPFC_PROCESS_LA) { | |
12370 | /* | |
12371 | @@ -4138,7 +5319,7 @@ lpfc_intr_handler(int irq, void *dev_id) | |
12372 | work_ha_copy &= ~HA_LATT; | |
12373 | } | |
12374 | ||
12375 | - if (work_ha_copy & ~(HA_ERATT|HA_MBATT|HA_LATT)) { | |
12376 | + if (work_ha_copy & ~(HA_ERATT | HA_MBATT | HA_LATT)) { | |
12377 | /* | |
12378 | * Turn off Slow Rings interrupts, LPFC_ELS_RING is | |
12379 | * the only slow ring. | |
12380 | @@ -4179,31 +5360,13 @@ lpfc_intr_handler(int irq, void *dev_id) | |
12381 | spin_unlock(&phba->hbalock); | |
12382 | } | |
12383 | } | |
12384 | - | |
12385 | - if (work_ha_copy & HA_ERATT) { | |
12386 | - /* | |
12387 | - * There was a link/board error. Read the | |
12388 | - * status register to retrieve the error event | |
12389 | - * and process it. | |
12390 | - */ | |
12391 | - phba->sli.slistat.err_attn_event++; | |
12392 | - /* Save status info */ | |
12393 | - phba->work_hs = readl(phba->HSregaddr); | |
12394 | - phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); | |
12395 | - phba->work_status[1] = readl(phba->MBslimaddr + 0xac); | |
12396 | - | |
12397 | - /* Clear Chip error bit */ | |
12398 | - writel(HA_ERATT, phba->HAregaddr); | |
12399 | - readl(phba->HAregaddr); /* flush */ | |
12400 | - phba->pport->stopped = 1; | |
12401 | - } | |
12402 | - | |
12403 | spin_lock(&phba->hbalock); | |
12404 | - if ((work_ha_copy & HA_MBATT) && | |
12405 | - (phba->sli.mbox_active)) { | |
12406 | + if (work_ha_copy & HA_ERATT) | |
12407 | + lpfc_sli_read_hs(phba); | |
12408 | + if ((work_ha_copy & HA_MBATT) && (phba->sli.mbox_active)) { | |
12409 | pmb = phba->sli.mbox_active; | |
12410 | pmbox = &pmb->mb; | |
12411 | - mbox = &phba->slim2p->mbx; | |
12412 | + mbox = phba->mbox; | |
12413 | vport = pmb->vport; | |
12414 | ||
12415 | /* First check out the status word */ | |
12416 | @@ -4270,7 +5433,7 @@ lpfc_intr_handler(int irq, void *dev_id) | |
12417 | lpfc_printf_log(phba, | |
12418 | KERN_ERR, | |
12419 | LOG_MBOX | LOG_SLI, | |
12420 | - "0306 rc should have" | |
12421 | + "0350 rc should have" | |
12422 | "been MBX_BUSY"); | |
12423 | goto send_current_mbox; | |
12424 | } | |
12425 | @@ -4283,6 +5446,7 @@ lpfc_intr_handler(int irq, void *dev_id) | |
12426 | } | |
12427 | } else | |
12428 | spin_unlock(&phba->hbalock); | |
12429 | + | |
12430 | if ((work_ha_copy & HA_MBATT) && | |
12431 | (phba->sli.mbox_active == NULL)) { | |
12432 | send_current_mbox: | |
12433 | @@ -4302,15 +5466,74 @@ send_current_mbox: | |
12434 | spin_unlock(&phba->hbalock); | |
12435 | lpfc_worker_wake_up(phba); | |
12436 | } | |
12437 | + return IRQ_HANDLED; | |
12438 | ||
12439 | - ha_copy &= ~(phba->work_ha_mask); | |
12440 | +} /* lpfc_sp_intr_handler */ | |
12441 | + | |
12442 | +/** | |
12443 | + * lpfc_fp_intr_handler: The fast-path interrupt handler of lpfc driver. | |
12444 | + * @irq: Interrupt number. | |
12445 | + * @dev_id: The device context pointer. | |
12446 | + * | |
12447 | + * This function is directly called from the PCI layer as an interrupt | |
12448 | + * service routine when the device is enabled with MSI-X multi-message | |
12449 | + * interrupt mode and there is a fast-path FCP IOCB ring event in the | |
12450 | + * HBA. However, when the device is enabled with either MSI or Pin-IRQ | |
12451 | + * interrupt mode, this function is called as part of the device-level | |
12452 | + * interrupt handler. When the PCI slot is in error recovery or the HBA | |
12453 | + * is undergoing initialization, the interrupt handler will not process | |
12454 | + * the interrupt. The SCSI FCP fast-path ring event are handled in the | |
12455 | + * intrrupt context. This function is called without any lock held. It | |
12456 | + * gets the hbalock to access and update SLI data structures. | |
12457 | + * | |
12458 | + * This function returns IRQ_HANDLED when interrupt is handled else it | |
12459 | + * returns IRQ_NONE. | |
12460 | + **/ | |
12461 | +irqreturn_t | |
12462 | +lpfc_fp_intr_handler(int irq, void *dev_id) | |
12463 | +{ | |
12464 | + struct lpfc_hba *phba; | |
12465 | + uint32_t ha_copy; | |
12466 | + unsigned long status; | |
12467 | + | |
12468 | + /* Get the driver's phba structure from the dev_id and | |
12469 | + * assume the HBA is not interrupting. | |
12470 | + */ | |
12471 | + phba = (struct lpfc_hba *) dev_id; | |
12472 | + | |
12473 | + if (unlikely(!phba)) | |
12474 | + return IRQ_NONE; | |
12475 | + | |
12476 | + /* | |
12477 | + * Stuff needs to be attented to when this function is invoked as an | |
12478 | + * individual interrupt handler in MSI-X multi-message interrupt mode | |
12479 | + */ | |
12480 | + if (phba->intr_type == MSIX) { | |
12481 | + /* If pci channel is offline, ignore all the interrupts */ | |
12482 | + if (unlikely(pci_channel_offline(phba->pcidev))) | |
12483 | + return IRQ_NONE; | |
12484 | + /* Update device-level interrupt statistics */ | |
12485 | + phba->sli.slistat.sli_intr++; | |
12486 | + /* Ignore all interrupts during initialization. */ | |
12487 | + if (unlikely(phba->link_state < LPFC_LINK_DOWN)) | |
12488 | + return IRQ_NONE; | |
12489 | + /* Need to read HA REG for FCP ring and other ring events */ | |
12490 | + ha_copy = readl(phba->HAregaddr); | |
12491 | + /* Clear up only attention source related to fast-path */ | |
12492 | + spin_lock(&phba->hbalock); | |
12493 | + writel((ha_copy & (HA_R0_CLR_MSK | HA_R1_CLR_MSK)), | |
12494 | + phba->HAregaddr); | |
12495 | + readl(phba->HAregaddr); /* flush */ | |
12496 | + spin_unlock(&phba->hbalock); | |
12497 | + } else | |
12498 | + ha_copy = phba->ha_copy; | |
12499 | ||
12500 | /* | |
12501 | - * Process all events on FCP ring. Take the optimized path for | |
12502 | - * FCP IO. Any other IO is slow path and is handled by | |
12503 | - * the worker thread. | |
12504 | + * Process all events on FCP ring. Take the optimized path for FCP IO. | |
12505 | */ | |
12506 | - status = (ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); | |
12507 | + ha_copy &= ~(phba->work_ha_mask); | |
12508 | + | |
12509 | + status = (ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); | |
12510 | status >>= (4*LPFC_FCP_RING); | |
12511 | if (status & HA_RXMASK) | |
12512 | lpfc_sli_handle_fast_ring_event(phba, | |
12513 | @@ -4319,11 +5542,10 @@ send_current_mbox: | |
12514 | ||
12515 | if (phba->cfg_multi_ring_support == 2) { | |
12516 | /* | |
12517 | - * Process all events on extra ring. Take the optimized path | |
12518 | - * for extra ring IO. Any other IO is slow path and is handled | |
12519 | - * by the worker thread. | |
12520 | + * Process all events on extra ring. Take the optimized path | |
12521 | + * for extra ring IO. | |
12522 | */ | |
12523 | - status = (ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); | |
12524 | + status = (ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); | |
12525 | status >>= (4*LPFC_EXTRA_RING); | |
12526 | if (status & HA_RXMASK) { | |
12527 | lpfc_sli_handle_fast_ring_event(phba, | |
12528 | @@ -4332,5 +5554,106 @@ send_current_mbox: | |
12529 | } | |
12530 | } | |
12531 | return IRQ_HANDLED; | |
12532 | +} /* lpfc_fp_intr_handler */ | |
12533 | + | |
12534 | +/** | |
12535 | + * lpfc_intr_handler: The device-level interrupt handler of lpfc driver. | |
12536 | + * @irq: Interrupt number. | |
12537 | + * @dev_id: The device context pointer. | |
12538 | + * | |
12539 | + * This function is the device-level interrupt handler called from the PCI | |
12540 | + * layer when either MSI or Pin-IRQ interrupt mode is enabled and there is | |
12541 | + * an event in the HBA which requires driver attention. This function | |
12542 | + * invokes the slow-path interrupt attention handling function and fast-path | |
12543 | + * interrupt attention handling function in turn to process the relevant | |
12544 | + * HBA attention events. This function is called without any lock held. It | |
12545 | + * gets the hbalock to access and update SLI data structures. | |
12546 | + * | |
12547 | + * This function returns IRQ_HANDLED when interrupt is handled, else it | |
12548 | + * returns IRQ_NONE. | |
12549 | + **/ | |
12550 | +irqreturn_t | |
12551 | +lpfc_intr_handler(int irq, void *dev_id) | |
12552 | +{ | |
12553 | + struct lpfc_hba *phba; | |
12554 | + irqreturn_t sp_irq_rc, fp_irq_rc; | |
12555 | + unsigned long status1, status2; | |
12556 | + | |
12557 | + /* | |
12558 | + * Get the driver's phba structure from the dev_id and | |
12559 | + * assume the HBA is not interrupting. | |
12560 | + */ | |
12561 | + phba = (struct lpfc_hba *) dev_id; | |
12562 | + | |
12563 | + if (unlikely(!phba)) | |
12564 | + return IRQ_NONE; | |
12565 | + | |
12566 | + /* If the pci channel is offline, ignore all the interrupts. */ | |
12567 | + if (unlikely(pci_channel_offline(phba->pcidev))) | |
12568 | + return IRQ_NONE; | |
12569 | + | |
12570 | + /* Update device level interrupt statistics */ | |
12571 | + phba->sli.slistat.sli_intr++; | |
12572 | + | |
12573 | + /* Ignore all interrupts during initialization. */ | |
12574 | + if (unlikely(phba->link_state < LPFC_LINK_DOWN)) | |
12575 | + return IRQ_NONE; | |
12576 | + | |
12577 | + spin_lock(&phba->hbalock); | |
12578 | + phba->ha_copy = readl(phba->HAregaddr); | |
12579 | + if (unlikely(!phba->ha_copy)) { | |
12580 | + spin_unlock(&phba->hbalock); | |
12581 | + return IRQ_NONE; | |
12582 | + } else if (phba->ha_copy & HA_ERATT) { | |
12583 | + if (phba->hba_flag & HBA_ERATT_HANDLED) | |
12584 | + /* ERATT polling has handled ERATT */ | |
12585 | + phba->ha_copy &= ~HA_ERATT; | |
12586 | + else | |
12587 | + /* Indicate interrupt handler handles ERATT */ | |
12588 | + phba->hba_flag |= HBA_ERATT_HANDLED; | |
12589 | + } | |
12590 | + | |
12591 | + /* Clear attention sources except link and error attentions */ | |
12592 | + writel((phba->ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); | |
12593 | + readl(phba->HAregaddr); /* flush */ | |
12594 | + spin_unlock(&phba->hbalock); | |
12595 | + | |
12596 | + /* | |
12597 | + * Invokes slow-path host attention interrupt handling as appropriate. | |
12598 | + */ | |
12599 | + | |
12600 | + /* status of events with mailbox and link attention */ | |
12601 | + status1 = phba->ha_copy & (HA_MBATT | HA_LATT | HA_ERATT); | |
12602 | + | |
12603 | + /* status of events with ELS ring */ | |
12604 | + status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); | |
12605 | + status2 >>= (4*LPFC_ELS_RING); | |
12606 | + | |
12607 | + if (status1 || (status2 & HA_RXMASK)) | |
12608 | + sp_irq_rc = lpfc_sp_intr_handler(irq, dev_id); | |
12609 | + else | |
12610 | + sp_irq_rc = IRQ_NONE; | |
12611 | + | |
12612 | + /* | |
12613 | + * Invoke fast-path host attention interrupt handling as appropriate. | |
12614 | + */ | |
12615 | + | |
12616 | + /* status of events with FCP ring */ | |
12617 | + status1 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); | |
12618 | + status1 >>= (4*LPFC_FCP_RING); | |
12619 | + | |
12620 | + /* status of events with extra ring */ | |
12621 | + if (phba->cfg_multi_ring_support == 2) { | |
12622 | + status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); | |
12623 | + status2 >>= (4*LPFC_EXTRA_RING); | |
12624 | + } else | |
12625 | + status2 = 0; | |
12626 | + | |
12627 | + if ((status1 & HA_RXMASK) || (status2 & HA_RXMASK)) | |
12628 | + fp_irq_rc = lpfc_fp_intr_handler(irq, dev_id); | |
12629 | + else | |
12630 | + fp_irq_rc = IRQ_NONE; | |
12631 | ||
12632 | -} /* lpfc_intr_handler */ | |
12633 | + /* Return device-level interrupt handling status */ | |
12634 | + return (sp_irq_rc == IRQ_HANDLED) ? sp_irq_rc : fp_irq_rc; | |
12635 | +} /* lpfc_intr_handler */ | |
12636 | --- a/drivers/scsi/lpfc/lpfc_sli.h | |
12637 | +++ b/drivers/scsi/lpfc/lpfc_sli.h | |
12638 | @@ -233,6 +233,7 @@ struct lpfc_sli { | |
12639 | #define LPFC_SLI2_ACTIVE 0x200 /* SLI2 overlay in firmware is active */ | |
12640 | #define LPFC_PROCESS_LA 0x400 /* Able to process link attention */ | |
12641 | #define LPFC_BLOCK_MGMT_IO 0x800 /* Don't allow mgmt mbx or iocb cmds */ | |
12642 | +#define LPFC_MENLO_MAINT 0x1000 /* need for menl fw download */ | |
12643 | ||
12644 | struct lpfc_sli_ring ring[LPFC_MAX_RING]; | |
12645 | int fcp_ring; /* ring used for FCP initiator commands */ | |
12646 | --- a/drivers/scsi/lpfc/lpfc_version.h | |
12647 | +++ b/drivers/scsi/lpfc/lpfc_version.h | |
12648 | @@ -18,9 +18,11 @@ | |
12649 | * included with this package. * | |
12650 | *******************************************************************/ | |
12651 | ||
12652 | -#define LPFC_DRIVER_VERSION "8.2.7" | |
12653 | +#define LPFC_DRIVER_VERSION "8.2.8" | |
12654 | ||
12655 | -#define LPFC_DRIVER_NAME "lpfc" | |
12656 | +#define LPFC_DRIVER_NAME "lpfc" | |
12657 | +#define LPFC_SP_DRIVER_HANDLER_NAME "lpfc:sp" | |
12658 | +#define LPFC_FP_DRIVER_HANDLER_NAME "lpfc:fp" | |
12659 | ||
12660 | #define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \ | |
12661 | LPFC_DRIVER_VERSION | |
12662 | --- a/drivers/scsi/lpfc/lpfc_vport.c | |
12663 | +++ b/drivers/scsi/lpfc/lpfc_vport.c | |
12664 | @@ -34,6 +34,7 @@ | |
12665 | #include <scsi/scsi_transport_fc.h> | |
12666 | #include "lpfc_hw.h" | |
12667 | #include "lpfc_sli.h" | |
12668 | +#include "lpfc_nl.h" | |
12669 | #include "lpfc_disc.h" | |
12670 | #include "lpfc_scsi.h" | |
12671 | #include "lpfc.h" | |
12672 | @@ -204,6 +205,77 @@ lpfc_unique_wwpn(struct lpfc_hba *phba, | |
12673 | return 1; | |
12674 | } | |
12675 | ||
12676 | +/** | |
12677 | + * lpfc_discovery_wait: Wait for driver discovery to quiesce. | |
12678 | + * @vport: The virtual port for which this call is being executed. | |
12679 | + * | |
12680 | + * This driver calls this routine specifically from lpfc_vport_delete | |
12681 | + * to enforce a synchronous execution of vport | |
12682 | + * delete relative to discovery activities. The | |
12683 | + * lpfc_vport_delete routine should not return until it | |
12684 | + * can reasonably guarantee that discovery has quiesced. | |
12685 | + * Post FDISC LOGO, the driver must wait until its SAN teardown is | |
12686 | + * complete and all resources recovered before allowing | |
12687 | + * cleanup. | |
12688 | + * | |
12689 | + * This routine does not require any locks held. | |
12690 | + **/ | |
12691 | +static void lpfc_discovery_wait(struct lpfc_vport *vport) | |
12692 | +{ | |
12693 | + struct lpfc_hba *phba = vport->phba; | |
12694 | + uint32_t wait_flags = 0; | |
12695 | + unsigned long wait_time_max; | |
12696 | + unsigned long start_time; | |
12697 | + | |
12698 | + wait_flags = FC_RSCN_MODE | FC_RSCN_DISCOVERY | FC_NLP_MORE | | |
12699 | + FC_RSCN_DEFERRED | FC_NDISC_ACTIVE | FC_DISC_TMO; | |
12700 | + | |
12701 | + /* | |
12702 | + * The time constraint on this loop is a balance between the | |
12703 | + * fabric RA_TOV value and dev_loss tmo. The driver's | |
12704 | + * devloss_tmo is 10 giving this loop a 3x multiplier minimally. | |
12705 | + */ | |
12706 | + wait_time_max = msecs_to_jiffies(((phba->fc_ratov * 3) + 3) * 1000); | |
12707 | + wait_time_max += jiffies; | |
12708 | + start_time = jiffies; | |
12709 | + while (time_before(jiffies, wait_time_max)) { | |
12710 | + if ((vport->num_disc_nodes > 0) || | |
12711 | + (vport->fc_flag & wait_flags) || | |
12712 | + ((vport->port_state > LPFC_VPORT_FAILED) && | |
12713 | + (vport->port_state < LPFC_VPORT_READY))) { | |
12714 | + lpfc_printf_log(phba, KERN_INFO, LOG_VPORT, | |
12715 | + "1833 Vport discovery quiesce Wait:" | |
12716 | + " vpi x%x state x%x fc_flags x%x" | |
12717 | + " num_nodes x%x, waiting 1000 msecs" | |
12718 | + " total wait msecs x%x\n", | |
12719 | + vport->vpi, vport->port_state, | |
12720 | + vport->fc_flag, vport->num_disc_nodes, | |
12721 | + jiffies_to_msecs(jiffies - start_time)); | |
12722 | + msleep(1000); | |
12723 | + } else { | |
12724 | + /* Base case. Wait variants satisfied. Break out */ | |
12725 | + lpfc_printf_log(phba, KERN_INFO, LOG_VPORT, | |
12726 | + "1834 Vport discovery quiesced:" | |
12727 | + " vpi x%x state x%x fc_flags x%x" | |
12728 | + " wait msecs x%x\n", | |
12729 | + vport->vpi, vport->port_state, | |
12730 | + vport->fc_flag, | |
12731 | + jiffies_to_msecs(jiffies | |
12732 | + - start_time)); | |
12733 | + break; | |
12734 | + } | |
12735 | + } | |
12736 | + | |
12737 | + if (time_after(jiffies, wait_time_max)) | |
12738 | + lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, | |
12739 | + "1835 Vport discovery quiesce failed:" | |
12740 | + " vpi x%x state x%x fc_flags x%x" | |
12741 | + " wait msecs x%x\n", | |
12742 | + vport->vpi, vport->port_state, | |
12743 | + vport->fc_flag, | |
12744 | + jiffies_to_msecs(jiffies - start_time)); | |
12745 | +} | |
12746 | + | |
12747 | int | |
12748 | lpfc_vport_create(struct fc_vport *fc_vport, bool disable) | |
12749 | { | |
12750 | @@ -506,8 +578,12 @@ lpfc_vport_delete(struct fc_vport *fc_vp | |
12751 | * initiated after we've disposed of all other resources associated | |
12752 | * with the port. | |
12753 | */ | |
12754 | - if (!scsi_host_get(shost) || !scsi_host_get(shost)) | |
12755 | + if (!scsi_host_get(shost)) | |
12756 | + return VPORT_INVAL; | |
12757 | + if (!scsi_host_get(shost)) { | |
12758 | + scsi_host_put(shost); | |
12759 | return VPORT_INVAL; | |
12760 | + } | |
12761 | spin_lock_irq(&phba->hbalock); | |
12762 | vport->load_flag |= FC_UNLOADING; | |
12763 | spin_unlock_irq(&phba->hbalock); | |
12764 | @@ -597,11 +673,16 @@ lpfc_vport_delete(struct fc_vport *fc_vp | |
12765 | } | |
12766 | vport->unreg_vpi_cmpl = VPORT_INVAL; | |
12767 | timeout = msecs_to_jiffies(phba->fc_ratov * 2000); | |
12768 | + if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) | |
12769 | + goto skip_logo; | |
12770 | if (!lpfc_issue_els_npiv_logo(vport, ndlp)) | |
12771 | while (vport->unreg_vpi_cmpl == VPORT_INVAL && timeout) | |
12772 | timeout = schedule_timeout(timeout); | |
12773 | } | |
12774 | ||
12775 | + if (!(phba->pport->load_flag & FC_UNLOADING)) | |
12776 | + lpfc_discovery_wait(vport); | |
12777 | + | |
12778 | skip_logo: | |
12779 | lpfc_cleanup(vport); | |
12780 | lpfc_sli_host_down(vport); | |
12781 | @@ -615,8 +696,10 @@ skip_logo: | |
12782 | * Completion of unreg_vpi (lpfc_mbx_cmpl_unreg_vpi) | |
12783 | * does the scsi_host_put() to release the vport. | |
12784 | */ | |
12785 | - lpfc_mbx_unreg_vpi(vport); | |
12786 | - } | |
12787 | + if (lpfc_mbx_unreg_vpi(vport)) | |
12788 | + scsi_host_put(shost); | |
12789 | + } else | |
12790 | + scsi_host_put(shost); | |
12791 | ||
12792 | lpfc_free_vpi(phba, vport->vpi); | |
12793 | vport->work_port_events = 0; | |
12794 | @@ -663,3 +746,82 @@ lpfc_destroy_vport_work_array(struct lpf | |
12795 | scsi_host_put(lpfc_shost_from_vport(vports[i])); | |
12796 | kfree(vports); | |
12797 | } | |
12798 | + | |
12799 | + | |
12800 | +/** | |
12801 | + * lpfc_vport_reset_stat_data: Reset the statistical data for the vport. | |
12802 | + * @vport: Pointer to vport object. | |
12803 | + * | |
12804 | + * This function resets the statistical data for the vport. This function | |
12805 | + * is called with the host_lock held | |
12806 | + **/ | |
12807 | +void | |
12808 | +lpfc_vport_reset_stat_data(struct lpfc_vport *vport) | |
12809 | +{ | |
12810 | + struct lpfc_nodelist *ndlp = NULL, *next_ndlp = NULL; | |
12811 | + | |
12812 | + list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | |
12813 | + if (!NLP_CHK_NODE_ACT(ndlp)) | |
12814 | + continue; | |
12815 | + if (ndlp->lat_data) | |
12816 | + memset(ndlp->lat_data, 0, LPFC_MAX_BUCKET_COUNT * | |
12817 | + sizeof(struct lpfc_scsicmd_bkt)); | |
12818 | + } | |
12819 | +} | |
12820 | + | |
12821 | + | |
12822 | +/** | |
12823 | + * lpfc_alloc_bucket: Allocate data buffer required for collecting | |
12824 | + * statistical data. | |
12825 | + * @vport: Pointer to vport object. | |
12826 | + * | |
12827 | + * This function allocates data buffer required for all the FC | |
12828 | + * nodes of the vport to collect statistical data. | |
12829 | + **/ | |
12830 | +void | |
12831 | +lpfc_alloc_bucket(struct lpfc_vport *vport) | |
12832 | +{ | |
12833 | + struct lpfc_nodelist *ndlp = NULL, *next_ndlp = NULL; | |
12834 | + | |
12835 | + list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | |
12836 | + if (!NLP_CHK_NODE_ACT(ndlp)) | |
12837 | + continue; | |
12838 | + | |
12839 | + kfree(ndlp->lat_data); | |
12840 | + ndlp->lat_data = NULL; | |
12841 | + | |
12842 | + if (ndlp->nlp_state == NLP_STE_MAPPED_NODE) { | |
12843 | + ndlp->lat_data = kcalloc(LPFC_MAX_BUCKET_COUNT, | |
12844 | + sizeof(struct lpfc_scsicmd_bkt), | |
12845 | + GFP_ATOMIC); | |
12846 | + | |
12847 | + if (!ndlp->lat_data) | |
12848 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE, | |
12849 | + "0287 lpfc_alloc_bucket failed to " | |
12850 | + "allocate statistical data buffer DID " | |
12851 | + "0x%x\n", ndlp->nlp_DID); | |
12852 | + } | |
12853 | + } | |
12854 | +} | |
12855 | + | |
12856 | +/** | |
12857 | + * lpfc_free_bucket: Free data buffer required for collecting | |
12858 | + * statistical data. | |
12859 | + * @vport: Pointer to vport object. | |
12860 | + * | |
12861 | + * Th function frees statistical data buffer of all the FC | |
12862 | + * nodes of the vport. | |
12863 | + **/ | |
12864 | +void | |
12865 | +lpfc_free_bucket(struct lpfc_vport *vport) | |
12866 | +{ | |
12867 | + struct lpfc_nodelist *ndlp = NULL, *next_ndlp = NULL; | |
12868 | + | |
12869 | + list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | |
12870 | + if (!NLP_CHK_NODE_ACT(ndlp)) | |
12871 | + continue; | |
12872 | + | |
12873 | + kfree(ndlp->lat_data); | |
12874 | + ndlp->lat_data = NULL; | |
12875 | + } | |
12876 | +} | |
12877 | --- a/drivers/scsi/lpfc/lpfc_vport.h | |
12878 | +++ b/drivers/scsi/lpfc/lpfc_vport.h | |
12879 | @@ -112,4 +112,8 @@ struct vport_cmd_tag { | |
12880 | void lpfc_vport_set_state(struct lpfc_vport *vport, | |
12881 | enum fc_vport_state new_state); | |
12882 | ||
12883 | +void lpfc_vport_reset_stat_data(struct lpfc_vport *); | |
12884 | +void lpfc_alloc_bucket(struct lpfc_vport *); | |
12885 | +void lpfc_free_bucket(struct lpfc_vport *); | |
12886 | + | |
12887 | #endif /* H_LPFC_VPORT */ |