19e86db79SHyon Kim /*
29e86db79SHyon Kim  * CDDL HEADER START
39e86db79SHyon Kim  *
49e86db79SHyon Kim  * The contents of this file are subject to the terms of the
59e86db79SHyon Kim  * Common Development and Distribution License (the "License").
69e86db79SHyon Kim  * You may not use this file except in compliance with the License.
79e86db79SHyon Kim  *
89e86db79SHyon Kim  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99e86db79SHyon Kim  * or http://www.opensolaris.org/os/licensing.
109e86db79SHyon Kim  * See the License for the specific language governing permissions
119e86db79SHyon Kim  * and limitations under the License.
129e86db79SHyon Kim  *
139e86db79SHyon Kim  * When distributing Covered Code, include this CDDL HEADER in each
149e86db79SHyon Kim  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159e86db79SHyon Kim  * If applicable, add the following below this CDDL HEADER, with the
169e86db79SHyon Kim  * fields enclosed by brackets "[]" replaced with your own identifying
179e86db79SHyon Kim  * information: Portions Copyright [yyyy] [name of copyright owner]
189e86db79SHyon Kim  *
199e86db79SHyon Kim  * CDDL HEADER END
209e86db79SHyon Kim  */
219e86db79SHyon Kim 
229e86db79SHyon Kim /*
239e86db79SHyon Kim  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
249e86db79SHyon Kim  * Use is subject to license terms.
259e86db79SHyon Kim  */
26*00f453f4SRob Johnston /*
27*00f453f4SRob Johnston  * Copyright 2019 Joyent, Inc.
28*00f453f4SRob Johnston  */
299e86db79SHyon Kim 
309e86db79SHyon Kim #include    <sun_sas.h>
319e86db79SHyon Kim /*
329e86db79SHyon Kim  * Retrieves the attribues for an adapter
339e86db79SHyon Kim  */
349e86db79SHyon Kim HBA_STATUS
Sun_sasGetAdapterAttributes(HBA_HANDLE handle,PSMHBA_ADAPTERATTRIBUTES attributes)359e86db79SHyon Kim Sun_sasGetAdapterAttributes(HBA_HANDLE handle,
36*00f453f4SRob Johnston     PSMHBA_ADAPTERATTRIBUTES attributes)
37*00f453f4SRob Johnston {
389e86db79SHyon Kim 	const char		ROUTINE[] = "Sun_sasGetAdapterAttributes";
39*00f453f4SRob Johnston 	struct sun_sas_hba	*hba_ptr;
40*00f453f4SRob Johnston 	int			index = 0;
419e86db79SHyon Kim 
429e86db79SHyon Kim 	if (attributes == NULL) {
43*00f453f4SRob Johnston 		log(LOG_DEBUG, ROUTINE, "NULL attributes pointer");
44*00f453f4SRob Johnston 		return (HBA_STATUS_ERROR_ARG);
459e86db79SHyon Kim 	}
469e86db79SHyon Kim 
479e86db79SHyon Kim 	lock(&all_hbas_lock);
489e86db79SHyon Kim 	index = RetrieveIndex(handle);
499e86db79SHyon Kim 	lock(&open_handles_lock);
509e86db79SHyon Kim 	hba_ptr = RetrieveHandle(index);
519e86db79SHyon Kim 	if (hba_ptr == NULL) {
52*00f453f4SRob Johnston 		log(LOG_DEBUG, ROUTINE, "Invalid handle %08lx", handle);
53*00f453f4SRob Johnston 		unlock(&open_handles_lock);
54*00f453f4SRob Johnston 		unlock(&all_hbas_lock);
55*00f453f4SRob Johnston 		return (HBA_STATUS_ERROR_INVALID_HANDLE);
569e86db79SHyon Kim 	}
579e86db79SHyon Kim 
589e86db79SHyon Kim 	(void) memcpy(attributes, &hba_ptr->adapter_attributes,
599e86db79SHyon Kim 	    sizeof (SMHBA_ADAPTERATTRIBUTES));
609e86db79SHyon Kim 
619e86db79SHyon Kim 	unlock(&open_handles_lock);
629e86db79SHyon Kim 	unlock(&all_hbas_lock);
639e86db79SHyon Kim 
649e86db79SHyon Kim 	return (HBA_STATUS_OK);
659e86db79SHyon Kim }
66