diff options
author | <andrew.vasquez@qlogic.com> | 2005-04-17 15:06:53 -0500 |
---|---|---|
committer | James Bottomley <jejb@titanic> | 2005-04-18 13:47:46 -0500 |
commit | bdf796210e01145fd77bbb3ae644d04f982b6c3b (patch) | |
tree | 92253748a63c51e76a70384d35119e107077b050 /drivers | |
parent | 8482e118afa0cb4321ab3d30b1100d27d63130c0 (diff) |
[PATCH] qla2xxx: remove lun discovery codes...
Remove internal lun discovery routines and support
structures.
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_attr.c | 51 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_dbg.c | 5 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_def.h | 103 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_gbl.h | 10 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_init.c | 864 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_inline.h | 17 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_iocb.c | 13 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_isr.c | 37 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mbx.c | 21 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_os.c | 282 |
10 files changed, 103 insertions, 1300 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 0105b609ff3..56770fac4d1 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -227,12 +227,17 @@ qla2x00_get_starget_node_name(struct scsi_target *starget) { struct Scsi_Host *host = dev_to_shost(starget->dev.parent); scsi_qla_host_t *ha = to_qla_host(host); - os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget->id); + fc_port_t *fcport; uint64_t node_name = 0; - if (tq->fcport) - node_name = be64_to_cpu(*(uint64_t *)tq->fcport->node_name); - fc_starget_node_name(starget) = node_name; + list_for_each_entry(fcport, &ha->fcports, list) { + if (starget->id == fcport->os_target_id) { + node_name = *(uint64_t *)fcport->node_name; + break; + } + } + + fc_starget_node_name(starget) = be64_to_cpu(node_name); } static void @@ -240,12 +245,17 @@ qla2x00_get_starget_port_name(struct scsi_target *starget) { struct Scsi_Host *host = dev_to_shost(starget->dev.parent); scsi_qla_host_t *ha = to_qla_host(host); - os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget->id); + fc_port_t *fcport; uint64_t port_name = 0; - if (tq->fcport) - port_name = be64_to_cpu(*(uint64_t *)tq->fcport->port_name); - fc_starget_port_name(starget) = port_name; + list_for_each_entry(fcport, &ha->fcports, list) { + if (starget->id == fcport->os_target_id) { + port_name = *(uint64_t *)fcport->port_name; + break; + } + } + + fc_starget_port_name(starget) = be64_to_cpu(port_name); } static void @@ -253,20 +263,25 @@ qla2x00_get_starget_port_id(struct scsi_target *starget) { struct Scsi_Host *host = dev_to_shost(starget->dev.parent); scsi_qla_host_t *ha = to_qla_host(host); - os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget->id); - uint32_t port_id = 0; + fc_port_t *fcport; + uint32_t port_id = ~0U; + + list_for_each_entry(fcport, &ha->fcports, list) { + if (starget->id == fcport->os_target_id) { + port_id = fcport->d_id.b.domain << 16 | + fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; + break; + } + } - if (tq->fcport) - port_id = tq->fcport->d_id.b.domain << 16 | - tq->fcport->d_id.b.area << 8 | tq->fcport->d_id.b.al_pa; fc_starget_port_id(starget) = port_id; } static void qla2x00_get_rport_loss_tmo(struct fc_rport *rport) { - os_tgt_t *tq = rport->dd_data; - scsi_qla_host_t *ha = tq->ha; + struct Scsi_Host *host = rport_to_shost(rport); + scsi_qla_host_t *ha = to_qla_host(host); rport->dev_loss_tmo = ha->port_down_retry_count + 5; } @@ -274,8 +289,8 @@ qla2x00_get_rport_loss_tmo(struct fc_rport *rport) static void qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) { - os_tgt_t *tq = rport->dd_data; - scsi_qla_host_t *ha = tq->ha; + struct Scsi_Host *host = rport_to_shost(rport); + scsi_qla_host_t *ha = to_qla_host(host); if (timeout) ha->port_down_retry_count = timeout; @@ -292,7 +307,7 @@ static struct fc_function_template qla2xxx_transport_functions = { .get_host_port_id = qla2x00_get_host_port_id, .show_host_port_id = 1, - .dd_fcrport_size = sizeof(os_tgt_t *), + .dd_fcrport_size = sizeof(struct fc_port *), .get_starget_node_name = qla2x00_get_starget_node_name, .show_starget_node_name = 1, diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 0e8ebbc56e8..c4cd4ac414c 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -1065,11 +1065,6 @@ qla2x00_print_scsi_cmd(struct scsi_cmnd * cmd) printk(" sp flags=0x%x\n", sp->flags); printk(" r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n", sp->r_start, sp->u_start, sp->f_start, sp->state); - - printk(" e_start= 0x%lx, ext_history=%d, fo retry=%d, loopid=%x, " - "port path=%d\n", sp->e_start, sp->ext_history, sp->fo_retry_cnt, - sp->lun_queue->fclun->fcport->loop_id, - sp->lun_queue->fclun->fcport->cur_path); } #if defined(QL_DEBUG_ROUTINES) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index b153d64bb96..7d47b8d9204 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -241,6 +241,7 @@ typedef struct srb { struct list_head list; struct scsi_qla_host *ha; /* HA the SP is queued on */ + struct fc_port *fcport; struct scsi_cmnd *cmd; /* Linux SCSI command pkt */ @@ -251,11 +252,6 @@ typedef struct srb { /* Request state */ uint16_t state; - /* Target/LUN queue pointers. */ - struct os_tgt *tgt_queue; /* ptr to visible ha's target */ - struct os_lun *lun_queue; /* ptr to visible ha's lun */ - struct fc_lun *fclun; /* FC LUN context pointer. */ - /* Timing counts. */ unsigned long e_start; /* Start of extend timeout */ unsigned long r_start; /* Start of request */ @@ -1603,73 +1599,6 @@ typedef struct { } rpt_lun_cmd_rsp_t; /* - * SCSI Target Queue structure - */ -typedef struct os_tgt { - struct os_lun *olun[MAX_LUNS]; /* LUN context pointer. */ - struct fc_port *fcport; - unsigned long flags; - uint8_t port_down_retry_count; - uint32_t down_timer; - struct scsi_qla_host *ha; - - /* Persistent binding information */ - port_id_t d_id; - uint8_t node_name[WWN_SIZE]; - uint8_t port_name[WWN_SIZE]; -} os_tgt_t; - -/* - * SCSI Target Queue flags - */ -#define TQF_ONLINE 0 /* Device online to OS. */ -#define TQF_SUSPENDED 1 -#define TQF_RETRY_CMDS 2 - -/* - * SCSI LUN Queue structure - */ -typedef struct os_lun { - struct fc_lun *fclun; /* FC LUN context pointer. */ - spinlock_t q_lock; /* Lun Lock */ - - unsigned long q_flag; -#define LUN_MPIO_RESET_CNTS 1 /* Lun */ -#define LUN_MPIO_BUSY 2 /* Lun is changing paths */ -#define LUN_EXEC_DELAYED 7 /* Lun execution is delayed */ - - u_long q_timeout; /* total command timeouts */ - atomic_t q_timer; /* suspend timer */ - uint32_t q_count; /* current count */ - uint32_t q_max; /* maxmum count lun can be suspended */ - uint8_t q_state; /* lun State */ -#define LUN_STATE_READY 1 /* lun is ready for i/o */ -#define LUN_STATE_RUN 2 /* lun has a timer running */ -#define LUN_STATE_WAIT 3 /* lun is suspended */ -#define LUN_STATE_TIMEOUT 4 /* lun has timed out */ - - u_long io_cnt; /* total xfer count since boot */ - u_long out_cnt; /* total outstanding IO count */ - u_long w_cnt; /* total writes */ - u_long r_cnt; /* total reads */ - u_long avg_time; /* */ -} os_lun_t; - - -/* LUN BitMask structure definition, array of 32bit words, - * 1 bit per lun. When bit == 1, the lun is masked. - * Most significant bit of mask[0] is lun 0, bit 24 is lun 7. - */ -typedef struct lun_bit_mask { - /* Must allocate at least enough bits to accomodate all LUNs */ -#if ((MAX_FIBRE_LUNS & 0x7) == 0) - uint8_t mask[MAX_FIBRE_LUNS >> 3]; -#else - uint8_t mask[(MAX_FIBRE_LUNS + 8) >> 3]; -#endif -} lun_bit_mask_t; - -/* * Fibre channel port type. */ typedef enum { @@ -1686,8 +1615,6 @@ typedef struct lun_bit_mask { */ typedef struct fc_port { struct list_head list; - struct list_head fcluns; - struct scsi_qla_host *ha; struct scsi_qla_host *vis_ha; /* only used when suspending lun */ @@ -1702,8 +1629,7 @@ typedef struct fc_port { atomic_t state; uint32_t flags; - os_tgt_t *tgt_queue; - uint16_t os_target_id; + unsigned int os_target_id; uint16_t iodesc_idx_sent; @@ -1717,7 +1643,6 @@ typedef struct fc_port { uint8_t mp_byte; /* multi-path byte (not used) */ uint8_t cur_path; /* current path id */ - lun_bit_mask_t lun_mask; struct fc_rport *rport; } fc_port_t; @@ -1765,25 +1690,6 @@ typedef struct fc_port { #define FC_NO_LOOP_ID 0x1000 /* - * Fibre channel LUN structure. - */ -typedef struct fc_lun { - struct list_head list; - - fc_port_t *fcport; - fc_port_t *o_fcport; - uint16_t lun; - atomic_t state; - uint8_t device_type; - - uint8_t max_path_retries; - uint32_t flags; -} fc_lun_t; - -#define FLF_VISIBLE_LUN BIT_0 -#define FLF_ACTIVE_LUN BIT_1 - -/* * FC-CT interface * * NOTE: All structures are big-endian in form. @@ -2253,9 +2159,6 @@ typedef struct scsi_qla_host { struct io_descriptor io_descriptors[MAX_IO_DESCRIPTORS]; uint16_t iodesc_signature; - /* OS target queue pointers. */ - os_tgt_t *otgt[MAX_FIBRE_DEVICES]; - /* RSCN queue. */ uint32_t rscn_queue[MAX_RSCN_COUNT]; uint8_t rscn_in_ptr; @@ -2400,8 +2303,6 @@ typedef struct scsi_qla_host { #define LOOP_RDY(ha) (!LOOP_NOT_READY(ha)) #define TGT_Q(ha, t) (ha->otgt[t]) -#define LUN_Q(ha, t, l) (TGT_Q(ha, t)->olun[l]) -#define GET_LU_Q(ha, t, l) ((TGT_Q(ha,t) != NULL)? TGT_Q(ha, t)->olun[l] : NULL) #define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata) diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index bc1ef103495..e4bfe4d5bbe 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -45,8 +45,6 @@ extern void qla2x00_restart_queues(scsi_qla_host_t *, uint8_t); extern void qla2x00_rescan_fcports(scsi_qla_host_t *); -extern void qla2x00_tgt_free(scsi_qla_host_t *ha, uint16_t t); - extern int qla2x00_abort_isp(scsi_qla_host_t *); extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *); @@ -83,12 +81,6 @@ extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *); extern void qla2x00_cmd_timeout(srb_t *); -extern int __qla2x00_suspend_lun(scsi_qla_host_t *, os_lun_t *, int, int, int); - -extern void qla2x00_done(scsi_qla_host_t *); -extern void qla2x00_flush_failover_q(scsi_qla_host_t *, os_lun_t *); -extern void qla2x00_reset_lun_fo_counts(scsi_qla_host_t *, os_lun_t *); - extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int); extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *); @@ -149,7 +141,7 @@ qla2x00_abort_target(fc_port_t *fcport); #endif extern int -qla2x00_target_reset(scsi_qla_host_t *, uint16_t, uint16_t); +qla2x00_target_reset(scsi_qla_host_t *, struct fc_port *); extern int qla2x00_get_adapter_id(scsi_qla_host_t *, uint16_t *, uint8_t *, uint8_t *, diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 29b301ecd2f..0387005fcb6 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -45,34 +45,17 @@ static int qla2x00_init_rings(scsi_qla_host_t *); static int qla2x00_fw_ready(scsi_qla_host_t *); static int qla2x00_configure_hba(scsi_qla_host_t *); static int qla2x00_nvram_config(scsi_qla_host_t *); -static void qla2x00_init_tgt_map(scsi_qla_host_t *); static int qla2x00_configure_loop(scsi_qla_host_t *); static int qla2x00_configure_local_loop(scsi_qla_host_t *); static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *); -static void qla2x00_lun_discovery(scsi_qla_host_t *, fc_port_t *); -static int qla2x00_rpt_lun_discovery(scsi_qla_host_t *, fc_port_t *, - inq_cmd_rsp_t *, dma_addr_t); -static int qla2x00_report_lun(scsi_qla_host_t *, fc_port_t *); -static fc_lun_t *qla2x00_cfg_lun(scsi_qla_host_t *, fc_port_t *, uint16_t, - inq_cmd_rsp_t *, dma_addr_t); -static fc_lun_t * qla2x00_add_lun(fc_port_t *, uint16_t); -static int qla2x00_inquiry(scsi_qla_host_t *, fc_port_t *, uint16_t, - inq_cmd_rsp_t *, dma_addr_t); static int qla2x00_configure_fabric(scsi_qla_host_t *); static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *); static int qla2x00_device_resync(scsi_qla_host_t *); static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *, uint16_t *); -static void qla2x00_config_os(scsi_qla_host_t *ha); -static uint16_t qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport); -static os_lun_t * qla2x00_fclun_bind(scsi_qla_host_t *, fc_port_t *, - fc_lun_t *); -static void qla2x00_lun_free(scsi_qla_host_t *, uint16_t, uint16_t); static int qla2x00_restart_isp(scsi_qla_host_t *); static void qla2x00_reset_adapter(scsi_qla_host_t *); -static os_tgt_t *qla2x00_tgt_alloc(scsi_qla_host_t *, uint16_t); -static os_lun_t *qla2x00_lun_alloc(scsi_qla_host_t *, uint16_t, uint16_t); /****************************************************************************/ /* QLogic ISP2x00 Hardware Support Functions. */ @@ -120,9 +103,6 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha) qla2x00_reset_chip(ha); - /* Initialize target map database. */ - qla2x00_init_tgt_map(ha); - qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); qla2x00_nvram_config(ha); @@ -1530,25 +1510,6 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) return (rval); } -/* -* qla2x00_init_tgt_map -* Initializes target map. -* -* Input: -* ha = adapter block pointer. -* -* Output: -* TGT_Q initialized -*/ -static void -qla2x00_init_tgt_map(scsi_qla_host_t *ha) -{ - uint32_t t; - - for (t = 0; t < MAX_TARGETS; t++) - TGT_Q(ha, t) = (os_tgt_t *)NULL; -} - /** * qla2x00_alloc_fcport() - Allocate a generic fcport. * @ha: HA context @@ -1573,7 +1534,6 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, int flags) fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; atomic_set(&fcport->state, FCS_UNCONFIGURED); fcport->flags = FCF_RLC_SUPPORT; - INIT_LIST_HEAD(&fcport->fcluns); return (fcport); } @@ -1663,7 +1623,6 @@ qla2x00_configure_loop(scsi_qla_host_t *ha) test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { rval = QLA_FUNCTION_FAILED; } else { - qla2x00_config_os(ha); atomic_set(&ha->loop_state, LOOP_READY); DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no)); @@ -1908,8 +1867,11 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) if (fcport->flags & FCF_TAPE_PRESENT) { spin_lock_irqsave(&ha->hardware_lock, flags); for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { + fc_port_t *sfcp; + if ((sp = ha->outstanding_cmds[index]) != 0) { - if (sp->fclun->fcport == fcport) { + sfcp = sp->fcport; + if (sfcp == fcport) { atomic_set(&fcport->state, FCS_ONLINE); spin_unlock_irqrestore( &ha->hardware_lock, flags); @@ -1920,14 +1882,12 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) spin_unlock_irqrestore(&ha->hardware_lock, flags); } - /* Do LUN discovery. */ if (fcport->port_type == FCT_INITIATOR || - fcport->port_type == FCT_BROADCAST) { + fcport->port_type == FCT_BROADCAST) fcport->device_type = TYPE_PROCESSOR; - } else { - qla2x00_lun_discovery(ha, fcport); - } + atomic_set(&fcport->state, FCS_ONLINE); + if (ha->flags.init_done) qla2x00_reg_remote_port(ha, fcport); } @@ -1936,6 +1896,7 @@ void qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) { struct fc_rport_identifiers rport_ids; + struct fc_rport *rport; if (fcport->rport) { fc_remote_port_unblock(fcport->rport); @@ -1952,419 +1913,18 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) if (fcport->port_type == FCT_TARGET) rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; - fcport->rport = fc_remote_port_add(ha->host, 0, &rport_ids); - if (!fcport->rport) + fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids); + if (!rport) qla_printk(KERN_WARNING, ha, "Unable to allocate fc remote port!\n"); -} -/* - * qla2x00_lun_discovery - * Issue SCSI inquiry command for LUN discovery. - * - * Input: - * ha: adapter state pointer. - * fcport: FC port structure pointer. - * - * Context: - * Kernel context. - */ -static void -qla2x00_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport) -{ - inq_cmd_rsp_t *inq; - dma_addr_t inq_dma; - uint16_t lun; - - inq = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &inq_dma); - if (inq == NULL) { - qla_printk(KERN_WARNING, ha, - "Memory Allocation failed - INQ\n"); - return; - } - /* Always add a fc_lun_t structure for lun 0 -- mid-layer requirement */ - qla2x00_add_lun(fcport, 0); - - /* If report LUN works, exit. */ - if (qla2x00_rpt_lun_discovery(ha, fcport, inq, inq_dma) != - QLA_SUCCESS) { - for (lun = 0; lun < ha->max_probe_luns; lun++) { - /* Configure LUN. */ - qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma); - } - } + if (rport->scsi_target_id != -1 && rport->scsi_target_id < MAX_TARGETS) + fcport->os_target_id = rport->scsi_target_id; - dma_pool_free(ha->s_dma_pool, inq, inq_dma); + rport->dd_data = fcport; } /* - * qla2x00_rpt_lun_discovery - * Issue SCSI report LUN command for LUN discovery. - * - * Input: - * ha: adapter state pointer. - * fcport: FC port structure pointer. - * - * Returns: - * qla2x00 local function return status code. - * - * Context: - * Kernel context. - */ -static int -qla2x00_rpt_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport, - inq_cmd_rsp_t *inq, dma_addr_t inq_dma) -{ - int rval; - uint32_t len, cnt; - uint16_t lun; - - /* Assume a failed status */ - rval = QLA_FUNCTION_FAILED; - - /* No point in continuing if the device doesn't support RLC */ - if ((fcport->flags & FCF_RLC_SUPPORT) == 0) - return (rval); - - rval = qla2x00_report_lun(ha, fcport); - if (rval != QLA_SUCCESS) - return (rval); - - /* Configure LUN list. */ - len = be32_to_cpu(ha->rlc_rsp->list.hdr.len); - len /= 8; - for (cnt = 0; cnt < len; cnt++) { - lun = CHAR_TO_SHORT(ha->rlc_rsp->list.lst[cnt].lsb, - ha->rlc_rsp->list.lst[cnt].msb.b); - - DEBUG3(printk("scsi(%ld): RLC lun = (%d)\n", ha->host_no, lun)); - - /* We only support 0 through MAX_LUNS-1 range */ - if (lun < MAX_LUNS) { - qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma); - } - } - atomic_set(&fcport->state, FCS_ONLINE); - - return (rval); -} - -/* - * qla2x00_report_lun - * Issue SCSI report LUN command. - * - * Input: - * ha: adapter state pointer. - * fcport: FC port structure pointer. - * - * Returns: - * qla2x00 local function return status code. - * - * Context: - * Kernel context. - */ -static int -qla2x00_report_lun(scsi_qla_host_t *ha, fc_port_t *fcport) -{ - int rval; - uint16_t retries; - uint16_t comp_status; - uint16_t scsi_status; - rpt_lun_cmd_rsp_t *rlc; - dma_addr_t rlc_dma; - - rval = QLA_FUNCTION_FAILED; - rlc = ha->rlc_rsp; - rlc_dma = ha->rlc_rsp_dma; - - for (retries = 3; retries; retries--) { - memset(rlc, 0, sizeof(rpt_lun_cmd_rsp_t)); - rlc->p.cmd.entry_type = COMMAND_A64_TYPE; - rlc->p.cmd.entry_count = 1; - SET_TARGET_ID(ha, rlc->p.cmd.target, fcport->loop_id); - rlc->p.cmd.control_flags = - __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG); - rlc->p.cmd.scsi_cdb[0] = REPORT_LUNS; - rlc->p.cmd.scsi_cdb[8] = MSB(sizeof(rpt_lun_lst_t)); - rlc->p.cmd.scsi_cdb[9] = LSB(sizeof(rpt_lun_lst_t)); - rlc->p.cmd.dseg_count = __constant_cpu_to_le16(1); - rlc->p.cmd.timeout = __constant_cpu_to_le16(10); - rlc->p.cmd.byte_count = - __constant_cpu_to_le32(sizeof(rpt_lun_lst_t)); - rlc->p.cmd.dseg_0_address[0] = cpu_to_le32( - LSD(rlc_dma + sizeof(sts_entry_t))); - rlc->p.cmd.dseg_0_address[1] = cpu_to_le32( - MSD(rlc_dma + sizeof(sts_entry_t))); - rlc->p.cmd.dseg_0_length = - __constant_cpu_to_le32(sizeof(rpt_lun_lst_t)); - - rval = qla2x00_issue_iocb(ha, rlc, rlc_dma, - sizeof(rpt_lun_cmd_rsp_t)); - - comp_status = le16_to_cpu(rlc->p.rsp.comp_status); - scsi_status = le16_to_cpu(rlc->p.rsp.scsi_status); - - if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE || - scsi_status & SS_CHECK_CONDITION) { - - /* Device underrun, treat as OK. */ - if (rval == QLA_SUCCESS && - comp_status == CS_DATA_UNDERRUN && - scsi_status & SS_RESIDUAL_UNDER) { - - rval = QLA_SUCCESS; - break; - } - - DEBUG(printk("scsi(%ld): RLC failed to issue iocb! " - "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n", - ha->host_no, fcport->loop_id, fcport, rval, - comp_status, scsi_status)); - - rval = QLA_FUNCTION_FAILED; - if (scsi_status & SS_CHECK_CONDITION) { - DEBUG2(printk("scsi(%ld): RLC " - "SS_CHECK_CONDITION Sense Data " - "%02x %02x %02x %02x %02x %02x %02x %02x\n", - ha->host_no, - rlc->p.rsp.req_sense_data[0], - rlc->p.rsp.req_sense_data[1], - rlc->p.rsp.req_sense_data[2], - rlc->p.rsp.req_sense_data[3], - rlc->p.rsp.req_sense_data[4], - rlc->p.rsp.req_sense_data[5], - rlc->p.rsp.req_sense_data[6], - rlc->p.rsp.req_sense_data[7])); - if (rlc->p.rsp.req_sense_data[2] == - ILLEGAL_REQUEST) { - fcport->flags &= ~(FCF_RLC_SUPPORT); - break; - } - } - } else { - break; - } - } - - return (rval); -} - -/* - * qla2x00_cfg_lun - * Configures LUN into fcport LUN list. - * - * Input: - * fcport: FC port structure pointer. - * lun: LUN number. - * - * Context: - * Kernel context. - */ -static fc_lun_t * -qla2x00_cfg_lun(scsi_qla_host_t *ha, fc_port_t *fcport, uint16_t lun, - inq_cmd_rsp_t *inq, dma_addr_t inq_dma) -{ - fc_lun_t *fclun; - uint8_t device_type; - - /* Bypass LUNs that failed. */ - if (qla2x00_inquiry(ha, fcport, lun, inq, inq_dma) != QLA_SUCCESS) { - DEBUG2(printk("scsi(%ld): Failed inquiry - loop id=0x%04x " - "lun=%d\n", ha->host_no, fcport->loop_id, lun)); - - return (NULL); - } - device_type = (inq->inq[0] & 0x1f); - switch (device_type) { - case TYPE_DISK: - case TYPE_PROCESSOR: - case TYPE_WORM: - case TYPE_ROM: - case TYPE_SCANNER: - case TYPE_MOD: - case TYPE_MEDIUM_CHANGER: - case TYPE_ENCLOSURE: - case 0x20: - case 0x0C: - break; - case TYPE_TAPE: - fcport->flags |= FCF_TAPE_PRESENT; - break; - default: - DEBUG2(printk("scsi(%ld): Unsupported lun type -- " - "loop id=0x%04x lun=%d type=%x\n", - ha->host_no, fcport->loop_id, lun, device_type)); - return (NULL); - } - - fcport->device_type = device_type; - fclun = qla2x00_add_lun(fcport, lun); - - if (fclun != NULL) { - atomic_set(&fcport->state, FCS_ONLINE); - } - - return (fclun); -} - -/* - * qla2x00_add_lun - * Adds LUN to database - * - * Input: - * fcport: FC port structure pointer. - * lun: LUN number. - * - * Context: - * Kernel context. - */ -static fc_lun_t * -qla2x00_add_lun(fc_port_t *fcport, uint16_t lun) -{ - int found; - fc_lun_t *fclun; - - if (fcport == NULL) { - DEBUG(printk("scsi: Unable to add lun to NULL port\n")); - return (NULL); - } - - /* Allocate LUN if not already allocated. */ - found = 0; - list_for_each_entry(fclun, &fcport->fcluns, list) { - if (fclun->lun == lun) { - found++; - break; - } - } - if (found) - return (NULL); - - fclun = kmalloc(sizeof(fc_lun_t), GFP_ATOMIC); - if (fclun == NULL) { - printk(KERN_WARNING - "%s(): Memory Allocation failed - FCLUN\n", - __func__); - return (NULL); - } - - /* Setup LUN structure. */ - memset(fclun, 0, sizeof(fc_lun_t)); - fclun->lun = lun; - fclun->fcport = fcport; - fclun->o_fcport = fcport; - fclun->device_type = fcport->device_type; - atomic_set(&fcport->state, FCS_UNCONFIGURED); - - list_add_tail(&fclun->list, &fcport->fcluns); - - return (fclun); -} - -/* - * qla2x00_inquiry - * Issue SCSI inquiry command. - * - * Input: - * ha = adapter block pointer. - * fcport = FC port structure pointer. - * - * Return: - * 0 - Success - * BIT_0 - error - * - * Context: - * Kernel context. - */ -static int -qla2x00_inquiry(scsi_qla_host_t *ha, - fc_port_t *fcport, uint16_t lun, inq_cmd_rsp_t *inq, dma_addr_t inq_dma) -{ - int rval; - uint16_t retries; - uint16_t comp_status; - uint16_t scsi_status; - - rval = QLA_FUNCTION_FAILED; - - for (retries = 3; retries; retries--) { - memset(inq, 0, sizeof(inq_cmd_rsp_t)); - inq->p.cmd.entry_type = COMMAND_A64_TYPE; - inq->p.cmd.entry_count = 1; - inq->p.cmd.lun = cpu_to_le16(lun); - SET_TARGET_ID(ha, inq->p.cmd.target, fcport->loop_id); - inq->p.cmd.control_flags = - __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG); - inq->p.cmd.scsi_cdb[0] = INQUIRY; - inq->p.cmd.scsi_cdb[4] = INQ_DATA_SIZE; - inq->p.cmd.dseg_count = __constant_cpu_to_le16(1); - inq->p.cmd.timeout = __constant_cpu_to_le16(10); - inq->p.cmd.byte_count = - __constant_cpu_to_le32(INQ_DATA_SIZE); - inq->p.cmd.dseg_0_address[0] = cpu_to_le32( - LSD(inq_dma + sizeof(sts_entry_t))); - inq->p.cmd.dseg_0_address[1] = cpu_to_le32( - MSD(inq_dma + sizeof(sts_entry_t))); - inq->p.cmd.dseg_0_length = - __constant_cpu_to_le32(INQ_DATA_SIZE); - - DEBUG5(printk("scsi(%ld): Lun Inquiry - fcport=[%04x/%p]," - " lun (%d)\n", - ha->host_no, fcport->loop_id, fcport, lun)); - - rval = qla2x00_issue_iocb(ha, inq, inq_dma, - sizeof(inq_cmd_rsp_t)); - - comp_status = le16_to_cpu(inq->p.rsp.comp_status); - scsi_status = le16_to_cpu(inq->p.rsp.scsi_status); - - DEBUG5(printk("scsi(%ld): lun (%d) inquiry - " - "inq[0]= 0x%x, comp status 0x%x, scsi status 0x%x, " - "rval=%d\n", - ha->host_no, lun, inq->inq[0], comp_status, scsi_status, - rval)); - - if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE || - scsi_status & SS_CHECK_CONDITION) { - - DEBUG(printk("scsi(%ld): INQ failed to issue iocb! " - "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n", - ha->host_no, fcport->loop_id, fcport, rval, - comp_status, scsi_status)); - - if (rval == QLA_SUCCESS) - rval = QLA_FUNCTION_FAILED; - - if (scsi_status & SS_CHECK_CONDITION) { - DEBUG2(printk("scsi(%ld): INQ " - "SS_CHECK_CONDITION Sense Data " - "%02x %02x %02x %02x %02x %02x %02x %02x\n", - ha->host_no, - inq->p.rsp.req_sense_data[0], - inq->p.rsp.req_sense_data[1], - inq->p.rsp.req_sense_data[2], - inq->p.rsp.req_sense_data[3], - inq->p.rsp.req_sense_data[4], - inq->p.rsp.req_sense_data[5], - inq->p.rsp.req_sense_data[6], - inq->p.rsp.req_sense_data[7])); - } - - /* Device underrun drop LUN. */ - if (comp_status == CS_DATA_UNDERRUN && - scsi_status & SS_RESIDUAL_UNDER) { - break; - } - } else { - break; - } - } - - return (rval); -} - - -/* * qla2x00_configure_fabric * Setup SNS devices with loop ID's. * @@ -2514,12 +2074,12 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) break; } - /* Login and update database */ - qla2x00_fabric_dev_login(ha, fcport, &next_loopid); - /* Remove device from the new list and add it to DB */ list_del(&fcport->list); list_add_tail(&fcport->list, &ha->fcports); + + /* Login and update database */ + qla2x00_fabric_dev_login(ha, fcport, &next_loopid); } } while (0); @@ -3203,396 +2763,6 @@ qla2x00_rescan_fcports(scsi_qla_host_t *ha) rescan_done = 1; } qla2x00_probe_for_all_luns(ha); - - /* Update OS target and lun structures if necessary. */ - if (rescan_done) { - qla2x00_config_os(ha); - } -} - - -/* - * qla2x00_config_os - * Setup OS target and LUN structures. - * - * Input: - * ha = adapter state pointer. - * - * Context: - * Kernel context. - */ -static void -qla2x00_config_os(scsi_qla_host_t *ha) -{ - fc_port_t *fcport; - fc_lun_t *fclun; - os_tgt_t *tq; - uint16_t tgt; - - - for (tgt = 0; tgt < MAX_TARGETS; tgt++) { - if ((tq = TGT_Q(ha, tgt)) == NULL) - continue; - - clear_bit(TQF_ONLINE, &tq->flags); - } - - list_for_each_entry(fcport, &ha->fcports, list) { - if (atomic_read(&fcport->state) != FCS_ONLINE || - fcport->port_type == FCT_INITIATOR || - fcport->port_type == FCT_BROADCAST) { - fcport->os_target_id = MAX_TARGETS; - continue; - } - - if (fcport->flags & FCF_FO_MASKED) { - continue; - } - - /* Bind FC port to OS target number. */ - if (qla2x00_fcport_bind(ha, fcport) == MAX_TARGETS) { - continue; - } - - /* Bind FC LUN to OS LUN number. */ - list_for_each_entry(fclun, &fcport->fcluns, list) { - qla2x00_fclun_bind(ha, fcport, fclun); - } - } -} - -/* - * qla2x00_fcport_bind - * Locates a target number for FC port. - * - * Input: - * ha = adapter state pointer. - * fcport = FC port structure pointer. - * - * Returns: - * target number - * - * Context: - * Kernel context. - */ -static uint16_t -qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport) -{ - int found; - uint16_t tgt; - os_tgt_t *tq; - - /* Check for persistent binding. */ - for (tgt = 0; tgt < MAX_TARGETS; tgt++) { - if ((tq = TGT_Q(ha, tgt)) == NULL) - continue; - - found = 0; - switch (ha->binding_type) { - case BIND_BY_PORT_ID: - if (fcport->d_id.b24 == tq->d_id.b24) { - memcpy(tq->node_name, fcport->node_name, - WWN_SIZE); - memcpy(tq->port_name, fcport->port_name, - WWN_SIZE); - found++; - } - break; - case BIND_BY_PORT_NAME: - if (memcmp(fcport->port_name, tq->port_name, - WWN_SIZE) == 0) { - /* - * In case of persistent binding, update the - * WWNN. - */ - memcpy(tq->node_name, fcport->node_name, - WWN_SIZE); - found++; - } - break; - } - if (found) - break; - } - - /* TODO: honor the ConfigRequired flag */ - if (tgt == MAX_TARGETS) { - /* Check if targetID 0 available. */ - tgt = 0; - - if (TGT_Q(ha, tgt) != NULL) { - /* Locate first free target for device. */ - for (tgt = 0; tgt < MAX_TARGETS; tgt++) { - if (TGT_Q(ha, tgt) == NULL) { - break; - } - } - } - if (tgt != MAX_TARGETS) { - if ((tq = qla2x00_tgt_alloc(ha, tgt)) != NULL) { - memcpy(tq->node_name, fcport->node_name, - WWN_SIZE); - memcpy(tq->port_name, fcport->port_name, - WWN_SIZE); - tq->d_id.b24 = fcport->d_id.b24; - } - } - } - - /* Reset target numbers incase it changed. */ - fcport->os_target_id = tgt; - if (tgt != MAX_TARGETS && tq != NULL) { - DEBUG2(printk("scsi(%ld): Assigning target ID=%02d @ %p to " - "loop id=0x%04x, port state=0x%x, port down retry=%d\n", - ha->host_no, tgt, tq, fcport->loop_id, - atomic_read(&fcport->state), - atomic_read(&fcport->port_down_timer))); - - fcport->tgt_queue = tq; - fcport->flags |= FCF_PERSISTENT_BOUND; - tq->fcport = fcport; - set_bit(TQF_ONLINE, &tq->flags); - tq->port_down_retry_count = ha->port_down_retry_count; - } - - if (tgt == MAX_TARGETS) { - qla_printk(KERN_WARNING, ha, - "Unable to bind fcport, loop_id=%x\n", fcport->loop_id); - } - - return (tgt); -} - -/* - * qla2x00_fclun_bind - * Binds all FC device LUNS to OS LUNS. - * - * Input: |