Linux Audio

Check our new training course

Loading...
v6.8
  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/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>
 24
 25#include "qlink.h"
 26#include "trans.h"
 27#include "qlink_util.h"
 28
 29#undef pr_fmt
 30#define pr_fmt(fmt)	KBUILD_MODNAME ": %s: " fmt, __func__
 31
 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
 36
 37#define QTNF_DEF_BSS_PRIORITY		0
 38#define QTNF_DEF_WDOG_TIMEOUT		5
 39#define QTNF_TX_TIMEOUT_TRSHLD		100
 40
 41extern const struct net_device_ops qtnf_netdev_ops;
 42
 43struct qtnf_bus;
 44struct qtnf_vif;
 45
 46struct qtnf_sta_node {
 47	struct list_head list;
 48	u8 mac_addr[ETH_ALEN];
 49};
 50
 51struct qtnf_sta_list {
 52	struct list_head head;
 53	atomic_t size;
 54};
 55
 56struct qtnf_vif {
 57	struct wireless_dev wdev;
 58	u8 bssid[ETH_ALEN];
 59	u8 mac_addr[ETH_ALEN];
 60	u8 vifid;
 61	u8 bss_priority;
 62	u8 bss_status;
 63	u16 mgmt_frames_bitmask;
 64	struct net_device *netdev;
 65	struct qtnf_wmac *mac;
 66
 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;
 72	int generation;
 
 
 73};
 74
 75struct qtnf_mac_info {
 76	u8 bands_cap;
 
 77	u8 num_tx_chain;
 78	u8 num_rx_chain;
 79	u16 max_ap_assoc_sta;
 80	u32 frag_thr;
 81	u32 rts_thr;
 82	u8 lretry_limit;
 83	u8 sretry_limit;
 84	u8 coverage_class;
 85	u8 radar_detect_widths;
 86	u8 max_scan_ssids;
 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;
 91	size_t n_if_comb;
 92	u8 *extended_capabilities;
 93	u8 *extended_capabilities_mask;
 94	u8 extended_capabilities_len;
 95	struct wiphy_wowlan_support *wowlan;
 96};
 97
 
 
 
 
 
 
 
 
 
 98struct qtnf_wmac {
 99	u8 macid;
100	u8 wiphy_registered;
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;
110};
111
112struct qtnf_hw_info {
113	u32 ql_proto_ver;
114	u8 num_mac;
115	u8 mac_bitmap;
116	u32 fw_ver;
 
117	u8 total_tx_chain;
118	u8 total_rx_chain;
119	char fw_version[ETHTOOL_FWVERS_LEN];
120	u32 hw_version;
121	u8 hw_capab[QLINK_HW_CAPAB_NUM / BITS_PER_BYTE + 1];
122};
123
124struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
125struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
126void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac);
127void qtnf_mac_ext_caps_free(struct qtnf_wmac *mac);
128bool qtnf_slave_radar_get(void);
129bool qtnf_dfs_offload_get(void);
130struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus,
131				  struct platform_device *pdev);
132int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
133			 const char *name, unsigned char name_assign_type);
134void qtnf_main_work_queue(struct work_struct *work);
135int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
 
136
137struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
138struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
139void qtnf_wake_all_queues(struct net_device *ndev);
 
 
140
141void qtnf_virtual_intf_cleanup(struct net_device *ndev);
142
143void qtnf_netdev_updown(struct net_device *ndev, bool up);
144void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted);
 
