#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)
port_params->frame_overhead = (uint32_t)atoi(entry);
if (entry)
port_params->n_subports_per_port = (uint32_t)atoi(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_profile(struct rte_cfgfile *cfg,
struct rte_sched_subport_profile_params *subport_profile)
{
int i;
const char *entry;
int profiles;
if (!cfg || !subport_profile)
return -1;
sizeof("subport profile") - 1);
port_params.n_subport_profiles = profiles;
for (i = 0; i < profiles; i++) {
char sec_name[32];
snprintf(sec_name, sizeof(sec_name), "subport profile %d", i);
if (entry)
subport_profile[i].tb_rate = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tb_size = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_period = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[0] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[1] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[2] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[3] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[4] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[5] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[6] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[7] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[8] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[9] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[10] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[11] = (uint64_t)atoi(entry);
if (entry)
subport_profile[i].tc_rate[12] = (uint64_t)atoi(entry);
}
return 0;
}
#ifdef RTE_SCHED_CMAN
void set_subport_cman_params(struct rte_sched_subport_params *subport_p,
struct rte_sched_cman_params cman_p)
{
int j, k;
subport_p->cman_params->cman_mode = cman_p.cman_mode;
if (subport_p->cman_params->cman_mode ==
subport_p->cman_params->red_params[j][k].min_th =
cman_p.red_params[j][k].min_th;
subport_p->cman_params->red_params[j][k].max_th =
cman_p.red_params[j][k].max_th;
subport_p->cman_params->red_params[j][k].maxp_inv =
cman_p.red_params[j][k].maxp_inv;
subport_p->cman_params->red_params[j][k].wq_log2 =
cman_p.red_params[j][k].wq_log2;
}
} else {
subport_p->cman_params->pie_params[j].qdelay_ref =
cman_p.pie_params[j].qdelay_ref;
subport_p->cman_params->pie_params[j].dp_update_interval =
cman_p.pie_params[j].dp_update_interval;
subport_p->cman_params->pie_params[j].max_burst =
cman_p.pie_params[j].max_burst;
subport_p->cman_params->pie_params[j].tailq_th =
cman_p.pie_params[j].tailq_th;
}
}
}
#endif
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_CMAN
struct rte_sched_cman_params cman_params = {
.red_params = { },
};
char str[32];
snprintf(str, sizeof(str), "tc %d red min", i);
if (entry) {
char *next;
cman_params.red_params[i][j].min_th
= (uint16_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d red max", i);
if (entry) {
char *next;
cman_params.red_params[i][j].max_th
= (uint16_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d red inv prob", i);
if (entry) {
char *next;
cman_params.red_params[i][j].maxp_inv
= (uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d red weight", i);
if (entry) {
char *next;
cman_params.red_params[i][j].wq_log2
= (uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
}
}
char str[32];
snprintf(str, sizeof(str), "tc %d qdelay ref", i);
if (entry)
cman_params.pie_params[i].qdelay_ref =
(uint16_t) atoi(entry);
snprintf(str, sizeof(str), "tc %d max burst", i);
if (entry)
cman_params.pie_params[i].max_burst =
(uint16_t) atoi(entry);
snprintf(str, sizeof(str), "tc %d update interval", i);
if (entry)
cman_params.pie_params[i].dp_update_interval =
(uint16_t) atoi(entry);
snprintf(str, sizeof(str), "tc %d tailq th", i);
if (entry)
cman_params.pie_params[i].tailq_th =
(uint16_t) atoi(entry);
}
}
#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] =
n_active_queues++;
}
}
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",
}
}
}
#ifdef RTE_SCHED_CMAN
set_subport_cman_params(subport_params+i, cman_params);
#endif
}
}
return 0;
}
int rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg, const char *sectionname)
const char * rte_cfgfile_get_entry(struct rte_cfgfile *cfg, const char *sectionname, const char *entryname)
int rte_cfgfile_section_entries(struct rte_cfgfile *cfg, const char *sectionname, struct rte_cfgfile_entry *entries, int max_entries)
int rte_cfgfile_has_section(struct rte_cfgfile *cfg, const char *sectionname)
int rte_cfgfile_num_sections(struct rte_cfgfile *cfg, const char *sec_name, size_t length)
__rte_noreturn void rte_exit(int exit_code, const char *format,...) __rte_format_printf(2
#define RTE_SCHED_QUEUES_PER_PIPE
#define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
#define RTE_SCHED_TRAFFIC_CLASS_BE
#define RTE_SCHED_BE_QUEUES_PER_PIPE
int rte_strsplit(char *string, int stringlen, char **tokens, int maxtokens, char delim)
char value[CFG_VALUE_LEN]