phy_stub_UE.h 8.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * phy_stub_UE.h
 *
 *  Created on: Sep 14, 2017
 *      Author: montre
 */


#ifndef __PHY_STUB_UE__H__
#define __PHY_STUB_UE__H__

#include <stdint.h>
#include "openair2/PHY_INTERFACE/IF_Module.h"
#include "nfapi_interface.h"
#include "nfapi_pnf_interface.h"
16
#include <pthread.h>
17
#include <semaphore.h>
18
#include "nfapi/oai_integration/vendor_ext.h"
19 20 21
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
//#include "openair1/PHY/defs.h"
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
22
#include "queue_t.h"
23

Ricky S's avatar
Ricky S committed
24 25 26 27
#define NUM_MCS 28
#define NUM_SINR 100
#define NUM_BLER_COL 13

28
// this mutex is used to set multiple UE's UL value in L2 FAPI simulator.
Melissa Elkadi's avatar
Melissa Elkadi committed
29
extern FILL_UL_INFO_MUTEX_t fill_ul_mutex;
30 31
//below 2 difinitions move to phy_stub_UE.c to add initialization when difinition.
extern UL_IND_t *UL_INFO;
32
// New
33
/// Pointers to config_request types. Used from nfapi callback functions.
34
//below 3 difinitions move to phy_stub_UE.c to add initialization when difinition.
35

36 37 38
//below 2 difinitions move to lte-ue.c to add initialization when difinition.
//int next_ra_frame;
//module_id_t next_Mod_id;
39

Ricky S's avatar
Ricky S committed
40 41 42 43 44 45 46
typedef struct
{
    uint8_t sf;
    uint16_t rnti[256];
    uint8_t mcs[256];
    float sinr;
    uint16_t pdu_size;
47
    bool drop_flag[256];
Melissa's avatar
Melissa committed
48
    bool latest;
Ricky S's avatar
Ricky S committed
49 50 51 52 53 54 55 56 57 58

} sf_rnti_mcs_s;

typedef struct
{
    uint16_t length;
    float bler_table[NUM_SINR][NUM_BLER_COL];
} bler_struct;

extern bler_struct bler_data[NUM_MCS];
Michael Cook's avatar
Michael Cook committed
59 60


61 62 63
extern nfapi_dl_config_request_t* dl_config_req;
extern nfapi_ul_config_request_t* ul_config_req;
extern nfapi_hi_dci0_request_t* hi_dci0_req;
64
extern int	tx_req_num_elems;
Michael Cook's avatar
Michael Cook committed
65

66
// This function should return all the sched_response config messages which concern a specific UE. Inside this
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
// function we should somehow make the translation of config message's rnti to Mod_ID.
Sched_Rsp_t get_nfapi_sched_response(uint8_t Mod_id);

// This function will be processing DL_config and Tx.requests and trigger all the MAC Rx related calls at the UE side,
// namely:ue_send_sdu(), or ue_decode_si(), or ue_decode_p(), or ue_process_rar() based on the rnti type.
//void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id);

int pnf_ul_config_req_UE_MAC(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req);

// This function will be processing UL and HI_DCI0 config requests to trigger all the MAC Tx related calls
// at the UE side, namely: ue_get_SR(), ue_get_rach(), ue_get_sdu() based on the pdu configuration type.
// The output of these calls will be put to an UL_IND_t structure which will then be the input to
// send_nfapi_UL_indications().
UL_IND_t generate_nfapi_UL_indications(Sched_Rsp_t sched_response);

// This function should pass the UL indication messages to the eNB side through the socket interface.
void send_nfapi_UL_indications(UL_IND_t UL_INFO);

// This function should be filling the nfapi ULSCH indications at the MAC level of the UE in a similar manner
// as fill_rx_indication() does. It should get called from ue_get_SDU()

//void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe);

90 91
void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index,
                            nfapi_ul_config_request_t *ul_config_req);
92 93 94 95


// This function should be indicating directly to the eNB when there is a planned scheduling request at the MAC layer
// of the UE. It should get called from ue_get_SR()
96 97
void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti,
                            nfapi_ul_config_request_t *ul_config_req);
98 99 100

// In our case the this function will be always indicating ACK to the MAC of the eNB (i.e. always assuming)
// successful decoding.
101 102
void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti,
                                nfapi_ul_config_request_t *ul_config_req);
103 104 105 106 107 108 109 110


void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI);


void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti);


111 112
void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti,
                                    nfapi_ul_config_request_t *ul_config_req);
113

114 115
void fill_uci_harq_indication_UE_MAC(int Mod_id, int frame, int subframe, UL_IND_t *UL_INFO,nfapi_ul_config_harq_information *harq_information, uint16_t rnti,
                                    nfapi_ul_config_request_t *ul_config_req
116 117 118 119 120 121 122
			      /*uint8_t tdd_mapping_mode,
			      uint16_t tdd_multiplexing_mask*/);

