From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 8C459567E for ; Thu, 29 Jun 2017 16:36:45 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id p204so2955034wmg.1 for ; Thu, 29 Jun 2017 07:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fGaT4DUCjB58H3kbCIYRveq2V6CMyzC4yYba0ZENn5g=; b=PjCX9ArPFRD2sllM8SREG8rw4sEwPW7RqfG6h7yQGojiGWonJphBONu2OZmj9mcytq ZH0D9Oc1iOMtIXMlueXRGNS+MMvfeYuQPEin6NeTmnGUKSVmLJPra5KSOpL6mCngH336 2DVYqtLjyPIdcKcYUjED1Rneh303SIqfS4ZbmwXm5ppsp08bgi7dYXSEKZtPkNFj/xoi YdTme8Y9kBgv34f7fm7WZl5xqJzpfMKOp03v4xlRrRySwD7M8ptXz1bhdO4dlkXtkIYI pyARSU1gSmtatCJg7PUHoYjv8UmQ0hyBM+xzf89GiaHCJ4ESkEMNg28AkDoaxFs9nF/U XnNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fGaT4DUCjB58H3kbCIYRveq2V6CMyzC4yYba0ZENn5g=; b=pC39atVyq7MJWPV7jgp6dFN24fVGy88enDuX1FpSWyGPlk1Ckhr4ZjRr4fxUCTcFEm xRHgNlucwPwALg8kgEEkiGBXI+Kdq8yBEfDDU4r6JkbnHby7FBx7xsWmHpianvVvX4tX L6josBqb7BAO2NW5fHHjj9lDNuWd4/rXLqpOZWlfldXPFJDsOB6+Q3yeDALNCdujA9cr 2+h5wn7tIKcGYZHzBUVqM8tYoaMzOD/TFAEwKdhOGQPWMMzMRgv+YkDLJ2mi4HnsfFPU loL9kiM0MF3v3efDrzMUG56ZMy7VB7EC9yB8LooLqnbBkpySWExawT4q2hdFTGwMtuaR pHDw== X-Gm-Message-State: AIVw112WGRvQg8QTUqtTlFcEaI495WHhLJYDk5EVeHp8bngMYQ+zPKQL enFGfNJDDr4kVTK3 X-Received: by 10.28.58.147 with SMTP id h141mr2420255wma.112.1498747004686; Thu, 29 Jun 2017 07:36:44 -0700 (PDT) Received: from localhost.localdomain (160.203.7.109.rev.sfr.net. [109.7.203.160]) by smtp.gmail.com with ESMTPSA id 24sm5513908wrw.0.2017.06.29.07.36.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jun 2017 07:36:44 -0700 (PDT) From: Olivier Chirossel To: dev@dpdk.org Cc: Olivier Chirossel Date: Thu, 29 Jun 2017 16:35:42 +0200 Message-Id: <1498746942-1741-2-git-send-email-olivier.chirossel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498746942-1741-1-git-send-email-olivier.chirossel@gmail.com> References: <1498746942-1741-1-git-send-email-olivier.chirossel@gmail.com> Subject: [dpdk-dev] [PATCH v2] lib/librte_sched: fix update tc_credits X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jun 2017 14:36:45 -0000 Signed-off-by: Olivier Chirossel 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.rst b/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_t tc_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_t tc_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(struct rte_sched_port *port, struct rte /* Traffic Classes */ dst->tc_period = rte_sched_time_ms_to_bytes(src->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->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->tc_credits_per_period[j]) < subport->tc_rate[j]) { + subport->tc_credits[j] += subport->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->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->tc_credits_per_period[j]) < subport->tc_rate[j]) { + subport->tc_credits[j] += subport->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->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