[PATCH] osmocom-bb[master]: VIRT-PHY: Extracted common virtphy utils.

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
Wed Jul 12 21:20:48 UTC 2017


Review at  https://gerrit.osmocom.org/3214

VIRT-PHY: Extracted common virtphy utils.

Change-Id: I759c6e9805ab012f9553bcba9b5d379193462955
---
A src/host/virt_phy/include/virtphy/common_util.h
M src/host/virt_phy/src/Makefile.am
M src/host/virt_phy/src/gsmtapl1_if.c
A src/host/virt_phy/src/shared/common_util.c
4 files changed, 96 insertions(+), 78 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/14/3214/1

diff --git a/src/host/virt_phy/include/virtphy/common_util.h b/src/host/virt_phy/include/virtphy/common_util.h
new file mode 100644
index 0000000..672ff93
--- /dev/null
+++ b/src/host/virt_phy/include/virtphy/common_util.h
@@ -0,0 +1,51 @@
+/*
+ * Utility function used both in osmo bts virt and osmocom bb virt.
+ */
+
+#pragma once
+
+#include <osmocom/core/gsmtap.h>
+#include <osmocom/gsm/rsl.h>
+
+#define LID_SACCH 		0x40
+#define LID_DEDIC 		0x00
+
+/*! \brief convert GSMTAP channel type to RSL channel number
+ *  \param[in] gsmtap_chantype GSMTAP channel type
+ *  \param[out] rsl_chantype rsl channel type
+ *  \param[out] rsl_chantype rsl link id
+ *
+ *  Mapping from gsmtap channel:
+ *  GSMTAP_CHANNEL_UNKNOWN *  0x00
+ *  GSMTAP_CHANNEL_BCCH *  0x01
+ *  GSMTAP_CHANNEL_CCCH *  0x02
+ *  GSMTAP_CHANNEL_RACH *  0x03
+ *  GSMTAP_CHANNEL_AGCH *  0x04
+ *  GSMTAP_CHANNEL_PCH *  0x05
+ *  GSMTAP_CHANNEL_SDCCH *  0x06
+ *  GSMTAP_CHANNEL_SDCCH4 *  0x07
+ *  GSMTAP_CHANNEL_SDCCH8 *  0x08
+ *  GSMTAP_CHANNEL_TCH_F *  0x09
+ *  GSMTAP_CHANNEL_TCH_H *  0x0a
+ *  GSMTAP_CHANNEL_PACCH *  0x0b
+ *  GSMTAP_CHANNEL_CBCH52 *  0x0c
+ *  GSMTAP_CHANNEL_PDCH *  0x0d
+ *  GSMTAP_CHANNEL_PTCCH *  0x0e
+ *  GSMTAP_CHANNEL_CBCH51 *  0x0f
+ *  to rsl channel type:
+ *  RSL_CHAN_NR_MASK *  0xf8
+ *  RSL_CHAN_NR_1 *   *  0x08
+ *  RSL_CHAN_Bm_ACCHs *  0x08
+ *  RSL_CHAN_Lm_ACCHs *  0x10
+ *  RSL_CHAN_SDCCH4_ACCH *  0x20
+ *  RSL_CHAN_SDCCH8_ACCH *  0x40
+ *  RSL_CHAN_BCCH *   *  0x80
+ *  RSL_CHAN_RACH *   *  0x88
+ *  RSL_CHAN_PCH_AGCH *  0x90
+ *  RSL_CHAN_OSMO_PDCH *  0xc0
+ *  and logical channel link id:
+ *  LID_SACCH  *   *  0x40
+ *  LID_DEDIC  *   *  0x00
+ */
+void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype,
+                         uint8_t *link_id);
diff --git a/src/host/virt_phy/src/Makefile.am b/src/host/virt_phy/src/Makefile.am
index d34b8ad..6628bce 100644
--- a/src/host/virt_phy/src/Makefile.am
+++ b/src/host/virt_phy/src/Makefile.am
@@ -4,7 +4,7 @@
 CFLAGS = "-g -O0"
 
 sbin_PROGRAMS = virtphy
