Merge remote-tracking branch 'origin/fix-tx-timing-offset-issues' into integration_2024_w09

This commit is contained in:
Jaroslava Fiedlerova
2024-03-04 16:07:34 +01:00
42 changed files with 627 additions and 507 deletions
+7 -2
View File
@@ -384,11 +384,16 @@ typedef struct {
short ssb_rsrp_dBm;
} NR_SSB_meas_t;
typedef enum ta_type {
no_ta = 0,
adjustment_ta,
rar_ta,
} ta_type_t;
typedef struct NR_UL_TIME_ALIGNMENT {
/// TA command and TAGID received from the gNB
bool ta_apply;
ta_type_t ta_apply;
int ta_command;
int ta_total;
uint32_t tag_id;
int frame;
int slot;
-1
View File
@@ -401,7 +401,6 @@ and fills the PRACH PDU per each FD occasion.
void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, int slotP, void *phy_data);
void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot);
void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot);
void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
/* \brief This function schedules the Msg3 transmission
@param
+9 -27
View File
@@ -3645,14 +3645,7 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i
}
if (mac_len > 0) {
LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_len);
for (int i = 0; i < mac_subheader_len; i++) {
LOG_D(NR_MAC, "MAC header %d: 0x%x\n", i, pduP[i]);
}
for (int i = 0; i < mac_len; i++) {
LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]);
}
LOG_DDUMP(NR_MAC, (void *)pduP, mac_subheader_len + mac_len, LOG_DUMP_CHAR, "DL_SCH_LCID_CCCH (e.g. RRCSetup) payload: ");
mac_rlc_data_ind(mac->ue_id,
mac->ue_id,
gNB_index,
@@ -3729,12 +3722,11 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i
const int tag = ((NR_MAC_CE_TA *)pduP)[1].TAGID;
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment;
ul_time_alignment->ta_total += ta - 31;
ul_time_alignment->tag_id = tag;
ul_time_alignment->ta_command = ta;
ul_time_alignment->frame = frameP;
ul_time_alignment->slot = slot;
ul_time_alignment->ta_apply = true;
ul_time_alignment->ta_apply = adjustment_ta;
/*
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i, pduP[1]);
@@ -3742,21 +3734,9 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i
*/
if (ta == 31)
LOG_D(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n",
frameP,
slot,
ta,
tag,
CC_id,
ul_time_alignment->ta_total);
LOG_D(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d \n", frameP, slot, ta, tag, CC_id);
else
LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n",
frameP,
slot,
ta,
tag,
CC_id,
ul_time_alignment->ta_total);
LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d \n", frameP, slot, ta, tag, CC_id);
break;
case DL_SCH_LCID_CON_RES_ID:
@@ -4136,9 +4116,9 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d
// TA command
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment;
const int ta = rar->TA2 + (rar->TA1 << 5);
ul_time_alignment->ta_command = 31 + ta;
ul_time_alignment->ta_total = ta;
ul_time_alignment->ta_apply = true;
ul_time_alignment->ta_command = ta;
ul_time_alignment->ta_apply = rar_ta;
LOG_W(MAC, "received TA command %d\n", 31 + ta);
#ifdef DEBUG_RAR
// CSI
@@ -4228,6 +4208,8 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d
return;
}
ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2);
ul_time_alignment->frame = frame_tx;
ul_time_alignment->slot = slot_tx;
if (ret != -1) {
uint16_t rnti = mac->crnti;
+5 -3
View File
@@ -58,6 +58,7 @@
//#define SRS_DEBUG
static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_frame_t slotP);
static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx, uint8_t pdu_type)
{
@@ -1018,7 +1019,7 @@ void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info
ue_dci_configuration(mac, dl_config, rx_frame, rx_slot);
if (mac->ul_time_alignment.ta_apply)
if (mac->ul_time_alignment.ta_apply != no_ta)
schedule_ta_command(dl_config, &mac->ul_time_alignment);
if (mac->state == UE_CONNECTED) {
nr_schedule_csirs_reception(mac, rx_frame, rx_slot);
@@ -3357,15 +3358,16 @@ uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac,
return num_sdus > 0 ? 1 : 0;
}
void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment)
static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment)
{
fapi_nr_ta_command_pdu *ta = &dl_config->dl_config_list[dl_config->number_pdus].ta_command_pdu;
ta->ta_frame = ul_time_alignment->frame;
ta->ta_slot = ul_time_alignment->slot;
ta->is_rar = ul_time_alignment->ta_apply == rar_ta;
ta->ta_command = ul_time_alignment->ta_command;
dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_CONFIG_TA_COMMAND;
dl_config->number_pdus += 1;
ul_time_alignment->ta_apply = false;
ul_time_alignment->ta_apply = no_ta;
}
uint32_t nr_get_pbr(long prioritizedbitrate)
+310 -253
View File
@@ -104,263 +104,320 @@ nfapi_nr_pm_list_t init_DL_MIMO_codebook(gNB_MAC_INST *gNB, nr_pdsch_AntennaPort
nfapi_nr_pm_pdu_t *pmi_pdu = malloc16(mat.num_pm_idx * sizeof(*pmi_pdu));
AssertFatal(pmi_pdu != NULL, "out of memory\n");
mat.pmi_pdu = pmi_pdu;
AssertFatal(num_antenna_ports < 16, "Max number of antenna ports supported is currently 16\n");
// Generation of codebook Type1 with codebookMode 1 (num_antenna_ports < 16)
if (num_antenna_ports < 16) {
//Generate DFT vertical beams
//ll: index of a vertical beams vector (represented by i1_1 in TS 38.214)
const int max_l = N1 * O1 + (K1 - 1) * O1;
double complex v[max_l][N1];
for (int ll = 0; ll < max_l; ll++) { //i1_1
for (int nn = 0; nn < N1; nn++) {
v[ll][nn] = cexp(I * (2 * M_PI * nn * ll) / (N1 * O1));
LOG_D(PHY,"v[%d][%d] = %f +j %f\n", ll, nn, creal(v[ll][nn]), cimag(v[ll][nn]));
}
// Generate DFT vertical beams
// ll: index of a vertical beams vector (represented by i1_1 in TS 38.214)
const int max_l = N1 * O1 + (K1 - 1) * O1;
double complex v[max_l][N1];
for (int ll = 0; ll < max_l; ll++) { // i1_1
for (int nn = 0; nn < N1; nn++) {
v[ll][nn] = cexp(I * (2 * M_PI * nn * ll) / (N1 * O1));
LOG_D(PHY, "v[%d][%d] = %f +j %f\n", ll, nn, creal(v[ll][nn]), cimag(v[ll][nn]));
}
//Generate DFT Horizontal beams
//mm: index of a Horizontal beams vector (represented by i1_2 in TS 38.214)
const int max_m = N2 * O2 + (K2 - 1) * O2;
double complex u[max_m][N2];
for (int mm = 0; mm < max_m; mm++) { //i1_2
for (int nn = 0; nn < N2; nn++) {
u[mm][nn] = cexp(I * (2 * M_PI * nn * mm) / (N2 * O2));
LOG_D(PHY,"u[%d][%d] = %f +j %f\n", mm, nn, creal(u[mm][nn]), cimag(u[mm][nn]));
}
}
//Generate co-phasing angles
//i_2: index of a co-phasing vector
//i1_1, i1_2, and i_2 are reported from UEs
double complex theta_n[4];
for (int nn = 0; nn < 4; nn++) {
theta_n[nn] = cexp(I * M_PI * nn / 2);
LOG_D(PHY,"theta_n[%d] = %f +j %f\n", nn, creal(theta_n[nn]), cimag(theta_n[nn]));
}
//Kronecker product v_lm
double complex v_lm[max_l][max_m][N2 * N1];
//v_ll_mm_codebook denotes the elements of a precoding matrix W_i1,1_i_1,2
for(int ll = 0; ll < max_l; ll++) { //i_1_1
for (int mm = 0; mm < max_m; mm++) { //i_1_2
for (int nn1 = 0; nn1 < N1; nn1++) {
for (int nn2 = 0; nn2 < N2; nn2++) {
v_lm[ll][mm][nn1 * N2 + nn2] = v[ll][nn1] * u[mm][nn2];
LOG_D(PHY,"v_lm[%d][%d][%d] = %f +j %f\n",ll, mm, nn1 * N2 + nn2, creal(v_lm[ll][mm][nn1*N2+nn2]), cimag(v_lm[ll][mm][nn1*N2+nn2]));
}
}
}
}
double complex res_code;
//Table 5.2.2.2.1-5:
int pmiq = 0;
//Codebook for 1-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
for(int ll = 0; ll < N1 * O1; ll++) { //i_1_1
for (int mm = 0; mm < N2 * O2; mm++) { //i_1_2
for (int nn = 0; nn < 4; nn++) {
pmiq = ll * N2 * O2 * 4 + mm * 4 + nn;
pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix
pmi_pdu[pmiq].numLayers = 1;
pmi_pdu[pmiq].num_ant_ports = num_antenna_ports;
LOG_D(PHY, "layer 1 Codebook pmiq = %d\n", pmiq);
for (int len = 0; len < N1 * N2; len++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[0][len];
res_code = sqrt( 1 /(double)num_antenna_ports) * v_lm[ll][mm][len];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq, len, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im);
}
for(int len = N1 * N2; len < 2 * N1 * N2; len++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[0][len];
res_code = sqrt(1 / (double)num_antenna_ports) * theta_n[nn] * v_lm[ll][mm][len-N1*N2];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq, len, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im);
}
}
}
}
int llc = 0;
int mmc = 0;
double complex phase_sign = 0;
//Table 5.2.2.2.1-6:
//Codebook for 2-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
//Compute the code book size for generating 2 layers out of Tx antenna ports
//pmi=1,...,pmi_size, we construct
for(int ll = 0; ll < N1 * O1; ll++) { //i_1_1
for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2
for(int k1 = 0; k1 < K1; k1++) {
for (int k2 = 0; k2 < K2; k2++) {
for (int nn = 0; nn < 2; nn++) { // i_2
pmiq ++;
pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix
pmi_pdu[pmiq].numLayers = 2;
pmi_pdu[pmiq].num_ant_ports = num_antenna_ports;
LOG_D(PHY, "layer 2 Codebook pmiq = %d\n", pmiq);
for(int j_col = 0; j_col < 2; j_col++) {
if (j_col == 0) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col == 1) {
llc = ll + k1 * O1;
mmc = mm + k2 * O2;
phase_sign = -1;
}
for (int i_rows = 0; i_rows < N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(2 * num_antenna_ports)) * v_lm[llc][mmc][i_rows];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im);
}
for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(2 * num_antenna_ports)) * (phase_sign) * theta_n[nn] * v_lm[llc][mmc][i_rows - N1 * N2];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im);
}
}
}
}
}
}
}
if(max_mimo_layers < 3)
return mat;
//Table 5.2.2.2.1-7:
//Codebook for 3-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
//pmi=1,...,pmi_size are computed as follows
for(int ll = 0; ll < N1 * O1; ll++) { //i_1_1
for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2
for(int k1 = 0; k1 < K1; k1++) {
for (int k2 = 0; k2 < K2; k2++) {
for (int nn = 0; nn < 2; nn++) { // i_2
pmiq ++;
pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix
pmi_pdu[pmiq].numLayers = 3;
pmi_pdu[pmiq].num_ant_ports = num_antenna_ports;
LOG_D(PHY, "layer 3 Codebook pmiq = %d\n",pmiq);
for(int j_col = 0; j_col < 3; j_col++) {
if (j_col == 0) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col==1) {
llc = ll + k1 * O1;
mmc = mm + k2 * O2;
phase_sign = 1;
}
if (j_col==2) {
llc = ll;
mmc = mm;
phase_sign = -1;
}
for (int i_rows = 0; i_rows < N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(3 * num_antenna_ports)) * v_lm[llc][mmc][i_rows];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY, "3 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im);
}
for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code=sqrt(1 / (double)(3 * num_antenna_ports)) * (phase_sign) * theta_n[nn] * v_lm[llc][mmc][i_rows - N1 * N2];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY, "3 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im);
}
}
}
}
}
}
}
if(max_mimo_layers < 4)
return mat;
//Table 5.2.2.2.1-8:
//Codebook for 4-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
for(int ll = 0; ll < N1 * O1; ll++) { //i_1_1
for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2
for(int k1 = 0; k1 < K1; k1++) {
for (int k2 = 0; k2 < K2; k2++) {
for (int nn = 0; nn < 2; nn++) { // i_2
pmiq ++;
pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix
pmi_pdu[pmiq].numLayers = 4;
pmi_pdu[pmiq].num_ant_ports = num_antenna_ports;
LOG_D(PHY, "layer 4 pmiq = %d\n", pmiq);
for(int j_col = 0; j_col < 4; j_col++) {
if (j_col == 0) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col == 1) {
llc = ll + k1 * O1;
mmc = mm + k2 * O2;
phase_sign = 1;
}
if (j_col == 2) {
llc = ll;
mmc = mm;
phase_sign = -1;
}
if (j_col == 3) {
llc = ll + k1 * O1;
mmc = mm + k2 * O2;
phase_sign = -1;
}
for (int i_rows = 0; i_rows < N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code=sqrt(1 / (double)(4 * num_antenna_ports)) * v_lm[llc][mmc][i_rows];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY, "4 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im);
}
for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code=sqrt(1 / (double)(4 * num_antenna_ports)) * (phase_sign) * theta_n[nn] * v_lm[llc][mmc][i_rows - N1 * N2];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY, "4 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im);
}
}
}
}
}
}
}
return mat;
}
else
AssertFatal(false, "Max number of antenna ports supported is currently 16\n");
// Generate DFT Horizontal beams
// mm: index of a Horizontal beams vector (represented by i1_2 in TS 38.214)
const int max_m = N2 * O2 + (K2 - 1) * O2;
double complex u[max_m][N2];
for (int mm = 0; mm < max_m; mm++) { // i1_2
for (int nn = 0; nn < N2; nn++) {
u[mm][nn] = cexp(I * (2 * M_PI * nn * mm) / (N2 * O2));
LOG_D(PHY, "u[%d][%d] = %f +j %f\n", mm, nn, creal(u[mm][nn]), cimag(u[mm][nn]));
}
}
// Generate co-phasing angles
// i_2: index of a co-phasing vector
// i1_1, i1_2, and i_2 are reported from UEs
double complex theta_n[4];
for (int nn = 0; nn < 4; nn++) {
theta_n[nn] = cexp(I * M_PI * nn / 2);
LOG_D(PHY, "theta_n[%d] = %f +j %f\n", nn, creal(theta_n[nn]), cimag(theta_n[nn]));
}
// Kronecker product v_lm
double complex v_lm[max_l][max_m][N2 * N1];
// v_ll_mm_codebook denotes the elements of a precoding matrix W_i1,1_i_1,2
for (int ll = 0; ll < max_l; ll++) { // i_1_1
for (int mm = 0; mm < max_m; mm++) { // i_1_2
for (int nn1 = 0; nn1 < N1; nn1++) {
for (int nn2 = 0; nn2 < N2; nn2++) {
v_lm[ll][mm][nn1 * N2 + nn2] = v[ll][nn1] * u[mm][nn2];
LOG_D(PHY,
"v_lm[%d][%d][%d] = %f +j %f\n",
ll,
mm,
nn1 * N2 + nn2,
creal(v_lm[ll][mm][nn1 * N2 + nn2]),
cimag(v_lm[ll][mm][nn1 * N2 + nn2]));
}
}
}
}
double complex res_code;
// Table 5.2.2.2.1-5:
int pmiq = 0;
// Codebook for 1-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
for (int ll = 0; ll < N1 * O1; ll++) { // i_1_1
for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2
for (int nn = 0; nn < 4; nn++) {
pmiq = ll * N2 * O2 * 4 + mm * 4 + nn;
pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix
pmi_pdu[pmiq].numLayers = 1;
pmi_pdu[pmiq].num_ant_ports = num_antenna_ports;
LOG_D(PHY, "layer 1 Codebook pmiq = %d\n", pmiq);
for (int len = 0; len < N1 * N2; len++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[0][len];
res_code = sqrt(1 / (double)num_antenna_ports) * v_lm[ll][mm][len];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY,
"1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq,
len,
creal(res_code),
cimag(res_code),
weights->precoder_weight_Re,
weights->precoder_weight_Im);
}
for (int len = N1 * N2; len < 2 * N1 * N2; len++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[0][len];
res_code = sqrt(1 / (double)num_antenna_ports) * theta_n[nn] * v_lm[ll][mm][len - N1 * N2];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY,
"1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq,
len,
creal(res_code),
cimag(res_code),
weights->precoder_weight_Re,
weights->precoder_weight_Im);
}
}
}
}
int llc = 0;
int mmc = 0;
double complex phase_sign = 0;
// Table 5.2.2.2.1-6:
// Codebook for 2-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
// Compute the code book size for generating 2 layers out of Tx antenna ports
// pmi=1,...,pmi_size, we construct
for (int ll = 0; ll < N1 * O1; ll++) { // i_1_1
for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2
for (int k1 = 0; k1 < K1; k1++) {
for (int k2 = 0; k2 < K2; k2++) {
for (int nn = 0; nn < 2; nn++) { // i_2
pmiq++;
pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix
pmi_pdu[pmiq].numLayers = 2;
pmi_pdu[pmiq].num_ant_ports = num_antenna_ports;
LOG_D(PHY, "layer 2 Codebook pmiq = %d\n", pmiq);
for (int j_col = 0; j_col < 2; j_col++) {
if (j_col == 0) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col == 1) {
llc = ll + k1 * O1;
mmc = mm + k2 * O2;
phase_sign = -1;
}
for (int i_rows = 0; i_rows < N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(2 * num_antenna_ports)) * v_lm[llc][mmc][i_rows];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY,
"2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq,
i_rows,
j_col,
creal(res_code),
cimag(res_code),
weights->precoder_weight_Re,
weights->precoder_weight_Im);
}
for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(2 * num_antenna_ports)) * (phase_sign)*theta_n[nn] * v_lm[llc][mmc][i_rows - N1 * N2];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY,
"2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq,
i_rows,
j_col,
creal(res_code),
cimag(res_code),
weights->precoder_weight_Re,
weights->precoder_weight_Im);
}
}
}
}
}
}
}
if (max_mimo_layers < 3)
return mat;
// Table 5.2.2.2.1-7:
// Codebook for 3-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
// pmi=1,...,pmi_size are computed as follows
for (int ll = 0; ll < N1 * O1; ll++) { // i_1_1
for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2
for (int k1 = 0; k1 < K1; k1++) {
for (int k2 = 0; k2 < K2; k2++) {
for (int nn = 0; nn < 2; nn++) { // i_2
pmiq++;
pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix
pmi_pdu[pmiq].numLayers = 3;
pmi_pdu[pmiq].num_ant_ports = num_antenna_ports;
LOG_D(PHY, "layer 3 Codebook pmiq = %d\n", pmiq);
for (int j_col = 0; j_col < 3; j_col++) {
if (j_col == 0) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col == 1) {
llc = ll + k1 * O1;
mmc = mm + k2 * O2;
phase_sign = 1;
}
if (j_col == 2) {
llc = ll;
mmc = mm;
phase_sign = -1;
}
for (int i_rows = 0; i_rows < N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(3 * num_antenna_ports)) * v_lm[llc][mmc][i_rows];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY,
"3 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq,
i_rows,
j_col,
creal(res_code),
cimag(res_code),
weights->precoder_weight_Re,
weights->precoder_weight_Im);
}
for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(3 * num_antenna_ports)) * (phase_sign)*theta_n[nn] * v_lm[llc][mmc][i_rows - N1 * N2];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY,
"3 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq,
i_rows,
j_col,
creal(res_code),
cimag(res_code),
weights->precoder_weight_Re,
weights->precoder_weight_Im);
}
}
}
}
}
}
}
if (max_mimo_layers < 4)
return mat;
// Table 5.2.2.2.1-8:
// Codebook for 4-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
for (int ll = 0; ll < N1 * O1; ll++) { // i_1_1
for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2
for (int k1 = 0; k1 < K1; k1++) {
for (int k2 = 0; k2 < K2; k2++) {
for (int nn = 0; nn < 2; nn++) { // i_2
pmiq++;
pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix
pmi_pdu[pmiq].numLayers = 4;
pmi_pdu[pmiq].num_ant_ports = num_antenna_ports;
LOG_D(PHY, "layer 4 pmiq = %d\n", pmiq);
for (int j_col = 0; j_col < 4; j_col++) {
if (j_col == 0) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col == 1) {
llc = ll + k1 * O1;
mmc = mm + k2 * O2;
phase_sign = 1;
}
if (j_col == 2) {
llc = ll;
mmc = mm;
phase_sign = -1;
}
if (j_col == 3) {
llc = ll + k1 * O1;
mmc = mm + k2 * O2;
phase_sign = -1;
}
for (int i_rows = 0; i_rows < N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(4 * num_antenna_ports)) * v_lm[llc][mmc][i_rows];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY,
"4 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq,
i_rows,
j_col,
creal(res_code),
cimag(res_code),
weights->precoder_weight_Re,
weights->precoder_weight_Im);
}
for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) {
nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows];
res_code = sqrt(1 / (double)(4 * num_antenna_ports)) * (phase_sign)*theta_n[nn] * v_lm[llc][mmc][i_rows - N1 * N2];
c16_t precoder_weight = convert_precoder_weight(res_code);
weights->precoder_weight_Re = precoder_weight.r;
weights->precoder_weight_Im = precoder_weight.i;
LOG_D(PHY,
"4 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",
pmiq,
i_rows,
j_col,
creal(res_code),
cimag(res_code),
weights->precoder_weight_Re,
weights->precoder_weight_Im);
}
}
}
}
}
}
}
return mat;
}
static void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list,
+9 -20
View File
@@ -2062,29 +2062,18 @@ static void nr_fill_rar(uint8_t Mod_idP, NR_RA_t *ra, uint8_t *dlsch_buffer, nfa
LOG_I(NR_MAC, "rar->TCRNTI_1 = 0x%x\n", rar->TCRNTI_1);
LOG_I(NR_MAC, "rar->TCRNTI_2 = 0x%x\n", rar->TCRNTI_2);
#endif
int mcs = (unsigned char) (rar->UL_GRANT_4 >> 4);
// time alloc
int Msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x0f);
// frequency alloc
int Msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12));
// frequency hopping
int freq_hopping = (unsigned char) (rar->UL_GRANT_1 >> 2);
// TA command
int ta_command = rar->TA2 + (rar->TA1 << 5);
// TC-RNTI
int t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
LOG_D(NR_MAC, "In %s: Transmitted RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d csi_req %d t_crnti %x \n",
LOG_D(NR_MAC,
"In %s: Transmitted RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d csi_req %d t_crnti "
"%x \n",
__FUNCTION__,
Msg3_t_alloc,
Msg3_f_alloc,
ta_command,
mcs,
freq_hopping,
rar->UL_GRANT_3 & 0x0f,
(rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12),
rar->TA2 + (rar->TA1 << 5),
rar->UL_GRANT_4 >> 4,
rar->UL_GRANT_1 >> 2,
tpc_command,
csi_req,
t_crnti);
rar->TCRNTI_2 + (rar->TCRNTI_1 << 8));
}
void nr_schedule_RA(module_id_t module_idP,
+4 -2
View File
@@ -542,8 +542,10 @@ void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsign
int init_opt(void) {
paramdef_t opt_params[] = OPT_PARAMS_DESC ;
checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC;
config_set_checkfunctions(opt_params, opt_checkParams, sizeofArray(opt_params));
config_get(config_get_if(), opt_params, sizeofArray(opt_params), OPT_CONFIGPREFIX);
int sz=sizeofArray(opt_params);
AssertFatal(sz == sizeofArray(opt_checkParams), "Error in arrays size (%d!=%lu)\n", sz, sizeofArray(opt_checkParams));
config_set_checkfunctions(opt_params, opt_checkParams, sz);
config_get(config_get_if(), opt_params, sz, OPT_CONFIGPREFIX);
subframesSinceCaptureStart = 0;
int tmptype = config_get_processedint(config_get_if(), &(opt_params[OPTTYPE_IDX]));