1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /********************************************************************20**
25 Desc: This file contain the hash definations for RLC
29 *********************************************************************21*/
31 @brief RLC Hash definitions
36 #include "rl_interface.h"
37 #include "rl_common.h"
40 #define KWLAYERNAME "LTE RLC" /* Layer Name */
48 /* RLC-SPLIT Activity */
55 #define KW_2K_BYTE 2048
57 /* RLC RB flag bits */
58 #define KW_RB_REESTABLISH_DL KW_BIT0
59 #define KW_RB_REESTABLISH_UL KW_BIT1
60 #define KW_RB_DELETE_DL KW_BIT2
61 #define KW_RB_DELETE_UL KW_BIT3
64 #define KW_MOD_1024 0x3FF /* used for MOD 1024 */
68 /************************************************************************
70 ************************************************************************/
72 #define KW_SAP_NOT_CFG 0 /*!< SAP Not Configured */
73 #define KW_SAP_CFG 1 /*!< SAP Configured but not not bound */
74 #define KW_SAP_BND 2 /*!< SAP Bound */
75 #define KW_SAP_BINDING 3 /*!< SAP Bind initiated */
76 #define KW_SAP_UBND 4 /*!< SAP Unbind */
78 #define KW_MAX_SAP_BND_RETRY 3 /*!< Maximum SAP Bin Retries */
80 #define KW_MAX_UE 0xffffffff /*!< Maximum number of UEs. */
82 /* Maximum number of Saps */
83 #define KW_MAX_UDXSAPS 1 /*!< Maximum number of UDX Saps */
84 #define KW_MAX_KWUSAPS 2 /*!< Maximum number of KWU Saps. */
85 #define KW_MAX_CKWSAPS 1 /*!< Maximum number of CKW Saps. */
87 #define KW_MAX_RGUSAPS 4//5 /*!< Maximum number of RGU Saps. */
89 #define KW_MAX_RGUSAP_TMR 1 /*!< Maximum number of RGU SAP Timers. */
91 #define KW_UI_RRC 0 /*!< Upper interface RRC sap Id. */
92 #define KW_UI_PDCP 1 /*!< Upper interface PDCP sap Id. */
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 KW_MAX_TB_PER_UE 64 /*!< Maximum number of tbCb for UE */
98 #define KW_INVALID_TBID KW_MAX_TB_PER_UE
100 /*******************************************************************************
101 * Memory related Defines
102 ******************************************************************************/
104 /* Allocate function */
105 #define KW_ALLOC(_cb,_buf, _size) \
107 SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf, \
109 cmMemset((U8 *)(_buf), 0, _size); \
112 #define KW_RMV_SDU(_cb,_sduQ,_sdu) \
114 SPutMsg(_sdu->mBuf); \
115 cmLListDelFrm(_sduQ,&_sdu->lstEnt); \
116 KW_FREE_WC(_cb,_sdu, sizeof(KwSdu)); \
119 #define KW_FREE(_cb,_buf, _size) \
121 (Void) SPutSBuf(_cb->init.region, _cb->init.pool, \
122 (Data *) _buf, (Size) _size); \
126 #define KW_FREE_BUF(_buf) \
134 #define KW_FREE_SHRABL_BUF(_region, _pool,_buf, _size) \
138 (Void) SPutStaticBuffer(_region, _pool, \
139 (Data *) _buf, (Size) _size, 0); \
144 #define KW_FREE_SHRABL_BUF_WC(_region, _pool,_buf, _size) \
146 (Void) SPutStaticBuffer(_region, _pool, \
147 (Data *) _buf, (Size) _size, 0); \
151 #define KW_ALLOC_SHRABL_BUF_WC(_region, _pool,_buf, _size) \
153 SGetStaticBuffer(_region, _pool, (Data **)&_buf, \
157 #define KW_ALLOC_SHRABL_BUF(_region, _pool,_buf, _size) \
159 if (SGetStaticBuffer(_region, _pool, (Data **)&_buf, \
160 (Size) _size, 0) == ROK) \
162 cmMemset((U8 *)(_buf), 0, _size); \
169 /* Allocate function */
170 #define KW_ALLOC(_cb,_buf, _size) \
172 if (SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf, \
173 (Size) _size) == ROK) \
175 cmMemset((U8 *)(_buf), 0, _size); \
183 #define KW_ALLOC_WC(_cb,_buf, _size) \
184 SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf, (Size) _size)
186 #define KW_RMV_SDU(_cb,_sduQ,_sdu) \
190 SPutMsg(_sdu->mBuf); \
192 cmLListDelFrm(_sduQ,&_sdu->lstEnt); \
193 KW_FREE(_cb,_sdu, sizeof(KwSdu)); \
196 #define KW_FREE(_cb,_buf, _size) \
200 (Void) SPutSBuf(_cb->init.region, _cb->init.pool, \
201 (Data *) _buf, (Size) _size); \
206 #define KW_FREE_BUF(_buf) \
219 #define KW_FREE_WC(_cb,_buf, _size) \
221 (Void) SPutSBuf(_cb->init.region, _cb->init.pool, \
222 (Data *) _buf, (Size) _size); \
223 _buf = NULLP; /*assigning NULLP after free*/ \
226 /* kw002.201 Freeing from region of pst */
227 #define KW_PST_FREE(_region, _pool, _buf, _size) \
231 (Void) SPutSBuf(_region, _pool, \
232 (Data *) _buf, (Size) _size); \
237 #ifdef XEON_SPECIFIC_CHANGES
238 #ifdef SS_LOCKLESS_MEMORY
239 #define KW_SHRABL_STATIC_BUF_FREE(_region, _pool, _buf, _size) \
243 (Void) SPutStaticBuffer(_region, _pool, \
244 (Data *) _buf, (Size) _size, 0); \
249 #define KW_SHRABL_STATIC_BUF_ALLOC(_region, _pool, _buf, _size) \
251 SGetStaticBuffer(_region, _pool, (Data **)&_buf, \
257 #define KW_SHRABL_STATIC_BUF_FREE(_region, _pool, _buf, _size) \
261 (Void) SPutSBuf(_region, _pool, \
262 (Data *) _buf, (Size) _size); \
267 #define KW_SHRABL_STATIC_BUF_ALLOC(_region, _pool, _buf, _size) \
269 SGetSBuf(_region, _pool, (Data **)&_buf, \
272 #endif /* SS_LOCKLESS_MEMORY */
276 #define KW_SHRABL_STATIC_BUF_FREE(_region, _pool, _buf, _size) \
280 (Void) SPutStaticBuffer(_region, _pool, \
281 (Data *) _buf, (Size) _size, 0); \
286 #define KW_SHRABL_STATIC_BUF_ALLOC(_region, _pool, _buf, _size) \
288 SGetStaticBuffer(_region, _pool, (Data **)&_buf, \
293 #define KW_FREE_BUF_WC(_buf) SPutMsg((_buf));
295 #define KW_MEM_CPY(_dst, _src, _size) cmMemcpy((U8*)_dst, (U8 *)_src, _size);
297 #define KW_MEM_ZERO(_buf, _size) cmMemset((U8 *)(_buf), 0, _size);
299 #define KW_GET_MEM_REGION(_cb) (_cb->init.region)
301 #define KW_GET_MEM_POOL(_cb) (_cb->init.pool)
303 #define KW_GET_MEM_POOL_ADDRESS(_cb) (&_cb->init.pool)
305 /* Memset to value */
306 #define KW_MEM_SET(_arg, _val, _size) cmMemset((U8 *)_arg, (U8)_val, _size);
309 /* Send an alarm for sapId events */
310 /* kw005.201 added support for L2 Measurement */
312 #define KW_GETSDUIDX(_sduIdx) \
314 _sduIdx = (((_sduIdx)+1) % KW_L2MEAS_MAX_OUTSTNGSDU);\
316 #define KW_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause) \
318 kwLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, _sapId, 0, 0); \
320 #define KW_SEND_UEID_ALARM(_cb,_ueId, _qci, _evnt, _cause) \
322 kwLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, 0, _ueId, _qci); \
324 #else /* LTE_L2_MEAS */
325 #define KW_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause) \
327 kwLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, _sapId, 0); \
329 #define KW_SEND_UEID_ALARM(_cb,_ueId, _evnt, _cause) \
331 kwLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, 0, _ueId); \
333 #endif /* LTE_L2_MEAS */
335 /*******************************************************************************
337 ******************************************************************************/
339 /* RLC Configuration parameters */
340 #define KW_MAX_UL_LI (2 * KW_MAX_LI)
341 /*macro KW_MAX_DL_LI is moved to kw_env.h file */
342 #define KW_MAX_DAT KW_MAXIMUM_DAT
343 /*macro KW_MAX_PDU is moved to kw_env.h file */
344 #define KW_MAX_RB_PER_CELL 10
345 #define KW_MAX_SRB_PER_UE 3
346 #define KW_MAX_DRB_PER_UE 32
347 #define KW_MAX_LCH_PER_UE 12
348 #define KW_MAX_LCH_PER_CELL 6
349 #define KW_MAX_NUM_RB 24
350 #define KW_MAX_UE 0xffffffff
351 #define KW_UE_LIST_BUCKET_SIZE 128
352 #define KW_CELL_LIST_BUCKET_SIZE 10
353 #define KW_TRANS_ID_LST_BKT_SIZE 10
356 /* Direction defines */
357 #define KW_DIR_UL 1 /*!< Unlink direction */
358 #define KW_DIR_DL 2 /*!< Downlink direction */
359 #define KW_DIR_BOTH 3 /*!< Both Downlink and Unlink */
361 #define KW_DEF_SEQ_NUM 0 /**< Sequence number to pick in case of duplicate
362 entries in hash list searches*/
367 * Macro to find the miniumum of two numbers
369 * @param[in] x First number
370 * @param[in] y Second number
373 #define KW_MIN(x,y) (x) < (y) ? (x) : (y)
378 * Macro to the RLC instance
380 * @param[in] _inst Instance Id
383 #define KW_GET_KWCB(_inst) kwCb[_inst]
385 #define KW_ADD_SDU 1 /*!< Add SDU. */
386 #define KW_DEL_SDU 2 /*!< Delete SDU. */
388 #define KW_CFM_NOK 0 /*!< Do not send DatCfm */
389 #define KW_CFM_OK 1 /*!< Send DatCfm */
391 /* Set the unsolictated Status flag */
392 #define KW_SET_USTA_FLAG(_kwCb, _value) \
394 _kwCb->init.usta = _value; \
397 /* Macros to get the init parameters */
398 #define KW_GET_DBG_MASK(_kwCb) (_kwCb->init.dbgMask)
399 #define KW_GET_LMPST_MEM_POOL(_kwCb) (_kwCb->init.lmPst.pool)
400 #define KW_GET_LMPST_MEM_REGION(_kwCb) (_kwCb->init.lmPst.region)
402 /* Macros for configuration module */
403 #define KW_CFG_FILL_CFG_CFM(_entCfm, _rbId, _rbType, _status, _reason) \
405 _entCfm->rbId = _rbId; \
406 _entCfm->rbType = _rbType; \
407 _entCfm->status.status = _status; \
408 _entCfm->status.reason = _reason; \
412 * @def KW_VALIDATE_UE_RBID
414 * This macro validates whether the _rbId passed is valid or not. It checks
415 * if the _rbId is within the maximum value depending on the _rbType.
416 * Returns TRUE if valid else FALSE
418 * @param[in] _rbType Type of the Radio Bearer; SRB or DRB
419 * @param[in] _rbId RB Id of the RB to be validated
422 #define KW_VALIDATE_UE_RBID(_rbType, _rbId) \
423 ((_rbType == CM_LTE_SRB && _rbId < KW_MAX_SRB_PER_UE) || \
424 (_rbType == CM_LTE_DRB && _rbId < KW_MAX_DRB_PER_UE))
426 /*******************************************************************************
428 ******************************************************************************/
429 #if (ERRCLASS & ERRCLS_INT_PAR)
430 #define KW_VALDATE_SAP(_cb,_chkSpId, _sap, _ret) \
432 if (_chkSpId != _sap->spId) \
434 KWLOGERROR(_cb,ERRCLS_DEBUG, EKWxxx, (ErrVal) RFAILED, \
435 "Sap Id Validation Failed."); \
438 /* SAP state validation */ \
439 if(_sap->state != KW_SAP_BND) \
441 KWLOGERROR(_cb,ERRCLS_INT_PAR, EKWXXX, (ErrVal) RFAILED, \
442 "Sap State Invalid."); \
443 KW_SEND_SAPID_ALARM(_cb,0, LCM_EVENT_UI_INV_EVT, LCM_CAUSE_INV_STATE); \
447 #else /* ERRCLASS & ERRCLS_INT_PAR */
448 #define KW_VALDATE_SAP(_cb,_chkSpId, _sap, _ret) \
450 /* SAP state validation */ \
451 if(_sap->state != KW_SAP_BND) \
453 KWLOGERROR(_cb,ERRCLS_INT_PAR, EKWXXX, (ErrVal) RFAILED, \
454 "Sap State Invalid."); \
455 KW_SEND_SAPID_ALARM(_cb,0, LCM_EVENT_UI_INV_EVT, LCM_CAUSE_INV_STATE); \
459 #endif /* ERRCLASS & ERRCLS_INT_PAR */
461 /*******************************************************************************
463 ******************************************************************************/
464 #define KW_TMR_LEN 10
465 #define KW_MAX_UM_TMR 1
466 #define KW_MAX_AM_TMR 3
467 #define KW_EVT_UMUL_REORD_TMR 1
468 #define KW_EVT_AMUL_REORD_TMR 2
469 #define KW_EVT_AMUL_STA_PROH_TMR 3
470 #define KW_EVT_AMDL_POLL_RETX_TMR 4
471 #define KW_EVT_WAIT_BNDCFM 5
472 /* kw005.201 added support for L2 Measurement */
474 #define KW_EVT_L2_TMR 6
475 #endif /* LTE_L2_MEAS */
477 /*******************************************************************************
479 ******************************************************************************/
481 * @def KW_DBM_GET_RBCB_FROM_UECB
483 * This macro makes _rbCb point to the RB in _ueCb based on the passed
484 * _rbId and _rbType. _rbCb can point to NULLP
486 * @param[in] _rbId RB Id of the RB to be fetched
487 * @param[in] _rbType Type of the RB, SRB or DRB
488 * @param[in] _ueCb Pointer to the UECb for which to get the RB
489 * @param[out] _rbCb Pointer to the found RbCb
492 #define KW_DBM_GET_RBCB_FROM_UECB(_rbId, _rbType, _ueCb, _rbCb) \
493 (_rbCb) = ((_rbType) == CM_LTE_SRB) ? (_ueCb)->srbCb[(_rbId)] : \
494 (_ueCb)->drbCb[(_rbId)];
496 * @def KW_DBM_GET_CELL_RBCB
498 * This macro makes _rbCb point to the RB in the _rbCbLst.
499 * _rbCb can point to NULLP
501 * @param[in] _rbId RB Id of the RB to be fetched
502 * @param[in] _rbCbLst Pointer to array of RBCbs
503 * @param[out] _rbCb Pointer to the found RbCb
506 #define KW_DBM_GET_CELL_RBCB(_rbId, _rbCbLst, _rbCb) \
507 (_rbCb) = (_rbCbLst)[(_rbId)];
509 /*******************************************************************************
511 ******************************************************************************/
512 #define KW_UMDL rbCb->m.umDl
513 #define KW_UMUL rbCb->m.umUl
515 /* Sequence Number length defines */
516 #define KW_UM_CFG_5BIT_SN_LEN 1 /**< UM 5-bit Sequence number length
518 #define KW_UM_CFG_10BIT_SN_LEN 2 /**< UM 10-bit Sequence number length
521 /* Sequence Number length defines */
522 #define KW_AM_CFG_12BIT_SN_LEN 1 /**< AM 12-bit Sequence number length
524 #define KW_AM_CFG_18BIT_SN_LEN 2 /**< AM 18-bit Sequence number length
528 * @def KW_RMV_MAC_HDR_SZ
530 * If PDU size is greater than 127, MAC header would be 3 bytes else 2 bytes
532 * @param[in,out] _pduSz Size of the pdu
535 #define KW_RMV_MAC_HDR_SZ(_pduSz) (_pduSz) -= ((_pduSz) > 127) ? 3 : 2;
538 * @def KW_UM_GET_VALUE
540 * This macro is used to calculate the value of UM state variables used
541 * in comparisons. VR(UH) - UM Window Size is taken as the base modulus.
542 * Returns the modifed value
544 * @param[in] _val Value of the state variable
545 * @param[in] _kwUmUl Um Uplink control block
548 #define KW_UM_GET_VALUE(_val,_kwUmUl) \
549 (((_val) - ((_kwUmUl).vrUh - (_kwUmUl).umWinSz)) & ((_kwUmUl).modBitMask))
551 /*******************************************************************************
553 ******************************************************************************/
554 #define AMDL rbCb->m.amDl
555 #define AMUL rbCb->m.amUl
558 #define KW_DATA_PDU 1
559 #define KW_CNTRL_PDU 0
561 #define KW_FI_FIRST_SEG 0x02
562 #define KW_FI_LAST_SEG 0x01
563 #define KW_SI_FIRST_SEG 0x01
564 #define KW_SI_LAST_SEG 0x02
565 #define KW_SI_MID_SEG 0x03
567 #define KW_POLL_SET 0x40 /* 01000000 */
568 #define KW_POLL_UNSET 0xbf /* 10111111 */
569 #define KW_AM_WIN_SZ 512
570 #define KW_MAX_NACK_CNT 100
571 /*KW_MAX_CNTRL_FIELDS (Maximum size of Status Pdu)
572 * = MAX_NACK_CNT * sizeof(NACK_SN,E1,E2,E3,soStart,soEnd, nackRange)
573 * for 18 bit SN + Fixed Header*/
574 #define KW_MAX_CNTRL_FIELDS ((KW_MAX_NACK_CNT * 8) + 3)
576 /* Each LI(Length Indicator) holds approx 1+1/2 byte and some other fields thus keeping Header Size equal to twice of MAX LI */
577 /* 5GNR_RLC: Need to change value of HDRSZ as per number of PDUs going in one datReq */
578 #define KW_MAX_HDRSZ 5
579 #define KW_AM_PDU_FIXED_HDRSZ 2
580 #define KW_AM_PDU_12BIT_SN_HDRSZ 2
581 #define KW_AM_PDU_18BIT_SN_HDRSZ 3
582 #define KW_AM_SEG_12BIT_SN_WITH_SO_HDRSZ 4
583 #define KW_AM_SEG_18BIT_SN_WITH_SO_HDRSZ 5
584 #define KW_AM_SEG_12BIT_SN_WITHOUT_SO_HDRSZ 2
585 #define KW_AM_SEG_18BIT_SN_WITHOUT_SO_HDRSZ 3
586 #define KW_EXTN_HDRSZ 2
587 #define KW_CNTRL_PDU_FIXED_HDRSZ 3
588 #define KW_MAC_HDR_SZ2 2
589 #define KW_MAC_HDR_SZ3 3
590 #define KW_BYTE_LEN 8
591 #define KW_2BYTE_LEN 16
593 #define KW_NACK_E1E2_LEN 12
603 #define KW_SN_LEN_12BITS 12
604 #define KW_SN_LEN_18BITS 18
607 #define KW_STA_PDU_R_BITS_ACKSN_12BITS 7 /* 5GNR : Num Reserved bits in STATUS PDU */
608 #define KW_STA_PDU_R_BITS_ACKSN_18BITS 1
609 #define KW_STA_PDU_R_BITS_NACKSN_12BITS 1
610 #define KW_STA_PDU_R_BITS_NACKSN_18BITS 3
611 #define KW_NACK_RANGE_LEN 8
612 #define KW_SO_LEN_5GNR 16
614 #define KW_DC_POS 0x80
616 #define KW_POLL_POS 0x40 /* 5GNR */
617 #define KW_POLL_SHT 6 /* 5GNR */
618 #define KW_SI_POS 0x30 /* 5GNR */
619 #define KW_SI_SHT 4 /* 5GNR */
620 #define KW_SN_POS_12BIT 0x0F
621 #define KW_SN_POS_18BIT 0x03
622 #define KW_AM_GET_WIN_SZ(_snLen) ((KW_AM_CFG_12BIT_SN_LEN == (_snLen)) ? (2048) : (131072)) /* 5GNR */
623 #define KW_RCV_BUF_BIN_SIZE 512 /* Could be increased to avoid the search time.
624 with the memory trade-off */
625 #define KW_TX_BUF_BIN_SIZE 512 /* Could be increased to avoid the search time.
626 with the memory trade-off */
630 #define KW_RETX_LST 3
631 #define KW_ALL_BYTES_MISSING 0xffff
633 #define KW_MAX_PDU_MAP 30 /*!< Maximum PDU Map. */
635 #define KW_LLIST_FIRST_SDU(lstCp, nod) \
638 /*CM_LLIST_FIRST_NODE(&(lstCp), tmpNode);*/ \
639 /*if (tmpNode != NULLP)*/ \
640 if((tmpNode=cmLListFirst(&lstCp))) \
641 nod = (KwSdu *)tmpNode->node; \
647 #define KW_LLIST_FIRST_SEG(lstCp, nod) \
650 /*CM_LLIST_FIRST_NODE(&(lstCp), tmpNode);*/ \
651 /*if (tmpNode != NULLP)*/ \
652 if((tmpNode=cmLListFirst(&lstCp))) \
653 nod = (KwSeg *)tmpNode->node; \
659 #define KW_LLIST_FIRST_RETX(lstCp, nod) \
662 /*CM_LLIST_FIRST_NODE(&(lstCp), tmpNode);*/ \
663 /*if (tmpNode != NULLP)*/ \
664 if((tmpNode=cmLListFirst(&lstCp))) \
665 nod = (KwRetx *)tmpNode->node; \
670 #define KW_LLIST_NEXT_SDU(lstCp, nod) \
673 /*CM_LLIST_NEXT_NODE(&(lstCp), tmpNode);*/ \
674 /*if (tmpNode != NULLP) */ \
675 if((tmpNode = cmLListNext(&lstCp))) \
676 nod = (KwSdu *)tmpNode->node; \
682 #define KW_LLIST_NEXT_SEG(lstCp, nod) \
685 (lstCp).crnt = &((nod)->lstEnt); \
686 /*CM_LLIST_NEXT_NODE(&(lstCp), tmpNode);*/ \
687 /*if (tmpNode != NULLP)*/ \
688 if((tmpNode = cmLListNext(&lstCp))) \
689 nod = (KwSeg *)tmpNode->node; \
695 #define KW_LLIST_NEXT_RETX(lstCp, nod) \
698 /*CM_LLIST_NEXT_NODE(&(lstCp), tmpNode);*/ \
699 /*if (tmpNode != NULLP) */ \
700 if ((tmpNode = cmLListNext(&lstCp))) \
701 nod = (KwRetx *)tmpNode->node; \
707 #define KW_LLIST_LAST_RETX(lstCp, nod) \
709 CmLList *tempNode = NULLP; \
710 cmLListLast(&lstCp); \
711 tempNode = cmLListCrnt(&lstCp); \
712 if (tempNode != NULLP) \
713 nod = (KwRetx *)tempNode->node; \
718 #define KW_LLIST_LAST_SEG(lstCp, nod) \
720 CmLList *tempNode = NULLP; \
721 cmLListLast(&lstCp); \
722 tempNode = cmLListCrnt(&lstCp); \
723 if (tempNode != NULLP) \
724 nod = (KwSeg *)tempNode->node; \
729 #define KW_LLIST_LAST_SDU(lstCp, nod) \
731 CmLList *tempNode = NULLP; \
732 cmLListLast(&lstCp); \
733 tempNode = cmLListCrnt(&lstCp); \
734 if (tempNode != NULLP) \
735 nod = (KwSdu *)tempNode->node; \
740 #define CM_LLIST_INS_AFT_CRNT(lstCp, nod) \
742 CmLList *nodeToIns = &nod->lstEnt;\
743 nodeToIns->node = (PTR) nod;\
744 cmLListInsAfterCrnt(&lstCp, nodeToIns); \
747 #define CM_LLIST_INS_BEF_CRNT(lstCp, nod) \
749 CmLList *nodeToIns = &nod->lstEnt; \
750 nodeToIns->node = (PTR) nod; \
751 cmLListInsCrnt(&lstCp, nodeToIns); \
754 #define KW_LLIST_DEL_RECBUF(_recBuf) \
756 KwSeg *_seg = NULLP; \
757 KW_LLIST_FIRST_SEG(_recBuf->segLst, _seg); \
760 cmLListDelFrm(&_recBuf->segLst, &_seg->lstEnt); \
761 KW_FREE(_seg, sizeof(KwSeg)); \
762 KW_LLIST_NEXT_SEG(_recBuf->segLst, _seg); \
766 #define MODAMT(x, y, z,_snModMask) \
768 y = (x - z) & _snModMask; \
771 #define MODAMR(x, y, z , _snModMask) \
773 y = (x - z) & (_snModMask); \
777 * @def KW_AM_IS_TRANS_WIN_STALLED
779 * This macro is used to check if the AM transmit window is stalled or not.
780 * The tramist window is stalled when the distance between txNext and txNextAck
781 * is greater than equal to Window Size. Actually it should never be greater
783 * Returns TRUE if the window is stalled else FALSE
785 * @param[in] _amDl AM Downlink control block
788 #define KW_AM_IS_TRANS_WIN_STALLED(_amDl) \
789 ((((_amDl)->txNext - (_amDl)->txNextAck) & _amDl->snModMask) >= (KW_AM_GET_WIN_SZ(_amDl->snLen)))
792 #define KW_AM_TRANS_WIN_SIZE(_amDl) \
793 (((_amDl)->txNext - (_amDl)->txNextAck) & _amDl->snModMask)
796 #define KW_AM_IS_POLL_BIT_SET(_amDl) \
797 (AMDL.pollSn == ((AMDL.txNext - 1) & AMDL.snModMask))
799 #define KW_FILL_CNTRL_INFO(cntrlInfo, _val, _len, _idx, _eb)\
801 cntrlInfo.val = _val; \
802 cntrlInfo.len = _len; \
803 cntrlInfo.idx = _idx; \
804 cntrlInfo.emtBits = _eb; \
806 #define KW_FILL_PREV_IDX(cntrlInfo, _e1Idx, _e1eb, _idx, _eb) \
808 _e1Idx = cntrlInfo.e1Idx; \
809 _e1eb = cntrlInfo.e1eb; \
810 _idx = cntrlInfo.idx; \
811 _eb = cntrlInfo.emtBits; \
814 #define KW_FILL_HDR_ARGS(hdrInfo, _val, _len) \
816 hdrInfo.val = _val; \
817 hdrInfo.len = _len; \
820 /* kw003.201 - This macro provides the header size other than the */
821 /* fixed header of 2 bytes for each AMD PDU or 4 bytes*/
822 /* for an AM PDU segment */
823 #define KW_AM_EXTN_HDRSZ(_numLi, _eHdrSz) \
825 if ((_numLi - 1) % 2) \
827 _eHdrSz = ((3 * (_numLi - 2)) >> 1) + 2; \
831 _eHdrSz = (3 * (_numLi - 1)) >> 1; \
835 /* Update poll bit in the buffer */
836 #define KW_UPD_POLL_BIT(_gCb, _retx, _poll) \
840 if (_poll != _retx->amHdr.p) \
842 /* Get the first byte of the buffer */ \
843 SRemPreMsg((Data *)&fHdr, _retx->seg); \
846 fHdr = fHdr | KW_POLL_SET; \
850 fHdr = fHdr & KW_POLL_UNSET; \
852 /* Concatenated updated hdr to the mBuf */ \
853 SAddPreMsg ((Data)fHdr, _retx->seg); \
855 /* Update poll bit in the hdrInfo */ \
856 _retx->amHdr.p = _poll; \
859 #define KW_AM_ELIMINATE_EXTN_HDR(_pduSz, _sduSz, _numLi) \
861 if ( (_pduSz > _sduSz) && (_sduSz < 2048) ) \
863 _pduSz -= (_numLi % 2) ? 1 : 2; \
867 * @def KW_AM_CHK_SN_WITHIN_RECV_WINDOW
869 * This macro is used to check if a Sequence Number falls within the AM
870 * reception window or not.
871 * The condition is VR(R) <= SN < VR(MR), which are subtracting the base
872 * modulus becomes 0 <= (SN - VR(R)) % SNLen < (VR(MR) - VR(R)) % SnLen
873 * NOTE: Careful with the parantheses
875 * Returns TRUE if within the window; FALSE otherwise
877 * @param[in] _sn The sequence number to be checked
878 * @param[in] _amUl AM Uplink control block
881 #define KW_AM_CHK_SN_WITHIN_RECV_WINDOW(_sn, _amUl) \
882 ((((_sn) - (_amUl->rxNext)) & (_amUl->snModMask)) < (((_amUl->vrMr) - (_amUl->rxNext)) & (_amUl->snModMask)))
884 #define KW_POWER(x, y) x << (y-1);
887 #define kwCpyMsg(_cb,x, y) \
888 (SAddMsgRef((x), KW_GET_MEM_REGION(_cb), KW_GET_MEM_POOL(_cb), (y)))
890 /* L2 optimization for mUe/Tti: Removing dup buf*/
891 #define kwCpyMsg(_cb,x, y) \
892 (SIncMsgRef((x), KW_GET_MEM_REGION(_cb), KW_GET_MEM_POOL(_cb), (y)))
895 // printf("Copy Msg %x \n",x);
897 /*******************************************************************************
899 ******************************************************************************/
900 #define KW_DBG_SUB_MASK DBGMASK_MI /**< Use for sub-mask */
901 #define KW_DBGMASK_DETAIL (KW_DBG_SUB_MASK << 0) /**< Parameters, It will give
903 #define KW_DBGMASK_BRIEF (KW_DBG_SUB_MASK << 1) /**< Info, It will give info at
904 entry and exit places along
905 with certain state changes */
906 #define KW_DBGMASK_ERROR (KW_DBG_SUB_MASK << 2) /**< Error information */
907 #define KW_DBGMASK_FATAL (KW_DBG_SUB_MASK << 3) /**< FATAL errors like memory
908 resource failure etc., */
910 #define KW_DBG_MDL_MASK (KW_DBG_SUB_MASK << 4)
912 #define KW_DBGMASK_TM (KW_DBG_MDL_MASK << 0) /**< TM */
913 #define KW_DBGMASK_UM (KW_DBG_MDL_MASK << 1) /**< UM */
914 #define KW_DBGMASK_AM (KW_DBG_MDL_MASK << 2) /**< AM */
915 #define KW_DBGMASK_DL (KW_DBG_MDL_MASK << 3) /**< DL */
916 #define KW_DBGMASK_UL (KW_DBG_MDL_MASK << 4) /**< UL */
917 #define KW_DBGMASK_CFG (KW_DBG_MDL_MASK << 5) /**< CFG */
918 #define KW_DBGMASK_LMM (KW_DBG_MDL_MASK << 6) /**< LMM */
919 #define KW_DBGMASK_INF (KW_DBG_MDL_MASK << 7) /**< UI, LI */
920 #define KW_DBGMASK_DUT (KW_DBG_MDL_MASK << 8) /**< DBM, UTL, TMR */
921 #define KW_DBGMASK_MBUF_PRNT (KW_DBG_MDL_MASK << 9) /**< MBUF, useful in
924 #define KW_DBGMASK_MEM_INFO (KW_DBG_MDL_MASK << 10) /**< Print SSI memory
926 #define KW_DBGMASK_UDX (KW_DBG_MDL_MASK << 11) /**< UDX interface */
929 #define KW_PRNT_BORDER \
932 KW_PRNT((_kwPBuf, "\n==========================\n")); \
935 #define KW_PRNT_HLINE(_cb,_pMsg) \
937 sprintf((_cb)->init.prntBuf, "[RLC_LAYER: %s:%d]::", __FILE__, __LINE__); \
938 SPrint((_cb)->init.prntBuf); \
939 KW_PRNT_TSTAMP(_cb); \
940 sprintf((_cb)->init.prntBuf, _pMsg); \
941 SPrint((_cb)->init.prntBuf); \
944 #define KW_PRNT(_cb,_prntbuf) \
947 SPrint(_cb->init.prntBuf); \
950 #define KW_PRINT_TO_BUFFER(_cb,...) \
952 snprintf((_cb)->init.prntBuf, PRNTSZE, "[%s]::", __func__); \
953 SPrint((_cb)->init.prntBuf); \
954 snprintf(_cb->init.prntBuf, PRNTSZE,__VA_ARGS__); \
955 SPrint(_cb->init.prntBuf); \
958 #define KW_PRNT_TSTAMP(_cb) \
962 cmMemset((U8 *)(&dt), 0, sizeof(DateTime)); \
964 sprintf(_buf, "date: %02d/%02d/%04d time: %02d:%02d:%02d", \
965 (int)dt.month,(int)dt.day,(int)dt.year + 1900, \
966 (int)dt.hour,(int)dt.min,(int)dt.sec); \
967 KW_PRNT(_cb,(_cb->init.prntBuf,("[%s]", _buf))); \
970 #define KW_PRNT_MBUF(_cb,_mBufPtr) \
973 if(_cb->init.dbgMask & (KW_DBGMASK_MBUF_PRNT)) \
975 KW_PRNT_HLINE(_cb,("\nMessage Buffer Contents:\n")); \
976 SPrntMsg ((Buffer *)_mBufPtr, 0, 0); \
980 #define KW_PRNT_MEMINFO(_cb) \
984 if(_cb->init.dbgMask & (KW_DBGMASK_MEM_INFO)) \
986 KW_PRNT_HLINE(_cb,("\nMemory Information:\n")); \
987 SRegInfoShow(0, &_memInfo); \
991 #define KWDBGP_INTERNAL(_cb,_mask,...) \
994 if (!((_cb->init.dbgMask & _mask) ^ _mask)) \
996 KW_PRINT_TO_BUFFER(_cb, __VA_ARGS__); \
1000 #define KWDBGP_ERROR(_cb, ...) \
1001 KWDBGP_INTERNAL(_cb,(KW_DBGMASK_ERROR | KW_MODULE),__VA_ARGS__)
1003 #define KWDBGP_DETAIL(_cb, ...) \
1004 KWDBGP_INTERNAL(_cb,(KW_DBGMASK_DETAIL | KW_MODULE),__VA_ARGS__)
1006 #define KWDBGP_BRIEF(_cb, ...) \
1007 KWDBGP_INTERNAL(_cb,(KW_DBGMASK_BRIEF | KW_MODULE),__VA_ARGS__)
1010 #define KW_PRNT_HLINE(_cb,_pMsg)
1011 #define KW_PRNT(_cb,_prntbuf)
1012 #define KW_PRNT_TSTAMP(_cb)
1013 #define KW_PRNT_MBUF(_cb,_mBufPtr)
1014 #define KW_PRNT_MEMINFO(_cb)
1015 #define KWDBGP(_cb,_mask, _arg)
1016 #define KWDBGP_ERROR(_cb, ...)
1017 #define KWDBGP_DETAIL(_cb, ...)
1018 #define KWDBGP_BRIEF(_cb, ...)
1021 /*******************************************************************************
1023 ******************************************************************************/
1024 #define KW_LMM_RB_STS_INC(_cb) (_cb)->genSts.numOfRb++;
1026 #define KW_LMM_RB_STS_DEC(_cb) (_cb)->genSts.numOfRb--;
1028 #if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION)
1029 #define KW_FILL_SAP_HELPER(_Sap, _cfg, _gCb)\
1031 _Sap->pst.selector = _cfg->selector; \
1032 _Sap->pst.route = _cfg->route; \
1033 _Sap->pst.prior = _cfg->priority; \
1034 _Sap->pst.region = _gCb->init.region;\
1035 _Sap->pst.pool = _gCb->init.pool;\
1036 _Sap->pst.dstProcId = _cfg->procId; \
1037 _Sap->pst.dstEnt = _cfg->ent; \
1038 _Sap->pst.dstInst = _cfg->inst; \
1039 _Sap->pst.srcProcId = _gCb->init.procId; \
1040 _Sap->pst.srcEnt = _gCb->init.ent; \
1041 _Sap->pst.srcInst = _gCb->init.inst; \
1042 _Sap->pst.event = EVTNONE; \
1043 _Sap->spId = _cfg->sapId; \
1044 _Sap->state = KW_SAP_CFG; \
1046 #else /* defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION) */
1047 #define KW_FILL_SAP_HELPER(_Sap, _cfg, _gCb)\
1049 _Sap->pst.selector = _cfg->selector; \
1050 _Sap->pst.route = _cfg->route; \
1051 _Sap->pst.prior = _cfg->priority; \
1052 _Sap->pst.region = _cfg->mem.region;\
1053 _Sap->pst.pool = _cfg->mem.pool;\
1054 _Sap->pst.dstProcId = _cfg->procId;\
1055 _Sap->pst.dstEnt = _cfg->ent;\
1056 _Sap->pst.dstInst = _cfg->inst;\
1057 _Sap->pst.srcProcId = _gCb->init.procId;\
1058 _Sap->pst.srcEnt = _gCb->init.ent;\
1059 _Sap->pst.srcInst = _gCb->init.inst;\
1060 _Sap->pst.event = EVTNONE;\
1061 _Sap->spId = _cfg->sapId;\
1062 _Sap->state = KW_SAP_CFG;\
1066 /*******************************************************************************
1068 ******************************************************************************/
1069 #define KW_GET_DL_SAPCB(_cb, _rbCb) (_cb->u.dlCb->udxDlSap + _rbCb->udxSapId)
1070 #define KW_GET_UDX_SAP(_cb) (_cb->u.ulCb->udxUlSap)
1072 /* kw005.201 added support for L2 Measurement */
1074 #define KW_L2_MAX_TIMERS 1
1075 #define KW_QCI_LIST_BUCKET_SIZE 10
1076 #define KW_TB_LIST_BUCKET_SIZE 10
1077 #define KW_MAX_L2MEAS_EVT 10
1078 /* L2 Measurement index to be used in rbCb to store measData */
1079 #define KW_L2MEAS_ACT_UE 0
1080 #define KW_L2MEAS_DL_DELAY 1
1081 #define KW_L2MEAS_DL_DISC 2
1082 #define KW_L2MEAS_UU_LOSS 3
1083 #define KW_L2MEAS_DL_IP 4
1084 #define KW_L2MEAS_UL_IP 5
1085 #endif /* LTE_L2_MEAS */
1087 #define KW_RDWR_LOCK(_lockPtr)
1088 #define KW_RDWR_UNLOCK(_lockPtr)
1089 #define KW_TIME_DIFF(t1,t2) \
1090 (t1<t2 ? ((0xffffffff - t2) + t1 ): (t1 - t2))
1092 #endif /* __KWH__ */
1094 /********************************************************************30**
1097 **********************************************************************/