aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/iscsi_tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/iscsi_tcp.c')
-rw-r--r--drivers/scsi/iscsi_tcp.c151
1 files changed, 76 insertions, 75 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 57ce2251abc8..4b226b88b68a 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -197,7 +197,7 @@ iscsi_tcp_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
197 if (unlikely(!sc)) 197 if (unlikely(!sc))
198 return; 198 return;
199 199
200 tcp_ctask->xmstate = XMSTATE_VALUE_IDLE; 200 tcp_ctask->xmstate = XMSTATE_IDLE;
201 tcp_ctask->r2t = NULL; 201 tcp_ctask->r2t = NULL;
202} 202}
203 203
@@ -369,8 +369,7 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
369 spin_lock(&session->lock); 369 spin_lock(&session->lock);
370 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); 370 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
371 371
372 if (!ctask->sc || ctask->mtask || 372 if (!ctask->sc || session->state != ISCSI_STATE_LOGGED_IN) {
373 session->state != ISCSI_STATE_LOGGED_IN) {
374 printk(KERN_INFO "iscsi_tcp: dropping R2T itt %d in " 373 printk(KERN_INFO "iscsi_tcp: dropping R2T itt %d in "
375 "recovery...\n", ctask->itt); 374 "recovery...\n", ctask->itt);
376 spin_unlock(&session->lock); 375 spin_unlock(&session->lock);
@@ -409,11 +408,10 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
409 408
410 tcp_ctask->exp_datasn = r2tsn + 1; 409 tcp_ctask->exp_datasn = r2tsn + 1;
411 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*)); 410 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));
412 set_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate); 411 tcp_ctask->xmstate |= XMSTATE_SOL_HDR_INIT;
413 list_move_tail(&ctask->running, &conn->xmitqueue);
414
415 scsi_queue_work(session->host, &conn->xmitwork);
416 conn->r2t_pdus_cnt++; 412 conn->r2t_pdus_cnt++;
413
414 iscsi_requeue_ctask(ctask);
417 spin_unlock(&session->lock); 415 spin_unlock(&session->lock);
418 416
419 return 0; 417 return 0;
@@ -1254,7 +1252,7 @@ static void iscsi_set_padding(struct iscsi_tcp_cmd_task *tcp_ctask,
1254 1252
1255 tcp_ctask->pad_count = ISCSI_PAD_LEN - tcp_ctask->pad_count; 1253 tcp_ctask->pad_count = ISCSI_PAD_LEN - tcp_ctask->pad_count;
1256 debug_scsi("write padding %d bytes\n", tcp_ctask->pad_count); 1254 debug_scsi("write padding %d bytes\n", tcp_ctask->pad_count);
1257 set_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate); 1255 tcp_ctask->xmstate |= XMSTATE_W_PAD;
1258} 1256}
1259 1257
1260/** 1258/**
@@ -1269,7 +1267,7 @@ iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask)
1269 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; 1267 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1270 1268
1271 BUG_ON(__kfifo_len(tcp_ctask->r2tqueue)); 1269 BUG_ON(__kfifo_len(tcp_ctask->r2tqueue));
1272 tcp_ctask->xmstate = 1 << XMSTATE_BIT_CMD_HDR_INIT; 1270 tcp_ctask->xmstate = XMSTATE_CMD_HDR_INIT;
1273} 1271}
1274 1272
1275/** 1273/**
@@ -1283,10 +1281,10 @@ iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask)
1283 * xmit. 1281 * xmit.
1284 * 1282 *
1285 * Management xmit state machine consists of these states: 1283 * Management xmit state machine consists of these states:
1286 * XMSTATE_BIT_IMM_HDR_INIT - calculate digest of PDU Header 1284 * XMSTATE_IMM_HDR_INIT - calculate digest of PDU Header
1287 * XMSTATE_BIT_IMM_HDR - PDU Header xmit in progress 1285 * XMSTATE_IMM_HDR - PDU Header xmit in progress
1288 * XMSTATE_BIT_IMM_DATA - PDU Data xmit in progress 1286 * XMSTATE_IMM_DATA - PDU Data xmit in progress
1289 * XMSTATE_VALUE_IDLE - management PDU is done 1287 * XMSTATE_IDLE - management PDU is done
1290 **/ 1288 **/
1291static int 1289static int
1292iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask) 1290iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
@@ -1297,12 +1295,12 @@ iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
1297 debug_scsi("mtask deq [cid %d state %x itt 0x%x]\n", 1295 debug_scsi("mtask deq [cid %d state %x itt 0x%x]\n",
1298 conn->id, tcp_mtask->xmstate, mtask->itt); 1296 conn->id, tcp_mtask->xmstate, mtask->itt);
1299 1297
1300 if (test_bit(XMSTATE_BIT_IMM_HDR_INIT, &tcp_mtask->xmstate)) { 1298 if (tcp_mtask->xmstate & XMSTATE_IMM_HDR_INIT) {
1301 iscsi_buf_init_iov(&tcp_mtask->headbuf, (char*)mtask->hdr, 1299 iscsi_buf_init_iov(&tcp_mtask->headbuf, (char*)mtask->hdr,
1302 sizeof(struct iscsi_hdr)); 1300 sizeof(struct iscsi_hdr));
1303 1301
1304 if (mtask->data_count) { 1302 if (mtask->data_count) {
1305 set_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate); 1303 tcp_mtask->xmstate |= XMSTATE_IMM_DATA;
1306 iscsi_buf_init_iov(&tcp_mtask->sendbuf, 1304 iscsi_buf_init_iov(&tcp_mtask->sendbuf,
1307 (char*)mtask->data, 1305 (char*)mtask->data,
1308 mtask->data_count); 1306 mtask->data_count);
@@ -1315,20 +1313,21 @@ iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
1315 (u8*)tcp_mtask->hdrext); 1313 (u8*)tcp_mtask->hdrext);
1316 1314
1317 tcp_mtask->sent = 0; 1315 tcp_mtask->sent = 0;
1318 clear_bit(XMSTATE_BIT_IMM_HDR_INIT, &tcp_mtask->xmstate); 1316 tcp_mtask->xmstate &= ~XMSTATE_IMM_HDR_INIT;
1319 set_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate); 1317 tcp_mtask->xmstate |= XMSTATE_IMM_HDR;
1320 } 1318 }
1321 1319
1322 if (test_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate)) { 1320 if (tcp_mtask->xmstate & XMSTATE_IMM_HDR) {
1323 rc = iscsi_sendhdr(conn, &tcp_mtask->headbuf, 1321 rc = iscsi_sendhdr(conn, &tcp_mtask->headbuf,
1324 mtask->data_count); 1322 mtask->data_count);
1325 if (rc) 1323 if (rc)
1326 return rc; 1324 return rc;
1327 clear_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate); 1325 tcp_mtask->xmstate &= ~XMSTATE_IMM_HDR;
1328 } 1326 }
1329 1327
1330 if (test_and_clear_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate)) { 1328 if (tcp_mtask->xmstate & XMSTATE_IMM_DATA) {
1331 BUG_ON(!mtask->data_count); 1329 BUG_ON(!mtask->data_count);
1330 tcp_mtask->xmstate &= ~XMSTATE_IMM_DATA;
1332 /* FIXME: implement. 1331 /* FIXME: implement.
1333 * Virtual buffer could be spreaded across multiple pages... 1332 * Virtual buffer could be spreaded across multiple pages...
1334 */ 1333 */
@@ -1338,13 +1337,13 @@ iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
1338 rc = iscsi_sendpage(conn, &tcp_mtask->sendbuf, 1337 rc = iscsi_sendpage(conn, &tcp_mtask->sendbuf,
1339 &mtask->data_count, &tcp_mtask->sent); 1338 &mtask->data_count, &tcp_mtask->sent);
1340 if (rc) { 1339 if (rc) {
1341 set_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate); 1340 tcp_mtask->xmstate |= XMSTATE_IMM_DATA;
1342 return rc; 1341 return rc;
1343 } 1342 }
1344 } while (mtask->data_count); 1343 } while (mtask->data_count);
1345 } 1344 }
1346 1345
1347 BUG_ON(tcp_mtask->xmstate != XMSTATE_VALUE_IDLE); 1346 BUG_ON(tcp_mtask->xmstate != XMSTATE_IDLE);
1348 if (mtask->hdr->itt == RESERVED_ITT) { 1347 if (mtask->hdr->itt == RESERVED_ITT) {
1349 struct iscsi_session *session = conn->session; 1348 struct iscsi_session *session = conn->session;
1350 1349
@@ -1364,7 +1363,7 @@ iscsi_send_cmd_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1364 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; 1363 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1365 int rc = 0; 1364 int rc = 0;
1366 1365
1367 if (test_bit(XMSTATE_BIT_CMD_HDR_INIT, &tcp_ctask->xmstate)) { 1366 if (tcp_ctask->xmstate & XMSTATE_CMD_HDR_INIT) {
1368 tcp_ctask->sent = 0; 1367 tcp_ctask->sent = 0;
1369 tcp_ctask->sg_count = 0; 1368 tcp_ctask->sg_count = 0;
1370 tcp_ctask->exp_datasn = 0; 1369 tcp_ctask->exp_datasn = 0;
@@ -1389,21 +1388,21 @@ iscsi_send_cmd_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1389 if (conn->hdrdgst_en) 1388 if (conn->hdrdgst_en)
1390 iscsi_hdr_digest(conn, &tcp_ctask->headbuf, 1389 iscsi_hdr_digest(conn, &tcp_ctask->headbuf,
1391 (u8*)tcp_ctask->hdrext); 1390 (u8*)tcp_ctask->hdrext);
1392 clear_bit(XMSTATE_BIT_CMD_HDR_INIT, &tcp_ctask->xmstate); 1391 tcp_ctask->xmstate &= ~XMSTATE_CMD_HDR_INIT;
1393 set_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate); 1392 tcp_ctask->xmstate |= XMSTATE_CMD_HDR_XMIT;
1394 } 1393 }
1395 1394
1396 if (test_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate)) { 1395 if (tcp_ctask->xmstate & XMSTATE_CMD_HDR_XMIT) {
1397 rc = iscsi_sendhdr(conn, &tcp_ctask->headbuf, ctask->imm_count); 1396 rc = iscsi_sendhdr(conn, &tcp_ctask->headbuf, ctask->imm_count);
1398 if (rc) 1397 if (rc)
1399 return rc; 1398 return rc;
1400 clear_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate); 1399 tcp_ctask->xmstate &= ~XMSTATE_CMD_HDR_XMIT;
1401 1400
1402 if (sc->sc_data_direction != DMA_TO_DEVICE) 1401 if (sc->sc_data_direction != DMA_TO_DEVICE)
1403 return 0; 1402 return 0;
1404 1403
1405 if (ctask->imm_count) { 1404 if (ctask->imm_count) {
1406 set_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate); 1405 tcp_ctask->xmstate |= XMSTATE_IMM_DATA;
1407 iscsi_set_padding(tcp_ctask, ctask->imm_count); 1406 iscsi_set_padding(tcp_ctask, ctask->imm_count);
1408 1407
1409 if (ctask->conn->datadgst_en) { 1408 if (ctask->conn->datadgst_en) {
@@ -1413,10 +1412,9 @@ iscsi_send_cmd_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1413 } 1412 }
1414 } 1413 }
1415 1414
1416 if (ctask->unsol_count) { 1415 if (ctask->unsol_count)
1417 set_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate); 1416 tcp_ctask->xmstate |=
1418 set_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate); 1417 XMSTATE_UNS_HDR | XMSTATE_UNS_INIT;
1419 }
1420 } 1418 }
1421 return rc; 1419 return rc;
1422} 1420}
@@ -1428,25 +1426,25 @@ iscsi_send_padding(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1428 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 1426 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1429 int sent = 0, rc; 1427 int sent = 0, rc;
1430 1428
1431 if (test_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate)) { 1429 if (tcp_ctask->xmstate & XMSTATE_W_PAD) {
1432 iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad, 1430 iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad,
1433 tcp_ctask->pad_count); 1431 tcp_ctask->pad_count);
1434 if (conn->datadgst_en) 1432 if (conn->datadgst_en)
1435 crypto_hash_update(&tcp_conn->tx_hash, 1433 crypto_hash_update(&tcp_conn->tx_hash,
1436 &tcp_ctask->sendbuf.sg, 1434 &tcp_ctask->sendbuf.sg,
1437 tcp_ctask->sendbuf.sg.length); 1435 tcp_ctask->sendbuf.sg.length);
1438 } else if (!test_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate)) 1436 } else if (!(tcp_ctask->xmstate & XMSTATE_W_RESEND_PAD))
1439 return 0; 1437 return 0;
1440 1438
1441 clear_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate); 1439 tcp_ctask->xmstate &= ~XMSTATE_W_PAD;
1442 clear_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate); 1440 tcp_ctask->xmstate &= ~XMSTATE_W_RESEND_PAD;
1443 debug_scsi("sending %d pad bytes for itt 0x%x\n", 1441 debug_scsi("sending %d pad bytes for itt 0x%x\n",
1444 tcp_ctask->pad_count, ctask->itt); 1442 tcp_ctask->pad_count, ctask->itt);
1445 rc = iscsi_sendpage(conn, &tcp_ctask->sendbuf, &tcp_ctask->pad_count, 1443 rc = iscsi_sendpage(conn, &tcp_ctask->sendbuf, &tcp_ctask->pad_count,
1446 &sent); 1444 &sent);
1447 if (rc) { 1445 if (rc) {
1448 debug_scsi("padding send failed %d\n", rc); 1446 debug_scsi("padding send failed %d\n", rc);
1449 set_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate); 1447 tcp_ctask->xmstate |= XMSTATE_W_RESEND_PAD;
1450 } 1448 }
1451 return rc; 1449 return rc;
1452} 1450}
@@ -1465,11 +1463,11 @@ iscsi_send_digest(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1465 tcp_ctask = ctask->dd_data; 1463 tcp_ctask = ctask->dd_data;
1466 tcp_conn = conn->dd_data; 1464 tcp_conn = conn->dd_data;
1467 1465
1468 if (!test_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate)) { 1466 if (!(tcp_ctask->xmstate & XMSTATE_W_RESEND_DATA_DIGEST)) {
1469 crypto_hash_final(&tcp_conn->tx_hash, (u8*)digest); 1467 crypto_hash_final(&tcp_conn->tx_hash, (u8*)digest);
1470 iscsi_buf_init_iov(buf, (char*)digest, 4); 1468 iscsi_buf_init_iov(buf, (char*)digest, 4);
1471 } 1469 }
1472 clear_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate); 1470 tcp_ctask->xmstate &= ~XMSTATE_W_RESEND_DATA_DIGEST;
1473 1471
1474 rc = iscsi_sendpage(conn, buf, &tcp_ctask->digest_count, &sent); 1472 rc = iscsi_sendpage(conn, buf, &tcp_ctask->digest_count, &sent);
1475 if (!rc) 1473 if (!rc)
@@ -1478,7 +1476,7 @@ iscsi_send_digest(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1478 else { 1476 else {
1479 debug_scsi("sending digest 0x%x failed for itt 0x%x!\n", 1477 debug_scsi("sending digest 0x%x failed for itt 0x%x!\n",
1480 *digest, ctask->itt); 1478 *digest, ctask->itt);
1481 set_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate); 1479 tcp_ctask->xmstate |= XMSTATE_W_RESEND_DATA_DIGEST;
1482 } 1480 }
1483 return rc; 1481 return rc;
1484} 1482}
@@ -1526,8 +1524,8 @@ iscsi_send_unsol_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1526 struct iscsi_data_task *dtask; 1524 struct iscsi_data_task *dtask;
1527 int rc; 1525 int rc;
1528 1526
1529 set_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate); 1527 tcp_ctask->xmstate |= XMSTATE_UNS_DATA;
1530 if (test_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate)) { 1528 if (tcp_ctask->xmstate & XMSTATE_UNS_INIT) {
1531 dtask = &tcp_ctask->unsol_dtask; 1529 dtask = &tcp_ctask->unsol_dtask;
1532 1530
1533 iscsi_prep_unsolicit_data_pdu(ctask, &dtask->hdr); 1531 iscsi_prep_unsolicit_data_pdu(ctask, &dtask->hdr);
@@ -1537,14 +1535,14 @@ iscsi_send_unsol_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1537 iscsi_hdr_digest(conn, &tcp_ctask->headbuf, 1535 iscsi_hdr_digest(conn, &tcp_ctask->headbuf,
1538 (u8*)dtask->hdrext); 1536 (u8*)dtask->hdrext);
1539 1537
1540 clear_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate); 1538 tcp_ctask->xmstate &= ~XMSTATE_UNS_INIT;
1541 iscsi_set_padding(tcp_ctask, ctask->data_count); 1539 iscsi_set_padding(tcp_ctask, ctask->data_count);
1542 } 1540 }
1543 1541
1544 rc = iscsi_sendhdr(conn, &tcp_ctask->headbuf, ctask->data_count); 1542 rc = iscsi_sendhdr(conn, &tcp_ctask->headbuf, ctask->data_count);
1545 if (rc) { 1543 if (rc) {
1546 clear_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate); 1544 tcp_ctask->xmstate &= ~XMSTATE_UNS_DATA;
1547 set_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate); 1545 tcp_ctask->xmstate |= XMSTATE_UNS_HDR;
1548 return rc; 1546 return rc;
1549 } 1547 }
1550 1548
@@ -1565,15 +1563,16 @@ iscsi_send_unsol_pdu(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1565 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; 1563 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1566 int rc; 1564 int rc;
1567 1565
1568 if (test_and_clear_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate)) { 1566 if (tcp_ctask->xmstate & XMSTATE_UNS_HDR) {
1569 BUG_ON(!ctask->unsol_count); 1567 BUG_ON(!ctask->unsol_count);
1568 tcp_ctask->xmstate &= ~XMSTATE_UNS_HDR;
1570send_hdr: 1569send_hdr:
1571 rc = iscsi_send_unsol_hdr(conn, ctask); 1570 rc = iscsi_send_unsol_hdr(conn, ctask);
1572 if (rc) 1571 if (rc)
1573 return rc; 1572 return rc;
1574 } 1573 }
1575 1574
1576 if (test_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate)) { 1575 if (tcp_ctask->xmstate & XMSTATE_UNS_DATA) {
1577 struct iscsi_data_task *dtask = &tcp_ctask->unsol_dtask; 1576 struct iscsi_data_task *dtask = &tcp_ctask->unsol_dtask;
1578 int start = tcp_ctask->sent; 1577 int start = tcp_ctask->sent;
1579 1578
@@ -1583,14 +1582,14 @@ send_hdr:
1583 ctask->unsol_count -= tcp_ctask->sent - start; 1582 ctask->unsol_count -= tcp_ctask->sent - start;
1584 if (rc) 1583 if (rc)
1585 return rc; 1584 return rc;
1586 clear_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate); 1585 tcp_ctask->xmstate &= ~XMSTATE_UNS_DATA;
1587 /* 1586 /*
1588 * Done with the Data-Out. Next, check if we need 1587 * Done with the Data-Out. Next, check if we need
1589 * to send another unsolicited Data-Out. 1588 * to send another unsolicited Data-Out.
1590 */ 1589 */
1591 if (ctask->unsol_count) { 1590 if (ctask->unsol_count) {
1592 debug_scsi("sending more uns\n"); 1591 debug_scsi("sending more uns\n");
1593 set_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate); 1592 tcp_ctask->xmstate |= XMSTATE_UNS_INIT;
1594 goto send_hdr; 1593 goto send_hdr;
1595 } 1594 }
1596 } 1595 }
@@ -1606,7 +1605,7 @@ static int iscsi_send_sol_pdu(struct iscsi_conn *conn,
1606 struct iscsi_data_task *dtask; 1605 struct iscsi_data_task *dtask;
1607 int left, rc; 1606 int left, rc;
1608 1607
1609 if (test_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate)) { 1608 if (tcp_ctask->xmstate & XMSTATE_SOL_HDR_INIT) {
1610 if (!tcp_ctask->r2t) { 1609 if (!tcp_ctask->r2t) {
1611 spin_lock_bh(&session->lock); 1610 spin_lock_bh(&session->lock);
1612 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t, 1611 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t,
@@ -1620,19 +1619,19 @@ send_hdr:
1620 if (conn->hdrdgst_en) 1619 if (conn->hdrdgst_en)
1621 iscsi_hdr_digest(conn, &r2t->headbuf, 1620 iscsi_hdr_digest(conn, &r2t->headbuf,
1622 (u8*)dtask->hdrext); 1621 (u8*)dtask->hdrext);
1623 clear_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate); 1622 tcp_ctask->xmstate &= ~XMSTATE_SOL_HDR_INIT;
1624 set_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate); 1623 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;
1625 } 1624 }
1626 1625
1627 if (test_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate)) { 1626 if (tcp_ctask->xmstate & XMSTATE_SOL_HDR) {
1628 r2t = tcp_ctask->r2t; 1627 r2t = tcp_ctask->r2t;
1629 dtask = &r2t->dtask; 1628 dtask = &r2t->dtask;
1630 1629
1631 rc = iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count); 1630 rc = iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count);
1632 if (rc) 1631 if (rc)
1633 return rc; 1632 return rc;
1634 clear_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate); 1633 tcp_ctask->xmstate &= ~XMSTATE_SOL_HDR;
1635 set_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate); 1634 tcp_ctask->xmstate |= XMSTATE_SOL_DATA;
1636 1635
1637 if (conn->datadgst_en) { 1636 if (conn->datadgst_en) {
1638 iscsi_data_digest_init(conn->dd_data, tcp_ctask); 1637 iscsi_data_digest_init(conn->dd_data, tcp_ctask);
@@ -1645,7 +1644,7 @@ send_hdr:
1645 r2t->sent); 1644 r2t->sent);
1646 } 1645 }
1647 1646
1648 if (test_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate)) { 1647 if (tcp_ctask->xmstate & XMSTATE_SOL_DATA) {
1649 r2t = tcp_ctask->r2t; 1648 r2t = tcp_ctask->r2t;
1650 dtask = &r2t->dtask; 1649 dtask = &r2t->dtask;
1651 1650
@@ -1654,7 +1653,7 @@ send_hdr:
1654 &dtask->digestbuf, &dtask->digest); 1653 &dtask->digestbuf, &dtask->digest);
1655 if (rc) 1654 if (rc)
1656 return rc; 1655 return rc;
1657 clear_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate); 1656 tcp_ctask->xmstate &= ~XMSTATE_SOL_DATA;
1658 1657
1659 /* 1658 /*
1660 * Done with this Data-Out. Next, check if we have 1659 * Done with this Data-Out. Next, check if we have
@@ -1699,32 +1698,32 @@ send_hdr:
1699 * xmit stages. 1698 * xmit stages.
1700 * 1699 *
1701 *iscsi_send_cmd_hdr() 1700 *iscsi_send_cmd_hdr()
1702 * XMSTATE_BIT_CMD_HDR_INIT - prepare Header and Data buffers Calculate 1701 * XMSTATE_CMD_HDR_INIT - prepare Header and Data buffers Calculate
1703 * Header Digest 1702 * Header Digest
1704 * XMSTATE_BIT_CMD_HDR_XMIT - Transmit header in progress 1703 * XMSTATE_CMD_HDR_XMIT - Transmit header in progress
1705 * 1704 *
1706 *iscsi_send_padding 1705 *iscsi_send_padding
1707 * XMSTATE_BIT_W_PAD - Prepare and send pading 1706 * XMSTATE_W_PAD - Prepare and send pading
1708 * XMSTATE_BIT_W_RESEND_PAD - retry send pading 1707 * XMSTATE_W_RESEND_PAD - retry send pading
1709 * 1708 *
1710 *iscsi_send_digest 1709 *iscsi_send_digest
1711 * XMSTATE_BIT_W_RESEND_DATA_DIGEST - Finalize and send Data Digest 1710 * XMSTATE_W_RESEND_DATA_DIGEST - Finalize and send Data Digest
1712 * XMSTATE_BIT_W_RESEND_DATA_DIGEST - retry sending digest 1711 * XMSTATE_W_RESEND_DATA_DIGEST - retry sending digest
1713 * 1712 *
1714 *iscsi_send_unsol_hdr 1713 *iscsi_send_unsol_hdr
1715 * XMSTATE_BIT_UNS_INIT - prepare un-solicit data header and digest 1714 * XMSTATE_UNS_INIT - prepare un-solicit data header and digest
1716 * XMSTATE_BIT_UNS_HDR - send un-solicit header 1715 * XMSTATE_UNS_HDR - send un-solicit header
1717 * 1716 *
1718 *iscsi_send_unsol_pdu 1717 *iscsi_send_unsol_pdu
1719 * XMSTATE_BIT_UNS_DATA - send un-solicit data in progress 1718 * XMSTATE_UNS_DATA - send un-solicit data in progress
1720 * 1719 *
1721 *iscsi_send_sol_pdu 1720 *iscsi_send_sol_pdu
1722 * XMSTATE_BIT_SOL_HDR_INIT - solicit data header and digest initialize 1721 * XMSTATE_SOL_HDR_INIT - solicit data header and digest initialize
1723 * XMSTATE_BIT_SOL_HDR - send solicit header 1722 * XMSTATE_SOL_HDR - send solicit header
1724 * XMSTATE_BIT_SOL_DATA - send solicit data 1723 * XMSTATE_SOL_DATA - send solicit data
1725 * 1724 *
1726 *iscsi_tcp_ctask_xmit 1725 *iscsi_tcp_ctask_xmit
1727 * XMSTATE_BIT_IMM_DATA - xmit managment data (??) 1726 * XMSTATE_IMM_DATA - xmit managment data (??)
1728 **/ 1727 **/
1729static int 1728static int
1730iscsi_tcp_ctask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) 1729iscsi_tcp_ctask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
@@ -1741,13 +1740,13 @@ iscsi_tcp_ctask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1741 if (ctask->sc->sc_data_direction != DMA_TO_DEVICE) 1740 if (ctask->sc->sc_data_direction != DMA_TO_DEVICE)
1742 return 0; 1741 return 0;
1743 1742
1744 if (test_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate)) { 1743 if (tcp_ctask->xmstate & XMSTATE_IMM_DATA) {
1745 rc = iscsi_send_data(ctask, &tcp_ctask->sendbuf, &tcp_ctask->sg, 1744 rc = iscsi_send_data(ctask, &tcp_ctask->sendbuf, &tcp_ctask->sg,
1746 &tcp_ctask->sent, &ctask->imm_count, 1745 &tcp_ctask->sent, &ctask->imm_count,
1747 &tcp_ctask->immbuf, &tcp_ctask->immdigest); 1746 &tcp_ctask->immbuf, &tcp_ctask->immdigest);
1748 if (rc) 1747 if (rc)
1749 return rc; 1748 return rc;
1750 clear_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate); 1749 tcp_ctask->xmstate &= ~XMSTATE_IMM_DATA;
1751 } 1750 }
1752 1751
1753 rc = iscsi_send_unsol_pdu(conn, ctask); 1752 rc = iscsi_send_unsol_pdu(conn, ctask);
@@ -1980,7 +1979,7 @@ static void
1980iscsi_tcp_mgmt_init(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask) 1979iscsi_tcp_mgmt_init(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
1981{ 1980{
1982 struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data; 1981 struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data;
1983 tcp_mtask->xmstate = 1 << XMSTATE_BIT_IMM_HDR_INIT; 1982 tcp_mtask->xmstate = XMSTATE_IMM_HDR_INIT;
1984} 1983}
1985 1984
1986static int 1985static int
@@ -2226,6 +2225,7 @@ static struct scsi_host_template iscsi_sht = {
2226 .max_sectors = 0xFFFF, 2225 .max_sectors = 0xFFFF,
2227 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, 2226 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN,
2228 .eh_abort_handler = iscsi_eh_abort, 2227 .eh_abort_handler = iscsi_eh_abort,
2228 .eh_device_reset_handler= iscsi_eh_device_reset,
2229 .eh_host_reset_handler = iscsi_eh_host_reset, 2229 .eh_host_reset_handler = iscsi_eh_host_reset,
2230 .use_clustering = DISABLE_CLUSTERING, 2230 .use_clustering = DISABLE_CLUSTERING,
2231 .slave_configure = iscsi_tcp_slave_configure, 2231 .slave_configure = iscsi_tcp_slave_configure,
@@ -2257,7 +2257,8 @@ static struct iscsi_transport iscsi_tcp_transport = {
2257 ISCSI_PERSISTENT_ADDRESS | 2257 ISCSI_PERSISTENT_ADDRESS |
2258 ISCSI_TARGET_NAME | ISCSI_TPGT | 2258 ISCSI_TARGET_NAME | ISCSI_TPGT |
2259 ISCSI_USERNAME | ISCSI_PASSWORD | 2259 ISCSI_USERNAME | ISCSI_PASSWORD |
2260 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN, 2260 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN |
2261 ISCSI_FAST_ABORT,
2261 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS | 2262 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
2262 ISCSI_HOST_INITIATOR_NAME | 2263 ISCSI_HOST_INITIATOR_NAME |
2263 ISCSI_HOST_NETDEV_NAME, 2264 ISCSI_HOST_NETDEV_NAME,