aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/scsi/iscsi_if.h34
-rw-r--r--include/scsi/libiscsi.h67
-rw-r--r--include/scsi/scsi_cmnd.h20
-rw-r--r--include/scsi/scsi_device.h2
-rw-r--r--include/scsi/scsi_host.h10
-rw-r--r--include/scsi/scsi_transport_fc.h186
-rw-r--r--include/scsi/scsi_transport_iscsi.h16
7 files changed, 284 insertions, 51 deletions
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 55ebf035e620..50e907f42048 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -48,6 +48,7 @@ enum iscsi_uevent_e {
48 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14, 48 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
49 49
50 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15, 50 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
51 ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
51 52
52 /* up events */ 53 /* up events */
53 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, 54 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
@@ -71,6 +72,8 @@ struct iscsi_uevent {
71 /* messages u -> k */ 72 /* messages u -> k */
72 struct msg_create_session { 73 struct msg_create_session {
73 uint32_t initial_cmdsn; 74 uint32_t initial_cmdsn;
75 uint16_t cmds_max;
76 uint16_t queue_depth;
74 } c_session; 77 } c_session;
75 struct msg_destroy_session { 78 struct msg_destroy_session {
76 uint32_t sid; 79 uint32_t sid;
@@ -136,6 +139,11 @@ struct iscsi_uevent {
136 */ 139 */
137 uint32_t enable; 140 uint32_t enable;
138 } tgt_dscvr; 141 } tgt_dscvr;
142 struct msg_set_host_param {
143 uint32_t host_no;
144 uint32_t param; /* enum iscsi_host_param */
145 uint32_t len;
146 } set_host_param;
139 } u; 147 } u;
140 union { 148 union {
141 /* messages k -> u */ 149 /* messages k -> u */
@@ -223,6 +231,11 @@ enum iscsi_param {
223 ISCSI_PARAM_CONN_PORT, 231 ISCSI_PARAM_CONN_PORT,
224 ISCSI_PARAM_CONN_ADDRESS, 232 ISCSI_PARAM_CONN_ADDRESS,
225 233
234 ISCSI_PARAM_USERNAME,
235 ISCSI_PARAM_USERNAME_IN,
236 ISCSI_PARAM_PASSWORD,
237 ISCSI_PARAM_PASSWORD_IN,
238
226 /* must always be last */ 239 /* must always be last */
227 ISCSI_PARAM_MAX, 240 ISCSI_PARAM_MAX,
228}; 241};
@@ -249,6 +262,24 @@ enum iscsi_param {
249#define ISCSI_SESS_RECOVERY_TMO (1 << ISCSI_PARAM_SESS_RECOVERY_TMO) 262#define ISCSI_SESS_RECOVERY_TMO (1 << ISCSI_PARAM_SESS_RECOVERY_TMO)
250#define ISCSI_CONN_PORT (1 << ISCSI_PARAM_CONN_PORT) 263#define ISCSI_CONN_PORT (1 << ISCSI_PARAM_CONN_PORT)
251#define ISCSI_CONN_ADDRESS (1 << ISCSI_PARAM_CONN_ADDRESS) 264#define ISCSI_CONN_ADDRESS (1 << ISCSI_PARAM_CONN_ADDRESS)
265#define ISCSI_USERNAME (1 << ISCSI_PARAM_USERNAME)
266#define ISCSI_USERNAME_IN (1 << ISCSI_PARAM_USERNAME_IN)
267#define ISCSI_PASSWORD (1 << ISCSI_PARAM_PASSWORD)
268#define ISCSI_PASSWORD_IN (1 << ISCSI_PARAM_PASSWORD_IN)
269
270/* iSCSI HBA params */
271enum iscsi_host_param {
272 ISCSI_HOST_PARAM_HWADDRESS,
273 ISCSI_HOST_PARAM_INITIATOR_NAME,
274 ISCSI_HOST_PARAM_NETDEV_NAME,
275 ISCSI_HOST_PARAM_IPADDRESS,
276 ISCSI_HOST_PARAM_MAX,
277};
278
279#define ISCSI_HOST_HWADDRESS (1 << ISCSI_HOST_PARAM_HWADDRESS)
280#define ISCSI_HOST_INITIATOR_NAME (1 << ISCSI_HOST_PARAM_INITIATOR_NAME)
281#define ISCSI_HOST_NETDEV_NAME (1 << ISCSI_HOST_PARAM_NETDEV_NAME)
282#define ISCSI_HOST_IPADDRESS (1 << ISCSI_HOST_PARAM_IPADDRESS)
252 283
253#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) 284#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
254#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) 285#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
@@ -272,6 +303,9 @@ enum iscsi_param {
272#define CAP_MULTI_CONN 0x40 303#define CAP_MULTI_CONN 0x40
273#define CAP_TEXT_NEGO 0x80 304#define CAP_TEXT_NEGO 0x80
274#define CAP_MARKERS 0x100 305#define CAP_MARKERS 0x100
306#define CAP_FW_DB 0x200
307#define CAP_SENDTARGETS_OFFLOAD 0x400
308#define CAP_DATA_PATH_OFFLOAD 0x800
275 309
276/* 310/*
277 * These flags describes reason of stop_conn() call 311 * These flags describes reason of stop_conn() call
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ea0816d4904d..3f631b08a1ab 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -48,9 +48,8 @@ struct iscsi_nopin;
48#define debug_scsi(fmt...) 48#define debug_scsi(fmt...)
49#endif 49#endif
50 50
51#define ISCSI_XMIT_CMDS_MAX 128 /* must be power of 2 */ 51#define ISCSI_DEF_XMIT_CMDS_MAX 128 /* must be power of 2 */
52#define ISCSI_MGMT_CMDS_MAX 32 /* must be power of 2 */ 52#define ISCSI_MGMT_CMDS_MAX 16 /* must be power of 2 */
53#define ISCSI_CONN_MAX 1
54 53
55#define ISCSI_MGMT_ITT_OFFSET 0xa00 54#define ISCSI_MGMT_ITT_OFFSET 0xa00
56 55
@@ -73,6 +72,8 @@ struct iscsi_nopin;
73#define ISCSI_AGE_SHIFT 28 72#define ISCSI_AGE_SHIFT 28
74#define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT) 73#define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT)
75 74
75#define ISCSI_ADDRESS_BUF_LEN 64
76
76struct iscsi_mgmt_task { 77struct iscsi_mgmt_task {
77 /* 78 /*
78 * Becuae LLDs allocate their hdr differently, this is a pointer to 79 * Becuae LLDs allocate their hdr differently, this is a pointer to
@@ -80,7 +81,7 @@ struct iscsi_mgmt_task {
80 */ 81 */
81 struct iscsi_hdr *hdr; 82 struct iscsi_hdr *hdr;
82 char *data; /* mgmt payload */ 83 char *data; /* mgmt payload */
83 int data_count; /* counts data to be sent */ 84 unsigned data_count; /* counts data to be sent */
84 uint32_t itt; /* this ITT */ 85 uint32_t itt; /* this ITT */
85 void *dd_data; /* driver/transport data */ 86 void *dd_data; /* driver/transport data */
86 struct list_head running; 87 struct list_head running;
@@ -90,6 +91,7 @@ enum {
90 ISCSI_TASK_COMPLETED, 91 ISCSI_TASK_COMPLETED,
91 ISCSI_TASK_PENDING, 92 ISCSI_TASK_PENDING,
92 ISCSI_TASK_RUNNING, 93 ISCSI_TASK_RUNNING,
94 ISCSI_TASK_ABORTING,
93}; 95};
94 96
95struct iscsi_cmd_task { 97struct iscsi_cmd_task {
@@ -99,16 +101,14 @@ struct iscsi_cmd_task {
99 */ 101 */
100 struct iscsi_cmd *hdr; 102 struct iscsi_cmd *hdr;
101 int itt; /* this ITT */ 103 int itt; /* this ITT */
102 int datasn; /* DataSN */
103 104
104 uint32_t unsol_datasn; 105 uint32_t unsol_datasn;
105 int imm_count; /* imm-data (bytes) */ 106 unsigned imm_count; /* imm-data (bytes) */
106 int unsol_count; /* unsolicited (bytes)*/ 107 unsigned unsol_count; /* unsolicited (bytes)*/
107 /* offset in unsolicited stream (bytes); */ 108 /* offset in unsolicited stream (bytes); */
108 int unsol_offset; 109 unsigned unsol_offset;
109 int data_count; /* remaining Data-Out */ 110 unsigned data_count; /* remaining Data-Out */
110 struct scsi_cmnd *sc; /* associated SCSI cmd*/ 111 struct scsi_cmnd *sc; /* associated SCSI cmd*/
111 int total_length;
112 struct iscsi_conn *conn; /* used connection */ 112 struct iscsi_conn *conn; /* used connection */
113 struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */ 113 struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */
114 114
@@ -152,18 +152,11 @@ struct iscsi_conn {
152 struct iscsi_cmd_task *ctask; /* xmit ctask in progress */ 152 struct iscsi_cmd_task *ctask; /* xmit ctask in progress */
153 153
154 /* xmit */ 154 /* xmit */
155 struct kfifo *immqueue; /* immediate xmit queue */
156 struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */ 155 struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */
157 struct list_head mgmt_run_list; /* list of control tasks */ 156 struct list_head mgmt_run_list; /* list of control tasks */
158 struct list_head xmitqueue; /* data-path cmd queue */ 157 struct list_head xmitqueue; /* data-path cmd queue */
159 struct list_head run_list; /* list of cmds in progress */ 158 struct list_head run_list; /* list of cmds in progress */
160 struct work_struct xmitwork; /* per-conn. xmit workqueue */ 159 struct work_struct xmitwork; /* per-conn. xmit workqueue */
161 /*
162 * serializes connection xmit, access to kfifos:
163 * xmitqueue, immqueue, mgmtqueue
164 */
165 struct mutex xmitmutex;
166
167 unsigned long suspend_tx; /* suspend Tx */ 160 unsigned long suspend_tx; /* suspend Tx */
168 unsigned long suspend_rx; /* suspend Rx */ 161 unsigned long suspend_rx; /* suspend Rx */
169 162
@@ -174,8 +167,8 @@ struct iscsi_conn {
174 int tmabort_state; /* see TMABORT_INITIAL, etc.*/ 167 int tmabort_state; /* see TMABORT_INITIAL, etc.*/
175 168
176 /* negotiated params */ 169 /* negotiated params */
177 int max_recv_dlength; /* initiator_max_recv_dsl*/ 170 unsigned max_recv_dlength; /* initiator_max_recv_dsl*/
178 int max_xmit_dlength; /* target_max_recv_dsl */ 171 unsigned max_xmit_dlength; /* target_max_recv_dsl */
179 int hdrdgst_en; 172 int hdrdgst_en;
180 int datadgst_en; 173 int datadgst_en;
181 int ifmarker_en; 174 int ifmarker_en;
@@ -183,6 +176,12 @@ struct iscsi_conn {
183 /* values userspace uses to id a conn */ 176 /* values userspace uses to id a conn */
184 int persistent_port; 177 int persistent_port;
185 char *persistent_address; 178 char *persistent_address;
179 /* remote portal currently connected to */
180 int portal_port;
181 char portal_address[ISCSI_ADDRESS_BUF_LEN];
182 /* local address */
183 int local_port;
184 char local_address[ISCSI_ADDRESS_BUF_LEN];
186 185
187 /* MIB-statistics */ 186 /* MIB-statistics */
188 uint64_t txdata_octets; 187 uint64_t txdata_octets;
@@ -213,18 +212,25 @@ struct iscsi_session {
213 212
214 /* configuration */ 213 /* configuration */
215 int initial_r2t_en; 214 int initial_r2t_en;
216 int max_r2t; 215 unsigned max_r2t;
217 int imm_data_en; 216 int imm_data_en;
218 int first_burst; 217 unsigned first_burst;
219 int max_burst; 218 unsigned max_burst;
220 int time2wait; 219 int time2wait;
221 int time2retain; 220 int time2retain;
222 int pdu_inorder_en; 221 int pdu_inorder_en;
223 int dataseq_inorder_en; 222 int dataseq_inorder_en;
224 int erl; 223 int erl;
225 int tpgt; 224 int tpgt;
225 char *username;
226 char *username_in;
227 char *password;
228 char *password_in;
226 char *targetname; 229 char *targetname;
227 230 char *initiatorname;
231 /* hw address or netdev iscsi connection is bound to */
232 char *hwaddress;
233 char *netdev;
228 /* control data */ 234 /* control data */
229 struct iscsi_transport *tt; 235 struct iscsi_transport *tt;
230 struct Scsi_Host *host; 236 struct Scsi_Host *host;
@@ -255,12 +261,22 @@ extern int iscsi_eh_host_reset(struct scsi_cmnd *sc);
255extern int iscsi_queuecommand(struct scsi_cmnd *sc, 261extern int iscsi_queuecommand(struct scsi_cmnd *sc,
256 void (*done)(struct scsi_cmnd *)); 262 void (*done)(struct scsi_cmnd *));
257 263
264
265/*
266 * iSCSI host helpers.
267 */
268extern int iscsi_host_set_param(struct Scsi_Host *shost,
269 enum iscsi_host_param param, char *buf,
270 int buflen);
271extern int iscsi_host_get_param(struct Scsi_Host *shost,
272 enum iscsi_host_param param, char *buf);
273
258/* 274/*
259 * session management 275 * session management
260 */ 276 */
261extern struct iscsi_cls_session * 277extern struct iscsi_cls_session *
262iscsi_session_setup(struct iscsi_transport *, struct scsi_transport_template *, 278iscsi_session_setup(struct iscsi_transport *, struct scsi_transport_template *,
263 int, int, uint32_t, uint32_t *); 279 uint16_t, uint16_t, int, int, uint32_t, uint32_t *);
264extern void iscsi_session_teardown(struct iscsi_cls_session *); 280extern void iscsi_session_teardown(struct iscsi_cls_session *);
265extern struct iscsi_session *class_to_transport_session(struct iscsi_cls_session *); 281extern struct iscsi_session *class_to_transport_session(struct iscsi_cls_session *);
266extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *); 282extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *);
@@ -289,8 +305,7 @@ extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
289/* 305/*
290 * pdu and task processing 306 * pdu and task processing
291 */ 307 */
292extern int iscsi_check_assign_cmdsn(struct iscsi_session *, 308extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *);
293 struct iscsi_nopin *);
294extern void iscsi_prep_unsolicit_data_pdu(struct iscsi_cmd_task *, 309extern void iscsi_prep_unsolicit_data_pdu(struct iscsi_cmd_task *,
295 struct iscsi_data *hdr); 310 struct iscsi_data *hdr);
296extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *, 311extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index a2e0c1032491..53e170586c26 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -135,4 +135,24 @@ extern void scsi_kunmap_atomic_sg(void *virt);
135extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t); 135extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
136extern void scsi_free_sgtable(struct scatterlist *, int); 136extern void scsi_free_sgtable(struct scatterlist *, int);
137 137
138extern int scsi_dma_map(struct scsi_cmnd *cmd);
139extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
140
141#define scsi_sg_count(cmd) ((cmd)->use_sg)
142#define scsi_sglist(cmd) ((struct scatterlist *)(cmd)->request_buffer)
143#define scsi_bufflen(cmd) ((cmd)->request_bufflen)
144
145static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid)
146{
147 cmd->resid = resid;
148}
149
150static inline int scsi_get_resid(struct scsi_cmnd *cmd)
151{
152 return cmd->resid;
153}
154
155#define scsi_for_each_sg(cmd, sg, nseg, __i) \
156 for (__i = 0, sg = scsi_sglist(cmd); __i < (nseg); __i++, (sg)++)
157
138#endif /* _SCSI_SCSI_CMND_H */ 158#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 2f3c5b8b1d6a..d5057bc338ff 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -209,7 +209,6 @@ extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
209extern int scsi_add_device(struct Scsi_Host *host, uint channel, 209extern int scsi_add_device(struct Scsi_Host *host, uint channel,
210 uint target, uint lun); 210 uint target, uint lun);
211extern void scsi_remove_device(struct scsi_device *); 211extern void scsi_remove_device(struct scsi_device *);
212extern int scsi_device_cancel(struct scsi_device *, int);
213 212
214extern int scsi_device_get(struct scsi_device *); 213extern int scsi_device_get(struct scsi_device *);
215extern void scsi_device_put(struct scsi_device *); 214extern void scsi_device_put(struct scsi_device *);
@@ -287,6 +286,7 @@ extern void scsi_target_block(struct device *);
287extern void scsi_target_unblock(struct device *); 286extern void scsi_target_unblock(struct device *);
288extern void scsi_remove_target(struct device *); 287extern void scsi_remove_target(struct device *);
289extern void int_to_scsilun(unsigned int, struct scsi_lun *); 288extern void int_to_scsilun(unsigned int, struct scsi_lun *);
289extern int scsilun_to_int(struct scsi_lun *);
290extern const char *scsi_device_state_name(enum scsi_device_state); 290extern const char *scsi_device_state_name(enum scsi_device_state);
291extern int scsi_is_sdev_device(const struct device *); 291extern int scsi_is_sdev_device(const struct device *);
292extern int scsi_is_target_device(const struct device *); 292extern int scsi_is_target_device(const struct device *);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 68f461b7a835..ba07cf7c04ba 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -339,12 +339,6 @@ struct scsi_host_template {
339 enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *); 339 enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *);
340 340
341 /* 341 /*
342 * suspend support
343 */
344 int (*resume)(struct scsi_device *);
345 int (*suspend)(struct scsi_device *, pm_message_t state);
346
347 /*
348 * Name of proc directory 342 * Name of proc directory
349 */ 343 */
350 char *proc_name; 344 char *proc_name;
@@ -677,6 +671,10 @@ struct Scsi_Host {
677#define shost_printk(prefix, shost, fmt, a...) \ 671#define shost_printk(prefix, shost, fmt, a...) \
678 dev_printk(prefix, &(shost)->shost_gendev, fmt, ##a) 672 dev_printk(prefix, &(shost)->shost_gendev, fmt, ##a)
679 673
674static inline void *shost_priv(struct Scsi_Host *shost)
675{
676 return (void *)shost->hostdata;
677}
680 678
681int scsi_is_host_device(const struct device *); 679int scsi_is_host_device(const struct device *);
682 680
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 1e797308640a..a0d80bcaa93d 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * FiberChannel transport specific attributes exported to sysfs. 2 * FiberChannel transport specific attributes exported to sysfs.
3 * 3 *
4 * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved. 4 * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
@@ -19,7 +19,7 @@
19 * 19 *
20 * ======== 20 * ========
21 * 21 *
22 * Copyright (C) 2004-2005 James Smart, Emulex Corporation 22 * Copyright (C) 2004-2007 James Smart, Emulex Corporation
23 * Rewrite for host, target, device, and remote port attributes, 23 * Rewrite for host, target, device, and remote port attributes,
24 * statistics, and service functions... 24 * statistics, and service functions...
25 * 25 *
@@ -62,8 +62,10 @@ enum fc_port_type {
62 FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */ 62 FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */
63 FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */ 63 FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */
64 FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */ 64 FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */
65 FC_PORTTYPE_NPIV, /* VPORT based on NPIV */
65}; 66};
66 67
68
67/* 69/*
68 * fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c 70 * fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c
69 * (for the ascii descriptions). 71 * (for the ascii descriptions).
@@ -83,7 +85,26 @@ enum fc_port_state {
83}; 85};
84 86
85 87
86/* 88/*
89 * fc_vport_state: If you alter this, you also need to alter
90 * scsi_transport_fc.c (for the ascii descriptions).
91 */
92enum fc_vport_state {
93 FC_VPORT_UNKNOWN,
94 FC_VPORT_ACTIVE,
95 FC_VPORT_DISABLED,
96 FC_VPORT_LINKDOWN,
97 FC_VPORT_INITIALIZING,
98 FC_VPORT_NO_FABRIC_SUPP,
99 FC_VPORT_NO_FABRIC_RSCS,
100 FC_VPORT_FABRIC_LOGOUT,
101 FC_VPORT_FABRIC_REJ_WWN,
102 FC_VPORT_FAILED,
103};
104
105
106
107/*
87 * FC Classes of Service 108 * FC Classes of Service
88 * Note: values are not enumerated, as they can be "or'd" together 109 * Note: values are not enumerated, as they can be "or'd" together
89 * for reporting (e.g. report supported_classes). If you alter this list, 110 * for reporting (e.g. report supported_classes). If you alter this list,
@@ -96,7 +117,7 @@ enum fc_port_state {
96#define FC_COS_CLASS4 0x10 117#define FC_COS_CLASS4 0x10
97#define FC_COS_CLASS6 0x40 118#define FC_COS_CLASS6 0x40
98 119
99/* 120/*
100 * FC Port Speeds 121 * FC Port Speeds
101 * Note: values are not enumerated, as they can be "or'd" together 122 * Note: values are not enumerated, as they can be "or'd" together
102 * for reporting (e.g. report supported_speeds). If you alter this list, 123 * for reporting (e.g. report supported_speeds). If you alter this list,
@@ -124,16 +145,114 @@ enum fc_tgtid_binding_type {
124}; 145};
125 146
126/* 147/*
127 * FC Remote Port Roles 148 * FC Port Roles
128 * Note: values are not enumerated, as they can be "or'd" together 149 * Note: values are not enumerated, as they can be "or'd" together
129 * for reporting (e.g. report roles). If you alter this list, 150 * for reporting (e.g. report roles). If you alter this list,
130 * you also need to alter scsi_transport_fc.c (for the ascii descriptions). 151 * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
131 */ 152 */
132#define FC_RPORT_ROLE_UNKNOWN 0x00 153#define FC_PORT_ROLE_UNKNOWN 0x00
133#define FC_RPORT_ROLE_FCP_TARGET 0x01 154#define FC_PORT_ROLE_FCP_TARGET 0x01
134#define FC_RPORT_ROLE_FCP_INITIATOR 0x02 155#define FC_PORT_ROLE_FCP_INITIATOR 0x02
135#define FC_RPORT_ROLE_IP_PORT 0x04 156#define FC_PORT_ROLE_IP_PORT 0x04
157
158/* The following are for compatibility */
159#define FC_RPORT_ROLE_UNKNOWN FC_PORT_ROLE_UNKNOWN
160#define FC_RPORT_ROLE_FCP_TARGET FC_PORT_ROLE_FCP_TARGET
161#define FC_RPORT_ROLE_FCP_INITIATOR FC_PORT_ROLE_FCP_INITIATOR
162#define FC_RPORT_ROLE_IP_PORT FC_PORT_ROLE_IP_PORT
163
164
165/* Macro for use in defining Virtual Port attributes */
166#define FC_VPORT_ATTR(_name,_mode,_show,_store) \
167struct class_device_attribute class_device_attr_vport_##_name = \
168 __ATTR(_name,_mode,_show,_store)
169
170
171/*
172 * FC Virtual Port Attributes
173 *
174 * This structure exists for each FC port is a virtual FC port. Virtual
175 * ports share the physical link with the Physical port. Each virtual
176 * ports has a unique presense on the SAN, and may be instantiated via
177 * NPIV, Virtual Fabrics, or via additional ALPAs. As the vport is a
178 * unique presense, each vport has it's own view of the fabric,
179 * authentication priviledge, and priorities.
180 *
181 * A virtual port may support 1 or more FC4 roles. Typically it is a
182 * FCP Initiator. It could be a FCP Target, or exist sole for an IP over FC
183 * roles. FC port attributes for the vport will be reported on any
184 * fc_host class object allocated for an FCP Initiator.
185 *
186 * --
187 *
188 * Fixed attributes are not expected to change. The driver is
189 * expected to set these values after receiving the fc_vport structure
190 * via the vport_create() call from the transport.
191 * The transport fully manages all get functions w/o driver interaction.
192 *
193 * Dynamic attributes are expected to change. The driver participates
194 * in all get/set operations via functions provided by the driver.
195 *
196 * Private attributes are transport-managed values. They are fully
197 * managed by the transport w/o driver interaction.
198 */
136 199
200#define FC_VPORT_SYMBOLIC_NAMELEN 64
201struct fc_vport {
202 /* Fixed Attributes */
203
204 /* Dynamic Attributes */
205
206 /* Private (Transport-managed) Attributes */
207 enum fc_vport_state vport_state;
208 enum fc_vport_state vport_last_state;
209 u64 node_name;
210 u64 port_name;
211 u32 roles;
212 u32 vport_id; /* Admin Identifier for the vport */
213 enum fc_port_type vport_type;
214 char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
215
216 /* exported data */
217 void *dd_data; /* Used for driver-specific storage */
218
219 /* internal data */
220 struct Scsi_Host *shost; /* Physical Port Parent */
221 unsigned int channel;
222 u32 number;
223 u8 flags;
224 struct list_head peers;
225 struct device dev;
226 struct work_struct vport_delete_work;
227} __attribute__((aligned(sizeof(unsigned long))));
228
229/* bit field values for struct fc_vport "flags" field: */
230#define FC_VPORT_CREATING 0x01
231#define FC_VPORT_DELETING 0x02
232#define FC_VPORT_DELETED 0x04
233#define FC_VPORT_DEL 0x06 /* Any DELETE state */
234
235#define dev_to_vport(d) \
236 container_of(d, struct fc_vport, dev)
237#define transport_class_to_vport(classdev) \
238 dev_to_vport(classdev->dev)
239#define vport_to_shost(v) \
240 (v->shost)
241#define vport_to_shost_channel(v) \
242 (v->channel)
243#define vport_to_parent(v) \
244 (v->dev.parent)
245
246
247/* Error return codes for vport_create() callback */
248#define VPCERR_UNSUPPORTED -ENOSYS /* no driver/adapter
249 support */
250#define VPCERR_BAD_WWN -ENOTUNIQ /* driver validation
251 of WWNs failed */
252#define VPCERR_NO_FABRIC_SUPP -EOPNOTSUPP /* Fabric connection
253 is loop or the
254 Fabric Port does
255 not support NPIV */
137 256
138/* 257/*
139 * fc_rport_identifiers: This set of data contains all elements 258 * fc_rport_identifiers: This set of data contains all elements
@@ -149,6 +268,7 @@ struct fc_rport_identifiers {
149 u32 roles; 268 u32 roles;
150}; 269};
151 270
271
152/* Macro for use in defining Remote Port attributes */ 272/* Macro for use in defining Remote Port attributes */
153#define FC_RPORT_ATTR(_name,_mode,_show,_store) \ 273#define FC_RPORT_ATTR(_name,_mode,_show,_store) \
154struct class_device_attribute class_device_attr_rport_##_name = \ 274struct class_device_attribute class_device_attr_rport_##_name = \
@@ -278,7 +398,7 @@ struct fc_host_statistics {
278 u64 prim_seq_protocol_err_count; 398 u64 prim_seq_protocol_err_count;
279 u64 invalid_tx_word_count; 399 u64 invalid_tx_word_count;
280 u64 invalid_crc_count; 400 u64 invalid_crc_count;
281 401
282 /* fc4 statistics (only FCP supported currently) */ 402 /* fc4 statistics (only FCP supported currently) */
283 u64 fcp_input_requests; 403 u64 fcp_input_requests;
284 u64 fcp_output_requests; 404 u64 fcp_output_requests;
@@ -343,6 +463,7 @@ struct fc_host_attrs {
343 u8 supported_fc4s[FC_FC4_LIST_SIZE]; 463 u8 supported_fc4s[FC_FC4_LIST_SIZE];
344 u32 supported_speeds; 464 u32 supported_speeds;
345 u32 maxframe_size; 465 u32 maxframe_size;
466 u16 max_npiv_vports;
346 char serial_number[FC_SERIAL_NUMBER_SIZE]; 467 char serial_number[FC_SERIAL_NUMBER_SIZE];
347 468
348 /* Dynamic Attributes */ 469 /* Dynamic Attributes */
@@ -361,8 +482,11 @@ struct fc_host_attrs {
361 /* internal data */ 482 /* internal data */
362 struct list_head rports; 483 struct list_head rports;
363 struct list_head rport_bindings; 484 struct list_head rport_bindings;
485 struct list_head vports;
364 u32 next_rport_number; 486 u32 next_rport_number;
365 u32 next_target_id; 487 u32 next_target_id;
488 u32 next_vport_number;
489 u16 npiv_vports_inuse;
366 490
367 /* work queues for rport state manipulation */ 491 /* work queues for rport state manipulation */
368 char work_q_name[KOBJ_NAME_LEN]; 492 char work_q_name[KOBJ_NAME_LEN];
@@ -388,6 +512,8 @@ struct fc_host_attrs {
388 (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds) 512 (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)
389#define fc_host_maxframe_size(x) \ 513#define fc_host_maxframe_size(x) \
390 (((struct fc_host_attrs *)(x)->shost_data)->maxframe_size) 514 (((struct fc_host_attrs *)(x)->shost_data)->maxframe_size)
515#define fc_host_max_npiv_vports(x) \
516 (((struct fc_host_attrs *)(x)->shost_data)->max_npiv_vports)
391#define fc_host_serial_number(x) \ 517#define fc_host_serial_number(x) \
392 (((struct fc_host_attrs *)(x)->shost_data)->serial_number) 518 (((struct fc_host_attrs *)(x)->shost_data)->serial_number)
393#define fc_host_port_id(x) \ 519#define fc_host_port_id(x) \
@@ -412,10 +538,16 @@ struct fc_host_attrs {
412 (((struct fc_host_attrs *)(x)->shost_data)->rports) 538 (((struct fc_host_attrs *)(x)->shost_data)->rports)
413#define fc_host_rport_bindings(x) \ 539#define fc_host_rport_bindings(x) \
414 (((struct fc_host_attrs *)(x)->shost_data)->rport_bindings) 540 (((struct fc_host_attrs *)(x)->shost_data)->rport_bindings)
541#define fc_host_vports(x) \
542 (((struct fc_host_attrs *)(x)->shost_data)->vports)
415#define fc_host_next_rport_number(x) \ 543#define fc_host_next_rport_number(x) \
416 (((struct fc_host_attrs *)(x)->shost_data)->next_rport_number) 544 (((struct fc_host_attrs *)(x)->shost_data)->next_rport_number)
417#define fc_host_next_target_id(x) \ 545#define fc_host_next_target_id(x) \
418 (((struct fc_host_attrs *)(x)->shost_data)->next_target_id) 546 (((struct fc_host_attrs *)(x)->shost_data)->next_target_id)
547#define fc_host_next_vport_number(x) \
548 (((struct fc_host_attrs *)(x)->shost_data)->next_vport_number)
549#define fc_host_npiv_vports_inuse(x) \
550 (((struct fc_host_attrs *)(x)->shost_data)->npiv_vports_inuse)
419#define fc_host_work_q_name(x) \ 551#define fc_host_work_q_name(x) \
420 (((struct fc_host_attrs *)(x)->shost_data)->work_q_name) 552 (((struct fc_host_attrs *)(x)->shost_data)->work_q_name)
421#define fc_host_work_q(x) \ 553#define fc_host_work_q(x) \
@@ -452,14 +584,20 @@ struct fc_function_template {
452 void (*dev_loss_tmo_callbk)(struct fc_rport *); 584 void (*dev_loss_tmo_callbk)(struct fc_rport *);
453 void (*terminate_rport_io)(struct fc_rport *); 585 void (*terminate_rport_io)(struct fc_rport *);
454 586
587 void (*set_vport_symbolic_name)(struct fc_vport *);
588 int (*vport_create)(struct fc_vport *, bool);
589 int (*vport_disable)(struct fc_vport *, bool);
590 int (*vport_delete)(struct fc_vport *);
591
455 /* allocation lengths for host-specific data */ 592 /* allocation lengths for host-specific data */
456 u32 dd_fcrport_size; 593 u32 dd_fcrport_size;
594 u32 dd_fcvport_size;
457 595
458 /* 596 /*
459 * The driver sets these to tell the transport class it 597 * The driver sets these to tell the transport class it
460 * wants the attributes displayed in sysfs. If the show_ flag 598 * wants the attributes displayed in sysfs. If the show_ flag
461 * is not set, the attribute will be private to the transport 599 * is not set, the attribute will be private to the transport
462 * class 600 * class
463 */ 601 */
464 602
465 /* remote port fixed attributes */ 603 /* remote port fixed attributes */
@@ -512,7 +650,7 @@ fc_remote_port_chkready(struct fc_rport *rport)
512 650
513 switch (rport->port_state) { 651 switch (rport->port_state) {
514 case FC_PORTSTATE_ONLINE: 652 case FC_PORTSTATE_ONLINE:
515 if (rport->roles & FC_RPORT_ROLE_FCP_TARGET) 653 if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
516 result = 0; 654 result = 0;
517 else if (rport->flags & FC_RPORT_DEVLOSS_PENDING) 655 else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
518 result = DID_IMM_RETRY << 16; 656 result = DID_IMM_RETRY << 16;
@@ -549,6 +687,27 @@ static inline void u64_to_wwn(u64 inm, u8 *wwn)
549 wwn[7] = inm & 0xff; 687 wwn[7] = inm & 0xff;
550} 688}
551 689
690/**
691 * fc_vport_set_state() - called to set a vport's state. Saves the old state,
692 * excepting the transitory states of initializing and sending the ELS
693 * traffic to instantiate the vport on the link.
694 *
695 * Assumes the driver has surrounded this with the proper locking to ensure
696 * a coherent state change.
697 *
698 * @vport: virtual port whose state is changing
699 * @new_state: new state
700 **/
701static inline void
702fc_vport_set_state(struct fc_vport *vport, enum fc_vport_state new_state)
703{
704 if ((new_state != FC_VPORT_UNKNOWN) &&
705 (new_state != FC_VPORT_INITIALIZING))
706 vport->vport_last_state = vport->vport_state;
707 vport->vport_state = new_state;
708}
709
710
552struct scsi_transport_template *fc_attach_transport( 711struct scsi_transport_template *fc_attach_transport(
553 struct fc_function_template *); 712 struct fc_function_template *);
554void fc_release_transport(struct scsi_transport_template *); 713void fc_release_transport(struct scsi_transport_template *);
@@ -567,5 +726,6 @@ void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
567 * be sure to read the Vendor Type and ID formatting requirements 726 * be sure to read the Vendor Type and ID formatting requirements
568 * specified in scsi_netlink.h 727 * specified in scsi_netlink.h
569 */ 728 */
729int fc_vport_terminate(struct fc_vport *vport);
570 730
571#endif /* SCSI_TRANSPORT_FC_H */ 731#endif /* SCSI_TRANSPORT_FC_H */
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index d5c218ddc527..706c0cd36c14 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -79,7 +79,8 @@ struct iscsi_transport {
79 char *name; 79 char *name;
80 unsigned int caps; 80 unsigned int caps;
81 /* LLD sets this to indicate what values it can export to sysfs */ 81 /* LLD sets this to indicate what values it can export to sysfs */
82 unsigned int param_mask; 82 uint64_t param_mask;
83 uint64_t host_param_mask;
83 struct scsi_host_template *host_template; 84 struct scsi_host_template *host_template;
84 /* LLD connection data size */ 85 /* LLD connection data size */
85 int conndata_size; 86 int conndata_size;
@@ -89,7 +90,8 @@ struct iscsi_transport {
89 unsigned int max_conn; 90 unsigned int max_conn;
90 unsigned int max_cmd_len; 91 unsigned int max_cmd_len;
91 struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it, 92 struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it,
92 struct scsi_transport_template *t, uint32_t sn, uint32_t *hn); 93 struct scsi_transport_template *t, uint16_t, uint16_t,
94 uint32_t sn, uint32_t *hn);
93 void (*destroy_session) (struct iscsi_cls_session *session); 95 void (*destroy_session) (struct iscsi_cls_session *session);
94 struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, 96 struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess,
95 uint32_t cid); 97 uint32_t cid);
@@ -105,14 +107,18 @@ struct iscsi_transport {
105 enum iscsi_param param, char *buf); 107 enum iscsi_param param, char *buf);
106 int (*get_session_param) (struct iscsi_cls_session *session, 108 int (*get_session_param) (struct iscsi_cls_session *session,
107 enum iscsi_param param, char *buf); 109 enum iscsi_param param, char *buf);
110 int (*get_host_param) (struct Scsi_Host *shost,
111 enum iscsi_host_param param, char *buf);
112 int (*set_host_param) (struct Scsi_Host *shost,
113 enum iscsi_host_param param, char *buf,
114 int buflen);
108 int (*send_pdu) (struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, 115 int (*send_pdu) (struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
109 char *data, uint32_t data_size); 116 char *data, uint32_t data_size);
110 void (*get_stats) (struct iscsi_cls_conn *conn, 117 void (*get_stats) (struct iscsi_cls_conn *conn,
111 struct iscsi_stats *stats); 118 struct iscsi_stats *stats);
112 void (*init_cmd_task) (struct iscsi_cmd_task *ctask); 119 void (*init_cmd_task) (struct iscsi_cmd_task *ctask);
113 void (*init_mgmt_task) (struct iscsi_conn *conn, 120 void (*init_mgmt_task) (struct iscsi_conn *conn,
114 struct iscsi_mgmt_task *mtask, 121 struct iscsi_mgmt_task *mtask);
115 char *data, uint32_t data_size);
116 int (*xmit_cmd_task) (struct iscsi_conn *conn, 122 int (*xmit_cmd_task) (struct iscsi_conn *conn,
117 struct iscsi_cmd_task *ctask); 123 struct iscsi_cmd_task *ctask);
118 void (*cleanup_cmd_task) (struct iscsi_conn *conn, 124 void (*cleanup_cmd_task) (struct iscsi_conn *conn,
@@ -124,7 +130,7 @@ struct iscsi_transport {
124 uint64_t *ep_handle); 130 uint64_t *ep_handle);
125 int (*ep_poll) (uint64_t ep_handle, int timeout_ms); 131 int (*ep_poll) (uint64_t ep_handle, int timeout_ms);
126 void (*ep_disconnect) (uint64_t ep_handle); 132 void (*ep_disconnect) (uint64_t ep_handle);
127 int (*tgt_dscvr) (enum iscsi_tgt_dscvr type, uint32_t host_no, 133 int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type,
128 uint32_t enable, struct sockaddr *dst_addr); 134 uint32_t enable, struct sockaddr *dst_addr);
129}; 135};
130 136