Modify the ip_pipeline application to build the hierarchical scheduler
with default subport bandwidth profile. It also allows to configure
a subport with different subport bandwidth profile dynamically

Signed-off-by: Savinay Dharmappa <savinay.dharma...@intel.com>
---
 examples/ip_pipeline/cli.c  | 17 +++++------
 examples/ip_pipeline/tmgr.c | 57 ++++++++++++++++++++++++-------------
 examples/ip_pipeline/tmgr.h |  7 ++++-
 3 files changed, 52 insertions(+), 29 deletions(-)

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index dafc95ae9..b4d95bb1d 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -406,7 +406,7 @@ cmd_tmgr_subport_profile(char **tokens,
        char *out,
        size_t out_size)
 {
-       struct rte_sched_subport_params p;
+       struct tmgr_subport sp;
        int status, i;
 
        if (n_tokens != 35) {
@@ -414,23 +414,23 @@ cmd_tmgr_subport_profile(char **tokens,
                return;
        }
 
-       if (parser_read_uint64(&p.tb_rate, tokens[3]) != 0) {
+       if (parser_read_uint64(&sp.pp.tb_rate, tokens[3]) != 0) {
                snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
                return;
        }
 
-       if (parser_read_uint64(&p.tb_size, tokens[4]) != 0) {
+       if (parser_read_uint64(&sp.pp.tb_size, tokens[4]) != 0) {
                snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
                return;
        }
 
        for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-               if (parser_read_uint64(&p.tc_rate[i], tokens[5 + i]) != 0) {
+               if (parser_read_uint64(&sp.pp.tc_rate[i], tokens[5 + i]) != 0) {
                        snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
                        return;
                }
 
-       if (parser_read_uint64(&p.tc_period, tokens[18]) != 0) {
+       if (parser_read_uint64(&sp.pp.tc_period, tokens[18]) != 0) {
                snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
                return;
        }
@@ -440,7 +440,8 @@ cmd_tmgr_subport_profile(char **tokens,
                return;
        }
 
-       if (parser_read_uint32(&p.n_pipes_per_subport_enabled, tokens[20]) != 
0) {
+       if (parser_read_uint32(&sp.p.n_pipes_per_subport_enabled,
+               tokens[20]) != 0) {
                snprintf(out, out_size, MSG_ARG_INVALID, "n_pipes_per_subport");
                return;
        }
@@ -451,12 +452,12 @@ cmd_tmgr_subport_profile(char **tokens,
        }
 
        for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-               if (parser_read_uint16(&p.qsize[i], tokens[22 + i]) != 0) {
+               if (parser_read_uint16(&sp.p.qsize[i], tokens[22 + i]) != 0) {
                        snprintf(out, out_size, MSG_ARG_INVALID, "qsize");
                        return;
                }
 
-       status = tmgr_subport_profile_add(&p);
+       status = tmgr_subport_profile_add(&sp);
        if (status != 0) {
                snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
                return;
diff --git a/examples/ip_pipeline/tmgr.c b/examples/ip_pipeline/tmgr.c
index 91ccbf60f..446df8fe2 100644
--- a/examples/ip_pipeline/tmgr.c
+++ b/examples/ip_pipeline/tmgr.c
@@ -8,8 +8,15 @@
 
 #include "tmgr.h"
 
-static struct rte_sched_subport_params
-       subport_profile[TMGR_SUBPORT_PROFILE_MAX];
+struct subport_profile_params {
+       struct rte_sched_subport_params
+               params[TMGR_SUBPORT_PROFILE_MAX];
+
+       struct rte_sched_subport_profile_params
+               profile[TMGR_SUBPORT_PROFILE_MAX];
+};
+
+static struct subport_profile_params subport_profile;
 
 static uint32_t n_subport_profiles;
 
@@ -44,17 +51,21 @@ tmgr_port_find(const char *name)
 }
 
 int
-tmgr_subport_profile_add(struct rte_sched_subport_params *p)
+tmgr_subport_profile_add(struct tmgr_subport *params)
 {
        /* Check input params */
-       if (p == NULL ||
-               p->n_pipes_per_subport_enabled == 0)
+       if (params == NULL ||
+               params->p.n_pipes_per_subport_enabled == 0)
                return -1;
 
        /* Save profile */
-       memcpy(&subport_profile[n_subport_profiles],
-               p,
-               sizeof(*p));
+       memcpy(&subport_profile.params[n_subport_profiles],
+               &params->p,
+               sizeof(params->p));
+
+       memcpy(&subport_profile.profile[n_subport_profiles],
+               &params->pp,
+               sizeof(params->pp));
 
        n_subport_profiles++;
 
@@ -103,30 +114,35 @@ tmgr_port_create(const char *name, struct 
tmgr_port_params *params)
        p.mtu = params->mtu;
        p.frame_overhead = params->frame_overhead;
        p.n_subports_per_port = params->n_subports_per_port;
+       p.n_subport_profiles = n_subport_profiles;
+       p.subport_profiles = subport_profile.profile;
+       p.n_max_subport_profiles = TMGR_SUBPORT_PROFILE_MAX;
        p.n_pipes_per_subport = TMGR_PIPE_SUBPORT_MAX;
 
        s = rte_sched_port_config(&p);
        if (s == NULL)
                return NULL;
 
-       subport_profile[0].pipe_profiles = pipe_profile;
-       subport_profile[0].n_pipe_profiles = n_pipe_profiles;
-       subport_profile[0].n_max_pipe_profiles = TMGR_PIPE_PROFILE_MAX;
+       subport_profile.params[0].pipe_profiles = pipe_profile;
+       subport_profile.params[0].n_pipe_profiles = n_pipe_profiles;
+       subport_profile.params[0].n_max_pipe_profiles = TMGR_PIPE_PROFILE_MAX;
 
        for (i = 0; i < params->n_subports_per_port; i++) {
                int status;
 
-               status = rte_sched_subport_config(
+               status = rte_dynamic_sched_subport_config(
                        s,
                        i,
-                       &subport_profile[0]);
+                       &subport_profile.params[0], 0);
 
                if (status) {
                        rte_sched_port_free(s);
                        return NULL;
                }
 
-               for (j = 0; j < subport_profile[0].n_pipes_per_subport_enabled; 
j++) {
+               for (j = 0; j <
+               subport_profile.params[0].n_pipes_per_subport_enabled; j++) {
+
                        status = rte_sched_pipe_config(
                                s,
                                i,
@@ -177,10 +193,11 @@ tmgr_subport_config(const char *port_name,
                return -1;
 
        /* Resource config */
-       status = rte_sched_subport_config(
+       status = rte_dynamic_sched_subport_config(
                port->s,
                subport_id,
-               &subport_profile[subport_profile_id]);
+               NULL,
+               subport_profile_id);
 
        return status;
 }
@@ -203,10 +220,10 @@ tmgr_pipe_config(const char *port_name,
        if ((port == NULL) ||
                (subport_id >= port->n_subports_per_port) ||
                (pipe_id_first >=
-                       
subport_profile[subport_id].n_pipes_per_subport_enabled) ||
-               (pipe_id_last >=
-                       
subport_profile[subport_id].n_pipes_per_subport_enabled) ||
-               (pipe_id_first > pipe_id_last) ||
+               subport_profile.params[subport_id].n_pipes_per_subport_enabled)
+               || (pipe_id_last >=
+               subport_profile.params[subport_id].n_pipes_per_subport_enabled)
+               || (pipe_id_first > pipe_id_last) ||
                (pipe_profile_id >= n_pipe_profiles))
                return -1;
 
diff --git a/examples/ip_pipeline/tmgr.h b/examples/ip_pipeline/tmgr.h
index ee50cf7cc..b651ede4a 100644
--- a/examples/ip_pipeline/tmgr.h
+++ b/examples/ip_pipeline/tmgr.h
@@ -31,6 +31,11 @@ struct tmgr_port {
        uint32_t n_subports_per_port;
 };
 
+struct tmgr_subport {
+       struct rte_sched_subport_params  p;
+       struct rte_sched_subport_profile_params pp;
+};
+
 TAILQ_HEAD(tmgr_port_list, tmgr_port);
 
 int
@@ -48,7 +53,7 @@ struct tmgr_port_params {
 };
 
 int
-tmgr_subport_profile_add(struct rte_sched_subport_params *p);
+tmgr_subport_profile_add(struct tmgr_subport *sp);
 
 int
 tmgr_pipe_profile_add(struct rte_sched_pipe_params *p);
-- 
2.17.1

Reply via email to