X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fcmd_parser.c;h=bc796b555fd78e7f1e6563c6d77a263090470803;hb=293ee4b62ca9b9d2d68492831b060c8af684ff8e;hp=0973a4e515828507ac757d6fab58fad3493f00b8;hpb=3ca39112898d0ab303e486d469fca87730263e52;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/cmd_parser.c b/VNFs/DPPD-PROX/cmd_parser.c index 0973a4e5..bc796b55 100644 --- a/VNFs/DPPD-PROX/cmd_parser.c +++ b/VNFs/DPPD-PROX/cmd_parser.c @@ -721,6 +721,27 @@ static int parse_cmd_reset_randoms_all(const char *str, struct input *input) return 0; } +static int parse_cmd_reset_ranges_all(const char *str, struct input *input) +{ + if (strcmp(str, "") != 0) { + return -1; + } + + 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(lcore_id, task_id, "gen")) { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + uint32_t n_ranges = task_gen_get_n_ranges(tbase); + + plog_info("Resetting ranges on core %d task %d from %d ranges\n", lcore_id, task_id, n_ranges); + task_gen_reset_ranges(tbase); + } + } + } + return 0; +} + static int parse_cmd_reset_values_all(const char *str, struct input *input) { if (strcmp(str, "") != 0) { @@ -841,6 +862,39 @@ static int parse_cmd_set_random(const char *str, struct input *input) return 0; } +static int parse_cmd_set_range(const char *str, struct input *input) +{ + unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; + struct range range; + + if (parse_cores_task(str, lcores, &task_id, &nb_cores)) + return -1; + if (!(str = strchr_skip_twice(str, ' '))) + return -1; + if (sscanf(str, "%u %u %u", &range.offset, &range.min, &range.max) != 3) { + 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, "gen")) { + plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); + } else if (range.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 (range.min > range.max) { + plog_err("Wrong range: end (%d) must be >= start (%d)\n", range.max, range.min); + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + if (task_gen_add_range(tbase, &range)) { + plog_warn("Range not added on core %u task %u\n", lcore_id, task_id); + } + } + } + } + return 0; +} + static int parse_cmd_thread_info(const char *str, struct input *input) { unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; @@ -2265,8 +2319,10 @@ static struct cmd_str cmd_strings[] = { {"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}, {"set random", " ", "Set bytes to at offset in packets generated on ", parse_cmd_set_random}, + {"set range", " ", "Set bytes from to at offset in packets generated on ", parse_cmd_set_range}, {"reset values all", "", "Undo all \"set value\" commands on all cores/tasks", parse_cmd_reset_values_all}, {"reset randoms all", "", "Undo all \"set random\" commands on all cores/tasks", parse_cmd_reset_randoms_all}, + {"reset ranges all", "", "Undo all \"set range\" commands on all cores/tasks", parse_cmd_reset_ranges_all}, {"reset values", " ", "Undo all \"set value\" commands on specified core/task", parse_cmd_reset_values}, {"arp add", " ", "Add a single ARP entry into a CPE table on /.", parse_cmd_arp_add},