From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by dpdk.org (Postfix) with ESMTP id A6D822C2E for ; Mon, 26 Jun 2017 12:14:34 +0200 (CEST) Received: by mail-wr0-f181.google.com with SMTP id r103so142204463wrb.0 for ; Mon, 26 Jun 2017 03:14:34 -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=14wrVwWiyp4Kv3lRpPtzPocinwzTvj3wxYaqfP7tyJg=; b=ZeUVXgWEe6MkqRF9EqXRzOh+TqM+vfTggK4Xw/kCNy1s77FiA+ChMUfDXeEoodPuBa /07XG6BdL+OXyYKJa9Yjv/M5r+hcsGAPsMdI7umpOTfAPu+QVutTNTQui/tRY3N0Lj8B wmuPFmzMSnaPzuI3Pb6VD5o3tmLWuxRJjqr4BwVfBI0hnkzvZl/0Nwo6ewOxW4fp3Bzq Cg5kMiYJFQj8/bxCve+7ZVRPSL8/Yk8gdQSEoLOjagkZrj9aPhehxwBMgYMME/OVnYWv Uy33VKRAzKqsiDgCHh+ZYkJRripKHiEF0U+kfwsloxIBkDLC1mYkuFm+GDvBbJglUN55 q2Ug== 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=14wrVwWiyp4Kv3lRpPtzPocinwzTvj3wxYaqfP7tyJg=; b=kv43pCyTA0p3umphRV7X2r21+z62XpSkovo7m6bKIjkkfWDsSKvmbcde+I/VMqJ4UP fBUPGcrp3KSTqsTpCgOYs/orm2h9uRGpv0BYfnuTUARURUeTODLhEZOHOTDFvQMmZF/l eu9TtKFHhxKBx1ooKXeTm5LpKXAgvu+3Br/7aZ3ifV+t+OuMgG019AmjqGI3X0GK3989 OzHMdaF9pXYzovamXSmkkcaLkg6bALs8kRQYbSSZsthN6yk2IjNJGAbz6SZTNOwJr329 RRfVBkw1njTizyQtKCBK+BoY0HzKp6jwsSqG3JCI1dC/Gd64ivGu5qGemw44yaDbHwv+ s1pA== X-Gm-Message-State: AKS2vOyGUEO2SHfJ+gVj2exHTX3kchSs3ICVre9fAdCWErYg6M71mtGd G2XiT9TSmzoFnsKYwks= X-Received: by 10.223.134.198 with SMTP id 6mr12470298wry.63.1498472074259; Mon, 26 Jun 2017 03:14:34 -0700 (PDT) Received: from localhost.localdomain (160.203.7.109.rev.sfr.net. [109.7.203.160]) by smtp.gmail.com with ESMTPSA id t136sm8417938wmt.12.2017.06.26.03.14.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Jun 2017 03:14:33 -0700 (PDT) From: Olivier Chirossel To: dev@dpdk.org Cc: Olivier Chirossel Date: Mon, 26 Jun 2017 12:13:48 +0200 Message-Id: <1498472028-20743-2-git-send-email-olivier.chirossel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498472028-20743-1-git-send-email-olivier.chirossel@gmail.com> References: <1498472028-20743-1-git-send-email-olivier.chirossel@gmail.com> 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_per_period. The purpose of the patch is to fix that. 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: Mon, 26 Jun 2017 10:14:35 -0000 --- 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