From b04e1d7d0ce1ca95a0c7e9835478eb751bd47669 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 12 Dec 2023 16:58:29 +0100 Subject: [PATCH] Revert "Revert "pdch_ul_controller: migrate from fn_cmp() to gsm0502_fncmp()"" Now that 1.4.0 is released, bring back the patch that was temporarily reverted to avoid the need for a new libosmocore. This reverts commit 16729ba72761fc981bcec6d3747d6f7dab4413ca. Change-Id: Idd113e328a693df2e8f2f5d172eaf5bf2bfcf009 --- TODO-RELEASE | 1 + src/pdch_ul_controller.c | 24 ++++++------------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/TODO-RELEASE b/TODO-RELEASE index cbfda241..73ad83b2 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,3 +7,4 @@ # If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line +libosmocore > 1.9.0 added gsm0502_fncmp() diff --git a/src/pdch_ul_controller.c b/src/pdch_ul_controller.c index c0e26de4..661957bb 100644 --- a/src/pdch_ul_controller.c +++ b/src/pdch_ul_controller.c @@ -17,6 +17,8 @@ #include #include +#include + #include "pdch_ul_controller.h" #include "bts.h" #include "sba.h" @@ -43,20 +45,6 @@ const struct value_string pdch_ulc_tbf_poll_reason_names[] = { { 0, NULL } }; -#define GSM_MAX_FN_THRESH (GSM_MAX_FN >> 1) -/* 0: equal, -1: fn1 BEFORE fn2, 1: fn1 AFTER fn2 */ -static inline int fn_cmp(uint32_t fn1, uint32_t fn2) -{ - if (fn1 == fn2) - return 0; - /* FN1 goes before FN2: */ - if ((fn1 < fn2 && (fn2 - fn1) < GSM_MAX_FN_THRESH) || - (fn1 > fn2 && (fn1 - fn2) > GSM_MAX_FN_THRESH)) - return -1; - /* FN1 goes after FN2: */ - return 1; -} - struct pdch_ulc *pdch_ulc_alloc(struct gprs_rlcmac_pdch *pdch, void *ctx) { struct pdch_ulc* ulc; @@ -78,7 +66,7 @@ struct pdch_ulc_node *pdch_ulc_get_node(struct pdch_ulc *ulc, uint32_t fn) while (node) { it = rb_entry(node, struct pdch_ulc_node, node); - res = fn_cmp(it->fn, fn); + res = gsm0502_fncmp(it->fn, fn); if (res > 0) /* it->fn AFTER fn */ node = node->rb_left; else if (res < 0) /* it->fn BEFORE fn */ @@ -167,7 +155,7 @@ uint32_t pdch_ulc_get_next_free_fn(const struct pdch_ulc *ulc, uint32_t start_fn for (node = rb_first(&ulc->tree_root); node; node = rb_next(node)) { it = container_of(node, struct pdch_ulc_node, node); - res = fn_cmp(it->fn, check_fn); + res = gsm0502_fncmp(it->fn, check_fn); if (res > 0) { /* it->fn AFTER check_fn */ /* Next reserved FN is passed check_fn, hence it means check_fn is free */ return check_fn; @@ -203,7 +191,7 @@ static int pdch_ulc_add_node(struct pdch_ulc *ulc, struct pdch_ulc_node *item) it = container_of(*n, struct pdch_ulc_node, node); parent = *n; - res = fn_cmp(item->fn, it->fn); + res = gsm0502_fncmp(item->fn, it->fn); if (res < 0) { /* item->fn "BEFORE" it->fn */ n = &((*n)->rb_left); } else if (res > 0) { /* item->fn "AFTER" it->fn */ @@ -305,7 +293,7 @@ void pdch_ulc_expire_fn(struct pdch_ulc *ulc, uint32_t fn) struct rb_node *first; while ((first = rb_first(&ulc->tree_root))) { item = container_of(first, struct pdch_ulc_node, node); - res = fn_cmp(item->fn, fn); + res = gsm0502_fncmp(item->fn, fn); if (res > 0) /* item->fn AFTER fn */ break; if (res < 0) { /* item->fn BEFORE fn */