nr_mac_gNB.h 6.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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
 */

ChenWeiTai's avatar
ChenWeiTai committed
22
/*! \file mac.h
23
* \brief MAC data structures, constant, and function prototype
ChenWeiTai's avatar
ChenWeiTai committed
24 25
* \author Navid Nikaein and Raymond Knopp, WIE-TAI CHEN
* \date 2011, 2018
26
* \version 0.5
ChenWeiTai's avatar
ChenWeiTai committed
27 28
* \company Eurecom, NTUST
* \email navid.nikaein@eurecom.fr, kroempa@gmail.com
29 30 31 32 33 34 35 36 37

*/
/** @defgroup _oai2  openair2 Reference Implementation
 * @ingroup _ref_implementation_
 * @{
 */

/*@}*/

38 39
#ifndef __LAYER2_NR_MAC_GNB_H__
#define __LAYER2_NR_MAC_GNB_H__
40 41 42 43 44 45 46 47 48 49 50 51

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "COMMON/platform_constants.h"

#include "NR_BCCH-BCH-Message.h"
#include "NR_ServingCellConfigCommon.h"

#include "nfapi_nr_interface.h"

52
#include "NR_PHY_INTERFACE/NR_IF_Module.h"
53 54 55

#include "PHY/TOOLS/time_meas.h"

56
#include "PHY/defs_gNB.h"
57 58 59

#include "targets/ARCH/COMMON/common_lib.h"

Guy De Souza's avatar
Guy De Souza committed
60 61 62 63
#include "LAYER2/MAC/mac.h"
#include "LAYER2/MAC/mac_proto.h"
#include "LAYER2/MAC/mac_extern.h"
#include "common/ran_context.h"
64

65
/*! \brief gNB common channels */
66 67 68 69
typedef struct {
    int physCellId;
    int p_gNB;
    int Ncp;
70
    int nr_band;
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    uint32_t dl_CarrierFreq;
    NR_BCCH_BCH_Message_t *mib;
    TDD_Config_t *tdd_Config;
    ARFCN_ValueEUTRA_t ul_CarrierFreq;
    long ul_Bandwidth;
    /// Outgoing MIB PDU for PHY
    MIB_PDU MIB_pdu;
    /// Outgoing BCCH pdu for PHY
    BCCH_PDU BCCH_pdu;
    /// Outgoing BCCH DCI allocation
    uint32_t BCCH_alloc_pdu;
    /// Outgoing CCCH pdu for PHY
    CCCH_PDU CCCH_pdu;
    /// Outgoing PCCH DCI allocation
    uint32_t PCCH_alloc_pdu;
    /// Outgoing PCCH pdu for PHY
    PCCH_PDU PCCH_pdu;
    /// Outgoing RAR pdu for PHY
    RAR_PDU RAR_pdu;
    /// Template for RA computations
    RA_t ra[NB_RA_PROC_MAX];
    /// VRB map for common channels
    uint8_t vrb_map[100];
    /// VRB map for common channels and retransmissions by PHICH
    uint8_t vrb_map_UL[100];
    /// number of subframe allocation pattern available for MBSFN sync area
    uint8_t num_sf_allocation_pattern;
} NR_COMMON_channels_t;

