xref: /titanic_50/usr/src/uts/common/sys/cmlb.h (revision 06bbe1e05e4f6fd0773ee85a50c0de7adfc4fa06)
13ccda647Slclee /*
23ccda647Slclee  * CDDL HEADER START
33ccda647Slclee  *
43ccda647Slclee  * The contents of this file are subject to the terms of the
5e8fb11a1Sshidokht  * Common Development and Distribution License (the "License").
6e8fb11a1Sshidokht  * You may not use this file except in compliance with the License.
73ccda647Slclee  *
83ccda647Slclee  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93ccda647Slclee  * or http://www.opensolaris.org/os/licensing.
103ccda647Slclee  * See the License for the specific language governing permissions
113ccda647Slclee  * and limitations under the License.
123ccda647Slclee  *
133ccda647Slclee  * When distributing Covered Code, include this CDDL HEADER in each
143ccda647Slclee  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153ccda647Slclee  * If applicable, add the following below this CDDL HEADER, with the
163ccda647Slclee  * fields enclosed by brackets "[]" replaced with your own identifying
173ccda647Slclee  * information: Portions Copyright [yyyy] [name of copyright owner]
183ccda647Slclee  *
193ccda647Slclee  * CDDL HEADER END
203ccda647Slclee  */
213ccda647Slclee /*
22*06bbe1e0Sedp  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
233ccda647Slclee  * Use is subject to license terms.
243ccda647Slclee  */
253ccda647Slclee 
263ccda647Slclee #ifndef _SYS_CMLB_H
273ccda647Slclee #define	_SYS_CMLB_H
283ccda647Slclee 
293ccda647Slclee #pragma ident	"%Z%%M%	%I%	%E% SMI"
303ccda647Slclee 
313ccda647Slclee #ifdef	__cplusplus
323ccda647Slclee extern "C" {
333ccda647Slclee #endif
343ccda647Slclee 
353ccda647Slclee #include <sys/dktp/fdisk.h>
363ccda647Slclee 
373ccda647Slclee /*
383ccda647Slclee  * structure used for getting phygeom and virtgeom from target driver
393ccda647Slclee  */
403ccda647Slclee typedef struct cmlb_geom {
413ccda647Slclee 	unsigned int    g_ncyl;
423ccda647Slclee 	unsigned short  g_acyl;
433ccda647Slclee 	unsigned short  g_nhead;
443ccda647Slclee 	unsigned short  g_nsect;
453ccda647Slclee 	unsigned short  g_secsize;
463ccda647Slclee 	diskaddr_t	g_capacity;
473ccda647Slclee 	unsigned short  g_intrlv;
483ccda647Slclee 	unsigned short  g_rpm;
493ccda647Slclee } cmlb_geom_t;
503ccda647Slclee 
513ccda647Slclee 
523ccda647Slclee typedef struct tg_attribute {
533ccda647Slclee 	int media_is_writable;
543ccda647Slclee } tg_attribute_t;
553ccda647Slclee 
563ccda647Slclee 
573ccda647Slclee 
58e8fb11a1Sshidokht /* bit definitions for alter_behavior passed to cmlb_attach */
593ccda647Slclee 
603ccda647Slclee #define	CMLB_CREATE_ALTSLICE_VTOC_16_DTYPE_DIRECT	0x00000001
613ccda647Slclee #define	CMLB_FAKE_GEOM_LABEL_IOCTLS_VTOC8		0x00000002
62e8fb11a1Sshidokht #define	CMLB_OFF_BY_ONE					0x00000004
63843e1988Sjohnlev #define	CMLB_FAKE_LABEL_ONE_PARTITION			0x00000008
64*06bbe1e0Sedp #define	CMLB_INTERNAL_MINOR_NODES			0x00000010
65e8fb11a1Sshidokht 
66e8fb11a1Sshidokht /* bit definitions of flag passed to cmlb_validate */
67e8fb11a1Sshidokht #define	CMLB_SILENT					0x00000001
68e8fb11a1Sshidokht 
69e8fb11a1Sshidokht /* version for tg_ops */
70e8fb11a1Sshidokht #define	TG_DK_OPS_VERSION_0	0
71e8fb11a1Sshidokht #define	TG_DK_OPS_VERSION_1	1
72e8fb11a1Sshidokht 
73e8fb11a1Sshidokht /* definitions for cmd passed to tg_rdwr */
74e8fb11a1Sshidokht #define	TG_READ			0
75e8fb11a1Sshidokht #define	TG_WRITE		1
76e8fb11a1Sshidokht 
77e8fb11a1Sshidokht /* definitions for cmd passed to tg_getinfo */
78e8fb11a1Sshidokht #define	TG_GETPHYGEOM		1
79e8fb11a1Sshidokht #define	TG_GETVIRTGEOM		2
80e8fb11a1Sshidokht #define	TG_GETCAPACITY		3
81e8fb11a1Sshidokht #define	TG_GETBLOCKSIZE		4
82e8fb11a1Sshidokht #define	TG_GETATTR		5
83e8fb11a1Sshidokht 
843ccda647Slclee 
853ccda647Slclee /*
863ccda647Slclee  * Ops vector including utility functions into target driver that cmlb uses.
873ccda647Slclee  */
883ccda647Slclee typedef struct cmlb_tg_ops {
89e8fb11a1Sshidokht 	int	tg_version;
90e8fb11a1Sshidokht 
913ccda647Slclee 	/*
923ccda647Slclee 	 * tg_rdwr:
933ccda647Slclee 	 *	perform read/write on target device associated with devi.
94e8fb11a1Sshidokht 	 *
953ccda647Slclee 	 * Arguments:
96e8fb11a1Sshidokht 	 *
973ccda647Slclee 	 *	devi:		pointer to device's dev_info structure.
98e8fb11a1Sshidokht 	 *
993ccda647Slclee 	 *	cmd:		operation to perform.
1003ccda647Slclee 	 *			Possible values: TG_READ, TG_WRITE
101e8fb11a1Sshidokht 	 *
1023ccda647Slclee 	 *	bufp:		pointer to allocated buffer for transfer
103e8fb11a1Sshidokht 	 *
1043ccda647Slclee 	 *	start_block:	starting block number to read/write (based on
1053ccda647Slclee 	 *			system blocksize, DEV_BSIZE)
1063ccda647Slclee 	 *
1073ccda647Slclee 	 *	reqlength:	requested transfer length (in bytes)
1083ccda647Slclee 	 *
109e8fb11a1Sshidokht 	 *	tg_cookie 	cookie from target driver to be passed back to
110e8fb11a1Sshidokht 	 *			target driver when we call back to it through
111e8fb11a1Sshidokht 	 *			tg_ops.
112e8fb11a1Sshidokht 	 *
1133ccda647Slclee 	 * Note: It is the responsibility of caller to make sure
1143ccda647Slclee 	 *	length of buffer pointed to by bufp is at least equal to
1153ccda647Slclee 	 *	requested transfer length
1163ccda647Slclee 	 *
1173ccda647Slclee 	 * Return values:
1183ccda647Slclee 	 *	0		success
1193ccda647Slclee 	 *	ENOMEM		can not allocate memory
1203ccda647Slclee 	 *	EACCESS  	reservation conflict
1213ccda647Slclee 	 *	EIO		I/O error
1223ccda647Slclee 	 *	EFAULT		copyin/copyout error
1233ccda647Slclee 	 *	ENXIO		internal error/ invalid devi
1243ccda647Slclee 	 *	EINVAL		invalid command value.
1253ccda647Slclee 	 */
1263ccda647Slclee 	int (*tg_rdwr)(dev_info_t *devi, uchar_t cmd, void *bufp,
127e8fb11a1Sshidokht 	    diskaddr_t start_block, size_t reqlength, void *tg_cookie);
1283ccda647Slclee 
1293ccda647Slclee 	/*
130e8fb11a1Sshidokht 	 * tg_getinfo:
1313ccda647Slclee 	 * 	Report the information requested on device/media and
132e8fb11a1Sshidokht 	 *	store the requested info in area pointed to by arg.
1333ccda647Slclee 	 *
1343ccda647Slclee 	 * Arguments:
1353ccda647Slclee 	 *	devi:		pointer to device's dev_info structure.
136e8fb11a1Sshidokht 	 *
137e8fb11a1Sshidokht 	 *	cmd:		operation to perform
138e8fb11a1Sshidokht 	 *
139e8fb11a1Sshidokht 	 *	arg:		arg for the operation for result.
140e8fb11a1Sshidokht 	 *
141e8fb11a1Sshidokht 	 *	tg_cookie 	cookie from target driver to be passed back to
142e8fb11a1Sshidokht 	 *			target driver when we call back to it through
143e8fb11a1Sshidokht 	 *			tg_ops.
144e8fb11a1Sshidokht 	 *
145e8fb11a1Sshidokht 	 * 	Possible commands and the interpretation of arg:
146e8fb11a1Sshidokht 	 *
147e8fb11a1Sshidokht 	 *	cmd:
148e8fb11a1Sshidokht 	 *		TG_GETPHYGEOM
149e8fb11a1Sshidokht 	 *			Obtain raw physical geometry from target,
150e8fb11a1Sshidokht 	 *			and store in structure pointed to by arg,
151e8fb11a1Sshidokht 	 *			a cmlb_geom_t structure.
152e8fb11a1Sshidokht 	 *
153e8fb11a1Sshidokht 	 * 		TG_GETVIRTGEOM:
154e8fb11a1Sshidokht 	 *			Obtain HBA geometry for the target and
155e8fb11a1Sshidokht 	 *			store in struct pointed to by arg,
156e8fb11a1Sshidokht 	 *			a cmlb_geom_t structure.
157e8fb11a1Sshidokht 	 *
158e8fb11a1Sshidokht 	 *		TG_GETCAPACITY:
159e8fb11a1Sshidokht 	 *			Report the capacity of the target (in system
160e8fb11a1Sshidokht 	 *			blocksize (DEV_BSIZE) and store in the
161e8fb11a1Sshidokht 	 *			space pointed to by arg, a diskaddr_t.
162e8fb11a1Sshidokht 	 *
163e8fb11a1Sshidokht 	 *		TG_GETBLOCKSIZE:
164e8fb11a1Sshidokht 	 *			Report the block size of the target
165e8fb11a1Sshidokht 	 *			in the space pointed to by arg, a uint32_t.
166e8fb11a1Sshidokht 	 *
167e8fb11a1Sshidokht 	 *		TG_GETATTR:
168e8fb11a1Sshidokht 	 * 			Report the information requested on
169e8fb11a1Sshidokht 	 *			device/media and store in area pointed to by
170e8fb11a1Sshidokht 	 *			arg, a tg_attribute_t structure.
171e8fb11a1Sshidokht 	 *			Return values:
1723ccda647Slclee 	 *
1733ccda647Slclee 	 * Return values:
1743ccda647Slclee 	 *	0		success
175e8fb11a1Sshidokht 	 *
1763ccda647Slclee 	 *	EACCESS		reservation conflict
1773ccda647Slclee 	 *
1783ccda647Slclee 	 *	ENXIO		internal error/invalid devi
179e8fb11a1Sshidokht 	 *
180e8fb11a1Sshidokht 	 *	EINVAL		When command is TG_GETPHYGEOM or
181e8fb11a1Sshidokht 	 *			TG_GETVIRTGEOM, or TG_GETATTR, this return code
182e8fb11a1Sshidokht 	 *			indicates the operation is not applicable to
183e8fb11a1Sshidokht 	 *			target.
184e8fb11a1Sshidokht 	 *			In case of TG_GETCAP, this return code
185e8fb11a1Sshidokht 	 *			indicates no media in the drive.
186e8fb11a1Sshidokht 	 *
187e8fb11a1Sshidokht 	 *	EIO		An error occured during obtaining info
188e8fb11a1Sshidokht 	 *			from device/media.
189e8fb11a1Sshidokht 	 *
190e8fb11a1Sshidokht 	 *	ENOTSUP		In case of TG_GETCAP, target does not
191e8fb11a1Sshidokht 	 *			support getting capacity info.
192e8fb11a1Sshidokht 	 *
193e8fb11a1Sshidokht 	 *	ENOTTY		Unknown command.
194e8fb11a1Sshidokht 	 *
195e8fb11a1Sshidokht 	 *
1963ccda647Slclee 	 */
197e8fb11a1Sshidokht 	int (*tg_getinfo)(dev_info_t *devi, int cmd, void *arg,
198e8fb11a1Sshidokht 	    void *tg_cookie);
199e8fb11a1Sshidokht 
2003ccda647Slclee } cmlb_tg_ops_t;
2013ccda647Slclee 
2023ccda647Slclee 
2033ccda647Slclee typedef struct __cmlb_handle *cmlb_handle_t;
2043ccda647Slclee 
2053ccda647Slclee /*
2063ccda647Slclee  *
2073ccda647Slclee  * Functions exported from cmlb
2083ccda647Slclee  *
2093ccda647Slclee  * Note: Most these functions can callback to target driver through the
2103ccda647Slclee  * tg_ops functions. Target driver should consider this for synchronization.
2113ccda647Slclee  * Any functions that may adjust minor nodes should be called when
2123ccda647Slclee  * the target driver ensures it is safe to do so.
2133ccda647Slclee  */
2143ccda647Slclee 
2153ccda647Slclee /*
2163ccda647Slclee  * cmlb_alloc_handle:
2173ccda647Slclee  *
2183ccda647Slclee  *	Allocates a handle.
2193ccda647Slclee  *
2203ccda647Slclee  * Arguments:
2213ccda647Slclee  *	cmlbhandlep	pointer to handle
2223ccda647Slclee  *
2233ccda647Slclee  * Notes:
2243ccda647Slclee  *	Allocates a handle and stores the allocated handle in the area
2253ccda647Slclee  *	pointed to by cmlbhandlep
2263ccda647Slclee  *
2273ccda647Slclee  * Context:
2283ccda647Slclee  *	Kernel thread only (can sleep).
2293ccda647Slclee  */
2303ccda647Slclee void
2313ccda647Slclee cmlb_alloc_handle(cmlb_handle_t *cmlbhandlep);
2323ccda647Slclee 
2333ccda647Slclee 
2343ccda647Slclee /*
2353ccda647Slclee  * cmlb_attach:
2363ccda647Slclee  *
2373ccda647Slclee  *	Attach handle to device, create minor nodes for device.
2383ccda647Slclee  *
2393ccda647Slclee  *
2403ccda647Slclee  * Arguments:
2413ccda647Slclee  * 	devi		pointer to device's dev_info structure.
2423ccda647Slclee  * 	tgopsp		pointer to array of functions cmlb can use to callback
2433ccda647Slclee  *			to target driver.
2443ccda647Slclee  *
2453ccda647Slclee  *	device_type	Peripheral device type as defined in
2463ccda647Slclee  *			scsi/generic/inquiry.h
2473ccda647Slclee  *
2483ccda647Slclee  *	is_removable	whether or not device is removable.
2493ccda647Slclee  *			0 non-removable, 1 removable.
2503ccda647Slclee  *
251e8fb11a1Sshidokht  *	is_hotpluggable	whether or not device is hotpluggable.
252e8fb11a1Sshidokht  *			0 non-hotpluggable, 1 hotpluggable.
253e8fb11a1Sshidokht  *
2543ccda647Slclee  *	node_type	minor node type (as used by ddi_create_minor_node)
2553ccda647Slclee  *
2563ccda647Slclee  *	alter_behavior
2573ccda647Slclee  *			bit flags:
2583ccda647Slclee  *
2593ccda647Slclee  *			CMLB_CREATE_ALTSLICE_VTOC_16_DTYPE_DIRECT: create
2603ccda647Slclee  *			an alternate slice for the default label, if
2613ccda647Slclee  *			device type is DTYPE_DIRECT an architectures default
2623ccda647Slclee  *			label type is VTOC16.
2633ccda647Slclee  *			Otherwise alternate slice will no be created.
2643ccda647Slclee  *
2653ccda647Slclee  *
2663ccda647Slclee  *			CMLB_FAKE_GEOM_LABEL_IOCTLS_VTOC8: report a default
2673ccda647Slclee  *			geometry and label for DKIOCGGEOM and DKIOCGVTOC
2683ccda647Slclee  *			on architecture with VTOC 8 label types.
2693ccda647Slclee  *
270e8fb11a1Sshidokht  * 			CMLB_OFF_BY_ONE: do the workaround for legacy off-by-
271e8fb11a1Sshidokht  *			one bug in obtaining capacity (used for sd).
272e8fb11a1Sshidokht  *
2733ccda647Slclee  *
2743ccda647Slclee  *	cmlbhandle	cmlb handle associated with device
2753ccda647Slclee  *
276e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
277e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
278e8fb11a1Sshidokht  *
279e8fb11a1Sshidokht  *			cmlb does not interpret the values. It is currently
280e8fb11a1Sshidokht  *			used for sd to indicate whether retries are allowed
281e8fb11a1Sshidokht  *			on commands or not. e.g when cmlb entries are called
282e8fb11a1Sshidokht  *			from interrupt context on removable media, sd rather
283e8fb11a1Sshidokht  *			not have retries done.
284e8fb11a1Sshidokht  *
285e8fb11a1Sshidokht  *
286e8fb11a1Sshidokht  *
2873ccda647Slclee  * Notes:
2883ccda647Slclee  *	Assumes a default label based on capacity for non-removable devices.
2893ccda647Slclee  *	If capacity > 1TB, EFI is assumed otherwise VTOC (default VTOC
2903ccda647Slclee  *	for the architecture).
2913ccda647Slclee  *	For removable devices, default label type is assumed to be VTOC
2923ccda647Slclee  *	type. Create minor nodes based on a default label type.
2933ccda647Slclee  *	Label on the media is not validated.
2943ccda647Slclee  *	minor number consists of:
2953ccda647Slclee  *		if _SUNOS_VTOC_8 is defined
2963ccda647Slclee  *			lowest 3 bits is taken as partition number
2973ccda647Slclee  *			the rest is instance number
2983ccda647Slclee  *		if _SUNOS_VTOC_16 is defined
2993ccda647Slclee  *			lowest 6 bits is taken as partition number
3003ccda647Slclee  *			the rest is instance number
3013ccda647Slclee  *
3023ccda647Slclee  *
3033ccda647Slclee  * Return values:
3043ccda647Slclee  *	0 	Success
3053ccda647Slclee  * 	ENXIO 	creating minor nodes failed.
306e8fb11a1Sshidokht  *	EINVAL	invalid arg, unsupported tg_ops version
3073ccda647Slclee  *
3083ccda647Slclee  */
3093ccda647Slclee int
3103ccda647Slclee cmlb_attach(dev_info_t *devi, cmlb_tg_ops_t *tgopsp, int device_type,
311e8fb11a1Sshidokht     int is_removable, int is_hotpluggable, char *node_type,
312e8fb11a1Sshidokht     int alter_behavior, cmlb_handle_t cmlbhandle, void *tg_cookie);
3133ccda647Slclee 
3143ccda647Slclee 
3153ccda647Slclee /*
3163ccda647Slclee  * cmlb_validate:
3173ccda647Slclee  *
3183ccda647Slclee  *	Validates label.
3193ccda647Slclee  *
3203ccda647Slclee  * Arguments
3213ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
3223ccda647Slclee  *
323e8fb11a1Sshidokht  * 	int 		flags
324e8fb11a1Sshidokht  *			currently used for verbosity control.
325e8fb11a1Sshidokht  *			CMLB_SILENT is the only current definition for it
326e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
327e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
3283ccda647Slclee  * Notes:
3293ccda647Slclee  *	If new label type is different from the current, adjust minor nodes
3303ccda647Slclee  *	accordingly.
3313ccda647Slclee  *
3323ccda647Slclee  * Return values:
3333ccda647Slclee  *	0		success
3343ccda647Slclee  *			Note: having fdisk but no solaris partition is assumed
3353ccda647Slclee  *			success.
3363ccda647Slclee  *
3373ccda647Slclee  *	ENOMEM		memory allocation failed
3383ccda647Slclee  *	EIO		i/o errors during read or get capacity
3393ccda647Slclee  * 	EACCESS		reservation conflicts
3403ccda647Slclee  * 	EINVAL		label was corrupt, or no default label was assumed
3413ccda647Slclee  *	ENXIO		invalid handle
3423ccda647Slclee  *
3433ccda647Slclee  */
3443ccda647Slclee int
345e8fb11a1Sshidokht cmlb_validate(cmlb_handle_t cmlbhandle, int flags, void *tg_cookie);
3463ccda647Slclee 
3473ccda647Slclee /*
3483ccda647Slclee  * cmlb_invalidate:
3493ccda647Slclee  *	Invalidate in core label data
3503ccda647Slclee  *
3513ccda647Slclee  * Arguments:
3523ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
353e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
354e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
3553ccda647Slclee  */
3563ccda647Slclee void
357e8fb11a1Sshidokht cmlb_invalidate(cmlb_handle_t cmlbhandle, void *tg_cookie);
3583ccda647Slclee 
3593ccda647Slclee 
360e8fb11a1Sshidokht 
361e8fb11a1Sshidokht /*
362e8fb11a1Sshidokht  * cmlb_is_valid
363e8fb11a1Sshidokht  *	 Get status on whether the incore label/geom data is valid
364e8fb11a1Sshidokht  *
365e8fb11a1Sshidokht  * Arguments:
366e8fb11a1Sshidokht  *      cmlbhandle      cmlb handle associated with device.
367e8fb11a1Sshidokht  *
368e8fb11a1Sshidokht  * Return values:
369e8fb11a1Sshidokht  *      TRUE if valid
370e8fb11a1Sshidokht  *      FALSE otherwise.
371e8fb11a1Sshidokht  *
372e8fb11a1Sshidokht  */
373e8fb11a1Sshidokht int
374e8fb11a1Sshidokht cmlb_is_valid(cmlb_handle_t cmlbhandle);
375e8fb11a1Sshidokht 
3763ccda647Slclee /*
3773ccda647Slclee  * cmlb_partinfo:
3783ccda647Slclee  *	Get partition info for specified partition number.
3793ccda647Slclee  *
3803ccda647Slclee  * Arguments:
3813ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
3823ccda647Slclee  *	part		partition number
383e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
3843ccda647Slclee  *	nblocksp	pointer to number of blocks
3853ccda647Slclee  *	startblockp	pointer to starting block
3863ccda647Slclee  *	partnamep	pointer to name of partition
3873ccda647Slclee  *	tagp		pointer to tag info
388e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
3893ccda647Slclee  *
3903ccda647Slclee  * Notes:
3913ccda647Slclee  *	If in-core label is not valid, this functions tries to revalidate
3923ccda647Slclee  *	the label. If label is valid, it stores the total number of blocks
3933ccda647Slclee  *	in this partition in the area pointed to by nblocksp, starting
3943ccda647Slclee  *	block number in area pointed to by startblockp,  pointer to partition
3953ccda647Slclee  *	name in area pointed to by partnamep, and tag value in area
3963ccda647Slclee  *	pointed by tagp.
3973ccda647Slclee  *	For EFI labels, tag value will be set to 0.
3983ccda647Slclee  *
3993ccda647Slclee  *	For all nblocksp, startblockp and partnamep, tagp, a value of NULL
4003ccda647Slclee  *	indicates the corresponding info is not requested.
4013ccda647Slclee  *
4023ccda647Slclee  *
4033ccda647Slclee  * Return values:
4043ccda647Slclee  *	0	success
4053ccda647Slclee  *	EINVAL  no valid label or requested partition number is invalid.
4063ccda647Slclee  *
4073ccda647Slclee  */
4083ccda647Slclee int
4093ccda647Slclee cmlb_partinfo(cmlb_handle_t cmlbhandle, int part, diskaddr_t *nblocksp,
410e8fb11a1Sshidokht     diskaddr_t *startblockp, char **partnamep, uint16_t *tagp, void *tg_cookie);
4113ccda647Slclee 
4123ccda647Slclee 
4133ccda647Slclee /*
4143ccda647Slclee  * cmlb_ioctl:
4153ccda647Slclee  * Ioctls for label handling will be handled by this function.
4163ccda647Slclee  * These are:
4173ccda647Slclee  *	DKIOCGGEOM
4183ccda647Slclee  *	DKIOCSGEOM
4193ccda647Slclee  *	DKIOCGAPART
4203ccda647Slclee  *	DKIOCSAPART
4213ccda647Slclee  *	DKIOCGVTOC
4223ccda647Slclee  *	DKIOCGETEFI
4233ccda647Slclee  *	DKIOCPARTITION
4243ccda647Slclee  *	DKIOCSVTOC
4253ccda647Slclee  * 	DKIOCSETEFI
4263ccda647Slclee  *	DKIOCGMBOOT
4273ccda647Slclee  *	DKIOCSMBOOT
4283ccda647Slclee  *	DKIOCG_PHYGEOM
4293ccda647Slclee  *	DKIOCG_VIRTGEOM
4303ccda647Slclee  *	DKIOCPARTINFO
4313ccda647Slclee  *
4323ccda647Slclee  *
4333ccda647Slclee  *   Arguments:
4343ccda647Slclee  *	cmlbhandle 	handle associated with device.
4353ccda647Slclee  *      cmd     	ioctl operation to be performed
4363ccda647Slclee  *      arg     	user argument, contains data to be set or reference
4373ccda647Slclee  *                      parameter for get
4383ccda647Slclee  *	flag    	bit flag, indicating open settings, 32/64 bit type
4393ccda647Slclee  *      cred_p  	user credential pointer (not currently used)
4403ccda647Slclee  *	rval_p  	not currently used
441e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
442e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
443e8fb11a1Sshidokht  *
4443ccda647Slclee  *
4453ccda647Slclee  *
4463ccda647Slclee  * Return values:
4473ccda647Slclee  *	0
4483ccda647Slclee  *	EINVAL
4493ccda647Slclee  *	ENOTTY
4503ccda647Slclee  *	ENXIO
4513ccda647Slclee  *	EIO
4523ccda647Slclee  *	EFAULT
4533ccda647Slclee  *	ENOTSUP
4543ccda647Slclee  *	EPERM
4553ccda647Slclee  */
4563ccda647Slclee int
457e8fb11a1Sshidokht cmlb_ioctl(cmlb_handle_t cmlbhandle, dev_t dev, int cmd,
458e8fb11a1Sshidokht     intptr_t arg, int flag, cred_t *cred_p, int *rval_p, void *tg_cookie);
4593ccda647Slclee 
4603ccda647Slclee /*
4613ccda647Slclee  * cmlb_get_devid_block:
4623ccda647Slclee  *	 get the block number where device id is stored.
4633ccda647Slclee  *
4643ccda647Slclee  * Arguments:
4653ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
4663ccda647Slclee  *	devidblockp	pointer to block number.
467e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
468e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
4693ccda647Slclee  *
4703ccda647Slclee  * Notes:
4713ccda647Slclee  *	It stores the block number of device id in the area pointed to
4723ccda647Slclee  *	by devidblockp.
4733ccda647Slclee  *
4743ccda647Slclee  * Return values:
4753ccda647Slclee  *	0	success
4763ccda647Slclee  *	EINVAL 	device id does not apply to current label type.
4773ccda647Slclee  */
4783ccda647Slclee int
479e8fb11a1Sshidokht cmlb_get_devid_block(cmlb_handle_t cmlbhandle, diskaddr_t *devidblockp,
480e8fb11a1Sshidokht     void *tg_cookie);
4813ccda647Slclee 
4823ccda647Slclee 
4833ccda647Slclee /*
4843ccda647Slclee  * cmlb_close:
4853ccda647Slclee  *
4863ccda647Slclee  * Close the device, revert to a default label minor node for the device,
4873ccda647Slclee  * if it is removable.
4883ccda647Slclee  *
4893ccda647Slclee  * Arguments:
4903ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
4913ccda647Slclee  *
492e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
493e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
4943ccda647Slclee  * Return values:
4953ccda647Slclee  *	0	Success
4963ccda647Slclee  * 	ENXIO	Re-creating minor node failed.
4973ccda647Slclee  */
4983ccda647Slclee int
499e8fb11a1Sshidokht cmlb_close(cmlb_handle_t cmlbhandle, void *tg_cookie);
5003ccda647Slclee 
5013ccda647Slclee /*
5023ccda647Slclee  * cmlb_detach:
5033ccda647Slclee  *
5043ccda647Slclee  * Invalidate in-core labeling data and remove all minor nodes for
5053ccda647Slclee  * the device associate with handle.
5063ccda647Slclee  *
5073ccda647Slclee  * Arguments:
5083ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
509e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
510e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
5113ccda647Slclee  *
5123ccda647Slclee  */
5133ccda647Slclee void
514e8fb11a1Sshidokht cmlb_detach(cmlb_handle_t cmlbhandle, void *tg_cookie);
5153ccda647Slclee 
5163ccda647Slclee /*
5173ccda647Slclee  * cmlb_free_handle
5183ccda647Slclee  *
5193ccda647Slclee  *	Frees handle.
5203ccda647Slclee  *
5213ccda647Slclee  * Arguments:
5223ccda647Slclee  *	cmlbhandlep	pointer to handle
5233ccda647Slclee  *
5243ccda647Slclee  */
5253ccda647Slclee void
5263ccda647Slclee cmlb_free_handle(cmlb_handle_t *cmlbhandlep);
5273ccda647Slclee 
5283ccda647Slclee #ifdef	__cplusplus
5293ccda647Slclee }
5303ccda647Slclee #endif
5313ccda647Slclee 
5323ccda647Slclee #endif /* _SYS_CMLB_H */
533