Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-29 Thread fixeria
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 = >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) \
(>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, );
 }

+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 = {
+   

Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-29 Thread fixeria
Attention is currently required from: msuraev.
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 3: Code-Review+2


--
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: 3
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: pespin 
Gerrit-CC: msuraev 
Gerrit-Attention: msuraev 
Gerrit-Comment-Date: Tue, 29 Nov 2022 11:03:05 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-29 Thread pespin
Attention is currently required from: fixeria, msuraev.
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 3: Code-Review+1

(1 comment)

Patchset:

PS1:
> There is l1sched (for which I am adding struct l1sched_probe) and libtrxcon 
> (for which I am adding s […]
I wonder why you didn't use same naming struct l1sched_rtr{ind,resp}, for me 
the "probe" concept there looks quite confusing. But if you are fine with that 
feel free to merge.



--
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: 3
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin 
Gerrit-CC: msuraev 
Gerrit-Attention: fixeria 
Gerrit-Attention: msuraev 
Gerrit-Comment-Date: Tue, 29 Nov 2022 10:37:32 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: fixeria 
Comment-In-Reply-To: pespin 
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-29 Thread Hoernchen
Attention is currently required from: fixeria, pespin, msuraev.
Hoernchen has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 3: Code-Review+1


--
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: 3
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: msuraev 
Gerrit-CC: pespin 
Gerrit-Attention: fixeria 
Gerrit-Attention: pespin 
Gerrit-Attention: msuraev 
Gerrit-Comment-Date: Tue, 29 Nov 2022 09:07:01 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-28 Thread fixeria
Attention is currently required from: Hoernchen, pespin, msuraev.
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 3:

(1 comment)

Patchset:

PS1:
> What's this "probe" thing you are added? I first though it was an indication 
> but later I saw the ind […]
There is l1sched (for which I am adding struct l1sched_probe) and libtrxcon 
(for which I am adding struct trxcon_phyif_rtr_{ind,rsp}). l1sched is not using 
the libtrxcon's PHYIF API directly, it offers its own API. This is why I am 
adding two things here.



--
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: 3
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: Hoernchen 
Gerrit-CC: msuraev 
Gerrit-CC: pespin 
Gerrit-Attention: Hoernchen 
Gerrit-Attention: pespin 
Gerrit-Attention: msuraev 
Gerrit-Comment-Date: Mon, 28 Nov 2022 20:14:41 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin 
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-28 Thread fixeria
Attention is currently required from: Hoernchen, msuraev.
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 3:

(1 comment)

File src/host/trxcon/src/sched_trx.c:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/d9b10d2c_9e33780d
PS2, Line 832:  probe->flags |= L1SCHED_PROBE_F_ACTIVE;
> The unexpected part here is that is ors the flags. […]
Indeed, fixed in the new patchset.



--
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: 3
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: Hoernchen 
Gerrit-CC: msuraev 
Gerrit-CC: pespin 
Gerrit-Attention: Hoernchen 
Gerrit-Attention: msuraev 
Gerrit-Comment-Date: Mon, 28 Nov 2022 20:10:45 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hoernchen 
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-28 Thread fixeria
Attention is currently required from: fixeria, msuraev.
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmocom-bb/+/30262

to look at the new patch set (#3).

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(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/62/30262/3
--
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: 3
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: Hoernchen 
Gerrit-CC: msuraev 
Gerrit-CC: pespin 
Gerrit-Attention: fixeria 
Gerrit-Attention: msuraev 
Gerrit-MessageType: newpatchset


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-28 Thread Hoernchen
Attention is currently required from: fixeria, msuraev.
Hoernchen has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 2:

(1 comment)

File src/host/trxcon/src/sched_trx.c:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/f1cb3baa_aad3999c
PS2, Line 832:  probe->flags |= L1SCHED_PROBE_F_ACTIVE;
The unexpected part here is that is ors the flags.

I as the caller know this is the passed _output_ arg, so I expect the function 
to set it. Right now the caller needs to initialize the output arg so random 
crap does not get "or"ed, which is unexpected...



--
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: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: Hoernchen 
Gerrit-CC: msuraev 
Gerrit-CC: pespin 
Gerrit-Attention: fixeria 
Gerrit-Attention: msuraev 
Gerrit-Comment-Date: Mon, 28 Nov 2022 16:35:47 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-28 Thread pespin
Attention is currently required from: fixeria, msuraev.
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 2:

(2 comments)

Patchset:

PS2:
My initial comment afaiu has not been answered.


File src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/9a8134a2_dbf71914
PS2, Line 166: #define L1SCHED_PROBE_F_ACTIVE   (1 << 0)
> I see nothing odd here. This is the usual way of defining bit-flags. […]
ACK (1 << N) is totally fine to define flags.



--
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: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: msuraev 
Gerrit-CC: pespin 
Gerrit-Attention: fixeria 
Gerrit-Attention: msuraev 
Gerrit-Comment-Date: Mon, 28 Nov 2022 09:27:43 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria 
Comment-In-Reply-To: msuraev 
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-26 Thread fixeria
Attention is currently required from: msuraev.
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 2:

(3 comments)

File src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/d6baeffc_2e355422
PS2, Line 166: #define L1SCHED_PROBE_F_ACTIVE   (1 << 0)
> That looks odd. […]
I see nothing odd here. This is the usual way of defining bit-flags. If we ever 
need more flags, it would be more convenient to write (1 << N) rather than 1, 
2, 4, 8, etc.


File src/host/trxcon/include/osmocom/bb/trxcon/phyif.h:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/dae2a8d5_3e29bd94
PS2, Line 85: #define TRXCON_PHYIF_RTR_F_ACTIVE (1 << 0)
> Same here.
See my answer near the L1SCHED_PROBE_F_ACTIVE.


File src/host/trxcon/src/sched_trx.c:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/dbc50b46_4ed388ca
PS2, Line 829:  return -ENODEV;
> Would be better to use different error code to distinguish between different 
> errors.
This is not really necessary though. Most of the times we check if the value is 
0 and don't care why exactly some function failed. If I ever needed distinct 
self-explanatory error causes, I would rather go for my own enumerated type 
rather than using constants from errno.h.



--
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: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: msuraev 
Gerrit-CC: pespin 
Gerrit-Attention: msuraev 
Gerrit-Comment-Date: Sat, 26 Nov 2022 15:56:20 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: msuraev 
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-26 Thread msuraev
Attention is currently required from: fixeria.
msuraev has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 2:

(3 comments)

File src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/8a6ea44b_3b48fd5d
PS2, Line 166: #define L1SCHED_PROBE_F_ACTIVE   (1 << 0)
That looks odd. Why not simply put 1?


File src/host/trxcon/include/osmocom/bb/trxcon/phyif.h:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/63baaeb5_10315d17
PS2, Line 85: #define TRXCON_PHYIF_RTR_F_ACTIVE (1 << 0)
Same here.


File src/host/trxcon/src/sched_trx.c:

https://gerrit.osmocom.org/c/osmocom-bb/+/30262/comment/e81094e2_7a6861eb
PS2, Line 829:  return -ENODEV;
Would be better to use different error code to distinguish between different 
errors.



--
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: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: msuraev 
Gerrit-CC: pespin 
Gerrit-Attention: fixeria 
Gerrit-Comment-Date: Sat, 26 Nov 2022 13:51:17 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-22 Thread pespin
Attention is currently required from: fixeria.
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30262 )

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


Patch Set 1:

(1 comment)

Patchset:

PS1:
What's this "probe" thing you are added? I first though it was an indication 
but later I saw the indication is also added in another place?



--
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: 1
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin 
Gerrit-Attention: fixeria 
Gerrit-Comment-Date: Tue, 22 Nov 2022 10:45:23 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmocom-bb[master]: trxcon: implement Ready-to-Receive PHYIF API

2022-11-21 Thread fixeria
fixeria has uploaded this change for review. ( 
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, 75 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/62/30262/1

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 = >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) \
(>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..60fbf74 100644
--- a/src/host/trxcon/src/trxcon_shim.c
+++ b/src/host/trxcon/src/trxcon_shim.c
@@ -233,6 +233,23 @@
return l1sched_handle_burst_req(trxcon->sched, );
 }

+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,
+   };
+
+