diff options
author | Harald Welte <laforge@gnumonks.org> | 2016-01-09 13:13:37 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-02-15 14:18:59 +0100 |
commit | d784e50747b8cf0ce505489e1451f75be5ccbd4b (patch) | |
tree | b143bbf2162bea0959ba9b80cc5d1573de7d62ee /src/osmo-bts-trx/trx_vty.c | |
parent | f58542899a91d1db0bbe9966ae98ccdf449f45d0 (diff) |
Introduce new phy_link and phy_instance abstraction
This way we can model a flexible mapping between any number of PHYs,
each having multiple instances, and then map BTSs with TRXx on top of
those PHYs.
Diffstat (limited to 'src/osmo-bts-trx/trx_vty.c')
-rw-r--r-- | src/osmo-bts-trx/trx_vty.c | 381 |
1 files changed, 233 insertions, 148 deletions
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index a4a79091..d2feea4c 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -45,6 +45,8 @@ #include "trx_if.h" #include "loops.h" +#define OSMOTRX_STR "OsmoTRX Transceiver configuration\n" + static struct gsm_bts *vty_bts; DEFUN(show_transceiver, show_transceiver_cmd, "show transceiver", @@ -53,7 +55,6 @@ DEFUN(show_transceiver, show_transceiver_cmd, "show transceiver", struct gsm_bts *bts = vty_bts; struct gsm_bts_trx *trx; struct trx_l1h *l1h; - uint8_t tn; if (!transceiver_available) { vty_out(vty, "transceiver is not connected%s", VTY_NEWLINE); @@ -63,7 +64,8 @@ DEFUN(show_transceiver, show_transceiver_cmd, "show transceiver", } llist_for_each_entry(trx, &bts->trx_list, list) { - l1h = trx_l1h_hdl(trx); + struct phy_instance *pinst = trx_phy_instance(trx); + l1h = pinst->u.osmotrx.hdl; vty_out(vty, "TRX %d%s", trx->nr, VTY_NEWLINE); vty_out(vty, " %s%s", (l1h->config.poweron) ? "poweron":"poweroff", @@ -85,56 +87,70 @@ DEFUN(show_transceiver, show_transceiver_cmd, "show transceiver", VTY_NEWLINE); else vty_out(vty, " bisc : undefined%s", VTY_NEWLINE); - if (l1h->config.rxgain_valid) - vty_out(vty, " rxgain : %d%s", l1h->config.rxgain, + } + + return CMD_SUCCESS; +} + + +static void show_phy_inst_single(struct vty *vty, struct phy_instance *pinst) +{ + uint8_t tn; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; + + vty_out(vty, "PHY Instance %s%s", + phy_instance_name(pinst), VTY_NEWLINE); + if (l1h->config.maxdly_valid) + vty_out(vty, " maxdly : %d%s", l1h->config.maxdly, + VTY_NEWLINE); + else + vty_out(vty, " maxdly : undefined%s", VTY_NEWLINE); + for (tn = 0; tn < TRX_NR_TS; tn++) { + if (!((1 << tn) & l1h->config.slotmask)) + vty_out(vty, " slot #%d: unsupported%s", tn, VTY_NEWLINE); - else - vty_out(vty, " rxgain : undefined%s", VTY_NEWLINE); - if (l1h->config.power_valid) - vty_out(vty, " power : %d%s", l1h->config.power, + else if (l1h->config.slottype_valid[tn]) + vty_out(vty, " slot #%d: type %d%s", tn, + l1h->config.slottype[tn], VTY_NEWLINE); else - vty_out(vty, " power : undefined%s", VTY_NEWLINE); - if (l1h->config.maxdly_valid) - vty_out(vty, " maxdly : %d%s", l1h->config.maxdly, + vty_out(vty, " slot #%d: undefined%s", tn, VTY_NEWLINE); - else - vty_out(vty, " maxdly : undefined%s", VTY_NEWLINE); - for (tn = 0; tn < TRX_NR_TS; tn++) { - if (!((1 << tn) & l1h->config.slotmask)) - vty_out(vty, " slot #%d: unsupported%s", tn, - VTY_NEWLINE); - else if (l1h->config.slottype_valid[tn]) - vty_out(vty, " slot #%d: type %d%s", tn, - l1h->config.slottype[tn], - VTY_NEWLINE); - else - vty_out(vty, " slot #%d: undefined%s", tn, - VTY_NEWLINE); - } } - - return CMD_SUCCESS; } -DEFUN(cfg_bts_fn_advance, cfg_bts_fn_advance_cmd, - "fn-advance <0-30>", - "Set the number of frames to be transmitted to transceiver in advance " - "of current FN\n" - "Advance in frames\n") +static void show_phy_single(struct vty *vty, struct phy_link *plink) { - trx_clock_advance = atoi(argv[0]); + struct phy_instance *pinst; - return CMD_SUCCESS; + vty_out(vty, "PHY %u%s", plink->num, VTY_NEWLINE); + + if (plink->u.osmotrx.rxgain_valid) + vty_out(vty, " rx-gain : %d dB%s", + plink->u.osmotrx.rxgain, VTY_NEWLINE); + else + vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE); + if (plink->u.osmotrx.power_valid) + vty_out(vty, " tx-attenuation : %d dB%s", + plink->u.osmotrx.power, VTY_NEWLINE); + else + vty_out(vty, " tx-attenuation : undefined%s", VTY_NEWLINE); + + llist_for_each_entry(pinst, &plink->instances, list) + show_phy_inst_single(vty, pinst); } -DEFUN(cfg_bts_rts_advance, cfg_bts_rts_advance_cmd, - "rts-advance <0-30>", - "Set the number of frames to be requested (PCU) in advance of current " - "FN. Do not change this, unless you have a good reason!\n" - "Advance in frames\n") +DEFUN(show_phy, show_phy_cmd, "show phy", + SHOW_STR "Display information about the available PHYs") { - trx_rts_advance = atoi(argv[0]); + int i; + + for (i = 0; i < 255; i++) { + struct phy_link *plink = phy_link_by_num(i); + if (!plink) + break; + show_phy_single(vty, plink); + } return CMD_SUCCESS; } @@ -220,63 +236,14 @@ DEFUN(cfg_bts_no_setbsic, cfg_bts_no_setbsic_cmd, return CMD_SUCCESS; } -DEFUN(cfg_trx_rxgain, cfg_trx_rxgain_cmd, - "rxgain <0-50>", - "Set the receiver gain in dB\n" - "Gain in dB\n") -{ - struct gsm_bts_trx *trx = vty->index; - struct trx_l1h *l1h = trx_l1h_hdl(trx); - l1h->config.rxgain = atoi(argv[0]); - l1h->config.rxgain_valid = 1; - l1h->config.rxgain_sent = 0; - l1if_provision_transceiver_trx(l1h); - - return CMD_SUCCESS; -} - -DEFUN(cfg_trx_power, cfg_trx_power_cmd, - "power <0-50>", - "Set the transmitter power dampening\n" - "Power dampening in dB\n") -{ - struct gsm_bts_trx *trx = vty->index; - struct trx_l1h *l1h = trx_l1h_hdl(trx); - - l1h->config.power = atoi(argv[0]); - l1h->config.power_oml = 0; - l1h->config.power_valid = 1; - l1h->config.power_sent = 0; - l1if_provision_transceiver_trx(l1h); - - return CMD_SUCCESS; -} - -DEFUN(cfg_trx_poweroml_, cfg_trx_power_oml_cmd, - "power oml", - "Set the transmitter power dampening\n" - "Given by NM_ATT_RF_MAXPOWR_R (max power reduction) via OML\n") -{ - struct gsm_bts_trx *trx = vty->index; - struct trx_l1h *l1h = trx_l1h_hdl(trx); - - l1h->config.power = trx->max_power_red; - l1h->config.power_oml = 1; - l1h->config.power_valid = 1; - l1h->config.power_sent = 0; - l1if_provision_transceiver_trx(l1h); - - return CMD_SUCCESS; -} - -DEFUN(cfg_trx_maxdly, cfg_trx_maxdly_cmd, - "maxdly <0-31>", +DEFUN(cfg_phyinst_maxdly, cfg_phyinst_maxdly_cmd, + "osmotrx maxdly <0-31>", "Set the maximum delay of GSM symbols\n" "GSM symbols (approx. 1.1km per symbol)\n") { - struct gsm_bts_trx *trx = vty->index; - struct trx_l1h *l1h = trx_l1h_hdl(trx); + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; l1h->config.maxdly = atoi(argv[0]); l1h->config.maxdly_valid = 1; @@ -286,7 +253,7 @@ DEFUN(cfg_trx_maxdly, cfg_trx_maxdly_cmd, return CMD_SUCCESS; } -DEFUN(cfg_trx_slotmask, cfg_trx_slotmask_cmd, +DEFUN(cfg_phyinst_slotmask, cfg_phyinst_slotmask_cmd, "slotmask (1|0) (1|0) (1|0) (1|0) (1|0) (1|0) (1|0) (1|0)", "Set the supported slots\n" "TS0 supported\nTS0 unsupported\nTS1 supported\nTS1 unsupported\n" @@ -294,8 +261,8 @@ DEFUN(cfg_trx_slotmask, cfg_trx_slotmask_cmd, "TS4 supported\nTS4 unsupported\nTS5 supported\nTS5 unsupported\n" "TS6 supported\nTS6 unsupported\nTS7 supported\nTS7 unsupported\n") { - struct gsm_bts_trx *trx = vty->index; - struct trx_l1h *l1h = trx_l1h_hdl(trx); + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; uint8_t tn; l1h->config.slotmask = 0; @@ -306,76 +273,171 @@ DEFUN(cfg_trx_slotmask, cfg_trx_slotmask_cmd, return CMD_SUCCESS; } -DEFUN(cfg_trx_no_rxgain, cfg_trx_no_rxgain_cmd, - "no rxgain <0-50>", - NO_STR "Unset the receiver gain in dB\n" + +DEFUN(cfg_phy_fn_advance, cfg_phy_fn_advance_cmd, + "osmotrx fn-advance <0-30>", + OSMOTRX_STR + "Set the number of frames to be transmitted to transceiver in advance " + "of current FN\n" + "Advance in frames\n") +{ + struct phy_link *plink = vty->index; + + plink->u.osmotrx.clock_advance = atoi(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_phy_rts_advance, cfg_phy_rts_advance_cmd, + "osmotrx rts-advance <0-30>", + OSMOTRX_STR + "Set the number of frames to be requested (PCU) in advance of current " + "FN. Do not change this, unless you have a good reason!\n" + "Advance in frames\n") +{ + struct phy_link *plink = vty->index; + + plink->u.osmotrx.rts_advance = atoi(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_phy_rxgain, cfg_phy_rxgain_cmd, + "osmotrx rx-gain <0-50>", + OSMOTRX_STR + "Set the receiver gain in dB\n" "Gain in dB\n") { - struct gsm_bts_trx *trx = vty->index; - struct trx_l1h *l1h = trx_l1h_hdl(trx); + struct phy_link *plink = vty->index; - l1h->config.rxgain_valid = 0; + plink->u.osmotrx.rxgain = atoi(argv[0]); + plink->u.osmotrx.rxgain_valid = 1; + plink->u.osmotrx.rxgain_sent = 0; return CMD_SUCCESS; } -DEFUN(cfg_trx_no_power, cfg_trx_no_power_cmd, - "no power <0-50>", - NO_STR "Unset the transmitter power dampening\n" - "Power dampening in dB\n") +DEFUN(cfg_phy_tx_atten, cfg_phy_tx_atten_cmd, + "osmotrx tx-attenuation <0-50>", + OSMOTRX_STR + "Set the transmitter attenuation\n" + "Fixed attenuation in dB, overriding OML\n") { - struct gsm_bts_trx *trx = vty->index; - struct trx_l1h *l1h = trx_l1h_hdl(trx); + struct phy_link *plink = vty->index; - l1h->config.power_valid = 0; + plink->u.osmotrx.power = atoi(argv[0]); + plink->u.osmotrx.power_oml = 0; + plink->u.osmotrx.power_valid = 1; + plink->u.osmotrx.power_sent = 0; return CMD_SUCCESS; } -DEFUN(cfg_trx_no_maxdly, cfg_trx_no_maxdly_cmd, - "no maxdly <0-31>", - NO_STR "Unset the maximum delay of GSM symbols\n" - "GSM symbols (approx. 1.1km per symbol)\n") +DEFUN(cfg_phy_tx_atten_oml, cfg_phy_tx_atten_oml_cmd, + "osmotrx tx-attenuation oml", + OSMOTRX_STR + "Set the transmitter attenuation\n" + "Use NM_ATT_RF_MAXPOWR_R (max power reduction) from BSC via OML\n") +{ + struct phy_link *plink = vty->index; + + plink->u.osmotrx.power_oml = 1; + plink->u.osmotrx.power_valid = 1; + plink->u.osmotrx.power_sent = 0; + + return CMD_SUCCESS; +} + +DEFUN(cfg_phy_no_rxgain, cfg_phy_no_rxgain_cmd, + "no osmotrx rx-gain", + NO_STR OSMOTRX_STR "Unset the receiver gain in dB\n") +{ + struct phy_link *plink = vty->index; + + plink->u.osmotrx.rxgain_valid = 0; + + return CMD_SUCCESS; +} + +DEFUN(cfg_phy_no_tx_atten, cfg_phy_no_tx_atten_cmd, + "no osmotrx tx-attenuation", + NO_STR OSMOTRX_STR "Unset the transmitter attenuation\n") { - struct gsm_bts_trx *trx = vty->index; - struct trx_l1h *l1h = trx_l1h_hdl(trx); + struct phy_link *plink = vty->index; + + plink->u.osmotrx.power_valid = 0; + + return CMD_SUCCESS; +} + +DEFUN(cfg_phyinst_no_maxdly, cfg_phyinst_no_maxdly_cmd, + "no osmotrx maxdly", + NO_STR "Unset the maximum delay of GSM symbols\n") +{ + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; l1h->config.maxdly_valid = 0; return CMD_SUCCESS; } -void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts) +DEFUN(cfg_phy_transc_ip, cfg_phy_transc_ip_cmd, + "osmotrx ip HOST", + OSMOTRX_STR + "Set remote IP address\n" + "IP address of OsmoTRX\n") { - vty_out(vty, " fn-advance %d%s", trx_clock_advance, VTY_NEWLINE); - vty_out(vty, " rts-advance %d%s", trx_rts_advance, VTY_NEWLINE); + struct phy_link *plink = vty->index; - if (trx_ms_power_loop) - vty_out(vty, " ms-power-loop %d%s", trx_target_rssi, - VTY_NEWLINE); - else - vty_out(vty, " no ms-power-loop%s", VTY_NEWLINE); - vty_out(vty, " %stiming-advance-loop%s", (trx_ta_loop) ? "":"no ", - VTY_NEWLINE); - if (settsc_enabled) - vty_out(vty, " settsc%s", VTY_NEWLINE); - if (setbsic_enabled) - vty_out(vty, " setbsic%s", VTY_NEWLINE); + if (plink->u.osmotrx.transceiver_ip) + talloc_free(plink->u.osmotrx.transceiver_ip); + plink->u.osmotrx.transceiver_ip = talloc_strdup(plink, argv[0]); + + return CMD_SUCCESS; } -void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx) +DEFUN(cfg_phy_base_port, cfg_phy_base_port_cmd, + "osmotrx base-port (local|remote) <0-65535>", + OSMOTRX_STR "Set base UDP port number\n" "Local UDP port\n" + "Remote UDP port\n" "UDP base port number\n") { - struct trx_l1h *l1h = trx_l1h_hdl(trx); + struct phy_link *plink = vty->index; + + if (!strcmp(argv[0], "local")) + plink->u.osmotrx.base_port_local = atoi(argv[1]); + else + plink->u.osmotrx.base_port_remote = atoi(argv[1]); + + return CMD_SUCCESS; +} - if (l1h->config.rxgain_valid) - vty_out(vty, " rxgain %d%s", l1h->config.rxgain, VTY_NEWLINE); - if (l1h->config.power_valid) { - if (l1h->config.power_oml) - vty_out(vty, " power oml%s", VTY_NEWLINE); +void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) +{ + if (plink->u.osmotrx.transceiver_ip) + vty_out(vty, " osmotrx ip %s%s", + plink->u.osmotrx.transceiver_ip, VTY_NEWLINE); + + vty_out(vty, " osmotrx fn-advance %d%s", + plink->u.osmotrx.clock_advance, VTY_NEWLINE); + vty_out(vty, " osmotrx rts-advance %d%s", + plink->u.osmotrx.rts_advance, VTY_NEWLINE); + if (plink->u.osmotrx.rxgain_valid) + vty_out(vty, " osmotrx rx-gain %d%s", + plink->u.osmotrx.rxgain, VTY_NEWLINE); + if (plink->u.osmotrx.power_valid) { + if (plink->u.osmotrx.power_oml) + vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE); else - vty_out(vty, " power %d%s", l1h->config.power, - VTY_NEWLINE); + vty_out(vty, " osmotrx tx-attenuation %d%s", + plink->u.osmotrx.power, VTY_NEWLINE); } +} + +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) +{ + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; + if (l1h->config.maxdly_valid) vty_out(vty, " maxdly %d%s", l1h->config.maxdly, VTY_NEWLINE); if (l1h->config.slotmask != 0xff) @@ -391,14 +453,32 @@ void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx) VTY_NEWLINE); } +void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts) +{ + if (trx_ms_power_loop) + vty_out(vty, " ms-power-loop %d%s", trx_target_rssi, + VTY_NEWLINE); + else + vty_out(vty, " no ms-power-loop%s", VTY_NEWLINE); + vty_out(vty, " %stiming-advance-loop%s", (trx_ta_loop) ? "":"no ", + VTY_NEWLINE); + if (settsc_enabled) + vty_out(vty, " settsc%s", VTY_NEWLINE); + if (setbsic_enabled) + vty_out(vty, " setbsic%s", VTY_NEWLINE); +} + +void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx) +{ +} + int bts_model_vty_init(struct gsm_bts *bts) { vty_bts = bts; install_element_ve(&show_transceiver_cmd); + install_element_ve(&show_phy_cmd); - install_element(BTS_NODE, &cfg_bts_fn_advance_cmd); - install_element(BTS_NODE, &cfg_bts_rts_advance_cmd); install_element(BTS_NODE, &cfg_bts_ms_power_loop_cmd); install_element(BTS_NODE, &cfg_bts_no_ms_power_loop_cmd); install_element(BTS_NODE, &cfg_bts_timing_advance_loop_cmd); @@ -408,14 +488,19 @@ int bts_model_vty_init(struct gsm_bts *bts) install_element(BTS_NODE, &cfg_bts_no_settsc_cmd); install_element(BTS_NODE, &cfg_bts_no_setbsic_cmd); - install_element(TRX_NODE, &cfg_trx_rxgain_cmd); - install_element(TRX_NODE, &cfg_trx_power_cmd); - install_element(TRX_NODE, &cfg_trx_power_oml_cmd); - install_element(TRX_NODE, &cfg_trx_maxdly_cmd); - install_element(TRX_NODE, &cfg_trx_slotmask_cmd); - install_element(TRX_NODE, &cfg_trx_no_rxgain_cmd); - install_element(TRX_NODE, &cfg_trx_no_power_cmd); - install_element(TRX_NODE, &cfg_trx_no_maxdly_cmd); + install_element(PHY_NODE, &cfg_phy_base_port_cmd); + install_element(PHY_NODE, &cfg_phy_fn_advance_cmd); + install_element(PHY_NODE, &cfg_phy_rts_advance_cmd); + install_element(PHY_NODE, &cfg_phy_transc_ip_cmd); + install_element(PHY_NODE, &cfg_phy_rxgain_cmd); + install_element(PHY_NODE, &cfg_phy_tx_atten_cmd); + install_element(PHY_NODE, &cfg_phy_tx_atten_oml_cmd); + install_element(PHY_NODE, &cfg_phy_no_rxgain_cmd); + install_element(PHY_NODE, &cfg_phy_no_tx_atten_cmd); + + install_element(PHY_INST_NODE, &cfg_phyinst_slotmask_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_maxdly_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_no_maxdly_cmd); return 0; } |