nr_mac_common.h 9.38 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
/*
 * 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 mac.h
cig's avatar
cig committed
23
* \brief common MAC function prototypes
24 25 26 27 28 29 30 31 32 33
* \author Navid Nikaein and Raymond Knopp, WIE-TAI CHEN
* \date Dec. 2019
* \version 0.1
* \company Eurecom
* \email raymond.knopp@eurecom.fr
*/

#ifndef __LAYER2_NR_MAC_COMMON_H__
#define __LAYER2_NR_MAC_COMMON_H__

34
#include "NR_MIB.h"
35
#include "NR_PDSCH-Config.h"
36 37
#include "NR_CellGroupConfig.h"
#include "nr_mac.h"
38
#include "openair1/PHY/impl_defs_nr.h"
39

40 41
uint16_t config_bandwidth(int mu, int nb_rb, int nr_band);

42
lte_frame_type_t get_frame_type(uint16_t nr_bandP, uint8_t scs_index);
cig's avatar
cig committed
43

44
int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index);
Francesco Mani's avatar
Francesco Mani committed
45

46
uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn);
47

48
uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw);
49

50
int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol,int mappingtype_fromDCI);
51

52
int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slot_t slotP);
53

54
int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, lte_frame_type_t frame_type);
55

56 57
uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialULBWP,
                     const NR_CellGroupConfig_t *cg,
58 59
                     dci_pdu_rel15_t *dci_pdu,
                     nr_dci_format_t format,
60 61
                     nr_rnti_type_t rnti_type,
                     uint16_t N_RB,
62
                     int bwp_id);
63

64 65 66 67
void find_aggregation_candidates(uint8_t *aggregation_level,
                                 uint8_t *nr_of_candidates,
                                 NR_SearchSpace_t *ss);

cig's avatar
cig committed
68 69 70 71
void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss,
                                               uint16_t *slot_period,
                                               uint16_t *offset);

72 73 74
int get_nr_prach_info_from_index(uint8_t index,
                                 int frame,
                                 int slot,
75
                                 uint32_t pointa,
76
                                 uint8_t mu,
77
                                 uint8_t unpaired,
78 79 80
                                 uint16_t *format,
                                 uint8_t *start_symbol,
                                 uint8_t *N_t_slot,
81 82
                                 uint8_t *N_dur,
                                 uint16_t *RA_sfn_index,
83
                                 uint8_t *N_RA_slot,
84
                                 uint8_t *config_period);
85 86 87 88 89 90 91 92 93 94 95 96

int get_nr_prach_occasion_info_from_index(uint8_t index,
                                 uint32_t pointa,
                                 uint8_t mu,
                                 uint8_t unpaired,
                                 uint16_t *format,
                                 uint8_t *start_symbol,
                                 uint8_t *N_t_slot,
                                 uint8_t *N_dur,
                                 uint8_t *N_RA_slot,
                                 uint16_t *N_RA_sfn,
                                 uint8_t *max_association_period);
97

98 99
uint8_t get_nr_prach_duration(uint8_t prach_format);

100 101 102 103 104 105
uint8_t get_pusch_mcs_table(long *mcs_Table,
                            int is_tp,
                            int dci_format,
                            int rnti_type,
                            int target_ss,
                            bool config_grant);
106

107 108
uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config,
                            uint8_t nb_preambles,
109 110
                            uint8_t unpaired,
			    frequency_range_t);
111

112 113
int ul_ant_bits(NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig,long transformPrecoder);

114
int get_format0(uint8_t index, uint8_t unpaired,frequency_range_t);
115

116
int64_t *get_prach_config_info(frequency_range_t freq_range,
117 118 119
                               uint8_t index,
                               uint8_t unpaired);

120 121
uint16_t get_NCS(uint8_t index, uint16_t format, uint8_t restricted_set_config);

