Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 24 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 25 | * |
| 26 | * |
| 27 | * Permission to use, copy, modify, and/or distribute this software for |
| 28 | * any purpose with or without fee is hereby granted, provided that the |
| 29 | * above copyright notice and this permission notice appear in all |
| 30 | * copies. |
| 31 | * |
| 32 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 33 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 35 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 36 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 37 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 38 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 39 | * PERFORMANCE OF THIS SOFTWARE. |
| 40 | */ |
| 41 | |
| 42 | #if !defined( __WLAN_QCT_WDI_DS_I_H ) |
| 43 | #define __WLAN_QCT_WDI_DS_I_H |
| 44 | |
| 45 | /**========================================================================= |
| 46 | * |
| 47 | * \file wlan_qct_wdi_ds_i.h |
| 48 | * |
| 49 | * \brief define Dataservice API |
| 50 | * |
| 51 | * WLAN Device Abstraction layer External API for Dataservice |
| 52 | * DESCRIPTION |
| 53 | * This file contains the external API exposed by the |
| 54 | * wlan device abstarction layer module. |
| 55 | * |
| 56 | * Copyright (c) 2008 QUALCOMM Incorporated. All Rights Reserved. |
| 57 | * Qualcomm Confidential and Proprietary |
| 58 | */ |
| 59 | |
| 60 | #include "wlan_qct_pal_type.h" |
| 61 | #include "wlan_qct_pal_status.h" |
| 62 | #include "wlan_qct_pal_packet.h" |
| 63 | #include "wlan_qct_wdi_ds.h" |
| 64 | #include "wlan_qct_dxe.h" |
| 65 | |
| 66 | |
| 67 | #define WDI_DS_MAX_CHUNK_SIZE 128 |
| 68 | #define WDI_802_11_MAX_HEADER_LEN 40 |
| 69 | |
| 70 | |
| 71 | /*The number of resources (BD headers) available for the HI priority DXE |
| 72 | channel |
| 73 | DXE will use 1 descriptor for the BD header and 1 for the data => |
| 74 | This is true for LA but not EA. EA sends down 3~4 MDL chain per a packet. |
| 75 | Now we set it the same with free DXE decriptor number*/ |
| 76 | #define WDI_DS_HI_PRI_RES_NUM (WLANDXE_HI_PRI_RES_NUM) |
| 77 | |
| 78 | /*The number of resources (BD headers) available for the Low priority DXE |
| 79 | channel - see above |
| 80 | */ |
| 81 | #define WDI_DS_LO_PRI_RES_NUM (WLANDXE_LO_PRI_RES_NUM) |
| 82 | |
| 83 | /*The number of BD headers available in the system for Tx must match the number |
| 84 | of DXE descriptors available for actual transmission, otherwise we have to |
| 85 | manage two diffrent level of resource pools*/ |
| 86 | |
| 87 | #define WDI_MAC_ADDR_SIZE ( 6 ) |
| 88 | /*802.3 header definitions*/ |
| 89 | #define WDI_802_3_HEADER_LEN 14 |
| 90 | /* Offset of DA field in a 802.3 header*/ |
| 91 | #define WDI_802_3_HEADER_DA_OFFSET 0 |
| 92 | /*802.11 header definitions - header len without QOS ctrl field*/ |
| 93 | #define WDI_802_11_HEADER_LEN 24 |
| 94 | /*802.11 header length + QOS ctrl field*/ |
| 95 | #define WDI_MPDU_HEADER_LEN 26 |
| 96 | /*802.11 header definitions*/ |
| 97 | #define WDI_802_11_MAX_HEADER_LEN 40 |
| 98 | /*802.11 header definitions - qos ctrl field len*/ |
| 99 | #define WDI_802_11_HEADER_QOS_CTL 2 |
| 100 | /*802.11 ADDR4 MAC addr field len */ |
| 101 | #define WDI_802_11_HEADER_ADDR4_LEN WDI_MAC_ADDR_SIZE |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | typedef enum |
| 108 | { |
| 109 | DTI_TRACE_LEVEL_FATAL, |
| 110 | DTI_TRACE_LEVEL_ERROR, |
| 111 | DTI_TRACE_LEVEL_WARN, |
| 112 | DTI_TRACE_LEVEL_INFO |
| 113 | |
| 114 | } DTI_TRACE_LEVEL; |
| 115 | |
| 116 | WPT_STATIC WPT_INLINE void DTI_TRACE ( DTI_TRACE_LEVEL level, ...) { }; |
| 117 | |
| 118 | /* !!! MAX NUM STA is not identified yet, 16 is correct value, |
| 119 | but need to get from correct common def |
| 120 | This should be identified ASAP */ |
| 121 | #define WDI_DS_MAX_STA_ID 16 |
| 122 | |
| 123 | /* !!! MAX NUM SUPPORTED BSS is not identified yet, 2 is correct value, |
| 124 | but need to get from correct common def |
| 125 | This should be identified ASAP */ |
| 126 | #define WDI_DS_MAX_SUPPORTED_BSS 2 |
| 127 | |
| 128 | #define WDI_DS_INDEX_INVALID 0xFF |
| 129 | |
| 130 | /* Mem Pool resorce count per STA data type */ |
| 131 | typedef struct { |
| 132 | wpt_uint8 validIdx; |
| 133 | wpt_uint8 STAIndex; |
| 134 | wpt_uint32 numChunkReservedBySTA; |
| 135 | /* Mutex, is not needed for counter operation |
| 136 | since all TX Data frame operations will happen only TX thread |
| 137 | All of the TX data frame operations are serialized, no pre-emption will happen |
| 138 | This is just for place holder */ |
| 139 | wpt_mutex resourceCountLock; |
| 140 | } WDI_DS_BdMemPoolSTAType; |
| 141 | |
| 142 | typedef struct { |
| 143 | void *pVirtBaseAddress; |
| 144 | void *pPhysBaseAddress; |
| 145 | wpt_uint32 poolSize; |
| 146 | wpt_uint32 numChunks; |
| 147 | wpt_uint32 chunkSize; |
| 148 | wpt_uint32* AllocationBitmap; |
| 149 | WDI_DS_BdMemPoolSTAType numChunkSTA[WDI_DS_MAX_STA_ID + 1]; |
| 150 | } WDI_DS_BdMemPoolType; |
| 151 | |
| 152 | /* STA index associated with BSS index data type */ |
| 153 | typedef struct |
| 154 | { |
| 155 | wpt_uint8 isUsed; |
| 156 | wpt_uint8 bssIdx; |
| 157 | wpt_uint8 staIdx; |
| 158 | } WDI_DS_staIdxPerBssIdxType; |
| 159 | |
| 160 | WDI_Status WDI_DS_MemPoolCreate(WDI_DS_BdMemPoolType *memPool, wpt_uint8 chunkSize, wpt_uint8 numChunks); |
| 161 | void *WDI_DS_MemPoolAlloc(WDI_DS_BdMemPoolType *memPool, void **pPhysAddress, WDI_ResPoolType wdiResPool); |
| 162 | void WDI_DS_MemPoolFree(WDI_DS_BdMemPoolType *memPool, void *pVirtAddress, void *pPhysAddress); |
| 163 | void WDI_DS_MemPoolDestroy(WDI_DS_BdMemPoolType *memPool); |
| 164 | |
| 165 | typedef struct |
| 166 | { |
| 167 | void *pcontext; |
| 168 | void *pCallbackContext; |
| 169 | wpt_uint8 suspend; |
| 170 | WDI_DS_BdMemPoolType mgmtMemPool; |
| 171 | WDI_DS_BdMemPoolType dataMemPool; |
| 172 | WDI_DS_RxPacketCallback receiveFrameCB; |
| 173 | WDI_DS_TxCompleteCallback txCompleteCB; |
| 174 | WDI_DS_TxFlowControlCallback txResourceCB; |
| 175 | WDI_DS_staIdxPerBssIdxType staIdxPerBssIdxTable[WDI_DS_MAX_SUPPORTED_BSS]; |
| 176 | } WDI_DS_ClientDataType; |
| 177 | |
| 178 | WPT_STATIC WPT_INLINE void WDI_GetBDPointers(wpt_packet *pFrame, void **pVirt, void **pPhys) |
| 179 | { |
| 180 | *pVirt = WPAL_PACKET_GET_BD_POINTER(pFrame); |
| 181 | *pPhys = WPAL_PACKET_GET_BD_PHYS(pFrame); |
| 182 | } |
| 183 | |
| 184 | |
| 185 | WPT_STATIC WPT_INLINE void WDI_SetBDPointers(wpt_packet *pFrame, void *pVirt, void *pPhys) |
| 186 | { |
| 187 | WPAL_PACKET_SET_BD_POINTER(pFrame, pVirt); |
| 188 | WPAL_PACKET_SET_BD_PHYS(pFrame, pPhys); |
| 189 | } |
| 190 | |
| 191 | |
| 192 | void |
| 193 | WDI_DS_PrepareBDHeader ( |
| 194 | wpt_packet* palPacket, |
| 195 | wpt_uint8 ucDisableHWFrmXtl, |
| 196 | wpt_uint8 alignment |
| 197 | ); |
| 198 | |
| 199 | /** |
| 200 | @brief Returns the available number of resources (BD headers) |
| 201 | available for TX |
| 202 | |
| 203 | @param pMemPool: pointer to the BD memory pool |
| 204 | |
| 205 | @see |
| 206 | @return Result of the function call |
| 207 | */ |
| 208 | wpt_uint32 WDI_DS_GetAvailableResCount(WDI_DS_BdMemPoolType *pMemPool); |
| 209 | |
| 210 | /** |
| 211 | @brief WDI_DS_GetreservedResCountPerSTA |
| 212 | Returns the Reserved number of resources (BD headers) |
| 213 | available for TX |
| 214 | |
| 215 | @param pMemPool: pointer to the BD memory pool |
| 216 | @param staId STA ID |
| 217 | |
| 218 | @see |
| 219 | @return Result of the function call |
| 220 | */ |
| 221 | wpt_uint32 WDI_DS_MemPoolGetRsvdResCountPerSTA(WDI_DS_BdMemPoolType *pMemPool, wpt_uint8 staId); |
| 222 | |
| 223 | /** |
| 224 | @brief WDI_DS_MemPoolAddSTA |
| 225 | Add NEW STA into mempool |
| 226 | |
| 227 | @param pMemPool: pointer to the BD memory pool |
| 228 | @param staId STA ID |
| 229 | |
| 230 | @see |
| 231 | @return Result of the function call |
| 232 | */ |
| 233 | WDI_Status WDI_DS_MemPoolAddSTA(WDI_DS_BdMemPoolType *memPool, wpt_uint8 staIndex); |
| 234 | |
| 235 | /** |
| 236 | @brief WDI_DS_MemPoolAddSTA |
| 237 | Remove STA from mempool |
| 238 | |
| 239 | @param pMemPool: pointer to the BD memory pool |
| 240 | @param staId STA ID |
| 241 | |
| 242 | @see |
| 243 | @return Result of the function call |
| 244 | */ |
| 245 | WDI_Status WDI_DS_MemPoolDelSTA(WDI_DS_BdMemPoolType *memPool, wpt_uint8 staIndex); |
| 246 | |
| 247 | /** |
| 248 | @brief Increase reserved TX resource count by specific STA |
| 249 | |
| 250 | @param pMemPool: pointer to the BD memory pool |
| 251 | @param staId STA ID |
| 252 | @see |
| 253 | @return Result of the function call |
| 254 | */ |
| 255 | void WDI_DS_MemPoolIncreaseReserveCount(WDI_DS_BdMemPoolType *memPool, wpt_uint8 staId); |
| 256 | |
| 257 | /** |
| 258 | @brief Decrease reserved TX resource count by specific STA |
| 259 | |
| 260 | @param pMemPool: pointer to the BD memory pool |
| 261 | @param staId STA ID |
| 262 | @see |
| 263 | @return Result of the function call |
| 264 | */ |
| 265 | void WDI_DS_MemPoolDecreaseReserveCount(WDI_DS_BdMemPoolType *memPool, wpt_uint8 staId); |
| 266 | #endif |