Commit ff3050a2 authored by Fang-WANG's avatar Fang-WANG

Merge branch 'sa-msg4-rrc-yihz' into sa-msg4-rrc

parents ee9eb843 5f199877
...@@ -310,6 +310,21 @@ void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, ...@@ -310,6 +310,21 @@ void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
void build_ssb_to_ro_map(NR_ServingCellConfigCommon_t *scc, uint8_t unpaired); void build_ssb_to_ro_map(NR_ServingCellConfigCommon_t *scc, uint8_t unpaired);
/**\brief
\param module_id module id
\param CC_id component carrier id
\param frame_t frameP
\param rb_id_t SRB id
\param buffer_pP pointer to buffer*/
int8_t mac_rrc_nr_data_req_ue(
const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const rb_id_t Srb_id,
const uint8_t Nb_tb,
uint8_t *const buffer_pP,
const uint8_t gNB_index,
const uint8_t mbsfn_sync_area);
#endif #endif
/** @}*/ /** @}*/
...@@ -962,7 +962,7 @@ int8_t nr_ue_decode_mib(module_id_t module_id, ...@@ -962,7 +962,7 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
nr_mac_rrc_data_ind_ue( module_id, cc_id, gNB_index, NR_BCCH_BCH, (uint8_t *) pduP, 3 ); // fixed 3 bytes MIB PDU nr_mac_rrc_data_ind_ue( module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3 ); // fixed 3 bytes MIB PDU
AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n"); AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n");
//if(mac->mib != NULL){ //if(mac->mib != NULL){
...@@ -1671,32 +1671,79 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in ...@@ -1671,32 +1671,79 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
fapi_nr_ul_config_request_pdu_t *ul_config_list = &ul_config->ul_config_list[ul_config->number_pdus]; fapi_nr_ul_config_request_pdu_t *ul_config_list = &ul_config->ul_config_list[ul_config->number_pdus];
uint16_t TBS_bytes = ul_config_list->pusch_config_pdu.pusch_data.tb_size; uint16_t TBS_bytes = ul_config_list->pusch_config_pdu.pusch_data.tb_size;
//if (IS_SOFTMODEM_NOS1){ uint16_t size_sdu = 0;
// // Getting IP traffic to be transmitted int CC_id;
// data_existing = nr_ue_get_sdu(mod_id, uint8_t mac_sdus[MAX_NR_ULSCH_PAYLOAD_BYTES];
// cc_id, uint8_t sdu_lcids[NB_RB_MAX] = {0};
// frame_tx, uint16_t sdu_lengths[NB_RB_MAX] = {0};
// slot_tx, uint8_t lcid = UL_SCH_LCID_CCCH;
// 0, // uint8_t *payload;
// ulsch_input_buffer, // payload = (uint8_t*) &mac->CCCH_pdu.payload;
// TBS_bytes, // int TBS_bytes_new = 848;
// &access_mode); int mac_ce_len = 0;
//} int header_length_total = 0;
int num_sdus = 1;
//Random traffic to be transmitted if there is no IP traffic available for this Tx opportunity unsigned short post_padding = 1;
//if (!IS_SOFTMODEM_NOS1 || !data_existing) { int offset;
//Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid
//and block this traffic from being forwarded to the upper layers at the gNB // //if (IS_SOFTMODEM_NOS1){
LOG_D(MAC, "Random data to be tranmsitted (TBS_bytes %d): \n", TBS_bytes); // // // Getting IP traffic to be transmitted
//Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) // // data_existing = nr_ue_get_sdu(mod_id,
//in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should // // cc_id,
//have a valid LCID (nr_process_mac_pdu function) // // frame_tx,
ulsch_input_buffer[0] = 0x31; // // slot_tx,
for (int i = 1; i < TBS_bytes; i++) { // // 0,
ulsch_input_buffer[i] = (unsigned char) rand(); // // ulsch_input_buffer,
//printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); // // TBS_bytes,
} // // &access_mode);
//} // //}
// //Random traffic to be transmitted if there is no IP traffic available for this Tx opportunity
// //if (!IS_SOFTMODEM_NOS1 || !data_existing) {
// //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid
// //and block this traffic from being forwarded to the upper layers at the gNB
// LOG_D(MAC, "Random data to be tranmsitted (TBS_bytes %d): \n", TBS_bytes);
// //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2)
// //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should
// //have a valid LCID (nr_process_mac_pdu function)
// ulsch_input_buffer[0] = 0x31;
// for (int i = 1; i < TBS_bytes; i++) {
// ulsch_input_buffer[i] = (unsigned char) rand();
// //printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
// }
// //}
size_sdu = (uint16_t) mac_rrc_nr_data_req_ue(ul_info->module_id,
ul_info->cc_id,
ul_info->frame_rx,
CCCH,
1,
mac_sdus,
ul_info->gNB_index,
0);
sdu_lcids[0] = lcid;
sdu_lengths[0] = TBS_bytes - 3 - post_padding - mac_ce_len;
header_length_total += 2 + (sdu_lengths[0] >= 128);
size_sdu += sdu_lengths[0];
offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer
(uint8_t *) ulsch_input_buffer, // UL MAC pdu pointer
num_sdus, // num sdus
sdu_lengths, // sdu length
sdu_lcids, // sdu lcid
0, // power headroom
0, // crnti
0, // truncated bsr
0, // short bsr
0, // long_bsr
post_padding,
0);
// Padding: fill remainder with 0
if (post_padding > 0){
for (int j = 0; j < (TBS_bytes - offset); j++)
ulsch_input_buffer[offset + j] = 0; // mac_pdu[offset + j] = 0;
}
LOG_D(MAC, "[UE %d] Frame %d, Subframe %d Adding Msg3 UL Config Request for rnti: %x\n", LOG_D(MAC, "[UE %d] Frame %d, Subframe %d Adding Msg3 UL Config Request for rnti: %x\n",
ul_info->module_id, ul_info->module_id,
...@@ -4879,10 +4926,13 @@ void nr_ue_process_mac_pdu(module_id_t module_idP, ...@@ -4879,10 +4926,13 @@ void nr_ue_process_mac_pdu(module_id_t module_idP,
| ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pdu_ptr)->L2 & 0xff); | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pdu_ptr)->L2 & 0xff);
mac_subheader_len = 3; mac_subheader_len = 3;
} }
else{ else
mac_sdu_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L; {
mac_subheader_len = 2; mac_sdu_len = ((NR_MAC_SUBHEADER_LONG *) pdu_ptr)->L1;
mac_subheader_len = 2;
} }
nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pdu_ptr+mac_subheader_len, mac_sdu_len);
break; break;
...@@ -4995,7 +5045,7 @@ void nr_ue_process_mac_pdu(module_id_t module_idP, ...@@ -4995,7 +5045,7 @@ void nr_ue_process_mac_pdu(module_id_t module_idP,
// WIP todo: handle CCCH_pdu // WIP todo: handle CCCH_pdu
mac_ce_len = 6; mac_ce_len = 6;
LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", module_idP, frameP, pdu_ptr[0], pdu_ptr[1], pdu_ptr[2], pdu_ptr[3], pdu_ptr[4], pdu_ptr[5]); LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", module_idP, frameP, pdu_ptr[1], pdu_ptr[2], pdu_ptr[3], pdu_ptr[4], pdu_ptr[5], pdu_ptr[6]);
if (mac->RA_active == 1) { if (mac->RA_active == 1) {
LOG_I(MAC, "[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n", module_idP, frameP); LOG_I(MAC, "[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n", module_idP, frameP);
...@@ -5059,7 +5109,7 @@ void nr_ue_process_mac_pdu(module_id_t module_idP, ...@@ -5059,7 +5109,7 @@ void nr_ue_process_mac_pdu(module_id_t module_idP,
#endif #endif
if (IS_SOFTMODEM_NOS1){ if (IS_SOFTMODEM_NOS1){
if (rx_lcid < NB_RB_MAX && rx_lcid >= DL_SCH_LCID_CCCH) { if (rx_lcid < NB_RB_MAX && rx_lcid >= DL_SCH_LCID_DCCH) {
mac_rlc_data_ind(module_idP, mac_rlc_data_ind(module_idP,
mac->crnti, mac->crnti,
...@@ -5139,7 +5189,10 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload, ...@@ -5139,7 +5189,10 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
} }
} else { // UL CCCH SDU } else { // UL CCCH SDU
mac_pdu_ptr->R = 0; mac_pdu_ptr->R = 0;
((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->F = 0;
mac_pdu_ptr->LCID = sdu_lcids[i]; mac_pdu_ptr->LCID = sdu_lcids[i];
((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->L = (unsigned char) sdu_lengths[i];
last_size = 2;
} }
mac_pdu_ptr += last_size; mac_pdu_ptr += last_size;
......
...@@ -1137,6 +1137,7 @@ nr_generate_Msg4(module_id_t module_id, ...@@ -1137,6 +1137,7 @@ nr_generate_Msg4(module_id_t module_id,
/* reserve space for timing advance of UE if necessary, /* reserve space for timing advance of UE if necessary,
* nr_generate_dlsch_pdu() checks for ta_apply and add TA CE if necessary */ * nr_generate_dlsch_pdu() checks for ta_apply and add TA CE if necessary */
const int cont_res_len = 1 + 6; const int cont_res_len = 1 + 6;
const int ta_len = (sched_ctrl->ta_apply) ? 2 : 0;
/* Get RLC data TODO: remove random data retrieval */ /* Get RLC data TODO: remove random data retrieval */
int header_length_total = 0; int header_length_total = 0;
...@@ -1148,11 +1149,21 @@ nr_generate_Msg4(module_id_t module_id, ...@@ -1148,11 +1149,21 @@ nr_generate_Msg4(module_id_t module_id,
unsigned char sdu_lcids[NB_RB_MAX] = {0}; unsigned char sdu_lcids[NB_RB_MAX] = {0};
const int lcid = DL_SCH_LCID_CCCH; const int lcid = DL_SCH_LCID_CCCH;
if (sched_ctrl->num_total_bytes > 0) { if (sched_ctrl->num_total_bytes > 0) {
#if 0 LOG_I(MAC,
sdu_lengths[num_sdus] = mac_rrc_data_req(module_id, CC_idP, frameP, CCCH, "[gNB %d][MSG4] Frame %d : CCCH->DLSCH, Requesting "
UE_RNTI(module_idP,UE_id),1, // 1 transport block "%d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n",
&cc[CC_idP].CCCH_pdu.payload[0], 1); module_id,
frame,
TBS - ta_len - header_length_total - sdu_length_total - 3,
lcid,
header_length_total,
TBS);
#if 1
// sdu_lengths[num_sdus] = mac_rrc_data_req(module_id, CC_idP, frameP, CCCH,
// UE_RNTI(module_idP,UE_id),1, // 1 transport block
// &cc[CC_idP].CCCH_pdu.payload[0], 1);
sdu_lengths[num_sdus] = mac_rrc_nr_data_req(module_id, CC_id, frame, CCCH, ra->rnti, 1, // 1 transport block
mac_sdus);
LOG_D(MAC, LOG_D(MAC,
"[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n",
......
...@@ -114,7 +114,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, ...@@ -114,7 +114,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP,
dl_tti_request = &gNB->DL_req[CC_id]; dl_tti_request = &gNB->DL_req[CC_id];
dl_req = &dl_tti_request->dl_tti_request_body; dl_req = &dl_tti_request->dl_tti_request_body;
mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]); mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 0, 1, &cc->MIB_pdu.payload[0]);
LOG_D(MAC, "Frame %d, slot %d: BCH PDU length %d\n", frameP, slotP, mib_sdu_length); LOG_D(MAC, "Frame %d, slot %d: BCH PDU length %d\n", frameP, slotP, mib_sdu_length);
......
...@@ -191,6 +191,17 @@ void nr_process_mac_pdu( ...@@ -191,6 +191,17 @@ void nr_process_mac_pdu(
case UL_SCH_LCID_CCCH: case UL_SCH_LCID_CCCH:
// todo // todo
mac_subheader_len = 2; mac_subheader_len = 2;
nr_mac_rrc_data_ind(module_idP,
CC_id,
frameP, 0,
0,
rnti,
CCCH,
pdu_ptr+2,
pdu_len-2,
0,0
);
break; break;
// MAC SDUs // MAC SDUs
...@@ -208,7 +219,7 @@ void nr_process_mac_pdu( ...@@ -208,7 +219,7 @@ void nr_process_mac_pdu(
mac_subheader_len = 2; mac_subheader_len = 2;
} }
LOG_I(MAC, "[UE %d] Frame %d : ULSCH -> UL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len); LOG_I(MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len);
int UE_id = find_nr_UE_id(module_idP, rnti); int UE_id = find_nr_UE_id(module_idP, rnti);
RC.nrmac[module_idP]->UE_info.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len; RC.nrmac[module_idP]->UE_info.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len;
#if defined(ENABLE_MAC_PAYLOAD_DEBUG) #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
...@@ -419,22 +430,19 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ...@@ -419,22 +430,19 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
// re-initialize ta update variables afrer RA procedure completion // re-initialize ta update variables afrer RA procedure completion
UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP;
if (isActive) // NSA mode nr_process_mac_pdu(gnb_mod_idP, current_rnti, CC_idP, frameP, sduP, sdu_lenP);
{
free(ra->preambles.preamble_list); free(ra->preambles.preamble_list);
ra->state = RA_IDLE; //ra->state = RA_IDLE;
LOG_I(MAC, // LOG_I(MAC,
"reset RA state information for RA-RNTI %04x/index %d\n", // "reset RA state information for RA-RNTI %04x/index %d\n",
ra->rnti, // ra->rnti,
i); // i);
} //ra->state = RA_IDLE;
else // SA mode ra->state = Msg4;
{ ra->Msg4_frame = ( frameP +2 ) % 1024;
ra->state = Msg4; ra->Msg4_slot = 1;
ra->Msg4_frame = ( frameP +2 ) % 1024; LOG_I(MAC, "set RA state to Msg4 for RA-RNTI %04x, msg4 frame %d %d\n", ra->rnti, ra->Msg4_frame, ra->Msg4_slot);
ra->Msg4_slot = 1;
LOG_I(MAC, "set RA state to Msg4 for RA-RNTI %04x, msg4 frame %d %d\n", ra->rnti, ra->Msg4_frame, ra->Msg4_slot);
}
return; return;
} }
} }
......
...@@ -520,7 +520,6 @@ static void deliver_sdu_drb(protocol_ctxt_t *ctxt_pP,void *_ue, nr_pdcp_entity_t ...@@ -520,7 +520,6 @@ static void deliver_sdu_drb(protocol_ctxt_t *ctxt_pP,void *_ue, nr_pdcp_entity_t
} }
#else #else
printf("----------------%d send data to tun -----------------\n",ctxt_pP->enb_flag);
len = write(nas_sock_fd[0], buf, size); len = write(nas_sock_fd[0], buf, size);
if (len != size) { if (len != size) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
...@@ -600,7 +599,6 @@ rb_found: ...@@ -600,7 +599,6 @@ rb_found:
enqueue_rlc_data_req(&ctxt, 0, MBMS_FLAG_NO, rb_id, sdu_id, 0, size, memblock, NULL, NULL); enqueue_rlc_data_req(&ctxt, 0, MBMS_FLAG_NO, rb_id, sdu_id, 0, size, memblock, NULL, NULL);
} }
static int ccch_or_dcch = 0;
static void deliver_sdu_srb(protocol_ctxt_t *ctxt_pP, void *_ue, nr_pdcp_entity_t *entity, static void deliver_sdu_srb(protocol_ctxt_t *ctxt_pP, void *_ue, nr_pdcp_entity_t *entity,
char *buf, int size) char *buf, int size)
{ {
...@@ -611,18 +609,21 @@ static void deliver_sdu_srb(protocol_ctxt_t *ctxt_pP, void *_ue, nr_pdcp_entity_ ...@@ -611,18 +609,21 @@ static void deliver_sdu_srb(protocol_ctxt_t *ctxt_pP, void *_ue, nr_pdcp_entity_
uint8_t *gtpu_buffer_p; uint8_t *gtpu_buffer_p;
int srb_id; int srb_id;
int i; int i;
if (ccch_or_dcch == 0) for (i = 0; i < 2; i++) {
{ if (entity == ue->srb[i]) {
nr_rrc_data_ind_ccch( ctxt_pP, 1, size, buf); srb_id = i+1;
ccch_or_dcch = 1; goto rb_found;
} }
else
{
nr_rrc_data_ind( ctxt_pP, 1, size, buf);
} }
LOG_E(PDCP, "%s:%d:%s: fatal, no RB found for ue %d\n",
__FILE__, __LINE__, __FUNCTION__, ue->rnti);
exit(1);
rb_found:
nr_rrc_data_ind( ctxt_pP, srb_id, size, buf);
return; return;
} }
...@@ -663,9 +664,6 @@ rb_found: ...@@ -663,9 +664,6 @@ rb_found:
memblock = get_free_mem_block(size, __FUNCTION__); memblock = get_free_mem_block(size, __FUNCTION__);
memcpy(memblock->data, buf, size); memcpy(memblock->data, buf, size);
printf("!!!!!!! deliver_pdu_srb (srb %d) calling rlc_data_req size %d: ", srb_id, size);
//for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]);
printf("\n");
enqueue_rlc_data_req(&ctxt, 1, MBMS_FLAG_NO, srb_id, sdu_id, 0, size, memblock, NULL, NULL); enqueue_rlc_data_req(&ctxt, 1, MBMS_FLAG_NO, srb_id, sdu_id, 0, size, memblock, NULL, NULL);
} }
......
...@@ -118,6 +118,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, ...@@ -118,6 +118,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
const int CC_id, const int CC_id,
const frame_t frameP, const frame_t frameP,
const rb_id_t Srb_id, const rb_id_t Srb_id,
const rnti_t rnti,
const uint8_t Nb_tb, const uint8_t Nb_tb,
uint8_t *const buffer_pP ){ uint8_t *const buffer_pP ){
...@@ -167,24 +168,27 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, ...@@ -167,24 +168,27 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
} }
/* CCCH */ /* CCCH */
struct rrc_gNB_ue_context_s *ue_context_p = NULL;
if( (Srb_id & RAB_OFFSET ) == CCCH) { if( (Srb_id & RAB_OFFSET ) == CCCH) {
//struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[Mod_idP],rnti); //struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[Mod_idP],rnti);
//if (ue_context_p == NULL) return(0); //if (ue_context_p == NULL) return(0);
//eNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; //eNB_RRC_UE_t *ue_p = &ue_context_p->ue_context;
LOG_D(RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id); ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_idP], rnti);
// LOG_I(NR_RRC,"3333 Returning new UE context at %p\n",RC.nrrrc[Mod_idP]);
// LOG_I(NR_RRC,"4444 Returning new UE context at %p\n",ue_context_p);
LOG_I(RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld), ue_context_p %p \n", Mod_idP, frameP, Srb_id, ue_context_p );
// srb_info=&ue_p->Srb0; // srb_info=&ue_p->Srb0;
payload_size = srb_info->Tx_buffer.payload_size; payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size;
// check if data is there for MAC // check if data is there for MAC
if (payload_size > 0) { if (payload_size > 0) {
payload_pP = srb_info->Tx_buffer.Payload; payload_pP = ue_context_p->ue_context.Srb0.Tx_buffer.Payload;
LOG_D(RRC,"[gNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n", Mod_idP, srb_info, payload_size, buffer_pP, payload_pP); LOG_D(RRC,"[gNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n", Mod_idP, srb_info, payload_size, buffer_pP, payload_pP);
// Fill buffer // Fill buffer
memcpy((void *)buffer_pP, (void*)payload_pP, payload_size); memcpy((void *)buffer_pP, (void*)payload_pP, payload_size);
Sdu_size = payload_size; Sdu_size = payload_size;
srb_info->Tx_buffer.payload_size = 0; ue_context_p->ue_context.Srb0.Tx_buffer.payload_size = 0;
} }
return Sdu_size; return Sdu_size;
} }
...@@ -192,3 +196,60 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, ...@@ -192,3 +196,60 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
return(0); return(0);
} }
//------------------------------------------------------------------------------
int8_t
nr_mac_rrc_data_ind(
const module_id_t module_idP,
const int CC_id,
const frame_t frameP,
const sub_frame_t sub_frameP,
const int UE_id,
const rnti_t rntiP,
const rb_id_t srb_idP,
const uint8_t *sduP,
const sdu_size_t sdu_lenP,
const uint8_t mbsfn_sync_areaP,
const boolean_t brOption
)
//--------------------------------------------------------------------------
{
// if (NODE_IS_DU(RC.nrrrc[module_idP]->node_type)) {
// LOG_W(RRC,"[DU %d][RAPROC] Received SDU for CCCH on SRB %ld length %d for UE id %d RNTI %x \n",
// module_idP, srb_idP, sdu_lenP, UE_id, rntiP);
// /* do ITTI message */
// DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(
// module_idP,
// CC_id,
// UE_id,
// rntiP,
// sduP,
// sdu_lenP
// );
// return(0);
// }
//SRB_INFO *Srb_info;
protocol_ctxt_t ctxt;
sdu_size_t sdu_size = 0;
/* for no gcc warnings */
(void)sdu_size;
/*
int si_window;
*/
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, GNB_FLAG_YES, rntiP, frameP, sub_frameP,0);
if((srb_idP & RAB_OFFSET) == CCCH) {
LOG_D(RRC, "[eNB %d] Received SDU for CCCH on SRB %ld\n", module_idP, srb_idP);
ctxt.brOption = brOption;
/*Srb_info = &RC.rrc[module_idP]->carrier[CC_id].Srb0;
if (sdu_lenP > 0) {
memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP);
Srb_info->Rx_buffer.payload_size = sdu_lenP;
rrc_eNB_decode_ccch(&ctxt, Srb_info, CC_id);
}*/
if (sdu_lenP > 0) nr_rrc_gNB_decode_ccch(&ctxt, sduP, sdu_lenP, CC_id);
}
return(0);
}
...@@ -50,6 +50,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, ...@@ -50,6 +50,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
const int CC_id, const int CC_id,
const frame_t frameP, const frame_t frameP,
const rb_id_t Srb_id, const rb_id_t Srb_id,
const rnti_t rnti,
const uint8_t Nb_tb, const uint8_t Nb_tb,
uint8_t *const buffer_pP ); uint8_t *const buffer_pP );
...@@ -64,7 +65,7 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( ...@@ -64,7 +65,7 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge(
); );
struct rrc_gNB_ue_context_s *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance_pP); struct rrc_gNB_ue_context_s *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance_pP);
struct rrc_gNB_ue_context_s *rrc_gNB_get_ue_context(gNB_RRC_INST *rrc_instance_pP,rnti_t rntiP);
void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc,LTE_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t * cg_config_info); void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc,LTE_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t * cg_config_info);
void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m); void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m);
...@@ -141,3 +142,22 @@ nr_rrc_data_req( ...@@ -141,3 +142,22 @@ nr_rrc_data_req(
int int
nr_rrc_mac_remove_ue(module_id_t mod_idP, nr_rrc_mac_remove_ue(module_id_t mod_idP,
rnti_t rntiP); rnti_t rntiP);
int8_t nr_mac_rrc_data_ind(
const module_id_t module_idP,
const int CC_id,
const frame_t frameP,
const sub_frame_t sub_frameP,
const int UE_id,
const rnti_t rntiP,
const rb_id_t srb_idP,
const uint8_t *sduP,
const sdu_size_t sdu_lenP,
const uint8_t mbsfn_sync_areaP,
const boolean_t brOption
);
int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
const uint8_t *buffer,
int buffer_length,
const int CC_id);
...@@ -404,13 +404,14 @@ rrc_gNB_generate_RRCSetup( ...@@ -404,13 +404,14 @@ rrc_gNB_generate_RRCSetup(
// ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0; // ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0;
log_dump(NR_RRC, ue_p->Srb0.Tx_buffer.Payload, 16, LOG_DUMP_CHAR,"RRCSetup size: "); log_dump(NR_RRC, ue_p->Srb0.Tx_buffer.Payload, 16, LOG_DUMP_CHAR,"RRCSetup size: ");
nr_rrc_data_req(ctxt_pP, // nr_rrc_data_req(ctxt_pP,
DCCH, // DCCH,
rrc_gNB_mui++, // rrc_gNB_mui++,
SDU_CONFIRM_NO, // SDU_CONFIRM_NO,
ue_p->Srb0.Tx_buffer.payload_size, // ue_p->Srb0.Tx_buffer.payload_size,
ue_p->Srb0.Tx_buffer.Payload, // ue_p->Srb0.Tx_buffer.Payload,
PDCP_TRANSMISSION_MODE_CONTROL); // PDCP_TRANSMISSION_MODE_CONTROL);
#ifdef ITTI_SIM #ifdef ITTI_SIM
MessageDef *message_p; MessageDef *message_p;
...@@ -737,7 +738,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -737,7 +738,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
100, 100,
0, 0,
0); 0);
if (dec_rval.consumed == 0) { if (dec_rval.consumed == 0) {
/* TODO */ /* TODO */
LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" FATAL Error in receiving CCCH\n", LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" FATAL Error in receiving CCCH\n",
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "rrc_defs.h" #include "rrc_defs.h"
#include "rrc_proto.h" #include "rrc_proto.h"
#include "assertions.h" #include "assertions.h"
#include "rrc_vars.h"
typedef uint32_t channel_t; typedef uint32_t channel_t;
...@@ -41,14 +42,44 @@ nr_mac_rrc_data_ind_ue( ...@@ -41,14 +42,44 @@ nr_mac_rrc_data_ind_ue(
const module_id_t module_id, const module_id_t module_id,
const int CC_id, const int CC_id,
const uint8_t gNB_index, const uint8_t gNB_index,
const frame_t frame,
const sub_frame_t sub_frame,
const rnti_t rnti,
const channel_t channel, const channel_t channel,
const uint8_t* pduP, const uint8_t* pduP,
const sdu_size_t pdu_len){ const sdu_size_t pdu_len){
sdu_size_t sdu_size = 0;
protocol_ctxt_t ctxt;
switch(channel){ switch(channel){
case NR_BCCH_BCH: case NR_BCCH_BCH:
AssertFatal( nr_rrc_ue_decode_NR_BCCH_BCH_Message( module_id, gNB_index, (uint8_t*)pduP, pdu_len) == 0, "UE decode BCCH-BCH error!\n"); AssertFatal( nr_rrc_ue_decode_NR_BCCH_BCH_Message( module_id, gNB_index, (uint8_t*)pduP, pdu_len) == 0, "UE decode BCCH-BCH error!\n");
break; break;
case CCCH:
if (pdu_len>0) {
LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %ld from gNB %d\n",module_id,channel & RAB_OFFSET,gNB_index);
{
MessageDef *message_p;
int msg_sdu_size = CCCH_SDU_SIZE;
if (pdu_len > msg_sdu_size) {
LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size);
sdu_size = msg_sdu_size;
} else {
sdu_size = pdu_len;
}
message_p = itti_alloc_new_message (TASK_MAC_UE, NR_RRC_MAC_CCCH_DATA_IND);
memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
memcpy (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, pduP, sdu_size);
NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = frame; //frameP
NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = sub_frame; //sub_frameP
NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size;
NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = gNB_index;
NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; //rntiP
itti_send_msg_to_task (TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE( module_id ), message_p);
}
}
default: default:
break; break;
} }
...@@ -58,13 +89,49 @@ nr_mac_rrc_data_ind_ue( ...@@ -58,13 +89,49 @@ nr_mac_rrc_data_ind_ue(
} }
int8_t mac_rrc_nr_data_req_ue(const module_id_t Mod_idP, int8_t mac_rrc_nr_data_req_ue(
const int CC_id, const module_id_t Mod_idP,
const frame_t frameP, const int CC_id,
const rb_id_t Srb_id, const frame_t frameP,
uint8_t *const buffer_pP ){ const rb_id_t Srb_id,
const uint8_t Nb_tb,
uint8_t *const buffer_pP,
const uint8_t gNB_index,
const uint8_t mbsfn_sync_area
){
// todo // todo
if( (NR_UE_rrc_inst[Mod_idP].Srb0[gNB_index].Tx_buffer.payload_size > 0) ) {
// MessageDef *message_p;
// int ccch_size = NR_UE_rrc_inst[Mod_idP].Srb0[gNB_index].Tx_buffer.payload_size;
// int sdu_size = sizeof(RRC_MAC_CCCH_DATA_REQ (message_p).sdu);
// if (ccch_size > sdu_size) {
// LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", ccch_size, sdu_size);
// ccch_size = sdu_size;
// }
// message_p = itti_alloc_new_message (TASK_RRC_UE, RRC_MAC_CCCH_DATA_REQ);
// RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP;
// RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size;
// memset (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, 0, CCCH_SDU_SIZE);
// memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, NR_UE_rrc_inst[Mod_idP].Srb0[gNB_index].Tx_buffer.Payload, ccch_size);
// RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = gNB_index;
// itti_send_msg_to_task (TASK_MAC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
// }
memset (buffer_pP, 0,sizeof(buffer_pP));
memcpy(&buffer_pP[0],&NR_UE_rrc_inst[Mod_idP].Srb0[gNB_index].Tx_buffer.Payload[0],NR_UE_rrc_inst[Mod_idP].Srb0[gNB_index].Tx_buffer.payload_size);
uint8_t Ret_size=NR_UE_rrc_inst[Mod_idP].Srb0[gNB_index].Tx_buffer.payload_size;
// NR_UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size=0;
NR_UE_rrc_inst[Mod_idP].Info[gNB_index].T300_active = 1;
NR_UE_rrc_inst[Mod_idP].Info[gNB_index].T300_cnt = 0;
// msg("[RRC][UE %d] Sending rach\n",Mod_id);
return(Ret_size);
} else {
return 0;
}
return 0; return 0;
} }
...@@ -107,3 +174,4 @@ rrc_data_req_ue( ...@@ -107,3 +174,4 @@ rrc_data_req_ue(
return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
} }
...@@ -100,7 +100,14 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message(const module_id_t module_id, const ui ...@@ -100,7 +100,14 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message(const module_id_t module_id, const ui
\param channel indicator for channel of the pdu \param channel indicator for channel of the pdu
\param pduP pointer to pdu \param pduP pointer to pdu
\param pdu_len data length of pdu*/ \param pdu_len data length of pdu*/
int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index, const channel_t channel, const uint8_t* pduP, const sdu_size_t pdu_len); int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
const int CC_id, const uint8_t gNB_index,
const frame_t frame,
const sub_frame_t sub_frame,
const rnti_t rnti,
const channel_t channel,
const uint8_t* pduP,
const sdu_size_t pdu_len);
/**\brief /**\brief
\param module_id module id \param module_id module id
...@@ -108,11 +115,15 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, cons ...@@ -108,11 +115,15 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, cons
\param frame_t frameP \param frame_t frameP
\param rb_id_t SRB id \param rb_id_t SRB id
\param buffer_pP pointer to buffer*/ \param buffer_pP pointer to buffer*/
int8_t mac_rrc_nr_data_req_ue(const module_id_t Mod_idP, int8_t mac_rrc_nr_data_req_ue(
const int CC_id, const module_id_t Mod_idP,
const frame_t frameP, const int CC_id,
const rb_id_t Srb_id, const frame_t frameP,
uint8_t *const buffer_pP); const rb_id_t Srb_id,
const uint8_t Nb_tb,
uint8_t *const buffer_pP,
const uint8_t gNB_index,
const uint8_t mbsfn_sync_area);
/**\brief RRC UE task. /**\brief RRC UE task.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment