sys/fs/zfs.h: replace grub in comments.
[unleashed.git] / include / sys / pppt_ic_if.h
blobdd640d79a62f68ed2edc77b71abc3c37397a827c
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 #ifndef _SYS_PPPT_IC_IF_H
25 #define _SYS_PPPT_IC_IF_H
27 #include <sys/stmf_defines.h>
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
34 * ALUA messaging and interconnect API.
38 * Message type.
40 typedef enum {
41 STMF_ICM_REGISTER_PROXY_PORT = 0,
42 STMF_ICM_DEREGISTER_PROXY_PORT,
43 STMF_ICM_REGISTER_LUN,
44 STMF_ICM_DEREGISTER_LUN,
45 STMF_ICM_SCSI_CMD,
46 STMF_ICM_SCSI_DATA,
47 STMF_ICM_SCSI_DATA_XFER_DONE,
48 STMF_ICM_SCSI_STATUS,
49 STMF_ICM_R2T,
50 STMF_ICM_STATUS,
51 STMF_ICM_SESSION_CREATE,
52 STMF_ICM_SESSION_DESTROY,
53 STMF_ICM_ECHO_REQUEST,
54 STMF_ICM_ECHO_REPLY,
55 STMF_ICM_LUN_ACTIVE,
56 STMF_ICM_MAX_MSG_TYPE
57 } stmf_ic_msg_type_t;
60 * Message id: uniquely identifies a message.
61 * This need not be a sequence number since we don't depend on
62 * messages being delivered in sequence.
64 typedef uint64_t stmf_ic_msgid_t;
67 * IC message. This is a container for the various specific message types.
69 * Note that the message contains a pointer to an nvlist. This pointer
70 * is valid only in the case of messages which are unmarshaled from
71 * nvlists. In that case, it's important to retain a pointer to the nvlist,
72 * since the message and the nvlist share data in the case of strings
73 * and array elements, and data in the message may be invalid if used
74 * after the nvlist is freed.
76 typedef struct stmf_ic_msg {
77 stmf_ic_msg_type_t icm_msg_type;
78 stmf_ic_msgid_t icm_msgid;
79 nvlist_t *icm_nvlist; /* nvlist associated with the msg */
80 void *icm_msg; /* ptr to the specific msg */
81 } stmf_ic_msg_t;
84 * Register port message.
86 typedef struct {
87 scsi_devid_desc_t *icrp_port_id;
88 uint16_t icrp_relative_port_id;
89 /* opaque callback data */
90 uint16_t icrp_cb_arg_len;
91 uint8_t *icrp_cb_arg;
92 } stmf_ic_reg_port_msg_t;
95 * Deregister port message.
97 typedef struct {
98 scsi_devid_desc_t *icdp_port_id;
99 /* opaque callback data */
100 uint16_t icdp_cb_arg_len;
101 uint8_t *icdp_cb_arg;
102 } stmf_ic_dereg_port_msg_t;
105 * Register/deregister lun message.
107 typedef struct {
108 uint8_t icrl_lun_id[16];
109 char *icrl_lu_provider_name;
110 /* opaque callback data */
111 uint16_t icrl_cb_arg_len;
112 uint8_t *icrl_cb_arg;
113 } stmf_ic_reg_dereg_lun_msg_t;
116 * SCSI cmd msg.
118 typedef struct {
119 stmf_ic_msgid_t icsc_task_msgid;
120 scsi_devid_desc_t *icsc_ini_devid;
121 scsi_devid_desc_t *icsc_tgt_devid;
122 stmf_remote_port_t *icsc_rport;
123 uint8_t icsc_lun_id[16];
125 * fields from scsi_task_t
127 uint64_t icsc_session_id;
128 uint8_t icsc_task_lun_no[8];
129 uint32_t icsc_task_expected_xfer_length;
130 uint16_t icsc_task_cdb_length;
131 uint8_t *icsc_task_cdb;
132 uint8_t icsc_task_flags; /* See def. for task flags */
133 uint8_t icsc_task_priority; /* As per SAM-3 */
134 uint8_t icsc_task_mgmt_function; /* if is a TM req */
135 uint32_t icsc_immed_data_len;
136 uint8_t *icsc_immed_data;
137 } stmf_ic_scsi_cmd_msg_t;
140 * SCSI data message.
142 typedef struct {
143 stmf_ic_msgid_t icsd_task_msgid; /* matches msgid of cmd */
144 uint64_t icsd_session_id;
145 uint8_t icsd_lun_id[16];
146 uint64_t icsd_data_len;
147 uint8_t *icsd_data;
148 } stmf_ic_scsi_data_msg_t;
151 * SCSI data xfer done msg
153 typedef struct {
154 stmf_ic_msgid_t icsx_task_msgid; /* matches msgid of cmd */
155 uint64_t icsx_session_id;
156 stmf_status_t icsx_status;
157 } stmf_ic_scsi_data_xfer_done_msg_t;
160 * SCSI status msg.
162 typedef struct {
163 stmf_ic_msgid_t icss_task_msgid; /* matches msgid of cmd */
164 uint64_t icss_session_id;
165 uint8_t icss_lun_id[16];
166 uint8_t icss_response; /* was command processed? */
167 uint8_t icss_status;
168 uint8_t icss_flags; /* TASK_SCTRL_OVER, TASK_SCTRL_UNDER */
169 uint32_t icss_resid;
170 uint8_t icss_sense_len;
171 uint8_t *icss_sense;
172 } stmf_ic_scsi_status_msg_t;
175 * Ready to transfer (r2t) msg.
177 typedef struct {
178 stmf_ic_msgid_t icrt_task_msgid; /* matches msgid of cmd */
179 uint64_t icrt_session_id;
180 uint32_t icrt_offset;
181 uint32_t icrt_length;
182 } stmf_ic_r2t_msg_t;
185 * Status message: sent in response to messages other than SCSI messages.
187 typedef struct {
188 stmf_ic_msg_type_t ics_msg_type; /* msg type rpting status on */
189 stmf_ic_msgid_t ics_msgid; /* msgid reporting status on */
190 stmf_status_t ics_status;
191 } stmf_ic_status_msg_t;
194 * Session create/destroy message.
196 typedef struct {
197 uint64_t icscd_session_id;
198 scsi_devid_desc_t *icscd_ini_devid;
199 scsi_devid_desc_t *icscd_tgt_devid;
200 stmf_remote_port_t *icscd_rport;
201 } stmf_ic_session_create_destroy_msg_t;
204 * Echo request/reply message
206 typedef struct {
207 uint8_t *icerr_data;
208 uint32_t icerr_datalen;
209 } stmf_ic_echo_request_reply_msg_t;
211 typedef enum {
212 STMF_IC_MSG_SUCCESS = 0,
213 STMF_IC_MSG_IC_DOWN,
214 STMF_IC_MSG_TIMED_OUT,
215 STMF_IC_MSG_INTERNAL_ERROR
216 } stmf_ic_msg_status_t;
219 * Function prototypes.
221 * Note: Functions which are exported to other modules must have a function
222 * typedef and a prototype; the function type definition is used by
223 * the other module to import the symbol using ddi_modsym().
226 void stmf_ic_ioctl_cmd(void *ibuf, uint32_t ibuf_size);
228 /* Allocate a register port message */
229 typedef
230 stmf_ic_msg_t *(*stmf_ic_reg_port_msg_alloc_func_t)(
231 scsi_devid_desc_t *port_id,
232 uint16_t relative_port_id,
233 uint16_t cb_arg_len,
234 uint8_t *cb_arg,
235 stmf_ic_msgid_t msgid);
237 stmf_ic_msg_t *stmf_ic_reg_port_msg_alloc(
238 scsi_devid_desc_t *port_id,
239 uint16_t relative_port_id,
240 uint16_t cb_arg_len,
241 uint8_t *cb_arg,
242 stmf_ic_msgid_t msgid);
244 /* Allocate a deregister port message */
245 typedef
246 stmf_ic_msg_t *(*stmf_ic_dereg_port_msg_alloc_func_t)(
247 scsi_devid_desc_t *port_id,
248 uint16_t cb_arg_len,
249 uint8_t *cb_arg,
250 stmf_ic_msgid_t msgid);
252 stmf_ic_msg_t *stmf_ic_dereg_port_msg_alloc(
253 scsi_devid_desc_t *port_id,
254 uint16_t cb_arg_len,
255 uint8_t *cb_arg,
256 stmf_ic_msgid_t msgid);
259 /* Allocate a register lun message */
260 typedef
261 stmf_ic_msg_t *(*stmf_ic_reg_lun_msg_alloc_func_t)(
262 uint8_t *icrl_lun_id, /* should be 16 bytes */
263 char *lu_provider_name,
264 uint16_t cb_arg_len,
265 uint8_t *cb_arg,
266 stmf_ic_msgid_t msgid);
268 stmf_ic_msg_t *stmf_ic_reg_lun_msg_alloc(
269 uint8_t *icrl_lun_id, /* should be 16 bytes */
270 char *lu_provider_name,
271 uint16_t cb_arg_len,
272 uint8_t *cb_arg,
273 stmf_ic_msgid_t msgid);
275 /* Allocate a lun active message */
276 typedef
277 stmf_ic_msg_t *(*stmf_ic_lun_active_msg_alloc_func_t)(
278 uint8_t *icrl_lun_id, /* should be 16 bytes */
279 char *lu_provider_name,
280 uint16_t cb_arg_len,
281 uint8_t *cb_arg,
282 stmf_ic_msgid_t msgid);
284 stmf_ic_msg_t *stmf_ic_lun_active_msg_alloc(
285 uint8_t *icrl_lun_id, /* should be 16 bytes */
286 char *lu_provider_name,
287 uint16_t cb_arg_len,
288 uint8_t *cb_arg,
289 stmf_ic_msgid_t msgid);
291 /* Allocate a deregister lun message */
292 typedef
293 stmf_ic_msg_t *(*stmf_ic_dereg_lun_msg_alloc_func_t)(
294 uint8_t *icrl_lun_id, /* should be 16 bytes */
295 char *lu_provider_name,
296 uint16_t cb_arg_len,
297 uint8_t *cb_arg,
298 stmf_ic_msgid_t msgid);
300 stmf_ic_msg_t *stmf_ic_dereg_lun_msg_alloc(
301 uint8_t *icrl_lun_id, /* should be 16 bytes */
302 char *lu_provider_name,
303 uint16_t cb_arg_len,
304 uint8_t *cb_arg,
305 stmf_ic_msgid_t msgid);
307 /* Allocate a scsi cmd message */
308 typedef
309 stmf_ic_msg_t *(*stmf_ic_scsi_cmd_msg_alloc_func_t)(
310 stmf_ic_msgid_t task_msgid,
311 scsi_task_t *scsi_task,
312 uint32_t immed_data_len,
313 uint8_t *immed_data,
314 stmf_ic_msgid_t msgid);
316 stmf_ic_msg_t *stmf_ic_scsi_cmd_msg_alloc(
317 stmf_ic_msgid_t task_msgid,
318 scsi_task_t *scsi_task,
319 uint32_t immed_data_len,
320 uint8_t *immed_data,
321 stmf_ic_msgid_t msgid);
323 /* Allocate a scsi data message */
324 typedef
325 stmf_ic_msg_t *(*stmf_ic_scsi_data_msg_alloc_func_t)(
326 stmf_ic_msgid_t task_msgid,
327 uint64_t session_id,
328 uint8_t *lun_id,
329 uint64_t data_len,
330 uint8_t *data,
331 stmf_ic_msgid_t msgid);
333 stmf_ic_msg_t *stmf_ic_scsi_data_msg_alloc(
334 stmf_ic_msgid_t task_msgid,
335 uint64_t session_id,
336 uint8_t *lun_id,
337 uint64_t data_len,
338 uint8_t *data,
339 stmf_ic_msgid_t msgid);
341 /* Allocate a scsi transfer done message */
342 typedef
343 stmf_ic_msg_t *(*stmf_ic_scsi_data_xfer_done_msg_alloc_func_t)(
344 stmf_ic_msgid_t task_msgid,
345 uint64_t session_id,
346 stmf_status_t status,
347 stmf_ic_msgid_t msgid);
349 stmf_ic_msg_t *stmf_ic_scsi_data_xfer_done_msg_alloc(
350 stmf_ic_msgid_t task_msgid,
351 uint64_t session_id,
352 stmf_status_t status,
353 stmf_ic_msgid_t msgid);
356 /* Allocate a scsi status message */
357 stmf_ic_msg_t *stmf_ic_scsi_status_msg_alloc(
358 stmf_ic_msgid_t task_msgid,
359 uint64_t session_id,
360 uint8_t *lun_id,
361 uint8_t response, /* was command processed? */
362 uint8_t status,
363 uint8_t flags,
364 uint32_t resid,
365 uint8_t sense_len,
366 uint8_t *sense,
367 stmf_ic_msgid_t msgid); /* must match corresponding scsi cmd msgid */
370 /* Allocate a scsi ready to transfer (r2t) message */
371 stmf_ic_msg_t *stmf_ic_r2t_msg_alloc(
372 stmf_ic_msgid_t task_msgid,
373 uint64_t session_id,
374 uint32_t offset,
375 uint32_t length,
376 stmf_ic_msgid_t msgid); /* must match corresponding scsi cmd msgid */
378 /* Allocate a status message */
379 stmf_ic_msg_t *stmf_ic_status_msg_alloc(
380 stmf_status_t status,
381 stmf_ic_msg_type_t msg_type, /* msg type reporting status on */
382 stmf_ic_msgid_t msgid); /* id of msg reporting status on */
384 /* Allocate a session create message */
385 typedef
386 stmf_ic_msg_t *(*stmf_ic_session_create_msg_alloc_func_t)(
387 stmf_scsi_session_t *session,
388 stmf_ic_msgid_t msgid);
390 stmf_ic_msg_t *stmf_ic_session_create_msg_alloc(
391 stmf_scsi_session_t *session,
392 stmf_ic_msgid_t msgid);
394 /* Allocate a session destroy message */
395 typedef
396 stmf_ic_msg_t *(*stmf_ic_session_destroy_msg_alloc_func_t)(
397 stmf_scsi_session_t *session,
398 stmf_ic_msgid_t msgid);
400 stmf_ic_msg_t *stmf_ic_session_destroy_msg_alloc(
401 stmf_scsi_session_t *session,
402 stmf_ic_msgid_t msgid);
404 /* Allocate an echo request message */
405 stmf_ic_msg_t *stmf_ic_echo_request_msg_alloc(
406 uint32_t data_len,
407 uint8_t *data,
408 stmf_ic_msgid_t msgid);
410 /* Allocate an echo reply message */
411 stmf_ic_msg_t *stmf_ic_echo_reply_msg_alloc(
412 uint32_t data_len,
413 uint8_t *data,
414 stmf_ic_msgid_t msgid);
417 * Free a msg.
419 typedef void (*stmf_ic_msg_free_func_t)(stmf_ic_msg_t *msg);
420 void stmf_ic_msg_free(stmf_ic_msg_t *msg);
423 * Send a message out over the interconnect, in the process marshalling
424 * the arguments.
426 * After being sent, the message is freed by tx_msg().
428 typedef stmf_ic_msg_status_t (*stmf_ic_tx_msg_func_t)(stmf_ic_msg_t *msg);
429 stmf_ic_msg_status_t stmf_ic_tx_msg(stmf_ic_msg_t *msg);
432 * This is a low-level upcall which is called when a message has
433 * been received on the interconnect.
435 void stmf_ic_rx_msg(char *buf, size_t len);
437 stmf_status_t stmf_msg_rx(stmf_ic_msg_t *msg);
439 #ifdef __cplusplus
441 #endif
443 #endif /* _SYS_PPPT_IC_IF_H */