Commit Graph

1766 Commits

Author SHA1 Message Date
Pau Espin ed066b5328 tbf: Get rid of unneeded poll_scheduled()
This API is not really needed anymore, since anyway it works under the
assumption there can only be 1 POLL in transit per TBF, which isn't
necessarily true.

Change-Id: I875f51cade95faeb2d79dcebfead4c83e23a731b
2021-03-31 17:39:50 +02:00
Pau Espin 86580e1966 pdch_ulc: Store TBF poll reason
This allows easily checking the initial reason to trigger the poll when
either it is received or times out.

Later on this reason can be transformed into an FSM event and sent to
the related FSM.

Related: OS#5020
Change-Id: Ie8fefd1f47ad674ce597a8065b15284088956bde
2021-03-31 17:39:50 +02:00
Pau Espin b5ae0811d1 Drop unused function tbf_check()
Change-Id: I90d75a75ae5b528c6ca7b409e60bd158d6043b35
2021-03-31 17:39:50 +02:00
Pau Espin 50a1ede693 pdch_ulc: Support picking RRBP other than N+13
Current algo always tries to sched RRBP the soonest possible.

Related: OS#5020
Change-Id: Ic6ddeea70e1f914cf423d0daab8fc492d0c992e2
2021-03-31 17:39:50 +02:00
Pau Espin ce3bd2522a Pick unreserved UL FN when allocating an SBA
Make sure an unreserved FN is picked and reserved when allocating and
scheduling an SBA.
In practice this has no change in behavior right now, since anyway using
an offset of 52 FNs ensure no USF or POLL has alredy been scheduled that
far in the future. Since it's also impossible to allocate more than 1
SBA per PDCH and RTS FN, we are also safe about multiple SBAs being
allocated, because we use a hardcoded offset of 52.
However, that could change in the future, when we dynamically tweak the
current offset of 52 FN based on information from BTS about its AGCH
queue load:
* If load is high, we may need to increase the offset since it
will take more time for the BTS to transmit the TBF and hence we must
reserve a TBF starting time further in the future (higher FN).
* If load turns low, we may schedule next SBA a bit more nearby in time
  than the previously allocated SBA, hence here there could be a
  collision.

Related: OS#5020
Change-Id: I2d4e21e2307de6c17748e8da5c7e149c947a7eb9
2021-03-31 17:39:50 +02:00
Pau Espin 222f674116 pdch_ulc: Optimize rbtree FN search
Use logarithmic lookup algo to find if FN is available instead of
iterating over the whole tree.

Change-Id: I2843aedb5ce74c909bde82d29269d0f956e9a093
2021-03-31 17:39:50 +02:00
Pau Espin 54e6450293 sba: Document AGCH_START_OFFSET after some experimental tests
Related: OS#5020
Change-Id: Id1460207be25750aeb5c1d7af2fac6591cf5e424
2021-03-31 17:39:46 +02:00
Pau Espin 0b998b15da Properly implement N3101
N3101 is incremented by unanswered USF requests, not from unanswered
POLLs.

Related: OS#5033
Change-Id: I1a55bdd39db8843976915b9f74fadb0942298413
2021-03-24 17:16:29 +01:00
Pau Espin c1f38c7f0b Track scheduled UL blocks through USF
This way PCU can now detect whether scheduled UL blocks through USF
were never received. This allows in a follow-up patch to start
increasing N3101 properly.

Related: OS#5033
Change-Id: Ia99c9edad6e5bd837e9baeb4fb2683b227887957
2021-03-24 17:14:19 +01:00
Pau Espin ade9c2f553 pdch_ulc: Create helper API pdch_ulc_release_node
Change-Id: I6362ad7382c2b73e6fedb11182964be96e5c8d35
2021-03-24 17:12:01 +01:00
Pau Espin 9a6f0b191a pdch: Add mising pdch_ulc_release_node in Rx Cell Change Notif
All other RX CTRL block paths have it, this one was missing.

Change-Id: Ief315d7b6d4fea946d43e5bd87cf8a0394adc855
2021-03-24 17:12:01 +01:00
Pau Espin 7bd92a3e1d Set matching USF if available when polling a UL TBF
When the scheduler detects it's time to receive a UL block due to a
scheduled poll, if that polling is done on a UL TBF, then use its USF if
available instead of using USF_UNUSED (=7) when sending a DL block on
that same FN.

This is not really needed for correct work, since MS take care
themselves of scheduling a UL block when they receive the poll (RRBP)
some time before, and don't check the USF at the time of transmitting.
In any case, it helps understand better when looking at pcap traces that
indeed it a UL block from that MS was requested, instead of setting USF
to 7.

Related: OS#5033
Change-Id: I2ad9d8ea6afc8f83192033470bd27010a7474430
2021-03-24 17:12:01 +01:00
Pau Espin 4bab867d9f sched: Simplify usf selection code
Simply use the UL TBF pointer all along until the end, instead of setting
both the UL TBF pointer plus the usf var.

This commit is also a preparation for next commit which also selects UL
TBF when a poll is available, to set its USF in the DL message instead
of "USF_UNUSED".

Change-Id: I3aa3886932ef87db18ed7ff6991ea315f481990b
2021-03-24 17:12:01 +01:00
Pau Espin 107e94c9f8 sched: Fix scheduling UL TBF not matching conditions
With previous code, a skipped TBF could be returned despite not matching
the conditions, since at the end of the loop the tbf pointer was
returned.

Related: OS#5020
Change-Id: If6dccec86c7a655bf1c62f333cfbc8d2c507c94f
2021-03-24 17:12:01 +01:00
Pau Espin 56f223d8d1 Fix: left shift cannot be repesented in type int
Caught by ASan:
runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Change-Id: I30aed795d027dc063f06e08c8455bad2dd92cf24
2021-03-24 14:27:19 +01:00
Alexander Couzens 5d376845bb gprs_bssgp_pcu: add comments to the pcu states
Related: OS#3879
Change-Id: Iccf6508ce46162e6dfd6b00abd44e24cb425b346
2021-03-23 17:47:22 +00:00
Alexander Couzens 82519264ca gprs_bssgp_pcu: ensure only known BVCI can be resetted by the SGSN
Related: OS#3879
Change-Id: I04e36ce4a29e51d85e67a0d3a81aa0e1eb9e9c08
2021-03-23 17:47:22 +00:00
Harald Welte d7f0558b5c pdch_ul_controller: Fix compiler warning on gcc-10.2
pdch_ul_controller.c: In function ‘pdch_ulc_release_tbf’:
pdch_ul_controller.c:217:7: error: ‘item_tbf’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  217 |    if (item_tbf != tbf)
      |       ^

Change-Id: I42120fdf23753945ebc16bb5469d9fd253c3da37
2021-03-20 16:17:30 +01:00
Pau Espin 755a8d61bb direct_phy: Fix condition dropping rx DATA.ind payload in in
Related: OS#5020
Fixes: 81c549d5be
Change-Id: Iad8e50b856009439d78c596c5b54dc3e9836e1d4
2021-03-18 14:03:35 +01:00
Pau Espin fecab50066 sysmo: fix wrong FN jumps in rx RA.ind
There's no need for setting the FN in RA.ind since we anyway already
receive a DATA.ind beforehand.
Furthermore, the applied delay of 5 in the call is not really used at
all.

Change-Id: I437f4f95d054aea96bec3b9343e495451020ff3c
2021-03-17 15:58:16 +01:00
Pau Espin c7cc4162e1 ulc: Fix FN store order upon wrap around
Related: OS#5020
Change-Id: I0a742f7fa1541b1837739207b9383772f981fb25
2021-03-15 19:36:56 +01:00
Pau Espin 3a42d17b14 bts: Detect FN jumps
Change-Id: I29fb27981597edc69abb976049ba41aa840488cb
2021-03-15 19:34:35 +01:00
Pau Espin fd1fbdb8db sched: Use new PDCH UL Controller
Take the time to also do small refactorings to clarify and simplify the
function, by using rts_next_fn() already available in pcu_utils.h and
getting rid of poll_tbf from tbf_candidates, which clearly follows
another objective.

Using PDCH UL Controller has the advantage that we don't need to check
poll_scheduled() on each TBF, but only do the query once.

Related: OS#5020
Change-Id: Ia60bb5249a9837dec1f42180e44d9848334d86d6
2021-03-15 19:34:20 +01:00
Pau Espin 99360a304f Replace PollController with newly added PDCH UL Controller
TbfTest is updated to submit empty blocks to have somehow meaningful
output (at least as meaningful test results as before, not much). That's
because we must update bts->curr_fn to have polls expire.

Related: OS#5020
Change-Id: I683ca738ce5a133c49c36a1d94439a942d64a831
2021-03-15 19:32:36 +01:00
Pau Espin 15c58ace75 Add new PDCH UL Controller, drop SBAllocator class
Right now we handle different types of UL allocations in different
classes like PollAllocator and SBAllocator, and they usually don't take
into account the other one in most cases. Furthermore, those objects are
usually per-BTS object, instead of per PDCH object.

This is a first step towards having a unified per-PDCH controller which
takes care of controlling what is scheduled and hence expected on the
uplink. Each PDCH has a UL Controller which keeps track of all reserved
uplink frame, be it SB, RRBP poll or USF assigned, all under the same
API.

As a first step, only the SBA part is fully implemented and used (being
it the easiest part to replace); TBF poll+usf will come in follow-up
patches later on. As a result, the SBAllocator per-BTS class dissappears
but some of its code is refactored/reused to provide more features to the
gprs_rlcmac_sba object, which is also further integrated into the new UL
Controller.

Related: OS#5020
Change-Id: I84b24beea4a1aa2c1528f41435f77bd16df2b947
2021-03-15 19:32:26 +01:00
Pau Espin 68bfdff3f0 pdch: Log FN when decoding UL Ctrl block
Change-Id: I5a44ebf49f7489211a77607052db6d9731f38704
2021-03-12 07:40:11 +00:00
Pau Espin 4f2c8cd96a tbf: Fix wrong variable printed in log
Change-Id: Iad99e48fcb7488daed40a5095c5dcdc02def00c5
2021-03-12 07:40:11 +00:00
Pau Espin df58ddf6d8 Improve logging in DATA.req and ACT.req
Change-Id: Id57d50d8bf528adfef3713c594102d31ab49c149
2021-03-12 07:40:11 +00:00
Pau Espin c1f31c46ac Improve DATA.ind logging
pdch object is obtained prior in the stack so it is available for
logging.

Change-Id: If51f7bdbd626a44c7b8e182a3460dad49fda6ec3
2021-03-12 07:40:11 +00:00
Pau Espin 91cc780b40 pdch.h: Drop uneeded include bts.h
This header is not needed and creates include loop issues in follow-up
patches.

Change-Id: Ic12ab293f27b5e13d1401c6f17d4d549bf5115f9
2021-03-12 07:40:11 +00:00
Pau Espin 702ebee751 Introduce init() APIs for PDCH and TRX objects
This will make it easier to keep object specific initializations in
expected place.

Change-Id: Idf1dbdf8bc0b1e16d86eeeffb1193fdf3a57d6ef
2021-03-12 07:40:11 +00:00
Pau Espin 30617115ba Track TDMA clock with DATA.ind instead of TIME.ind
Since recently (see Depends below), BTS side submits DATA.ind with len=0
to announce nothing was received on that UL block FN. This will allow
osmo-pcu track time more accurately, and use this information to quickly
find out if a UL block was expected as requested by RRBP or USF poll and
increment counters such as N3101 (finally being able to properly
implement timers such as T3619).

Depends: osmo-bts.git Change-Id I343c7a721dab72411edbca816c8864926bc329fb
Related: OS#5020

Change-Id: Ibc495173119465e74f726ddc36e312334e6dc0fd
2021-03-12 07:40:11 +00:00
Pau Espin 5447f3acf6 pcu_utils.h: Fix trailing whitespace
Change-Id: I113766e342a00f61f9894dee1bb89b8ae8354007
2021-03-11 17:01:25 +01:00
Pau Espin 81c549d5be direct_phy: Support submitting DATA.ind with len=0 to upper layers
Since recently (see Depends below), BTS side submits DATA.ind with len=0
to announce nothing was received on that UL block FN. This will allow
osmo-pcu track time more accurately, and use this information to quickly
find out if a UL block was expected as requested by RRBP or USF poll and
increment counters such as N3101 (finally being able to properly
implement timers such as T3619).

