xref: /netbsd-src/sys/dev/pci/twaio.h (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1 /*	$NetBSD: twaio.h,v 1.5 2008/09/08 23:36:54 gmcgarry Exp $ */
2 /*	$wasabi: twaio.h,v 1.8 2006/04/27 17:12:39 wrstuden Exp $ */
3 
4 /*-
5  * Copyright (c) 2003-04 3ware, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *$FreeBSD: src/sys/dev/twa/twa_ioctl.h,v 1.1 2004/03/30 03:45:59 vkashyap Exp $
30  */
31 
32 /*
33  * 3ware driver for 9000 series storage controllers.
34  *
35  * Author: Vinod Kashyap
36  */
37 
38 
39 #ifndef _DEV_PCI_TWAIO_H_
40 #define	_DEV_PCI_TWAIO_H_
41 
42 #define TWA_AEN_NOT_RETRIEVED	0x1
43 #define TWA_AEN_RETRIEVED	0x2
44 
45 #define TWA_ERROR_AEN_NO_EVENTS	0x1003           /* No more events */
46 #define TWA_ERROR_AEN_OVERFLOW	0x1004           /* AEN clobber occurred */
47 
48 #define TWA_ERROR_IOCTL_LOCK_NOT_HELD		0x1001   /* Not locked */
49 #define TWA_ERROR_IOCTL_LOCK_ALREADY_HELD	0x1002   /* Already locked */
50 
51 
52 struct twa_scan_bus_packet {
53 	uint32_t	unit;
54 } __packed;
55 
56 struct tw_cl_event_packet {
57 	uint32_t	sequence_id;
58 	uint32_t	time_stamp_sec;
59 	uint16_t	aen_code;
60 	uint8_t		severity;
61 	uint8_t		retrieved;
62 	uint8_t		repeat_count;
63 	uint8_t		parameter_len;
64 	uint8_t		parameter_data[98];
65 	uint32_t	event_src;
66 	uint8_t		severity_str[20];
67 } __packed;
68 
69 struct tw_cl_lock_packet {
70 	uint32_t	timeout_msec;
71 	uint32_t	time_remaining_msec;
72 	uint32_t	force_flag;
73 } __packed;
74 
75 
76 struct tw_cl_compatibility_packet {
77 	uint8_t		driver_version[32];/* driver version */
78 	uint16_t	working_srl;	/* driver & firmware negotiated srl */
79 	uint16_t	working_branch;	/* branch # of the firmware that the driver is compatible with */
80 	uint16_t	working_build;	/* build # of the firmware that the driver is compatible with */
81 } __packed;
82 
83 
84 struct twa_driver_packet {
85 	uint32_t	control_code;
86 	uint32_t	status;
87 	uint32_t	unique_id;
88 	uint32_t	sequence_id;
89 	uint32_t	os_status;
90 	uint32_t	buffer_length;
91 } __packed;
92 
93 /* Account for differences between 32/64 bit system. Offsets into memory
94  * are anticipated for driver/firmware command packets and having a
95  * variable sized pointer depending on architecture add 4 bytes to any offset
96  * after the pdata declaration
97  */
98 #define TW_SIZEOF_VOIDPTR		(sizeof(void *))
99 
100 struct twa_ioctl_9k {
101 	struct twa_driver_packet	twa_drvr_pkt;
102 	void				*pdata; /* points to data_buf */
103 	int8_t				padding[488 - TW_SIZEOF_VOIDPTR];
104 	struct twa_command_packet	twa_cmd_pkt;
105 	int8_t				data_buf[1];
106 } __packed;
107 
108 typedef struct twa_ioctl_with_payload {
109 	struct twa_driver_packet	twa_drvr_pkt;
110 	int8_t				padding[488];
111 	struct twa_command_packet	twa_cmd_pkt;
112 	union {
113 		struct tw_cl_event_packet		event_pkt;
114 		struct tw_cl_lock_packet 		lock_pkt;
115 		struct tw_cl_compatibility_packet	compat_pkt;
116 		int8_t					data_buf[1];
117 	} payload;
118 }  __packed TWA_IOCTL_WITH_PAYLOAD;
119 
120 /*
121  * We need the structure below to ensure that the first byte of
122  * data_buf is not overwritten by the kernel, after we return
123  * from the ioctl call.  Note that twa_cmd_pkt has been reduced
124  * to an array of 1024 bytes even though it's actually 2048 bytes
125  * in size.  This is because, we don't expect requests from user
126  * land requiring 2048 (273 sg elements) byte cmd pkts.
127  */
128 typedef struct twa_ioctl_no_data_buf {
129 	struct twa_driver_packet	twa_drvr_pkt;
130 	void				*pdata; /* points to data_buf */
131 	int8_t				padding[488 - TW_SIZEOF_VOIDPTR];
132 	struct twa_command_packet	twa_cmd_pkt;
133 }  __packed TWA_IOCTL_NO_DATA_BUF;
134 
135 
136 /*
137  * Get the device external name of the specified array unit.
138  */
139  /* WASABI */
140 struct twa_unitname {
141 	int		tn_unit;
142 	char		tn_name[16];	/* XXX sizeof(dev->dv_xname) */
143 };
144 
145 #define TW_OSL_IOCTL_SCAN_BUS		_IO ('T', 200)
146 
147 #define TW_OSL_IOCTL_FIRMWARE_PASS_THROUGH \
148 	_IOWR('T', 202, TWA_IOCTL_NO_DATA_BUF)
149 
150 #define TW_CL_IOCTL_GET_FIRST_EVENT	_IOWR('T', 203, TWA_IOCTL_WITH_PAYLOAD)
151 #define TW_CL_IOCTL_GET_LAST_EVENT	_IOWR('T', 204, TWA_IOCTL_WITH_PAYLOAD)
152 #define TW_CL_IOCTL_GET_NEXT_EVENT	_IOWR('T', 205, TWA_IOCTL_WITH_PAYLOAD)
153 #define TW_CL_IOCTL_GET_PREVIOUS_EVENT	_IOWR('T', 206, TWA_IOCTL_WITH_PAYLOAD)
154 #define TW_CL_IOCTL_GET_LOCK		_IOWR('T', 207, TWA_IOCTL_WITH_PAYLOAD)
155 #define TW_CL_IOCTL_RELEASE_LOCK	_IOWR('T', 208, TWA_IOCTL_WITH_PAYLOAD)
156 #define TW_CL_IOCTL_GET_COMPATIBILITY_INFO 	\
157 	_IOWR('T', 209, TWA_IOCTL_WITH_PAYLOAD)
158 /* WASABI */
159 #define	TWA_IOCTL_GET_UNITNAME		_IOWR('T', 220, struct twa_unitname)
160 
161 #endif /* _DEV_PCI_TWAIO_H_ */
162