From a4aac5c3554559c2c994609f90b92a9daf6e8a89 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Tue, 22 Nov 2022 05:36:50 +0700 Subject: [PATCH] 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 --- .../include/osmocom/bb/l1sched/l1sched.h | 12 ++++++++ .../trxcon/include/osmocom/bb/trxcon/phyif.h | 16 ++++++++++ src/host/trxcon/src/sched_trx.c | 30 +++++++++++++++++++ src/host/trxcon/src/trxcon_shim.c | 19 ++++++++++++ 4 files changed, 77 insertions(+) diff --git a/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h b/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h index 5202e5e50..4b743cace 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 @@ struct l1sched_burst_ind { 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 @@ void l1sched_prim_flush_queue(struct llist_head *list); 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 ac23ac647..abda393ea 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 @@ struct trxcon_phyif_rts_ind { 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_burst_ind(void *priv, const struct trxcon_phyif_burst_in 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 b7d785498..4cedd8a5e 100644 --- a/src/host/trxcon/src/sched_trx.c +++ b/src/host/trxcon/src/sched_trx.c @@ -804,6 +804,36 @@ int l1sched_handle_rx_burst(struct l1sched_state *sched, 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 9da3cb76f..f8b1872e7 100644 --- a/src/host/trxcon/src/trxcon_shim.c +++ b/src/host/trxcon/src/trxcon_shim.c @@ -233,6 +233,25 @@ int trxcon_phyif_handle_rts_ind(void *priv, const struct trxcon_phyif_rts_ind *r 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;