fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

Change subject: trxcon: implement Ready-to-Receive PHYIF API
......................................................................

trxcon: implement Ready-to-Receive PHYIF API

This API is going to be used by osmo-trx-ms for inquiring the l1sched
about an lchan state before attempting to demodulate a Downlink burst.

Change-Id: I9a71b8a59733f4dd908b760c5e23ea3d624afb1a
Related: OS#5599
---
M src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h
M src/host/trxcon/include/osmocom/bb/trxcon/phyif.h
M src/host/trxcon/src/sched_trx.c
M src/host/trxcon/src/trxcon_shim.c
4 files changed, 77 insertions(+), 0 deletions(-)

Approvals:
  fixeria: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Hoernchen: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h 
b/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h
index 5202e5e..4b743ca 100644
--- a/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h
+++ b/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h
@@ -162,6 +162,16 @@
        size_t burst_len;
 };

+/* Probed lchan is active */
+#define L1SCHED_PROBE_F_ACTIVE         (1 << 0)
+
+/* RTR (Ready-to-Receive) probe */
+struct l1sched_probe {
+       uint32_t flags; /* see L1SCHED_PROBE_F_* above */
+       uint32_t fn;
+       uint8_t tn;
+};
+
 typedef int l1sched_lchan_rx_func(struct l1sched_lchan_state *lchan,
                                  const struct l1sched_burst_ind *bi);

@@ -477,6 +487,8 @@

 int l1sched_handle_rx_burst(struct l1sched_state *sched,
                            struct l1sched_burst_ind *bi);
+int l1sched_handle_rx_probe(struct l1sched_state *sched,
+                           struct l1sched_probe *probe);

 /* Shared declarations for lchan handlers */
 extern const uint8_t l1sched_nb_training_bits[8][26];
diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h 
b/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h
index ac23ac6..abda393 100644
--- a/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h
+++ b/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h
@@ -75,6 +75,20 @@
        uint8_t tn;
 };

+/* RTR.ind - Ready-to-Receive indicaton */
+struct trxcon_phyif_rtr_ind {
+       uint32_t fn;
+       uint8_t tn;
+};
+
+/* The probed lchan is active */
+#define TRXCON_PHYIF_RTR_F_ACTIVE      (1 << 0)
+
+/* RTR.rsp - Ready-to-Receive response */
+struct trxcon_phyif_rtr_rsp {
+       uint32_t flags; /* see TRXCON_PHYIF_RTR_F_* above */
+};
+
 /* BURST.req - a burst to be transmitted */
 struct trxcon_phyif_burst_req {
        uint32_t fn;
@@ -99,6 +113,8 @@
 int trxcon_phyif_handle_clock_ind(void *priv, uint32_t fn);

 int trxcon_phyif_handle_rts_ind(void *priv, const struct trxcon_phyif_rts_ind 
*rts);
+int trxcon_phyif_handle_rtr_ind(void *priv, const struct trxcon_phyif_rtr_ind 
*ind,
+                               struct trxcon_phyif_rtr_rsp *rsp);

 int trxcon_phyif_handle_cmd(void *phyif, const struct trxcon_phyif_cmd *cmd);
 int trxcon_phyif_handle_rsp(void *priv, const struct trxcon_phyif_rsp *rsp);
diff --git a/src/host/trxcon/src/sched_trx.c b/src/host/trxcon/src/sched_trx.c
index b7d7854..4cedd8a 100644
--- a/src/host/trxcon/src/sched_trx.c
+++ b/src/host/trxcon/src/sched_trx.c
@@ -804,6 +804,36 @@
        return 0;
 }

+int l1sched_handle_rx_probe(struct l1sched_state *sched,
+                           struct l1sched_probe *probe)
+{
+       struct l1sched_ts *ts = sched->ts[probe->tn];
+       const struct l1sched_tdma_frame *frame;
+       struct l1sched_lchan_state *lchan;
+       unsigned int offset;
+
+       /* Check whether required timeslot is allocated and configured */
+       if (ts == NULL || ts->mf_layout == NULL)
+               return -EINVAL;
+
+       /* Get frame from multiframe */
+       offset = probe->fn % ts->mf_layout->period;
+       frame = &ts->mf_layout->frames[offset];
+
+       if (l1sched_lchan_desc[frame->dl_chan].rx_fn == NULL)
+               return -ENODEV;
+
+       /* Find the appropriate logical channel */
+       lchan = l1sched_find_lchan(ts, frame->dl_chan);
+       if (lchan == NULL)
+               return -ENODEV;
+
+       if (lchan->active)
+               probe->flags |= L1SCHED_PROBE_F_ACTIVE;
+
+       return 0;
+}
+
 #define MEAS_HIST_FIRST(hist) \
        (&hist->buf[0])
 #define MEAS_HIST_LAST(hist) \
diff --git a/src/host/trxcon/src/trxcon_shim.c 
b/src/host/trxcon/src/trxcon_shim.c
index 9da3cb7..f8b1872 100644
--- a/src/host/trxcon/src/trxcon_shim.c
+++ b/src/host/trxcon/src/trxcon_shim.c
@@ -233,6 +233,25 @@
        return l1sched_handle_burst_req(trxcon->sched, &br);
 }

+int trxcon_phyif_handle_rtr_ind(void *priv, const struct trxcon_phyif_rtr_ind 
*ind,
+                               struct trxcon_phyif_rtr_rsp *rsp)
+{
+       struct trxcon_inst *trxcon = priv;
+       struct l1sched_probe probe = {
+               .fn = ind->fn,
+               .tn = ind->tn,
+       };
+
+       l1sched_handle_rx_probe(trxcon->sched, &probe);
+
+       memset(rsp, 0x00, sizeof(*rsp));
+
+       if (probe.flags & L1SCHED_PROBE_F_ACTIVE)
+               rsp->flags |= TRXCON_PHYIF_RTR_F_ACTIVE;
+
+       return 0;
+}
+
 int trxcon_phyif_handle_burst_ind(void *priv, const struct 
trxcon_phyif_burst_ind *phybi)
 {
        struct trxcon_inst *trxcon = priv;

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

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I9a71b8a59733f4dd908b760c5e23ea3d624afb1a
Gerrit-Change-Number: 30262
Gerrit-PatchSet: 4
Gerrit-Owner: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: Hoernchen <ew...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-CC: msuraev <msur...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to