187011Smsmith/*-
287011Smsmith * Copyright (c) 2001 Michael Smith
387011Smsmith * All rights reserved.
487011Smsmith *
587011Smsmith * Redistribution and use in source and binary forms, with or without
687011Smsmith * modification, are permitted provided that the following conditions
787011Smsmith * are met:
887011Smsmith * 1. Redistributions of source code must retain the above copyright
987011Smsmith *    notice, this list of conditions and the following disclaimer.
1087011Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1187011Smsmith *    notice, this list of conditions and the following disclaimer in the
1287011Smsmith *    documentation and/or other materials provided with the distribution.
1387011Smsmith *
1487011Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1587011Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1687011Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1787011Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1887011Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1987011Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2087011Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2187011Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2287011Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2387011Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2487011Smsmith * SUCH DAMAGE.
2587011Smsmith *
2687011Smsmith *	$FreeBSD$
2787011Smsmith */
2887011Smsmith
2987011Smsmith/*
3087011Smsmith * Driver ioctl interface.
3187011Smsmith *
3287011Smsmith * Note that this interface is API-compatible with the Linux implementation
3387011Smsmith * except as noted, and thus this header bears a striking resemblance to
3487011Smsmith * the Linux driver's cciss_ioctl.h.
3587011Smsmith *
3687011Smsmith */
3787011Smsmith
3887011Smsmith#include <sys/ioccom.h>
3987011Smsmith
4087011Smsmith#pragma pack(1)
4187011Smsmith
4287011Smsmithtypedef struct
4387011Smsmith{
4487011Smsmith    u_int8_t	bus;
4587011Smsmith    u_int8_t	dev_fn;
4687011Smsmith    u_int32_t	board_id;
4787011Smsmith} cciss_pci_info_struct;
4887011Smsmith
4987011Smsmithtypedef struct
5087011Smsmith{
5187011Smsmith    u_int32_t	delay;
5287011Smsmith    u_int32_t	count;
5387011Smsmith} cciss_coalint_struct;
5487011Smsmith
5587011Smsmithtypedef char		NodeName_type[16];
5687011Smsmithtypedef u_int32_t	Heartbeat_type;
5787011Smsmith
5887011Smsmith#define CISS_PARSCSIU2	0x0001
5987011Smsmith#define CISS_PARCSCIU3	0x0002
6087011Smsmith#define CISS_FIBRE1G	0x0100
6187011Smsmith#define CISS_FIBRE2G	0x0200
6287011Smsmithtypedef u_int32_t	BusTypes_type;
6387011Smsmith
6487011Smsmithtypedef char		FirmwareVer_type[4];
6587011Smsmithtypedef u_int32_t	DriverVer_type;
6687011Smsmith
6787011Smsmith/* passthrough command definitions */
6887011Smsmith#define SENSEINFOBYTES          32
6987011Smsmith#define CISS_MAX_LUN		16
7087011Smsmith#define LEVEL2LUN		1
7187011Smsmith#define LEVEL3LUN		0
7287011Smsmith
7387011Smsmith/* command status value */
7487011Smsmith#define CMD_SUCCESS		0x0000
7587011Smsmith#define CMD_TARGET_STATUS	0x0001
7687011Smsmith#define CMD_DATA_UNDERRUN	0x0002
7787011Smsmith#define CMD_DATA_OVERRUN	0x0003
7887011Smsmith#define CMD_INVALID		0x0004
7987011Smsmith#define CMD_PROTOCOL_ERR	0x0005
8087011Smsmith#define CMD_HARDWARE_ERR	0x0006
8187011Smsmith#define CMD_CONNECTION_LOST	0x0007
8287011Smsmith#define CMD_ABORTED		0x0008
8387011Smsmith#define CMD_ABORT_FAILED	0x0009
8487011Smsmith#define CMD_UNSOLICITED_ABORT	0x000A
8587011Smsmith#define CMD_TIMEOUT		0x000B
8687011Smsmith#define CMD_UNABORTABLE		0x000C
8787011Smsmith
8887011Smsmith/* transfer direction */
8987011Smsmith#define XFER_NONE		0x00
9087011Smsmith#define XFER_WRITE		0x01
9187011Smsmith#define XFER_READ		0x02
9287011Smsmith#define XFER_RSVD		0x03
9387011Smsmith
9487011Smsmith/* task attribute */
9587011Smsmith#define ATTR_UNTAGGED		0x00
9687011Smsmith#define ATTR_SIMPLE		0x04
9787011Smsmith#define ATTR_HEADOFQUEUE	0x05
9887011Smsmith#define ATTR_ORDERED		0x06
9987011Smsmith#define ATTR_ACA		0x07
10087011Smsmith
10187011Smsmith/* CDB type */
10287011Smsmith#define TYPE_CMD		0x00
10387011Smsmith#define TYPE_MSG		0x01
10487011Smsmith
10587011Smsmith/* command list structure */
10687011Smsmithtypedef union {
10787011Smsmith    struct {
10887011Smsmith	u_int8_t	Dev;
10987011Smsmith	u_int8_t	Bus:6;
11087011Smsmith	u_int8_t	Mode:2;
111132829Sps    } __packed PeripDev;
11287011Smsmith    struct {
11387011Smsmith	u_int8_t	DevLSB;
11487011Smsmith	u_int8_t	DevMSB:6;
11587011Smsmith	u_int8_t	Mode:2;
116132829Sps    } __packed LogDev;
11787011Smsmith    struct {
11887011Smsmith	u_int8_t	Dev:5;
11987011Smsmith	u_int8_t	Bus:3;
12087011Smsmith	u_int8_t	Targ:6;
12187011Smsmith	u_int8_t	Mode:2;
122132829Sps    } __packed LogUnit;
12387011Smsmith} SCSI3Addr_struct;
12487011Smsmith
125132829Spstypedef struct {
12687011Smsmith    u_int32_t		TargetId:24;
12787011Smsmith    u_int32_t		Bus:6;
12887011Smsmith    u_int32_t		Mode:2;
12987011Smsmith    SCSI3Addr_struct	Target[2];
130132829Sps} __packed PhysDevAddr_struct;
13187011Smsmith
132132829Spstypedef struct {
13387011Smsmith    u_int32_t		VolId:30;
13487011Smsmith    u_int32_t		Mode:2;
13587011Smsmith    u_int8_t		reserved[4];
136132829Sps} __packed LogDevAddr_struct;
13787011Smsmith
13887011Smsmithtypedef union {
13987011Smsmith    u_int8_t		LunAddrBytes[8];
14087011Smsmith    SCSI3Addr_struct	SCSI3Lun[4];
141132829Sps    PhysDevAddr_struct	PhysDev;
142132829Sps    LogDevAddr_struct	LogDev;
143132829Sps} __packed LUNAddr_struct;
14487011Smsmith
145132829Spstypedef struct {
14687011Smsmith    u_int8_t	CDBLen;
14787011Smsmith    struct {
14887011Smsmith	u_int8_t	Type:3;
14987011Smsmith	u_int8_t	Attribute:3;
15087011Smsmith	u_int8_t	Direction:2;
151132829Sps    } __packed Type;
15287011Smsmith    u_int16_t	Timeout;
15387011Smsmith    u_int8_t	CDB[16];
154132829Sps} __packed RequestBlock_struct;
15587011Smsmith
15687011Smsmithtypedef union {
15787011Smsmith    struct {
15887011Smsmith	u_int8_t	Reserved[3];
15987011Smsmith	u_int8_t	Type;
16087011Smsmith	u_int32_t	ErrorInfo;
161132829Sps    } __packed Common_Info;
16287011Smsmith    struct {
16387011Smsmith	u_int8_t	Reserved[2];
16487011Smsmith	u_int8_t	offense_size;
16587011Smsmith	u_int8_t	offense_num;
16687011Smsmith	u_int32_t	offense_value;
167132829Sps    } __packed Invalid_Cmd;
168132829Sps} __packed MoreErrInfo_struct;
16987011Smsmith
170132829Spstypedef struct {
17187011Smsmith    u_int8_t		ScsiStatus;
17287011Smsmith    u_int8_t		SenseLen;
17387011Smsmith    u_int16_t		CommandStatus;
17487011Smsmith    u_int32_t		ResidualCnt;
17587011Smsmith    MoreErrInfo_struct	MoreErrInfo;
17687011Smsmith    u_int8_t		SenseInfo[SENSEINFOBYTES];
177132829Sps} __packed ErrorInfo_struct;
17887011Smsmith
179132829Spstypedef struct {
18087011Smsmith    LUNAddr_struct	LUN_info;	/* 8 */
18187011Smsmith    RequestBlock_struct	Request;	/* 20 */
18287011Smsmith    ErrorInfo_struct	error_info;	/* 48 */
18387011Smsmith    u_int16_t		buf_size;	/* 2 */
18487011Smsmith    u_int8_t		*buf;		/* 4 */
185132829Sps} __packed IOCTL_Command_struct;
18687011Smsmith
187146337Sps#ifdef __amd64__
188146337Spstypedef struct {
189146337Sps    LUNAddr_struct	LUN_info;	/* 8 */
190146337Sps    RequestBlock_struct	Request;	/* 20 */
191146337Sps    ErrorInfo_struct	error_info;	/* 48 */
192146337Sps    u_int16_t		buf_size;	/* 2 */
193146337Sps    u_int32_t		buf;		/* 4 */
194146337Sps} __packed IOCTL_Command_struct32;
195146337Sps#endif
196146337Sps
197180454Sscottl/************************************************************************
198180454Sscottl * Command queue statistics
199180454Sscottl */
200180454Sscottl
201180454Sscottl#define CISSQ_FREE	0
202180454Sscottl#define CISSQ_NOTIFY	1
203180454Sscottl#define CISSQ_COUNT	2
204180454Sscottl
205180454Sscottlstruct ciss_qstat {
206180454Sscottl    uint32_t		q_length;
207180454Sscottl    uint32_t		q_max;
208180454Sscottl};
209180454Sscottl
210180454Sscottlunion ciss_statrequest {
211180454Sscottl    uint32_t		cs_item;
212180454Sscottl    struct ciss_qstat	cs_qstat;
213180454Sscottl};
214180454Sscottl
21587011Smsmith/*
21687011Smsmith * Note that we'd normally pass the struct in directly, but
21787011Smsmith * this code is trying to be compatible with other drivers.
21887011Smsmith */
21987011Smsmith#define CCISS_GETPCIINFO	_IOR ('C', 200, cciss_pci_info_struct)
22087011Smsmith#define CCISS_GETINTINFO	_IOR ('C', 201, cciss_coalint_struct)
22187011Smsmith#define CCISS_SETINTINFO	_IOW ('C', 202, cciss_coalint_struct)
22287011Smsmith#define CCISS_GETNODENAME	_IOR ('C', 203, NodeName_type)
22387011Smsmith#define CCISS_SETNODENAME	_IOW ('C', 204, NodeName_type)
22487011Smsmith#define CCISS_GETHEARTBEAT	_IOR ('C', 205, Heartbeat_type)
22587011Smsmith#define CCISS_GETBUSTYPES	_IOR ('C', 206, BusTypes_type)
22687011Smsmith#define CCISS_GETFIRMVER	_IOR ('C', 207, FirmwareVer_type)
22787011Smsmith#define CCISS_GETDRIVERVER	_IOR ('C', 208, DriverVer_type)
22887011Smsmith#define CCISS_REVALIDVOLS	_IO  ('C', 209)
22987011Smsmith#define CCISS_PASSTHRU		_IOWR ('C', 210, IOCTL_Command_struct)
230146337Sps#ifdef __amd64
231146337Sps#define CCISS_PASSTHRU32	_IOWR ('C', 210, IOCTL_Command_struct32)
232146337Sps#endif
233180454Sscottl#define CCISS_GETQSTATS		_IOWR ('C', 211, union ciss_statrequest)
23487011Smsmith
23587011Smsmith#pragma pack()
236