vfio: support VF token
[dpdk.git] / lib / librte_eal / linux / eal.c
index 3b56d14..d6b8d8b 100644 (file)
@@ -540,6 +540,7 @@ eal_usage(const char *prgname)
               "  --"OPT_FILE_PREFIX"       Prefix for hugepage filenames\n"
               "  --"OPT_CREATE_UIO_DEV"    Create /dev/uioX (usually done by hotplug)\n"
               "  --"OPT_VFIO_INTR"         Interrupt mode for VFIO (legacy|msi|msix)\n"
+              "  --"OPT_VFIO_VF_TOKEN"     VF token (UUID) shared between SR-IOV PF and VFs\n"
               "  --"OPT_LEGACY_MEM"        Legacy memory mode (no dynamic allocation, contiguous segments)\n"
               "  --"OPT_SINGLE_FILE_SEGMENTS" Put all hugepage memory in single files\n"
               "  --"OPT_MATCH_ALLOCATIONS" Free hugepages exactly as allocated\n"
@@ -620,6 +621,20 @@ eal_parse_vfio_intr(const char *mode)
        return -1;
 }
 
+static int
+eal_parse_vfio_vf_token(const char *vf_token)
+{
+       struct internal_config *cfg = eal_get_internal_configuration();
+       rte_uuid_t uuid;
+
+       if (!rte_uuid_parse(vf_token, uuid)) {
+               rte_uuid_copy(cfg->vfio_vf_token, uuid);
+               return 0;
+       }
+
+       return -1;
+}
+
 /* Parse the arguments for --log-level only */
 static void
 eal_log_level_parse(int argc, char **argv)
@@ -762,6 +777,16 @@ eal_parse_args(int argc, char **argv)
                        }
                        break;
 
+               case OPT_VFIO_VF_TOKEN_NUM:
+                       if (eal_parse_vfio_vf_token(optarg) < 0) {
+                               RTE_LOG(ERR, EAL, "invalid parameters for --"
+                                               OPT_VFIO_VF_TOKEN "\n");
+                               eal_usage(prgname);
+                               ret = -1;
+                               goto out;
+                       }
+                       break;
+
                case OPT_CREATE_UIO_DEV_NUM:
                        internal_conf->create_uio_dev = 1;
                        break;
@@ -1342,6 +1367,14 @@ rte_eal_vfio_intr_mode(void)
        return internal_conf->vfio_intr_mode;
 }
 
+void
+rte_eal_vfio_get_vf_token(rte_uuid_t vf_token)
+{
+       struct internal_config *cfg = eal_get_internal_configuration();
+
+       rte_uuid_copy(vf_token, cfg->vfio_vf_token);
+}
+
 int
 rte_eal_check_module(const char *module_name)
 {