aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/iscsi_proto.h12
-rw-r--r--include/scsi/scsi.h1
-rw-r--r--include/scsi/scsi_cmnd.h3
-rw-r--r--include/scsi/scsi_dbg.h10
-rw-r--r--include/scsi/scsi_device.h14
-rw-r--r--include/scsi/scsi_host.h32
-rw-r--r--include/scsi/scsi_tgt_if.h6
-rw-r--r--include/scsi/scsi_transport_fc.h2
-rw-r--r--include/scsi/sd.h72
9 files changed, 126 insertions, 26 deletions
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index 4a44278ed768..8d1e4e8026fe 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -588,7 +588,17 @@ struct iscsi_reject {
588#define VALUE_MAXLEN 255 588#define VALUE_MAXLEN 255
589#define TARGET_NAME_MAXLEN VALUE_MAXLEN 589#define TARGET_NAME_MAXLEN VALUE_MAXLEN
590 590
591#define DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH 8192 591#define ISCSI_DEF_MAX_RECV_SEG_LEN 8192
592#define ISCSI_MIN_MAX_RECV_SEG_LEN 512
593#define ISCSI_MAX_MAX_RECV_SEG_LEN 16777215
594
595#define ISCSI_DEF_FIRST_BURST_LEN 65536
596#define ISCSI_MIN_FIRST_BURST_LEN 512
597#define ISCSI_MAX_FIRST_BURST_LEN 16777215
598
599#define ISCSI_DEF_MAX_BURST_LEN 262144
600#define ISCSI_MIN_MAX_BURST_LEN 512
601#define ISCSI_MAX_MAX_BURST_LEN 16777215
592 602
593/************************* RFC 3720 End *****************************/ 603/************************* RFC 3720 End *****************************/
594 604
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 5c0e9791441c..9f8f80ab0c8b 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -203,6 +203,7 @@ static inline int scsi_status_is_good(int status)
203 203
204/* 204/*
205 * DEVICE TYPES 205 * DEVICE TYPES
206 * Please keep them in 0x%02x format for $MODALIAS to work
206 */ 207 */
207 208
208#define TYPE_DISK 0x00 209#define TYPE_DISK 0x00
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index d6948d0e8cdb..a2e0c1032491 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -73,9 +73,6 @@ struct scsi_cmnd {
73 unsigned short use_sg; /* Number of pieces of scatter-gather */ 73 unsigned short use_sg; /* Number of pieces of scatter-gather */
74 unsigned short sglist_len; /* size of malloc'd scatter-gather list */ 74 unsigned short sglist_len; /* size of malloc'd scatter-gather list */
75 75
76 /* offset in cmd we are at (for multi-transfer tgt cmds) */
77 unsigned offset;
78
79 unsigned underflow; /* Return error if less than 76 unsigned underflow; /* Return error if less than
80 this amount is transferred */ 77 this amount is transferred */
81 78
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 3bbbfbe8cbfc..5a43a4cd96c6 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -5,14 +5,16 @@ struct scsi_cmnd;
5struct scsi_sense_hdr; 5struct scsi_sense_hdr;
6 6
7extern void scsi_print_command(struct scsi_cmnd *); 7extern void scsi_print_command(struct scsi_cmnd *);
8extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
9extern void __scsi_print_command(unsigned char *); 8extern void __scsi_print_command(unsigned char *);
10extern void scsi_print_sense(const char *, struct scsi_cmnd *); 9extern void scsi_show_extd_sense(unsigned char, unsigned char);
10extern void scsi_show_sense_hdr(struct scsi_sense_hdr *);
11extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
12extern void scsi_print_sense(char *, struct scsi_cmnd *);
11extern void __scsi_print_sense(const char *name, 13extern void __scsi_print_sense(const char *name,
12 const unsigned char *sense_buffer, 14 const unsigned char *sense_buffer,
13 int sense_len); 15 int sense_len);
14extern void scsi_print_driverbyte(int); 16extern void scsi_show_result(int);
15extern void scsi_print_hostbyte(int); 17extern void scsi_print_result(struct scsi_cmnd *);
16extern void scsi_print_status(unsigned char); 18extern void scsi_print_status(unsigned char);
17extern const char *scsi_sense_key_string(unsigned char); 19extern const char *scsi_sense_key_string(unsigned char);
18extern const char *scsi_extd_sense_format(unsigned char, unsigned char); 20extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 9dd37e2f5a84..2f3c5b8b1d6a 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -5,6 +5,7 @@
5#include <linux/list.h> 5#include <linux/list.h>
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 <asm/atomic.h> 9#include <asm/atomic.h>
9 10
10struct request_queue; 11struct request_queue;
@@ -119,6 +120,7 @@ struct scsi_device {
119 unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ 120 unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
120 unsigned no_start_on_add:1; /* do not issue start on add */ 121 unsigned no_start_on_add:1; /* do not issue start on add */
121 unsigned allow_restart:1; /* issue START_UNIT in error handler */ 122 unsigned allow_restart:1; /* issue START_UNIT in error handler */
123 unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */
122 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ 124 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
123 unsigned select_no_atn:1; 125 unsigned select_no_atn:1;
124 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ 126 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */
@@ -154,8 +156,11 @@ struct scsi_device {
154#define sdev_printk(prefix, sdev, fmt, a...) \ 156#define sdev_printk(prefix, sdev, fmt, a...) \
155 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a) 157 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a)
156 158
157#define scmd_printk(prefix, scmd, fmt, a...) \ 159#define scmd_printk(prefix, scmd, fmt, a...) \
158 dev_printk(prefix, &(scmd)->device->sdev_gendev, fmt, ##a) 160 (scmd)->request->rq_disk ? \
161 sdev_printk(prefix, (scmd)->device, "[%s] " fmt, \
162 (scmd)->request->rq_disk->disk_name, ##a) : \
163 sdev_printk(prefix, (scmd)->device, fmt, ##a)
159 164
160enum scsi_target_state { 165enum scsi_target_state {
161 STARGET_RUNNING = 1, 166 STARGET_RUNNING = 1,
@@ -353,4 +358,9 @@ static inline int scsi_device_qas(struct scsi_device *sdev)
353 return 0; 358 return 0;
354 return sdev->inquiry[56] & 0x02; 359 return sdev->inquiry[56] & 0x02;
355} 360}
361
362#define MODULE_ALIAS_SCSI_DEVICE(type) \
363 MODULE_ALIAS("scsi:t-" __stringify(type) "*")
364#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
365
356#endif /* _SCSI_SCSI_DEVICE_H */ 366#endif /* _SCSI_SCSI_DEVICE_H */
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 7f1f411d07af..68f461b7a835 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -129,6 +129,11 @@ struct scsi_host_template {
129 * the LLD. When the driver is finished processing the command 129 * the LLD. When the driver is finished processing the command
130 * the done callback is invoked. 130 * the done callback is invoked.
131 * 131 *
132 * This is called to inform the LLD to transfer
133 * cmd->request_bufflen bytes. The cmd->use_sg speciefies the
134 * number of scatterlist entried in the command and
135 * cmd->request_buffer contains the scatterlist.
136 *
132 * return values: see queuecommand 137 * return values: see queuecommand
133 * 138 *
134 * If the LLD accepts the cmd, it should set the result to an 139 * If the LLD accepts the cmd, it should set the result to an
@@ -139,20 +144,6 @@ struct scsi_host_template {
139 /* TODO: rename */ 144 /* TODO: rename */
140 int (* transfer_response)(struct scsi_cmnd *, 145 int (* transfer_response)(struct scsi_cmnd *,
141 void (*done)(struct scsi_cmnd *)); 146 void (*done)(struct scsi_cmnd *));
142 /*
143 * This is called to inform the LLD to transfer cmd->request_bufflen
144 * bytes of the cmd at cmd->offset in the cmd. The cmd->use_sg
145 * speciefies the number of scatterlist entried in the command
146 * and cmd->request_buffer contains the scatterlist.
147 *
148 * If the command cannot be processed in one transfer_data call
149 * becuase a scatterlist within the LLD's limits cannot be
150 * created then transfer_data will be called multiple times.
151 * It is initially called from process context, and later
152 * calls are from the interrup context.
153 */
154 int (* transfer_data)(struct scsi_cmnd *,
155 void (*done)(struct scsi_cmnd *));
156 147
157 /* Used as callback for the completion of task management request. */ 148 /* Used as callback for the completion of task management request. */
158 int (* tsk_mgmt_response)(u64 mid, int result); 149 int (* tsk_mgmt_response)(u64 mid, int result);
@@ -335,6 +326,19 @@ struct scsi_host_template {
335 int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int); 326 int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int);
336 327
337 /* 328 /*
329 * This is an optional routine that allows the transport to become
330 * involved when a scsi io timer fires. The return value tells the
331 * timer routine how to finish the io timeout handling:
332 * EH_HANDLED: I fixed the error, please complete the command
333 * EH_RESET_TIMER: I need more time, reset the timer and
334 * begin counting again
335 * EH_NOT_HANDLED Begin normal error recovery
336 *
337 * Status: OPTIONAL
338 */
339 enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *);
340
341 /*
338 * suspend support 342 * suspend support
339 */ 343 */
340 int (*resume)(struct scsi_device *); 344 int (*resume)(struct scsi_device *);
diff --git a/include/scsi/scsi_tgt_if.h b/include/scsi/scsi_tgt_if.h
index 07d6e77ae895..4cf9dff29a2f 100644
--- a/include/scsi/scsi_tgt_if.h
+++ b/include/scsi/scsi_tgt_if.h
@@ -45,11 +45,13 @@ struct tgt_event {
45 /* user-> kernel */ 45 /* user-> kernel */
46 struct { 46 struct {
47 int host_no; 47 int host_no;
48 uint32_t len;
49 int result; 48 int result;
49 aligned_u64 tag;
50 aligned_u64 uaddr; 50 aligned_u64 uaddr;
51 aligned_u64 sense_uaddr;
52 uint32_t len;
53 uint32_t sense_len;
51 uint8_t rw; 54 uint8_t rw;
52 aligned_u64 tag;
53 } cmd_rsp; 55 } cmd_rsp;
54 struct { 56 struct {
55 int host_no; 57 int host_no;
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 798f7c7ee426..1e797308640a 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -108,6 +108,8 @@ enum fc_port_state {
108#define FC_PORTSPEED_2GBIT 2 108#define FC_PORTSPEED_2GBIT 2
109#define FC_PORTSPEED_4GBIT 4 109#define FC_PORTSPEED_4GBIT 4
110#define FC_PORTSPEED_10GBIT 8 110#define FC_PORTSPEED_10GBIT 8
111#define FC_PORTSPEED_8GBIT 0x10
112#define FC_PORTSPEED_16GBIT 0x20
111#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */ 113#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
112 114
113/* 115/*
diff --git a/include/scsi/sd.h b/include/scsi/sd.h
new file mode 100644
index 000000000000..5261488e1108
--- /dev/null
+++ b/include/scsi/sd.h
@@ -0,0 +1,72 @@
1#ifndef _SCSI_DISK_H
2#define _SCSI_DISK_H
3
4/*
5 * More than enough for everybody ;) The huge number of majors
6 * is a leftover from 16bit dev_t days, we don't really need that
7 * much numberspace.
8 */
9#define SD_MAJORS 16
10
11/*
12 * This is limited by the naming scheme enforced in sd_probe,
13 * add another character to it if you really need more disks.
14 */
15#define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26)
16
17/*
18 * Time out in seconds for disks and Magneto-opticals (which are slower).
19 */
20#define SD_TIMEOUT (30 * HZ)
21#define SD_MOD_TIMEOUT (75 * HZ)
22
23/*
24 * Number of allowed retries
25 */
26#define SD_MAX_RETRIES 5
27#define SD_PASSTHROUGH_RETRIES 1
28
29/*
30 * Size of the initial data buffer for mode and read capacity data
31 */
32#define SD_BUF_SIZE 512
33
34struct scsi_disk {
35 struct scsi_driver *driver; /* always &sd_template */
36 struct scsi_device *device;
37 struct class_device cdev;
38 struct gendisk *disk;
39 unsigned int openers; /* protected by BKL for now, yuck */
40 sector_t capacity; /* size in 512-byte sectors */
41 u32 index;
42 u8 media_present;
43 u8 write_prot;
44 unsigned WCE : 1; /* state of disk WCE bit */
45 unsigned RCD : 1; /* state of disk RCD bit, unused */
46 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
47};
48#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
49
50static int sd_revalidate_disk(struct gendisk *disk);
51static void sd_rw_intr(struct scsi_cmnd * SCpnt);
52static int sd_probe(struct device *);
53static int sd_remove(struct device *);
54static void sd_shutdown(struct device *dev);
55static int sd_suspend(struct device *dev, pm_message_t state);
56static int sd_resume(struct device *dev);
57static void sd_rescan(struct device *);
58static int sd_init_command(struct scsi_cmnd *);
59static int sd_issue_flush(struct device *, sector_t *);
60static void sd_prepare_flush(request_queue_t *, struct request *);
61static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
62static void scsi_disk_release(struct class_device *cdev);
63static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
64static void sd_print_result(struct scsi_disk *, int);
65
66#define sd_printk(prefix, sdsk, fmt, a...) \
67 (sdsk)->disk ? \
68 sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \
69 (sdsk)->disk->disk_name, ##a) : \
70 sdev_printk(prefix, (sdsk)->device, fmt, ##a)
71
72#endif /* _SCSI_DISK_H */