1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef _QTN_FMAC_CORE_H_
18#define _QTN_FMAC_CORE_H_
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/sched.h>
23#include <linux/semaphore.h>
24#include <linux/ip.h>
25#include <linux/skbuff.h>
26#include <linux/if_arp.h>
27#include <linux/etherdevice.h>
28#include <net/sock.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>
36
37#include "qlink.h"
38#include "trans.h"
39
40#undef pr_fmt
41#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
42
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_SCAN_TIMEOUT_SEC 15
48
49#define QTNF_DEF_BSS_PRIORITY 0
50#define QTNF_DEF_WDOG_TIMEOUT 5
51#define QTNF_TX_TIMEOUT_TRSHLD 100
52
53extern const struct net_device_ops qtnf_netdev_ops;
54
55struct qtnf_bus;
56struct qtnf_vif;
57
58struct qtnf_sta_node {
59 struct list_head list;
60 u8 mac_addr[ETH_ALEN];
61};
62
63struct qtnf_sta_list {
64 struct list_head head;
65 atomic_t size;
66};
67
68enum qtnf_sta_state {
69 QTNF_STA_DISCONNECTED,
70 QTNF_STA_CONNECTING,
71 QTNF_STA_CONNECTED
72};
73
74struct qtnf_vif {
75 struct wireless_dev wdev;
76 u8 bssid[ETH_ALEN];
77 u8 mac_addr[ETH_ALEN];
78 u8 vifid;
79 u8 bss_priority;
80 u8 bss_status;
81 enum qtnf_sta_state sta_state;
82 u16 mgmt_frames_bitmask;
83 struct net_device *netdev;
84 struct qtnf_wmac *mac;
85
86 struct work_struct reset_work;
87 struct qtnf_sta_list sta_list;
88 unsigned long cons_tx_timeout_cnt;
89 int generation;
90
91 struct pcpu_sw_netstats __percpu *stats64;
92};
93
94struct qtnf_mac_info {
95 u8 bands_cap;
96 u8 dev_mac[ETH_ALEN];
97 u8 num_tx_chain;
98 u8 num_rx_chain;
99 u16 max_ap_assoc_sta;
100 u32 frag_thr;
101 u32 rts_thr;
102 u8 lretry_limit;
103 u8 sretry_limit;
104 u8 coverage_class;
105 u8 radar_detect_widths;
106 u32 max_acl_mac_addrs;
107 struct ieee80211_ht_cap ht_cap_mod_mask;
108 struct ieee80211_vht_cap vht_cap_mod_mask;
109 struct ieee80211_iface_combination *if_comb;
110 size_t n_if_comb;
111 u8 *extended_capabilities;
112 u8 *extended_capabilities_mask;
113 u8 extended_capabilities_len;
114};
115
116struct qtnf_chan_stats {
117 u32 chan_num;
118 u32 cca_tx;
119 u32 cca_rx;
120 u32 cca_busy;
121 u32 cca_try;
122 s8 chan_noise;
123};
124
125struct qtnf_wmac {
126 u8 macid;
127 u8 wiphy_registered;
128 u8 macaddr[ETH_ALEN];
129 struct qtnf_bus *bus;
130 struct qtnf_mac_info macinfo;
131 struct qtnf_vif iflist[QTNF_MAX_INTF];
132 struct cfg80211_scan_request *scan_req;
133 struct mutex mac_lock;
134 struct delayed_work scan_timeout;
135};
136
137struct qtnf_hw_info {
138 u16 ql_proto_ver;
139 u8 num_mac;
140 u8 mac_bitmap;
141 u32 fw_ver;
142 u32 hw_capab;
143 struct ieee80211_regdomain *rd;
144 u8 total_tx_chain;
145 u8 total_rx_chain;
146 char fw_version[ETHTOOL_FWVERS_LEN];
147 u32 hw_version;
148};
149
150struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
151struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
152void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac);
153struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus);
154int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
155 const char *name, unsigned char name_assign_type);
156void qtnf_main_work_queue(struct work_struct *work);
157int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
158int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac);
159
160struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
161struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
162void qtnf_wake_all_queues(struct net_device *ndev);
163void qtnf_update_rx_stats(struct net_device *ndev, const struct sk_buff *skb);
164void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb);
165
166void qtnf_virtual_intf_cleanup(struct net_device *ndev);
167
168void qtnf_netdev_updown(struct net_device *ndev, bool up);
169void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted);
170
171static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
172{
173 return *((void **)netdev_priv(dev));
174}
175
176#endif
177