1 /*
2 * Copyright (c) 2012-2020 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 /*
21 * This file was originally distributed by Qualcomm Atheros, Inc.
22 * under proprietary terms before Copyright ownership was assigned
23 * to the Linux Foundation.
24 */
25
26 /**
27 * DOC: wlan_hdd_apf.h
28 *
29 * Android Packet Filter related API's and definitions
30 */
31
32 #ifndef __WLAN_HDD_APF_H
33 #define __WLAN_HDD_APF_H
34
35 #ifdef FEATURE_WLAN_APF
36
37 #include <net/cfg80211.h>
38 #include "sir_api.h"
39 #include "wlan_hdd_main.h"
40 #include "wmi_unified_param.h"
41 #include "qca_vendor.h"
42
43 #define APF_CONTEXT_MAGIC 0x4575354
44
45 #define MAX_APF_MEMORY_LEN 4096
46
47 /* APF commands wait times in msec */
48 #define WLAN_WAIT_TIME_APF_READ_MEM 10000
49
50 /* QCA_NL80211_VENDOR_PACKET_FILTER policy */
51 extern const struct nla_policy wlan_hdd_apf_offload_policy[
52 QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_MAX + 1];
53
54 #define FEATURE_APF_OFFLOAD_VENDOR_COMMANDS \
55 { \
56 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
57 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER, \
58 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
59 WIPHY_VENDOR_CMD_NEED_NETDEV | \
60 WIPHY_VENDOR_CMD_NEED_RUNNING, \
61 .doit = wlan_hdd_cfg80211_apf_offload, \
62 vendor_command_policy(wlan_hdd_apf_offload_policy, \
63 QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_MAX) \
64 },
65
66 /**
67 * wlan_hdd_cfg80211_apf_offload() - SSR Wrapper to APF Offload
68 * @wiphy: wiphy structure pointer
69 * @wdev: Wireless device structure pointer
70 * @data: Pointer to the data received
71 * @data_len: Length of @data
72 *
73 * Return: 0 on success; errno on failure
74 */
75
76 int wlan_hdd_cfg80211_apf_offload(struct wiphy *wiphy,
77 struct wireless_dev *wdev,
78 const void *data, int data_len);
79
80 /**
81 * hdd_apf_context_init - APF Context initialization operations
82 * @adapter: hdd adapter
83 *
84 * Return: None
85 */
86 void hdd_apf_context_init(struct hdd_adapter *adapter);
87
88 /**
89 * hdd_apf_context_destroy - APF Context de-init operations
90 * @adapter: hdd adapter
91 *
92 * Return: None
93 */
94 void hdd_apf_context_destroy(struct hdd_adapter *adapter);
95
96 /**
97 * hdd_get_apf_capabilities_cb() - Callback function to get APF capabilities
98 * @hdd_context: pointer to the hdd context
99 * @data: pointer to the data received
100 *
101 * This function receives the response/data from the lower layer and
102 * checks to see if the thread is still waiting then post the results to
103 * upper layer, if the request has timed out then ignore.
104 *
105 * Return: None
106 */
107 void hdd_get_apf_capabilities_cb(void *hdd_context,
108 struct sir_apf_get_offload *data);
109 #else /* FEATURE_WLAN_APF */
110
111 #define FEATURE_APF_OFFLOAD_VENDOR_COMMANDS
112
hdd_apf_context_init(struct hdd_adapter * adapter)113 static inline void hdd_apf_context_init(struct hdd_adapter *adapter)
114 {
115 }
116
hdd_apf_context_destroy(struct hdd_adapter * adapter)117 static inline void hdd_apf_context_destroy(struct hdd_adapter *adapter)
118 {
119 }
120
121 #endif /* FEATURE_WLAN_APF */
122
123 #endif /* WLAN_HDD_APF_H */
124