aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-octphy/l1_if.c
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2019-09-25 10:39:40 +0200
committerlaforge <laforge@osmocom.org>2019-10-11 10:46:02 +0000
commit5fee4d1ff5fac53bc21ed19abf2f84456486fa44 (patch)
treef8387d2bcff68f83320ff3da3f02c2e02a7ef439 /src/osmo-bts-octphy/l1_if.c
parenta4c54b531c05151f7074be952a22f1891aa0fcc6 (diff)
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
Diffstat (limited to 'src/osmo-bts-octphy/l1_if.c')
-rw-r--r--src/osmo-bts-octphy/l1_if.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 612c29ad..bf2fa355 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -938,6 +938,47 @@ static int handle_mph_time_ind(struct octphy_hdl *fl1, uint8_t trx_id, uint32_t
return 0;
}
+/* octv1_gsm_api.h does not have an end marker for CTVC1_GSM_SAPI_ENUM */
+#define _OCTVC1_GSM_SAPI_ENUM_LENGTH (cOCTVC1_GSM_SAPI_ENUM_PRACH + 1)
+
+static const enum l1sap_common_sapi common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MON_SAPI_PPCH,
+ [cOCTVC1_GSM_SAPI_ENUM_PNCH] = L1SAP_COMMON_SAPI_PNCH,
+ [cOCTVC1_GSM_SAPI_ENUM_PTCCH] = L1SAP_COMMON_SAPI_PTCCH,
+ [cOCTVC1_GSM_SAPI_ENUM_PRACH] = L1SAP_COMMON_SAPI_PRACH,
+};
+
+static enum l1sap_common_sapi get_common_sapi(tOCT_UINT8 sapi)
+{
+ if (sapi >= _OCTVC1_GSM_SAPI_ENUM_LENGTH)
+ return L1SAP_COMMON_SAPI_UNKNOWN;
+ return common_sapi_by_oct_sapi[sapi];
+}
+
+static void set_log_ctx_sapi(tOCT_UINT8 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 octphy_hdl *fl1,
tOCTVC1_GSM_MSG_TRX_LOGICAL_CHANNEL_READY_TO_SEND_INDICATION_EVT *evt,
struct msgb *l1p_msg)
@@ -955,6 +996,8 @@ static int handle_ph_readytosend_ind(struct octphy_hdl *fl1,
struct msgb *resp_msg;
tOCTVC1_GSM_MSG_TRX_REQUEST_LOGICAL_CHANNEL_DATA_CMD *data_req;
+ set_log_ctx_sapi(evt->LchId.bySAPI);
+
/* Retrive the data */
fn = evt->ulFrameNumber;
ts_num = (uint8_t) evt->LchId.byTimeslotNb;
@@ -1079,6 +1122,8 @@ static int handle_ph_data_ind(struct octphy_hdl *fl1,
uint8_t ts_num = (uint8_t) data_ind->LchId.byTimeslotNb;
uint8_t sc = (uint8_t) data_ind->LchId.bySubChannelNb;
+ set_log_ctx_sapi(data_ind->LchId.bySAPI);
+
/* Need to combine two 16bit MSB and LSB to form 32bit FN */
fn = data_ind->Data.ulFrameNumber;
@@ -1171,6 +1216,8 @@ static int handle_ph_rach_ind(struct octphy_hdl *fl1,
int rc;
struct ph_rach_ind_param rach_ind_param;
+ set_log_ctx_sapi(ra_ind->LchId.bySAPI);
+
dump_meas_res(LOGL_DEBUG, &ra_ind->MeasurementInfo);
if (ra_ind->ulMsgLength != 1) {