Credits are updated by fetching subport profile parameters from
subport profile table. Similarly subport best effort tc is
calculated in pipe config.

Signed-off-by: Savinay Dharmappa <savinay.dharma...@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.si...@intel.com>
---
 lib/librte_sched/rte_sched.c | 55 ++++++++++++++++++++++++++------------------
 1 file changed, 33 insertions(+), 22 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 23aaec4..3f61afa 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -123,6 +123,7 @@ struct rte_sched_grinder {
        uint32_t productive;
        uint32_t pindex;
        struct rte_sched_subport *subport;
+       struct rte_sched_subport_profile *subport_params;
        struct rte_sched_pipe *pipe;
        struct rte_sched_pipe_profile *pipe_params;
 
@@ -1401,6 +1402,7 @@ rte_sched_pipe_config(struct rte_sched_port *port,
        int32_t pipe_profile)
 {
        struct rte_sched_subport *s;
+       struct rte_sched_subport_profile *sp;
        struct rte_sched_pipe *p;
        struct rte_sched_pipe_profile *params;
        uint32_t n_subports = subport_id + 1;
@@ -1441,14 +1443,15 @@ rte_sched_pipe_config(struct rte_sched_port *port,
                return -EINVAL;
        }
 
+       sp = port->subport_profiles + s->profile;
        /* Handle the case when pipe already has a valid configuration */
        p = s->pipe + pipe_id;
        if (p->tb_time) {
                params = s->pipe_profiles + p->profile;
 
                double subport_tc_be_rate =
-                       (double) 
s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
-                       / (double) s->tc_period;
+               (double)sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
+                       / (double) sp->tc_period;
                double pipe_tc_be_rate =
                        (double) 
params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
                        / (double) params->tc_period;
@@ -1490,8 +1493,8 @@ rte_sched_pipe_config(struct rte_sched_port *port,
        {
                /* Subport best effort tc oversubscription */
                double subport_tc_be_rate =
-                       (double) 
s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
-                       / (double) s->tc_period;
+               (double)sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
+                       / (double) sp->tc_period;
                double pipe_tc_be_rate =
                        (double) 
params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
                        / (double) params->tc_period;
@@ -2279,14 +2282,15 @@ grinder_credits_update(struct rte_sched_port *port,
        struct rte_sched_grinder *grinder = subport->grinder + pos;
        struct rte_sched_pipe *pipe = grinder->pipe;
        struct rte_sched_pipe_profile *params = grinder->pipe_params;
+       struct rte_sched_subport_profile *sp = grinder->subport_params;
        uint64_t n_periods;
        uint32_t i;
 
        /* Subport TB */
-       n_periods = (port->time - subport->tb_time) / subport->tb_period;
-       subport->tb_credits += n_periods * subport->tb_credits_per_period;
-       subport->tb_credits = RTE_MIN(subport->tb_credits, subport->tb_size);
-       subport->tb_time += n_periods * subport->tb_period;
+       n_periods = (port->time - subport->tb_time) / sp->tb_period;
+       subport->tb_credits += n_periods * sp->tb_credits_per_period;
+       subport->tb_credits = RTE_MIN(subport->tb_credits, sp->tb_size);
+       subport->tb_time += n_periods * sp->tb_period;
 
        /* Pipe TB */
        n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2297,9 +2301,9 @@ grinder_credits_update(struct rte_sched_port *port,
        /* Subport TCs */
        if (unlikely(port->time >= subport->tc_time)) {
                for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-                       subport->tc_credits[i] = 
subport->tc_credits_per_period[i];
+                       subport->tc_credits[i] = sp->tc_credits_per_period[i];
 
-               subport->tc_time = port->time + subport->tc_period;
+               subport->tc_time = port->time + sp->tc_period;
        }
 
        /* Pipe TCs */
@@ -2315,8 +2319,10 @@ grinder_credits_update(struct rte_sched_port *port,
 
 static inline uint64_t
 grinder_tc_ov_credits_update(struct rte_sched_port *port,
-       struct rte_sched_subport *subport)
+       struct rte_sched_subport *subport, uint32_t pos)
 {
+       struct rte_sched_grinder *grinder = subport->grinder + pos;
+       struct rte_sched_subport_profile *sp = grinder->subport_params;
        uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
        uint64_t tc_consumption = 0, tc_ov_consumption_max;
        uint64_t tc_ov_wm = subport->tc_ov_wm;
@@ -2326,17 +2332,17 @@ grinder_tc_ov_credits_update(struct rte_sched_port 
*port,
                return subport->tc_ov_wm_max;
 
        for (i = 0; i < RTE_SCHED_TRAFFIC_CLASS_BE; i++) {
-               tc_ov_consumption[i] =
-                       subport->tc_credits_per_period[i] - 
subport->tc_credits[i];
+               tc_ov_consumption[i] = sp->tc_credits_per_period[i]
+                                       -  subport->tc_credits[i];
                tc_consumption += tc_ov_consumption[i];
        }
 
        tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] =
-               subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
+       sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
                subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE];
 
        tc_ov_consumption_max =
-               subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
+       sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
                        tc_consumption;
 
        if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] >
@@ -2362,14 +2368,15 @@ grinder_credits_update(struct rte_sched_port *port,
        struct rte_sched_grinder *grinder = subport->grinder + pos;
        struct rte_sched_pipe *pipe = grinder->pipe;
        struct rte_sched_pipe_profile *params = grinder->pipe_params;
+       struct rte_sched_subport_profile *sp = grinder->subport_params;
        uint64_t n_periods;
        uint32_t i;
 
        /* Subport TB */
-       n_periods = (port->time - subport->tb_time) / subport->tb_period;
-       subport->tb_credits += n_periods * subport->tb_credits_per_period;
-       subport->tb_credits = RTE_MIN(subport->tb_credits, subport->tb_size);
-       subport->tb_time += n_periods * subport->tb_period;
+       n_periods = (port->time - subport->tb_time) / sp->tb_period;
+       subport->tb_credits += n_periods * sp->tb_credits_per_period;
+       subport->tb_credits = RTE_MIN(subport->tb_credits, sp->tb_size);
+       subport->tb_time += n_periods * sp->tb_period;
 
        /* Pipe TB */
        n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2379,12 +2386,13 @@ grinder_credits_update(struct rte_sched_port *port,
 
        /* Subport TCs */
        if (unlikely(port->time >= subport->tc_time)) {
-               subport->tc_ov_wm = grinder_tc_ov_credits_update(port, subport);
+               subport->tc_ov_wm =
+                       grinder_tc_ov_credits_update(port, subport, pos);
 
                for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-                       subport->tc_credits[i] = 
subport->tc_credits_per_period[i];
+                       subport->tc_credits[i] = sp->tc_credits_per_period[i];
 
-               subport->tc_time = port->time + subport->tc_period;
+               subport->tc_time = port->time + sp->tc_period;
                subport->tc_ov_period_id++;
        }
 
@@ -2907,6 +2915,9 @@ grinder_handle(struct rte_sched_port *port,
                struct rte_sched_pipe *pipe = grinder->pipe;
 
                grinder->pipe_params = subport->pipe_profiles + pipe->profile;
+               grinder->subport_params = port->subport_profiles +
+                                               subport->profile;
+
                grinder_prefetch_tc_queue_arrays(subport, pos);
                grinder_credits_update(port, subport, pos);
 
-- 
2.7.4

Reply via email to