Change in osmo-bsc[master]: add chan_mode_to_chan_type()

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/.

neels gerrit-no-reply at lists.osmocom.org
Tue Jun 1 17:29:44 UTC 2021


neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/24367 )

Change subject: add chan_mode_to_chan_type()
......................................................................

add chan_mode_to_chan_type()

Move the conversion from chan_mode to lchan type out of the
lchan_select_by_chan_mode() function, so that the conversion can be used
by other code paths, coming up in VAMOS patches.

Related: SYS#5315 OS#4940
Change-Id: I296651ebadba81f8b3db0d9bb5b5377877a43677
---
M include/osmocom/bsc/lchan_select.h
M src/osmo-bsc/lchan_select.c
2 files changed, 25 insertions(+), 15 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved



diff --git a/include/osmocom/bsc/lchan_select.h b/include/osmocom/bsc/lchan_select.h
index 11f63b0..aa2f40e 100644
--- a/include/osmocom/bsc/lchan_select.h
+++ b/include/osmocom/bsc/lchan_select.h
@@ -2,6 +2,7 @@
 #pragma once
 
 struct gsm_lchan *lchan_select_by_type(struct gsm_bts *bts, enum gsm_chan_t type);
+enum gsm_chan_t chan_mode_to_chan_type(enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate);
 struct gsm_lchan *lchan_select_by_chan_mode(struct gsm_bts *bts,
 					    enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate);
 struct gsm_lchan *lchan_avail_by_type(struct gsm_bts *bts, enum gsm_chan_t type, bool log);
diff --git a/src/osmo-bsc/lchan_select.c b/src/osmo-bsc/lchan_select.c
index 626520c..b494f02 100644
--- a/src/osmo-bsc/lchan_select.c
+++ b/src/osmo-bsc/lchan_select.c
@@ -142,37 +142,46 @@
 	return _lc_dyn_find_bts(bts, pchan, pchan, log);
 }
 
-struct gsm_lchan *lchan_select_by_chan_mode(struct gsm_bts *bts,
-					    enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate)
+enum gsm_chan_t chan_mode_to_chan_type(enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate)
 {
-	enum gsm_chan_t type;
-
 	switch (chan_mode) {
 	case GSM48_CMODE_SIGN:
 		switch (chan_rate) {
-		case CH_RATE_SDCCH: type = GSM_LCHAN_SDCCH; break;
-		case CH_RATE_HALF:  type = GSM_LCHAN_TCH_H; break;
-		case CH_RATE_FULL:  type = GSM_LCHAN_TCH_F; break;
-		default: return NULL;
+		case CH_RATE_SDCCH:
+			return GSM_LCHAN_SDCCH;
+		case CH_RATE_HALF:
+			return GSM_LCHAN_TCH_H;
+		case CH_RATE_FULL:
+			return GSM_LCHAN_TCH_F;
+		default:
+			return GSM_LCHAN_NONE;
 		}
-		break;
 	case GSM48_CMODE_SPEECH_EFR:
 		/* EFR works over FR channels only */
 		if (chan_rate != CH_RATE_FULL)
-			return NULL;
+			return GSM_LCHAN_NONE;
 		/* fall through */
 	case GSM48_CMODE_SPEECH_V1:
 	case GSM48_CMODE_SPEECH_AMR:
 		switch (chan_rate) {
-		case CH_RATE_HALF:  type = GSM_LCHAN_TCH_H; break;
-		case CH_RATE_FULL:  type = GSM_LCHAN_TCH_F; break;
-		default: return NULL;
+		case CH_RATE_HALF:
+			return GSM_LCHAN_TCH_H;
+		case CH_RATE_FULL:
+			return GSM_LCHAN_TCH_F;
+		default:
+			return GSM_LCHAN_NONE;
 		}
-		break;
 	default:
-		return NULL;
+		return GSM_LCHAN_NONE;
 	}
+}
 
+struct gsm_lchan *lchan_select_by_chan_mode(struct gsm_bts *bts,
+					    enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate)
+{
+	enum gsm_chan_t type = chan_mode_to_chan_type(chan_mode, chan_rate);
+	if (type == GSM_LCHAN_NONE)
+		return NULL;
 	return lchan_select_by_type(bts, type);
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/24367
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I296651ebadba81f8b3db0d9bb5b5377877a43677
Gerrit-Change-Number: 24367
Gerrit-PatchSet: 9
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210601/56e9c3c1/attachment.htm>


More information about the gerrit-log mailing list