<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/26180">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ts_alloc: Simplify tfi_find_free logic<br><br>Avoid passing an extra pram which is accessible by GprsMs object already<br>being passed. Once, the "trx = ms_current_trx(ms)" is moved inside the<br>tfi_find_free function, it becomes clear that all the logic can be<br>further simplified.<br><br>Change-Id: I733d9bee3fa1dfc647da9f150b30014fbdab7442<br>---<br>M src/gprs_rlcmac_ts_alloc.cpp<br>1 file changed, 6 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/80/26180/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp</span><br><span>index 5b3b355..c3709c5 100644</span><br><span>--- a/src/gprs_rlcmac_ts_alloc.cpp</span><br><span>+++ b/src/gprs_rlcmac_ts_alloc.cpp</span><br><span>@@ -298,20 +298,21 @@</span><br><span> /*! Return free TFI</span><br><span>  *</span><br><span>  *  \param[in] bts Pointer to BTS struct</span><br><span style="color: hsl(0, 100%, 40%);">- *  \param[in] trx Optional pointer to TRX struct</span><br><span>  *  \param[in] ms Pointer to MS object</span><br><span>  *  \param[in] dir DL or UL direction</span><br><span>  *  \param[in] use_trx which TRX to use or -1 if it should be selected based on what MS uses</span><br><span>  *  \param[out] trx_no_ TRX number on which TFI was found</span><br><span>  *  \returns negative error code or 0 on success</span><br><span>  */</span><br><span style="color: hsl(0, 100%, 40%);">-static int tfi_find_free(const struct gprs_rlcmac_bts *bts, const gprs_rlcmac_trx *trx, const GprsMs *ms,</span><br><span style="color: hsl(120, 100%, 40%);">+static int tfi_find_free(const struct gprs_rlcmac_bts *bts, const GprsMs *ms,</span><br><span>                      enum gprs_rlcmac_tbf_direction dir, int8_t use_trx, uint8_t *trx_no_)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+   struct gprs_rlcmac_trx *trx;</span><br><span>         int tfi;</span><br><span>     uint8_t trx_no;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     if (trx) {</span><br><span style="color: hsl(120, 100%, 40%);">+    /* If MS is already doing stuff on a TRX, set use_trx to it: */</span><br><span style="color: hsl(120, 100%, 40%);">+       if ((trx = ms_current_trx(ms))) {</span><br><span>            if (use_trx >= 0 && use_trx != trx->trx_no) {</span><br><span>                  LOGP(DRLCMAC, LOGL_ERROR, "- Requested incompatible TRX %d (current is %d)\n",</span><br><span>                          use_trx, trx->trx_no);</span><br><span>@@ -320,9 +321,6 @@</span><br><span>                 use_trx = trx->trx_no;</span><br><span>    }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   if (use_trx == -1 && ms_current_trx(ms))</span><br><span style="color: hsl(0, 100%, 40%);">-                use_trx = ms_current_trx(ms)->trx_no;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>     tfi = bts_tfi_find_free(bts, dir, &trx_no, use_trx);</span><br><span>     if (tfi < 0)</span><br><span>              return -EBUSY;</span><br><span>@@ -884,18 +882,16 @@</span><br><span>       reserved_dl_slots = ms_reserved_dl_slots(ms);</span><br><span>        reserved_ul_slots = ms_reserved_ul_slots(ms);</span><br><span>        first_common_ts = ms_first_common_ts(ms);</span><br><span style="color: hsl(0, 100%, 40%);">-       trx = ms_current_trx(ms);</span><br><span> </span><br><span>        /* Step 2a: Find usable TRX and TFI */</span><br><span style="color: hsl(0, 100%, 40%);">-  tfi = tfi_find_free(bts, trx, ms, tbf->direction, use_trx, &trx_no);</span><br><span style="color: hsl(120, 100%, 40%);">+   tfi = tfi_find_free(bts, ms, tbf->direction, use_trx, &trx_no);</span><br><span>       if (tfi < 0) {</span><br><span>            LOGPAL(tbf, "B", single, use_trx, LOGL_NOTICE, "failed to allocate a TFI\n");</span><br><span>            return tfi;</span><br><span>  }</span><br><span> </span><br><span>        /* Step 2b: Reserve slots on the TRX for the MS */</span><br><span style="color: hsl(0, 100%, 40%);">-      if (!trx)</span><br><span style="color: hsl(0, 100%, 40%);">-               trx = &bts->trx[trx_no];</span><br><span style="color: hsl(120, 100%, 40%);">+       trx = &bts->trx[trx_no];</span><br><span> </span><br><span>  if (!reserved_dl_slots || !reserved_ul_slots) {</span><br><span>              rc = find_multi_slots(trx, ms_ms_class(ms), &reserved_ul_slots, &reserved_dl_slots);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/26180">change 26180</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-pcu/+/26180"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I733d9bee3fa1dfc647da9f150b30014fbdab7442 </div>
<div style="display:none"> Gerrit-Change-Number: 26180 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>