Skip to content

Commit

Permalink
scsi: qla2xxx: Combine Active command arrays.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Quinn Tran authored and Martin K. Petersen committed Jun 28, 2017
1 parent 8ba1ddb commit c5419e2
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 144 deletions.
15 changes: 12 additions & 3 deletions drivers/scsi/qla2xxx/qla_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,18 @@ struct srb_iocb {
#define SRB_NACK_PRLI 17
#define SRB_NACK_LOGO 18

enum {
TYPE_SRB,
TYPE_TGT_CMD,
};

typedef struct srb {
/*
* Do not move cmd_type field, it needs to
* line up with qla_tgt_cmd->cmd_type
*/
uint8_t cmd_type;
uint8_t pad[3];
atomic_t ref_count;
struct fc_port *fcport;
struct scsi_qla_host *vha;
Expand Down Expand Up @@ -3287,9 +3298,6 @@ struct qlt_hw_data {
uint32_t __iomem *atio_q_out;

struct qla_tgt_func_tmpl *tgt_ops;
struct qla_tgt_cmd *cmds[DEFAULT_OUTSTANDING_COMMANDS];
uint16_t current_handle;

struct qla_tgt_vp_map *tgt_vp_map;

int saved_set;
Expand Down Expand Up @@ -4258,6 +4266,7 @@ enum nexus_wait_type {
WAIT_LUN,
};

#include "qla_target.h"
#include "qla_gbl.h"
#include "qla_dbg.h"
#include "qla_inline.h"
Expand Down
2 changes: 0 additions & 2 deletions drivers/scsi/qla2xxx/qla_gbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,6 @@ extern irqreturn_t qla8044_intr_handler(int, void *);
extern void qla82xx_mbx_completion(scsi_qla_host_t *, uint16_t);
extern int qla8044_abort_isp(scsi_qla_host_t *);
extern int qla8044_check_fw_alive(struct scsi_qla_host *);

extern void qlt_host_reset_handler(struct qla_hw_data *ha);
extern int qla_get_exlogin_status(scsi_qla_host_t *, uint16_t *,
uint16_t *);
extern int qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr);
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/qla2xxx/qla_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ qla2x00_get_sp(scsi_qla_host_t *vha, fc_port_t *fcport, gfp_t flag)

memset(sp, 0, sizeof(*sp));
sp->fcport = fcport;
sp->cmd_type = TYPE_SRB;
sp->iocbs = 1;
sp->vha = vha;
done:
Expand Down
48 changes: 36 additions & 12 deletions drivers/scsi/qla2xxx/qla_isr.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
static void qla2x00_status_entry(scsi_qla_host_t *, struct rsp_que *, void *);
static void qla2x00_status_cont_entry(struct rsp_que *, sts_cont_entry_t *);
static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
static int qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
sts_entry_t *);

/**
Expand Down Expand Up @@ -2280,6 +2280,14 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
return;
}

if (sp->cmd_type != TYPE_SRB) {
req->outstanding_cmds[handle] = NULL;
ql_dbg(ql_dbg_io, vha, 0x3015,
"Unknown sp->cmd_type %x %p).\n",
sp->cmd_type, sp);
return;
}

if (unlikely((state_flags & BIT_1) && (sp->type == SRB_BIDI_CMD))) {
qla25xx_process_bidir_status_iocb(vha, pkt, req, handle);
return;
Expand Down Expand Up @@ -2632,8 +2640,9 @@ qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt)
* qla2x00_error_entry() - Process an error entry.
* @ha: SCSI driver HA context
* @pkt: Entry pointer
* return : 1=allow further error analysis. 0=no additional error analysis.
*/
static void
static int
qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
{
srb_t *sp;
Expand All @@ -2654,18 +2663,35 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
if (pkt->entry_status & RF_BUSY)
res = DID_BUS_BUSY << 16;

if (pkt->entry_type == NOTIFY_ACK_TYPE &&
pkt->handle == QLA_TGT_SKIP_HANDLE)
return;
if ((pkt->handle & ~QLA_TGT_HANDLE_MASK) == QLA_TGT_SKIP_HANDLE)
return 0;

sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
if (sp) {
sp->done(sp, res);
return;
switch (pkt->entry_type) {
case NOTIFY_ACK_TYPE:
case STATUS_TYPE:
case STATUS_CONT_TYPE:
case LOGINOUT_PORT_IOCB_TYPE:
case CT_IOCB_TYPE:
case ELS_IOCB_TYPE:
case ABORT_IOCB_TYPE:
case MBX_IOCB_TYPE:
sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
if (sp) {
sp->done(sp, res);
return 0;
}
break;

case ABTS_RESP_24XX:
case CTIO_TYPE7:
case CTIO_CRC2:
default:
return 1;
}
fatal:
ql_log(ql_log_warn, vha, 0x5030,
"Error entry - invalid handle/queue (%04x).\n", que);
return 0;
}

/**
Expand Down Expand Up @@ -2746,9 +2772,7 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
}

if (pkt->entry_status != 0) {
qla2x00_error_entry(vha, rsp, (sts_entry_t *) pkt);

if (qlt_24xx_process_response_error(vha, pkt))
if (qla2x00_error_entry(vha, rsp, (sts_entry_t *) pkt))
goto process_err;

((response_t *)pkt)->signature = RESPONSE_PROCESSED;
Expand Down
75 changes: 54 additions & 21 deletions drivers/scsi/qla2xxx/qla_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1649,8 +1649,9 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
srb_t *sp;
struct qla_hw_data *ha = vha->hw;
struct req_que *req;

qlt_host_reset_handler(ha);
struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
struct qla_tgt_cmd *cmd;
uint8_t trace = 0;

spin_lock_irqsave(&ha->hardware_lock, flags);
for (que = 0; que < ha->max_req_queues; que++) {
Expand All @@ -1662,27 +1663,57 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
sp = req->outstanding_cmds[cnt];
if (sp) {
/* Don't abort commands in adapter during EEH
* recovery as it's not accessible/responding.
*/
if (GET_CMD_SP(sp) && !ha->flags.eeh_busy &&
(sp->type == SRB_SCSI_CMD)) {
/* Get a reference to the sp and drop the lock.
* The reference ensures this sp->done() call
* - and not the call in qla2xxx_eh_abort() -
* ends the SCSI command (with result 'res').
req->outstanding_cmds[cnt] = NULL;
if (sp->cmd_type == TYPE_SRB) {
/*
* Don't abort commands in adapter
* during EEH recovery as it's not
* accessible/responding.
*/
sp_get(sp);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
status = qla2xxx_eh_abort(GET_CMD_SP(sp));
spin_lock_irqsave(&ha->hardware_lock, flags);
/* Get rid of extra reference if immediate exit
* from ql2xxx_eh_abort */
if (status == FAILED && (qla2x00_isp_reg_stat(ha)))
atomic_dec(&sp->ref_count);
if (GET_CMD_SP(sp) &&
!ha->flags.eeh_busy &&
(sp->type == SRB_SCSI_CMD)) {
/*
* Get a reference to the sp
* and drop the lock. The
* reference ensures this
* sp->done() call and not the
* call in qla2xxx_eh_abort()
* ends the SCSI command (with
* result 'res').
*/
sp_get(sp);
spin_unlock_irqrestore(
&ha->hardware_lock, flags);
status = qla2xxx_eh_abort(
GET_CMD_SP(sp));
spin_lock_irqsave(
&ha->hardware_lock, flags);
/*
* Get rid of extra reference
* if immediate exit from
* ql2xxx_eh_abort
*/
if (status == FAILED &&
(qla2x00_isp_reg_stat(ha)))
atomic_dec(
&sp->ref_count);
}
sp->done(sp, res);
} else {
if (!vha->hw->tgt.tgt_ops || !tgt ||
qla_ini_mode_enabled(vha)) {
if (!trace)
ql_dbg(ql_dbg_tgt_mgt,
vha, 0xf003,
"HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n",
vha->dpc_flags);
continue;
}
cmd = (struct qla_tgt_cmd *)sp;
qlt_abort_cmd_on_host_reset(cmd->vha,
cmd);
}
req->outstanding_cmds[cnt] = NULL;
sp->done(sp, res);
}
}
}
Expand Down Expand Up @@ -5862,6 +5893,8 @@ qla2x00_timer(scsi_qla_host_t *vha)
sp = req->outstanding_cmds[index];
if (!sp)
continue;
if (sp->cmd_type != TYPE_SRB)
continue;
if (sp->type != SRB_SCSI_CMD)
continue;
sfcp = sp->fcport;
Expand Down
Loading

0 comments on commit c5419e2

Please sign in to comment.