Print this page
Overlay fabric router
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/overlay_impl.h
+++ new/usr/src/uts/common/sys/overlay_impl.h
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright 2018 Joyent, Inc.
14 14 */
15 15
16 16 #ifndef _SYS_OVERLAY_IMPL_H
|
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 #define _SYS_OVERLAY_IMPL_H
18 18
19 19 /*
20 20 * Overlay device support
21 21 */
22 22
23 23 #include <sys/overlay.h>
24 24 #include <sys/overlay_common.h>
25 25 #include <sys/overlay_plugin.h>
26 26 #include <sys/overlay_target.h>
27 +#include <sys/overlay_router.h>
27 28 #include <sys/ksynch.h>
28 29 #include <sys/list.h>
29 30 #include <sys/avl.h>
30 31 #include <sys/ksocket.h>
31 32 #include <sys/socket.h>
32 33 #include <sys/refhash.h>
33 34 #include <sys/ethernet.h>
34 35 #include <sys/list.h>
36 +#include <sys/atomic.h>
35 37
36 38 #ifdef __cplusplus
37 39 extern "C" {
38 40 #endif
39 41
40 42 #define OVEP_VERSION_ONE 0x1
41 43
42 44 typedef struct overlay_plugin {
43 45 kmutex_t ovp_mutex;
44 46 list_node_t ovp_link; /* overlay_plugin_lock */
45 47 uint_t ovp_active; /* ovp_mutex */
46 48 const char *ovp_name; /* RO */
47 49 const overlay_plugin_ops_t *ovp_ops; /* RO */
48 50 const char *const *ovp_props; /* RO */
49 51 uint_t ovp_nprops; /* RO */
50 52 uint_t ovp_id_size; /* RO */
51 53 overlay_plugin_flags_t ovp_flags; /* RO */
52 54 overlay_plugin_dest_t ovp_dest; /* RO */
53 55 } overlay_plugin_t;
54 56
55 57 typedef struct overlay_mux {
56 58 list_node_t omux_lnode;
57 59 ksocket_t omux_ksock; /* RO */
58 60 overlay_plugin_t *omux_plugin; /* RO: associated encap */
59 61 int omux_domain; /* RO: socket domain */
60 62 int omux_family; /* RO: socket family */
61 63 int omux_protocol; /* RO: socket protocol */
62 64 struct sockaddr *omux_addr; /* RO: socket address */
63 65 socklen_t omux_alen; /* RO: sockaddr len */
64 66 kmutex_t omux_lock; /* Protects everything below */
65 67 uint_t omux_count; /* Active instances */
66 68 avl_tree_t omux_devices; /* Tree of devices */
67 69 } overlay_mux_t;
68 70
69 71 typedef enum overlay_target_flag {
70 72 OVERLAY_T_TEARDOWN = 0x1
71 73 } overlay_target_flag_t;
72 74
73 75 typedef struct overlay_target {
74 76 kmutex_t ott_lock;
75 77 kcondvar_t ott_cond;
76 78 overlay_target_mode_t ott_mode; /* RO */
|
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
77 79 overlay_plugin_dest_t ott_dest; /* RO */
78 80 uint64_t ott_id; /* RO */
79 81 overlay_target_flag_t ott_flags; /* ott_lock */
80 82 uint_t ott_ocount; /* ott_lock */
81 83 union { /* ott_lock */
82 84 overlay_target_point_t ott_point;
83 85 struct overlay_target_dyn {
84 86 refhash_t *ott_dhash;
85 87 refhash_t *ott_l3dhash;
86 88 avl_tree_t ott_tree;
87 - /* XXX: Do we actually need a tree sorted by VL3? */
88 89 avl_tree_t ott_l3tree;
89 90 } ott_dyn;
90 91 } ott_u;
91 92 } overlay_target_t;
92 93
93 -/*
94 - * Initially at least, we represent a group of fabrics that are attached to
95 - * each other as a circular linked list. Within an overlay_dev_t, we then
96 - * maintain a list of pointers into these lists for each fabric that's
97 - * present locally on the CN as we learn them:
98 - *
99 - */
100 -typedef struct overlay_fabric_attach {
101 - struct overlay_fabric_attach *ofa_next;
102 - struct in6_addr ofa_addr;
103 - uint32_t ofa_dcid;
104 - uint16_t ofa_vlan;
105 - uint8_t ofa_prefixlen;
106 - uint8_t ofa_pad;
107 -} overlay_fabric_attach_t;
94 +typedef struct overlay_router {
95 + kmutex_t otr_lock;
96 + avl_tree_t otr_tree; /* RW tree of all fabrics */
97 + list_t otr_tables;
98 +} overlay_router_t;
108 99
109 -/*
110 - * Since we have two different refhashes for an overlay_target_entry_t
111 - * (VL2 aka MAC address and VL3 aka IP address), we want to maintain
112 - * the refcount in only one place. We elect to use the ott_dhash
113 - * refhash to do so.
114 - */
115 -#define OVERLAY_TARGET_ENTRY_HOLD(tgt, e) \
116 - refhash_hold((tgt)->ott_u.ott_dyn.ott_dhash, e)
117 -#define OVERLAY_TARGET_ENTRY_RELE(tgt, e) \
118 - refhash_rele((tgt)->ott_u.ott_dyn.ott_dhash, e)
119 -
120 100 typedef enum overlay_dev_flag {
121 101 OVERLAY_F_ACTIVATED = 0x01, /* Activate ioctl completed */
122 102 OVERLAY_F_IN_MUX = 0x02, /* Currently in a mux */
123 103 OVERLAY_F_IN_TX = 0x04, /* Currently doing tx */
124 104 OVERLAY_F_IN_RX = 0x08, /* Currently doing rx */
125 105 OVERLAY_F_IOMASK = 0x0c, /* A mask for rx and tx */
126 106 OVERLAY_F_MDDROP = 0x10, /* Drop traffic for metadata update */
127 107 OVERLAY_F_STOPMASK = 0x1e, /* None set when stopping */
128 108 OVERLAY_F_VARPD = 0x20, /* varpd plugin exists */
129 109 OVERLAY_F_DEGRADED = 0x40, /* device is degraded */
130 110 OVERLAY_F_MASK = 0x7f /* mask of everything */
131 111 } overlay_dev_flag_t;
132 112
133 113 typedef struct overlay_dev {
134 114 kmutex_t odd_lock;
135 115 kcondvar_t odd_iowait;
136 116 list_node_t odd_link; /* overlay_dev_lock */
137 117 mac_handle_t odd_mh; /* RO */
138 118 overlay_plugin_t *odd_plugin; /* RO */
139 119 datalink_id_t odd_linkid; /* RO */
|
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
140 120 void *odd_pvoid; /* RO -- only used by plugin */
141 121 uint_t odd_ref; /* protected by odd_lock */
142 122 uint_t odd_mtu; /* protected by odd_lock */
143 123 overlay_dev_flag_t odd_flags; /* protected by odd_lock */
144 124 uint_t odd_rxcount; /* protected by odd_lock */
145 125 uint_t odd_txcount; /* protected by odd_lock */
146 126 overlay_mux_t *odd_mux; /* protected by odd_lock */
147 127 uint64_t odd_vid; /* RO if active else odd_lock */
148 128 avl_node_t odd_muxnode; /* managed by mux */
149 129 overlay_target_t *odd_target; /* See big theory statement */
150 - overlay_fabric_attach_t **odd_fattach; /* protected by odd_lock */
130 + overlay_router_t *odd_router;
151 131 uint32_t odd_dcid; /* RO if active else odd_lock */
152 132 uint8_t odd_macaddr[ETHERADDRL]; /* RO same as odd_dcid */
153 133 char odd_fmamsg[OVERLAY_STATUS_BUFLEN]; /* odd_lock */
154 134 } overlay_dev_t;
155 135
136 +struct overlay_route_table;
137 +typedef struct overlay_route_table overlay_route_table_t;
138 +
139 +typedef struct overlay_fabric_entry {
140 + avl_node_t ofe_avllink;
141 + overlay_dev_t *ofe_odd;
142 + overlay_route_table_t *ofe_route_table;
143 + volatile uint32_t ofe_refcnt;
144 + overlay_fabric_t ofe_fabric;
145 + list_t ofe_targ_list;
146 +} overlay_fabric_entry_t;
147 +#define OVERLAY_FAB_ENTRY_REFHOLD(ofe) atomic_inc_32(&(ofe)->ofe_refcnt)
148 +#define OVERLAY_FAB_ENTRY_REFRELE(ofe) \
149 + (void) ((atomic_dec_32_nv(&(ofe)->ofe_refcnt) != 0) || \
150 + (overlay_fabric_entry_free(ofe), 0))
151 +
152 +struct overlay_route_table {
153 + list_node_t ort_link;
154 + overlay_fabric_entry_t **ort_dest;
155 + size_t ort_nalloc;
156 +};
157 +
156 158 typedef enum overlay_target_entry_flags {
157 159 OVERLAY_ENTRY_F_PENDING = 0x01, /* lookup in progress */
158 160 OVERLAY_ENTRY_F_VALID = 0x02, /* entry is currently valid */
159 161 OVERLAY_ENTRY_F_DROP = 0x04, /* always drop target */
160 - OVERLAY_ENTRY_F_VALID_MASK = 0x06
162 + OVERLAY_ENTRY_F_ROUTER = 0x08, /* entry is for router */
163 + OVERLAY_ENTRY_F_VALID_MASK = 0x0e,
164 + OVERLAY_ENTRY_F_VL3_PENDING = 0x10,
165 + OVERLAY_ENTRY_F_VL3_VALID = 0x20,
161 166 } overlay_target_entry_flags_t;
162 167
163 168 typedef struct overlay_target_entry {
164 169 kmutex_t ote_lock;
165 170 refhash_link_t ote_reflink; /* hashtable link */
166 171 refhash_link_t ote_l3_reflink; /* IP hashtable link */
167 172 avl_node_t ote_avllink; /* iteration link */
168 - avl_node_t ote_l3_avllink; /* IP iteration link */
173 + avl_node_t ote_l3_avllink; /* IP iteration link */
169 174 list_node_t ote_qlink;
175 + list_node_t ote_fablink;
176 + volatile uint32_t ote_refcnt;
170 177 overlay_target_entry_flags_t ote_flags; /* RW: state flags */
171 - uint32_t ote_dcid;
172 - uint16_t ote_vlan; /* RO: VL3 vlan id */
173 - uint8_t ote_addr[ETHERADDRL]; /* RO: mac addr */
174 178 struct in6_addr ote_ip; /* RO: VL3 IP */
179 + uint8_t ote_addr[ETHERADDRL]; /* RO: mac addr */
175 180 overlay_target_t *ote_ott; /* RO */
176 181 overlay_dev_t *ote_odd; /* RO */
182 + overlay_fabric_entry_t *ote_fab; /* RO */
177 183 overlay_target_point_t ote_dest; /* RW: destination */
178 184 mblk_t *ote_chead; /* RW: blocked mb chain head */
179 185 mblk_t *ote_ctail; /* RW: blocked mb chain tail */
180 186 size_t ote_mbsize; /* RW: outstanding mblk size */
181 187 hrtime_t ote_vtime; /* RW: valid timestamp */
182 188 } overlay_target_entry_t;
189 +#define OVERLAY_TARG_ENTRY_REFHOLD(ote) atomic_inc_32(&(ote)->ote_refcnt)
190 +#define OVERLAY_TARG_ENTRY_REFRELE(ote) \
191 + (void) ((atomic_dec_32_nv(&(ote)->ote_refcnt) != 0) || \
192 + (overlay_target_entry_dtor(ote), 0))
183 193
184 194 #define OVERLAY_CTL "overlay"
185 195
186 196 extern dev_info_t *overlay_dip;
187 197
188 198 extern mblk_t *overlay_m_tx(void *, mblk_t *);
189 199
190 200 typedef int (*overlay_dev_iter_f)(overlay_dev_t *, void *);
191 201 extern void overlay_dev_iter(overlay_dev_iter_f, void *);
192 202
193 203 extern void overlay_plugin_init(void);
194 204 extern overlay_plugin_t *overlay_plugin_lookup(const char *);
195 205 extern void overlay_plugin_rele(overlay_plugin_t *);
196 206 extern void overlay_plugin_fini(void);
197 207 typedef int (*overlay_plugin_walk_f)(overlay_plugin_t *, void *);
198 208 extern void overlay_plugin_walk(overlay_plugin_walk_f, void *);
199 209
200 210 extern void overlay_io_start(overlay_dev_t *, overlay_dev_flag_t);
201 211 extern void overlay_io_done(overlay_dev_t *, overlay_dev_flag_t);
202 212
203 213 extern void overlay_mux_init(void);
204 214 extern void overlay_mux_fini(void);
205 215
206 216 extern overlay_mux_t *overlay_mux_open(overlay_plugin_t *, int, int, int,
207 217 struct sockaddr *, socklen_t, int *);
208 218 extern void overlay_mux_close(overlay_mux_t *);
209 219 extern void overlay_mux_add_dev(overlay_mux_t *, overlay_dev_t *);
210 220 extern void overlay_mux_remove_dev(overlay_mux_t *, overlay_dev_t *);
|
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
211 221 extern int overlay_mux_tx(overlay_mux_t *, struct msghdr *, mblk_t *);
212 222
213 223 extern void overlay_prop_init(overlay_prop_handle_t);
214 224
215 225 extern void overlay_target_init(void);
216 226 extern int overlay_target_busy(void);
217 227 extern int overlay_target_open(dev_t *, int, int, cred_t *);
218 228 extern int overlay_target_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
219 229 extern int overlay_target_close(dev_t, int, int, cred_t *);
220 230 extern void overlay_target_free(overlay_dev_t *);
231 +extern void overlay_target_entry_dtor(void *);
221 232
222 233 #define OVERLAY_TARGET_OK 0
223 234 #define OVERLAY_TARGET_DROP 1
224 235 #define OVERLAY_TARGET_ASYNC 2
225 236 extern int overlay_target_lookup(overlay_dev_t *, mblk_t *, struct sockaddr *,
226 - socklen_t *);
237 + socklen_t *, uint64_t *);
238 +extern void overlay_target_queue(overlay_target_entry_t *);
227 239 extern void overlay_target_quiesce(overlay_target_t *);
228 240 extern void overlay_target_fini(void);
229 241
242 +extern int overlay_route_lookup(overlay_dev_t *, mblk_t *,
243 + const mac_header_info_t *, struct sockaddr *, socklen_t *, uint64_t *);
244 +extern int overlay_mblk_vl3ip(mblk_t *, struct in6_addr *, struct in6_addr *);
245 +extern int overlay_router_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
246 +extern int overlay_fabric_avl(const void *, const void *);
247 +
230 248 extern void overlay_fm_init(void);
231 249 extern void overlay_fm_fini(void);
232 250 extern void overlay_fm_degrade(overlay_dev_t *, const char *);
233 251 extern void overlay_fm_restore(overlay_dev_t *);
234 252
235 253 extern overlay_dev_t *overlay_hold_by_dlid(datalink_id_t);
236 254 extern void overlay_hold_rele(overlay_dev_t *);
237 255
238 256 #ifdef __cplusplus
239 257 }
240 258 #endif
241 259
242 260 #endif /* _SYS_OVERLAY_IMPL_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX