[MERGED] osmo-bts[master]: code dup: join [rsl_]lchan_lookup() from libbsc and osmo-bts

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Jul 25 21:45:10 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: code dup: join [rsl_]lchan_lookup() from libbsc and osmo-bts
......................................................................


code dup: join [rsl_]lchan_lookup() from libbsc and osmo-bts

lchan_lookup in openbsc abis_rsl.c and rsl_lchan_lookup() rsl.c are the
same code, except for the log context, which is only set in abis_rsl.c.
The common code was factored out to gsm_data_shared.c in openbsc.git.

Use the *rc return code argument to keep the logging part in the newly
introduced thin wrapper lchan_lookup() in common/rsl.c. This also removes code
dup for logging

The rsl_lchan_lookup() implementation is removed from osmo-bts, so a recent
openbsc is needed to build this.

Change-Id: Ibc469b75e31560271be8633d524366442d27e6fb
---
M include/osmo-bts/rsl.h
M src/common/rsl.c
2 files changed, 11 insertions(+), 53 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/rsl.h b/include/osmo-bts/rsl.h
index f13e968..72ed2fc 100644
--- a/include/osmo-bts/rsl.h
+++ b/include/osmo-bts/rsl.h
@@ -33,8 +33,6 @@
 int rsl_tx_ccch_load_ind_rach(struct gsm_bts *bts, uint16_t total,
 			      uint16_t busy, uint16_t access);
 
-struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr);
-
 void cb_ts_disconnected(struct gsm_bts_trx_ts *ts);
 void cb_ts_connected(struct gsm_bts_trx_ts *ts);
 void ipacc_dyn_pdch_complete(struct gsm_bts_trx_ts *ts, int rc);
diff --git a/src/common/rsl.c b/src/common/rsl.c
index aac520c..69ed108 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -144,59 +144,19 @@
 	return rsl_tx_error_report(trx, RSL_ERR_IE_CONTENT);
 }
 
-#warning merge lchan_lookup with OpenBSC
-/* determine logical channel based on TRX and channel number IE */
-struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr)
+static struct gsm_lchan *lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr)
 {
-	struct gsm_lchan *lchan;
-	uint8_t ts_nr = chan_nr & 0x07;
-	uint8_t cbits = chan_nr >> 3;
-	uint8_t lch_idx;
-	struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
+	int rc;
+	struct gsm_lchan *lchan = rsl_lchan_lookup(trx, chan_nr, &rc);
 
-	if (cbits == 0x01) {
-		lch_idx = 0;	/* TCH/F */	
-		if (ts->pchan != GSM_PCHAN_TCH_F &&
-		    ts->pchan != GSM_PCHAN_PDCH &&
-		    ts->pchan != GSM_PCHAN_TCH_F_PDCH)
-			LOGP(DRSL, LOGL_ERROR, "chan_nr=0x%02x but pchan=%u\n",
-				chan_nr, ts->pchan);
-	} else if ((cbits & 0x1e) == 0x02) {
-		lch_idx = cbits & 0x1;	/* TCH/H */
-		if (ts->pchan != GSM_PCHAN_TCH_H)
-			LOGP(DRSL, LOGL_ERROR, "chan_nr=0x%02x but pchan=%u\n",
-				chan_nr, ts->pchan);
-	} else if ((cbits & 0x1c) == 0x04) {
-		lch_idx = cbits & 0x3;	/* SDCCH/4 */
-		if (ts->pchan != GSM_PCHAN_CCCH_SDCCH4 &&
-		    ts->pchan != GSM_PCHAN_CCCH_SDCCH4_CBCH)
-			LOGP(DRSL, LOGL_ERROR, "chan_nr=0x%02x but pchan=%u\n",
-				chan_nr, ts->pchan);
-	} else if ((cbits & 0x18) == 0x08) {
-		lch_idx = cbits & 0x7;	/* SDCCH/8 */
-		if (ts->pchan != GSM_PCHAN_SDCCH8_SACCH8C &&
-		    ts->pchan != GSM_PCHAN_SDCCH8_SACCH8C_CBCH)
-			LOGP(DRSL, LOGL_ERROR, "chan_nr=0x%02x but pchan=%u\n",
-				chan_nr, ts->pchan);
-	} else if (cbits == 0x10 || cbits == 0x11 || cbits == 0x12) {
-		lch_idx = 0;
-		if (ts->pchan != GSM_PCHAN_CCCH &&
-		    ts->pchan != GSM_PCHAN_CCCH_SDCCH4)
-			LOGP(DRSL, LOGL_ERROR, "chan_nr=0x%02x but pchan=%u\n",
-				chan_nr, ts->pchan);
-		/* FIXME: we should not return first sdcch4 !!! */
-	} else {
+	if (!lchan) {
 		LOGP(DRSL, LOGL_ERROR, "unknown chan_nr=0x%02x\n", chan_nr);
 		return NULL;
 	}
 
-	lchan = &ts->lchan[lch_idx];
-#if 0
-	log_set_context(BSC_CTX_LCHAN, lchan);
-	if (lchan->conn)
-		log_set_context(BSC_CTX_SUBSCR, lchan->conn->subscr);
-#endif
-
+	if (rc < 0)
+		LOGP(DRSL, LOGL_ERROR, "%s mismatching chan_nr=0x%02x\n",
+		     gsm_ts_and_pchan_name(lchan->ts), chan_nr);
 	return lchan;
 }
 
@@ -1919,7 +1879,7 @@
 	}
 	msg->l3h = (unsigned char *)rh + sizeof(*rh);
 
-	lchan = rsl_lchan_lookup(trx, rh->chan_nr);
+	lchan = lchan_lookup(trx, rh->chan_nr);
 	if (!lchan) {
 		LOGP(DRLL, LOGL_NOTICE, "Rx RLL %s for unknown lchan\n",
 			rsl_msg_name(rh->c.msg_type));
@@ -2063,7 +2023,7 @@
 	}
 	msg->l3h = (unsigned char *)cch + sizeof(*cch);
 
-	msg->lchan = rsl_lchan_lookup(trx, cch->chan_nr);
+	msg->lchan = lchan_lookup(trx, cch->chan_nr);
 	if (!msg->lchan) {
 		LOGP(DRSL, LOGL_ERROR, "Rx RSL %s for unknown lchan\n",
 			rsl_msg_name(cch->c.msg_type));
@@ -2117,7 +2077,7 @@
 	}
 	msg->l3h = (unsigned char *)dch + sizeof(*dch);
 
-	msg->lchan = rsl_lchan_lookup(trx, dch->chan_nr);
+	msg->lchan = lchan_lookup(trx, dch->chan_nr);
 	if (!msg->lchan) {
 		LOGP(DRSL, LOGL_ERROR, "Rx RSL %s for unknown lchan\n",
 			rsl_or_ipac_msg_name(dch->c.msg_type));
@@ -2216,7 +2176,7 @@
 	}
 	msg->l3h = (unsigned char *)dch + sizeof(*dch);
 
-	msg->lchan = rsl_lchan_lookup(trx, dch->chan_nr);
+	msg->lchan = lchan_lookup(trx, dch->chan_nr);
 	if (!msg->lchan) {
 		LOGP(DRSL, LOGL_ERROR, "Rx RSL %s for unknow lchan\n",
 			rsl_msg_name(dch->c.msg_type));

-- 
To view, visit https://gerrit.osmocom.org/604
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibc469b75e31560271be8633d524366442d27e6fb
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list