1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
4 #ifndef _QTN_FMAC_CORE_H_
5 #define _QTN_FMAC_CORE_H_
7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/sched.h>
10 #include <linux/semaphore.h>
12 #include <linux/skbuff.h>
13 #include <linux/if_arp.h>
14 #include <linux/etherdevice.h>
16 #include <net/lib80211.h>
17 #include <net/cfg80211.h>
18 #include <linux/vmalloc.h>
19 #include <linux/firmware.h>
20 #include <linux/ctype.h>
21 #include <linux/workqueue.h>
22 #include <linux/slab.h>
23 #include <linux/platform_device.h>
27 #include "qlink_util.h"
30 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
32 #define QTNF_MAX_VSIE_LEN 255
33 #define QTNF_MAX_INTF 8
34 #define QTNF_MAX_EVENT_QUEUE_LEN 255
35 #define QTNF_SCAN_TIMEOUT_SEC 15
37 #define QTNF_DEF_BSS_PRIORITY 0
38 #define QTNF_DEF_WDOG_TIMEOUT 5
39 #define QTNF_TX_TIMEOUT_TRSHLD 100
41 extern const struct net_device_ops qtnf_netdev_ops;
46 struct qtnf_sta_node {
47 struct list_head list;
48 u8 mac_addr[ETH_ALEN];
51 struct qtnf_sta_list {
52 struct list_head head;
57 struct wireless_dev wdev;
59 u8 mac_addr[ETH_ALEN];
63 u16 mgmt_frames_bitmask;
64 struct net_device *netdev;
65 struct qtnf_wmac *mac;
67 struct work_struct reset_work;
68 struct work_struct high_pri_tx_work;
69 struct sk_buff_head high_pri_tx_queue;
70 struct qtnf_sta_list sta_list;
71 unsigned long cons_tx_timeout_cnt;
75 struct qtnf_mac_info {
85 u8 radar_detect_widths;
87 u16 max_acl_mac_addrs;
88 struct ieee80211_ht_cap ht_cap_mod_mask;
89 struct ieee80211_vht_cap vht_cap_mod_mask;
90 struct ieee80211_iface_combination *if_comb;
92 u8 *extended_capabilities;
93 u8 *extended_capabilities_mask;
94 u8 extended_capabilities_len;
95 struct wiphy_wowlan_support *wowlan;
101 u8 macaddr[ETH_ALEN];
102 struct qtnf_bus *bus;
103 struct qtnf_mac_info macinfo;
104 struct qtnf_vif iflist[QTNF_MAX_INTF];
105 struct cfg80211_scan_request *scan_req;
106 struct mutex mac_lock; /* lock during wmac speicific ops */
107 struct delayed_work scan_timeout;
108 struct ieee80211_regdomain *rd;
109 struct platform_device *pdev;
112 struct qtnf_hw_info {
119 char fw_version[ETHTOOL_FWVERS_LEN];
121 u8 hw_capab[QLINK_HW_CAPAB_NUM / BITS_PER_BYTE + 1];
124 struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
125 struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
126 void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac);
127 void qtnf_mac_ext_caps_free(struct qtnf_wmac *mac);
128 bool qtnf_slave_radar_get(void);
129 bool qtnf_dfs_offload_get(void);
130 struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus,
131 struct platform_device *pdev);
132 int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
133 const char *name, unsigned char name_assign_type);
134 void qtnf_main_work_queue(struct work_struct *work);
135 int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
137 struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
138 struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
139 void qtnf_wake_all_queues(struct net_device *ndev);
141 void qtnf_virtual_intf_cleanup(struct net_device *ndev);
143 void qtnf_netdev_updown(struct net_device *ndev, bool up);
144 void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted);
145 struct dentry *qtnf_get_debugfs_dir(void);
146 bool qtnf_netdev_is_qtn(const struct net_device *ndev);
148 static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
150 return *((void **)netdev_priv(dev));
153 static inline bool qtnf_hwcap_is_set(const struct qtnf_hw_info *info,
156 return qtnf_utils_is_bit_set(info->hw_capab, bit,
157 sizeof(info->hw_capab));
160 #endif /* _QTN_FMAC_CORE_H_ */