aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-12-25 21:11:20 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-15 10:39:08 +0100
commit3fd2ddf1a2c8c6c471b9996af6fc8f7c4c579fd5 (patch)
treeee0438b5510fc4d439acd08c29a272f59c0327d7
parentdd4af8045f3306b8b59a1ba8319dc903ce00e550 (diff)
alloc: Move the tx window calculation to a new method
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index c612f3e..2c2636f 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -353,6 +353,27 @@ static uint8_t update_rx_win_max(const int ms_type, const int Tt,
return rx_win_max;
}
+static void tx_win_from_rx(const int ms_type,
+ uint8_t rx_win_min, uint8_t rx_win_max,
+ int Tt, int Tr,
+ uint8_t *tx_win_min, uint8_t *tx_win_max,
+ uint8_t *tx_range)
+{
+ if (ms_type == 1) {
+ /* calculate TX window (shifted by 3 timeslots)
+ * it uses the space between tx_win_max and tx_win_min */
+ *tx_win_min = (rx_win_max - 2 + Tt) & 7;
+ *tx_win_max = (rx_win_min + 4 - Tr) & 7;
+ } else {
+ /* TX and RX simultaniously */
+ *tx_win_min = rx_win_min;
+ *tx_win_max = 7;
+ }
+
+ *tx_range = (*tx_win_max - *tx_win_min + 1) & 7;
+ LOGP(DRLCMAC, LOGL_DEBUG, "- TX-Window is: %d..%d\n", *tx_win_min,
+ *tx_win_max);
+}
/* Slot Allocation: Algorithm B
*
@@ -369,7 +390,6 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
uint8_t Tta, Ttb, Tra, Trb, Tt, Tr; /* Minimum Number of Slots */
uint8_t Type; /* Type of Mobile */
int rx_window;
- uint8_t tx_win_min, tx_win_max, tx_range;
uint8_t tx_window = 0;
static const char *digit[10] = { "0","1","2","3","4","5","6","7","8","9" };
int8_t usf[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; /* must be signed */
@@ -440,23 +460,9 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
rx_win_max);
/* calculate TX window */
- if (Type == 1) {
- /* calculate TX window (shifted by 3 timeslots)
- * it uses the space between tx_win_max and tx_win_min */
- tx_win_min = (rx_win_max - 2 + Tt) & 7;
- tx_win_max = (rx_win_min + 4 - Tr) & 7;
- /* calculate the TX window size (might be larger than Tx) */
- tx_range = (tx_win_max - tx_win_min + 1) & 7;
- } else {
- /* TX and RX simultaniously */
- tx_win_min = rx_win_min;
- tx_win_max = 7;
- /* TX window size (might be larger than Tx) */
- tx_range = tx_win_max - tx_win_min + 1;
- }
-
- LOGP(DRLCMAC, LOGL_DEBUG, "- TX-Window is: %d..%d\n", tx_win_min,
- tx_win_max);
+ uint8_t tx_win_min, tx_win_max, tx_range;
+ tx_win_from_rx(ms_class->type, rx_win_min, rx_win_max, Tt, Tr,
+ &tx_win_min, &tx_win_max, &tx_range);
/* select a window of Tx slots if available
* The maximum allowed slots depend on TX or the window of available