Open-iSCSI High-Performance Initiator for Linux
PATCH 2/6 Open-iSCSI High-Performance Initiator for Linux
Common header files:
- iscsi_ifev.h (user/kernel events).
- iscsi_if.h (iSCSI open interface over netlink);
- iscsi_proto.h (RFC3720 #defines and types);
include/scsi/iscsi_ifev.h +105 -0
@@ -0,0 +1,105 @@ +/* +* 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 + +typedef 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 , + +/* up events */ +ISCSI_KEVENT_RECV_PDU =KEVENT_BASE +1 , +ISCSI_KEVENT_CNX_ERROR =KEVENT_BASE +2 , +}iscsi_uevent_e ; + +struct iscsi_uevent { +uint32_t type;/* k/u events type */ +uint32_t transport_id; + +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; + } d_session; +struct msg_create_cnx { +uint64_t session_handle; +uint64_t cnx_handle; +uint32_t cid; + } 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; + } 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;/* iscsi_param_e */ +uint32_t value; + } set_param; +struct msg_start_cnx { +uint64_t cnx_handle; + } start_cnx; +struct msg_stop_cnx { +uint64_t cnx_handle; + } 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;/* iscsi_err_e */ + } cnxerror; + } r; +}; + +#endif /* ISCSI_IFEV_H */
include/scsi/iscsi_if.h +140 -0
140 lines not on this page · raw message
include/scsi/iscsi_proto.h +565 -0
565 lines not on this page · raw message
Quoted 35 lines · Alex Aizman
Common header files:
-iscsi_ifev.h(user/kernel events).
-iscsi_if.h(iSCSI open interface over netlink);
-iscsi_proto.h(RFC3720 #defines and types);include/scsi/iscsi_if.h +27
-0+/** +* struct iscsi_transport - down calls +* +* @name: transport name +* @caps: iSCSI Data-Path capabilities +* @create_snx: create new iSCSI session object +* @destroy_snx: destroy existing iSCSI session object +* @create_cnx: create new iSCSI connection +* @bind_cnx: associate this connection with existing iSCSI session and +* specified transport descriptor +* @destroy_cnx: destroy inactive iSCSI connection +* @set_param: set iSCSI Data-Path operational parameter +* @start_cnx: set connection to be operational +* @stop_cnx: suspend connection +* @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. +* +* API provided by generic iSCSI Data Path module +*/ +struct iscsi_transport { +char *name; +unsigned int caps; +unsigned int max_cnx; +iscsi_snx_h (*create_session) (iscsi_snx_h cp_snx, +uint32_t initial_cmdsn,uint32_t *sid); +void (*destroy_session) (iscsi_snx_h dp_snx); +iscsi_cnx_h (*create_cnx) (iscsi_snx_h dp_snx,iscsi_cnx_h cp_cnx, +uint32_t cid);
include/scsi/iscsi_if.h line 129
Quoted 10 lines
include/scsi/iscsi_if.h +10
-0+int (*bind_cnx) (iscsi_snx_h dp_snx,iscsi_cnx_h dp_cnx, +uint32_t transport_fd,int is_leading); +int (*start_cnx) (iscsi_cnx_h dp_cnx); +void (*stop_cnx) (iscsi_cnx_h dp_cnx); +void (*destroy_cnx) (iscsi_cnx_h dp_cnx); +int (*set_param) (iscsi_cnx_h dp_cnx,iscsi_param_e param, +uint32_t value); +int (*send_pdu) (iscsi_cnx_h dp_cnx,struct iscsi_hdr *hdr, +char *data,uint32_t data_size); +};
create_snx in comment but not in structuredestroy_snx in comment but not in structure
destroy_session in structure but not in commentcreate_session in structure but not in commentmax_cnx in structure but not in comment
Alexey
include/scsi/iscsi_if.h line 79
Quoted 2 lines · Alex Aizman
include/scsi/iscsi_if.h +2
-0+#define iscsi_ptr (_handle) ((void*)(unsigned long)_handle) +#define iscsi_handle (_ptr) ((uint64_t)(unsigned long)_ptr)
This is a bit wonky. Why is there a distinction?
include/scsi/iscsi_proto.h line 31
Quoted 12 lines
include/scsi/iscsi_proto.h +12
-0+#ifndef ISCSI_PROTO_H +#define ISCSI_PROTO_H + +#define ISCSI_VERSION_STR "0.1.0" +#define ISCSI_DATE_STR "17-Jan-2005" +#define ISCSI_DRAFT20_VERSION 0x00 + +/* default iSCSI listen port for incoming connections */ +#define ISCSI_LISTEN_PORT 3260 + +/* Padding word length */ +#define PAD_WORD_LEN 4
Namespace.
include/scsi/iscsi_proto.h line 42
Quoted 11 lines
include/scsi/iscsi_proto.h +11
-0+ +/* +* useful common(control and data pathes) macro +*/ +#define ntoh24 (p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2])) +#define hton24 (p, v) { \ + p[0] = (((v) >> 16) & 0xFF); \ + p[1] = (((v) >> 8) & 0xFF); \ + p[2] = ((v) & 0xFF); \ +} +#define zero_data (p) {p[0]=0;p[1]=0;p[2]=0;}
These are specific to dlength, yes? Can we instead roll dlength and hlength together, and do this with masking?
#define iscsi_hlen(hdr) (ntohl(hdr->hdlen)>>24)
#define iscsi_dlen(hdr) (ntohl(hdr->hdlen) & 0xffffff)
#define iscsi_set_hlen(hdr, len) (hdr->hdlen=htonl(iscsi_dlen(hdr)|(len<<24))) #define iscsi_set_hlen(hdr, len) (hdr->hdlen=htonl(len|(iscsi_hlen(hdr)<<24)))
The last two obviously have multiple evaluation, but you get the idea.
Quoted 1 line
+/* SNACK Header */
Mmm, snacks.
Quoted 12 lines
include/scsi/iscsi_proto.h +12
-0+/* Reason for Reject */ +#define CMD_BEFORE_LOGIN 1 +#define DATA_DIGEST_ERROR 2 +#define DATA_SNACK_REJECT 3 +#define ISCSI_PROTOCOL_ERROR 4 +#define CMD_NOT_SUPPORTED 5 +#define IMM_CMD_REJECT 6 +#define TASK_IN_PROGRESS 7 +#define INVALID_SNACK 8 +#define BOOKMARK_REJECTED 9 +#define BOOKMARK_NO_RESOURCES 10 +#define NEGOTIATION_RESET 11
include/scsi/iscsi_proto.h line 561
Quoted 10 lines
include/scsi/iscsi_proto.h +10
-0+ +/* Max. number of Key=Value pairs in a text message */ +#define MAX_KEY_VALUE_PAIRS 8192 + +/* maximum length for text keys/values */ +#define KEY_MAXLEN 64 +#define VALUE_MAXLEN 255 +#define TARGET_NAME_MAXLEN VALUE_MAXLEN + +#define DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH 8192
Namespace.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.