[MERGED] osmocom-bb[fixeria/trx]: trxcon/scheduler: enforce lchan handlers to set message type

2018-03-11 Thread Vadim Yanitskiy
Vadim Yanitskiy has submitted this change and it was merged.

Change subject: trxcon/scheduler: enforce lchan handlers to set message type
..


trxcon/scheduler: enforce lchan handlers to set message type

Since this change, each lchan handler shall manually indicate
a type of both message indications and confirmations.

Change-Id: I02e0b87d61c127d2f6f5b9532909af78332bf707
---
M src/host/trxcon/sched_lchan_common.c
M src/host/trxcon/sched_lchan_tchf.c
M src/host/trxcon/sched_lchan_xcch.c
M src/host/trxcon/sched_trx.h
4 files changed, 18 insertions(+), 21 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/trxcon/sched_lchan_common.c 
b/src/host/trxcon/sched_lchan_common.c
index 1858619..47b0162 100644
--- a/src/host/trxcon/sched_lchan_common.c
+++ b/src/host/trxcon/sched_lchan_common.c
@@ -82,9 +82,9 @@
},
 };
 
-int sched_send_data_ind(struct trx_instance *trx, struct trx_ts *ts,
+int sched_send_dt_ind(struct trx_instance *trx, struct trx_ts *ts,
struct trx_lchan_state *lchan, uint8_t *l2, size_t l2_len,
-   bool dec_failed, int bit_error_count)
+   int bit_error_count, bool dec_failed, bool traffic)
 {
const struct trx_lchan_desc *lchan_desc;
struct l1ctl_info_dl dl_hdr;
@@ -107,14 +107,13 @@
dl_hdr.fire_crc = dec_failed ? 2 : 0;
 
/* Put a packet to higher layers */
-   l1ctl_tx_dt_ind(trx->l1l, &dl_hdr, l2, l2_len,
-   l2_len != GSM_MACBLOCK_LEN);
+   l1ctl_tx_dt_ind(trx->l1l, &dl_hdr, l2, l2_len, traffic);
 
return 0;
 }
 
-int sched_send_data_conf(struct trx_instance *trx, struct trx_ts *ts,
-   struct trx_lchan_state *lchan, uint32_t fn, size_t l2_len)
+int sched_send_dt_conf(struct trx_instance *trx, struct trx_ts *ts,
+   struct trx_lchan_state *lchan, uint32_t fn, bool traffic)
 {
const struct trx_lchan_desc *lchan_desc;
struct l1ctl_info_dl dl_hdr;
@@ -131,8 +130,7 @@
dl_hdr.band_arfcn = htons(trx->band_arfcn);
dl_hdr.frame_nr = htonl(fn);
 
-   l1ctl_tx_dt_conf(trx->l1l, &dl_hdr,
-   l2_len != GSM_MACBLOCK_LEN);
+   l1ctl_tx_dt_conf(trx->l1l, &dl_hdr, traffic);
 
return 0;
 }
diff --git a/src/host/trxcon/sched_lchan_tchf.c 
b/src/host/trxcon/sched_lchan_tchf.c
index b023126..25c9b10 100644
--- a/src/host/trxcon/sched_lchan_tchf.c
+++ b/src/host/trxcon/sched_lchan_tchf.c
@@ -147,8 +147,8 @@
l2_len = sched_bad_frame_ind(l2, rsl_cmode, tch_mode);
} else if (rc == GSM_MACBLOCK_LEN) {
/* FACCH received, forward it to the higher layers */
-   sched_send_data_ind(trx, ts, lchan,
-   l2, GSM_MACBLOCK_LEN, false, n_errors);
+   sched_send_dt_ind(trx, ts, lchan, l2, GSM_MACBLOCK_LEN,
+   n_errors, false, false);
 
/* Send BFI instead of stolen TCH frame */
l2_len = sched_bad_frame_ind(l2, rsl_cmode, tch_mode);
@@ -159,8 +159,8 @@
 
/* Send a traffic frame to the higher layers */
if (l2_len > 0)
-   sched_send_data_ind(trx, ts, lchan,
-   l2, l2_len, false, n_errors);
+   sched_send_dt_ind(trx, ts, lchan, l2, l2_len,
+   n_errors, rc < 4, true);
 
return 0;
 }
