summaryrefslogtreecommitdiff
path: root/examples/vm_power_manager
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2018-04-05 17:33:20 +0200
committerThomas Monjalon <thomas@monjalon.net>2018-04-18 00:25:27 +0200
commit8728ccf37615904cf23fb8763895b05c9a3c6b0c (patch)
treeb6e895ec425d20d4933115f533da4be189be1f8a /examples/vm_power_manager
parenta3d6026711d00183e308f1dd79933f6161840e04 (diff)
downloaddpdk-8728ccf37615904cf23fb8763895b05c9a3c6b0c.zip
dpdk-8728ccf37615904cf23fb8763895b05c9a3c6b0c.tar.gz
dpdk-8728ccf37615904cf23fb8763895b05c9a3c6b0c.tar.xz
fix ethdev ports enumeration
Some DPDK applications wrongly assume these requirements: - no hotplug, i.e. ports are never detached - all allocated ports are available to the application Such application iterates over ports by its own mean. The most common pattern is to request the port count and assume ports with index in the range [0..count[ can be used. There are three consequences when using such wrong design: - new ports having an index higher than the port count won't be seen - old ports being detached (RTE_ETH_DEV_UNUSED) can be seen as ghosts - failsafe sub-devices (RTE_ETH_DEV_DEFERRED) will be seen by the application Such mistake will be less common with growing hotplug awareness. All applications and examples inside this repository - except testpmd - must be fixed to use the iterator RTE_ETH_FOREACH_DEV. Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Diffstat (limited to 'examples/vm_power_manager')
-rw-r--r--examples/vm_power_manager/Makefile1
-rw-r--r--examples/vm_power_manager/channel_monitor.c5
-rw-r--r--examples/vm_power_manager/main.c8
3 files changed, 7 insertions, 7 deletions
diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile
index ef2a9f9..608d0d9 100644
--- a/examples/vm_power_manager/Makefile
+++ b/examples/vm_power_manager/Makefile
@@ -21,6 +21,7 @@ APP = vm_power_mgr
SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c
SRCS-y += channel_monitor.c
+CFLAGS += -DALLOW_EXPERIMENTAL_API
CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/
CFLAGS += $(WERROR_FLAGS)
diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c
index 1c7b6eb..73bddd9 100644
--- a/examples/vm_power_manager/channel_monitor.c
+++ b/examples/vm_power_manager/channel_monitor.c
@@ -110,12 +110,11 @@ static int
get_pfid(struct policy *pol)
{
- int i, x, ret = 0, nb_ports;
+ int i, x, ret = 0;
- nb_ports = rte_eth_dev_count();
for (i = 0; i < pol->pkt.nb_mac_to_monitor; i++) {
- for (x = 0; x < nb_ports; x++) {
+ RTE_ETH_FOREACH_DEV(x) {
ret = rte_pmd_i40e_query_vfid_by_mac(x,
(struct ether_addr *)&(pol->pkt.vfid[i]));
if (ret != -EINVAL) {
diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
index 8a1e95b..4cde828 100644
--- a/examples/vm_power_manager/main.c
+++ b/examples/vm_power_manager/main.c
@@ -176,7 +176,7 @@ parse_args(int argc, char **argv)
}
static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
{
#define CHECK_INTERVAL 100 /* 100ms */
#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -189,7 +189,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
if (force_quit)
return;
all_ports_up = 1;
- for (portid = 0; portid < port_num; portid++) {
+ RTE_ETH_FOREACH_DEV(portid) {
if (force_quit)
return;
if ((port_mask & (1 << portid)) == 0)
@@ -287,7 +287,7 @@ main(int argc, char **argv)
rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
/* Initialize ports. */
- for (portid = 0; portid < nb_ports; portid++) {
+ RTE_ETH_FOREACH_DEV(portid) {
struct ether_addr eth;
int w, j;
int ret;
@@ -339,7 +339,7 @@ main(int argc, char **argv)
return 0;
}
- check_all_ports_link_status(nb_ports, enabled_port_mask);
+ check_all_ports_link_status(enabled_port_mask);
rte_eal_remote_launch(run_monitor, NULL, lcore_id);
if (power_manager_init() < 0) {