20 #include <sys/ioctl.h> 21 #include <sys/types.h> 62 else if (nif->
fd > -1)
81 memset (nif, 0,
sizeof (*nif));
93 VLIB_NODE_STATE_POLLING);
106 VLIB_NODE_STATE_INTERRUPT);
114 u8 is_pipe,
u8 is_master,
u32 * sw_if_index)
124 struct nmreq *req = 0;
131 return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
133 fd = open (
"/dev/netmap", O_RDWR);
135 return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
153 snprintf (req->
nr_name, IFNAMSIZ,
"%s", if_name);
154 req->
nr_name[IFNAMSIZ - 1] = 0;
158 ret = VNET_API_ERROR_NOT_CONNECTED;
170 if (reg->
mem == MAP_FAILED)
172 ret = VNET_API_ERROR_NOT_CONNECTED;
197 template.file_descriptor = nif->
fd;
198 template.private_data = nif->
if_index;
204 memcpy (hw_addr, hw_addr_set, 6);
209 rnd = (
u32) (now * 1e6);
212 memcpy (hw_addr + 2, &rnd,
sizeof (rnd));
225 ret = VNET_API_ERROR_SYSCALL_ERROR_1;
259 clib_warning (
"Host interface %s does not exist", host_if_name);
260 return VNET_API_ERROR_SYSCALL_ERROR_1;
294 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)
vnet_main_t * vnet_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 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 vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define VLIB_INIT_FUNCTION(x)
u32 per_interface_next_index
static uword unix_file_add(unix_main_t *um, unix_file_t *template)
#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).
#define NR_ACCEPT_VNET_HDR
#define clib_warning(format, args...)
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 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)
static uword * mhash_get(mhash_t *h, const void *key)
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)
#define clib_error_report(e)
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
static vlib_main_t * vlib_get_main(void)
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
static vlib_thread_main_t * vlib_get_thread_main()
#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 void unix_file_del(unix_main_t *um, unix_file_t *f)
static uword pool_elts(void *v)
Number of active elements in a pool.