rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2016 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS (""MEDIATEK SOFTWARE"") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN ""AS-IS"" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | /************************************************************* |
| 36 | * |
| 37 | * This Software is the property of VIA Telecom, Inc. and may only be used pursuant to a license from VIA Telecom, Inc. |
| 38 | * |
| 39 | * Any unauthorized use inconsistent with the terms of such license is strictly prohibited. |
| 40 | * |
| 41 | * Copyright (c) 2006-2010 VIA Telecom, Inc. All rights reserved. |
| 42 | * |
| 43 | *************************************************************/ |
| 44 | #ifndef _CPBUF_H_ |
| 45 | #define _CPBUF_H_ |
| 46 | /***************************************************************************** |
| 47 | * |
| 48 | * FILE NAME : cpbuf.h |
| 49 | * |
| 50 | * DESCRIPTION : CP Buffer Manager |
| 51 | * |
| 52 | * HISTORY : |
| 53 | * See Log at end of file |
| 54 | * |
| 55 | *****************************************************************************/ |
| 56 | #include "kal_public_api.h" |
| 57 | #include "flc2_ent_functions.h" |
| 58 | #include "monapi.h" |
| 59 | |
| 60 | |
| 61 | #define CPBUF_SIZE_FWD 640 /* bytes */ |
| 62 | #define CPBUF_SIZE_REV 252 /* bytes */ |
| 63 | #define CPBUF_SIZE_SIG 100 /* bytes */ |
| 64 | #define CPBUF_SIZE_HDR 15 /* bytes */ |
| 65 | #define CPBUF_SIZE_FWD1X 48 /* bytes */ |
| 66 | |
| 67 | #define CPBUF_ONEBUF 0xFFFF |
| 68 | |
| 69 | //#define CPBUF_SPIN_LOCK |
| 70 | #define DEBUG_CPBUF_FILE_INFO |
| 71 | |
| 72 | extern kal_spinlockid cpBufSpinLock[5]; |
| 73 | |
| 74 | |
| 75 | /*---------------------------------------------------------------------------- |
| 76 | CP Buf Data Struct |
| 77 | ----------------------------------------------------------------------------*/ |
| 78 | |
| 79 | /* Allocation Status of each CP Buf memory buffer */ |
| 80 | typedef enum |
| 81 | { |
| 82 | CPBUF_FREE = 0xFE, /* non-zero nor one to avoid unwanted matching of uninitialized data field. */ |
| 83 | CPBUF_BUSY = 0xB0 |
| 84 | } CpBufStatusT; |
| 85 | |
| 86 | |
| 87 | /* Allocation Type of CP Buf memory buffer */ |
| 88 | typedef enum |
| 89 | { |
| 90 | CPBUF_FWD = 0, |
| 91 | CPBUF_REV, |
| 92 | CPBUF_SIGNALING_MSG, |
| 93 | CPBUF_POOL_NUM, |
| 94 | CPBUF_HEADER = CPBUF_POOL_NUM, /* Obsolete pool */ |
| 95 | CPBUF_FWD1X /* Obsolete pool */ |
| 96 | } CpBufTypeT; |
| 97 | |
| 98 | typedef struct cpBuffer |
| 99 | { |
| 100 | kal_uint32* dataPtr; /* Ptr to the CPBUF addr in CPBUF_Pool[] */ |
| 101 | kal_uint16 len; /* Length of data in bytes. */ |
| 102 | CpBufStatusT status; /* Free or Busy */ |
| 103 | CpBufTypeT type; /* partition type. Need this info to Free cpbuf */ |
| 104 | kal_uint32 refCount; /* reference count of this cp buffer */ |
| 105 | struct cpBuffer *nextPtr; /* Ptr to the next cpPktHdr in this CP Pkt */ |
| 106 | } CpBufferT; |
| 107 | |
| 108 | |
| 109 | /* cpBufQ - This is a generic CpBufferT type Queue Linked-List */ |
| 110 | typedef struct cpBufQ |
| 111 | { |
| 112 | CpBufferT *head; |
| 113 | CpBufferT *tail; |
| 114 | kal_uint32 count; /* Total number of CpBufferT in this linked-list */ |
| 115 | } CpBufQT; |
| 116 | |
| 117 | |
| 118 | /*---------------------------------------------------------------------------- |
| 119 | CP Pkt Functions |
| 120 | ----------------------------------------------------------------------------*/ |
| 121 | #ifndef DEBUG_CPBUF_FILE_INFO |
| 122 | extern CpBufferT* CpBufGet(kal_uint16 size, CpBufTypeT CpBufType ); |
| 123 | extern void CpBufCopy( CpBufferT *cpPktPtr ); |
| 124 | extern void CpBufFree( CpBufferT *cpPktPtr ); |
| 125 | #else |
| 126 | extern CpBufferT* __CpBufGet(const char *moduleName, unsigned lineNumber, kal_uint16 size, CpBufTypeT CpBufType ); |
| 127 | extern void __CpBufCopy(const char *moduleName, unsigned lineNumber, CpBufferT *cpPktPtr ); |
| 128 | extern void __CpBufFree(const char *moduleName, unsigned lineNumber, CpBufferT *cpPktPtr ); |
| 129 | |
| 130 | #define CpBufGet(size, CpBufType) __CpBufGet( __FUNCTION__, __LINE__, size, CpBufType) |
| 131 | #define CpBufFree( cpPktPtr ) __CpBufFree( __FUNCTION__, __LINE__, cpPktPtr ) |
| 132 | #define CpBufCopy( cpPktPtr ) __CpBufCopy(__FUNCTION__, __LINE__, cpPktPtr ) |
| 133 | |
| 134 | #endif |
| 135 | extern kal_bool CpBufFwdFlowCtrlOn(void); |
| 136 | extern kal_bool CpBufRevFlowCtrlOn(void); |
| 137 | extern CpBufferT * CpBufMerge (kal_uint16 numCpBuffers, |
| 138 | CpBufferT *cpBufList[], |
| 139 | kal_uint16 *offsetList, |
| 140 | kal_uint16 *lenList, |
| 141 | kal_uint16 *mergedLen, |
| 142 | CpBufTypeT cpBufType); |
| 143 | extern void CpBufSpinLocksCreate(void); |
| 144 | extern CpBufferT * isr_get_cpbuf(kal_uint16 size, CpBufTypeT cpBufType, const char *moduleName, kal_uint16 lineNumber); |
| 145 | extern void fill_isr_cpbuf_queue(kal_uint16 size, CpBufTypeT cpBufType); |
| 146 | extern void fill_rcp_ri_cpbuf_queue(void); |
| 147 | |
| 148 | #if defined (RCP_RI_HRT_DEV) |
| 149 | #define RCP_CPBUF_GET(size, cpbufType) isr_get_cpbuf(size, cpbufType, __FUNCTION__, __LINE__) |
| 150 | #else |
| 151 | #define RCP_CPBUF_GET(size, cpbufType) CpBufGet(size, cpbufType) |
| 152 | #endif |
| 153 | |
| 154 | |
| 155 | /*---------------------------------------------------------------------------- |
| 156 | Global Data |
| 157 | ----------------------------------------------------------------------------*/ |
| 158 | |
| 159 | /***************************************************************************** |
| 160 | * End of File |
| 161 | *****************************************************************************/ |
| 162 | #endif |