From patchwork Thu Jul 6 13:44:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Chirossel X-Patchwork-Id: 26539 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 4DC063772; Thu, 6 Jul 2017 15:44:57 +0200 (CEST) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id 9F6202B96 for ; Thu, 6 Jul 2017 15:44:56 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id k67so595550wrc.1 for ; Thu, 06 Jul 2017 06:44:56 -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=L/RvoPOtutAWbBh/qnuySqHb18v1OCAj+Kw+h7HjflI=; b=n9dxOiLOx6uGjJqwx2J7OoIjFn+L0KGgbbiw4tTgTyucZCUwIL5aPbcaJ4dJGg131U vTO+vt/SuXMQy1m04ZLQUkvBwp/5jaPfPpnGNZlVLk/X1TV0aTC4NUKmN0JiGx8GCTjt 6WS9mHtGU06ROgFXuhHAZCOIAx8Vl1Fg35O/T98N+Ick/2vGFS+54lm6Kdbu35TcTKss NsepslVfoPi+EJ7szkEZlgxqmuUklj08/echYYMpeEmicizDvkc+349HUpHhBTXylrEs nAop0ER1dVBPwb1g9XvYThaGjYEa6Eq3eyvShGywX6C4BT7JNCiE+HchPAq6RR6dOoAm WTPg== 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=L/RvoPOtutAWbBh/qnuySqHb18v1OCAj+Kw+h7HjflI=; b=WN7BHEB2S1KbyfS/YaVpjZFomyAPV7ocjiaAAouRlUjMIsCIHSAkNj/CCUaDtqfbha oW5cvA2/4rhaXPkHqWEdled7ftvk43PlcfG4bsld0CrabzPjtNoJtjaKv0EraKxfW9p9 G2jWk/4aOx/+T7fy+cMgAwTTw+DjKyyTRSqYMTyWVPOrzsjRQvVu3syaYlRNHWOj8M9Y I0aUCIU06iF3X0VZfjeqhIYz5glUgafLv3PJVvV6XODo7Xq8pjnUomEe/W6kSMFtudfd HwwHlIVqoAE5tabJS0XKGAuMc8sXjiT5M9FpH3jPpFYEhmv0sbdt/yuZ6OXpB4+ef/Ns 5iIA== X-Gm-Message-State: AKS2vOzmeLf1tNzSbIt6YsijaV4JuDIoeJxZjfQX071e9ZZ0RHgYROrJ u1OwHj+QW6gZVNu9WrA= X-Received: by 10.223.177.142 with SMTP id q14mr42309490wra.200.1499348696251; Thu, 06 Jul 2017 06:44:56 -0700 (PDT) Received: from localhost.localdomain (160.203.7.109.rev.sfr.net. [109.7.203.160]) by smtp.gmail.com with ESMTPSA id p27sm362556wmf.23.2017.07.06.06.44.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Jul 2017 06:44:55 -0700 (PDT) From: Olivier Chirossel To: dev@dpdk.org Cc: Olivier Chirossel Date: Thu, 6 Jul 2017 15:44:28 +0200 Message-Id: <1499348668-2155-2-git-send-email-olivier.chirossel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499348668-2155-1-git-send-email-olivier.chirossel@gmail.com> References: <1499348668-2155-1-git-send-email-olivier.chirossel@gmail.com> Subject: [dpdk-dev] [PATCH] [PATCH v3] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Olivier Chirossel --- doc/guides/prog_guide/qos_framework.rst | 10 ++- lib/librte_sched/rte_sched.c | 124 ++++++++++++++++++++++++++------ 2 files changed, 112 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 b7cba11..732d5ef 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -85,6 +85,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; @@ -109,6 +110,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; @@ -568,11 +570,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; @@ -838,6 +843,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]); @@ -1495,19 +1501,59 @@ 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]; + if (likely((subport->tc_credits[0] + subport->tc_credits_per_period[0]) < subport->tc_rate[0])) { + subport->tc_credits[0] += subport->tc_credits_per_period[0]; + } + else { + subport->tc_credits[0] = subport->tc_rate[0]; + } + if (likely((subport->tc_credits[1] + subport->tc_credits_per_period[1]) < subport->tc_rate[1])) { + subport->tc_credits[1] += subport->tc_credits_per_period[1]; + } + else { + subport->tc_credits[1] = subport->tc_rate[1]; + } + if (likely((subport->tc_credits[2] + subport->tc_credits_per_period[2]) < subport->tc_rate[2])) { + subport->tc_credits[2] += subport->tc_credits_per_period[2]; + } + else { + subport->tc_credits[2] = subport->tc_rate[2]; + } + if (likely((subport->tc_credits[3] + subport->tc_credits_per_period[3]) < subport->tc_rate[3])) { + subport->tc_credits[3] += subport->tc_credits_per_period[3]; + } + else { + subport->tc_credits[3] = subport->tc_rate[3]; + } 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]; + if (likely((pipe->tc_credits[0] + params->tc_credits_per_period[0]) < params->tc_rate[0])) { + pipe->tc_credits[0] += params->tc_credits_per_period[0]; + } + else { + pipe->tc_credits[0] = params->tc_rate[0]; + } + if (likely((pipe->tc_credits[1] + params->tc_credits_per_period[1]) < params->tc_rate[1])) { + pipe->tc_credits[1] += params->tc_credits_per_period[1]; + } + else { + pipe->tc_credits[1] = params->tc_rate[1]; + } + if (likely((pipe->tc_credits[2] + params->tc_credits_per_period[2]) < params->tc_rate[2])) { + pipe->tc_credits[2] += params->tc_credits_per_period[2]; + } + else { + pipe->tc_credits[2] = params->tc_rate[2]; + } + if (likely((pipe->tc_credits[3] + params->tc_credits_per_period[3]) < params->tc_rate[3])) { + pipe->tc_credits[3] += params->tc_credits_per_period[3]; + } + else { + pipe->tc_credits[3] = params->tc_rate[3]; + } pipe->tc_time = port->time + params->tc_period; } } @@ -1573,22 +1619,60 @@ 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]; - + if (likely((subport->tc_credits[0] + subport->tc_credits_per_period[0]) < subport->tc_rate[0])) { + subport->tc_credits[0] += subport->tc_credits_per_period[0]; + } + else { + subport->tc_credits[0] = subport->tc_rate[0]; + } + if (likely((subport->tc_credits[1] + subport->tc_credits_per_period[1]) < subport->tc_rate[1])) { + subport->tc_credits[1] += subport->tc_credits_per_period[1]; + } + else { + subport->tc_credits[1] = subport->tc_rate[1]; + } + if (likely((subport->tc_credits[2] + subport->tc_credits_per_period[2]) < subport->tc_rate[2])) { + subport->tc_credits[2] += subport->tc_credits_per_period[2]; + } + else { + subport->tc_credits[2] = subport->tc_rate[2]; + } + if (likely((subport->tc_credits[3] + subport->tc_credits_per_period[3]) < subport->tc_rate[3])) { + subport->tc_credits[3] += subport->tc_credits_per_period[3]; + } + else { + subport->tc_credits[3] = subport->tc_rate[3]; + } 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]; + if (likely((pipe->tc_credits[0] + params->tc_credits_per_period[0]) < params->tc_rate[0])) { + pipe->tc_credits[0] += params->tc_credits_per_period[0]; + } + else { + pipe->tc_credits[0] = params->tc_rate[0]; + } + if (likely((pipe->tc_credits[1] + params->tc_credits_per_period[1]) < params->tc_rate[1])) { + pipe->tc_credits[1] += params->tc_credits_per_period[1]; + } + else { + pipe->tc_credits[1] = params->tc_rate[1]; + } + if (likely((pipe->tc_credits[2] + params->tc_credits_per_period[2]) < params->tc_rate[2])) { + pipe->tc_credits[2] += params->tc_credits_per_period[2]; + } + else { + pipe->tc_credits[2] = params->tc_rate[2]; + } + if (likely((pipe->tc_credits[3] + params->tc_credits_per_period[3]) < params->tc_rate[3])) { + pipe->tc_credits[3] += params->tc_credits_per_period[3]; + } + else { + pipe->tc_credits[3] = params->tc_rate[3]; + } pipe->tc_time = port->time + params->tc_period; }