From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9A2EDA0471 for ; Mon, 9 Sep 2019 12:06:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B7F8E1EBB5; Mon, 9 Sep 2019 12:05:48 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 226CA1EB9F for ; Mon, 9 Sep 2019 12:05:41 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Sep 2019 03:05:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,484,1559545200"; d="scan'208";a="188977414" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.223.4]) by orsmga006.jf.intel.com with ESMTP; 09 Sep 2019 03:05:40 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, Lukasz Krakowiak Date: Mon, 9 Sep 2019 11:05:20 +0100 Message-Id: <20190909100530.86020-6-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909100530.86020-1-jasvinder.singh@intel.com> References: <20190823144602.58213-1-jasvinder.singh@intel.com> <20190909100530.86020-1-jasvinder.singh@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 05/15] sched: modify pipe functions for config flexibility 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" Modify pipe level functions to allow different subports of the same port to have different configuration in terms of number of pipes, pipe queue sizes, etc. Signed-off-by: Jasvinder Singh Signed-off-by: Lukasz Krakowiak --- lib/librte_sched/rte_sched.c | 95 +++++++++++++++++++++++++----------- lib/librte_sched/rte_sched.h | 5 +- 2 files changed, 70 insertions(+), 30 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 1491cb695..6bafbd8fe 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -648,9 +648,9 @@ rte_sched_subport_config_qsize(struct rte_sched_subport *subport) } static void -rte_sched_port_log_pipe_profile(struct rte_sched_port *port, uint32_t i) +rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) { - struct rte_sched_pipe_profile *p = port->pipe_profiles + i; + struct rte_sched_pipe_profile *p = subport->pipe_profiles + i; RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n" " Token bucket: period = %u, credits per period = %u, size = %u\n" @@ -699,7 +699,7 @@ rte_sched_time_ms_to_bytes(uint32_t time_ms, uint32_t rate) } static void -rte_sched_pipe_profile_convert(struct rte_sched_port *port, +rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, struct rte_sched_pipe_params *src, struct rte_sched_pipe_profile *dst, uint32_t rate) @@ -728,7 +728,7 @@ rte_sched_pipe_profile_convert(struct rte_sched_port *port, rate); for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) - if (port->qsize[i]) + if (subport->qsize[i]) dst->tc_credits_per_period[i] = rte_sched_time_ms_to_bytes(src->tc_period, src->tc_rate[i]); @@ -756,6 +756,30 @@ rte_sched_pipe_profile_convert(struct rte_sched_port *port, dst->wrr_cost[3] = (uint8_t) wrr_cost[3]; } +static void +rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, + struct rte_sched_subport_params *params, uint32_t rate) +{ + uint32_t i; + + for (i = 0; i < subport->n_pipe_profiles; i++) { + struct rte_sched_pipe_params *src = params->pipe_profiles + i; + struct rte_sched_pipe_profile *dst = subport->pipe_profiles + i; + + rte_sched_pipe_profile_convert(subport, src, dst, rate); + rte_sched_port_log_pipe_profile(subport, i); + } + + subport->pipe_tc_be_rate_max = 0; + for (i = 0; i < subport->n_pipe_profiles; i++) { + struct rte_sched_pipe_params *src = params->pipe_profiles + i; + uint32_t pipe_tc_be_rate = src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE]; + + if (subport->pipe_tc_be_rate_max < pipe_tc_be_rate) + subport->pipe_tc_be_rate_max = pipe_tc_be_rate; + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport, @@ -1200,6 +1224,9 @@ rte_sched_subport_config(struct rte_sched_port *port, (s->memory + rte_sched_subport_get_array_base(params, port->n_max_pipe_profiles, e_RTE_SCHED_SUBPORT_ARRAY_QUEUE_ARRAY)); + /* Pipe profile table */ + rte_sched_subport_config_pipe_profile_table(s, params, port->rate); + /* Bitmap */ n_subport_pipe_queues = rte_sched_subport_pipe_queues(s); bmp_mem_size = rte_bitmap_get_memory_footprint(n_subport_pipe_queues); @@ -1242,6 +1269,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, struct rte_sched_subport *s; struct rte_sched_pipe *p; struct rte_sched_pipe_profile *params; + uint32_t n_subports = subport_id + 1; uint32_t deactivate, profile, i; /* Check user parameters */ @@ -1257,34 +1285,32 @@ rte_sched_pipe_config(struct rte_sched_port *port, if (subport_id >= port->n_subports_per_port) { RTE_LOG(ERR, SCHED, "%s: Incorrect value for parameter subport id\n", __func__); + + rte_sched_free_memory(port, n_subports); return -EINVAL; } - if (pipe_id >= port->n_pipes_per_subport) { + s = port->subports[subport_id]; + if (pipe_id >= s->n_pipes_per_subport) { RTE_LOG(ERR, SCHED, "%s: Incorrect value for parameter pipe id\n", __func__); + + rte_sched_free_memory(port, n_subports); return -EINVAL; } - if (!deactivate && profile >= port->n_pipe_profiles) { + if (!deactivate && profile >= s->n_pipe_profiles) { RTE_LOG(ERR, SCHED, "%s: Incorrect value for parameter pipe profile\n", __func__); - return -EINVAL; - } - /* Check that subport configuration is valid */ - s = port->subport + subport_id; - if (s->tb_period == 0) { - RTE_LOG(ERR, SCHED, - "%s: Subport configuration invalid\n", __func__); + rte_sched_free_memory(port, n_subports); return -EINVAL; } - p = port->pipe + (subport_id * port->n_pipes_per_subport + pipe_id); - /* Handle the case when pipe already has a valid configuration */ + p = s->pipe + pipe_id; if (p->tb_time) { - params = port->pipe_profiles + p->profile; + params = s->pipe_profiles + p->profile; double subport_tc_be_rate = (double) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] @@ -1314,7 +1340,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, /* Apply the new pipe configuration */ p->profile = profile; - params = port->pipe_profiles + p->profile; + params = s->pipe_profiles + p->profile; /* Token Bucket (TB) */ p->tb_time = port->time; @@ -1324,7 +1350,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, p->tc_time = port->time + params->tc_period; for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) - if (port->qsize[i]) + if (s->qsize[i]) p->tc_credits[i] = params->tc_credits_per_period[i]; { @@ -1355,9 +1381,11 @@ rte_sched_pipe_config(struct rte_sched_port *port, int rte_sched_port_pipe_profile_add(struct rte_sched_port *port, + uint32_t subport_id, struct rte_sched_pipe_params *params, uint32_t *pipe_profile_id) { + struct rte_sched_subport *s; struct rte_sched_pipe_profile *pp; uint32_t i; int status; @@ -1369,40 +1397,49 @@ rte_sched_port_pipe_profile_add(struct rte_sched_port *port, return -EINVAL; } + /* Subport id not exceeds the max limit */ + if (subport_id > port->n_subports_per_port) { + RTE_LOG(ERR, SCHED, + "%s: Incorrect value for subport id\n", __func__); + return -EINVAL; + } + + s = port->subports[subport_id]; + /* Pipe profiles not exceeds the max limit */ - if (port->n_pipe_profiles >= port->n_max_pipe_profiles) { + if (s->n_pipe_profiles >= port->n_max_pipe_profiles) { RTE_LOG(ERR, SCHED, "%s: Number of pipe profiles exceeds the max limit\n", __func__); return -EINVAL; } /* Pipe params */ - status = pipe_profile_check(params, port->rate, &port->qsize[0]); + status = pipe_profile_check(params, port->rate, &s->qsize[0]); if (status != 0) { RTE_LOG(ERR, SCHED, "%s: Pipe profile check failed(%d)\n", __func__, status); return -EINVAL; } - pp = &port->pipe_profiles[port->n_pipe_profiles]; - rte_sched_pipe_profile_convert(port, params, pp, port->rate); + pp = &s->pipe_profiles[s->n_pipe_profiles]; + rte_sched_pipe_profile_convert(s, params, pp, port->rate); /* Pipe profile not exists */ - for (i = 0; i < port->n_pipe_profiles; i++) - if (memcmp(port->pipe_profiles + i, pp, sizeof(*pp)) == 0) { + for (i = 0; i < s->n_pipe_profiles; i++) + if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) { RTE_LOG(ERR, SCHED, "%s: Pipe profile doesn't exist\n", __func__); return -EINVAL; } /* Pipe profile commit */ - *pipe_profile_id = port->n_pipe_profiles; - port->n_pipe_profiles++; + *pipe_profile_id = s->n_pipe_profiles; + s->n_pipe_profiles++; - if (port->pipe_tc_be_rate_max < params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE]) - port->pipe_tc_be_rate_max = params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE]; + if (s->pipe_tc_be_rate_max < params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE]) + s->pipe_tc_be_rate_max = params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE]; - rte_sched_port_log_pipe_profile(port, *pipe_profile_id); + rte_sched_port_log_pipe_profile(s, *pipe_profile_id); return 0; } diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h index 48be702bc..56e9fbfa7 100644 --- a/lib/librte_sched/rte_sched.h +++ b/lib/librte_sched/rte_sched.h @@ -308,6 +308,8 @@ rte_sched_port_free(struct rte_sched_port *port); * * @param port * Handle to port scheduler instance + * @param subport_id + * Subport ID * @param params * Pipe profile parameters * @param pipe_profile_id @@ -318,6 +320,7 @@ rte_sched_port_free(struct rte_sched_port *port); __rte_experimental int rte_sched_port_pipe_profile_add(struct rte_sched_port *port, + uint32_t subport_id, struct rte_sched_pipe_params *params, uint32_t *pipe_profile_id); @@ -348,7 +351,7 @@ rte_sched_subport_config(struct rte_sched_port *port, * @param pipe_id * Pipe ID within subport * @param pipe_profile - * ID of port-level pre-configured pipe profile + * ID of subport-level pre-configured pipe profile * @return * 0 upon success, error code otherwise */ -- 2.21.0