Commit 603c7aec authored by francescomani's avatar francescomani

moving generation of precoding matrices at MAC and trying to adapt to SCF (1st version)

parent 90e67e28
......@@ -42,6 +42,7 @@
#define NR_MAX_HARQ_PROCESSES 16
#define NR_NB_REG_PER_CCE 6
#define NR_NB_SC_PER_RB 12
#define NR_MAX_NB_LAYERS 4 // 8
typedef enum {
nr_FR1 = 0,
......
......@@ -74,17 +74,17 @@ typedef enum {
NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION= 0X89,
//RESERVED 0X8a ~ 0xff
NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_REQUEST = 0x0100,
NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_RESPONSE = 0x0101,
NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_REQUEST= 0x0102,
NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_RESPONSE= 0x0103,
NFAPI_NR_PHY_MSG_TYPE_PNF_START_REQUEST= 0x0104,
NFAPI_NR_PHY_MSG_TYPE_PNF_START_RESPONSE= 0x0105,
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_REQUEST= 0x0106,
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_RESPONSE= 0x0107,
NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_RESPONSE = 0x0101,
NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_REQUEST= 0x0102,
NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_RESPONSE= 0x0103,
NFAPI_NR_PHY_MSG_TYPE_PNF_START_REQUEST= 0x0104,
NFAPI_NR_PHY_MSG_TYPE_PNF_START_RESPONSE= 0x0105,
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_REQUEST= 0x0106,
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_RESPONSE= 0x0107,
NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC = 0x0180,
NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC,
NFAPI_NR_PHY_MSG_TYPE_TIMING_INFO
NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC,
NFAPI_NR_PHY_MSG_TYPE_TIMING_INFO
} nfapi_nr_phy_msg_type_e;
// SCF222_5G-FAPI_PHY_SPI_Specificayion.pdf Section 3.3
......@@ -449,6 +449,26 @@ typedef struct
} nfapi_nr_measurement_config_t;
//table 3-33
typedef struct {
int16_t precoder_weight_Re;
int16_t precoder_weight_Im;
} nfapi_nr_pm_weights_t;
typedef struct {
uint16_t pm_idx;
uint16_t numLayers;
uint16_t num_ant_ports;
nfapi_nr_pm_weights_t weights[4][4]; // TODO temporary hardcoding
} nfapi_nr_pm_pdu_t;
typedef struct {
uint16_t num_pm_idx;
nfapi_nr_pm_pdu_t *pmi_pdu;
} nfapi_nr_pm_list_t;
// ERROR enums
typedef enum { // Table 2-22
NFAPI_NR_PARAM_MSG_OK = 0,
......@@ -559,6 +579,7 @@ typedef struct {
nfapi_nr_tdd_table_t tdd_table;
nfapi_nr_measurement_config_t measurement_config;
nfapi_nr_nfapi_t nfapi_config;
nfapi_nr_pm_list_t pmi_list;
} nfapi_nr_config_request_scf_t;
......@@ -588,24 +609,24 @@ typedef struct {
//3.3.4 STOP
typedef struct {
nfapi_p4_p5_message_header_t header;
nfapi_vendor_extension_tlv_t vendor_extension;
nfapi_p4_p5_message_header_t header;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_stop_request_t;
typedef struct {
nfapi_p4_p5_message_header_t header;
nfapi_vendor_extension_tlv_t vendor_extension;
nfapi_p4_p5_message_header_t header;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_stop_indication_t;
typedef enum {
NFAPI_NR_STOP_MSG_INVALID_STATE
NFAPI_NR_STOP_MSG_INVALID_STATE
} nfapi_nr_stop_errors_e;
//3.3.5 PHY Notifications
typedef enum {
NFAPI_NR_PHY_API_MSG_OK =0x0,
NFAPI_NR_PHY_API_MSG_INVALID_STATE =0x1,
NFAPI_NR_PHY_API_MSG_INVALID_STATE =0x1,
NFAPI_NR_PHY_API_MSG_INVALID_CONFIG =0x2,
NFAPI_NR_PHY_API_SFN_OUT_OF_SYNC =0X3,
NFAPI_NR_PHY_API_MSG_SLOR_ERR =0X4,
......@@ -616,7 +637,7 @@ typedef enum {
} nfapi_nr_phy_notifications_errors_e;
typedef struct {
uint16_t sfn; //0~1023
uint16_t sfn; //0~1023
uint16_t slot;//0~319
nfapi_nr_phy_msg_type_e msg_id;//Indicate which message received by the PHY has an error. Values taken from Table 3-4.
nfapi_nr_phy_notifications_errors_e error_code;
......@@ -628,42 +649,22 @@ typedef struct {
//table 3-32
//?
typedef struct {
uint16_t beam_idx; //0~65535
uint16_t beam_idx; //0~65535
} nfapi_nr_dig_beam_t;
typedef struct {
uint16_t dig_beam_weight_Re;
uint16_t dig_beam_weight_Re;
uint16_t dig_beam_weight_Im;
} nfapi_nr_txru_t;
typedef struct {
uint16_t num_dig_beams; //0~65535
uint16_t num_dig_beams; //0~65535
uint16_t num_txrus; //0~65535
nfapi_nr_dig_beam_t* dig_beam_list;
nfapi_nr_txru_t* txru_list;
} nfapi_nr_dbt_pdu_t;
//table 3-33
//?
typedef struct {
uint16_t num_ant_ports;
int16_t precoder_weight_Re;
int16_t precoder_weight_Im;
} nfapi_nr_num_ant_ports_t;
typedef struct {
uint16_t numLayers; //0~65535
nfapi_nr_num_ant_ports_t* num_ant_ports_list;
} nfapi_nr_num_layers_t;
typedef struct {
uint16_t pm_idx; //0~65535
nfapi_nr_num_layers_t* num_layers_list; //0~65535
//nfapi_nr_num_ant_ports_t* num_ant_ports_list;
} nfapi_nr_pm_pdu_t;
// Section 3.4
// Section 3.4.1 slot indication
......@@ -674,7 +675,7 @@ typedef struct {
typedef struct {
nfapi_p7_message_header_t header;
uint16_t sfn; //0->1023
uint16_t sfn; //0->1023
uint16_t slot;//0->319
} nfapi_nr_slot_indication_scf_t;
......@@ -1435,7 +1436,7 @@ typedef struct {
//3.4.5 slot_errors
typedef enum {
NFAPI_NR_SLOT_UL_TTI_MSG_INVALID_STATE,
NFAPI_NR_SLOT_UL_TTI_MSG_INVALID_STATE,
NFAPI_NR_SLOT_UL_TTI_SFN_OUT_OF_SYNC,
NFAPI_NR_SLOT_UL_TTI_MSG_BCH_MISSING,
NFAPI_NR_SLOT_UL_TTI_MSG_SLOT_ERR
......@@ -1443,14 +1444,14 @@ typedef enum {
} nfapi_nr_slot_errors_ul_tti_e;
typedef enum {
NFAPI_NR_SLOT_DL_TTI_MSG_INVALID_STATE,
NFAPI_NR_SLOT_DL_TTI_MSG_INVALID_STATE,
NFAPI_NR_SLOT_DL_TTI_MSG_SLOT_ERR
} nfapi_nr_slot_errors_dl_tti_e;
typedef enum {
NFAPI_NR_SLOT_UL_DCI_MSG_INVALID_STATE,
NFAPI_NR_SLOT_UL_DCI_MSG_INVALID_STATE,
NFAPI_NR_SLOT_UL_DCI_MSG_INVALID_SFN,
NFAPI_NR_SLOT_UL_DCI_MSG_UL_DCI_ERR
......
This diff is collapsed.
......@@ -705,17 +705,19 @@ int nr_layer_precoder(int16_t **datatx_F_precoding, const char *prec_matrix, uin
((int16_t *)precodatatx_F)[1] = (int16_t)((((int16_t *)precodatatx_F)[1]*ONE_OVER_SQRT2_Q15)>>15);*/
}
int nr_layer_precoder_cm(int16_t **datatx_F_precoding, int *prec_matrix, uint8_t n_layers, int32_t re_offset)
c16_t nr_layer_precoder_cm(int16_t **datatx_F_precoding, nfapi_nr_pm_pdu_t *pmi_pdu, int ap, uint8_t n_layers, int32_t re_offset)
{
int32_t precodatatx_F = 0;
for (int al = 0; al<n_layers; al++) {
int16_t antenna_re = datatx_F_precoding[al][re_offset<<1];
int16_t antenna_im = datatx_F_precoding[al][(re_offset<<1) +1];
//printf("antenna precoding: %d %d\n",((int16_t *)&prec_matrix[al])[0],((int16_t *)&prec_matrix[al])[1]);
((int16_t *) &precodatatx_F)[0] += (int16_t)(((int32_t)(antenna_re*(((int16_t *)&prec_matrix[al])[0])) - (int32_t)(antenna_im* (((int16_t *)&prec_matrix[al])[1])))>>15);
((int16_t *) &precodatatx_F)[1] += (int16_t)(((int32_t)(antenna_re*(((int16_t *)&prec_matrix[al])[1])) + (int32_t)(antenna_im* (((int16_t *)&prec_matrix[al])[0])))>>15);
AssertFatal(ap < pmi_pdu->num_ant_ports, "Antenna port index %d exceeds precoding matrix AP size %d\n", ap, pmi_pdu->num_ant_ports);
AssertFatal(n_layers == pmi_pdu->numLayers, "Number of layers %d doesn't match to the one in precoding matrix%d\n", n_layers, pmi_pdu->numLayers);
c16_t precodatatx_F = {0};
for (int l = 0; l < n_layers; l++) {
int16_t antenna_re = datatx_F_precoding[l][re_offset << 1];
int16_t antenna_im = datatx_F_precoding[l][(re_offset << 1) + 1];
nfapi_nr_pm_weights_t weights = pmi_pdu->weights[l][ap];
//printf("antenna precoding: %d %d\n",((int16_t *)&prec_matrix[l])[0],((int16_t *)&prec_matrix[l])[1]);
precodatatx_F.r += (int16_t)(((int32_t)(antenna_re * weights.precoder_weight_Re) - (int32_t)(antenna_im * weights.precoder_weight_Im))>>15);
precodatatx_F.i += (int16_t)(((int32_t)(antenna_re * weights.precoder_weight_Im) + (int32_t)(antenna_im * weights.precoder_weight_Re))>>15);
}
return precodatatx_F;
}
......@@ -131,8 +131,5 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms,
*/
int nr_layer_precoder(int16_t **datatx_F_precoding, const char *prec_matrix, uint8_t n_layers, int32_t re_offset);
int nr_layer_precoder_cm(int16_t **datatx_F_precoding,
int *prec_matrix,
uint8_t n_layers,
int32_t re_offset);
c16_t nr_layer_precoder_cm(int16_t **datatx_F_precoding, nfapi_nr_pm_pdu_t *pmi_pdu, int ap, uint8_t n_layers, int32_t re_offset);
#endif
......@@ -531,38 +531,24 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
}
}
else {
if(frame_parms->nb_antennas_tx==1){//no precoding matrix defined
memcpy((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k],
(void*)&txdataF_precoding[ap][2*(l*frame_parms->ofdm_symbol_size + k)],
NR_NB_SC_PER_RB*sizeof(int32_t));
k += NR_NB_SC_PER_RB;
if (k >= frame_parms->ofdm_symbol_size) {
AssertFatal(frame_parms->nb_antennas_tx > 1, "No precoding can be done with a single antenna port\n");
//get the precoding matrix weights:
nfapi_nr_pm_pdu_t *pmi_pdu = &gNB->gNB_config.pmi_list.pmi_pdu[pmi];
for (int i = 0; i < NR_NB_SC_PER_RB; i++) {
int32_t re_offset = l * frame_parms->ofdm_symbol_size + k;
c16_t precodatatx_F = nr_layer_precoder_cm(txdataF_precoding, pmi_pdu, ap, rel15->nrOfLayers, re_offset);
((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)] = precodatatx_F.r;
((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)] = precodatatx_F.i;
#ifdef DEBUG_DLSCH_MAPPING
printf("antenna %d\t l %d \t k %d \t txdataF: %d %d\n",
ap, l, k, ((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)],
((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)]);
#endif
if (++k >= frame_parms->ofdm_symbol_size) {
k -= frame_parms->ofdm_symbol_size;
}
}
else {
//get the precoding matrix weights:
int32_t **mat = gNB->nr_mimo_precoding_matrix[rel15->nrOfLayers-1];
//i_row =0,...,dl_antenna_port
//j_col =0,...,nrOfLayers
//mat[pmi][i_rows*2+j_col]
int *W_prec;
W_prec = (int32_t *)&mat[pmi][ap*rel15->nrOfLayers];
for (int i=0; i<NR_NB_SC_PER_RB; i++) {
int32_t re_offset = l*frame_parms->ofdm_symbol_size + k;
int32_t precodatatx_F = nr_layer_precoder_cm(txdataF_precoding, W_prec, rel15->nrOfLayers, re_offset);
((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)] = ((int16_t *) &precodatatx_F)[0];
((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)] = ((int16_t *) &precodatatx_F)[1];
#ifdef DEBUG_DLSCH_MAPPING
printf("antenna %d\t l %d \t k %d \t txdataF: %d %d\n",
ap, l, k, ((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)],
((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)]);
#endif
if (++k >= frame_parms->ofdm_symbol_size) {
k -= frame_parms->ofdm_symbol_size;
}
}
}
}
} //RB loop
} // symbol loop
......
......@@ -661,13 +661,6 @@ typedef struct PHY_VARS_gNB_s {
/// PDSCH DMRS sequence
uint32_t ****nr_gold_pdsch_dmrs;
/// PDSCH codebook I precoding LUTs
/// first dimension: Rank number [0,...,noOfLayers-1[
/// second dimension: PMI [0,...,CodeSize-1[
/// third dimension: [i_rows*noOfLayers+j_col], i_rows=0,...pdsch_AntennaPorts-1 and j_col=0,...,noOfLayers-1
int32_t ***nr_mimo_precoding_matrix;
int pmiq_size[NR_MAX_NB_LAYERS];
/// PUSCH DMRS
uint32_t ****nr_gold_pusch_dmrs;
......
......@@ -79,7 +79,6 @@
#define NR_MAX_PDCCH_AGG_LEVEL 16 // 3GPP TS 38.211 V15.8 Section 7.3.2 Table 7.3.2.1-1: Supported PDCCH aggregation levels
#define NR_MAX_NB_LAYERS 4 // 8
#define NR_MAX_NB_PORTS 32
#define NR_MAX_PDSCH_TBS 3824
......
This diff is collapsed.
......@@ -632,7 +632,7 @@ static void pf_dl(module_id_t module_id,
else
sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame);
sched_pdsch->nrOfLayers = get_dl_nrOfLayers(sched_ctrl, current_BWP->dci_format);
sched_pdsch->pm_index = mac->identity_pm ? 0 : get_pm_index(UE, sched_pdsch->nrOfLayers, mac->xp_pdsch_antenna_ports);
sched_pdsch->pm_index = mac->identity_pm ? 0 : get_pm_index(mac, UE, sched_pdsch->nrOfLayers, mac->xp_pdsch_antenna_ports);
const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx);
const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx);
uint32_t tbs = nr_compute_tbs(Qm,
......
......@@ -126,29 +126,32 @@ uint8_t get_dl_nrOfLayers(const NR_UE_sched_ctrl_t *sched_ctrl,
}
uint16_t get_pm_index(const NR_UE_info_t *UE,
uint16_t get_pm_index(const gNB_MAC_INST *nrmac,
const NR_UE_info_t *UE,
int layers,
int xp_pdsch_antenna_ports) {
if (layers == 1) return 0;
int xp_pdsch_antenna_ports)
{
const NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
const int report_id = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id;
const nr_csi_report_t *csi_report = &UE->csi_report_template[report_id];
const int N1 = csi_report->N1;
const int N2 = csi_report->N2;
const int antenna_ports = (N1*N2)<<1;
const int antenna_ports = (N1 * N2) << 1;
if (xp_pdsch_antenna_ports == 1 &&
antenna_ports>1)
antenna_ports > 1)
return 0; //identity matrix (basic 5G configuration handled by PMI report is with XP antennas)
const int x1 = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1;
const int x2 = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2;
LOG_D(NR_MAC,"PMI report: x1 %d x2 %d\n",x1,x2);
LOG_D(NR_MAC,"PMI report: x1 %d x2 %d layers: %d\n", x1, x2, layers);
int prev_layers_size = 0;
for (int i = 1; i < layers; i++)
prev_layers_size += nrmac->precoding_matrix_size[i - 1];
if (antenna_ports == 2)
return x2;
return 1 + prev_layers_size + x2; // 0 for identity matrix
else
AssertFatal(1==0,"More than 2 antenna ports not yet supported\n");
}
......
......@@ -382,7 +382,8 @@ NR_pdsch_dmrs_t get_dl_dmrs_params(const NR_ServingCellConfigCommon_t *scc,
const NR_tda_info_t *tda_info,
const int Layers);
uint16_t get_pm_index(const NR_UE_info_t *UE,
uint16_t get_pm_index(const gNB_MAC_INST *nrmac,
const NR_UE_info_t *UE,
int layers,
int xp_pdsch_antenna_ports);
......
......@@ -814,6 +814,8 @@ typedef struct gNB_MAC_INST_s {
uint8_t min_grant_prb;
uint8_t min_grant_mcs;
bool identity_pm;
int precoding_matrix_size[NR_MAX_NB_LAYERS];
nr_mac_rrc_ul_if_t mac_rrc;
int16_t frame;
......
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