Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_env.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 PDCP file 
22     
23         Type:     H include file
24   
25         Desc:     This file contain the hash definations for PDCP 
26  
27         File:     pj_env.h
28
29 *********************************************************************21*/
30 /** @file pj_env.h
31 @brief PDCP Hash definitions
32 */
33
34 #ifndef __PJENVT2KH__
35 #define __PJENVT2KH__
36
37 #define PJ_MAX_PDCP_INSTANCES            2 
38 #define PJ_FWD_MAX_SDU_CNT            1 
39
40 #define PJ_ALLOC_BUF(gCb,_buf)                                 \
41 {                                                          \
42    if (SGetMsg(gCb->init.region, gCb->init.pool, (Buffer **)&_buf) != ROK) \
43    {                                                       \
44       (_buf) = NULLP;                                      \
45    }                                                       \
46 }
47
48 #define PJ_CPY_MSG(_cb,_x, _y, _ret)                           \
49    _ret =(SAddMsgRef((_x), PJ_GET_MEM_REGION(_cb), PJ_GET_MEM_POOL(_cb), (_y)))                                                                                         
50
51 #define PJ_SND_CFM(_cb,_pjRbCb, _txEnt, _cause)                \
52 {                                                          \
53    PjuDatCfmInfo *_datCfm;                                 \
54    CmLtePdcpId *_pdcpId;                                   \
55    PjPjuSapCb  *_pjuSap;                                   \
56    if (_pjRbCb->rbType == PJ_SRB)                          \
57       _pjuSap   = &(_cb->u.dlCb->pjuSap[PJ_SRB_SAP]);                  \
58    else                                                    \
59       _pjuSap   = &(_cb->u.dlCb->pjuSap[PJ_DRB_SAP]);                  \
60                                                            \
61    PJ_ALLOC(_cb, _datCfm, sizeof(PjuDatCfmInfo));              \
62    PJ_ALLOC(_cb,_pdcpId, sizeof(CmLtePdcpId));                \
63    if ( _datCfm != NULLP && _pdcpId != NULLP )             \
64    {                                                       \
65       _datCfm->cfmSta[_datCfm->numSdus].sduId = _txEnt->sduId;\
66       _datCfm->cfmSta[_datCfm->numSdus].status = _cause;   \
67       _datCfm->numSdus++;                                  \
68       _pdcpId->rbId   = _pjRbCb->rbId;                     \
69       _pdcpId->rbType = _pjRbCb->rbType;                   \
70       _pdcpId->ueId   = _pjRbCb->ueCb->key.ueId;           \
71       _pdcpId->cellId = _pjRbCb->ueCb->key.cellId;         \
72       PjUiPjuDatCfm(&(_pjuSap->pst), _pjuSap->suId, _pdcpId, _datCfm);\
73    }                                                       \
74    pjDbmDelTxEnt(_cb, &(pjRbCb->dlCb.txBuf), _txEnt->count);   \
75 }
76
77 #define PJ_ADD_PRE_MSG(_pdu, _hdr, _numBytes, _ret)        \
78 {                                                          \
79    Data _liByte;                                           \
80    U16  _bytes;                                            \
81    _bytes = 0;                                             \
82    while (_numBytes > _bytes )                             \
83    {                                                       \
84       _liByte = (U8) (_hdr >> (8*_bytes));                 \
85       _ret = SAddPreMsg((Data )_liByte, _pdu);             \
86       if ( _ret != ROK )                                   \
87       {                                                    \
88          break;                                            \
89       }                                                    \
90       _bytes++;                                            \
91    }                                                       \
92 }
93 #endif /* __PJENVT2KH__ */
94 /********************************************************************30**
95   
96          End of file
97 **********************************************************************/