transport.h 3.3 KB

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