xref: /wlan-driver/qcacld-3.0/core/cds/inc/cds_packet.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2014-2016, 2018, 2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #if !defined(__CDS_PKT_H)
21 #define __CDS_PKT_H
22 
23 /**
24  * DOC: cds_packet.h
25  *      Connectivity driver services (CDS) network Packet APIs
26  *      Network Protocol packet/buffer support interfaces
27  */
28 
29 #include <qdf_types.h>
30 #include <qdf_status.h>
31 
32 /*--------------------------------------------------------------------------
33    Preprocessor definitions and constants
34    ------------------------------------------------------------------------*/
35 
36 /*--------------------------------------------------------------------------
37    Type declarations
38    ------------------------------------------------------------------------*/
39 struct cds_pkt_t;
40 typedef struct cds_pkt_t cds_pkt_t;
41 
42 #include "qdf_nbuf.h"
43 
44 /**
45  * cds_pkt_return_packet() - Free the cds Packet
46  * @packet: cds Packet
47  *
48  * Return: QDF_STATUS
49  */
50 QDF_STATUS cds_pkt_return_packet(cds_pkt_t *packet);
51 
52 /**
53  * cds_pkt_get_packet_length() - Get packet length for a cds Packet
54  * @pPacket: the cds Packet to get the packet length from
55  * @pPacketSize: location to return the total size of the data
56  *               contained in the cds Packet.
57  *
58  * Return: QDF_STATUS_SUCCESS if the length was returned, otherwise an
59  *         appropriate QDF_STATUS_E_* status code.
60  */
61 QDF_STATUS cds_pkt_get_packet_length(cds_pkt_t *pPacket,
62 				     uint16_t *pPacketSize);
63 
64 /*
65  * TODO: Remove later
66  * All the below definitions are not
67  * required for Host Driver 2.0
68  * once corresponding references are removed
69  * from HDD and other layers
70  * below code will be removed
71  */
72 
73 /**
74  * cds_packet_alloc() - Allocate a network buffer for TX
75  * @size: size of the packet
76  * @data: packet payload
77  * @ppPacket: pointer to return allocated packet
78  *
79  * Allocates a packet of the indicated @size, populates it with the
80  * @data payload, and returns the pointer via @ppPacket. Caller is
81  * responsible for calling cds_packet_free() after the packet has been
82  * sent to reclaim the packet.
83  *
84  * Return: QDF_STATUS_SUCCESS if a packet is allocated, otherwise a
85  * appropriate QDF_STATUS_E_* status code.
86  */
87 #ifdef MEMORY_DEBUG
88 #define cds_packet_alloc(size, data, ppPacket)	\
89 	cds_packet_alloc_debug(size, data, ppPacket, __func__, __LINE__)
90 
91 QDF_STATUS cds_packet_alloc_debug(uint16_t size, void **data, void **ppPacket,
92 				  const char *func_name, uint32_t line_num);
93 #else
94 QDF_STATUS cds_packet_alloc(uint16_t size, void **data, void **ppPacket);
95 #endif
96 
97 /**
98  * cds_packet_free() - Free input network buffer
99  * @pPacket: network buffer
100  */
101 void cds_packet_free(void *pPacket);
102 
103 #endif /* !defined( __CDS_PKT_H ) */
104