1*4c06356bSdh /*
2*4c06356bSdh  * CDDL HEADER START
3*4c06356bSdh  *
4*4c06356bSdh  * The contents of this file are subject to the terms of the
5*4c06356bSdh  * Common Development and Distribution License (the "License").
6*4c06356bSdh  * You may not use this file except in compliance with the License.
7*4c06356bSdh  *
8*4c06356bSdh  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*4c06356bSdh  * or http://www.opensolaris.org/os/licensing.
10*4c06356bSdh  * See the License for the specific language governing permissions
11*4c06356bSdh  * and limitations under the License.
12*4c06356bSdh  *
13*4c06356bSdh  * When distributing Covered Code, include this CDDL HEADER in each
14*4c06356bSdh  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*4c06356bSdh  * If applicable, add the following below this CDDL HEADER, with the
16*4c06356bSdh  * fields enclosed by brackets "[]" replaced with your own identifying
17*4c06356bSdh  * information: Portions Copyright [yyyy] [name of copyright owner]
18*4c06356bSdh  *
19*4c06356bSdh  * CDDL HEADER END
20*4c06356bSdh  *
21*4c06356bSdh  *
22*4c06356bSdh  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*4c06356bSdh  * Use is subject to license terms.
24*4c06356bSdh  */
25*4c06356bSdh /*
26*4c06356bSdh  * SAS Common Structures and Definitions
27*4c06356bSdh  * sas2r14, simplified/reduced
28*4c06356bSdh  */
29*4c06356bSdh #ifndef	_SAS_H
30*4c06356bSdh #define	_SAS_H
31*4c06356bSdh #ifdef	__cplusplus
32*4c06356bSdh extern "C" {
33*4c06356bSdh #endif
35*4c06356bSdh #include <sys/sysmacros.h>
36*4c06356bSdh /*
37*4c06356bSdh  * SAS Address Frames
38*4c06356bSdh  * Trailing 4 byte CRC not included.
39*4c06356bSdh  */
40*4c06356bSdh typedef struct {
41*4c06356bSdh 	DECL_BITFIELD3(
42*4c06356bSdh 	    address_frame_type		:4,
43*4c06356bSdh 	    device_type			:3,
44*4c06356bSdh 	    reserved0			:1);
45*4c06356bSdh 	DECL_BITFIELD2(
46*4c06356bSdh 	    reason			:4,
47*4c06356bSdh 	    reserved1			:4);
48*4c06356bSdh 	DECL_BITFIELD5(
49*4c06356bSdh 	    restricted0			:1,
50*4c06356bSdh 	    smp_ini_port		:1,
51*4c06356bSdh 	    stp_ini_port		:1,
52*4c06356bSdh 	    ssp_ini_port		:1,
53*4c06356bSdh 	    reserved2			:4);
54*4c06356bSdh 	DECL_BITFIELD5(
55*4c06356bSdh 	    restricted1			:1,
56*4c06356bSdh 	    smp_tgt_port		:1,
57*4c06356bSdh 	    stp_tgt_port		:1,
58*4c06356bSdh 	    ssp_tgt_port		:1,
59*4c06356bSdh 	    reserved3			:4);
60*4c06356bSdh 	uint8_t		device_name[8];
61*4c06356bSdh 	uint8_t		sas_address[8];
62*4c06356bSdh 	uint8_t		phy_identifier;
63*4c06356bSdh 	DECL_BITFIELD4(
64*4c06356bSdh 	    break_reply_capable		:1,
65*4c06356bSdh 	    requested_inside_zpsds	:1,
66*4c06356bSdh 	    inside_zpsds_persistent	:1,
67*4c06356bSdh 	    reserved4			:5);
68*4c06356bSdh 	uint8_t		reserved5[6];
69*4c06356bSdh } sas_identify_af_t;
71*4c06356bSdh typedef struct {
72*4c06356bSdh 	DECL_BITFIELD3(
73*4c06356bSdh 	    address_frame_type		:4,
74*4c06356bSdh 	    protocol			:3,
75*4c06356bSdh 	    ini_port			:1);
76*4c06356bSdh 	DECL_BITFIELD2(
77*4c06356bSdh 	    connection_rate		:4,
78*4c06356bSdh 	    features			:4);
79*4c06356bSdh 	uint16_t 	itag;			/* initiator connection tag */
80*4c06356bSdh 	uint8_t 	sas_dst[8];		/* destination sas address */
81*4c06356bSdh 	uint8_t 	sas_src[8];		/* source sas address */
82*4c06356bSdh 	uint8_t 	src_zone_group;		/* source zone group  */
83*4c06356bSdh 	uint8_t 	path_block_count;	/* pathway blocked count */
84*4c06356bSdh 	uint16_t	arb_wait_time;		/* arbitration wait time */
85*4c06356bSdh 	uint8_t 	compat[4];		/* 'more' compatible features */
86*4c06356bSdh } sas_open_af_t;
88*4c06356bSdh #define	SAS_AF_IDENTIFY			0
89*4c06356bSdh #define	SAS_AF_OPEN			1
91*4c06356bSdh #define	SAS_IF_DTYPE_ENDPOINT		1
92*4c06356bSdh #define	SAS_IF_DTYPE_EDGE		2
93*4c06356bSdh #define	SAS_IF_DTYPE_FANOUT		3	/* obsolete */
95*4c06356bSdh #define	SAS_OF_PROTO_SMP		0
96*4c06356bSdh #define	SAS_OF_PROTO_SSP		1
97*4c06356bSdh #define	SAS_OF_PROTO_STP		2
99*4c06356bSdh #define	SAS_SSP_SUPPORT			0x8
100*4c06356bSdh #define	SAS_STP_SUPPORT			0x4
101*4c06356bSdh #define	SAS_SMP_SUPPORT			0x2
104*4c06356bSdh #define	SAS_CONNRATE_1_5_GBPS		0x8
105*4c06356bSdh #define	SAS_CONNRATE_3_0_GBPS		0x9
106*4c06356bSdh #define	SAS_CONNRATE_6_0_GBPS		0xA
108*4c06356bSdh #define	SAS_SATA_SUPPORT		0x1
109*4c06356bSdh #define	SAS_ATTACHED_NAME_OFFSET	52	/* SAS-2 only */
111*4c06356bSdh /*
112*4c06356bSdh  * SSP Definitions
113*4c06356bSdh  */
114*4c06356bSdh typedef struct {
115*4c06356bSdh 	uint8_t		lun[8];
116*4c06356bSdh 	uint8_t		reserved0;
117*4c06356bSdh 	DECL_BITFIELD3(
118*4c06356bSdh 	    task_attribute	:2,
119*4c06356bSdh 	    command_priority	:4,
120*4c06356bSdh 	    enable_first_burst	:1);
121*4c06356bSdh 	uint8_t		reserved1;
122*4c06356bSdh 	DECL_BITFIELD2(
123*4c06356bSdh 	    reserved2		:2,
124*4c06356bSdh 	    addi_cdb_len	:6);
125*4c06356bSdh 	uint8_t		cdb[16];
126*4c06356bSdh 	/* additional cdb bytes go here, followed by 4 byte CRC */
127*4c06356bSdh } sas_ssp_cmd_iu_t;
129*4c06356bSdh #define	SAS_CMD_TASK_ATTR_SIMPLE	0x00
130*4c06356bSdh #define	SAS_CMD_TASK_ATTR_HEAD		0x01
131*4c06356bSdh #define	SAS_CMD_TASK_ATTR_ORDERED	0x02
132*4c06356bSdh #define	SAS_CMD_TASK_ATTR_ACA		0x04
134*4c06356bSdh typedef struct {
135*4c06356bSdh 	uint8_t		reserved0[8];
136*4c06356bSdh 	uint16_t	status_qualifier;
137*4c06356bSdh 	DECL_BITFIELD2(
138*4c06356bSdh 	    datapres		:2,
139*4c06356bSdh 	    reserved1		:6);
140*4c06356bSdh 	uint8_t		status;
141*4c06356bSdh 	uint8_t		reserved2[4];
142*4c06356bSdh 	uint32_t	sense_data_length;
143*4c06356bSdh 	uint32_t	response_data_length;
144*4c06356bSdh 	uint8_t		rspd[];
145*4c06356bSdh 	/* response data followed by sense data goes here */
146*4c06356bSdh } sas_ssp_rsp_iu_t;
148*4c06356bSdh /* length of bytes up to response data */
149*4c06356bSdh #define	SAS_RSP_HDR_SIZE		24
151*4c06356bSdh #define	SAS_RSP_DATAPRES_NO_DATA	0x00
152*4c06356bSdh #define	SAS_RSP_DATAPRES_RESPONSE_DATA	0x01
153*4c06356bSdh #define	SAS_RSP_DATAPRES_SENSE_DATA	0x02
155*4c06356bSdh /*
156*4c06356bSdh  * When the RSP IU is type RESPONSE_DATA,
157*4c06356bSdh  * the first 4 bytes of response data should
158*4c06356bSdh  * be a Big Endian representation of one of
159*4c06356bSdh  * these codes.
160*4c06356bSdh  */
161*4c06356bSdh #define	SAS_RSP_TMF_COMPLETE		0x00
162*4c06356bSdh #define	SAS_RSP_INVALID_FRAME		0x02
163*4c06356bSdh #define	SAS_RSP_TMF_NOT_SUPPORTED	0x04
164*4c06356bSdh #define	SAS_RSP_TMF_FAILED		0x05
165*4c06356bSdh #define	SAS_RSP_TMF_SUCCEEDED		0x08
166*4c06356bSdh #define	SAS_RSP_TMF_INCORRECT_LUN	0x09
167*4c06356bSdh #define	SAS_RSP_OVERLAPPED_OIPTTA	0x0A
169*4c06356bSdh /*
170*4c06356bSdh  * Task Management Functions- should be in a SAM definition file
171*4c06356bSdh  */
172*4c06356bSdh #define	SAS_ABORT_TASK			0x01
173*4c06356bSdh #define	SAS_ABORT_TASK_SET		0x02
174*4c06356bSdh #define	SAS_CLEAR_TASK_SET		0x04
175*4c06356bSdh #define	SAS_LOGICAL_UNIT_RESET		0x08
176*4c06356bSdh #define	SAS_I_T_NEXUS_RESET		0x10
177*4c06356bSdh #define	SAS_CLEAR_ACA			0x40
178*4c06356bSdh #define	SAS_QUERY_TASK			0x80
179*4c06356bSdh #define	SAS_QUERY_TASK_SET		0x81
180*4c06356bSdh #define	SAS_QUERY_UNIT_ATTENTION	0x82
182*4c06356bSdh /*
183*4c06356bSdh  * PHY size changed from SAS1.1 to SAS2.
184*4c06356bSdh  */
185*4c06356bSdh #define	SAS_PHYNUM_MAX			127
186*4c06356bSdh #define	SAS_PHYNUM_MASK			0x7f
188*4c06356bSdh #define	SAS2_PHYNUM_MAX			254
189*4c06356bSdh #define	SAS2_PHYNUM_MASK		0xff
192*4c06356bSdh /*
193*4c06356bSdh  * Maximum SMP payload size, including CRC
194*4c06356bSdh  */
195*4c06356bSdh #define	SAS_SMP_MAX_PAYLOAD		1032
196*4c06356bSdh #ifdef	__cplusplus
197*4c06356bSdh }
198*4c06356bSdh #endif
199*4c06356bSdh #endif	/* _SAS_H */