linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] srp.h: avoid padding of structs
@ 2006-04-16 19:34 Arne Redlich
  2006-04-17  9:17 ` Arne Redlich
  0 siblings, 1 reply; 6+ messages in thread
From: Arne Redlich @ 2006-04-16 19:34 UTC (permalink / raw)
  To: linux-scsi

Several structs in srp.h are padded by the compiler on some architectures, causing problems e.g. in ib_srp:

				i386	x86_64	(SRP spec)

sizeof(struct indirect_buf)	20	24	(20)
sizeof(struct srp_login_rsp)	52	56	(52)
sizeof(struct srp_rsp)		36	40	(36)

The patch below addresses this issue by packing these three structs, as well as the remaining ones.

Signed-off-by: Arne Redlich <arne.redlich@xiranet.com>

diff -prauN a/include/scsi/srp.h b/include/scsi/srp.h
--- a/include/scsi/srp.h	2006-04-16 19:12:27.347924280 +0200
+++ b/include/scsi/srp.h	2006-04-16 19:16:47.789331168 +0200
@@ -91,18 +91,13 @@ struct srp_direct_buf {
 	__be64	va;
 	__be32	key;
 	__be32  len;
-};
+} __attribute__((packed));
 
-/*
- * We need the packed attribute because the SRP spec puts the list of
- * descriptors at an offset of 20, which is not aligned to the size
- * of struct srp_direct_buf.
- */
 struct srp_indirect_buf {
 	struct srp_direct_buf	table_desc;
 	__be32			len;
 	struct srp_direct_buf	desc_list[0] __attribute__((packed));
-};
+} __attribute__((packed));
 
 enum {
 	SRP_MULTICHAN_SINGLE = 0,
@@ -120,7 +115,7 @@ struct srp_login_req {
 	u8	reserved3[5];
 	u8	initiator_port_id[16];
 	u8	target_port_id[16];
-};
+} __attribute__((packed));
 
 struct srp_login_rsp {
 	u8	opcode;
@@ -132,7 +127,7 @@ struct srp_login_rsp {
 	__be16	buf_fmt;
 	u8	rsp_flags;
 	u8	reserved2[25];
-};
+} __attribute__((packed));
 
 struct srp_login_rej {
 	u8	opcode;
@@ -142,13 +137,13 @@ struct srp_login_rej {
 	u8	reserved2[8];
 	__be16	buf_fmt;
 	u8	reserved3[6];
-};
+} __attribute__((packed));
 
 struct srp_i_logout {
 	u8	opcode;
 	u8	reserved[7];
 	u64	tag;
-};
+} __attribute__((packed));
 
 struct srp_t_logout {
 	u8	opcode;
@@ -156,30 +151,22 @@ struct srp_t_logout {
 	u8	reserved[2];
 	__be32	reason;
 	u64	tag;
-};
+} __attribute__((packed));
 
-/*
- * We need the packed attribute because the SRP spec only aligns the
- * 8-byte LUN field to 4 bytes.
- */
 struct srp_tsk_mgmt {
 	u8	opcode;
 	u8	sol_not;
 	u8	reserved1[6];
 	u64	tag;
 	u8	reserved2[4];
-	__be64	lun __attribute__((packed));
+	__be64	lun;
 	u8	reserved3[2];
 	u8	tsk_mgmt_func;
 	u8	reserved4;
 	u64	task_tag;
 	u8	reserved5[8];
-};
+} __attribute__((packed));
 
-/*
- * We need the packed attribute because the SRP spec only aligns the
- * 8-byte LUN field to 4 bytes.
- */
 struct srp_cmd {
 	u8	opcode;
 	u8	sol_not;
@@ -189,14 +176,14 @@ struct srp_cmd {
 	u8	data_in_desc_cnt;
 	u64	tag;
 	u8	reserved2[4];
-	__be64	lun __attribute__((packed));
+	__be64	lun;
 	u8	reserved3;
 	u8	task_attr;
 	u8	reserved4;
 	u8	add_cdb_len;
 	u8	cdb[16];
 	u8	add_data[0];
-};
+} __attribute__((packed));
 
 enum {
 	SRP_RSP_FLAG_RSPVALID = 1 << 0,
@@ -221,6 +208,6 @@ struct srp_rsp {
 	__be32	sense_data_len;
 	__be32	resp_data_len;
 	u8	data[0];
-};
+} __attribute__((packed));
 
 #endif /* SCSI_SRP_H */

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-04-28 14:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-16 19:34 [PATCH] srp.h: avoid padding of structs Arne Redlich
2006-04-17  9:17 ` Arne Redlich
     [not found]   ` <20050823221723.GE31949@krispykreme>
2006-04-18 16:05     ` Roland Dreier
2006-04-18 16:27       ` Arne Redlich
2006-04-18 16:33         ` Roland Dreier
2006-04-28 14:53       ` Arne Redlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).