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