blob: ab949c8704a8b0ed7b3bf8c8a8517f2b40704d78 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Asodi T,Venkateswara Reddy9826c872017-01-18 19:08:25 +05302 * Copyright (c) 2011-2017 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
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +0530568/**
569 * vos_is_pkt_chain() - Check for chain of packets
570 * @pPacket: pointer to chain of packet list
571 *
572 * Return: true if chain of packets or false otherwise
573 */
574bool vos_is_pkt_chain(vos_pkt_t *pPacket);
575
Jeff Johnson295189b2012-06-20 16:38:30 -0700576/**--------------------------------------------------------------------------
577
578 \brief vos_pkt_get_data_vector() - Get data vectors from a voss Packet
579
580 This API gets the complete set of Vectors (pointer / length pairs) that
581 describe all of the data that makes up the voss Packet.
582
583 \param pPacket - pointer to the vOSS Packet to get the pointer/length
584 vector from
585
586 \param pVector - pointer to the vector array where the vectors are returned.
587
588 \param pNumVectors - Number of vector's in the vector array (at pVector).
589 On successful return, *pNumVectors is updated with the
590 number of pointer/length vectors at pVector populated
591 with valid vectors.
592
593 Call with NULL pVector or 0 vectorSize, will return the size of vector
594 needed (in *pNumVectors)
595
596 Caller allocates and frees the vector memory.
597
598 \return
599
600 \sa
601
602 ----------------------------------------------------------------------------*/
603VOS_STATUS vos_pkt_get_data_vector( vos_pkt_t *pPacket, vos_pkt_data_vector_t *pVector,
604 v_SIZE_t *pNumVectors );
605
606
607/**--------------------------------------------------------------------------
608
609 \brief vos_pkt_extract_data() - Extract data from the voss Packet.
610
611 This API extracts data from a voss Packet, copying the data into the
612 supplied output buffer. Note the data is copied from the vos packet
613 but the data remains in the vos packet and the size is unaffected.
614
615 \param pPacket - the voss Packet to get the data from.
616
617 \param pktOffset - the offset from the start of the voss Packet to get the
618 data. (i.e. 0 would be the beginning of the voss Packet).
619
620 \param pOutputBuffer - Pointer to the location where the voss Packet data
621 will be copied.
622
623 \param pOutputBufferSize - on input, contains the amount of data to extract
624 into the output buffer. Upon return, contains the amount of data
625 extracted into the output buffer.
626
627 Note: an input of 0 in *pOutputBufferSize, means to copy *all*
628 data in the voss Packet into the output buffer. The caller is
629 responsible for assuring the output buffer size is big enough
630 since the size of the buffer is not being passed in!
631
632 \return
633
634 \sa
635
636 ----------------------------------------------------------------------------*/
637VOS_STATUS vos_pkt_extract_data( vos_pkt_t *pPacket, v_SIZE_t pktOffset,
638 v_VOID_t *pOutputBuffer, v_SIZE_t *pOutputBufferSize );
639
640
641/**--------------------------------------------------------------------------
642
643 \brief vos_pkt_extract_data_chain() - Extract data from a voss Packet chain.
644
645 This API extracts *all* the data from a voss Packet chain, copying the
646 data into the supplied output buffer. Note the data is copied from
647 the vos packet chain but the data remains in the vos packet and the
648 size of the vos packets are unaffected.
649
650 \param pPacket - the first voss Packet in the voss packet chain to
651 extract data.
652
653 \param pOutputBuffer - Pointer to the location where the voss Packet data
654 will be copied.
655
656 \param pOutputBufferSize - on input, contains the maximum amount of data
657 that can be extracted into the output buffer. Upon return, contains
658 the amount of data extracted from the packet chain.
659
660 \return VOS_STATUS_SUCCESS - the data from the entire packet chain is
661 extracted and found at *pOutputBuffer. *pOutputBufferSize bytes
662 were extracted.
663
664 VOS_STATUS_E_FAULT - pPacket, pOutputBuffer, or pOutputBufferSize
665 is not a valid pointer.
666
667 VOS_STATUS_E_NOMEM - there is not enough room to extract the data
668 from the entire packet chain. *pOutputBufferSize has been updated
669 with the size needed to extract the entier packet chain.
670
671 \sa vos_pkt_extract_data()
672
673 ----------------------------------------------------------------------------*/
674VOS_STATUS vos_pkt_extract_data_chain( vos_pkt_t *pPacket, v_VOID_t *pOutputBuffer,
675 v_SIZE_t *pOutputBufferSize );
676
677
678
679/**--------------------------------------------------------------------------
680
681 \brief vos_pkt_peek_data() - peek into voss Packet at given offset
682
683 This API provides a pointer to a specified offset into a voss Packet,
684 allowing the caller to peek at a given number of bytes in the voss Packet.
685 Upon successful return, the caller can access "numBytes" of data at
686 "pPacketData".
687
688 This API will fail if the data length requested to peek at is not in
689 contiguous memory in the voss Packet. In this case, the caller should
690 use vos_pkt_extract_data() to have the data copied into a caller supplied
691 buffer.
692
693 \param pPacket - the vOSS Packet to peek into
694
695 \param pktOffset - the offset into the voss Packet data to peek into.
696
697 \param ppPacketData - pointer to the location where the pointer to the
698 packet data at pktOffset will be returned.
699
700 \param numBytes - the number of bytes the caller wishes to peek at.
701
702 \return
703
704 \sa
705
706 ----------------------------------------------------------------------------*/
707VOS_STATUS vos_pkt_peek_data( vos_pkt_t *pPacket, v_SIZE_t pktOffset,
708 v_VOID_t **ppPacketData, v_SIZE_t numBytes );
709
710
711/**--------------------------------------------------------------------------
712
713 \brief vos_pkt_get_packet_type() - Get packet type for a voss Packet
714
715 This API returns the packet Type for a voss Packet.
716
717 \param pPacket - the voss Packet to get the packet type from.
718
719 \param pPacketType - location to return the packet type for the voss Packet
720
721 \return
722
723 \sa
724
725 ----------------------------------------------------------------------------*/
726VOS_STATUS vos_pkt_get_packet_type( vos_pkt_t *pPacket, VOS_PKT_TYPE *pPacketType );
727
728
729/**--------------------------------------------------------------------------
730
731 \brief vos_pkt_get_packet_length() - Get packet length for a voss Packet
732
733 This API returns the total length of the data in a voss Packet.
734
735 \param pPacket - the voss Packet to get the packet length from.
736
737 \param pPacketSize - location to return the total size of the data contained
738 in the voss Packet.
739 \return
740
741 \sa
742
743 ----------------------------------------------------------------------------*/
744VOS_STATUS vos_pkt_get_packet_length( vos_pkt_t *pPacket, v_U16_t *pPacketSize );
745
746
747/**--------------------------------------------------------------------------
748
749 \brief vos_pkt_get_packet_chain_length() - Get length of a vos packet chain
750
751 This API returns the total length of the data in a voss Packet chain.
752
753 \param pPacket - the voss Packet at the start of the packet chain. This API
754 will calculate the length of data in the packet chain stating with
755 this packet.
756
757 \param pPacketSize - location to return the total size of the data contained
758 in the voss Packet.
759 \return
760
761 \sa
762
763 ----------------------------------------------------------------------------*/
764VOS_STATUS vos_pkt_get_packet_chain_length( vos_pkt_t *pPacketChain, v_SIZE_t *pPacketChainSize );
765
766
767
768
769/**--------------------------------------------------------------------------
770
771 \brief vos_pkt_push_head() - push data on the front a of a voss Packet
772
773 This API will push data onto the front of a voss Packet. The data will be
774 appended in front of any data already contained in the voss Packet.
775
776 \param pPacket - the voss Packet to modify.
777
778 \param pData - pointer to the data to push onto the head of the voss Packet.
779
780 \param dataSize - the size of the data to put onto the head of the voss Packet.
781
782 \return
783
784 \sa
785
786 ----------------------------------------------------------------------------*/
787VOS_STATUS vos_pkt_push_head( vos_pkt_t *pPacket, v_VOID_t *pData, v_SIZE_t dataSize );
788
789
790/**--------------------------------------------------------------------------
791
792 \brief vos_pkt_reserve_head() - Reserve space at the front of a voss Packet
793
794 This API will reserve space at the front of a voss Packet. The caller can
795 then copy data into this reserved space using memcpy() like functions. This
796 allows the caller to reserve space and build headers directly in this
797 reserved space in the voss Packet.
798
799 Upon successful return, the length of the voss Packet is increased by
800 dataSize.
801
802 < put a before / after picture here>
803
804 \param pPacket - the voss Packet to modify.
805
806 \param ppData - pointer to the location where the pointer to the reserved
807 space is returned. Upon successful return, the caller has
808 write / read access to the data space at *ppData for length
809 dataSize to build headers, etc.
810
811 \param dataSize - the size of the data to reserve at the head of the voss
812 Packet. Upon successful return, the length of the voss
813 Packet is increased by dataSize.
814
815 \return
816
817 \sa
818
819 ----------------------------------------------------------------------------*/
820VOS_STATUS vos_pkt_reserve_head( vos_pkt_t *pPacket, v_VOID_t **ppData,
821 v_SIZE_t dataSize );
822
823/**--------------------------------------------------------------------------
824
825 \brief vos_pkt_reserve_head_fast()- Reserve space at the front of a voss Pkt
826
827 This API will reserve space at the front of a voss Packet. The caller can
828 then copy data into this reserved space using memcpy() like functions. This
829 allows the caller to reserve space and build headers directly in this
830 reserved space in the voss Packet.
831
832 Upon successful return, the length of the voss Packet is increased by
833 dataSize.
834
835 Same as above API but no memset to 0.
836
837 < put a before / after picture here>
838
839 \param pPacket - the voss Packet to modify.
840
841 \param ppData - pointer to the location where the pointer to the reserved
842 space is returned. Upon successful return, the caller has
843 write / read access to the data space at *ppData for length
844 dataSize to build headers, etc.
845
846 \param dataSize - the size of the data to reserve at the head of the voss
847 Packet. Upon successful return, the length of the voss
848 Packet is increased by dataSize.
849
850 \return
851
852 \sa
853
854 ----------------------------------------------------------------------------*/
855VOS_STATUS vos_pkt_reserve_head_fast( vos_pkt_t *pPacket,
856 v_VOID_t **ppData,
857 v_SIZE_t dataSize );
858
859/**--------------------------------------------------------------------------
860
861 \brief vos_pkt_pop_head() - Remove data from the front of the voss Packet
862
863 This API removes data from the front of a voss Packet. The data is
864 copied into the output buffer described by pData and pDataSize
865
866 \param pPacket - the voss Packet to operate on.
867
868 \param pData - pointer to the data buffer where the data removed from the
869 voss Packet is placed.
870
871 \param dataSize - The amount of space to remove from the head of the voss
872 Packet. The output buffer (at *pData) must contain at
873 least this amount of space.
874
875 \return
876
877 \sa
878
879 ----------------------------------------------------------------------------*/
880VOS_STATUS vos_pkt_pop_head( vos_pkt_t *pPacket, v_VOID_t *pData, v_SIZE_t dataSize );
881
882
883/**--------------------------------------------------------------------------
884
885 \brief vos_pkt_trim_head() - Skip over bytes at the front of a voss Packet
886
887 This API moves the pointers at the head of a voss Packet to essentially
888 skip over data at the front of a voss Packet. Upon successful return, the
889 length of the voss Packet is reduced by dataSize and the starting pointer
890 to the voss Packet is adjusted to eliminate the data from the start of the
891 voss Packet.
892
893 This API has the opposite effect of \a vos_pkt_reserve_head().
894
895 \param pPacket - the voss Packet to operate on.
896
897 \param dataSize - The amount of space to skip at the start of the voss
898 Packet.
899
900 Note that upon return, the data skipped over is
901 inaccessible to the caller. If the caller needs access
902 to the head data, use vos_pkt_pop_head() or
903 vos_pkt_extract_data() to get a copy of the data.
904
905 \return
906
907 \sa
908
909 ----------------------------------------------------------------------------*/
910VOS_STATUS vos_pkt_trim_head( vos_pkt_t *pPacket, v_SIZE_t dataSize );
911
912
913/**--------------------------------------------------------------------------
914
915 \brief vos_pkt_push_tail() - push data on the end a of a voss Packet
916
917 This API will push data onto the end of a voss Packet. The data will be
918 appended to the end of any data already contained in the voss Packet.
919
920 \param pPacket - the voss Packet to modify.
921
922 \param pData - pointer to the data to push onto the tail of the voss Packet.
923
924 \param dataSize - the size of the data to put onto the tail of the voss Packet.
925
926 \return
927
928 \sa
929
930 ----------------------------------------------------------------------------*/
931VOS_STATUS vos_pkt_push_tail( vos_pkt_t *pPacket, v_VOID_t *pData, v_SIZE_t dataSize );
932
933
934/**--------------------------------------------------------------------------
935
936 \brief vos_pkt_reserve_tail() - Reserve space at the end of a voss Packet
937
938 This API will reserve space at the end of a voss Packet. The caller can
939 then copy data into this reserved space using memcpy() like functions. This
940 allows the caller to reserve space and build headers directly in this
941 reserved space in the voss Packet.
942
943 Upon successful return, the length of the voss Packet is increased by
944 dataSize.
945
946 \param pPacket - the voss Packet to modify.
947
948 \param ppData - pointer to the location where the pointer to the reserved
949 space is returned. Upon successful return, the caller has
950 write / read access to the data space at *ppData for length
951 dataSize to build headers, etc.
952
953 \param dataSize - the size of the data to reserve at the head of the voss
954 Packet. Upon successful return, the length of the voss
955 Packet is increased by dataSize.
956
957 \return
958
959 \sa
960
961 ----------------------------------------------------------------------------*/
962VOS_STATUS vos_pkt_reserve_tail( vos_pkt_t *pPacket, v_VOID_t **ppData,
963 v_SIZE_t dataSize );
964
965
966/**--------------------------------------------------------------------------
967
968 \brief vos_pkt_pop_tail() - Remove data from the end of the voss Packet
969
970 This API removes data from the end of a voss Packet. The data is
971 copied into the output buffer described by pData and pDataSize
972
973 \param pPacket - the voss Packet to operate on.
974
975 \param pData - pointer to the data buffer where the data removed from the
976 voss Packet is placed.
977
978 \param dataSize - The amount of space to remove from the end of the voss
979 Packet. The output buffer (at *pData) must contain at
980 least this amount of space.
981
982 \return
983
984 \sa
985
986 ----------------------------------------------------------------------------*/
987VOS_STATUS vos_pkt_pop_tail( vos_pkt_t *pPacket, v_VOID_t *pData, v_SIZE_t dataSize );
988
989
990/**--------------------------------------------------------------------------
991
992 \brief vos_pkt_trim_tail() - Skip over bytes at the end of a voss Packet
993
994 This API moves the pointers at the head of a voss Packet to essentially
995 skip over data at the end of a voss Packet. Upon successful return, the
996 length of the voss Packet is reduced by dataSize and voss Packet is
997 adjusted to eliminate the data from the end of the voss Packet.
998
999 This API has the opposite effect of \a vos_pkt_reserve_tail().
1000
1001 \param pPacket - the voss Packet to operate on.
1002
1003 \param dataSize - The amount of space to remove at the end of the voss
1004 Packet.
1005
1006 Note that upon return, the data skipped over is
1007 inaccessible to the caller. If the caller needs access
1008 to the tail data, use vos_pkt_pop_tail() or
1009 vos_pkt_extract_data() to get a copy of the data.
1010
1011 \return
1012
1013 \sa
1014
1015 ----------------------------------------------------------------------------*/
1016VOS_STATUS vos_pkt_trim_tail( vos_pkt_t *pPacket, v_SIZE_t dataSize );
1017
1018/**--------------------------------------------------------------------------
1019
1020 \brief vos_pkt_get_timestamp() - Retrive the timestamp attribute from the
1021 specified VOSS packet
1022
1023 \param pPacket - the voss Packet to operate on.
1024
1025 \param pTstamp - the timestamp will be returned here.
1026
1027 \return VOS_STATUS_E_FAULT - invalid parameter(s) specified
1028
1029 VOS_STATUS_SUCCESS - timestamp retrived successfully
1030
1031 \sa
1032
1033 ----------------------------------------------------------------------------*/
1034VOS_STATUS vos_pkt_get_timestamp( vos_pkt_t *pPacket, v_TIME_t* pTstamp );
1035
1036/**--------------------------------------------------------------------------
1037
1038 \brief vos_pkt_flatten_rx_pkt() - Transform a platform based RX VOSS
1039 packet into a flat buffer based VOSS packet if needed. This is needed in cases
1040 where for reasons of efficiency we want the RX packets to be very platform specific
1041 (for e.g. DSM based on AMSS, etc). However platform independent code may rely
1042 on making calls on the VOSS packet which can only be supported by the flat buffer
1043 based implementation of a RX packet. This API will allocate a new VOSS packet
1044 with flat buffer, extract the data from the input VOSS packet and then release
1045 the input VOSS packet. The new VOSS packet will be returned from this call.
1046
1047 \param ppPacket - the voss Packet to operate on. on input contains
1048 the platform based packet. On output contains the flat
1049 buffer based packet. Any applicable resources
1050 are freed as part of this call.
1051
1052 \return VOS_STATUS_E_FAULT - invalid parameter specified
1053
1054 VOS_STATUS_E_INVAL - packet type not RX_RAW
1055
1056 VOS_STATUS_SUCCESS - transform successful
1057
1058 other VOSS status - other errors encountered
1059
1060 \sa
1061
1062 ----------------------------------------------------------------------------*/
1063VOS_STATUS vos_pkt_flatten_rx_pkt( vos_pkt_t **ppPacket );
1064
1065/**--------------------------------------------------------------------------
1066
1067 \brief vos_pkt_set_rx_length() - Set the length of a received packet
1068
1069 This API set the length of the data inside the packet after a DMA has occurred
1070 on rx, it will also set the tail pointer to the end of the data.
1071
1072 \param pPacket - the voss Packet to operate on.
1073
1074 \param pktLen - The size of the data placed in the Rx packet during DMA.
1075
1076
1077 \return
1078
1079 \sa
1080
1081 ---------------------------------------------------------------------------*/
1082VOS_STATUS vos_pkt_set_rx_length( vos_pkt_t *pPacket, v_SIZE_t pktLen );
1083
1084/**--------------------------------------------------------------------------
1085
1086 \brief vos_pkt_get_available_buffer_pool() - Get avaliable VOS packet size
1087 VOSS Packet pool is limitted resource
1088 VOSS Client need to know how many packet pool is still avaliable to control the flow
1089
1090 \param pktType - Packet type want to know free buffer count
1091 VOS_PKT_TYPE_TX_802_11_MGMT, management free buffer count,
1092 VOS_PKT_TYPE_TX_802_11_DATA
1093 VOS_PKT_TYPE_TX_802_3_DATA, TX free buffer count
1094 VOS_PKT_TYPE_RX_RAW, RX free buffer count
1095
1096 vosFreeBuffer - free frame buffer size
1097
1098 \return VOS_STATUS_E_INVAL - invalid input parameter
1099
1100 VOS_STATUS_SUCCESS - Get size success
1101
1102 \sa
1103
1104 ----------------------------------------------------------------------------*/
1105VOS_STATUS vos_pkt_get_available_buffer_pool
1106(
1107 VOS_PKT_TYPE pktType,
1108 v_SIZE_t *vosFreeBuffer
1109);
1110
Sameer Thalappild0158402013-05-03 13:19:03 -07001111/**
1112 @brief vos_pkt_get_num_of_rx_raw_pkts() - Get the number of RX packets
1113 that should be allocated.
1114
1115 This function is called by VOS packet module to know how many RX raw
1116 packets it should allocate/reserve. This value can be configured thru
1117 Kernel device tree to save memory usage.
1118
1119 @param
1120 NONE
1121 @return
1122 v_SIZE_t the number of packets to allocate
1123
1124*/
1125v_SIZE_t vos_pkt_get_num_of_rx_raw_pkts(void);
1126
Mihir Sheted183cef2014-09-26 19:17:56 +05301127/**
1128 @brief vos_pkt_get_num_of_rx_pkt_alloc_failures() - Get the number of times
1129 skb allocation failed while replenishing packets
1130
1131
1132 @param
1133 NONE
1134 @return
1135 v_SIZE_t the number of times packet allocation failed
1136
1137*/
1138v_SIZE_t vos_pkt_get_num_of_rx_pkt_alloc_failures(void);
1139
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08001140v_U8_t vos_pkt_get_proto_type
1141(
1142 void *pskb,
1143 v_U8_t tracking_map
1144);
Bhargav Shah7dbfb6f2016-02-12 20:49:58 +05301145
1146/**
1147 @brief vos_get_pkt_head() - Get skb head pointer
1148
1149 @param
1150 pPacket - the voss Packet to operate on
1151 @return
1152 v_PVOID_t - skb head pointer
1153
1154*/
1155v_PVOID_t vos_get_pkt_head(vos_pkt_t *pPacket);
1156
1157/**
1158
1159 @brief vos_get_pkt_end() - Get skb end pointer
1160
1161 @param
1162 pPacket - the voss Packet to operate on
1163 @return
1164 v_PVOID_t - skb end pointer
1165
1166*/
1167v_PVOID_t vos_get_pkt_end(vos_pkt_t *pPacket);
1168
1169/**
1170
1171 @brief vos_recover_tail() - Recover corrupted tail of skb
1172
1173 @param
1174 pPacket - the voss Packet to operate on
1175 @return
1176 v_VOID_t - None
1177
1178*/
1179v_VOID_t vos_recover_tail(vos_pkt_t *pPacket);
1180
Asodi T,Venkateswara Reddy9826c872017-01-18 19:08:25 +05301181/**
1182 @breaf vos_is_arp_pkt() - Check the packet is ARP or not.
1183
1184 @param
1185 pskb - pointer to skb
1186 is_translated - header translation check
1187 @return
1188 TRUE - if packet is ARP
1189 FALSE -if packet is not ARP
1190*/
1191bool vos_is_arp_pkt(void *pskb, bool is_translated);
1192
Jeff Johnson295189b2012-06-20 16:38:30 -07001193#endif // !defined( __VOS_PKT_H )