xref: /onnv-gate/usr/src/lib/scsi/plugins/smp/sas2/common/sas2_functions.c (revision 13094:efddb0166961)
112126SHyon.Kim@Sun.COM /*
212126SHyon.Kim@Sun.COM  * CDDL HEADER START
312126SHyon.Kim@Sun.COM  *
412126SHyon.Kim@Sun.COM  * The contents of this file are subject to the terms of the
512126SHyon.Kim@Sun.COM  * Common Development and Distribution License (the "License").
612126SHyon.Kim@Sun.COM  * You may not use this file except in compliance with the License.
712126SHyon.Kim@Sun.COM  *
812126SHyon.Kim@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
912126SHyon.Kim@Sun.COM  * or http://www.opensolaris.org/os/licensing.
1012126SHyon.Kim@Sun.COM  * See the License for the specific language governing permissions
1112126SHyon.Kim@Sun.COM  * and limitations under the License.
1212126SHyon.Kim@Sun.COM  *
1312126SHyon.Kim@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
1412126SHyon.Kim@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1512126SHyon.Kim@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
1612126SHyon.Kim@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
1712126SHyon.Kim@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
1812126SHyon.Kim@Sun.COM  *
1912126SHyon.Kim@Sun.COM  * CDDL HEADER END
2012126SHyon.Kim@Sun.COM  */
2112126SHyon.Kim@Sun.COM 
2212126SHyon.Kim@Sun.COM /*
2312126SHyon.Kim@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2412126SHyon.Kim@Sun.COM  */
2512126SHyon.Kim@Sun.COM 
2612126SHyon.Kim@Sun.COM #include <sys/types.h>
2712126SHyon.Kim@Sun.COM #include <sys/scsi/generic/commands.h>
2812126SHyon.Kim@Sun.COM #include <sys/scsi/impl/commands.h>
2912126SHyon.Kim@Sun.COM #include <sys/scsi/generic/smp_frames.h>
3012126SHyon.Kim@Sun.COM 
3112126SHyon.Kim@Sun.COM #include <scsi/libsmp.h>
3212126SHyon.Kim@Sun.COM #include <scsi/libsmp_plugin.h>
3312126SHyon.Kim@Sun.COM #include "sas2.h"
3412126SHyon.Kim@Sun.COM 
3512126SHyon.Kim@Sun.COM /*ARGSUSED*/
3612126SHyon.Kim@Sun.COM static size_t
sas2_rq_len(size_t user,smp_target_t * tp)3712126SHyon.Kim@Sun.COM sas2_rq_len(size_t user, smp_target_t *tp)
3812126SHyon.Kim@Sun.COM {
3912126SHyon.Kim@Sun.COM 	if (user != 0) {
4012126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
4112126SHyon.Kim@Sun.COM 		return (0);
4212126SHyon.Kim@Sun.COM 	}
4312126SHyon.Kim@Sun.COM 
4412126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN);
4512126SHyon.Kim@Sun.COM }
4612126SHyon.Kim@Sun.COM 
4712126SHyon.Kim@Sun.COM /*ARGSUSED*/
4812126SHyon.Kim@Sun.COM static off_t
sas2_rq_dataoff(smp_action_t * ap,smp_target_t * tp)4912126SHyon.Kim@Sun.COM sas2_rq_dataoff(smp_action_t *ap, smp_target_t *tp)
5012126SHyon.Kim@Sun.COM {
5112126SHyon.Kim@Sun.COM 	size_t len;
5212126SHyon.Kim@Sun.COM 
5312126SHyon.Kim@Sun.COM 	smp_action_get_request_frame(ap, NULL, &len);
5412126SHyon.Kim@Sun.COM 
5512126SHyon.Kim@Sun.COM 	if (len > SMP_REQ_MINLEN)
5612126SHyon.Kim@Sun.COM 		return (offsetof(smp_request_frame_t, srf_data[0]));
5712126SHyon.Kim@Sun.COM 
5812126SHyon.Kim@Sun.COM 	return (-1);
5912126SHyon.Kim@Sun.COM }
6012126SHyon.Kim@Sun.COM 
6112126SHyon.Kim@Sun.COM static void
sas2_rq_setframe(smp_action_t * ap,smp_target_t * tp)6212126SHyon.Kim@Sun.COM sas2_rq_setframe(smp_action_t *ap, smp_target_t *tp)
6312126SHyon.Kim@Sun.COM {
6412126SHyon.Kim@Sun.COM 	const smp_function_def_t *dp = smp_action_get_function_def(ap);
6512126SHyon.Kim@Sun.COM 	smp_request_frame_t *fp;
6612126SHyon.Kim@Sun.COM 	uint_t cap;
6712126SHyon.Kim@Sun.COM 	uint16_t change_count;
6812126SHyon.Kim@Sun.COM 	uint16_t *rqcc;
6912126SHyon.Kim@Sun.COM 	size_t rqlen, rslen;
7012126SHyon.Kim@Sun.COM 
7112126SHyon.Kim@Sun.COM 	smp_action_get_request_frame(ap, (void *)&fp, &rqlen);
7212126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, NULL, &rslen);
7312126SHyon.Kim@Sun.COM 	cap = smp_target_getcap(tp);
7412126SHyon.Kim@Sun.COM 
7512126SHyon.Kim@Sun.COM 	fp->srf_frame_type = SMP_FRAME_TYPE_REQUEST;
7612126SHyon.Kim@Sun.COM 	fp->srf_function = dp->sfd_function;
7712126SHyon.Kim@Sun.COM 
7812126SHyon.Kim@Sun.COM 	if (cap & SMP_TARGET_C_LONG_RESP) {
7912126SHyon.Kim@Sun.COM 		fp->srf_allocated_response_len = (rslen - SMP_RESP_MINLEN) / 4;
8012126SHyon.Kim@Sun.COM 		fp->srf_request_len = (rqlen - SMP_REQ_MINLEN) / 4;
8112126SHyon.Kim@Sun.COM 	} else {
8212126SHyon.Kim@Sun.COM 		fp->srf_allocated_response_len = 0;
8312126SHyon.Kim@Sun.COM 		fp->srf_request_len = 0;
8412126SHyon.Kim@Sun.COM 	}
8512126SHyon.Kim@Sun.COM 
8612126SHyon.Kim@Sun.COM 	/*
8712126SHyon.Kim@Sun.COM 	 * If this command requires that the expected expander change count
8812126SHyon.Kim@Sun.COM 	 * be set (as many do), we will attempt to set it based on the
8912126SHyon.Kim@Sun.COM 	 * most recently executed command.  However, if the user has set it
9012126SHyon.Kim@Sun.COM 	 * already, we will not overwrite that setting.  It is the consumer's
9112126SHyon.Kim@Sun.COM 	 * responsibility to keep track of expander changes each time it
9212126SHyon.Kim@Sun.COM 	 * receives a new change count in a response.
9312126SHyon.Kim@Sun.COM 	 */
9412126SHyon.Kim@Sun.COM 	if (dp->sfd_flags & SMP_FD_F_NEEDS_CHANGE_COUNT) {
9512126SHyon.Kim@Sun.COM 		ASSERT(rqlen >= SMP_REQ_MINLEN + sizeof (uint16_t));
9612126SHyon.Kim@Sun.COM 		/* LINTED - alignment */
9712126SHyon.Kim@Sun.COM 		rqcc = (uint16_t *)(&fp->srf_data[0]);
9812126SHyon.Kim@Sun.COM 		if (SCSI_READ16(rqcc) == 0) {
9912126SHyon.Kim@Sun.COM 			change_count = smp_target_get_change_count(tp);
10012126SHyon.Kim@Sun.COM 			SCSI_WRITE16(rqcc, change_count);
10112126SHyon.Kim@Sun.COM 		}
10212126SHyon.Kim@Sun.COM 	}
10312126SHyon.Kim@Sun.COM }
10412126SHyon.Kim@Sun.COM 
10512126SHyon.Kim@Sun.COM /*ARGSUSED*/
10612126SHyon.Kim@Sun.COM static size_t
sas2_rs_datalen(smp_action_t * ap,smp_target_t * tp)10712126SHyon.Kim@Sun.COM sas2_rs_datalen(smp_action_t *ap, smp_target_t *tp)
10812126SHyon.Kim@Sun.COM {
10912126SHyon.Kim@Sun.COM 	smp_response_frame_t *fp;
11012126SHyon.Kim@Sun.COM 	size_t len;
11112126SHyon.Kim@Sun.COM 
11212126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, (void **)&fp, &len);
11312126SHyon.Kim@Sun.COM 
11412126SHyon.Kim@Sun.COM 	if (len >= SMP_RESP_MINLEN)
11512126SHyon.Kim@Sun.COM 		len -= SMP_RESP_MINLEN;
11612126SHyon.Kim@Sun.COM 	else
11712126SHyon.Kim@Sun.COM 		return (0);
11812126SHyon.Kim@Sun.COM 
11912126SHyon.Kim@Sun.COM 	len &= ~3;
12012126SHyon.Kim@Sun.COM 
12112126SHyon.Kim@Sun.COM 	if (fp->srf_response_len == 0)
12212126SHyon.Kim@Sun.COM 		return (0);
12312126SHyon.Kim@Sun.COM 
12412126SHyon.Kim@Sun.COM 	return (MIN(len, 4 * (fp->srf_response_len)));
12512126SHyon.Kim@Sun.COM }
12612126SHyon.Kim@Sun.COM 
12712126SHyon.Kim@Sun.COM /*ARGSUSED*/
12812126SHyon.Kim@Sun.COM static off_t
sas2_rs_dataoff(smp_action_t * ap,smp_target_t * tp)12912126SHyon.Kim@Sun.COM sas2_rs_dataoff(smp_action_t *ap, smp_target_t *tp)
13012126SHyon.Kim@Sun.COM {
13112126SHyon.Kim@Sun.COM 	size_t len;
13212126SHyon.Kim@Sun.COM 
13312126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, NULL, &len);
13412126SHyon.Kim@Sun.COM 
13512126SHyon.Kim@Sun.COM 	if (len > SMP_RESP_MINLEN)
13612126SHyon.Kim@Sun.COM 		return (offsetof(smp_request_frame_t, srf_data[0]));
13712126SHyon.Kim@Sun.COM 
13812126SHyon.Kim@Sun.COM 	return (-1);
13912126SHyon.Kim@Sun.COM }
14012126SHyon.Kim@Sun.COM 
14112126SHyon.Kim@Sun.COM static void
sas2_rs_getparams(smp_action_t * ap,smp_target_t * tp)14212126SHyon.Kim@Sun.COM sas2_rs_getparams(smp_action_t *ap, smp_target_t *tp)
14312126SHyon.Kim@Sun.COM {
14412126SHyon.Kim@Sun.COM 	const smp_function_def_t *dp;
14512126SHyon.Kim@Sun.COM 	smp_response_frame_t *fp;
14612126SHyon.Kim@Sun.COM 	size_t len;
14712126SHyon.Kim@Sun.COM 	uint16_t change_count;
14812126SHyon.Kim@Sun.COM 
14912126SHyon.Kim@Sun.COM 	dp = smp_action_get_function_def(ap);
15012126SHyon.Kim@Sun.COM 
15112126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, (void **)&fp, &len);
15212126SHyon.Kim@Sun.COM 
15312126SHyon.Kim@Sun.COM 	smp_action_set_result(ap, fp->srf_result);
15412126SHyon.Kim@Sun.COM 
15512126SHyon.Kim@Sun.COM 	if (!(dp->sfd_flags & SMP_FD_F_PROVIDES_CHANGE_COUNT))
15612126SHyon.Kim@Sun.COM 		return;
15712126SHyon.Kim@Sun.COM 
15812126SHyon.Kim@Sun.COM 	if (len <= SMP_RESP_MINLEN + sizeof (uint16_t))
15912126SHyon.Kim@Sun.COM 		return;
16012126SHyon.Kim@Sun.COM 
16112126SHyon.Kim@Sun.COM 	change_count = SCSI_READ16(&fp->srf_data[0]);
16212126SHyon.Kim@Sun.COM 	smp_target_set_change_count(tp, change_count);
16312126SHyon.Kim@Sun.COM }
16412126SHyon.Kim@Sun.COM 
16512126SHyon.Kim@Sun.COM /*ARGSUSED*/
16612126SHyon.Kim@Sun.COM static size_t
sas2_report_general_rs_datalen(smp_action_t * ap,smp_target_t * tp)16712126SHyon.Kim@Sun.COM sas2_report_general_rs_datalen(smp_action_t *ap, smp_target_t *tp)
16812126SHyon.Kim@Sun.COM {
16912126SHyon.Kim@Sun.COM 	const smp_function_def_t *dp = smp_action_get_function_def(ap);
17012126SHyon.Kim@Sun.COM 	smp_response_frame_t *fp;
17112126SHyon.Kim@Sun.COM 	size_t len;
17212126SHyon.Kim@Sun.COM 
17312126SHyon.Kim@Sun.COM 	ASSERT(dp->sfd_function == SMP_FUNC_REPORT_GENERAL);
17412126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, (void **)&fp, &len);
17512126SHyon.Kim@Sun.COM 
17612126SHyon.Kim@Sun.COM 	if (len >= SMP_RESP_MINLEN)
17712126SHyon.Kim@Sun.COM 		len -= SMP_RESP_MINLEN;
17812126SHyon.Kim@Sun.COM 	else
17912126SHyon.Kim@Sun.COM 		return (0);
18012126SHyon.Kim@Sun.COM 
18112126SHyon.Kim@Sun.COM 	len &= ~3;
18212126SHyon.Kim@Sun.COM 
18312126SHyon.Kim@Sun.COM 	if (fp->srf_response_len == 0)
18412126SHyon.Kim@Sun.COM 		return (MIN(len, 24));
18512126SHyon.Kim@Sun.COM 
18612126SHyon.Kim@Sun.COM 	return (MIN(len, 4 * (fp->srf_response_len)));
18712126SHyon.Kim@Sun.COM }
18812126SHyon.Kim@Sun.COM 
18912126SHyon.Kim@Sun.COM /*ARGSUSED*/
19012126SHyon.Kim@Sun.COM static size_t
sas2_report_manufacturer_info_rs_datalen(smp_action_t * ap,smp_target_t * tp)19112126SHyon.Kim@Sun.COM sas2_report_manufacturer_info_rs_datalen(smp_action_t *ap, smp_target_t *tp)
19212126SHyon.Kim@Sun.COM {
19312126SHyon.Kim@Sun.COM 	const smp_function_def_t *dp = smp_action_get_function_def(ap);
19412126SHyon.Kim@Sun.COM 	smp_response_frame_t *fp;
19512126SHyon.Kim@Sun.COM 	size_t len;
19612126SHyon.Kim@Sun.COM 
19712126SHyon.Kim@Sun.COM 	ASSERT(dp->sfd_function == SMP_FUNC_REPORT_MANUFACTURER_INFO);
19812126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, (void **)&fp, &len);
19912126SHyon.Kim@Sun.COM 
20012126SHyon.Kim@Sun.COM 	if (len >= SMP_RESP_MINLEN)
20112126SHyon.Kim@Sun.COM 		len -= SMP_RESP_MINLEN;
20212126SHyon.Kim@Sun.COM 	else
20312126SHyon.Kim@Sun.COM 		return (0);
20412126SHyon.Kim@Sun.COM 
20512126SHyon.Kim@Sun.COM 	len &= ~3;
20612126SHyon.Kim@Sun.COM 
20712126SHyon.Kim@Sun.COM 	if (fp->srf_response_len == 0)
20812126SHyon.Kim@Sun.COM 		return (MIN(len, 56));
20912126SHyon.Kim@Sun.COM 
21012126SHyon.Kim@Sun.COM 	return (MIN(len, 4 * (fp->srf_response_len)));
21112126SHyon.Kim@Sun.COM }
21212126SHyon.Kim@Sun.COM 
21312126SHyon.Kim@Sun.COM /*ARGSUSED*/
21412126SHyon.Kim@Sun.COM static size_t
sas2_report_self_config_status_rq_len(size_t user,smp_target_t * tp)21512126SHyon.Kim@Sun.COM sas2_report_self_config_status_rq_len(size_t user, smp_target_t *tp)
21612126SHyon.Kim@Sun.COM {
21712126SHyon.Kim@Sun.COM 	if (user != 0) {
21812126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
21912126SHyon.Kim@Sun.COM 		return (0);
22012126SHyon.Kim@Sun.COM 	}
22112126SHyon.Kim@Sun.COM 
22212126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_report_self_config_status_req_t));
22312126SHyon.Kim@Sun.COM }
22412126SHyon.Kim@Sun.COM 
22512126SHyon.Kim@Sun.COM /*ARGSUSED*/
22612126SHyon.Kim@Sun.COM static size_t
sas2_report_zone_perm_table_rq_len(size_t user,smp_target_t * tp)22712126SHyon.Kim@Sun.COM sas2_report_zone_perm_table_rq_len(size_t user, smp_target_t *tp)
22812126SHyon.Kim@Sun.COM {
22912126SHyon.Kim@Sun.COM 	if (user != 0) {
23012126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
23112126SHyon.Kim@Sun.COM 		return (0);
23212126SHyon.Kim@Sun.COM 	}
23312126SHyon.Kim@Sun.COM 
23412126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_report_zone_perm_table_req_t));
23512126SHyon.Kim@Sun.COM }
23612126SHyon.Kim@Sun.COM 
23712126SHyon.Kim@Sun.COM /*ARGSUSED*/
23812126SHyon.Kim@Sun.COM static size_t
sas2_report_zone_mgr_password_rq_len(size_t user,smp_target_t * tp)239*13094Sdavid.hollister@oracle.com sas2_report_zone_mgr_password_rq_len(size_t user, smp_target_t *tp)
240*13094Sdavid.hollister@oracle.com {
241*13094Sdavid.hollister@oracle.com 	if (user != 0) {
242*13094Sdavid.hollister@oracle.com 		(void) smp_set_errno(ESMP_RANGE);
243*13094Sdavid.hollister@oracle.com 		return (0);
244*13094Sdavid.hollister@oracle.com 	}
245*13094Sdavid.hollister@oracle.com 
246*13094Sdavid.hollister@oracle.com 	return (SMP_REQ_MINLEN + sizeof (smp_report_zone_perm_table_req_t));
247*13094Sdavid.hollister@oracle.com }
248*13094Sdavid.hollister@oracle.com 
249*13094Sdavid.hollister@oracle.com /*ARGSUSED*/
250*13094Sdavid.hollister@oracle.com static size_t
sas2_report_broadcast_rq_len(size_t user,smp_target_t * tp)25112126SHyon.Kim@Sun.COM sas2_report_broadcast_rq_len(size_t user, smp_target_t *tp)
25212126SHyon.Kim@Sun.COM {
25312126SHyon.Kim@Sun.COM 	if (user != 0) {
25412126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
25512126SHyon.Kim@Sun.COM 		return (0);
25612126SHyon.Kim@Sun.COM 	}
25712126SHyon.Kim@Sun.COM 
25812126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_report_broadcast_req_t));
25912126SHyon.Kim@Sun.COM }
26012126SHyon.Kim@Sun.COM 
26112126SHyon.Kim@Sun.COM /*ARGSUSED*/
26212126SHyon.Kim@Sun.COM static size_t
sas2_discover_rq_len(size_t user,smp_target_t * tp)26312126SHyon.Kim@Sun.COM sas2_discover_rq_len(size_t user, smp_target_t *tp)
26412126SHyon.Kim@Sun.COM {
26512126SHyon.Kim@Sun.COM 	if (user != 0) {
26612126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
26712126SHyon.Kim@Sun.COM 		return (0);
26812126SHyon.Kim@Sun.COM 	}
26912126SHyon.Kim@Sun.COM 
27012126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_discover_req_t));
27112126SHyon.Kim@Sun.COM }
27212126SHyon.Kim@Sun.COM 
27312126SHyon.Kim@Sun.COM /*ARGSUSED*/
27412126SHyon.Kim@Sun.COM static size_t
sas2_discover_rs_datalen(smp_action_t * ap,smp_target_t * tp)27512126SHyon.Kim@Sun.COM sas2_discover_rs_datalen(smp_action_t *ap, smp_target_t *tp)
27612126SHyon.Kim@Sun.COM {
27712126SHyon.Kim@Sun.COM 	const smp_function_def_t *dp = smp_action_get_function_def(ap);
27812126SHyon.Kim@Sun.COM 	smp_response_frame_t *fp;
27912126SHyon.Kim@Sun.COM 	size_t len;
28012126SHyon.Kim@Sun.COM 
28112126SHyon.Kim@Sun.COM 	ASSERT(dp->sfd_function == SMP_FUNC_DISCOVER);
28212126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, (void **)&fp, &len);
28312126SHyon.Kim@Sun.COM 
28412126SHyon.Kim@Sun.COM 	if (len >= SMP_RESP_MINLEN)
28512126SHyon.Kim@Sun.COM 		len -= SMP_RESP_MINLEN;
28612126SHyon.Kim@Sun.COM 	else
28712126SHyon.Kim@Sun.COM 		return (0);
28812126SHyon.Kim@Sun.COM 
28912126SHyon.Kim@Sun.COM 	len &= ~3;
29012126SHyon.Kim@Sun.COM 
29112126SHyon.Kim@Sun.COM 	if (fp->srf_response_len == 0)
29212126SHyon.Kim@Sun.COM 		return (MIN(len, 48));
29312126SHyon.Kim@Sun.COM 
29412126SHyon.Kim@Sun.COM 	return (MIN(len, 4 * (fp->srf_response_len)));
29512126SHyon.Kim@Sun.COM }
29612126SHyon.Kim@Sun.COM 
29712126SHyon.Kim@Sun.COM /*ARGSUSED*/
29812126SHyon.Kim@Sun.COM static size_t
sas2_report_phy_error_log_rq_len(size_t user,smp_target_t * tp)29912126SHyon.Kim@Sun.COM sas2_report_phy_error_log_rq_len(size_t user, smp_target_t *tp)
30012126SHyon.Kim@Sun.COM {
30112126SHyon.Kim@Sun.COM 	if (user != 0) {
30212126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
30312126SHyon.Kim@Sun.COM 		return (0);
30412126SHyon.Kim@Sun.COM 	}
30512126SHyon.Kim@Sun.COM 
30612126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_report_phy_error_log_req_t));
30712126SHyon.Kim@Sun.COM }
30812126SHyon.Kim@Sun.COM 
30912126SHyon.Kim@Sun.COM /*ARGSUSED*/
31012126SHyon.Kim@Sun.COM static size_t
sas2_report_phy_error_log_rs_datalen(smp_action_t * ap,smp_target_t * tp)31112126SHyon.Kim@Sun.COM sas2_report_phy_error_log_rs_datalen(smp_action_t *ap, smp_target_t *tp)
31212126SHyon.Kim@Sun.COM {
31312126SHyon.Kim@Sun.COM 	const smp_function_def_t *dp = smp_action_get_function_def(ap);
31412126SHyon.Kim@Sun.COM 	smp_response_frame_t *fp;
31512126SHyon.Kim@Sun.COM 	size_t len;
31612126SHyon.Kim@Sun.COM 
31712126SHyon.Kim@Sun.COM 	ASSERT(dp->sfd_function == SMP_FUNC_REPORT_PHY_ERROR_LOG);
31812126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, (void **)&fp, &len);
31912126SHyon.Kim@Sun.COM 
32012126SHyon.Kim@Sun.COM 	if (len >= SMP_RESP_MINLEN)
32112126SHyon.Kim@Sun.COM 		len -= SMP_RESP_MINLEN;
32212126SHyon.Kim@Sun.COM 	else
32312126SHyon.Kim@Sun.COM 		return (0);
32412126SHyon.Kim@Sun.COM 
32512126SHyon.Kim@Sun.COM 	len &= ~3;
32612126SHyon.Kim@Sun.COM 
32712126SHyon.Kim@Sun.COM 	if (fp->srf_response_len == 0)
32812126SHyon.Kim@Sun.COM 		return (MIN(len, sizeof (smp_report_phy_error_log_resp_t)));
32912126SHyon.Kim@Sun.COM 
33012126SHyon.Kim@Sun.COM 	return (MIN(len, 4 * (fp->srf_response_len)));
33112126SHyon.Kim@Sun.COM }
33212126SHyon.Kim@Sun.COM 
33312126SHyon.Kim@Sun.COM /*ARGSUSED*/
33412126SHyon.Kim@Sun.COM static size_t
sas2_report_phy_sata_rq_len(size_t user,smp_target_t * tp)33512126SHyon.Kim@Sun.COM sas2_report_phy_sata_rq_len(size_t user, smp_target_t *tp)
33612126SHyon.Kim@Sun.COM {
33712126SHyon.Kim@Sun.COM 	if (user != 0) {
33812126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
33912126SHyon.Kim@Sun.COM 		return (0);
34012126SHyon.Kim@Sun.COM 	}
34112126SHyon.Kim@Sun.COM 
34212126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_report_phy_sata_req_t));
34312126SHyon.Kim@Sun.COM }
34412126SHyon.Kim@Sun.COM 
34512126SHyon.Kim@Sun.COM /*ARGSUSED*/
34612126SHyon.Kim@Sun.COM static size_t
sas2_report_phy_sata_rs_datalen(smp_action_t * ap,smp_target_t * tp)34712126SHyon.Kim@Sun.COM sas2_report_phy_sata_rs_datalen(smp_action_t *ap, smp_target_t *tp)
34812126SHyon.Kim@Sun.COM {
34912126SHyon.Kim@Sun.COM 	const smp_function_def_t *dp = smp_action_get_function_def(ap);
35012126SHyon.Kim@Sun.COM 	smp_response_frame_t *fp;
35112126SHyon.Kim@Sun.COM 	size_t len;
35212126SHyon.Kim@Sun.COM 
35312126SHyon.Kim@Sun.COM 	ASSERT(dp->sfd_function == SMP_FUNC_REPORT_PHY_SATA);
35412126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, (void **)&fp, &len);
35512126SHyon.Kim@Sun.COM 
35612126SHyon.Kim@Sun.COM 	if (len >= SMP_RESP_MINLEN)
35712126SHyon.Kim@Sun.COM 		len -= SMP_RESP_MINLEN;
35812126SHyon.Kim@Sun.COM 	else
35912126SHyon.Kim@Sun.COM 		return (0);
36012126SHyon.Kim@Sun.COM 
36112126SHyon.Kim@Sun.COM 	len &= ~3;
36212126SHyon.Kim@Sun.COM 
36312126SHyon.Kim@Sun.COM 	if (fp->srf_response_len == 0)
36412126SHyon.Kim@Sun.COM 		return (MIN(len, 52));
36512126SHyon.Kim@Sun.COM 
36612126SHyon.Kim@Sun.COM 	return (MIN(len, 4 * (fp->srf_response_len)));
36712126SHyon.Kim@Sun.COM }
36812126SHyon.Kim@Sun.COM 
36912126SHyon.Kim@Sun.COM /*ARGSUSED*/
37012126SHyon.Kim@Sun.COM static size_t
sas2_report_route_info_rq_len(size_t user,smp_target_t * tp)37112126SHyon.Kim@Sun.COM sas2_report_route_info_rq_len(size_t user, smp_target_t *tp)
37212126SHyon.Kim@Sun.COM {
37312126SHyon.Kim@Sun.COM 	if (user != 0) {
37412126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
37512126SHyon.Kim@Sun.COM 		return (0);
37612126SHyon.Kim@Sun.COM 	}
37712126SHyon.Kim@Sun.COM 
37812126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_report_route_info_req_t));
37912126SHyon.Kim@Sun.COM }
38012126SHyon.Kim@Sun.COM 
38112126SHyon.Kim@Sun.COM /*ARGSUSED*/
38212126SHyon.Kim@Sun.COM static size_t
sas2_report_route_info_rs_datalen(smp_action_t * ap,smp_target_t * tp)38312126SHyon.Kim@Sun.COM sas2_report_route_info_rs_datalen(smp_action_t *ap, smp_target_t *tp)
38412126SHyon.Kim@Sun.COM {
38512126SHyon.Kim@Sun.COM 	const smp_function_def_t *dp = smp_action_get_function_def(ap);
38612126SHyon.Kim@Sun.COM 	smp_response_frame_t *fp;
38712126SHyon.Kim@Sun.COM 	size_t len;
38812126SHyon.Kim@Sun.COM 
38912126SHyon.Kim@Sun.COM 	ASSERT(dp->sfd_function == SMP_FUNC_REPORT_ROUTE_INFO);
39012126SHyon.Kim@Sun.COM 	smp_action_get_response_frame(ap, (void **)&fp, &len);
39112126SHyon.Kim@Sun.COM 
39212126SHyon.Kim@Sun.COM 	if (len >= SMP_RESP_MINLEN)
39312126SHyon.Kim@Sun.COM 		len -= SMP_RESP_MINLEN;
39412126SHyon.Kim@Sun.COM 	else
39512126SHyon.Kim@Sun.COM 		return (0);
39612126SHyon.Kim@Sun.COM 
39712126SHyon.Kim@Sun.COM 	len &= ~3;
39812126SHyon.Kim@Sun.COM 
39912126SHyon.Kim@Sun.COM 	if (fp->srf_response_len == 0)
40012126SHyon.Kim@Sun.COM 		return (MIN(len, sizeof (smp_report_route_info_resp_t)));
40112126SHyon.Kim@Sun.COM 
40212126SHyon.Kim@Sun.COM 	return (MIN(len, 4 * (fp->srf_response_len)));
40312126SHyon.Kim@Sun.COM }
40412126SHyon.Kim@Sun.COM 
40512126SHyon.Kim@Sun.COM /*ARGSUSED*/
40612126SHyon.Kim@Sun.COM static size_t
sas2_report_phy_event_rq_len(size_t user,smp_target_t * tp)40712126SHyon.Kim@Sun.COM sas2_report_phy_event_rq_len(size_t user, smp_target_t *tp)
40812126SHyon.Kim@Sun.COM {
40912126SHyon.Kim@Sun.COM 	if (user != 0) {
41012126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
41112126SHyon.Kim@Sun.COM 		return (0);
41212126SHyon.Kim@Sun.COM 	}
41312126SHyon.Kim@Sun.COM 
41412126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_report_phy_event_req_t));
41512126SHyon.Kim@Sun.COM }
41612126SHyon.Kim@Sun.COM 
41712126SHyon.Kim@Sun.COM /*ARGSUSED*/
41812126SHyon.Kim@Sun.COM static size_t
sas2_discover_list_rq_len(size_t user,smp_target_t * tp)41912126SHyon.Kim@Sun.COM sas2_discover_list_rq_len(size_t user, smp_target_t *tp)
42012126SHyon.Kim@Sun.COM {
42112126SHyon.Kim@Sun.COM 	if (user != 0) {
42212126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
42312126SHyon.Kim@Sun.COM 		return (0);
42412126SHyon.Kim@Sun.COM 	}
42512126SHyon.Kim@Sun.COM 
42612126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_discover_list_req_t));
42712126SHyon.Kim@Sun.COM }
42812126SHyon.Kim@Sun.COM 
42912126SHyon.Kim@Sun.COM /*ARGSUSED*/
43012126SHyon.Kim@Sun.COM static size_t
sas2_report_phy_event_list_rq_len(size_t user,smp_target_t * tp)43112126SHyon.Kim@Sun.COM sas2_report_phy_event_list_rq_len(size_t user, smp_target_t *tp)
43212126SHyon.Kim@Sun.COM {
43312126SHyon.Kim@Sun.COM 	if (user != 0) {
43412126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
43512126SHyon.Kim@Sun.COM 		return (0);
43612126SHyon.Kim@Sun.COM 	}
43712126SHyon.Kim@Sun.COM 
43812126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_report_phy_event_list_req_t));
43912126SHyon.Kim@Sun.COM }
44012126SHyon.Kim@Sun.COM 
44112126SHyon.Kim@Sun.COM /*ARGSUSED*/
44212126SHyon.Kim@Sun.COM static size_t
sas2_report_exp_route_table_list_rq_len(size_t user,smp_target_t * tp)44312126SHyon.Kim@Sun.COM sas2_report_exp_route_table_list_rq_len(size_t user, smp_target_t *tp)
44412126SHyon.Kim@Sun.COM {
44512126SHyon.Kim@Sun.COM 	if (user != 0) {
44612126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
44712126SHyon.Kim@Sun.COM 		return (0);
44812126SHyon.Kim@Sun.COM 	}
44912126SHyon.Kim@Sun.COM 
45012126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN +
45112126SHyon.Kim@Sun.COM 	    sizeof (smp_report_exp_route_table_list_req_t));
45212126SHyon.Kim@Sun.COM }
45312126SHyon.Kim@Sun.COM 
45412126SHyon.Kim@Sun.COM /*ARGSUSED*/
45512126SHyon.Kim@Sun.COM static size_t
sas2_config_general_rq_len(size_t user,smp_target_t * tp)45612126SHyon.Kim@Sun.COM sas2_config_general_rq_len(size_t user, smp_target_t *tp)
45712126SHyon.Kim@Sun.COM {
45812126SHyon.Kim@Sun.COM 	if (user != 0) {
45912126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
46012126SHyon.Kim@Sun.COM 		return (0);
46112126SHyon.Kim@Sun.COM 	}
46212126SHyon.Kim@Sun.COM 
46312126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_config_general_req_t));
46412126SHyon.Kim@Sun.COM }
46512126SHyon.Kim@Sun.COM 
46612126SHyon.Kim@Sun.COM /*ARGSUSED*/
46712126SHyon.Kim@Sun.COM static size_t
sas2_enable_disable_zoning_rq_len(size_t user,smp_target_t * tp)46812126SHyon.Kim@Sun.COM sas2_enable_disable_zoning_rq_len(size_t user, smp_target_t *tp)
46912126SHyon.Kim@Sun.COM {
47012126SHyon.Kim@Sun.COM 	if (user != 0) {
47112126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
47212126SHyon.Kim@Sun.COM 		return (0);
47312126SHyon.Kim@Sun.COM 	}
47412126SHyon.Kim@Sun.COM 
47512126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_enable_disable_zoning_req_t));
47612126SHyon.Kim@Sun.COM }
47712126SHyon.Kim@Sun.COM 
47812126SHyon.Kim@Sun.COM /*ARGSUSED*/
47912126SHyon.Kim@Sun.COM static size_t
sas2_zoned_broadcast_rq_len(size_t user,smp_target_t * tp)48012126SHyon.Kim@Sun.COM sas2_zoned_broadcast_rq_len(size_t user, smp_target_t *tp)
48112126SHyon.Kim@Sun.COM {
48212126SHyon.Kim@Sun.COM 	size_t descrsz;
48312126SHyon.Kim@Sun.COM 
48412126SHyon.Kim@Sun.COM 	if (user == 0 || user > 1008) {
48512126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
48612126SHyon.Kim@Sun.COM 		return (0);
48712126SHyon.Kim@Sun.COM 	}
48812126SHyon.Kim@Sun.COM 
48912126SHyon.Kim@Sun.COM 	descrsz = P2ROUNDUP((user - 1), 4);
49012126SHyon.Kim@Sun.COM 
49112126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + descrsz + sizeof (smp_zoned_broadcast_req_t));
49212126SHyon.Kim@Sun.COM }
49312126SHyon.Kim@Sun.COM 
49412126SHyon.Kim@Sun.COM /*ARGSUSED*/
49512126SHyon.Kim@Sun.COM static size_t
sas2_zone_lock_rq_len(size_t user,smp_target_t * tp)49612126SHyon.Kim@Sun.COM sas2_zone_lock_rq_len(size_t user, smp_target_t *tp)
49712126SHyon.Kim@Sun.COM {
49812126SHyon.Kim@Sun.COM 	if (user != 0) {
49912126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
50012126SHyon.Kim@Sun.COM 		return (0);
50112126SHyon.Kim@Sun.COM 	}
50212126SHyon.Kim@Sun.COM 
50312126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_zone_lock_req_t));
50412126SHyon.Kim@Sun.COM }
50512126SHyon.Kim@Sun.COM 
50612126SHyon.Kim@Sun.COM /*ARGSUSED*/
50712126SHyon.Kim@Sun.COM static size_t
sas2_zone_activate_rq_len(size_t user,smp_target_t * tp)50812126SHyon.Kim@Sun.COM sas2_zone_activate_rq_len(size_t user, smp_target_t *tp)
50912126SHyon.Kim@Sun.COM {
51012126SHyon.Kim@Sun.COM 	if (user != 0) {
51112126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
51212126SHyon.Kim@Sun.COM 		return (0);
51312126SHyon.Kim@Sun.COM 	}
51412126SHyon.Kim@Sun.COM 
51512126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_zone_activate_req_t));
51612126SHyon.Kim@Sun.COM }
51712126SHyon.Kim@Sun.COM 
51812126SHyon.Kim@Sun.COM /*ARGSUSED*/
51912126SHyon.Kim@Sun.COM static size_t
sas2_zone_unlock_rq_len(size_t user,smp_target_t * tp)52012126SHyon.Kim@Sun.COM sas2_zone_unlock_rq_len(size_t user, smp_target_t *tp)
52112126SHyon.Kim@Sun.COM {
52212126SHyon.Kim@Sun.COM 	if (user != 0) {
52312126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
52412126SHyon.Kim@Sun.COM 		return (0);
52512126SHyon.Kim@Sun.COM 	}
52612126SHyon.Kim@Sun.COM 
52712126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_zone_unlock_req_t));
52812126SHyon.Kim@Sun.COM }
52912126SHyon.Kim@Sun.COM 
53012126SHyon.Kim@Sun.COM /*ARGSUSED*/
53112126SHyon.Kim@Sun.COM static size_t
sas2_config_zone_manager_password_rq_len(size_t user,smp_target_t * tp)53212126SHyon.Kim@Sun.COM sas2_config_zone_manager_password_rq_len(size_t user, smp_target_t *tp)
53312126SHyon.Kim@Sun.COM {
53412126SHyon.Kim@Sun.COM 	if (user != 0) {
53512126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
53612126SHyon.Kim@Sun.COM 		return (0);
53712126SHyon.Kim@Sun.COM 	}
53812126SHyon.Kim@Sun.COM 
53912126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN +
54012126SHyon.Kim@Sun.COM 	    sizeof (smp_config_zone_manager_password_req_t));
54112126SHyon.Kim@Sun.COM }
54212126SHyon.Kim@Sun.COM 
54312126SHyon.Kim@Sun.COM /*ARGSUSED*/
54412126SHyon.Kim@Sun.COM static size_t
sas2_config_zone_phy_info_rq_len(size_t user,smp_target_t * tp)54512126SHyon.Kim@Sun.COM sas2_config_zone_phy_info_rq_len(size_t user, smp_target_t *tp)
54612126SHyon.Kim@Sun.COM {
54712126SHyon.Kim@Sun.COM 	if (user == 0 || user > 252) {
54812126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
54912126SHyon.Kim@Sun.COM 		return (0);
55012126SHyon.Kim@Sun.COM 	}
55112126SHyon.Kim@Sun.COM 
55212126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_config_zone_phy_info_req_t) +
55312126SHyon.Kim@Sun.COM 	    (user - 1) * sizeof (smp_zone_phy_config_descr_t));
55412126SHyon.Kim@Sun.COM }
55512126SHyon.Kim@Sun.COM 
55612126SHyon.Kim@Sun.COM static size_t
sas2_config_zone_perm_table_rq_len(size_t user,smp_target_t * tp)55712126SHyon.Kim@Sun.COM sas2_config_zone_perm_table_rq_len(size_t user, smp_target_t *tp)
55812126SHyon.Kim@Sun.COM {
55912126SHyon.Kim@Sun.COM 	uint_t cap = smp_target_getcap(tp);
56012126SHyon.Kim@Sun.COM 	size_t maxdescr, descrsz;
56112126SHyon.Kim@Sun.COM 
56212126SHyon.Kim@Sun.COM 	if (cap & SMP_TARGET_C_ZG_256)
56312126SHyon.Kim@Sun.COM 		descrsz = sizeof (smp_zone_perm_descr256_t);
56412126SHyon.Kim@Sun.COM 	else
56512126SHyon.Kim@Sun.COM 		descrsz = sizeof (smp_zone_perm_descr128_t);
56612126SHyon.Kim@Sun.COM 
56712126SHyon.Kim@Sun.COM 	maxdescr = (1020 - sizeof (smp_config_zone_perm_table_req_t)) / descrsz;
56812126SHyon.Kim@Sun.COM 
56912126SHyon.Kim@Sun.COM 	if (user == 0 || user > maxdescr) {
57012126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
57112126SHyon.Kim@Sun.COM 		return (0);
57212126SHyon.Kim@Sun.COM 	}
57312126SHyon.Kim@Sun.COM 
57412126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_config_zone_perm_table_req_t) - 1 +
57512126SHyon.Kim@Sun.COM 	    user * descrsz);
57612126SHyon.Kim@Sun.COM }
57712126SHyon.Kim@Sun.COM 
57812126SHyon.Kim@Sun.COM /*ARGSUSED*/
57912126SHyon.Kim@Sun.COM static size_t
sas2_config_route_info_rq_len(size_t user,smp_target_t * tp)58012126SHyon.Kim@Sun.COM sas2_config_route_info_rq_len(size_t user, smp_target_t *tp)
58112126SHyon.Kim@Sun.COM {
58212126SHyon.Kim@Sun.COM 	if (user != 0) {
58312126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
58412126SHyon.Kim@Sun.COM 		return (0);
58512126SHyon.Kim@Sun.COM 	}
58612126SHyon.Kim@Sun.COM 
58712126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_config_route_info_req_t));
58812126SHyon.Kim@Sun.COM }
58912126SHyon.Kim@Sun.COM 
59012126SHyon.Kim@Sun.COM /*ARGSUSED*/
59112126SHyon.Kim@Sun.COM static size_t
sas2_phy_control_rq_len(size_t user,smp_target_t * tp)59212126SHyon.Kim@Sun.COM sas2_phy_control_rq_len(size_t user, smp_target_t *tp)
59312126SHyon.Kim@Sun.COM {
59412126SHyon.Kim@Sun.COM 	if (user != 0) {
59512126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
59612126SHyon.Kim@Sun.COM 		return (0);
59712126SHyon.Kim@Sun.COM 	}
59812126SHyon.Kim@Sun.COM 
59912126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_phy_control_req_t));
60012126SHyon.Kim@Sun.COM }
60112126SHyon.Kim@Sun.COM 
60212126SHyon.Kim@Sun.COM /*ARGSUSED*/
60312126SHyon.Kim@Sun.COM static size_t
sas2_phy_test_function_rq_len(size_t user,smp_target_t * tp)60412126SHyon.Kim@Sun.COM sas2_phy_test_function_rq_len(size_t user, smp_target_t *tp)
60512126SHyon.Kim@Sun.COM {
60612126SHyon.Kim@Sun.COM 	if (user != 0) {
60712126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
60812126SHyon.Kim@Sun.COM 		return (0);
60912126SHyon.Kim@Sun.COM 	}
61012126SHyon.Kim@Sun.COM 
61112126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_phy_test_function_req_t));
61212126SHyon.Kim@Sun.COM }
61312126SHyon.Kim@Sun.COM 
61412126SHyon.Kim@Sun.COM /*ARGSUSED*/
61512126SHyon.Kim@Sun.COM static size_t
sas2_config_phy_event_rq_len(size_t user,smp_target_t * tp)61612126SHyon.Kim@Sun.COM sas2_config_phy_event_rq_len(size_t user, smp_target_t *tp)
61712126SHyon.Kim@Sun.COM {
61812126SHyon.Kim@Sun.COM 	if (user == 0 || user > 126) {
61912126SHyon.Kim@Sun.COM 		(void) smp_set_errno(ESMP_RANGE);
62012126SHyon.Kim@Sun.COM 		return (0);
62112126SHyon.Kim@Sun.COM 	}
62212126SHyon.Kim@Sun.COM 
62312126SHyon.Kim@Sun.COM 	return (SMP_REQ_MINLEN + sizeof (smp_config_phy_event_req_t) +
62412126SHyon.Kim@Sun.COM 	    (user - 1) * sizeof (smp_phy_event_config_descr_t));
62512126SHyon.Kim@Sun.COM }
62612126SHyon.Kim@Sun.COM 
62712126SHyon.Kim@Sun.COM smp_function_def_t sas2_functions[] = {
62812126SHyon.Kim@Sun.COM {
62912126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_GENERAL,
63012126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_PROVIDES_CHANGE_COUNT,
63112126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_rq_len,
63212126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
63312126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
63412126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_report_general_rs_datalen,
63512126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
63612126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
63712126SHyon.Kim@Sun.COM },
63812126SHyon.Kim@Sun.COM {
63912126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_MANUFACTURER_INFO,
64012126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_PROVIDES_CHANGE_COUNT,
64112126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_rq_len,
64212126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
64312126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
64412126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_report_manufacturer_info_rs_datalen,
64512126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
64612126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
64712126SHyon.Kim@Sun.COM },
64812126SHyon.Kim@Sun.COM {
64912126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_SELF_CONFIG_STATUS,
65012126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
65112126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
65212126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_self_config_status_rq_len,
65312126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
65412126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
65512126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
65612126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
65712126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
65812126SHyon.Kim@Sun.COM },
65912126SHyon.Kim@Sun.COM {
66012126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_ZONE_PERM_TABLE,
66112126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
66212126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
66312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_zone_perm_table_rq_len,
66412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
66512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
66612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
66712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
66812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
66912126SHyon.Kim@Sun.COM },
67012126SHyon.Kim@Sun.COM {
67112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_ZONE_MANAGER_PASSWORD,
67212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_PROVIDES_CHANGE_COUNT,
673*13094Sdavid.hollister@oracle.com 	.sfd_rq_len = sas2_report_zone_mgr_password_rq_len,
67412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
67512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
67612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
67712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
67812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
67912126SHyon.Kim@Sun.COM },
68012126SHyon.Kim@Sun.COM {
68112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_BROADCAST,
68212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
68312126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
68412126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_broadcast_rq_len,
68512126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
68612126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
68712126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
68812126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
68912126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
69012126SHyon.Kim@Sun.COM },
69112126SHyon.Kim@Sun.COM {
69212126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_DISCOVER,
69312126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
69412126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
69512126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_discover_rq_len,
69612126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
69712126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
69812126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_discover_rs_datalen,
69912126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
70012126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
70112126SHyon.Kim@Sun.COM },
70212126SHyon.Kim@Sun.COM {
70312126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_PHY_ERROR_LOG,
70412126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
70512126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
70612126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_phy_error_log_rq_len,
70712126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
70812126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
70912126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_report_phy_error_log_rs_datalen,
71012126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
71112126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
71212126SHyon.Kim@Sun.COM },
71312126SHyon.Kim@Sun.COM {
71412126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_PHY_SATA,
71512126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
71612126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
71712126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_phy_sata_rq_len,
71812126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
71912126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
72012126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_report_phy_sata_rs_datalen,
72112126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
72212126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
72312126SHyon.Kim@Sun.COM },
72412126SHyon.Kim@Sun.COM {
72512126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_ROUTE_INFO,
72612126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
72712126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
72812126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_route_info_rq_len,
72912126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
73012126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
73112126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_report_route_info_rs_datalen,
73212126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
73312126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
73412126SHyon.Kim@Sun.COM },
73512126SHyon.Kim@Sun.COM {
73612126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_PHY_EVENT,
73712126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
73812126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
73912126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_phy_event_rq_len,
74012126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
74112126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
74212126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
74312126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
74412126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
74512126SHyon.Kim@Sun.COM },
74612126SHyon.Kim@Sun.COM {
74712126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_DISCOVER_LIST,
74812126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
74912126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
75012126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_discover_list_rq_len,
75112126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
75212126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
75312126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
75412126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
75512126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
75612126SHyon.Kim@Sun.COM },
75712126SHyon.Kim@Sun.COM {
75812126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_PHY_EVENT_LIST,
75912126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
76012126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
76112126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_phy_event_list_rq_len,
76212126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
76312126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
76412126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
76512126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
76612126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
76712126SHyon.Kim@Sun.COM },
76812126SHyon.Kim@Sun.COM {
76912126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_REPORT_EXP_ROUTE_TABLE_LIST,
77012126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
77112126SHyon.Kim@Sun.COM 	    SMP_FD_F_PROVIDES_CHANGE_COUNT,
77212126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_report_exp_route_table_list_rq_len,
77312126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
77412126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
77512126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
77612126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
77712126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
77812126SHyon.Kim@Sun.COM },
77912126SHyon.Kim@Sun.COM {
78012126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_CONFIG_GENERAL,
78112126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
78212126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_config_general_rq_len,
78312126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
78412126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
78512126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
78612126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
78712126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
78812126SHyon.Kim@Sun.COM },
78912126SHyon.Kim@Sun.COM {
79012126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_ENABLE_DISABLE_ZONING,
79112126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
79212126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_enable_disable_zoning_rq_len,
79312126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
79412126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
79512126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
79612126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
79712126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
79812126SHyon.Kim@Sun.COM },
79912126SHyon.Kim@Sun.COM {
80012126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_ZONED_BROADCAST,
80112126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE,
80212126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_zoned_broadcast_rq_len,
80312126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
80412126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
80512126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
80612126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
80712126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
80812126SHyon.Kim@Sun.COM },
80912126SHyon.Kim@Sun.COM {
81012126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_ZONE_LOCK,
81112126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_READ | SMP_FD_F_WRITE |
81212126SHyon.Kim@Sun.COM 	    SMP_FD_F_NEEDS_CHANGE_COUNT,
81312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_zone_lock_rq_len,
81412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
81512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
81612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
81712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
81812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
81912126SHyon.Kim@Sun.COM },
82012126SHyon.Kim@Sun.COM {
82112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_ZONE_ACTIVATE,
82212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
82312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_zone_activate_rq_len,
82412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
82512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
82612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
82712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
82812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
82912126SHyon.Kim@Sun.COM },
83012126SHyon.Kim@Sun.COM {
83112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_ZONE_UNLOCK,
83212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE,
83312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_zone_unlock_rq_len,
83412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
83512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
83612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
83712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
83812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
83912126SHyon.Kim@Sun.COM },
84012126SHyon.Kim@Sun.COM {
84112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_CONFIG_ZONE_MANAGER_PASSWORD,
84212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
84312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_config_zone_manager_password_rq_len,
84412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
84512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
84612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
84712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
84812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
84912126SHyon.Kim@Sun.COM },
85012126SHyon.Kim@Sun.COM {
85112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_CONFIG_ZONE_PHY_INFO,
85212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
85312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_config_zone_phy_info_rq_len,
85412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
85512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
85612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
85712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
85812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
85912126SHyon.Kim@Sun.COM },
86012126SHyon.Kim@Sun.COM {
86112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_CONFIG_ZONE_PERM_TABLE,
86212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
86312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_config_zone_perm_table_rq_len,
86412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
86512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
86612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
86712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
86812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
86912126SHyon.Kim@Sun.COM },
87012126SHyon.Kim@Sun.COM {
87112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_CONFIG_ROUTE_INFO,
87212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
87312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_config_route_info_rq_len,
87412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
87512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
87612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
87712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
87812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
87912126SHyon.Kim@Sun.COM },
88012126SHyon.Kim@Sun.COM {
88112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_PHY_CONTROL,
88212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
88312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_phy_control_rq_len,
88412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
88512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
88612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
88712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
88812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
88912126SHyon.Kim@Sun.COM },
89012126SHyon.Kim@Sun.COM {
89112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_PHY_TEST_FUNCTION,
89212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
89312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_phy_test_function_rq_len,
89412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
89512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
89612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
89712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
89812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
89912126SHyon.Kim@Sun.COM },
90012126SHyon.Kim@Sun.COM {
90112126SHyon.Kim@Sun.COM 	.sfd_function = SMP_FUNC_CONFIG_PHY_EVENT,
90212126SHyon.Kim@Sun.COM 	.sfd_flags = SMP_FD_F_WRITE | SMP_FD_F_NEEDS_CHANGE_COUNT,
90312126SHyon.Kim@Sun.COM 	.sfd_rq_len = sas2_config_phy_event_rq_len,
90412126SHyon.Kim@Sun.COM 	.sfd_rq_dataoff = sas2_rq_dataoff,
90512126SHyon.Kim@Sun.COM 	.sfd_rq_setframe = sas2_rq_setframe,
90612126SHyon.Kim@Sun.COM 	.sfd_rs_datalen = sas2_rs_datalen,
90712126SHyon.Kim@Sun.COM 	.sfd_rs_dataoff = sas2_rs_dataoff,
90812126SHyon.Kim@Sun.COM 	.sfd_rs_getparams = sas2_rs_getparams
90912126SHyon.Kim@Sun.COM },
91012126SHyon.Kim@Sun.COM {
91112126SHyon.Kim@Sun.COM 	.sfd_function = -1
91212126SHyon.Kim@Sun.COM }
91312126SHyon.Kim@Sun.COM };
91412126SHyon.Kim@Sun.COM 
91512126SHyon.Kim@Sun.COM /*
91612126SHyon.Kim@Sun.COM  * Returns the number of bytes in the request frame, including the header
91712126SHyon.Kim@Sun.COM  * and footer, for the given function and capabilities.  Presently the only
91812126SHyon.Kim@Sun.COM  * relevant capability is long-request, which in some cases increases the
91912126SHyon.Kim@Sun.COM  * size of the request from the SAS-1 spec to that found in SAS-2.
92012126SHyon.Kim@Sun.COM  *
92112126SHyon.Kim@Sun.COM  * Variably-sized request frames have no default size; we return 0 in that
92212126SHyon.Kim@Sun.COM  * case, which will often be interpreted by the caller as an error although
92312126SHyon.Kim@Sun.COM  * in general it is not.
92412126SHyon.Kim@Sun.COM  */
92512126SHyon.Kim@Sun.COM size_t
smp_default_request_len(uint_t cap,smp_function_t fn)92612126SHyon.Kim@Sun.COM smp_default_request_len(uint_t cap, smp_function_t fn)
92712126SHyon.Kim@Sun.COM {
92812126SHyon.Kim@Sun.COM 	switch (fn) {
92912126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_GENERAL:
93012126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_MANUFACTURER_INFO:
931*13094Sdavid.hollister@oracle.com 		return (SMP_REQ_MINLEN);
93212126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_ZONE_MANAGER_PASSWORD:
933*13094Sdavid.hollister@oracle.com 		return (SMP_REQ_MINLEN +
934*13094Sdavid.hollister@oracle.com 		    sizeof (smp_report_zone_mgr_password_req_t));
93512126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_SELF_CONFIG_STATUS:
93612126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
93712126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
93812126SHyon.Kim@Sun.COM 			    sizeof (smp_report_self_config_status_req_t));
93912126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
94012126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_ZONE_PERM_TABLE:
94112126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
94212126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
94312126SHyon.Kim@Sun.COM 			    sizeof (smp_report_zone_perm_table_req_t));
94412126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
94512126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_BROADCAST:
94612126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
94712126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
94812126SHyon.Kim@Sun.COM 			    sizeof (smp_report_broadcast_req_t));
94912126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
95012126SHyon.Kim@Sun.COM 	case SMP_FUNC_DISCOVER:
95112126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN + sizeof (smp_discover_req_t));
95212126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_PHY_ERROR_LOG:
95312126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN +
95412126SHyon.Kim@Sun.COM 		    sizeof (smp_report_phy_error_log_req_t));
95512126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_PHY_SATA:
95612126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN + sizeof (smp_report_phy_sata_req_t));
95712126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_ROUTE_INFO:
95812126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN + sizeof (smp_report_route_info_req_t));
95912126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_PHY_EVENT:
96012126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
96112126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
96212126SHyon.Kim@Sun.COM 			    sizeof (smp_report_phy_event_req_t));
96312126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
96412126SHyon.Kim@Sun.COM 	case SMP_FUNC_DISCOVER_LIST:
96512126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
96612126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
96712126SHyon.Kim@Sun.COM 			    sizeof (smp_discover_list_req_t));
96812126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
96912126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_PHY_EVENT_LIST:
97012126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
97112126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
97212126SHyon.Kim@Sun.COM 			    sizeof (smp_report_phy_event_list_req_t));
97312126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
97412126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_EXP_ROUTE_TABLE_LIST:
97512126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
97612126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
97712126SHyon.Kim@Sun.COM 			    sizeof (smp_report_exp_route_table_list_req_t));
97812126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
97912126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_GENERAL:
98012126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
98112126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
98212126SHyon.Kim@Sun.COM 			    sizeof (smp_config_general_req_t));
98312126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
98412126SHyon.Kim@Sun.COM 	case SMP_FUNC_ENABLE_DISABLE_ZONING:
98512126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
98612126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
98712126SHyon.Kim@Sun.COM 			    sizeof (smp_enable_disable_zoning_req_t));
98812126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
98912126SHyon.Kim@Sun.COM 	case SMP_FUNC_ZONE_LOCK:
99012126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
99112126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
99212126SHyon.Kim@Sun.COM 			    sizeof (smp_zone_lock_req_t));
99312126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
99412126SHyon.Kim@Sun.COM 	case SMP_FUNC_ZONE_ACTIVATE:
99512126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
99612126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
99712126SHyon.Kim@Sun.COM 			    sizeof (smp_zone_activate_req_t));
99812126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
99912126SHyon.Kim@Sun.COM 	case SMP_FUNC_ZONE_UNLOCK:
100012126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
100112126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
100212126SHyon.Kim@Sun.COM 			    sizeof (smp_zone_unlock_req_t));
100312126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
100412126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_ZONE_MANAGER_PASSWORD:
100512126SHyon.Kim@Sun.COM 		if (cap & SMP_TARGET_C_LONG_RESP)
100612126SHyon.Kim@Sun.COM 			return (SMP_REQ_MINLEN +
100712126SHyon.Kim@Sun.COM 			    sizeof (smp_config_zone_manager_password_req_t));
100812126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN);
100912126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_ROUTE_INFO:
101012126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN + sizeof (smp_config_route_info_req_t));
101112126SHyon.Kim@Sun.COM 	case SMP_FUNC_PHY_CONTROL:
101212126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN + sizeof (smp_phy_control_req_t));
101312126SHyon.Kim@Sun.COM 	case SMP_FUNC_PHY_TEST_FUNCTION:
101412126SHyon.Kim@Sun.COM 		return (SMP_REQ_MINLEN + sizeof (smp_phy_test_function_req_t));
101512126SHyon.Kim@Sun.COM 
101612126SHyon.Kim@Sun.COM 	case SMP_FUNC_ZONED_BROADCAST:
101712126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_ZONE_PHY_INFO:
101812126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_ZONE_PERM_TABLE:
101912126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_PHY_EVENT:
102012126SHyon.Kim@Sun.COM 	default:
102112126SHyon.Kim@Sun.COM 		return (0);
102212126SHyon.Kim@Sun.COM 	}
102312126SHyon.Kim@Sun.COM }
102412126SHyon.Kim@Sun.COM 
102512126SHyon.Kim@Sun.COM /*
102612126SHyon.Kim@Sun.COM  * This is slightly different - return the length in bytes, including the
102712126SHyon.Kim@Sun.COM  * header and footer, to be assumed for the response frame type if the
102812126SHyon.Kim@Sun.COM  * length field is zero.  Since the length field will not be zero unless the
102912126SHyon.Kim@Sun.COM  * long response bit is clear or the target is buggy, we always assume that
103012126SHyon.Kim@Sun.COM  * the caller wants the size of the v1 frame.
103112126SHyon.Kim@Sun.COM  */
103212126SHyon.Kim@Sun.COM /*ARGSUSED*/
103312126SHyon.Kim@Sun.COM size_t
smp_default_response_len(uint_t cap,smp_function_t fn)103412126SHyon.Kim@Sun.COM smp_default_response_len(uint_t cap, smp_function_t fn)
103512126SHyon.Kim@Sun.COM {
103612126SHyon.Kim@Sun.COM 	switch (fn) {
103712126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_SELF_CONFIG_STATUS:
103812126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_ZONE_PERM_TABLE:
103912126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_BROADCAST:
104012126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_PHY_EVENT:
104112126SHyon.Kim@Sun.COM 	case SMP_FUNC_DISCOVER_LIST:
104212126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_PHY_EVENT_LIST:
104312126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_EXP_ROUTE_TABLE_LIST:
104412126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_GENERAL:
104512126SHyon.Kim@Sun.COM 	case SMP_FUNC_ENABLE_DISABLE_ZONING:
104612126SHyon.Kim@Sun.COM 	case SMP_FUNC_ZONED_BROADCAST:
104712126SHyon.Kim@Sun.COM 	case SMP_FUNC_ZONE_LOCK:
104812126SHyon.Kim@Sun.COM 	case SMP_FUNC_ZONE_ACTIVATE:
104912126SHyon.Kim@Sun.COM 	case SMP_FUNC_ZONE_UNLOCK:
105012126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_ZONE_MANAGER_PASSWORD:
105112126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_ZONE_PHY_INFO:
105212126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_ZONE_PERM_TABLE:
105312126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_ROUTE_INFO:
105412126SHyon.Kim@Sun.COM 	case SMP_FUNC_PHY_CONTROL:
105512126SHyon.Kim@Sun.COM 	case SMP_FUNC_PHY_TEST_FUNCTION:
105612126SHyon.Kim@Sun.COM 	case SMP_FUNC_CONFIG_PHY_EVENT:
105712126SHyon.Kim@Sun.COM 		return (SMP_RESP_MINLEN);
1058*13094Sdavid.hollister@oracle.com 	case SMP_FUNC_REPORT_ZONE_MANAGER_PASSWORD:
1059*13094Sdavid.hollister@oracle.com 		return (SMP_RESP_MINLEN +
1060*13094Sdavid.hollister@oracle.com 		    sizeof (smp_report_zone_mgr_password_resp_t));
106112126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_GENERAL:
106212126SHyon.Kim@Sun.COM 		return (SMP_RESP_MINLEN + 24);
106312126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_MANUFACTURER_INFO:
106412126SHyon.Kim@Sun.COM 		return (SMP_RESP_MINLEN +
106512126SHyon.Kim@Sun.COM 		    sizeof (smp_report_manufacturer_info_resp_t));
106612126SHyon.Kim@Sun.COM 	case SMP_FUNC_DISCOVER:
106712126SHyon.Kim@Sun.COM 		return (SMP_RESP_MINLEN + 48);
106812126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_PHY_ERROR_LOG:
106912126SHyon.Kim@Sun.COM 		return (SMP_RESP_MINLEN +
107012126SHyon.Kim@Sun.COM 		    sizeof (smp_report_phy_error_log_resp_t));
107112126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_PHY_SATA:
107212126SHyon.Kim@Sun.COM 		return (SMP_RESP_MINLEN + 52);
107312126SHyon.Kim@Sun.COM 	case SMP_FUNC_REPORT_ROUTE_INFO:
107412126SHyon.Kim@Sun.COM 		return (SMP_RESP_MINLEN +
107512126SHyon.Kim@Sun.COM 		    sizeof (smp_report_route_info_resp_t));
107612126SHyon.Kim@Sun.COM 
107712126SHyon.Kim@Sun.COM 	default:
107812126SHyon.Kim@Sun.COM 		return (0);
107912126SHyon.Kim@Sun.COM 	}
108012126SHyon.Kim@Sun.COM }
1081