This patch does the same for direct phy feature, where the osmo-pcu
process receives the DATA.ind directly from the DSP.

Depends: osmo-bts.git Change-Id I343c7a721dab72411edbca816c8864926bc329fb

Related: OS#5033
Change-Id: I9a835e16ef0e5a68c003a93d1a33233aa43464ae
2021-03-08 13:11:03 +01:00
Pau Espin 3cba94d70e pdch: Silently ignore DATA.ind with len=0
Since recently (see Depends below), BTS side submits DATA.ind with len=0
to announce nothing was received on that UL block FN. This will allow
osmo-pcu track time more accurately, and use this information to quickly
find out if a UL block was expected as requested by RRBP or USF poll and
increment counters such as N3101 (finally being able to properly
implement timers such as T3619).

Depends: osmo-bts.git Change-Id I343c7a721dab72411edbca816c8864926bc329fb
Related: OS#5020
Change-Id: I17c28abf63b153448b533971ac5cf2e48daadea8
2021-03-08 10:39:31 +01:00
Pau Espin 58fdc54a7f tbf: Log N310* counter increments
Change-Id: Iacd2fb894b4f2a9aade7e66aa40969fea031c3b2
2021-03-04 14:11:23 +01:00
Pau Espin 2ad15d51fa sched: sched_select_downlink(): Clean up param list and improve logging
Passing TRX and TS is redundant since the info is contained in pdch
object.

Change-Id: I1b154d82c4a3e09f7fe7ef771de2abca0160cc7b
2021-03-03 20:52:26 +01:00
Pau Espin 3973eb5fe8 sched: sched_select_ctrl_msg(): Clean up param list and improve logging
Passing TRX and TS is redundant since the info is contained in pdch
object.

Change-Id: Ic3ec7547cae2ddd0f9c33b82e15ec83cd941e6c8
2021-03-03 20:47:09 +01:00
Pau Espin 11f01105a0 gprs_ms: Use standarized logging on more messages
Change-Id: If7f471f4932c2347cd857cd59f761a36d9e735d1
2021-03-03 20:37:38 +01:00
Pau Espin 4fe090146f ms: clarify delayed MS release process related code and logging
Change-Id: Ieaea6ab07b4b2822bcf394f2d0e9298b9f3c5854
2021-03-03 20:28:51 +01:00
Alexander Couzens 423bf8c408 gprs_bssgp_pcu: rework BSSGP Reset messages to support SGSN originated BSSGP-RESET
Use primitives instead of parsing the message a second time.
Set bctx->is_sgsn to false to allow the BSSGP layer to send back a
RESET_ACK with cell information.

Related: OS#3879
Depends: Ibcbaffa94cbdc4296a8a7c372304ac11d50d9559 (libosmocore)
Change-Id: I3afaf826798e362270ffa622c24bfd124ef25cd1
2021-03-03 15:37:19 +00:00
Pau Espin Pedrol cf6c71263f tbf_dl: fix FBI not set upon X2031 = 0
If Idle TBF timer (X2031) is set to 0, it means the TBF release is
immediately started once all queued data has been scheduled. In that
case, we must set FBI=1 (by setting cv=0) and move to FINISH state.

This used to work over the usual path where X2031 != 0, because release
start will alays happen at a later sched poll time where a dummy LLC
frame is sent and FBI set accordingly.

Change-Id: Ib20602936ae084c413f6bfe14eea33b602020be0
2021-03-02 18:25:33 +01:00
Pau Espin Pedrol 8afc6bad80 tbf_dl: Fix m_last_dl_drained_fn not set under some conditions
Old commit getting rid of LLC UI dummy and updating create_new_bsn()
function introduced a bug by not moving update of value m_last_dl_drained_fn
prior to a new break introduced.
As a result, the value is not updated in the case LLC queue becomes
drained but last few bytes are drained at exactly that moment.
Furthermore, then the IDLE tbf timer (X2031, keep_open())) returns always
true since according to it the drain never happened.

The impact of the bug is basically delaying a bit more than expected the
time the TBF stays in IDLE state with the TBF release process yet
to be started.

Related: OS#4849
Fixes: 7d0f9a0ec3
Change-Id: I7420aeffda3500bcdc990291e4a56511af433ff9
2021-03-02 18:24:46 +01:00
Pau Espin Pedrol 5b9d0bb8e5 tbf: log keep_open condition status
Change-Id: I069e84926aaa8f13b23c3ea4083b4c68dbc6cff2
2021-03-02 13:13:52 +01:00
Pau Espin Pedrol a89008b724 tbd_dl: Don't re-initialize class field twice
Change-Id: Ia92c24032dc1f8965008ff03a3a0a94bbb93893a
2021-03-02 13:09:32 +01:00
Pau Espin Pedrol a70bf72ce5 llc: use memset to fill llc dummy frame padding
Change-Id: Iaa55549f979ca23dad0bddd308c1144aa4b17255
2021-03-02 12:28:32 +01:00
Pau Espin 9688dc9aca bts: Add new stats to detect TBF allocation failure reasons
This is specially useful to detect for instance if a cell is handling
too many users, ending up in TFI or USF exhaustions. This information
can be later in the future used to tune TBF allocation algorithm behavior
(either manually/statially through config file, or
automatically/dynamically in code based on some thresholds).

Related: OS#5042
Change-Id: I5402e937ff8d800684655e500ef8e5c867141dc3
2021-03-01 13:18:36 +01:00
Pau Espin c85e093969 Remove uneeded ms param from alloc_algorithm_func_t func
Since a while ago, the data architecture was changed so that TBF is
guaranteed to always have a MS object associated. Hence, it makes no
sense to pass the MS object as a separate param as we can take it from
tbf object and makes code less confusing.

Change-Id: Idc0c76cf6f007afa4236480cdad0d8e99dabec5f
2021-02-26 11:50:21 +01:00
Pau Espin 36177c6b58 tbf: Improve logging when TBF being allocated or no TBF avail
Change-Id: I68491fe2c643262e35b4d4f1ecac34afcf61848f
2021-02-26 11:50:15 +01:00
Pau Espin 95e2266832 pdch: Standarize and improve logging
Change-Id: I1686a72eb9f9014ed3365376bc43d59d60bee8a5
2021-02-26 11:36:55 +01:00
Pau Espin 4e1c9adb67 bts: Count TBF TS allocation failure
Related: OS#2282
Change-Id: I0696bf77364bd31b96c00614a58ce66809683d1c
2021-02-25 17:49:59 +01:00
Pau Espin 7c9a4a41bc tbf: Log timeslot allocation failure
Change-Id: I48fc1eac37eeb74649bfc0888e06afc0079a58f8
2021-02-25 17:21:10 +01:00
Pau Espin Pedrol ed2afa3bed Support uplink multi-slot allocations
Before this patch, allocate_usf() was implemented to only allocate 1 USF
per TBF, regardless of the available ul_slot mask.

As a result, only 1 slot at max was allocated to any TBF. That's a pity
because usual multislot classes like 12 support up to 2 UL slots per TBF
(in common TS with DL).

This patch reworks allocate_usf() to allocate as many UL multislots as
possible (given mslot class, current USF availability, TFI availability,
related DL TBF slots for the same MS, etc.).

As a result, it can be seen that AllocTest results change substantially
and maximum concurrent TBF allocation drops under some conditions.
That happens due to more USFs being reserved (because each TBF has now
more UL slots reserved). Hence now USF exhaustion becomes the usual
limitation factor as per the number of concurrent TBFs than can be
handled per TRX (as opposed to TFIs previously).

Some of the biggest limitations in test appear though because really
high end multislot classes are used, which can consume high volumes of
UL slots (USFs), and which are probably not the most extended devices in
the field.

Moreover, in general the curren timeslot allocator for a given
multislot class will in general try to optimize the DL side gathering
most of the possible timeslots there. That means, for instance on ms
class 12 (4 Tx, 4Rx, 5 Sum), 4 DL slots and 1 UL slot will still be
selected. But in the case where only 3 PDCHs are available, then with
this new multi-slot UL support a TBF will reserve 3 DL slots and 2 UL
slots, while before this patch it would only taken 1 UL slot instead of
2.

This USF exhaustion situation can be improved in the future by
parametrizing (VTY command?) the maximum amount of UL slots that a TBF
can reserve, making for instance a default value of 2, meaning usual
classes can gather up 2 UL timelosts at a time while forbidding high-end
hungry classes to gather up to 8 UL timeslots.

Another approach would be to dynamically limit the amount of allowed
reservable UL timeslots based on current USF reservation load.

Related: OS#2282
Change-Id: Id97cc6e3b769511b591b1694549e0dac55227c43
2021-02-24 13:48:01 +00:00
Pau Espin Pedrol fe8de457ac Use ALPHA value received in SI13 from PCUIF
The old VTY command is marked as deprecated and still overrides the use
in case it's used.

Related: SYS#5358
Depends: libosmocore.git Change-Id I74fb0a3afc1ac4aadbfc609b882d929401f790eb
Depends: osmo-bsc.git Change-Id I8b97ea11bad5fe05f2f634945b5703ee9abde81d
Change-Id: I46f2a955b157a409055fca7fb917dc4f75482426
2021-02-22 12:29:12 +00:00
Pau Espin 4df2658884 find_multi_slots: Avoid multiple calls to mslot_class_get_type()
Change-Id: I9cda52befe32a7727ab479bc151d10106fb94688
2021-02-19 17:35:11 +01:00
Pau Espin 10475f5832 find_multi_slots: Mark mslot_class properties const
This way it's clear for reader that those variables are never touched
during the function.

Change-Id: Ief038c75bc02d0e987135f29599014eab88447dd
2021-02-19 17:33:23 +01:00
Pau Espin dfbf3d2c09 find_multi_slots: Avoid multiple calls to mslot_class_get_rx()
Change-Id: I06c97d81636e251f81c26f3aa042c70717be083a
2021-02-19 17:32:14 +01:00
Pau Espin 47a3b780db find_multi_slots: Avoid calling mslot_class_get_tx() on each iteration
Change-Id: I397495c158bce1c2715991371368b0d84cf69261
2021-02-19 16:56:36 +01:00
Pau Espin 1f8e229221 Use NULL as default value for pointer type
Using zero there is confusing since it's a pointer to an integer.

Change-Id: Ief2368954c71005c529e3eea3fee5df2630e44c1
2021-02-19 16:49:24 +01:00
Alexander Couzens 151bc5b0d3 gprs_bssgp: use gprs_ns2_sns_add_bind() to allow the NSE to use the binds for IP-SNS configuration
The gprs_ns2 now requires to specify every bind which should be used by the NSE for IP-SNS

Related: SYS#5354
Depends: I9ab8092bf286e7d90e92f5702a5404425e959c84 (libosmocore)
Change-Id: I35c987224ce098f7ee9f189ce0fce9e68ad3feac
2021-02-19 12:00:47 +00:00
Pau Espin 9345eb34d3 sched: Avoid selecting TBF to tx NACC Dl msg if no TFI is assigned
The DL NACC related message (PKT Cell Neighbor Data/Change Continue)
are filled with the TFI of the target TBF. Hence, only select the tbf
for NACC transmission if the related TBF already has a TFI assigned.

Otherwise, "OSMO_ASSERT(tbf_is_tfi_assigned(tbf));" in nacc_fsm.c when
generating messages may be hit.

Related: SYS#4909
Change-Id: I72b2dff28aacdb04909c098c94834ff79f55b31d
2021-02-18 15:50:47 +01:00
Pau Espin cf6b3bc08f cosmetic: fix line indentation
Change-Id: Ia8335ce5c005885e4db1864faf775c4bff509c53
2021-02-18 14:02:50 +01:00
Pau Espin 66e8a49734 vty: Write 'neighbor resolution' config to file
Fixes: c0a250d17d
Related: SYS#4909
Change-Id: I44eef3826939e05ba88e0c5a67e1fef535582ba7
2021-02-17 20:25:03 +01:00
Alexander Couzens 94a367f224 gprs_bssgp: rename gprs_ns_config -> gprs_ns_update_config
Improve the naming of the function to match it's purpose.

