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