From patchwork Wed Sep 2 08:56:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Savinay Dharmappa X-Patchwork-Id: 76299 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 82610A04B7; Wed, 2 Sep 2020 10:58:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6371F1C0B0; Wed, 2 Sep 2020 10:58:31 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 5288A1C0AC for ; Wed, 2 Sep 2020 10:58:29 +0200 (CEST) IronPort-SDR: R5PEeT7c4mkimhgxNjMFhZXuPZBpYcTtU0MAMfLGsHIAPSuS1S8GV8XNVy+7epTYr1W9aVj3y/ 1/Gol0OvGmkg== X-IronPort-AV: E=McAfee;i="6000,8403,9731"; a="242173513" X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="242173513" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2020 01:58:25 -0700 IronPort-SDR: RSW7MVc7S7zdXG4SXzzwwMX9JJEvc+NL7qXZskWbL/8tbuYhk38rNCRwod/8AFfi/0KFBwNTEW 1tblPCy+0qpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="477557368" Received: from unknown (HELO silpixa00400629.ir.intel.com) ([10.237.214.135]) by orsmga005.jf.intel.com with ESMTP; 02 Sep 2020 01:58:24 -0700 From: Savinay Dharmappa To: cristian.dumitrescu@intel.com, jasvinder.singh@intel.com, dev@dpdk.org Cc: savinay.dharmappa@intel.com Date: Wed, 2 Sep 2020 09:56:44 +0100 Message-Id: <1599037006-3931-2-git-send-email-savinay.dharmappa@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599037006-3931-1-git-send-email-savinay.dharmappa@intel.com> References: <1594837677-313175-2-git-send-email-savinay.dharmappa@intel.com> <1599037006-3931-1-git-send-email-savinay.dharmappa@intel.com> Subject: [dpdk-dev] [PATCH v1 2/4] sched: add dynamic config of subport bandwidth profile X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch builds the subport profile table during port configuration. Since the tb_period,tb_size,tc_period, tb_credits_per_period and tc_credits_per_period are updated in subport profile table, references to them are removed from subport configuration. Signed-off-by: Savinay Dharmappa Signed-off-by: Jasvinder Singh --- lib/librte_sched/rte_sched.c | 154 +++++++++++++------------------------------ 1 file changed, 47 insertions(+), 107 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index c82e09c..c1846d0 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -438,6 +438,8 @@ subport_profile_check(struct rte_sched_subport_profile_params *params, static int rte_sched_port_check_params(struct rte_sched_port_params *params) { + uint32_t i; + if (params == NULL) { RTE_LOG(ERR, SCHED, "%s: Incorrect value for parameter params\n", __func__); @@ -474,6 +476,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) return -EINVAL; } + if (params->subport_profiles == NULL || + params->n_subport_profiles == 0 || + params->n_max_subport_profiles == 0 || + params->n_subport_profiles > params->n_max_subport_profiles) { + RTE_LOG(ERR, SCHED, + "%s: Incorrect value for subport profiles\n", __func__); + return -EINVAL; + } + + for (i = 0; i < params->n_subport_profiles; i++) { + struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; + int status; + + status = subport_profile_check(p, params->rate); + if (status != 0) { + RTE_LOG(ERR, SCHED, + "%s: subport profile check failed(%d)\n", + __func__, status); + return -EINVAL; + } + } + /* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport == 0 || !rte_is_power_of_2(params->n_pipes_per_subport)) { @@ -807,18 +832,6 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, return -EINVAL; } - if (params->tb_rate == 0 || params->tb_rate > rate) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tb rate\n", __func__); - return -EINVAL; - } - - if (params->tb_size == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tb size\n", __func__); - return -EINVAL; - } - /* qsize: if non-zero, power of 2, * no bigger than 32K (due to 16-bit read/write pointers) */ @@ -832,32 +845,12 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, } } - for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) { - uint64_t tc_rate = params->tc_rate[i]; - uint16_t qsize = params->qsize[i]; - - if ((qsize == 0 && tc_rate != 0) || - (qsize != 0 && tc_rate == 0) || - (tc_rate > params->tb_rate)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tc rate\n", __func__); - return -EINVAL; - } - } - - if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0 || - params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) { + if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) { RTE_LOG(ERR, SCHED, "%s: Incorrect qsize or tc rate(best effort)\n", __func__); return -EINVAL; } - if (params->tc_period == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tc period\n", __func__); - return -EINVAL; - } - /* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport_enabled == 0 || params->n_pipes_per_subport_enabled > n_max_pipes_per_subport || @@ -939,7 +932,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) { struct rte_sched_port *port = NULL; - uint32_t size0, size1; + uint32_t size0, size1, size2; uint32_t cycles_per_byte; uint32_t i, j; int status; @@ -954,10 +947,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 = sizeof(struct rte_sched_port); size1 = params->n_subports_per_port * sizeof(struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * + sizeof(struct rte_sched_subport_profile); /* Allocate memory to store the data structures */ - port = rte_zmalloc_socket("qos_params", size0 + size1, RTE_CACHE_LINE_SIZE, - params->socket); + port = rte_zmalloc_socket("qos_params", size0 + size1, + RTE_CACHE_LINE_SIZE, params->socket); + if (port == NULL) { + RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); + + return NULL; + } + + /* Allocate memory to store the subport profile */ + port->subport_profiles = rte_zmalloc_socket("subport_profile", size2, + RTE_CACHE_LINE_SIZE, params->socket); if (port == NULL) { RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); @@ -966,6 +970,8 @@ rte_sched_port_config(struct rte_sched_port_params *params) /* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 = __builtin_ctz(params->n_pipes_per_subport); @@ -996,6 +1002,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes = 0; port->time = 0; + /* Subport profile table */ + rte_sched_port_config_subport_profile_table(port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz() << RTE_SCHED_TIME_SHIFT) / params->rate; port->inv_cycles_per_byte = rte_reciprocal_value(cycles_per_byte); @@ -1054,48 +1063,6 @@ rte_sched_port_free(struct rte_sched_port *port) } static void -rte_sched_port_log_subport_config(struct rte_sched_port *port, uint32_t i) -{ - struct rte_sched_subport *s = port->subports[i]; - - RTE_LOG(DEBUG, SCHED, "Low level config for subport %u:\n" - " Token bucket: period = %"PRIu64", credits per period = %"PRIu64 - ", size = %"PRIu64"\n" - " Traffic classes: period = %"PRIu64"\n" - " credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 - ", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 - ", %"PRIu64", %"PRIu64", %"PRIu64"]\n" - " Best effort traffic class oversubscription: wm min = %"PRIu64 - ", wm max = %"PRIu64"\n", - i, - - /* Token bucket */ - s->tb_period, - s->tb_credits_per_period, - s->tb_size, - - /* Traffic classes */ - s->tc_period, - s->tc_credits_per_period[0], - s->tc_credits_per_period[1], - s->tc_credits_per_period[2], - s->tc_credits_per_period[3], - s->tc_credits_per_period[4], - s->tc_credits_per_period[5], - s->tc_credits_per_period[6], - s->tc_credits_per_period[7], - s->tc_credits_per_period[8], - s->tc_credits_per_period[9], - s->tc_credits_per_period[10], - s->tc_credits_per_period[11], - s->tc_credits_per_period[12], - - /* Best effort traffic class oversubscription */ - s->tc_ov_wm_min, - s->tc_ov_wm_max); -} - -static void rte_sched_free_memory(struct rte_sched_port *port, uint32_t n_subports) { uint32_t i; @@ -1168,33 +1135,7 @@ rte_sched_subport_config(struct rte_sched_port *port, /* Port */ port->subports[subport_id] = s; - /* Token Bucket (TB) */ - if (params->tb_rate == port->rate) { - s->tb_credits_per_period = 1; - s->tb_period = 1; - } else { - double tb_rate = ((double) params->tb_rate) / ((double) port->rate); - double d = RTE_SCHED_TB_RATE_CONFIG_ERR; - - rte_approx_64(tb_rate, d, &s->tb_credits_per_period, &s->tb_period); - } - - s->tb_size = params->tb_size; s->tb_time = port->time; - s->tb_credits = s->tb_size / 2; - - /* Traffic Classes (TCs) */ - s->tc_period = rte_sched_time_ms_to_bytes(params->tc_period, port->rate); - for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) { - if (params->qsize[i]) - s->tc_credits_per_period[i] - = rte_sched_time_ms_to_bytes(params->tc_period, - params->tc_rate[i]); - } - s->tc_time = port->time + s->tc_period; - for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) - if (params->qsize[i]) - s->tc_credits[i] = s->tc_credits_per_period[i]; /* compile time checks */ RTE_BUILD_BUG_ON(RTE_SCHED_PORT_N_GRINDERS == 0); @@ -1284,8 +1225,6 @@ rte_sched_subport_config(struct rte_sched_port *port, #ifdef RTE_SCHED_SUBPORT_TC_OV /* TC oversubscription */ s->tc_ov_wm_min = port->mtu; - s->tc_ov_wm_max = rte_sched_time_ms_to_bytes(params->tc_period, - s->pipe_tc_be_rate_max); s->tc_ov_wm = s->tc_ov_wm_max; s->tc_ov_period_id = 0; s->tc_ov = 0; @@ -1293,7 +1232,8 @@ rte_sched_subport_config(struct rte_sched_port *port, s->tc_ov_rate = 0; #endif - rte_sched_port_log_subport_config(port, subport_id); + return 0; +} return 0; }