Related: SYS#5354
Change-Id: Ib8e4ae734503fd6f6695d9d6767d809e1bf79d22
2021-02-16 21:32:47 +00:00
Alexander Couzens 13a12e2e3b gprs_bssgp: rework and rename ns_create_nsvc -> ns_configure_nse
Add support for multiple SNS endpoints.
Move the NSE allocation to the top in preparation of IP-SNS binds.
The future gprs_ns2 library will require to manual add every bind to the NSE for IP-SNS.
Rename the function to match more it's purpose.

Related: SYS#5354
Change-Id: I69cf48ab168a6dca4f649157bf6556d7cd27d4fb
2021-02-16 21:32:47 +00:00
Pau Espin 9313da517d nacc_fsm: Improve log when sending RIM RAN-INFO to gather SI from remote cell
Change-Id: I6972f46f0f3223ce00672178e5610bd3a012fb19
2021-02-15 12:12:51 +01:00
Pau Espin Pedrol a78f0d5bfe nacc_fsm: Support receiving Pkt Cell Chg Notif while in some advanced states
Related: SYS#4909
Change-Id: Iee9cb67bf2c0c6f36b788498f4ef2672e33204b7
2021-02-11 18:49:03 +01:00
Pau Espin Pedrol 8e69fc0c3a nacc_fsm: nacc_fsm: Support receiving Pkt Cell Change Notify in state WAIT_REQUEST_SI
Similar to what's done in the previous commit, but this time when we are
further forward in the resolution process.
This can be triggered for instance because we are taking too much time
to resolve and MS has timer to retransmit the Pkt cell Change Notify in
case no response was received in time.

This commit fixes osmo-pcu exiting due to ASSERT(0) since the event was
already accepted but not being handled in the state function.

Related: SYS#4909
Change-Id: I0c29e5979fec6eebe9dfb151907a4cd2f5e4a737
2021-02-11 13:23:52 +01:00
Pau Espin Pedrol 069a637be8 nacc_fsm: Support receiving Pkt Cell Change Notify in state WAIT_RESOLVE_RAC_CI
If the message is a duplicate (same tgt cell), simply ignore it.
If the message contains a different tgt cell, restart the resolution:
* Avoid re-creating the socket in that case
* Avoid potentially picking a CTRL response for an older request

Related: SYS#4909
Change-Id: Ia2ed2580bbbdd6d3464833257b0dcb8ec6f8d699
2021-02-11 13:17:16 +01:00
Pau Espin Pedrol 41ff273226 nacc_fsm: Remove NACC_EV_RX_SI from in_event_mask of some states
We don't care about those messages anymore if we already transitioned
further than NACC_ST_WAIT_REQUEST_SI. Furthermore, RIM code dispatching
the event to the FSM is only doing it in the mentioned state above.

Related: SYS#4909
Change-Id: If420b49e437ff02073669522408763e5e84fe477
2021-02-11 13:17:16 +01:00
Pau Espin Pedrol 0c10b3cdc1 nacc_fsm: Move code filling struct to helper function
Same filler will be needed in different places since that message can
arrive at different points of time (different states).
It also helps supporting newer key types in the future.

Change-Id: Idfd4db8408f767b1847b04c88047a1c4996e543e
2021-02-11 12:26:24 +01:00
Pau Espin Pedrol abba102d7b cosmetic: fix typo in comment
Change-Id: I5a384985ef54234e915bf6334125f8d087988d1d
2021-02-08 18:35:13 +01:00
Vadim Yanitskiy 830ca26034 vty: register libosmocore's FSM introspection commands
Change-Id: Id268e44de6eb873138f38720a61cabe589a5d2c8
2021-02-05 23:22:37 +01:00
Pau Espin 55aca83098 rlc.h: Fix struct bit fields on big endian systems
Related: OS#5003
Change-Id: I534539cdf197ce5c038752a177aff7efeefc9883
2021-02-04 12:59:40 +01:00
Pau Espin Pedrol 44768f2127 nacc: Avoid RIM procedures targeting cells under same PCU
Now that we have the required System Information in osmo-pcu to craft
the Packet Neigbour Cell Change packet for cells it controls, let's
avoid starting a RIM procedure to gather the SI info, since the SGSN
would end up routing the RIM request back at us and we'd answer back to
ourselves.

This same optimization cannot be done on the first step (CTRL Neighbor
Resolution against BSC), because the PCU cannot know if the target
ARFCN+BSIC requested by the MS is actually managed by a cell under the
PCU or it's another cell managed by another external PCU, because
ARFCN+BSIC keys can be resued among non-neighbor cells. Hence, it shall
always ask the BSC since only it holds the information about neighboring
cells.

Related: OS#4909
Change-Id: I928875b6b66dff55fc12f51b6b1ad919fef7d03b
2021-02-03 08:34:12 +00:00
Pau Espin Pedrol 952cb3d5d7 nacc: Implement Pkt Cell Change Continue retransmission
Use the fact that the MS must answer the RRBP of the Pkt Cell Change
Continue with a CTRL ACK to find out whether the message was received
successfuly or a retransmission is potentially required.

3GPP TS 44.060:
"""
When the mobile station receives the PACKET CELL CHANGE ORDER or
the PACKET CELL CHANGE CONTINUE message the mobile station shall
transmit a PACKET CONTROL ACKNOWLEDGMENT message in the specified
uplink radio block if a valid RRBP field is received as part of the
message; the mobile station may then switch to a new cell.
"""

Related: SYS#4909
Change-Id: I7cc28922e71699598da0ef6eb90136a47d3c002f
2021-02-03 08:34:04 +00:00
Philipp Maier a58ec61514 gprs_bssgp_rim: add serving BSS NACC application
Answer an incoming RAN INFORMATION REQUEST RIM PDU with RAN INFORMATION
PDU that contains system information type 1, 3 and 13

Depends: osmo-bts I5138ab183793e7eee4dc494318d984e9f1f56932
Change-Id: Id72118120c14984d2fb1b918b41fac4868150d41
Related: SYS#5103
2021-02-02 21:57:09 +01:00
Pau Espin Pedrol 1aef113bb7 nacc: Fix typo in function name
Change-Id: I74857eacf4664508dce70eb0c6dd2acd7bfb72e4
2021-02-01 19:34:53 +01:00
Pau Espin Pedrol 57dcde4242 tbf: Constify some methods
Change-Id: I2681a98583f4fb26a274c75d0279084239f76a68
2021-02-01 18:14:37 +01:00
Pau Espin Pedrol b71aab5646 tbf: Reuse stored result in variable in check_polling()
Change-Id: Ie6fbe3699bcb4f63f7b617243c769e60881d8aac
2021-02-01 16:37:46 +01:00
Pau Espin Pedrol 4668dc6f07 encoding: Fix comment description of S/P field
Those fields were ment to be 0 (non-valid), just the comments were
copied over from somewhere else, and they are misleading.

Change-Id: Ic95853e115f60c65f7f11187d49d6e870d08c7bb
2021-02-01 16:37:46 +01:00
Pau Espin Pedrol 79784d0249 Move src/tbf.txt to doc/
At least there it will pass less unnoticed, I just discovered this file
by chance.

Change-Id: I65a443ae498ae4c5e837e5a069fd87863f259152
2021-02-01 14:28:35 +01:00
Pau Espin Pedrol fdbcea3532 Drop comment about an already implemented TODO
The comment target is already implemented just above it.

Change-Id: I05534bbbad24ad8ba602244b834cdbadcabcc7ec
2021-02-01 14:02:15 +01:00
Pau Espin Pedrol 05be90367a Update TS 04.60 references to new TS 44.060
Change-Id: Ib7c3a74b502b2251da2f7b9d6d711f3e32133bc3
2021-02-01 13:06:45 +01:00
Pau Espin f7e1df0da2 nacc: Improve log line failing to establish CTRL neigh conn
Change-Id: Ic92158f9fe986ff427ee2ed2cfbf95549e348746
2021-01-29 16:48:54 +01:00
Pau Espin a06ac18d22 NACC: Send only Pkt Cell Chg Continue if SI retrieve fails
If fore some reason we fail to fetch SI of target cell, we move
directly to NACC_ST_TX_CELL_CHG_CONTINUE in order to submit a Cell
Change Continue against the MS without providing any Packet Neighbor
Cell Data beforehand, as per spec that's probably the best we can do
in this scenario (TS 44.060):
"""
1)  The network responds with a PACKET CELL CHANGE CONTINUE message.
If a mobile station as response to a PACKET CELL CHANGE NOTIFICATION
message receives a PACKET CELL CHANGE CONTINUE message without receiving
any neighbour cell system information, the mobile station shall stop timer
T3208, stop timer T3210 if still running, leave CCN mode and continue cell
reselection in NC0/NC1 mode.
"""

This commit also fixes a use-after-free triggered by TTCN3 test
TC_nacc_outbound_rac_ci-resolve_fail_parse_response, where the "cmd"
pointer passed to nacc_fsm_ctrl_reply_cb() was freed during FSM
termination (its talloc ctx was under ctx->neigh_ctrl_conn) and the
libosmocore code calling that callback was later on accessing
cmd->defer.
Since due to this change the FSM is no longer syncrhonously freed, the
issue is gone.

Related: SYS#4909
Change-Id: Ie3f12a08ad611b1086d3f4ab7c3d34af43c07961
2021-01-29 12:59:30 +01:00
Pau Espin 41a22a7ab8 NACC: Configure neighbor and SI resolution timeout values
Upon timeout, we move directly to NACC_ST_TX_CELL_CHG_CONTINUE in order
to submit a Cell Change Continue against the MS without providing any
Packet Neighbor Cell Data beforehand, as per spec that's probably the
best we can do in this scenario (TS 44.060):
"""
1)  The network responds with a PACKET CELL CHANGE CONTINUE message.
If a mobile station as response to a PACKET CELL CHANGE NOTIFICATION
message receives a PACKET CELL CHANGE CONTINUE message without receiving
any neighbour cell system information, the mobile station shall stop timer
T3208, stop timer T3210 if still running, leave CCN mode and continue cell
reselection in NC0/NC1 mode.
"""

Related: SYS#4909
Change-Id: Ia9932ab082ec095294e85dc4d532046970e17986
2021-01-29 12:59:30 +01:00
Pau Espin ab7159f6ec NACC: allow setting keep time for entries in neigh and si cache
Related: SYS#4909
Change-Id: Ifa336aa27dd88ff5b78dbc5a2799740f542bb369
2021-01-29 12:59:30 +01:00
Pau Espin c0805e6389 NACC: delay CTRL conn socket init until it's needed
This way, we don't open a socket and do the IPA handshake in the event
the request is already cached.

Related: SYS#4909
Change-Id: Ib1ea85e1196c8b9dc40c8837ab5d4a54f2a1f2d4
2021-01-29 12:59:30 +01:00
Pau Espin 202a47886c NACC: Fix crash freeing struct if CTRL conn was refused during alloc
Older versions of osmo_ctrl_conn_alloc() may not properly initialize
write_queue.bfd.fd to -1, which means if osmo_sock_init2_ofd() failed
during nacc_fsm_alloc(), the destructor would wrongly enter the conditon
where the whole structure is set and unregister the unregistered fd.

Related: libosmocore Change-Id I98f744d2880fbb883719cdf1d3eb31f2b22a13b6
Related: SYS#4909
Change-Id: I253bd9087b1f7ab039aa1127e9dc586f5106905a
2021-01-29 12:59:30 +01:00
Pau Espin c0a250d17d Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.

The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.

First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.

Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.

After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.

One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.

Once the message above has been sent, the FSM autodestroys itself.

Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.

Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-29 12:59:30 +01:00
Pau Espin 1e77ca88af tbf: Make tbf_ms() param const
Change-Id: I041c564b15d17d05ce97ea0085fcd9192a346578
2021-01-29 11:54:18 +00:00
Alexander Couzens 54211b1e1b gprs_ns2: migrate to the new vty syntax
This also changes the vty configuration. If only timeout has been
configured for ns the new configuration is compatible.

For further information see:
https://osmocom.org/projects/libosmocore/wiki/Network_service_(NS)

