ecc4b2b3d5164ffaf3983f0b055dae09e0c19900
[o-du/l2.git] / src / phy_stub / phy_stub.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18 #include <unistd.h>
19
20 /* Changes the IP information 
21 * At DU1, SOURCE_DU_IPV4_ADDR = 192.168.130.81 and DESTINATION_DU_IPV4_ADDR = 192.168.130.83 
22 * At DU2, SOURCE_DU_IPV4_ADDR = 192.168.130.83 and DESTINATION_DU_IPV4_ADDR = 192.168.130.81 */
23 #define SOURCE_DU_IPV4_ADDR      "192.168.130.81"
24 #define DESTINATION_DU_IPV4_ADDR "192.168.130.83"
25 #define PORT_NUMBER 8080
26 #define NUM_THREADS 1
27
28 #ifdef NR_TDD
29 #define MAX_SLOT_VALUE   19
30 #else
31 #define MAX_SLOT_VALUE   9
32 #endif
33 #define MAX_SFN_VALUE    1023
34 #define NR_PCI            1
35 #define SLOT_DELAY       3
36 #define NUM_DRB_TO_PUMP_DATA  3
37 #define NUM_UL_PACKETS   1
38
39 /*UE Ids for RACH IND*/
40 #define UE_IDX_0     0
41 #define UE_IDX_1     1
42 #define UE_IDX_2     2
43
44 /* Default RA Preamble index to be used when Rach Indication is triggered from
45  * PHY stub */
46 #define CB_RA_PREAMBLE_IDX 3  /* For contention based RA */
47 #define CF_RA_PREAMBLE_IDX 8  /* For contention free RA */
48
49 bool     slotIndicationStarted;
50 uint16_t sfnValue;
51 uint16_t slotValue;
52
53 /*Mapping between LCG ID and BSR Idx*/
54 typedef struct lcgBufferSize
55 {
56    uint8_t lcgId;   /*LCG ID for which BSR will be requested*/
57    /*BufferStatus Index. This is as per Spec 38.321, BSR will be reported as Index 
58     * Refer table Table 6.1.3.1-1:Short_BSR and Table 6.1.3.1-2:Long_BSR*/
59    uint8_t bsIdx;
60 }LcgBufferSize;
61
62 /* UE specific information */
63 typedef struct ueCb
64 {
65    uint8_t  ueId;
66    uint16_t crnti;
67    bool     rachIndSent;
68    bool     isCFRA;
69    bool     msg3Sent;
70    bool     msg5ShortBsrSent;
71    bool     msg5Sent;
72    bool     dlDedMsg;
73    bool     msgNasSecurityModeComp;
74    bool     msgRrcSecurityModeComp;
75    bool     msgRrcReconfigComp;
76    bool     msgRegistrationComp;
77    uint8_t  rlcSnForSrb1;           /* Sequence number of PDU at RLC for AM mode */
78    uint8_t  pdcpSn;                 /* Sequence number of PDU at PDCP */
79 }UeCb;
80
81 /* Database to store information for all UE */
82 typedef struct ueDb
83 {
84    uint8_t   numActvUe;
85    UeCb      ueCb[MAX_NUM_UE];
86 }UeDb;
87
88 typedef struct ipCfg
89 {
90    uint32_t sourceDu;
91    uint32_t destinationDu;
92    uint16_t portNumber;
93 }IpCfg;
94
95 typedef struct phyDb
96 {
97    bool   isServer;
98    IpCfg  ipCfgInfo;  
99    UeDb    ueDb;
100 }PhyDb;
101
102 PhyDb phyDb;
103
104 typedef enum
105 {
106    MSG_TYPE_MSG3,
107    MSG_TYPE_SHORT_BSR,
108    MSG_TYPE_MSG5,
109    MSG_TYPE_NAS_SECURITY_MODE_COMPLETE,
110    MSG_TYPE_RRC_SECURITY_MODE_COMPLETE,
111    MSG_TYPE_REGISTRATION_COMPLETE,
112    MSG_TYPE_RRC_RECONFIG_COMPLETE
113 }MsgType;
114
115 void phyToMac ARGS((uint16_t msgType, uint32_t msgLen,void *msg));
116 #ifdef INTEL_FAPI
117 void fillTlvs ARGS((fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t
118 length, uint16_t value, uint32_t *msgLen));
119 void fillMsgHeader ARGS((fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen));
120 #endif
121 void procPhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
122 void l1StartConsoleHandler();
123 void l1HdlSlotIndicaion(bool);
124 void GenerateTicks();
125 uint8_t l1SendUlUserData(uint8_t drbId, uint8_t ueIdx);
126 uint8_t l1SendStatusPdu();
127 uint16_t l1BuildAndSendSlotIndication();
128 uint16_t l1BuildAndSendStopInd();
129 int inet_pton(int af, const char *sourc, void *dst);
130 void *establishConnectionWithPeerL1(void *args);
131 uint16_t l1BuildAndSendRachInd(uint16_t slot, uint16_t sfn, uint8_t raPreambleIdx);
132
133 /**********************************************************************
134          End of file
135 **********************************************************************/