Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 292969
b: refs/heads/master
c: c0b9d3f
h: refs/heads/master
i:
  292967: 9a4b6c8
v: v3
  • Loading branch information
Vikas Chaudhary authored and James Bottomley committed Feb 19, 2012
1 parent 3b8b8e3 commit 0fc032e
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ac20c7bf070df2b0feb410558ec4d75dbe59b701
refs/heads/master: c0b9d3f750520ad3005b99144260e486ef01b5d9
21 changes: 21 additions & 0 deletions trunk/drivers/scsi/qla4xxx/ql4_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ struct srb {
uint16_t reserved2;
};

/* Mailbox request block structure */
struct mrb {
struct scsi_qla_host *ha;
struct mbox_cmd_iocb *mbox;
uint32_t mbox_cmd;
uint16_t iocb_cnt; /* Number of used iocbs */
uint32_t pid;
};

/*
* Asynchronous Event Queue structure
*/
Expand Down Expand Up @@ -303,6 +312,7 @@ struct ql4_tuple_ddb {

enum qla4_work_type {
QLA4_EVENT_AEN,
QLA4_EVENT_PING_STATUS,
};

struct qla4_work_evt {
Expand All @@ -314,6 +324,12 @@ struct qla4_work_evt {
uint32_t data_size;
uint8_t data[0];
} aen;
struct {
uint32_t status;
uint32_t pid;
uint32_t data_size;
uint8_t data[0];
} ping;
} u;
};

Expand Down Expand Up @@ -690,6 +706,11 @@ struct scsi_qla_host {
/* event work list */
struct list_head work_list;
spinlock_t work_lock;

/* mbox iocb */
#define MAX_MRB 128
struct mrb *active_mrb_array[MAX_MRB];
uint32_t mrb_index;
};

