Skip to contentSkip to conversation

Linux-iSCSI High-Performance Initiator

PATCH In review Alex Aizman 4 participants 8 messages Apr 12, 2005

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

PATCH 2/6 Linux-iSCSI High-Performance Initiator

Common header files:
- iscsi_ifev.h (user/kernel events).
- iscsi_if.h (user/kernel #defines);
- iscsi_iftrans.h (iscsi transport interface);
- iscsi_proto.h (RFC3720 #defines and types).

include/scsi/iscsi_ifev.h +118 -0
diff -Nru linux-2.6.12-rc2.orig/include/scsi/iscsi_ifev.h linux-2.6.12-rc2.dima/include/scsi/iscsi_ifev.h
@@ -0,0 +1,118 @@
+/*
+ * 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,
+
+	/* 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 {
+			uint64_t	session_handle;
+			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;
+			uint64_t	cnx_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;
+	} u;
+	union {
+		/* messages k -> u */
+		uint64_t		handle;
+		int			retcode;
+		struct msg_create_session_ret {
+			uint64_t	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 handle;
+				char name[ISCSI_TRANSPORT_NAME_MAXLEN];
+			} elements[ISCSI_TRANSPORT_MAX];
+		} t_list;
+	} r;
+};
+
+#endif /* ISCSI_IFEV_H */
include/scsi/iscsi_if.h +103 -0

103 lines not on this page · raw message

include/scsi/iscsi_iftrans.h +83 -0

83 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

include/scsi/iscsi_proto.h line 58

Quoted 12 lines
include/scsi/iscsi_proto.h +12 -0
+struct iscsi_hdr {
+	uint8_t		opcode;
+	uint8_t		flags;		/* Final bit */
+	uint8_t		rsvd2[2];
+	uint8_t		hlength;	/* AHSs total length */
+	uint8_t		dlength[3];	/* Data length */
+	uint8_t		lun[8];
+	uint32_t	itt;		/* Initiator Task Tag */
+	uint32_t	ttt;		/* Target Task Tag */
+	uint32_t	statsn;
+	uint32_t	exp_statsn;
+	uint8_t		other[16];

Please use u8 and u32 instead of the types you used here. See the lkml archives for many threads about this topic.

thanks,

greg k-h

#2 lore raw
In reply to Alex Aizman

include/scsi/iscsi_if.h line 78

Quoted 2 lines · Alex Aizman
include/scsi/iscsi_if.h +2 -0
+typedef uint64_t iscsi_snx_t;		/* iSCSI Data-Path session handle */
+typedef uint64_t iscsi_cnx_t;		/* iSCSI Data-Path connection handle */

Do you really have to create a new typedef? Please reconsider. Just use u64 everywhere, unless you need to do type checking...

thanks,

greg k-h

#4 lore raw
In reply to Alex Aizman
Quoted 2 lines · Alex Aizman

Common header files:
- iscsi_ifev.h (user/kernel events).

These structures cross the user/kernel boundry? If so, they _must_ use the __u32 and friends types, not the horrible uint32_t mess...

thanks,

greg k-h

#5 lore raw
Quoted 6 lines · Greg KH
Quoted 2 lines · Alex Aizman

Common header files:
- iscsi_ifev.h (user/kernel events).

These structures cross the user/kernel boundry? If so, they _must_ use the __u32 and friends types, not the horrible uint32_t mess...

No, C99 are just fine.

#6 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · Greg KH
Quoted 2 lines · Alex Aizman

Common header files:
- iscsi_ifev.h (user/kernel events).

These structures cross the user/kernel boundry? If so, they _must_ use the __u32 and friends types, not the horrible uint32_t mess...

No, C99 are just fine.

Um, why? We've been down this road before, and for types that cross the boundry, we _must_ use the __ version of the kernel types, not the uint32_t stuff.

thanks,

greg k-h

#7 lore raw
Quoted 3 lines · Greg KH

Um, why? We've been down this road before, and for types that cross the boundry, we _must_ use the __ version of the kernel types, not the uint32_t stuff.

That's total bullshit. C99 types just work in both the kernel and userland, while __u* types need to be typedefed to these exact C99 everywhere in userland bnecause they're only provided in kernelspace.

#3 lore raw
In reply to Greg KH
Quoted 6 lines · Greg KH

include/scsi/iscsi_if.h line 78

Quoted 2 lines · Alex Aizman
include/scsi/iscsi_if.h +2 -0
+typedef uint64_t iscsi_snx_t;		/* iSCSI Data-Path session handle */
+typedef uint64_t iscsi_cnx_t;		/* iSCSI Data-Path connection handle */

Do you really have to create a new typedef? Please reconsider. Just use u64 everywhere, unless you need to do type checking...

it is a handle and it is used as a parameter in exported API. yes. type checking exactly the reason.

Dima