aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2007-02-09 11:39:40 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-09 12:14:07 -0500
commitb4377356450e2358f5f92d34f130d6cb6574bf76 (patch)
treec5f1d7fb258e115f6b3429942ea1eae944823799 /drivers/scsi/libiscsi.c
parent04d4f7a1143e4fb291cd1584c9ac8de4ba584d34 (diff)
[PATCH] iscsi endianness annotations
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index d37048c96eab..7c75771c77ff 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -113,8 +113,7 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
113 hdr->opcode = ISCSI_OP_SCSI_CMD; 113 hdr->opcode = ISCSI_OP_SCSI_CMD;
114 hdr->flags = ISCSI_ATTR_SIMPLE; 114 hdr->flags = ISCSI_ATTR_SIMPLE;
115 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); 115 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
116 hdr->itt = ctask->itt | (conn->id << ISCSI_CID_SHIFT) | 116 hdr->itt = build_itt(ctask->itt, conn->id, session->age);
117 (session->age << ISCSI_AGE_SHIFT);
118 hdr->data_length = cpu_to_be32(sc->request_bufflen); 117 hdr->data_length = cpu_to_be32(sc->request_bufflen);
119 hdr->cmdsn = cpu_to_be32(session->cmdsn); 118 hdr->cmdsn = cpu_to_be32(session->cmdsn);
120 session->cmdsn++; 119 session->cmdsn++;
@@ -270,7 +269,7 @@ invalid_datalen:
270 goto out; 269 goto out;
271 } 270 }
272 271
273 senselen = be16_to_cpu(*(uint16_t *)data); 272 senselen = be16_to_cpu(*(__be16 *)data);
274 if (datalen < senselen) 273 if (datalen < senselen)
275 goto invalid_datalen; 274 goto invalid_datalen;
276 275
@@ -338,7 +337,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
338 337
339 if (ntoh24(reject->dlength) >= sizeof(struct iscsi_hdr)) { 338 if (ntoh24(reject->dlength) >= sizeof(struct iscsi_hdr)) {
340 memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr)); 339 memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr));
341 itt = rejected_pdu.itt & ISCSI_ITT_MASK; 340 itt = get_itt(rejected_pdu.itt);
342 printk(KERN_ERR "itt 0x%x had pdu (op 0x%x) rejected " 341 printk(KERN_ERR "itt 0x%x had pdu (op 0x%x) rejected "
343 "due to DataDigest error.\n", itt, 342 "due to DataDigest error.\n", itt,
344 rejected_pdu.opcode); 343 rejected_pdu.opcode);
@@ -367,10 +366,10 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
367 struct iscsi_mgmt_task *mtask; 366 struct iscsi_mgmt_task *mtask;
368 uint32_t itt; 367 uint32_t itt;
369 368
370 if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG)) 369 if (hdr->itt != RESERVED_ITT)
371 itt = hdr->itt & ISCSI_ITT_MASK; 370 itt = get_itt(hdr->itt);
372 else 371 else
373 itt = hdr->itt; 372 itt = ~0U;
374 373
375 if (itt < session->cmds_max) { 374 if (itt < session->cmds_max) {
376 ctask = session->cmds[itt]; 375 ctask = session->cmds[itt];
@@ -440,7 +439,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
440 iscsi_tmf_rsp(conn, hdr); 439 iscsi_tmf_rsp(conn, hdr);
441 break; 440 break;
442 case ISCSI_OP_NOOP_IN: 441 case ISCSI_OP_NOOP_IN:
443 if (hdr->ttt != ISCSI_RESERVED_TAG || datalen) { 442 if (hdr->ttt != cpu_to_be32(ISCSI_RESERVED_TAG) || datalen) {
444 rc = ISCSI_ERR_PROTO; 443 rc = ISCSI_ERR_PROTO;
445 break; 444 break;
446 } 445 }
@@ -457,7 +456,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
457 rc = ISCSI_ERR_BAD_OPCODE; 456 rc = ISCSI_ERR_BAD_OPCODE;
458 break; 457 break;
459 } 458 }
460 } else if (itt == ISCSI_RESERVED_TAG) { 459 } else if (itt == ~0U) {
461 rc = iscsi_check_assign_cmdsn(session, 460 rc = iscsi_check_assign_cmdsn(session,
462 (struct iscsi_nopin*)hdr); 461 (struct iscsi_nopin*)hdr);
463 if (rc) 462 if (rc)
@@ -470,7 +469,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
470 break; 469 break;
471 } 470 }
472 471
473 if (hdr->ttt == ISCSI_RESERVED_TAG) 472 if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG))
474 break; 473 break;
475 474
476 if (iscsi_recv_pdu(conn->cls_conn, hdr, NULL, 0)) 475 if (iscsi_recv_pdu(conn->cls_conn, hdr, NULL, 0))
@@ -516,24 +515,24 @@ int iscsi_verify_itt(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
516 struct iscsi_cmd_task *ctask; 515 struct iscsi_cmd_task *ctask;
517 uint32_t itt; 516 uint32_t itt;
518 517
519 if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG)) { 518 if (hdr->itt != RESERVED_ITT) {
520 if ((hdr->itt & ISCSI_AGE_MASK) != 519 if (((__force u32)hdr->itt & ISCSI_AGE_MASK) !=
521 (session->age << ISCSI_AGE_SHIFT)) { 520 (session->age << ISCSI_AGE_SHIFT)) {
522 printk(KERN_ERR "iscsi: received itt %x expected " 521 printk(KERN_ERR "iscsi: received itt %x expected "
523 "session age (%x)\n", hdr->itt, 522 "session age (%x)\n", (__force u32)hdr->itt,
524 session->age & ISCSI_AGE_MASK); 523 session->age & ISCSI_AGE_MASK);
525 return ISCSI_ERR_BAD_ITT; 524 return ISCSI_ERR_BAD_ITT;
526 } 525 }
527 526
528 if ((hdr->itt & ISCSI_CID_MASK) != 527 if (((__force u32)hdr->itt & ISCSI_CID_MASK) !=
529 (conn->id << ISCSI_CID_SHIFT)) { 528 (conn->id << ISCSI_CID_SHIFT)) {
530 printk(KERN_ERR "iscsi: received itt %x, expected " 529 printk(KERN_ERR "iscsi: received itt %x, expected "
531 "CID (%x)\n", hdr->itt, conn->id); 530 "CID (%x)\n", (__force u32)hdr->itt, conn->id);
532 return ISCSI_ERR_BAD_ITT; 531 return ISCSI_ERR_BAD_ITT;
533 } 532 }
534 itt = hdr->itt & ISCSI_ITT_MASK; 533 itt = get_itt(hdr->itt);
535 } else 534 } else
536 itt = hdr->itt; 535 itt = ~0U;
537 536
538 if (itt < session->cmds_max) { 537 if (itt < session->cmds_max) {
539 ctask = session->cmds[itt]; 538 ctask = session->cmds[itt];
@@ -896,9 +895,8 @@ iscsi_conn_send_generic(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
896 /* 895 /*
897 * pre-format CmdSN for outgoing PDU. 896 * pre-format CmdSN for outgoing PDU.
898 */ 897 */
899 if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG)) { 898 if (hdr->itt != RESERVED_ITT) {
900 hdr->itt = mtask->itt | (conn->id << ISCSI_CID_SHIFT) | 899 hdr->itt = build_itt(mtask->itt, conn->id, session->age);
901 (session->age << ISCSI_AGE_SHIFT);
902 nop->cmdsn = cpu_to_be32(session->cmdsn); 900 nop->cmdsn = cpu_to_be32(session->cmdsn);
903 if (conn->c_stage == ISCSI_CONN_STARTED && 901 if (conn->c_stage == ISCSI_CONN_STARTED &&
904 !(hdr->opcode & ISCSI_OP_IMMEDIATE)) 902 !(hdr->opcode & ISCSI_OP_IMMEDIATE))
@@ -1064,7 +1062,7 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
1064 1062
1065 spin_lock_bh(&session->lock); 1063 spin_lock_bh(&session->lock);
1066 ctask->mtask = (struct iscsi_mgmt_task *) 1064 ctask->mtask = (struct iscsi_mgmt_task *)
1067 session->mgmt_cmds[(hdr->itt & ISCSI_ITT_MASK) - 1065 session->mgmt_cmds[get_itt(hdr->itt) -
1068 ISCSI_MGMT_ITT_OFFSET]; 1066 ISCSI_MGMT_ITT_OFFSET];
1069 1067
1070 if (conn->tmabort_state == TMABORT_INITIAL) { 1068 if (conn->tmabort_state == TMABORT_INITIAL) {