struct ql4_task_data {
Expand Down
20 changes: 20 additions & 0 deletions trunk/drivers/scsi/qla4xxx/ql4_fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ struct qla_flt_region {
/* Mailbox command definitions */
#define MBOX_CMD_ABOUT_FW 0x0009
#define MBOX_CMD_PING 0x000B
#define PING_IPV6_PROTOCOL_ENABLE 0x1
#define PING_IPV6_LINKLOCAL_ADDR 0x4
#define PING_IPV6_ADDR0 0x8
#define PING_IPV6_ADDR1 0xC
#define MBOX_CMD_ENABLE_INTRS 0x0010
#define INTR_DISABLE 0
#define INTR_ENABLE 1
Expand Down Expand Up @@ -922,6 +926,8 @@ struct qla4_header {
#define ET_CMND_T3 0x19
#define ET_PASSTHRU0 0x3A
#define ET_PASSTHRU_STATUS 0x3C
#define ET_MBOX_CMD 0x38
#define ET_MBOX_STATUS 0x39

uint8_t entryStatus;
uint8_t systemDefined;
Expand Down Expand Up @@ -1122,6 +1128,20 @@ struct passthru_status {
uint8_t res4[16]; /* 30-3F */
};

struct mbox_cmd_iocb {
struct qla4_header hdr; /* 00-03 */
uint32_t handle; /* 04-07 */
uint32_t in_mbox[8]; /* 08-25 */
uint32_t res1[6]; /* 26-3F */
};

struct mbox_status_iocb {
struct qla4_header hdr; /* 00-03 */
uint32_t handle; /* 04-07 */
uint32_t out_mbox[8]; /* 08-25 */
uint32_t res1[6]; /* 26-3F */
};

/*
* ISP queue - response queue entry definition.
*/
Expand Down
5 changes: 5 additions & 0 deletions trunk/drivers/scsi/qla4xxx/ql4_glbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ int qla4xxx_ddb_change(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
void qla4xxx_build_ddb_list(struct scsi_qla_host *ha, int is_reset);
int qla4xxx_post_aen_work(struct scsi_qla_host *ha, uint32_t aen_code,
uint32_t data_size, uint8_t *data);
int qla4xxx_ping_iocb(struct scsi_qla_host *ha, uint32_t options,
uint32_t payload_size, uint32_t pid, uint8_t *ipaddr);
int qla4xxx_post_ping_evt_work(struct scsi_qla_host *ha,
uint32_t status, uint32_t pid,
uint32_t data_size, uint8_t *data);

/* BSG Functions */
int qla4xxx_bsg_request(struct bsg_job *bsg_job);
Expand Down
5 changes: 5 additions & 0 deletions trunk/drivers/scsi/qla4xxx/ql4_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static void qla4xxx_init_response_q_entries(struct scsi_qla_host *ha)
int qla4xxx_init_rings(struct scsi_qla_host *ha)
{
unsigned long flags = 0;
int i;

/* Initialize request queue. */
spin_lock_irqsave(&ha->hardware_lock, flags);
Expand Down Expand Up @@ -125,6 +126,10 @@ int qla4xxx_init_rings(struct scsi_qla_host *ha)

qla4xxx_init_response_q_entries(ha);

/* Initialize mabilbox active array */
for (i = 0; i < MAX_MRB; i++)
ha->active_mrb_array[i] = NULL;

spin_unlock_irqrestore(&ha->hardware_lock, flags);

return QLA_SUCCESS;
Expand Down
92 changes: 92 additions & 0 deletions trunk/drivers/scsi/qla4xxx/ql4_iocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,95 @@ int qla4xxx_send_passthru0(struct iscsi_task *task)
spin_unlock_irqrestore(&ha->hardware_lock, flags);
return ret;
}

static struct mrb *qla4xxx_get_new_mrb(struct scsi_qla_host *ha)
{
struct mrb *mrb;

mrb = kzalloc(sizeof(*mrb), GFP_KERNEL);
if (!mrb)
return mrb;

mrb->ha = ha;
return mrb;
}

int qla4xxx_send_mbox_iocb(struct scsi_qla_host *ha, struct mrb *mrb,
uint32_t *in_mbox)
{
int rval = QLA_SUCCESS;
uint32_t i;
unsigned long flags;
uint32_t index = 0;

/* Acquire hardware specific lock */
spin_lock_irqsave(&ha->hardware_lock, flags);

/* Get pointer to the queue entry for the marker */
rval = qla4xxx_get_req_pkt(ha, (struct queue_entry **) &(mrb->mbox));
if (rval != QLA_SUCCESS)
goto exit_mbox_iocb;

index = ha->mrb_index;
/* get valid mrb index*/
for (i = 0; i < MAX_MRB; i++) {
index++;
if (index == MAX_MRB)
index = 1;
if (ha->active_mrb_array[index] == NULL) {
ha->mrb_index = index;
break;
}
}

mrb->iocb_cnt = 1;
ha->active_mrb_array[index] = mrb;
mrb->mbox->handle = index;
mrb->mbox->hdr.entryType = ET_MBOX_CMD;
mrb->mbox->hdr.entryCount = mrb->iocb_cnt;
memcpy(mrb->mbox->in_mbox, in_mbox, 32);
mrb->mbox_cmd = in_mbox[0];
wmb();

ha->isp_ops->queue_iocb(ha);
exit_mbox_iocb:
spin_unlock_irqrestore(&ha->hardware_lock, flags);
return rval;
}

int qla4xxx_ping_iocb(struct scsi_qla_host *ha, uint32_t options,
uint32_t payload_size, uint32_t pid, uint8_t *ipaddr)
{
uint32_t in_mbox[8];
struct mrb *mrb = NULL;
int rval = QLA_SUCCESS;

memset(in_mbox, 0, sizeof(in_mbox));

mrb = qla4xxx_get_new_mrb(ha);
if (!mrb) {
DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: fail to get new mrb\n",
__func__));
rval = QLA_ERROR;
goto exit_ping;
}

in_mbox[0] = MBOX_CMD_PING;
in_mbox[1] = options;
memcpy(&in_mbox[2], &ipaddr[0], 4);
memcpy(&in_mbox[3], &ipaddr[4], 4);
memcpy(&in_mbox[4], &ipaddr[8], 4);
memcpy(&in_mbox[5], &ipaddr[12], 4);
in_mbox[6] = payload_size;

mrb->pid = pid;
rval = qla4xxx_send_mbox_iocb(ha, mrb, in_mbox);

if (rval != QLA_SUCCESS)
goto exit_ping;

return rval;
exit_ping:
kfree(mrb);
return rval;
}
72 changes: 72 additions & 0 deletions trunk/drivers/scsi/qla4xxx/ql4_isr.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,71 @@ static void qla4xxx_passthru_status_entry(struct scsi_qla_host *ha,
queue_work(ha->task_wq, &task_data->task_work);
}

static struct mrb *qla4xxx_del_mrb_from_active_array(struct scsi_qla_host *ha,
uint32_t index)
{
struct mrb *mrb = NULL;

/* validate handle and remove from active array */
if (index >= MAX_MRB)
return mrb;

mrb = ha->active_mrb_array[index];
ha->active_mrb_array[index] = NULL;
if (!mrb)
return mrb;

/* update counters */
ha->req_q_count += mrb->iocb_cnt;
ha->iocb_cnt -= mrb->iocb_cnt;

return mrb;
}

static void qla4xxx_mbox_status_entry(struct scsi_qla_host *ha,
struct mbox_status_iocb *mbox_sts_entry)
{
struct mrb *mrb;
uint32_t status;
uint32_t data_size;

mrb = qla4xxx_del_mrb_from_active_array(ha,
le32_to_cpu(mbox_sts_entry->handle));

if (mrb == NULL) {
ql4_printk(KERN_WARNING, ha, "%s: mrb[%d] is null\n", __func__,
mbox_sts_entry->handle);
return;
}

switch (mrb->mbox_cmd) {
case MBOX_CMD_PING:
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: mbox_cmd = 0x%x, "
"mbox_sts[0] = 0x%x, mbox_sts[6] = 0x%x\n",
__func__, mrb->mbox_cmd,
mbox_sts_entry->out_mbox[0],
mbox_sts_entry->out_mbox[6]));

if (mbox_sts_entry->out_mbox[0] == MBOX_STS_COMMAND_COMPLETE)
status = QLA_SUCCESS;
else
status = QLA_ERROR;

data_size = sizeof(mbox_sts_entry->out_mbox);

qla4xxx_post_ping_evt_work(ha, status, mrb->pid, data_size,
(uint8_t *) mbox_sts_entry->out_mbox);
break;

default:
DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: invalid mbox_cmd = "
"0x%x\n", __func__, mrb->mbox_cmd));
}

kfree(mrb);
return;
}

/**
* qla4xxx_process_response_queue - process response queue completions
* @ha: Pointer to host adapter structure.
Expand Down Expand Up @@ -461,6 +526,13 @@ void qla4xxx_process_response_queue(struct scsi_qla_host *ha)
"ignoring\n", ha->host_no, __func__));
break;

case ET_MBOX_STATUS:
DEBUG2(ql4_printk(KERN_INFO, ha,
"%s: mbox status IOCB\n", __func__));
qla4xxx_mbox_status_entry(ha,
(struct mbox_status_iocb *)sts_entry);
break;

default:
/*
* Invalid entry in response queue, reset RISC
Expand Down
Loading

0 comments on commit 0fc032e

Please sign in to comment.