Allow multiple bts objects in PCU

This patch doesn't really tests whether osmo-pcu can work on a multi-bts
environment, but it prepares the data structures to be able to do so at
any later point in time.

Change-Id: I6b10913f46c19d438c4e250a436a7446694b725a
This commit is contained in:
Pau Espin 2021-01-18 17:14:14 +01:00
parent e91c4c72b1
commit d1049dc8cc
27 changed files with 355 additions and 263 deletions

View File

@ -82,3 +82,4 @@ Current limitations
* No half-duplex class support (only semi-duplex)
* No TA loop
* No power loop
* Multi-BTS support not tested

View File

@ -221,10 +221,12 @@ static int bts_talloc_destructor(struct gprs_rlcmac_bts* bts)
msgb_free(bts->app_info);
bts->app_info = NULL;
}
llist_del(&bts->list);
return 0;
}
struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu)
struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu, uint8_t bts_nr)
{
struct gprs_rlcmac_bts* bts;
bts = talloc_zero(pcu, struct gprs_rlcmac_bts);
@ -233,6 +235,7 @@ struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu)
talloc_set_destructor(bts, bts_talloc_destructor);
bts->pcu = pcu;
bts->nr = bts_nr;
bts->pollController = new PollController(*bts);
bts->sba = new SBAController(*bts);
@ -286,6 +289,8 @@ struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu)
bts->statg = osmo_stat_item_group_alloc(tall_pcu_ctx, &bts_statg_desc, 0);
OSMO_ASSERT(bts->statg);
llist_add_tail(&bts->list, &pcu->bts_list);
return bts;
}
@ -916,7 +921,7 @@ send_imm_ass_rej:
}
if (plen >= 0)
pcu_l1if_tx_agch(bv, plen);
pcu_l1if_tx_agch(bts, bv, plen);
else
rc = plen;
@ -995,7 +1000,7 @@ void bts_snd_dl_ass(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bo
GSM_L1_BURST_TYPE_ACCESS_0);
if (plen >= 0) {
bts_do_rate_ctr_inc(bts, CTR_IMMEDIATE_ASSIGN_DL_TBF);
pcu_l1if_tx_pch(immediate_assignment, plen, pgroup);
pcu_l1if_tx_pch(bts, immediate_assignment, plen, pgroup);
}
bitvec_free(immediate_assignment);
@ -1125,10 +1130,11 @@ void set_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, uint8_t ta)
}
}
void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, int8_t ta, bool is_rach)
void bts_update_tbf_ta(struct gprs_rlcmac_bts *bts, const char *p, uint32_t fn,
uint8_t trx_no, uint8_t ts, int8_t ta, bool is_rach)
{
struct gprs_rlcmac_ul_tbf *tbf =
bts_ul_tbf_by_poll_fn(the_pcu->bts, fn, trx_no, ts);
bts_ul_tbf_by_poll_fn(bts, fn, trx_no, ts);
if (!tbf)
LOGP(DL1IF, LOGL_DEBUG, "[%s] update TA = %u ignored due to "
"unknown UL TBF on TRX = %d, TS = %d, FN = %d\n",

View File

@ -67,7 +67,8 @@ void bts_trx_reserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_dir
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);
void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, int8_t ta, bool is_rach);
void bts_update_tbf_ta(struct gprs_rlcmac_bts *bts, const char *p, uint32_t fn,
uint8_t trx_no, uint8_t ts, int8_t ta, bool is_rach);
#ifdef __cplusplus
}
#endif
@ -194,6 +195,8 @@ struct pcu_l1_meas;
* on my TRXs.
*/
struct gprs_rlcmac_bts {
uint8_t nr; /* bts_nr */
struct llist_head list; /* queued in pcu->bts_list */
bool active;
uint8_t bsic;
uint8_t cs_mask; /* Allowed CS mask from BTS */
@ -317,7 +320,7 @@ static inline void bts_stat_item_add(struct gprs_rlcmac_bts *bts, unsigned int s
osmo_stat_item_set(bts->statg->items[stat_id], val + inc);
}
struct gprs_rlcmac_bts *bts_alloc(struct gprs_pcu *pcu);
struct gprs_rlcmac_bts *bts_alloc(struct gprs_pcu *pcu, uint8_t bts_nr);
void bts_recalc_initial_cs(struct gprs_rlcmac_bts *bts);
void bts_recalc_initial_mcs(struct gprs_rlcmac_bts *bts);

View File

@ -204,18 +204,24 @@ static unsigned int get_paging_mi(struct osmo_mobile_identity *mi, const struct
static int gprs_bssgp_pcu_rx_paging_cs(struct msgb *msg, const struct tlv_parsed *tp)
{
struct osmo_mobile_identity mi;
struct gprs_rlcmac_bts *bts;
int rc;
if ((rc = get_paging_mi(&mi, tp)) > 0)
return bssgp_tx_status((enum gprs_bssgp_cause) rc, NULL, msg);
return bts_add_paging(the_pcu->bts, tlvp_val8(tp, BSSGP_IE_CHAN_NEEDED, 0), &mi);
/* FIXME: look if MS is attached a specific BTS and then only page on that one? */
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
bts_add_paging(bts, tlvp_val8(tp, BSSGP_IE_CHAN_NEEDED, 0), &mi);
}
return 0;
}
static int gprs_bssgp_pcu_rx_paging_ps(struct msgb *msg, const struct tlv_parsed *tp)
{
struct osmo_mobile_identity mi_imsi;
struct osmo_mobile_identity paging_mi;
struct gprs_rlcmac_bts *bts;
uint16_t pgroup;
int rc;
@ -238,7 +244,11 @@ static int gprs_bssgp_pcu_rx_paging_ps(struct msgb *msg, const struct tlv_parsed
if ((rc = get_paging_mi(&paging_mi, tp)) > 0)
return bssgp_tx_status((enum gprs_bssgp_cause) rc, NULL, msg);
return gprs_rlcmac_paging_request(&paging_mi, pgroup);
/* FIXME: look if MS is attached a specific BTS and then only page on that one? */
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
gprs_rlcmac_paging_request(bts, &paging_mi, pgroup);
}
return 0;
}
/* Receive a BSSGP PDU from a BSS on a PTP BVCI */
@ -808,7 +818,13 @@ static int gprs_bssgp_tx_fc_bvc(void)
LOGP(DBSSGP, LOGL_ERROR, "No bctx\n");
return -EIO;
}
bts = the_pcu->bts;
/* FIXME: This calculation needs to be redone to support multiple BTS */
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
if (!bts) {
LOGP(DBSSGP, LOGL_ERROR, "No bts\n");
return -EIO;
}
max_cs_dl = max_coding_scheme_dl(bts);

View File

@ -21,6 +21,7 @@
*/
#include <osmocom/core/utils.h>
#include <osmocom/core/linuxlist.h>
#include "gprs_pcu.h"
#include "bts.h"
@ -100,37 +101,63 @@ struct gprs_pcu *gprs_pcu_alloc(void *ctx)
pcu->T_defs = T_defs_pcu;
osmo_tdefs_reset(pcu->T_defs);
INIT_LLIST_HEAD(&pcu->bts_list);
return pcu;
}
struct gprs_rlcmac_bts *gprs_pcu_get_bts_by_nr(struct gprs_pcu *pcu, uint8_t bts_nr)
{
struct gprs_rlcmac_bts *pos;
llist_for_each_entry(pos, &pcu->bts_list, list) {
if (pos->nr == bts_nr)
return pos;
}
return NULL;
}
void gprs_pcu_set_initial_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul)
{
struct gprs_rlcmac_bts *bts;
the_pcu->vty.initial_cs_dl = cs_dl;
the_pcu->vty.initial_cs_ul = cs_ul;
/*TODO: once we support multiple bts, foreach(bts) apply */
bts_recalc_initial_cs(pcu->bts);
llist_for_each_entry(bts, &pcu->bts_list, list) {
bts_recalc_initial_cs(bts);
}
}
void gprs_pcu_set_initial_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul)
{
struct gprs_rlcmac_bts *bts;
the_pcu->vty.initial_mcs_dl = mcs_dl;
the_pcu->vty.initial_mcs_ul = mcs_ul;
/*TODO: once we support multiple bts, foreach(bts) apply */
bts_recalc_initial_mcs(pcu->bts);
llist_for_each_entry(bts, &pcu->bts_list, list) {
bts_recalc_initial_mcs(bts);
}
}
void gprs_pcu_set_max_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul)
{
struct gprs_rlcmac_bts *bts;
the_pcu->vty.max_cs_dl = cs_dl;
the_pcu->vty.max_cs_ul = cs_ul;
/*TODO: once we support multiple bts, foreach(bts) apply */
bts_recalc_max_cs(pcu->bts);
llist_for_each_entry(bts, &pcu->bts_list, list) {
bts_recalc_max_cs(bts);
}
}
void gprs_pcu_set_max_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul)
{
struct gprs_rlcmac_bts *bts;
the_pcu->vty.max_mcs_dl = mcs_dl;
the_pcu->vty.max_mcs_ul = mcs_ul;
/* TODO: once we support multiple bts, foreach(bts) apply */
bts_recalc_max_mcs(pcu->bts);
llist_for_each_entry(bts, &pcu->bts_list, list) {
bts_recalc_max_mcs(bts);
}
}

