- Fix: avoid infinite loop on mulitcast read thread if no data to read

Pre-ci test passed

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4000 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
Cedric Roux
2013-06-25 09:05:02 +00:00
commit 56c66c09aa
4111 changed files with 2133103 additions and 0 deletions
+283
View File
@@ -0,0 +1,283 @@
/*******************************************************************************
Eurecom OpenAirInterface
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file defs.h
* \brief mac phy interface primitives
* \author Raymond Knopp and Navid Nikaein
* \date 2011
* \version 0.5
* @ingroup _mac
*/
#ifndef __MAC_PHY_PRIMITIVES_H__
# define __MAC_PHY_PRIMITIVES_H__
#include "LAYER2/MAC/defs.h"
#define MAX_NUMBER_OF_MAC_INSTANCES 16
#define NULL_PDU 255
#define DCI 0
#define DLSCH 1
#define ULSCH 2
/*! \brief MACPHY Interface */
typedef struct
{
/// Pointer function that initializes L2
void (*macphy_init)(int eMBMS_active, u8 CBA_enabled);
/// Pointer function that stops the low-level scheduler due an exit condition
void (*macphy_exit)(const char *);
// eNB functions
/// Invoke dlsch/ulsch scheduling procedure for new subframe
void (*eNB_dlsch_ulsch_scheduler)(u8 Mod_id, u8 cooperation_flag, u32 frame, u8 subframe);//, int calibration_flag);
/// Fill random access response sdu, passing timing advance
u16 (*fill_rar)(u8 Mod_id,u32 frame,u8 *dlsch_buffer,u16 N_RB_UL, u8 input_buffer_length);
/// Terminate the RA procedure upon reception of l3msg on ulsch
void (*terminate_ra_proc)(u8 Mod_id,u32 frame,u16 UE_id, u8 *l3msg,u16 l3msg_len);
/// Initiate the RA procedure upon reception (hypothetical) of a valid preamble
void (*initiate_ra_proc)(u8 Mod_id,u32 frame,u16 preamble,s16 timing_offset,u8 sect_id,u8 subframe,u8 f_id);
/// cancel an ongoing RA procedure
void (*cancel_ra_proc)(u8 Mod_id,u32 frame,u16 preamble);
/// Get DCI for current subframe from MAC
DCI_PDU* (*get_dci_sdu)(u8 Mod_id,u32 frame,u8 subframe);
/// Get DLSCH sdu for particular RNTI and Transport block index
u8* (*get_dlsch_sdu)(u8 Mod_id,u32 frame,u16 rnti,u8 TB_index);
/// Send ULSCH sdu to MAC for given rnti
void (*rx_sdu)(u8 Mod_id,u32 frame,u16 rnti, u8 *sdu,u16 sdu_len);
/// Indicate failure to synch to external source
void (*mrbch_phy_sync_failure) (u8 Mod_id,u32 frame, u8 Free_ch_index);
/// Indicate Scheduling Request from UE
void (*SR_indication)(u8 Mod_id,u32 frame,u16 rnti,u8 subframe);
/// Configure Common PHY parameters from SIB1
void (*phy_config_sib1_eNB)(u8 Mod_id,
TDD_Config_t *tdd_config,
u8 SIwindowsize,
u16 SIperiod);
/// Configure Common PHY parameters from SIB2
void (*phy_config_sib2_eNB)(u8 Mod_id,
RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
ARFCN_ValueEUTRA_t *ul_CArrierFreq,
long *ul_Bandwidth,
AdditionalSpectrumEmission_t *additionalSpectrumEmission,
struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList);
#ifdef Rel10
/// Configure Common PHY parameters from SIB13
void (*phy_config_sib13_eNB)(u8 Mod_id,int mbsfn_Area_idx,
long mbsfn_AreaId_r9);
#endif
/// PHY-Config-Dedicated eNB
void (*phy_config_dedicated_eNB)(u8 Mod_id,u16 rnti,
struct PhysicalConfigDedicated *physicalConfigDedicated);
#ifdef Rel10
/// Get MCH sdu and corresponding MCS for particular MBSFN subframe
MCH_PDU* (*get_mch_sdu)(uint8_t Mod_id,uint32_t frame,uint32_t subframe);
#endif
// configure the cba rnti at the physical layer
void (*phy_config_cba_rnti)(u8 Mod_id,u8 eNB_flag, u8 index, u16 cba_rnti, u8 cba_group_id, u8 num_active_cba_groups);
// UE functions
/// Indicate loss of synchronization of PBCH
void (*out_of_sync_ind)(u8 Mod_id,u32 frame,u16);
/// Send a received SI sdu
void (*ue_decode_si)(u8 Mod_id,u32 frame, u8 CH_index, void *pdu, u16 len);
/// Send a received DLSCH sdu to MAC
void (*ue_send_sdu)(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 CH_index);
#ifdef Rel10
/// Send a received MCH sdu to MAC
void (*ue_send_mch_sdu)(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 CH_index);
/// Function to check if UE PHY needs to decode MCH for MAC
/// Return MCS value if need to decode, otherwise -1
int (*ue_query_mch)(uint8_t Mod_id,uint32_t frame,uint32_t subframe);
#endif
/// Retrieve ULSCH sdu from MAC
void (*ue_get_sdu)(u8 Mod_id,u32 frame,u8 subframe, u8 CH_index,u8 *ulsch_buffer,u16 buflen,u8 *access_mode);
/// Retrieve RRCConnectionReq from MAC
PRACH_RESOURCES_t* (*ue_get_rach)(u8 Mod_id,u32 frame,u8 Msg3_flag,u8 subframe);
/// Process Random-Access Response
u16 (*ue_process_rar)(u8 Mod_id,u32 frame,u8 *dlsch_buffer,u16 *t_crnti,u8 preamble_index);
/// Get SR payload (0,1) from UE MAC
u32 (*ue_get_SR)(u8 Mod_id,u32 frame,u8 eNB_id,u16 rnti,u8 subframe);
/// Indicate synchronization with valid PBCH
void (*dl_phy_sync_success) (u8 Mod_id,u32 frame, u8 CH_index,u8 first_sync);
/// Only calls the PDCP for now
UE_L2_STATE_t (*ue_scheduler)(u8 Mod_id, u32 frame,u8 subframe, lte_subframe_t direction,u8 eNB_id);
/// PHY-Config-Dedicated UE
void (*phy_config_dedicated_ue)(u8 Mod_id,u8 CH_index,
struct PhysicalConfigDedicated *physicalConfigDedicated);
/// Configure Common PHY parameters from SIB1
void (*phy_config_sib1_ue)(u8 Mod_id,u8 CH_index,
TDD_Config_t *tdd_config,
u8 SIwindowsize,
u16 SIperiod);
/// Configure Common PHY parameters from SIB2
void (*phy_config_sib2_ue)(u8 Mod_id,u8 CH_index,
RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
ARFCN_ValueEUTRA_t *ul_CArrierFreq,
long *ul_Bandwidth,
AdditionalSpectrumEmission_t *additionalSpectrumEmission,
struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList);
#ifdef Rel10
/// Configure Common PHY parameters from SIB13
void (*phy_config_sib13_ue)(u8 Mod_id,u8 CH_index,int mbsfn_Area_idx,
long mbsfn_AreaId_r9);
#endif
/// Function to indicate failure of contention resolution or RA procedure
void (*ra_failed)(u8 Mod_id,u8 eNB_index);
/// Function to indicate success of contention resolution or RA procedure
void (*ra_succeeded)(u8 Mod_id,u8 eNB_index);
/// Function to indicate the transmission of msg1/rach to MAC
void (*Msg1_transmitted)(u8 Mod_id,u32 frame,u8 eNB_id);
/// Function to indicate Msg3 transmission/retransmission which initiates/reset Contention Resolution Timer
void (*Msg3_transmitted)(u8 Mod_id,u32 frame,u8 eNB_id);
/// Function to pass inter-cell measurement parameters to PHY (cell Ids)
void (*phy_config_meas_ue)(u8 Mod_id,u8 eNB_index,u8 n_adj_cells,u32 *adj_cell_id);
// PHY Helper Functions
/// RIV computation from PHY
u16 (*computeRIV)(u16 N_RB_DL,u16 RBstart,u16 Lcrbs);
/// Downlink TBS table lookup from PHY
u16 (*get_TBS_DL)(u8 mcs, u16 nb_rb);
/// Uplink TBS table lookup from PHY
u16 (*get_TBS_UL)(u8 mcs, u16 nb_rb);
/// Function to retrieve the HARQ round index for a particular UL/DLSCH and harq_pid
int (*get_ue_active_harq_pid)(u8 Mod_id, u16 rnti, u8 subframe, u8 *harq_pid, u8 *round, u8 ul_flag);
/// Function to retrieve number of CCE
u16 (*get_nCCE_max)(u8 Mod_id);
/// Function to retrieve number of PRB in an rb_alloc
u16 (*get_nb_rb)(u8 ra_header,u32 rb_alloc);
/// Function to retrieve transmission mode for UE
u8 (*get_transmission_mode)(u16 Mod_id,u16 rnti);
/// Function to retrieve rb_alloc bitmap from dci rballoc field and VRB type
u32 (*get_rballoc)(u8 vrb_type,u8 rb_alloc_dci);
/// Function for UE MAC to retrieve current PHY connectivity mode (PRACH,RA_RESPONSE,PUSCH)
UE_MODE_t (*get_ue_mode)(u8 Mod_id,u8 eNB_index);
/// Function for UE MAC to retrieve measured Path Loss
s16 (*get_PL)(u8 Mod_id,u8 eNB_index);
/// Function for UE MAC to retrieve RSRP/RSRQ measurements
u8* (*get_RSRP)(u8 Mod_id,u8 eNB_index);
/// Function for UE MAC to retrieve RSRP/RSRQ measurements
u8* (*get_RSRQ)(u8 Mod_id,u8 eNB_index);
/// Function for UE/eNB MAC to retrieve number of PRACH in TDD
u8 (*get_num_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms);
/// Function for UE/eNB MAC to retrieve f_id of particular PRACH resource in TDD
u8 (*get_fid_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms,u8 tdd_map_index);
/// Function for eNB MAC to retrieve subframe direction
lte_subframe_t (*get_subframe_direction)(u8 Mod_id, u8 subframe);
// MAC Helper functions
/// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (Po_NOMINAL_PUSCH parameter)
s8 (*get_Po_NOMINAL_PUSCH)(u8 Mod_id);
/// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (deltaP_rampup parameter)
s8 (*get_deltaP_rampup)(u8 Mod_id);
/// Function for UE/PHY to compute PHR
s8 (*get_PHR)(u8 Mod_id, u8 eNB_index);
void (*process_timing_advance)(u8 Mod_id,s16 timing_advance);
LTE_eNB_UE_stats* (*get_eNB_UE_stats)(u8 Mod_id, u16 rnti);
unsigned char is_cluster_head;
unsigned char is_primary_cluster_head;
unsigned char is_secondary_cluster_head;
unsigned char cluster_head_index;
/// PHY Frame Configuration
LTE_DL_FRAME_PARMS *lte_frame_parms;
//ICIC algos
u8 (*get_SB_size)(u8 n_rb_dl);
//end ALU's algo
} MAC_xface;
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef __PHY_INTERFACE_EXTERN_H__
#define __PHY_INTERFACE_EXTERN_H__
//#include "SIMULATION/PHY_EMULATION/spec_defs.h"
#ifdef PHY_EMUL
#include "SIMULATION/PHY_EMULATION/DEVICE_DRIVER/defs.h"
#include "SIMULATION/PHY_EMULATION/DEVICE_DRIVER/extern.h"
#endif //PHY_EMUL
#include "defs.h"
extern unsigned int mac_debug;
#ifdef PHYSIM
extern MAC_xface *mac_xface;
#endif
//extern MACPHY_PARAMS MACPHY_params;
extern unsigned int mac_registered;
#endif
+260
View File
@@ -0,0 +1,260 @@
/*________________________mac_phy_primitives.c________________________
Authors : Hicham Anouar, Raymond Knopp
Company : EURECOM
Emails : anouar@eurecom.fr, knopp@eurecom.fr
________________________________________________________________*/
//#include "openair_extern.h"
#ifdef MAC_CONTEXT
#include "LAYER2/MAC/defs.h"
#include "LAYER2/MAC/extern.h"
//#include "extern.h"
#include "defs.h"
#endif //MAC_CONTEXT
//#define DEBUG_UE_DECODE_SACH
//#define DEBUG_NODEB_DECODE_SACH
#ifdef PHY_CONTEXT
#ifdef PHY_EMUL
#include "extern.h"
#include "SIMULATION/simulation_defs.h"
#else //PHY_EMUL
#include "MAC_INTERFACE/extern.h"
#endif //PHY_EMUL
void clear_macphy_data_req(unsigned char Mod_id) {
//msg("CLEAR DATA_REQ\n");
unsigned char i;
Macphy_req_table[Mod_id].Macphy_req_cnt = 0;
for (i=0;i<NB_REQ_MAX;i++)
Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active = 0;
}
/*
unsigned char phy_resources_compare(PHY_RESOURCES *Phy1,PHY_RESOURCES* Phy2 ){
if(Phy1->Time_alloc==Phy2->Time_alloc && Phy1->Freq_alloc==Phy2->Freq_alloc)// && Phy1->Coding_fmt==Phy2->Coding_fmt && Phy1->Seq_index==Phy2->Seq_index)
return 1;
else
return 0;
}
*/
MACPHY_DATA_REQ_TABLE_ENTRY* find_data_req_entry(unsigned char Mod_id,MACPHY_REQ_ENTRY_KEY *Search_key){
unsigned char i;
//msg("[MAC_PHY]MAC_PHY_REQUEST_CNT=%d\n",Macphy_req_table.Macphy_req_cnt);
if (Macphy_req_table[Mod_id].Macphy_req_cnt > 0) {
#ifdef DEBUG_PHY
// msg("[MACPHY_FIND_REQ] SEARCH KEY=%d\n",Search_key->Key_type);
#endif //DEBUG_PHY
//msg("[MACPHY_FIND_REQ] SEARCH KEY=%d, NB_REQ_MAX=%d\n",Search_key->Key_type,NB_REQ_MAX);
switch(Search_key->Key_type){
case PDU_TYPE_KEY:
for(i=0;i<NB_REQ_MAX;i++){
if ( (Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Pdu_type==Search_key->Key.Pdu_type) &&
(Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active == 1) ){
//msg("[MACPHY_FIND] MACPHY_req_table_entry=%p,idx=%d,Phy_resources %p", &Macphy_req_table.Macphy_req_table_entry[i],i,Macphy_req_table.Macphy_req_table_entry[i].Macphy_data_req.Phy_Resources_Entry);
return(&Macphy_req_table[Mod_id].Macphy_req_table_entry[i]);
}
}
break;
/*
case LCHAN_KEY:
for(i=0;i<NB_REQ_MAX;i++){
if ((Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Lchan_id.Index==Search_key->Key.Lchan_id->Index) &&
(Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active == 1) )
return(&Macphy_req_table[Mod_id].Macphy_req_table_entry[i]);
}
break;
case PHY_RESOURCES_KEY:
for(i=0;i<NB_REQ_MAX;i++){
if(Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active == 1)
if ( ( Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources->Time_alloc ==
Search_key->Key.Phy_resources.Time_alloc )
&&( Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources->Freq_alloc ==
Search_key->Key.Phy_resources.Freq_alloc )
&&( Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.CH_index ==
Search_key->CH_index )
&& ( Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Direction == RX))
return(&Macphy_req_table[Mod_id].Macphy_req_table_entry[i]);
}
break;
*/
}
}
#ifndef PHY_EMUL
// msg("[PHY][PHY_MAC] Frame %d : No data request\n",mac_xface->frame);
#endif //PHY_EMUL
return (MACPHY_DATA_REQ_TABLE_ENTRY*)0;
}
void print_active_requests(unsigned char Mod_id) {
int i;
msg("_________________________INST %d , FRAME %d ACTIVE_REQUESTS_________________\n",Mod_id,mac_xface->frame);
for (i=0;i<NB_REQ_MAX;i++){
if (Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active == 1) {
msg("[MACPHY][DATA][REQ] Request %d: Direction %d, Pdu_type %d\n",
i,
Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Direction,
Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Pdu_type);
// Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Lchan_id.Index);
// Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources,
// Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources->Time_alloc,
// Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources->Freq_alloc);
//if(Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Pdu_type==RACH)
//msg("[RACH_REQ] Rach_pdu %p, Payload %p\n",Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Dir.Req_rx.Pdu.Rach_pdu,
// Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Dir.Req_rx.Pdu.Rach_pdu->Rach_payload);
}
}
}
/*___________________________________________________________________________________________________*/
#define RCNT Macphy_req_table[Mod_id].Macphy_req_cnt
MACPHY_DATA_REQ *new_macphy_data_req(unsigned char Mod_id) {
/*___________________________________________________________________________________________________*/
unsigned char i;
for (i=0;i<NB_REQ_MAX;i++){
if (Macphy_req_table[Mod_id].Macphy_req_table_entry[(i)%NB_REQ_MAX].Active == 0) {
Macphy_req_table[Mod_id].Macphy_req_table_entry[(i)%NB_REQ_MAX].Active = 1;
RCNT = (RCNT + 1)%NB_REQ_MAX;
// msg("[MAC_PHY]NEW MAC_REQUEST_CNT=%d,frame %d, Module %d, entry %d \n",Macphy_req_table[Mod_id].Macphy_req_cnt,mac_xface->frame,Mod_id,i);
// Macphy_req_table[Mod_id].Macphy_req_table_entry[i%NB_REQ_MAX].Macphy_data_req.Phy_resources=(PHY_RESOURCES*)malloc16(sizeof(PHY_RESOURCES));
return(&Macphy_req_table[Mod_id].Macphy_req_table_entry[i%NB_REQ_MAX].Macphy_data_req);
}
}
msg("[OPENAIR][MAC][ERROR] frame %d: No more DATA_REQ !!!!\n",mac_xface->frame);
print_active_requests(Mod_id);
mac_xface->macphy_exit("");
//rt_sleep(nano2count(2000));
return((MACPHY_DATA_REQ*)0);
}
#ifndef USER_MODE
EXPORT_SYMBOL(new_macphy_data_req);
#endif
#endif //PHY_CONTEXT
#ifdef MAC_CONTEXT
#include "LAYER2/MAC/extern.h"
// Function called by PHY to indicate available data/measurements for MAC
/*___________________________________________________________________________________________________*/
void macphy_data_ind(unsigned char Mod_id,unsigned char Pdu_type,void *pdu,unsigned short rnti) {
/*___________________________________________________________________________________________________*/
//msg("[OPENAIR][MACPHY] Calling mac_resp In\n");
int i;
// if (Req_rx->crc_status[0]!= -1) { //CRC_STATUS
// msg("[OPENAIR][MACPHY] Calling mac_indicate In\n");
// Req_rx->Meas.UL_meas=&UL_meas[Mod_id];
// Req_rx->Meas.DL_meas=&DL_meas[Mod_id];
switch (Pdu_type) {
case ULSCH:
// msg("[OPENAIR][MACPHY] Received RACH, Sending to MAC\n");
nodeb_decode_ulsch(Mod_id,(ULSCH_PDU *)pdu,rnti);
break;
case DLSCH:
#ifdef DEBUG_UE_DECODE_SACH
msg("[MAC][UE][MAC_PHY] TTI %d Inst %d\n",mac_xface->frame,Mod_id);
#endif
// ue_decode_dlsch(Mod_id-NB_CH_INST,
// (DLSCH_PDU *)pdu,rnti);
break;
default:
break;
}
// msg("Freeing Req %p\n",Macphy_data_req_table_entry);
// }
}
/*PHY_RESOURCES_TABLE_ENTRY *new_phy_resources() {
unsigned char i;
//msg("[OPENAIR][PHY][MAC Interface] New Phy Resource, cnt %d\n",Phy_resources_table.Phy_resources_cnt);
for (i=0;i<NB_PHY_RESOURCES_MAX;i++){
if (Phy_resources_table.Phy_resources_table_entry[(i+Phy_resources_table.Phy_resources_cnt+1)%NB_PHY_RESOURCES_MAX].Active == 0) {
Phy_resources_table.Phy_resources_table_entry[(i+Phy_resources_table.Phy_resources_cnt+1)%NB_PHY_RESOURCES_MAX].Active = 1;
Phy_resources_table.Phy_resources_cnt = (Phy_resources_table.Phy_resources_cnt + 1)%NB_PHY_RESOURCES_MAX;
// msg("[OPENAIR][PHY][MAC Interface] NEW PHY_RESOURCES: Taking index %d\n\n",(i+Phy_resources_table.Phy_resources_cnt+1)%NB_PHY_RESOURCES_MAX);
return(&Phy_resources_table.Phy_resources_table_entry[(i+Phy_resources_table.Phy_resources_cnt)%NB_PHY_RESOURCES_MAX]);
}
}
msg("[OPENAIR][MAC][ERROR] No more PHY_RESOURCES !!!!\n");
#ifdef USER_MODE
exit(-1);
#else
print_active_indications();
print_active_requests();
mac_xface->macphy_exit();
#endif
}
*/
#endif //MAC_CONTEXT
// Measurements, etc ..
//short phy_resource_cnt = 0, macphy_data_req_cnt = 0, macphy_data_ind_cnt = 0;
+211
View File
@@ -0,0 +1,211 @@
/*________________________mac_phy_primitives.h________________________
Authors : Hicham Anouar, Raymond Knopp
Company : EURECOM
Emails : anouar@eurecom.fr, knopp@eurecom.fr
________________________________________________________________*/
#ifndef __MAC_PHY_PRIMITIVES_H__
# define __MAC_PHY_PRIMITIVES_H__
#include "../LAYER2/MAC/defs.h"
/**@defgroup _mac_phy_primitives_ MAC Layer Primitives for Communications with PHY
*@ingroup w3g4f_mac_layer_
*@{
This subclause describes the primitives for communications between the MAC and PHY sub-layers.
The primitives for dynamic MAC-PHY PDU exchange (Transport channel interface) are:
- MACPHY_DATA_REQ: transfers or requests a PDU from PHY. The data is passed along with the dynamic PHY transmission
format (coding and modulation, time/freq/space resource allocation)
- MACPHY_DATA_IND: Function call (by PHY) to deliver a new PDU and corresponding measurements to MAC. This implicitly confirms the MACPHY_DATA_REQ by
filling the fields of the request (TX or RX) with the data and measurements.
One primitive is used for semi-static configuration (during logical channel establishment)
relaying the puncturing/repetition patterns for HARQ:
- MACPHY_CONFIG_SACH_HARQ_REQ (still to be defined...)
The primitive for static (re)configuration is:
- MACPHY_CONFIG_REQ : This primitive transports the initial configuration during the setup phase of equipment, both for CH and UE.
Static configuration is used during the initialization phase of the equipment. For a CH, it is done prior to any communication. For a UE, some
structures may be set after receiving configuration information from the network via the BCCH/CCCH.
*/
/*! \brief MACPHY-DATA-REQ_RX structure is used to request transfer a new PDU from PHY corresponding to a particular transport channel*/
typedef struct {
int crc_status[MAX_NUMBER_TB_PER_LCHAN]; /*!< This field indicates the CRC status of the PDU upon reception from PHY*/
unsigned char num_tb; /*!< This field indicates the number of transport blocks to be received*/
unsigned short tb_size_bytes; /*!< This field indicates the number of bytes per transpor block*/
unsigned int Active_process_map; /*!< HARQ indicator for active processes*/
union {
CHBCH_PDU *Chbch_pdu; /*!< This is a pointer to CHBCH data*/
DL_SACH_PDU *DL_sach_pdu; /*!< This is a pointer to DL_SACH data*/
UL_SACH_PDU *UL_sach_pdu; /*!< This is a pointer to UL_SACH data*/
RACH_PDU *Rach_pdu; /*!< This is a pointer to RACH data*/
MRBCH_PDU *Mrbch_pdu; /*!< This is a pointer to MRBCH data*/
} Pdu;
union {
DL_MEAS *DL_meas; /*!< This is an array of pointers to the current measurements of DL quality at UE (indexed by CH_id) */
UL_MEAS *UL_meas; /*!< This is an array of pointers to the current measurements of UL quality at Node-B (indexed by user_id) */
} Meas;
} MACPHY_DATA_REQ_RX;
/*! \brief MACPHY-DATA-REQ_TX structure is used to transfer a new PDU to PHY corresponding to a particular transport channel*/
typedef struct {
unsigned char num_tb; /*!< This field indicates the number of transport blocks to be received*/
unsigned short tb_size_bytes; /*!< This field indicates the number of bytes per transpor block*/
unsigned int Active_process_map; /*!< HARQ indicator for active processes*/
unsigned int New_process_map; /*!< HARQ indicator for new processes*/
// unsigned char round_indices_tx;
union {
CHBCH_PDU *Chbch_pdu; /*!< pointer to CHBCH data */
DL_SACH_PDU DL_sach_pdu; /*!< pointer to DL_SACH data*/
UL_SACH_PDU UL_sach_pdu; /*!< pointer to UL_SACH data*/
RACH_PDU Rach_pdu; //H.A /*!< pointer to RACH data */
MRBCH_PDU *Mrbch_pdu; /*!< pointer to MRBCH data */
} Pdu;
}MACPHY_DATA_REQ_TX;
/*! \brief MACPHY-DATA-REQ primitive is used to transfer a new PDU to PHY corresponding to a particular transport channel*/
typedef struct {
unsigned char Direction;
unsigned char Pdu_type; /*!< This field indicates the type of PDU requested */
LCHAN_ID Lchan_id; /*!< This field indicates the flow id of the PDU */
PHY_RESOURCES *Phy_resources; /*!< This field indicates to PHY the physical resources */
unsigned int format_flag; /*!< This field indicates to PHY something about a SACH, e.g. presense of SACCH*/
union {
MACPHY_DATA_REQ_RX Req_rx; /*!< This field contains the request corresponding to an RX resource*/
MACPHY_DATA_REQ_TX Req_tx; /*!< This field contains the request corresponding to a TX resource*/
} Dir;
}MACPHY_DATA_REQ;
/*!\fn void macphy_data_ind(unsigned char Mod_id,MACPHY_DATA_REQ_RX *Req_rx,unsigned char Pdu_type,unsigned short Index);
\brief MACPHY_DATA_IND function call. Called by PHY to upload PDU and measurements in response to a MACPHY_DATA_REQ_RX.
@param Mod_id MAC instance ID (only useful if multiple MAC instances run in the same machine)
@param Req_rx Pointer to MACPHY_DTA_REQ_RX received previously
@param Pdu_type Type of PDU (redundant!)
@param Index CH Index for CH, UEid for UE
*/
void macphy_data_ind(unsigned char Mod_id,
MACPHY_DATA_REQ_RX *Req_rx,
unsigned char Pdu_type,
unsigned short Index);
/*! \brief MACPHY-CONFIG-REQ primitive is used to configure a new instance of OpenAirInterface (static configuration) during initialization*/
typedef struct {
PHY_FRAMING Phy_framing; /*!< Framing Configuration*/
PHY_CHSCH Phy_chsch[8]; /*!< CHSCH Static Configuration*/
PHY_CHBCH Phy_chbch; /*!< CHBCH Static Configuration*/
PHY_SCH Phy_sch[8]; /*!< SCH Static Configuration*/
PHY_SACH Phy_sach; /*!< SACH Statuc Configuration*/
} MACPHY_CONFIG_REQ;
/*! \brief MACPHY-CONFIG-SACH-HARQ-REQ primitive is used to configure a new SACH transport channel (dynamic configuration) during logical channel establishment*/
//typedef struct {
// LCHAN_ID Lchan_id; /*!< This is the identifier of the SACH, which should simply be the logical channel id*/
// HARQ_PARAMS Harq_params; /*!< This is the set of HARQ parameters corresponding to the QoS description of the logical channel*/
//} MACPHY_CONFIG_SACH_HARQ_REQ;
/** @} */
#define MAX_NUMBER_OF_MAC_INSTANCES 16
#define NULL_PDU 255
#define CHBCH 0
#define DL_SACH 1
#define UL_SACH 2
#define UL_SACCH_SACH 3
#define RACH 4
#define MRBCH 5
#define NUMBER_OF_SUBBANDS 64
#define LCHAN_KEY 0
#define PDU_TYPE_KEY 1
#define PHY_RESOURCES_KEY 2
typedef struct Macphy_req_entry_key{
unsigned char Key_type;
union{
LCHAN_ID *Lchan_id; //SACH, EMULATION
unsigned char Pdu_type;//CHBCH, RACH, EMULATION
PHY_RESOURCES Phy_resources;//REAL PHY
}Key;
}MACPHY_REQ_ENTRY_KEY;
/** @ingroup _PHY_TRANSPORT_CHANNEL_PROCEDURES_
* @{
\var typedef struct Macphy_data_req_table_entry {
MACPHY_DATA_REQ Macphy_data_req;
unsigned char Active;
} MACPHY_DATA_REQ_TABLE_ENTRY;
\brief An entry in the MACPHY_DATA_REQ Table.
*/
typedef struct Macphy_data_req_table_entry {
/// The MACPHY_DATA_REQ Structure itself
MACPHY_DATA_REQ Macphy_data_req;
/// Active flag. Active=1 means that the REQ is pending.
unsigned char Active;
} MACPHY_DATA_REQ_TABLE_ENTRY;
/*!\var typedef struct {
MACPHY_DATA_REQ_TABLE_ENTRY *Macphy_req_table_entry;
unsigned int Macphy_req_cnt;
} MACPHY_DATA_REQ_TABLE
\brief The MACPHY_DATA_REQ interface between MAC and PHY. This table stores the pending requests from MAC which are serviced by PHY. The pointer Macphy_req_table_entry points
to an array of idle reqests allocated during initialization of the MAC-layer.
*/
typedef struct {
/// Pointer to a MACPHY_DATA_REQ
MACPHY_DATA_REQ_TABLE_ENTRY *Macphy_req_table_entry;
/// Number of active requests
unsigned int Macphy_req_cnt;
} MACPHY_DATA_REQ_TABLE;
/** @} */
/*typedef struct Tx_Phy_Pdu{ //H.A
PHY_RESOURCES *Phy_resources;
MACPHY_DATA_IND *Macphy_data_ind;
}T_PHY_PDU;
typedef struct Rx_Phy_Pdu{ //H.A
PHY_RESOURCES *Phy_resources;
char *Phy_payload;
}RX_PHY_PDU;*/
typedef struct GRANTED_LCHAN_TABLE_ENTRY{
PHY_RESOURCES *Phy_resources;
LCHAN_ID Lchan_id;
}GRANTED_LCHAN_TABLE_ENTRY;
void clear_macphy_data_req(u8);
//void clean_macphy_interface(void);
unsigned char phy_resources_compare(PHY_RESOURCES *,PHY_RESOURCES*);
MACPHY_DATA_REQ_TABLE_ENTRY* find_data_req_entry(u8,MACPHY_REQ_ENTRY_KEY*);
void print_active_requests(u8);
void mac_process_meas_ul(u8 Mod_id,UL_MEAS *UL_meas, u16 Index);
void mac_process_meas_dl(u8 Mod_id,DL_MEAS *DL_meas, u16 Index);
MACPHY_DATA_REQ *new_macphy_data_req(u8);
//PHY_RESOURCES_TABLE_ENTRY *new_phy_resources(void);
//MACPHY_DATA_IND *new_macphy_data_ind(void);
#endif
+27
View File
@@ -0,0 +1,27 @@
#ifndef __PHY_INTERFACE_VARS_H__
#define __PHY_INTERFACE_VARS_H__
//#include "SIMULATION/PHY_EMULATION/spec_defs.h"
#include "defs.h"
#ifdef PHY_EMUL
#include "SIMULATION/PHY_EMULATION/DEVICE_DRIVER/defs.h"
#include "SIMULATION/simulation_defs.h"
#endif
unsigned int mac_debug;
//MAC_xface *mac_xface;
//MACPHY_PARAMS MACPHY_params;
unsigned int mac_registered;
#endif
#ifndef USER_MODE
EXPORT_SYMBOL(mac_xface);
#endif //PHY_EMUL