aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-02-27 09:41:30 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-02-27 10:31:30 +0100
commit305d8314bce8f10d9c42aa8e19ccd7960fc5f194 (patch)
treeffd65c5aba632115bee436e44a47c6882a487cb8
parentdc9148d0351878a79d689a9c6f60aff21b9d5b81 (diff)
parent5e46e4b4880f01eed508d49b66d96c1f7475ab89 (diff)
Merge branch 'zecke/request-queuing'
* Simplify the callback signature. The trx is now the first argument. * Embed the calibration data into the femtol1_hdl. Tests: * All commits are compile tested * All commits bring up the radio (without using calibration data) * Calibration data loading has been tested with the merge * All commits allow a IMSI Attach and a MO Call (to an invalid unknown number). All channels are freed after this. It has been tested with the E71.
-rw-r--r--src/osmo-bts-sysmo/calib_file.c29
-rw-r--r--src/osmo-bts-sysmo/l1_if.c50
-rw-r--r--src/osmo-bts-sysmo/l1_if.h13
-rw-r--r--src/osmo-bts-sysmo/oml.c49
4 files changed, 75 insertions, 66 deletions
diff --git a/src/osmo-bts-sysmo/calib_file.c b/src/osmo-bts-sysmo/calib_file.c
index 081444fa..43156565 100644
--- a/src/osmo-bts-sysmo/calib_file.c
+++ b/src/osmo-bts-sysmo/calib_file.c
@@ -27,6 +27,7 @@
#include <osmocom/core/utils.h>
+#include <osmo-bts/gsm_data.h>
#include <osmo-bts/logging.h>
#include <sysmocom/femtobts/superfemto.h>
@@ -199,17 +200,11 @@ int calib_file_read(const char *path, const struct calib_file_desc *desc,
/* iteratively download the calibration data into the L1 */
-struct calib_send_state {
- struct femtol1_hdl *fl1h;
- const char *path;
- int last_file_idx;
-};
-
-static int calib_send_compl_cb(struct msgb *l1_msg, void *data);
+static int calib_send_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg);
/* send the calibration table for a single specified file */
static int calib_file_send(struct femtol1_hdl *fl1h,
- const struct calib_file_desc *desc, void *state)
+ const struct calib_file_desc *desc)
{
struct msgb *msg;
int rc;
@@ -222,13 +217,14 @@ static int calib_file_send(struct femtol1_hdl *fl1h,
return rc;
}
- return l1if_req_compl(fl1h, msg, 1, calib_send_compl_cb, state);
+ return l1if_req_compl(fl1h, msg, calib_send_compl_cb);
}
/* completion callback after every SetCalibTbl is confirmed */
-static int calib_send_compl_cb(struct msgb *l1_msg, void *data)
+static int calib_send_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
{
- struct calib_send_state *st = data;
+ struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx);
+ struct calib_send_state *st = &fl1h->st;
LOGP(DL1C, LOGL_DEBUG, "L1 calibration table %s loaded\n",
calib_files[st->last_file_idx].fname);
@@ -236,8 +232,8 @@ static int calib_send_compl_cb(struct msgb *l1_msg, void *data)
st->last_file_idx++;
if (st->last_file_idx < ARRAY_SIZE(calib_files))
- return calib_file_send(st->fl1h,
- &calib_files[st->last_file_idx], st);
+ return calib_file_send(fl1h,
+ &calib_files[st->last_file_idx]);
LOGP(DL1C, LOGL_INFO, "L1 calibration table loading complete!\n");
@@ -247,15 +243,10 @@ static int calib_send_compl_cb(struct msgb *l1_msg, void *data)
int calib_load(struct femtol1_hdl *fl1h)
{
- static struct calib_send_state st;
-
- memset(&st, 0, sizeof(st));
- st.fl1h = fl1h;
-
#if SUPERFEMTO_API_VERSION < SUPERFEMTO_API(2,4,0)
return -1;
#else
- return calib_file_send(fl1h, &calib_files[0], &st);
+ return calib_file_send(fl1h, &calib_files[0]);
#endif
}
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index 198ced48..d848f7de 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -181,9 +181,8 @@ static void l1if_req_timeout(void *data)
exit(23);
}
-/* send a request primitive to the L1 and schedule completion call-back */
-int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
- int is_system_prim, l1if_compl_cb *cb, void *data)
+static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
+ int is_system_prim, l1if_compl_cb *cb)
{
struct wait_l1_conf *wlc;
struct osmo_wqueue *wqueue;
@@ -192,7 +191,7 @@ int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
/* allocate new wsc and store reference to mutex and conf_id */
wlc = talloc_zero(fl1h, struct wait_l1_conf);
wlc->cb = cb;
- wlc->cb_data = data;
+ wlc->cb_data = NULL;
/* Make sure we actually have received a REQUEST type primitive */
if (is_system_prim == 0) {
@@ -241,10 +240,17 @@ int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
return 0;
}
+/* send a request primitive to the L1 and schedule completion call-back */
+int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
+ l1if_compl_cb *cb)
+{
+ return _l1if_req_compl(fl1h, msg, 1, cb);
+}
+
int l1if_gsm_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
- l1if_compl_cb *cb, void *data)
+ l1if_compl_cb *cb)
{
- return l1if_req_compl(fl1h, msg, 0, cb, data);
+ return _l1if_req_compl(fl1h, msg, 0, cb);
}
/* allocate a msgb containing a GsmL1_Prim_t */
@@ -875,9 +881,11 @@ int l1if_handle_l1prim(int wq, struct femtol1_hdl *fl1h, struct msgb *msg)
if (wlc->is_sys_prim == 0 && l1p->id == wlc->conf_prim_id) {
llist_del(&wlc->list);
if (wlc->cb)
- rc = wlc->cb(msg, wlc->cb_data);
- else
+ rc = wlc->cb(fl1h->priv, msg);
+ else {
rc = 0;
+ msgb_free(msg);
+ }
release_wlc(wlc);
return rc;
}
@@ -903,9 +911,11 @@ int l1if_handle_sysprim(struct femtol1_hdl *fl1h, struct msgb *msg)
if (wlc->is_sys_prim && sysp->id == wlc->conf_prim_id) {
llist_del(&wlc->list);
if (wlc->cb)
- rc = wlc->cb(msg, wlc->cb_data);
- else
+ rc = wlc->cb(fl1h->priv, msg);
+ else {
rc = 0;
+ msgb_free(msg);
+ }
release_wlc(wlc);
return rc;
}
@@ -930,11 +940,9 @@ int sysinfo_has_changed(struct gsm_bts *bts, int si)
}
#endif
-static int activate_rf_compl_cb(struct msgb *resp, void *data)
+static int activate_rf_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp)
{
SuperFemto_Prim_t *sysp = msgb_sysprim(resp);
- struct femtol1_hdl *fl1h = data;
- struct gsm_bts_trx *trx = fl1h->priv;
GsmL1_Status_t status;
int on = 0;
unsigned int i;
@@ -1014,16 +1022,15 @@ int l1if_activate_rf(struct femtol1_hdl *hdl, int on)
sysp->id = SuperFemto_PrimId_DeactivateRfReq;
}
- return l1if_req_compl(hdl, msg, 1, activate_rf_compl_cb, hdl);
+ return l1if_req_compl(hdl, msg, activate_rf_compl_cb);
}
/* call-back on arrival of DSP+FPGA version + band capability */
-static int info_compl_cb(struct msgb *resp, void *data)
+static int info_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp)
{
SuperFemto_Prim_t *sysp = msgb_sysprim(resp);
SuperFemto_SystemInfoCnf_t *sic = &sysp->u.systemInfoCnf;
- struct femtol1_hdl *fl1h = data;
- struct gsm_bts_trx *trx = fl1h->priv;
+ struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx);
fl1h->hw_info.dsp_version[0] = sic->dspVersion.major;
fl1h->hw_info.dsp_version[1] = sic->dspVersion.minor;
@@ -1067,13 +1074,12 @@ static int l1if_get_info(struct femtol1_hdl *hdl)
sysp->id = SuperFemto_PrimId_SystemInfoReq;
- return l1if_req_compl(hdl, msg, 1, info_compl_cb, hdl);
+ return l1if_req_compl(hdl, msg, info_compl_cb);
}
-static int reset_compl_cb(struct msgb *resp, void *data)
+static int reset_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp)
{
- struct femtol1_hdl *fl1h = data;
- struct gsm_bts_trx *trx = fl1h->priv;
+ struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx);
SuperFemto_Prim_t *sysp = msgb_sysprim(resp);
GsmL1_Status_t status = sysp->u.layer1ResetCnf.status;
@@ -1116,7 +1122,7 @@ int l1if_reset(struct femtol1_hdl *hdl)
SuperFemto_Prim_t *sysp = msgb_sysprim(msg);
sysp->id = SuperFemto_PrimId_Layer1ResetReq;
- return l1if_req_compl(hdl, msg, 1, reset_compl_cb, hdl);
+ return l1if_req_compl(hdl, msg, reset_compl_cb);
}
/* set the trace flags within the DSP */
diff --git a/src/osmo-bts-sysmo/l1_if.h b/src/osmo-bts-sysmo/l1_if.h
index 47d58de9..d564e3dc 100644
--- a/src/osmo-bts-sysmo/l1_if.h
+++ b/src/osmo-bts-sysmo/l1_if.h
@@ -27,6 +27,11 @@ enum {
_NUM_MQ_WRITE
};
+struct calib_send_state {
+ const char *path;
+ int last_file_idx;
+};
+
struct femtol1_hdl {
struct gsm_time gsm_time;
uint32_t hLayer1; /* handle to the L1 instance in the DSP */
@@ -53,18 +58,20 @@ struct femtol1_hdl {
uint8_t fpga_version[3];
uint32_t band_support; /* bitmask of GSM_BAND_* */
} hw_info;
+
+ struct calib_send_state st;
};
#define msgb_l1prim(msg) ((GsmL1_Prim_t *)(msg)->l1h)
#define msgb_sysprim(msg) ((SuperFemto_Prim_t *)(msg)->l1h)
-typedef int l1if_compl_cb(struct msgb *l1_msg, void *data);
+typedef int l1if_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg);
/* send a request primitive to the L1 and schedule completion call-back */
int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
- int is_system_prim, l1if_compl_cb *cb, void *data);
+ l1if_compl_cb *cb);
int l1if_gsm_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
- l1if_compl_cb *cb, void *data);
+ l1if_compl_cb *cb);
struct femtol1_hdl *l1if_open(void *priv);
int l1if_close(struct femtol1_hdl *hdl);
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index ce1a94e7..bf4fe158 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -179,9 +179,8 @@ static int compl_cb_send_oml_msg(struct msgb *l1_msg, void *data)
int lchan_activate(struct gsm_lchan *lchan);
-static int opstart_compl_cb(struct msgb *l1_msg, void *data)
+static int opstart_compl(struct gsm_abis_mo *mo, struct msgb *l1_msg)
{
- struct gsm_abis_mo *mo = data;
GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg);
GsmL1_Status_t status = prim_status(l1p);
@@ -208,10 +207,19 @@ static int opstart_compl_cb(struct msgb *l1_msg, void *data)
return oml_mo_opstart_ack(mo);
}
-static int trx_init_compl_cb(struct msgb *l1_msg, void *data)
+static int opstart_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
{
- struct femtol1_hdl *fl1h = data;
- struct gsm_bts_trx *trx = fl1h->priv;
+ struct gsm_abis_mo *mo;
+ GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg);
+ GsmL1_MphConnectCnf_t *cnf = &l1p->u.mphConnectCnf;
+
+ mo = &trx->ts[cnf->u8Tn].mo;
+ return opstart_compl(mo, l1_msg);
+}
+
+static int trx_init_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
+{
+ struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx);
GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg);
GsmL1_MphInitCnf_t *ic = &l1p->u.mphInitCnf;
@@ -228,7 +236,7 @@ static int trx_init_compl_cb(struct msgb *l1_msg, void *data)
fl1h->hLayer1 = ic->hLayer1;
- return opstart_compl_cb(l1_msg, &trx->mo);
+ return opstart_compl(&trx->mo, l1_msg);
}
int gsm_abis_mo_check_attr(const struct gsm_abis_mo *mo, const uint8_t *attr_ids,
@@ -286,7 +294,7 @@ static int trx_init(struct gsm_bts_trx *trx)
dev_par->fRxPowerLevel, dev_par->fTxPowerLevel);
/* send MPH-INIT-REQ, wait for MPH-INIT-CNF */
- return l1if_gsm_req_compl(fl1h, msg, trx_init_compl_cb, fl1h);
+ return l1if_gsm_req_compl(fl1h, msg, trx_init_compl_cb);
}
uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx)
@@ -296,7 +304,7 @@ uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx)
return fl1h->hLayer1;
}
-static int trx_close_compl_cb(struct msgb *l1_msg, void *data)
+static int trx_close_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
{
msgb_free(l1_msg);
return 0;
@@ -311,7 +319,7 @@ static int trx_close(struct gsm_bts_trx *trx)
prim_init(msgb_l1prim(msg), GsmL1_PrimId_MphCloseReq, fl1h);
LOGP(DL1C, LOGL_NOTICE, "Close TRX %u\n", trx->nr);
- return l1if_gsm_req_compl(fl1h, msg, trx_close_compl_cb, fl1h);
+ return l1if_gsm_req_compl(fl1h, msg, trx_close_compl_cb);
}
static int ts_connect(struct gsm_bts_trx_ts *ts)
@@ -324,7 +332,7 @@ static int ts_connect(struct gsm_bts_trx_ts *ts)
cr->u8Tn = ts->nr;
cr->logChComb = pchan_to_logChComb[ts->pchan];
- return l1if_gsm_req_compl(fl1h, msg, opstart_compl_cb, &ts->mo);
+ return l1if_gsm_req_compl(fl1h, msg, opstart_compl_cb);
}
GsmL1_Sapi_t lchan_to_GsmL1_Sapi_t(const struct gsm_lchan *lchan)
@@ -444,10 +452,9 @@ static const struct lchan_sapis sapis_for_lchan[_GSM_LCHAN_MAX] = {
},
};
-static int lchan_act_compl_cb(struct msgb *l1_msg, void *data)
+static int lchan_act_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
{
struct gsm_time *time;
- struct gsm_bts_trx *trx = data;
struct gsm_lchan *lchan;
GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg);
GsmL1_MphActivateCnf_t *ic = &l1p->u.mphActivateCnf;
@@ -706,7 +713,7 @@ static int mph_send_activate_req(struct gsm_lchan *lchan, int sapi, int dir)
get_value_string(femtobts_dir_names, act_req->dir));
/* send the primitive for all GsmL1_Sapi_* that match the LCHAN */
- return l1if_gsm_req_compl(fl1h, msg, lchan_act_compl_cb, lchan->ts->trx);
+ return l1if_gsm_req_compl(fl1h, msg, lchan_act_compl_cb);
}
int lchan_activate(struct gsm_lchan *lchan)
@@ -777,9 +784,8 @@ static void dump_lch_par(int logl, GsmL1_LogChParam_t *lch_par, GsmL1_Sapi_t sap
LOGPC(DL1C, logl, ")\n");
}
-static int chmod_modif_compl_cb(struct msgb *l1_msg, void *data)
+static int chmod_modif_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
{
- struct gsm_bts_trx *trx = data;
struct gsm_lchan *lchan;
GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg);
GsmL1_MphConfigCnf_t *cc = &l1p->u.mphConfigCnf;
@@ -868,7 +874,7 @@ static int tx_confreq_logchpar(struct gsm_lchan *lchan, uint8_t direction)
&conf_req->cfgParams.setLogChParams.logChParams,
conf_req->cfgParams.setLogChParams.sapi);
- return l1if_gsm_req_compl(fl1h, msg, chmod_modif_compl_cb, lchan->ts->trx);
+ return l1if_gsm_req_compl(fl1h, msg, chmod_modif_compl_cb);
}
int l1if_set_txpower(struct femtol1_hdl *fl1h, float tx_power)
@@ -880,7 +886,7 @@ int l1if_set_txpower(struct femtol1_hdl *fl1h, float tx_power)
conf_req->cfgParamId = GsmL1_ConfigParamId_SetTxPowerLevel;
conf_req->cfgParams.setTxPowerLevel.fTxPowerLevel = tx_power;
- return l1if_gsm_req_compl(fl1h, msg, NULL, NULL);
+ return l1if_gsm_req_compl(fl1h, msg, NULL);
}
const enum GsmL1_CipherId_t rsl2l1_ciph[] = {
@@ -923,7 +929,7 @@ int l1if_set_ciphering(struct femtol1_hdl *fl1h,
memcpy(cfgr->cfgParams.setCipheringParams.u8Kc,
lchan->encr.key, lchan->encr.key_len);
- return l1if_gsm_req_compl(fl1h, msg, chmod_modif_compl_cb, lchan->ts->trx);
+ return l1if_gsm_req_compl(fl1h, msg, chmod_modif_compl_cb);
}
@@ -940,9 +946,8 @@ int bts_model_rsl_mode_modify(struct gsm_lchan *lchan)
return 0;
}
-static int lchan_deact_compl_cb(struct msgb *l1_msg, void *data)
+static int lchan_deact_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
{
- struct gsm_bts_trx *trx = data;
struct gsm_lchan *lchan;
GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg);
GsmL1_MphDeactivateCnf_t *ic = &l1p->u.mphDeactivateCnf;
@@ -1024,7 +1029,7 @@ int lchan_deactivate(struct gsm_lchan *lchan)
osmo_timer_del(&fl1h->alive_timer);
/* send the primitive for all GsmL1_Sapi_* that match the LCHAN */
- l1if_gsm_req_compl(fl1h, msg, lchan_deact_compl_cb, lchan->ts->trx);
+ l1if_gsm_req_compl(fl1h, msg, lchan_deact_compl_cb);
}
lchan_set_state(lchan, LCHAN_S_REL_REQ);
@@ -1053,7 +1058,7 @@ static int lchan_deactivate_sacch(struct gsm_lchan *lchan)
get_value_string(femtobts_dir_names, deact_req->dir));
/* send the primitive for all GsmL1_Sapi_* that match the LCHAN */
- return l1if_gsm_req_compl(fl1h, msg, lchan_deact_compl_cb, lchan->ts->trx);
+ return l1if_gsm_req_compl(fl1h, msg, lchan_deact_compl_cb);
}