#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "cfg_file.h"
#include "main.h"
#define CFG_ALLOC_SECTION_BATCH 8
#define CFG_ALLOC_ENTRY_BATCH 16
uint32_t n_active_queues;
int
{
const char *entry;
if (!cfg || !port_params)
return -1;
if (entry)
if (entry)
return 0;
}
int
cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params)
{
int i, j;
char *next;
const char *entry;
int profiles;
if (!cfg || !pipe_params)
return -1;
subport_params[0].n_pipe_profiles = profiles;
for (j = 0; j < profiles; j++) {
char pipe_name[32];
snprintf(pipe_name, sizeof(pipe_name), "pipe profile %d", j);
if (entry)
pipe_params[j].tb_rate = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tb_size = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_period = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[0] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[1] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[2] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[3] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[4] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[5] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[6] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[7] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[8] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[9] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[10] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[11] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[12] = (uint64_t)atoi(entry);
if (entry)
pipe_params[j].tc_ov_weight = (uint8_t)atoi(entry);
if (entry) {
pipe_params[j].wrr_weights[i] =
(uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
}
return 0;
}
int
cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subport_params)
{
const char *entry;
int i, j, k;
if (!cfg || !subport_params)
return -1;
memset(app_pipe_to_profile, -1, sizeof(app_pipe_to_profile));
memset(active_queues, 0, sizeof(active_queues));
n_active_queues = 0;
#ifdef RTE_SCHED_RED
char sec_name[CFG_NAME_LEN];
struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
snprintf(sec_name, sizeof(sec_name), "red");
char str[32];
snprintf(str, sizeof(str), "tc %d wred min", i);
if (entry) {
char *next;
= (uint16_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d wred max", i);
if (entry) {
char *next;
= (uint16_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d wred inv prob", i);
if (entry) {
char *next;
= (uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d wred weight", i);
if (entry) {
char *next;
= (uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
}
}
#endif
for (i = 0; i < MAX_SCHED_SUBPORTS; i++) {
char sec_name[CFG_NAME_LEN];
snprintf(sec_name, sizeof(sec_name), "subport %d", i);
"number of pipes per subport");
if (entry)
subport_params[i].n_pipes_per_subport_enabled =
(uint32_t)atoi(entry);
if (entry) {
char *next;
subport_params[i].qsize[j] =
(uint16_t)strtol(entry, &next, 10);
if (subport_params[i].qsize[j] != 0) {
active_queues[n_active_queues] = j;
n_active_queues++;
}
if (next == NULL)
break;
entry = next;
}
(uint16_t)strtol(entry, &next, 10);
active_queues[n_active_queues] =
RTE_SCHED_TRAFFIC_CLASS_BE + j;
n_active_queues++;
}
}
if (entry)
subport_params[i].tb_rate = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tb_size = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_period = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[0] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[1] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[2] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[3] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[4] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[5] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[6] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[7] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[8] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[9] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[10] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[11] = (uint64_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[12] = (uint64_t)atoi(entry);
for (j = 0; j < n_entries; j++) {
if (strncmp(
"pipe", entries[j].
name,
sizeof(
"pipe") - 1) == 0) {
int profile;
char *tokens[2] = {NULL, NULL};
int n_tokens;
int begin, end;
profile = atoi(entries[j].
value);
strnlen(entries[j].name, CFG_NAME_LEN), tokens, 2, '-');
begin = atoi(tokens[0]);
if (n_tokens == 2)
end = atoi(tokens[1]);
else
end = begin;
if (end >= MAX_SCHED_PIPES || begin > end)
return -1;
for (k = begin; k <= end; k++) {
char profile_name[CFG_NAME_LEN];
snprintf(profile_name, sizeof(profile_name),
"pipe profile %d", profile);
app_pipe_to_profile[i][k] = profile;
else
rte_exit(EXIT_FAILURE,
"Wrong pipe profile %s\n",
entries[j].value);
}
}
}
#ifdef RTE_SCHED_RED
subport_params[i].red_params[j][k].min_th =
subport_params[i].red_params[j][k].max_th =
subport_params[i].red_params[j][k].maxp_inv =
subport_params[i].red_params[j][k].wq_log2 =
}
}
#endif
}
}
return 0;
}