Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * Driver for USB Mass Storage compliant devices
0004  * Transport Functions Header File
0005  *
0006  * Current development and maintenance by:
0007  *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
0008  *
0009  * This driver is based on the 'USB Mass Storage Class' document. This
0010  * describes in detail the protocol used to communicate with such
0011  * devices.  Clearly, the designers had SCSI and ATAPI commands in
0012  * mind when they created this document.  The commands are all very
0013  * similar to commands in the SCSI-II and ATAPI specifications.
0014  *
0015  * It is important to note that in a number of cases this class
0016  * exhibits class-specific exemptions from the USB specification.
0017  * Notably the usage of NAK, STALL and ACK differs from the norm, in
0018  * that they are used to communicate wait, failed and OK on commands.
0019  *
0020  * Also, for certain devices, the interrupt endpoint is used to convey
0021  * status of a command.
0022  */
0023 
0024 #ifndef _TRANSPORT_H_
0025 #define _TRANSPORT_H_
0026 
0027 #include <linux/blkdev.h>
0028 
0029 /*
0030  * usb_stor_bulk_transfer_xxx() return codes, in order of severity
0031  */
0032 
0033 #define USB_STOR_XFER_GOOD  0   /* good transfer                 */
0034 #define USB_STOR_XFER_SHORT 1   /* transferred less than expected */
0035 #define USB_STOR_XFER_STALLED   2   /* endpoint stalled              */
0036 #define USB_STOR_XFER_LONG  3   /* device tried to send too much */
0037 #define USB_STOR_XFER_ERROR 4   /* transfer died in the middle   */
0038 
0039 /*
0040  * Transport return codes
0041  */
0042 
0043 #define USB_STOR_TRANSPORT_GOOD    0   /* Transport good, command good     */
0044 #define USB_STOR_TRANSPORT_FAILED  1   /* Transport good, command failed   */
0045 #define USB_STOR_TRANSPORT_NO_SENSE 2  /* Command failed, no auto-sense    */
0046 #define USB_STOR_TRANSPORT_ERROR   3   /* Transport bad (i.e. device dead) */
0047 
0048 /*
0049  * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
0050  * return codes.  But now the transport and low-level transfer routines
0051  * treat an abort as just another error (-ENOENT for a cancelled URB).
0052  * It is up to the invoke_transport() function to test for aborts and
0053  * distinguish them from genuine communication errors.
0054  */
0055 
0056 /*
0057  * CBI accept device specific command
0058  */
0059 
0060 #define US_CBI_ADSC     0
0061 
0062 extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*);
0063 extern int usb_stor_CB_reset(struct us_data*);
0064 
0065 extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
0066 extern int usb_stor_Bulk_max_lun(struct us_data*);
0067 extern int usb_stor_Bulk_reset(struct us_data*);
0068 
0069 extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
0070 extern void usb_stor_stop_transport(struct us_data*);
0071 
0072 extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
0073         u8 request, u8 requesttype, u16 value, u16 index,
0074         void *data, u16 size, int timeout);
0075 extern int usb_stor_clear_halt(struct us_data *us, unsigned int pipe);
0076 
0077 extern int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
0078         u8 request, u8 requesttype, u16 value, u16 index,
0079         void *data, u16 size);
0080 extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
0081         void *buf, unsigned int length, unsigned int *act_len);
0082 extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
0083         void *buf, unsigned int length, int use_sg, int *residual);
0084 extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
0085         struct scsi_cmnd* srb);
0086 
0087 extern int usb_stor_port_reset(struct us_data *us);
0088 #endif