unsigned int lcore_id;
for (unsigned int i = 0; i < nb_cores; i++) {
lcore_id = lcores[i];
- if (lcore_id >= RTE_MAX_LCORE) {
- plog_err("Invalid core id %u (lcore ID above %d)\n", lcore_id, RTE_MAX_LCORE);
+ if (core_task_is_valid(lcore_id, task_id) == 0)
return 0;
- }
- else if (!prox_core_active(lcore_id, 0)) {
- plog_err("Invalid core id %u (lcore is not active)\n", lcore_id);
- return 0;
- }
- else if (task_id >= lcore_cfg[lcore_id].n_tasks_all) {
- plog_err("Invalid task id (valid task IDs for core %u are below %u)\n",
- lcore_id, lcore_cfg[lcore_id].n_tasks_all);
- return 0;
- }
}
return 1;
}
-static int parse_core_task(const char *str, uint32_t *lcore_id, uint32_t *task_id, unsigned int *nb_cores)
+static int parse_cores_task(const char *str, uint32_t *lcore_id, uint32_t *task_id, unsigned *nb_cores)
{
char str_lcore_id[128];
int ret;
return 0;
}
+static int parse_cores_tasks(const char *str, uint32_t *lcore_id, uint32_t *task_id, unsigned *nb_cores, unsigned *nb_tasks)
+{
+ char str_lcore_id[128], str_task_id[128];
+ int ret;
+
+ if (2 != sscanf(str, "%s %s", str_lcore_id, str_task_id))
+ return -1;
+
+ if ((ret = parse_list_set(lcore_id, str_lcore_id, RTE_MAX_LCORE)) <= 0) {
+ plog_err("Invalid core while parsing command (%s)\n", get_parse_err());
+ return -1;
+ }
+ *nb_cores = ret;
+
+ if ((ret = parse_list_set(task_id, str_task_id, MAX_TASKS_PER_CORE)) <= 0) {
+ plog_err("Invalid task while parsing command (%s)\n", get_parse_err());
+ return -1;
+ }
+ *nb_tasks = ret;
+
+ return 0;
+}
+
static const char *strchr_skip_twice(const char *str, int chr)
{
str = strchr(str, chr);
{
unsigned lcores[RTE_MAX_LCORE], task_id, nb_packets, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], task_id, nb_packets, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], task_id, nb_packets, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, count, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
float probability;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, delay_us, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, delay_us, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, pkt_size, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if ((prox_cfg.flags & DSF_ENABLE_BYPASS) == 0) {
plog_err("enable bypass not set => command not supported\n");
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, pkt_size, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
for (unsigned int i = 0; i < nb_cores; i++) {
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, pkt_size, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
float speed;
unsigned i;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
uint64_t bps;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
unsigned short offset;
uint8_t value_len;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
char rand_str[64];
int16_t rand_id = -1;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
for (unsigned int i = 0; i < nb_cores; i++) {
cmd_thread_info(lcores[i], task_id);
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
struct rte_ring *ring;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
struct rte_ring *ring;
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, ip[4], nb_cores, i;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, ip[4], nb_cores, i;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, prefix, next_hop_idx, ip[4], nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{
unsigned lcores[RTE_MAX_LCORE], task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
return 0;
}
+static int parse_cmd_multi_port_stats(const char *str, struct input *input)
+{
+ uint32_t ports[PROX_MAX_PORTS];
+ int nb_ports = parse_list_set(ports, str, PROX_MAX_PORTS);
+ if (nb_ports <= 0) {
+ return -1;
+ }
+
+ char buf[PROX_MAX_PORTS * (11+5*21) + 1], *pbuf = buf;
+ int left = sizeof(buf);
+ for (int i = 0; i < nb_ports; ++i) {
+ struct get_port_stats s;
+ if (stats_port(ports[i], &s)) {
+ plog_err("Invalid port %u\n", ports[i]);
+ return 0;
+ }
+
+ int len = snprintf(pbuf, left,
+ "%u,"
+ "%"PRIu64",%"PRIu64","
+ "%"PRIu64",%"PRIu64","
+ "%"PRIu64";",
+ //TODO: adjust buf size above when adding fields
+ ports[i],
+ s.rx_tot, s.tx_tot,
+ s.no_mbufs_tot, s.ierrors_tot + s.imissed_tot,
+ s.last_tsc);
+ if ((len < 0) || (len >= left)) {
+ plog_err("Cannot print stats for port %u\n", ports[i]);
+ return 0;
+ }
+ pbuf += len;
+ left -= len;
+ }
+ pbuf--;
+ *pbuf = '\n';
+
+ plog_info("%s", buf);
+ if (input->reply)
+ input->reply(input, buf, sizeof(buf) - left);
+ return 0;
+}
+
static int parse_cmd_core_stats(const char *str, struct input *input)
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
return 0;
}
+static int parse_cmd_dp_core_stats(const char *str, struct input *input)
+{
+ unsigned lcores[RTE_MAX_LCORE], tasks[MAX_TASKS_PER_CORE], lcore_id, task_id, nb_cores, nb_tasks;
+
+ // This function either outputs a single line, in case of syntax error on the lists of cores and/or tasks
+ if (parse_cores_tasks(str, lcores, tasks, &nb_cores, &nb_tasks)) {
+ if (input->reply) {
+ char buf[128];
+ snprintf(buf, sizeof(buf), "error: invalid syntax\n");
+ input->reply(input, buf, strlen(buf));
+ }
+ return -1;
+ }
+
+ // or outputs (nb_cores * nb_tasks) lines, one line for each core/task pair:
+ // - if the core/task pair is invalid, the output line reports an error
+ // - otherwise, the output line provides the dataplane statistics for the core/task pair
+ for (unsigned int i = 0; i < nb_cores; i++) {
+ for (unsigned int j = 0; j < nb_tasks; j++) {
+ lcore_id = lcores[i];
+ task_id = tasks[j];
+ if (core_task_is_valid(lcore_id, task_id) == 0) {
+ if (input->reply) {
+ char buf[128];
+ snprintf(buf, sizeof(buf), "error: invalid core %u, task %u\n", lcore_id, task_id);
+ input->reply(input, buf, strlen(buf));
+ } else {
+ plog_info("error: invalid core %u, task %u\n", lcore_id, task_id);
+ }
+ continue;
+ }
+ uint64_t tot_rx = stats_core_task_tot_rx(lcore_id, task_id);
+ uint64_t tot_tx = stats_core_task_tot_tx(lcore_id, task_id);
+ uint64_t tot_tx_fail = stats_core_task_tot_tx_fail(lcore_id, task_id);
+ uint64_t tot_rx_non_dp = stats_core_task_tot_rx_non_dp(lcore_id, task_id);
+ uint64_t tot_tx_non_dp = stats_core_task_tot_tx_non_dp(lcore_id, task_id);
+ uint64_t tot_drop = stats_core_task_tot_drop(lcore_id, task_id);
+ uint64_t last_tsc = stats_core_task_last_tsc(lcore_id, task_id);
+
+ if (input->reply) {
+ char buf[128];
+ snprintf(buf, sizeof(buf),
+ "%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%u,%u\n",
+ tot_rx, tot_tx, tot_rx_non_dp, tot_tx_non_dp, tot_drop, tot_tx_fail, last_tsc, rte_get_tsc_hz(), lcore_id, task_id);
+ input->reply(input, buf, strlen(buf));
+ }
+ else {
+ plog_info("core: %u, task: %u, RX: %"PRIu64", TX: %"PRIu64", RX_NON_DP: %"PRIu64", TX_NON_DP: %"PRIu64", DROP: %"PRIu64", TX_FAIL: %"PRIu64"\n",
+ lcore_id, task_id, tot_rx, tot_tx, tot_rx_non_dp, tot_tx_non_dp, tot_drop, tot_tx_fail);
+ }
+ }
+ }
+ return 0;
+}
+
static int parse_cmd_lat_stats(const char *str, struct input *input)
{
- unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+ unsigned lcores[RTE_MAX_LCORE], tasks[MAX_TASKS_PER_CORE], lcore_id, task_id, nb_cores, nb_tasks;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ // This function either outputs a single line, in case of syntax error on the lists of cores and/or tasks
+ if (parse_cores_tasks(str, lcores, tasks, &nb_cores, &nb_tasks)) {
+ if (input->reply) {
+ char buf[128];
+ snprintf(buf, sizeof(buf), "error: invalid syntax\n");
+ input->reply(input, buf, strlen(buf));
+ }
return -1;
+ }
- if (cores_task_are_valid(lcores, task_id, nb_cores)) {
- for (unsigned int i = 0; i < nb_cores; i++) {
+ // or outputs (nb_cores * nb_tasks) lines, one line for each core/task pair:
+ // - if the core/task pair is invalid, the output line reports an error
+ // - otherwise, the output line provides the latency statistics for the core/task pair
+ for (unsigned int i = 0; i < nb_cores; i++) {
+ for (unsigned int j = 0; j < nb_tasks; j++) {
lcore_id = lcores[i];
- if (!task_is_mode(lcore_id, task_id, "lat")) {
- plog_err("Core %u task %u is not measuring latency\n", lcore_id, task_id);
+ task_id = tasks[j];
+ if (core_task_is_valid(lcore_id, task_id) == 0) {
+ if (input->reply) {
+ char buf[128];
+ snprintf(buf, sizeof(buf), "error: invalid core %u, task %u\n", lcore_id, task_id);
+ input->reply(input, buf, strlen(buf));
+ } else {
+ plog_info("error: invalid core %u, task %u\n", lcore_id, task_id);
+ }
+ } else if (!task_is_mode(lcore_id, task_id, "lat")) {
+ if (input->reply) {
+ char buf[128];
+ snprintf(buf, sizeof(buf), "error: core %u task %u is not measuring latency\n", lcore_id, task_id);
+ input->reply(input, buf, strlen(buf));
+ } else {
+ plog_info("error: core %u task %u is not measuring latency\n", lcore_id, task_id);
+ }
}
else {
struct stats_latency *stats = stats_latency_find(lcore_id, task_id);
struct stats_latency *tot = stats_latency_tot_find(lcore_id, task_id);
+ if (!stats || !tot) {
+ if (input->reply) {
+ char buf[128];
+ snprintf(buf, sizeof(buf),
+ "error: core %u task %u stats = %p tot = %p\n",
+ lcore_id, task_id, stats, tot);
+ input->reply(input, buf, strlen(buf));
+ } else {
+ plog_info("error: core %u task %u stats = %p tot = %p\n",
+ lcore_id, task_id, stats, tot);
+ }
+ continue;
+ }
uint64_t last_tsc = stats_core_task_last_tsc(lcore_id, task_id);
uint64_t lat_min_usec = time_unit_to_usec(&stats->min.time);
if (input->reply) {
char buf[128];
snprintf(buf, sizeof(buf),
- "%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64"\n",
+ "%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%u,%u\n",
lat_min_usec,
lat_max_usec,
lat_avg_usec,
tot_lat_min_usec,
tot_lat_max_usec,
last_tsc,
- rte_get_tsc_hz());
+ rte_get_tsc_hz(),
+ lcore_id,
+ task_id);
input->reply(input, buf, strlen(buf));
}
else {
- plog_info("min: %"PRIu64", max: %"PRIu64", avg: %"PRIu64", min since reset: %"PRIu64", max since reset: %"PRIu64"\n",
+ plog_info("core: %u, task: %u, min: %"PRIu64", max: %"PRIu64", avg: %"PRIu64", min since reset: %"PRIu64", max since reset: %"PRIu64"\n",
+ lcore_id,
+ task_id,
lat_min_usec,
lat_max_usec,
lat_avg_usec,
unsigned int i, c;
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
unsigned int i, c;
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
{
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
uint32_t val;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
uint32_t val;
- if (parse_core_task(str, lcores, &task_id, &nb_cores))
+ if (parse_cores_task(str, lcores, &task_id, &nb_cores))
return -1;
if (!(str = strchr_skip_twice(str, ' ')))
return -1;
{"lat packets", "<core id> <task id>", "Print the latency for each of the last set of packets", parse_cmd_lat_packets},
{"accuracy limit", "<core id> <task id> <nsec>", "Only consider latency of packets that were measured with an error no more than <nsec>", parse_cmd_accuracy},
{"core stats", "<core id> <task id>", "Print rx/tx/drop for task <task id> running on core <core id>", parse_cmd_core_stats},
+ {"dp core stats", "<core id> <task id>", "Print rx/tx/non_dp_rx/non_dp_tx/drop for task <task id> running on core <core id>", parse_cmd_dp_core_stats},
{"port_stats", "<port id>", "Print rate for no_mbufs, ierrors + imissed, rx_bytes, tx_bytes, rx_pkts, tx_pkts; totals for RX, TX, no_mbufs, ierrors + imissed for port <port id>", parse_cmd_port_stats},
+ {"multi port stats", "<port list>", "Get stats for multiple ports, semi-colon separated: port id, total for rx_pkts, tx_pkts, no_mbufs, ierrors + imissed, last_tsc", parse_cmd_multi_port_stats},
{"read reg", "", "Read register", parse_cmd_read_reg},
{"write reg", "", "Read register", parse_cmd_write_reg},
{"set vlan offload", "", "Set Vlan offload", parse_cmd_set_vlan_offload},