aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/sg.h
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-06-03 13:18:18 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-17 16:07:33 -0400
commit65c26a0f39695ba01d9693754f27ca76cc8a3ab5 (patch)
tree040940d590d3dafd9eb65c843526a1c4476a8063 /include/scsi/sg.h
parentbcdb247c6b6a1f3e72b9b787b73f47dd509d17ec (diff)
sg: relax 16 byte cdb restriction
- remove the 16 byte CDB (SCSI command) length limit from the sg driver by handling longer CDBs the same way as the bsg driver. Remove comment from sg.h public interface about the cmd_len field being limited to 16 bytes. - remove some dead code caused by this change - cleanup comment block at the top of sg.h, fix urls Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/scsi/sg.h')
-rw-r--r--include/scsi/sg.h91
1 files changed, 24 insertions, 67 deletions
diff --git a/include/scsi/sg.h b/include/scsi/sg.h
index a9f3c6fc3f57..d8c0c4307fca 100644
--- a/include/scsi/sg.h
+++ b/include/scsi/sg.h
@@ -4,77 +4,34 @@
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5 5
6/* 6/*
7 History: 7 * History:
8 Started: Aug 9 by Lawrence Foard (entropy@world.std.com), to allow user 8 * Started: Aug 9 by Lawrence Foard (entropy@world.std.com), to allow user
9 process control of SCSI devices. 9 * process control of SCSI devices.
10 Development Sponsored by Killy Corp. NY NY 10 * Development Sponsored by Killy Corp. NY NY
11Original driver (sg.h): 11 *
12* Copyright (C) 1992 Lawrence Foard 12 * Original driver (sg.h):
13Version 2 and 3 extensions to driver: 13 * Copyright (C) 1992 Lawrence Foard
14* Copyright (C) 1998 - 2006 Douglas Gilbert 14 * Version 2 and 3 extensions to driver:
15 15 * Copyright (C) 1998 - 2014 Douglas Gilbert
16 Version: 3.5.34 (20060920) 16 *
17 This version is for 2.6 series kernels. 17 * Version: 3.5.36 (20140603)
18 18 * This version is for 2.6 and 3 series kernels.
19 For a full changelog see http://www.torque.net/sg 19 *
20 20 * Documentation
21Map of SG verions to the Linux kernels in which they appear: 21 * =============
22 ---------- ---------------------------------- 22 * A web site for the SG device driver can be found at:
23 original all kernels < 2.2.6 23 * http://sg.danny.cz/sg [alternatively check the MAINTAINERS file]
24 2.1.40 2.2.20 24 * The documentation for the sg version 3 driver can be found at:
25 3.0.x optional version 3 sg driver for 2.2 series 25 * http://sg.danny.cz/sg/p/sg_v3_ho.html
26 3.1.17++ 2.4.0++ 26 * Also see: <kernel_source>/Documentation/scsi/scsi-generic.txt
27 3.5.30++ 2.6.0++ 27 *
28 28 * For utility and test programs see: http://sg.danny.cz/sg/sg3_utils.html
29Major new features in SG 3.x driver (cf SG 2.x drivers) 29 */
30 - SG_IO ioctl() combines function if write() and read()
31 - new interface (sg_io_hdr_t) but still supports old interface
32 - scatter/gather in user space, direct IO, and mmap supported
33
34 The normal action of this driver is to use the adapter (HBA) driver to DMA
35 data into kernel buffers and then use the CPU to copy the data into the
36 user space (vice versa for writes). That is called "indirect" IO due to
37 the double handling of data. There are two methods offered to remove the
38 redundant copy: 1) direct IO and 2) using the mmap() system call to map
39 the reserve buffer (this driver has one reserve buffer per fd) into the
40 user space. Both have their advantages.
41 In terms of absolute speed mmap() is faster. If speed is not a concern,
42 indirect IO should be fine. Read the documentation for more information.
43
44 ** N.B. To use direct IO 'echo 1 > /proc/scsi/sg/allow_dio' or
45 'echo 1 > /sys/module/sg/parameters/allow_dio' is needed.
46 That attribute is 0 by default. **
47
48 Historical note: this SCSI pass-through driver has been known as "sg" for
49 a decade. In broader kernel discussions "sg" is used to refer to scatter
50 gather techniques. The context should clarify which "sg" is referred to.
51
52 Documentation
53 =============
54 A web site for the SG device driver can be found at:
55 http://www.torque.net/sg [alternatively check the MAINTAINERS file]
56 The documentation for the sg version 3 driver can be found at:
57 http://www.torque.net/sg/p/sg_v3_ho.html
58 This is a rendering from DocBook source [change the extension to "sgml"
59 or "xml"]. There are renderings in "ps", "pdf", "rtf" and "txt" (soon).
60 The SG_IO ioctl is now found in other parts kernel (e.g. the block layer).
61 For more information see http://www.torque.net/sg/sg_io.html
62
63 The older, version 2 documents discuss the original sg interface in detail:
64 http://www.torque.net/sg/p/scsi-generic.txt
65 http://www.torque.net/sg/p/scsi-generic_long.txt
66 Also available: <kernel_source>/Documentation/scsi/scsi-generic.txt
67
68 Utility and test programs are available at the sg web site. They are
69 packaged as sg3_utils (for the lk 2.4 and 2.6 series) and sg_utils
70 (for the lk 2.2 series).
71*/
72 30
73#ifdef __KERNEL__ 31#ifdef __KERNEL__
74extern int sg_big_buff; /* for sysctl */ 32extern int sg_big_buff; /* for sysctl */
75#endif 33#endif
76 34
77/* New interface introduced in the 3.x SG drivers follows */
78 35
79typedef struct sg_iovec /* same structure as used by readv() Linux system */ 36typedef struct sg_iovec /* same structure as used by readv() Linux system */
80{ /* call. It defines one scatter-gather element. */ 37{ /* call. It defines one scatter-gather element. */
@@ -87,7 +44,7 @@ typedef struct sg_io_hdr
87{ 44{
88 int interface_id; /* [i] 'S' for SCSI generic (required) */ 45 int interface_id; /* [i] 'S' for SCSI generic (required) */
89 int dxfer_direction; /* [i] data transfer direction */ 46 int dxfer_direction; /* [i] data transfer direction */
90 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */ 47 unsigned char cmd_len; /* [i] SCSI command length */
91 unsigned char mx_sb_len; /* [i] max length to write to sbp */ 48 unsigned char mx_sb_len; /* [i] max length to write to sbp */
92 unsigned short iovec_count; /* [i] 0 implies no scatter gather */ 49 unsigned short iovec_count; /* [i] 0 implies no scatter gather */
93 unsigned int dxfer_len; /* [i] byte count of data transfer */ 50 unsigned int dxfer_len; /* [i] byte count of data transfer */