linux/drivers/net/wireless/marvell/libertas/dev.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * This file contains definitions and data structures specific
   4 * to Marvell 802.11 NIC. It contains the Device Information
   5 * structure struct lbs_private..
   6 */
   7#ifndef _LBS_DEV_H_
   8#define _LBS_DEV_H_
   9
  10#include "defs.h"
  11#include "decl.h"
  12#include "host.h"
  13
  14#include <linux/kfifo.h>
  15
  16/* sleep_params */
  17struct sleep_params {
  18        uint16_t sp_error;
  19        uint16_t sp_offset;
  20        uint16_t sp_stabletime;
  21        uint8_t  sp_calcontrol;
  22        uint8_t  sp_extsleepclk;
  23        uint16_t sp_reserved;
  24};
  25
  26/* Mesh statistics */
  27struct lbs_mesh_stats {
  28        u32     fwd_bcast_cnt;          /* Fwd: Broadcast counter */
  29        u32     fwd_unicast_cnt;        /* Fwd: Unicast counter */
  30        u32     fwd_drop_ttl;           /* Fwd: TTL zero */
  31        u32     fwd_drop_rbt;           /* Fwd: Recently Broadcasted */
  32        u32     fwd_drop_noroute;       /* Fwd: No route to Destination */
  33        u32     fwd_drop_nobuf;         /* Fwd: Run out of internal buffers */
  34        u32     drop_blind;             /* Rx:  Dropped by blinding table */
  35        u32     tx_failed_cnt;          /* Tx:  Failed transmissions */
  36};
  37
  38/* Private structure for the MV device */
  39struct lbs_private {
  40
  41        /* Basic networking */
  42        struct net_device *dev;
  43        u32 connect_status;
  44        struct work_struct mcast_work;
  45        u32 nr_of_multicastmacaddr;
  46        u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
  47
  48        /* CFG80211 */
  49        struct wireless_dev *wdev;
  50        bool wiphy_registered;
  51        struct cfg80211_scan_request *scan_req;
  52        u8 assoc_bss[ETH_ALEN];
  53        u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  54        u8 disassoc_reason;
  55
  56        /* Mesh */
  57        struct net_device *mesh_dev; /* Virtual device */
  58#ifdef CONFIG_LIBERTAS_MESH
  59        struct lbs_mesh_stats mstats;
  60        uint16_t mesh_tlv;
  61        u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
  62        u8 mesh_ssid_len;
  63        u8 mesh_channel;
  64#endif
  65
  66        /* Debugfs */
  67        struct dentry *debugfs_dir;
  68        struct dentry *debugfs_debug;
  69        struct dentry *debugfs_files[6];
  70        struct dentry *events_dir;
  71        struct dentry *debugfs_events_files[6];
  72        struct dentry *regs_dir;
  73        struct dentry *debugfs_regs_files[6];
  74
  75        /* Hardware debugging */
  76        u32 mac_offset;
  77        u32 bbp_offset;
  78        u32 rf_offset;
  79
  80        /* Power management */
  81        u16 psmode;
  82        u32 psstate;
  83        u8 needtowakeup;
  84
  85        /* Deep sleep */
  86        int is_deep_sleep;
  87        int deep_sleep_required;
  88        int is_auto_deep_sleep_enabled;
  89        int wakeup_dev_required;
  90        int is_activity_detected;
  91        int auto_deep_sleep_timeout; /* in ms */
  92        wait_queue_head_t ds_awake_q;
  93        struct timer_list auto_deepsleep_timer;
  94
  95        /* Host sleep*/
  96        int is_host_sleep_configured;
  97        int is_host_sleep_activated;
  98        wait_queue_head_t host_sleep_q;
  99
 100        /* Hardware access */
 101        void *card;
 102        bool iface_running;
 103        u8 is_polling; /* host has to poll the card irq */
 104        u8 fw_ready;
 105        u8 surpriseremoved;
 106        u8 setup_fw_on_resume;
 107        int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
 108        void (*reset_card) (struct lbs_private *priv);
 109        int (*power_save) (struct lbs_private *priv);
 110        int (*power_restore) (struct lbs_private *priv);
 111        int (*enter_deep_sleep) (struct lbs_private *priv);
 112        int (*exit_deep_sleep) (struct lbs_private *priv);
 113        int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
 114
 115        /* Adapter info (from EEPROM) */
 116        u32 fwrelease;
 117        u32 fwcapinfo;
 118        u16 regioncode;
 119        u8 current_addr[ETH_ALEN];
 120        u8 copied_hwaddr;
 121
 122        /* Command download */
 123        u8 dnld_sent;
 124        /* bit0 1/0=data_sent/data_tx_done,
 125           bit1 1/0=cmd_sent/cmd_tx_done,
 126           all other bits reserved 0 */
 127        u16 seqnum;
 128        struct cmd_ctrl_node *cmd_array;
 129        struct cmd_ctrl_node *cur_cmd;
 130        struct list_head cmdfreeq;    /* free command buffers */
 131        struct list_head cmdpendingq; /* pending command buffers */
 132        struct timer_list command_timer;
 133        int cmd_timed_out;
 134
 135        /* Command responses sent from the hardware to the driver */
 136        u8 resp_idx;
 137        u8 resp_buf[2][LBS_UPLD_SIZE];
 138        u32 resp_len[2];
 139
 140        /* Events sent from hardware to driver */
 141        struct kfifo event_fifo;
 142
 143        /* thread to service interrupts */
 144        struct task_struct *main_thread;
 145        wait_queue_head_t waitq;
 146        struct workqueue_struct *work_thread;
 147
 148        /* Encryption stuff */
 149        u8 authtype_auto;
 150        u8 wep_tx_key;
 151        u8 wep_key[4][WLAN_KEY_LEN_WEP104];
 152        u8 wep_key_len[4];
 153
 154        /* Wake On LAN */
 155        uint32_t wol_criteria;
 156        uint8_t wol_gpio;
 157        uint8_t wol_gap;
 158        bool ehs_remove_supported;
 159
 160        /* Transmitting */
 161        int tx_pending_len;             /* -1 while building packet */
 162        u8 tx_pending_buf[LBS_UPLD_SIZE];
 163        /* protected by hard_start_xmit serialization */
 164        u8 txretrycount;
 165        struct sk_buff *currenttxskb;
 166        struct timer_list tx_lockup_timer;
 167
 168        /* Locks */
 169        struct mutex lock;
 170        spinlock_t driver_lock;
 171
 172        /* NIC/link operation characteristics */
 173        u16 mac_control;
 174        u8 radio_on;
 175        u8 cur_rate;
 176        u8 channel;
 177        s16 txpower_cur;
 178        s16 txpower_min;
 179        s16 txpower_max;
 180
 181        /* Scanning */
 182        struct delayed_work scan_work;
 183        int scan_channel;
 184        /* Queue of things waiting for scan completion */
 185        wait_queue_head_t scan_q;
 186        /* Whether the scan was initiated internally and not by cfg80211 */
 187        bool internal_scan;
 188
 189        /* Firmware load */
 190        u32 fw_model;
 191        wait_queue_head_t fw_waitq;
 192        struct device *fw_device;
 193        const struct firmware *helper_fw;
 194        const struct lbs_fw_table *fw_table;
 195        const struct lbs_fw_table *fw_iter;
 196        lbs_fw_cb fw_callback;
 197};
 198
 199extern struct cmd_confirm_sleep confirm_sleep;
 200
 201/* Check if there is an interface active. */
 202static inline int lbs_iface_active(struct lbs_private *priv)
 203{
 204        int r;
 205
 206        r = netif_running(priv->dev);
 207        if (priv->mesh_dev)
 208                r |= netif_running(priv->mesh_dev);
 209
 210        return r;
 211}
 212
 213#endif
 214