Commit Graph

185 Commits

Author SHA1 Message Date
Pau Espin 20853c3bf9 rlcmac: Implement RLC_OCTET_COUNT in DL ACK/NACK
This helps debugging what's already in the MS tx queue when requesting a
new UL TBF.

Change-Id: Ie5f399fa0bffed8e39811075feba47a54054c8e5
2024-02-05 16:02:32 +01:00
Pau Espin ffc388ed4c Delay deleting UL TBF until last Pkt Ctrl Ack is fully transmitted
This in turn delays reconfiguring the lower layers (L1CTL-CFG_UL_TBF.req
mask=0x0) until the last block has been transmited.

Change-Id: Ic38b4207623ccbda3b77d4b0a47431c25de95034
2024-02-05 16:00:32 +01:00
Vadim Yanitskiy 5e0c5d990f rlcmac: add definition for OSMO_GPRS_RLCMAC_L1CTL_PDCH_DATA | Cnf
Change-Id: I145b9586f83ae0235b4648916bd44996e8dc57f0
2024-02-02 23:49:53 +01:00
Pau Espin d4c441f431 rlcmac: ul_tbf: Register UL ACK/NACK poll inside FSM
The poll is part of the FSM mechanism to get events to transit over the
different states. Register it from within the FSM to have more fine
grained control as well as have knowledge about the FN being reserved.

This knowledge will be used ina follow up patch for the UL TBF to wait
for the correct PKT CTRL ACK BLOCk.conf.

Change-Id: Iaa8ad8052b9f3b52b05af2b7fc9cb8172f1b6bb7
2024-02-02 23:49:53 +01:00
Pau Espin 31b298dfa5 rlcmac: Add new structure to allow passing FN+TN to TBF handling functions
The different paths will be updated as required as needed in the future.
Until now it was difficult while still valuable to have access to
current FN+TS, even if only for logging.

Follow up patch will use this info to be able to calculate poll FN from
RRBP more deep in the stack (ul_tbf_fsm).

Change-Id: Ifa09cd70c915aa3a2b799412cb02315aaebc0503
2024-02-02 23:49:48 +01:00
Pau Espin b0aae5bcd1 rlcmac: ul_tbf: Implement T3180
Related: OS#6209
Change-Id: I350b277532d36ed7928b33ee3b77d98d083a3179
2023-10-17 12:10:21 +02:00
Vadim Yanitskiy 5162449b71 rlcmac: migrate from fn_cmp() to gsm0502_fncmp()
Change-Id: I3030d00c6881713a088b1739b2b5ba77bac84e46
Depends: libosmocore.git I9590f2e836fc48650decf1564b6ab46306c4fe2d
Depends: libosmocore.git Ie8bb9c49c6f81b8f4a1766547d6943f9880d1186
2023-10-04 11:40:57 +00:00
Vadim Yanitskiy fef4af9381 rlcmac: deal with RACH retransmissions (drop rach_req_ra)
The RA value does change during RACH retransmissions, so we cannot
expect a specific value in gprs_rlcmac_handle_ccch_imm_ass_ul_tbf()
anymore.  Offload checking it to the lower layers.

* Rename submit_rach_req() to submit_packet_access_req().
* Get rid of gen_chan_req(), indicate only the access cause.

Ideally, we should also rename the OSMO_GPRS_RLCMAC_L1CTL_RACH
let's better do this separately.

Change-Id: If0de3ed86b1e2897d70183f3b0f4fbfd7d2bda80
Related: osmocom-bb.git Iab6d9147f6e0aeb99239affacf318a3897fd6ffe
Related: OS#5500, OS#6131
2023-09-23 03:28:31 +07:00
Pau Espin 5d806d88e3 rlcmac: tbf_dl: Log with FN request of UL TBF through PKT DL ACK/NACK
Change-Id: Ib81f1003361ca6501ce5a0e16ab2cdafc8ed66d3
2023-09-05 19:03:52 +02:00
Pau Espin f815b8f690 tbf_ul_ass_fsm: Listen only on 1 TS for PKT UL ASS when assignment done from DL TBF
This also fixes a memcpy writing out of bounds reported by Coverity
CID#323120 in gprs_rlcmac_tbf_ul_ass_start_from_dl_tbf_ack_nack(), due
to the difference of size between struct gprs_rlcmac_ul_tbf_allocation
and struct gprs_rlcmac_dl_tbf_allocation.
While fixing it, actually properly implement passing of the 1 only
interesting TS to the tbf_ul_ass_fsm at that point in time.

