From: Rajesh Ravi <rajesh.r...@broadcom.com> Support external custom memory added to heap to be used with vfio with --iso-cmem option.Type1 memory mapping was by passed for external memory. But an exception is added to allow external custom memory to be used with vfio.
Signed-off-by: Rajesh Ravi <rajesh.r...@broadcom.com> Reviewed-by: Jonathan Richardson <jonathan.richard...@broadcom.com> Reviewed-by: Scott Branden <scott.bran...@broadcom.com> Reviewed-by: Vikram Mysore Prakash <vikram.prak...@broadcom.com> Reviewed-by: Ajit Khaparde <ajit.khapa...@broadcom.com> --- lib/librte_eal/common/eal_common_options.c | 5 +++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 ++ lib/librte_eal/linux/eal/eal_vfio.c | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 05cae5f75..b46fb3870 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -78,6 +78,7 @@ eal_long_options[] = { {OPT_VDEV, 1, NULL, OPT_VDEV_NUM }, {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM }, {OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM }, + {OPT_ISO_CMEM, 0, NULL, OPT_ISO_CMEM_NUM }, {OPT_LEGACY_MEM, 0, NULL, OPT_LEGACY_MEM_NUM }, {OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM}, {OPT_MATCH_ALLOCATIONS, 0, NULL, OPT_MATCH_ALLOCATIONS_NUM}, @@ -1327,6 +1328,10 @@ eal_parse_common_option(int opt, const char *optarg, conf->no_hpet = 1; break; + case OPT_ISO_CMEM_NUM: + conf->iso_cmem = 1; + break; + case OPT_VMWARE_TSC_MAP_NUM: conf->vmware_tsc_map = 1; break; diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h index a42f34923..fb64b5f79 100644 --- a/lib/librte_eal/common/eal_internal_cfg.h +++ b/lib/librte_eal/common/eal_internal_cfg.h @@ -43,6 +43,7 @@ struct internal_config { volatile unsigned no_hugetlbfs; /**< true to disable hugetlbfs */ unsigned hugepage_unlink; /**< true to unlink backing files */ volatile unsigned no_pci; /**< true to disable PCI */ + unsigned int iso_cmem; /**< true to enable isolated cmem */ volatile unsigned no_hpet; /**< true to disable HPET */ volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping * instead of native TSC */ diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index 9855429e5..f56e2536b 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -61,6 +61,8 @@ enum { OPT_VFIO_INTR_NUM, #define OPT_VMWARE_TSC_MAP "vmware-tsc-map" OPT_VMWARE_TSC_MAP_NUM, +#define OPT_ISO_CMEM "iso-cmem" + OPT_ISO_CMEM_NUM, #define OPT_LEGACY_MEM "legacy-mem" OPT_LEGACY_MEM_NUM, #define OPT_SINGLE_FILE_SEGMENTS "single-file-segments" diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c index 501c74f23..8fbad63cc 100644 --- a/lib/librte_eal/linux/eal/eal_vfio.c +++ b/lib/librte_eal/linux/eal/eal_vfio.c @@ -1250,7 +1250,7 @@ type1_map(const struct rte_memseg_list *msl, const struct rte_memseg *ms, { int *vfio_container_fd = arg; - if (msl->external) + if (msl->external & !internal_config.iso_cmem) return 0; return vfio_type1_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova, -- 2.20.1 (Apple Git-117)