1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Driver for USB Mass Storage compliant devices 4*4882a593Smuzhiyun * Transport Functions Header File 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Current development and maintenance by: 7*4882a593Smuzhiyun * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) 8*4882a593Smuzhiyun * 9*4882a593Smuzhiyun * This driver is based on the 'USB Mass Storage Class' document. This 10*4882a593Smuzhiyun * describes in detail the protocol used to communicate with such 11*4882a593Smuzhiyun * devices. Clearly, the designers had SCSI and ATAPI commands in 12*4882a593Smuzhiyun * mind when they created this document. The commands are all very 13*4882a593Smuzhiyun * similar to commands in the SCSI-II and ATAPI specifications. 14*4882a593Smuzhiyun * 15*4882a593Smuzhiyun * It is important to note that in a number of cases this class 16*4882a593Smuzhiyun * exhibits class-specific exemptions from the USB specification. 17*4882a593Smuzhiyun * Notably the usage of NAK, STALL and ACK differs from the norm, in 18*4882a593Smuzhiyun * that they are used to communicate wait, failed and OK on commands. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * Also, for certain devices, the interrupt endpoint is used to convey 21*4882a593Smuzhiyun * status of a command. 22*4882a593Smuzhiyun */ 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun #ifndef _TRANSPORT_H_ 25*4882a593Smuzhiyun #define _TRANSPORT_H_ 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun #include <linux/blkdev.h> 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun /* 30*4882a593Smuzhiyun * usb_stor_bulk_transfer_xxx() return codes, in order of severity 31*4882a593Smuzhiyun */ 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun #define USB_STOR_XFER_GOOD 0 /* good transfer */ 34*4882a593Smuzhiyun #define USB_STOR_XFER_SHORT 1 /* transferred less than expected */ 35*4882a593Smuzhiyun #define USB_STOR_XFER_STALLED 2 /* endpoint stalled */ 36*4882a593Smuzhiyun #define USB_STOR_XFER_LONG 3 /* device tried to send too much */ 37*4882a593Smuzhiyun #define USB_STOR_XFER_ERROR 4 /* transfer died in the middle */ 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun /* 40*4882a593Smuzhiyun * Transport return codes 41*4882a593Smuzhiyun */ 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun #define USB_STOR_TRANSPORT_GOOD 0 /* Transport good, command good */ 44*4882a593Smuzhiyun #define USB_STOR_TRANSPORT_FAILED 1 /* Transport good, command failed */ 45*4882a593Smuzhiyun #define USB_STOR_TRANSPORT_NO_SENSE 2 /* Command failed, no auto-sense */ 46*4882a593Smuzhiyun #define USB_STOR_TRANSPORT_ERROR 3 /* Transport bad (i.e. device dead) */ 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun /* 49*4882a593Smuzhiyun * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED 50*4882a593Smuzhiyun * return codes. But now the transport and low-level transfer routines 51*4882a593Smuzhiyun * treat an abort as just another error (-ENOENT for a cancelled URB). 52*4882a593Smuzhiyun * It is up to the invoke_transport() function to test for aborts and 53*4882a593Smuzhiyun * distinguish them from genuine communication errors. 54*4882a593Smuzhiyun */ 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun /* 57*4882a593Smuzhiyun * CBI accept device specific command 58*4882a593Smuzhiyun */ 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun #define US_CBI_ADSC 0 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*); 63*4882a593Smuzhiyun extern int usb_stor_CB_reset(struct us_data*); 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*); 66*4882a593Smuzhiyun extern int usb_stor_Bulk_max_lun(struct us_data*); 67*4882a593Smuzhiyun extern int usb_stor_Bulk_reset(struct us_data*); 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*); 70*4882a593Smuzhiyun extern void usb_stor_stop_transport(struct us_data*); 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe, 73*4882a593Smuzhiyun u8 request, u8 requesttype, u16 value, u16 index, 74*4882a593Smuzhiyun void *data, u16 size, int timeout); 75*4882a593Smuzhiyun extern int usb_stor_clear_halt(struct us_data *us, unsigned int pipe); 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun extern int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe, 78*4882a593Smuzhiyun u8 request, u8 requesttype, u16 value, u16 index, 79*4882a593Smuzhiyun void *data, u16 size); 80*4882a593Smuzhiyun extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe, 81*4882a593Smuzhiyun void *buf, unsigned int length, unsigned int *act_len); 82*4882a593Smuzhiyun extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe, 83*4882a593Smuzhiyun void *buf, unsigned int length, int use_sg, int *residual); 84*4882a593Smuzhiyun extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe, 85*4882a593Smuzhiyun struct scsi_cmnd* srb); 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun extern int usb_stor_port_reset(struct us_data *us); 88*4882a593Smuzhiyun #endif 89