/* parse hexadecimal string */
pm = strtoul(portmask, &end, 16);
if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
- return -1;
-
- if (pm == 0)
- return -1;
+ return 0;
return pm;
}
uint16_t portid;
struct rte_eth_link link;
int ret;
+ char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
printf("\nChecking link status");
fflush(stdout);
}
/* print link status if flag set */
if (print_flag == 1) {
- if (link.link_status)
- printf("Port %d Link Up - speed %u "
- "Mbps - %s\n", (uint8_t)portid,
- (unsigned)link.link_speed,
- (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex"));
- else
- printf("Port %d Link Down\n",
- (uint8_t)portid);
+ rte_eth_link_to_str(link_status_text,
+ sizeof(link_status_text), &link);
+ printf("Port %d %s\n", portid,
+ link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
return 0;
}
+static int
+autodetect_mode(void)
+{
+ RTE_LOG(NOTICE, L3FWD_POWER, "Operating mode not specified, probing frequency scaling support...\n");
+
+ /*
+ * Empty poll and telemetry modes have to be specifically requested to
+ * be enabled, but we can auto-detect between interrupt mode with or
+ * without frequency scaling. Both ACPI and pstate can be used.
+ */
+ if (rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ))
+ return APP_MODE_LEGACY;
+ if (rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ))
+ return APP_MODE_LEGACY;
+
+ RTE_LOG(NOTICE, L3FWD_POWER, "Frequency scaling not supported, selecting interrupt-only mode\n");
+
+ return APP_MODE_INTERRUPT;
+}
+
+static const char *
+mode_to_str(enum appmode mode)
+{
+ switch (mode) {
+ case APP_MODE_LEGACY:
+ return "legacy";
+ case APP_MODE_EMPTY_POLL:
+ return "empty poll";
+ case APP_MODE_TELEMETRY:
+ return "telemetry";
+ case APP_MODE_INTERRUPT:
+ return "interrupt-only";
+ default:
+ return "invalid";
+ }
+}
int
main(int argc, char **argv)
rte_exit(EXIT_FAILURE, "Invalid L3FWD parameters\n");
if (app_mode == APP_MODE_DEFAULT)
- app_mode = APP_MODE_LEGACY;
+ app_mode = autodetect_mode();
+
+ RTE_LOG(INFO, L3FWD_POWER, "Selected operation mode: %s\n",
+ mode_to_str(app_mode));
/* only legacy and empty poll mode rely on power library */
if ((app_mode == APP_MODE_LEGACY || app_mode == APP_MODE_EMPTY_POLL) &&