Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * This file contains definitions and data structures specific
0004  * to Marvell 802.11 NIC. It contains the Device Information
0005  * structure struct lbs_private..
0006  */
0007 #ifndef _LBS_DEV_H_
0008 #define _LBS_DEV_H_
0009 
0010 #include "defs.h"
0011 #include "decl.h"
0012 #include "host.h"
0013 
0014 #include <linux/kfifo.h>
0015 
0016 /* sleep_params */
0017 struct sleep_params {
0018     uint16_t sp_error;
0019     uint16_t sp_offset;
0020     uint16_t sp_stabletime;
0021     uint8_t  sp_calcontrol;
0022     uint8_t  sp_extsleepclk;
0023     uint16_t sp_reserved;
0024 };
0025 
0026 /* Mesh statistics */
0027 struct lbs_mesh_stats {
0028     u32 fwd_bcast_cnt;      /* Fwd: Broadcast counter */
0029     u32 fwd_unicast_cnt;    /* Fwd: Unicast counter */
0030     u32 fwd_drop_ttl;       /* Fwd: TTL zero */
0031     u32 fwd_drop_rbt;       /* Fwd: Recently Broadcasted */
0032     u32 fwd_drop_noroute;   /* Fwd: No route to Destination */
0033     u32 fwd_drop_nobuf;     /* Fwd: Run out of internal buffers */
0034     u32 drop_blind;     /* Rx:  Dropped by blinding table */
0035     u32 tx_failed_cnt;      /* Tx:  Failed transmissions */
0036 };
0037 
0038 /* Private structure for the MV device */
0039 struct lbs_private {
0040 
0041     /* Basic networking */
0042     struct net_device *dev;
0043     u32 connect_status;
0044     struct work_struct mcast_work;
0045     u32 nr_of_multicastmacaddr;
0046     u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
0047 
0048     /* CFG80211 */
0049     struct wireless_dev *wdev;
0050     bool wiphy_registered;
0051     struct cfg80211_scan_request *scan_req;
0052     u8 assoc_bss[ETH_ALEN];
0053     u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
0054     u8 disassoc_reason;
0055 
0056     /* Mesh */
0057     struct net_device *mesh_dev; /* Virtual device */
0058 #ifdef CONFIG_LIBERTAS_MESH
0059     struct lbs_mesh_stats mstats;
0060     uint16_t mesh_tlv;
0061     u8 mesh_channel;
0062 #endif
0063 
0064     /* Debugfs */
0065     struct dentry *debugfs_dir;
0066     struct dentry *debugfs_debug;
0067     struct dentry *debugfs_files[6];
0068     struct dentry *events_dir;
0069     struct dentry *debugfs_events_files[6];
0070     struct dentry *regs_dir;
0071     struct dentry *debugfs_regs_files[6];
0072 
0073     /* Hardware debugging */
0074     u32 mac_offset;
0075     u32 bbp_offset;
0076     u32 rf_offset;
0077 
0078     /* Power management */
0079     u16 psmode;
0080     u32 psstate;
0081     u8 needtowakeup;
0082 
0083     /* Deep sleep */
0084     int is_deep_sleep;
0085     int deep_sleep_required;
0086     int is_auto_deep_sleep_enabled;
0087     int wakeup_dev_required;
0088     int is_activity_detected;
0089     int auto_deep_sleep_timeout; /* in ms */
0090     wait_queue_head_t ds_awake_q;
0091     struct timer_list auto_deepsleep_timer;
0092 
0093     /* Host sleep*/
0094     int is_host_sleep_configured;
0095     int is_host_sleep_activated;
0096     wait_queue_head_t host_sleep_q;
0097 
0098     /* Hardware access */
0099     void *card;
0100     bool iface_running;
0101     u8 is_polling; /* host has to poll the card irq */
0102     u8 fw_ready;
0103     u8 surpriseremoved;
0104     u8 setup_fw_on_resume;
0105     u8 power_up_on_resume;
0106     int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
0107     void (*reset_card) (struct lbs_private *priv);
0108     int (*power_save) (struct lbs_private *priv);
0109     int (*power_restore) (struct lbs_private *priv);
0110     int (*enter_deep_sleep) (struct lbs_private *priv);
0111     int (*exit_deep_sleep) (struct lbs_private *priv);
0112     int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
0113 
0114     /* Adapter info (from EEPROM) */
0115     u32 fwrelease;
0116     u32 fwcapinfo;
0117     u16 regioncode;
0118     u8 current_addr[ETH_ALEN];
0119     u8 copied_hwaddr;
0120 
0121     /* Command download */
0122     u8 dnld_sent;
0123     /* bit0 1/0=data_sent/data_tx_done,
0124        bit1 1/0=cmd_sent/cmd_tx_done,
0125        all other bits reserved 0 */
0126     u16 seqnum;
0127     struct cmd_ctrl_node *cmd_array;
0128     struct cmd_ctrl_node *cur_cmd;
0129     struct list_head cmdfreeq;    /* free command buffers */
0130     struct list_head cmdpendingq; /* pending command buffers */
0131     struct timer_list command_timer;
0132     int cmd_timed_out;
0133 
0134     /* Command responses sent from the hardware to the driver */
0135     u8 resp_idx;
0136     u8 resp_buf[2][LBS_UPLD_SIZE];
0137     u32 resp_len[2];
0138 
0139     /* Events sent from hardware to driver */
0140     struct kfifo event_fifo;
0141 
0142     /* thread to service interrupts */
0143     struct task_struct *main_thread;
0144     wait_queue_head_t waitq;
0145     struct workqueue_struct *work_thread;
0146 
0147     /* Encryption stuff */
0148     u8 authtype_auto;
0149     u8 wep_tx_key;
0150     u8 wep_key[4][WLAN_KEY_LEN_WEP104];
0151     u8 wep_key_len[4];
0152 
0153     /* Wake On LAN */
0154     uint32_t wol_criteria;
0155     uint8_t wol_gpio;
0156     uint8_t wol_gap;
0157     bool ehs_remove_supported;
0158 
0159     /* Transmitting */
0160     int tx_pending_len;     /* -1 while building packet */
0161     u8 tx_pending_buf[LBS_UPLD_SIZE];
0162     /* protected by hard_start_xmit serialization */
0163     u8 txretrycount;
0164     struct sk_buff *currenttxskb;
0165     struct timer_list tx_lockup_timer;
0166 
0167     /* Locks */
0168     struct mutex lock;
0169     spinlock_t driver_lock;
0170 
0171     /* NIC/link operation characteristics */
0172     u16 mac_control;
0173     u8 radio_on;
0174     u8 cur_rate;
0175     u8 channel;
0176     s16 txpower_cur;
0177     s16 txpower_min;
0178     s16 txpower_max;
0179 
0180     /* Scanning */
0181     struct delayed_work scan_work;
0182     int scan_channel;
0183     /* Queue of things waiting for scan completion */
0184     wait_queue_head_t scan_q;
0185     /* Whether the scan was initiated internally and not by cfg80211 */
0186     bool internal_scan;
0187 
0188     /* Firmware load */
0189     u32 fw_model;
0190     wait_queue_head_t fw_waitq;
0191     struct device *fw_device;
0192     const struct firmware *helper_fw;
0193     const struct lbs_fw_table *fw_table;
0194     const struct lbs_fw_table *fw_iter;
0195     lbs_fw_cb fw_callback;
0196 };
0197 
0198 extern struct cmd_confirm_sleep confirm_sleep;
0199 
0200 /* Check if there is an interface active. */
0201 static inline int lbs_iface_active(struct lbs_private *priv)
0202 {
0203     int r;
0204 
0205     r = netif_running(priv->dev);
0206     if (priv->mesh_dev)
0207         r |= netif_running(priv->mesh_dev);
0208 
0209     return r;
0210 }
0211 
0212 #endif