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
changes/09/22309/6
Pau Espin 2 years ago
parent e91c4c72b1
commit d1049dc8cc
  1. 1
      README.md
  2. 16
      src/bts.cpp
  3. 7
      src/bts.h
  4. 22
      src/gprs_bssgp_pcu.c
  5. 43
      src/gprs_pcu.c
  6. 4
      src/gprs_pcu.h
  7. 5
      src/gprs_rlcmac.cpp
  8. 2
      src/gprs_rlcmac.h
  9. 4
      src/gprs_rlcmac_sched.cpp
  10. 23
      src/osmo-bts-litecell15/lc15_l1_if.c
  11. 23
      src/osmo-bts-oc2g/oc2g_l1_if.c
  12. 27
      src/osmo-bts-sysmo/sysmo_l1_if.c
  13. 48
      src/osmobts_sock.c
  14. 131
      src/pcu_l1_if.cpp
  15. 23
      src/pcu_l1_if.h
  16. 2
      src/pcu_main.cpp
  17. 72
      src/pcu_vty.c
  18. 2
      src/pcu_vty_functions.cpp
  19. 14
      tests/alloc/AllocTest.cpp
  20. 8
      tests/alloc/MslotTest.cpp
  21. 15
      tests/app_info/AppInfoTest.cpp
  22. 4
      tests/edge/EdgeTest.cpp
  23. 9
      tests/emu/pcu_emu.cpp
  24. 2
      tests/fn/FnTest.cpp
  25. 16
      tests/ms/MsTest.cpp
  26. 87
      tests/tbf/TbfTest.cpp
  27. 10
      tests/types/TypesTest.cpp

@ -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

@ -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",

@ -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);

@ -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);

@ -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);
}
}

@ -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);

@ -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;

@ -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
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -123,7 +123,7 @@ int l1if_connect_pdch(void *obj, uint8_t ts)
cr = prim_init(msgb_l1prim(msg), GsmL1_PrimId_MphConnectReq, fl1h);
cr->u8Tn = ts;
cr->logChComb = GsmL1_LogChComb_XIII;
return l1if_req_pdch(fl1h, msg);
}
@ -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;
}

@ -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;
if (bts->active)
return;
struct gprs_rlcmac_bts *bts;
bool retry = llist_empty(&the_pcu->bts_list);
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);
}

@ -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",

@ -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
}

@ -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);

@ -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")
{