Hello Vadim Yanitskiy, Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/3044

to look at the new patch set (#4).

TRX: Remove global variables, move SETBSIC/SETTSC handling into phy_link

Whether or not we are talking to an OpenBTS (SETBSIC) or OsmoTRX
(SETTSC) transceiver is a property of the phy_link, and not a property
of the BTS.  Also, we *really, really* should never use global
variables. I'm very happy this is being cleaned up, finally.

Change-Id: I51aeb17661dfd63ff347f7b2c0d7ffa383ec814c
---
M include/osmo-bts/phy_link.h
M src/osmo-bts-trx/trx_if.c
M src/osmo-bts-trx/trx_if.h
M src/osmo-bts-trx/trx_vty.c
4 files changed, 38 insertions(+), 66 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/44/3044/4

diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index 3d4bf91..7011622 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -47,6 +47,7 @@
 
                        uint32_t clock_advance;
                        uint32_t rts_advance;
+                       bool use_legacy_setbsic;
                } osmotrx;
                struct {
                        char *mcast_dev;                /* Network device for 
multicast */
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 8ce2893..86a3b9b 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -51,8 +51,6 @@
 //#define TOA_RSSI_DEBUG
 
 int transceiver_available = 0;
-int settsc_enabled = 0;
-int setbsic_enabled = 0;
 
 #define TRX_MAX_BURST_LEN      512
 
@@ -248,21 +246,21 @@
 /*! Send "SETTSC" command to TRX */
 int trx_if_cmd_settsc(struct trx_l1h *l1h, uint8_t tsc)
 {
-       if (!settsc_enabled)
+       struct phy_instance *pinst = l1h->phy_inst;
+       if (pinst->phy_link->u.osmotrx.use_legacy_setbsic)
                return 0;
-       /* if TSC is enabled only, the positive response is mandatory */
-       return trx_ctrl_cmd(l1h, (setbsic_enabled) ? 0 : 1, "SETTSC", "%d",
-               tsc);
+
+       return trx_ctrl_cmd(l1h, 1, "SETTSC", "%d", tsc);
 }
 
 /*! Send "SETBSIC" command to TRX */
 int trx_if_cmd_setbsic(struct trx_l1h *l1h, uint8_t bsic)
 {
-       if (!setbsic_enabled)
+       struct phy_instance *pinst = l1h->phy_inst;
+       if (!pinst->phy_link->u.osmotrx.use_legacy_setbsic)
                return 0;
-       /* if BSIC is enabled only, the positive response is mandatory */
-       return trx_ctrl_cmd(l1h, (settsc_enabled) ? 0 : 1, "SETBSIC", "%d",
-               bsic);
+
+       return trx_ctrl_cmd(l1h, 1, "SETBSIC", "%d", bsic);
 }
 
 /*! Send "SETRXGAIN" command to TRX */
diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h
index 86fb18f..076e35e 100644
--- a/src/osmo-bts-trx/trx_if.h
+++ b/src/osmo-bts-trx/trx_if.h
@@ -2,8 +2,6 @@
 #define TRX_IF_H
 
 extern int transceiver_available;
-extern int settsc_enabled;
-extern int setbsic_enabled;
 
 struct trx_l1h;
 
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index 6d6cded..482248c 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -197,51 +197,6 @@
        return CMD_SUCCESS;
 }
 
