Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
0003 
0004 #ifndef _QTN_FMAC_CORE_H_
0005 #define _QTN_FMAC_CORE_H_
0006 
0007 #include <linux/kernel.h>
0008 #include <linux/module.h>
0009 #include <linux/sched.h>
0010 #include <linux/semaphore.h>
0011 #include <linux/ip.h>
0012 #include <linux/skbuff.h>
0013 #include <linux/if_arp.h>
0014 #include <linux/etherdevice.h>
0015 #include <net/sock.h>
0016 #include <net/lib80211.h>
0017 #include <net/cfg80211.h>
0018 #include <linux/vmalloc.h>
0019 #include <linux/firmware.h>
0020 #include <linux/ctype.h>
0021 #include <linux/workqueue.h>
0022 #include <linux/slab.h>
0023 #include <linux/platform_device.h>
0024 
0025 #include "qlink.h"
0026 #include "trans.h"
0027 #include "qlink_util.h"
0028 
0029 #undef pr_fmt
0030 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
0031 
0032 #define QTNF_MAX_VSIE_LEN       255
0033 #define QTNF_MAX_INTF           8
0034 #define QTNF_MAX_EVENT_QUEUE_LEN    255
0035 #define QTNF_SCAN_TIMEOUT_SEC       15
0036 
0037 #define QTNF_DEF_BSS_PRIORITY       0
0038 #define QTNF_DEF_WDOG_TIMEOUT       5
0039 #define QTNF_TX_TIMEOUT_TRSHLD      100
0040 
0041 extern const struct net_device_ops qtnf_netdev_ops;
0042 
0043 struct qtnf_bus;
0044 struct qtnf_vif;
0045 
0046 struct qtnf_sta_node {
0047     struct list_head list;
0048     u8 mac_addr[ETH_ALEN];
0049 };
0050 
0051 struct qtnf_sta_list {
0052     struct list_head head;
0053     atomic_t size;
0054 };
0055 
0056 struct qtnf_vif {
0057     struct wireless_dev wdev;
0058     u8 bssid[ETH_ALEN];
0059     u8 mac_addr[ETH_ALEN];
0060     u8 vifid;
0061     u8 bss_priority;
0062     u8 bss_status;
0063     u16 mgmt_frames_bitmask;
0064     struct net_device *netdev;
0065     struct qtnf_wmac *mac;
0066 
0067     struct work_struct reset_work;
0068     struct work_struct high_pri_tx_work;
0069     struct sk_buff_head high_pri_tx_queue;
0070     struct qtnf_sta_list sta_list;
0071     unsigned long cons_tx_timeout_cnt;
0072     int generation;
0073 };
0074 
0075 struct qtnf_mac_info {
0076     u8 bands_cap;
0077     u8 num_tx_chain;
0078     u8 num_rx_chain;
0079     u16 max_ap_assoc_sta;
0080     u32 frag_thr;
0081     u32 rts_thr;
0082     u8 lretry_limit;
0083     u8 sretry_limit;
0084     u8 coverage_class;
0085     u8 radar_detect_widths;
0086     u8 max_scan_ssids;
0087     u16 max_acl_mac_addrs;
0088     struct ieee80211_ht_cap ht_cap_mod_mask;
0089     struct ieee80211_vht_cap vht_cap_mod_mask;
0090     struct ieee80211_iface_combination *if_comb;
0091     size_t n_if_comb;
0092     u8 *extended_capabilities;
0093     u8 *extended_capabilities_mask;
0094     u8 extended_capabilities_len;
0095     struct wiphy_wowlan_support *wowlan;
0096 };
0097 
0098 struct qtnf_wmac {
0099     u8 macid;
0100     u8 wiphy_registered;
0101     u8 macaddr[ETH_ALEN];
0102     struct qtnf_bus *bus;
0103     struct qtnf_mac_info macinfo;
0104     struct qtnf_vif iflist[QTNF_MAX_INTF];
0105     struct cfg80211_scan_request *scan_req;
0106     struct mutex mac_lock;  /* lock during wmac speicific ops */
0107     struct delayed_work scan_timeout;
0108     struct ieee80211_regdomain *rd;
0109     struct platform_device *pdev;
0110 };
0111 
0112 struct qtnf_hw_info {
0113     u32 ql_proto_ver;
0114     u8 num_mac;
0115     u8 mac_bitmap;
0116     u32 fw_ver;
0117     u8 total_tx_chain;
0118     u8 total_rx_chain;
0119     char fw_version[ETHTOOL_FWVERS_LEN];
0120     u32 hw_version;
0121     u8 hw_capab[QLINK_HW_CAPAB_NUM / BITS_PER_BYTE + 1];
0122 };
0123 
0124 struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
0125 struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
0126 void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac);
0127 void qtnf_mac_ext_caps_free(struct qtnf_wmac *mac);
0128 bool qtnf_slave_radar_get(void);
0129 bool qtnf_dfs_offload_get(void);
0130 struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus,
0131                   struct platform_device *pdev);
0132 int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
0133              const char *name, unsigned char name_assign_type);
0134 void qtnf_main_work_queue(struct work_struct *work);
0135 int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
0136 
0137 struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
0138 struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
0139 void qtnf_wake_all_queues(struct net_device *ndev);
0140 
0141 void qtnf_virtual_intf_cleanup(struct net_device *ndev);
0142 
0143 void qtnf_netdev_updown(struct net_device *ndev, bool up);
0144 void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted);
0145 struct dentry *qtnf_get_debugfs_dir(void);
0146 bool qtnf_netdev_is_qtn(const struct net_device *ndev);
0147 
0148 static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
0149 {
0150     return *((void **)netdev_priv(dev));
0151 }
0152 
0153 static inline bool qtnf_hwcap_is_set(const struct qtnf_hw_info *info,
0154                      unsigned int bit)
0155 {
0156     return qtnf_utils_is_bit_set(info->hw_capab, bit,
0157                      sizeof(info->hw_capab));
0158 }
0159 
0160 #endif /* _QTN_FMAC_CORE_H_ */