1216088Sken/*-
2216088Sken * Copyright (c) 2010 Spectra Logic Corporation
3216088Sken * All rights reserved.
4216088Sken *
5216088Sken * Redistribution and use in source and binary forms, with or without
6216088Sken * modification, are permitted provided that the following conditions
7216088Sken * are met:
8216088Sken * 1. Redistributions of source code must retain the above copyright
9216088Sken *    notice, this list of conditions, and the following disclaimer,
10216088Sken *    without modification.
11216088Sken * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12216088Sken *    substantially similar to the "NO WARRANTY" disclaimer below
13216088Sken *    ("Disclaimer") and any redistribution must be conditioned upon
14216088Sken *    including a substantially similar Disclaimer requirement for further
15216088Sken *    binary redistribution.
16216088Sken *
17216088Sken * NO WARRANTY
18216088Sken * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19216088Sken * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20216088Sken * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21216088Sken * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22216088Sken * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23216088Sken * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24216088Sken * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25216088Sken * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26216088Sken * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27216088Sken * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28216088Sken * POSSIBILITY OF SUCH DAMAGES.
29216088Sken *
30216088Sken * $Id: //depot/users/kenm/FreeBSD-test/sys/cam/scsi/smp_all.h#4 $
31216088Sken * $FreeBSD: releng/10.2/sys/cam/scsi/smp_all.h 216088 2010-11-30 22:39:46Z ken $
32216088Sken */
33216088Sken
34216088Sken/*
35216088Sken * Serial Management Protocol definitions.
36216088Sken */
37216088Sken
38216088Sken#ifndef	_SCSI_SMP_ALL_H
39216088Sken#define	_SCSI_SMP_ALL_H	1
40216088Sken
41216088Sken#define	SMP_FRAME_TYPE_REQUEST	0x40
42216088Sken#define	SMP_FRAME_TYPE_RESPONSE	0x41
43216088Sken#define	SMP_WORD_LEN		4
44216088Sken#define	SMP_CRC_LEN		4
45216088Sken
46216088Sken/*
47216088Sken * SMP Functions (current as of SPL Revision 7)
48216088Sken */
49216088Sken/* 0x00 to 0x7f: SMP input functions */
50216088Sken/* 0x00 to 0x0f: General SMP input functions */
51216088Sken#define	SMP_FUNC_REPORT_GENERAL		0x00
52216088Sken#define	SMP_FUNC_REPORT_MANUF_INFO	0x01
53216088Sken#define	SMP_FUNC_REPORT_SC_STATUS	0x03
54216088Sken#define	SMP_FUNC_REPORT_ZONE_PERM_TBL	0x04
55216088Sken#define	SMP_FUNC_REPORT_ZONE_MAN_PWD	0x05
56216088Sken#define	SMP_FUNC_REPORT_BROADCAST	0x06
57216088Sken
58216088Sken/* 0x10 to 0x1f: Phy-based SMP input functions */
59216088Sken#define	SMP_FUNC_DISCOVER		0x10
60216088Sken#define	SMP_FUNC_REPORT_PHY_ERR_LOG	0x11
61216088Sken#define	SMP_FUNC_REPORT_PHY_SATA	0x12
62216088Sken#define	SMP_FUNC_REPORT_ROUTE_INFO	0x13
63216088Sken#define	SMP_FUNC_REPORT_PHY_EVENT	0x14
64216088Sken
65216088Sken/* 0x20 to 0x2f: Descriptor list-based SMP input functions */
66216088Sken#define	SMP_FUNC_DISCOVER_LIST		0x20
67216088Sken#define	SMP_FUNC_REPORT_PHY_EVENT_LIST	0x21
68216088Sken#define	SMP_FUNC_REPORT_EXP_RTL		0x22
69216088Sken
70216088Sken/* 0x30 to 0x3f: Reserved for SMP input functions */
71216088Sken/* 0x40 to 0x7f: Vendor specific */
72216088Sken
73216088Sken/* 0x80 to 0xff: SMP output functions */
74216088Sken/* 0x80 to 0x8f: General SMP output functions */
75216088Sken#define	SMP_FUNC_CONFIG_GENERAL		0x80
76216088Sken#define	SMP_FUNC_ENABLE_DISABLE_ZONING	0x81
77216088Sken#define	SMP_FUNC_ZONED_BROADCAST	0x85
78216088Sken#define	SMP_FUNC_ZONE_LOCK		0x86
79216088Sken#define	SMP_FUNC_ZONE_ACTIVATE		0x87
80216088Sken#define	SMP_FUNC_ZONE_UNLOCK		0x88
81216088Sken#define	SMP_FUNC_CONFIG_ZM_PWD		0x89
82216088Sken#define	SMP_FUNC_CONFIG_ZONE_PHY_INFO	0x8a
83216088Sken#define	SMP_FUNC_CONFIG_ZONE_PERM_TBL	0x8b
84216088Sken
85216088Sken/* 0x90 to 0x9f: Phy-based SMP output functions */
86216088Sken#define	SMP_FUNC_CONFIG_ROUTE_INFO	0x90
87216088Sken#define	SMP_FUNC_PHY_CONTROL		0x91
88216088Sken#define	SMP_FUNC_PHY_TEST_FUNC		0x92
89216088Sken#define	SMP_FUNC_CONFIG_PHY_EVENT	0x93
90216088Sken
91216088Sken/* 0xa0 to 0xbf: Reserved for SMP output functions */
92216088Sken/* 0xc0 to 0xff: Vendor specific */
93216088Sken
94216088Sken/*
95216088Sken * Function Results (current as of SPL Revision 7)
96216088Sken */
97216088Sken#define	SMP_FR_ACCEPTED			0x00
98216088Sken#define	SMP_FR_UNKNOWN_FUNC		0x01
99216088Sken#define	SMP_FR_FUNCTION_FAILED		0x02
100216088Sken#define	SMP_FR_INVALID_REQ_FRAME_LEN	0x03
101216088Sken#define	SMP_FR_INVALID_EXP_CHG_CNT	0x04
102216088Sken#define	SMP_FR_BUSY			0x05
103216088Sken#define	SMP_FR_INCOMPLETE_DESC_LIST	0x06
104216088Sken#define	SMP_FR_PHY_DOES_NOT_EXIST	0x10
105216088Sken#define	SMP_FR_INDEX_DOES_NOT_EXIST	0x11
106216088Sken#define	SMP_FR_PHY_DOES_NOT_SUP_SATA	0x12
107216088Sken#define	SMP_FR_UNKNOWN_PHY_OP		0x13
108216088Sken#define	SMP_FR_UNKNOWN_PHY_TEST_FUNC	0x14
109216088Sken#define	SMP_FR_PHY_TEST_FUNC_INPROG	0x15
110216088Sken#define	SMP_FR_PHY_VACANT		0x16
111216088Sken#define	SMP_FR_UNKNOWN_PHY_EVENT_SRC	0x17
112216088Sken#define	SMP_FR_UNKNOWN_DESC_TYPE	0x18
113216088Sken#define	SMP_FR_UNKNOWN_PHY_FILTER	0x19
114216088Sken#define	SMP_FR_AFFILIATION_VIOLATION	0x1a
115216088Sken#define	SMP_FR_SMP_ZONE_VIOLATION	0x20
116216088Sken#define	SMP_FR_NO_MGMT_ACCESS_RIGHTS	0x21
117216088Sken#define	SMP_FR_UNKNOWN_ED_ZONING_VAL	0x22
118216088Sken#define	SMP_FR_ZONE_LOCK_VIOLATION	0x23
119216088Sken#define	SMP_FR_NOT_ACTIVATED		0x24
120216088Sken#define	SMP_FR_ZG_OUT_OF_RANGE		0x25
121216088Sken#define	SMP_FR_NO_PHYS_PRESENCE		0x26
122216088Sken#define	SMP_FR_SAVING_NOT_SUP		0x27
123216088Sken#define	SMP_FR_SRC_ZONE_DNE		0x28
124216088Sken#define	SMP_FR_DISABLED_PWD_NOT_SUP	0x29
125216088Sken
126216088Sken/*
127216088Sken * REPORT GENERAL request and response, current as of SPL Revision 7.
128216088Sken */
129216088Skenstruct smp_report_general_request
130216088Sken{
131216088Sken	uint8_t	frame_type;
132216088Sken	uint8_t	function;
133216088Sken	uint8_t	response_len;
134216088Sken	uint8_t	request_len;
135216088Sken	uint8_t	crc[4];
136216088Sken};
137216088Sken
138216088Skenstruct smp_report_general_response
139216088Sken{
140216088Sken	uint8_t	frame_type;
141216088Sken	uint8_t	function;
142216088Sken	uint8_t	function_result;
143216088Sken	uint8_t	response_len;
144216088Sken#define	SMP_RG_RESPONSE_LEN		0x11
145216088Sken	uint8_t	expander_change_count[2];
146216088Sken	uint8_t	expander_route_indexes[2];
147216088Sken	uint8_t	long_response;
148216088Sken#define	SMP_RG_LONG_RESPONSE		0x80
149216088Sken	uint8_t	num_phys;
150216088Sken	uint8_t	config_bits0;
151216088Sken#define	SMP_RG_TABLE_TO_TABLE_SUP	0x80
152216088Sken#define	SMP_RG_ZONE_CONFIGURING		0x40
153216088Sken#define	SMP_RG_SELF_CONFIGURING		0x20
154216088Sken#define	SMP_RG_STP_CONTINUE_AWT		0x10
155216088Sken#define	SMP_RG_OPEN_REJECT_RETRY_SUP	0x08
156216088Sken#define	SMP_RG_CONFIGURES_OTHERS	0x04
157216088Sken#define	SMP_RG_CONFIGURING		0x02
158216088Sken#define	SMP_RG_EXT_CONFIG_ROUTE_TABLE	0x01
159216088Sken	uint8_t	reserved0;
160216088Sken	uint8_t	encl_logical_id[8];
161216088Sken	uint8_t	reserved1[8];
162216088Sken	uint8_t	reserved2[2];
163216088Sken	uint8_t	stp_bus_inact_time_limit[2];
164216088Sken	uint8_t	stp_max_conn_time_limit[2];
165216088Sken	uint8_t	stp_smp_it_nexus_loss_time[2];
166216088Sken	uint8_t	config_bits1;
167216088Sken#define	SMP_RG_NUM_ZONE_GROUPS_MASK	0xc0
168216088Sken#define	SMP_RG_NUM_ZONE_GROUPS_SHIFT	6
169216088Sken#define	SMP_RG_ZONE_LOCKED		0x10
170216088Sken#define	SMP_RG_PP_SUPPORTED		0x08
171216088Sken#define	SMP_RG_PP_ASSERTED		0x04
172216088Sken#define	SMP_RG_ZONING_SUPPORTED		0x02
173216088Sken#define	SMP_RG_ZONING_ENABLED		0x01
174216088Sken	uint8_t	config_bits2;
175216088Sken#define	SMP_RG_SAVING			0x10
176216088Sken#define	SMP_RG_SAVING_ZM_PWD_SUP	0x08
177216088Sken#define	SMP_RG_SAVING_PHY_INFO_SUP	0x04
178216088Sken#define	SMP_RG_SAVING_ZPERM_TAB_SUP	0x02
179216088Sken#define	SMP_RG_SAVING_ZENABLED_SUP	0x01
180216088Sken	uint8_t	max_num_routed_addrs[2];
181216088Sken	uint8_t	active_zm_address[8];
182216088Sken	uint8_t	zone_lock_inact_time_limit[2];
183216088Sken	uint8_t	reserved3[2];
184216088Sken	uint8_t	reserved4;
185216088Sken	uint8_t	first_encl_conn_el_index;
186216088Sken	uint8_t	num_encl_conn_el_indexes;
187216088Sken	uint8_t	reserved5;
188216088Sken	uint8_t	reduced_functionality;
189216088Sken#define	SMP_RG_REDUCED_FUNCTIONALITY	0x80
190216088Sken	uint8_t	time_to_reduced_func;
191216088Sken	uint8_t	initial_time_to_reduced_func;
192216088Sken	uint8_t	max_reduced_func_time;
193216088Sken	uint8_t	last_sc_stat_desc_index[2];
194216088Sken	uint8_t	max_sc_stat_descs[2];
195216088Sken	uint8_t	last_phy_evl_desc_index[2];
196216088Sken	uint8_t	max_stored_pel_descs[2];
197216088Sken	uint8_t	stp_reject_to_open_limit[2];
198216088Sken	uint8_t	reserved6[2];
199216088Sken	uint8_t	crc[4];
200216088Sken};
201216088Sken
202216088Sken/*
203216088Sken * REPORT MANUFACTURER INFORMATION request and response, current as of SPL
204216088Sken * Revision 7.
205216088Sken */
206216088Skenstruct smp_report_manuf_info_request
207216088Sken{
208216088Sken	uint8_t	frame_type;
209216088Sken	uint8_t	function;
210216088Sken	uint8_t	response_len;
211216088Sken	uint8_t	request_len;
212216088Sken#define	SMP_RMI_REQUEST_LEN		0x00
213216088Sken	uint8_t	crc[4];
214216088Sken};
215216088Sken
216216088Skenstruct smp_report_manuf_info_response
217216088Sken{
218216088Sken	uint8_t	frame_type;
219216088Sken	uint8_t	function;
220216088Sken	uint8_t	function_result;
221216088Sken	uint8_t	response_len;
222216088Sken#define	SMP_RMI_RESPONSE_LEN		0x0e
223216088Sken	uint8_t	expander_change_count[2];
224216088Sken	uint8_t	reserved0[2];
225216088Sken	uint8_t	sas_11_format;
226216088Sken#define	SMP_RMI_SAS11_FORMAT		0x01
227216088Sken	uint8_t	reserved1[3];
228216088Sken	uint8_t	vendor[8];
229216088Sken	uint8_t	product[16];
230216088Sken	uint8_t	revision[4];
231216088Sken	uint8_t	comp_vendor[8];
232216088Sken	uint8_t	comp_id[2];
233216088Sken	uint8_t	comp_revision;
234216088Sken	uint8_t	reserved2;
235216088Sken	uint8_t	vendor_specific[8];
236216088Sken	uint8_t	crc[4];
237216088Sken};
238216088Sken
239216088Sken/*
240216088Sken * DISCOVER request and response, current as of SPL Revision 7.
241216088Sken */
242216088Skenstruct smp_discover_request
243216088Sken{
244216088Sken	uint8_t	frame_type;
245216088Sken	uint8_t	function;
246216088Sken	uint8_t response_len;
247216088Sken	uint8_t request_len;
248216088Sken#define	SMP_DIS_REQUEST_LEN		0x02
249216088Sken	uint8_t reserved0[4];
250216088Sken	uint8_t	ignore_zone_group;
251216088Sken#define	SMP_DIS_IGNORE_ZONE_GROUP	0x01
252216088Sken	uint8_t	phy;
253216088Sken	uint8_t	reserved1[2];
254216088Sken	uint8_t	crc[4];
255216088Sken};
256216088Sken
257216088Skenstruct smp_discover_response
258216088Sken{
259216088Sken	uint8_t	frame_type;
260216088Sken	uint8_t	function;
261216088Sken	uint8_t	function_result;
262216088Sken	uint8_t	response_len;
263216088Sken#define	SMP_DIS_RESPONSE_LEN		0x20
264216088Sken	uint8_t	expander_change_count[2];
265216088Sken	uint8_t	reserved0[3];
266216088Sken	uint8_t	phy;
267216088Sken	uint8_t	reserved1[2];
268216088Sken	uint8_t	attached_device;
269216088Sken#define	SMP_DIS_AD_TYPE_MASK		0x70
270216088Sken#define	SMP_DIS_AD_TYPE_NONE		0x00
271216088Sken#define	SMP_DIS_AD_TYPE_SAS_SATA	0x10
272216088Sken#define	SMP_DIS_AD_TYPE_EXP		0x20
273216088Sken#define	SMP_DIS_AD_TYPE_EXP_OLD		0x30
274216088Sken#define	SMP_DIS_ATTACH_REASON_MASK	0x0f
275216088Sken	uint8_t	neg_logical_link_rate;
276216088Sken#define	SMP_DIS_LR_MASK			0x0f
277216088Sken#define	SMP_DIS_LR_DISABLED		0x01
278216088Sken#define	SMP_DIS_LR_PHY_RES_PROB		0x02
279216088Sken#define	SMP_DIS_LR_SPINUP_HOLD		0x03
280216088Sken#define	SMP_DIS_LR_PORT_SEL		0x04
281216088Sken#define	SMP_DIS_LR_RESET_IN_PROG	0x05
282216088Sken#define	SMP_DIS_LR_UNSUP_PHY_ATTACHED	0x06
283216088Sken#define	SMP_DIS_LR_G1_15GBPS		0x08
284216088Sken#define	SMP_DIS_LR_G2_30GBPS		0x09
285216088Sken#define	SMP_DIS_LR_G3_60GBPS		0x0a
286216088Sken	uint8_t	config_bits0;
287216088Sken#define	SMP_DIS_ATTACHED_SSP_INIT	0x08
288216088Sken#define	SMP_DIS_ATTACHED_STP_INIT	0x04
289216088Sken#define	SMP_DIS_ATTACHED_SMP_INIT	0x02
290216088Sken#define	SMP_DIS_ATTACHED_SATA_HOST	0x01
291216088Sken	uint8_t	config_bits1;
292216088Sken#define	SMP_DIS_ATTACHED_SATA_PORTSEL	0x80
293216088Sken#define	SMP_DIS_STP_BUFFER_TOO_SMALL	0x10
294216088Sken#define	SMP_DIS_ATTACHED_SSP_TARG	0x08
295216088Sken#define	SMP_DIS_ATTACHED_STP_TARG	0x04
296216088Sken#define	SMP_DIS_ATTACHED_SMP_TARG	0x02
297216088Sken#define	SMP_DIS_ATTACHED_SATA_DEV	0x01
298216088Sken	uint8_t	sas_address[8];
299216088Sken	uint8_t	attached_sas_address[8];
300216088Sken	uint8_t	attached_phy_id;
301216088Sken	uint8_t	config_bits2;
302216088Sken#define	SMP_DIS_ATT_SLUMB_CAP		0x10
303216088Sken#define	SMP_DIS_ATT_PAR_CAP		0x08
304216088Sken#define	SMP_DIS_ATT_IN_ZPSDS_PER	0x04
305216088Sken#define	SMP_DIS_ATT_REQ_IN_ZPSDS	0x02
306216088Sken#define	SMP_DIS_ATT_BREAK_RPL_CAP	0x01
307216088Sken	uint8_t	reserved2[6];
308216088Sken	uint8_t	link_rate0;
309216088Sken#define	SMP_DIS_PROG_MIN_LR_MASK	0xf0
310216088Sken#define	SMP_DIS_PROG_MIN_LR_SHIFT	4
311216088Sken#define	SMP_DIS_HARD_MIN_LR_MASK	0x0f
312216088Sken	uint8_t	link_rate1;
313216088Sken#define	SMP_DIS_PROG_MAX_LR_MAX		0xf0
314216088Sken#define	SMP_DIS_PROG_MAX_LR_SHIFT	4
315216088Sken#define	SMP_DIS_HARD_MAX_LR_MASK	0x0f
316216088Sken	uint8_t	phy_change_count;
317216088Sken	uint8_t	pp_timeout;
318216088Sken#define	SMP_DIS_VIRTUAL_PHY		0x80
319216088Sken#define	SMP_DIS_PP_TIMEOUT_MASK		0x0f
320216088Sken	uint8_t	routing_attr;
321216088Sken	uint8_t	conn_type;
322216088Sken	uint8_t	conn_el_index;
323216088Sken	uint8_t	conn_phys_link;
324216088Sken	uint8_t	config_bits3;
325216088Sken#define	SMP_DIS_PHY_POW_COND_MASK	0xc0
326216088Sken#define	SMP_DIS_PHY_POW_COND_SHIFT	6
327216088Sken#define	SMP_DIS_SAS_SLUMB_CAP		0x08
328216088Sken#define	SMP_DIS_SAS_PART_CAP		0x04
329216088Sken#define	SMP_DIS_SATA_SLUMB_CAP		0x02
330216088Sken#define	SMP_DIS_SATA_PART_CAP		0x01
331216088Sken	uint8_t	config_bits4;
332216088Sken#define	SMP_DIS_SAS_SLUMB_ENB		0x08
333216088Sken#define	SMP_DIS_SAS_PART_ENB		0x04
334216088Sken#define	SMP_DIS_SATA_SLUMB_ENB		0x02
335216088Sken#define	SMP_DIS_SATA_PART_ENB		0x01
336216088Sken	uint8_t	vendor_spec[2];
337216088Sken	uint8_t	attached_dev_name[8];
338216088Sken	uint8_t	config_bits5;
339216088Sken#define	SMP_DIS_REQ_IN_ZPSDS_CHG	0x40
340216088Sken#define	SMP_DIS_IN_ZPSDS_PER		0x20
341216088Sken#define	SMP_DIS_REQ_IN_ZPSDS		0x10
342216088Sken#define	SMP_DIS_ZG_PER			0x04
343216088Sken#define	SMP_DIS_IN_ZPSDS		0x02
344216088Sken#define	SMP_DIS_ZONING_ENB		0x01
345216088Sken	uint8_t	reserved3[2];
346216088Sken	uint8_t	zone_group;
347216088Sken	uint8_t	self_config_status;
348216088Sken	uint8_t	self_config_levels_comp;
349216088Sken	uint8_t	reserved4[2];
350216088Sken	uint8_t	self_config_sas_addr[8];
351216088Sken	uint8_t	prog_phy_cap[4];
352216088Sken	uint8_t	current_phy_cap[4];
353216088Sken	uint8_t	attached_phy_cap[4];
354216088Sken	uint8_t	reserved5[6];
355216088Sken	uint8_t	neg_phys_link_rate;
356216088Sken#define	SMP_DIS_REASON_MASK		0xf0
357216088Sken#define	SMP_DIS_REASON_SHIFT		4
358216088Sken#define	SMP_DIS_PHYS_LR_MASK		0x0f
359216088Sken	uint8_t	config_bits6;
360216088Sken#define	SMP_DIS_OPTICAL_MODE_ENB	0x04
361216088Sken#define	SMP_DIS_NEG_SSC			0x02
362216088Sken#define	SMP_DIS_HW_MUX_SUP		0x01
363216088Sken	uint8_t	config_bits7;
364216088Sken#define	SMP_DIS_DEF_IN_ZPSDS_PER	0x20
365216088Sken#define	SMP_DIS_DEF_REQ_IN_ZPSDS	0x10
366216088Sken#define	SMP_DIS_DEF_ZG_PER		0x04
367216088Sken#define	SMP_DIS_DEF_ZONING_ENB		0x01
368216088Sken	uint8_t	reserved6;
369216088Sken	uint8_t	reserved7;
370216088Sken	uint8_t	default_zone_group;
371216088Sken	uint8_t	config_bits8;
372216088Sken#define	SMP_DIS_SAVED_IN_ZPSDS_PER	0x20
373216088Sken#define	SMP_DIS_SAVED_REQ_IN_SPSDS	0x10
374216088Sken#define	SMP_DIS_SAVED_ZG_PER		0x04
375216088Sken#define	SMP_DIS_SAVED_ZONING_ENB	0x01
376216088Sken	uint8_t	reserved8;
377216088Sken	uint8_t	reserved9;
378216088Sken	uint8_t	saved_zone_group;
379216088Sken	uint8_t	config_bits9;
380216088Sken#define	SMP_DIS_SHADOW_IN_ZPSDS_PER	0x20
381216088Sken#define	SMP_DIS_SHADOW_IN_REQ_IN_ZPSDS	0x10
382216088Sken#define	SMP_DIS_SHADOW_ZG_PER		0x04
383216088Sken	uint8_t reserved10;
384216088Sken	uint8_t reserved11;
385216088Sken	uint8_t	shadow_zone_group;
386216088Sken	uint8_t	device_slot_num;
387216088Sken	uint8_t	device_slot_group_num;
388216088Sken	uint8_t	device_slot_group_out_conn[6];
389216088Sken	uint8_t	stp_buffer_size[2];
390216088Sken	uint8_t	reserved12;
391216088Sken	uint8_t	reserved13;
392216088Sken	uint8_t	crc[4];
393216088Sken};
394216088Sken
395216088Sken/*
396216088Sken * PHY CONTROL request and response.  Current as of SPL Revision 7.
397216088Sken */
398216088Skenstruct smp_phy_control_request
399216088Sken{
400216088Sken	uint8_t	frame_type;
401216088Sken	uint8_t	function;
402216088Sken	uint8_t response_len;
403216088Sken#define	SMP_PC_RESPONSE_LEN		0x00
404216088Sken	uint8_t request_len;
405216088Sken#define	SMP_PC_REQUEST_LEN		0x09
406216088Sken	uint8_t expected_exp_chg_cnt[2];
407216088Sken	uint8_t reserved0[3];
408216088Sken	uint8_t phy;
409216088Sken	uint8_t phy_operation;
410216088Sken#define	SMP_PC_PHY_OP_NOP		0x00
411216088Sken#define	SMP_PC_PHY_OP_LINK_RESET	0x01
412216088Sken#define	SMP_PC_PHY_OP_HARD_RESET	0x02
413216088Sken#define	SMP_PC_PHY_OP_DISABLE		0x03
414216088Sken#define	SMP_PC_PHY_OP_CLEAR_ERR_LOG	0x05
415216088Sken#define	SMP_PC_PHY_OP_CLEAR_AFFILIATON	0x06
416216088Sken#define	SMP_PC_PHY_OP_TRANS_SATA_PSS	0x07
417216088Sken#define	SMP_PC_PHY_OP_CLEAR_STP_ITN_LS	0x08
418216088Sken#define	SMP_PC_PHY_OP_SET_ATT_DEV_NAME	0x09
419216088Sken	uint8_t update_pp_timeout;
420216088Sken#define	SMP_PC_UPDATE_PP_TIMEOUT	0x01
421216088Sken	uint8_t reserved1[12];
422216088Sken	uint8_t attached_device_name[8];
423216088Sken	uint8_t prog_min_phys_link_rate;
424216088Sken#define	SMP_PC_PROG_MIN_PL_RATE_MASK	0xf0
425216088Sken#define	SMP_PC_PROG_MIN_PL_RATE_SHIFT	4
426216088Sken	uint8_t prog_max_phys_link_rate;
427216088Sken#define	SMP_PC_PROG_MAX_PL_RATE_MASK	0xf0
428216088Sken#define	SMP_PC_PROG_MAX_PL_RATE_SHIFT	4
429216088Sken	uint8_t	config_bits0;
430216088Sken#define	SMP_PC_SP_NC			0x00
431216088Sken#define	SMP_PC_SP_DISABLE		0x02
432216088Sken#define	SMP_PC_SP_ENABLE		0x01
433216088Sken#define	SMP_PC_SAS_SLUMBER_NC		0x00
434216088Sken#define	SMP_PC_SAS_SLUMBER_DISABLE	0x80
435216088Sken#define	SMP_PC_SAS_SLUMBER_ENABLE	0x40
436216088Sken#define	SMP_PC_SAS_SLUMBER_MASK		0xc0
437216088Sken#define	SMP_PC_SAS_SLUMBER_SHIFT	6
438216088Sken#define	SMP_PC_SAS_PARTIAL_NC		0x00
439216088Sken#define	SMP_PC_SAS_PARTIAL_DISABLE	0x20
440216088Sken#define	SMP_PC_SAS_PARTIAL_ENABLE	0x10
441216088Sken#define	SMP_PC_SAS_PARTIAL_MASK		0x30
442216088Sken#define	SMP_PC_SAS_PARTIAL_SHIFT	4
443216088Sken#define	SMP_PC_SATA_SLUMBER_NC		0x00
444216088Sken#define	SMP_PC_SATA_SLUMBER_DISABLE	0x08
445216088Sken#define	SMP_PC_SATA_SLUMBER_ENABLE	0x04
446216088Sken#define	SMP_PC_SATA_SLUMBER_MASK	0x0c
447216088Sken#define	SMP_PC_SATA_SLUMBER_SHIFT	2
448216088Sken#define	SMP_PC_SATA_PARTIAL_NC		0x00
449216088Sken#define	SMP_PC_SATA_PARTIAL_DISABLE	0x02
450216088Sken#define	SMP_PC_SATA_PARTIAL_ENABLE	0x01
451216088Sken#define	SMP_PC_SATA_PARTIAL_MASK	0x03
452216088Sken#define	SMP_PC_SATA_PARTIAL_SHIFT	0
453216088Sken	uint8_t	reserved2;
454216088Sken	uint8_t	pp_timeout_value;
455216088Sken#define	SMP_PC_PP_TIMEOUT_MASK		0x0f
456216088Sken	uint8_t reserved3[3];
457216088Sken	uint8_t	crc[4];
458216088Sken};
459216088Sken
460216088Skenstruct smp_phy_control_response
461216088Sken{
462216088Sken	uint8_t	frame_type;
463216088Sken	uint8_t	function;
464216088Sken	uint8_t	function_result;
465216088Sken	uint8_t	response_len;
466216088Sken#define	SMP_PC_RESPONSE_LEN		0x00
467216088Sken	uint8_t crc[4];
468216088Sken};
469216088Sken
470216088Sken__BEGIN_DECLS
471216088Sken
472216088Skenconst char *smp_error_desc(int function_result);
473216088Skenconst char *smp_command_desc(uint8_t cmd_num);
474216088Skenvoid smp_command_decode(uint8_t *smp_request, int request_len, struct sbuf *sb,
475216088Sken			char *line_prefix, int first_line_len, int line_len);
476216088Skenvoid smp_command_sbuf(struct ccb_smpio *smpio, struct sbuf *sb,
477216088Sken		      char *line_prefix, int first_line_len, int line_len);
478216088Sken
479216088Sken#ifdef _KERNEL
480216088Skenvoid smp_error_sbuf(struct ccb_smpio *smpio, struct sbuf *sb);
481216088Sken#else /* !_KERNEL*/
482216088Skenvoid smp_error_sbuf(struct cam_device *device, struct ccb_smpio *smpio,
483216088Sken		    struct sbuf *sb);
484216088Sken#endif /* _KERNEL/!_KERNEL */
485216088Sken
486216088Skenvoid smp_report_general_sbuf(struct smp_report_general_response *response,
487216088Sken			     int response_len, struct sbuf *sb);
488216088Sken
489216088Skenvoid smp_report_manuf_info_sbuf(struct smp_report_manuf_info_response *response,
490216088Sken				int response_len, struct sbuf *sb);
491216088Sken
492216088Skenvoid smp_report_general(struct ccb_smpio *smpio, uint32_t retries,
493216088Sken			void (*cbfcnp)(struct cam_periph *, union ccb *),
494216088Sken			struct smp_report_general_request *request,
495216088Sken			int request_len, uint8_t *response, int response_len,
496216088Sken			int long_response, uint32_t timeout);
497216088Sken
498216088Skenvoid smp_discover(struct ccb_smpio *smpio, uint32_t retries,
499216088Sken		  void (*cbfcnp)(struct cam_periph *, union ccb *),
500216088Sken		  struct smp_discover_request *request, int request_len,
501216088Sken		  uint8_t *response, int response_len, int long_response,
502216088Sken		  int ignore_zone_group, int phy, uint32_t timeout);
503216088Sken
504216088Skenvoid smp_report_manuf_info(struct ccb_smpio *smpio, uint32_t retries,
505216088Sken			   void (*cbfcnp)(struct cam_periph *, union ccb *),
506216088Sken			   struct smp_report_manuf_info_request *request,
507216088Sken			   int request_len, uint8_t *response, int response_len,
508216088Sken			   int long_response, uint32_t timeout);
509216088Sken
510216088Skenvoid smp_phy_control(struct ccb_smpio *smpio, uint32_t retries,
511216088Sken		     void (*cbfcnp)(struct cam_periph *, union ccb *),
512216088Sken		     struct smp_phy_control_request *request, int request_len,
513216088Sken		     uint8_t *response, int response_len, int long_response,
514216088Sken		     uint32_t expected_exp_change_count, int phy, int phy_op,
515216088Sken		     int update_pp_timeout_val, uint64_t attached_device_name,
516216088Sken		     int prog_min_prl, int prog_max_prl, int slumber_partial,
517216088Sken		     int pp_timeout_value, uint32_t timeout);
518216088Sken__END_DECLS
519216088Sken
520216088Sken#endif /*_SCSI_SMP_ALL_H*/
521