blob: 3aa0a33b55ebbb829aedda2953b509403573c7b5 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Bhargav Shah53ff2202016-02-12 20:49:58 +05302 * Copyright (c) 2011-2016 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.
20 */
21
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 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28#if !defined( __VOS_PKT_H )
29#define __VOS_PKT_H
30
31/**=========================================================================
32
33 \file vos_packet.h
34
35 \brief virtual Operating System Services (vOSS) network Packet APIs
36
37 Network Protocol packet/buffer support interfaces
38
Kiet Lamaa8e15a2014-02-11 23:30:06 -080039
Jeff Johnson295189b2012-06-20 16:38:30 -070040 ========================================================================*/
41
42/* $Header$ */
43
44/*--------------------------------------------------------------------------
45 Include Files
46 ------------------------------------------------------------------------*/
47#include <vos_types.h>
48#include <vos_status.h>
49
50/*--------------------------------------------------------------------------
51 Preprocessor definitions and constants
52 ------------------------------------------------------------------------*/
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080053#define VOS_PKT_PROTO_TYPE_EAPOL 0x02
54#define VOS_PKT_PROTO_TYPE_DHCP 0x04
Mihir Shete39f7c752015-06-11 15:40:09 +053055#define VOS_PKT_PROTO_TYPE_ARP 0x08
Jeff Johnson295189b2012-06-20 16:38:30 -070056/*--------------------------------------------------------------------------
57 Type declarations
58 ------------------------------------------------------------------------*/
59struct vos_pkt_t;
60typedef struct vos_pkt_t vos_pkt_t;
61
62
63/// data vector
64typedef struct
65{
66 /// address of data
67 v_VOID_t *pData;
68
69 /// number of bytes at address
70 v_U32_t numBytes;
71
72} vos_pkt_data_vector_t;
73
74
75
76/// voss Packet Types
77typedef enum
78{
79 /// voss Packet is used to transmit 802.11 Management frames.
80 VOS_PKT_TYPE_TX_802_11_MGMT,
81
82 /// voss Packet is used to transmit 802.11 Data frames.
83 VOS_PKT_TYPE_TX_802_11_DATA,
84
85 /// voss Packet is used to transmit 802.3 Data frames.
86 VOS_PKT_TYPE_TX_802_3_DATA,
87
88 /// voss Packet contains Received data of an unknown frame type
89 VOS_PKT_TYPE_RX_RAW,
90
91 /// Invalid sentinel value
92 VOS_PKT_TYPE_MAXIMUM
93
94} VOS_PKT_TYPE;
95
96/// user IDs. These IDs are needed on the vos_pkt_get/set_user_data_ptr()
97/// to identify the user area in the voss Packet.
98typedef enum
99{
100 VOS_PKT_USER_DATA_ID_TL =0,
101 VOS_PKT_USER_DATA_ID_BAL,
102 VOS_PKT_USER_DATA_ID_WDA,
103 VOS_PKT_USER_DATA_ID_HDD,
104 VOS_PKT_USER_DATA_ID_BAP,
105 VOS_PKT_USER_DATA_ID_BSL,
106
107 VOS_PKT_USER_DATA_ID_MAX
108
109} VOS_PKT_USER_DATA_ID;
110
111/**------------------------------------------------------------------------
112
113 \brief voss asynchronous get_packet callback function
114
115 This is a callback function invoked when vos_pkt_get_packet() cannot
116 get the requested packet and the caller specified a callback to be
117 invoked when packets are available.
118
119 \param pPacket - the packet obtained by voss for the caller.
120
121 \param userData - the userData field given on the vos_pkt_get_packet()
122 call
123
124 \return
125
126 \sa
127
128 ------------------------------------------------------------------------*/
129typedef VOS_STATUS ( *vos_pkt_get_packet_callback )( vos_pkt_t *pPacket,
130 v_VOID_t *userData );
131
132/*
133 * include the OS-specific packet abstraction
134 * we include it here since the abstraction probably needs to access the
135 * generic types defined above
136 */
137#include "i_vos_packet.h"
138
139/*-------------------------------------------------------------------------
140 Function declarations and documenation
141 ------------------------------------------------------------------------*/
142
143/**--------------------------------------------------------------------------
144
145 \brief vos_pkt_get_packet() - Get a voss Packets
146
147 Gets a voss Packets from an internally managed packet pool.
148
149 \param ppPacket - pointer to location where the voss Packet pointer is
150 returned. If multiple packets are requested, they
151 will be chained onto this first packet.
152
153 \param pktType - the packet type to be retreived. Valid packet types are:
154 <ul>
155 <li> VOS_PKT_TYPE_TX_802_11_MGMT - voss packet is for Transmitting 802.11
156 Management frames.
157
158 <li> VOS_PKT_TYPE_RX_RAW - voss Packet contains a buffer for Receiving
159 raw frames of unknown type.
160 </ul>
161
162 \param dataSize - the Data size needed in the voss Packet.
163
164 \param numPackets - the number of packets requested.
165
166 \param zeroBuffer - parameter that tells the API to zero the data buffer
167 in this voss Packet.
168 <ul>
169 <li> VOS_TRUE - the API will zero out the entire data buffer.
170
171 <li> VOS_FALSE - the API will not zero out the data buffer.
172 </ul>
173
174 \note If enough room for headers to transmit or receive the packet is not
175 available, this API will fail.
176
177 \param callback - This callback function, if provided, is invoked in the
178 case when resources are not available at the time of the call to
179 get packets. This callback function is invoked when packets are
180 available.
181
182 \param userData - This user data is passed back to the caller in the
183 callback function, if the callback is invoked.
184
185 \return VOS_STATUS_SUCCESS - the API was able to get a vos_packet for the
186 requested type. *ppPacket contains a pointer to the packet.
187
188 VOS_STATUS_E_INVAL - pktType is not a valid packet type. This
189 API only supports getting vos packets for 802_11_MGMT and
190 RX_RAW packet types. This status is also returned if the
191 numPackets or dataSize are invalid.
192
193 VOS_STATUS_E_RESOURCES - unable to get resources needed to get
194 a vos packet. If a callback function is specified and this
195 status is returned from the API, the callback will be called
196 when resources are available to fulfill the original request.
197
198 Note that the low resources condition is indicated to the caller
199 by returning VOS_STATUS_E_RESOURCES. This status is the only
200 non-success status that indicates to the caller that the callback
201 will be called when resources are available. All other status
202 indicate failures that are not recoverable and the 'callback'
203 will not be called.
204
205 VOS_STATUS_E_FAILURE - The API returns this status when unable
206 to get a packet from the packet pool because the pool
207 is depleted and the caller did not specify a low resource callback.
208
209 VOS_STATUS_E_ALREADY - This status is returned when the VOS
210 packet pool is in a 'low resource' condition and cannot
211 accomodate any more calls to retrieve packets from that
212 pool. Note this is a FAILURE and the 'low resource' callback
213 will *not* be called.
214
215 VOS_STATUS_E_FAULT - ppPacket does not specify a valid pointer.
216
217 \sa
218
219 ------------------------------------------------------------------------*/
220VOS_STATUS vos_pkt_get_packet( vos_pkt_t **ppPacket, VOS_PKT_TYPE pktType,
221 v_SIZE_t dataSize, v_SIZE_t numPackets,
222 v_BOOL_t zeroBuffer,
223 vos_pkt_get_packet_callback callback,
224 v_VOID_t *userData );
225
226
227/**--------------------------------------------------------------------------
228
229 \brief vos_pkt_wrap_data_packets() - Wrap an OS provided data packet in a
230 vos packet.
231
232 Takes as input an OS provided data packet and 'wraps' that packet in a
233 vos_packet, returning the vos_packet to the caller.
234
235 This function is intended to be called from the HDD to wrap Tx data packets
236 from the OS into vos_packets before sending them to TL for transmission.
237
238 \param ppPacket - pointer to location where the voss Packet pointer is
239 returned. If multiple packets are requested, they
240 will be chained onto this first packet.
241
242 \param pktType - the packet type to be retreived. Valid packet types are:
243 <ul>
244 <li> VOS_PKT_TYPE_802_3_DATA - voss packet is for Transmitting 802.3
245 data frames.
246
247 <li> VOS_PKT_TYPE_802_11_DATA - voss Packet is for Transmitting 802.11
248 data frames.
249 </ul>
250
251 \param pOSPacket - a pointer to the Transmit packet provided by the OS. This
252 OS provided packet will be wrapped into a vos_packet_t. Note this
253 OS packet pointer can be NULL. The OS packet pointer can be inserted
254 into a VOS packet of type VOS_PKT_TYPE_802_3_DATA or
255 VOS_PKT_TYPE_802_11_DATA through vos_pkt_set_os_packet().
256
257 \note If enough room for headers to transmit or receive the packet is not
258 available, this API will fail.
259
260 \param callback - This callback function, if provided, is invoked in the
261 case where packets are not available at the time of the call to
262 return the packets to the caller (a 'low resource' condition).
263
264 When packets become available, the callback callback function is
265 invoked to return a VOS packet to the caller. Note that the
266 OS Packet is *not* inserted into the VOS packet when it is returned
267 to the low resource callback. It is up to the caller to insert
268 the OS packet into the VOS packet by calling vos_pkt_set_os_packet()
269
270 \param userData - This user data is passed back to the caller in the
271 callback function, if the callback is invoked.
272
273 \return VOS_STATUS_SUCCESS - the API was able to get a vos_packet for the
274 requested type. *ppPacket contains a pointer to the packet.
275
276 VOS_STATUS_E_INVAL - pktType is not a valid packet type. This
277 API only supports getting vos packets for 802_11_MGMT and
278 RX_RAW packet types.
279
280 VOS_STATUS_E_RESOURCES - unable to get resources needed to get
281 a vos packet. If a callback function is specified and this
282 status is returned from the API, the callback will be called
283 when resources are available to fulfill the original request.
284
285 Note that the low resources condition is indicated to the caller
286 by returning VOS_STATUS_E_RESOURCES. This status is the only
287 non-success status that indicates to the caller that the callback
288 will be called when resources are available. All other status
289 indicate failures that are not recoverable and the 'callback'
290 will not be called.
291
292 VOS_STATUS_E_FAILURE - The API returns this status when unable
293 to get a packet from the packet pool because the pool
294 is depleted and the caller did not specify a low resource callback.
295
296 VOS_STATUS_E_ALREADY - This status is returned when the VOS
297 packet pool is in a 'low resource' condition and cannot
298 accomodate any more calls to retrieve packets from that
299 pool. Note this is a FAILURE and the 'low resource' callback
300 will *not* be called.
301
302 VOS_STATUS_E_FAULT - ppPacket or pOSPacket do not specify valid
303 pointers.
304
305 \sa vos_pkt_set_os_packet()
306
307 ------------------------------------------------------------------------*/
308VOS_STATUS vos_pkt_wrap_data_packet( vos_pkt_t **ppPacket, VOS_PKT_TYPE pktType,
309 v_VOID_t *pOSPacket,
310 vos_pkt_get_packet_callback callback,
311 v_VOID_t *userData );
312
313
314/*---------------------------------------------------------------------------
315
316 \brief vos_pkt_set_os_packet() - set the OS packet in a VOS data packet
317
318 This API inserts an OS packet into a previously retreived VOS packet.
319 This API only applies to VOS packets of type VOS_PKT_TYPE_802_3_DATA or
320 VOS_PKT_TYPE_802_11_DATA.
321
322 There are cases where a user will need to get a VOS data packet without
323 having the OS packet to insert/wrap into the data packet. This could happen
324 if the user calls vos_pkt_wrap_data_packet() without the OS packet.
325
326 Also, when the user hit a 'low resource' situation for data packets, the
327 low resource callback is going to return a VOS packet without an OS packet
328 attached to it. The caller who gets the packet through the low resource
329 callback uses this API to insert an OS packet into the VOS packet that
330 was returned through the low resource callback.
331
332 \param pPacket - the voss Packet to insert the OS packet into.
333
334 \param pOSPacket - a pointer to the Transmit packet provided by the OS. This
335 OS provided packet will be wrapped into a vos_packet_t. Note this
336 OS packet pointer can be NULL. The OS packet pointer can be inserted
337 into a VOS packet of type VOS_PKT_TYPE_802_3_DATA or
338 VOS_PKT_TYPE_802_11_DATA through vos_pkt_set_os_packet().
339
340 Caller beware. If there is a valid OS packet wrapped into this
341 VOS packet already, this API will blindly overwrite the OS packet
342 with the new one specified on this API call. If you need to determine
343 or retreive the current OS packet from a VOS packet, call
344 vos_pkt_get_os_packet() first.
345
346 \return VOS_STATUS_SUCCESS - the API was able to insert the OS packet into
347 the vos_packet.
348
349 VOS_STATUS_E_INVAL - pktType is not a valid packet type. This
350 API only supports getting vos packets of type
351 VOS_PKT_TYPE_802_3_DATA or VOS_PKT_TYPE_802_11_DATA.
352
353 VOS_STATUS_E_FAULT - pPacket does not specify a valid pointer.
354
355 \sa vos_pkt_get_os_packet()
356
357 ----------------------------------------------------------------------------*/
358VOS_STATUS vos_pkt_set_os_packet( vos_pkt_t *pPacket, v_VOID_t *pOSPacket );
359
360
361
362/*---------------------------------------------------------------------------
363
364 \brief vos_pkt_get_os_packet() - get the OS packet in a VOS data packet
365
366 This API returns the OS packet that is inserted in a VOS packet.
367 This API only applies to VOS packets of type VOS_PKT_TYPE_802_3_DATA or
368 VOS_PKT_TYPE_802_11_DATA.
369
370 \param pPacket - the voss Packet to return the OS packet from.
371
372 \param ppOSPacket - a pointer to the location where the OS packet pointer
373 retreived from the VOS packet will be returned. Note this OS packet
374 pointer can be NULL, meaning there is no OS packet attached to this
375 VOS data packet.
376
377 \param clearOSPacket - a boolean value that tells the API to clear out the
378 OS packet pointer from the VOS packet. Setting this to 'true' will
379 essentially remove the OS packet from the VOS packet. 'false' means
380 the OS packet remains chained to the VOS packet. In either case,
381 the OS packet pointer is returned to the caller.
382
383 \return VOS_STATUS_SUCCESS - the API was able to retreive the OS packet
384 pointer from the VOS packet and return it to the caller in
385 *ppOsPacket
386
387 VOS_STATUS_E_INVAL - pktType is not a valid packet type. This
388 API only supports getting vos packets of type
389 VOS_PKT_TYPE_802_3_DATA or VOS_PKT_TYPE_802_11_DATA.
390
391 VOS_STATUS_E_FAULT - pPacket or ppOsPacket does not specify a valid
392 pointers.
393
394 \sa vos_pkt_set_os_packet(), vos_pkt_wrap_data_packet(), vos_pkt_return_packet()
395
396 ----------------------------------------------------------------------------*/
397VOS_STATUS vos_pkt_get_os_packet( vos_pkt_t *pPacket, v_VOID_t **ppOSPacket,
398 v_BOOL_t clearOSPacket );
399
400
401/**--------------------------------------------------------------------------
402
403 \brief vos_pkt_get_user_data_ptr() - return a pointer to user data area
404 of a voss Packet
405
406 This API returns a pointer to a specified user Data area in the voss
407 Packet. User data areas are uniqua areas of the voss Packet that can
408 be used by specific components to store private data. These areas are
409 identified by a user "ID" and should only be accessed by the component
410 specified.
411
412 \param pPacket - the voss Packet to retreive the user data pointer from.
413
414 \param userID - the identifier for the user data area in the voss Packet
415 to get.
416
417 User IDs and user data areas in the voss Packet are
418 available for:
419 - Transport Layer (TL)
420 - Bus Abstraction Layer (BAL)
421 - SDIO Services Component (SSC)
422 - Host Device Driver (HDD)
423
424 \param ppUserData - pointer to location to return the pointer to the user
425 data.
426
427 \return - Nothing.
428
429 \sa
430
431 ----------------------------------------------------------------------------*/
432v_VOID_t vos_pkt_get_user_data_ptr( vos_pkt_t *pPacket, VOS_PKT_USER_DATA_ID userID,
433 v_VOID_t **ppUserData );
434
435
436/**--------------------------------------------------------------------------
437
438 \brief vos_pkt_set_user_data_ptr() - set the user data pointer of a voss
439 Packet
440
441 This API sets a pointer in the specified user Data area in the voss
442 Packet. User data areas are uniqua areas of the voss Packet that can
443 be used by specific components to store private data. These areas are
444 identified by a user "ID" and should only be accessed by the component
445 specified.
446
447 Note: The size of the user data areas in the voss Packet are fixed. The
448 size of a single pointer is available in each user area.
449
450 \param pPacket - the voss Packet to set the user pointer.
451
452 \param userID - the identifier for the user data area in the voss Packet
453 to set.
454
455 User IDs and user data areas in the voss Packet are
456 available for:
457 - Transport Layer (TL)
458 - Bus Abstraction Layer (BAL)
459 - SDIO Services Component (SSC)
460 - Host Device Driver (HDD)
461
462 \param pUserData - pointer value to set in the user data area of the voss
463 packet..
464
465 \return - Nothing.
466
467 \sa
468
469 ----------------------------------------------------------------------------*/
470v_VOID_t vos_pkt_set_user_data_ptr( vos_pkt_t *pPacket, VOS_PKT_USER_DATA_ID userID,
471 v_VOID_t *pUserData );
472
473/**--------------------------------------------------------------------------
474
475 \brief vos_pkt_return_packet() - Return a voss Packet (chain) to vOSS
476
477 This API returns a voss Packet to the internally managed packet pool.
478
479 Note: If there are multiple packets chained to this packet, the entire
480 packet chain is returned to vOSS. The caller must unchain the
481 packets throgh vos_pkt_get_next_packet() and return them individually
482 if all packets in the packet chain are not to be returned.
483
484 \param pPacket - the voss Packet(s) to return. Note all packets chained
485 to this packet are returned to vOSS.
486
487 \return
488
489 \sa
490
491 ----------------------------------------------------------------------------*/
492VOS_STATUS vos_pkt_return_packet( vos_pkt_t *pPacket );
493
494
495/**--------------------------------------------------------------------------
496
497 \brief vos_pkt_chain_packet() - chain a voss Packet to another packet
498
499 This API chains a voss Packet to another voss Packet, creating a packet
500 chain. Packets can be chained before or after the current packet in the
501 packet chain.
502
503 \param pPacket - pointer to a voss packet to chain to
504
505 \param pChainPacket - pointer to packet to chain
506
507 \param chainAfter - boolean to specify to chain packet after or before
508 the input packet
509 <ul>
510 <li> true - chain packet AFTER pPacket (chain behind)
511 <li> false - chain packet BEFORE pPacket (chain in front)
512 </ul>
513
514 \return
515
516 \sa
517
518 ----------------------------------------------------------------------------*/
519VOS_STATUS vos_pkt_chain_packet( vos_pkt_t *pPacket, vos_pkt_t *pChainPacket,
520 v_BOOL_t chainAfter );
521
522
523/**--------------------------------------------------------------------------
524
525 \brief vos_pkt_walk_packet_chain() - Walk packet chain and (possibly)
526 unchain packets
527
528 This API will walk the voss Packet and unchain the packet from the chain,
529 if specified. The 'next' packet in the packet chain is returned as the
530 packet chain is traversed.
531
532 \param pPacket - input vos_packet walk
533
534 \param ppChainedPacket - pointer to location to return the 'next' voss
535 packet pointer in the packet chain.
536 NULL means there is was not packet chained
537 to this packet.
538
539 \param unchainPacket - Flag that specifies if the caller wants the packet
540 to be removed from the packet chain. This is
541 provided to allow the caller to walk the packet chain
542 with or without breaking the chain.
543
544 <ul>
545 <li> true - when set 'true' the API will return
546 the 'next' packet pointer in the voss Packte chain and
547 *WILL* unchain the input packet from the packet chain.
548
549 <li> NOT false - when set 'false' the API will return
550 the 'next' packet pointer in the voss Packet chain but
551 *WILL NOT* unchain the packet chain. This option gives
552 the caller the ability to walk the packet chain without
553 modifying it in the process.
554 </ul>
555
556 \note Having the packets chained has an implicaiton on how the return
557 packet API (vos_pkt_return_packet() ) operates.
558
559 \return
560
561 \sa
562
563 ----------------------------------------------------------------------------*/
564VOS_STATUS vos_pkt_walk_packet_chain( vos_pkt_t *pPacket, vos_pkt_t **ppChainedPacket,
565 v_BOOL_t unchainPacket );
566
567
568/**--------------------------------------------------------------------------
569
570 \brief vos_pkt_get_data_vector() - Get data vectors from a voss Packet
571
572 This API gets the complete set of Vectors (pointer / length pairs) that
573 describe all of the data that makes up the voss Packet.
574
575 \param pPacket - pointer to the vOSS Packet to get the pointer/length
576 vector from
577
578 \param pVector - pointer to the vector array where the vectors are returned.
579
580 \param pNumVectors - Number of vector's in the vector array (at pVector).
581 On successful return, *pNumVectors is updated with the
582 number of pointer/length vectors at pVector populated
583 with valid vectors.
584
585 Call with NULL pVector or 0 vectorSize, will return the size of vector
586 needed (in *pNumVectors)
587
588 Caller allocates and frees the vector memory.
589
590 \return
591
592 \sa
593
594 ----------------------------------------------------------------------------*/
595VOS_STATUS vos_pkt_get_data_vector( vos_pkt_t *pPacket, vos_pkt_data_vector_t *pVector,
596 v_SIZE_t *pNumVectors );
597
598
599/**--------------------------------------------------------------------------
600
601 \brief vos_pkt_extract_data() - Extract data from the voss Packet.
602
603 This API extracts data from a voss Packet, copying the data into the
604 supplied output buffer. Note the data is copied from the vos packet
605 but the data remains in the vos packet and the size is unaffected.
606
607 \param pPacket - the voss Packet to get the data from.
608
609 \param pktOffset - the offset from the start of the voss Packet to get the
610 data. (i.e. 0 would be the beginning of the voss Packet).
611
612 \param pOutputBuffer - Pointer to the location where the voss Packet data
613 will be copied.
614
615 \param pOutputBufferSize - on input, contains the amount of data to extract
616 into the output buffer. Upon return, contains the amount of data
617 extracted into the output buffer.
618
619 Note: an input of 0 in *pOutputBufferSize, means to copy *all*
620 data in the voss Packet into the output buffer. The caller is
621 responsible for assuring the output buffer size is big enough
622 since the size of the buffer is not being passed in!
623
624 \return
625
626 \sa
627
628 ----------------------------------------------------------------------------*/
629VOS_STATUS vos_pkt_extract_data( vos_pkt_t *pPacket, v_SIZE_t pktOffset,
630 v_VOID_t *pOutputBuffer, v_SIZE_t *pOutputBufferSize );
631
632
633/**--------------------------------------------------------------------------
634
635 \brief vos_pkt_extract_data_chain() - Extract data from a voss Packet chain.
636
637 This API extracts *all* the data from a voss Packet chain, copying the
638 data into the supplied output buffer. Note the data is copied from
639 the vos packet chain but the data remains in the vos packet and the
640 size of the vos packets are unaffected.
641
642 \param pPacket - the first voss Packet in the voss packet chain to
643 extract data.
644
645 \param pOutputBuffer - Pointer to the location where the voss Packet data
646 will be copied.
647
648 \param pOutputBufferSize - on input, contains the maximum amount of data
649 that can be extracted into the output buffer. Upon return, contains
650 the amount of data extracted from the packet chain.
651
652 \return VOS_STATUS_SUCCESS - the data from the entire packet chain is
653 extracted and found at *pOutputBuffer. *pOutputBufferSize bytes
654 were extracted.
655
656 VOS_STATUS_E_FAULT - pPacket, pOutputBuffer, or pOutputBufferSize
657 is not a valid pointer.
658
659 VOS_STATUS_E_NOMEM - there is not enough room to extract the data
660 from the entire packet chain. *pOutputBufferSize has been updated
661 with the size needed to extract the entier packet chain.
662
663 \sa vos_pkt_extract_data()
664
665 ----------------------------------------------------------------------------*/
666VOS_STATUS vos_pkt_extract_data_chain( vos_pkt_t *pPacket, v_VOID_t *pOutputBuffer,
667 v_SIZE_t *pOutputBufferSize );
668
669
670
671/**--------------------------------------------------------------------------
672
673 \brief vos_pkt_peek_data() - peek into voss Packet at given offset
674
675 This API provides a pointer to a specified offset into a voss Packet,
676 allowing the caller to peek at a given number of bytes in the voss Packet.
677 Upon successful return, the caller can access "numBytes" of data at
678 "pPacketData".
679
680 This API will fail if the data length requested to peek at is not in
681 contiguous memory in the voss Packet. In this case, the caller should
682 use vos_pkt_extract_data() to have the data copied into a caller supplied
683 buffer.
684
685 \param pPacket - the vOSS Packet to peek into
686
687 \param pktOffset - the offset into the voss Packet data to peek into.
688
689 \param ppPacketData - pointer to the location where the pointer to the
690 packet data at pktOffset will be returned.
691
692 \param numBytes - the number of bytes the caller wishes to peek at.
693
694 \return
695
696 \sa
697
698 ----------------------------------------------------------------------------*/
699VOS_STATUS vos_pkt_peek_data( vos_pkt_t *pPacket, v_SIZE_t pktOffset,
700 v_VOID_t **ppPacketData, v_SIZE_t numBytes );
701
702
703/**--------------------------------------------------------------------------
704
705 \brief vos_pkt_get_packet_type() - Get packet type for a voss Packet
706
707 This API returns the packet Type for a voss Packet.
708
709 \param pPacket - the voss Packet to get the packet type from.
710
711 \param pPacketType - location to return the packet type for the voss Packet
712
713 \return
714
715 \sa
716
717 ----------------------------------------------------------------------------*/
718VOS_STATUS vos_pkt_get_packet_type( vos_pkt_t *pPacket, VOS_PKT_TYPE *pPacketType );
719
720
721/**--------------------------------------------------------------------------
722
723 \brief vos_pkt_get_packet_length() - Get packet length for a voss Packet
724
725 This API returns the total length of the data in a voss Packet.
726
727 \param pPacket - the voss Packet to get the packet length from.
728
729 \param pPacketSize - location to return the total size of the data contained
730 in the voss Packet.
731 \return
732
733 \sa
734
735 ----------------------------------------------------------------------------*/
736VOS_STATUS vos_pkt_get_packet_length( vos_pkt_t *pPacket, v_U16_t *pPacketSize );
737
738
739/**--------------------------------------------------------------------------
740
741 \brief vos_pkt_get_packet_chain_length() - Get length of a vos packet chain
742
743 This API returns the total length of the data in a voss Packet chain.
744
745 \param pPacket - the voss Packet at the start of the packet chain. This API
746 will calculate the length of data in the packet chain stating with
747 this packet.
748
749 \param pPacketSize - location to return the total size of the data contained
750 in the voss Packet.
751 \return
752
753 \sa
754
755 ----------------------------------------------------------------------------*/
756VOS_STATUS vos_pkt_get_packet_chain_length( vos_pkt_t *pPacketChain, v_SIZE_t *pPacketChainSize );
757
758
759
760
761/**--------------------------------------------------------------------------
762
763 \brief vos_pkt_push_head() - push data on the front a of a voss Packet
764
765 This API will push data onto the front of a voss Packet. The data will be
766 appended in front of any data already contained in the voss Packet.
767
768 \param pPacket - the voss Packet to modify.
769
770 \param pData - pointer to the data to push onto the head of the voss Packet.
771
772 \param dataSize - the size of the data to put onto the head of the voss Packet.
773
774 \return
775
776 \sa
777
778 ----------------------------------------------------------------------------*/
779VOS_STATUS vos_pkt_push_head( vos_pkt_t *pPacket, v_VOID_t *pData, v_SIZE_t dataSize );
780
781
782/**--------------------------------------------------------------------------
783
784 \brief vos_pkt_reserve_head() - Reserve space at the front of a voss Packet
785
786 This API will reserve space at the front of a voss Packet. The caller can
787 then copy data into this reserved space using memcpy() like functions. This
788 allows the caller to reserve space and build headers directly in this
789 reserved space in the voss Packet.
790
791 Upon successful return, the length of the voss Packet is increased by
792 dataSize.
793
794 < put a before / after picture here>
795
796 \param pPacket - the voss Packet to modify.
797
798 \param ppData - pointer to the location where the pointer to the reserved
799 space is returned. Upon successful return, the caller has
800 write / read access to the data space at *ppData for length
801 dataSize to build headers, etc.
802
803 \param dataSize - the size of the data to reserve at the head of the voss
804 Packet. Upon successful return, the length of the voss
805 Packet is increased by dataSize.
806
807 \return
808
809 \sa
810
811 ----------------------------------------------------------------------------*/
812VOS_STATUS vos_pkt_reserve_head( vos_pkt_t *pPacket, v_VOID_t **ppData,
813 v_SIZE_t dataSize );
814
815/**--------------------------------------------------------------------------
816
817 \brief vos_pkt_reserve_head_fast()- Reserve space at the front of a voss Pkt
818
819 This API will reserve space at the front of a voss Packet. The caller can
820 then copy data into this reserved space using memcpy() like functions. This
821 allows the caller to reserve space and build headers directly in this
822 reserved space in the voss Packet.
823
824 Upon successful return, the length of the voss Packet is increased by
825 dataSize.
826
827 Same as above API but no memset to 0.
828
829 < put a before / after picture here>
830
831 \param pPacket - the voss Packet to modify.
832
833 \param ppData - pointer to the location where the pointer to the reserved
834 space is returned. Upon successful return, the caller has
835 write / read access to the data space at *ppData for length
836 dataSize to build headers, etc.
837
838 \param dataSize - the size of the data to reserve at the head of the voss
839 Packet. Upon successful return, the length of the voss
840 Packet is increased by dataSize.
841
842 \return
843
844 \sa
845
846 ----------------------------------------------------------------------------*/
847VOS_STATUS vos_pkt_reserve_head_fast( vos_pkt_t *pPacket,
848 v_VOID_t **ppData,
849 v_SIZE_t dataSize );
850
851/**--------------------------------------------------------------------------
852
853 \brief vos_pkt_pop_head() - Remove data from the front of the voss Packet
854
855 This API removes data from the front of a voss Packet. The data is
856 copied into the output buffer described by pData and pDataSize
857
858 \param pPacket - the voss Packet to operate on.
859
860 \param pData - pointer to the data buffer where the data removed from the
861 voss Packet is placed.
862
863 \param dataSize - The amount of space to remove from the head of the voss
864 Packet. The output buffer (at *pData) must contain at
865 least this amount of space.
866
867 \return
868
869 \sa
870
871 ----------------------------------------------------------------------------*/
872VOS_STATUS vos_pkt_pop_head( vos_pkt_t *pPacket, v_VOID_t *pData, v_SIZE_t dataSize );
873
874
875/**--------------------------------------------------------------------------
876
877 \brief vos_pkt_trim_head() - Skip over bytes at the front of a voss Packet
878
879 This API moves the pointers at the head of a voss Packet to essentially
880 skip over data at the front of a voss Packet. Upon successful return, the
881 length of the voss Packet is reduced by dataSize and the starting pointer
882 to the voss Packet is adjusted to eliminate the data from the start of the
883 voss Packet.
884
885 This API has the opposite effect of \a vos_pkt_reserve_head().
886
887 \param pPacket - the voss Packet to operate on.
888
889 \param dataSize - The amount of space to skip at the start of the voss
890 Packet.
891
892 Note that upon return, the data skipped over is
893 inaccessible to the caller. If the caller needs access
894 to the head data, use vos_pkt_pop_head() or
895 vos_pkt_extract_data() to get a copy of the data.
896
897 \return
898
899 \sa
900
901 ----------------------------------------------------------------------------*/
902VOS_STATUS vos_pkt_trim_head( vos_pkt_t *pPacket, v_SIZE_t dataSize );
903
904
905/**--------------------------------------------------------------------------
906
907 \brief vos_pkt_push_tail() - push data on the end a of a voss Packet
908
909 This API will push data onto the end of a voss Packet. The data will be
910 appended to the end of any data already contained in the voss Packet.
911
912 \param pPacket - the voss Packet to modify.
913
914 \param pData - pointer to the data to push onto the tail of the voss Packet.
915
916 \param dataSize - the size of the data to put onto the tail of the voss Packet.
917
918 \return
919
920 \sa
921
922 ----------------------------------------------------------------------------*/
923VOS_STATUS vos_pkt_push_tail( vos_pkt_t *pPacket, v_VOID_t *pData, v_SIZE_t dataSize );
924
925
926/**--------------------------------------------------------------------------
927
928 \brief vos_pkt_reserve_tail() - Reserve space at the end of a voss Packet
929
930 This API will reserve space at the end of a voss Packet. The caller can
931 then copy data into this reserved space using memcpy() like functions. This
932 allows the caller to reserve space and build headers directly in this
933 reserved space in the voss Packet.
934
935 Upon successful return, the length of the voss Packet is increased by
936 dataSize.
937
938 \param pPacket - the voss Packet to modify.
939
940 \param ppData - pointer to the location where the pointer to the reserved
941 space is returned. Upon successful return, the caller has
942 write / read access to the data space at *ppData for length
943 dataSize to build headers, etc.
944
945 \param dataSize - the size of the data to reserve at the head of the voss
946 Packet. Upon successful return, the length of the voss
947 Packet is increased by dataSize.
948
949 \return
950
951 \sa
952
953 ----------------------------------------------------------------------------*/
954VOS_STATUS vos_pkt_reserve_tail( vos_pkt_t *pPacket, v_VOID_t **ppData,
955 v_SIZE_t dataSize );
956
957
958/**--------------------------------------------------------------------------
959
960 \brief vos_pkt_pop_tail() - Remove data from the end of the voss Packet
961
962 This API removes data from the end of a voss Packet. The data is
963 copied into the output buffer described by pData and pDataSize
964
965 \param pPacket - the voss Packet to operate on.
966
967 \param pData - pointer to the data buffer where the data removed from the
968 voss Packet is placed.
969
970 \param dataSize - The amount of space to remove from the end of the voss
971 Packet. The output buffer (at *pData) must contain at
972 least this amount of space.
973
974 \return
975
976 \sa
977
978 ----------------------------------------------------------------------------*/
979VOS_STATUS vos_pkt_pop_tail( vos_pkt_t *pPacket, v_VOID_t *pData, v_SIZE_t dataSize );
980
981
982/**--------------------------------------------------------------------------
983
984 \brief vos_pkt_trim_tail() - Skip over bytes at the end of a voss Packet
985
986 This API moves the pointers at the head of a voss Packet to essentially
987 skip over data at the end of a voss Packet. Upon successful return, the
988 length of the voss Packet is reduced by dataSize and voss Packet is
989 adjusted to eliminate the data from the end of the voss Packet.
990
991 This API has the opposite effect of \a vos_pkt_reserve_tail().
992
993 \param pPacket - the voss Packet to operate on.
994
995 \param dataSize - The amount of space to remove at the end of the voss
996 Packet.
997
998 Note that upon return, the data skipped over is
999 inaccessible to the caller. If the caller needs access
1000 to the tail data, use vos_pkt_pop_tail() or
1001 vos_pkt_extract_data() to get a copy of the data.
1002
1003 \return
1004
1005 \sa
1006
1007 ----------------------------------------------------------------------------*/
1008VOS_STATUS vos_pkt_trim_tail( vos_pkt_t *pPacket, v_SIZE_t dataSize );
1009
1010/**--------------------------------------------------------------------------
1011
1012 \brief vos_pkt_get_timestamp() - Retrive the timestamp attribute from the
1013 specified VOSS packet
1014
1015 \param pPacket - the voss Packet to operate on.
1016
1017 \param pTstamp - the timestamp will be returned here.
1018
1019 \return VOS_STATUS_E_FAULT - invalid parameter(s) specified
1020
1021 VOS_STATUS_SUCCESS - timestamp retrived successfully
1022
1023 \sa
1024
1025 ----------------------------------------------------------------------------*/
1026VOS_STATUS vos_pkt_get_timestamp( vos_pkt_t *pPacket, v_TIME_t* pTstamp );
1027
1028/**--------------------------------------------------------------------------
1029
1030 \brief vos_pkt_flatten_rx_pkt() - Transform a platform based RX VOSS
1031 packet into a flat buffer based VOSS packet if needed. This is needed in cases
1032 where for reasons of efficiency we want the RX packets to be very platform specific
1033 (for e.g. DSM based on AMSS, etc). However platform independent code may rely
1034 on making calls on the VOSS packet which can only be supported by the flat buffer
1035 based implementation of a RX packet. This API will allocate a new VOSS packet
1036 with flat buffer, extract the data from the input VOSS packet and then release
1037 the input VOSS packet. The new VOSS packet will be returned from this call.
1038
1039 \param ppPacket - the voss Packet to operate on. on input contains
1040 the platform based packet. On output contains the flat
1041 buffer based packet. Any applicable resources
1042 are freed as part of this call.
1043
1044 \return VOS_STATUS_E_FAULT - invalid parameter specified
1045
1046 VOS_STATUS_E_INVAL - packet type not RX_RAW
1047
1048 VOS_STATUS_SUCCESS - transform successful
1049
1050 other VOSS status - other errors encountered
1051
1052 \sa
1053
1054 ----------------------------------------------------------------------------*/
1055VOS_STATUS vos_pkt_flatten_rx_pkt( vos_pkt_t **ppPacket );
1056
1057/**--------------------------------------------------------------------------
1058
1059 \brief vos_pkt_set_rx_length() - Set the length of a received packet
1060
1061 This API set the length of the data inside the packet after a DMA has occurred
1062 on rx, it will also set the tail pointer to the end of the data.
1063
1064 \param pPacket - the voss Packet to operate on.
1065
1066 \param pktLen - The size of the data placed in the Rx packet during DMA.
1067
1068
1069 \return
1070
1071 \sa
1072
1073 ---------------------------------------------------------------------------*/
1074VOS_STATUS vos_pkt_set_rx_length( vos_pkt_t *pPacket, v_SIZE_t pktLen );
1075
1076/**--------------------------------------------------------------------------
1077
1078 \brief vos_pkt_get_available_buffer_pool() - Get avaliable VOS packet size
1079 VOSS Packet pool is limitted resource
1080 VOSS Client need to know how many packet pool is still avaliable to control the flow
1081
1082 \param pktType - Packet type want to know free buffer count
1083 VOS_PKT_TYPE_TX_802_11_MGMT, management free buffer count,
1084 VOS_PKT_TYPE_TX_802_11_DATA
1085 VOS_PKT_TYPE_TX_802_3_DATA, TX free buffer count
1086 VOS_PKT_TYPE_RX_RAW, RX free buffer count
1087
1088 vosFreeBuffer - free frame buffer size
1089
1090 \return VOS_STATUS_E_INVAL - invalid input parameter
1091
1092 VOS_STATUS_SUCCESS - Get size success
1093
1094 \sa
1095
1096 ----------------------------------------------------------------------------*/
1097VOS_STATUS vos_pkt_get_available_buffer_pool
1098(
1099 VOS_PKT_TYPE pktType,
1100 v_SIZE_t *vosFreeBuffer
1101);
1102
Sameer Thalappild0158402013-05-03 13:19:03 -07001103/**
1104 @brief vos_pkt_get_num_of_rx_raw_pkts() - Get the number of RX packets
1105 that should be allocated.
1106
1107 This function is called by VOS packet module to know how many RX raw
1108 packets it should allocate/reserve. This value can be configured thru
1109 Kernel device tree to save memory usage.
1110
1111 @param
1112 NONE
1113 @return
1114 v_SIZE_t the number of packets to allocate
1115
1116*/
1117v_SIZE_t vos_pkt_get_num_of_rx_raw_pkts(void);
1118
Mihir Sheted183cef2014-09-26 19:17:56 +05301119/**
1120 @brief vos_pkt_get_num_of_rx_pkt_alloc_failures() - Get the number of times
1121 skb allocation failed while replenishing packets
1122
1123
1124 @param
1125 NONE
1126 @return
1127 v_SIZE_t the number of times packet allocation failed
1128
1129*/
1130v_SIZE_t vos_pkt_get_num_of_rx_pkt_alloc_failures(void);
1131
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08001132v_U8_t vos_pkt_get_proto_type
1133(
1134 void *pskb,
1135 v_U8_t tracking_map
1136);
Bhargav Shah53ff2202016-02-12 20:49:58 +05301137
1138/**
1139 @brief vos_get_pkt_head() - Get skb head pointer
1140
1141 @param
1142 pPacket - the voss Packet to operate on
1143 @return
1144 v_PVOID_t - skb head pointer
1145
1146*/
1147v_PVOID_t vos_get_pkt_head(vos_pkt_t *pPacket);
1148
1149/**
1150
1151 @brief vos_get_pkt_end() - Get skb end pointer
1152
1153 @param
1154 pPacket - the voss Packet to operate on
1155 @return
1156 v_PVOID_t - skb end pointer
1157
1158*/
1159v_PVOID_t vos_get_pkt_end(vos_pkt_t *pPacket);
1160
1161/**
1162
1163 @brief vos_recover_tail() - Recover corrupted tail of skb
1164
1165 @param
1166 pPacket - the voss Packet to operate on
1167 @return
1168 v_VOID_t - None
1169
1170*/
1171v_VOID_t vos_recover_tail(vos_pkt_t *pPacket);
1172
Jeff Johnson295189b2012-06-20 16:38:30 -07001173#endif // !defined( __VOS_PKT_H )