Hi,

I've added a print after the call to the uplink assignment function:

        if (usf < 0) {
LOGP(DRLCMAC, LOGL_NOTICE, "- Failed "
"allocating TS=%d, no USF available\n", ts);
return -EBUSY;
}
        LOGP(DRLCMAC, LOGL_DEBUG, "- Assign uplink "
                       "TS=%d USF=%d\n", ts, usf);
        assign_uplink_tbf_usf(bts, pdch, ts, tbf, usf);
        LOGP(DRLCMAC, LOGL_NOTICE, "USF allocated %d ts %d\n", tbf->dir.ul.usf[ts], ts);


Two MSs are getting different USFs now:


<0001> pcu_l1_if.cpp:290 RACH request received: sapi=1 qta=1, ra=123, fn=1109521
<0002> gprs_rlcmac.cpp:454 USF allocated 0 ts 7
<0002> gprs_rlcmac_data.cpp:1906 Got IMM.ASS confirm, but rest octets do not start with bit sequence 'HH01' (Packet Downlink Assignment)
<0001> pcu_l1_if.cpp:290 RACH request received: sapi=1 qta=1, ra=121, fn=1109533
<0002> gprs_rlcmac.cpp:454 USF allocated 1 ts 7
<0002> gprs_rlcmac_data.cpp:1906 Got IMM.ASS confirm, but rest octets do not start with bit sequence 'HH01' (Packet Downlink Assignment)
<0008> gprs_rlcmac.cpp:1799 LLC [PCU -> SGSN] TFI: 0 TLLI: 0xc0a3df97 len=79
<0008> gprs_bssgp_pcu.cpp:155 LLC [SGSN -> PCU] = TLLI: 0xc0a3df97 IMSI: 334020481442858 len: 191
<0007> gprs_rlcmac_meas.cpp:102 UL RSSI of TLLI=0xc0a3df97: 0 dBm
<0008> gprs_rlcmac.cpp:1799 LLC [PCU -> SGSN] TFI: 1 TLLI: 0xf844d86d len=8
<0007> gprs_rlcmac_meas.cpp:102 UL RSSI of TLLI=0xf844d86d: 0 dBm
<0002> gprs_rlcmac_data.cpp:1549 Polling sheduled in this TS 7, FN 1109736

And it works. Both of them succeeded to open the internet page..
Without deep investigation alloc_b works as well (after patch applying).

Regards,
Vladimir.





On Wed, Sep 25, 2013 at 1:11 PM, Holger Hans Peter Freyther <hfreyther@sysmocom.de> wrote:
On Tue, Sep 24, 2013 at 01:26:17PM +0300, Vladimir Rolbin wrote:
> Hi all,
>
> It looks like usf found (allocated) is never used. I guess something
> like tbf->dir.ul.usf[ts] = usf is missed.

Hi!

can you indicate on how to re-produce the problem and how much time
you have spent in analyzing this problem? I have indicated the lack
of test cases in the past.

I moved the "assignment" (having to pass trx, bts, pdch, ts just
indicates the lack of structure in this code...) into a new method.
It kills code duplication and could fix the issue. I have only compile
tested it. Could you give it a try?

holger



diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp
index 1d1a8c6..695bf47 100644
--- a/src/gprs_rlcmac.cpp
+++ b/src/gprs_rlcmac.cpp
@@ -402,6 +402,17 @@ next_diagram:
        return tbf;
 }

+static void assign_uplink_tbf_usf(struct gprs_rlcmac_bts *bts,
+                               struct gprs_rlcmac_pdch *pdch,
+                               int ts,
+                               struct gprs_rlcmac_tbf *tbf, int8_t usf)
+{
+       bts->trx[tbf->trx].ul_tbf[tbf->tfi] = tbf;
+       pdch->ul_tbf[tbf->tfi] = tbf;
+       tbf->pdch[ts] = pdch;
+       tbf->dir.ul.usf[ts] = usf;
+}
+
 /* Slot Allocation: Algorithm A
  *
  * Assign single slot for uplink and downlink
@@ -433,17 +444,14 @@ int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
        if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
                /* if USF available */
                usf = find_free_usf(pdch, ts);
-               if (usf >= 0) {
-                       LOGP(DRLCMAC, LOGL_DEBUG, "- Assign uplink "
-                               "TS=%d USF=%d\n", ts, usf);
-                       bts->trx[tbf->trx].ul_tbf[tbf->tfi] = tbf;
-                       pdch->ul_tbf[tbf->tfi] = tbf;
-                       tbf->pdch[ts] = pdch;
-               } else {
+               if (usf < 0) {
                        LOGP(DRLCMAC, LOGL_NOTICE, "- Failed "
                                "allocating TS=%d, no USF available\n", ts);
                        return -EBUSY;
                }
+               LOGP(DRLCMAC, LOGL_DEBUG, "- Assign uplink "
+                       "TS=%d USF=%d\n", ts, usf);
+               assign_uplink_tbf_usf(bts, pdch, ts, tbf, usf);
        } else {
                LOGP(DRLCMAC, LOGL_DEBUG, "- Assign downlink TS=%d\n", ts);
                bts->trx[tbf->trx].dl_tbf[tbf->tfi] = tbf;
@@ -859,10 +867,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
                                LOGP(DRLCMAC, LOGL_DEBUG, "- Assigning UL TS "
                                        "%d\n", ts);
                                pdch = &bts->trx[tbf->trx].pdch[ts];
-                               bts->trx[tbf->trx].ul_tbf[tbf->tfi] = tbf;
-                               pdch->ul_tbf[tbf->tfi] = tbf;
-                               tbf->pdch[ts] = pdch;
-                               tbf->dir.ul.usf[ts] = usf[ts];
+                               assign_uplink_tbf_usf(bts, pdch, ts, tbf, usf[ts]);
                                slotcount++;
                                if (slotcount == 1)
                                        tbf->first_ts = ts;

--
- Holger Freyther <hfreyther@sysmocom.de>       http://www.sysmocom.de/
=======================================================================
* sysmocom - systems for mobile communications GmbH
* Schivelbeiner Str. 5
* 10439 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B
* Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte