2019-01-14 17:39:45 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
|
|
/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
|
2017-05-12 05:51:01 +08:00
|
|
|
|
|
|
|
#ifndef _QTN_FMAC_CORE_H_
|
|
|
|
#define _QTN_FMAC_CORE_H_
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/semaphore.h>
|
|
|
|
#include <linux/ip.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <net/sock.h>
|
|
|
|
#include <net/lib80211.h>
|
|
|
|
#include <net/cfg80211.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/slab.h>
|
2020-02-13 19:45:31 +08:00
|
|
|
#include <linux/platform_device.h>
|
2017-05-12 05:51:01 +08:00
|
|
|
|
|
|
|
#include "qlink.h"
|
|
|
|
#include "trans.h"
|
2020-01-27 18:46:46 +08:00
|
|
|
#include "qlink_util.h"
|
2017-05-12 05:51:01 +08:00
|
|
|
|
|
|
|
#undef pr_fmt
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
|
|
|
|
|
|
|
|
#define QTNF_MAX_VSIE_LEN 255
|
|
|
|
#define QTNF_MAX_INTF 8
|
|
|
|
#define QTNF_MAX_EVENT_QUEUE_LEN 255
|
2017-07-28 07:06:51 +08:00
|
|
|
#define QTNF_SCAN_TIMEOUT_SEC 15
|
2017-05-12 05:51:01 +08:00
|
|
|
|
|
|
|
#define QTNF_DEF_BSS_PRIORITY 0
|
|
|
|
#define QTNF_DEF_WDOG_TIMEOUT 5
|
|
|
|
#define QTNF_TX_TIMEOUT_TRSHLD 100
|
|
|
|
|
|
|
|
extern const struct net_device_ops qtnf_netdev_ops;
|
2017-10-05 09:38:10 +08:00
|
|
|
|
2017-05-12 05:51:01 +08:00
|
|
|
struct qtnf_bus;
|
|
|
|
struct qtnf_vif;
|
|
|
|
|
|
|
|
struct qtnf_sta_node {
|
|
|
|
struct list_head list;
|
|
|
|
u8 mac_addr[ETH_ALEN];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct qtnf_sta_list {
|
|
|
|
struct list_head head;
|
|
|
|
atomic_t size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct qtnf_vif {
|
|
|
|
struct wireless_dev wdev;
|
2017-10-05 09:38:11 +08:00
|
|
|
u8 bssid[ETH_ALEN];
|
|
|
|
u8 mac_addr[ETH_ALEN];
|
2017-05-12 05:51:01 +08:00
|
|
|
u8 vifid;
|
|
|
|
u8 bss_priority;
|
|
|
|
u8 bss_status;
|
|
|
|
u16 mgmt_frames_bitmask;
|
|
|
|
struct net_device *netdev;
|
|
|
|
struct qtnf_wmac *mac;
|
2017-10-05 09:38:11 +08:00
|
|
|
|
2017-05-12 05:51:01 +08:00
|
|
|
struct work_struct reset_work;
|
2019-03-20 18:04:09 +08:00
|
|
|
struct work_struct high_pri_tx_work;
|
|
|
|
struct sk_buff_head high_pri_tx_queue;
|
2017-05-12 05:51:01 +08:00
|
|
|
struct qtnf_sta_list sta_list;
|
|
|
|
unsigned long cons_tx_timeout_cnt;
|
2017-12-19 19:28:55 +08:00
|
|
|
int generation;
|
2018-01-22 20:46:26 +08:00
|
|
|
|
|
|
|
struct pcpu_sw_netstats __percpu *stats64;
|
2017-05-12 05:51:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct qtnf_mac_info {
|
|
|
|
u8 bands_cap;
|
|
|
|
u8 num_tx_chain;
|
|
|
|
u8 num_rx_chain;
|
|
|
|
u16 max_ap_assoc_sta;
|
|
|
|
u32 frag_thr;
|
|
|
|
u32 rts_thr;
|
|
|
|
u8 lretry_limit;
|
|
|
|
u8 sretry_limit;
|
|
|
|
u8 coverage_class;
|
|
|
|
u8 radar_detect_widths;
|
2020-01-27 18:46:52 +08:00
|
|
|
u8 max_scan_ssids;
|
2020-01-27 18:46:47 +08:00
|
|
|
u16 max_acl_mac_addrs;
|
2017-10-31 09:04:48 +08:00
|
|
|
struct ieee80211_ht_cap ht_cap_mod_mask;
|
|
|
|
struct ieee80211_vht_cap vht_cap_mod_mask;
|
2018-01-22 20:46:29 +08:00
|
|
|
struct ieee80211_iface_combination *if_comb;
|
|
|
|
size_t n_if_comb;
|
2017-12-19 19:28:53 +08:00
|
|
|
u8 *extended_capabilities;
|
|
|
|
u8 *extended_capabilities_mask;
|
|
|
|
u8 extended_capabilities_len;
|
2018-08-02 18:40:43 +08:00
|
|
|
struct wiphy_wowlan_support *wowlan;
|
2017-05-12 05:51:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct qtnf_wmac {
|
|
|
|
u8 macid;
|
|
|
|
u8 wiphy_registered;
|
|
|
|
u8 macaddr[ETH_ALEN];
|
|
|
|
struct qtnf_bus *bus;
|
|
|
|
struct qtnf_mac_info macinfo;
|
|
|
|
struct qtnf_vif iflist[QTNF_MAX_INTF];
|
|
|
|
struct cfg80211_scan_request *scan_req;
|
2017-07-28 07:06:51 +08:00
|
|
|
struct mutex mac_lock; /* lock during wmac speicific ops */
|
2018-01-22 20:46:32 +08:00
|
|
|
struct delayed_work scan_timeout;
|
2019-03-20 18:03:57 +08:00
|
|
|
struct ieee80211_regdomain *rd;
|
2020-02-13 19:45:31 +08:00
|
|
|
struct platform_device *pdev;
|
2017-05-12 05:51:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct qtnf_hw_info {
|
2020-01-27 18:46:44 +08:00
|
|
|
u32 ql_proto_ver;
|
2017-05-12 05:51:01 +08:00
|
|
|
u8 num_mac;
|
|
|
|
u8 mac_bitmap;
|
|
|
|
u32 fw_ver;
|
|
|
|
u8 total_tx_chain;
|
|
|
|
u8 total_rx_chain;
|
2018-01-22 20:46:28 +08:00
|
|
|
char fw_version[ETHTOOL_FWVERS_LEN];
|
|
|
|
u32 hw_version;
|
2020-01-27 18:46:46 +08:00
|
|
|
u8 hw_capab[QLINK_HW_CAPAB_NUM / BITS_PER_BYTE + 1];
|
2017-05-12 05:51:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
|
|
|
|
struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
|
2018-01-22 20:46:29 +08:00
|
|
|
void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac);
|
2018-10-05 18:11:38 +08:00
|
|
|
void qtnf_mac_ext_caps_free(struct qtnf_wmac *mac);
|
2020-01-09 21:17:51 +08:00
|
|
|
bool qtnf_slave_radar_get(void);
|
2020-01-09 21:17:52 +08:00
|
|
|
bool qtnf_dfs_offload_get(void);
|
2020-02-13 19:45:31 +08:00
|
|
|
struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus,
|
|
|
|
struct platform_device *pdev);
|
2017-05-12 05:51:01 +08:00
|
|
|
int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
|
2017-12-19 19:28:50 +08:00
|
|
|
const char *name, unsigned char name_assign_type);
|
2017-05-12 05:51:01 +08:00
|
|
|
void qtnf_main_work_queue(struct work_struct *work);
|
|
|
|
int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
|
|
|
|
|
|
|
|
struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
|
|
|
|
struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
|
2017-10-30 18:13:49 +08:00
|
|
|
void qtnf_wake_all_queues(struct net_device *ndev);
|
2018-01-22 20:46:26 +08:00
|
|
|
void qtnf_update_rx_stats(struct net_device *ndev, const struct sk_buff *skb);
|
|
|
|
void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb);
|
|
|
|
|
2017-05-12 05:51:01 +08:00
|
|
|
void qtnf_virtual_intf_cleanup(struct net_device *ndev);
|
|
|
|
|
|
|
|
void qtnf_netdev_updown(struct net_device *ndev, bool up);
|
2018-01-22 20:46:32 +08:00
|
|
|
void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted);
|
2019-04-09 15:35:12 +08:00
|
|
|
struct dentry *qtnf_get_debugfs_dir(void);
|
2019-11-18 16:23:06 +08:00
|
|
|
bool qtnf_netdev_is_qtn(const struct net_device *ndev);
|
2017-05-12 05:51:01 +08:00
|
|
|
|
|
|
|
static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
|
|
|
|
{
|
|
|
|
return *((void **)netdev_priv(dev));
|
|
|
|
}
|
|
|
|
|
2020-01-27 18:46:46 +08:00
|
|
|
static inline bool qtnf_hwcap_is_set(const struct qtnf_hw_info *info,
|
|
|
|
unsigned int bit)
|
|
|
|
{
|
|
|
|
return qtnf_utils_is_bit_set(info->hw_capab, bit,
|
|
|
|
sizeof(info->hw_capab));
|
|
|
|
}
|
|
|
|
|
2017-05-12 05:51:01 +08:00
|
|
|
#endif /* _QTN_FMAC_CORE_H_ */
|