1 /* 2 * DHD Linux header file (dhd_linux exports for cfg80211 and other components) 3 * 4 * Copyright (C) 1999-2017, Broadcom Corporation 5 * 6 * Unless you and Broadcom execute a separate written software license 7 * agreement governing use of this software, this software is licensed to you 8 * under the terms of the GNU General Public License version 2 (the "GPL"), 9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 10 * following added to such license: 11 * 12 * As a special exception, the copyright holders of this software give you 13 * permission to link this software with independent modules, and to copy and 14 * distribute the resulting executable under terms of your choice, provided that 15 * you also meet, for each linked independent module, the terms and conditions of 16 * the license of that module. An independent module is a module which is not 17 * derived from this software. The special exception does not apply to any 18 * modifications of the software. 19 * 20 * Notwithstanding the above, under no circumstances may you combine this 21 * software in any way with any other Broadcom software provided under a license 22 * other than the GPL, without Broadcom's express prior written consent. 23 * 24 * 25 * <<Broadcom-WL-IPTag/Open:>> 26 * 27 * $Id: dhd_linux.h 699532 2017-05-15 11:00:39Z $ 28 */ 29 30 /* wifi platform functions for power, interrupt and pre-alloc, either 31 * from Android-like platform device data, or Broadcom wifi platform 32 * device data. 33 * 34 */ 35 #ifndef __DHD_LINUX_H__ 36 #define __DHD_LINUX_H__ 37 38 #include <linux/kernel.h> 39 #include <linux/init.h> 40 #include <linux/fs.h> 41 #include <dngl_stats.h> 42 #include <dhd.h> 43 #ifdef DHD_WMF 44 #include <dhd_wmf_linux.h> 45 #endif 46 /* Linux wireless extension support */ 47 #if defined(WL_WIRELESS_EXT) 48 #include <wl_iw.h> 49 #endif /* defined(WL_WIRELESS_EXT) */ 50 #if defined(CONFIG_HAS_EARLYSUSPEND) && defined(DHD_USE_EARLYSUSPEND) 51 #include <linux/earlysuspend.h> 52 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) && defined(DHD_USE_EARLYSUSPEND) */ 53 54 /* dongle status */ 55 enum wifi_adapter_status { 56 WIFI_STATUS_POWER_ON = 0, 57 WIFI_STATUS_ATTACH, 58 WIFI_STATUS_FW_READY, 59 WIFI_STATUS_DETTACH 60 }; 61 #define wifi_chk_adapter_status(adapter, stat) (test_bit(stat, &(adapter)->status)) 62 #define wifi_get_adapter_status(adapter, stat) (test_bit(stat, &(adapter)->status)) 63 #define wifi_set_adapter_status(adapter, stat) (set_bit(stat, &(adapter)->status)) 64 #define wifi_clr_adapter_status(adapter, stat) (clear_bit(stat, &(adapter)->status)) 65 #define wifi_chg_adapter_status(adapter, stat) (change_bit(stat, &(adapter)->status)) 66 67 #define DHD_REGISTRATION_TIMEOUT 12000 /* msec : allowed time to finished dhd registration */ 68 #define DHD_FW_READY_TIMEOUT 5000 /* msec : allowed time to finished fw download */ 69 70 typedef struct wifi_adapter_info { 71 const char *name; 72 uint irq_num; 73 uint intr_flags; 74 const char *fw_path; 75 const char *nv_path; 76 const char *clm_path; 77 const char *conf_path; 78 void *wifi_plat_data; /* wifi ctrl func, for backward compatibility */ 79 uint bus_type; 80 uint bus_num; 81 uint slot_num; 82 wait_queue_head_t status_event; 83 unsigned long status; 84 #if defined(BT_OVER_SDIO) 85 const char *btfw_path; 86 #endif /* defined (BT_OVER_SDIO) */ 87 #ifdef BUS_POWER_RESTORE 88 #if defined(BCMSDIO) 89 struct sdio_func *sdio_func; 90 #endif /* BCMSDIO */ 91 #if defined(BCMPCIE) 92 struct pci_dev *pci_dev; 93 struct pci_saved_state *pci_saved_state; 94 #endif /* BCMPCIE */ 95 #endif 96 } wifi_adapter_info_t; 97 98 #define WLAN_PLAT_NODFS_FLAG 0x01 99 #define WLAN_PLAT_AP_FLAG 0x02 100 struct wifi_platform_data { 101 #ifdef BUS_POWER_RESTORE 102 int (*set_power)(int val, wifi_adapter_info_t *adapter); 103 #else 104 int (*set_power)(int val); 105 #endif 106 int (*set_reset)(int val); 107 int (*set_carddetect)(int val); 108 void *(*mem_prealloc)(int section, unsigned long size); 109 int (*get_mac_addr)(unsigned char *buf); 110 #if defined(CUSTOM_COUNTRY_CODE) 111 void *(*get_country_code)(char *ccode, u32 flags); 112 #else /* defined (CUSTOM_COUNTRY_CODE) */ 113 void *(*get_country_code)(char *ccode); 114 #endif 115 }; 116 117 typedef struct bcmdhd_wifi_platdata { 118 uint num_adapters; 119 wifi_adapter_info_t *adapters; 120 } bcmdhd_wifi_platdata_t; 121 122 /** Per STA params. A list of dhd_sta objects are managed in dhd_if */ 123 typedef struct dhd_sta { 124 cumm_ctr_t cumm_ctr; /* cummulative queue length of child flowrings */ 125 uint16 flowid[NUMPRIO]; /* allocated flow ring ids (by priority) */ 126 void *ifp; /* associated dhd_if */ 127 struct ether_addr ea; /* stations ethernet mac address */ 128 struct list_head list; /* link into dhd_if::sta_list */ 129 int idx; /* index of self in dhd_pub::sta_pool[] */ 130 int ifidx; /* index of interface in dhd */ 131 #ifdef DHD_WMF 132 struct dhd_sta *psta_prim; /* primary index of psta interface */ 133 #endif /* DHD_WMF */ 134 } dhd_sta_t; 135 typedef dhd_sta_t dhd_sta_pool_t; 136 137 int dhd_wifi_platform_register_drv(void); 138 void dhd_wifi_platform_unregister_drv(void); 139 wifi_adapter_info_t *dhd_wifi_platform_attach_adapter(uint32 bus_type, 140 uint32 bus_num, uint32 slot_num, unsigned long status); 141 wifi_adapter_info_t *dhd_wifi_platform_get_adapter(uint32 bus_type, uint32 bus_num, 142 uint32 slot_num); 143 int wifi_platform_set_power(wifi_adapter_info_t *adapter, bool on, unsigned long msec); 144 int wifi_platform_bus_enumerate(wifi_adapter_info_t *adapter, bool device_present); 145 int wifi_platform_get_irq_number(wifi_adapter_info_t *adapter, unsigned long *irq_flags_ptr); 146 int wifi_platform_get_mac_addr(wifi_adapter_info_t *adapter, unsigned char *buf); 147 #ifdef CUSTOM_COUNTRY_CODE 148 void *wifi_platform_get_country_code(wifi_adapter_info_t *adapter, char *ccode, 149 u32 flags); 150 #else 151 void *wifi_platform_get_country_code(wifi_adapter_info_t *adapter, char *ccode); 152 #endif /* CUSTOM_COUNTRY_CODE */ 153 void* wifi_platform_prealloc(wifi_adapter_info_t *adapter, int section, unsigned long size); 154 void* wifi_platform_get_prealloc_func_ptr(wifi_adapter_info_t *adapter); 155 156 int dhd_get_fw_mode(struct dhd_info *dhdinfo); 157 bool dhd_update_fw_nv_path(struct dhd_info *dhdinfo); 158 159 #ifdef DHD_WMF 160 dhd_wmf_t* dhd_wmf_conf(dhd_pub_t *dhdp, uint32 idx); 161 int dhd_get_wmf_psta_disable(dhd_pub_t *dhdp, uint32 idx); 162 int dhd_set_wmf_psta_disable(dhd_pub_t *dhdp, uint32 idx, int val); 163 void dhd_update_psta_interface_for_sta(dhd_pub_t *dhdp, char* ifname, 164 void* mac_addr, void* event_data); 165 #endif /* DHD_WMF */ 166 #if defined(BT_OVER_SDIO) 167 int dhd_net_bus_get(struct net_device *dev); 168 int dhd_net_bus_put(struct net_device *dev); 169 #endif /* BT_OVER_SDIO */ 170 #ifdef HOFFLOAD_MODULES 171 extern void dhd_free_module_memory(struct dhd_bus *bus, struct module_metadata *hmem); 172 extern void* dhd_alloc_module_memory(struct dhd_bus *bus, uint32_t size, 173 struct module_metadata *hmem); 174 #endif /* HOFFLOAD_MODULES */ 175 #if defined(WLADPS) || defined(WLADPS_PRIVATE_CMD) 176 #define ADPS_ENABLE 1 177 #define ADPS_DISABLE 0 178 typedef struct bcm_iov_buf { 179 uint16 version; 180 uint16 len; 181 uint16 id; 182 uint16 data[1]; 183 } bcm_iov_buf_t; 184 185 int dhd_enable_adps(dhd_pub_t *dhd, uint8 on); 186 #endif /* WLADPS || WLADPS_PRIVATE_CMD */ 187 #endif /* __DHD_LINUX_H__ */ 188