]> Git Repo - linux.git/blob - drivers/net/wireless/quantenna/qtnfmac/core.h
Linux 6.14-rc3
[linux.git] / drivers / net / wireless / quantenna / qtnfmac / core.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3
4 #ifndef _QTN_FMAC_CORE_H_
5 #define _QTN_FMAC_CORE_H_
6
7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/sched.h>
10 #include <linux/semaphore.h>
11 #include <linux/ip.h>
12 #include <linux/skbuff.h>
13 #include <linux/if_arp.h>
14 #include <linux/etherdevice.h>
15 #include <net/sock.h>
16 #include <net/cfg80211.h>
17 #include <linux/vmalloc.h>
18 #include <linux/firmware.h>
19 #include <linux/ctype.h>
20 #include <linux/workqueue.h>
21 #include <linux/slab.h>
22 #include <linux/platform_device.h>
23
24 #include "qlink.h"
25 #include "trans.h"
26 #include "qlink_util.h"
27
28 #undef pr_fmt
29 #define pr_fmt(fmt)     KBUILD_MODNAME ": %s: " fmt, __func__
30
31 #define QTNF_MAX_VSIE_LEN               255
32 #define QTNF_MAX_INTF                   8
33 #define QTNF_MAX_EVENT_QUEUE_LEN        255
34 #define QTNF_SCAN_TIMEOUT_SEC           15
35
36 #define QTNF_DEF_BSS_PRIORITY           0
37 #define QTNF_DEF_WDOG_TIMEOUT           5
38 #define QTNF_TX_TIMEOUT_TRSHLD          100
39
40 extern const struct net_device_ops qtnf_netdev_ops;
41
42 struct qtnf_bus;
43 struct qtnf_vif;
44
45 struct qtnf_sta_node {
46         struct list_head list;
47         u8 mac_addr[ETH_ALEN];
48 };
49
50 struct qtnf_sta_list {
51         struct list_head head;
52         atomic_t size;
53 };
54
55 struct qtnf_vif {
56         struct wireless_dev wdev;
57         u8 bssid[ETH_ALEN];
58         u8 mac_addr[ETH_ALEN];
59         u8 vifid;
60         u8 bss_priority;
61         u8 bss_status;
62         u16 mgmt_frames_bitmask;
63         struct net_device *netdev;
64         struct qtnf_wmac *mac;
65
66         struct work_struct reset_work;
67         struct work_struct high_pri_tx_work;
68         struct sk_buff_head high_pri_tx_queue;
69         struct qtnf_sta_list sta_list;
70         unsigned long cons_tx_timeout_cnt;
71         int generation;
72 };
73
74 struct qtnf_mac_info {
75         u8 bands_cap;
76         u8 num_tx_chain;
77         u8 num_rx_chain;
78         u16 max_ap_assoc_sta;
79         u32 frag_thr;
80         u32 rts_thr;
81         u8 lretry_limit;
82         u8 sretry_limit;
83         u8 coverage_class;
84         u8 radar_detect_widths;
85         u8 max_scan_ssids;
86         u16 max_acl_mac_addrs;
87         struct ieee80211_ht_cap ht_cap_mod_mask;
88         struct ieee80211_vht_cap vht_cap_mod_mask;
89         struct ieee80211_iface_combination *if_comb;
90         size_t n_if_comb;
91         u8 *extended_capabilities;
92         u8 *extended_capabilities_mask;
93         u8 extended_capabilities_len;
94         struct wiphy_wowlan_support *wowlan;
95 };
96
97 struct qtnf_wmac {
98         u8 macid;
99         u8 wiphy_registered;
100         u8 macaddr[ETH_ALEN];
101         struct qtnf_bus *bus;
102         struct qtnf_mac_info macinfo;
103         struct qtnf_vif iflist[QTNF_MAX_INTF];
104         struct cfg80211_scan_request *scan_req;
105         struct mutex mac_lock;  /* lock during wmac specific ops */
106         struct delayed_work scan_timeout;
107         struct ieee80211_regdomain *rd;
108         struct platform_device *pdev;
109 };
110
111 struct qtnf_hw_info {
112         u32 ql_proto_ver;
113         u8 num_mac;
114         u8 mac_bitmap;
115         u32 fw_ver;
116         u8 total_tx_chain;
117         u8 total_rx_chain;
118         char fw_version[ETHTOOL_FWVERS_LEN];
119         u32 hw_version;
120         u8 hw_capab[QLINK_HW_CAPAB_NUM / BITS_PER_BYTE + 1];
121 };
122
123 struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
124 struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
125 void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac);
126 void qtnf_mac_ext_caps_free(struct qtnf_wmac *mac);
127 bool qtnf_slave_radar_get(void);
128 bool qtnf_dfs_offload_get(void);
129 struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus,
130                                   struct platform_device *pdev);
131 int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
132                          const char *name, unsigned char name_assign_type);
133 void qtnf_main_work_queue(struct work_struct *work);
134 int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
135
136 struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
137 struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
138 void qtnf_wake_all_queues(struct net_device *ndev);
139
140 void qtnf_virtual_intf_cleanup(struct net_device *ndev);
141
142 void qtnf_netdev_updown(struct net_device *ndev, bool up);
143 void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted);
144 struct dentry *qtnf_get_debugfs_dir(void);
145 bool qtnf_netdev_is_qtn(const struct net_device *ndev);
146
147 static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
148 {
149         return *((void **)netdev_priv(dev));
150 }
151
152 static inline bool qtnf_hwcap_is_set(const struct qtnf_hw_info *info,
153                                      unsigned int bit)
154 {
155         return qtnf_utils_is_bit_set(info->hw_capab, bit,
156                                      sizeof(info->hw_capab));
157 }
158
159 #endif /* _QTN_FMAC_CORE_H_ */
This page took 0.040219 seconds and 4 git commands to generate.