-virtphy_SOURCES = virtphy.c l1ctl_sock.c gsmtapl1_if.c l1ctl_sap.c virt_prim_pm.c virt_prim_fbsb.c virt_prim_rach.c virt_prim_data.c virt_prim_traffic.c virt_l1_sched_simple.c logging.c virt_l1_model.c shared/virtual_um.c shared/osmo_mcast_sock.c
+virtphy_SOURCES = virtphy.c l1ctl_sock.c gsmtapl1_if.c l1ctl_sap.c virt_prim_pm.c virt_prim_fbsb.c virt_prim_rach.c virt_prim_data.c virt_prim_traffic.c virt_l1_sched_simple.c logging.c virt_l1_model.c shared/virtual_um.c shared/osmo_mcast_sock.c shared/common_util.c
 virtphy_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) 
 virtphy_LDFLAGS = -pthread
 
diff --git a/src/host/virt_phy/src/gsmtapl1_if.c b/src/host/virt_phy/src/gsmtapl1_if.c
index 401df9e..1a2c085 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -282,80 +282,3 @@
 {
 	gsmtapl1_rx_from_virt_um_inst_cb(l1_model_ms->vui, msg);
 }
-
-/*! \brief convert GSMTAP channel type to RSL channel number
- *  \param[in] gsmtap_chantype GSMTAP channel type
- *  \param[out] rsl_chantype rsl channel type
- *  \param[out] rsl_chantype rsl link id
- *
- *  Mapping from gsmtap channel:
- *  GSMTAP_CHANNEL_UNKNOWN *  0x00
- *  GSMTAP_CHANNEL_BCCH *  0x01
- *  GSMTAP_CHANNEL_CCCH *  0x02
- *  GSMTAP_CHANNEL_RACH *  0x03
- *  GSMTAP_CHANNEL_AGCH *  0x04
- *  GSMTAP_CHANNEL_PCH *  0x05
- *  GSMTAP_CHANNEL_SDCCH *  0x06
- *  GSMTAP_CHANNEL_SDCCH4 *  0x07
- *  GSMTAP_CHANNEL_SDCCH8 *  0x08
- *  GSMTAP_CHANNEL_TCH_F *  0x09
- *  GSMTAP_CHANNEL_TCH_H *  0x0a
- *  GSMTAP_CHANNEL_PACCH *  0x0b
- *  GSMTAP_CHANNEL_CBCH52 *  0x0c
- *  GSMTAP_CHANNEL_PDCH *  0x0d
- *  GSMTAP_CHANNEL_PTCCH *  0x0e
- *  GSMTAP_CHANNEL_CBCH51 *  0x0f
- *  to rsl channel type:
- *  RSL_CHAN_NR_MASK *  0xf8
- *  RSL_CHAN_NR_1 *   *  0x08
- *  RSL_CHAN_Bm_ACCHs *  0x08
- *  RSL_CHAN_Lm_ACCHs *  0x10
- *  RSL_CHAN_SDCCH4_ACCH *  0x20
- *  RSL_CHAN_SDCCH8_ACCH *  0x40
- *  RSL_CHAN_BCCH *   *  0x80
- *  RSL_CHAN_RACH *   *  0x88
- *  RSL_CHAN_PCH_AGCH *  0x90
- *  RSL_CHAN_OSMO_PDCH *  0xc0
- *  and logical channel link id:
- *  LID_SACCH  *   *  0x40
- *  LID_DEDIC  *   *  0x00
- *
- *  TODO: move this to a library used by both ms and bts virt um
- */
-void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype,
-                         uint8_t *link_id)
-{
-	// switch case with removed acch flag
-	switch (gsmtap_chantype & ~GSMTAP_CHANNEL_ACCH & 0xff) {
-	case GSMTAP_CHANNEL_TCH_F: // TCH/F, FACCH/F
-		*rsl_chantype = RSL_CHAN_Bm_ACCHs;
-		break;
-	case GSMTAP_CHANNEL_TCH_H: // TCH/H, FACCH/H
-		*rsl_chantype = RSL_CHAN_Lm_ACCHs;
-		break;
-	case GSMTAP_CHANNEL_SDCCH4: // SDCCH/4
-		*rsl_chantype = RSL_CHAN_SDCCH4_ACCH;
-		break;
-	case GSMTAP_CHANNEL_SDCCH8: // SDCCH/8
-		*rsl_chantype = RSL_CHAN_SDCCH8_ACCH;
-		break;
-	case GSMTAP_CHANNEL_BCCH: // BCCH
-		*rsl_chantype = RSL_CHAN_BCCH;
-		break;
-	case GSMTAP_CHANNEL_RACH: // RACH
-		*rsl_chantype = RSL_CHAN_RACH;
-		break;
-	case GSMTAP_CHANNEL_PCH: // PCH
-	case GSMTAP_CHANNEL_AGCH: // AGCH
-		*rsl_chantype = RSL_CHAN_PCH_AGCH;
-		break;
-	case GSMTAP_CHANNEL_PDCH:
-		*rsl_chantype = GSMTAP_CHANNEL_PDCH;
-		break;
-	}
-
-	*link_id = gsmtap_chantype & GSMTAP_CHANNEL_ACCH ?
-	LID_SACCH :
-	                                                   LID_DEDIC;
-
-}
diff --git a/src/host/virt_phy/src/shared/common_util.c b/src/host/virt_phy/src/shared/common_util.c
new file mode 100644
index 0000000..49dea18
--- /dev/null
+++ b/src/host/virt_phy/src/shared/common_util.c
@@ -0,0 +1,44 @@
+/*
+ * Utility function used both in osmo bts virt and osmocom bb virt.
+ */
+
+#include <osmocom/core/gsmtap.h>
+#include <osmocom/gsm/rsl.h>
+#include <virtphy/common_util.h>
+
+void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype,
+                         uint8_t *link_id)
+{
+	// switch case with removed acch flag
+	switch (gsmtap_chantype & ~GSMTAP_CHANNEL_ACCH & 0xff) {
+	case GSMTAP_CHANNEL_TCH_F: // TCH/F, FACCH/F
+		*rsl_chantype = RSL_CHAN_Bm_ACCHs;
+		break;
+	case GSMTAP_CHANNEL_TCH_H: // TCH/H, FACCH/H
+		*rsl_chantype = RSL_CHAN_Lm_ACCHs;
+		break;
+	case GSMTAP_CHANNEL_SDCCH4: // SDCCH/4
+		*rsl_chantype = RSL_CHAN_SDCCH4_ACCH;
+		break;
+	case GSMTAP_CHANNEL_SDCCH8: // SDCCH/8
+		*rsl_chantype = RSL_CHAN_SDCCH8_ACCH;
+		break;
+	case GSMTAP_CHANNEL_BCCH: // BCCH
+		*rsl_chantype = RSL_CHAN_BCCH;
+		break;
+	case GSMTAP_CHANNEL_RACH: // RACH
+		*rsl_chantype = RSL_CHAN_RACH;
+		break;
+	case GSMTAP_CHANNEL_PCH: // PCH
+	case GSMTAP_CHANNEL_AGCH: // AGCH
+		*rsl_chantype = RSL_CHAN_PCH_AGCH;
+		break;
+	case GSMTAP_CHANNEL_PDCH:
+		*rsl_chantype = GSMTAP_CHANNEL_PDCH;
+		break;
+	}
+
+	*link_id = gsmtap_chantype & GSMTAP_CHANNEL_ACCH ? LID_SACCH :
+	                                                   LID_DEDIC;
+
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I759c6e9805ab012f9553bcba9b5d379193462955
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: BastusIII <sebastian.stumpf87 at googlemail.com>



More information about the gerrit-log mailing list