xref: /wlan-driver/qca-wifi-host-cmn/qdf/inc/qdf_lro.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2015-2017 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 /**
21  * DOC: Large Receive Offload API
22  * This file defines the Large receive offload API.
23  */
24 #ifndef _QDF_LRO_H
25 #define _QDF_LRO_H
26 
27 #include <qdf_nbuf.h>
28 #include <i_qdf_lro.h>
29 
30 /**
31  * typedef qdf_lro_ctx_t - Platform independent LRO context abstraction
32  */
33 typedef __qdf_lro_ctx_t qdf_lro_ctx_t;
34 
35 /**
36  * struct qdf_lro_info - LRO information
37  * @iph: IP header
38  * @tcph: TCP header
39  */
40 struct qdf_lro_info {
41 	uint8_t *iph;
42 	uint8_t *tcph;
43 };
44 
45 #if defined(FEATURE_LRO)
46 
47 /**
48  * qdf_lro_init() - LRO initialization function
49  *
50  * Return: LRO context
51  */
52 qdf_lro_ctx_t qdf_lro_init(void);
53 
54 /**
55  * qdf_lro_deinit() - LRO deinitialization function
56  * @lro_ctx: LRO context
57  *
58  * Return: nothing
59  */
60 void qdf_lro_deinit(qdf_lro_ctx_t lro_ctx);
61 
62 /**
63  *  qdf_lro_get_info() - Update the LRO information
64  *
65  * @lro_ctx: LRO context
66  * @nbuf: network buffer
67  * @info: LRO related information passed in by the caller
68  * @plro_desc: lro information returned as output
69  *
70  * Look-up the LRO descriptor based on the LRO information and
71  * the network buffer provided. Update the skb cb with the
72  * descriptor found
73  *
74  * Return: true: LRO eligible false: LRO ineligible
75  */
76 bool qdf_lro_get_info(qdf_lro_ctx_t lro_ctx, qdf_nbuf_t nbuf,
77 						 struct qdf_lro_info *info,
78 						 void **plro_desc);
79 
80 /**
81  * qdf_lro_flush_pkt() - function to flush the LRO flow
82  * @info: LRO related information passed by the caller
83  * @lro_ctx: LRO context
84  *
85  * Flush all the packets aggregated in the LRO manager for the
86  * flow indicated by the TCP and IP header
87  *
88  * Return: none
89  */
90 void qdf_lro_flush_pkt(qdf_lro_ctx_t lro_ctx,
91 		       struct qdf_lro_info *info);
92 
93 /**
94  * qdf_lro_flush() - LRO flush API
95  * @lro_ctx: LRO context
96  *
97  * Flush all the packets aggregated in the LRO manager for all
98  * the flows
99  *
100  * Return: none
101  */
102 void qdf_lro_flush(qdf_lro_ctx_t lro_ctx);
103 
104 /**
105  * qdf_lro_desc_free() - Free the LRO descriptor
106  * @lro_ctx: LRO context
107  * @data: LRO descriptor
108  *
109  * Return the LRO descriptor to the free pool
110  *
111  * Return: none
112  */
113 void qdf_lro_desc_free(qdf_lro_ctx_t lro_ctx, void *data);
114 
115 #else
116 
qdf_lro_init(void)117 static inline qdf_lro_ctx_t qdf_lro_init(void)
118 {
119 	return NULL;
120 }
121 
qdf_lro_deinit(qdf_lro_ctx_t lro_ctx)122 static inline void qdf_lro_deinit(qdf_lro_ctx_t lro_ctx)
123 {
124 }
125 
qdf_lro_flush(qdf_lro_ctx_t lro_ctx)126 static inline void qdf_lro_flush(qdf_lro_ctx_t lro_ctx)
127 {
128 }
129 #endif /* FEATURE_LRO */
130 #endif
131