1 /*
2  * Copyright (c) 2012-2019, 2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 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 #ifndef __P2P_H
21 #define __P2P_H
22 
23 /**
24  * DOC: wlan_hdd_p2p.h
25  *
26  * Linux HDD P2P include file
27  */
28 
29 #define WLAN_HDD_GET_TYPE_FRM_FC(__fc__)         (((__fc__) & 0x0F) >> 2)
30 #define WLAN_HDD_GET_SUBTYPE_FRM_FC(__fc__)      (((__fc__) & 0xF0) >> 4)
31 #define WLAN_HDD_80211_FRM_DA_OFFSET             4
32 
33 #define P2P_POWER_SAVE_TYPE_OPPORTUNISTIC        (1 << 0)
34 #define P2P_POWER_SAVE_TYPE_PERIODIC_NOA         (1 << 1)
35 #define P2P_POWER_SAVE_TYPE_SINGLE_NOA           (1 << 2)
36 
37 struct p2p_app_set_ps {
38 	uint8_t opp_ps;
39 	uint32_t ct_window;
40 	uint8_t count;
41 	uint32_t duration;
42 	uint32_t interval;
43 	uint32_t single_noa_duration;
44 	uint8_t ps_selection;
45 };
46 
47 int wlan_hdd_cfg80211_remain_on_channel(struct wiphy *wiphy,
48 					struct wireless_dev *wdev,
49 					struct ieee80211_channel *chan,
50 					unsigned int duration, u64 *cookie);
51 
52 int wlan_hdd_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy,
53 					       struct wireless_dev *wdev,
54 					       u64 cookie);
55 
56 int wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
57 					  struct wireless_dev *wdev,
58 					  u64 cookie);
59 
60 int hdd_set_p2p_ps(struct net_device *dev, void *msgData);
61 int hdd_set_p2p_opps(struct net_device *dev, uint8_t *command);
62 int hdd_set_p2p_noa(struct net_device *dev, uint8_t *command);
63 
64 /**
65  * hdd_indicate_mgmt_frame_to_user- send mgmt frame to user
66  * @adapter: adapter pointer
67  * @frm_len: frame length
68  * @pb_frames: frame bytes
69  * @frame_type: frame type
70  * @rx_freq: frequency on which frame was received
71  * @rx_rssi: rssi
72  * @rx_flags: rx flags of the frame
73  */
74 void hdd_indicate_mgmt_frame_to_user(struct hdd_adapter *adapter,
75 				     uint32_t frm_len, uint8_t *pb_frames,
76 				     uint8_t frame_type, uint32_t rx_freq,
77 				     int8_t rx_rssi,
78 				     enum rxmgmt_flags rx_flags);
79 
80 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
81 int wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
82 		     struct cfg80211_mgmt_tx_params *params, u64 *cookie);
83 #else
84 int wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
85 		     struct ieee80211_channel *chan, bool offchan,
86 		     unsigned int wait,
87 		     const u8 *buf, size_t len, bool no_cck,
88 		     bool dont_wait_for_ack, u64 *cookie);
89 #endif
90 
91 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
92 struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
93 					       const char *name,
94 					       unsigned char name_assign_type,
95 					       enum nl80211_iftype type,
96 					       struct vif_params *params);
97 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) || defined(WITH_BACKPORTS)
98 struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
99 					       const char *name,
100 					       unsigned char name_assign_type,
101 					       enum nl80211_iftype type,
102 					       u32 *flags,
103 					       struct vif_params *params);
104 #else
105 struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
106 					       const char *name,
107 					       enum nl80211_iftype type,
108 					       u32 *flags,
109 					       struct vif_params *params);
110 
111 #endif
112 
113 /**
114  * hdd_clean_up_interface() - clean up hdd interface
115  * @hdd_ctx: pointer to hdd context
116  * @adapter: pointer to adapter
117  *
118  * This function clean up hdd interface.
119  *
120  * Return: None
121  */
122 void hdd_clean_up_interface(struct hdd_context *hdd_ctx,
123 			    struct hdd_adapter *adapter);
124 int wlan_hdd_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
125 int __wlan_hdd_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
126 
127 /**
128  * wlan_hdd_cleanup_remain_on_channel_ctx - Cleanup ROC on VDEV
129  * @link_info: pointer to link_info struct in adapter
130  *
131  * This function is used to cleanup the ROC on the vdev
132  * pointed in the @link_info
133  *
134  * Return: void
135  */
136 void
137 wlan_hdd_cleanup_remain_on_channel_ctx(struct wlan_hdd_link_info *link_info);
138 
139 /**
140  * wlan_hdd_set_power_save() - hdd set power save
141  * @adapter:    adapter context
142  * @ps_config:  pointer to power save configure
143  *
144  * This function sets power save parameters.
145  *
146  * Return: 0 - success
147  *    others - failure
148  */
149 int wlan_hdd_set_power_save(struct hdd_adapter *adapter,
150 	struct p2p_ps_config *ps_config);
151 
152 /**
153  * wlan_hdd_set_mas() - Function to set MAS value to FW
154  * @adapter:            Pointer to HDD adapter
155  * @mas_value:          0-Disable, 1-Enable MAS
156  *
157  * This function passes down the value of MAS to FW
158  *
159  * Return: Configuration message posting status, SUCCESS or Fail
160  *
161  */
162 int32_t wlan_hdd_set_mas(struct hdd_adapter *adapter, uint8_t mas_value);
163 
164 /**
165  * wlan_hdd_set_mcc_p2p_quota() - Function to set quota for P2P
166  * to FW
167  * @adapter:            Pointer to HDD adapter
168  * @set_value:          Quota value for the interface
169  *
170  * This function is used to set the quota for P2P cases
171  *
172  * Return: Configuration message posting status, SUCCESS or Fail
173  *
174  */
175 int wlan_hdd_set_mcc_p2p_quota(struct hdd_adapter *adapter,
176 			       uint32_t set_value);
177 
178 /**
179  * wlan_hdd_go_set_mcc_p2p_quota() - Function to set quota for
180  * P2P GO to FW
181  * @hostapd_adapter:    Pointer to HDD adapter
182  * @set_value:          Quota value for the interface
183  *
184  * This function is used to set the quota for P2P GO cases
185  *
186  * Return: Configuration message posting status, SUCCESS or Fail
187  *
188  */
189 int wlan_hdd_go_set_mcc_p2p_quota(struct hdd_adapter *hostapd_adapter,
190 				  uint32_t set_value);
191 /**
192  * wlan_hdd_set_mcc_latency() - Set MCC latency to FW
193  * @adapter: Pointer to HDD adapter
194  * @set_value: Latency value
195  *
196  * Sets the MCC latency value during STA-P2P concurrency
197  *
198  * Return: None
199  */
200 void wlan_hdd_set_mcc_latency(struct hdd_adapter *adapter, int set_value);
201 
202 /**
203  * wlan_hdd_cleanup_actionframe() - Cleanup action frame
204  * @link_info: pointer to link_info struct in adapter
205  *
206  * This function cleans up action frame.
207  *
208  * Return: None
209  */
210 void wlan_hdd_cleanup_actionframe(struct wlan_hdd_link_info *link_info);
211 #endif /* __P2P_H */
212