Re: [PATCH] [PATCH] lib/librte_sched: fix update tc_credits Actualy ( for small rate ) if tc_credits_per_period < packets length all packets are drop. also the credits presents before the updade are loose, because tc_credits is set to tc_credit
From: Dumitrescu, Cristian <hidden>
Date: 2017-06-26 10:43:34
quoted hunk
-----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Olivier Chirossel Sent: Monday, June 26, 2017 11:14 AM To: dev@dpdk.org Cc: Olivier Chirossel <redacted> Subject: [dpdk-dev] [PATCH] [PATCH] lib/librte_sched: fix update tc_credits Actualy ( for small rate ) if tc_credits_per_period < packets length all packets are drop. also the credits presents before the updade are loose, because tc_credits is set to tc_credits... --- doc/guides/prog_guide/qos_framework.rst | 10 ++++-- lib/librte_sched/rte_sched.c | 62 ++++++++++++++++++++++---------- - 2 files changed, 50 insertions(+), 22 deletions(-)diff --git a/doc/guides/prog_guide/qos_framework.rstb/doc/guides/prog_guide/qos_framework.rst index f3f60b8..e566ff9 100644--- a/doc/guides/prog_guide/qos_framework.rst +++ b/doc/guides/prog_guide/qos_framework.rst@@ -799,6 +799,9 @@ as described in :numref:`table_qos_10` and:numref:`table_qos_11`. | 4 | tc_credits | Bytes | Current upper limit for the number of credits that can be consumed by | | | | | the current traffic class for the remainder of the current | | | | | enforcement period. | + | | | | when The credits is update (every tc_period) the | + | | | | tc_credits_per_period is added to the value (tc_credits) if the new | + | | | | value is lower than tc_rate. else the value is set to tc_rate. | | | | | | +---+-----------------------+-------+---------------------------------------------------- -------------------+@@ -819,8 +822,11 @@ as described in :numref:`table_qos_10` and:numref:`table_qos_11`. | | | | | | | if (time >= tc_time) { | | | | | - | | | tc_credits = tc_credits_per_period; | - | | | | + | | | if (tc_credits + tc_credits_per_period < tc_rate) { | + | | | tc_credits += tc_credits_per_period | + | | | else { | + | | | tc_credits = tc_rate | + | | | } | | | | tc_time = time + tc_period; | | | | | | | | } |diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 614705d..7d15eee 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c@@ -83,6 +83,7 @@ struct rte_sched_subport { /* Traffic classes (TCs) */ uint64_t tc_time; /* time of next update */ + uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; uint32_ttc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; uint32_t tc_period;@@ -107,6 +108,7 @@ struct rte_sched_pipe_profile { uint32_t tb_size; /* Pipe traffic classes */ + uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; uint32_t tc_period; uint32_ttc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; uint8_t tc_ov_weight;@@ -566,11 +568,14 @@ rte_sched_port_config_pipe_profile_table(structrte_sched_port *port, struct rte /* Traffic Classes */ dst->tc_period = rte_sched_time_ms_to_bytes(src-quoted
tc_period,params->rate); - - for (j = 0; j < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; j++) + + for (j = 0; j < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; j++) { + dst->tc_rate[j] = src->tc_rate[j]; dst->tc_credits_per_period[j] = rte_sched_time_ms_to_bytes(src-quoted
tc_period,src->tc_rate[j]); + } + #ifdef RTE_SCHED_SUBPORT_TC_OV dst->tc_ov_weight = src->tc_ov_weight;@@ -836,6 +841,7 @@ rte_sched_subport_config(struct rte_sched_port*port, /* Traffic Classes (TCs) */ s->tc_period = rte_sched_time_ms_to_bytes(params->tc_period, port->rate); for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) { + s->tc_rate[i] = params->tc_rate[i]; s->tc_credits_per_period[i] = rte_sched_time_ms_to_bytes(params->tc_period, params->tc_rate[i]);@@ -1478,6 +1484,7 @@ grinder_credits_update(struct rte_sched_port*port, uint32_t pos) struct rte_sched_pipe *pipe = grinder->pipe; struct rte_sched_pipe_profile *params = grinder->pipe_params; uint64_t n_periods; + uint32_t j; /* Subport TB */ n_periods = (port->time - subport->tb_time) / subport->tb_period;@@ -1493,19 +1500,27 @@ grinder_credits_update(struct rte_sched_port*port, uint32_t pos) /* Subport TCs */ if (unlikely(port->time >= subport->tc_time)) { - subport->tc_credits[0] = subport->tc_credits_per_period[0]; - subport->tc_credits[1] = subport->tc_credits_per_period[1]; - subport->tc_credits[2] = subport->tc_credits_per_period[2]; - subport->tc_credits[3] = subport->tc_credits_per_period[3]; + for (j = 0; j < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; j++) { + if ((subport->tc_credits[j] + subport-quoted
tc_credits_per_period[j]) < subport->tc_rate[j]) {+ subport->tc_credits[j] += subport-quoted
tc_credits_per_period[j];+ } + else { + subport->tc_credits[j] = subport->tc_rate[j]; + } + } subport->tc_time = port->time + subport->tc_period; } /* Pipe TCs */ if (unlikely(port->time >= pipe->tc_time)) { - pipe->tc_credits[0] = params->tc_credits_per_period[0]; - pipe->tc_credits[1] = params->tc_credits_per_period[1]; - pipe->tc_credits[2] = params->tc_credits_per_period[2]; - pipe->tc_credits[3] = params->tc_credits_per_period[3]; + for (j = 0; j < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; j++) { + if ((pipe->tc_credits[j] + params-quoted
tc_credits_per_period[j]) < params->tc_rate[j]) {+ pipe->tc_credits[j] += params->tc_credits_per_period[j]; + } + else { + pipe->tc_credits[j] = params->tc_rate[j]; + } + } pipe->tc_time = port->time + params->tc_period; } }@@ -1555,6 +1570,7 @@ grinder_credits_update(struct rte_sched_port*port, uint32_t pos) struct rte_sched_pipe *pipe = grinder->pipe; struct rte_sched_pipe_profile *params = grinder->pipe_params; uint64_t n_periods; + uint32_t j; /* Subport TB */ n_periods = (port->time - subport->tb_time) / subport->tb_period;@@ -1571,22 +1587,28 @@ grinder_credits_update(struct rte_sched_port*port, uint32_t pos) /* Subport TCs */ if (unlikely(port->time >= subport->tc_time)) { subport->tc_ov_wm = grinder_tc_ov_credits_update(port, pos); - - subport->tc_credits[0] = subport->tc_credits_per_period[0]; - subport->tc_credits[1] = subport->tc_credits_per_period[1]; - subport->tc_credits[2] = subport->tc_credits_per_period[2]; - subport->tc_credits[3] = subport->tc_credits_per_period[3]; - + for (j = 0; j < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; j++) { + if ((subport->tc_credits[j] + subport-quoted
tc_credits_per_period[j]) < subport->tc_rate[j]) {+ subport->tc_credits[j] += subport-quoted
tc_credits_per_period[j];+ } + else { + subport->tc_credits[j] = subport->tc_rate[j]; + } + } subport->tc_time = port->time + subport->tc_period; subport->tc_ov_period_id++; } /* Pipe TCs */ if (unlikely(port->time >= pipe->tc_time)) { - pipe->tc_credits[0] = params->tc_credits_per_period[0]; - pipe->tc_credits[1] = params->tc_credits_per_period[1]; - pipe->tc_credits[2] = params->tc_credits_per_period[2]; - pipe->tc_credits[3] = params->tc_credits_per_period[3]; + for (j = 0; j < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; j++) { + if ((pipe->tc_credits[j] + params-quoted
tc_credits_per_period[j]) < params->tc_rate[j]) {+ pipe->tc_credits[j] += params->tc_credits_per_period[j]; + } + else { + pipe->tc_credits[j] = params->tc_rate[j]; + } + } pipe->tc_time = port->time + params->tc_period; } -- 2.7.4
Olivier, thank you for you patch, I will put it on my list of patches to review. Please add the Signed Off line, otherwise DPDK project cannot accept the patch. Please also add a clear description of the problem you are trying to solve in the patch or cover letter. Regards, Cristian