xref: /wlan-driver/qcacld-3.0/core/hdd/inc/wlan_hdd_napi.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2015-2018 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 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 #ifndef __HDD_NAPI_H__
21 #define __HDD_NAPI_H__
22 
23 #ifdef FEATURE_NAPI
24 /**
25  * DOC: wlan_hdd_napi.h
26  *
27  * WLAN NAPI interface module headers
28  */
29 
30 /* CLD headers */
31 #include "hif_napi.h"
32 
33 /* Linux headers */
34 #include <linux/netdevice.h> /* net_device */
35 
36 struct hdd_context;
37 
38 #define HDD_NAPI_ANY (-1)
39 
40 int hdd_napi_enabled(int id);
41 int hdd_napi_create(void);
42 int hdd_napi_destroy(int force);
43 int hdd_display_napi_stats(void);
44 int hdd_clear_napi_stats(void);
45 
46 /* the following triggers napi_enable/disable as required */
47 int hdd_napi_event(enum qca_napi_event event, void *data);
48 
49 int hdd_napi_poll(struct napi_struct *napi, int budget);
50 
51 struct qca_napi_data *hdd_napi_get_all(void);
52 
53 #if defined HELIUMPLUS && defined MSM_PLATFORM
54 int hdd_napi_apply_throughput_policy(struct hdd_context *hddctx,
55 				     uint64_t              tx_packets,
56 				     uint64_t              rx_packets);
57 int hdd_napi_serialize(int is_on);
58 #else
hdd_napi_apply_throughput_policy(struct hdd_context * hddctx,uint64_t tx_packets,uint64_t rx_packets)59 static inline int hdd_napi_apply_throughput_policy(struct hdd_context *hddctx,
60 						   uint64_t tx_packets,
61 						   uint64_t rx_packets)
62 {
63 	return 0;
64 }
hdd_napi_serialize(int is_on)65 static inline int hdd_napi_serialize(int is_on)
66 {
67 	return -EINVAL;
68 }
69 #endif /* HELIUMPLUS && MSM_PLATFORM */
70 
71 #else /* ! defined(FEATURE_NAPI) */
72 #include "hif_napi.h"
73 /*
74  * Stub API
75  *
76  */
77 
78 #define HDD_NAPI_ANY (-1)
79 
hdd_napi_enabled(int id)80 static inline int hdd_napi_enabled(int id) { return 0; }
hdd_napi_create(void)81 static inline int hdd_napi_create(void) { return 0; }
hdd_napi_destroy(int force)82 static inline int hdd_napi_destroy(int force) { return 0; }
hdd_display_napi_stats(void)83 static inline int hdd_display_napi_stats(void) { return 0; }
hdd_clear_napi_stats(void)84 static inline int hdd_clear_napi_stats(void) { return 0; }
hdd_napi_event(enum qca_napi_event event,void * data)85 static inline int hdd_napi_event(enum qca_napi_event event, void *data)
86 {
87 	return 0;
88 }
hdd_napi_get_all(void)89 static inline struct qca_napi_data *hdd_napi_get_all(void) { return NULL; }
hdd_napi_apply_throughput_policy(void * hdd_ctx,uint64_t tx_packets,uint64_t rx_packets)90 static inline int hdd_napi_apply_throughput_policy(void *hdd_ctx,
91 				uint64_t tx_packets, uint64_t rx_packets)
92 {
93 	return 0;
94 }
95 
hdd_napi_serialize(int is_on)96 static inline int hdd_napi_serialize(int is_on)
97 {
98 	return -EINVAL;
99 }
100 #endif /* FEATURE_NAPI */
101 
102 #endif /*  HDD_NAPI_H__ */
103