examples/qos_sched: support higher rates for subport/pipe
Config load functions updated to support 100G rates for subport and pipes. Added new parse function to convert string to unsigned long long. Added error checks. Fixed format warnings. Signed-off-by: Megha Ajmera <megha.ajmera@intel.com> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
parent
85ea681c82
commit
92e9fe0d87
@ -25,6 +25,21 @@ uint32_t n_active_queues;
|
||||
|
||||
struct rte_sched_cman_params cman_params;
|
||||
|
||||
int parse_u64(const char *entry, uint64_t *val)
|
||||
{
|
||||
char *endptr;
|
||||
if (!entry || !val)
|
||||
return -EINVAL;
|
||||
|
||||
errno = 0;
|
||||
|
||||
*val = strtoull(entry, &endptr, 0);
|
||||
if (errno == EINVAL || errno == ERANGE || *endptr != '\0')
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
cfg_load_port(struct rte_cfgfile *cfg, struct rte_sched_port_params *port_params)
|
||||
{
|
||||
@ -47,7 +62,7 @@ cfg_load_port(struct rte_cfgfile *cfg, struct rte_sched_port_params *port_params
|
||||
int
|
||||
cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params)
|
||||
{
|
||||
int i, j;
|
||||
int i, j, ret = 0;
|
||||
char *next;
|
||||
const char *entry;
|
||||
int profiles;
|
||||
@ -63,68 +78,84 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params
|
||||
snprintf(pipe_name, sizeof(pipe_name), "pipe profile %d", j);
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tb rate");
|
||||
if (entry)
|
||||
pipe_params[j].tb_rate = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tb_rate);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tb size");
|
||||
if (entry)
|
||||
pipe_params[j].tb_size = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tb_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc period");
|
||||
if (entry)
|
||||
pipe_params[j].tc_period = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_period);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 0 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[0] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[0]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 1 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[1] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[1]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 2 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[2] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[2]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 3 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[3] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[3]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 4 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[4] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[4]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 5 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[5] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[5]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 6 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[6] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[6]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 7 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[7] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[7]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 8 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[8] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[8]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 9 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[9] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[9]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 10 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[10] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[10]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 11 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[11] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[11]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 12 rate");
|
||||
if (entry)
|
||||
pipe_params[j].tc_rate[12] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &pipe_params[j].tc_rate[12]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 12 oversubscription weight");
|
||||
if (entry)
|
||||
@ -148,7 +179,7 @@ int
|
||||
cfg_load_subport_profile(struct rte_cfgfile *cfg,
|
||||
struct rte_sched_subport_profile_params *subport_profile)
|
||||
{
|
||||
int i;
|
||||
int i, ret = 0;
|
||||
const char *entry;
|
||||
int profiles;
|
||||
|
||||
@ -164,68 +195,84 @@ cfg_load_subport_profile(struct rte_cfgfile *cfg,
|
||||
snprintf(sec_name, sizeof(sec_name), "subport profile %d", i);
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tb rate");
|
||||
if (entry)
|
||||
subport_profile[i].tb_rate = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tb_rate);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tb size");
|
||||
if (entry)
|
||||
subport_profile[i].tb_size = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tb_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc period");
|
||||
if (entry)
|
||||
subport_profile[i].tc_period = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_period);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 0 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[0] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[0]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 1 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[1] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[1]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 2 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[2] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[2]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 3 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[3] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[3]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 4 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[4] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[4]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 5 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[5] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[5]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 6 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[6] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[6]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 7 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[7] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[7]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 8 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[8] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[8]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 9 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[9] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[9]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 10 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[10] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[10]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 11 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[11] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[11]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 12 rate");
|
||||
if (entry)
|
||||
subport_profile[i].tc_rate[12] = (uint64_t)atoi(entry);
|
||||
ret = parse_u64(entry, &subport_profile[i].tc_rate[12]);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <rte_sched.h>
|
||||
#include <rte_cfgfile.h>
|
||||
|
||||
int parse_u64(const char *entry, uint64_t *val);
|
||||
|
||||
int cfg_load_port(struct rte_cfgfile *cfg, struct rte_sched_port_params *port);
|
||||
|
||||
int cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe);
|
||||
|
@ -280,20 +280,33 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)
|
||||
static int
|
||||
app_load_cfg_profile(const char *profile)
|
||||
{
|
||||
int ret = 0;
|
||||
if (profile == NULL)
|
||||
return 0;
|
||||
struct rte_cfgfile *file = rte_cfgfile_load(profile, 0);
|
||||
if (file == NULL)
|
||||
rte_exit(EXIT_FAILURE, "Cannot load configuration profile %s\n", profile);
|
||||
|
||||
cfg_load_port(file, &port_params);
|
||||
cfg_load_subport(file, subport_params);
|
||||
cfg_load_subport_profile(file, subport_profile);
|
||||
cfg_load_pipe(file, pipe_profiles);
|
||||
ret = cfg_load_port(file, &port_params);
|
||||
if (ret)
|
||||
goto _app_load_cfg_profile_error_return;
|
||||
|
||||
ret = cfg_load_subport(file, subport_params);
|
||||
if (ret)
|
||||
goto _app_load_cfg_profile_error_return;
|
||||
|
||||
ret = cfg_load_subport_profile(file, subport_profile);
|
||||
if (ret)
|
||||
goto _app_load_cfg_profile_error_return;
|
||||
|
||||
ret = cfg_load_pipe(file, pipe_profiles);
|
||||
if (ret)
|
||||
goto _app_load_cfg_profile_error_return;
|
||||
|
||||
_app_load_cfg_profile_error_return:
|
||||
rte_cfgfile_close(file);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int app_init(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user