0001
0002
0003
0004
0005
0006
0007 #ifndef WILC_NETDEV_H
0008 #define WILC_NETDEV_H
0009
0010 #include <linux/tcp.h>
0011 #include <linux/ieee80211.h>
0012 #include <net/cfg80211.h>
0013 #include <net/ieee80211_radiotap.h>
0014 #include <linux/if_arp.h>
0015 #include <linux/gpio/consumer.h>
0016
0017 #include "hif.h"
0018 #include "wlan.h"
0019 #include "wlan_cfg.h"
0020
0021 #define FLOW_CONTROL_LOWER_THRESHOLD 128
0022 #define FLOW_CONTROL_UPPER_THRESHOLD 256
0023
0024 #define PMKID_FOUND 1
0025 #define NUM_STA_ASSOCIATED 8
0026
0027 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
0028 #define DEFAULT_LINK_SPEED 72
0029
0030 struct wilc_wfi_stats {
0031 unsigned long rx_packets;
0032 unsigned long tx_packets;
0033 unsigned long rx_bytes;
0034 unsigned long tx_bytes;
0035 u64 rx_time;
0036 u64 tx_time;
0037
0038 };
0039
0040 struct wilc_wfi_key {
0041 u8 *key;
0042 u8 *seq;
0043 int key_len;
0044 int seq_len;
0045 u32 cipher;
0046 };
0047
0048 struct sta_info {
0049 u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN];
0050 };
0051
0052
0053 struct wilc_wfi_p2p_listen_params {
0054 struct ieee80211_channel *listen_ch;
0055 u32 listen_duration;
0056 u64 listen_cookie;
0057 };
0058
0059 static const u32 wilc_cipher_suites[] = {
0060 WLAN_CIPHER_SUITE_TKIP,
0061 WLAN_CIPHER_SUITE_CCMP,
0062 WLAN_CIPHER_SUITE_AES_CMAC
0063 };
0064
0065 #define CHAN2G(_channel, _freq, _flags) { \
0066 .band = NL80211_BAND_2GHZ, \
0067 .center_freq = (_freq), \
0068 .hw_value = (_channel), \
0069 .flags = (_flags), \
0070 .max_antenna_gain = 0, \
0071 .max_power = 30, \
0072 }
0073
0074 static const struct ieee80211_channel wilc_2ghz_channels[] = {
0075 CHAN2G(1, 2412, 0),
0076 CHAN2G(2, 2417, 0),
0077 CHAN2G(3, 2422, 0),
0078 CHAN2G(4, 2427, 0),
0079 CHAN2G(5, 2432, 0),
0080 CHAN2G(6, 2437, 0),
0081 CHAN2G(7, 2442, 0),
0082 CHAN2G(8, 2447, 0),
0083 CHAN2G(9, 2452, 0),
0084 CHAN2G(10, 2457, 0),
0085 CHAN2G(11, 2462, 0),
0086 CHAN2G(12, 2467, 0),
0087 CHAN2G(13, 2472, 0),
0088 CHAN2G(14, 2484, 0)
0089 };
0090
0091 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
0092 .bitrate = (_rate), \
0093 .hw_value = (_hw_value), \
0094 .flags = (_flags), \
0095 }
0096
0097 static struct ieee80211_rate wilc_bitrates[] = {
0098 RATETAB_ENT(10, 0, 0),
0099 RATETAB_ENT(20, 1, 0),
0100 RATETAB_ENT(55, 2, 0),
0101 RATETAB_ENT(110, 3, 0),
0102 RATETAB_ENT(60, 9, 0),
0103 RATETAB_ENT(90, 6, 0),
0104 RATETAB_ENT(120, 7, 0),
0105 RATETAB_ENT(180, 8, 0),
0106 RATETAB_ENT(240, 9, 0),
0107 RATETAB_ENT(360, 10, 0),
0108 RATETAB_ENT(480, 11, 0),
0109 RATETAB_ENT(540, 12, 0)
0110 };
0111
0112 struct wilc_priv {
0113 struct wireless_dev wdev;
0114 struct cfg80211_scan_request *scan_req;
0115
0116 struct wilc_wfi_p2p_listen_params remain_on_ch_params;
0117 u64 tx_cookie;
0118
0119 bool cfg_scanning;
0120
0121 u8 associated_bss[ETH_ALEN];
0122 struct sta_info assoc_stainfo;
0123 struct sk_buff *skb;
0124 struct net_device *dev;
0125 struct host_if_drv *hif_drv;
0126 struct wilc_pmkid_attr pmkid_list;
0127
0128
0129 struct net_device *real_ndev;
0130 struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA];
0131 struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA];
0132 struct wilc_wfi_key *wilc_igtk[2];
0133 u8 wilc_groupkey;
0134
0135
0136 struct mutex scan_req_lock;
0137 bool p2p_listen_state;
0138 int scanned_cnt;
0139
0140 u64 inc_roc_cookie;
0141 };
0142
0143 #define MAX_TCP_SESSION 25
0144 #define MAX_PENDING_ACKS 256
0145
0146 struct ack_session_info {
0147 u32 seq_num;
0148 u32 bigger_ack_num;
0149 u16 src_port;
0150 u16 dst_port;
0151 u16 status;
0152 };
0153
0154 struct pending_acks {
0155 u32 ack_num;
0156 u32 session_index;
0157 struct txq_entry_t *txqe;
0158 };
0159
0160 struct tcp_ack_filter {
0161 struct ack_session_info ack_session_info[2 * MAX_TCP_SESSION];
0162 struct pending_acks pending_acks[MAX_PENDING_ACKS];
0163 u32 pending_base;
0164 u32 tcp_session;
0165 u32 pending_acks_idx;
0166 bool enabled;
0167 };
0168
0169 struct wilc_vif {
0170 u8 idx;
0171 u8 iftype;
0172 int monitor_flag;
0173 int mac_opened;
0174 u32 mgmt_reg_stypes;
0175 struct net_device_stats netstats;
0176 struct wilc *wilc;
0177 u8 bssid[ETH_ALEN];
0178 struct host_if_drv *hif_drv;
0179 struct net_device *ndev;
0180 struct timer_list during_ip_timer;
0181 struct timer_list periodic_rssi;
0182 struct rf_info periodic_stat;
0183 struct tcp_ack_filter ack_filter;
0184 bool connecting;
0185 struct wilc_priv priv;
0186 struct list_head list;
0187 struct cfg80211_bss *bss;
0188 struct cfg80211_external_auth_params auth;
0189 };
0190
0191 struct wilc_tx_queue_status {
0192 u8 buffer[AC_BUFFER_SIZE];
0193 u16 end_index;
0194 u16 cnt[NQUEUES];
0195 u16 sum;
0196 bool initialized;
0197 };
0198
0199 struct wilc {
0200 struct wiphy *wiphy;
0201 const struct wilc_hif_func *hif_func;
0202 int io_type;
0203 s8 mac_status;
0204 struct clk *rtc_clk;
0205 bool initialized;
0206 u32 chipid;
0207 bool power_save_mode;
0208 int dev_irq_num;
0209 int close;
0210 u8 vif_num;
0211 struct list_head vif_list;
0212
0213
0214 struct mutex vif_mutex;
0215 struct srcu_struct srcu;
0216 u8 open_ifcs;
0217
0218
0219 struct mutex txq_add_to_head_cs;
0220
0221
0222 spinlock_t txq_spinlock;
0223
0224
0225 struct mutex rxq_cs;
0226
0227
0228 struct mutex hif_cs;
0229
0230 struct completion cfg_event;
0231 struct completion sync_event;
0232 struct completion txq_event;
0233 struct completion txq_thread_started;
0234
0235 struct task_struct *txq_thread;
0236
0237 int quit;
0238
0239
0240 struct mutex cfg_cmd_lock;
0241 struct wilc_cfg_frame cfg_frame;
0242 u32 cfg_frame_offset;
0243 u8 cfg_seq_no;
0244
0245 u8 *rx_buffer;
0246 u32 rx_buffer_offset;
0247 u8 *tx_buffer;
0248 u32 *vmm_table;
0249
0250 struct txq_handle txq[NQUEUES];
0251 int txq_entries;
0252
0253 struct wilc_tx_queue_status tx_q_limit;
0254 struct rxq_entry_t rxq_head;
0255
0256 const struct firmware *firmware;
0257
0258 struct device *dev;
0259 bool suspend_event;
0260
0261 struct workqueue_struct *hif_workqueue;
0262 struct wilc_cfg cfg;
0263 void *bus_data;
0264 struct net_device *monitor_dev;
0265
0266
0267 struct mutex deinit_lock;
0268 u8 sta_ch;
0269 u8 op_ch;
0270 struct ieee80211_channel channels[ARRAY_SIZE(wilc_2ghz_channels)];
0271 struct ieee80211_rate bitrates[ARRAY_SIZE(wilc_bitrates)];
0272 struct ieee80211_supported_band band;
0273 u32 cipher_suites[ARRAY_SIZE(wilc_cipher_suites)];
0274 };
0275
0276 struct wilc_wfi_mon_priv {
0277 struct net_device *real_ndev;
0278 };
0279
0280 void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
0281 void wilc_mac_indicate(struct wilc *wilc);
0282 void wilc_netdev_cleanup(struct wilc *wilc);
0283 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size, bool is_auth);
0284 void wilc_wlan_set_bssid(struct net_device *wilc_netdev, const u8 *bssid,
0285 u8 mode);
0286 struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
0287 int vif_type, enum nl80211_iftype type,
0288 bool rtnl_locked);
0289 #endif