aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/iscsi_if.h2
-rw-r--r--include/scsi/libiscsi.h15
-rw-r--r--include/scsi/scsi.h23
-rw-r--r--include/scsi/scsi_cmnd.h89
-rw-r--r--include/scsi/scsi_device.h49
-rw-r--r--include/scsi/scsi_dh.h11
-rw-r--r--include/scsi/scsi_eh.h2
-rw-r--r--include/scsi/scsi_host.h97
-rw-r--r--include/scsi/scsi_ioctl.h2
-rw-r--r--include/scsi/scsi_netlink.h62
-rw-r--r--include/scsi/scsi_transport.h3
-rw-r--r--include/scsi/scsi_transport_fc.h35
-rw-r--r--include/scsi/scsi_transport_iscsi.h7
13 files changed, 367 insertions, 30 deletions
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 16be12f1cbe8..0c9514de5df7 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -213,6 +213,8 @@ enum iscsi_err {
213 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15, 213 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
214 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16, 214 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
215 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17, 215 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
216 ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
217 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
216}; 218};
217 219
218/* 220/*
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 5e75bb7f311c..61e53f14f7e1 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -287,6 +287,11 @@ struct iscsi_session {
287 struct iscsi_pool cmdpool; /* PDU's pool */ 287 struct iscsi_pool cmdpool; /* PDU's pool */
288}; 288};
289 289
290enum {
291 ISCSI_HOST_SETUP,
292 ISCSI_HOST_REMOVED,
293};
294
290struct iscsi_host { 295struct iscsi_host {
291 char *initiatorname; 296 char *initiatorname;
292 /* hw address or netdev iscsi connection is bound to */ 297 /* hw address or netdev iscsi connection is bound to */
@@ -295,6 +300,12 @@ struct iscsi_host {
295 /* local address */ 300 /* local address */
296 int local_port; 301 int local_port;
297 char local_address[ISCSI_ADDRESS_BUF_LEN]; 302 char local_address[ISCSI_ADDRESS_BUF_LEN];
303
304 wait_queue_head_t session_removal_wq;
305 /* protects sessions and state */
306 spinlock_t lock;
307 int num_sessions;
308 int state;
298}; 309};
299 310
300/* 311/*
@@ -302,7 +313,7 @@ struct iscsi_host {
302 */ 313 */
303extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth); 314extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth);
304extern int iscsi_eh_abort(struct scsi_cmnd *sc); 315extern int iscsi_eh_abort(struct scsi_cmnd *sc);
305extern int iscsi_eh_host_reset(struct scsi_cmnd *sc); 316extern int iscsi_eh_target_reset(struct scsi_cmnd *sc);
306extern int iscsi_eh_device_reset(struct scsi_cmnd *sc); 317extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
307extern int iscsi_queuecommand(struct scsi_cmnd *sc, 318extern int iscsi_queuecommand(struct scsi_cmnd *sc,
308 void (*done)(struct scsi_cmnd *)); 319 void (*done)(struct scsi_cmnd *));
@@ -351,6 +362,8 @@ extern void iscsi_conn_stop(struct iscsi_cls_conn *, int);
351extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *, 362extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
352 int); 363 int);
353extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err); 364extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err);
365extern void iscsi_session_failure(struct iscsi_cls_session *cls_session,
366 enum iscsi_err err);
354extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, 367extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
355 enum iscsi_param param, char *buf); 368 enum iscsi_param param, char *buf);
356extern void iscsi_suspend_tx(struct iscsi_conn *conn); 369extern void iscsi_suspend_tx(struct iscsi_conn *conn);
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 00137a7769ee..a109165714d6 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -106,6 +106,7 @@
106#define VARIABLE_LENGTH_CMD 0x7f 106#define VARIABLE_LENGTH_CMD 0x7f
107#define REPORT_LUNS 0xa0 107#define REPORT_LUNS 0xa0
108#define MAINTENANCE_IN 0xa3 108#define MAINTENANCE_IN 0xa3
109#define MAINTENANCE_OUT 0xa4
109#define MOVE_MEDIUM 0xa5 110#define MOVE_MEDIUM 0xa5
110#define EXCHANGE_MEDIUM 0xa6 111#define EXCHANGE_MEDIUM 0xa6
111#define READ_12 0xa8 112#define READ_12 0xa8
@@ -125,6 +126,8 @@
125#define SAI_READ_CAPACITY_16 0x10 126#define SAI_READ_CAPACITY_16 0x10
126/* values for maintenance in */ 127/* values for maintenance in */
127#define MI_REPORT_TARGET_PGS 0x0a 128#define MI_REPORT_TARGET_PGS 0x0a
129/* values for maintenance out */
130#define MO_SET_TARGET_PGS 0x0a
128 131
129/* Values for T10/04-262r7 */ 132/* Values for T10/04-262r7 */
130#define ATA_16 0x85 /* 16-byte pass-thru */ 133#define ATA_16 0x85 /* 16-byte pass-thru */
@@ -306,6 +309,20 @@ struct scsi_lun {
306}; 309};
307 310
308/* 311/*
312 * The Well Known LUNS (SAM-3) in our int representation of a LUN
313 */
314#define SCSI_W_LUN_BASE 0xc100
315#define SCSI_W_LUN_REPORT_LUNS (SCSI_W_LUN_BASE + 1)
316#define SCSI_W_LUN_ACCESS_CONTROL (SCSI_W_LUN_BASE + 2)
317#define SCSI_W_LUN_TARGET_LOG_PAGE (SCSI_W_LUN_BASE + 3)
318
319static inline int scsi_is_wlun(unsigned int lun)
320{
321 return (lun & 0xff00) == SCSI_W_LUN_BASE;
322}
323
324
325/*
309 * MESSAGE CODES 326 * MESSAGE CODES
310 */ 327 */
311 328
@@ -364,6 +381,11 @@ struct scsi_lun {
364#define DID_IMM_RETRY 0x0c /* Retry without decrementing retry count */ 381#define DID_IMM_RETRY 0x0c /* Retry without decrementing retry count */
365#define DID_REQUEUE 0x0d /* Requeue command (no immediate retry) also 382#define DID_REQUEUE 0x0d /* Requeue command (no immediate retry) also
366 * without decrementing the retry count */ 383 * without decrementing the retry count */
384#define DID_TRANSPORT_DISRUPTED 0x0e /* Transport error disrupted execution
385 * and the driver blocked the port to
386 * recover the link. Transport class will
387 * retry or fail IO */
388#define DID_TRANSPORT_FAILFAST 0x0f /* Transport class fastfailed the io */
367#define DRIVER_OK 0x00 /* Driver status */ 389#define DRIVER_OK 0x00 /* Driver status */
368 390
369/* 391/*
@@ -409,6 +431,7 @@ struct scsi_lun {
409#define SCSI_MLQUEUE_HOST_BUSY 0x1055 431#define SCSI_MLQUEUE_HOST_BUSY 0x1055
410#define SCSI_MLQUEUE_DEVICE_BUSY 0x1056 432#define SCSI_MLQUEUE_DEVICE_BUSY 0x1056
411#define SCSI_MLQUEUE_EH_RETRY 0x1057 433#define SCSI_MLQUEUE_EH_RETRY 0x1057
434#define SCSI_MLQUEUE_TARGET_BUSY 0x1058
412 435
413/* 436/*
414 * Use these to separate status msg and our bytes 437 * Use these to separate status msg and our bytes
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 66c944849d6b..855bf95963e7 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -75,7 +75,9 @@ struct scsi_cmnd {
75 75
76 int retries; 76 int retries;
77 int allowed; 77 int allowed;
78 int timeout_per_command; 78
79 unsigned char prot_op;
80 unsigned char prot_type;
79 81
80 unsigned short cmd_len; 82 unsigned short cmd_len;
81 enum dma_data_direction sc_data_direction; 83 enum dma_data_direction sc_data_direction;
@@ -83,10 +85,11 @@ struct scsi_cmnd {
83 /* These elements define the operation we are about to perform */ 85 /* These elements define the operation we are about to perform */
84 unsigned char *cmnd; 86 unsigned char *cmnd;
85 87
86 struct timer_list eh_timeout; /* Used to time out the command. */
87 88
88 /* These elements define the operation we ultimately want to perform */ 89 /* These elements define the operation we ultimately want to perform */
89 struct scsi_data_buffer sdb; 90 struct scsi_data_buffer sdb;
91 struct scsi_data_buffer *prot_sdb;
92
90 unsigned underflow; /* Return error if less than 93 unsigned underflow; /* Return error if less than
91 this amount is transferred */ 94 this amount is transferred */
92 95
@@ -134,7 +137,6 @@ extern void scsi_put_command(struct scsi_cmnd *);
134extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *, 137extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *,
135 struct device *); 138 struct device *);
136extern void scsi_finish_command(struct scsi_cmnd *cmd); 139extern void scsi_finish_command(struct scsi_cmnd *cmd);
137extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
138 140
139extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, 141extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
140 size_t *offset, size_t *len); 142 size_t *offset, size_t *len);
@@ -208,4 +210,85 @@ static inline int scsi_sg_copy_to_buffer(struct scsi_cmnd *cmd,
208 buf, buflen); 210 buf, buflen);
209} 211}
210 212
213/*
214 * The operations below are hints that tell the controller driver how
215 * to handle I/Os with DIF or similar types of protection information.
216 */
217enum scsi_prot_operations {
218 /* Normal I/O */
219 SCSI_PROT_NORMAL = 0,
220
221 /* OS-HBA: Protected, HBA-Target: Unprotected */
222 SCSI_PROT_READ_INSERT,
223 SCSI_PROT_WRITE_STRIP,
224
225 /* OS-HBA: Unprotected, HBA-Target: Protected */
226 SCSI_PROT_READ_STRIP,
227 SCSI_PROT_WRITE_INSERT,
228
229 /* OS-HBA: Protected, HBA-Target: Protected */
230 SCSI_PROT_READ_PASS,
231 SCSI_PROT_WRITE_PASS,
232
233 /* OS-HBA: Protected, HBA-Target: Protected, checksum conversion */
234 SCSI_PROT_READ_CONVERT,
235 SCSI_PROT_WRITE_CONVERT,
236};
237
238static inline void scsi_set_prot_op(struct scsi_cmnd *scmd, unsigned char op)
239{
240 scmd->prot_op = op;
241}
242
243static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd)
244{
245 return scmd->prot_op;
246}
247
248/*
249 * The controller usually does not know anything about the target it
250 * is communicating with. However, when DIX is enabled the controller
251 * must be know target type so it can verify the protection
252 * information passed along with the I/O.
253 */
254enum scsi_prot_target_type {
255 SCSI_PROT_DIF_TYPE0 = 0,
256 SCSI_PROT_DIF_TYPE1,
257 SCSI_PROT_DIF_TYPE2,
258 SCSI_PROT_DIF_TYPE3,
259};
260
261static inline void scsi_set_prot_type(struct scsi_cmnd *scmd, unsigned char type)
262{
263 scmd->prot_type = type;
264}
265
266static inline unsigned char scsi_get_prot_type(struct scsi_cmnd *scmd)
267{
268 return scmd->prot_type;
269}
270
271static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
272{
273 return scmd->request->sector;
274}
275
276static inline unsigned scsi_prot_sg_count(struct scsi_cmnd *cmd)
277{
278 return cmd->prot_sdb ? cmd->prot_sdb->table.nents : 0;
279}
280
281static inline struct scatterlist *scsi_prot_sglist(struct scsi_cmnd *cmd)
282{
283 return cmd->prot_sdb ? cmd->prot_sdb->table.sgl : NULL;
284}
285
286static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)
287{
288 return cmd->prot_sdb;
289}
290
291#define scsi_for_each_prot_sg(cmd, sg, nseg, __i) \
292 for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i)
293
211#endif /* _SCSI_SCSI_CMND_H */ 294#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 6467f78b191f..a37a8148a310 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -6,6 +6,7 @@
6#include <linux/spinlock.h> 6#include <linux/spinlock.h>
7#include <linux/workqueue.h> 7#include <linux/workqueue.h>
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <scsi/scsi.h>
9#include <asm/atomic.h> 10#include <asm/atomic.h>
10 11
11struct request_queue; 12struct request_queue;
@@ -41,9 +42,11 @@ enum scsi_device_state {
41 * originate in the mid-layer) */ 42 * originate in the mid-layer) */
42 SDEV_OFFLINE, /* Device offlined (by error handling or 43 SDEV_OFFLINE, /* Device offlined (by error handling or
43 * user request */ 44 * user request */
44 SDEV_BLOCK, /* Device blocked by scsi lld. No scsi 45 SDEV_BLOCK, /* Device blocked by scsi lld. No
45 * commands from user or midlayer should be issued 46 * scsi commands from user or midlayer
46 * to the scsi lld. */ 47 * should be issued to the scsi
48 * lld. */
49 SDEV_CREATED_BLOCK, /* same as above but for created devices */
47}; 50};
48 51
49enum scsi_device_event { 52enum scsi_device_event {
@@ -140,7 +143,8 @@ struct scsi_device {
140 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ 143 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */
141 unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */ 144 unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */
142 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ 145 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */
143 unsigned last_sector_bug:1; /* Always read last sector in a 1 sector read */ 146 unsigned last_sector_bug:1; /* do not use multisector accesses on
147 SD_LAST_BUGGY_SECTORS */
144 148
145 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ 149 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
146 struct list_head event_list; /* asserted events */ 150 struct list_head event_list; /* asserted events */
@@ -167,15 +171,22 @@ struct scsi_device {
167 unsigned long sdev_data[0]; 171 unsigned long sdev_data[0];
168} __attribute__((aligned(sizeof(unsigned long)))); 172} __attribute__((aligned(sizeof(unsigned long))));
169 173
174struct scsi_dh_devlist {
175 char *vendor;
176 char *model;
177};
178
170struct scsi_device_handler { 179struct scsi_device_handler {
171 /* Used by the infrastructure */ 180 /* Used by the infrastructure */
172 struct list_head list; /* list of scsi_device_handlers */ 181 struct list_head list; /* list of scsi_device_handlers */
173 struct notifier_block nb;
174 182
175 /* Filled by the hardware handler */ 183 /* Filled by the hardware handler */
176 struct module *module; 184 struct module *module;
177 const char *name; 185 const char *name;
186 const struct scsi_dh_devlist *devlist;
178 int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); 187 int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
188 int (*attach)(struct scsi_device *);
189 void (*detach)(struct scsi_device *);
179 int (*activate)(struct scsi_device *); 190 int (*activate)(struct scsi_device *);
180 int (*prep_fn)(struct scsi_device *, struct request *); 191 int (*prep_fn)(struct scsi_device *, struct request *);
181}; 192};
@@ -227,6 +238,16 @@ struct scsi_target {
227 * for the device at a time. */ 238 * for the device at a time. */
228 unsigned int pdt_1f_for_no_lun; /* PDT = 0x1f */ 239 unsigned int pdt_1f_for_no_lun; /* PDT = 0x1f */
229 /* means no lun present */ 240 /* means no lun present */
241 /* commands actually active on LLD. protected by host lock. */
242 unsigned int target_busy;
243 /*
244 * LLDs should set this in the slave_alloc host template callout.
245 * If set to zero then there is not limit.
246 */
247 unsigned int can_queue;
248 unsigned int target_blocked;
249 unsigned int max_target_blocked;
250#define SCSI_DEFAULT_TARGET_BLOCKED 3
230 251
231 char scsi_level; 252 char scsi_level;
232 struct execute_work ew; 253 struct execute_work ew;
@@ -375,10 +396,23 @@ static inline unsigned int sdev_id(struct scsi_device *sdev)
375#define scmd_id(scmd) sdev_id((scmd)->device) 396#define scmd_id(scmd) sdev_id((scmd)->device)
376#define scmd_channel(scmd) sdev_channel((scmd)->device) 397#define scmd_channel(scmd) sdev_channel((scmd)->device)
377 398
399/*
400 * checks for positions of the SCSI state machine
401 */
378static inline int scsi_device_online(struct scsi_device *sdev) 402static inline int scsi_device_online(struct scsi_device *sdev)
379{ 403{
380 return sdev->sdev_state != SDEV_OFFLINE; 404 return sdev->sdev_state != SDEV_OFFLINE;
381} 405}
406static inline int scsi_device_blocked(struct scsi_device *sdev)
407{
408 return sdev->sdev_state == SDEV_BLOCK ||
409 sdev->sdev_state == SDEV_CREATED_BLOCK;
410}
411static inline int scsi_device_created(struct scsi_device *sdev)
412{
413 return sdev->sdev_state == SDEV_CREATED ||
414 sdev->sdev_state == SDEV_CREATED_BLOCK;
415}
382 416
383/* accessor functions for the SCSI parameters */ 417/* accessor functions for the SCSI parameters */
384static inline int scsi_device_sync(struct scsi_device *sdev) 418static inline int scsi_device_sync(struct scsi_device *sdev)
@@ -416,6 +450,11 @@ static inline int scsi_device_enclosure(struct scsi_device *sdev)
416 return sdev->inquiry[6] & (1<<6); 450 return sdev->inquiry[6] & (1<<6);
417} 451}
418 452
453static inline int scsi_device_protection(struct scsi_device *sdev)
454{
455 return sdev->scsi_level > SCSI_2 && sdev->inquiry[5] & (1<<0);
456}
457
419#define MODULE_ALIAS_SCSI_DEVICE(type) \ 458#define MODULE_ALIAS_SCSI_DEVICE(type) \
420 MODULE_ALIAS("scsi:t-" __stringify(type) "*") 459 MODULE_ALIAS("scsi:t-" __stringify(type) "*")
421#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" 460#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
diff --git a/include/scsi/scsi_dh.h b/include/scsi/scsi_dh.h
index 3ad2303d1a16..33efce20c26c 100644
--- a/include/scsi/scsi_dh.h
+++ b/include/scsi/scsi_dh.h
@@ -32,6 +32,7 @@ enum {
32 */ 32 */
33 SCSI_DH_DEV_FAILED, /* generic device error */ 33 SCSI_DH_DEV_FAILED, /* generic device error */
34 SCSI_DH_DEV_TEMP_BUSY, 34 SCSI_DH_DEV_TEMP_BUSY,
35 SCSI_DH_DEV_UNSUPP, /* device handler not supported */
35 SCSI_DH_DEVICE_MAX, /* max device blkerr definition */ 36 SCSI_DH_DEVICE_MAX, /* max device blkerr definition */
36 37
37 /* 38 /*
@@ -57,6 +58,8 @@ enum {
57#if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE) 58#if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE)
58extern int scsi_dh_activate(struct request_queue *); 59extern int scsi_dh_activate(struct request_queue *);
59extern int scsi_dh_handler_exist(const char *); 60extern int scsi_dh_handler_exist(const char *);
61extern int scsi_dh_attach(struct request_queue *, const char *);
62extern void scsi_dh_detach(struct request_queue *);
60#else 63#else
61static inline int scsi_dh_activate(struct request_queue *req) 64static inline int scsi_dh_activate(struct request_queue *req)
62{ 65{
@@ -66,4 +69,12 @@ static inline int scsi_dh_handler_exist(const char *name)
66{ 69{
67 return 0; 70 return 0;
68} 71}
72static inline int scsi_dh_attach(struct request_queue *req, const char *name)
73{
74 return SCSI_DH_NOSYS;
75}
76static inline void scsi_dh_detach(struct request_queue *q)
77{
78 return;
79}
69#endif 80#endif
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 2a9add21267d..06a8790893ef 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -74,7 +74,9 @@ struct scsi_eh_save {
74 /* saved state */ 74 /* saved state */
75 int result; 75 int result;
76 enum dma_data_direction data_direction; 76 enum dma_data_direction data_direction;
77 unsigned underflow;
77 unsigned char cmd_len; 78 unsigned char cmd_len;
79 unsigned char prot_op;
78 unsigned char *cmnd; 80 unsigned char *cmnd;
79 struct scsi_data_buffer sdb; 81 struct scsi_data_buffer sdb;
80 struct request *next_rq; 82 struct request *next_rq;
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 1834fdfe82a7..d123ca84e732 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -43,13 +43,6 @@ struct blk_queue_tags;
43#define DISABLE_CLUSTERING 0 43#define DISABLE_CLUSTERING 0
44#define ENABLE_CLUSTERING 1 44#define ENABLE_CLUSTERING 1
45 45
46enum scsi_eh_timer_return {
47 EH_NOT_HANDLED,
48 EH_HANDLED,
49 EH_RESET_TIMER,
50};
51
52
53struct scsi_host_template { 46struct scsi_host_template {
54 struct module *module; 47 struct module *module;
55 const char *name; 48 const char *name;
@@ -347,7 +340,7 @@ struct scsi_host_template {
347 * 340 *
348 * Status: OPTIONAL 341 * Status: OPTIONAL
349 */ 342 */
350 enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *); 343 enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *);
351 344
352 /* 345 /*
353 * Name of proc directory 346 * Name of proc directory
@@ -547,7 +540,7 @@ struct Scsi_Host {
547 unsigned int host_failed; /* commands that failed. */ 540 unsigned int host_failed; /* commands that failed. */
548 unsigned int host_eh_scheduled; /* EH scheduled without command */ 541 unsigned int host_eh_scheduled; /* EH scheduled without command */
549 542
550 unsigned short host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */ 543 unsigned int host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */
551 int resetting; /* if set, it means that last_reset is a valid value */ 544 int resetting; /* if set, it means that last_reset is a valid value */
552 unsigned long last_reset; 545 unsigned long last_reset;
553 546
@@ -623,7 +616,7 @@ struct Scsi_Host {
623 /* 616 /*
624 * Optional work queue to be utilized by the transport 617 * Optional work queue to be utilized by the transport
625 */ 618 */
626 char work_q_name[KOBJ_NAME_LEN]; 619 char work_q_name[20];
627 struct workqueue_struct *work_q; 620 struct workqueue_struct *work_q;
628 621
629 /* 622 /*
@@ -636,6 +629,10 @@ struct Scsi_Host {
636 */ 629 */
637 unsigned int max_host_blocked; 630 unsigned int max_host_blocked;
638 631
632 /* Protection Information */
633 unsigned int prot_capabilities;
634 unsigned char prot_guard_type;
635
639 /* 636 /*
640 * q used for scsi_tgt msgs, async events or any other requests that 637 * q used for scsi_tgt msgs, async events or any other requests that
641 * need to be processed in userspace 638 * need to be processed in userspace
@@ -756,6 +753,86 @@ extern struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
756extern void scsi_free_host_dev(struct scsi_device *); 753extern void scsi_free_host_dev(struct scsi_device *);
757extern struct scsi_device *scsi_get_host_dev(struct Scsi_Host *); 754extern struct scsi_device *scsi_get_host_dev(struct Scsi_Host *);
758 755
756/*
757 * DIF defines the exchange of protection information between
758 * initiator and SBC block device.
759 *
760 * DIX defines the exchange of protection information between OS and
761 * initiator.
762 */
763enum scsi_host_prot_capabilities {
764 SHOST_DIF_TYPE1_PROTECTION = 1 << 0, /* T10 DIF Type 1 */
765 SHOST_DIF_TYPE2_PROTECTION = 1 << 1, /* T10 DIF Type 2 */
766 SHOST_DIF_TYPE3_PROTECTION = 1 << 2, /* T10 DIF Type 3 */
767
768 SHOST_DIX_TYPE0_PROTECTION = 1 << 3, /* DIX between OS and HBA only */
769 SHOST_DIX_TYPE1_PROTECTION = 1 << 4, /* DIX with DIF Type 1 */
770 SHOST_DIX_TYPE2_PROTECTION = 1 << 5, /* DIX with DIF Type 2 */
771 SHOST_DIX_TYPE3_PROTECTION = 1 << 6, /* DIX with DIF Type 3 */
772};
773
774/*
775 * SCSI hosts which support the Data Integrity Extensions must
776 * indicate their capabilities by setting the prot_capabilities using
777 * this call.
778 */
779static inline void scsi_host_set_prot(struct Scsi_Host *shost, unsigned int mask)
780{
781 shost->prot_capabilities = mask;
782}
783
784static inline unsigned int scsi_host_get_prot(struct Scsi_Host *shost)
785{
786 return shost->prot_capabilities;
787}
788
789static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsigned int target_type)
790{
791 switch (target_type) {
792 case 1: return shost->prot_capabilities & SHOST_DIF_TYPE1_PROTECTION;
793 case 2: return shost->prot_capabilities & SHOST_DIF_TYPE2_PROTECTION;
794 case 3: return shost->prot_capabilities & SHOST_DIF_TYPE3_PROTECTION;
795 }
796
797 return 0;
798}
799
800static inline unsigned int scsi_host_dix_capable(struct Scsi_Host *shost, unsigned int target_type)
801{
802 switch (target_type) {
803 case 0: return shost->prot_capabilities & SHOST_DIX_TYPE0_PROTECTION;
804 case 1: return shost->prot_capabilities & SHOST_DIX_TYPE1_PROTECTION;
805 case 2: return shost->prot_capabilities & SHOST_DIX_TYPE2_PROTECTION;
806 case 3: return shost->prot_capabilities & SHOST_DIX_TYPE3_PROTECTION;
807 }
808
809 return 0;
810}
811
812/*
813 * All DIX-capable initiators must support the T10-mandated CRC
814 * checksum. Controllers can optionally implement the IP checksum
815 * scheme which has much lower impact on system performance. Note
816 * that the main rationale for the checksum is to match integrity
817 * metadata with data. Detecting bit errors are a job for ECC memory
818 * and buses.
819 */
820
821enum scsi_host_guard_type {
822 SHOST_DIX_GUARD_CRC = 1 << 0,
823 SHOST_DIX_GUARD_IP = 1 << 1,
824};
825
826static inline void scsi_host_set_guard(struct Scsi_Host *shost, unsigned char type)
827{
828 shost->prot_guard_type = type;
829}
830
831static inline unsigned char scsi_host_get_guard(struct Scsi_Host *shost)
832{
833 return shost->prot_guard_type;
834}
835
759/* legacy interfaces */ 836/* legacy interfaces */
760extern struct Scsi_Host *scsi_register(struct scsi_host_template *, int); 837extern struct Scsi_Host *scsi_register(struct scsi_host_template *, int);
761extern void scsi_unregister(struct Scsi_Host *); 838extern void scsi_unregister(struct Scsi_Host *);
diff --git a/include/scsi/scsi_ioctl.h b/include/scsi/scsi_ioctl.h
index edb9525386da..b9006848b813 100644
--- a/include/scsi/scsi_ioctl.h
+++ b/include/scsi/scsi_ioctl.h
@@ -42,7 +42,7 @@ typedef struct scsi_fctargaddress {
42 42
43extern int scsi_ioctl(struct scsi_device *, int, void __user *); 43extern int scsi_ioctl(struct scsi_device *, int, void __user *);
44extern int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, 44extern int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd,
45 void __user *arg, struct file *filp); 45 void __user *arg, int ndelay);
46 46
47#endif /* __KERNEL__ */ 47#endif /* __KERNEL__ */
48#endif /* _SCSI_IOCTL_H */ 48#endif /* _SCSI_IOCTL_H */
diff --git a/include/scsi/scsi_netlink.h b/include/scsi/scsi_netlink.h
index 8c1470cc8209..536752c40d41 100644
--- a/include/scsi/scsi_netlink.h
+++ b/include/scsi/scsi_netlink.h
@@ -22,6 +22,9 @@
22#ifndef SCSI_NETLINK_H 22#ifndef SCSI_NETLINK_H
23#define SCSI_NETLINK_H 23#define SCSI_NETLINK_H
24 24
25#include <linux/netlink.h>
26
27
25/* 28/*
26 * This file intended to be included by both kernel and user space 29 * This file intended to be included by both kernel and user space
27 */ 30 */
@@ -55,7 +58,41 @@ struct scsi_nl_hdr {
55#define SCSI_NL_TRANSPORT_FC 1 58#define SCSI_NL_TRANSPORT_FC 1
56#define SCSI_NL_MAX_TRANSPORTS 2 59#define SCSI_NL_MAX_TRANSPORTS 2
57 60
58/* scsi_nl_hdr->msgtype values are defined in each transport */ 61/* Transport-based scsi_nl_hdr->msgtype values are defined in each transport */
62
63/*
64 * GENERIC SCSI scsi_nl_hdr->msgtype Values
65 */
66 /* kernel -> user */
67#define SCSI_NL_SHOST_VENDOR 0x0001
68 /* user -> kernel */
69/* SCSI_NL_SHOST_VENDOR msgtype is kernel->user and user->kernel */
70
71
72/*
73 * Message Structures :
74 */
75
76/* macro to round up message lengths to 8byte boundary */
77#define SCSI_NL_MSGALIGN(len) (((len) + 7) & ~7)
78
79
80/*
81 * SCSI HOST Vendor Unique messages :
82 * SCSI_NL_SHOST_VENDOR
83 *
84 * Note: The Vendor Unique message payload will begin directly after
85 * this structure, with the length of the payload per vmsg_datalen.
86 *
87 * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
88 * formatting requirements specified below
89 */
90struct scsi_nl_host_vendor_msg {
91 struct scsi_nl_hdr snlh; /* must be 1st element ! */
92 uint64_t vendor_id;
93 uint16_t host_no;
94 uint16_t vmsg_datalen;
95} __attribute__((aligned(sizeof(uint64_t))));
59 96
60 97
61/* 98/*
@@ -83,5 +120,28 @@ struct scsi_nl_hdr {
83 } 120 }
84 121
85 122
123#ifdef __KERNEL__
124
125#include <scsi/scsi_host.h>
126
127/* Exported Kernel Interfaces */
128int scsi_nl_add_transport(u8 tport,
129 int (*msg_handler)(struct sk_buff *),
130 void (*event_handler)(struct notifier_block *, unsigned long, void *));
131void scsi_nl_remove_transport(u8 tport);
132
133int scsi_nl_add_driver(u64 vendor_id, struct scsi_host_template *hostt,
134 int (*nlmsg_handler)(struct Scsi_Host *shost, void *payload,
135 u32 len, u32 pid),
136 void (*nlevt_handler)(struct notifier_block *nb,
137 unsigned long event, void *notify_ptr));
138void scsi_nl_remove_driver(u64 vendor_id);
139
140void scsi_nl_send_transport_msg(u32 pid, struct scsi_nl_hdr *hdr);
141int scsi_nl_send_vendor_msg(u32 pid, unsigned short host_no, u64 vendor_id,
142 char *data_buf, u32 data_len);
143
144#endif /* __KERNEL__ */
145
86#endif /* SCSI_NETLINK_H */ 146#endif /* SCSI_NETLINK_H */
87 147
diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
index 490bd13a634c..0de32cd4e8a7 100644
--- a/include/scsi/scsi_transport.h
+++ b/include/scsi/scsi_transport.h
@@ -21,6 +21,7 @@
21#define SCSI_TRANSPORT_H 21#define SCSI_TRANSPORT_H
22 22
23#include <linux/transport_class.h> 23#include <linux/transport_class.h>
24#include <linux/blkdev.h>
24#include <scsi/scsi_host.h> 25#include <scsi/scsi_host.h>
25#include <scsi/scsi_device.h> 26#include <scsi/scsi_device.h>
26 27
@@ -64,7 +65,7 @@ struct scsi_transport_template {
64 * begin counting again 65 * begin counting again
65 * EH_NOT_HANDLED Begin normal error recovery 66 * EH_NOT_HANDLED Begin normal error recovery
66 */ 67 */
67 enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *); 68 enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *);
68 69
69 /* 70 /*
70 * Used as callback for the completion of i_t_nexus request 71 * Used as callback for the completion of i_t_nexus request
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 06f72bab9df0..49d8913c4f86 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -167,6 +167,26 @@ enum fc_tgtid_binding_type {
167struct device_attribute dev_attr_vport_##_name = \ 167struct device_attribute dev_attr_vport_##_name = \
168 __ATTR(_name,_mode,_show,_store) 168 __ATTR(_name,_mode,_show,_store)
169 169
170/*
171 * fc_vport_identifiers: This set of data contains all elements
172 * to uniquely identify and instantiate a FC virtual port.
173 *
174 * Notes:
175 * symbolic_name: The driver is to append the symbolic_name string data
176 * to the symbolic_node_name data that it generates by default.
177 * the resulting combination should then be registered with the switch.
178 * It is expected that things like Xen may stuff a VM title into
179 * this field.
180 */
181#define FC_VPORT_SYMBOLIC_NAMELEN 64
182struct fc_vport_identifiers {
183 u64 node_name;
184 u64 port_name;
185 u32 roles;
186 bool disable;
187 enum fc_port_type vport_type; /* only FC_PORTTYPE_NPIV allowed */
188 char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
189};
170 190
171/* 191/*
172 * FC Virtual Port Attributes 192 * FC Virtual Port Attributes
@@ -197,7 +217,6 @@ struct device_attribute dev_attr_vport_##_name = \
197 * managed by the transport w/o driver interaction. 217 * managed by the transport w/o driver interaction.
198 */ 218 */
199 219
200#define FC_VPORT_SYMBOLIC_NAMELEN 64
201struct fc_vport { 220struct fc_vport {
202 /* Fixed Attributes */ 221 /* Fixed Attributes */
203 222
@@ -338,6 +357,7 @@ struct fc_rport { /* aka fc_starget_attrs */
338/* bit field values for struct fc_rport "flags" field: */ 357/* bit field values for struct fc_rport "flags" field: */
339#define FC_RPORT_DEVLOSS_PENDING 0x01 358#define FC_RPORT_DEVLOSS_PENDING 0x01
340#define FC_RPORT_SCAN_PENDING 0x02 359#define FC_RPORT_SCAN_PENDING 0x02
360#define FC_RPORT_FAST_FAIL_TIMEDOUT 0x03
341 361
342#define dev_to_rport(d) \ 362#define dev_to_rport(d) \
343 container_of(d, struct fc_rport, dev) 363 container_of(d, struct fc_rport, dev)
@@ -489,9 +509,9 @@ struct fc_host_attrs {
489 u16 npiv_vports_inuse; 509 u16 npiv_vports_inuse;
490 510
491 /* work queues for rport state manipulation */ 511 /* work queues for rport state manipulation */
492 char work_q_name[KOBJ_NAME_LEN]; 512 char work_q_name[20];
493 struct workqueue_struct *work_q; 513 struct workqueue_struct *work_q;
494 char devloss_work_q_name[KOBJ_NAME_LEN]; 514 char devloss_work_q_name[20];
495 struct workqueue_struct *devloss_work_q; 515 struct workqueue_struct *devloss_work_q;
496}; 516};
497 517
@@ -659,12 +679,15 @@ fc_remote_port_chkready(struct fc_rport *rport)
659 if (rport->roles & FC_PORT_ROLE_FCP_TARGET) 679 if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
660 result = 0; 680 result = 0;
661 else if (rport->flags & FC_RPORT_DEVLOSS_PENDING) 681 else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
662 result = DID_IMM_RETRY << 16; 682 result = DID_TRANSPORT_DISRUPTED << 16;
663 else 683 else
664 result = DID_NO_CONNECT << 16; 684 result = DID_NO_CONNECT << 16;
665 break; 685 break;
666 case FC_PORTSTATE_BLOCKED: 686 case FC_PORTSTATE_BLOCKED:
667 result = DID_IMM_RETRY << 16; 687 if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)
688 result = DID_TRANSPORT_FAILFAST << 16;
689 else
690 result = DID_TRANSPORT_DISRUPTED << 16;
668 break; 691 break;
669 default: 692 default:
670 result = DID_NO_CONNECT << 16; 693 result = DID_NO_CONNECT << 16;
@@ -732,6 +755,8 @@ void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
732 * be sure to read the Vendor Type and ID formatting requirements 755 * be sure to read the Vendor Type and ID formatting requirements
733 * specified in scsi_netlink.h 756 * specified in scsi_netlink.h
734 */ 757 */
758struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel,
759 struct fc_vport_identifiers *);
735int fc_vport_terminate(struct fc_vport *vport); 760int fc_vport_terminate(struct fc_vport *vport);
736 761
737#endif /* SCSI_TRANSPORT_FC_H */ 762#endif /* SCSI_TRANSPORT_FC_H */
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index f5444e033cc9..c667cc396545 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -135,7 +135,8 @@ extern int iscsi_unregister_transport(struct iscsi_transport *tt);
135/* 135/*
136 * control plane upcalls 136 * control plane upcalls
137 */ 137 */
138extern void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error); 138extern void iscsi_conn_error_event(struct iscsi_cls_conn *conn,
139 enum iscsi_err error);
139extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, 140extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
140 char *data, uint32_t data_size); 141 char *data, uint32_t data_size);
141 142
@@ -198,7 +199,7 @@ struct iscsi_cls_host {
198 atomic_t nr_scans; 199 atomic_t nr_scans;
199 struct mutex mutex; 200 struct mutex mutex;
200 struct workqueue_struct *scan_workq; 201 struct workqueue_struct *scan_workq;
201 char scan_workq_name[KOBJ_NAME_LEN]; 202 char scan_workq_name[20];
202}; 203};
203 204
204extern void iscsi_host_for_each_session(struct Scsi_Host *shost, 205extern void iscsi_host_for_each_session(struct Scsi_Host *shost,
@@ -207,7 +208,7 @@ extern void iscsi_host_for_each_session(struct Scsi_Host *shost,
207struct iscsi_endpoint { 208struct iscsi_endpoint {
208 void *dd_data; /* LLD private data */ 209 void *dd_data; /* LLD private data */
209 struct device dev; 210 struct device dev;
210 unsigned int id; 211 uint64_t id;
211}; 212};
212 213
213/* 214/*