From 5fee4d1ff5fac53bc21ed19abf2f84456486fa44 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 25 Sep 2019 10:39:40 +0200 Subject: log: set L1 SAPI log context Add a new common L1 SAPI enum, to unify all the BTS specific SAPIs. Translate to this enum, and set the context for uplink messages in each BTS specific implementation. Set the context for downlink messages in the common l1sap code, by converting the osmo_phsap_prim back to the SAPI value (mostly looking at chan_nr). The new functions for doing this conversion, get_common_sapi_by_trx_prim() and get_common_sapi_ph_data(), are based on the existing to_gsmtap() and gsmtap_ph_data() functions. Note that we can't set the uplink SAPI context in the common code, because then we can't set it as early as possible. In this patch, the SAPI context is set for the PHYs where the SAPI is readily available. With additional conversion from the RSL channel, the SAPI context could be set for osmo-bts-trx in a follow up patch. Related: OS#2356 Depends: (libosmocore) I814cb3328d99faca9220adb5a80ffb934f219d7d Change-Id: I6b7bb2e1d61502b61214f854a4ec5cbb7267545b --- src/osmo-bts-litecell15/l1_if.c | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/osmo-bts-litecell15/l1_if.c') diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index 2ac0b7ab..d7e0cde5 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -795,6 +795,45 @@ static uint8_t chan_nr_by_sapi(struct gsm_bts_trx_ts *ts, return (cbits << 3) | u8Tn; } +static const enum l1sap_common_sapi common_sapi_by_sapi_t[] = { + [GsmL1_Sapi_Idle] = L1SAP_COMMON_SAPI_IDLE, + [GsmL1_Sapi_Fcch] = L1SAP_COMMON_SAPI_FCCH, + [GsmL1_Sapi_Sch] = L1SAP_COMMON_SAPI_SCH, + [GsmL1_Sapi_Sacch] = L1SAP_COMMON_SAPI_SACCH, + [GsmL1_Sapi_Sdcch] = L1SAP_COMMON_SAPI_SDCCH, + [GsmL1_Sapi_Bcch] = L1SAP_COMMON_SAPI_BCCH, + [GsmL1_Sapi_Pch] = L1SAP_COMMON_SAPI_PCH, + [GsmL1_Sapi_Agch] = L1SAP_COMMON_SAPI_AGCH, + [GsmL1_Sapi_Cbch] = L1SAP_COMMON_SAPI_CBCH, + [GsmL1_Sapi_Rach] = L1SAP_COMMON_SAPI_RACH, + [GsmL1_Sapi_TchF] = L1SAP_COMMON_SAPI_TCH_F, + [GsmL1_Sapi_FacchF] = L1SAP_COMMON_SAPI_FACCH_F, + [GsmL1_Sapi_TchH] = L1SAP_COMMON_SAPI_TCH_H, + [GsmL1_Sapi_FacchH] = L1SAP_COMMON_SAPI_FACCH_H, + [GsmL1_Sapi_Nch] = L1SAP_COMMON_SAPI_NCH, + [GsmL1_Sapi_Pdtch] = L1SAP_COMMON_SAPI_PDTCH, + [GsmL1_Sapi_Pacch] = L1SAP_COMMON_SAPI_PACCH, + [GsmL1_Sapi_Pbcch] = L1SAP_COMMON_SAPI_PBCCH, + [GsmL1_Sapi_Pagch] = L1SAP_COMMON_SAPI_PAGCH, + [GsmL1_Sapi_Ppch] = L1SAP_COMMON_SAPI_PPCH, + [GsmL1_Sapi_Pnch] = L1SAP_COMMON_SAPI_PNCH, + [GsmL1_Sapi_Ptcch] = L1SAP_COMMON_SAPI_PTCCH, + [GsmL1_Sapi_Prach] = L1SAP_COMMON_SAPI_PRACH, +}; + +static enum l1sap_common_sapi get_common_sapi(GsmL1_Sapi_t sapi) +{ + if (sapi >= GsmL1_Sapi_NUM) + return L1SAP_COMMON_SAPI_UNKNOWN; + return common_sapi_by_sapi_t[sapi]; +} + +static void set_log_ctx_sapi(GsmL1_Sapi_t sapi) +{ + l1sap_log_ctx_sapi = get_common_sapi(sapi); + log_set_context(LOG_CTX_L1_SAPI, &l1sap_log_ctx_sapi); +} + static int handle_ph_readytosend_ind(struct lc15l1_hdl *fl1, GsmL1_PhReadyToSendInd_t *rts_ind, struct msgb *l1p_msg) @@ -811,6 +850,8 @@ static int handle_ph_readytosend_ind(struct lc15l1_hdl *fl1, uint8_t chan_nr, link_id; uint32_t fn; + set_log_ctx_sapi(rts_ind->sapi); + /* check if primitive should be handled by common part */ chan_nr = chan_nr_by_sapi(&trx->ts[rts_ind->u8Tn], rts_ind->sapi, rts_ind->subCh, rts_ind->u8Tn, rts_ind->u32Fn); @@ -933,6 +974,8 @@ static int handle_ph_data_ind(struct lc15l1_hdl *fl1, GsmL1_PhDataInd_t *data_in int rc = 0; int8_t rssi; + set_log_ctx_sapi(data_ind->sapi); + chan_nr = chan_nr_by_sapi(&trx->ts[data_ind->u8Tn], data_ind->sapi, data_ind->subCh, data_ind->u8Tn, data_ind->u32Fn); fn = data_ind->u32Fn; @@ -1002,6 +1045,7 @@ static int handle_ph_ra_ind(struct lc15l1_hdl *fl1, GsmL1_PhRaInd_t *ra_ind, int rc; struct ph_rach_ind_param rach_ind_param; + set_log_ctx_sapi(ra_ind->sapi); dump_meas_res(LOGL_DEBUG, &ra_ind->measParam); if ((ra_ind->msgUnitParam.u8Size != 1) && -- cgit v1.2.3