• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Driver for USB Mass Storage compliant devices
3  * Transport Functions Header File
4  *
5  * Current development and maintenance by:
6  *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
7  *
8  * This driver is based on the 'USB Mass Storage Class' document. This
9  * describes in detail the protocol used to communicate with such
10  * devices.  Clearly, the designers had SCSI and ATAPI commands in
11  * mind when they created this document.  The commands are all very
12  * similar to commands in the SCSI-II and ATAPI specifications.
13  *
14  * It is important to note that in a number of cases this class
15  * exhibits class-specific exemptions from the USB specification.
16  * Notably the usage of NAK, STALL and ACK differs from the norm, in
17  * that they are used to communicate wait, failed and OK on commands.
18  *
19  * Also, for certain devices, the interrupt endpoint is used to convey
20  * status of a command.
21  *
22  * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
23  * information about this driver.
24  *
25  * This program is free software; you can redistribute it and/or modify it
26  * under the terms of the GNU General Public License as published by the
27  * Free Software Foundation; either version 2, or (at your option) any
28  * later version.
29  *
30  * This program is distributed in the hope that it will be useful, but
31  * WITHOUT ANY WARRANTY; without even the implied warranty of
32  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
33  * General Public License for more details.
34  *
35  * You should have received a copy of the GNU General Public License along
36  * with this program; if not, write to the Free Software Foundation, Inc.,
37  * 675 Mass Ave, Cambridge, MA 02139, USA.
38  */
39 
40 #ifndef _TRANSPORT_H_
41 #define _TRANSPORT_H_
42 
43 #include <linux/blkdev.h>
44 
45 /*
46  * usb_stor_bulk_transfer_xxx() return codes, in order of severity
47  */
48 
49 #define USB_STOR_XFER_GOOD	0	/* good transfer                 */
50 #define USB_STOR_XFER_SHORT	1	/* transferred less than expected */
51 #define USB_STOR_XFER_STALLED	2	/* endpoint stalled              */
52 #define USB_STOR_XFER_LONG	3	/* device tried to send too much */
53 #define USB_STOR_XFER_ERROR	4	/* transfer died in the middle   */
54 
55 /*
56  * Transport return codes
57  */
58 
59 #define USB_STOR_TRANSPORT_GOOD	   0   /* Transport good, command good	   */
60 #define USB_STOR_TRANSPORT_FAILED  1   /* Transport good, command failed   */
61 #define USB_STOR_TRANSPORT_NO_SENSE 2  /* Command failed, no auto-sense    */
62 #define USB_STOR_TRANSPORT_ERROR   3   /* Transport bad (i.e. device dead) */
63 
64 /*
65  * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
66  * return codes.  But now the transport and low-level transfer routines
67  * treat an abort as just another error (-ENOENT for a cancelled URB).
68  * It is up to the invoke_transport() function to test for aborts and
69  * distinguish them from genuine communication errors.
70  */
71 
72 /*
73  * CBI accept device specific command
74  */
75 
76 #define US_CBI_ADSC		0
77 
78 extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*);
79 extern int usb_stor_CB_reset(struct us_data*);
80 
81 extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
82 extern int usb_stor_Bulk_max_lun(struct us_data*);
83 extern int usb_stor_Bulk_reset(struct us_data*);
84 
85 extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
86 extern void usb_stor_stop_transport(struct us_data*);
87 
88 extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
89 		u8 request, u8 requesttype, u16 value, u16 index,
90 		void *data, u16 size, int timeout);
91 extern int usb_stor_clear_halt(struct us_data *us, unsigned int pipe);
92 
93 extern int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
94 		u8 request, u8 requesttype, u16 value, u16 index,
95 		void *data, u16 size);
96 extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
97 		void *buf, unsigned int length, unsigned int *act_len);
98 extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
99 		void *buf, unsigned int length, int use_sg, int *residual);
100 extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
101 		struct scsi_cmnd* srb);
102 
103 extern int usb_stor_port_reset(struct us_data *us);
104 #endif
105