linux/drivers/net/wireless/quantenna/qtnfmac/core.h
<<
>>
Prefs
   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
  17#ifndef _QTN_FMAC_CORE_H_
  18#define _QTN_FMAC_CORE_H_
  19
  20#include <linux/kernel.h>
  21#include <linux/module.h>
  22#include <linux/sched.h>
  23#include <linux/semaphore.h>
  24#include <linux/ip.h>
  25#include <linux/skbuff.h>
  26#include <linux/if_arp.h>
  27#include <linux/etherdevice.h>
  28#include <net/sock.h>
  29#include <net/lib80211.h>
  30#include <net/cfg80211.h>
  31#include <linux/vmalloc.h>
  32#include <linux/firmware.h>
  33#include <linux/ctype.h>
  34#include <linux/workqueue.h>
  35#include <linux/slab.h>
  36
  37#include "qlink.h"
  38#include "trans.h"
  39
  40#undef pr_fmt
  41#define pr_fmt(fmt)     KBUILD_MODNAME ": %s: " fmt, __func__
  42
  43#define QTNF_MAX_SSID_LIST_LENGTH       2
  44#define QTNF_MAX_VSIE_LEN               255
  45#define QTNF_MAX_INTF                   8
  46#define QTNF_MAX_EVENT_QUEUE_LEN        255
  47#define QTNF_DEFAULT_BG_SCAN_PERIOD     300
  48#define QTNF_MAX_BG_SCAN_PERIOD         0xffff
  49#define QTNF_SCAN_TIMEOUT_SEC           15
  50
  51#define QTNF_DEF_BSS_PRIORITY           0
  52#define QTNF_DEF_WDOG_TIMEOUT           5
  53#define QTNF_TX_TIMEOUT_TRSHLD          100
  54
  55extern const struct net_device_ops qtnf_netdev_ops;
  56
  57struct qtnf_bus;
  58struct qtnf_vif;
  59
  60struct qtnf_sta_node {
  61        struct list_head list;
  62        u8 mac_addr[ETH_ALEN];
  63};
  64
  65struct qtnf_sta_list {
  66        struct list_head head;
  67        atomic_t size;
  68};
  69
  70enum qtnf_sta_state {
  71        QTNF_STA_DISCONNECTED,
  72        QTNF_STA_CONNECTING,
  73        QTNF_STA_CONNECTED
  74};
  75
  76struct qtnf_vif {
  77        struct wireless_dev wdev;
  78        u8 bssid[ETH_ALEN];
  79        u8 mac_addr[ETH_ALEN];
  80        u8 vifid;
  81        u8 bss_priority;
  82        u8 bss_status;
  83        enum qtnf_sta_state sta_state;
  84        u16 mgmt_frames_bitmask;
  85        struct net_device *netdev;
  86        struct qtnf_wmac *mac;
  87
  88        struct work_struct reset_work;
  89        struct qtnf_sta_list sta_list;
  90        unsigned long cons_tx_timeout_cnt;
  91};
  92
  93struct qtnf_mac_info {
  94        u8 bands_cap;
  95        u8 dev_mac[ETH_ALEN];
  96        u8 num_tx_chain;
  97        u8 num_rx_chain;
  98        u16 max_ap_assoc_sta;
  99        u32 frag_thr;
 100        u32 rts_thr;
 101        u8 lretry_limit;
 102        u8 sretry_limit;
 103        u8 coverage_class;
 104        u8 radar_detect_widths;
 105        struct ieee80211_ht_cap ht_cap_mod_mask;
 106        struct ieee80211_vht_cap vht_cap_mod_mask;
 107        struct ieee80211_iface_limit *limits;
 108        size_t n_limits;
 109};
 110
 111struct qtnf_chan_stats {
 112        u32 chan_num;
 113        u32 cca_tx;
 114        u32 cca_rx;
 115        u32 cca_busy;
 116        u32 cca_try;
 117        s8 chan_noise;
 118};
 119
 120struct qtnf_wmac {
 121        u8 macid;
 122        u8 wiphy_registered;
 123        u8 macaddr[ETH_ALEN];
 124        struct qtnf_bus *bus;
 125        struct qtnf_mac_info macinfo;
 126        struct qtnf_vif iflist[QTNF_MAX_INTF];
 127        struct cfg80211_scan_request *scan_req;
 128        struct mutex mac_lock;  /* lock during wmac speicific ops */
 129        struct timer_list scan_timeout;
 130};
 131
 132struct qtnf_hw_info {
 133        u16 ql_proto_ver;
 134        u8 num_mac;
 135        u8 mac_bitmap;
 136        u32 fw_ver;
 137        u32 hw_capab;
 138        struct ieee80211_regdomain *rd;
 139        u8 total_tx_chain;
 140        u8 total_rx_chain;
 141};
 142
 143struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);
 144struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac);
 145struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus);
 146int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
 147                         const char *name, unsigned char name_assign_type,
 148                         enum nl80211_iftype iftype);
 149void qtnf_main_work_queue(struct work_struct *work);
 150int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
 151int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac);
 152
 153struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
 154struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
 155void qtnf_wake_all_queues(struct net_device *ndev);
 156void qtnf_virtual_intf_cleanup(struct net_device *ndev);
 157
 158void qtnf_netdev_updown(struct net_device *ndev, bool up);
 159
 160static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev)
 161{
 162        return *((void **)netdev_priv(dev));
 163}
 164
 165#endif /* _QTN_FMAC_CORE_H_ */
 166