nr_transport_proto.h 13.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

/*! \file PHY/NR_TRANSPORT/nr_transport_proto.h.c
* \brief Function prototypes for PHY physical/transport channel processing and generation
* \author Ahmed Hussein
* \date 2019
* \version 0.1
* \company Fraunhofer IIS
* \email: ahmed.hussein@iis.fraunhofer.de
* \note
* \warning
*/

cig's avatar
cig committed
33 34 35
#ifndef __NR_TRANSPORT__H__
#define __NR_TRANSPORT__H__

36
#include "PHY/defs_nr_common.h"
cig's avatar
cig committed
37 38
#include "PHY/defs_gNB.h"

cig's avatar
cig committed
39 40
#define NR_PBCH_PDU_BITS 24

41
NR_gNB_PHY_STATS_t *get_phy_stats(PHY_VARS_gNB *gNB, uint16_t rnti);
ahadi's avatar
ahadi committed
42

Florian Kaltenberger's avatar
Florian Kaltenberger committed
43
int nr_generate_prs(uint32_t **nr_gold_prs,
44
                    c16_t *txdataF,
ahadi's avatar
ahadi committed
45
                    int16_t amp,
46
                    prs_config_t *prs_cfg,
ahadi's avatar
ahadi committed
47 48 49
                    nfapi_nr_config_request_scf_t *config,
                    NR_DL_FRAME_PARMS *frame_parms);

cig's avatar
cig committed
50 51 52 53 54 55
/*!
\fn int nr_generate_pss
\brief Generation of the NR PSS
@param
@returns 0 on success
 */
56
int nr_generate_pss(c16_t *txdataF,
cig's avatar
cig committed
57 58 59 60 61 62 63 64 65 66 67
                    int16_t amp,
                    uint8_t ssb_start_symbol,
                    nfapi_nr_config_request_scf_t *config,
                    NR_DL_FRAME_PARMS *frame_parms);

/*!
\fn int nr_generate_sss
\brief Generation of the NR SSS
@param
@returns 0 on success
 */
68
int nr_generate_sss(c16_t *txdataF,
cig's avatar
cig committed
69 70 71 72 73 74 75 76 77 78 79 80
                    int16_t amp,
                    uint8_t ssb_start_symbol,
                    nfapi_nr_config_request_scf_t *config,
                    NR_DL_FRAME_PARMS *frame_parms);

/*!
\fn int nr_generate_pbch_dmrs
\brief Generation of the DMRS for the PBCH
@param
@returns 0 on success
 */
int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
81
                          c16_t *txdataF,
cig's avatar
cig committed
82 83 84 85 86 87 88 89 90 91 92
                          int16_t amp,
                          uint8_t ssb_start_symbol,
                          nfapi_nr_config_request_scf_t *config,
                          NR_DL_FRAME_PARMS *frame_parms);

/*!
\fn int nr_generate_pbch
\brief Generation of the PBCH
@param
@returns 0 on success
 */
93
int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
cig's avatar
cig committed
94
                     uint8_t *interleaver,
95
                     c16_t *txdataF,
cig's avatar
cig committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
                     int16_t amp,
                     uint8_t ssb_start_symbol,
                     uint8_t n_hf,
                     int sfn,
                     nfapi_nr_config_request_scf_t *config,
                     NR_DL_FRAME_PARMS *frame_parms);

/*!
\fn int nr_generate_pbch
\brief PBCH interleaving function
@param bit index i of the input payload
@returns the bit index of the output
 */
void nr_init_pbch_interleaver(uint8_t *interleaver);

francescomani's avatar
francescomani committed
111
NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB);
112

francescomani's avatar
francescomani committed
113
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch, uint16_t N_RB, const NR_DL_FRAME_PARMS *frame_parms);
114

115 116 117 118 119 120 121 122 123 124
/** \brief This function is the top-level entry point to PUSCH demodulation, after frequency-domain transformation and channel estimation.  It performs
    - RB extraction (signal and channel estimates)
    - channel compensation (matched filtering)
    - RE extraction (dmrs)
    - antenna combining (MRC, Alamouti, cycling)
    - LLR computation
    This function supports TM1, 2, 3, 5, and 6.
    @param ue Pointer to PHY variables
    @param UE_id id of current UE
    @param frame Frame number
125
    @param slot Slot number
126
    @param harq_pid HARQ process ID
127
*/
128 129 130 131 132 133
int nr_rx_pusch_tp(PHY_VARS_gNB *gNB,
                   uint8_t ulsch_id,
                   uint32_t frame,
                   uint8_t slot,
                   unsigned char harq_pid);

134 135 136 137 138
/*!
\brief This function implements the idft transform precoding in PUSCH
\param z Pointer to input in frequnecy domain, and it is also the output in time domain
\param Msc_PUSCH number of allocated data subcarriers
*/
139
void nr_idft(int32_t *z, uint32_t Msc_PUSCH);
140

141 142 143 144 145
void nr_ulsch_qpsk_qpsk(c16_t *stream0_in, 
                        c16_t *stream1_in, 
                        c16_t *stream0_out, 
                        c16_t *rho01, 
                        uint32_t length);
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162

void nr_ulsch_qam16_qam16(c16_t *stream0_in,
                          c16_t *stream1_in,
                          c16_t *ch_mag,
                          c16_t *ch_mag_i,
                          c16_t *stream0_out,
                          c16_t *rho01,
                          uint32_t length);

void nr_ulsch_qam64_qam64(c16_t *stream0_in,
                          c16_t *stream1_in,
                          c16_t *ch_mag,
                          c16_t *ch_mag_i,
                          c16_t *stream0_out,
                          c16_t *rho01,
                          uint32_t length);

163 164 165 166 167 168 169
/** \brief This function generates log-likelihood ratios (decoder input) for single-stream QPSK received waveforms.
    @param rxdataF_comp Compensated channel output
    @param ulsch_llr llr output
    @param nb_re number of REs for this allocation
    @param symbol OFDM symbol index in sub-frame
*/
void nr_ulsch_qpsk_llr(int32_t *rxdataF_comp,
170
                       int16_t *ulsch_llr,
171 172 173
                       uint32_t nb_re,
                       uint8_t  symbol);

174

175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
/** \brief This function generates log-likelihood ratios (decoder input) for single-stream 16 QAM received waveforms.
    @param rxdataF_comp Compensated channel output
    @param ul_ch_mag uplink channel magnitude multiplied by the 1st amplitude threshold in QAM 16
    @param ulsch_llr llr output
    @param nb_re number of RBs for this allocation
    @param symbol OFDM symbol index in sub-frame
*/
void nr_ulsch_16qam_llr(int32_t *rxdataF_comp,
                        int32_t **ul_ch_mag,
                        int16_t  *ulsch_llr,
                        uint32_t nb_re,
                        uint8_t  symbol);

/** \brief This function generates log-likelihood ratios (decoder input) for single-stream 64 QAM received waveforms.
    @param rxdataF_comp Compensated channel output
    @param ul_ch_mag  uplink channel magnitude multiplied by the 1st amplitude threshold in QAM 64
    @param ul_ch_magb uplink channel magnitude multiplied by the 2bd amplitude threshold in QAM 64
    @param ulsch_llr llr output
    @param nb_re number of REs for this allocation
    @param symbol OFDM symbol index in sub-frame
*/
void nr_ulsch_64qam_llr(int32_t *rxdataF_comp,
                        int32_t **ul_ch_mag,
                        int32_t **ul_ch_magb,
                        int16_t  *ulsch_llr,
                        uint32_t nb_re,
                        uint8_t  symbol);

203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
/** \brief This function generates log-likelihood ratios (decoder input) for single-stream 256 QAM received waveforms.
    @param rxdataF_comp Compensated channel output
    @param ul_ch_mag  uplink channel magnitude multiplied by the 1st amplitude threshold in QAM 256
    @param ul_ch_magb uplink channel magnitude multiplied by the 2bd amplitude threshold in QAM 256
    @param ul_ch_magc uplink channel magnitude multiplied by the 3rd amplitude threshold in QAM 256 
    @param ulsch_llr llr output
    @param nb_re number of REs for this allocation
    @param symbol OFDM symbol index in sub-frame
*/
void nr_ulsch_256qam_llr(int32_t *rxdataF_comp,
                        int32_t **ul_ch_mag,
                        int32_t **ul_ch_magb,
                        int32_t **ul_ch_magc,
                        int16_t  *ulsch_llr,
                        uint32_t nb_re,
                        uint8_t  symbol);
219 220 221 222 223 224 225 226 227 228 229

/** \brief This function computes the log-likelihood ratios for 4, 16, and 64 QAM
    @param rxdataF_comp Compensated channel output
    @param ul_ch_mag  uplink channel magnitude multiplied by the 1st amplitude threshold in QAM 64
    @param ul_ch_magb uplink channel magnitude multiplied by the 2bd amplitude threshold in QAM 64
    @param ulsch_llr llr output
    @param nb_re number of REs for this allocation
    @param symbol OFDM symbol index in sub-frame
    @param mod_order modulation order
*/
void nr_ulsch_compute_llr(int32_t *rxdataF_comp,
230 231
                          int32_t *ul_ch_mag,
                          int32_t *ul_ch_magb,
232
                          int32_t *ul_ch_magc,
233 234 235
                          int16_t  *ulsch_llr,
                          uint32_t nb_re,
                          uint8_t  symbol,
236 237
                          uint8_t  mod_order);

francescomani's avatar
francescomani committed
238 239 240
void reset_active_stats(PHY_VARS_gNB *gNB, int frame);
void reset_active_ulsch(PHY_VARS_gNB *gNB, int frame);

Tsung-Yu Chan's avatar
Tsung-Yu Chan committed
241 242 243 244 245 246 247 248 249 250
void nr_ulsch_compute_ML_llr(NR_gNB_PUSCH *pusch_vars,
                             uint32_t symbol,
                             c16_t* rxdataF_comp0,
                             c16_t* rxdataF_comp1,
                             c16_t* ul_ch_mag0,
                             c16_t* ul_ch_mag1,
                             c16_t* llr_layers0,
                             c16_t* llr_layers1,
                             c16_t* rho0,
                             c16_t* rho1,
251 252 253 254 255
                             uint32_t nb_re,
                             uint8_t mod_order);

void nr_ulsch_shift_llr(int16_t **llr_layers, uint32_t nb_re, uint32_t rxdataF_ext_offset, uint8_t mod_order, int shift);

256 257 258 259
void nr_fill_ulsch(PHY_VARS_gNB *gNB,
                   int frame,
                   int slot,
                   nfapi_nr_pusch_pdu_t *ulsch_pdu);
260

261
void nr_fill_prach(PHY_VARS_gNB *gNB,
cig's avatar
cig committed
262 263 264
                   int SFN,
                   int Slot,
                   nfapi_nr_prach_pdu_t *prach_pdu);
265

266
void rx_nr_prach(PHY_VARS_gNB *gNB,
cig's avatar
cig committed
267
                 nfapi_nr_prach_pdu_t *prach_pdu,
268
		 int prachOccasion,
cig's avatar
cig committed
269 270 271 272 273 274 275 276 277 278
                 int frame,
                 int subframe,
                 uint16_t *max_preamble,
                 uint16_t *max_preamble_energy,
                 uint16_t *max_preamble_delay);

