eal: add --iova-mode option
authorSantosh Shukla <santosh.shukla@caviumnetworks.com>
Wed, 3 Oct 2018 20:53:12 +0000 (16:53 -0400)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 28 Oct 2018 22:41:26 +0000 (23:41 +0100)
In the case of user don't want to use bus iova scheme and want
to override.

For that, adding EAL option --iova-mode=<string> where valid input
string is 'pa' or 'va'.

Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Eric Zhang <eric.zhang@windriver.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/common/eal_common_options.c
lib/librte_eal/common/eal_internal_cfg.h
lib/librte_eal/common/eal_options.h

index ddd6241..b82f3dd 100644 (file)
@@ -58,6 +58,7 @@ eal_long_options[] = {
        {OPT_HELP,              0, NULL, OPT_HELP_NUM             },
        {OPT_HUGE_DIR,          1, NULL, OPT_HUGE_DIR_NUM         },
        {OPT_HUGE_UNLINK,       0, NULL, OPT_HUGE_UNLINK_NUM      },
+       {OPT_IOVA_MODE,         1, NULL, OPT_IOVA_MODE_NUM        },
        {OPT_LCORES,            1, NULL, OPT_LCORES_NUM           },
        {OPT_LOG_LEVEL,         1, NULL, OPT_LOG_LEVEL_NUM        },
        {OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
@@ -205,6 +206,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg)
 #endif
        internal_cfg->vmware_tsc_map = 0;
        internal_cfg->create_uio_dev = 0;
+       internal_cfg->iova_mode = RTE_IOVA_DC;
        internal_cfg->user_mbuf_pool_ops_name = NULL;
        internal_cfg->init_complete = 0;
 }
@@ -1075,6 +1077,25 @@ eal_parse_proc_type(const char *arg)
        return RTE_PROC_INVALID;
 }
 
+static int
+eal_parse_iova_mode(const char *name)
+{
+       int mode;
+
+       if (name == NULL)
+               return -1;
+
+       if (!strcmp("pa", name))
+               mode = RTE_IOVA_PA;
+       else if (!strcmp("va", name))
+               mode = RTE_IOVA_VA;
+       else
+               return -1;
+
+       internal_config.iova_mode = mode;
+       return 0;
+}
+
 int
 eal_parse_common_option(int opt, const char *optarg,
                        struct internal_config *conf)
@@ -1281,6 +1302,13 @@ eal_parse_common_option(int opt, const char *optarg,
        case OPT_SINGLE_FILE_SEGMENTS_NUM:
                conf->single_file_segments = 1;
                break;
+       case OPT_IOVA_MODE_NUM:
+               if (eal_parse_iova_mode(optarg) < 0) {
+                       RTE_LOG(ERR, EAL, "invalid parameters for --"
+                               OPT_IOVA_MODE "\n");
+                       return -1;
+               }
+               break;
 
        /* don't know what to do, leave this to caller */
        default:
@@ -1434,6 +1462,8 @@ eal_common_usage(void)
               "  --"OPT_VDEV"              Add a virtual device.\n"
               "                      The argument format is <driver><id>[,key=val,...]\n"
               "                      (ex: --vdev=net_pcap0,iface=eth2).\n"
+              "  --"OPT_IOVA_MODE"   Set IOVA mode. 'pa' for IOVA_PA\n"
+              "                      'va' for IOVA_VA\n"
               "  -d LIB.so|DIR       Add a driver or driver directory\n"
               "                      (can be used multiple times)\n"
               "  --"OPT_VMWARE_TSC_MAP"    Use VMware TSC map instead of native RDTSC\n"
index 00ee6e0..737f17e 100644 (file)
@@ -70,6 +70,7 @@ struct internal_config {
                        /**< user defined mbuf pool ops name */
        unsigned num_hugepage_sizes;      /**< how many sizes on this system */
        struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES];
+       enum rte_iova_mode iova_mode ;    /**< Set IOVA mode on this system  */
        volatile unsigned int init_complete;
        /**< indicates whether EAL has completed initialization */
 };
index 96e1667..5271f94 100644 (file)
@@ -63,6 +63,8 @@ enum {
        OPT_LEGACY_MEM_NUM,
 #define OPT_SINGLE_FILE_SEGMENTS    "single-file-segments"
        OPT_SINGLE_FILE_SEGMENTS_NUM,
+#define OPT_IOVA_MODE          "iova-mode"
+       OPT_IOVA_MODE_NUM,
        OPT_LONG_MAX_NUM
 };