X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fcmd_parser.c;h=a1d101f877786126e1ca37a9274aadd86d29cf08;hb=0d8616af8418480595a2c53e1dc7c3b809962a28;hp=f61fbe452816391156a64081900e76f26d4e15be;hpb=0bb9030df98a4214cd0ea2bb9d7dabd3d9635ad2;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/cmd_parser.c b/VNFs/DPPD-PROX/cmd_parser.c index f61fbe45..a1d101f8 100644 --- a/VNFs/DPPD-PROX/cmd_parser.c +++ b/VNFs/DPPD-PROX/cmd_parser.c @@ -401,10 +401,10 @@ static int parse_cmd_set_probability(const char *str, struct input *input) 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"))){ plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); - return -1; + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_impair_set_proba(tbase, probability); } - struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - task_impair_set_proba(tbase, probability); } } return 0; @@ -426,10 +426,10 @@ static int parse_cmd_delay_us(const char *str, struct input *input) 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"))){ plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); - return -1; + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_impair_set_delay_us(tbase, delay_us, 0); } - struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - task_impair_set_delay_us(tbase, delay_us, 0); } } return 0; @@ -451,10 +451,10 @@ static int parse_cmd_random_delay_us(const char *str, struct input *input) 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"))){ plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); - return -1; + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_impair_set_delay_us(tbase, 0, delay_us); } - struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - task_impair_set_delay_us(tbase, 0, delay_us); } } return 0; @@ -513,11 +513,10 @@ static int parse_cmd_pkt_size(const char *str, struct input *input) 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_pkt_size(tbase, pkt_size); /* error printed within function */ } - struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - - if (task_gen_set_pkt_size(tbase, pkt_size) != 0) - return -1; } } return 0; @@ -546,8 +545,8 @@ static int parse_cmd_speed(const char *str, struct input *input) 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 if (speed > 400.0f || speed < 0.0f) { - plog_err("Speed out of range (must be betweeen 0%% and 100%%)\n"); + else if (speed > 1000.0f || speed < 0.0f) { // Up to 100 Gbps + plog_err("Speed out of range (must be betweeen 0%% and 1000%%)\n"); } else { struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; @@ -580,8 +579,8 @@ static int parse_cmd_speed_byte(const char *str, struct input *input) 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 if (bps > 1250000000) { - plog_err("Speed out of range (must be <= 1250000000)\n"); + else if (bps > 12500000000) { // Up to 100Gbps + plog_err("Speed out of range (must be <= 12500000000)\n"); } else { struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; @@ -1583,6 +1582,49 @@ static int parse_cmd_port_stats(const char *str, struct input *input) 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; @@ -1614,6 +1656,39 @@ 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) +{ + unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; + + if (parse_core_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]; + 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_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"\n", + tot_rx, tot_tx, tot_rx_non_dp, tot_tx_non_dp, tot_drop, last_tsc, rte_get_tsc_hz()); + input->reply(input, buf, strlen(buf)); + } + else { + plog_info("RX: %"PRIu64", TX: %"PRIu64", RX_NON_DP: %"PRIu64", TX_NON_DP: %"PRIu64", DROP: %"PRIu64"\n", + tot_rx, tot_tx, tot_rx_non_dp, tot_tx_non_dp, tot_drop); + } + } + } + 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; @@ -1665,6 +1740,28 @@ static int parse_cmd_lat_stats(const char *str, struct input *input) return 0; } +static int parse_cmd_show_irq_buckets(const char *str, struct input *input) +{ + char buf[4096] = {0}; + 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)) + return -1; + + if (cores_task_are_valid(lcores, task_id, nb_cores)) { + for (c = 0; c < nb_cores; c++) { + lcore_id = lcores[c]; + get_irq_buckets_by_core_task(buf, lcore_id, task_id); + plog_info("%s", buf); + if (input->reply) + input->reply(input, buf, strlen(buf)); + buf[0] = 0; + } + } + return 0; +} + static int parse_cmd_irq(const char *str, struct input *input) { unsigned int i, c; @@ -1907,10 +2004,13 @@ static struct cmd_str cmd_strings[] = { {"tot imissed tot", "", "Print total number of imissed since reset", parse_cmd_tot_imissed_tot}, {"lat stats", " ", "Print min,max,avg latency as measured during last sampling interval", parse_cmd_lat_stats}, {"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}, {"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}, {"port_stats", "", "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 ", parse_cmd_port_stats}, + {"multi port stats", "", "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}, @@ -1929,7 +2029,7 @@ static struct cmd_str cmd_strings[] = { {"port down", "", "Set the port down", parse_cmd_port_down}, {"port link state", "", "Get link state (up or down) for port", parse_cmd_port_link_state}, {"port xstats", "", "Get extra statistics for the port", parse_cmd_xstats}, - {"stats", "", "Get stats as sepcified by . A comma-separated list of can be supplied", parse_cmd_stats}, + {"stats", "", "Get stats as specified by . A comma-separated list of can be supplied", parse_cmd_stats}, {"cgnat dump public hash", " ", "Dump cgnat public hash table", parse_cmd_cgnat_public_hash}, {"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},