Depends-on: I8c3f2afecc74b78f7f914f7dce166cbcb63444eb (libosmocore)
Change-Id: I14af821a8d1fda670643c3d5f81299a3abf3c583
2021-01-28 19:55:14 +01:00
Alexander Couzens f7ec52560f follow gprs_ns2 API enum changes
All gprs_ns2 enums have now GPRS_NS2 as prefix.

Depends-on: I548ff12f7277cbb7e1a630a3dc02b738ce89be72 (libosmocore)
Change-Id: Ifdc7956318c07d680feab33c22bc2c6f20927bf9
2021-01-28 12:55:41 +00:00
Pau Espin 1a5439b739 sched: Avoid picking TBF with nacked dl blocks when GMSK is required
Sine we don't yet implement properly all resegmentation of blocks from
same MCS family type, when requiring a GMSK DL block (due to GPRS+EGPRS
multiplexing limitations) we need to skip retransmitions, otherwise we'd
be incorrectly picking a DL block which was already built with a
potentially higher MCS value.

The "DL_PRIO_NEW_DATA" prio serves two purposes:
* There's new data to send
* There's some nacked data to be retransmitted

The 2nd purpose has, later on, more priority over the 1st one when the tbf
is selected (see gprs_rlcmac_dl_tbf::take_next_bsn()).

Until now we were handling correctly the case where the tbf was skipped
in case the prio was to resend unacked data (DL_PRIO_SENT_DATA), but
was incorrectly selected when it'd send nacked data. Let's fix it by
specifically checking w->resend_needed() < 0.

Change-Id: I253de8e1a190a9adb56160f38892c9e43e2c0272
2021-01-26 16:26:34 +01:00
Pau Espin fc464935a4 Fix Dl EGPRS data blocks being generated occasionally on GPRS TBFs
Under some circumstances, it could happen that a DL TBF is created as a
GPRS TBF due to not yet having enough information of the MS, and only
after the TBF is created the PCU gains that information and upgrades the
MS mode to "EGPRS". Hence, there's the possibility to run into a
situation where a GPRS TBF is attached to a EGPRS MS.

It may also happen sometimes that despite the TBF and the MS be EGPRS,
there's need to further limit the DL MCS to use, eg. MCS1-4 (GMSK).

As a result, when asking for the current DL (M)CS to use, we must tell
the MS which kind of limitations we want to apply. The later reasoning
was already implemented when GPRS+EGPRS multiplexing was added, but the
former was not being checked. Hence, by further spreading through the
call stack the "req_kind_mode" we match both cases.

Related: OS#4973
Change-Id: Ic0276ce045660713129f0c72f1158a3321c5977f
2021-01-25 16:56:59 +01:00
Pau Espin 201da4e5b2 ms: Properly handle EGPRS_GMSK mode in ms_max_cs_dl/ul()
Change-Id: Ied3e02a12145112fafa12282ed7aefa5b0fa6eb6
2021-01-25 16:19:37 +01:00
Pau Espin 7bb8cd683c ms: Set proper initial MCS values setting mode EGPRS_GMSK
Before this patch, shared logic with EGPRS case would allow keeping
MCS>4.

Change-Id: I94cbf0c120fd37deb2dfd077d35b3811c7da0675
2021-01-25 16:19:37 +01:00
Pau Espin 7963edba09 encoding: fix typos in comment
Change-Id: I0867935ad08d6e49c62e061742d3d76eeac35844
2021-01-25 16:19:37 +01:00
Pau Espin 2238228e3c tbf: Drop always-true condition checking for MS
The TBF can sometimes be detached from an MS, for eg. when switching
from one MS object to another due to them being merged after we found
duplicate objects upon receiving new information from it, but that
change is instantaneous so it shouldn't be a problem. The only other way
where an MS can be detached from an MS is during the end of its (or the
MS) life, where it is not sending data anymore.

Hence, it is safe to drop those checks for MS not being null. Those
being trigger, it should be considered a bug.

Change-Id: If292a53a09a64664031e756bff4735b9c6ee8651
2021-01-25 16:18:19 +01:00
Pau Espin 8f1701fe24 sched: Check if egprs is enabled in TBF rather than MS being egprs capable
It could happen as of current implementation that a TBF was created as
GPRS due to the MS being non-egprs, and later on the MS was upgraded to
EGPRS due to newly received information from the MS.
Hence, in order to infer if the data block is EGPRS or GPRS, let's
better check for the TBF info, which is the one really mandating the
kind of dl block to generate.

Change-Id: I49720fb3a69ca972cd1973de937ac8ee77615431
2021-01-25 11:31:59 +01:00
Pau Espin 0298c0b6a0 ms: Drop always-false check
MS is always assigned to a BTS, since it's set during MS constructor.
Hence, the check removed in this patch would never hold true (and if it
did, it'd be a bug).

Change-Id: I86a71c64623f7bec031226938a54306148370ffb
2021-01-25 11:20:46 +01:00
Pau Espin a100a6bc56 gprs_pcu: Use libosmocore osmo_cgi_ps_cmp API
it was noticed that gprs_pcu_get_bts_by_cgi_ps() sometimes failed to
return the BTS even if the CGI-PS fields matched, probably due to memcmp
checking too padding bytes which may not be zero-initialized in one of
the two memory regions being checked. Let's be on the safe side and use
libosmocore APIs to check them.

Depends: libosmocore.git Change-Id I00e329bc5be8674b30267dec238e7656ddfc21db
Change-Id: I7c8ee2c447634e45b367bb8f84adf0140ae48591
2021-01-22 20:40:08 +01:00
Pau Espin 3a27102e59 Initial handling support for RIM messages
This code doesn't do anything yet app-related with the received RIM
messages, but already provides the initial infrastructure to handle them
in the future, and does first checkings.

Related: SYS#5103
Change-Id: Ia0ade0e97ea781ec655439c008b6cefaf3e90dec
2021-01-22 16:37:12 +01:00
Pau Espin db5e339da4 Get rid of singleton gprs_bssgp_pcu_current_bctx()
Access it from existing pointers instead.

Change-Id: I77455da5221090ebea142ecd49d5dba0065bfc5c
2021-01-21 18:02:57 +01:00
Pau Espin 2e6b60df45 bts: Store RAC+CI from info_ind
Having those values at hand will be needed later for RIM / NACC related
purposes.

Change-Id: Ia3596e9e81cd71443be2cc6f2450bb7f91d2667d
2021-01-20 15:00:38 +01:00
Pau Espin d1049dc8cc Allow multiple bts objects in PCU
This patch doesn't really tests whether osmo-pcu can work on a multi-bts
environment, but it prepares the data structures to be able to do so at
any later point in time.

Change-Id: I6b10913f46c19d438c4e250a436a7446694b725a
2021-01-20 12:36:21 +01:00
Pau Espin e91c4c72b1 Convert osmo_bts_sock.cpp to C
There's no real point in using C++ there, and using C++ makes the
compiler fail to use llist_head in multi-bts patches added later due to:
"""
'offsetof' within non-standard-layout type is conditionally-supported
"""

Change-Id: I8965b5cc5a713e64788b5b6aa183d3035341ddbb
2021-01-19 16:28:13 +01:00
Pau Espin 906aafc9e2 Move tbf::free_all static methods to proper object files
Move each method to the object on which they operate, be it a trx or a
pdch ts.

Change-Id: Ida715cbf384431d37b2b192fbd7882957c93a4d1
2021-01-19 16:28:13 +01:00
Pau Espin 8a35e640a3 Convert gprs_bssgp_pcu.cpp to C
There's no real use of C++ in that file, and it causes problems when
using llist_head entry macros in future patches adding initial support
for multiple BTS in PCU object, so let's move it to plain C.

Change-Id: Ic771a89fd78b5e66151a5384f0ff6a8895589466
2021-01-19 16:28:13 +01:00
Pau Espin 4a5209d8bc Get rid of unused gsm_timer.{cpp,h}
Those files are not really being used other than for calling
get_current_fn() which is just a placeholder to call
bts_current_frame_number on the global bts object.

Change-Id: I6d50a8c15c1de5e2a308a24b313a7776f94ae54f
2021-01-19 16:28:13 +01:00
Pau Espin 289f90048b bts: combine bts_{init,cleanup} into consturctor/destructor methods
The bts_init/cleanup functions were kept during the C and C++ structure
merge process to make the patch simpler. It's not needed anymore,
let's move all the destructor logic into one function and keep that
together.

Change-Id: I73a9457d5c92f62261561ef6afe392953576aec4
2021-01-19 16:28:13 +01:00
Pau Espin 0ece97d718 Rename 'bts_data' leftovers to 'bts'
Before, we used tho have a BTs object split into 2 parts, a C
gprs_rlcmac_bts struct and a C++ BTS struct, and "bts_data" naming was
used to distinguish them in variable names. Nowadays the struct is
finally combined into one, so there's no point in using this "bts_data"
terminology, we use always "bts".

Change-Id: I9852bf439292d1abc70711bea65698b21bde0ee8
2021-01-19 16:28:13 +01:00
Pau Espin a45aafd39c Get rid of bts singletons
There's no BTS single global object anymore, get rid of those APIs. Move
users to use "pcu->bts", which will evolve to a linked list in the
future.

Change-Id: I9cf762b0d3cb9e2cc3582727e07fa82c8e183ec5
2021-01-19 16:28:13 +01:00
Pau Espin 2182e627cd Unify BTS into a C usable structure
Previous work on BTS class started to get stuff out of the C++ struct
 into a C struct (BTS -> struct gprs_glcmac_bts) so that some parts of
it were accessible from C code. Doing so, however, ended up being messy
too, since all code needs to be switching from one object to another,
which actually refer to the same logical component.

Let's instead rejoin the structures and make sure the struct is
accessible and usable from both C and C++ code by rewriting all methods
to be C compatible and converting 3 allocated suboject as pointers.
This way BTS can internally still use those C++ objects while providing
a clean APi to both C and C++ code.

Change-Id: I7d12c896c5ded659ca9d3bff4cf3a3fc857db9dd
2021-01-19 16:28:10 +01:00
Pau Espin 793583ea21 Fix configuration mess of initial_cs/mcs between PCUIF and VTY
Both values (optionally) set (forced) by VTY and the values received
from PCUIF were stored in the same variable, meaning that for instance
the PCUIF values wouldn't really be used if someone applied eg "no cs"
during runtime.

This commit does something similar to what was already done for the
max_(m)cs fields. We store PCUIF values in one place and VTY ones in
another place, and then trigger a bts object internal process to find
out exactly which initial CS should it be using.

Change-Id: I80a6ba401f9c0c85bdf6e0cc99a9d2008d31e1b0
2021-01-18 11:57:14 +01:00
Pau Espin f473ec9d7a Move llc_* fields from BTS to PCU
Change-Id: Iffb916e53fdf99164ad07cd19e4b35a64136307e
2021-01-18 11:54:57 +01:00
Pau Espin 519d071131 Move ws_* fields from BTS to PCU
Change-Id: I997bc52f0d924c8f2a0b1d6cf23af98828ad4258
2021-01-18 11:54:57 +01:00
Pau Espin e891222920 Move fc_* fields from BTS to PCU
Change-Id: I816d49e732d0fc7a3c9aa1f0e9a83b83d25e6a32
2021-01-18 11:54:57 +01:00
Pau Espin 113fb419ec Move ns_dialect field from BTS to PCU
Change-Id: Iffb22b776b91f93d6d2a7ccfa47deeecc22c33f0
2021-01-18 11:54:57 +01:00
Pau Espin 54b159aab9 Move (m)cs_lqual_ranges fields from BTS to PCU
Change-Id: I39e2fc7e229851610d797c594d84902af6079411
2021-01-18 11:54:57 +01:00
Pau Espin ad79b857cd Move cs_downgrade_threshold field from BTS to PCU
Change-Id: I3e1c65eb3cccff565d5d84588bdce93a47909a0f
2021-01-18 11:54:57 +01:00
Pau Espin e8dcf64881 Move cs_adj* fields from BTS to PCU
Change-Id: I2b00a83279dccd4feeeeb95e34878c4405e7972c
2021-01-18 11:54:57 +01:00
Pau Espin 97296b299c Move dl_arq_type field from BTS to PCU
Change-Id: I0b82ab59edd58d60e5581c707dc49f58de0ba203
2021-01-18 11:54:53 +01:00
Pau Espin 05f9f59a67 Move dl_tbf_preemptive_retransmission field from BTS to PCU
Change-Id: I3ab32fcafe83f3ecb116a5b8a05f58f3fddc5451
2021-01-18 11:38:38 +01:00
Pau Espin a281495008 Move alpha,gamma fields from BTS to PCU
Change-Id: I2fdd9c8a7393157183fff64084bb10e2a3b1dc63
2021-01-18 11:38:38 +01:00
Pau Espin 03de898d19 Move force_two_phase field from BTS to PCU
Change-Id: I68a6e032f725cde87992b99f039c5280e912faf7
2021-01-18 10:37:05 +00:00
Pau Espin 924aaad4bc Move T_defs_pcu from BTS to PCU object
Change-Id: I0cac5c12dff2e90b52d00383a00b4b94a9603a0a
2021-01-18 10:37:05 +00:00
Pau Espin ac3fd12026 Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.

This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.

This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.

The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.

Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-18 10:37:05 +00:00
Alexander Couzens 695ce77167 gprs_rlc_ts_alloc: ensure no rolling slots are allocated
When allocating multiple slots for a UE the following example
is not allowed 'UU----UU' for a UE class 12.
The time slot number can not roll over 7 and move to 0.
44.060 or 45.002 only specifies contigous however it was unclear
it this is an allowed pattern.

Only the example 45.002 B.3 in release 12 cleared this up.
It gives an example for a multi slot class 5 UE which has 7 possible
configuration this means the rolled over is not allowed.

Multislot class type 2 UE doesn't have this limitation.
Further if a UE supports 8 time slots this is not a limitation because
the window size (45.002 B.1) can include all time slots.

Releated: SYS#5073
Change-Id: I16019bdbe741b37b83b62749b840a3b7f4ddc6c7
2021-01-15 15:50:41 +00:00
Pau Espin 54faf023be Workaround ASan false positive runtime errors under some platforms
Under some platforms (RPI4, ARM) container older ASan, it will log false
positive log errors which will make unit test fail because then output
changes:
"""
pcu_l1_if.cpp:847:2: runtime error: member access within misaligned address 0xb3f0b78c for type 'struct GprsMs', which requires 8 byte alignment
"""

The pointer is indeed misaligned, but it's not actually a bug, because
the pointer is never derreferenced. That happens during
llist_for_each_entry operation where it does cast the pointer but it
only checks if the list has actually reached the end.

To workaround the issue, simply defer casting it by using llist_for_each
instead, where the pointer is assigned only in the case it really points
to a GprsMS struct.

Change-Id: I149fb42706501eb33f9c6fe48f76a03ddee5954a
2021-01-14 12:12:45 +01:00
Vadim Yanitskiy eb70a4098f bts: fix uninitialized memaccess in BTS::send_gsmtap()
Change-Id: I7c5105c9e8a2c680dc8b24cc5e3bda6f7405a3ee
Fixes: CID#216511
2021-01-13 13:58:16 +01:00
Vadim Yanitskiy 55022ea1b1 bts: fix uninitialized memaccess in BTS::send_gsmtap_rach()
Unfortunately, RACH.ind on the PCU interface contains no Uplink
measurements: neiter RSSI nor C/I.  In order to avoid sending
garbage, let's zero-initialize 'struct pcu_l1_meas'.

Change-Id: I8c3210c428da17d23d798f3ef9df941ded6e162a
Fixes: CID#216512
2021-01-13 13:57:13 +01:00
Pau Espin f5a251bcee gprs_ms: Mark ms_ctrg_desc static
Change-Id: I3b1f0d0ee932a97414375a679962356c9178c2eb
2021-01-12 20:57:56 +01:00
Pau Espin bed48cc14f ms: Replace struct var with rate_ctr
Let's use usual osmocom rate_ctr instead of having one variable +
setter/getter functions, so we can easily add new counters and also
because it makes code more clear (no need to look at what the "update"
function is doing).

Using rate counter also provides info about how recently the MS has been
interacting with the network.

Related: OS#4907
Change-Id: I744507fde4291955c1dbbb9739b18a12a80145b1
2021-01-12 18:01:53 +00:00
Pau Espin c2d3625bf6 tbf: remove 'software error' logs from tbf_free
It is expected that the tbf object is freed at any moment in time, for
instance if osmo-pcu drops PCUIF connection with osmo-bts. I couldn't
find any reason why it would e dangerous to free the tbf, so let's
remove this message.

related: OS#4779
Change-Id: I4ab5ccaa5bf6257b18d8fd5ba06baab083821817
2021-01-11 19:17:05 +01:00
Eric Wild 1188167a92 tbf: add virtual destructor
This ensures spec compliance, because currently the base class
destructor would be called through a base class pointer to derived
class instead of the most derived one, which ist unexpected and actually
undefined behavior in c++11 and beyond.

Change-Id: Ic4abde1658a983bb0ccf9a526177dce50ff6dc23
2021-01-11 17:55:07 +00:00
Vadim Yanitskiy 480c8acc8b gprs_rlcmac_sched: fix incorrect SBA frame number assignment
There is a big difference between:

  if ((a = foo() != 0xffffffff)) { ... }

and

  if ((a = foo()) != 0xffffffff) { ... }

In the first case, 'a' is the result of '!=' operation, i.e. either
0 (false) or 1 (true).  In the second case, 'a' will hold the value
returned by foo(), and this is exactly what must have been used in
gprs_rlcmac_rcv_rts_block().

The bug was there since SBA allocation feature was added in 2012.

Change-Id: Ifd607ae8a33382e48f9d9e50a28a4bdf4eaf73a2
Fixes: 07e97cf8a5
Related: CID#215835
2021-01-06 12:34:07 +00:00
Pau Espin Pedrol 8b4b19a012 tbf: Fix wrong verb used in log message
Change-Id: Id9f8df9a5c0e0f88a811c5d7f06821cb4f30ab93
2021-01-05 10:34:25 +00:00
Pau Espin Pedrol da971ee502 Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).

GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.

Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.

For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.

Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2021-01-05 10:34:25 +00:00
Alexander Couzens 86fad1ec4e gprs_rlcmac_sched: don't leak a sched_dummy()
Change-Id: Iea0fc51809c78514c85e45e7f499a531c4ea1bcf
2020-12-30 23:30:16 +01:00
Pau Espin Pedrol d6b913fc39 sched: Convert code handling next_list array to be size independant
Change-Id: Id209fe66f85501437a79f7ca0c8e3cf816177611
2020-12-17 15:27:41 +00:00
Pau Espin Pedrol b77a2c992e gprs_rlcmac_sched: Use helper structure to store several tbf pointer params
The resulting code is cleaner since it becomes clear the relation
between all those pointers, which are set in one function and used in
another one, passed through the caller of the former two.

Moreover, if more tbf candidates are to be added for other type of
actions, having them in a struct is much easier since only one pointer
is passed.

Change-Id: I55482aa5af7be5a176a7b4879a672ad37e618020
2020-12-17 15:27:41 +00:00
Alexander Couzens 3db4789be8 gprs_ns2: set default dialect to ipaccess
The default pcu dialect is ipaccess. Keep it that way.

Fixes ttcn3 pcu testcases.

Change-Id: I426f507fb8863abd8995bc615dc6a6fa7ae69217
2020-12-16 21:39:07 +01:00
Alexander Couzens 1e6c350a9f ns2: follow ns2 sns api changes
Related: OS#4472, OS#4890
Depends: libosmocore.git I71cdbfb53e361e6112fed5e2712236d797ef3ab2
Change-Id: Id530e5497c17885817493f8a8a9436bc187c88aa
2020-12-16 12:51:08 +01:00
Alexander Couzens b644fd1f09 ns2: follow changes to add a unique name to all binds
Related: OS#4472, OS#4890
Depends: libosmocore.git I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Change-Id: I3638c7204db576116ba2e20dae27539ce6143bd7
2020-12-16 12:51:04 +01:00
Alexander Couzens 5012e07685 ns2: follow ns2 dialect changes
NS2 introduce a ns dialect to differentiate
between the 4 possible dialects.

Related: OS#4472, OS#4890
Depends: libosmocore.git Ia118bb6f994845d84db09de7a94856f5ca573404
Change-Id: I16dc82c38eb75c2b9d1197640a955fec7df84efc
2020-12-16 12:50:50 +01:00
Harald Welte 398f60e11c migrate to DLBSSGP as log sub-system for BSSGP
Change-Id: I94864c5fa2688fc91b8b6077a14ad098851afdc7
Depends: libosmocore.git Change-Id I506190aae9217c0956e4b5764d1a0c0772268e93
2020-12-12 20:05:51 +01:00
Pau Espin Pedrol 95e4a2b3ae rlcmac: Fix typo in MT_PACKET_CELL_CHANGE_NOTIFICATION value_string
Change-Id: I1b327bf955069ab10b2c6aa643ecf975fa23c1b5
2020-12-11 19:57:29 +00:00
Pau Espin 7d0f9a0ec3 Dl TBF: Get rid of LLC UI dummy blocks following other data
According to:
* 3GPP TS 44.060 version 16.0.0 "9.3.1a Delayed release of downlink Temporary Block Flow"
* 3GPP TS 44.064 version 16.0.0 "6.4.2.2 Unconfirmed Information (UI) Dummy command"

LLC UI Dummy frames are to be used when there no more data to send, only
in order to delay the release of a TBF. Hence, while not incorrect per
se, makes no sense to send those LLC UI Dummy frames inserted into
rlcmac blocks which already contain other LLC frames, since the MS in
that case is already being kept active.
It only makes sense to send those LLC UI Dummy frames when we have
nothing else to send, that is, alone inside a RLCMAC block without other
LLC frames.

Related: OS#4849
Change-Id: Ifae1a7b2b3dfad8df19585063088ba0df2749c8f
2020-12-01 15:57:37 +01:00
Alexander Couzens 30d9a5989e NS2: rework handling of unknown primitive
Use prim_str() method to get the human readable string.
Define unhandled events with a nop in the switch()

Depends-on: Ibf610fbd929dddc4a4e235152447caff522d4eb2 (libosmocore)
Change-Id: I50188afb83ac142e22d4bda4e8050eb4de962e70
2020-12-01 12:07:18 +00:00
Pau Espin 022f9e56e5 Implement downgrade to DL MCS1-4 when USF for GPRS_only MS
In previous status, if USF for GPRS-only MS was selected, then EGPRS
TBFs were skipped and either a GPRS TBF was selected or a Dummy Block
was sent. That means the behavior was unfair towards EGPRS TBFs, because
sometimes they were skipped in favor of GPRS ones.
This patch imporves the situation in the above mentioned USF scenario, by
first, under specific conditions, allowing selection of an EGPRS TBF and
then forcing it to transmit in EGPRS-GMSK (MCS1-4) so that the
USF-targeted MS can still decode the USF, while at the same time
providing more fairness by allowing the EGPRS TBF to transmit data.

The specific conditions mentioned above are, mainly, related to the fact
that once a DL data block has been sent, and hence a BSN was assigned to
it, it cannot be retransmitted later using another MCS, since lower
MCS1-4 wouldn't be able to contain higher MCS RLC payload.

The set of conditions could be expanded in the future by also selecting
the EGPRS TBF if retransmition is required and the block to be
retransmitted was originally transmitted as MCS1-4.

Related: OS#4544
Change-Id: I9af23e175435fe9ae7b0e4119ad52fcd4707b9ca
2020-12-01 11:56:01 +00:00
Pau Espin 7fd9a29eba tbf: Log previous TS when changing Control TS
Change-Id: I5f37f3512dde60e4eb1ccebbb2d96de24604d241
2020-12-01 11:53:39 +00:00
Pau Espin 58cd1d2f8a main: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: I8f02925eedd8855bb58555df20b443f79d5c6da8
Fixes: OS#4865
2020-11-26 13:40:57 +01:00
Alexander Couzens 4e8f2c310f gprs_bssgp_pcu: follow ns2 library changes
Depends-on: I18dfd40a2429cd61b7c4a3dad5f226c64296f7d8 (libosmocore)
Change-Id: I056fe624160f2fe01d405690eba5cc0032780837
2020-11-25 20:53:37 +00:00
Pau Espin 74aa3523f3 csn1: Log CSN_VARIABLE_ARRAY values as hex
Change-Id: If84c4b3cb870068a85405116f1d505ffcff9c26e
2020-11-24 11:24:11 +01:00
Pau Espin 259a694ba7 csn1: Fix readIndex pointer change in CSN_VARIABLE_ARRAY
There's actually 3 errors:
* Its value should be updated, not the pointer itself
* Value should be increased, not decreased
* bitvec_read_field() API is already advancing it, no need to do it

