Commit 98480e71 authored by cig's avatar cig

RA, Updated nr_ue_get_rach:

- using LTE function mac_rrc_nr_data_req_ue in noS1 mode
- cleanup code, comments
- fixes RA procedure
- Processing UL MAC PDU according to TS 38.321 ch 6.1:
- introduced function for gNB side UL PDU processing
- fixed bug in nr_ue_process_mac_pdu
parent 6c61fef3
...@@ -3290,9 +3290,6 @@ void nr_ue_process_mac_pdu(module_id_t module_idP, ...@@ -3290,9 +3290,6 @@ void nr_ue_process_mac_pdu(module_id_t module_idP,
mac->t_crnti = 0; mac->t_crnti = 0;
mac->ra_state = RA_SUCCEEDED; mac->ra_state = RA_SUCCEEDED;
} }
break;
break; break;
case DL_SCH_LCID_PADDING: case DL_SCH_LCID_PADDING:
done = 1; done = 1;
......
...@@ -46,11 +46,12 @@ void nr_add_subframe(uint16_t *frameP, uint16_t *slotP, int offset){ ...@@ -46,11 +46,12 @@ void nr_add_subframe(uint16_t *frameP, uint16_t *slotP, int offset){
*slotP = ((*slotP + offset) % 10); *slotP = ((*slotP + offset) % 10);
} }
// TBR // WIP
// handles the event of msg1 reception // handles the event of msg1 reception
// todo: // todo:
// - offset computation // - offset computation
// - fix nr_add_subframe // - fix nr_add_subframe
// - msg2 time location
void nr_initiate_ra_proc(module_id_t module_idP, void nr_initiate_ra_proc(module_id_t module_idP,
int CC_id, int CC_id,
frame_t frameP, frame_t frameP,
...@@ -96,17 +97,15 @@ void nr_initiate_ra_proc(module_id_t module_idP, ...@@ -96,17 +97,15 @@ void nr_initiate_ra_proc(module_id_t module_idP,
ra->Msg2_frame = msg2_frame; ra->Msg2_frame = msg2_frame;
ra->Msg2_slot = msg2_slot; ra->Msg2_slot = msg2_slot;
// ra->Msg2_slot = (slotP + offset) % 10;
LOG_D(MAC, "%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__, ra->Msg2_frame, ra->Msg2_slot, frameP, slotP, offset); LOG_D(MAC, "%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__, ra->Msg2_frame, ra->Msg2_slot, frameP, slotP, offset);
ra->Msg2_slot = (slotP + offset) % 10; // TBR this is done twice ?
do { do {
ra->rnti = taus(); // todo 5.1.3 TS 38.321 ra->rnti = (taus() % 65518) + 1;
loop++; loop++;
} }
// Range coming from 5.1.3 TS 38.321 while (loop != 100 && !(find_nr_UE_id(module_idP, ra->rnti) == -1 && ra->rnti >= 1 && ra->rnti <= 65519));
while (loop != 100 && !(find_nr_UE_id(module_idP, ra->rnti) == -1 && ra->rnti >= 1 && ra->rnti <= 17920));
if (loop == 100) { if (loop == 100) {
LOG_E(MAC,"%s:%d:%s: [RAPROC] initialisation random access aborted\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(MAC,"%s:%d:%s: [RAPROC] initialisation random access aborted\n", __FILE__, __LINE__, __FUNCTION__);
abort(); abort();
...@@ -137,7 +136,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, ...@@ -137,7 +136,6 @@ void nr_initiate_ra_proc(module_id_t module_idP,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0);
} }
// WIP
void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){
//uint8_t i = 0; //uint8_t i = 0;
...@@ -166,6 +164,7 @@ void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ ...@@ -166,6 +164,7 @@ void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){
} }
// WIP // WIP
// todo: fix
void nr_generate_Msg2(module_id_t module_idP, void nr_generate_Msg2(module_id_t module_idP,
int CC_id, int CC_id,
frame_t frameP, frame_t frameP,
...@@ -367,6 +366,7 @@ void nr_clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP){ ...@@ -367,6 +366,7 @@ void nr_clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP){
ra->msg3_round = 0; ra->msg3_round = 0;
} }
// WIP
// todo: // todo:
// - handle MAC RAR BI subheader // - handle MAC RAR BI subheader
// - sending only 1 RAR subPDU // - sending only 1 RAR subPDU
...@@ -403,6 +403,7 @@ void nr_fill_rar(NR_RA_t * ra, ...@@ -403,6 +403,7 @@ void nr_fill_rar(NR_RA_t * ra,
} }
// WIP // WIP
// todo: fix
void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP){ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP){
gNB_MAC_INST *mac = RC.nrmac[module_idP]; gNB_MAC_INST *mac = RC.nrmac[module_idP];
...@@ -439,7 +440,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t ...@@ -439,7 +440,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t
LOG_D(MAC, "[gNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot); LOG_D(MAC, "[gNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot);
ul_req->SFN = ra->Msg3_frame << 4 | ra->Msg3_slot; // TBR ul_req->SFN = ra->Msg3_frame << 4 | ra->Msg3_slot;
ul_req->Slot = slotP; ul_req->Slot = slotP;
ul_req->n_pdus = 1; ul_req->n_pdus = 1;
ul_req->pdus_list[0].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE; ul_req->pdus_list[0].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE;
...@@ -485,7 +486,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t ...@@ -485,7 +486,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t
pusch_pdu->nrOfLayers = 1; pusch_pdu->nrOfLayers = 1;
pusch_pdu->ul_dmrs_symb_pos = 1; pusch_pdu->ul_dmrs_symb_pos = 1;
pusch_pdu->dmrs_config_type = 0; pusch_pdu->dmrs_config_type = 0;
pusch_pdu->ul_dmrs_scrambling_id = 0; //If provided and the PUSCH is not a msg3 PUSCH, otherwise, L2 should set this to physical cell id. // TBR pusch_pdu->ul_dmrs_scrambling_id = 0; //If provided and the PUSCH is not a msg3 PUSCH, otherwise, L2 should set this to physical cell id.
pusch_pdu->scid = 0; //DMRS sequence initialization [TS38.211, sec 6.4.1.1.1]. Should match what is sent in DCI 0_1, otherwise set to 0. pusch_pdu->scid = 0; //DMRS sequence initialization [TS38.211, sec 6.4.1.1.1]. Should match what is sent in DCI 0_1, otherwise set to 0.
pusch_pdu->resource_alloc = 1; //type 1 pusch_pdu->resource_alloc = 1; //type 1
//pusch_pdu->rb_bitmap;// for ressource alloc type 0 //pusch_pdu->rb_bitmap;// for ressource alloc type 0
......
...@@ -70,3 +70,137 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ...@@ -70,3 +70,137 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
UE_scheduling_control->ta_update = timing_advance; UE_scheduling_control->ta_update = timing_advance;
} }
} }
// WIP
// todo: complete
// TS 38.321 ch 6.1 Protocol Data Units - UL-SCH
void nr_process_mac_pdu(module_id_t module_idP,
uint8_t CC_id,
frame_t frameP,
uint8_t *pduP,
uint16_t mac_pdu_len,
uint8_t UE_id){
uint8_t *pdu_ptr = pduP, rx_lcid, done = 0;
int pdu_len = mac_pdu_len;
uint16_t mac_ce_len, mac_subheader_len, mac_sdu_len;
// For both DL/UL-SCH
// Except:
// - UL/DL-SCH: fixed-size MAC CE(known by LCID)
// - UL/DL-SCH: padding
// - UL-SCH: MSG3 48-bits
// |0|1|2|3|4|5|6|7| bit-wise
// |R|F| LCID |
// | L |
// |0|1|2|3|4|5|6|7| bit-wise
// |R|F| LCID |
// | L |
// | L |
// For both DL/UL-SCH
// For:
// - UL/DL-SCH: fixed-size MAC CE(known by LCID)
// - UL/DL-SCH: padding, for single/multiple 1-oct padding CE(s)
// - UL-SCH: MSG3 48-bits
// |0|1|2|3|4|5|6|7| bit-wise
// |R|R| LCID |
// LCID: The Logical Channel ID field identifies the logical channel instance of the corresponding MAC SDU or the type of the corresponding MAC CE or padding as described in Tables 6.2.1-1 and 6.2.1-2 for the DL-SCH and UL-SCH respectively. There is one LCID field per MAC subheader. The LCID field size is 6 bits;
// L: The Length field indicates the length of the corresponding MAC SDU or variable-sized MAC CE in bytes. There is one L field per MAC subheader except for subheaders corresponding to fixed-sized MAC CEs and padding. The size of the L field is indicated by the F field;
// F: lenght of L is 0:8 or 1:16 bits wide
// R: Reserved bit, set to zero.
while (!done && pdu_len > 0){
mac_ce_len = 0x0000;
mac_subheader_len = 0x0001; // default to fixed-length subheader = 1-oct
mac_sdu_len = 0x0000;
rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pdu_ptr)->LCID;
switch(rx_lcid){
// MAC CEs
case UL_SCH_LCID_RECOMMENDED_BITRATE_QUERY:
// 38.321 Ch6.1.3.20
mac_ce_len = 2;
break;
case UL_SCH_LCID_MULTI_ENTRY_PHR_4_OCT:
// 38.321 Ch6.1.3.9
// variable length
// todo
break;
case UL_SCH_LCID_CONFIGURED_GRANT_CONFIRMATION:
// 38.321 Ch6.1.3.7
break;
case UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT:
// 38.321 Ch6.1.3.9
// variable length
// todo
break;
case UL_SCH_LCID_SINGLE_ENTRY_PHR:
// 38.321 Ch6.1.3.8
mac_ce_len = 2;
break;
case UL_SCH_LCID_C_RNTI:
// 38.321 Ch6.1.3.2
mac_ce_len = 2;
break;
case UL_SCH_LCID_S_TRUNCATED_BSR:
// 38.321 Ch6.1.3.1
// fixed length
mac_ce_len = 1;
break;
case UL_SCH_LCID_L_TRUNCATED_BSR:
// 38.321 Ch6.1.3.1
// variable length
// todo
break;
case UL_SCH_LCID_S_BSR:
// 38.321 Ch6.1.3.1
// fixed length
mac_ce_len = 1;
break;
case UL_SCH_LCID_L_BSR:
// 38.321 Ch6.1.3.1
// variable length
// todo
break;
case UL_SCH_LCID_PADDING:
done = 1;
// end of MAC PDU, can ignore the rest.
break;
// MAC SDUs
case UL_SCH_LCID_SRB1:
// todo
break;
case UL_SCH_LCID_SRB2:
// todo
break;
case UL_SCH_LCID_SRB3:
// todo
break;
case UL_SCH_LCID_CCCH_MSG3:
case UL_SCH_LCID_CCCH:
// todo
mac_subheader_len = 2;
break;
case UL_SCH_LCID_DTCH:
// todo
default:
if(((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F){
//mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2)<<8;
mac_subheader_len = 3;
mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pdu_ptr)->L1 & 0x7f) << 8) | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pdu_ptr)->L2 & 0xff);
} else {
mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
mac_subheader_len = 2;
}
// todo
break;
}
pdu_ptr += ( mac_subheader_len + mac_ce_len + mac_sdu_len );
pdu_len -= ( mac_subheader_len + mac_ce_len + mac_sdu_len );
AssertFatal(pdu_len >= 0, "[MAC] nr_process_mac_pdu, residual mac pdu length < 0!\n");
}
}
\ No newline at end of file
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