#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
int
{
const char *entry;
int j;
if (!cfg || !port_params)
return -1;
if (entry)
if (entry)
if (entry)
if (entry) {
char *next;
port_params->
qsize[j] = (uint16_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
#ifdef RTE_SCHED_RED
char str[32];
snprintf(str, sizeof(str), "tc %d wred min", j);
if (entry) {
char *next;
int k;
for (k = 0; k < e_RTE_METER_COLORS; k++) {
port_params->red_params[j][k].min_th
= (uint16_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d wred max", j);
if (entry) {
char *next;
int k;
for (k = 0; k < e_RTE_METER_COLORS; k++) {
port_params->red_params[j][k].max_th
= (uint16_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d wred inv prob", j);
if (entry) {
char *next;
int k;
for (k = 0; k < e_RTE_METER_COLORS; k++) {
port_params->red_params[j][k].maxp_inv
= (uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
snprintf(str, sizeof(str), "tc %d wred weight", j);
if (entry) {
char *next;
int k;
for (k = 0; k < e_RTE_METER_COLORS; k++) {
port_params->red_params[j][k].wq_log2
= (uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
}
#endif
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;
port_params.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 = (uint32_t)atoi(entry);
if (entry)
pipe_params[j].tb_size = (uint32_t)atoi(entry);
if (entry)
pipe_params[j].tc_period = (uint32_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[0] = (uint32_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[1] = (uint32_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[2] = (uint32_t)atoi(entry);
if (entry)
pipe_params[j].tc_rate[3] = (uint32_t)atoi(entry);
#ifdef RTE_SCHED_SUBPORT_TC_OV
if (entry)
pipe_params[j].tc_ov_weight = (uint8_t)atoi(entry);
#endif
if (entry) {
(uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
if (entry) {
(uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
if (entry) {
(uint8_t)strtol(entry, &next, 10);
if (next == NULL)
break;
entry = next;
}
}
if (entry) {
(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));
for (i = 0; i < MAX_SCHED_SUBPORTS; i++) {
char sec_name[CFG_NAME_LEN];
snprintf(sec_name, sizeof(sec_name), "subport %d", i);
if (entry)
subport_params[i].tb_rate = (uint32_t)atoi(entry);
if (entry)
subport_params[i].tb_size = (uint32_t)atoi(entry);
if (entry)
subport_params[i].tc_period = (uint32_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[0] = (uint32_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[1] = (uint32_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[2] = (uint32_t)atoi(entry);
if (entry)
subport_params[i].tc_rate[3] = (uint32_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",
}
}
}
}
}
return 0;
}