Fixes: OS#4838
Change-Id: I009abc373794e148091e637ffee80c6461960945
2020-11-24 11:22:06 +01:00
Pau Espin 9c4f9ffec1 pdch: Log hexdump of decde failure for dl rlcmac block
Change-Id: I591212a43bf92984348d1992df8c9b4fdddeba3b
2020-11-23 16:36:42 +01:00
Pau Espin 7d3ee9ed8d pdch: packet_paging_request: Put back non-fitting paging entry where where it was
dequeue_paging() dequeues the first paging (at the start of the list).
If a paging request is dequeued but later it cannot be added to the
message being sent, it has to be re-added to the list for later
processing on next message. However, existing code was enqueueing it at
the end, which meant that paging request was delayed for no reason.

Change-Id: Iad8e7045267d56e32f42db0fbb8448b1b1185f05
2020-11-23 16:04:11 +01:00
Pau Espin 228628860f Support multiplexing of GPRS and EGPRS TBFs in one PDCH
There are some restrictions to have both GPRS-only and EGPRS MS attached
to the same MS:
* Any MS needs to be able to successfully decode a DL block at least
  every 18 DL blocks (360 ms). That means a Dl block with CS1-4 must be
  sent at least once during that time.
* Any MS needs to be able to decode USF targeting it. GPRS-only MS can
  successfully decode USF from DL blocks using GMSK: CS1-4 and MCS1-4.

In this patch, if USF of a GPRS-only MS is selected, then all DL EGPRS
TBFs are discarded from data block selection. However, this logic can be
further improved later by still allowing selection of DL EGPRS TBFs and
then forcing construction of a DL EGPRS data block using MCS1-4.

Sources:
* 3GPP TS 03.64 version 8.12.0 "6.6.4.1.1.2 Multiplexing of GPRS and EGPRS MSs"
* 3GPP TS 05.08 version 8.23.0 "10.2.2 BTS output power"

Related: OS#4544
Change-Id: Ib4991c864eda6864533363443f76ae5d999532ae
2020-11-17 16:42:15 +01:00
Pau Espin daa6c1c645 sched: Use correct GMSTAP category for EGPRS DL data blocks
Change-Id: I3bd8b6a2328e13543b7d4c4a945e86f14ff35bda
2020-11-17 15:05:10 +01:00
Pau Espin 4c5a7d315c sched: Fix sending GSMTAP DL data blocks with unset USF
Change-Id: Ib5ceb83a85b517ee9bf2c59cf27fe818373abe60
2020-11-17 15:05:10 +01:00
Pau Espin 49efd9b606 encoding: Fix duplicate word in log str
Change-Id: Ifb0b359c43e79bab5599625fae20750ae5a6ae54
2020-11-17 09:52:29 +00:00
Pau Espin e309d80dd4 Fix ctr reports: Remove ctr description from already removed counter
Recent commit removed the counter enum but forgot to remove the
description, so the descriptions were all shifted by 1 counter.

Fixes: 133fe4a852
Change-Id: I82ee9f36d60a1fd129ae3a864508fcd886e4bfef
2020-11-13 16:19:25 +01:00
Harald Welte 2bbdf2e3d7 Use osmo_fd_*_{disable,enable}
Change-Id: I16563a1033ad12a32104bfee974045ac4302bc74
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-11-11 20:15:37 +00:00
Vadim Yanitskiy cb98894eb1 TLLI 0x00000000 is a valid TLLI, use 0xffffffff instead
The assumption that TLLI 0x00000000 is invalid and can be used
as the initializer is wrong.  Similar to TMSI, 0x00000000 is a
perfectly valid value, while 0xffffffff is reserved - use it.

According to 3GPP TS 23.003, section 2.4, a TMSI/P-TMSI with
all 32 bits equal to 1 is special and shall not be allocated by
the network.  The reason is that it must be stored on the SIM,
where 'ff'O represents the erased state.  According to section
2.6 of the same document, a local/foreign TLLI is derived from
P-TMSI, so the same rule applies to TLLI.

I manually checked and corrected all occurances of 'tlli' in the
code.  The test expectations have been adjusted with this command:

  $ find tests/ -name "*.err" | xargs sed -i "s/0x00000000/0xffffffff/g"

so there should be no behavior change.  The only exception is
the 'TypesTest', where TLLI 0xffffffff is being encoded and
expected in the hexdump, so I regenerated the test output.

Change-Id: Ie89fab75ecc1d8b5e238d3ff214ea7ac830b68b5
Related: OS#4844
2020-11-10 17:06:39 +00:00
Pau Espin 305763dc6f tbf_ul: Log mismatching TLLI on log message
Change-Id: Ia2ac7062c1f3308a1485da6d769cb8a869fa8100
2020-11-06 20:03:24 +01:00
Pau Espin 9897b26e3e gprs_ms: Avoid enabling EGPRS if no MCS are supported
This patch avoids enabling EGPRS on MS objects if BTS/VTY assigned no
MCS supported/available for use.
As a result, if NO MCS is enabled/supported EGPRS won't be used despite
the MS announcing through EGPRS MS class that it supports EGPRS.

Change-Id: Ib19e9e006d851c2147de15f4aec36ab65250bdd3
2020-11-05 15:48:11 +01:00
Pau Espin f1159c559b Fix mcs_is_valid(): UNKNOWN value is not a valid (M)CS
Also add a few more asserts to make sure a valid CS/MCS is passed in
some placed where we expect (M)CS to be set.

Change-Id: I0a973e10cd9477f72d8bd47a06048414b33ae96a
2020-11-05 15:48:04 +01:00
Pau Espin b47b137c66 Fix configuration of initial_(m)cs
Properly clip initial_(m)cs values to be lower-equal than maximum
configured.

Regarding initial_mcs, use values provided by BTS, which were not used
before.

Change-Id: Ifc6bc7c2734d1ae404adc2497afec5366e4f9e50
2020-11-04 21:39:43 +01:00
Pau Espin 87eec1fd74 Get rid of bts->egprs_enabled
BTS simply notifies the PCU about the supported MCS, and PCU is
responsible for providing correct data formatting supported for the BTS
and the target MS.

Related: OS#4544
Change-Id: Ifcf23771bd23afc64ca6fea38948f98f2d134ecb
2020-11-04 21:39:43 +01:00
Pau Espin 133fe4a852 tbf_ul: Allow non-egprs phones if EGPRS is enabled
We'll be able to still serve GPRS-only phones if EGPRS is enabled.

Related: OS#4544
Change-Id: I2e01b9d0de7506e0c0960342d73dba29187fe61f
2020-11-04 21:39:43 +01:00
Pau Espin 569f0d27c7 tbf_dl: Don't fake EGPRS MS class when no related info is available
For instance if PCU received DL data to be sent to an MS from an SGSN,
and the MS is not currently cached in the PCU (because there's no TBF
active for it), it will page it and transmit the DL data to it.
The SGSN is capable of sending (EGPRS) MS Class information in that same
DL data message, so it's the one responsible for providing that
information if not available at the PCU.
In the PCU if we don't have information about that MS and SGSN didn't
provide us information about it, we cannot assume the MS is going to be
EGPRS capable and even less expecting a specific EGPRS MS class.
So let's drop this code.

Related: OS#4544
Change-Id: Icce66cadb51af25ae0c3b3719940eccb548fe33b
2020-11-04 21:39:42 +01:00
Pau Espin 4808d1ceb8 pdch: Process received CS1-4 data blocks regardless of egprs_enabled
EGPRS "enabled" or "not enabled" is a bit of confusing idea, since there
are different levels of EGPRS support. For instance we may have been
instructed by config to not transmit using MCS5-9 (8PSK), or not use
MCS1-9 at all (GMSK+8PSK). However, we cannot control what is sent to us
or what we receive on lower layers, so if the BTS PHY/receiver was able
to decode+receive, let's try to process it anyway...

Related: OS#4544
Change-Id: Ie70ec8e4a2d688762d7d320d6ad58d5a0cc52ea1
2020-11-04 21:39:42 +01:00
Pau Espin 270c9ea5d9 Enable egprs support through PCUIF from BTS/BSC
This VTY command was added due to EGPRS being introduced later as an
experimental feature. It's no longer needed and causes more problems
than goodness (since people sometimes forgets to enable it).

Let's rather simply enable EGPRS support based on what BTS/BSC requests
over PCUIF.

Related: OS#4544
Change-Id: Ic80970a136361584da9c912252a07e7c3c9d85d0
2020-11-04 21:39:42 +01:00
Pau Espin 343ec9b9fd Take into account BTS supported (M)CS values when retrieving the maximum
Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
2020-11-04 21:39:42 +01:00
Pau Espin 8072e354cc Move EGPRS MS mode set to gprs_ms.cpp
Some tests were wrong (TypesTest) and required modification, since they
were setting a EGPRS MS but then expecting a GPRS assignment.

Change-Id: I9d3ee21c765054a36bd22352e48bde5ffca9225a
2020-11-04 21:39:42 +01:00
Pau Espin d87722d03c pcuif: Improve BTS-supported CS/MCS handling
Take into account the MCS values supported by the BTS. In osmo-bts,
in general all MCS are enabled if "mode egprs" is selected in BSC,
and none otherwise.

Change-Id: Ie8f0215ba17da1e545e98bec9325c02f1e8efaea
2020-11-04 21:39:42 +01:00
Pau Espin 46fd7a0316 Move BTS initial values inside bts.cpp
This way everytime any program or test initiates a BTS object, the
bts_data structure has the same values.

Change-Id: Iffd6eecb1f08bda0091f45e2ef7c9c63b42e10b3
2020-11-04 19:32:12 +00:00
Alexander Couzens a2848546d2 NS2: follow the change of ownership
When receiving a primitive from the NS2 layer
the PCU must free the msg buffer if given.

Change-Id: I180433735bfbb3375c41318d7a7709d5845199ba
2020-11-03 22:37:49 +00:00
Vadim Yanitskiy 2c1fed20ab BSSGP: constify argument 'tp' of gprs_bssgp_pcu_rx_paging_{cs,ps}
Change-Id: I24e48964a0ff86c2ca962ab3928d07b1c9200390
2020-11-02 09:10:00 +00:00
Vadim Yanitskiy e9bddabc01 BSSGP: use tlvp_val8() in gprs_bssgp_pcu_rx_paging_cs()
Change-Id: Ic1e37cb9938323c9b9f0466be5cf7251a6db1008
2020-11-02 09:10:00 +00:00
Pau Espin b6450840dc gprs_ms: Use proper function to get CS
Change-Id: I161e733991ac4fa7bd25a0f12b20e5701c76fc52
2020-10-30 19:44:43 +01:00
Pau Espin 758ace867b tbf_dl: Update (egprs_)ms_class for already known MS
If SGSN provides us with MS class information upon DL data, let's use it
and set it in an already existing MS object if not yet known.

Also remove all unneeded code passing ms_class to append_data() which
would simply try to (again) set the ms_class.

Change-Id: I4979c9344bffd3ba7657bbab94981d233eab801f
2020-10-29 12:38:17 +01:00
Pau Espin 16705a4db1 cosmetic: Fix ws between if keyword and parenthesis
Change-Id: I5932f21c58e76552f7187a175b8e281c5846536c
2020-10-29 11:34:17 +00:00
Pau Espin 4d1663594b bts: define egprs_enabled as bool
Change-Id: I66a8254ee392ad75226c58b7df5746f409463f0f
2020-10-29 11:34:17 +00:00
Pau Espin 983bb7eb31 alloc_algo_b: Select TRX with least assigned TFIs during TBF alloc
Before this patch, it would always allocate all TBFs on the first TRX
until all TFIs were filled, then second, and so on. But it would
actually fail around 8th MS requesting an UL TBF because despite a TFI
was successfuly assigned, because all USFs were already exhausted for
that PDCH.

