summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Marchand <david.marchand@6wind.com>2014-08-26 16:11:39 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-09-29 14:39:09 +0200
commit565b85dcd9f48e47e7607086dddaa34f8b3c0b1c (patch)
treeb03be969b12252dc24860de43827e2b4e10f275c
parent8a312224bcdeb45a36685b7c517c12d00683b24d (diff)
downloaddpdk-565b85dcd9f48e47e7607086dddaa34f8b3c0b1c.zip
dpdk-565b85dcd9f48e47e7607086dddaa34f8b3c0b1c.tar.gz
dpdk-565b85dcd9f48e47e7607086dddaa34f8b3c0b1c.tar.xz
eal: set iopl only when needed
There is no need for ioport access for applications that won't use virtio pmds. Make rte_eal_iopl_init() non-static so that it is called from pmds that need it. Signed-off-by: David Marchand <david.marchand@6wind.com> Acked-by: Huawei Xie <huawei.xie@intel.com> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
-rw-r--r--lib/librte_eal/bsdapp/eal/eal.c5
-rw-r--r--lib/librte_eal/common/include/rte_eal.h14
-rw-r--r--lib/librte_eal/linuxapp/eal/eal.c11
-rw-r--r--lib/librte_pmd_virtio/virtio_ethdev.c14
4 files changed, 23 insertions, 21 deletions
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index ae21e28..c40a59a 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -490,7 +490,7 @@ int rte_eal_has_hugepages(void)
}
/* Abstraction for port I/0 privilege */
-static int
+int
rte_eal_iopl_init(void)
{
int fd = -1;
@@ -551,9 +551,6 @@ rte_eal_init(int argc, char **argv)
rte_config_init();
- if (rte_eal_iopl_init() == 0)
- rte_config.flags |= EAL_FLG_HIGH_IOPL;
-
if (rte_eal_cpu_init() < 0)
rte_panic("Cannot detect lcores\n");
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index 273da9a..8d39cba 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -88,9 +88,6 @@ struct rte_config {
struct rte_mem_config *mem_config;
} __attribute__((__packed__));
-/* Flag definitions for rte_config flags */
-#define EAL_FLG_HIGH_IOPL 1 /**< indicates high IO privilege in a linux env */
-
/**
* Get the global configuration structure.
*
@@ -119,6 +116,17 @@ enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
enum rte_proc_type_t rte_eal_process_type(void);
/**
+ * Request iopl privilege for all RPL.
+ *
+ * This function should be called by pmds which need access to ioports.
+
+ * @return
+ * - On success, returns 0.
+ * - On failure, returns -1.
+ */
+int rte_eal_iopl_init(void);
+
+/**
* Initialize the Environment Abstraction Layer (EAL).
*
* This function is to be executed on the MASTER lcore only, as soon
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 6c8e760..7a1d087 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -87,8 +87,6 @@
#define SOCKET_MEM_STRLEN (RTE_MAX_NUMA_NODES * 10)
-#define HIGHEST_RPL 3
-
/* Allow the application to print its usage message too if set */
static rte_usage_hook_t rte_application_usage_hook = NULL;
@@ -755,10 +753,12 @@ rte_eal_mcfg_complete(void)
/*
* Request iopl privilege for all RPL, returns 0 on success
*/
-static int
+int
rte_eal_iopl_init(void)
{
- return iopl(HIGHEST_RPL);
+ if (iopl(3) != 0)
+ return -1;
+ return 0;
}
/* Launch threads, called at application init(). */
@@ -820,9 +820,6 @@ rte_eal_init(int argc, char **argv)
rte_config_init();
- if (rte_eal_iopl_init() == 0)
- rte_config.flags |= EAL_FLG_HIGH_IOPL;
-
if (rte_eal_pci_init() < 0)
rte_panic("Cannot init PCI\n");
diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c b/lib/librte_pmd_virtio/virtio_ethdev.c
index 3344ffb..19930c0 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -736,12 +736,6 @@ eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv,
return -1;
}
- if (!(rte_eal_get_configuration()->flags & EAL_FLG_HIGH_IOPL)) {
- PMD_INIT_LOG(ERR,
- "IOPL call failed in EAL init - cannot use virtio PMD driver\n");
- return -1;
- }
-
eth_dev->dev_ops = &virtio_eth_dev_ops;
eth_dev->tx_pkt_burst = &virtio_xmit_pkts;
@@ -896,8 +890,14 @@ static struct eth_driver rte_virtio_pmd = {
* Returns 0 on success.
*/
static int
-rte_virtio_pmd_init(const char *name __rte_unused, const char *param __rte_unused)
+rte_virtio_pmd_init(const char *name __rte_unused,
+ const char *param __rte_unused)
{
+ if (rte_eal_iopl_init() != 0) {
+ PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
+ return -1;
+ }
+
rte_eth_driver_register(&rte_virtio_pmd);
return 0;
}