blob: 482c224462f3f22ec7f9cadd3ba810a5a64569a3 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. 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
22#if !defined( __WLAN_QCT_WDI_DS_I_H )
23#define __WLAN_QCT_WDI_DS_I_H
24
25/**=========================================================================
26 *
27 * \file wlan_qct_wdi_ds_i.h
28 *
29 * \brief define Dataservice API
30 *
31 * WLAN Device Abstraction layer External API for Dataservice
32 * DESCRIPTION
33 * This file contains the external API exposed by the
34 * wlan device abstarction layer module.
35 *
36 * Copyright (c) 2008 QUALCOMM Incorporated. All Rights Reserved.
37 * Qualcomm Confidential and Proprietary
38 */
39
40#include "wlan_qct_pal_type.h"
41#include "wlan_qct_pal_status.h"
42#include "wlan_qct_pal_packet.h"
43#include "wlan_qct_wdi_ds.h"
44#include "wlan_qct_dxe.h"
45
46
47#define WDI_DS_MAX_CHUNK_SIZE 128
48#define WDI_802_11_MAX_HEADER_LEN 40
49
50
51/*The number of resources (BD headers) available for the HI priority DXE
52 channel
53 DXE will use 1 descriptor for the BD header and 1 for the data =>
54 This is true for LA but not EA. EA sends down 3~4 MDL chain per a packet.
55 Now we set it the same with free DXE decriptor number*/
56#define WDI_DS_HI_PRI_RES_NUM (WLANDXE_HI_PRI_RES_NUM)
57
58/*The number of resources (BD headers) available for the Low priority DXE
59 channel - see above
60*/
61#define WDI_DS_LO_PRI_RES_NUM (WLANDXE_LO_PRI_RES_NUM)
62
63/*The number of BD headers available in the system for Tx must match the number
64 of DXE descriptors available for actual transmission, otherwise we have to
65 manage two diffrent level of resource pools*/
66
67#define WDI_MAC_ADDR_SIZE ( 6 )
68/*802.3 header definitions*/
69#define WDI_802_3_HEADER_LEN 14
70/* Offset of DA field in a 802.3 header*/
71#define WDI_802_3_HEADER_DA_OFFSET 0
72/*802.11 header definitions - header len without QOS ctrl field*/
73#define WDI_802_11_HEADER_LEN 24
74/*802.11 header length + QOS ctrl field*/
75#define WDI_MPDU_HEADER_LEN 26
76/*802.11 header definitions*/
77#define WDI_802_11_MAX_HEADER_LEN 40
78/*802.11 header definitions - qos ctrl field len*/
79#define WDI_802_11_HEADER_QOS_CTL 2
80/*802.11 ADDR4 MAC addr field len */
81#define WDI_802_11_HEADER_ADDR4_LEN WDI_MAC_ADDR_SIZE
82
83
84
85
86
87typedef enum
88{
89 DTI_TRACE_LEVEL_FATAL,
90 DTI_TRACE_LEVEL_ERROR,
91 DTI_TRACE_LEVEL_WARN,
92 DTI_TRACE_LEVEL_INFO
93
94} DTI_TRACE_LEVEL;
95
96WPT_STATIC WPT_INLINE void DTI_TRACE ( DTI_TRACE_LEVEL level, ...) { };
97
98/* !!! MAX NUM STA is not identified yet, 16 is correct value,
99 but need to get from correct common def
100 This should be identified ASAP */
101#define WDI_DS_MAX_STA_ID 16
102
103/* !!! MAX NUM SUPPORTED BSS is not identified yet, 2 is correct value,
104 but need to get from correct common def
105 This should be identified ASAP */
106#define WDI_DS_MAX_SUPPORTED_BSS 2
107
108#define WDI_DS_INDEX_INVALID 0xFF
109
110/* Mem Pool resorce count per STA data type */
111typedef struct {
112 wpt_uint8 validIdx;
113 wpt_uint8 STAIndex;
114 wpt_uint32 numChunkReservedBySTA;
115 /* Mutex, is not needed for counter operation
116 since all TX Data frame operations will happen only TX thread
117 All of the TX data frame operations are serialized, no pre-emption will happen
118 This is just for place holder */
119 wpt_mutex resourceCountLock;
120} WDI_DS_BdMemPoolSTAType;
121
122typedef struct {
123 void *pVirtBaseAddress;
124 void *pPhysBaseAddress;
125 wpt_uint32 poolSize;
126 wpt_uint32 numChunks;
127 wpt_uint32 chunkSize;
128 wpt_uint32* AllocationBitmap;
129 WDI_DS_BdMemPoolSTAType numChunkSTA[WDI_DS_MAX_STA_ID + 1];
130} WDI_DS_BdMemPoolType;
131
132/* STA index associated with BSS index data type */
133typedef struct
134{
135 wpt_uint8 isUsed;
136 wpt_uint8 bssIdx;
137 wpt_uint8 staIdx;
138} WDI_DS_staIdxPerBssIdxType;
139
140WDI_Status WDI_DS_MemPoolCreate(WDI_DS_BdMemPoolType *memPool, wpt_uint8 chunkSize, wpt_uint8 numChunks);
141void *WDI_DS_MemPoolAlloc(WDI_DS_BdMemPoolType *memPool, void **pPhysAddress, WDI_ResPoolType wdiResPool);
142void WDI_DS_MemPoolFree(WDI_DS_BdMemPoolType *memPool, void *pVirtAddress, void *pPhysAddress);
143void WDI_DS_MemPoolDestroy(WDI_DS_BdMemPoolType *memPool);
144
145typedef struct
146{
147 void *pcontext;
148 void *pCallbackContext;
149 wpt_uint8 suspend;
150 WDI_DS_BdMemPoolType mgmtMemPool;
151 WDI_DS_BdMemPoolType dataMemPool;
152 WDI_DS_RxPacketCallback receiveFrameCB;
153 WDI_DS_TxCompleteCallback txCompleteCB;
154 WDI_DS_TxFlowControlCallback txResourceCB;
155 WDI_DS_staIdxPerBssIdxType staIdxPerBssIdxTable[WDI_DS_MAX_SUPPORTED_BSS];
156} WDI_DS_ClientDataType;
157
158WPT_STATIC WPT_INLINE void WDI_GetBDPointers(wpt_packet *pFrame, void **pVirt, void **pPhys)
159{
160 *pVirt = WPAL_PACKET_GET_BD_POINTER(pFrame);
161 *pPhys = WPAL_PACKET_GET_BD_PHYS(pFrame);
162}
163
164
165WPT_STATIC WPT_INLINE void WDI_SetBDPointers(wpt_packet *pFrame, void *pVirt, void *pPhys)
166{
167 WPAL_PACKET_SET_BD_POINTER(pFrame, pVirt);
168 WPAL_PACKET_SET_BD_PHYS(pFrame, pPhys);
169}
170
171
172void
173WDI_DS_PrepareBDHeader (
174 wpt_packet* palPacket,
175 wpt_uint8 ucDisableHWFrmXtl,
176 wpt_uint8 alignment
177);
178
179/**
180 @brief Returns the available number of resources (BD headers)
181 available for TX
182
183 @param pMemPool: pointer to the BD memory pool
184
185 @see
186 @return Result of the function call
187*/
188wpt_uint32 WDI_DS_GetAvailableResCount(WDI_DS_BdMemPoolType *pMemPool);
189
190/**
191 @brief WDI_DS_GetreservedResCountPerSTA
192 Returns the Reserved number of resources (BD headers)
193 available for TX
194
195 @param pMemPool: pointer to the BD memory pool
196 @param staId STA ID
197
198 @see
199 @return Result of the function call
200*/
201wpt_uint32 WDI_DS_MemPoolGetRsvdResCountPerSTA(WDI_DS_BdMemPoolType *pMemPool, wpt_uint8 staId);
202
203/**
204 @brief WDI_DS_MemPoolAddSTA
205 Add NEW STA into mempool
206
207 @param pMemPool: pointer to the BD memory pool
208 @param staId STA ID
209
210 @see
211 @return Result of the function call
212*/
213WDI_Status WDI_DS_MemPoolAddSTA(WDI_DS_BdMemPoolType *memPool, wpt_uint8 staIndex);
214
215/**
216 @brief WDI_DS_MemPoolAddSTA
217 Remove STA from mempool
218
219 @param pMemPool: pointer to the BD memory pool
220 @param staId STA ID
221
222 @see
223 @return Result of the function call
224*/
225WDI_Status WDI_DS_MemPoolDelSTA(WDI_DS_BdMemPoolType *memPool, wpt_uint8 staIndex);
226
227/**
228 @brief Increase reserved TX resource count by specific STA
229
230 @param pMemPool: pointer to the BD memory pool
231 @param staId STA ID
232 @see
233 @return Result of the function call
234*/
235void WDI_DS_MemPoolIncreaseReserveCount(WDI_DS_BdMemPoolType *memPool, wpt_uint8 staId);
236
237/**
238 @brief Decrease reserved TX resource count by specific STA
239
240 @param pMemPool: pointer to the BD memory pool
241 @param staId STA ID
242 @see
243 @return Result of the function call
244*/
245void WDI_DS_MemPoolDecreaseReserveCount(WDI_DS_BdMemPoolType *memPool, wpt_uint8 staId);
246#endif