blob: aa3ad39d39dc9548b127d9dcd0550029bfcea48a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sebastian Andrzej Siewior348748b2012-01-11 12:45:56 +01002#ifndef __USB_UAS_H__
3#define __USB_UAS_H__
4
5#include <scsi/scsi.h>
6#include <scsi/scsi_cmnd.h>
7
8/* Common header for all IUs */
9struct iu {
10 __u8 iu_id;
11 __u8 rsvd1;
12 __be16 tag;
Hans de Goeded24354b2013-10-21 11:15:11 +010013} __attribute__((__packed__));
Sebastian Andrzej Siewior348748b2012-01-11 12:45:56 +010014
15enum {
16 IU_ID_COMMAND = 0x01,
17 IU_ID_STATUS = 0x03,
18 IU_ID_RESPONSE = 0x04,
19 IU_ID_TASK_MGMT = 0x05,
20 IU_ID_READ_READY = 0x06,
21 IU_ID_WRITE_READY = 0x07,
22};
23
Gerd Hoffmann023b5152012-06-19 09:54:54 +020024enum {
25 TMF_ABORT_TASK = 0x01,
26 TMF_ABORT_TASK_SET = 0x02,
27 TMF_CLEAR_TASK_SET = 0x04,
28 TMF_LOGICAL_UNIT_RESET = 0x08,
29 TMF_I_T_NEXUS_RESET = 0x10,
30 TMF_CLEAR_ACA = 0x40,
31 TMF_QUERY_TASK = 0x80,
32 TMF_QUERY_TASK_SET = 0x81,
33 TMF_QUERY_ASYNC_EVENT = 0x82,
34};
35
36enum {
37 RC_TMF_COMPLETE = 0x00,
38 RC_INVALID_INFO_UNIT = 0x02,
39 RC_TMF_NOT_SUPPORTED = 0x04,
40 RC_TMF_FAILED = 0x05,
41 RC_TMF_SUCCEEDED = 0x08,
42 RC_INCORRECT_LUN = 0x09,
43 RC_OVERLAPPED_TAG = 0x0a,
44};
45
Sebastian Andrzej Siewior348748b2012-01-11 12:45:56 +010046struct command_iu {
47 __u8 iu_id;
48 __u8 rsvd1;
49 __be16 tag;
50 __u8 prio_attr;
51 __u8 rsvd5;
52 __u8 len;
53 __u8 rsvd7;
54 struct scsi_lun lun;
55 __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */
Hans de Goeded24354b2013-10-21 11:15:11 +010056} __attribute__((__packed__));
Sebastian Andrzej Siewior348748b2012-01-11 12:45:56 +010057
Gerd Hoffmann023b5152012-06-19 09:54:54 +020058struct task_mgmt_iu {
59 __u8 iu_id;
60 __u8 rsvd1;
61 __be16 tag;
62 __u8 function;
63 __u8 rsvd2;
64 __be16 task_tag;
65 struct scsi_lun lun;
Hans de Goeded24354b2013-10-21 11:15:11 +010066} __attribute__((__packed__));
Gerd Hoffmann023b5152012-06-19 09:54:54 +020067
Sebastian Andrzej Siewior348748b2012-01-11 12:45:56 +010068/*
69 * Also used for the Read Ready and Write Ready IUs since they have the
70 * same first four bytes
71 */
72struct sense_iu {
73 __u8 iu_id;
74 __u8 rsvd1;
75 __be16 tag;
76 __be16 status_qual;
77 __u8 status;
78 __u8 rsvd7[7];
79 __be16 len;
80 __u8 sense[SCSI_SENSE_BUFFERSIZE];
Hans de Goeded24354b2013-10-21 11:15:11 +010081} __attribute__((__packed__));
Sebastian Andrzej Siewior348748b2012-01-11 12:45:56 +010082
Hans de Goedee52e0312013-10-23 14:27:09 +010083struct response_iu {
Gerd Hoffmann023b5152012-06-19 09:54:54 +020084 __u8 iu_id;
85 __u8 rsvd1;
86 __be16 tag;
Hans de Goede00d202c2013-10-31 09:59:12 +010087 __u8 add_response_info[3];
Gerd Hoffmann023b5152012-06-19 09:54:54 +020088 __u8 response_code;
Hans de Goeded24354b2013-10-21 11:15:11 +010089} __attribute__((__packed__));
Gerd Hoffmann023b5152012-06-19 09:54:54 +020090
Sebastian Andrzej Siewioree398b52012-01-11 12:45:57 +010091struct usb_pipe_usage_descriptor {
92 __u8 bLength;
93 __u8 bDescriptorType;
94
95 __u8 bPipeID;
96 __u8 Reserved;
97} __attribute__((__packed__));
98
Sebastian Andrzej Siewior348748b2012-01-11 12:45:56 +010099enum {
100 CMD_PIPE_ID = 1,
101 STATUS_PIPE_ID = 2,
102 DATA_IN_PIPE_ID = 3,
103 DATA_OUT_PIPE_ID = 4,
104
105 UAS_SIMPLE_TAG = 0,
106 UAS_HEAD_TAG = 1,
107 UAS_ORDERED_TAG = 2,
108 UAS_ACA = 4,
109};
110#endif