Merge branch 'NR_RRC_PRACH_procedures' of https://gitlab.eurecom.fr/oai/openairinterface5g into NR_RRC_PRACH_procedures
This commit is contained in:
@@ -50,6 +50,7 @@ int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB) {
|
||||
else return(N_RB-1-tmp2);
|
||||
}
|
||||
|
||||
/* TS 38.214 ch. 6.1.2.2.2 - Resource allocation type 1 for DL and UL */
|
||||
int PRBalloc_to_locationandbandwidth0(int NPRB,int RBstart,int BWPsize) {
|
||||
AssertFatal(NPRB>0 && (NPRB + RBstart <= BWPsize),"Illegal NPRB/RBstart Configuration (%d,%d)\n",NPRB,RBstart);
|
||||
if (NPRB <= 1+(BWPsize>>1)) return(BWPsize*(NPRB-1)+RBstart);
|
||||
@@ -59,14 +60,21 @@ int PRBalloc_to_locationandbandwidth0(int NPRB,int RBstart,int BWPsize) {
|
||||
int PRBalloc_to_locationandbandwidth(int NPRB,int RBstart) {
|
||||
return(PRBalloc_to_locationandbandwidth0(NPRB,RBstart,275));
|
||||
}
|
||||
|
||||
/// Target code rate tables indexed by Imcs
|
||||
/* TS 38.214 table 5.1.3.1-1 - MCS index table 1 for PDSCH */
|
||||
uint16_t nr_target_code_rate_table1[29] = {120, 157, 193, 251, 308, 379, 449, 526, 602, 679, 340, 378, 434, 490, 553, \
|
||||
616, 658, 438, 466, 517, 567, 616, 666, 719, 772, 822, 873, 910, 948};
|
||||
// Imcs values 20 and 26 have been multiplied by 2 to avoid the floating point
|
||||
|
||||
/* TS 38.214 table 5.1.3.1-2 - MCS index table 2 for PDSCH */
|
||||
// Imcs values 20 and 26 have been multiplied by 2 to avoid the floating point
|
||||
uint16_t nr_target_code_rate_table2[28] = {120, 193, 308, 449, 602, 378, 434, 490, 553, 616, 658, 466, 517, 567, \
|
||||
616, 666, 719, 772, 822, 873, 1365, 711, 754, 797, 841, 885, 1833, 948};
|
||||
|
||||
/* TS 38.214 table 5.1.3.1-3 - MCS index table 3 for PDSCH */
|
||||
uint16_t nr_target_code_rate_table3[29] = {30, 40, 50, 64, 78, 99, 120, 157, 193, 251, 308, 379, 449, 526, 602, 340, \
|
||||
378, 434, 490, 553, 616, 438, 466, 517, 567, 616, 666, 719, 772};
|
||||
|
||||
uint16_t nr_tbs_table[93] = {24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 208, 224, 240, 256, 272, 288, 304, 320, \
|
||||
336, 352, 368, 384, 408, 432, 456, 480, 504, 528, 552, 576, 608, 640, 672, 704, 736, 768, 808, 848, 888, 928, 984, 1032, 1064, 1128, 1160, 1192, 1224, 1256, \
|
||||
1288, 1320, 1352, 1416, 1480, 1544, 1608, 1672, 1736, 1800, 1864, 1928, 2024, 2088, 2152, 2216, 2280, 2408, 2472, 2536, 2600, 2664, 2728, 2792, 2856, 2976, \
|
||||
|
||||
@@ -965,11 +965,12 @@ typedef struct {
|
||||
|
||||
char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX];
|
||||
|
||||
|
||||
|
||||
unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
uint32_t ulsch_Msg3_frame[NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
uint8_t Msg3_startSymbol[NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
uint8_t Msg3_Length[NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
|
||||
NR_PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
int turbo_iterations, turbo_cntl_iterations;
|
||||
/// \brief ?.
|
||||
|
||||
@@ -3133,7 +3133,7 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) {
|
||||
NR_PRACH_RESOURCES_t *prach_resources = ue->prach_resources[gNB_index];
|
||||
uint16_t slots_per_frame = ue->frame_parms.slots_per_frame;
|
||||
|
||||
uint8_t mu_pusch = 1;
|
||||
uint8_t mu_pusch = 1, sliv_S, sliv_L;
|
||||
// definition table j Table 6.1.2.1.1-4
|
||||
uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1;
|
||||
uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1
|
||||
@@ -3186,6 +3186,9 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) {
|
||||
// PUSCH time domain resource allocation A for normal CP
|
||||
// TS 38.214 ch 6.1.2.1.1
|
||||
k2 = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][0];
|
||||
sliv_S = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][1];
|
||||
sliv_L = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][2];
|
||||
|
||||
switch (mu_pusch) {
|
||||
case 0:
|
||||
delta = 2;
|
||||
@@ -3201,6 +3204,8 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) {
|
||||
break;
|
||||
}
|
||||
|
||||
ue->Msg3_startSymbol[gNB_index] = sliv_S;
|
||||
ue->Msg3_Length[gNB_index] = sliv_L;
|
||||
ue->ulsch_Msg3_subframe[gNB_index] = (nr_tti_rx + k2 + delta) % slots_per_frame;
|
||||
if (nr_tti_rx + k2 + delta > slots_per_frame){
|
||||
ue->ulsch_Msg3_frame[gNB_index] = (frame_rx + 1) % 1024;
|
||||
|
||||
@@ -161,10 +161,10 @@ typedef struct {
|
||||
|
||||
// TS 38.321 ch. 6.2.3
|
||||
typedef struct {
|
||||
uint8_t TA1:7; // octet 1 [6:0]
|
||||
uint8_t R:1; // octet 1 [7]
|
||||
uint8_t TA1:7; // octet 1 [7:0]
|
||||
uint8_t TA2:5; // octet 2 [7:2]
|
||||
uint8_t UL_GRANT_1:3; // octet 2 [2:0]
|
||||
uint8_t TA2:5; // octet 2 [7:3]
|
||||
uint8_t UL_GRANT_2:8; // octet 3 [7:0]
|
||||
uint8_t UL_GRANT_3:8; // octet 4 [7:0]
|
||||
uint8_t UL_GRANT_4:8; // octet 5 [7:0]
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
uint16_t config_bandwidth(int mu, int nb_rb, int nr_band);
|
||||
|
||||
void get_band(uint64_t downlink_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type);
|
||||
|
||||
uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn);
|
||||
|
||||
uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw);
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
|
||||
//#include "mac_defs.h"
|
||||
#include "NR_MAC_UE/mac_proto.h"
|
||||
|
||||
#include "NR_MAC-CellGroupConfig.h"
|
||||
|
||||
#include "LAYER2/NR_MAC_COMMON/nr_mac_common.h"
|
||||
#include "SCHED_NR/phy_frame_config_nr.h"
|
||||
|
||||
@@ -203,12 +201,20 @@ void config_common_ue(NR_UE_MAC_INST_t *mac,
|
||||
}
|
||||
}
|
||||
|
||||
lte_frame_type_t frame_type;
|
||||
uint16_t band;
|
||||
int32_t offset;
|
||||
|
||||
get_band((cfg->carrier_config.dl_frequency)*1000,
|
||||
&band,
|
||||
&offset,
|
||||
&frame_type);
|
||||
|
||||
|
||||
// cell config
|
||||
|
||||
cfg->cell_config.phy_cell_id = *scc->physCellId;
|
||||
cfg->cell_config.frame_duplex_type = 1;
|
||||
|
||||
cfg->cell_config.frame_duplex_type = frame_type;
|
||||
|
||||
// SSB config
|
||||
cfg->ssb_config.ss_pbch_power = scc->ss_PBCH_BlockPower;
|
||||
@@ -270,6 +276,54 @@ void config_common_ue(NR_UE_MAC_INST_t *mac,
|
||||
LOG_I(PHY,"TDD has been properly configurated\n");
|
||||
}
|
||||
|
||||
// PRACH configuration
|
||||
|
||||
uint8_t nb_preambles = 64;
|
||||
if(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles != NULL)
|
||||
nb_preambles = *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles;
|
||||
|
||||
cfg->prach_config.prach_sequence_length = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present-1;
|
||||
|
||||
if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing)
|
||||
cfg->prach_config.prach_sub_c_spacing = *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing;
|
||||
else
|
||||
cfg->prach_config.prach_sub_c_spacing = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing;
|
||||
|
||||
cfg->prach_config.restricted_set_config = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->restrictedSetConfig;
|
||||
|
||||
switch (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM) {
|
||||
case 0 :
|
||||
cfg->prach_config.num_prach_fd_occasions = 1;
|
||||
break;
|
||||
case 1 :
|
||||
cfg->prach_config.num_prach_fd_occasions = 2;
|
||||
break;
|
||||
case 2 :
|
||||
cfg->prach_config.num_prach_fd_occasions = 4;
|
||||
break;
|
||||
case 3 :
|
||||
cfg->prach_config.num_prach_fd_occasions = 8;
|
||||
break;
|
||||
default:
|
||||
AssertFatal(1==0,"msg1 FDM identifier %ld undefined (0,1,2,3) \n", scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM);
|
||||
}
|
||||
|
||||
cfg->prach_config.num_prach_fd_occasions_list = (fapi_nr_num_prach_fd_occasions_t *) malloc(cfg->prach_config.num_prach_fd_occasions*sizeof(fapi_nr_num_prach_fd_occasions_t));
|
||||
for (i=0; i<cfg->prach_config.num_prach_fd_occasions; i++) {
|
||||
cfg->prach_config.num_prach_fd_occasions_list[i].num_prach_fd_occasions = i;
|
||||
if (cfg->prach_config.prach_sequence_length)
|
||||
cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139;
|
||||
else
|
||||
cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l839;
|
||||
|
||||
cfg->prach_config.num_prach_fd_occasions_list[i].k1 = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FrequencyStart;
|
||||
cfg->prach_config.num_prach_fd_occasions_list[i].prach_zero_corr_conf = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.zeroCorrelationZoneConfig;
|
||||
cfg->prach_config.num_prach_fd_occasions_list[i].num_root_sequences = compute_nr_root_seq(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup,
|
||||
nb_preambles, frame_type);
|
||||
//cfg->prach_config.num_prach_fd_occasions_list[i].num_unused_root_sequences = ???
|
||||
}
|
||||
|
||||
cfg->prach_config.ssb_per_rach = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present-1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,8 @@ typedef struct {
|
||||
uint8_t RA_contention_resolution_cnt;
|
||||
/// Msg3 Delta Preamble
|
||||
int8_t deltaPreamble_Msg3;
|
||||
/// Received TPC command (in dB) from RAR
|
||||
int8_t Msg3_TPC;
|
||||
/// Flag to monitor if matching RAPID was received in RAR
|
||||
uint8_t RA_RAPID_found;
|
||||
/// Flag to monitor if BI was received in RAR
|
||||
|
||||
@@ -65,8 +65,33 @@ uint16_t table_7_2_1[16] = {
|
||||
1920, // row index 13
|
||||
};
|
||||
|
||||
/////////////////////////////////////
|
||||
// Random Access Response PDU //
|
||||
// TS 38.213 ch 8.2 //
|
||||
// TS 38.321 ch 6.2.3 //
|
||||
/////////////////////////////////////
|
||||
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |// bit-wise
|
||||
//| E | T | R A P I D |//
|
||||
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |//
|
||||
//| R | T A |//
|
||||
//| T A | UL grant |//
|
||||
//| UL grant |//
|
||||
//| UL grant |//
|
||||
//| UL grant |//
|
||||
//| T C - R N T I |//
|
||||
//| T C - R N T I |//
|
||||
/////////////////////////////////////
|
||||
// UL grant (27 bits) //
|
||||
/////////////////////////////////////
|
||||
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |// bit-wise
|
||||
//|-------------------|FHF|F_alloc|//
|
||||
//| Freq allocation |//
|
||||
//| F_alloc |Time allocation|//
|
||||
//| MCS | TPC |CSI|//
|
||||
/////////////////////////////////////
|
||||
// WIP todo:
|
||||
// - UL grant
|
||||
// - apply UL grant freq alloc & time alloc as per 8.2 TS 38.213
|
||||
// - apply tpc command, csi req, mcs
|
||||
uint16_t nr_ue_process_rar(module_id_t mod_id,
|
||||
int CC_id,
|
||||
frame_t frameP,
|
||||
@@ -81,7 +106,9 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
|
||||
uint8_t n_subPDUs = 0; // number of RAR payloads
|
||||
uint8_t n_subheaders = 0; // number of MAC RAR subheaders
|
||||
uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs
|
||||
uint16_t ta_command = 0;
|
||||
unsigned char freq_hopping, msg3_t_alloc, mcs, tpc_command, csi_req;
|
||||
uint16_t ta_command = 0, msg3_f_alloc, bwp_size;
|
||||
int f_alloc, mask;
|
||||
|
||||
AssertFatal(CC_id == 0, "RAR reception on secondary CCs is not supported yet\n");
|
||||
|
||||
@@ -102,12 +129,8 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
|
||||
ue_mac->RA_RAPID_found = 1;
|
||||
break;
|
||||
}
|
||||
// if (abs((int) rarh->RAPID - (int) preamble_index) < abs((int) best_rx_rapid - (int) preamble_index)) {
|
||||
// best_rx_rapid = rarh->RAPID;
|
||||
// rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR));
|
||||
// }
|
||||
if (rarh->E == 0) {
|
||||
LOG_I(PHY, "No RAR found with the intended RAPID. The closest RAPID in all RARs is %d\n", best_rx_rapid);
|
||||
LOG_I(PHY, "No RAR found with the intended RAPID. \n");
|
||||
break;
|
||||
} else {
|
||||
rarh += sizeof(NR_MAC_RAR) + 1;
|
||||
@@ -120,10 +143,58 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
|
||||
// mod_id, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
|
||||
|
||||
if (ue_mac->RA_RAPID_found) {
|
||||
// TC-RNTI
|
||||
*t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
|
||||
ue_mac->t_crnti = *t_crnti;
|
||||
ue_mac->rnti_type = NR_RNTI_TC;
|
||||
// TA command
|
||||
ta_command = rar->TA2 + (rar->TA1 << 5);
|
||||
// CSI
|
||||
csi_req = (unsigned char) (rar->UL_GRANT_4 & 0x01);
|
||||
// TPC
|
||||
tpc_command = (unsigned char) ((rar->UL_GRANT_4 >> 1) & 0x07);
|
||||
switch (tpc_command){
|
||||
case 0:
|
||||
ue_mac->Msg3_TPC = -6;
|
||||
break;
|
||||
case 1:
|
||||
ue_mac->Msg3_TPC = -4;
|
||||
break;
|
||||
case 2:
|
||||
ue_mac->Msg3_TPC = -2;
|
||||
break;
|
||||
case 3:
|
||||
ue_mac->Msg3_TPC = 0;
|
||||
break;
|
||||
case 4:
|
||||
ue_mac->Msg3_TPC = 2;
|
||||
break;
|
||||
case 5:
|
||||
ue_mac->Msg3_TPC = 4;
|
||||
break;
|
||||
case 6:
|
||||
ue_mac->Msg3_TPC = 6;
|
||||
break;
|
||||
case 7:
|
||||
ue_mac->Msg3_TPC = 8;
|
||||
break;
|
||||
}
|
||||
//MCS
|
||||
mcs = (unsigned char) (rar->UL_GRANT_4 >> 4);
|
||||
// time and frequency alloc
|
||||
bwp_size = NRRIV2BW(ue_mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275);
|
||||
msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x07);
|
||||
msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12));
|
||||
|
||||
if (bwp_size < 180)
|
||||
mask = (1 << ((int) ceil(log2((bwp_size*(bwp_size+1))>>1)))) - 1;
|
||||
else
|
||||
mask = (1 << (28 - (int)(ceil(log2((bwp_size*(bwp_size+1))>>1))))) - 1;
|
||||
|
||||
f_alloc = msg3_f_alloc & mask;
|
||||
|
||||
// frequency hopping flag
|
||||
freq_hopping = (unsigned char) (rar->UL_GRANT_1 >> 2);
|
||||
} else {
|
||||
ue_mac->t_crnti = 0;
|
||||
ta_command = (0xffff);
|
||||
|
||||
@@ -186,23 +186,6 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t
|
||||
|
||||
AssertFatal(ra->state != RA_IDLE, "RA is not active for RA %X\n", ra->rnti);
|
||||
|
||||
// if(N_RB_UL == 25) {
|
||||
// ra->msg3_first_rb = 1;
|
||||
// } else {
|
||||
// if (cc->tdd_Config && N_RB_UL == 100) {
|
||||
// ra->msg3_first_rb = 3;
|
||||
// } else {
|
||||
// ra->msg3_first_rb = 2;
|
||||
// }
|
||||
// }
|
||||
// ra->msg3_nb_rb = 1;
|
||||
// /* UL Grant */
|
||||
// ra->msg3_mcs = 10;
|
||||
// ra->msg3_TPC = 3;
|
||||
// ra->msg3_ULdelay = 0;
|
||||
// ra->msg3_cqireq = 0;
|
||||
// ra->msg3_round = 0;
|
||||
|
||||
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;
|
||||
@@ -456,7 +439,7 @@ void nr_generate_Msg2(module_id_t module_idP,
|
||||
// Program UL processing for Msg3
|
||||
// nr_get_Msg3alloc(&cc[CC_id], slotP, frameP,&ra->Msg3_frame, &ra->Msg3_slot); // todo
|
||||
LOG_D(MAC, "Frame %d, Subframe %d: Setting Msg3 reception for Frame %d Subframe %d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot);
|
||||
nr_fill_rar(ra, cc[CC_id].RAR_pdu.payload, N_RB_UL);
|
||||
nr_fill_rar(module_idP, ra, cc[CC_id].RAR_pdu.payload, N_RB_UL);
|
||||
nr_add_msg3(module_idP, CC_id, frameP, slotP);
|
||||
ra->state = WAIT_Msg3;
|
||||
LOG_D(MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state);
|
||||
@@ -486,40 +469,89 @@ void nr_clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP){
|
||||
ra->msg3_round = 0;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Random Access Response PDU //
|
||||
// TS 38.213 ch 8.2 //
|
||||
// TS 38.321 ch 6.2.3 //
|
||||
/////////////////////////////////////
|
||||
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |// bit-wise
|
||||
//| E | T | R A P I D |//
|
||||
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |//
|
||||
//| R | T A |//
|
||||
//| T A | UL grant |//
|
||||
//| UL grant |//
|
||||
//| UL grant |//
|
||||
//| UL grant |//
|
||||
//| T C - R N T I |//
|
||||
//| T C - R N T I |//
|
||||
/////////////////////////////////////
|
||||
// UL grant (27 bits) //
|
||||
/////////////////////////////////////
|
||||
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |// bit-wise
|
||||
//|-------------------|FHF|F_alloc|//
|
||||
//| Freq allocation |//
|
||||
//| F_alloc |Time allocation|//
|
||||
//| MCS | TPC |CSI|//
|
||||
/////////////////////////////////////
|
||||
// WIP
|
||||
// todo:
|
||||
// - handle MAC RAR BI subheader
|
||||
// - sending only 1 RAR subPDU
|
||||
// - UL Grant
|
||||
// - UL Grant: hardcoded CSI, TPC, time alloc
|
||||
// - padding
|
||||
void nr_fill_rar(NR_RA_t * ra,
|
||||
void nr_fill_rar(uint8_t Mod_idP,
|
||||
NR_RA_t * ra,
|
||||
uint8_t * dlsch_buffer,
|
||||
uint16_t N_RB_UL){
|
||||
|
||||
LOG_D(MAC, "[gNB] Generate RAR MAC PDU frame %d slot %d ", ra->Msg2_frame, ra-> Msg2_slot);
|
||||
NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer;
|
||||
NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1);
|
||||
LOG_D(MAC, "[gNB] Generate RAR MAC PDU frame %d slot %d ", ra->Msg2_frame, ra-> Msg2_slot);
|
||||
nfapi_nr_ul_tti_request_t *UL_tti_req = &RC.nrmac[Mod_idP]->UL_tti_req[0];
|
||||
nfapi_nr_pusch_pdu_t *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu;
|
||||
NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer;
|
||||
NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1);
|
||||
unsigned char frequency_hopping_flag = 0, csi_req = 0, tpc_command = 0, mcs = 9, t_alloc = 0;
|
||||
uint8_t N_UL_Hop;
|
||||
uint16_t ul_grant, f_alloc, prb_alloc;
|
||||
int bwp_size;
|
||||
|
||||
// E/T/RAPID subheader
|
||||
// E = 0, one only RAR, first and last
|
||||
// T = 1, RAPID
|
||||
rarh->E = 0;
|
||||
rarh->T = 1;
|
||||
rarh->RAPID = ra->preamble_index;
|
||||
/// E/T/RAPID subheader ///
|
||||
// E = 0, one only RAR, first and last
|
||||
// T = 1, RAPID
|
||||
rarh->E = 0;
|
||||
rarh->T = 1;
|
||||
rarh->RAPID = ra->preamble_index;
|
||||
|
||||
// RAR MAC payload
|
||||
rar->R = 0;
|
||||
rar->TA1 = (uint8_t) (ra->timing_offset >> 5); // 7 MSBs of timing advance
|
||||
rar->TA2 = (uint8_t) (ra->timing_offset & 0x1f); // 5 LSBs of timing advance
|
||||
rar->TCRNTI_1 = (uint8_t) (ra->rnti >> 8); // 8 MSBs of rnti
|
||||
rar->TCRNTI_2 = (uint8_t) (ra->rnti & 0xff); // 8 LSBs of rnti
|
||||
/// RAR MAC payload ///
|
||||
rar->R = 0;
|
||||
|
||||
// uint16_t rballoc = nr_mac_compute_RIV(N_RB_UL, ra->msg3_first_rb, ra->msg3_nb_rb); // first PRB only for UL Grant
|
||||
// uint32_t buffer = 0;
|
||||
// rar->UL_GRANT_1 = (uint8_t) (buffer >> 24) & 0x7;
|
||||
// rar->UL_GRANT_2 = (uint8_t) (buffer >> 16) & 0xFF;
|
||||
// rar->UL_GRANT_3 = (uint8_t) (buffer >> 8) & 0xFF;
|
||||
// rar->UL_GRANT_4 = (uint8_t) buffer & 0xff;
|
||||
// TA command
|
||||
rar->TA1 = (uint8_t) (ra->timing_offset >> 5); // 7 MSBs of timing advance
|
||||
rar->TA2 = (uint8_t) (ra->timing_offset & 0x1f); // 5 LSBs of timing advance
|
||||
|
||||
}
|
||||
// TC-RNTI
|
||||
rar->TCRNTI_1 = (uint8_t) (ra->rnti >> 8); // 8 MSBs of rnti
|
||||
rar->TCRNTI_2 = (uint8_t) (ra->rnti & 0xff); // 8 LSBs of rnti
|
||||
|
||||
// UL grant
|
||||
|
||||
ra->msg3_mcs = mcs;
|
||||
ra->msg3_TPC = tpc_command;
|
||||
|
||||
bwp_size = pusch_pdu->bwp_size;
|
||||
prb_alloc = PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, bwp_size);
|
||||
if (frequency_hopping_flag){
|
||||
// PUSCH with frequency hopping
|
||||
} else {
|
||||
N_UL_Hop = 0;
|
||||
}
|
||||
|
||||
f_alloc = (prb_alloc & 0xfff) | (N_UL_Hop << 12);
|
||||
ul_grant = csi_req | (tpc_command << 1) | (mcs << 4) | (t_alloc << 8) | (f_alloc << 12) | (frequency_hopping_flag << 26);
|
||||
|
||||
rar->UL_GRANT_1 = (uint8_t) (ul_grant >> 24) & 0x07;
|
||||
rar->UL_GRANT_2 = (uint8_t) (ul_grant >> 16) & 0xff;
|
||||
rar->UL_GRANT_3 = (uint8_t) (ul_grant >> 8) & 0xff;
|
||||
rar->UL_GRANT_4 = (uint8_t) ul_grant & 0xff;
|
||||
|
||||
}
|
||||
@@ -941,7 +941,6 @@ int to_absslot(nfapi_nr_config_request_scf_t *cfg,int frame,int slot) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
int extract_startSymbol(int startSymbolAndLength) {
|
||||
int tmp = startSymbolAndLength/14;
|
||||
int tmp2 = startSymbolAndLength%14;
|
||||
|
||||
@@ -107,7 +107,8 @@ void nr_get_Msg3alloc(NR_COMMON_channels_t *cc,
|
||||
@param dlsch_buffer Pointer to RAR input buffer
|
||||
@param N_RB_UL Number of UL resource blocks
|
||||
*/
|
||||
void nr_fill_rar(NR_RA_t * ra,
|
||||
void nr_fill_rar(uint8_t Mod_idP,
|
||||
NR_RA_t * ra,
|
||||
uint8_t * dlsch_buffer,
|
||||
uint16_t N_RB_UL);
|
||||
|
||||
@@ -179,8 +180,6 @@ int get_spf(nfapi_nr_config_request_scf_t *cfg);
|
||||
|
||||
int to_absslot(nfapi_nr_config_request_scf_t *cfg,int frame,int slot);
|
||||
|
||||
void get_band(uint64_t downlink_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type);
|
||||
|
||||
void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
|
||||
int x_overhead);
|
||||
/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */
|
||||
|
||||
Reference in New Issue
Block a user