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 AB595A06CB; Thu, 20 Oct 2022 11:51:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 04FF942D18; Thu, 20 Oct 2022 11:51:05 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 8AB4742D06; Thu, 20 Oct 2022 11:51:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666259462; x=1697795462; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hKo0W95XhzjZtQNJzW6s93Bufw36eydBzEyXJ1QU8v0=; b=JkkKppkZDuBuqH1ZcsMdabTSDXnUDN44LHbU5Wyi2xh1gclFyZcfhRAm n0EcQxDXQBhXrJur7TFF14xyl4n5QO5jTosjiUXc/WOHYTVgeeVoJa0xw 9wUbj4Dg4Q4k6NW54UfGkHHSBVNW7wQPGRuZ1NbbOI7yJ7ORpdwuH5/wI F7OcL5KHPMVe4i7rxAPYvSV4JGwCgWflDFmyf4H10J3YSQfwsGhWZ2IYC YMEN+CoUfejmhL5/MbbDy0E1BBb9HlOwtSobHOq/DZ71bcRQc2oa672Gp 8brCE5Dmz1qJgSI0tvfmcbdr133T16d/olcbgGzCWfR+s96HHfq/+oN8U A==; X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="289974300" X-IronPort-AV: E=Sophos;i="5.95,198,1661842800"; d="scan'208";a="289974300" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 02:51:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="874904085" X-IronPort-AV: E=Sophos;i="5.95,198,1661842800"; d="scan'208";a="874904085" Received: from unknown (HELO localhost.localdomain) ([10.190.213.60]) by fmsmga006.fm.intel.com with ESMTP; 20 Oct 2022 02:50:59 -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 v4 3/3] sched: support for 100G+ rates in subport/pipe config Date: Thu, 20 Oct 2022 09:47:47 +0000 Message-Id: <20221020094747.605087-3-megha.ajmera@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221020094747.605087-1-megha.ajmera@intel.com> References: <20221019113714.1e949cd2@hermes.local> <20221020094747.605087-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. Signed-off-by: Megha Ajmera --- 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