xref: /openbmc/linux/include/uapi/linux/cciss_defs.h (revision 6f52b16c)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells #ifndef CCISS_DEFS_H
3607ca46eSDavid Howells #define CCISS_DEFS_H
4607ca46eSDavid Howells 
5607ca46eSDavid Howells #include <linux/types.h>
6607ca46eSDavid Howells 
7607ca46eSDavid Howells /* general boundary definitions */
8607ca46eSDavid Howells #define SENSEINFOBYTES          32 /* note that this value may vary
9607ca46eSDavid Howells 				      between host implementations */
10607ca46eSDavid Howells 
11607ca46eSDavid Howells /* Command Status value */
12607ca46eSDavid Howells #define CMD_SUCCESS             0x0000
13607ca46eSDavid Howells #define CMD_TARGET_STATUS       0x0001
14607ca46eSDavid Howells #define CMD_DATA_UNDERRUN       0x0002
15607ca46eSDavid Howells #define CMD_DATA_OVERRUN        0x0003
16607ca46eSDavid Howells #define CMD_INVALID             0x0004
17607ca46eSDavid Howells #define CMD_PROTOCOL_ERR        0x0005
18607ca46eSDavid Howells #define CMD_HARDWARE_ERR        0x0006
19607ca46eSDavid Howells #define CMD_CONNECTION_LOST     0x0007
20607ca46eSDavid Howells #define CMD_ABORTED             0x0008
21607ca46eSDavid Howells #define CMD_ABORT_FAILED        0x0009
22607ca46eSDavid Howells #define CMD_UNSOLICITED_ABORT   0x000A
23607ca46eSDavid Howells #define CMD_TIMEOUT             0x000B
24607ca46eSDavid Howells #define CMD_UNABORTABLE		0x000C
25607ca46eSDavid Howells 
26607ca46eSDavid Howells /* transfer direction */
27607ca46eSDavid Howells #define XFER_NONE               0x00
28607ca46eSDavid Howells #define XFER_WRITE              0x01
29607ca46eSDavid Howells #define XFER_READ               0x02
30607ca46eSDavid Howells #define XFER_RSVD               0x03
31607ca46eSDavid Howells 
32607ca46eSDavid Howells /* task attribute */
33607ca46eSDavid Howells #define ATTR_UNTAGGED           0x00
34607ca46eSDavid Howells #define ATTR_SIMPLE             0x04
35607ca46eSDavid Howells #define ATTR_HEADOFQUEUE        0x05
36607ca46eSDavid Howells #define ATTR_ORDERED            0x06
37607ca46eSDavid Howells #define ATTR_ACA                0x07
38607ca46eSDavid Howells 
39607ca46eSDavid Howells /* cdb type */
40607ca46eSDavid Howells #define TYPE_CMD				0x00
41607ca46eSDavid Howells #define TYPE_MSG				0x01
42607ca46eSDavid Howells 
43607ca46eSDavid Howells /* Type defs used in the following structs */
44607ca46eSDavid Howells #define BYTE __u8
45607ca46eSDavid Howells #define WORD __u16
46607ca46eSDavid Howells #define HWORD __u16
47607ca46eSDavid Howells #define DWORD __u32
48607ca46eSDavid Howells 
49607ca46eSDavid Howells #define CISS_MAX_LUN	1024
50607ca46eSDavid Howells 
51607ca46eSDavid Howells #define LEVEL2LUN   1 /* index into Target(x) structure, due to byte swapping */
52607ca46eSDavid Howells #define LEVEL3LUN   0
53607ca46eSDavid Howells 
54607ca46eSDavid Howells #pragma pack(1)
55607ca46eSDavid Howells 
56607ca46eSDavid Howells /* Command List Structure */
57607ca46eSDavid Howells typedef union _SCSI3Addr_struct {
58607ca46eSDavid Howells    struct {
59607ca46eSDavid Howells     BYTE Dev;
60607ca46eSDavid Howells     BYTE Bus:6;
61607ca46eSDavid Howells     BYTE Mode:2;        /* b00 */
62607ca46eSDavid Howells   } PeripDev;
63607ca46eSDavid Howells    struct {
64607ca46eSDavid Howells     BYTE DevLSB;
65607ca46eSDavid Howells     BYTE DevMSB:6;
66607ca46eSDavid Howells     BYTE Mode:2;        /* b01 */
67607ca46eSDavid Howells   } LogDev;
68607ca46eSDavid Howells    struct {
69607ca46eSDavid Howells     BYTE Dev:5;
70607ca46eSDavid Howells     BYTE Bus:3;
71607ca46eSDavid Howells     BYTE Targ:6;
72607ca46eSDavid Howells     BYTE Mode:2;        /* b10 */
73607ca46eSDavid Howells   } LogUnit;
74607ca46eSDavid Howells } SCSI3Addr_struct;
75607ca46eSDavid Howells 
76607ca46eSDavid Howells typedef struct _PhysDevAddr_struct {
77607ca46eSDavid Howells   DWORD             TargetId:24;
78607ca46eSDavid Howells   DWORD             Bus:6;
79607ca46eSDavid Howells   DWORD             Mode:2;
80607ca46eSDavid Howells   SCSI3Addr_struct  Target[2]; /* 2 level target device addr */
81607ca46eSDavid Howells } PhysDevAddr_struct;
82607ca46eSDavid Howells 
83607ca46eSDavid Howells typedef struct _LogDevAddr_struct {
84607ca46eSDavid Howells   DWORD            VolId:30;
85607ca46eSDavid Howells   DWORD            Mode:2;
86607ca46eSDavid Howells   BYTE             reserved[4];
87607ca46eSDavid Howells } LogDevAddr_struct;
88607ca46eSDavid Howells 
89607ca46eSDavid Howells typedef union _LUNAddr_struct {
90607ca46eSDavid Howells   BYTE               LunAddrBytes[8];
91607ca46eSDavid Howells   SCSI3Addr_struct   SCSI3Lun[4];
92607ca46eSDavid Howells   PhysDevAddr_struct PhysDev;
93607ca46eSDavid Howells   LogDevAddr_struct  LogDev;
94607ca46eSDavid Howells } LUNAddr_struct;
95607ca46eSDavid Howells 
96607ca46eSDavid Howells typedef struct _RequestBlock_struct {
97607ca46eSDavid Howells   BYTE   CDBLen;
98607ca46eSDavid Howells   struct {
99607ca46eSDavid Howells     BYTE Type:3;
100607ca46eSDavid Howells     BYTE Attribute:3;
101607ca46eSDavid Howells     BYTE Direction:2;
102607ca46eSDavid Howells   } Type;
103607ca46eSDavid Howells   HWORD  Timeout;
104607ca46eSDavid Howells   BYTE   CDB[16];
105607ca46eSDavid Howells } RequestBlock_struct;
106607ca46eSDavid Howells 
107607ca46eSDavid Howells typedef union _MoreErrInfo_struct{
108607ca46eSDavid Howells   struct {
109607ca46eSDavid Howells     BYTE  Reserved[3];
110607ca46eSDavid Howells     BYTE  Type;
111607ca46eSDavid Howells     DWORD ErrorInfo;
112607ca46eSDavid Howells   } Common_Info;
113607ca46eSDavid Howells   struct{
114607ca46eSDavid Howells     BYTE  Reserved[2];
115607ca46eSDavid Howells     BYTE  offense_size; /* size of offending entry */
116607ca46eSDavid Howells     BYTE  offense_num;  /* byte # of offense 0-base */
117607ca46eSDavid Howells     DWORD offense_value;
118607ca46eSDavid Howells   } Invalid_Cmd;
119607ca46eSDavid Howells } MoreErrInfo_struct;
120607ca46eSDavid Howells typedef struct _ErrorInfo_struct {
121607ca46eSDavid Howells   BYTE               ScsiStatus;
122607ca46eSDavid Howells   BYTE               SenseLen;
123607ca46eSDavid Howells   HWORD              CommandStatus;
124607ca46eSDavid Howells   DWORD              ResidualCnt;
125607ca46eSDavid Howells   MoreErrInfo_struct MoreErrInfo;
126607ca46eSDavid Howells   BYTE               SenseInfo[SENSEINFOBYTES];
127607ca46eSDavid Howells } ErrorInfo_struct;
128607ca46eSDavid Howells 
129607ca46eSDavid Howells #pragma pack()
130607ca46eSDavid Howells 
131607ca46eSDavid Howells #endif /* CCISS_DEFS_H */
132