xref: /freebsd-src/sys/contrib/openzfs/lib/libspl/include/sys/mhd.h (revision 271171e0d97b88ba2a7c3bf750c9672b484c1c13)
1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License, Version 1.0 only
6eda14cbcSMatt Macy  * (the "License").  You may not use this file except in compliance
7eda14cbcSMatt Macy  * with the License.
8eda14cbcSMatt Macy  *
9eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*271171e0SMartin Matuska  * or https://opensource.org/licenses/CDDL-1.0.
11eda14cbcSMatt Macy  * See the License for the specific language governing permissions
12eda14cbcSMatt Macy  * and limitations under the License.
13eda14cbcSMatt Macy  *
14eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
15eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
17eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
18eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
19eda14cbcSMatt Macy  *
20eda14cbcSMatt Macy  * CDDL HEADER END
21eda14cbcSMatt Macy  */
22eda14cbcSMatt Macy /*
23eda14cbcSMatt Macy  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24eda14cbcSMatt Macy  * Use is subject to license terms.
25eda14cbcSMatt Macy  */
26eda14cbcSMatt Macy 
27eda14cbcSMatt Macy #ifndef _SYS_MHD_H
28eda14cbcSMatt Macy #define	_SYS_MHD_H
29eda14cbcSMatt Macy 
30eda14cbcSMatt Macy #ifdef __cplusplus
31eda14cbcSMatt Macy extern "C" {
32eda14cbcSMatt Macy #endif
33eda14cbcSMatt Macy 
34eda14cbcSMatt Macy /*
35eda14cbcSMatt Macy  * Definitions for multi-host device I/O control commands
36eda14cbcSMatt Macy  */
37eda14cbcSMatt Macy #define	MHIOC				('M'<<8)
38eda14cbcSMatt Macy #define	MHIOCENFAILFAST			(MHIOC|1)
39eda14cbcSMatt Macy #define	MHIOCTKOWN			(MHIOC|2)
40eda14cbcSMatt Macy #define	MHIOCRELEASE			(MHIOC|3)
41eda14cbcSMatt Macy #define	MHIOCSTATUS			(MHIOC|4)
42eda14cbcSMatt Macy #define	MHIOCGRP_INKEYS 		(MHIOC|5)
43eda14cbcSMatt Macy #define	MHIOCGRP_INRESV 		(MHIOC|6)
44eda14cbcSMatt Macy #define	MHIOCGRP_REGISTER		(MHIOC|7)
45eda14cbcSMatt Macy #define	MHIOCGRP_RESERVE		(MHIOC|8)
46eda14cbcSMatt Macy #define	MHIOCGRP_PREEMPTANDABORT	(MHIOC|9)
47eda14cbcSMatt Macy #define	MHIOCGRP_PREEMPT		(MHIOC|10)
48eda14cbcSMatt Macy #define	MHIOCGRP_CLEAR			(MHIOC|11)
49eda14cbcSMatt Macy #define	MHIOCGRP_REGISTERANDIGNOREKEY	(MHIOC|14)
50eda14cbcSMatt Macy #define	MHIOCQRESERVE			(MHIOC|12)
51eda14cbcSMatt Macy #define	MHIOCREREGISTERDEVID		(MHIOC|13)
52eda14cbcSMatt Macy 
53eda14cbcSMatt Macy /*
54eda14cbcSMatt Macy  * Following is the structure to specify the delay parameters in
55eda14cbcSMatt Macy  * milliseconds, via the MHIOCTKOWN ioctl.
56eda14cbcSMatt Macy  */
57eda14cbcSMatt Macy struct mhioctkown {
58eda14cbcSMatt Macy 	int reinstate_resv_delay;
59eda14cbcSMatt Macy 	int min_ownership_delay;
60eda14cbcSMatt Macy 	int max_ownership_delay;
61eda14cbcSMatt Macy };
62eda14cbcSMatt Macy 
63eda14cbcSMatt Macy #define	MHIOC_RESV_KEY_SIZE	8
64eda14cbcSMatt Macy typedef struct mhioc_resv_key {
65eda14cbcSMatt Macy 	uchar_t	key[MHIOC_RESV_KEY_SIZE];
66eda14cbcSMatt Macy } mhioc_resv_key_t;
67eda14cbcSMatt Macy 
68eda14cbcSMatt Macy typedef struct mhioc_key_list {
69eda14cbcSMatt Macy 	uint32_t		listsize;
70eda14cbcSMatt Macy 	uint32_t		listlen;
71eda14cbcSMatt Macy 	mhioc_resv_key_t	*list;
72eda14cbcSMatt Macy } mhioc_key_list_t;
73eda14cbcSMatt Macy 
74eda14cbcSMatt Macy typedef struct mhioc_inkeys {
75eda14cbcSMatt Macy 	uint32_t		generation;
76eda14cbcSMatt Macy 	mhioc_key_list_t	*li;
77eda14cbcSMatt Macy } mhioc_inkeys_t;
78eda14cbcSMatt Macy 
79eda14cbcSMatt Macy #if defined(_SYSCALL32)
80eda14cbcSMatt Macy struct mhioc_key_list32 {
81eda14cbcSMatt Macy 	uint32_t		listsize;
82eda14cbcSMatt Macy 	uint32_t		listlen;
83eda14cbcSMatt Macy 	caddr32_t		list;
84eda14cbcSMatt Macy } mhioc_key_list32_t;
85eda14cbcSMatt Macy 
86eda14cbcSMatt Macy struct mhioc_inkeys32 {
87eda14cbcSMatt Macy 	uint32_t		generation;
88eda14cbcSMatt Macy 	caddr32_t		li;
89eda14cbcSMatt Macy } mhioc_inkeys32_t;
90eda14cbcSMatt Macy #endif
91eda14cbcSMatt Macy 
92eda14cbcSMatt Macy typedef struct mhioc_resv_desc {
93eda14cbcSMatt Macy 	mhioc_resv_key_t	key;
94eda14cbcSMatt Macy 	uint8_t			type;
95eda14cbcSMatt Macy 	uint8_t			scope;
96eda14cbcSMatt Macy 	uint32_t		scope_specific_addr;
97eda14cbcSMatt Macy } mhioc_resv_desc_t;
98eda14cbcSMatt Macy 
99eda14cbcSMatt Macy typedef struct mhioc_resv_desc_list {
100eda14cbcSMatt Macy 	uint32_t		listsize;
101eda14cbcSMatt Macy 	uint32_t		listlen;
102eda14cbcSMatt Macy 	mhioc_resv_desc_t	*list;
103eda14cbcSMatt Macy } mhioc_resv_desc_list_t;
104eda14cbcSMatt Macy 
105eda14cbcSMatt Macy typedef struct mhioc_inresvs {
106eda14cbcSMatt Macy 	uint32_t		generation;
107eda14cbcSMatt Macy 	mhioc_resv_desc_list_t	*li;
108eda14cbcSMatt Macy } mhioc_inresvs_t;
109eda14cbcSMatt Macy 
110eda14cbcSMatt Macy #if defined(_SYSCALL32)
111eda14cbcSMatt Macy struct mhioc_resv_desc_list32 {
112eda14cbcSMatt Macy 	uint32_t		listsize;
113eda14cbcSMatt Macy 	uint32_t		listlen;
114eda14cbcSMatt Macy 	caddr32_t		list;
115eda14cbcSMatt Macy } mhioc_resv_desc_list32_t;
116eda14cbcSMatt Macy 
117eda14cbcSMatt Macy typedef struct mhioc_inresvs32 {
118eda14cbcSMatt Macy 	uint32_t		generation;
119eda14cbcSMatt Macy 	caddr32_t		li;
120eda14cbcSMatt Macy } mhioc_inresvs32_t;
121eda14cbcSMatt Macy #endif
122eda14cbcSMatt Macy 
123eda14cbcSMatt Macy typedef struct mhioc_register {
124eda14cbcSMatt Macy     mhioc_resv_key_t	oldkey;
125eda14cbcSMatt Macy     mhioc_resv_key_t	newkey;
126eda14cbcSMatt Macy     boolean_t		aptpl;  /* True if persistent across power failures */
127eda14cbcSMatt Macy } mhioc_register_t;
128eda14cbcSMatt Macy 
129eda14cbcSMatt Macy typedef struct mhioc_preemptandabort {
130eda14cbcSMatt Macy     mhioc_resv_desc_t	resvdesc;
131eda14cbcSMatt Macy     mhioc_resv_key_t	victim_key;
132eda14cbcSMatt Macy } mhioc_preemptandabort_t;
133eda14cbcSMatt Macy 
134eda14cbcSMatt Macy typedef struct mhioc_registerandignorekey {
135eda14cbcSMatt Macy     mhioc_resv_key_t	newkey;
136eda14cbcSMatt Macy     boolean_t		aptpl;  /* True if persistent across power failures */
137eda14cbcSMatt Macy } mhioc_registerandignorekey_t;
138eda14cbcSMatt Macy 
139eda14cbcSMatt Macy /*
140eda14cbcSMatt Macy  * SCSI-3 PGR Reservation Type Codes.  Codes with the _OBSOLETE suffix
141eda14cbcSMatt Macy  * have been removed from the SCSI3 PGR standard.
142eda14cbcSMatt Macy  */
143eda14cbcSMatt Macy #define	SCSI3_RESV_READSHARED_OBSOLETE			0
144eda14cbcSMatt Macy #define	SCSI3_RESV_WRITEEXCLUSIVE			1
145eda14cbcSMatt Macy #define	SCSI3_RESV_READEXCLUSIVE_OBSOLETE		2
146eda14cbcSMatt Macy #define	SCSI3_RESV_EXCLUSIVEACCESS			3
147eda14cbcSMatt Macy #define	SCSI3_RESV_SHAREDACCESS_OBSOLETE		4
148eda14cbcSMatt Macy #define	SCSI3_RESV_WRITEEXCLUSIVEREGISTRANTSONLY	5
149eda14cbcSMatt Macy #define	SCSI3_RESV_EXCLUSIVEACCESSREGISTRANTSONLY	6
150eda14cbcSMatt Macy 
151eda14cbcSMatt Macy #define	SCSI3_SCOPE_LOGICALUNIT				0
152eda14cbcSMatt Macy #define	SCSI3_SCOPE_EXTENT_OBSOLETE			1
153eda14cbcSMatt Macy #define	SCSI3_SCOPE_ELEMENT				2
154eda14cbcSMatt Macy 
155eda14cbcSMatt Macy #ifdef __cplusplus
156eda14cbcSMatt Macy }
157eda14cbcSMatt Macy #endif
158eda14cbcSMatt Macy 
159eda14cbcSMatt Macy #endif	/* _SYS_MHD_H */
160