Related: OS#1775
Change-Id: Iccfc8acfbfdc258ed16cc5af01f12b376fe73b72
2020-10-29 11:34:17 +00:00
Pau Espin 528820dbe1 tbf: Clean up gprs_rlcmac_dl_tbf::handle()
Avoid passing tons of params to internal helper function
tbf_nel_dl_assignment() in order to either fetch again the ms object or
create a new one. Let's instead create the ms function earlier if needed
and fill it with all the discovered information prior to calling the
helper function. This provides cleaner code and also better log output.

This way we also avoid trying to fill the MS twice and unneeded
getter+setter for TA.

tbf::imsi(): There' always an ms, so simply forward call to
ms()->imsi().

We can also get rid of assign_imsi, since the modified code is the only
place where it's used and there's already some code in place there to
update the MS. We instead merge it with set_imsi and keep the
duplication code to catch possible bugs from callers.

Move merge_and_clear_ms from tbf class to GprsMS, where it really
belongs.

Change-Id: Id18098bac3cff26fc4a8d2f419e21641a1f4c83b
2020-10-29 11:34:17 +00:00
Alexander Couzens 87c6dd3c26 pcu_l1_if: fix misaligned assignment of remote address
Found-by: asan
Change-Id: I9c87d3fc1b6f03d79b53f1da3a146630061c3459
2020-10-27 15:29:05 +00:00
Pau Espin 9f6d1a85e1 tbf: Drop unused function disable_egprs()
Change-Id: I8e3e1d9e70d46c7ca65ce67c408830f8bd20ce3b
2020-10-25 23:29:20 +01:00
Pau Espin b385969039 Move dl_tbf allocation code to correct file
Change-Id: I50d41b1c6f244edcfb78646d0fac4e47c2e3e561
2020-10-24 22:14:42 +02:00
Pau Espin 442198cd41 Move ul_tbf allocation code to correct file
Change-Id: Ifd98abbcce49e4605c764267965903fbf9f35867
2020-10-24 22:14:42 +02:00
Pau Espin e9f77d377b tbf: Set MS during constructor time
This is another step forward towards a more clear data model where a TBF
always has a MS object (which may be lacking some information, and at a
later point when more information is found, it may actually be a
duplicated MS object and hence one duplicate removed and the TBF moved
to the object being kept).

This helps for instance in removing duplicated information stored in
the TBF which is really per MS, like ms_class, ta, etc. Since there's
always a MS object there's no need to keep a duplicate in both classes
in case there's no MS object.

It can already be seen looking at unit test logging that this kind of
data model already provides better information.
Some unit test parts were needed to adapt to the new model too.

Change-Id: I3cdf4d53e222777d5a2bf4c5aad3a7414105f14c
2020-10-24 22:14:42 +02:00
Pau Espin 7bde60f260 tbf: Implement enable_egprs() once
There's no real need for having different copies of this method in each
children. Furthermore, having the method implemented in the base class
made me shoot my foot while trying to move this to the tbf constructor
(see next commit), so let's simplify this and avoid other people
following into the same issue.

enable_egprs() in tbf.h is moved to be public since it needed (as it was
for the duplicated children mehtods with same name), but anyway it will
be moved to private in next commit.

Change-Id: Id7de060318201a42e51f277f898463f4b9a84eba
2020-10-24 22:14:42 +02:00
Pau Espin b3f239785c tbf: Make window() available to tbf base class
Return an interface to the window base class so that the tbf base class
can access the common window methods, such as set_ws(). It will be used
in next commit to get rid of duplicated function enable_egprs in both
dl_tbf and ul_tbf subclasses.

The user of the function can then decide to access more specific
functionaltiites of the window class by static casting it to the
specific direction (which is known by the caller since it operates on a
ul_tbf or a dl_tbf).

Change-Id: Ia2e1decf91be1184668e28297c2126affb9c7ae4
2020-10-24 22:14:42 +02:00
Pau Espin 834cbab97d Move constructor gprs_rlcmac_dl_tbf::BandWidth to correct file
Change-Id: I7587fd2ee97424020a099a8513f95544d6635f3d
2020-10-24 19:49:43 +00:00
Pau Espin 9767e44fd4 Move gprs_rlcmac_ul_tbf::window to correct file
It wasn't move when all the UL specific code was moved to a separate
file.

Change-Id: I6f8c2d568ffdea3826ec1e11358d24eea6c9335b
2020-10-24 19:49:43 +00:00
Vadim Yanitskiy 1136fdb563 main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
Change-Id: If82208ecb931a6024f1a83c8648c5855b15dcc96
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: SYS#4910
2020-10-24 05:15:20 +07:00
Vadim Yanitskiy 35668a2e06 main: remove line breaks in print_help(), increase spacing
Change-Id: I07010afec3bb85d875926813772a6504f3bdb7b5
Related: SYS#4910
2020-10-24 05:14:39 +07:00
Pau Espin a611b4f6a0 Fix several calls to LOGPAL
In those cases since a string pointer was passed, it always printed
"single" instead of whatever really was being used, since the string
pointer was not NULL.

Change-Id: Idab7d18e8f519e10fc3df4007634661c46f9256d
2020-10-23 17:13:04 +02:00
Pau Espin 8353d97904 Improve debug logging for alloc algos
In general we want to see explicitly the kind of requested allocation at
the start. The MS class is not needed since it's printed in the previous
log line in any case.

Change-Id: I9eb0a592c15be96da9d140ff373c1afead76b18c
2020-10-23 17:08:43 +02:00
Harald Welte 8347359cb0 Use osmo_fd_setup() whenever applicable
Change-Id: I8abd4c50b172f6b312bb4ba3c29e74396f6e6b93
2020-10-19 11:36:33 +00:00
Vadim Yanitskiy a6c5db954f fix tbf_select_slot_set(): use LOGP() instead of LOGPC()
Change-Id: I8e9ae854d147735357921f71d9a02862376a50b2
2020-10-16 22:33:54 +07:00
Alexander Couzens 5bece2a0ed Rework NS configuration over the info indication
Add support of the second NSVC in the info indication.
Add support to update a previous NS configuration.
Allow to update of a NS-VC while the NSE is still available over the
second.

Depends-on: I917f25ebd1239eae5855d973ced15b93731e33a0 (libosmocore)
Depends-on: I3a0cd305fd73b3cb9ec70246ec15ac70b83e57f2 (libosmocore)
Depends-on: I5a2bb95d05d06d909347e2fb084a446ead888cb3 (libosmocore)
Depends-on: I54f110acc3acccb362f6e554324d08cc42b7c328 (libosmocore)
Depends-on: Ia00753a64b7622a0864341f51ea49b6963543755 (libosmocore)
Depends-on: Ic8f6f8aca10da23a18fab8870be7806065a34b47 (libosmocore)
Depends-on: I5f67e6a9bf4cb322bd169061fee0a528012ed54d (libosmocore)
Change-Id: I589ebaa2a2b7de55b7e4e975d8fd6412dd5f214b
2020-10-13 08:45:30 +00:00
Vadim Yanitskiy 974cc7b324 gprs_bssgp_pcu: fix: do not crash on receipt of subsequent INFO.ind
It's expected to receive subsequent INFO.ind messages at run-time,
e.g. when a dynamic TCH/F_TCH/H_PDCH timeslot is switched from
PDCH to TCH/F or TCH/H, osmo-bts would send us INFO.ind with the
updated PDCH slot-mask indicating that this timeslot is disabled.

In gprs_nsvc_create_and_connect(), do not bind() on the received
NSVC address unconditionally - we may already be bound to it.
Instead, return early and keep everything unchanged.

I don't know how the PCU is supposed to handle NSVC address change,
at least the new NS2 library does not handle this internally, nor
it provides any API for that.  Let's leave it for later.

Change-Id: I159138e41e147cd30212da548b0ccd3f81d61b4e
Related: I4c3bc883d795e5d1ee5ab175ac03684924692a7c
Fixes: Ib389925cf5c9f18951af6242c31ea70476218e9a
Related: SYS#5108
2020-10-10 06:16:11 +07:00
Vadim Yanitskiy d038361e95 struct gprs_rlcmac_bts: remove unused 'nsei' field
The code in gprs_nsvc_create_and_connect() stores NSEI there for
no reason, despite it's already stored in struct gprs_ns2_nse.

Change-Id: Ib30152a12384cf0448104a1ee1cfb949f4a27553
2020-10-10 05:05:33 +07:00
Vadim Yanitskiy 0d0ac1b949 gprs_bssgp_pcu: fix possible memleak in gprs_nsvc_create_and_connect()
Change-Id: I9f44cd22b1353ded6eeb2fe9f8dd4818de758003
2020-10-10 05:05:33 +07:00
Vadim Yanitskiy 194b6f06a0 gprs_bssgp_pcu: make osmo_sockaddr local/sgsn arguments const
Change-Id: I40e51de300533cfcbb3c9f90a0858a489a3c2b6b
Depends: I0df6a00ac1830bd64a10b9336b827e113fa772bb
2020-10-09 21:43:09 +00:00
Philipp Maier 08c5037d60 pcu_main: add commandline option --vty-ref-xml
The commandline option --vty-ref-xml is needed to enable automatic
generation of the VTY reference manual.

Change-Id: Ie1829a06b83f69f4cd8256adbf9437388ca3d7e0
Related: SYS#4937, OS#1601
2020-10-09 20:42:16 +02:00
Vadim Yanitskiy 781f04a8f8 pcu_l1_if: print NSVC address in more common format
Change-Id: I5aac1b0624d127ef92a7b9c791f6b409e9e6055a
2020-10-09 20:54:03 +07:00
Vadim Yanitskiy 24c643e143 pcu_l1_if: use proper format string specifiers: %d -> %u
Change-Id: Ieb81dcb4096acbc7a308d003c9e653800071e149
2020-10-09 20:34:21 +07:00
Vadim Yanitskiy 19622aee5b pcu_l1_if: cosmetic: make {local,remote}_sockaddr scoped variables
Change-Id: Ib5ddf3622226ac9c612a03ca32d373bcc9b208cf
2020-10-09 20:03:16 +07:00
Vadim Yanitskiy c1a726c573 pcu_l1_if: correct logging level in pcu_rx_info_ind()
Change-Id: Ib4bb9b907fc2bf279cf22a3bb9b95ea1a0fb3db6
2020-10-08 23:03:39 +07:00
Vadim Yanitskiy 5d5b50aaf3 pcu_l1_if: cosmetic: use ARRAY_SIZE() in pcu_rx_info_ind()
Change-Id: Iff11c854b1687f75c1125a5bcd616da95ade69ee
2020-10-08 23:03:36 +07:00
Philipp Maier 9459ebde32 vty: add attributes to VTY commands indicating when they apply
Change-Id: I63978ce3ea87593c9a41e503ed3b761c64e1e80f
Related: SYS#4937, OS#1601
2020-10-08 07:16:31 +00:00
Alexander Couzens 290d9030e9 Use the new NS2 lib
Depends: Id7edb8feb96436ba170383fc62d43ceb16955d53 (libosmocore)
Depends: I2a9dcd14f4ad16211c0f6d98812ad4a13e910c2a (libosmocore)
Change-Id: Ib389925cf5c9f18951af6242c31ea70476218e9a
2020-10-06 16:38:38 +02:00
Harald Welte 0a369e560c bts.cpp: Increase constructor priority
It seems that some gcc versions do not consider the priority of
"C" __attribute__((constructor)) definitions in the same order as
they do C++ static initializers, which are called in the order in which
they appear in the compile unit (source file).

The problem has been observed at least in a
environment based on T2 SDE with GCC 6.3.0 and binutils 2.28.

Let's work around this by making sure the __attribute__((constructor))
function always gets the highest priority value permitted by gcc (101).

Closes: SYS#5093
Change-Id: I65de69a32ac929e6ddd4e58980027f9e76813153
2020-10-01 19:39:58 +02:00
Pau Espin 84abd2f65e Fix crash accessing NULL tbf->pdch[first_ts]
Fixes consistent crash under some specific scenarios explained in
OS#4756.