-DEFUN(cfg_bts_settsc, cfg_bts_settsc_cmd,
-       "settsc",
-       "Use SETTSC to configure transceiver\n")
-{
-       settsc_enabled = 1;
-
-       return CMD_SUCCESS;
-}
-
-DEFUN(cfg_bts_setbsic, cfg_bts_setbsic_cmd,
-       "setbsic",
-       "Use SETBSIC to configure transceiver\n")
-{
-       setbsic_enabled = 1;
-
-       return CMD_SUCCESS;
-}
-
-DEFUN(cfg_bts_no_settsc, cfg_bts_no_settsc_cmd,
-       "no settsc",
-       NO_STR "Disable SETTSC to configure transceiver\n")
-{
-       settsc_enabled = 0;
-       if (!setbsic_enabled) {
-               vty_out(vty, "%% Auto enabling SETBSIC.%s", VTY_NEWLINE);
-               setbsic_enabled = 1;
-       }
-
-       return CMD_SUCCESS;
-}
-
-DEFUN(cfg_bts_no_setbsic, cfg_bts_no_setbsic_cmd,
-       "no setbsic",
-       NO_STR "Disable SETBSIC to configure transceiver\n")
-{
-       setbsic_enabled = 0;
-       if (!settsc_enabled) {
-               vty_out(vty, "%% Auto enabling SETTSC.%s", VTY_NEWLINE);
-               settsc_enabled = 1;
-       }
-
-       return CMD_SUCCESS;
-}
-
-
 DEFUN(cfg_phyinst_maxdly, cfg_phyinst_maxdly_cmd,
        "osmotrx maxdly <0-31>",
        "Set the maximum acceptable delay of an Access Burst (in GSM symbols)."
@@ -322,7 +277,6 @@
                vty_out(vty, "OFF: %d%s", trx_if_cmd_poweroff(l1h), 
VTY_NEWLINE);
        else {
                vty_out(vty, "ON: %d%s", trx_if_cmd_poweron(l1h), VTY_NEWLINE);
-               settsc_enabled = 1;
        }
 
        return CMD_SUCCESS;
@@ -503,6 +457,30 @@
        return CMD_SUCCESS;
 }
 
+DEFUN(cfg_phy_setbsic, cfg_phy_setbsic_cmd,
+       "osmotrx legacy-setbsic",
+       "Use SETBSIC to configure transceiver (use ONLY with OpenBTS 
Transceiver!)\n")
+{
+       struct phy_link *plink = vty->index;
+       plink->u.osmotrx.use_legacy_setbsic = true;
+
+       vty_out(vty, "%% You have enabled SETBSIC, which is not supported by 
OsmoTRX "
+               "but only useful if you want to interface with legacy OpenBTS 
Transceivers%s",
+               VTY_NEWLINE);
+
+       return CMD_SUCCESS;
+}
+
+DEFUN(cfg_phy_no_setbsic, cfg_phy_no_setbsic_cmd,
+       "no osmotrx legacy-setbsic",
+       NO_STR "Disable Legacy SETBSIC to configure transceiver\n")
+{
+       struct phy_link *plink = vty->index;
+       plink->u.osmotrx.use_legacy_setbsic = false;
+
+       return CMD_SUCCESS;
+}
+
 void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink)
 {
        if (plink->u.osmotrx.local_ip)
@@ -523,6 +501,9 @@
                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.use_legacy_setbsic)
+               vty_out(vty, " osmotrx leyacy-setbsic%s", VTY_NEWLINE);
 }
 
 void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance 
*pinst)
@@ -565,10 +546,6 @@
                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)
@@ -586,16 +563,14 @@
        install_element(BTS_NODE, &cfg_bts_no_ms_power_loop_cmd);
        install_element(BTS_NODE, &cfg_bts_timing_advance_loop_cmd);
        install_element(BTS_NODE, &cfg_bts_no_timing_advance_loop_cmd);
-       install_element(BTS_NODE, &cfg_bts_settsc_cmd);
-       install_element(BTS_NODE, &cfg_bts_setbsic_cmd);
-       install_element(BTS_NODE, &cfg_bts_no_settsc_cmd);
-       install_element(BTS_NODE, &cfg_bts_no_setbsic_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_osmotrx_ip_cmd);
+       install_element(PHY_NODE, &cfg_phy_setbsic_cmd);
+       install_element(PHY_NODE, &cfg_phy_no_setbsic_cmd);
 
        install_element(PHY_INST_NODE, &cfg_phyinst_rxgain_cmd);
        install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_cmd);

-- 
To view, visit https://gerrit.osmocom.org/3044
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I51aeb17661dfd63ff347f7b2c0d7ffa383ec814c
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msur...@sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofm...@sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilira...@gmail.com>

Reply via email to