Skip to content

Commit

Permalink
[SCSI] qla2xxx: Removed dependency for SRB structure for Marker proce…
Browse files Browse the repository at this point in the history
…ssing

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
Giridhar Malavali authored and James Bottomley committed Jul 28, 2010
1 parent 17cf2c5 commit d94d10e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 240 deletions.
11 changes: 0 additions & 11 deletions drivers/scsi/qla2xxx/qla_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,6 @@ struct srb_iocb {
uint32_t lun;
uint32_t data;
} tmf;
struct {
/*
* values for modif field below are as
* defined in mrk_entry_24xx struct
* for the modifier field in qla_fw.h.
*/
uint8_t modif;
uint16_t lun;
uint32_t data;
} marker;
} u;

struct timer_list timer;
Expand All @@ -277,7 +267,6 @@ struct srb_iocb {
#define SRB_CT_CMD 5
#define SRB_ADISC_CMD 6
#define SRB_TM_CMD 7
#define SRB_MARKER_CMD 8

struct srb_ctx {
uint16_t type;
Expand Down
4 changes: 1 addition & 3 deletions drivers/scsi/qla2xxx/qla_gbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ extern int qla2x00_async_logout(struct scsi_qla_host *, fc_port_t *);
extern int qla2x00_async_adisc(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
extern int qla2x00_async_tm_cmd(fc_port_t *, uint32_t, uint32_t, uint32_t);
extern int qla2x00_async_marker(fc_port_t *, uint16_t, uint8_t);
extern void qla2x00_async_login_done(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
extern void qla2x00_async_logout_done(struct scsi_qla_host *, fc_port_t *,
Expand All @@ -68,8 +67,7 @@ extern void qla2x00_async_adisc_done(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
extern void qla2x00_async_tm_cmd_done(struct scsi_qla_host *, fc_port_t *,
struct srb_iocb *);
extern void qla2x00_async_marker_done(struct scsi_qla_host *, fc_port_t *,
struct srb_iocb *);
extern void *qla2x00_alloc_iocbs(struct scsi_qla_host *, srb_t *);

extern fc_port_t *
qla2x00_alloc_fcport(scsi_qla_host_t *, gfp_t );
Expand Down
73 changes: 2 additions & 71 deletions drivers/scsi/qla2xxx/qla_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,58 +367,6 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun,
return rval;
}

static void
qla2x00_async_marker_ctx_done(srb_t *sp)
{
struct srb_ctx *ctx = sp->ctx;
struct srb_iocb *iocb = (struct srb_iocb *)ctx->u.iocb_cmd;

qla2x00_async_marker_done(sp->fcport->vha, sp->fcport, iocb);
iocb->free(sp);
}

int
qla2x00_async_marker(fc_port_t *fcport, uint16_t lun, uint8_t modif)
{
struct scsi_qla_host *vha = fcport->vha;
srb_t *sp;
struct srb_ctx *ctx;
struct srb_iocb *mrk;
int rval;

rval = QLA_FUNCTION_FAILED;
sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_ctx), 0);
if (!sp)
goto done;

ctx = sp->ctx;
ctx->type = SRB_MARKER_CMD;
ctx->name = "marker";
mrk = ctx->u.iocb_cmd;
mrk->u.marker.lun = lun;
mrk->u.marker.modif = modif;
mrk->timeout = qla2x00_async_iocb_timeout;
mrk->done = qla2x00_async_marker_ctx_done;

rval = qla2x00_start_sp(sp);
if (rval != QLA_SUCCESS)
goto done_free_sp;

DEBUG2(printk(KERN_DEBUG
"scsi(%ld:%x): Async-marker - loop-id=%x "
"portid=%02x%02x%02x.\n",
fcport->vha->host_no, sp->handle, fcport->loop_id,
fcport->d_id.b.domain, fcport->d_id.b.area,
fcport->d_id.b.al_pa));

return rval;

done_free_sp:
mrk->free(sp);
done:
return rval;
}

void
qla2x00_async_login_done(struct scsi_qla_host *vha, fc_port_t *fcport,
uint16_t *data)
Expand Down Expand Up @@ -500,7 +448,8 @@ qla2x00_async_tm_cmd_done(struct scsi_qla_host *vha, fc_port_t *fcport,
lun = (uint16_t)iocb->u.tmf.lun;

/* Issue Marker IOCB */
rval = qla2x00_async_marker(fcport, lun,
rval = qla2x00_marker(vha, vha->hw->req_q_map[0],
vha->hw->rsp_q_map[0], fcport->loop_id, lun,
flags == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID);

if ((rval != QLA_SUCCESS) || iocb->u.tmf.data) {
Expand All @@ -512,24 +461,6 @@ qla2x00_async_tm_cmd_done(struct scsi_qla_host *vha, fc_port_t *fcport,
return;
}

void
qla2x00_async_marker_done(struct scsi_qla_host *vha, fc_port_t *fcport,
struct srb_iocb *iocb)
{
/*
* Currently we dont have any specific post response processing
* for this IOCB. We'll just return success or failed
* depending on whether the IOCB command succeeded or failed.
*/
if (iocb->u.tmf.data) {
DEBUG2_3_11(printk(KERN_WARNING
"%s(%ld): Marker IOCB failed (%x).\n",
__func__, vha->host_no, iocb->u.tmf.data));
}

return;
}

/****************************************************************************/
/* QLogic ISP2x00 Hardware Support Functions. */
/****************************************************************************/
Expand Down
134 changes: 16 additions & 118 deletions drivers/scsi/qla2xxx/qla_iocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#include <scsi/scsi_tcq.h>

static request_t *qla2x00_req_pkt(struct scsi_qla_host *, struct req_que *,
struct rsp_que *rsp);
static void qla2x00_isp_cmd(struct scsi_qla_host *, struct req_que *);

static void qla25xx_set_que(srb_t *, struct rsp_que **);
Expand Down Expand Up @@ -474,7 +472,7 @@ __qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req,
scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);

mrk24 = NULL;
mrk = (mrk_entry_t *)qla2x00_req_pkt(vha, req, rsp);
mrk = (mrk_entry_t *)qla2x00_alloc_iocbs(vha, 0);
if (mrk == NULL) {
DEBUG2_3(printk("%s(%ld): failed to allocate Marker IOCB.\n",
__func__, base_vha->host_no));
Expand Down Expand Up @@ -520,84 +518,6 @@ qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req,
return (ret);
}

/**
* qla2x00_req_pkt() - Retrieve a request packet from the request ring.
* @ha: HA context
*
* Note: The caller must hold the hardware lock before calling this routine.
*
* Returns NULL if function failed, else, a pointer to the request packet.
*/
static request_t *
qla2x00_req_pkt(struct scsi_qla_host *vha, struct req_que *req,
struct rsp_que *rsp)
{
struct qla_hw_data *ha = vha->hw;
device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id);
request_t *pkt = NULL;
uint16_t cnt;
uint32_t *dword_ptr;
uint32_t timer;
uint16_t req_cnt = 1;

/* Wait 1 second for slot. */
for (timer = HZ; timer; timer--) {
if ((req_cnt + 2) >= req->cnt) {
/* Calculate number of free request entries. */
if (ha->mqenable)
cnt = (uint16_t)
RD_REG_DWORD(&reg->isp25mq.req_q_out);
else {
if (IS_QLA82XX(ha))
cnt = (uint16_t)RD_REG_DWORD(
&reg->isp82.req_q_out);
else if (IS_FWI2_CAPABLE(ha))
cnt = (uint16_t)RD_REG_DWORD(
&reg->isp24.req_q_out);
else
cnt = qla2x00_debounce_register(
ISP_REQ_Q_OUT(ha, &reg->isp));
}
if (req->ring_index < cnt)
req->cnt = cnt - req->ring_index;
else
req->cnt = req->length -
(req->ring_index - cnt);
}
/* If room for request in request ring. */
if ((req_cnt + 2) < req->cnt) {
req->cnt--;
pkt = req->ring_ptr;

/* Zero out packet. */
dword_ptr = (uint32_t *)pkt;
for (cnt = 0; cnt < REQUEST_ENTRY_SIZE / 4; cnt++)
*dword_ptr++ = 0;

/* Set entry count. */
pkt->entry_count = 1;

break;
}

/* Release ring specific lock */
spin_unlock_irq(&ha->hardware_lock);

udelay(2); /* 2 us */

/* Check for pending interrupts. */
/* During init we issue marker directly */
if (!vha->marker_needed && !vha->flags.init_done)
qla2x00_poll(rsp);
spin_lock_irq(&ha->hardware_lock);
}
if (!pkt) {
DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
}

return (pkt);
}

/**
* qla2x00_isp_cmd() - Modify the request ring pointer.
* @ha: HA context
Expand Down Expand Up @@ -1559,11 +1479,9 @@ static void qla25xx_set_que(srb_t *sp, struct rsp_que **rsp)
}

/* Generic Control-SRB manipulation functions. */

static void *
qla2x00_alloc_iocbs(srb_t *sp)
void *
qla2x00_alloc_iocbs(scsi_qla_host_t *vha, srb_t *sp)
{
scsi_qla_host_t *vha = sp->fcport->vha;
struct qla_hw_data *ha = vha->hw;
struct req_que *req = ha->req_q_map[0];
device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id);
Expand All @@ -1573,6 +1491,10 @@ qla2x00_alloc_iocbs(srb_t *sp)

pkt = NULL;
req_cnt = 1;
handle = 0;

if (!sp)
goto skip_cmd_array;

/* Check for room in outstanding command list. */
handle = req->current_outstanding_cmd;
Expand All @@ -1586,10 +1508,18 @@ qla2x00_alloc_iocbs(srb_t *sp)
if (index == MAX_OUTSTANDING_COMMANDS)
goto queuing_error;

/* Prep command array. */
req->current_outstanding_cmd = handle;
req->outstanding_cmds[handle] = sp;
sp->handle = handle;

skip_cmd_array:
/* Check for room on request queue. */
if (req->cnt < req_cnt) {
if (ha->mqenable)
cnt = RD_REG_DWORD(&reg->isp25mq.req_q_out);
else if (IS_QLA82XX(ha))
cnt = RD_REG_DWORD(&reg->isp82.req_q_out);
else if (IS_FWI2_CAPABLE(ha))
cnt = RD_REG_DWORD(&reg->isp24.req_q_out);
else
Expand All @@ -1606,15 +1536,11 @@ qla2x00_alloc_iocbs(srb_t *sp)
goto queuing_error;

/* Prep packet */
req->current_outstanding_cmd = handle;
req->outstanding_cmds[handle] = sp;
req->cnt -= req_cnt;

pkt = req->ring_ptr;
memset(pkt, 0, REQUEST_ENTRY_SIZE);
pkt->entry_count = req_cnt;
pkt->handle = handle;
sp->handle = handle;

queuing_error:
return pkt;
Expand Down Expand Up @@ -1794,31 +1720,6 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk)
}
}

static void
qla24xx_marker_iocb(srb_t *sp, struct mrk_entry_24xx *mrk)
{
uint16_t lun;
uint8_t modif;
struct fc_port *fcport = sp->fcport;
scsi_qla_host_t *vha = fcport->vha;
struct srb_ctx *ctx = sp->ctx;
struct srb_iocb *iocb = ctx->u.iocb_cmd;
struct req_que *req = vha->req;

lun = iocb->u.marker.lun;
modif = iocb->u.marker.modif;
mrk->entry_type = MARKER_TYPE;
mrk->modifier = modif;
if (modif != MK_SYNC_ALL) {
mrk->nport_handle = cpu_to_le16(fcport->loop_id);
mrk->lun[1] = LSB(lun);
mrk->lun[2] = MSB(lun);
host_to_fcp_swap(mrk->lun, sizeof(mrk->lun));
mrk->vp_index = vha->vp_idx;
mrk->handle = MAKE_HANDLE(req->id, mrk->handle);
}
}

static void
qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
{
Expand Down Expand Up @@ -1945,7 +1846,7 @@ qla2x00_start_sp(srb_t *sp)

rval = QLA_FUNCTION_FAILED;
spin_lock_irqsave(&ha->hardware_lock, flags);
pkt = qla2x00_alloc_iocbs(sp);
pkt = qla2x00_alloc_iocbs(sp->fcport->vha, sp);
if (!pkt)
goto done;

Expand Down Expand Up @@ -1976,9 +1877,6 @@ qla2x00_start_sp(srb_t *sp)
case SRB_TM_CMD:
qla24xx_tm_iocb(sp, pkt);
break;
case SRB_MARKER_CMD:
qla24xx_marker_iocb(sp, pkt);
break;
default:
break;
}
Expand Down
Loading

0 comments on commit d94d10e

Please sign in to comment.