100 101 102 103 104 105 106 107 108 109
/*! \brief top level eNB MAC structure */
typedef struct gNB_MAC_INST_s {
  /// Ethernet parameters for northbound midhaul interface
  eth_params_t                    eth_params_n;
  /// Ethernet parameters for fronthaul interface
  eth_params_t                    eth_params_s;
  /// Module
  module_id_t                     Mod_id;
  /// frame counter
  frame_t                         frame;
110 111
  /// slot counter
  int                             slot;  
112 113
  /// Pointer to IF module instance for PHY
  NR_IF_Module_t                  *if_inst;
114 115 116 117 118
    /// Common cell resources
  NR_COMMON_channels_t common_channels[NFAPI_CC_MAX];
  /// current PDU index (BCH,DLSCH)
  uint16_t pdu_index[NFAPI_CC_MAX];

119
  /// NFAPI Config Request Structure
ChenWeiTai's avatar
ChenWeiTai committed
120
  nfapi_nr_config_request_t         config[NFAPI_CC_MAX];
121
  /// NFAPI DL Config Request Structure
ChenWeiTai's avatar
ChenWeiTai committed
122
  nfapi_nr_dl_config_request_t      DL_req[NFAPI_CC_MAX];
123
  /// NFAPI UL Config Request Structure, send to L1 4 subframes before processing takes place
ChenWeiTai's avatar
ChenWeiTai committed
124
  nfapi_ul_config_request_t         UL_req[NFAPI_CC_MAX];
125
  /// Preallocated DL pdu list
ChenWeiTai's avatar
ChenWeiTai committed
126
  nfapi_nr_dl_config_request_pdu_t  dl_config_pdu_list[NFAPI_CC_MAX][MAX_NUM_DL_PDU];
127
  /// Preallocated UL pdu list
ChenWeiTai's avatar
ChenWeiTai committed
128
  nfapi_ul_config_request_pdu_t     ul_config_pdu_list[NFAPI_CC_MAX][MAX_NUM_UL_PDU];
129
  /// Preallocated UL pdu list for ULSCH (n+k delay)
ChenWeiTai's avatar
ChenWeiTai committed
130
  nfapi_ul_config_request_pdu_t     ul_config_pdu_list_tmp[NFAPI_CC_MAX][10][MAX_NUM_UL_PDU];
131
  /// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests
ChenWeiTai's avatar
ChenWeiTai committed
132
  nfapi_ul_config_request_t         UL_req_tmp[NFAPI_CC_MAX][10];
133
  /// Preallocated HI_DCI0 pdu list
ChenWeiTai's avatar
ChenWeiTai committed
134
  nfapi_hi_dci0_request_pdu_t       hi_dci0_pdu_list[NFAPI_CC_MAX][MAX_NUM_HI_DCI0_PDU];
135
  /// NFAPI HI/DCI0 Config Request Structure
ChenWeiTai's avatar
ChenWeiTai committed
136
  nfapi_hi_dci0_request_t           HI_DCI0_req[NFAPI_CC_MAX];
137
  /// Prealocated TX pdu list
ChenWeiTai's avatar
ChenWeiTai committed
138
  nfapi_tx_request_pdu_t            tx_request_pdu[NFAPI_CC_MAX][MAX_NUM_TX_REQUEST_PDU];
139
  /// NFAPI DL PDU structure
ChenWeiTai's avatar
ChenWeiTai committed
140
  nfapi_tx_request_t                TX_req[NFAPI_CC_MAX];
141 142 143 144
  /// NFAPI coreset structure
  nfapi_nr_coreset_t                coreset[NFAPI_CC_MAX][NFAPI_NR_MAX_NB_CORESETS];
  /// NFAPI search space structure
  nfapi_nr_search_space_t           search_space[NFAPI_CC_MAX][NFAPI_NR_MAX_NB_SEARCH_SPACES];
145 146

  UE_list_t UE_list;
147

148 149 150
  /// UL handle
  uint32_t ul_handle;

151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
    // MAC function execution peformance profiler
  /// processing time of eNB scheduler
  time_stats_t eNB_scheduler;
  /// processing time of eNB scheduler for SI
  time_stats_t schedule_si;
  /// processing time of eNB scheduler for Random access
  time_stats_t schedule_ra;
  /// processing time of eNB ULSCH scheduler
  time_stats_t schedule_ulsch;
  /// processing time of eNB DCI generation
  time_stats_t fill_DLSCH_dci;
  /// processing time of eNB MAC preprocessor
  time_stats_t schedule_dlsch_preprocessor;
  /// processing time of eNB DLSCH scheduler
  time_stats_t schedule_dlsch;  // include rlc_data_req + MAC header + preprocessor
  /// processing time of eNB MCH scheduler
  time_stats_t schedule_mch;
  /// processing time of eNB ULSCH reception
  time_stats_t rx_ulsch_sdu;  // include rlc_data_ind
  /// processing time of eNB PCH scheduler
  time_stats_t schedule_pch;
172 173
} gNB_MAC_INST;

Guy De Souza's avatar
Guy De Souza committed
174 175 176 177
void nr_schedule_css_dlsch_phytest(module_id_t   module_idP,
                                   frame_t       frameP,
                                   sub_frame_t   subframeP);

178
#endif /*__LAYER2_NR_MAC_GNB_H__ */