Skip to contentSkip to conversation

add open iscsi netlink interface to iscsi transport class

PATCH In review Mike Christie 5 participants 6 messages May 5, 2005

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 add open iscsi netlink interface to iscsi transport class

attached common-iscsi-headers.patch - Common header files:
- iscsi_if.h (user/kernel #defines);
- iscsi_proto.h (RFC3720 #defines and types);
- iscsi_ifev.h (user/kernel events).

Thanks,

Linux-iscsi Team

include/scsi/iscsi_ifev.h +121 -0
diff -Naurp linux-2.6.12-rc3.orig/include/scsi/iscsi_ifev.h linux-2.6.12-rc3/include/scsi/iscsi_ifev.h
@@ -0,0 +1,121 @@
+/*
+ * iSCSI Kernel/User Interface Events
+ *
+ * Copyright (C) 2005 Dmitry Yusupov, Alex Aizman
+ * maintained by [email protected]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * See the file COPYING included with this distribution for more details.
+ */
+
+#ifndef ISCSI_IFEV_H
+#define ISCSI_IFEV_H
+
+enum iscsi_uevent_e {
+	ISCSI_UEVENT_UNKNOWN		= 0,
+
+	/* down events */
+	ISCSI_UEVENT_CREATE_SESSION	= UEVENT_BASE + 1,
+	ISCSI_UEVENT_DESTROY_SESSION	= UEVENT_BASE + 2,
+	ISCSI_UEVENT_CREATE_CNX		= UEVENT_BASE + 3,
+	ISCSI_UEVENT_DESTROY_CNX	= UEVENT_BASE + 4,
+	ISCSI_UEVENT_BIND_CNX		= UEVENT_BASE + 5,
+	ISCSI_UEVENT_SET_PARAM		= UEVENT_BASE + 6,
+	ISCSI_UEVENT_START_CNX		= UEVENT_BASE + 7,
+	ISCSI_UEVENT_STOP_CNX		= UEVENT_BASE + 8,
+	ISCSI_UEVENT_SEND_PDU		= UEVENT_BASE + 9,
+	ISCSI_UEVENT_TRANS_LIST		= UEVENT_BASE + 10,
+	ISCSI_UEVENT_GET_STATS		= UEVENT_BASE + 11,
+	ISCSI_UEVENT_GET_PARAM		= UEVENT_BASE + 12,
+
+	/* up events */
+	ISCSI_KEVENT_RECV_PDU		= KEVENT_BASE + 1,
+	ISCSI_KEVENT_CNX_ERROR		= KEVENT_BASE + 2,
+	ISCSI_KEVENT_IF_ERROR		= KEVENT_BASE + 3,
+};
+
+struct iscsi_uevent {
+	uint32_t type; /* k/u events type */
+	uint32_t iferror; /* carries interface or resource errors */
+	uint64_t transport_handle;
+
+	union {
+		/* messages u -> k */
+		struct msg_create_session {
+			uint32_t	initial_cmdsn;
+		} c_session;
+		struct msg_destroy_session {
+			uint64_t	session_handle;
+			uint32_t	sid;
+		} d_session;
+		struct msg_create_cnx {
+			uint64_t	session_handle;
+			uint32_t	cid;
+			uint32_t	sid;
+		} c_cnx;
+		struct msg_bind_cnx {
+			uint64_t	session_handle;
+			uint64_t	cnx_handle;
+			uint32_t	transport_fd;
+			uint32_t	is_leading;
+		} b_cnx;
+		struct msg_destroy_cnx {
+			uint64_t	cnx_handle;
+			uint32_t	cid;
+		} d_cnx;
+		struct msg_send_pdu {
+			uint32_t	hdr_size;
+			uint32_t	data_size;
+			uint64_t	cnx_handle;
+		} send_pdu;
+		struct msg_set_param {
+			uint64_t	cnx_handle;
+			uint32_t	param; /* enum iscsi_param */
+			uint32_t	value;
+		} set_param;
+		struct msg_start_cnx {
+			uint64_t	cnx_handle;
+		} start_cnx;
+		struct msg_stop_cnx {
+			uint64_t	cnx_handle;
+			uint32_t	flag;
+		} stop_cnx;
+		struct msg_get_stats {
+			uint64_t	cnx_handle;
+		} get_stats;
+	} u;
+	union {
+		/* messages k -> u */
+		uint64_t		handle;
+		int			retcode;
+		struct msg_create_session_ret {
+			uint64_t	session_handle;
+			uint32_t	sid;
+		} c_session_ret;
+		struct msg_recv_req {
+			uint64_t	recv_handle;
+			uint64_t	cnx_handle;
+		} recv_req;
+		struct msg_cnx_error {
+			uint64_t	cnx_handle;
+			uint32_t	error; /* enum iscsi_err */
+		} cnxerror;
+		struct msg_trans_list {
+			struct {
+				uint64_t trans_handle;
+				char name[ISCSI_TRANSPORT_NAME_MAXLEN];
+			} elements[ISCSI_TRANSPORT_MAX];
+		} t_list;
+	} r;
+} __attribute__ ((aligned (sizeof(unsigned long))));
+
+#endif /* ISCSI_IFEV_H */
include/scsi/iscsi_if.h +155 -0

155 lines not on this page · raw message

include/scsi/iscsi_proto.h +565 -0

565 lines not on this page · raw message

#1 lore raw

In article <[email protected]> (at Wed, 04 May 2005 19:53:53 -0700), Mike Christie <[email protected]> says:

Quoted 1 line

+struct iscsi_uevent {

:

Quoted 1 line

+} __attribute__ ((aligned (sizeof(unsigned long))));

I think it'd be better to use sizeof(uint64_t) or something. Please check other spots, too. e.g.:

include/scsi/iscsi_if.h line 152

Quoted 2 lines
include/scsi/iscsi_if.h +2 -0
+	struct iscsi_stats_custom custom[0]
+		__attribute__ ((aligned (sizeof(unsigned long))));

--yoshfuji

#2 lore raw
Quoted 7 lines · YOSHIFUJI Hideaki / ????

In article <[email protected]> (at Wed, 04 May 2005 19:53:53 -0700), Mike Christie <[email protected]> says:

Quoted 1 line

+struct iscsi_uevent {

:

Quoted 1 line

+} __attribute__ ((aligned (sizeof(unsigned long))));

I think it'd be better to use sizeof(uint64_t) or something.

Is there a benefit in aligning on 64-bit boundaries for 32-bit platforms?

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#3 lore raw
Quoted 10 lines · Herbert Xu
Quoted 7 lines · YOSHIFUJI Hideaki / ????

In article <[email protected]> (at Wed, 04 May 2005 19:53:53 -0700), Mike Christie <[email protected]> says:

Quoted 1 line

+struct iscsi_uevent {

:

Quoted 1 line

+} __attribute__ ((aligned (sizeof(unsigned long))));

I think it'd be better to use sizeof(uint64_t) or something.

Is there a benefit in aligning on 64-bit boundaries for 32-bit platforms?

why align at all as opposed to just letting the compiler figure it out.

#4 lore raw
In reply to Herbert Xu

In article <[email protected]> (at Thu, 05 May 2005 21:39:47 +1000), Herbert Xu <[email protected]> says:

Quoted 10 lines
Quoted 7 lines · YOSHIFUJI Hideaki / ????

In article <[email protected]> (at Wed, 04 May 2005 19:53:53 -0700), Mike Christie <[email protected]> says:

Quoted 1 line

+struct iscsi_uevent {

:

Quoted 1 line

+} __attribute__ ((aligned (sizeof(unsigned long))));

I think it'd be better to use sizeof(uint64_t) or something.

Is there a benefit in aligning on 64-bit boundaries for 32-bit platforms?

Well, this if for avoiding inconsistency between kernel and userspace. If you use unsigned long, sizeof(unsigned long) may be inconssitent between kernel and userland like this:
kernel: sizeof(unsigned long) == 8
userspace: sizeof(unsigned long) == 4

--yoshfuji

#5 lore raw
In reply to YOSHIFUJI Hideaki / 吉藤英明
Quoted 7 lines · On Thu, May 05, 2005 at 06:55:03PM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ wrote:

In article <[email protected]> (at Wed, 04 May 2005 19:53:53 -0700), Mike Christie <[email protected]> says:

Quoted 1 line

+struct iscsi_uevent {

:

Quoted 1 line

+} __attribute__ ((aligned (sizeof(unsigned long))));

I think it'd be better to use sizeof(uint64_t) or something.

Actually, it's completely unnecessary. iscsi_uevent contains a uint64_t element, and the GCC docs (in the 'Type attribute' section, documenting aligned) say:

Note that the alignment of any given struct' or union' type is required by the ISO C standard to be at least a perfect multiple of the lowest common multiple of the alignments of all of the members of the struct' or union' in question. This means that you _can_

So best to just delete it. It has no effect.

Quoted 4 lines

Please check other spots, too. e.g.:

include/scsi/iscsi_if.h line 152

Quoted 2 lines
include/scsi/iscsi_if.h +2 -0
+	struct iscsi_stats_custom custom[0]
+		__attribute__ ((aligned (sizeof(unsigned long))));

This one's probably useless too, but it's hard to tell since the patches weren't sent inline thus making them difficult to cross-reference.

Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain