|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
25 #include <sys/types.h>
29 #include <sys/ioctl.h>
31 #include <linux/ethtool.h>
32 #include <linux/sockios.h>
34 #include <uuid/uuid.h>
40 static const char netvsc_uuid[] =
"f8615163-df3e-46c5-913f-f2d2f965ed0e";
131 if (uuid_parse ((
char *) s,
addr->guid) == 0)
146 uuid_unparse (
addr->guid,
tmp);
164 dir = opendir ((
char *) dev_net_dir);
172 while ((e = readdir (dir)))
175 if (strncmp (e->d_name,
"lower_", 6))
178 strncpy (ifr.ifr_name, e->d_name + 6, IFNAMSIZ - 1);
186 if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0)
189 else if (!(ifr.ifr_flags & IFF_UP))
191 ifr.ifr_flags |= IFF_UP;
193 if (ioctl (fd, SIOCSIFFLAGS, &ifr) < 0)
205 struct stat s = { 0 };
206 if (stat (
path, &s) == -1)
209 return S_ISDIR (s.st_mode);
218 static int uio_new_id_needed = 1;
227 s =
format (0,
"%v/driver%c", dev_dir_name, 0);
233 if (!driver_name || strcmp (
"hv_netvsc", (
char *) driver_name) != 0)
240 s =
format (s,
"%v/net%c", dev_dir_name, 0);
241 dir = opendir ((
char *) s);
247 while ((e = readdir (dir)))
249 if (e->d_name[0] ==
'.')
252 ifname = strdup (e->d_name);
260 "VMBUS device %U eth not found",
267 strncpy (ifr.ifr_name, ifname, IFNAMSIZ - 1);
270 fd = socket (PF_INET, SOCK_DGRAM, 0);
277 if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0)
285 if (ifr.ifr_flags & IFF_UP)
288 "Skipping VMBUS device %U as host interface %s is up",
295 if (uio_new_id_needed)
303 if (
error->code == EEXIST)
314 uio_new_id_needed = 0;
325 s =
format (s,
"%/driver_override%c", dev_dir_name, 0);
326 if (access ((
char *) s, F_OK) == 0)
334 s =
format (s,
"%v/driver/unbind%c", dev_dir_name, 0);
367 if (!
unformat (&input,
"/sys/bus/vmbus/devices/%U",
386 return uuid_compare (a1->
guid, a2->
guid);
linux_vmbus_device_t * linux_vmbus_devices
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static const char uio_drv_name[]
__clib_export u8 * clib_sysfs_link_to_name(char *link)
clib_error_t * foreach_directory_file(char *dir_name, clib_error_t *(*f)(void *arg, u8 *path_name, u8 *file_name), void *arg, int scan_dirs)
uword unformat_vlib_vmbus_addr(unformat_input_t *input, va_list *args)
void vlib_vmbus_set_private_data(vlib_vmbus_dev_handle_t h, uword private_data)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static const char sysfs_vmbus_drv_path[]
#define clib_error_return(e, args...)
vlib_vmbus_addr_t * vlib_vmbus_get_addr(vlib_vmbus_dev_handle_t h)
clib_error_t * linux_vmbus_init(vlib_main_t *vm)
static int vmbus_addr_cmp(void *v1, void *v2)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
__clib_export clib_error_t * clib_sysfs_write(char *file_name, char *fmt,...)
static clib_error_t * scan_vmbus_addr(void *arg, u8 *dev_dir_name, u8 *ignored)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * vlib_vmbus_raise_lower(int fd, const char *upper_name)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
clib_error_t * vmbus_bus_init(vlib_main_t *vm)
static const char sysfs_vmbus_dev_path[]
vlib_vmbus_dev_handle_t handle
uword vlib_vmbus_get_private_data(vlib_vmbus_dev_handle_t h)
vlib_vmbus_addr_t * vlib_vmbus_get_all_dev_addrs()
#define vec_free(V)
Free vector's memory (no header).
u8 * format_vlib_vmbus_addr(u8 *s, va_list *va)
description fragment has unexpected format
#define VLIB_INIT_FUNCTION(x)
#define clib_error_return_unix(e, args...)
linux_vmbus_main_t linux_vmbus_main
static linux_vmbus_device_t * linux_vmbus_get_device(vlib_vmbus_dev_handle_t h)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
static const char sysfs_class_net_path[]
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define clib_error_free(e)
static const char netvsc_uuid[]
u32 vlib_vmbus_dev_handle_t
clib_error_t * vlib_vmbus_bind_to_uio(vlib_vmbus_addr_t *addr)
static int directory_exists(char *path)