void rx_nr_prach_ru(RU_t *ru,
                    int prach_fmt,
                    int numRA,
                    int prachStartSymbol,
279
		    int prachOccasion,
cig's avatar
cig committed
280 281 282 283 284 285 286 287
                    int frame,
                    int subframe);

void nr_fill_prach_ru(RU_t *ru,
                      int SFN,
                      int Slot,
                      nfapi_nr_prach_pdu_t *prach_pdu);

288
int16_t find_nr_prach(PHY_VARS_gNB *gNB,int frame,int slot, find_type_t type);
cig's avatar
cig committed
289
int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type);
290

Francesco Mani's avatar
Francesco Mani committed
291 292 293 294 295
void nr_fill_pucch(PHY_VARS_gNB *gNB,
                   int frame,
                   int slot,
                   nfapi_nr_pucch_pdu_t *pucch_pdu);

296
void nr_fill_srs(PHY_VARS_gNB *gNB,
297 298
                 frame_t frame,
                 slot_t slot,
299 300
                 nfapi_nr_srs_pdu_t *srs_pdu);

rmagueta's avatar
rmagueta committed
301
int nr_get_srs_signal(PHY_VARS_gNB *gNB,
302 303
                      frame_t frame,
                      slot_t slot,
rmagueta's avatar
rmagueta committed
304 305
                      nfapi_nr_srs_pdu_t *srs_pdu,
                      nr_srs_info_t *nr_srs_info,
306
                      int32_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size*(1<<srs_pdu->num_symbols)]);
307

cig's avatar
cig committed
308 309 310
void init_prach_list(PHY_VARS_gNB *gNB);
void init_prach_ru_list(RU_t *ru);
void free_nr_ru_prach_entry(RU_t *ru, int prach_id);
311
uint8_t get_nr_prach_duration(uint8_t prach_format);
cig's avatar
cig committed
312

313 314 315 316 317 318 319 320 321 322 323 324 325 326
void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
                        int32_t **dataF,
                        const int16_t amp,
                        nr_csi_info_t *nr_csi_info,
                        const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params,
                        const int slot,
                        uint8_t *N_cdm_groups,
                        uint8_t *CDM_group_size,
                        uint8_t *k_prime,
                        uint8_t *l_prime,
                        uint8_t *N_ports,
                        uint8_t *j_cdm,
                        uint8_t *k_overline,
                        uint8_t *l_overline);
327

kn.raju's avatar
kn.raju committed
328
void free_nr_prach_entry(PHY_VARS_gNB *gNB, int prach_id);
329

330
void nr_decode_pucch1(c16_t **rxdataF,
331 332 333 334 335 336 337 338 339 340 341 342 343 344
                      pucch_GroupHopping_t pucch_GroupHopping,
                      uint32_t n_id,       // hoppingID higher layer parameter
                      uint64_t *payload,
                      NR_DL_FRAME_PARMS *frame_parms,
                      int16_t amp,
                      int nr_tti_tx,
                      uint8_t m0,
                      uint8_t nrofSymbols,
                      uint8_t startingSymbolIndex,
                      uint16_t startingPRB,
                      uint16_t startingPRB_intraSlotHopping,
                      uint8_t timeDomainOCC,
                      uint8_t nr_bit);

345
void nr_decode_pucch2(PHY_VARS_gNB *gNB,
346
                      int frame,
347 348 349 350
                      int slot,
                      nfapi_nr_uci_pucch_pdu_format_2_3_4_t* uci_pdu,
                      nfapi_nr_pucch_pdu_t* pucch_pdu);

351
void nr_decode_pucch0(PHY_VARS_gNB *gNB,
352
                      int frame,
353
                      int slot,
354 355 356
                      nfapi_nr_uci_pucch_pdu_format_0_1_t* uci_pdu,
                      nfapi_nr_pucch_pdu_t* pucch_pdu);

357

cig's avatar
cig committed
358
#endif /*__NR_TRANSPORT__H__*/