X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fcmd_parser.c;h=0973a4e515828507ac757d6fab58fad3493f00b8;hb=00f5630bf8a9a625a6ff4b35169a2f1f6ff23703;hp=dea955f4db3c78a62ed1c4cdf6879257cffc41f7;hpb=da4e41a67cca12cc4160a66ca46a37889137fa1e;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/cmd_parser.c b/VNFs/DPPD-PROX/cmd_parser.c index dea955f4..0973a4e5 100644 --- a/VNFs/DPPD-PROX/cmd_parser.c +++ b/VNFs/DPPD-PROX/cmd_parser.c @@ -1,5 +1,5 @@ /* -// Copyright (c) 2010-2017 Intel Corporation +// Copyright (c) 2010-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -384,7 +384,7 @@ static int parse_cmd_count(const char *str, struct input *input) if (cores_task_are_valid(lcores, task_id, nb_cores)) { for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (!task_is_mode(lcore_id, task_id, "gen")) { plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); } else { @@ -398,26 +398,78 @@ static int parse_cmd_count(const char *str, struct input *input) return 0; } -static int parse_cmd_set_probability(const char *str, struct input *input) +static int parse_cmd_set_proba_no_drop(const char *str, struct input *input) +{ + unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; + float proba_no_drop; + + if (parse_cores_task(str, lcores, &task_id, &nb_cores)) + return -1; + if (!(str = strchr_skip_twice(str, ' '))) + return -1; + if (sscanf(str, "%f", &proba_no_drop) != 1) + return -1; + + if (cores_task_are_valid(lcores, task_id, nb_cores)) { + for (unsigned int i = 0; i < nb_cores; i++) { + lcore_id = lcores[i]; + if (!task_is_mode(lcore_id, task_id, "impair")) { + plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_impair_set_proba_no_drop(tbase, proba_no_drop); + } + } + } + return 0; +} + +static int parse_cmd_set_proba_delay(const char *str, struct input *input) +{ + unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; + float proba_delay; + + if (parse_cores_task(str, lcores, &task_id, &nb_cores)) + return -1; + if (!(str = strchr_skip_twice(str, ' '))) + return -1; + if (sscanf(str, "%f", &proba_delay) != 1) + return -1; + + if (cores_task_are_valid(lcores, task_id, nb_cores)) { + for (unsigned int i = 0; i < nb_cores; i++) { + lcore_id = lcores[i]; + if (!task_is_mode(lcore_id, task_id, "impair")) { + plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_impair_set_proba_delay(tbase, proba_delay); + } + } + } + return 0; +} + +static int parse_cmd_set_proba_duplicate(const char *str, struct input *input) { unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; - float probability; + float proba_duplicate; if (parse_cores_task(str, lcores, &task_id, &nb_cores)) return -1; if (!(str = strchr_skip_twice(str, ' '))) return -1; - if (sscanf(str, "%f", &probability) != 1) + if (sscanf(str, "%f", &proba_duplicate) != 1) return -1; if (cores_task_are_valid(lcores, task_id, nb_cores)) { for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){ + if (!task_is_mode(lcore_id, task_id, "impair")) { plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); } else { struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - task_impair_set_proba(tbase, probability); + task_impair_set_proba_duplicate(tbase, proba_duplicate); } } } @@ -438,7 +490,7 @@ static int parse_cmd_delay_us(const char *str, struct input *input) if (cores_task_are_valid(lcores, task_id, nb_cores)) { for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){ + if (!task_is_mode(lcore_id, task_id, "impair")) { plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); } else { struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; @@ -463,7 +515,7 @@ static int parse_cmd_random_delay_us(const char *str, struct input *input) if (cores_task_are_valid(lcores, task_id, nb_cores)) { for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){ + if (!task_is_mode(lcore_id, task_id, "impair")) { plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); } else { struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; @@ -525,7 +577,7 @@ static int parse_cmd_pkt_size(const char *str, struct input *input) if (cores_task_are_valid(lcores, task_id, nb_cores)) { for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (!task_is_mode(lcore_id, task_id, "gen")) { plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); } else { struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; @@ -536,6 +588,47 @@ static int parse_cmd_pkt_size(const char *str, struct input *input) return 0; } +static int parse_cmd_imix(const char *str, struct input *input) +{ + unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; + uint32_t pkt_sizes[MAX_IMIX_PKTS], tmp; + uint32_t pkt_index = 0; + + if (parse_cores_task(str, lcores, &task_id, &nb_cores)) + return -1; + if (!(str = strchr_skip_twice(str, ' '))) + return -1; + while (pkt_index < MAX_IMIX_PKTS) { + if (sscanf(str, "%d", &pkt_sizes[pkt_index]) != 1) + break; + pkt_index++; + if ((str = strchr(str, ',')) == NULL) + break; + str = str + 1; + } + if (pkt_index == 0) { + plog_err("No pkt size found\n"); + return -1; + } + if ((pkt_index == MAX_IMIX_PKTS) && (str) && (sscanf(str, "%d", &tmp) == 1)) { + plog_err("Too many inputs - unexpected inputs starting at %s\n", str); + return -1; + } + + if (cores_task_are_valid(lcores, task_id, nb_cores)) { + for (unsigned int i = 0; i < nb_cores; i++) { + lcore_id = lcores[i]; + if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_gen_set_imix(tbase, pkt_index, pkt_sizes); /* error printed within function */ + } + } + } + return 0; +} + static int parse_cmd_speed(const char *str, struct input *input) { unsigned lcores[RTE_MAX_LCORE], task_id, lcore_id, nb_cores; @@ -556,7 +649,7 @@ static int parse_cmd_speed(const char *str, struct input *input) for (i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (!task_is_mode(lcore_id, task_id, "gen")) { plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); } else if (speed > 1000.0f || speed < 0.0f) { // Up to 100 Gbps @@ -590,7 +683,7 @@ static int parse_cmd_speed_byte(const char *str, struct input *input) for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (!task_is_mode(lcore_id, task_id, "gen")) { plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); } else if (bps > 12500000000) { // Up to 100Gbps @@ -616,7 +709,7 @@ static int parse_cmd_reset_randoms_all(const char *str, struct input *input) unsigned task_id, lcore_id = -1; while (prox_core_next(&lcore_id, 0) == 0) { for (task_id = 0; task_id < lcore_cfg[lcore_id].n_tasks_all; task_id++) { - if ((task_is_mode_and_submode(lcore_id, task_id, "gen", "")) || (task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (task_is_mode(lcore_id, task_id, "gen")) { struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; uint32_t n_rands = task_gen_get_n_randoms(tbase); @@ -637,7 +730,7 @@ static int parse_cmd_reset_values_all(const char *str, struct input *input) unsigned task_id, lcore_id = -1; while (prox_core_next(&lcore_id, 0) == 0) { for (task_id = 0; task_id < lcore_cfg[lcore_id].n_tasks_all; task_id++) { - if ((task_is_mode_and_submode(lcore_id, task_id, "gen", "")) || (task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (task_is_mode(lcore_id, task_id, "gen")) { struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; plog_info("Resetting values on core %d task %d\n", lcore_id, task_id); @@ -658,7 +751,7 @@ static int parse_cmd_reset_values(const char *str, struct input *input) if (cores_task_are_valid(lcores, task_id, nb_cores)) { for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (!task_is_mode(lcore_id, task_id, "gen")) { plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); } else { @@ -689,12 +782,10 @@ static int parse_cmd_set_value(const char *str, struct input *input) if (cores_task_are_valid(lcores, task_id, nb_cores)) { for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (!task_is_mode(lcore_id, task_id, "gen")) { plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); } - else if (offset > ETHER_MAX_LEN) { - plog_err("Offset out of range (must be less then %u)\n", ETHER_MAX_LEN); - } + // do not check offset here - gen knows better than us the maximum frame size else if (value_len > 4) { plog_err("Length out of range (must be less then 4)\n"); } @@ -702,7 +793,7 @@ static int parse_cmd_set_value(const char *str, struct input *input) struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; if (task_gen_set_value(tbase, value, offset, value_len)) - plog_info("Unable to set Byte %"PRIu16" to %"PRIu8" - too many value set\n", offset, value); + plog_info("Unable to set Byte %"PRIu16" to %"PRIu8" - invalid offset/len\n", offset, value); else plog_info("Setting Byte %"PRIu16" to %"PRIu32"\n", offset, value); } @@ -730,11 +821,11 @@ static int parse_cmd_set_random(const char *str, struct input *input) if (cores_task_are_valid(lcores, task_id, nb_cores)) { for (unsigned int i = 0; i < nb_cores; i++) { lcore_id = lcores[i]; - if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { + if (!task_is_mode(lcore_id, task_id, "gen")) { plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); } - else if (offset > ETHER_MAX_LEN) { - plog_err("Offset out of range (must be less then %u)\n", ETHER_MAX_LEN); + else if (offset > PROX_RTE_ETHER_MAX_LEN) { + plog_err("Offset out of range (must be less then %u)\n", PROX_RTE_ETHER_MAX_LEN); } else if (value_len > 4) { plog_err("Length out of range (must be less then 4)\n"); @@ -904,12 +995,7 @@ static int parse_cmd_local_ip(const char *str, struct input *input) struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; uint32_t local_ip = ((ip[3] & 0xFF) << 24) | ((ip[2] & 0xFF) << 16) | ((ip[1] & 0xFF) << 8) | ((ip[0] & 0xFF) << 0); if (!task_is_mode_and_submode(lcore_id, task_id, "arp", "local")) { - if (!task_is_sub_mode(lcore_id, task_id, "l3")) { - plog_err("Core %u task %u is not in l3 mode\n", lcore_id, task_id); - } else { - plog_info("Setting local ip to %s\n", str); - task_set_local_ip(tbase, local_ip); - } + plog_err("Core %u task %u is not in arp mode\n", lcore_id, task_id); } else { plog_info("Setting local ip to %s\n", str); task_arp_set_local_ip(tbase, local_ip); @@ -1258,7 +1344,7 @@ static int parse_cmd_tot_imissed_tot(const char *str, struct input *input) static int parse_cmd_enable_multicast(const char *str, struct input *input) { uint8_t port_id; - struct ether_addr mac; + prox_rte_ether_addr mac; if (sscanf(str, "%hhu %hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &port_id, mac.addr_bytes, mac.addr_bytes + 1, mac.addr_bytes + 2, mac.addr_bytes + 3, mac.addr_bytes + 4, mac.addr_bytes + 5 ) != 7) { return -1; @@ -1270,7 +1356,7 @@ static int parse_cmd_enable_multicast(const char *str, struct input *input) static int parse_cmd_disable_multicast(const char *str, struct input *input) { uint8_t port_id; - struct ether_addr mac; + prox_rte_ether_addr mac; if (sscanf(str, "%hhu %hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &port_id, mac.addr_bytes, mac.addr_bytes + 1, mac.addr_bytes + 2, mac.addr_bytes + 3, mac.addr_bytes + 4, mac.addr_bytes + 5 ) != 7) { return -1; @@ -1695,11 +1781,15 @@ static int parse_cmd_core_stats(const char *str, struct input *input) return 0; } -static int parse_cmd_dp_core_stats(const char *str, struct input *input) +typedef void (*parser_handler)(unsigned, unsigned, struct input *); +static int handle_cores_tasks(const char *str, struct input *input, const char *mode_str, const char *mode_name, parser_handler f) { - 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 + // 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 + + unsigned lcores[RTE_MAX_LCORE], tasks[MAX_TASKS_PER_CORE], lcore_id, task_id, nb_cores, nb_tasks; if (parse_cores_tasks(str, lcores, tasks, &nb_cores, &nb_tasks)) { if (input->reply) { char buf[128]; @@ -1709,9 +1799,6 @@ static int parse_cmd_dp_core_stats(const char *str, struct input *input) 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]; @@ -1726,122 +1813,180 @@ static int parse_cmd_dp_core_stats(const char *str, struct input *input) } 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); + if ((mode_str) && (!task_is_mode(lcore_id, task_id, mode_str))) { + if (input->reply) { + char buf[128]; + snprintf(buf, sizeof(buf), "error: core %u task %u is not measuring %s\n", lcore_id, task_id, mode_name); + input->reply(input, buf, strlen(buf)); + } else { + plog_info("error: core %u task %u is not measuring %s\n", lcore_id, task_id, mode_name); + } + continue; } + f(lcore_id, task_id, input); } } return 0; } -static int parse_cmd_lat_stats(const char *str, struct input *input) +static void handle_dp_core_stats(unsigned lcore_id, unsigned task_id, struct input *input) { - unsigned lcores[RTE_MAX_LCORE], tasks[MAX_TASKS_PER_CORE], lcore_id, task_id, nb_cores, nb_tasks; + 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); - // 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), + "%"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); + } +} + +static void handle_lat_stats(unsigned lcore_id, unsigned task_id, struct input *input) +{ + 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: invalid syntax\n"); + 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); } - return -1; + return; } - // 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]; - 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; - } - 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); - } - 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); + uint64_t lat_max_usec = time_unit_to_usec(&stats->max.time); + uint64_t tot_lat_min_usec = time_unit_to_usec(&tot->min.time); + uint64_t tot_lat_max_usec = time_unit_to_usec(&tot->max.time); + uint64_t lat_avg_usec = time_unit_to_usec(&stats->avg.time); - 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; - } + if (input->reply) { + char buf[128]; + snprintf(buf, sizeof(buf), + "%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%u,%u,%"PRIu64",%"PRIu64",%"PRIu64"\n", + lat_min_usec, + lat_max_usec, + lat_avg_usec, + tot_lat_min_usec, + tot_lat_max_usec, + last_tsc, + rte_get_tsc_hz(), + lcore_id, + task_id, + stats->mis_ordered, + stats->extent, + stats->duplicate); + input->reply(input, buf, strlen(buf)); + } + else { + plog_info("core: %u, task: %u, min: %"PRIu64", max: %"PRIu64", avg: %"PRIu64", min since reset: %"PRIu64", max since reset: %"PRIu64", mis_ordered: %"PRIu64", extent: %"PRIu64", duplicates: %"PRIu64"\n", + lcore_id, + task_id, + lat_min_usec, + lat_max_usec, + lat_avg_usec, + tot_lat_min_usec, + tot_lat_max_usec, + stats->mis_ordered, + stats->extent, + stats->duplicate); + } +} - 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); - uint64_t lat_max_usec = time_unit_to_usec(&stats->max.time); - uint64_t tot_lat_min_usec = time_unit_to_usec(&tot->min.time); - uint64_t tot_lat_max_usec = time_unit_to_usec(&tot->max.time); - uint64_t lat_avg_usec = time_unit_to_usec(&stats->avg.time); +#ifdef LATENCY_HISTOGRAM +static void handle_latency_histogram(unsigned lcore_id, unsigned task_id, struct input *input) +{ + uint64_t *buckets; - if (input->reply) { - char buf[128]; - snprintf(buf, sizeof(buf), - "%"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(), - lcore_id, - task_id); - input->reply(input, buf, strlen(buf)); - } - else { - 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, - tot_lat_min_usec, - tot_lat_max_usec); - } + stats_core_lat_histogram(lcore_id, task_id, &buckets); + + if (buckets == NULL) { + if (input->reply) { + char buf[128]; + snprintf(buf, sizeof(buf), "error: unexpected NULL bucket\n"); + input->reply(input, buf, strlen(buf)); } + return; + } + + if (input->reply) { + char buf[4096] = {0}; + for (size_t i = 0; i < LAT_BUCKET_COUNT; i++) + sprintf(buf+strlen(buf), "Bucket [%zu]: %"PRIu64"\n", i, buckets[i]); + input->reply(input, buf, strlen(buf)); + } + else { + for (size_t i = 0; i < LAT_BUCKET_COUNT; i++) + if (buckets[i]) + plog_info("Bucket [%zu]: %"PRIu64"\n", i, buckets[i]); + } +} + +static void handle_stats_and_packets(unsigned lcore_id, unsigned task_id, struct input *input) +{ + handle_lat_stats(lcore_id, task_id, input); + handle_latency_histogram(lcore_id, task_id, input); +} +#endif + +static int parse_cmd_dp_core_stats(const char *str, struct input *input) +{ + handle_cores_tasks(str, input, NULL, NULL, handle_dp_core_stats); + return 0; +} + +static int parse_cmd_lat_stats(const char *str, struct input *input) +{ + handle_cores_tasks(str, input, "lat", "latency", handle_lat_stats); + return 0; +} + +static int parse_cmd_lat_packets(const char *str, struct input *input) +{ +#ifdef LATENCY_HISTOGRAM + handle_cores_tasks(str, input, "lat", "latency", handle_latency_histogram); +#else + if (input->reply) { + char buf[128]; + snprintf(buf, sizeof(buf), "error: invalid syntax (LATENCY_HISTOGRAM disabled)\n"); + input->reply(input, buf, strlen(buf)); + } else { + plog_info("LATENCY_HISTOGRAMS disabled\n"); + } +#endif + return 0; +} + +static int parse_cmd_lat_stats_and_packets(const char *str, struct input *input) +{ +#ifdef LATENCY_HISTOGRAM + handle_cores_tasks(str, input, "lat", "latency", handle_stats_and_packets); +#else + if (input->reply) { + char buf[128]; + snprintf(buf, sizeof(buf), "error: invalid syntax (LATENCY_HISTOGRAMS disabled)\n"); + input->reply(input, buf, strlen(buf)); + } else { + plog_info("LATENCY_HISTOGRAMS disabled\n"); } +#endif return 0; } @@ -1890,53 +2035,6 @@ static int parse_cmd_irq(const char *str, struct input *input) return 0; } -static void task_lat_show_latency_histogram(uint8_t lcore_id, uint8_t task_id, struct input *input) -{ -#ifdef LATENCY_HISTOGRAM - uint64_t *buckets; - - stats_core_lat_histogram(lcore_id, task_id, &buckets); - - if (buckets == NULL) - return; - - if (input->reply) { - char buf[4096] = {0}; - for (size_t i = 0; i < 128; i++) - sprintf(buf+strlen(buf), "Bucket [%zu]: %"PRIu64"\n", i, buckets[i]); - input->reply(input, buf, strlen(buf)); - } - else { - for (size_t i = 0; i < 128; i++) - if (buckets[i]) - plog_info("Bucket [%zu]: %"PRIu64"\n", i, buckets[i]); - } -#else - plog_info("LATENCY_DETAILS disabled\n"); -#endif -} - -static int parse_cmd_lat_packets(const char *str, struct input *input) -{ - unsigned lcores[RTE_MAX_LCORE], lcore_id, 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++) { - 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); - } - else { - task_lat_show_latency_histogram(lcore_id, task_id, input); - } - } - } - return 0; -} - static int parse_cmd_cgnat_public_hash(const char *str, struct input *input) { unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; @@ -2065,6 +2163,29 @@ static int parse_cmd_join_igmp(const char *str, struct input *input) return 0; } +static int parse_cmd_send_unsollicited_na(const char *str, struct input *input) +{ + unsigned lcores[RTE_MAX_LCORE], lcore_id, 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++) { + lcore_id = lcores[i]; + + if (!task_is_sub_mode(lcore_id, task_id, "ndp")) { + plog_err("Core %u task %u is not running ndp\n", lcore_id, task_id); + } + else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + send_unsollicited_neighbour_advertisement(tbase); + } + } + } + return 0; +} + static int parse_cmd_rx_tx_info(const char *str, struct input *input) { if (strcmp(str, "") != 0) { @@ -2139,6 +2260,7 @@ static struct cmd_str cmd_strings[] = { {"bypass", " ", "Bypass task", parse_cmd_bypass}, {"reconnect", " ", "Reconnect task", parse_cmd_reconnect}, {"pkt_size", " ", "Set the packet size to ", parse_cmd_pkt_size}, + {"imix", " ", "Set the packet sizes to ", parse_cmd_imix}, {"speed", " ", "Change the speed to at which packets are being generated on core in task .", parse_cmd_speed}, {"speed_byte", " ", "Change speed to . The speed is specified in units of bytes per second.", parse_cmd_speed_byte}, {"set value", " ", "Set bytes to at offset in packets generated on ", parse_cmd_set_value}, @@ -2163,6 +2285,7 @@ static struct cmd_str cmd_strings[] = { {"irq stats", " ", "Print irq related infos", parse_cmd_irq}, {"show irq buckets", " ", "Print irq buckets", parse_cmd_show_irq_buckets}, {"lat packets", " ", "Print the latency for each of the last set of packets", parse_cmd_lat_packets}, + {"lat all stats", " ", "Print the latency for each of the last set of packets as well as latency distribution", parse_cmd_lat_stats_and_packets}, {"accuracy limit", " ", "Only consider latency of packets that were measured with an error no more than ", parse_cmd_accuracy}, {"core stats", " ", "Print rx/tx/drop for task running on core ", parse_cmd_core_stats}, {"dp core stats", " ", "Print rx/tx/non_dp_rx/non_dp_tx/drop for task running on core ", parse_cmd_dp_core_stats}, @@ -2193,10 +2316,16 @@ static struct cmd_str cmd_strings[] = { {"cgnat dump private hash", " ", "Dump cgnat private hash table", parse_cmd_cgnat_private_hash}, {"delay_us", " ", "Set the delay in usec for the impair mode to ", parse_cmd_delay_us}, {"random delay_us", " ", "Set the delay in usec for the impair mode to ", parse_cmd_random_delay_us}, - {"probability", " ", "Set the percent of forwarded packets for the impair mode", parse_cmd_set_probability}, + {"probability", " ", "Old - Use instead. Set the percent of forwarded packets for the impair mode", parse_cmd_set_proba_no_drop}, // old - backward compatibility + {"proba no drop", " ", "Set the percent of forwarded packets for the impair mode", parse_cmd_set_proba_no_drop}, + {"proba delay", " ", "Set the percent of delayed packets for the impair mode", parse_cmd_set_proba_delay}, +#if RTE_VERSION >= RTE_VERSION_NUM(19,11,0,0) + {"proba duplicate", " ", "Set the percent of duplicate packets for the impair mode", parse_cmd_set_proba_duplicate}, +#endif {"version", "", "Show version", parse_cmd_version}, {"join igmp", " ", "Send igmp membership report for group ", parse_cmd_join_igmp}, {"leave igmp", " ", "Send igmp leave group", parse_cmd_leave_igmp}, + {"send unsollicited na", " ", "Send Unsollicited Neighbor Advertisement", parse_cmd_send_unsollicited_na}, {0,0,0,0}, };