Introduce init() APIs for PDCH and TRX objects

This will make it easier to keep object specific initializations in
expected place.

Change-Id: Idf1dbdf8bc0b1e16d86eeeffb1193fdf3a57d6ef
This commit is contained in:
Pau Espin 2021-03-08 14:15:54 +01:00 committed by laforge
parent 30617115ba
commit 702ebee751
4 changed files with 23 additions and 21 deletions

View File

@ -271,18 +271,8 @@ struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu, uint8_t bts_nr)
INIT_LLIST_HEAD(&bts->dl_tbfs);
/* initialize back pointers */
for (size_t trx_no = 0; trx_no < ARRAY_SIZE(bts->trx); ++trx_no) {
struct gprs_rlcmac_trx *trx = &bts->trx[trx_no];
trx->trx_no = trx_no;
trx->bts = bts;
for (size_t ts_no = 0; ts_no < ARRAY_SIZE(trx->pdch); ++ts_no) {
struct gprs_rlcmac_pdch *pdch = &trx->pdch[ts_no];
pdch->init_ptcch_msg();
pdch->ts_no = ts_no;
pdch->trx = trx;
}
}
for (size_t trx_no = 0; trx_no < ARRAY_SIZE(bts->trx); ++trx_no)
bts_trx_init(&bts->trx[trx_no], bts, trx_no);
/* The static allocator might have already registered the counter group.
If this happens and we still called explicitly (in tests/ for example)
@ -1161,6 +1151,15 @@ void bts_update_tbf_ta(struct gprs_rlcmac_bts *bts, const char *p, uint32_t fn,
}
}
void bts_trx_init(struct gprs_rlcmac_trx *trx, struct gprs_rlcmac_bts *bts, uint8_t trx_no)
{
trx->trx_no = trx_no;
trx->bts = bts;
for (size_t ts_no = 0; ts_no < ARRAY_SIZE(trx->pdch); ts_no++)
pdch_init(&trx->pdch[ts_no], trx, ts_no);
}
void bts_trx_reserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_direction dir,
uint8_t slots)
{

View File

@ -65,6 +65,7 @@ struct gprs_rlcmac_trx {
#ifdef __cplusplus
extern "C" {
#endif
void bts_trx_init(struct gprs_rlcmac_trx *trx, struct gprs_rlcmac_bts *bts, uint8_t trx_no);
void bts_trx_reserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_direction dir, uint8_t slots);
void bts_trx_unreserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_direction dir, uint8_t slots);
void bts_trx_free_all_tbf(struct gprs_rlcmac_trx *trx);

View File

@ -131,6 +131,16 @@ static inline void sched_ul_ass_or_rej(struct gprs_rlcmac_bts *bts, struct gprs_
}
}
void pdch_init(struct gprs_rlcmac_pdch *pdch, struct gprs_rlcmac_trx *trx, uint8_t ts_nr)
{
pdch->ts_no = ts_nr;
pdch->trx = trx;
/* Initialize the PTCCH/D message (Packet Timing Advance Control Channel) */
memset(pdch->ptcch_msg, PTCCH_TAI_FREE, PTCCH_TAI_NUM);
memset(pdch->ptcch_msg + PTCCH_TAI_NUM, PTCCH_PADDING, 7);
}
void gprs_rlcmac_pdch::enable()
{
/* TODO: Check if there are still allocated resources.. */
@ -1039,13 +1049,6 @@ uint8_t gprs_rlcmac_pdch::trx_no() const
return trx->trx_no;
}
/* PTCCH (Packet Timing Advance Control Channel) */
void gprs_rlcmac_pdch::init_ptcch_msg(void)
{
memset(ptcch_msg, PTCCH_TAI_FREE, PTCCH_TAI_NUM);
memset(ptcch_msg + PTCCH_TAI_NUM, PTCCH_PADDING, 7);
}
uint8_t gprs_rlcmac_pdch::reserve_tai(uint8_t ta)
{
uint8_t tai;

View File

@ -105,8 +105,6 @@ struct gprs_rlcmac_pdch {
/* PTCCH (Packet Timing Advance Control Channel) */
uint8_t ptcch_msg[GSM_MACBLOCK_LEN]; /* 'ready to use' PTCCH/D message */
#ifdef __cplusplus
/* Initialize the PTCCH/D message */
void init_ptcch_msg(void);
/* 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 */
@ -190,6 +188,7 @@ inline bool gprs_rlcmac_pdch::is_enabled() const
#ifdef __cplusplus
extern "C" {
#endif
void pdch_init(struct gprs_rlcmac_pdch *pdch, struct gprs_rlcmac_trx *trx, uint8_t ts_nr);
void pdch_free_all_tbf(struct gprs_rlcmac_pdch *pdch);
void pdch_disable(struct gprs_rlcmac_pdch *pdch);
#ifdef __cplusplus