1 /* SPDX-License-Identifier: Apache-2.0
2 * Copyright (c) 2023 Cisco Systems, Inc.
8 #include <vppinfra/clib.h>
9 #include <vppinfra/error_bootstrap.h>
10 #include <vppinfra/format.h>
11 #include <vnet/vnet.h>
12 #include <vnet/dev/types.h>
13 #include <vnet/dev/args.h>
15 #define VNET_DEV_DEVICE_ID_PREFIX_DELIMITER "/"
17 #define foreach_vnet_dev_port_type \
23 #define _(b, n) VNET_DEV_PORT_TYPE_##n = (1U << (b)),
24 foreach_vnet_dev_port_type
26 } vnet_dev_port_type_t;
28 #define foreach_vnet_dev_port_caps \
31 _ (change_max_rx_frame_size) \
34 #define foreach_vnet_dev_port_rx_offloads _ (ip4_cksum)
36 #define foreach_vnet_dev_port_tx_offloads \
45 #define _(n) u8 n : 1;
46 foreach_vnet_dev_port_caps
50 } vnet_dev_port_caps_t;
56 #define _(n) u8 n : 1;
57 foreach_vnet_dev_port_rx_offloads
61 } vnet_dev_port_rx_offloads_t;
67 #define _(n) u8 n : 1;
68 foreach_vnet_dev_port_tx_offloads
72 } vnet_dev_port_tx_offloads_t;
80 typedef struct vnet_dev_bus_registration vnet_dev_bus_registration_t;
81 typedef struct vnet_dev_driver_registration vnet_dev_driver_registration_t;
83 typedef struct vnet_dev vnet_dev_t;
84 typedef struct vnet_dev_port vnet_dev_port_t;
85 typedef struct vnet_dev_rx_queue vnet_dev_rx_queue_t;
86 typedef struct vnet_dev_tx_queue vnet_dev_tx_queue_t;
87 typedef struct vnet_dev_bus_registration vnet_dev_bus_registration_t;
88 typedef struct vnet_dev_driver_registration vnet_dev_driver_registration_t;
89 typedef struct vnet_dev_counter vnet_dev_counter_t;
90 typedef struct vnet_dev_counter_main vnet_dev_counter_main_t;
91 typedef struct vnet_dev_port_cfg_change_req vnet_dev_port_cfg_change_req_t;
93 typedef vnet_dev_rv_t (vnet_dev_op_t) (vlib_main_t *, vnet_dev_t *);
94 typedef vnet_dev_rv_t (vnet_dev_port_op_t) (vlib_main_t *, vnet_dev_port_t *);
95 typedef vnet_dev_rv_t (vnet_dev_port_cfg_change_op_t) (
96 vlib_main_t *, vnet_dev_port_t *, vnet_dev_port_cfg_change_req_t *);
97 typedef vnet_dev_rv_t (vnet_dev_rx_queue_op_t) (vlib_main_t *,
98 vnet_dev_rx_queue_t *);
99 typedef vnet_dev_rv_t (vnet_dev_tx_queue_op_t) (vlib_main_t *,
100 vnet_dev_tx_queue_t *);
101 typedef void (vnet_dev_op_no_rv_t) (vlib_main_t *, vnet_dev_t *);
102 typedef void (vnet_dev_port_op_no_rv_t) (vlib_main_t *, vnet_dev_port_t *);
103 typedef void (vnet_dev_rx_queue_op_no_rv_t) (vlib_main_t *,
104 vnet_dev_rx_queue_t *);
105 typedef void (vnet_dev_tx_queue_op_no_rv_t) (vlib_main_t *,
106 vnet_dev_tx_queue_t *);
108 typedef u16 vnet_dev_queue_id_t;
109 typedef u16 vnet_dev_bus_index_t;
110 typedef u16 vnet_dev_driver_index_t;
114 vnet_dev_rx_queue_op_t *alloc;
115 vnet_dev_rx_queue_op_t *start;
116 vnet_dev_rx_queue_op_no_rv_t *stop;
117 vnet_dev_rx_queue_op_no_rv_t *free;
118 format_function_t *format_info;
119 } vnet_dev_rx_queue_ops_t;
123 vnet_dev_tx_queue_op_t *alloc;
124 vnet_dev_tx_queue_op_t *start;
125 vnet_dev_tx_queue_op_no_rv_t *stop;
126 vnet_dev_tx_queue_op_no_rv_t *free;
127 format_function_t *format_info;
128 } vnet_dev_tx_queue_ops_t;
137 u8 size_is_power_of_two : 1;
138 } vnet_dev_queue_config_t;
140 #define foreach_vnet_dev_port_cfg_type \
142 _ (MAX_RX_FRAME_SIZE) \
143 _ (CHANGE_PRIMARY_HW_ADDR) \
144 _ (ADD_SECONDARY_HW_ADDR) \
145 _ (REMOVE_SECONDARY_HW_ADDR) \
146 _ (RXQ_INTR_MODE_ENABLE) \
147 _ (RXQ_INTR_MODE_DISABLE) \
150 _ (GET_RX_FLOW_COUNTER) \
151 _ (RESET_RX_FLOW_COUNTER)
155 VNET_DEV_PORT_CFG_UNKNOWN,
156 #define _(n) VNET_DEV_PORT_CFG_##n,
157 foreach_vnet_dev_port_cfg_type
159 } __clib_packed vnet_dev_port_cfg_type_t;
161 typedef struct vnet_dev_port_cfg_change_req
163 vnet_dev_port_cfg_type_t type;
170 vnet_dev_hw_addr_t addr;
171 u16 max_rx_frame_size;
172 vnet_dev_queue_id_t queue_id;
180 } vnet_dev_port_cfg_change_req_t;
184 vnet_dev_hw_addr_t hw_addr;
187 u16 max_supported_rx_frame_size;
188 vnet_dev_port_type_t type;
189 vnet_dev_port_caps_t caps;
190 vnet_dev_port_rx_offloads_t rx_offloads;
191 vnet_dev_port_tx_offloads_t tx_offloads;
192 } vnet_dev_port_attr_t;
196 VNET_DEV_PERIODIC_OP_TYPE_DEV = 1,
197 VNET_DEV_PERIODIC_OP_TYPE_PORT = 2,
198 } __clib_packed vnet_dev_periodic_op_type_t;
204 vnet_dev_periodic_op_type_t type;
208 vnet_dev_port_t *port;
213 vnet_dev_op_no_rv_t *dev_op;
214 vnet_dev_port_op_no_rv_t *port_op;
217 } vnet_dev_periodic_op_t;
221 struct _vlib_node_fn_registration *registrations;
222 format_function_t *format_trace;
223 vlib_error_desc_t *error_counters;
224 u16 n_error_counters;
229 vnet_dev_op_t *alloc;
231 vnet_dev_op_no_rv_t *deinit;
232 vnet_dev_op_t *reset;
233 vnet_dev_op_no_rv_t *free;
234 u8 *(*probe) (vlib_main_t *, vnet_dev_bus_index_t, void *);
235 format_function_t *format_info;
240 vnet_dev_port_op_t *alloc;
241 vnet_dev_port_op_t *init;
242 vnet_dev_port_cfg_change_op_t *config_change;
243 vnet_dev_port_cfg_change_op_t *config_change_validate;
244 vnet_dev_port_op_t *start;
245 vnet_dev_port_op_no_rv_t *stop;
246 vnet_dev_port_op_no_rv_t *deinit;
247 vnet_dev_port_op_no_rv_t *free;
248 format_function_t *format_status;
249 format_function_t *format_flow;
250 } vnet_dev_port_ops_t;
256 u8 update_next_index : 1;
257 u8 update_feature_arc : 1;
262 } vnet_dev_rx_queue_rt_req_t;
264 typedef struct vnet_dev_rx_queue
266 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
267 vnet_dev_port_t *port;
270 vnet_dev_counter_main_t *counter_main;
271 CLIB_CACHE_LINE_ALIGN_MARK (runtime0);
272 vnet_dev_rx_queue_t *next_on_thread;
273 u8 interrupt_mode : 1;
277 vnet_dev_queue_id_t queue_id;
280 vnet_dev_rx_queue_rt_req_t runtime_request;
281 CLIB_CACHE_LINE_ALIGN_MARK (runtime1);
282 vlib_buffer_template_t buffer_template;
283 CLIB_CACHE_LINE_ALIGN_MARK (driver_data);
285 } vnet_dev_rx_queue_t;
287 STATIC_ASSERT_SIZEOF (vnet_dev_rx_queue_t, 3 * CLIB_CACHE_LINE_BYTES);
289 typedef struct vnet_dev_tx_queue
291 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
292 vnet_dev_port_t *port;
293 clib_bitmap_t *assigned_threads;
295 vnet_dev_counter_main_t *counter_main;
296 CLIB_CACHE_LINE_ALIGN_MARK (runtime0);
297 vnet_dev_queue_id_t queue_id;
303 CLIB_ALIGN_MARK (private_data, 16);
305 } vnet_dev_tx_queue_t;
307 STATIC_ASSERT_SIZEOF (vnet_dev_tx_queue_t, 2 * CLIB_CACHE_LINE_BYTES);
309 typedef struct vnet_dev_port
311 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
313 vnet_dev_port_id_t port_id;
314 vnet_dev_driver_index_t driver_index;
319 u8 interface_created : 1;
320 u8 rx_node_assigned : 1;
321 vnet_dev_counter_main_t *counter_main;
322 vnet_dev_queue_config_t rx_queue_config;
323 vnet_dev_queue_config_t tx_queue_config;
324 vnet_dev_port_attr_t attr;
325 u32 max_rx_frame_size;
326 vnet_dev_hw_addr_t primary_hw_addr;
327 vnet_dev_hw_addr_t *secondary_hw_addr;
330 vnet_dev_rx_queue_t **rx_queues;
331 vnet_dev_tx_queue_t **tx_queues;
332 vnet_dev_port_ops_t port_ops;
333 vnet_dev_arg_t *args;
334 vnet_dev_rx_queue_ops_t rx_queue_ops;
335 vnet_dev_tx_queue_ops_t tx_queue_ops;
336 vnet_dev_node_t rx_node;
337 vnet_dev_node_t tx_node;
341 vnet_dev_if_name_t name;
344 u32 current_config_index;
346 u16 redirect_to_node_next_index;
347 u8 feature_arc_index;
349 u8 redirect_to_node : 1;
350 u8 default_is_intr_mode : 1;
360 CLIB_CACHE_LINE_ALIGN_MARK (data0);
364 typedef struct vnet_dev
366 vnet_dev_device_id_t device_id;
368 u16 not_first_init : 1;
370 u16 process_node_quit : 1;
371 u16 process_node_periodic : 1;
377 vnet_dev_driver_index_t driver_index;
379 u32 process_node_index;
380 u8 bus_data[32] __clib_aligned (16);
382 vnet_dev_port_t **ports;
383 vnet_dev_periodic_op_t *periodic_ops;
385 vnet_dev_arg_t *args;
386 u8 __clib_aligned (16)
392 u16 vendor_id, device_id;
396 #define VNET_DEV_MATCH(...) \
397 (vnet_dev_match_t[]) \
404 vnet_dev_op_t *device_open;
405 vnet_dev_op_no_rv_t *device_close;
406 vnet_dev_rv_t (*dma_mem_alloc_fn) (vlib_main_t *, vnet_dev_t *, u32, u32,
408 void (*dma_mem_free_fn) (vlib_main_t *, vnet_dev_t *, void *);
409 void *(*get_device_info) (vlib_main_t *, char *);
410 void (*free_device_info) (vlib_main_t *, void *);
411 format_function_t *format_device_info;
412 format_function_t *format_device_addr;
413 } vnet_dev_bus_ops_t;
415 struct vnet_dev_bus_registration
417 vnet_dev_bus_registration_t *next_registration;
418 vnet_dev_driver_name_t name;
419 u16 device_data_size;
420 vnet_dev_bus_ops_t ops;
423 struct vnet_dev_driver_registration
425 vnet_dev_driver_registration_t *next_registration;
426 u8 bus_master_enable : 1;
427 vnet_dev_driver_name_t name;
428 vnet_dev_bus_name_t bus;
430 u16 runtime_temp_space_sz;
431 vnet_dev_match_t *match;
434 vnet_dev_arg_t *args;
440 vnet_dev_bus_registration_t *registration;
441 vnet_dev_bus_ops_t ops;
448 vnet_dev_driver_registration_t *registration;
450 vnet_dev_bus_index_t bus_index;
456 vnet_dev_bus_t *buses;
457 vnet_dev_driver_t *drivers;
458 vnet_dev_t **devices;
459 vnet_dev_port_t **ports_by_dev_instance;
460 vnet_dev_bus_registration_t *bus_registrations;
461 vnet_dev_driver_registration_t *driver_registrations;
462 void *runtime_temp_spaces;
463 u32 log2_runtime_temp_space_sz;
464 u32 *free_process_node_indices;
465 u32 *free_rx_node_indices;
466 uword *device_index_by_id;
469 u16 next_rx_queue_thread;
470 u8 eth_port_rx_feature_arc_index;
473 extern vnet_dev_main_t vnet_dev_main;
479 vnet_dev_port_attr_t attr;
480 vnet_dev_port_ops_t ops;
481 vnet_dev_arg_t *args;
486 vnet_dev_node_t *rx_node;
487 vnet_dev_node_t *tx_node;
491 vnet_dev_queue_config_t config;
492 vnet_dev_rx_queue_ops_t ops;
497 vnet_dev_queue_config_t config;
498 vnet_dev_tx_queue_ops_t ops;
500 } vnet_dev_port_add_args_t;
517 } vnet_dev_port_state_changes_t;
520 vnet_dev_rv_t vnet_dev_arg_parse (vlib_main_t *, vnet_dev_t *,
521 vnet_dev_arg_t *, u8 *);
522 void vnet_dev_arg_free (vnet_dev_arg_t **);
523 void vnet_dev_arg_clear_value (vnet_dev_arg_t *);
524 format_function_t format_vnet_dev_arg_type;
525 format_function_t format_vnet_dev_arg_value;
526 format_function_t format_vnet_dev_args;
529 vnet_dev_t *vnet_dev_alloc (vlib_main_t *, vnet_dev_device_id_t,
530 vnet_dev_driver_t *);
531 void vnet_dev_free (vlib_main_t *, vnet_dev_t *);
532 vnet_dev_rv_t vnet_dev_init (vlib_main_t *, vnet_dev_t *);
533 void vnet_dev_deinit (vlib_main_t *, vnet_dev_t *);
534 vnet_dev_rv_t vnet_dev_reset (vlib_main_t *, vnet_dev_t *);
535 void vnet_dev_detach (vlib_main_t *, vnet_dev_t *);
536 vnet_dev_rv_t vnet_dev_port_add (vlib_main_t *, vnet_dev_t *,
538 vnet_dev_port_add_args_t *);
539 vnet_dev_rv_t vnet_dev_dma_mem_alloc (vlib_main_t *, vnet_dev_t *, u32, u32,
541 void vnet_dev_dma_mem_free (vlib_main_t *, vnet_dev_t *, void *);
542 vnet_dev_bus_t *vnet_dev_find_device_bus (vlib_main_t *, vnet_dev_device_id_t);
543 void *vnet_dev_get_device_info (vlib_main_t *, vnet_dev_device_id_t);
546 clib_error_t *vnet_dev_port_err (vlib_main_t *, vnet_dev_port_t *,
547 vnet_dev_rv_t, char *, ...);
548 int vnet_dev_flow_err (vlib_main_t *, vnet_dev_rv_t);
551 clib_error_t *vnet_dev_port_set_max_frame_size (vnet_main_t *,
552 vnet_hw_interface_t *, u32);
553 u32 vnet_dev_port_eth_flag_change (vnet_main_t *, vnet_hw_interface_t *, u32);
554 clib_error_t *vnet_dev_port_mac_change (vnet_hw_interface_t *, const u8 *,
556 clib_error_t *vnet_dev_add_del_mac_address (vnet_hw_interface_t *, const u8 *,
558 int vnet_dev_flow_ops_fn (vnet_main_t *, vnet_flow_dev_op_t, u32, u32,
560 clib_error_t *vnet_dev_interface_set_rss_queues (vnet_main_t *,
561 vnet_hw_interface_t *,
563 void vnet_dev_clear_hw_interface_counters (u32);
564 void vnet_dev_set_interface_next_node (vnet_main_t *, u32, u32);
567 vnet_dev_rv_t vnet_dev_port_start (vlib_main_t *, vnet_dev_port_t *);
568 vnet_dev_rv_t vnet_dev_port_start_all_rx_queues (vlib_main_t *,
570 vnet_dev_rv_t vnet_dev_port_start_all_tx_queues (vlib_main_t *,
572 void vnet_dev_port_stop (vlib_main_t *, vnet_dev_port_t *);
573 void vnet_dev_port_deinit (vlib_main_t *, vnet_dev_port_t *);
574 void vnet_dev_port_free (vlib_main_t *, vnet_dev_port_t *);
575 void vnet_dev_port_add_counters (vlib_main_t *, vnet_dev_port_t *,
576 vnet_dev_counter_t *, u16);
577 void vnet_dev_port_free_counters (vlib_main_t *, vnet_dev_port_t *);
578 void vnet_dev_port_update_tx_node_runtime (vlib_main_t *, vnet_dev_port_t *);
579 void vnet_dev_port_state_change (vlib_main_t *, vnet_dev_port_t *,
580 vnet_dev_port_state_changes_t);
581 void vnet_dev_port_clear_counters (vlib_main_t *, vnet_dev_port_t *);
583 vnet_dev_port_cfg_change_req_validate (vlib_main_t *, vnet_dev_port_t *,
584 vnet_dev_port_cfg_change_req_t *);
585 vnet_dev_rv_t vnet_dev_port_cfg_change (vlib_main_t *, vnet_dev_port_t *,
586 vnet_dev_port_cfg_change_req_t *);
587 vnet_dev_rv_t vnet_dev_port_if_create (vlib_main_t *, vnet_dev_port_t *);
588 vnet_dev_rv_t vnet_dev_port_if_remove (vlib_main_t *, vnet_dev_port_t *);
591 vnet_dev_rv_t vnet_dev_rx_queue_alloc (vlib_main_t *, vnet_dev_port_t *, u16);
592 vnet_dev_rv_t vnet_dev_tx_queue_alloc (vlib_main_t *, vnet_dev_port_t *, u16);
593 void vnet_dev_rx_queue_free (vlib_main_t *, vnet_dev_rx_queue_t *);
594 void vnet_dev_tx_queue_free (vlib_main_t *, vnet_dev_tx_queue_t *);
595 void vnet_dev_rx_queue_add_counters (vlib_main_t *, vnet_dev_rx_queue_t *,
596 vnet_dev_counter_t *, u16);
597 void vnet_dev_rx_queue_free_counters (vlib_main_t *, vnet_dev_rx_queue_t *);
598 void vnet_dev_tx_queue_add_counters (vlib_main_t *, vnet_dev_tx_queue_t *,
599 vnet_dev_counter_t *, u16);
600 void vnet_dev_tx_queue_free_counters (vlib_main_t *, vnet_dev_tx_queue_t *);
601 vnet_dev_rv_t vnet_dev_rx_queue_start (vlib_main_t *, vnet_dev_rx_queue_t *);
602 vnet_dev_rv_t vnet_dev_tx_queue_start (vlib_main_t *, vnet_dev_tx_queue_t *);
603 void vnet_dev_rx_queue_stop (vlib_main_t *, vnet_dev_rx_queue_t *);
604 void vnet_dev_tx_queue_stop (vlib_main_t *, vnet_dev_tx_queue_t *);
607 vnet_dev_rv_t vnet_dev_process_create (vlib_main_t *, vnet_dev_t *);
608 vnet_dev_rv_t vnet_dev_process_call_op (vlib_main_t *, vnet_dev_t *,
610 vnet_dev_rv_t vnet_dev_process_call_op_no_rv (vlib_main_t *, vnet_dev_t *,
611 vnet_dev_op_no_rv_t *);
612 void vnet_dev_process_call_op_no_wait (vlib_main_t *, vnet_dev_t *,
613 vnet_dev_op_no_rv_t *);
614 vnet_dev_rv_t vnet_dev_process_call_port_op (vlib_main_t *, vnet_dev_port_t *,
615 vnet_dev_port_op_t *);
616 vnet_dev_rv_t vnet_dev_process_call_port_op_no_rv (vlib_main_t *vm,
618 vnet_dev_port_op_no_rv_t *);
619 void vnet_dev_process_call_port_op_no_wait (vlib_main_t *, vnet_dev_port_t *,
620 vnet_dev_port_op_no_rv_t *);
622 vnet_dev_process_port_cfg_change_req (vlib_main_t *, vnet_dev_port_t *,
623 vnet_dev_port_cfg_change_req_t *);
624 void vnet_dev_process_quit (vlib_main_t *, vnet_dev_t *);
625 void vnet_dev_poll_dev_add (vlib_main_t *, vnet_dev_t *, f64,
626 vnet_dev_op_no_rv_t *);
627 void vnet_dev_poll_dev_remove (vlib_main_t *, vnet_dev_t *,
628 vnet_dev_op_no_rv_t *);
629 void vnet_dev_poll_port_add (vlib_main_t *, vnet_dev_port_t *, f64,
630 vnet_dev_port_op_no_rv_t *);
631 void vnet_dev_poll_port_remove (vlib_main_t *, vnet_dev_port_t *,
632 vnet_dev_port_op_no_rv_t *);
639 vnet_dev_port_t *port;
642 vnet_dev_rv_t vnet_dev_rt_exec_ops (vlib_main_t *, vnet_dev_t *,
643 vnet_dev_rt_op_t *, u32);
649 u8 show_zero_counters : 1;
651 } vnet_dev_format_args_t;
653 format_function_t format_vnet_dev_addr;
654 format_function_t format_vnet_dev_flags;
655 format_function_t format_vnet_dev_hw_addr;
656 format_function_t format_vnet_dev_info;
657 format_function_t format_vnet_dev_interface_info;
658 format_function_t format_vnet_dev_interface_name;
659 format_function_t format_vnet_dev_log;
660 format_function_t format_vnet_dev_port_caps;
661 format_function_t format_vnet_dev_port_flags;
662 format_function_t format_vnet_dev_port_info;
663 format_function_t format_vnet_dev_port_rx_offloads;
664 format_function_t format_vnet_dev_port_tx_offloads;
665 format_function_t format_vnet_dev_rv;
666 format_function_t format_vnet_dev_rx_queue_info;
667 format_function_t format_vnet_dev_tx_queue_info;
668 format_function_t format_vnet_dev_flow;
669 unformat_function_t unformat_vnet_dev_flags;
670 unformat_function_t unformat_vnet_dev_port_flags;
674 vnet_dev_rx_queue_t *first_rx_queue;
675 } vnet_dev_rx_node_runtime_t;
677 STATIC_ASSERT (sizeof (vnet_dev_rx_node_runtime_t) <=
678 VLIB_NODE_RUNTIME_DATA_SIZE,
679 "must fit into runtime data");
681 #define foreach_vnet_dev_port_rx_next \
682 _ (ETH_INPUT, "ethernet-input") \
683 _ (DROP, "error-drop")
687 #define _(n, s) VNET_DEV_ETH_RX_PORT_NEXT_##n,
688 foreach_vnet_dev_port_rx_next
690 VNET_DEV_ETH_RX_PORT_N_NEXTS
691 } vnet_dev_eth_port_rx_next_t;
693 extern u16 vnet_dev_default_next_index_by_port_type[];
694 extern vlib_node_registration_t port_rx_eth_node;
696 typedef vnet_interface_output_runtime_t vnet_dev_tx_node_runtime_t;
698 STATIC_ASSERT (sizeof (vnet_dev_tx_node_runtime_t) <=
699 VLIB_NODE_RUNTIME_DATA_SIZE,
700 "must fit into runtime data");
702 #define VNET_DEV_REGISTER_BUS(x, ...) \
703 __VA_ARGS__ vnet_dev_bus_registration_t __vnet_dev_bus_registration_##x; \
704 static void __clib_constructor __vnet_dev_bus_registration_fn_##x (void) \
706 vnet_dev_main_t *dm = &vnet_dev_main; \
707 __vnet_dev_bus_registration_##x.next_registration = \
708 dm->bus_registrations; \
709 dm->bus_registrations = &__vnet_dev_bus_registration_##x; \
711 __VA_ARGS__ vnet_dev_bus_registration_t __vnet_dev_bus_registration_##x
713 #define VNET_DEV_REGISTER_DRIVER(x, ...) \
714 __VA_ARGS__ vnet_dev_driver_registration_t \
715 __vnet_dev_driver_registration_##x; \
716 static void __clib_constructor __vnet_dev_driver_registration_fn_##x (void) \
718 vnet_dev_main_t *dm = &vnet_dev_main; \
719 __vnet_dev_driver_registration_##x.next_registration = \
720 dm->driver_registrations; \
721 dm->driver_registrations = &__vnet_dev_driver_registration_##x; \
723 __VA_ARGS__ vnet_dev_driver_registration_t __vnet_dev_driver_registration_##x
725 #define VNET_DEV_NODE_FN(node) \
726 uword CLIB_MARCH_SFX (node##_fn) (vlib_main_t *, vlib_node_runtime_t *, \
728 static vlib_node_fn_registration_t CLIB_MARCH_SFX ( \
729 node##_fn_registration) = { \
730 .function = &CLIB_MARCH_SFX (node##_fn), \
733 static void __clib_constructor CLIB_MARCH_SFX ( \
734 node##_fn_multiarch_register) (void) \
736 extern vnet_dev_node_t node; \
737 vlib_node_fn_registration_t *r; \
738 r = &CLIB_MARCH_SFX (node##_fn_registration); \
739 r->march_variant = CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE); \
740 r->next_registration = (node).registrations; \
741 (node).registrations = r; \
743 uword CLIB_MARCH_SFX (node##_fn)
745 #define foreach_vnet_dev_port(p, d) pool_foreach_pointer (p, d->ports)
746 #define foreach_vnet_dev_port_rx_queue(q, p) \
747 pool_foreach_pointer (q, p->rx_queues)
748 #define foreach_vnet_dev_port_tx_queue(q, p) \
749 pool_foreach_pointer (q, p->tx_queues)
751 #include <vnet/dev/dev_funcs.h>
753 #endif /* _VNET_DEV_H_ */