1 /* 2 * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. 3 * 4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc. 5 * 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /* 23 * This file was originally distributed by Qualcomm Atheros, Inc. 24 * under proprietary terms before Copyright ownership was assigned 25 * to the Linux Foundation. 26 */ 27 28 /*=========================================================================== 29 \file wlan_nlink_common.h 30 31 Exports and types for the Netlink Service interface. This header file contains 32 message types and definitions that is shared between the user space service 33 (e.g. logging service) and WLAN kernel module. 34 35 ===========================================================================*/ 36 37 #ifndef WLAN_NLINK_COMMON_H__ 38 #define WLAN_NLINK_COMMON_H__ 39 40 #include <linux/netlink.h> 41 42 #ifdef __KERNEL__ 43 #include <linux/if.h> 44 #else 45 #include <net/if.h> 46 #endif 47 48 /*--------------------------------------------------------------------------- 49 * External Functions 50 *-------------------------------------------------------------------------*/ 51 52 /*--------------------------------------------------------------------------- 53 * Preprocessor Definitions and Constants 54 *-------------------------------------------------------------------------*/ 55 #define WLAN_NL_MAX_PAYLOAD 5120 /* maximum size for netlink message */ 56 #define WLAN_NLINK_PROTO_FAMILY NETLINK_USERSOCK 57 #define WLAN_NLINK_MCAST_GRP_ID 0x01 58 59 /*--------------------------------------------------------------------------- 60 * Type Declarations 61 *-------------------------------------------------------------------------*/ 62 63 /* 64 * The following enum defines the target service within WLAN driver for which the 65 * message is intended for. Each service along with its counterpart 66 * in the user space, define a set of messages they recognize. 67 * Each of this message will have an header of type tAniMsgHdr defined below. 68 * Each Netlink message to/from a kernel module will contain only one 69 * message which is preceded by a tAniMsgHdr. The maximun size (in bytes) of 70 * a netlink message is assumed to be MAX_PAYLOAD bytes. 71 * 72 * +------------+-------+----------+----------+ 73 * |Netlink hdr | Align |tAniMsgHdr| msg body | 74 * +------------+-------+----------|----------+ 75 */ 76 77 /* Message Types */ 78 #define WLAN_SVC_FW_CRASHED_IND 0x100 79 #define WLAN_SVC_LTE_COEX_IND 0x101 80 #define WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND 0x102 81 #define WLAN_SVC_DFS_CAC_START_IND 0x103 82 #define WLAN_SVC_DFS_CAC_END_IND 0x104 83 #define WLAN_SVC_DFS_RADAR_DETECT_IND 0x105 84 #define WLAN_SVC_WLAN_STATUS_IND 0x106 85 #define WLAN_SVC_WLAN_VERSION_IND 0x107 86 #define WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND 0x108 87 #define WLAN_SVC_WLAN_TP_IND 0x109 88 #define WLAN_SVC_RPS_ENABLE_IND 0x10A 89 #define WLAN_SVC_WLAN_TP_TX_IND 0x10B 90 #define WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND 0x10C 91 #define WLAN_SVC_WLAN_RADIO_INDEX 0x10D 92 #define WLAN_SVC_FW_SHUTDOWN_IND 0x10E 93 #define WLAN_SVC_CORE_MINFREQ 0x10F 94 #define WLAN_SVC_MAX_SSID_LEN 32 95 #define WLAN_SVC_MAX_BSSID_LEN 6 96 #define WLAN_SVC_MAX_STR_LEN 16 97 #define WLAN_SVC_MAX_NUM_CHAN 128 98 #define WLAN_SVC_COUNTRY_CODE_LEN 3 99 100 #define ANI_NL_MSG_BASE 0x10 /* Some arbitrary base */ 101 102 typedef enum eAniNlModuleTypes { 103 ANI_NL_MSG_PUMAC = ANI_NL_MSG_BASE + 0x01, /* PTT Socket App */ 104 ANI_NL_MSG_PTT = ANI_NL_MSG_BASE + 0x07, /* Quarky GUI */ 105 WLAN_NL_MSG_OEM = ANI_NL_MSG_BASE + 0x09, 106 WLAN_NL_MSG_SVC, 107 WLAN_NL_MSG_CNSS_DIAG = ANI_NL_MSG_BASE + 0x0B, /* Value needs to be 27 */ 108 ANI_NL_MSG_LOG, 109 WLAN_NL_MSG_SPECTRAL_SCAN, 110 ANI_NL_MSG_MAX 111 } tAniNlModTypes, tWlanNlModTypes; 112 113 #define WLAN_NL_MSG_BASE ANI_NL_MSG_BASE 114 #define WLAN_NL_MSG_MAX ANI_NL_MSG_MAX 115 116 /* All Netlink messages must contain this header */ 117 typedef struct sAniHdr { 118 unsigned short type; 119 unsigned short length; 120 } tAniHdr, tAniMsgHdr; 121 122 typedef struct sAniNlMsg { 123 struct nlmsghdr nlh; /* Netlink Header */ 124 int radio; /* unit number of the radio */ 125 tAniHdr wmsg; /* Airgo Message Header */ 126 } tAniNlHdr; 127 128 struct radio_index_tlv { 129 unsigned short type; 130 unsigned short length; 131 int radio; 132 }; 133 134 /** 135 * struct svc_channel_info - Channel information 136 * @chan_id: Channel ID 137 * @reserved0: Reserved for padding and future use 138 * @mhz: Primary 20 MHz channel frequency in MHz 139 * @band_center_freq1: Center frequency 1 in MHz 140 * @band_center_freq2: Center frequency 2 in MHz 141 * @info: Channel info 142 * @reg_info_1: Regulatory information field 1 which contains 143 * MIN power, MAX power, reg power and reg class ID 144 * @reg_info_2: Regulatory information field 2 which contains antennamax 145 */ 146 struct svc_channel_info { 147 uint32_t chan_id; 148 uint32_t reserved0; 149 uint32_t mhz; 150 uint32_t band_center_freq1; 151 uint32_t band_center_freq2; 152 uint32_t info; 153 uint32_t reg_info_1; 154 uint32_t reg_info_2; 155 }; 156 157 struct wlan_status_data { 158 uint8_t lpss_support; 159 uint8_t is_on; 160 uint8_t vdev_id; 161 uint8_t is_connected; 162 int8_t rssi; 163 uint8_t ssid_len; 164 uint8_t country_code[WLAN_SVC_COUNTRY_CODE_LEN]; 165 uint32_t vdev_mode; 166 uint32_t freq; 167 uint32_t numChannels; 168 uint8_t channel_list[WLAN_SVC_MAX_NUM_CHAN]; 169 uint8_t ssid[WLAN_SVC_MAX_SSID_LEN]; 170 uint8_t bssid[WLAN_SVC_MAX_BSSID_LEN]; 171 struct svc_channel_info channel_info[WLAN_SVC_MAX_NUM_CHAN]; 172 }; 173 174 struct wlan_version_data { 175 uint32_t chip_id; 176 char chip_name[WLAN_SVC_MAX_STR_LEN]; 177 char chip_from[WLAN_SVC_MAX_STR_LEN]; 178 char host_version[WLAN_SVC_MAX_STR_LEN]; 179 char fw_version[WLAN_SVC_MAX_STR_LEN]; 180 }; 181 182 struct wlan_dfs_info { 183 uint16_t channel; 184 uint8_t country_code[WLAN_SVC_COUNTRY_CODE_LEN]; 185 }; 186 187 /* 188 * Maximim number of queues supported by WLAN driver. Setting an upper 189 * limit. Actual number of queues may be smaller than this value. 190 */ 191 #define WLAN_SVC_IFACE_NUM_QUEUES 6 192 193 /** 194 * struct wlan_rps_data - structure to send RPS info to cnss-daemon 195 * @ifname: interface name for which the RPS data belongs to 196 * @num_queues: number of rx queues for which RPS data is being sent 197 * @cpu_map_list: array of cpu maps for different rx queues supported by 198 * the wlan driver 199 * 200 * The structure specifies the format of data exchanged between wlan 201 * driver and cnss-daemon. On receipt of the data, cnss-daemon is expected 202 * to apply the 'cpu_map' for each rx queue belonging to the interface 'ifname' 203 */ 204 struct wlan_rps_data { 205 char ifname[IFNAMSIZ]; 206 uint16_t num_queues; 207 uint16_t cpu_map_list[WLAN_SVC_IFACE_NUM_QUEUES]; 208 }; 209 210 /** 211 * enum wlan_tp_level - indicates wlan throughput level 212 * @WLAN_SVC_TP_NONE: used for initialization 213 * @WLAN_SVC_TP_LOW: used to identify low throughput level 214 * @WLAN_SVC_TP_MEDIUM: used to identify medium throughput level 215 * @WLAN_SVC_TP_HIGH: used to identify high throughput level 216 * 217 * The different throughput levels are determined on the basis of # of tx and 218 * rx packets and other threshold values. For example, if the # of total 219 * packets sent or received by the driver is greater than 500 in the last 100ms 220 * , the driver has a high throughput requirement. The driver may tweak certain 221 * system parameters based on the throughput level. 222 */ 223 enum wlan_tp_level { 224 WLAN_SVC_TP_NONE, 225 WLAN_SVC_TP_LOW, 226 WLAN_SVC_TP_MEDIUM, 227 WLAN_SVC_TP_HIGH, 228 }; 229 230 /** 231 * struct wlan_core_minfreq - msg to [re]set the min freq of a set of cores 232 * @magic: signature token: 0xBABA 233 * @reserved: unused for now 234 * @coremask: bitmap of cores (16 bits) bit0=CORE0, bit1=CORE1, ... 235 * coremask is ONLY valid for set command 236 * valid values: 0xf0, or 0x0f 237 * @freq: frequency in KH 238 * > 0: "set to the given frequency" 239 * == 0: "free; remove the lock" 240 * 241 * Msg structure passed by the driver to cnss-daemon. 242 * 243 * Semantical Alert: 244 * There can be only one outstanding lock, even for different masks. 245 */ 246 #define WLAN_CORE_MINFREQ_MAGIC 0xBABA 247 struct wlan_core_minfreq { 248 uint16_t magic; 249 uint16_t reserved; 250 uint16_t coremask; 251 uint16_t freq; 252 }; 253 254 /* Indication to enable TCP delayed ack in TPUT indication */ 255 #define TCP_DEL_ACK_IND (1 << 0) 256 /* Indication to enable TCP advance window scaling in TPUT indication */ 257 #define TCP_ADV_WIN_SCL (1 << 1) 258 259 /** 260 * struct wlan_rx_tp_data - msg to TCP delayed ack and advance window scaling 261 * @level: Throughput level. 262 * @rx_tp_flags: Bit map of flags, for which this indcation will take 263 * effect, bit map for TCP_ADV_WIN_SCL and TCP_DEL_ACK_IND. 264 */ 265 struct wlan_rx_tp_data { 266 enum wlan_tp_level level; 267 uint16_t rx_tp_flags; 268 }; 269 270 #endif /* WLAN_NLINK_COMMON_H__ */ 271