diff options
author | James Smart <James.Smart@Emulex.Com> | 2008-08-24 21:49:00 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-10-13 09:28:53 -0400 |
commit | e59058c44025d71c9b7f260076a932935d3bba95 (patch) | |
tree | 36cd4b31ac3b130849c5ad4d2c0cef035a7389dd /drivers/scsi/lpfc/lpfc_sli.c | |
parent | 4a27446f3e39b06c28d1c8e31d33a5340826ed5c (diff) |
[SCSI] lpfc 8.2.8 : Add kernel-doc function headers
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_sli.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_sli.c | 1063 |
1 files changed, 1027 insertions, 36 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 50fe07646738..3cf488496d86 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -66,10 +66,16 @@ typedef enum _lpfc_iocb_type { | |||
66 | LPFC_ABORT_IOCB | 66 | LPFC_ABORT_IOCB |
67 | } lpfc_iocb_type; | 67 | } lpfc_iocb_type; |
68 | 68 | ||
69 | /* SLI-2/SLI-3 provide different sized iocbs. Given a pointer | 69 | /** |
70 | * to the start of the ring, and the slot number of the | 70 | * lpfc_cmd_iocb: Get next command iocb entry in the ring. |
71 | * desired iocb entry, calc a pointer to that entry. | 71 | * @phba: Pointer to HBA context object. |
72 | */ | 72 | * @pring: Pointer to driver SLI ring object. |
73 | * | ||
74 | * This function returns pointer to next command iocb entry | ||
75 | * in the command ring. The caller must hold hbalock to prevent | ||
76 | * other threads consume the next command iocb. | ||
77 | * SLI-2/SLI-3 provide different sized iocbs. | ||
78 | **/ | ||
73 | static inline IOCB_t * | 79 | static inline IOCB_t * |
74 | lpfc_cmd_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 80 | lpfc_cmd_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
75 | { | 81 | { |
@@ -77,6 +83,16 @@ lpfc_cmd_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
77 | pring->cmdidx * phba->iocb_cmd_size); | 83 | pring->cmdidx * phba->iocb_cmd_size); |
78 | } | 84 | } |
79 | 85 | ||
86 | /** | ||
87 | * lpfc_resp_iocb: Get next response iocb entry in the ring. | ||
88 | * @phba: Pointer to HBA context object. | ||
89 | * @pring: Pointer to driver SLI ring object. | ||
90 | * | ||
91 | * This function returns pointer to next response iocb entry | ||
92 | * in the response ring. The caller must hold hbalock to make sure | ||
93 | * that no other thread consume the next response iocb. | ||
94 | * SLI-2/SLI-3 provide different sized iocbs. | ||
95 | **/ | ||
80 | static inline IOCB_t * | 96 | static inline IOCB_t * |
81 | lpfc_resp_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 97 | lpfc_resp_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
82 | { | 98 | { |
@@ -84,6 +100,15 @@ lpfc_resp_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
84 | pring->rspidx * phba->iocb_rsp_size); | 100 | pring->rspidx * phba->iocb_rsp_size); |
85 | } | 101 | } |
86 | 102 | ||
103 | /** | ||
104 | * __lpfc_sli_get_iocbq: Allocates an iocb object from iocb pool. | ||
105 | * @phba: Pointer to HBA context object. | ||
106 | * | ||
107 | * This function is called with hbalock held. This function | ||
108 | * allocates a new driver iocb object from the iocb pool. If the | ||
109 | * allocation is successful, it returns pointer to the newly | ||
110 | * allocated iocb object else it returns NULL. | ||
111 | **/ | ||
87 | static struct lpfc_iocbq * | 112 | static struct lpfc_iocbq * |
88 | __lpfc_sli_get_iocbq(struct lpfc_hba *phba) | 113 | __lpfc_sli_get_iocbq(struct lpfc_hba *phba) |
89 | { | 114 | { |
@@ -94,6 +119,15 @@ __lpfc_sli_get_iocbq(struct lpfc_hba *phba) | |||
94 | return iocbq; | 119 | return iocbq; |
95 | } | 120 | } |
96 | 121 | ||
122 | /** | ||
123 | * lpfc_sli_get_iocbq: Allocates an iocb object from iocb pool. | ||
124 | * @phba: Pointer to HBA context object. | ||
125 | * | ||
126 | * This function is called with no lock held. This function | ||
127 | * allocates a new driver iocb object from the iocb pool. If the | ||
128 | * allocation is successful, it returns pointer to the newly | ||
129 | * allocated iocb object else it returns NULL. | ||
130 | **/ | ||
97 | struct lpfc_iocbq * | 131 | struct lpfc_iocbq * |
98 | lpfc_sli_get_iocbq(struct lpfc_hba *phba) | 132 | lpfc_sli_get_iocbq(struct lpfc_hba *phba) |
99 | { | 133 | { |
@@ -106,6 +140,16 @@ lpfc_sli_get_iocbq(struct lpfc_hba *phba) | |||
106 | return iocbq; | 140 | return iocbq; |
107 | } | 141 | } |
108 | 142 | ||
143 | /** | ||
144 | * __lpfc_sli_release_iocbq: Release iocb to the iocb pool. | ||
145 | * @phba: Pointer to HBA context object. | ||
146 | * @iocbq: Pointer to driver iocb object. | ||
147 | * | ||
148 | * This function is called with hbalock held to release driver | ||
149 | * iocb object to the iocb pool. The iotag in the iocb object | ||
150 | * does not change for each use of the iocb object. This function | ||
151 | * clears all other fields of the iocb object when it is freed. | ||
152 | **/ | ||
109 | static void | 153 | static void |
110 | __lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | 154 | __lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) |
111 | { | 155 | { |
@@ -118,6 +162,14 @@ __lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |||
118 | list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); | 162 | list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); |
119 | } | 163 | } |
120 | 164 | ||
165 | /** | ||
166 | * lpfc_sli_release_iocbq: Release iocb to the iocb pool. | ||
167 | * @phba: Pointer to HBA context object. | ||
168 | * @iocbq: Pointer to driver iocb object. | ||
169 | * | ||
170 | * This function is called with no lock held to release the iocb to | ||
171 | * iocb pool. | ||
172 | **/ | ||
121 | void | 173 | void |
122 | lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | 174 | lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) |
123 | { | 175 | { |
@@ -131,10 +183,21 @@ lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |||
131 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 183 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
132 | } | 184 | } |
133 | 185 | ||
134 | /* | 186 | /** |
135 | * Translate the iocb command to an iocb command type used to decide the final | 187 | * lpfc_sli_iocb_cmd_type: Get the iocb type. |
136 | * disposition of each completed IOCB. | 188 | * @iocb_cmnd : iocb command code. |
137 | */ | 189 | * |
190 | * This function is called by ring event handler function to get the iocb type. | ||
191 | * This function translates the iocb command to an iocb command type used to | ||
192 | * decide the final disposition of each completed IOCB. | ||
193 | * The function returns | ||
194 | * LPFC_UNKNOWN_IOCB if it is an unsupported iocb | ||
195 | * LPFC_SOL_IOCB if it is a solicited iocb completion | ||
196 | * LPFC_ABORT_IOCB if it is an abort iocb | ||
197 | * LPFC_UNSOL_IOCB if it is an unsolicited iocb | ||
198 | * | ||
199 | * The caller is not required to hold any lock. | ||
200 | **/ | ||
138 | static lpfc_iocb_type | 201 | static lpfc_iocb_type |
139 | lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd) | 202 | lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd) |
140 | { | 203 | { |
@@ -230,6 +293,17 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd) | |||
230 | return type; | 293 | return type; |
231 | } | 294 | } |
232 | 295 | ||
296 | /** | ||
297 | * lpfc_sli_ring_map: Issue config_ring mbox for all rings. | ||
298 | * @phba: Pointer to HBA context object. | ||
299 | * | ||
300 | * This function is called from SLI initialization code | ||
301 | * to configure every ring of the HBA's SLI interface. The | ||
302 | * caller is not required to hold any lock. This function issues | ||
303 | * a config_ring mailbox command for each ring. | ||
304 | * This function returns zero if successful else returns a negative | ||
305 | * error code. | ||
306 | **/ | ||
233 | static int | 307 | static int |
234 | lpfc_sli_ring_map(struct lpfc_hba *phba) | 308 | lpfc_sli_ring_map(struct lpfc_hba *phba) |
235 | { | 309 | { |
@@ -262,6 +336,18 @@ lpfc_sli_ring_map(struct lpfc_hba *phba) | |||
262 | return ret; | 336 | return ret; |
263 | } | 337 | } |
264 | 338 | ||
339 | /** | ||
340 | * lpfc_sli_ringtxcmpl_put: Adds new iocb to the txcmplq. | ||
341 | * @phba: Pointer to HBA context object. | ||
342 | * @pring: Pointer to driver SLI ring object. | ||
343 | * @piocb: Pointer to the driver iocb object. | ||
344 | * | ||
345 | * This function is called with hbalock held. The function adds the | ||
346 | * new iocb to txcmplq of the given ring. This function always returns | ||
347 | * 0. If this function is called for ELS ring, this function checks if | ||
348 | * there is a vport associated with the ELS command. This function also | ||
349 | * starts els_tmofunc timer if this is an ELS command. | ||
350 | **/ | ||
265 | static int | 351 | static int |
266 | lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 352 | lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
267 | struct lpfc_iocbq *piocb) | 353 | struct lpfc_iocbq *piocb) |
@@ -282,6 +368,16 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
282 | return 0; | 368 | return 0; |
283 | } | 369 | } |
284 | 370 | ||
371 | /** | ||
372 | * lpfc_sli_ringtx_get: Get first element of the txq. | ||
373 | * @phba: Pointer to HBA context object. | ||
374 | * @pring: Pointer to driver SLI ring object. | ||
375 | * | ||
376 | * This function is called with hbalock held to get next | ||
377 | * iocb in txq of the given ring. If there is any iocb in | ||
378 | * the txq, the function returns first iocb in the list after | ||
379 | * removing the iocb from the list, else it returns NULL. | ||
380 | **/ | ||
285 | static struct lpfc_iocbq * | 381 | static struct lpfc_iocbq * |
286 | lpfc_sli_ringtx_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 382 | lpfc_sli_ringtx_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
287 | { | 383 | { |
@@ -293,6 +389,20 @@ lpfc_sli_ringtx_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
293 | return cmd_iocb; | 389 | return cmd_iocb; |
294 | } | 390 | } |
295 | 391 | ||
392 | /** | ||
393 | * lpfc_sli_next_iocb_slot: Get next iocb slot in the ring. | ||
394 | * @phba: Pointer to HBA context object. | ||
395 | * @pring: Pointer to driver SLI ring object. | ||
396 | * | ||
397 | * This function is called with hbalock held and the caller must post the | ||
398 | * iocb without releasing the lock. If the caller releases the lock, | ||
399 | * iocb slot returned by the function is not guaranteed to be available. | ||
400 | * The function returns pointer to the next available iocb slot if there | ||
401 | * is available slot in the ring, else it returns NULL. | ||
402 | * If the get index of the ring is ahead of the put index, the function | ||
403 | * will post an error attention event to the worker thread to take the | ||
404 | * HBA to offline state. | ||
405 | **/ | ||
296 | static IOCB_t * | 406 | static IOCB_t * |
297 | lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 407 | lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
298 | { | 408 | { |
@@ -336,6 +446,18 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
336 | return lpfc_cmd_iocb(phba, pring); | 446 | return lpfc_cmd_iocb(phba, pring); |
337 | } | 447 | } |
338 | 448 | ||
449 | /** | ||
450 | * lpfc_sli_next_iotag: Get an iotag for the iocb. | ||
451 | * @phba: Pointer to HBA context object. | ||
452 | * @iocbq: Pointer to driver iocb object. | ||
453 | * | ||
454 | * This function gets an iotag for the iocb. If there is no unused iotag and | ||
455 | * the iocbq_lookup_len < 0xffff, this function allocates a bigger iotag_lookup | ||
456 | * array and assigns a new iotag. | ||
457 | * The function returns the allocated iotag if successful, else returns zero. | ||
458 | * Zero is not a valid iotag. | ||
459 | * The caller is not required to hold any lock. | ||
460 | **/ | ||
339 | uint16_t | 461 | uint16_t |
340 | lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | 462 | lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) |
341 | { | 463 | { |
@@ -399,6 +521,20 @@ lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |||
399 | return 0; | 521 | return 0; |
400 | } | 522 | } |
401 | 523 | ||
524 | /** | ||
525 | * lpfc_sli_submit_iocb: Submit an iocb to the firmware. | ||
526 | * @phba: Pointer to HBA context object. | ||
527 | * @pring: Pointer to driver SLI ring object. | ||
528 | * @iocb: Pointer to iocb slot in the ring. | ||
529 | * @nextiocb: Pointer to driver iocb object which need to be | ||
530 | * posted to firmware. | ||
531 | * | ||
532 | * This function is called with hbalock held to post a new iocb to | ||
533 | * the firmware. This function copies the new iocb to ring iocb slot and | ||
534 | * updates the ring pointers. It adds the new iocb to txcmplq if there is | ||
535 | * a completion call back for this iocb else the function will free the | ||
536 | * iocb object. | ||
537 | **/ | ||
402 | static void | 538 | static void |
403 | lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 539 | lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
404 | IOCB_t *iocb, struct lpfc_iocbq *nextiocb) | 540 | IOCB_t *iocb, struct lpfc_iocbq *nextiocb) |
@@ -441,6 +577,18 @@ lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
441 | writel(pring->cmdidx, &phba->host_gp[pring->ringno].cmdPutInx); | 577 | writel(pring->cmdidx, &phba->host_gp[pring->ringno].cmdPutInx); |
442 | } | 578 | } |
443 | 579 | ||
580 | /** | ||
581 | * lpfc_sli_update_full_ring: Update the chip attention register. | ||
582 | * @phba: Pointer to HBA context object. | ||
583 | * @pring: Pointer to driver SLI ring object. | ||
584 | * | ||
585 | * The caller is not required to hold any lock for calling this function. | ||
586 | * This function updates the chip attention bits for the ring to inform firmware | ||
587 | * that there are pending work to be done for this ring and requests an | ||
588 | * interrupt when there is space available in the ring. This function is | ||
589 | * called when the driver is unable to post more iocbs to the ring due | ||
590 | * to unavailability of space in the ring. | ||
591 | **/ | ||
444 | static void | 592 | static void |
445 | lpfc_sli_update_full_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 593 | lpfc_sli_update_full_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
446 | { | 594 | { |
@@ -460,6 +608,15 @@ lpfc_sli_update_full_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
460 | pring->stats.iocb_cmd_full++; | 608 | pring->stats.iocb_cmd_full++; |
461 | } | 609 | } |
462 | 610 | ||
611 | /** | ||
612 | * lpfc_sli_update_ring: Update chip attention register. | ||
613 | * @phba: Pointer to HBA context object. | ||
614 | * @pring: Pointer to driver SLI ring object. | ||
615 | * | ||
616 | * This function updates the chip attention register bit for the | ||
617 | * given ring to inform HBA that there is more work to be done | ||
618 | * in this ring. The caller is not required to hold any lock. | ||
619 | **/ | ||
463 | static void | 620 | static void |
464 | lpfc_sli_update_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 621 | lpfc_sli_update_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
465 | { | 622 | { |
@@ -473,6 +630,15 @@ lpfc_sli_update_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
473 | readl(phba->CAregaddr); /* flush */ | 630 | readl(phba->CAregaddr); /* flush */ |
474 | } | 631 | } |
475 | 632 | ||
633 | /** | ||
634 | * lpfc_sli_resume_iocb: Process iocbs in the txq. | ||
635 | * @phba: Pointer to HBA context object. | ||
636 | * @pring: Pointer to driver SLI ring object. | ||
637 | * | ||
638 | * This function is called with hbalock held to post pending iocbs | ||
639 | * in the txq to the firmware. This function is called when driver | ||
640 | * detects space available in the ring. | ||
641 | **/ | ||
476 | static void | 642 | static void |
477 | lpfc_sli_resume_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 643 | lpfc_sli_resume_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
478 | { | 644 | { |
@@ -504,6 +670,16 @@ lpfc_sli_resume_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
504 | return; | 670 | return; |
505 | } | 671 | } |
506 | 672 | ||
673 | /** | ||
674 | * lpfc_sli_next_hbq_slot: Get next hbq entry for the HBQ. | ||
675 | * @phba: Pointer to HBA context object. | ||
676 | * @hbqno: HBQ number. | ||
677 | * | ||
678 | * This function is called with hbalock held to get the next | ||
679 | * available slot for the given HBQ. If there is free slot | ||
680 | * available for the HBQ it will return pointer to the next available | ||
681 | * HBQ entry else it will return NULL. | ||
682 | **/ | ||
507 | static struct lpfc_hbq_entry * | 683 | static struct lpfc_hbq_entry * |
508 | lpfc_sli_next_hbq_slot(struct lpfc_hba *phba, uint32_t hbqno) | 684 | lpfc_sli_next_hbq_slot(struct lpfc_hba *phba, uint32_t hbqno) |
509 | { | 685 | { |
@@ -539,6 +715,15 @@ lpfc_sli_next_hbq_slot(struct lpfc_hba *phba, uint32_t hbqno) | |||
539 | hbqp->hbqPutIdx; | 715 | hbqp->hbqPutIdx; |
540 | } | 716 | } |
541 | 717 | ||
718 | /** | ||
719 | * lpfc_sli_hbqbuf_free_all: Free all the hbq buffers. | ||
720 | * @phba: Pointer to HBA context object. | ||
721 | * | ||
722 | * This function is called with no lock held to free all the | ||
723 | * hbq buffers while uninitializing the SLI interface. It also | ||
724 | * frees the HBQ buffers returned by the firmware but not yet | ||
725 | * processed by the upper layers. | ||
726 | **/ | ||
542 | void | 727 | void |
543 | lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba) | 728 | lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba) |
544 | { | 729 | { |
@@ -584,6 +769,18 @@ lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba) | |||
584 | spin_unlock_irqrestore(&phba->hbalock, flags); | 769 | spin_unlock_irqrestore(&phba->hbalock, flags); |
585 | } | 770 | } |
586 | 771 | ||
772 | /** | ||
773 | * lpfc_sli_hbq_to_firmware: Post the hbq buffer to firmware. | ||
774 | * @phba: Pointer to HBA context object. | ||
775 | * @hbqno: HBQ number. | ||
776 | * @hbq_buf: Pointer to HBQ buffer. | ||
777 | * | ||
778 | * This function is called with the hbalock held to post a | ||
779 | * hbq buffer to the firmware. If the function finds an empty | ||
780 | * slot in the HBQ, it will post the buffer. The function will return | ||
781 | * pointer to the hbq entry if it successfully post the buffer | ||
782 | * else it will return NULL. | ||
783 | **/ | ||
587 | static struct lpfc_hbq_entry * | 784 | static struct lpfc_hbq_entry * |
588 | lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno, | 785 | lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno, |
589 | struct hbq_dmabuf *hbq_buf) | 786 | struct hbq_dmabuf *hbq_buf) |
@@ -612,6 +809,7 @@ lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno, | |||
612 | return hbqe; | 809 | return hbqe; |
613 | } | 810 | } |
614 | 811 | ||
812 | /* HBQ for ELS and CT traffic. */ | ||
615 | static struct lpfc_hbq_init lpfc_els_hbq = { | 813 | static struct lpfc_hbq_init lpfc_els_hbq = { |
616 | .rn = 1, | 814 | .rn = 1, |
617 | .entry_count = 200, | 815 | .entry_count = 200, |
@@ -623,6 +821,7 @@ static struct lpfc_hbq_init lpfc_els_hbq = { | |||
623 | .add_count = 5, | 821 | .add_count = 5, |
624 | }; | 822 | }; |
625 | 823 | ||
824 | /* HBQ for the extra ring if needed */ | ||
626 | static struct lpfc_hbq_init lpfc_extra_hbq = { | 825 | static struct lpfc_hbq_init lpfc_extra_hbq = { |
627 | .rn = 1, | 826 | .rn = 1, |
628 | .entry_count = 200, | 827 | .entry_count = 200, |
@@ -634,11 +833,22 @@ static struct lpfc_hbq_init lpfc_extra_hbq = { | |||
634 | .add_count = 5, | 833 | .add_count = 5, |
635 | }; | 834 | }; |
636 | 835 | ||
836 | /* Array of HBQs */ | ||
637 | struct lpfc_hbq_init *lpfc_hbq_defs[] = { | 837 | struct lpfc_hbq_init *lpfc_hbq_defs[] = { |
638 | &lpfc_els_hbq, | 838 | &lpfc_els_hbq, |
639 | &lpfc_extra_hbq, | 839 | &lpfc_extra_hbq, |
640 | }; | 840 | }; |
641 | 841 | ||
842 | /** | ||
843 | * lpfc_sli_hbqbuf_fill_hbqs: Post more hbq buffers to HBQ. | ||
844 | * @phba: Pointer to HBA context object. | ||
845 | * @hbqno: HBQ number. | ||
846 | * @count: Number of HBQ buffers to be posted. | ||
847 | * | ||
848 | * This function is called with no lock held to post more | ||
849 | * hbq buffers to the given HBQ. The function returns 0 | ||
850 | * when successful and returns 1 other wise. | ||
851 | **/ | ||
642 | static int | 852 | static int |
643 | lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) | 853 | lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) |
644 | { | 854 | { |
@@ -679,6 +889,15 @@ lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) | |||
679 | return 1; | 889 | return 1; |
680 | } | 890 | } |
681 | 891 | ||
892 | /** | ||
893 | * lpfc_sli_hbqbuf_add_hbqs: Post more HBQ buffers to firmware. | ||
894 | * @phba: Pointer to HBA context object. | ||
895 | * @qno: HBQ number. | ||
896 | * | ||
897 | * This function posts more buffers to the HBQ. This function | ||
898 | * is called with no lock held. The function returns 0 when | ||
899 | * successful and returns 1 otherwise. | ||
900 | **/ | ||
682 | int | 901 | int |
683 | lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) | 902 | lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) |
684 | { | 903 | { |
@@ -686,6 +905,15 @@ lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) | |||
686 | lpfc_hbq_defs[qno]->add_count)); | 905 | lpfc_hbq_defs[qno]->add_count)); |
687 | } | 906 | } |
688 | 907 | ||
908 | /** | ||
909 | * lpfc_sli_hbqbuf_init_hbqs: Post initial buffers to the HBQ. | ||
910 | * @phba: Pointer to HBA context object. | ||
911 | * @qno: HBQ queue number. | ||
912 | * | ||
913 | * This function is called from SLI initialization code path with | ||
914 | * no lock held to post initial HBQ buffers to firmware. The | ||
915 | * function returns 0 when successful and returns 1 otherwise. | ||
916 | **/ | ||
689 | static int | 917 | static int |
690 | lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) | 918 | lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) |
691 | { | 919 | { |
@@ -693,6 +921,16 @@ lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) | |||
693 | lpfc_hbq_defs[qno]->init_count)); | 921 | lpfc_hbq_defs[qno]->init_count)); |
694 | } | 922 | } |
695 | 923 | ||
924 | /** | ||
925 | * lpfc_sli_hbqbuf_find: Find the hbq buffer associated with a tag. | ||
926 | * @phba: Pointer to HBA context object. | ||
927 | * @tag: Tag of the hbq buffer. | ||
928 | * | ||
929 | * This function is called with hbalock held. This function searches | ||
930 | * for the hbq buffer associated with the given tag in the hbq buffer | ||
931 | * list. If it finds the hbq buffer, it returns the hbq_buffer other wise | ||
932 | * it returns NULL. | ||
933 | **/ | ||
696 | static struct hbq_dmabuf * | 934 | static struct hbq_dmabuf * |
697 | lpfc_sli_hbqbuf_find(struct lpfc_hba *phba, uint32_t tag) | 935 | lpfc_sli_hbqbuf_find(struct lpfc_hba *phba, uint32_t tag) |
698 | { | 936 | { |
@@ -716,6 +954,15 @@ lpfc_sli_hbqbuf_find(struct lpfc_hba *phba, uint32_t tag) | |||
716 | return NULL; | 954 | return NULL; |
717 | } | 955 | } |
718 | 956 | ||
957 | /** | ||
958 | * lpfc_sli_free_hbq: Give back the hbq buffer to firmware. | ||
959 | * @phba: Pointer to HBA context object. | ||
960 | * @hbq_buffer: Pointer to HBQ buffer. | ||
961 | * | ||
962 | * This function is called with hbalock. This function gives back | ||
963 | * the hbq buffer to firmware. If the HBQ does not have space to | ||
964 | * post the buffer, it will free the buffer. | ||
965 | **/ | ||
719 | void | 966 | void |
720 | lpfc_sli_free_hbq(struct lpfc_hba *phba, struct hbq_dmabuf *hbq_buffer) | 967 | lpfc_sli_free_hbq(struct lpfc_hba *phba, struct hbq_dmabuf *hbq_buffer) |
721 | { | 968 | { |
@@ -729,6 +976,15 @@ lpfc_sli_free_hbq(struct lpfc_hba *phba, struct hbq_dmabuf *hbq_buffer) | |||
729 | } | 976 | } |
730 | } | 977 | } |
731 | 978 | ||
979 | /** | ||
980 | * lpfc_sli_chk_mbx_command: Check if the mailbox is a legitimate mailbox. | ||
981 | * @mbxCommand: mailbox command code. | ||
982 | * | ||
983 | * This function is called by the mailbox event handler function to verify | ||
984 | * that the completed mailbox command is a legitimate mailbox command. If the | ||
985 | * completed mailbox is not known to the function, it will return MBX_SHUTDOWN | ||
986 | * and the mailbox event handler will take the HBA offline. | ||
987 | **/ | ||
732 | static int | 988 | static int |
733 | lpfc_sli_chk_mbx_command(uint8_t mbxCommand) | 989 | lpfc_sli_chk_mbx_command(uint8_t mbxCommand) |
734 | { | 990 | { |
@@ -793,6 +1049,19 @@ lpfc_sli_chk_mbx_command(uint8_t mbxCommand) | |||
793 | } | 1049 | } |
794 | return ret; | 1050 | return ret; |
795 | } | 1051 | } |
1052 | |||
1053 | /** | ||
1054 | * lpfc_sli_wake_mbox_wait: Completion handler for mbox issued from | ||
1055 | * lpfc_sli_issue_mbox_wait. | ||
1056 | * @phba: Pointer to HBA context object. | ||
1057 | * @pmboxq: Pointer to mailbox command. | ||
1058 | * | ||
1059 | * This is completion handler function for mailbox commands issued from | ||
1060 | * lpfc_sli_issue_mbox_wait function. This function is called by the | ||
1061 | * mailbox event handler function with no lock held. This function | ||
1062 | * will wake up thread waiting on the wait queue pointed by context1 | ||
1063 | * of the mailbox. | ||
1064 | **/ | ||
796 | static void | 1065 | static void |
797 | lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) | 1066 | lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) |
798 | { | 1067 | { |
@@ -812,6 +1081,17 @@ lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) | |||
812 | return; | 1081 | return; |
813 | } | 1082 | } |
814 | 1083 | ||
1084 | |||
1085 | /** | ||
1086 | * lpfc_sli_def_mbox_cmpl: Default mailbox completion handler. | ||
1087 | * @phba: Pointer to HBA context object. | ||
1088 | * @pmb: Pointer to mailbox object. | ||
1089 | * | ||
1090 | * This function is the default mailbox completion handler. It | ||
1091 | * frees the memory resources associated with the completed mailbox | ||
1092 | * command. If the completed command is a REG_LOGIN mailbox command, | ||
1093 | * this function will issue a UREG_LOGIN to re-claim the RPI. | ||
1094 | **/ | ||
815 | void | 1095 | void |
816 | lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | 1096 | lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
817 | { | 1097 | { |
@@ -846,6 +1126,19 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
846 | return; | 1126 | return; |
847 | } | 1127 | } |
848 | 1128 | ||
1129 | /** | ||
1130 | * lpfc_sli_handle_mb_event: Handle mailbox completions from firmware. | ||
1131 | * @phba: Pointer to HBA context object. | ||
1132 | * | ||
1133 | * This function is called with no lock held. This function processes all | ||
1134 | * the completed mailbox commands and gives it to upper layers. The interrupt | ||
1135 | * service routine processes mailbox completion interrupt and adds completed | ||
1136 | * mailbox commands to the mboxq_cmpl queue and signals the worker thread. | ||
1137 | * Worker thread call lpfc_sli_handle_mb_event, which will return the | ||
1138 | * completed mailbox commands in mboxq_cmpl queue to the upper layers. This | ||
1139 | * function returns the mailbox commands to the upper layer by calling the | ||
1140 | * completion handler function of each mailbox. | ||
1141 | **/ | ||
849 | int | 1142 | int |
850 | lpfc_sli_handle_mb_event(struct lpfc_hba *phba) | 1143 | lpfc_sli_handle_mb_event(struct lpfc_hba *phba) |
851 | { | 1144 | { |
@@ -953,6 +1246,16 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba) | |||
953 | return 0; | 1246 | return 0; |
954 | } | 1247 | } |
955 | 1248 | ||
1249 | /** | ||
1250 | * lpfc_sli_replace_hbqbuff: Replace the HBQ buffer with a new buffer. | ||
1251 | * @phba: Pointer to HBA context object. | ||
1252 | * @tag: Tag for the HBQ buffer. | ||
1253 | * | ||
1254 | * This function is called from unsolicited event handler code path to get the | ||
1255 | * HBQ buffer associated with an unsolicited iocb. This function is called with | ||
1256 | * no lock held. It returns the buffer associated with the given tag and posts | ||
1257 | * another buffer to the firmware. | ||
1258 | **/ | ||
956 | static struct lpfc_dmabuf * | 1259 | static struct lpfc_dmabuf * |
957 | lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) | 1260 | lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) |
958 | { | 1261 | { |
@@ -997,6 +1300,18 @@ lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) | |||
997 | return &new_hbq_entry->dbuf; | 1300 | return &new_hbq_entry->dbuf; |
998 | } | 1301 | } |
999 | 1302 | ||
1303 | /** | ||
1304 | * lpfc_sli_get_buff: Get the buffer associated with the buffer tag. | ||
1305 | * @phba: Pointer to HBA context object. | ||
1306 | * @pring: Pointer to driver SLI ring object. | ||
1307 | * @tag: buffer tag. | ||
1308 | * | ||
1309 | * This function is called with no lock held. When QUE_BUFTAG_BIT bit | ||
1310 | * is set in the tag the buffer is posted for a particular exchange, | ||
1311 | * the function will return the buffer without replacing the buffer. | ||
1312 | * If the buffer is for unsolicited ELS or CT traffic, this function | ||
1313 | * returns the buffer and also posts another buffer to the firmware. | ||
1314 | **/ | ||
1000 | static struct lpfc_dmabuf * | 1315 | static struct lpfc_dmabuf * |
1001 | lpfc_sli_get_buff(struct lpfc_hba *phba, | 1316 | lpfc_sli_get_buff(struct lpfc_hba *phba, |
1002 | struct lpfc_sli_ring *pring, | 1317 | struct lpfc_sli_ring *pring, |
@@ -1008,6 +1323,21 @@ lpfc_sli_get_buff(struct lpfc_hba *phba, | |||
1008 | return lpfc_sli_replace_hbqbuff(phba, tag); | 1323 | return lpfc_sli_replace_hbqbuff(phba, tag); |
1009 | } | 1324 | } |
1010 | 1325 | ||
1326 | |||
1327 | /** | ||
1328 | * lpfc_sli_process_unsol_iocb: Unsolicited iocb handler. | ||
1329 | * @phba: Pointer to HBA context object. | ||
1330 | * @pring: Pointer to driver SLI ring object. | ||
1331 | * @saveq: Pointer to the unsolicited iocb. | ||
1332 | * | ||
1333 | * This function is called with no lock held by the ring event handler | ||
1334 | * when there is an unsolicited iocb posted to the response ring by the | ||
1335 | * firmware. This function gets the buffer associated with the iocbs | ||
1336 | * and calls the event handler for the ring. This function handles both | ||
1337 | * qring buffers and hbq buffers. | ||
1338 | * When the function returns 1 the caller can free the iocb object otherwise | ||
1339 | * upper layer functions will free the iocb objects. | ||
1340 | **/ | ||
1011 | static int | 1341 | static int |
1012 | lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 1342 | lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
1013 | struct lpfc_iocbq *saveq) | 1343 | struct lpfc_iocbq *saveq) |
@@ -1192,6 +1522,18 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
1192 | return 1; | 1522 | return 1; |
1193 | } | 1523 | } |
1194 | 1524 | ||
1525 | /** | ||
1526 | * lpfc_sli_iocbq_lookup: Find command iocb for the given response iocb. | ||
1527 | * @phba: Pointer to HBA context object. | ||
1528 | * @pring: Pointer to driver SLI ring object. | ||
1529 | * @prspiocb: Pointer to response iocb object. | ||
1530 | * | ||
1531 | * This function looks up the iocb_lookup table to get the command iocb | ||
1532 | * corresponding to the given response iocb using the iotag of the | ||
1533 | * response iocb. This function is called with the hbalock held. | ||
1534 | * This function returns the command iocb object if it finds the command | ||
1535 | * iocb else returns NULL. | ||
1536 | **/ | ||
1195 | static struct lpfc_iocbq * | 1537 | static struct lpfc_iocbq * |
1196 | lpfc_sli_iocbq_lookup(struct lpfc_hba *phba, | 1538 | lpfc_sli_iocbq_lookup(struct lpfc_hba *phba, |
1197 | struct lpfc_sli_ring *pring, | 1539 | struct lpfc_sli_ring *pring, |
@@ -1217,6 +1559,23 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba *phba, | |||
1217 | return NULL; | 1559 | return NULL; |
1218 | } | 1560 | } |
1219 | 1561 | ||
1562 | /** | ||
1563 | * lpfc_sli_process_sol_iocb: process solicited iocb completion. | ||
1564 | * @phba: Pointer to HBA context object. | ||
1565 | * @pring: Pointer to driver SLI ring object. | ||
1566 | * @saveq: Pointer to the response iocb to be processed. | ||
1567 | * | ||
1568 | * This function is called by the ring event handler for non-fcp | ||
1569 | * rings when there is a new response iocb in the response ring. | ||
1570 | * The caller is not required to hold any locks. This function | ||
1571 | * gets the command iocb associated with the response iocb and | ||
1572 | * calls the completion handler for the command iocb. If there | ||
1573 | * is no completion handler, the function will free the resources | ||
1574 | * associated with command iocb. If the response iocb is for | ||
1575 | * an already aborted command iocb, the status of the completion | ||
1576 | * is changed to IOSTAT_LOCAL_REJECT/IOERR_SLI_ABORTED. | ||
1577 | * This function always returns 1. | ||
1578 | **/ | ||
1220 | static int | 1579 | static int |
1221 | lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 1580 | lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
1222 | struct lpfc_iocbq *saveq) | 1581 | struct lpfc_iocbq *saveq) |
@@ -1282,6 +1641,16 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
1282 | return rc; | 1641 | return rc; |
1283 | } | 1642 | } |
1284 | 1643 | ||
1644 | /** | ||
1645 | * lpfc_sli_rsp_pointers_error: Response ring pointer error handler. | ||
1646 | * @phba: Pointer to HBA context object. | ||
1647 | * @pring: Pointer to driver SLI ring object. | ||
1648 | * | ||
1649 | * This function is called from the iocb ring event handlers when | ||
1650 | * put pointer is ahead of the get pointer for a ring. This function signal | ||
1651 | * an error attention condition to the worker thread and the worker | ||
1652 | * thread will transition the HBA to offline state. | ||
1653 | **/ | ||
1285 | static void | 1654 | static void |
1286 | lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 1655 | lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
1287 | { | 1656 | { |
@@ -1312,6 +1681,21 @@ lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
1312 | return; | 1681 | return; |
1313 | } | 1682 | } |
1314 | 1683 | ||
1684 | /** | ||
1685 | * lpfc_sli_poll_fcp_ring: Handle FCP ring completion in polling mode. | ||
1686 | * @phba: Pointer to HBA context object. | ||
1687 | * | ||
1688 | * This function is called from lpfc_queuecommand, lpfc_poll_timeout, | ||
1689 | * lpfc_abort_handler and lpfc_slave_configure when FCP_RING_POLLING | ||
1690 | * is enabled. | ||
1691 | * | ||
1692 | * The caller does not hold any lock. | ||
1693 | * The function processes each response iocb in the response ring until it | ||
1694 | * finds an iocb with LE bit set and chains all the iocbs upto the iocb with | ||
1695 | * LE bit set. The function will call the completion handler of the command iocb | ||
1696 | * if the response iocb indicates a completion for a command iocb or it is | ||
1697 | * an abort completion. | ||
1698 | **/ | ||
1315 | void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba) | 1699 | void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba) |
1316 | { | 1700 | { |
1317 | struct lpfc_sli *psli = &phba->sli; | 1701 | struct lpfc_sli *psli = &phba->sli; |
@@ -1465,10 +1849,23 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba) | |||
1465 | return; | 1849 | return; |
1466 | } | 1850 | } |
1467 | 1851 | ||
1468 | /* | 1852 | /** |
1853 | * lpfc_sli_handle_fast_ring_event: Handle ring events on FCP ring. | ||
1854 | * @phba: Pointer to HBA context object. | ||
1855 | * @pring: Pointer to driver SLI ring object. | ||
1856 | * @mask: Host attention register mask for this ring. | ||
1857 | * | ||
1858 | * This function is called from the interrupt context when there is a ring | ||
1859 | * event for the fcp ring. The caller does not hold any lock. | ||
1860 | * The function processes each response iocb in the response ring until it | ||
1861 | * finds an iocb with LE bit set and chains all the iocbs upto the iocb with | ||
1862 | * LE bit set. The function will call the completion handler of the command iocb | ||
1863 | * if the response iocb indicates a completion for a command iocb or it is | ||
1864 | * an abort completion. The function will call lpfc_sli_process_unsol_iocb | ||
1865 | * function if this is an unsolicited iocb. | ||
1469 | * This routine presumes LPFC_FCP_RING handling and doesn't bother | 1866 | * This routine presumes LPFC_FCP_RING handling and doesn't bother |
1470 | * to check it explicitly. | 1867 | * to check it explicitly. This function always returns 1. |
1471 | */ | 1868 | **/ |
1472 | static int | 1869 | static int |
1473 | lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, | 1870 | lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, |
1474 | struct lpfc_sli_ring *pring, uint32_t mask) | 1871 | struct lpfc_sli_ring *pring, uint32_t mask) |
@@ -1646,6 +2043,23 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, | |||
1646 | return rc; | 2043 | return rc; |
1647 | } | 2044 | } |
1648 | 2045 | ||
2046 | /** | ||
2047 | * lpfc_sli_handle_slow_ring_event: Handle ring events for non-FCP rings. | ||
2048 | * @phba: Pointer to HBA context object. | ||
2049 | * @pring: Pointer to driver SLI ring object. | ||
2050 | * @mask: Host attention register mask for this ring. | ||
2051 | * | ||
2052 | * This function is called from the worker thread when there is a ring | ||
2053 | * event for non-fcp rings. The caller does not hold any lock . | ||
2054 | * The function processes each response iocb in the response ring until it | ||
2055 | * finds an iocb with LE bit set and chains all the iocbs upto the iocb with | ||
2056 | * LE bit set. The function will call lpfc_sli_process_sol_iocb function if the | ||
2057 | * response iocb indicates a completion of a command iocb. The function | ||
2058 | * will call lpfc_sli_process_unsol_iocb function if this is an unsolicited | ||
2059 | * iocb. The function frees the resources or calls the completion handler if | ||
2060 | * this iocb is an abort completion. The function returns 0 when the allocated | ||
2061 | * iocbs are not freed, otherwise returns 1. | ||
2062 | **/ | ||
1649 | int | 2063 | int |
1650 | lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba, | 2064 | lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba, |
1651 | struct lpfc_sli_ring *pring, uint32_t mask) | 2065 | struct lpfc_sli_ring *pring, uint32_t mask) |
@@ -1904,6 +2318,16 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba, | |||
1904 | return rc; | 2318 | return rc; |
1905 | } | 2319 | } |
1906 | 2320 | ||
2321 | /** | ||
2322 | * lpfc_sli_abort_iocb_ring: Abort all iocbs in the ring. | ||
2323 | * @phba: Pointer to HBA context object. | ||
2324 | * @pring: Pointer to driver SLI ring object. | ||
2325 | * | ||
2326 | * This function aborts all iocbs in the given ring and frees all the iocb | ||
2327 | * objects in txq. This function issues an abort iocb for all the iocb commands | ||
2328 | * in txcmplq. The iocbs in the txcmplq is not guaranteed to complete before | ||
2329 | * the return of this function. The caller is not required to hold any locks. | ||
2330 | **/ | ||
1907 | void | 2331 | void |
1908 | lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 2332 | lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
1909 | { | 2333 | { |
@@ -1943,6 +2367,19 @@ lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
1943 | } | 2367 | } |
1944 | } | 2368 | } |
1945 | 2369 | ||
2370 | /** | ||
2371 | * lpfc_sli_brdready: Check for host status bits. | ||
2372 | * @phba: Pointer to HBA context object. | ||
2373 | * @mask: Bit mask to be checked. | ||
2374 | * | ||
2375 | * This function reads the host status register and compares | ||
2376 | * with the provided bit mask to check if HBA completed | ||
2377 | * the restart. This function will wait in a loop for the | ||
2378 | * HBA to complete restart. If the HBA does not restart within | ||
2379 | * 15 iterations, the function will reset the HBA again. The | ||
2380 | * function returns 1 when HBA fail to restart otherwise returns | ||
2381 | * zero. | ||
2382 | **/ | ||
1946 | int | 2383 | int |
1947 | lpfc_sli_brdready(struct lpfc_hba *phba, uint32_t mask) | 2384 | lpfc_sli_brdready(struct lpfc_hba *phba, uint32_t mask) |
1948 | { | 2385 | { |
@@ -1990,6 +2427,13 @@ lpfc_sli_brdready(struct lpfc_hba *phba, uint32_t mask) | |||
1990 | 2427 | ||
1991 | #define BARRIER_TEST_PATTERN (0xdeadbeef) | 2428 | #define BARRIER_TEST_PATTERN (0xdeadbeef) |
1992 | 2429 | ||
2430 | /** | ||
2431 | * lpfc_reset_barrier: Make HBA ready for HBA reset. | ||
2432 | * @phba: Pointer to HBA context object. | ||
2433 | * | ||
2434 | * This function is called before resetting an HBA. This | ||
2435 | * function requests HBA to quiesce DMAs before a reset. | ||
2436 | **/ | ||
1993 | void lpfc_reset_barrier(struct lpfc_hba *phba) | 2437 | void lpfc_reset_barrier(struct lpfc_hba *phba) |
1994 | { | 2438 | { |
1995 | uint32_t __iomem *resp_buf; | 2439 | uint32_t __iomem *resp_buf; |
@@ -2063,6 +2507,17 @@ restore_hc: | |||
2063 | readl(phba->HCregaddr); /* flush */ | 2507 | readl(phba->HCregaddr); /* flush */ |
2064 | } | 2508 | } |
2065 | 2509 | ||
2510 | /** | ||
2511 | * lpfc_sli_brdkill: Issue a kill_board mailbox command. | ||
2512 | * @phba: Pointer to HBA context object. | ||
2513 | * | ||
2514 | * This function issues a kill_board mailbox command and waits for | ||
2515 | * the error attention interrupt. This function is called for stopping | ||
2516 | * the firmware processing. The caller is not required to hold any | ||
2517 | * locks. This function calls lpfc_hba_down_post function to free | ||
2518 | * any pending commands after the kill. The function will return 1 when it | ||
2519 | * fails to kill the board else will return 0. | ||
2520 | **/ | ||
2066 | int | 2521 | int |
2067 | lpfc_sli_brdkill(struct lpfc_hba *phba) | 2522 | lpfc_sli_brdkill(struct lpfc_hba *phba) |
2068 | { | 2523 | { |
@@ -2139,6 +2594,17 @@ lpfc_sli_brdkill(struct lpfc_hba *phba) | |||
2139 | return ha_copy & HA_ERATT ? 0 : 1; | 2594 | return ha_copy & HA_ERATT ? 0 : 1; |
2140 | } | 2595 | } |
2141 | 2596 | ||
2597 | /** | ||
2598 | * lpfc_sli_brdreset: Reset the HBA. | ||
2599 | * @phba: Pointer to HBA context object. | ||
2600 | * | ||
2601 | * This function resets the HBA by writing HC_INITFF to the control | ||
2602 | * register. After the HBA resets, this function resets all the iocb ring | ||
2603 | * indices. This function disables PCI layer parity checking during | ||
2604 | * the reset. | ||
2605 | * This function returns 0 always. | ||
2606 | * The caller is not required to hold any locks. | ||
2607 | **/ | ||
2142 | int | 2608 | int |
2143 | lpfc_sli_brdreset(struct lpfc_hba *phba) | 2609 | lpfc_sli_brdreset(struct lpfc_hba *phba) |
2144 | { | 2610 | { |
@@ -2191,6 +2657,19 @@ lpfc_sli_brdreset(struct lpfc_hba *phba) | |||
2191 | return 0; | 2657 | return 0; |
2192 | } | 2658 | } |
2193 | 2659 | ||
2660 | /** | ||
2661 | * lpfc_sli_brdrestart: Restart the HBA. | ||
2662 | * @phba: Pointer to HBA context object. | ||
2663 | * | ||
2664 | * This function is called in the SLI initialization code path to | ||
2665 | * restart the HBA. The caller is not required to hold any lock. | ||
2666 | * This function writes MBX_RESTART mailbox command to the SLIM and | ||
2667 | * resets the HBA. At the end of the function, it calls lpfc_hba_down_post | ||
2668 | * function to free any pending commands. The function enables | ||
2669 | * POST only during the first initialization. The function returns zero. | ||
2670 | * The function does not guarantee completion of MBX_RESTART mailbox | ||
2671 | * command before the return of this function. | ||
2672 | **/ | ||
2194 | int | 2673 | int |
2195 | lpfc_sli_brdrestart(struct lpfc_hba *phba) | 2674 | lpfc_sli_brdrestart(struct lpfc_hba *phba) |
2196 | { | 2675 | { |
@@ -2251,6 +2730,16 @@ lpfc_sli_brdrestart(struct lpfc_hba *phba) | |||
2251 | return 0; | 2730 | return 0; |
2252 | } | 2731 | } |
2253 | 2732 | ||
2733 | /** | ||
2734 | * lpfc_sli_chipset_init: Wait for the restart of the HBA after a restart. | ||
2735 | * @phba: Pointer to HBA context object. | ||
2736 | * | ||
2737 | * This function is called after a HBA restart to wait for successful | ||
2738 | * restart of the HBA. Successful restart of the HBA is indicated by | ||
2739 | * HS_FFRDY and HS_MBRDY bits. If the HBA fails to restart even after 15 | ||
2740 | * iteration, the function will restart the HBA again. The function returns | ||
2741 | * zero if HBA successfully restarted else returns negative error code. | ||
2742 | **/ | ||
2254 | static int | 2743 | static int |
2255 | lpfc_sli_chipset_init(struct lpfc_hba *phba) | 2744 | lpfc_sli_chipset_init(struct lpfc_hba *phba) |
2256 | { | 2745 | { |
@@ -2336,12 +2825,25 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba) | |||
2336 | return 0; | 2825 | return 0; |
2337 | } | 2826 | } |
2338 | 2827 | ||
2828 | /** | ||
2829 | * lpfc_sli_hbq_count: Get the number of HBQs to be configured. | ||
2830 | * | ||
2831 | * This function calculates and returns the number of HBQs required to be | ||
2832 | * configured. | ||
2833 | **/ | ||
2339 | int | 2834 | int |
2340 | lpfc_sli_hbq_count(void) | 2835 | lpfc_sli_hbq_count(void) |
2341 | { | 2836 | { |
2342 | return ARRAY_SIZE(lpfc_hbq_defs); | 2837 | return ARRAY_SIZE(lpfc_hbq_defs); |
2343 | } | 2838 | } |
2344 | 2839 | ||
2840 | /** | ||
2841 | * lpfc_sli_hbq_entry_count: Calculate total number of hbq entries. | ||
2842 | * | ||
2843 | * This function adds the number of hbq entries in every HBQ to get | ||
2844 | * the total number of hbq entries required for the HBA and returns | ||
2845 | * the total count. | ||
2846 | **/ | ||
2345 | static int | 2847 | static int |
2346 | lpfc_sli_hbq_entry_count(void) | 2848 | lpfc_sli_hbq_entry_count(void) |
2347 | { | 2849 | { |
@@ -2354,12 +2856,27 @@ lpfc_sli_hbq_entry_count(void) | |||
2354 | return count; | 2856 | return count; |
2355 | } | 2857 | } |
2356 | 2858 | ||
2859 | /** | ||
2860 | * lpfc_sli_hbq_size: Calculate memory required for all hbq entries. | ||
2861 | * | ||
2862 | * This function calculates amount of memory required for all hbq entries | ||
2863 | * to be configured and returns the total memory required. | ||
2864 | **/ | ||
2357 | int | 2865 | int |
2358 | lpfc_sli_hbq_size(void) | 2866 | lpfc_sli_hbq_size(void) |
2359 | { | 2867 | { |
2360 | return lpfc_sli_hbq_entry_count() * sizeof(struct lpfc_hbq_entry); | 2868 | return lpfc_sli_hbq_entry_count() * sizeof(struct lpfc_hbq_entry); |
2361 | } | 2869 | } |
2362 | 2870 | ||
2871 | /** | ||
2872 | * lpfc_sli_hbq_setup: configure and initialize HBQs. | ||
2873 | * @phba: Pointer to HBA context object. | ||
2874 | * | ||
2875 | * This function is called during the SLI initialization to configure | ||
2876 | * all the HBQs and post buffers to the HBQ. The caller is not | ||
2877 | * required to hold any locks. This function will return zero if successful | ||
2878 | * else it will return negative error code. | ||
2879 | **/ | ||
2363 | static int | 2880 | static int |
2364 | lpfc_sli_hbq_setup(struct lpfc_hba *phba) | 2881 | lpfc_sli_hbq_setup(struct lpfc_hba *phba) |
2365 | { | 2882 | { |
@@ -2422,6 +2939,19 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba) | |||
2422 | return 0; | 2939 | return 0; |
2423 | } | 2940 | } |
2424 | 2941 | ||
2942 | /** | ||
2943 | * lpfc_do_config_port: Issue config port mailbox command. | ||
2944 | * @phba: Pointer to HBA context object. | ||
2945 | * @sli_mode: sli mode - 2/3 | ||
2946 | * | ||
2947 | * This function is called by the sli intialization code path | ||
2948 | * to issue config_port mailbox command. This function restarts the | ||
2949 | * HBA firmware and issues a config_port mailbox command to configure | ||
2950 | * the SLI interface in the sli mode specified by sli_mode | ||
2951 | * variable. The caller is not required to hold any locks. | ||
2952 | * The function returns 0 if successful, else returns negative error | ||
2953 | * code. | ||
2954 | **/ | ||
2425 | static int | 2955 | static int |
2426 | lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode) | 2956 | lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode) |
2427 | { | 2957 | { |
@@ -2500,6 +3030,20 @@ do_prep_failed: | |||
2500 | return rc; | 3030 | return rc; |
2501 | } | 3031 | } |
2502 | 3032 | ||
3033 | |||
3034 | /** | ||
3035 | * lpfc_sli_hba_setup: SLI intialization function. | ||
3036 | * @phba: Pointer to HBA context object. | ||
3037 | * | ||
3038 | * This function is the main SLI intialization function. This function | ||
3039 | * is called by the HBA intialization code, HBA reset code and HBA | ||
3040 | * error attention handler code. Caller is not required to hold any | ||
3041 | * locks. This function issues config_port mailbox command to configure | ||
3042 | * the SLI, setup iocb rings and HBQ rings. In the end the function | ||
3043 | * calls the config_port_post function to issue init_link mailbox | ||
3044 | * command and to start the discovery. The function will return zero | ||
3045 | * if successful, else it will return negative error code. | ||
3046 | **/ | ||
2503 | int | 3047 | int |
2504 | lpfc_sli_hba_setup(struct lpfc_hba *phba) | 3048 | lpfc_sli_hba_setup(struct lpfc_hba *phba) |
2505 | { | 3049 | { |
@@ -2581,19 +3125,19 @@ lpfc_sli_hba_setup_error: | |||
2581 | return rc; | 3125 | return rc; |
2582 | } | 3126 | } |
2583 | 3127 | ||
2584 | /*! lpfc_mbox_timeout | 3128 | |
2585 | * | 3129 | /** |
2586 | * \pre | 3130 | * lpfc_mbox_timeout: Timeout call back function for mbox timer. |
2587 | * \post | 3131 | * @ptr: context object - pointer to hba structure. |
2588 | * \param hba Pointer to per struct lpfc_hba structure | ||
2589 | * \param l1 Pointer to the driver's mailbox queue. | ||
2590 | * \return | ||
2591 | * void | ||
2592 | * | ||
2593 | * \b Description: | ||
2594 | * | 3132 | * |
2595 | * This routine handles mailbox timeout events at timer interrupt context. | 3133 | * This is the callback function for mailbox timer. The mailbox |
2596 | */ | 3134 | * timer is armed when a new mailbox command is issued and the timer |
3135 | * is deleted when the mailbox complete. The function is called by | ||
3136 | * the kernel timer code when a mailbox does not complete within | ||
3137 | * expected time. This function wakes up the worker thread to | ||
3138 | * process the mailbox timeout and returns. All the processing is | ||
3139 | * done by the worker thread function lpfc_mbox_timeout_handler. | ||
3140 | **/ | ||
2597 | void | 3141 | void |
2598 | lpfc_mbox_timeout(unsigned long ptr) | 3142 | lpfc_mbox_timeout(unsigned long ptr) |
2599 | { | 3143 | { |
@@ -2612,6 +3156,15 @@ lpfc_mbox_timeout(unsigned long ptr) | |||
2612 | return; | 3156 | return; |
2613 | } | 3157 | } |
2614 | 3158 | ||
3159 | |||
3160 | /** | ||
3161 | * lpfc_mbox_timeout_handler: Worker thread function to handle mailbox timeout. | ||
3162 | * @phba: Pointer to HBA context object. | ||
3163 | * | ||
3164 | * This function is called from worker thread when a mailbox command times out. | ||
3165 | * The caller is not required to hold any locks. This function will reset the | ||
3166 | * HBA and recover all the pending commands. | ||
3167 | **/ | ||
2615 | void | 3168 | void |
2616 | lpfc_mbox_timeout_handler(struct lpfc_hba *phba) | 3169 | lpfc_mbox_timeout_handler(struct lpfc_hba *phba) |
2617 | { | 3170 | { |
@@ -2666,6 +3219,32 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba) | |||
2666 | return; | 3219 | return; |
2667 | } | 3220 | } |
2668 | 3221 | ||
3222 | /** | ||
3223 | * lpfc_sli_issue_mbox: Issue a mailbox command to firmware. | ||
3224 | * @phba: Pointer to HBA context object. | ||
3225 | * @pmbox: Pointer to mailbox object. | ||
3226 | * @flag: Flag indicating how the mailbox need to be processed. | ||
3227 | * | ||
3228 | * This function is called by discovery code and HBA management code | ||
3229 | * to submit a mailbox command to firmware. This function gets the | ||
3230 | * hbalock to protect the data structures. | ||
3231 | * The mailbox command can be submitted in polling mode, in which case | ||
3232 | * this function will wait in a polling loop for the completion of the | ||
3233 | * mailbox. | ||
3234 | * If the mailbox is submitted in no_wait mode (not polling) the | ||
3235 | * function will submit the command and returns immediately without waiting | ||
3236 | * for the mailbox completion. The no_wait is supported only when HBA | ||
3237 | * is in SLI2/SLI3 mode - interrupts are enabled. | ||
3238 | * The SLI interface allows only one mailbox pending at a time. If the | ||
3239 | * mailbox is issued in polling mode and there is already a mailbox | ||
3240 | * pending, then the function will return an error. If the mailbox is issued | ||
3241 | * in NO_WAIT mode and there is a mailbox pending already, the function | ||
3242 | * will return MBX_BUSY after queuing the mailbox into mailbox queue. | ||
3243 | * The sli layer owns the mailbox object until the completion of mailbox | ||
3244 | * command if this function return MBX_BUSY or MBX_SUCCESS. For all other | ||
3245 | * return codes the caller owns the mailbox command after the return of | ||
3246 | * the function. | ||
3247 | **/ | ||
2669 | int | 3248 | int |
2670 | lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag) | 3249 | lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag) |
2671 | { | 3250 | { |
@@ -2980,9 +3559,16 @@ out_not_finished: | |||
2980 | return MBX_NOT_FINISHED; | 3559 | return MBX_NOT_FINISHED; |
2981 | } | 3560 | } |
2982 | 3561 | ||
2983 | /* | 3562 | /** |
2984 | * Caller needs to hold lock. | 3563 | * __lpfc_sli_ringtx_put: Add an iocb to the txq. |
2985 | */ | 3564 | * @phba: Pointer to HBA context object. |
3565 | * @pring: Pointer to driver SLI ring object. | ||
3566 | * @piocb: Pointer to address of newly added command iocb. | ||
3567 | * | ||
3568 | * This function is called with hbalock held to add a command | ||
3569 | * iocb to the txq when SLI layer cannot submit the command iocb | ||
3570 | * to the ring. | ||
3571 | **/ | ||
2986 | static void | 3572 | static void |
2987 | __lpfc_sli_ringtx_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 3573 | __lpfc_sli_ringtx_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
2988 | struct lpfc_iocbq *piocb) | 3574 | struct lpfc_iocbq *piocb) |
@@ -2992,6 +3578,23 @@ __lpfc_sli_ringtx_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2992 | pring->txq_cnt++; | 3578 | pring->txq_cnt++; |
2993 | } | 3579 | } |
2994 | 3580 | ||
3581 | /** | ||
3582 | * lpfc_sli_next_iocb: Get the next iocb in the txq. | ||
3583 | * @phba: Pointer to HBA context object. | ||
3584 | * @pring: Pointer to driver SLI ring object. | ||
3585 | * @piocb: Pointer to address of newly added command iocb. | ||
3586 | * | ||
3587 | * This function is called with hbalock held before a new | ||
3588 | * iocb is submitted to the firmware. This function checks | ||
3589 | * txq to flush the iocbs in txq to Firmware before | ||
3590 | * submitting new iocbs to the Firmware. | ||
3591 | * If there are iocbs in the txq which need to be submitted | ||
3592 | * to firmware, lpfc_sli_next_iocb returns the first element | ||
3593 | * of the txq after dequeuing it from txq. | ||
3594 | * If there is no iocb in the txq then the function will return | ||
3595 | * *piocb and *piocb is set to NULL. Caller needs to check | ||
3596 | * *piocb to find if there are more commands in the txq. | ||
3597 | **/ | ||
2995 | static struct lpfc_iocbq * | 3598 | static struct lpfc_iocbq * |
2996 | lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 3599 | lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
2997 | struct lpfc_iocbq **piocb) | 3600 | struct lpfc_iocbq **piocb) |
@@ -3007,9 +3610,30 @@ lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3007 | return nextiocb; | 3610 | return nextiocb; |
3008 | } | 3611 | } |
3009 | 3612 | ||
3010 | /* | 3613 | /** |
3011 | * Lockless version of lpfc_sli_issue_iocb. | 3614 | * __lpfc_sli_issue_iocb: Lockless version of lpfc_sli_issue_iocb. |
3012 | */ | 3615 | * @phba: Pointer to HBA context object. |
3616 | * @pring: Pointer to driver SLI ring object. | ||
3617 | * @piocb: Pointer to command iocb. | ||
3618 | * @flag: Flag indicating if this command can be put into txq. | ||
3619 | * | ||
3620 | * __lpfc_sli_issue_iocb is used by other functions in the driver | ||
3621 | * to issue an iocb command to the HBA. If the PCI slot is recovering | ||
3622 | * from error state or if HBA is resetting or if LPFC_STOP_IOCB_EVENT | ||
3623 | * flag is turned on, the function returns IOCB_ERROR. | ||
3624 | * When the link is down, this function allows only iocbs for | ||
3625 | * posting buffers. | ||
3626 | * This function finds next available slot in the command ring and | ||
3627 | * posts the command to the available slot and writes the port | ||
3628 | * attention register to request HBA start processing new iocb. | ||
3629 | * If there is no slot available in the ring and | ||
3630 | * flag & SLI_IOCB_RET_IOCB is set, the new iocb is added to the | ||
3631 | * txq, otherwise the function returns IOCB_BUSY. | ||
3632 | * | ||
3633 | * This function is called with hbalock held. | ||
3634 | * The function will return success after it successfully submit the | ||
3635 | * iocb to firmware or after adding to the txq. | ||
3636 | **/ | ||
3013 | static int | 3637 | static int |
3014 | __lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 3638 | __lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
3015 | struct lpfc_iocbq *piocb, uint32_t flag) | 3639 | struct lpfc_iocbq *piocb, uint32_t flag) |
@@ -3106,6 +3730,19 @@ __lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3106 | } | 3730 | } |
3107 | 3731 | ||
3108 | 3732 | ||
3733 | /** | ||
3734 | * lpfc_sli_issue_iocb: Wrapper function for __lpfc_sli_issue_iocb. | ||
3735 | * @phba: Pointer to HBA context object. | ||
3736 | * @pring: Pointer to driver SLI ring object. | ||
3737 | * @piocb: Pointer to command iocb. | ||
3738 | * @flag: Flag indicating if this command can be put into txq. | ||
3739 | * | ||
3740 | * lpfc_sli_issue_iocb is a wrapper around __lpfc_sli_issue_iocb | ||
3741 | * function. This function gets the hbalock and calls | ||
3742 | * __lpfc_sli_issue_iocb function and will return the error returned | ||
3743 | * by __lpfc_sli_issue_iocb function. This wrapper is used by | ||
3744 | * functions which do not hold hbalock. | ||
3745 | **/ | ||
3109 | int | 3746 | int |
3110 | lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 3747 | lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
3111 | struct lpfc_iocbq *piocb, uint32_t flag) | 3748 | struct lpfc_iocbq *piocb, uint32_t flag) |
@@ -3120,6 +3757,17 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3120 | return rc; | 3757 | return rc; |
3121 | } | 3758 | } |
3122 | 3759 | ||
3760 | /** | ||
3761 | * lpfc_extra_ring_setup: Extra ring setup function. | ||
3762 | * @phba: Pointer to HBA context object. | ||
3763 | * | ||
3764 | * This function is called while driver attaches with the | ||
3765 | * HBA to setup the extra ring. The extra ring is used | ||
3766 | * only when driver needs to support target mode functionality | ||
3767 | * or IP over FC functionalities. | ||
3768 | * | ||
3769 | * This function is called with no lock held. | ||
3770 | **/ | ||
3123 | static int | 3771 | static int |
3124 | lpfc_extra_ring_setup( struct lpfc_hba *phba) | 3772 | lpfc_extra_ring_setup( struct lpfc_hba *phba) |
3125 | { | 3773 | { |
@@ -3155,6 +3803,19 @@ lpfc_extra_ring_setup( struct lpfc_hba *phba) | |||
3155 | return 0; | 3803 | return 0; |
3156 | } | 3804 | } |
3157 | 3805 | ||
3806 | /** | ||
3807 | * lpfc_sli_async_event_handler: ASYNC iocb handler function. | ||
3808 | * @phba: Pointer to HBA context object. | ||
3809 | * @pring: Pointer to driver SLI ring object. | ||
3810 | * @iocbq: Pointer to iocb object. | ||
3811 | * | ||
3812 | * This function is called by the slow ring event handler | ||
3813 | * function when there is an ASYNC event iocb in the ring. | ||
3814 | * This function is called with no lock held. | ||
3815 | * Currently this function handles only temperature related | ||
3816 | * ASYNC events. The function decodes the temperature sensor | ||
3817 | * event message and posts events for the management applications. | ||
3818 | **/ | ||
3158 | static void | 3819 | static void |
3159 | lpfc_sli_async_event_handler(struct lpfc_hba * phba, | 3820 | lpfc_sli_async_event_handler(struct lpfc_hba * phba, |
3160 | struct lpfc_sli_ring * pring, struct lpfc_iocbq * iocbq) | 3821 | struct lpfc_sli_ring * pring, struct lpfc_iocbq * iocbq) |
@@ -3210,6 +3871,17 @@ lpfc_sli_async_event_handler(struct lpfc_hba * phba, | |||
3210 | } | 3871 | } |
3211 | 3872 | ||
3212 | 3873 | ||
3874 | /** | ||
3875 | * lpfc_sli_setup: SLI ring setup function. | ||
3876 | * @phba: Pointer to HBA context object. | ||
3877 | * | ||
3878 | * lpfc_sli_setup sets up rings of the SLI interface with | ||
3879 | * number of iocbs per ring and iotags. This function is | ||
3880 | * called while driver attach to the HBA and before the | ||
3881 | * interrupts are enabled. So there is no need for locking. | ||
3882 | * | ||
3883 | * This function always returns 0. | ||
3884 | **/ | ||
3213 | int | 3885 | int |
3214 | lpfc_sli_setup(struct lpfc_hba *phba) | 3886 | lpfc_sli_setup(struct lpfc_hba *phba) |
3215 | { | 3887 | { |
@@ -3321,6 +3993,17 @@ lpfc_sli_setup(struct lpfc_hba *phba) | |||
3321 | return 0; | 3993 | return 0; |
3322 | } | 3994 | } |
3323 | 3995 | ||
3996 | /** | ||
3997 | * lpfc_sli_queue_setup: Queue initialization function. | ||
3998 | * @phba: Pointer to HBA context object. | ||
3999 | * | ||
4000 | * lpfc_sli_queue_setup sets up mailbox queues and iocb queues for each | ||
4001 | * ring. This function also initializes ring indices of each ring. | ||
4002 | * This function is called during the initialization of the SLI | ||
4003 | * interface of an HBA. | ||
4004 | * This function is called with no lock held and always returns | ||
4005 | * 1. | ||
4006 | **/ | ||
3324 | int | 4007 | int |
3325 | lpfc_sli_queue_setup(struct lpfc_hba *phba) | 4008 | lpfc_sli_queue_setup(struct lpfc_hba *phba) |
3326 | { | 4009 | { |
@@ -3349,6 +4032,23 @@ lpfc_sli_queue_setup(struct lpfc_hba *phba) | |||
3349 | return 1; | 4032 | return 1; |
3350 | } | 4033 | } |
3351 | 4034 | ||
4035 | /** | ||
4036 | * lpfc_sli_host_down: Vport cleanup function. | ||
4037 | * @vport: Pointer to virtual port object. | ||
4038 | * | ||
4039 | * lpfc_sli_host_down is called to clean up the resources | ||
4040 | * associated with a vport before destroying virtual | ||
4041 | * port data structures. | ||
4042 | * This function does following operations: | ||
4043 | * - Free discovery resources associated with this virtual | ||
4044 | * port. | ||
4045 | * - Free iocbs associated with this virtual port in | ||
4046 | * the txq. | ||
4047 | * - Send abort for all iocb commands associated with this | ||
4048 | * vport in txcmplq. | ||
4049 | * | ||
4050 | * This function is called with no lock held and always returns 1. | ||
4051 | **/ | ||
3352 | int | 4052 | int |
3353 | lpfc_sli_host_down(struct lpfc_vport *vport) | 4053 | lpfc_sli_host_down(struct lpfc_vport *vport) |
3354 | { | 4054 | { |
@@ -3411,6 +4111,21 @@ lpfc_sli_host_down(struct lpfc_vport *vport) | |||
3411 | return 1; | 4111 | return 1; |
3412 | } | 4112 | } |
3413 | 4113 | ||
4114 | /** | ||
4115 | * lpfc_sli_hba_down: Resource cleanup function for the HBA. | ||
4116 | * @phba: Pointer to HBA context object. | ||
4117 | * | ||
4118 | * This function cleans up all iocb, buffers, mailbox commands | ||
4119 | * while shutting down the HBA. This function is called with no | ||
4120 | * lock held and always returns 1. | ||
4121 | * This function does the following to cleanup driver resources: | ||
4122 | * - Free discovery resources for each virtual port | ||
4123 | * - Cleanup any pending fabric iocbs | ||
4124 | * - Iterate through the iocb txq and free each entry | ||
4125 | * in the list. | ||
4126 | * - Free up any buffer posted to the HBA | ||
4127 | * - Free mailbox commands in the mailbox queue. | ||
4128 | **/ | ||
3414 | int | 4129 | int |
3415 | lpfc_sli_hba_down(struct lpfc_hba *phba) | 4130 | lpfc_sli_hba_down(struct lpfc_hba *phba) |
3416 | { | 4131 | { |
@@ -3501,6 +4216,18 @@ lpfc_sli_hba_down(struct lpfc_hba *phba) | |||
3501 | return 1; | 4216 | return 1; |
3502 | } | 4217 | } |
3503 | 4218 | ||
4219 | /** | ||
4220 | * lpfc_sli_pcimem_bcopy: SLI memory copy function. | ||
4221 | * @srcp: Source memory pointer. | ||
4222 | * @destp: Destination memory pointer. | ||
4223 | * @cnt: Number of words required to be copied. | ||
4224 | * | ||
4225 | * This function is used for copying data between driver memory | ||
4226 | * and the SLI memory. This function also changes the endianness | ||
4227 | * of each word if native endianness is different from SLI | ||
4228 | * endianness. This function can be called with or without | ||
4229 | * lock. | ||
4230 | **/ | ||
3504 | void | 4231 | void |
3505 | lpfc_sli_pcimem_bcopy(void *srcp, void *destp, uint32_t cnt) | 4232 | lpfc_sli_pcimem_bcopy(void *srcp, void *destp, uint32_t cnt) |
3506 | { | 4233 | { |
@@ -3518,6 +4245,17 @@ lpfc_sli_pcimem_bcopy(void *srcp, void *destp, uint32_t cnt) | |||
3518 | } | 4245 | } |
3519 | } | 4246 | } |
3520 | 4247 | ||
4248 | |||
4249 | /** | ||
4250 | * lpfc_sli_ringpostbuf_put: Function to add a buffer to postbufq. | ||
4251 | * @phba: Pointer to HBA context object. | ||
4252 | * @pring: Pointer to driver SLI ring object. | ||
4253 | * @mp: Pointer to driver buffer object. | ||
4254 | * | ||
4255 | * This function is called with no lock held. | ||
4256 | * It always return zero after adding the buffer to the postbufq | ||
4257 | * buffer list. | ||
4258 | **/ | ||
3521 | int | 4259 | int |
3522 | lpfc_sli_ringpostbuf_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 4260 | lpfc_sli_ringpostbuf_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
3523 | struct lpfc_dmabuf *mp) | 4261 | struct lpfc_dmabuf *mp) |
@@ -3531,6 +4269,18 @@ lpfc_sli_ringpostbuf_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3531 | return 0; | 4269 | return 0; |
3532 | } | 4270 | } |
3533 | 4271 | ||
4272 | /** | ||
4273 | * lpfc_sli_get_buffer_tag: Tag allocation function for a buffer posted | ||
4274 | * using CMD_QUE_XRI64_CX iocb. | ||
4275 | * @phba: Pointer to HBA context object. | ||
4276 | * | ||
4277 | * When HBQ is enabled, buffers are searched based on tags. This function | ||
4278 | * allocates a tag for buffer posted using CMD_QUE_XRI64_CX iocb. The | ||
4279 | * tag is bit wise or-ed with QUE_BUFTAG_BIT to make sure that the tag | ||
4280 | * does not conflict with tags of buffer posted for unsolicited events. | ||
4281 | * The function returns the allocated tag. The function is called with | ||
4282 | * no locks held. | ||
4283 | **/ | ||
3534 | uint32_t | 4284 | uint32_t |
3535 | lpfc_sli_get_buffer_tag(struct lpfc_hba *phba) | 4285 | lpfc_sli_get_buffer_tag(struct lpfc_hba *phba) |
3536 | { | 4286 | { |
@@ -3545,6 +4295,22 @@ lpfc_sli_get_buffer_tag(struct lpfc_hba *phba) | |||
3545 | return phba->buffer_tag_count; | 4295 | return phba->buffer_tag_count; |
3546 | } | 4296 | } |
3547 | 4297 | ||
4298 | /** | ||
4299 | * lpfc_sli_ring_taggedbuf_get: Search HBQ buffer associated with | ||
4300 | * posted using CMD_QUE_XRI64_CX iocb. | ||
4301 | * @phba: Pointer to HBA context object. | ||
4302 | * @pring: Pointer to driver SLI ring object. | ||
4303 | * @tag: Buffer tag. | ||
4304 | * | ||
4305 | * Buffers posted using CMD_QUE_XRI64_CX iocb are in pring->postbufq | ||
4306 | * list. After HBA DMA data to these buffers, CMD_IOCB_RET_XRI64_CX | ||
4307 | * iocb is posted to the response ring with the tag of the buffer. | ||
4308 | * This function searches the pring->postbufq list using the tag | ||
4309 | * to find buffer associated with CMD_IOCB_RET_XRI64_CX | ||
4310 | * iocb. If the buffer is found then lpfc_dmabuf object of the | ||
4311 | * buffer is returned to the caller else NULL is returned. | ||
4312 | * This function is called with no lock held. | ||
4313 | **/ | ||
3548 | struct lpfc_dmabuf * | 4314 | struct lpfc_dmabuf * |
3549 | lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 4315 | lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
3550 | uint32_t tag) | 4316 | uint32_t tag) |
@@ -3573,6 +4339,23 @@ lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3573 | return NULL; | 4339 | return NULL; |
3574 | } | 4340 | } |
3575 | 4341 | ||
4342 | /** | ||
4343 | * lpfc_sli_ringpostbuf_get: SLI2 buffer search function for | ||
4344 | * unsolicited ct and els events. | ||
4345 | * @phba: Pointer to HBA context object. | ||
4346 | * @pring: Pointer to driver SLI ring object. | ||
4347 | * @phys: DMA address of the buffer. | ||
4348 | * | ||
4349 | * This function searches the buffer list using the dma_address | ||
4350 | * of unsolicited event to find the driver's lpfc_dmabuf object | ||
4351 | * corresponding to the dma_address. The function returns the | ||
4352 | * lpfc_dmabuf object if a buffer is found else it returns NULL. | ||
4353 | * This function is called by the ct and els unsolicited event | ||
4354 | * handlers to get the buffer associated with the unsolicited | ||
4355 | * event. | ||
4356 | * | ||
4357 | * This function is called with no lock held. | ||
4358 | **/ | ||
3576 | struct lpfc_dmabuf * | 4359 | struct lpfc_dmabuf * |
3577 | lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 4360 | lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
3578 | dma_addr_t phys) | 4361 | dma_addr_t phys) |
@@ -3600,6 +4383,17 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3600 | return NULL; | 4383 | return NULL; |
3601 | } | 4384 | } |
3602 | 4385 | ||
4386 | /** | ||
4387 | * lpfc_sli_abort_els_cmpl: Completion handler for the els abort iocbs. | ||
4388 | * @phba: Pointer to HBA context object. | ||
4389 | * @cmdiocb: Pointer to driver command iocb object. | ||
4390 | * @rspiocb: Pointer to driver response iocb object. | ||
4391 | * | ||
4392 | * This function is the completion handler for the abort iocbs for | ||
4393 | * ELS commands. This function is called from the ELS ring event | ||
4394 | * handler with no lock held. This function frees memory resources | ||
4395 | * associated with the abort iocb. | ||
4396 | **/ | ||
3603 | static void | 4397 | static void |
3604 | lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | 4398 | lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
3605 | struct lpfc_iocbq *rspiocb) | 4399 | struct lpfc_iocbq *rspiocb) |
@@ -3665,6 +4459,17 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
3665 | return; | 4459 | return; |
3666 | } | 4460 | } |
3667 | 4461 | ||
4462 | /** | ||
4463 | * lpfc_ignore_els_cmpl: Completion handler for aborted ELS command. | ||
4464 | * @phba: Pointer to HBA context object. | ||
4465 | * @cmdiocb: Pointer to driver command iocb object. | ||
4466 | * @rspiocb: Pointer to driver response iocb object. | ||
4467 | * | ||
4468 | * The function is called from SLI ring event handler with no | ||
4469 | * lock held. This function is the completion handler for ELS commands | ||
4470 | * which are aborted. The function frees memory resources used for | ||
4471 | * the aborted ELS commands. | ||
4472 | **/ | ||
3668 | static void | 4473 | static void |
3669 | lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | 4474 | lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
3670 | struct lpfc_iocbq *rspiocb) | 4475 | struct lpfc_iocbq *rspiocb) |
@@ -3684,6 +4489,17 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
3684 | return; | 4489 | return; |
3685 | } | 4490 | } |
3686 | 4491 | ||
4492 | /** | ||
4493 | * lpfc_sli_issue_abort_iotag: Abort function for a command iocb. | ||
4494 | * @phba: Pointer to HBA context object. | ||
4495 | * @pring: Pointer to driver SLI ring object. | ||
4496 | * @cmdiocb: Pointer to driver command iocb object. | ||
4497 | * | ||
4498 | * This function issues an abort iocb for the provided command | ||
4499 | * iocb. This function is called with hbalock held. | ||
4500 | * The function returns 0 when it fails due to memory allocation | ||
4501 | * failure or when the command iocb is an abort request. | ||
4502 | **/ | ||
3687 | int | 4503 | int |
3688 | lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 4504 | lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
3689 | struct lpfc_iocbq *cmdiocb) | 4505 | struct lpfc_iocbq *cmdiocb) |
@@ -3757,6 +4573,29 @@ abort_iotag_exit: | |||
3757 | return retval; | 4573 | return retval; |
3758 | } | 4574 | } |
3759 | 4575 | ||
4576 | /** | ||
4577 | * lpfc_sli_validate_fcp_iocb: Filtering function, used to find commands | ||
4578 | * associated with a vport/SCSI target/lun. | ||
4579 | * @iocbq: Pointer to driver iocb object. | ||
4580 | * @vport: Pointer to driver virtual port object. | ||
4581 | * @tgt_id: SCSI ID of the target. | ||
4582 | * @lun_id: LUN ID of the scsi device. | ||
4583 | * @ctx_cmd: LPFC_CTX_LUN/LPFC_CTX_TGT/LPFC_CTX_HOST | ||
4584 | * | ||
4585 | * This function acts as iocb filter for functions which abort or count | ||
4586 | * all FCP iocbs pending on a lun/SCSI target/SCSI host. It will return | ||
4587 | * 0 if the filtering criteria is met for the given iocb and will return | ||
4588 | * 1 if the filtering criteria is not met. | ||
4589 | * If ctx_cmd == LPFC_CTX_LUN, the function returns 0 only if the | ||
4590 | * given iocb is for the SCSI device specified by vport, tgt_id and | ||
4591 | * lun_id parameter. | ||
4592 | * If ctx_cmd == LPFC_CTX_TGT, the function returns 0 only if the | ||
4593 | * given iocb is for the SCSI target specified by vport and tgt_id | ||
4594 | * parameters. | ||
4595 | * If ctx_cmd == LPFC_CTX_HOST, the function returns 0 only if the | ||
4596 | * given iocb is for the SCSI host associated with the given vport. | ||
4597 | * This function is called with no locks held. | ||
4598 | **/ | ||
3760 | static int | 4599 | static int |
3761 | lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, struct lpfc_vport *vport, | 4600 | lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, struct lpfc_vport *vport, |
3762 | uint16_t tgt_id, uint64_t lun_id, | 4601 | uint16_t tgt_id, uint64_t lun_id, |
@@ -3800,6 +4639,25 @@ lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, struct lpfc_vport *vport, | |||
3800 | return rc; | 4639 | return rc; |
3801 | } | 4640 | } |
3802 | 4641 | ||
4642 | /** | ||
4643 | * lpfc_sli_sum_iocb: Function to count the number of FCP iocbs pending. | ||
4644 | * @vport: Pointer to virtual port. | ||
4645 | * @tgt_id: SCSI ID of the target. | ||
4646 | * @lun_id: LUN ID of the scsi device. | ||
4647 | * @ctx_cmd: LPFC_CTX_LUN/LPFC_CTX_TGT/LPFC_CTX_HOST. | ||
4648 | * | ||
4649 | * This function returns number of FCP commands pending for the vport. | ||
4650 | * When ctx_cmd == LPFC_CTX_LUN, the function returns number of FCP | ||
4651 | * commands pending on the vport associated with SCSI device specified | ||
4652 | * by tgt_id and lun_id parameters. | ||
4653 | * When ctx_cmd == LPFC_CTX_TGT, the function returns number of FCP | ||
4654 | * commands pending on the vport associated with SCSI target specified | ||
4655 | * by tgt_id parameter. | ||
4656 | * When ctx_cmd == LPFC_CTX_HOST, the function returns number of FCP | ||
4657 | * commands pending on the vport. | ||
4658 | * This function returns the number of iocbs which satisfy the filter. | ||
4659 | * This function is called without any lock held. | ||
4660 | **/ | ||
3803 | int | 4661 | int |
3804 | lpfc_sli_sum_iocb(struct lpfc_vport *vport, uint16_t tgt_id, uint64_t lun_id, | 4662 | lpfc_sli_sum_iocb(struct lpfc_vport *vport, uint16_t tgt_id, uint64_t lun_id, |
3805 | lpfc_ctx_cmd ctx_cmd) | 4663 | lpfc_ctx_cmd ctx_cmd) |
@@ -3819,6 +4677,17 @@ lpfc_sli_sum_iocb(struct lpfc_vport *vport, uint16_t tgt_id, uint64_t lun_id, | |||
3819 | return sum; | 4677 | return sum; |
3820 | } | 4678 | } |
3821 | 4679 | ||
4680 | /** | ||
4681 | * lpfc_sli_abort_fcp_cmpl: Completion handler function for an aborted | ||
4682 | * FCP iocb. | ||
4683 | * @phba: Pointer to HBA context object | ||
4684 | * @cmdiocb: Pointer to command iocb object. | ||
4685 | * @rspiocb: Pointer to response iocb object. | ||
4686 | * | ||
4687 | * This function is called when an aborted FCP iocb completes. This | ||
4688 | * function is called by the ring event handler with no lock held. | ||
4689 | * This function frees the iocb. | ||
4690 | **/ | ||
3822 | void | 4691 | void |
3823 | lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | 4692 | lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
3824 | struct lpfc_iocbq *rspiocb) | 4693 | struct lpfc_iocbq *rspiocb) |
@@ -3827,6 +4696,28 @@ lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
3827 | return; | 4696 | return; |
3828 | } | 4697 | } |
3829 | 4698 | ||
4699 | /** | ||
4700 | * lpfc_sli_abort_iocb: This function issue abort for all SCSI commands | ||
4701 | * pending on a SCSI host(vport)/target/lun. | ||
4702 | * @vport: Pointer to virtual port. | ||
4703 | * @pring: Pointer to driver SLI ring object. | ||
4704 | * @tgt_id: SCSI ID of the target. | ||
4705 | * @lun_id: LUN ID of the scsi device. | ||
4706 | * @abort_cmd: LPFC_CTX_LUN/LPFC_CTX_TGT/LPFC_CTX_HOST. | ||
4707 | * | ||
4708 | * This function sends an abort command for every SCSI command | ||
4709 | * associated with the given virtual port pending on the ring | ||
4710 | * filtered by lpfc_sli_validate_fcp_iocb function. | ||
4711 | * When abort_cmd == LPFC_CTX_LUN, the function sends abort only to the | ||
4712 | * FCP iocbs associated with lun specified by tgt_id and lun_id | ||
4713 | * parameters | ||
4714 | * When abort_cmd == LPFC_CTX_TGT, the function sends abort only to the | ||
4715 | * FCP iocbs associated with SCSI target specified by tgt_id parameter. | ||
4716 | * When abort_cmd == LPFC_CTX_HOST, the function sends abort to all | ||
4717 | * FCP iocbs associated with virtual port. | ||
4718 | * This function returns number of iocbs it failed to abort. | ||
4719 | * This function is called with no locks held. | ||
4720 | **/ | ||
3830 | int | 4721 | int |
3831 | lpfc_sli_abort_iocb(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, | 4722 | lpfc_sli_abort_iocb(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, |
3832 | uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd abort_cmd) | 4723 | uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd abort_cmd) |
@@ -3878,6 +4769,24 @@ lpfc_sli_abort_iocb(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, | |||
3878 | return errcnt; | 4769 | return errcnt; |
3879 | } | 4770 | } |
3880 | 4771 | ||
4772 | /** | ||
4773 | * lpfc_sli_wake_iocb_wait: iocb completion handler for iocb issued using | ||
4774 | * lpfc_sli_issue_iocb_wait. | ||
4775 | * @phba: Pointer to HBA context object. | ||
4776 | * @cmdiocbq: Pointer to command iocb. | ||
4777 | * @rspiocbq: Pointer to response iocb. | ||
4778 | * | ||
4779 | * This function is the completion handler for iocbs issued using | ||
4780 | * lpfc_sli_issue_iocb_wait function. This function is called by the | ||
4781 | * ring event handler function without any lock held. This function | ||
4782 | * can be called from both worker thread context and interrupt | ||
4783 | * context. This function also can be called from other thread which | ||
4784 | * cleans up the SLI layer objects. | ||
4785 | * This function copy the contents of the response iocb to the | ||
4786 | * response iocb memory object provided by the caller of | ||
4787 | * lpfc_sli_issue_iocb_wait and then wakes up the thread which | ||
4788 | * sleeps for the iocb completion. | ||
4789 | **/ | ||
3881 | static void | 4790 | static void |
3882 | lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, | 4791 | lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, |
3883 | struct lpfc_iocbq *cmdiocbq, | 4792 | struct lpfc_iocbq *cmdiocbq, |
@@ -3899,13 +4808,36 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, | |||
3899 | return; | 4808 | return; |
3900 | } | 4809 | } |
3901 | 4810 | ||
3902 | /* | 4811 | /** |
3903 | * Issue the caller's iocb and wait for its completion, but no longer than the | 4812 | * lpfc_sli_issue_iocb_wait: Synchronous function to issue iocb commands. |
3904 | * caller's timeout. Note that iocb_flags is cleared before the | 4813 | * @phba: Pointer to HBA context object.. |
3905 | * lpfc_sli_issue_call since the wake routine sets a unique value and by | 4814 | * @pring: Pointer to sli ring. |
3906 | * definition this is a wait function. | 4815 | * @piocb: Pointer to command iocb. |
3907 | */ | 4816 | * @prspiocbq: Pointer to response iocb. |
3908 | 4817 | * @timeout: Timeout in number of seconds. | |
4818 | * | ||
4819 | * This function issues the iocb to firmware and waits for the | ||
4820 | * iocb to complete. If the iocb command is not | ||
4821 | * completed within timeout seconds, it returns IOCB_TIMEDOUT. | ||
4822 | * Caller should not free the iocb resources if this function | ||
4823 | * returns IOCB_TIMEDOUT. | ||
4824 | * The function waits for the iocb completion using an | ||
4825 | * non-interruptible wait. | ||
4826 | * This function will sleep while waiting for iocb completion. | ||
4827 | * So, this function should not be called from any context which | ||
4828 | * does not allow sleeping. Due to the same reason, this function | ||
4829 | * cannot be called with interrupt disabled. | ||
4830 | * This function assumes that the iocb completions occur while | ||
4831 | * this function sleep. So, this function cannot be called from | ||
4832 | * the thread which process iocb completion for this ring. | ||
4833 | * This function clears the iocb_flag of the iocb object before | ||
4834 | * issuing the iocb and the iocb completion handler sets this | ||
4835 | * flag and wakes this thread when the iocb completes. | ||
4836 | * The contents of the response iocb will be copied to prspiocbq | ||
4837 | * by the completion handler when the command completes. | ||
4838 | * This function returns IOCB_SUCCESS when success. | ||
4839 | * This function is called with no lock held. | ||
4840 | **/ | ||
3909 | int | 4841 | int |
3910 | lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, | 4842 | lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, |
3911 | struct lpfc_sli_ring *pring, | 4843 | struct lpfc_sli_ring *pring, |
@@ -3983,6 +4915,32 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, | |||
3983 | return retval; | 4915 | return retval; |
3984 | } | 4916 | } |
3985 | 4917 | ||
4918 | /** | ||
4919 | * lpfc_sli_issue_mbox_wait: Synchronous function to issue mailbox. | ||
4920 | * @phba: Pointer to HBA context object. | ||
4921 | * @pmboxq: Pointer to driver mailbox object. | ||
4922 | * @timeout: Timeout in number of seconds. | ||
4923 | * | ||
4924 | * This function issues the mailbox to firmware and waits for the | ||
4925 | * mailbox command to complete. If the mailbox command is not | ||
4926 | * completed within timeout seconds, it returns MBX_TIMEOUT. | ||
4927 | * The function waits for the mailbox completion using an | ||
4928 | * interruptible wait. If the thread is woken up due to a | ||
4929 | * signal, MBX_TIMEOUT error is returned to the caller. Caller | ||
4930 | * should not free the mailbox resources, if this function returns | ||
4931 | * MBX_TIMEOUT. | ||
4932 | * This function will sleep while waiting for mailbox completion. | ||
4933 | * So, this function should not be called from any context which | ||
4934 | * does not allow sleeping. Due to the same reason, this function | ||
4935 | * cannot be called with interrupt disabled. | ||
4936 | * This function assumes that the mailbox completion occurs while | ||
4937 | * this function sleep. So, this function cannot be called from | ||
4938 | * the worker thread which processes mailbox completion. | ||
4939 | * This function is called in the context of HBA management | ||
4940 | * applications. | ||
4941 | * This function returns MBX_SUCCESS when successful. | ||
4942 | * This function is called with no lock held. | ||
4943 | **/ | ||
3986 | int | 4944 | int |
3987 | lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq, | 4945 | lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq, |
3988 | uint32_t timeout) | 4946 | uint32_t timeout) |
@@ -4027,6 +4985,18 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq, | |||
4027 | return retval; | 4985 | return retval; |
4028 | } | 4986 | } |
4029 | 4987 | ||
4988 | /** | ||
4989 | * lpfc_sli_flush_mbox_queue: mailbox queue cleanup function. | ||
4990 | * @phba: Pointer to HBA context. | ||
4991 | * | ||
4992 | * This function is called to cleanup any pending mailbox | ||
4993 | * objects in the driver queue before bringing the HBA offline. | ||
4994 | * This function is called while resetting the HBA. | ||
4995 | * The function is called without any lock held. The function | ||
4996 | * takes hbalock to update SLI data structure. | ||
4997 | * This function returns 1 when there is an active mailbox | ||
4998 | * command pending else returns 0. | ||
4999 | **/ | ||
4030 | int | 5000 | int |
4031 | lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba) | 5001 | lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba) |
4032 | { | 5002 | { |
@@ -4058,6 +5028,27 @@ lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba) | |||
4058 | return (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) ? 1 : 0; | 5028 | return (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) ? 1 : 0; |
4059 | } | 5029 | } |
4060 | 5030 | ||
5031 | /** | ||
5032 | * lpfc_intr_handler: The interrupt handler of lpfc driver. | ||
5033 | * @irq: Interrupt number. | ||
5034 | * @dev_id: The device context pointer. | ||
5035 | * | ||
5036 | * This function is called from the PCI layer when there is | ||
5037 | * an event in the HBA which requires driver attention. When | ||
5038 | * the PCI slot is in error recovery or the HBA is undergoing | ||
5039 | * initialization the interrupt handler will not process the | ||
5040 | * interrupt. | ||
5041 | * The error attention, link attention and els ring attention | ||
5042 | * events are handled by the worker thread. The interrupt | ||
5043 | * handler signals the worker thread and returns for these | ||
5044 | * events. | ||
5045 | * The SCSI ring event and mailbox events are handled in the | ||
5046 | * interrupt context. | ||
5047 | * This function is called without any lock held. It gets the | ||
5048 | * hbalock to access and update SLI data structures. | ||
5049 | * This function returns IRQ_HANDLED when interrupt is handled | ||
5050 | * else it returns IRQ_NONE. | ||
5051 | **/ | ||
4061 | irqreturn_t | 5052 | irqreturn_t |
4062 | lpfc_intr_handler(int irq, void *dev_id) | 5053 | lpfc_intr_handler(int irq, void *dev_id) |
4063 | { | 5054 | { |