This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
fixeria gerrit-no-reply at lists.osmocom.orgfixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/19775 ) Change subject: tbf: allocate the bitvec on stack in create_{dl,ul}_ass() ...................................................................... tbf: allocate the bitvec on stack in create_{dl,ul}_ass() Initialize the bit vector to use already allocated memory, so we would not need to allocate additional 23 bytes and copy them from the bit vector to a msgb. Change-Id: I4190707d7fa5b1c4c3db745635f88d5afb9e21ca --- M src/tbf.cpp 1 file changed, 13 insertions(+), 21 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/75/19775/1 diff --git a/src/tbf.cpp b/src/tbf.cpp index f77b1e2..2d78ef8 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -1192,7 +1192,6 @@ struct msgb *msg; struct gprs_rlcmac_dl_tbf *new_dl_tbf = NULL; RlcMacDownlink_t *mac_control_block = NULL; - bitvec *ass_vec = NULL; int poll_ass_dl = 1; unsigned int rrbp = 0; uint32_t new_poll_fn = 0; @@ -1256,10 +1255,11 @@ msg = msgb_alloc(23, "rlcmac_dl_ass"); if (!msg) return NULL; - ass_vec = bitvec_alloc(23, tall_pcu_ctx); - if (!ass_vec) - goto free_ret; - bitvec_unhex(ass_vec, DUMMY_VEC); + struct bitvec bv = { + .data_len = GSM_MACBLOCK_LEN, + .data = msgb_put(msg, GSM_MACBLOCK_LEN), + }; + bitvec_unhex(&bv, DUMMY_VEC); LOGPTBF(new_dl_tbf, LOGL_INFO, "start Packet Downlink Assignment (PACCH)\n"); mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t); Encoding::write_packet_downlink_assignment(mac_control_block, @@ -1268,14 +1268,13 @@ bts_data()->alpha, bts_data()->gamma, -1, 0, is_egprs_enabled()); LOGP(DTBF, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Downlink Assignment +++++++++++++++++++++++++\n"); - rc = encode_gsm_rlcmac_downlink(ass_vec, mac_control_block); + rc = encode_gsm_rlcmac_downlink(&bv, mac_control_block); if (rc < 0) { LOGP(DTBF, LOGL_ERROR, "Decoding of Packet Downlink Ass failed (%d)\n", rc); goto free_ret; } LOGP(DTBF, LOGL_DEBUG, "------------------------- TX : Packet Downlink Assignment -------------------------\n"); bts->do_rate_ctr_inc(CTR_PKT_DL_ASSIGNMENT); - bitvec_pack(ass_vec, msgb_put(msg, 23)); if (poll_ass_dl) { set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_DL_ASS); @@ -1288,13 +1287,10 @@ } - bitvec_free(ass_vec); talloc_free(mac_control_block); return msg; free_ret: - if (ass_vec != NULL) - bitvec_free(ass_vec); talloc_free(mac_control_block); msgb_free(msg); return NULL; @@ -1333,7 +1329,6 @@ struct msgb *msg = NULL; struct gprs_rlcmac_ul_tbf *new_tbf = NULL; RlcMacDownlink_t *mac_control_block = NULL; - bitvec *ass_vec = NULL; int rc; unsigned int rrbp; uint32_t new_poll_fn; @@ -1361,20 +1356,20 @@ msg = msgb_alloc(23, "rlcmac_ul_ass"); if (!msg) return NULL; + struct bitvec bv = { + .data_len = GSM_MACBLOCK_LEN, + .data = msgb_put(msg, GSM_MACBLOCK_LEN), + }; + bitvec_unhex(&bv, DUMMY_VEC); LOGPTBF(new_tbf, LOGL_INFO, "start Packet Uplink Assignment (PACCH)\n"); - ass_vec = bitvec_alloc(23, tall_pcu_ctx); - if (!ass_vec) - goto free_ret; - bitvec_unhex(ass_vec, DUMMY_VEC); - Encoding::write_packet_uplink_assignment(ass_vec, m_tfi, + Encoding::write_packet_uplink_assignment(&bv, m_tfi, (direction == GPRS_RLCMAC_DL_TBF), tlli(), is_tlli_valid(), new_tbf, 1, rrbp, bts_data()->alpha, bts_data()->gamma, -1, is_egprs_enabled()); - bitvec_pack(ass_vec, msgb_put(msg, 23)); mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t); LOGP(DTBF, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Uplink Assignment +++++++++++++++++++++++++\n"); - rc = decode_gsm_rlcmac_downlink(ass_vec, mac_control_block); + rc = decode_gsm_rlcmac_downlink(&bv, mac_control_block); if (rc < 0) { LOGP(DTBF, LOGL_ERROR, "Decoding of Packet Uplink Ass failed (%d)\n", rc); goto free_ret; @@ -1384,13 +1379,10 @@ set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_UL_ASS); - bitvec_free(ass_vec); talloc_free(mac_control_block); return msg; free_ret: - if (ass_vec != NULL) - bitvec_free(ass_vec); talloc_free(mac_control_block); msgb_free(msg); return NULL; -- To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/19775 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Change-Id: I4190707d7fa5b1c4c3db745635f88d5afb9e21ca Gerrit-Change-Number: 19775 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200821/8f4800ee/attachment.htm>