20 #include <sys/ioctl.h> 21 #include <sys/types.h> 82 memset (nif, 0,
sizeof (*nif));
94 VLIB_NODE_STATE_POLLING);
107 VLIB_NODE_STATE_INTERRUPT);
115 u8 is_pipe,
u8 is_master,
u32 * sw_if_index)
125 struct nmreq *req = 0;
132 return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
134 fd = open (
"/dev/netmap", O_RDWR);
136 return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
154 snprintf (req->
nr_name, IFNAMSIZ,
"%s", if_name);
155 req->
nr_name[IFNAMSIZ - 1] = 0;
159 ret = VNET_API_ERROR_NOT_CONNECTED;
171 if (reg->
mem == MAP_FAILED)
173 ret = VNET_API_ERROR_NOT_CONNECTED;
198 template.file_descriptor = nif->
fd;
199 template.private_data = nif->
if_index;
205 memcpy (hw_addr, hw_addr_set, 6);
210 rnd = (
u32) (now * 1e6);
213 memcpy (hw_addr + 2, &rnd,
sizeof (rnd));
226 ret = VNET_API_ERROR_SYSCALL_ERROR_1;
260 clib_warning (
"Host interface %s does not exist", host_if_name);
261 return VNET_API_ERROR_SYSCALL_ERROR_1;
295 if (tr && tr->
count > 0)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
unix_file_function_t * read_function
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
static vlib_main_t * vlib_get_main(void)
int netmap_worker_thread_enable()
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
static f64 vlib_time_now(vlib_main_t *vm)
static void mhash_init_vec_string(mhash_t *h, uword n_value_bytes)
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
#define clib_error_report(e)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static uword unix_file_add(unix_main_t *um, unix_file_t *template)
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
u32 per_interface_next_index
#define clib_warning(format, args...)
static void unix_file_del(unix_main_t *um, unix_file_t *f)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
netmap_mem_region_t * mem_regions
uword mhash_set_mem(mhash_t *h, void *key, uword *new_value, uword *old_value)
#define pool_put(P, E)
Free an object E in pool P.
static u32 netmap_eth_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 flags)
#define foreach_vlib_main(body)
mhash_t if_index_by_host_if_name
#define vec_free(V)
Free vector's memory (no header).
static vlib_thread_main_t * vlib_get_thread_main()
#define NR_ACCEPT_VNET_HDR
int netmap_create_if(vlib_main_t *vm, u8 *if_name, u8 *hw_addr_set, u8 is_pipe, u8 is_master, u32 *sw_if_index)
static uword * mhash_get(mhash_t *h, void *key)
static void close_netmap_if(netmap_main_t *nm, netmap_if_t *nif)
netmap_main_t netmap_main
vlib_node_registration_t netmap_input_node
(constructor) VLIB_REGISTER_NODE (netmap_input_node)
int netmap_worker_thread_disable()
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
static clib_error_t * netmap_fd_read_ready(unix_file_t *uf)
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
uword * thread_registrations_by_name
u32 input_cpu_first_index
vnet_device_class_t netmap_device_class
uword * pending_input_bitmap
#define hash_get_mem(h, key)
static void * clib_mem_alloc_aligned(uword size, uword align)
static u32 random_u32(u32 *seed)
32-bit random number generator
#define CLIB_CACHE_LINE_BYTES
static clib_error_t * netmap_init(vlib_main_t *vm)
int netmap_delete_if(vlib_main_t *vm, u8 *host_if_name)
static uword pool_elts(void *v)
Number of active elements in a pool.