145struct dentry *qtnf_get_debugfs_dir(void);
146bool qtnf_netdev_is_qtn(const struct net_device *ndev);
147
148static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
149{
150	return *((void **)netdev_priv(dev));
151}
152
153static inline bool qtnf_hwcap_is_set(const struct qtnf_hw_info *info,
154				     unsigned int bit)
155{
156	return qtnf_utils_is_bit_set(info->hw_capab, bit,
157				     sizeof(info->hw_capab));
158}
159
160#endif /* _QTN_FMAC_CORE_H_ */
v5.4
  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/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
 24#include "qlink.h"
 25#include "trans.h"
 
 26
 27#undef pr_fmt
 28#define pr_fmt(fmt)	KBUILD_MODNAME ": %s: " fmt, __func__
 29
 30#define QTNF_MAX_VSIE_LEN		255
 31#define QTNF_MAX_INTF			8
 32#define QTNF_MAX_EVENT_QUEUE_LEN	255
 33#define QTNF_SCAN_TIMEOUT_SEC		15
 34
 35#define QTNF_DEF_BSS_PRIORITY		0
 36#define QTNF_DEF_WDOG_TIMEOUT		5
 37#define QTNF_TX_TIMEOUT_TRSHLD		100
 38
 39extern const struct net_device_ops qtnf_netdev_ops;
 40
 41struct qtnf_bus;
 42struct qtnf_vif;
 43
 44struct qtnf_sta_node {
 45	struct list_head list;
 46	u8 mac_addr[ETH_ALEN];
 47};
 48
 49struct qtnf_sta_list {
 50	struct list_head head;
 51	atomic_t size;
 52};
 53
 54struct qtnf_vif {
 55	struct wireless_dev wdev;
 56	u8 bssid[ETH_ALEN];
 57	u8 mac_addr[ETH_ALEN];
 58	u8 vifid;
 59	u8 bss_priority;
 60	u8 bss_status;
 61	u16 mgmt_frames_bitmask;
 62	struct net_device *netdev;
 63	struct qtnf_wmac *mac;
 64
 65	struct work_struct reset_work;
 66	struct work_struct high_pri_tx_work;
 67	struct sk_buff_head high_pri_tx_queue;
 68	struct qtnf_sta_list sta_list;
 69	unsigned long cons_tx_timeout_cnt;
 70	int generation;
 71
 72	struct pcpu_sw_netstats __percpu *stats64;
 73};
 74
 75struct qtnf_mac_info {
 76	u8 bands_cap;
 77	u8 dev_mac[ETH_ALEN];
 78	u8 num_tx_chain;
 79	u8 num_rx_chain;
 80	u16 max_ap_assoc_sta;
 81	u32 frag_thr;
 82	u32 rts_thr;
 83	u8 lretry_limit;
 84	u8 sretry_limit;
 85	u8 coverage_class;
 86	u8 radar_detect_widths;
 87	u32 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;
 91	size_t n_if_comb;
 92	u8 *extended_capabilities;
 93	u8 *extended_capabilities_mask;
 94	u8 extended_capabilities_len;
 95	struct wiphy_wowlan_support *wowlan;
 96};
 97
 98struct qtnf_chan_stats {
 99	u32 chan_num;
100	u32 cca_tx;
101	u32 cca_rx;
102	u32 cca_busy;
103	u32 cca_try;
104	s8 chan_noise;
105};
106
107struct qtnf_wmac {
108	u8 macid;
109	u8 wiphy_registered;
110	u8 macaddr[ETH_ALEN];
111	struct qtnf_bus *bus;
112	struct qtnf_mac_info macinfo;
113	struct qtnf_vif iflist[QTNF_MAX_INTF];
114	struct cfg80211_scan_request *scan_req;
115	struct mutex mac_lock;	/* lock during wmac speicific ops */
116	struct delayed_work scan_timeout;
117	struct ieee80211_regdomain *rd;
 
118};
119
120struct qtnf_hw_info {
121	u16 ql_proto_ver;
122	u8 num_mac;
123	u8 mac_bitmap;
124	u32 fw_ver;
125	u32 hw_capab;
126	u8 total_tx_chain;
127	u8 total_rx_chain;
128	char fw_version[ETHTOOL_FWVERS_LEN];
129	u32 hw_version;
130	u8 max_scan_ssids;
131};
132
133struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
134struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
135void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac);
136void qtnf_mac_ext_caps_free(struct qtnf_wmac *mac);
137bool qtnf_mac_slave_radar_get(struct wiphy *wiphy);
138struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus);
 
 
139int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
140			 const char *name, unsigned char name_assign_type);
141void qtnf_main_work_queue(struct work_struct *work);
142int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
143int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac);
144
145struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
146struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
147void qtnf_wake_all_queues(struct net_device *ndev);
148void qtnf_update_rx_stats(struct net_device *ndev, const struct sk_buff *skb);
149void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb);
150
151void qtnf_virtual_intf_cleanup(struct net_device *ndev);
152
153void qtnf_netdev_updown(struct net_device *ndev, bool up);
154void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted);
155void qtnf_packet_send_hi_pri(struct sk_buff *skb);
156struct dentry *qtnf_get_debugfs_dir(void);
 
157
158static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
159{
160	return *((void **)netdev_priv(dev));
 
 
 
 
 
 
 
161}
162
163#endif /* _QTN_FMAC_CORE_H_ */