carrier_freq_local=1900000000+(dl_CarrierFreq_r10-36000)*100000;//band 33 from 3GPP 36.101 v 10.9 Table 5.7.3-1
LOG_I(PHY,"[eNB %d] Frame %d: Configured SCell %d to frequency %d (ARFCN %ld) for UE %d\n",Mod_id,/*eNB->frame*/0,CC_id,carrier_freq_local,dl_CarrierFreq_r10,UE_id);
carrier_freq_local=832000000+(dl_CarrierFreq_r10-6150)*100000;//band 20 from 3GPP 36.101 v 10.9 Table 5.7.3-1
// this is actually for the UL only, but we use it for DL too, since there is no TDD mode for this band
LOG_I(PHY,"[eNB %d] Frame %d: Configured SCell %d to frequency %d (ARFCN %ld) for UE %d\n",Mod_id,/*eNB->frame*/0,CC_id,carrier_freq_local,dl_CarrierFreq_r10,UE_id);
}else{
LOG_E(PHY,"[eNB %d] Frame %d: ARFCN %ld of SCell %d for UE %d not supported\n",Mod_id,/*eNB->frame*/0,dl_CarrierFreq_r10,CC_id,UE_id);
}
if(physicalConfigDedicatedSCell_r10){
//#warning " eNB->physicalConfigDedicatedSCell_r10 does not exist in eNB"
//for (i=index; i < NUMBER_OF_UE_MAX; i+=num_active_cba_groups){
// LOG_D(PHY,"[eNB %d] configure cba group %d with rnti %x for UE %d, num active cba grp %d\n",Mod_id, i%num_active_cba_groups, cba_rnti, i, num_active_cba_groups);
1;///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
eNB->first_run_I0_measurements=1;///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
/// Outgoing DCI for PHY generated by eNB scheduler
DCI_PDU_NBDCI_pdu;
/// Outgoing BCCH pdu for PHY
BCCH_PDU_NBBCCH_pdu;
/// Outgoing BCCH DCI allocation
uint32_tBCCH_alloc_pdu;
/// Outgoing CCCH pdu for PHY
CCCH_PDUCCCH_pdu;
RA_TEMPLATE_NBRA_template[NB_RA_PROC_MAX];
/// Delete VRB map for common channels
/// Delete MBSFN SubframeConfig
/// Delete number of subframe allocation pattern available for MBSFN sync area
// #if defined(Rel10) || defined(Rel14)
/// Delete MBMS Flag
/// Delete Outgoing MCCH pdu for PHY
/// Delete MCCH active flag
/// Delete MCCH active flag
/// Delete MTCH active flag
/// Delete number of active MBSFN area
/// Delete MBSFN Area Info
/// Delete PMCH Config
/// Delete MBMS session info list
/// Delete Outgoing MCH pdu for PHY
// #endif
// #ifdef CBA
/// Delete number of CBA groups
/// Delete RNTI for each CBA group
/// Delete MCS for each CBA group
// #endif
}COMMON_channels_NB_t;
/*! \brief top level eNB MAC structure */
typedefstruct{
///
uint16_tNode_id;
/// frame counter
frame_tframe;
/// subframe counter
sub_frame_tsubframe;
/// Common cell resources
COMMON_channels_NB_tcommon_channels[MAX_NUM_CCs];
UE_list_NB_tUE_list;
///Delete subband bitmap configuration, no related CQI report
// / Modify CCE table used to build DCI scheduling information
intCCE_table[MAX_NUM_CCs][12];//180 khz for Anchor carrier
/// active flag for Other lcid
uint8_tlcid_active[NB_RB_MAX];
/// eNB stats
eNB_STATSeNB_stats[MAX_NUM_CCs];
// MAC function execution peformance profiler
/// processing time of eNB scheduler
time_stats_teNB_scheduler;
/// processing time of eNB scheduler for SI
time_stats_tschedule_si;
/// processing time of eNB scheduler for Random access
time_stats_tschedule_ra;
/// processing time of eNB ULSCH scheduler
time_stats_tschedule_ulsch;
/// processing time of eNB DCI generation
time_stats_tfill_DLSCH_dci;
/// processing time of eNB MAC preprocessor
time_stats_tschedule_dlsch_preprocessor;
/// processing time of eNB DLSCH scheduler
time_stats_tschedule_dlsch;// include rlc_data_req + MAC header + preprocessor
/// Delete processing time of eNB MCH scheduler
/// processing time of eNB ULSCH reception
time_stats_trx_ulsch_sdu;// include rlc_data_ind
}eNB_MAC_INST_NB;
/*
* UE part
*/
/*!\brief UE layer 2 status */
typedefenum{
CONNECTION_OK=0,
CONNECTION_LOST,
PHY_RESYNCH,
PHY_HO_PRACH
}UE_L2_STATE_t_NB;
/*!\brief UE scheduling info */
typedefstruct{
/// buffer status for each lcgid
uint8_tBSR[MAX_NUM_LCGID];// should be more for mesh topology
/// keep the number of bytes in rlc buffer for each lcgid
int32_tBSR_bytes[MAX_NUM_LCGID];
/// after multiplexing buffer remain for each lcid
int32_tLCID_buffer_remain[MAX_NUM_LCID];
/// sum of all lcid buffer size
uint16_tAll_lcid_buffer_size_lastTTI;
/// buffer status for each lcid
uint8_tLCID_status[MAX_NUM_LCID];
/// Delete SR pending as defined in 36.321
/// Delete SR_COUNTER as defined in 36.321
/// logical channel group ide for each LCID
uint8_tLCGID[MAX_NUM_LCID];
/// retxBSR-Timer, default value is sf2560
uint16_tretxBSR_Timer;
/// retxBSR_SF, number of subframe before triggering a regular BSR
uint16_tretxBSR_SF;
/// periodicBSR-Timer, default to infinity
uint16_tperiodicBSR_Timer;
/// periodicBSR_SF, number of subframe before triggering a periodic BSR
uint16_tperiodicBSR_SF;
/// Delete sr_ProhibitTimer in MAC_MainConfig, default value is 0: not configured
/// Delete sr ProhibitTime running
/// Delete maxHARQ_Tx in MAC_MainConfig, default value to n5
/// delete ttiBundling in MAC_MainConfig, default value is false
/// default value is release
structDRX_Config*drx_config;
/// Delete phr_config in MAC_MainConfig, default value is release
///Delete timer before triggering a periodic PHR
///Delete timer before triggering a prohibit PHR
///DL Pathloss change value
uint16_tPathlossChange;
///Delete number of subframe before triggering a periodic PHR
///Delete number of subframe before triggering a prohibit PHR
///DL Pathloss Change in db
uint16_tPathlossChange_db;
/// Delete extendedBSR_Sizes_r10, default value is false, only support short BSR
/// Delete extendedPHR_r10, default value is false
//For NB-IoT in TS 36.321, prioritisedBitRate, bucketSizeDuration and the corresponding steps of the Logical Channel Prioritisation procedure (i.e., Step 1 and Step 2 below) are not applicable.
//LG commented cause compilation error for RT eNB extern inline unsigned int taus(void);
/** \fn void schedule_RA(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,uint8_t Msg3_subframe,unsigned int *nprb);
\brief First stage of Random-Access Scheduling. Loops over the RA_templates and checks if RAR, Msg3 or its retransmission are to be scheduled in the subframe. It returns the total number of PRB used for RA SDUs. For Msg3 it retrieves the L3msg from RRC and fills the appropriate buffers. For the others it just computes the number of PRBs. Each DCI uses 3 PRBs (format 1A)
/** \brief First stage of SI Scheduling. Gets a SI SDU from RRC if available and computes the MCS required to transport it as a function of the SDU length. It assumes a length less than or equal to 64 bytes (MCS 6, 3 PRBs).
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe number on which to act
@param Msg3_subframe Subframe where Msg3 will be transmitted
/** \brief MBMS scheduling: Checking the position for MBSFN subframes. Create MSI, transfer MCCH from RRC to MAC, transfer MTCHs from RLC to MAC. Multiplexing MSI,MCCH&MTCHs. Return 1 if there are MBSFN data being allocated, otherwise return 0;
/** \brief Second stage of DLSCH scheduling, after schedule_SI, schedule_RA and schedule_dlsch have been called. This routine first allocates random frequency assignments for SI and RA SDUs using distributed VRB allocations and adds the corresponding DCI SDU to the DCI buffer for PHY. It then loops over the UE specific DCIs previously allocated and fills in the remaining DCI fields related to frequency allocation. It assumes localized allocation of type 0 (DCI.rah=0). The allocation is done for tranmission modes 1,2,4.
@param Mod_id Instance of eNB
@param frame Frame index
@param subframe Index of subframe
@param mbsfn_flag Indicates that this subframe is for MCH/MCCH
/** \brief UE specific DLSCH scheduling. Retrieves next ue to be schduled from round-robin scheduler and gets the appropriate harq_pid for the subframe from PHY. If the process is active and requires a retransmission, it schedules the retransmission with the same PRB count and MCS as the first transmission. Otherwise it consults RLC for DCCH/DTCH SDUs (status with maximum number of available PRBS), builds the MAC header (timing advance sent by default) and copies
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe on which to act
@param mbsfn_flag Indicates that MCH/MCCH is in this subframe
/* \brief Function to trigger the eNB scheduling procedure. It is called by PHY at the beginning of each subframe, \f$n$\f
and generates all DLSCH allocations for subframe \f$n\f$ and ULSCH allocations for subframe \f$n+k$\f. The resultant DCI_PDU is
ready after returning from this call.
@param Mod_id Instance ID of eNB
@param cooperation_flag Flag to indicated that this cell has cooperating nodes (i.e. that there are collaborative transport channels that
can be scheduled.
@param subframe Index of current subframe
@param calibration_flag Flag to indicate that eNB scheduler should schedule TDD auto-calibration PUSCH.
*/
voideNB_dlsch_ulsch_scheduler(module_id_tmodule_idP,uint8_tcooperation_flag,frame_tframeP,sub_frame_tsubframeP);//, int calibration_flag);
/* \brief Function to retrieve result of scheduling (DCI) in current subframe. Can be called an arbitrary numeber of times after eNB_dlsch_ulsch_scheduler
/* \brief Allocates a set of PRBS for a particular UE. This is a simple function for the moment, later it should process frequency-domain CQI information and/or PMI information. Currently it just returns the first PRBS that are available in the subframe based on the number requested.
@param UE_id Index of UE on which to act
@param nb_rb Number of PRBs allocated to UE by scheduler
@param rballoc Pointer to bit-map of current PRB allocation given to previous users/control channels. This is updated for subsequent calls to the routine.
@returns an rballoc bitmap for resource type 0 allocation (DCI).
/* \brief Called by PHY to get sdu for PUSCH transmission. It performs the following operations: Checks BSR for DCCH, DCCH1 and DTCH corresponding to previous values computed either in SR or BSR procedures. It gets rlc status indications on DCCH,DCCH1 and DTCH and forms BSR elements and PHR in MAC header. CRNTI element is not supported yet. It computes transport block for up to 3 SDUs and generates header and forms the complete MAC SDU.
/* \brief Function called by PHY to retrieve information to be transmitted using the RA procedure. If the UE is not in PUSCH mode for a particular eNB index, this is assumed to be an Msg3 and MAC attempts to retrieves the CCCH message from RRC. If the UE is in PUSCH mode for a particular eNB index and PUCCH format 0 (Scheduling Request) is not activated, the MAC may use this resource for random-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321)
@param Mod_id Index of UE instance
@param Mod_id Component Carrier Index
@param New_Msg3 Flag to indicate this call is for a new Msg3
@param subframe Index of subframe for PRACH transmission (0 ... 9)
/* \brief Function called by PHY to process the received RAR. It checks that the preamble matches what was sent by the eNB and provides the timing advance and t-CRNTI.
@param Mod_id Index of UE instance
@param CC_id Index to a component carrier
@param frame Frame index
@param ra_rnti RA_RNTI value
@param dlsch_buffer Pointer to dlsch_buffer containing RAR PDU
@param t_crnti Pointer to PHY variable containing the T_CRNTI
@param preamble_index Preamble Index used by PHY to transmit the PRACH. This should match the received RAR to trigger the rest of
random-access procedure
@param selected_rar_buffer the output buffer for storing the selected RAR header and RAR payload
@returns timing advance or 0xffff if preamble doesn't match
*/
uint16_t
ue_process_rar(
constmodule_id_tmodule_idP,
constintCC_id,
constframe_tframeP,
constrnti_tra_rnti,
uint8_t*constdlsch_buffer,
rnti_t*constt_crnti,
constuint8_tpreamble_index,
uint8_t*selected_rar_buffer
);
/* \brief Generate header for UL-SCH. This function parses the desired control elements and sdus and generates the header as described
in 36-321 MAC layer specifications. It returns the number of bytes used for the header to be used as an offset for the payload
in the ULSCH buffer.
@param mac_header Pointer to the first byte of the MAC header (UL-SCH buffer)
@param num_sdus Number of SDUs in the payload
@param short_padding Number of bytes for short padding (0,1,2)
@param sdu_lengths Pointer to array of SDU lengths
@param sdu_lcids Pointer to array of LCIDs (the order must be the same as the SDU length array)
@param power_headroom Pointer to power headroom command (NULL means not present in payload)
@param crnti Pointer to CRNTI command (NULL means not present in payload)
@param truncated_bsr Pointer to Truncated BSR command (NULL means not present in payload)
@param short_bsr Pointer to Short BSR command (NULL means not present in payload)
@param long_bsr Pointer to Long BSR command (NULL means not present in payload)
@param post_padding Number of bytes for padding at the end of MAC PDU
\brief UE scheduler where all the ue background tasks are done. This function performs the following: 1) Trigger PDCP every 5ms 2) Call RRC for link status return to PHY3) Perform SR/BSR procedures for scheduling feedback 4) Perform PHR procedures.
\param[in] module_idP instance of the UE
\param[in] rxFrame the RX frame number
\param[in] rxSubframe the RX subframe number
\param[in] txFrame the TX frame number
\param[in] txSubframe the TX subframe number
\param[in] direction subframe direction
\param[in] eNB_index instance of eNB
@returns L2 state (CONNETION_OK or CONNECTION_LOST or PHY_RESYNCH)
*/
UE_L2_STATE_tue_scheduler(
constmodule_id_tmodule_idP,
constframe_trxFrameP,
constsub_frame_trxSubframe,
constframe_ttxFrameP,
constsub_frame_ttxSubframe,
constlte_subframe_tdirection,
constuint8_teNB_index,
constintCC_id);
/*! \fn int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen);
\brief determine whether to use cba resource to transmit or not
/*! \fn locate_BsrIndexByBufferSize (int *table, int size, int value)
\brief locate the BSR level in the table as defined in 36.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table.
/** \brief RRC Configuration primitive for PHY/MAC. Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages.
@param Mod_id Instance ID of eNB
@param CC_id Component Carrier of the eNB
@param eNB_flag Indicates if this is a eNB or UE configuration
@param rntiP id of UE if this is an eNB configuration
@param eNB_id Index of eNB if this is a UE configuration
@param radioResourceConfigCommon Structure from SIB2 for common radio parameters (if NULL keep existing configuration)
@param physcialConfigDedicated Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated PHY parameters (if NULL keep existing configuration)
@param measObj Structure from RRCConnectionReconfiguration for UE measurement procedures
@param mac_MainConfig Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated MAC parameters (if NULL keep existing configuration)
@param logicalChannelIdentity Logical channel identity index of corresponding logical channel config
@param logicalChannelConfig Pointer to logical channel configuration
@param measGapConfig Measurement Gap configuration for MAC (if NULL keep existing configuration)
/* \brief Function to retrieve result of scheduling (DCI) in current subframe. Can be called an arbitrary numeber of times after eNB_dlsch_ulsch_scheduler