[M] Change in libosmo-gprs[master]: rlcmac: migrate from fn_cmp() to gsm0502_fncmp()

2023-10-04 Thread pespin
pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-gprs/+/34627?usp=email )

Change subject: rlcmac: migrate from fn_cmp() to gsm0502_fncmp()
..

rlcmac: migrate from fn_cmp() to gsm0502_fncmp()

Change-Id: I3030d00c6881713a088b1739b2b5ba77bac84e46
Depends: libosmocore.git I9590f2e836fc48650decf1564b6ab46306c4fe2d
Depends: libosmocore.git Ie8bb9c49c6f81b8f4a1766547d6943f9880d1186
---
M include/osmocom/gprs/rlcmac/sched.h
M src/rlcmac/pdch_ul_controller.c
M src/rlcmac/tbf_dl_ass_fsm.c
M src/rlcmac/tbf_ul_ass_fsm.c
4 files changed, 27 insertions(+), 28 deletions(-)

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




diff --git a/include/osmocom/gprs/rlcmac/sched.h 
b/include/osmocom/gprs/rlcmac/sched.h
index a90cbc1..9e03c01 100644
--- a/include/osmocom/gprs/rlcmac/sched.h
+++ b/include/osmocom/gprs/rlcmac/sched.h
@@ -20,20 +20,6 @@
return f == 0 || f == 4 || f == 8;
 }

-#define GSM_MAX_FN_THRESH (GSM_MAX_FN >> 1)
-/* 0: equal, -1: fn1 BEFORE fn2, 1: fn1 AFTER fn2 */
-static inline int fn_cmp(uint32_t fn1, uint32_t fn2)
-{
-   if (fn1 == fn2)
-   return 0;
-   /* FN1 goes before FN2: */
-   if ((fn1 < fn2 && (fn2 - fn1) < GSM_MAX_FN_THRESH) ||
-   (fn1 > fn2 && (fn1 - fn2) > GSM_MAX_FN_THRESH))
-   return -1;
-   /* FN1 goes after FN2: */
-   return 1;
-}
-
 static inline uint32_t fn2bn(uint32_t fn)
 {
return (fn % 52) / 4;
diff --git a/src/rlcmac/pdch_ul_controller.c b/src/rlcmac/pdch_ul_controller.c
index 7c5e41a..b6859b1 100644
--- a/src/rlcmac/pdch_ul_controller.c
+++ b/src/rlcmac/pdch_ul_controller.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -61,7 +62,7 @@

while (node) {
it = rb_entry(node, struct gprs_rlcmac_pdch_ulc_node, node);
-   res = fn_cmp(it->fn, fn);
+   res = gsm0502_fncmp(it->fn, fn);
if (res > 0) /* it->fn AFTER fn */
node = node->rb_left;
else if (res < 0) /* it->fn BEFORE fn */
@@ -105,7 +106,7 @@
it = container_of(*n, struct gprs_rlcmac_pdch_ulc_node, node);

parent = *n;
-   res = fn_cmp(item->fn, it->fn);
+   res = gsm0502_fncmp(item->fn, it->fn);
if (res < 0) { /* item->fn "BEFORE" it->fn */
n = &((*n)->rb_left);
} else if (res > 0) { /* item->fn "AFTER" it->fn */
@@ -180,7 +181,7 @@
struct rb_node *first;
while ((first = rb_first(>tree_root))) {
item = container_of(first, struct gprs_rlcmac_pdch_ulc_node, 
node);
-   res = fn_cmp(item->fn, fn);
+   res = gsm0502_fncmp(item->fn, fn);
if (res > 0) /* item->fn AFTER fn */
break;
if (res < 0) { /* item->fn BEFORE fn */
diff --git a/src/rlcmac/tbf_dl_ass_fsm.c b/src/rlcmac/tbf_dl_ass_fsm.c
index 9acf723..fec375f 100644
--- a/src/rlcmac/tbf_dl_ass_fsm.c
+++ b/src/rlcmac/tbf_dl_ass_fsm.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -141,7 +142,7 @@
return;
memcpy(>iaro, ev_ccch_imm_ass->iaro, sizeof(ctx->iaro));
if (ctx->tbf_starting_time_exists &&
-   fn_cmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) > 0)
+   gsm0502_fncmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) 
> 0)
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
else
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
@@ -152,7 +153,7 @@
return;
memcpy(>dl_block, ev_pacch_pkt_ass->dl_block, 
sizeof(ctx->dl_block));
if (ctx->tbf_starting_time_exists &&
-   fn_cmp(ctx->tbf_starting_time, ev_pacch_pkt_ass->fn) > 0)
+   gsm0502_fncmp(ctx->tbf_starting_time, ev_pacch_pkt_ass->fn) 
> 0)
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
else
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
@@ -175,7 +176,7 @@
return;
memcpy(>iaro, ev_ccch_imm_ass->iaro, sizeof(ctx->iaro));
if (ctx->tbf_starting_time_exists &&
-   fn_cmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) > 0)
+   gsm0502_fncmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) 
> 0)
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
else
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
@@ -186,7 

[M] Change in libosmo-gprs[master]: rlcmac: migrate from fn_cmp() to gsm0502_fncmp()

2023-10-04 Thread pespin
Attention is currently required from: fixeria.

pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmo-gprs/+/34627?usp=email )

Change subject: rlcmac: migrate from fn_cmp() to gsm0502_fncmp()
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/34627?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I3030d00c6881713a088b1739b2b5ba77bac84e46
Gerrit-Change-Number: 34627
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-Attention: fixeria 
Gerrit-Comment-Date: Wed, 04 Oct 2023 11:40:54 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in libosmo-gprs[master]: rlcmac: migrate from fn_cmp() to gsm0502_fncmp()