Change-Id: I89b15982b73f00599183981142495d7b9befbb78
2023-09-05 11:55:25 +02:00
Pau Espin 1e2779652b rlcmac: Move FN related helper functions to private header inside libosmo-gprs
These may be handy in other tests or inside the library.

Change-Id: I87393239b05a1c11498323139866aec9f6550f3b
2023-08-21 18:10:02 +02:00
Pau Espin ffb7833ce7 tbf_ul_ass: Don't check USF during SingleBlock Allocation
Change-Id: Icc2c17dc1933ad95da1b6b050f38a769909b23e5
2023-08-21 18:10:02 +02:00
Pau Espin 7c6773f6ff rlcmac: ul_tbf: Factor out function configuring TBF to lower layers
This code part will also be used by tbf_ul_ass_fsm.c to temporarily
configure lower layers with ctx->phase1_alloc in order to receive RTS
indications which the RLC/MAC uses to tick the FSM in state

Change-Id: I174327b25b726662a6b5902008e205ddb3de2fe0
2023-08-21 18:10:02 +02:00
Vadim Yanitskiy 9fd9d34e44 rlcmac: l1ctl_prim: add 'start_rfn' field to cfg_{ul,dl}_tbf_req
Change-Id: I27a7a896fe3839fa4f9b8cd9500c4ab7867bbaa0
Related: OS#5500
2023-08-21 18:10:02 +02:00
Pau Espin 58342fdbe2 rlcmac: keep looking up GRE based on old TLLI
This is needed after RAU Update since the PCU may still be using the old
TLLI to reference the MS for a while until it finds out about the TLLI update.

Change-Id: I2653db3dac58342df02a1b4d0c76e69e0e8d583f
2023-07-31 16:12:58 +02:00
Pau Espin 0f51adb03e rlcmac: Fix OSMO_GPRS_RLCMAC_GMMRR_LLC_TRANSMITTED declared in wrong offset
This enum should match osmo_gprs_gmm_gmmrr_prim_type, and I placed that
osmocom-specific enum at the wrong place in the rlcmac counterpart.

Change-Id: I3f198c756866417f8f975373f84fd3ec4da608fa
2023-07-31 14:55:25 +02:00
Pau Espin b4a6069f82 gmm: Several fixes for radio_prio
The "Radio Priority" received in GMM Attach Accept are for SMS and TOM8
SAPs only. For GMM/SM unitdata transferred to LLC, use highest

Change-Id: Ie583c433547fb5ecbb6b6077c39a157961f73cfc
2023-07-31 14:37:34 +02:00
Pau Espin ee091182c5 rlcmac: Initial selection of packet-access-procedure mode based on originating cause
Change-Id: I930a1fcf23506f75562a6795f9a6e42b187d2974
2023-07-28 17:56:45 +02:00
Pau Espin 27bbb88d27 rlcmac: Use enum gprs_rlcmac_radio_priority internally everywhere
This simplifies the array handling in the LLC queue, and moves param
checking to the rx rlcmac_prim path instead of deep in the llc_queue
enqueuing code.

This commit also fixes the RADIO_PRIORITY field in the Channel Request
Description section of PKT DL ACK/NCK, since
gprs_rlcmac_llc_queue_highest_radio_prio_pending() now returns the enum
normalized 0..3 as expected by the field format (before it was returning

Change-Id: If2d1946522bc4a1c19d65acb23605f1a3f05ab45
2023-07-28 13:49:49 +02:00
Pau Espin 8b1e4cbae6 sndcp: Forward QoS params from SM to LLC
Change-Id: I70e355ef27d24bdaf00e54f0e7126193f5bbf19f
2023-07-28 13:49:49 +02:00
Pau Espin bd7964f101 sm: Introduce APIs to enc/dec QoS Profile
Ported from  open5gs.git/lib/gtp/v1/types.{c,h} 5764f7267d16a8ea6aeedc6c227552575915def5,
for which I was the author too.
The ARP extra byte field at the start of the IE val which is introduced in the
GTP variant is dropped when porting to SM, since it's not present there
(and offsets/sizes are adjusted).

The QoS code is moved is moved into a common/ directory where a new private static library is created.
This is done in order to be able to resuse the QoS dec/enc code in
several libraries since it's actually planned to use it in SNDCP and SM
The most natural place to add the APIs is SM, and that's where the
public API to accees the enc/dec is provided, since the user app will
have to use them in the SM SAP.
However, the SNDCP will also have to decode the QoS recived by SM
through the SNSM SAP, and we don't really want libosmo-gprs-sndcp depend
on libosmo-gprs-sm. This way libosmo-gprs-sndcp will be able to use the
private APIs directly in a follow-up commit.

Change-Id: I6c0676e55bb1f0f424f41d8d04d4f5e5bf376f4f
2023-07-28 13:49:46 +02:00
Pau Espin 3ad76e16ef llc: Set proper Radio Priority when submitting GRR-UNITDATA.req
Change-Id: I2ace165003469c2a43d7333634171896699d5a5d
2023-07-28 13:48:25 +02:00
Pau Espin f79a8d8499 sndcp: Use radio_prio assigned by SM when submitting LLC unitdata.req
Change-Id: I632329bb1f34efb4d9263241e2cda5b559f1ff59
2023-07-28 13:48:25 +02:00
Pau Espin 9b50028192 sndcp: Update n201_u & n201_i indicatd by LLC layer
Change-Id: I7429701ae49c2a694dcad3e3d5ec639ab9927f5b
2023-07-28 13:48:25 +02:00
Pau Espin 7a75a16350 llc: Introduce function to log XID fields and use upon Rx/Tx
Change-Id: I8c6b07305c0bcecb4e1681967884a3e62c813592
2023-07-26 20:22:56 +02:00
Pau Espin f4fca416e2 llc: xid: Introduce some helper internal functions to make code easier to follow
Take the chance to fix wrong indentation on related function parameter.

Change-Id: I8c0163583efc2720a4b2675ce93293c184f80d0c
2023-07-26 19:00:32 +02:00
Pau Espin 678daf22ca rlcmac: recalculate CV as needed when already in Countdown procedure
Getting out of contention resolution means we may have to update our
calculated CV state because we are no longer sending TLLI.

Same happens if a new tx CS is provided by the network, since different
block size means different CV.

In this commit only code paths for the state where already in Countdown
Procedure are added. If TBF has to enter Countdown Procedure due the
above mentioned changes, it will do so using regular path where a new
RLC block is created.

Related specs: TS 44.060 9.3.1
Related: OS#6018

Change-Id: I6ca88c005060ba1302d46717e45b0d9731d86d8d
2023-07-24 16:36:52 +02:00
Pau Espin 3ae18f65a8 rlcmac: Avoid discard packets when in Countdown procedure
Discarding a packet through CoDel during Countdown procedure may end up
in the transmitted CV=14..0 being incorrect, since we are not really yet
recalculating them once we enter Countdown procedure.
Hence, to make it simpler for now, avoid dropping packets when in
Countdown procedure to avoid having to recalculate them.

Change-Id: I311302b5282767dc806b1dfe053994f175390b69
2023-07-24 13:46:50 +02:00
Pau Espin 49535bec37 rlcmac: Mark received BSNs falling out of the V(N)/RBB when V(R) is raised
Problem this patch is fixing:
The current RLCMAC window code ported from osmo-pcu is never
invalidating the BSNs which have been received after they are not
As a result, when the DL TBF keeps sending data for a long time, and
finally BSN wraps around 127->0, when this implementation receives the
BSN=0, it will find it is already received and hence will discard it,
and then keep asking for BSN=0 nevertheless in PKT DL ACK, causing an
endless loop where PCU stays submitting the same block forever.

Explanation of the solution:
The V(N) array contains the status of the previous WS (64 in GPRS) data
blocks. This array is used to construct the RRB signaled to the peer
during PKT DL ACK/NACK messages together with the SSN (start sequence
number), which in our case is mainly V(R), aka one block higher than the
highest received block in the rx window.
Hence, whenever PKT DL ACK/NACK is transmitted, it contains an RRB
ranging [V(R)-1,...V(R)-WS)] mod SNS (SNS=128 in GPRS).

The receive window is basically [V(Q) <= BSN < V(R)] mod SNS, as is of
size 64.
The V(R) is increased whenever a highest new block arrives which is in the
receive window (guaranteeing it will be increased to at most V(Q)+64.

Since we are only announcing state of blocks from V(R)..V(R)-WS, and
blocks received which are before that BSN are dropped since don't fall
inside the rx window, we can securely mark as invalid those blocks
falling behind V(R)-WS whenever we increase V(R).

Related: OS#6102

Change-Id: I962111995e741a7e9c230b2dd4904c2fa9a828e9
2023-07-21 17:59:45 +02:00
Pau Espin f8b1d0002f rlcmac: Fix LOGPTBFDL macro log category
Change-Id: I7f90981a114070ff13c508f0c6800cc1dd2cfe14
2023-07-20 17:39:46 +02:00
Pau Espin 12311c2561 rlcmac: tbf_ul: Free TBF if submitting RACH.req fails
Change-Id: I63d68e524629a90931497d1181f134830b4819f9
2023-07-20 14:17:32 +02:00
Pau Espin c0bc613f60 llc: Introduce LL-ASSIGN.ind
TS 24.007, TS 24.008, TS 44.064 nor TS 44.065 explain how the TLLI
update happening during GMM RAU propagates to the SNDCP layer.
GMM only has interfaces towards LLC and GRR, and uses LLGMM-Assign.Req
and GMMRR-Assign.req to update the TLLI in the respective layers.
This patch adds a new primitive in the LL interface (LLC->SNDCP)
LL-Assign.ind to propagate the LLGM-Assign.req received from
GMM towards SNDCP, so that it can use the new TLLI in order to address
the specific MS.

Change-Id: Icb858f5397414b6d4183c21f13d35c0166ca7635
2023-07-20 11:59:32 +02:00
Pau Espin 25ed304b44 sndcp: Answer SNSM-DEACTIVATE.ind with .resp
Change-Id: I8ddebf93d3150cc952f9e5fc5d6f3cfc99e912a5
2023-07-20 10:00:22 +02:00
Pau Espin f87b9da362 sm: Handle GMMSM-MODIFY.ind primitive
Change-Id: Ic765b7a565cac4abcf34d8c6868e103971d17822
2023-07-20 10:00:22 +02:00
Pau Espin 70c6407f69 gmm: Introduce GMMSM-Modify.ind primitive
TS 24.007 and TS 24.008 seem to lack providing an explicit way to pass
information between GMM and SM (GMMSM interface) when a RAU process
happens in GMM (rx RAU Accept).

This lack of primitive can easily be spotted by looking at TS 24.007
Appending C.15, or even better, at the 3rd page of "C.16(cont’d)" around
the "STOP Trams" timer, where the info is magically available in SM when
being received at GMM.

Change-Id: I81e207d44d88f18f0ee13fb413827606a6f830bc
2023-07-19 19:02:27 +02:00
Pau Espin f31984ba35 gmm: Store received PDP Ctx Status and List of Receive N-PDU Numbers
Those IEs are aimed at upper layers (SM, SNDCP) and will be relayed in
follow-up patches.

Change-Id: I3a43b5e0417796f7dce4010cd6a6d3fd2d9c543e
2023-07-18 18:03:42 +02:00
Pau Espin 34f4b94a98 gmm: Make OSMO_GPRS_GMM_TLLI_UNASSIGNED def publicly available
This can be used for users receiving the GMMRR_ASSIGN_REQ primitive to
find out if it's a creation, update or deletion of a TLLI.

Change-Id: I881b1370b283ceee98c035ed42b91f7e12611979
2023-07-18 11:31:20 +02:00
Pau Espin 2d121dcdb1 rlcmac: Introduce L1CTL-CCCH_READY.ind primitive
This is used by lower layer L1CTL to notify the upper layer RLCMAC when
it's prepared to use CCCH.

Change-Id: I4cfb1e2db217a97b7a1dc8849cd13d58e4034c56
2023-07-18 11:31:05 +02:00
Pau Espin 7d3f3ad57e cosmetic: gmm: fix spec reference format
Change-Id: Id4b52b6110fc8012d5d3b4d341b9702e3142c334
2023-07-14 16:09:33 +02:00
Pau Espin cabca87921 rlcmac: tbf_dl: Implement T3192
Related: OS#5500
Change-Id: I49c9068d1819d6189103908f6f92ce05952b74e6
2023-07-05 13:49:20 +02:00
Pau Espin 5dc23ea408 rlcmac: tbf_dl: Implement T3190
Related: OS#5500
Change-Id: I3f69fde298dcd64d30b9d648a96717a8378864c4
2023-07-05 13:49:20 +02:00
Pau Espin 1026e0a417 rlcmac: defer going to pkt_idle_timer after freeing TBF
Give some time to pending tx blocks to be transmitted before jumping
back to CCCH.

Change-Id: I563ad2ee6aacd65314e998626dc27adc29221a7d
2023-07-05 13:49:13 +02:00
Pau Espin 806426525d rlcmac: tbf_ul: Move to packet-idle state when T3164 triggers
TS 44.018
"The one phase packet access procedure is completed at a successful
contention resolution. The mobile station has entered the packet transfer
mode. Timer T3141 is stopped on the network side. Timer T3164 is stopped
on the mobile station side."

Change-Id: Ic7420a42e2e81effdde587d7e49acd66b404354c
2023-07-04 14:29:25 +02:00
Pau Espin 2f47cf4edb rlcmac: Rework tbf destructor to signal free() to its gre object
This will be needed in follow-up patches for the MS to trigger actions
when TBFs are freed (like going back to IDLE mode, or start

Change-Id: I72959e27f2f62c84218d740cfb9e396d70562929
2023-07-04 14:13:02 +02:00
Vadim Yanitskiy f77d343966 rlcmac: add OSMO_GPRS_RLCMAC_L1CTL_PDCH_{ESTABLISH,RELEASE}.req
* Send the PDCH_ESTABLISH.req on receipt of RR IMM ASS,
* Sending of PDCH_RELEASE.req is to be implemented.

Change-Id: I2568c58646ce7511367275ac96cd55e7fdd7ec18
Related: OS#5500
2023-07-04 14:13:02 +02:00
Pau Espin 3406697bcf rlcmac: tbf_dl: Fix typo in event name
Change-Id: I089d8e5f0a3e8946cc78a0e9645a8d040aa7dddf
2023-07-04 14:12:49 +02:00
Pau Espin 90a46d1d2a rlcmac: Implement UL TBF Countdown procedure
The Countdown procedure (decreasing CV field in UL RLCMAC data blocks)
is defined in TS 44.060 9.3.1.

It is implemented by means of counting/calculating the amount of RLC/MAC
blocks to be transmitted based on the LLC frames in the several LLC
queues, without actually generating the RLC/MAC blocks. The blocks
cannot be generated ahead of time because that wouldn't allow recreating
them in case Tx UL CS changes, or if a higher priority LLC frames
The functions calculating the required amount of RLC/MAC blocks are
coded so that they early return to avoid spending more time than
necessary counting blocks (< BS_CV_MAX).
An extra heuristic optimization to be used when LLC queues are long is left
documented as a TODO, in order to test further the general non-optimized
path for now. Once the counting is proved to work reliably, that and
other heuristic optimizations ca be implemented, like keeping and
decreasing CV cached counter while no Tx CS change occurs or no new LLC
frames are enqueued.

Change-Id: If043c86a0c2b89d0ac0b8174de39fbcb22bed8cb
2023-06-06 12:54:38 +02:00
Pau Espin 7b9654c4d0 sm: Handle GMMSM-Release.ind
Change-Id: Ia2ac9dbffe29c3509f1088ceb327569a331ec598
2023-05-31 14:47:56 +02:00
Pau Espin d2fd394e4d gmm: Implement rx RAU Reject
Change-Id: I0d4d8288b78cfd3140c786a52a3906eaf37ebe6b
2023-05-29 16:22:13 +02:00
Pau Espin 5e083ed3b9 gmm: Initial implementation of T3166, rx Auth & Ciph Reject
As specified in 3GPP TS 24.008 Table 11.3/3.

Change-Id: I2c24b968e90cf5ec71fa8a777ec57b407eec015f
2023-05-29 16:22:13 +02:00