@@ -273,8 +273,7 @@
/* If we have sent the last (4/4) burst */
if (*mask == 0x0f) {
/* Confirm data / traffic sending */
-   sched_send_data_conf(trx, ts, lchan, fn,
-   lchan->prim->payload_len);
+   sched_send_dt_conf(trx, ts, lchan, fn, 
PRIM_IS_TCH(lchan->prim));
 
/* Forget processed primitive */
sched_prim_drop(lchan);
diff --git a/src/host/trxcon/sched_lchan_xcch.c 
b/src/host/trxcon/sched_lchan_xcch.c
index b2cbd22..f351674 100644
--- a/src/host/trxcon/sched_lchan_xcch.c
+++ b/src/host/trxcon/sched_lchan_xcch.c
@@ -109,8 +109,8 @@
}
 
/* Send a L2 frame to the higher layers */
-   sched_send_data_ind(trx, ts, lchan,
-   l2, GSM_MACBLOCK_LEN, rc != 0, n_errors);
+   sched_send_dt_ind(trx, ts, lchan, l2, GSM_MACBLOCK_LEN,
+   n_errors, rc != 0, false);
 
return 0;
 }
@@ -190,7 +190,7 @@
*mask = 0x00;
 
/* Confirm data sending */
-   sched_send_data_conf(trx, ts, lchan, fn, GSM_MACBLOCK_LEN);
+   sched_send_dt_conf(trx, ts, lchan, fn, false);
}
 
return 0;
diff --git a/src/host/trxcon/sched_trx.h b/src/host/trxcon/sched_trx.h
index d9e0c8e..80b8dd2 100644
--- a/src/host/trxcon/sched_trx.h
+++ b/src/host/trxcon/sched_trx.h
@@ -312,8 +312,8 @@
 extern const uint8_t sched_nb_training_bits[8][26];
 
 size_t sched_bad_frame_ind(uint8_t *l2, uint8_t rsl_cmode, uint8_t tch_mode);
-int sched_send_data_ind(struct trx_i

osmocom-bb[fixeria/trx]: trxcon/scheduler: enforce lchan handlers to set message type

2018-03-11 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/7214
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I02e0b87d61c127d2f6f5b9532909af78332bf707
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmocom-bb[fixeria/trx]: trxcon/scheduler: enforce lchan handlers to set message type

2018-03-11 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/7214

trxcon/scheduler: enforce lchan handlers to set message type

Since this change, each lchan handler shall manually indicate
a type of both message indications and confirmations.

Change-Id: I02e0b87d61c127d2f6f5b9532909af78332bf707
---
M src/host/trxcon/sched_lchan_common.c
M src/host/trxcon/sched_lchan_tchf.c
M src/host/trxcon/sched_lchan_xcch.c
M src/host/trxcon/sched_trx.h
4 files changed, 18 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/14/7214/1

diff --git a/src/host/trxcon/sched_lchan_common.c 
b/src/host/trxcon/sched_lchan_common.c
index 1858619..47b0162 100644
--- a/src/host/trxcon/sched_lchan_common.c
+++ b/src/host/trxcon/sched_lchan_common.c
@@ -82,9 +82,9 @@
},
 };
 
-int sched_send_data_ind(struct trx_instance *trx, struct trx_ts *ts,
+int sched_send_dt_ind(struct trx_instance *trx, struct trx_ts *ts,
struct trx_lchan_state *lchan, uint8_t *l2, size_t l2_len,
-   bool dec_failed, int bit_error_count)
+   int bit_error_count, bool dec_failed, bool traffic)
 {
const struct trx_lchan_desc *lchan_desc;
struct l1ctl_info_dl dl_hdr;
@@ -107,14 +107,13 @@
dl_hdr.fire_crc = dec_failed ? 2 : 0;
 
/* Put a packet to higher layers */
-   l1ctl_tx_dt_ind(trx->l1l, &dl_hdr, l2, l2_len,
-   l2_len != GSM_MACBLOCK_LEN);
+   l1ctl_tx_dt_ind(trx->l1l, &dl_hdr, l2, l2_len, traffic);
 
return 0;
 }
 
