LC15: port litecell 1.5 support to recent osmo-bts master
This includes changes required for * shared main() function accross all BTS models * use of the new phy_link / phy_instance infrastructure as the basis for true multi-TRX operation
This commit is contained in:
parent
29a0197ead
commit
1dcb97eaa3
|
@ -91,6 +91,9 @@ struct phy_instance {
|
|||
/* logical transceiver number within one PHY */
|
||||
uint32_t trx_id;
|
||||
} octphy;
|
||||
struct {
|
||||
struct lc15l1_hdl *hdl;
|
||||
} lc15;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* NuRAN Wireless Litecell 1.5 BTS L1 calibration file routines*/
|
||||
|
||||
/* Copyright (C) 2015 by Yves Godin <support@nuranwireless.com>
|
||||
* Copyright (C) 2016 by Harald Welte <laforge@gnumonks.org>
|
||||
*
|
||||
* Based on sysmoBTS:
|
||||
* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||
|
@ -54,31 +55,31 @@ static const struct calib_file_desc calib_files[] = {
|
|||
{
|
||||
.fname = "calib_rx1a.conf",
|
||||
.rx = 1,
|
||||
.trx = 1,
|
||||
.trx = 0,
|
||||
.rxpath = 0,
|
||||
}, {
|
||||
.fname = "calib_rx1b.conf",
|
||||
.rx = 1,
|
||||
.trx = 1,
|
||||
.trx = 0,
|
||||
.rxpath = 1,
|
||||
}, {
|
||||
.fname = "calib_rx2a.conf",
|
||||
.rx = 1,
|
||||
.trx = 2,
|
||||
.trx = 1,
|
||||
.rxpath = 0,
|
||||
}, {
|
||||
.fname = "calib_rx2b.conf",
|
||||
.rx = 1,
|
||||
.trx = 2,
|
||||
.trx = 1,
|
||||
.rxpath = 1,
|
||||
}, {
|
||||
.fname = "calib_tx1.conf",
|
||||
.rx = 0,
|
||||
.trx = 1,
|
||||
.trx = 0,
|
||||
}, {
|
||||
.fname = "calib_tx2.conf",
|
||||
.rx = 0,
|
||||
.trx = 2,
|
||||
.trx = 1,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -89,10 +90,11 @@ static int calib_file_send(struct lc15l1_hdl *fl1h,
|
|||
/* determine next calibration file index based on supported bands */
|
||||
static int get_next_calib_file_idx(struct lc15l1_hdl *fl1h, int last_idx)
|
||||
{
|
||||
struct phy_link *plink = fl1h->phy_inst->phy_link;
|
||||
int i;
|
||||
|
||||
for (i = last_idx+1; i < ARRAY_SIZE(calib_files); i++) {
|
||||
if (calib_files[i].trx == fl1h->hw_info.trx_nr)
|
||||
if (calib_files[i].trx == plink->num)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* Interface handler for NuRAN Wireless Litecell 1.5 L1 */
|
||||
|
||||
/* Copyright (C) 2015 by Yves Godin <support@nuranwireless.com>
|
||||
* Copyright (C) 2016 by Harald Welte <laforge@gnumonks.org>
|
||||
*
|
||||
* Based on sysmoBTS:
|
||||
* (C) 2011-2014 by Harald Welte <laforge@gnumonks.org>
|
||||
|
@ -44,6 +45,7 @@
|
|||
#include <osmo-bts/oml.h>
|
||||
#include <osmo-bts/rsl.h>
|
||||
#include <osmo-bts/gsm_data.h>
|
||||
#include <osmo-bts/phy_link.h>
|
||||
#include <osmo-bts/paging.h>
|
||||
#include <osmo-bts/measurement.h>
|
||||
#include <osmo-bts/pcu_if.h>
|
||||
|
@ -583,7 +585,7 @@ int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
|
|||
static int handle_mph_time_ind(struct lc15l1_hdl *fl1,
|
||||
GsmL1_MphTimeInd_t *time_ind)
|
||||
{
|
||||
struct gsm_bts_trx *trx = fl1->priv;
|
||||
struct gsm_bts_trx *trx = lc15l1_hdl_trx(fl1);
|
||||
struct gsm_bts *bts = trx->bts;
|
||||
struct osmo_phsap_prim l1sap;
|
||||
uint32_t fn;
|
||||
|
@ -707,7 +709,7 @@ static int handle_ph_readytosend_ind(struct lc15l1_hdl *fl1,
|
|||
GsmL1_PhReadyToSendInd_t *rts_ind,
|
||||
struct msgb *l1p_msg)
|
||||
{
|
||||
struct gsm_bts_trx *trx = fl1->priv;
|
||||
struct gsm_bts_trx *trx = lc15l1_hdl_trx(fl1);
|
||||
struct gsm_bts *bts = trx->bts;
|
||||
struct msgb *resp_msg;
|
||||
GsmL1_PhDataReq_t *data_req;
|
||||
|
@ -830,7 +832,7 @@ static int process_meas_res(struct gsm_bts_trx *trx, uint8_t chan_nr,
|
|||
static int handle_ph_data_ind(struct lc15l1_hdl *fl1, GsmL1_PhDataInd_t *data_ind,
|
||||
struct msgb *l1p_msg)
|
||||
{
|
||||
struct gsm_bts_trx *trx = fl1->priv;
|
||||
struct gsm_bts_trx *trx = lc15l1_hdl_trx(fl1);
|
||||
uint8_t chan_nr, link_id;
|
||||
struct osmo_phsap_prim *l1sap;
|
||||
uint32_t fn;
|
||||
|
@ -902,7 +904,7 @@ static int handle_ph_data_ind(struct lc15l1_hdl *fl1, GsmL1_PhDataInd_t *data_in
|
|||
static int handle_ph_ra_ind(struct lc15l1_hdl *fl1, GsmL1_PhRaInd_t *ra_ind,
|
||||
struct msgb *l1p_msg)
|
||||
{
|
||||
struct gsm_bts_trx *trx = fl1->priv;
|
||||
struct gsm_bts_trx *trx = lc15l1_hdl_trx(fl1);
|
||||
struct gsm_bts *bts = trx->bts;
|
||||
struct gsm_bts_role_bts *btsb = bts->role;
|
||||
struct gsm_lchan *lchan;
|
||||
|
@ -1022,7 +1024,8 @@ int l1if_handle_l1prim(int wq, struct lc15l1_hdl *fl1h, struct msgb *msg)
|
|||
if (is_prim_compat(l1p, wlc)) {
|
||||
llist_del(&wlc->list);
|
||||
if (wlc->cb)
|
||||
rc = wlc->cb(fl1h->priv, msg, wlc->cb_data);
|
||||
rc = wlc->cb(lc15l1_hdl_trx(fl1h), msg,
|
||||
wlc->cb_data);
|
||||
else {
|
||||
rc = 0;
|
||||
msgb_free(msg);
|
||||
|
@ -1052,7 +1055,8 @@ int l1if_handle_sysprim(struct lc15l1_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, wlc->cb_data);
|
||||
rc = wlc->cb(lc15l1_hdl_trx(fl1h), msg,
|
||||
wlc->cb_data);
|
||||
else {
|
||||
rc = 0;
|
||||
msgb_free(msg);
|
||||
|
@ -1379,7 +1383,7 @@ static int get_hwinfo(struct lc15l1_hdl *fl1h)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct lc15l1_hdl *l1if_open(void *priv, int trx_nr)
|
||||
struct lc15l1_hdl *l1if_open(struct phy_instance *pinst)
|
||||
{
|
||||
struct lc15l1_hdl *fl1h;
|
||||
int rc;
|
||||
|
@ -1389,12 +1393,12 @@ struct lc15l1_hdl *l1if_open(void *priv, int trx_nr)
|
|||
(LITECELL15_API_VERSION >> 8) & 0xff,
|
||||
LITECELL15_API_VERSION & 0xff);
|
||||
|
||||
fl1h = talloc_zero(priv, struct lc15l1_hdl);
|
||||
fl1h = talloc_zero(pinst, struct lc15l1_hdl);
|
||||
if (!fl1h)
|
||||
return NULL;
|
||||
INIT_LLIST_HEAD(&fl1h->wlc_list);
|
||||
|
||||
fl1h->priv = priv;
|
||||
fl1h->phy_inst = pinst;
|
||||
fl1h->clk_cal = 0;
|
||||
fl1h->clk_use_eeprom = 1;
|
||||
fl1h->min_qual_rach = MIN_QUAL_RACH;
|
||||
|
@ -1402,9 +1406,6 @@ struct lc15l1_hdl *l1if_open(void *priv, int trx_nr)
|
|||
|
||||
get_hwinfo(fl1h);
|
||||
|
||||
/* NTQD: Change how rx_nr is handle in multi-trx */
|
||||
fl1h->hw_info.trx_nr = trx_nr;
|
||||
|
||||
rc = l1if_transport_open(MQ_SYS_WRITE, fl1h);
|
||||
if (rc < 0) {
|
||||
talloc_free(fl1h);
|
||||
|
@ -1427,3 +1428,21 @@ int l1if_close(struct lc15l1_hdl *fl1h)
|
|||
l1if_transport_close(MQ_SYS_WRITE, fl1h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bts_model_phy_link_open(struct phy_link *plink)
|
||||
{
|
||||
struct phy_instance *pinst = phy_instance_by_num(plink, 0);
|
||||
|
||||
OSMO_ASSERT(pinst);
|
||||
|
||||
phy_link_state_set(plink, PHY_LINK_CONNECTING);
|
||||
|
||||
pinst->u.lc15.hdl = l1if_open(pinst);
|
||||
if (!pinst->u.lc15.hdl) {
|
||||
LOGP(DL1C, LOGL_FATAL, "Cannot open L1 interface\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
phy_link_state_set(plink, PHY_LINK_CONNECTED);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <osmocom/core/timer.h>
|
||||
#include <osmocom/gsm/gsm_utils.h>
|
||||
|
||||
#include <osmo-bts/phy_link.h>
|
||||
|
||||
#include <nrw/litecell15/gsml1prim.h>
|
||||
|
||||
enum {
|
||||
|
@ -43,7 +45,7 @@ struct lc15l1_hdl {
|
|||
char *calib_path;
|
||||
struct llist_head wlc_list;
|
||||
|
||||
void *priv; /* user reference */
|
||||
struct phy_instance *phy_inst;
|
||||
|
||||
struct osmo_timer_list alive_timer;
|
||||
unsigned int alive_prim_cnt;
|
||||
|
@ -58,7 +60,6 @@ struct lc15l1_hdl {
|
|||
uint32_t band_support;
|
||||
uint8_t ver_major;
|
||||
uint8_t ver_minor;
|
||||
uint8_t trx_nr; // 1 or 2
|
||||
} hw_info;
|
||||
|
||||
struct calib_send_state st;
|
||||
|
@ -77,7 +78,7 @@ int l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg,
|
|||
int l1if_gsm_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg,
|
||||
l1if_compl_cb *cb, void *cb_data);
|
||||
|
||||
struct lc15l1_hdl *l1if_open(void *priv, int trx_nr);
|
||||
struct lc15l1_hdl *l1if_open(struct phy_instance *pinst);
|
||||
int l1if_close(struct lc15l1_hdl *hdl);
|
||||
int l1if_reset(struct lc15l1_hdl *hdl);
|
||||
int l1if_activate_rf(struct lc15l1_hdl *hdl, int on);
|
||||
|
@ -116,6 +117,20 @@ int calib_load(struct lc15l1_hdl *fl1h);
|
|||
/* public helpers for test */
|
||||
int bts_check_for_ciph_cmd(struct lc15l1_hdl *fl1h,
|
||||
struct msgb *msg, struct gsm_lchan *lchan);
|
||||
inline int l1if_ms_pwr_ctrl(struct gsm_lchan *lchan, const int uplink_target,
|
||||
int l1if_ms_pwr_ctrl(struct gsm_lchan *lchan, const int uplink_target,
|
||||
const uint8_t ms_power, const float rxLevel);
|
||||
|
||||
static inline struct lc15l1_hdl *trx_lc15l1_hdl(struct gsm_bts_trx *trx)
|
||||
{
|
||||
struct phy_instance *pinst = trx_phy_instance(trx);
|
||||
OSMO_ASSERT(pinst);
|
||||
return pinst->u.lc15.hdl;
|
||||
}
|
||||
|
||||
static inline struct gsm_bts_trx *lc15l1_hdl_trx(struct lc15l1_hdl *fl1h)
|
||||
{
|
||||
OSMO_ASSERT(fl1h->phy_inst);
|
||||
return fl1h->phy_inst->trx;
|
||||
}
|
||||
|
||||
#endif /* _L1_IF_H */
|
||||
|
|
|
@ -240,6 +240,7 @@ static int l1fd_write_cb(struct osmo_fd *ofd, struct msgb *msg)
|
|||
|
||||
int l1if_transport_open(int q, struct lc15l1_hdl *hdl)
|
||||
{
|
||||
struct phy_link *plink = hdl->phy_inst->phy_link;
|
||||
int rc;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
|
@ -248,7 +249,7 @@ int l1if_transport_open(int q, struct lc15l1_hdl *hdl)
|
|||
struct osmo_wqueue *wq = &hdl->write_q[q];
|
||||
struct osmo_fd *write_ofd = &hdl->write_q[q].bfd;
|
||||
|
||||
snprintf(buf, sizeof(buf)-1, "%s%d", rd_devnames[q], hdl->hw_info.trx_nr);
|
||||
snprintf(buf, sizeof(buf)-1, "%s%d", rd_devnames[q], plink->num+1);
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
|
||||
rc = open(buf, O_RDONLY);
|
||||
|
@ -270,7 +271,7 @@ int l1if_transport_open(int q, struct lc15l1_hdl *hdl)
|
|||
return rc;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf)-1, "%s%d", wr_devnames[q], hdl->hw_info.trx_nr);
|
||||
snprintf(buf, sizeof(buf)-1, "%s%d", wr_devnames[q], plink->num+1);
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
|
||||
rc = open(buf, O_WRONLY);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* VTY interface for NuRAN Wireless Litecell 1.5 */
|
||||
|
||||
/* Copyright (C) 2015 by Yves Godin <support@nuranwireless.com>
|
||||
* Copyright (C) 2016 by Harald Welte <laforge@gnumonks.org>
|
||||
*
|
||||
* Based on sysmoBTS:
|
||||
* (C) 2011 by Harald Welte <laforge@gnumonks.org>
|
||||
|
@ -43,6 +44,7 @@
|
|||
#include <osmocom/vty/misc.h>
|
||||
|
||||
#include <osmo-bts/gsm_data.h>
|
||||
#include <osmo-bts/phy_link.h>
|
||||
#include <osmo-bts/logging.h>
|
||||
#include <osmo-bts/vty.h>
|
||||
|
||||
|
@ -87,12 +89,12 @@ DEFUN(cfg_bts_no_auto_band, cfg_bts_no_auto_band_cmd,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_trx_cal_path, cfg_trx_cal_path_cmd,
|
||||
DEFUN(cfg_phy_cal_path, cfg_phy_cal_path_cmd,
|
||||
"trx-calibration-path PATH",
|
||||
"Set the path name to TRX calibration data\n" "Path name\n")
|
||||
{
|
||||
struct gsm_bts_trx *trx = vty->index;
|
||||
struct lc15l1_hdl *fl1h = trx_lc15l1_hdl(trx);
|
||||
struct phy_instance *pinst = vty->index;
|
||||
struct lc15l1_hdl *fl1h = pinst->u.lc15.hdl;
|
||||
|
||||
if (fl1h->calib_path)
|
||||
talloc_free(fl1h->calib_path);
|
||||
|
@ -102,44 +104,32 @@ DEFUN(cfg_trx_cal_path, cfg_trx_cal_path_cmd,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_trx_min_qual_rach, cfg_trx_min_qual_rach_cmd,
|
||||
DEFUN(cfg_phy_min_qual_rach, cfg_phy_min_qual_rach_cmd,
|
||||
"min-qual-rach <-100-100>",
|
||||
"Set the minimum quality level of RACH burst to be accpeted\n"
|
||||
"C/I level in tenth of dB\n")
|
||||
{
|
||||
struct gsm_bts_trx *trx = vty->index;
|
||||
struct lc15l1_hdl *fl1h = trx_lc15l1_hdl(trx);
|
||||
struct phy_instance *pinst = vty->index;
|
||||
struct lc15l1_hdl *fl1h = pinst->u.lc15.hdl;
|
||||
|
||||
fl1h->min_qual_rach = strtof(argv[0], NULL) / 10.0f;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_trx_min_qual_norm, cfg_trx_min_qual_norm_cmd,
|
||||
DEFUN(cfg_phy_min_qual_norm, cfg_phy_min_qual_norm_cmd,
|
||||
"min-qual-norm <-100-100>",
|
||||
"Set the minimum quality level of normal burst to be accpeted\n"
|
||||
"C/I level in tenth of dB\n")
|
||||
{
|
||||
struct gsm_bts_trx *trx = vty->index;
|
||||
struct lc15l1_hdl *fl1h = trx_lc15l1_hdl(trx);
|
||||
struct phy_instance *pinst = vty->index;
|
||||
struct lc15l1_hdl *fl1h = pinst->u.lc15.hdl;
|
||||
|
||||
fl1h->min_qual_norm = strtof(argv[0], NULL) / 10.0f;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_trx_nominal_power, cfg_trx_nominal_power_cmd,
|
||||
"nominal-tx-power <0-100>",
|
||||
"Set the nominal transmit output power in dBm\n"
|
||||
"Nominal transmit output power level in dBm\n")
|
||||
{
|
||||
struct gsm_bts_trx *trx = vty->index;
|
||||
|
||||
trx->nominal_power = atoi(argv[0]);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* runtime */
|
||||
|
||||
DEFUN(show_dsp_trace_f, show_dsp_trace_f_cmd,
|
||||
|
@ -180,18 +170,26 @@ DEFUN(show_dsp_trace_f, show_dsp_trace_f_cmd,
|
|||
|
||||
DEFUN(dsp_trace_f, dsp_trace_f_cmd, "HIDDEN", TRX_STR)
|
||||
{
|
||||
int trx_nr = atoi(argv[0]);
|
||||
struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
|
||||
int phy_nr = atoi(argv[0]);
|
||||
struct phy_link *plink = phy_link_by_num(phy_nr);
|
||||
struct phy_instance *pinst;
|
||||
struct lc15l1_hdl *fl1h;
|
||||
unsigned int flag ;
|
||||
|
||||
if (!trx) {
|
||||
vty_out(vty, "Cannot find TRX number %u%s",
|
||||
trx_nr, VTY_NEWLINE);
|
||||
if (!plink) {
|
||||
vty_out(vty, "Cannot find PHY link number %u%s",
|
||||
phy_nr, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
fl1h = trx_lc15l1_hdl(trx);
|
||||
pinst = phy_instance_by_num(plink, 0);
|
||||
if (!pinst) {
|
||||
vty_out(vty, "Cannot find PHY instance number 0%s",
|
||||
VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
fl1h = pinst->u.lc15.hdl;
|
||||
flag = get_string_value(lc15bts_tracef_names, argv[1]);
|
||||
l1if_set_trace_flags(fl1h, fl1h->dsp_trace_f | flag);
|
||||
|
||||
|
@ -200,18 +198,26 @@ DEFUN(dsp_trace_f, dsp_trace_f_cmd, "HIDDEN", TRX_STR)
|
|||
|
||||
DEFUN(no_dsp_trace_f, no_dsp_trace_f_cmd, "HIDDEN", NO_STR TRX_STR)
|
||||
{
|
||||
int trx_nr = atoi(argv[0]);
|
||||
struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
|
||||
int phy_nr = atoi(argv[0]);
|
||||
struct phy_link *plink = phy_link_by_num(phy_nr);
|
||||
struct phy_instance *pinst;
|
||||
struct lc15l1_hdl *fl1h;
|
||||
unsigned int flag ;
|
||||
|
||||
if (!trx) {
|
||||
vty_out(vty, "Cannot find TRX number %u%s",
|
||||
trx_nr, VTY_NEWLINE);
|
||||
if (!plink) {
|
||||
vty_out(vty, "Cannot find PHY link number %u%s",
|
||||
phy_nr, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
fl1h = trx_lc15l1_hdl(trx);
|
||||
pinst = phy_instance_by_num(plink, 0);
|
||||
if (!pinst) {
|
||||
vty_out(vty, "Cannot find PHY instance number 0%s",
|
||||
VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
fl1h = pinst->u.lc15.hdl;
|
||||
flag = get_string_value(lc15bts_tracef_names, argv[1]);
|
||||
l1if_set_trace_flags(fl1h, fl1h->dsp_trace_f & ~flag);
|
||||
|
||||
|
@ -219,20 +225,28 @@ DEFUN(no_dsp_trace_f, no_dsp_trace_f_cmd, "HIDDEN", NO_STR TRX_STR)
|
|||
}
|
||||
|
||||
DEFUN(show_sys_info, show_sys_info_cmd,
|
||||
"show trx <0-0> system-information",
|
||||
"show phy <0-1> instance <0-0> system-information",
|
||||
SHOW_TRX_STR "Display information about system\n")
|
||||
{
|
||||
int trx_nr = atoi(argv[0]);
|
||||
struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
|
||||
int phy_nr = atoi(argv[0]);
|
||||
int inst_nr = atoi(argv[1]);
|
||||
struct phy_link *plink = phy_link_by_num(phy_nr);
|
||||
struct phy_instance *pinst;
|
||||
struct lc15l1_hdl *fl1h;
|
||||
int i;
|
||||
|
||||
if (!trx) {
|
||||
vty_out(vty, "Cannot find TRX number %u%s",
|
||||
trx_nr, VTY_NEWLINE);
|
||||
if (!plink) {
|
||||
vty_out(vty, "Cannot find PHY link %u%s",
|
||||
phy_nr, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
fl1h = trx_lc15l1_hdl(trx);
|
||||
pinst = phy_instance_by_num(plink, inst_nr);
|
||||
if (!plink) {
|
||||
vty_out(vty, "Cannot find PHY instance %u%s",
|
||||
phy_nr, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
fl1h = pinst->u.lc15.hdl;
|
||||
|
||||
vty_out(vty, "DSP Version: %u.%u.%u, FPGA Version: %u.%u.%u%s",
|
||||
fl1h->hw_info.dsp_version[0],
|
||||
|
@ -339,13 +353,12 @@ void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts)
|
|||
|
||||
void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx)
|
||||
{
|
||||
struct lc15l1_hdl *fl1h = trx_lc15l1_hdl(trx);
|
||||
}
|
||||
|
||||
static void write_phy_inst(struct vty *vty, struct phy_instance *pinst)
|
||||
{
|
||||
struct lc15l1_hdl *fl1h = pinst->u.lc15.hdl;
|
||||
|
||||
if (fl1h->clk_use_eeprom)
|
||||
vty_out(vty, " clock-calibration eeprom%s", VTY_NEWLINE);
|
||||
else
|
||||
vty_out(vty, " clock-calibration %d%s", fl1h->clk_cal,
|
||||
VTY_NEWLINE);
|
||||
if (fl1h->calib_path)
|
||||
vty_out(vty, " trx-calibration-path %s%s",
|
||||
fl1h->calib_path, VTY_NEWLINE);
|
||||
|
@ -353,9 +366,14 @@ void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx)
|
|||
VTY_NEWLINE);
|
||||
vty_out(vty, " min-qual-norm %.0f%s", fl1h->min_qual_norm * 10.0f,
|
||||
VTY_NEWLINE);
|
||||
if (trx->nominal_power != lc15bts_get_nominal_power(trx))
|
||||
vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power,
|
||||
VTY_NEWLINE);
|
||||
}
|
||||
|
||||
void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink)
|
||||
{
|
||||
struct phy_instance *pinst;
|
||||
|
||||
llist_for_each_entry(pinst, &plink->instances, list)
|
||||
write_phy_inst(vty, pinst);
|
||||
}
|
||||
|
||||
int bts_model_vty_init(struct gsm_bts *bts)
|
||||
|
@ -364,14 +382,14 @@ int bts_model_vty_init(struct gsm_bts *bts)
|
|||
|
||||
/* runtime-patch the command strings with debug levels */
|
||||
dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(bts, lc15bts_tracef_names,
|
||||
"trx <0-0> dsp-trace-flag (",
|
||||
"phy <0-0> dsp-trace-flag (",
|
||||
"|",")", VTY_DO_LOWER);
|
||||
dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts, lc15bts_tracef_docs,
|
||||
TRX_STR DSP_TRACE_F_STR,
|
||||
"\n", "", 0);
|
||||
|
||||
no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(bts, lc15bts_tracef_names,
|
||||
"no trx <0-0> dsp-trace-flag (",
|
||||
"no phy <0-0> dsp-trace-flag (",
|
||||
"|",")", VTY_DO_LOWER);
|
||||
no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts, lc15bts_tracef_docs,
|
||||
NO_STR TRX_STR DSP_TRACE_F_STR,
|
||||
|
@ -391,10 +409,14 @@ int bts_model_vty_init(struct gsm_bts *bts)
|
|||
install_element(BTS_NODE, &cfg_bts_auto_band_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_no_auto_band_cmd);
|
||||
|
||||
install_element(TRX_NODE, &cfg_trx_cal_path_cmd);
|
||||
install_element(TRX_NODE, &cfg_trx_min_qual_rach_cmd);
|
||||
install_element(TRX_NODE, &cfg_trx_min_qual_norm_cmd);
|
||||
install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
|
||||
install_element(PHY_INST_NODE, &cfg_phy_cal_path_cmd);
|
||||
install_element(PHY_INST_NODE, &cfg_phy_min_qual_rach_cmd);
|
||||
install_element(PHY_INST_NODE, &cfg_phy_min_qual_norm_cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bts_model_ctrl_cmds_install(struct gsm_bts *bts)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* Main program for NuRAN Wireless Litecell 1.5 BTS */
|
||||
|
||||
/* Copyright (C) 2015 by Yves Godin <support@nuranwireless.com>
|
||||
* Copyright (C) 2016 by Harald Welte <laforge@gnumonks.org>
|
||||
*
|
||||
* Based on sysmoBTS:
|
||||
* (C) 2011-2013 by Harald Welte <laforge@gnumonks.org>
|
||||
|
@ -41,22 +42,16 @@
|
|||
#include <osmocom/vty/telnet_interface.h>
|
||||
#include <osmocom/vty/logging.h>
|
||||
#include <osmocom/vty/ports.h>
|
||||
#include <osmocom/core/gsmtap_util.h>
|
||||
#include <osmocom/core/gsmtap.h>
|
||||
|
||||
#include <osmo-bts/gsm_data.h>
|
||||
#include <osmo-bts/logging.h>
|
||||
#include <osmo-bts/abis.h>
|
||||
#include <osmo-bts/bts.h>
|
||||
#include <osmo-bts/vty.h>
|
||||
#include <osmo-bts/bts_model.h>
|
||||
#include <osmo-bts/pcu_if.h>
|
||||
#include <osmo-bts/control_if.h>
|
||||
#include <osmo-bts/l1sap.h>
|
||||
|
||||
/*NTQD: Change how rx_nr is handle in multi-trx*/
|
||||
#define LC15BTS_RF_LOCK_PATH(NR) ((((NR))==1) ? "/var/lock/bts_rf_lock1" : "/var/lock/bts_rf_lock2")
|
||||
#define LC15BTS_PID_FILE(NR) ((((NR))==1) ? "osmo-bts1" : "osmo-bts2")
|
||||
#define LC15BTS_RF_LOCK_PATH "/var/lock/bts_rf_lock"
|
||||
|
||||
#include "utils.h"
|
||||
#include "l1_if.h"
|
||||
|
@ -64,37 +59,33 @@
|
|||
#include "oml_router.h"
|
||||
#include "misc/lc15bts_bid.h"
|
||||
|
||||
int pcu_direct = 0;
|
||||
|
||||
static const char *config_file = "lc15bts.cfg";
|
||||
static int daemonize = 0;
|
||||
extern int pcu_direct;
|
||||
static unsigned int dsp_trace = 0x00000000;
|
||||
static int rt_prio = -1;
|
||||
static char *gsmtap_ip = 0;
|
||||
static int trx_nr = 1;
|
||||
|
||||
int bts_model_init(struct gsm_bts *bts)
|
||||
{
|
||||
struct lc15l1_hdl *fl1h;
|
||||
struct gsm_bts_role_bts *btsb;
|
||||
struct stat st;
|
||||
static struct osmo_fd accept_fd, read_fd;
|
||||
int rc;
|
||||
|
||||
fl1h = l1if_open(bts->c0, trx_nr);
|
||||
if (!fl1h) {
|
||||
LOGP(DL1C, LOGL_FATAL, "Cannot open L1 Interface\n");
|
||||
return -EIO;
|
||||
}
|
||||
fl1h->dsp_trace_f = dsp_trace;
|
||||
btsb = bts_role_bts(bts);
|
||||
btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3);
|
||||
|
||||
bts->c0->role_bts.l1h = fl1h;
|
||||
|
||||
rc = lc15bts_get_nominal_power(bts->c0);
|
||||
rc = oml_router_init(bts, OML_ROUTER_PATH, &accept_fd, &read_fd);
|
||||
if (rc < 0) {
|
||||
LOGP(DL1C, LOGL_NOTICE, "Cannot determine nominal "
|
||||
"transmit power. Assuming 37dBm.\n");
|
||||
rc = 37;
|
||||
fprintf(stderr, "Error creating the OML router: %s rc=%d\n",
|
||||
OML_ROUTER_PATH, rc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bts->c0->nominal_power = 37;
|
||||
bts->c0->power_params.trx_p_max_out_mdBm = to_mdB(bts->c0->nominal_power);
|
||||
|
||||
if (stat(LC15BTS_RF_LOCK_PATH, &st) == 0) {
|
||||
LOGP(DL1C, LOGL_NOTICE, "Not starting BTS due to RF_LOCK file present\n");
|
||||
exit(23);
|
||||
}
|
||||
bts->c0->nominal_power = rc;
|
||||
bts->c0->power_params.trx_p_max_out_mdBm = to_mdB(rc);
|
||||
|
||||
bts_model_vty_init(bts);
|
||||
|
||||
|
@ -134,24 +125,12 @@ void bts_update_status(enum bts_global_status which, int on)
|
|||
lc15bts_led_set(led_rf_active_on ? LED_GREEN : LED_OFF);
|
||||
}
|
||||
|
||||
static void print_help()
|
||||
void bts_model_print_help()
|
||||
{
|
||||
printf( "Some useful options:\n"
|
||||
" -h --help this text\n"
|
||||
" -d --debug MASK Enable debugging (e.g. -d DRSL:DOML:DLAPDM)\n"
|
||||
" -D --daemonize For the process into a background daemon\n"
|
||||
" -c --config-file Specify the filename of the config file\n"
|
||||
" -s --disable-color Don't use colors in stderr log output\n"
|
||||
" -T --timestamp Prefix every log line with a timestamp\n"
|
||||
" -V --version Print version information and exit\n"
|
||||
" -e --log-level Set a global log-level\n"
|
||||
" -p --dsp-trace Set DSP trace flags\n"
|
||||
" -r --realtime PRIO Use SCHED_RR with the specified priority\n"
|
||||
printf( " -p --dsp-trace Set DSP trace flags\n"
|
||||
" -w --hw-version Print the targeted HW Version\n"
|
||||
" -M --pcu-direct Force PCU to access message queue for "
|
||||
"PDCH dchannel directly\n"
|
||||
" -i --gsmtap-ip The destination IP used for GSMTAP.\n"
|
||||
" -n --hw-trx-nr Hardware TRX number <1-2>\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -178,250 +157,44 @@ static void print_hwversion()
|
|||
printf(model_name);
|
||||
}
|
||||
|
||||
/* FIXME: finally get some option parsing code into libosmocore */
|
||||
static void handle_options(int argc, char **argv)
|
||||
int bts_model_handle_options(int argc, char **argv)
|
||||
{
|
||||
int num_errors = 0;
|
||||
|
||||
while (1) {
|
||||
int option_idx = 0, c;
|
||||
static const struct option long_options[] = {
|
||||
/* FIXME: all those are generic Osmocom app options */
|
||||
{ "help", 0, 0, 'h' },
|
||||
{ "debug", 1, 0, 'd' },
|
||||
{ "daemonize", 0, 0, 'D' },
|
||||
{ "config-file", 1, 0, 'c' },
|
||||
{ "disable-color", 0, 0, 's' },
|
||||
{ "timestamp", 0, 0, 'T' },
|
||||
{ "version", 0, 0, 'V' },
|
||||
{ "log-level", 1, 0, 'e' },
|
||||
{ "dsp-trace", 1, 0, 'p' },
|
||||
{ "hw-version", 0, 0, 'w' },
|
||||
{ "pcu-direct", 0, 0, 'M' },
|
||||
{ "realtime", 1, 0, 'r' },
|
||||
{ "gsmtap-ip", 1, 0, 'i' },
|
||||
{ "hw-trx-nr", 1, 0, 'n' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "hc:d:Dc:sTVe:p:w:Mr:n:",
|
||||
c = getopt_long(argc, argv, "p:wM",
|
||||
long_options, &option_idx);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'h':
|
||||
print_help();
|
||||
exit(0);
|
||||
break;
|
||||
case 's':
|
||||
log_set_use_color(osmo_stderr_target, 0);
|
||||
break;
|
||||
case 'd':
|
||||
log_parse_category_mask(osmo_stderr_target, optarg);
|
||||
break;
|
||||
case 'D':
|
||||
daemonize = 1;
|
||||
break;
|
||||
case 'c':
|
||||
config_file = optarg;
|
||||
break;
|
||||
case 'T':
|
||||
log_set_print_timestamp(osmo_stderr_target, 1);
|
||||
case 'p':
|
||||
dsp_trace = strtoul(optarg, NULL, 16);
|
||||
#warning use dsp_trace!!!
|
||||
break;
|
||||
case 'M':
|
||||
pcu_direct = 1;
|
||||
break;
|
||||
case 'V':
|
||||
print_version(1);
|
||||
exit(0);
|
||||
break;
|
||||
case 'e':
|
||||
log_set_log_level(osmo_stderr_target, atoi(optarg));
|
||||
break;
|
||||
case 'p':
|
||||
dsp_trace = strtoul(optarg, NULL, 16);
|
||||
break;
|
||||
case 'w':
|
||||
print_hwversion();
|
||||
exit(0);
|
||||
break;
|
||||
case 'r':
|
||||
rt_prio = atoi(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
gsmtap_ip = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
trx_nr = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
num_errors++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct gsm_bts *bts;
|
||||
|
||||
static void signal_handler(int signal)
|
||||
{
|
||||
fprintf(stderr, "signal %u received\n", signal);
|
||||
|
||||
switch (signal) {
|
||||
case SIGINT:
|
||||
//osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
|
||||
bts_shutdown(bts, "SIGINT");
|
||||
break;
|
||||
case SIGABRT:
|
||||
case SIGUSR1:
|
||||
case SIGUSR2:
|
||||
talloc_report_full(tall_bts_ctx, stderr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int write_pid_file(char *procname)
|
||||
{
|
||||
FILE *outf;
|
||||
char tmp[PATH_MAX+1];
|
||||
|
||||
snprintf(tmp, sizeof(tmp)-1, "/var/run/%s.pid", procname);
|
||||
tmp[PATH_MAX-1] = '\0';
|
||||
|
||||
outf = fopen(tmp, "w");
|
||||
if (!outf)
|
||||
return -1;
|
||||
|
||||
fprintf(outf, "%d\n", getpid());
|
||||
|
||||
fclose(outf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int lc15bts_ctrlif_inst_cmds(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct stat st;
|
||||
struct sched_param param;
|
||||
struct gsm_bts_role_bts *btsb;
|
||||
struct e1inp_line *line;
|
||||
void *tall_msgb_ctx;
|
||||
struct osmo_fd accept_fd, read_fd;
|
||||
int vty_port;
|
||||
int rc;
|
||||
|
||||
|
||||
tall_bts_ctx = talloc_named_const(NULL, 1, "lc15BTS context");
|
||||
tall_msgb_ctx = talloc_pool(tall_bts_ctx, 100*1024);
|
||||
msgb_set_talloc_ctx(tall_msgb_ctx);
|
||||
|
||||
bts_log_init(NULL);
|
||||
|
||||
bts = gsm_bts_alloc(tall_bts_ctx);
|
||||
vty_init(&bts_vty_info);
|
||||
e1inp_vty_init();
|
||||
bts_vty_init(bts, &bts_log_info);
|
||||
|
||||
handle_options(argc, argv);
|
||||
|
||||
/* enable realtime priority for us */
|
||||
if (rt_prio != -1) {
|
||||
memset(¶m, 0, sizeof(param));
|
||||
param.sched_priority = rt_prio;
|
||||
rc = sched_setscheduler(getpid(), SCHED_RR, ¶m);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "Setting SCHED_RR priority(%d) failed: %s\n",
|
||||
param.sched_priority, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (gsmtap_ip) {
|
||||
gsmtap = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1);
|
||||
if (!gsmtap) {
|
||||
fprintf(stderr, "Failed during gsmtap_init()\n");
|
||||
exit(1);
|
||||
}
|
||||
gsmtap_source_add_sink(gsmtap);
|
||||
}
|
||||
|
||||
if (bts_init(bts) < 0) {
|
||||
fprintf(stderr, "unable to open bts\n");
|
||||
exit(1);
|
||||
}
|
||||
btsb = bts_role_bts(bts);
|
||||
btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3);
|
||||
|
||||
abis_init(bts);
|
||||
|
||||
rc = vty_read_config_file(config_file, NULL);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to parse the config file: '%s'\n",
|
||||
config_file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (stat(LC15BTS_RF_LOCK_PATH(trx_nr), &st) == 0) {
|
||||
LOGP(DL1C, LOGL_NOTICE, "Not starting BTS due to RF_LOCK file present\n");
|
||||
exit(23);
|
||||
}
|
||||
write_pid_file(LC15BTS_PID_FILE(trx_nr));
|
||||
|
||||
bts_controlif_setup(bts);
|
||||
|
||||
vty_port = (trx_nr == 1) ? OSMO_VTY_PORT_BTS : (OSMO_VTY_PORT_BTS + 1000);
|
||||
rc = telnet_init(tall_bts_ctx, NULL, vty_port);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Error initializing telnet\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* NTQD: For testing, we only support PCU on the first TRX */
|
||||
if (trx_nr == 1) {
|
||||
if (pcu_sock_init()) {
|
||||
fprintf(stderr, "PCU L1 socket failed\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
signal(SIGINT, &signal_handler);
|
||||
//signal(SIGABRT, &signal_handler);
|
||||
signal(SIGUSR1, &signal_handler);
|
||||
signal(SIGUSR2, &signal_handler);
|
||||
osmo_init_ignore_signals();
|
||||
|
||||
rc = oml_router_init(bts, OML_ROUTER_PATH, &accept_fd, &read_fd);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Error creating the OML router: %s rc=%d\n",
|
||||
OML_ROUTER_PATH, rc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!btsb->bsc_oml_host) {
|
||||
fprintf(stderr, "Cannot start BTS without knowing BSC OML IP\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
line = abis_open(bts, btsb->bsc_oml_host, "lc15BTS");
|
||||
if (!line) {
|
||||
fprintf(stderr, "unable to connect to BSC\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (daemonize) {
|
||||
rc = osmo_daemonize();
|
||||
if (rc < 0) {
|
||||
perror("Error during daemonize");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
log_reset_context();
|
||||
osmo_select_main(0);
|
||||
}
|
||||
return num_errors;
|
||||
}
|
||||
|
||||
void bts_model_abis_close(struct gsm_bts *bts)
|
||||
|
@ -429,3 +202,8 @@ void bts_model_abis_close(struct gsm_bts *bts)
|
|||
/* for now, we simply terminate the program and re-spawn */
|
||||
bts_shutdown(bts, "Abis close");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return bts_main(argc, argv);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <osmo-bts/amr.h>
|
||||
#include <osmo-bts/bts.h>
|
||||
#include <osmo-bts/bts_model.h>
|
||||
#include <osmo-bts/phy_link.h>
|
||||
#include <osmo-bts/handover.h>
|
||||
#include <osmo-bts/l1sap.h>
|
||||
|
||||
|
|
|
@ -114,14 +114,3 @@ int lc15bts_select_lc15_band(struct gsm_bts_trx *trx, uint16_t arfcn)
|
|||
/* give up */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int lc15bts_get_nominal_power(struct gsm_bts_trx *trx)
|
||||
{
|
||||
return 37;
|
||||
}
|
||||
|
||||
struct lc15l1_hdl *trx_lc15l1_hdl(struct gsm_bts_trx *trx)
|
||||
{
|
||||
return trx->role_bts.l1h;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,4 @@ int band_lc152osmo(GsmL1_FreqBand_t band);
|
|||
|
||||
int lc15bts_select_lc15_band(struct gsm_bts_trx *trx, uint16_t arfcn);
|
||||
|
||||
int lc15bts_get_nominal_power(struct gsm_bts_trx *trx);
|
||||
|
||||
struct lc15l1_hdl *trx_lc15l1_hdl(struct gsm_bts_trx *trx);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue