Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/3934

to look at the new patch set (#6).

Simplify TS alloc: separate capacity computation

Move TRX capacity computation into separate function and document it.

Change-Id: Ifd88fc7ff818ea2a041eae61c5d457926a0df0f2
Related: OS#2282
---
M src/gprs_rlcmac_ts_alloc.cpp
1 file changed, 32 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/34/3934/6

diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index af4d011..438ec93 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -496,6 +496,33 @@
        return false;
 }
 
+/*! Compute capacity of a given TRX
+ *
+ *  \param[in] trx Pointer to TRX object
+ *  \param[in] rx_window Receive window
+ *  \param[in] tx_window Transmit window
+ *  \returns non-negative capacity
+ */
+static inline unsigned compute_capacity(const struct gprs_rlcmac_trx *trx, int 
rx_window, int tx_window)
+{
+       const struct gprs_rlcmac_pdch *pdch;
+       unsigned ts, capacity = 0;
+
+       for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) {
+               pdch = &trx->pdch[ts];
+               if (rx_window & (1 << ts))
+                       capacity += OSMO_MAX(32 - 
pdch->num_reserved(GPRS_RLCMAC_DL_TBF), 1);
+
+               /* Only consider common slots for UL */
+               if (tx_window & rx_window & (1 << ts)) {
+                       if (find_free_usf(pdch) >= 0)
+                               capacity += OSMO_MAX(32 - 
pdch->num_reserved(GPRS_RLCMAC_UL_TBF), 1);
+               }
+       }
+
+       return capacity;
+}
+
 /*! Find set of slots available for allocation while taking MS class into 
account
  *
  *  \param[in] trx Pointer to TRX object
@@ -620,7 +647,6 @@
 
        /* Validate with both Tta/Ttb/Trb and Ttb/Tra/Trb */
        for (mask_sel = MASK_TT; mask_sel <= MASK_TR; mask_sel += 1) {
-               unsigned ts;
                int capacity;
 
                rx_window = mslot_filter_bad(rx_mask[mask_sel], ul_ts, 
*dl_slots, rx_valid_win);
@@ -631,25 +657,7 @@
                        continue;
 
                /* Compute capacity */
-               capacity = 0;
-
-               for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) {
-                       int c;
-                       const struct gprs_rlcmac_pdch *pdch = &trx->pdch[ts];
-                       if (rx_window & (1 << ts)) {
-                               c = 32 - pdch->num_reserved(GPRS_RLCMAC_DL_TBF);
-                               c = OSMO_MAX(c, 1);
-                               capacity += c;
-                       }
-                       /* Only consider common slots for UL */
-                       if (tx_window & rx_window & (1 << ts)) {
-                               if (find_free_usf(pdch) >= 0) {
-                                       c = 32 - 
pdch->num_reserved(GPRS_RLCMAC_UL_TBF);
-                                       c = OSMO_MAX(c, 1);
-                                       capacity += c;
-                               }
-                       }
-               }
+               capacity = compute_capacity(trx, rx_window, tx_window);
 
 #ifdef ENABLE_TS_ALLOC_DEBUG
                LOGP(DRLCMAC, LOGL_DEBUG,
@@ -670,7 +678,10 @@
                max_capacity = capacity;
                max_ul_slots = tx_window;
                max_dl_slots = rx_window;
-       }}}}
+       }
+       }
+       }
+       }
 
        if (!max_ul_slots || !max_dl_slots) {
                LOGP(DRLCMAC, LOGL_NOTICE,

-- 
To view, visit https://gerrit.osmocom.org/3934
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ifd88fc7ff818ea2a041eae61c5d457926a0df0f2
Gerrit-PatchSet: 6
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder

Reply via email to