#include "stats_latency.h"
#include "handle_cgnat.h"
#include "handle_impair.h"
+#include "rx_pkt.h"
static int core_task_is_valid(int lcore_id, int task_id)
{
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
for (unsigned int i = 0; i < nb_cores; i++) {
+ if (lcores[i] > RTE_MAX_LCORE) {
+ plog_warn("core_id too high, maximum allowed is: %u\n", RTE_MAX_LCORE);
+ return -1;
+ } else if (task_id >= lcore_cfg[lcores[i]].n_tasks_all) {
+ plog_warn("task_id too high, should be in [0, %u]\n", lcore_cfg[lcores[i]].n_tasks_all - 1);
+ return -1;
+ } else {
+ struct lcore_cfg *lconf = &lcore_cfg[lcores[i]];
+ struct task_base *tbase = lconf->tasks_all[task_id];
+ int prev_count = tbase->aux->rx_prev_count;
+ if (((prev_count) && (tbase->aux->rx_pkt_prev[prev_count - 1] == rx_pkt_dummy))
+ || (tbase->rx_pkt == rx_pkt_dummy)) {
+ plog_warn("Unable to dump_rx as rx_pkt_dummy\n");
+ return -1;
+ }
+ }
cmd_dump(lcores[i], task_id, nb_packets, input, 1, 0);
}
}
return 0;
}
-int task_is_mode(uint32_t lcore_id, uint32_t task_id, const char *mode, const char *sub_mode)
+int task_is_mode_and_submode(uint32_t lcore_id, uint32_t task_id, const char *mode, const char *sub_mode)
+{
+ struct task_args *targs = &lcore_cfg[lcore_id].targs[task_id];
+
+ return !strcmp(targs->task_init->mode_str, mode) && !strcmp(targs->sub_mode_str, sub_mode);
+}
+
+int task_is_mode(uint32_t lcore_id, uint32_t task_id, const char *mode)
{
struct task_init *t = lcore_cfg[lcore_id].targs[task_id].task_init;
- return !strcmp(t->mode_str, mode) && !strcmp(t->sub_mode_str, sub_mode);
+ return !strcmp(t->mode_str, mode);
}
int task_is_sub_mode(uint32_t lcore_id, uint32_t task_id, const char *sub_mode)
{
- struct task_init *t = lcore_cfg[lcore_id].targs[task_id].task_init;
+ struct task_args *targs = &lcore_cfg[lcore_id].targs[task_id];
- return !strcmp(t->sub_mode_str, sub_mode);
+ return !strcmp(targs->sub_mode_str, sub_mode);
}
static void log_pkt_count(uint32_t count, uint32_t lcore_id, uint32_t task_id)
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", "")) && (!task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ 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 (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", "")) {
+ 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);
+ } 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;
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", "")) {
+ 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);
+ } 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;
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", "")) {
+ 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);
+ } 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;
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", "")) && (!task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ 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;
for (i = 0; i < nb_cores; i++) {
lcore_id = lcores[i];
- if ((!task_is_mode(lcore_id, task_id, "gen", "")) && (!task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ 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];
for (unsigned int i = 0; i < nb_cores; i++) {
lcore_id = lcores[i];
- if ((!task_is_mode(lcore_id, task_id, "gen", "")) && (!task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ 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];
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", "")) || (task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ if ((task_is_mode_and_submode(lcore_id, task_id, "gen", "")) || (task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
uint32_t n_rands = task_gen_get_n_randoms(tbase);
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", "")) || (task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ if ((task_is_mode_and_submode(lcore_id, task_id, "gen", "")) || (task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
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);
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", "")) && (!task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ 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 (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", "")) && (!task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ 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 (offset > ETHER_MAX_LEN) {
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", "")) && (!task_is_mode(lcore_id, task_id, "gen", "l3"))) {
+ 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 (offset > ETHER_MAX_LEN) {
}
for (i = 0; i < nb_cores; i++) {
lcore_id = lcores[i];
- if ((!task_is_mode(lcore_id, task_id, "gen", "")) && (!task_is_mode(lcore_id, task_id, "gen", "l3"))) {
- plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
+
+ 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 {
uint32_t gateway_ip = ((ip[3] & 0xFF) << 24) | ((ip[2] & 0xFF) << 16) | ((ip[1] & 0xFF) << 8) | ((ip[0] & 0xFF) << 0);
struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
plog_info("Setting gateway ip to %s\n", str);
- task_gen_set_gateway_ip(tbase, gateway_ip);
+ task_set_gateway_ip(tbase, gateway_ip);
}
}
return 0;
}
for (i = 0; i < nb_cores; i++) {
lcore_id = lcores[i];
- if (!task_is_mode(lcore_id, task_id, "arp", "local")) {
- plog_err("Core %u task %u is not in arp mode\n", lcore_id, task_id);
- }
- else {
- uint32_t local_ip = ((ip[3] & 0xFF) << 24) | ((ip[2] & 0xFF) << 16) | ((ip[1] & 0xFF) << 8) | ((ip[0] & 0xFF) << 0);
- struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+ 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);
+ }
+ } else {
plog_info("Setting local ip to %s\n", str);
task_arp_set_local_ip(tbase, local_ip);
}
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", "")) {
+ 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 {
if (cores_task_are_valid(lcores, task_id, nb_cores)) {
for (c = 0; c < nb_cores; c++) {
lcore_id = lcores[c];
- if (!task_is_mode(lcore_id, task_id, "irq", "")) {
+ if (!task_is_mode(lcore_id, task_id, "irq")) {
plog_err("Core %u task %u is not in irq mode\n", lcore_id, task_id);
} else {
struct task_irq *task_irq = (struct task_irq *)(lcore_cfg[lcore_id].tasks_all[task_id]);
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", "")) {
+ 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 {
for (unsigned int i = 0; i < nb_cores; i++) {
lcore_id = lcores[i];
- if (!task_is_mode(lcore_id, task_id, "cgnat", "")) {
+ if (!task_is_mode(lcore_id, task_id, "cgnat")) {
plog_err("Core %u task %u is not cgnat\n", lcore_id, task_id);
}
else {
for (unsigned int i = 0; i < nb_cores; i++) {
lcore_id = lcores[i];
- if (!task_is_mode(lcore_id, task_id, "cgnat", "")) {
+ if (!task_is_mode(lcore_id, task_id, "cgnat")) {
plog_err("Core %u task %u is not cgnat\n", lcore_id, task_id);
}
else {
for (unsigned int i = 0; i < nb_cores; i++) {
lcore_id = lcores[i];
- if (!task_is_mode(lcore_id, task_id, "lat", "")) {
+ 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 {