summaryrefslogtreecommitdiffstats
path: root/src/host/trxcon/sched_trx.h
AgeCommit message (Collapse)AuthorFilesLines
2020-03-08trxcon/scheduler: refactor Downlink measurement processingVadim Yanitskiy1-10/+24
So far we used to store the sums of ToA and RSSI measurements in the logical channel state, and after decoding of a block, we did calculate the average. This approach works fine for xCCH and PDTCH, but when it comes to block-diagonal interleaving (which is used on TCH/F and TCH/H channels), the results are incorrect. The problem is that a burst on TCH may carry 57 bits of one encoded frame and 57 bits of another. Instead of calculating the sum of measurements on the fly, let's push them into a circular buffer (the measurement history), and keep them there even after decoding of a block. This would allow us to calculate the average of N last measurements depending on the interleaving type. A single circular buffer can hold up to 8 unique measurements, so the recent measurements would basically override the oldest ones. Change-Id: I211ee3314f0a284112a4deddc0e93028f4a27cef
2020-03-01trxcon/scheduler: print completeness of the Rx burst buffersVadim Yanitskiy1-0/+1
Change-Id: Ife9f5eabc23aa2eea08b190361e10a98e890d608 Related: OS#3554
2019-12-04trxcon: Use current MS Power on dummy meas reportsPau Espin Pedrol1-0/+5
backpointers are added in order to access the TRX, as advised in the existing comment. Change-Id: I975cfc5f5d63eb32a7f8932a7f6a544c9a12233c
2019-11-05trxcon: Fix missing header for GSM_MACBLOCK_LENPau Espin Pedrol1-0/+1
Due to recent include dependency tree change in libosmocore, trxcon fails now to build since it uncovered it's missing a header inclusion for a symbol it is using: osmocom-bb/src/host/trxcon/sched_trx.h:204:20: error: ‘GSM_MACBLOCK_LEN’ undeclared here (not in a function) 204 | uint8_t mr_cache[GSM_MACBLOCK_LEN]; | ^~~~~~~~~~~~~~~~ Change-Id: Ide22e525c106342b00171a8c08bb7265d19a651b
2019-10-05host/trxcon: add optional GSMTAP frame logging supportVadim Yanitskiy1-0/+7
This feature may be useful for our TTCN-3 testing infrastructure. By default it's disabled, and can be enabled using command line arguments of the main binary: ./trxcon -g 127.0.0.1 ... Change-Id: Iab4128fee5f18d816830fdca6c5ebebaf7451902
2019-09-30trxcon/scheduler: fix handling of PTCCH logical channelVadim Yanitskiy1-0/+4
According to 3GPP TS 45.010, section 5.6.2, for packet-switched channels the BTS shall monitor the delay of the Access Bursts sent by the MS on PTCCH and respond with timing advance values for all MS performing the procedure on that PDCH. According to 3GPP TS 45.002, section 3.3.4.2, PTCCH (Packet Timing advance control channel) is a packet dedicated channel, that is used for continuous Timing Advance control (mentioned above). There are two sub-types of that logical channel: - PTCCH/U (Uplink): used to transmit random Access Bursts to allow estimation of the Timing Advance for one MS in packet transfer mode. - PTCCH/D (Downlink): used by the network to transmit Timing Advance updates for several MS. As per 3GPP TS 45.003, section 5.2, the coding scheme used for PTCCH/U is the same as for PRACH as specified in subclause 5.3, while the coding scheme used for PTCCH/D is the same as for CS-1 as specified in subclause 5.1.1. The way we used to handle both PTCCH/U and PTCCH/D is absolutely wrong - it has nothing to do with xCCH coding. Instead, we need to use rx_pdtch_fn() for Downlink and tx_rach_fn() for Uplink. Also, since we only have a shared RSL channel number for PDCH (Osmocom-specific RSL_CHAN_OSMO_PDCH), there should be a way to distinguish both PDTCH and PTCCH logical channels. Let's introduce TRX_CH_LID_PTCCH for that. Change-Id: I2d1e9b8a66f027047f8d7bdc3f82ff9d8ebcc25e
2019-05-30trxcon/scheduler: move PRIM_IS[_EXT]_RACH macros to sched_trx.hVadim Yanitskiy1-0/+10
Both PRIM_IS_RACH() and PRIM_IS_EXT_RACH() macros to be used for handover RACH detection in the follow up changes, thus we need have them widely available. Let's also give them better names: PRIM_IS_EXT_RACH -> PRIM_IS_RACH11 PRIM_IS_RACH -> PRIM_IS_RACH8 and introduce a new generic one for checking whether a given primitive is RACH in general (either 8-bit or 11-bit) or not. Change-Id: Ibc39c57fda000647be1829786f6423dcf3f435cd
2019-05-28trxcon/scheduler: refactor description of TRXC_* lchansVadim Yanitskiy1-2/+3
Let's avoid fancy alignment in the description of logical channels for the benefits of having better readability, the ability to add more comments and fields without making it look ugly. Also, let's get rid of field 'chan' of 'trx_lchan_desc' structure since it's not used anywhere, and not actually needed because the position of each lchan description is defined by its TRXC_* type. As a bonus, let's add a human readable description to each lchan definition, so it can be printed in the VTY some day. Change-Id: I2fc61e1cdca4690a34e2861b9ee3b7c64ea64843
2019-02-21trxcon/scheduler: count number of measurementsVadim Yanitskiy1-4/+2
Instead of counting both RSSI and ToA measurements separately, let's have a single counter in trx_lchan_state.meas struct. Change-Id: I45454a3ac92b8cc85dd74092e4ab6eb350f20c9a
2019-01-15trxcon/sched_trx.c: use bool in sched_trx_reset()Vadim Yanitskiy1-1/+1
Change-Id: I4f6990520836edb5eecce38c04857a4b3bc6f2fc
2018-10-20trxcon/scheduler: add PDTCH channel supportVadim Yanitskiy1-0/+3
Change-Id: I1176576f54c1d68e79cc6ac37d61a9033f7018dd
2018-10-03trxcon/scheduler: add CCCH/SDCCH mframe layouts with CBCHHarald Welte1-0/+2
According to GSM TS 05.02, section 3.3.5, Cell Broadcast Channel (CBCH) is a downlink only channel, which is used to carry the short message service cell broadcast (SMSCB). CBCH is optional, and uses the same physical channel as SDCCH. More precisely, CBCH replaces sub-slot number 2 of SDCCH channels when enabled. This change introduces the CBCH enabled multi-frame layouts, and two separate logical channel types: - GSM_PCHAN_CCCH_SDCCH4_CBCH (lchan TRXC_SDCCH4_CBCH), - GSM_PCHAN_SDCCH8_SACCH8C_CBCH (lchan TRXC_SDCCH8_CBCH). Both logical channels are separately identified using the following Osmocom specific cbits: - TRXC_SDCCH4_CBCH - 0x18 (0b11000), - TRXC_SDCCH8_CBCH - 0x19 (0b11001). The reason of this separation is that we somehow need to distinguish between CBCH on C0/TS0, and CBCH on CX/TS0. Unlike TRXC_SDCCH8_CBCH, TRXC_SDCCH4_CBCH is enabled automatically (TRX_CH_FLAG_AUTO), so CBCH messages can be decoded on C0 while being in idle mode. Change-Id: Iad9905fc3a8a012ff1ada26ff95af384816f9873
2018-09-28trxcon/scheduler: fix Measurement Reporting on SACCHVadim Yanitskiy1-0/+10
According to 3GPP TS 04.08, section 3.4.1, SACCH logical channel accompanies either a traffic or a signaling channel. It has the particularity that continuous transmission must occur in both directions, so on the Uplink direction measurement result messages are sent at each possible occasion when nothing else has to be sent. The LAPDm fill frames (0x01, 0x03, 0x01, 0x2b, ...) are not applicable on SACCH channels! Unfortunately, 3GPP TS 04.08 doesn't clearly state which "else messages" besides Measurement Reports can be send by the MS on SACCH channels. However, in sub-clause 3.4.1 it's stated that the interval between two successive measurement result messages shall not exceed one L2 frame. This change introduces a separate handler for SACCH primitives, which dequeues a SACCH primitive from transmit queue, if present. Otherwise it dequeues a cached Measurement Report (the last received one). Finally, if the cache is empty, a "dummy" measurement report is used. When it's possible, a non-MR primitive is prioritized. Change-Id: If1b8dc74ced746d6270676fdde75fcda32f91a3d Related: OS#2988
2018-09-28trxcon/scheduler: pass talloc ctx directly to sched_prim_init()Vadim Yanitskiy1-1/+1
Enforcing pointer to a 'trx_instance' structure is not flexible, because it is used as parent talloc context only. Change-Id: I5ab2ef5cea76f955bf72ef54541b3b75cdc2d23f
2018-09-28trxcon/scheduler: pass lchan state to sched_prim_dequeue()Vadim Yanitskiy1-1/+1
Having access to a logical channel state is required by the follow-up change, which will introduce a separate function for dequeuing SACCH primitives. Change-Id: Ibde0acf8e6be224b1007be707a636eaad68c8d36
2018-09-16trxcon/scheduler: add TCH/H channel supportVadim Yanitskiy1-3/+3
Change-Id: Ibb2a0850692c5ff86b13b820af10b12085589e67
2018-09-16trxcon/scheduler: introduce TCH/H TDMA frame mapping helpresVadim Yanitskiy1-0/+16
Unlike xCCH, TCH/H channels are using block diagonal interleaving, so every single burst carries 57 bits of one traffic frame, and 57 bits of another one. Moreover, unlike TCH/F where both traffic and FACCH/F frames are interleaved over 8 bursts, a FACCH/H is interleaved over 6 bursts, while a traffic frame is interleaved over 4 bursts. This is why a TCH/H burst transmission can't be initiated on an arbitrary TDMA frame number. It shall be aligned as of stated in GSM 05.02, clause 7, table 1. This change introduces two basic functions: - sched_tchh_block_map_fn - checks if a TCH/H block transmission can be initiated / finished on a given frame number and a given channel type; - sched_tchh_block_dl_first_fn - calculates TDMA frame number of the first burst using given frame number of the last burst; and some auxiliary wrappers to simplify the usage of sched_tchh_block_map_fn(). Change-Id: Iaf4cb33f1b79df23f8a90c8b14ebe0cd9907fbb9
2018-08-15trxcon/scheduler: get rid of useless lchan->rsl_modeVadim Yanitskiy1-2/+2
This field of the logical channel state structure was not used at all as there is nothing related to A-bis / RSL in trxcon itself. Change-Id: Iec1abf777a74cf57deadafa95e2337cba5d02842
2018-08-15trxcon/scheduler: pass lchan to sched_bad_frame_ind()Vadim Yanitskiy1-1/+1
Instead of passing the information about a logical channel, it makes sense to pass the pointer to its state where everything is stored. This approach would allow to avoid adding more arguments every time, e.g. in case of AMR. Change-Id: I91fe86fef43aac68776a58c9acc37ef2a9ee8042
2018-08-14trxcon/sched_prim.c: properly handle both TCH/H and FACCH/H primsVadim Yanitskiy1-1/+1
Initially it was assumed that FACCH prioritization should be done in the same way for both TCH/F and TCH/H. Moreover, it was not possible to confirm this, because TCH/H was (and still) not implemented yet. But according to the specs: - unlike FACCH/F, FACCH/H transmissions shall be aligned within a multiframe, i.e. can only be initiated on particular frame numbers (see GSM 05.02, clause 7); - unlike FACCH/F, a FACCH/H frame steals two TCH/F frames; so the TCH/H (including FACCH/H) primitives should be handled separately from the TCH/F (including FACCH/F) primitives. Change-Id: I9b59f60e1cbac8fb8fd557b6c67b5e376c0a6bbb
2018-08-14trxcon/sched_trx.h: add missing parentheses to PRIM_IS_*Vadim Yanitskiy1-2/+2
Change-Id: Ifa7d9f806b3f18f2dfec931252f5119441b30e8a
2018-04-02trxcon: Respect the tch_mode field of DM_EST_REQHarald Welte1-1/+1
the initial tch_mode is not always 0 (signalling) but can very well be directly a codec mode, if the initial activation of the channel is in speech mode as opposed to signalling Change-Id: I96e4c89da1165e9c5287d863e0e65d811460c606
2018-03-22trxcon/scheduler: add CHAN_IS_SACCH macroVadim Yanitskiy1-0/+3
Change-Id: I2fc90d4732433f221c628058c9812815edf9c8cb
2018-03-22trxcon/scheduler: share lchan link identifiersVadim Yanitskiy1-0/+3
Change-Id: Ie1632f274b2ae6147a8e918ebfea60eeeb6a234c
2018-03-11trxcon/scheduler: enforce lchan handlers to set message typeVadim Yanitskiy1-4/+4
Since this change, each lchan handler shall manually indicate a type of both message indications and confirmations. Change-Id: I02e0b87d61c127d2f6f5b9532909af78332bf707
2018-03-11trxcon/scheduler: transmit dummy frames on CBTX lchansVadim Yanitskiy1-0/+12
If at the moment of transmission there are no frames in TX buffer, then either a dummy LAPDm frame (0x01, 0x03, 0x01, 0x2b ...) or a silence frame (depending on a codec in use) shall be transmitted. This is required for proper measurements on the BTS side. Change-Id: Ie590990f2274ea476678f6b2079f90eeadab6501
2018-03-11trxcon/scheduler: introduce a new CBTX lchan flagVadim Yanitskiy1-0/+2
This new flag is intended to indicate that continuous burst transmission is assumed on particular logical channel. In other words, if a logical channel has this flag, but there is nothing to transmit in a TX buffer, then either a dummy LAPDm frame or a silence frame shall be sent. Change-Id: I25fcf9eeb787ffe5378d92532439e67d7d42fa65
2018-03-11trxcon/sched_trx.h: clarify lchan flags meaningVadim Yanitskiy1-1/+3
Change-Id: I51b663dd16e46a4523488c3d3000922a7c3640d1
2018-03-02host/trxcon: use integer math for ToA (Timing of Arrival)Vadim Yanitskiy1-4/+5
There's no need to express ToA value as a float. Let's turn it into an int16_t with 1/256 symbol period accuracy throughout the code to avoid both float arithmetic as well as loosing any precision. Inspired by Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec. Change-Id: I99c0f38db08a530d5846c474aba352aa0b68fe86
2018-01-05trxcon/scheduler: use TCH frame length defs from libosmocodecVadim Yanitskiy1-5/+0
Change-Id: I6439d3cadd2dc1fa8fe401eb61c977a12ec844f2
2018-01-05trxcon/scheduler: use linuxlist API for lchan managementVadim Yanitskiy1-1/+3
As there is no any order relation between logical channels, it's better to use the linuxlist API instead of talloc array. Change-Id: I5a78582c77ed1ab33817d240e065dc4cd4708199
2018-01-05trxcon/scheduler: share chan / prim identification helpersVadim Yanitskiy1-0/+9
Because they would be also used outside. Change-Id: Ic8af9d7c72fdb124caef82e35170f92b84e16eb9
2017-12-18trxcon/scheduler: implement A5/X ciphering supportVadim Yanitskiy1-0/+2
This change implements the A5/X ciphering support transparently for the logical channel handlers. In other words, a DL burst is deciphered before being passed to a handler, and an UL burst is ciphered before being sent to transceiver. The implementation mostly relays on the libosmocore's A5 API. Change-Id: Ib53418d8c0f394fdece09cf5cc240887cb0bb5af
2017-12-18trxcon/scheduler: preprocess UL bursts before sendingVadim Yanitskiy1-0/+3
Having a possibility to preprocess UL burst before sending to transceiver is required for the further ciphering support integration and probably some other tasks. Change-Id: Ia6eead5d4f51d7c0bf277b9d5ebb0a74676df567
2017-12-18trxcon/scheduler: move prim management outside lchan handlersVadim Yanitskiy1-1/+6
Previously, each lchan handler used to obtain and delete primitives from a timeslot's tranmit queue itself. This approach entails many potential problems and bugs: - The lchan handlers shall not do that by definition, they should encode and decode frames according to GSM 05.03. - In some cases (e.g. TCH), a single transmit queue may contain primitives of different types (e.g. TCH, FACCH and SACCH). At the same time, the lchan handlers don't care and don't even know about each other. So, this could cause an unexpected behaviour in some cases. This change separates all primitive management routines, providing a new API for obtaining and dropping them. "Write programs that do one thing and do it well." Change-Id: I29503ece51903784bc53541015285234471c8d15
2017-12-18trxcon/scheduler: separate primitive management codeVadim Yanitskiy1-3/+5
It's good to write, keep and make the source code as much modular as possible. So, Tte primitive management code was separated to the 'sched_prim.c' and going to be extended in the near future. Change-Id: Ifec8c9e4f2c95c72b00772688bcb5dc9c11d6de7
2017-12-16host/trxcon/scheduler: inform L2&3 about decoding errorsVadim Yanitskiy1-1/+3
Previously, we used to drop a frame if decoding wasn't successful. This way, the higher layers didn't even know about that, so the local counters and Measurement Reports were incomplete. This change makes scheduler to forward L2 frames in any case, setting the num_biterr for each of them. In case of decoding error, a dummy (payload filled by 0x00) L2 frame will be sent. Change-Id: I31011d8f3ca8b9a12474cd0bc653faed18391033
2017-12-16host/trxcon/scheduler: add initial TCH/F channel supportVadim Yanitskiy1-0/+6
This change implements basic TCH/F lchan handlers for both data reception and transmission. Only FACCH (signaling), FR and EFR payloads are supported at the moment. Change-Id: If6b0eaede2b484484d2a824e7219ff04483266a1
2017-12-16host/trxcon/scheduler: clean up the trx_lchan_stateVadim Yanitskiy1-52/+40
There were some BTS specific variables, which are meaningless. This change cleans them up, and also groups some measurement, encryption, and AMR specific variables into sub-structures. Change-Id: Ie753a7e3e7fa2b433d8319b3a05b85b8583d7be2
2017-11-23host/trxcon/scheduler: process frames in advanceVadim Yanitskiy1-1/+1
In order to get the transceiver more time to process bursts, the L1 scheduler should process the frames and send the bursts in advance (a few frames before), like OsmoBTS does. By default, the advance value is 20 frames, but this can be adjusted using a new command line option of trxcon '-f'. Change-Id: Ic258a169f3554f931d6277e18ca060d029b77f32
2017-11-19host/trxcon/scheduler: share common declarations of lchan handlersVadim Yanitskiy1-0/+9
The training sequences, data / traffic indication and confirmation helpers are used by several lchan handlers, like xCCC and TCH. It would be better to have them all declared within a shared header. Change-Id: I71980f09a0c0e023370e1a651afc24fff2491552
2017-11-19host/trxcon/l1ctl.c: share primitive management codeVadim Yanitskiy1-0/+8
This change introduces shared primitive management functions, exposed from the l1ctl_rx_data_req() implementation: - sched_trx_init_prim() - allocates memory for a new primitive and its payload. Initializes primitive's header, setting the logical channel type and the payload length. After initialization, the talloc context of a primitive is a trx instance, which passed as the first argument. - sched_trx_push_prim() - decodes the timeslot index from chan_nr and pushes a primitive to its transimt queue. The talloc context of primitive is changed to the parent trx_ts instance after queuing. Both functions will be used for handling both L1CTL_TRAFFIC_REQ and L1CTL_RACH_REQ. Change-Id: I8169a1ef4ef54d91b50f3e213e4842f54af8b499
2017-11-19host/trxcon/scheduler: get rid of useless nbits argumentVadim Yanitskiy1-2/+2
Change-Id: I8508676e2cb347396c6ca6b394f13113f3e63084
2017-11-19host/trxcon/scheduler: pass trx_lchan_state to lchan handlersVadim Yanitskiy1-7/+6
It's better to pass a trx_lchan_state instance directly from caller to lchan handler instead of passing trx_lchan_type. This way a handler wouldn't need to find lchan itself. Change-Id: I47a40542b03ab31da12b0abb1c263c83662ff018
2017-11-19host/trxcon/scheduler: fix chan_nr parsingVadim Yanitskiy1-1/+4
Previously, the chan_nr, received from L2, was parsed in a wrong way, so in some cases only one logical channel was activated or some messages (such as Measurement Requests) were sent on incorrect channel (e.g. on SDCCH instead of SACCH). This change reimplements the sched_trx_chan_nr2lchan_type(), and introduces a new function sched_trx_set_lchans(), whics will parse chan_nr and (de)activate required channels. Change-Id: I480311c65ef93bbc1644ec708dd2a68fd33091e0
2017-11-19host/trxcon/scheduler: use 'tn' instead of 'ts_num'Vadim Yanitskiy1-6/+6
The new timeslot index designation is more generic for Osmocom projects, so let's use one. Change-Id: I8c0118aad439816148490e57938d7e32b6e20877
2017-11-19host/trxcon/scheduler: git rid of sched_trx_find_ts()Vadim Yanitskiy1-1/+0
After simplification of timeslot management API this function does not make sense. Change-Id: I2fc0c68d784c8f01e1452bc46f8e1eaac2917656
2017-11-19host/trxcon/scheduler: simplify timeslot managementVadim Yanitskiy1-2/+0
As we know the count of timeslots per GSM TDMA frame, it would be better to have an array of pointers to trx_ts instances instead of linux list, which is more usable for lists with unknown length. Change-Id: I9510a5cddde22950ceb8422e0990d59f05ed4d60
2017-11-19host/trxcon/scheduler: optionally reset clock counterVadim Yanitskiy1-1/+1
Change-Id: I4565620fc0c5f64133c2674d2c972fc34245cf32
2017-11-19host/trxcon/scheduler: implement xCCH TX capabilityVadim Yanitskiy1-0/+2
Change-Id: I4da4816dcecc55eb9b4d2d6c631967026a5e4f68