2 * Copyright (c) 2015-2016 Quantenna Communications, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #ifndef _QTN_FMAC_CORE_H_
18 #define _QTN_FMAC_CORE_H_
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/sched.h>
23 #include <linux/semaphore.h>
25 #include <linux/skbuff.h>
26 #include <linux/if_arp.h>
27 #include <linux/etherdevice.h>
29 #include <net/lib80211.h>
30 #include <net/cfg80211.h>
31 #include <linux/vmalloc.h>
32 #include <linux/firmware.h>
33 #include <linux/ctype.h>
34 #include <linux/workqueue.h>
35 #include <linux/slab.h>
41 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
43 #define QTNF_MAX_SSID_LIST_LENGTH 2
44 #define QTNF_MAX_VSIE_LEN 255
45 #define QTNF_MAX_INTF 8
46 #define QTNF_MAX_EVENT_QUEUE_LEN 255
47 #define QTNF_DEFAULT_BG_SCAN_PERIOD 300
48 #define QTNF_MAX_BG_SCAN_PERIOD 0xffff
49 #define QTNF_SCAN_TIMEOUT_SEC 15
51 #define QTNF_DEF_BSS_PRIORITY 0
52 #define QTNF_DEF_WDOG_TIMEOUT 5
53 #define QTNF_TX_TIMEOUT_TRSHLD 100
55 extern const struct net_device_ops qtnf_netdev_ops
;
60 struct qtnf_sta_node
{
61 struct list_head list
;
62 u8 mac_addr
[ETH_ALEN
];
65 struct qtnf_sta_list
{
66 struct list_head head
;
71 QTNF_STA_DISCONNECTED
,
77 struct wireless_dev wdev
;
79 u8 mac_addr
[ETH_ALEN
];
83 enum qtnf_sta_state sta_state
;
84 u16 mgmt_frames_bitmask
;
85 struct net_device
*netdev
;
86 struct qtnf_wmac
*mac
;
88 struct work_struct reset_work
;
89 struct qtnf_sta_list sta_list
;
90 unsigned long cons_tx_timeout_cnt
;
93 struct pcpu_sw_netstats __percpu
*stats64
;
96 struct qtnf_mac_info
{
101 u16 max_ap_assoc_sta
;
107 u8 radar_detect_widths
;
108 u32 max_acl_mac_addrs
;
109 struct ieee80211_ht_cap ht_cap_mod_mask
;
110 struct ieee80211_vht_cap vht_cap_mod_mask
;
111 struct ieee80211_iface_combination
*if_comb
;
113 u8
*extended_capabilities
;
114 u8
*extended_capabilities_mask
;
115 u8 extended_capabilities_len
;
118 struct qtnf_chan_stats
{
130 u8 macaddr
[ETH_ALEN
];
131 struct qtnf_bus
*bus
;
132 struct qtnf_mac_info macinfo
;
133 struct qtnf_vif iflist
[QTNF_MAX_INTF
];
134 struct cfg80211_scan_request
*scan_req
;
135 struct mutex mac_lock
; /* lock during wmac speicific ops */
136 struct delayed_work scan_timeout
;
139 struct qtnf_hw_info
{
145 struct ieee80211_regdomain
*rd
;
148 char fw_version
[ETHTOOL_FWVERS_LEN
];
152 struct qtnf_vif
*qtnf_mac_get_free_vif(struct qtnf_wmac
*mac
);
153 struct qtnf_vif
*qtnf_mac_get_base_vif(struct qtnf_wmac
*mac
);
154 void qtnf_mac_iface_comb_free(struct qtnf_wmac
*mac
);
155 struct wiphy
*qtnf_wiphy_allocate(struct qtnf_bus
*bus
);
156 int qtnf_core_net_attach(struct qtnf_wmac
*mac
, struct qtnf_vif
*priv
,
157 const char *name
, unsigned char name_assign_type
);
158 void qtnf_main_work_queue(struct work_struct
*work
);
159 int qtnf_cmd_send_update_phy_params(struct qtnf_wmac
*mac
, u32 changed
);
160 int qtnf_cmd_send_get_phy_params(struct qtnf_wmac
*mac
);
162 struct qtnf_wmac
*qtnf_core_get_mac(const struct qtnf_bus
*bus
, u8 macid
);
163 struct net_device
*qtnf_classify_skb(struct qtnf_bus
*bus
, struct sk_buff
*skb
);
164 void qtnf_wake_all_queues(struct net_device
*ndev
);
165 void qtnf_update_rx_stats(struct net_device
*ndev
, const struct sk_buff
*skb
);
166 void qtnf_update_tx_stats(struct net_device
*ndev
, const struct sk_buff
*skb
);
168 void qtnf_virtual_intf_cleanup(struct net_device
*ndev
);
170 void qtnf_netdev_updown(struct net_device
*ndev
, bool up
);
171 void qtnf_scan_done(struct qtnf_wmac
*mac
, bool aborted
);
173 static inline struct qtnf_vif
*qtnf_netdev_get_priv(struct net_device
*dev
)
175 return *((void **)netdev_priv(dev
));
178 #endif /* _QTN_FMAC_CORE_H_ */