Commit 82f18785 authored by root's avatar root

Merge branch 'develop-nr' of https://gitlab.eurecom.fr/oai/openairinterface5g into develop-nr

parents 6147b8d8 a964b894
...@@ -69,12 +69,45 @@ typedef struct { ...@@ -69,12 +69,45 @@ typedef struct {
uint8_t R:2; // octet 1 [7:6] uint8_t R:2; // octet 1 [7:6]
} __attribute__ ((__packed__)) NR_MAC_SUBHEADER_FIXED; } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_FIXED;
#define DL_SCH_LCID_CCCH 0x0 // 38.321 ch6.2.1, 38.331
#define DL_SCH_LCID_R_BITRATE 0x2f #define DL_SCH_LCID_CCCH 0x00
#define DL_SCH_LCID_L_DRX 0x3b #define DL_SCH_LCID_SRB1 0x01
#define DL_SCH_LCID_DRX 0x3c #define DL_SCH_LCID_SRB2 0x02
#define DL_SCH_LCID_TA 0x3d #define DL_SCH_LCID_SRB3 0x03
#define DL_SCH_LCID_CONTENTION_RESOLUTION_ID 0x3e #define DL_SCH_LCID_RECOMMENDED_BITRATE 0x2F
#define DL_SCH_LCID_PADDING 0x3f #define DL_SCH_LCID_SP_ZP_CSI_RS_RES_SET_ACT 0x30
#define DL_SCH_LCID_PUCCH_SPATIAL_RELATION_ACT 0x31
#define DL_SCH_LCID_SP_SRS_ACTIVATION 0x32
#define DL_SCH_LCID_SP_CSI_REP_PUCCH_ACT 0x33
#define DL_SCH_LCID_TCI_STATE_IND_UE_SPEC_PDCCH 0x34
#define DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH 0x35
#define DL_SCH_LCID_APERIODIC_CSI_TRI_STATE_SUBSEL 0x36
#define DL_SCH_LCID_SP_CSI_RS_CSI_IM_RES_SET_ACT 0X37
#define DL_SCH_LCID_DUPLICATION_ACT 0X38
#define DL_SCH_LCID_SCell_ACT_4_OCT 0X39
#define DL_SCH_LCID_SCell_ACT_1_OCT 0X3A
#define DL_SCH_LCID_L_DRX 0x3B
#define DL_SCH_LCID_DRX 0x3C
#define DL_SCH_LCID_TA_COMMAND 0x3D
#define DL_SCH_LCID_CON_RES_ID 0x3E
#define DL_SCH_LCID_PADDING 0x3F
#define UL_SCH_LCID_CCCH 0x00
#define UL_SCH_LCID_SRB1 0x01
#define UL_SCH_LCID_SRB2 0x02
#define UL_SCH_LCID_SRB3 0x03
#define UL_SCH_LCID_CCCH_MSG3 0x21
#define UL_SCH_LCID_RECOMMENDED_BITRATE_QUERY 0x35
#define UL_SCH_LCID_MULTI_ENTRY_PHR_4_OCT 0x36
#define UL_SCH_LCID_CONFIGURED_GRANT_CONFIRMATION 0x37
#define UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT 0x38
#define UL_SCH_LCID_SINGLE_ENTRY_PHR 0x39
#define UL_SCH_LCID_C_RNTI 0x3A
#define UL_SCH_LCID_S_TRUNCATED_BSR 0x3B
#define UL_SCH_LCID_L_TRUNCATED_BSR 0x3C
#define UL_SCH_LCID_S_BSR 0x3D
#define UL_SCH_LCID_L_BSR 0x3E
#define UL_SCH_LCID_PADDING 0x3F
#endif /*__LAYER2_MAC_DEFS_H__ */ #endif /*__LAYER2_MAC_DEFS_H__ */
...@@ -115,10 +115,17 @@ uint32_t ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, ...@@ -115,10 +115,17 @@ uint32_t ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP,
int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_type); int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_type);
uint32_t get_ssb_frame(void); uint32_t get_ssb_frame(uint32_t test);
uint32_t get_ssb_slot(uint32_t ssb_index); uint32_t get_ssb_slot(uint32_t ssb_index);
uint32_t mr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe); uint32_t mr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe);
void nr_ue_process_mac_pdu(
module_id_t module_idP,
uint8_t CC_id,
uint8_t *pduP,
uint16_t mac_pdu_len,
uint8_t eNB_index);
#endif #endif
/** @}*/ /** @}*/
\ No newline at end of file
...@@ -96,7 +96,9 @@ int8_t nr_ue_decode_mib( ...@@ -96,7 +96,9 @@ int8_t nr_ue_decode_mib(
printf("ssb index(extra bits): %d\n", (int)ssb_index); printf("ssb index(extra bits): %d\n", (int)ssb_index);
#endif #endif
subcarrier_spacing_t scs_ssb = scs_30kHz; // default for testing subcarrier_spacing_t scs_ssb = scs_30kHz; // default for
//const uint32_t scs_index = 0;
const uint32_t num_slot_per_frame = 20;
subcarrier_spacing_t scs_pdcch; subcarrier_spacing_t scs_pdcch;
// assume carrier frequency < 6GHz // assume carrier frequency < 6GHz
...@@ -268,8 +270,7 @@ int8_t nr_ue_decode_mib( ...@@ -268,8 +270,7 @@ int8_t nr_ue_decode_mib(
uint32_t search_space_duration; // element of search space uint32_t search_space_duration; // element of search space
uint32_t coreset_duration; // element of coreset uint32_t coreset_duration; // element of coreset
const uint32_t scs_index = 0;
const uint32_t num_slot_per_frame = 20;
// 38.213 table 10.1-1 // 38.213 table 10.1-1
...@@ -281,7 +282,7 @@ const uint32_t num_slot_per_frame = 20; ...@@ -281,7 +282,7 @@ const uint32_t num_slot_per_frame = 20;
number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb]; number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb];
big_m = table_38213_13_11_c3[index_4lsb]; big_m = table_38213_13_11_c3[index_4lsb];
temp = (uint32_t)(big_o*pow(2, scs_index)) + (uint32_t)(ssb_index*big_m); temp = (uint32_t)(big_o*pow(2, scs_pdcch)) + (uint32_t)(ssb_index*big_m);
n_c = temp / num_slot_per_frame; n_c = temp / num_slot_per_frame;
if((temp/num_slot_per_frame) & 0x1){ if((temp/num_slot_per_frame) & 0x1){
sfn_c = SFN_C_MOD_2_EQ_1; sfn_c = SFN_C_MOD_2_EQ_1;
...@@ -445,8 +446,8 @@ const uint32_t num_slot_per_frame = 20; ...@@ -445,8 +446,8 @@ const uint32_t num_slot_per_frame = 20;
// TODO: change to UE parameter, scs: 15KHz, slot duration: 1ms // TODO: change to UE parameter, scs: 15KHz, slot duration: 1ms
uint32_t get_ssb_frame(){ uint32_t get_ssb_frame(uint32_t test){
return 0; return test;
} }
// Performs : // Performs :
...@@ -485,14 +486,14 @@ NR_UE_L2_STATE_t nr_ue_scheduler( ...@@ -485,14 +486,14 @@ NR_UE_L2_STATE_t nr_ue_scheduler(
} }
if(mac->type0_pdcch_ss_mux_pattern == 2){ if(mac->type0_pdcch_ss_mux_pattern == 2){
// 38.213 Table 13-13, 13-14 // 38.213 Table 13-13, 13-14
if((rx_frame == get_ssb_frame()) && (rx_slot == mac->type0_pdcch_ss_n_c)){ if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){
search_space_mask = search_space_mask | type0_pdcch; search_space_mask = search_space_mask | type0_pdcch;
mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.duration; mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.duration;
} }
} }
if(mac->type0_pdcch_ss_mux_pattern == 3){ if(mac->type0_pdcch_ss_mux_pattern == 3){
// 38.213 Table 13-15 // 38.213 Table 13-15
if((rx_frame == get_ssb_frame()) && (rx_slot == mac->type0_pdcch_ss_n_c)){ if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){
search_space_mask = search_space_mask | type0_pdcch; search_space_mask = search_space_mask | type0_pdcch;
mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.duration; mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.duration;
} }
...@@ -574,48 +575,175 @@ void nr_ue_process_mac_pdu( ...@@ -574,48 +575,175 @@ void nr_ue_process_mac_pdu(
module_id_t module_idP, module_id_t module_idP,
uint8_t CC_id, uint8_t CC_id,
uint8_t *pduP, uint8_t *pduP,
uint16_t pdu_len, uint16_t mac_pdu_len,
uint8_t eNB_index){ uint8_t eNB_index){
uint8_t *pdu_ptr = pduP; uint8_t *pdu_ptr = pduP;
uint8_t sub_pdu_len; uint16_t pdu_len = mac_pdu_len;
// variable-size MAC CE(known by LCID), padding, MSG3, MAC SDU uint16_t mac_ce_len;
uint16_t mac_subheader_len;
uint16_t 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 // |0|1|2|3|4|5|6|7| bit-wise
// |R|F| LCID | // |R|F| LCID |
// | L | // | L |
// variable-size MAC CE(known by LCID), padding, MSG3, MAC SDU
// |0|1|2|3|4|5|6|7| bit-wise // |0|1|2|3|4|5|6|7| bit-wise
// |R|F| LCID | // |R|F| LCID |
// | L | // | L |
// | L | // | L |
// fixed-size MAC CE(known by LCID), padding, MSG3 // 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 // |0|1|2|3|4|5|6|7| bit-wise
// |R|R| LCID | // |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; // 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; // 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 8 or 16 bits wide // F: lenght of L is 0:8 or 1:16 bits wide
// R: Reserved bit, set to zero. // R: Reserved bit, set to zero.
uint8_t done = 0;
while (!done) { uint8_t done = 0;
while (!done || pdu_len <= 0){
mac_ce_len = 0x0000;
mac_subheader_len = 0x0001; // default to fixed-length subheader = 1-oct
mac_sdu_len = 0x0000;
switch(((NR_MAC_SUBHEADER_FIXED *)pdu_ptr)->LCID){ switch(((NR_MAC_SUBHEADER_FIXED *)pdu_ptr)->LCID){
// Control element // MAC CE
case DL_SCH_LCID_CCCH:
// MSG4 RRC Connection Setup 38.331
// varialbe length
mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
mac_subheader_len = 2;
if(((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F){
mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2)<<8;
mac_subheader_len = 3;
}
break;
case DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH:
// 38.321 Ch6.1.3.14
// varialbe length
mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
mac_subheader_len = 2;
if(((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F){
mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2)<<8;
mac_subheader_len = 3;
}
break;
case DL_SCH_LCID_APERIODIC_CSI_TRI_STATE_SUBSEL:
// 38.321 Ch6.1.3.13
// varialbe length
mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
mac_subheader_len = 2;
if(((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F){
mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2)<<8;
mac_subheader_len = 3;
}
break;
case DL_SCH_LCID_SP_CSI_RS_CSI_IM_RES_SET_ACT:
// 38.321 Ch6.1.3.12
// varialbe length
mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
mac_subheader_len = 2;
if(((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F){
mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2)<<8;
mac_subheader_len = 3;
}
break;
case DL_SCH_LCID_SP_SRS_ACTIVATION:
// 38.321 Ch6.1.3.17
// varialbe length
mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
mac_subheader_len = 2;
if(((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F){
mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2)<<8;
mac_subheader_len = 3;
}
break;
case DL_SCH_LCID_RECOMMENDED_BITRATE:
// 38.321 Ch6.1.3.20
mac_ce_len = 2;
break;
case DL_SCH_LCID_SP_ZP_CSI_RS_RES_SET_ACT:
// 38.321 Ch6.1.3.19
mac_ce_len = 2;
break;
case DL_SCH_LCID_PUCCH_SPATIAL_RELATION_ACT:
// 38.321 Ch6.1.3.18
mac_ce_len = 3;
break;
case DL_SCH_LCID_SP_CSI_REP_PUCCH_ACT:
// 38.321 Ch6.1.3.16
mac_ce_len = 2;
break;
case DL_SCH_LCID_TCI_STATE_IND_UE_SPEC_PDCCH:
// 38.321 Ch6.1.3.15
mac_ce_len = 2;
break;
case DL_SCH_LCID_DUPLICATION_ACT:
// 38.321 Ch6.1.3.11
mac_ce_len = 1;
break;
case DL_SCH_LCID_SCell_ACT_4_OCT:
// 38.321 Ch6.1.3.10
mac_ce_len = 4;
break;
case DL_SCH_LCID_SCell_ACT_1_OCT:
// 38.321 Ch6.1.3.10
mac_ce_len = 1;
break;
case DL_SCH_LCID_L_DRX:
// 38.321 Ch6.1.3.6
// fixed length but not yet specify.
mac_ce_len = 0;
break;
case DL_SCH_LCID_DRX:
// 38.321 Ch6.1.3.5
// fixed length but not yet specify.
mac_ce_len = 0;
break;
case DL_SCH_LCID_TA_COMMAND:
// 38.321 Ch6.1.3.4
mac_ce_len = 1;
break;
case DL_SCH_LCID_CON_RES_ID:
// 38.321 Ch6.1.3.3
mac_ce_len = 6;
break;
case DL_SCH_LCID_PADDING: case DL_SCH_LCID_PADDING:
done = 1; done = 1;
// end of MAC PDU, there is nothing right after padding // end of MAC PDU, can ignore the rest.
break; break;
// MAC SDU // MAC SDU
case DL_SCH_LCID_SRB1:
// check if LCID is valid at current time.
case UL_SCH_LCID_SRB2:
// check if LCID is valid at current time.
case UL_SCH_LCID_SRB3:
// check if LCID is valid at current time.
default: default:
printf("[MAC] get lcid: %d which not support yet\n", ((NR_MAC_SUBHEADER_FIXED *)pdu_ptr)->LCID); // check if LCID is valid at current time.
mac_sdu_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
mac_subheader_len = 2;
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;
}
// DRB LCID by RRC
break; break;
} }
pdu_ptr += sub_pdu_len; 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_ue_process_mac_pdu, residual mac pdu length < 0!\n");
} }
} }
...@@ -630,7 +630,8 @@ static void *UE_thread_rxn_txnp4(void *arg) { ...@@ -630,7 +630,8 @@ static void *UE_thread_rxn_txnp4(void *arg) {
UE->ul_indication.module_id = 0; UE->ul_indication.module_id = 0;
UE->ul_indication.gNB_index = 0; UE->ul_indication.gNB_index = 0;
UE->ul_indication.cc_id = 0; UE->ul_indication.cc_id = 0;
UE->ul_indication.slot = 0; // to be fill
UE->ul_indication.frame = 0; // to be fill
// [TODO] mapping right after NR initial sync // [TODO] mapping right after NR initial sync
//UE->ul_indication.frame = ; //UE->ul_indication.frame = ;
//UE->ul_indication.slot = ; //UE->ul_indication.slot = ;
......
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