msg3 and msg4 changes
[o-du/l2.git] / src / mt / ss_rbuf.x
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
19 /********************************************************************20**
20   
21      Name:    Packet Buffers Free Manager 
22   
23      Type:     C include file
24   
25      Desc:     This file implements the funcitons required to isolate
26                freeing of packer buffers from Main stack processing. This will be 
27                usefull in a hyper threaded environment where the freeing can be
28                done from low priority thread
29   
30      File:     ss_rbuf.x
31   
32      Sid:      ss_rbuf.x@@/main/TeNB_Main_BR/3 - Mon Aug 11 16:44:15 2014
33    
34      Prg:      
35   
36 *********************************************************************21*/
37 #ifndef __SS_RBUF_X__
38 #define __SS_RBUF_X__
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 extern Void SsRngBufEnable ARGS((Void));
44 extern Void SsRngBufDisable ARGS((Void));
45 extern S16 SCreateSRngBuf ARGS((U32 id, Region region, Pool pool, U32 elmSize, U32 rngSize));
46 extern S16 SDestroySRngBuf ARGS((U32 id, Region region, Pool pool));
47 extern S16 SAttachSRngBuf ARGS((U32 id, U32 ent, U32 txRx));
48 extern S16 SEnqSRngBuf ARGS((U32 id, Void* elem));
49 extern S16 SDeqSRngBuf ARGS((U32 id, Void* elem));
50 extern Void* SRngGetWIndx ARGS((U32 rngId));
51 extern Void* SRngGetRIndx ARGS((U32 rngId));
52 extern Void SRngIncrRIndx ARGS((U32 rngId));
53 extern Void SRngIncrWIndx ARGS((U32 rngId));
54 extern S16  isRngEmpty ARGS((U32 rngId));
55 extern S16 SConnectSRngBuf ARGS((U32 id,  U32 rxEnt));
56 EXTERN S16 SGetNumElemInRng ARGS(( U32 id));
57 extern S16 SPrintSRngStats ARGS((Void));
58 extern S16 pjBatchProc ARGS((Void));
59 extern U32 ssRngBufStatus;
60
61 #define SS_RNG_BUF_STATUS() ssRngBufStatus
62 /* Ring Buffer Structure */
63 typedef struct
64 {
65    U32 size;    /* Number of elements in a ring */
66    U32 read;    /* Read Index incremented by Deque operation */
67    U32 write;   /* Write index incremented by Enque operation */
68    U32 type;    /* sizeof user specified ring element structure */
69    Void* elem;  /* pointer to the allocated ring Elements */
70 }SsRngBuf;
71
72 /* Ring Cfg Table */
73 typedef struct
74 {
75    U32 rngSize;
76    U32 elemSize;
77 } SsRngCfg;
78
79 /* Global Ring Buffer Info structure */
80 typedef struct
81 {
82    SsRngBuf* r_addr;     // Address of allocated ring
83    U32 txEnt;          // Tx Entity id
84    U32 rxEnt;          // Rx Entity id
85    U32 n_write;        // Number of Enque operations
86    U32 n_read;         // Number of Deque operations
87    U32 nReadFail;      // Number of Deque failures due to ring empty
88    U32 nWriteFail;     // Number of Enque failures due to ring full
89    U32 rngState;       /* Ring Buffer State */
90    U32 pktDrop;        // Number of pkts dropped due to  buffer full
91    U32 nPktProc;       // Debug counter for pkts processed per tti
92    U32 pktRate;        // Debug counter for icpu pkt rate
93 } SsRngBufTbl;
94
95 /* Global Structure for updating Ring buffer for Flow Control */
96 typedef struct
97 {
98    U16 dlRngBuffCnt;   /* Dl Ring Buffer Count */
99    U16 ulRngBuffCnt;   /* Ul Ring Buffer Count */
100 }SsRngBufCnt;
101
102 /* Ring Buffer Id Enum */
103 typedef enum
104 {
105   SS_RNG_BUF_DEBUG_COUNTER,
106   SS_RNG_BUF_ICPU_TO_DLPDCP,
107   SS_RNG_BUF_DLPDCP_TO_DLRLC,
108   SS_RNG_BUF_L2_RT_TO_FREE_MGR,
109   SS_RNG_BUF_L2_NRT_TO_FREE_MGR,
110   SS_RNG_BUF_PRC_L1D_TO_CL,
111   SS_RNG_BUF_PRC_FREE_TO_CL,
112   SS_RNG_BUF_ICPU_TO_DAM,
113   SS_RNG_BUF_L2_NRT_DLRLC_TO_FREE_MGR,
114   SS_RNG_BUF_ICPU_BATCH_START,
115 #ifdef SS_RBUF
116   SS_RNG_BUF_ICPU_BATCH_END = SS_RNG_BUF_ICPU_BATCH_START + BC_BATCH_MGR_MAX_BKT,
117 #endif
118 #ifdef CIPH_BATCH_PROC
119   SS_RNG_BUF_DLPDCP_TO_CIPH,
120   SS_RNG_BUF_CIPH_TO_DLPDCP,
121   SS_RNG_BUF_ULPDCP_TO_CIPH,
122   SS_RNG_BUF_CIPH_TO_ULPDCP,
123 #endif
124   SS_RNG_BUF_ULMAC_TO_ULRLC,
125   SS_RNG_BUF_RX_TO_DLRLC,
126   SS_RNG_BUF_RX_TO_ULPDCP,
127   SS_RNG_BUF_DL_SMSG_REUSE,
128   SS_RNG_BUF_DLRLC_TO_DLMAC,
129   SS_RNG_BUF_MAC_HARQ,
130 #if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_DAT_REQ_RBUF)
131   SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ,
132   SS_RNG_BUF_DLRLC_TO_DLMAC_STA_RSP,
133   SS_RNG_BUF_MAC_TO_RLC_HARQ_STA,
134 #endif
135 #ifdef MAC_FREE_RING_BUF
136   SS_RNG_BUF_MAC_FREE_RING,
137 #endif
138 #ifdef RLC_FREE_RING_BUF
139   SS_RNG_BUF_RLC_FREE_RING,
140 #endif
141 #ifdef LC_EGTP_THREAD
142   SS_RNG_BUF_EGTP_FREE_RING,
143 #endif
144
145   SS_RNG_BUF_MAX
146 } SsRngBufId;
147
148 /* Ring Buffer User Entity Enum */
149 typedef enum
150 {
151    SS_RBUF_ENT_ICPU,
152    SS_RBUF_ENT_DLPDCP,
153    SS_RBUF_ENT_DLRLC,
154    SS_RBUF_ENT_L2_RT,
155    SS_RBUF_ENT_L2_NRT,
156    SS_RBUF_ENT_FREE_MGR,
157    SS_RBUF_ENT_CL,
158    SS_RBUF_ENT_PRC_L1D,
159    SS_RBUF_ENT_PRC_FREE,
160    SS_RBUF_ENT_DAM
161 #ifdef CIPH_BATCH_PROC
162    ,
163    SS_RBUF_ENT_DLCIPH,
164    SS_RBUF_ENT_ULCIPH
165 #endif
166    ,SS_RBUF_ENT_ULPDCP,
167    SS_RBUF_ENT_ULMAC,
168    SS_RBUF_ENT_ICCRX_DL,
169    SS_RBUF_ENT_ULRLC,
170    SS_RBUF_ENT_DLRLC_DAT_REQ,
171    SS_RBUF_ENT_DLMAC_DAT_REQ,
172    SS_RBUF_ENT_DLRLC_STA_RSP,
173    SS_RBUF_ENT_DLMAC_STA_RSP,
174    SS_RBUF_ENT_MAC_HARQ_STA,
175 #ifdef MAC_FREE_RING_BUF
176    SS_RBUF_ENT_MAC_FREE_REQ,
177    SS_RBUF_ENT_MAC_BUF_FREE,
178 #endif
179 #ifdef RLC_FREE_RING_BUF
180    SS_RBUF_ENT_RLC_FREE_REQ,
181    SS_RBUF_ENT_RLC_BUF_FREE,
182 #endif
183 #ifdef LC_EGTP_THREAD
184    SS_RBUF_ENT_EGTP_FREE_REQ,
185    SS_RBUF_ENT_EGTP_BUF_FREE,
186 #endif
187    SS_RBUF_ENT_RLC_HARQ_STA
188 }SsRngUserEnt;
189 /* Ring Buffer State Enum   */
190
191 typedef enum
192 {
193    SS_RNG_DESTROYED,
194    SS_RNG_CREATED,
195    SS_RNG_TX_ATTACHED,
196    SS_RNG_RX_ATTACHED,
197    SS_RNG_READY,
198    SS_RNG_EMPTY,
199    SS_RNG_FULL
200 }SsRngBufState;
201
202 /* User defined Ring Element structures */
203 typedef struct
204 {
205   Buffer* mBuf;
206 } SsRngBufElem;
207
208 EXTERN  SsRngBufTbl SsRngInfoTbl[SS_RNG_BUF_MAX];
209
210 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
211 extern S16 mtAddBufToRing(SsRngBufId ringId,void *bufPtr,U8 freeType);
212 #ifdef XEON_SPECIFIC_CHANGES
213 typedef struct rgKwBufFreeInfo
214 {
215    Void    *bufToFree;
216    U8      freeType; /* 0- SPutMsg, 1->SPutStaticBuffer*/
217 }RgKwFreeInfo;
218 #endif
219 #endif
220 #ifdef __cplusplus
221 }
222 #endif
223
224 #endif