aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
authorOlaf Kirch <olaf.kirch@oracle.com>2007-12-13 13:43:35 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-11 19:28:42 -0500
commita8ac6311cc21d78fa284cd43f56df2063f536bf1 (patch)
treec408dcccab2854dd9dd1775b5971ea60b34127dd /drivers/scsi/libiscsi.c
parent1040c99d9fd9de2bf00efae6d91014f890575bdb (diff)
[SCSI] iscsi: convert xmit path to iscsi chunks
Convert xmit to iscsi chunks. from michaelc@cs.wisc.edu: Bug fixes, more digest integration, sg chaining conversion and other sg wrapper changes, coding style sync up, and removal of io fields, like pdu_sent, that are not needed. Signed-off-by: Olaf Kirch <olaf.kirch@oracle.com> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index b0bc8c3b0ecb..f15df8d75fd8 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -156,20 +156,19 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
156 rc = iscsi_add_hdr(ctask, sizeof(*hdr)); 156 rc = iscsi_add_hdr(ctask, sizeof(*hdr));
157 if (rc) 157 if (rc)
158 return rc; 158 return rc;
159 hdr->opcode = ISCSI_OP_SCSI_CMD; 159 hdr->opcode = ISCSI_OP_SCSI_CMD;
160 hdr->flags = ISCSI_ATTR_SIMPLE; 160 hdr->flags = ISCSI_ATTR_SIMPLE;
161 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); 161 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
162 hdr->itt = build_itt(ctask->itt, conn->id, session->age); 162 hdr->itt = build_itt(ctask->itt, conn->id, session->age);
163 hdr->data_length = cpu_to_be32(scsi_bufflen(sc)); 163 hdr->data_length = cpu_to_be32(scsi_bufflen(sc));
164 hdr->cmdsn = cpu_to_be32(session->cmdsn); 164 hdr->cmdsn = cpu_to_be32(session->cmdsn);
165 session->cmdsn++; 165 session->cmdsn++;
166 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn); 166 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
167 memcpy(hdr->cdb, sc->cmnd, sc->cmd_len); 167 memcpy(hdr->cdb, sc->cmnd, sc->cmd_len);
168 if (sc->cmd_len < MAX_COMMAND_SIZE) 168 if (sc->cmd_len < MAX_COMMAND_SIZE)
169 memset(&hdr->cdb[sc->cmd_len], 0, 169 memset(&hdr->cdb[sc->cmd_len], 0,
170 MAX_COMMAND_SIZE - sc->cmd_len); 170 MAX_COMMAND_SIZE - sc->cmd_len);
171 171
172 ctask->data_count = 0;
173 ctask->imm_count = 0; 172 ctask->imm_count = 0;
174 if (sc->sc_data_direction == DMA_TO_DEVICE) { 173 if (sc->sc_data_direction == DMA_TO_DEVICE) {
175 hdr->flags |= ISCSI_FLAG_CMD_WRITE; 174 hdr->flags |= ISCSI_FLAG_CMD_WRITE;
@@ -198,9 +197,9 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
198 else 197 else
199 ctask->imm_count = min(scsi_bufflen(sc), 198 ctask->imm_count = min(scsi_bufflen(sc),
200 conn->max_xmit_dlength); 199 conn->max_xmit_dlength);
201 hton24(ctask->hdr->dlength, ctask->imm_count); 200 hton24(hdr->dlength, ctask->imm_count);
202 } else 201 } else
203 zero_data(ctask->hdr->dlength); 202 zero_data(hdr->dlength);
204 203
205 if (!session->initial_r2t_en) { 204 if (!session->initial_r2t_en) {
206 ctask->unsol_count = min((session->first_burst), 205 ctask->unsol_count = min((session->first_burst),
@@ -210,7 +209,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
210 209
211 if (!ctask->unsol_count) 210 if (!ctask->unsol_count)
212 /* No unsolicit Data-Out's */ 211 /* No unsolicit Data-Out's */
213 ctask->hdr->flags |= ISCSI_FLAG_CMD_FINAL; 212 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
214 } else { 213 } else {
215 hdr->flags |= ISCSI_FLAG_CMD_FINAL; 214 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
216 zero_data(hdr->dlength); 215 zero_data(hdr->dlength);
@@ -228,13 +227,15 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
228 WARN_ON(hdrlength >= 256); 227 WARN_ON(hdrlength >= 256);
229 hdr->hlength = hdrlength & 0xFF; 228 hdr->hlength = hdrlength & 0xFF;
230 229
231 conn->scsicmd_pdus_cnt++; 230 if (conn->session->tt->init_cmd_task(conn->ctask))
231 return EIO;
232 232
233 debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d " 233 conn->scsicmd_pdus_cnt++;
234 debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d "
234 "cmdsn %d win %d]\n", 235 "cmdsn %d win %d]\n",
235 sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read", 236 sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read",
236 conn->id, sc, sc->cmnd[0], ctask->itt, scsi_bufflen(sc), 237 conn->id, sc, sc->cmnd[0], ctask->itt, scsi_bufflen(sc),
237 session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); 238 session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1);
238 return 0; 239 return 0;
239} 240}
240 241
@@ -927,7 +928,7 @@ check_mgmt:
927 fail_command(conn, conn->ctask, DID_ABORT << 16); 928 fail_command(conn, conn->ctask, DID_ABORT << 16);
928 continue; 929 continue;
929 } 930 }
930 conn->session->tt->init_cmd_task(conn->ctask); 931
931 conn->ctask->state = ISCSI_TASK_RUNNING; 932 conn->ctask->state = ISCSI_TASK_RUNNING;
932 list_move_tail(conn->xmitqueue.next, &conn->run_list); 933 list_move_tail(conn->xmitqueue.next, &conn->run_list);
933 rc = iscsi_xmit_ctask(conn); 934 rc = iscsi_xmit_ctask(conn);