rework the ul_config_request data structure: put the mutex in correct place and encapsulate the struct management in access API, remove internal storage visibility
This commit is contained in:
@@ -69,4 +69,5 @@
|
|||||||
#define FAPI_NR_UL_CONFIG_TYPE_SRS 0x04
|
#define FAPI_NR_UL_CONFIG_TYPE_SRS 0x04
|
||||||
#define FAPI_NR_UL_CONFIG_TYPES 0x04
|
#define FAPI_NR_UL_CONFIG_TYPES 0x04
|
||||||
|
|
||||||
|
#define FAPI_NR_END 0xff
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -391,20 +391,22 @@ typedef struct {
|
|||||||
} fapi_nr_ul_config_srs_pdu;
|
} fapi_nr_ul_config_srs_pdu;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t pdu_type;
|
int pdu_type;
|
||||||
union {
|
union {
|
||||||
fapi_nr_ul_config_prach_pdu prach_config_pdu;
|
fapi_nr_ul_config_prach_pdu prach_config_pdu;
|
||||||
fapi_nr_ul_config_pucch_pdu pucch_config_pdu;
|
fapi_nr_ul_config_pucch_pdu pucch_config_pdu;
|
||||||
nfapi_nr_ue_pusch_pdu_t pusch_config_pdu;
|
nfapi_nr_ue_pusch_pdu_t pusch_config_pdu;
|
||||||
fapi_nr_ul_config_srs_pdu srs_config_pdu;
|
fapi_nr_ul_config_srs_pdu srs_config_pdu;
|
||||||
};
|
};
|
||||||
|
pthread_mutex_t* lock;
|
||||||
|
int* privateNBpdus;
|
||||||
} fapi_nr_ul_config_request_pdu_t;
|
} fapi_nr_ul_config_request_pdu_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int frame;
|
int frame;
|
||||||
int slot;
|
int slot;
|
||||||
int number_pdus;
|
int number_pdus;
|
||||||
fapi_nr_ul_config_request_pdu_t ul_config_list[FAPI_NR_UL_CONFIG_LIST_NUM];
|
fapi_nr_ul_config_request_pdu_t ul_config_list[FAPI_NR_UL_CONFIG_LIST_NUM + 1]; // +1 to have space for iterator ending
|
||||||
pthread_mutex_t mutex_ul_config;
|
pthread_mutex_t mutex_ul_config;
|
||||||
} fapi_nr_ul_config_request_t;
|
} fapi_nr_ul_config_request_t;
|
||||||
|
|
||||||
|
|||||||
@@ -104,192 +104,182 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
|
|||||||
|
|
||||||
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
|
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
|
||||||
|
|
||||||
if(scheduled_response != NULL) {
|
if (scheduled_response && scheduled_response->ul_config) {
|
||||||
if (scheduled_response->ul_config != NULL) {
|
int frame = scheduled_response->ul_config->frame;
|
||||||
int frame = scheduled_response->ul_config->frame;
|
int slot = scheduled_response->ul_config->slot;
|
||||||
int slot = scheduled_response->ul_config->slot;
|
fapi_nr_ul_config_request_pdu_t *it = fapiLockIterator(scheduled_response->ul_config, frame, slot);
|
||||||
fapi_nr_ul_config_request_t *ul_config = scheduled_response->ul_config;
|
while (it->pdu_type != FAPI_NR_END) {
|
||||||
AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]),
|
switch (it->pdu_type) {
|
||||||
"Too many ul_config pdus %d", ul_config->number_pdus);
|
case FAPI_NR_UL_CONFIG_TYPE_PRACH: {
|
||||||
for (int i = 0; i < ul_config->number_pdus; ++i) {
|
fapi_nr_ul_config_prach_pdu *prach_pdu = &it->prach_config_pdu;
|
||||||
LOG_D(NR_PHY, "In %s: processing type %d PDU of %d total UL PDUs (ul_config %p) \n",
|
nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind));
|
||||||
__FUNCTION__, ul_config->ul_config_list[i].pdu_type, ul_config->number_pdus, ul_config);
|
rach_ind->sfn = frame;
|
||||||
|
rach_ind->slot = slot;
|
||||||
|
rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION;
|
||||||
|
uint8_t pdu_index = 0;
|
||||||
|
rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list));
|
||||||
|
rach_ind->number_of_pdus = 1;
|
||||||
|
rach_ind->pdu_list[pdu_index].phy_cell_id = prach_pdu->phys_cell_id;
|
||||||
|
rach_ind->pdu_list[pdu_index].symbol_index = prach_pdu->prach_start_symbol;
|
||||||
|
rach_ind->pdu_list[pdu_index].slot_index = prach_pdu->prach_slot;
|
||||||
|
rach_ind->pdu_list[pdu_index].freq_index = prach_pdu->num_ra;
|
||||||
|
rach_ind->pdu_list[pdu_index].avg_rssi = 128;
|
||||||
|
rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now
|
||||||
|
rach_ind->pdu_list[pdu_index].num_preamble = 1;
|
||||||
|
const int num_p = rach_ind->pdu_list[pdu_index].num_preamble;
|
||||||
|
rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
|
||||||
|
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = prach_pdu->ra_PreambleIndex;
|
||||||
|
rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0;
|
||||||
|
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff;
|
||||||
|
|
||||||
uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type;
|
if (!put_queue(&nr_rach_ind_queue, rach_ind)) {
|
||||||
switch (pdu_type) {
|
for (int pdu_index = 0; pdu_index < rach_ind->number_of_pdus; pdu_index++)
|
||||||
case FAPI_NR_UL_CONFIG_TYPE_PRACH: {
|
free(rach_ind->pdu_list[pdu_index].preamble_list);
|
||||||
fapi_nr_ul_config_prach_pdu *prach_pdu = &ul_config->ul_config_list[i].prach_config_pdu;
|
free(rach_ind->pdu_list);
|
||||||
nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind));
|
free(rach_ind);
|
||||||
rach_ind->sfn = frame;
|
|
||||||
rach_ind->slot = slot;
|
|
||||||
rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION;
|
|
||||||
uint8_t pdu_index = 0;
|
|
||||||
rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list));
|
|
||||||
rach_ind->number_of_pdus = 1;
|
|
||||||
rach_ind->pdu_list[pdu_index].phy_cell_id = prach_pdu->phys_cell_id;
|
|
||||||
rach_ind->pdu_list[pdu_index].symbol_index = prach_pdu->prach_start_symbol;
|
|
||||||
rach_ind->pdu_list[pdu_index].slot_index = prach_pdu->prach_slot;
|
|
||||||
rach_ind->pdu_list[pdu_index].freq_index = prach_pdu->num_ra;
|
|
||||||
rach_ind->pdu_list[pdu_index].avg_rssi = 128;
|
|
||||||
rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now
|
|
||||||
rach_ind->pdu_list[pdu_index].num_preamble = 1;
|
|
||||||
const int num_p = rach_ind->pdu_list[pdu_index].num_preamble;
|
|
||||||
rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
|
|
||||||
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = prach_pdu->ra_PreambleIndex;
|
|
||||||
rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0;
|
|
||||||
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff;
|
|
||||||
|
|
||||||
if (!put_queue(&nr_rach_ind_queue, rach_ind)) {
|
|
||||||
for (int pdu_index = 0; pdu_index < rach_ind->number_of_pdus; pdu_index++)
|
|
||||||
free(rach_ind->pdu_list[pdu_index].preamble_list);
|
|
||||||
free(rach_ind->pdu_list);
|
|
||||||
free(rach_ind);
|
|
||||||
}
|
|
||||||
LOG_D(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case (FAPI_NR_UL_CONFIG_TYPE_PUSCH): {
|
LOG_D(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n");
|
||||||
nfapi_nr_rx_data_indication_t *rx_ind = CALLOC(1, sizeof(*rx_ind));
|
|
||||||
nfapi_nr_crc_indication_t *crc_ind = CALLOC(1, sizeof(*crc_ind));
|
|
||||||
nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[i].pusch_config_pdu;
|
|
||||||
if (pusch_config_pdu->tx_request_body.pdu) {
|
|
||||||
rx_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION;
|
|
||||||
rx_ind->sfn = frame;
|
|
||||||
rx_ind->slot = slot;
|
|
||||||
rx_ind->number_of_pdus = 1; // scheduled_response->tx_request->number_of_pdus;
|
|
||||||
rx_ind->pdu_list = CALLOC(rx_ind->number_of_pdus, sizeof(*rx_ind->pdu_list));
|
|
||||||
for (int j = 0; j < rx_ind->number_of_pdus; j++) {
|
|
||||||
fapi_nr_tx_request_body_t *tx_req_body = &pusch_config_pdu->tx_request_body;
|
|
||||||
rx_ind->pdu_list[j].handle = pusch_config_pdu->handle;
|
|
||||||
rx_ind->pdu_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id;
|
|
||||||
rx_ind->pdu_list[j].pdu_length = tx_req_body->pdu_length;
|
|
||||||
rx_ind->pdu_list[j].pdu = CALLOC(tx_req_body->pdu_length, sizeof(*rx_ind->pdu_list[j].pdu));
|
|
||||||
memcpy(rx_ind->pdu_list[j].pdu, tx_req_body->pdu, tx_req_body->pdu_length * sizeof(*rx_ind->pdu_list[j].pdu));
|
|
||||||
rx_ind->pdu_list[j].rnti = pusch_config_pdu->rnti;
|
|
||||||
/* TODO: Implement channel modeling to abstract TA and CQI. For now,
|
|
||||||
we hard code the values below since they are set in L1 and we are
|
|
||||||
abstracting L1. */
|
|
||||||
rx_ind->pdu_list[j].timing_advance = 31;
|
|
||||||
rx_ind->pdu_list[j].ul_cqi = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
crc_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION;
|
|
||||||
crc_ind->number_crcs = scheduled_response->ul_config->number_pdus;
|
|
||||||
crc_ind->sfn = frame;
|
|
||||||
crc_ind->slot = slot;
|
|
||||||
crc_ind->crc_list = CALLOC(crc_ind->number_crcs, sizeof(*crc_ind->crc_list));
|
|
||||||
for (int j = 0; j < crc_ind->number_crcs; j++) {
|
|
||||||
crc_ind->crc_list[j].handle = pusch_config_pdu->handle;
|
|
||||||
crc_ind->crc_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id;
|
|
||||||
LOG_D(NR_MAC, "This is the harq pid %d for crc_list[%d]\n", crc_ind->crc_list[j].harq_id, j);
|
|
||||||
LOG_D(NR_MAC, "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d]\n", frame, slot, crc_ind->sfn, crc_ind->slot);
|
|
||||||
crc_ind->crc_list[j].num_cb = pusch_config_pdu->pusch_data.num_cb;
|
|
||||||
crc_ind->crc_list[j].rnti = pusch_config_pdu->rnti;
|
|
||||||
crc_ind->crc_list[j].tb_crc_status = 0;
|
|
||||||
crc_ind->crc_list[j].timing_advance = 31;
|
|
||||||
crc_ind->crc_list[j].ul_cqi = 255;
|
|
||||||
AssertFatal(mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot == -1,
|
|
||||||
"We did not send an active CRC when we should have!\n");
|
|
||||||
mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot =
|
|
||||||
NFAPI_SFNSLOT2HEX(crc_ind->sfn, crc_ind->slot);
|
|
||||||
LOG_D(NR_MAC,
|
|
||||||
"This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d] with mcs_index in ul_cqi -> %d\n",
|
|
||||||
frame,
|
|
||||||
slot,
|
|
||||||
crc_ind->sfn,
|
|
||||||
crc_ind->slot,
|
|
||||||
pusch_config_pdu->mcs_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!put_queue(&nr_rx_ind_queue, rx_ind)) {
|
|
||||||
LOG_E(NR_MAC, "Put_queue failed for rx_ind\n");
|
|
||||||
for (int i = 0; i < rx_ind->number_of_pdus; i++) {
|
|
||||||
free(rx_ind->pdu_list[i].pdu);
|
|
||||||
rx_ind->pdu_list[i].pdu = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(rx_ind->pdu_list);
|
|
||||||
rx_ind->pdu_list = NULL;
|
|
||||||
free(rx_ind);
|
|
||||||
rx_ind = NULL;
|
|
||||||
}
|
|
||||||
if (!put_queue(&nr_crc_ind_queue, crc_ind)) {
|
|
||||||
LOG_E(NR_MAC, "Put_queue failed for crc_ind\n");
|
|
||||||
free(crc_ind->crc_list);
|
|
||||||
crc_ind->crc_list = NULL;
|
|
||||||
free(crc_ind);
|
|
||||||
crc_ind = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_D(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FAPI_NR_UL_CONFIG_TYPE_PUCCH: {
|
|
||||||
nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind));
|
|
||||||
uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION;
|
|
||||||
uci_ind->sfn = frame;
|
|
||||||
uci_ind->slot = slot;
|
|
||||||
uci_ind->num_ucis = 1;
|
|
||||||
uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list));
|
|
||||||
for (int j = 0; j < uci_ind->num_ucis; j++) {
|
|
||||||
LOG_D(NR_MAC, "ul_config->ul_config_list[%d].pucch_config_pdu.n_bit = %d\n", i, ul_config->ul_config_list[i].pucch_config_pdu.n_bit);
|
|
||||||
if (ul_config->ul_config_list[i].pucch_config_pdu.n_bit > 3 && mac->nr_ue_emul_l1.num_csi_reports > 0) {
|
|
||||||
uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE;
|
|
||||||
uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_2_3_4_t);
|
|
||||||
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[j].pucch_pdu_format_2_3_4;
|
|
||||||
fill_uci_2_3_4(pdu_2_3_4, &ul_config->ul_config_list[i].pucch_config_pdu);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1;
|
|
||||||
uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE;
|
|
||||||
uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t);
|
|
||||||
memset(pdu_0_1, 0, sizeof(*pdu_0_1));
|
|
||||||
pdu_0_1->handle = 0;
|
|
||||||
pdu_0_1->rnti = ul_config->ul_config_list[i].pucch_config_pdu.rnti;
|
|
||||||
pdu_0_1->pucch_format = 1;
|
|
||||||
pdu_0_1->ul_cqi = 255;
|
|
||||||
pdu_0_1->timing_advance = 0;
|
|
||||||
pdu_0_1->rssi = 0;
|
|
||||||
if (mac->nr_ue_emul_l1.num_harqs > 0) {
|
|
||||||
int harq_index = 0;
|
|
||||||
pdu_0_1->pduBitmap = 2; // (value->pduBitmap >> 1) & 0x01) == HARQ and (value->pduBitmap) & 0x01) == SR
|
|
||||||
pdu_0_1->harq.num_harq = mac->nr_ue_emul_l1.num_harqs;
|
|
||||||
pdu_0_1->harq.harq_confidence_level = 0;
|
|
||||||
int harq_pid = -1;
|
|
||||||
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) {
|
|
||||||
if (mac->nr_ue_emul_l1.harq[k].active &&
|
|
||||||
mac->nr_ue_emul_l1.harq[k].active_dl_harq_sfn == uci_ind->sfn &&
|
|
||||||
mac->nr_ue_emul_l1.harq[k].active_dl_harq_slot == uci_ind->slot) {
|
|
||||||
mac->nr_ue_emul_l1.harq[k].active = false;
|
|
||||||
harq_pid = k;
|
|
||||||
AssertFatal(harq_index < pdu_0_1->harq.num_harq, "Invalid harq_index %d\n", harq_index);
|
|
||||||
pdu_0_1->harq.harq_list[harq_index].harq_value = !mac->dl_harq_info[k].ack;
|
|
||||||
harq_index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AssertFatal(harq_pid != -1, "No active harq_pid, sfn_slot = %u.%u", uci_ind->sfn, uci_ind->slot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_D(NR_PHY, "Sending UCI with %d PDUs in sfn.slot %d/%d\n",
|
|
||||||
uci_ind->num_ucis, uci_ind->sfn, uci_ind->slot);
|
|
||||||
NR_UL_IND_t ul_info = {
|
|
||||||
.uci_ind = *uci_ind,
|
|
||||||
};
|
|
||||||
send_nsa_standalone_msg(&ul_info, uci_ind->header.message_id);
|
|
||||||
free_uci_inds(uci_ind);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
LOG_W(NR_MAC, "Unknown ul_config->pdu_type %d\n", pdu_type);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case (FAPI_NR_UL_CONFIG_TYPE_PUSCH): {
|
||||||
|
nfapi_nr_rx_data_indication_t *rx_ind = CALLOC(1, sizeof(*rx_ind));
|
||||||
|
nfapi_nr_crc_indication_t *crc_ind = CALLOC(1, sizeof(*crc_ind));
|
||||||
|
nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &it->pusch_config_pdu;
|
||||||
|
if (pusch_config_pdu->tx_request_body.pdu) {
|
||||||
|
rx_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION;
|
||||||
|
rx_ind->sfn = frame;
|
||||||
|
rx_ind->slot = slot;
|
||||||
|
rx_ind->number_of_pdus = 1;
|
||||||
|
rx_ind->pdu_list = CALLOC(rx_ind->number_of_pdus, sizeof(*rx_ind->pdu_list));
|
||||||
|
for (int j = 0; j < rx_ind->number_of_pdus; j++) {
|
||||||
|
fapi_nr_tx_request_body_t *tx_req_body = &pusch_config_pdu->tx_request_body;
|
||||||
|
rx_ind->pdu_list[j].handle = pusch_config_pdu->handle;
|
||||||
|
rx_ind->pdu_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id;
|
||||||
|
rx_ind->pdu_list[j].pdu_length = tx_req_body->pdu_length;
|
||||||
|
rx_ind->pdu_list[j].pdu = CALLOC(tx_req_body->pdu_length, sizeof(*rx_ind->pdu_list[j].pdu));
|
||||||
|
memcpy(rx_ind->pdu_list[j].pdu, tx_req_body->pdu, tx_req_body->pdu_length * sizeof(*rx_ind->pdu_list[j].pdu));
|
||||||
|
rx_ind->pdu_list[j].rnti = pusch_config_pdu->rnti;
|
||||||
|
/* TODO: Implement channel modeling to abstract TA and CQI. For now,
|
||||||
|
we hard code the values below since they are set in L1 and we are
|
||||||
|
abstracting L1. */
|
||||||
|
rx_ind->pdu_list[j].timing_advance = 31;
|
||||||
|
rx_ind->pdu_list[j].ul_cqi = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
crc_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION;
|
||||||
|
crc_ind->number_crcs = rx_ind->number_of_pdus;
|
||||||
|
crc_ind->sfn = frame;
|
||||||
|
crc_ind->slot = slot;
|
||||||
|
crc_ind->crc_list = CALLOC(crc_ind->number_crcs, sizeof(*crc_ind->crc_list));
|
||||||
|
for (int j = 0; j < crc_ind->number_crcs; j++) {
|
||||||
|
crc_ind->crc_list[j].handle = pusch_config_pdu->handle;
|
||||||
|
crc_ind->crc_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id;
|
||||||
|
LOG_D(NR_MAC, "This is the harq pid %d for crc_list[%d]\n", crc_ind->crc_list[j].harq_id, j);
|
||||||
|
LOG_D(NR_MAC, "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d]\n", frame, slot, crc_ind->sfn, crc_ind->slot);
|
||||||
|
crc_ind->crc_list[j].num_cb = pusch_config_pdu->pusch_data.num_cb;
|
||||||
|
crc_ind->crc_list[j].rnti = pusch_config_pdu->rnti;
|
||||||
|
crc_ind->crc_list[j].tb_crc_status = 0;
|
||||||
|
crc_ind->crc_list[j].timing_advance = 31;
|
||||||
|
crc_ind->crc_list[j].ul_cqi = 255;
|
||||||
|
AssertFatal(mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot == -1,
|
||||||
|
"We did not send an active CRC when we should have!\n");
|
||||||
|
mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot =
|
||||||
|
NFAPI_SFNSLOT2HEX(crc_ind->sfn, crc_ind->slot);
|
||||||
|
LOG_D(NR_MAC,
|
||||||
|
"This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d] with mcs_index in ul_cqi -> %d\n",
|
||||||
|
frame,
|
||||||
|
slot,
|
||||||
|
crc_ind->sfn,
|
||||||
|
crc_ind->slot,
|
||||||
|
pusch_config_pdu->mcs_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!put_queue(&nr_rx_ind_queue, rx_ind)) {
|
||||||
|
LOG_E(NR_MAC, "Put_queue failed for rx_ind\n");
|
||||||
|
for (int i = 0; i < rx_ind->number_of_pdus; i++) {
|
||||||
|
free(rx_ind->pdu_list[i].pdu);
|
||||||
|
rx_ind->pdu_list[i].pdu = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(rx_ind->pdu_list);
|
||||||
|
rx_ind->pdu_list = NULL;
|
||||||
|
free(rx_ind);
|
||||||
|
rx_ind = NULL;
|
||||||
|
}
|
||||||
|
if (!put_queue(&nr_crc_ind_queue, crc_ind)) {
|
||||||
|
LOG_E(NR_MAC, "Put_queue failed for crc_ind\n");
|
||||||
|
free(crc_ind->crc_list);
|
||||||
|
crc_ind->crc_list = NULL;
|
||||||
|
free(crc_ind);
|
||||||
|
crc_ind = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_D(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FAPI_NR_UL_CONFIG_TYPE_PUCCH: {
|
||||||
|
nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind));
|
||||||
|
uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION;
|
||||||
|
uci_ind->sfn = frame;
|
||||||
|
uci_ind->slot = slot;
|
||||||
|
uci_ind->num_ucis = 1;
|
||||||
|
uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list));
|
||||||
|
for (int j = 0; j < uci_ind->num_ucis; j++) {
|
||||||
|
LOG_D(NR_MAC, "pucch_config_pdu.n_bit = %d\n", it->pucch_config_pdu.n_bit);
|
||||||
|
if (it->pucch_config_pdu.n_bit > 3 && mac->nr_ue_emul_l1.num_csi_reports > 0) {
|
||||||
|
uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE;
|
||||||
|
uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_2_3_4_t);
|
||||||
|
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[j].pucch_pdu_format_2_3_4;
|
||||||
|
fill_uci_2_3_4(pdu_2_3_4, &it->pucch_config_pdu);
|
||||||
|
} else {
|
||||||
|
nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1;
|
||||||
|
uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE;
|
||||||
|
uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t);
|
||||||
|
memset(pdu_0_1, 0, sizeof(*pdu_0_1));
|
||||||
|
pdu_0_1->handle = 0;
|
||||||
|
pdu_0_1->rnti = it->pucch_config_pdu.rnti;
|
||||||
|
pdu_0_1->pucch_format = 1;
|
||||||
|
pdu_0_1->ul_cqi = 255;
|
||||||
|
pdu_0_1->timing_advance = 0;
|
||||||
|
pdu_0_1->rssi = 0;
|
||||||
|
if (mac->nr_ue_emul_l1.num_harqs > 0) {
|
||||||
|
int harq_index = 0;
|
||||||
|
pdu_0_1->pduBitmap = 2; // (value->pduBitmap >> 1) & 0x01) == HARQ and (value->pduBitmap) & 0x01) == SR
|
||||||
|
pdu_0_1->harq.num_harq = mac->nr_ue_emul_l1.num_harqs;
|
||||||
|
pdu_0_1->harq.harq_confidence_level = 0;
|
||||||
|
int harq_pid = -1;
|
||||||
|
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) {
|
||||||
|
if (mac->nr_ue_emul_l1.harq[k].active && mac->nr_ue_emul_l1.harq[k].active_dl_harq_sfn == uci_ind->sfn
|
||||||
|
&& mac->nr_ue_emul_l1.harq[k].active_dl_harq_slot == uci_ind->slot) {
|
||||||
|
mac->nr_ue_emul_l1.harq[k].active = false;
|
||||||
|
harq_pid = k;
|
||||||
|
AssertFatal(harq_index < pdu_0_1->harq.num_harq, "Invalid harq_index %d\n", harq_index);
|
||||||
|
pdu_0_1->harq.harq_list[harq_index].harq_value = !mac->dl_harq_info[k].ack;
|
||||||
|
harq_index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AssertFatal(harq_pid != -1, "No active harq_pid, sfn_slot = %u.%u", uci_ind->sfn, uci_ind->slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_D(NR_PHY, "Sending UCI with %d PDUs in sfn.slot %d/%d\n", uci_ind->num_ucis, uci_ind->sfn, uci_ind->slot);
|
||||||
|
NR_UL_IND_t ul_info = {
|
||||||
|
.uci_ind = *uci_ind,
|
||||||
|
};
|
||||||
|
send_nsa_standalone_msg(&ul_info, uci_ind->header.message_id);
|
||||||
|
free_uci_inds(uci_ind);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
LOG_W(NR_MAC, "Unknown ul_config->pdu_type %d\n", it->pdu_type);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
scheduled_response->ul_config->number_pdus = 0;
|
it++;
|
||||||
}
|
}
|
||||||
|
release_ul_config(it, true);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -440,114 +430,52 @@ static void nr_ue_scheduled_response_dl(NR_UE_MAC_INST_t *mac,
|
|||||||
dl_config->number_pdus = 0;
|
dl_config->number_pdus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nr_ue_scheduled_response_ul(PHY_VARS_NR_UE *phy,
|
static void nr_ue_scheduled_response_ul(PHY_VARS_NR_UE *phy, fapi_nr_ul_config_request_t *ul_config, nr_phy_data_tx_t *phy_data)
|
||||||
fapi_nr_ul_config_request_t *ul_config,
|
|
||||||
nr_phy_data_tx_t *phy_data,
|
|
||||||
int module_id,
|
|
||||||
int cc_id)
|
|
||||||
{
|
{
|
||||||
int slot = ul_config->slot;
|
fapi_nr_ul_config_request_pdu_t *pdu = fapiLockIterator(ul_config, ul_config->frame, ul_config->slot);
|
||||||
int pdu_done = 0;
|
if (!pdu) {
|
||||||
pthread_mutex_lock(&ul_config->mutex_ul_config);
|
LOG_E(NR_MAC, "Error in locking ul scheduler dtata\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_D(PHY,
|
while (pdu->pdu_type != FAPI_NR_END) {
|
||||||
"%d.%d ul S ul_config %p pdu_done %d number_pdus %d\n",
|
switch (pdu->pdu_type) {
|
||||||
ul_config->frame,
|
|
||||||
slot,
|
|
||||||
ul_config,
|
|
||||||
pdu_done,
|
|
||||||
ul_config->number_pdus);
|
|
||||||
for (int i = 0; i < ul_config->number_pdus; ++i) {
|
|
||||||
AssertFatal(ul_config->ul_config_list[i].pdu_type <= FAPI_NR_UL_CONFIG_TYPES,
|
|
||||||
"pdu_type %d out of bounds\n",
|
|
||||||
ul_config->ul_config_list[i].pdu_type);
|
|
||||||
LOG_D(PHY,
|
|
||||||
"[%d.%d] i %d: processing %s PDU of %d total UL PDUs (ul_config %p) \n",
|
|
||||||
ul_config->frame,
|
|
||||||
slot,
|
|
||||||
i,
|
|
||||||
ul_pdu_type[ul_config->ul_config_list[i].pdu_type - 1],
|
|
||||||
ul_config->number_pdus,
|
|
||||||
ul_config);
|
|
||||||
|
|
||||||
uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type, current_harq_pid, gNB_id = 0;
|
|
||||||
/* PRACH */
|
|
||||||
fapi_nr_ul_config_prach_pdu *prach_config_pdu;
|
|
||||||
/* PUSCH */
|
|
||||||
nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu;
|
|
||||||
/* PUCCH */
|
|
||||||
fapi_nr_ul_config_pucch_pdu *pucch_config_pdu;
|
|
||||||
LOG_D(PHY,
|
|
||||||
"%d.%d ul B ul_config %p t %d pdu_done %d number_pdus %d\n",
|
|
||||||
ul_config->frame,
|
|
||||||
slot,
|
|
||||||
ul_config,
|
|
||||||
pdu_type,
|
|
||||||
pdu_done,
|
|
||||||
ul_config->number_pdus);
|
|
||||||
/* SRS */
|
|
||||||
fapi_nr_ul_config_srs_pdu *srs_config_pdu;
|
|
||||||
|
|
||||||
switch (pdu_type) {
|
|
||||||
case FAPI_NR_UL_CONFIG_TYPE_PUSCH: {
|
case FAPI_NR_UL_CONFIG_TYPE_PUSCH: {
|
||||||
// pusch config pdu
|
// pusch config pdu
|
||||||
pusch_config_pdu = &ul_config->ul_config_list[i].pusch_config_pdu;
|
int current_harq_pid = pdu->pusch_config_pdu.pusch_data.harq_process_id;
|
||||||
current_harq_pid = pusch_config_pdu->pusch_data.harq_process_id;
|
NR_UL_UE_HARQ_t *harq_process_ul_ue = &phy->ul_harq_processes[current_harq_pid];
|
||||||
NR_UL_UE_HARQ_t *harq_process_ul_ue = &PHY_vars_UE_g[module_id][cc_id]->ul_harq_processes[current_harq_pid];
|
nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &phy_data->ulsch.pusch_pdu;
|
||||||
NR_UE_ULSCH_t *ulsch = &phy_data->ulsch;
|
|
||||||
nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &ulsch->pusch_pdu;
|
|
||||||
|
|
||||||
LOG_D(PHY,
|
LOG_D(PHY,
|
||||||
"In %s i %d: copy pusch_config_pdu nrOfLayers:%d, num_dmrs_cdm_grps_no_data:%d \n",
|
"copy pusch_config_pdu nrOfLayers:%d, num_dmrs_cdm_grps_no_data:%d \n",
|
||||||
__FUNCTION__,
|
pdu->pusch_config_pdu.nrOfLayers,
|
||||||
i,
|
pdu->pusch_config_pdu.num_dmrs_cdm_grps_no_data);
|
||||||
pusch_config_pdu->nrOfLayers,
|
|
||||||
pusch_config_pdu->num_dmrs_cdm_grps_no_data);
|
|
||||||
|
|
||||||
memcpy(pusch_pdu, pusch_config_pdu, sizeof(nfapi_nr_ue_pusch_pdu_t));
|
memcpy(pusch_pdu, &pdu->pusch_config_pdu, sizeof(*pusch_pdu));
|
||||||
if (pusch_config_pdu->tx_request_body.pdu) {
|
if (pdu->pusch_config_pdu.tx_request_body.pdu) {
|
||||||
LOG_D(PHY,
|
LOG_D(PHY,
|
||||||
"%d.%d Copying %d bytes to harq_process_ul_ue->a (harq_pid %d)\n",
|
"%d.%d Copying %d bytes to harq_process_ul_ue->a (harq_pid %d)\n",
|
||||||
ul_config->frame,
|
ul_config->frame,
|
||||||
slot,
|
ul_config->slot,
|
||||||
pusch_config_pdu->tx_request_body.pdu_length,
|
pdu->pusch_config_pdu.tx_request_body.pdu_length,
|
||||||
current_harq_pid);
|
current_harq_pid);
|
||||||
memcpy(harq_process_ul_ue->a, pusch_config_pdu->tx_request_body.pdu, pusch_config_pdu->tx_request_body.pdu_length);
|
memcpy(harq_process_ul_ue->a,
|
||||||
|
pdu->pusch_config_pdu.tx_request_body.pdu,
|
||||||
|
pdu->pusch_config_pdu.tx_request_body.pdu_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
harq_process_ul_ue->status = ACTIVE;
|
harq_process_ul_ue->status = ACTIVE;
|
||||||
ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
pdu->pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
||||||
pdu_done++;
|
|
||||||
LOG_D(PHY,
|
|
||||||
"%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n",
|
|
||||||
ul_config->frame,
|
|
||||||
slot,
|
|
||||||
ul_config,
|
|
||||||
pdu_type,
|
|
||||||
pdu_done,
|
|
||||||
ul_config->number_pdus);
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FAPI_NR_UL_CONFIG_TYPE_PUCCH: {
|
case FAPI_NR_UL_CONFIG_TYPE_PUCCH: {
|
||||||
NR_UE_PUCCH *pucch_vars = &phy_data->pucch_vars;
|
bool found = false;
|
||||||
int found = false;
|
|
||||||
pucch_config_pdu = &ul_config->ul_config_list[i].pucch_config_pdu;
|
|
||||||
for (int j = 0; j < 2; j++) {
|
for (int j = 0; j < 2; j++) {
|
||||||
if (pucch_vars->active[j] == false) {
|
if (phy_data->pucch_vars.active[j] == false) {
|
||||||
LOG_D(PHY, "%d.%d Copying pucch pdu to UE PHY\n", ul_config->frame, slot);
|
LOG_D(PHY, "Copying pucch pdu to UE PHY\n");
|
||||||
memcpy((void *)&(pucch_vars->pucch_pdu[j]), (void *)pucch_config_pdu, sizeof(fapi_nr_ul_config_pucch_pdu));
|
phy_data->pucch_vars.pucch_pdu[j] = pdu->pucch_config_pdu;
|
||||||
pucch_vars->active[j] = true;
|
phy_data->pucch_vars.active[j] = true;
|
||||||
found = true;
|
found = true;
|
||||||
ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
pdu->pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
||||||
pdu_done++;
|
|
||||||
LOG_D(PHY,
|
|
||||||
"%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n",
|
|
||||||
ul_config->frame,
|
|
||||||
slot,
|
|
||||||
ul_config,
|
|
||||||
pdu_type,
|
|
||||||
pdu_done,
|
|
||||||
ul_config->number_pdus);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,72 +483,31 @@ static void nr_ue_scheduled_response_ul(PHY_VARS_NR_UE *phy,
|
|||||||
LOG_E(PHY, "Couldn't find allocation for PUCCH PDU in PUCCH VARS\n");
|
LOG_E(PHY, "Couldn't find allocation for PUCCH PDU in PUCCH VARS\n");
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FAPI_NR_UL_CONFIG_TYPE_PRACH:
|
case FAPI_NR_UL_CONFIG_TYPE_PRACH: {
|
||||||
// prach config pdu
|
phy->prach_vars[0]->prach_pdu = pdu->prach_config_pdu;
|
||||||
prach_config_pdu = &ul_config->ul_config_list[i].prach_config_pdu;
|
phy->prach_vars[0]->active = true;
|
||||||
memcpy((void *)&(PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->prach_pdu),
|
pdu->pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
||||||
(void *)prach_config_pdu,
|
} break;
|
||||||
sizeof(fapi_nr_ul_config_prach_pdu));
|
|
||||||
PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->active = true;
|
|
||||||
ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
|
||||||
pdu_done++;
|
|
||||||
LOG_D(PHY,
|
|
||||||
"%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n",
|
|
||||||
ul_config->frame,
|
|
||||||
slot,
|
|
||||||
ul_config,
|
|
||||||
pdu_type,
|
|
||||||
pdu_done,
|
|
||||||
ul_config->number_pdus);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FAPI_NR_UL_CONFIG_TYPE_DONE:
|
case FAPI_NR_UL_CONFIG_TYPE_DONE:
|
||||||
pdu_done++; // count the no of pdu processed
|
|
||||||
LOG_D(PHY,
|
|
||||||
"%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n",
|
|
||||||
ul_config->frame,
|
|
||||||
slot,
|
|
||||||
ul_config,
|
|
||||||
pdu_type,
|
|
||||||
pdu_done,
|
|
||||||
ul_config->number_pdus);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FAPI_NR_UL_CONFIG_TYPE_SRS:
|
case FAPI_NR_UL_CONFIG_TYPE_SRS:
|
||||||
// srs config pdu
|
// srs config pdu
|
||||||
srs_config_pdu = &ul_config->ul_config_list[i].srs_config_pdu;
|
phy->srs_vars[0]->srs_config_pdu = pdu->srs_config_pdu;
|
||||||
memcpy((void *)&(PHY_vars_UE_g[module_id][cc_id]->srs_vars[gNB_id]->srs_config_pdu),
|
phy->srs_vars[0]->active = true;
|
||||||
(void *)srs_config_pdu,
|
pdu->pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
||||||
sizeof(fapi_nr_ul_config_srs_pdu));
|
|
||||||
PHY_vars_UE_g[module_id][cc_id]->srs_vars[gNB_id]->active = true;
|
|
||||||
ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
|
||||||
pdu_done++;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
|
LOG_W(PHY, "unhandled ul pdu type %d \n", pdu->pdu_type);
|
||||||
pdu_done++; // count the no of pdu processed
|
|
||||||
LOG_D(PHY,
|
|
||||||
"%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n",
|
|
||||||
ul_config->frame,
|
|
||||||
slot,
|
|
||||||
ul_config,
|
|
||||||
pdu_type,
|
|
||||||
pdu_done,
|
|
||||||
ul_config->number_pdus);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pdu++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the fields when all the config pdu are done
|
LOG_D(PHY, "clear ul_config\n");
|
||||||
if (pdu_done == ul_config->number_pdus) {
|
release_ul_config(pdu, true);
|
||||||
ul_config->frame = 0;
|
|
||||||
ul_config->slot = 0;
|
|
||||||
ul_config->number_pdus = 0;
|
|
||||||
LOG_D(PHY, "%d.%d clear ul_config %p\n", ul_config->frame, slot, ul_config);
|
|
||||||
memset(ul_config->ul_config_list, 0, sizeof(ul_config->ul_config_list));
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&ul_config->mutex_ul_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response)
|
int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response)
|
||||||
@@ -635,11 +522,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response)
|
|||||||
scheduled_response->dl_config,
|
scheduled_response->dl_config,
|
||||||
(nr_phy_data_t *)scheduled_response->phy_data);
|
(nr_phy_data_t *)scheduled_response->phy_data);
|
||||||
if (scheduled_response->ul_config)
|
if (scheduled_response->ul_config)
|
||||||
nr_ue_scheduled_response_ul(phy,
|
nr_ue_scheduled_response_ul(phy, scheduled_response->ul_config, (nr_phy_data_tx_t *)scheduled_response->phy_data);
|
||||||
scheduled_response->ul_config,
|
|
||||||
(nr_phy_data_tx_t *)scheduled_response->phy_data,
|
|
||||||
scheduled_response->module_id,
|
|
||||||
scheduled_response->CC_id);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -483,10 +483,13 @@ void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac);
|
|||||||
|
|
||||||
void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs);
|
void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs);
|
||||||
|
|
||||||
fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot, int fb_time);
|
|
||||||
fapi_nr_dl_config_request_t *get_dl_config_request(NR_UE_MAC_INST_t *mac, int slot);
|
fapi_nr_dl_config_request_t *get_dl_config_request(NR_UE_MAC_INST_t *mac, int slot);
|
||||||
|
|
||||||
void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx, uint8_t pdu_type);
|
fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx, uint8_t pdu_type);
|
||||||
|
void remove_ul_config_last_item(fapi_nr_ul_config_request_pdu_t *pdu);
|
||||||
|
fapi_nr_ul_config_request_pdu_t *fapiLockIterator(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx);
|
||||||
|
|
||||||
|
void release_ul_config(fapi_nr_ul_config_request_pdu_t *pdu, bool clearIt);
|
||||||
|
|
||||||
int16_t compute_nr_SSB_PL(NR_UE_MAC_INST_t *mac, short ssb_rsrp_dBm);
|
int16_t compute_nr_SSB_PL(NR_UE_MAC_INST_t *mac, short ssb_rsrp_dBm);
|
||||||
|
|
||||||
|
|||||||
@@ -949,19 +949,12 @@ void prepare_msg4_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack)
|
|||||||
NR_UE_HARQ_STATUS_t *current_harq = &mac->dl_harq_info[pid];
|
NR_UE_HARQ_STATUS_t *current_harq = &mac->dl_harq_info[pid];
|
||||||
int sched_slot = current_harq->ul_slot;
|
int sched_slot = current_harq->ul_slot;
|
||||||
int sched_frame = current_harq->ul_frame;
|
int sched_frame = current_harq->ul_frame;
|
||||||
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, sched_slot, 0);
|
|
||||||
pthread_mutex_lock(&ul_config->mutex_ul_config);
|
|
||||||
mac->nr_ue_emul_l1.num_harqs = 1;
|
mac->nr_ue_emul_l1.num_harqs = 1;
|
||||||
AssertFatal(ul_config->number_pdus < FAPI_NR_UL_CONFIG_LIST_NUM,
|
PUCCH_sched_t pucch = {.n_CCE = current_harq->n_CCE,
|
||||||
"ul_config->number_pdus %d out of bounds\n",
|
.N_CCE = current_harq->N_CCE,
|
||||||
ul_config->number_pdus);
|
.delta_pucch = current_harq->delta_pucch,
|
||||||
fapi_nr_ul_config_pucch_pdu *pucch_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu;
|
.ack_payload = ack_nack,
|
||||||
PUCCH_sched_t pucch = {0};
|
.n_harq = 1};
|
||||||
pucch.n_CCE = current_harq->n_CCE;
|
|
||||||
pucch.N_CCE = current_harq->N_CCE;
|
|
||||||
pucch.delta_pucch = current_harq->delta_pucch;
|
|
||||||
pucch.ack_payload = ack_nack;
|
|
||||||
pucch.n_harq = 1;
|
|
||||||
current_harq->active = false;
|
current_harq->active = false;
|
||||||
current_harq->ack_received = false;
|
current_harq->ack_received = false;
|
||||||
if (get_softmodem_params()->emulate_l1) {
|
if (get_softmodem_params()->emulate_l1) {
|
||||||
@@ -969,11 +962,11 @@ void prepare_msg4_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack)
|
|||||||
mac->nr_ue_emul_l1.harq[pid].active_dl_harq_sfn = sched_frame;
|
mac->nr_ue_emul_l1.harq[pid].active_dl_harq_sfn = sched_frame;
|
||||||
mac->nr_ue_emul_l1.harq[pid].active_dl_harq_slot = sched_slot;
|
mac->nr_ue_emul_l1.harq[pid].active_dl_harq_slot = sched_slot;
|
||||||
}
|
}
|
||||||
nr_ue_configure_pucch(mac,
|
fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, sched_frame, sched_slot, FAPI_NR_UL_CONFIG_TYPE_PUCCH);
|
||||||
sched_slot,
|
if (!pdu)
|
||||||
mac->ra.t_crnti,
|
return;
|
||||||
&pucch,
|
int ret = nr_ue_configure_pucch(mac, sched_slot, mac->ra.t_crnti, &pucch, &pdu->pucch_config_pdu);
|
||||||
pucch_pdu);
|
if (ret != 0)
|
||||||
fill_ul_config(ul_config, sched_frame, sched_slot, FAPI_NR_UL_CONFIG_TYPE_PUCCH);
|
remove_ul_config_last_item(pdu);
|
||||||
pthread_mutex_unlock(&ul_config->mutex_ul_config);
|
release_ul_config(pdu, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,25 +408,15 @@ static int nr_ue_process_dci_ul_00(module_id_t module_id,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get UL config request corresponding slot_tx
|
fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
|
||||||
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx, tda_info.k2);
|
if (!pdu)
|
||||||
|
|
||||||
if (!ul_config) {
|
|
||||||
LOG_W(MAC, "ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n", frame, slot);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_lock(&ul_config->mutex_ul_config);
|
int ret = nr_config_pusch_pdu(mac, &tda_info, &pdu->pusch_config_pdu, dci, NULL, dci_ind->rnti, NR_UL_DCI_FORMAT_0_0);
|
||||||
AssertFatal(ul_config->number_pdus < FAPI_NR_UL_CONFIG_LIST_NUM,
|
if (ret != 0)
|
||||||
"ul_config->number_pdus %d out of bounds\n",
|
remove_ul_config_last_item(pdu);
|
||||||
ul_config->number_pdus);
|
release_ul_config(pdu, false);
|
||||||
nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu;
|
return ret;
|
||||||
|
|
||||||
fill_ul_config(ul_config, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
|
|
||||||
pthread_mutex_unlock(&ul_config->mutex_ul_config);
|
|
||||||
|
|
||||||
// Config PUSCH PDU
|
|
||||||
return nr_config_pusch_pdu(mac, &tda_info, pusch_config_pdu, dci, NULL, dci_ind->rnti, NR_UL_DCI_FORMAT_0_0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nr_ue_process_dci_ul_01(module_id_t module_id,
|
static int nr_ue_process_dci_ul_01(module_id_t module_id,
|
||||||
@@ -493,26 +483,14 @@ static int nr_ue_process_dci_ul_01(module_id_t module_id,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get UL config request corresponding slot_tx
|
fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
|
||||||
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx, tda_info.k2);
|
if (!pdu)
|
||||||
|
|
||||||
if (!ul_config) {
|
|
||||||
LOG_W(MAC, "ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n", frame, slot);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
int ret = nr_config_pusch_pdu(mac, &tda_info, &pdu->pusch_config_pdu, dci, NULL, dci_ind->rnti, NR_UL_DCI_FORMAT_0_1);
|
||||||
ul_config->number_pdus = 0;
|
if (ret != 0)
|
||||||
|
remove_ul_config_last_item(pdu);
|
||||||
pthread_mutex_lock(&ul_config->mutex_ul_config);
|
release_ul_config(pdu, false);
|
||||||
AssertFatal(ul_config->number_pdus < FAPI_NR_UL_CONFIG_LIST_NUM,
|
return ret;
|
||||||
"ul_config->number_pdus %d out of bounds\n",
|
|
||||||
ul_config->number_pdus);
|
|
||||||
nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu;
|
|
||||||
|
|
||||||
fill_ul_config(ul_config, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
|
|
||||||
pthread_mutex_unlock(&ul_config->mutex_ul_config);
|
|
||||||
|
|
||||||
// Config PUSCH PDU
|
|
||||||
return nr_config_pusch_pdu(mac, &tda_info, pusch_config_pdu, dci, NULL, dci_ind->rnti, NR_UL_DCI_FORMAT_0_1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nr_ue_process_dci_dl_10(module_id_t module_id,
|
static int nr_ue_process_dci_dl_10(module_id_t module_id,
|
||||||
@@ -4156,32 +4134,21 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
|
|||||||
ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2);
|
ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2);
|
||||||
|
|
||||||
if (ret != -1) {
|
if (ret != -1) {
|
||||||
|
|
||||||
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx, tda_info.k2);
|
|
||||||
uint16_t rnti = mac->crnti;
|
uint16_t rnti = mac->crnti;
|
||||||
|
|
||||||
if (!ul_config) {
|
|
||||||
LOG_W(MAC, "In %s: ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n", __FUNCTION__, frame, slot);
|
|
||||||
}
|
|
||||||
AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]),
|
|
||||||
"Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus);
|
|
||||||
|
|
||||||
// Upon successful reception, set the T-CRNTI to the RAR value if the RA preamble is selected among the contention-based RA Preambles
|
// Upon successful reception, set the T-CRNTI to the RAR value if the RA preamble is selected among the contention-based RA Preambles
|
||||||
if (!ra->cfra) {
|
if (!ra->cfra) {
|
||||||
ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
|
ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
|
||||||
rnti = ra->t_crnti;
|
rnti = ra->t_crnti;
|
||||||
send_msg3_rrc_request(mod_id, rnti);
|
send_msg3_rrc_request(mod_id, rnti);
|
||||||
}
|
}
|
||||||
|
fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
|
||||||
pthread_mutex_lock(&ul_config->mutex_ul_config);
|
if (!pdu)
|
||||||
AssertFatal(ul_config->number_pdus<FAPI_NR_UL_CONFIG_LIST_NUM, "ul_config->number_pdus %d out of bounds\n",ul_config->number_pdus);
|
return;
|
||||||
nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu;
|
|
||||||
|
|
||||||
fill_ul_config(ul_config, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
|
|
||||||
pthread_mutex_unlock(&ul_config->mutex_ul_config);
|
|
||||||
|
|
||||||
// Config Msg3 PDU
|
// Config Msg3 PDU
|
||||||
nr_config_pusch_pdu(mac, &tda_info, pusch_config_pdu, NULL, &rar_grant, rnti, NR_DCI_NONE);
|
int ret = nr_config_pusch_pdu(mac, &tda_info, &pdu->pusch_config_pdu, NULL, &rar_grant, rnti, NR_DCI_NONE);
|
||||||
|
if (ret != 0)
|
||||||
|
remove_ul_config_last_item(pdu);
|
||||||
|
release_ul_config(pdu, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user