split_headers.h 5.79 KB
Newer Older
laurent's avatar
laurent committed
1 2 3
#ifndef __SPLIT_HEADERS_H
#define __SPLIT_HEADERS_H

laurent's avatar
laurent committed
4
#include <stdint.h>
laurent's avatar
laurent committed
5
#include <stdbool.h>
laurent's avatar
laurent committed
6
#include <openair1/PHY/defs_eNB.h>
7 8 9 10 11 12

#define CU_IP "127.0.0.1"
#define CU_PORT "7878"
#define DU_IP "127.0.0.1"
#define DU_PORT "8787"

laurent's avatar
laurent committed
13 14 15 16 17
#define MTU 65536
#define UDP_TIMEOUT 100000L // in nano second
#define MAX_BLOCKS 16
#define blockAlign 32 //bytes

18

laurent's avatar
laurent committed
19 20 21 22 23 24 25 26 27
typedef struct {
  char *sourceIP;
  char *sourcePort;
  char *destIP;
  char *destPort;
  struct addrinfo *destAddr;
  int sockHandler;
} UDPsock_t;

laurent's avatar
laurent committed
28 29 30
#define CTsentCUv0 0xA500
#define CTsentDUv0 0x5A00

laurent's avatar
laurent committed
31 32 33 34 35 36 37 38 39
typedef struct commonUDP_s {
  uint64_t timestamp; // id of the group (subframe for LTE)
  uint16_t nbBlocks;       // total number of blocks for this timestamp
  uint16_t blockID;        // id: 0..nbBocks-1
  uint16_t contentType;    // defines the content format
  uint16_t contentBytes;   // will be sent in a UDP packet, so must be < 2^16 bytes
} commonUDP_t;

typedef struct frequency_s {
laurent's avatar
laurent committed
40 41 42
  int frame;
  int subframe;
  int sampleSize;
laurent's avatar
laurent committed
43
  int nbAnt;
laurent's avatar
laurent committed
44 45
  int nbSamples;
} frequency_t;
laurent's avatar
laurent committed
46

laurent's avatar
laurent committed
47 48 49 50 51 52 53 54
typedef struct {
  uint16_t max_preamble[4];
  uint16_t max_preamble_energy[4];
  uint16_t max_preamble_delay[4];
  uint16_t avg_preamble_energy[4];
} fs6_ul_t;

typedef struct {
55
  uint8_t pbch_pdu[4];
laurent's avatar
laurent committed
56 57 58 59 60 61 62 63
  int num_pdcch_symbols;
  int num_dci;
  DCI_ALLOC_t dci_alloc[32];
  int num_mdci;
  int amp;
  LTE_eNB_PHICH phich_vars;
} fs6_dl_t;

64 65 66
enum pckType {
  fs6UlConfig=25,
  fs6DlConfig=26,
67 68 69
  fs6ULConfigCCH=27,
  fs6ULsch=28,
  fs6ULcch=29,
70 71
  fs6ULindicationHarq=40,
  fs6ULindicationSr=41,
72 73
};

laurent's avatar
laurent committed
74
typedef struct {
75 76 77 78 79 80 81 82
  enum pckType type:8;
  uint16_t UE_id;
  int8_t harq_pid;
  UE_type_t ue_type;
  uint16_t harq_mask;
  uint16_t nb_rb;
  uint8_t Qm;
  uint16_t first_rb;
83 84 85 86
  uint8_t O_RI;
  uint8_t Or1;
  uint16_t Msc_initial;
  uint8_t Nsymb_initial;
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
  uint8_t V_UL_DAI;
  uint8_t srs_active;
  uint32_t TBS;
  uint8_t Nsymb_pusch;
  uint8_t Mlimit;
  uint8_t max_turbo_iterations;
  uint8_t bundling;
  uint16_t beta_offset_cqi_times8;
  uint16_t beta_offset_ri_times8;
  uint16_t beta_offset_harqack_times8;
  uint8_t Msg3_active;
  uint16_t rnti;
  uint8_t cyclicShift;
  uint8_t cooperation_flag;
  uint8_t num_active_cba_groups;
  uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
} fs6_dl_ulsched_t;

typedef struct {
  enum pckType type:8;
laurent's avatar
laurent committed
107 108 109
  int UE_id;
  int8_t harq_pid;
  uint16_t rnti;
laurent's avatar
laurent committed
110 111
  int16_t sqrt_rho_a;
  int16_t sqrt_rho_b;
112
  CEmode_t CEmode:8;
laurent's avatar
laurent committed
113 114 115 116 117 118
  uint16_t nb_rb;
  uint8_t Qm;
  int8_t Nl;
  uint8_t pdsch_start;
  uint8_t sib1_br_flag;
  uint16_t i0;
119
  uint32_t rb_alloc[4];;
laurent's avatar
laurent committed
120 121 122
  int dataLen;
} fs6_dl_uespec_t;

123
typedef struct {
124 125 126 127 128 129 130 131 132 133 134
  int16_t UE_id;
  LTE_eNB_UCI cch_vars;
} fs6_dl_uespec_ulcch_element_t;

typedef struct {
  enum pckType type:8;
  int16_t nb_active_ue;
} fs6_dl_uespec_ulcch_t;

