xref: /netbsd/sys/compat/linux/common/linux_sg.h (revision 95e1ffb1)
1 /* $NetBSD: linux_sg.h,v 1.3 2005/12/11 12:20:19 christos Exp $ */
2 
3 /*
4  * Copyright (c) 2004 Soren S. Jorvang.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #ifndef _LINUX_SG_H
29 #define _LINUX_SG_H
30 
31 /* sg driver version 3 */
32 #define LINUX_SG_EMULATED_HOST		_LINUX_IO('"', 0x03)
33 #define LINUX_SG_SET_TRANSFORM		_LINUX_IO('"', 0x04)
34 #define LINUX_SG_GET_TRANSFORM		_LINUX_IO('"', 0x05)
35 #define LINUX_SG_SET_RESERVED_SIZE	_LINUX_IO('"', 0x75)
36 #define LINUX_SG_GET_RESERVED_SIZE	_LINUX_IO('"', 0x72)
37 #define LINUX_SG_GET_SCSI_ID		_LINUX_IO('"', 0x76)
38 #define LINUX_SG_SET_FORCE_LOW_DMA	_LINUX_IO('"', 0x79)
39 #define LINUX_SG_GET_LOW_DMA		_LINUX_IO('"', 0x7a)
40 #define LINUX_SG_SET_FORCE_PACK_ID	_LINUX_IO('"', 0x7b)
41 #define LINUX_SG_GET_PACK_ID		_LINUX_IO('"', 0x7c)
42 #define LINUX_SG_GET_NUM_WAITING	_LINUX_IO('"', 0x7d)
43 #define LINUX_SG_GET_SG_TABLESIZE	_LINUX_IO('"', 0x7f)
44 #define LINUX_SG_GET_VERSION_NUM	_LINUX_IO('"', 0x82)
45 #define LINUX_SG_SCSI_RESET		_LINUX_IO('"', 0x84)
46 #define LINUX_SG_IO			_LINUX_IO('"', 0x85)
47 #define LINUX_SG_GET_REQUEST_TABLE	_LINUX_IO('"', 0x86)
48 #define LINUX_SG_SET_KEEP_ORPHAN	_LINUX_IO('"', 0x87)
49 #define LINUX_SG_GET_KEEP_ORPHAN	_LINUX_IO('"', 0x88)
50 #define LINUX_SG_GET_ACCESS_COUNT	_LINUX_IO('"', 0x89)
51 /* sg driver version 2 */
52 #define LINUX_SG_SET_TIMEOUT		_LINUX_IO('"', 0x01)
53 #define LINUX_SG_GET_TIMEOUT		_LINUX_IO('"', 0x02)
54 #define LINUX_SG_GET_COMMAND_Q		_LINUX_IO('"', 0x70)
55 #define LINUX_SG_SET_COMMAND_Q		_LINUX_IO('"', 0x71)
56 #define LINUX_SG_SET_DEBUG		_LINUX_IO('"', 0x7e)
57 #define LINUX_SG_NEXT_CMD_LEN		_LINUX_IO('"', 0x83)
58 
59 
60 struct linux_sg_io_hdr {
61 	int interface_id;
62 #define SG_DXFER_NONE		-1
63 #define SG_DXFER_TO_DEV		-2
64 #define SG_DXFER_FROM_DEV	-3
65 #define SG_DXFER_TO_FROM_DEV	-4
66 #define SG_DXFER_UNKNOWN	-5
67 	int dxfer_direction;
68 	unsigned char cmd_len;
69 	unsigned char mx_sb_len;
70 	unsigned short iovec_count;
71 	unsigned int dxfer_len;
72 	void *dxferp;
73 	unsigned char *cmdp;
74 	unsigned char *sbp;
75 	unsigned int timeout;
76 	unsigned int flags;
77 	int pack_id;
78 	void *usr_ptr;
79 	unsigned char status;
80 	unsigned char masked_status;
81 	unsigned char msg_status;
82 	unsigned char sb_len_wr;
83 	unsigned short host_status;
84 	unsigned short driver_status;
85 	int resid;
86 	unsigned int duration;
87 	unsigned int info;
88 };
89 
90 #define SG_MAX_SENSE 16
91 
92 /*
93  * Host codes
94  */
95 #define LINUX_DID_OK		0x00	/* OK */
96 #define LINUX_DID_NO_CONNECT	0x01	/* timeout during connect */
97 #define LINUX_DID_BUS_BUSY	0x02	/* timeout during command */
98 #define LINUX_DID_TIME_OUT	0x03	/* other timeout */
99 #define LINUX_DID_BAD_TARGET	0x04	/* bad target */
100 #define LINUX_DID_ABORT		0x05	/* abort */
101 #define LINUX_DID_PARITY	0x06	/* parity error */
102 #define LINUX_DID_ERROR		0x07	/* internal error */
103 #define LINUX_DID_RESET		0x08	/* reset by somebody */
104 #define LINUX_DID_BAD_INTR	0x09	/* unexpected interrupt */
105 #define LINUX_DID_PASSTHROUGH	0x0a	/* passthrough */
106 #define LINUX_DID_SOFT_ERROR	0x0b	/* low driver wants retry */
107 #define LINUX_DID_IMM_RETRY	0x0c	/* retry without decreasing retrycnt */
108 
109 /*
110  * Driver codes
111  */
112 #define LINUX_DRIVER_BUSY	0x01
113 #define LINUX_DRIVER_SOFT	0x02
114 #define LINUX_DRIVER_MEDIA	0x03
115 #define LINUX_DRIVER_ERROR	0x04
116 
117 #define LINUX_DRIVER_INVALID	0x05
118 #define LINUX_DRIVER_TIMEOUT	0x06
119 #define LINUX_DRIVER_HARD	0x07
120 #define LINUX_DRIVER_SENSE	0x08
121 
122 #define LINUX_SUGGEST_RETRY	0x10
123 #define LINUX_SUGGEST_ABORT	0x20
124 #define LINUX_SUGGEST_REMAP	0x30
125 #define LINUX_SUGGEST_DIE	0x40
126 #define LINUX_SUGGEST_SENSE	0x80
127 #define LINUX_SUGGEST_IS_OK	0xff
128 
129 #define LINUX_DRIVER_MASK	0x0f
130 #define LINUX_SUGGEST_MASK	0xf0
131 
132 #endif /* !_LINUX_SG_H */
133