1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name *
5*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name * above copyright notice and this permission notice appear in all
8*5113495bSYour Name * copies.
9*5113495bSYour Name *
10*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name */
19*5113495bSYour Name
20*5113495bSYour Name /*
21*5113495bSYour Name * This file was originally distributed by Qualcomm Atheros, Inc.
22*5113495bSYour Name * under proprietary terms before Copyright ownership was assigned
23*5113495bSYour Name * to the Linux Foundation.
24*5113495bSYour Name */
25*5113495bSYour Name
26*5113495bSYour Name /**
27*5113495bSYour Name * DOC: wlan_hdd_apf.h
28*5113495bSYour Name *
29*5113495bSYour Name * Android Packet Filter related API's and definitions
30*5113495bSYour Name */
31*5113495bSYour Name
32*5113495bSYour Name #ifndef __WLAN_HDD_APF_H
33*5113495bSYour Name #define __WLAN_HDD_APF_H
34*5113495bSYour Name
35*5113495bSYour Name #ifdef FEATURE_WLAN_APF
36*5113495bSYour Name
37*5113495bSYour Name #include <net/cfg80211.h>
38*5113495bSYour Name #include "sir_api.h"
39*5113495bSYour Name #include "wlan_hdd_main.h"
40*5113495bSYour Name #include "wmi_unified_param.h"
41*5113495bSYour Name #include "qca_vendor.h"
42*5113495bSYour Name
43*5113495bSYour Name #define APF_CONTEXT_MAGIC 0x4575354
44*5113495bSYour Name
45*5113495bSYour Name #define MAX_APF_MEMORY_LEN 4096
46*5113495bSYour Name
47*5113495bSYour Name /* APF commands wait times in msec */
48*5113495bSYour Name #define WLAN_WAIT_TIME_APF_READ_MEM 10000
49*5113495bSYour Name
50*5113495bSYour Name /* QCA_NL80211_VENDOR_PACKET_FILTER policy */
51*5113495bSYour Name extern const struct nla_policy wlan_hdd_apf_offload_policy[
52*5113495bSYour Name QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_MAX + 1];
53*5113495bSYour Name
54*5113495bSYour Name #define FEATURE_APF_OFFLOAD_VENDOR_COMMANDS \
55*5113495bSYour Name { \
56*5113495bSYour Name .info.vendor_id = QCA_NL80211_VENDOR_ID, \
57*5113495bSYour Name .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER, \
58*5113495bSYour Name .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
59*5113495bSYour Name WIPHY_VENDOR_CMD_NEED_NETDEV | \
60*5113495bSYour Name WIPHY_VENDOR_CMD_NEED_RUNNING, \
61*5113495bSYour Name .doit = wlan_hdd_cfg80211_apf_offload, \
62*5113495bSYour Name vendor_command_policy(wlan_hdd_apf_offload_policy, \
63*5113495bSYour Name QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_MAX) \
64*5113495bSYour Name },
65*5113495bSYour Name
66*5113495bSYour Name /**
67*5113495bSYour Name * wlan_hdd_cfg80211_apf_offload() - SSR Wrapper to APF Offload
68*5113495bSYour Name * @wiphy: wiphy structure pointer
69*5113495bSYour Name * @wdev: Wireless device structure pointer
70*5113495bSYour Name * @data: Pointer to the data received
71*5113495bSYour Name * @data_len: Length of @data
72*5113495bSYour Name *
73*5113495bSYour Name * Return: 0 on success; errno on failure
74*5113495bSYour Name */
75*5113495bSYour Name
76*5113495bSYour Name int wlan_hdd_cfg80211_apf_offload(struct wiphy *wiphy,
77*5113495bSYour Name struct wireless_dev *wdev,
78*5113495bSYour Name const void *data, int data_len);
79*5113495bSYour Name
80*5113495bSYour Name /**
81*5113495bSYour Name * hdd_apf_context_init - APF Context initialization operations
82*5113495bSYour Name * @adapter: hdd adapter
83*5113495bSYour Name *
84*5113495bSYour Name * Return: None
85*5113495bSYour Name */
86*5113495bSYour Name void hdd_apf_context_init(struct hdd_adapter *adapter);
87*5113495bSYour Name
88*5113495bSYour Name /**
89*5113495bSYour Name * hdd_apf_context_destroy - APF Context de-init operations
90*5113495bSYour Name * @adapter: hdd adapter
91*5113495bSYour Name *
92*5113495bSYour Name * Return: None
93*5113495bSYour Name */
94*5113495bSYour Name void hdd_apf_context_destroy(struct hdd_adapter *adapter);
95*5113495bSYour Name
96*5113495bSYour Name /**
97*5113495bSYour Name * hdd_get_apf_capabilities_cb() - Callback function to get APF capabilities
98*5113495bSYour Name * @hdd_context: pointer to the hdd context
99*5113495bSYour Name * @data: pointer to the data received
100*5113495bSYour Name *
101*5113495bSYour Name * This function receives the response/data from the lower layer and
102*5113495bSYour Name * checks to see if the thread is still waiting then post the results to
103*5113495bSYour Name * upper layer, if the request has timed out then ignore.
104*5113495bSYour Name *
105*5113495bSYour Name * Return: None
106*5113495bSYour Name */
107*5113495bSYour Name void hdd_get_apf_capabilities_cb(void *hdd_context,
108*5113495bSYour Name struct sir_apf_get_offload *data);
109*5113495bSYour Name #else /* FEATURE_WLAN_APF */
110*5113495bSYour Name
111*5113495bSYour Name #define FEATURE_APF_OFFLOAD_VENDOR_COMMANDS
112*5113495bSYour Name
hdd_apf_context_init(struct hdd_adapter * adapter)113*5113495bSYour Name static inline void hdd_apf_context_init(struct hdd_adapter *adapter)
114*5113495bSYour Name {
115*5113495bSYour Name }
116*5113495bSYour Name
hdd_apf_context_destroy(struct hdd_adapter * adapter)117*5113495bSYour Name static inline void hdd_apf_context_destroy(struct hdd_adapter *adapter)
118*5113495bSYour Name {
119*5113495bSYour Name }
120*5113495bSYour Name
121*5113495bSYour Name #endif /* FEATURE_WLAN_APF */
122*5113495bSYour Name
123*5113495bSYour Name #endif /* WLAN_HDD_APF_H */
124