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