From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jasvinder Singh Subject: [PATCH 2/2] test/sched: add test for pipe profile add api Date: Fri, 9 Mar 2018 18:41:14 +0000 Message-ID: <20180309184114.139136-2-jasvinder.singh@intel.com> References: <20180309184114.139136-1-jasvinder.singh@intel.com> Cc: cristian.dumitrescu@intel.com To: dev@dpdk.org Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 7183B5B34 for ; Fri, 9 Mar 2018 19:41:19 +0100 (CET) In-Reply-To: <20180309184114.139136-1-jasvinder.singh@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Update the unit test to check the working of new API. Signed-off-by: Jasvinder Singh --- test/test/test_sched.c | 91 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/test/test/test_sched.c b/test/test/test_sched.c index 32e500b..5d30187 100644 --- a/test/test/test_sched.c +++ b/test/test/test_sched.c @@ -44,6 +44,18 @@ static struct rte_sched_pipe_params pipe_profile[] = { }, }; +static struct rte_sched_pipe_params pipe_profile1 = { + /* Profile #1 */ + .tb_rate = 300000, + .tb_size = 100000, + + .tc_rate = {300000, 300000, 300000, 300000}, + .tc_period = 40, + + .wrr_weights = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, +}; + + static struct rte_sched_port_params port_param = { .socket = 0, /* computed */ .rate = 0, /* computed */ @@ -102,7 +114,23 @@ prepare_pkt(struct rte_mbuf *mbuf) mbuf->data_len = 60; } +static int pipe_profile_set(struct rte_sched_port *port, + struct rte_sched_pipe_params *params) +{ + uint32_t pipe; + int32_t profile_id, err; + err = rte_sched_pipe_profile_add(port, params, &profile_id); + if (err) + return err; + + for (pipe = 0; pipe < port_param.n_pipes_per_subport; pipe++) { + err = rte_sched_pipe_config(port, SUBPORT, pipe, profile_id); + TEST_ASSERT_SUCCESS(err, "Error config sched pipe %u, err=%d\n", + pipe, err); + } + return 0; +} /** * test main entrance for library sched */ @@ -114,7 +142,7 @@ test_sched(void) uint32_t pipe; struct rte_mbuf *in_mbufs[10]; struct rte_mbuf *out_mbufs[10]; - int i; + int i, pipe_profile = 0; int err; @@ -135,35 +163,42 @@ test_sched(void) TEST_ASSERT_SUCCESS(err, "Error config sched pipe %u, err=%d\n", pipe, err); } - for (i = 0; i < 10; i++) { - in_mbufs[i] = rte_pktmbuf_alloc(mp); - TEST_ASSERT_NOT_NULL(in_mbufs[i], "Packet allocation failed\n"); - prepare_pkt(in_mbufs[i]); - } + while (pipe_profile < 2) { + for (i = 0; i < 10; i++) { + in_mbufs[i] = rte_pktmbuf_alloc(mp); + TEST_ASSERT_NOT_NULL(in_mbufs[i], + "Packet allocation failed\n"); + prepare_pkt(in_mbufs[i]); + } - err = rte_sched_port_enqueue(port, in_mbufs, 10); - TEST_ASSERT_EQUAL(err, 10, "Wrong enqueue, err=%d\n", err); + err = rte_sched_port_enqueue(port, in_mbufs, 10); + TEST_ASSERT_EQUAL(err, 10, "Wrong enqueue, err=%d\n", err); - err = rte_sched_port_dequeue(port, out_mbufs, 10); - TEST_ASSERT_EQUAL(err, 10, "Wrong dequeue, err=%d\n", err); + err = rte_sched_port_dequeue(port, out_mbufs, 10); + TEST_ASSERT_EQUAL(err, 10, "Wrong dequeue, err=%d\n", err); - for (i = 0; i < 10; i++) { - enum rte_meter_color color; - uint32_t subport, traffic_class, queue; + for (i = 0; i < 10; i++) { + enum rte_meter_color color; + uint32_t subport, traffic_class, queue; - color = rte_sched_port_pkt_read_color(out_mbufs[i]); - TEST_ASSERT_EQUAL(color, e_RTE_METER_YELLOW, "Wrong color\n"); + color = rte_sched_port_pkt_read_color(out_mbufs[i]); + TEST_ASSERT_EQUAL(color, + e_RTE_METER_YELLOW, "Wrong color\n"); - rte_sched_port_pkt_read_tree_path(out_mbufs[i], - &subport, &pipe, &traffic_class, &queue); + rte_sched_port_pkt_read_tree_path(out_mbufs[i], + &subport, + &pipe, + &traffic_class, + &queue); - TEST_ASSERT_EQUAL(subport, SUBPORT, "Wrong subport\n"); - TEST_ASSERT_EQUAL(pipe, PIPE, "Wrong pipe\n"); - TEST_ASSERT_EQUAL(traffic_class, TC, "Wrong traffic_class\n"); - TEST_ASSERT_EQUAL(queue, QUEUE, "Wrong queue\n"); + TEST_ASSERT_EQUAL(subport, SUBPORT, "Wrong subport\n"); + TEST_ASSERT_EQUAL(pipe, PIPE, "Wrong pipe\n"); + TEST_ASSERT_EQUAL(traffic_class, TC, + "Wrong traffic_class\n"); + TEST_ASSERT_EQUAL(queue, QUEUE, "Wrong queue\n"); - } + } struct rte_sched_subport_stats subport_stats; @@ -179,6 +214,18 @@ test_sched(void) TEST_ASSERT_EQUAL(queue_stats.n_pkts, 10, "Wrong queue stats\n"); #endif + for (i = 0; i < 10; i++) + rte_pktmbuf_free(in_mbufs[i]); + + pipe_profile += 1; + + if (pipe_profile == 1) { + err = pipe_profile_set(port, &pipe_profile1); + TEST_ASSERT_EQUAL(err, 0, + "Profile not added, err=%d\n", err); + } + } + rte_sched_port_free(port); return 0; -- 2.9.3