int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int frame, int subframe, module_id_t Mod_id);

void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
                         nfapi_ul_config_request_pdu_t *ul_config_pdu,
123 124
                         uint16_t frame,uint8_t subframe,uint8_t srs_present, int index,
                         nfapi_ul_config_request_t *ul_config_req);
125

126 127 128 129 130 131 132
typedef struct phy_channel_params_t
{
    uint16_t sfn_sf;
    float sinr;
    // Incomplete, need all channel parameters
} phy_channel_params_t;

Andrew Burger's avatar
Andrew Burger committed
133 134 135 136 137 138
typedef struct nfapi_tx_req_pdu_list_t
{
    int num_pdus;                  /* number .pdus[] objects */
    nfapi_tx_request_pdu_t pdus[]; /* see "struct hack" */
} nfapi_tx_req_pdu_list_t;

139 140 141 142 143 144
typedef struct nfapi_dl_config_req_tx_req_t
{
    nfapi_dl_config_request_t *dl_config_req;
    nfapi_tx_req_pdu_list_t *tx_req_pdu_list;
} nfapi_dl_config_req_tx_req_t;

Andrew Burger's avatar
Andrew Burger committed
145 146
void nfapi_free_tx_req_pdu_list(nfapi_tx_req_pdu_list_t *);

147 148 149 150
void dl_config_req_UE_MAC_dci(int sfn,
                              int sf,
                              nfapi_dl_config_request_pdu_t *dci,
                              nfapi_dl_config_request_pdu_t *dlsch,
151
                              int num_ue,
Andrew Burger's avatar
Andrew Burger committed
152
                              nfapi_tx_req_pdu_list_t *);
153 154 155 156
void dl_config_req_UE_MAC_bch(int sfn,
                              int sf,
                              nfapi_dl_config_request_pdu_t *bch,
                              int num_ue);
Javier Morgade's avatar
Javier Morgade committed
157 158 159
void dl_config_req_UE_MAC_mch(int sfn,
                              int sf,
                              nfapi_dl_config_request_pdu_t *bch,
160
                              int num_ue,
Andrew Burger's avatar
Andrew Burger committed
161
                              nfapi_tx_req_pdu_list_t *);
162 163 164 165

int tx_req_UE_MAC(nfapi_tx_request_t* req);


166 167 168 169
void hi_dci0_req_UE_MAC(int sfn,
                        int sf,
                        nfapi_hi_dci0_request_pdu_t* bch,
                        int num_ue);
170 171 172 173

// The following set of memcpy functions should be getting called as callback functions from
// pnf_p7_subframe_ind.

174
int memcpy_ul_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req);
175

176
int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req);
177 178 179

void UE_config_stub_pnf(void);

180 181 182 183
void *memcpy_tx_req_standalone(nfapi_tx_request_t *tx_req);

void *memcpy_dl_config_req_standalone(nfapi_dl_config_request_t *dl_config_req);

Michael Cook's avatar
Michael Cook committed
184
// open an SCTP socket with a standalone PNF module
185
void ue_init_standalone_socket(int tx_port, int rx_port);
186

Michael Cook's avatar
Michael Cook committed
187
// read from standalone pnf socket call corresponding memcpy functions
188
void *ue_standalone_pnf_task(void *context);
189 190
void send_standalone_msg(UL_IND_t *UL, nfapi_message_id_e msg_type);
void send_standalone_dummy(void);
191
void enqueue_dl_config_req_tx_req(nfapi_dl_config_request_t *dl_config_req, nfapi_tx_request_t *tx_req);
192

Andrew Burger's avatar
Andrew Burger committed
193 194 195 196 197 198 199 200 201 202
// Convert downlink nfapi messages to a string.
// Returned memory is malloc'ed, caller is responsible for freeing.
char *nfapi_dl_config_req_to_string(nfapi_dl_config_request_t *req);
char *nfapi_ul_config_req_to_string(nfapi_ul_config_request_t *req);

// Convert downlink nfapi messages to a string.
// Returned memory is statically allocated.
const char *dl_pdu_type_to_string(uint8_t pdu_type);
const char *ul_pdu_type_to_string(uint8_t pdu_type);

203
extern queue_t dl_config_req_tx_req_queue;
204 205 206 207 208
extern queue_t ul_config_req_queue;
extern queue_t hi_dci0_req_queue;

extern nfapi_ul_config_request_t* ul_config_req;
extern nfapi_hi_dci0_request_t* hi_dci0_req;
209

Andrew Burger's avatar
Andrew Burger committed
210
extern int current_sfn_sf;
Andrew Burger's avatar
Andrew Burger committed
211

212 213
extern sem_t sfn_semaphore;

214
#endif /* PHY_STUB_UE_H_ */