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
This commit is contained in:
Vadim Yanitskiy 2018-03-09 14:52:35 +07:00
parent ddddf9e0c4
commit 633c806a2b
3 changed files with 23 additions and 27 deletions

View File

@ -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;
uint8_t *msg_l2;
if (msg_type != L1CTL_DATA_IND && msg_type != L1CTL_TRAFFIC_IND) {
LOGP(DL1D, LOGL_ERROR, "Incorrect indication type\n");
return -EINVAL;
}
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);

View File

@ -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);

View File

@ -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;