Merge branch 'eurecom-nfapi-nr-arch-mod' into episys/merge_nsa_w_develop

This commit is contained in:
Melissa Elkadi
2021-08-13 10:27:30 -07:00
189 changed files with 17377 additions and 19130 deletions
-283
View File
@@ -1,283 +0,0 @@
/*
* 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
*/
/*________________________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("new_macphy_data_req: no more DATA_REQ");
//rt_sleep(nano2count(2000));
return((MACPHY_DATA_REQ*)0);
}
#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");
exit(-1);
}
*/
#endif //MAC_CONTEXT
// Measurements, etc ..
//short phy_resource_cnt = 0, macphy_data_req_cnt = 0, macphy_data_ind_cnt = 0;
-232
View File
@@ -1,232 +0,0 @@
/*
* 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
*/
/*________________________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(uint8_t);
//void clean_macphy_interface(void);
unsigned char phy_resources_compare(PHY_RESOURCES *,PHY_RESOURCES*);
MACPHY_DATA_REQ_TABLE_ENTRY* find_data_req_entry(uint8_t,MACPHY_REQ_ENTRY_KEY*);
void print_active_requests(uint8_t);
void mac_process_meas_ul(uint8_t Mod_id,UL_MEAS *UL_meas, uint16_t Index);
void mac_process_meas_dl(uint8_t Mod_id,DL_MEAS *DL_meas, uint16_t Index);
MACPHY_DATA_REQ *new_macphy_data_req(uint8_t);
//PHY_RESOURCES_TABLE_ENTRY *new_phy_resources(void);
//MACPHY_DATA_IND *new_macphy_data_ind(void);
#endif