[ Jira id - ODUHIGH-593 ] Pack and unpack function nomenclature correction
[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 Void SsRngBufEnable ARGS((Void));
44 Void SsRngBufDisable ARGS((Void));
45 S16 SCreateSRngBuf ARGS((uint32_t id, Region region, Pool pool, uint32_t elmSize, uint32_t rngSize));
46 S16 SDestroySRngBuf ARGS((uint32_t id, Region region, Pool pool));
47 S16 SAttachSRngBuf ARGS((uint32_t id, uint32_t ent, uint32_t txRx));
48 S16 SEnqSRngBuf ARGS((uint32_t id, Void* elem));
49 S16 SDeqSRngBuf ARGS((uint32_t id, Void* elem));
50 Void* SRngGetWIndx ARGS((uint32_t rngId));
51 Void* SRngGetRIndx ARGS((uint32_t rngId));
52 Void SRngIncrRIndx ARGS((uint32_t rngId));
53 Void SRngIncrWIndx ARGS((uint32_t rngId));
54 S16  isRngEmpty ARGS((uint32_t rngId));
55 S16 SConnectSRngBuf ARGS((uint32_t id,  uint32_t rxEnt));
56 S16 SGetNumElemInRng ARGS(( uint32_t id));
57 S16 SPrintSRngStats ARGS((Void));
58 S16 pjBatchProc ARGS((Void));
59 extern uint32_t ssRngBufStatus;
60
61 #define SS_RNG_BUF_STATUS() ssRngBufStatus
62 /* Ring Buffer Structure */
63 typedef struct
64 {
65    uint32_t size;    /* Number of elements in a ring */
66    uint32_t read;    /* Read Index incremented by Deque operation */
67    uint32_t write;   /* Write index incremented by Enque operation */
68    uint32_t 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    uint32_t rngSize;
76    uint32_t elemSize;
77 } SsRngCfg;
78
79 /* Global Ring Buffer Info structure */
80 typedef struct
81 {
82    SsRngBuf* r_addr;     // Address of allocated ring
83    uint32_t txEnt;          // Tx Entity id
84    uint32_t rxEnt;          // Rx Entity id
85    uint32_t n_write;        // Number of Enque operations
86    uint32_t n_read;         // Number of Deque operations
87    uint32_t nReadFail;      // Number of Deque failures due to ring empty
88    uint32_t nWriteFail;     // Number of Enque failures due to ring full
89    uint32_t rngState;       /* Ring Buffer State */
90    uint32_t pktDrop;        // Number of pkts dropped due to  buffer full
91    uint32_t nPktProc;       // Debug counter for pkts processed per tti
92    uint32_t 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    uint16_t dlRngBuffCnt;   /* Dl Ring Buffer Count */
99    uint16_t 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 S16 mtAddBufToRing(SsRngBufId ringId,void *bufPtr,uint8_t freeType);
212 #ifdef XEON_SPECIFIC_CHANGES
213 typedef struct rgKwBufFreeInfo
214 {
215    Void    *bufToFree;
216    uint8_t      freeType; /* 0- SPutMsg, 1->SPutStaticBuffer*/
217 }RgKwFreeInfo;
218 #endif
219 #endif
220 #ifdef __cplusplus
221 }
222 #endif
223
224 #endif