diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2018-03-09 14:52:35 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2018-03-11 17:38:29 +0700 |
commit | 633c806a2bc25bac0abce6b48c5cf255cc99f8a1 (patch) | |
tree | 81f8e98f35b38be57e0372c1a20cc30382272906 | |
parent | ddddf9e0c488b51d08f6127e29a2d2e48e440095 (diff) |
trxcon: clean up DATA / TRAFFIC indication API
- change 'l1ctl_tx_data_ind' symbol to 'l1ctl_tx_dt_ind' in
order to indicate that it's used for both DATA and TRAFFIC;
- introduce a 'traffic' flag, which is used to define either
TRAFFIC or DATA indication type;
- pass L2 payload and its length separately from the
Downlink info header.
Change-Id: I9fe65ee9b2d772576b86b7bc85d53518530d1579
-rw-r--r-- | src/host/trxcon/l1ctl.c | 31 | ||||
-rw-r--r-- | src/host/trxcon/l1ctl.h | 4 | ||||
-rw-r--r-- | src/host/trxcon/sched_lchan_common.c | 15 |
3 files changed, 23 insertions, 27 deletions
diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c index 3702e8a7..3de0cf68 100644 --- a/src/host/trxcon/l1ctl.c +++ b/src/host/trxcon/l1ctl.c @@ -183,29 +183,30 @@ int l1ctl_tx_ccch_mode_conf(struct l1ctl_link *l1l, uint8_t mode) return l1ctl_link_send(l1l, msg); } -int l1ctl_tx_data_ind(struct l1ctl_link *l1l, - struct l1ctl_info_dl *data, uint8_t msg_type) +/** + * Handles both L1CTL_DATA_IND and L1CTL_TRAFFIC_IND. + */ +int l1ctl_tx_dt_ind(struct l1ctl_link *l1l, struct l1ctl_info_dl *data, + uint8_t *l2, size_t l2_len, bool traffic) { struct l1ctl_info_dl *dl; struct msgb *msg; - size_t len; - - if (msg_type != L1CTL_DATA_IND && msg_type != L1CTL_TRAFFIC_IND) { - LOGP(DL1D, LOGL_ERROR, "Incorrect indication type\n"); - return -EINVAL; - } + uint8_t *msg_l2; - msg = l1ctl_alloc_msg(msg_type); + msg = l1ctl_alloc_msg(traffic ? + L1CTL_TRAFFIC_IND : L1CTL_DATA_IND); if (msg == NULL) return -ENOMEM; - /* We store the payload as a flexible array member */ - len = sizeof(struct l1ctl_info_dl); - len += msg_type == L1CTL_DATA_IND ? 23 : TRAFFIC_DATA_LEN; - dl = (struct l1ctl_info_dl *) msgb_put(msg, len); + /* Copy DL header */ + dl = (struct l1ctl_info_dl *) msgb_put(msg, sizeof(*dl)); + memcpy(dl, data, sizeof(*dl)); - /* Copy header and data from source message */ - memcpy(dl, data, len); + /* Copy the L2 payload if preset */ + if (l2 && l2_len > 0) { + msg_l2 = (uint8_t *) msgb_put(msg, l2_len); + memcpy(msg_l2, l2, l2_len); + } /* Put message to upper layers */ return l1ctl_link_send(l1l, msg); diff --git a/src/host/trxcon/l1ctl.h b/src/host/trxcon/l1ctl.h index 290a0f52..ca8c0be6 100644 --- a/src/host/trxcon/l1ctl.h +++ b/src/host/trxcon/l1ctl.h @@ -18,8 +18,8 @@ int l1ctl_tx_pm_conf(struct l1ctl_link *l1l, uint16_t band_arfcn, int l1ctl_tx_reset_conf(struct l1ctl_link *l1l, uint8_t type); int l1ctl_tx_reset_ind(struct l1ctl_link *l1l, uint8_t type); -int l1ctl_tx_data_ind(struct l1ctl_link *l1l, - struct l1ctl_info_dl *data, uint8_t msg_type); +int l1ctl_tx_dt_ind(struct l1ctl_link *l1l, struct l1ctl_info_dl *data, + uint8_t *l2, size_t l2_len, bool traffic); int l1ctl_tx_dt_conf(struct l1ctl_link *l1l, struct l1ctl_info_dl *data, bool traffic); int l1ctl_tx_rach_conf(struct l1ctl_link *l1l, uint32_t fn); diff --git a/src/host/trxcon/sched_lchan_common.c b/src/host/trxcon/sched_lchan_common.c index d946e577..13c87649 100644 --- a/src/host/trxcon/sched_lchan_common.c +++ b/src/host/trxcon/sched_lchan_common.c @@ -90,7 +90,7 @@ int sched_send_data_ind(struct trx_instance *trx, struct trx_ts *ts, struct l1ctl_info_dl *data; /* Allocate memory */ - data = talloc_zero_size(ts, sizeof(struct l1ctl_info_dl) + l2_len); + data = talloc_zero_size(ts, sizeof(struct l1ctl_info_dl)); if (data == NULL) return -ENOMEM; @@ -108,17 +108,12 @@ int sched_send_data_ind(struct trx_instance *trx, struct trx_ts *ts, /* FIXME: set proper values */ data->snr = 0; - if (dec_failed) { - /* Mark frame as broken */ - data->fire_crc = 2; - } else { - /* Fill in the payload */ - memcpy(data->payload, l2, l2_len); - } + /* Mark frame as broken if so */ + data->fire_crc = dec_failed ? 2 : 0; /* Put a packet to higher layers */ - l1ctl_tx_data_ind(trx->l1l, data, l2_len == GSM_MACBLOCK_LEN ? - L1CTL_DATA_IND : L1CTL_TRAFFIC_IND); + l1ctl_tx_dt_ind(trx->l1l, data, l2, l2_len, + l2_len != GSM_MACBLOCK_LEN); talloc_free(data); return 0; |