linux/drivers/staging/wilc1000/host_interface.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#ifndef HOST_INT_H
   3#define HOST_INT_H
   4#include <linux/ieee80211.h>
   5#include "coreconfigurator.h"
   6
   7#define IP_ALEN  4
   8
   9#define IDLE_MODE       0x00
  10#define AP_MODE         0x01
  11#define STATION_MODE    0x02
  12#define GO_MODE         0x03
  13#define CLIENT_MODE     0x04
  14#define ACTION          0xD0
  15#define PROBE_REQ       0x40
  16#define PROBE_RESP      0x50
  17
  18#define ACTION_FRM_IDX                          0
  19#define PROBE_REQ_IDX                           1
  20#define MAX_NUM_STA                             9
  21#define ACTIVE_SCAN_TIME                        10
  22#define PASSIVE_SCAN_TIME                       1200
  23#define MIN_SCAN_TIME                           10
  24#define MAX_SCAN_TIME                           1200
  25#define DEFAULT_SCAN                            0
  26#define USER_SCAN                               BIT(0)
  27#define OBSS_PERIODIC_SCAN                      BIT(1)
  28#define OBSS_ONETIME_SCAN                       BIT(2)
  29#define GTK_RX_KEY_BUFF_LEN                     24
  30#define ADDKEY                                  0x1
  31#define REMOVEKEY                               0x2
  32#define DEFAULTKEY                              0x4
  33#define ADDKEY_AP                               0x8
  34#define MAX_NUM_SCANNED_NETWORKS                100
  35#define MAX_NUM_SCANNED_NETWORKS_SHADOW         130
  36#define MAX_NUM_PROBED_SSID                     10
  37#define CHANNEL_SCAN_TIME                       250
  38
  39#define TX_MIC_KEY_LEN                          8
  40#define RX_MIC_KEY_LEN                          8
  41#define PTK_KEY_LEN                             16
  42
  43#define TX_MIC_KEY_MSG_LEN                      26
  44#define RX_MIC_KEY_MSG_LEN                      48
  45#define PTK_KEY_MSG_LEN                         39
  46
  47#define PMKSA_KEY_LEN                           22
  48#define ETH_ALEN                                6
  49#define PMKID_LEN                               16
  50#define WILC_MAX_NUM_PMKIDS                     16
  51#define WILC_ADD_STA_LENGTH                     40
  52#define SCAN_EVENT_DONE_ABORTED
  53#define NUM_CONCURRENT_IFC                      2
  54#define DRV_HANDLER_SIZE                        5
  55#define DRV_HANDLER_MASK                        0x000000FF
  56
  57struct rf_info {
  58        u8 link_speed;
  59        s8 rssi;
  60        u32 tx_cnt;
  61        u32 rx_cnt;
  62        u32 tx_fail_cnt;
  63};
  64
  65enum host_if_state {
  66        HOST_IF_IDLE                    = 0,
  67        HOST_IF_SCANNING                = 1,
  68        HOST_IF_CONNECTING              = 2,
  69        HOST_IF_WAITING_CONN_RESP       = 3,
  70        HOST_IF_CONNECTED               = 4,
  71        HOST_IF_P2P_LISTEN              = 5,
  72        HOST_IF_FORCE_32BIT             = 0xFFFFFFFF
  73};
  74
  75struct host_if_pmkid {
  76        u8 bssid[ETH_ALEN];
  77        u8 pmkid[PMKID_LEN];
  78};
  79
  80struct host_if_pmkid_attr {
  81        u8 numpmkid;
  82        struct host_if_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
  83};
  84
  85enum CURRENT_TXRATE {
  86        AUTORATE        = 0,
  87        MBPS_1          = 1,
  88        MBPS_2          = 2,
  89        MBPS_5_5        = 5,
  90        MBPS_11         = 11,
  91        MBPS_6          = 6,
  92        MBPS_9          = 9,
  93        MBPS_12         = 12,
  94        MBPS_18         = 18,
  95        MBPS_24         = 24,
  96        MBPS_36         = 36,
  97        MBPS_48         = 48,
  98        MBPS_54         = 54
  99};
 100
 101struct cfg_param_attr {
 102        u32 flag;
 103        u8 ht_enable;
 104        u8 bss_type;
 105        u8 auth_type;
 106        u16 auth_timeout;
 107        u8 power_mgmt_mode;
 108        u16 short_retry_limit;
 109        u16 long_retry_limit;
 110        u16 frag_threshold;
 111        u16 rts_threshold;
 112        u16 preamble_type;
 113        u8 short_slot_allowed;
 114        u8 txop_prot_disabled;
 115        u16 beacon_interval;
 116        u16 dtim_period;
 117        enum SITESURVEY site_survey_enabled;
 118        u16 site_survey_scan_time;
 119        u8 scan_source;
 120        u16 active_scan_time;
 121        u16 passive_scan_time;
 122        enum CURRENT_TXRATE curr_tx_rate;
 123
 124};
 125
 126enum cfg_param {
 127        RETRY_SHORT             = BIT(0),
 128        RETRY_LONG              = BIT(1),
 129        FRAG_THRESHOLD          = BIT(2),
 130        RTS_THRESHOLD           = BIT(3),
 131        BSS_TYPE                = BIT(4),
 132        AUTH_TYPE               = BIT(5),
 133        AUTHEN_TIMEOUT          = BIT(6),
 134        POWER_MANAGEMENT        = BIT(7),
 135        PREAMBLE                = BIT(8),
 136        SHORT_SLOT_ALLOWED      = BIT(9),
 137        TXOP_PROT_DISABLE       = BIT(10),
 138        BEACON_INTERVAL         = BIT(11),
 139        DTIM_PERIOD             = BIT(12),
 140        SITE_SURVEY             = BIT(13),
 141        SITE_SURVEY_SCAN_TIME   = BIT(14),
 142        ACTIVE_SCANTIME         = BIT(15),
 143        PASSIVE_SCANTIME        = BIT(16),
 144        CURRENT_TX_RATE         = BIT(17),
 145        HT_ENABLE               = BIT(18),
 146};
 147
 148struct found_net_info {
 149        u8 bssid[6];
 150        s8 rssi;
 151};
 152
 153enum scan_event {
 154        SCAN_EVENT_NETWORK_FOUND        = 0,
 155        SCAN_EVENT_DONE                 = 1,
 156        SCAN_EVENT_ABORTED              = 2,
 157        SCAN_EVENT_FORCE_32BIT          = 0xFFFFFFFF
 158};
 159
 160enum conn_event {
 161        CONN_DISCONN_EVENT_CONN_RESP            = 0,
 162        CONN_DISCONN_EVENT_DISCONN_NOTIF        = 1,
 163        CONN_DISCONN_EVENT_FORCE_32BIT          = 0xFFFFFFFF
 164};
 165
 166enum KEY_TYPE {
 167        WEP,
 168        WPA_RX_GTK,
 169        WPA_PTK,
 170        PMKSA,
 171};
 172
 173typedef void (*wilc_scan_result)(enum scan_event, struct network_info *,
 174                                 void *, void *);
 175
 176typedef void (*wilc_connect_result)(enum conn_event,
 177                                     struct connect_info *,
 178                                     u8,
 179                                     struct disconnect_info *,
 180                                     void *);
 181
 182typedef void (*wilc_remain_on_chan_expired)(void *, u32);
 183typedef void (*wilc_remain_on_chan_ready)(void *);
 184
 185struct rcvd_net_info {
 186        u8 *buffer;
 187        u32 len;
 188};
 189
 190struct hidden_net_info {
 191        u8  *ssid;
 192        u8 ssid_len;
 193};
 194
 195struct hidden_network {
 196        struct hidden_net_info *net_info;
 197        u8 n_ssids;
 198};
 199
 200struct user_scan_req {
 201        wilc_scan_result scan_result;
 202        void *arg;
 203        u32 rcvd_ch_cnt;
 204        struct found_net_info net_info[MAX_NUM_SCANNED_NETWORKS];
 205};
 206
 207struct user_conn_req {
 208        u8 *bssid;
 209        u8 *ssid;
 210        u8 security;
 211        enum AUTHTYPE auth_type;
 212        size_t ssid_len;
 213        u8 *ies;
 214        size_t ies_len;
 215        wilc_connect_result conn_result;
 216        bool ht_capable;
 217        void *arg;
 218};
 219
 220struct drv_handler {
 221        u32 handler;
 222        u8 mode;
 223        u8 name;
 224};
 225
 226struct op_mode {
 227        u32 mode;
 228};
 229
 230struct get_mac_addr {
 231        u8 *mac_addr;
 232};
 233
 234struct ba_session_info {
 235        u8 bssid[ETH_ALEN];
 236        u8 tid;
 237        u16 buf_size;
 238        u16 time_out;
 239};
 240
 241struct remain_ch {
 242        u16 ch;
 243        u32 duration;
 244        wilc_remain_on_chan_expired expired;
 245        wilc_remain_on_chan_ready ready;
 246        void *arg;
 247        u32 id;
 248};
 249
 250struct reg_frame {
 251        bool reg;
 252        u16 frame_type;
 253        u8 reg_id;
 254};
 255
 256enum p2p_listen_state {
 257        P2P_IDLE,
 258        P2P_LISTEN,
 259        P2P_GRP_FORMATION
 260};
 261
 262struct wilc;
 263struct host_if_drv {
 264        struct user_scan_req usr_scan_req;
 265        struct user_conn_req usr_conn_req;
 266        struct remain_ch remain_on_ch;
 267        u8 remain_on_ch_pending;
 268        u64 p2p_timeout;
 269        u8 p2p_connect;
 270
 271        enum host_if_state hif_state;
 272
 273        u8 assoc_bssid[ETH_ALEN];
 274        struct cfg_param_attr cfg_values;
 275
 276        struct mutex cfg_values_lock;
 277        struct completion comp_test_key_block;
 278        struct completion comp_test_disconn_block;
 279        struct completion comp_get_rssi;
 280        struct completion comp_inactive_time;
 281
 282        struct timer_list scan_timer;
 283        struct timer_list connect_timer;
 284        struct timer_list remain_on_ch_timer;
 285
 286        bool IFC_UP;
 287        int driver_handler_id;
 288};
 289
 290struct add_sta_param {
 291        u8 bssid[ETH_ALEN];
 292        u16 aid;
 293        u8 rates_len;
 294        const u8 *rates;
 295        bool ht_supported;
 296        struct ieee80211_ht_cap ht_capa;
 297        u16 flags_mask;
 298        u16 flags_set;
 299};
 300
 301struct wilc_vif;
 302s32 wilc_remove_key(struct host_if_drv *hWFIDrv, const u8 *pu8StaAddress);
 303int wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
 304int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
 305int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
 306                             u8 index);
 307int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
 308                            u8 index, u8 mode, enum AUTHTYPE auth_type);
 309int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
 310                 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
 311                 u8 mode, u8 cipher_mode, u8 index);
 312s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
 313                           u32 *pu32InactiveTime);
 314int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
 315                    u8 index, u32 key_rsc_len, const u8 *key_rsc,
 316                    const u8 *rx_mic, const u8 *tx_mic, u8 mode,
 317                    u8 cipher_mode);
 318int wilc_set_pmkid_info(struct wilc_vif *vif,
 319                        struct host_if_pmkid_attr *pmkid);
 320int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
 321int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
 322                      size_t ssid_len, const u8 *ies, size_t ies_len,
 323                      wilc_connect_result connect_result, void *user_arg,
 324                      u8 security, enum AUTHTYPE auth_type,
 325                      u8 channel, void *join_params);
 326int wilc_disconnect(struct wilc_vif *vif, u16 reason_code);
 327int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
 328int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
 329int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
 330              u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
 331              size_t ies_len, wilc_scan_result scan_result, void *user_arg,
 332              struct hidden_network *hidden_network);
 333int wilc_hif_set_cfg(struct wilc_vif *vif,
 334                     struct cfg_param_attr *cfg_param);
 335int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
 336int wilc_deinit(struct wilc_vif *vif);
 337int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
 338                    u32 head_len, u8 *head, u32 tail_len, u8 *tail);
 339int wilc_del_beacon(struct wilc_vif *vif);
 340int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param);
 341int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
 342int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
 343int wilc_edit_station(struct wilc_vif *vif,
 344                      struct add_sta_param *sta_param);
 345int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
 346int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
 347                                u32 count);
 348int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
 349int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
 350                           u32 duration, u16 chan,
 351                           wilc_remain_on_chan_expired expired,
 352                           wilc_remain_on_chan_ready ready,
 353                           void *user_arg);
 354int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id);
 355int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
 356int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode,
 357                             u8 ifc_id);
 358int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode);
 359int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
 360void wilc_resolve_disconnect_aberration(struct wilc_vif *vif);
 361int wilc_get_vif_idx(struct wilc_vif *vif);
 362int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
 363int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
 364
 365extern bool wilc_optaining_ip;
 366extern u8 wilc_connected_ssid[6];
 367extern u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
 368
 369extern int wilc_connecting;
 370extern struct timer_list wilc_during_ip_timer;
 371
 372#endif
 373