<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bts/+/14611">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">osmo-bts-trx/trx_if.c: request the newest TRXD header version<br><br>This change introduces the new command for TRXD header version<br>negotiation - SETFORMAT. Old transceivers would reject it as<br>an unknown command. FakeTRX confirms all unknown commands with<br>status 0. The modern transceivers should respond with status<br>code equal to or less than the requested header version.<br><br>Change-Id: I8afe950bd1ec2afaf3347ff848ee46e69c4f5011<br>---<br>M src/osmo-bts-trx/l1_if.c<br>M src/osmo-bts-trx/l1_if.h<br>M src/osmo-bts-trx/trx_if.c<br>M src/osmo-bts-trx/trx_if.h<br>4 files changed, 44 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/11/14611/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c</span><br><span>index e6e384a..816d745 100644</span><br><span>--- a/src/osmo-bts-trx/l1_if.c</span><br><span>+++ b/src/osmo-bts-trx/l1_if.c</span><br><span>@@ -208,6 +208,9 @@</span><br><span>                        l1h->config.bsic_sent = 1;</span><br><span>                }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+         /* Ask transceiver to use the newest TRXD header version */</span><br><span style="color: hsl(120, 100%, 40%);">+           trx_if_cmd_setformat(l1h, TRX_DATA_FORMAT_VER);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>            if (!l1h->config.poweron_sent) {</span><br><span>                  trx_if_cmd_poweron(l1h);</span><br><span>                     l1h->config.poweron_sent = 1;</span><br><span>diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h</span><br><span>index 9c95c53..90c2758 100644</span><br><span>--- a/src/osmo-bts-trx/l1_if.h</span><br><span>+++ b/src/osmo-bts-trx/l1_if.h</span><br><span>@@ -8,6 +8,7 @@</span><br><span> struct trx_config {</span><br><span>       uint8_t                 poweron;        /* poweron(1) or poweroff(0) */</span><br><span>      int                     poweron_sent;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t                 trxd_hdr_ver;</span><br><span> </span><br><span>    int                     arfcn_valid;</span><br><span>         uint16_t                arfcn;</span><br><span>diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c</span><br><span>index 3fc06b8..2bf2a8d 100644</span><br><span>--- a/src/osmo-bts-trx/trx_if.c</span><br><span>+++ b/src/osmo-bts-trx/trx_if.c</span><br><span>@@ -272,6 +272,14 @@</span><br><span>               return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Send "SETFORMAT" command to TRX: change TRXD header format version */</span><br><span style="color: hsl(120, 100%, 40%);">+int trx_if_cmd_setformat(struct trx_l1h *l1h, uint8_t ver)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        LOGPPHI(l1h->phy_inst, DTRX, LOGL_INFO,</span><br><span style="color: hsl(120, 100%, 40%);">+            "Requesting TRXD header format version %u\n", ver);</span><br><span style="color: hsl(120, 100%, 40%);">+ return trx_ctrl_cmd(l1h, 0, "SETFORMAT", "%u", ver);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! Send "SETTSC" command to TRX */</span><br><span> int trx_if_cmd_settsc(struct trx_l1h *l1h, uint8_t tsc)</span><br><span> {</span><br><span>@@ -463,6 +471,30 @@</span><br><span>        return rsp->status == 0 ? 0 : -EINVAL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Old transceivers would reject SETFORMAT as an unknown command. FakeTRX confirms</span><br><span style="color: hsl(120, 100%, 40%);">+ * all unknown commands with status 0. The modern transceivers should respond</span><br><span style="color: hsl(120, 100%, 40%);">+ * with status code equal to or less than the requested version. */</span><br><span style="color: hsl(120, 100%, 40%);">+static int trx_ctrl_rx_rsp_setformat(struct trx_l1h *l1h, struct trx_ctrl_rsp *rsp)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rsp->status < 0 || rsp->status > TRX_DATA_FORMAT_VER) {</span><br><span style="color: hsl(120, 100%, 40%);">+               LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+                   "TRX indicated an unsupported header "</span><br><span style="color: hsl(120, 100%, 40%);">+                      "format version %d\n", rsp->status);</span><br><span style="color: hsl(120, 100%, 40%);">+             return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+       } else if (rsp->status == -1 || rsp->status == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+             l1h->config.trxd_hdr_ver = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+              LOGPPHI(l1h->phy_inst, DTRX, LOGL_NOTICE,</span><br><span style="color: hsl(120, 100%, 40%);">+                  "Using legacy TRXD header format version\n");</span><br><span style="color: hsl(120, 100%, 40%);">+       } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              l1h->config.trxd_hdr_ver = rsp->status;</span><br><span style="color: hsl(120, 100%, 40%);">+         LOGPPHI(l1h->phy_inst, DTRX, LOGL_INFO,</span><br><span style="color: hsl(120, 100%, 40%);">+                    "Using TRXD header format version %u\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                    l1h->config.trxd_hdr_ver);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* -EINVAL: unrecoverable error, exit BTS</span><br><span>  * N > 0: try sending originating command again after N seconds</span><br><span>  * 0: Done with response, get originating command out from send queue</span><br><span>@@ -487,6 +519,8 @@</span><br><span>             }</span><br><span>    } else if (strcmp(rsp->cmd, "SETSLOT") == 0) {</span><br><span>          return trx_ctrl_rx_rsp_setslot(l1h, rsp);</span><br><span style="color: hsl(120, 100%, 40%);">+     } else if (strcmp(rsp->cmd, "SETFORMAT") == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+         return trx_ctrl_rx_rsp_setformat(l1h, rsp);</span><br><span>  }</span><br><span> </span><br><span>        if (rsp->status) {</span><br><span>diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h</span><br><span>index cdfbd41..a76065c 100644</span><br><span>--- a/src/osmo-bts-trx/trx_if.h</span><br><span>+++ b/src/osmo-bts-trx/trx_if.h</span><br><span>@@ -35,4 +35,10 @@</span><br><span>  const ubit_t *bits, uint16_t nbits);</span><br><span> int trx_if_powered(struct trx_l1h *l1h);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* The latest supported TRXD header format version */</span><br><span style="color: hsl(120, 100%, 40%);">+#define TRX_DATA_FORMAT_VER    0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Format negotiation command */</span><br><span style="color: hsl(120, 100%, 40%);">+int trx_if_cmd_setformat(struct trx_l1h *l1h, uint8_t ver);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #endif /* TRX_IF_H */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bts/+/14611">change 14611</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-bts/+/14611"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bts </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I8afe950bd1ec2afaf3347ff848ee46e69c4f5011 </div>
<div style="display:none"> Gerrit-Change-Number: 14611 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>