aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith <keith@rhizomatica.org>2021-09-21 00:09:59 +0200
committerKeith <keith@rhizomatica.org>2021-09-21 00:13:28 +0200
commitdfde60cc6668a921ba65a68389262d761009b75e (patch)
tree90e762154458578ab601f65a5cc0de932c520874
parentaa4d99fd8b11f922a2bc9828b427affa8e25560c (diff)
Implement crude BSC Uplink Power Control Loopkeith/uplink_power_loop
-rw-r--r--src/osmo-bsc/abis_rsl.c38
-rw-r--r--src/osmo-bsc/bsc_vty.c27
2 files changed, 64 insertions, 1 deletions
diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c
index c7399ebef..7340e70f9 100644
--- a/src/osmo-bsc/abis_rsl.c
+++ b/src/osmo-bsc/abis_rsl.c
@@ -377,7 +377,7 @@ int rsl_chan_ms_power_ctrl(struct gsm_lchan *lchan)
if (chan_nr < 0)
return chan_nr;
- LOG_LCHAN(lchan, LOGL_DEBUG, "Tx MS POWER CONTROL (ms_power_lvl=%" PRIu8 ")\n",
+ LOG_LCHAN(lchan, LOGL_INFO, "Tx MS POWER CONTROL (ms_power_lvl=%" PRIu8 ")\n",
lchan->ms_power);
msg = rsl_msgb_alloc();
@@ -396,6 +396,40 @@ int rsl_chan_ms_power_ctrl(struct gsm_lchan *lchan)
return abis_rsl_sendmsg(msg);
}
+static void crude_ms_power_loop(struct gsm_lchan *lchan, struct gsm_meas_rep *mr) {
+ uint8_t cur_lev;
+ int8_t cur_pwr_rep;
+ int8_t cur_pwr_lchan;
+ enum gsm_band band = lchan->ts->trx->bts->band;
+ int8_t new_pwr;
+
+ /* -110 + cur_lev = dBm */
+ cur_lev = mr->ul.full.rx_lev;
+ cur_pwr_rep = mr->ms_l1.pwr; /* MS power in dBm */
+ cur_pwr_lchan = lchan->ms_power;
+ printf("Uplink receive level is [%d](%ddBm) with power [%d](%ddBm) LCHAN:(%d)(%ddBm)\n",
+ cur_lev, (-110 + cur_lev),
+ ms_pwr_ctl_lvl(band, cur_pwr_rep), cur_pwr_rep,
+ cur_pwr_lchan, ms_pwr_dbm(band, cur_pwr_lchan));
+
+ if (cur_lev > 45) {
+ if (cur_pwr_lchan >= 19)
+ return;
+ new_pwr = cur_pwr_lchan + 1;
+ lchan->ms_power = new_pwr;
+ printf ("We should change to %d.\n", lchan->ms_power);
+ rsl_chan_ms_power_ctrl(lchan);
+ }
+ if (cur_lev < 45) {
+ if (cur_pwr_lchan == 0)
+ return;
+ new_pwr = cur_pwr_lchan - 1;
+ lchan->ms_power = new_pwr;
+ printf ("We should change to %d.\n", lchan->ms_power);
+ rsl_chan_ms_power_ctrl(lchan);
+ }
+}
+
static int channel_mode_from_lchan(struct rsl_ie_chan_mode *cm,
struct gsm_lchan *lchan,
const struct channel_mode_and_rate *ch_mode_rate,
@@ -1338,6 +1372,8 @@ static int rsl_rx_meas_res(struct msgb *msg)
LOGP(DRSL, LOGL_DEBUG, "%s: meas_rep_count++=%d meas_rep_last_seen_nr=%u\n",
gsm_lchan_name(mr->lchan), mr->lchan->meas_rep_count, mr->lchan->meas_rep_last_seen_nr);
+ crude_ms_power_loop(msg->lchan, mr);
+
print_meas_rep(msg->lchan, mr);
send_lchan_signal(S_LCHAN_MEAS_REP, msg->lchan, mr);
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 5ccd78487..8977a08a1 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1884,6 +1884,32 @@ DEFUN_HIDDEN(lchan_act_all_trx, lchan_act_all_trx_cmd,
return CMD_SUCCESS;
}
+DEFUN(lchan_set_mspower, lchan_set_mspower_cmd,
+ "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> ms-power <5-40>\n",
+ BTS_NR_TRX_TS_SS_STR2
+ "Manually force MS Uplink Power Level in dBm on the lchan (for testing)\n")
+{
+ struct gsm_bts_trx_ts *ts;
+ struct gsm_lchan *lchan;
+ int ss_nr = atoi(argv[3]);
+ ts = vty_get_ts(vty, argv[0], argv[1], argv[2]);
+ if (!ts)
+ return CMD_WARNING;
+
+ if (ss_nr >= ts->max_primary_lchans) {
+ vty_out(vty, "%% Invalid sub-slot number for this timeslot type%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ lchan = &ts->lchan[ss_nr];
+ if (!lchan->fi)
+ return CMD_WARNING;
+
+ lchan->ms_power = ms_pwr_ctl_lvl(ts->trx->bts->band, atoi(argv[4]));
+ rsl_chan_ms_power_ctrl(lchan);
+ return CMD_SUCCESS;
+}
+
DEFUN(vamos_modify_lchan, vamos_modify_lchan_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> modify (vamos|non-vamos) " TSC_ARGS_OPT,
BTS_NR_TRX_TS_SS_STR2
@@ -3402,6 +3428,7 @@ int bsc_vty_init(struct gsm_network *network)
install_element(ENABLE_NODE, &lchan_mdcx_cmd);
install_element(ENABLE_NODE, &lchan_set_borken_cmd);
install_element(ENABLE_NODE, &lchan_reassign_cmd);
+ install_element(ENABLE_NODE, &lchan_set_mspower_cmd);
install_element(ENABLE_NODE, &handover_subscr_conn_cmd);
install_element(ENABLE_NODE, &assignment_subscr_conn_cmd);