core.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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_SSID_LIST_LENGTH 2
  39. #define QTNF_MAX_VSIE_LEN 255
  40. #define QTNF_MAX_INTF 8
  41. #define QTNF_MAX_EVENT_QUEUE_LEN 255
  42. #define QTNF_DEFAULT_BG_SCAN_PERIOD 300
  43. #define QTNF_MAX_BG_SCAN_PERIOD 0xffff
  44. #define QTNF_SCAN_TIMEOUT_SEC 15
  45. #define QTNF_DEF_BSS_PRIORITY 0
  46. #define QTNF_DEF_WDOG_TIMEOUT 5
  47. #define QTNF_TX_TIMEOUT_TRSHLD 100
  48. extern const struct net_device_ops qtnf_netdev_ops;
  49. struct qtnf_bus;
  50. struct qtnf_vif;
  51. struct qtnf_sta_node {
  52. struct list_head list;
  53. u8 mac_addr[ETH_ALEN];
  54. };
  55. struct qtnf_sta_list {
  56. struct list_head head;
  57. atomic_t size;
  58. };
  59. enum qtnf_sta_state {
  60. QTNF_STA_DISCONNECTED,
  61. QTNF_STA_CONNECTING,
  62. QTNF_STA_CONNECTED
  63. };
  64. struct qtnf_vif {
  65. struct wireless_dev wdev;
  66. u8 bssid[ETH_ALEN];
  67. u8 mac_addr[ETH_ALEN];
  68. u8 vifid;
  69. u8 bss_priority;
  70. u8 bss_status;
  71. enum qtnf_sta_state sta_state;
  72. u16 mgmt_frames_bitmask;
  73. struct net_device *netdev;
  74. struct qtnf_wmac *mac;
  75. struct work_struct reset_work;
  76. struct qtnf_sta_list sta_list;
  77. unsigned long cons_tx_timeout_cnt;
  78. };
  79. struct qtnf_mac_info {
  80. u8 bands_cap;
  81. u8 dev_mac[ETH_ALEN];
  82. u8 num_tx_chain;
  83. u8 num_rx_chain;
  84. u16 max_ap_assoc_sta;
  85. u32 frag_thr;
  86. u32 rts_thr;
  87. u8 lretry_limit;
  88. u8 sretry_limit;
  89. u8 coverage_class;
  90. u8 radar_detect_widths;
  91. struct ieee80211_ht_cap ht_cap_mod_mask;
  92. struct ieee80211_vht_cap vht_cap_mod_mask;
  93. struct ieee80211_iface_limit *limits;
  94. size_t n_limits;
  95. };
  96. struct qtnf_chan_stats {
  97. u32 chan_num;
  98. u32 cca_tx;
  99. u32 cca_rx;
  100. u32 cca_busy;
  101. u32 cca_try;
  102. s8 chan_noise;
  103. };
  104. struct qtnf_wmac {
  105. u8 macid;
  106. u8 wiphy_registered;
  107. u8 macaddr[ETH_ALEN];
  108. struct qtnf_bus *bus;
  109. struct qtnf_mac_info macinfo;
  110. struct qtnf_vif iflist[QTNF_MAX_INTF];
  111. struct cfg80211_scan_request *scan_req;
  112. struct mutex mac_lock; /* lock during wmac speicific ops */
  113. struct timer_list scan_timeout;
  114. };
  115. struct qtnf_hw_info {
  116. u16 ql_proto_ver;
  117. u8 num_mac;
  118. u8 mac_bitmap;
  119. u32 fw_ver;
  120. u32 hw_capab;
  121. struct ieee80211_regdomain *rd;
  122. u8 total_tx_chain;
  123. u8 total_rx_chain;
  124. };
  125. struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
  126. struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
  127. struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus);
  128. int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
  129. const char *name, unsigned char name_assign_type,
  130. enum nl80211_iftype iftype);
  131. void qtnf_main_work_queue(struct work_struct *work);
  132. int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
  133. int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac);
  134. struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
  135. struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
  136. void qtnf_wake_all_queues(struct net_device *ndev);
  137. void qtnf_virtual_intf_cleanup(struct net_device *ndev);
  138. void qtnf_netdev_updown(struct net_device *ndev, bool up);
  139. static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
  140. {
  141. return *((void **)netdev_priv(dev));
  142. }
  143. #endif /* _QTN_FMAC_CORE_H_ */