Skip to content

Commit c5419e2

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Combine Active command arrays.
Merge active/outstanding cmd arrays from target side and initiator side together in prepration for Target Multi Queue support. Signed-off-by: Quinn Tran <quinn.tran@cavium.com> Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 8ba1ddb commit c5419e2

File tree

7 files changed

+164
-144
lines changed

7 files changed

+164
-144
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,18 @@ struct srb_iocb {
437437
#define SRB_NACK_PRLI 17
438438
#define SRB_NACK_LOGO 18
439439

440+
enum {
441+
TYPE_SRB,
442+
TYPE_TGT_CMD,
443+
};
444+
440445
typedef struct srb {
446+
/*
447+
* Do not move cmd_type field, it needs to
448+
* line up with qla_tgt_cmd->cmd_type
449+
*/
450+
uint8_t cmd_type;
451+
uint8_t pad[3];
441452
atomic_t ref_count;
442453
struct fc_port *fcport;
443454
struct scsi_qla_host *vha;
@@ -3287,9 +3298,6 @@ struct qlt_hw_data {
32873298
uint32_t __iomem *atio_q_out;
32883299

32893300
struct qla_tgt_func_tmpl *tgt_ops;
3290-
struct qla_tgt_cmd *cmds[DEFAULT_OUTSTANDING_COMMANDS];
3291-
uint16_t current_handle;
3292-
32933301
struct qla_tgt_vp_map *tgt_vp_map;
32943302

32953303
int saved_set;
@@ -4258,6 +4266,7 @@ enum nexus_wait_type {
42584266
WAIT_LUN,
42594267
};
42604268

4269+
#include "qla_target.h"
42614270
#include "qla_gbl.h"
42624271
#include "qla_dbg.h"
42634272
#include "qla_inline.h"

drivers/scsi/qla2xxx/qla_gbl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,6 @@ extern irqreturn_t qla8044_intr_handler(int, void *);
834834
extern void qla82xx_mbx_completion(scsi_qla_host_t *, uint16_t);
835835
extern int qla8044_abort_isp(scsi_qla_host_t *);
836836
extern int qla8044_check_fw_alive(struct scsi_qla_host *);
837-
838-
extern void qlt_host_reset_handler(struct qla_hw_data *ha);
839837
extern int qla_get_exlogin_status(scsi_qla_host_t *, uint16_t *,
840838
uint16_t *);
841839
extern int qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr);

drivers/scsi/qla2xxx/qla_inline.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ qla2x00_get_sp(scsi_qla_host_t *vha, fc_port_t *fcport, gfp_t flag)
250250

251251
memset(sp, 0, sizeof(*sp));
252252
sp->fcport = fcport;
253+
sp->cmd_type = TYPE_SRB;
253254
sp->iocbs = 1;
254255
sp->vha = vha;
255256
done:

drivers/scsi/qla2xxx/qla_isr.c

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
1818
static void qla2x00_status_entry(scsi_qla_host_t *, struct rsp_que *, void *);
1919
static void qla2x00_status_cont_entry(struct rsp_que *, sts_cont_entry_t *);
20-
static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
20+
static int qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
2121
sts_entry_t *);
2222

2323
/**
@@ -2280,6 +2280,14 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
22802280
return;
22812281
}
22822282

2283+
if (sp->cmd_type != TYPE_SRB) {
2284+
req->outstanding_cmds[handle] = NULL;
2285+
ql_dbg(ql_dbg_io, vha, 0x3015,
2286+
"Unknown sp->cmd_type %x %p).\n",
2287+
sp->cmd_type, sp);
2288+
return;
2289+
}
2290+
22832291
if (unlikely((state_flags & BIT_1) && (sp->type == SRB_BIDI_CMD))) {
22842292
qla25xx_process_bidir_status_iocb(vha, pkt, req, handle);
22852293
return;
@@ -2632,8 +2640,9 @@ qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt)
26322640
* qla2x00_error_entry() - Process an error entry.
26332641
* @ha: SCSI driver HA context
26342642
* @pkt: Entry pointer
2643+
* return : 1=allow further error analysis. 0=no additional error analysis.
26352644
*/
2636-
static void
2645+
static int
26372646
qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
26382647
{
26392648
srb_t *sp;
@@ -2654,18 +2663,35 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
26542663
if (pkt->entry_status & RF_BUSY)
26552664
res = DID_BUS_BUSY << 16;
26562665

2657-
if (pkt->entry_type == NOTIFY_ACK_TYPE &&
2658-
pkt->handle == QLA_TGT_SKIP_HANDLE)
2659-
return;
2666+
if ((pkt->handle & ~QLA_TGT_HANDLE_MASK) == QLA_TGT_SKIP_HANDLE)
2667+
return 0;
26602668

2661-
sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
2662-
if (sp) {
2663-
sp->done(sp, res);
2664-
return;
2669+
switch (pkt->entry_type) {
2670+
case NOTIFY_ACK_TYPE:
2671+
case STATUS_TYPE:
2672+
case STATUS_CONT_TYPE:
2673+
case LOGINOUT_PORT_IOCB_TYPE:
2674+
case CT_IOCB_TYPE:
2675+
case ELS_IOCB_TYPE:
2676+
case ABORT_IOCB_TYPE:
2677+
case MBX_IOCB_TYPE:
2678+
sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
2679+
if (sp) {
2680+
sp->done(sp, res);
2681+
return 0;
2682+
}
2683+
break;
2684+
2685+
case ABTS_RESP_24XX:
2686+
case CTIO_TYPE7:
2687+
case CTIO_CRC2:
2688+
default:
2689+
return 1;
26652690
}
26662691
fatal:
26672692
ql_log(ql_log_warn, vha, 0x5030,
26682693
"Error entry - invalid handle/queue (%04x).\n", que);
2694+
return 0;
26692695
}
26702696

26712697
/**
@@ -2746,9 +2772,7 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
27462772
}
27472773

27482774
if (pkt->entry_status != 0) {
2749-
qla2x00_error_entry(vha, rsp, (sts_entry_t *) pkt);
2750-
2751-
if (qlt_24xx_process_response_error(vha, pkt))
2775+
if (qla2x00_error_entry(vha, rsp, (sts_entry_t *) pkt))
27522776
goto process_err;
27532777

27542778
((response_t *)pkt)->signature = RESPONSE_PROCESSED;

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,8 +1649,9 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
16491649
srb_t *sp;
16501650
struct qla_hw_data *ha = vha->hw;
16511651
struct req_que *req;
1652-
1653-
qlt_host_reset_handler(ha);
1652+
struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
1653+
struct qla_tgt_cmd *cmd;
1654+
uint8_t trace = 0;
16541655

16551656
spin_lock_irqsave(&ha->hardware_lock, flags);
16561657
for (que = 0; que < ha->max_req_queues; que++) {
@@ -1662,27 +1663,57 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
16621663
for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
16631664
sp = req->outstanding_cmds[cnt];
16641665
if (sp) {
1665-
/* Don't abort commands in adapter during EEH
1666-
* recovery as it's not accessible/responding.
1667-
*/
1668-
if (GET_CMD_SP(sp) && !ha->flags.eeh_busy &&
1669-
(sp->type == SRB_SCSI_CMD)) {
1670-
/* Get a reference to the sp and drop the lock.
1671-
* The reference ensures this sp->done() call
1672-
* - and not the call in qla2xxx_eh_abort() -
1673-
* ends the SCSI command (with result 'res').
1666+
req->outstanding_cmds[cnt] = NULL;
1667+
if (sp->cmd_type == TYPE_SRB) {
1668+
/*
1669+
* Don't abort commands in adapter
1670+
* during EEH recovery as it's not
1671+
* accessible/responding.
16741672
*/
1675-
sp_get(sp);
1676-
spin_unlock_irqrestore(&ha->hardware_lock, flags);
1677-
status = qla2xxx_eh_abort(GET_CMD_SP(sp));
1678-
spin_lock_irqsave(&ha->hardware_lock, flags);
1679-
/* Get rid of extra reference if immediate exit
1680-
* from ql2xxx_eh_abort */
1681-
if (status == FAILED && (qla2x00_isp_reg_stat(ha)))
1682-
atomic_dec(&sp->ref_count);
1673+
if (GET_CMD_SP(sp) &&
1674+
!ha->flags.eeh_busy &&
1675+
(sp->type == SRB_SCSI_CMD)) {
1676+
/*
1677+
* Get a reference to the sp
1678+
* and drop the lock. The
1679+
* reference ensures this
1680+
* sp->done() call and not the
1681+
* call in qla2xxx_eh_abort()
1682+
* ends the SCSI command (with
1683+
* result 'res').
1684+
*/
1685+
sp_get(sp);
1686+
spin_unlock_irqrestore(
1687+
&ha->hardware_lock, flags);
1688+
status = qla2xxx_eh_abort(
1689+
GET_CMD_SP(sp));
1690+
spin_lock_irqsave(
1691+
&ha->hardware_lock, flags);
1692+
/*
1693+
* Get rid of extra reference
1694+
* if immediate exit from
1695+
* ql2xxx_eh_abort
1696+
*/
1697+
if (status == FAILED &&
1698+
(qla2x00_isp_reg_stat(ha)))
1699+
atomic_dec(
1700+
&sp->ref_count);
1701+
}
1702+
sp->done(sp, res);
1703+
} else {
1704+
if (!vha->hw->tgt.tgt_ops || !tgt ||
1705+
qla_ini_mode_enabled(vha)) {
1706+
if (!trace)
1707+
ql_dbg(ql_dbg_tgt_mgt,
1708+
vha, 0xf003,
1709+
"HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n",
1710+
vha->dpc_flags);
1711+
continue;
1712+
}
1713+
cmd = (struct qla_tgt_cmd *)sp;
1714+
qlt_abort_cmd_on_host_reset(cmd->vha,
1715+
cmd);
16831716
}
1684-
req->outstanding_cmds[cnt] = NULL;
1685-
sp->done(sp, res);
16861717
}
16871718
}
16881719
}
@@ -5862,6 +5893,8 @@ qla2x00_timer(scsi_qla_host_t *vha)
58625893
sp = req->outstanding_cmds[index];
58635894
if (!sp)
58645895
continue;
5896+
if (sp->cmd_type != TYPE_SRB)
5897+
continue;
58655898
if (sp->type != SRB_SCSI_CMD)
58665899
continue;
58675900
sfcp = sp->fcport;

0 commit comments

Comments
 (0)