Commit 2747fdb2 authored by Mike Christie's avatar Mike Christie Committed by James Bottomley

[SCSI] iser: convert ib_iser to support merged tasks

Convert ib_iser to support merged tasks.
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent fbc514b4
...@@ -124,15 +124,23 @@ iscsi_iser_recv(struct iscsi_conn *conn, ...@@ -124,15 +124,23 @@ iscsi_iser_recv(struct iscsi_conn *conn,
/** /**
* iscsi_iser_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands * iscsi_iser_task_init - Initialize ctask
* @ctask: iscsi ctask
* *
**/ * Initialize the ctask for the scsi command or mgmt command.
*/
static int static int
iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask) iscsi_iser_task_init(struct iscsi_cmd_task *ctask)
{ {
struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data; struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data;
struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
/* mgmt ctask */
if (!ctask->sc) {
iser_ctask->desc.data = ctask->data;
return 0;
}
iser_ctask->command_sent = 0; iser_ctask->command_sent = 0;
iser_ctask->iser_conn = iser_conn; iser_ctask->iser_conn = iser_conn;
iser_ctask_rdma_init(iser_ctask); iser_ctask_rdma_init(iser_ctask);
...@@ -140,9 +148,9 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask) ...@@ -140,9 +148,9 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask)
} }
/** /**
* iscsi_mtask_xmit - xmit management(immediate) task * iscsi_iser_mtask_xmit - xmit management(immediate) ctask
* @conn: iscsi connection * @conn: iscsi connection
* @mtask: task management task * @ctask: ctask management ctask
* *
* Notes: * Notes:
* The function can return -EAGAIN in which case caller must * The function can return -EAGAIN in which case caller must
...@@ -151,20 +159,19 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask) ...@@ -151,20 +159,19 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask)
* *
**/ **/
static int static int
iscsi_iser_mtask_xmit(struct iscsi_conn *conn, iscsi_iser_mtask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
struct iscsi_mgmt_task *mtask)
{ {
int error = 0; int error = 0;
debug_scsi("mtask deq [cid %d itt 0x%x]\n", conn->id, mtask->itt); debug_scsi("ctask deq [cid %d itt 0x%x]\n", conn->id, ctask->itt);
error = iser_send_control(conn, mtask); error = iser_send_control(conn, ctask);
/* since iser xmits control with zero copy, mtasks can not be recycled /* since iser xmits control with zero copy, ctasks can not be recycled
* right after sending them. * right after sending them.
* The recycling scheme is based on whether a response is expected * The recycling scheme is based on whether a response is expected
* - if yes, the mtask is recycled at iscsi_complete_pdu * - if yes, the ctask is recycled at iscsi_complete_pdu
* - if no, the mtask is recycled at iser_snd_completion * - if no, the ctask is recycled at iser_snd_completion
*/ */
if (error && error != -ENOBUFS) if (error && error != -ENOBUFS)
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
...@@ -173,7 +180,7 @@ iscsi_iser_mtask_xmit(struct iscsi_conn *conn, ...@@ -173,7 +180,7 @@ iscsi_iser_mtask_xmit(struct iscsi_conn *conn,
} }
static int static int
iscsi_iser_ctask_xmit_unsol_data(struct iscsi_conn *conn, iscsi_iser_task_xmit_unsol_data(struct iscsi_conn *conn,
struct iscsi_cmd_task *ctask) struct iscsi_cmd_task *ctask)
{ {
struct iscsi_data hdr; struct iscsi_data hdr;
...@@ -190,24 +197,27 @@ iscsi_iser_ctask_xmit_unsol_data(struct iscsi_conn *conn, ...@@ -190,24 +197,27 @@ iscsi_iser_ctask_xmit_unsol_data(struct iscsi_conn *conn,
error = iser_send_data_out(conn, ctask, &hdr); error = iser_send_data_out(conn, ctask, &hdr);
if (error) { if (error) {
ctask->unsol_datasn--; ctask->unsol_datasn--;
goto iscsi_iser_ctask_xmit_unsol_data_exit; goto iscsi_iser_task_xmit_unsol_data_exit;
} }
ctask->unsol_count -= ctask->data_count; ctask->unsol_count -= ctask->data_count;
debug_scsi("Need to send %d more as data-out PDUs\n", debug_scsi("Need to send %d more as data-out PDUs\n",
ctask->unsol_count); ctask->unsol_count);
} }
iscsi_iser_ctask_xmit_unsol_data_exit: iscsi_iser_task_xmit_unsol_data_exit:
return error; return error;
} }
static int static int
iscsi_iser_ctask_xmit(struct iscsi_conn *conn, iscsi_iser_task_xmit(struct iscsi_cmd_task *ctask)
struct iscsi_cmd_task *ctask)
{ {
struct iscsi_conn *conn = ctask->conn;
struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
int error = 0; int error = 0;
if (!ctask->sc)
return iscsi_iser_mtask_xmit(conn, ctask);
if (ctask->sc->sc_data_direction == DMA_TO_DEVICE) { if (ctask->sc->sc_data_direction == DMA_TO_DEVICE) {
BUG_ON(scsi_bufflen(ctask->sc) == 0); BUG_ON(scsi_bufflen(ctask->sc) == 0);
...@@ -223,25 +233,29 @@ iscsi_iser_ctask_xmit(struct iscsi_conn *conn, ...@@ -223,25 +233,29 @@ iscsi_iser_ctask_xmit(struct iscsi_conn *conn,
if (!iser_ctask->command_sent) { if (!iser_ctask->command_sent) {
error = iser_send_command(conn, ctask); error = iser_send_command(conn, ctask);
if (error) if (error)
goto iscsi_iser_ctask_xmit_exit; goto iscsi_iser_task_xmit_exit;
iser_ctask->command_sent = 1; iser_ctask->command_sent = 1;
} }
/* Send unsolicited data-out PDU(s) if necessary */ /* Send unsolicited data-out PDU(s) if necessary */
if (ctask->unsol_count) if (ctask->unsol_count)
error = iscsi_iser_ctask_xmit_unsol_data(conn, ctask); error = iscsi_iser_task_xmit_unsol_data(conn, ctask);
iscsi_iser_ctask_xmit_exit: iscsi_iser_task_xmit_exit:
if (error && error != -ENOBUFS) if (error && error != -ENOBUFS)
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
return error; return error;
} }
static void static void
iscsi_iser_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) iscsi_iser_cleanup_task(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
{ {
struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
/* mgmt tasks do not need special cleanup */
if (!ctask->sc)
return;
if (iser_ctask->status == ISER_TASK_STATUS_STARTED) { if (iser_ctask->status == ISER_TASK_STATUS_STARTED) {
iser_ctask->status = ISER_TASK_STATUS_COMPLETED; iser_ctask->status = ISER_TASK_STATUS_COMPLETED;
iser_ctask_rdma_finalize(iser_ctask); iser_ctask_rdma_finalize(iser_ctask);
...@@ -395,9 +409,7 @@ iscsi_iser_session_create(struct Scsi_Host *shost, ...@@ -395,9 +409,7 @@ iscsi_iser_session_create(struct Scsi_Host *shost,
struct iscsi_session *session; struct iscsi_session *session;
int i; int i;
struct iscsi_cmd_task *ctask; struct iscsi_cmd_task *ctask;
struct iscsi_mgmt_task *mtask;
struct iscsi_iser_cmd_task *iser_ctask; struct iscsi_iser_cmd_task *iser_ctask;
struct iser_desc *desc;
if (shost) { if (shost) {
printk(KERN_ERR "iscsi_tcp: invalid shost %d.\n", printk(KERN_ERR "iscsi_tcp: invalid shost %d.\n",
...@@ -425,13 +437,12 @@ iscsi_iser_session_create(struct Scsi_Host *shost, ...@@ -425,13 +437,12 @@ iscsi_iser_session_create(struct Scsi_Host *shost,
cls_session = iscsi_session_setup(&iscsi_iser_transport, shost, cls_session = iscsi_session_setup(&iscsi_iser_transport, shost,
ISCSI_DEF_XMIT_CMDS_MAX, ISCSI_DEF_XMIT_CMDS_MAX,
sizeof(struct iscsi_iser_cmd_task), sizeof(struct iscsi_iser_cmd_task),
sizeof(struct iser_desc),
initial_cmdsn); initial_cmdsn);
if (!cls_session) if (!cls_session)
goto remove_host; goto remove_host;
session = cls_session->dd_data; session = cls_session->dd_data;
shost->can_queue = session->cmds_max; shost->can_queue = session->scsi_cmds_max;
/* libiscsi setup itts, data and pool so just set desc fields */ /* libiscsi setup itts, data and pool so just set desc fields */
for (i = 0; i < session->cmds_max; i++) { for (i = 0; i < session->cmds_max; i++) {
ctask = session->cmds[i]; ctask = session->cmds[i];
...@@ -439,14 +450,6 @@ iscsi_iser_session_create(struct Scsi_Host *shost, ...@@ -439,14 +450,6 @@ iscsi_iser_session_create(struct Scsi_Host *shost,
ctask->hdr = (struct iscsi_cmd *)&iser_ctask->desc.iscsi_header; ctask->hdr = (struct iscsi_cmd *)&iser_ctask->desc.iscsi_header;
ctask->hdr_max = sizeof(iser_ctask->desc.iscsi_header); ctask->hdr_max = sizeof(iser_ctask->desc.iscsi_header);
} }
for (i = 0; i < session->mgmtpool_max; i++) {
mtask = session->mgmt_cmds[i];
desc = mtask->dd_data;
mtask->hdr = &desc->iscsi_header;
desc->data = mtask->data;
}
return cls_session; return cls_session;
remove_host: remove_host:
...@@ -659,10 +662,9 @@ static struct iscsi_transport iscsi_iser_transport = { ...@@ -659,10 +662,9 @@ static struct iscsi_transport iscsi_iser_transport = {
/* IO */ /* IO */
.send_pdu = iscsi_conn_send_pdu, .send_pdu = iscsi_conn_send_pdu,
.get_stats = iscsi_iser_conn_get_stats, .get_stats = iscsi_iser_conn_get_stats,
.init_cmd_task = iscsi_iser_cmd_init, .init_task = iscsi_iser_task_init,
.xmit_cmd_task = iscsi_iser_ctask_xmit, .xmit_task = iscsi_iser_task_xmit,
.xmit_mgmt_task = iscsi_iser_mtask_xmit, .cleanup_task = iscsi_iser_cleanup_task,
.cleanup_cmd_task = iscsi_iser_cleanup_ctask,
/* recovery */ /* recovery */
.session_recovery_timedout = iscsi_session_recovery_timedout, .session_recovery_timedout = iscsi_session_recovery_timedout,
......
...@@ -299,7 +299,7 @@ extern int iser_debug_level; ...@@ -299,7 +299,7 @@ extern int iser_debug_level;
int iser_conn_set_full_featured_mode(struct iscsi_conn *conn); int iser_conn_set_full_featured_mode(struct iscsi_conn *conn);
int iser_send_control(struct iscsi_conn *conn, int iser_send_control(struct iscsi_conn *conn,
struct iscsi_mgmt_task *mtask); struct iscsi_cmd_task *ctask);
int iser_send_command(struct iscsi_conn *conn, int iser_send_command(struct iscsi_conn *conn,
struct iscsi_cmd_task *ctask); struct iscsi_cmd_task *ctask);
......
...@@ -300,13 +300,13 @@ int iser_conn_set_full_featured_mode(struct iscsi_conn *conn) ...@@ -300,13 +300,13 @@ int iser_conn_set_full_featured_mode(struct iscsi_conn *conn)
} }
static int static int
iser_check_xmit(struct iscsi_conn *conn, void *task) iser_check_xmit(struct iscsi_conn *conn, void *ctask)
{ {
struct iscsi_iser_conn *iser_conn = conn->dd_data; struct iscsi_iser_conn *iser_conn = conn->dd_data;
if (atomic_read(&iser_conn->ib_conn->post_send_buf_count) == if (atomic_read(&iser_conn->ib_conn->post_send_buf_count) ==
ISER_QP_MAX_REQ_DTOS) { ISER_QP_MAX_REQ_DTOS) {
iser_dbg("%ld can't xmit task %p\n",jiffies,task); iser_dbg("%ld can't xmit ctask %p\n",jiffies,ctask);
return -ENOBUFS; return -ENOBUFS;
} }
return 0; return 0;
...@@ -470,10 +470,11 @@ int iser_send_data_out(struct iscsi_conn *conn, ...@@ -470,10 +470,11 @@ int iser_send_data_out(struct iscsi_conn *conn,
} }
int iser_send_control(struct iscsi_conn *conn, int iser_send_control(struct iscsi_conn *conn,
struct iscsi_mgmt_task *mtask) struct iscsi_cmd_task *ctask)
{ {
struct iscsi_iser_conn *iser_conn = conn->dd_data; struct iscsi_iser_conn *iser_conn = conn->dd_data;
struct iser_desc *mdesc = mtask->dd_data; struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
struct iser_desc *mdesc = &iser_ctask->desc;
struct iser_dto *send_dto = NULL; struct iser_dto *send_dto = NULL;
unsigned long data_seg_len; unsigned long data_seg_len;
int err = 0; int err = 0;
...@@ -485,7 +486,7 @@ int iser_send_control(struct iscsi_conn *conn, ...@@ -485,7 +486,7 @@ int iser_send_control(struct iscsi_conn *conn,
return -EPERM; return -EPERM;
} }
if (iser_check_xmit(conn,mtask)) if (iser_check_xmit(conn, ctask))
return -ENOBUFS; return -ENOBUFS;
/* build the tx desc regd header and add it to the tx desc dto */ /* build the tx desc regd header and add it to the tx desc dto */
...@@ -498,14 +499,14 @@ int iser_send_control(struct iscsi_conn *conn, ...@@ -498,14 +499,14 @@ int iser_send_control(struct iscsi_conn *conn,
iser_reg_single(device, send_dto->regd[0], DMA_TO_DEVICE); iser_reg_single(device, send_dto->regd[0], DMA_TO_DEVICE);
data_seg_len = ntoh24(mtask->hdr->dlength); data_seg_len = ntoh24(ctask->hdr->dlength);
if (data_seg_len > 0) { if (data_seg_len > 0) {
regd_buf = &mdesc->data_regd_buf; regd_buf = &mdesc->data_regd_buf;
memset(regd_buf, 0, sizeof(struct iser_regd_buf)); memset(regd_buf, 0, sizeof(struct iser_regd_buf));
regd_buf->device = device; regd_buf->device = device;
regd_buf->virt_addr = mtask->data; regd_buf->virt_addr = ctask->data;
regd_buf->data_size = mtask->data_count; regd_buf->data_size = ctask->data_count;
iser_reg_single(device, regd_buf, iser_reg_single(device, regd_buf,
DMA_TO_DEVICE); DMA_TO_DEVICE);
iser_dto_add_regd_buff(send_dto, regd_buf, iser_dto_add_regd_buff(send_dto, regd_buf,
...@@ -559,7 +560,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc, ...@@ -559,7 +560,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
if (opcode == ISCSI_OP_SCSI_CMD_RSP) { if (opcode == ISCSI_OP_SCSI_CMD_RSP) {
ctask = iscsi_itt_to_ctask(conn->iscsi_conn, hdr->itt); ctask = iscsi_itt_to_ctask(conn->iscsi_conn, hdr->itt);
if (!ctask) if (!ctask)
iser_err("itt can't be matched to task!!! " iser_err("itt can't be matched to ctask!!! "
"conn %p opcode %d itt %d\n", "conn %p opcode %d itt %d\n",
conn->iscsi_conn, opcode, hdr->itt); conn->iscsi_conn, opcode, hdr->itt);
else { else {
...@@ -577,7 +578,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc, ...@@ -577,7 +578,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
kmem_cache_free(ig.desc_cache, rx_desc); kmem_cache_free(ig.desc_cache, rx_desc);
/* decrementing conn->post_recv_buf_count only --after-- freeing the * /* decrementing conn->post_recv_buf_count only --after-- freeing the *
* task eliminates the need to worry on tasks which are completed in * * ctask eliminates the need to worry on ctasks which are completed in *
* parallel to the execution of iser_conn_term. So the code that waits * * parallel to the execution of iser_conn_term. So the code that waits *
* for the posted rx bufs refcount to become zero handles everything */ * for the posted rx bufs refcount to become zero handles everything */
atomic_dec(&conn->ib_conn->post_recv_buf_count); atomic_dec(&conn->ib_conn->post_recv_buf_count);
...@@ -589,7 +590,7 @@ void iser_snd_completion(struct iser_desc *tx_desc) ...@@ -589,7 +590,7 @@ void iser_snd_completion(struct iser_desc *tx_desc)
struct iser_conn *ib_conn = dto->ib_conn; struct iser_conn *ib_conn = dto->ib_conn;
struct iscsi_iser_conn *iser_conn = ib_conn->iser_conn; struct iscsi_iser_conn *iser_conn = ib_conn->iser_conn;
struct iscsi_conn *conn = iser_conn->iscsi_conn; struct iscsi_conn *conn = iser_conn->iscsi_conn;
struct iscsi_mgmt_task *mtask; struct iscsi_cmd_task *ctask;
int resume_tx = 0; int resume_tx = 0;
iser_dbg("Initiator, Data sent dto=0x%p\n", dto); iser_dbg("Initiator, Data sent dto=0x%p\n", dto);
...@@ -612,15 +613,10 @@ void iser_snd_completion(struct iser_desc *tx_desc) ...@@ -612,15 +613,10 @@ void iser_snd_completion(struct iser_desc *tx_desc)
if (tx_desc->type == ISCSI_TX_CONTROL) { if (tx_desc->type == ISCSI_TX_CONTROL) {
/* this arithmetic is legal by libiscsi dd_data allocation */ /* this arithmetic is legal by libiscsi dd_data allocation */
mtask = (void *) ((long)(void *)tx_desc - ctask = (void *) ((long)(void *)tx_desc -
sizeof(struct iscsi_mgmt_task)); sizeof(struct iscsi_cmd_task));
if (mtask->hdr->itt == RESERVED_ITT) { if (ctask->hdr->itt == RESERVED_ITT)
struct iscsi_session *session = conn->session; iscsi_put_ctask(ctask);
spin_lock(&conn->session->lock);
iscsi_free_mgmt_task(conn, mtask);
spin_unlock(&session->lock);
}
} }
} }
......
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