static struct rte_eth_conf port_conf = {
.rxmode = {
- .mq_mode = ETH_MQ_RX_RSS,
+ .mq_mode = RTE_ETH_MQ_RX_RSS,
.split_hdr_size = 0,
- .offloads = DEV_RX_OFFLOAD_CHECKSUM,
+ .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM,
},
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
- .rss_hf = ETH_RSS_UDP,
+ .rss_hf = RTE_ETH_RSS_UDP,
},
},
.txmode = {
- .mq_mode = ETH_MQ_TX_NONE,
+ .mq_mode = RTE_ETH_MQ_TX_NONE,
}
};
static uint32_t max_pkt_len;
+static uint32_t max_empty_polls = 512;
+static uint32_t pause_duration = 1;
+static uint32_t scale_freq_min;
+static uint32_t scale_freq_max;
static struct rte_mempool * pktmbuf_pool[NB_SOCKETS];
}
-/* Freqency scale down timer callback */
+/* Frequency scale down timer callback */
static void
power_timer_cb(__rte_unused struct rte_timer *tim,
__rte_unused void *arg)
return -1;
/* 2. The IP checksum must be correct. */
- /* this is checked in H/W */
+ /* if this is not checked in H/W, check it. */
+ if ((port_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) == 0) {
+ uint16_t actual_cksum, expected_cksum;
+ actual_cksum = pkt->hdr_checksum;
+ pkt->hdr_checksum = 0;
+ expected_cksum = rte_ipv4_cksum(pkt);
+ if (actual_cksum != expected_cksum)
+ return -2;
+ }
/*
* 3. The IP version number must be 4. If the version number is not 4
" 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: baseline, monitor, pause, scale\n",
+ "Currently supported modes: baseline, monitor, pause, scale\n"
+ " --max-empty-polls MAX_EMPTY_POLLS: number of empty polls to"
+ " wait before entering sleep state\n"
+ " --pause-duration DURATION: set the duration, in microseconds,"
+ " of the pause callback\n"
+ " --scale-freq-min FREQ_MIN: set minimum frequency for scaling mode for"
+ " all application lcores (FREQ_MIN must be in kHz, in increments of 100MHz)\n"
+ " --scale-freq-max FREQ_MAX: set maximum frequency for scaling mode for"
+ " all application lcores (FREQ_MAX must be in kHz, in increments of 100MHz)\n",
prgname);
}
+static int
+parse_int(const char *opt)
+{
+ char *end = NULL;
+ unsigned long val;
+
+ /* parse integer string */
+ val = strtoul(opt, &end, 10);
+ if ((opt[0] == '\0') || (end == NULL) || (*end != '\0'))
+ return -1;
+
+ return val;
+}
+
static int parse_max_pkt_len(const char *pktlen)
{
char *end = NULL;
#define CMD_LINE_OPT_TELEMETRY "telemetry"
#define CMD_LINE_OPT_PMD_MGMT "pmd-mgmt"
#define CMD_LINE_OPT_MAX_PKT_LEN "max-pkt-len"
+#define CMD_LINE_OPT_MAX_EMPTY_POLLS "max-empty-polls"
+#define CMD_LINE_OPT_PAUSE_DURATION "pause-duration"
+#define CMD_LINE_OPT_SCALE_FREQ_MIN "scale-freq-min"
+#define CMD_LINE_OPT_SCALE_FREQ_MAX "scale-freq-max"
/* Parse the argument given in the command line of the application */
static int
{CMD_LINE_OPT_TELEMETRY, 0, 0, 0},
{CMD_LINE_OPT_INTERRUPT_ONLY, 0, 0, 0},
{CMD_LINE_OPT_PMD_MGMT, 1, 0, 0},
+ {CMD_LINE_OPT_MAX_EMPTY_POLLS, 1, 0, 0},
+ {CMD_LINE_OPT_PAUSE_DURATION, 1, 0, 0},
+ {CMD_LINE_OPT_SCALE_FREQ_MIN, 1, 0, 0},
+ {CMD_LINE_OPT_SCALE_FREQ_MAX, 1, 0, 0},
{NULL, 0, 0, 0}
};
parse_ptype = 1;
}
+ if (!strncmp(lgopts[option_index].name,
+ CMD_LINE_OPT_MAX_EMPTY_POLLS,
+ sizeof(CMD_LINE_OPT_MAX_EMPTY_POLLS))) {
+ printf("Maximum empty polls configured\n");
+ max_empty_polls = parse_int(optarg);
+ }
+
+ if (!strncmp(lgopts[option_index].name,
+ CMD_LINE_OPT_PAUSE_DURATION,
+ sizeof(CMD_LINE_OPT_PAUSE_DURATION))) {
+ printf("Pause duration configured\n");
+ pause_duration = parse_int(optarg);
+ }
+
+ if (!strncmp(lgopts[option_index].name,
+ CMD_LINE_OPT_SCALE_FREQ_MIN,
+ sizeof(CMD_LINE_OPT_SCALE_FREQ_MIN))) {
+ printf("Scaling frequency minimum configured\n");
+ scale_freq_min = parse_int(optarg);
+ }
+
+ if (!strncmp(lgopts[option_index].name,
+ CMD_LINE_OPT_SCALE_FREQ_MAX,
+ sizeof(CMD_LINE_OPT_SCALE_FREQ_MAX))) {
+ printf("Scaling frequency maximum configured\n");
+ scale_freq_max = parse_int(optarg);
+ }
+
break;
default:
continue;
}
/* clear all_ports_up flag if any link down */
- if (link.link_status == ETH_LINK_DOWN) {
+ if (link.link_status == RTE_ETH_LINK_DOWN) {
all_ports_up = 0;
break;
}
ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
values, RTE_DIM(values));
if (ret < 0)
- RTE_LOG(WARNING, POWER, "failed to update metrcis\n");
+ RTE_LOG(WARNING, POWER, "failed to update metrics\n");
}
static int
conf->rxmode.mtu = max_pkt_len - overhead_len;
if (conf->rxmode.mtu > RTE_ETHER_MTU)
- conf->txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
+ conf->txmode.offloads |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
return 0;
}
uint16_t portid;
const char *ptr_strings[NUM_TELSTATS];
- /* catch SIGINT and restore cpufreq governor to ondemand */
- signal(SIGINT, signal_exit_now);
-
/* init EAL */
ret = rte_eal_init(argc, argv);
if (ret < 0)
argc -= ret;
argv += ret;
+ /* catch SIGINT and restore cpufreq governor to ondemand */
+ signal(SIGINT, signal_exit_now);
+
/* init RTE timer library to be used late */
rte_timer_subsystem_init();
"Invalid max packet length: %u (port %u)\n",
max_pkt_len, portid);
- if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+ if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
local_port_conf.txmode.offloads |=
- DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+ RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
dev_info.flow_type_rss_offloads;
local_port_conf.rx_adv_conf.rss_conf.rss_hf);
}
+ if (local_port_conf.rx_adv_conf.rss_conf.rss_hf == 0)
+ local_port_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_NONE;
+ local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa;
+ port_conf.rxmode.offloads = local_port_conf.rxmode.offloads;
+
ret = rte_eth_dev_configure(portid, nb_rx_queue,
(uint16_t)n_tx_queue, &local_port_conf);
if (ret < 0)
}
if (app_mode == APP_MODE_PMD_MGMT && !baseline_enabled) {
+ /* Set power_pmd_mgmt configs passed by user */
+ rte_power_pmd_mgmt_set_emptypoll_max(max_empty_polls);
+ ret = rte_power_pmd_mgmt_set_pause_duration(pause_duration);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Error setting pause_duration: err=%d, lcore=%d\n",
+ ret, lcore_id);
+
+ ret = rte_power_pmd_mgmt_set_scaling_freq_min(lcore_id,
+ scale_freq_min);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Error setting scaling freq min: err=%d, lcore=%d\n",
+ ret, lcore_id);
+
+ ret = rte_power_pmd_mgmt_set_scaling_freq_max(lcore_id,
+ scale_freq_max);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Error setting scaling freq max: err=%d, lcore %d\n",
+ ret, lcore_id);
+
ret = rte_power_ethdev_pmgmt_queue_enable(
lcore_id, portid, queueid,
pmgmt_type);