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 FORMATE 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.
180 * RETURNS: struct config ->Success, NULL->Failed.
182 extern struct config * mpath_lib_init (void);
187 * Release device mapper multipath configuration. This function must be invoked after
188 * performing reservation management functions.
191 * RETURNS: 0->Success, 1->Failed.
193 extern int mpath_lib_exit (struct config *conf);
198 * This function sends PRIN command to the DM device and get the response.
200 * @fd: The file descriptor of a multipath device. Input argument.
201 * @rq_servact: PRIN command service action. Input argument
202 * @resp: The response from PRIN service action. The resp is a struct specified above. The caller should
203 * manage the memory allocation of this struct
204 * @noisy: Turn on debugging trace: Input argument. 0->Disable, 1->Enable
205 * @verbose: Set verbosity level. Input argument. value:[0-3]. 0->disabled, 3->Max verbose
209 * RETURNS: MPATH_PR_SUCCESS if PR command successful else returns any of the status specified
210 * above in RETURN_STATUS.
213 extern int mpath_persistent_reserve_in (int fd, int rq_servact, struct prin_resp *resp,
214 int noisy, int verbose);
218 * This function sends PROUT command to the DM device and get the response.
220 * @fd: The file descriptor of a multipath device. Input argument.
221 * @rq_servact: PROUT command service action. Input argument
222 * @rq_scope: Persistent reservation scope. The value should be always LU_SCOPE (0h).
223 * @rq_type: Persistent reservation type. The valid values of persistent reservation types are
224 * 5h (Write exclusive - registrants only)
225 * 6h (Exclusive access - registrants only)
226 * 7h (Write exclusive - All registrants)
227 * 8h (Exclusive access - All registrants).
228 * @paramp: PROUT command parameter data. The paramp is a struct which describes PROUT
229 * parameter list. The caller should manage the memory allocation of this struct.
230 * @noisy: Turn on debugging trace: Input argument.0->Disable, 1->Enable.
231 * @verbose: Set verbosity level. Input argument. value:0 to 3. 0->disabled, 3->Max verbose
235 * RETURNS: MPATH_PR_SUCCESS if PR command successful else returns any of the status specified
236 * above in RETURN_STATUS.
238 extern int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
239 unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy,
246 #endif /*MPATH_PERSIST_LIB_H*/