aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic
diff options
context:
space:
mode:
authorDmitriy Krot <globaxbiz@gmail.com>2017-05-12 03:00:13 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2017-05-15 22:24:04 +0300
commit160f71a48b5891b49a84cc849f08c1ff99d26b3f (patch)
tree808d53da315b97421c3bff6c6d2edcc0f3a5d7e9 /platform/linux-generic
parent8b9783b7f5667b3a37f039222e06448af2eec070 (diff)
linux-gen: tm: fix wrr/wfq bug when weight=1
Usage of 0x10000 in the inverted weight calculation causes overflow of uint16_t if weight=1. As a result of this bug, frame len used for virtual finish time calculation is always zero, despite of packet size, so packets from input with weight=1 always pass first. Signed-off-by: Dmitriy Krot <globaxbiz@gmail.com> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic')
-rw-r--r--platform/linux-generic/odp_traffic_mngr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c
index 4e9358b96..a93b3ba90 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -3238,7 +3238,7 @@ static void tm_sched_params_cvt_to(odp_tm_sched_params_t *odp_sched_params,
if (weight == 0)
inv_weight = 0;
else
- inv_weight = 0x10000 / weight;
+ inv_weight = 0xFFFF / weight;
tm_sched_params->sched_modes[priority] = sched_mode;
tm_sched_params->inverted_weights[priority] = inv_weight;
@@ -3254,7 +3254,7 @@ static void tm_sched_params_cvt_from(tm_sched_params_t *tm_sched_params,
for (priority = 0; priority < ODP_TM_MAX_PRIORITIES; priority++) {
sched_mode = tm_sched_params->sched_modes[priority];
inv_weight = tm_sched_params->inverted_weights[priority];
- weight = 0x10000 / inv_weight;
+ weight = 0xFFFF / inv_weight;
odp_sched_params->sched_modes[priority] = sched_mode;
odp_sched_params->sched_weights[priority] = weight;