Skip to content

Commit

Permalink
[SCSI] qla2xxx: Provide common framework for BSG and IOCB commands.
Browse files Browse the repository at this point in the history
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: Giridhar Malavali <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
Madhuranath Iyengar authored and James Bottomley committed May 16, 2010
1 parent b7d2280 commit 4916392
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 142 deletions.
28 changes: 14 additions & 14 deletions drivers/scsi/qla2xxx/qla_bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ qla2x00_get_ctx_bsg_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size)
{
srb_t *sp;
struct qla_hw_data *ha = vha->hw;
struct srb_bsg_ctx *ctx;
struct srb_ctx *ctx;

sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL);
if (!sp)
Expand Down Expand Up @@ -208,7 +208,7 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
int req_sg_cnt, rsp_sg_cnt;
int rval = (DRIVER_ERROR << 16);
uint16_t nextlid = 0;
struct srb_bsg *els;
struct srb_ctx *els;

/* Multiple SG's are not supported for ELS requests */
if (bsg_job->request_payload.sg_cnt > 1 ||
Expand Down Expand Up @@ -307,17 +307,17 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
}

/* 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) {
rval = -ENOMEM;
goto done_unmap_sg;
}

els = sp->ctx;
els->ctx.type =
els->type =
(bsg_job->request->msgcode == FC_BSG_RPT_ELS ?
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,
"scsi(%ld:%x): bsg rqst type: %s els type: %x - loop-id=%x "
Expand Down Expand Up @@ -361,7 +361,7 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
uint16_t loop_id;
struct fc_port *fcport;
char *type = "FC_BSG_HST_CT";
struct srb_bsg *ct;
struct srb_ctx *ct;

/* pass through is supported only for ISP 4Gb or higher */
if (!IS_FWI2_CAPABLE(ha)) {
Expand Down Expand Up @@ -442,15 +442,15 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
fcport->loop_id = loop_id;

/* 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) {
rval = -ENOMEM;
goto done_free_fcport;
}

ct = sp->ctx;
ct->ctx.type = SRB_CT_CMD;
ct->bsg_job = bsg_job;
ct->type = SRB_CT_CMD;
ct->u.bsg_job = bsg_job;

DEBUG2(qla_printk(KERN_INFO, ha,
"scsi(%ld:%x): bsg rqst type: %s els type: %x - loop-id=%x "
Expand Down Expand Up @@ -1155,7 +1155,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
int cnt, que;
unsigned long flags;
struct req_que *req;
struct srb_bsg *sp_bsg;
struct srb_ctx *sp_bsg;

/* find the bsg job from the active list of commands */
spin_lock_irqsave(&ha->hardware_lock, flags);
Expand All @@ -1167,11 +1167,11 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
sp = req->outstanding_cmds[cnt];
if (sp) {
sp_bsg = (struct srb_bsg *)sp->ctx;
sp_bsg = sp->ctx;

if (((sp_bsg->ctx.type == SRB_CT_CMD) ||
(sp_bsg->ctx.type == SRB_ELS_CMD_HST))
&& (sp_bsg->bsg_job == bsg_job)) {
if (((sp_bsg->type == SRB_CT_CMD) ||
(sp_bsg->type == SRB_ELS_CMD_HST))
&& (sp_bsg->u.bsg_job == bsg_job)) {
if (ha->isp_ops->abort_command(sp)) {
DEBUG2(qla_printk(KERN_INFO, ha,
"scsi(%ld): mbx "
Expand Down
48 changes: 23 additions & 25 deletions drivers/scsi/qla2xxx/qla_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,16 @@ typedef struct srb {
/*
* SRB extensions.
*/
#define SRB_LOGIN_CMD 1
#define SRB_LOGOUT_CMD 2
#define SRB_ELS_CMD_RPT 3
#define SRB_ELS_CMD_HST 4
#define SRB_CT_CMD 5
#define SRB_ADISC_CMD 6

struct srb_ctx {
uint16_t type;
char *name;
struct srb_iocb {
union {
struct {
uint16_t flags;
#define SRB_LOGIN_RETRIED BIT_0
#define SRB_LOGIN_COND_PLOGI BIT_1
#define SRB_LOGIN_SKIP_PRLI BIT_2
uint16_t data[2];
} logio;
} u;

struct timer_list timer;

Expand All @@ -232,23 +232,21 @@ struct srb_ctx {
void (*timeout)(srb_t *);
};

struct srb_logio {
struct srb_ctx ctx;

#define SRB_LOGIN_RETRIED BIT_0
#define SRB_LOGIN_COND_PLOGI BIT_1
#define SRB_LOGIN_SKIP_PRLI BIT_2
uint16_t flags;
uint16_t data[2];
};
/* Values for srb_ctx type */
#define SRB_LOGIN_CMD 1
#define SRB_LOGOUT_CMD 2
#define SRB_ELS_CMD_RPT 3
#define SRB_ELS_CMD_HST 4
#define SRB_CT_CMD 5
#define SRB_ADISC_CMD 6

struct srb_bsg_ctx {
struct srb_ctx {
uint16_t type;
};

struct srb_bsg {
struct srb_bsg_ctx ctx;
struct fc_bsg_job *bsg_job;
char *name;
union {
struct srb_iocb *iocb_cmd;
struct fc_bsg_job *bsg_job;
} u;
};

struct msg_echo_lb {
Expand Down
6 changes: 3 additions & 3 deletions drivers/scsi/qla2xxx/qla_gbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_adisc(struct scsi_qla_host *, fc_port_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 *);
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 *);
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 *);

extern fc_port_t *
Expand Down
Loading

0 comments on commit 4916392

Please sign in to comment.