1294 task->conn = conn;
1295 task->sc = sc;
1296 INIT_LIST_HEAD(&task->running);
1297 list_add_tail(&task->running, &conn->xmitqueue);
1298
1299 if (session->tt->caps & CAP_DATA_PATH_OFFLOAD) {
1300 if (iscsi_prep_scsi_cmd_pdu(task)) {
1301 sc->result = DID_ABORT << 16;
1302 sc->scsi_done = NULL;
1303 iscsi_complete_command(task);
1304 goto fault;
1305 }
1306 if (session->tt->xmit_task(task)) {
1307 sc->scsi_done = NULL;
1308 iscsi_complete_command(task);
1309 reason = FAILURE_SESSION_NOT_READY;
1310 goto reject;
1311 }
1312 } else
1313 scsi_queue_work(session->host, &conn->xmitwork);
1314
1315 session->queued_cmdsn++;
1316 spin_unlock(&session->lock);
1317 spin_lock(host->host_lock);
1318 return 0;
1319
1320reject:
1321 spin_unlock(&session->lock);
1322 debug_scsi("cmd 0x%x rejected (%d)\n", sc->cmnd[0], reason);
1323 spin_lock(host->host_lock);
1324 return SCSI_MLQUEUE_TARGET_BUSY;
1325
1326fault:
1327 spin_unlock(&session->lock);
1328 debug_scsi("iscsi: cmd 0x%x is not queued (%d)\n", sc->cmnd[0], reason);
1329 if (!scsi_bidi_cmnd(sc))
1330 scsi_set_resid(sc, scsi_bufflen(sc));
1331 else {
1332 scsi_out(sc)->resid = scsi_out(sc)->length;
1333 scsi_in(sc)->resid = scsi_in(sc)->length;
1334 }