xref: /freebsd/sys/cam/scsi/smp_all.h (revision 2ff63af9b88c7413b7d71715b5532625752a248e)
106e79492SKenneth D. Merry /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3bec9534dSPedro F. Giffuni  *
406e79492SKenneth D. Merry  * Copyright (c) 2010 Spectra Logic Corporation
506e79492SKenneth D. Merry  * All rights reserved.
606e79492SKenneth D. Merry  *
706e79492SKenneth D. Merry  * Redistribution and use in source and binary forms, with or without
806e79492SKenneth D. Merry  * modification, are permitted provided that the following conditions
906e79492SKenneth D. Merry  * are met:
1006e79492SKenneth D. Merry  * 1. Redistributions of source code must retain the above copyright
1106e79492SKenneth D. Merry  *    notice, this list of conditions, and the following disclaimer,
1206e79492SKenneth D. Merry  *    without modification.
1306e79492SKenneth D. Merry  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1406e79492SKenneth D. Merry  *    substantially similar to the "NO WARRANTY" disclaimer below
1506e79492SKenneth D. Merry  *    ("Disclaimer") and any redistribution must be conditioned upon
1606e79492SKenneth D. Merry  *    including a substantially similar Disclaimer requirement for further
1706e79492SKenneth D. Merry  *    binary redistribution.
1806e79492SKenneth D. Merry  *
1906e79492SKenneth D. Merry  * NO WARRANTY
2006e79492SKenneth D. Merry  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2106e79492SKenneth D. Merry  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2206e79492SKenneth D. Merry  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
2306e79492SKenneth D. Merry  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2406e79492SKenneth D. Merry  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2506e79492SKenneth D. Merry  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2606e79492SKenneth D. Merry  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2706e79492SKenneth D. Merry  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
2806e79492SKenneth D. Merry  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
2906e79492SKenneth D. Merry  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3006e79492SKenneth D. Merry  * POSSIBILITY OF SUCH DAMAGES.
3106e79492SKenneth D. Merry  *
3206e79492SKenneth D. Merry  * $Id: //depot/users/kenm/FreeBSD-test/sys/cam/scsi/smp_all.h#4 $
3306e79492SKenneth D. Merry  */
3406e79492SKenneth D. Merry 
3506e79492SKenneth D. Merry /*
3606e79492SKenneth D. Merry  * Serial Management Protocol definitions.
3706e79492SKenneth D. Merry  */
3806e79492SKenneth D. Merry 
3906e79492SKenneth D. Merry #ifndef	_SCSI_SMP_ALL_H
4006e79492SKenneth D. Merry #define	_SCSI_SMP_ALL_H	1
4106e79492SKenneth D. Merry 
4206e79492SKenneth D. Merry #define	SMP_FRAME_TYPE_REQUEST	0x40
4306e79492SKenneth D. Merry #define	SMP_FRAME_TYPE_RESPONSE	0x41
4406e79492SKenneth D. Merry #define	SMP_WORD_LEN		4
4506e79492SKenneth D. Merry #define	SMP_CRC_LEN		4
4606e79492SKenneth D. Merry 
4706e79492SKenneth D. Merry /*
4806e79492SKenneth D. Merry  * SMP Functions (current as of SPL Revision 7)
4906e79492SKenneth D. Merry  */
5006e79492SKenneth D. Merry /* 0x00 to 0x7f: SMP input functions */
5106e79492SKenneth D. Merry /* 0x00 to 0x0f: General SMP input functions */
5206e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_GENERAL		0x00
5306e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_MANUF_INFO	0x01
5406e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_SC_STATUS	0x03
5506e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_ZONE_PERM_TBL	0x04
5606e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_ZONE_MAN_PWD	0x05
5706e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_BROADCAST	0x06
5806e79492SKenneth D. Merry 
5906e79492SKenneth D. Merry /* 0x10 to 0x1f: Phy-based SMP input functions */
6006e79492SKenneth D. Merry #define	SMP_FUNC_DISCOVER		0x10
6106e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_PHY_ERR_LOG	0x11
6206e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_PHY_SATA	0x12
6306e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_ROUTE_INFO	0x13
6406e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_PHY_EVENT	0x14
6506e79492SKenneth D. Merry 
6606e79492SKenneth D. Merry /* 0x20 to 0x2f: Descriptor list-based SMP input functions */
6706e79492SKenneth D. Merry #define	SMP_FUNC_DISCOVER_LIST		0x20
6806e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_PHY_EVENT_LIST	0x21
6906e79492SKenneth D. Merry #define	SMP_FUNC_REPORT_EXP_RTL		0x22
7006e79492SKenneth D. Merry 
7106e79492SKenneth D. Merry /* 0x30 to 0x3f: Reserved for SMP input functions */
7206e79492SKenneth D. Merry /* 0x40 to 0x7f: Vendor specific */
7306e79492SKenneth D. Merry 
7406e79492SKenneth D. Merry /* 0x80 to 0xff: SMP output functions */
7506e79492SKenneth D. Merry /* 0x80 to 0x8f: General SMP output functions */
7606e79492SKenneth D. Merry #define	SMP_FUNC_CONFIG_GENERAL		0x80
7706e79492SKenneth D. Merry #define	SMP_FUNC_ENABLE_DISABLE_ZONING	0x81
7806e79492SKenneth D. Merry #define	SMP_FUNC_ZONED_BROADCAST	0x85
7906e79492SKenneth D. Merry #define	SMP_FUNC_ZONE_LOCK		0x86
8006e79492SKenneth D. Merry #define	SMP_FUNC_ZONE_ACTIVATE		0x87
8106e79492SKenneth D. Merry #define	SMP_FUNC_ZONE_UNLOCK		0x88
8206e79492SKenneth D. Merry #define	SMP_FUNC_CONFIG_ZM_PWD		0x89
8306e79492SKenneth D. Merry #define	SMP_FUNC_CONFIG_ZONE_PHY_INFO	0x8a
8406e79492SKenneth D. Merry #define	SMP_FUNC_CONFIG_ZONE_PERM_TBL	0x8b
8506e79492SKenneth D. Merry 
8606e79492SKenneth D. Merry /* 0x90 to 0x9f: Phy-based SMP output functions */
8706e79492SKenneth D. Merry #define	SMP_FUNC_CONFIG_ROUTE_INFO	0x90
8806e79492SKenneth D. Merry #define	SMP_FUNC_PHY_CONTROL		0x91
8906e79492SKenneth D. Merry #define	SMP_FUNC_PHY_TEST_FUNC		0x92
9006e79492SKenneth D. Merry #define	SMP_FUNC_CONFIG_PHY_EVENT	0x93
9106e79492SKenneth D. Merry 
9206e79492SKenneth D. Merry /* 0xa0 to 0xbf: Reserved for SMP output functions */
9306e79492SKenneth D. Merry /* 0xc0 to 0xff: Vendor specific */
9406e79492SKenneth D. Merry 
9506e79492SKenneth D. Merry /*
9606e79492SKenneth D. Merry  * Function Results (current as of SPL Revision 7)
9706e79492SKenneth D. Merry  */
9806e79492SKenneth D. Merry #define	SMP_FR_ACCEPTED			0x00
9906e79492SKenneth D. Merry #define	SMP_FR_UNKNOWN_FUNC		0x01
10006e79492SKenneth D. Merry #define	SMP_FR_FUNCTION_FAILED		0x02
10106e79492SKenneth D. Merry #define	SMP_FR_INVALID_REQ_FRAME_LEN	0x03
10206e79492SKenneth D. Merry #define	SMP_FR_INVALID_EXP_CHG_CNT	0x04
10306e79492SKenneth D. Merry #define	SMP_FR_BUSY			0x05
10406e79492SKenneth D. Merry #define	SMP_FR_INCOMPLETE_DESC_LIST	0x06
10506e79492SKenneth D. Merry #define	SMP_FR_PHY_DOES_NOT_EXIST	0x10
10606e79492SKenneth D. Merry #define	SMP_FR_INDEX_DOES_NOT_EXIST	0x11
10706e79492SKenneth D. Merry #define	SMP_FR_PHY_DOES_NOT_SUP_SATA	0x12
10806e79492SKenneth D. Merry #define	SMP_FR_UNKNOWN_PHY_OP		0x13
10906e79492SKenneth D. Merry #define	SMP_FR_UNKNOWN_PHY_TEST_FUNC	0x14
11006e79492SKenneth D. Merry #define	SMP_FR_PHY_TEST_FUNC_INPROG	0x15
11106e79492SKenneth D. Merry #define	SMP_FR_PHY_VACANT		0x16
11206e79492SKenneth D. Merry #define	SMP_FR_UNKNOWN_PHY_EVENT_SRC	0x17
11306e79492SKenneth D. Merry #define	SMP_FR_UNKNOWN_DESC_TYPE	0x18
11406e79492SKenneth D. Merry #define	SMP_FR_UNKNOWN_PHY_FILTER	0x19
11506e79492SKenneth D. Merry #define	SMP_FR_AFFILIATION_VIOLATION	0x1a
11606e79492SKenneth D. Merry #define	SMP_FR_SMP_ZONE_VIOLATION	0x20
11706e79492SKenneth D. Merry #define	SMP_FR_NO_MGMT_ACCESS_RIGHTS	0x21
11806e79492SKenneth D. Merry #define	SMP_FR_UNKNOWN_ED_ZONING_VAL	0x22
11906e79492SKenneth D. Merry #define	SMP_FR_ZONE_LOCK_VIOLATION	0x23
12006e79492SKenneth D. Merry #define	SMP_FR_NOT_ACTIVATED		0x24
12106e79492SKenneth D. Merry #define	SMP_FR_ZG_OUT_OF_RANGE		0x25
12206e79492SKenneth D. Merry #define	SMP_FR_NO_PHYS_PRESENCE		0x26
12306e79492SKenneth D. Merry #define	SMP_FR_SAVING_NOT_SUP		0x27
12406e79492SKenneth D. Merry #define	SMP_FR_SRC_ZONE_DNE		0x28
12506e79492SKenneth D. Merry #define	SMP_FR_DISABLED_PWD_NOT_SUP	0x29
12606e79492SKenneth D. Merry 
12706e79492SKenneth D. Merry /*
12806e79492SKenneth D. Merry  * REPORT GENERAL request and response, current as of SPL Revision 7.
12906e79492SKenneth D. Merry  */
13006e79492SKenneth D. Merry struct smp_report_general_request
13106e79492SKenneth D. Merry {
13206e79492SKenneth D. Merry 	uint8_t	frame_type;
13306e79492SKenneth D. Merry 	uint8_t	function;
13406e79492SKenneth D. Merry 	uint8_t	response_len;
13506e79492SKenneth D. Merry 	uint8_t	request_len;
13606e79492SKenneth D. Merry 	uint8_t	crc[4];
13706e79492SKenneth D. Merry };
13806e79492SKenneth D. Merry 
13906e79492SKenneth D. Merry struct smp_report_general_response
14006e79492SKenneth D. Merry {
14106e79492SKenneth D. Merry 	uint8_t	frame_type;
14206e79492SKenneth D. Merry 	uint8_t	function;
14306e79492SKenneth D. Merry 	uint8_t	function_result;
14406e79492SKenneth D. Merry 	uint8_t	response_len;
14506e79492SKenneth D. Merry #define	SMP_RG_RESPONSE_LEN		0x11
14606e79492SKenneth D. Merry 	uint8_t	expander_change_count[2];
14706e79492SKenneth D. Merry 	uint8_t	expander_route_indexes[2];
14806e79492SKenneth D. Merry 	uint8_t	long_response;
14906e79492SKenneth D. Merry #define	SMP_RG_LONG_RESPONSE		0x80
15006e79492SKenneth D. Merry 	uint8_t	num_phys;
15106e79492SKenneth D. Merry 	uint8_t	config_bits0;
15206e79492SKenneth D. Merry #define	SMP_RG_TABLE_TO_TABLE_SUP	0x80
15306e79492SKenneth D. Merry #define	SMP_RG_ZONE_CONFIGURING		0x40
15406e79492SKenneth D. Merry #define	SMP_RG_SELF_CONFIGURING		0x20
15506e79492SKenneth D. Merry #define	SMP_RG_STP_CONTINUE_AWT		0x10
15606e79492SKenneth D. Merry #define	SMP_RG_OPEN_REJECT_RETRY_SUP	0x08
15706e79492SKenneth D. Merry #define	SMP_RG_CONFIGURES_OTHERS	0x04
15806e79492SKenneth D. Merry #define	SMP_RG_CONFIGURING		0x02
15906e79492SKenneth D. Merry #define	SMP_RG_EXT_CONFIG_ROUTE_TABLE	0x01
16006e79492SKenneth D. Merry 	uint8_t	reserved0;
16106e79492SKenneth D. Merry 	uint8_t	encl_logical_id[8];
16206e79492SKenneth D. Merry 	uint8_t	reserved1[8];
16306e79492SKenneth D. Merry 	uint8_t	reserved2[2];
16406e79492SKenneth D. Merry 	uint8_t	stp_bus_inact_time_limit[2];
16506e79492SKenneth D. Merry 	uint8_t	stp_max_conn_time_limit[2];
16606e79492SKenneth D. Merry 	uint8_t	stp_smp_it_nexus_loss_time[2];
16706e79492SKenneth D. Merry 	uint8_t	config_bits1;
16806e79492SKenneth D. Merry #define	SMP_RG_NUM_ZONE_GROUPS_MASK	0xc0
16906e79492SKenneth D. Merry #define	SMP_RG_NUM_ZONE_GROUPS_SHIFT	6
17006e79492SKenneth D. Merry #define	SMP_RG_ZONE_LOCKED		0x10
17106e79492SKenneth D. Merry #define	SMP_RG_PP_SUPPORTED		0x08
17206e79492SKenneth D. Merry #define	SMP_RG_PP_ASSERTED		0x04
17306e79492SKenneth D. Merry #define	SMP_RG_ZONING_SUPPORTED		0x02
17406e79492SKenneth D. Merry #define	SMP_RG_ZONING_ENABLED		0x01
17506e79492SKenneth D. Merry 	uint8_t	config_bits2;
17606e79492SKenneth D. Merry #define	SMP_RG_SAVING			0x10
17706e79492SKenneth D. Merry #define	SMP_RG_SAVING_ZM_PWD_SUP	0x08
17806e79492SKenneth D. Merry #define	SMP_RG_SAVING_PHY_INFO_SUP	0x04
17906e79492SKenneth D. Merry #define	SMP_RG_SAVING_ZPERM_TAB_SUP	0x02
18006e79492SKenneth D. Merry #define	SMP_RG_SAVING_ZENABLED_SUP	0x01
18106e79492SKenneth D. Merry 	uint8_t	max_num_routed_addrs[2];
18206e79492SKenneth D. Merry 	uint8_t	active_zm_address[8];
18306e79492SKenneth D. Merry 	uint8_t	zone_lock_inact_time_limit[2];
18406e79492SKenneth D. Merry 	uint8_t	reserved3[2];
18506e79492SKenneth D. Merry 	uint8_t	reserved4;
18606e79492SKenneth D. Merry 	uint8_t	first_encl_conn_el_index;
18706e79492SKenneth D. Merry 	uint8_t	num_encl_conn_el_indexes;
18806e79492SKenneth D. Merry 	uint8_t	reserved5;
18906e79492SKenneth D. Merry 	uint8_t	reduced_functionality;
19006e79492SKenneth D. Merry #define	SMP_RG_REDUCED_FUNCTIONALITY	0x80
19106e79492SKenneth D. Merry 	uint8_t	time_to_reduced_func;
19206e79492SKenneth D. Merry 	uint8_t	initial_time_to_reduced_func;
19306e79492SKenneth D. Merry 	uint8_t	max_reduced_func_time;
19406e79492SKenneth D. Merry 	uint8_t	last_sc_stat_desc_index[2];
19506e79492SKenneth D. Merry 	uint8_t	max_sc_stat_descs[2];
19606e79492SKenneth D. Merry 	uint8_t	last_phy_evl_desc_index[2];
19706e79492SKenneth D. Merry 	uint8_t	max_stored_pel_descs[2];
19806e79492SKenneth D. Merry 	uint8_t	stp_reject_to_open_limit[2];
19906e79492SKenneth D. Merry 	uint8_t	reserved6[2];
20006e79492SKenneth D. Merry 	uint8_t	crc[4];
20106e79492SKenneth D. Merry };
20206e79492SKenneth D. Merry 
20306e79492SKenneth D. Merry /*
20406e79492SKenneth D. Merry  * REPORT MANUFACTURER INFORMATION request and response, current as of SPL
20506e79492SKenneth D. Merry  * Revision 7.
20606e79492SKenneth D. Merry  */
20706e79492SKenneth D. Merry struct smp_report_manuf_info_request
20806e79492SKenneth D. Merry {
20906e79492SKenneth D. Merry 	uint8_t	frame_type;
21006e79492SKenneth D. Merry 	uint8_t	function;
21106e79492SKenneth D. Merry 	uint8_t	response_len;
21206e79492SKenneth D. Merry 	uint8_t	request_len;
21306e79492SKenneth D. Merry #define	SMP_RMI_REQUEST_LEN		0x00
21406e79492SKenneth D. Merry 	uint8_t	crc[4];
21506e79492SKenneth D. Merry };
21606e79492SKenneth D. Merry 
21706e79492SKenneth D. Merry struct smp_report_manuf_info_response
21806e79492SKenneth D. Merry {
21906e79492SKenneth D. Merry 	uint8_t	frame_type;
22006e79492SKenneth D. Merry 	uint8_t	function;
22106e79492SKenneth D. Merry 	uint8_t	function_result;
22206e79492SKenneth D. Merry 	uint8_t	response_len;
22306e79492SKenneth D. Merry #define	SMP_RMI_RESPONSE_LEN		0x0e
22406e79492SKenneth D. Merry 	uint8_t	expander_change_count[2];
22506e79492SKenneth D. Merry 	uint8_t	reserved0[2];
22606e79492SKenneth D. Merry 	uint8_t	sas_11_format;
22706e79492SKenneth D. Merry #define	SMP_RMI_SAS11_FORMAT		0x01
22806e79492SKenneth D. Merry 	uint8_t	reserved1[3];
22906e79492SKenneth D. Merry 	uint8_t	vendor[8];
23006e79492SKenneth D. Merry 	uint8_t	product[16];
23106e79492SKenneth D. Merry 	uint8_t	revision[4];
23206e79492SKenneth D. Merry 	uint8_t	comp_vendor[8];
23306e79492SKenneth D. Merry 	uint8_t	comp_id[2];
23406e79492SKenneth D. Merry 	uint8_t	comp_revision;
23506e79492SKenneth D. Merry 	uint8_t	reserved2;
23606e79492SKenneth D. Merry 	uint8_t	vendor_specific[8];
23706e79492SKenneth D. Merry 	uint8_t	crc[4];
23806e79492SKenneth D. Merry };
23906e79492SKenneth D. Merry 
24006e79492SKenneth D. Merry /*
24106e79492SKenneth D. Merry  * DISCOVER request and response, current as of SPL Revision 7.
24206e79492SKenneth D. Merry  */
24306e79492SKenneth D. Merry struct smp_discover_request
24406e79492SKenneth D. Merry {
24506e79492SKenneth D. Merry 	uint8_t	frame_type;
24606e79492SKenneth D. Merry 	uint8_t	function;
24706e79492SKenneth D. Merry 	uint8_t response_len;
24806e79492SKenneth D. Merry 	uint8_t request_len;
24906e79492SKenneth D. Merry #define	SMP_DIS_REQUEST_LEN		0x02
25006e79492SKenneth D. Merry 	uint8_t reserved0[4];
25106e79492SKenneth D. Merry 	uint8_t	ignore_zone_group;
25206e79492SKenneth D. Merry #define	SMP_DIS_IGNORE_ZONE_GROUP	0x01
25306e79492SKenneth D. Merry 	uint8_t	phy;
25406e79492SKenneth D. Merry 	uint8_t	reserved1[2];
25506e79492SKenneth D. Merry 	uint8_t	crc[4];
25606e79492SKenneth D. Merry };
25706e79492SKenneth D. Merry 
25806e79492SKenneth D. Merry struct smp_discover_response
25906e79492SKenneth D. Merry {
26006e79492SKenneth D. Merry 	uint8_t	frame_type;
26106e79492SKenneth D. Merry 	uint8_t	function;
26206e79492SKenneth D. Merry 	uint8_t	function_result;
26306e79492SKenneth D. Merry 	uint8_t	response_len;
26406e79492SKenneth D. Merry #define	SMP_DIS_RESPONSE_LEN		0x20
26506e79492SKenneth D. Merry 	uint8_t	expander_change_count[2];
26606e79492SKenneth D. Merry 	uint8_t	reserved0[3];
26706e79492SKenneth D. Merry 	uint8_t	phy;
26806e79492SKenneth D. Merry 	uint8_t	reserved1[2];
26906e79492SKenneth D. Merry 	uint8_t	attached_device;
27006e79492SKenneth D. Merry #define	SMP_DIS_AD_TYPE_MASK		0x70
27106e79492SKenneth D. Merry #define	SMP_DIS_AD_TYPE_NONE		0x00
27206e79492SKenneth D. Merry #define	SMP_DIS_AD_TYPE_SAS_SATA	0x10
27306e79492SKenneth D. Merry #define	SMP_DIS_AD_TYPE_EXP		0x20
27406e79492SKenneth D. Merry #define	SMP_DIS_AD_TYPE_EXP_OLD		0x30
27506e79492SKenneth D. Merry #define	SMP_DIS_ATTACH_REASON_MASK	0x0f
27606e79492SKenneth D. Merry 	uint8_t	neg_logical_link_rate;
27706e79492SKenneth D. Merry #define	SMP_DIS_LR_MASK			0x0f
27806e79492SKenneth D. Merry #define	SMP_DIS_LR_DISABLED		0x01
27906e79492SKenneth D. Merry #define	SMP_DIS_LR_PHY_RES_PROB		0x02
28006e79492SKenneth D. Merry #define	SMP_DIS_LR_SPINUP_HOLD		0x03
28106e79492SKenneth D. Merry #define	SMP_DIS_LR_PORT_SEL		0x04
28206e79492SKenneth D. Merry #define	SMP_DIS_LR_RESET_IN_PROG	0x05
28306e79492SKenneth D. Merry #define	SMP_DIS_LR_UNSUP_PHY_ATTACHED	0x06
28406e79492SKenneth D. Merry #define	SMP_DIS_LR_G1_15GBPS		0x08
28506e79492SKenneth D. Merry #define	SMP_DIS_LR_G2_30GBPS		0x09
28606e79492SKenneth D. Merry #define	SMP_DIS_LR_G3_60GBPS		0x0a
28706e79492SKenneth D. Merry 	uint8_t	config_bits0;
28806e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_SSP_INIT	0x08
28906e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_STP_INIT	0x04
29006e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_SMP_INIT	0x02
29106e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_SATA_HOST	0x01
29206e79492SKenneth D. Merry 	uint8_t	config_bits1;
29306e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_SATA_PORTSEL	0x80
29406e79492SKenneth D. Merry #define	SMP_DIS_STP_BUFFER_TOO_SMALL	0x10
29506e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_SSP_TARG	0x08
29606e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_STP_TARG	0x04
29706e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_SMP_TARG	0x02
29806e79492SKenneth D. Merry #define	SMP_DIS_ATTACHED_SATA_DEV	0x01
29906e79492SKenneth D. Merry 	uint8_t	sas_address[8];
30006e79492SKenneth D. Merry 	uint8_t	attached_sas_address[8];
30106e79492SKenneth D. Merry 	uint8_t	attached_phy_id;
30206e79492SKenneth D. Merry 	uint8_t	config_bits2;
30306e79492SKenneth D. Merry #define	SMP_DIS_ATT_SLUMB_CAP		0x10
30406e79492SKenneth D. Merry #define	SMP_DIS_ATT_PAR_CAP		0x08
30506e79492SKenneth D. Merry #define	SMP_DIS_ATT_IN_ZPSDS_PER	0x04
30606e79492SKenneth D. Merry #define	SMP_DIS_ATT_REQ_IN_ZPSDS	0x02
30706e79492SKenneth D. Merry #define	SMP_DIS_ATT_BREAK_RPL_CAP	0x01
30806e79492SKenneth D. Merry 	uint8_t	reserved2[6];
30906e79492SKenneth D. Merry 	uint8_t	link_rate0;
31006e79492SKenneth D. Merry #define	SMP_DIS_PROG_MIN_LR_MASK	0xf0
31106e79492SKenneth D. Merry #define	SMP_DIS_PROG_MIN_LR_SHIFT	4
31206e79492SKenneth D. Merry #define	SMP_DIS_HARD_MIN_LR_MASK	0x0f
31306e79492SKenneth D. Merry 	uint8_t	link_rate1;
31406e79492SKenneth D. Merry #define	SMP_DIS_PROG_MAX_LR_MAX		0xf0
31506e79492SKenneth D. Merry #define	SMP_DIS_PROG_MAX_LR_SHIFT	4
31606e79492SKenneth D. Merry #define	SMP_DIS_HARD_MAX_LR_MASK	0x0f
31706e79492SKenneth D. Merry 	uint8_t	phy_change_count;
31806e79492SKenneth D. Merry 	uint8_t	pp_timeout;
31906e79492SKenneth D. Merry #define	SMP_DIS_VIRTUAL_PHY		0x80
32006e79492SKenneth D. Merry #define	SMP_DIS_PP_TIMEOUT_MASK		0x0f
32106e79492SKenneth D. Merry 	uint8_t	routing_attr;
32206e79492SKenneth D. Merry 	uint8_t	conn_type;
32306e79492SKenneth D. Merry 	uint8_t	conn_el_index;
32406e79492SKenneth D. Merry 	uint8_t	conn_phys_link;
32506e79492SKenneth D. Merry 	uint8_t	config_bits3;
32606e79492SKenneth D. Merry #define	SMP_DIS_PHY_POW_COND_MASK	0xc0
32706e79492SKenneth D. Merry #define	SMP_DIS_PHY_POW_COND_SHIFT	6
32806e79492SKenneth D. Merry #define	SMP_DIS_SAS_SLUMB_CAP		0x08
32906e79492SKenneth D. Merry #define	SMP_DIS_SAS_PART_CAP		0x04
33006e79492SKenneth D. Merry #define	SMP_DIS_SATA_SLUMB_CAP		0x02
33106e79492SKenneth D. Merry #define	SMP_DIS_SATA_PART_CAP		0x01
33206e79492SKenneth D. Merry 	uint8_t	config_bits4;
33306e79492SKenneth D. Merry #define	SMP_DIS_SAS_SLUMB_ENB		0x08
33406e79492SKenneth D. Merry #define	SMP_DIS_SAS_PART_ENB		0x04
33506e79492SKenneth D. Merry #define	SMP_DIS_SATA_SLUMB_ENB		0x02
33606e79492SKenneth D. Merry #define	SMP_DIS_SATA_PART_ENB		0x01
33706e79492SKenneth D. Merry 	uint8_t	vendor_spec[2];
33806e79492SKenneth D. Merry 	uint8_t	attached_dev_name[8];
33906e79492SKenneth D. Merry 	uint8_t	config_bits5;
34006e79492SKenneth D. Merry #define	SMP_DIS_REQ_IN_ZPSDS_CHG	0x40
34106e79492SKenneth D. Merry #define	SMP_DIS_IN_ZPSDS_PER		0x20
34206e79492SKenneth D. Merry #define	SMP_DIS_REQ_IN_ZPSDS		0x10
34306e79492SKenneth D. Merry #define	SMP_DIS_ZG_PER			0x04
34406e79492SKenneth D. Merry #define	SMP_DIS_IN_ZPSDS		0x02
34506e79492SKenneth D. Merry #define	SMP_DIS_ZONING_ENB		0x01
34606e79492SKenneth D. Merry 	uint8_t	reserved3[2];
34706e79492SKenneth D. Merry 	uint8_t	zone_group;
34806e79492SKenneth D. Merry 	uint8_t	self_config_status;
34906e79492SKenneth D. Merry 	uint8_t	self_config_levels_comp;
35006e79492SKenneth D. Merry 	uint8_t	reserved4[2];
35106e79492SKenneth D. Merry 	uint8_t	self_config_sas_addr[8];
35206e79492SKenneth D. Merry 	uint8_t	prog_phy_cap[4];
35306e79492SKenneth D. Merry 	uint8_t	current_phy_cap[4];
35406e79492SKenneth D. Merry 	uint8_t	attached_phy_cap[4];
35506e79492SKenneth D. Merry 	uint8_t	reserved5[6];
35606e79492SKenneth D. Merry 	uint8_t	neg_phys_link_rate;
35706e79492SKenneth D. Merry #define	SMP_DIS_REASON_MASK		0xf0
35806e79492SKenneth D. Merry #define	SMP_DIS_REASON_SHIFT		4
35906e79492SKenneth D. Merry #define	SMP_DIS_PHYS_LR_MASK		0x0f
36006e79492SKenneth D. Merry 	uint8_t	config_bits6;
36106e79492SKenneth D. Merry #define	SMP_DIS_OPTICAL_MODE_ENB	0x04
36206e79492SKenneth D. Merry #define	SMP_DIS_NEG_SSC			0x02
36306e79492SKenneth D. Merry #define	SMP_DIS_HW_MUX_SUP		0x01
36406e79492SKenneth D. Merry 	uint8_t	config_bits7;
36506e79492SKenneth D. Merry #define	SMP_DIS_DEF_IN_ZPSDS_PER	0x20
36606e79492SKenneth D. Merry #define	SMP_DIS_DEF_REQ_IN_ZPSDS	0x10
36706e79492SKenneth D. Merry #define	SMP_DIS_DEF_ZG_PER		0x04
36806e79492SKenneth D. Merry #define	SMP_DIS_DEF_ZONING_ENB		0x01
36906e79492SKenneth D. Merry 	uint8_t	reserved6;
37006e79492SKenneth D. Merry 	uint8_t	reserved7;
37106e79492SKenneth D. Merry 	uint8_t	default_zone_group;
37206e79492SKenneth D. Merry 	uint8_t	config_bits8;
37306e79492SKenneth D. Merry #define	SMP_DIS_SAVED_IN_ZPSDS_PER	0x20
37406e79492SKenneth D. Merry #define	SMP_DIS_SAVED_REQ_IN_SPSDS	0x10
37506e79492SKenneth D. Merry #define	SMP_DIS_SAVED_ZG_PER		0x04
37606e79492SKenneth D. Merry #define	SMP_DIS_SAVED_ZONING_ENB	0x01
37706e79492SKenneth D. Merry 	uint8_t	reserved8;
37806e79492SKenneth D. Merry 	uint8_t	reserved9;
37906e79492SKenneth D. Merry 	uint8_t	saved_zone_group;
38006e79492SKenneth D. Merry 	uint8_t	config_bits9;
38106e79492SKenneth D. Merry #define	SMP_DIS_SHADOW_IN_ZPSDS_PER	0x20
38206e79492SKenneth D. Merry #define	SMP_DIS_SHADOW_IN_REQ_IN_ZPSDS	0x10
38306e79492SKenneth D. Merry #define	SMP_DIS_SHADOW_ZG_PER		0x04
38406e79492SKenneth D. Merry 	uint8_t reserved10;
38506e79492SKenneth D. Merry 	uint8_t reserved11;
38606e79492SKenneth D. Merry 	uint8_t	shadow_zone_group;
38706e79492SKenneth D. Merry 	uint8_t	device_slot_num;
38806e79492SKenneth D. Merry 	uint8_t	device_slot_group_num;
38906e79492SKenneth D. Merry 	uint8_t	device_slot_group_out_conn[6];
39006e79492SKenneth D. Merry 	uint8_t	stp_buffer_size[2];
39106e79492SKenneth D. Merry 	uint8_t	reserved12;
39206e79492SKenneth D. Merry 	uint8_t	reserved13;
39306e79492SKenneth D. Merry 	uint8_t	crc[4];
39406e79492SKenneth D. Merry };
39506e79492SKenneth D. Merry 
39606e79492SKenneth D. Merry /*
39706e79492SKenneth D. Merry  * PHY CONTROL request and response.  Current as of SPL Revision 7.
39806e79492SKenneth D. Merry  */
39906e79492SKenneth D. Merry struct smp_phy_control_request
40006e79492SKenneth D. Merry {
40106e79492SKenneth D. Merry 	uint8_t	frame_type;
40206e79492SKenneth D. Merry 	uint8_t	function;
40306e79492SKenneth D. Merry 	uint8_t response_len;
40406e79492SKenneth D. Merry #define	SMP_PC_RESPONSE_LEN		0x00
40506e79492SKenneth D. Merry 	uint8_t request_len;
40606e79492SKenneth D. Merry #define	SMP_PC_REQUEST_LEN		0x09
40706e79492SKenneth D. Merry 	uint8_t expected_exp_chg_cnt[2];
40806e79492SKenneth D. Merry 	uint8_t reserved0[3];
40906e79492SKenneth D. Merry 	uint8_t phy;
41006e79492SKenneth D. Merry 	uint8_t phy_operation;
41106e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_NOP		0x00
41206e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_LINK_RESET	0x01
41306e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_HARD_RESET	0x02
41406e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_DISABLE		0x03
41506e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_CLEAR_ERR_LOG	0x05
41606e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_CLEAR_AFFILIATON	0x06
41706e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_TRANS_SATA_PSS	0x07
41806e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_CLEAR_STP_ITN_LS	0x08
41906e79492SKenneth D. Merry #define	SMP_PC_PHY_OP_SET_ATT_DEV_NAME	0x09
42006e79492SKenneth D. Merry 	uint8_t update_pp_timeout;
42106e79492SKenneth D. Merry #define	SMP_PC_UPDATE_PP_TIMEOUT	0x01
42206e79492SKenneth D. Merry 	uint8_t reserved1[12];
42306e79492SKenneth D. Merry 	uint8_t attached_device_name[8];
42406e79492SKenneth D. Merry 	uint8_t prog_min_phys_link_rate;
42506e79492SKenneth D. Merry #define	SMP_PC_PROG_MIN_PL_RATE_MASK	0xf0
42606e79492SKenneth D. Merry #define	SMP_PC_PROG_MIN_PL_RATE_SHIFT	4
42706e79492SKenneth D. Merry 	uint8_t prog_max_phys_link_rate;
42806e79492SKenneth D. Merry #define	SMP_PC_PROG_MAX_PL_RATE_MASK	0xf0
42906e79492SKenneth D. Merry #define	SMP_PC_PROG_MAX_PL_RATE_SHIFT	4
43006e79492SKenneth D. Merry 	uint8_t	config_bits0;
43106e79492SKenneth D. Merry #define	SMP_PC_SP_NC			0x00
43206e79492SKenneth D. Merry #define	SMP_PC_SP_DISABLE		0x02
43306e79492SKenneth D. Merry #define	SMP_PC_SP_ENABLE		0x01
43406e79492SKenneth D. Merry #define	SMP_PC_SAS_SLUMBER_NC		0x00
43506e79492SKenneth D. Merry #define	SMP_PC_SAS_SLUMBER_DISABLE	0x80
43606e79492SKenneth D. Merry #define	SMP_PC_SAS_SLUMBER_ENABLE	0x40
43706e79492SKenneth D. Merry #define	SMP_PC_SAS_SLUMBER_MASK		0xc0
43806e79492SKenneth D. Merry #define	SMP_PC_SAS_SLUMBER_SHIFT	6
43906e79492SKenneth D. Merry #define	SMP_PC_SAS_PARTIAL_NC		0x00
44006e79492SKenneth D. Merry #define	SMP_PC_SAS_PARTIAL_DISABLE	0x20
44106e79492SKenneth D. Merry #define	SMP_PC_SAS_PARTIAL_ENABLE	0x10
44206e79492SKenneth D. Merry #define	SMP_PC_SAS_PARTIAL_MASK		0x30
44306e79492SKenneth D. Merry #define	SMP_PC_SAS_PARTIAL_SHIFT	4
44406e79492SKenneth D. Merry #define	SMP_PC_SATA_SLUMBER_NC		0x00
44506e79492SKenneth D. Merry #define	SMP_PC_SATA_SLUMBER_DISABLE	0x08
44606e79492SKenneth D. Merry #define	SMP_PC_SATA_SLUMBER_ENABLE	0x04
44706e79492SKenneth D. Merry #define	SMP_PC_SATA_SLUMBER_MASK	0x0c
44806e79492SKenneth D. Merry #define	SMP_PC_SATA_SLUMBER_SHIFT	2
44906e79492SKenneth D. Merry #define	SMP_PC_SATA_PARTIAL_NC		0x00
45006e79492SKenneth D. Merry #define	SMP_PC_SATA_PARTIAL_DISABLE	0x02
45106e79492SKenneth D. Merry #define	SMP_PC_SATA_PARTIAL_ENABLE	0x01
45206e79492SKenneth D. Merry #define	SMP_PC_SATA_PARTIAL_MASK	0x03
45306e79492SKenneth D. Merry #define	SMP_PC_SATA_PARTIAL_SHIFT	0
45406e79492SKenneth D. Merry 	uint8_t	reserved2;
45506e79492SKenneth D. Merry 	uint8_t	pp_timeout_value;
45606e79492SKenneth D. Merry #define	SMP_PC_PP_TIMEOUT_MASK		0x0f
45706e79492SKenneth D. Merry 	uint8_t reserved3[3];
45806e79492SKenneth D. Merry 	uint8_t	crc[4];
45906e79492SKenneth D. Merry };
46006e79492SKenneth D. Merry 
46106e79492SKenneth D. Merry struct smp_phy_control_response
46206e79492SKenneth D. Merry {
46306e79492SKenneth D. Merry 	uint8_t	frame_type;
46406e79492SKenneth D. Merry 	uint8_t	function;
46506e79492SKenneth D. Merry 	uint8_t	function_result;
46606e79492SKenneth D. Merry 	uint8_t	response_len;
46706e79492SKenneth D. Merry #define	SMP_PC_RESPONSE_LEN		0x00
46806e79492SKenneth D. Merry 	uint8_t crc[4];
46906e79492SKenneth D. Merry };
47006e79492SKenneth D. Merry 
47106e79492SKenneth D. Merry __BEGIN_DECLS
47206e79492SKenneth D. Merry 
47306e79492SKenneth D. Merry const char *smp_error_desc(int function_result);
47406e79492SKenneth D. Merry const char *smp_command_desc(uint8_t cmd_num);
47506e79492SKenneth D. Merry void smp_command_decode(uint8_t *smp_request, int request_len, struct sbuf *sb,
47606e79492SKenneth D. Merry 			char *line_prefix, int first_line_len, int line_len);
47706e79492SKenneth D. Merry void smp_command_sbuf(struct ccb_smpio *smpio, struct sbuf *sb,
47806e79492SKenneth D. Merry 		      char *line_prefix, int first_line_len, int line_len);
47906e79492SKenneth D. Merry 
48006e79492SKenneth D. Merry #ifdef _KERNEL
48106e79492SKenneth D. Merry void smp_error_sbuf(struct ccb_smpio *smpio, struct sbuf *sb);
48206e79492SKenneth D. Merry #else /* !_KERNEL*/
48306e79492SKenneth D. Merry void smp_error_sbuf(struct cam_device *device, struct ccb_smpio *smpio,
48406e79492SKenneth D. Merry 		    struct sbuf *sb);
48506e79492SKenneth D. Merry #endif /* _KERNEL/!_KERNEL */
48606e79492SKenneth D. Merry 
48706e79492SKenneth D. Merry void smp_report_general_sbuf(struct smp_report_general_response *response,
48806e79492SKenneth D. Merry 			     int response_len, struct sbuf *sb);
48906e79492SKenneth D. Merry 
49006e79492SKenneth D. Merry void smp_report_manuf_info_sbuf(struct smp_report_manuf_info_response *response,
49106e79492SKenneth D. Merry 				int response_len, struct sbuf *sb);
49206e79492SKenneth D. Merry 
49306e79492SKenneth D. Merry void smp_report_general(struct ccb_smpio *smpio, uint32_t retries,
49406e79492SKenneth D. Merry 			void (*cbfcnp)(struct cam_periph *, union ccb *),
49506e79492SKenneth D. Merry 			struct smp_report_general_request *request,
49606e79492SKenneth D. Merry 			int request_len, uint8_t *response, int response_len,
49706e79492SKenneth D. Merry 			int long_response, uint32_t timeout);
49806e79492SKenneth D. Merry 
49906e79492SKenneth D. Merry void smp_discover(struct ccb_smpio *smpio, uint32_t retries,
50006e79492SKenneth D. Merry 		  void (*cbfcnp)(struct cam_periph *, union ccb *),
50106e79492SKenneth D. Merry 		  struct smp_discover_request *request, int request_len,
50206e79492SKenneth D. Merry 		  uint8_t *response, int response_len, int long_response,
50306e79492SKenneth D. Merry 		  int ignore_zone_group, int phy, uint32_t timeout);
50406e79492SKenneth D. Merry 
50506e79492SKenneth D. Merry void smp_report_manuf_info(struct ccb_smpio *smpio, uint32_t retries,
50606e79492SKenneth D. Merry 			   void (*cbfcnp)(struct cam_periph *, union ccb *),
50706e79492SKenneth D. Merry 			   struct smp_report_manuf_info_request *request,
50806e79492SKenneth D. Merry 			   int request_len, uint8_t *response, int response_len,
50906e79492SKenneth D. Merry 			   int long_response, uint32_t timeout);
51006e79492SKenneth D. Merry 
51106e79492SKenneth D. Merry void smp_phy_control(struct ccb_smpio *smpio, uint32_t retries,
51206e79492SKenneth D. Merry 		     void (*cbfcnp)(struct cam_periph *, union ccb *),
51306e79492SKenneth D. Merry 		     struct smp_phy_control_request *request, int request_len,
51406e79492SKenneth D. Merry 		     uint8_t *response, int response_len, int long_response,
51506e79492SKenneth D. Merry 		     uint32_t expected_exp_change_count, int phy, int phy_op,
51606e79492SKenneth D. Merry 		     int update_pp_timeout_val, uint64_t attached_device_name,
51706e79492SKenneth D. Merry 		     int prog_min_prl, int prog_max_prl, int slumber_partial,
51806e79492SKenneth D. Merry 		     int pp_timeout_value, uint32_t timeout);
51906e79492SKenneth D. Merry __END_DECLS
52006e79492SKenneth D. Merry 
52106e79492SKenneth D. Merry #endif /*_SCSI_SMP_ALL_H*/
522