net/vdev_netvsc: implement core functionality
[dpdk.git] / drivers / net / vdev_netvsc / vdev_netvsc.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017 6WIND S.A.
3  * Copyright 2017 Mellanox Technologies, Ltd.
4  */
5
6 #include <errno.h>
7 #include <fcntl.h>
8 #include <inttypes.h>
9 #include <linux/sockios.h>
10 #include <net/if.h>
11 #include <net/if_arp.h>
12 #include <netinet/ip.h>
13 #include <stdarg.h>
14 #include <stddef.h>
15 #include <stdlib.h>
16 #include <stdint.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include <sys/ioctl.h>
20 #include <sys/queue.h>
21 #include <sys/socket.h>
22 #include <unistd.h>
23
24 #include <rte_alarm.h>
25 #include <rte_bus.h>
26 #include <rte_bus_vdev.h>
27 #include <rte_common.h>
28 #include <rte_config.h>
29 #include <rte_dev.h>
30 #include <rte_errno.h>
31 #include <rte_ethdev.h>
32 #include <rte_ether.h>
33 #include <rte_kvargs.h>
34 #include <rte_log.h>
35
36 #define VDEV_NETVSC_DRIVER net_vdev_netvsc
37 #define VDEV_NETVSC_ARG_IFACE "iface"
38 #define VDEV_NETVSC_ARG_MAC "mac"
39 #define VDEV_NETVSC_PROBE_MS 1000
40
41 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}"
42
43 #define DRV_LOG(level, ...) \
44         rte_log(RTE_LOG_ ## level, \
45                 vdev_netvsc_logtype, \
46                 RTE_FMT(RTE_STR(VDEV_NETVSC_DRIVER) ": " \
47                         RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
48                 RTE_FMT_TAIL(__VA_ARGS__,)))
49
50 /** Driver-specific log messages type. */
51 static int vdev_netvsc_logtype;
52
53 /** Context structure for a vdev_netvsc instance. */
54 struct vdev_netvsc_ctx {
55         LIST_ENTRY(vdev_netvsc_ctx) entry; /**< Next entry in list. */
56         unsigned int id;                   /**< Unique ID. */
57         char name[64];                     /**< Unique name. */
58         char devname[64];                  /**< Fail-safe instance name. */
59         char devargs[256];                 /**< Fail-safe device arguments. */
60         char if_name[IF_NAMESIZE];         /**< NetVSC netdevice name. */
61         unsigned int if_index;             /**< NetVSC netdevice index. */
62         struct ether_addr if_addr;         /**< NetVSC MAC address. */
63         int pipe[2];                       /**< Fail-safe communication pipe. */
64         char yield[256];                   /**< PCI sub-device arguments. */
65 };
66
67 /** Context list is common to all driver instances. */
68 static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
69         LIST_HEAD_INITIALIZER(vdev_netvsc_ctx_list);
70
71 /** Number of entries in context list. */
72 static unsigned int vdev_netvsc_ctx_count;
73
74 /** Number of driver instances relying on context list. */
75 static unsigned int vdev_netvsc_ctx_inst;
76
77 /**
78  * Destroy a vdev_netvsc context instance.
79  *
80  * @param ctx
81  *   Context to destroy.
82  */
83 static void
84 vdev_netvsc_ctx_destroy(struct vdev_netvsc_ctx *ctx)
85 {
86         if (ctx->pipe[0] != -1)
87                 close(ctx->pipe[0]);
88         if (ctx->pipe[1] != -1)
89                 close(ctx->pipe[1]);
90         free(ctx);
91 }
92
93 /**
94  * Iterate over system network interfaces.
95  *
96  * This function runs a given callback function for each netdevice found on
97  * the system.
98  *
99  * @param func
100  *   Callback function pointer. List traversal is aborted when this function
101  *   returns a nonzero value.
102  * @param ...
103  *   Variable parameter list passed as @p va_list to @p func.
104  *
105  * @return
106  *   0 when the entire list is traversed successfully, a negative error code
107  *   in case or failure, or the nonzero value returned by @p func when list
108  *   traversal is aborted.
109  */
110 static int
111 vdev_netvsc_foreach_iface(int (*func)(const struct if_nameindex *iface,
112                                       const struct ether_addr *eth_addr,
113                                       va_list ap), ...)
114 {
115         struct if_nameindex *iface = if_nameindex();
116         int s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
117         unsigned int i;
118         int ret = 0;
119
120         if (!iface) {
121                 ret = -ENOBUFS;
122                 DRV_LOG(ERR, "cannot retrieve system network interfaces");
123                 goto error;
124         }
125         if (s == -1) {
126                 ret = -errno;
127                 DRV_LOG(ERR, "cannot open socket: %s", rte_strerror(errno));
128                 goto error;
129         }
130         for (i = 0; iface[i].if_name; ++i) {
131                 struct ifreq req;
132                 struct ether_addr eth_addr;
133                 va_list ap;
134
135                 strncpy(req.ifr_name, iface[i].if_name, sizeof(req.ifr_name));
136                 if (ioctl(s, SIOCGIFHWADDR, &req) == -1) {
137                         DRV_LOG(WARNING, "cannot retrieve information about"
138                                          " interface \"%s\": %s",
139                                          req.ifr_name, rte_strerror(errno));
140                         continue;
141                 }
142                 if (req.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
143                         DRV_LOG(DEBUG, "interface %s is non-ethernet device",
144                                 req.ifr_name);
145                         continue;
146                 }
147                 memcpy(eth_addr.addr_bytes, req.ifr_hwaddr.sa_data,
148                        RTE_DIM(eth_addr.addr_bytes));
149                 va_start(ap, func);
150                 ret = func(&iface[i], &eth_addr, ap);
151                 va_end(ap);
152                 if (ret)
153                         break;
154         }
155 error:
156         if (s != -1)
157                 close(s);
158         if (iface)
159                 if_freenameindex(iface);
160         return ret;
161 }
162
163 /**
164  * Determine if a network interface is NetVSC.
165  *
166  * @param[in] iface
167  *   Pointer to netdevice description structure (name and index).
168  *
169  * @return
170  *   A nonzero value when interface is detected as NetVSC. In case of error,
171  *   rte_errno is updated and 0 returned.
172  */
173 static int
174 vdev_netvsc_iface_is_netvsc(const struct if_nameindex *iface)
175 {
176         static const char temp[] = "/sys/class/net/%s/device/class_id";
177         char path[sizeof(temp) + IF_NAMESIZE];
178         FILE *f;
179         int ret;
180         int len = 0;
181
182         ret = snprintf(path, sizeof(path), temp, iface->if_name);
183         if (ret == -1 || (size_t)ret >= sizeof(path)) {
184                 rte_errno = ENOBUFS;
185                 return 0;
186         }
187         f = fopen(path, "r");
188         if (!f) {
189                 rte_errno = errno;
190                 return 0;
191         }
192         ret = fscanf(f, NETVSC_CLASS_ID "%n", &len);
193         if (ret == EOF)
194                 rte_errno = errno;
195         ret = len == (int)strlen(NETVSC_CLASS_ID);
196         fclose(f);
197         return ret;
198 }
199
200 /**
201  * Retrieve network interface data from sysfs symbolic link.
202  *
203  * @param[out] buf
204  *   Output data buffer.
205  * @param size
206  *   Output buffer size.
207  * @param[in] if_name
208  *   Netdevice name.
209  * @param[in] relpath
210  *   Symbolic link path relative to netdevice sysfs entry.
211  *
212  * @return
213  *   0 on success, a negative error code otherwise.
214  */
215 static int
216 vdev_netvsc_sysfs_readlink(char *buf, size_t size, const char *if_name,
217                            const char *relpath)
218 {
219         int ret;
220
221         ret = snprintf(buf, size, "/sys/class/net/%s/%s", if_name, relpath);
222         if (ret == -1 || (size_t)ret >= size)
223                 return -ENOBUFS;
224         ret = readlink(buf, buf, size);
225         if (ret == -1)
226                 return -errno;
227         if ((size_t)ret >= size - 1)
228                 return -ENOBUFS;
229         buf[ret] = '\0';
230         return 0;
231 }
232
233 /**
234  * Probe a network interface to associate with vdev_netvsc context.
235  *
236  * This function determines if the network device matches the properties of
237  * the NetVSC interface associated with the vdev_netvsc context and
238  * communicates its bus address to the fail-safe PMD instance if so.
239  *
240  * It is normally used with vdev_netvsc_foreach_iface().
241  *
242  * @param[in] iface
243  *   Pointer to netdevice description structure (name and index).
244  * @param[in] eth_addr
245  *   MAC address associated with @p iface.
246  * @param ap
247  *   Variable arguments list comprising:
248  *
249  *   - struct vdev_netvsc_ctx *ctx:
250  *     Context to associate network interface with.
251  *
252  * @return
253  *   A nonzero value when interface matches, 0 otherwise or in case of
254  *   error.
255  */
256 static int
257 vdev_netvsc_device_probe(const struct if_nameindex *iface,
258                     const struct ether_addr *eth_addr,
259                     va_list ap)
260 {
261         struct vdev_netvsc_ctx *ctx = va_arg(ap, struct vdev_netvsc_ctx *);
262         char buf[RTE_MAX(sizeof(ctx->yield), 256u)];
263         const char *addr;
264         size_t len;
265         int ret;
266
267         /* Skip non-matching or unwanted NetVSC interfaces. */
268         if (ctx->if_index == iface->if_index) {
269                 if (!strcmp(ctx->if_name, iface->if_name))
270                         return 0;
271                 DRV_LOG(DEBUG,
272                         "NetVSC interface \"%s\" (index %u) renamed \"%s\"",
273                         ctx->if_name, ctx->if_index, iface->if_name);
274                 strncpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name));
275                 return 0;
276         }
277         if (vdev_netvsc_iface_is_netvsc(iface))
278                 return 0;
279         if (!is_same_ether_addr(eth_addr, &ctx->if_addr))
280                 return 0;
281         /* Look for associated PCI device. */
282         ret = vdev_netvsc_sysfs_readlink(buf, sizeof(buf), iface->if_name,
283                                          "device/subsystem");
284         if (ret)
285                 return 0;
286         addr = strrchr(buf, '/');
287         addr = addr ? addr + 1 : buf;
288         if (strcmp(addr, "pci"))
289                 return 0;
290         ret = vdev_netvsc_sysfs_readlink(buf, sizeof(buf), iface->if_name,
291                                          "device");
292         if (ret)
293                 return 0;
294         addr = strrchr(buf, '/');
295         addr = addr ? addr + 1 : buf;
296         len = strlen(addr);
297         if (!len)
298                 return 0;
299         /* Send PCI device argument to fail-safe PMD instance. */
300         if (strcmp(addr, ctx->yield))
301                 DRV_LOG(DEBUG, "associating PCI device \"%s\" with NetVSC"
302                         " interface \"%s\" (index %u)", addr, ctx->if_name,
303                         ctx->if_index);
304         memmove(buf, addr, len + 1);
305         addr = buf;
306         buf[len] = '\n';
307         ret = write(ctx->pipe[1], addr, len + 1);
308         buf[len] = '\0';
309         if (ret == -1) {
310                 if (errno == EINTR || errno == EAGAIN)
311                         return 1;
312                 DRV_LOG(WARNING, "cannot associate PCI device name \"%s\" with"
313                         " interface \"%s\": %s", addr, ctx->if_name,
314                         rte_strerror(errno));
315                 return 1;
316         }
317         if ((size_t)ret != len + 1) {
318                 /*
319                  * Attempt to override previous partial write, no need to
320                  * recover if that fails.
321                  */
322                 ret = write(ctx->pipe[1], "\n", 1);
323                 (void)ret;
324                 return 1;
325         }
326         fsync(ctx->pipe[1]);
327         memcpy(ctx->yield, addr, len + 1);
328         return 1;
329 }
330
331 /**
332  * Alarm callback that regularly probes system network interfaces.
333  *
334  * This callback runs at a frequency determined by VDEV_NETVSC_PROBE_MS as
335  * long as an vdev_netvsc context instance exists.
336  *
337  * @param arg
338  *   Ignored.
339  */
340 static void
341 vdev_netvsc_alarm(__rte_unused void *arg)
342 {
343         struct vdev_netvsc_ctx *ctx;
344         int ret;
345
346         LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) {
347                 ret = vdev_netvsc_foreach_iface(vdev_netvsc_device_probe, ctx);
348                 if (ret)
349                         break;
350         }
351         if (!vdev_netvsc_ctx_count)
352                 return;
353         ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000,
354                                 vdev_netvsc_alarm, NULL);
355         if (ret < 0) {
356                 DRV_LOG(ERR, "unable to reschedule alarm callback: %s",
357                         rte_strerror(-ret));
358         }
359 }
360
361 /**
362  * Probe a NetVSC interface to generate a vdev_netvsc context from.
363  *
364  * This function instantiates vdev_netvsc contexts either for all NetVSC
365  * devices found on the system or only a subset provided as device
366  * arguments.
367  *
368  * It is normally used with vdev_netvsc_foreach_iface().
369  *
370  * @param[in] iface
371  *   Pointer to netdevice description structure (name and index).
372  * @param[in] eth_addr
373  *   MAC address associated with @p iface.
374  * @param ap
375  *   Variable arguments list comprising:
376  *
377  *   - const char *name:
378  *     Name associated with current driver instance.
379  *
380  *   - struct rte_kvargs *kvargs:
381  *     Device arguments provided to current driver instance.
382  *
383  *   - unsigned int specified:
384  *     Number of specific netdevices provided as device arguments.
385  *
386  *   - unsigned int *matched:
387  *     The number of specified netdevices matched by this function.
388  *
389  * @return
390  *   A nonzero value when interface matches, 0 otherwise or in case of
391  *   error.
392  */
393 static int
394 vdev_netvsc_netvsc_probe(const struct if_nameindex *iface,
395                          const struct ether_addr *eth_addr,
396                          va_list ap)
397 {
398         const char *name = va_arg(ap, const char *);
399         struct rte_kvargs *kvargs = va_arg(ap, struct rte_kvargs *);
400         unsigned int specified = va_arg(ap, unsigned int);
401         unsigned int *matched = va_arg(ap, unsigned int *);
402         unsigned int i;
403         struct vdev_netvsc_ctx *ctx;
404         int ret;
405
406         /* Probe all interfaces when none are specified. */
407         if (specified) {
408                 for (i = 0; i != kvargs->count; ++i) {
409                         const struct rte_kvargs_pair *pair = &kvargs->pairs[i];
410
411                         if (!strcmp(pair->key, VDEV_NETVSC_ARG_IFACE)) {
412                                 if (!strcmp(pair->value, iface->if_name))
413                                         break;
414                         } else if (!strcmp(pair->key, VDEV_NETVSC_ARG_MAC)) {
415                                 struct ether_addr tmp;
416
417                                 if (sscanf(pair->value,
418                                            "%" SCNx8 ":%" SCNx8 ":%" SCNx8 ":"
419                                            "%" SCNx8 ":%" SCNx8 ":%" SCNx8,
420                                            &tmp.addr_bytes[0],
421                                            &tmp.addr_bytes[1],
422                                            &tmp.addr_bytes[2],
423                                            &tmp.addr_bytes[3],
424                                            &tmp.addr_bytes[4],
425                                            &tmp.addr_bytes[5]) != 6) {
426                                         DRV_LOG(ERR,
427                                                 "invalid MAC address format"
428                                                 " \"%s\"",
429                                                 pair->value);
430                                         return -EINVAL;
431                                 }
432                                 if (is_same_ether_addr(eth_addr, &tmp))
433                                         break;
434                         }
435                 }
436                 if (i == kvargs->count)
437                         return 0;
438                 ++(*matched);
439         }
440         /* Weed out interfaces already handled. */
441         LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry)
442                 if (ctx->if_index == iface->if_index)
443                         break;
444         if (ctx) {
445                 if (!specified)
446                         return 0;
447                 DRV_LOG(WARNING,
448                         "interface \"%s\" (index %u) is already handled,"
449                         " skipping",
450                         iface->if_name, iface->if_index);
451                 return 0;
452         }
453         if (!vdev_netvsc_iface_is_netvsc(iface)) {
454                 if (!specified)
455                         return 0;
456                 DRV_LOG(WARNING,
457                         "interface \"%s\" (index %u) is not NetVSC,"
458                         " skipping",
459                         iface->if_name, iface->if_index);
460                 return 0;
461         }
462         /* Create interface context. */
463         ctx = calloc(1, sizeof(*ctx));
464         if (!ctx) {
465                 ret = -errno;
466                 DRV_LOG(ERR, "cannot allocate context for interface \"%s\": %s",
467                         iface->if_name, rte_strerror(errno));
468                 goto error;
469         }
470         ctx->id = vdev_netvsc_ctx_count;
471         strncpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name));
472         ctx->if_index = iface->if_index;
473         ctx->if_addr = *eth_addr;
474         ctx->pipe[0] = -1;
475         ctx->pipe[1] = -1;
476         ctx->yield[0] = '\0';
477         if (pipe(ctx->pipe) == -1) {
478                 ret = -errno;
479                 DRV_LOG(ERR,
480                         "cannot allocate control pipe for interface \"%s\": %s",
481                         ctx->if_name, rte_strerror(errno));
482                 goto error;
483         }
484         for (i = 0; i != RTE_DIM(ctx->pipe); ++i) {
485                 int flf = fcntl(ctx->pipe[i], F_GETFL);
486
487                 if (flf != -1 &&
488                     fcntl(ctx->pipe[i], F_SETFL, flf | O_NONBLOCK) != -1)
489                         continue;
490                 ret = -errno;
491                 DRV_LOG(ERR, "cannot toggle non-blocking flag on control file"
492                         " descriptor #%u (%d): %s", i, ctx->pipe[i],
493                         rte_strerror(errno));
494                 goto error;
495         }
496         /* Generate virtual device name and arguments. */
497         i = 0;
498         ret = snprintf(ctx->name, sizeof(ctx->name), "%s_id%u",
499                        name, ctx->id);
500         if (ret == -1 || (size_t)ret >= sizeof(ctx->name))
501                 ++i;
502         ret = snprintf(ctx->devname, sizeof(ctx->devname), "net_failsafe_%s",
503                        ctx->name);
504         if (ret == -1 || (size_t)ret >= sizeof(ctx->devname))
505                 ++i;
506         ret = snprintf(ctx->devargs, sizeof(ctx->devargs),
507                        "fd(%d),dev(net_tap_%s,remote=%s)",
508                        ctx->pipe[0], ctx->name, ctx->if_name);
509         if (ret == -1 || (size_t)ret >= sizeof(ctx->devargs))
510                 ++i;
511         if (i) {
512                 ret = -ENOBUFS;
513                 DRV_LOG(ERR, "generated virtual device name or argument list"
514                         " too long for interface \"%s\"", ctx->if_name);
515                 goto error;
516         }
517         /* Request virtual device generation. */
518         DRV_LOG(DEBUG, "generating virtual device \"%s\" with arguments \"%s\"",
519                 ctx->devname, ctx->devargs);
520         vdev_netvsc_foreach_iface(vdev_netvsc_device_probe, ctx);
521         ret = rte_eal_hotplug_add("vdev", ctx->devname, ctx->devargs);
522         if (ret)
523                 goto error;
524         LIST_INSERT_HEAD(&vdev_netvsc_ctx_list, ctx, entry);
525         ++vdev_netvsc_ctx_count;
526         DRV_LOG(DEBUG, "added NetVSC interface \"%s\" to context list",
527                 ctx->if_name);
528         return 0;
529 error:
530         if (ctx)
531                 vdev_netvsc_ctx_destroy(ctx);
532         return ret;
533 }
534
535 /**
536  * Probe NetVSC interfaces.
537  *
538  * This function probes system netdevices according to the specified device
539  * arguments and starts a periodic alarm callback to notify the resulting
540  * fail-safe PMD instances of their sub-devices whereabouts.
541  *
542  * @param dev
543  *   Virtual device context for driver instance.
544  *
545  * @return
546  *    Always 0, even in case of errors.
547  */
548 static int
549 vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
550 {
551         static const char *const vdev_netvsc_arg[] = {
552                 VDEV_NETVSC_ARG_IFACE,
553                 VDEV_NETVSC_ARG_MAC,
554                 NULL,
555         };
556         const char *name = rte_vdev_device_name(dev);
557         const char *args = rte_vdev_device_args(dev);
558         struct rte_kvargs *kvargs = rte_kvargs_parse(args ? args : "",
559                                                      vdev_netvsc_arg);
560         unsigned int specified = 0;
561         unsigned int matched = 0;
562         unsigned int i;
563         int ret;
564
565         DRV_LOG(DEBUG, "invoked as \"%s\", using arguments \"%s\"", name, args);
566         if (!kvargs) {
567                 DRV_LOG(ERR, "cannot parse arguments list");
568                 goto error;
569         }
570         for (i = 0; i != kvargs->count; ++i) {
571                 const struct rte_kvargs_pair *pair = &kvargs->pairs[i];
572
573                 if (!strcmp(pair->key, VDEV_NETVSC_ARG_IFACE) ||
574                     !strcmp(pair->key, VDEV_NETVSC_ARG_MAC))
575                         ++specified;
576         }
577         rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL);
578         /* Gather interfaces. */
579         ret = vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, name, kvargs,
580                                         specified, &matched);
581         if (ret < 0)
582                 goto error;
583         if (matched < specified)
584                 DRV_LOG(WARNING,
585                         "some of the specified parameters did not match"
586                         " recognized network interfaces");
587         ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000,
588                                 vdev_netvsc_alarm, NULL);
589         if (ret < 0) {
590                 DRV_LOG(ERR, "unable to schedule alarm callback: %s",
591                         rte_strerror(-ret));
592                 goto error;
593         }
594 error:
595         if (kvargs)
596                 rte_kvargs_free(kvargs);
597         ++vdev_netvsc_ctx_inst;
598         return 0;
599 }
600
601 /**
602  * Remove driver instance.
603  *
604  * The alarm callback and underlying vdev_netvsc context instances are only
605  * destroyed after the last PMD instance is removed.
606  *
607  * @param dev
608  *   Virtual device context for driver instance.
609  *
610  * @return
611  *   Always 0.
612  */
613 static int
614 vdev_netvsc_vdev_remove(__rte_unused struct rte_vdev_device *dev)
615 {
616         if (--vdev_netvsc_ctx_inst)
617                 return 0;
618         rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL);
619         while (!LIST_EMPTY(&vdev_netvsc_ctx_list)) {
620                 struct vdev_netvsc_ctx *ctx = LIST_FIRST(&vdev_netvsc_ctx_list);
621
622                 LIST_REMOVE(ctx, entry);
623                 --vdev_netvsc_ctx_count;
624                 vdev_netvsc_ctx_destroy(ctx);
625         }
626         return 0;
627 }
628
629 /** Virtual device descriptor. */
630 static struct rte_vdev_driver vdev_netvsc_vdev = {
631         .probe = vdev_netvsc_vdev_probe,
632         .remove = vdev_netvsc_vdev_remove,
633 };
634
635 RTE_PMD_REGISTER_VDEV(VDEV_NETVSC_DRIVER, vdev_netvsc_vdev);
636 RTE_PMD_REGISTER_ALIAS(VDEV_NETVSC_DRIVER, eth_vdev_netvsc);
637 RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
638                               VDEV_NETVSC_ARG_IFACE "=<string> "
639                               VDEV_NETVSC_ARG_MAC "=<string>");
640
641 /** Initialize driver log type. */
642 RTE_INIT(vdev_netvsc_init_log)
643 {
644         vdev_netvsc_logtype = rte_log_register("pmd.vdev_netvsc");
645         if (vdev_netvsc_logtype >= 0)
646                 rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE);
647 }