blob: 58ef385f12927d787767c7d281b1c9b3b4de1d34 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * 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 Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
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( __I_VOS_PACKET_H )
43#define __I_VOS_PACKET_H
44
45/**=========================================================================
46
47 \file i_vos_packet.h
48
49 \brief virtual Operating System Servies (vOSS)
50
51 Network Protocol packet/buffer internal include file
52
53 Copyright 2009 (c) Qualcomm, Incorporated. All Rights Reserved.
54
55 Qualcomm Confidential and Proprietary.
56
57 ========================================================================*/
58
59/* $Header$ */
60
61/*--------------------------------------------------------------------------
62 Include Files
63 ------------------------------------------------------------------------*/
64#include <vos_types.h>
65#include <vos_list.h>
66#include <linux/skbuff.h>
67#include <linux/list.h>
68
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include <wlan_qct_pal_packet.h>
70#include <wlan_qct_wdi_ds.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070071
72/*--------------------------------------------------------------------------
73 Preprocessor definitions and constants
74 ------------------------------------------------------------------------*/
75
76// Definitions for the various VOS packet pools. Following are defines
77// for the SIZE and the NUMBER of vos packets in the vos packet pools.
78// Note that all of the code is written to allocate and manage the vos
79// packet pools based on these #defines only. For example, if you want to
80// change the number of RX_RAW packets, simply change the #define that
81// defines the number of RX_RAW packets and rebuild VOSS.
82
83// the number of Receive vos packets used exclusively for vos packet
84// allocations of type VOS_PKT_TYPE_RX_RAW
Jeff Johnsone7245742012-09-05 17:12:55 -070085#define VPKT_NUM_RX_RAW_PACKETS (1024)
Jeff Johnson295189b2012-06-20 16:38:30 -070086
87// the number of Transmit Management vos packets, used exclusively for
88// vos packet allocations of type VOS_PKT_TYPE_TX_802_11_MGMT
89#define VPKT_NUM_TX_MGMT_PACKETS ( 6 )
90
91// the number of Transmit Data vos packets, used exclusively for
92// vos packet allocations of type VOS_PKT_TYPE_TX_802_3_DATA or
93// VOS_PKT_TYPE_TX_802_11_DATA
94#define VPKT_NUM_TX_DATA_PACKETS ( 128 )
95
96// the number of VOS Packets we need. This is the memory we need to
97// allocate for the vos Packet structures themselves. We need vos
98// packet structures for all of the packet types (RX_RAW, TX_MGMT, and
99// TX_DATA).
100#define VPKT_NUM_VOS_PKT_BUFFERS \
101 ( VPKT_NUM_RX_RAW_PACKETS \
102 + VPKT_NUM_TX_MGMT_PACKETS \
103 + VPKT_NUM_TX_DATA_PACKETS )
104
105// the number of Receive vos packets that we accumulate in the
106// replenish pool before we attempt to replenish them
107#define VPKT_RX_REPLENISH_THRESHOLD ( VPKT_NUM_RX_RAW_PACKETS >> 2 )
108
109// magic number which can be used to verify that a structure pointer being
110// dereferenced is really referencing a struct vos_pkt_t
111#define VPKT_MAGIC_NUMBER 0x56504B54 /* VPKT in ASCII */
112
113/*--------------------------------------------------------------------------
114 Type declarations
115 ------------------------------------------------------------------------*/
116
117
118
119/// implementation specific vos packet type
120struct vos_pkt_t
121{
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
123 //palPacket MUST be the first member of vos_pkt_t
124 wpt_packet palPacket;
Jeff Johnson295189b2012-06-20 16:38:30 -0700125
126 // Node for linking vos packets into a free list
127 struct list_head node;
128
129 // Node for chaining vos packets into a packet chain
130 struct vos_pkt_t *pNext;
131
132 // pointer to an OS specific packet descriptor
133 struct sk_buff *pSkb;
134
135 // packet type
136 VOS_PKT_TYPE packetType;
137
138 // timestamp
139 v_TIME_t timestamp;
140
141 // user data pointers
142 v_VOID_t *pvUserData[ VOS_PKT_USER_DATA_ID_MAX ];
143
144 // magic number for verifying this is really a struct vos_pkt_t
145 v_U32_t magic;
146};
147
148
149// Parameters from the vos_pkt_get_packet() call that needs
150// to be saved in 'low resource' conditions. We need all the
151// parameters from the original call to vos_pkt_get_packet()
152// to resolve the packet request when one become available.
153typedef struct
154{
155 vos_pkt_get_packet_callback callback;
156
157 v_VOID_t *userData;
158
159 v_SIZE_t dataSize;
160 v_SIZE_t numPackets;
161 v_BOOL_t zeroBuffer;
162
163} vos_pkt_low_resource_info;
164
165
166
167// vOSS Packet Context - all context / internal data needed for the
168// vOSS pPacket module. This consiste of:
169// - memory for the vos Packet structures
170// - memory for the vos Packet Head / Tail buffers
171// - memory for the Rx Raw data buffers
172// - memory for the Tx Mgmt data buffers.
173typedef struct vos_pkt_context_s
174{
175 // place to save the vos Context
176 v_CONTEXT_t vosContext;
177
178 // the memory for the vos Packet structures....
179 struct vos_pkt_t vosPktBuffers[ VPKT_NUM_VOS_PKT_BUFFERS ];
180
181 // These are the lists to keep the constructed VOS packets that are
182 // available for allocation. There are separate free vos packet
183 // pools for RX_RAW without attached skb, RX_RAW with attached skb,
184 // TX_DATA, and TX_MGMT.
185 struct list_head rxReplenishList;
186 struct list_head rxRawFreeList;
187 struct list_head txDataFreeList;
188 struct list_head txMgmtFreeList;
189
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 //Existing list_size opearation traverse the list. Too slow for data path.
191 //Add the field to enable faster flow control on tx path
192 v_U32_t uctxDataFreeListCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700193
194 // We keep a separate count of the number of RX_RAW packets
195 // waiting to be replenished
196 v_SIZE_t rxReplenishListCount;
Mahesh Kumar Kalikot Veetil78b1f372013-02-21 17:32:37 -0800197 //Existing list_size opearation traverse the list. Too slow for data path.
198 //Add the field for a faster rx path
199 v_SIZE_t rxRawFreeListCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700200
Sameer Thalappild0158402013-05-03 13:19:03 -0700201 // Number of RX Raw packets that will be reserved; this is a configurable
202 // value to the driver to save the memory usage.
203 v_SIZE_t numOfRxRawPackets;
204
Jeff Johnson295189b2012-06-20 16:38:30 -0700205 // These are the structs to keep low-resource callback information.
206 // There are separate low-resource callback information blocks for
207 // RX_RAW, TX_DATA, and TX_MGMT.
208 vos_pkt_low_resource_info rxRawLowResourceInfo;
209 vos_pkt_low_resource_info txDataLowResourceInfo;
Jeff Johnson2f5cfec2013-02-22 21:25:10 -0800210 vos_pkt_low_resource_info txMgmtLowResourceInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700211
212 struct mutex mlock;
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 /*Meta Information to be transported with the packet*/
214 WDI_DS_TxMetaInfoType txMgmtMetaInfo[VPKT_NUM_TX_MGMT_PACKETS];
215 WDI_DS_TxMetaInfoType txDataMetaInfo[VPKT_NUM_TX_DATA_PACKETS];
216 WDI_DS_RxMetaInfoType rxMetaInfo[VPKT_NUM_RX_RAW_PACKETS];
Jeff Johnson295189b2012-06-20 16:38:30 -0700217
218} vos_pkt_context_t;
219
220
221
222/*---------------------------------------------------------------------------
223
224 \brief vos_packet_open() - initialize the vOSS Packet module
225
226 The \a vos_packet_open() function initializes the vOSS Packet
227 module.
228
229 \param pVosContext - pointer to the global vOSS Context
230
231 \param pVosPacketContext - pointer to a previously allocated
232 buffer big enough to hold the vos Packet context.
233
234 \param vosPacketContextSize - the size allocated for the vos
235 packet context.
236
237 \return VOS_STATUS_SUCCESS - vos Packet module was successfully
238 initialized and is ready to be used.
239
240 VOS_STATUS_E_RESOURCES - System resources (other than memory)
241 are unavailable to initilize the vos Packet module
242
243 VOS_STATUS_E_NOMEM - insufficient memory exists to initialize
244 the vos packet module
245
246 VOS_STATUS_E_INVAL - Invalid parameter passed to the vos open
247 function
248
249 VOS_STATUS_E_FAILURE - Failure to initialize the vos packet
250 module
251
252 \sa vos_packet_close()
253
254 -------------------------------------------------------------------------*/
255VOS_STATUS vos_packet_open( v_VOID_t *pVosContext,
256 vos_pkt_context_t *pVosPacketContext,
257 v_SIZE_t vosPacketContextSize );
258
259
260/*---------------------------------------------------------------------------
261
262 \brief vos_packet_close() - Close the vOSS Packet module
263
264 The \a vos_packet_close() function closes the vOSS Packet module
265 Upon successful close all resources allocated from the OS will be
266 relinquished.
267
268 \param pVosContext - pointer to the global vOSS Context
269
270 \return VOS_STATUS_SUCCESS - Packet module was successfully closed.
271
272 VOS_STATUS_E_INVAL - Invalid parameter passed to the packet
273 close function
274
275 VOS_STATUS_E_FAILURE - Failure to close the vos Packet module
276
277 \sa vos_packet_open()
278
279---------------------------------------------------------------------------*/
280VOS_STATUS vos_packet_close( v_PVOID_t pVosContext );
281
282#endif // !defined( __I_VOS_PACKET_H )