typedef struct {
  enum pckType type:8;
135 136 137 138
  short UE_id;
  short harq_id;
  short segment;
  short segLen;
139
  int ulsch_power[2];
140 141
} fs6_ul_uespec_t;

142
typedef struct {
143
  enum pckType type:8;
144 145 146 147 148 149 150
  int UEid;
  int frame;
  int subframe;
  uint8_t harq_ack[4];
  uint8_t tdd_mapping_mode;
  uint16_t tdd_multiplexing_mask;
  unsigned short n0_subband_power_dB;
151 152
  uint16_t rnti;
  int32_t stat;
153 154 155 156 157 158 159 160
} fs6_ul_uespec_uci_element_t;

typedef struct {
  enum pckType type:8;
  int16_t nb_active_ue;
}  fs6_ul_uespec_uci_t;


laurent's avatar
laurent committed
161
bool createUDPsock (char *sourceIP, char *sourcePort, char *destIP, char *destPort, UDPsock_t *result);
162
int receiveSubFrame(UDPsock_t *sock, void *bufferZone,  int bufferSize, uint16_t contentType);
laurent's avatar
laurent committed
163
int sendSubFrame(UDPsock_t *sock, void *bufferZone, ssize_t secondHeaderSize, uint16_t contentType);
164

laurent's avatar
laurent committed
165
#define initBufferZone(xBuf) \
166
  uint8_t xBuf[FS6_BUF_SIZE];   \
laurent's avatar
laurent committed
167 168
  ((commonUDP_t *)xBuf)->nbBlocks=0;

laurent's avatar
laurent committed
169
#define hUDP(xBuf) ((commonUDP_t *)xBuf)
170 171 172
#define hDL(xBuf)  ((fs6_dl_t*)(((commonUDP_t *)xBuf)+1))
#define hUL(xBuf)  ((fs6_ul_t*)(((commonUDP_t *)xBuf)+1))
#define hDLUE(xBuf) ((fs6_dl_uespec_t*) (((fs6_dl_t*)(((commonUDP_t *)xBuf)+1))+1))
173
#define hTxULUE(xBuf) ((fs6_dl_ulsched_t*) (((fs6_dl_t*)(((commonUDP_t *)xBuf)+1))+1))
174
#define hTxULcch(xBuf) ((fs6_dl_uespec_ulcch_t*) (((fs6_dl_t*)(((commonUDP_t *)xBuf)+1))+1))
175
#define hULUE(xBuf) ((fs6_ul_uespec_t*) (((fs6_ul_t*)(((commonUDP_t *)xBuf)+1))+1))
176
#define hULUEuci(xBuf) ((fs6_ul_uespec_uci_t*) (((fs6_ul_t*)(((commonUDP_t *)xBuf)+1))+1))
laurent's avatar
laurent committed
177

laurent's avatar
laurent committed
178
static inline size_t alignedSize(uint8_t *ptr) {
laurent's avatar
laurent committed
179 180
  commonUDP_t *header=(commonUDP_t *) ptr;
  return ((header->contentBytes+sizeof(commonUDP_t)+blockAlign-1)/blockAlign)*blockAlign;
laurent's avatar
laurent committed
181
}
laurent's avatar
laurent committed
182

laurent's avatar
laurent committed
183
static inline void *commonUDPdata(uint8_t *ptr) {
laurent's avatar
laurent committed
184
  return (void *) (((commonUDP_t *)ptr)+1);
185 186
}

187
void setAllfromTS(uint64_t TS);
188 189
void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask,  uint16_t rnti,  int32_t stat);
void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen);
laurent's avatar
laurent committed
190 191 192
void *cu_fs6(void *arg);
void *du_fs6(void *arg);
void fill_rf_config(RU_t *ru, char *rf_config_file);
193
void rx_rf(RU_t *ru);
laurent's avatar
laurent committed
194
void tx_rf(RU_t *ru);
laurent's avatar
laurent committed
195 196
void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe);
void pmch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc);
laurent's avatar
laurent committed
197 198 199 200 201 202 203 204 205 206
bool dlsch_procedures(PHY_VARS_eNB *eNB,
                      L1_rxtx_proc_t *proc,
                      int harq_pid,
                      LTE_eNB_DLSCH_t *dlsch,
                      LTE_eNB_UE_stats *ue_stats) ;
void pdsch_procedures(PHY_VARS_eNB *eNB,
                      L1_rxtx_proc_t *proc,
                      int harq_pid,
                      LTE_eNB_DLSCH_t *dlsch,
                      LTE_eNB_DLSCH_t *dlsch1);
laurent's avatar
laurent committed
207 208 209 210
void srs_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc);
void uci_procedures(PHY_VARS_eNB *eNB,
                    L1_rxtx_proc_t *proc);

laurent's avatar
laurent committed
211 212 213 214 215
// mistakes in main OAI
void  phy_init_RU(RU_t *);
void feptx_prec(RU_t *);
void feptx_ofdm(RU_t *);
void oai_subframe_ind(uint16_t sfn, uint16_t sf);
216
void fep_full(RU_t *ru);
217
extern uint16_t sf_ahead;
laurent's avatar
laurent committed
218
#endif