[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/cp/ps/modem/com/inc/psbuf.h b/cp/ps/modem/com/inc/psbuf.h
new file mode 100755
index 0000000..53a6051
--- /dev/null
+++ b/cp/ps/modem/com/inc/psbuf.h
@@ -0,0 +1,302 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2001,ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ: psbuf.h
+* Îļþ±êʶ:
+* ÄÚÈÝÕªÒª: Êý¾ÝÃæ»º´æÏà¹Ø½á¹¹Ì嶨Òå¡¢ºê¶¨ÒåºÍº¯ÊýÉùÃ÷
+*
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* ---------------------------------------------------------------------
+* 2012/06/15 V1.0 create
+************************************************************************/
+
+#ifndef _PS_BUF_H
+#define _PS_BUF_H
+
+/**************************************************************************
+ * Í·Îļþ°üº¬ *
+ **************************************************************************/
+
+/**************************************************************************
+ È«¾Ö±äÁ¿ÉùÃ÷
+**************************************************************************/
+extern WORD gLinkAlignOffset;
+extern WORD g_l2_wUpLinkSDUNum;
+extern WORD g_l2_wEpdcpPDUNum;
+
+/**************************************************************************
+ PSÊý¾ÝÃæÓÅ»¯Ïà¹Ø
+**************************************************************************/
+/**************************************************************************
+ * Ïà¹Øºê¶¨Òå *
+ **************************************************************************/
+#define Z_LINK_ALIGN_OFFSET gLinkAlignOffset
+/* PSÊý¾ÝÃæ£¬ÉÏÐлº´æÐèÒªÔ¤ÁôÊý¾ÝÇø´óС */
+
+#define Z_UP_PPP_MAX_SIZE (1520 + 100)
+#define Z_UP_IP_MAX_SIZE 1520
+#define LL_MAX_HEADER 48//64
+#define Z_UP_LINK_RESERVE LL_MAX_HEADER
+#define Z_UL_PDU_BUF_SIZE 1600
+/* PSÊý¾ÝÃæ£¬ÉÏÐÐPPPÊý¾Ý°üµÄ×î´óÖµ */
+
+#define Z_DOWN_LINK_RESERVE_IP (LL_MAX_HEADER + 16)
+#define Z_DOWN_LINK_RESERVE_MAC (LL_MAX_HEADER + 14)
+#define Z_DOWN_RLCSDU_MAX_SIZE 1504
+
+/* PSÊý¾ÝÃæ£¬ÏÂÐлº´æÐèÒªÔ¤ÁôÊý¾ÝÇø´óС */
+#define Z_DOWN_LINK_RESERVE (Z_DOWN_LINK_RESERVE_MAC + Z_LINK_ALIGN_OFFSET)
+
+#define Z_DDR_32 0
+#define Z_DDR_64 1
+
+#ifdef _OS_WIN
+/* PSÊý¾ÝÃæ£¬ÉÏ¡¢ÏÂÐлº´æ¿éµÄ¸öÊý */
+#define Z_UP_LINK_SDU_COUNT (1536 + 1792)//g_El2_wUpLinkSDUNum
+#define Z_DOWNLINK_SDU_COUNT 1792
+
+#define Z_LTE_EPDCP_PDU_COUNT 1536
+
+#else
+/*ps buffer memory size provided by product ddr*/
+#define Z_PS_BUFFER_MEM_SIZE DDR_BASE_LEN_PSBUF /* 2.5M */
+
+/* PSÊý¾ÝÃæ£¬ÉÏ¡¢ÏÂÐлº´æ¿éµÄ¸öÊý */
+#define Z_UP_LINK_SDU_COUNT g_l2_wUpLinkSDUNum//520 //1792
+#define Z_DOWNLINK_SDU_COUNT 0
+#define Z_LTE_EPDCP_PDU_COUNT g_l2_wUpLinkSDUNum // 520 //1536
+
+#endif
+
+#define Z_PLAT_DL_RESERVE (Z_DOWN_LINK_RESERVE - 14)
+#define Z_UL_DATA_DESC_SIZE 40
+#define Z_DL_DATA_DESC_SIZE 40
+#define Z_SKB_SHARE_INFO_SIZE 396 //400 //ºêÖµÓÉ 400¸ÄΪ396£¬±£Ö¤psbufµÄdataÓòΪ64×Ö½Ú¶ÔÆë
+
+//DHD°üÍ·×î´óÆ«ÒÆ
+#define Z_UL_DHD_MAX_OFFSET 64
+#define Z_OVERFLUD_SIZE 4
+//ec616000533092
+#define Z_UL_NODE_BUF_SIZE (((DWORD)(Z_UP_LINK_RESERVE + Z_UP_IP_MAX_SIZE + Z_SKB_SHARE_INFO_SIZE + Z_OVERFLUD_SIZE+63) >> 6) << 6)/*4×Ö½Ú»º´æ¸Äд±êÖ¾*/
+#define Z_UL_SDU_BUF_SIZE (Z_UP_LINK_RESERVE + Z_UP_IP_MAX_SIZE)
+//#define Z_DL_NODE_BUF_SIZE (Z_DOWN_LINK_RESERVE_IP + Z_DOWN_RLCSDU_MAX_SIZE + Z_SKB_SHARE_INFO_SIZE + Z_OVERFLUD_SIZE)
+//#define Z_DL_SDU_BUF_SIZE (Z_DOWN_LINK_RESERVE_IP + Z_DOWN_RLCSDU_MAX_SIZE)
+
+/* PSÊý¾ÝÃæ£¬¼ì²é»º´æ¿éÊÇ·ñ±»Öظ´Êͷűêʾ£¬ÄÚ²¿Ê¹Óò»¶ÔÍ⿪·Å */
+#define Z_BUFFER_NOFREED 0xA3A3A3A3//0xFEFEFEFE
+#define Z_BUFFER_FREED 0x00
+#define Z_BUFFER_NOFLUD 0xA3A3A3A3//0xFEFEFEFE
+/**************************************************************************
+ * È«¾Ö½á¹¹ÀàÐÍ *
+ **************************************************************************/
+/* PSÊý¾ÝÃæ£¬ÉÏÐлº´æ¿éµÄ½á¹¹ */
+typedef struct _Z_UpLink_Sdu {
+ T_ZOss_Node tNode;
+ BYTE tDataDescInfo[Z_UL_DATA_DESC_SIZE]; //±£´æTD»òLTEµÄÃèÊöÐÅÏ¢
+ BYTE bCid;
+ BYTE bPid; //ƽ̨ÓÃÓÚ±êʶÊÇ·ñΪTCP ACK°ü
+ BYTE bNsapi;
+ BYTE bAtiBuf;
+ PBYTE pbPdcpPduAddr;
+ WORD wIpPacketLen;
+ WORD wIpPacketOffSet; // ÐèÒª³õʼ»¯
+ BYTE bIsTcpAck;
+ BYTE bPad[3];
+ PBYTE Data;
+ PBYTE tSkbShareInfo;
+ PBYTE pbSkbAddr;
+} T_z_UpLink_Sdu;
+
+/* PSÊý¾ÝÃæ£¬ÏÂÐлº´æ¿éµÄ½á¹¹ */
+typedef struct _Z_DownLink_Sdu {
+ T_ZOss_Node tNode;
+ BYTE tDataDescInfo[Z_DL_DATA_DESC_SIZE]; //±£´æTD»òLTEµÄÃèÊöÐÅÏ¢
+ BYTE bCid;
+ BYTE bPid;
+ BYTE bNsapi;
+ BYTE bRbid;
+ WORD abPadding1[2];/*¶ÔÓ¦ÉÏÐÐpbPdcpPduAddr£¬ÏÂÐд¦Àí²»ÄÜʹÓã¬
+ ÒòÊͷŽڵãʱ²»Çø·ÖÉÏÏÂÐУ¬»á×÷ΪpbPdcpPduAddrµØÖ·½øÐлØÊÕ£¬
+ Èô±»ÉÏÐÐÉêÇëµ½£¬¶Ô¸ÃµØÖ·²Ù×÷ʱ£¬»áÔì³ÉËÀ»ú*/
+ WORD wDataLen;
+ WORD wDataOffSet;
+ WORD abPadding2[2];
+ PBYTE Data;
+ PBYTE tSkbShareInfo;
+ PBYTE pbSkbAddr;
+} T_z_DownLink_Sdu;
+
+/* PSÊý¾ÝÃæ£¬ÉÏÐлº´æ¿é½Úµã½á¹¹£¬ÄÚ²¿Ê¹Óò»¶ÔÍ⿪·Å */
+typedef struct _T_z_UpLink_Node {
+ T_z_UpLink_Sdu tUpLinkSdu;
+ PDWORD pdwOverFlud;
+ DWORD dwFreed;
+ WORD wCurrentModule;
+ WORD wNextModule;
+ struct _T_z_UpLink_Node *ptNextNode;
+} T_z_UpLink_Node;
+
+/**************************************************************************
+ * º¯ÊýÉùÃ÷ *
+ **************************************************************************/
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zAllocUlBuf
+*º¯Êý¹¦ÄÜ : ÉêÇëÉÏÐÐÊý¾Ý»º´æ
+*ÊäÈë²ÎÊý : VOID
+*·µ »Ø Öµ : PBYTE ÿ¿éÊý¾Ý»º´æÆ«ÒƺóµÄµØÖ·
+*ÆäËû˵Ã÷ : Ö§³Ö²¢·¢²Ù×÷£¬»º´æÎª¿Õʱ·µ»ØNULL
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+PBYTE zAllocUlBuf(VOID);
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zAllocDlBuf
+*º¯Êý¹¦ÄÜ : ÉêÇëÏÂÐÐÊý¾Ý»º´æ
+*ÊäÈë²ÎÊý : VOID
+*·µ »Ø Öµ : PBYTE ÿ¿éÊý¾Ý»º´æÆ«ÒƺóµÄµØÖ·
+*ÆäËû˵Ã÷ : Ö§³Ö²¢·¢²Ù×÷£¬»º´æÎª¿Õʱ·µ»ØNULL
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+PBYTE zAllocDlBuf(VOID);
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zAllocUlBufCanWait
+*º¯Êý¹¦ÄÜ : ÉêÇëÉÏÐÐÊý¾Ý»º´æ
+*ÊäÈë²ÎÊý : VOID
+*·µ »Ø Öµ : PBYTE ÿ¿éÊý¾Ý»º´æÆ«ÒƺóµÄµØÖ·
+*ÆäËû˵Ã÷ : Ö§³Ö²¢·¢²Ù×÷£¬»º´æÎª¿Õʱ×èÈûµ÷ÓÃÏß³ÌÖ±µ½ÓпÉÓõÄÏß³Ì
+*º¯Êý×÷Õß : ´´½¨ÈÕÆÚ: 2011-11-04
+*
+*ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË µ¥ºÅÓëÐÞ¸ÄÄÚÈÝ
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+PBYTE zAllocUlBufCanWait(VOID);
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zFreeUlBuf
+*º¯Êý¹¦ÄÜ : ÊÍ·ÅÉÏÐÐÊý¾Ý»º´æ
+*ÊäÈë²ÎÊý : VOID
+*·µ »Ø Öµ : PBYTE ÿ¿éÊý¾Ý»º´æÆ«ÒƺóµÄµØÖ·
+*ÆäËû˵Ã÷ : Ö§³Ö²¢·¢²Ù×÷£¬
+*º¯Êý×÷Õß : ´´½¨ÈÕÆÚ: 2011-11-04
+*
+*ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË µ¥ºÅÓëÐÞ¸ÄÄÚÈÝ
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+VOID zFreeUlBuf(PBYTE pBuf);
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zFreeDlBuf
+*º¯Êý¹¦ÄÜ : ÊÍ·ÅÏÂÐÐÊý¾Ý»º´æ
+*ÊäÈë²ÎÊý : VOID
+*·µ »Ø Öµ : PBYTE ÿ¿éÊý¾Ý»º´æµÄÊ×µØÖ·
+*ÆäËû˵Ã÷ : Ö§³Ö²¢·¢²Ù×÷£¬
+*º¯Êý×÷Õß : ´´½¨ÈÕÆÚ: 2011-11-04
+*
+*ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË µ¥ºÅÓëÐÞ¸ÄÄÚÈÝ
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+VOID zFreeDlBuf(PBYTE pBuf);
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zGetUlBufAddr
+*º¯Êý¹¦ÄÜ : ΪÁ˽â¾öDHD°üÍ·32×Ö½Ú¶ÔÆë´«ÊäµÄÎÊÌ⣬´Ëº¯Êý¹©RNDISµ÷Ó㬻ñÈ¡
+ SduÊ×µØÖ·ºó£¬Í¶µÝ¸øÐÒéÕ»¡£
+*ÊäÈë²ÎÊý : ÎÞ
+*·µ »Ø Öµ : ÎÞ
+*ÆäËû˵Ã÷ :
+*º¯Êý×÷Õß : ´´½¨ÈÕÆÚ: 2013-09-23
+*Ôö¼Ó±³¾° : 7510UFIÁªµ÷ÐÂÔö
+*ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË µ¥ºÅÓëÐÞ¸ÄÄÚÈÝ
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+T_z_UpLink_Sdu * zGetUlBufAddr(PBYTE pBuf);
+
+#if !defined(_OS_WIN)
+PBYTE zGetpsbufferHead(PBYTE data);
+#endif
+
+PBYTE zAllocEpdcpPduBuf(VOID);
+void zInitEpdcpPduBuf(VOID);
+void zFreeEpdcpPduBuf(PBYTE pbAddr);
+void zFreeEpdcpPduBufList(T_z_UpLink_Node *ptHead,T_z_UpLink_Node *ptTail);
+
+BOOL zIsPsbuff(VOID *buf);
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zPutSkb2Psbuf
+*º¯Êý¹¦ÄÜ : ½«SKBÐÅÏ¢·â×°µ½PSBUF½á¹¹ÄÚ
+*ÊäÈë²ÎÊý : pbIpData - IPÂëÁ÷Ê×µØÖ·
+ wIpDataLen - IPÂëÁ÷³¤¶È(×Ö½Ú)
+ pbPdcpPduAddr - ÉÏÐÐEPDCP¼ÓÃܵÄÄ¿±êµØÖ·
+ pbSkbAddr - SKBµØÖ·£¬ÊÍ·ÅʱʹÓÃ
+*·µ »Ø Öµ : ÉÏÐÐÊý¾Ý½ÚµãÖ¸Õë
+*ÆäËû˵Ã÷ :
+ ×¢Òâ:sizeof(T_z_UpLink_Node) + Z_UP_LINK_RESERVE ²»Äܳ¬¹ý192×Ö½Ú£¬·ñÔòҪ֪ͨAP
+*º¯Êý×÷Õß :
+*
+*ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË µ¥ºÅÓëÐÞ¸ÄÄÚÈÝ
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+extern PBYTE zPutSkb2Psbuf(PBYTE pbIpData, WORD wIpDataLen, PBYTE pbPdcpPduAddr, PBYTE pbSkbAddr);
+extern WORD zGetUpLinkSduSize(VOID);
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zPsBuf_CacheInvalidateRange
+*º¯Êý¹¦ÄÜ : PSBUF·â×°zOss_CacheInvalidateRange²Ù×÷£¬ÒÔºó°æ±¾ºÃͳһ
+*ÊäÈë²ÎÊý :
+*·µ »Ø Öµ :
+*ÆäËû˵Ã÷ :
+*º¯Êý×÷Õß :
+*
+*ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË µ¥ºÅÓëÐÞ¸ÄÄÚÈÝ
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+extern VOID zPsBuf_CacheInvalidateRange(UINT32 base, UINT32 size);
+
+/*****************************************************************************
+*º¯ÊýÃû³Æ : zPsBuf_CacheCleanRange
+*º¯Êý¹¦ÄÜ : PSBUF·â×°zOss_CacheCleanRange²Ù×÷£¬ÒÔºó°æ±¾ºÃͳһ
+*ÊäÈë²ÎÊý :
+*·µ »Ø Öµ :
+*ÆäËû˵Ã÷ :
+*º¯Êý×÷Õß :
+*
+*ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË µ¥ºÅÓëÐÞ¸ÄÄÚÈÝ
+*---------------------------------------------------------------------------
+*
+****************************************************************************/
+extern VOID zPsBuf_CacheCleanRange(UINT32 base, UINT32 size);
+
+
+/* psbuff leak check */
+#ifdef _PSBUF_LEAK_CHECK
+void SetCurrntModule( PBYTE pBuf, WORD wModule );
+void SetNextModule( PBYTE pBuf, WORD wModuleC, WORD wModuleN );
+#define PSBUF_IN(b,m) SetCurrntModule((PBYTE)(b),(WORD)(m)) /* psbuff into module m */
+#define PSBUF_OUT(b,mc,mn) SetNextModule((PBYTE)(b),(WORD)(mc),(WORD)(mn)) /* psbuff from module mc to mn */
+#else
+#define PSBUF_IN(b,m)
+#define PSBUF_OUT(b,mc,mn)
+#endif
+/* outter module id define */
+#define PSBUF_MDL_BASE 0x10
+#define PSBUF_MDL_SIZE 0x10 /* high 4bit for outter module, low 4bit for inner module */
+#define PSBUF_MDL_CP_DRV_BASE PSBUF_MDL_BASE /* 0x10 */
+#define PSBUF_MDL_CP_CTRM_BASE (PSBUF_MDL_CP_DRV_BASE + PSBUF_MDL_SIZE) /* 0x20 */
+#define PSBUF_MDL_CP_NET_BASE (PSBUF_MDL_CP_CTRM_BASE + PSBUF_MDL_SIZE) /* 0x30 */
+#define PSBUF_MDL_AP_PSBUF_BASE (PSBUF_MDL_CP_NET_BASE + PSBUF_MDL_SIZE) /* 0x40 */
+#define PSBUF_MDL_AP_DDRNET_BASE (PSBUF_MDL_AP_PSBUF_BASE + PSBUF_MDL_SIZE) /* 0x50 */
+#define PSBUF_MDL_AP_NET_BASE (PSBUF_MDL_AP_DDRNET_BASE + PSBUF_MDL_SIZE) /* 0x60 */
+#define PSBUF_MDL_AP_WIFI_BASE (PSBUF_MDL_AP_NET_BASE + PSBUF_MDL_SIZE) /* 0x70 */
+#define PSBUF_MDL_CP_PS_BASE (PSBUF_MDL_AP_WIFI_BASE + PSBUF_MDL_SIZE) /* 0x80 */
+#endif