-int sched_send_data_conf(struct trx_instance *trx, struct trx_ts *ts,
-   struct trx_lchan_state *lchan, uint32_t fn, size_t l2_len)
+int sched_send_dt_conf(struct trx_instance *trx, struct trx_ts *ts,
+   struct trx_lchan_state *lchan, uint32_t fn, bool traffic)
 {
const struct trx_lchan_desc *lchan_desc;
struct l1ctl_info_dl dl_hdr;
@@ -131,8 +130,7 @@
dl_hdr.band_arfcn = htons(trx->band_arfcn);
dl_hdr.frame_nr = htonl(fn);
 
-   l1ctl_tx_dt_conf(trx->l1l, &dl_hdr,
-   l2_len != GSM_MACBLOCK_LEN);
+   l1ctl_tx_dt_conf(trx->l1l, &dl_hdr, traffic);
 
return 0;
 }
diff --git a/src/host/trxcon/sched_lchan_tchf.c 
b/src/host/trxcon/sched_lchan_tchf.c
index b023126..25c9b10 100644
--- a/src/host/trxcon/sched_lchan_tchf.c
+++ b/src/host/trxcon/sched_lchan_tchf.c
@@ -147,8 +147,8 @@
l2_len = sched_bad_frame_ind(l2, rsl_cmode, tch_mode);
} else if (rc == GSM_MACBLOCK_LEN) {
/* FACCH received, forward it to the higher layers */
-   sched_send_data_ind(trx, ts, lchan,
-   l2, GSM_MACBLOCK_LEN, false, n_errors);
+   sched_send_dt_ind(trx, ts, lchan, l2, GSM_MACBLOCK_LEN,
+   n_errors, false, false);
 
/* Send BFI instead of stolen TCH frame */
l2_len = sched_bad_frame_ind(l2, rsl_cmode, tch_mode);
@@ -159,8 +159,8 @@
 
/* Send a traffic frame to the higher layers */
if (l2_len > 0)
-   sched_send_data_ind(trx, ts, lchan,
-   l2, l2_len, false, n_errors);
+   sched_send_dt_ind(trx, ts, lchan, l2, l2_len,
+   n_errors, rc < 4, true);
 
return 0;
 }
@@ -273,8 +273,7 @@
/* If we have sent the last (4/4) burst */
if (*mask == 0x0f) {
/* Confirm data / traffic sending */
-   sched_send_data_conf(trx, ts, lchan, fn,
-   lchan->prim->payload_len);
+   sched_send_dt_conf(trx, ts, lchan, fn, 
PRIM_IS_TCH(lchan->prim));
 
/* Forget processed primitive */
sched_prim_drop(lchan);
diff --git a/src/host/trxcon/sched_lchan_xcch.c 
b/src/host/trxcon/sched_lchan_xcch.c
index b2cbd22..f351674 100644
--- a/src/host/trxcon/sched_lchan_xcch.c
+++ b/src/host/trxcon/sched_lchan_xcch.c
@@ -109,8 +109,8 @@
}
 
/* Send a L2 frame to the higher layers */
-   sched_send_data_ind(trx, ts, lchan,
-   l2, GSM_MACBLOCK_LEN, rc != 0, n_errors);
+   sched_send_dt_ind(trx, ts, lchan, l2, GSM_MACBLOCK_LEN,
+   n_errors, rc != 0, false);
 
return 0;
 }
@@ -190,7 +190,7 @@
*mask = 0x00;
 
/* Confirm data sending */
-   sched_send_data_conf(trx, ts, lchan, fn, GSM_MACBLOCK_LEN);
+   sched_send_dt_conf(trx, ts, lchan, fn, false);
}
 
return 0;
diff --git a/src/host/trxcon/sched_trx.h b/src/host/trxcon/sched_trx.h
index 856566c..e9c0e6d 100644
--- a/src/host/trxcon/sched_trx.h
+++ b/src/host/trxcon/sched_trx.h
@@ -296,8 +296,8 @@
 extern const uint8_t sched_nb_training_bits[8][26];
 
 size_t sched_bad_frame_ind(uint8_t *l2, uint8_t rsl_cmode, uint8_t tch_mode);
-int sched_send_data_ind(struct trx_instance *trx, struct trx_ts *ts,
+int sched_send_dt_ind(struct trx_instance *trx, struct trx_ts *ts,
struct trx_lchan_state *lchan, uint8_t *l2, size_t l2_len,
-