20 #include <sys/ioctl.h> 21 #include <sys/types.h> 64 else if (nif->
fd > -1)
95 VLIB_NODE_STATE_POLLING);
108 VLIB_NODE_STATE_INTERRUPT);
126 struct nmreq *req = 0;
133 return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
135 fd = open (
"/dev/netmap", O_RDWR);
137 return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
155 snprintf (req->
nr_name, IFNAMSIZ,
"%s", if_name);
156 req->
nr_name[IFNAMSIZ - 1] = 0;
160 ret = VNET_API_ERROR_NOT_CONNECTED;
172 if (reg->
mem == MAP_FAILED)
174 ret = VNET_API_ERROR_NOT_CONNECTED;
195 template.file_descriptor = nif->
fd;
196 template.private_data = nif->
if_index;
202 memcpy (hw_addr, hw_addr_set, 6);
207 rnd = (
u32) (now * 1e6);
210 memcpy (hw_addr + 2, &rnd,
sizeof (rnd));
223 ret = VNET_API_ERROR_SYSCALL_ERROR_1;
257 clib_warning (
"Host interface %s does not exist", host_if_name);
258 return VNET_API_ERROR_SYSCALL_ERROR_1;
292 if (tr && tr->
count > 0)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void clib_file_del(clib_file_main_t *um, clib_file_t *f)
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)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
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).
clib_file_function_t * read_function
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
u32 per_interface_next_index
clib_file_main_t file_main
static clib_error_t * netmap_fd_read_ready(clib_file_t *uf)
static void clib_spinlock_init(clib_spinlock_t *p)
#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)
vlib_node_registration_t netmap_input_node
(constructor) VLIB_REGISTER_NODE (netmap_input_node)
static uword * mhash_get(mhash_t *h, const void *key)
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
int netmap_worker_thread_disable()
#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
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
uword * pending_input_bitmap
#define hash_get_mem(h, key)
static u32 random_u32(u32 *seed)
32-bit random number generator
static vlib_thread_main_t * vlib_get_thread_main()
netmap_main_t netmap_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 uword pool_elts(void *v)
Number of active elements in a pool.