aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2006-01-13 19:05:50 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2006-01-14 11:55:20 -0500
commit7b8631b53bea286b68847a939b87135198335b66 (patch)
tree69a3d47f4d00f98771c4eb3cb6bc11fde0a6e0a1 /include
parent7cae5159dd2623300cf9820865bfbf6dcdb7c1b9 (diff)
[SCSI] iscsi: seperate iscsi interface from setup functions
This is the second version of the patch to address Christoph's comments. Instead of doing the lib, I just kept everything in scsi_trnapsort_iscsi.c like the FC and SPI class. This was becuase the driver model and sysfs class is tied to the session and connection setup so separating did not buy very much at this time. The reason for this patch was becuase HW iscsi LLDs like qla4xxx cannot use the iscsi class becuase the scsi_host was tied to the interface and class code. This patch just seperates the session from scsi host so that LLDs that allocate the host per some resource like pci device can still use the class. This is also fixes a couple refcount bugs that can be triggered when users have a sysfs file open, close the session, then read or write to the file. Signed-off-by: Alex Aizman <itn780@yahoo.com> Signed-off-by: Dmitry Yusupov <dmitry_yus@yahoo.com> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'include')
-rw-r--r--include/scsi/iscsi_if.h6
-rw-r--r--include/scsi/scsi_transport_iscsi.h75
2 files changed, 73 insertions, 8 deletions
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index be1bc792ab18..3e5cb5ab2d34 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -168,6 +168,12 @@ typedef uint64_t iscsi_connh_t; /* iSCSI Data-Path connection handle */
168 168
169#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) 169#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
170#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) 170#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
171#define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))
172
173/**
174 * iscsi_hostdata - get LLD hostdata from scsi_host
175 * @_hostdata: pointer to scsi host's hostdata
176 **/
171#define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long)) 177#define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long))
172 178
173/* 179/*
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index f25041c386ec..16602a547a63 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -23,8 +23,14 @@
23#ifndef SCSI_TRANSPORT_ISCSI_H 23#ifndef SCSI_TRANSPORT_ISCSI_H
24#define SCSI_TRANSPORT_ISCSI_H 24#define SCSI_TRANSPORT_ISCSI_H
25 25
26#include <linux/device.h>
26#include <scsi/iscsi_if.h> 27#include <scsi/iscsi_if.h>
27 28
29struct scsi_transport_template;
30struct Scsi_Host;
31struct mempool_zone;
32struct iscsi_cls_conn;
33
28/** 34/**
29 * struct iscsi_transport - iSCSI Transport template 35 * struct iscsi_transport - iSCSI Transport template
30 * 36 *
@@ -48,23 +54,31 @@ struct iscsi_transport {
48 char *name; 54 char *name;
49 unsigned int caps; 55 unsigned int caps;
50 struct scsi_host_template *host_template; 56 struct scsi_host_template *host_template;
57 /* LLD session/scsi_host data size */
51 int hostdata_size; 58 int hostdata_size;
59 /* LLD iscsi_host data size */
60 int ihostdata_size;
61 /* LLD connection data size */
62 int conndata_size;
52 int max_lun; 63 int max_lun;
53 unsigned int max_conn; 64 unsigned int max_conn;
54 unsigned int max_cmd_len; 65 unsigned int max_cmd_len;
55 iscsi_sessionh_t (*create_session) (uint32_t initial_cmdsn, 66 struct Scsi_Host *(*create_session) (struct scsi_transport_template *t,
56 struct Scsi_Host *shost); 67 uint32_t initial_cmdsn);
57 void (*destroy_session) (iscsi_sessionh_t session); 68 void (*destroy_session) (struct Scsi_Host *shost);
58 iscsi_connh_t (*create_conn) (iscsi_sessionh_t session, uint32_t cid); 69 struct iscsi_cls_conn *(*create_conn) (struct Scsi_Host *shost,
70 uint32_t cid);
59 int (*bind_conn) (iscsi_sessionh_t session, iscsi_connh_t conn, 71 int (*bind_conn) (iscsi_sessionh_t session, iscsi_connh_t conn,
60 uint32_t transport_fd, int is_leading); 72 uint32_t transport_fd, int is_leading);
61 int (*start_conn) (iscsi_connh_t conn); 73 int (*start_conn) (iscsi_connh_t conn);
62 void (*stop_conn) (iscsi_connh_t conn, int flag); 74 void (*stop_conn) (iscsi_connh_t conn, int flag);
63 void (*destroy_conn) (iscsi_connh_t conn); 75 void (*destroy_conn) (struct iscsi_cls_conn *conn);
64 int (*set_param) (iscsi_connh_t conn, enum iscsi_param param, 76 int (*set_param) (iscsi_connh_t conn, enum iscsi_param param,
65 uint32_t value); 77 uint32_t value);
66 int (*get_param) (iscsi_connh_t conn, enum iscsi_param param, 78 int (*get_conn_param) (void *conndata, enum iscsi_param param,
67 uint32_t *value); 79 uint32_t *value);
80 int (*get_session_param) (struct Scsi_Host *shost,
81 enum iscsi_param param, uint32_t *value);
68 int (*send_pdu) (iscsi_connh_t conn, struct iscsi_hdr *hdr, 82 int (*send_pdu) (iscsi_connh_t conn, struct iscsi_hdr *hdr,
69 char *data, uint32_t data_size); 83 char *data, uint32_t data_size);
70 void (*get_stats) (iscsi_connh_t conn, struct iscsi_stats *stats); 84 void (*get_stats) (iscsi_connh_t conn, struct iscsi_stats *stats);
@@ -73,7 +87,7 @@ struct iscsi_transport {
73/* 87/*
74 * transport registration upcalls 88 * transport registration upcalls
75 */ 89 */
76extern int iscsi_register_transport(struct iscsi_transport *tt); 90extern struct scsi_transport_template *iscsi_register_transport(struct iscsi_transport *tt);
77extern int iscsi_unregister_transport(struct iscsi_transport *tt); 91extern int iscsi_unregister_transport(struct iscsi_transport *tt);
78 92
79/* 93/*
@@ -83,4 +97,49 @@ extern void iscsi_conn_error(iscsi_connh_t conn, enum iscsi_err error);
83extern int iscsi_recv_pdu(iscsi_connh_t conn, struct iscsi_hdr *hdr, 97extern int iscsi_recv_pdu(iscsi_connh_t conn, struct iscsi_hdr *hdr,
84 char *data, uint32_t data_size); 98 char *data, uint32_t data_size);
85 99
100struct iscsi_cls_conn {
101 struct list_head conn_list; /* item in connlist */
102 void *dd_data; /* LLD private data */
103 struct iscsi_transport *transport;
104 iscsi_connh_t connh;
105 int active; /* must be accessed with the connlock */
106 struct device dev; /* sysfs transport/container device */
107 struct mempool_zone *z_error;
108 struct mempool_zone *z_pdu;
109 struct list_head freequeue;
110};
111
112#define iscsi_dev_to_conn(_dev) \
113 container_of(_dev, struct iscsi_cls_conn, dev)
114
115struct iscsi_cls_session {
116 struct list_head list; /* item in session_list */
117 struct iscsi_transport *transport;
118 struct device dev; /* sysfs transport/container device */
119};
120
121#define iscsi_dev_to_session(_dev) \
122 container_of(_dev, struct iscsi_cls_session, dev)
123
124#define iscsi_session_to_shost(_session) \
125 dev_to_shost(_session->dev.parent)
126
127/*
128 * session and connection functions that can be used by HW iSCSI LLDs
129 */
130extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost,
131 struct iscsi_transport *t);
132extern int iscsi_destroy_session(struct iscsi_cls_session *session);
133extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess,
134 uint32_t cid);
135extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
136
137/*
138 * session functions used by software iscsi
139 */
140extern struct Scsi_Host *
141iscsi_transport_create_session(struct scsi_transport_template *scsit,
142 struct iscsi_transport *transport);
143extern int iscsi_transport_destroy_session(struct Scsi_Host *shost);
144
86#endif 145#endif