1 /*
2 * Copyright (c) 2012-2014, 2017-2019, 2020 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 #if !defined(WLAN_HDD_IOCTL_H)
21 #define WLAN_HDD_IOCTL_H
22
23 #include <linux/netdevice.h>
24 #include <uapi/linux/if.h>
25 #include "wlan_hdd_main.h"
26
27 extern struct sock *cesium_nl_srv_sock;
28
29 /**
30 * hdd_ioctl() - ioctl handler (wrapper) for wlan network interfaces
31 * @dev: device upon which the ioctl was received
32 * @ifr: ioctl request information
33 * @cmd: ioctl command
34 *
35 * This function acts as an SSR-protecting wrapper to __hdd_ioctl()
36 * which is where the ioctls are really handled.
37 *
38 * Return: 0 on success, non-zero on error
39 */
40 int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
41
42 /**
43 * hdd_dev_private_ioctl() - private ioctl handler for wlan network interfaces
44 * @dev: device upon which the ioctl was received
45 * @ifr: ioctl request information
46 * @data: pointer to the raw command data in the ioctl request
47 * @cmd: ioctl command
48 *
49 * For Kernel 5.15+, this function acts as an SSR-protecting wrapper
50 * to __hdd_ioctl(), which is where the ioctls are really handled.
51 *
52 * Return: 0 on success, non-zero on error
53 */
54 int hdd_dev_private_ioctl(struct net_device *dev, struct ifreq *ifr,
55 void __user *data, int cmd);
56
57 /**
58 * wlan_hdd_set_mc_rate() - Function to set MC rate.
59 * @link_info: Link info pointer in HDD adapter
60 * @target_rate: Target rate to set.
61 *
62 * The API sets the value in @target_rate for MC Tx
63 *
64 * Return: Non-zero value on failure.
65 */
66 int wlan_hdd_set_mc_rate(struct wlan_hdd_link_info *link_info, int target_rate);
67
68 /**
69 * hdd_update_smps_antenna_mode() - set smps and antenna mode
70 * @hdd_ctx: Pointer to hdd context
71 * @mode: antenna mode
72 *
73 * This function will set smps and antenna mode.
74 *
75 * Return: QDF_STATUS
76 */
77 QDF_STATUS hdd_update_smps_antenna_mode(struct hdd_context *hdd_ctx, int mode);
78
79 /**
80 * hdd_set_antenna_mode() - SET ANTENNA MODE command handler
81 * @link_info: Link info pointer in HDD adapter
82 * @mode: new antenna mode
83 */
84 int hdd_set_antenna_mode(struct wlan_hdd_link_info *link_info, int mode);
85
86 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
87 /**
88 * hdd_get_roam_scan_ch_cb() - roam scan channel list callback handler
89 * @hdd_handle: Pointer to hdd context
90 * @roam_ch: pointer to roam scan ch event data
91 * @context: cookie
92 *
93 * Callback function to processes roam scan chaanel list event. If
94 * command response field in the response message is set that means
95 * event received as a response of GETROAMSCANCHANNELS command else
96 * event was raised by firmware upon disconnection.
97 *
98 * Return: none
99 */
100 void hdd_get_roam_scan_ch_cb(hdd_handle_t hdd_handle,
101 struct roam_scan_ch_resp *roam_ch,
102 void *context);
103
104 /**
105 * hdd_get_roam_scan_freq() - roam scan freq list
106 * @adapter: Pointer to hdd adapter
107 * @mac_handle: pointer to mac_handle
108 * @chan_list: Pointer to hold roam scan freq list
109 * @num_channels: Pointer to hold num of roam scan channels in list
110 *
111 * This function gets roam scan frequencies from FW if FW is capable else
112 * roam scan frequencies are taken from host maintained list.
113 *
114 * Return: 0 on success else error value
115 */
116 int
117 hdd_get_roam_scan_freq(struct hdd_adapter *adapter, mac_handle_t mac_handle,
118 uint32_t *chan_list, uint8_t *num_channels);
119 #else
120 static inline void
hdd_get_roam_scan_ch_cb(hdd_handle_t hdd_handle,void * roam_ch,void * context)121 hdd_get_roam_scan_ch_cb(hdd_handle_t hdd_handle,
122 void *roam_ch,
123 void *context)
124 {
125 }
126
127 static inline int
hdd_get_roam_scan_freq(struct hdd_adapter * adapter,mac_handle_t mac_handle,uint32_t * chan_list,uint8_t * num_channels)128 hdd_get_roam_scan_freq(struct hdd_adapter *adapter, mac_handle_t mac_handle,
129 uint32_t *chan_list, uint8_t *num_channels)
130 {
131 return -EFAULT;
132 }
133 #endif
134
135 /**
136 * hdd_ioctl_log_buffer() - dump log buffer of a type
137 * @log_id: id of what log type to be
138 * @count: number of lines to be copied
139 * @custom_print: custom print function pointer
140 * @print_ctx: print context for custom print function
141 *
142 * If custom print function is NULL, will default to printk
143 *
144 * Return: None
145 */
146 void hdd_ioctl_log_buffer(int log_id, uint32_t count, qdf_abstract_print
147 *custom_print,
148 void *print_ctx);
149 #ifdef WLAN_DUMP_LOG_BUF_CNT
150 /**
151 * hdd_dump_log_buffer() - dump log buffer history
152 * @print_ctx: print context for custom print function
153 * @custom_print: custom print function pointer
154 *
155 * If custom print function is NULL, will default to printk
156 *
157 * Return: None
158 */
159 void hdd_dump_log_buffer(void *print_ctx, qdf_abstract_print *custom_print);
160
161 #else
162 static inline
hdd_dump_log_buffer(void * print_ctx,qdf_abstract_print * custom_print)163 void hdd_dump_log_buffer(void *print_ctx, qdf_abstract_print *custom_print)
164 {
165 }
166
167 #endif
168 #endif /* end #if !defined(WLAN_HDD_IOCTL_H) */
169