mac_proto.h 6.33 KB
Newer Older
WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
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
/*
 * 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_proto.h
 * \brief MAC functions prototypes for gNB
 * \author Navid Nikaein and Raymond Knopp, WEI-TAI CHEN
 * \date 2010 - 2014, 2018
 * \email navid.nikaein@eurecom.fr, kroempa@gmail.com
 * \version 1.0
 * \company Eurecom, NTUST
 */
30 31 32 33

#ifndef __LAYER2_NR_MAC_PROTO_H__
#define __LAYER2_NR_MAC_PROTO_H__

34 35
#include "nr_mac_gNB.h"
#include "PHY/defs_gNB.h"
36

37 38
void set_cset_offset(uint16_t);

39 40
void mac_top_init_gNB(void);

41
void config_common(int Mod_idP,
42
                   int pdsch_AntennaPorts,
43 44
		   NR_ServingCellConfigCommon_t *scc
		   );
45

46
int rrc_mac_config_req_gNB(module_id_t Mod_idP, 
47
			   int ssb_SubcarrierOffset,
48
                           int pdsch_AntennaPorts,
49 50 51 52
                           NR_ServingCellConfigCommon_t *scc,
			   int nsa_flag,
			   uint32_t rnti,
			   NR_CellGroupConfig_t *secondaryCellGroup
53
                           );
WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
54

WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
55 56 57
void clear_nr_nfapi_information(gNB_MAC_INST * gNB, 
                                int CC_idP,
                                frame_t frameP, 
WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
58
                                sub_frame_t subframeP);
WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
59

60 61 62
void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
			       frame_t frame_txP, sub_frame_t slot_txP,
			       frame_t frame_rxP, sub_frame_t slot_rxP);
63

WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
64 65
void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP);

Raymond Knopp's avatar
Raymond Knopp committed
66 67 68 69
void nr_schedule_css_dlsch_phytest(module_id_t   module_idP,
                                   frame_t       frameP,
                                   sub_frame_t   subframeP);

Raymond Knopp's avatar
Raymond Knopp committed
70
int configure_fapi_dl_Tx(int Mod_id,
71
			 int *CCEIndeces,
Raymond Knopp's avatar
Raymond Knopp committed
72
			 nfapi_nr_dl_tti_request_body_t *dl_req,
73
			 nfapi_nr_pdu_t *TX_req,
74 75 76
			 uint8_t *mcsIndex,
			 uint16_t *rbSize,
			 uint16_t *rbStart);
Raymond Knopp's avatar
Raymond Knopp committed
77

78
void config_uldci(NR_BWP_Uplink_t *ubwp,nfapi_nr_pusch_pdu_t *pusch_pdu,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, dci_pdu_rel15_t *dci_pdu_rel15, int *dci_formats, int *rnti_types);
79 80
void nr_schedule_uss_dlsch_phytest(module_id_t   module_idP,
                                   frame_t       frameP,
81
                                   sub_frame_t   slotP,
Raymond Knopp's avatar
Raymond Knopp committed
82
                                   nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_config);
83

84
void nr_schedule_uss_ulsch_phytest(int Mod_idP,
85 86 87
                                   frame_t       frameP,
                                   sub_frame_t   slotP);
  
Raymond Knopp's avatar
Raymond Knopp committed
88
void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
89 90 91 92 93 94 95 96 97 98
                                  nr_scs_e scs_common,
                                  nr_scs_e pdcch_scs,
                                  nr_frequency_range_e freq_range,
                                  uint8_t rmsi_pdcch_config,
                                  uint8_t ssb_idx,
                                  uint8_t k_ssb,
                                  uint16_t sfn_ssb,
                                  uint8_t n_ssb,
                                  uint16_t nb_slots_per_frame,
                                  uint16_t N_RB);
99
/*
100
int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space,
101 102 103
                          nfapi_nr_coreset_t coreset,
                          uint16_t frame,
                          uint16_t slot,
104
                          nfapi_nr_config_request_scf_t cfg);
105
*/
106 107
void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu,
			NR_ServingCellConfigCommon_t *scc,
108 109 110 111 112
			NR_BWP_Uplink_t *bwp,
                        uint8_t pucch_resource,
                        uint16_t O_uci,
                        uint16_t O_ack,
                        uint8_t SR_flag);
Raymond Knopp's avatar
Raymond Knopp committed
113
void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
114 115 116
			int ss_type,
			NR_ServingCellConfigCommon_t *scc,
			NR_BWP_Downlink_t *bwp);
Raymond Knopp's avatar
Raymond Knopp committed
117
void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
118 119 120 121
			dci_pdu_rel15_t *dci_pdu_rel15,
			int *dci_formats,
			int *rnti_types
			);
122

123
int get_spf(nfapi_nr_config_request_scf_t *cfg);
124

125
int to_absslot(nfapi_nr_config_request_scf_t *cfg,int frame,int slot);
126

127
void get_band(uint64_t downlink_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type);
128

Raymond Knopp's avatar
Raymond Knopp committed
129
void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
Raymond Knopp's avatar
Raymond Knopp committed
130 131 132 133 134 135 136 137
		   int x_overhead);
/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */
uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx);
uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx);

/** \brief Computes Q based on I_MCS PDSCH and table_idx for uplink. Implements MCS Tables from 38.214. */
uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx);
uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx);
138 139 140 141 142

int NRRIV2BW(int locationAndBandwidth,int N_RB);

int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB);

143 144 145 146 147 148 149 150 151 152 153
void
dump_nr_ue_list(NR_UE_list_t *listP,
		int ul_flag);

int
find_nr_UE_id(module_id_t mod_idP,
	      rnti_t rntiP);

int add_new_nr_ue(module_id_t mod_idP,
		  rnti_t rntiP);

Raymond Knopp's avatar
Raymond Knopp committed
154 155
int get_num_dmrs(uint16_t dmrs_mask );

Raymond Knopp's avatar
Raymond Knopp committed
156 157 158 159
uint16_t nr_dci_size(nr_dci_format_t format,
                         nr_rnti_type_t rnti_type,
                         uint16_t N_RB);

160 161 162 163 164 165 166 167 168
int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
		     int bwp_id,
		     int coreset_id,
		     int aggregation,
		     int search_space, // 0 common, 1 ue-specific
		     int UE_id,
		     int m
		     );

169 170
int is_nr_DL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP);
int is_nr_UL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP);
171

172
#endif /*__LAYER2_NR_MAC_PROTO_H__*/