From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 853BAA0542; Fri, 28 Oct 2022 10:13:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2B3C410DC; Fri, 28 Oct 2022 10:13:28 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 8421C40696; Fri, 28 Oct 2022 10:13:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666944806; x=1698480806; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aXjg8H76PtJhSsU5UAc7Ant36JDFKg6W9ibAKpoan1c=; b=lFVNPaf1bJc/zFnW+7lCXtZQZ7UdmDXdMI8pL2d1yE6ocl3/N91dcToW VRlUl19zX7BF0mVJIDtQox+mD1efj0p4i7Sk/tFxhAUN/K9EyM8qZHoQ9 R/w6TrLtuGKTrkvOnOj0YFy8ntnfPlfJQ+jJ7KKOSoqVq0RwHSMHSarQ3 Bu5p3Y6m03sa3V7UNPSwzfxiFXHxwMaE+Gqj11aYngFyYfoDixV39R5+F OSEpHG1RD1ikmHSv139UL0Yi0djJj6y8xWISet+EYAcMHkMEEhbNBvL11 kG+E4xRPShxSCoG7hhyJnY5nh31ItcOfGbNJ4YnHaFPLVNjTScZO9XSVH w==; X-IronPort-AV: E=McAfee;i="6500,9779,10513"; a="372653697" X-IronPort-AV: E=Sophos;i="5.95,220,1661842800"; d="scan'208";a="372653697" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2022 01:13:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10513"; a="610668433" X-IronPort-AV: E=Sophos;i="5.95,220,1661842800"; d="scan'208";a="610668433" Received: from unknown (HELO localhost.localdomain) ([10.190.213.60]) by orsmga006.jf.intel.com with ESMTP; 28 Oct 2022 01:13:18 -0700 From: Megha Ajmera To: dev@dpdk.org, jasvinder.singh@intel.com, cristian.dumitrescu@intel.com, stephen@networkplumber.org Cc: stable@dpdk.org Subject: [PATCH v5 3/3] sched: support for 100G+ rates in subport/pipe config Date: Fri, 28 Oct 2022 08:09:46 +0000 Message-Id: <20221028080946.676201-3-megha.ajmera@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221028080946.676201-1-megha.ajmera@intel.com> References: <20221006190038.431828-1-megha.ajmera@intel.com> <20221028080946.676201-1-megha.ajmera@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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. Signed-off-by: Megha Ajmera --- examples/qos_sched/cfg_file.c | 180 +++++++++++++++++++++------------- examples/qos_sched/cfg_file.h | 2 + examples/qos_sched/init.c | 16 ++- 3 files changed, 128 insertions(+), 70 deletions(-) diff --git a/examples/qos_sched/cfg_file.c b/examples/qos_sched/cfg_file.c index ca871d3287..d203621fa4 100644 --- a/examples/qos_sched/cfg_file.c +++ b/examples/qos_sched/cfg_file.c @@ -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,85 @@ 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; diff --git a/examples/qos_sched/cfg_file.h b/examples/qos_sched/cfg_file.h index 0dc458aa71..71d280718f 100644 --- a/examples/qos_sched/cfg_file.h +++ b/examples/qos_sched/cfg_file.h @@ -8,6 +8,8 @@ #include #include +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); diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c index d897fd378b..e3b0930dd0 100644 --- a/examples/qos_sched/init.c +++ b/examples/qos_sched/init.c @@ -286,10 +286,18 @@ app_load_cfg_profile(const char *profile) 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); + if (cfg_load_port(file, &port_params)) { + rte_exit(EXIT_FAILURE, "Invalid port configuration\n"); + } + if (cfg_load_subport(file, subport_params)) { + rte_exit (EXIT_FAILURE, "Invalid subport configuration\n"); + } + if (cfg_load_subport_profile(file, subport_profile)) { + rte_exit(EXIT_FAILURE, "Invalid subport profile configuration\n"); + } + if (cfg_load_pipe(file, pipe_profiles)) { + rte_exit(EXIT_FAILURE, "Invalid pipe profile configuration\n"); + } rte_cfgfile_close(file); -- 2.25.1