pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/14896


Change subject: bts-trx: Introduce VTY command osmotrx trxd-max-version
......................................................................

bts-trx: Introduce VTY command osmotrx trxd-max-version

This command allows setting a maximum TRXD format version to negotiate
with TRX. osmo-bts-trx will hence end up using that version if supported
by TRX, or a lower one otherwise (or fail if TRX doesn't support any of
them).
Since now the maximum version can be 0, avoid going through SETFORMAT
negotiation in that case, since 0 is the default version. This way we
keep backward compatibility with TRX implementations that exit upon
receival of unknown commands (such as SC5 current one).

Related: OS#4006
Change-Id: I5eb1fdc002f9d7f4acf475356d8fc998dc8f6326
---
M include/osmo-bts/phy_link.h
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-trx/main.c
M src/osmo-bts-trx/trx_vty.c
4 files changed, 32 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/96/14896/1

diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index 273103c..3bf5159 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -50,6 +50,7 @@
                        uint32_t clock_advance;
                        uint32_t rts_advance;
                        bool use_legacy_setbsic;
+                       uint8_t  trxd_hdr_ver_max; /* Maximum TRXD header 
version to negotiate */
                } osmotrx;
                struct {
                        char *mcast_dev;                /* Network device for 
multicast */
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 9c1dc18..22ef2d7 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -185,6 +185,7 @@
 int l1if_provision_transceiver_trx(struct trx_l1h *l1h)
 {
        uint8_t tn;
+       struct phy_link *plink = l1h->phy_inst->phy_link;

        if (!transceiver_available)
                return -EIO;
@@ -208,10 +209,11 @@
                        l1h->config.bsic_sent = 1;
                }

-               /* Ask transceiver to use the newest TRXD header version */
-               if (!l1h->config.setformat_sent) {
-                       trx_if_cmd_setformat(l1h, TRX_DATA_FORMAT_VER);
-                       l1h->config.trxd_hdr_ver_req = TRX_DATA_FORMAT_VER;
+               /* Ask transceiver to use the newest TRXD header version if not 
using it yet */
+               if (!l1h->config.setformat_sent &&
+                   l1h->config.trxd_hdr_ver_use != 
plink->u.osmotrx.trxd_hdr_ver_max) {
+                       trx_if_cmd_setformat(l1h, 
plink->u.osmotrx.trxd_hdr_ver_max);
+                       l1h->config.trxd_hdr_ver_req = 
plink->u.osmotrx.trxd_hdr_ver_max;
                        l1h->config.setformat_sent = 1;
                }

diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 9529190..b1fa207 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -134,6 +134,8 @@
        plink->u.osmotrx.trx_ta_loop = true;
        plink->u.osmotrx.trx_ms_power_loop = false;
        plink->u.osmotrx.trx_target_rssi = -10;
+       /* attempt use newest TRXD version by default: */
+       plink->u.osmotrx.trxd_hdr_ver_max = TRX_DATA_FORMAT_VER;
 }

 void bts_model_phy_instance_set_defaults(struct phy_instance *pinst)
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index b9af445..21b21bd 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -496,6 +496,25 @@
        return CMD_SUCCESS;
 }

+DEFUN(cfg_phy_trxd_max_version, cfg_phy_trxd_max_version_cmd,
+       "osmotrx trxd-max-version <-1-15>", OSMOTRX_STR
+       "Set maximum TRXD format version to negotiate with TRX\n"
+       "The maximum TRXD format version to negotiate with TRX (-1 for highest 
supported, default)\n")
+{
+       struct phy_link *plink = vty->index;
+
+       int max_ver = atoi(argv[0]);
+       if (max_ver == -1)
+               max_ver = TRX_DATA_FORMAT_VER;
+       if (max_ver > TRX_DATA_FORMAT_VER) {
+               vty_out(vty, "%% Format version %d is not supported by 
osmo-bts-trx%s", max_ver, VTY_NEWLINE);
+               return CMD_WARNING;
+       }
+       plink->u.osmotrx.trxd_hdr_ver_max = max_ver;
+
+       return CMD_SUCCESS;
+}
+
 void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink)
 {
        if (plink->u.osmotrx.local_ip)
@@ -525,6 +544,9 @@

        if (plink->u.osmotrx.use_legacy_setbsic)
                vty_out(vty, " osmotrx legacy-setbsic%s", VTY_NEWLINE);
+
+       if (plink->u.osmotrx.trxd_hdr_ver_max != TRX_DATA_FORMAT_VER)
+               vty_out(vty, " osmotrx trxd-max-version %d%s", 
plink->u.osmotrx.trxd_hdr_ver_max, VTY_NEWLINE);
 }

 void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance 
*pinst)
@@ -584,6 +606,7 @@
        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_NODE, &cfg_phy_trxd_max_version_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/c/osmo-bts/+/14896
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I5eb1fdc002f9d7f4acf475356d8fc998dc8f6326
Gerrit-Change-Number: 14896
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to