Fix Msg4 for mac subheader long, RB calculation improvement, and fix variable types to support bigger payload lengths

This commit is contained in:
luis_pereira87
2022-01-13 11:16:11 +00:00
parent b15f1f1830
commit c1f6dbfb2f
5 changed files with 53 additions and 31 deletions
+1 -1
View File
@@ -58,7 +58,7 @@
// Some constants from "LAYER2/MAC/defs.h"
#define BCCH_SDU_SIZE (512)
#define BCCH_SDU_MBMS_SIZE (512)
#define CCCH_SDU_SIZE (512)
#define CCCH_SDU_SIZE (1024)
#define MCCH_SDU_SIZE (512)
#define PCCH_SDU_SIZE (512)
+35 -13
View File
@@ -1518,13 +1518,26 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
} else {
uint16_t mac_pdu_length = nr_write_ce_dlsch_pdu(module_idP, nr_mac->sched_ctrlCommon, buf, 255, ra->cont_res_id);
LOG_D(NR_MAC,"Encoded contention resolution mac_pdu_length %d\n",mac_pdu_length);
uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, &buf[mac_pdu_length+2]);
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->R = 0;
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->F = 0;
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH;
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->L = mac_sdu_length;
ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_SHORT);
LOG_D(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", mac_sdu_length, (int)sizeof(NR_MAC_SUBHEADER_SHORT), ra->mac_pdu_length);
uint8_t buffer[CCCH_SDU_SIZE];
uint8_t mac_subheader_len = sizeof(NR_MAC_SUBHEADER_SHORT);
uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, buffer);
if (mac_sdu_length < 256) {
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->R = 0;
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->F = 0;
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH;
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->L = mac_sdu_length;
ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_SHORT);
} else {
mac_subheader_len = sizeof(NR_MAC_SUBHEADER_LONG);
((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->R = 0;
((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->F = 1;
((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH;
((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->L1 = (mac_sdu_length >> 8) & 0xff;
((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->L2 = mac_sdu_length & 0xff;
ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_LONG);
}
LOG_I(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", mac_sdu_length, mac_subheader_len, ra->mac_pdu_length);
memcpy(&buf[mac_pdu_length + mac_subheader_len], buffer, mac_sdu_length);
}
}
@@ -1581,13 +1594,22 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
int rbSize = 0;
uint8_t tb_scaling = 0;
uint16_t *vrb_map = cc[CC_id].vrb_map;
do {
rbSize++;
LOG_D(NR_MAC,"Calling nr_compute_tbs with N_PRB_DMRS %d, N_DMRS_SLOT %d\n",N_PRB_DMRS,N_DMRS_SLOT);
harq->tb_size = nr_compute_tbs(nr_get_Qm_dl(mcsIndex, mcsTableIdx),
nr_get_code_rate_dl(mcsIndex, mcsTableIdx),
rbSize, nrOfSymbols, N_PRB_DMRS * N_DMRS_SLOT, 0, tb_scaling,1) >> 3;
} while (rbSize < BWPSize && harq->tb_size < ra->mac_pdu_length);
do {
rbSize++;
LOG_D(NR_MAC,"Calling nr_compute_tbs with N_PRB_DMRS %d, N_DMRS_SLOT %d\n",N_PRB_DMRS,N_DMRS_SLOT);
harq->tb_size = nr_compute_tbs(nr_get_Qm_dl(mcsIndex, mcsTableIdx),
nr_get_code_rate_dl(mcsIndex, mcsTableIdx),
rbSize, nrOfSymbols, N_PRB_DMRS * N_DMRS_SLOT, 0, tb_scaling,1) >> 3;
} while (rbSize < BWPSize && harq->tb_size < ra->mac_pdu_length);
if(harq->tb_size < ra->mac_pdu_length) {
rbSize = 0;
mcsIndex++;
}
} while(rbSize < BWPSize && harq->tb_size < ra->mac_pdu_length && mcsIndex<=28);
AssertFatal(harq->tb_size >= ra->mac_pdu_length,"Cannot allocate Msg4\n");
int i = 0;
while ((i < rbSize) && (rbStart + rbSize <= BWPSize)) {
+9 -9
View File
@@ -218,13 +218,13 @@ nr_rrc_data_req(
return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
}
int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const rb_id_t Srb_id,
const rnti_t rnti,
const uint8_t Nb_tb,
uint8_t *const buffer_pP ){
uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const rb_id_t Srb_id,
const rnti_t rnti,
const uint8_t Nb_tb,
uint8_t *const buffer_pP ){
#ifdef DEBUG_RRC
LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%ld\n",Mod_idP,Srb_id);
@@ -280,13 +280,13 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
if( (Srb_id & RAB_OFFSET ) == CCCH) {
char *payload_pP;
uint8_t Sdu_size = 0;
uint16_t Sdu_size = 0;
struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_idP], rnti);
LOG_D(NR_RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id);
AssertFatal(ue_context_p!=NULL,"failed to get ue_context, rnti %x\n",rnti);
char payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size;
uint16_t payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size;
// check if data is there for MAC
if (payload_size > 0) {
+1 -1
View File
@@ -213,7 +213,7 @@ typedef struct HANDOVER_INFO_NR_s {
typedef struct {
char Payload[NR_RRC_BUFFER_SIZE_MAX];
char Header[NR_RRC_HEADER_SIZE_MAX];
char payload_size;
uint16_t payload_size;
} NR_RRC_BUFFER;
#define NR_RRC_BUFFER_SIZE sizeof(RRC_BUFFER_NR)
+7 -7
View File
@@ -47,13 +47,13 @@ void rrc_config_nr_buffer(NR_SRB_INFO* Srb_info,
uint8_t Lchan_type,
uint8_t Role);
int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const rb_id_t Srb_id,
const rnti_t rnti,
const uint8_t Nb_tb,
uint8_t *const buffer_pP );
uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const rb_id_t Srb_id,
const rnti_t rnti,
const uint8_t Nb_tb,
uint8_t *const buffer_pP);
void rrc_gNB_process_SgNBAdditionRequest(
const protocol_ctxt_t *const ctxt_pP,