|
|
|
@ -41,6 +41,8 @@
|
|
|
|
|
|
|
|
|
|
#include "dci_sz_table.h"
|
|
|
|
|
|
|
|
|
|
int harq_pid_len = 3;
|
|
|
|
|
|
|
|
|
|
/* Unpacks a DCI message and configures the DL grant object
|
|
|
|
|
*/
|
|
|
|
|
int srslte_dci_msg_to_dl_grant(srslte_dci_msg_t *msg, uint16_t msg_rnti,
|
|
|
|
@ -240,7 +242,7 @@ uint32_t dci_format0_sizeof_(uint32_t nof_prb) {
|
|
|
|
|
|
|
|
|
|
uint32_t dci_format1A_sizeof(uint32_t nof_prb) {
|
|
|
|
|
uint32_t n;
|
|
|
|
|
n = 1 + 1 + riv_nbits(nof_prb) + 5 + 3 + 1 + 2 + 2;
|
|
|
|
|
n = 1 + 1 + riv_nbits(nof_prb) + 5 + harq_pid_len + 1 + 2 + 2;
|
|
|
|
|
while (n < dci_format0_sizeof_(nof_prb)) {
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
@ -260,7 +262,7 @@ uint32_t dci_format0_sizeof(uint32_t nof_prb) {
|
|
|
|
|
|
|
|
|
|
uint32_t dci_format1_sizeof(uint32_t nof_prb) {
|
|
|
|
|
|
|
|
|
|
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb)) + 5 + 3 + 1 + 2
|
|
|
|
|
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb)) + 5 + harq_pid_len + 1 + 2
|
|
|
|
|
+ 2;
|
|
|
|
|
if (nof_prb > 10) {
|
|
|
|
|
n++;
|
|
|
|
@ -316,7 +318,7 @@ uint32_t precoding_bits_f2(uint32_t nof_ports) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t dci_format2_sizeof(uint32_t nof_prb, uint32_t nof_ports) {
|
|
|
|
|
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+3+1+2*(5+1+2)+precoding_bits_f2(nof_ports);
|
|
|
|
|
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+harq_pid_len+1+2*(5+1+2)+precoding_bits_f2(nof_ports);
|
|
|
|
|
if (nof_prb > 10) {
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
@ -336,7 +338,7 @@ uint32_t precoding_bits_f2a(uint32_t nof_ports) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t dci_format2A_sizeof(uint32_t nof_prb, uint32_t nof_ports) {
|
|
|
|
|
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+3+1+2*(5+1+2)+precoding_bits_f2a(nof_ports);
|
|
|
|
|
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+harq_pid_len+1+2*(5+1+2)+precoding_bits_f2a(nof_ports);
|
|
|
|
|
if (nof_prb > 10) {
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
@ -348,7 +350,7 @@ uint32_t dci_format2A_sizeof(uint32_t nof_prb, uint32_t nof_ports) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t dci_format2B_sizeof(uint32_t nof_prb, uint32_t nof_ports) {
|
|
|
|
|
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+3+1+2*(5+1+2);
|
|
|
|
|
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+harq_pid_len+1+2*(5+1+2);
|
|
|
|
|
if (nof_prb > 10) {
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
@ -455,7 +457,7 @@ int dci_format0_pack(srslte_ra_ul_dci_t *data, srslte_dci_msg_t *msg, uint32_t n
|
|
|
|
|
*y++ = data->cqi_request;
|
|
|
|
|
|
|
|
|
|
// Padding with zeros
|
|
|
|
|
uint32_t n = srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT0, nof_prb);
|
|
|
|
|
uint32_t n = srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT0, nof_prb, 1);
|
|
|
|
|
while (y - msg->data < n) {
|
|
|
|
|
*y++ = 0;
|
|
|
|
|
}
|
|
|
|
@ -474,7 +476,7 @@ int dci_format0_unpack(srslte_dci_msg_t *msg, srslte_ra_ul_dci_t *data, uint32_t
|
|
|
|
|
uint32_t n_ul_hop;
|
|
|
|
|
|
|
|
|
|
/* Make sure it's a SRSLTE_DCI_FORMAT0 message */
|
|
|
|
|
if (msg->nof_bits != srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT0, nof_prb)) {
|
|
|
|
|
if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT0, nof_prb, 1)) {
|
|
|
|
|
fprintf(stderr, "Invalid message length for format 0\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -556,7 +558,7 @@ int dci_format1_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t n
|
|
|
|
|
srslte_bit_unpack(data->mcs_idx, &y, 5);
|
|
|
|
|
|
|
|
|
|
/* harq process number */
|
|
|
|
|
srslte_bit_unpack(data->harq_process, &y, 3);
|
|
|
|
|
srslte_bit_unpack(data->harq_process, &y, harq_pid_len);
|
|
|
|
|
|
|
|
|
|
*y++ = data->ndi;
|
|
|
|
|
|
|
|
|
@ -567,7 +569,7 @@ int dci_format1_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t n
|
|
|
|
|
srslte_bit_unpack(data->tpc_pucch, &y, 2);
|
|
|
|
|
|
|
|
|
|
// Padding with zeros
|
|
|
|
|
uint32_t n = srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1, nof_prb);
|
|
|
|
|
uint32_t n = srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb, 1);
|
|
|
|
|
while (y - msg->data < n) {
|
|
|
|
|
*y++ = 0;
|
|
|
|
|
}
|
|
|
|
@ -582,7 +584,7 @@ int dci_format1_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_t
|
|
|
|
|
uint8_t *y = msg->data;
|
|
|
|
|
|
|
|
|
|
/* Make sure it's a SRSLTE_DCI_FORMAT1 message */
|
|
|
|
|
if (msg->nof_bits != srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1, nof_prb)) {
|
|
|
|
|
if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb, 1)) {
|
|
|
|
|
fprintf(stderr, "Invalid message length for format 1\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -615,7 +617,7 @@ int dci_format1_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_t
|
|
|
|
|
data->mcs_idx = srslte_bit_pack(&y, 5);
|
|
|
|
|
|
|
|
|
|
/* harq process number */
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, 3);
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, harq_pid_len);
|
|
|
|
|
|
|
|
|
|
data->ndi = *y++ ? true : false;
|
|
|
|
|
// rv version
|
|
|
|
@ -687,7 +689,7 @@ int dci_format1As_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t
|
|
|
|
|
// in format1A, MCS = TBS according to 7.1.7.2 of 36.213
|
|
|
|
|
srslte_bit_unpack(data->mcs_idx, &y, 5);
|
|
|
|
|
|
|
|
|
|
srslte_bit_unpack(data->harq_process, &y, 3);
|
|
|
|
|
srslte_bit_unpack(data->harq_process, &y, harq_pid_len);
|
|
|
|
|
|
|
|
|
|
if (crc_is_crnti) {
|
|
|
|
|
if (nof_prb >= 50 && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) {
|
|
|
|
@ -712,7 +714,7 @@ int dci_format1As_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Padding with zeros
|
|
|
|
|
uint32_t n = srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1A, nof_prb);
|
|
|
|
|
uint32_t n = srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb, 1);
|
|
|
|
|
while (y - msg->data < n) {
|
|
|
|
|
*y++ = 0;
|
|
|
|
|
}
|
|
|
|
@ -731,7 +733,7 @@ int dci_format1As_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
|
|
|
|
|
uint8_t *y = msg->data;
|
|
|
|
|
|
|
|
|
|
/* Make sure it's a SRSLTE_DCI_FORMAT0 message */
|
|
|
|
|
if (msg->nof_bits != srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1A, nof_prb)) {
|
|
|
|
|
if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb, 1)) {
|
|
|
|
|
fprintf(stderr, "Invalid message length for format 1A\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -788,7 +790,7 @@ int dci_format1As_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
|
|
|
|
|
// unpack MCS
|
|
|
|
|
data->mcs_idx = srslte_bit_pack(&y, 5);
|
|
|
|
|
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, 3);
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, harq_pid_len);
|
|
|
|
|
|
|
|
|
|
if (!crc_is_crnti) {
|
|
|
|
|
if (nof_prb >= 50 && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) {
|
|
|
|
@ -848,7 +850,7 @@ int dci_format1B_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_
|
|
|
|
|
|
|
|
|
|
// unpack MCS, Harq pid and ndi
|
|
|
|
|
data->mcs_idx = srslte_bit_pack(&y, 5);
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, 3);
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, harq_pid_len);
|
|
|
|
|
data->ndi = *y++ ? true : false;
|
|
|
|
|
data->rv_idx = srslte_bit_pack(&y, 2);
|
|
|
|
|
|
|
|
|
@ -924,7 +926,7 @@ int dci_format1Cs_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
|
|
|
|
|
/* pack bits */
|
|
|
|
|
uint8_t *y = msg->data;
|
|
|
|
|
|
|
|
|
|
if (msg->nof_bits != srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1C, nof_prb)) {
|
|
|
|
|
if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1C, nof_prb, 1)) {
|
|
|
|
|
fprintf(stderr, "Invalid message length for format 1C\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -989,7 +991,7 @@ int dci_format1D_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_
|
|
|
|
|
|
|
|
|
|
// unpack MCS, Harq pid and ndi
|
|
|
|
|
data->mcs_idx = srslte_bit_pack(&y, 5);
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, 3);
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, harq_pid_len);
|
|
|
|
|
data->ndi = *y++ ? true : false;
|
|
|
|
|
data->rv_idx = srslte_bit_pack(&y, 2);
|
|
|
|
|
|
|
|
|
@ -1038,7 +1040,7 @@ int dci_format2AB_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
|
|
|
|
|
y+=2;
|
|
|
|
|
|
|
|
|
|
/* harq process number */
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, 3);
|
|
|
|
|
data->harq_process = srslte_bit_pack(&y, harq_pid_len);
|
|
|
|
|
|
|
|
|
|
// Transpor block to codeword swap flag
|
|
|
|
|
if (msg->format == SRSLTE_DCI_FORMAT2B) {
|
|
|
|
@ -1202,16 +1204,16 @@ int srslte_dci_msg_get_type(srslte_dci_msg_t *msg, srslte_dci_msg_type_t *type,
|
|
|
|
|
uint16_t msg_rnti)
|
|
|
|
|
{
|
|
|
|
|
DEBUG("Get message type: nof_bits=%d, msg_rnti=0x%x\n", msg->nof_bits, msg_rnti);
|
|
|
|
|
if (msg->nof_bits == srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT0, nof_prb)
|
|
|
|
|
if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT0, nof_prb, 1)
|
|
|
|
|
&& !msg->data[0]) {
|
|
|
|
|
type->type = SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED;
|
|
|
|
|
type->format = SRSLTE_DCI_FORMAT0;
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
} else if (msg->nof_bits == srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1, nof_prb)) {
|
|
|
|
|
} else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb, 1)) {
|
|
|
|
|
type->type = SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED; // only these 2 types supported
|
|
|
|
|
type->format = SRSLTE_DCI_FORMAT1;
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
} else if (msg->nof_bits == srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1A, nof_prb)) {
|
|
|
|
|
} else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb, 1)) {
|
|
|
|
|
/* The RNTI is not the only condition. Also some fields in the packet.
|
|
|
|
|
* if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) {
|
|
|
|
|
type->type = SRSLTE_DCI_MSG_TYPE_RA_PROC_PDCCH;
|
|
|
|
@ -1222,7 +1224,7 @@ int srslte_dci_msg_get_type(srslte_dci_msg_t *msg, srslte_dci_msg_type_t *type,
|
|
|
|
|
type->format = SRSLTE_DCI_FORMAT1A;
|
|
|
|
|
//}
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
} else if (msg->nof_bits == srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1C, nof_prb)) {
|
|
|
|
|
} else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1C, nof_prb, 1)) {
|
|
|
|
|
if (msg_rnti == SRSLTE_MRNTI) {
|
|
|
|
|
type->type = SRSLTE_DCI_MSG_TYPE_MCCH_CHANGE;
|
|
|
|
|
type->format = SRSLTE_DCI_FORMAT1C;
|
|
|
|
|