pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/18589 )

Change subject: bts-trx: Use TRXC cmd NOMTXPOWER to retrieve nominal tx power 
from osmo-trx
......................................................................

bts-trx: Use TRXC cmd NOMTXPOWER to retrieve nominal tx power from osmo-trx

Change-Id: I682211f3d664c21f923ca4a530e0464ca383b6d9
---
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-trx/main.c
M src/osmo-bts-trx/trx_if.c
M src/osmo-bts-trx/trx_if.h
4 files changed, 49 insertions(+), 4 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 97f87a1..0858de2 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -145,6 +145,16 @@
        trx->power_params.trx_p_max_out_mdBm = to_mdB(nominal_power);
 }

+static void l1if_getnompower_cb(struct trx_l1h *l1h, unsigned int 
nominal_power, int rc)
+{
+       struct phy_instance *pinst = l1h->phy_inst;
+       struct gsm_bts_trx *trx = pinst->trx;
+
+       LOGPPHI(pinst, DL1C, LOGL_DEBUG, "l1if_getnompower_cb(nominal_power=%u, 
rc=%d)\n", nominal_power, rc);
+
+       l1if_trx_set_nominal_power(trx, nominal_power);
+}
+
 static void l1if_setslot_cb(struct trx_l1h *l1h, uint8_t tn, uint8_t type, int 
rc)
 {
        struct phy_instance *pinst = l1h->phy_inst;
@@ -240,6 +250,13 @@
                if (!l1h->config.arfcn_sent) {
                        trx_if_cmd_rxtune(l1h, l1h->config.arfcn);
                        trx_if_cmd_txtune(l1h, l1h->config.arfcn);
+                       /* After TXTUNE is sent to TRX, get the tx nominal power
+                        * (which may vary precisly on band/arfcn. Avoid sending
+                        * it if we are forced by VTY to use a specific nominal
+                        * power (because TRX may not support the command or
+                        * provide broken values) */
+                       if (!l1h->config.nominal_power_set_by_vty)
+                               trx_if_cmd_getnompower(l1h, 
l1if_getnompower_cb);
                        l1h->config.arfcn_sent = 1;
                }
                if (!l1h->config.tsc_sent) {
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index fbe4c2f..0d2a1f7 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -104,10 +104,9 @@
        bts->variant = BTS_OSMO_TRX;
        bts->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3);

-       /* The nominal value is later  overwritten through VTY cmd
-        * 'nominal-tx-power' if present.
-        * FIXME: In the future, we want osmo-trx to provide us with this info
-        * through TRXC. */
+       /* The nominal value for each TRX is later overwritten through VTY cmd
+        * 'nominal-tx-power' if present, otherwise through TRXC cmd NOMTXPOWER.
+        */
        bts->c0->nominal_power = 23;

        osmo_bts_set_feature(bts->features, BTS_FEAT_GPRS);
@@ -129,6 +128,9 @@

 int bts_model_trx_init(struct gsm_bts_trx *trx)
 {
+       /* The nominal value for each TRX is later overwritten through VTY cmd
+        * 'nominal-tx-power' if present, otherwise through TRXC cmd NOMTXPOWER.
+        */
        l1if_trx_set_nominal_power(trx, trx->bts->c0->nominal_power);
        return 0;
 }
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index f2e2915..61f57b9 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -302,6 +302,12 @@
        return trx_ctrl_cmd(l1h, 0, "SETRXGAIN", "%d", db);
 }

+/*! Send "NOMTXPOWER" command to TRX */
+int trx_if_cmd_getnompower(struct trx_l1h *l1h, trx_if_cmd_getnompower_cb *cb)
+{
+       return trx_ctrl_cmd_cb(l1h, 1, cb, "NOMTXPOWER", "");
+}
+
 /*! Send "SETPOWER" command to TRX */
 int trx_if_cmd_setpower_att(struct trx_l1h *l1h, int power_att_db, 
trx_if_cmd_setpower_att_cb *cb)
 {
@@ -544,6 +550,22 @@
        return 0;
 }

+static int trx_ctrl_rx_rsp_nomtxpower(struct trx_l1h *l1h, struct trx_ctrl_rsp 
*rsp)
+{
+       trx_if_cmd_getnompower_cb *cb = (trx_if_cmd_getnompower_cb*) rsp->cb;
+       struct phy_instance *pinst = l1h->phy_inst;
+       unsigned int nominal_power;
+
+       if (rsp->status)
+               LOGPPHI(pinst, DTRX, LOGL_ERROR, "transceiver NOMTXPOWER failed 
with status %d\n",
+                       rsp->status);
+       if (cb) {
+               sscanf(rsp->params, "%u", &nominal_power);
+               cb(l1h, nominal_power, rsp->status);
+       }
+       return 0;
+}
+
 static int trx_ctrl_rx_rsp_setpower(struct trx_l1h *l1h, struct trx_ctrl_rsp 
*rsp)
 {
        trx_if_cmd_setpower_att_cb *cb = (trx_if_cmd_setpower_att_cb*) rsp->cb;
@@ -578,6 +600,8 @@
         * so that's why we should use tcm instead of rsp. */
        } else if (strcmp(tcm->cmd, "SETFORMAT") == 0) {
                return trx_ctrl_rx_rsp_setformat(l1h, rsp);
+       } else if (strcmp(tcm->cmd, "NOMTXPOWER") == 0) {
+               return trx_ctrl_rx_rsp_nomtxpower(l1h, rsp);
        } else if (strcmp(tcm->cmd, "SETPOWER") == 0) {
                return trx_ctrl_rx_rsp_setpower(l1h, rsp);
        }
diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h
index 300be92..34335f8 100644
--- a/src/osmo-bts-trx/trx_if.h
+++ b/src/osmo-bts-trx/trx_if.h
@@ -15,6 +15,7 @@

 typedef void trx_if_cmd_poweronoff_cb(struct trx_l1h *l1h, bool poweronoff, 
int rc);
 typedef void trx_if_cmd_setslot_cb(struct trx_l1h *l1h, uint8_t tn, uint8_t 
type, int rc);
+typedef void trx_if_cmd_getnompower_cb(struct trx_l1h *l1h, unsigned int 
nominal_power, int rc);
 typedef void trx_if_cmd_setpower_att_cb(struct trx_l1h *l1h, int power_att_db, 
int rc);

 void trx_if_init(struct trx_l1h *l1h);
@@ -23,6 +24,7 @@
 int trx_if_cmd_settsc(struct trx_l1h *l1h, uint8_t tsc);
 int trx_if_cmd_setbsic(struct trx_l1h *l1h, uint8_t bsic);
 int trx_if_cmd_setrxgain(struct trx_l1h *l1h, int db);
+int trx_if_cmd_getnompower(struct trx_l1h *l1h, trx_if_cmd_getnompower_cb *cb);
 int trx_if_cmd_setpower_att(struct trx_l1h *l1h, int power_att_db, 
trx_if_cmd_setpower_att_cb *cb);
 int trx_if_cmd_setmaxdly(struct trx_l1h *l1h, int dly);
 int trx_if_cmd_setmaxdlynb(struct trx_l1h *l1h, int dly);

--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/18589
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I682211f3d664c21f923ca4a530e0464ca383b6d9
Gerrit-Change-Number: 18589
Gerrit-PatchSet: 6
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-CC: Hoernchen <ew...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to