From 9d0fd073e91d25bf61c19089a0c4e0ee35457446 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 21 Aug 2014 23:03:45 +0200 Subject: l1_if: pass private 'void *data' from call to callback When enqueueing a command towards the L1, we can now pass along a private data pointer, which then gets passed to the call-back upon completion. --- src/osmo-bts-sysmo/calib_file.c | 8 ++++--- src/osmo-bts-sysmo/l1_if.c | 52 ++++++++++++++++++++++++----------------- src/osmo-bts-sysmo/l1_if.h | 6 ++--- src/osmo-bts-sysmo/oml.c | 40 ++++++++++++++++++------------- 4 files changed, 62 insertions(+), 44 deletions(-) diff --git a/src/osmo-bts-sysmo/calib_file.c b/src/osmo-bts-sysmo/calib_file.c index f188b51c..476d7963 100644 --- a/src/osmo-bts-sysmo/calib_file.c +++ b/src/osmo-bts-sysmo/calib_file.c @@ -369,7 +369,8 @@ static int calib_eeprom_read(const struct calib_file_desc *desc, SuperFemto_Prim /* iteratively download the calibration data into the L1 */ -static int calib_send_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg); +static int calib_send_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data); /* send the calibration table for a single specified file */ static int calib_file_send(struct femtol1_hdl *fl1h, @@ -400,11 +401,12 @@ static int calib_file_send(struct femtol1_hdl *fl1h, } calib_fixup_rx(fl1h, msgb_sysprim(msg)); - return l1if_req_compl(fl1h, msg, calib_send_compl_cb); + return l1if_req_compl(fl1h, msg, calib_send_compl_cb, NULL); } /* completion callback after every SetCalibTbl is confirmed */ -static int calib_send_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) +static int calib_send_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data) { struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); struct calib_send_state *st = &fl1h->st; diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 16e2bc60..4b9ab3e8 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -189,7 +189,7 @@ static void l1if_req_timeout(void *data) } static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, - int is_system_prim, l1if_compl_cb *cb) + int is_system_prim, l1if_compl_cb *cb, void *data) { struct wait_l1_conf *wlc; struct osmo_wqueue *wqueue; @@ -198,7 +198,7 @@ static 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 = NULL; + wlc->cb_data = data; /* Make sure we actually have received a REQUEST type primitive */ if (is_system_prim == 0) { @@ -249,15 +249,15 @@ static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, /* 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) + l1if_compl_cb *cb, void *data) { - return _l1if_req_compl(fl1h, msg, 1, cb); + return _l1if_req_compl(fl1h, msg, 1, cb, data); } int l1if_gsm_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, - l1if_compl_cb *cb) + l1if_compl_cb *cb, void *data) { - return _l1if_req_compl(fl1h, msg, 0, cb); + return _l1if_req_compl(fl1h, msg, 0, cb, data); } /* allocate a msgb containing a GsmL1_Prim_t */ @@ -1002,7 +1002,7 @@ int l1if_handle_l1prim(int wq, struct femtol1_hdl *fl1h, struct msgb *msg) if (is_prim_compat(l1p, wlc)) { llist_del(&wlc->list); if (wlc->cb) - rc = wlc->cb(fl1h->priv, msg); + rc = wlc->cb(fl1h->priv, msg, wlc->cb_data); else { rc = 0; msgb_free(msg); @@ -1032,7 +1032,7 @@ 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(fl1h->priv, msg); + rc = wlc->cb(fl1h->priv, msg, wlc->cb_data); else { rc = 0; msgb_free(msg); @@ -1061,7 +1061,8 @@ int sysinfo_has_changed(struct gsm_bts *bts, int si) } #endif -static int activate_rf_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp) +static int activate_rf_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp, + void *data) { SuperFemto_Prim_t *sysp = msgb_sysprim(resp); GsmL1_Status_t status; @@ -1188,7 +1189,7 @@ int l1if_activate_rf(struct femtol1_hdl *hdl, int on) sysp->id = SuperFemto_PrimId_DeactivateRfReq; } - return l1if_req_compl(hdl, msg, activate_rf_compl_cb); + return l1if_req_compl(hdl, msg, activate_rf_compl_cb, NULL); } #if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(3,6,0) @@ -1219,7 +1220,8 @@ static void mute_handle_ts(struct gsm_bts_trx_ts *ts, int is_muted) } } -static int mute_rf_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp) +static int mute_rf_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp, + void *data) { struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); SuperFemto_Prim_t *sysp = msgb_sysprim(resp); @@ -1274,12 +1276,13 @@ int l1if_mute_rf(struct femtol1_hdl *hdl, uint8_t mute[8], l1if_compl_cb *cb) /* save for later use */ memcpy(hdl->last_rf_mute, mute, sizeof(hdl->last_rf_mute)); - return l1if_req_compl(hdl, msg, cb ? cb : mute_rf_compl_cb); + return l1if_req_compl(hdl, msg, cb ? cb : mute_rf_compl_cb, NULL); #endif /* < 3.6.0 */ } /* call-back on arrival of DSP+FPGA version + band capability */ -static int info_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp) +static int info_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp, + void *data) { SuperFemto_Prim_t *sysp = msgb_sysprim(resp); SuperFemto_SystemInfoCnf_t *sic = &sysp->u.systemInfoCnf; @@ -1347,10 +1350,11 @@ static int l1if_get_info(struct femtol1_hdl *hdl) sysp->id = SuperFemto_PrimId_SystemInfoReq; - return l1if_req_compl(hdl, msg, info_compl_cb); + return l1if_req_compl(hdl, msg, info_compl_cb, NULL); } -static int reset_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp) +static int reset_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp, + void *data) { struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); SuperFemto_Prim_t *sysp = msgb_sysprim(resp); @@ -1384,7 +1388,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, reset_compl_cb); + return l1if_req_compl(hdl, msg, reset_compl_cb, NULL); } /* set the trace flags within the DSP */ @@ -1574,13 +1578,15 @@ int l1if_rf_clock_info_correct(struct femtol1_hdl *fl1h) } #else -static int clock_reset_cb(struct gsm_bts_trx *trx, struct msgb *resp) +static int clock_reset_cb(struct gsm_bts_trx *trx, struct msgb *resp, + void *data) { msgb_free(resp); return 0; } -static int clock_setup_cb(struct gsm_bts_trx *trx, struct msgb *resp) +static int clock_setup_cb(struct gsm_bts_trx *trx, struct msgb *resp, + void *data) { SuperFemto_Prim_t *sysp = msgb_sysprim(resp); @@ -1591,7 +1597,8 @@ static int clock_setup_cb(struct gsm_bts_trx *trx, struct msgb *resp) return 0; } -static int clock_correct_info_cb(struct gsm_bts_trx *trx, struct msgb *resp) +static int clock_correct_info_cb(struct gsm_bts_trx *trx, struct msgb *resp, + void *data) { struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); SuperFemto_Prim_t *sysp = msgb_sysprim(resp); @@ -1650,7 +1657,7 @@ int l1if_rf_clock_info_reset(struct femtol1_hdl *fl1h) sysp->u.rfClockSetupReq.rfTrx.iClkCor = get_clk_cal(fl1h); sysp->u.rfClockSetupReq.rfTrx.clkSrc = fl1h->clk_src; sysp->u.rfClockSetupReq.rfTrxClkCal.clkSrc = SuperFemto_ClkSrcId_GpsPps; - l1if_req_compl(fl1h, msg, clock_setup_cb); + l1if_req_compl(fl1h, msg, clock_setup_cb, NULL); /* Reset the error counters */ msg = sysp_msgb_alloc(); @@ -1659,7 +1666,7 @@ int l1if_rf_clock_info_reset(struct femtol1_hdl *fl1h) sysp->id = SuperFemto_PrimId_RfClockInfoReq; sysp->u.rfClockInfoReq.u8RstClkCal = 1; - return l1if_req_compl(fl1h, msg, clock_reset_cb); + return l1if_req_compl(fl1h, msg, clock_reset_cb, NULL); } int l1if_rf_clock_info_correct(struct femtol1_hdl *fl1h) @@ -1670,6 +1677,7 @@ int l1if_rf_clock_info_correct(struct femtol1_hdl *fl1h) sysp->id = SuperFemto_PrimId_RfClockInfoReq; sysp->u.rfClockInfoReq.u8RstClkCal = 0; - return l1if_req_compl(fl1h, msg, clock_correct_info_cb); + return l1if_req_compl(fl1h, msg, clock_correct_info_cb, NULL); } + #endif diff --git a/src/osmo-bts-sysmo/l1_if.h b/src/osmo-bts-sysmo/l1_if.h index 77144931..5efa25b4 100644 --- a/src/osmo-bts-sysmo/l1_if.h +++ b/src/osmo-bts-sysmo/l1_if.h @@ -87,13 +87,13 @@ struct femtol1_hdl { #define msgb_l1prim(msg) ((GsmL1_Prim_t *)(msg)->l1h) #define msgb_sysprim(msg) ((SuperFemto_Prim_t *)(msg)->l1h) -typedef int l1if_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg); +typedef int l1if_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, void *data); /* 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); + l1if_compl_cb *cb, void *cb_data); int l1if_gsm_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, - l1if_compl_cb *cb); + l1if_compl_cb *cb, void *cb_data); 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 207cae89..2aed31f4 100644 --- a/src/osmo-bts-sysmo/oml.c +++ b/src/osmo-bts-sysmo/oml.c @@ -216,7 +216,8 @@ static int opstart_compl(struct gsm_abis_mo *mo, struct msgb *l1_msg) return oml_mo_opstart_ack(mo); } -static int opstart_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) +static int opstart_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data) { struct gsm_abis_mo *mo; GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg); @@ -227,7 +228,8 @@ static int opstart_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) } #if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(3,6,0) -static int trx_mute_on_init_cb(struct gsm_bts_trx *trx, struct msgb *resp) +static int trx_mute_on_init_cb(struct gsm_bts_trx *trx, struct msgb *resp, + void *data) { SuperFemto_Prim_t *sysp = msgb_sysprim(resp); GsmL1_Status_t status; @@ -246,7 +248,8 @@ static int trx_mute_on_init_cb(struct gsm_bts_trx *trx, struct msgb *resp) } #endif -static int trx_init_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) +static int trx_init_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data) { struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); @@ -333,7 +336,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); + return l1if_gsm_req_compl(fl1h, msg, trx_init_compl_cb, NULL); } uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx) @@ -343,7 +346,8 @@ uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx) return fl1h->hLayer1; } -static int trx_close_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) +static int trx_close_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data) { msgb_free(l1_msg); return 0; @@ -358,7 +362,7 @@ int bts_model_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); + return l1if_gsm_req_compl(fl1h, msg, trx_close_compl_cb, NULL); } static int trx_rf_lock(struct gsm_bts_trx *trx, int locked, l1if_compl_cb *cb) @@ -404,7 +408,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); + return l1if_gsm_req_compl(fl1h, msg, opstart_compl_cb, NULL); } GsmL1_Sapi_t lchan_to_GsmL1_Sapi_t(const struct gsm_lchan *lchan) @@ -643,7 +647,8 @@ static int queue_sapi_command(struct gsm_lchan *lchan, struct sapi_cmd *cmd) return 1; } -static int lchan_act_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) +static int lchan_act_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data) { enum lchan_sapi_state status; struct sapi_cmd *cmd; @@ -921,7 +926,7 @@ static int mph_send_activate_req(struct gsm_lchan *lchan, struct sapi_cmd *cmd) 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); + return l1if_gsm_req_compl(fl1h, msg, lchan_act_compl_cb, NULL); } static void sapi_clear_queue(struct llist_head *queue) @@ -1060,7 +1065,8 @@ static void dump_lch_par(int logl, GsmL1_LogChParam_t *lch_par, GsmL1_Sapi_t sap LOGPC(DL1C, logl, ")\n"); } -static int chmod_txpower_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) +static int chmod_txpower_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data) { GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg); GsmL1_MphConfigCnf_t *cc = &l1p->u.mphConfigCnf; @@ -1077,7 +1083,8 @@ static int chmod_txpower_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) return 0; } -static int chmod_modif_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) +static int chmod_modif_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data) { struct gsm_lchan *lchan; GsmL1_Prim_t *l1p = msgb_l1prim(l1_msg); @@ -1173,7 +1180,7 @@ static int mph_send_config_logchpar(struct gsm_lchan *lchan, struct sapi_cmd *cm &conf_req->cfgParams.setLogChParams.logChParams, conf_req->cfgParams.setLogChParams.sapi); - return l1if_gsm_req_compl(fl1h, msg, chmod_modif_compl_cb); + return l1if_gsm_req_compl(fl1h, msg, chmod_modif_compl_cb, NULL); } static void enqueue_sapi_logchpar_cmd(struct gsm_lchan *lchan, int dir) @@ -1201,7 +1208,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, chmod_txpower_compl_cb); + return l1if_gsm_req_compl(fl1h, msg, chmod_txpower_compl_cb, NULL); } const enum GsmL1_CipherId_t rsl2l1_ciph[] = { @@ -1239,7 +1246,7 @@ static int mph_send_config_ciphering(struct gsm_lchan *lchan, struct sapi_cmd *c memcpy(cfgr->cfgParams.setCipheringParams.u8Kc, lchan->encr.key, lchan->encr.key_len); - return l1if_gsm_req_compl(fl1h, msg, chmod_modif_compl_cb); + return l1if_gsm_req_compl(fl1h, msg, chmod_modif_compl_cb, NULL); } static void enqueue_sapi_ciphering_cmd(struct gsm_lchan *lchan, int dir) @@ -1287,7 +1294,8 @@ int bts_model_rsl_mode_modify(struct gsm_lchan *lchan) return 0; } -static int lchan_deact_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg) +static int lchan_deact_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, + void *data) { enum lchan_sapi_state status; struct sapi_cmd *cmd; @@ -1369,7 +1377,7 @@ static int mph_send_deactivate_req(struct gsm_lchan *lchan, struct sapi_cmd *cmd 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); + return l1if_gsm_req_compl(fl1h, msg, lchan_deact_compl_cb, NULL); } static int sapi_deactivate_cb(struct gsm_lchan *lchan, int status) -- cgit v1.2.3