Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
0004  * All rights reserved.
0005  */
0006 
0007 #ifndef WILC_HIF_H
0008 #define WILC_HIF_H
0009 #include <linux/ieee80211.h>
0010 #include "wlan_if.h"
0011 
0012 enum {
0013     WILC_IDLE_MODE = 0x0,
0014     WILC_AP_MODE = 0x1,
0015     WILC_STATION_MODE = 0x2,
0016     WILC_GO_MODE = 0x3,
0017     WILC_CLIENT_MODE = 0x4
0018 };
0019 
0020 #define WILC_MAX_NUM_PROBED_SSID        10
0021 
0022 #define WILC_TX_MIC_KEY_LEN         8
0023 #define WILC_RX_MIC_KEY_LEN         8
0024 
0025 #define WILC_ADD_STA_LENGTH         40
0026 #define WILC_NUM_CONCURRENT_IFC         2
0027 
0028 enum {
0029     WILC_SET_CFG = 0,
0030     WILC_GET_CFG
0031 };
0032 
0033 #define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
0034 
0035 struct rf_info {
0036     u8 link_speed;
0037     s8 rssi;
0038     u32 tx_cnt;
0039     u32 rx_cnt;
0040     u32 tx_fail_cnt;
0041 };
0042 
0043 enum host_if_state {
0044     HOST_IF_IDLE            = 0,
0045     HOST_IF_SCANNING        = 1,
0046     HOST_IF_CONNECTING      = 2,
0047     HOST_IF_WAITING_CONN_RESP   = 3,
0048     HOST_IF_CONNECTED       = 4,
0049     HOST_IF_P2P_LISTEN      = 5,
0050     HOST_IF_EXTERNAL_AUTH           = 6,
0051     HOST_IF_FORCE_32BIT     = 0xFFFFFFFF
0052 };
0053 
0054 struct cfg_param_attr {
0055     u32 flag;
0056     u16 short_retry_limit;
0057     u16 long_retry_limit;
0058     u16 frag_threshold;
0059     u16 rts_threshold;
0060 };
0061 
0062 enum cfg_param {
0063     WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
0064     WILC_CFG_PARAM_RETRY_LONG = BIT(1),
0065     WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
0066     WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
0067 };
0068 
0069 enum scan_event {
0070     SCAN_EVENT_NETWORK_FOUND    = 0,
0071     SCAN_EVENT_DONE         = 1,
0072     SCAN_EVENT_ABORTED      = 2,
0073     SCAN_EVENT_FORCE_32BIT      = 0xFFFFFFFF
0074 };
0075 
0076 enum conn_event {
0077     CONN_DISCONN_EVENT_CONN_RESP        = 0,
0078     CONN_DISCONN_EVENT_DISCONN_NOTIF    = 1,
0079     CONN_DISCONN_EVENT_FORCE_32BIT      = 0xFFFFFFFF
0080 };
0081 
0082 enum {
0083     WILC_HIF_SDIO = 0,
0084     WILC_HIF_SPI = BIT(0)
0085 };
0086 
0087 enum {
0088     WILC_MAC_STATUS_INIT = -1,
0089     WILC_MAC_STATUS_DISCONNECTED = 0,
0090     WILC_MAC_STATUS_CONNECTED = 1
0091 };
0092 
0093 struct wilc_rcvd_net_info {
0094     s8 rssi;
0095     u8 ch;
0096     u16 frame_len;
0097     struct ieee80211_mgmt *mgmt;
0098 };
0099 
0100 struct wilc_user_scan_req {
0101     void (*scan_result)(enum scan_event evt,
0102                 struct wilc_rcvd_net_info *info, void *priv);
0103     void *arg;
0104     u32 ch_cnt;
0105 };
0106 
0107 struct wilc_conn_info {
0108     u8 bssid[ETH_ALEN];
0109     u8 security;
0110     enum authtype auth_type;
0111     enum mfptype mfp_type;
0112     u8 ch;
0113     u8 *req_ies;
0114     size_t req_ies_len;
0115     u8 *resp_ies;
0116     u16 resp_ies_len;
0117     u16 status;
0118     void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
0119     void *arg;
0120     void *param;
0121 };
0122 
0123 struct wilc_remain_ch {
0124     u16 ch;
0125     u32 duration;
0126     void (*expired)(void *priv, u64 cookie);
0127     void *arg;
0128     u64 cookie;
0129 };
0130 
0131 struct wilc;
0132 struct host_if_drv {
0133     struct wilc_user_scan_req usr_scan_req;
0134     struct wilc_conn_info conn_info;
0135     struct wilc_remain_ch remain_on_ch;
0136     u64 p2p_timeout;
0137 
0138     enum host_if_state hif_state;
0139 
0140     u8 assoc_bssid[ETH_ALEN];
0141 
0142     struct timer_list scan_timer;
0143     struct wilc_vif *scan_timer_vif;
0144 
0145     struct timer_list connect_timer;
0146     struct wilc_vif *connect_timer_vif;
0147 
0148     struct timer_list remain_on_ch_timer;
0149     struct wilc_vif *remain_on_ch_timer_vif;
0150 
0151     bool ifc_up;
0152     u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
0153 };
0154 
0155 struct wilc_vif;
0156 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
0157          const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
0158          u8 mode, u8 cipher_mode, u8 index);
0159 int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len,
0160           const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode,
0161           u8 index);
0162 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
0163                u32 *out_val);
0164 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
0165             u8 index, u32 key_rsc_len, const u8 *key_rsc,
0166             const u8 *rx_mic, const u8 *tx_mic, u8 mode,
0167             u8 cipher_mode);
0168 int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
0169 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
0170 int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr);
0171 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
0172               size_t ies_len);
0173 int wilc_disconnect(struct wilc_vif *vif);
0174 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
0175 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
0176 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
0177           u8 *ch_freq_list, u8 ch_list_len,
0178           void (*scan_result_fn)(enum scan_event,
0179                      struct wilc_rcvd_net_info *, void *),
0180           void *user_arg, struct cfg80211_scan_request *request);
0181 int wilc_hif_set_cfg(struct wilc_vif *vif,
0182              struct cfg_param_attr *cfg_param);
0183 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
0184 int wilc_deinit(struct wilc_vif *vif);
0185 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
0186             struct cfg80211_beacon_data *params);
0187 int wilc_del_beacon(struct wilc_vif *vif);
0188 int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
0189              struct station_parameters *params);
0190 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
0191 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
0192 int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
0193               struct station_parameters *params);
0194 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
0195 int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
0196                 u8 *mc_list);
0197 int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
0198                u32 duration, u16 chan,
0199                void (*expired)(void *, u64),
0200                void *user_arg);
0201 int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
0202 void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
0203 int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
0204                 u8 ifc_id);
0205 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
0206 int wilc_get_vif_idx(struct wilc_vif *vif);
0207 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
0208 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
0209 void wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled);
0210 int wilc_set_external_auth_param(struct wilc_vif *vif,
0211                  struct cfg80211_external_auth_params *param);
0212 void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
0213 void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
0214 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
0215 void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
0216                 struct cfg80211_crypto_settings *crypto);
0217 int wilc_set_default_mgmt_key_index(struct wilc_vif *vif, u8 index);
0218 void wilc_handle_disconnect(struct wilc_vif *vif);
0219 
0220 #endif