Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Apr 14-17, 2025
Register
Loading...
v3.1
  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
 39#ifndef _TRANSPORT_H_
 40#define _TRANSPORT_H_
 41
 42#include <linux/blkdev.h>
 43
 44/*
 45 * Bulk only data structures
 46 */
 47
 48/* command block wrapper */
 49struct bulk_cb_wrap {
 50	__le32	Signature;		/* contains 'USBC' */
 51	__u32	Tag;			/* unique per command id */
 52	__le32	DataTransferLength;	/* size of data */
 53	__u8	Flags;			/* direction in bit 0 */
 54	__u8	Lun;			/* LUN normally 0 */
 55	__u8	Length;			/* of of the CDB */
 56	__u8	CDB[16];		/* max command */
 57};
 58
 59#define US_BULK_CB_WRAP_LEN	31
 60#define US_BULK_CB_SIGN		0x43425355	/*spells out USBC */
 61#define US_BULK_FLAG_IN		1
 62#define US_BULK_FLAG_OUT	0
 63
 64/* command status wrapper */
 65struct bulk_cs_wrap {
 66	__le32	Signature;		/* should = 'USBS' */
 67	__u32	Tag;			/* same as original command */
 68	__le32	Residue;		/* amount not transferred */
 69	__u8	Status;			/* see below */
 70	__u8	Filler[18];
 71};
 72
 73#define US_BULK_CS_WRAP_LEN	13
 74#define US_BULK_CS_SIGN		0x53425355	/* spells out 'USBS' */
 75#define US_BULK_STAT_OK		0
 76#define US_BULK_STAT_FAIL	1
 77#define US_BULK_STAT_PHASE	2
 78
 79/* bulk-only class specific requests */
 80#define US_BULK_RESET_REQUEST	0xff
 81#define US_BULK_GET_MAX_LUN	0xfe
 82
 83/*
 84 * usb_stor_bulk_transfer_xxx() return codes, in order of severity
 85 */
 86
 87#define USB_STOR_XFER_GOOD	0	/* good transfer                 */
 88#define USB_STOR_XFER_SHORT	1	/* transferred less than expected */
 89#define USB_STOR_XFER_STALLED	2	/* endpoint stalled              */
 90#define USB_STOR_XFER_LONG	3	/* device tried to send too much */
 91#define USB_STOR_XFER_ERROR	4	/* transfer died in the middle   */
 92
 93/*
 94 * Transport return codes
 95 */
 96
 97#define USB_STOR_TRANSPORT_GOOD	   0   /* Transport good, command good	   */
 98#define USB_STOR_TRANSPORT_FAILED  1   /* Transport good, command failed   */
 99#define USB_STOR_TRANSPORT_NO_SENSE 2  /* Command failed, no auto-sense    */
100#define USB_STOR_TRANSPORT_ERROR   3   /* Transport bad (i.e. device dead) */
101
102/*
103 * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
104 * return codes.  But now the transport and low-level transfer routines
105 * treat an abort as just another error (-ENOENT for a cancelled URB).
106 * It is up to the invoke_transport() function to test for aborts and
107 * distinguish them from genuine communication errors.
108 */
109
110/*
111 * CBI accept device specific command
112 */
113
114#define US_CBI_ADSC		0
115
116extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*);
117extern int usb_stor_CB_reset(struct us_data*);
118
119extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
120extern int usb_stor_Bulk_max_lun(struct us_data*);
121extern int usb_stor_Bulk_reset(struct us_data*);
122
123extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
124extern void usb_stor_stop_transport(struct us_data*);
125
126extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
127		u8 request, u8 requesttype, u16 value, u16 index,
128		void *data, u16 size, int timeout);
129extern int usb_stor_clear_halt(struct us_data *us, unsigned int pipe);
130
131extern int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
132		u8 request, u8 requesttype, u16 value, u16 index,
133		void *data, u16 size);
134extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
135		void *buf, unsigned int length, unsigned int *act_len);
136extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
137		void *buf, unsigned int length, int use_sg, int *residual);
138extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
139		struct scsi_cmnd* srb);
140
141extern int usb_stor_port_reset(struct us_data *us);
142#endif
v3.15
  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
 39#ifndef _TRANSPORT_H_
 40#define _TRANSPORT_H_
 41
 42#include <linux/blkdev.h>
 43
 44/*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 45 * usb_stor_bulk_transfer_xxx() return codes, in order of severity
 46 */
 47
 48#define USB_STOR_XFER_GOOD	0	/* good transfer                 */
 49#define USB_STOR_XFER_SHORT	1	/* transferred less than expected */
 50#define USB_STOR_XFER_STALLED	2	/* endpoint stalled              */
 51#define USB_STOR_XFER_LONG	3	/* device tried to send too much */
 52#define USB_STOR_XFER_ERROR	4	/* transfer died in the middle   */
 53
 54/*
 55 * Transport return codes
 56 */
 57
 58#define USB_STOR_TRANSPORT_GOOD	   0   /* Transport good, command good	   */
 59#define USB_STOR_TRANSPORT_FAILED  1   /* Transport good, command failed   */
 60#define USB_STOR_TRANSPORT_NO_SENSE 2  /* Command failed, no auto-sense    */
 61#define USB_STOR_TRANSPORT_ERROR   3   /* Transport bad (i.e. device dead) */
 62
 63/*
 64 * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
 65 * return codes.  But now the transport and low-level transfer routines
 66 * treat an abort as just another error (-ENOENT for a cancelled URB).
 67 * It is up to the invoke_transport() function to test for aborts and
 68 * distinguish them from genuine communication errors.
 69 */
 70
 71/*
 72 * CBI accept device specific command
 73 */
 74
 75#define US_CBI_ADSC		0
 76
 77extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*);
 78extern int usb_stor_CB_reset(struct us_data*);
 79
 80extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
 81extern int usb_stor_Bulk_max_lun(struct us_data*);
 82extern int usb_stor_Bulk_reset(struct us_data*);
 83
 84extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
 85extern void usb_stor_stop_transport(struct us_data*);
 86
 87extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
 88		u8 request, u8 requesttype, u16 value, u16 index,
 89		void *data, u16 size, int timeout);
 90extern int usb_stor_clear_halt(struct us_data *us, unsigned int pipe);
 91
 92extern int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
 93		u8 request, u8 requesttype, u16 value, u16 index,
 94		void *data, u16 size);
 95extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
 96		void *buf, unsigned int length, unsigned int *act_len);
 97extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
 98		void *buf, unsigned int length, int use_sg, int *residual);
 99extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
100		struct scsi_cmnd* srb);
101
102extern int usb_stor_port_reset(struct us_data *us);
103#endif