The crash was caused due to a bug in channel allocator algorithm
incorrectly populating tbf->pdch[] array as a result of mismatching
first_ts and resulting pdch selected slot bitmask.

The issue happens because when allocating a UL TBF in allocator B, the
subset is always further forced into allocating one single TS. As a
result, on that branch several variables are updated, but first_ts was
not.

The field used to be updated in older versions, but a bug was introduced
during code refactoring in commit listed below (31 Jan 2018).

Fixes: 0cc7212cfd
Related: OS#4756
Change-Id: I79596803f7dab6f21b58bfe39c2af65d9c5b39d5
2020-09-22 20:57:06 +02:00
Pau Espin 01aef5ed8b cosmetic: Fix typo in comment
Change-Id: I6567065b8ec0082b21c371bbd0c2e85fecc96c90
2020-09-22 20:57:05 +02:00
Pau Espin 5d2d2ec466 cosmetic: Fix indentation of for loops
Change-Id: Id7087bd00d9003235688ff34f2b039d525caa777
2020-09-22 20:57:05 +02:00
Pau Espin a1ac2f017f vty: Add 'show bts pdch' command
This allows to see which channels have been enabled according to PCU.

Change-Id: If72e67ba80aab4e0c68408e6996d74d2ff70c322
2020-09-22 20:56:53 +02:00
Pau Espin 5fc95771bb cosmetic: fix indentation alignment
Change-Id: I105cf184a478cf178d69e16cd35fa36c51133a18
2020-09-22 20:46:20 +02:00
Pau Espin bd9973a64f Free all MS TBFs when receiving GPRS Suspension Request
Otherwise the TBFs are kept, and hence PCU will continue reserving resources and
DL data queued will still be sent over the air, despite the MS not
listening anymore on the PDCH.

Change-Id: I4ae1c3706b2ed6e4d271cd16f7cd7f8937b84836
2020-09-22 20:46:15 +02:00
Pau Espin e3ef51ec06 gprs_ms_storage.h: Set pointer to NULL instead of 0
Change-Id: If8acd012909c9f452b609e4a804c9a059379f07d
2020-09-22 13:56:57 +02:00
Pau Espin cd6c466922 tbf: Don't log rlcmac_diag() output in separate lines
Output of all diag in different lines is really confusing, since the
user reads a timeout ocurred and then later in another line something
like "Downlink ACK was received" while no GSMTAP message shows any ACK.

Change-Id: I6a7d79c16c930f0712bc73b308409ececb1946ba
2020-09-22 13:44:15 +02:00
Alexander Couzens 9b5c960f55 pcuif_proto: version 10: add support for IPv6 NSVCs
Introduce a address_type in the NSVC configuration pass the given
protocol.  The remote_ip is network byte order, the default
encoding for in_addr and in6_addr.

Change-Id: Ia0852f9f4395f1248b39363ef90f6f5673b24e2f
Related: SYS#4915
2020-09-22 00:49:28 +07:00
Vadim Yanitskiy 8e2bd1e79d pcuif_proto: version 10: add frequency hopping parameters
Change-Id: I6863830883d90954006a7126c22d348aa2a83271
Related: SYS#4868, OS#4547
2020-09-22 00:49:11 +07:00
Alexander Couzens 40a9e603b9 Revert "pcuif_proto: version 0xa: add support for IPv6 NSVCs"
This reverts commit 38aaa10ed4.
It was to early because the frequency hopping wasn't ready to be merged.

Change-Id: Ibf055d5adfd9bffaaf51cb8468c79be597467e0f
2020-09-16 03:24:55 +02:00
Alexander Couzens 38aaa10ed4 pcuif_proto: version 0xa: add support for IPv6 NSVCs
Introduce a address_type in the NSVC configuration pass the given
protocol.
The remote_ip is network byte order, the default encoding for in_addr and in6_addr.

Change-Id: If26958d5b584973dca79159cf9e7f3f266519ce9
2020-09-15 22:21:43 +02:00
Vadim Yanitskiy 2597cf1494 encoding: fix gen_freq_params(): do not check pdch twice
This is a left-over from an earlier version of [1] that makes
Coverity think that there can be NULL pointer dereference,
even despite we assert(pdch != NULL).

[1] I8adc0cdb1b05a87b4df5d4bc196f6d381283a06f

Change-Id: I3490c38e0c1186dfd2fae63526a05c694547cebb
Fixes: CID#214230
2020-09-10 18:23:03 +07:00
Vadim Yanitskiy 542e388e4f encoding: implement handing of hopping parameters
The following test cases verify coding of the hopping parameters:

  + (RR) Immediate Assignment
    - TC_pcuif_fh_imm_ass_ul_egprs,
    - TC_pcuif_fh_imm_ass_ul,
    - TC_pcuif_fh_imm_ass_dl,

  + (RLC/MAC) Packet Uplink/Downlink Assignment:
    - TC_pcuif_fh_pkt_ass_ul,
    - TC_pcuif_fh_pkt_ass_dl,

all of them pass with this (and the upcoming) change applied.

Change-Id: I8adc0cdb1b05a87b4df5d4bc196f6d381283a06f
Related: SYS#4868, OS#4547
2020-09-08 02:47:02 +07:00
Vadim Yanitskiy db56a3563e encoding: use CSN.1 codec to generate Packet Uplink Assignment
It's quite odd to see that in write_packet_downlink_assignment()
we initialize an 'RlcMacDownlink_t', so then the caller can use
the power of CSN.1 codec to generate the final sequence of bytes
to be transmitted, while in write_packet_uplink_assignment() we
already compose the final RLC/MAC message straight away using
the low-level bitvec API (like bitvec_write_field()).

I guess the reason is that at the time of writing this code, the
CSN.1 codec was not stable enough, so it was safer to generate
the message 'by hand'.  This would also explain why we *decode*
the final RLC/MAC message in create_ul_ass() right after encoding.

Rewrite write_packet_uplink_assignment(), so now it initializes
a caller-provided 'RlcMacDownlink_t' structure.  Given that it's
allocated on heap using talloc_zero(), do not initialize presence
indicators of fields that are not present in the message.

This would facilitate handling of frequency hopping parameters
in the upcoming changes, in particular we can now introduce a
function that would compose Frequency Parameters IE for both
write_packet_{downlink,uplink}_assignment().

Tested manually by running a GPRS-enabled network, as well as by
running test cases from ttcn3-pcu-test => no regressions observed.

Change-Id: I2850b91e0043cdca8ae7498a5fc727eeedd029b6
Related: SYS#4868, OS#4547
2020-09-08 02:47:02 +07:00
Vadim Yanitskiy 962d717f41 encoding: clarify docstring for write_packet_downlink_assignment()
Change-Id: I7c4458c2e7767b6cf03462ba79acdd9c9904ee83
2020-09-08 02:47:02 +07:00
Pau Espin 1d68cdff92 Fix recent typo preventing MS from registering
Fixes: 0052051c07
Change-Id: Icbbf7340d78ef709ea00d527036533a14e9c21f9
2020-08-26 13:43:39 +02:00
Vadim Yanitskiy 1156776572 encoding: pass pdch slot directly to encoding functions
In order to be able to encode frequency hopping parameters, let's
pass a const pointer to 'gprs_rlcmac_pdch' (PDCH slot) directly,
instead of passing all related parameters separately.

Change-Id: I6bccad508f0fdccc4a763211008dd847a9111a8d
Related: SYS#4868, OS#4547
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy a76cdaceb2 encoding: use bool for use_egprs in write_packet_uplink_assignment()
Change-Id: Iab4fb44c666a0d4fe8c98f5ff9221e23a6f1f2fa
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy 59d64fb234 encoding: fix RRBP field in write_packet_uplink_assignment()
Do not hard-code 0x00, write what was passed as a parameter.

Change-Id: I9eb362292e9f4c16d4b8f8d4253df0422062eeb4
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy 7a1fdfde8a encoding: do not encode out of range Timing Advance values
According to 3GPP TS 44.060, section 12.12 "Packet Timing Advance",
the 'TIMING_ADVANCE_VALUE' field is optional, and takes 6 bits
if present.  This means that a value that fits in range 0..63
(inclusive) can be encoded (0b111111 == 63).

It's possible that tbf->ta() returns GSM48_TA_INVALID == 220,
so the bitvec API would encode only 6 LSBs of it:

  220 & 0b111111 == 28

Let's ensure that the 'TIMING_ADVANCE_VALUE' is present iff
tbf->ta() returns a correct (0 <= x <= 63), and absent otherwise.

Change-Id: I342288ea4ef1e218e5744e9be6a8e528d4e697fa
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy c0ddaa94e6 encoding: constify 'tbf' in UL/DL assignment functions
Change-Id: I9b80ce22914a355592502c936046b233c3ba216d
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy e4bcd2103c tbf: allocate the bitvec on stack in create_{dl,ul}_ass()
Initialize the bit vector to use already allocated memory,
so we would not need to allocate additional 23 bytes and
copy them from the bit vector to a msgb.

Change-Id: I4190707d7fa5b1c4c3db745635f88d5afb9e21ca
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy c82c1f5efc tbf: cosmetic: use GSM_MACBLOCK_LEN where possible
Change-Id: Ib42770cb009e8d559f733ebedd058e2f0a18820a
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy 48587d5475 gsm_rlcmac: use consistent naming for [Extended] Packet Timing Advance
Change-Id: I6382c81f7569b4c5a68521c04f6b03a34bfc39dd
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy 1d52c1e02e pcu_l1_if: cosmetic: correct error message in pcu_rx_info_ind()
Change-Id: I26ad0e990f6bf049a14f63b1255722d60c7ff868
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy 0f41b710b7 pcu_l1_if: cosmetic: move struct 'gprs_rlcmac_pdch' into the for loop
Change-Id: I5bc270ddb6064e5086a801061c2eff074c293e77
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy 11b0f00c00 pcu_l1_if: cosmetic: rename both 'trx'/'ts' to 'trx_nr'/'ts_nr'
Change-Id: Id481eba9bd462e411b2ba047ee5b849ddba8ac6b
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy ce0dae9fda pcu_l1_if: constify the argument of pcu_rx_info_ind()
Change-Id: I0b146c9f8c1e566c3aff4bd7869ca9699f888d4f
2020-08-24 10:53:08 +00:00
Vadim Yanitskiy fad2128d17 pcu_l1_if: use proper format specifier for PCUIF version
Change-Id: Ibd15a678a7a8fc840422e2280b0d358138a67e0c
2020-08-24 10:53:08 +00:00
Pau Espin b69928cfaf pdch: rcv pkt meas rep: Allocate MS object early in path and use it
Let's create the MS object early if doesn't exist and fill in the
information, so that we can operate on it in an early way (for instance,
logging macros), this way it's easier to trace the lifecycle of
subscribers.

Change-Id: I3ec7eb970310698dd228ae6ad65ec5ca833bab3f
2020-08-24 07:50:49 +00:00
Neels Hofmeyr 59fc0bda6e paging: pass struct osmo_mobile_identity, not encoded IE bytes
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is
returned. Code paths following this repeatedly decode the Mobile Identity
bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in
from a different encoding than a typical Mobile Identity IE, the TMSI was
manually encoded into a typical Mobile Identity IE. This is essentially a code
dup of osmo_mobile_identity_encode(). Stop this madness.

Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code
paths after this use the struct osmo_mobile_identity directly without repeated
decoding.

At the point of finally needing an encoded Mobile Identity IE (in
Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode().

Since this may return errors, add an rc check for the caller of
write_paging_request(), gprs_rlcmac_paging_request().

A side effect is stricter validation of the Mobile Identity passing through the
Paging code path. Before, invalid MI might have passed through unnoticed.

Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-24 01:12:16 +00:00
Neels Hofmeyr 0052051c07 use new osmo_mobile_identity api (avoid deprecation)
Note: subsequent patch Iad845acb0096b75dc453105c9c16b2252879b4ca will change to
passing a struct osmo_mobile_identity in the Paging code path, instead of
passing the encoded IE data.

Change-Id: Ibb03b8e601160427944f434761ca59811d1fc12f
2020-08-21 16:40:14 +02:00