2023-10-04 Thread osmith
Attention is currently required from: fixeria.

osmith has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmo-gprs/+/34627?usp=email )

Change subject: rlcmac: migrate from fn_cmp() to gsm0502_fncmp()
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/34627?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I3030d00c6881713a088b1739b2b5ba77bac84e46
Gerrit-Change-Number: 34627
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith 
Gerrit-Attention: fixeria 
Gerrit-Comment-Date: Wed, 04 Oct 2023 08:18:12 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in libosmo-gprs[master]: rlcmac: migrate from fn_cmp() to gsm0502_fncmp()

2023-10-03 Thread fixeria
fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-gprs/+/34627?usp=email )


Change subject: rlcmac: migrate from fn_cmp() to gsm0502_fncmp()
..

rlcmac: migrate from fn_cmp() to gsm0502_fncmp()

Change-Id: I3030d00c6881713a088b1739b2b5ba77bac84e46
Depends: libosmocore.git I9590f2e836fc48650decf1564b6ab46306c4fe2d
Depends: libosmocore.git Ie8bb9c49c6f81b8f4a1766547d6943f9880d1186
---
M include/osmocom/gprs/rlcmac/sched.h
M src/rlcmac/pdch_ul_controller.c
M src/rlcmac/tbf_dl_ass_fsm.c
M src/rlcmac/tbf_ul_ass_fsm.c
4 files changed, 27 insertions(+), 28 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/27/34627/1

diff --git a/include/osmocom/gprs/rlcmac/sched.h 
b/include/osmocom/gprs/rlcmac/sched.h
index a90cbc1..9e03c01 100644
--- a/include/osmocom/gprs/rlcmac/sched.h
+++ b/include/osmocom/gprs/rlcmac/sched.h
@@ -20,20 +20,6 @@
return f == 0 || f == 4 || f == 8;
 }

-#define GSM_MAX_FN_THRESH (GSM_MAX_FN >> 1)
-/* 0: equal, -1: fn1 BEFORE fn2, 1: fn1 AFTER fn2 */
-static inline int fn_cmp(uint32_t fn1, uint32_t fn2)
-{
-   if (fn1 == fn2)
-   return 0;
-   /* FN1 goes before FN2: */
-   if ((fn1 < fn2 && (fn2 - fn1) < GSM_MAX_FN_THRESH) ||
-   (fn1 > fn2 && (fn1 - fn2) > GSM_MAX_FN_THRESH))
-   return -1;
-   /* FN1 goes after FN2: */
-   return 1;
-}
-
 static inline uint32_t fn2bn(uint32_t fn)
 {
return (fn % 52) / 4;
diff --git a/src/rlcmac/pdch_ul_controller.c b/src/rlcmac/pdch_ul_controller.c
index 7c5e41a..b6859b1 100644
--- a/src/rlcmac/pdch_ul_controller.c
+++ b/src/rlcmac/pdch_ul_controller.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -61,7 +62,7 @@

while (node) {
it = rb_entry(node, struct gprs_rlcmac_pdch_ulc_node, node);
-   res = fn_cmp(it->fn, fn);
+   res = gsm0502_fncmp(it->fn, fn);
if (res > 0) /* it->fn AFTER fn */
node = node->rb_left;
else if (res < 0) /* it->fn BEFORE fn */
@@ -105,7 +106,7 @@
it = container_of(*n, struct gprs_rlcmac_pdch_ulc_node, node);

parent = *n;
-   res = fn_cmp(item->fn, it->fn);
+   res = gsm0502_fncmp(item->fn, it->fn);
if (res < 0) { /* item->fn "BEFORE" it->fn */
n = &((*n)->rb_left);
} else if (res > 0) { /* item->fn "AFTER" it->fn */
@@ -180,7 +181,7 @@
struct rb_node *first;
while ((first = rb_first(>tree_root))) {
item = container_of(first, struct gprs_rlcmac_pdch_ulc_node, 
node);
-   res = fn_cmp(item->fn, fn);
+   res = gsm0502_fncmp(item->fn, fn);
if (res > 0) /* item->fn AFTER fn */
break;
if (res < 0) { /* item->fn BEFORE fn */
diff --git a/src/rlcmac/tbf_dl_ass_fsm.c b/src/rlcmac/tbf_dl_ass_fsm.c
index 9acf723..fec375f 100644
--- a/src/rlcmac/tbf_dl_ass_fsm.c
+++ b/src/rlcmac/tbf_dl_ass_fsm.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -141,7 +142,7 @@
return;
memcpy(>iaro, ev_ccch_imm_ass->iaro, sizeof(ctx->iaro));
if (ctx->tbf_starting_time_exists &&
-   fn_cmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) > 0)
+   gsm0502_fncmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) 
> 0)
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
else
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
@@ -152,7 +153,7 @@
return;
memcpy(>dl_block, ev_pacch_pkt_ass->dl_block, 
sizeof(ctx->dl_block));
if (ctx->tbf_starting_time_exists &&
-   fn_cmp(ctx->tbf_starting_time, ev_pacch_pkt_ass->fn) > 0)
+   gsm0502_fncmp(ctx->tbf_starting_time, ev_pacch_pkt_ass->fn) 
> 0)
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
else
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
@@ -175,7 +176,7 @@
return;
memcpy(>iaro, ev_ccch_imm_ass->iaro, sizeof(ctx->iaro));
if (ctx->tbf_starting_time_exists &&
-   fn_cmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) > 0)
+   gsm0502_fncmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) 
> 0)
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
else
tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
@@ -186,7 +187,7 @@
return;