Merge "DL throughput calculation for UM [Issue-ID: ODUHIGH-319]"
[o-du/l2.git] / src / 5gnrrlc / kw.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
19 /********************************************************************20**
20   
21         Name:     NR RLC file
22
23         Type:     C include file
24   
25         Desc:     This file contain the hash definations for RLC 
26  
27         File:     kw.h
28   
29 *********************************************************************21*/
30 /** @file kw.h
31 @brief RLC Hash definitions
32 */
33
34 #ifndef __KWH__
35 #define __KWH__
36 #include "du_log.h"
37 \f 
38
39 #define EKWxxx 1
40 #define EMG099 1
41 #define EMG102 2
42 #define EMG103 3
43 #define EMG104 4
44
45 /* RLC-SPLIT Activity */
46 #define RLC_ONE       1
47 #define RLC_BIT0      0x01
48 #define RLC_BIT1      0x02
49 #define RLC_BIT2      0x04
50 #define RLC_BIT3      0x08
51
52 #define RLC_2K_BYTE   2048
53
54 /* RLC RB flag bits */
55 #define RLC_RB_REESTABLISH_DL  RLC_BIT0
56 #define RLC_RB_REESTABLISH_UL  RLC_BIT1
57 #define RLC_RB_DELETE_DL       RLC_BIT2
58 #define RLC_RB_DELETE_UL       RLC_BIT3
59
60
61 #define RLC_MOD_1024           0x3FF  /* used for MOD 1024 */
62
63
64 \f 
65 /************************************************************************
66  *                            SAP States
67  ************************************************************************/
68
69 #define RLC_SAP_NOT_CFG        0     /*!< SAP Not Configured */
70 #define RLC_SAP_CFG            1     /*!< SAP Configured but not not bound */
71 #define RLC_SAP_BND            2     /*!< SAP Bound */
72 #define RLC_SAP_BINDING        3     /*!< SAP Bind initiated */
73 #define RLC_SAP_UBND           4     /*!< SAP Unbind */
74
75 #define RLC_MAX_SAP_BND_RETRY  3     /*!< Maximum SAP Bin Retries */
76
77 #define RLC_MAX_UE             0xffffffff  /*!< Maximum number of UEs. */
78
79 /* Maximum number of Saps */
80 #define RLC_MAX_UDXSAPS        1     /*!< Maximum number of UDX Saps */
81 #define RLC_MAX_KWUSAPS        2     /*!< Maximum number of KWU Saps. */
82 #define RLC_MAX_CKWSAPS        1     /*!< Maximum number of CKW Saps. */
83 /*MCELL changes*/
84 #define RLC_MAX_RGUSAPS        4//5     /*!< Maximum number of RGU Saps. */
85
86 #define RLC_MAX_RGUSAP_TMR     1     /*!< Maximum number of RGU SAP Timers. */
87
88 #define RLC_UI_RRC             0     /*!< Upper interface RRC sap Id. */
89 #define RLC_UI_PDCP            1     /*!< Upper interface PDCP sap Id. */
90
91 #ifdef LTE_L2_MEAS
92 /* TODO. This works for FDD only. For TDD the array dimension
93  * should be changed according to the number of Harq Procs */
94 #define RLC_MAX_TB_PER_UE      64    /*!< Maximum number of tbCb for UE */
95 #define RLC_INVALID_TBID       RLC_MAX_TB_PER_UE
96 #endif
97 /*******************************************************************************
98  *                              Memory related Defines 
99  ******************************************************************************/
100 #ifdef MCCABE_COV
101 /* Allocate function */
102 #define RLC_ALLOC(_cb,_buf, _size)                                   \
103 {                                                                   \
104    SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf,       \
105                 (Size) _size);                                     \
106       memset((_buf), 0, _size);                             \
107 }
108
109 #define RLC_RMV_SDU(_cb,_sduQ,_sdu)                    \
110 {                                                     \
111    SPutMsg(_sdu->mBuf);                               \
112    cmLListDelFrm(_sduQ,&_sdu->lstEnt);                \
113    RLC_FREE(_cb,_sdu, sizeof(RlcSdu));               \
114 }
115
116 #define RLC_FREE(_cb,_buf, _size)                          \
117 {                                                         \
118       (Void) SPutSBuf(_cb->init.region, _cb->init.pool,   \
119             (Data *) _buf, (Size) _size);                 \
120       _buf = NULLP;                                       \
121 }
122
123 #else
124
125 #define RLC_FREE_SHRABL_BUF(_region, _pool,_buf, _size)    \
126 {                                                         \
127    if (_buf != NULLP)                                     \
128    {                                                      \
129       (Void) SPutStaticBuffer(_region, _pool,             \
130             (Data *) _buf, (Size) _size, 0);                 \
131       _buf = NULLP;                                       \
132    }                                                      \
133 }
134
135 #define RLC_FREE_SHRABL_BUF_WC(_region, _pool,_buf, _size) \
136 {                                                         \
137   (Void) SPutStaticBuffer(_region, _pool,                 \
138         (Data *) _buf, (Size) _size, 0);                 \
139   _buf = NULLP;                                       \
140 }
141
142 #define RLC_ALLOC_SHRABL_BUF_WC(_region, _pool,_buf, _size)           \
143 {                                                                    \
144  SGetStaticBuffer(_region, _pool, (Data **)&_buf,                    \
145                 (Size) _size, 0);                                    \
146 }
147
148 #define RLC_ALLOC_SHRABL_BUF(_region, _pool,_buf, _size)              \
149 {                                                                    \
150  if (SGetStaticBuffer(_region, _pool, (Data **)&_buf,                \
151                 (Size) _size, 0) == ROK)                                \
152    {                                                                 \
153       memset((_buf), 0, _size);                              \
154    }                                                                 \
155    else                                                              \
156    {                                                                 \
157       (_buf) = NULLP;                                                \
158    }                                                                 \
159 }
160 /* Allocate function */
161 #define RLC_ALLOC(_cb,_buf, _size)                                    \
162 {                                                                    \
163  if (SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf,      \
164                 (Size) _size) == ROK)                                \
165    {                                                                 \
166       memset((_buf), 0, _size);                              \
167    }                                                                 \
168    else                                                              \
169    {                                                                 \
170       (_buf) = NULLP;                                                \
171    }                                                                 \
172 }
173
174 #define RLC_ALLOC_WC(_cb,_buf, _size)  \
175            SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf, (Size) _size)     
176
177 #define RLC_RMV_SDU(_cb,_sduQ,_sdu)              \
178 {                                               \
179    if(_sdu->mBuf)                               \
180    {                                            \
181       SPutMsg(_sdu->mBuf);    \
182    }                                            \
183    cmLListDelFrm(_sduQ,&_sdu->lstEnt);          \
184    RLC_FREE(_cb,_sdu, sizeof(RlcSdu));            \
185 }
186
187 #define RLC_FREE(_cb,_buf, _size)                          \
188 {                                                         \
189    if (_buf != NULLP)                                     \
190    {                                                      \
191       (Void) SPutSBuf(_cb->init.region, _cb->init.pool,   \
192             (Data *) _buf, (Size) _size);                 \
193       _buf = NULLP;                                       \
194    }                                                      \
195 }
196
197 #endif
198
199 /* kw002.201 Freeing from region of pst */
200 #define RLC_PST_FREE(_region, _pool, _buf, _size)          \
201 {                                                         \
202    if (_buf != NULLP)                                     \
203    {                                                      \
204       (Void) SPutSBuf(_region, _pool,                     \
205                       (Data *) _buf, (Size) _size);       \
206       _buf = NULLP;                                       \
207    }                                                      \
208 }
209
210 #ifdef XEON_SPECIFIC_CHANGES
211 #ifdef SS_LOCKLESS_MEMORY
212 #define RLC_SHRABL_STATIC_BUF_FREE(_region, _pool, _buf, _size)     \
213 {                                                                  \
214    if (_buf != NULLP)                                              \
215    {                                                               \
216       (Void) SPutStaticBuffer(_region, _pool,                      \
217                       (Data *) _buf, (Size) _size, 0);             \
218       _buf = NULLP;                                                \
219    }                                                               \
220 }
221
222 #define RLC_SHRABL_STATIC_BUF_ALLOC(_region, _pool, _buf, _size)     \
223 {                                                                        \
224  SGetStaticBuffer(_region, _pool, (Data **)&_buf,      \
225                 (Size) _size, 0);                                        \
226 }
227
228 #else
229
230 #define RLC_SHRABL_STATIC_BUF_FREE(_region, _pool, _buf, _size)     \
231 {                                                                  \
232    if (_buf != NULLP)                                              \
233    {                                                               \
234       (Void) SPutSBuf(_region, _pool,                      \
235                       (Data *) _buf, (Size) _size);             \
236       _buf = NULLP;                                                \
237    }                                                               \
238 }
239
240 #define RLC_SHRABL_STATIC_BUF_ALLOC(_region, _pool, _buf, _size)     \
241 {                                                                        \
242  SGetSBuf(_region, _pool, (Data **)&_buf,      \
243                 (Size) _size);                                        \
244 }
245 #endif /* SS_LOCKLESS_MEMORY */
246
247 #else 
248
249 #define RLC_SHRABL_STATIC_BUF_FREE(_region, _pool, _buf, _size)     \
250 {                                                                  \
251    if (_buf != NULLP)                                              \
252    {                                                               \
253       (Void) SPutStaticBuffer(_region, _pool,                      \
254                       (Data *) _buf, (Size) _size, 0);             \
255       _buf = NULLP;                                                \
256    }                                                               \
257 }
258
259 #define RLC_SHRABL_STATIC_BUF_ALLOC(_region, _pool, _buf, _size)     \
260 {                                                                        \
261  SGetStaticBuffer(_region, _pool, (Data **)&_buf,      \
262                 (Size) _size, 0);                                        \
263 }
264 #endif
265
266 #define RLC_MEM_CPY(_dst, _src, _size)  memcpy(_dst, _src, _size); 
267
268 #define RLC_MEM_ZERO(_buf, _size) memset((_buf), 0, _size);
269
270 #define RLC_GET_MEM_REGION(_cb) (_cb->init.region)
271
272 #define RLC_GET_MEM_POOL(_cb) (_cb->init.pool)
273
274 #define RLC_GET_MEM_POOL_ADDRESS(_cb) (&_cb->init.pool)
275
276 /* Memset to value */
277 #define RLC_MEM_SET(_arg, _val, _size) memset(_arg, _val, _size); 
278
279 /* Alarms */
280 /* Send an alarm for sapId events */
281 /* kw005.201 added support for L2 Measurement */
282 #ifdef LTE_L2_MEAS
283 #define RLC_GETSDUIDX(_sduIdx) \
284 {\
285    _sduIdx = (((_sduIdx)+1) % RLC_L2MEAS_MAX_OUTSTNGSDU);\
286 }
287 #define RLC_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause) \
288 { \
289    rlcLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, _sapId, 0, 0); \
290 }
291 #define RLC_SEND_UEID_ALARM(_cb,_ueId, _qci, _evnt, _cause) \
292 { \
293    rlcLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, 0, _ueId, _qci); \
294 }
295 #else /* LTE_L2_MEAS */
296 #define RLC_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause) \
297 { \
298    rlcLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, _sapId, 0); \
299 }
300 #define RLC_SEND_UEID_ALARM(_cb,_ueId, _evnt, _cause) \
301 { \
302    rlcLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, 0, _ueId); \
303 }
304 #endif /* LTE_L2_MEAS */
305
306 /*******************************************************************************
307  *                              Common Defines 
308  ******************************************************************************/
309
310 /* RLC Configuration parameters */
311 #define RLC_MAX_UL_LI                (2 * RLC_MAX_LI)
312 /*macro RLC_MAX_DL_LI is moved to kw_env.h file */
313 #define RLC_MAX_DAT                  RLC_MAXIMUM_DAT
314 /*macro RLC_MAX_PDU is moved to kw_env.h file */
315 #define RLC_MAX_RB_PER_CELL          10
316 #define RLC_MAX_SRB_PER_UE           3
317 #define RLC_MAX_DRB_PER_UE           32
318 #define RLC_MAX_LCH_PER_UE           12
319 #define RLC_MAX_LCH_PER_CELL         6
320 #define RLC_MAX_NUM_RB               24
321 #define RLC_MAX_UE                   0xffffffff 
322 #define RLC_UE_LIST_BUCKET_SIZE      128 
323 #define RLC_CELL_LIST_BUCKET_SIZE    10 
324 #define RLC_TRANS_ID_LST_BKT_SIZE    10 
325 #define RLC_MAX_RB                   32
326
327 /* RLC Mode defines */
328 #define RLC_MODE_TM 1
329 #define RLC_MODE_UM 2
330 #define RLC_MODE_AM 3
331
332 /* Direction defines */
333 #define RLC_DIR_UL        1     /*!< Unlink direction */
334 #define RLC_DIR_DL        2     /*!< Downlink direction */
335 #define RLC_DIR_BOTH      3     /*!< Both Downlink and Unlink */
336
337 #define RLC_DEF_SEQ_NUM 0 /**< Sequence number to pick in case of duplicate
338                               entries in hash list searches*/
339
340 /**
341  * @def RLC_MIN
342  *
343  *    Macro to find the miniumum of two numbers
344  *
345  * @param[in] x    First number
346  * @param[in] y    Second number
347  *
348 */
349 #define RLC_MIN(x,y) (x) < (y) ? (x) : (y)
350
351 /**
352  * @def RLC_GET_RLCCB
353  *
354  *    Macro to the RLC instance
355  *
356  * @param[in] _inst    Instance Id
357  *
358 */
359 #define RLC_GET_RLCCB(_inst) rlcCb[_inst]                              
360
361 #define RLC_ADD_SDU            1     /*!< Add SDU. */
362 #define RLC_DEL_SDU            2     /*!< Delete SDU. */
363
364 #define RLC_CFM_NOK            0     /*!< Do not send DatCfm */
365 #define RLC_CFM_OK             1     /*!< Send DatCfm */
366
367 /* Set the unsolictated Status flag */
368 #define RLC_SET_USTA_FLAG(_rlcCb, _value) \
369 { \
370    _rlcCb->init.usta = _value; \
371 }
372
373 /* Macros to get the init parameters */
374 #define RLC_GET_DBG_MASK(_rlcCb) (_rlcCb->init.dbgMask)
375 #define RLC_GET_LMPST_MEM_POOL(_rlcCb) (_rlcCb->init.lmPst.pool)
376 #define RLC_GET_LMPST_MEM_REGION(_rlcCb) (_rlcCb->init.lmPst.region)
377
378 /* Macros for configuration module */
379 #define RLC_CFG_FILL_CFG_CFM(_entCfm, _rbId, _rbType, _status, _reason)  \
380 {                                                              \
381    _entCfm->rbId  = _rbId;                                     \
382    _entCfm->rbType = _rbType;                                  \
383    _entCfm->status.status = _status;                           \
384    _entCfm->status.reason = _reason;                           \
385
386
387 /**
388  * @def RLC_VALIDATE_UE_RBID
389  *
390  *    This macro validates whether the _rbId passed is valid or not. It checks
391  *    if the _rbId is within the maximum value depending on the _rbType.
392  *    Returns TRUE if valid else FALSE
393  *
394  * @param[in] _rbType    Type of the Radio Bearer; SRB or DRB
395  * @param[in] _rbId      RB Id of the RB to be validated
396  *
397 */ 
398 #define RLC_VALIDATE_UE_RBID(_rbType, _rbId)                     \
399        ((_rbType == CM_LTE_SRB && _rbId < RLC_MAX_SRB_PER_UE) || \
400        (_rbType == CM_LTE_DRB && _rbId < RLC_MAX_DRB_PER_UE))
401
402 /*******************************************************************************
403  *                              UIM Defines 
404  ******************************************************************************/
405 #if (ERRCLASS & ERRCLS_INT_PAR)
406 #define RLC_VALDATE_SAP(_cb,_chkSpId, _sap, _ret)                             \
407 {                                                                            \
408    if (_chkSpId != _sap->spId)                                               \
409    {                                                                         \
410       RLCLOGERROR(_cb,ERRCLS_DEBUG, EKWxxx, (ErrVal) RFAILED,                 \
411             "Sap Id Validation Failed.");                                    \
412       _ret = RFAILED;                                                        \
413    }                                                                         \
414    /* SAP state validation */                                                \
415    if(_sap->state != RLC_SAP_BND)                                             \
416    {                                                                         \
417       RLCLOGERROR(_cb,ERRCLS_INT_PAR, EKWXXX, (ErrVal) RFAILED,               \
418             "Sap State Invalid.");                                           \
419       RLC_SEND_SAPID_ALARM(_cb,0, LCM_EVENT_UI_INV_EVT, LCM_CAUSE_INV_STATE); \
420       _ret = RFAILED;                                                        \
421    }                                                                         \
422 }
423 #else /* ERRCLASS & ERRCLS_INT_PAR */
424 #define RLC_VALDATE_SAP(_cb,_chkSpId, _sap, _ret)                             \
425 {                                                                            \
426    /* SAP state validation */                                                \
427    if(_sap->state != RLC_SAP_BND)                                             \
428    {                                                                         \
429       RLCLOGERROR(_cb,ERRCLS_INT_PAR, EKWXXX, (ErrVal) RFAILED,               \
430             "Sap State Invalid.");                                           \
431       RLC_SEND_SAPID_ALARM(_cb,0, LCM_EVENT_UI_INV_EVT, LCM_CAUSE_INV_STATE); \
432       _ret = RFAILED;                                                        \
433    }                                                                         \
434 }
435 #endif /* ERRCLASS & ERRCLS_INT_PAR */
436
437 /*******************************************************************************
438  *                              Timer Defines 
439  ******************************************************************************/
440 #define RLC_TMR_LEN                     10
441 #define RLC_MAX_UM_TMR                  1
442 #define RLC_MAX_AM_TMR                  3
443 #define RLC_MAX_THPT_TMR                1
444
445 /* Timer events */
446 #define EVENT_RLC_UMUL_REASSEMBLE_TMR     1
447 #define EVENT_RLC_AMUL_REASSEMBLE_TMR          2
448 #define EVENT_RLC_AMUL_STA_PROH_TMR       3
449 #define EVENT_RLC_AMDL_POLL_RETX_TMR      4
450 #define EVENT_RLC_WAIT_BNDCFM             5
451 /* kw005.201 added support for L2 Measurement */
452 #ifdef LTE_L2_MEAS
453 #define EVENT_RLC_L2_TMR                  6
454 #endif /* LTE_L2_MEAS */
455 #define EVENT_RLC_THROUGHPUT_TMR          7
456
457 /*******************************************************************************
458  *                              DBM Defines 
459  ******************************************************************************/
460 /**
461  * @def RLC_DBM_GET_RBCB_FROM_UECB
462  *
463  *    This macro makes _rbCb point to the RB in _ueCb based on the passed 
464  *    _rbId and _rbType. _rbCb can point to NULLP
465  *
466  * @param[in] _rbId      RB Id of the RB to be fetched
467  * @param[in] _rbType    Type of the RB, SRB or DRB
468  * @param[in] _ueCb      Pointer to the UECb for which to get the RB
469  * @param[out] _rbCb     Pointer to the found RbCb
470  *
471 */
472 #define RLC_DBM_GET_RBCB_FROM_UECB(_rbId, _rbType, _ueCb, _rbCb)            \
473            (_rbCb) = ((_rbType) == CM_LTE_SRB) ? (_ueCb)->srbCb[(_rbId)] : \
474                                                  (_ueCb)->drbCb[(_rbId)];     
475 /**
476  * @def RLC_DBM_GET_CELL_RBCB
477  *
478  *    This macro makes _rbCb point to the RB in the _rbCbLst. 
479  *    _rbCb can point to NULLP
480  *
481  * @param[in] _rbId         RB Id of the RB to be fetched
482  * @param[in] _rbCbLst      Pointer to array of RBCbs
483  * @param[out] _rbCb        Pointer to the found RbCb
484  *
485 */
486 #define RLC_DBM_GET_CELL_RBCB(_rbId, _rbCbLst, _rbCb) \
487            (_rbCb) = (_rbCbLst)[(_rbId)]; 
488
489 /*******************************************************************************
490  *                              UMM Defines 
491  ******************************************************************************/
492 #define RLC_UMDL     rbCb->m.umDl 
493 #define RLC_UMUL     rbCb->m.umUl 
494
495 /* Sequence Number length defines */
496 #define RLC_UM_CFG_6BIT_SN_LEN      1 /**< UM 6-bit Sequence number length 
497                                           in bytes*/   
498 #define RLC_UM_CFG_12BIT_SN_LEN     2 /**< UM 12-bit Sequence number length 
499                                           in bytes*/
500 /* 5GNR */
501 /* Sequence Number length defines */
502 #define RLC_AM_CFG_12BIT_SN_LEN      1 /**< AM 12-bit Sequence number length 
503                                           in bytes*/   
504 #define RLC_AM_CFG_18BIT_SN_LEN      2 /**< AM 18-bit Sequence number length 
505                                           in bytes*/
506
507 /**
508  * @def RLC_RMV_MAC_HDR_SZ
509  *
510  *    If PDU size is greater than 127, MAC header would be 3 bytes else 2 bytes
511  *
512  * @param[in,out] _pduSz        Size of the pdu 
513  *
514 */
515 #define RLC_RMV_MAC_HDR_SZ(_pduSz) (_pduSz) -= ((_pduSz) > 127) ? 3 : 2;
516
517 /**
518  * @def RLC_UM_GET_VALUE
519  *
520  *    This macro is used to calculate the value of UM state variables used 
521  *    in comparisons.  VR(UH) - UM Window Size is taken as the base modulus.
522  *    Returns the modifed value
523  *
524  * @param[in] _val               Value of the state variable 
525  * @param[in] _kwUmUl        Um Uplink control block
526  *
527 */ 
528 #define RLC_UM_GET_VALUE(_val,_kwUmUl)  \
529      (((_val) - ((_kwUmUl).vrUh - (_kwUmUl).umWinSz)) & ((_kwUmUl).modBitMask))
530      
531 /*******************************************************************************
532  *                              AMM Defines 
533  ******************************************************************************/ 
534 #define RLC_AMDL                           rbCb->m.amDl 
535 #define RLC_AMUL                           rbCb->m.amUl
536
537 /* PDU Types */
538 #define RLC_DATA_PDU  1
539 #define RLC_CNTRL_PDU 0
540
541 #define RLC_FI_FIRST_SEG                0x02
542 #define RLC_FI_LAST_SEG                 0x01
543 #define RLC_SI_FIRST_SEG                0x01
544 #define RLC_SI_LAST_SEG                 0x02
545 #define RLC_SI_MID_SEG                  0x03
546
547 #define RLC_POLL_SET                    0x40 /* 01000000 */
548 #define RLC_POLL_UNSET                  0xbf /* 10111111 */
549 #define RLC_MAX_NACK_CNT                100
550 /*RLC_MAX_CNTRL_FIELDS (Maximum size of Status Pdu) 
551  *  = MAX_NACK_CNT * sizeof(NACK_SN,E1,E2,E3,soStart,soEnd, nackRange)
552  * for 18 bit SN + Fixed Header*/
553 #define RLC_MAX_CNTRL_FIELDS            ((RLC_MAX_NACK_CNT * 8) + 3)  
554
555 /* Each LI(Length Indicator) holds approx 1+1/2 byte and some other fields thus keeping Header Size equal to twice of MAX LI */
556 /* 5GNR_RLC: Need to change value of HDRSZ as per number of PDUs going in one datReq */
557 #define RLC_MIN_HDRSZ                         1
558 #define RLC_MAX_HDRSZ                         5 
559 #define RLC_AM_PDU_FIXED_HDRSZ                2
560 #define RLC_AM_PDU_12BIT_SN_HDRSZ             2
561 #define RLC_AM_PDU_18BIT_SN_HDRSZ             3
562 #define RLC_AM_SEG_12BIT_SN_WITH_SO_HDRSZ     4
563 #define RLC_AM_SEG_18BIT_SN_WITH_SO_HDRSZ     5
564 #define RLC_AM_SEG_12BIT_SN_WITHOUT_SO_HDRSZ  2
565 #define RLC_AM_SEG_18BIT_SN_WITHOUT_SO_HDRSZ  3
566 #define RLC_EXTN_HDRSZ                  2
567 #define RLC_CNTRL_PDU_FIXED_HDRSZ       3
568 #define RLC_MAC_HDR_SZ2                 2
569 #define RLC_MAC_HDR_SZ3                 3
570 #define RLC_BYTE_LEN                    8
571 #define RLC_2BYTE_LEN                   16
572 #define RLC_E1_LEN                      1
573 #define RLC_NACK_E1E2_LEN               12
574 #define RLC_SO_LEN                      15
575 #define RLC_DC_LEN                      1
576 #define RLC_CPT_LEN                     3
577 #define RLC_RF_LEN                      1
578 #define RLC_P_LEN                       1
579 #define RLC_FI_LEN                      2
580 #define RLC_SI_LEN                      2
581 #define RLC_E_LEN                       1
582 #define RLC_SN_LEN                      10
583 #define RLC_SN_LEN_12BITS               12
584 #define RLC_SN_LEN_18BITS               18
585 #define RLC_LSF_LEN                     1
586 #define RLC_LI_LEN                      11
587 #define RLC_STA_PDU_R_BITS_ACKSN_12BITS 7  /* 5GNR : Num Reserved bits in STATUS PDU */
588 #define RLC_STA_PDU_R_BITS_ACKSN_18BITS 1
589 #define RLC_STA_PDU_R_BITS_NACKSN_12BITS 1
590 #define RLC_STA_PDU_R_BITS_NACKSN_18BITS 3
591 #define RLC_NACK_RANGE_LEN               8
592 #define RLC_SO_LEN_5GNR                  16
593
594 #define RLC_DC_POS                      0x80
595 #define RLC_DC_SHT                      7      
596 #define RLC_POLL_POS                    0x40 /* 5GNR */
597 #define RLC_POLL_SHT                    6    /* 5GNR */
598 #define RLC_SI_POS                      0x30 /* 5GNR */
599 #define RLC_SI_SHT                      4    /* 5GNR */
600 #define RLC_SN_POS_12BIT                0x0F
601 #define RLC_SN_POS_18BIT                0x03
602 #define RLC_AM_GET_WIN_SZ(_snLen)       ((RLC_AM_CFG_12BIT_SN_LEN == (_snLen)) ? (2048) : (131072)) /* 5GNR */
603 #define RLC_RCV_BUF_BIN_SIZE 512   /* receive buffer size */
604 #define RLC_TX_BUF_BIN_SIZE 512   /* receive buffer size */
605
606 #define RLC_SDU_LST                     1
607 #define RLC_SEG_LST                     2
608 #define RLC_RETX_LST                    3
609 #define RLC_ALL_BYTES_MISSING           0xffff
610
611 #define RLC_MAX_PDU_MAP                 30       /*!< Maximum PDU Map. */
612
613 #define RLC_LLIST_FIRST_SDU(lstCp, nod)          \
614 {                                               \
615    CmLList *tmpNode;                            \
616    /*CM_LLIST_FIRST_NODE(&(lstCp), tmpNode);*/      \
617    /*if (tmpNode != NULLP)*/                        \
618    if((tmpNode=cmLListFirst(&lstCp)))            \
619       nod = (RlcSdu *)tmpNode->node;             \
620    else                                         \
621       nod = NULLP;                              \
622 }                                                          
623
624                                                            
625 #define RLC_LLIST_FIRST_SEG(lstCp, nod)         \
626 {                                              \
627    CmLList *tmpNode;                           \
628    /*CM_LLIST_FIRST_NODE(&(lstCp), tmpNode);*/     \
629    /*if (tmpNode != NULLP)*/                       \
630    if((tmpNode=cmLListFirst(&lstCp)))            \
631       nod = (RlcSeg *)tmpNode->node;            \
632    else                                        \
633       nod = NULLP;                             \
634 }                                                          
635
636 #define RLC_LLIST_FIRST_RETX(lstCp, nod)        \
637 {                                              \
638    CmLList *tmpNode;                           \
639    /*CM_LLIST_FIRST_NODE(&(lstCp), tmpNode);*/     \
640    /*if (tmpNode != NULLP)*/                       \
641    if((tmpNode=cmLListFirst(&lstCp)))            \
642       nod = (RlcRetx *)tmpNode->node;           \
643    else                                        \
644       nod = NULLP;                             \
645 }
646
647 #define RLC_LLIST_NEXT_SDU(lstCp, nod)          \
648 {                                              \
649    CmLList *tmpNode;                           \
650    /*CM_LLIST_NEXT_NODE(&(lstCp), tmpNode);*/      \
651    /*if (tmpNode != NULLP)  */                     \
652    if((tmpNode = cmLListNext(&lstCp)))          \
653       nod = (RlcSdu *)tmpNode->node;            \
654    else                                        \
655       nod = NULLP;                             \
656 }                                              
657
658
659 #define RLC_LLIST_NEXT_SEG(lstCp, nod)          \
660 {                                              \
661    CmLList *tmpNode;                           \
662    (lstCp).crnt = &((nod)->lstEnt);            \
663    /*CM_LLIST_NEXT_NODE(&(lstCp), tmpNode);*/      \
664    /*if (tmpNode != NULLP)*/                       \
665    if((tmpNode = cmLListNext(&lstCp)))           \
666       nod = (RlcSeg *)tmpNode->node;            \
667    else                                        \
668       nod = NULLP;                             \
669 }      
670
671                                         
672 #define RLC_LLIST_NEXT_RETX(lstCp, nod)         \
673 {                                              \
674    CmLList *tmpNode;                           \
675    /*CM_LLIST_NEXT_NODE(&(lstCp), tmpNode);*/      \
676    /*if (tmpNode != NULLP) */                      \
677    if ((tmpNode = cmLListNext(&lstCp)))          \
678       nod = (RlcRetx *)tmpNode->node;           \
679    else                                        \
680       nod = NULLP;                             \
681 }
682
683
684 #define RLC_LLIST_LAST_RETX(lstCp, nod)         \
685 {                                              \
686    CmLList *tempNode = NULLP;                  \
687    cmLListLast(&lstCp);                        \
688    tempNode = cmLListCrnt(&lstCp);             \
689    if (tempNode != NULLP)                      \
690       nod = (RlcRetx *)tempNode->node;          \
691    else                                        \
692       nod = NULLP;                             \
693 }
694
695 #define RLC_LLIST_LAST_SEG(lstCp, nod)          \
696 {                                              \
697    CmLList *tempNode = NULLP;                  \
698    cmLListLast(&lstCp);                        \
699    tempNode = cmLListCrnt(&lstCp);             \
700    if (tempNode != NULLP)                      \
701       nod = (RlcSeg *)tempNode->node;           \
702    else                                        \
703       nod = NULLP;                             \
704 }
705
706 #define RLC_LLIST_LAST_SDU(lstCp, nod)          \
707 {                                              \
708    CmLList *tempNode = NULLP;                  \
709    cmLListLast(&lstCp);                        \
710    tempNode = cmLListCrnt(&lstCp);             \
711    if (tempNode != NULLP)                      \
712       nod = (RlcSdu *)tempNode->node;           \
713    else                                        \
714       nod = NULLP;                             \
715 }
716
717 #define CM_LLIST_INS_AFT_CRNT(lstCp, nod)      \
718 {                                              \
719    CmLList *nodeToIns = &nod->lstEnt;\
720    nodeToIns->node = (PTR) nod;\
721    cmLListInsAfterCrnt(&lstCp, nodeToIns);     \
722 }
723
724 #define CM_LLIST_INS_BEF_CRNT(lstCp, nod)      \
725 {                                              \
726    CmLList *nodeToIns = &nod->lstEnt;          \
727    nodeToIns->node = (PTR) nod;                \
728    cmLListInsCrnt(&lstCp, nodeToIns);          \
729 }
730
731 #define RLC_LLIST_DEL_RECBUF(_recBuf)                      \
732 {                                                          \
733    RlcSeg  *_seg = NULLP;                                  \
734    RLC_LLIST_FIRST_SEG(_recBuf->segLst, _seg);             \
735    while (_seg)                                            \
736    {                                                       \
737       cmLListDelFrm(&_recBuf->segLst, &_seg->lstEnt);      \
738       RLC_FREE(_seg, sizeof(RlcSeg));                      \
739       RLC_LLIST_NEXT_SEG(_recBuf->segLst, _seg);           \
740    }                                                       \
741 }
742
743 #define RLC_UMM_LLIST_FIRST_SEG(lstCp, nod)         \
744 {                                              \
745    CmLList *tmpNode;                           \
746    if((tmpNode=cmLListFirst(&lstCp)))            \
747       nod = (RlcUmSeg *)tmpNode->node;            \
748    else                                        \
749       nod = NULLP;                             \
750 } /*!< um mode first segment of linked list*/
751
752 #define RLC_UMM_LLIST_NEXT_SEG(lstCp, nod)          \
753 {                                              \
754    CmLList *tmpNode;                           \
755    (lstCp).crnt = &((nod)->lstEnt);            \
756    if((tmpNode = cmLListNext(&lstCp)))           \
757       nod = (RlcUmSeg *)tmpNode->node;            \
758    else                                        \
759       nod = NULLP;                             \
760 }/*!< next segment in um mode linked list*/
761
762 #define MODAMT(x, y, z,_snModMask)   \
763 {                         \
764    y = (x - z) & _snModMask;   \
765 }                                                         
766
767 #define MODAMR(x, y, z , _snModMask)   \
768 {                         \
769    y = (x - z) & (_snModMask);   \
770 }
771
772 /**
773  * @def RLC_AM_IS_TRANS_WIN_STALLED
774  *
775  *    This macro is used to check if the AM transmit window is stalled or not.
776  *    The tramist window is stalled when the distance between txNext and txNextAck
777  *    is greater than equal to Window Size. Actually it should never be greater 
778  *    than Window Size.
779  *    Returns TRUE if the window is stalled else FALSE
780  *
781  * @param[in] _amDl     AM Downlink control block
782  *
783 */ 
784 #define RLC_AM_IS_TRANS_WIN_STALLED(_amDl)  \
785      ((((_amDl)->txNext - (_amDl)->txNextAck) & _amDl->snModMask) >= (RLC_AM_GET_WIN_SZ(_amDl->snLen)))
786
787 #ifdef TENB_STATS
788 #define RLC_AM_TRANS_WIN_SIZE(_amDl)  \
789      (((_amDl)->txNext - (_amDl)->txNextAck) & _amDl->snModMask)
790 #endif
791
792 #define RLC_AM_IS_POLL_BIT_SET(_amDl) \
793   (RLC_AMDL.pollSn == ((RLC_AMDL.txNext - 1) & RLC_AMDL.snModMask))
794
795 #define RLC_FILL_CNTRL_INFO(cntrlInfo, _val, _len, _idx, _eb)\
796 {                                                           \
797    cntrlInfo.val = _val;                                    \
798    cntrlInfo.len = _len;                                    \
799    cntrlInfo.idx = _idx;                                    \
800    cntrlInfo.emtBits = _eb;                                 \
801 }
802 #define RLC_FILL_PREV_IDX(cntrlInfo, _e1Idx, _e1eb, _idx, _eb) \
803 {                                                                     \
804   _e1Idx = cntrlInfo.e1Idx;                                           \
805   _e1eb  = cntrlInfo.e1eb;                                            \
806   _idx   = cntrlInfo.idx;                                             \
807   _eb    = cntrlInfo.emtBits;                                         \
808 }
809
810 #define RLC_FILL_HDR_ARGS(hdrInfo, _val, _len)  \
811 {                                              \
812    hdrInfo.val = _val;                         \
813    hdrInfo.len = _len;                         \
814 }
815
816 /* kw003.201 - This macro provides the header size other than the */
817 /*             fixed header of 2 bytes for each AMD PDU or 4 bytes*/
818 /*             for an AM PDU segment                              */
819 #define RLC_AM_EXTN_HDRSZ(_numLi, _eHdrSz)       \
820 {                                               \
821    if ((_numLi - 1) % 2)                        \
822    {                                            \
823       _eHdrSz = ((3 * (_numLi - 2)) >> 1) + 2;  \
824    }                                            \
825    else                                         \
826    {                                            \
827       _eHdrSz = (3 * (_numLi - 1)) >> 1;        \
828    }                                            \
829 }
830
831 /* Update poll bit in the buffer */
832 #define RLC_UPD_POLL_BIT(_gCb, _retx, _poll)                \
833 {                                                          \
834    uint8_t fHdr;                                                \
835                                                            \
836    if (_poll != _retx->amHdr.p)                            \
837    {                                                       \
838       /* Get the first byte of the buffer */               \
839       SRemPreMsg((Data *)&fHdr, _retx->seg);               \
840       if (_poll == TRUE)                                   \
841       {                                                    \
842          fHdr = fHdr | RLC_POLL_SET;                        \
843       }                                                    \
844       else                                                 \
845       {                                                    \
846          fHdr = fHdr & RLC_POLL_UNSET;                      \
847       }                                                    \
848       /* Concatenated updated hdr to the mBuf */           \
849       SAddPreMsg ((Data)fHdr, _retx->seg);                 \
850    }                                                       \
851    /* Update poll bit in the hdrInfo */                    \
852    _retx->amHdr.p = _poll;                                 \
853 }
854
855 #define RLC_AM_ELIMINATE_EXTN_HDR(_pduSz, _sduSz, _numLi)   \
856 {                                                          \
857    if ( (_pduSz > _sduSz) && (_sduSz < 2048) )             \
858    {                                                       \
859       _pduSz -= (_numLi % 2) ? 1 : 2;                      \
860    }                                                       \
861 }
862 /**
863  * @def RLC_AM_CHK_SN_WITHIN_RECV_WINDOW
864  *
865  *    This macro is used to check if a Sequence Number falls within the AM
866  *    reception window or not.
867  *    The condition is VR(R) <= SN < VR(MR), which are subtracting the base
868  *    modulus becomes 0 <= (SN - VR(R)) % SNLen < (VR(MR) - VR(R)) % SnLen
869  *    NOTE: Careful with the parantheses
870  *
871  *    Returns TRUE if within the window; FALSE otherwise
872  *
873  * @param[in] _sn       The sequence number to be checked
874  * @param[in] _amUl     AM Uplink control block
875  *
876 */
877 #define RLC_AM_CHK_SN_WITHIN_RECV_WINDOW(_sn, _amUl)          \
878   ((((_sn) - (_amUl->rxNext)) & (_amUl->snModMask)) < (((_amUl->vrMr) - (_amUl->rxNext)) & (_amUl->snModMask))) 
879
880 #define RLC_POWER(x, y)  x << (y-1); 
881
882 #ifndef L2_OPTMZ
883 #define rlcCpyMsg(_cb,x, y) \
884       (SAddMsgRef((x), RLC_GET_MEM_REGION(_cb), RLC_GET_MEM_POOL(_cb), (y)))
885 #else
886 /* L2 optimization for mUe/Tti: Removing dup buf*/
887 #define rlcCpyMsg(_cb,x, y) \
888       (SIncMsgRef((x), RLC_GET_MEM_REGION(_cb), RLC_GET_MEM_POOL(_cb), (y)))
889 #endif
890
891 //      printf("Copy Msg %x \n",x);
892
893 /*******************************************************************************
894  *                              Debugging Defines 
895  ******************************************************************************/
896 #define RLC_DBG_SUB_MASK   DBGMASK_MI             /**< Use for sub-mask */
897 #define RLC_DBGMASK_DETAIL (RLC_DBG_SUB_MASK << 0) /**< Parameters, It will give
898                                                       in depth info */
899 #define RLC_DBGMASK_BRIEF  (RLC_DBG_SUB_MASK << 1) /**< Info, It will give info at
900                                                     entry and exit places along
901                                                    with certain state changes */
902 #define RLC_DBGMASK_ERROR  (RLC_DBG_SUB_MASK << 2) /**< Error information */
903 #define RLC_DBGMASK_FATAL  (RLC_DBG_SUB_MASK << 3) /**< FATAL errors like memory
904                                                     resource failure etc., */
905
906 #define RLC_DBG_MDL_MASK (RLC_DBG_SUB_MASK << 4)
907
908 #define RLC_DBGMASK_TM         (RLC_DBG_MDL_MASK << 0)    /**< TM */
909 #define RLC_DBGMASK_UM         (RLC_DBG_MDL_MASK << 1)    /**< UM */
910 #define RLC_DBGMASK_AM         (RLC_DBG_MDL_MASK << 2)    /**< AM */
911 #define RLC_DBGMASK_DL         (RLC_DBG_MDL_MASK << 3)    /**< DL */
912 #define RLC_DBGMASK_UL         (RLC_DBG_MDL_MASK << 4)    /**< UL */
913 #define RLC_DBGMASK_CFG        (RLC_DBG_MDL_MASK << 5)    /**< CFG */
914 #define RLC_DBGMASK_LMM        (RLC_DBG_MDL_MASK << 6)    /**< LMM */
915 #define RLC_DBGMASK_INF        (RLC_DBG_MDL_MASK << 7)    /**< UI, LI */
916 #define RLC_DBGMASK_DUT        (RLC_DBG_MDL_MASK << 8)    /**< DBM, UTL, TMR */
917 #define RLC_DBGMASK_MBUF_PRNT  (RLC_DBG_MDL_MASK << 9)    /**< MBUF, useful in
918                                                              integrated 
919                                                              testing */
920 #define RLC_DBGMASK_MEM_INFO   (RLC_DBG_MDL_MASK << 10)   /**< Print SSI memory
921                                                              information*/
922 #define RLC_DBGMASK_UDX        (RLC_DBG_MDL_MASK << 11)   /**< UDX interface */
923
924 #ifdef DEBUGP
925 #define RLC_PRNT_BORDER                                   \
926 do                                                       \
927 {                                                        \
928    RLC_PRNT((_kwPBuf, "\n==========================\n")); \
929 }while(0)
930
931 #define RLC_PRNT_HLINE(_cb,_pMsg)                                              \
932 {                                                                             \
933    sprintf((_cb)->init.prntBuf, "[RLC_LAYER: %s:%d]::", __FILE__, __LINE__);  \
934    SPrint((_cb)->init.prntBuf);                                               \
935    RLC_PRNT_TSTAMP(_cb);                                                       \
936    sprintf((_cb)->init.prntBuf, _pMsg);                                       \
937    SPrint((_cb)->init.prntBuf);                                               \
938 }
939
940 #define RLC_PRNT(_cb,_prntbuf)  \
941 {                              \
942    sprintf _prntbuf;           \
943    SPrint(_cb->init.prntBuf);  \
944 }
945
946 #define RLC_PRINT_TO_BUFFER(_cb,...)                             \
947 {                                                               \
948    snprintf((_cb)->init.prntBuf, PRNTSZE, "[%s]::", __func__);  \
949    SPrint((_cb)->init.prntBuf);                                 \
950    snprintf(_cb->init.prntBuf, PRNTSZE,__VA_ARGS__);            \
951    SPrint(_cb->init.prntBuf);                                   \
952 }
953
954 #define RLC_PRNT_TSTAMP(_cb)                                   \
955 {                                                             \
956    S8 _buf[60];                                               \
957    DateTime dt;                                               \
958    memset((&dt), 0, sizeof(DateTime));                \
959    SGetDateTime(&dt);                                         \
960    sprintf(_buf, "date: %02d/%02d/%04d time: %02d:%02d:%02d", \
961      (int)dt.month,(int)dt.day,(int)dt.year + 1900,           \
962      (int)dt.hour,(int)dt.min,(int)dt.sec);                   \
963    RLC_PRNT(_cb,(_cb->init.prntBuf,("[%s]", _buf)));           \
964 }
965
966 #define RLC_PRNT_MBUF(_cb,_mBufPtr)                          \
967 do                                                          \
968 {                                                           \
969    if(_cb->init.dbgMask & (RLC_DBGMASK_MBUF_PRNT))           \
970    {                                                        \
971      RLC_PRNT_HLINE(_cb,("\nMessage Buffer Contents:\n"));   \
972      SPrntMsg ((Buffer *)_mBufPtr, 0, 0);                   \
973    }                                                        \
974 }while(0)
975
976 #define RLC_PRNT_MEMINFO(_cb)                                  \
977 do                                                            \
978 {                                                             \
979    uint32_t  _memInfo;                                             \
980    if(_cb->init.dbgMask & (RLC_DBGMASK_MEM_INFO))              \
981    {                                                          \
982      RLC_PRNT_HLINE(_cb,("\nMemory Information:\n"));          \
983      SRegInfoShow(0, &_memInfo);                              \
984    }                                                          \
985 }while(0)
986
987 #define RLCDBGP_INTERNAL(_cb,_mask,...)           \
988 do                                               \
989 {                                                \
990    if (!((_cb->init.dbgMask & _mask) ^ _mask))   \
991    {                                             \
992       RLC_PRINT_TO_BUFFER(_cb, __VA_ARGS__);      \
993    }                                             \
994 }while(0)
995
996 #define RLCDBGP_ERROR(_cb, ...) \
997    RLCDBGP_INTERNAL(_cb,(RLC_DBGMASK_ERROR | RLC_MODULE),__VA_ARGS__)
998
999 #define RLCDBGP_DETAIL(_cb, ...) \
1000    RLCDBGP_INTERNAL(_cb,(RLC_DBGMASK_DETAIL | RLC_MODULE),__VA_ARGS__)
1001
1002 #define RLCDBGP_BRIEF(_cb, ...) \
1003    RLCDBGP_INTERNAL(_cb,(RLC_DBGMASK_BRIEF | RLC_MODULE),__VA_ARGS__)   
1004    
1005 #else  /* DEBUGP */ 
1006 #define RLC_PRNT_HLINE(_cb,_pMsg)
1007 #define RLC_PRNT(_cb,_prntbuf)
1008 #define RLC_PRNT_TSTAMP(_cb)
1009 #define RLC_PRNT_MBUF(_cb,_mBufPtr)
1010 #define RLC_PRNT_MEMINFO(_cb)
1011 #define RLCDBGP(_cb,_mask, _arg)
1012 #define RLCDBGP_ERROR(_cb, ...) 
1013 #define RLCDBGP_DETAIL(_cb, ...)
1014 #define RLCDBGP_BRIEF(_cb, ...)
1015 #endif /* DEBUGP */
1016
1017 /*******************************************************************************
1018  *                              LMM Defines 
1019  ******************************************************************************/
1020 #define RLC_LMM_RB_STS_INC(_cb)    (_cb)->genSts.numOfRb++;
1021
1022 #define RLC_LMM_RB_STS_DEC(_cb)    (_cb)->genSts.numOfRb--;
1023
1024 #if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION)
1025 #define RLC_FILL_SAP_HELPER(_Sap, _cfg, _gCb)\
1026 {\
1027    _Sap->pst.selector = _cfg->selector; \
1028    _Sap->pst.route = _cfg->route; \
1029    _Sap->pst.prior =  _cfg->priority; \
1030    _Sap->pst.region = _gCb->init.region;\
1031    _Sap->pst.pool = _gCb->init.pool;\
1032    _Sap->pst.dstProcId = _cfg->procId; \
1033    _Sap->pst.dstEnt = _cfg->ent; \
1034    _Sap->pst.dstInst = _cfg->inst; \
1035    _Sap->pst.srcProcId = _gCb->init.procId; \
1036    _Sap->pst.srcEnt = _gCb->init.ent; \
1037    _Sap->pst.srcInst = _gCb->init.inst; \
1038    _Sap->pst.event = EVTNONE; \
1039    _Sap->spId = _cfg->sapId; \
1040    _Sap->state = RLC_SAP_CFG; \
1041 }
1042 #else /* defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION) */
1043 #define RLC_FILL_SAP_HELPER(_Sap, _cfg, _gCb)\
1044 {\
1045    _Sap->pst.selector = _cfg->selector; \
1046    _Sap->pst.route = _cfg->route; \
1047    _Sap->pst.prior =  _cfg->priority; \
1048    _Sap->pst.region = _cfg->mem.region;\
1049    _Sap->pst.pool = _cfg->mem.pool;\
1050    _Sap->pst.dstProcId = _cfg->procId;\
1051    _Sap->pst.dstEnt = _cfg->ent;\
1052    _Sap->pst.dstInst = _cfg->inst;\
1053    _Sap->pst.srcProcId = _gCb->init.procId;\
1054    _Sap->pst.srcEnt = _gCb->init.ent;\
1055    _Sap->pst.srcInst = _gCb->init.inst;\
1056    _Sap->pst.event = EVTNONE;\
1057    _Sap->spId = _cfg->sapId;\
1058    _Sap->state = RLC_SAP_CFG;\
1059 }
1060 #endif
1061
1062 /*******************************************************************************
1063  *                              UDX Defines 
1064  ******************************************************************************/
1065 #define RLC_GET_DL_SAPCB(_cb, _rbCb) (_cb->u.dlCb->udxDlSap + _rbCb->udxSapId)
1066 #define RLC_GET_UDX_SAP(_cb) (_cb->u.ulCb->udxUlSap)
1067
1068 /* kw005.201 added support for L2 Measurement */
1069 #ifdef LTE_L2_MEAS
1070 #define RLC_L2_MAX_TIMERS        1
1071 #define RLC_QCI_LIST_BUCKET_SIZE 10
1072 #define RLC_TB_LIST_BUCKET_SIZE  10
1073 #define RLC_MAX_L2MEAS_EVT       10
1074 /* L2 Measurement index to be used in rbCb to store measData */                                       
1075 #define RLC_L2MEAS_ACT_UE       0                                       
1076 #define RLC_L2MEAS_DL_DELAY     1                                       
1077 #define RLC_L2MEAS_DL_DISC      2
1078 #define RLC_L2MEAS_UU_LOSS      3
1079 #define RLC_L2MEAS_DL_IP        4
1080 #define RLC_L2MEAS_UL_IP        5
1081 #endif /* LTE_L2_MEAS */
1082
1083 #define RLC_RDWR_LOCK(_lockPtr)
1084 #define RLC_RDWR_UNLOCK(_lockPtr)
1085 #define RLC_TIME_DIFF(t1,t2)                  \
1086    (t1<t2 ? ((0xffffffff - t2) + t1 ): (t1 - t2)) 
1087
1088 #endif /* __KWH__ */
1089 \f  
1090 /********************************************************************30**
1091   
1092          End of file
1093 **********************************************************************/