Make get_lchan_by_chan_nr globally available

* Remove static qualifier
* Remove duplicated code - use generic function instead

Change-Id: I37a312648771f58d3087471083cfcebbd97ccf1d
This commit is contained in:
Max 2016-06-23 15:39:31 +02:00 committed by Harald Welte
parent 4fa641d7b2
commit 5c0d88e69d
6 changed files with 21 additions and 42 deletions

View File

@ -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);

View File

@ -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)];
}

View File

@ -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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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"