common/sfc_efx/base: allow creating invalid mport selectors
[dpdk.git] / examples / l3fwd-power / main.c
index 52f56dc..be0d4f1 100644 (file)
@@ -24,7 +24,6 @@
 #include <rte_memcpy.h>
 #include <rte_eal.h>
 #include <rte_launch.h>
-#include <rte_atomic.h>
 #include <rte_cycles.h>
 #include <rte_prefetch.h>
 #include <rte_lcore.h>
@@ -207,6 +206,7 @@ enum appmode {
 enum appmode app_mode;
 
 static enum rte_power_pmd_mgmt_type pmgmt_type;
+bool baseline_enabled;
 
 enum freq_scale_hint_t
 {
@@ -716,7 +716,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
                        dst_port = portid;
 
                /* 02:00:00:00:00:xx */
-               d_addr_bytes = &eth_hdr->d_addr.addr_bytes[0];
+               d_addr_bytes = &eth_hdr->dst_addr.addr_bytes[0];
                *((uint64_t *)d_addr_bytes) =
                        0x000000000002 + ((uint64_t)dst_port << 40);
 
@@ -728,7 +728,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
 
                /* src addr */
                rte_ether_addr_copy(&ports_eth_addr[dst_port],
-                               &eth_hdr->s_addr);
+                               &eth_hdr->src_addr);
 
                send_single_packet(m, dst_port);
        } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
@@ -748,13 +748,13 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
                        dst_port = portid;
 
                /* 02:00:00:00:00:xx */
-               d_addr_bytes = &eth_hdr->d_addr.addr_bytes[0];
+               d_addr_bytes = &eth_hdr->dst_addr.addr_bytes[0];
                *((uint64_t *)d_addr_bytes) =
                        0x000000000002 + ((uint64_t)dst_port << 40);
 
                /* src addr */
                rte_ether_addr_copy(&ports_eth_addr[dst_port],
-                               &eth_hdr->s_addr);
+                               &eth_hdr->src_addr);
 
                send_single_packet(m, dst_port);
 #else
@@ -910,7 +910,7 @@ static int event_register(struct lcore_conf *qconf)
        return 0;
 }
 
-/* main processing loop */
+/* Main processing loop. 8< */
 static int main_intr_loop(__rte_unused void *dummy)
 {
        struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -1073,6 +1073,7 @@ start_rx:
 
        return 0;
 }
+/* >8 End of main processing loop. */
 
 /* main processing loop */
 static int
@@ -1617,7 +1618,7 @@ print_usage(const char *prgname)
                " empty polls, full polls, and core busyness to telemetry\n"
                " --interrupt-only: enable interrupt-only mode\n"
                " --pmd-mgmt MODE: enable PMD power management mode. "
-               "Currently supported modes: monitor, pause, scale\n",
+               "Currently supported modes: baseline, monitor, pause, scale\n",
                prgname);
 }
 
@@ -1714,6 +1715,7 @@ parse_pmd_mgmt_config(const char *name)
 #define PMD_MGMT_MONITOR "monitor"
 #define PMD_MGMT_PAUSE   "pause"
 #define PMD_MGMT_SCALE   "scale"
+#define PMD_MGMT_BASELINE  "baseline"
 
        if (strncmp(PMD_MGMT_MONITOR, name, sizeof(PMD_MGMT_MONITOR)) == 0) {
                pmgmt_type = RTE_POWER_MGMT_TYPE_MONITOR;
@@ -1729,6 +1731,10 @@ parse_pmd_mgmt_config(const char *name)
                pmgmt_type = RTE_POWER_MGMT_TYPE_SCALE;
                return 0;
        }
+       if (strncmp(PMD_MGMT_BASELINE, name, sizeof(PMD_MGMT_BASELINE)) == 0) {
+               baseline_enabled = true;
+               return 0;
+       }
        /* unknown PMD power management mode */
        return -1;
 }
@@ -2498,6 +2504,7 @@ mode_to_str(enum appmode mode)
        }
 }
 
+/* Power library initialized in the main routine. 8< */
 int
 main(int argc, char **argv)
 {
@@ -2528,6 +2535,9 @@ main(int argc, char **argv)
        /* init RTE timer library to be used late */
        rte_timer_subsystem_init();
 
+       /* if we're running pmd-mgmt mode, don't default to baseline mode */
+       baseline_enabled = false;
+
        /* parse application arguments (after the EAL ones) */
        ret = parse_args(argc, argv);
        if (ret < 0)
@@ -2761,7 +2771,7 @@ main(int argc, char **argv)
                                                 "Fail to add ptype cb\n");
                        }
 
-                       if (app_mode == APP_MODE_PMD_MGMT) {
+                       if (app_mode == APP_MODE_PMD_MGMT && !baseline_enabled) {
                                ret = rte_power_ethdev_pmgmt_queue_enable(
                                                lcore_id, portid, queueid,
                                                pmgmt_type);
@@ -2772,6 +2782,7 @@ main(int argc, char **argv)
                        }
                }
        }
+       /* >8 End of power library initialization. */
 
        printf("\n");