View File

@ -107,7 +107,7 @@ struct gprs_pcu {
struct gsmtap_inst *gsmtap;
uint32_t gsmtap_categ_mask;
struct gprs_rlcmac_bts *bts;
struct llist_head bts_list; /* list of gprs_rlcmac_tbf */
struct gprs_ns2_inst *nsi;
@ -123,6 +123,8 @@ extern struct gprs_pcu *the_pcu;
struct gprs_pcu *gprs_pcu_alloc(void *ctx);
struct gprs_rlcmac_bts *gprs_pcu_get_bts_by_nr(struct gprs_pcu *pcu, uint8_t bts_nr);
void gprs_pcu_set_initial_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul);
void gprs_pcu_set_initial_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul);
void gprs_pcu_set_max_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul);

View File

@ -32,7 +32,8 @@ extern "C" {
extern void *tall_pcu_ctx;
int gprs_rlcmac_paging_request(const struct osmo_mobile_identity *mi, uint16_t pgroup)
int gprs_rlcmac_paging_request(struct gprs_rlcmac_bts *bts, const struct osmo_mobile_identity *mi,
uint16_t pgroup)
{
if (log_check_level(DRLCMAC, LOGL_NOTICE)) {
char str[64];
@ -46,7 +47,7 @@ int gprs_rlcmac_paging_request(const struct osmo_mobile_identity *mi, uint16_t p
LOGP(DRLCMAC, LOGL_ERROR, "TX: [PCU -> BTS] Failed to encode Paging Request\n");
return -1;
}
pcu_l1if_tx_pch(paging_request, plen, pgroup);
pcu_l1if_tx_pch(bts, paging_request, plen, pgroup);
bitvec_free(paging_request);
return 0;

View File

@ -113,7 +113,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gpr
int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
int8_t use_trx);
int gprs_rlcmac_paging_request(const struct osmo_mobile_identity *mi, uint16_t pgroup);
int gprs_rlcmac_paging_request(struct gprs_rlcmac_bts *bts, const struct osmo_mobile_identity *mi, uint16_t pgroup);
int gprs_alloc_max_dl_slots_per_ms(const struct gprs_rlcmac_bts *bts, uint8_t ms_class);
#ifdef __cplusplus
}

View File

@ -136,7 +136,7 @@ struct msgb *sched_app_info(struct gprs_rlcmac_tbf *tbf) {
if (!tbf || !tbf->ms()->app_info_pending)
return NULL;
bts = the_pcu->bts;
bts = tbf->bts;
if (bts->app_info) {
LOGP(DRLCMACSCHED, LOGL_DEBUG, "Sending Packet Application Information message\n");
@ -506,7 +506,7 @@ int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts,
tap_n_acc(msg, bts, trx, ts, fn, gsmtap_cat);
/* send PDTCH/PACCH to L1 */
pcu_l1if_tx_pdtch(msg, trx, ts, bts->trx[trx].arfcn, fn, block_nr);
pcu_l1if_tx_pdtch(msg, bts, trx, ts, bts->trx[trx].arfcn, fn, block_nr);
return 0;
}

View File

@ -148,6 +148,7 @@ static int handle_ph_readytosend_ind(struct lc15l1_hdl *fl1h,
GsmL1_PhReadyToSendInd_t *rts_ind)
{
struct gsm_time g_time;
struct gprs_rlcmac_bts *bts;
int rc = 0;
gsm_fn2gsmtime(&g_time, rts_ind->u32Fn);
@ -156,14 +157,17 @@ static int handle_ph_readytosend_ind(struct lc15l1_hdl *fl1h,
g_time.t1, g_time.t2, g_time.t3,
get_value_string(lc15bts_l1sapi_names, rts_ind->sapi));
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
switch (rts_ind->sapi) {
case GsmL1_Sapi_Pdtch:
case GsmL1_Sapi_Pacch:
rc = pcu_rx_rts_req_pdtch(fl1h->trx_no, rts_ind->u8Tn,
rc = pcu_rx_rts_req_pdtch(bts, fl1h->trx_no, rts_ind->u8Tn,
rts_ind->u32Fn, rts_ind->u8BlockNbr);
break;
case GsmL1_Sapi_Ptcch:
rc = pcu_rx_rts_req_ptcch(fl1h->trx_no, rts_ind->u8Tn,
rc = pcu_rx_rts_req_ptcch(bts, fl1h->trx_no, rts_ind->u8Tn,
rts_ind->u32Fn, rts_ind->u8BlockNbr);
break;
default:
@ -189,6 +193,7 @@ static int handle_ph_data_ind(struct lc15l1_hdl *fl1h,
GsmL1_PhDataInd_t *data_ind, struct msgb *l1p_msg)
{
int rc = 0;
struct gprs_rlcmac_bts *bts;
struct pcu_l1_meas meas = {0};
DEBUGP(DL1IF, "Rx PH-DATA.ind %s (hL2 %08x): %s\n",
@ -205,8 +210,10 @@ static int handle_ph_data_ind(struct lc15l1_hdl *fl1h,
if (data_ind->msgUnitParam.u8Size == 0)
return -1;
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
get_meas(&meas, &data_ind->measParam);
bts_update_tbf_ta("PH-DATA", data_ind->u32Fn, fl1h->trx_no,
bts_update_tbf_ta(bts, "PH-DATA", data_ind->u32Fn, fl1h->trx_no,
data_ind->u8Tn, sign_qta2ta(meas.bto), false);
switch (data_ind->sapi) {
@ -217,7 +224,7 @@ static int handle_ph_data_ind(struct lc15l1_hdl *fl1h,
!= GsmL1_PdtchPlType_Full)
break;
/* PDTCH / PACCH frame handling */
rc = pcu_rx_data_ind_pdtch(fl1h->trx_no, data_ind->u8Tn,
rc = pcu_rx_data_ind_pdtch(bts, fl1h->trx_no, data_ind->u8Tn,
data_ind->msgUnitParam.u8Buffer + 1,
data_ind->msgUnitParam.u8Size - 1,
data_ind->u32Fn,
@ -243,19 +250,22 @@ static int handle_ph_data_ind(struct lc15l1_hdl *fl1h,
static int handle_ph_ra_ind(struct lc15l1_hdl *fl1h, GsmL1_PhRaInd_t *ra_ind)
{
struct gprs_rlcmac_bts *bts;
if (ra_ind->measParam.fLinkQuality < MIN_QUAL_RACH)
return 0;
DEBUGP(DL1IF, "Rx PH-RA.ind");
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
switch (ra_ind->sapi) {
case GsmL1_Sapi_Pdtch:
case GsmL1_Sapi_Prach:
bts_update_tbf_ta("PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn,
bts_update_tbf_ta(bts, "PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn,
qta2ta(ra_ind->measParam.i16BurstTiming), true);
break;
case GsmL1_Sapi_Ptcch:
pcu_rx_rach_ind_ptcch(fl1h->trx_no, ra_ind->u8Tn, ra_ind->u32Fn,
pcu_rx_rach_ind_ptcch(bts, fl1h->trx_no, ra_ind->u8Tn, ra_ind->u32Fn,
ra_ind->measParam.i16BurstTiming);
break;
default:
@ -387,4 +397,3 @@ int l1if_close_pdch(void *obj)
talloc_free(fl1h);
return 0;
}

View File

@ -149,6 +149,7 @@ static int handle_ph_readytosend_ind(struct oc2gl1_hdl *fl1h,
GsmL1_PhReadyToSendInd_t *rts_ind)
{
struct gsm_time g_time;
struct gprs_rlcmac_bts *bts;
int rc = 0;
gsm_fn2gsmtime(&g_time, rts_ind->u32Fn);
@ -157,14 +158,16 @@ static int handle_ph_readytosend_ind(struct oc2gl1_hdl *fl1h,
g_time.t1, g_time.t2, g_time.t3,
get_value_string(oc2gbts_l1sapi_names, rts_ind->sapi));
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
switch (rts_ind->sapi) {
case GsmL1_Sapi_Pdtch:
case GsmL1_Sapi_Pacch:
rc = pcu_rx_rts_req_pdtch(fl1h->trx_no, rts_ind->u8Tn,
rc = pcu_rx_rts_req_pdtch(bts, fl1h->trx_no, rts_ind->u8Tn,
rts_ind->u32Fn, rts_ind->u8BlockNbr);
break;
case GsmL1_Sapi_Ptcch:
rc = pcu_rx_rts_req_ptcch(fl1h->trx_no, rts_ind->u8Tn,
rc = pcu_rx_rts_req_ptcch(bts, fl1h->trx_no, rts_ind->u8Tn,
rts_ind->u32Fn, rts_ind->u8BlockNbr);
break;
default:
@ -190,6 +193,7 @@ static int handle_ph_data_ind(struct oc2gl1_hdl *fl1h,
GsmL1_PhDataInd_t *data_ind, struct msgb *l1p_msg)
{
int rc = 0;
struct gprs_rlcmac_bts *bts;
struct pcu_l1_meas meas = {0};
DEBUGP(DL1IF, "Rx PH-DATA.ind %s (hL2 %08x): %s\n",
@ -206,13 +210,15 @@ static int handle_ph_data_ind(struct oc2gl1_hdl *fl1h,
if (data_ind->msgUnitParam.u8Size == 0)
return -1;
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
gsmtap_send(fl1h->gsmtap, data_ind->u16Arfcn | GSMTAP_ARFCN_F_UPLINK,
data_ind->u8Tn, GSMTAP_CHANNEL_PACCH, 0,
data_ind->u32Fn, 0, 0, data_ind->msgUnitParam.u8Buffer+1,
data_ind->msgUnitParam.u8Size-1);
get_meas(&meas, &data_ind->measParam);
bts_update_tbf_ta("PH-DATA", data_ind->u32Fn, fl1h->trx_no,
bts_update_tbf_ta(bts, "PH-DATA", data_ind->u32Fn, fl1h->trx_no,
data_ind->u8Tn, sign_qta2ta(meas.bto), false);
switch (data_ind->sapi) {
@ -223,7 +229,7 @@ static int handle_ph_data_ind(struct oc2gl1_hdl *fl1h,
!= GsmL1_PdtchPlType_Full)
break;
/* PDTCH / PACCH frame handling */
pcu_rx_data_ind_pdtch(fl1h->trx_no, data_ind->u8Tn,
pcu_rx_data_ind_pdtch(bts, fl1h->trx_no, data_ind->u8Tn,
data_ind->msgUnitParam.u8Buffer + 1,
data_ind->msgUnitParam.u8Size - 1,
data_ind->u32Fn,
@ -242,19 +248,23 @@ static int handle_ph_data_ind(struct oc2gl1_hdl *fl1h,
static int handle_ph_ra_ind(struct oc2gl1_hdl *fl1h, GsmL1_PhRaInd_t *ra_ind)
{
struct gprs_rlcmac_bts *bts;
if (ra_ind->measParam.fLinkQuality < MIN_QUAL_RACH)
return 0;
LOGP(DL1IF, LOGL_DEBUG, "PH-RA-IND L1 qta=%d\n", ra_ind->measParam.i16BurstTiming);
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
switch (ra_ind->sapi) {
case GsmL1_Sapi_Pdtch:
case GsmL1_Sapi_Prach:
bts_update_tbf_ta("PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn,
bts_update_tbf_ta(bts, "PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn,
qta2ta(ra_ind->measParam.i16BurstTiming), true);
break;
case GsmL1_Sapi_Ptcch:
pcu_rx_rach_ind_ptcch(fl1h->trx_no, ra_ind->u8Tn, ra_ind->u32Fn,
pcu_rx_rach_ind_ptcch(bts, fl1h->trx_no, ra_ind->u8Tn, ra_ind->u32Fn,
ra_ind->measParam.i16BurstTiming);
break;
default:
@ -392,4 +402,3 @@ int l1if_close_pdch(void *obj)
talloc_free(fl1h);
return 0;
}

View File

@ -131,6 +131,7 @@ static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1h,
GsmL1_PhReadyToSendInd_t *rts_ind)
{
struct gsm_time g_time;
struct gprs_rlcmac_bts *bts;
int rc = 0;
gsm_fn2gsmtime(&g_time, rts_ind->u32Fn);
@ -139,14 +140,16 @@ static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1h,
g_time.t1, g_time.t2, g_time.t3,
get_value_string(femtobts_l1sapi_names, rts_ind->sapi));
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
switch (rts_ind->sapi) {
case GsmL1_Sapi_Pdtch:
case GsmL1_Sapi_Pacch:
rc = pcu_rx_rts_req_pdtch(fl1h->trx_no, rts_ind->u8Tn,
rc = pcu_rx_rts_req_pdtch(bts, fl1h->trx_no, rts_ind->u8Tn,
rts_ind->u32Fn, rts_ind->u8BlockNbr);
break;
case GsmL1_Sapi_Ptcch:
rc = pcu_rx_rts_req_ptcch(fl1h->trx_no, rts_ind->u8Tn,
rc = pcu_rx_rts_req_ptcch(bts, fl1h->trx_no, rts_ind->u8Tn,
rts_ind->u32Fn, rts_ind->u8BlockNbr);
break;
default:
@ -172,6 +175,7 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1h,
GsmL1_PhDataInd_t *data_ind, struct msgb *l1p_msg)
{
int rc = 0;
struct gprs_rlcmac_bts *bts;
struct pcu_l1_meas meas = {0};
DEBUGP(DL1IF, "Rx PH-DATA.ind %s (hL2 %08x): %s\n",
@ -180,7 +184,8 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1h,
osmo_hexdump(data_ind->msgUnitParam.u8Buffer,
data_ind->msgUnitParam.u8Size));
pcu_rx_block_time(data_ind->u16Arfcn, data_ind->u32Fn, data_ind->u8Tn);
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
pcu_rx_block_time(bts, data_ind->u16Arfcn, data_ind->u32Fn, data_ind->u8Tn);
/*
* TODO: Add proper bad frame handling here. This could be used
@ -191,7 +196,7 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1h,
return -1;
get_meas(&meas, &data_ind->measParam);
bts_update_tbf_ta("PH-DATA", data_ind->u32Fn, fl1h->trx_no,
bts_update_tbf_ta(bts, "PH-DATA", data_ind->u32Fn, fl1h->trx_no,
data_ind->u8Tn, sign_qta2ta(meas.bto), false);
switch (data_ind->sapi) {
@ -202,7 +207,7 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1h,
!= GsmL1_PdtchPlType_Full)
break;
/* PDTCH / PACCH frame handling */
pcu_rx_data_ind_pdtch(fl1h->trx_no, data_ind->u8Tn,
pcu_rx_data_ind_pdtch(bts, fl1h->trx_no, data_ind->u8Tn,
data_ind->msgUnitParam.u8Buffer + 1,
data_ind->msgUnitParam.u8Size - 1,
data_ind->u32Fn,
@ -230,7 +235,10 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1h,
static int handle_ph_ra_ind(struct femtol1_hdl *fl1h, GsmL1_PhRaInd_t *ra_ind)
{
pcu_rx_ra_time(ra_ind->u16Arfcn, ra_ind->u32Fn, ra_ind->u8Tn);
struct gprs_rlcmac_bts *bts;
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
pcu_rx_ra_time(bts, ra_ind->u16Arfcn, ra_ind->u32Fn, ra_ind->u8Tn);
if (ra_ind->measParam.fLinkQuality < MIN_QUAL_RACH)
return 0;
@ -240,11 +248,11 @@ static int handle_ph_ra_ind(struct femtol1_hdl *fl1h, GsmL1_PhRaInd_t *ra_ind)
switch (ra_ind->sapi) {
case GsmL1_Sapi_Pdtch:
case GsmL1_Sapi_Prach:
bts_update_tbf_ta("PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn,
bts_update_tbf_ta(bts, "PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn,
qta2ta(ra_ind->measParam.i16BurstTiming), true);
break;
case GsmL1_Sapi_Ptcch:
pcu_rx_rach_ind_ptcch(fl1h->trx_no, ra_ind->u8Tn, ra_ind->u32Fn,
pcu_rx_rach_ind_ptcch(bts, fl1h->trx_no, ra_ind->u8Tn, ra_ind->u32Fn,
ra_ind->measParam.i16BurstTiming);
break;
default:
@ -373,4 +381,3 @@ int l1if_close_pdch(void *obj)
talloc_free(fl1h);
return 0;
}

View File

@ -60,13 +60,20 @@ static void pcu_sock_timeout(void *_priv)
static void pcu_tx_txt_retry(void *_priv)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts;
bool retry = llist_empty(&the_pcu->bts_list);
if (bts->active)
return;
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
if (bts->active)
continue;
retry = true;
pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION);
break;
}
pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION);
osmo_timer_schedule(&pcu_sock_state.timer, 5, 0);
/* If no BTS (or not all) yet active, retry */
if (retry)
osmo_timer_schedule(&pcu_sock_state.timer, 5, 0);
}
int pcu_sock_send(struct msgb *msg)
@ -88,7 +95,7 @@ int pcu_sock_send(struct msgb *msg)
static void pcu_sock_close(int lost)
{
struct osmo_fd *bfd = &pcu_sock_state.conn_bfd;
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts;
uint8_t trx, ts;
LOGP(DL1IF, LOGL_NOTICE, "PCU socket has %s connection\n",
@ -104,22 +111,23 @@ static void pcu_sock_close(int lost)
msgb_free(msg);
}
/* disable all slots, kick all TBFs */
for (trx = 0; trx < 8; trx++) {
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
/* disable all slots, kick all TBFs */
for (trx = 0; trx < 8; trx++) {
#ifdef ENABLE_DIRECT_PHY
if (bts->trx[trx].fl1h) {
l1if_close_pdch(bts->trx[trx].fl1h);
bts->trx[trx].fl1h = NULL;
}
if (bts->trx[trx].fl1h) {
l1if_close_pdch(bts->trx[trx].fl1h);
bts->trx[trx].fl1h = NULL;
}
#endif
for (ts = 0; ts < 8; ts++)
pdch_disable(&bts->trx[trx].pdch[ts]);
/* FIXME: NOT ALL RESOURCES are freed in this case... inconsistent with the other code. Share the code with pcu_l1if.c
for the reset. */
bts_trx_free_all_tbf(&bts->trx[trx]);
for (ts = 0; ts < 8; ts++)
pdch_disable(&bts->trx[trx].pdch[ts]);
/* FIXME: NOT ALL RESOURCES are freed in this case... inconsistent with the other code. Share the code with pcu_l1if.c
for the reset. */
bts_trx_free_all_tbf(&bts->trx[trx]);
}
gprs_bssgp_destroy(bts);
}
gprs_bssgp_destroy(bts);
exit(0);
}

View File

@ -145,7 +145,7 @@ int pcu_tx_txt_ind(enum gsm_pcu_if_text_type t, const char *fmt, ...)
return pcu_sock_send(msg);
}
static int pcu_tx_act_req(uint8_t trx, uint8_t ts, uint8_t activate)
static int pcu_tx_act_req(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint8_t activate)
{
struct msgb *msg;
struct gsm_pcu_if *pcu_prim;
@ -154,7 +154,7 @@ static int pcu_tx_act_req(uint8_t trx, uint8_t ts, uint8_t activate)
LOGP(DL1IF, LOGL_INFO, "Sending %s request: trx=%d ts=%d\n",
(activate) ? "activate" : "deactivate", trx, ts);
msg = pcu_msgb_alloc(PCU_IF_MSG_ACT_REQ, 0);
msg = pcu_msgb_alloc(PCU_IF_MSG_ACT_REQ, bts->nr);
if (!msg)
return -ENOMEM;
pcu_prim = (struct gsm_pcu_if *) msg->data;
@ -166,20 +166,20 @@ static int pcu_tx_act_req(uint8_t trx, uint8_t ts, uint8_t activate)
return pcu_sock_send(msg);
}
static int pcu_tx_data_req(uint8_t trx, uint8_t ts, uint8_t sapi,
static int pcu_tx_data_req(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint8_t sapi,
uint16_t arfcn, uint32_t fn, uint8_t block_nr, uint8_t *data,
uint8_t len)
{
struct msgb *msg;
struct gsm_pcu_if *pcu_prim;
struct gsm_pcu_if_data *data_req;
int current_fn = bts_current_frame_number(the_pcu->bts);
int current_fn = bts_current_frame_number(bts);
LOGP(DL1IF, LOGL_DEBUG, "Sending data request: trx=%d ts=%d sapi=%d "
"arfcn=%d fn=%d cur_fn=%d block=%d data=%s\n", trx, ts, sapi, arfcn, fn, current_fn,
block_nr, osmo_hexdump(data, len));
msg = pcu_msgb_alloc(PCU_IF_MSG_DATA_REQ, 0);
msg = pcu_msgb_alloc(PCU_IF_MSG_DATA_REQ, bts->nr);
if (!msg)
return -ENOMEM;
pcu_prim = (struct gsm_pcu_if *) msg->data;
@ -197,12 +197,10 @@ static int pcu_tx_data_req(uint8_t trx, uint8_t ts, uint8_t sapi,
return pcu_sock_send(msg);
}
void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn,
void pcu_l1if_tx_pdtch(msgb *msg, struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint16_t arfcn,
uint32_t fn, uint8_t block_nr)
{
#ifdef ENABLE_DIRECT_PHY
struct gprs_rlcmac_bts *bts = the_pcu->bts;
if (bts->trx[trx].fl1h) {
l1if_pdch_req(bts->trx[trx].fl1h, ts, 0, fn, arfcn, block_nr,
msg->data, msg->len);
@ -210,7 +208,7 @@ void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn,
return;
}
#endif
pcu_tx_data_req(trx, ts, PCU_IF_SAPI_PDTCH, arfcn, fn, block_nr,
pcu_tx_data_req(bts, trx, ts, PCU_IF_SAPI_PDTCH, arfcn, fn, block_nr,
msg->data, msg->len);
msgb_free(msg);
}
@ -228,10 +226,10 @@ void pcu_l1if_tx_ptcch(struct gprs_rlcmac_bts *bts,
return;
}
#endif
pcu_tx_data_req(trx, ts, PCU_IF_SAPI_PTCCH, arfcn, fn, block_nr, data, data_len);
pcu_tx_data_req(bts, trx, ts, PCU_IF_SAPI_PTCCH, arfcn, fn, block_nr, data, data_len);
}
void pcu_l1if_tx_agch(bitvec * block, int plen)
void pcu_l1if_tx_agch(struct gprs_rlcmac_bts *bts, bitvec * block, int plen)
{
uint8_t data[GSM_MACBLOCK_LEN]; /* prefix PLEN */
@ -242,10 +240,10 @@ void pcu_l1if_tx_agch(bitvec * block, int plen)
if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_AGCH))
gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_AGCH, 0, 0, 0, 0, data, GSM_MACBLOCK_LEN);
pcu_tx_data_req(0, 0, PCU_IF_SAPI_AGCH, 0, 0, 0, data, GSM_MACBLOCK_LEN);
pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_AGCH, 0, 0, 0, data, GSM_MACBLOCK_LEN);
}
void pcu_l1if_tx_pch(bitvec * block, int plen, uint16_t pgroup)
void pcu_l1if_tx_pch(struct gprs_rlcmac_bts *bts, bitvec * block, int plen, uint16_t pgroup)
{
uint8_t data[PAGING_GROUP_LEN + GSM_MACBLOCK_LEN];
int i;
@ -267,33 +265,31 @@ void pcu_l1if_tx_pch(bitvec * block, int plen, uint16_t pgroup)
if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_PCH))
gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_PCH, 0, 0, 0, 0, data + 3, GSM_MACBLOCK_LEN);
pcu_tx_data_req(0, 0, PCU_IF_SAPI_PCH, 0, 0, 0, data, PAGING_GROUP_LEN + GSM_MACBLOCK_LEN);
pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_PCH, 0, 0, 0, data, PAGING_GROUP_LEN + GSM_MACBLOCK_LEN);
}
extern "C" void pcu_rx_block_time(uint16_t arfcn, uint32_t fn, uint8_t ts_no)
void pcu_rx_block_time(struct gprs_rlcmac_bts *bts, uint16_t arfcn, uint32_t fn, uint8_t ts_no)
{
bts_set_current_block_frame_number(the_pcu->bts,fn, 0);
bts_set_current_block_frame_number(bts, fn, 0);
}
extern "C" void pcu_rx_ra_time(uint16_t arfcn, uint32_t fn, uint8_t ts_no)
void pcu_rx_ra_time(struct gprs_rlcmac_bts *bts, uint16_t arfcn, uint32_t fn, uint8_t ts_no)
{
/* access bursts may arrive some bursts earlier */
bts_set_current_block_frame_number(the_pcu->bts,fn, 5);
bts_set_current_block_frame_number(bts, fn, 5);
}
extern "C" int pcu_rx_data_ind_pdtch(uint8_t trx_no, uint8_t ts_no, uint8_t *data,
int pcu_rx_data_ind_pdtch(struct gprs_rlcmac_bts *bts, uint8_t trx_no, uint8_t ts_no, uint8_t *data,
uint8_t len, uint32_t fn, struct pcu_l1_meas *meas)
{
struct gprs_rlcmac_pdch *pdch;
pdch = &the_pcu->bts->trx[trx_no].pdch[ts_no];
pdch = &bts->trx[trx_no].pdch[ts_no];
return pdch->rcv_block(data, len, fn, meas);
}
static int pcu_rx_data_ind_bcch(uint8_t *data, uint8_t len)
static int pcu_rx_data_ind_bcch(struct gprs_rlcmac_bts *bts, uint8_t *data, uint8_t len)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
if (len == 0) {
bts->si13_is_set = false;
LOGP(DL1IF, LOGL_INFO, "Received PCU data indication with empty SI13: cache cleaned\n");
@ -311,10 +307,10 @@ static int pcu_rx_data_ind_bcch(uint8_t *data, uint8_t len)
return 0;
}
static int pcu_rx_data_ind(struct gsm_pcu_if_data *data_ind)
static int pcu_rx_data_ind(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_data *data_ind)
{
int rc;
int current_fn = bts_current_frame_number(the_pcu->bts);
int current_fn = bts_current_frame_number(bts);
struct pcu_l1_meas meas = {0};
uint8_t gsmtap_chantype;
@ -334,13 +330,13 @@ static int pcu_rx_data_ind(struct gsm_pcu_if_data *data_ind)
LOGP(DL1IF, LOGL_DEBUG, "Data indication with raw measurements received: BER10k = %d, BTO = %d, Q = %d\n",
data_ind->ber10k, data_ind->ta_offs_qbits, data_ind->lqual_cb);
rc = pcu_rx_data_ind_pdtch(data_ind->trx_nr, data_ind->ts_nr,
rc = pcu_rx_data_ind_pdtch(bts, data_ind->trx_nr, data_ind->ts_nr,
data_ind->data, data_ind->len, data_ind->fn,
&meas);
gsmtap_chantype = GSMTAP_CHANNEL_PDTCH;
break;
case PCU_IF_SAPI_BCCH:
rc = pcu_rx_data_ind_bcch(data_ind->data, data_ind->len);
rc = pcu_rx_data_ind_bcch(bts, data_ind->data, data_ind->len);
gsmtap_chantype = GSMTAP_CHANNEL_BCCH;
break;
default:
@ -358,10 +354,10 @@ static int pcu_rx_data_ind(struct gsm_pcu_if_data *data_ind)
return rc;
}
static int pcu_rx_data_cnf(struct gsm_pcu_if_data *data_cnf)
static int pcu_rx_data_cnf(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_data *data_cnf)
{
int rc = 0;
int current_fn = bts_current_frame_number(the_pcu->bts);
int current_fn = bts_current_frame_number(bts);
LOGP(DL1IF, LOGL_DEBUG, "Data confirm received: sapi=%d fn=%d cur_fn=%d\n",
data_cnf->sapi, data_cnf->fn, current_fn);
@ -369,7 +365,7 @@ static int pcu_rx_data_cnf(struct gsm_pcu_if_data *data_cnf)
switch (data_cnf->sapi) {
case PCU_IF_SAPI_PCH:
if (data_cnf->data[2] == 0x3f)
bts_rcv_imm_ass_cnf(the_pcu->bts, data_cnf->data, data_cnf->fn);
bts_rcv_imm_ass_cnf(bts, data_cnf->data, data_cnf->fn);
break;
default:
LOGP(DL1IF, LOGL_ERROR, "Received PCU data confirm with "
@ -381,16 +377,15 @@ static int pcu_rx_data_cnf(struct gsm_pcu_if_data *data_cnf)
}
// FIXME: remove this, when changed from c++ to c.
extern "C" int pcu_rx_rts_req_pdtch(uint8_t trx, uint8_t ts,
int pcu_rx_rts_req_pdtch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
uint32_t fn, uint8_t block_nr)
{
return gprs_rlcmac_rcv_rts_block(the_pcu->bts,
return gprs_rlcmac_rcv_rts_block(bts,
trx, ts, fn, block_nr);
}
extern "C" int pcu_rx_rts_req_ptcch(uint8_t trx, uint8_t ts,
int pcu_rx_rts_req_ptcch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
uint32_t fn, uint8_t block_nr)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_pdch *pdch;
/* Prevent buffer overflow */
@ -407,10 +402,10 @@ extern "C" int pcu_rx_rts_req_ptcch(uint8_t trx, uint8_t ts,
return 0;
}
static int pcu_rx_rts_req(struct gsm_pcu_if_rts_req *rts_req)
static int pcu_rx_rts_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_rts_req *rts_req)
{
int rc = 0;
int current_fn = bts_current_frame_number(the_pcu->bts);
int current_fn = bts_current_frame_number(bts);
LOGP(DL1IF, LOGL_DEBUG, "RTS request received: trx=%d ts=%d sapi=%d "
"arfcn=%d fn=%d cur_fn=%d block=%d\n", rts_req->trx_nr, rts_req->ts_nr,
@ -418,11 +413,11 @@ static int pcu_rx_rts_req(struct gsm_pcu_if_rts_req *rts_req)
switch (rts_req->sapi) {
case PCU_IF_SAPI_PDTCH:
pcu_rx_rts_req_pdtch(rts_req->trx_nr, rts_req->ts_nr,
pcu_rx_rts_req_pdtch(bts, rts_req->trx_nr, rts_req->ts_nr,
rts_req->fn, rts_req->block_nr);
break;
case PCU_IF_SAPI_PTCCH:
pcu_rx_rts_req_ptcch(rts_req->trx_nr, rts_req->ts_nr,
pcu_rx_rts_req_ptcch(bts, rts_req->trx_nr, rts_req->ts_nr,
rts_req->fn, rts_req->block_nr);
break;
default:
@ -435,7 +430,7 @@ static int pcu_rx_rts_req(struct gsm_pcu_if_rts_req *rts_req)
}
/* C -> C++ adapter for direct DSP access code (e.g. osmo-bts-sysmo) */
extern "C" int pcu_rx_rach_ind_ptcch(uint8_t trx_nr, uint8_t ts_nr, uint32_t fn, int16_t qta)
extern "C" int pcu_rx_rach_ind_ptcch(struct gprs_rlcmac_bts *bts, uint8_t trx_nr, uint8_t ts_nr, uint32_t fn, int16_t qta)
{
struct rach_ind_params rip = {
/* The content of RA is not of interest on PTCCH/U */
@ -448,13 +443,13 @@ extern "C" int pcu_rx_rach_ind_ptcch(uint8_t trx_nr, uint8_t ts_nr, uint32_t fn,
.qta = qta,
};
return bts_rcv_ptcch_rach(the_pcu->bts, &rip);
return bts_rcv_ptcch_rach(bts, &rip);
}
static int pcu_rx_rach_ind(const struct gsm_pcu_if_rach_ind *rach_ind)
static int pcu_rx_rach_ind(struct gprs_rlcmac_bts *bts, const struct gsm_pcu_if_rach_ind *rach_ind)
{
int rc = 0;
int current_fn = bts_current_frame_number(the_pcu->bts);
int current_fn = bts_current_frame_number(bts);
LOGP(DL1IF, LOGL_INFO, "RACH request received: sapi=%d "
"qta=%d, ra=0x%02x, fn=%u, cur_fn=%d, is_11bit=%d\n", rach_ind->sapi, rach_ind->qta,
@ -472,10 +467,10 @@ static int pcu_rx_rach_ind(const struct gsm_pcu_if_rach_ind *rach_ind)
switch (rach_ind->sapi) {
case PCU_IF_SAPI_RACH:
rc = bts_rcv_rach(the_pcu->bts, &rip);
rc = bts_rcv_rach(bts, &rip);
break;
case PCU_IF_SAPI_PTCCH:
rc = bts_rcv_ptcch_rach(the_pcu->bts, &rip);
rc = bts_rcv_ptcch_rach(bts, &rip);
break;
default:
LOGP(DL1IF, LOGL_ERROR, "Received PCU rach request with "
@ -542,9 +537,8 @@ static int pcu_info_ind_ns(struct gprs_rlcmac_bts *bts,
return gprs_ns_config(bts, info_ind->nsei, local, remote, nsvci, valid);
}
static int pcu_rx_info_ind(const struct gsm_pcu_if_info_ind *info_ind)
static int pcu_rx_info_ind(struct gprs_rlcmac_bts *bts, const struct gsm_pcu_if_info_ind *info_ind)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_bssgp_pcu *pcu;
int rc = 0;
unsigned int trx_nr, ts_nr;
@ -704,7 +698,7 @@ bssgp_failed:
l1if_connect_pdch(
bts->trx[trx_nr].fl1h, ts_nr);
#endif
pcu_tx_act_req(trx_nr, ts_nr, 1);
pcu_tx_act_req(bts, trx_nr, ts_nr, 1);
pdch->enable();
}
@ -730,7 +724,7 @@ bssgp_failed:
trx_nr, ts_nr, pdch->tsc, pdch->fh.enabled ? "yes" : "no");
} else {
if (pdch->is_enabled()) {
pcu_tx_act_req(trx_nr, ts_nr, 0);
pcu_tx_act_req(bts, trx_nr, ts_nr, 0);
pdch->free_resources();
pdch->disable();
}
@ -742,7 +736,7 @@ bssgp_failed:
return rc;
}
static int pcu_rx_time_ind(struct gsm_pcu_if_time_ind *time_ind)
static int pcu_rx_time_ind(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_time_ind *time_ind)
{
uint8_t fn13 = time_ind->fn % 13;
@ -752,11 +746,11 @@ static int pcu_rx_time_ind(struct gsm_pcu_if_time_ind *time_ind)
LOGP(DL1IF, LOGL_DEBUG, "Time indication received: %d\n", time_ind->fn % 52);
bts_set_current_frame_number(the_pcu->bts, time_ind->fn);
bts_set_current_frame_number(bts, time_ind->fn);
return 0;
}
static int pcu_rx_pag_req(struct gsm_pcu_if_pag_req *pag_req)
static int pcu_rx_pag_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_pag_req *pag_req)
{
struct osmo_mobile_identity mi;
int rc;
@ -777,12 +771,11 @@ static int pcu_rx_pag_req(struct gsm_pcu_if_pag_req *pag_req)
return -EINVAL;
}
return bts_add_paging(the_pcu->bts, pag_req->chan_needed, &mi);
return bts_add_paging(bts, pag_req->chan_needed, &mi);
}
static int pcu_rx_susp_req(struct gsm_pcu_if_susp_req *susp_req)
static int pcu_rx_susp_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_susp_req *susp_req)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct bssgp_bvc_ctx *bctx = gprs_bssgp_pcu_current_bctx();
GprsMs *ms;
struct gprs_rlcmac_dl_tbf *dl_tbf;
@ -811,9 +804,8 @@ static int pcu_rx_susp_req(struct gsm_pcu_if_susp_req *susp_req)
return bssgp_tx_suspend(bctx->nsei, susp_req->tlli, &ra_id);
}
static int pcu_rx_app_info_req(struct gsm_pcu_if_app_info_req *app_info_req)
static int pcu_rx_app_info_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_app_info_req *app_info_req)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct llist_head *tmp;
LOGP(DL1IF, LOGL_DEBUG, "Application Information Request received: type=0x%08x len=%i\n",
@ -849,34 +841,43 @@ static int pcu_rx_app_info_req(struct gsm_pcu_if_app_info_req *app_info_req)
int pcu_rx(uint8_t msg_type, struct gsm_pcu_if *pcu_prim)
{
int rc = 0;
struct gprs_rlcmac_bts *bts = gprs_pcu_get_bts_by_nr(the_pcu, pcu_prim->bts_nr);
if (!bts) {
LOGP(DL1IF, LOGL_NOTICE, "Received message for new BTS%d\n", pcu_prim->bts_nr);
bts = bts_alloc(the_pcu, pcu_prim->bts_nr);
if (!bts) {
LOGP(DL1IF, LOGL_ERROR, "Failed to create object for BTS%d!\n", pcu_prim->bts_nr);
return -EAGAIN;
}
}
switch (msg_type) {
case PCU_IF_MSG_DATA_IND:
rc = pcu_rx_data_ind(&pcu_prim->u.data_ind);
rc = pcu_rx_data_ind(bts, &pcu_prim->u.data_ind);
break;
case PCU_IF_MSG_DATA_CNF:
rc = pcu_rx_data_cnf(&pcu_prim->u.data_cnf);
rc = pcu_rx_data_cnf(bts, &pcu_prim->u.data_cnf);
break;
case PCU_IF_MSG_RTS_REQ:
rc = pcu_rx_rts_req(&pcu_prim->u.rts_req);
rc = pcu_rx_rts_req(bts, &pcu_prim->u.rts_req);
break;
case PCU_IF_MSG_RACH_IND:
rc = pcu_rx_rach_ind(&pcu_prim->u.rach_ind);
rc = pcu_rx_rach_ind(bts, &pcu_prim->u.rach_ind);
break;
case PCU_IF_MSG_INFO_IND:
rc = pcu_rx_info_ind(&pcu_prim->u.info_ind);
rc = pcu_rx_info_ind(bts, &pcu_prim->u.info_ind);
break;
case PCU_IF_MSG_TIME_IND:
rc = pcu_rx_time_ind(&pcu_prim->u.time_ind);
rc = pcu_rx_time_ind(bts, &pcu_prim->u.time_ind);
break;
case PCU_IF_MSG_PAG_REQ:
rc = pcu_rx_pag_req(&pcu_prim->u.pag_req);
rc = pcu_rx_pag_req(bts, &pcu_prim->u.pag_req);
break;
case PCU_IF_MSG_SUSP_REQ:
rc = pcu_rx_susp_req(&pcu_prim->u.susp_req);
rc = pcu_rx_susp_req(bts, &pcu_prim->u.susp_req);
break;
case PCU_IF_MSG_APP_INFO_REQ:
rc = pcu_rx_app_info_req(&pcu_prim->u.app_info_req);
rc = pcu_rx_app_info_req(bts, &pcu_prim->u.app_info_req);
break;
default:
LOGP(DL1IF, LOGL_ERROR, "Received unknown PCU msg type %d\n",

View File

@ -141,20 +141,23 @@ static inline void pcu_l1_meas_set_ms_i_level(struct pcu_l1_meas *m, size_t idx,
}
#ifdef __cplusplus
void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn,
uint32_t fn, uint8_t block_nr);
struct gprs_rlcmac_bts;
void pcu_l1if_tx_pdtch(msgb *msg, struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
uint16_t arfcn, uint32_t fn, uint8_t block_nr);
void pcu_l1if_tx_ptcch(struct gprs_rlcmac_bts *bts,
uint8_t trx, uint8_t ts, uint16_t arfcn,
uint32_t fn, uint8_t block_nr,
uint8_t *data, size_t data_len);
void pcu_l1if_tx_agch(bitvec * block, int len);
void pcu_l1if_tx_agch(struct gprs_rlcmac_bts *bts, bitvec * block, int len);
void pcu_l1if_tx_pch(bitvec * block, int plen, uint16_t pgroup);
void pcu_l1if_tx_pch(struct gprs_rlcmac_bts *bts, bitvec * block, int plen, uint16_t pgroup);
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct gprs_rlcmac_bts;
int pcu_rx(uint8_t msg_type, struct gsm_pcu_if *pcu_prim);
int pcu_l1if_open(void);
void pcu_l1if_close(void);
@ -162,17 +165,17 @@ int pcu_sock_send(struct msgb *msg);
int pcu_tx_txt_ind(enum gsm_pcu_if_text_type t, const char *fmt, ...);
int pcu_rx_rts_req_pdtch(uint8_t trx, uint8_t ts,
int pcu_rx_rts_req_pdtch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
uint32_t fn, uint8_t block_nr);
int pcu_rx_rts_req_ptcch(uint8_t trx, uint8_t ts,
int pcu_rx_rts_req_ptcch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
uint32_t fn, uint8_t block_nr);
int pcu_rx_rach_ind_ptcch(uint8_t trx_nr, uint8_t ts_nr, uint32_t fn, int16_t qta);
int pcu_rx_data_ind_pdtch(uint8_t trx, uint8_t ts, uint8_t *data,
int pcu_rx_rach_ind_ptcch(struct gprs_rlcmac_bts *bts, uint8_t trx_nr, uint8_t ts_nr, uint32_t fn, int16_t qta);
int pcu_rx_data_ind_pdtch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint8_t *data,
uint8_t len, uint32_t fn, struct pcu_l1_meas *meas);
void pcu_rx_block_time(uint16_t arfcn, uint32_t fn, uint8_t ts_no);
void pcu_rx_ra_time(uint16_t arfcn, uint32_t fn, uint8_t ts_no);
void pcu_rx_block_time(struct gprs_rlcmac_bts *bts, uint16_t arfcn, uint32_t fn, uint8_t ts_no);
void pcu_rx_ra_time(struct gprs_rlcmac_bts *bts, uint16_t arfcn, uint32_t fn, uint8_t ts_no);
uint16_t imsi2paging_group(const char* imsi);
#ifdef __cplusplus
}

View File

@ -237,8 +237,6 @@ int main(int argc, char *argv[])
pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu = pcu; /* globally avaialable object */
pcu->bts = bts_alloc(pcu);
pcu->pcu_sock_path = talloc_strdup(tall_pcu_ctx, PCU_SOCK_DEFAULT);
msgb_talloc_ctx_init(tall_pcu_ctx, 0);

View File

@ -4,6 +4,8 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <osmocom/core/tdef.h>
#include <osmocom/core/utils.h>
#include <osmocom/vty/tdef_vty.h>
@ -753,7 +755,11 @@ DEFUN(show_bts_stats,
"show bts statistics",
SHOW_STR "BTS related functionality\nStatistics\n")
{
vty_out_rate_ctr_group(vty, "", bts_rate_counters(the_pcu->bts));
struct gprs_rlcmac_bts *bts;
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
vty_out(vty, "BTS%" PRIu8 ":%s", bts->nr, VTY_NEWLINE);
vty_out_rate_ctr_group(vty, " ", bts_rate_counters(bts));
}
return CMD_SUCCESS;
}
@ -762,7 +768,11 @@ DEFUN(show_bts_pdch,
"show bts pdch",
SHOW_STR "BTS related functionality\nPDCH timeslots\n")
{
return pcu_vty_show_bts_pdch(vty, the_pcu->bts);
struct gprs_rlcmac_bts *bts;
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
pcu_vty_show_bts_pdch(vty, bts);
}
return CMD_SUCCESS;
}
#define IDLE_TIME_STR "keep an idle DL TBF alive for the time given\n"
@ -1013,9 +1023,13 @@ DEFUN(show_bts_timer, show_bts_timer_cmd,
SHOW_STR "Show BTS controlled timers\n"
OSMO_TDEF_VTY_DOC_T)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
const char *T_arg = argc > 0 ? argv[0] : NULL;
return osmo_tdef_vty_show_cmd(vty, bts->T_defs_bts, T_arg, NULL);
struct gprs_rlcmac_bts *bts;
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
const char *T_arg = argc > 0 ? argv[0] : NULL;
vty_out(vty, "BTS%" PRIu8 ":%s", bts->nr, VTY_NEWLINE);
osmo_tdef_vty_show_cmd(vty, bts->T_defs_bts, T_arg, " ");
}
return CMD_SUCCESS;
}
DEFUN(show_timer, show_timer_cmd,
@ -1047,15 +1061,18 @@ DEFUN(show_tbf,
"TBFs allocated via CCCH\n"
"TBFs allocated via PACCH\n")
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
uint32_t flags = UINT32_MAX;
struct gprs_rlcmac_bts *bts;
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
uint32_t flags = UINT32_MAX;
if (argv[0][0] == 'c')
flags = (1 << GPRS_RLCMAC_FLAG_CCCH);
else if (argv[0][0] == 'p')
flags = (1 << GPRS_RLCMAC_FLAG_PACCH);
if (argv[0][0] == 'c')
flags = (1 << GPRS_RLCMAC_FLAG_CCCH);
else if (argv[0][0] == 'p')
flags = (1 << GPRS_RLCMAC_FLAG_PACCH);
return pcu_vty_show_tbf_all(vty, bts, flags);
pcu_vty_show_tbf_all(vty, bts, flags);
}
return CMD_SUCCESS;
}
DEFUN(show_ms_all,
@ -1063,8 +1080,11 @@ DEFUN(show_ms_all,
"show ms all",
SHOW_STR "information about MSs\n" "All TBFs\n")
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
return pcu_vty_show_ms_all(vty, bts);
struct gprs_rlcmac_bts *bts;
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
pcu_vty_show_ms_all(vty, bts);
}
return CMD_SUCCESS;
}
DEFUN(show_ms_tlli,
@ -1072,14 +1092,17 @@ DEFUN(show_ms_tlli,
"show ms tlli TLLI",
SHOW_STR "information about MSs\n" "Select MS by TLLI\n" "TLLI as hex\n")
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
char *endp = NULL;
unsigned long long tlli = strtoll(argv[0], &endp, 16);
if ((endp != NULL && *endp != 0) || tlli > 0xffffffffULL) {
vty_out(vty, "Invalid TLLI.%s", VTY_NEWLINE);
return CMD_WARNING;
struct gprs_rlcmac_bts *bts;
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
char *endp = NULL;
unsigned long long tlli = strtoll(argv[0], &endp, 16);
if ((endp != NULL && *endp != 0) || tlli > 0xffffffffULL) {
vty_out(vty, "Invalid TLLI.%s", VTY_NEWLINE);
return CMD_WARNING;
}
pcu_vty_show_ms_by_tlli(vty, bts, (uint32_t)tlli);
}
return pcu_vty_show_ms_by_tlli(vty, bts, (uint32_t)tlli);
return CMD_SUCCESS;
}
DEFUN(show_ms_imsi,
@ -1087,8 +1110,11 @@ DEFUN(show_ms_imsi,
"show ms imsi IMSI",
SHOW_STR "information about MSs\n" "Select MS by IMSI\n" "IMSI\n")
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
return pcu_vty_show_ms_by_imsi(vty, bts, argv[0]);
struct gprs_rlcmac_bts *bts;
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
pcu_vty_show_ms_by_imsi(vty, bts, argv[0]);
}
return CMD_SUCCESS;
}
static const char pcu_copyright[] =

View File

@ -246,7 +246,7 @@ int pcu_vty_show_bts_pdch(struct vty *vty, const struct gprs_rlcmac_bts *bts)
{
unsigned int trx_nr, ts_nr;
vty_out(vty, "BTS (%s)%s", bts->active ? "active" : "disabled", VTY_NEWLINE);
vty_out(vty, "BTS%" PRIu8 " (%s)%s", bts->nr, bts->active ? "active" : "disabled", VTY_NEWLINE);
for (trx_nr = 0; trx_nr < ARRAY_SIZE(bts->trx); trx_nr++) {
const struct gprs_rlcmac_trx *trx = &bts->trx[trx_nr];

View File

@ -114,7 +114,7 @@ static void test_alloc_a(gprs_rlcmac_tbf_direction dir,
int tfi;
int i;
uint8_t used_trx, tmp_trx;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
struct gprs_rlcmac_tbf *tbfs[32*8+1] = { 0, };
@ -206,7 +206,7 @@ static inline void enable_ts_on_bts(struct gprs_rlcmac_bts *bts,
static inline bool test_alloc_b_ul_dl(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7,
uint8_t ms_class, bool verbose)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
gprs_rlcmac_ul_tbf *ul_tbf;
gprs_rlcmac_dl_tbf *dl_tbf;
@ -250,7 +250,7 @@ static inline bool test_alloc_b_ul_dl(bool ts0, bool ts1, bool ts2, bool ts3, bo
static inline bool test_alloc_b_dl_ul(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7,
uint8_t ms_class, bool verbose)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
gprs_rlcmac_ul_tbf *ul_tbf;
gprs_rlcmac_dl_tbf *dl_tbf;
@ -301,7 +301,7 @@ static inline bool test_alloc_b_dl_ul(bool ts0, bool ts1, bool ts2, bool ts3, bo
static inline bool test_alloc_b_jolly(uint8_t ms_class)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
int tfi;
uint8_t trx_no;
@ -644,7 +644,7 @@ static void test_successive_allocation(algo_t algo, unsigned min_class,
unsigned max_class, enum test_mode mode,
unsigned expect_num, const char *text)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
struct gprs_rlcmac_trx *trx;
unsigned counter;
@ -677,7 +677,7 @@ static void test_successive_allocation(algo_t algo, unsigned min_class,
static void test_many_connections(algo_t algo, unsigned expect_num,
const char *text)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
struct gprs_rlcmac_trx *trx;
int counter1, counter2 = -1;
unsigned i;
@ -754,7 +754,7 @@ static void test_successive_allocations()
static void test_2_consecutive_dl_tbfs()
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
struct gprs_rlcmac_trx *trx;
uint8_t ms_class = 11;

View File

@ -62,7 +62,7 @@ static inline void test_all_classes(struct gprs_rlcmac_trx *trx, bool clear_mask
static inline void test_multislot_total_ascending(bool seq)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
struct gprs_rlcmac_trx *trx;
int i;
@ -81,7 +81,7 @@ static inline void test_multislot_total_ascending(bool seq)
static inline void test_multislot_total_descending(bool seq)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
struct gprs_rlcmac_trx *trx;
int i;
@ -100,7 +100,7 @@ static inline void test_multislot_total_descending(bool seq)
static inline void test_multislot_middle(bool seq)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
struct gprs_rlcmac_trx *trx;
printf("%s(): %s\n", __func__, seq ? "sequential" : "accumulative");
@ -117,7 +117,7 @@ static inline void test_multislot_middle(bool seq)
static inline void test_multislot_ends(bool seq)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
struct gprs_rlcmac_trx *trx;
printf("%s(): %s\n", __func__, seq ? "sequential" : "accumulative");

View File

@ -78,7 +78,7 @@ void test_pcu_rx_no_subscr_with_active_tbf()
void prepare_bts_with_two_dl_tbf_subscr()
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = gprs_pcu_get_bts_by_nr(the_pcu, 0);
struct gprs_rlcmac_trx *trx;
fprintf(stderr, "--- %s ---\n", __func__);
@ -121,7 +121,7 @@ void test_sched_app_info_ok(const struct gsm_pcu_if_app_info_req *req)
void test_sched_app_info_missing_app_info_in_bts(const struct gsm_pcu_if_app_info_req *req)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = gprs_pcu_get_bts_by_nr(the_pcu, 0);
struct gsm_pcu_if pcu_prim = {PCU_IF_MSG_APP_INFO_REQ, };
fprintf(stderr, "--- %s ---\n", __func__);
@ -147,13 +147,18 @@ void test_pcu_rx_overwrite_app_info(const struct gsm_pcu_if_app_info_req *req)
fprintf(stderr, "\n");
}
void cleanup()
extern "C" void cleanup()
{
fprintf(stderr, "--- %s ---\n", __func__);
struct gprs_rlcmac_bts *bts;
tbf_free(tbf1);
tbf_free(tbf2);
TALLOC_FREE(the_pcu->bts);
bts = gprs_pcu_get_bts_by_nr(the_pcu, 0);
talloc_free(bts);
/* FIXME: talloc report disabled, because bts_alloc_ms(bts, ) in prepare_bts_with_two_dl_tbf_subscr() causes leak */
/* talloc_report_full(tall_pcu_ctx, stderr); */
talloc_free(the_pcu);
@ -173,7 +178,7 @@ int main(int argc, char *argv[])
log_parse_category_mask(osmo_stderr_target, "DL1IF,1:DRLCMAC,3:DRLCMACSCHED,1");
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
bts_alloc(the_pcu, 0);
test_enc_zero_len();
test_enc(&req);

View File

@ -1252,7 +1252,7 @@ static void uplink_header_type_2_parsing_test(struct gprs_rlcmac_bts *bts,
static void uplink_header_type2_test(void)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -1370,7 +1370,7 @@ static void uplink_header_type_1_parsing_test(struct gprs_rlcmac_bts *bts,
void uplink_header_type1_test(void)
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;

View File

@ -63,9 +63,8 @@ struct gprs_test all_tests[] = {
test_pdp_activation_data),
};
static void init_main_bts()
static void init_main_bts(struct gprs_rlcmac_bts *bts)
{
struct gprs_rlcmac_bts *bts = the_pcu->bts;
bts->initial_cs_dl = bts->initial_cs_ul = 1;
bts->cs_mask = 1 << 0; /* CS-1 always enabled by default */
bts->n3101 = 10;
@ -119,7 +118,7 @@ int main(int argc, char **argv)
{
struct gprs_pcu *pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu = pcu; /* globally avaialable object */
pcu->bts = bts_alloc(pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(pcu, 0);
tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile Emu-PCU context");
if (!tall_pcu_ctx)
@ -140,9 +139,9 @@ int main(int argc, char **argv)
current_test = 0;
init_pcu(pcu);
init_main_bts();
init_main_bts(bts);
bssgp_set_bssgp_callback(gprs_gp_send_cb, pcu->nsi);
create_and_connect_bssgp(pcu->bts, INADDR_LOOPBACK, 23000);
create_and_connect_bssgp(bts, INADDR_LOOPBACK, 23000);
for (;;)
osmo_select_main(0);

View File

@ -53,7 +53,7 @@ static void set_fn(struct gprs_rlcmac_bts * bts, uint32_t fn)
static void run_test()
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint32_t fn;
printf("RFN_MODULUS=%i\n",RFN_MODULUS);

View File

@ -51,7 +51,7 @@ static void test_ms_state()
uint32_t tlli = 0xffeeddbb;
gprs_rlcmac_dl_tbf *dl_tbf;
gprs_rlcmac_ul_tbf *ul_tbf;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
printf("=== start %s ===\n", __func__);
@ -114,7 +114,7 @@ static void test_ms_callback()
uint32_t tlli = 0xffeeddbb;
gprs_rlcmac_dl_tbf *dl_tbf;
gprs_rlcmac_ul_tbf *ul_tbf;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
last_cb = CB_UNKNOWN;
@ -188,7 +188,7 @@ static void test_ms_replace_tbf()
uint32_t tlli = 0xffeeddbb;
gprs_rlcmac_dl_tbf *dl_tbf[2];
gprs_rlcmac_ul_tbf *ul_tbf;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
printf("=== start %s ===\n", __func__);
@ -262,7 +262,7 @@ static void test_ms_change_tlli()
uint32_t start_tlli = 0xaa000000;
uint32_t new_ms_tlli = 0xff001111;
uint32_t other_sgsn_tlli = 0xff00eeee;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
printf("=== start %s ===\n", __func__);
@ -374,7 +374,7 @@ static void test_ms_storage()
const char *imsi2 = "001001987654322";
gprs_rlcmac_ul_tbf *ul_tbf;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms, *ms_tmp;
GprsMsStorage store(bts);
@ -446,7 +446,7 @@ static void test_ms_timeout()
uint32_t tlli = 0xffeeddbb;
gprs_rlcmac_dl_tbf *dl_tbf;
gprs_rlcmac_ul_tbf *ul_tbf;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
last_cb = CB_UNKNOWN;
@ -499,7 +499,7 @@ static void test_ms_timeout()
static void test_ms_cs_selection()
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint32_t tlli = 0xffeeddbb;
gprs_rlcmac_dl_tbf *dl_tbf;
@ -544,7 +544,7 @@ static void dump_ms(const GprsMs *ms, const char *pref)
static void test_ms_mcs_mode()
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint32_t tlli = 0xdeadbeef;
gprs_rlcmac_dl_tbf *dl_tbf;

View File

@ -95,8 +95,7 @@ static void test_tbf_base()
static void test_tbf_tlli_update()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms, *ms_new;
fprintf(stderr, "=== start %s ===\n", __func__);
@ -254,8 +253,7 @@ enum test_tbf_final_ack_mode {
static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ts_no = 4;
unsigned i;
uint8_t ms_class = 45;
@ -340,8 +338,7 @@ static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode)
static void test_tbf_delayed_release()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ts_no = 4;
unsigned i;
uint8_t ms_class = 45;
@ -411,8 +408,7 @@ static void test_tbf_delayed_release()
static void test_tbf_imsi()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ts_no = 4;
uint8_t ms_class = 45;
uint8_t trx_no;
@ -473,8 +469,7 @@ static void test_tbf_imsi()
static void test_tbf_exhaustion()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
unsigned i;
uint8_t ts_no = 4;
uint8_t ms_class = 45;
@ -517,8 +512,7 @@ static void test_tbf_exhaustion()
static void test_tbf_dl_llc_loss()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ts_no = 4;
uint8_t ms_class = 45;
int rc = 0;
@ -1699,8 +1693,7 @@ static inline void print_ta_tlli(const gprs_rlcmac_ul_tbf *ul_tbf, bool print_ms
static void test_tbf_single_phase()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = DUMMY_FN; /* 17,25,9 */
uint32_t tlli = 0xf1223344;
@ -1724,8 +1717,7 @@ static void test_tbf_single_phase()
static void test_tbf_egprs_two_phase_puan(void)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -1780,8 +1772,7 @@ static void test_tbf_egprs_two_phase_puan(void)
static void test_immediate_assign_rej_single_block()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint32_t fn = 2654218;
uint16_t qta = 31;
int ts_no = 7;
@ -1814,8 +1805,7 @@ static void test_immediate_assign_rej_single_block()
static void test_immediate_assign_rej_multi_block()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint32_t fn = 2654218;
uint16_t qta = 31;
int ts_no = 7;
@ -1856,8 +1846,7 @@ static void test_immediate_assign_rej()
static void test_tbf_two_phase()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -1889,8 +1878,7 @@ static inline void print_ms(GprsMs *ms, bool old)
static void test_tbf_ra_update_rach()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -1956,8 +1944,7 @@ static void test_tbf_ra_update_rach()
static void test_tbf_dl_flow_and_rach_two_phase()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -2018,8 +2005,7 @@ static void test_tbf_dl_flow_and_rach_two_phase()
static void test_tbf_dl_flow_and_rach_single_phase()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -2079,8 +2065,7 @@ static void test_tbf_dl_flow_and_rach_single_phase()
static void test_tbf_dl_reuse()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -2180,8 +2165,7 @@ static void test_tbf_dl_reuse()
static void test_tbf_gprs_egprs()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ts_no = 4;
uint8_t ms_class = 45;
int rc = 0;
@ -2248,8 +2232,7 @@ static inline void ws_check(gprs_rlcmac_dl_tbf *dl_tbf, const char *test, uint8_
static void test_tbf_ws()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
uint8_t ts_no = 4;
uint8_t ms_class = 12;
@ -2294,8 +2277,7 @@ static void test_tbf_ws()
static void test_tbf_update_ws(void)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
GprsMs *ms;
uint8_t ts_no = 4;
uint8_t ms_class = 11;
@ -2339,8 +2321,7 @@ static void test_tbf_update_ws(void)
static void test_tbf_puan_urbb_len(void)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -2479,8 +2460,7 @@ static gprs_rlcmac_ul_tbf *tbf_li_decoding(struct gprs_rlcmac_bts *bts,
static void test_tbf_li_decoding(void)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -2516,8 +2496,7 @@ static void test_tbf_li_decoding(void)
static void test_tbf_epdan_out_of_rx_window(void)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ms_class = 11;
uint8_t egprs_ms_class = 11;
uint8_t trx_no;
@ -2608,8 +2587,7 @@ static void test_tbf_epdan_out_of_rx_window(void)
static void test_tbf_egprs_two_phase_spb(void)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -2640,8 +2618,7 @@ static void test_tbf_egprs_two_phase_spb(void)
static void test_tbf_egprs_two_phase()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
int ts_no = 7;
uint32_t fn = 2654218;
uint16_t qta = 31;
@ -3064,8 +3041,7 @@ static void establish_and_use_egprs_dl_tbf_for_retx(struct gprs_rlcmac_bts *bts,
static void test_tbf_egprs_retx_dl(void)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ts_no = 4;
fprintf(stderr, "=== start %s ===\n", __func__);
@ -3093,8 +3069,7 @@ static void test_tbf_egprs_retx_dl(void)
static void test_tbf_egprs_spb_dl(void)
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ts_no = 4;
fprintf(stderr, "=== start %s ===\n", __func__);
@ -3124,8 +3099,7 @@ static void test_tbf_egprs_spb_dl(void)
static void test_tbf_egprs_dl()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint8_t ts_no = 4;
int i;
@ -3148,8 +3122,7 @@ static void test_tbf_egprs_dl()
static void test_packet_access_rej_prr_no_other_tbfs()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint32_t fn = 2654218;
int ts_no = 7;
uint8_t trx_no = 0;
@ -3184,8 +3157,7 @@ static void test_packet_access_rej_prr_no_other_tbfs()
static void test_packet_access_rej_prr()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint32_t fn = 2654218;
uint16_t qta = 31;
int ts_no = 7;
@ -3255,8 +3227,7 @@ static void test_packet_access_rej_prr()
void test_packet_access_rej_epdan()
{
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
uint32_t tlli = 0xffeeddcc;
static uint8_t exp[] = { 0x40, 0x84, 0x7f, 0xf7, 0x6e, 0xe6, 0x41, 0x4b,
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,

View File

@ -353,7 +353,7 @@ static void test_rlc_dl_ul_basic()
uint16_t lost = 0, recv = 0;
char show_rbb[65];
uint8_t bits_data[8];
struct gprs_rlcmac_bts *dummy_bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *dummy_bts = bts_alloc(the_pcu, 0);
gprs_rlc_dl_window dl_win;
bitvec bits;
int bsn_begin, bsn_end, num_blocks;
@ -671,7 +671,7 @@ static void test_egprs_ul_ack_nack()
fprintf(stderr, "############## test_egprs_ul_ack_nack\n");
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
the_pcu->alloc_algorithm = alloc_algorithm_a;
bts->trx[0].pdch[4].enable();
@ -762,7 +762,7 @@ static void check_imm_ass(struct gprs_rlcmac_tbf *tbf, bool dl, enum ph_burst_ty
void test_immediate_assign_dl()
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
the_pcu->alloc_algorithm = alloc_algorithm_a;
bts->trx[0].pdch[2].enable();
bts->trx[0].pdch[3].enable();
@ -787,7 +787,7 @@ void test_immediate_assign_dl()
void test_immediate_assign_ul0m()
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
the_pcu->alloc_algorithm = alloc_algorithm_a;
bts->trx[0].pdch[4].enable();
bts->trx[0].pdch[5].enable();
@ -829,7 +829,7 @@ void test_immediate_assign_ul0s()
void test_immediate_assign_ul1s()
{
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu);
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
the_pcu->alloc_algorithm = alloc_algorithm_a;
bts->trx[0].pdch[1].enable();
bts->trx[0].pdch[2].enable();