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 PDCP
30 *********************************************************************21*/
32 @brief PDCP Hash definitions
38 #include "rl_interface.h"
39 #include "rl_common.h"
43 #define PJLAYERNAME "LTE PDCP" /* Layer Name */
47 #define PJ_MAX_KWUSAPS 2 /*!< Maximum number of KWU Saps. */
48 #define PJ_MAX_UDXSAPS 1
49 #define PJ_MAX_RB_PER_CELL 10
50 #define PJ_MAX_SRB_PER_UE 3
51 #define PJ_MAX_DRB_PER_UE 32
52 #define PJ_MAX_LCH_PER_UE 12
53 #define PJ_MAX_LCH_PER_CELL 6
54 #define PJ_MAX_NUM_RB 24
55 #define PJ_MAX_UE 0xffffffff
56 #define PJ_UE_LIST_BUCKET_SIZE 128
57 #define PJ_CELL_LIST_BUCKET_SIZE 10
59 #define PJ_DEF_SEQ_NUM 0
60 #define PJ_ASYNC_WIN 16
62 #define PJ_MAX_CPJSAPS 1 /*!< Maximum number of CPJ Saps. */
63 #define PJ_MAX_PJUSAPS 2 /*!< Maximum number of PJU Saps. */
65 #define PJ_LMM_GENCFG_DONE 2 /*!< PDCP LM general configuraiton done. */
67 #define PJ_PDCP_MODE_DL 1
68 #define PJ_PDCP_MODE_UL 2
70 /* Direction defines */
71 #define PJ_DIR_UL 1 /*!< Unlink direction */
72 #define PJ_DIR_DL 2 /*!< Downlink direction */
73 #define PJ_DIR_BOTH 3 /*!< Both Downlink and Unlink */
75 #define PJ_DBG_SUB_MASK DBGMASK_MI /* Use for sub-mask */
76 #define PJ_DBGMASK_DETAIL (PJ_DBG_SUB_MASK << 0) /* Parameters, It will give
78 #define PJ_DBGMASK_BRIEF (PJ_DBG_SUB_MASK << 1) /* Info, It will give info at
79 entry and exit places along
80 with certain state changes */
81 #define PJ_DBGMASK_ERROR (PJ_DBG_SUB_MASK << 2) /* Error information */
82 #define PJ_DBGMASK_FATAL (PJ_DBG_SUB_MASK << 3) /* FATAL errors like memory
83 resource failure etc., */
86 #define PJ_DBG_MDL_MASK (PJ_DBG_SUB_MASK << 4)
88 #define PJ_DBGMASK_DLM (PJ_DBG_MDL_MASK << 0) /* DL */
89 #define PJ_DBGMASK_ULM (PJ_DBG_MDL_MASK << 1) /* UL */
90 #define PJ_DBGMASK_UTL (PJ_DBG_MDL_MASK << 2) /* DBM, UTL, TMR */
91 #define PJ_DBGMASK_CFG (PJ_DBG_MDL_MASK << 3) /* LMM and CFG */
92 #define PJ_DBGMASK_LIB (PJ_DBG_MDL_MASK << 4) /* LIB - means software
94 #define PJ_DBGMASK_INF (PJ_DBG_MDL_MASK << 5)
95 #define PJ_DBGMASK_LMM (PJ_DBG_MDL_MASK << 6)
96 #define PJ_DBGMASK_DL (PJ_DBG_MDL_MASK << 7)
97 #define PJ_DBGMASK_UL (PJ_DBG_MDL_MASK << 8)
100 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
102 #define ICC_POOL_ZERO_SIZE 384
103 #define ICC_POOL_ONE_SIZE 1920
104 #define ICC_POOL_TWO_SIZE 3968
105 #define ICC_POOL_THREE_SIZE 16256
106 #endif /* TENB_T2K3K_SPECIFIC_CHANGES */
109 #define _pjPBuf pjCb.init.prntBuf
111 #define PJ_PRNT(_cb,_prntbuf) \
114 SPrint(_cb->init.prntBuf); \
118 #define PJ_PRNT_HLINE(_pMsg)
119 #define PJ_PRNT(_cb,_prntbuf)
120 #define PJ_PRNT_TSTAMP
121 #define PJ_PRNT_MBUF(_mBufPtr)
122 #define PJ_PRNT_MEMINFO
126 #define PJ_PRNT_HLINE(_pMsg) \
128 sprintf(_pjPBuf, "[PDCP_LAYER: %s:%d]::", __FILE__, __LINE__); \
130 sprintf(_pjPBuf, _pMsg); \
134 #define PJDBGP(_cb,_mask, _arg) \
137 if (!((_cb->init.dbgMask & _mask) ^ _mask)) \
143 #define PJ_PJ_PRNT_HLINE(_pMsg)
144 #define PJDBGP(_cb,_mask, _arg)
149 /************************************************************************
151 ************************************************************************/
153 /* ############################PDCP DEFINES ############################# */
155 #define PJ_SAP_NOT_CFG 0 /*!< SAP Not Configured */
156 #define PJ_SAP_CFG 1 /*!< SAP Configured but not not bound */
157 #define PJ_SAP_BND 2 /*!< SAP Bound */
158 #define PJ_SAP_BINDING 3 /*!< SAP Bind initiated */
159 #define PJ_SAP_UBND 4 /*!< SAP Unbind */
160 #define PJ_MAX_SAP_BND_RETRY 3 /*!< Maximum SAP Bin Retries */
163 #define PJ_RB_MAX_TIMERS 1 /* No of timers */
164 #define PJ_MAX_OBD_TMR 3 /* Number of OBD Timers */
165 #define PJ_MAX_DISC_TMR 1 /* Number of Discard Timers */
166 #define PJ_MAX_KWUSAP_TMR 1 /*!< Maximum number of KWU SAP Timers. */
167 #define PJ_EVT_WAIT_BNDCFM 0x01 /* Bind confirm timer */
168 #define PJ_MAX_UDXSAP_TMR 1 /*!< Maximum number of UDX SAP Timers. */
169 #define PJ_EVT_DL_OBD_TMR 0x11
170 #define PJ_EVT_UL_OBD_TMR 0x12
171 #define PJ_EVT_OBD_TMR 0x13
172 #define PJ_EVT_TMR_NONE 0x14
173 #define PJ_EVT_OBD_WAIT_TMR 0x15
174 #define PJ_EVT_UE_DEL_WAIT_TMR 0x16
175 /* kw005.201 added support for L2 Measurement */
177 #define PJ_EVT_L2_TMR 0x20
178 #define PJ_EVT_L2_MEAS_TMR 0x17
179 #endif /* LTE_L2_MEAS */
180 #define PJ_EVT_UL_REORD_TMR 0x21
181 #define PJ_MAX_UL_REORD_TMRS 1
182 #define PJ_EVT_WAIT_KWU_BNDCFM 0x18
183 #define PJ_EVT_WAIT_UDX_BNDCFM 0x19
184 #define PJ_DRB_12BIT_SN_HDR 0x8000
185 #define PJ_DRB_18BIT_SN_HDR 0x800000 /*!<18 bit SN setting the hdr for DRB */
186 #define PJ_ROHC_FEEDBACK_HDR 0x0010
187 #define PJ_FIRST_BIT 0x80
189 #define PJ_DATA_PDU 0x01
190 #define PJ_ROHC_FEEDBACK 0x02
191 #define PJ_STA_PDU 0x03
193 #define PJ_INTG_KEY_LEN 16
194 #define PJ_CIPHER_KEY_LEN 16
196 /*#define PJ_MAX_DAT_CFM 512 */
197 /* changed from 512 to 1024 */
198 #define PJ_MAX_DAT_CFM 1024
200 #define PJ_SDU_RECEIVED 0x01
201 #define PJ_WAIT_FOR_INTPROT 0x02
202 #define PJ_WAIT_FOR_CMP 0x03
203 #define PJ_WAIT_FOR_CIPHER 0x04
204 #define PJ_PDU_CONSTRUCTED 0x05
205 #define PJ_PDU_SUBMITTED 0x06
206 #define PJ_TX_ENT_TO_DEL 0x07
208 #define PJ_12_BIT_SN 12
209 #define PJ_18_BIT_SN 18
211 #define PJ_TX_BUF_LEN 256
212 #define PJ_MAX_SDU_SIZE 8188
214 #define PJ_SRB PJ_SRB_SAP
215 #define PJ_DRB PJ_DRB_SAP
226 #define PJ_GET_PJCB(_inst) pjCb[_inst];
227 #define PJ_BYTE_LEN 8
230 #define PJ_SEC_DIR_UL 0
231 #define PJ_SEC_DIR_DL 1
233 #define PJ_PDU_CONSTRUCT_FAILED 1
234 #define PJ_HDR_COMP_FAILED 2
235 #define PJ_INTG_PROT_FAILED 3
236 #define PJ_CIPHER_FAILED 4
237 #define PJ_CPY_MSG_FAILED 5
238 #define PJ_REM_MSG_FAILED 6
239 #define PJ_DISC_TMR_EXP 7
240 #define PJ_OBD_TIMEOUT 8
243 #define PJ_CFG_PDCP 2
244 #define PJ_CFG_BOTH 3
245 #define PJ_TRANS_ID_LST_BKT_SIZE 10
247 /* PJ_MS_KENB_LEN: Its the max lenght of the key for derivation of CK and IK */
248 /* PJ_MS_STR_S_LEN: Length of "STR S" which is one of the inputs for CK and IK dervation */
249 #define PJ_MS_KENB_LEN 32
250 #define PJ_MS_STR_S_LEN 9
251 #define PJ_NUM_BYTES_FRESH 4 /*<!Number of Bytes for FRESH variable */
253 #define PJ_KDF_SAP 0 /*!<Dummy SAP for KDF functionality*/
256 #define PJ_VALIDATE_RBID(_ueId, _rbId, _rbType, _ret) \
261 if (_rbId >= PJ_MAX_RB_PER_CELL) \
268 if ((_rbType != CM_LTE_SRB) && (_rbType != CM_LTE_DRB)) \
272 else if (_rbType == CM_LTE_SRB &&_rbId >= PJ_MAX_SRB_PER_UE) \
276 else if (_rbType == CM_LTE_DRB &&_rbId >= PJ_MAX_DRB_PER_UE) \
283 #define PJ_DBM_FETCH_RBCB(_rbId, _rbType, _ueCb, _rbCb) \
286 _rbCbLst = (_rbType==CM_LTE_SRB)?_ueCb->srbCb:_ueCb->drbCb;\
287 if (_rbCbLst[_rbId] != NULLP) \
289 _rbCb = _rbCbLst[_rbId]; \
296 #define PJ_DBM_FETCH_CELL_RBCB(_rbId, _rbCbLst, _rbCb) \
298 if (_rbCbLst[_rbId] != NULLP) \
300 _rbCb = _rbCbLst[_rbId]; \
308 #define PJ_GET_UL_UDX_SAP(_cb) (&(_cb->u.ulCb->udxUlSap[0]))
310 /* LMM Module Macros */
311 #define PJ_LMM_RB_STS_INC(_cb) \
313 _cb->pjGenSts.numOfRb++; \
316 #define PJ_LMM_RB_STS_DEC(_cb) \
318 _cb->pjGenSts.numOfRb--; \
324 /* kw005.201 moved the definition from kw_pj_dlm.c file */
325 #define PJ_PJ_ASYNC_WIN 16
327 /* L2 Measurement index to be used in rbCb to store measData */
328 #define PJ_L2MEAS_UL_LOSS 0
329 #define PJ_L2CPU_PERCORE_STATS 1
330 #define PJ_L2MEM_PERPOOL_STATS 2
331 #define PJ_L2MEAS_ACT_UE 3
332 #define PJ_L2MEAS_DL_DELAY 4
333 #define PJ_L2MEAS_DL_DISC 5
334 #define PJ_MAX_L2MEAS_INRB 6
335 #define PJ_L2MEAS_UU_LOSS 7
336 #define PJ_L2MEAS_DL_IP 8
337 #define PJ_L2MEAS_UL_IP 9
339 #define PJ_L2_MAX_TIMERS 1
341 #define PJ_MAX_L2MEAS_EVT 10
342 #define PJ_INIT_RB_L2CB(_measVal, _measCb, _pjRbCb) \
344 cmLListAdd2Tail(&_measCb->rbList, &_pjRbCb->rbL2Cb.listNode[_measVal]);\
345 _pjRbCb->rbL2Cb.l2Sts[_measVal] = &_measCb->measData[_pjRbCb->qci]; \
348 #define PJ_RMV_RB_FRM_L2LIST(_measVal, _measCb, _pjRbCb) \
349 cmLListDelFrm(&_measCb->rbList, \
350 &_pjRbCb->rbL2Cb.listNode[_measVal]);
352 #define PJ_UPD_L2_DLDELAY_STS(_pjRbCb, _val) \
354 _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY]->dlDelay.numPkts++; \
355 _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY]->dlDelay.val += _val; \
357 #define PJ_UPD_L2_DLDISC_PKT_STS(_pjCb, _pjRbCb) \
359 if((_pjRbCb->rbType == PJ_DRB) && \
360 ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC)) \
362 _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC]->dlDisc.numPkts++; \
366 #define PJ_UPD_L2_DLDISC_STS(_pjCb, _pjRbCb) \
368 if((_pjRbCb->rbType == PJ_DRB) && \
369 ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC)) \
371 _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC]->dlDisc.val++; \
375 #define PJ_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause) \
377 pjLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, _sapId, 0, 0); \
379 #define PJ_SEND_UEID_ALARM(_ueId, _qci, _evnt, _cause) \
381 pjLmmSendAlarm(LCM_CATEGORY_INTERFACE, _evnt, _cause, 0, _ueId, _qci); \
384 #define PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(_pjCb, _pjRbCb) \
386 if(((_pjRbCb)->rbType == CM_LTE_DRB) && \
387 ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC)) \
390 for (idx1 = 0; idx1 < LPJ_MAX_L2MEAS; idx1++) \
392 if(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measType & LPJ_L2MEAS_DL_DISC) \
394 if(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci > 0) \
396 _pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci--; \
397 if (_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci == 0) \
399 _pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.qci[(_pjRbCb)->qci] = 0; \
400 cmMemset((U8 *)&_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci], 0, \
401 sizeof(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci])); \
409 #define PJ_GET_SN_DIFF(_expSn, _rcvdSn, _snLen, _diff) \
411 if(_expSn > _rcvdSn) \
413 _diff = _rcvdSn + (1 << _snLen) - _expSn; \
417 _diff = _rcvdSn - _expSn; \
421 #define PJ_UPD_L2_ULLOSS_CNTRS(_cb,_count, _pjRbCb) \
425 PJ_GET_SN_HFN(_count, _pjRbCb->snLen, _sn, _hfn) \
426 if(_cb->u.ulCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_UL_LOSS) \
429 PJ_GET_SN_DIFF(_pjRbCb->ulCb.nxtSubSn, _sn, _pjRbCb->snLen, _diff) \
430 _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->ulLoss.numPkts += _diff + 1; \
431 _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->ulLoss.val += _diff; \
433 _pjRbCb->ulCb.nxtSubSn = (_sn + 1) % (1 << _pjRbCb->snLen); \
436 #else /* LTE_L2_MEAS */
437 #define PJ_UPD_L2_DLDELAY_STS(_pjRbCb, _val)
438 #define PJ_UPD_L2_ULLOSS_PKT_STS(_pjRbCb)
439 #define PJ_UPD_L2_ULLOSS_STS(_pjRbCb)
440 #define PJ_UPD_L2_DLDISC_PKT_STS(_pjCb,_pjRbCb)
441 #define PJ_UPD_L2_DLDISC_STS(_pjCb,_pjRbCb)
442 #define PJ_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause)
443 #define PJ_SEND_UEID_ALARM(_ueId, _qci, _evnt, _cause)
444 #define PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(_pjCb, _pjRbCb)
445 #define PJ_UPD_L2_ULLOSS_CNTRS(_cb, _count, _pjRbCb)
446 #endif /* LTE_L2_MEAS */
447 /* kw005.201 added support for L2 Measurement */
449 #if (ERRCLASS & ERRCLS_INT_PAR)
450 #define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret) \
452 if (_chkSpId != _sap->spId) \
454 RLOG0(L_ERROR,"Sap Id Validation Failed."); \
457 /* SAP state validation */ \
458 if(_sap->state != PJ_SAP_BND) \
460 RLOG0(L_ERROR,"Sap State Invalid."); \
461 pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT, \
462 LCM_CAUSE_INV_STATE, 0, 0, 0); \
466 #else /* ERRCLASS & ERRCLS_INT_PAR */
467 #define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret) \
469 /* SAP state validation */ \
470 if(_sap->state != PJ_SAP_BND) \
472 RLOG0(L_ERROR,"Sap State Invalid."); \
473 pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT, \
474 LCM_CAUSE_INV_STATE, 0, 0, 0); \
478 #endif /* ERRCLASS & ERRCLS_INT_PAR */
479 #else /* LTE_L2_MEAS */
480 #if (ERRCLASS & ERRCLS_INT_PAR)
481 #define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret) \
483 if (_chkSpId != _sap->spId) \
485 RLOG0(L_ERROR,"Sap Id Validation Failed."); \
488 /* SAP state validation */ \
489 if(_sap->state != PJ_SAP_BND) \
491 RLOG0(L_ERROR,"Sap State Invalid."); \
492 pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT, \
493 LCM_CAUSE_INV_STATE, 0, 0); \
497 #else /* ERRCLASS & ERRCLS_INT_PAR */
498 #define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret) \
500 /* SAP state validation */ \
501 if(_sap->state != PJ_SAP_BND) \
503 RLOG0(L_ERROR,"Sap State Invalid."); \
504 pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT, \
505 LCM_CAUSE_INV_STATE, 0, 0); \
509 #endif /* ERRCLASS & ERRCLS_INT_PAR */
510 #endif/* LTE_L2_MEAS */
513 #define PJ_FREE_FLAT_BUF(_cb, _buf) \
515 if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP)) \
517 (Void) SPutSBufDpdk((Data *) (_buf)->startAddr); \
520 #else /* TENB_DPDK_BUF */
523 #define PJ_FREE_FLAT_BUF(_cb, _buf) \
525 if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP)) \
527 (Void) SPutSBufWls(_cb->init.region, _cb->init.pool, \
528 (Data *) (_buf)->startAddr, (Size)(2048)); \
532 #ifdef FLAT_BUFFER_OPT
533 #define PJ_FREE_FLAT_BUF(_cb, _buf) \
535 if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP))\
537 (Void) SPutStaticBuffer(_cb->init.region, _cb->init.pool, \
538 (Data *) (_buf)->startAddr, (Size)((_buf)->ptr - (_buf)->startAddr + (_buf)->len) , 0); \
541 #endif /* FLAT_BUFFER_OPT */
542 #endif /* INTEL_WLS */
543 #endif /* TENB_DPDK_BUF */
546 #define PJ_FREE_SHRABL_BUF(_cb,_buf, _size) \
550 (Void) SPutStaticBuffer(_cb->init.region, _cb->init.pool, \
551 (Data *) _buf, (Size) _size, 0); \
556 #define PJ_ALLOC_SHRABL_BUF(_cb,_buf, _size) \
558 if (SGetStaticBuffer(_cb->init.region, _cb->init.pool, (Data **)&_buf, \
559 (Size) _size, 0) == ROK) \
561 cmMemset((U8 *)(_buf), 0, _size); \
569 #define PJ_ALLOC_SHRABL_BUF_WM(_cb,_buf, _size) \
571 SGetStaticBuffer(_cb->init.region, _cb->init.pool, (Data **)&_buf, \
575 #ifndef XEON_SPECIFIC_CHANGES
576 #define PJ_FREE_SHRABL_BUF_PST(_region, _pool, _buf, _size) \
580 (Void) SPutStaticBuffer(_region, _pool, \
581 (Data *) _buf, (Size) _size, 0); \
586 #define PJ_FREE_SHRABL_BUF_PST(_region, _pool, _buf, _size) \
590 (Void) SPutSBuf(_region, _pool, \
591 (Data *) _buf, (Size) _size); \
597 #define PJ_ALLOC_SHRABL_BUF_PST(_region, _pool, _buf, _size) \
599 SGetStaticBuffer(_region, _pool, (Data **)&_buf, \
603 #ifndef XEON_SPECIFIC_CHANGES
604 #define PJ_ALLOC_BUF_SHRABL(_pst, _buf, _size, _ret) \
606 if(SGetStaticBuffer(_pst.region, _pst.pool, (Data **)&_buf, \
607 (Size) _size, 0) != ROK) \
613 #define PJ_ALLOC_BUF_SHRABL(_pst, _buf, _size, _ret) \
615 if(SGetSBuf(_pst.region, _pst.pool, (Data **)&_buf, \
616 (Size) _size) != ROK) \
623 #define PJ_PJDBM_CREATE_RBCB(_rbCb,_rbCbLst, _rbId, _rbType) \
625 /* Allocate memory for rbCb */ \
626 PJ_ALLOC(_rbCb, sizeof(RbCb)); \
628 if ( rbCb != NULLP) \
630 _rbCbLst[_rbId] = (_rbCb); \
631 _rbCb->kwRbCb.rlcId.rbId = _rbId; \
635 /* Macros for configuration module */
636 #define PJ_CFG_FILL_CFG_CFM(_entCfm, _rbId, _rbType, _status, _reason) \
638 _entCfm->rbId = _rbId; \
639 _entCfm->rbType = _rbType; \
640 _entCfm->status = _status; \
641 _entCfm->reason = _reason; \
644 #define PJ_CFG_FILL_SECCFG_CFM(_entCfm, _ueId, _cellId, _transId, _status, _reason) \
646 _entCfm->ueId = _ueId; \
647 _entCfm->cellId = _cellId; \
648 _entCfm->transId = _transId; \
649 _entCfm->status = _status; \
650 _entCfm->reason = _reason; \
653 #define PJ_CFG_FILL_SDUSTA_CFM(_entCfm, _ueId, _cellId, _transId, _status, _reason) \
655 _entCfm->ueId = _ueId; \
656 _entCfm->cellId = _cellId; \
657 _entCfm->transId = _transId; \
658 _entCfm->status = _status; \
659 _entCfm->reason = _reason; \
662 #define PJ_CFG_FILL_REESTREQ_CFM(_entCfm, _ueId, _cellId, _transId, _status) \
664 _entCfm->ueId = _ueId; \
665 _entCfm->cellId = _cellId; \
666 _entCfm->transId = _transId; \
667 _entCfm->status = _status; \
670 #define PJ_UPD_COUNT(_pjRbCb, _sn, _txHfn, _count) \
672 _count = _txHfn << (_pjRbCb->snLen); \
675 #define PJ_ADD_PST_MSG(_pdu, _hdr, _size, _ret) \
679 _bytes = _size - 1; \
680 while (_bytes >= 0 ) \
682 _liByte = (U8) (_hdr >> (8*_bytes)); \
683 _ret = SAddPstMsg((Data )_liByte, _pdu); \
692 #define PJ_RESET_ALL_VAR(_pjRbCb) \
694 _pjRbCb->dlCb.cfmExp = 0; \
695 _pjRbCb->dlCb.count = 0; \
696 _pjRbCb->dlCb.txNext = 0; \
699 #define PJ_ALLOC(_cb, _buf, _size) \
701 if (SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf,\
702 (Size) _size) == ROK) \
704 cmMemset((U8 *)(_buf), 0, _size); \
712 #define PJ_ALLOC_WC(_cb, _buf, _size)\
714 if (SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf,\
715 (Size) _size) != ROK) \
722 #define PJ_FREE_BUF(_buf) \
731 #define PJ_FREE(_cb, _buf, _size) \
735 (Void) SPutSBuf(_cb->init.region, _cb->init.pool, \
736 (Data *) _buf, (Size) _size); \
741 #define PJ_PST_FREE(_region, _pool, _buf, _size) \
745 (Void) SPutSBuf(_region, _pool, \
746 (Data *) _buf, (Size) _size); \
751 #define PJ_MEM_CPY(_dst, _src, _size) \
753 cmMemcpy((U8*)_dst, (U8 *)_src, _size); \
756 #define PJ_DLM_UPD_VAR(_pjRbCb, _count) \
760 _dlCb = &_pjRbCb->dlCb; \
761 _count = _dlCb->txNext; \
762 if ( (++_dlCb->txNext) == 0xFFFFFFFF) \
767 #define PJ_DLM_GET_SN(_pjRbCb, _count,_sn) \
769 _sn = (_count % ( _pjRbCb->maxTxSn)); \
773 #define PJ_FILL_CFM_OK(_cb,_pjRbCb, _fms, _datCfm) \
775 U32 _startCount = _pjRbCb->dlCb.cfmExp; \
776 U32 _stopCount = _pjRbCb->dlCb.cfmExp; \
778 _ent = (PjTxEnt *)pjDbmGetTxEntSn(_cb, &(_pjRbCb->dlCb.txBuf), _fms); \
779 if ( _ent != NULLP ) \
781 _stopCount = _ent->count; \
782 _pjRbCb->dlCb.cfmExp = _ent->count; \
783 _pjRbCb->dlCb.nxtToSub = _ent->count; \
785 while ( _startCount < _stopCount ) \
787 _ent = (PjTxEnt *)pjDbmGetTxEnt(_cb, &(_pjRbCb->dlCb.txBuf), _startCount);\
788 if ( _ent != NULLP ) \
790 if ( _pjRbCb->dlCb.cfmReqd) \
792 _datCfm->cfmSta[_datCfm->numSdus].sduId = _ent->sduId;\
793 _datCfm->cfmSta[_datCfm->numSdus].status = PJ_CFM_OK;\
794 _datCfm->numSdus++; \
796 pjDbmDelTxEnt(_cb, &(pjRbCb->dlCb.txBuf), _ent->count);\
802 #define PJ_UPD_CFM_EXP(_cb,_dlCb) \
804 U32 _curCount = _dlCb->count; \
805 U32 _count = _dlCb->cfmExp; \
806 PjTxEnt *_txEnt = NULLP; \
807 while ( _count <= _curCount ) \
809 _txEnt = (PjTxEnt *)pjDbmGetTxEnt(_cb,&(_dlCb->txBuf), _count);\
810 if ( _txEnt != NULLP ) \
816 _dlCb->cfmExp = _count; \
819 #define PJ_UPD_DL_VAR(_cb, _pjRbCb, _curCnt) \
821 U32 _count = _curCnt + 1; \
822 if ( _pjRbCb->dlCb.nxtToSub == _curCnt ) \
824 _pjRbCb->dlCb.nxtToSub = _count; \
826 if ( _pjRbCb->dlCb.cfmExp == _curCnt ) \
828 _pjRbCb->dlCb.cfmExp = _count; \
832 #define PJ_CREATE_NEW_LIST(_cb,_pjRbCb, _tmpTxBuf, _ret) \
834 _tmpTxBuf.datQ = _pjRbCb->dlCb.txBuf.datQ; \
835 _tmpTxBuf.numEntries = pjRbCb->dlCb.txBuf.numEntries; \
836 _tmpTxBuf.numBins = pjRbCb->dlCb.txBuf.numBins; \
837 _tmpTxBuf.sduSubmitQ = pjRbCb->dlCb.txBuf.sduSubmitQ; \
838 pjDbmDlBufInit(_cb,&pjRbCb->dlCb.txBuf,_cb->pjGenCfg.nmbDlBins);\
839 if ( _pjRbCb->dlCb.txBuf.datQ == NULLP ) \
841 RLOG0(L_ERROR,"PJ_CREATE_NEW_LIST: PJ_ALLOC Failed."); \
846 #define PJ_SND_ROHC_FDB(_cb,_pjRbCb, _rohcFdbPdu, _ret) \
850 _hdr |= PJ_ROHC_FEEDBACK_HDR; \
851 _ret = SAddPreMsg((Data) _hdr, _rohcFdbPdu); \
854 RLOG0(L_ERROR,"PJ_SND__ROHC_FDB: SAddPreMsg failed for pdu ");\
855 PJ_FREE_BUF(_rohcFdbPdu); \
858 if ( _pjRbCb->mode == PJ_DRB_UM ) \
860 _count = _pjRbCb->dlCb.nxtToSub - 1; \
864 _count = _pjRbCb->dlCb.cfmExp - 1; \
868 pjDlmSendDatReq(_cb, _pjRbCb, _count, _rohcFdbPdu); \
872 #define PJ_MAX_HASH_BINS 255
874 /* Defines used in gp_pj_dbm.c */
875 #define PJ_HASH_FN(_buf, _cnt) (_cnt % PJ_MAX_HASH_BINS)
877 /* Defines used in gp_pj_ulm.c */
878 #define MAX_BMAP_SIZE 2048
879 #define PJ_WINSIZE(_snLen) (1 << (_snLen - 1))
880 #define PJ_MAX_HFN(_snLen) ((1 << (32 - _snLen)) - 1)
881 #define PJ_U16_BIT_SIZE 16
882 #define PJ_BYTE_SIZE 8
883 //#define PJ_SRB_SN_LEN 12
884 #define PJ_SRB_SN_LEN 12
885 #define PJ_DRBAM_SN_LEN 12
886 #define PJ_TYPE_DRB_DATA 0x80
887 #define PJ_TYPE_STATUS_REPORT 0x00
888 #define PJ_TYPE_ROHC_FEEDBACK 0x01
889 #define PJ_PDU_BIT_MASK 0x70
890 #define PJ_12_BIT_SN_MSB_MASK 0x0F
891 #define PJ_18_BIT_SN_MSB_MASK 0x03
892 #define PJ_CPDU_RES_VAL_MASK 0x0F
893 #define PJ_MACI_LEN 4
895 #define PJ_RDY_TO_DCIPHER 1
896 #define PJ_SENT_TO_DCIPHER 2
897 #define PJ_RDY_TO_INTVER 3
898 #define PJ_SENT_TO_INTVER 4
899 #define PJ_RDY_TO_DCOMP 5
900 #define PJ_SENT_TO_DCOMP 6
901 #define PJ_RDY_TO_SUBMIT 7
902 #define PJ_RX_ENT_TO_DEL 8
903 #define PJ_RX_INTVER_FAIL 9
905 #define PJ_STATE_NORMAL 1
906 #define PJ_STATE_REEST 2
907 #define PJ_STATE_REEST_HO 3
908 #define PJ_STATE_HO 4
909 #define PJ_TMR_ULM_OBD 10
911 /* Defines used in gp_pj_utl.c */
912 #define PJ_LIB_COMP_BIT_MASK 0x00000001
913 #define PJ_LIB_INT_BIT_MASK 0x00000002
914 #define PJ_LIB_CP_CIP_BIT_MASK 0x00000004
915 #define PJ_LIB_UP_CIP_BIT_MASK 0x00000008
917 #define PJ_MAX_SDU_IN_DAT_FWD_IND 5
918 /* Defines used for multi cfg confirms */
919 #define PJ_MAX_ASYNC_CFM 2
921 #define PJ_SEC_ASYNC_CFM 0x01
922 #define PJ_CFG_ASYNC_CFM 0x02
923 #define PJ_CFG_REEST_ASYNC_CFM 0x04
924 #define PJ_CFG_UEDEL_ASYNC_CFM 0x08
925 #define PJ_REEST_ASYNC_CFM 0x10
927 #define PJ_SEC_INIT_CFM 1
928 #define PJ_CMP_INIT_CFM 2
930 #define PJ_GET_MEM_REGION(_cb) (_cb->init.region)
932 #define PJ_GET_MEM_POOL(_cb) (_cb->init.pool)
934 #define PJ_GET_MEM_POOL_ADDRESS(_cb) (&_cb->init.pool)
936 #define PJ_GET_DBG_MASK(_cb) (_cb->init.dbgMask)
938 /* Memset to value */
939 #define PJ_MEM_SET(_arg, _val, _size) \
941 cmMemset((U8 *)_arg, (U8)_val, _size); \
944 /* Set the unsolictated Status flag */
945 #define PJ_SET_USTA_FLAG(_cb, _value) \
947 _cb->init.usta = _value; \
950 #define PJ_DATA_FWD_PKT 1
951 #define PJ_DATA_NRM_PKT 2
953 #define PJ_CHK_RESTART_OBD_TIMER(_cb,_ueCb, _cfgTxId) \
956 if(_ueCb->libInfo.crntTmrTxId == _cfgTxId) \
958 pjStopTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR); \
961 if(pjChkTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR) == FALSE) \
963 for(_idx = 0; _idx < (PJ_MAX_ASYNC_CFM - 1) ; _idx++) \
965 _ueCb->libInfo.crntTmrTxId = \
966 (U16)((_ueCb->libInfo.crntTmrTxId + 1) % PJ_MAX_ASYNC_CFM); \
967 if((_ueCb->libInfo.asyncCfm[_ueCb->libInfo.crntTmrTxId] != NULLP) && \
968 (_ueCb->libInfo.asyncCfm[_ueCb->libInfo.crntTmrTxId]->startTmr \
971 pjStartTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR); \
978 #define PJ_CLEAN_AND_UPD_ASYNCINFO(_cb,_ueCb, _txIdx) \
980 PJ_FREE(_cb,_ueCb->libInfo.asyncCfm[_txIdx], sizeof(PjAsyncCfm)); \
981 _ueCb->libInfo.asyncCfm[_txIdx]=NULLP; \
982 if(_ueCb->libInfo.nxtAvlbTxId == PJ_MAX_ASYNC_CFM) \
984 _ueCb->libInfo.nxtAvlbTxId = _txIdx; \
988 #define PJ_FILL_TIMEOUT_CFG_CFM_INFO(_cb,_cfgCfm, _asyncCfm) \
991 PJ_ALLOC(_cb,_cfgCfm, sizeof(CpjCfgCfmInfo)); \
992 if (_cfgCfm != NULLP) \
994 for ( _idx = 0; _idx < _asyncCfm->numEnt ; _idx++) \
996 if ( _asyncCfm->cmpInitBitMask & \
997 (1 << (_asyncCfm->cfmEnt[_idx].rbId - 1))) \
999 _cfgCfm->cfmEnt[_idx].status = CPJ_CFG_CFM_NOK; \
1000 _cfgCfm->cfmEnt[_idx].reason = CPJ_CFG_REAS_OBD_TIMEOUT; \
1004 _cfgCfm->cfmEnt[_idx].status = _asyncCfm->cfmEnt[_idx].status;\
1005 _cfgCfm->cfmEnt[_idx].reason = _asyncCfm->cfmEnt[_idx].reason;\
1007 _cfgCfm->cfmEnt[_idx].rbId = _asyncCfm->cfmEnt[_idx].rbId; \
1008 _cfgCfm->cfmEnt[_idx].rbType = _asyncCfm->cfmEnt[_idx].rbType; \
1010 _cfgCfm->ueId = _asyncCfm->ueId; \
1011 _cfgCfm->cellId = _asyncCfm->cellId; \
1012 _cfgCfm->transId = _asyncCfm->transId; \
1013 _cfgCfm->numEnt = _asyncCfm->numEnt; \
1018 /* In the case when all the elements in the reception buffer have already
1019 * been sent to the dcomp unit or sent up, our nxtSubDcomp will be pointing to
1020 * NEXT_PDCP_RX_SN. So if there is a jump, this has to be updated accordingly */
1021 #define PJ_ULM_UPD_NXT2DCOMP(_ulCb, _snLen, _rcvdCount, _oldRxCnt) \
1023 if(_oldRxCnt == _ulCb->nxtSubDeCmp) \
1025 _ulCb->nxtSubCnt = _rcvdCount; \
1028 #else /* !PJ_SEC_ASYNC */
1029 #define PJ_ULM_UPD_NXT2DCOMP(_ulCb, _snLen, _sn, _oldRxCnt)
1030 #endif /* PJ_SEC_ASYNC */
1032 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
1033 /* There can be a case where the first PDU that you receive *
1034 * does not match with the NEXT_PDCP_RX_SN. If nxtSubCnt is also
1035 * pointing to NETX_PDCP_RX_SN, it has to be updated. */
1036 #define PJ_ULM_UPD_NXT2SUB(_ulCb, _cnt) \
1038 if(_ulCb->recBuf.numEntries == 0) \
1040 _ulCb->nxtSubCnt = _cnt; \
1041 _ulCb->nxtSubDeCmp = _cnt; \
1044 #define PJ_INC_OBD_COUNT(_pjRbCb, _count) \
1046 if(_pjRbCb->state == PJ_STATE_REEST || \
1047 _pjRbCb->state == PJ_STATE_REEST_HO) \
1049 _pjRbCb->ulCb.obdCnt ++; \
1053 /* Notes: This will be called only for DRBs */
1054 #define PJ_DEC_OBD_COUNT(_cb, _pjRbCb, _count) \
1056 if(_pjRbCb->state == PJ_STATE_REEST || \
1057 _pjRbCb->state == PJ_STATE_REEST_HO) \
1059 if((_count >= _pjRbCb->ulCb.firstReEstCnt)&& \
1060 (_pjRbCb->mode = PJ_DRB_AM)) \
1062 _pjRbCb->ulCb.obdCnt --; \
1066 #else /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
1068 #define PJ_ULM_UPD_NXT2SUB(_ulCb, _cnt)
1069 #define PJ_INC_OBD_COUNT(_pjRbCb, _count)
1070 #define PJ_DEC_OBD_COUNT(_cb,_pjRbCb, _count)
1071 #endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
1074 #define PJ_INC_SN(_sn, _snLen) ((++_sn) % (1 << _snLen)) \
1076 #define PJ_GET_SN_HFN(_count, _snLen, _sn, _hfn) \
1078 _sn = (_count % (1 << _snLen)); \
1079 _hfn = (_count >> _snLen); \
1082 #define PJ_GET_HFN(_count,_snLen,_hfn)\
1084 _hfn = (_count >> _snLen);\
1086 #define PJ_GET_SN(_count, _snLen, _sn) (_sn = _count % (1 << _snLen));
1088 #define PJ_ULM_REEST_DRB_AM(_pjRbCb) \
1090 _pjRbCb->frstReEstCnt = _pjRbCb->rxDeliv; \
1091 _pjRbCb->obdCnt = 0; \
1096 /* kw005.201,replaced macro with function */
1097 #define PJ_SND_PJU_STA_IND(_cb,_pjRbCb, _rxEnt) \
1099 CmLtePdcpId _pdcpId; \
1100 Buffer *_mBuf = NULLP; \
1101 PjuStaIndInfo _staInd; \
1102 PjPjuSapCb *_pjuSap; \
1104 if (_pjRbCb->rbType == PJ_SRB) \
1105 _pjuSap = &(_cb->u.ulCb->pjuSap[PJ_SRB_SAP]); \
1107 _pjuSap = &(_cb->u.ulCb->pjuSap[PJ_DRB_SAP]); \
1111 _pdcpId.ueId = _pjRbCb->ueCb->key.ueId; \
1112 _pdcpId.cellId = _pjRbCb->ueCb->key.cellId; \
1113 _pdcpId.rbId = _pjRbCb->rbId; \
1114 _pdcpId.rbType = _pjRbCb->rbType; \
1116 switch (_rxEnt->state) \
1118 case PJ_RDY_TO_DCIPHER: \
1119 case PJ_SENT_TO_DCIPHER: \
1121 _staInd.cause = PJU_DCIP_FAILED; \
1124 case PJ_RDY_TO_INTVER: \
1125 case PJ_SENT_TO_INTVER: \
1127 _staInd.cause = PJU_INTVER_FAILED; \
1128 _mBuf = _rxEnt->mBuf; \
1129 _rxEnt->mBuf = NULLP; \
1132 case PJ_RDY_TO_DCOMP: \
1133 case PJ_SENT_TO_DCOMP: \
1135 _staInd.cause = PJU_DCOMP_FAILED; \
1136 if(_pjRbCb->ulCb.discReqd == FALSE) \
1138 _mBuf = _rxEnt->mBuf; \
1139 _rxEnt->mBuf = NULLP; \
1146 PjUiPjuStaInd(&(_pjuSap->pst), _pjuSap->suId, \
1147 &_pdcpId, &_staInd, _mBuf); \
1152 #define PJ_SND_PJU_DAT_IND(_cb,_pjRbCb, _rxEnt) \
1154 CmLtePdcpId _pdcpId; \
1156 PjPjuSapCb *_pjuSap; \
1158 if (_pjRbCb->rbType == PJ_SRB) \
1160 _pjuSap = &(_cb->u.ulCb->pjuSap[PJ_SRB_SAP]); \
1164 PJ_UPD_L2_ULLOSS_CNTRS(_cb,_rxEnt->count, _pjRbCb) \
1165 _pjuSap = &(_cb->u.ulCb->pjuSap[PJ_DRB_SAP]); \
1168 _pdcpId.ueId = _pjRbCb->ueCb->key.ueId; \
1169 _pdcpId.cellId = _pjRbCb->ueCb->key.cellId; \
1170 _pdcpId.rbType = _pjRbCb->rbType; \
1171 _pdcpId.rbId = _pjRbCb->rbId; \
1172 _mBuf = _rxEnt->mBuf; \
1173 _rxEnt->mBuf = NULLP; \
1175 /* If trace flag is enabled send the trace indication */\
1176 if(_cb->init.trc == TRUE) \
1178 /* Populate the trace params */ \
1179 pjLmmSendTrc(_cb,EVTPJUDATIND, _mBuf); \
1182 PjUiPjuDatInd(&(_pjuSap->pst), _pjuSap->suId, \
1184 PJ_STS_INC_PJU_CNT(_cb,_pjRbCb->rbType, txSdus) \
1188 #define PJ_FILL_REEST_CFM_INFO(_reEstCfm, _asyncCfm, _status) \
1190 _reEstCfm->ueId = _asyncCfm->ueId; \
1191 _reEstCfm->cellId = _asyncCfm->cellId; \
1192 _reEstCfm->transId = _asyncCfm->transId; \
1193 _reEstCfm->status = _status; \
1196 #define PJ_FILL_SEC_CFM_INFO(_secCfgCfm, _asyncCfm) \
1198 _secCfgCfm->ueId = _asyncCfm->ueId; \
1199 _secCfgCfm->cellId = _asyncCfm->cellId; \
1200 _secCfgCfm->transId = _asyncCfm->transId; \
1201 _secCfgCfm->status = UDX_CFG_CFM_OK; \
1202 _secCfgCfm->reason = UDX_CFG_REAS_NONE; \
1205 #define PJ_FILL_REEST_CFG_CFM_INFO(_cfmInfo, _asyncCfm) \
1208 for (_idx = 0; _idx < _asyncCfm->numEnt ; _idx++) \
1210 if (_asyncCfm->cfmEnt[_idx].cfgType == CPJ_CFG_REESTABLISH) \
1212 _cfmInfo->cfmEnt[_idx].status = CPJ_CFG_CFM_OK; \
1213 _cfmInfo->cfmEnt[_idx].reason = LCM_REASON_NOT_APPL; \
1217 _cfmInfo->cfmEnt[_idx].status = _asyncCfm->cfmEnt[_idx].status;\
1218 _cfmInfo->cfmEnt[_idx].reason = _asyncCfm->cfmEnt[_idx].reason;\
1220 _cfmInfo->cfmEnt[_idx].rbId = _asyncCfm->cfmEnt[_idx].rbId; \
1221 _cfmInfo->cfmEnt[_idx].rbType = _asyncCfm->cfmEnt[_idx].rbType; \
1223 _cfmInfo->ueId = _asyncCfm->ueId; \
1224 _cfmInfo->cellId = _asyncCfm->cellId; \
1225 _cfmInfo->transId = _asyncCfm->transId; \
1226 _cfmInfo->numEnt = _asyncCfm->numEnt; \
1230 #define PJ_PERFORM_ERR_UPDATES(_cb, _pjRbCb, _count) \
1234 _upCb = &_pjRbCb->ulCb; \
1235 if(_upCb->recBuf.numEntries != 0) \
1237 PJ_CALC_NXT2SUB(_cb, _upCb); \
1239 PJ_CHK_RDY_TO_DELIVER(_cb, _pjRbCb); \
1243 #define PJ_CALC_NXT2SUB(_cb, __ulCb) \
1247 _nxtToSub = __ulCb->nxtSubCnt; \
1248 if(__ulCb->recBuf.numEntries != 0) \
1251 while( (_rxEnt = (PjRxEnt *)pjDbmGetRxEnt(_cb, &ulCb->recBuf, _nxtToSub)) != NULLP)\
1253 __ulCb->nxtSubCnt++; \
1256 __ulCb->nxtSubCnt = _nxtToSub; \
1260 #define PJ_CHK_RDY_TO_DELIVER(_cb, _pjRbCb) \
1265 _ulCb = &_pjRbCb->ulCb; \
1266 if(_ulCb->recBuf.numEntries == 0) \
1268 if((_pjRbCb->rbType == PJ_DRB)&& \
1269 (_pjRbCb->state != PJ_STATE_NORMAL)) \
1271 if((_ulCb->transCmp) \
1272 && (_ulCb->obdCnt == 0) \
1275 pjUlmReEstDrbAm(_cb, _pjRbCb); \
1281 _rxEnt = (PjRxEnt *)pjDbmGetRxEnt(_cb, &_ulCb->recBuf, ulCb->nxtSubCnt);\
1282 if( _rxEnt && _rxEnt->state == PJ_RDY_TO_SUBMIT) \
1284 if(_pjRbCb->rbType == PJ_SRB) \
1286 pjUlmDeliverSrb(_cb, _pjRbCb, _rxEnt); \
1290 if(_pjRbCb->mode == PJ_DRB_UM) \
1292 pjUlmDeliverDrbUm(_cb, _pjRbCb, _rxEnt); \
1296 pjUlmDeliverDrbAm(_cb, _pjRbCb, _rxEnt); \
1303 #define PJ_GET_COUNT(_count, _snLen, _sn, _hfn) \
1305 _count = ((_hfn << _snLen) | _sn); \
1309 #define PJ_CALC_RCVD_HFN(_rcvdSn,_snLen,_rxDeliv,_rcvdHfn) \
1314 PJ_GET_SN_HFN(_rxDeliv,_snLen,_sn,_hfn); \
1315 _winSize = _sn - PJ_WINSIZE(_snLen); \
1316 if((_winSize > 0) && (_rcvdSn < _winSize)) \
1318 _rcvdHfn = _hfn + 1; \
1320 else if(_rcvdSn >= (_sn + PJ_WINSIZE(_snLen))) \
1322 _rcvdHfn = _hfn - 1; \
1332 #define PJ_ULM_DRBUM_REEST(_cb,_pjRbCb) \
1334 _pjRbCb->ulCb.rxNext = 0; \
1335 _pjRbCb->ulCb.rxDeliv = 0; \
1336 pjUtlUlHdlRbReEstComplete(_cb, _pjRbCb); \
1339 #define PJ_ULM_DRBUM_REEST(_cb,_pjRbCb) \
1341 _pjRbCb->ulCb.rxNext = 0; \
1342 _pjRbCb->ulCb.rxDeliv = 0; \
1343 pjUtlUlHdlRbReEstComplete(_cb, _pjRbCb); \
1348 /* Update state and call the respective delivery
1350 #define PJ_ULM_DELIVER_DRB(_cb,_pjRbCb, _rxEnt) \
1352 if(_pjRbCb->mode == PJ_DRB_AM) \
1354 pjUlmDeliverDrbAm(_cb,_pjRbCb, _rxEnt); \
1358 pjUlmDeliverDrbUm(_cb,_pjRbCb, _rxEnt); \
1362 /*update the state variable RX_NEXT */
1363 #define PJ_ULM_UPDATE_RX_NEXT(_pjRbCb,_rxEnt) \
1366 U32 _diffRcvdCount;\
1367 _diffRxNext = ((_pjRbCb->ulCb.rxNext - _pjRbCb->ulCb.rxDeliv) % PJ_WINSIZE(_pjRbCb->snLen));\
1368 _diffRcvdCount = ((_rxEnt->count - _pjRbCb->ulCb.rxDeliv) % PJ_WINSIZE(_pjRbCb->snLen));\
1369 if(_diffRcvdCount >= _diffRxNext) \
1371 _pjRbCb->ulCb.rxNext = _rxEnt->count + 1; \
1374 /* Update state and call the respective delivery
1376 #define PJ_ULM_DELIVER_PDU(_cb,_pjRbCb, _rxEnt) \
1379 if(_pjRbCb->rbType == PJ_SRB) \
1381 pjUlmDeliverSrb(_cb,_pjRbCb, _rxEnt); \
1385 PJ_ULM_DELIVER_DRB(_cb,_pjRbCb, _rxEnt); \
1389 /* There is case that all PDUs in the recv Buf can be back from off board
1390 * but not sent up. In that case, though the the recvBuf has entries the
1391 * obd timer should not be restarted. This works with the PJ_ULM_GET_DRBAM_SUBCNT
1392 * macro to acheive this. */
1393 #define PJ_DRBAM_ALL_PDU_RECVD(_pjRbCb)\
1394 ((pjRbCb->rbType == PJ_DRB) && \
1395 (pjRbCb->mode == PJ_DRB_AM) && \
1396 ((ulCb->rxDeliv - 1) == ulCb->obdPdu)) \
1399 #define PJ_ULM_GET_DRBAM_SUBCNT(_pjUlRbCb, _nxtSubCnt, _pjCb) \
1401 U32 _count = _pjUlRbCb->ulCb.rxDeliv - 1; \
1402 U32 _nxtRxCnt = (_pjUlRbCb->ulCb.rxNext) ;\
1403 PjRxEnt *_rxEnt = NULLP; \
1404 _nxtSubCnt = _count; \
1405 if(((_pjUlRbCb->state != PJ_STATE_NORMAL) && \
1406 (_pjUlRbCb->ulCb.obdCnt != 0)) || \
1407 ((_pjUlRbCb->state == PJ_STATE_NORMAL) && \
1408 (_pjUlRbCb->ulCb.recBuf.numEntries != 0))) \
1411 for(;_count < _nxtRxCnt; _count ++) \
1413 _rxEnt = (PjRxEnt *)pjDbmGetRxEnt(_pjCb, &_pjUlRbCb->ulCb.recBuf, _count); \
1414 if((_rxEnt != NULLP) && (_rxEnt->state != PJ_RDY_TO_SUBMIT)) \
1416 _nxtSubCnt = _count; \
1424 #define PJ_ULM_GET_SUBCNT(_pjUlRbCb, _subPdu, _pjCb) \
1426 if((_pjUlRbCb->rbType == PJ_DRB) && (_pjUlRbCb->mode == PJ_DRB_AM))\
1428 PJ_ULM_GET_DRBAM_SUBCNT(_pjUlRbCb, _subPdu, _pjCb); \
1432 _subPdu = _pjUlRbCb->ulCb.nxtSubCnt; \
1437 #define PJ_STS_INC_GEN_CNT(_cb, _cntr) \
1439 _cb->pjGenSts._cntr++; \
1442 #define PJ_STS_INC_PJU_CNT(_cb, _rbType, _cntr) \
1444 if (_rbType == PJ_SRB) \
1445 _cb->u.ulCb->pjuSap[PJ_SRB_SAP].sts._cntr++; \
1447 _cb->u.ulCb->pjuSap[PJ_DRB_SAP].sts._cntr++; \
1450 #define PJ_PK_U8(_msg, _val, _ret) \
1452 (_ret) = SAddPstMsg((Data) (_val), (_msg)); \
1455 #define PJ_PK_U16(_msg, _val, _ret) \
1457 PJ_PK_U8(_msg, (U8) GetHiByte(_val), _ret) \
1458 if ((_ret) == ROK) \
1459 PJ_PK_U8(_msg, (U8) GetLoByte(_val), _ret) \
1462 #define PJ_PK_U32(_msg, _val, _ret) \
1465 _tmp16 = (U16) GetHiWord(_val); \
1466 PJ_PK_U16(_msg, _tmp16, _ret) \
1467 if ((_ret) == ROK) \
1469 _tmp16 = (U16) GetLoWord(_val); \
1470 PJ_PK_U16(_msg, _tmp16, _ret) \
1474 #define PJ_PACK_MACI(_mBuf, _macI) \
1478 _tmp = (U16) GetHiWord(_macI); \
1479 _pkArray[0] = (Data) GetHiByte(_tmp); \
1480 _pkArray[1] = (Data) GetLoByte(_tmp); \
1481 _tmp = (U16) GetLoWord(_macI); \
1482 _pkArray[2] = (Data) GetHiByte(_tmp); \
1483 _pkArray[3] = (Data) GetLoByte(_tmp); \
1484 SAddPstMsgMult(_pkArray, (MsgLen) 4, _mBuf); \
1487 #define PJ_UNPK_MACI(_mBuf, _macI) \
1490 Data _unPkArray[4] = {0}; \
1491 SRemPstMsgMult(_unPkArray, (MsgLen)4, _mBuf); \
1492 _tmp16 = (U16) PutHiByte(_tmp16, (U8) _unPkArray[3]); \
1493 _tmp16 = (U16) PutLoByte(_tmp16, (U8) _unPkArray[2]); \
1494 _macI = (U32) PutHiWord(_macI, (U16) _tmp16); \
1495 _tmp16 = (U16) PutHiByte(_tmp16, (U8) _unPkArray[1]); \
1496 _tmp16 = (U16) PutLoByte(_tmp16, (U8) _unPkArray[0]); \
1497 _macI = (U32) PutLoWord(_macI, (U16) _tmp16); \
1500 /*@def PJ_SEC_FILL_COUNT
1502 * This macro fills the COUNT value. COUNT value is composed
1503 * of a HFN and the PDCP SN. Refer to 36.323 for details.
1505 *@param[in]_secInp Count Value as Input
1506 *@param[in]_pSecInfo Variable into which count value needs to be populated
1509 #define PJ_SEC_FILL_COUNT(_secInp, _pSecInfo) \
1512 _tmp = (U16) GetHiWord(_secInp); \
1513 _pSecInfo[0] = (Data) GetHiByte(_tmp); \
1514 _pSecInfo[1] = (Data) GetLoByte(_tmp); \
1515 _tmp = (U16) GetLoWord(_secInp); \
1516 _pSecInfo[2] = (Data) GetHiByte(_tmp); \
1517 _pSecInfo[3] = (Data) GetLoByte(_tmp); \
1520 /*@def PJ_SEC_FILL_FRESH
1522 * This macro fills the FRESH value. FRESH [0], . FRESH [3]
1523 * is set as BEARER[0] . BEARER[4] | 0 pow(27). Refer to 33.401 for details.
1525 *@param[in]_fresh Variable into which o/p needs to be set.
1526 *@param[in]_rbId RbId of the RB to be filled in FRESH
1529 #define PJ_SEC_FILL_FRESH(_fresh, _rbId) \
1534 _fresh[3] = _rbId; \
1537 #define PJ_TIME_DIFF(cur,prev) \
1538 (cur<prev ? ((0xffffffff - prev) + cur ): (cur - prev))
1539 #define PJ_MAX_CNT_RB_OVERLOAD 10
1540 #endif /* __PJH__ */
1542 /********************************************************************30**
1545 **********************************************************************/