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 EAB10A04B7; Wed, 2 Sep 2020 10:58:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9945E1C0B7; Wed, 2 Sep 2020 10:58:32 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 630571C0AC for ; Wed, 2 Sep 2020 10:58:30 +0200 (CEST) IronPort-SDR: z98CMACtdqvMzOENdQNMMi3Z3d61wvSDiCbhbneU9j9etagVoRVHEwEgls5uQjSRRXegcHhCVf PNJKHBjcNP3Q== X-IronPort-AV: E=McAfee;i="6000,8403,9731"; a="242173515" X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="242173515" 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:27 -0700 IronPort-SDR: SC1glCaeRE1qhdguDtymc/oyde0HvA8U9PwsnmLVXnfIwBR47t4kJWFExjjPbvhhgrZMYZKb5K BSWZ7HJV44EQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="477557379" Received: from unknown (HELO silpixa00400629.ir.intel.com) ([10.237.214.135]) by orsmga005.jf.intel.com with ESMTP; 02 Sep 2020 01:58:26 -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:45 +0100 Message-Id: <1599037006-3931-3-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 3/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 add public APIs to add new subport profile and to configure them. Signed-off-by: Savinay Dharmappa Signed-off-by: Jasvinder Singh --- lib/librte_sched/rte_sched.c | 115 ++++++++++++++++++++++++++++++++++++++++++- lib/librte_sched/rte_sched.h | 45 +++++++++++++++++ 2 files changed, 158 insertions(+), 2 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index c1846d0..770c8bd 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -1212,8 +1212,8 @@ rte_sched_subport_config(struct rte_sched_port *port, s->bmp = rte_bitmap_init(n_subport_pipe_queues, s->bmp_array, bmp_mem_size); if (s->bmp == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Subport bitmap init error\n", __func__); + RTE_LOG(ERR, SCHED, "%s: " + "Subport bitmap init error\n", __func__); rte_sched_free_memory(port, n_subports); return -EINVAL; @@ -1235,6 +1235,52 @@ rte_sched_subport_config(struct rte_sched_port *port, return 0; } +int +rte_sched_subport_profile_config(struct rte_sched_port *port, + uint32_t subport_id, + uint32_t profile_id) +{ + int i; + struct rte_sched_subport_profile *params; + uint32_t n_subports = subport_id + 1; + struct rte_sched_subport *s; + + if (port == NULL) { + RTE_LOG(ERR, SCHED, "%s: " + "Incorrect value for parameter port\n", __func__); + return -EINVAL; + } + + 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; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size / 2; + + s->tc_time = port->time + params->tc_period; + + for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) + if (s->qsize[i]) + s->tc_credits[i] = params->tc_credits_per_period[i]; + else + params->tc_credits_per_period[i] = 0; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max = rte_sched_time_ms_to_bytes(params->tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + + rte_sched_port_log_subport_profile(port, profile_id); + return 0; } @@ -1422,6 +1468,71 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, return 0; } +int +rte_sched_port_subport_profile_add(struct rte_sched_port *port, + struct rte_sched_subport_profile_params *params, + uint32_t *subport_profile_id) +{ + int status; + uint32_t i; + struct rte_sched_subport_profile *dst; + + /* Port */ + if (port == NULL) { + RTE_LOG(ERR, SCHED, "%s: " + "Incorrect value for parameter port\n", __func__); + return -EINVAL; + } + + if (params == NULL) { + RTE_LOG(ERR, SCHED, "%s: " + "Incorrect value for parameter profile\n", __func__); + return -EINVAL; + } + + if (subport_profile_id == NULL) { + RTE_LOG(ERR, SCHED, "%s: " + "Incorrect value for parametersubport_profile_id\n", + __func__); + return -EINVAL; + } + + dst = port->subport_profiles + port->n_subport_profiles; + + /* Subport profiles exceeds the max limit */ + if (port->n_subport_profiles >= port->n_max_subport_profiles) { + RTE_LOG(ERR, SCHED, "%s: " + "Number of subport profiles exceeds the max limit", __func__); + return -EINVAL; + } + + status = subport_profile_check(params, port->rate); + if (status != 0) { + RTE_LOG(ERR, SCHED, "%s: " + "subport profile check failed(%d)\n", __func__, status); + return -EINVAL; + } + + rte_sched_subport_profile_convert(params, dst, port->rate); + + /* Subport profile should not exists */ + for (i = 0; i < port->n_subport_profiles; i++) + if (memcmp(port->subport_profiles + i, + params, sizeof(*params)) == 0) { + RTE_LOG(ERR, SCHED, + "%s: subport profile exists\n", __func__); + return -EINVAL; + } + + /* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + + rte_sched_port_log_subport_profile(port, *subport_profile_id); + + return 0; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport, diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h index e7514bb..7623919 100644 --- a/lib/librte_sched/rte_sched.h +++ b/lib/librte_sched/rte_sched.h @@ -325,6 +325,29 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, uint32_t *pipe_profile_id); /** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Hierarchical scheduler subport bandwidth profile add + * Note that this function is safe to use in runtime for adding new + * subport bandwidth profile as it doesn't have any impact on hiearchical + * structure of the scheduler. + * @param port + * Handle to port scheduler instance + * @param struct rte_sched_subport_profile + * Subport bandwidth profile + * @param subport_profile_d + * Subport profile id + * @return + * 0 upon success, error code otherwise + */ +__rte_experimental +int +rte_sched_port_subport_profile_add(struct rte_sched_port *port, + struct rte_sched_subport_profile_params *profile, + uint32_t *subport_profile_id); + +/** * Hierarchical scheduler subport configuration * * @param port @@ -342,6 +365,28 @@ rte_sched_subport_config(struct rte_sched_port *port, struct rte_sched_subport_params *params); /** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Hierarchical scheduler subport profile configuration + * Note that this function is safe to use in runtime for applying any specific + * subport bandwidth profile as it doesn't have any impact on hiearchical + * structure of the scheduler. + * @param port + * Handle to port scheduler instance + * @param subport_id + * Subport ID + * @param profile_d + * Subport profile id + * @return + * 0 upon success, error code otherwise + */ +__rte_experimental +int +rte_sched_subport_profile_config(struct rte_sched_port *port, + uint32_t subport_id, + uint32_t profile_id); +/** * Hierarchical scheduler pipe configuration * * @param port -- 2.7.4