[dpdk-dev] [PATCH 2/2] test/sched: add test for pipe profile add api
Jasvinder Singh
jasvinder.singh at intel.com
Fri Mar 9 19:41:14 CET 2018
Update the unit test to check the working of new API.
Signed-off-by: Jasvinder Singh <jasvinder.singh at intel.com>
---
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
More information about the dev
mailing list