3 #ifndef MPATH_PERSIST_LIB_H
4 #define MPATH_PERSIST_LIB_H
13 #define MPATH_MAX_PARAM_LEN 8192
15 #define MPATH_MX_TIDS 32 /* Max number of transport ids"*/
16 #define MPATH_MX_TID_LEN 256 /* Max length of transport id */
18 /* PRIN Service Actions */
19 #define MPATH_PRIN_RKEY_SA 0x00 /* READ KEYS SA*/
20 #define MPATH_PRIN_RRES_SA 0x01 /* READ RESERVATION SA*/
21 #define MPATH_PRIN_RCAP_SA 0x02 /* REPORT CAPABILITIES SA*/
22 #define MPATH_PRIN_RFSTAT_SA 0x03 /* READ FULL STATUS SA*/
24 /* PROUT Service Actions */
25 #define MPATH_PROUT_REG_SA 0x00 /* REGISTER SA */
26 #define MPATH_PROUT_RES_SA 0x01 /* RESERVE SA*/
27 #define MPATH_PROUT_REL_SA 0x02 /* RELEASE SA*/
28 #define MPATH_PROUT_CLEAR_SA 0x03 /* CLEAR SA*/
29 #define MPATH_PROUT_PREE_SA 0x04 /* PREEMPT SA*/
30 #define MPATH_PROUT_PREE_AB_SA 0x05 /* PREEMPT AND ABORT SA*/
31 #define MPATH_PROUT_REG_IGN_SA 0x06 /* REGISTER AND IGNORE EXISTING KEY SA*/
32 #define MPATH_PROUT_REG_MOV_SA 0x07 /* REGISTER AND MOVE SA*/
34 #define MPATH_LU_SCOPE 0x00 /* LU_SCOPE */
36 /* Persistent reservations type */
37 #define MPATH_PRTPE_WE 0x01 /* Write Exclusive */
38 #define MPATH_PRTPE_EA 0x03 /* Exclusive Access*/
39 #define MPATH_PRTPE_WE_RO 0x05 /* WriteExclusive Registrants Only */
40 #define MPATH_PRTPE_EA_RO 0x06 /* Exclusive Access. Registrants Only*/
41 #define MPATH_PRTPE_WE_AR 0x07 /* Write Exclusive. All Registrants*/
42 #define MPATH_PRTPE_EA_AR 0x08 /* Exclusive Access. All Registrants */
45 /* PR RETURN_STATUS */
46 #define MPATH_PR_SKIP -1 /* skipping this path */
47 #define MPATH_PR_SUCCESS 0
48 #define MPATH_PR_SYNTAX_ERROR 1 /* syntax error or invalid parameter */
49 /* status for check condition */
50 #define MPATH_PR_SENSE_NOT_READY 2 /* [sk,asc,ascq: 0x2,*,*] */
51 #define MPATH_PR_SENSE_MEDIUM_ERROR 3 /* [sk,asc,ascq: 0x3,*,*] */
52 #define MPATH_PR_SENSE_HARDWARE_ERROR 4 /* [sk,asc,ascq: 0x4,*,*] */
53 #define MPATH_PR_ILLEGAL_REQ 5 /* [sk,asc,ascq: 0x5,*,*]*/
54 #define MPATH_PR_SENSE_UNIT_ATTENTION 6 /* [sk,asc,ascq: 0x6,*,*] */
55 #define MPATH_PR_SENSE_INVALID_OP 7 /* [sk,asc,ascq: 0x5,0x20,0x0]*/
56 #define MPATH_PR_SENSE_ABORTED_COMMAND 8 /* [sk,asc,ascq: 0xb,*,*] */
57 #define MPATH_PR_NO_SENSE 9 /* [sk,asc,ascq: 0x0,*,*] */
59 #define MPATH_PR_SENSE_MALFORMED 10 /* Response to SCSI command malformed */
60 #define MPATH_PR_RESERV_CONFLICT 11 /* Reservation conflict on the device */
61 #define MPATH_PR_FILE_ERROR 12 /* file (device node) problems(e.g. not found)*/
62 #define MPATH_PR_DMMP_ERROR 13 /* DMMP related error.(e.g Error in getting dm info */
63 #define MPATH_PR_THREAD_ERROR 14 /* pthreads error (e.g. unable to create new thread) */
64 #define MPATH_PR_OTHER 15 /*other error/warning has occurred(transport
68 #define MPATH_F_APTPL_MASK 0x01 /* APTPL MASK*/
69 #define MPATH_F_ALL_TG_PT_MASK 0x04 /* ALL_TG_PT MASK*/
70 #define MPATH_F_SPEC_I_PT_MASK 0x08 /* SPEC_I_PT MASK*/
71 #define MPATH_PR_TYPE_MASK 0x0f /* TYPE MASK*/
72 #define MPATH_PR_SCOPE_MASK 0xf0 /* SCOPE MASK*/
74 /*Transport ID PROTOCOL IDENTIFIER values */
75 #define MPATH_PROTOCOL_ID_FC 0x00
76 #define MPATH_PROTOCOL_ID_ISCSI 0x05
77 #define MPATH_PROTOCOL_ID_SAS 0x06
80 /*Transport ID FORMAT CODE */
81 #define MPATH_WWUI_DEVICE_NAME 0x00 /* World wide unique initiator device name */
82 #define MPATH_WWUI_PORT_IDENTIFIER 0x40 /* World wide unique initiator port identifier */
86 extern unsigned int mpath_mx_alloc_len;
92 uint32_t prgeneration;
93 uint32_t additional_length; /* The value should be either 0 or divisible by 8.
94 0 indicates no registered reservation key. */
95 uint8_t key_list[MPATH_MAX_PARAM_LEN];
100 uint32_t prgeneration;
101 uint32_t additional_length; /* The value should be either 0 or 10h. 0 indicates
102 there is no reservation held. 10h indicates the
103 key[8] and scope_type have valid values */
107 uint8_t scope_type; /* Use PR SCOPE AND TYPE MASK specified above */
115 uint16_t pr_type_mask;
124 uint8_t n_port_name[8]; /* FC transport*/
125 uint8_t sas_address[8]; /* SAS transport */
126 uint8_t iscsi_name[256]; /* ISCSI transport */
130 struct prin_fulldescr
133 uint8_t flag; /* All_tg_pt and reservation holder */
134 uint8_t scope_type; /* Use PR SCOPE AND TYPE MASK specified above.
135 Meaningful only for reservation holder */
137 struct transportid trnptid;
140 struct print_fulldescr_list
142 uint32_t prgeneration;
143 uint32_t number_of_descriptor;
144 uint8_t private_buffer[MPATH_MAX_PARAM_LEN]; /*Private buffer for list storage*/
145 struct prin_fulldescr *descriptors[];
152 struct prin_readdescr prin_readkeys; /* for PRIN read keys SA*/
153 struct prin_resvdescr prin_readresv; /* for PRIN read reservation SA*/
154 struct prin_capdescr prin_readcap; /* for PRIN Report Capabilities SA*/
155 struct print_fulldescr_list prin_readfd; /* for PRIN read full status SA*/
159 struct prout_param_descriptor { /* PROUT parameter descriptor */
166 uint8_t private_buffer[MPATH_MAX_PARAM_LEN]; /*private buffer for list storage*/
167 uint32_t num_transportid; /* Number of Transport ID listed in trnptid_list[]*/
168 struct transportid *trnptid_list[];
172 /* Function declarations */
176 * Initialize device mapper multipath configuration. This function must be invoked first
177 * before performing reservation management functions.
178 * Either this function or mpath_lib_init() may be used.
179 * Use this function to work with libmultipath's internal "struct config"
180 * and "struct udev". The latter will be initialized automatically.
181 * Call libmpathpersist_exit() for cleanup.
184 * RETURNS: 0->Success, 1->Failed.
186 extern int libmpathpersist_init (void);
190 * Initialize device mapper multipath configuration. This function must be invoked first
191 * before performing reservation management functions.
192 * Either this function or libmpathpersist_init() may be used.
193 * Use this function to work with an application-specific "struct config"
194 * and "struct udev". The latter must be initialized by the application.
195 * Call mpath_lib_exit() for cleanup.
198 * RETURNS: struct config ->Success, NULL->Failed.
200 extern struct config * mpath_lib_init (void);
205 * Release device mapper multipath configuration. This function must be invoked after
206 * performing reservation management functions.
207 * Use this after initialization with mpath_lib_init().
210 * RETURNS: 0->Success, 1->Failed.
212 extern int mpath_lib_exit (struct config *conf);
216 * Release device mapper multipath configuration a. This function must be invoked after
217 * performing reservation management functions.
218 * Use this after initialization with libmpathpersist_init().
219 * Calling libmpathpersist_init() after libmpathpersist_exit() will fail.
222 * RETURNS: 0->Success, 1->Failed.
224 extern int libmpathpersist_exit (void);
229 * This function sends PRIN command to the DM device and get the response.
231 * @fd: The file descriptor of a multipath device. Input argument.
232 * @rq_servact: PRIN command service action. Input argument
233 * @resp: The response from PRIN service action. The resp is a struct specified above. The caller should
234 * manage the memory allocation of this struct
235 * @noisy: Turn on debugging trace: Input argument. 0->Disable, 1->Enable
236 * @verbose: Set verbosity level. Input argument. value:[0-3]. 0->disabled, 3->Max verbose
240 * RETURNS: MPATH_PR_SUCCESS if PR command successful else returns any of the status specified
241 * above in RETURN_STATUS.
244 extern int mpath_persistent_reserve_in (int fd, int rq_servact, struct prin_resp *resp,
245 int noisy, int verbose);
249 * This function is like mpath_persistent_reserve_in(), except that it
250 * requires mpath_persistent_reserve_init_vecs() to be called before the
251 * PR call to set up internal variables. These must later be cleanup up
252 * by calling mpath_persistent_reserve_free_vecs().
255 * This function uses static internal variables, and is not thread-safe.
257 extern int __mpath_persistent_reserve_in(int fd, int rq_servact,
258 struct prin_resp *resp, int noisy);
262 * This function sends PROUT command to the DM device and get the response.
264 * @fd: The file descriptor of a multipath device. Input argument.
265 * @rq_servact: PROUT command service action. Input argument
266 * @rq_scope: Persistent reservation scope. The value should be always LU_SCOPE (0h).
267 * @rq_type: Persistent reservation type. The valid values of persistent reservation types are
268 * 5h (Write exclusive - registrants only)
269 * 6h (Exclusive access - registrants only)
270 * 7h (Write exclusive - All registrants)
271 * 8h (Exclusive access - All registrants).
272 * @paramp: PROUT command parameter data. The paramp is a struct which describes PROUT
273 * parameter list. The caller should manage the memory allocation of this struct.
274 * @noisy: Turn on debugging trace: Input argument.0->Disable, 1->Enable.
275 * @verbose: Set verbosity level. Input argument. value:0 to 3. 0->disabled, 3->Max verbose
279 * RETURNS: MPATH_PR_SUCCESS if PR command successful else returns any of the status specified
280 * above in RETURN_STATUS.
282 extern int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
283 unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy,
287 * This function is like mpath_persistent_reserve_out(), except that it
288 * requires mpath_persistent_reserve_init_vecs() to be called before the
289 * PR call to set up internal variables. These must later be cleanup up
290 * by calling mpath_persistent_reserve_free_vecs().
293 * This function uses static internal variables, and is not thread-safe.
295 extern int __mpath_persistent_reserve_out( int fd, int rq_servact, int rq_scope,
296 unsigned int rq_type, struct prout_param_descriptor *paramp,
301 * This function allocates data structures and performs basic initialization and
302 * device discovery for later calls of __mpath_persistent_reserve_in() or
303 * __mpath_persistent_reserve_out().
304 * @verbose: Set verbosity level. Input argument. value:0 to 3. 0->disabled, 3->Max verbose
307 * This function uses static internal variables, and is not thread-safe.
309 * RETURNS: MPATH_PR_SUCCESS if successful else returns any of the status specified
310 * above in RETURN_STATUS.
312 int mpath_persistent_reserve_init_vecs(int verbose);
316 * This function frees data structures allocated by
317 * mpath_persistent_reserve_init_vecs().
320 * This function uses static internal variables, and is not thread-safe.
322 void mpath_persistent_reserve_free_vecs(void);
329 #endif /*MPATH_PERSIST_LIB_H*/