aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c51
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h103
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h10
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c864
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h17
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c13
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c37
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c21
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c282
10 files changed, 103 insertions, 1300 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 0105b609ff3a..56770fac4d14 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)
227{ 227{
228 struct Scsi_Host *host = dev_to_shost(starget->dev.parent); 228 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
229 scsi_qla_host_t *ha = to_qla_host(host); 229 scsi_qla_host_t *ha = to_qla_host(host);
230 os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget->id); 230 fc_port_t *fcport;
231 uint64_t node_name = 0; 231 uint64_t node_name = 0;
232 232
233 if (tq->fcport) 233 list_for_each_entry(fcport, &ha->fcports, list) {
234 node_name = be64_to_cpu(*(uint64_t *)tq->fcport->node_name); 234 if (starget->id == fcport->os_target_id) {
235 fc_starget_node_name(starget) = node_name; 235 node_name = *(uint64_t *)fcport->node_name;
236 break;
237 }
238 }
239
240 fc_starget_node_name(starget) = be64_to_cpu(node_name);
236} 241}
237 242
238static void 243static void
@@ -240,12 +245,17 @@ qla2x00_get_starget_port_name(struct scsi_target *starget)
240{ 245{
241 struct Scsi_Host *host = dev_to_shost(starget->dev.parent); 246 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
242 scsi_qla_host_t *ha = to_qla_host(host); 247 scsi_qla_host_t *ha = to_qla_host(host);
243 os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget->id); 248 fc_port_t *fcport;
244 uint64_t port_name = 0; 249 uint64_t port_name = 0;
245 250
246 if (tq->fcport) 251 list_for_each_entry(fcport, &ha->fcports, list) {
247 port_name = be64_to_cpu(*(uint64_t *)tq->fcport->port_name); 252 if (starget->id == fcport->os_target_id) {
248 fc_starget_port_name(starget) = port_name; 253 port_name = *(uint64_t *)fcport->port_name;
254 break;
255 }
256 }
257
258 fc_starget_port_name(starget) = be64_to_cpu(port_name);
249} 259}
250 260
251static void 261static void
@@ -253,20 +263,25 @@ qla2x00_get_starget_port_id(struct scsi_target *starget)
253{ 263{
254 struct Scsi_Host *host = dev_to_shost(starget->dev.parent); 264 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
255 scsi_qla_host_t *ha = to_qla_host(host); 265 scsi_qla_host_t *ha = to_qla_host(host);
256 os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget->id); 266 fc_port_t *fcport;
257 uint32_t port_id = 0; 267 uint32_t port_id = ~0U;
268
269 list_for_each_entry(fcport, &ha->fcports, list) {
270 if (starget->id == fcport->os_target_id) {
271 port_id = fcport->d_id.b.domain << 16 |
272 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
273 break;
274 }
275 }
258 276
259 if (tq->fcport)
260 port_id = tq->fcport->d_id.b.domain << 16 |
261 tq->fcport->d_id.b.area << 8 | tq->fcport->d_id.b.al_pa;
262 fc_starget_port_id(starget) = port_id; 277 fc_starget_port_id(starget) = port_id;
263} 278}
264 279
265static void 280static void
266qla2x00_get_rport_loss_tmo(struct fc_rport *rport) 281qla2x00_get_rport_loss_tmo(struct fc_rport *rport)
267{ 282{
268 os_tgt_t *tq = rport->dd_data; 283 struct Scsi_Host *host = rport_to_shost(rport);
269 scsi_qla_host_t *ha = tq->ha; 284 scsi_qla_host_t *ha = to_qla_host(host);
270 285
271 rport->dev_loss_tmo = ha->port_down_retry_count + 5; 286 rport->dev_loss_tmo = ha->port_down_retry_count + 5;
272} 287}
@@ -274,8 +289,8 @@ qla2x00_get_rport_loss_tmo(struct fc_rport *rport)
274static void 289static void
275qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) 290qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
276{ 291{
277 os_tgt_t *tq = rport->dd_data; 292 struct Scsi_Host *host = rport_to_shost(rport);
278 scsi_qla_host_t *ha = tq->ha; 293 scsi_qla_host_t *ha = to_qla_host(host);
279 294
280 if (timeout) 295 if (timeout)
281 ha->port_down_retry_count = timeout; 296 ha->port_down_retry_count = timeout;
@@ -292,7 +307,7 @@ static struct fc_function_template qla2xxx_transport_functions = {
292 .get_host_port_id = qla2x00_get_host_port_id, 307 .get_host_port_id = qla2x00_get_host_port_id,
293 .show_host_port_id = 1, 308 .show_host_port_id = 1,
294 309
295 .dd_fcrport_size = sizeof(os_tgt_t *), 310 .dd_fcrport_size = sizeof(struct fc_port *),
296 311
297 .get_starget_node_name = qla2x00_get_starget_node_name, 312 .get_starget_node_name = qla2x00_get_starget_node_name,
298 .show_starget_node_name = 1, 313 .show_starget_node_name = 1,
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 0e8ebbc56e81..c4cd4ac414c4 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)
1065 printk(" sp flags=0x%x\n", sp->flags); 1065 printk(" sp flags=0x%x\n", sp->flags);
1066 printk(" r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n", 1066 printk(" r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n",
1067 sp->r_start, sp->u_start, sp->f_start, sp->state); 1067 sp->r_start, sp->u_start, sp->f_start, sp->state);
1068
1069 printk(" e_start= 0x%lx, ext_history=%d, fo retry=%d, loopid=%x, "
1070 "port path=%d\n", sp->e_start, sp->ext_history, sp->fo_retry_cnt,
1071 sp->lun_queue->fclun->fcport->loop_id,
1072 sp->lun_queue->fclun->fcport->cur_path);
1073} 1068}
1074 1069
1075#if defined(QL_DEBUG_ROUTINES) 1070#if defined(QL_DEBUG_ROUTINES)
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index b153d64bb966..7d47b8d92047 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -241,6 +241,7 @@ typedef struct srb {
241 struct list_head list; 241 struct list_head list;
242 242
243 struct scsi_qla_host *ha; /* HA the SP is queued on */ 243 struct scsi_qla_host *ha; /* HA the SP is queued on */
244 struct fc_port *fcport;
244 245
245 struct scsi_cmnd *cmd; /* Linux SCSI command pkt */ 246 struct scsi_cmnd *cmd; /* Linux SCSI command pkt */
246 247
@@ -251,11 +252,6 @@ typedef struct srb {
251 /* Request state */ 252 /* Request state */
252 uint16_t state; 253 uint16_t state;
253 254
254 /* Target/LUN queue pointers. */
255 struct os_tgt *tgt_queue; /* ptr to visible ha's target */
256 struct os_lun *lun_queue; /* ptr to visible ha's lun */
257 struct fc_lun *fclun; /* FC LUN context pointer. */
258
259 /* Timing counts. */ 255 /* Timing counts. */
260 unsigned long e_start; /* Start of extend timeout */ 256 unsigned long e_start; /* Start of extend timeout */
261 unsigned long r_start; /* Start of request */ 257 unsigned long r_start; /* Start of request */
@@ -1603,73 +1599,6 @@ typedef struct {
1603} rpt_lun_cmd_rsp_t; 1599} rpt_lun_cmd_rsp_t;
1604 1600
1605/* 1601/*
1606 * SCSI Target Queue structure
1607 */
1608typedef struct os_tgt {
1609 struct os_lun *olun[MAX_LUNS]; /* LUN context pointer. */
1610 struct fc_port *fcport;
1611 unsigned long flags;
1612 uint8_t port_down_retry_count;
1613 uint32_t down_timer;
1614 struct scsi_qla_host *ha;
1615
1616 /* Persistent binding information */
1617 port_id_t d_id;
1618 uint8_t node_name[WWN_SIZE];
1619 uint8_t port_name[WWN_SIZE];
1620} os_tgt_t;
1621
1622/*
1623 * SCSI Target Queue flags
1624 */
1625#define TQF_ONLINE 0 /* Device online to OS. */
1626#define TQF_SUSPENDED 1
1627#define TQF_RETRY_CMDS 2
1628
1629/*
1630 * SCSI LUN Queue structure
1631 */
1632typedef struct os_lun {
1633 struct fc_lun *fclun; /* FC LUN context pointer. */
1634 spinlock_t q_lock; /* Lun Lock */
1635
1636 unsigned long q_flag;
1637#define LUN_MPIO_RESET_CNTS 1 /* Lun */
1638#define LUN_MPIO_BUSY 2 /* Lun is changing paths */
1639#define LUN_EXEC_DELAYED 7 /* Lun execution is delayed */
1640
1641 u_long q_timeout; /* total command timeouts */
1642 atomic_t q_timer; /* suspend timer */
1643 uint32_t q_count; /* current count */
1644 uint32_t q_max; /* maxmum count lun can be suspended */
1645 uint8_t q_state; /* lun State */
1646#define LUN_STATE_READY 1 /* lun is ready for i/o */
1647#define LUN_STATE_RUN 2 /* lun has a timer running */
1648#define LUN_STATE_WAIT 3 /* lun is suspended */
1649#define LUN_STATE_TIMEOUT 4 /* lun has timed out */
1650
1651 u_long io_cnt; /* total xfer count since boot */
1652 u_long out_cnt; /* total outstanding IO count */
1653 u_long w_cnt; /* total writes */
1654 u_long r_cnt; /* total reads */
1655 u_long avg_time; /* */
1656} os_lun_t;
1657
1658
1659/* LUN BitMask structure definition, array of 32bit words,
1660 * 1 bit per lun. When bit == 1, the lun is masked.
1661 * Most significant bit of mask[0] is lun 0, bit 24 is lun 7.
1662 */
1663typedef struct lun_bit_mask {
1664 /* Must allocate at least enough bits to accomodate all LUNs */
1665#if ((MAX_FIBRE_LUNS & 0x7) == 0)
1666 uint8_t mask[MAX_FIBRE_LUNS >> 3];
1667#else
1668 uint8_t mask[(MAX_FIBRE_LUNS + 8) >> 3];
1669#endif
1670} lun_bit_mask_t;
1671
1672/*
1673 * Fibre channel port type. 1602 * Fibre channel port type.
1674 */ 1603 */
1675 typedef enum { 1604 typedef enum {
@@ -1686,8 +1615,6 @@ typedef struct lun_bit_mask {
1686 */ 1615 */
1687typedef struct fc_port { 1616typedef struct fc_port {
1688 struct list_head list; 1617 struct list_head list;
1689 struct list_head fcluns;
1690
1691 struct scsi_qla_host *ha; 1618 struct scsi_qla_host *ha;
1692 struct scsi_qla_host *vis_ha; /* only used when suspending lun */ 1619 struct scsi_qla_host *vis_ha; /* only used when suspending lun */
1693 1620
@@ -1702,8 +1629,7 @@ typedef struct fc_port {
1702 atomic_t state; 1629 atomic_t state;
1703 uint32_t flags; 1630 uint32_t flags;
1704 1631
1705 os_tgt_t *tgt_queue; 1632 unsigned int os_target_id;
1706 uint16_t os_target_id;
1707 1633
1708 uint16_t iodesc_idx_sent; 1634 uint16_t iodesc_idx_sent;
1709 1635
@@ -1717,7 +1643,6 @@ typedef struct fc_port {
1717 uint8_t mp_byte; /* multi-path byte (not used) */ 1643 uint8_t mp_byte; /* multi-path byte (not used) */
1718 uint8_t cur_path; /* current path id */ 1644 uint8_t cur_path; /* current path id */
1719 1645
1720 lun_bit_mask_t lun_mask;
1721 struct fc_rport *rport; 1646 struct fc_rport *rport;
1722} fc_port_t; 1647} fc_port_t;
1723 1648
@@ -1765,25 +1690,6 @@ typedef struct fc_port {
1765#define FC_NO_LOOP_ID 0x1000 1690#define FC_NO_LOOP_ID 0x1000
1766 1691
1767/* 1692/*
1768 * Fibre channel LUN structure.
1769 */
1770typedef struct fc_lun {
1771 struct list_head list;
1772
1773 fc_port_t *fcport;
1774 fc_port_t *o_fcport;
1775 uint16_t lun;
1776 atomic_t state;
1777 uint8_t device_type;
1778
1779 uint8_t max_path_retries;
1780 uint32_t flags;
1781} fc_lun_t;
1782
1783#define FLF_VISIBLE_LUN BIT_0
1784#define FLF_ACTIVE_LUN BIT_1
1785
1786/*
1787 * FC-CT interface 1693 * FC-CT interface
1788 * 1694 *
1789 * NOTE: All structures are big-endian in form. 1695 * NOTE: All structures are big-endian in form.
@@ -2253,9 +2159,6 @@ typedef struct scsi_qla_host {
2253 struct io_descriptor io_descriptors[MAX_IO_DESCRIPTORS]; 2159 struct io_descriptor io_descriptors[MAX_IO_DESCRIPTORS];
2254 uint16_t iodesc_signature; 2160 uint16_t iodesc_signature;
2255 2161
2256 /* OS target queue pointers. */
2257 os_tgt_t *otgt[MAX_FIBRE_DEVICES];
2258
2259 /* RSCN queue. */ 2162 /* RSCN queue. */
2260 uint32_t rscn_queue[MAX_RSCN_COUNT]; 2163 uint32_t rscn_queue[MAX_RSCN_COUNT];
2261 uint8_t rscn_in_ptr; 2164 uint8_t rscn_in_ptr;
@@ -2400,8 +2303,6 @@ typedef struct scsi_qla_host {
2400#define LOOP_RDY(ha) (!LOOP_NOT_READY(ha)) 2303#define LOOP_RDY(ha) (!LOOP_NOT_READY(ha))
2401 2304
2402#define TGT_Q(ha, t) (ha->otgt[t]) 2305#define TGT_Q(ha, t) (ha->otgt[t])
2403#define LUN_Q(ha, t, l) (TGT_Q(ha, t)->olun[l])
2404#define GET_LU_Q(ha, t, l) ((TGT_Q(ha,t) != NULL)? TGT_Q(ha, t)->olun[l] : NULL)
2405 2306
2406#define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata) 2307#define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata)
2407 2308
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index bc1ef103495a..e4bfe4d5bbe4 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);
45 45
46extern void qla2x00_rescan_fcports(scsi_qla_host_t *); 46extern void qla2x00_rescan_fcports(scsi_qla_host_t *);
47 47
48extern void qla2x00_tgt_free(scsi_qla_host_t *ha, uint16_t t);
49
50extern int qla2x00_abort_isp(scsi_qla_host_t *); 48extern int qla2x00_abort_isp(scsi_qla_host_t *);
51 49
52extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *); 50extern 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 *);
83 81
84extern void qla2x00_cmd_timeout(srb_t *); 82extern void qla2x00_cmd_timeout(srb_t *);
85 83
86extern int __qla2x00_suspend_lun(scsi_qla_host_t *, os_lun_t *, int, int, int);
87
88extern void qla2x00_done(scsi_qla_host_t *);
89extern void qla2x00_flush_failover_q(scsi_qla_host_t *, os_lun_t *);
90extern void qla2x00_reset_lun_fo_counts(scsi_qla_host_t *, os_lun_t *);
91
92extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int); 84extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int);
93extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *); 85extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *);
94 86
@@ -149,7 +141,7 @@ qla2x00_abort_target(fc_port_t *fcport);
149#endif 141#endif
150 142
151extern int 143extern int
152qla2x00_target_reset(scsi_qla_host_t *, uint16_t, uint16_t); 144qla2x00_target_reset(scsi_qla_host_t *, struct fc_port *);
153 145
154extern int 146extern int
155qla2x00_get_adapter_id(scsi_qla_host_t *, uint16_t *, uint8_t *, uint8_t *, 147qla2x00_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 29b301ecd2ff..0387005fcb6d 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 *);
45static int qla2x00_fw_ready(scsi_qla_host_t *); 45static int qla2x00_fw_ready(scsi_qla_host_t *);
46static int qla2x00_configure_hba(scsi_qla_host_t *); 46static int qla2x00_configure_hba(scsi_qla_host_t *);
47static int qla2x00_nvram_config(scsi_qla_host_t *); 47static int qla2x00_nvram_config(scsi_qla_host_t *);
48static void qla2x00_init_tgt_map(scsi_qla_host_t *);
49static int qla2x00_configure_loop(scsi_qla_host_t *); 48static int qla2x00_configure_loop(scsi_qla_host_t *);
50static int qla2x00_configure_local_loop(scsi_qla_host_t *); 49static int qla2x00_configure_local_loop(scsi_qla_host_t *);
51static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *); 50static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
52static void qla2x00_lun_discovery(scsi_qla_host_t *, fc_port_t *);
53static int qla2x00_rpt_lun_discovery(scsi_qla_host_t *, fc_port_t *,
54 inq_cmd_rsp_t *, dma_addr_t);
55static int qla2x00_report_lun(scsi_qla_host_t *, fc_port_t *);
56static fc_lun_t *qla2x00_cfg_lun(scsi_qla_host_t *, fc_port_t *, uint16_t,
57 inq_cmd_rsp_t *, dma_addr_t);
58static fc_lun_t * qla2x00_add_lun(fc_port_t *, uint16_t);
59static int qla2x00_inquiry(scsi_qla_host_t *, fc_port_t *, uint16_t,
60 inq_cmd_rsp_t *, dma_addr_t);
61static int qla2x00_configure_fabric(scsi_qla_host_t *); 51static int qla2x00_configure_fabric(scsi_qla_host_t *);
62static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *); 52static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *);
63static int qla2x00_device_resync(scsi_qla_host_t *); 53static int qla2x00_device_resync(scsi_qla_host_t *);
64static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *, 54static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *,
65 uint16_t *); 55 uint16_t *);
66static void qla2x00_config_os(scsi_qla_host_t *ha);
67static uint16_t qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport);
68static os_lun_t * qla2x00_fclun_bind(scsi_qla_host_t *, fc_port_t *,
69 fc_lun_t *);
70static void qla2x00_lun_free(scsi_qla_host_t *, uint16_t, uint16_t);
71 56
72static int qla2x00_restart_isp(scsi_qla_host_t *); 57static int qla2x00_restart_isp(scsi_qla_host_t *);
73static void qla2x00_reset_adapter(scsi_qla_host_t *); 58static void qla2x00_reset_adapter(scsi_qla_host_t *);
74static os_tgt_t *qla2x00_tgt_alloc(scsi_qla_host_t *, uint16_t);
75static os_lun_t *qla2x00_lun_alloc(scsi_qla_host_t *, uint16_t, uint16_t);
76 59
77/****************************************************************************/ 60/****************************************************************************/
78/* QLogic ISP2x00 Hardware Support Functions. */ 61/* QLogic ISP2x00 Hardware Support Functions. */
@@ -120,9 +103,6 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
120 103
121 qla2x00_reset_chip(ha); 104 qla2x00_reset_chip(ha);
122 105
123 /* Initialize target map database. */
124 qla2x00_init_tgt_map(ha);
125
126 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); 106 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n");
127 qla2x00_nvram_config(ha); 107 qla2x00_nvram_config(ha);
128 108
@@ -1530,25 +1510,6 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1530 return (rval); 1510 return (rval);
1531} 1511}
1532 1512
1533/*
1534* qla2x00_init_tgt_map
1535* Initializes target map.
1536*
1537* Input:
1538* ha = adapter block pointer.
1539*
1540* Output:
1541* TGT_Q initialized
1542*/
1543static void
1544qla2x00_init_tgt_map(scsi_qla_host_t *ha)
1545{
1546 uint32_t t;
1547
1548 for (t = 0; t < MAX_TARGETS; t++)
1549 TGT_Q(ha, t) = (os_tgt_t *)NULL;
1550}
1551
1552/** 1513/**
1553 * qla2x00_alloc_fcport() - Allocate a generic fcport. 1514 * qla2x00_alloc_fcport() - Allocate a generic fcport.
1554 * @ha: HA context 1515 * @ha: HA context
@@ -1573,7 +1534,6 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, int flags)
1573 fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; 1534 fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
1574 atomic_set(&fcport->state, FCS_UNCONFIGURED); 1535 atomic_set(&fcport->state, FCS_UNCONFIGURED);
1575 fcport->flags = FCF_RLC_SUPPORT; 1536 fcport->flags = FCF_RLC_SUPPORT;
1576 INIT_LIST_HEAD(&fcport->fcluns);
1577 1537
1578 return (fcport); 1538 return (fcport);
1579} 1539}
@@ -1663,7 +1623,6 @@ qla2x00_configure_loop(scsi_qla_host_t *ha)
1663 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { 1623 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
1664 rval = QLA_FUNCTION_FAILED; 1624 rval = QLA_FUNCTION_FAILED;
1665 } else { 1625 } else {
1666 qla2x00_config_os(ha);
1667 atomic_set(&ha->loop_state, LOOP_READY); 1626 atomic_set(&ha->loop_state, LOOP_READY);
1668 1627
1669 DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no)); 1628 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)
1908 if (fcport->flags & FCF_TAPE_PRESENT) { 1867 if (fcport->flags & FCF_TAPE_PRESENT) {
1909 spin_lock_irqsave(&ha->hardware_lock, flags); 1868 spin_lock_irqsave(&ha->hardware_lock, flags);
1910 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { 1869 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
1870 fc_port_t *sfcp;
1871
1911 if ((sp = ha->outstanding_cmds[index]) != 0) { 1872 if ((sp = ha->outstanding_cmds[index]) != 0) {
1912 if (sp->fclun->fcport == fcport) { 1873 sfcp = sp->fcport;
1874 if (sfcp == fcport) {
1913 atomic_set(&fcport->state, FCS_ONLINE); 1875 atomic_set(&fcport->state, FCS_ONLINE);
1914 spin_unlock_irqrestore( 1876 spin_unlock_irqrestore(
1915 &ha->hardware_lock, flags); 1877 &ha->hardware_lock, flags);
@@ -1920,14 +1882,12 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
1920 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1882 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1921 } 1883 }
1922 1884
1923 /* Do LUN discovery. */
1924 if (fcport->port_type == FCT_INITIATOR || 1885 if (fcport->port_type == FCT_INITIATOR ||
1925 fcport->port_type == FCT_BROADCAST) { 1886 fcport->port_type == FCT_BROADCAST)
1926 fcport->device_type = TYPE_PROCESSOR; 1887 fcport->device_type = TYPE_PROCESSOR;
1927 } else { 1888
1928 qla2x00_lun_discovery(ha, fcport);
1929 }
1930 atomic_set(&fcport->state, FCS_ONLINE); 1889 atomic_set(&fcport->state, FCS_ONLINE);
1890
1931 if (ha->flags.init_done) 1891 if (ha->flags.init_done)
1932 qla2x00_reg_remote_port(ha, fcport); 1892 qla2x00_reg_remote_port(ha, fcport);
1933} 1893}
@@ -1936,6 +1896,7 @@ void
1936qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) 1896qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
1937{ 1897{
1938 struct fc_rport_identifiers rport_ids; 1898 struct fc_rport_identifiers rport_ids;
1899 struct fc_rport *rport;
1939 1900
1940 if (fcport->rport) { 1901 if (fcport->rport) {
1941 fc_remote_port_unblock(fcport->rport); 1902 fc_remote_port_unblock(fcport->rport);
@@ -1952,419 +1913,18 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
1952 if (fcport->port_type == FCT_TARGET) 1913 if (fcport->port_type == FCT_TARGET)
1953 rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; 1914 rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
1954 1915
1955 fcport->rport = fc_remote_port_add(ha->host, 0, &rport_ids); 1916 fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids);
1956 if (!fcport->rport) 1917 if (!rport)
1957 qla_printk(KERN_WARNING, ha, 1918 qla_printk(KERN_WARNING, ha,
1958 "Unable to allocate fc remote port!\n"); 1919 "Unable to allocate fc remote port!\n");
1959}
1960/*
1961 * qla2x00_lun_discovery
1962 * Issue SCSI inquiry command for LUN discovery.
1963 *
1964 * Input:
1965 * ha: adapter state pointer.
1966 * fcport: FC port structure pointer.
1967 *
1968 * Context:
1969 * Kernel context.
1970 */
1971static void
1972qla2x00_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport)
1973{
1974 inq_cmd_rsp_t *inq;
1975 dma_addr_t inq_dma;
1976 uint16_t lun;
1977
1978 inq = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &inq_dma);
1979 if (inq == NULL) {
1980 qla_printk(KERN_WARNING, ha,
1981 "Memory Allocation failed - INQ\n");
1982 return;
1983 }
1984 1920
1985 /* Always add a fc_lun_t structure for lun 0 -- mid-layer requirement */ 1921 if (rport->scsi_target_id != -1 && rport->scsi_target_id < MAX_TARGETS)
1986 qla2x00_add_lun(fcport, 0); 1922 fcport->os_target_id = rport->scsi_target_id;
1987
1988 /* If report LUN works, exit. */
1989 if (qla2x00_rpt_lun_discovery(ha, fcport, inq, inq_dma) !=
1990 QLA_SUCCESS) {
1991 for (lun = 0; lun < ha->max_probe_luns; lun++) {
1992 /* Configure LUN. */
1993 qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma);
1994 }
1995 }
1996 1923
1997 dma_pool_free(ha->s_dma_pool, inq, inq_dma); 1924 rport->dd_data = fcport;
1998} 1925}
1999 1926
2000/* 1927/*
2001 * qla2x00_rpt_lun_discovery
2002 * Issue SCSI report LUN command for LUN discovery.
2003 *
2004 * Input:
2005 * ha: adapter state pointer.
2006 * fcport: FC port structure pointer.
2007 *
2008 * Returns:
2009 * qla2x00 local function return status code.
2010 *
2011 * Context:
2012 * Kernel context.
2013 */
2014static int
2015qla2x00_rpt_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport,
2016 inq_cmd_rsp_t *inq, dma_addr_t inq_dma)
2017{
2018 int rval;
2019 uint32_t len, cnt;
2020 uint16_t lun;
2021
2022 /* Assume a failed status */
2023 rval = QLA_FUNCTION_FAILED;
2024
2025 /* No point in continuing if the device doesn't support RLC */
2026 if ((fcport->flags & FCF_RLC_SUPPORT) == 0)
2027 return (rval);
2028
2029 rval = qla2x00_report_lun(ha, fcport);
2030 if (rval != QLA_SUCCESS)
2031 return (rval);
2032
2033 /* Configure LUN list. */
2034 len = be32_to_cpu(ha->rlc_rsp->list.hdr.len);
2035 len /= 8;
2036 for (cnt = 0; cnt < len; cnt++) {
2037 lun = CHAR_TO_SHORT(ha->rlc_rsp->list.lst[cnt].lsb,
2038 ha->rlc_rsp->list.lst[cnt].msb.b);
2039
2040 DEBUG3(printk("scsi(%ld): RLC lun = (%d)\n", ha->host_no, lun));
2041
2042 /* We only support 0 through MAX_LUNS-1 range */
2043 if (lun < MAX_LUNS) {
2044 qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma);
2045 }
2046 }
2047 atomic_set(&fcport->state, FCS_ONLINE);
2048
2049 return (rval);
2050}
2051
2052/*
2053 * qla2x00_report_lun
2054 * Issue SCSI report LUN command.
2055 *
2056 * Input:
2057 * ha: adapter state pointer.
2058 * fcport: FC port structure pointer.
2059 *
2060 * Returns:
2061 * qla2x00 local function return status code.
2062 *
2063 * Context:
2064 * Kernel context.
2065 */
2066static int
2067qla2x00_report_lun(scsi_qla_host_t *ha, fc_port_t *fcport)
2068{
2069 int rval;
2070 uint16_t retries;
2071 uint16_t comp_status;
2072 uint16_t scsi_status;
2073 rpt_lun_cmd_rsp_t *rlc;
2074 dma_addr_t rlc_dma;
2075
2076 rval = QLA_FUNCTION_FAILED;
2077 rlc = ha->rlc_rsp;
2078 rlc_dma = ha->rlc_rsp_dma;
2079
2080 for (retries = 3; retries; retries--) {
2081 memset(rlc, 0, sizeof(rpt_lun_cmd_rsp_t));
2082 rlc->p.cmd.entry_type = COMMAND_A64_TYPE;
2083 rlc->p.cmd.entry_count = 1;
2084 SET_TARGET_ID(ha, rlc->p.cmd.target, fcport->loop_id);
2085 rlc->p.cmd.control_flags =
2086 __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG);
2087 rlc->p.cmd.scsi_cdb[0] = REPORT_LUNS;
2088 rlc->p.cmd.scsi_cdb[8] = MSB(sizeof(rpt_lun_lst_t));
2089 rlc->p.cmd.scsi_cdb[9] = LSB(sizeof(rpt_lun_lst_t));
2090 rlc->p.cmd.dseg_count = __constant_cpu_to_le16(1);
2091 rlc->p.cmd.timeout = __constant_cpu_to_le16(10);
2092 rlc->p.cmd.byte_count =
2093 __constant_cpu_to_le32(sizeof(rpt_lun_lst_t));
2094 rlc->p.cmd.dseg_0_address[0] = cpu_to_le32(
2095 LSD(rlc_dma + sizeof(sts_entry_t)));
2096 rlc->p.cmd.dseg_0_address[1] = cpu_to_le32(
2097 MSD(rlc_dma + sizeof(sts_entry_t)));
2098 rlc->p.cmd.dseg_0_length =
2099 __constant_cpu_to_le32(sizeof(rpt_lun_lst_t));
2100
2101 rval = qla2x00_issue_iocb(ha, rlc, rlc_dma,
2102 sizeof(rpt_lun_cmd_rsp_t));
2103
2104 comp_status = le16_to_cpu(rlc->p.rsp.comp_status);
2105 scsi_status = le16_to_cpu(rlc->p.rsp.scsi_status);
2106
2107 if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE ||
2108 scsi_status & SS_CHECK_CONDITION) {
2109
2110 /* Device underrun, treat as OK. */
2111 if (rval == QLA_SUCCESS &&
2112 comp_status == CS_DATA_UNDERRUN &&
2113 scsi_status & SS_RESIDUAL_UNDER) {
2114
2115 rval = QLA_SUCCESS;
2116 break;
2117 }
2118
2119 DEBUG(printk("scsi(%ld): RLC failed to issue iocb! "
2120 "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n",
2121 ha->host_no, fcport->loop_id, fcport, rval,
2122 comp_status, scsi_status));
2123
2124 rval = QLA_FUNCTION_FAILED;
2125 if (scsi_status & SS_CHECK_CONDITION) {
2126 DEBUG2(printk("scsi(%ld): RLC "
2127 "SS_CHECK_CONDITION Sense Data "
2128 "%02x %02x %02x %02x %02x %02x %02x %02x\n",
2129 ha->host_no,
2130 rlc->p.rsp.req_sense_data[0],
2131 rlc->p.rsp.req_sense_data[1],
2132 rlc->p.rsp.req_sense_data[2],
2133 rlc->p.rsp.req_sense_data[3],
2134 rlc->p.rsp.req_sense_data[4],
2135 rlc->p.rsp.req_sense_data[5],
2136 rlc->p.rsp.req_sense_data[6],
2137 rlc->p.rsp.req_sense_data[7]));
2138 if (rlc->p.rsp.req_sense_data[2] ==
2139 ILLEGAL_REQUEST) {
2140 fcport->flags &= ~(FCF_RLC_SUPPORT);
2141 break;
2142 }
2143 }
2144 } else {
2145 break;
2146 }
2147 }
2148
2149 return (rval);
2150}
2151
2152/*
2153 * qla2x00_cfg_lun
2154 * Configures LUN into fcport LUN list.
2155 *
2156 * Input:
2157 * fcport: FC port structure pointer.
2158 * lun: LUN number.
2159 *
2160 * Context:
2161 * Kernel context.
2162 */
2163static fc_lun_t *
2164qla2x00_cfg_lun(scsi_qla_host_t *ha, fc_port_t *fcport, uint16_t lun,
2165 inq_cmd_rsp_t *inq, dma_addr_t inq_dma)
2166{
2167 fc_lun_t *fclun;
2168 uint8_t device_type;
2169
2170 /* Bypass LUNs that failed. */
2171 if (qla2x00_inquiry(ha, fcport, lun, inq, inq_dma) != QLA_SUCCESS) {
2172 DEBUG2(printk("scsi(%ld): Failed inquiry - loop id=0x%04x "
2173 "lun=%d\n", ha->host_no, fcport->loop_id, lun));
2174
2175 return (NULL);
2176 }
2177 device_type = (inq->inq[0] & 0x1f);
2178 switch (device_type) {
2179 case TYPE_DISK:
2180 case TYPE_PROCESSOR:
2181 case TYPE_WORM:
2182 case TYPE_ROM:
2183 case TYPE_SCANNER:
2184 case TYPE_MOD:
2185 case TYPE_MEDIUM_CHANGER:
2186 case TYPE_ENCLOSURE:
2187 case 0x20:
2188 case 0x0C:
2189 break;
2190 case TYPE_TAPE:
2191 fcport->flags |= FCF_TAPE_PRESENT;
2192 break;
2193 default:
2194 DEBUG2(printk("scsi(%ld): Unsupported lun type -- "
2195 "loop id=0x%04x lun=%d type=%x\n",
2196 ha->host_no, fcport->loop_id, lun, device_type));
2197 return (NULL);
2198 }
2199
2200 fcport->device_type = device_type;
2201 fclun = qla2x00_add_lun(fcport, lun);
2202
2203 if (fclun != NULL) {
2204 atomic_set(&fcport->state, FCS_ONLINE);
2205 }
2206
2207 return (fclun);
2208}
2209
2210/*
2211 * qla2x00_add_lun
2212 * Adds LUN to database
2213 *
2214 * Input:
2215 * fcport: FC port structure pointer.
2216 * lun: LUN number.
2217 *
2218 * Context:
2219 * Kernel context.
2220 */
2221static fc_lun_t *
2222qla2x00_add_lun(fc_port_t *fcport, uint16_t lun)
2223{
2224 int found;
2225 fc_lun_t *fclun;
2226
2227 if (fcport == NULL) {
2228 DEBUG(printk("scsi: Unable to add lun to NULL port\n"));
2229 return (NULL);
2230 }
2231
2232 /* Allocate LUN if not already allocated. */
2233 found = 0;
2234 list_for_each_entry(fclun, &fcport->fcluns, list) {
2235 if (fclun->lun == lun) {
2236 found++;
2237 break;
2238 }
2239 }
2240 if (found)
2241 return (NULL);
2242
2243 fclun = kmalloc(sizeof(fc_lun_t), GFP_ATOMIC);
2244 if (fclun == NULL) {
2245 printk(KERN_WARNING
2246 "%s(): Memory Allocation failed - FCLUN\n",
2247 __func__);
2248 return (NULL);
2249 }
2250
2251 /* Setup LUN structure. */
2252 memset(fclun, 0, sizeof(fc_lun_t));
2253 fclun->lun = lun;
2254 fclun->fcport = fcport;
2255 fclun->o_fcport = fcport;
2256 fclun->device_type = fcport->device_type;
2257 atomic_set(&fcport->state, FCS_UNCONFIGURED);
2258
2259 list_add_tail(&fclun->list, &fcport->fcluns);
2260
2261 return (fclun);
2262}
2263
2264/*
2265 * qla2x00_inquiry
2266 * Issue SCSI inquiry command.
2267 *
2268 * Input:
2269 * ha = adapter block pointer.
2270 * fcport = FC port structure pointer.
2271 *
2272 * Return:
2273 * 0 - Success
2274 * BIT_0 - error
2275 *
2276 * Context:
2277 * Kernel context.
2278 */
2279static int
2280qla2x00_inquiry(scsi_qla_host_t *ha,
2281 fc_port_t *fcport, uint16_t lun, inq_cmd_rsp_t *inq, dma_addr_t inq_dma)
2282{
2283 int rval;
2284 uint16_t retries;
2285 uint16_t comp_status;
2286 uint16_t scsi_status;
2287
2288 rval = QLA_FUNCTION_FAILED;
2289
2290 for (retries = 3; retries; retries--) {
2291 memset(inq, 0, sizeof(inq_cmd_rsp_t));
2292 inq->p.cmd.entry_type = COMMAND_A64_TYPE;
2293 inq->p.cmd.entry_count = 1;
2294 inq->p.cmd.lun = cpu_to_le16(lun);
2295 SET_TARGET_ID(ha, inq->p.cmd.target, fcport->loop_id);
2296 inq->p.cmd.control_flags =
2297 __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG);
2298 inq->p.cmd.scsi_cdb[0] = INQUIRY;
2299 inq->p.cmd.scsi_cdb[4] = INQ_DATA_SIZE;
2300 inq->p.cmd.dseg_count = __constant_cpu_to_le16(1);
2301 inq->p.cmd.timeout = __constant_cpu_to_le16(10);
2302 inq->p.cmd.byte_count =
2303 __constant_cpu_to_le32(INQ_DATA_SIZE);
2304 inq->p.cmd.dseg_0_address[0] = cpu_to_le32(
2305 LSD(inq_dma + sizeof(sts_entry_t)));
2306 inq->p.cmd.dseg_0_address[1] = cpu_to_le32(
2307 MSD(inq_dma + sizeof(sts_entry_t)));
2308 inq->p.cmd.dseg_0_length =
2309 __constant_cpu_to_le32(INQ_DATA_SIZE);
2310
2311 DEBUG5(printk("scsi(%ld): Lun Inquiry - fcport=[%04x/%p],"
2312 " lun (%d)\n",
2313 ha->host_no, fcport->loop_id, fcport, lun));
2314
2315 rval = qla2x00_issue_iocb(ha, inq, inq_dma,
2316 sizeof(inq_cmd_rsp_t));
2317
2318 comp_status = le16_to_cpu(inq->p.rsp.comp_status);
2319 scsi_status = le16_to_cpu(inq->p.rsp.scsi_status);
2320
2321 DEBUG5(printk("scsi(%ld): lun (%d) inquiry - "
2322 "inq[0]= 0x%x, comp status 0x%x, scsi status 0x%x, "
2323 "rval=%d\n",
2324 ha->host_no, lun, inq->inq[0], comp_status, scsi_status,
2325 rval));
2326
2327 if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE ||
2328 scsi_status & SS_CHECK_CONDITION) {
2329
2330 DEBUG(printk("scsi(%ld): INQ failed to issue iocb! "
2331 "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n",
2332 ha->host_no, fcport->loop_id, fcport, rval,
2333 comp_status, scsi_status));
2334
2335 if (rval == QLA_SUCCESS)
2336 rval = QLA_FUNCTION_FAILED;
2337
2338 if (scsi_status & SS_CHECK_CONDITION) {
2339 DEBUG2(printk("scsi(%ld): INQ "
2340 "SS_CHECK_CONDITION Sense Data "
2341 "%02x %02x %02x %02x %02x %02x %02x %02x\n",
2342 ha->host_no,
2343 inq->p.rsp.req_sense_data[0],
2344 inq->p.rsp.req_sense_data[1],
2345 inq->p.rsp.req_sense_data[2],
2346 inq->p.rsp.req_sense_data[3],
2347 inq->p.rsp.req_sense_data[4],
2348 inq->p.rsp.req_sense_data[5],
2349 inq->p.rsp.req_sense_data[6],
2350 inq->p.rsp.req_sense_data[7]));
2351 }
2352
2353 /* Device underrun drop LUN. */
2354 if (comp_status == CS_DATA_UNDERRUN &&
2355 scsi_status & SS_RESIDUAL_UNDER) {
2356 break;
2357 }
2358 } else {
2359 break;
2360 }
2361 }
2362
2363 return (rval);
2364}
2365
2366
2367/*
2368 * qla2x00_configure_fabric 1928 * qla2x00_configure_fabric
2369 * Setup SNS devices with loop ID's. 1929 * Setup SNS devices with loop ID's.
2370 * 1930 *
@@ -2514,12 +2074,12 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha)
2514 break; 2074 break;
2515 } 2075 }
2516 2076
2517 /* Login and update database */
2518 qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
2519
2520 /* Remove device from the new list and add it to DB */ 2077 /* Remove device from the new list and add it to DB */
2521 list_del(&fcport->list); 2078 list_del(&fcport->list);
2522 list_add_tail(&fcport->list, &ha->fcports); 2079 list_add_tail(&fcport->list, &ha->fcports);
2080
2081 /* Login and update database */
2082 qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
2523 } 2083 }
2524 } while (0); 2084 } while (0);
2525 2085
@@ -3203,396 +2763,6 @@ qla2x00_rescan_fcports(scsi_qla_host_t *ha)
3203 rescan_done = 1; 2763 rescan_done = 1;
3204 } 2764 }
3205 qla2x00_probe_for_all_luns(ha); 2765 qla2x00_probe_for_all_luns(ha);
3206
3207 /* Update OS target and lun structures if necessary. */
3208 if (rescan_done) {
3209 qla2x00_config_os(ha);
3210 }
3211}
3212
3213
3214/*
3215 * qla2x00_config_os
3216 * Setup OS target and LUN structures.
3217 *
3218 * Input:
3219 * ha = adapter state pointer.
3220 *
3221 * Context:
3222 * Kernel context.
3223 */
3224static void
3225qla2x00_config_os(scsi_qla_host_t *ha)
3226{
3227 fc_port_t *fcport;
3228 fc_lun_t *fclun;
3229 os_tgt_t *tq;
3230 uint16_t tgt;
3231
3232
3233 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
3234 if ((tq = TGT_Q(ha, tgt)) == NULL)
3235 continue;
3236
3237 clear_bit(TQF_ONLINE, &tq->flags);
3238 }
3239
3240 list_for_each_entry(fcport, &ha->fcports, list) {
3241 if (atomic_read(&fcport->state) != FCS_ONLINE ||
3242 fcport->port_type == FCT_INITIATOR ||
3243 fcport->port_type == FCT_BROADCAST) {
3244 fcport->os_target_id = MAX_TARGETS;
3245 continue;
3246 }
3247
3248 if (fcport->flags & FCF_FO_MASKED) {
3249 continue;
3250 }
3251
3252 /* Bind FC port to OS target number. */
3253 if (qla2x00_fcport_bind(ha, fcport) == MAX_TARGETS) {
3254 continue;
3255 }
3256
3257 /* Bind FC LUN to OS LUN number. */
3258 list_for_each_entry(fclun, &fcport->fcluns, list) {
3259 qla2x00_fclun_bind(ha, fcport, fclun);
3260 }
3261 }
3262}
3263
3264/*
3265 * qla2x00_fcport_bind
3266 * Locates a target number for FC port.
3267 *
3268 * Input:
3269 * ha = adapter state pointer.
3270 * fcport = FC port structure pointer.
3271 *
3272 * Returns:
3273 * target number
3274 *
3275 * Context:
3276 * Kernel context.
3277 */
3278static uint16_t
3279qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport)
3280{
3281 int found;
3282 uint16_t tgt;
3283 os_tgt_t *tq;
3284
3285 /* Check for persistent binding. */
3286 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
3287 if ((tq = TGT_Q(ha, tgt)) == NULL)
3288 continue;
3289
3290 found = 0;
3291 switch (ha->binding_type) {
3292 case BIND_BY_PORT_ID:
3293 if (fcport->d_id.b24 == tq->d_id.b24) {
3294 memcpy(tq->node_name, fcport->node_name,
3295 WWN_SIZE);
3296 memcpy(tq->port_name, fcport->port_name,
3297 WWN_SIZE);
3298 found++;
3299 }
3300 break;
3301 case BIND_BY_PORT_NAME:
3302 if (memcmp(fcport->port_name, tq->port_name,
3303 WWN_SIZE) == 0) {
3304 /*
3305 * In case of persistent binding, update the
3306 * WWNN.
3307 */
3308 memcpy(tq->node_name, fcport->node_name,
3309 WWN_SIZE);
3310 found++;
3311 }
3312 break;
3313 }
3314 if (found)
3315 break;
3316 }
3317
3318 /* TODO: honor the ConfigRequired flag */
3319 if (tgt == MAX_TARGETS) {
3320 /* Check if targetID 0 available. */
3321 tgt = 0;
3322
3323 if (TGT_Q(ha, tgt) != NULL) {
3324 /* Locate first free target for device. */
3325 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
3326 if (TGT_Q(ha, tgt) == NULL) {
3327 break;
3328 }
3329 }
3330 }
3331 if (tgt != MAX_TARGETS) {
3332 if ((tq = qla2x00_tgt_alloc(ha, tgt)) != NULL) {
3333 memcpy(tq->node_name, fcport->node_name,
3334 WWN_SIZE);
3335 memcpy(tq->port_name, fcport->port_name,
3336 WWN_SIZE);
3337 tq->d_id.b24 = fcport->d_id.b24;
3338 }
3339 }
3340 }
3341
3342 /* Reset target numbers incase it changed. */
3343 fcport->os_target_id = tgt;
3344 if (tgt != MAX_TARGETS && tq != NULL) {
3345 DEBUG2(printk("scsi(%ld): Assigning target ID=%02d @ %p to "
3346 "loop id=0x%04x, port state=0x%x, port down retry=%d\n",
3347 ha->host_no, tgt, tq, fcport->loop_id,
3348 atomic_read(&fcport->state),
3349 atomic_read(&fcport->port_down_timer)));
3350
3351 fcport->tgt_queue = tq;
3352 fcport->flags |= FCF_PERSISTENT_BOUND;
3353 tq->fcport = fcport;
3354 set_bit(TQF_ONLINE, &tq->flags);
3355 tq->port_down_retry_count = ha->port_down_retry_count;
3356 }
3357
3358 if (tgt == MAX_TARGETS) {
3359 qla_printk(KERN_WARNING, ha,
3360 "Unable to bind fcport, loop_id=%x\n", fcport->loop_id);
3361 }
3362
3363 return (tgt);
3364}
3365
3366/*
3367 * qla2x00_fclun_bind
3368 * Binds all FC device LUNS to OS LUNS.
3369 *
3370 * Input:
3371 * ha: adapter state pointer.
3372 * fcport: FC port structure pointer.
3373 *
3374 * Returns:
3375 * target number
3376 *
3377 * Context:
3378 * Kernel context.
3379 */
3380static os_lun_t *
3381qla2x00_fclun_bind(scsi_qla_host_t *ha, fc_port_t *fcport, fc_lun_t *fclun)
3382{
3383 os_lun_t *lq;
3384 uint16_t tgt;
3385 uint16_t lun;
3386
3387 tgt = fcport->os_target_id;
3388 lun = fclun->lun;
3389
3390 /* Allocate LUNs */
3391 if (lun >= MAX_LUNS) {
3392 DEBUG2(printk("scsi(%ld): Unable to bind lun, invalid "
3393 "lun=(%x).\n", ha->host_no, lun));
3394 return (NULL);
3395 }
3396
3397 /* Always alloc LUN 0 so kernel will scan past LUN 0. */
3398 if (lun != 0 && (EXT_IS_LUN_BIT_SET(&(fcport->lun_mask), lun))) {
3399 return (NULL);
3400 }
3401
3402 if ((lq = qla2x00_lun_alloc(ha, tgt, lun)) == NULL) {
3403 qla_printk(KERN_WARNING, ha,
3404 "Unable to bind fclun, loop_id=%x lun=%x\n",
3405 fcport->loop_id, lun);
3406 return (NULL);
3407 }
3408
3409 lq->fclun = fclun;
3410
3411 return (lq);
3412}
3413
3414/*
3415 * qla2x00_tgt_alloc
3416 * Allocate and pre-initialize target queue.
3417 *
3418 * Input:
3419 * ha = adapter block pointer.
3420 * t = SCSI target number.
3421 *
3422 * Returns:
3423 * NULL = failure
3424 *
3425 * Context:
3426 * Kernel context.
3427 */
3428static os_tgt_t *
3429qla2x00_tgt_alloc(scsi_qla_host_t *ha, uint16_t tgt)
3430{
3431 os_tgt_t *tq;
3432
3433 /*
3434 * If SCSI addressing OK, allocate TGT queue and lock.
3435 */
3436 if (tgt >= MAX_TARGETS) {
3437 DEBUG2(printk("scsi(%ld): Unable to allocate target, invalid "
3438 "target number %d.\n", ha->host_no, tgt));
3439 return (NULL);
3440 }
3441
3442 tq = TGT_Q(ha, tgt);
3443 if (tq == NULL) {
3444 tq = kmalloc(sizeof(os_tgt_t), GFP_ATOMIC);
3445 if (tq != NULL) {
3446 DEBUG2(printk("scsi(%ld): Alloc Target %d @ %p\n",
3447 ha->host_no, tgt, tq));
3448
3449 memset(tq, 0, sizeof(os_tgt_t));
3450 tq->ha = ha;
3451
3452 TGT_Q(ha, tgt) = tq;
3453 }
3454 }
3455 if (tq != NULL) {
3456 tq->port_down_retry_count = ha->port_down_retry_count;
3457 } else {
3458 qla_printk(KERN_WARNING, ha,
3459 "Unable to allocate target.\n");
3460 ha->mem_err++;
3461 }
3462
3463 return (tq);
3464}
3465
3466/*
3467 * qla2x00_tgt_free
3468 * Frees target and LUN queues.
3469 *
3470 * Input:
3471 * ha = adapter block pointer.
3472 * t = SCSI target number.
3473 *
3474 * Context:
3475 * Kernel context.
3476 */
3477void
3478qla2x00_tgt_free(scsi_qla_host_t *ha, uint16_t tgt)
3479{
3480 os_tgt_t *tq;
3481 uint16_t lun;
3482
3483 /*
3484 * If SCSI addressing OK, allocate TGT queue and lock.
3485 */
3486 if (tgt >= MAX_TARGETS) {
3487 DEBUG2(printk("scsi(%ld): Unable to de-allocate target, "
3488 "invalid target number %d.\n", ha->host_no, tgt));
3489
3490 return;
3491 }
3492
3493 tq = TGT_Q(ha, tgt);
3494 if (tq != NULL) {
3495 TGT_Q(ha, tgt) = NULL;
3496
3497 /* Free LUN structures. */
3498 for (lun = 0; lun < MAX_LUNS; lun++)
3499 qla2x00_lun_free(ha, tgt, lun);
3500
3501 kfree(tq);
3502 }
3503
3504 return;
3505}
3506
3507/*
3508 * qla2x00_lun_alloc
3509 * Allocate and initialize LUN queue.
3510 *
3511 * Input:
3512 * ha = adapter block pointer.
3513 * t = SCSI target number.
3514 * l = LUN number.
3515 *
3516 * Returns:
3517 * NULL = failure
3518 *
3519 * Context:
3520 * Kernel context.
3521 */
3522static os_lun_t *
3523qla2x00_lun_alloc(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun)
3524{
3525 os_lun_t *lq;
3526
3527 /*
3528 * If SCSI addressing OK, allocate LUN queue.
3529 */
3530 if (tgt >= MAX_TARGETS || lun >= MAX_LUNS || TGT_Q(ha, tgt) == NULL) {
3531 DEBUG2(printk("scsi(%ld): Unable to allocate lun, invalid "
3532 "parameter.\n", ha->host_no));
3533
3534 return (NULL);
3535 }
3536
3537 lq = LUN_Q(ha, tgt, lun);
3538 if (lq == NULL) {
3539 lq = kmalloc(sizeof(os_lun_t), GFP_ATOMIC);
3540 if (lq != NULL) {
3541 DEBUG2(printk("scsi(%ld): Alloc Lun %d @ tgt %d.\n",
3542 ha->host_no, lun, tgt));
3543
3544 memset(lq, 0, sizeof(os_lun_t));
3545 LUN_Q(ha, tgt, lun) = lq;
3546
3547 /*
3548 * The following lun queue initialization code
3549 * must be duplicated in alloc_ioctl_mem function
3550 * for ioctl_lq.
3551 */
3552 lq->q_state = LUN_STATE_READY;
3553 spin_lock_init(&lq->q_lock);
3554 }
3555 }
3556
3557 if (lq == NULL) {
3558 qla_printk(KERN_WARNING, ha, "Unable to allocate lun.\n");
3559 }
3560
3561 return (lq);
3562}
3563
3564/*
3565 * qla2x00_lun_free
3566 * Frees LUN queue.
3567 *
3568 * Input:
3569 * ha = adapter block pointer.
3570 * t = SCSI target number.
3571 *
3572 * Context:
3573 * Kernel context.
3574 */
3575static void
3576qla2x00_lun_free(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun)
3577{
3578 os_lun_t *lq;
3579
3580 /*
3581 * If SCSI addressing OK, allocate TGT queue and lock.
3582 */
3583 if (tgt >= MAX_TARGETS || lun >= MAX_LUNS) {
3584 DEBUG2(printk("scsi(%ld): Unable to deallocate lun, invalid "
3585 "parameter.\n", ha->host_no));
3586
3587 return;
3588 }
3589
3590 if (TGT_Q(ha, tgt) != NULL && (lq = LUN_Q(ha, tgt, lun)) != NULL) {
3591 LUN_Q(ha, tgt, lun) = NULL;
3592 kfree(lq);
3593 }
3594
3595 return;
3596} 2766}
3597 2767
3598/* 2768/*
@@ -3642,8 +2812,6 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3642 ha->outstanding_cmds[cnt] = NULL; 2812 ha->outstanding_cmds[cnt] = NULL;
3643 if (ha->actthreads) 2813 if (ha->actthreads)
3644 ha->actthreads--; 2814 ha->actthreads--;
3645 sp->lun_queue->out_cnt--;
3646
3647 sp->flags = 0; 2815 sp->flags = 0;
3648 sp->cmd->result = DID_RESET << 16; 2816 sp->cmd->result = DID_RESET << 16;
3649 sp->cmd->host_scribble = (unsigned char *)NULL; 2817 sp->cmd->host_scribble = (unsigned char *)NULL;
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index 07c11330f9a3..6a05d1b8d48a 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -187,23 +187,6 @@ qla2x00_is_wwn_zero(uint8_t *wwn)
187 return (0); 187 return (0);
188} 188}
189 189
190static __inline__ uint8_t
191qla2x00_suspend_lun(scsi_qla_host_t *, os_lun_t *, int, int);
192static __inline__ uint8_t
193qla2x00_delay_lun(scsi_qla_host_t *, os_lun_t *, int);
194
195static __inline__ uint8_t
196qla2x00_suspend_lun(scsi_qla_host_t *ha, os_lun_t *lq, int time, int count)
197{
198 return (__qla2x00_suspend_lun(ha, lq, time, count, 0));
199}
200
201static __inline__ uint8_t
202qla2x00_delay_lun(scsi_qla_host_t *ha, os_lun_t *lq, int time)
203{
204 return (__qla2x00_suspend_lun(ha, lq, time, 1, 1));
205}
206
207static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *); 190static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *);
208/* 191/*
209 * This routine will wait for fabric devices for 192 * This routine will wait for fabric devices for
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 6b1a0450e8d4..59d62cbb994e 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -328,7 +328,6 @@ qla2x00_start_scsi(srb_t *sp)
328 int ret; 328 int ret;
329 unsigned long flags; 329 unsigned long flags;
330 scsi_qla_host_t *ha; 330 scsi_qla_host_t *ha;
331 fc_lun_t *fclun;
332 struct scsi_cmnd *cmd; 331 struct scsi_cmnd *cmd;
333 uint32_t *clr_ptr; 332 uint32_t *clr_ptr;
334 uint32_t index; 333 uint32_t index;
@@ -343,8 +342,7 @@ qla2x00_start_scsi(srb_t *sp)
343 342
344 /* Setup device pointers. */ 343 /* Setup device pointers. */
345 ret = 0; 344 ret = 0;
346 fclun = sp->lun_queue->fclun; 345 ha = sp->ha;
347 ha = fclun->fcport->ha;
348 reg = ha->iobase; 346 reg = ha->iobase;
349 cmd = sp->cmd; 347 cmd = sp->cmd;
350 348
@@ -411,11 +409,9 @@ qla2x00_start_scsi(srb_t *sp)
411 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); 409 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8);
412 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); 410 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds);
413 411
414 /* Set target ID */ 412 /* Set target ID and LUN number*/
415 SET_TARGET_ID(ha, cmd_pkt->target, fclun->fcport->loop_id); 413 SET_TARGET_ID(ha, cmd_pkt->target, sp->fcport->loop_id);
416 414 cmd_pkt->lun = cpu_to_le16(sp->cmd->device->lun);
417 /* Set LUN number*/
418 cmd_pkt->lun = cpu_to_le16(fclun->lun);
419 415
420 /* Update tagged queuing modifier */ 416 /* Update tagged queuing modifier */
421 cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG); 417 cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG);
@@ -453,7 +449,6 @@ qla2x00_start_scsi(srb_t *sp)
453 449
454 ha->actthreads++; 450 ha->actthreads++;
455 ha->total_ios++; 451 ha->total_ios++;
456 sp->lun_queue->out_cnt++;
457 sp->flags |= SRB_DMA_VALID; 452 sp->flags |= SRB_DMA_VALID;
458 sp->state = SRB_ACTIVE_STATE; 453 sp->state = SRB_ACTIVE_STATE;
459 sp->u_start = jiffies; 454 sp->u_start = jiffies;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 6e7eaaf33679..6792cfae56e2 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -697,7 +697,6 @@ qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index)
697 697
698 if (ha->actthreads) 698 if (ha->actthreads)
699 ha->actthreads--; 699 ha->actthreads--;
700 sp->lun_queue->out_cnt--;
701 CMD_COMPL_STATUS(sp->cmd) = 0L; 700 CMD_COMPL_STATUS(sp->cmd) = 0L;
702 CMD_SCSI_STATUS(sp->cmd) = 0L; 701 CMD_SCSI_STATUS(sp->cmd) = 0L;
703 702
@@ -818,11 +817,8 @@ qla2x00_process_response_queue(struct scsi_qla_host *ha)
818static void 817static void
819qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt) 818qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
820{ 819{
821 int ret;
822 unsigned b, t, l; 820 unsigned b, t, l;
823 srb_t *sp; 821 srb_t *sp;
824 os_lun_t *lq;
825 os_tgt_t *tq;
826 fc_port_t *fcport; 822 fc_port_t *fcport;
827 struct scsi_cmnd *cp; 823 struct scsi_cmnd *cp;
828 uint16_t comp_status; 824 uint16_t comp_status;
@@ -872,21 +868,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
872 if (ha->actthreads) 868 if (ha->actthreads)
873 ha->actthreads--; 869 ha->actthreads--;
874 870
875 if (sp->lun_queue == NULL) {
876 DEBUG2(printk("scsi(%ld): Status Entry invalid lun pointer.\n",
877 ha->host_no));
878 qla_printk(KERN_WARNING, ha,
879 "Status Entry invalid lun pointer.\n");
880
881 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
882 if (ha->dpc_wait && !ha->dpc_active)
883 up(ha->dpc_wait);
884
885 return;
886 }
887
888 sp->lun_queue->out_cnt--;
889
890 comp_status = le16_to_cpu(pkt->comp_status); 871 comp_status = le16_to_cpu(pkt->comp_status);
891 /* Mask of reserved bits 12-15, before we examine the scsi status */ 872 /* Mask of reserved bits 12-15, before we examine the scsi status */
892 scsi_status = le16_to_cpu(pkt->scsi_status) & SS_MASK; 873 scsi_status = le16_to_cpu(pkt->scsi_status) & SS_MASK;
@@ -901,8 +882,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
901 t = cp->device->id; 882 t = cp->device->id;
902 l = cp->device->lun, 883 l = cp->device->lun,
903 884
904 tq = sp->tgt_queue; 885 fcport = sp->fcport;
905 lq = sp->lun_queue;
906 886
907 /* Check for any FCP transport errors. */ 887 /* Check for any FCP transport errors. */
908 if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) { 888 if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) {
@@ -1096,7 +1076,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
1096 * Target with DID_NO_CONNECT ELSE Queue the IOs in the 1076 * Target with DID_NO_CONNECT ELSE Queue the IOs in the
1097 * retry_queue. 1077 * retry_queue.
1098 */ 1078 */
1099 fcport = sp->fclun->fcport;
1100 DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down " 1079 DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down "
1101 "pid=%ld, compl status=0x%x, port state=0x%x\n", 1080 "pid=%ld, compl status=0x%x, port state=0x%x\n",
1102 ha->host_no, t, l, cp->serial_number, comp_status, 1081 ha->host_no, t, l, cp->serial_number, comp_status,
@@ -1137,8 +1116,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
1137 1116
1138 cp->result = DID_BUS_BUSY << 16; 1117 cp->result = DID_BUS_BUSY << 16;
1139 1118
1140 fcport = lq->fclun->fcport;
1141
1142 /* Check to see if logout occurred */ 1119 /* Check to see if logout occurred */
1143 if ((le16_to_cpu(pkt->status_flags) & SF_LOGOUT_SENT)) { 1120 if ((le16_to_cpu(pkt->status_flags) & SF_LOGOUT_SENT)) {
1144 qla2x00_mark_device_lost(ha, fcport, 1); 1121 qla2x00_mark_device_lost(ha, fcport, 1);
@@ -1154,16 +1131,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
1154 1131
1155 cp->result = DID_OK << 16 | lscsi_status; 1132 cp->result = DID_OK << 16 | lscsi_status;
1156 1133
1157 /* TODO: ??? */
1158 /* Adjust queue depth */
1159 ret = scsi_track_queue_full(cp->device,
1160 sp->lun_queue->out_cnt - 1);
1161 if (ret) {
1162 qla_printk(KERN_INFO, ha,
1163 "scsi(%ld:%d:%d:%d): Queue depth adjusted to %d.\n",
1164 ha->host_no, cp->device->channel, cp->device->id,
1165 cp->device->lun, ret);
1166 }
1167 break; 1134 break;
1168 1135
1169 default: 1136 default:
@@ -1268,8 +1235,6 @@ qla2x00_error_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
1268 ha->outstanding_cmds[pkt->handle] = NULL; 1235 ha->outstanding_cmds[pkt->handle] = NULL;
1269 if (ha->actthreads) 1236 if (ha->actthreads)
1270 ha->actthreads--; 1237 ha->actthreads--;
1271 sp->lun_queue->out_cnt--;
1272
1273 /* Bad payload or header */ 1238 /* Bad payload or header */
1274 if (pkt->entry_status & 1239 if (pkt->entry_status &
1275 (RF_INV_E_ORDER | RF_INV_E_COUNT | 1240 (RF_INV_E_ORDER | RF_INV_E_COUNT |
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index c04fbcd75235..15f6acaca305 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -858,8 +858,7 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
858 858
859 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);) 859 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);)
860 860
861 fcport = sp->fclun->fcport; 861 fcport = sp->fcport;
862
863 if (atomic_read(&ha->loop_state) == LOOP_DOWN || 862 if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
864 atomic_read(&fcport->state) == FCS_DEVICE_LOST) { 863 atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
865 return 1; 864 return 1;
@@ -884,7 +883,7 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
884 mcp->mb[1] = fcport->loop_id << 8; 883 mcp->mb[1] = fcport->loop_id << 8;
885 mcp->mb[2] = (uint16_t)handle; 884 mcp->mb[2] = (uint16_t)handle;
886 mcp->mb[3] = (uint16_t)(handle >> 16); 885 mcp->mb[3] = (uint16_t)(handle >> 16);
887 mcp->mb[6] = (uint16_t)sp->fclun->lun; 886 mcp->mb[6] = (uint16_t)sp->cmd->device->lun;
888 mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 887 mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
889 mcp->in_mb = MBX_0; 888 mcp->in_mb = MBX_0;
890 mcp->tov = 30; 889 mcp->tov = 30;
@@ -980,30 +979,22 @@ qla2x00_abort_target(fc_port_t *fcport)
980 * Kernel context. 979 * Kernel context.
981 */ 980 */
982int 981int
983qla2x00_target_reset(scsi_qla_host_t *ha, uint16_t b, uint16_t t) 982qla2x00_target_reset(scsi_qla_host_t *ha, struct fc_port *fcport)
984{ 983{
985 int rval; 984 int rval;
986 mbx_cmd_t mc; 985 mbx_cmd_t mc;
987 mbx_cmd_t *mcp = &mc; 986 mbx_cmd_t *mcp = &mc;
988 os_tgt_t *tgt;
989 987
990 DEBUG11(printk("qla2x00_target_reset(%ld): entered.\n", ha->host_no);) 988 DEBUG11(printk("qla2x00_target_reset(%ld): entered.\n", ha->host_no);)
991 989
992 tgt = TGT_Q(ha, t); 990 if (atomic_read(&fcport->state) != FCS_ONLINE)
993 if (tgt->fcport == NULL) {
994 /* no target to abort */
995 return 0;
996 }
997 if (atomic_read(&tgt->fcport->state) != FCS_ONLINE) {
998 /* target not online */
999 return 0; 991 return 0;
1000 }
1001 992
1002 mcp->mb[0] = MBC_TARGET_RESET; 993 mcp->mb[0] = MBC_TARGET_RESET;
1003 if (HAS_EXTENDED_IDS(ha)) 994 if (HAS_EXTENDED_IDS(ha))
1004 mcp->mb[1] = tgt->fcport->loop_id; 995 mcp->mb[1] = fcport->loop_id;
1005 else 996 else
1006 mcp->mb[1] = tgt->fcport->loop_id << 8; 997 mcp->mb[1] = fcport->loop_id << 8;
1007 mcp->mb[2] = ha->loop_reset_delay; 998 mcp->mb[2] = ha->loop_reset_delay;
1008 mcp->out_mb = MBX_2|MBX_1|MBX_0; 999 mcp->out_mb = MBX_2|MBX_1|MBX_0;
1009 mcp->in_mb = MBX_0; 1000 mcp->in_mb = MBX_0;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index d0aa18831544..2b6104daacb0 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -75,11 +75,6 @@ MODULE_PARM_DESC(ql2xretrycount,
75 "Maximum number of mid-layer retries allowed for a command. " 75 "Maximum number of mid-layer retries allowed for a command. "
76 "Default value is 20, "); 76 "Default value is 20, ");
77 77
78int displayConfig;
79module_param(displayConfig, int, S_IRUGO|S_IWUSR);
80MODULE_PARM_DESC(displayConfig,
81 "If 1 then display the configuration used in /etc/modprobe.conf.");
82
83int ql2xplogiabsentdevice; 78int ql2xplogiabsentdevice;
84module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); 79module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
85MODULE_PARM_DESC(ql2xplogiabsentdevice, 80MODULE_PARM_DESC(ql2xplogiabsentdevice,
@@ -119,12 +114,6 @@ MODULE_PARM_DESC(ql2xsuspendcount,
119 "target returns a <NOT READY> status. Default is 10 " 114 "target returns a <NOT READY> status. Default is 10 "
120 "iterations."); 115 "iterations.");
121 116
122int ql2xdoinitscan = 1;
123module_param(ql2xdoinitscan, int, S_IRUGO|S_IWUSR);
124MODULE_PARM_DESC(ql2xdoinitscan,
125 "Signal mid-layer to perform scan after driver load: 0 -- no "
126 "signal sent to mid-layer.");
127
128int ql2xloginretrycount = 0; 117int ql2xloginretrycount = 0;
129module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR); 118module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
130MODULE_PARM_DESC(ql2xloginretrycount, 119MODULE_PARM_DESC(ql2xloginretrycount,
@@ -195,8 +184,6 @@ static struct scsi_host_template qla2x00_driver_template = {
195 184
196static struct scsi_transport_template *qla2xxx_transport_template = NULL; 185static struct scsi_transport_template *qla2xxx_transport_template = NULL;
197 186
198static void qla2x00_display_fc_names(scsi_qla_host_t *);
199
200/* TODO Convert to inlines 187/* TODO Convert to inlines
201 * 188 *
202 * Timer routines 189 * Timer routines
@@ -332,14 +319,11 @@ static int
332qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 319qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
333{ 320{
334 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 321 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
335 os_tgt_t *tq = (os_tgt_t *) cmd->device->hostdata; 322 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
336 fc_port_t *fcport = tq->fcport;
337 os_lun_t *lq;
338 srb_t *sp; 323 srb_t *sp;
339 int rval; 324 int rval;
340 325
341 lq = GET_LU_Q(ha, cmd->device->id, cmd->device->lun); 326 if (!fcport) {
342 if (!fcport || !lq) {
343 cmd->result = DID_NO_CONNECT << 16; 327 cmd->result = DID_NO_CONNECT << 16;
344 goto qc_fail_command; 328 goto qc_fail_command;
345 } 329 }
@@ -361,13 +345,8 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
361 } 345 }
362 346
363 sp->ha = ha; 347 sp->ha = ha;
348 sp->fcport = fcport;
364 sp->cmd = cmd; 349 sp->cmd = cmd;
365 sp->tgt_queue = tq;
366
367 sp->lun_queue = lq;
368 lq->io_cnt++;
369 sp->fclun = lq->fclun;
370
371 sp->flags = 0; 350 sp->flags = 0;
372 sp->err_id = 0; 351 sp->err_id = 0;
373 352
@@ -677,9 +656,7 @@ int
677qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) 656qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
678{ 657{
679 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 658 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
680 os_tgt_t *tq = (os_tgt_t *) cmd->device->hostdata; 659 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
681 fc_port_t *fcport = tq->fcport;
682 os_lun_t *lq;
683 srb_t *sp; 660 srb_t *sp;
684 int ret; 661 int ret;
685 unsigned int id, lun; 662 unsigned int id, lun;
@@ -692,8 +669,7 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
692 serial = cmd->serial_number; 669 serial = cmd->serial_number;
693 670
694 sp = (srb_t *) CMD_SP(cmd); 671 sp = (srb_t *) CMD_SP(cmd);
695 lq = GET_LU_Q(ha, id, lun); 672 if (!sp || !fcport)
696 if (!sp || !fcport || !lq)
697 return ret; 673 return ret;
698 674
699 qla_printk(KERN_INFO, ha, 675 qla_printk(KERN_INFO, ha,
@@ -826,9 +802,7 @@ int
826qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) 802qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
827{ 803{
828 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 804 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
829 os_tgt_t *tq = (os_tgt_t *) cmd->device->hostdata; 805 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
830 fc_port_t *fcport = tq->fcport;
831 os_lun_t *lq;
832 srb_t *sp; 806 srb_t *sp;
833 int ret; 807 int ret;
834 unsigned int id, lun; 808 unsigned int id, lun;
@@ -841,8 +815,7 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
841 serial = cmd->serial_number; 815 serial = cmd->serial_number;
842 816
843 sp = (srb_t *) CMD_SP(cmd); 817 sp = (srb_t *) CMD_SP(cmd);
844 lq = GET_LU_Q(ha, id, lun); 818 if (!sp || !fcport)
845 if (!sp || !fcport || !lq)
846 return ret; 819 return ret;
847 820
848 qla_printk(KERN_INFO, ha, 821 qla_printk(KERN_INFO, ha,
@@ -895,9 +868,7 @@ int
895qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) 868qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
896{ 869{
897 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 870 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
898 os_tgt_t *tq = (os_tgt_t *) cmd->device->hostdata; 871 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
899 fc_port_t *fcport = tq->fcport;
900 os_lun_t *lq;
901 srb_t *sp; 872 srb_t *sp;
902 int ret; 873 int ret;
903 unsigned int id, lun; 874 unsigned int id, lun;
@@ -910,8 +881,7 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
910 serial = cmd->serial_number; 881 serial = cmd->serial_number;
911 882
912 sp = (srb_t *) CMD_SP(cmd); 883 sp = (srb_t *) CMD_SP(cmd);
913 lq = GET_LU_Q(ha, id, lun); 884 if (!sp || !fcport)
914 if (!sp || !fcport || !lq)
915 return ret; 885 return ret;
916 886
917 qla_printk(KERN_INFO, ha, 887 qla_printk(KERN_INFO, ha,
@@ -969,25 +939,20 @@ static int
969qla2x00_loop_reset(scsi_qla_host_t *ha) 939qla2x00_loop_reset(scsi_qla_host_t *ha)
970{ 940{
971 int status = QLA_SUCCESS; 941 int status = QLA_SUCCESS;
972 uint16_t t; 942 struct fc_port *fcport;
973 os_tgt_t *tq;
974 943
975 if (ha->flags.enable_lip_reset) { 944 if (ha->flags.enable_lip_reset) {
976 status = qla2x00_lip_reset(ha); 945 status = qla2x00_lip_reset(ha);
977 } 946 }
978 947
979 if (status == QLA_SUCCESS && ha->flags.enable_target_reset) { 948 if (status == QLA_SUCCESS && ha->flags.enable_target_reset) {
980 for (t = 0; t < MAX_FIBRE_DEVICES; t++) { 949 list_for_each_entry(fcport, &ha->fcports, list) {
981 if ((tq = TGT_Q(ha, t)) == NULL) 950 if (fcport->port_type != FCT_TARGET)
982 continue;
983
984 if (tq->fcport == NULL)
985 continue; 951 continue;
986 952
987 status = qla2x00_target_reset(ha, 0, t); 953 status = qla2x00_target_reset(ha, fcport);
988 if (status != QLA_SUCCESS) { 954 if (status != QLA_SUCCESS)
989 break; 955 break;
990 }
991 } 956 }
992 } 957 }
993 958
@@ -1041,15 +1006,26 @@ static int
1041qla2xxx_slave_alloc(struct scsi_device *sdev) 1006qla2xxx_slave_alloc(struct scsi_device *sdev)
1042{ 1007{
1043 scsi_qla_host_t *ha = to_qla_host(sdev->host); 1008 scsi_qla_host_t *ha = to_qla_host(sdev->host);
1044 os_tgt_t *tq; 1009 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
1010 fc_port_t *fcport;
1011 int found;
1045 1012
1046 tq = (os_tgt_t *) TGT_Q(ha, sdev->id); 1013 if (!rport)
1047 if (!tq)
1048 return -ENXIO; 1014 return -ENXIO;
1049 if (!tq->fcport) 1015
1016 found = 0;
1017 list_for_each_entry(fcport, &ha->fcports, list) {
1018 if (rport->port_name ==
1019 be64_to_cpu(*(uint64_t *)fcport->port_name)) {
1020 found++;
1021 break;
1022 }
1023
1024 }
1025 if (!found)
1050 return -ENXIO; 1026 return -ENXIO;
1051 1027
1052 sdev->hostdata = tq; 1028 sdev->hostdata = fcport;
1053 1029
1054 return 0; 1030 return 0;
1055} 1031}
@@ -1330,6 +1306,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1330 } 1306 }
1331 1307
1332 qla2x00_init_host_attr(ha); 1308 qla2x00_init_host_attr(ha);
1309
1333 /* 1310 /*
1334 * Startup the kernel thread for this host adapter 1311 * Startup the kernel thread for this host adapter
1335 */ 1312 */
@@ -1406,11 +1383,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1406 ha->flags.init_done = 1; 1383 ha->flags.init_done = 1;
1407 num_hosts++; 1384 num_hosts++;
1408 1385
1409 /* List the target we have found */
1410 if (displayConfig) {
1411 qla2x00_display_fc_names(ha);
1412 }
1413
1414 qla_printk(KERN_INFO, ha, "\n" 1386 qla_printk(KERN_INFO, ha, "\n"
1415 " QLogic Fibre Channel HBA Driver: %s\n" 1387 " QLogic Fibre Channel HBA Driver: %s\n"
1416 " QLogic %s - %s\n" 1388 " QLogic %s - %s\n"
@@ -1427,6 +1399,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1427 return 0; 1399 return 0;
1428 1400
1429probe_failed: 1401probe_failed:
1402 fc_remove_host(ha->host);
1403
1430 scsi_remove_host(host); 1404 scsi_remove_host(host);
1431 1405
1432probe_alloc_failed: 1406probe_alloc_failed:
@@ -1449,6 +1423,8 @@ void qla2x00_remove_one(struct pci_dev *pdev)
1449 1423
1450 qla2x00_free_sysfs_attr(ha); 1424 qla2x00_free_sysfs_attr(ha);
1451 1425
1426 fc_remove_host(ha->host);
1427
1452 scsi_remove_host(ha->host); 1428 scsi_remove_host(ha->host);
1453 1429
1454 qla2x00_free_device(ha); 1430 qla2x00_free_device(ha);
@@ -1581,9 +1557,6 @@ qla2x00_proc_info(struct Scsi_Host *shost, char *buffer,
1581{ 1557{
1582 struct info_str info; 1558 struct info_str info;
1583 int retval = -EINVAL; 1559 int retval = -EINVAL;
1584 os_lun_t *up;
1585 os_tgt_t *tq;
1586 unsigned int t, l;
1587 uint32_t tmp_sn; 1560 uint32_t tmp_sn;
1588 uint32_t *flags; 1561 uint32_t *flags;
1589 uint8_t *loop_state; 1562 uint8_t *loop_state;
@@ -1737,79 +1710,6 @@ qla2x00_proc_info(struct Scsi_Host *shost, char *buffer,
1737 ha->init_cb->port_name[6], 1710 ha->init_cb->port_name[6],
1738 ha->init_cb->port_name[7]); 1711 ha->init_cb->port_name[7]);
1739 1712
1740 /* Print out device port names */
1741 for (t = 0; t < MAX_FIBRE_DEVICES; t++) {
1742 if ((tq = TGT_Q(ha, t)) == NULL)
1743 continue;
1744
1745 copy_info(&info,
1746 "scsi-qla%d-target-%d="
1747 "%02x%02x%02x%02x%02x%02x%02x%02x;\n",
1748 (int)ha->instance, t,
1749 tq->port_name[0], tq->port_name[1],
1750 tq->port_name[2], tq->port_name[3],
1751 tq->port_name[4], tq->port_name[5],
1752 tq->port_name[6], tq->port_name[7]);
1753 }
1754
1755 copy_info(&info, "\nSCSI LUN Information:\n");
1756 copy_info(&info,
1757 "(Id:Lun) * - indicates lun is not registered with the OS.\n");
1758
1759 /* scan for all equipment stats */
1760 for (t = 0; t < MAX_FIBRE_DEVICES; t++) {
1761 /* scan all luns */
1762 for (l = 0; l < ha->max_luns; l++) {
1763 up = (os_lun_t *) GET_LU_Q(ha, t, l);
1764
1765 if (up == NULL) {
1766 continue;
1767 }
1768 if (up->fclun == NULL) {
1769 continue;
1770 }
1771
1772 copy_info(&info,
1773 "(%2d:%2d): Total reqs %ld,",
1774 t,l,up->io_cnt);
1775
1776 copy_info(&info,
1777 " Pending reqs %ld,",
1778 up->out_cnt);
1779
1780 if (up->io_cnt < 4) {
1781 copy_info(&info,
1782 " flags 0x%x*,",
1783 (int)up->q_flag);
1784 } else {
1785 copy_info(&info,
1786 " flags 0x%x,",
1787 (int)up->q_flag);
1788 }
1789
1790 copy_info(&info,
1791 " %ld:%d:%02x %02x",
1792 up->fclun->fcport->ha->instance,
1793 up->fclun->fcport->cur_path,
1794 up->fclun->fcport->loop_id,
1795 up->fclun->device_type);
1796
1797 copy_info(&info, "\n");
1798
1799 if (info.pos >= info.offset + info.length) {
1800 /* No need to continue */
1801 goto profile_stop;
1802 }
1803 }
1804
1805 if (info.pos >= info.offset + info.length) {
1806 /* No need to continue */
1807 break;
1808 }
1809 }
1810
1811profile_stop:
1812
1813 retval = info.pos > info.offset ? info.pos - info.offset : 0; 1713 retval = info.pos > info.offset ? info.pos - info.offset : 0;
1814 1714
1815 DEBUG3(printk(KERN_INFO 1715 DEBUG3(printk(KERN_INFO
@@ -1820,95 +1720,6 @@ profile_stop:
1820} 1720}
1821 1721
1822/* 1722/*
1823* qla2x00_display_fc_names
1824* This routine will the node names of the different devices found
1825* after port inquiry.
1826*
1827* Input:
1828* cmd = SCSI command structure
1829*
1830* Returns:
1831* None.
1832*/
1833static void
1834qla2x00_display_fc_names(scsi_qla_host_t *ha)
1835{
1836 uint16_t tgt;
1837 os_tgt_t *tq;
1838
1839 /* Display the node name for adapter */
1840 qla_printk(KERN_INFO, ha,
1841 "scsi-qla%d-adapter-node=%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
1842 (int)ha->instance,
1843 ha->init_cb->node_name[0],
1844 ha->init_cb->node_name[1],
1845 ha->init_cb->node_name[2],
1846 ha->init_cb->node_name[3],
1847 ha->init_cb->node_name[4],
1848 ha->init_cb->node_name[5],
1849 ha->init_cb->node_name[6],
1850 ha->init_cb->node_name[7]);
1851
1852 /* display the port name for adapter */
1853 qla_printk(KERN_INFO, ha,
1854 "scsi-qla%d-adapter-port=%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
1855 (int)ha->instance,
1856 ha->init_cb->port_name[0],
1857 ha->init_cb->port_name[1],
1858 ha->init_cb->port_name[2],
1859 ha->init_cb->port_name[3],
1860 ha->init_cb->port_name[4],
1861 ha->init_cb->port_name[5],
1862 ha->init_cb->port_name[6],
1863 ha->init_cb->port_name[7]);
1864
1865 /* Print out device port names */
1866 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
1867 if ((tq = ha->otgt[tgt]) == NULL)
1868 continue;
1869
1870 if (tq->fcport == NULL)
1871 continue;
1872
1873 switch (ha->binding_type) {
1874 case BIND_BY_PORT_NAME:
1875 qla_printk(KERN_INFO, ha,
1876 "scsi-qla%d-tgt-%d-di-0-port="
1877 "%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
1878 (int)ha->instance,
1879 tgt,
1880 tq->port_name[0],
1881 tq->port_name[1],
1882 tq->port_name[2],
1883 tq->port_name[3],
1884 tq->port_name[4],
1885 tq->port_name[5],
1886 tq->port_name[6],
1887 tq->port_name[7]);
1888
1889 break;
1890
1891 case BIND_BY_PORT_ID:
1892 qla_printk(KERN_INFO, ha,
1893 "scsi-qla%d-tgt-%d-di-0-pid="
1894 "%02x%02x%02x\\;\n",
1895 (int)ha->instance,
1896 tgt,
1897 tq->d_id.b.domain,
1898 tq->d_id.b.area,
1899 tq->d_id.b.al_pa);
1900 break;
1901 }
1902
1903#if VSA
1904 qla_printk(KERN_INFO, ha,
1905 "scsi-qla%d-target-%d-vsa=01;\n", (int)ha->instance, tgt);
1906#endif
1907 }
1908}
1909
1910
1911/*
1912 * qla2x00_mark_device_lost Updates fcport state when device goes offline. 1723 * qla2x00_mark_device_lost Updates fcport state when device goes offline.
1913 * 1724 *
1914 * Input: ha = adapter block pointer. fcport = port structure pointer. 1725 * Input: ha = adapter block pointer. fcport = port structure pointer.
@@ -2199,11 +2010,8 @@ qla2x00_mem_alloc(scsi_qla_host_t *ha)
2199static void 2010static void
2200qla2x00_mem_free(scsi_qla_host_t *ha) 2011qla2x00_mem_free(scsi_qla_host_t *ha)
2201{ 2012{
2202 uint32_t t;
2203 struct list_head *fcpl, *fcptemp; 2013 struct list_head *fcpl, *fcptemp;
2204 fc_port_t *fcport; 2014 fc_port_t *fcport;
2205 struct list_head *fcll, *fcltemp;
2206 fc_lun_t *fclun;
2207 unsigned long wtime;/* max wait time if mbx cmd is busy. */ 2015 unsigned long wtime;/* max wait time if mbx cmd is busy. */
2208 2016
2209 if (ha == NULL) { 2017 if (ha == NULL) {
@@ -2212,11 +2020,6 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
2212 return; 2020 return;
2213 } 2021 }
2214 2022
2215 /* Free the target queues */
2216 for (t = 0; t < MAX_TARGETS; t++) {
2217 qla2x00_tgt_free(ha, t);
2218 }
2219
2220 /* Make sure all other threads are stopped. */ 2023 /* Make sure all other threads are stopped. */
2221 wtime = 60 * HZ; 2024 wtime = 60 * HZ;
2222 while (ha->dpc_wait && wtime) { 2025 while (ha->dpc_wait && wtime) {
@@ -2295,14 +2098,6 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
2295 list_for_each_safe(fcpl, fcptemp, &ha->fcports) { 2098 list_for_each_safe(fcpl, fcptemp, &ha->fcports) {
2296 fcport = list_entry(fcpl, fc_port_t, list); 2099 fcport = list_entry(fcpl, fc_port_t, list);
2297 2100
2298 /* fc luns */
2299 list_for_each_safe(fcll, fcltemp, &fcport->fcluns) {
2300 fclun = list_entry(fcll, fc_lun_t, list);
2301
2302 list_del_init(&fclun->list);
2303 kfree(fclun);
2304 }
2305
2306 /* fc ports */ 2101 /* fc ports */
2307 list_del_init(&fcport->list); 2102 list_del_init(&fcport->list);
2308 kfree(fcport); 2103 kfree(fcport);
@@ -2648,6 +2443,7 @@ qla2x00_sp_compl(scsi_qla_host_t *ha, srb_t *sp)
2648 2443
2649 cmd->scsi_done(cmd); 2444 cmd->scsi_done(cmd);
2650} 2445}
2446
2651/************************************************************************** 2447/**************************************************************************
2652* qla2x00_timer 2448* qla2x00_timer
2653* 2449*
@@ -2713,11 +2509,13 @@ qla2x00_timer(scsi_qla_host_t *ha)
2713 spin_lock_irqsave(&ha->hardware_lock, cpu_flags); 2509 spin_lock_irqsave(&ha->hardware_lock, cpu_flags);
2714 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; 2510 for (index = 1; index < MAX_OUTSTANDING_COMMANDS;
2715 index++) { 2511 index++) {
2512 fc_port_t *sfcp;
2513
2716 sp = ha->outstanding_cmds[index]; 2514 sp = ha->outstanding_cmds[index];
2717 if (!sp) 2515 if (!sp)
2718 continue; 2516 continue;
2719 if (!(sp->fclun->fcport->flags & 2517 sfcp = sp->fcport;
2720 FCF_TAPE_PRESENT)) 2518 if (!(sfcp->flags & FCF_TAPE_PRESENT))
2721 continue; 2519 continue;
2722 2520
2723 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 2521 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);