Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | /** |
| 16 | * @brief |
| 17 | * A Data-Path Object is an object that represents actions that are |
| 18 | * applied to packets are they are switched through VPP's data-path. |
| 19 | * |
| 20 | * The DPO can be considered to be like is a base class that is specialised |
| 21 | * by other objects to provide concreate actions |
| 22 | * |
| 23 | * The VLIB graph nodes are graph of DPO types, the DPO graph is a graph of |
| 24 | * instances. |
| 25 | */ |
| 26 | |
| 27 | #ifndef __DPO_H__ |
| 28 | #define __DPO_H__ |
| 29 | |
| 30 | #include <vnet/vnet.h> |
| 31 | |
| 32 | /** |
| 33 | * @brief An index for adjacencies. |
| 34 | * Alas 'C' is not typesafe enough to b0rk when a u32 is used instead of |
| 35 | * an index_t. However, for us humans, we can glean much more intent |
| 36 | * from the declaration |
| 37 | * foo barindex_t t); |
| 38 | * than we can from |
| 39 | * foo bar(u32 t); |
| 40 | */ |
| 41 | typedef u32 index_t; |
| 42 | |
| 43 | /** |
| 44 | * @brief Invalid index - used when no index is known |
| 45 | * blazoned capitals INVALID speak volumes where ~0 does not. |
| 46 | */ |
| 47 | #define INDEX_INVALID ((index_t)(~0)) |
| 48 | |
| 49 | /** |
| 50 | * @brief Data path protocol. |
| 51 | * Actions performed on packets in the data-plane can be described and represented |
| 52 | * by protocol independent objects, i.e. ADJACENCY, but the spceifics actions |
| 53 | * required during ADJACENCY processing can be protocol dependent. For example, |
| 54 | * the adjacency rewrite node performs a ip4 checksum calculation, ip6 and MPLS |
| 55 | * do not, all 3 perform a TTL decrement. The VLIB graph nodes are thus protocol |
| 56 | * dependent, and thus each graph edge/arc is too. |
| 57 | * When programming a DPO's next node arc from child to parent it is thus required |
| 58 | * to know the parent's data-path protocol so the correct arc index can be used. |
| 59 | */ |
| 60 | typedef enum dpo_proto_t_ |
| 61 | { |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 62 | DPO_PROTO_IP4 = 0, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 63 | DPO_PROTO_IP6, |
| 64 | DPO_PROTO_MPLS, |
Neale Ranns | da78f95 | 2017-05-24 09:15:43 -0700 | [diff] [blame] | 65 | DPO_PROTO_ETHERNET, |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 66 | DPO_PROTO_BIER, |
Florin Coras | ce1b4c7 | 2017-01-26 14:25:34 -0800 | [diff] [blame] | 67 | DPO_PROTO_NSH, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 68 | } __attribute__((packed)) dpo_proto_t; |
| 69 | |
Florin Coras | ce1b4c7 | 2017-01-26 14:25:34 -0800 | [diff] [blame] | 70 | #define DPO_PROTO_NUM ((dpo_proto_t)(DPO_PROTO_NSH+1)) |
Neale Ranns | 450cd30 | 2016-11-09 17:49:42 +0000 | [diff] [blame] | 71 | #define DPO_PROTO_NONE ((dpo_proto_t)(DPO_PROTO_NUM+1)) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 72 | |
| 73 | #define DPO_PROTOS { \ |
| 74 | [DPO_PROTO_IP4] = "ip4", \ |
| 75 | [DPO_PROTO_IP6] = "ip6", \ |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 76 | [DPO_PROTO_ETHERNET] = "ethernet", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 77 | [DPO_PROTO_MPLS] = "mpls", \ |
Florin Coras | ce1b4c7 | 2017-01-26 14:25:34 -0800 | [diff] [blame] | 78 | [DPO_PROTO_NSH] = "nsh", \ |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 79 | [DPO_PROTO_BIER] = "bier", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 80 | } |
| 81 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 82 | #define FOR_EACH_DPO_PROTO(_proto) \ |
| 83 | for (_proto = DPO_PROTO_IP4; \ |
Florin Coras | ce1b4c7 | 2017-01-26 14:25:34 -0800 | [diff] [blame] | 84 | _proto <= DPO_PROTO_NSH; \ |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 85 | _proto++) |
| 86 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 87 | /** |
| 88 | * @brief Common types of data-path objects |
| 89 | * New types can be dynamically added using dpo_register_new_type() |
| 90 | */ |
| 91 | typedef enum dpo_type_t_ { |
| 92 | /** |
| 93 | * A non-zero value first so we can spot unitialisation errors |
| 94 | */ |
| 95 | DPO_FIRST, |
| 96 | DPO_DROP, |
Neale Ranns | 948e00f | 2016-10-20 13:39:34 +0100 | [diff] [blame] | 97 | DPO_IP_NULL, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 98 | DPO_PUNT, |
| 99 | /** |
| 100 | * @brief load-balancing over a choice of [un]equal cost paths |
| 101 | */ |
| 102 | DPO_LOAD_BALANCE, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 103 | DPO_REPLICATE, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 104 | DPO_ADJACENCY, |
| 105 | DPO_ADJACENCY_INCOMPLETE, |
| 106 | DPO_ADJACENCY_MIDCHAIN, |
| 107 | DPO_ADJACENCY_GLEAN, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 108 | DPO_ADJACENCY_MCAST, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 109 | DPO_ADJACENCY_MCAST_MIDCHAIN, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 110 | DPO_RECEIVE, |
| 111 | DPO_LOOKUP, |
| 112 | DPO_LISP_CP, |
| 113 | DPO_CLASSIFY, |
| 114 | DPO_MPLS_LABEL, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 115 | DPO_MPLS_DISPOSITION, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 116 | DPO_MFIB_ENTRY, |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 117 | DPO_INTERFACE_RX, |
| 118 | DPO_INTERFACE_TX, |
Neale Ranns | 6f63115 | 2017-10-03 08:20:21 -0700 | [diff] [blame] | 119 | DPO_L2_BRIDGE, |
Andrew Yourtchenko | 5f3fcb9 | 2017-10-25 05:50:37 -0700 | [diff] [blame] | 120 | DPO_L3_PROXY, |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 121 | DPO_BIER_TABLE, |
| 122 | DPO_BIER_FMASK, |
| 123 | DPO_BIER_IMP, |
| 124 | DPO_BIER_DISP_TABLE, |
| 125 | DPO_BIER_DISP_ENTRY, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 126 | DPO_LAST, |
| 127 | } __attribute__((packed)) dpo_type_t; |
| 128 | |
| 129 | #define DPO_TYPE_NUM DPO_LAST |
| 130 | |
| 131 | #define DPO_TYPES { \ |
| 132 | [DPO_FIRST] = "dpo-invalid", \ |
| 133 | [DPO_DROP] = "dpo-drop", \ |
Neale Ranns | 948e00f | 2016-10-20 13:39:34 +0100 | [diff] [blame] | 134 | [DPO_IP_NULL] = "dpo-ip-null", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 135 | [DPO_PUNT] = "dpo-punt", \ |
| 136 | [DPO_ADJACENCY] = "dpo-adjacency", \ |
| 137 | [DPO_ADJACENCY_INCOMPLETE] = "dpo-adjacency-incomplete", \ |
| 138 | [DPO_ADJACENCY_MIDCHAIN] = "dpo-adjacency-midcahin", \ |
| 139 | [DPO_ADJACENCY_GLEAN] = "dpo-glean", \ |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 140 | [DPO_ADJACENCY_MCAST] = "dpo-adj-mcast", \ |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 141 | [DPO_ADJACENCY_MCAST_MIDCHAIN] = "dpo-adj-mcast-midchain", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 142 | [DPO_RECEIVE] = "dpo-receive", \ |
| 143 | [DPO_LOOKUP] = "dpo-lookup", \ |
| 144 | [DPO_LOAD_BALANCE] = "dpo-load-balance", \ |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 145 | [DPO_REPLICATE] = "dpo-replicate", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 146 | [DPO_LISP_CP] = "dpo-lisp-cp", \ |
| 147 | [DPO_CLASSIFY] = "dpo-classify", \ |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 148 | [DPO_MPLS_LABEL] = "dpo-mpls-label", \ |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 149 | [DPO_MPLS_DISPOSITION] = "dpo-mpls-diposition", \ |
| 150 | [DPO_MFIB_ENTRY] = "dpo-mfib_entry", \ |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 151 | [DPO_INTERFACE_RX] = "dpo-interface-rx", \ |
Neale Ranns | 6f63115 | 2017-10-03 08:20:21 -0700 | [diff] [blame] | 152 | [DPO_INTERFACE_TX] = "dpo-interface-tx", \ |
Andrew Yourtchenko | 5f3fcb9 | 2017-10-25 05:50:37 -0700 | [diff] [blame] | 153 | [DPO_L2_BRIDGE] = "dpo-l2-bridge", \ |
| 154 | [DPO_L3_PROXY] = "dpo-l3-proxy", \ |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 155 | [DPO_BIER_TABLE] = "bier-table", \ |
| 156 | [DPO_BIER_FMASK] = "bier-fmask", \ |
| 157 | [DPO_BIER_IMP] = "bier-imposition", \ |
| 158 | [DPO_BIER_DISP_ENTRY] = "bier-disp-entry", \ |
| 159 | [DPO_BIER_DISP_TABLE] = "bier-disp-table", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | /** |
| 163 | * @brief The identity of a DPO is a combination of its type and its |
| 164 | * instance number/index of objects of that type |
| 165 | */ |
| 166 | typedef struct dpo_id_t_ { |
| 167 | /** |
| 168 | * the type |
| 169 | */ |
| 170 | dpo_type_t dpoi_type; |
| 171 | /** |
| 172 | * the data-path protocol of the type. |
| 173 | */ |
| 174 | dpo_proto_t dpoi_proto; |
| 175 | /** |
| 176 | * The next VLIB node to follow. |
| 177 | */ |
| 178 | u16 dpoi_next_node; |
| 179 | /** |
| 180 | * the index of objects of that type |
| 181 | */ |
| 182 | index_t dpoi_index; |
| 183 | } __attribute__ ((aligned(sizeof(u64)))) dpo_id_t; |
| 184 | |
Damjan Marion | cf47894 | 2016-11-07 14:57:50 +0100 | [diff] [blame] | 185 | STATIC_ASSERT(sizeof(dpo_id_t) <= sizeof(u64), |
| 186 | "DPO ID is greater than sizeof u64 " |
| 187 | "atomic updates need to be revisited"); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 188 | |
| 189 | /** |
Neale Ranns | ad95b5d | 2016-11-10 20:35:14 +0000 | [diff] [blame] | 190 | * @brief An initialiser for DPOs declared on the stack. |
| 191 | * Thenext node is set to 0 since VLIB graph nodes should set 0 index to drop. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 192 | */ |
Neale Ranns | ad95b5d | 2016-11-10 20:35:14 +0000 | [diff] [blame] | 193 | #define DPO_INVALID \ |
| 194 | { \ |
| 195 | .dpoi_type = DPO_FIRST, \ |
| 196 | .dpoi_proto = DPO_PROTO_NONE, \ |
| 197 | .dpoi_index = INDEX_INVALID, \ |
| 198 | .dpoi_next_node = 0, \ |
| 199 | } |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 200 | |
| 201 | /** |
| 202 | * @brief Return true if the DPO object is valid, i.e. has been initialised. |
| 203 | */ |
| 204 | static inline int |
| 205 | dpo_id_is_valid (const dpo_id_t *dpoi) |
| 206 | { |
| 207 | return (dpoi->dpoi_type != DPO_FIRST && |
| 208 | dpoi->dpoi_index != INDEX_INVALID); |
| 209 | } |
| 210 | |
Neale Ranns | ad95b5d | 2016-11-10 20:35:14 +0000 | [diff] [blame] | 211 | extern dpo_proto_t vnet_link_to_dpo_proto(vnet_link_t linkt); |
| 212 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 213 | /** |
| 214 | * @brief |
| 215 | * Take a reference counting lock on the DPO |
| 216 | */ |
| 217 | extern void dpo_lock(dpo_id_t *dpo); |
| 218 | |
| 219 | /** |
| 220 | * @brief |
| 221 | * Release a reference counting lock on the DPO |
| 222 | */ |
| 223 | extern void dpo_unlock(dpo_id_t *dpo); |
| 224 | |
| 225 | /** |
| 226 | * @brief Set/create a DPO ID |
| 227 | * The DPO will be locked. |
| 228 | * |
| 229 | * @param dpo |
| 230 | * The DPO object to configure |
| 231 | * |
| 232 | * @param type |
| 233 | * The dpo_type_t of the DPO |
| 234 | * |
| 235 | * @param proto |
| 236 | * The dpo_proto_t of the DPO |
| 237 | * |
| 238 | * @param index |
| 239 | * The type specific index of the DPO |
| 240 | */ |
| 241 | extern void dpo_set(dpo_id_t *dpo, |
| 242 | dpo_type_t type, |
| 243 | dpo_proto_t proto, |
| 244 | index_t index); |
| 245 | |
| 246 | /** |
| 247 | * @brief reset a DPO ID |
| 248 | * The DPO will be unlocked. |
| 249 | * |
| 250 | * @param dpo |
| 251 | * The DPO object to reset |
| 252 | */ |
| 253 | extern void dpo_reset(dpo_id_t *dpo); |
| 254 | |
| 255 | /** |
| 256 | * @brief compare two DPOs for equality |
| 257 | */ |
| 258 | extern int dpo_cmp(const dpo_id_t *dpo1, |
| 259 | const dpo_id_t *dpo2); |
| 260 | |
| 261 | /** |
| 262 | * @brief |
| 263 | * atomic copy a data-plane object. |
| 264 | * This is safe to use when the dst DPO is currently switching packets |
| 265 | */ |
| 266 | extern void dpo_copy(dpo_id_t *dst, |
| 267 | const dpo_id_t *src); |
| 268 | |
| 269 | /** |
| 270 | * @brief Return TRUE is the DPO is any type of adjacency |
| 271 | */ |
| 272 | extern int dpo_is_adj(const dpo_id_t *dpo); |
| 273 | |
| 274 | /** |
| 275 | * @biref Format a DPO_id_t oject |
| 276 | */ |
| 277 | extern u8 *format_dpo_id(u8 * s, va_list * args); |
| 278 | |
| 279 | /** |
| 280 | * @biref format a DPO type |
| 281 | */ |
| 282 | extern u8 *format_dpo_type(u8 * s, va_list * args); |
| 283 | |
| 284 | /** |
| 285 | * @brief format a DPO protocol |
| 286 | */ |
| 287 | extern u8 *format_dpo_proto(u8 * s, va_list * args); |
| 288 | |
| 289 | /** |
Neale Ranns | da78f95 | 2017-05-24 09:15:43 -0700 | [diff] [blame] | 290 | * @brief format a DPO protocol |
| 291 | */ |
| 292 | extern vnet_link_t dpo_proto_to_link(dpo_proto_t dp); |
| 293 | |
| 294 | /** |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 295 | * @brief |
| 296 | * Set and stack a DPO. |
| 297 | * The DPO passed is set to the parent DPO and the necessary |
| 298 | * VLIB graph arcs are created. The child_type and child_proto |
| 299 | * are used to get the VLID nodes from which the arcs are added. |
| 300 | * |
| 301 | * @param child_type |
| 302 | * Child DPO type. |
| 303 | * |
| 304 | * @param child_proto |
| 305 | * Child DPO proto |
| 306 | * |
| 307 | * @parem dpo |
| 308 | * This is the DPO to stack and set. |
| 309 | * |
| 310 | * @paren parent_dpo |
| 311 | * The parent DPO to stack onto. |
| 312 | */ |
| 313 | extern void dpo_stack(dpo_type_t child_type, |
| 314 | dpo_proto_t child_proto, |
| 315 | dpo_id_t *dpo, |
| 316 | const dpo_id_t *parent_dpo); |
| 317 | |
| 318 | /** |
| 319 | * @brief |
| 320 | * Set and stack a DPO. |
| 321 | * The DPO passed is set to the parent DPO and the necessary |
| 322 | * VLIB graph arcs are created, from the child_node passed. |
| 323 | * |
| 324 | * @param child_node |
| 325 | * The VLIB grpah node index to create an arc from to the parent |
| 326 | * |
Andrew Yourtchenko | 5f3fcb9 | 2017-10-25 05:50:37 -0700 | [diff] [blame] | 327 | * @param dpo |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 328 | * This is the DPO to stack and set. |
| 329 | * |
Andrew Yourtchenko | 5f3fcb9 | 2017-10-25 05:50:37 -0700 | [diff] [blame] | 330 | * @param parent_dpo |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 331 | * The parent DPO to stack onto. |
| 332 | */ |
| 333 | extern void dpo_stack_from_node(u32 child_node, |
| 334 | dpo_id_t *dpo, |
| 335 | const dpo_id_t *parent); |
| 336 | |
| 337 | /** |
Andrew Yourtchenko | 5f3fcb9 | 2017-10-25 05:50:37 -0700 | [diff] [blame] | 338 | * Get a uRPF interface for the DPO |
| 339 | * |
| 340 | * @param dpo |
| 341 | * The DPO from which to get the uRPF interface |
| 342 | * |
| 343 | * @return valid SW interface index or ~0 |
| 344 | */ |
| 345 | extern u32 dpo_get_urpf(const dpo_id_t *dpo); |
| 346 | |
| 347 | /** |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 348 | * @brief A lock function registered for a DPO type |
| 349 | */ |
| 350 | typedef void (*dpo_lock_fn_t)(dpo_id_t *dpo); |
| 351 | |
| 352 | /** |
| 353 | * @brief An unlock function registered for a DPO type |
| 354 | */ |
| 355 | typedef void (*dpo_unlock_fn_t)(dpo_id_t *dpo); |
| 356 | |
| 357 | /** |
Neale Ranns | 6c3ebcc | 2016-10-02 21:20:15 +0100 | [diff] [blame] | 358 | * @brief An memory usage show command |
| 359 | */ |
| 360 | typedef void (*dpo_mem_show_t)(void); |
| 361 | |
| 362 | /** |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 363 | * @brief Given a DPO instance return a vector of node indices that |
| 364 | * the type/instance will use. |
| 365 | */ |
| 366 | typedef u32* (*dpo_get_next_node_t)(const dpo_id_t *dpo); |
| 367 | |
| 368 | /** |
Andrew Yourtchenko | 5f3fcb9 | 2017-10-25 05:50:37 -0700 | [diff] [blame] | 369 | * @brief Given a DPO instance return an interface that can |
| 370 | * be used in an uRPF check |
| 371 | */ |
| 372 | typedef u32 (*dpo_get_urpf_t)(const dpo_id_t *dpo); |
| 373 | |
| 374 | /** |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 375 | * @brief A virtual function table regisitered for a DPO type |
| 376 | */ |
| 377 | typedef struct dpo_vft_t_ |
| 378 | { |
| 379 | /** |
| 380 | * A reference counting lock function |
| 381 | */ |
| 382 | dpo_lock_fn_t dv_lock; |
| 383 | /** |
| 384 | * A reference counting unlock function |
| 385 | */ |
| 386 | dpo_lock_fn_t dv_unlock; |
| 387 | /** |
| 388 | * A format function |
| 389 | */ |
| 390 | format_function_t *dv_format; |
Neale Ranns | 6c3ebcc | 2016-10-02 21:20:15 +0100 | [diff] [blame] | 391 | /** |
| 392 | * A show memory usage function |
| 393 | */ |
| 394 | dpo_mem_show_t dv_mem_show; |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 395 | /** |
| 396 | * A function to get the next VLIB node given an instance |
| 397 | * of the DPO. If this is null, then the node's name MUST be |
| 398 | * retreiveable from the nodes names array passed in the register |
| 399 | * function |
| 400 | */ |
| 401 | dpo_get_next_node_t dv_get_next_node; |
Andrew Yourtchenko | 5f3fcb9 | 2017-10-25 05:50:37 -0700 | [diff] [blame] | 402 | /** |
| 403 | * Get uRPF interface |
| 404 | */ |
| 405 | dpo_get_urpf_t dv_get_urpf; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 406 | } dpo_vft_t; |
| 407 | |
| 408 | |
| 409 | /** |
| 410 | * @brief For a given DPO type Register: |
| 411 | * - a virtual function table |
| 412 | * - a NULL terminated array of graph nodes from which that object type |
| 413 | * will originate packets, i.e. the nodes in which the object type will be |
| 414 | * the parent DPO in the DP graph. The ndoes are per-data-path protocol |
| 415 | * (see above). |
| 416 | * |
| 417 | * @param type |
| 418 | * The type being registered. |
| 419 | * |
| 420 | * @param vft |
| 421 | * The virtual function table to register for the type. |
| 422 | * |
| 423 | * @param nodes |
| 424 | * The string description of the per-protocol VLIB graph nodes. |
| 425 | */ |
Neale Ranns | 6c3ebcc | 2016-10-02 21:20:15 +0100 | [diff] [blame] | 426 | extern void dpo_register(dpo_type_t type, |
| 427 | const dpo_vft_t *vft, |
| 428 | const char * const * const * nodes); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 429 | |
| 430 | /** |
| 431 | * @brief Create and register a new DPO type. |
| 432 | * |
| 433 | * This can be used by plugins to create new DPO types that are not listed |
| 434 | * in dpo_type_t enum |
| 435 | * |
| 436 | * @param vft |
| 437 | * The virtual function table to register for the type. |
| 438 | * |
| 439 | * @param nodes |
| 440 | * The string description of the per-protocol VLIB graph nodes. |
| 441 | * |
| 442 | * @return The new dpo_type_t |
| 443 | */ |
Neale Ranns | 6c3ebcc | 2016-10-02 21:20:15 +0100 | [diff] [blame] | 444 | extern dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, |
| 445 | const char * const * const * nodes); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 446 | |
| 447 | #endif |