transport.h 4.1 KB

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