2018-02-19 16:17:28 +00:00
|
|
|
/* pdch.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
|
|
|
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
|
|
|
* Copyright (C) 2018 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-02-25 16:49:30 +00:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
2018-02-19 16:17:28 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#include <osmocom/core/linuxlist.h>
|
2020-03-26 14:14:01 +00:00
|
|
|
#include "gsm_rlcmac.h"
|
2020-05-18 09:35:35 +00:00
|
|
|
#include "coding_scheme.h"
|
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-08 13:57:58 +00:00
|
|
|
#include "pdch_ul_controller.h"
|
2018-02-19 16:17:28 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <tbf.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-10-05 14:57:14 +00:00
|
|
|
/* PTCCH (Packet Timing Advance Control Channel) */
|
|
|
|
#define PTCCH_TAI_FREE 0x7f /*!< Special value for unused TA Indexes */
|
|
|
|
#define PTCCH_TAI_NUM 16 /*!< Number of PTCCH/U slots and thus TA Indexes */
|
|
|
|
#define PTCCH_PADDING 0x2b /*!< PTCCH/D messages need to be padded to 23 octets */
|
|
|
|
|
2020-11-16 16:35:10 +00:00
|
|
|
#define USF_UNUSED 0x07
|
|
|
|
/* 3GPP TS 05.08 version 8.23.0 "10.2.2 BTS output power". 360 ms */
|
|
|
|
#define MS_RESYNC_NUM_FRAMES 18
|
|
|
|
|
2018-02-19 16:17:28 +00:00
|
|
|
/*
|
|
|
|
* PDCH instance
|
|
|
|
*/
|
|
|
|
struct gprs_rlcmac_pdch {
|
|
|
|
#ifdef __cplusplus
|
|
|
|
struct gprs_rlcmac_paging *dequeue_paging();
|
|
|
|
struct msgb *packet_paging_request();
|
|
|
|
|
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-21 14:21:23 +00:00
|
|
|
bool add_paging(uint8_t chan_needed, const struct osmo_mobile_identity *mi);
|
2018-02-19 16:17:28 +00:00
|
|
|
|
|
|
|
bool is_enabled() const;
|
|
|
|
|
|
|
|
void enable();
|
|
|
|
void disable();
|
|
|
|
|
|
|
|
/* dispatching of messages */
|
|
|
|
int rcv_block(uint8_t *data, uint8_t len, uint32_t fn,
|
|
|
|
struct pcu_l1_meas *meas);
|
|
|
|
int rcv_block_gprs(uint8_t *data, uint8_t data_len, uint32_t fn,
|
2020-05-18 09:35:35 +00:00
|
|
|
struct pcu_l1_meas *meas, enum CodingScheme cs);
|
2018-02-19 16:17:28 +00:00
|
|
|
int rcv_data_block(uint8_t *data, uint8_t data_len, uint32_t fn,
|
2020-05-18 09:35:35 +00:00
|
|
|
struct pcu_l1_meas *meas, enum CodingScheme cs);
|
2018-02-19 16:17:28 +00:00
|
|
|
|
2021-01-14 15:48:38 +00:00
|
|
|
struct gprs_rlcmac_bts *bts() const;
|
2018-02-19 16:17:28 +00:00
|
|
|
uint8_t trx_no() const;
|
|
|
|
|
|
|
|
struct gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi);
|
|
|
|
struct gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi);
|
|
|
|
|
|
|
|
void attach_tbf(gprs_rlcmac_tbf *tbf);
|
|
|
|
void detach_tbf(gprs_rlcmac_tbf *tbf);
|
|
|
|
|
|
|
|
unsigned num_tbfs(enum gprs_rlcmac_tbf_direction dir) const;
|
|
|
|
|
|
|
|
void reserve(enum gprs_rlcmac_tbf_direction dir);
|
|
|
|
void unreserve(enum gprs_rlcmac_tbf_direction dir);
|
|
|
|
unsigned num_reserved(enum gprs_rlcmac_tbf_direction dir) const;
|
|
|
|
|
|
|
|
uint8_t assigned_usf() const;
|
|
|
|
uint32_t assigned_tfi(enum gprs_rlcmac_tbf_direction dir) const;
|
2020-11-16 16:35:10 +00:00
|
|
|
|
|
|
|
bool has_gprs_only_tbf_attached() const;
|
2018-02-19 16:17:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
uint8_t m_is_enabled; /* TS is enabled */
|
|
|
|
uint8_t tsc; /* TSC of this slot */
|
|
|
|
uint8_t next_ul_tfi; /* next uplink TBF/TFI to schedule (0..31) */
|
|
|
|
uint8_t next_dl_tfi; /* next downlink TBF/TFI to schedule (0..31) */
|
|
|
|
uint8_t next_ctrl_prio; /* next kind of ctrl message to schedule */
|
|
|
|
struct llist_head paging_list; /* list of paging messages */
|
|
|
|
uint32_t last_rts_fn; /* store last frame number of RTS */
|
2020-11-16 16:35:10 +00:00
|
|
|
/* store number of contiguous frame number where a DL block was transmitted which can be decoded by GPRS-only MS */
|
|
|
|
uint32_t fn_without_cs14;
|
2018-02-19 16:17:28 +00:00
|
|
|
|
2019-10-05 14:57:14 +00:00
|
|
|
/* PTCCH (Packet Timing Advance Control Channel) */
|
|
|
|
uint8_t ptcch_msg[GSM_MACBLOCK_LEN]; /* 'ready to use' PTCCH/D message */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
/* Obtain an unused TA Index for a TBF */
|
|
|
|
uint8_t reserve_tai(uint8_t ta);
|
|
|
|
/* Mark a given TA Index as free, so it can be used again */
|
|
|
|
void release_tai(uint8_t tai);
|
|
|
|
/* Update the actual Timing Advance value for a given TA Index */
|
|
|
|
void update_ta(uint8_t tai, uint8_t ta);
|
|
|
|
#endif
|
|
|
|
|
2020-07-18 17:47:20 +00:00
|
|
|
/* Frequency hopping parameters */
|
|
|
|
struct {
|
|
|
|
bool enabled;
|
|
|
|
/* 3GPP TS 45.002 HSN / MAIO (6 bit each) */
|
|
|
|
uint8_t hsn;
|
|
|
|
uint8_t maio;
|
|
|
|
/* 3GPP TS 44.018, 10.5.2.21 "Mobile Allocation" */
|
|
|
|
uint8_t ma_oct_len;
|
|
|
|
uint8_t ma_bit_len;
|
|
|
|
uint8_t ma[8];
|
|
|
|
} fh;
|
|
|
|
|
2018-02-19 16:17:28 +00:00
|
|
|
/* back pointers */
|
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
uint8_t ts_no;
|
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-08 13:57:58 +00:00
|
|
|
struct pdch_ulc *ulc;
|
2018-02-19 16:17:28 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
private:
|
2019-09-25 11:46:14 +00:00
|
|
|
int rcv_control_block(const uint8_t *data, uint8_t data_len, uint32_t fn,
|
2020-05-18 09:35:35 +00:00
|
|
|
struct pcu_l1_meas *meas, enum CodingScheme cs);
|
2018-02-19 16:17:28 +00:00
|
|
|
|
|
|
|
void rcv_control_ack(Packet_Control_Acknowledgement_t *, uint32_t fn);
|
2019-09-25 11:46:14 +00:00
|
|
|
void rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *, uint32_t fn, struct pcu_l1_meas *meas);
|
|
|
|
void rcv_control_egprs_dl_ack_nack(EGPRS_PD_AckNack_t *, uint32_t fn, struct pcu_l1_meas *meas);
|
|
|
|
void rcv_resource_request(Packet_Resource_Request_t *t, uint32_t fn, struct pcu_l1_meas *meas);
|
2018-02-19 16:17:28 +00:00
|
|
|
void rcv_measurement_report(Packet_Measurement_Report_t *t, uint32_t fn);
|
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-21 17:46:13 +00:00
|
|
|
void rcv_cell_change_notification(Packet_Cell_Change_Notification_t *, uint32_t fn, struct pcu_l1_meas *meas);
|
2018-02-19 16:17:28 +00:00
|
|
|
gprs_rlcmac_tbf *tbf_from_list_by_tfi(
|
|
|
|
LListHead<gprs_rlcmac_tbf> *tbf_list, uint8_t tfi,
|
|
|
|
enum gprs_rlcmac_tbf_direction dir);
|
|
|
|
gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi,
|
|
|
|
enum gprs_rlcmac_tbf_direction dir);
|
2021-06-30 14:03:06 +00:00
|
|
|
|
|
|
|
void free_resources();
|
2018-02-19 16:17:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
uint8_t m_num_tbfs[2];
|
|
|
|
uint8_t m_num_reserved[2];
|
|
|
|
uint8_t m_assigned_usf; /* bit set */
|
|
|
|
uint32_t m_assigned_tfi[2]; /* bit set */
|
|
|
|
struct gprs_rlcmac_tbf *m_tbfs[2][32];
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const
|
|
|
|
{
|
|
|
|
return m_num_tbfs[dir];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline unsigned gprs_rlcmac_pdch::num_reserved(
|
|
|
|
enum gprs_rlcmac_tbf_direction dir) const
|
|
|
|
{
|
|
|
|
return gprs_rlcmac_pdch::m_num_reserved[dir];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint8_t gprs_rlcmac_pdch::assigned_usf() const
|
|
|
|
{
|
|
|
|
return m_assigned_usf;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint32_t gprs_rlcmac_pdch::assigned_tfi(
|
|
|
|
enum gprs_rlcmac_tbf_direction dir) const
|
|
|
|
{
|
|
|
|
return m_assigned_tfi[dir];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool gprs_rlcmac_pdch::is_enabled() const
|
|
|
|
{
|
|
|
|
return m_is_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __cplusplus */
|
2021-01-18 16:53:29 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2021-03-08 13:15:54 +00:00
|
|
|
void pdch_init(struct gprs_rlcmac_pdch *pdch, struct gprs_rlcmac_trx *trx, uint8_t ts_nr);
|
2021-01-18 16:53:29 +00:00
|
|
|
void pdch_free_all_tbf(struct gprs_rlcmac_pdch *pdch);
|
2021-01-18 16:54:30 +00:00
|
|
|
void pdch_disable(struct gprs_rlcmac_pdch *pdch);
|
2021-06-30 14:03:06 +00:00
|
|
|
bool pdch_is_enabled(const struct gprs_rlcmac_pdch *pdch);
|
2021-01-18 16:53:29 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
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-08 13:57:58 +00:00
|
|
|
#endif
|
2021-02-25 16:49:30 +00:00
|
|
|
|
|
|
|
#define LOGPDCH(pdch, category, level, fmt, args...) \
|
|
|
|
LOGP(category, level, "PDCH(bts=%" PRIu8 ",trx=%" PRIu8 ",ts=%" PRIu8 ") " fmt, \
|
|
|
|
(pdch)->trx->bts->nr, (pdch)->trx->trx_no, (pdch)->ts_no, \
|
|
|
|
## args)
|