aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-06-23 15:39:31 +0200
committerHarald Welte <laforge@gnumonks.org>2016-06-23 20:00:44 +0000
commit5c0d88e69d16426d8e7af5bf4b7866aa33132064 (patch)
treefbaecee280b714d79e394e1d8b75da8a73d6a441
parent4fa641d7b22116c7b1af0bf80ebe6ab78a06cee9 (diff)
Make get_lchan_by_chan_nr globally available
* Remove static qualifier * Remove duplicated code - use generic function instead Change-Id: I37a312648771f58d3087471083cfcebbd97ccf1d
-rw-r--r--include/osmo-bts/l1sap.h2
-rw-r--r--src/common/l1sap.c4
-rw-r--r--src/osmo-bts-litecell15/l1_if.c16
-rw-r--r--src/osmo-bts-octphy/l1_if.c16
-rw-r--r--src/osmo-bts-sysmo/l1_if.c16
-rw-r--r--src/osmo-bts-trx/l1_if.c9
6 files changed, 21 insertions, 42 deletions
diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h
index dd25161..2735574 100644
--- a/include/osmo-bts/l1sap.h
+++ b/include/osmo-bts/l1sap.h
@@ -40,6 +40,8 @@ static inline uint8_t l1sap_chan2ss(uint8_t chan_nr)
return 0;
}
+struct gsm_lchan *get_lchan_by_chan_nr(struct gsm_bts_trx *trx,
+ unsigned int chan_nr);
/* allocate a msgb containing a osmo_phsap_prim + optional l2 data */
struct msgb *l1sap_msgb_alloc(unsigned int l2_len);
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 0a6bc49..5ea2a2c 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -47,8 +47,8 @@
#include <osmo-bts/handover.h>
#include <osmo-bts/power_control.h>
-static struct gsm_lchan *
-get_lchan_by_chan_nr(struct gsm_bts_trx *trx, unsigned int chan_nr)
+struct gsm_lchan *get_lchan_by_chan_nr(struct gsm_bts_trx *trx,
+ unsigned int chan_nr)
{
return &trx->ts[L1SAP_CHAN2TS(chan_nr)].lchan[l1sap_chan2ss(chan_nr)];
}
diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c
index 395ee0d..2af2481 100644
--- a/src/osmo-bts-litecell15/l1_if.c
+++ b/src/osmo-bts-litecell15/l1_if.c
@@ -439,7 +439,7 @@ static int ph_tch_req(struct gsm_bts_trx *trx, struct msgb *msg,
struct lc15l1_hdl *fl1 = trx_lc15l1_hdl(trx);
struct gsm_lchan *lchan;
uint32_t u32Fn;
- uint8_t u8Tn, subCh, u8BlockNbr = 0, sapi, ss;
+ uint8_t u8Tn, subCh, u8BlockNbr = 0, sapi;
uint8_t chan_nr;
GsmL1_Prim_t *l1p;
struct msgb *nmsg = NULL;
@@ -449,15 +449,14 @@ static int ph_tch_req(struct gsm_bts_trx *trx, struct msgb *msg,
u8Tn = L1SAP_CHAN2TS(chan_nr);
u8BlockNbr = (u32Fn % 13) >> 2;
if (L1SAP_IS_CHAN_TCHH(chan_nr)) {
- ss = subCh = L1SAP_CHAN2SS_TCHH(chan_nr);
+ subCh = L1SAP_CHAN2SS_TCHH(chan_nr);
sapi = GsmL1_Sapi_TchH;
} else {
subCh = 0x1f;
- ss = 0;
sapi = GsmL1_Sapi_TchF;
}
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
/* create new message and fill data */
if (msg) {
@@ -509,7 +508,6 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
struct osmo_phsap_prim *l1sap)
{
struct lc15l1_hdl *fl1 = trx_lc15l1_hdl(trx);
- uint8_t u8Tn, ss;
uint8_t chan_nr;
struct gsm_lchan *lchan;
int rc = 0;
@@ -517,9 +515,7 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
switch (l1sap->u.info.type) {
case PRIM_INFO_ACT_CIPH:
chan_nr = l1sap->u.info.u.ciph_req.chan_nr;
- u8Tn = L1SAP_CHAN2TS(chan_nr);
- ss = l1sap_chan2ss(chan_nr);
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (l1sap->u.info.u.ciph_req.uplink) {
l1if_set_ciphering(fl1, lchan, 0);
lchan->ciph_state = LCHAN_CIPH_RX_REQ;
@@ -536,9 +532,7 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
case PRIM_INFO_DEACTIVATE:
case PRIM_INFO_MODIFY:
chan_nr = l1sap->u.info.u.act_req.chan_nr;
- u8Tn = L1SAP_CHAN2TS(chan_nr);
- ss = l1sap_chan2ss(chan_nr);
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (l1sap->u.info.type == PRIM_INFO_ACTIVATE)
l1if_rsl_chan_act(lchan);
else if (l1sap->u.info.type == PRIM_INFO_MODIFY) {
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index c8ed216..760c988 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -546,7 +546,7 @@ static int ph_tch_req(struct gsm_bts_trx *trx, struct msgb *msg,
struct octphy_hdl *fl1h = pinst->phy_link->u.octphy.hdl;
struct gsm_lchan *lchan;
uint32_t u32Fn;
- uint8_t u8Tn, subCh, sapi, ss;
+ uint8_t u8Tn, subCh, sapi;
uint8_t chan_nr;
struct msgb *nmsg = NULL;
@@ -554,15 +554,14 @@ static int ph_tch_req(struct gsm_bts_trx *trx, struct msgb *msg,
u32Fn = l1sap->u.tch.fn;
u8Tn = L1SAP_CHAN2TS(chan_nr);
if (L1SAP_IS_CHAN_TCHH(chan_nr)) {
- ss = subCh = L1SAP_CHAN2SS_TCHH(chan_nr);
+ subCh = L1SAP_CHAN2SS_TCHH(chan_nr);
sapi = cOCTVC1_GSM_SAPI_ENUM_TCHH;
} else {
subCh = 0xf1;
- ss = 0;
sapi = cOCTVC1_GSM_SAPI_ENUM_TCHF;
}
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
/* create new message */
nmsg = l1p_msgb_alloc();
@@ -623,7 +622,6 @@ static int ph_tch_req(struct gsm_bts_trx *trx, struct msgb *msg,
static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
struct osmo_phsap_prim *l1sap)
{
- uint8_t u8Tn, ss;
uint8_t chan_nr;
struct gsm_lchan *lchan;
int rc = 0;
@@ -631,9 +629,7 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
switch (l1sap->u.info.type) {
case PRIM_INFO_ACT_CIPH:
chan_nr = l1sap->u.info.u.ciph_req.chan_nr;
- u8Tn = L1SAP_CHAN2TS(chan_nr);
- ss = l1sap_chan2ss(chan_nr);
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (l1sap->u.info.u.ciph_req.uplink) {
l1if_set_ciphering(lchan, 0);
lchan->ciph_state = LCHAN_CIPH_RX_REQ;
@@ -650,9 +646,7 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
case PRIM_INFO_DEACTIVATE:
case PRIM_INFO_MODIFY:
chan_nr = l1sap->u.info.u.act_req.chan_nr;
- u8Tn = L1SAP_CHAN2TS(chan_nr);
- ss = l1sap_chan2ss(chan_nr);
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (l1sap->u.info.type == PRIM_INFO_ACTIVATE)
l1if_rsl_chan_act(lchan);
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index 0330308..355507d 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -432,7 +432,7 @@ static int ph_tch_req(struct gsm_bts_trx *trx, struct msgb *msg,
struct femtol1_hdl *fl1 = trx_femtol1_hdl(trx);
struct gsm_lchan *lchan;
uint32_t u32Fn;
- uint8_t u8Tn, subCh, u8BlockNbr = 0, sapi, ss;
+ uint8_t u8Tn, subCh, u8BlockNbr = 0, sapi;
uint8_t chan_nr;
GsmL1_Prim_t *l1p;
struct msgb *nmsg = NULL;
@@ -442,15 +442,14 @@ static int ph_tch_req(struct gsm_bts_trx *trx, struct msgb *msg,
u8Tn = L1SAP_CHAN2TS(chan_nr);
u8BlockNbr = (u32Fn % 13) >> 2;
if (L1SAP_IS_CHAN_TCHH(chan_nr)) {
- ss = subCh = L1SAP_CHAN2SS_TCHH(chan_nr);
+ subCh = L1SAP_CHAN2SS_TCHH(chan_nr);
sapi = GsmL1_Sapi_TchH;
} else {
subCh = 0x1f;
- ss = 0;
sapi = GsmL1_Sapi_TchF;
}
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
/* create new message and fill data */
if (msg) {
@@ -501,7 +500,6 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
struct osmo_phsap_prim *l1sap)
{
struct femtol1_hdl *fl1 = trx_femtol1_hdl(trx);
- uint8_t u8Tn, ss;
uint8_t chan_nr;
struct gsm_lchan *lchan;
int rc = 0;
@@ -509,9 +507,7 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
switch (l1sap->u.info.type) {
case PRIM_INFO_ACT_CIPH:
chan_nr = l1sap->u.info.u.ciph_req.chan_nr;
- u8Tn = L1SAP_CHAN2TS(chan_nr);
- ss = l1sap_chan2ss(chan_nr);
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (l1sap->u.info.u.ciph_req.uplink) {
l1if_set_ciphering(fl1, lchan, 0);
lchan->ciph_state = LCHAN_CIPH_RX_REQ;
@@ -528,9 +524,7 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
case PRIM_INFO_DEACTIVATE:
case PRIM_INFO_MODIFY:
chan_nr = l1sap->u.info.u.act_req.chan_nr;
- u8Tn = L1SAP_CHAN2TS(chan_nr);
- ss = l1sap_chan2ss(chan_nr);
- lchan = &trx->ts[u8Tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (l1sap->u.info.type == PRIM_INFO_ACTIVATE)
l1if_rsl_chan_act(lchan);
else if (l1sap->u.info.type == PRIM_INFO_MODIFY) {
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 59442d9..0a3e48d 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -527,7 +527,6 @@ int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
struct msgb *msg = l1sap->oph.msg;
uint8_t chan_nr;
- uint8_t tn, ss;
int rc = 0;
struct gsm_lchan *lchan;
@@ -546,9 +545,7 @@ int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
switch (l1sap->u.info.type) {
case PRIM_INFO_ACT_CIPH:
chan_nr = l1sap->u.info.u.ciph_req.chan_nr;
- tn = L1SAP_CHAN2TS(chan_nr);
- ss = l1sap_chan2ss(chan_nr);
- lchan = &trx->ts[tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (l1sap->u.info.u.ciph_req.uplink)
l1if_set_ciphering(l1h, lchan, chan_nr, 0);
if (l1sap->u.info.u.ciph_req.downlink)
@@ -558,9 +555,7 @@ int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
case PRIM_INFO_DEACTIVATE:
case PRIM_INFO_MODIFY:
chan_nr = l1sap->u.info.u.act_req.chan_nr;
- tn = L1SAP_CHAN2TS(chan_nr);
- ss = l1sap_chan2ss(chan_nr);
- lchan = &trx->ts[tn].lchan[ss];
+ lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (l1sap->u.info.type == PRIM_INFO_ACTIVATE) {
if ((chan_nr & 0x80)) {
LOGP(DL1C, LOGL_ERROR, "Cannot activate"