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]
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>
34 * ALUA messaging and interconnect API.
41 STMF_ICM_REGISTER_PROXY_PORT
= 0,
42 STMF_ICM_DEREGISTER_PROXY_PORT
,
43 STMF_ICM_REGISTER_LUN
,
44 STMF_ICM_DEREGISTER_LUN
,
47 STMF_ICM_SCSI_DATA_XFER_DONE
,
51 STMF_ICM_SESSION_CREATE
,
52 STMF_ICM_SESSION_DESTROY
,
53 STMF_ICM_ECHO_REQUEST
,
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 */
84 * Register port message.
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
;
92 } stmf_ic_reg_port_msg_t
;
95 * Deregister port message.
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.
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
;
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
;
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
;
148 } stmf_ic_scsi_data_msg_t
;
151 * SCSI data xfer done msg
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
;
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? */
168 uint8_t icss_flags
; /* TASK_SCTRL_OVER, TASK_SCTRL_UNDER */
170 uint8_t icss_sense_len
;
172 } stmf_ic_scsi_status_msg_t
;
175 * Ready to transfer (r2t) msg.
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
;
185 * Status message: sent in response to messages other than SCSI messages.
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.
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
208 uint32_t icerr_datalen
;
209 } stmf_ic_echo_request_reply_msg_t
;
212 STMF_IC_MSG_SUCCESS
= 0,
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 */
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
,
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
,
242 stmf_ic_msgid_t msgid
);
244 /* Allocate a deregister port message */
246 stmf_ic_msg_t
*(*stmf_ic_dereg_port_msg_alloc_func_t
)(
247 scsi_devid_desc_t
*port_id
,
250 stmf_ic_msgid_t msgid
);
252 stmf_ic_msg_t
*stmf_ic_dereg_port_msg_alloc(
253 scsi_devid_desc_t
*port_id
,
256 stmf_ic_msgid_t msgid
);
259 /* Allocate a register lun message */
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
,
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
,
273 stmf_ic_msgid_t msgid
);
275 /* Allocate a lun active message */
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
,
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
,
289 stmf_ic_msgid_t msgid
);
291 /* Allocate a deregister lun message */
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
,
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
,
305 stmf_ic_msgid_t msgid
);
307 /* Allocate a scsi cmd message */
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
,
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
,
321 stmf_ic_msgid_t msgid
);
323 /* Allocate a scsi data message */
325 stmf_ic_msg_t
*(*stmf_ic_scsi_data_msg_alloc_func_t
)(
326 stmf_ic_msgid_t task_msgid
,
331 stmf_ic_msgid_t msgid
);
333 stmf_ic_msg_t
*stmf_ic_scsi_data_msg_alloc(
334 stmf_ic_msgid_t task_msgid
,
339 stmf_ic_msgid_t msgid
);
341 /* Allocate a scsi transfer done message */
343 stmf_ic_msg_t
*(*stmf_ic_scsi_data_xfer_done_msg_alloc_func_t
)(
344 stmf_ic_msgid_t task_msgid
,
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
,
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
,
361 uint8_t response
, /* was command processed? */
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
,
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 */
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 */
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(
408 stmf_ic_msgid_t msgid
);
410 /* Allocate an echo reply message */
411 stmf_ic_msg_t
*stmf_ic_echo_reply_msg_alloc(
414 stmf_ic_msgid_t msgid
);
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
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
);
443 #endif /* _SYS_PPPT_IC_IF_H */