From: Megha Ajmera <megha.ajmera@intel.com>
To: dev@dpdk.org, jasvinder.singh@intel.com,
cristian.dumitrescu@intel.com, stephen@networkplumber.org
Cc: stable@dpdk.org
Subject: [PATCH v4 3/3] sched: support for 100G+ rates in subport/pipe config
Date: Thu, 20 Oct 2022 09:47:47 +0000 [thread overview]
Message-ID: <20221020094747.605087-3-megha.ajmera@intel.com> (raw)
In-Reply-To: <20221020094747.605087-1-megha.ajmera@intel.com>
Config load functions updated to support 100G rates
for subport and pipes.
Signed-off-by: Megha Ajmera <megha.ajmera@intel.com>
---
examples/qos_sched/cfg_file.c | 294 ++++++++++++++++++++++++++--------
1 file changed, 230 insertions(+), 64 deletions(-)
diff --git a/examples/qos_sched/cfg_file.c b/examples/qos_sched/cfg_file.c
index ca871d3287..9fcdf5eeb6 100644
--- a/examples/qos_sched/cfg_file.c
+++ b/examples/qos_sched/cfg_file.c
@@ -60,71 +60,154 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params
for (j = 0; j < profiles; j++) {
char pipe_name[32];
+ /* Convert to decimal */
+ int base = 10;
+
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);
+ if (entry) {
+ pipe_params[j].tb_rate = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tb size");
- if (entry)
- pipe_params[j].tb_size = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tb_size = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc period");
- if (entry)
- pipe_params[j].tc_period = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_period = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 0 rate");
- if (entry)
- pipe_params[j].tc_rate[0] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[0] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 1 rate");
- if (entry)
- pipe_params[j].tc_rate[1] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[1] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 2 rate");
- if (entry)
- pipe_params[j].tc_rate[2] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[2] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 3 rate");
- if (entry)
- pipe_params[j].tc_rate[3] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[3] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 4 rate");
- if (entry)
- pipe_params[j].tc_rate[4] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[4] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 5 rate");
- if (entry)
- pipe_params[j].tc_rate[5] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[5] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 6 rate");
- if (entry)
- pipe_params[j].tc_rate[6] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[6] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 7 rate");
- if (entry)
- pipe_params[j].tc_rate[7] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[7] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 8 rate");
- if (entry)
- pipe_params[j].tc_rate[8] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[8] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 9 rate");
- if (entry)
- pipe_params[j].tc_rate[9] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[9] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 10 rate");
- if (entry)
- pipe_params[j].tc_rate[10] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[10] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 11 rate");
- if (entry)
- pipe_params[j].tc_rate[11] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[11] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 12 rate");
- if (entry)
- pipe_params[j].tc_rate[12] = (uint64_t)atoi(entry);
+ if (entry) {
+ pipe_params[j].tc_rate[12] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 12 oversubscription weight");
if (entry)
@@ -161,71 +244,154 @@ cfg_load_subport_profile(struct rte_cfgfile *cfg,
for (i = 0; i < profiles; i++) {
char sec_name[32];
+ /* convert to decimal */
+ int base = 10;
+
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);
+ if (entry) {
+ subport_profile[i].tb_rate = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tb size");
- if (entry)
- subport_profile[i].tb_size = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tb_size = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc period");
- if (entry)
- subport_profile[i].tc_period = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_period = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 0 rate");
- if (entry)
- subport_profile[i].tc_rate[0] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[0] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 1 rate");
- if (entry)
- subport_profile[i].tc_rate[1] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[1] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 2 rate");
- if (entry)
- subport_profile[i].tc_rate[2] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[2] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 3 rate");
- if (entry)
- subport_profile[i].tc_rate[3] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[3] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 4 rate");
- if (entry)
- subport_profile[i].tc_rate[4] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[4] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 5 rate");
- if (entry)
- subport_profile[i].tc_rate[5] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[5] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 6 rate");
- if (entry)
- subport_profile[i].tc_rate[6] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[6] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 7 rate");
- if (entry)
- subport_profile[i].tc_rate[7] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[7] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 8 rate");
- if (entry)
- subport_profile[i].tc_rate[8] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[8] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 9 rate");
- if (entry)
- subport_profile[i].tc_rate[9] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[9] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 10 rate");
- if (entry)
- subport_profile[i].tc_rate[10] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[10] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 11 rate");
- if (entry)
- subport_profile[i].tc_rate[11] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[11] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 12 rate");
- if (entry)
- subport_profile[i].tc_rate[12] = (uint64_t)atoi(entry);
+ if (entry) {
+ subport_profile[i].tc_rate[12] = (uint64_t)strtoull(entry, NULL, base);
+ if (errno == EINVAL || errno == ERANGE) {
+ /* cannot convert string to unsigned long long */
+ return -1;
+ }
+ }
}
return 0;
--
2.25.1
next prev parent reply other threads:[~2022-10-20 9:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 17:22 [PATCH v2] sched: Fix subport profile id not set correctly Megha Ajmera
2022-10-05 19:19 ` Dumitrescu, Cristian
2022-10-11 4:59 ` Ajmera, Megha
2022-10-06 19:00 ` [PATCH 1/3] sched: fix " Megha Ajmera
2022-10-06 19:00 ` [PATCH 2/3] sched: removed unused subport field in hqos profile Megha Ajmera
2022-10-11 14:26 ` Dumitrescu, Cristian
2022-10-06 19:00 ` [PATCH 3/3] sched: support for 100G+ rates in subport/pipe config Megha Ajmera
2022-10-11 13:09 ` Dumitrescu, Cristian
2022-10-18 5:40 ` Ajmera, Megha
2022-10-18 13:12 ` Dumitrescu, Cristian
2022-10-19 18:37 ` Stephen Hemminger
2022-10-20 9:47 ` [PATCH v4 1/3] sched: fix subport profile ID Megha Ajmera
2022-10-20 9:47 ` [PATCH v4 2/3] sched: fix number of subport profiles Megha Ajmera
2022-10-20 9:47 ` Megha Ajmera [this message]
2022-10-24 18:57 ` [PATCH v4 3/3] sched: support for 100G+ rates in subport/pipe config Dumitrescu, Cristian
2022-10-20 9:55 ` [PATCH " Ajmera, Megha
2022-10-11 14:22 ` [PATCH 1/3] sched: fix subport profile id not set correctly Dumitrescu, Cristian
2022-10-28 8:09 ` [PATCH v5 1/3] sched: fix subport profile ID Megha Ajmera
2022-10-28 8:09 ` [PATCH v5 2/3] sched: fix number of subport profiles Megha Ajmera
2022-10-28 8:09 ` [PATCH v5 3/3] sched: support for 100G+ rates in subport/pipe config Megha Ajmera
2022-10-28 9:55 ` [PATCH v6 1/3] sched: fix subport profile ID Megha Ajmera
2022-10-28 9:55 ` [PATCH v6 2/3] sched: fix number of subport profiles Megha Ajmera
2022-10-28 14:02 ` David Marchand
2022-10-28 9:55 ` [PATCH v6 3/3] sched: support for 100G+ rates in subport/pipe config Megha Ajmera
2022-10-28 10:57 ` Dumitrescu, Cristian
2022-10-28 14:04 ` David Marchand
2022-10-28 14:01 ` [PATCH v6 1/3] sched: fix subport profile ID David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221020094747.605087-3-megha.ajmera@intel.com \
--to=megha.ajmera@intel.com \
--cc=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=jasvinder.singh@intel.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).