DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
To: dev@dpdk.org
Cc: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Subject: [dpdk-dev] [PATCH 1/2] sched: refine get base helper function
Date: Wed, 28 Nov 2018 05:55:54 -0800	[thread overview]
Message-ID: <1543413355-2874-1-git-send-email-xiangxia.m.yue@gmail.com> (raw)

use switch instead of if, and it is more easy reading.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 lib/librte_sched/rte_sched.c | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 587d5e6..17de6e6 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -385,7 +385,7 @@ enum rte_sched_port_array {
 	uint32_t n_subports_per_port = params->n_subports_per_port;
 	uint32_t n_pipes_per_subport = params->n_pipes_per_subport;
 	uint32_t n_pipes_per_port = n_pipes_per_subport * n_subports_per_port;
-	uint32_t n_queues_per_port = RTE_SCHED_QUEUES_PER_PIPE * n_pipes_per_subport * n_subports_per_port;
+	uint32_t n_queues_per_port = RTE_SCHED_QUEUES_PER_PIPE * n_pipes_per_port;
 
 	uint32_t size_subport = n_subports_per_port * sizeof(struct rte_sched_subport);
 	uint32_t size_pipe = n_pipes_per_port * sizeof(struct rte_sched_pipe);
@@ -407,35 +407,33 @@ enum rte_sched_port_array {
 	size_queue_array = n_pipes_per_port * size_per_pipe_queue_array;
 
 	base = 0;
+	switch (array) {
+	case e_RTE_SCHED_PORT_ARRAY_TOTAL:
+		base += RTE_CACHE_LINE_ROUNDUP(size_queue_array);
 
-	if (array == e_RTE_SCHED_PORT_ARRAY_SUBPORT)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_subport);
+	case e_RTE_SCHED_PORT_ARRAY_QUEUE_ARRAY:
+		base += RTE_CACHE_LINE_ROUNDUP(size_bmp_array);
 
-	if (array == e_RTE_SCHED_PORT_ARRAY_PIPE)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_pipe);
+	case e_RTE_SCHED_PORT_ARRAY_BMP_ARRAY:
+		base += RTE_CACHE_LINE_ROUNDUP(size_pipe_profiles);
 
-	if (array == e_RTE_SCHED_PORT_ARRAY_QUEUE)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_queue);
+	case e_RTE_SCHED_PORT_ARRAY_PIPE_PROFILES:
+		base += RTE_CACHE_LINE_ROUNDUP(size_queue_extra);
 
-	if (array == e_RTE_SCHED_PORT_ARRAY_QUEUE_EXTRA)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_queue_extra);
+	case e_RTE_SCHED_PORT_ARRAY_QUEUE_EXTRA:
+		base += RTE_CACHE_LINE_ROUNDUP(size_queue);
 
-	if (array == e_RTE_SCHED_PORT_ARRAY_PIPE_PROFILES)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_pipe_profiles);
+	case e_RTE_SCHED_PORT_ARRAY_QUEUE:
+		base += RTE_CACHE_LINE_ROUNDUP(size_pipe);
 
-	if (array == e_RTE_SCHED_PORT_ARRAY_BMP_ARRAY)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_bmp_array);
+	case e_RTE_SCHED_PORT_ARRAY_PIPE:
+		base += RTE_CACHE_LINE_ROUNDUP(size_subport);
 
-	if (array == e_RTE_SCHED_PORT_ARRAY_QUEUE_ARRAY)
+	case e_RTE_SCHED_PORT_ARRAY_SUBPORT:
 		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_queue_array);
+	}
 
+	RTE_LOG(DEBUG, SCHED, "Should not reach here. \n");
 	return base;
 }
 
-- 
1.8.3.1

             reply	other threads:[~2018-11-28 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28 13:55 Tonghao Zhang [this message]
2018-11-28 13:55 ` [dpdk-dev] [PATCH 2/2] sched: fix possible mem leak on initialize Tonghao Zhang
2018-12-11  2:54   ` Tonghao Zhang
2018-12-20 19:09     ` Dumitrescu, Cristian
2018-12-20 19:10 ` [dpdk-dev] [PATCH 1/2] sched: refine get base helper function Dumitrescu, Cristian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1543413355-2874-1-git-send-email-xiangxia.m.yue@gmail.com \
    --to=xiangxia.m.yue@gmail.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).