xref: /freebsd/sys/dev/smartpqi/smartpqi_ioctl.h (revision 4f52dfbb)
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 
44 /* Type defs used in the following structs */
45 #define BYTE  	uint8_t
46 #define WORD  	uint16_t
47 #define HWORD 	uint16_t
48 #define DWORD 	uint32_t
49 
50 
51 
52 /* Command List Structure */
53 typedef union _SCSI3Addr_struct {
54 	  struct {
55 	   BYTE Dev;
56 	   BYTE Bus:6;
57 	   BYTE Mode:2; 	   /* b00 */
58 	 } PeripDev;
59 	  struct {
60 	   BYTE DevLSB;
61 	   BYTE DevMSB:6;
62 	   BYTE Mode:2; 	   /* b01 */
63 	 } LogDev;
64 	  struct {
65 	   BYTE Dev:5;
66 	   BYTE Bus:3;
67 	   BYTE Targ:6;
68 	   BYTE Mode:2; 	   /* b10 */
69 	 } LogUnit;
70 
71 }OS_ATTRIBUTE_PACKED SCSI3Addr_struct;
72 
73 typedef struct _PhysDevAddr_struct {
74 	 DWORD			   TargetId:24;
75 	 DWORD			   Bus:6;
76 	 DWORD			   Mode:2;
77 	 SCSI3Addr_struct  Target[2]; 	/* 2 level target device addr */
78 
79 }OS_ATTRIBUTE_PACKED PhysDevAddr_struct;
80 
81 typedef struct _LogDevAddr_struct {
82 	 DWORD			  VolId:30;
83 	 DWORD			  Mode:2;
84 	 BYTE			  reserved[4];
85 
86 }OS_ATTRIBUTE_PACKED LogDevAddr_struct;
87 
88 typedef union _LUNAddr_struct {
89     BYTE               LunAddrBytes[8];
90     SCSI3Addr_struct   SCSI3Lun[4];
91     PhysDevAddr_struct PhysDev;
92     LogDevAddr_struct  LogDev;
93 
94 }OS_ATTRIBUTE_PACKED LUNAddr_struct;
95 
96 typedef struct _RequestBlock_struct {
97     BYTE  CDBLen;
98     struct {
99       BYTE Type:3;
100       BYTE Attribute:3;
101       BYTE Direction:2;
102     } Type;
103     HWORD  Timeout;
104     BYTE   CDB[16];
105 
106 }OS_ATTRIBUTE_PACKED RequestBlock_struct;
107 
108 typedef union _MoreErrInfo_struct{
109    struct {
110     BYTE  Reserved[3];
111     BYTE  Type;
112     DWORD ErrorInfo;
113    } Common_Info;
114    struct{
115      BYTE  Reserved[2];
116      BYTE  offense_size; /* size of offending entry */
117      BYTE  offense_num;  /* byte # of offense 0-base */
118      DWORD offense_value;
119    } Invalid_Cmd;
120 
121 }OS_ATTRIBUTE_PACKED MoreErrInfo_struct;
122 
123 typedef struct _ErrorInfo_struct {
124    BYTE               ScsiStatus;
125    BYTE               SenseLen;
126    HWORD              CommandStatus;
127    DWORD              ResidualCnt;
128    MoreErrInfo_struct MoreErrInfo;
129    BYTE               SenseInfo[SENSEINFOBYTES];
130 
131 }OS_ATTRIBUTE_PACKED ErrorInfo_struct;
132 
133 
134 typedef struct pqi_ioctl_passthruCmd_struct {
135 	LUNAddr_struct           LUN_info;
136 	RequestBlock_struct      Request;
137 	ErrorInfo_struct         error_info;
138    	WORD                     buf_size;  /* size in bytes of the buf */
139 	passthru_buf_type_t		buf;
140 
141 }OS_ATTRIBUTE_PACKED IOCTL_Command_struct;
142 
143 
144 #endif  /* _PQI_IOCTL_H_ */
145