Commit 4916392b authored by Madhuranath Iyengar's avatar Madhuranath Iyengar Committed by James Bottomley

[SCSI] qla2xxx: Provide common framework for BSG and IOCB commands.

Currently, BSG and IOCB/Logio commands have a different
framework (srb structs). The purpose of this effort is to
consolidate them into a generalized framework for these
as well as other asynchronous operations in the future.
Signed-off-by: default avatarGiridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent b7d2280c
...@@ -16,7 +16,7 @@ qla2x00_get_ctx_bsg_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size) ...@@ -16,7 +16,7 @@ qla2x00_get_ctx_bsg_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size)
{ {
srb_t *sp; srb_t *sp;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
struct srb_bsg_ctx *ctx; struct srb_ctx *ctx;
sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL); sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL);
if (!sp) if (!sp)
...@@ -208,7 +208,7 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job) ...@@ -208,7 +208,7 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
int req_sg_cnt, rsp_sg_cnt; int req_sg_cnt, rsp_sg_cnt;
int rval = (DRIVER_ERROR << 16); int rval = (DRIVER_ERROR << 16);
uint16_t nextlid = 0; uint16_t nextlid = 0;
struct srb_bsg *els; struct srb_ctx *els;
/* Multiple SG's are not supported for ELS requests */ /* Multiple SG's are not supported for ELS requests */
if (bsg_job->request_payload.sg_cnt > 1 || if (bsg_job->request_payload.sg_cnt > 1 ||
...@@ -307,17 +307,17 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job) ...@@ -307,17 +307,17 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
} }
/* Alloc SRB structure */ /* Alloc SRB structure */
sp = qla2x00_get_ctx_bsg_sp(vha, fcport, sizeof(struct srb_bsg)); sp = qla2x00_get_ctx_bsg_sp(vha, fcport, sizeof(struct srb_ctx));
if (!sp) { if (!sp) {
rval = -ENOMEM; rval = -ENOMEM;
goto done_unmap_sg; goto done_unmap_sg;
} }
els = sp->ctx; els = sp->ctx;
els->ctx.type = els->type =
(bsg_job->request->msgcode == FC_BSG_RPT_ELS ? (bsg_job->request->msgcode == FC_BSG_RPT_ELS ?
SRB_ELS_CMD_RPT : SRB_ELS_CMD_HST); SRB_ELS_CMD_RPT : SRB_ELS_CMD_HST);
els->bsg_job = bsg_job; els->u.bsg_job = bsg_job;
DEBUG2(qla_printk(KERN_INFO, ha, DEBUG2(qla_printk(KERN_INFO, ha,
"scsi(%ld:%x): bsg rqst type: %s els type: %x - loop-id=%x " "scsi(%ld:%x): bsg rqst type: %s els type: %x - loop-id=%x "
...@@ -361,7 +361,7 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job) ...@@ -361,7 +361,7 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
uint16_t loop_id; uint16_t loop_id;
struct fc_port *fcport; struct fc_port *fcport;
char *type = "FC_BSG_HST_CT"; char *type = "FC_BSG_HST_CT";
struct srb_bsg *ct; struct srb_ctx *ct;
/* pass through is supported only for ISP 4Gb or higher */ /* pass through is supported only for ISP 4Gb or higher */
if (!IS_FWI2_CAPABLE(ha)) { if (!IS_FWI2_CAPABLE(ha)) {
...@@ -442,15 +442,15 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job) ...@@ -442,15 +442,15 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
fcport->loop_id = loop_id; fcport->loop_id = loop_id;
/* Alloc SRB structure */ /* Alloc SRB structure */
sp = qla2x00_get_ctx_bsg_sp(vha, fcport, sizeof(struct srb_bsg)); sp = qla2x00_get_ctx_bsg_sp(vha, fcport, sizeof(struct srb_ctx));
if (!sp) { if (!sp) {
rval = -ENOMEM; rval = -ENOMEM;
goto done_free_fcport; goto done_free_fcport;
} }
ct = sp->ctx; ct = sp->ctx;
ct->ctx.type = SRB_CT_CMD; ct->type = SRB_CT_CMD;
ct->bsg_job = bsg_job; ct->u.bsg_job = bsg_job;
DEBUG2(qla_printk(KERN_INFO, ha, DEBUG2(qla_printk(KERN_INFO, ha,
"scsi(%ld:%x): bsg rqst type: %s els type: %x - loop-id=%x " "scsi(%ld:%x): bsg rqst type: %s els type: %x - loop-id=%x "
...@@ -1155,7 +1155,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) ...@@ -1155,7 +1155,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
int cnt, que; int cnt, que;
unsigned long flags; unsigned long flags;
struct req_que *req; struct req_que *req;
struct srb_bsg *sp_bsg; struct srb_ctx *sp_bsg;
/* find the bsg job from the active list of commands */ /* find the bsg job from the active list of commands */
spin_lock_irqsave(&ha->hardware_lock, flags); spin_lock_irqsave(&ha->hardware_lock, flags);
...@@ -1167,11 +1167,11 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) ...@@ -1167,11 +1167,11 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
sp = req->outstanding_cmds[cnt]; sp = req->outstanding_cmds[cnt];
if (sp) { if (sp) {
sp_bsg = (struct srb_bsg *)sp->ctx; sp_bsg = sp->ctx;
if (((sp_bsg->ctx.type == SRB_CT_CMD) || if (((sp_bsg->type == SRB_CT_CMD) ||
(sp_bsg->ctx.type == SRB_ELS_CMD_HST)) (sp_bsg->type == SRB_ELS_CMD_HST))
&& (sp_bsg->bsg_job == bsg_job)) { && (sp_bsg->u.bsg_job == bsg_job)) {
if (ha->isp_ops->abort_command(sp)) { if (ha->isp_ops->abort_command(sp)) {
DEBUG2(qla_printk(KERN_INFO, ha, DEBUG2(qla_printk(KERN_INFO, ha,
"scsi(%ld): mbx " "scsi(%ld): mbx "
......
...@@ -214,16 +214,16 @@ typedef struct srb { ...@@ -214,16 +214,16 @@ typedef struct srb {
/* /*
* SRB extensions. * SRB extensions.
*/ */
#define SRB_LOGIN_CMD 1 struct srb_iocb {
#define SRB_LOGOUT_CMD 2 union {
#define SRB_ELS_CMD_RPT 3 struct {
#define SRB_ELS_CMD_HST 4 uint16_t flags;
#define SRB_CT_CMD 5 #define SRB_LOGIN_RETRIED BIT_0
#define SRB_ADISC_CMD 6 #define SRB_LOGIN_COND_PLOGI BIT_1
#define SRB_LOGIN_SKIP_PRLI BIT_2
struct srb_ctx { uint16_t data[2];
uint16_t type; } logio;
char *name; } u;
struct timer_list timer; struct timer_list timer;
...@@ -232,23 +232,21 @@ struct srb_ctx { ...@@ -232,23 +232,21 @@ struct srb_ctx {
void (*timeout)(srb_t *); void (*timeout)(srb_t *);
}; };
struct srb_logio { /* Values for srb_ctx type */
struct srb_ctx ctx; #define SRB_LOGIN_CMD 1
#define SRB_LOGOUT_CMD 2
#define SRB_LOGIN_RETRIED BIT_0 #define SRB_ELS_CMD_RPT 3
#define SRB_LOGIN_COND_PLOGI BIT_1 #define SRB_ELS_CMD_HST 4
#define SRB_LOGIN_SKIP_PRLI BIT_2 #define SRB_CT_CMD 5
uint16_t flags; #define SRB_ADISC_CMD 6
uint16_t data[2];
};
struct srb_bsg_ctx { struct srb_ctx {
uint16_t type; uint16_t type;
}; char *name;
union {
struct srb_bsg { struct srb_iocb *iocb_cmd;
struct srb_bsg_ctx ctx;
struct fc_bsg_job *bsg_job; struct fc_bsg_job *bsg_job;
} u;
}; };
struct msg_echo_lb { struct msg_echo_lb {
......
...@@ -58,11 +58,11 @@ extern int qla2x00_async_login(struct scsi_qla_host *, fc_port_t *, ...@@ -58,11 +58,11 @@ extern int qla2x00_async_login(struct scsi_qla_host *, fc_port_t *,
extern int qla2x00_async_logout(struct scsi_qla_host *, fc_port_t *); extern int qla2x00_async_logout(struct scsi_qla_host *, fc_port_t *);
extern int qla2x00_async_adisc(struct scsi_qla_host *, fc_port_t *, extern int qla2x00_async_adisc(struct scsi_qla_host *, fc_port_t *,
uint16_t *); uint16_t *);
extern int qla2x00_async_login_done(struct scsi_qla_host *, fc_port_t *, extern void qla2x00_async_login_done(struct scsi_qla_host *, fc_port_t *,
uint16_t *); uint16_t *);
extern int qla2x00_async_logout_done(struct scsi_qla_host *, fc_port_t *, extern void qla2x00_async_logout_done(struct scsi_qla_host *, fc_port_t *,
uint16_t *); uint16_t *);
extern int qla2x00_async_adisc_done(struct scsi_qla_host *, fc_port_t *, extern void qla2x00_async_adisc_done(struct scsi_qla_host *, fc_port_t *,
uint16_t *); uint16_t *);
extern fc_port_t * extern fc_port_t *
......
...@@ -48,6 +48,7 @@ qla2x00_ctx_sp_timeout(unsigned long __data) ...@@ -48,6 +48,7 @@ qla2x00_ctx_sp_timeout(unsigned long __data)
{ {
srb_t *sp = (srb_t *)__data; srb_t *sp = (srb_t *)__data;
struct srb_ctx *ctx; struct srb_ctx *ctx;
struct srb_iocb *iocb;
fc_port_t *fcport = sp->fcport; fc_port_t *fcport = sp->fcport;
struct qla_hw_data *ha = fcport->vha->hw; struct qla_hw_data *ha = fcport->vha->hw;
struct req_que *req; struct req_que *req;
...@@ -57,17 +58,21 @@ qla2x00_ctx_sp_timeout(unsigned long __data) ...@@ -57,17 +58,21 @@ qla2x00_ctx_sp_timeout(unsigned long __data)
req = ha->req_q_map[0]; req = ha->req_q_map[0];
req->outstanding_cmds[sp->handle] = NULL; req->outstanding_cmds[sp->handle] = NULL;
ctx = sp->ctx; ctx = sp->ctx;
ctx->timeout(sp); iocb = ctx->u.iocb_cmd;
iocb->timeout(sp);
spin_unlock_irqrestore(&ha->hardware_lock, flags); spin_unlock_irqrestore(&ha->hardware_lock, flags);
ctx->free(sp); iocb->free(sp);
} }
void void
qla2x00_ctx_sp_free(srb_t *sp) qla2x00_ctx_sp_free(srb_t *sp)
{ {
struct srb_ctx *ctx = sp->ctx; struct srb_ctx *ctx = sp->ctx;
struct srb_iocb *iocb = ctx->u.iocb_cmd;
del_timer_sync(&iocb->timer);
kfree(iocb);
kfree(ctx); kfree(ctx);
mempool_free(sp, sp->fcport->vha->hw->srb_mempool); mempool_free(sp, sp->fcport->vha->hw->srb_mempool);
} }
...@@ -79,6 +84,7 @@ qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size, ...@@ -79,6 +84,7 @@ qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size,
srb_t *sp; srb_t *sp;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
struct srb_ctx *ctx; struct srb_ctx *ctx;
struct srb_iocb *iocb;
sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL); sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL);
if (!sp) if (!sp)
...@@ -86,21 +92,30 @@ qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size, ...@@ -86,21 +92,30 @@ qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size,
ctx = kzalloc(size, GFP_KERNEL); ctx = kzalloc(size, GFP_KERNEL);
if (!ctx) { if (!ctx) {
mempool_free(sp, ha->srb_mempool); mempool_free(sp, ha->srb_mempool);
sp = NULL;
goto done;
}
iocb = kzalloc(sizeof(struct srb_iocb), GFP_KERNEL);
if (!iocb) {
mempool_free(sp, ha->srb_mempool);
sp = NULL;
kfree(ctx);
goto done; goto done;
} }
memset(sp, 0, sizeof(*sp)); memset(sp, 0, sizeof(*sp));
sp->fcport = fcport; sp->fcport = fcport;
sp->ctx = ctx; sp->ctx = ctx;
ctx->free = qla2x00_ctx_sp_free; ctx->u.iocb_cmd = iocb;
iocb->free = qla2x00_ctx_sp_free;
init_timer(&ctx->timer); init_timer(&iocb->timer);
if (!tmo) if (!tmo)
goto done; goto done;
ctx->timer.expires = jiffies + tmo * HZ; iocb->timer.expires = jiffies + tmo * HZ;
ctx->timer.data = (unsigned long)sp; iocb->timer.data = (unsigned long)sp;
ctx->timer.function = qla2x00_ctx_sp_timeout; iocb->timer.function = qla2x00_ctx_sp_timeout;
add_timer(&ctx->timer); add_timer(&iocb->timer);
done: done:
return sp; return sp;
} }
...@@ -113,25 +128,26 @@ static void ...@@ -113,25 +128,26 @@ static void
qla2x00_async_logio_timeout(srb_t *sp) qla2x00_async_logio_timeout(srb_t *sp)
{ {
fc_port_t *fcport = sp->fcport; fc_port_t *fcport = sp->fcport;
struct srb_logio *lio = sp->ctx; struct srb_ctx *ctx = sp->ctx;
DEBUG2(printk(KERN_WARNING DEBUG2(printk(KERN_WARNING
"scsi(%ld:%x): Async-%s timeout.\n", "scsi(%ld:%x): Async-%s timeout.\n",
fcport->vha->host_no, sp->handle, lio->ctx.name)); fcport->vha->host_no, sp->handle, ctx->name));
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
if (lio->ctx.type == SRB_LOGIN_CMD) if (ctx->type == SRB_LOGIN_CMD)
qla2x00_post_async_logout_work(fcport->vha, fcport, NULL); qla2x00_post_async_logout_work(fcport->vha, fcport, NULL);
} }
static void static void
qla2x00_async_login_ctx_done(srb_t *sp) qla2x00_async_login_ctx_done(srb_t *sp)
{ {
struct srb_logio *lio = sp->ctx; struct srb_ctx *ctx = sp->ctx;
struct srb_iocb *lio = ctx->u.iocb_cmd;
qla2x00_post_async_login_done_work(sp->fcport->vha, sp->fcport, qla2x00_post_async_login_done_work(sp->fcport->vha, sp->fcport,
lio->data); lio->u.logio.data);
lio->ctx.free(sp); lio->free(sp);
} }
int int
...@@ -140,23 +156,25 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -140,23 +156,25 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
{ {
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
srb_t *sp; srb_t *sp;
struct srb_logio *lio; struct srb_ctx *ctx;
struct srb_iocb *lio;
int rval; int rval;
rval = QLA_FUNCTION_FAILED; rval = QLA_FUNCTION_FAILED;
sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_logio), sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_ctx),
ELS_TMO_2_RATOV(ha) + 2); ELS_TMO_2_RATOV(ha) + 2);
if (!sp) if (!sp)
goto done; goto done;
lio = sp->ctx; ctx = sp->ctx;
lio->ctx.type = SRB_LOGIN_CMD; ctx->type = SRB_LOGIN_CMD;
lio->ctx.name = "login"; ctx->name = "login";
lio->ctx.timeout = qla2x00_async_logio_timeout; lio = ctx->u.iocb_cmd;
lio->ctx.done = qla2x00_async_login_ctx_done; lio->timeout = qla2x00_async_logio_timeout;
lio->flags |= SRB_LOGIN_COND_PLOGI; lio->done = qla2x00_async_login_ctx_done;
lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI;
if (data[1] & QLA_LOGIO_LOGIN_RETRIED) if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
lio->flags |= SRB_LOGIN_RETRIED; lio->u.logio.flags |= SRB_LOGIN_RETRIED;
rval = qla2x00_start_sp(sp); rval = qla2x00_start_sp(sp);
if (rval != QLA_SUCCESS) if (rval != QLA_SUCCESS)
goto done_free_sp; goto done_free_sp;
...@@ -169,8 +187,7 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -169,8 +187,7 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
return rval; return rval;
done_free_sp: done_free_sp:
del_timer_sync(&lio->ctx.timer); lio->free(sp);
lio->ctx.free(sp);
done: done:
return rval; return rval;
} }
...@@ -178,11 +195,12 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -178,11 +195,12 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
static void static void
qla2x00_async_logout_ctx_done(srb_t *sp) qla2x00_async_logout_ctx_done(srb_t *sp)
{ {
struct srb_logio *lio = sp->ctx; struct srb_ctx *ctx = sp->ctx;
struct srb_iocb *lio = ctx->u.iocb_cmd;
qla2x00_post_async_logout_done_work(sp->fcport->vha, sp->fcport, qla2x00_post_async_logout_done_work(sp->fcport->vha, sp->fcport,
lio->data); lio->u.logio.data);
lio->ctx.free(sp); lio->free(sp);
} }
int int
...@@ -190,20 +208,22 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -190,20 +208,22 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
{ {
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
srb_t *sp; srb_t *sp;
struct srb_logio *lio; struct srb_ctx *ctx;
struct srb_iocb *lio;
int rval; int rval;
rval = QLA_FUNCTION_FAILED; rval = QLA_FUNCTION_FAILED;
sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_logio), sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_ctx),
ELS_TMO_2_RATOV(ha) + 2); ELS_TMO_2_RATOV(ha) + 2);
if (!sp) if (!sp)
goto done; goto done;
lio = sp->ctx; ctx = sp->ctx;
lio->ctx.type = SRB_LOGOUT_CMD; ctx->type = SRB_LOGOUT_CMD;
lio->ctx.name = "logout"; ctx->name = "logout";
lio->ctx.timeout = qla2x00_async_logio_timeout; lio = ctx->u.iocb_cmd;
lio->ctx.done = qla2x00_async_logout_ctx_done; lio->timeout = qla2x00_async_logio_timeout;
lio->done = qla2x00_async_logout_ctx_done;
rval = qla2x00_start_sp(sp); rval = qla2x00_start_sp(sp);
if (rval != QLA_SUCCESS) if (rval != QLA_SUCCESS)
goto done_free_sp; goto done_free_sp;
...@@ -215,8 +235,7 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -215,8 +235,7 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
return rval; return rval;
done_free_sp: done_free_sp:
del_timer_sync(&lio->ctx.timer); lio->free(sp);
lio->ctx.free(sp);
done: done:
return rval; return rval;
} }
...@@ -224,11 +243,12 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -224,11 +243,12 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
static void static void
qla2x00_async_adisc_ctx_done(srb_t *sp) qla2x00_async_adisc_ctx_done(srb_t *sp)
{ {
struct srb_logio *lio = sp->ctx; struct srb_ctx *ctx = sp->ctx;
struct srb_iocb *lio = ctx->u.iocb_cmd;
qla2x00_post_async_adisc_done_work(sp->fcport->vha, sp->fcport, qla2x00_post_async_adisc_done_work(sp->fcport->vha, sp->fcport,
lio->data); lio->u.logio.data);
lio->ctx.free(sp); lio->free(sp);
} }
int int
...@@ -237,22 +257,24 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -237,22 +257,24 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
{ {
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
srb_t *sp; srb_t *sp;
struct srb_logio *lio; struct srb_ctx *ctx;
struct srb_iocb *lio;
int rval; int rval;
rval = QLA_FUNCTION_FAILED; rval = QLA_FUNCTION_FAILED;
sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_logio), sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_ctx),
ELS_TMO_2_RATOV(ha) + 2); ELS_TMO_2_RATOV(ha) + 2);
if (!sp) if (!sp)
goto done; goto done;
lio = sp->ctx; ctx = sp->ctx;
lio->ctx.type = SRB_ADISC_CMD; ctx->type = SRB_ADISC_CMD;
lio->ctx.name = "adisc"; ctx->name = "adisc";
lio->ctx.timeout = qla2x00_async_logio_timeout; lio = ctx->u.iocb_cmd;
lio->ctx.done = qla2x00_async_adisc_ctx_done; lio->timeout = qla2x00_async_logio_timeout;
lio->done = qla2x00_async_adisc_ctx_done;
if (data[1] & QLA_LOGIO_LOGIN_RETRIED) if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
lio->flags |= SRB_LOGIN_RETRIED; lio->u.logio.flags |= SRB_LOGIN_RETRIED;
rval = qla2x00_start_sp(sp); rval = qla2x00_start_sp(sp);
if (rval != QLA_SUCCESS) if (rval != QLA_SUCCESS)
goto done_free_sp; goto done_free_sp;
...@@ -265,13 +287,12 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -265,13 +287,12 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
return rval; return rval;
done_free_sp: done_free_sp:
del_timer_sync(&lio->ctx.timer); lio->free(sp);
lio->ctx.free(sp);
done: done:
return rval; return rval;
} }
int void
qla2x00_async_login_done(struct scsi_qla_host *vha, fc_port_t *fcport, qla2x00_async_login_done(struct scsi_qla_host *vha, fc_port_t *fcport,
uint16_t *data) uint16_t *data)
{ {
...@@ -308,25 +329,25 @@ qla2x00_async_login_done(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -308,25 +329,25 @@ qla2x00_async_login_done(struct scsi_qla_host *vha, fc_port_t *fcport,
qla2x00_post_async_login_work(vha, fcport, NULL); qla2x00_post_async_login_work(vha, fcport, NULL);
break; break;
} }
return QLA_SUCCESS; return;
} }
int void
qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport, qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport,
uint16_t *data) uint16_t *data)
{ {
qla2x00_mark_device_lost(vha, fcport, 1, 0); qla2x00_mark_device_lost(vha, fcport, 1, 0);
return QLA_SUCCESS; return;
} }
int void
qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport, qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport,
uint16_t *data) uint16_t *data)
{ {
if (data[0] == MBS_COMMAND_COMPLETE) { if (data[0] == MBS_COMMAND_COMPLETE) {
qla2x00_update_fcport(vha, fcport); qla2x00_update_fcport(vha, fcport);
return QLA_SUCCESS; return;
} }
/* Retry login. */ /* Retry login. */
...@@ -336,7 +357,7 @@ qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -336,7 +357,7 @@ qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport,
else else
qla2x00_mark_device_lost(vha, fcport, 1, 0); qla2x00_mark_device_lost(vha, fcport, 1, 0);
return QLA_SUCCESS; return;
} }
/****************************************************************************/ /****************************************************************************/
......
...@@ -983,13 +983,14 @@ qla2x00_start_iocbs(srb_t *sp) ...@@ -983,13 +983,14 @@ qla2x00_start_iocbs(srb_t *sp)
static void static void
qla24xx_login_iocb(srb_t *sp, struct logio_entry_24xx *logio) qla24xx_login_iocb(srb_t *sp, struct logio_entry_24xx *logio)
{ {
struct srb_logio *lio = sp->ctx; struct srb_ctx *ctx = sp->ctx;
struct srb_iocb *lio = ctx->u.iocb_cmd;
logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; logio->entry_type = LOGINOUT_PORT_IOCB_TYPE;
logio->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); logio->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI);
if (lio->flags & SRB_LOGIN_COND_PLOGI) if (lio->u.logio.flags & SRB_LOGIN_COND_PLOGI)
logio->control_flags |= cpu_to_le16(LCF_COND_PLOGI); logio->control_flags |= cpu_to_le16(LCF_COND_PLOGI);
if (lio->flags & SRB_LOGIN_SKIP_PRLI) if (lio->u.logio.flags & SRB_LOGIN_SKIP_PRLI)
logio->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); logio->control_flags |= cpu_to_le16(LCF_SKIP_PRLI);
logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); logio->nport_handle = cpu_to_le16(sp->fcport->loop_id);
logio->port_id[0] = sp->fcport->d_id.b.al_pa; logio->port_id[0] = sp->fcport->d_id.b.al_pa;
...@@ -1002,14 +1003,15 @@ static void ...@@ -1002,14 +1003,15 @@ static void
qla2x00_login_iocb(srb_t *sp, struct mbx_entry *mbx) qla2x00_login_iocb(srb_t *sp, struct mbx_entry *mbx)
{ {
struct qla_hw_data *ha = sp->fcport->vha->hw; struct qla_hw_data *ha = sp->fcport->vha->hw;
struct srb_logio *lio = sp->ctx; struct srb_ctx *ctx = sp->ctx;
struct srb_iocb *lio = ctx->u.iocb_cmd;
uint16_t opts; uint16_t opts;
mbx->entry_type = MBX_IOCB_TYPE;; mbx->entry_type = MBX_IOCB_TYPE;;
SET_TARGET_ID(ha, mbx->loop_id, sp->fcport->loop_id); SET_TARGET_ID(ha, mbx->loop_id, sp->fcport->loop_id);
mbx->mb0 = cpu_to_le16(MBC_LOGIN_FABRIC_PORT); mbx->mb0 = cpu_to_le16(MBC_LOGIN_FABRIC_PORT);
opts = lio->flags & SRB_LOGIN_COND_PLOGI ? BIT_0: 0; opts = lio->u.logio.flags & SRB_LOGIN_COND_PLOGI ? BIT_0 : 0;
opts |= lio->flags & SRB_LOGIN_SKIP_PRLI ? BIT_1: 0; opts |= lio->u.logio.flags & SRB_LOGIN_SKIP_PRLI ? BIT_1 : 0;
if (HAS_EXTENDED_IDS(ha)) { if (HAS_EXTENDED_IDS(ha)) {
mbx->mb1 = cpu_to_le16(sp->fcport->loop_id); mbx->mb1 = cpu_to_le16(sp->fcport->loop_id);
mbx->mb10 = cpu_to_le16(opts); mbx->mb10 = cpu_to_le16(opts);
...@@ -1086,7 +1088,7 @@ qla2x00_adisc_iocb(srb_t *sp, struct mbx_entry *mbx) ...@@ -1086,7 +1088,7 @@ qla2x00_adisc_iocb(srb_t *sp, struct mbx_entry *mbx)
static void static void
qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
{ {
struct fc_bsg_job *bsg_job = ((struct srb_bsg*)sp->ctx)->bsg_job; struct fc_bsg_job *bsg_job = ((struct srb_ctx *)sp->ctx)->u.bsg_job;
els_iocb->entry_type = ELS_IOCB_TYPE; els_iocb->entry_type = ELS_IOCB_TYPE;
els_iocb->entry_count = 1; els_iocb->entry_count = 1;
...@@ -1099,8 +1101,10 @@ qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) ...@@ -1099,8 +1101,10 @@ qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
els_iocb->sof_type = EST_SOFI3; els_iocb->sof_type = EST_SOFI3;
els_iocb->rx_dsd_count = __constant_cpu_to_le16(bsg_job->reply_payload.sg_cnt); els_iocb->rx_dsd_count = __constant_cpu_to_le16(bsg_job->reply_payload.sg_cnt);
els_iocb->opcode =(((struct srb_bsg*)sp->ctx)->ctx.type == SRB_ELS_CMD_RPT) ? els_iocb->opcode =
bsg_job->request->rqst_data.r_els.els_code : bsg_job->request->rqst_data.h_els.command_code; (((struct srb_ctx *)sp->ctx)->type == SRB_ELS_CMD_RPT) ?
bsg_job->request->rqst_data.r_els.els_code :
bsg_job->request->rqst_data.h_els.command_code;
els_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; els_iocb->port_id[0] = sp->fcport->d_id.b.al_pa;
els_iocb->port_id[1] = sp->fcport->d_id.b.area; els_iocb->port_id[1] = sp->fcport->d_id.b.area;
els_iocb->port_id[2] = sp->fcport->d_id.b.domain; els_iocb->port_id[2] = sp->fcport->d_id.b.domain;
...@@ -1134,7 +1138,7 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb) ...@@ -1134,7 +1138,7 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb)
int index; int index;
uint16_t tot_dsds; uint16_t tot_dsds;
scsi_qla_host_t *vha = sp->fcport->vha; scsi_qla_host_t *vha = sp->fcport->vha;
struct fc_bsg_job *bsg_job = ((struct srb_bsg*)sp->ctx)->bsg_job; struct fc_bsg_job *bsg_job = ((struct srb_ctx *)sp->ctx)->u.bsg_job;
int loop_iterartion = 0; int loop_iterartion = 0;
int cont_iocb_prsnt = 0; int cont_iocb_prsnt = 0;
int entry_count = 1; int entry_count = 1;
......
...@@ -897,7 +897,8 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -897,7 +897,8 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
const char *type; const char *type;
fc_port_t *fcport; fc_port_t *fcport;
srb_t *sp; srb_t *sp;
struct srb_logio *lio; struct srb_iocb *lio;
struct srb_ctx *ctx;
uint16_t *data; uint16_t *data;
uint16_t status; uint16_t status;
...@@ -905,14 +906,14 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -905,14 +906,14 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
if (!sp) if (!sp)
return; return;
lio = sp->ctx; ctx = sp->ctx;
del_timer(&lio->ctx.timer); lio = ctx->u.iocb_cmd;
type = lio->ctx.name; type = ctx->name;
fcport = sp->fcport; fcport = sp->fcport;
data = lio->data; data = lio->u.logio.data;
data[0] = MBS_COMMAND_ERROR; data[0] = MBS_COMMAND_ERROR;
data[1] = lio->flags & SRB_LOGIN_RETRIED ? data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ?
QLA_LOGIO_LOGIN_RETRIED : 0; QLA_LOGIO_LOGIN_RETRIED : 0;
if (mbx->entry_status) { if (mbx->entry_status) {
DEBUG2(printk(KERN_WARNING DEBUG2(printk(KERN_WARNING
...@@ -928,7 +929,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -928,7 +929,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
} }
status = le16_to_cpu(mbx->status); status = le16_to_cpu(mbx->status);
if (status == 0x30 && lio->ctx.type == SRB_LOGIN_CMD && if (status == 0x30 && ctx->type == SRB_LOGIN_CMD &&
le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE)
status = 0; status = 0;
if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) { if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) {
...@@ -938,7 +939,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -938,7 +939,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
le16_to_cpu(mbx->mb1))); le16_to_cpu(mbx->mb1)));
data[0] = MBS_COMMAND_COMPLETE; data[0] = MBS_COMMAND_COMPLETE;
if (lio->ctx.type == SRB_LOGIN_CMD) { if (ctx->type == SRB_LOGIN_CMD) {
fcport->port_type = FCT_TARGET; fcport->port_type = FCT_TARGET;
if (le16_to_cpu(mbx->mb1) & BIT_0) if (le16_to_cpu(mbx->mb1) & BIT_0)
fcport->port_type = FCT_INITIATOR; fcport->port_type = FCT_INITIATOR;
...@@ -969,7 +970,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -969,7 +970,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
le16_to_cpu(mbx->mb7))); le16_to_cpu(mbx->mb7)));
logio_done: logio_done:
lio->ctx.done(sp); lio->done(sp);
} }
static void static void
...@@ -980,7 +981,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -980,7 +981,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
const char *type; const char *type;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
srb_t *sp; srb_t *sp;
struct srb_bsg *sp_bsg; struct srb_ctx *sp_bsg;
struct fc_bsg_job *bsg_job; struct fc_bsg_job *bsg_job;
uint16_t comp_status; uint16_t comp_status;
uint32_t fw_status[3]; uint32_t fw_status[3];
...@@ -989,11 +990,11 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -989,11 +990,11 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
if (!sp) if (!sp)
return; return;
sp_bsg = (struct srb_bsg*)sp->ctx; sp_bsg = sp->ctx;
bsg_job = sp_bsg->bsg_job; bsg_job = sp_bsg->u.bsg_job;
type = NULL; type = NULL;
switch (sp_bsg->ctx.type) { switch (sp_bsg->type) {
case SRB_ELS_CMD_RPT: case SRB_ELS_CMD_RPT:
case SRB_ELS_CMD_HST: case SRB_ELS_CMD_HST:
type = "els"; type = "els";
...@@ -1004,7 +1005,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -1004,7 +1005,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
default: default:
qla_printk(KERN_WARNING, ha, qla_printk(KERN_WARNING, ha,
"%s: Unrecognized SRB: (%p) type=%d.\n", func, sp, "%s: Unrecognized SRB: (%p) type=%d.\n", func, sp,
sp_bsg->ctx.type); sp_bsg->type);
return; return;
} }
...@@ -1058,8 +1059,8 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -1058,8 +1059,8 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
dma_unmap_sg(&ha->pdev->dev, dma_unmap_sg(&ha->pdev->dev,
bsg_job->reply_payload.sg_list, bsg_job->reply_payload.sg_list,
bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE); bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
if ((sp_bsg->ctx.type == SRB_ELS_CMD_HST) || if ((sp_bsg->type == SRB_ELS_CMD_HST) ||
(sp_bsg->ctx.type == SRB_CT_CMD)) (sp_bsg->type == SRB_CT_CMD))
kfree(sp->fcport); kfree(sp->fcport);
kfree(sp->ctx); kfree(sp->ctx);
mempool_free(sp, ha->srb_mempool); mempool_free(sp, ha->srb_mempool);
...@@ -1074,7 +1075,8 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -1074,7 +1075,8 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
const char *type; const char *type;
fc_port_t *fcport; fc_port_t *fcport;
srb_t *sp; srb_t *sp;
struct srb_logio *lio; struct srb_iocb *lio;
struct srb_ctx *ctx;
uint16_t *data; uint16_t *data;
uint32_t iop[2]; uint32_t iop[2];
...@@ -1082,14 +1084,14 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -1082,14 +1084,14 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
if (!sp) if (!sp)
return; return;
lio = sp->ctx; ctx = sp->ctx;
del_timer(&lio->ctx.timer); lio = ctx->u.iocb_cmd;
type = lio->ctx.name; type = ctx->name;
fcport = sp->fcport; fcport = sp->fcport;
data = lio->data; data = lio->u.logio.data;
data[0] = MBS_COMMAND_ERROR; data[0] = MBS_COMMAND_ERROR;
data[1] = lio->flags & SRB_LOGIN_RETRIED ? data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ?
QLA_LOGIO_LOGIN_RETRIED : 0; QLA_LOGIO_LOGIN_RETRIED : 0;
if (logio->entry_status) { if (logio->entry_status) {
DEBUG2(printk(KERN_WARNING DEBUG2(printk(KERN_WARNING
...@@ -1108,7 +1110,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -1108,7 +1110,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
le32_to_cpu(logio->io_parameter[0]))); le32_to_cpu(logio->io_parameter[0])));
data[0] = MBS_COMMAND_COMPLETE; data[0] = MBS_COMMAND_COMPLETE;
if (lio->ctx.type != SRB_LOGIN_CMD) if (ctx->type != SRB_LOGIN_CMD)
goto logio_done; goto logio_done;
iop[0] = le32_to_cpu(logio->io_parameter[0]); iop[0] = le32_to_cpu(logio->io_parameter[0]);
...@@ -1156,7 +1158,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req, ...@@ -1156,7 +1158,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
le32_to_cpu(logio->io_parameter[1]))); le32_to_cpu(logio->io_parameter[1])));
logio_done: logio_done:
lio->ctx.done(sp); lio->done(sp);
} }
/** /**
......
...@@ -1191,21 +1191,16 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) ...@@ -1191,21 +1191,16 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
ctx = sp->ctx; ctx = sp->ctx;
if (ctx->type == SRB_LOGIN_CMD || if (ctx->type == SRB_LOGIN_CMD ||
ctx->type == SRB_LOGOUT_CMD) { ctx->type == SRB_LOGOUT_CMD) {
del_timer_sync(&ctx->timer); ctx->u.iocb_cmd->free(sp);
ctx->free(sp);
} else { } else {
struct srb_bsg *sp_bsg =
(struct srb_bsg *)sp->ctx;
struct fc_bsg_job *bsg_job = struct fc_bsg_job *bsg_job =
sp_bsg->bsg_job; ctx->u.bsg_job;
if (bsg_job->request->msgcode if (bsg_job->request->msgcode
== FC_BSG_HST_CT) == FC_BSG_HST_CT)
kfree(sp->fcport); kfree(sp->fcport);
bsg_job->req->errors = 0; bsg_job->req->errors = 0;
bsg_job->reply->result = res; bsg_job->reply->result = res;
bsg_job->job_done( bsg_job->job_done(bsg_job);
sp_bsg->bsg_job);
kfree(sp->ctx); kfree(sp->ctx);
mempool_free(sp, mempool_free(sp,
ha->srb_mempool); ha->srb_mempool);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment