Commit Graph

366 Commits

Author SHA1 Message Date
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
1..4).

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
libosmo-gprs-common.la 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
layers.
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 b3e506b38c sm: Forward RadioPrio & QoS in SNSM-Activate.ind
Change-Id: Ia8226f6e687f86b2502b27f9979dce13cf751c01
2023-07-28 13:48:25 +02:00
Pau Espin b59dfd4de9 cosmetic: sm: Fix wrong reference in comment
Change-Id: I8828e0019f6446c3a17d09e8483573bf752c159f
2023-07-28 13:48:25 +02:00
Pau Espin f37d91072f sndcp: Initialize N201-U & N201-I to default settings
LLC is only expected to signal new values if SNDCP XID params are
received, or if the default N201 values change.

Change-Id: I68f54d329b326895ed8f010cf50f20fa30948d30
2023-07-28 13:48:25 +02:00
Pau Espin d8d592db54 llc: Set proper SAPI when transmitting UNITDATA.req to GRR/BSSGP
Change-Id: I962e25789849f89c532f5ede386fa029600d9901
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 6e1a35bab7 llc: Submit LL-XID-IND to L3 if N201-U or N201-I changes
Change-Id: I8135c5cef4df69a7c3a540050da0837bf2059df2
2023-07-28 13:48:22 +02:00
Pau Espin 5aa16e1c8d llc: Apply N201-I & N201-U requested by the network
Change-Id: I2f2cb8b831266b8e4251c2832e6545bef776658c
2023-07-26 20:23:00 +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 459383d531 rlcmac: Apply tx_cs requested by the network through PKT UL ACK/NACK
Recalculating CV when in Countdown Procedure will be implemented in a
follow-up commit.

Related: OS#6108
Change-Id: I1e7b28c2e5f1d77a962ec3070f3a027b8f66a69e
2023-07-24 13:52:51 +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 8c935ca0a7 rlcmac: ul_tbf: Move logic selecting proper queue to helper function
This clarifies the logic behind selecting the proper queue, and it will
be used further in the future, for instance when recalculating CV once
already in Countdown procedure.

Change-Id: Icceaf53048e9662176385b2976e2bc8e3387df71
2023-07-24 13:46:46 +02:00
Pau Espin 29dc2b13fb rlcmac: Log LLC PDUs enqueued in llc_queue
This allows gathering more information on the state of the queue and
helps in understanding possible bugs on the CV calculation algo.

Related: OS#6108
Change-Id: I97f4977944a6f82abc7b39c4e578de9d8e152740
2023-07-21 18:33:31 +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
needed.
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 1d41688c56 rlcmac: rlc_window_dl: Fix RBB generation
We want to do mod sns on the BSN, not on the boolean returned by
gprs_rlcmac_rlc_v_n_is_received().
This is a typo which occurred while porting the code from osmo-pcu.git
void gprs_rlc_ul_window::update_rbb(char *rbb), where the following line
is used:
"""
	if (m_v_n.is_received((ssn()-1-i) & mod_sns()))
"""

Change-Id: I37c8fd5c2528f035f077c3e05105f913922ffd84
2023-07-21 16:08:03 +02:00
Pau Espin 937fdb405e rlcmac: Log SSN and FINAL_ACK when preparing PKT DL ACK/NACK msg
Change-Id: Ia8cd3ea341308887953fe76df6821c429b3d8e77
2023-07-21 16:07:44 +02:00
Pau Espin f8b1d0002f rlcmac: Fix LOGPTBFDL macro log category
Change-Id: I7f90981a114070ff13c508f0c6800cc1dd2cfe14
2023-07-20 17:39:46 +02:00
Pau Espin 427949ce75 rlcmac: Fix null ptr dereference
Caught by ASan during test run. This can happen if
gprs_rlcmac_ul_tbf_schedule_next_llc_frame() finds no more llc frames to
submit during the loop iteration.

Change-Id: I5bd6dd6c6b7dc4b911af7bc119cf85eb810959a0
2023-07-20 14:18:35 +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 b688cdf727 sndcp: Handle LL-ASSIGN.ind
Change-Id: I924dcf3ac9cbb15e26a5e9376f89ca098ab49e0b
2023-07-20 11:59: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 a8f90e5bc1 gmm: Document spec ref regarding Receive N-PDU Numbers IE in RAU Compl
Change-Id: I8b4c5a6c4c4da3648160aa32f7586c74942c7734
2023-07-19 18:58:23 +02:00
Pau Espin 2b2d81c5d6 gmm: Fix typos in test
The TLLI was wrong (I tooked the one from the Attach Accept msg instead
of RAU accept message defined above).

Change-Id: I2f7d61c72febad24fde285578e20485a23b8e175
2023-07-18 18:28:30 +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 4c9ea11604 cosmetic: gmm: Fix typo in comment
Change-Id: I9c32def9571294abe2e67235a50809839ed5966a
2023-07-17 12:12:48 +02:00
Pau Espin 7d3f3ad57e cosmetic: gmm: fix spec reference format
Change-Id: Id4b52b6110fc8012d5d3b4d341b9702e3142c334
2023-07-14 16:09:33 +02:00
Vadim Yanitskiy fc2228e050 doc: add PDCH timing diagram illustrating UL/DL delay
Change-Id: I7d01c833b6b746d74e6ecd8c65c929a320a95d17
2023-07-11 18:36:07 +07:00
Pau Espin f60efde896 gmm: Accept event LOW_LVL_FAIL in RAU/SR_INITIATED states
This even is triggered by the GSM itself due to internal timeouts as a
consequence of lower layers not resolving the request (with accept or
reject events).

Change-Id: Ic1072629595e75c411b421e71f6ffac5dd41da3b
2023-07-05 13:49:20 +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 3.5.2.1.4:
"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
packet-access-procedure).

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 b96ceaa9e3 rlcmac: tbf_fsl_fsm: Expect ev LAST_DL_DATA_RECVD in state FINISHED
Change-Id: Iff581e53cdbf9057b65c478f7ce9f3387c4a1646
2023-07-04 13:19:28 +02:00
Pau Espin 93290a2470 rlcmac: BS_CV_MAX=0 should be interpreted as =1 when calculating N3104_MAX
In the test more PDUs are submited in LLC in order to avoid trigger
max_retrans=4 for last block, which would trigger beforehand in that
case.

Change-Id: Ia83173afdbb25df18c7cead7857fe1b39a1ce82f
2023-06-21 11:55:56 +02:00
Pau Espin 1e1675091c rlcmac: Submit UL block to lower layers before freeing TBF
Change-Id: I236a5fd0e97b0b323153a4b6cf95b785348cf7df
2023-06-06 14:23:27 +02:00
Pau Espin ad51d7797c rlcmac: tbf_ul: Handle SBA from CCCH Imm Ass
Change-Id: I8563b6d61b93d86c15282995352ca9312e167160
2023-06-06 12:54:53 +02:00