2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
10 * IO descriptor handle definitions.
14 * |31------28|27-------------------12|11-------0|
15 * | Type | Rolling Signature | Index |
16 * |----------|-----------------------|----------|
20 #define HDL_TYPE_SCSI 0
21 #define HDL_TYPE_ASYNC_IOCB 0x0A
23 #define HDL_INDEX_BITS 12
24 #define HDL_ITER_BITS 16
25 #define HDL_TYPE_BITS 4
27 #define HDL_INDEX_MASK ((1UL << HDL_INDEX_BITS) - 1)
28 #define HDL_ITER_MASK ((1UL << HDL_ITER_BITS) - 1)
29 #define HDL_TYPE_MASK ((1UL << HDL_TYPE_BITS) - 1)
31 #define HDL_INDEX_SHIFT 0
32 #define HDL_ITER_SHIFT (HDL_INDEX_SHIFT + HDL_INDEX_BITS)
33 #define HDL_TYPE_SHIFT (HDL_ITER_SHIFT + HDL_ITER_BITS)
35 /* Local Prototypes. */
36 static inline uint32_t qla2x00_to_handle(uint16_t, uint16_t, uint16_t);
37 static inline uint16_t qla2x00_handle_to_idx(uint32_t);
38 static inline uint32_t qla2x00_iodesc_to_handle(struct io_descriptor *);
39 static inline struct io_descriptor *qla2x00_handle_to_iodesc(scsi_qla_host_t *,
42 static inline struct io_descriptor *qla2x00_alloc_iodesc(scsi_qla_host_t *);
43 static inline void qla2x00_free_iodesc(struct io_descriptor *);
44 static inline void qla2x00_init_io_descriptors(scsi_qla_host_t *);
46 static void qla2x00_iodesc_timeout(unsigned long);
47 static inline void qla2x00_add_iodesc_timer(struct io_descriptor *);
48 static inline void qla2x00_remove_iodesc_timer(struct io_descriptor *);
50 static inline void qla2x00_update_login_fcport(scsi_qla_host_t *,
51 struct mbx_entry *, fc_port_t *);
53 static int qla2x00_send_abort_iocb(scsi_qla_host_t *, struct io_descriptor *,
55 static int qla2x00_send_abort_iocb_cb(scsi_qla_host_t *, struct io_descriptor *,
58 static int qla2x00_send_adisc_iocb(scsi_qla_host_t *, struct io_descriptor *,
60 static int qla2x00_send_adisc_iocb_cb(scsi_qla_host_t *, struct io_descriptor *,
63 static int qla2x00_send_logout_iocb(scsi_qla_host_t *, struct io_descriptor *,
65 static int qla2x00_send_logout_iocb_cb(scsi_qla_host_t *,
66 struct io_descriptor *, struct mbx_entry *);
68 static int qla2x00_send_login_iocb(scsi_qla_host_t *, struct io_descriptor *,
70 static int qla2x00_send_login_iocb_cb(scsi_qla_host_t *, struct io_descriptor *,
74 * Mailbox IOCB callback array.
76 static int (*iocb_function_cb_list[LAST_IOCB_CB])
77 (scsi_qla_host_t *, struct io_descriptor *, struct mbx_entry *) = {
79 qla2x00_send_abort_iocb_cb,
80 qla2x00_send_adisc_iocb_cb,
81 qla2x00_send_logout_iocb_cb,
82 qla2x00_send_login_iocb_cb,
87 * Generic IO descriptor handle routines.
91 * qla2x00_to_handle() - Create a descriptor handle.
92 * @type: descriptor type
93 * @iter: descriptor rolling signature
94 * @idx: index to the descriptor array
96 * Returns a composite handle based in the @type, @iter, and @idx.
98 static inline uint32_t
99 qla2x00_to_handle(uint16_t type, uint16_t iter, uint16_t idx)
101 return ((uint32_t)(((uint32_t)type << HDL_TYPE_SHIFT) |
102 ((uint32_t)iter << HDL_ITER_SHIFT) |
103 ((uint32_t)idx << HDL_INDEX_SHIFT)));
107 * qla2x00_handle_to_idx() - Retrive the index for a given handle.
108 * @handle: descriptor handle
110 * Returns the index specified by the @handle.
112 static inline uint16_t
113 qla2x00_handle_to_idx(uint32_t handle)
115 return ((uint16_t)(((handle) >> HDL_INDEX_SHIFT) & HDL_INDEX_MASK));
119 * qla2x00_iodesc_to_handle() - Convert an IO descriptor to a unique handle.
120 * @iodesc: io descriptor
122 * Returns a unique handle for @iodesc.
124 static inline uint32_t
125 qla2x00_iodesc_to_handle(struct io_descriptor *iodesc)
129 handle = qla2x00_to_handle(HDL_TYPE_ASYNC_IOCB,
130 ++iodesc->ha->iodesc_signature, iodesc->idx);
131 iodesc->signature = handle;
137 * qla2x00_handle_to_iodesc() - Retrieve an IO descriptor given a unique handle.
139 * @handle: handle to io descriptor
141 * Returns a pointer to the io descriptor, or NULL, if the io descriptor does
142 * not exist or the io descriptors signature does not @handle.
144 static inline struct io_descriptor *
145 qla2x00_handle_to_iodesc(scsi_qla_host_t *ha, uint32_t handle)
148 struct io_descriptor *iodesc;
150 idx = qla2x00_handle_to_idx(handle);
151 iodesc = &ha->io_descriptors[idx];
153 if (iodesc->signature != handle)
161 * IO descriptor allocation routines.
165 * qla2x00_alloc_iodesc() - Allocate an IO descriptor from the pool.
168 * Returns a pointer to the allocated io descriptor, or NULL, if none available.
170 static inline struct io_descriptor *
171 qla2x00_alloc_iodesc(scsi_qla_host_t *ha)
174 struct io_descriptor *iodesc;
177 for (iter = 0; iter < MAX_IO_DESCRIPTORS; iter++) {
178 if (ha->io_descriptors[iter].used)
181 iodesc = &ha->io_descriptors[iter];
184 init_timer(&iodesc->timer);
186 iodesc->signature = qla2x00_iodesc_to_handle(iodesc);
194 * qla2x00_free_iodesc() - Free an IO descriptor.
195 * @iodesc: io descriptor
197 * NOTE: The io descriptors timer *must* be stopped before it can be free'd.
200 qla2x00_free_iodesc(struct io_descriptor *iodesc)
203 iodesc->signature = 0;
207 * qla2x00_remove_iodesc_timer() - Remove an active timer from an IO descriptor.
208 * @iodesc: io descriptor
211 qla2x00_remove_iodesc_timer(struct io_descriptor *iodesc)
213 if (iodesc->timer.function != NULL) {
214 del_timer_sync(&iodesc->timer);
215 iodesc->timer.data = (unsigned long) NULL;
216 iodesc->timer.function = NULL;
221 * qla2x00_init_io_descriptors() - Initialize the pool of IO descriptors.
225 qla2x00_init_io_descriptors(scsi_qla_host_t *ha)
229 for (iter = 0; iter < MAX_IO_DESCRIPTORS; iter++) {
230 if (!ha->io_descriptors[iter].used)
233 qla2x00_remove_iodesc_timer(&ha->io_descriptors[iter]);
234 qla2x00_free_iodesc(&ha->io_descriptors[iter]);
240 * IO descriptor timer routines.
244 * qla2x00_iodesc_timeout() - Timeout IO descriptor handler.
245 * @data: io descriptor
248 qla2x00_iodesc_timeout(unsigned long data)
250 struct io_descriptor *iodesc;
252 iodesc = (struct io_descriptor *) data;
254 DEBUG14(printk("scsi(%ld): IO descriptor timeout, index=%x "
255 "signature=%08x, scheduling ISP abort.\n", iodesc->ha->host_no,
256 iodesc->idx, iodesc->signature));
258 qla2x00_free_iodesc(iodesc);
260 qla_printk(KERN_WARNING, iodesc->ha,
261 "IO descriptor timeout. Scheduling ISP abort.\n");
262 set_bit(ISP_ABORT_NEEDED, &iodesc->ha->dpc_flags);
266 * qla2x00_add_iodesc_timer() - Add and start a timer for an IO descriptor.
267 * @iodesc: io descriptor
270 * The firmware shall timeout an outstanding mailbox IOCB in 2 * R_A_TOV (in
271 * tenths of a second) after it hits the wire. But, if there are any request
272 * resource contraints (i.e. during heavy I/O), exchanges can be held off for
273 * at most R_A_TOV. Therefore, the driver will wait 4 * R_A_TOV before
274 * scheduling a recovery (big hammer).
277 qla2x00_add_iodesc_timer(struct io_descriptor *iodesc)
279 unsigned long timeout;
281 timeout = (iodesc->ha->r_a_tov * 4) / 10;
282 init_timer(&iodesc->timer);
283 iodesc->timer.data = (unsigned long) iodesc;
284 iodesc->timer.expires = jiffies + (timeout * HZ);
285 iodesc->timer.function =
286 (void (*) (unsigned long)) qla2x00_iodesc_timeout;
287 add_timer(&iodesc->timer);
291 * IO descriptor support routines.
295 * qla2x00_update_login_fcport() - Update fcport data after login processing.
297 * @mbxstat: Mailbox command status IOCB
298 * @fcport: port to update
301 qla2x00_update_login_fcport(scsi_qla_host_t *ha, struct mbx_entry *mbxstat,
304 if (le16_to_cpu(mbxstat->mb1) & BIT_0) {
305 fcport->port_type = FCT_INITIATOR;
307 fcport->port_type = FCT_TARGET;
308 if (le16_to_cpu(mbxstat->mb1) & BIT_1) {
309 fcport->flags |= FCF_TAPE_PRESENT;
312 fcport->login_retry = 0;
313 fcport->port_login_retry_count = ha->port_down_retry_count *
315 atomic_set(&fcport->port_down_timer, ha->port_down_retry_count *
317 fcport->flags |= FCF_FABRIC_DEVICE;
318 fcport->flags &= ~FCF_FAILOVER_NEEDED;
319 fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
320 atomic_set(&fcport->state, FCS_ONLINE);
325 * Mailbox IOCB commands.
329 * qla2x00_get_mbx_iocb_entry() - Retrieve an IOCB from the request queue.
331 * @handle: handle to io descriptor
333 * Returns a pointer to the reqest entry, or NULL, if none were available.
335 static inline struct mbx_entry *
336 qla2x00_get_mbx_iocb_entry(scsi_qla_host_t *ha, uint32_t handle)
339 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
340 struct mbx_entry *mbxentry;
344 if (ha->req_q_cnt < 3) {
345 cnt = qla2x00_debounce_register(ISP_REQ_Q_OUT(ha, reg));
346 if (ha->req_ring_index < cnt)
347 ha->req_q_cnt = cnt - ha->req_ring_index;
349 ha->req_q_cnt = ha->request_q_length -
350 (ha->req_ring_index - cnt);
352 if (ha->req_q_cnt >= 3) {
353 mbxentry = (struct mbx_entry *)ha->request_ring_ptr;
355 memset(mbxentry, 0, sizeof(struct mbx_entry));
356 mbxentry->entry_type = MBX_IOCB_TYPE;
357 mbxentry->entry_count = 1;
358 mbxentry->sys_define1 = SOURCE_ASYNC_IOCB;
359 mbxentry->handle = handle;
365 * qla2x00_send_abort_iocb() - Issue an abort IOCB to the firmware.
367 * @iodesc: io descriptor
368 * @handle_to_abort: firmware handle to abort
369 * @ha_locked: is function called with the hardware lock
371 * Returns QLA_SUCCESS if the IOCB was issued.
374 qla2x00_send_abort_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
375 uint32_t handle_to_abort, int ha_locked)
377 unsigned long flags = 0;
378 struct mbx_entry *mbxentry;
380 /* Send marker if required. */
381 if (qla2x00_issue_marker(ha, ha_locked) != QLA_SUCCESS)
382 return (QLA_FUNCTION_FAILED);
385 spin_lock_irqsave(&ha->hardware_lock, flags);
387 /* Build abort mailbox IOCB. */
388 mbxentry = qla2x00_get_mbx_iocb_entry(ha, iodesc->signature);
389 if (mbxentry == NULL) {
391 spin_unlock_irqrestore(&ha->hardware_lock, flags);
393 return (QLA_FUNCTION_FAILED);
395 mbxentry->mb0 = __constant_cpu_to_le16(MBC_ABORT_COMMAND);
396 mbxentry->mb1 = mbxentry->loop_id.extended =
397 cpu_to_le16(iodesc->remote_fcport->loop_id);
398 mbxentry->mb2 = LSW(handle_to_abort);
399 mbxentry->mb3 = MSW(handle_to_abort);
402 qla2x00_add_iodesc_timer(iodesc);
404 /* Issue command to ISP. */
408 spin_unlock_irqrestore(&ha->hardware_lock, flags);
410 DEBUG14(printk("scsi(%ld): Sending Abort IOCB (%08x) to [%x], aborting "
411 "%08x.\n", ha->host_no, iodesc->signature,
412 iodesc->remote_fcport->loop_id, handle_to_abort));
414 return (QLA_SUCCESS);
418 * qla2x00_send_abort_iocb_cb() - Abort IOCB callback.
420 * @iodesc: io descriptor
421 * @mbxstat: mailbox status IOCB
423 * Returns QLA_SUCCESS if @iodesc can be freed by the caller, else, @iodesc
424 * will be used for a retry.
427 qla2x00_send_abort_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
428 struct mbx_entry *mbxstat)
430 DEBUG14(printk("scsi(%ld): Abort IOCB -- sent to [%x/%02x%02x%02x], "
431 "status=%x mb0=%x.\n", ha->host_no, iodesc->remote_fcport->loop_id,
432 iodesc->d_id.b.domain, iodesc->d_id.b.area, iodesc->d_id.b.al_pa,
433 le16_to_cpu(mbxstat->status), le16_to_cpu(mbxstat->mb0)));
435 return (QLA_SUCCESS);
440 * qla2x00_send_adisc_iocb() - Issue a Get Port Database IOCB to the firmware.
442 * @iodesc: io descriptor
443 * @ha_locked: is function called with the hardware lock
445 * Returns QLA_SUCCESS if the IOCB was issued.
448 qla2x00_send_adisc_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
451 unsigned long flags = 0;
452 struct mbx_entry *mbxentry;
454 /* Send marker if required. */
455 if (qla2x00_issue_marker(ha, ha_locked) != QLA_SUCCESS)
456 return (QLA_FUNCTION_FAILED);
459 spin_lock_irqsave(&ha->hardware_lock, flags);
461 /* Build Get Port Database IOCB. */
462 mbxentry = qla2x00_get_mbx_iocb_entry(ha, iodesc->signature);
463 if (mbxentry == NULL) {
465 spin_unlock_irqrestore(&ha->hardware_lock, flags);
467 return (QLA_FUNCTION_FAILED);
469 mbxentry->mb0 = __constant_cpu_to_le16(MBC_GET_PORT_DATABASE);
470 mbxentry->mb1 = mbxentry->loop_id.extended =
471 cpu_to_le16(iodesc->remote_fcport->loop_id);
472 mbxentry->mb2 = cpu_to_le16(MSW(LSD(ha->iodesc_pd_dma)));
473 mbxentry->mb3 = cpu_to_le16(LSW(LSD(ha->iodesc_pd_dma)));
474 mbxentry->mb6 = cpu_to_le16(MSW(MSD(ha->iodesc_pd_dma)));
475 mbxentry->mb7 = cpu_to_le16(LSW(MSD(ha->iodesc_pd_dma)));
476 mbxentry->mb10 = __constant_cpu_to_le16(BIT_0);
479 qla2x00_add_iodesc_timer(iodesc);
481 /* Issue command to ISP. */
485 spin_unlock_irqrestore(&ha->hardware_lock, flags);
487 DEBUG14(printk("scsi(%ld): Sending Adisc IOCB (%08x) to [%x].\n",
488 ha->host_no, iodesc->signature, iodesc->remote_fcport->loop_id));
490 return (QLA_SUCCESS);
494 * qla2x00_send_adisc_iocb_cb() - Get Port Database IOCB callback.
496 * @iodesc: io descriptor
497 * @mbxstat: mailbox status IOCB
499 * Returns QLA_SUCCESS if @iodesc can be freed by the caller, else, @iodesc
500 * will be used for a retry.
503 qla2x00_send_adisc_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
504 struct mbx_entry *mbxstat)
506 fc_port_t *remote_fcport;
508 remote_fcport = iodesc->remote_fcport;
510 /* Ensure the port IDs are consistent. */
511 if (remote_fcport->d_id.b24 != iodesc->d_id.b24) {
512 DEBUG14(printk("scsi(%ld): Adisc IOCB -- ignoring, remote port "
513 "id changed from [%02x%02x%02x] to [%02x%02x%02x].\n",
514 ha->host_no, remote_fcport->d_id.b.domain,
515 remote_fcport->d_id.b.area, remote_fcport->d_id.b.al_pa,
516 iodesc->d_id.b.domain, iodesc->d_id.b.area,
517 iodesc->d_id.b.al_pa));
519 return (QLA_SUCCESS);
522 /* Only process the last command. */
523 if (remote_fcport->iodesc_idx_sent != iodesc->idx) {
524 DEBUG14(printk("scsi(%ld): Adisc IOCB -- ignoring, sent to "
525 "[%02x%02x%02x], expected %x, received %x.\n", ha->host_no,
526 iodesc->d_id.b.domain, iodesc->d_id.b.area,
527 iodesc->d_id.b.al_pa, remote_fcport->iodesc_idx_sent,
530 return (QLA_SUCCESS);
533 if (le16_to_cpu(mbxstat->status) == CS_COMPLETE) {
534 DEBUG14(printk("scsi(%ld): Adisc IOCB -- marking "
535 "[%x/%02x%02x%02x] online.\n", ha->host_no,
536 remote_fcport->loop_id, remote_fcport->d_id.b.domain,
537 remote_fcport->d_id.b.area, remote_fcport->d_id.b.al_pa));
539 atomic_set(&remote_fcport->state, FCS_ONLINE);
541 DEBUG14(printk("scsi(%ld): Adisc IOCB -- marking "
542 "[%x/%02x%02x%02x] lost, status=%x mb0=%x.\n", ha->host_no,
543 remote_fcport->loop_id, remote_fcport->d_id.b.domain,
544 remote_fcport->d_id.b.area, remote_fcport->d_id.b.al_pa,
545 le16_to_cpu(mbxstat->status), le16_to_cpu(mbxstat->mb0)));
547 if (atomic_read(&remote_fcport->state) != FCS_DEVICE_DEAD)
548 atomic_set(&remote_fcport->state, FCS_DEVICE_LOST);
550 remote_fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
552 return (QLA_SUCCESS);
557 * qla2x00_send_logout_iocb() - Issue a fabric port logout IOCB to the firmware.
559 * @iodesc: io descriptor
560 * @ha_locked: is function called with the hardware lock
562 * Returns QLA_SUCCESS if the IOCB was issued.
565 qla2x00_send_logout_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
568 unsigned long flags = 0;
569 struct mbx_entry *mbxentry;
571 /* Send marker if required. */
572 if (qla2x00_issue_marker(ha, ha_locked) != QLA_SUCCESS)
573 return (QLA_FUNCTION_FAILED);
576 spin_lock_irqsave(&ha->hardware_lock, flags);
578 /* Build fabric port logout mailbox IOCB. */
579 mbxentry = qla2x00_get_mbx_iocb_entry(ha, iodesc->signature);
580 if (mbxentry == NULL) {
582 spin_unlock_irqrestore(&ha->hardware_lock, flags);
584 return (QLA_FUNCTION_FAILED);
586 mbxentry->mb0 = __constant_cpu_to_le16(MBC_LOGOUT_FABRIC_PORT);
587 mbxentry->mb1 = mbxentry->loop_id.extended =
588 cpu_to_le16(iodesc->remote_fcport->loop_id);
591 qla2x00_add_iodesc_timer(iodesc);
593 /* Issue command to ISP. */
597 spin_unlock_irqrestore(&ha->hardware_lock, flags);
599 DEBUG14(printk("scsi(%ld): Sending Logout IOCB (%08x) to [%x].\n",
600 ha->host_no, iodesc->signature, iodesc->remote_fcport->loop_id));
602 return (QLA_SUCCESS);
606 * qla2x00_send_logout_iocb_cb() - Fabric port logout IOCB callback.
608 * @iodesc: io descriptor
609 * @mbxstat: mailbox status IOCB
611 * Returns QLA_SUCCESS if @iodesc can be freed by the caller, else, @iodesc
612 * will be used for a retry.
615 qla2x00_send_logout_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
616 struct mbx_entry *mbxstat)
618 DEBUG14(printk("scsi(%ld): Logout IOCB -- sent to [%x/%02x%02x%02x], "
619 "status=%x mb0=%x mb1=%x.\n", ha->host_no,
620 iodesc->remote_fcport->loop_id,
621 iodesc->remote_fcport->d_id.b.domain,
622 iodesc->remote_fcport->d_id.b.area,
623 iodesc->remote_fcport->d_id.b.al_pa, le16_to_cpu(mbxstat->status),
624 le16_to_cpu(mbxstat->mb0), le16_to_cpu(mbxstat->mb1)));
626 return (QLA_SUCCESS);
631 * qla2x00_send_login_iocb() - Issue a fabric port login IOCB to the firmware.
633 * @iodesc: io descriptor
634 * @d_id: port id for device
635 * @ha_locked: is function called with the hardware lock
637 * Returns QLA_SUCCESS if the IOCB was issued.
640 qla2x00_send_login_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
641 port_id_t *d_id, int ha_locked)
643 unsigned long flags = 0;
644 struct mbx_entry *mbxentry;
646 /* Send marker if required. */
647 if (qla2x00_issue_marker(ha, ha_locked) != QLA_SUCCESS)
648 return (QLA_FUNCTION_FAILED);
651 spin_lock_irqsave(&ha->hardware_lock, flags);
653 /* Build fabric port login mailbox IOCB. */
654 mbxentry = qla2x00_get_mbx_iocb_entry(ha, iodesc->signature);
655 if (mbxentry == NULL) {
657 spin_unlock_irqrestore(&ha->hardware_lock, flags);
659 return (QLA_FUNCTION_FAILED);
661 mbxentry->mb0 = __constant_cpu_to_le16(MBC_LOGIN_FABRIC_PORT);
662 mbxentry->mb1 = mbxentry->loop_id.extended =
663 cpu_to_le16(iodesc->remote_fcport->loop_id);
664 mbxentry->mb2 = cpu_to_le16(d_id->b.domain);
665 mbxentry->mb3 = cpu_to_le16(d_id->b.area << 8 | d_id->b.al_pa);
666 mbxentry->mb10 = __constant_cpu_to_le16(BIT_0);
669 qla2x00_add_iodesc_timer(iodesc);
671 /* Issue command to ISP. */
675 spin_unlock_irqrestore(&ha->hardware_lock, flags);
677 DEBUG14(printk("scsi(%ld): Sending Login IOCB (%08x) to "
678 "[%x/%02x%02x%02x].\n", ha->host_no, iodesc->signature,
679 iodesc->remote_fcport->loop_id, d_id->b.domain, d_id->b.area,
682 return (QLA_SUCCESS);
686 * qla2x00_send_login_iocb_cb() - Fabric port logout IOCB callback.
688 * @iodesc: io descriptor
689 * @mbxstat: mailbox status IOCB
691 * Returns QLA_SUCCESS if @iodesc can be freed by the caller, else, @iodesc
692 * will be used for a retry.
695 qla2x00_send_login_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
696 struct mbx_entry *mbxstat)
699 fc_port_t *fcport, *remote_fcport, *exist_fcport;
700 struct io_descriptor *abort_iodesc, *login_iodesc;
701 uint16_t status, mb[8];
703 uint16_t remote_loopid;
704 port_id_t remote_did, inuse_did;
706 remote_fcport = iodesc->remote_fcport;
708 /* Only process the last command. */
709 if (remote_fcport->iodesc_idx_sent != iodesc->idx) {
710 DEBUG14(printk("scsi(%ld): Login IOCB -- ignoring, sent to "
711 "[%02x%02x%02x], expected %x, received %x.\n",
712 ha->host_no, iodesc->d_id.b.domain, iodesc->d_id.b.area,
713 iodesc->d_id.b.al_pa, remote_fcport->iodesc_idx_sent,
716 /* Free RSCN fcport resources. */
717 if (remote_fcport->port_type == FCT_RSCN) {
718 DEBUG14(printk("scsi(%ld): Login IOCB -- Freeing RSCN "
719 "fcport %p [%x/%02x%02x%02x] given ignored Login "
720 "IOCB.\n", ha->host_no, remote_fcport,
721 remote_fcport->loop_id,
722 remote_fcport->d_id.b.domain,
723 remote_fcport->d_id.b.area,
724 remote_fcport->d_id.b.al_pa));
726 list_del(&remote_fcport->list);
727 kfree(remote_fcport);
729 return (QLA_SUCCESS);
732 status = le16_to_cpu(mbxstat->status);
733 mb[0] = le16_to_cpu(mbxstat->mb0);
734 mb[1] = le16_to_cpu(mbxstat->mb1);
735 mb[2] = le16_to_cpu(mbxstat->mb2);
736 mb[6] = le16_to_cpu(mbxstat->mb6);
737 mb[7] = le16_to_cpu(mbxstat->mb7);
740 if ((status == CS_COMPLETE || status == CS_COMPLETE_CHKCOND) &&
741 mb[0] == MBS_COMMAND_COMPLETE) {
743 DEBUG14(printk("scsi(%ld): Login IOCB -- status=%x mb1=%x pn="
744 "%02x%02x%02x%02x%02x%02x%02x%02x.\n", ha->host_no, status,
745 mb[1], mbxstat->port_name[0], mbxstat->port_name[1],
746 mbxstat->port_name[2], mbxstat->port_name[3],
747 mbxstat->port_name[4], mbxstat->port_name[5],
748 mbxstat->port_name[6], mbxstat->port_name[7]));
750 memcpy(remote_fcport->node_name, mbxstat->node_name, WWN_SIZE);
751 memcpy(remote_fcport->port_name, mbxstat->port_name, WWN_SIZE);
753 /* Is the device already in our fcports list? */
754 if (remote_fcport->port_type != FCT_RSCN) {
755 DEBUG14(printk("scsi(%ld): Login IOCB -- marking "
756 "[%x/%02x%02x%02x] online.\n", ha->host_no,
757 remote_fcport->loop_id,
758 remote_fcport->d_id.b.domain,
759 remote_fcport->d_id.b.area,
760 remote_fcport->d_id.b.al_pa));
762 qla2x00_update_login_fcport(ha, mbxstat, remote_fcport);
764 return (QLA_SUCCESS);
767 /* Does the RSCN portname already exist in our fcports list? */
769 list_for_each_entry(fcport, &ha->fcports, list) {
770 if (memcmp(remote_fcport->port_name, fcport->port_name,
772 exist_fcport = fcport;
776 if (exist_fcport != NULL) {
777 DEBUG14(printk("scsi(%ld): Login IOCB -- found RSCN "
778 "fcport in fcports list [%p].\n", ha->host_no,
781 /* Abort any ADISC that could have been sent. */
782 if (exist_fcport->iodesc_idx_sent != iodesc->idx &&
783 exist_fcport->iodesc_idx_sent <
784 MAX_IO_DESCRIPTORS &&
785 ha->io_descriptors[exist_fcport->iodesc_idx_sent].
786 cb_idx == ADISC_PORT_IOCB_CB) {
788 abort_iodesc = qla2x00_alloc_iodesc(ha);
790 DEBUG14(printk("scsi(%ld): Login IOCB "
791 "-- issuing abort to outstanding "
792 "Adisc [%x/%02x%02x%02x].\n",
793 ha->host_no, remote_fcport->loop_id,
794 exist_fcport->d_id.b.domain,
795 exist_fcport->d_id.b.area,
796 exist_fcport->d_id.b.al_pa));
798 abort_iodesc->cb_idx = ABORT_IOCB_CB;
799 abort_iodesc->d_id.b24 =
800 exist_fcport->d_id.b24;
801 abort_iodesc->remote_fcport =
803 exist_fcport->iodesc_idx_sent =
805 qla2x00_send_abort_iocb(ha,
806 abort_iodesc, ha->io_descriptors[
807 exist_fcport->iodesc_idx_sent].
810 DEBUG14(printk("scsi(%ld): Login IOCB "
811 "-- unable to abort outstanding "
812 "Adisc [%x/%02x%02x%02x].\n",
813 ha->host_no, remote_fcport->loop_id,
814 exist_fcport->d_id.b.domain,
815 exist_fcport->d_id.b.area,
816 exist_fcport->d_id.b.al_pa));
821 * If the existing fcport is waiting to send an ADISC
822 * or LOGIN, then reuse remote fcport (RSCN) to
826 remote_loopid = remote_fcport->loop_id;
827 remote_did.b24 = remote_fcport->d_id.b24;
828 if (exist_fcport->iodesc_idx_sent ==
829 IODESC_ADISC_NEEDED ||
830 exist_fcport->iodesc_idx_sent ==
831 IODESC_LOGIN_NEEDED) {
832 DEBUG14(printk("scsi(%ld): Login IOCB -- "
833 "existing fcport [%x/%02x%02x%02x] "
834 "waiting for IO descriptor, reuse RSCN "
835 "fcport.\n", ha->host_no,
836 exist_fcport->loop_id,
837 exist_fcport->d_id.b.domain,
838 exist_fcport->d_id.b.area,
839 exist_fcport->d_id.b.al_pa));
842 remote_fcport->iodesc_idx_sent =
843 exist_fcport->iodesc_idx_sent;
844 exist_fcport->iodesc_idx_sent =
845 IODESC_INVALID_INDEX;
846 remote_fcport->loop_id = exist_fcport->loop_id;
847 remote_fcport->d_id.b24 =
848 exist_fcport->d_id.b24;
851 /* Logout the old loopid. */
853 exist_fcport->loop_id != remote_fcport->loop_id &&
854 exist_fcport->loop_id != FC_NO_LOOP_ID) {
855 login_iodesc = qla2x00_alloc_iodesc(ha);
857 DEBUG14(printk("scsi(%ld): Login IOCB "
858 "-- issuing logout to free old "
859 "loop id [%x/%02x%02x%02x].\n",
860 ha->host_no, exist_fcport->loop_id,
861 exist_fcport->d_id.b.domain,
862 exist_fcport->d_id.b.area,
863 exist_fcport->d_id.b.al_pa));
865 login_iodesc->cb_idx =
867 login_iodesc->d_id.b24 =
868 exist_fcport->d_id.b24;
869 login_iodesc->remote_fcport =
871 exist_fcport->iodesc_idx_sent =
873 qla2x00_send_logout_iocb(ha,
876 /* Ran out of IO descriptiors. */
877 DEBUG14(printk("scsi(%ld): Login IOCB "
878 "-- unable to logout to free old "
879 "loop id [%x/%02x%02x%02x].\n",
880 ha->host_no, exist_fcport->loop_id,
881 exist_fcport->d_id.b.domain,
882 exist_fcport->d_id.b.area,
883 exist_fcport->d_id.b.al_pa));
885 exist_fcport->iodesc_idx_sent =
886 IODESC_INVALID_INDEX;
891 /* Update existing fcport with remote fcport info. */
892 DEBUG14(printk("scsi(%ld): Login IOCB -- marking "
893 "existing fcport [%x/%02x%02x%02x] online.\n",
894 ha->host_no, remote_loopid, remote_did.b.domain,
895 remote_did.b.area, remote_did.b.al_pa));
897 memcpy(exist_fcport->node_name,
898 remote_fcport->node_name, WWN_SIZE);
899 exist_fcport->loop_id = remote_loopid;
900 exist_fcport->d_id.b24 = remote_did.b24;
901 qla2x00_update_login_fcport(ha, mbxstat, exist_fcport);
903 /* Finally, free the remote (RSCN) fcport. */
905 DEBUG14(printk("scsi(%ld): Login IOCB -- "
906 "Freeing RSCN fcport %p "
907 "[%x/%02x%02x%02x].\n", ha->host_no,
908 remote_fcport, remote_fcport->loop_id,
909 remote_fcport->d_id.b.domain,
910 remote_fcport->d_id.b.area,
911 remote_fcport->d_id.b.al_pa));
913 list_del(&remote_fcport->list);
914 kfree(remote_fcport);
917 return (QLA_SUCCESS);
921 * A new device has been added, move the RSCN fcport to our
924 DEBUG14(printk("scsi(%ld): Login IOCB -- adding RSCN fcport "
925 "[%x/%02x%02x%02x] to fcports list.\n", ha->host_no,
926 remote_fcport->loop_id, remote_fcport->d_id.b.domain,
927 remote_fcport->d_id.b.area, remote_fcport->d_id.b.al_pa));
929 list_del(&remote_fcport->list);
930 remote_fcport->flags = (FCF_RLC_SUPPORT | FCF_RESCAN_NEEDED);
931 qla2x00_update_login_fcport(ha, mbxstat, remote_fcport);
932 list_add_tail(&remote_fcport->list, &ha->fcports);
933 set_bit(FCPORT_RESCAN_NEEDED, &ha->dpc_flags);
935 /* Handle login failure. */
936 if (remote_fcport->login_retry != 0) {
937 if (mb[0] == MBS_LOOP_ID_USED) {
938 inuse_did.b.domain = LSB(mb[1]);
939 inuse_did.b.area = MSB(mb[2]);
940 inuse_did.b.al_pa = LSB(mb[2]);
942 DEBUG14(printk("scsi(%ld): Login IOCB -- loop "
943 "id [%x] used by port id [%02x%02x%02x].\n",
944 ha->host_no, remote_fcport->loop_id,
945 inuse_did.b.domain, inuse_did.b.area,
948 if (remote_fcport->d_id.b24 ==
951 * Invalid port id means we are trying
952 * to login to a remote port with just
953 * a loop id without knowing about the
954 * port id. Copy the port id and try
957 remote_fcport->d_id.b24 = inuse_did.b24;
958 iodesc->d_id.b24 = inuse_did.b24;
960 remote_fcport->loop_id++;
961 rval = qla2x00_find_new_loop_id(ha,
963 if (rval == QLA_FUNCTION_FAILED) {
964 /* No more loop ids. */
965 return (QLA_SUCCESS);
968 } else if (mb[0] == MBS_PORT_ID_USED) {
970 * Device has another loop ID. The firmware
971 * group recommends the driver perform an
972 * implicit login with the specified ID.
974 DEBUG14(printk("scsi(%ld): Login IOCB -- port "
975 "id [%02x%02x%02x] already assigned to "
976 "loop id [%x].\n", ha->host_no,
977 iodesc->d_id.b.domain, iodesc->d_id.b.area,
978 iodesc->d_id.b.al_pa, mb[1]));
980 remote_fcport->loop_id = mb[1];
983 /* Unable to perform login, try again. */
984 DEBUG14(printk("scsi(%ld): Login IOCB -- "
985 "failed login [%x/%02x%02x%02x], status=%x "
986 "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n",
987 ha->host_no, remote_fcport->loop_id,
988 iodesc->d_id.b.domain, iodesc->d_id.b.area,
989 iodesc->d_id.b.al_pa, status, mb[0], mb[1],
990 mb[2], mb[6], mb[7]));
993 /* Reissue Login with the same IO descriptor. */
995 qla2x00_iodesc_to_handle(iodesc);
996 iodesc->cb_idx = LOGIN_PORT_IOCB_CB;
997 iodesc->d_id.b24 = remote_fcport->d_id.b24;
998 remote_fcport->iodesc_idx_sent = iodesc->idx;
999 remote_fcport->login_retry--;
1001 DEBUG14(printk("scsi(%ld): Login IOCB -- retrying "
1002 "login to [%x/%02x%02x%02x] (%d).\n", ha->host_no,
1003 remote_fcport->loop_id,
1004 remote_fcport->d_id.b.domain,
1005 remote_fcport->d_id.b.area,
1006 remote_fcport->d_id.b.al_pa,
1007 remote_fcport->login_retry));
1009 qla2x00_send_login_iocb(ha, iodesc,
1010 &remote_fcport->d_id, 1);
1012 return (QLA_FUNCTION_FAILED);
1014 /* No more logins, mark device dead. */
1015 DEBUG14(printk("scsi(%ld): Login IOCB -- failed "
1016 "login [%x/%02x%02x%02x] after retries, status=%x "
1017 "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n",
1018 ha->host_no, remote_fcport->loop_id,
1019 iodesc->d_id.b.domain, iodesc->d_id.b.area,
1020 iodesc->d_id.b.al_pa, status, mb[0], mb[1],
1021 mb[2], mb[6], mb[7]));
1023 atomic_set(&remote_fcport->state, FCS_DEVICE_DEAD);
1024 if (remote_fcport->port_type == FCT_RSCN) {
1025 DEBUG14(printk("scsi(%ld): Login IOCB -- "
1026 "Freeing dead RSCN fcport %p "
1027 "[%x/%02x%02x%02x].\n", ha->host_no,
1028 remote_fcport, remote_fcport->loop_id,
1029 remote_fcport->d_id.b.domain,
1030 remote_fcport->d_id.b.area,
1031 remote_fcport->d_id.b.al_pa));
1033 list_del(&remote_fcport->list);
1034 kfree(remote_fcport);
1039 return (QLA_SUCCESS);
1044 * IO descriptor processing routines.
1048 * qla2x00_alloc_rscn_fcport() - Allocate an RSCN type fcport.
1050 * @flags: allocation flags
1052 * Returns a pointer to the allocated RSCN fcport, or NULL, if none available.
1055 qla2x00_alloc_rscn_fcport(scsi_qla_host_t *ha, gfp_t flags)
1059 fcport = qla2x00_alloc_fcport(ha, flags);
1063 /* Setup RSCN fcport structure. */
1064 fcport->port_type = FCT_RSCN;
1070 * qla2x00_handle_port_rscn() - Handle port RSCN.
1072 * @rscn_entry: RSCN entry
1073 * @fcport: fcport entry to updated
1075 * Returns QLA_SUCCESS if the port RSCN was handled.
1078 qla2x00_handle_port_rscn(scsi_qla_host_t *ha, uint32_t rscn_entry,
1079 fc_port_t *known_fcport, int ha_locked)
1083 fc_port_t *fcport, *remote_fcport, *rscn_fcport;
1084 struct io_descriptor *iodesc;
1086 remote_fcport = NULL;
1089 /* Prepare port id based on incoming entries. */
1091 rscn_pid.b24 = known_fcport->d_id.b24;
1092 remote_fcport = known_fcport;
1094 DEBUG14(printk("scsi(%ld): Handle RSCN -- process RSCN for "
1095 "fcport [%02x%02x%02x].\n", ha->host_no,
1096 remote_fcport->d_id.b.domain, remote_fcport->d_id.b.area,
1097 remote_fcport->d_id.b.al_pa));
1099 rscn_pid.b.domain = LSB(MSW(rscn_entry));
1100 rscn_pid.b.area = MSB(LSW(rscn_entry));
1101 rscn_pid.b.al_pa = LSB(LSW(rscn_entry));
1103 DEBUG14(printk("scsi(%ld): Handle RSCN -- process RSCN for "
1104 "port id [%02x%02x%02x].\n", ha->host_no,
1105 rscn_pid.b.domain, rscn_pid.b.area, rscn_pid.b.al_pa));
1108 * Search fcport lists for a known entry at the specified port
1111 list_for_each_entry(fcport, &ha->fcports, list) {
1112 if (rscn_pid.b24 == fcport->d_id.b24) {
1113 remote_fcport = fcport;
1117 list_for_each_entry(fcport, &ha->rscn_fcports, list) {
1118 if (rscn_pid.b24 == fcport->d_id.b24) {
1119 rscn_fcport = fcport;
1123 if (remote_fcport == NULL)
1124 remote_fcport = rscn_fcport;
1128 * If the port is already in our fcport list and online, send an ADISC
1129 * to see if it's still alive. Issue login if a new fcport or the known
1130 * fcport is currently offline.
1132 if (remote_fcport) {
1134 * No need to send request if the remote fcport is currently
1135 * waiting for an available io descriptor.
1137 if (known_fcport == NULL &&
1138 (remote_fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED ||
1139 remote_fcport->iodesc_idx_sent == IODESC_LOGIN_NEEDED)) {
1141 * If previous waiting io descriptor is an ADISC, then
1142 * the new RSCN may come from a new remote fcport being
1143 * plugged into the same location.
1145 if (remote_fcport->port_type == FCT_RSCN) {
1146 remote_fcport->iodesc_idx_sent =
1147 IODESC_LOGIN_NEEDED;
1148 } else if (remote_fcport->iodesc_idx_sent ==
1149 IODESC_ADISC_NEEDED) {
1150 fc_port_t *new_fcport;
1152 remote_fcport->iodesc_idx_sent =
1153 IODESC_INVALID_INDEX;
1155 /* Create new fcport for later login. */
1156 new_fcport = qla2x00_alloc_rscn_fcport(ha,
1157 ha_locked ? GFP_ATOMIC: GFP_KERNEL);
1159 DEBUG14(printk("scsi(%ld): Handle RSCN "
1160 "-- creating RSCN fcport %p for "
1161 "future login.\n", ha->host_no,
1164 new_fcport->d_id.b24 =
1165 remote_fcport->d_id.b24;
1166 new_fcport->iodesc_idx_sent =
1167 IODESC_LOGIN_NEEDED;
1169 list_add_tail(&new_fcport->list,
1171 set_bit(IODESC_PROCESS_NEEDED,
1174 DEBUG14(printk("scsi(%ld): Handle RSCN "
1175 "-- unable to allocate RSCN fcport "
1176 "for future login.\n",
1180 return (QLA_SUCCESS);
1183 /* Send ADISC if the fcport is online */
1184 if (atomic_read(&remote_fcport->state) == FCS_ONLINE ||
1185 remote_fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED) {
1187 atomic_set(&remote_fcport->state, FCS_DEVICE_LOST);
1189 iodesc = qla2x00_alloc_iodesc(ha);
1190 if (iodesc == NULL) {
1191 /* Mark fcport for later adisc processing */
1192 DEBUG14(printk("scsi(%ld): Handle RSCN -- not "
1193 "enough IO descriptors for Adisc, flag "
1194 "for later processing.\n", ha->host_no));
1196 remote_fcport->iodesc_idx_sent =
1197 IODESC_ADISC_NEEDED;
1198 set_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags);
1200 return (QLA_SUCCESS);
1203 iodesc->cb_idx = ADISC_PORT_IOCB_CB;
1204 iodesc->d_id.b24 = rscn_pid.b24;
1205 iodesc->remote_fcport = remote_fcport;
1206 remote_fcport->iodesc_idx_sent = iodesc->idx;
1207 qla2x00_send_adisc_iocb(ha, iodesc, ha_locked);
1209 return (QLA_SUCCESS);
1210 } else if (remote_fcport->iodesc_idx_sent <
1211 MAX_IO_DESCRIPTORS &&
1212 ha->io_descriptors[remote_fcport->iodesc_idx_sent].cb_idx ==
1213 ADISC_PORT_IOCB_CB) {
1215 * Receiving another RSCN while an ADISC is pending,
1216 * abort the IOCB. Use the same descriptor for the
1219 uint32_t handle_to_abort;
1221 iodesc = &ha->io_descriptors[
1222 remote_fcport->iodesc_idx_sent];
1223 qla2x00_remove_iodesc_timer(iodesc);
1224 handle_to_abort = iodesc->signature;
1225 iodesc->signature = qla2x00_iodesc_to_handle(iodesc);
1226 iodesc->cb_idx = ABORT_IOCB_CB;
1227 iodesc->d_id.b24 = remote_fcport->d_id.b24;
1228 iodesc->remote_fcport = remote_fcport;
1229 remote_fcport->iodesc_idx_sent = iodesc->idx;
1231 DEBUG14(printk("scsi(%ld): Handle RSCN -- issuing "
1232 "abort to outstanding Adisc [%x/%02x%02x%02x].\n",
1233 ha->host_no, remote_fcport->loop_id,
1234 iodesc->d_id.b.domain, iodesc->d_id.b.area,
1235 iodesc->d_id.b.al_pa));
1237 qla2x00_send_abort_iocb(ha, iodesc, handle_to_abort,
1242 /* We need to login to the remote port, find it. */
1244 remote_fcport = known_fcport;
1245 } else if (rscn_fcport && rscn_fcport->d_id.b24 != INVALID_PORT_ID &&
1246 rscn_fcport->iodesc_idx_sent < MAX_IO_DESCRIPTORS &&
1247 ha->io_descriptors[rscn_fcport->iodesc_idx_sent].cb_idx ==
1248 LOGIN_PORT_IOCB_CB) {
1250 * Ignore duplicate RSCN on fcport which has already
1251 * initiated a login IOCB.
1253 DEBUG14(printk("scsi(%ld): Handle RSCN -- ignoring, login "
1254 "already sent to [%02x%02x%02x].\n", ha->host_no,
1255 rscn_fcport->d_id.b.domain, rscn_fcport->d_id.b.area,
1256 rscn_fcport->d_id.b.al_pa));
1258 return (QLA_SUCCESS);
1259 } else if (rscn_fcport && rscn_fcport->d_id.b24 != INVALID_PORT_ID &&
1260 rscn_fcport != remote_fcport) {
1261 /* Reuse same rscn fcport. */
1262 DEBUG14(printk("scsi(%ld): Handle RSCN -- reusing RSCN fcport "
1263 "[%02x%02x%02x].\n", ha->host_no,
1264 rscn_fcport->d_id.b.domain, rscn_fcport->d_id.b.area,
1265 rscn_fcport->d_id.b.al_pa));
1267 remote_fcport = rscn_fcport;
1269 /* Create new fcport for later login. */
1270 remote_fcport = qla2x00_alloc_rscn_fcport(ha,
1271 ha_locked ? GFP_ATOMIC: GFP_KERNEL);
1272 list_add_tail(&remote_fcport->list, &ha->rscn_fcports);
1274 if (remote_fcport == NULL)
1275 return (QLA_SUCCESS);
1277 /* Prepare fcport for login. */
1278 atomic_set(&remote_fcport->state, FCS_DEVICE_LOST);
1279 remote_fcport->login_retry = 3; /* ha->login_retry_count; */
1280 remote_fcport->d_id.b24 = rscn_pid.b24;
1282 iodesc = qla2x00_alloc_iodesc(ha);
1283 if (iodesc == NULL) {
1284 /* Mark fcport for later adisc processing. */
1285 DEBUG14(printk("scsi(%ld): Handle RSCN -- not enough IO "
1286 "descriptors for Login, flag for later processing.\n",
1289 remote_fcport->iodesc_idx_sent = IODESC_LOGIN_NEEDED;
1290 set_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags);
1292 return (QLA_SUCCESS);
1295 if (known_fcport == NULL || rscn_pid.b24 != INVALID_PORT_ID) {
1296 remote_fcport->loop_id = ha->min_external_loopid;
1298 rval = qla2x00_find_new_loop_id(ha, remote_fcport);
1299 if (rval == QLA_FUNCTION_FAILED) {
1300 /* No more loop ids, failed. */
1301 DEBUG14(printk("scsi(%ld): Handle RSCN -- no available "
1302 "loop id to perform Login, failed.\n",
1309 iodesc->cb_idx = LOGIN_PORT_IOCB_CB;
1310 iodesc->d_id.b24 = rscn_pid.b24;
1311 iodesc->remote_fcport = remote_fcport;
1312 remote_fcport->iodesc_idx_sent = iodesc->idx;
1314 DEBUG14(printk("scsi(%ld): Handle RSCN -- attempting login to "
1315 "[%x/%02x%02x%02x].\n", ha->host_no, remote_fcport->loop_id,
1316 iodesc->d_id.b.domain, iodesc->d_id.b.area, iodesc->d_id.b.al_pa));
1318 qla2x00_send_login_iocb(ha, iodesc, &rscn_pid, ha_locked);
1320 return (QLA_SUCCESS);
1324 * qla2x00_process_iodesc() - Complete IO descriptor processing.
1326 * @mbxstat: Mailbox IOCB status
1329 qla2x00_process_iodesc(scsi_qla_host_t *ha, struct mbx_entry *mbxstat)
1334 struct io_descriptor *iodesc;
1336 signature = mbxstat->handle;
1338 DEBUG14(printk("scsi(%ld): Process IODesc -- processing %08x.\n",
1339 ha->host_no, signature));
1341 /* Retrieve proper IO descriptor. */
1342 iodesc = qla2x00_handle_to_iodesc(ha, signature);
1343 if (iodesc == NULL) {
1344 DEBUG14(printk("scsi(%ld): Process IODesc -- ignoring, "
1345 "incorrect signature %08x.\n", ha->host_no, signature));
1350 /* Stop IO descriptor timer. */
1351 qla2x00_remove_iodesc_timer(iodesc);
1353 /* Verify signature match. */
1354 if (iodesc->signature != signature) {
1355 DEBUG14(printk("scsi(%ld): Process IODesc -- ignoring, "
1356 "signature mismatch, sent %08x, received %08x.\n",
1357 ha->host_no, iodesc->signature, signature));
1362 /* Go with IOCB callback. */
1363 rval = iocb_function_cb_list[iodesc->cb_idx](ha, iodesc, mbxstat);
1364 if (rval != QLA_SUCCESS) {
1365 /* IO descriptor reused by callback. */
1369 qla2x00_free_iodesc(iodesc);
1371 if (test_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags)) {
1372 /* Scan our fcports list for any RSCN requests. */
1373 list_for_each_entry(fcport, &ha->fcports, list) {
1374 if (fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED ||
1375 fcport->iodesc_idx_sent == IODESC_LOGIN_NEEDED) {
1376 qla2x00_handle_port_rscn(ha, 0, fcport, 1);
1381 /* Scan our RSCN fcports list for any RSCN requests. */
1382 list_for_each_entry(fcport, &ha->rscn_fcports, list) {
1383 if (fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED ||
1384 fcport->iodesc_idx_sent == IODESC_LOGIN_NEEDED) {
1385 qla2x00_handle_port_rscn(ha, 0, fcport, 1);
1390 clear_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags);
1394 * qla2x00_cancel_io_descriptors() - Cancel all outstanding io descriptors.
1397 * This routine will also delete any RSCN entries related to the outstanding
1401 qla2x00_cancel_io_descriptors(scsi_qla_host_t *ha)
1403 fc_port_t *fcport, *fcptemp;
1405 clear_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags);
1407 /* Abort all IO descriptors. */
1408 qla2x00_init_io_descriptors(ha);
1410 /* Reset all pending IO descriptors in fcports list. */
1411 list_for_each_entry(fcport, &ha->fcports, list) {
1412 fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
1415 /* Reset all pending IO descriptors in rscn fcports list. */
1416 list_for_each_entry_safe(fcport, fcptemp, &ha->rscn_fcports, list) {
1417 DEBUG14(printk("scsi(%ld): Cancel IOs -- Freeing RSCN fcport "
1418 "%p [%x/%02x%02x%02x].\n", ha->host_no, fcport,
1419 fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area,
1420 fcport->d_id.b.al_pa));
1422 list_del(&fcport->list);