diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_sli.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_sli.c | 2047 |
1 files changed, 1369 insertions, 678 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index a1e721459e2b..f4d5a6b00fde 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -38,23 +38,25 @@ | |||
38 | #include "lpfc_crtn.h" | 38 | #include "lpfc_crtn.h" |
39 | #include "lpfc_logmsg.h" | 39 | #include "lpfc_logmsg.h" |
40 | #include "lpfc_compat.h" | 40 | #include "lpfc_compat.h" |
41 | #include "lpfc_debugfs.h" | ||
41 | 42 | ||
42 | /* | 43 | /* |
43 | * Define macro to log: Mailbox command x%x cannot issue Data | 44 | * Define macro to log: Mailbox command x%x cannot issue Data |
44 | * This allows multiple uses of lpfc_msgBlk0311 | 45 | * This allows multiple uses of lpfc_msgBlk0311 |
45 | * w/o perturbing log msg utility. | 46 | * w/o perturbing log msg utility. |
46 | */ | 47 | */ |
47 | #define LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) \ | 48 | #define LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag) \ |
48 | lpfc_printf_log(phba, \ | 49 | lpfc_printf_log(phba, \ |
49 | KERN_INFO, \ | 50 | KERN_INFO, \ |
50 | LOG_MBOX | LOG_SLI, \ | 51 | LOG_MBOX | LOG_SLI, \ |
51 | "%d:0311 Mailbox command x%x cannot issue " \ | 52 | "%d (%d):0311 Mailbox command x%x cannot " \ |
52 | "Data: x%x x%x x%x\n", \ | 53 | "issue Data: x%x x%x x%x\n", \ |
53 | phba->brd_no, \ | 54 | phba->brd_no, \ |
54 | mb->mbxCommand, \ | 55 | pmbox->vport ? pmbox->vport->vpi : 0, \ |
55 | phba->hba_state, \ | 56 | pmbox->mb.mbxCommand, \ |
57 | phba->pport->port_state, \ | ||
56 | psli->sli_flag, \ | 58 | psli->sli_flag, \ |
57 | flag); | 59 | flag) |
58 | 60 | ||
59 | 61 | ||
60 | /* There are only four IOCB completion types. */ | 62 | /* There are only four IOCB completion types. */ |
@@ -65,8 +67,26 @@ typedef enum _lpfc_iocb_type { | |||
65 | LPFC_ABORT_IOCB | 67 | LPFC_ABORT_IOCB |
66 | } lpfc_iocb_type; | 68 | } lpfc_iocb_type; |
67 | 69 | ||
68 | struct lpfc_iocbq * | 70 | /* SLI-2/SLI-3 provide different sized iocbs. Given a pointer |
69 | lpfc_sli_get_iocbq(struct lpfc_hba * phba) | 71 | * to the start of the ring, and the slot number of the |
72 | * desired iocb entry, calc a pointer to that entry. | ||
73 | */ | ||
74 | static inline IOCB_t * | ||
75 | lpfc_cmd_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | ||
76 | { | ||
77 | return (IOCB_t *) (((char *) pring->cmdringaddr) + | ||
78 | pring->cmdidx * phba->iocb_cmd_size); | ||
79 | } | ||
80 | |||
81 | static inline IOCB_t * | ||
82 | lpfc_resp_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | ||
83 | { | ||
84 | return (IOCB_t *) (((char *) pring->rspringaddr) + | ||
85 | pring->rspidx * phba->iocb_rsp_size); | ||
86 | } | ||
87 | |||
88 | static struct lpfc_iocbq * | ||
89 | __lpfc_sli_get_iocbq(struct lpfc_hba *phba) | ||
70 | { | 90 | { |
71 | struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list; | 91 | struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list; |
72 | struct lpfc_iocbq * iocbq = NULL; | 92 | struct lpfc_iocbq * iocbq = NULL; |
@@ -75,10 +95,22 @@ lpfc_sli_get_iocbq(struct lpfc_hba * phba) | |||
75 | return iocbq; | 95 | return iocbq; |
76 | } | 96 | } |
77 | 97 | ||
98 | struct lpfc_iocbq * | ||
99 | lpfc_sli_get_iocbq(struct lpfc_hba *phba) | ||
100 | { | ||
101 | struct lpfc_iocbq * iocbq = NULL; | ||
102 | unsigned long iflags; | ||
103 | |||
104 | spin_lock_irqsave(&phba->hbalock, iflags); | ||
105 | iocbq = __lpfc_sli_get_iocbq(phba); | ||
106 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
107 | return iocbq; | ||
108 | } | ||
109 | |||
78 | void | 110 | void |
79 | lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocbq) | 111 | __lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) |
80 | { | 112 | { |
81 | size_t start_clean = (size_t)(&((struct lpfc_iocbq *)NULL)->iocb); | 113 | size_t start_clean = offsetof(struct lpfc_iocbq, iocb); |
82 | 114 | ||
83 | /* | 115 | /* |
84 | * Clean all volatile data fields, preserve iotag and node struct. | 116 | * Clean all volatile data fields, preserve iotag and node struct. |
@@ -87,6 +119,19 @@ lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocbq) | |||
87 | list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); | 119 | list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); |
88 | } | 120 | } |
89 | 121 | ||
122 | void | ||
123 | lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | ||
124 | { | ||
125 | unsigned long iflags; | ||
126 | |||
127 | /* | ||
128 | * Clean all volatile data fields, preserve iotag and node struct. | ||
129 | */ | ||
130 | spin_lock_irqsave(&phba->hbalock, iflags); | ||
131 | __lpfc_sli_release_iocbq(phba, iocbq); | ||
132 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
133 | } | ||
134 | |||
90 | /* | 135 | /* |
91 | * Translate the iocb command to an iocb command type used to decide the final | 136 | * Translate the iocb command to an iocb command type used to decide the final |
92 | * disposition of each completed IOCB. | 137 | * disposition of each completed IOCB. |
@@ -155,6 +200,9 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd) | |||
155 | case CMD_RCV_ELS_REQ_CX: | 200 | case CMD_RCV_ELS_REQ_CX: |
156 | case CMD_RCV_SEQUENCE64_CX: | 201 | case CMD_RCV_SEQUENCE64_CX: |
157 | case CMD_RCV_ELS_REQ64_CX: | 202 | case CMD_RCV_ELS_REQ64_CX: |
203 | case CMD_IOCB_RCV_SEQ64_CX: | ||
204 | case CMD_IOCB_RCV_ELS64_CX: | ||
205 | case CMD_IOCB_RCV_CONT64_CX: | ||
158 | type = LPFC_UNSOL_IOCB; | 206 | type = LPFC_UNSOL_IOCB; |
159 | break; | 207 | break; |
160 | default: | 208 | default: |
@@ -166,73 +214,77 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd) | |||
166 | } | 214 | } |
167 | 215 | ||
168 | static int | 216 | static int |
169 | lpfc_sli_ring_map(struct lpfc_hba * phba, LPFC_MBOXQ_t *pmb) | 217 | lpfc_sli_ring_map(struct lpfc_hba *phba) |
170 | { | 218 | { |
171 | struct lpfc_sli *psli = &phba->sli; | 219 | struct lpfc_sli *psli = &phba->sli; |
172 | MAILBOX_t *pmbox = &pmb->mb; | 220 | LPFC_MBOXQ_t *pmb; |
173 | int i, rc; | 221 | MAILBOX_t *pmbox; |
222 | int i, rc, ret = 0; | ||
174 | 223 | ||
224 | pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | ||
225 | if (!pmb) | ||
226 | return -ENOMEM; | ||
227 | pmbox = &pmb->mb; | ||
228 | phba->link_state = LPFC_INIT_MBX_CMDS; | ||
175 | for (i = 0; i < psli->num_rings; i++) { | 229 | for (i = 0; i < psli->num_rings; i++) { |
176 | phba->hba_state = LPFC_INIT_MBX_CMDS; | ||
177 | lpfc_config_ring(phba, i, pmb); | 230 | lpfc_config_ring(phba, i, pmb); |
178 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); | 231 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); |
179 | if (rc != MBX_SUCCESS) { | 232 | if (rc != MBX_SUCCESS) { |
180 | lpfc_printf_log(phba, | 233 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
181 | KERN_ERR, | 234 | "%d:0446 Adapter failed to init (%d), " |
182 | LOG_INIT, | ||
183 | "%d:0446 Adapter failed to init, " | ||
184 | "mbxCmd x%x CFG_RING, mbxStatus x%x, " | 235 | "mbxCmd x%x CFG_RING, mbxStatus x%x, " |
185 | "ring %d\n", | 236 | "ring %d\n", |
186 | phba->brd_no, | 237 | phba->brd_no, rc, |
187 | pmbox->mbxCommand, | 238 | pmbox->mbxCommand, |
188 | pmbox->mbxStatus, | 239 | pmbox->mbxStatus, |
189 | i); | 240 | i); |
190 | phba->hba_state = LPFC_HBA_ERROR; | 241 | phba->link_state = LPFC_HBA_ERROR; |
191 | return -ENXIO; | 242 | ret = -ENXIO; |
243 | break; | ||
192 | } | 244 | } |
193 | } | 245 | } |
194 | return 0; | 246 | mempool_free(pmb, phba->mbox_mem_pool); |
247 | return ret; | ||
195 | } | 248 | } |
196 | 249 | ||
197 | static int | 250 | static int |
198 | lpfc_sli_ringtxcmpl_put(struct lpfc_hba * phba, | 251 | lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
199 | struct lpfc_sli_ring * pring, struct lpfc_iocbq * piocb) | 252 | struct lpfc_iocbq *piocb) |
200 | { | 253 | { |
201 | list_add_tail(&piocb->list, &pring->txcmplq); | 254 | list_add_tail(&piocb->list, &pring->txcmplq); |
202 | pring->txcmplq_cnt++; | 255 | pring->txcmplq_cnt++; |
203 | if (unlikely(pring->ringno == LPFC_ELS_RING)) | 256 | if ((unlikely(pring->ringno == LPFC_ELS_RING)) && |
204 | mod_timer(&phba->els_tmofunc, | 257 | (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && |
205 | jiffies + HZ * (phba->fc_ratov << 1)); | 258 | (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) { |
259 | if (!piocb->vport) | ||
260 | BUG(); | ||
261 | else | ||
262 | mod_timer(&piocb->vport->els_tmofunc, | ||
263 | jiffies + HZ * (phba->fc_ratov << 1)); | ||
264 | } | ||
206 | 265 | ||
207 | return (0); | 266 | |
267 | return 0; | ||
208 | } | 268 | } |
209 | 269 | ||
210 | static struct lpfc_iocbq * | 270 | static struct lpfc_iocbq * |
211 | lpfc_sli_ringtx_get(struct lpfc_hba * phba, struct lpfc_sli_ring * pring) | 271 | lpfc_sli_ringtx_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
212 | { | 272 | { |
213 | struct list_head *dlp; | ||
214 | struct lpfc_iocbq *cmd_iocb; | 273 | struct lpfc_iocbq *cmd_iocb; |
215 | 274 | ||
216 | dlp = &pring->txq; | 275 | list_remove_head((&pring->txq), cmd_iocb, struct lpfc_iocbq, list); |
217 | cmd_iocb = NULL; | 276 | if (cmd_iocb != NULL) |
218 | list_remove_head((&pring->txq), cmd_iocb, | ||
219 | struct lpfc_iocbq, | ||
220 | list); | ||
221 | if (cmd_iocb) { | ||
222 | /* If the first ptr is not equal to the list header, | ||
223 | * deque the IOCBQ_t and return it. | ||
224 | */ | ||
225 | pring->txq_cnt--; | 277 | pring->txq_cnt--; |
226 | } | 278 | return cmd_iocb; |
227 | return (cmd_iocb); | ||
228 | } | 279 | } |
229 | 280 | ||
230 | static IOCB_t * | 281 | static IOCB_t * |
231 | lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 282 | lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
232 | { | 283 | { |
233 | struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno]; | 284 | struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? |
285 | &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | ||
286 | &phba->slim2p->mbx.us.s2.port[pring->ringno]; | ||
234 | uint32_t max_cmd_idx = pring->numCiocb; | 287 | uint32_t max_cmd_idx = pring->numCiocb; |
235 | IOCB_t *iocb = NULL; | ||
236 | 288 | ||
237 | if ((pring->next_cmdidx == pring->cmdidx) && | 289 | if ((pring->next_cmdidx == pring->cmdidx) && |
238 | (++pring->next_cmdidx >= max_cmd_idx)) | 290 | (++pring->next_cmdidx >= max_cmd_idx)) |
@@ -249,15 +301,17 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
249 | phba->brd_no, pring->ringno, | 301 | phba->brd_no, pring->ringno, |
250 | pring->local_getidx, max_cmd_idx); | 302 | pring->local_getidx, max_cmd_idx); |
251 | 303 | ||
252 | phba->hba_state = LPFC_HBA_ERROR; | 304 | phba->link_state = LPFC_HBA_ERROR; |
253 | /* | 305 | /* |
254 | * All error attention handlers are posted to | 306 | * All error attention handlers are posted to |
255 | * worker thread | 307 | * worker thread |
256 | */ | 308 | */ |
257 | phba->work_ha |= HA_ERATT; | 309 | phba->work_ha |= HA_ERATT; |
258 | phba->work_hs = HS_FFER3; | 310 | phba->work_hs = HS_FFER3; |
311 | |||
312 | /* hbalock should already be held */ | ||
259 | if (phba->work_wait) | 313 | if (phba->work_wait) |
260 | wake_up(phba->work_wait); | 314 | lpfc_worker_wake_up(phba); |
261 | 315 | ||
262 | return NULL; | 316 | return NULL; |
263 | } | 317 | } |
@@ -266,39 +320,34 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
266 | return NULL; | 320 | return NULL; |
267 | } | 321 | } |
268 | 322 | ||
269 | iocb = IOCB_ENTRY(pring->cmdringaddr, pring->cmdidx); | 323 | return lpfc_cmd_iocb(phba, pring); |
270 | |||
271 | return iocb; | ||
272 | } | 324 | } |
273 | 325 | ||
274 | uint16_t | 326 | uint16_t |
275 | lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocbq) | 327 | lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) |
276 | { | 328 | { |
277 | struct lpfc_iocbq ** new_arr; | 329 | struct lpfc_iocbq **new_arr; |
278 | struct lpfc_iocbq ** old_arr; | 330 | struct lpfc_iocbq **old_arr; |
279 | size_t new_len; | 331 | size_t new_len; |
280 | struct lpfc_sli *psli = &phba->sli; | 332 | struct lpfc_sli *psli = &phba->sli; |
281 | uint16_t iotag; | 333 | uint16_t iotag; |
282 | 334 | ||
283 | spin_lock_irq(phba->host->host_lock); | 335 | spin_lock_irq(&phba->hbalock); |
284 | iotag = psli->last_iotag; | 336 | iotag = psli->last_iotag; |
285 | if(++iotag < psli->iocbq_lookup_len) { | 337 | if(++iotag < psli->iocbq_lookup_len) { |
286 | psli->last_iotag = iotag; | 338 | psli->last_iotag = iotag; |
287 | psli->iocbq_lookup[iotag] = iocbq; | 339 | psli->iocbq_lookup[iotag] = iocbq; |
288 | spin_unlock_irq(phba->host->host_lock); | 340 | spin_unlock_irq(&phba->hbalock); |
289 | iocbq->iotag = iotag; | 341 | iocbq->iotag = iotag; |
290 | return iotag; | 342 | return iotag; |
291 | } | 343 | } else if (psli->iocbq_lookup_len < (0xffff |
292 | else if (psli->iocbq_lookup_len < (0xffff | ||
293 | - LPFC_IOCBQ_LOOKUP_INCREMENT)) { | 344 | - LPFC_IOCBQ_LOOKUP_INCREMENT)) { |
294 | new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT; | 345 | new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT; |
295 | spin_unlock_irq(phba->host->host_lock); | 346 | spin_unlock_irq(&phba->hbalock); |
296 | new_arr = kmalloc(new_len * sizeof (struct lpfc_iocbq *), | 347 | new_arr = kzalloc(new_len * sizeof (struct lpfc_iocbq *), |
297 | GFP_KERNEL); | 348 | GFP_KERNEL); |
298 | if (new_arr) { | 349 | if (new_arr) { |
299 | memset((char *)new_arr, 0, | 350 | spin_lock_irq(&phba->hbalock); |
300 | new_len * sizeof (struct lpfc_iocbq *)); | ||
301 | spin_lock_irq(phba->host->host_lock); | ||
302 | old_arr = psli->iocbq_lookup; | 351 | old_arr = psli->iocbq_lookup; |
303 | if (new_len <= psli->iocbq_lookup_len) { | 352 | if (new_len <= psli->iocbq_lookup_len) { |
304 | /* highly unprobable case */ | 353 | /* highly unprobable case */ |
@@ -307,11 +356,11 @@ lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocbq) | |||
307 | if(++iotag < psli->iocbq_lookup_len) { | 356 | if(++iotag < psli->iocbq_lookup_len) { |
308 | psli->last_iotag = iotag; | 357 | psli->last_iotag = iotag; |
309 | psli->iocbq_lookup[iotag] = iocbq; | 358 | psli->iocbq_lookup[iotag] = iocbq; |
310 | spin_unlock_irq(phba->host->host_lock); | 359 | spin_unlock_irq(&phba->hbalock); |
311 | iocbq->iotag = iotag; | 360 | iocbq->iotag = iotag; |
312 | return iotag; | 361 | return iotag; |
313 | } | 362 | } |
314 | spin_unlock_irq(phba->host->host_lock); | 363 | spin_unlock_irq(&phba->hbalock); |
315 | return 0; | 364 | return 0; |
316 | } | 365 | } |
317 | if (psli->iocbq_lookup) | 366 | if (psli->iocbq_lookup) |
@@ -322,13 +371,13 @@ lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocbq) | |||
322 | psli->iocbq_lookup_len = new_len; | 371 | psli->iocbq_lookup_len = new_len; |
323 | psli->last_iotag = iotag; | 372 | psli->last_iotag = iotag; |
324 | psli->iocbq_lookup[iotag] = iocbq; | 373 | psli->iocbq_lookup[iotag] = iocbq; |
325 | spin_unlock_irq(phba->host->host_lock); | 374 | spin_unlock_irq(&phba->hbalock); |
326 | iocbq->iotag = iotag; | 375 | iocbq->iotag = iotag; |
327 | kfree(old_arr); | 376 | kfree(old_arr); |
328 | return iotag; | 377 | return iotag; |
329 | } | 378 | } |
330 | } else | 379 | } else |
331 | spin_unlock_irq(phba->host->host_lock); | 380 | spin_unlock_irq(&phba->hbalock); |
332 | 381 | ||
333 | lpfc_printf_log(phba, KERN_ERR,LOG_SLI, | 382 | lpfc_printf_log(phba, KERN_ERR,LOG_SLI, |
334 | "%d:0318 Failed to allocate IOTAG.last IOTAG is %d\n", | 383 | "%d:0318 Failed to allocate IOTAG.last IOTAG is %d\n", |
@@ -349,7 +398,7 @@ lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
349 | /* | 398 | /* |
350 | * Issue iocb command to adapter | 399 | * Issue iocb command to adapter |
351 | */ | 400 | */ |
352 | lpfc_sli_pcimem_bcopy(&nextiocb->iocb, iocb, sizeof (IOCB_t)); | 401 | lpfc_sli_pcimem_bcopy(&nextiocb->iocb, iocb, phba->iocb_cmd_size); |
353 | wmb(); | 402 | wmb(); |
354 | pring->stats.iocb_cmd++; | 403 | pring->stats.iocb_cmd++; |
355 | 404 | ||
@@ -361,20 +410,18 @@ lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
361 | if (nextiocb->iocb_cmpl) | 410 | if (nextiocb->iocb_cmpl) |
362 | lpfc_sli_ringtxcmpl_put(phba, pring, nextiocb); | 411 | lpfc_sli_ringtxcmpl_put(phba, pring, nextiocb); |
363 | else | 412 | else |
364 | lpfc_sli_release_iocbq(phba, nextiocb); | 413 | __lpfc_sli_release_iocbq(phba, nextiocb); |
365 | 414 | ||
366 | /* | 415 | /* |
367 | * Let the HBA know what IOCB slot will be the next one the | 416 | * Let the HBA know what IOCB slot will be the next one the |
368 | * driver will put a command into. | 417 | * driver will put a command into. |
369 | */ | 418 | */ |
370 | pring->cmdidx = pring->next_cmdidx; | 419 | pring->cmdidx = pring->next_cmdidx; |
371 | writel(pring->cmdidx, phba->MBslimaddr | 420 | writel(pring->cmdidx, &phba->host_gp[pring->ringno].cmdPutInx); |
372 | + (SLIMOFF + (pring->ringno * 2)) * 4); | ||
373 | } | 421 | } |
374 | 422 | ||
375 | static void | 423 | static void |
376 | lpfc_sli_update_full_ring(struct lpfc_hba * phba, | 424 | lpfc_sli_update_full_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
377 | struct lpfc_sli_ring *pring) | ||
378 | { | 425 | { |
379 | int ringno = pring->ringno; | 426 | int ringno = pring->ringno; |
380 | 427 | ||
@@ -393,8 +440,7 @@ lpfc_sli_update_full_ring(struct lpfc_hba * phba, | |||
393 | } | 440 | } |
394 | 441 | ||
395 | static void | 442 | static void |
396 | lpfc_sli_update_ring(struct lpfc_hba * phba, | 443 | lpfc_sli_update_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
397 | struct lpfc_sli_ring *pring) | ||
398 | { | 444 | { |
399 | int ringno = pring->ringno; | 445 | int ringno = pring->ringno; |
400 | 446 | ||
@@ -407,7 +453,7 @@ lpfc_sli_update_ring(struct lpfc_hba * phba, | |||
407 | } | 453 | } |
408 | 454 | ||
409 | static void | 455 | static void |
410 | lpfc_sli_resume_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring) | 456 | lpfc_sli_resume_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
411 | { | 457 | { |
412 | IOCB_t *iocb; | 458 | IOCB_t *iocb; |
413 | struct lpfc_iocbq *nextiocb; | 459 | struct lpfc_iocbq *nextiocb; |
@@ -420,7 +466,7 @@ lpfc_sli_resume_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring) | |||
420 | * (d) IOCB processing is not blocked by the outstanding mbox command. | 466 | * (d) IOCB processing is not blocked by the outstanding mbox command. |
421 | */ | 467 | */ |
422 | if (pring->txq_cnt && | 468 | if (pring->txq_cnt && |
423 | (phba->hba_state > LPFC_LINK_DOWN) && | 469 | lpfc_is_link_up(phba) && |
424 | (pring->ringno != phba->sli.fcp_ring || | 470 | (pring->ringno != phba->sli.fcp_ring || |
425 | phba->sli.sli_flag & LPFC_PROCESS_LA) && | 471 | phba->sli.sli_flag & LPFC_PROCESS_LA) && |
426 | !(pring->flag & LPFC_STOP_IOCB_MBX)) { | 472 | !(pring->flag & LPFC_STOP_IOCB_MBX)) { |
@@ -440,11 +486,15 @@ lpfc_sli_resume_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring) | |||
440 | 486 | ||
441 | /* lpfc_sli_turn_on_ring is only called by lpfc_sli_handle_mb_event below */ | 487 | /* lpfc_sli_turn_on_ring is only called by lpfc_sli_handle_mb_event below */ |
442 | static void | 488 | static void |
443 | lpfc_sli_turn_on_ring(struct lpfc_hba * phba, int ringno) | 489 | lpfc_sli_turn_on_ring(struct lpfc_hba *phba, int ringno) |
444 | { | 490 | { |
445 | struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[ringno]; | 491 | struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? |
492 | &phba->slim2p->mbx.us.s3_pgp.port[ringno] : | ||
493 | &phba->slim2p->mbx.us.s2.port[ringno]; | ||
494 | unsigned long iflags; | ||
446 | 495 | ||
447 | /* If the ring is active, flag it */ | 496 | /* If the ring is active, flag it */ |
497 | spin_lock_irqsave(&phba->hbalock, iflags); | ||
448 | if (phba->sli.ring[ringno].cmdringaddr) { | 498 | if (phba->sli.ring[ringno].cmdringaddr) { |
449 | if (phba->sli.ring[ringno].flag & LPFC_STOP_IOCB_MBX) { | 499 | if (phba->sli.ring[ringno].flag & LPFC_STOP_IOCB_MBX) { |
450 | phba->sli.ring[ringno].flag &= ~LPFC_STOP_IOCB_MBX; | 500 | phba->sli.ring[ringno].flag &= ~LPFC_STOP_IOCB_MBX; |
@@ -453,11 +503,176 @@ lpfc_sli_turn_on_ring(struct lpfc_hba * phba, int ringno) | |||
453 | */ | 503 | */ |
454 | phba->sli.ring[ringno].local_getidx | 504 | phba->sli.ring[ringno].local_getidx |
455 | = le32_to_cpu(pgp->cmdGetInx); | 505 | = le32_to_cpu(pgp->cmdGetInx); |
456 | spin_lock_irq(phba->host->host_lock); | ||
457 | lpfc_sli_resume_iocb(phba, &phba->sli.ring[ringno]); | 506 | lpfc_sli_resume_iocb(phba, &phba->sli.ring[ringno]); |
458 | spin_unlock_irq(phba->host->host_lock); | ||
459 | } | 507 | } |
460 | } | 508 | } |
509 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
510 | } | ||
511 | |||
512 | struct lpfc_hbq_entry * | ||
513 | lpfc_sli_next_hbq_slot(struct lpfc_hba *phba, uint32_t hbqno) | ||
514 | { | ||
515 | struct hbq_s *hbqp = &phba->hbqs[hbqno]; | ||
516 | |||
517 | if (hbqp->next_hbqPutIdx == hbqp->hbqPutIdx && | ||
518 | ++hbqp->next_hbqPutIdx >= hbqp->entry_count) | ||
519 | hbqp->next_hbqPutIdx = 0; | ||
520 | |||
521 | if (unlikely(hbqp->local_hbqGetIdx == hbqp->next_hbqPutIdx)) { | ||
522 | uint32_t raw_index = phba->hbq_get[hbqno]; | ||
523 | uint32_t getidx = le32_to_cpu(raw_index); | ||
524 | |||
525 | hbqp->local_hbqGetIdx = getidx; | ||
526 | |||
527 | if (unlikely(hbqp->local_hbqGetIdx >= hbqp->entry_count)) { | ||
528 | lpfc_printf_log(phba, KERN_ERR, | ||
529 | LOG_SLI | LOG_VPORT, | ||
530 | "%d:1802 HBQ %d: local_hbqGetIdx " | ||
531 | "%u is > than hbqp->entry_count %u\n", | ||
532 | phba->brd_no, hbqno, | ||
533 | hbqp->local_hbqGetIdx, | ||
534 | hbqp->entry_count); | ||
535 | |||
536 | phba->link_state = LPFC_HBA_ERROR; | ||
537 | return NULL; | ||
538 | } | ||
539 | |||
540 | if (hbqp->local_hbqGetIdx == hbqp->next_hbqPutIdx) | ||
541 | return NULL; | ||
542 | } | ||
543 | |||
544 | return (struct lpfc_hbq_entry *) phba->hbqslimp.virt + hbqp->hbqPutIdx; | ||
545 | } | ||
546 | |||
547 | void | ||
548 | lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba) | ||
549 | { | ||
550 | struct lpfc_dmabuf *dmabuf, *next_dmabuf; | ||
551 | struct hbq_dmabuf *hbq_buf; | ||
552 | |||
553 | /* Return all memory used by all HBQs */ | ||
554 | list_for_each_entry_safe(dmabuf, next_dmabuf, | ||
555 | &phba->hbq_buffer_list, list) { | ||
556 | hbq_buf = container_of(dmabuf, struct hbq_dmabuf, dbuf); | ||
557 | list_del(&hbq_buf->dbuf.list); | ||
558 | lpfc_hbq_free(phba, hbq_buf->dbuf.virt, hbq_buf->dbuf.phys); | ||
559 | kfree(hbq_buf); | ||
560 | } | ||
561 | } | ||
562 | |||
563 | static void | ||
564 | lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno, | ||
565 | struct hbq_dmabuf *hbq_buf) | ||
566 | { | ||
567 | struct lpfc_hbq_entry *hbqe; | ||
568 | dma_addr_t physaddr = hbq_buf->dbuf.phys; | ||
569 | |||
570 | /* Get next HBQ entry slot to use */ | ||
571 | hbqe = lpfc_sli_next_hbq_slot(phba, hbqno); | ||
572 | if (hbqe) { | ||
573 | struct hbq_s *hbqp = &phba->hbqs[hbqno]; | ||
574 | |||
575 | hbqe->bde.addrHigh = le32_to_cpu(putPaddrHigh(physaddr)); | ||
576 | hbqe->bde.addrLow = le32_to_cpu(putPaddrLow(physaddr)); | ||
577 | hbqe->bde.tus.f.bdeSize = FCELSSIZE; | ||
578 | hbqe->bde.tus.f.bdeFlags = 0; | ||
579 | hbqe->bde.tus.w = le32_to_cpu(hbqe->bde.tus.w); | ||
580 | hbqe->buffer_tag = le32_to_cpu(hbq_buf->tag); | ||
581 | /* Sync SLIM */ | ||
582 | hbqp->hbqPutIdx = hbqp->next_hbqPutIdx; | ||
583 | writel(hbqp->hbqPutIdx, phba->hbq_put + hbqno); | ||
584 | /* flush */ | ||
585 | readl(phba->hbq_put + hbqno); | ||
586 | list_add_tail(&hbq_buf->dbuf.list, &phba->hbq_buffer_list); | ||
587 | } | ||
588 | } | ||
589 | |||
590 | static struct lpfc_hbq_init lpfc_els_hbq = { | ||
591 | .rn = 1, | ||
592 | .entry_count = 200, | ||
593 | .mask_count = 0, | ||
594 | .profile = 0, | ||
595 | .ring_mask = 1 << LPFC_ELS_RING, | ||
596 | .buffer_count = 0, | ||
597 | .init_count = 20, | ||
598 | .add_count = 5, | ||
599 | }; | ||
600 | |||
601 | static struct lpfc_hbq_init *lpfc_hbq_defs[] = { | ||
602 | &lpfc_els_hbq, | ||
603 | }; | ||
604 | |||
605 | int | ||
606 | lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) | ||
607 | { | ||
608 | uint32_t i, start, end; | ||
609 | struct hbq_dmabuf *hbq_buffer; | ||
610 | |||
611 | start = lpfc_hbq_defs[hbqno]->buffer_count; | ||
612 | end = count + lpfc_hbq_defs[hbqno]->buffer_count; | ||
613 | if (end > lpfc_hbq_defs[hbqno]->entry_count) { | ||
614 | end = lpfc_hbq_defs[hbqno]->entry_count; | ||
615 | } | ||
616 | |||
617 | /* Populate HBQ entries */ | ||
618 | for (i = start; i < end; i++) { | ||
619 | hbq_buffer = kmalloc(sizeof(struct hbq_dmabuf), | ||
620 | GFP_KERNEL); | ||
621 | if (!hbq_buffer) | ||
622 | return 1; | ||
623 | hbq_buffer->dbuf.virt = lpfc_hbq_alloc(phba, MEM_PRI, | ||
624 | &hbq_buffer->dbuf.phys); | ||
625 | if (hbq_buffer->dbuf.virt == NULL) | ||
626 | return 1; | ||
627 | hbq_buffer->tag = (i | (hbqno << 16)); | ||
628 | lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer); | ||
629 | lpfc_hbq_defs[hbqno]->buffer_count++; | ||
630 | } | ||
631 | return 0; | ||
632 | } | ||
633 | |||
634 | int | ||
635 | lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) | ||
636 | { | ||
637 | return(lpfc_sli_hbqbuf_fill_hbqs(phba, qno, | ||
638 | lpfc_hbq_defs[qno]->add_count)); | ||
639 | } | ||
640 | |||
641 | int | ||
642 | lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) | ||
643 | { | ||
644 | return(lpfc_sli_hbqbuf_fill_hbqs(phba, qno, | ||
645 | lpfc_hbq_defs[qno]->init_count)); | ||
646 | } | ||
647 | |||
648 | struct hbq_dmabuf * | ||
649 | lpfc_sli_hbqbuf_find(struct lpfc_hba *phba, uint32_t tag) | ||
650 | { | ||
651 | struct lpfc_dmabuf *d_buf; | ||
652 | struct hbq_dmabuf *hbq_buf; | ||
653 | |||
654 | list_for_each_entry(d_buf, &phba->hbq_buffer_list, list) { | ||
655 | hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf); | ||
656 | if ((hbq_buf->tag & 0xffff) == tag) { | ||
657 | return hbq_buf; | ||
658 | } | ||
659 | } | ||
660 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI | LOG_VPORT, | ||
661 | "%d:1803 Bad hbq tag. Data: x%x x%x\n", | ||
662 | phba->brd_no, tag, | ||
663 | lpfc_hbq_defs[tag >> 16]->buffer_count); | ||
664 | return NULL; | ||
665 | } | ||
666 | |||
667 | void | ||
668 | lpfc_sli_free_hbq(struct lpfc_hba *phba, struct hbq_dmabuf *sp) | ||
669 | { | ||
670 | uint32_t hbqno; | ||
671 | |||
672 | if (sp) { | ||
673 | hbqno = sp->tag >> 16; | ||
674 | lpfc_sli_hbq_to_firmware(phba, hbqno, sp); | ||
675 | } | ||
461 | } | 676 | } |
462 | 677 | ||
463 | static int | 678 | static int |
@@ -511,32 +726,38 @@ lpfc_sli_chk_mbx_command(uint8_t mbxCommand) | |||
511 | case MBX_FLASH_WR_ULA: | 726 | case MBX_FLASH_WR_ULA: |
512 | case MBX_SET_DEBUG: | 727 | case MBX_SET_DEBUG: |
513 | case MBX_LOAD_EXP_ROM: | 728 | case MBX_LOAD_EXP_ROM: |
729 | case MBX_REG_VPI: | ||
730 | case MBX_UNREG_VPI: | ||
731 | case MBX_HEARTBEAT: | ||
514 | ret = mbxCommand; | 732 | ret = mbxCommand; |
515 | break; | 733 | break; |
516 | default: | 734 | default: |
517 | ret = MBX_SHUTDOWN; | 735 | ret = MBX_SHUTDOWN; |
518 | break; | 736 | break; |
519 | } | 737 | } |
520 | return (ret); | 738 | return ret; |
521 | } | 739 | } |
522 | static void | 740 | static void |
523 | lpfc_sli_wake_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq) | 741 | lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) |
524 | { | 742 | { |
525 | wait_queue_head_t *pdone_q; | 743 | wait_queue_head_t *pdone_q; |
744 | unsigned long drvr_flag; | ||
526 | 745 | ||
527 | /* | 746 | /* |
528 | * If pdone_q is empty, the driver thread gave up waiting and | 747 | * If pdone_q is empty, the driver thread gave up waiting and |
529 | * continued running. | 748 | * continued running. |
530 | */ | 749 | */ |
531 | pmboxq->mbox_flag |= LPFC_MBX_WAKE; | 750 | pmboxq->mbox_flag |= LPFC_MBX_WAKE; |
751 | spin_lock_irqsave(&phba->hbalock, drvr_flag); | ||
532 | pdone_q = (wait_queue_head_t *) pmboxq->context1; | 752 | pdone_q = (wait_queue_head_t *) pmboxq->context1; |
533 | if (pdone_q) | 753 | if (pdone_q) |
534 | wake_up_interruptible(pdone_q); | 754 | wake_up_interruptible(pdone_q); |
755 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); | ||
535 | return; | 756 | return; |
536 | } | 757 | } |
537 | 758 | ||
538 | void | 759 | void |
539 | lpfc_sli_def_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 760 | lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
540 | { | 761 | { |
541 | struct lpfc_dmabuf *mp; | 762 | struct lpfc_dmabuf *mp; |
542 | uint16_t rpi; | 763 | uint16_t rpi; |
@@ -553,79 +774,64 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
553 | * If a REG_LOGIN succeeded after node is destroyed or node | 774 | * If a REG_LOGIN succeeded after node is destroyed or node |
554 | * is in re-discovery driver need to cleanup the RPI. | 775 | * is in re-discovery driver need to cleanup the RPI. |
555 | */ | 776 | */ |
556 | if (!(phba->fc_flag & FC_UNLOADING) && | 777 | if (!(phba->pport->load_flag & FC_UNLOADING) && |
557 | (pmb->mb.mbxCommand == MBX_REG_LOGIN64) && | 778 | pmb->mb.mbxCommand == MBX_REG_LOGIN64 && |
558 | (!pmb->mb.mbxStatus)) { | 779 | !pmb->mb.mbxStatus) { |
559 | 780 | ||
560 | rpi = pmb->mb.un.varWords[0]; | 781 | rpi = pmb->mb.un.varWords[0]; |
561 | lpfc_unreg_login(phba, rpi, pmb); | 782 | lpfc_unreg_login(phba, pmb->mb.un.varRegLogin.vpi, rpi, pmb); |
562 | pmb->mbox_cmpl=lpfc_sli_def_mbox_cmpl; | 783 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
563 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | 784 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); |
564 | if (rc != MBX_NOT_FINISHED) | 785 | if (rc != MBX_NOT_FINISHED) |
565 | return; | 786 | return; |
566 | } | 787 | } |
567 | 788 | ||
568 | mempool_free( pmb, phba->mbox_mem_pool); | 789 | mempool_free(pmb, phba->mbox_mem_pool); |
569 | return; | 790 | return; |
570 | } | 791 | } |
571 | 792 | ||
572 | int | 793 | int |
573 | lpfc_sli_handle_mb_event(struct lpfc_hba * phba) | 794 | lpfc_sli_handle_mb_event(struct lpfc_hba *phba) |
574 | { | 795 | { |
575 | MAILBOX_t *mbox; | ||
576 | MAILBOX_t *pmbox; | 796 | MAILBOX_t *pmbox; |
577 | LPFC_MBOXQ_t *pmb; | 797 | LPFC_MBOXQ_t *pmb; |
578 | struct lpfc_sli *psli; | 798 | int rc; |
579 | int i, rc; | 799 | LIST_HEAD(cmplq); |
580 | uint32_t process_next; | ||
581 | |||
582 | psli = &phba->sli; | ||
583 | /* We should only get here if we are in SLI2 mode */ | ||
584 | if (!(phba->sli.sli_flag & LPFC_SLI2_ACTIVE)) { | ||
585 | return (1); | ||
586 | } | ||
587 | 800 | ||
588 | phba->sli.slistat.mbox_event++; | 801 | phba->sli.slistat.mbox_event++; |
589 | 802 | ||
803 | /* Get all completed mailboxe buffers into the cmplq */ | ||
804 | spin_lock_irq(&phba->hbalock); | ||
805 | list_splice_init(&phba->sli.mboxq_cmpl, &cmplq); | ||
806 | spin_unlock_irq(&phba->hbalock); | ||
807 | |||
590 | /* Get a Mailbox buffer to setup mailbox commands for callback */ | 808 | /* Get a Mailbox buffer to setup mailbox commands for callback */ |
591 | if ((pmb = phba->sli.mbox_active)) { | 809 | do { |
592 | pmbox = &pmb->mb; | 810 | list_remove_head(&cmplq, pmb, LPFC_MBOXQ_t, list); |
593 | mbox = &phba->slim2p->mbx; | 811 | if (pmb == NULL) |
812 | break; | ||
594 | 813 | ||
595 | /* First check out the status word */ | 814 | pmbox = &pmb->mb; |
596 | lpfc_sli_pcimem_bcopy(mbox, pmbox, sizeof (uint32_t)); | ||
597 | 815 | ||
598 | /* Sanity check to ensure the host owns the mailbox */ | 816 | if (pmbox->mbxCommand != MBX_HEARTBEAT) { |
599 | if (pmbox->mbxOwner != OWN_HOST) { | 817 | if (pmb->vport) { |
600 | /* Lets try for a while */ | 818 | lpfc_debugfs_disc_trc(pmb->vport, |
601 | for (i = 0; i < 10240; i++) { | 819 | LPFC_DISC_TRC_MBOX_VPORT, |
602 | /* First copy command data */ | 820 | "MBOX cmpl vport: cmd:x%x mb:x%x x%x", |
603 | lpfc_sli_pcimem_bcopy(mbox, pmbox, | 821 | (uint32_t)pmbox->mbxCommand, |
604 | sizeof (uint32_t)); | 822 | pmbox->un.varWords[0], |
605 | if (pmbox->mbxOwner == OWN_HOST) | 823 | pmbox->un.varWords[1]); |
606 | goto mbout; | 824 | } |
825 | else { | ||
826 | lpfc_debugfs_disc_trc(phba->pport, | ||
827 | LPFC_DISC_TRC_MBOX, | ||
828 | "MBOX cmpl: cmd:x%x mb:x%x x%x", | ||
829 | (uint32_t)pmbox->mbxCommand, | ||
830 | pmbox->un.varWords[0], | ||
831 | pmbox->un.varWords[1]); | ||
607 | } | 832 | } |
608 | /* Stray Mailbox Interrupt, mbxCommand <cmd> mbxStatus | ||
609 | <status> */ | ||
610 | lpfc_printf_log(phba, | ||
611 | KERN_WARNING, | ||
612 | LOG_MBOX | LOG_SLI, | ||
613 | "%d:0304 Stray Mailbox Interrupt " | ||
614 | "mbxCommand x%x mbxStatus x%x\n", | ||
615 | phba->brd_no, | ||
616 | pmbox->mbxCommand, | ||
617 | pmbox->mbxStatus); | ||
618 | |||
619 | spin_lock_irq(phba->host->host_lock); | ||
620 | phba->sli.sli_flag |= LPFC_SLI_MBOX_ACTIVE; | ||
621 | spin_unlock_irq(phba->host->host_lock); | ||
622 | return (1); | ||
623 | } | 833 | } |
624 | 834 | ||
625 | mbout: | ||
626 | del_timer_sync(&phba->sli.mbox_tmo); | ||
627 | phba->work_hba_events &= ~WORKER_MBOX_TMO; | ||
628 | |||
629 | /* | 835 | /* |
630 | * It is a fatal error if unknown mbox command completion. | 836 | * It is a fatal error if unknown mbox command completion. |
631 | */ | 837 | */ |
@@ -633,51 +839,50 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba) | |||
633 | MBX_SHUTDOWN) { | 839 | MBX_SHUTDOWN) { |
634 | 840 | ||
635 | /* Unknow mailbox command compl */ | 841 | /* Unknow mailbox command compl */ |
636 | lpfc_printf_log(phba, | 842 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
637 | KERN_ERR, | 843 | "%d (%d):0323 Unknown Mailbox command " |
638 | LOG_MBOX | LOG_SLI, | 844 | "%x Cmpl\n", |
639 | "%d:0323 Unknown Mailbox command %x Cmpl\n", | 845 | phba->brd_no, |
640 | phba->brd_no, | 846 | pmb->vport ? pmb->vport->vpi : 0, |
641 | pmbox->mbxCommand); | 847 | pmbox->mbxCommand); |
642 | phba->hba_state = LPFC_HBA_ERROR; | 848 | phba->link_state = LPFC_HBA_ERROR; |
643 | phba->work_hs = HS_FFER3; | 849 | phba->work_hs = HS_FFER3; |
644 | lpfc_handle_eratt(phba); | 850 | lpfc_handle_eratt(phba); |
645 | return (0); | 851 | continue; |
646 | } | 852 | } |
647 | 853 | ||
648 | phba->sli.mbox_active = NULL; | ||
649 | if (pmbox->mbxStatus) { | 854 | if (pmbox->mbxStatus) { |
650 | phba->sli.slistat.mbox_stat_err++; | 855 | phba->sli.slistat.mbox_stat_err++; |
651 | if (pmbox->mbxStatus == MBXERR_NO_RESOURCES) { | 856 | if (pmbox->mbxStatus == MBXERR_NO_RESOURCES) { |
652 | /* Mbox cmd cmpl error - RETRYing */ | 857 | /* Mbox cmd cmpl error - RETRYing */ |
653 | lpfc_printf_log(phba, | 858 | lpfc_printf_log(phba, KERN_INFO, |
654 | KERN_INFO, | 859 | LOG_MBOX | LOG_SLI, |
655 | LOG_MBOX | LOG_SLI, | 860 | "%d (%d):0305 Mbox cmd cmpl " |
656 | "%d:0305 Mbox cmd cmpl error - " | 861 | "error - RETRYing Data: x%x " |
657 | "RETRYing Data: x%x x%x x%x x%x\n", | 862 | "x%x x%x x%x\n", |
658 | phba->brd_no, | 863 | phba->brd_no, |
659 | pmbox->mbxCommand, | 864 | pmb->vport ? pmb->vport->vpi :0, |
660 | pmbox->mbxStatus, | 865 | pmbox->mbxCommand, |
661 | pmbox->un.varWords[0], | 866 | pmbox->mbxStatus, |
662 | phba->hba_state); | 867 | pmbox->un.varWords[0], |
868 | pmb->vport->port_state); | ||
663 | pmbox->mbxStatus = 0; | 869 | pmbox->mbxStatus = 0; |
664 | pmbox->mbxOwner = OWN_HOST; | 870 | pmbox->mbxOwner = OWN_HOST; |
665 | spin_lock_irq(phba->host->host_lock); | 871 | spin_lock_irq(&phba->hbalock); |
666 | phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | 872 | phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; |
667 | spin_unlock_irq(phba->host->host_lock); | 873 | spin_unlock_irq(&phba->hbalock); |
668 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | 874 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); |
669 | if (rc == MBX_SUCCESS) | 875 | if (rc == MBX_SUCCESS) |
670 | return (0); | 876 | continue; |
671 | } | 877 | } |
672 | } | 878 | } |
673 | 879 | ||
674 | /* Mailbox cmd <cmd> Cmpl <cmpl> */ | 880 | /* Mailbox cmd <cmd> Cmpl <cmpl> */ |
675 | lpfc_printf_log(phba, | 881 | lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, |
676 | KERN_INFO, | 882 | "%d (%d):0307 Mailbox cmd x%x Cmpl x%p " |
677 | LOG_MBOX | LOG_SLI, | ||
678 | "%d:0307 Mailbox cmd x%x Cmpl x%p " | ||
679 | "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x\n", | 883 | "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x\n", |
680 | phba->brd_no, | 884 | phba->brd_no, |
885 | pmb->vport ? pmb->vport->vpi : 0, | ||
681 | pmbox->mbxCommand, | 886 | pmbox->mbxCommand, |
682 | pmb->mbox_cmpl, | 887 | pmb->mbox_cmpl, |
683 | *((uint32_t *) pmbox), | 888 | *((uint32_t *) pmbox), |
@@ -690,39 +895,35 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba) | |||
690 | pmbox->un.varWords[6], | 895 | pmbox->un.varWords[6], |
691 | pmbox->un.varWords[7]); | 896 | pmbox->un.varWords[7]); |
692 | 897 | ||
693 | if (pmb->mbox_cmpl) { | 898 | if (pmb->mbox_cmpl) |
694 | lpfc_sli_pcimem_bcopy(mbox, pmbox, MAILBOX_CMD_SIZE); | ||
695 | pmb->mbox_cmpl(phba,pmb); | 899 | pmb->mbox_cmpl(phba,pmb); |
696 | } | 900 | } while (1); |
697 | } | 901 | return 0; |
698 | 902 | } | |
699 | |||
700 | do { | ||
701 | process_next = 0; /* by default don't loop */ | ||
702 | spin_lock_irq(phba->host->host_lock); | ||
703 | phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | ||
704 | |||
705 | /* Process next mailbox command if there is one */ | ||
706 | if ((pmb = lpfc_mbox_get(phba))) { | ||
707 | spin_unlock_irq(phba->host->host_lock); | ||
708 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | ||
709 | if (rc == MBX_NOT_FINISHED) { | ||
710 | pmb->mb.mbxStatus = MBX_NOT_FINISHED; | ||
711 | pmb->mbox_cmpl(phba,pmb); | ||
712 | process_next = 1; | ||
713 | continue; /* loop back */ | ||
714 | } | ||
715 | } else { | ||
716 | spin_unlock_irq(phba->host->host_lock); | ||
717 | /* Turn on IOCB processing */ | ||
718 | for (i = 0; i < phba->sli.num_rings; i++) | ||
719 | lpfc_sli_turn_on_ring(phba, i); | ||
720 | } | ||
721 | |||
722 | } while (process_next); | ||
723 | 903 | ||
724 | return (0); | 904 | static struct lpfc_dmabuf * |
905 | lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) | ||
906 | { | ||
907 | struct hbq_dmabuf *hbq_entry, *new_hbq_entry; | ||
908 | |||
909 | hbq_entry = lpfc_sli_hbqbuf_find(phba, tag); | ||
910 | if (hbq_entry == NULL) | ||
911 | return NULL; | ||
912 | list_del(&hbq_entry->dbuf.list); | ||
913 | new_hbq_entry = kmalloc(sizeof(struct hbq_dmabuf), GFP_ATOMIC); | ||
914 | if (new_hbq_entry == NULL) | ||
915 | return &hbq_entry->dbuf; | ||
916 | new_hbq_entry->dbuf = hbq_entry->dbuf; | ||
917 | new_hbq_entry->tag = -1; | ||
918 | hbq_entry->dbuf.virt = lpfc_hbq_alloc(phba, 0, &hbq_entry->dbuf.phys); | ||
919 | if (hbq_entry->dbuf.virt == NULL) { | ||
920 | kfree(new_hbq_entry); | ||
921 | return &hbq_entry->dbuf; | ||
922 | } | ||
923 | lpfc_sli_free_hbq(phba, hbq_entry); | ||
924 | return &new_hbq_entry->dbuf; | ||
725 | } | 925 | } |
926 | |||
726 | static int | 927 | static int |
727 | lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 928 | lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
728 | struct lpfc_iocbq *saveq) | 929 | struct lpfc_iocbq *saveq) |
@@ -735,7 +936,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
735 | match = 0; | 936 | match = 0; |
736 | irsp = &(saveq->iocb); | 937 | irsp = &(saveq->iocb); |
737 | if ((irsp->ulpCommand == CMD_RCV_ELS_REQ64_CX) | 938 | if ((irsp->ulpCommand == CMD_RCV_ELS_REQ64_CX) |
738 | || (irsp->ulpCommand == CMD_RCV_ELS_REQ_CX)) { | 939 | || (irsp->ulpCommand == CMD_RCV_ELS_REQ_CX) |
940 | || (irsp->ulpCommand == CMD_IOCB_RCV_ELS64_CX) | ||
941 | || (irsp->ulpCommand == CMD_IOCB_RCV_CONT64_CX)) { | ||
739 | Rctl = FC_ELS_REQ; | 942 | Rctl = FC_ELS_REQ; |
740 | Type = FC_ELS_DATA; | 943 | Type = FC_ELS_DATA; |
741 | } else { | 944 | } else { |
@@ -747,13 +950,24 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
747 | 950 | ||
748 | /* Firmware Workaround */ | 951 | /* Firmware Workaround */ |
749 | if ((Rctl == 0) && (pring->ringno == LPFC_ELS_RING) && | 952 | if ((Rctl == 0) && (pring->ringno == LPFC_ELS_RING) && |
750 | (irsp->ulpCommand == CMD_RCV_SEQUENCE64_CX)) { | 953 | (irsp->ulpCommand == CMD_RCV_SEQUENCE64_CX || |
954 | irsp->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { | ||
751 | Rctl = FC_ELS_REQ; | 955 | Rctl = FC_ELS_REQ; |
752 | Type = FC_ELS_DATA; | 956 | Type = FC_ELS_DATA; |
753 | w5p->hcsw.Rctl = Rctl; | 957 | w5p->hcsw.Rctl = Rctl; |
754 | w5p->hcsw.Type = Type; | 958 | w5p->hcsw.Type = Type; |
755 | } | 959 | } |
756 | } | 960 | } |
961 | |||
962 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { | ||
963 | if (irsp->ulpBdeCount != 0) | ||
964 | saveq->context2 = lpfc_sli_replace_hbqbuff(phba, | ||
965 | irsp->un.ulpWord[3]); | ||
966 | if (irsp->ulpBdeCount == 2) | ||
967 | saveq->context3 = lpfc_sli_replace_hbqbuff(phba, | ||
968 | irsp->un.ulpWord[15]); | ||
969 | } | ||
970 | |||
757 | /* unSolicited Responses */ | 971 | /* unSolicited Responses */ |
758 | if (pring->prt[0].profile) { | 972 | if (pring->prt[0].profile) { |
759 | if (pring->prt[0].lpfc_sli_rcv_unsol_event) | 973 | if (pring->prt[0].lpfc_sli_rcv_unsol_event) |
@@ -781,23 +995,21 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
781 | /* Unexpected Rctl / Type received */ | 995 | /* Unexpected Rctl / Type received */ |
782 | /* Ring <ringno> handler: unexpected | 996 | /* Ring <ringno> handler: unexpected |
783 | Rctl <Rctl> Type <Type> received */ | 997 | Rctl <Rctl> Type <Type> received */ |
784 | lpfc_printf_log(phba, | 998 | lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, |
785 | KERN_WARNING, | ||
786 | LOG_SLI, | ||
787 | "%d:0313 Ring %d handler: unexpected Rctl x%x " | 999 | "%d:0313 Ring %d handler: unexpected Rctl x%x " |
788 | "Type x%x received \n", | 1000 | "Type x%x received\n", |
789 | phba->brd_no, | 1001 | phba->brd_no, |
790 | pring->ringno, | 1002 | pring->ringno, |
791 | Rctl, | 1003 | Rctl, |
792 | Type); | 1004 | Type); |
793 | } | 1005 | } |
794 | return(1); | 1006 | return 1; |
795 | } | 1007 | } |
796 | 1008 | ||
797 | static struct lpfc_iocbq * | 1009 | static struct lpfc_iocbq * |
798 | lpfc_sli_iocbq_lookup(struct lpfc_hba * phba, | 1010 | lpfc_sli_iocbq_lookup(struct lpfc_hba *phba, |
799 | struct lpfc_sli_ring * pring, | 1011 | struct lpfc_sli_ring *pring, |
800 | struct lpfc_iocbq * prspiocb) | 1012 | struct lpfc_iocbq *prspiocb) |
801 | { | 1013 | { |
802 | struct lpfc_iocbq *cmd_iocb = NULL; | 1014 | struct lpfc_iocbq *cmd_iocb = NULL; |
803 | uint16_t iotag; | 1015 | uint16_t iotag; |
@@ -806,7 +1018,7 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba * phba, | |||
806 | 1018 | ||
807 | if (iotag != 0 && iotag <= phba->sli.last_iotag) { | 1019 | if (iotag != 0 && iotag <= phba->sli.last_iotag) { |
808 | cmd_iocb = phba->sli.iocbq_lookup[iotag]; | 1020 | cmd_iocb = phba->sli.iocbq_lookup[iotag]; |
809 | list_del(&cmd_iocb->list); | 1021 | list_del_init(&cmd_iocb->list); |
810 | pring->txcmplq_cnt--; | 1022 | pring->txcmplq_cnt--; |
811 | return cmd_iocb; | 1023 | return cmd_iocb; |
812 | } | 1024 | } |
@@ -821,16 +1033,18 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba * phba, | |||
821 | } | 1033 | } |
822 | 1034 | ||
823 | static int | 1035 | static int |
824 | lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, | 1036 | lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
825 | struct lpfc_iocbq *saveq) | 1037 | struct lpfc_iocbq *saveq) |
826 | { | 1038 | { |
827 | struct lpfc_iocbq * cmdiocbp; | 1039 | struct lpfc_iocbq *cmdiocbp; |
828 | int rc = 1; | 1040 | int rc = 1; |
829 | unsigned long iflag; | 1041 | unsigned long iflag; |
830 | 1042 | ||
831 | /* Based on the iotag field, get the cmd IOCB from the txcmplq */ | 1043 | /* Based on the iotag field, get the cmd IOCB from the txcmplq */ |
832 | spin_lock_irqsave(phba->host->host_lock, iflag); | 1044 | spin_lock_irqsave(&phba->hbalock, iflag); |
833 | cmdiocbp = lpfc_sli_iocbq_lookup(phba, pring, saveq); | 1045 | cmdiocbp = lpfc_sli_iocbq_lookup(phba, pring, saveq); |
1046 | spin_unlock_irqrestore(&phba->hbalock, iflag); | ||
1047 | |||
834 | if (cmdiocbp) { | 1048 | if (cmdiocbp) { |
835 | if (cmdiocbp->iocb_cmpl) { | 1049 | if (cmdiocbp->iocb_cmpl) { |
836 | /* | 1050 | /* |
@@ -846,17 +1060,8 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, | |||
846 | saveq->iocb.un.ulpWord[4] = | 1060 | saveq->iocb.un.ulpWord[4] = |
847 | IOERR_SLI_ABORTED; | 1061 | IOERR_SLI_ABORTED; |
848 | } | 1062 | } |
849 | spin_unlock_irqrestore(phba->host->host_lock, | ||
850 | iflag); | ||
851 | (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq); | ||
852 | spin_lock_irqsave(phba->host->host_lock, iflag); | ||
853 | } | ||
854 | else { | ||
855 | spin_unlock_irqrestore(phba->host->host_lock, | ||
856 | iflag); | ||
857 | (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq); | ||
858 | spin_lock_irqsave(phba->host->host_lock, iflag); | ||
859 | } | 1063 | } |
1064 | (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq); | ||
860 | } else | 1065 | } else |
861 | lpfc_sli_release_iocbq(phba, cmdiocbp); | 1066 | lpfc_sli_release_iocbq(phba, cmdiocbp); |
862 | } else { | 1067 | } else { |
@@ -870,29 +1075,30 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, | |||
870 | * Ring <ringno> handler: unexpected completion IoTag | 1075 | * Ring <ringno> handler: unexpected completion IoTag |
871 | * <IoTag> | 1076 | * <IoTag> |
872 | */ | 1077 | */ |
873 | lpfc_printf_log(phba, | 1078 | lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, |
874 | KERN_WARNING, | 1079 | "%d (%d):0322 Ring %d handler: " |
875 | LOG_SLI, | 1080 | "unexpected completion IoTag x%x " |
876 | "%d:0322 Ring %d handler: unexpected " | 1081 | "Data: x%x x%x x%x x%x\n", |
877 | "completion IoTag x%x Data: x%x x%x x%x x%x\n", | 1082 | phba->brd_no, |
878 | phba->brd_no, | 1083 | cmdiocbp->vport->vpi, |
879 | pring->ringno, | 1084 | pring->ringno, |
880 | saveq->iocb.ulpIoTag, | 1085 | saveq->iocb.ulpIoTag, |
881 | saveq->iocb.ulpStatus, | 1086 | saveq->iocb.ulpStatus, |
882 | saveq->iocb.un.ulpWord[4], | 1087 | saveq->iocb.un.ulpWord[4], |
883 | saveq->iocb.ulpCommand, | 1088 | saveq->iocb.ulpCommand, |
884 | saveq->iocb.ulpContext); | 1089 | saveq->iocb.ulpContext); |
885 | } | 1090 | } |
886 | } | 1091 | } |
887 | 1092 | ||
888 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | ||
889 | return rc; | 1093 | return rc; |
890 | } | 1094 | } |
891 | 1095 | ||
892 | static void lpfc_sli_rsp_pointers_error(struct lpfc_hba * phba, | 1096 | static void |
893 | struct lpfc_sli_ring * pring) | 1097 | lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
894 | { | 1098 | { |
895 | struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno]; | 1099 | struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? |
1100 | &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | ||
1101 | &phba->slim2p->mbx.us.s2.port[pring->ringno]; | ||
896 | /* | 1102 | /* |
897 | * Ring <ringno> handler: portRspPut <portRspPut> is bigger then | 1103 | * Ring <ringno> handler: portRspPut <portRspPut> is bigger then |
898 | * rsp ring <portRspMax> | 1104 | * rsp ring <portRspMax> |
@@ -904,7 +1110,7 @@ static void lpfc_sli_rsp_pointers_error(struct lpfc_hba * phba, | |||
904 | le32_to_cpu(pgp->rspPutInx), | 1110 | le32_to_cpu(pgp->rspPutInx), |
905 | pring->numRiocb); | 1111 | pring->numRiocb); |
906 | 1112 | ||
907 | phba->hba_state = LPFC_HBA_ERROR; | 1113 | phba->link_state = LPFC_HBA_ERROR; |
908 | 1114 | ||
909 | /* | 1115 | /* |
910 | * All error attention handlers are posted to | 1116 | * All error attention handlers are posted to |
@@ -912,16 +1118,18 @@ static void lpfc_sli_rsp_pointers_error(struct lpfc_hba * phba, | |||
912 | */ | 1118 | */ |
913 | phba->work_ha |= HA_ERATT; | 1119 | phba->work_ha |= HA_ERATT; |
914 | phba->work_hs = HS_FFER3; | 1120 | phba->work_hs = HS_FFER3; |
1121 | |||
1122 | /* hbalock should already be held */ | ||
915 | if (phba->work_wait) | 1123 | if (phba->work_wait) |
916 | wake_up(phba->work_wait); | 1124 | lpfc_worker_wake_up(phba); |
917 | 1125 | ||
918 | return; | 1126 | return; |
919 | } | 1127 | } |
920 | 1128 | ||
921 | void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) | 1129 | void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba) |
922 | { | 1130 | { |
923 | struct lpfc_sli * psli = &phba->sli; | 1131 | struct lpfc_sli *psli = &phba->sli; |
924 | struct lpfc_sli_ring * pring = &psli->ring[LPFC_FCP_RING]; | 1132 | struct lpfc_sli_ring *pring = &psli->ring[LPFC_FCP_RING]; |
925 | IOCB_t *irsp = NULL; | 1133 | IOCB_t *irsp = NULL; |
926 | IOCB_t *entry = NULL; | 1134 | IOCB_t *entry = NULL; |
927 | struct lpfc_iocbq *cmdiocbq = NULL; | 1135 | struct lpfc_iocbq *cmdiocbq = NULL; |
@@ -931,13 +1139,15 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) | |||
931 | uint32_t portRspPut, portRspMax; | 1139 | uint32_t portRspPut, portRspMax; |
932 | int type; | 1140 | int type; |
933 | uint32_t rsp_cmpl = 0; | 1141 | uint32_t rsp_cmpl = 0; |
934 | void __iomem *to_slim; | ||
935 | uint32_t ha_copy; | 1142 | uint32_t ha_copy; |
1143 | unsigned long iflags; | ||
936 | 1144 | ||
937 | pring->stats.iocb_event++; | 1145 | pring->stats.iocb_event++; |
938 | 1146 | ||
939 | /* The driver assumes SLI-2 mode */ | 1147 | pgp = (phba->sli_rev == 3) ? |
940 | pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno]; | 1148 | &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : |
1149 | &phba->slim2p->mbx.us.s2.port[pring->ringno]; | ||
1150 | |||
941 | 1151 | ||
942 | /* | 1152 | /* |
943 | * The next available response entry should never exceed the maximum | 1153 | * The next available response entry should never exceed the maximum |
@@ -952,15 +1162,13 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) | |||
952 | 1162 | ||
953 | rmb(); | 1163 | rmb(); |
954 | while (pring->rspidx != portRspPut) { | 1164 | while (pring->rspidx != portRspPut) { |
955 | 1165 | entry = lpfc_resp_iocb(phba, pring); | |
956 | entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx); | ||
957 | |||
958 | if (++pring->rspidx >= portRspMax) | 1166 | if (++pring->rspidx >= portRspMax) |
959 | pring->rspidx = 0; | 1167 | pring->rspidx = 0; |
960 | 1168 | ||
961 | lpfc_sli_pcimem_bcopy((uint32_t *) entry, | 1169 | lpfc_sli_pcimem_bcopy((uint32_t *) entry, |
962 | (uint32_t *) &rspiocbq.iocb, | 1170 | (uint32_t *) &rspiocbq.iocb, |
963 | sizeof (IOCB_t)); | 1171 | phba->iocb_rsp_size); |
964 | irsp = &rspiocbq.iocb; | 1172 | irsp = &rspiocbq.iocb; |
965 | type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); | 1173 | type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); |
966 | pring->stats.iocb_rsp++; | 1174 | pring->stats.iocb_rsp++; |
@@ -998,8 +1206,10 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) | |||
998 | break; | 1206 | break; |
999 | } | 1207 | } |
1000 | 1208 | ||
1209 | spin_lock_irqsave(&phba->hbalock, iflags); | ||
1001 | cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring, | 1210 | cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring, |
1002 | &rspiocbq); | 1211 | &rspiocbq); |
1212 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
1003 | if ((cmdiocbq) && (cmdiocbq->iocb_cmpl)) { | 1213 | if ((cmdiocbq) && (cmdiocbq->iocb_cmpl)) { |
1004 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, | 1214 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, |
1005 | &rspiocbq); | 1215 | &rspiocbq); |
@@ -1033,9 +1243,7 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) | |||
1033 | * been updated, sync the pgp->rspPutInx and fetch the new port | 1243 | * been updated, sync the pgp->rspPutInx and fetch the new port |
1034 | * response put pointer. | 1244 | * response put pointer. |
1035 | */ | 1245 | */ |
1036 | to_slim = phba->MBslimaddr + | 1246 | writel(pring->rspidx, &phba->host_gp[pring->ringno].rspGetInx); |
1037 | (SLIMOFF + (pring->ringno * 2) + 1) * 4; | ||
1038 | writeb(pring->rspidx, to_slim); | ||
1039 | 1247 | ||
1040 | if (pring->rspidx == portRspPut) | 1248 | if (pring->rspidx == portRspPut) |
1041 | portRspPut = le32_to_cpu(pgp->rspPutInx); | 1249 | portRspPut = le32_to_cpu(pgp->rspPutInx); |
@@ -1045,13 +1253,16 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) | |||
1045 | ha_copy >>= (LPFC_FCP_RING * 4); | 1253 | ha_copy >>= (LPFC_FCP_RING * 4); |
1046 | 1254 | ||
1047 | if ((rsp_cmpl > 0) && (ha_copy & HA_R0RE_REQ)) { | 1255 | if ((rsp_cmpl > 0) && (ha_copy & HA_R0RE_REQ)) { |
1256 | spin_lock_irqsave(&phba->hbalock, iflags); | ||
1048 | pring->stats.iocb_rsp_full++; | 1257 | pring->stats.iocb_rsp_full++; |
1049 | status = ((CA_R0ATT | CA_R0RE_RSP) << (LPFC_FCP_RING * 4)); | 1258 | status = ((CA_R0ATT | CA_R0RE_RSP) << (LPFC_FCP_RING * 4)); |
1050 | writel(status, phba->CAregaddr); | 1259 | writel(status, phba->CAregaddr); |
1051 | readl(phba->CAregaddr); | 1260 | readl(phba->CAregaddr); |
1261 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
1052 | } | 1262 | } |
1053 | if ((ha_copy & HA_R0CE_RSP) && | 1263 | if ((ha_copy & HA_R0CE_RSP) && |
1054 | (pring->flag & LPFC_CALL_RING_AVAILABLE)) { | 1264 | (pring->flag & LPFC_CALL_RING_AVAILABLE)) { |
1265 | spin_lock_irqsave(&phba->hbalock, iflags); | ||
1055 | pring->flag &= ~LPFC_CALL_RING_AVAILABLE; | 1266 | pring->flag &= ~LPFC_CALL_RING_AVAILABLE; |
1056 | pring->stats.iocb_cmd_empty++; | 1267 | pring->stats.iocb_cmd_empty++; |
1057 | 1268 | ||
@@ -1062,6 +1273,7 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) | |||
1062 | if ((pring->lpfc_sli_cmd_available)) | 1273 | if ((pring->lpfc_sli_cmd_available)) |
1063 | (pring->lpfc_sli_cmd_available) (phba, pring); | 1274 | (pring->lpfc_sli_cmd_available) (phba, pring); |
1064 | 1275 | ||
1276 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
1065 | } | 1277 | } |
1066 | 1278 | ||
1067 | return; | 1279 | return; |
@@ -1072,10 +1284,12 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) | |||
1072 | * to check it explicitly. | 1284 | * to check it explicitly. |
1073 | */ | 1285 | */ |
1074 | static int | 1286 | static int |
1075 | lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | 1287 | lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, |
1076 | struct lpfc_sli_ring * pring, uint32_t mask) | 1288 | struct lpfc_sli_ring *pring, uint32_t mask) |
1077 | { | 1289 | { |
1078 | struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno]; | 1290 | struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? |
1291 | &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | ||
1292 | &phba->slim2p->mbx.us.s2.port[pring->ringno]; | ||
1079 | IOCB_t *irsp = NULL; | 1293 | IOCB_t *irsp = NULL; |
1080 | IOCB_t *entry = NULL; | 1294 | IOCB_t *entry = NULL; |
1081 | struct lpfc_iocbq *cmdiocbq = NULL; | 1295 | struct lpfc_iocbq *cmdiocbq = NULL; |
@@ -1086,9 +1300,8 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1086 | lpfc_iocb_type type; | 1300 | lpfc_iocb_type type; |
1087 | unsigned long iflag; | 1301 | unsigned long iflag; |
1088 | uint32_t rsp_cmpl = 0; | 1302 | uint32_t rsp_cmpl = 0; |
1089 | void __iomem *to_slim; | ||
1090 | 1303 | ||
1091 | spin_lock_irqsave(phba->host->host_lock, iflag); | 1304 | spin_lock_irqsave(&phba->hbalock, iflag); |
1092 | pring->stats.iocb_event++; | 1305 | pring->stats.iocb_event++; |
1093 | 1306 | ||
1094 | /* | 1307 | /* |
@@ -1099,7 +1312,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1099 | portRspPut = le32_to_cpu(pgp->rspPutInx); | 1312 | portRspPut = le32_to_cpu(pgp->rspPutInx); |
1100 | if (unlikely(portRspPut >= portRspMax)) { | 1313 | if (unlikely(portRspPut >= portRspMax)) { |
1101 | lpfc_sli_rsp_pointers_error(phba, pring); | 1314 | lpfc_sli_rsp_pointers_error(phba, pring); |
1102 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | 1315 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
1103 | return 1; | 1316 | return 1; |
1104 | } | 1317 | } |
1105 | 1318 | ||
@@ -1110,14 +1323,15 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1110 | * structure. The copy involves a byte-swap since the | 1323 | * structure. The copy involves a byte-swap since the |
1111 | * network byte order and pci byte orders are different. | 1324 | * network byte order and pci byte orders are different. |
1112 | */ | 1325 | */ |
1113 | entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx); | 1326 | entry = lpfc_resp_iocb(phba, pring); |
1327 | phba->last_completion_time = jiffies; | ||
1114 | 1328 | ||
1115 | if (++pring->rspidx >= portRspMax) | 1329 | if (++pring->rspidx >= portRspMax) |
1116 | pring->rspidx = 0; | 1330 | pring->rspidx = 0; |
1117 | 1331 | ||
1118 | lpfc_sli_pcimem_bcopy((uint32_t *) entry, | 1332 | lpfc_sli_pcimem_bcopy((uint32_t *) entry, |
1119 | (uint32_t *) &rspiocbq.iocb, | 1333 | (uint32_t *) &rspiocbq.iocb, |
1120 | sizeof (IOCB_t)); | 1334 | phba->iocb_rsp_size); |
1121 | INIT_LIST_HEAD(&(rspiocbq.list)); | 1335 | INIT_LIST_HEAD(&(rspiocbq.list)); |
1122 | irsp = &rspiocbq.iocb; | 1336 | irsp = &rspiocbq.iocb; |
1123 | 1337 | ||
@@ -1126,16 +1340,30 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1126 | rsp_cmpl++; | 1340 | rsp_cmpl++; |
1127 | 1341 | ||
1128 | if (unlikely(irsp->ulpStatus)) { | 1342 | if (unlikely(irsp->ulpStatus)) { |
1343 | /* | ||
1344 | * If resource errors reported from HBA, reduce | ||
1345 | * queuedepths of the SCSI device. | ||
1346 | */ | ||
1347 | if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && | ||
1348 | (irsp->un.ulpWord[4] == IOERR_NO_RESOURCES)) { | ||
1349 | spin_unlock_irqrestore(&phba->hbalock, iflag); | ||
1350 | lpfc_adjust_queue_depth(phba); | ||
1351 | spin_lock_irqsave(&phba->hbalock, iflag); | ||
1352 | } | ||
1353 | |||
1129 | /* Rsp ring <ringno> error: IOCB */ | 1354 | /* Rsp ring <ringno> error: IOCB */ |
1130 | lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, | 1355 | lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, |
1131 | "%d:0336 Rsp Ring %d error: IOCB Data: " | 1356 | "%d:0336 Rsp Ring %d error: IOCB Data: " |
1132 | "x%x x%x x%x x%x x%x x%x x%x x%x\n", | 1357 | "x%x x%x x%x x%x x%x x%x x%x x%x\n", |
1133 | phba->brd_no, pring->ringno, | 1358 | phba->brd_no, pring->ringno, |
1134 | irsp->un.ulpWord[0], irsp->un.ulpWord[1], | 1359 | irsp->un.ulpWord[0], |
1135 | irsp->un.ulpWord[2], irsp->un.ulpWord[3], | 1360 | irsp->un.ulpWord[1], |
1136 | irsp->un.ulpWord[4], irsp->un.ulpWord[5], | 1361 | irsp->un.ulpWord[2], |
1137 | *(((uint32_t *) irsp) + 6), | 1362 | irsp->un.ulpWord[3], |
1138 | *(((uint32_t *) irsp) + 7)); | 1363 | irsp->un.ulpWord[4], |
1364 | irsp->un.ulpWord[5], | ||
1365 | *(((uint32_t *) irsp) + 6), | ||
1366 | *(((uint32_t *) irsp) + 7)); | ||
1139 | } | 1367 | } |
1140 | 1368 | ||
1141 | switch (type) { | 1369 | switch (type) { |
@@ -1149,7 +1377,8 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1149 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | 1377 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
1150 | "%d:0333 IOCB cmd 0x%x" | 1378 | "%d:0333 IOCB cmd 0x%x" |
1151 | " processed. Skipping" | 1379 | " processed. Skipping" |
1152 | " completion\n", phba->brd_no, | 1380 | " completion\n", |
1381 | phba->brd_no, | ||
1153 | irsp->ulpCommand); | 1382 | irsp->ulpCommand); |
1154 | break; | 1383 | break; |
1155 | } | 1384 | } |
@@ -1161,19 +1390,19 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1161 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, | 1390 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, |
1162 | &rspiocbq); | 1391 | &rspiocbq); |
1163 | } else { | 1392 | } else { |
1164 | spin_unlock_irqrestore( | 1393 | spin_unlock_irqrestore(&phba->hbalock, |
1165 | phba->host->host_lock, iflag); | 1394 | iflag); |
1166 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, | 1395 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, |
1167 | &rspiocbq); | 1396 | &rspiocbq); |
1168 | spin_lock_irqsave(phba->host->host_lock, | 1397 | spin_lock_irqsave(&phba->hbalock, |
1169 | iflag); | 1398 | iflag); |
1170 | } | 1399 | } |
1171 | } | 1400 | } |
1172 | break; | 1401 | break; |
1173 | case LPFC_UNSOL_IOCB: | 1402 | case LPFC_UNSOL_IOCB: |
1174 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | 1403 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
1175 | lpfc_sli_process_unsol_iocb(phba, pring, &rspiocbq); | 1404 | lpfc_sli_process_unsol_iocb(phba, pring, &rspiocbq); |
1176 | spin_lock_irqsave(phba->host->host_lock, iflag); | 1405 | spin_lock_irqsave(&phba->hbalock, iflag); |
1177 | break; | 1406 | break; |
1178 | default: | 1407 | default: |
1179 | if (irsp->ulpCommand == CMD_ADAPTER_MSG) { | 1408 | if (irsp->ulpCommand == CMD_ADAPTER_MSG) { |
@@ -1186,11 +1415,13 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1186 | } else { | 1415 | } else { |
1187 | /* Unknown IOCB command */ | 1416 | /* Unknown IOCB command */ |
1188 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, | 1417 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
1189 | "%d:0334 Unknown IOCB command " | 1418 | "%d:0334 Unknown IOCB command " |
1190 | "Data: x%x, x%x x%x x%x x%x\n", | 1419 | "Data: x%x, x%x x%x x%x x%x\n", |
1191 | phba->brd_no, type, irsp->ulpCommand, | 1420 | phba->brd_no, type, |
1192 | irsp->ulpStatus, irsp->ulpIoTag, | 1421 | irsp->ulpCommand, |
1193 | irsp->ulpContext); | 1422 | irsp->ulpStatus, |
1423 | irsp->ulpIoTag, | ||
1424 | irsp->ulpContext); | ||
1194 | } | 1425 | } |
1195 | break; | 1426 | break; |
1196 | } | 1427 | } |
@@ -1201,9 +1432,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1201 | * been updated, sync the pgp->rspPutInx and fetch the new port | 1432 | * been updated, sync the pgp->rspPutInx and fetch the new port |
1202 | * response put pointer. | 1433 | * response put pointer. |
1203 | */ | 1434 | */ |
1204 | to_slim = phba->MBslimaddr + | 1435 | writel(pring->rspidx, &phba->host_gp[pring->ringno].rspGetInx); |
1205 | (SLIMOFF + (pring->ringno * 2) + 1) * 4; | ||
1206 | writel(pring->rspidx, to_slim); | ||
1207 | 1436 | ||
1208 | if (pring->rspidx == portRspPut) | 1437 | if (pring->rspidx == portRspPut) |
1209 | portRspPut = le32_to_cpu(pgp->rspPutInx); | 1438 | portRspPut = le32_to_cpu(pgp->rspPutInx); |
@@ -1228,31 +1457,31 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1228 | 1457 | ||
1229 | } | 1458 | } |
1230 | 1459 | ||
1231 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | 1460 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
1232 | return rc; | 1461 | return rc; |
1233 | } | 1462 | } |
1234 | 1463 | ||
1235 | |||
1236 | int | 1464 | int |
1237 | lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | 1465 | lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba, |
1238 | struct lpfc_sli_ring * pring, uint32_t mask) | 1466 | struct lpfc_sli_ring *pring, uint32_t mask) |
1239 | { | 1467 | { |
1468 | struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? | ||
1469 | &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] : | ||
1470 | &phba->slim2p->mbx.us.s2.port[pring->ringno]; | ||
1240 | IOCB_t *entry; | 1471 | IOCB_t *entry; |
1241 | IOCB_t *irsp = NULL; | 1472 | IOCB_t *irsp = NULL; |
1242 | struct lpfc_iocbq *rspiocbp = NULL; | 1473 | struct lpfc_iocbq *rspiocbp = NULL; |
1243 | struct lpfc_iocbq *next_iocb; | 1474 | struct lpfc_iocbq *next_iocb; |
1244 | struct lpfc_iocbq *cmdiocbp; | 1475 | struct lpfc_iocbq *cmdiocbp; |
1245 | struct lpfc_iocbq *saveq; | 1476 | struct lpfc_iocbq *saveq; |
1246 | struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno]; | ||
1247 | uint8_t iocb_cmd_type; | 1477 | uint8_t iocb_cmd_type; |
1248 | lpfc_iocb_type type; | 1478 | lpfc_iocb_type type; |
1249 | uint32_t status, free_saveq; | 1479 | uint32_t status, free_saveq; |
1250 | uint32_t portRspPut, portRspMax; | 1480 | uint32_t portRspPut, portRspMax; |
1251 | int rc = 1; | 1481 | int rc = 1; |
1252 | unsigned long iflag; | 1482 | unsigned long iflag; |
1253 | void __iomem *to_slim; | ||
1254 | 1483 | ||
1255 | spin_lock_irqsave(phba->host->host_lock, iflag); | 1484 | spin_lock_irqsave(&phba->hbalock, iflag); |
1256 | pring->stats.iocb_event++; | 1485 | pring->stats.iocb_event++; |
1257 | 1486 | ||
1258 | /* | 1487 | /* |
@@ -1266,16 +1495,14 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | |||
1266 | * Ring <ringno> handler: portRspPut <portRspPut> is bigger then | 1495 | * Ring <ringno> handler: portRspPut <portRspPut> is bigger then |
1267 | * rsp ring <portRspMax> | 1496 | * rsp ring <portRspMax> |
1268 | */ | 1497 | */ |
1269 | lpfc_printf_log(phba, | 1498 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
1270 | KERN_ERR, | ||
1271 | LOG_SLI, | ||
1272 | "%d:0303 Ring %d handler: portRspPut %d " | 1499 | "%d:0303 Ring %d handler: portRspPut %d " |
1273 | "is bigger then rsp ring %d\n", | 1500 | "is bigger then rsp ring %d\n", |
1274 | phba->brd_no, | 1501 | phba->brd_no, pring->ringno, portRspPut, |
1275 | pring->ringno, portRspPut, portRspMax); | 1502 | portRspMax); |
1276 | 1503 | ||
1277 | phba->hba_state = LPFC_HBA_ERROR; | 1504 | phba->link_state = LPFC_HBA_ERROR; |
1278 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | 1505 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
1279 | 1506 | ||
1280 | phba->work_hs = HS_FFER3; | 1507 | phba->work_hs = HS_FFER3; |
1281 | lpfc_handle_eratt(phba); | 1508 | lpfc_handle_eratt(phba); |
@@ -1298,23 +1525,24 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | |||
1298 | * the ulpLe field is set, the entire Command has been | 1525 | * the ulpLe field is set, the entire Command has been |
1299 | * received. | 1526 | * received. |
1300 | */ | 1527 | */ |
1301 | entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx); | 1528 | entry = lpfc_resp_iocb(phba, pring); |
1302 | rspiocbp = lpfc_sli_get_iocbq(phba); | 1529 | |
1530 | phba->last_completion_time = jiffies; | ||
1531 | rspiocbp = __lpfc_sli_get_iocbq(phba); | ||
1303 | if (rspiocbp == NULL) { | 1532 | if (rspiocbp == NULL) { |
1304 | printk(KERN_ERR "%s: out of buffers! Failing " | 1533 | printk(KERN_ERR "%s: out of buffers! Failing " |
1305 | "completion.\n", __FUNCTION__); | 1534 | "completion.\n", __FUNCTION__); |
1306 | break; | 1535 | break; |
1307 | } | 1536 | } |
1308 | 1537 | ||
1309 | lpfc_sli_pcimem_bcopy(entry, &rspiocbp->iocb, sizeof (IOCB_t)); | 1538 | lpfc_sli_pcimem_bcopy(entry, &rspiocbp->iocb, |
1539 | phba->iocb_rsp_size); | ||
1310 | irsp = &rspiocbp->iocb; | 1540 | irsp = &rspiocbp->iocb; |
1311 | 1541 | ||
1312 | if (++pring->rspidx >= portRspMax) | 1542 | if (++pring->rspidx >= portRspMax) |
1313 | pring->rspidx = 0; | 1543 | pring->rspidx = 0; |
1314 | 1544 | ||
1315 | to_slim = phba->MBslimaddr + (SLIMOFF + (pring->ringno * 2) | 1545 | writel(pring->rspidx, &phba->host_gp[pring->ringno].rspGetInx); |
1316 | + 1) * 4; | ||
1317 | writel(pring->rspidx, to_slim); | ||
1318 | 1546 | ||
1319 | if (list_empty(&(pring->iocb_continueq))) { | 1547 | if (list_empty(&(pring->iocb_continueq))) { |
1320 | list_add(&rspiocbp->list, &(pring->iocb_continueq)); | 1548 | list_add(&rspiocbp->list, &(pring->iocb_continueq)); |
@@ -1338,23 +1566,44 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | |||
1338 | 1566 | ||
1339 | pring->stats.iocb_rsp++; | 1567 | pring->stats.iocb_rsp++; |
1340 | 1568 | ||
1569 | /* | ||
1570 | * If resource errors reported from HBA, reduce | ||
1571 | * queuedepths of the SCSI device. | ||
1572 | */ | ||
1573 | if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && | ||
1574 | (irsp->un.ulpWord[4] == IOERR_NO_RESOURCES)) { | ||
1575 | spin_unlock_irqrestore(&phba->hbalock, iflag); | ||
1576 | lpfc_adjust_queue_depth(phba); | ||
1577 | spin_lock_irqsave(&phba->hbalock, iflag); | ||
1578 | } | ||
1579 | |||
1341 | if (irsp->ulpStatus) { | 1580 | if (irsp->ulpStatus) { |
1342 | /* Rsp ring <ringno> error: IOCB */ | 1581 | /* Rsp ring <ringno> error: IOCB */ |
1343 | lpfc_printf_log(phba, | 1582 | lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, |
1344 | KERN_WARNING, | 1583 | "%d:0328 Rsp Ring %d error: " |
1345 | LOG_SLI, | 1584 | "IOCB Data: " |
1346 | "%d:0328 Rsp Ring %d error: IOCB Data: " | 1585 | "x%x x%x x%x x%x " |
1347 | "x%x x%x x%x x%x x%x x%x x%x x%x\n", | 1586 | "x%x x%x x%x x%x " |
1348 | phba->brd_no, | 1587 | "x%x x%x x%x x%x " |
1349 | pring->ringno, | 1588 | "x%x x%x x%x x%x\n", |
1350 | irsp->un.ulpWord[0], | 1589 | phba->brd_no, |
1351 | irsp->un.ulpWord[1], | 1590 | pring->ringno, |
1352 | irsp->un.ulpWord[2], | 1591 | irsp->un.ulpWord[0], |
1353 | irsp->un.ulpWord[3], | 1592 | irsp->un.ulpWord[1], |
1354 | irsp->un.ulpWord[4], | 1593 | irsp->un.ulpWord[2], |
1355 | irsp->un.ulpWord[5], | 1594 | irsp->un.ulpWord[3], |
1356 | *(((uint32_t *) irsp) + 6), | 1595 | irsp->un.ulpWord[4], |
1357 | *(((uint32_t *) irsp) + 7)); | 1596 | irsp->un.ulpWord[5], |
1597 | *(((uint32_t *) irsp) + 6), | ||
1598 | *(((uint32_t *) irsp) + 7), | ||
1599 | *(((uint32_t *) irsp) + 8), | ||
1600 | *(((uint32_t *) irsp) + 9), | ||
1601 | *(((uint32_t *) irsp) + 10), | ||
1602 | *(((uint32_t *) irsp) + 11), | ||
1603 | *(((uint32_t *) irsp) + 12), | ||
1604 | *(((uint32_t *) irsp) + 13), | ||
1605 | *(((uint32_t *) irsp) + 14), | ||
1606 | *(((uint32_t *) irsp) + 15)); | ||
1358 | } | 1607 | } |
1359 | 1608 | ||
1360 | /* | 1609 | /* |
@@ -1366,17 +1615,17 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | |||
1366 | iocb_cmd_type = irsp->ulpCommand & CMD_IOCB_MASK; | 1615 | iocb_cmd_type = irsp->ulpCommand & CMD_IOCB_MASK; |
1367 | type = lpfc_sli_iocb_cmd_type(iocb_cmd_type); | 1616 | type = lpfc_sli_iocb_cmd_type(iocb_cmd_type); |
1368 | if (type == LPFC_SOL_IOCB) { | 1617 | if (type == LPFC_SOL_IOCB) { |
1369 | spin_unlock_irqrestore(phba->host->host_lock, | 1618 | spin_unlock_irqrestore(&phba->hbalock, |
1370 | iflag); | 1619 | iflag); |
1371 | rc = lpfc_sli_process_sol_iocb(phba, pring, | 1620 | rc = lpfc_sli_process_sol_iocb(phba, pring, |
1372 | saveq); | 1621 | saveq); |
1373 | spin_lock_irqsave(phba->host->host_lock, iflag); | 1622 | spin_lock_irqsave(&phba->hbalock, iflag); |
1374 | } else if (type == LPFC_UNSOL_IOCB) { | 1623 | } else if (type == LPFC_UNSOL_IOCB) { |
1375 | spin_unlock_irqrestore(phba->host->host_lock, | 1624 | spin_unlock_irqrestore(&phba->hbalock, |
1376 | iflag); | 1625 | iflag); |
1377 | rc = lpfc_sli_process_unsol_iocb(phba, pring, | 1626 | rc = lpfc_sli_process_unsol_iocb(phba, pring, |
1378 | saveq); | 1627 | saveq); |
1379 | spin_lock_irqsave(phba->host->host_lock, iflag); | 1628 | spin_lock_irqsave(&phba->hbalock, iflag); |
1380 | } else if (type == LPFC_ABORT_IOCB) { | 1629 | } else if (type == LPFC_ABORT_IOCB) { |
1381 | if ((irsp->ulpCommand != CMD_XRI_ABORTED_CX) && | 1630 | if ((irsp->ulpCommand != CMD_XRI_ABORTED_CX) && |
1382 | ((cmdiocbp = | 1631 | ((cmdiocbp = |
@@ -1386,15 +1635,15 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | |||
1386 | routine */ | 1635 | routine */ |
1387 | if (cmdiocbp->iocb_cmpl) { | 1636 | if (cmdiocbp->iocb_cmpl) { |
1388 | spin_unlock_irqrestore( | 1637 | spin_unlock_irqrestore( |
1389 | phba->host->host_lock, | 1638 | &phba->hbalock, |
1390 | iflag); | 1639 | iflag); |
1391 | (cmdiocbp->iocb_cmpl) (phba, | 1640 | (cmdiocbp->iocb_cmpl) (phba, |
1392 | cmdiocbp, saveq); | 1641 | cmdiocbp, saveq); |
1393 | spin_lock_irqsave( | 1642 | spin_lock_irqsave( |
1394 | phba->host->host_lock, | 1643 | &phba->hbalock, |
1395 | iflag); | 1644 | iflag); |
1396 | } else | 1645 | } else |
1397 | lpfc_sli_release_iocbq(phba, | 1646 | __lpfc_sli_release_iocbq(phba, |
1398 | cmdiocbp); | 1647 | cmdiocbp); |
1399 | } | 1648 | } |
1400 | } else if (type == LPFC_UNKNOWN_IOCB) { | 1649 | } else if (type == LPFC_UNKNOWN_IOCB) { |
@@ -1411,32 +1660,28 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | |||
1411 | phba->brd_no, adaptermsg); | 1660 | phba->brd_no, adaptermsg); |
1412 | } else { | 1661 | } else { |
1413 | /* Unknown IOCB command */ | 1662 | /* Unknown IOCB command */ |
1414 | lpfc_printf_log(phba, | 1663 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
1415 | KERN_ERR, | 1664 | "%d:0335 Unknown IOCB " |
1416 | LOG_SLI, | 1665 | "command Data: x%x " |
1417 | "%d:0335 Unknown IOCB command " | 1666 | "x%x x%x x%x\n", |
1418 | "Data: x%x x%x x%x x%x\n", | 1667 | phba->brd_no, |
1419 | phba->brd_no, | 1668 | irsp->ulpCommand, |
1420 | irsp->ulpCommand, | 1669 | irsp->ulpStatus, |
1421 | irsp->ulpStatus, | 1670 | irsp->ulpIoTag, |
1422 | irsp->ulpIoTag, | 1671 | irsp->ulpContext); |
1423 | irsp->ulpContext); | ||
1424 | } | 1672 | } |
1425 | } | 1673 | } |
1426 | 1674 | ||
1427 | if (free_saveq) { | 1675 | if (free_saveq) { |
1428 | if (!list_empty(&saveq->list)) { | 1676 | list_for_each_entry_safe(rspiocbp, next_iocb, |
1429 | list_for_each_entry_safe(rspiocbp, | 1677 | &saveq->list, list) { |
1430 | next_iocb, | 1678 | list_del(&rspiocbp->list); |
1431 | &saveq->list, | 1679 | __lpfc_sli_release_iocbq(phba, |
1432 | list) { | 1680 | rspiocbp); |
1433 | list_del(&rspiocbp->list); | ||
1434 | lpfc_sli_release_iocbq(phba, | ||
1435 | rspiocbp); | ||
1436 | } | ||
1437 | } | 1681 | } |
1438 | lpfc_sli_release_iocbq(phba, saveq); | 1682 | __lpfc_sli_release_iocbq(phba, saveq); |
1439 | } | 1683 | } |
1684 | rspiocbp = NULL; | ||
1440 | } | 1685 | } |
1441 | 1686 | ||
1442 | /* | 1687 | /* |
@@ -1449,7 +1694,7 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | |||
1449 | } | 1694 | } |
1450 | } /* while (pring->rspidx != portRspPut) */ | 1695 | } /* while (pring->rspidx != portRspPut) */ |
1451 | 1696 | ||
1452 | if ((rspiocbp != 0) && (mask & HA_R0RE_REQ)) { | 1697 | if ((rspiocbp != NULL) && (mask & HA_R0RE_REQ)) { |
1453 | /* At least one response entry has been freed */ | 1698 | /* At least one response entry has been freed */ |
1454 | pring->stats.iocb_rsp_full++; | 1699 | pring->stats.iocb_rsp_full++; |
1455 | /* SET RxRE_RSP in Chip Att register */ | 1700 | /* SET RxRE_RSP in Chip Att register */ |
@@ -1470,24 +1715,25 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba, | |||
1470 | 1715 | ||
1471 | } | 1716 | } |
1472 | 1717 | ||
1473 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | 1718 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
1474 | return rc; | 1719 | return rc; |
1475 | } | 1720 | } |
1476 | 1721 | ||
1477 | int | 1722 | void |
1478 | lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | 1723 | lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) |
1479 | { | 1724 | { |
1480 | LIST_HEAD(completions); | 1725 | LIST_HEAD(completions); |
1481 | struct lpfc_iocbq *iocb, *next_iocb; | 1726 | struct lpfc_iocbq *iocb, *next_iocb; |
1482 | IOCB_t *cmd = NULL; | 1727 | IOCB_t *cmd = NULL; |
1483 | int errcnt; | ||
1484 | 1728 | ||
1485 | errcnt = 0; | 1729 | if (pring->ringno == LPFC_ELS_RING) { |
1730 | lpfc_fabric_abort_hba(phba); | ||
1731 | } | ||
1486 | 1732 | ||
1487 | /* Error everything on txq and txcmplq | 1733 | /* Error everything on txq and txcmplq |
1488 | * First do the txq. | 1734 | * First do the txq. |
1489 | */ | 1735 | */ |
1490 | spin_lock_irq(phba->host->host_lock); | 1736 | spin_lock_irq(&phba->hbalock); |
1491 | list_splice_init(&pring->txq, &completions); | 1737 | list_splice_init(&pring->txq, &completions); |
1492 | pring->txq_cnt = 0; | 1738 | pring->txq_cnt = 0; |
1493 | 1739 | ||
@@ -1495,26 +1741,25 @@ lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
1495 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) | 1741 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) |
1496 | lpfc_sli_issue_abort_iotag(phba, pring, iocb); | 1742 | lpfc_sli_issue_abort_iotag(phba, pring, iocb); |
1497 | 1743 | ||
1498 | spin_unlock_irq(phba->host->host_lock); | 1744 | spin_unlock_irq(&phba->hbalock); |
1499 | 1745 | ||
1500 | while (!list_empty(&completions)) { | 1746 | while (!list_empty(&completions)) { |
1501 | iocb = list_get_first(&completions, struct lpfc_iocbq, list); | 1747 | iocb = list_get_first(&completions, struct lpfc_iocbq, list); |
1502 | cmd = &iocb->iocb; | 1748 | cmd = &iocb->iocb; |
1503 | list_del(&iocb->list); | 1749 | list_del_init(&iocb->list); |
1504 | 1750 | ||
1505 | if (iocb->iocb_cmpl) { | 1751 | if (!iocb->iocb_cmpl) |
1752 | lpfc_sli_release_iocbq(phba, iocb); | ||
1753 | else { | ||
1506 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | 1754 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; |
1507 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | 1755 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; |
1508 | (iocb->iocb_cmpl) (phba, iocb, iocb); | 1756 | (iocb->iocb_cmpl) (phba, iocb, iocb); |
1509 | } else | 1757 | } |
1510 | lpfc_sli_release_iocbq(phba, iocb); | ||
1511 | } | 1758 | } |
1512 | |||
1513 | return errcnt; | ||
1514 | } | 1759 | } |
1515 | 1760 | ||
1516 | int | 1761 | int |
1517 | lpfc_sli_brdready(struct lpfc_hba * phba, uint32_t mask) | 1762 | lpfc_sli_brdready(struct lpfc_hba *phba, uint32_t mask) |
1518 | { | 1763 | { |
1519 | uint32_t status; | 1764 | uint32_t status; |
1520 | int i = 0; | 1765 | int i = 0; |
@@ -1541,7 +1786,8 @@ lpfc_sli_brdready(struct lpfc_hba * phba, uint32_t mask) | |||
1541 | msleep(2500); | 1786 | msleep(2500); |
1542 | 1787 | ||
1543 | if (i == 15) { | 1788 | if (i == 15) { |
1544 | phba->hba_state = LPFC_STATE_UNKNOWN; /* Do post */ | 1789 | /* Do post */ |
1790 | phba->pport->port_state = LPFC_VPORT_UNKNOWN; | ||
1545 | lpfc_sli_brdrestart(phba); | 1791 | lpfc_sli_brdrestart(phba); |
1546 | } | 1792 | } |
1547 | /* Read the HBA Host Status Register */ | 1793 | /* Read the HBA Host Status Register */ |
@@ -1550,7 +1796,7 @@ lpfc_sli_brdready(struct lpfc_hba * phba, uint32_t mask) | |||
1550 | 1796 | ||
1551 | /* Check to see if any errors occurred during init */ | 1797 | /* Check to see if any errors occurred during init */ |
1552 | if ((status & HS_FFERM) || (i >= 20)) { | 1798 | if ((status & HS_FFERM) || (i >= 20)) { |
1553 | phba->hba_state = LPFC_HBA_ERROR; | 1799 | phba->link_state = LPFC_HBA_ERROR; |
1554 | retval = 1; | 1800 | retval = 1; |
1555 | } | 1801 | } |
1556 | 1802 | ||
@@ -1559,7 +1805,7 @@ lpfc_sli_brdready(struct lpfc_hba * phba, uint32_t mask) | |||
1559 | 1805 | ||
1560 | #define BARRIER_TEST_PATTERN (0xdeadbeef) | 1806 | #define BARRIER_TEST_PATTERN (0xdeadbeef) |
1561 | 1807 | ||
1562 | void lpfc_reset_barrier(struct lpfc_hba * phba) | 1808 | void lpfc_reset_barrier(struct lpfc_hba *phba) |
1563 | { | 1809 | { |
1564 | uint32_t __iomem *resp_buf; | 1810 | uint32_t __iomem *resp_buf; |
1565 | uint32_t __iomem *mbox_buf; | 1811 | uint32_t __iomem *mbox_buf; |
@@ -1584,12 +1830,12 @@ void lpfc_reset_barrier(struct lpfc_hba * phba) | |||
1584 | hc_copy = readl(phba->HCregaddr); | 1830 | hc_copy = readl(phba->HCregaddr); |
1585 | writel((hc_copy & ~HC_ERINT_ENA), phba->HCregaddr); | 1831 | writel((hc_copy & ~HC_ERINT_ENA), phba->HCregaddr); |
1586 | readl(phba->HCregaddr); /* flush */ | 1832 | readl(phba->HCregaddr); /* flush */ |
1587 | phba->fc_flag |= FC_IGNORE_ERATT; | 1833 | phba->link_flag |= LS_IGNORE_ERATT; |
1588 | 1834 | ||
1589 | if (readl(phba->HAregaddr) & HA_ERATT) { | 1835 | if (readl(phba->HAregaddr) & HA_ERATT) { |
1590 | /* Clear Chip error bit */ | 1836 | /* Clear Chip error bit */ |
1591 | writel(HA_ERATT, phba->HAregaddr); | 1837 | writel(HA_ERATT, phba->HAregaddr); |
1592 | phba->stopped = 1; | 1838 | phba->pport->stopped = 1; |
1593 | } | 1839 | } |
1594 | 1840 | ||
1595 | mbox = 0; | 1841 | mbox = 0; |
@@ -1606,7 +1852,7 @@ void lpfc_reset_barrier(struct lpfc_hba * phba) | |||
1606 | 1852 | ||
1607 | if (readl(resp_buf + 1) != ~(BARRIER_TEST_PATTERN)) { | 1853 | if (readl(resp_buf + 1) != ~(BARRIER_TEST_PATTERN)) { |
1608 | if (phba->sli.sli_flag & LPFC_SLI2_ACTIVE || | 1854 | if (phba->sli.sli_flag & LPFC_SLI2_ACTIVE || |
1609 | phba->stopped) | 1855 | phba->pport->stopped) |
1610 | goto restore_hc; | 1856 | goto restore_hc; |
1611 | else | 1857 | else |
1612 | goto clear_errat; | 1858 | goto clear_errat; |
@@ -1623,17 +1869,17 @@ clear_errat: | |||
1623 | 1869 | ||
1624 | if (readl(phba->HAregaddr) & HA_ERATT) { | 1870 | if (readl(phba->HAregaddr) & HA_ERATT) { |
1625 | writel(HA_ERATT, phba->HAregaddr); | 1871 | writel(HA_ERATT, phba->HAregaddr); |
1626 | phba->stopped = 1; | 1872 | phba->pport->stopped = 1; |
1627 | } | 1873 | } |
1628 | 1874 | ||
1629 | restore_hc: | 1875 | restore_hc: |
1630 | phba->fc_flag &= ~FC_IGNORE_ERATT; | 1876 | phba->link_flag &= ~LS_IGNORE_ERATT; |
1631 | writel(hc_copy, phba->HCregaddr); | 1877 | writel(hc_copy, phba->HCregaddr); |
1632 | readl(phba->HCregaddr); /* flush */ | 1878 | readl(phba->HCregaddr); /* flush */ |
1633 | } | 1879 | } |
1634 | 1880 | ||
1635 | int | 1881 | int |
1636 | lpfc_sli_brdkill(struct lpfc_hba * phba) | 1882 | lpfc_sli_brdkill(struct lpfc_hba *phba) |
1637 | { | 1883 | { |
1638 | struct lpfc_sli *psli; | 1884 | struct lpfc_sli *psli; |
1639 | LPFC_MBOXQ_t *pmb; | 1885 | LPFC_MBOXQ_t *pmb; |
@@ -1645,26 +1891,22 @@ lpfc_sli_brdkill(struct lpfc_hba * phba) | |||
1645 | psli = &phba->sli; | 1891 | psli = &phba->sli; |
1646 | 1892 | ||
1647 | /* Kill HBA */ | 1893 | /* Kill HBA */ |
1648 | lpfc_printf_log(phba, | 1894 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
1649 | KERN_INFO, | 1895 | "%d:0329 Kill HBA Data: x%x x%x\n", |
1650 | LOG_SLI, | 1896 | phba->brd_no, phba->pport->port_state, psli->sli_flag); |
1651 | "%d:0329 Kill HBA Data: x%x x%x\n", | ||
1652 | phba->brd_no, | ||
1653 | phba->hba_state, | ||
1654 | psli->sli_flag); | ||
1655 | 1897 | ||
1656 | if ((pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, | 1898 | if ((pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, |
1657 | GFP_KERNEL)) == 0) | 1899 | GFP_KERNEL)) == 0) |
1658 | return 1; | 1900 | return 1; |
1659 | 1901 | ||
1660 | /* Disable the error attention */ | 1902 | /* Disable the error attention */ |
1661 | spin_lock_irq(phba->host->host_lock); | 1903 | spin_lock_irq(&phba->hbalock); |
1662 | status = readl(phba->HCregaddr); | 1904 | status = readl(phba->HCregaddr); |
1663 | status &= ~HC_ERINT_ENA; | 1905 | status &= ~HC_ERINT_ENA; |
1664 | writel(status, phba->HCregaddr); | 1906 | writel(status, phba->HCregaddr); |
1665 | readl(phba->HCregaddr); /* flush */ | 1907 | readl(phba->HCregaddr); /* flush */ |
1666 | phba->fc_flag |= FC_IGNORE_ERATT; | 1908 | phba->link_flag |= LS_IGNORE_ERATT; |
1667 | spin_unlock_irq(phba->host->host_lock); | 1909 | spin_unlock_irq(&phba->hbalock); |
1668 | 1910 | ||
1669 | lpfc_kill_board(phba, pmb); | 1911 | lpfc_kill_board(phba, pmb); |
1670 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | 1912 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
@@ -1673,9 +1915,9 @@ lpfc_sli_brdkill(struct lpfc_hba * phba) | |||
1673 | if (retval != MBX_SUCCESS) { | 1915 | if (retval != MBX_SUCCESS) { |
1674 | if (retval != MBX_BUSY) | 1916 | if (retval != MBX_BUSY) |
1675 | mempool_free(pmb, phba->mbox_mem_pool); | 1917 | mempool_free(pmb, phba->mbox_mem_pool); |
1676 | spin_lock_irq(phba->host->host_lock); | 1918 | spin_lock_irq(&phba->hbalock); |
1677 | phba->fc_flag &= ~FC_IGNORE_ERATT; | 1919 | phba->link_flag &= ~LS_IGNORE_ERATT; |
1678 | spin_unlock_irq(phba->host->host_lock); | 1920 | spin_unlock_irq(&phba->hbalock); |
1679 | return 1; | 1921 | return 1; |
1680 | } | 1922 | } |
1681 | 1923 | ||
@@ -1698,22 +1940,22 @@ lpfc_sli_brdkill(struct lpfc_hba * phba) | |||
1698 | del_timer_sync(&psli->mbox_tmo); | 1940 | del_timer_sync(&psli->mbox_tmo); |
1699 | if (ha_copy & HA_ERATT) { | 1941 | if (ha_copy & HA_ERATT) { |
1700 | writel(HA_ERATT, phba->HAregaddr); | 1942 | writel(HA_ERATT, phba->HAregaddr); |
1701 | phba->stopped = 1; | 1943 | phba->pport->stopped = 1; |
1702 | } | 1944 | } |
1703 | spin_lock_irq(phba->host->host_lock); | 1945 | spin_lock_irq(&phba->hbalock); |
1704 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | 1946 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; |
1705 | phba->fc_flag &= ~FC_IGNORE_ERATT; | 1947 | phba->link_flag &= ~LS_IGNORE_ERATT; |
1706 | spin_unlock_irq(phba->host->host_lock); | 1948 | spin_unlock_irq(&phba->hbalock); |
1707 | 1949 | ||
1708 | psli->mbox_active = NULL; | 1950 | psli->mbox_active = NULL; |
1709 | lpfc_hba_down_post(phba); | 1951 | lpfc_hba_down_post(phba); |
1710 | phba->hba_state = LPFC_HBA_ERROR; | 1952 | phba->link_state = LPFC_HBA_ERROR; |
1711 | 1953 | ||
1712 | return (ha_copy & HA_ERATT ? 0 : 1); | 1954 | return ha_copy & HA_ERATT ? 0 : 1; |
1713 | } | 1955 | } |
1714 | 1956 | ||
1715 | int | 1957 | int |
1716 | lpfc_sli_brdreset(struct lpfc_hba * phba) | 1958 | lpfc_sli_brdreset(struct lpfc_hba *phba) |
1717 | { | 1959 | { |
1718 | struct lpfc_sli *psli; | 1960 | struct lpfc_sli *psli; |
1719 | struct lpfc_sli_ring *pring; | 1961 | struct lpfc_sli_ring *pring; |
@@ -1725,12 +1967,12 @@ lpfc_sli_brdreset(struct lpfc_hba * phba) | |||
1725 | /* Reset HBA */ | 1967 | /* Reset HBA */ |
1726 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | 1968 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
1727 | "%d:0325 Reset HBA Data: x%x x%x\n", phba->brd_no, | 1969 | "%d:0325 Reset HBA Data: x%x x%x\n", phba->brd_no, |
1728 | phba->hba_state, psli->sli_flag); | 1970 | phba->pport->port_state, psli->sli_flag); |
1729 | 1971 | ||
1730 | /* perform board reset */ | 1972 | /* perform board reset */ |
1731 | phba->fc_eventTag = 0; | 1973 | phba->fc_eventTag = 0; |
1732 | phba->fc_myDID = 0; | 1974 | phba->pport->fc_myDID = 0; |
1733 | phba->fc_prevDID = 0; | 1975 | phba->pport->fc_prevDID = 0; |
1734 | 1976 | ||
1735 | /* Turn off parity checking and serr during the physical reset */ | 1977 | /* Turn off parity checking and serr during the physical reset */ |
1736 | pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value); | 1978 | pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value); |
@@ -1760,12 +2002,12 @@ lpfc_sli_brdreset(struct lpfc_hba * phba) | |||
1760 | pring->missbufcnt = 0; | 2002 | pring->missbufcnt = 0; |
1761 | } | 2003 | } |
1762 | 2004 | ||
1763 | phba->hba_state = LPFC_WARM_START; | 2005 | phba->link_state = LPFC_WARM_START; |
1764 | return 0; | 2006 | return 0; |
1765 | } | 2007 | } |
1766 | 2008 | ||
1767 | int | 2009 | int |
1768 | lpfc_sli_brdrestart(struct lpfc_hba * phba) | 2010 | lpfc_sli_brdrestart(struct lpfc_hba *phba) |
1769 | { | 2011 | { |
1770 | MAILBOX_t *mb; | 2012 | MAILBOX_t *mb; |
1771 | struct lpfc_sli *psli; | 2013 | struct lpfc_sli *psli; |
@@ -1773,14 +2015,14 @@ lpfc_sli_brdrestart(struct lpfc_hba * phba) | |||
1773 | volatile uint32_t word0; | 2015 | volatile uint32_t word0; |
1774 | void __iomem *to_slim; | 2016 | void __iomem *to_slim; |
1775 | 2017 | ||
1776 | spin_lock_irq(phba->host->host_lock); | 2018 | spin_lock_irq(&phba->hbalock); |
1777 | 2019 | ||
1778 | psli = &phba->sli; | 2020 | psli = &phba->sli; |
1779 | 2021 | ||
1780 | /* Restart HBA */ | 2022 | /* Restart HBA */ |
1781 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | 2023 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
1782 | "%d:0337 Restart HBA Data: x%x x%x\n", phba->brd_no, | 2024 | "%d:0337 Restart HBA Data: x%x x%x\n", phba->brd_no, |
1783 | phba->hba_state, psli->sli_flag); | 2025 | phba->pport->port_state, psli->sli_flag); |
1784 | 2026 | ||
1785 | word0 = 0; | 2027 | word0 = 0; |
1786 | mb = (MAILBOX_t *) &word0; | 2028 | mb = (MAILBOX_t *) &word0; |
@@ -1794,7 +2036,7 @@ lpfc_sli_brdrestart(struct lpfc_hba * phba) | |||
1794 | readl(to_slim); /* flush */ | 2036 | readl(to_slim); /* flush */ |
1795 | 2037 | ||
1796 | /* Only skip post after fc_ffinit is completed */ | 2038 | /* Only skip post after fc_ffinit is completed */ |
1797 | if (phba->hba_state) { | 2039 | if (phba->pport->port_state) { |
1798 | skip_post = 1; | 2040 | skip_post = 1; |
1799 | word0 = 1; /* This is really setting up word1 */ | 2041 | word0 = 1; /* This is really setting up word1 */ |
1800 | } else { | 2042 | } else { |
@@ -1806,10 +2048,10 @@ lpfc_sli_brdrestart(struct lpfc_hba * phba) | |||
1806 | readl(to_slim); /* flush */ | 2048 | readl(to_slim); /* flush */ |
1807 | 2049 | ||
1808 | lpfc_sli_brdreset(phba); | 2050 | lpfc_sli_brdreset(phba); |
1809 | phba->stopped = 0; | 2051 | phba->pport->stopped = 0; |
1810 | phba->hba_state = LPFC_INIT_START; | 2052 | phba->link_state = LPFC_INIT_START; |
1811 | 2053 | ||
1812 | spin_unlock_irq(phba->host->host_lock); | 2054 | spin_unlock_irq(&phba->hbalock); |
1813 | 2055 | ||
1814 | memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets)); | 2056 | memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets)); |
1815 | psli->stats_start = get_seconds(); | 2057 | psli->stats_start = get_seconds(); |
@@ -1843,14 +2085,11 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba) | |||
1843 | if (i++ >= 20) { | 2085 | if (i++ >= 20) { |
1844 | /* Adapter failed to init, timeout, status reg | 2086 | /* Adapter failed to init, timeout, status reg |
1845 | <status> */ | 2087 | <status> */ |
1846 | lpfc_printf_log(phba, | 2088 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
1847 | KERN_ERR, | ||
1848 | LOG_INIT, | ||
1849 | "%d:0436 Adapter failed to init, " | 2089 | "%d:0436 Adapter failed to init, " |
1850 | "timeout, status reg x%x\n", | 2090 | "timeout, status reg x%x\n", |
1851 | phba->brd_no, | 2091 | phba->brd_no, status); |
1852 | status); | 2092 | phba->link_state = LPFC_HBA_ERROR; |
1853 | phba->hba_state = LPFC_HBA_ERROR; | ||
1854 | return -ETIMEDOUT; | 2093 | return -ETIMEDOUT; |
1855 | } | 2094 | } |
1856 | 2095 | ||
@@ -1859,14 +2098,12 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba) | |||
1859 | /* ERROR: During chipset initialization */ | 2098 | /* ERROR: During chipset initialization */ |
1860 | /* Adapter failed to init, chipset, status reg | 2099 | /* Adapter failed to init, chipset, status reg |
1861 | <status> */ | 2100 | <status> */ |
1862 | lpfc_printf_log(phba, | 2101 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
1863 | KERN_ERR, | ||
1864 | LOG_INIT, | ||
1865 | "%d:0437 Adapter failed to init, " | 2102 | "%d:0437 Adapter failed to init, " |
1866 | "chipset, status reg x%x\n", | 2103 | "chipset, status reg x%x\n", |
1867 | phba->brd_no, | 2104 | phba->brd_no, |
1868 | status); | 2105 | status); |
1869 | phba->hba_state = LPFC_HBA_ERROR; | 2106 | phba->link_state = LPFC_HBA_ERROR; |
1870 | return -EIO; | 2107 | return -EIO; |
1871 | } | 2108 | } |
1872 | 2109 | ||
@@ -1879,7 +2116,8 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba) | |||
1879 | } | 2116 | } |
1880 | 2117 | ||
1881 | if (i == 15) { | 2118 | if (i == 15) { |
1882 | phba->hba_state = LPFC_STATE_UNKNOWN; /* Do post */ | 2119 | /* Do post */ |
2120 | phba->pport->port_state = LPFC_VPORT_UNKNOWN; | ||
1883 | lpfc_sli_brdrestart(phba); | 2121 | lpfc_sli_brdrestart(phba); |
1884 | } | 2122 | } |
1885 | /* Read the HBA Host Status Register */ | 2123 | /* Read the HBA Host Status Register */ |
@@ -1890,14 +2128,12 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba) | |||
1890 | if (status & HS_FFERM) { | 2128 | if (status & HS_FFERM) { |
1891 | /* ERROR: During chipset initialization */ | 2129 | /* ERROR: During chipset initialization */ |
1892 | /* Adapter failed to init, chipset, status reg <status> */ | 2130 | /* Adapter failed to init, chipset, status reg <status> */ |
1893 | lpfc_printf_log(phba, | 2131 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
1894 | KERN_ERR, | ||
1895 | LOG_INIT, | ||
1896 | "%d:0438 Adapter failed to init, chipset, " | 2132 | "%d:0438 Adapter failed to init, chipset, " |
1897 | "status reg x%x\n", | 2133 | "status reg x%x\n", |
1898 | phba->brd_no, | 2134 | phba->brd_no, |
1899 | status); | 2135 | status); |
1900 | phba->hba_state = LPFC_HBA_ERROR; | 2136 | phba->link_state = LPFC_HBA_ERROR; |
1901 | return -EIO; | 2137 | return -EIO; |
1902 | } | 2138 | } |
1903 | 2139 | ||
@@ -1911,80 +2147,253 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba) | |||
1911 | return 0; | 2147 | return 0; |
1912 | } | 2148 | } |
1913 | 2149 | ||
2150 | static int | ||
2151 | lpfc_sli_hbq_count(void) | ||
2152 | { | ||
2153 | return ARRAY_SIZE(lpfc_hbq_defs); | ||
2154 | } | ||
2155 | |||
2156 | static int | ||
2157 | lpfc_sli_hbq_entry_count(void) | ||
2158 | { | ||
2159 | int hbq_count = lpfc_sli_hbq_count(); | ||
2160 | int count = 0; | ||
2161 | int i; | ||
2162 | |||
2163 | for (i = 0; i < hbq_count; ++i) | ||
2164 | count += lpfc_hbq_defs[i]->entry_count; | ||
2165 | return count; | ||
2166 | } | ||
2167 | |||
1914 | int | 2168 | int |
1915 | lpfc_sli_hba_setup(struct lpfc_hba * phba) | 2169 | lpfc_sli_hbq_size(void) |
2170 | { | ||
2171 | return lpfc_sli_hbq_entry_count() * sizeof(struct lpfc_hbq_entry); | ||
2172 | } | ||
2173 | |||
2174 | static int | ||
2175 | lpfc_sli_hbq_setup(struct lpfc_hba *phba) | ||
2176 | { | ||
2177 | int hbq_count = lpfc_sli_hbq_count(); | ||
2178 | LPFC_MBOXQ_t *pmb; | ||
2179 | MAILBOX_t *pmbox; | ||
2180 | uint32_t hbqno; | ||
2181 | uint32_t hbq_entry_index; | ||
2182 | |||
2183 | /* Get a Mailbox buffer to setup mailbox | ||
2184 | * commands for HBA initialization | ||
2185 | */ | ||
2186 | pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | ||
2187 | |||
2188 | if (!pmb) | ||
2189 | return -ENOMEM; | ||
2190 | |||
2191 | pmbox = &pmb->mb; | ||
2192 | |||
2193 | /* Initialize the struct lpfc_sli_hbq structure for each hbq */ | ||
2194 | phba->link_state = LPFC_INIT_MBX_CMDS; | ||
2195 | |||
2196 | hbq_entry_index = 0; | ||
2197 | for (hbqno = 0; hbqno < hbq_count; ++hbqno) { | ||
2198 | phba->hbqs[hbqno].next_hbqPutIdx = 0; | ||
2199 | phba->hbqs[hbqno].hbqPutIdx = 0; | ||
2200 | phba->hbqs[hbqno].local_hbqGetIdx = 0; | ||
2201 | phba->hbqs[hbqno].entry_count = | ||
2202 | lpfc_hbq_defs[hbqno]->entry_count; | ||
2203 | lpfc_config_hbq(phba, lpfc_hbq_defs[hbqno], hbq_entry_index, | ||
2204 | pmb); | ||
2205 | hbq_entry_index += phba->hbqs[hbqno].entry_count; | ||
2206 | |||
2207 | if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { | ||
2208 | /* Adapter failed to init, mbxCmd <cmd> CFG_RING, | ||
2209 | mbxStatus <status>, ring <num> */ | ||
2210 | |||
2211 | lpfc_printf_log(phba, KERN_ERR, | ||
2212 | LOG_SLI | LOG_VPORT, | ||
2213 | "%d:1805 Adapter failed to init. " | ||
2214 | "Data: x%x x%x x%x\n", | ||
2215 | phba->brd_no, pmbox->mbxCommand, | ||
2216 | pmbox->mbxStatus, hbqno); | ||
2217 | |||
2218 | phba->link_state = LPFC_HBA_ERROR; | ||
2219 | mempool_free(pmb, phba->mbox_mem_pool); | ||
2220 | return ENXIO; | ||
2221 | } | ||
2222 | } | ||
2223 | phba->hbq_count = hbq_count; | ||
2224 | |||
2225 | mempool_free(pmb, phba->mbox_mem_pool); | ||
2226 | |||
2227 | /* Initially populate or replenish the HBQs */ | ||
2228 | for (hbqno = 0; hbqno < hbq_count; ++hbqno) { | ||
2229 | if (lpfc_sli_hbqbuf_init_hbqs(phba, hbqno)) | ||
2230 | return -ENOMEM; | ||
2231 | } | ||
2232 | return 0; | ||
2233 | } | ||
2234 | |||
2235 | static int | ||
2236 | lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode) | ||
1916 | { | 2237 | { |
1917 | LPFC_MBOXQ_t *pmb; | 2238 | LPFC_MBOXQ_t *pmb; |
1918 | uint32_t resetcount = 0, rc = 0, done = 0; | 2239 | uint32_t resetcount = 0, rc = 0, done = 0; |
1919 | 2240 | ||
1920 | pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 2241 | pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
1921 | if (!pmb) { | 2242 | if (!pmb) { |
1922 | phba->hba_state = LPFC_HBA_ERROR; | 2243 | phba->link_state = LPFC_HBA_ERROR; |
1923 | return -ENOMEM; | 2244 | return -ENOMEM; |
1924 | } | 2245 | } |
1925 | 2246 | ||
2247 | phba->sli_rev = sli_mode; | ||
1926 | while (resetcount < 2 && !done) { | 2248 | while (resetcount < 2 && !done) { |
1927 | spin_lock_irq(phba->host->host_lock); | 2249 | spin_lock_irq(&phba->hbalock); |
1928 | phba->sli.sli_flag |= LPFC_SLI_MBOX_ACTIVE; | 2250 | phba->sli.sli_flag |= LPFC_SLI_MBOX_ACTIVE; |
1929 | spin_unlock_irq(phba->host->host_lock); | 2251 | spin_unlock_irq(&phba->hbalock); |
1930 | phba->hba_state = LPFC_STATE_UNKNOWN; | 2252 | phba->pport->port_state = LPFC_VPORT_UNKNOWN; |
1931 | lpfc_sli_brdrestart(phba); | 2253 | lpfc_sli_brdrestart(phba); |
1932 | msleep(2500); | 2254 | msleep(2500); |
1933 | rc = lpfc_sli_chipset_init(phba); | 2255 | rc = lpfc_sli_chipset_init(phba); |
1934 | if (rc) | 2256 | if (rc) |
1935 | break; | 2257 | break; |
1936 | 2258 | ||
1937 | spin_lock_irq(phba->host->host_lock); | 2259 | spin_lock_irq(&phba->hbalock); |
1938 | phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | 2260 | phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; |
1939 | spin_unlock_irq(phba->host->host_lock); | 2261 | spin_unlock_irq(&phba->hbalock); |
1940 | resetcount++; | 2262 | resetcount++; |
1941 | 2263 | ||
1942 | /* Call pre CONFIG_PORT mailbox command initialization. A value of 0 | 2264 | /* Call pre CONFIG_PORT mailbox command initialization. A |
1943 | * means the call was successful. Any other nonzero value is a failure, | 2265 | * value of 0 means the call was successful. Any other |
1944 | * but if ERESTART is returned, the driver may reset the HBA and try | 2266 | * nonzero value is a failure, but if ERESTART is returned, |
1945 | * again. | 2267 | * the driver may reset the HBA and try again. |
1946 | */ | 2268 | */ |
1947 | rc = lpfc_config_port_prep(phba); | 2269 | rc = lpfc_config_port_prep(phba); |
1948 | if (rc == -ERESTART) { | 2270 | if (rc == -ERESTART) { |
1949 | phba->hba_state = 0; | 2271 | phba->link_state = LPFC_LINK_UNKNOWN; |
1950 | continue; | 2272 | continue; |
1951 | } else if (rc) { | 2273 | } else if (rc) { |
1952 | break; | 2274 | break; |
1953 | } | 2275 | } |
1954 | 2276 | ||
1955 | phba->hba_state = LPFC_INIT_MBX_CMDS; | 2277 | phba->link_state = LPFC_INIT_MBX_CMDS; |
1956 | lpfc_config_port(phba, pmb); | 2278 | lpfc_config_port(phba, pmb); |
1957 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); | 2279 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); |
1958 | if (rc == MBX_SUCCESS) | 2280 | if (rc != MBX_SUCCESS) { |
1959 | done = 1; | ||
1960 | else { | ||
1961 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 2281 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
1962 | "%d:0442 Adapter failed to init, mbxCmd x%x " | 2282 | "%d:0442 Adapter failed to init, mbxCmd x%x " |
1963 | "CONFIG_PORT, mbxStatus x%x Data: x%x\n", | 2283 | "CONFIG_PORT, mbxStatus x%x Data: x%x\n", |
1964 | phba->brd_no, pmb->mb.mbxCommand, | 2284 | phba->brd_no, pmb->mb.mbxCommand, |
1965 | pmb->mb.mbxStatus, 0); | 2285 | pmb->mb.mbxStatus, 0); |
2286 | spin_lock_irq(&phba->hbalock); | ||
1966 | phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE; | 2287 | phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE; |
2288 | spin_unlock_irq(&phba->hbalock); | ||
2289 | rc = -ENXIO; | ||
2290 | } else { | ||
2291 | done = 1; | ||
2292 | phba->max_vpi = (phba->max_vpi && | ||
2293 | pmb->mb.un.varCfgPort.gmv) != 0 | ||
2294 | ? pmb->mb.un.varCfgPort.max_vpi | ||
2295 | : 0; | ||
2296 | } | ||
2297 | } | ||
2298 | |||
2299 | if (!done) { | ||
2300 | rc = -EINVAL; | ||
2301 | goto do_prep_failed; | ||
2302 | } | ||
2303 | |||
2304 | if ((pmb->mb.un.varCfgPort.sli_mode == 3) && | ||
2305 | (!pmb->mb.un.varCfgPort.cMA)) { | ||
2306 | rc = -ENXIO; | ||
2307 | goto do_prep_failed; | ||
2308 | } | ||
2309 | return rc; | ||
2310 | |||
2311 | do_prep_failed: | ||
2312 | mempool_free(pmb, phba->mbox_mem_pool); | ||
2313 | return rc; | ||
2314 | } | ||
2315 | |||
2316 | int | ||
2317 | lpfc_sli_hba_setup(struct lpfc_hba *phba) | ||
2318 | { | ||
2319 | uint32_t rc; | ||
2320 | int mode = 3; | ||
2321 | |||
2322 | switch (lpfc_sli_mode) { | ||
2323 | case 2: | ||
2324 | if (phba->cfg_npiv_enable) { | ||
2325 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, | ||
2326 | "%d:1824 NPIV enabled: Override lpfc_sli_mode " | ||
2327 | "parameter (%d) to auto (0).\n", | ||
2328 | phba->brd_no, lpfc_sli_mode); | ||
2329 | break; | ||
1967 | } | 2330 | } |
2331 | mode = 2; | ||
2332 | break; | ||
2333 | case 0: | ||
2334 | case 3: | ||
2335 | break; | ||
2336 | default: | ||
2337 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, | ||
2338 | "%d:1819 Unrecognized lpfc_sli_mode " | ||
2339 | "parameter: %d.\n", | ||
2340 | phba->brd_no, lpfc_sli_mode); | ||
2341 | |||
2342 | break; | ||
1968 | } | 2343 | } |
1969 | if (!done) | 2344 | |
2345 | rc = lpfc_do_config_port(phba, mode); | ||
2346 | if (rc && lpfc_sli_mode == 3) | ||
2347 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, | ||
2348 | "%d:1820 Unable to select SLI-3. " | ||
2349 | "Not supported by adapter.\n", | ||
2350 | phba->brd_no); | ||
2351 | if (rc && mode != 2) | ||
2352 | rc = lpfc_do_config_port(phba, 2); | ||
2353 | if (rc) | ||
1970 | goto lpfc_sli_hba_setup_error; | 2354 | goto lpfc_sli_hba_setup_error; |
1971 | 2355 | ||
1972 | rc = lpfc_sli_ring_map(phba, pmb); | 2356 | if (phba->sli_rev == 3) { |
2357 | phba->iocb_cmd_size = SLI3_IOCB_CMD_SIZE; | ||
2358 | phba->iocb_rsp_size = SLI3_IOCB_RSP_SIZE; | ||
2359 | phba->sli3_options |= LPFC_SLI3_ENABLED; | ||
2360 | phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED; | ||
2361 | |||
2362 | } else { | ||
2363 | phba->iocb_cmd_size = SLI2_IOCB_CMD_SIZE; | ||
2364 | phba->iocb_rsp_size = SLI2_IOCB_RSP_SIZE; | ||
2365 | phba->sli3_options = 0; | ||
2366 | } | ||
2367 | |||
2368 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | ||
2369 | "%d:0444 Firmware in SLI %x mode. Max_vpi %d\n", | ||
2370 | phba->brd_no, phba->sli_rev, phba->max_vpi); | ||
2371 | rc = lpfc_sli_ring_map(phba); | ||
1973 | 2372 | ||
1974 | if (rc) | 2373 | if (rc) |
1975 | goto lpfc_sli_hba_setup_error; | 2374 | goto lpfc_sli_hba_setup_error; |
1976 | 2375 | ||
2376 | /* Init HBQs */ | ||
2377 | |||
2378 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { | ||
2379 | rc = lpfc_sli_hbq_setup(phba); | ||
2380 | if (rc) | ||
2381 | goto lpfc_sli_hba_setup_error; | ||
2382 | } | ||
2383 | |||
1977 | phba->sli.sli_flag |= LPFC_PROCESS_LA; | 2384 | phba->sli.sli_flag |= LPFC_PROCESS_LA; |
1978 | 2385 | ||
1979 | rc = lpfc_config_port_post(phba); | 2386 | rc = lpfc_config_port_post(phba); |
1980 | if (rc) | 2387 | if (rc) |
1981 | goto lpfc_sli_hba_setup_error; | 2388 | goto lpfc_sli_hba_setup_error; |
1982 | 2389 | ||
1983 | goto lpfc_sli_hba_setup_exit; | 2390 | return rc; |
2391 | |||
1984 | lpfc_sli_hba_setup_error: | 2392 | lpfc_sli_hba_setup_error: |
1985 | phba->hba_state = LPFC_HBA_ERROR; | 2393 | phba->link_state = LPFC_HBA_ERROR; |
1986 | lpfc_sli_hba_setup_exit: | 2394 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
1987 | mempool_free(pmb, phba->mbox_mem_pool); | 2395 | "%d:0445 Firmware initialization failed\n", |
2396 | phba->brd_no); | ||
1988 | return rc; | 2397 | return rc; |
1989 | } | 2398 | } |
1990 | 2399 | ||
@@ -2004,56 +2413,58 @@ lpfc_sli_hba_setup_exit: | |||
2004 | void | 2413 | void |
2005 | lpfc_mbox_timeout(unsigned long ptr) | 2414 | lpfc_mbox_timeout(unsigned long ptr) |
2006 | { | 2415 | { |
2007 | struct lpfc_hba *phba; | 2416 | struct lpfc_hba *phba = (struct lpfc_hba *) ptr; |
2008 | unsigned long iflag; | 2417 | unsigned long iflag; |
2418 | uint32_t tmo_posted; | ||
2009 | 2419 | ||
2010 | phba = (struct lpfc_hba *)ptr; | 2420 | spin_lock_irqsave(&phba->pport->work_port_lock, iflag); |
2011 | spin_lock_irqsave(phba->host->host_lock, iflag); | 2421 | tmo_posted = phba->pport->work_port_events & WORKER_MBOX_TMO; |
2012 | if (!(phba->work_hba_events & WORKER_MBOX_TMO)) { | 2422 | if (!tmo_posted) |
2013 | phba->work_hba_events |= WORKER_MBOX_TMO; | 2423 | phba->pport->work_port_events |= WORKER_MBOX_TMO; |
2424 | spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); | ||
2425 | |||
2426 | if (!tmo_posted) { | ||
2427 | spin_lock_irqsave(&phba->hbalock, iflag); | ||
2014 | if (phba->work_wait) | 2428 | if (phba->work_wait) |
2015 | wake_up(phba->work_wait); | 2429 | lpfc_worker_wake_up(phba); |
2430 | spin_unlock_irqrestore(&phba->hbalock, iflag); | ||
2016 | } | 2431 | } |
2017 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | ||
2018 | } | 2432 | } |
2019 | 2433 | ||
2020 | void | 2434 | void |
2021 | lpfc_mbox_timeout_handler(struct lpfc_hba *phba) | 2435 | lpfc_mbox_timeout_handler(struct lpfc_hba *phba) |
2022 | { | 2436 | { |
2023 | LPFC_MBOXQ_t *pmbox; | 2437 | LPFC_MBOXQ_t *pmbox = phba->sli.mbox_active; |
2024 | MAILBOX_t *mb; | 2438 | MAILBOX_t *mb = &pmbox->mb; |
2025 | struct lpfc_sli *psli = &phba->sli; | 2439 | struct lpfc_sli *psli = &phba->sli; |
2026 | struct lpfc_sli_ring *pring; | 2440 | struct lpfc_sli_ring *pring; |
2027 | 2441 | ||
2028 | spin_lock_irq(phba->host->host_lock); | 2442 | if (!(phba->pport->work_port_events & WORKER_MBOX_TMO)) { |
2029 | if (!(phba->work_hba_events & WORKER_MBOX_TMO)) { | ||
2030 | spin_unlock_irq(phba->host->host_lock); | ||
2031 | return; | 2443 | return; |
2032 | } | 2444 | } |
2033 | 2445 | ||
2034 | pmbox = phba->sli.mbox_active; | ||
2035 | mb = &pmbox->mb; | ||
2036 | |||
2037 | /* Mbox cmd <mbxCommand> timeout */ | 2446 | /* Mbox cmd <mbxCommand> timeout */ |
2038 | lpfc_printf_log(phba, | 2447 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
2039 | KERN_ERR, | 2448 | "%d:0310 Mailbox command x%x timeout Data: x%x x%x " |
2040 | LOG_MBOX | LOG_SLI, | 2449 | "x%p\n", |
2041 | "%d:0310 Mailbox command x%x timeout Data: x%x x%x x%p\n", | 2450 | phba->brd_no, |
2042 | phba->brd_no, | 2451 | mb->mbxCommand, |
2043 | mb->mbxCommand, | 2452 | phba->pport->port_state, |
2044 | phba->hba_state, | 2453 | phba->sli.sli_flag, |
2045 | phba->sli.sli_flag, | 2454 | phba->sli.mbox_active); |
2046 | phba->sli.mbox_active); | ||
2047 | 2455 | ||
2048 | /* Setting state unknown so lpfc_sli_abort_iocb_ring | 2456 | /* Setting state unknown so lpfc_sli_abort_iocb_ring |
2049 | * would get IOCB_ERROR from lpfc_sli_issue_iocb, allowing | 2457 | * would get IOCB_ERROR from lpfc_sli_issue_iocb, allowing |
2050 | * it to fail all oustanding SCSI IO. | 2458 | * it to fail all oustanding SCSI IO. |
2051 | */ | 2459 | */ |
2052 | phba->hba_state = LPFC_STATE_UNKNOWN; | 2460 | spin_lock_irq(&phba->pport->work_port_lock); |
2053 | phba->work_hba_events &= ~WORKER_MBOX_TMO; | 2461 | phba->pport->work_port_events &= ~WORKER_MBOX_TMO; |
2054 | phba->fc_flag |= FC_ESTABLISH_LINK; | 2462 | spin_unlock_irq(&phba->pport->work_port_lock); |
2463 | spin_lock_irq(&phba->hbalock); | ||
2464 | phba->link_state = LPFC_LINK_UNKNOWN; | ||
2465 | phba->pport->fc_flag |= FC_ESTABLISH_LINK; | ||
2055 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | 2466 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; |
2056 | spin_unlock_irq(phba->host->host_lock); | 2467 | spin_unlock_irq(&phba->hbalock); |
2057 | 2468 | ||
2058 | pring = &psli->ring[psli->fcp_ring]; | 2469 | pring = &psli->ring[psli->fcp_ring]; |
2059 | lpfc_sli_abort_iocb_ring(phba, pring); | 2470 | lpfc_sli_abort_iocb_ring(phba, pring); |
@@ -2075,10 +2486,10 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba) | |||
2075 | } | 2486 | } |
2076 | 2487 | ||
2077 | int | 2488 | int |
2078 | lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | 2489 | lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag) |
2079 | { | 2490 | { |
2080 | MAILBOX_t *mb; | 2491 | MAILBOX_t *mb; |
2081 | struct lpfc_sli *psli; | 2492 | struct lpfc_sli *psli = &phba->sli; |
2082 | uint32_t status, evtctr; | 2493 | uint32_t status, evtctr; |
2083 | uint32_t ha_copy; | 2494 | uint32_t ha_copy; |
2084 | int i; | 2495 | int i; |
@@ -2086,31 +2497,44 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2086 | volatile uint32_t word0, ldata; | 2497 | volatile uint32_t word0, ldata; |
2087 | void __iomem *to_slim; | 2498 | void __iomem *to_slim; |
2088 | 2499 | ||
2500 | if (pmbox->mbox_cmpl && pmbox->mbox_cmpl != lpfc_sli_def_mbox_cmpl && | ||
2501 | pmbox->mbox_cmpl != lpfc_sli_wake_mbox_wait) { | ||
2502 | if(!pmbox->vport) { | ||
2503 | lpfc_printf_log(phba, KERN_ERR, | ||
2504 | LOG_MBOX | LOG_VPORT, | ||
2505 | "%d:1806 Mbox x%x failed. No vport\n", | ||
2506 | phba->brd_no, | ||
2507 | pmbox->mb.mbxCommand); | ||
2508 | dump_stack(); | ||
2509 | return MBXERR_ERROR; | ||
2510 | } | ||
2511 | } | ||
2512 | |||
2513 | |||
2089 | /* If the PCI channel is in offline state, do not post mbox. */ | 2514 | /* If the PCI channel is in offline state, do not post mbox. */ |
2090 | if (unlikely(pci_channel_offline(phba->pcidev))) | 2515 | if (unlikely(pci_channel_offline(phba->pcidev))) |
2091 | return MBX_NOT_FINISHED; | 2516 | return MBX_NOT_FINISHED; |
2092 | 2517 | ||
2518 | spin_lock_irqsave(&phba->hbalock, drvr_flag); | ||
2093 | psli = &phba->sli; | 2519 | psli = &phba->sli; |
2094 | 2520 | ||
2095 | spin_lock_irqsave(phba->host->host_lock, drvr_flag); | ||
2096 | |||
2097 | 2521 | ||
2098 | mb = &pmbox->mb; | 2522 | mb = &pmbox->mb; |
2099 | status = MBX_SUCCESS; | 2523 | status = MBX_SUCCESS; |
2100 | 2524 | ||
2101 | if (phba->hba_state == LPFC_HBA_ERROR) { | 2525 | if (phba->link_state == LPFC_HBA_ERROR) { |
2102 | spin_unlock_irqrestore(phba->host->host_lock, drvr_flag); | 2526 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2103 | 2527 | ||
2104 | /* Mbox command <mbxCommand> cannot issue */ | 2528 | /* Mbox command <mbxCommand> cannot issue */ |
2105 | LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) | 2529 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag) |
2106 | return (MBX_NOT_FINISHED); | 2530 | return MBX_NOT_FINISHED; |
2107 | } | 2531 | } |
2108 | 2532 | ||
2109 | if (mb->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT && | 2533 | if (mb->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT && |
2110 | !(readl(phba->HCregaddr) & HC_MBINT_ENA)) { | 2534 | !(readl(phba->HCregaddr) & HC_MBINT_ENA)) { |
2111 | spin_unlock_irqrestore(phba->host->host_lock, drvr_flag); | 2535 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2112 | LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) | 2536 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag) |
2113 | return (MBX_NOT_FINISHED); | 2537 | return MBX_NOT_FINISHED; |
2114 | } | 2538 | } |
2115 | 2539 | ||
2116 | if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { | 2540 | if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { |
@@ -2120,20 +2544,18 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2120 | */ | 2544 | */ |
2121 | 2545 | ||
2122 | if (flag & MBX_POLL) { | 2546 | if (flag & MBX_POLL) { |
2123 | spin_unlock_irqrestore(phba->host->host_lock, | 2547 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2124 | drvr_flag); | ||
2125 | 2548 | ||
2126 | /* Mbox command <mbxCommand> cannot issue */ | 2549 | /* Mbox command <mbxCommand> cannot issue */ |
2127 | LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) | 2550 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag); |
2128 | return (MBX_NOT_FINISHED); | 2551 | return MBX_NOT_FINISHED; |
2129 | } | 2552 | } |
2130 | 2553 | ||
2131 | if (!(psli->sli_flag & LPFC_SLI2_ACTIVE)) { | 2554 | if (!(psli->sli_flag & LPFC_SLI2_ACTIVE)) { |
2132 | spin_unlock_irqrestore(phba->host->host_lock, | 2555 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2133 | drvr_flag); | ||
2134 | /* Mbox command <mbxCommand> cannot issue */ | 2556 | /* Mbox command <mbxCommand> cannot issue */ |
2135 | LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) | 2557 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag); |
2136 | return (MBX_NOT_FINISHED); | 2558 | return MBX_NOT_FINISHED; |
2137 | } | 2559 | } |
2138 | 2560 | ||
2139 | /* Handle STOP IOCB processing flag. This is only meaningful | 2561 | /* Handle STOP IOCB processing flag. This is only meaningful |
@@ -2157,21 +2579,33 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2157 | lpfc_mbox_put(phba, pmbox); | 2579 | lpfc_mbox_put(phba, pmbox); |
2158 | 2580 | ||
2159 | /* Mbox cmd issue - BUSY */ | 2581 | /* Mbox cmd issue - BUSY */ |
2160 | lpfc_printf_log(phba, | 2582 | lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, |
2161 | KERN_INFO, | 2583 | "%d (%d):0308 Mbox cmd issue - BUSY Data: " |
2162 | LOG_MBOX | LOG_SLI, | 2584 | "x%x x%x x%x x%x\n", |
2163 | "%d:0308 Mbox cmd issue - BUSY Data: x%x x%x x%x x%x\n", | 2585 | phba->brd_no, |
2164 | phba->brd_no, | 2586 | pmbox->vport ? pmbox->vport->vpi : 0xffffff, |
2165 | mb->mbxCommand, | 2587 | mb->mbxCommand, phba->pport->port_state, |
2166 | phba->hba_state, | 2588 | psli->sli_flag, flag); |
2167 | psli->sli_flag, | ||
2168 | flag); | ||
2169 | 2589 | ||
2170 | psli->slistat.mbox_busy++; | 2590 | psli->slistat.mbox_busy++; |
2171 | spin_unlock_irqrestore(phba->host->host_lock, | 2591 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2172 | drvr_flag); | 2592 | |
2593 | if (pmbox->vport) { | ||
2594 | lpfc_debugfs_disc_trc(pmbox->vport, | ||
2595 | LPFC_DISC_TRC_MBOX_VPORT, | ||
2596 | "MBOX Bsy vport: cmd:x%x mb:x%x x%x", | ||
2597 | (uint32_t)mb->mbxCommand, | ||
2598 | mb->un.varWords[0], mb->un.varWords[1]); | ||
2599 | } | ||
2600 | else { | ||
2601 | lpfc_debugfs_disc_trc(phba->pport, | ||
2602 | LPFC_DISC_TRC_MBOX, | ||
2603 | "MBOX Bsy: cmd:x%x mb:x%x x%x", | ||
2604 | (uint32_t)mb->mbxCommand, | ||
2605 | mb->un.varWords[0], mb->un.varWords[1]); | ||
2606 | } | ||
2173 | 2607 | ||
2174 | return (MBX_BUSY); | 2608 | return MBX_BUSY; |
2175 | } | 2609 | } |
2176 | 2610 | ||
2177 | /* Handle STOP IOCB processing flag. This is only meaningful | 2611 | /* Handle STOP IOCB processing flag. This is only meaningful |
@@ -2198,11 +2632,10 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2198 | if (!(psli->sli_flag & LPFC_SLI2_ACTIVE) && | 2632 | if (!(psli->sli_flag & LPFC_SLI2_ACTIVE) && |
2199 | (mb->mbxCommand != MBX_KILL_BOARD)) { | 2633 | (mb->mbxCommand != MBX_KILL_BOARD)) { |
2200 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | 2634 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; |
2201 | spin_unlock_irqrestore(phba->host->host_lock, | 2635 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2202 | drvr_flag); | ||
2203 | /* Mbox command <mbxCommand> cannot issue */ | 2636 | /* Mbox command <mbxCommand> cannot issue */ |
2204 | LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag); | 2637 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag); |
2205 | return (MBX_NOT_FINISHED); | 2638 | return MBX_NOT_FINISHED; |
2206 | } | 2639 | } |
2207 | /* timeout active mbox command */ | 2640 | /* timeout active mbox command */ |
2208 | mod_timer(&psli->mbox_tmo, (jiffies + | 2641 | mod_timer(&psli->mbox_tmo, (jiffies + |
@@ -2210,15 +2643,29 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2210 | } | 2643 | } |
2211 | 2644 | ||
2212 | /* Mailbox cmd <cmd> issue */ | 2645 | /* Mailbox cmd <cmd> issue */ |
2213 | lpfc_printf_log(phba, | 2646 | lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, |
2214 | KERN_INFO, | 2647 | "%d (%d):0309 Mailbox cmd x%x issue Data: x%x x%x " |
2215 | LOG_MBOX | LOG_SLI, | 2648 | "x%x\n", |
2216 | "%d:0309 Mailbox cmd x%x issue Data: x%x x%x x%x\n", | 2649 | phba->brd_no, pmbox->vport ? pmbox->vport->vpi : 0, |
2217 | phba->brd_no, | 2650 | mb->mbxCommand, phba->pport->port_state, |
2218 | mb->mbxCommand, | 2651 | psli->sli_flag, flag); |
2219 | phba->hba_state, | 2652 | |
2220 | psli->sli_flag, | 2653 | if (mb->mbxCommand != MBX_HEARTBEAT) { |
2221 | flag); | 2654 | if (pmbox->vport) { |
2655 | lpfc_debugfs_disc_trc(pmbox->vport, | ||
2656 | LPFC_DISC_TRC_MBOX_VPORT, | ||
2657 | "MBOX Send vport: cmd:x%x mb:x%x x%x", | ||
2658 | (uint32_t)mb->mbxCommand, | ||
2659 | mb->un.varWords[0], mb->un.varWords[1]); | ||
2660 | } | ||
2661 | else { | ||
2662 | lpfc_debugfs_disc_trc(phba->pport, | ||
2663 | LPFC_DISC_TRC_MBOX, | ||
2664 | "MBOX Send: cmd:x%x mb:x%x x%x", | ||
2665 | (uint32_t)mb->mbxCommand, | ||
2666 | mb->un.varWords[0], mb->un.varWords[1]); | ||
2667 | } | ||
2668 | } | ||
2222 | 2669 | ||
2223 | psli->slistat.mbox_cmd++; | 2670 | psli->slistat.mbox_cmd++; |
2224 | evtctr = psli->slistat.mbox_event; | 2671 | evtctr = psli->slistat.mbox_event; |
@@ -2233,7 +2680,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2233 | if (mb->mbxCommand == MBX_CONFIG_PORT) { | 2680 | if (mb->mbxCommand == MBX_CONFIG_PORT) { |
2234 | /* copy command data into host mbox for cmpl */ | 2681 | /* copy command data into host mbox for cmpl */ |
2235 | lpfc_sli_pcimem_bcopy(mb, &phba->slim2p->mbx, | 2682 | lpfc_sli_pcimem_bcopy(mb, &phba->slim2p->mbx, |
2236 | MAILBOX_CMD_SIZE); | 2683 | MAILBOX_CMD_SIZE); |
2237 | } | 2684 | } |
2238 | 2685 | ||
2239 | /* First copy mbox command data to HBA SLIM, skip past first | 2686 | /* First copy mbox command data to HBA SLIM, skip past first |
@@ -2285,12 +2732,12 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2285 | /* Wait for command to complete */ | 2732 | /* Wait for command to complete */ |
2286 | while (((word0 & OWN_CHIP) == OWN_CHIP) || | 2733 | while (((word0 & OWN_CHIP) == OWN_CHIP) || |
2287 | (!(ha_copy & HA_MBATT) && | 2734 | (!(ha_copy & HA_MBATT) && |
2288 | (phba->hba_state > LPFC_WARM_START))) { | 2735 | (phba->link_state > LPFC_WARM_START))) { |
2289 | if (i-- <= 0) { | 2736 | if (i-- <= 0) { |
2290 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | 2737 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; |
2291 | spin_unlock_irqrestore(phba->host->host_lock, | 2738 | spin_unlock_irqrestore(&phba->hbalock, |
2292 | drvr_flag); | 2739 | drvr_flag); |
2293 | return (MBX_NOT_FINISHED); | 2740 | return MBX_NOT_FINISHED; |
2294 | } | 2741 | } |
2295 | 2742 | ||
2296 | /* Check if we took a mbox interrupt while we were | 2743 | /* Check if we took a mbox interrupt while we were |
@@ -2299,12 +2746,12 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2299 | && (evtctr != psli->slistat.mbox_event)) | 2746 | && (evtctr != psli->slistat.mbox_event)) |
2300 | break; | 2747 | break; |
2301 | 2748 | ||
2302 | spin_unlock_irqrestore(phba->host->host_lock, | 2749 | spin_unlock_irqrestore(&phba->hbalock, |
2303 | drvr_flag); | 2750 | drvr_flag); |
2304 | 2751 | ||
2305 | msleep(1); | 2752 | msleep(1); |
2306 | 2753 | ||
2307 | spin_lock_irqsave(phba->host->host_lock, drvr_flag); | 2754 | spin_lock_irqsave(&phba->hbalock, drvr_flag); |
2308 | 2755 | ||
2309 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) { | 2756 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) { |
2310 | /* First copy command data */ | 2757 | /* First copy command data */ |
@@ -2335,7 +2782,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2335 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) { | 2782 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) { |
2336 | /* copy results back to user */ | 2783 | /* copy results back to user */ |
2337 | lpfc_sli_pcimem_bcopy(&phba->slim2p->mbx, mb, | 2784 | lpfc_sli_pcimem_bcopy(&phba->slim2p->mbx, mb, |
2338 | MAILBOX_CMD_SIZE); | 2785 | MAILBOX_CMD_SIZE); |
2339 | } else { | 2786 | } else { |
2340 | /* First copy command data */ | 2787 | /* First copy command data */ |
2341 | lpfc_memcpy_from_slim(mb, phba->MBslimaddr, | 2788 | lpfc_memcpy_from_slim(mb, phba->MBslimaddr, |
@@ -2355,23 +2802,25 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2355 | status = mb->mbxStatus; | 2802 | status = mb->mbxStatus; |
2356 | } | 2803 | } |
2357 | 2804 | ||
2358 | spin_unlock_irqrestore(phba->host->host_lock, drvr_flag); | 2805 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2359 | return (status); | 2806 | return status; |
2360 | } | 2807 | } |
2361 | 2808 | ||
2362 | static int | 2809 | /* |
2363 | lpfc_sli_ringtx_put(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, | 2810 | * Caller needs to hold lock. |
2364 | struct lpfc_iocbq * piocb) | 2811 | */ |
2812 | static void | ||
2813 | __lpfc_sli_ringtx_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | ||
2814 | struct lpfc_iocbq *piocb) | ||
2365 | { | 2815 | { |
2366 | /* Insert the caller's iocb in the txq tail for later processing. */ | 2816 | /* Insert the caller's iocb in the txq tail for later processing. */ |
2367 | list_add_tail(&piocb->list, &pring->txq); | 2817 | list_add_tail(&piocb->list, &pring->txq); |
2368 | pring->txq_cnt++; | 2818 | pring->txq_cnt++; |
2369 | return (0); | ||
2370 | } | 2819 | } |
2371 | 2820 | ||
2372 | static struct lpfc_iocbq * | 2821 | static struct lpfc_iocbq * |
2373 | lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 2822 | lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
2374 | struct lpfc_iocbq ** piocb) | 2823 | struct lpfc_iocbq **piocb) |
2375 | { | 2824 | { |
2376 | struct lpfc_iocbq * nextiocb; | 2825 | struct lpfc_iocbq * nextiocb; |
2377 | 2826 | ||
@@ -2384,13 +2833,29 @@ lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2384 | return nextiocb; | 2833 | return nextiocb; |
2385 | } | 2834 | } |
2386 | 2835 | ||
2836 | /* | ||
2837 | * Lockless version of lpfc_sli_issue_iocb. | ||
2838 | */ | ||
2387 | int | 2839 | int |
2388 | lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 2840 | __lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
2389 | struct lpfc_iocbq *piocb, uint32_t flag) | 2841 | struct lpfc_iocbq *piocb, uint32_t flag) |
2390 | { | 2842 | { |
2391 | struct lpfc_iocbq *nextiocb; | 2843 | struct lpfc_iocbq *nextiocb; |
2392 | IOCB_t *iocb; | 2844 | IOCB_t *iocb; |
2393 | 2845 | ||
2846 | if (piocb->iocb_cmpl && (!piocb->vport) && | ||
2847 | (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && | ||
2848 | (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) { | ||
2849 | lpfc_printf_log(phba, KERN_ERR, | ||
2850 | LOG_SLI | LOG_VPORT, | ||
2851 | "%d:1807 IOCB x%x failed. No vport\n", | ||
2852 | phba->brd_no, | ||
2853 | piocb->iocb.ulpCommand); | ||
2854 | dump_stack(); | ||
2855 | return IOCB_ERROR; | ||
2856 | } | ||
2857 | |||
2858 | |||
2394 | /* If the PCI channel is in offline state, do not post iocbs. */ | 2859 | /* If the PCI channel is in offline state, do not post iocbs. */ |
2395 | if (unlikely(pci_channel_offline(phba->pcidev))) | 2860 | if (unlikely(pci_channel_offline(phba->pcidev))) |
2396 | return IOCB_ERROR; | 2861 | return IOCB_ERROR; |
@@ -2398,7 +2863,7 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2398 | /* | 2863 | /* |
2399 | * We should never get an IOCB if we are in a < LINK_DOWN state | 2864 | * We should never get an IOCB if we are in a < LINK_DOWN state |
2400 | */ | 2865 | */ |
2401 | if (unlikely(phba->hba_state < LPFC_LINK_DOWN)) | 2866 | if (unlikely(phba->link_state < LPFC_LINK_DOWN)) |
2402 | return IOCB_ERROR; | 2867 | return IOCB_ERROR; |
2403 | 2868 | ||
2404 | /* | 2869 | /* |
@@ -2408,7 +2873,7 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2408 | if (unlikely(pring->flag & LPFC_STOP_IOCB_MBX)) | 2873 | if (unlikely(pring->flag & LPFC_STOP_IOCB_MBX)) |
2409 | goto iocb_busy; | 2874 | goto iocb_busy; |
2410 | 2875 | ||
2411 | if (unlikely(phba->hba_state == LPFC_LINK_DOWN)) { | 2876 | if (unlikely(phba->link_state == LPFC_LINK_DOWN)) { |
2412 | /* | 2877 | /* |
2413 | * Only CREATE_XRI, CLOSE_XRI, and QUE_RING_BUF | 2878 | * Only CREATE_XRI, CLOSE_XRI, and QUE_RING_BUF |
2414 | * can be issued if the link is not up. | 2879 | * can be issued if the link is not up. |
@@ -2436,8 +2901,9 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2436 | * attention events. | 2901 | * attention events. |
2437 | */ | 2902 | */ |
2438 | } else if (unlikely(pring->ringno == phba->sli.fcp_ring && | 2903 | } else if (unlikely(pring->ringno == phba->sli.fcp_ring && |
2439 | !(phba->sli.sli_flag & LPFC_PROCESS_LA))) | 2904 | !(phba->sli.sli_flag & LPFC_PROCESS_LA))) { |
2440 | goto iocb_busy; | 2905 | goto iocb_busy; |
2906 | } | ||
2441 | 2907 | ||
2442 | while ((iocb = lpfc_sli_next_iocb_slot(phba, pring)) && | 2908 | while ((iocb = lpfc_sli_next_iocb_slot(phba, pring)) && |
2443 | (nextiocb = lpfc_sli_next_iocb(phba, pring, &piocb))) | 2909 | (nextiocb = lpfc_sli_next_iocb(phba, pring, &piocb))) |
@@ -2459,13 +2925,28 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2459 | out_busy: | 2925 | out_busy: |
2460 | 2926 | ||
2461 | if (!(flag & SLI_IOCB_RET_IOCB)) { | 2927 | if (!(flag & SLI_IOCB_RET_IOCB)) { |
2462 | lpfc_sli_ringtx_put(phba, pring, piocb); | 2928 | __lpfc_sli_ringtx_put(phba, pring, piocb); |
2463 | return IOCB_SUCCESS; | 2929 | return IOCB_SUCCESS; |
2464 | } | 2930 | } |
2465 | 2931 | ||
2466 | return IOCB_BUSY; | 2932 | return IOCB_BUSY; |
2467 | } | 2933 | } |
2468 | 2934 | ||
2935 | |||
2936 | int | ||
2937 | lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | ||
2938 | struct lpfc_iocbq *piocb, uint32_t flag) | ||
2939 | { | ||
2940 | unsigned long iflags; | ||
2941 | int rc; | ||
2942 | |||
2943 | spin_lock_irqsave(&phba->hbalock, iflags); | ||
2944 | rc = __lpfc_sli_issue_iocb(phba, pring, piocb, flag); | ||
2945 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
2946 | |||
2947 | return rc; | ||
2948 | } | ||
2949 | |||
2469 | static int | 2950 | static int |
2470 | lpfc_extra_ring_setup( struct lpfc_hba *phba) | 2951 | lpfc_extra_ring_setup( struct lpfc_hba *phba) |
2471 | { | 2952 | { |
@@ -2504,7 +2985,7 @@ lpfc_extra_ring_setup( struct lpfc_hba *phba) | |||
2504 | int | 2985 | int |
2505 | lpfc_sli_setup(struct lpfc_hba *phba) | 2986 | lpfc_sli_setup(struct lpfc_hba *phba) |
2506 | { | 2987 | { |
2507 | int i, totiocb = 0; | 2988 | int i, totiocbsize = 0; |
2508 | struct lpfc_sli *psli = &phba->sli; | 2989 | struct lpfc_sli *psli = &phba->sli; |
2509 | struct lpfc_sli_ring *pring; | 2990 | struct lpfc_sli_ring *pring; |
2510 | 2991 | ||
@@ -2529,6 +3010,12 @@ lpfc_sli_setup(struct lpfc_hba *phba) | |||
2529 | pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; | 3010 | pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; |
2530 | pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; | 3011 | pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; |
2531 | pring->numRiocb += SLI2_IOCB_RSP_R3XTRA_ENTRIES; | 3012 | pring->numRiocb += SLI2_IOCB_RSP_R3XTRA_ENTRIES; |
3013 | pring->sizeCiocb = (phba->sli_rev == 3) ? | ||
3014 | SLI3_IOCB_CMD_SIZE : | ||
3015 | SLI2_IOCB_CMD_SIZE; | ||
3016 | pring->sizeRiocb = (phba->sli_rev == 3) ? | ||
3017 | SLI3_IOCB_RSP_SIZE : | ||
3018 | SLI2_IOCB_RSP_SIZE; | ||
2532 | pring->iotag_ctr = 0; | 3019 | pring->iotag_ctr = 0; |
2533 | pring->iotag_max = | 3020 | pring->iotag_max = |
2534 | (phba->cfg_hba_queue_depth * 2); | 3021 | (phba->cfg_hba_queue_depth * 2); |
@@ -2539,12 +3026,25 @@ lpfc_sli_setup(struct lpfc_hba *phba) | |||
2539 | /* numCiocb and numRiocb are used in config_port */ | 3026 | /* numCiocb and numRiocb are used in config_port */ |
2540 | pring->numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; | 3027 | pring->numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; |
2541 | pring->numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; | 3028 | pring->numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; |
3029 | pring->sizeCiocb = (phba->sli_rev == 3) ? | ||
3030 | SLI3_IOCB_CMD_SIZE : | ||
3031 | SLI2_IOCB_CMD_SIZE; | ||
3032 | pring->sizeRiocb = (phba->sli_rev == 3) ? | ||
3033 | SLI3_IOCB_RSP_SIZE : | ||
3034 | SLI2_IOCB_RSP_SIZE; | ||
3035 | pring->iotag_max = phba->cfg_hba_queue_depth; | ||
2542 | pring->num_mask = 0; | 3036 | pring->num_mask = 0; |
2543 | break; | 3037 | break; |
2544 | case LPFC_ELS_RING: /* ring 2 - ELS / CT */ | 3038 | case LPFC_ELS_RING: /* ring 2 - ELS / CT */ |
2545 | /* numCiocb and numRiocb are used in config_port */ | 3039 | /* numCiocb and numRiocb are used in config_port */ |
2546 | pring->numCiocb = SLI2_IOCB_CMD_R2_ENTRIES; | 3040 | pring->numCiocb = SLI2_IOCB_CMD_R2_ENTRIES; |
2547 | pring->numRiocb = SLI2_IOCB_RSP_R2_ENTRIES; | 3041 | pring->numRiocb = SLI2_IOCB_RSP_R2_ENTRIES; |
3042 | pring->sizeCiocb = (phba->sli_rev == 3) ? | ||
3043 | SLI3_IOCB_CMD_SIZE : | ||
3044 | SLI2_IOCB_CMD_SIZE; | ||
3045 | pring->sizeRiocb = (phba->sli_rev == 3) ? | ||
3046 | SLI3_IOCB_RSP_SIZE : | ||
3047 | SLI2_IOCB_RSP_SIZE; | ||
2548 | pring->fast_iotag = 0; | 3048 | pring->fast_iotag = 0; |
2549 | pring->iotag_ctr = 0; | 3049 | pring->iotag_ctr = 0; |
2550 | pring->iotag_max = 4096; | 3050 | pring->iotag_max = 4096; |
@@ -2575,14 +3075,16 @@ lpfc_sli_setup(struct lpfc_hba *phba) | |||
2575 | lpfc_ct_unsol_event; | 3075 | lpfc_ct_unsol_event; |
2576 | break; | 3076 | break; |
2577 | } | 3077 | } |
2578 | totiocb += (pring->numCiocb + pring->numRiocb); | 3078 | totiocbsize += (pring->numCiocb * pring->sizeCiocb) + |
3079 | (pring->numRiocb * pring->sizeRiocb); | ||
2579 | } | 3080 | } |
2580 | if (totiocb > MAX_SLI2_IOCB) { | 3081 | if (totiocbsize > MAX_SLIM_IOCB_SIZE) { |
2581 | /* Too many cmd / rsp ring entries in SLI2 SLIM */ | 3082 | /* Too many cmd / rsp ring entries in SLI2 SLIM */ |
2582 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 3083 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
2583 | "%d:0462 Too many cmd / rsp ring entries in " | 3084 | "%d:0462 Too many cmd / rsp ring entries in " |
2584 | "SLI2 SLIM Data: x%x x%x\n", | 3085 | "SLI2 SLIM Data: x%x x%lx\n", |
2585 | phba->brd_no, totiocb, MAX_SLI2_IOCB); | 3086 | phba->brd_no, totiocbsize, |
3087 | (unsigned long) MAX_SLIM_IOCB_SIZE); | ||
2586 | } | 3088 | } |
2587 | if (phba->cfg_multi_ring_support == 2) | 3089 | if (phba->cfg_multi_ring_support == 2) |
2588 | lpfc_extra_ring_setup(phba); | 3090 | lpfc_extra_ring_setup(phba); |
@@ -2591,15 +3093,16 @@ lpfc_sli_setup(struct lpfc_hba *phba) | |||
2591 | } | 3093 | } |
2592 | 3094 | ||
2593 | int | 3095 | int |
2594 | lpfc_sli_queue_setup(struct lpfc_hba * phba) | 3096 | lpfc_sli_queue_setup(struct lpfc_hba *phba) |
2595 | { | 3097 | { |
2596 | struct lpfc_sli *psli; | 3098 | struct lpfc_sli *psli; |
2597 | struct lpfc_sli_ring *pring; | 3099 | struct lpfc_sli_ring *pring; |
2598 | int i; | 3100 | int i; |
2599 | 3101 | ||
2600 | psli = &phba->sli; | 3102 | psli = &phba->sli; |
2601 | spin_lock_irq(phba->host->host_lock); | 3103 | spin_lock_irq(&phba->hbalock); |
2602 | INIT_LIST_HEAD(&psli->mboxq); | 3104 | INIT_LIST_HEAD(&psli->mboxq); |
3105 | INIT_LIST_HEAD(&psli->mboxq_cmpl); | ||
2603 | /* Initialize list headers for txq and txcmplq as double linked lists */ | 3106 | /* Initialize list headers for txq and txcmplq as double linked lists */ |
2604 | for (i = 0; i < psli->num_rings; i++) { | 3107 | for (i = 0; i < psli->num_rings; i++) { |
2605 | pring = &psli->ring[i]; | 3108 | pring = &psli->ring[i]; |
@@ -2612,15 +3115,73 @@ lpfc_sli_queue_setup(struct lpfc_hba * phba) | |||
2612 | INIT_LIST_HEAD(&pring->iocb_continueq); | 3115 | INIT_LIST_HEAD(&pring->iocb_continueq); |
2613 | INIT_LIST_HEAD(&pring->postbufq); | 3116 | INIT_LIST_HEAD(&pring->postbufq); |
2614 | } | 3117 | } |
2615 | spin_unlock_irq(phba->host->host_lock); | 3118 | spin_unlock_irq(&phba->hbalock); |
2616 | return (1); | 3119 | return 1; |
2617 | } | 3120 | } |
2618 | 3121 | ||
2619 | int | 3122 | int |
2620 | lpfc_sli_hba_down(struct lpfc_hba * phba) | 3123 | lpfc_sli_host_down(struct lpfc_vport *vport) |
2621 | { | 3124 | { |
2622 | LIST_HEAD(completions); | 3125 | LIST_HEAD(completions); |
2623 | struct lpfc_sli *psli; | 3126 | struct lpfc_hba *phba = vport->phba; |
3127 | struct lpfc_sli *psli = &phba->sli; | ||
3128 | struct lpfc_sli_ring *pring; | ||
3129 | struct lpfc_iocbq *iocb, *next_iocb; | ||
3130 | int i; | ||
3131 | unsigned long flags = 0; | ||
3132 | uint16_t prev_pring_flag; | ||
3133 | |||
3134 | lpfc_cleanup_discovery_resources(vport); | ||
3135 | |||
3136 | spin_lock_irqsave(&phba->hbalock, flags); | ||
3137 | for (i = 0; i < psli->num_rings; i++) { | ||
3138 | pring = &psli->ring[i]; | ||
3139 | prev_pring_flag = pring->flag; | ||
3140 | if (pring->ringno == LPFC_ELS_RING) /* Only slow rings */ | ||
3141 | pring->flag |= LPFC_DEFERRED_RING_EVENT; | ||
3142 | /* | ||
3143 | * Error everything on the txq since these iocbs have not been | ||
3144 | * given to the FW yet. | ||
3145 | */ | ||
3146 | list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { | ||
3147 | if (iocb->vport != vport) | ||
3148 | continue; | ||
3149 | list_move_tail(&iocb->list, &completions); | ||
3150 | pring->txq_cnt--; | ||
3151 | } | ||
3152 | |||
3153 | /* Next issue ABTS for everything on the txcmplq */ | ||
3154 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, | ||
3155 | list) { | ||
3156 | if (iocb->vport != vport) | ||
3157 | continue; | ||
3158 | lpfc_sli_issue_abort_iotag(phba, pring, iocb); | ||
3159 | } | ||
3160 | |||
3161 | pring->flag = prev_pring_flag; | ||
3162 | } | ||
3163 | |||
3164 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
3165 | |||
3166 | while (!list_empty(&completions)) { | ||
3167 | list_remove_head(&completions, iocb, struct lpfc_iocbq, list); | ||
3168 | |||
3169 | if (!iocb->iocb_cmpl) | ||
3170 | lpfc_sli_release_iocbq(phba, iocb); | ||
3171 | else { | ||
3172 | iocb->iocb.ulpStatus = IOSTAT_LOCAL_REJECT; | ||
3173 | iocb->iocb.un.ulpWord[4] = IOERR_SLI_DOWN; | ||
3174 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
3175 | } | ||
3176 | } | ||
3177 | return 1; | ||
3178 | } | ||
3179 | |||
3180 | int | ||
3181 | lpfc_sli_hba_down(struct lpfc_hba *phba) | ||
3182 | { | ||
3183 | LIST_HEAD(completions); | ||
3184 | struct lpfc_sli *psli = &phba->sli; | ||
2624 | struct lpfc_sli_ring *pring; | 3185 | struct lpfc_sli_ring *pring; |
2625 | LPFC_MBOXQ_t *pmb; | 3186 | LPFC_MBOXQ_t *pmb; |
2626 | struct lpfc_iocbq *iocb; | 3187 | struct lpfc_iocbq *iocb; |
@@ -2628,13 +3189,15 @@ lpfc_sli_hba_down(struct lpfc_hba * phba) | |||
2628 | int i; | 3189 | int i; |
2629 | unsigned long flags = 0; | 3190 | unsigned long flags = 0; |
2630 | 3191 | ||
2631 | psli = &phba->sli; | ||
2632 | lpfc_hba_down_prep(phba); | 3192 | lpfc_hba_down_prep(phba); |
2633 | 3193 | ||
2634 | spin_lock_irqsave(phba->host->host_lock, flags); | 3194 | lpfc_fabric_abort_hba(phba); |
3195 | |||
3196 | spin_lock_irqsave(&phba->hbalock, flags); | ||
2635 | for (i = 0; i < psli->num_rings; i++) { | 3197 | for (i = 0; i < psli->num_rings; i++) { |
2636 | pring = &psli->ring[i]; | 3198 | pring = &psli->ring[i]; |
2637 | pring->flag |= LPFC_DEFERRED_RING_EVENT; | 3199 | if (pring->ringno == LPFC_ELS_RING) /* Only slow rings */ |
3200 | pring->flag |= LPFC_DEFERRED_RING_EVENT; | ||
2638 | 3201 | ||
2639 | /* | 3202 | /* |
2640 | * Error everything on the txq since these iocbs have not been | 3203 | * Error everything on the txq since these iocbs have not been |
@@ -2644,51 +3207,50 @@ lpfc_sli_hba_down(struct lpfc_hba * phba) | |||
2644 | pring->txq_cnt = 0; | 3207 | pring->txq_cnt = 0; |
2645 | 3208 | ||
2646 | } | 3209 | } |
2647 | spin_unlock_irqrestore(phba->host->host_lock, flags); | 3210 | spin_unlock_irqrestore(&phba->hbalock, flags); |
2648 | 3211 | ||
2649 | while (!list_empty(&completions)) { | 3212 | while (!list_empty(&completions)) { |
2650 | iocb = list_get_first(&completions, struct lpfc_iocbq, list); | 3213 | list_remove_head(&completions, iocb, struct lpfc_iocbq, list); |
2651 | cmd = &iocb->iocb; | 3214 | cmd = &iocb->iocb; |
2652 | list_del(&iocb->list); | ||
2653 | 3215 | ||
2654 | if (iocb->iocb_cmpl) { | 3216 | if (!iocb->iocb_cmpl) |
3217 | lpfc_sli_release_iocbq(phba, iocb); | ||
3218 | else { | ||
2655 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | 3219 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; |
2656 | cmd->un.ulpWord[4] = IOERR_SLI_DOWN; | 3220 | cmd->un.ulpWord[4] = IOERR_SLI_DOWN; |
2657 | (iocb->iocb_cmpl) (phba, iocb, iocb); | 3221 | (iocb->iocb_cmpl) (phba, iocb, iocb); |
2658 | } else | 3222 | } |
2659 | lpfc_sli_release_iocbq(phba, iocb); | ||
2660 | } | 3223 | } |
2661 | 3224 | ||
2662 | /* Return any active mbox cmds */ | 3225 | /* Return any active mbox cmds */ |
2663 | del_timer_sync(&psli->mbox_tmo); | 3226 | del_timer_sync(&psli->mbox_tmo); |
2664 | spin_lock_irqsave(phba->host->host_lock, flags); | 3227 | spin_lock_irqsave(&phba->hbalock, flags); |
2665 | phba->work_hba_events &= ~WORKER_MBOX_TMO; | 3228 | |
3229 | spin_lock(&phba->pport->work_port_lock); | ||
3230 | phba->pport->work_port_events &= ~WORKER_MBOX_TMO; | ||
3231 | spin_unlock(&phba->pport->work_port_lock); | ||
3232 | |||
2666 | if (psli->mbox_active) { | 3233 | if (psli->mbox_active) { |
2667 | pmb = psli->mbox_active; | 3234 | list_add_tail(&psli->mbox_active->list, &completions); |
2668 | pmb->mb.mbxStatus = MBX_NOT_FINISHED; | 3235 | psli->mbox_active = NULL; |
2669 | if (pmb->mbox_cmpl) { | 3236 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; |
2670 | spin_unlock_irqrestore(phba->host->host_lock, flags); | ||
2671 | pmb->mbox_cmpl(phba,pmb); | ||
2672 | spin_lock_irqsave(phba->host->host_lock, flags); | ||
2673 | } | ||
2674 | } | 3237 | } |
2675 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | ||
2676 | psli->mbox_active = NULL; | ||
2677 | 3238 | ||
2678 | /* Return any pending mbox cmds */ | 3239 | /* Return any pending or completed mbox cmds */ |
2679 | while ((pmb = lpfc_mbox_get(phba)) != NULL) { | 3240 | list_splice_init(&phba->sli.mboxq, &completions); |
3241 | list_splice_init(&phba->sli.mboxq_cmpl, &completions); | ||
3242 | INIT_LIST_HEAD(&psli->mboxq); | ||
3243 | INIT_LIST_HEAD(&psli->mboxq_cmpl); | ||
3244 | |||
3245 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
3246 | |||
3247 | while (!list_empty(&completions)) { | ||
3248 | list_remove_head(&completions, pmb, LPFC_MBOXQ_t, list); | ||
2680 | pmb->mb.mbxStatus = MBX_NOT_FINISHED; | 3249 | pmb->mb.mbxStatus = MBX_NOT_FINISHED; |
2681 | if (pmb->mbox_cmpl) { | 3250 | if (pmb->mbox_cmpl) { |
2682 | spin_unlock_irqrestore(phba->host->host_lock, flags); | ||
2683 | pmb->mbox_cmpl(phba,pmb); | 3251 | pmb->mbox_cmpl(phba,pmb); |
2684 | spin_lock_irqsave(phba->host->host_lock, flags); | ||
2685 | } | 3252 | } |
2686 | } | 3253 | } |
2687 | |||
2688 | INIT_LIST_HEAD(&psli->mboxq); | ||
2689 | |||
2690 | spin_unlock_irqrestore(phba->host->host_lock, flags); | ||
2691 | |||
2692 | return 1; | 3254 | return 1; |
2693 | } | 3255 | } |
2694 | 3256 | ||
@@ -2710,14 +3272,15 @@ lpfc_sli_pcimem_bcopy(void *srcp, void *destp, uint32_t cnt) | |||
2710 | } | 3272 | } |
2711 | 3273 | ||
2712 | int | 3274 | int |
2713 | lpfc_sli_ringpostbuf_put(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, | 3275 | lpfc_sli_ringpostbuf_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
2714 | struct lpfc_dmabuf * mp) | 3276 | struct lpfc_dmabuf *mp) |
2715 | { | 3277 | { |
2716 | /* Stick struct lpfc_dmabuf at end of postbufq so driver can look it up | 3278 | /* Stick struct lpfc_dmabuf at end of postbufq so driver can look it up |
2717 | later */ | 3279 | later */ |
3280 | spin_lock_irq(&phba->hbalock); | ||
2718 | list_add_tail(&mp->list, &pring->postbufq); | 3281 | list_add_tail(&mp->list, &pring->postbufq); |
2719 | |||
2720 | pring->postbufq_cnt++; | 3282 | pring->postbufq_cnt++; |
3283 | spin_unlock_irq(&phba->hbalock); | ||
2721 | return 0; | 3284 | return 0; |
2722 | } | 3285 | } |
2723 | 3286 | ||
@@ -2730,14 +3293,17 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2730 | struct list_head *slp = &pring->postbufq; | 3293 | struct list_head *slp = &pring->postbufq; |
2731 | 3294 | ||
2732 | /* Search postbufq, from the begining, looking for a match on phys */ | 3295 | /* Search postbufq, from the begining, looking for a match on phys */ |
3296 | spin_lock_irq(&phba->hbalock); | ||
2733 | list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { | 3297 | list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { |
2734 | if (mp->phys == phys) { | 3298 | if (mp->phys == phys) { |
2735 | list_del_init(&mp->list); | 3299 | list_del_init(&mp->list); |
2736 | pring->postbufq_cnt--; | 3300 | pring->postbufq_cnt--; |
3301 | spin_unlock_irq(&phba->hbalock); | ||
2737 | return mp; | 3302 | return mp; |
2738 | } | 3303 | } |
2739 | } | 3304 | } |
2740 | 3305 | ||
3306 | spin_unlock_irq(&phba->hbalock); | ||
2741 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 3307 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
2742 | "%d:0410 Cannot find virtual addr for mapped buf on " | 3308 | "%d:0410 Cannot find virtual addr for mapped buf on " |
2743 | "ring %d Data x%llx x%p x%p x%x\n", | 3309 | "ring %d Data x%llx x%p x%p x%x\n", |
@@ -2747,92 +3313,110 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2747 | } | 3313 | } |
2748 | 3314 | ||
2749 | static void | 3315 | static void |
2750 | lpfc_sli_abort_els_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, | 3316 | lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
2751 | struct lpfc_iocbq * rspiocb) | 3317 | struct lpfc_iocbq *rspiocb) |
2752 | { | 3318 | { |
2753 | IOCB_t *irsp; | 3319 | IOCB_t *irsp = &rspiocb->iocb; |
2754 | uint16_t abort_iotag, abort_context; | 3320 | uint16_t abort_iotag, abort_context; |
2755 | struct lpfc_iocbq *abort_iocb, *rsp_ab_iocb; | 3321 | struct lpfc_iocbq *abort_iocb; |
2756 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; | 3322 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
2757 | 3323 | ||
2758 | abort_iocb = NULL; | 3324 | abort_iocb = NULL; |
2759 | irsp = &rspiocb->iocb; | ||
2760 | |||
2761 | spin_lock_irq(phba->host->host_lock); | ||
2762 | 3325 | ||
2763 | if (irsp->ulpStatus) { | 3326 | if (irsp->ulpStatus) { |
2764 | abort_context = cmdiocb->iocb.un.acxri.abortContextTag; | 3327 | abort_context = cmdiocb->iocb.un.acxri.abortContextTag; |
2765 | abort_iotag = cmdiocb->iocb.un.acxri.abortIoTag; | 3328 | abort_iotag = cmdiocb->iocb.un.acxri.abortIoTag; |
2766 | 3329 | ||
3330 | spin_lock_irq(&phba->hbalock); | ||
2767 | if (abort_iotag != 0 && abort_iotag <= phba->sli.last_iotag) | 3331 | if (abort_iotag != 0 && abort_iotag <= phba->sli.last_iotag) |
2768 | abort_iocb = phba->sli.iocbq_lookup[abort_iotag]; | 3332 | abort_iocb = phba->sli.iocbq_lookup[abort_iotag]; |
2769 | 3333 | ||
2770 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, | 3334 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS | LOG_SLI, |
2771 | "%d:0327 Cannot abort els iocb %p" | 3335 | "%d:0327 Cannot abort els iocb %p " |
2772 | " with tag %x context %x\n", | 3336 | "with tag %x context %x, abort status %x, " |
2773 | phba->brd_no, abort_iocb, | 3337 | "abort code %x\n", |
2774 | abort_iotag, abort_context); | 3338 | phba->brd_no, abort_iocb, abort_iotag, |
3339 | abort_context, irsp->ulpStatus, | ||
3340 | irsp->un.ulpWord[4]); | ||
2775 | 3341 | ||
2776 | /* | 3342 | /* |
2777 | * make sure we have the right iocbq before taking it | 3343 | * make sure we have the right iocbq before taking it |
2778 | * off the txcmplq and try to call completion routine. | 3344 | * off the txcmplq and try to call completion routine. |
2779 | */ | 3345 | */ |
2780 | if (abort_iocb && | 3346 | if (!abort_iocb || |
2781 | abort_iocb->iocb.ulpContext == abort_context && | 3347 | abort_iocb->iocb.ulpContext != abort_context || |
2782 | abort_iocb->iocb_flag & LPFC_DRIVER_ABORTED) { | 3348 | (abort_iocb->iocb_flag & LPFC_DRIVER_ABORTED) == 0) |
2783 | list_del(&abort_iocb->list); | 3349 | spin_unlock_irq(&phba->hbalock); |
3350 | else { | ||
3351 | list_del_init(&abort_iocb->list); | ||
2784 | pring->txcmplq_cnt--; | 3352 | pring->txcmplq_cnt--; |
3353 | spin_unlock_irq(&phba->hbalock); | ||
2785 | 3354 | ||
2786 | rsp_ab_iocb = lpfc_sli_get_iocbq(phba); | 3355 | abort_iocb->iocb_flag &= ~LPFC_DRIVER_ABORTED; |
2787 | if (rsp_ab_iocb == NULL) | 3356 | abort_iocb->iocb.ulpStatus = IOSTAT_LOCAL_REJECT; |
2788 | lpfc_sli_release_iocbq(phba, abort_iocb); | 3357 | abort_iocb->iocb.un.ulpWord[4] = IOERR_SLI_ABORTED; |
2789 | else { | 3358 | (abort_iocb->iocb_cmpl)(phba, abort_iocb, abort_iocb); |
2790 | abort_iocb->iocb_flag &= | ||
2791 | ~LPFC_DRIVER_ABORTED; | ||
2792 | rsp_ab_iocb->iocb.ulpStatus = | ||
2793 | IOSTAT_LOCAL_REJECT; | ||
2794 | rsp_ab_iocb->iocb.un.ulpWord[4] = | ||
2795 | IOERR_SLI_ABORTED; | ||
2796 | spin_unlock_irq(phba->host->host_lock); | ||
2797 | (abort_iocb->iocb_cmpl) | ||
2798 | (phba, abort_iocb, rsp_ab_iocb); | ||
2799 | spin_lock_irq(phba->host->host_lock); | ||
2800 | lpfc_sli_release_iocbq(phba, rsp_ab_iocb); | ||
2801 | } | ||
2802 | } | 3359 | } |
2803 | } | 3360 | } |
2804 | 3361 | ||
2805 | lpfc_sli_release_iocbq(phba, cmdiocb); | 3362 | lpfc_sli_release_iocbq(phba, cmdiocb); |
2806 | spin_unlock_irq(phba->host->host_lock); | 3363 | return; |
3364 | } | ||
3365 | |||
3366 | static void | ||
3367 | lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | ||
3368 | struct lpfc_iocbq *rspiocb) | ||
3369 | { | ||
3370 | IOCB_t *irsp = &rspiocb->iocb; | ||
3371 | |||
3372 | /* ELS cmd tag <ulpIoTag> completes */ | ||
3373 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, | ||
3374 | "%d (X):0133 Ignoring ELS cmd tag x%x completion Data: " | ||
3375 | "x%x x%x x%x\n", | ||
3376 | phba->brd_no, irsp->ulpIoTag, irsp->ulpStatus, | ||
3377 | irsp->un.ulpWord[4], irsp->ulpTimeout); | ||
3378 | if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) | ||
3379 | lpfc_ct_free_iocb(phba, cmdiocb); | ||
3380 | else | ||
3381 | lpfc_els_free_iocb(phba, cmdiocb); | ||
2807 | return; | 3382 | return; |
2808 | } | 3383 | } |
2809 | 3384 | ||
2810 | int | 3385 | int |
2811 | lpfc_sli_issue_abort_iotag(struct lpfc_hba * phba, | 3386 | lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
2812 | struct lpfc_sli_ring * pring, | 3387 | struct lpfc_iocbq *cmdiocb) |
2813 | struct lpfc_iocbq * cmdiocb) | ||
2814 | { | 3388 | { |
3389 | struct lpfc_vport *vport = cmdiocb->vport; | ||
2815 | struct lpfc_iocbq *abtsiocbp; | 3390 | struct lpfc_iocbq *abtsiocbp; |
2816 | IOCB_t *icmd = NULL; | 3391 | IOCB_t *icmd = NULL; |
2817 | IOCB_t *iabt = NULL; | 3392 | IOCB_t *iabt = NULL; |
2818 | int retval = IOCB_ERROR; | 3393 | int retval = IOCB_ERROR; |
2819 | 3394 | ||
2820 | /* There are certain command types we don't want | 3395 | /* |
2821 | * to abort. | 3396 | * There are certain command types we don't want to abort. And we |
3397 | * don't want to abort commands that are already in the process of | ||
3398 | * being aborted. | ||
2822 | */ | 3399 | */ |
2823 | icmd = &cmdiocb->iocb; | 3400 | icmd = &cmdiocb->iocb; |
2824 | if ((icmd->ulpCommand == CMD_ABORT_XRI_CN) || | 3401 | if (icmd->ulpCommand == CMD_ABORT_XRI_CN || |
2825 | (icmd->ulpCommand == CMD_CLOSE_XRI_CN)) | 3402 | icmd->ulpCommand == CMD_CLOSE_XRI_CN || |
3403 | (cmdiocb->iocb_flag & LPFC_DRIVER_ABORTED) != 0) | ||
2826 | return 0; | 3404 | return 0; |
2827 | 3405 | ||
2828 | /* If we're unloading, interrupts are disabled so we | 3406 | /* If we're unloading, don't abort iocb on the ELS ring, but change the |
2829 | * need to cleanup the iocb here. | 3407 | * callback so that nothing happens when it finishes. |
2830 | */ | 3408 | */ |
2831 | if (phba->fc_flag & FC_UNLOADING) | 3409 | if ((vport->load_flag & FC_UNLOADING) && |
3410 | (pring->ringno == LPFC_ELS_RING)) { | ||
3411 | if (cmdiocb->iocb_flag & LPFC_IO_FABRIC) | ||
3412 | cmdiocb->fabric_iocb_cmpl = lpfc_ignore_els_cmpl; | ||
3413 | else | ||
3414 | cmdiocb->iocb_cmpl = lpfc_ignore_els_cmpl; | ||
2832 | goto abort_iotag_exit; | 3415 | goto abort_iotag_exit; |
3416 | } | ||
2833 | 3417 | ||
2834 | /* issue ABTS for this IOCB based on iotag */ | 3418 | /* issue ABTS for this IOCB based on iotag */ |
2835 | abtsiocbp = lpfc_sli_get_iocbq(phba); | 3419 | abtsiocbp = __lpfc_sli_get_iocbq(phba); |
2836 | if (abtsiocbp == NULL) | 3420 | if (abtsiocbp == NULL) |
2837 | return 0; | 3421 | return 0; |
2838 | 3422 | ||
@@ -2848,7 +3432,7 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba * phba, | |||
2848 | iabt->ulpLe = 1; | 3432 | iabt->ulpLe = 1; |
2849 | iabt->ulpClass = icmd->ulpClass; | 3433 | iabt->ulpClass = icmd->ulpClass; |
2850 | 3434 | ||
2851 | if (phba->hba_state >= LPFC_LINK_UP) | 3435 | if (phba->link_state >= LPFC_LINK_UP) |
2852 | iabt->ulpCommand = CMD_ABORT_XRI_CN; | 3436 | iabt->ulpCommand = CMD_ABORT_XRI_CN; |
2853 | else | 3437 | else |
2854 | iabt->ulpCommand = CMD_CLOSE_XRI_CN; | 3438 | iabt->ulpCommand = CMD_CLOSE_XRI_CN; |
@@ -2856,32 +3440,20 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba * phba, | |||
2856 | abtsiocbp->iocb_cmpl = lpfc_sli_abort_els_cmpl; | 3440 | abtsiocbp->iocb_cmpl = lpfc_sli_abort_els_cmpl; |
2857 | 3441 | ||
2858 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | 3442 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
2859 | "%d:0339 Abort xri x%x, original iotag x%x, abort " | 3443 | "%d (%d):0339 Abort xri x%x, original iotag x%x, " |
2860 | "cmd iotag x%x\n", | 3444 | "abort cmd iotag x%x\n", |
2861 | phba->brd_no, iabt->un.acxri.abortContextTag, | 3445 | phba->brd_no, vport->vpi, |
3446 | iabt->un.acxri.abortContextTag, | ||
2862 | iabt->un.acxri.abortIoTag, abtsiocbp->iotag); | 3447 | iabt->un.acxri.abortIoTag, abtsiocbp->iotag); |
2863 | retval = lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0); | 3448 | retval = __lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0); |
2864 | 3449 | ||
2865 | abort_iotag_exit: | 3450 | abort_iotag_exit: |
2866 | 3451 | /* | |
2867 | /* If we could not issue an abort dequeue the iocb and handle | 3452 | * Caller to this routine should check for IOCB_ERROR |
2868 | * the completion here. | 3453 | * and handle it properly. This routine no longer removes |
3454 | * iocb off txcmplq and call compl in case of IOCB_ERROR. | ||
2869 | */ | 3455 | */ |
2870 | if (retval == IOCB_ERROR) { | 3456 | return retval; |
2871 | list_del(&cmdiocb->list); | ||
2872 | pring->txcmplq_cnt--; | ||
2873 | |||
2874 | if (cmdiocb->iocb_cmpl) { | ||
2875 | icmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
2876 | icmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
2877 | spin_unlock_irq(phba->host->host_lock); | ||
2878 | (cmdiocb->iocb_cmpl) (phba, cmdiocb, cmdiocb); | ||
2879 | spin_lock_irq(phba->host->host_lock); | ||
2880 | } else | ||
2881 | lpfc_sli_release_iocbq(phba, cmdiocb); | ||
2882 | } | ||
2883 | |||
2884 | return 1; | ||
2885 | } | 3457 | } |
2886 | 3458 | ||
2887 | static int | 3459 | static int |
@@ -2930,7 +3502,7 @@ lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, uint16_t tgt_id, | |||
2930 | 3502 | ||
2931 | int | 3503 | int |
2932 | lpfc_sli_sum_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | 3504 | lpfc_sli_sum_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
2933 | uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd ctx_cmd) | 3505 | uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd ctx_cmd) |
2934 | { | 3506 | { |
2935 | struct lpfc_iocbq *iocbq; | 3507 | struct lpfc_iocbq *iocbq; |
2936 | int sum, i; | 3508 | int sum, i; |
@@ -2947,14 +3519,10 @@ lpfc_sli_sum_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2947 | } | 3519 | } |
2948 | 3520 | ||
2949 | void | 3521 | void |
2950 | lpfc_sli_abort_fcp_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, | 3522 | lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
2951 | struct lpfc_iocbq * rspiocb) | 3523 | struct lpfc_iocbq *rspiocb) |
2952 | { | 3524 | { |
2953 | unsigned long iflags; | ||
2954 | |||
2955 | spin_lock_irqsave(phba->host->host_lock, iflags); | ||
2956 | lpfc_sli_release_iocbq(phba, cmdiocb); | 3525 | lpfc_sli_release_iocbq(phba, cmdiocb); |
2957 | spin_unlock_irqrestore(phba->host->host_lock, iflags); | ||
2958 | return; | 3526 | return; |
2959 | } | 3527 | } |
2960 | 3528 | ||
@@ -2972,8 +3540,8 @@ lpfc_sli_abort_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2972 | for (i = 1; i <= phba->sli.last_iotag; i++) { | 3540 | for (i = 1; i <= phba->sli.last_iotag; i++) { |
2973 | iocbq = phba->sli.iocbq_lookup[i]; | 3541 | iocbq = phba->sli.iocbq_lookup[i]; |
2974 | 3542 | ||
2975 | if (lpfc_sli_validate_fcp_iocb (iocbq, tgt_id, lun_id, | 3543 | if (lpfc_sli_validate_fcp_iocb(iocbq, tgt_id, lun_id, 0, |
2976 | 0, abort_cmd) != 0) | 3544 | abort_cmd) != 0) |
2977 | continue; | 3545 | continue; |
2978 | 3546 | ||
2979 | /* issue ABTS for this IOCB based on iotag */ | 3547 | /* issue ABTS for this IOCB based on iotag */ |
@@ -2989,8 +3557,9 @@ lpfc_sli_abort_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2989 | abtsiocb->iocb.un.acxri.abortIoTag = cmd->ulpIoTag; | 3557 | abtsiocb->iocb.un.acxri.abortIoTag = cmd->ulpIoTag; |
2990 | abtsiocb->iocb.ulpLe = 1; | 3558 | abtsiocb->iocb.ulpLe = 1; |
2991 | abtsiocb->iocb.ulpClass = cmd->ulpClass; | 3559 | abtsiocb->iocb.ulpClass = cmd->ulpClass; |
3560 | abtsiocb->vport = phba->pport; | ||
2992 | 3561 | ||
2993 | if (phba->hba_state >= LPFC_LINK_UP) | 3562 | if (lpfc_is_link_up(phba)) |
2994 | abtsiocb->iocb.ulpCommand = CMD_ABORT_XRI_CN; | 3563 | abtsiocb->iocb.ulpCommand = CMD_ABORT_XRI_CN; |
2995 | else | 3564 | else |
2996 | abtsiocb->iocb.ulpCommand = CMD_CLOSE_XRI_CN; | 3565 | abtsiocb->iocb.ulpCommand = CMD_CLOSE_XRI_CN; |
@@ -3016,16 +3585,16 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, | |||
3016 | wait_queue_head_t *pdone_q; | 3585 | wait_queue_head_t *pdone_q; |
3017 | unsigned long iflags; | 3586 | unsigned long iflags; |
3018 | 3587 | ||
3019 | spin_lock_irqsave(phba->host->host_lock, iflags); | 3588 | spin_lock_irqsave(&phba->hbalock, iflags); |
3020 | cmdiocbq->iocb_flag |= LPFC_IO_WAKE; | 3589 | cmdiocbq->iocb_flag |= LPFC_IO_WAKE; |
3021 | if (cmdiocbq->context2 && rspiocbq) | 3590 | if (cmdiocbq->context2 && rspiocbq) |
3022 | memcpy(&((struct lpfc_iocbq *)cmdiocbq->context2)->iocb, | 3591 | memcpy(&((struct lpfc_iocbq *)cmdiocbq->context2)->iocb, |
3023 | &rspiocbq->iocb, sizeof(IOCB_t)); | 3592 | &rspiocbq->iocb, sizeof(IOCB_t)); |
3024 | 3593 | ||
3025 | pdone_q = cmdiocbq->context_un.wait_queue; | 3594 | pdone_q = cmdiocbq->context_un.wait_queue; |
3026 | spin_unlock_irqrestore(phba->host->host_lock, iflags); | ||
3027 | if (pdone_q) | 3595 | if (pdone_q) |
3028 | wake_up(pdone_q); | 3596 | wake_up(pdone_q); |
3597 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
3029 | return; | 3598 | return; |
3030 | } | 3599 | } |
3031 | 3600 | ||
@@ -3035,11 +3604,12 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, | |||
3035 | * lpfc_sli_issue_call since the wake routine sets a unique value and by | 3604 | * lpfc_sli_issue_call since the wake routine sets a unique value and by |
3036 | * definition this is a wait function. | 3605 | * definition this is a wait function. |
3037 | */ | 3606 | */ |
3607 | |||
3038 | int | 3608 | int |
3039 | lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba, | 3609 | lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, |
3040 | struct lpfc_sli_ring * pring, | 3610 | struct lpfc_sli_ring *pring, |
3041 | struct lpfc_iocbq * piocb, | 3611 | struct lpfc_iocbq *piocb, |
3042 | struct lpfc_iocbq * prspiocbq, | 3612 | struct lpfc_iocbq *prspiocbq, |
3043 | uint32_t timeout) | 3613 | uint32_t timeout) |
3044 | { | 3614 | { |
3045 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q); | 3615 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q); |
@@ -3071,11 +3641,9 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba, | |||
3071 | retval = lpfc_sli_issue_iocb(phba, pring, piocb, 0); | 3641 | retval = lpfc_sli_issue_iocb(phba, pring, piocb, 0); |
3072 | if (retval == IOCB_SUCCESS) { | 3642 | if (retval == IOCB_SUCCESS) { |
3073 | timeout_req = timeout * HZ; | 3643 | timeout_req = timeout * HZ; |
3074 | spin_unlock_irq(phba->host->host_lock); | ||
3075 | timeleft = wait_event_timeout(done_q, | 3644 | timeleft = wait_event_timeout(done_q, |
3076 | piocb->iocb_flag & LPFC_IO_WAKE, | 3645 | piocb->iocb_flag & LPFC_IO_WAKE, |
3077 | timeout_req); | 3646 | timeout_req); |
3078 | spin_lock_irq(phba->host->host_lock); | ||
3079 | 3647 | ||
3080 | if (piocb->iocb_flag & LPFC_IO_WAKE) { | 3648 | if (piocb->iocb_flag & LPFC_IO_WAKE) { |
3081 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | 3649 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
@@ -3117,16 +3685,16 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba, | |||
3117 | } | 3685 | } |
3118 | 3686 | ||
3119 | int | 3687 | int |
3120 | lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, | 3688 | lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq, |
3121 | uint32_t timeout) | 3689 | uint32_t timeout) |
3122 | { | 3690 | { |
3123 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q); | 3691 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q); |
3124 | int retval; | 3692 | int retval; |
3693 | unsigned long flag; | ||
3125 | 3694 | ||
3126 | /* The caller must leave context1 empty. */ | 3695 | /* The caller must leave context1 empty. */ |
3127 | if (pmboxq->context1 != 0) { | 3696 | if (pmboxq->context1 != 0) |
3128 | return (MBX_NOT_FINISHED); | 3697 | return MBX_NOT_FINISHED; |
3129 | } | ||
3130 | 3698 | ||
3131 | /* setup wake call as IOCB callback */ | 3699 | /* setup wake call as IOCB callback */ |
3132 | pmboxq->mbox_cmpl = lpfc_sli_wake_mbox_wait; | 3700 | pmboxq->mbox_cmpl = lpfc_sli_wake_mbox_wait; |
@@ -3141,6 +3709,7 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, | |||
3141 | pmboxq->mbox_flag & LPFC_MBX_WAKE, | 3709 | pmboxq->mbox_flag & LPFC_MBX_WAKE, |
3142 | timeout * HZ); | 3710 | timeout * HZ); |
3143 | 3711 | ||
3712 | spin_lock_irqsave(&phba->hbalock, flag); | ||
3144 | pmboxq->context1 = NULL; | 3713 | pmboxq->context1 = NULL; |
3145 | /* | 3714 | /* |
3146 | * if LPFC_MBX_WAKE flag is set the mailbox is completed | 3715 | * if LPFC_MBX_WAKE flag is set the mailbox is completed |
@@ -3148,8 +3717,11 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, | |||
3148 | */ | 3717 | */ |
3149 | if (pmboxq->mbox_flag & LPFC_MBX_WAKE) | 3718 | if (pmboxq->mbox_flag & LPFC_MBX_WAKE) |
3150 | retval = MBX_SUCCESS; | 3719 | retval = MBX_SUCCESS; |
3151 | else | 3720 | else { |
3152 | retval = MBX_TIMEOUT; | 3721 | retval = MBX_TIMEOUT; |
3722 | pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | ||
3723 | } | ||
3724 | spin_unlock_irqrestore(&phba->hbalock, flag); | ||
3153 | } | 3725 | } |
3154 | 3726 | ||
3155 | return retval; | 3727 | return retval; |
@@ -3158,14 +3730,27 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, | |||
3158 | int | 3730 | int |
3159 | lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba) | 3731 | lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba) |
3160 | { | 3732 | { |
3733 | struct lpfc_vport *vport = phba->pport; | ||
3161 | int i = 0; | 3734 | int i = 0; |
3735 | uint32_t ha_copy; | ||
3162 | 3736 | ||
3163 | while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE && !phba->stopped) { | 3737 | while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE && !vport->stopped) { |
3164 | if (i++ > LPFC_MBOX_TMO * 1000) | 3738 | if (i++ > LPFC_MBOX_TMO * 1000) |
3165 | return 1; | 3739 | return 1; |
3166 | 3740 | ||
3167 | if (lpfc_sli_handle_mb_event(phba) == 0) | 3741 | /* |
3168 | i = 0; | 3742 | * Call lpfc_sli_handle_mb_event only if a mailbox cmd |
3743 | * did finish. This way we won't get the misleading | ||
3744 | * "Stray Mailbox Interrupt" message. | ||
3745 | */ | ||
3746 | spin_lock_irq(&phba->hbalock); | ||
3747 | ha_copy = phba->work_ha; | ||
3748 | phba->work_ha &= ~HA_MBATT; | ||
3749 | spin_unlock_irq(&phba->hbalock); | ||
3750 | |||
3751 | if (ha_copy & HA_MBATT) | ||
3752 | if (lpfc_sli_handle_mb_event(phba) == 0) | ||
3753 | i = 0; | ||
3169 | 3754 | ||
3170 | msleep(1); | 3755 | msleep(1); |
3171 | } | 3756 | } |
@@ -3176,13 +3761,20 @@ lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba) | |||
3176 | irqreturn_t | 3761 | irqreturn_t |
3177 | lpfc_intr_handler(int irq, void *dev_id) | 3762 | lpfc_intr_handler(int irq, void *dev_id) |
3178 | { | 3763 | { |
3179 | struct lpfc_hba *phba; | 3764 | struct lpfc_hba *phba; |
3180 | uint32_t ha_copy; | 3765 | uint32_t ha_copy; |
3181 | uint32_t work_ha_copy; | 3766 | uint32_t work_ha_copy; |
3182 | unsigned long status; | 3767 | unsigned long status; |
3183 | int i; | 3768 | int i; |
3184 | uint32_t control; | 3769 | uint32_t control; |
3185 | 3770 | ||
3771 | MAILBOX_t *mbox, *pmbox; | ||
3772 | struct lpfc_vport *vport; | ||
3773 | struct lpfc_nodelist *ndlp; | ||
3774 | struct lpfc_dmabuf *mp; | ||
3775 | LPFC_MBOXQ_t *pmb; | ||
3776 | int rc; | ||
3777 | |||
3186 | /* | 3778 | /* |
3187 | * Get the driver's phba structure from the dev_id and | 3779 | * Get the driver's phba structure from the dev_id and |
3188 | * assume the HBA is not interrupting. | 3780 | * assume the HBA is not interrupting. |
@@ -3204,7 +3796,7 @@ lpfc_intr_handler(int irq, void *dev_id) | |||
3204 | */ | 3796 | */ |
3205 | 3797 | ||
3206 | /* Ignore all interrupts during initialization. */ | 3798 | /* Ignore all interrupts during initialization. */ |
3207 | if (unlikely(phba->hba_state < LPFC_LINK_DOWN)) | 3799 | if (unlikely(phba->link_state < LPFC_LINK_DOWN)) |
3208 | return IRQ_NONE; | 3800 | return IRQ_NONE; |
3209 | 3801 | ||
3210 | /* | 3802 | /* |
@@ -3212,16 +3804,16 @@ lpfc_intr_handler(int irq, void *dev_id) | |||
3212 | * Clear Attention Sources, except Error Attention (to | 3804 | * Clear Attention Sources, except Error Attention (to |
3213 | * preserve status) and Link Attention | 3805 | * preserve status) and Link Attention |
3214 | */ | 3806 | */ |
3215 | spin_lock(phba->host->host_lock); | 3807 | spin_lock(&phba->hbalock); |
3216 | ha_copy = readl(phba->HAregaddr); | 3808 | ha_copy = readl(phba->HAregaddr); |
3217 | /* If somebody is waiting to handle an eratt don't process it | 3809 | /* If somebody is waiting to handle an eratt don't process it |
3218 | * here. The brdkill function will do this. | 3810 | * here. The brdkill function will do this. |
3219 | */ | 3811 | */ |
3220 | if (phba->fc_flag & FC_IGNORE_ERATT) | 3812 | if (phba->link_flag & LS_IGNORE_ERATT) |
3221 | ha_copy &= ~HA_ERATT; | 3813 | ha_copy &= ~HA_ERATT; |
3222 | writel((ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); | 3814 | writel((ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); |
3223 | readl(phba->HAregaddr); /* flush */ | 3815 | readl(phba->HAregaddr); /* flush */ |
3224 | spin_unlock(phba->host->host_lock); | 3816 | spin_unlock(&phba->hbalock); |
3225 | 3817 | ||
3226 | if (unlikely(!ha_copy)) | 3818 | if (unlikely(!ha_copy)) |
3227 | return IRQ_NONE; | 3819 | return IRQ_NONE; |
@@ -3235,36 +3827,41 @@ lpfc_intr_handler(int irq, void *dev_id) | |||
3235 | * Turn off Link Attention interrupts | 3827 | * Turn off Link Attention interrupts |
3236 | * until CLEAR_LA done | 3828 | * until CLEAR_LA done |
3237 | */ | 3829 | */ |
3238 | spin_lock(phba->host->host_lock); | 3830 | spin_lock(&phba->hbalock); |
3239 | phba->sli.sli_flag &= ~LPFC_PROCESS_LA; | 3831 | phba->sli.sli_flag &= ~LPFC_PROCESS_LA; |
3240 | control = readl(phba->HCregaddr); | 3832 | control = readl(phba->HCregaddr); |
3241 | control &= ~HC_LAINT_ENA; | 3833 | control &= ~HC_LAINT_ENA; |
3242 | writel(control, phba->HCregaddr); | 3834 | writel(control, phba->HCregaddr); |
3243 | readl(phba->HCregaddr); /* flush */ | 3835 | readl(phba->HCregaddr); /* flush */ |
3244 | spin_unlock(phba->host->host_lock); | 3836 | spin_unlock(&phba->hbalock); |
3245 | } | 3837 | } |
3246 | else | 3838 | else |
3247 | work_ha_copy &= ~HA_LATT; | 3839 | work_ha_copy &= ~HA_LATT; |
3248 | } | 3840 | } |
3249 | 3841 | ||
3250 | if (work_ha_copy & ~(HA_ERATT|HA_MBATT|HA_LATT)) { | 3842 | if (work_ha_copy & ~(HA_ERATT|HA_MBATT|HA_LATT)) { |
3251 | for (i = 0; i < phba->sli.num_rings; i++) { | 3843 | /* |
3252 | if (work_ha_copy & (HA_RXATT << (4*i))) { | 3844 | * Turn off Slow Rings interrupts, LPFC_ELS_RING is |
3253 | /* | 3845 | * the only slow ring. |
3254 | * Turn off Slow Rings interrupts | 3846 | */ |
3255 | */ | 3847 | status = (work_ha_copy & |
3256 | spin_lock(phba->host->host_lock); | 3848 | (HA_RXMASK << (4*LPFC_ELS_RING))); |
3257 | control = readl(phba->HCregaddr); | 3849 | status >>= (4*LPFC_ELS_RING); |
3258 | control &= ~(HC_R0INT_ENA << i); | 3850 | if (status & HA_RXMASK) { |
3851 | spin_lock(&phba->hbalock); | ||
3852 | control = readl(phba->HCregaddr); | ||
3853 | if (control & (HC_R0INT_ENA << LPFC_ELS_RING)) { | ||
3854 | control &= | ||
3855 | ~(HC_R0INT_ENA << LPFC_ELS_RING); | ||
3259 | writel(control, phba->HCregaddr); | 3856 | writel(control, phba->HCregaddr); |
3260 | readl(phba->HCregaddr); /* flush */ | 3857 | readl(phba->HCregaddr); /* flush */ |
3261 | spin_unlock(phba->host->host_lock); | ||
3262 | } | 3858 | } |
3859 | spin_unlock(&phba->hbalock); | ||
3263 | } | 3860 | } |
3264 | } | 3861 | } |
3265 | 3862 | ||
3266 | if (work_ha_copy & HA_ERATT) { | 3863 | if (work_ha_copy & HA_ERATT) { |
3267 | phba->hba_state = LPFC_HBA_ERROR; | 3864 | phba->link_state = LPFC_HBA_ERROR; |
3268 | /* | 3865 | /* |
3269 | * There was a link/board error. Read the | 3866 | * There was a link/board error. Read the |
3270 | * status register to retrieve the error event | 3867 | * status register to retrieve the error event |
@@ -3279,14 +3876,108 @@ lpfc_intr_handler(int irq, void *dev_id) | |||
3279 | /* Clear Chip error bit */ | 3876 | /* Clear Chip error bit */ |
3280 | writel(HA_ERATT, phba->HAregaddr); | 3877 | writel(HA_ERATT, phba->HAregaddr); |
3281 | readl(phba->HAregaddr); /* flush */ | 3878 | readl(phba->HAregaddr); /* flush */ |
3282 | phba->stopped = 1; | 3879 | phba->pport->stopped = 1; |
3880 | } | ||
3881 | |||
3882 | if ((work_ha_copy & HA_MBATT) && | ||
3883 | (phba->sli.mbox_active)) { | ||
3884 | pmb = phba->sli.mbox_active; | ||
3885 | pmbox = &pmb->mb; | ||
3886 | mbox = &phba->slim2p->mbx; | ||
3887 | vport = pmb->vport; | ||
3888 | |||
3889 | /* First check out the status word */ | ||
3890 | lpfc_sli_pcimem_bcopy(mbox, pmbox, sizeof(uint32_t)); | ||
3891 | if (pmbox->mbxOwner != OWN_HOST) { | ||
3892 | /* | ||
3893 | * Stray Mailbox Interrupt, mbxCommand <cmd> | ||
3894 | * mbxStatus <status> | ||
3895 | */ | ||
3896 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | | ||
3897 | LOG_SLI, | ||
3898 | "%d (%d):0304 Stray Mailbox " | ||
3899 | "Interrupt mbxCommand x%x " | ||
3900 | "mbxStatus x%x\n", | ||
3901 | phba->brd_no, | ||
3902 | (vport | ||
3903 | ? vport->vpi : 0), | ||
3904 | pmbox->mbxCommand, | ||
3905 | pmbox->mbxStatus); | ||
3906 | } | ||
3907 | phba->last_completion_time = jiffies; | ||
3908 | del_timer_sync(&phba->sli.mbox_tmo); | ||
3909 | |||
3910 | phba->sli.mbox_active = NULL; | ||
3911 | if (pmb->mbox_cmpl) { | ||
3912 | lpfc_sli_pcimem_bcopy(mbox, pmbox, | ||
3913 | MAILBOX_CMD_SIZE); | ||
3914 | } | ||
3915 | if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { | ||
3916 | pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; | ||
3917 | |||
3918 | lpfc_debugfs_disc_trc(vport, | ||
3919 | LPFC_DISC_TRC_MBOX_VPORT, | ||
3920 | "MBOX dflt rpi: : status:x%x rpi:x%x", | ||
3921 | (uint32_t)pmbox->mbxStatus, | ||
3922 | pmbox->un.varWords[0], 0); | ||
3923 | |||
3924 | if ( !pmbox->mbxStatus) { | ||
3925 | mp = (struct lpfc_dmabuf *) | ||
3926 | (pmb->context1); | ||
3927 | ndlp = (struct lpfc_nodelist *) | ||
3928 | pmb->context2; | ||
3929 | |||
3930 | /* Reg_LOGIN of dflt RPI was successful. | ||
3931 | * new lets get rid of the RPI using the | ||
3932 | * same mbox buffer. | ||
3933 | */ | ||
3934 | lpfc_unreg_login(phba, vport->vpi, | ||
3935 | pmbox->un.varWords[0], pmb); | ||
3936 | pmb->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; | ||
3937 | pmb->context1 = mp; | ||
3938 | pmb->context2 = ndlp; | ||
3939 | pmb->vport = vport; | ||
3940 | spin_lock(&phba->hbalock); | ||
3941 | phba->sli.sli_flag &= | ||
3942 | ~LPFC_SLI_MBOX_ACTIVE; | ||
3943 | spin_unlock(&phba->hbalock); | ||
3944 | goto send_current_mbox; | ||
3945 | } | ||
3946 | } | ||
3947 | spin_lock(&phba->pport->work_port_lock); | ||
3948 | phba->pport->work_port_events &= ~WORKER_MBOX_TMO; | ||
3949 | spin_unlock(&phba->pport->work_port_lock); | ||
3950 | lpfc_mbox_cmpl_put(phba, pmb); | ||
3951 | } | ||
3952 | if ((work_ha_copy & HA_MBATT) && | ||
3953 | (phba->sli.mbox_active == NULL)) { | ||
3954 | send_next_mbox: | ||
3955 | spin_lock(&phba->hbalock); | ||
3956 | phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | ||
3957 | pmb = lpfc_mbox_get(phba); | ||
3958 | spin_unlock(&phba->hbalock); | ||
3959 | send_current_mbox: | ||
3960 | /* Process next mailbox command if there is one */ | ||
3961 | if (pmb != NULL) { | ||
3962 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | ||
3963 | if (rc == MBX_NOT_FINISHED) { | ||
3964 | pmb->mb.mbxStatus = MBX_NOT_FINISHED; | ||
3965 | lpfc_mbox_cmpl_put(phba, pmb); | ||
3966 | goto send_next_mbox; | ||
3967 | } | ||
3968 | } else { | ||
3969 | /* Turn on IOCB processing */ | ||
3970 | for (i = 0; i < phba->sli.num_rings; i++) | ||
3971 | lpfc_sli_turn_on_ring(phba, i); | ||
3972 | } | ||
3973 | |||
3283 | } | 3974 | } |
3284 | 3975 | ||
3285 | spin_lock(phba->host->host_lock); | 3976 | spin_lock(&phba->hbalock); |
3286 | phba->work_ha |= work_ha_copy; | 3977 | phba->work_ha |= work_ha_copy; |
3287 | if (phba->work_wait) | 3978 | if (phba->work_wait) |
3288 | wake_up(phba->work_wait); | 3979 | lpfc_worker_wake_up(phba); |
3289 | spin_unlock(phba->host->host_lock); | 3980 | spin_unlock(&phba->hbalock); |
3290 | } | 3981 | } |
3291 | 3982 | ||
3292 | ha_copy &= ~(phba->work_ha_mask); | 3983 | ha_copy &= ~(phba->work_ha_mask); |
@@ -3298,7 +3989,7 @@ lpfc_intr_handler(int irq, void *dev_id) | |||
3298 | */ | 3989 | */ |
3299 | status = (ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); | 3990 | status = (ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); |
3300 | status >>= (4*LPFC_FCP_RING); | 3991 | status >>= (4*LPFC_FCP_RING); |
3301 | if (status & HA_RXATT) | 3992 | if (status & HA_RXMASK) |
3302 | lpfc_sli_handle_fast_ring_event(phba, | 3993 | lpfc_sli_handle_fast_ring_event(phba, |
3303 | &phba->sli.ring[LPFC_FCP_RING], | 3994 | &phba->sli.ring[LPFC_FCP_RING], |
3304 | status); | 3995 | status); |
@@ -3311,7 +4002,7 @@ lpfc_intr_handler(int irq, void *dev_id) | |||
3311 | */ | 4002 | */ |
3312 | status = (ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); | 4003 | status = (ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); |
3313 | status >>= (4*LPFC_EXTRA_RING); | 4004 | status >>= (4*LPFC_EXTRA_RING); |
3314 | if (status & HA_RXATT) { | 4005 | if (status & HA_RXMASK) { |
3315 | lpfc_sli_handle_fast_ring_event(phba, | 4006 | lpfc_sli_handle_fast_ring_event(phba, |
3316 | &phba->sli.ring[LPFC_EXTRA_RING], | 4007 | &phba->sli.ring[LPFC_EXTRA_RING], |
3317 | status); | 4008 | status); |