2 * Copyright (c) 2004-2006 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/sys/syslink_msg.h,v 1.5 2007/03/24 19:11:15 dillon Exp $
37 * The syslink infrastructure implements an optimized RPC mechanism across a
38 * communications link. Endpoints, defined by a sysid, are typically
39 * associated with system structures but do not have to be.
41 * syslink - Implements a communications end-point and protocol. A
42 * syslink is typically directly embedded in a related
45 * syslink_proto- Specifies a set of RPC functions.
47 * syslink_desc - Specifies a single RPC function within a protocol.
50 #ifndef _SYS_SYSLINK_MSG_H_
51 #define _SYS_SYSLINK_MSG_H_
54 #include <sys/types.h>
56 #ifndef _MACHINE_ATOMIC_H_
57 #include <machine/atomic.h>
60 typedef u_int32_t sl_msgid_t;
61 typedef u_int16_t sl_cmd_t; /* command or error */
62 typedef u_int16_t sl_itemid_t; /* item id */
63 typedef u_int16_t sl_reclen_t; /* item length */
65 #define SL_ALIGN 8 /* 8-byte alignment */
66 #define SL_ALIGNMASK (SL_ALIGN - 1)
69 * Stream or FIFO based messaging structures.
71 * The reclen is the actual record length in bytes prior to alignment.
72 * The reclen must be aligned to obtain the actual size of a syslink_msg
73 * or syslink_item structure. Note that the reclen includes structural
74 * headers (i.e. it does not represent just the data payload, it represents
75 * the entire structure).
77 * Sessions are identified with a session id. The session id is a rendezvous
78 * id that associates physical and logical routing information with a single
79 * sysid, allowing us to both avoid storing the source and target logical id
80 * in the syslink message AND ALSO providing a unique session id for an
81 * abstracted connection between two entities. Otherwise the syslink message
82 * would become bloated with five sysid fields instead of the three we have
85 * Link layer communications is accomplished by specifying a session id of
90 * Raw protocol structures
93 sl_cmd_t sm_cmd; /* protocol command code */
94 sl_reclen_t sm_bytes; /* unaligned size of message */
95 sl_msgid_t sm_msgid; /* message transaction control */
96 /* minimum syslink_msg size is 8 bytes (special PAD) */
97 sysid_t sm_sessid; /* session id */
98 sysid_t sm_srcphysid; /* originating physical id */
99 sysid_t sm_dstphysid; /* target physical id */
102 #define SL_MIN_MESSAGE_SIZE offsetof(struct syslink_msg, sm_sessid)
104 #define SL_MSGID_REPLY 0x80000000 /* command vs reply */
105 #define SL_MSGID_ORIG 0x40000000 /* originator transaction */
106 /* (else target transaction) */
107 #define SL_MSGID_BEG 0x20000000 /* first msg in transaction */
108 #define SL_MSGID_END 0x10000000 /* last msg in transaction */
109 #define SL_MSGID_STRUCTURED 0x08000000 /* contains structured data */
110 #define SL_MSGID_TRANS_MASK 0x00FFFF00 /* transaction id */
111 #define SL_MSGID_SEQ_MASK 0x000000FF /* sequence no within trans */
113 #define SLMSG_ALIGN(bytes) (((bytes) + 7) & ~7)
116 * Syslink message commands (16 bits, bit 15 must be 0)
118 * Commands 0x0000-0x001F are reserved for the universal link layer, but
119 * except for 0x0000 (which is a PAD message), must still be properly
122 * Commands 0x0020-0x002F are reserved for the universal protocol
123 * identification layer.
125 * Commands 0x0100-0x7FFF are protocol commands.
127 * The command field is the error return field with bit 15 set in the
130 #define SL_CMD_PAD 0x0000
131 #define SL_CMD_LINK_MESH 0x0001 /* mesh construction */
132 #define SL_CMD_LINK_REG 0x0002 /* register logical id */
133 #define SL_CMD_LINK_DEREG 0x0003 /* unregister logical id */
134 #define SL_CMD_LINK_ID 0x0004 /* link level identification */
136 #define SL_CMD_PROT_ID 0x0010 /* protocol & device ident */
139 * Message elements for structured messages. If SL_MSGID_STRUCTURED is
140 * set the syslink message contains zero or more syslink_elm structures
141 * laid side by side. Each syslink_elm structure may or may not be
142 * structured (i.e. recursive).
144 * Most of the same SL_MSGID_* bits apply. The first structured element
145 * will have SL_MSGID_BEG set, the last will have SL_MSGID_END set (if
146 * there is only one element, both bits will be set in that element). If
147 * the payload is structured, SL_MSGID_STRUCTURED will be set.
149 * syslink_elm's may use the TRANS and SEQ bits in the msgid for other
150 * purposes. A syslink_elm is considered to be a PAD if se_cmd == 0.
154 sl_reclen_t se_bytes;
156 /* extended by data */
159 typedef struct syslink_msg *syslink_msg_t;
160 typedef struct syslink_elm *syslink_elm_t;