hif.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
  4. * All rights reserved.
  5. */
  6. #ifndef WILC_HIF_H
  7. #define WILC_HIF_H
  8. #include <linux/ieee80211.h>
  9. #include "wlan_if.h"
  10. enum {
  11. WILC_IDLE_MODE = 0x0,
  12. WILC_AP_MODE = 0x1,
  13. WILC_STATION_MODE = 0x2,
  14. WILC_GO_MODE = 0x3,
  15. WILC_CLIENT_MODE = 0x4
  16. };
  17. #define WILC_MAX_NUM_PROBED_SSID 10
  18. #define WILC_TX_MIC_KEY_LEN 8
  19. #define WILC_RX_MIC_KEY_LEN 8
  20. #define WILC_ADD_STA_LENGTH 40
  21. #define WILC_NUM_CONCURRENT_IFC 2
  22. enum {
  23. WILC_SET_CFG = 0,
  24. WILC_GET_CFG
  25. };
  26. struct rf_info {
  27. u8 link_speed;
  28. s8 rssi;
  29. u32 tx_cnt;
  30. u32 rx_cnt;
  31. u32 tx_fail_cnt;
  32. };
  33. enum host_if_state {
  34. HOST_IF_IDLE = 0,
  35. HOST_IF_SCANNING = 1,
  36. HOST_IF_CONNECTING = 2,
  37. HOST_IF_WAITING_CONN_RESP = 3,
  38. HOST_IF_CONNECTED = 4,
  39. HOST_IF_P2P_LISTEN = 5,
  40. HOST_IF_EXTERNAL_AUTH = 6,
  41. HOST_IF_FORCE_32BIT = 0xFFFFFFFF
  42. };
  43. struct cfg_param_attr {
  44. u32 flag;
  45. u16 short_retry_limit;
  46. u16 long_retry_limit;
  47. u16 frag_threshold;
  48. u16 rts_threshold;
  49. };
  50. enum cfg_param {
  51. WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
  52. WILC_CFG_PARAM_RETRY_LONG = BIT(1),
  53. WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
  54. WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
  55. };
  56. enum scan_event {
  57. SCAN_EVENT_NETWORK_FOUND = 0,
  58. SCAN_EVENT_DONE = 1,
  59. SCAN_EVENT_ABORTED = 2,
  60. SCAN_EVENT_FORCE_32BIT = 0xFFFFFFFF
  61. };
  62. enum conn_event {
  63. CONN_DISCONN_EVENT_CONN_RESP = 0,
  64. CONN_DISCONN_EVENT_DISCONN_NOTIF = 1,
  65. CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF
  66. };
  67. enum {
  68. WILC_HIF_SDIO = 0,
  69. WILC_HIF_SPI = BIT(0)
  70. };
  71. enum {
  72. WILC_MAC_STATUS_INIT = -1,
  73. WILC_MAC_STATUS_DISCONNECTED = 0,
  74. WILC_MAC_STATUS_CONNECTED = 1
  75. };
  76. struct wilc_rcvd_net_info {
  77. s8 rssi;
  78. u8 ch;
  79. u16 frame_len;
  80. struct ieee80211_mgmt *mgmt;
  81. };
  82. struct wilc_priv;
  83. struct wilc_user_scan_req {
  84. void (*scan_result)(enum scan_event evt,
  85. struct wilc_rcvd_net_info *info,
  86. struct wilc_priv *priv);
  87. struct wilc_priv *priv;
  88. u32 ch_cnt;
  89. };
  90. struct wilc_join_bss_param;
  91. struct wilc_conn_info {
  92. u8 bssid[ETH_ALEN];
  93. u8 security;
  94. enum authtype auth_type;
  95. enum mfptype mfp_type;
  96. u8 *req_ies;
  97. size_t req_ies_len;
  98. u8 *resp_ies;
  99. u16 resp_ies_len;
  100. u16 status;
  101. void (*conn_result)(enum conn_event evt, u8 status,
  102. struct wilc_priv *priv);
  103. struct wilc_priv *priv;
  104. struct wilc_join_bss_param *param;
  105. };
  106. struct wilc_vif;
  107. struct wilc_remain_ch {
  108. u16 ch;
  109. void (*expired)(struct wilc_vif *vif, u64 cookie);
  110. struct wilc_vif *vif;
  111. u64 cookie;
  112. };
  113. struct wilc;
  114. struct host_if_drv {
  115. struct wilc_user_scan_req usr_scan_req;
  116. struct wilc_conn_info conn_info;
  117. struct wilc_remain_ch remain_on_ch;
  118. u64 p2p_timeout;
  119. enum host_if_state hif_state;
  120. u8 assoc_bssid[ETH_ALEN];
  121. struct timer_list scan_timer;
  122. struct wilc_vif *scan_timer_vif;
  123. struct timer_list connect_timer;
  124. struct wilc_vif *connect_timer_vif;
  125. struct timer_list remain_on_ch_timer;
  126. struct wilc_vif *remain_on_ch_timer_vif;
  127. bool ifc_up;
  128. u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
  129. };
  130. int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
  131. const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
  132. u8 mode, u8 cipher_mode, u8 index);
  133. int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len,
  134. const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode,
  135. u8 index);
  136. s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
  137. u32 *out_val);
  138. int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
  139. u8 index, u32 key_rsc_len, const u8 *key_rsc,
  140. const u8 *rx_mic, const u8 *tx_mic, u8 mode,
  141. u8 cipher_mode);
  142. int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
  143. int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
  144. int wilc_set_mac_address(struct wilc_vif *vif, const u8 *mac_addr);
  145. int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
  146. size_t ies_len);
  147. int wilc_disconnect(struct wilc_vif *vif);
  148. int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
  149. int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
  150. int wilc_scan(struct wilc_vif *vif, u8 scan_source,
  151. u8 scan_type, u8 *ch_freq_list,
  152. void (*scan_result_fn)(enum scan_event,
  153. struct wilc_rcvd_net_info *,
  154. struct wilc_priv *),
  155. struct cfg80211_scan_request *request);
  156. int wilc_hif_set_cfg(struct wilc_vif *vif,
  157. struct cfg_param_attr *cfg_param);
  158. int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
  159. int wilc_deinit(struct wilc_vif *vif);
  160. int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
  161. struct cfg80211_beacon_data *params);
  162. int wilc_del_beacon(struct wilc_vif *vif);
  163. int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
  164. struct station_parameters *params);
  165. int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
  166. int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
  167. int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
  168. struct station_parameters *params);
  169. int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
  170. int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
  171. u8 *mc_list);
  172. int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, u16 chan,
  173. void (*expired)(struct wilc_vif *, u64));
  174. int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
  175. void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
  176. int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
  177. u8 ifc_id);
  178. int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
  179. int wilc_get_vif_idx(struct wilc_vif *vif);
  180. int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
  181. int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
  182. void wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled);
  183. int wilc_set_external_auth_param(struct wilc_vif *vif,
  184. struct cfg80211_external_auth_params *param);
  185. void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
  186. void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
  187. void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
  188. struct wilc_join_bss_param *
  189. wilc_parse_join_bss_param(struct cfg80211_bss *bss,
  190. struct cfg80211_crypto_settings *crypto);
  191. int wilc_set_default_mgmt_key_index(struct wilc_vif *vif, u8 index);
  192. void wilc_handle_disconnect(struct wilc_vif *vif);
  193. #endif