pespin submitted this change.

View Change


Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved fixeria: Looks good to me, but someone else must approve
rlcmac: Implement RLC_OCTET_COUNT in DL ACK/NACK

This helps debugging what's already in the MS tx queue when requesting a
new UL TBF.

Change-Id: Ie5f399fa0bffed8e39811075feba47a54054c8e5
---
M include/osmocom/gprs/rlcmac/gre.h
M src/rlcmac/gre.c
M src/rlcmac/rlcmac_enc.c
M tests/rlcmac/rlcmac_prim_test.ok
4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/include/osmocom/gprs/rlcmac/gre.h b/include/osmocom/gprs/rlcmac/gre.h
index be36e23..b9a917d 100644
--- a/include/osmocom/gprs/rlcmac/gre.h
+++ b/include/osmocom/gprs/rlcmac/gre.h
@@ -46,6 +46,7 @@
bool gprs_rlcmac_entity_in_packet_transfer_mode(const struct gprs_rlcmac_entity *gre);
bool gprs_rlcmac_entity_have_tx_data_queued(const struct gprs_rlcmac_entity *gre);
int gprs_rlcmac_entity_start_ul_tbf_pkt_acc_proc_if_needed(struct gprs_rlcmac_entity *gre);
+uint16_t gprs_rlcmac_entity_calculate_new_ul_tbf_rlc_octet_count(const struct gprs_rlcmac_entity *gre);

int gprs_rlcmac_entity_llc_enqueue(struct gprs_rlcmac_entity *gre,
const uint8_t *ll_pdu, unsigned int ll_pdu_len,
diff --git a/src/rlcmac/gre.c b/src/rlcmac/gre.c
index 9102124..aca17bf 100644
--- a/src/rlcmac/gre.c
+++ b/src/rlcmac/gre.c
@@ -259,6 +259,30 @@
return rc;
}

+/* Calculate TS 44.060 Table 12.7.2 RLC_OCTET_COUNT. 0 = unable to count. */
+uint16_t gprs_rlcmac_entity_calculate_new_ul_tbf_rlc_octet_count(const struct gprs_rlcmac_entity *gre)
+{
+ /* The RLC_OCTET_COUNT field indicates the number of RLC data octets,
+ * plus the number of RLC data block length octets, that the mobile
+ * station wishes to transfer. The value '0' indicates that the mobile
+ * station does not provide any information on the TBF size.
+ */
+ uint32_t rlc_oct_cnt = 0;
+ const struct gprs_rlcmac_llc_queue *q = gre->llc_queue;
+
+ for (unsigned int i = 0; i < ARRAY_SIZE(q->pq); i++) {
+ for (unsigned int j = 0; j < ARRAY_SIZE(q->pq[i]); j++) {
+ struct msgb *msg;
+ llist_for_each_entry(msg, &q->pq[i][j].queue, list) {
+ rlc_oct_cnt += 1 + msgb_l2len(msg);
+ if (rlc_oct_cnt >= UINT16_MAX)
+ return UINT16_MAX;
+ }
+ }
+ }
+ return rlc_oct_cnt;
+}
+
struct msgb *gprs_rlcmac_gre_create_pkt_ctrl_ack(const struct gprs_rlcmac_entity *gre)
{
struct msgb *msg;
diff --git a/src/rlcmac/rlcmac_enc.c b/src/rlcmac/rlcmac_enc.c
index dec2fa6..afe5bce 100644
--- a/src/rlcmac/rlcmac_enc.c
+++ b/src/rlcmac/rlcmac_enc.c
@@ -403,7 +403,7 @@
chan_req->RADIO_PRIORITY = gprs_rlcmac_llc_queue_highest_radio_prio_pending(dl_tbf->tbf.gre->llc_queue);
chan_req->RLC_MODE = GPRS_RLCMAC_RLC_MODE_ACKNOWLEDGED;
chan_req->LLC_PDU_TYPE = GPRS_RLCMAC_LLC_PDU_TYPE_ACKNOWLEDGED;
- chan_req->RLC_OCTET_COUNT = 0; /* TODO */
+ chan_req->RLC_OCTET_COUNT = gprs_rlcmac_entity_calculate_new_ul_tbf_rlc_octet_count(dl_tbf->tbf.gre);
} else {
ack->Exist_Channel_Request_Description = 0;
}
diff --git a/tests/rlcmac/rlcmac_prim_test.ok b/tests/rlcmac/rlcmac_prim_test.ok
index 70d0939..b9f18d2 100644
--- a/tests/rlcmac/rlcmac_prim_test.ok
+++ b/tests/rlcmac/rlcmac_prim_test.ok
@@ -217,7 +217,7 @@
test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_ESTABLISH.request
test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_DL_TBF.request dl_tbf_nr=0 dl_slotmask=0x80 dl_tfi=0
test_rlcmac_prim_up_cb(): Rx GRR-UNITDATA.indication TLLI=0x00000001 ll=[43 c0 01 2b 2b 2b ]
-test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=21 ts=7 data_len=23 data=[40 08 10 20 00 00 00 00 00 00 00 30 00 00 00 00 00 03 2b 2b 2b 2b 2b ]
+test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=21 ts=7 data_len=23 data=[40 08 10 20 00 00 00 00 00 00 00 30 00 00 f0 00 00 03 2b 2b 2b 2b 2b ]
test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0xc0
test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=43 ts=7 data_len=23 data=[40 04 00 00 00 04 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b ]
test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0xc0

To view, visit change 35786. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: Ie5f399fa0bffed8e39811075feba47a54054c8e5
Gerrit-Change-Number: 35786
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged