pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/15600


Change subject: pdch.cpp: Refactor bitvec param passing in rcv_control_block
......................................................................

pdch.cpp: Refactor bitvec param passing in rcv_control_block

Move code in rcv_block_gprs() only needed for rcv_control_block() into
the later. This way rcv_block_gprs() is simplified and shows similar
code paths with regards to rcv_data_block().
It can now be seen that the main difference between both is the meas
param no being passed in the control case.

Change-Id: I2a0133463edced93c72ccc743a0cf00d1d6922cf
---
M src/pdch.cpp
M src/pdch.h
2 files changed, 14 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/00/15600/1

diff --git a/src/pdch.cpp b/src/pdch.cpp
index 7488b96..5ae7e63 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -680,10 +680,18 @@
 }

 /* Received Uplink RLC control block. */
-int gprs_rlcmac_pdch::rcv_control_block(
-       const uint8_t *data, uint8_t data_len, bitvec *rlc_block, uint32_t fn)
+int gprs_rlcmac_pdch::rcv_control_block(const uint8_t *data, uint8_t data_len,
+                                       uint32_t fn, GprsCodingScheme cs)
 {
-       RlcMacUplink_t * ul_control_block = (RlcMacUplink_t 
*)talloc_zero(tall_pcu_ctx, RlcMacUplink_t);
+       bitvec *rlc_block;
+       RlcMacUplink_t *ul_control_block;
+       unsigned len = cs.maxBytesUL();
+
+       if (!(rlc_block = bitvec_alloc(len, tall_pcu_ctx)))
+               return -ENOMEM;
+       bitvec_unpack(rlc_block, data);
+       ul_control_block = (RlcMacUplink_t *)talloc_zero(tall_pcu_ctx, 
RlcMacUplink_t);
+
        LOGP(DRLCMAC, LOGL_DEBUG, "+++++++++++++++++++++++++ RX : Uplink 
Control Block +++++++++++++++++++++++++\n");
        decode_gsm_rlcmac_uplink(rlc_block, ul_control_block);
        LOGPC(DCSN1, LOGL_NOTICE, "\n");
@@ -721,6 +729,7 @@
                        ul_control_block->u.MESSAGE_TYPE);
        }
        talloc_free(ul_control_block);
+       bitvec_free(rlc_block);
        return 1;
 }

@@ -816,21 +825,14 @@
        struct pcu_l1_meas *meas, GprsCodingScheme cs)
 {
        unsigned payload = data[0] >> 6;
-       bitvec *block;
        int rc = 0;
-       unsigned len = cs.maxBytesUL();

        switch (payload) {
        case GPRS_RLCMAC_DATA_BLOCK:
                rc = rcv_data_block(data, data_len, fn, meas, cs);
                break;
        case GPRS_RLCMAC_CONTROL_BLOCK:
-               block = bitvec_alloc(len, tall_pcu_ctx);
-               if (!block)
-                       return -ENOMEM;
-               bitvec_unpack(block, data);
-               rc = rcv_control_block(data, data_len, block, fn);
-               bitvec_free(block);
+               rc = rcv_control_block(data, data_len, fn, cs);
                break;
        case GPRS_RLCMAC_CONTROL_BLOCK_OPT:
                LOGP(DRLCMAC, LOGL_NOTICE, "GPRS_RLCMAC_CONTROL_BLOCK_OPT block 
payload is not supported.\n");
@@ -961,4 +963,3 @@
 {
        return trx->bts->bts_data();
 }
-
diff --git a/src/pdch.h b/src/pdch.h
index cf9804d..e23d56f 100644
--- a/src/pdch.h
+++ b/src/pdch.h
@@ -94,7 +94,7 @@

 #ifdef __cplusplus
 private:
-       int rcv_control_block(const uint8_t *data, uint8_t data_len, bitvec 
*rlc_block, uint32_t fn);
+       int rcv_control_block(const uint8_t *data, uint8_t data_len, uint32_t 
fn, GprsCodingScheme cs);

        void rcv_control_ack(Packet_Control_Acknowledgement_t *, uint32_t fn);
        void rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *, uint32_t fn);

--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/15600
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I2a0133463edced93c72ccc743a0cf00d1d6922cf
Gerrit-Change-Number: 15600
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to