From bd554829a6da62798d32bac46cec6b24450d0bc4 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 4 Jan 2014 15:42:38 +0100 Subject: alloc_algorithm_b: Add seperate function to shrink rx window when TS are removed After reduce_rx_window() and update_rx_win_max() was called, one or more TS might be removed. tx_win_min and tx_win_max must be adjusted to the new range of allocated slots. --- src/gprs_rlcmac_ts_alloc.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index e1e2498d..58dd2e9b 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -320,25 +320,29 @@ static int reduce_rx_window(const int ms_type, const struct gprs_rlcmac_tbf *old return -EBUSY; } + return 0; +} + +/* shrink range of rx_win_min and rx_win_max */ +static void shrink_rx_window(uint8_t *rx_win_min, uint8_t *rx_win_max, int rx_window) +{ /* calculate new min/max */ for (uint8_t ts_no = *rx_win_min; ts_no <= *rx_win_max; ts_no++) { - if ((*rx_window & (1 << ts_no))) + if ((rx_window & (1 << ts_no))) break; *rx_win_min = ts_no + 1; - LOGP(DRLCMAC, LOGL_DEBUG, "- TS has been deleted, so " + LOGP(DRLCMAC, LOGL_DEBUG, "- TS is unused, so " "raising start of DL window to %d\n", *rx_win_min); } for (uint8_t ts_no = *rx_win_max; ts_no >= *rx_win_min; ts_no--) { - if ((*rx_window & (1 << ts_no))) + if ((rx_window & (1 << ts_no))) break; *rx_win_max = ts_no - 1; - LOGP(DRLCMAC, LOGL_DEBUG, "- TS has been deleted, so " + LOGP(DRLCMAC, LOGL_DEBUG, "- TS is unused, so " "lowering end of DL window to %d\n", *rx_win_max); } - - return 0; } /* @@ -590,8 +594,10 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, &rx_window, &rx_win_min, &rx_win_max); if (rc < 0) return rc; + shrink_rx_window(&rx_win_min, &rx_win_max, rx_window); rx_win_max = update_rx_win_max(ms_class->type, Tt, Tr, rx_win_min, rx_win_max); + shrink_rx_window(&rx_win_min, &rx_win_max, rx_window); LOGP(DRLCMAC, LOGL_DEBUG, "- RX-Window is: %d..%d\n", rx_win_min, rx_win_max); -- cgit v1.2.3