xref: /freebsd/sys/dev/smartpqi/smartpqi_ioctl.h (revision 184c1b943937986c81e1996d999d21626ec7a4ff)
1 /*-
2  * Copyright (c) 2018 Microsemi Corporation.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
27 /* $FreeBSD$ */
28 
29 #ifndef	_PQI_IOCTL_H_
30 #define	_PQI_IOCTL_H_
31 
32 /* IOCTL passthrough macros and structures */
33 
34 #define SENSEINFOBYTES	32              /* note that this value may vary
35  										 between host implementations */
36 
37 /* transfer direction */
38 #define PQIIOCTL_NONE			0x00
39 #define PQIIOCTL_WRITE			0x01
40 #define PQIIOCTL_READ			0x02
41 #define PQIIOCTL_BIDIRECTIONAL		(PQIIOCTL_READ | PQIIOCTL_WRITE)
42 
43 /* Type defs used in the following structs */
44 #define BYTE  	uint8_t
45 #define WORD  	uint16_t
46 #define HWORD 	uint16_t
47 #define DWORD 	uint32_t
48 
49 /* Command List Structure */
50 typedef union _SCSI3Addr_struct {
51 	  struct {
52 	   BYTE Dev;
53 	   BYTE Bus:6;
54 	   BYTE Mode:2; 	   /* b00 */
55 	 } PeripDev;
56 	  struct {
57 	   BYTE DevLSB;
58 	   BYTE DevMSB:6;
59 	   BYTE Mode:2; 	   /* b01 */
60 	 } LogDev;
61 	  struct {
62 	   BYTE Dev:5;
63 	   BYTE Bus:3;
64 	   BYTE Targ:6;
65 	   BYTE Mode:2; 	   /* b10 */
66 	 } LogUnit;
67 
68 }OS_ATTRIBUTE_PACKED SCSI3Addr_struct;
69 
70 typedef struct _PhysDevAddr_struct {
71 	 DWORD			   TargetId:24;
72 	 DWORD			   Bus:6;
73 	 DWORD			   Mode:2;
74 	 SCSI3Addr_struct  Target[2]; 	/* 2 level target device addr */
75 
76 }OS_ATTRIBUTE_PACKED PhysDevAddr_struct;
77 
78 typedef struct _LogDevAddr_struct {
79 	 DWORD			  VolId:30;
80 	 DWORD			  Mode:2;
81 	 BYTE			  reserved[4];
82 
83 }OS_ATTRIBUTE_PACKED LogDevAddr_struct;
84 
85 typedef union _LUNAddr_struct {
86     BYTE               LunAddrBytes[8];
87     SCSI3Addr_struct   SCSI3Lun[4];
88     PhysDevAddr_struct PhysDev;
89     LogDevAddr_struct  LogDev;
90 
91 }OS_ATTRIBUTE_PACKED LUNAddr_struct;
92 
93 typedef struct _RequestBlock_struct {
94     BYTE  CDBLen;
95     struct {
96       BYTE Type:3;
97       BYTE Attribute:3;
98       BYTE Direction:2;
99     } Type;
100     HWORD  Timeout;
101     BYTE   CDB[16];
102 
103 }OS_ATTRIBUTE_PACKED RequestBlock_struct;
104 
105 typedef union _MoreErrInfo_struct{
106    struct {
107     BYTE  Reserved[3];
108     BYTE  Type;
109     DWORD ErrorInfo;
110    } Common_Info;
111    struct{
112      BYTE  Reserved[2];
113      BYTE  offense_size; /* size of offending entry */
114      BYTE  offense_num;  /* byte # of offense 0-base */
115      DWORD offense_value;
116    } Invalid_Cmd;
117 
118 }OS_ATTRIBUTE_PACKED MoreErrInfo_struct;
119 
120 typedef struct _ErrorInfo_struct {
121    BYTE               ScsiStatus;
122    BYTE               SenseLen;
123    HWORD              CommandStatus;
124    DWORD              ResidualCnt;
125    MoreErrInfo_struct MoreErrInfo;
126    BYTE               SenseInfo[SENSEINFOBYTES];
127 
128 }OS_ATTRIBUTE_PACKED ErrorInfo_struct;
129 
130 typedef struct pqi_ioctl_passthruCmd_struct {
131 	LUNAddr_struct           LUN_info;
132 	RequestBlock_struct      Request;
133 	ErrorInfo_struct         error_info;
134    	WORD                     buf_size;  /* size in bytes of the buf */
135 	passthru_buf_type_t		buf;
136 
137 }OS_ATTRIBUTE_PACKED IOCTL_Command_struct;
138 
139 #endif  /* _PQI_IOCTL_H_ */
140