fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/43607?usp=email )
(
3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: proxy: implement power measurement emulation ......................................................................
proxy: implement power measurement emulation
Add the TRXC MEASURE command, used by the MS side (trxcon) to probe RF power on a given frequency. Scan all powered-on channels on the requested frequency: if found, report the RSSI it would be measured at using the same path-loss formula (or FAKE_RSSI override) as burst forwarding; if not, report a fixed noise floor.
The noise floor is configurable via the new 'pm-rssi-noise' VTY command under the 'proxy' node (default -110 dBm).
Change-Id: I9be028ae9c1a20caf24327b7ee81eeeabbda0634 Related: OS#6672 --- M proxy/include/osmocom/proxy/path_sim.h M proxy/include/osmocom/proxy/proxy.h M proxy/src/ctrl_cmd.c M proxy/src/path_sim.c M proxy/src/proxy.c M proxy/src/vty.c 6 files changed, 74 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved
diff --git a/proxy/include/osmocom/proxy/path_sim.h b/proxy/include/osmocom/proxy/path_sim.h index d27a3b1..c263eea 100644 --- a/proxy/include/osmocom/proxy/path_sim.h +++ b/proxy/include/osmocom/proxy/path_sim.h @@ -30,3 +30,4 @@ struct proxy_trx_chan *dst, const struct osmo_trxd_burst_req *br, const struct proxy_trx_chan *src); +int path_sim_measure(uint32_t freq_hz, int rssi_noise); diff --git a/proxy/include/osmocom/proxy/proxy.h b/proxy/include/osmocom/proxy/proxy.h index 080ff53..2d17ce9 100644 --- a/proxy/include/osmocom/proxy/proxy.h +++ b/proxy/include/osmocom/proxy/proxy.h @@ -13,8 +13,12 @@ #define PROXY_DEFAULT_MS_NAME "ms" #define PROXY_DEFAULT_MS_PORT 6700
+/*! RSSI (dBm) reported by MEASURE for a frequency with no Tx found on it */ +#define PROXY_DEFAULT_PM_RSSI_NOISE -110 + struct proxy_ctx { char *bind_addr; + int path_sim_noise_dbm; /*!< dBm, MEASURE result for frequencies with no Tx found */ struct llist_head trx_list; /*!< struct proxy_trx::list */ };
diff --git a/proxy/src/ctrl_cmd.c b/proxy/src/ctrl_cmd.c index 449fe81..9a86bb1 100644 --- a/proxy/src/ctrl_cmd.c +++ b/proxy/src/ctrl_cmd.c @@ -29,6 +29,7 @@ #include <osmocom/trx/ep.h> #include <osmocom/trx/trxc.h>
+#include <osmocom/proxy/proxy.h> #include <osmocom/proxy/trx.h> #include <osmocom/proxy/path_sim.h> #include <osmocom/proxy/logging.h> @@ -36,6 +37,7 @@ /* Not part of the well-known OSMO_TRXC_CMD_* verbs (libosmo-trx/trxc.h) since * they are specific to this transceiver's RF path simulation. */ #define CTRL_CMD_SETTA "SETTA" +#define CTRL_CMD_MEASURE "MEASURE" #define CTRL_CMD_FAKE_TOA "FAKE_TOA" #define CTRL_CMD_FAKE_RSSI "FAKE_RSSI" #define CTRL_CMD_FAKE_CI "FAKE_CI" @@ -274,6 +276,23 @@ "Dropping %d burst(s), every %d frame(s)\n", amount, period); }
+static void ctrl_cmd_measure(struct proxy_trx *trx, unsigned int chan, + const struct osmo_trxc_msg *cmd, struct osmo_trxc_msg *rsp) +{ + int freq_khz, rssi; + + if (osmo_trxc_msg_params_scan(cmd, "%d", &freq_khz) != 1) { + LOGP_TRXCH(trx, chan, DTRXC, LOGL_ERROR, + "%s(): Failed to parse target frequency: '%s'\n", + __func__, osmo_trxc_msg_name(cmd)); + rsp->status = 1; + return; + } + + rssi = path_sim_measure(freq_khz * 1000, g_proxy_ctx->path_sim_noise_dbm); + snprintf(rsp->params, sizeof(rsp->params), "%d %d", freq_khz, rssi); +} + void osmo_trx_ep_rx_ctrl_msg(struct osmo_trx_ep *ep, unsigned int chan, const struct osmo_trxc_msg *cmd) { @@ -304,6 +323,8 @@ ctrl_cmd_rfmute(trx, chan, cmd, &rsp); } else if (!strcmp(cmd->cmd, CTRL_CMD_SETTA)) { ctrl_cmd_setta(trx, chan, cmd, &rsp); + } else if (!strcmp(cmd->cmd, CTRL_CMD_MEASURE)) { + ctrl_cmd_measure(trx, chan, cmd, &rsp); } else if (!strcmp(cmd->cmd, CTRL_CMD_FAKE_TOA)) { ctrl_cmd_fake_toa(trx, chan, cmd, &rsp); } else if (!strcmp(cmd->cmd, CTRL_CMD_FAKE_RSSI)) { diff --git a/proxy/src/path_sim.c b/proxy/src/path_sim.c index b835f76..d51c20a 100644 --- a/proxy/src/path_sim.c +++ b/proxy/src/path_sim.c @@ -27,6 +27,7 @@
#include <osmocom/trx/trxd.h>
+#include <osmocom/proxy/proxy.h> #include <osmocom/proxy/trx.h> #include <osmocom/proxy/path_sim.h>
@@ -119,3 +120,34 @@ bi->ci_cb = dst->path_sim.ci + path_sim_jitter(dst->path_sim.ci_jitter); bi->flags |= OSMO_TRXD_F_CI_CB; } + +static int path_sim_measure_rssi(const struct proxy_trx_chan *tx) +{ + if (tx->path_sim.flags & PATH_SIM_F_FAKE_RSSI) + return tx->path_sim.rssi; + + return (tx->path_sim.tx_power - tx->path_sim.tx_att) - PATH_SIM_PATH_LOSS_DEFAULT; +} + +/*! Emulate a power measurement (MEASURE CTRL command) on a given Tx + * frequency: if some powered-on channel is currently transmitting on it, + * return the RSSI it would be measured at (same path-loss formula, or + * FAKE_RSSI override, as path_sim_apply()); otherwise return rssi_noise. */ +int path_sim_measure(uint32_t freq_hz, int rssi_noise) +{ + struct proxy_trx *trx; + + llist_for_each_entry(trx, &g_proxy_ctx->trx_list, list) { + unsigned int chan; + + if (!trx->powered) + continue; + + for (chan = 0; chan < trx->num_chans; chan++) { + if (trx->chans[chan].tx_freq == freq_hz) + return path_sim_measure_rssi(&trx->chans[chan]); + } + } + + return rssi_noise; +} diff --git a/proxy/src/proxy.c b/proxy/src/proxy.c index b194bc9..4495909 100644 --- a/proxy/src/proxy.c +++ b/proxy/src/proxy.c @@ -45,6 +45,7 @@ return NULL;
proxy->bind_addr = talloc_strdup(proxy, PROXY_DEFAULT_BIND_ADDR); + proxy->path_sim_noise_dbm = PROXY_DEFAULT_PM_RSSI_NOISE; INIT_LLIST_HEAD(&proxy->trx_list);
return proxy; diff --git a/proxy/src/vty.c b/proxy/src/vty.c index ec986d0..aa8288a 100644 --- a/proxy/src/vty.c +++ b/proxy/src/vty.c @@ -91,6 +91,19 @@ return CMD_SUCCESS; }
+DEFUN(cfg_proxy_pm_rssi_noise, + cfg_proxy_pm_rssi_noise_cmd, + "pm-rssi-noise <-150-0>", + "Set the RSSI reported by MEASURE for a frequency with no Tx found\n" + "RSSI in dBm\n") +{ + struct proxy_ctx *proxy = vty->index; + + proxy->path_sim_noise_dbm = atoi(argv[0]); + + return CMD_SUCCESS; +} + DEFUN(cfg_proxy_ep, cfg_proxy_ep_cmd, "ep NAME", @@ -220,6 +233,7 @@ vty_out(vty, "proxy%s", VTY_NEWLINE); if (g_proxy_ctx->bind_addr) vty_out(vty, " bind-addr %s%s", g_proxy_ctx->bind_addr, VTY_NEWLINE); + vty_out(vty, " pm-rssi-noise %d%s", g_proxy_ctx->path_sim_noise_dbm, VTY_NEWLINE);
llist_for_each_entry(trx, &g_proxy_ctx->trx_list, list) { const char *raddr = osmo_trx_ep_get_raddr(trx->ep); @@ -322,6 +336,7 @@ install_element(CONFIG_NODE, &cfg_proxy_cmd); install_node(&proxy_node, config_write_proxy); install_element(PROXY_NODE, &cfg_proxy_bind_addr_cmd); + install_element(PROXY_NODE, &cfg_proxy_pm_rssi_noise_cmd); install_element(PROXY_NODE, &cfg_proxy_ep_cmd); install_element(PROXY_NODE, &cfg_no_proxy_ep_cmd);