aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2011-06-16 18:57:09 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-07-25 03:47:59 -0400
commit55bdabdf41b6ee99e22e9d78a895b001fb1d852e (patch)
treea66c6d6480a2bddc7cbd534be6411cdda27a4898
parent123521830c0ea35055b900d2ff0b73bb129e08cb (diff)
iscsi: Use struct scsi_lun in iscsi structs instead of u8[8]
struct scsi_lun is also just a struct with an array of 8 octets (64 bits) but using it instead in iscsi structs lets us call scsilun_to_int without a cast, and also lets us copy it using assignment, instead of memcpy(). Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/be2iscsi/be_main.c5
-rw-r--r--drivers/scsi/bnx2i/bnx2i_hwi.c8
-rw-r--r--drivers/scsi/libiscsi.c14
-rw-r--r--include/scsi/iscsi_proto.h18
-rw-r--r--include/scsi/libiscsi.h2
5 files changed, 23 insertions, 24 deletions
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 94b9a07845d5..7b967ed48962 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3963,11 +3963,10 @@ static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg,
3963 } 3963 }
3964 memcpy(&io_task->cmd_bhs->iscsi_data_pdu. 3964 memcpy(&io_task->cmd_bhs->iscsi_data_pdu.
3965 dw[offsetof(struct amap_pdu_data_out, lun) / 32], 3965 dw[offsetof(struct amap_pdu_data_out, lun) / 32],
3966 io_task->cmd_bhs->iscsi_hdr.lun, sizeof(struct scsi_lun)); 3966 &io_task->cmd_bhs->iscsi_hdr.lun, sizeof(struct scsi_lun));
3967 3967
3968 AMAP_SET_BITS(struct amap_iscsi_wrb, lun, pwrb, 3968 AMAP_SET_BITS(struct amap_iscsi_wrb, lun, pwrb,
3969 cpu_to_be16((unsigned short)io_task->cmd_bhs->iscsi_hdr. 3969 cpu_to_be16(*(unsigned short *)&io_task->cmd_bhs->iscsi_hdr.lun));
3970 lun[0]));
3971 AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, xferlen); 3970 AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, xferlen);
3972 AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb, 3971 AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb,
3973 io_task->pwrb_handle->wrb_index); 3972 io_task->pwrb_handle->wrb_index);
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 1b160e12afa3..2b119cc3eac5 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -430,7 +430,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
430 default: 430 default:
431 tmfabort_wqe->ref_itt = RESERVED_ITT; 431 tmfabort_wqe->ref_itt = RESERVED_ITT;
432 } 432 }
433 memcpy(scsi_lun, tmfabort_hdr->lun, sizeof(struct scsi_lun)); 433 memcpy(scsi_lun, &tmfabort_hdr->lun, sizeof(struct scsi_lun));
434 tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]); 434 tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
435 tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]); 435 tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
436 436
@@ -547,7 +547,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
547 547
548 nopout_wqe->op_code = nopout_hdr->opcode; 548 nopout_wqe->op_code = nopout_hdr->opcode;
549 nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL; 549 nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
550 memcpy(nopout_wqe->lun, nopout_hdr->lun, 8); 550 memcpy(nopout_wqe->lun, &nopout_hdr->lun, 8);
551 551
552 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { 552 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
553 u32 tmp = nopout_wqe->lun[0]; 553 u32 tmp = nopout_wqe->lun[0];
@@ -1711,7 +1711,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
1711 hdr->flags = ISCSI_FLAG_CMD_FINAL; 1711 hdr->flags = ISCSI_FLAG_CMD_FINAL;
1712 hdr->itt = task->hdr->itt; 1712 hdr->itt = task->hdr->itt;
1713 hdr->ttt = cpu_to_be32(nop_in->ttt); 1713 hdr->ttt = cpu_to_be32(nop_in->ttt);
1714 memcpy(hdr->lun, nop_in->lun, 8); 1714 memcpy(&hdr->lun, nop_in->lun, 8);
1715 } 1715 }
1716done: 1716done:
1717 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); 1717 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0);
@@ -1754,7 +1754,7 @@ static void bnx2i_process_async_mesg(struct iscsi_session *session,
1754 resp_hdr->opcode = async_cqe->op_code; 1754 resp_hdr->opcode = async_cqe->op_code;
1755 resp_hdr->flags = 0x80; 1755 resp_hdr->flags = 0x80;
1756 1756
1757 memcpy(resp_hdr->lun, async_cqe->lun, 8); 1757 memcpy(&resp_hdr->lun, async_cqe->lun, 8);
1758 resp_hdr->exp_cmdsn = cpu_to_be32(async_cqe->exp_cmd_sn); 1758 resp_hdr->exp_cmdsn = cpu_to_be32(async_cqe->exp_cmd_sn);
1759 resp_hdr->max_cmdsn = cpu_to_be32(async_cqe->max_cmd_sn); 1759 resp_hdr->max_cmdsn = cpu_to_be32(async_cqe->max_cmd_sn);
1760 1760
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c552cd7850ac..57175a7d2ef0 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -169,7 +169,7 @@ void iscsi_prep_data_out_pdu(struct iscsi_task *task, struct iscsi_r2t_info *r2t
169 hdr->datasn = cpu_to_be32(r2t->datasn); 169 hdr->datasn = cpu_to_be32(r2t->datasn);
170 r2t->datasn++; 170 r2t->datasn++;
171 hdr->opcode = ISCSI_OP_SCSI_DATA_OUT; 171 hdr->opcode = ISCSI_OP_SCSI_DATA_OUT;
172 memcpy(hdr->lun, task->lun, sizeof(hdr->lun)); 172 hdr->lun = task->lun;
173 hdr->itt = task->hdr_itt; 173 hdr->itt = task->hdr_itt;
174 hdr->exp_statsn = r2t->exp_statsn; 174 hdr->exp_statsn = r2t->exp_statsn;
175 hdr->offset = cpu_to_be32(r2t->data_offset + r2t->sent); 175 hdr->offset = cpu_to_be32(r2t->data_offset + r2t->sent);
@@ -296,7 +296,7 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
296 /* 296 /*
297 * Allow PDUs for unrelated LUNs 297 * Allow PDUs for unrelated LUNs
298 */ 298 */
299 hdr_lun = scsilun_to_int((struct scsi_lun *)tmf->lun); 299 hdr_lun = scsilun_to_int(&tmf->lun);
300 if (hdr_lun != task->sc->device->lun) 300 if (hdr_lun != task->sc->device->lun)
301 return 0; 301 return 0;
302 /* fall through */ 302 /* fall through */
@@ -389,8 +389,8 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
389 return rc; 389 return rc;
390 hdr->opcode = ISCSI_OP_SCSI_CMD; 390 hdr->opcode = ISCSI_OP_SCSI_CMD;
391 hdr->flags = ISCSI_ATTR_SIMPLE; 391 hdr->flags = ISCSI_ATTR_SIMPLE;
392 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); 392 int_to_scsilun(sc->device->lun, &hdr->lun);
393 memcpy(task->lun, hdr->lun, sizeof(task->lun)); 393 task->lun = hdr->lun;
394 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn); 394 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
395 cmd_len = sc->cmd_len; 395 cmd_len = sc->cmd_len;
396 if (cmd_len < ISCSI_CDB_SIZE) 396 if (cmd_len < ISCSI_CDB_SIZE)
@@ -968,7 +968,7 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
968 hdr.flags = ISCSI_FLAG_CMD_FINAL; 968 hdr.flags = ISCSI_FLAG_CMD_FINAL;
969 969
970 if (rhdr) { 970 if (rhdr) {
971 memcpy(hdr.lun, rhdr->lun, 8); 971 hdr.lun = rhdr->lun;
972 hdr.ttt = rhdr->ttt; 972 hdr.ttt = rhdr->ttt;
973 hdr.itt = RESERVED_ITT; 973 hdr.itt = RESERVED_ITT;
974 } else 974 } else
@@ -2092,7 +2092,7 @@ static void iscsi_prep_abort_task_pdu(struct iscsi_task *task,
2092 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE; 2092 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
2093 hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK; 2093 hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK;
2094 hdr->flags |= ISCSI_FLAG_CMD_FINAL; 2094 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
2095 memcpy(hdr->lun, task->lun, sizeof(hdr->lun)); 2095 hdr->lun = task->lun;
2096 hdr->rtt = task->hdr_itt; 2096 hdr->rtt = task->hdr_itt;
2097 hdr->refcmdsn = task->cmdsn; 2097 hdr->refcmdsn = task->cmdsn;
2098} 2098}
@@ -2233,7 +2233,7 @@ static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
2233 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE; 2233 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
2234 hdr->flags = ISCSI_TM_FUNC_LOGICAL_UNIT_RESET & ISCSI_FLAG_TM_FUNC_MASK; 2234 hdr->flags = ISCSI_TM_FUNC_LOGICAL_UNIT_RESET & ISCSI_FLAG_TM_FUNC_MASK;
2235 hdr->flags |= ISCSI_FLAG_CMD_FINAL; 2235 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
2236 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); 2236 int_to_scsilun(sc->device->lun, &hdr->lun);
2237 hdr->rtt = RESERVED_ITT; 2237 hdr->rtt = RESERVED_ITT;
2238} 2238}
2239 2239
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index a9c9058ffc60..f5f83534fc13 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -60,7 +60,7 @@ struct iscsi_hdr {
60 uint8_t rsvd2[2]; 60 uint8_t rsvd2[2];
61 uint8_t hlength; /* AHSs total length */ 61 uint8_t hlength; /* AHSs total length */
62 uint8_t dlength[3]; /* Data length */ 62 uint8_t dlength[3]; /* Data length */
63 uint8_t lun[8]; 63 struct scsi_lun lun;
64 itt_t itt; /* Initiator Task Tag, opaque for target */ 64 itt_t itt; /* Initiator Task Tag, opaque for target */
65 __be32 ttt; /* Target Task Tag */ 65 __be32 ttt; /* Target Task Tag */
66 __be32 statsn; 66 __be32 statsn;
@@ -122,7 +122,7 @@ struct iscsi_scsi_req {
122 __be16 rsvd2; 122 __be16 rsvd2;
123 uint8_t hlength; 123 uint8_t hlength;
124 uint8_t dlength[3]; 124 uint8_t dlength[3];
125 uint8_t lun[8]; 125 struct scsi_lun lun;
126 itt_t itt; /* Initiator Task Tag */ 126 itt_t itt; /* Initiator Task Tag */
127 __be32 data_length; 127 __be32 data_length;
128 __be32 cmdsn; 128 __be32 cmdsn;
@@ -198,7 +198,7 @@ struct iscsi_async {
198 uint8_t rsvd2[2]; 198 uint8_t rsvd2[2];
199 uint8_t rsvd3; 199 uint8_t rsvd3;
200 uint8_t dlength[3]; 200 uint8_t dlength[3];
201 uint8_t lun[8]; 201 struct scsi_lun lun;
202 uint8_t rsvd4[8]; 202 uint8_t rsvd4[8];
203 __be32 statsn; 203 __be32 statsn;
204 __be32 exp_cmdsn; 204 __be32 exp_cmdsn;
@@ -226,7 +226,7 @@ struct iscsi_nopout {
226 __be16 rsvd2; 226 __be16 rsvd2;
227 uint8_t rsvd3; 227 uint8_t rsvd3;
228 uint8_t dlength[3]; 228 uint8_t dlength[3];
229 uint8_t lun[8]; 229 struct scsi_lun lun;
230 itt_t itt; /* Initiator Task Tag */ 230 itt_t itt; /* Initiator Task Tag */
231 __be32 ttt; /* Target Transfer Tag */ 231 __be32 ttt; /* Target Transfer Tag */
232 __be32 cmdsn; 232 __be32 cmdsn;
@@ -241,7 +241,7 @@ struct iscsi_nopin {
241 __be16 rsvd2; 241 __be16 rsvd2;
242 uint8_t rsvd3; 242 uint8_t rsvd3;
243 uint8_t dlength[3]; 243 uint8_t dlength[3];
244 uint8_t lun[8]; 244 struct scsi_lun lun;
245 itt_t itt; /* Initiator Task Tag */ 245 itt_t itt; /* Initiator Task Tag */
246 __be32 ttt; /* Target Transfer Tag */ 246 __be32 ttt; /* Target Transfer Tag */
247 __be32 statsn; 247 __be32 statsn;
@@ -257,7 +257,7 @@ struct iscsi_tm {
257 uint8_t rsvd1[2]; 257 uint8_t rsvd1[2];
258 uint8_t hlength; 258 uint8_t hlength;
259 uint8_t dlength[3]; 259 uint8_t dlength[3];
260 uint8_t lun[8]; 260 struct scsi_lun lun;
261 itt_t itt; /* Initiator Task Tag */ 261 itt_t itt; /* Initiator Task Tag */
262 itt_t rtt; /* Reference Task Tag */ 262 itt_t rtt; /* Reference Task Tag */
263 __be32 cmdsn; 263 __be32 cmdsn;
@@ -315,7 +315,7 @@ struct iscsi_r2t_rsp {
315 uint8_t rsvd2[2]; 315 uint8_t rsvd2[2];
316 uint8_t hlength; 316 uint8_t hlength;
317 uint8_t dlength[3]; 317 uint8_t dlength[3];
318 uint8_t lun[8]; 318 struct scsi_lun lun;
319 itt_t itt; /* Initiator Task Tag */ 319 itt_t itt; /* Initiator Task Tag */
320 __be32 ttt; /* Target Transfer Tag */ 320 __be32 ttt; /* Target Transfer Tag */
321 __be32 statsn; 321 __be32 statsn;
@@ -333,7 +333,7 @@ struct iscsi_data {
333 uint8_t rsvd2[2]; 333 uint8_t rsvd2[2];
334 uint8_t rsvd3; 334 uint8_t rsvd3;
335 uint8_t dlength[3]; 335 uint8_t dlength[3];
336 uint8_t lun[8]; 336 struct scsi_lun lun;
337 itt_t itt; 337 itt_t itt;
338 __be32 ttt; 338 __be32 ttt;
339 __be32 rsvd4; 339 __be32 rsvd4;
@@ -353,7 +353,7 @@ struct iscsi_data_rsp {
353 uint8_t cmd_status; 353 uint8_t cmd_status;
354 uint8_t hlength; 354 uint8_t hlength;
355 uint8_t dlength[3]; 355 uint8_t dlength[3];
356 uint8_t lun[8]; 356 struct scsi_lun lun;
357 itt_t itt; 357 itt_t itt;
358 __be32 ttt; 358 __be32 ttt;
359 __be32 statsn; 359 __be32 statsn;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 0f4367751b71..cedcff371c88 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -115,7 +115,7 @@ struct iscsi_task {
115 /* copied values in case we need to send tmfs */ 115 /* copied values in case we need to send tmfs */
116 itt_t hdr_itt; 116 itt_t hdr_itt;
117 __be32 cmdsn; 117 __be32 cmdsn;
118 uint8_t lun[8]; 118 struct scsi_lun lun;
119 119
120 int itt; /* this ITT */ 120 int itt; /* this ITT */
121 121