xref: /illumos-gate/usr/src/uts/common/io/scsi/impl/scsi_capabilities.c (revision 1a220b56b93ff1dc80855691548503117af4cc10)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  *
30  * Generic Capabilities Routines
31  *
32  */
33 
34 #include <sys/scsi/scsi.h>
35 
36 #define	A_TO_TRAN(ap)	(ap->a_hba_tran)
37 
38 int
39 scsi_ifgetcap(struct scsi_address *ap, char *cap, int whom)
40 {
41 	return (*A_TO_TRAN(ap)->tran_getcap)(ap, cap, whom);
42 }
43 
44 int
45 scsi_ifsetcap(struct scsi_address *ap, char *cap, int value, int whom)
46 {
47 	int rval;
48 	int cidx;
49 
50 	rval = (*A_TO_TRAN(ap)->tran_setcap)(ap, cap, value, whom);
51 	if (rval == 0) {
52 		cidx = scsi_hba_lookup_capstr(cap);
53 		if (cidx == SCSI_CAP_SECTOR_SIZE) {
54 			/*
55 			 * if we have successfully changed the
56 			 * granularity update SCSA's copy
57 			 */
58 			A_TO_TRAN(ap)->tran_dma_attr.dma_attr_granular =
59 				value;
60 		}
61 	}
62 	return (rval);
63 }
64