core.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Copyright (c) 2015-2016 Quantenna Communications, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef _QTN_FMAC_CORE_H_
  17. #define _QTN_FMAC_CORE_H_
  18. #include <linux/kernel.h>
  19. #include <linux/module.h>
  20. #include <linux/sched.h>
  21. #include <linux/semaphore.h>
  22. #include <linux/ip.h>
  23. #include <linux/skbuff.h>
  24. #include <linux/if_arp.h>
  25. #include <linux/etherdevice.h>
  26. #include <net/sock.h>
  27. #include <net/lib80211.h>
  28. #include <net/cfg80211.h>
  29. #include <linux/vmalloc.h>
  30. #include <linux/firmware.h>
  31. #include <linux/ctype.h>
  32. #include <linux/workqueue.h>
  33. #include <linux/slab.h>
  34. #include "qlink.h"
  35. #include "trans.h"
  36. #undef pr_fmt
  37. #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
  38. #define QTNF_MAX_VSIE_LEN 255
  39. #define QTNF_MAX_INTF 8
  40. #define QTNF_MAX_EVENT_QUEUE_LEN 255
  41. #define QTNF_SCAN_TIMEOUT_SEC 15
  42. #define QTNF_DEF_BSS_PRIORITY 0
  43. #define QTNF_DEF_WDOG_TIMEOUT 5
  44. #define QTNF_TX_TIMEOUT_TRSHLD 100
  45. extern const struct net_device_ops qtnf_netdev_ops;
  46. struct qtnf_bus;
  47. struct qtnf_vif;
  48. struct qtnf_sta_node {
  49. struct list_head list;
  50. u8 mac_addr[ETH_ALEN];
  51. };
  52. struct qtnf_sta_list {
  53. struct list_head head;
  54. atomic_t size;
  55. };
  56. enum qtnf_sta_state {
  57. QTNF_STA_DISCONNECTED,
  58. QTNF_STA_CONNECTING,
  59. QTNF_STA_CONNECTED
  60. };
  61. struct qtnf_vif {
  62. struct wireless_dev wdev;
  63. u8 bssid[ETH_ALEN];
  64. u8 mac_addr[ETH_ALEN];
  65. u8 vifid;
  66. u8 bss_priority;
  67. u8 bss_status;
  68. enum qtnf_sta_state sta_state;
  69. u16 mgmt_frames_bitmask;
  70. struct net_device *netdev;
  71. struct qtnf_wmac *mac;
  72. struct work_struct reset_work;
  73. struct qtnf_sta_list sta_list;
  74. unsigned long cons_tx_timeout_cnt;
  75. int generation;
  76. struct pcpu_sw_netstats __percpu *stats64;
  77. };
  78. struct qtnf_mac_info {
  79. u8 bands_cap;
  80. u8 dev_mac[ETH_ALEN];
  81. u8 num_tx_chain;
  82. u8 num_rx_chain;
  83. u16 max_ap_assoc_sta;
  84. u32 frag_thr;
  85. u32 rts_thr;
  86. u8 lretry_limit;
  87. u8 sretry_limit;
  88. u8 coverage_class;
  89. u8 radar_detect_widths;
  90. u32 max_acl_mac_addrs;
  91. struct ieee80211_ht_cap ht_cap_mod_mask;
  92. struct ieee80211_vht_cap vht_cap_mod_mask;
  93. struct ieee80211_iface_combination *if_comb;
  94. size_t n_if_comb;
  95. u8 *extended_capabilities;
  96. u8 *extended_capabilities_mask;
  97. u8 extended_capabilities_len;
  98. struct wiphy_wowlan_support *wowlan;
  99. };
  100. struct qtnf_chan_stats {
  101. u32 chan_num;
  102. u32 cca_tx;
  103. u32 cca_rx;
  104. u32 cca_busy;
  105. u32 cca_try;
  106. s8 chan_noise;
  107. };
  108. struct qtnf_wmac {
  109. u8 macid;
  110. u8 wiphy_registered;
  111. u8 macaddr[ETH_ALEN];
  112. struct qtnf_bus *bus;
  113. struct qtnf_mac_info macinfo;
  114. struct qtnf_vif iflist[QTNF_MAX_INTF];
  115. struct cfg80211_scan_request *scan_req;
  116. struct mutex mac_lock; /* lock during wmac speicific ops */
  117. struct delayed_work scan_timeout;
  118. };
  119. struct qtnf_hw_info {
  120. u16 ql_proto_ver;
  121. u8 num_mac;
  122. u8 mac_bitmap;
  123. u32 fw_ver;
  124. u32 hw_capab;
  125. struct ieee80211_regdomain *rd;
  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. struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
  133. struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
  134. void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac);
  135. void qtnf_mac_ext_caps_free(struct qtnf_wmac *mac);
  136. struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus);
  137. int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
  138. const char *name, unsigned char name_assign_type);
  139. void qtnf_main_work_queue(struct work_struct *work);
  140. int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
  141. int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac);
  142. struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
  143. struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
  144. void qtnf_wake_all_queues(struct net_device *ndev);
  145. void qtnf_update_rx_stats(struct net_device *ndev, const struct sk_buff *skb);
  146. void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb);
  147. void qtnf_virtual_intf_cleanup(struct net_device *ndev);
  148. void qtnf_netdev_updown(struct net_device *ndev, bool up);
  149. void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted);
  150. static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
  151. {
  152. return *((void **)netdev_priv(dev));
  153. }
  154. #endif /* _QTN_FMAC_CORE_H_ */