[MERGED] osmocom-bb[fixeria/trx]: trxcon/sched_lchan_common.c: use static memory allocation

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/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Sun Mar 11 11:19:09 UTC 2018


Vadim Yanitskiy has submitted this change and it was merged.

Change subject: trxcon/sched_lchan_common.c: use static memory allocation
......................................................................


trxcon/sched_lchan_common.c: use static memory allocation

There is no need to allocate the DL header for each new message.

Change-Id: Id7ad815c6b403f5c3d15fc02022397188f1d87fd
---
M src/host/trxcon/sched_lchan_common.c
1 file changed, 20 insertions(+), 29 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 13c8764..1858619 100644
--- a/src/host/trxcon/sched_lchan_common.c
+++ b/src/host/trxcon/sched_lchan_common.c
@@ -87,34 +87,28 @@
 	bool dec_failed, int bit_error_count)
 {
 	const struct trx_lchan_desc *lchan_desc;
-	struct l1ctl_info_dl *data;
-
-	/* Allocate memory */
-	data = talloc_zero_size(ts, sizeof(struct l1ctl_info_dl));
-	if (data == NULL)
-		return -ENOMEM;
+	struct l1ctl_info_dl dl_hdr;
 
 	/* Set up pointers */
 	lchan_desc = &trx_lchan_desc[lchan->type];
 
 	/* Fill in known downlink info */
-	data->chan_nr = lchan_desc->chan_nr | ts->index;
-	data->link_id = lchan_desc->link_id;
-	data->band_arfcn = htons(trx->band_arfcn);
-	data->frame_nr = htonl(lchan->rx_first_fn);
-	data->rx_level = -(lchan->meas.rssi_sum / lchan->meas.rssi_num);
-	data->num_biterr = bit_error_count;
+	dl_hdr.chan_nr = lchan_desc->chan_nr | ts->index;
+	dl_hdr.link_id = lchan_desc->link_id;
+	dl_hdr.band_arfcn = htons(trx->band_arfcn);
+	dl_hdr.frame_nr = htonl(lchan->rx_first_fn);
+	dl_hdr.rx_level = -(lchan->meas.rssi_sum / lchan->meas.rssi_num);
+	dl_hdr.num_biterr = bit_error_count;
 
 	/* FIXME: set proper values */
-	data->snr = 0;
+	dl_hdr.snr = 0;
 
 	/* Mark frame as broken if so */
-	data->fire_crc = dec_failed ? 2 : 0;
+	dl_hdr.fire_crc = dec_failed ? 2 : 0;
 
 	/* Put a packet to higher layers */
-	l1ctl_tx_dt_ind(trx->l1l, data, l2, l2_len,
+	l1ctl_tx_dt_ind(trx->l1l, &dl_hdr, l2, l2_len,
 		l2_len != GSM_MACBLOCK_LEN);
-	talloc_free(data);
 
 	return 0;
 }
@@ -123,25 +117,22 @@
 	struct trx_lchan_state *lchan, uint32_t fn, size_t l2_len)
 {
 	const struct trx_lchan_desc *lchan_desc;
-	struct l1ctl_info_dl *data;
-
-	/* Allocate memory */
-	data = talloc_zero(ts, struct l1ctl_info_dl);
-	if (data == NULL)
-		return -ENOMEM;
+	struct l1ctl_info_dl dl_hdr;
 
 	/* Set up pointers */
 	lchan_desc = &trx_lchan_desc[lchan->type];
 
-	/* Fill in known downlink info */
-	data->chan_nr = lchan_desc->chan_nr | ts->index;
-	data->link_id = lchan_desc->link_id;
-	data->band_arfcn = htons(trx->band_arfcn);
-	data->frame_nr = htonl(fn);
+	/* Zero-initialize DL header, because we don't set all fields */
+	memset(&dl_hdr, 0x00, sizeof(struct l1ctl_info_dl));
 
-	l1ctl_tx_dt_conf(trx->l1l, data,
+	/* Fill in known downlink info */
+	dl_hdr.chan_nr = lchan_desc->chan_nr | ts->index;
+	dl_hdr.link_id = lchan_desc->link_id;
+	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);
-	talloc_free(data);
 
 	return 0;
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id7ad815c6b403f5c3d15fc02022397188f1d87fd
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list