122 123
int get_num_dmrs(uint16_t dmrs_mask );
uint8_t get_l0_ul(uint8_t mapping_type, uint8_t dmrs_typeA_position);
124
int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength, uint8_t start_symbolt, uint8_t dmrs_typeA_position);
125 126 127 128

uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint8_t mcs_table);
uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB);

129 130 131 132 133
void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config,
                                           frame_t frameP,
                                           NR_MIB_t *mib,
                                           uint8_t num_slot_per_frame,
                                           uint8_t ssb_subcarrier_offset,
134
                                           uint16_t ssb_start_symbol,
135 136
                                           NR_SubcarrierSpacing_t scs_ssb,
                                           frequency_range_t frequency_range,
137
                                           int nr_band,
138
                                           uint32_t ssb_index,
139
                                           uint32_t ssb_period,
140
                                           uint32_t ssb_offset_point_a);
141

142
uint16_t get_ssb_start_symbol(const long band, NR_SubcarrierSpacing_t scs, int i_ssb);
143

144 145 146 147 148 149 150
void get_info_from_tda_tables(int default_abc,
                              int tda,
                              int dmrs_TypeA_Position,
                              int normal_CP,
                              int *startSymbolIndex,
                              int *nrOfSymbols);

151
void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config);
152
uint8_t fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, int L);
153

154 155 156 157 158 159 160 161 162
uint16_t compute_pucch_prb_size(uint8_t format,
                                uint8_t nr_prbs,
                                uint16_t O_tot,
                                uint16_t O_csi,
                                NR_PUCCH_MaxCodeRate_t *maxCodeRate,
                                uint8_t Qm,
                                uint8_t n_symb,
                                uint8_t n_re_ctrl);

163
int16_t get_N_RA_RB (int delta_f_RA_PRACH,int delta_f_PUSCH);
164

165 166
void find_period_offest_SR (NR_SchedulingRequestResourceConfig_t *SchedulingReqRec, int *period, int *offset);

167 168
void csi_period_offset(NR_CSI_ReportConfig_t *csirep,
                       NR_NZP_CSI_RS_Resource_t *nzpcsi,
169 170
                       int *period, int *offset);

171 172
void reverse_n_bits(uint8_t *value, uint16_t bitlen);

173 174 175 176 177
bool set_dl_ptrs_values(NR_PTRS_DownlinkConfig_t *ptrs_config,
                        uint16_t rbSize, uint8_t mcsIndex, uint8_t mcsTable,
                        uint8_t *K_ptrs, uint8_t *L_ptrs,uint8_t *portIndex,
                        uint8_t *nERatio,uint8_t *reOffset,
                        uint8_t NrOfSymbols);
178

179 180 181 182 183
bool set_ul_ptrs_values(NR_PTRS_UplinkConfig_t *ul_ptrs_config,
                        uint16_t rbSize,uint8_t mcsIndex, uint8_t mcsTable,
                        uint8_t *K_ptrs, uint8_t *L_ptrs,
                        uint8_t *reOffset, uint8_t *maxNumPorts, uint8_t *ulPower,
                        uint8_t NrOfSymbols);
184

185
uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol,int mappingtype);
186

187 188 189 190 191 192 193
/* \brief Set the transform precoding according to 6.1.3 of 3GPP TS 38.214 version 16.3.0 Release 16
@param    *pusch_config,   pointer to pusch config
@param    *ubwp            pointer to uplink bwp
@param    *dci_format      pointer to dci format
@param    rnti_type        rnti type
@param    configuredGrant  indicates whether a configured grant was received or not
@returns                   transformPrecoding value */
194
uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP,
195 196
                               const NR_PUSCH_Config_t *pusch_config,
                               const NR_BWP_Uplink_t *ubwp,
197 198 199 200
                               uint8_t *dci_format,
                               int rnti_type,
                               uint8_t configuredGrant);

rmagueta's avatar
rmagueta committed
201
void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP,
202 203 204 205
                            const int CC_idP,
                            const frame_t frameP,
                            const sub_frame_t subframeP,
                            const rnti_t rntiP) ;
206
#endif