18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci Copyright (C) 2010 Willow Garage <http://www.willowgarage.com> 48c2ecf20Sopenharmony_ci Copyright (C) 2004 - 2010 Ivo van Doorn <IvDoorn@gmail.com> 58c2ecf20Sopenharmony_ci Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com> 68c2ecf20Sopenharmony_ci <http://rt2x00.serialmonkey.com> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* 118c2ecf20Sopenharmony_ci Module: rt2x00 128c2ecf20Sopenharmony_ci Abstract: rt2x00 global information. 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef RT2X00_H 168c2ecf20Sopenharmony_ci#define RT2X00_H 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <linux/bitops.h> 198c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 208c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 218c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 228c2ecf20Sopenharmony_ci#include <linux/firmware.h> 238c2ecf20Sopenharmony_ci#include <linux/leds.h> 248c2ecf20Sopenharmony_ci#include <linux/mutex.h> 258c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 268c2ecf20Sopenharmony_ci#include <linux/kfifo.h> 278c2ecf20Sopenharmony_ci#include <linux/hrtimer.h> 288c2ecf20Sopenharmony_ci#include <linux/average.h> 298c2ecf20Sopenharmony_ci#include <linux/usb.h> 308c2ecf20Sopenharmony_ci#include <linux/clk.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include <net/mac80211.h> 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#include "rt2x00debug.h" 358c2ecf20Sopenharmony_ci#include "rt2x00dump.h" 368c2ecf20Sopenharmony_ci#include "rt2x00leds.h" 378c2ecf20Sopenharmony_ci#include "rt2x00reg.h" 388c2ecf20Sopenharmony_ci#include "rt2x00queue.h" 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* 418c2ecf20Sopenharmony_ci * Module information. 428c2ecf20Sopenharmony_ci */ 438c2ecf20Sopenharmony_ci#define DRV_VERSION "2.3.0" 448c2ecf20Sopenharmony_ci#define DRV_PROJECT "http://rt2x00.serialmonkey.com" 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* Debug definitions. 478c2ecf20Sopenharmony_ci * Debug output has to be enabled during compile time. 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci#ifdef CONFIG_RT2X00_DEBUG 508c2ecf20Sopenharmony_ci#define DEBUG 518c2ecf20Sopenharmony_ci#endif /* CONFIG_RT2X00_DEBUG */ 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* Utility printing macros 548c2ecf20Sopenharmony_ci * rt2x00_probe_err is for messages when rt2x00_dev is uninitialized 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci#define rt2x00_probe_err(fmt, ...) \ 578c2ecf20Sopenharmony_ci printk(KERN_ERR KBUILD_MODNAME ": %s: Error - " fmt, \ 588c2ecf20Sopenharmony_ci __func__, ##__VA_ARGS__) 598c2ecf20Sopenharmony_ci#define rt2x00_err(dev, fmt, ...) \ 608c2ecf20Sopenharmony_ci wiphy_err_ratelimited((dev)->hw->wiphy, "%s: Error - " fmt, \ 618c2ecf20Sopenharmony_ci __func__, ##__VA_ARGS__) 628c2ecf20Sopenharmony_ci#define rt2x00_warn(dev, fmt, ...) \ 638c2ecf20Sopenharmony_ci wiphy_warn_ratelimited((dev)->hw->wiphy, "%s: Warning - " fmt, \ 648c2ecf20Sopenharmony_ci __func__, ##__VA_ARGS__) 658c2ecf20Sopenharmony_ci#define rt2x00_info(dev, fmt, ...) \ 668c2ecf20Sopenharmony_ci wiphy_info((dev)->hw->wiphy, "%s: Info - " fmt, \ 678c2ecf20Sopenharmony_ci __func__, ##__VA_ARGS__) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* Various debug levels */ 708c2ecf20Sopenharmony_ci#define rt2x00_dbg(dev, fmt, ...) \ 718c2ecf20Sopenharmony_ci wiphy_dbg((dev)->hw->wiphy, "%s: Debug - " fmt, \ 728c2ecf20Sopenharmony_ci __func__, ##__VA_ARGS__) 738c2ecf20Sopenharmony_ci#define rt2x00_eeprom_dbg(dev, fmt, ...) \ 748c2ecf20Sopenharmony_ci wiphy_dbg((dev)->hw->wiphy, "%s: EEPROM recovery - " fmt, \ 758c2ecf20Sopenharmony_ci __func__, ##__VA_ARGS__) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* 788c2ecf20Sopenharmony_ci * Duration calculations 798c2ecf20Sopenharmony_ci * The rate variable passed is: 100kbs. 808c2ecf20Sopenharmony_ci * To convert from bytes to bits we multiply size with 8, 818c2ecf20Sopenharmony_ci * then the size is multiplied with 10 to make the 828c2ecf20Sopenharmony_ci * real rate -> rate argument correction. 838c2ecf20Sopenharmony_ci */ 848c2ecf20Sopenharmony_ci#define GET_DURATION(__size, __rate) (((__size) * 8 * 10) / (__rate)) 858c2ecf20Sopenharmony_ci#define GET_DURATION_RES(__size, __rate)(((__size) * 8 * 10) % (__rate)) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* 888c2ecf20Sopenharmony_ci * Determine the number of L2 padding bytes required between the header and 898c2ecf20Sopenharmony_ci * the payload. 908c2ecf20Sopenharmony_ci */ 918c2ecf20Sopenharmony_ci#define L2PAD_SIZE(__hdrlen) (-(__hdrlen) & 3) 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* 948c2ecf20Sopenharmony_ci * Determine the alignment requirement, 958c2ecf20Sopenharmony_ci * to make sure the 802.11 payload is padded to a 4-byte boundrary 968c2ecf20Sopenharmony_ci * we must determine the address of the payload and calculate the 978c2ecf20Sopenharmony_ci * amount of bytes needed to move the data. 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_ci#define ALIGN_SIZE(__skb, __header) \ 1008c2ecf20Sopenharmony_ci (((unsigned long)((__skb)->data + (__header))) & 3) 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci/* 1038c2ecf20Sopenharmony_ci * Constants for extra TX headroom for alignment purposes. 1048c2ecf20Sopenharmony_ci */ 1058c2ecf20Sopenharmony_ci#define RT2X00_ALIGN_SIZE 4 /* Only whole frame needs alignment */ 1068c2ecf20Sopenharmony_ci#define RT2X00_L2PAD_SIZE 8 /* Both header & payload need alignment */ 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci/* 1098c2ecf20Sopenharmony_ci * Standard timing and size defines. 1108c2ecf20Sopenharmony_ci * These values should follow the ieee80211 specifications. 1118c2ecf20Sopenharmony_ci */ 1128c2ecf20Sopenharmony_ci#define ACK_SIZE 14 1138c2ecf20Sopenharmony_ci#define IEEE80211_HEADER 24 1148c2ecf20Sopenharmony_ci#define PLCP 48 1158c2ecf20Sopenharmony_ci#define BEACON 100 1168c2ecf20Sopenharmony_ci#define PREAMBLE 144 1178c2ecf20Sopenharmony_ci#define SHORT_PREAMBLE 72 1188c2ecf20Sopenharmony_ci#define SLOT_TIME 20 1198c2ecf20Sopenharmony_ci#define SHORT_SLOT_TIME 9 1208c2ecf20Sopenharmony_ci#define SIFS 10 1218c2ecf20Sopenharmony_ci#define PIFS (SIFS + SLOT_TIME) 1228c2ecf20Sopenharmony_ci#define SHORT_PIFS (SIFS + SHORT_SLOT_TIME) 1238c2ecf20Sopenharmony_ci#define DIFS (PIFS + SLOT_TIME) 1248c2ecf20Sopenharmony_ci#define SHORT_DIFS (SHORT_PIFS + SHORT_SLOT_TIME) 1258c2ecf20Sopenharmony_ci#define EIFS (SIFS + DIFS + \ 1268c2ecf20Sopenharmony_ci GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10)) 1278c2ecf20Sopenharmony_ci#define SHORT_EIFS (SIFS + SHORT_DIFS + \ 1288c2ecf20Sopenharmony_ci GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10)) 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cienum rt2x00_chip_intf { 1318c2ecf20Sopenharmony_ci RT2X00_CHIP_INTF_PCI, 1328c2ecf20Sopenharmony_ci RT2X00_CHIP_INTF_PCIE, 1338c2ecf20Sopenharmony_ci RT2X00_CHIP_INTF_USB, 1348c2ecf20Sopenharmony_ci RT2X00_CHIP_INTF_SOC, 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* 1388c2ecf20Sopenharmony_ci * Chipset identification 1398c2ecf20Sopenharmony_ci * The chipset on the device is composed of a RT and RF chip. 1408c2ecf20Sopenharmony_ci * The chipset combination is important for determining device capabilities. 1418c2ecf20Sopenharmony_ci */ 1428c2ecf20Sopenharmony_cistruct rt2x00_chip { 1438c2ecf20Sopenharmony_ci u16 rt; 1448c2ecf20Sopenharmony_ci#define RT2460 0x2460 1458c2ecf20Sopenharmony_ci#define RT2560 0x2560 1468c2ecf20Sopenharmony_ci#define RT2570 0x2570 1478c2ecf20Sopenharmony_ci#define RT2661 0x2661 1488c2ecf20Sopenharmony_ci#define RT2573 0x2573 1498c2ecf20Sopenharmony_ci#define RT2860 0x2860 /* 2.4GHz */ 1508c2ecf20Sopenharmony_ci#define RT2872 0x2872 /* WSOC */ 1518c2ecf20Sopenharmony_ci#define RT2883 0x2883 /* WSOC */ 1528c2ecf20Sopenharmony_ci#define RT3070 0x3070 1538c2ecf20Sopenharmony_ci#define RT3071 0x3071 1548c2ecf20Sopenharmony_ci#define RT3090 0x3090 /* 2.4GHz PCIe */ 1558c2ecf20Sopenharmony_ci#define RT3290 0x3290 1568c2ecf20Sopenharmony_ci#define RT3352 0x3352 /* WSOC */ 1578c2ecf20Sopenharmony_ci#define RT3390 0x3390 1588c2ecf20Sopenharmony_ci#define RT3572 0x3572 1598c2ecf20Sopenharmony_ci#define RT3593 0x3593 1608c2ecf20Sopenharmony_ci#define RT3883 0x3883 /* WSOC */ 1618c2ecf20Sopenharmony_ci#define RT5350 0x5350 /* WSOC 2.4GHz */ 1628c2ecf20Sopenharmony_ci#define RT5390 0x5390 /* 2.4GHz */ 1638c2ecf20Sopenharmony_ci#define RT5392 0x5392 /* 2.4GHz */ 1648c2ecf20Sopenharmony_ci#define RT5592 0x5592 1658c2ecf20Sopenharmony_ci#define RT6352 0x6352 /* WSOC 2.4GHz */ 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci u16 rf; 1688c2ecf20Sopenharmony_ci u16 rev; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci enum rt2x00_chip_intf intf; 1718c2ecf20Sopenharmony_ci}; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* 1748c2ecf20Sopenharmony_ci * RF register values that belong to a particular channel. 1758c2ecf20Sopenharmony_ci */ 1768c2ecf20Sopenharmony_cistruct rf_channel { 1778c2ecf20Sopenharmony_ci int channel; 1788c2ecf20Sopenharmony_ci u32 rf1; 1798c2ecf20Sopenharmony_ci u32 rf2; 1808c2ecf20Sopenharmony_ci u32 rf3; 1818c2ecf20Sopenharmony_ci u32 rf4; 1828c2ecf20Sopenharmony_ci}; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci/* 1858c2ecf20Sopenharmony_ci * Channel information structure 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_cistruct channel_info { 1888c2ecf20Sopenharmony_ci unsigned int flags; 1898c2ecf20Sopenharmony_ci#define GEOGRAPHY_ALLOWED 0x00000001 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci short max_power; 1928c2ecf20Sopenharmony_ci short default_power1; 1938c2ecf20Sopenharmony_ci short default_power2; 1948c2ecf20Sopenharmony_ci short default_power3; 1958c2ecf20Sopenharmony_ci}; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/* 1988c2ecf20Sopenharmony_ci * Antenna setup values. 1998c2ecf20Sopenharmony_ci */ 2008c2ecf20Sopenharmony_cistruct antenna_setup { 2018c2ecf20Sopenharmony_ci enum antenna rx; 2028c2ecf20Sopenharmony_ci enum antenna tx; 2038c2ecf20Sopenharmony_ci u8 rx_chain_num; 2048c2ecf20Sopenharmony_ci u8 tx_chain_num; 2058c2ecf20Sopenharmony_ci}; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci/* 2088c2ecf20Sopenharmony_ci * Quality statistics about the currently active link. 2098c2ecf20Sopenharmony_ci */ 2108c2ecf20Sopenharmony_cistruct link_qual { 2118c2ecf20Sopenharmony_ci /* 2128c2ecf20Sopenharmony_ci * Statistics required for Link tuning by driver 2138c2ecf20Sopenharmony_ci * The rssi value is provided by rt2x00lib during the 2148c2ecf20Sopenharmony_ci * link_tuner() callback function. 2158c2ecf20Sopenharmony_ci * The false_cca field is filled during the link_stats() 2168c2ecf20Sopenharmony_ci * callback function and could be used during the 2178c2ecf20Sopenharmony_ci * link_tuner() callback function. 2188c2ecf20Sopenharmony_ci */ 2198c2ecf20Sopenharmony_ci int rssi; 2208c2ecf20Sopenharmony_ci int false_cca; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci /* 2238c2ecf20Sopenharmony_ci * VGC levels 2248c2ecf20Sopenharmony_ci * Hardware driver will tune the VGC level during each call 2258c2ecf20Sopenharmony_ci * to the link_tuner() callback function. This vgc_level is 2268c2ecf20Sopenharmony_ci * is determined based on the link quality statistics like 2278c2ecf20Sopenharmony_ci * average RSSI and the false CCA count. 2288c2ecf20Sopenharmony_ci * 2298c2ecf20Sopenharmony_ci * In some cases the drivers need to differentiate between 2308c2ecf20Sopenharmony_ci * the currently "desired" VGC level and the level configured 2318c2ecf20Sopenharmony_ci * in the hardware. The latter is important to reduce the 2328c2ecf20Sopenharmony_ci * number of BBP register reads to reduce register access 2338c2ecf20Sopenharmony_ci * overhead. For this reason we store both values here. 2348c2ecf20Sopenharmony_ci */ 2358c2ecf20Sopenharmony_ci u8 vgc_level; 2368c2ecf20Sopenharmony_ci u8 vgc_level_reg; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci /* 2398c2ecf20Sopenharmony_ci * Statistics required for Signal quality calculation. 2408c2ecf20Sopenharmony_ci * These fields might be changed during the link_stats() 2418c2ecf20Sopenharmony_ci * callback function. 2428c2ecf20Sopenharmony_ci */ 2438c2ecf20Sopenharmony_ci int rx_success; 2448c2ecf20Sopenharmony_ci int rx_failed; 2458c2ecf20Sopenharmony_ci int tx_success; 2468c2ecf20Sopenharmony_ci int tx_failed; 2478c2ecf20Sopenharmony_ci}; 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ciDECLARE_EWMA(rssi, 10, 8) 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci/* 2528c2ecf20Sopenharmony_ci * Antenna settings about the currently active link. 2538c2ecf20Sopenharmony_ci */ 2548c2ecf20Sopenharmony_cistruct link_ant { 2558c2ecf20Sopenharmony_ci /* 2568c2ecf20Sopenharmony_ci * Antenna flags 2578c2ecf20Sopenharmony_ci */ 2588c2ecf20Sopenharmony_ci unsigned int flags; 2598c2ecf20Sopenharmony_ci#define ANTENNA_RX_DIVERSITY 0x00000001 2608c2ecf20Sopenharmony_ci#define ANTENNA_TX_DIVERSITY 0x00000002 2618c2ecf20Sopenharmony_ci#define ANTENNA_MODE_SAMPLE 0x00000004 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci /* 2648c2ecf20Sopenharmony_ci * Currently active TX/RX antenna setup. 2658c2ecf20Sopenharmony_ci * When software diversity is used, this will indicate 2668c2ecf20Sopenharmony_ci * which antenna is actually used at this time. 2678c2ecf20Sopenharmony_ci */ 2688c2ecf20Sopenharmony_ci struct antenna_setup active; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci /* 2718c2ecf20Sopenharmony_ci * RSSI history information for the antenna. 2728c2ecf20Sopenharmony_ci * Used to determine when to switch antenna 2738c2ecf20Sopenharmony_ci * when using software diversity. 2748c2ecf20Sopenharmony_ci */ 2758c2ecf20Sopenharmony_ci int rssi_history; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci /* 2788c2ecf20Sopenharmony_ci * Current RSSI average of the currently active antenna. 2798c2ecf20Sopenharmony_ci * Similar to the avg_rssi in the link_qual structure 2808c2ecf20Sopenharmony_ci * this value is updated by using the walking average. 2818c2ecf20Sopenharmony_ci */ 2828c2ecf20Sopenharmony_ci struct ewma_rssi rssi_ant; 2838c2ecf20Sopenharmony_ci}; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci/* 2868c2ecf20Sopenharmony_ci * To optimize the quality of the link we need to store 2878c2ecf20Sopenharmony_ci * the quality of received frames and periodically 2888c2ecf20Sopenharmony_ci * optimize the link. 2898c2ecf20Sopenharmony_ci */ 2908c2ecf20Sopenharmony_cistruct link { 2918c2ecf20Sopenharmony_ci /* 2928c2ecf20Sopenharmony_ci * Link tuner counter 2938c2ecf20Sopenharmony_ci * The number of times the link has been tuned 2948c2ecf20Sopenharmony_ci * since the radio has been switched on. 2958c2ecf20Sopenharmony_ci */ 2968c2ecf20Sopenharmony_ci u32 count; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci /* 2998c2ecf20Sopenharmony_ci * Quality measurement values. 3008c2ecf20Sopenharmony_ci */ 3018c2ecf20Sopenharmony_ci struct link_qual qual; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci /* 3048c2ecf20Sopenharmony_ci * TX/RX antenna setup. 3058c2ecf20Sopenharmony_ci */ 3068c2ecf20Sopenharmony_ci struct link_ant ant; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci /* 3098c2ecf20Sopenharmony_ci * Currently active average RSSI value 3108c2ecf20Sopenharmony_ci */ 3118c2ecf20Sopenharmony_ci struct ewma_rssi avg_rssi; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci /* 3148c2ecf20Sopenharmony_ci * Work structure for scheduling periodic link tuning. 3158c2ecf20Sopenharmony_ci */ 3168c2ecf20Sopenharmony_ci struct delayed_work work; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci /* 3198c2ecf20Sopenharmony_ci * Work structure for scheduling periodic watchdog monitoring. 3208c2ecf20Sopenharmony_ci * This work must be scheduled on the kernel workqueue, while 3218c2ecf20Sopenharmony_ci * all other work structures must be queued on the mac80211 3228c2ecf20Sopenharmony_ci * workqueue. This guarantees that the watchdog can schedule 3238c2ecf20Sopenharmony_ci * other work structures and wait for their completion in order 3248c2ecf20Sopenharmony_ci * to bring the device/driver back into the desired state. 3258c2ecf20Sopenharmony_ci */ 3268c2ecf20Sopenharmony_ci struct delayed_work watchdog_work; 3278c2ecf20Sopenharmony_ci unsigned int watchdog_interval; 3288c2ecf20Sopenharmony_ci bool watchdog_disabled; 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci /* 3318c2ecf20Sopenharmony_ci * Work structure for scheduling periodic AGC adjustments. 3328c2ecf20Sopenharmony_ci */ 3338c2ecf20Sopenharmony_ci struct delayed_work agc_work; 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci /* 3368c2ecf20Sopenharmony_ci * Work structure for scheduling periodic VCO calibration. 3378c2ecf20Sopenharmony_ci */ 3388c2ecf20Sopenharmony_ci struct delayed_work vco_work; 3398c2ecf20Sopenharmony_ci}; 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_cienum rt2x00_delayed_flags { 3428c2ecf20Sopenharmony_ci DELAYED_UPDATE_BEACON, 3438c2ecf20Sopenharmony_ci}; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci/* 3468c2ecf20Sopenharmony_ci * Interface structure 3478c2ecf20Sopenharmony_ci * Per interface configuration details, this structure 3488c2ecf20Sopenharmony_ci * is allocated as the private data for ieee80211_vif. 3498c2ecf20Sopenharmony_ci */ 3508c2ecf20Sopenharmony_cistruct rt2x00_intf { 3518c2ecf20Sopenharmony_ci /* 3528c2ecf20Sopenharmony_ci * beacon->skb must be protected with the mutex. 3538c2ecf20Sopenharmony_ci */ 3548c2ecf20Sopenharmony_ci struct mutex beacon_skb_mutex; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci /* 3578c2ecf20Sopenharmony_ci * Entry in the beacon queue which belongs to 3588c2ecf20Sopenharmony_ci * this interface. Each interface has its own 3598c2ecf20Sopenharmony_ci * dedicated beacon entry. 3608c2ecf20Sopenharmony_ci */ 3618c2ecf20Sopenharmony_ci struct queue_entry *beacon; 3628c2ecf20Sopenharmony_ci bool enable_beacon; 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci /* 3658c2ecf20Sopenharmony_ci * Actions that needed rescheduling. 3668c2ecf20Sopenharmony_ci */ 3678c2ecf20Sopenharmony_ci unsigned long delayed_flags; 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci /* 3708c2ecf20Sopenharmony_ci * Software sequence counter, this is only required 3718c2ecf20Sopenharmony_ci * for hardware which doesn't support hardware 3728c2ecf20Sopenharmony_ci * sequence counting. 3738c2ecf20Sopenharmony_ci */ 3748c2ecf20Sopenharmony_ci atomic_t seqno; 3758c2ecf20Sopenharmony_ci}; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_cistatic inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif) 3788c2ecf20Sopenharmony_ci{ 3798c2ecf20Sopenharmony_ci return (struct rt2x00_intf *)vif->drv_priv; 3808c2ecf20Sopenharmony_ci} 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci/** 3838c2ecf20Sopenharmony_ci * struct hw_mode_spec: Hardware specifications structure 3848c2ecf20Sopenharmony_ci * 3858c2ecf20Sopenharmony_ci * Details about the supported modes, rates and channels 3868c2ecf20Sopenharmony_ci * of a particular chipset. This is used by rt2x00lib 3878c2ecf20Sopenharmony_ci * to build the ieee80211_hw_mode array for mac80211. 3888c2ecf20Sopenharmony_ci * 3898c2ecf20Sopenharmony_ci * @supported_bands: Bitmask contained the supported bands (2.4GHz, 5.2GHz). 3908c2ecf20Sopenharmony_ci * @supported_rates: Rate types which are supported (CCK, OFDM). 3918c2ecf20Sopenharmony_ci * @num_channels: Number of supported channels. This is used as array size 3928c2ecf20Sopenharmony_ci * for @tx_power_a, @tx_power_bg and @channels. 3938c2ecf20Sopenharmony_ci * @channels: Device/chipset specific channel values (See &struct rf_channel). 3948c2ecf20Sopenharmony_ci * @channels_info: Additional information for channels (See &struct channel_info). 3958c2ecf20Sopenharmony_ci * @ht: Driver HT Capabilities (See &ieee80211_sta_ht_cap). 3968c2ecf20Sopenharmony_ci */ 3978c2ecf20Sopenharmony_cistruct hw_mode_spec { 3988c2ecf20Sopenharmony_ci unsigned int supported_bands; 3998c2ecf20Sopenharmony_ci#define SUPPORT_BAND_2GHZ 0x00000001 4008c2ecf20Sopenharmony_ci#define SUPPORT_BAND_5GHZ 0x00000002 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci unsigned int supported_rates; 4038c2ecf20Sopenharmony_ci#define SUPPORT_RATE_CCK 0x00000001 4048c2ecf20Sopenharmony_ci#define SUPPORT_RATE_OFDM 0x00000002 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci unsigned int num_channels; 4078c2ecf20Sopenharmony_ci const struct rf_channel *channels; 4088c2ecf20Sopenharmony_ci const struct channel_info *channels_info; 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci struct ieee80211_sta_ht_cap ht; 4118c2ecf20Sopenharmony_ci}; 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci/* 4148c2ecf20Sopenharmony_ci * Configuration structure wrapper around the 4158c2ecf20Sopenharmony_ci * mac80211 configuration structure. 4168c2ecf20Sopenharmony_ci * When mac80211 configures the driver, rt2x00lib 4178c2ecf20Sopenharmony_ci * can precalculate values which are equal for all 4188c2ecf20Sopenharmony_ci * rt2x00 drivers. Those values can be stored in here. 4198c2ecf20Sopenharmony_ci */ 4208c2ecf20Sopenharmony_cistruct rt2x00lib_conf { 4218c2ecf20Sopenharmony_ci struct ieee80211_conf *conf; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci struct rf_channel rf; 4248c2ecf20Sopenharmony_ci struct channel_info channel; 4258c2ecf20Sopenharmony_ci}; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci/* 4288c2ecf20Sopenharmony_ci * Configuration structure for erp settings. 4298c2ecf20Sopenharmony_ci */ 4308c2ecf20Sopenharmony_cistruct rt2x00lib_erp { 4318c2ecf20Sopenharmony_ci int short_preamble; 4328c2ecf20Sopenharmony_ci int cts_protection; 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci u32 basic_rates; 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci int slot_time; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci short sifs; 4398c2ecf20Sopenharmony_ci short pifs; 4408c2ecf20Sopenharmony_ci short difs; 4418c2ecf20Sopenharmony_ci short eifs; 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci u16 beacon_int; 4448c2ecf20Sopenharmony_ci u16 ht_opmode; 4458c2ecf20Sopenharmony_ci}; 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci/* 4488c2ecf20Sopenharmony_ci * Configuration structure for hardware encryption. 4498c2ecf20Sopenharmony_ci */ 4508c2ecf20Sopenharmony_cistruct rt2x00lib_crypto { 4518c2ecf20Sopenharmony_ci enum cipher cipher; 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci enum set_key_cmd cmd; 4548c2ecf20Sopenharmony_ci const u8 *address; 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci u32 bssidx; 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_ci u8 key[16]; 4598c2ecf20Sopenharmony_ci u8 tx_mic[8]; 4608c2ecf20Sopenharmony_ci u8 rx_mic[8]; 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci int wcid; 4638c2ecf20Sopenharmony_ci}; 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci/* 4668c2ecf20Sopenharmony_ci * Configuration structure wrapper around the 4678c2ecf20Sopenharmony_ci * rt2x00 interface configuration handler. 4688c2ecf20Sopenharmony_ci */ 4698c2ecf20Sopenharmony_cistruct rt2x00intf_conf { 4708c2ecf20Sopenharmony_ci /* 4718c2ecf20Sopenharmony_ci * Interface type 4728c2ecf20Sopenharmony_ci */ 4738c2ecf20Sopenharmony_ci enum nl80211_iftype type; 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci /* 4768c2ecf20Sopenharmony_ci * TSF sync value, this is dependent on the operation type. 4778c2ecf20Sopenharmony_ci */ 4788c2ecf20Sopenharmony_ci enum tsf_sync sync; 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci /* 4818c2ecf20Sopenharmony_ci * The MAC and BSSID addresses are simple array of bytes, 4828c2ecf20Sopenharmony_ci * these arrays are little endian, so when sending the addresses 4838c2ecf20Sopenharmony_ci * to the drivers, copy the it into a endian-signed variable. 4848c2ecf20Sopenharmony_ci * 4858c2ecf20Sopenharmony_ci * Note that all devices (except rt2500usb) have 32 bits 4868c2ecf20Sopenharmony_ci * register word sizes. This means that whatever variable we 4878c2ecf20Sopenharmony_ci * pass _must_ be a multiple of 32 bits. Otherwise the device 4888c2ecf20Sopenharmony_ci * might not accept what we are sending to it. 4898c2ecf20Sopenharmony_ci * This will also make it easier for the driver to write 4908c2ecf20Sopenharmony_ci * the data to the device. 4918c2ecf20Sopenharmony_ci */ 4928c2ecf20Sopenharmony_ci __le32 mac[2]; 4938c2ecf20Sopenharmony_ci __le32 bssid[2]; 4948c2ecf20Sopenharmony_ci}; 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci/* 4978c2ecf20Sopenharmony_ci * Private structure for storing STA details 4988c2ecf20Sopenharmony_ci * wcid: Wireless Client ID 4998c2ecf20Sopenharmony_ci */ 5008c2ecf20Sopenharmony_cistruct rt2x00_sta { 5018c2ecf20Sopenharmony_ci int wcid; 5028c2ecf20Sopenharmony_ci}; 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_cistatic inline struct rt2x00_sta* sta_to_rt2x00_sta(struct ieee80211_sta *sta) 5058c2ecf20Sopenharmony_ci{ 5068c2ecf20Sopenharmony_ci return (struct rt2x00_sta *)sta->drv_priv; 5078c2ecf20Sopenharmony_ci} 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci/* 5108c2ecf20Sopenharmony_ci * rt2x00lib callback functions. 5118c2ecf20Sopenharmony_ci */ 5128c2ecf20Sopenharmony_cistruct rt2x00lib_ops { 5138c2ecf20Sopenharmony_ci /* 5148c2ecf20Sopenharmony_ci * Interrupt handlers. 5158c2ecf20Sopenharmony_ci */ 5168c2ecf20Sopenharmony_ci irq_handler_t irq_handler; 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci /* 5198c2ecf20Sopenharmony_ci * TX status tasklet handler. 5208c2ecf20Sopenharmony_ci */ 5218c2ecf20Sopenharmony_ci void (*txstatus_tasklet) (struct tasklet_struct *t); 5228c2ecf20Sopenharmony_ci void (*pretbtt_tasklet) (struct tasklet_struct *t); 5238c2ecf20Sopenharmony_ci void (*tbtt_tasklet) (struct tasklet_struct *t); 5248c2ecf20Sopenharmony_ci void (*rxdone_tasklet) (struct tasklet_struct *t); 5258c2ecf20Sopenharmony_ci void (*autowake_tasklet) (struct tasklet_struct *t); 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci /* 5288c2ecf20Sopenharmony_ci * Device init handlers. 5298c2ecf20Sopenharmony_ci */ 5308c2ecf20Sopenharmony_ci int (*probe_hw) (struct rt2x00_dev *rt2x00dev); 5318c2ecf20Sopenharmony_ci char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev); 5328c2ecf20Sopenharmony_ci int (*check_firmware) (struct rt2x00_dev *rt2x00dev, 5338c2ecf20Sopenharmony_ci const u8 *data, const size_t len); 5348c2ecf20Sopenharmony_ci int (*load_firmware) (struct rt2x00_dev *rt2x00dev, 5358c2ecf20Sopenharmony_ci const u8 *data, const size_t len); 5368c2ecf20Sopenharmony_ci 5378c2ecf20Sopenharmony_ci /* 5388c2ecf20Sopenharmony_ci * Device initialization/deinitialization handlers. 5398c2ecf20Sopenharmony_ci */ 5408c2ecf20Sopenharmony_ci int (*initialize) (struct rt2x00_dev *rt2x00dev); 5418c2ecf20Sopenharmony_ci void (*uninitialize) (struct rt2x00_dev *rt2x00dev); 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci /* 5448c2ecf20Sopenharmony_ci * queue initialization handlers 5458c2ecf20Sopenharmony_ci */ 5468c2ecf20Sopenharmony_ci bool (*get_entry_state) (struct queue_entry *entry); 5478c2ecf20Sopenharmony_ci void (*clear_entry) (struct queue_entry *entry); 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci /* 5508c2ecf20Sopenharmony_ci * Radio control handlers. 5518c2ecf20Sopenharmony_ci */ 5528c2ecf20Sopenharmony_ci int (*set_device_state) (struct rt2x00_dev *rt2x00dev, 5538c2ecf20Sopenharmony_ci enum dev_state state); 5548c2ecf20Sopenharmony_ci int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev); 5558c2ecf20Sopenharmony_ci void (*link_stats) (struct rt2x00_dev *rt2x00dev, 5568c2ecf20Sopenharmony_ci struct link_qual *qual); 5578c2ecf20Sopenharmony_ci void (*reset_tuner) (struct rt2x00_dev *rt2x00dev, 5588c2ecf20Sopenharmony_ci struct link_qual *qual); 5598c2ecf20Sopenharmony_ci void (*link_tuner) (struct rt2x00_dev *rt2x00dev, 5608c2ecf20Sopenharmony_ci struct link_qual *qual, const u32 count); 5618c2ecf20Sopenharmony_ci void (*gain_calibration) (struct rt2x00_dev *rt2x00dev); 5628c2ecf20Sopenharmony_ci void (*vco_calibration) (struct rt2x00_dev *rt2x00dev); 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci /* 5658c2ecf20Sopenharmony_ci * Data queue handlers. 5668c2ecf20Sopenharmony_ci */ 5678c2ecf20Sopenharmony_ci void (*watchdog) (struct rt2x00_dev *rt2x00dev); 5688c2ecf20Sopenharmony_ci void (*start_queue) (struct data_queue *queue); 5698c2ecf20Sopenharmony_ci void (*kick_queue) (struct data_queue *queue); 5708c2ecf20Sopenharmony_ci void (*stop_queue) (struct data_queue *queue); 5718c2ecf20Sopenharmony_ci void (*flush_queue) (struct data_queue *queue, bool drop); 5728c2ecf20Sopenharmony_ci void (*tx_dma_done) (struct queue_entry *entry); 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci /* 5758c2ecf20Sopenharmony_ci * TX control handlers 5768c2ecf20Sopenharmony_ci */ 5778c2ecf20Sopenharmony_ci void (*write_tx_desc) (struct queue_entry *entry, 5788c2ecf20Sopenharmony_ci struct txentry_desc *txdesc); 5798c2ecf20Sopenharmony_ci void (*write_tx_data) (struct queue_entry *entry, 5808c2ecf20Sopenharmony_ci struct txentry_desc *txdesc); 5818c2ecf20Sopenharmony_ci void (*write_beacon) (struct queue_entry *entry, 5828c2ecf20Sopenharmony_ci struct txentry_desc *txdesc); 5838c2ecf20Sopenharmony_ci void (*clear_beacon) (struct queue_entry *entry); 5848c2ecf20Sopenharmony_ci int (*get_tx_data_len) (struct queue_entry *entry); 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci /* 5878c2ecf20Sopenharmony_ci * RX control handlers 5888c2ecf20Sopenharmony_ci */ 5898c2ecf20Sopenharmony_ci void (*fill_rxdone) (struct queue_entry *entry, 5908c2ecf20Sopenharmony_ci struct rxdone_entry_desc *rxdesc); 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci /* 5938c2ecf20Sopenharmony_ci * Configuration handlers. 5948c2ecf20Sopenharmony_ci */ 5958c2ecf20Sopenharmony_ci int (*config_shared_key) (struct rt2x00_dev *rt2x00dev, 5968c2ecf20Sopenharmony_ci struct rt2x00lib_crypto *crypto, 5978c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key); 5988c2ecf20Sopenharmony_ci int (*config_pairwise_key) (struct rt2x00_dev *rt2x00dev, 5998c2ecf20Sopenharmony_ci struct rt2x00lib_crypto *crypto, 6008c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key); 6018c2ecf20Sopenharmony_ci void (*config_filter) (struct rt2x00_dev *rt2x00dev, 6028c2ecf20Sopenharmony_ci const unsigned int filter_flags); 6038c2ecf20Sopenharmony_ci void (*config_intf) (struct rt2x00_dev *rt2x00dev, 6048c2ecf20Sopenharmony_ci struct rt2x00_intf *intf, 6058c2ecf20Sopenharmony_ci struct rt2x00intf_conf *conf, 6068c2ecf20Sopenharmony_ci const unsigned int flags); 6078c2ecf20Sopenharmony_ci#define CONFIG_UPDATE_TYPE ( 1 << 1 ) 6088c2ecf20Sopenharmony_ci#define CONFIG_UPDATE_MAC ( 1 << 2 ) 6098c2ecf20Sopenharmony_ci#define CONFIG_UPDATE_BSSID ( 1 << 3 ) 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci void (*config_erp) (struct rt2x00_dev *rt2x00dev, 6128c2ecf20Sopenharmony_ci struct rt2x00lib_erp *erp, 6138c2ecf20Sopenharmony_ci u32 changed); 6148c2ecf20Sopenharmony_ci void (*config_ant) (struct rt2x00_dev *rt2x00dev, 6158c2ecf20Sopenharmony_ci struct antenna_setup *ant); 6168c2ecf20Sopenharmony_ci void (*config) (struct rt2x00_dev *rt2x00dev, 6178c2ecf20Sopenharmony_ci struct rt2x00lib_conf *libconf, 6188c2ecf20Sopenharmony_ci const unsigned int changed_flags); 6198c2ecf20Sopenharmony_ci void (*pre_reset_hw) (struct rt2x00_dev *rt2x00dev); 6208c2ecf20Sopenharmony_ci int (*sta_add) (struct rt2x00_dev *rt2x00dev, 6218c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 6228c2ecf20Sopenharmony_ci struct ieee80211_sta *sta); 6238c2ecf20Sopenharmony_ci int (*sta_remove) (struct rt2x00_dev *rt2x00dev, 6248c2ecf20Sopenharmony_ci struct ieee80211_sta *sta); 6258c2ecf20Sopenharmony_ci}; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci/* 6288c2ecf20Sopenharmony_ci * rt2x00 driver callback operation structure. 6298c2ecf20Sopenharmony_ci */ 6308c2ecf20Sopenharmony_cistruct rt2x00_ops { 6318c2ecf20Sopenharmony_ci const char *name; 6328c2ecf20Sopenharmony_ci const unsigned int drv_data_size; 6338c2ecf20Sopenharmony_ci const unsigned int max_ap_intf; 6348c2ecf20Sopenharmony_ci const unsigned int eeprom_size; 6358c2ecf20Sopenharmony_ci const unsigned int rf_size; 6368c2ecf20Sopenharmony_ci const unsigned int tx_queues; 6378c2ecf20Sopenharmony_ci void (*queue_init)(struct data_queue *queue); 6388c2ecf20Sopenharmony_ci const struct rt2x00lib_ops *lib; 6398c2ecf20Sopenharmony_ci const void *drv; 6408c2ecf20Sopenharmony_ci const struct ieee80211_ops *hw; 6418c2ecf20Sopenharmony_ci#ifdef CONFIG_RT2X00_LIB_DEBUGFS 6428c2ecf20Sopenharmony_ci const struct rt2x00debug *debugfs; 6438c2ecf20Sopenharmony_ci#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 6448c2ecf20Sopenharmony_ci}; 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci/* 6478c2ecf20Sopenharmony_ci * rt2x00 state flags 6488c2ecf20Sopenharmony_ci */ 6498c2ecf20Sopenharmony_cienum rt2x00_state_flags { 6508c2ecf20Sopenharmony_ci /* 6518c2ecf20Sopenharmony_ci * Device flags 6528c2ecf20Sopenharmony_ci */ 6538c2ecf20Sopenharmony_ci DEVICE_STATE_PRESENT, 6548c2ecf20Sopenharmony_ci DEVICE_STATE_REGISTERED_HW, 6558c2ecf20Sopenharmony_ci DEVICE_STATE_INITIALIZED, 6568c2ecf20Sopenharmony_ci DEVICE_STATE_STARTED, 6578c2ecf20Sopenharmony_ci DEVICE_STATE_ENABLED_RADIO, 6588c2ecf20Sopenharmony_ci DEVICE_STATE_SCANNING, 6598c2ecf20Sopenharmony_ci DEVICE_STATE_FLUSHING, 6608c2ecf20Sopenharmony_ci DEVICE_STATE_RESET, 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_ci /* 6638c2ecf20Sopenharmony_ci * Driver configuration 6648c2ecf20Sopenharmony_ci */ 6658c2ecf20Sopenharmony_ci CONFIG_CHANNEL_HT40, 6668c2ecf20Sopenharmony_ci CONFIG_POWERSAVING, 6678c2ecf20Sopenharmony_ci CONFIG_HT_DISABLED, 6688c2ecf20Sopenharmony_ci CONFIG_MONITORING, 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_ci /* 6718c2ecf20Sopenharmony_ci * Mark we currently are sequentially reading TX_STA_FIFO register 6728c2ecf20Sopenharmony_ci * FIXME: this is for only rt2800usb, should go to private data 6738c2ecf20Sopenharmony_ci */ 6748c2ecf20Sopenharmony_ci TX_STATUS_READING, 6758c2ecf20Sopenharmony_ci}; 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci/* 6788c2ecf20Sopenharmony_ci * rt2x00 capability flags 6798c2ecf20Sopenharmony_ci */ 6808c2ecf20Sopenharmony_cienum rt2x00_capability_flags { 6818c2ecf20Sopenharmony_ci /* 6828c2ecf20Sopenharmony_ci * Requirements 6838c2ecf20Sopenharmony_ci */ 6848c2ecf20Sopenharmony_ci REQUIRE_FIRMWARE, 6858c2ecf20Sopenharmony_ci REQUIRE_BEACON_GUARD, 6868c2ecf20Sopenharmony_ci REQUIRE_ATIM_QUEUE, 6878c2ecf20Sopenharmony_ci REQUIRE_DMA, 6888c2ecf20Sopenharmony_ci REQUIRE_COPY_IV, 6898c2ecf20Sopenharmony_ci REQUIRE_L2PAD, 6908c2ecf20Sopenharmony_ci REQUIRE_TXSTATUS_FIFO, 6918c2ecf20Sopenharmony_ci REQUIRE_TASKLET_CONTEXT, 6928c2ecf20Sopenharmony_ci REQUIRE_SW_SEQNO, 6938c2ecf20Sopenharmony_ci REQUIRE_HT_TX_DESC, 6948c2ecf20Sopenharmony_ci REQUIRE_PS_AUTOWAKE, 6958c2ecf20Sopenharmony_ci REQUIRE_DELAYED_RFKILL, 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_ci /* 6988c2ecf20Sopenharmony_ci * Capabilities 6998c2ecf20Sopenharmony_ci */ 7008c2ecf20Sopenharmony_ci CAPABILITY_HW_BUTTON, 7018c2ecf20Sopenharmony_ci CAPABILITY_HW_CRYPTO, 7028c2ecf20Sopenharmony_ci CAPABILITY_POWER_LIMIT, 7038c2ecf20Sopenharmony_ci CAPABILITY_CONTROL_FILTERS, 7048c2ecf20Sopenharmony_ci CAPABILITY_CONTROL_FILTER_PSPOLL, 7058c2ecf20Sopenharmony_ci CAPABILITY_PRE_TBTT_INTERRUPT, 7068c2ecf20Sopenharmony_ci CAPABILITY_LINK_TUNING, 7078c2ecf20Sopenharmony_ci CAPABILITY_FRAME_TYPE, 7088c2ecf20Sopenharmony_ci CAPABILITY_RF_SEQUENCE, 7098c2ecf20Sopenharmony_ci CAPABILITY_EXTERNAL_LNA_A, 7108c2ecf20Sopenharmony_ci CAPABILITY_EXTERNAL_LNA_BG, 7118c2ecf20Sopenharmony_ci CAPABILITY_DOUBLE_ANTENNA, 7128c2ecf20Sopenharmony_ci CAPABILITY_BT_COEXIST, 7138c2ecf20Sopenharmony_ci CAPABILITY_VCO_RECALIBRATION, 7148c2ecf20Sopenharmony_ci CAPABILITY_EXTERNAL_PA_TX0, 7158c2ecf20Sopenharmony_ci CAPABILITY_EXTERNAL_PA_TX1, 7168c2ecf20Sopenharmony_ci CAPABILITY_RESTART_HW, 7178c2ecf20Sopenharmony_ci}; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci/* 7208c2ecf20Sopenharmony_ci * Interface combinations 7218c2ecf20Sopenharmony_ci */ 7228c2ecf20Sopenharmony_cienum { 7238c2ecf20Sopenharmony_ci IF_COMB_AP = 0, 7248c2ecf20Sopenharmony_ci NUM_IF_COMB, 7258c2ecf20Sopenharmony_ci}; 7268c2ecf20Sopenharmony_ci 7278c2ecf20Sopenharmony_ci/* 7288c2ecf20Sopenharmony_ci * rt2x00 device structure. 7298c2ecf20Sopenharmony_ci */ 7308c2ecf20Sopenharmony_cistruct rt2x00_dev { 7318c2ecf20Sopenharmony_ci /* 7328c2ecf20Sopenharmony_ci * Device structure. 7338c2ecf20Sopenharmony_ci * The structure stored in here depends on the 7348c2ecf20Sopenharmony_ci * system bus (PCI or USB). 7358c2ecf20Sopenharmony_ci * When accessing this variable, the rt2x00dev_{pci,usb} 7368c2ecf20Sopenharmony_ci * macros should be used for correct typecasting. 7378c2ecf20Sopenharmony_ci */ 7388c2ecf20Sopenharmony_ci struct device *dev; 7398c2ecf20Sopenharmony_ci 7408c2ecf20Sopenharmony_ci /* 7418c2ecf20Sopenharmony_ci * Callback functions. 7428c2ecf20Sopenharmony_ci */ 7438c2ecf20Sopenharmony_ci const struct rt2x00_ops *ops; 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci /* 7468c2ecf20Sopenharmony_ci * Driver data. 7478c2ecf20Sopenharmony_ci */ 7488c2ecf20Sopenharmony_ci void *drv_data; 7498c2ecf20Sopenharmony_ci 7508c2ecf20Sopenharmony_ci /* 7518c2ecf20Sopenharmony_ci * IEEE80211 control structure. 7528c2ecf20Sopenharmony_ci */ 7538c2ecf20Sopenharmony_ci struct ieee80211_hw *hw; 7548c2ecf20Sopenharmony_ci struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; 7558c2ecf20Sopenharmony_ci enum nl80211_band curr_band; 7568c2ecf20Sopenharmony_ci int curr_freq; 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_ci /* 7598c2ecf20Sopenharmony_ci * If enabled, the debugfs interface structures 7608c2ecf20Sopenharmony_ci * required for deregistration of debugfs. 7618c2ecf20Sopenharmony_ci */ 7628c2ecf20Sopenharmony_ci#ifdef CONFIG_RT2X00_LIB_DEBUGFS 7638c2ecf20Sopenharmony_ci struct rt2x00debug_intf *debugfs_intf; 7648c2ecf20Sopenharmony_ci#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_ci /* 7678c2ecf20Sopenharmony_ci * LED structure for changing the LED status 7688c2ecf20Sopenharmony_ci * by mac8011 or the kernel. 7698c2ecf20Sopenharmony_ci */ 7708c2ecf20Sopenharmony_ci#ifdef CONFIG_RT2X00_LIB_LEDS 7718c2ecf20Sopenharmony_ci struct rt2x00_led led_radio; 7728c2ecf20Sopenharmony_ci struct rt2x00_led led_assoc; 7738c2ecf20Sopenharmony_ci struct rt2x00_led led_qual; 7748c2ecf20Sopenharmony_ci u16 led_mcu_reg; 7758c2ecf20Sopenharmony_ci#endif /* CONFIG_RT2X00_LIB_LEDS */ 7768c2ecf20Sopenharmony_ci 7778c2ecf20Sopenharmony_ci /* 7788c2ecf20Sopenharmony_ci * Device state flags. 7798c2ecf20Sopenharmony_ci * In these flags the current status is stored. 7808c2ecf20Sopenharmony_ci * Access to these flags should occur atomically. 7818c2ecf20Sopenharmony_ci */ 7828c2ecf20Sopenharmony_ci unsigned long flags; 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci /* 7858c2ecf20Sopenharmony_ci * Device capabiltiy flags. 7868c2ecf20Sopenharmony_ci * In these flags the device/driver capabilities are stored. 7878c2ecf20Sopenharmony_ci * Access to these flags should occur non-atomically. 7888c2ecf20Sopenharmony_ci */ 7898c2ecf20Sopenharmony_ci unsigned long cap_flags; 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci /* 7928c2ecf20Sopenharmony_ci * Device information, Bus IRQ and name (PCI, SoC) 7938c2ecf20Sopenharmony_ci */ 7948c2ecf20Sopenharmony_ci int irq; 7958c2ecf20Sopenharmony_ci const char *name; 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_ci /* 7988c2ecf20Sopenharmony_ci * Chipset identification. 7998c2ecf20Sopenharmony_ci */ 8008c2ecf20Sopenharmony_ci struct rt2x00_chip chip; 8018c2ecf20Sopenharmony_ci 8028c2ecf20Sopenharmony_ci /* 8038c2ecf20Sopenharmony_ci * hw capability specifications. 8048c2ecf20Sopenharmony_ci */ 8058c2ecf20Sopenharmony_ci struct hw_mode_spec spec; 8068c2ecf20Sopenharmony_ci 8078c2ecf20Sopenharmony_ci /* 8088c2ecf20Sopenharmony_ci * This is the default TX/RX antenna setup as indicated 8098c2ecf20Sopenharmony_ci * by the device's EEPROM. 8108c2ecf20Sopenharmony_ci */ 8118c2ecf20Sopenharmony_ci struct antenna_setup default_ant; 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ci /* 8148c2ecf20Sopenharmony_ci * Register pointers 8158c2ecf20Sopenharmony_ci * csr.base: CSR base register address. (PCI) 8168c2ecf20Sopenharmony_ci * csr.cache: CSR cache for usb_control_msg. (USB) 8178c2ecf20Sopenharmony_ci */ 8188c2ecf20Sopenharmony_ci union csr { 8198c2ecf20Sopenharmony_ci void __iomem *base; 8208c2ecf20Sopenharmony_ci void *cache; 8218c2ecf20Sopenharmony_ci } csr; 8228c2ecf20Sopenharmony_ci 8238c2ecf20Sopenharmony_ci /* 8248c2ecf20Sopenharmony_ci * Mutex to protect register accesses. 8258c2ecf20Sopenharmony_ci * For PCI and USB devices it protects against concurrent indirect 8268c2ecf20Sopenharmony_ci * register access (BBP, RF, MCU) since accessing those 8278c2ecf20Sopenharmony_ci * registers require multiple calls to the CSR registers. 8288c2ecf20Sopenharmony_ci * For USB devices it also protects the csr_cache since that 8298c2ecf20Sopenharmony_ci * field is used for normal CSR access and it cannot support 8308c2ecf20Sopenharmony_ci * multiple callers simultaneously. 8318c2ecf20Sopenharmony_ci */ 8328c2ecf20Sopenharmony_ci struct mutex csr_mutex; 8338c2ecf20Sopenharmony_ci 8348c2ecf20Sopenharmony_ci /* 8358c2ecf20Sopenharmony_ci * Mutex to synchronize config and link tuner. 8368c2ecf20Sopenharmony_ci */ 8378c2ecf20Sopenharmony_ci struct mutex conf_mutex; 8388c2ecf20Sopenharmony_ci /* 8398c2ecf20Sopenharmony_ci * Current packet filter configuration for the device. 8408c2ecf20Sopenharmony_ci * This contains all currently active FIF_* flags send 8418c2ecf20Sopenharmony_ci * to us by mac80211 during configure_filter(). 8428c2ecf20Sopenharmony_ci */ 8438c2ecf20Sopenharmony_ci unsigned int packet_filter; 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci /* 8468c2ecf20Sopenharmony_ci * Interface details: 8478c2ecf20Sopenharmony_ci * - Open ap interface count. 8488c2ecf20Sopenharmony_ci * - Open sta interface count. 8498c2ecf20Sopenharmony_ci * - Association count. 8508c2ecf20Sopenharmony_ci * - Beaconing enabled count. 8518c2ecf20Sopenharmony_ci */ 8528c2ecf20Sopenharmony_ci unsigned int intf_ap_count; 8538c2ecf20Sopenharmony_ci unsigned int intf_sta_count; 8548c2ecf20Sopenharmony_ci unsigned int intf_associated; 8558c2ecf20Sopenharmony_ci unsigned int intf_beaconing; 8568c2ecf20Sopenharmony_ci 8578c2ecf20Sopenharmony_ci /* 8588c2ecf20Sopenharmony_ci * Interface combinations 8598c2ecf20Sopenharmony_ci */ 8608c2ecf20Sopenharmony_ci struct ieee80211_iface_limit if_limits_ap; 8618c2ecf20Sopenharmony_ci struct ieee80211_iface_combination if_combinations[NUM_IF_COMB]; 8628c2ecf20Sopenharmony_ci 8638c2ecf20Sopenharmony_ci /* 8648c2ecf20Sopenharmony_ci * Link quality 8658c2ecf20Sopenharmony_ci */ 8668c2ecf20Sopenharmony_ci struct link link; 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_ci /* 8698c2ecf20Sopenharmony_ci * EEPROM data. 8708c2ecf20Sopenharmony_ci */ 8718c2ecf20Sopenharmony_ci __le16 *eeprom; 8728c2ecf20Sopenharmony_ci 8738c2ecf20Sopenharmony_ci /* 8748c2ecf20Sopenharmony_ci * Active RF register values. 8758c2ecf20Sopenharmony_ci * These are stored here so we don't need 8768c2ecf20Sopenharmony_ci * to read the rf registers and can directly 8778c2ecf20Sopenharmony_ci * use this value instead. 8788c2ecf20Sopenharmony_ci * This field should be accessed by using 8798c2ecf20Sopenharmony_ci * rt2x00_rf_read() and rt2x00_rf_write(). 8808c2ecf20Sopenharmony_ci */ 8818c2ecf20Sopenharmony_ci u32 *rf; 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_ci /* 8848c2ecf20Sopenharmony_ci * LNA gain 8858c2ecf20Sopenharmony_ci */ 8868c2ecf20Sopenharmony_ci short lna_gain; 8878c2ecf20Sopenharmony_ci 8888c2ecf20Sopenharmony_ci /* 8898c2ecf20Sopenharmony_ci * Current TX power value. 8908c2ecf20Sopenharmony_ci */ 8918c2ecf20Sopenharmony_ci u16 tx_power; 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci /* 8948c2ecf20Sopenharmony_ci * Current retry values. 8958c2ecf20Sopenharmony_ci */ 8968c2ecf20Sopenharmony_ci u8 short_retry; 8978c2ecf20Sopenharmony_ci u8 long_retry; 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_ci /* 9008c2ecf20Sopenharmony_ci * Rssi <-> Dbm offset 9018c2ecf20Sopenharmony_ci */ 9028c2ecf20Sopenharmony_ci u8 rssi_offset; 9038c2ecf20Sopenharmony_ci 9048c2ecf20Sopenharmony_ci /* 9058c2ecf20Sopenharmony_ci * Frequency offset. 9068c2ecf20Sopenharmony_ci */ 9078c2ecf20Sopenharmony_ci u8 freq_offset; 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_ci /* 9108c2ecf20Sopenharmony_ci * Association id. 9118c2ecf20Sopenharmony_ci */ 9128c2ecf20Sopenharmony_ci u16 aid; 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci /* 9158c2ecf20Sopenharmony_ci * Beacon interval. 9168c2ecf20Sopenharmony_ci */ 9178c2ecf20Sopenharmony_ci u16 beacon_int; 9188c2ecf20Sopenharmony_ci 9198c2ecf20Sopenharmony_ci /** 9208c2ecf20Sopenharmony_ci * Timestamp of last received beacon 9218c2ecf20Sopenharmony_ci */ 9228c2ecf20Sopenharmony_ci unsigned long last_beacon; 9238c2ecf20Sopenharmony_ci 9248c2ecf20Sopenharmony_ci /* 9258c2ecf20Sopenharmony_ci * Low level statistics which will have 9268c2ecf20Sopenharmony_ci * to be kept up to date while device is running. 9278c2ecf20Sopenharmony_ci */ 9288c2ecf20Sopenharmony_ci struct ieee80211_low_level_stats low_level_stats; 9298c2ecf20Sopenharmony_ci 9308c2ecf20Sopenharmony_ci /** 9318c2ecf20Sopenharmony_ci * Work queue for all work which should not be placed 9328c2ecf20Sopenharmony_ci * on the mac80211 workqueue (because of dependencies 9338c2ecf20Sopenharmony_ci * between various work structures). 9348c2ecf20Sopenharmony_ci */ 9358c2ecf20Sopenharmony_ci struct workqueue_struct *workqueue; 9368c2ecf20Sopenharmony_ci 9378c2ecf20Sopenharmony_ci /* 9388c2ecf20Sopenharmony_ci * Scheduled work. 9398c2ecf20Sopenharmony_ci * NOTE: intf_work will use ieee80211_iterate_active_interfaces() 9408c2ecf20Sopenharmony_ci * which means it cannot be placed on the hw->workqueue 9418c2ecf20Sopenharmony_ci * due to RTNL locking requirements. 9428c2ecf20Sopenharmony_ci */ 9438c2ecf20Sopenharmony_ci struct work_struct intf_work; 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_ci /** 9468c2ecf20Sopenharmony_ci * Scheduled work for TX/RX done handling (USB devices) 9478c2ecf20Sopenharmony_ci */ 9488c2ecf20Sopenharmony_ci struct work_struct rxdone_work; 9498c2ecf20Sopenharmony_ci struct work_struct txdone_work; 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci /* 9528c2ecf20Sopenharmony_ci * Powersaving work 9538c2ecf20Sopenharmony_ci */ 9548c2ecf20Sopenharmony_ci struct delayed_work autowakeup_work; 9558c2ecf20Sopenharmony_ci struct work_struct sleep_work; 9568c2ecf20Sopenharmony_ci 9578c2ecf20Sopenharmony_ci /* 9588c2ecf20Sopenharmony_ci * Data queue arrays for RX, TX, Beacon and ATIM. 9598c2ecf20Sopenharmony_ci */ 9608c2ecf20Sopenharmony_ci unsigned int data_queues; 9618c2ecf20Sopenharmony_ci struct data_queue *rx; 9628c2ecf20Sopenharmony_ci struct data_queue *tx; 9638c2ecf20Sopenharmony_ci struct data_queue *bcn; 9648c2ecf20Sopenharmony_ci struct data_queue *atim; 9658c2ecf20Sopenharmony_ci 9668c2ecf20Sopenharmony_ci /* 9678c2ecf20Sopenharmony_ci * Firmware image. 9688c2ecf20Sopenharmony_ci */ 9698c2ecf20Sopenharmony_ci const struct firmware *fw; 9708c2ecf20Sopenharmony_ci 9718c2ecf20Sopenharmony_ci /* 9728c2ecf20Sopenharmony_ci * FIFO for storing tx status reports between isr and tasklet. 9738c2ecf20Sopenharmony_ci */ 9748c2ecf20Sopenharmony_ci DECLARE_KFIFO_PTR(txstatus_fifo, u32); 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_ci /* 9778c2ecf20Sopenharmony_ci * Timer to ensure tx status reports are read (rt2800usb). 9788c2ecf20Sopenharmony_ci */ 9798c2ecf20Sopenharmony_ci struct hrtimer txstatus_timer; 9808c2ecf20Sopenharmony_ci 9818c2ecf20Sopenharmony_ci /* 9828c2ecf20Sopenharmony_ci * Tasklet for processing tx status reports (rt2800pci). 9838c2ecf20Sopenharmony_ci */ 9848c2ecf20Sopenharmony_ci struct tasklet_struct txstatus_tasklet; 9858c2ecf20Sopenharmony_ci struct tasklet_struct pretbtt_tasklet; 9868c2ecf20Sopenharmony_ci struct tasklet_struct tbtt_tasklet; 9878c2ecf20Sopenharmony_ci struct tasklet_struct rxdone_tasklet; 9888c2ecf20Sopenharmony_ci struct tasklet_struct autowake_tasklet; 9898c2ecf20Sopenharmony_ci 9908c2ecf20Sopenharmony_ci /* 9918c2ecf20Sopenharmony_ci * Used for VCO periodic calibration. 9928c2ecf20Sopenharmony_ci */ 9938c2ecf20Sopenharmony_ci int rf_channel; 9948c2ecf20Sopenharmony_ci 9958c2ecf20Sopenharmony_ci /* 9968c2ecf20Sopenharmony_ci * Protect the interrupt mask register. 9978c2ecf20Sopenharmony_ci */ 9988c2ecf20Sopenharmony_ci spinlock_t irqmask_lock; 9998c2ecf20Sopenharmony_ci 10008c2ecf20Sopenharmony_ci /* 10018c2ecf20Sopenharmony_ci * List of BlockAckReq TX entries that need driver BlockAck processing. 10028c2ecf20Sopenharmony_ci */ 10038c2ecf20Sopenharmony_ci struct list_head bar_list; 10048c2ecf20Sopenharmony_ci spinlock_t bar_list_lock; 10058c2ecf20Sopenharmony_ci 10068c2ecf20Sopenharmony_ci /* Extra TX headroom required for alignment purposes. */ 10078c2ecf20Sopenharmony_ci unsigned int extra_tx_headroom; 10088c2ecf20Sopenharmony_ci 10098c2ecf20Sopenharmony_ci struct usb_anchor *anchor; 10108c2ecf20Sopenharmony_ci unsigned int num_proto_errs; 10118c2ecf20Sopenharmony_ci 10128c2ecf20Sopenharmony_ci /* Clock for System On Chip devices. */ 10138c2ecf20Sopenharmony_ci struct clk *clk; 10148c2ecf20Sopenharmony_ci}; 10158c2ecf20Sopenharmony_ci 10168c2ecf20Sopenharmony_cistruct rt2x00_bar_list_entry { 10178c2ecf20Sopenharmony_ci struct list_head list; 10188c2ecf20Sopenharmony_ci struct rcu_head head; 10198c2ecf20Sopenharmony_ci 10208c2ecf20Sopenharmony_ci struct queue_entry *entry; 10218c2ecf20Sopenharmony_ci int block_acked; 10228c2ecf20Sopenharmony_ci 10238c2ecf20Sopenharmony_ci /* Relevant parts of the IEEE80211 BAR header */ 10248c2ecf20Sopenharmony_ci __u8 ra[6]; 10258c2ecf20Sopenharmony_ci __u8 ta[6]; 10268c2ecf20Sopenharmony_ci __le16 control; 10278c2ecf20Sopenharmony_ci __le16 start_seq_num; 10288c2ecf20Sopenharmony_ci}; 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci/* 10318c2ecf20Sopenharmony_ci * Register defines. 10328c2ecf20Sopenharmony_ci * Some registers require multiple attempts before success, 10338c2ecf20Sopenharmony_ci * in those cases REGISTER_BUSY_COUNT attempts should be 10348c2ecf20Sopenharmony_ci * taken with a REGISTER_BUSY_DELAY interval. Due to USB 10358c2ecf20Sopenharmony_ci * bus delays, we do not have to loop so many times to wait 10368c2ecf20Sopenharmony_ci * for valid register value on that bus. 10378c2ecf20Sopenharmony_ci */ 10388c2ecf20Sopenharmony_ci#define REGISTER_BUSY_COUNT 100 10398c2ecf20Sopenharmony_ci#define REGISTER_USB_BUSY_COUNT 20 10408c2ecf20Sopenharmony_ci#define REGISTER_BUSY_DELAY 100 10418c2ecf20Sopenharmony_ci 10428c2ecf20Sopenharmony_ci/* 10438c2ecf20Sopenharmony_ci * Generic RF access. 10448c2ecf20Sopenharmony_ci * The RF is being accessed by word index. 10458c2ecf20Sopenharmony_ci */ 10468c2ecf20Sopenharmony_cistatic inline u32 rt2x00_rf_read(struct rt2x00_dev *rt2x00dev, 10478c2ecf20Sopenharmony_ci const unsigned int word) 10488c2ecf20Sopenharmony_ci{ 10498c2ecf20Sopenharmony_ci BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32)); 10508c2ecf20Sopenharmony_ci return rt2x00dev->rf[word - 1]; 10518c2ecf20Sopenharmony_ci} 10528c2ecf20Sopenharmony_ci 10538c2ecf20Sopenharmony_cistatic inline void rt2x00_rf_write(struct rt2x00_dev *rt2x00dev, 10548c2ecf20Sopenharmony_ci const unsigned int word, u32 data) 10558c2ecf20Sopenharmony_ci{ 10568c2ecf20Sopenharmony_ci BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32)); 10578c2ecf20Sopenharmony_ci rt2x00dev->rf[word - 1] = data; 10588c2ecf20Sopenharmony_ci} 10598c2ecf20Sopenharmony_ci 10608c2ecf20Sopenharmony_ci/* 10618c2ecf20Sopenharmony_ci * Generic EEPROM access. The EEPROM is being accessed by word or byte index. 10628c2ecf20Sopenharmony_ci */ 10638c2ecf20Sopenharmony_cistatic inline void *rt2x00_eeprom_addr(struct rt2x00_dev *rt2x00dev, 10648c2ecf20Sopenharmony_ci const unsigned int word) 10658c2ecf20Sopenharmony_ci{ 10668c2ecf20Sopenharmony_ci return (void *)&rt2x00dev->eeprom[word]; 10678c2ecf20Sopenharmony_ci} 10688c2ecf20Sopenharmony_ci 10698c2ecf20Sopenharmony_cistatic inline u16 rt2x00_eeprom_read(struct rt2x00_dev *rt2x00dev, 10708c2ecf20Sopenharmony_ci const unsigned int word) 10718c2ecf20Sopenharmony_ci{ 10728c2ecf20Sopenharmony_ci return le16_to_cpu(rt2x00dev->eeprom[word]); 10738c2ecf20Sopenharmony_ci} 10748c2ecf20Sopenharmony_ci 10758c2ecf20Sopenharmony_cistatic inline void rt2x00_eeprom_write(struct rt2x00_dev *rt2x00dev, 10768c2ecf20Sopenharmony_ci const unsigned int word, u16 data) 10778c2ecf20Sopenharmony_ci{ 10788c2ecf20Sopenharmony_ci rt2x00dev->eeprom[word] = cpu_to_le16(data); 10798c2ecf20Sopenharmony_ci} 10808c2ecf20Sopenharmony_ci 10818c2ecf20Sopenharmony_cistatic inline u8 rt2x00_eeprom_byte(struct rt2x00_dev *rt2x00dev, 10828c2ecf20Sopenharmony_ci const unsigned int byte) 10838c2ecf20Sopenharmony_ci{ 10848c2ecf20Sopenharmony_ci return *(((u8 *)rt2x00dev->eeprom) + byte); 10858c2ecf20Sopenharmony_ci} 10868c2ecf20Sopenharmony_ci 10878c2ecf20Sopenharmony_ci/* 10888c2ecf20Sopenharmony_ci * Chipset handlers 10898c2ecf20Sopenharmony_ci */ 10908c2ecf20Sopenharmony_cistatic inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev, 10918c2ecf20Sopenharmony_ci const u16 rt, const u16 rf, const u16 rev) 10928c2ecf20Sopenharmony_ci{ 10938c2ecf20Sopenharmony_ci rt2x00dev->chip.rt = rt; 10948c2ecf20Sopenharmony_ci rt2x00dev->chip.rf = rf; 10958c2ecf20Sopenharmony_ci rt2x00dev->chip.rev = rev; 10968c2ecf20Sopenharmony_ci 10978c2ecf20Sopenharmony_ci rt2x00_info(rt2x00dev, "Chipset detected - rt: %04x, rf: %04x, rev: %04x\n", 10988c2ecf20Sopenharmony_ci rt2x00dev->chip.rt, rt2x00dev->chip.rf, 10998c2ecf20Sopenharmony_ci rt2x00dev->chip.rev); 11008c2ecf20Sopenharmony_ci} 11018c2ecf20Sopenharmony_ci 11028c2ecf20Sopenharmony_cistatic inline void rt2x00_set_rt(struct rt2x00_dev *rt2x00dev, 11038c2ecf20Sopenharmony_ci const u16 rt, const u16 rev) 11048c2ecf20Sopenharmony_ci{ 11058c2ecf20Sopenharmony_ci rt2x00dev->chip.rt = rt; 11068c2ecf20Sopenharmony_ci rt2x00dev->chip.rev = rev; 11078c2ecf20Sopenharmony_ci 11088c2ecf20Sopenharmony_ci rt2x00_info(rt2x00dev, "RT chipset %04x, rev %04x detected\n", 11098c2ecf20Sopenharmony_ci rt2x00dev->chip.rt, rt2x00dev->chip.rev); 11108c2ecf20Sopenharmony_ci} 11118c2ecf20Sopenharmony_ci 11128c2ecf20Sopenharmony_cistatic inline void rt2x00_set_rf(struct rt2x00_dev *rt2x00dev, const u16 rf) 11138c2ecf20Sopenharmony_ci{ 11148c2ecf20Sopenharmony_ci rt2x00dev->chip.rf = rf; 11158c2ecf20Sopenharmony_ci 11168c2ecf20Sopenharmony_ci rt2x00_info(rt2x00dev, "RF chipset %04x detected\n", 11178c2ecf20Sopenharmony_ci rt2x00dev->chip.rf); 11188c2ecf20Sopenharmony_ci} 11198c2ecf20Sopenharmony_ci 11208c2ecf20Sopenharmony_cistatic inline bool rt2x00_rt(struct rt2x00_dev *rt2x00dev, const u16 rt) 11218c2ecf20Sopenharmony_ci{ 11228c2ecf20Sopenharmony_ci return (rt2x00dev->chip.rt == rt); 11238c2ecf20Sopenharmony_ci} 11248c2ecf20Sopenharmony_ci 11258c2ecf20Sopenharmony_cistatic inline bool rt2x00_rf(struct rt2x00_dev *rt2x00dev, const u16 rf) 11268c2ecf20Sopenharmony_ci{ 11278c2ecf20Sopenharmony_ci return (rt2x00dev->chip.rf == rf); 11288c2ecf20Sopenharmony_ci} 11298c2ecf20Sopenharmony_ci 11308c2ecf20Sopenharmony_cistatic inline u16 rt2x00_rev(struct rt2x00_dev *rt2x00dev) 11318c2ecf20Sopenharmony_ci{ 11328c2ecf20Sopenharmony_ci return rt2x00dev->chip.rev; 11338c2ecf20Sopenharmony_ci} 11348c2ecf20Sopenharmony_ci 11358c2ecf20Sopenharmony_cistatic inline bool rt2x00_rt_rev(struct rt2x00_dev *rt2x00dev, 11368c2ecf20Sopenharmony_ci const u16 rt, const u16 rev) 11378c2ecf20Sopenharmony_ci{ 11388c2ecf20Sopenharmony_ci return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) == rev); 11398c2ecf20Sopenharmony_ci} 11408c2ecf20Sopenharmony_ci 11418c2ecf20Sopenharmony_cistatic inline bool rt2x00_rt_rev_lt(struct rt2x00_dev *rt2x00dev, 11428c2ecf20Sopenharmony_ci const u16 rt, const u16 rev) 11438c2ecf20Sopenharmony_ci{ 11448c2ecf20Sopenharmony_ci return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) < rev); 11458c2ecf20Sopenharmony_ci} 11468c2ecf20Sopenharmony_ci 11478c2ecf20Sopenharmony_cistatic inline bool rt2x00_rt_rev_gte(struct rt2x00_dev *rt2x00dev, 11488c2ecf20Sopenharmony_ci const u16 rt, const u16 rev) 11498c2ecf20Sopenharmony_ci{ 11508c2ecf20Sopenharmony_ci return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) >= rev); 11518c2ecf20Sopenharmony_ci} 11528c2ecf20Sopenharmony_ci 11538c2ecf20Sopenharmony_cistatic inline void rt2x00_set_chip_intf(struct rt2x00_dev *rt2x00dev, 11548c2ecf20Sopenharmony_ci enum rt2x00_chip_intf intf) 11558c2ecf20Sopenharmony_ci{ 11568c2ecf20Sopenharmony_ci rt2x00dev->chip.intf = intf; 11578c2ecf20Sopenharmony_ci} 11588c2ecf20Sopenharmony_ci 11598c2ecf20Sopenharmony_cistatic inline bool rt2x00_intf(struct rt2x00_dev *rt2x00dev, 11608c2ecf20Sopenharmony_ci enum rt2x00_chip_intf intf) 11618c2ecf20Sopenharmony_ci{ 11628c2ecf20Sopenharmony_ci return (rt2x00dev->chip.intf == intf); 11638c2ecf20Sopenharmony_ci} 11648c2ecf20Sopenharmony_ci 11658c2ecf20Sopenharmony_cistatic inline bool rt2x00_is_pci(struct rt2x00_dev *rt2x00dev) 11668c2ecf20Sopenharmony_ci{ 11678c2ecf20Sopenharmony_ci return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCI) || 11688c2ecf20Sopenharmony_ci rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE); 11698c2ecf20Sopenharmony_ci} 11708c2ecf20Sopenharmony_ci 11718c2ecf20Sopenharmony_cistatic inline bool rt2x00_is_pcie(struct rt2x00_dev *rt2x00dev) 11728c2ecf20Sopenharmony_ci{ 11738c2ecf20Sopenharmony_ci return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE); 11748c2ecf20Sopenharmony_ci} 11758c2ecf20Sopenharmony_ci 11768c2ecf20Sopenharmony_cistatic inline bool rt2x00_is_usb(struct rt2x00_dev *rt2x00dev) 11778c2ecf20Sopenharmony_ci{ 11788c2ecf20Sopenharmony_ci return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_USB); 11798c2ecf20Sopenharmony_ci} 11808c2ecf20Sopenharmony_ci 11818c2ecf20Sopenharmony_cistatic inline bool rt2x00_is_soc(struct rt2x00_dev *rt2x00dev) 11828c2ecf20Sopenharmony_ci{ 11838c2ecf20Sopenharmony_ci return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC); 11848c2ecf20Sopenharmony_ci} 11858c2ecf20Sopenharmony_ci 11868c2ecf20Sopenharmony_ci/* Helpers for capability flags */ 11878c2ecf20Sopenharmony_ci 11888c2ecf20Sopenharmony_cistatic inline bool 11898c2ecf20Sopenharmony_cirt2x00_has_cap_flag(struct rt2x00_dev *rt2x00dev, 11908c2ecf20Sopenharmony_ci enum rt2x00_capability_flags cap_flag) 11918c2ecf20Sopenharmony_ci{ 11928c2ecf20Sopenharmony_ci return test_bit(cap_flag, &rt2x00dev->cap_flags); 11938c2ecf20Sopenharmony_ci} 11948c2ecf20Sopenharmony_ci 11958c2ecf20Sopenharmony_cistatic inline bool 11968c2ecf20Sopenharmony_cirt2x00_has_cap_hw_crypto(struct rt2x00_dev *rt2x00dev) 11978c2ecf20Sopenharmony_ci{ 11988c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_HW_CRYPTO); 11998c2ecf20Sopenharmony_ci} 12008c2ecf20Sopenharmony_ci 12018c2ecf20Sopenharmony_cistatic inline bool 12028c2ecf20Sopenharmony_cirt2x00_has_cap_power_limit(struct rt2x00_dev *rt2x00dev) 12038c2ecf20Sopenharmony_ci{ 12048c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_POWER_LIMIT); 12058c2ecf20Sopenharmony_ci} 12068c2ecf20Sopenharmony_ci 12078c2ecf20Sopenharmony_cistatic inline bool 12088c2ecf20Sopenharmony_cirt2x00_has_cap_control_filters(struct rt2x00_dev *rt2x00dev) 12098c2ecf20Sopenharmony_ci{ 12108c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_CONTROL_FILTERS); 12118c2ecf20Sopenharmony_ci} 12128c2ecf20Sopenharmony_ci 12138c2ecf20Sopenharmony_cistatic inline bool 12148c2ecf20Sopenharmony_cirt2x00_has_cap_control_filter_pspoll(struct rt2x00_dev *rt2x00dev) 12158c2ecf20Sopenharmony_ci{ 12168c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_CONTROL_FILTER_PSPOLL); 12178c2ecf20Sopenharmony_ci} 12188c2ecf20Sopenharmony_ci 12198c2ecf20Sopenharmony_cistatic inline bool 12208c2ecf20Sopenharmony_cirt2x00_has_cap_pre_tbtt_interrupt(struct rt2x00_dev *rt2x00dev) 12218c2ecf20Sopenharmony_ci{ 12228c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_PRE_TBTT_INTERRUPT); 12238c2ecf20Sopenharmony_ci} 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_cistatic inline bool 12268c2ecf20Sopenharmony_cirt2x00_has_cap_link_tuning(struct rt2x00_dev *rt2x00dev) 12278c2ecf20Sopenharmony_ci{ 12288c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_LINK_TUNING); 12298c2ecf20Sopenharmony_ci} 12308c2ecf20Sopenharmony_ci 12318c2ecf20Sopenharmony_cistatic inline bool 12328c2ecf20Sopenharmony_cirt2x00_has_cap_frame_type(struct rt2x00_dev *rt2x00dev) 12338c2ecf20Sopenharmony_ci{ 12348c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_FRAME_TYPE); 12358c2ecf20Sopenharmony_ci} 12368c2ecf20Sopenharmony_ci 12378c2ecf20Sopenharmony_cistatic inline bool 12388c2ecf20Sopenharmony_cirt2x00_has_cap_rf_sequence(struct rt2x00_dev *rt2x00dev) 12398c2ecf20Sopenharmony_ci{ 12408c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_RF_SEQUENCE); 12418c2ecf20Sopenharmony_ci} 12428c2ecf20Sopenharmony_ci 12438c2ecf20Sopenharmony_cistatic inline bool 12448c2ecf20Sopenharmony_cirt2x00_has_cap_external_lna_a(struct rt2x00_dev *rt2x00dev) 12458c2ecf20Sopenharmony_ci{ 12468c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_EXTERNAL_LNA_A); 12478c2ecf20Sopenharmony_ci} 12488c2ecf20Sopenharmony_ci 12498c2ecf20Sopenharmony_cistatic inline bool 12508c2ecf20Sopenharmony_cirt2x00_has_cap_external_lna_bg(struct rt2x00_dev *rt2x00dev) 12518c2ecf20Sopenharmony_ci{ 12528c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_EXTERNAL_LNA_BG); 12538c2ecf20Sopenharmony_ci} 12548c2ecf20Sopenharmony_ci 12558c2ecf20Sopenharmony_cistatic inline bool 12568c2ecf20Sopenharmony_cirt2x00_has_cap_double_antenna(struct rt2x00_dev *rt2x00dev) 12578c2ecf20Sopenharmony_ci{ 12588c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_DOUBLE_ANTENNA); 12598c2ecf20Sopenharmony_ci} 12608c2ecf20Sopenharmony_ci 12618c2ecf20Sopenharmony_cistatic inline bool 12628c2ecf20Sopenharmony_cirt2x00_has_cap_bt_coexist(struct rt2x00_dev *rt2x00dev) 12638c2ecf20Sopenharmony_ci{ 12648c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_BT_COEXIST); 12658c2ecf20Sopenharmony_ci} 12668c2ecf20Sopenharmony_ci 12678c2ecf20Sopenharmony_cistatic inline bool 12688c2ecf20Sopenharmony_cirt2x00_has_cap_vco_recalibration(struct rt2x00_dev *rt2x00dev) 12698c2ecf20Sopenharmony_ci{ 12708c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_VCO_RECALIBRATION); 12718c2ecf20Sopenharmony_ci} 12728c2ecf20Sopenharmony_ci 12738c2ecf20Sopenharmony_cistatic inline bool 12748c2ecf20Sopenharmony_cirt2x00_has_cap_restart_hw(struct rt2x00_dev *rt2x00dev) 12758c2ecf20Sopenharmony_ci{ 12768c2ecf20Sopenharmony_ci return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_RESTART_HW); 12778c2ecf20Sopenharmony_ci} 12788c2ecf20Sopenharmony_ci 12798c2ecf20Sopenharmony_ci/** 12808c2ecf20Sopenharmony_ci * rt2x00queue_map_txskb - Map a skb into DMA for TX purposes. 12818c2ecf20Sopenharmony_ci * @entry: Pointer to &struct queue_entry 12828c2ecf20Sopenharmony_ci * 12838c2ecf20Sopenharmony_ci * Returns -ENOMEM if mapping fail, 0 otherwise. 12848c2ecf20Sopenharmony_ci */ 12858c2ecf20Sopenharmony_ciint rt2x00queue_map_txskb(struct queue_entry *entry); 12868c2ecf20Sopenharmony_ci 12878c2ecf20Sopenharmony_ci/** 12888c2ecf20Sopenharmony_ci * rt2x00queue_unmap_skb - Unmap a skb from DMA. 12898c2ecf20Sopenharmony_ci * @entry: Pointer to &struct queue_entry 12908c2ecf20Sopenharmony_ci */ 12918c2ecf20Sopenharmony_civoid rt2x00queue_unmap_skb(struct queue_entry *entry); 12928c2ecf20Sopenharmony_ci 12938c2ecf20Sopenharmony_ci/** 12948c2ecf20Sopenharmony_ci * rt2x00queue_get_tx_queue - Convert tx queue index to queue pointer 12958c2ecf20Sopenharmony_ci * @rt2x00dev: Pointer to &struct rt2x00_dev. 12968c2ecf20Sopenharmony_ci * @queue: rt2x00 queue index (see &enum data_queue_qid). 12978c2ecf20Sopenharmony_ci * 12988c2ecf20Sopenharmony_ci * Returns NULL for non tx queues. 12998c2ecf20Sopenharmony_ci */ 13008c2ecf20Sopenharmony_cistatic inline struct data_queue * 13018c2ecf20Sopenharmony_cirt2x00queue_get_tx_queue(struct rt2x00_dev *rt2x00dev, 13028c2ecf20Sopenharmony_ci const enum data_queue_qid queue) 13038c2ecf20Sopenharmony_ci{ 13048c2ecf20Sopenharmony_ci if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx) 13058c2ecf20Sopenharmony_ci return &rt2x00dev->tx[queue]; 13068c2ecf20Sopenharmony_ci 13078c2ecf20Sopenharmony_ci if (queue == QID_ATIM) 13088c2ecf20Sopenharmony_ci return rt2x00dev->atim; 13098c2ecf20Sopenharmony_ci 13108c2ecf20Sopenharmony_ci return NULL; 13118c2ecf20Sopenharmony_ci} 13128c2ecf20Sopenharmony_ci 13138c2ecf20Sopenharmony_ci/** 13148c2ecf20Sopenharmony_ci * rt2x00queue_get_entry - Get queue entry where the given index points to. 13158c2ecf20Sopenharmony_ci * @queue: Pointer to &struct data_queue from where we obtain the entry. 13168c2ecf20Sopenharmony_ci * @index: Index identifier for obtaining the correct index. 13178c2ecf20Sopenharmony_ci */ 13188c2ecf20Sopenharmony_cistruct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, 13198c2ecf20Sopenharmony_ci enum queue_index index); 13208c2ecf20Sopenharmony_ci 13218c2ecf20Sopenharmony_ci/** 13228c2ecf20Sopenharmony_ci * rt2x00queue_pause_queue - Pause a data queue 13238c2ecf20Sopenharmony_ci * @queue: Pointer to &struct data_queue. 13248c2ecf20Sopenharmony_ci * 13258c2ecf20Sopenharmony_ci * This function will pause the data queue locally, preventing 13268c2ecf20Sopenharmony_ci * new frames to be added to the queue (while the hardware is 13278c2ecf20Sopenharmony_ci * still allowed to run). 13288c2ecf20Sopenharmony_ci */ 13298c2ecf20Sopenharmony_civoid rt2x00queue_pause_queue(struct data_queue *queue); 13308c2ecf20Sopenharmony_ci 13318c2ecf20Sopenharmony_ci/** 13328c2ecf20Sopenharmony_ci * rt2x00queue_unpause_queue - unpause a data queue 13338c2ecf20Sopenharmony_ci * @queue: Pointer to &struct data_queue. 13348c2ecf20Sopenharmony_ci * 13358c2ecf20Sopenharmony_ci * This function will unpause the data queue locally, allowing 13368c2ecf20Sopenharmony_ci * new frames to be added to the queue again. 13378c2ecf20Sopenharmony_ci */ 13388c2ecf20Sopenharmony_civoid rt2x00queue_unpause_queue(struct data_queue *queue); 13398c2ecf20Sopenharmony_ci 13408c2ecf20Sopenharmony_ci/** 13418c2ecf20Sopenharmony_ci * rt2x00queue_start_queue - Start a data queue 13428c2ecf20Sopenharmony_ci * @queue: Pointer to &struct data_queue. 13438c2ecf20Sopenharmony_ci * 13448c2ecf20Sopenharmony_ci * This function will start handling all pending frames in the queue. 13458c2ecf20Sopenharmony_ci */ 13468c2ecf20Sopenharmony_civoid rt2x00queue_start_queue(struct data_queue *queue); 13478c2ecf20Sopenharmony_ci 13488c2ecf20Sopenharmony_ci/** 13498c2ecf20Sopenharmony_ci * rt2x00queue_stop_queue - Halt a data queue 13508c2ecf20Sopenharmony_ci * @queue: Pointer to &struct data_queue. 13518c2ecf20Sopenharmony_ci * 13528c2ecf20Sopenharmony_ci * This function will stop all pending frames in the queue. 13538c2ecf20Sopenharmony_ci */ 13548c2ecf20Sopenharmony_civoid rt2x00queue_stop_queue(struct data_queue *queue); 13558c2ecf20Sopenharmony_ci 13568c2ecf20Sopenharmony_ci/** 13578c2ecf20Sopenharmony_ci * rt2x00queue_flush_queue - Flush a data queue 13588c2ecf20Sopenharmony_ci * @queue: Pointer to &struct data_queue. 13598c2ecf20Sopenharmony_ci * @drop: True to drop all pending frames. 13608c2ecf20Sopenharmony_ci * 13618c2ecf20Sopenharmony_ci * This function will flush the queue. After this call 13628c2ecf20Sopenharmony_ci * the queue is guaranteed to be empty. 13638c2ecf20Sopenharmony_ci */ 13648c2ecf20Sopenharmony_civoid rt2x00queue_flush_queue(struct data_queue *queue, bool drop); 13658c2ecf20Sopenharmony_ci 13668c2ecf20Sopenharmony_ci/** 13678c2ecf20Sopenharmony_ci * rt2x00queue_start_queues - Start all data queues 13688c2ecf20Sopenharmony_ci * @rt2x00dev: Pointer to &struct rt2x00_dev. 13698c2ecf20Sopenharmony_ci * 13708c2ecf20Sopenharmony_ci * This function will loop through all available queues to start them 13718c2ecf20Sopenharmony_ci */ 13728c2ecf20Sopenharmony_civoid rt2x00queue_start_queues(struct rt2x00_dev *rt2x00dev); 13738c2ecf20Sopenharmony_ci 13748c2ecf20Sopenharmony_ci/** 13758c2ecf20Sopenharmony_ci * rt2x00queue_stop_queues - Halt all data queues 13768c2ecf20Sopenharmony_ci * @rt2x00dev: Pointer to &struct rt2x00_dev. 13778c2ecf20Sopenharmony_ci * 13788c2ecf20Sopenharmony_ci * This function will loop through all available queues to stop 13798c2ecf20Sopenharmony_ci * any pending frames. 13808c2ecf20Sopenharmony_ci */ 13818c2ecf20Sopenharmony_civoid rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev); 13828c2ecf20Sopenharmony_ci 13838c2ecf20Sopenharmony_ci/** 13848c2ecf20Sopenharmony_ci * rt2x00queue_flush_queues - Flush all data queues 13858c2ecf20Sopenharmony_ci * @rt2x00dev: Pointer to &struct rt2x00_dev. 13868c2ecf20Sopenharmony_ci * @drop: True to drop all pending frames. 13878c2ecf20Sopenharmony_ci * 13888c2ecf20Sopenharmony_ci * This function will loop through all available queues to flush 13898c2ecf20Sopenharmony_ci * any pending frames. 13908c2ecf20Sopenharmony_ci */ 13918c2ecf20Sopenharmony_civoid rt2x00queue_flush_queues(struct rt2x00_dev *rt2x00dev, bool drop); 13928c2ecf20Sopenharmony_ci 13938c2ecf20Sopenharmony_ci/* 13948c2ecf20Sopenharmony_ci * Debugfs handlers. 13958c2ecf20Sopenharmony_ci */ 13968c2ecf20Sopenharmony_ci/** 13978c2ecf20Sopenharmony_ci * rt2x00debug_dump_frame - Dump a frame to userspace through debugfs. 13988c2ecf20Sopenharmony_ci * @rt2x00dev: Pointer to &struct rt2x00_dev. 13998c2ecf20Sopenharmony_ci * @type: The type of frame that is being dumped. 14008c2ecf20Sopenharmony_ci * @entry: The queue entry containing the frame to be dumped. 14018c2ecf20Sopenharmony_ci */ 14028c2ecf20Sopenharmony_ci#ifdef CONFIG_RT2X00_LIB_DEBUGFS 14038c2ecf20Sopenharmony_civoid rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, 14048c2ecf20Sopenharmony_ci enum rt2x00_dump_type type, struct queue_entry *entry); 14058c2ecf20Sopenharmony_ci#else 14068c2ecf20Sopenharmony_cistatic inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, 14078c2ecf20Sopenharmony_ci enum rt2x00_dump_type type, 14088c2ecf20Sopenharmony_ci struct queue_entry *entry) 14098c2ecf20Sopenharmony_ci{ 14108c2ecf20Sopenharmony_ci} 14118c2ecf20Sopenharmony_ci#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 14128c2ecf20Sopenharmony_ci 14138c2ecf20Sopenharmony_ci/* 14148c2ecf20Sopenharmony_ci * Utility functions. 14158c2ecf20Sopenharmony_ci */ 14168c2ecf20Sopenharmony_ciu32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev, 14178c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 14188c2ecf20Sopenharmony_civoid rt2x00lib_set_mac_address(struct rt2x00_dev *rt2x00dev, u8 *eeprom_mac_addr); 14198c2ecf20Sopenharmony_ci 14208c2ecf20Sopenharmony_ci/* 14218c2ecf20Sopenharmony_ci * Interrupt context handlers. 14228c2ecf20Sopenharmony_ci */ 14238c2ecf20Sopenharmony_civoid rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev); 14248c2ecf20Sopenharmony_civoid rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev); 14258c2ecf20Sopenharmony_civoid rt2x00lib_dmastart(struct queue_entry *entry); 14268c2ecf20Sopenharmony_civoid rt2x00lib_dmadone(struct queue_entry *entry); 14278c2ecf20Sopenharmony_civoid rt2x00lib_txdone(struct queue_entry *entry, 14288c2ecf20Sopenharmony_ci struct txdone_entry_desc *txdesc); 14298c2ecf20Sopenharmony_civoid rt2x00lib_txdone_nomatch(struct queue_entry *entry, 14308c2ecf20Sopenharmony_ci struct txdone_entry_desc *txdesc); 14318c2ecf20Sopenharmony_civoid rt2x00lib_txdone_noinfo(struct queue_entry *entry, u32 status); 14328c2ecf20Sopenharmony_civoid rt2x00lib_rxdone(struct queue_entry *entry, gfp_t gfp); 14338c2ecf20Sopenharmony_ci 14348c2ecf20Sopenharmony_ci/* 14358c2ecf20Sopenharmony_ci * mac80211 handlers. 14368c2ecf20Sopenharmony_ci */ 14378c2ecf20Sopenharmony_civoid rt2x00mac_tx(struct ieee80211_hw *hw, 14388c2ecf20Sopenharmony_ci struct ieee80211_tx_control *control, 14398c2ecf20Sopenharmony_ci struct sk_buff *skb); 14408c2ecf20Sopenharmony_ciint rt2x00mac_start(struct ieee80211_hw *hw); 14418c2ecf20Sopenharmony_civoid rt2x00mac_stop(struct ieee80211_hw *hw); 14428c2ecf20Sopenharmony_civoid rt2x00mac_reconfig_complete(struct ieee80211_hw *hw, 14438c2ecf20Sopenharmony_ci enum ieee80211_reconfig_type reconfig_type); 14448c2ecf20Sopenharmony_ciint rt2x00mac_add_interface(struct ieee80211_hw *hw, 14458c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 14468c2ecf20Sopenharmony_civoid rt2x00mac_remove_interface(struct ieee80211_hw *hw, 14478c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 14488c2ecf20Sopenharmony_ciint rt2x00mac_config(struct ieee80211_hw *hw, u32 changed); 14498c2ecf20Sopenharmony_civoid rt2x00mac_configure_filter(struct ieee80211_hw *hw, 14508c2ecf20Sopenharmony_ci unsigned int changed_flags, 14518c2ecf20Sopenharmony_ci unsigned int *total_flags, 14528c2ecf20Sopenharmony_ci u64 multicast); 14538c2ecf20Sopenharmony_ciint rt2x00mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 14548c2ecf20Sopenharmony_ci bool set); 14558c2ecf20Sopenharmony_ci#ifdef CONFIG_RT2X00_LIB_CRYPTO 14568c2ecf20Sopenharmony_ciint rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 14578c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, struct ieee80211_sta *sta, 14588c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key); 14598c2ecf20Sopenharmony_ci#else 14608c2ecf20Sopenharmony_ci#define rt2x00mac_set_key NULL 14618c2ecf20Sopenharmony_ci#endif /* CONFIG_RT2X00_LIB_CRYPTO */ 14628c2ecf20Sopenharmony_civoid rt2x00mac_sw_scan_start(struct ieee80211_hw *hw, 14638c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 14648c2ecf20Sopenharmony_ci const u8 *mac_addr); 14658c2ecf20Sopenharmony_civoid rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw, 14668c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 14678c2ecf20Sopenharmony_ciint rt2x00mac_get_stats(struct ieee80211_hw *hw, 14688c2ecf20Sopenharmony_ci struct ieee80211_low_level_stats *stats); 14698c2ecf20Sopenharmony_civoid rt2x00mac_bss_info_changed(struct ieee80211_hw *hw, 14708c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 14718c2ecf20Sopenharmony_ci struct ieee80211_bss_conf *bss_conf, 14728c2ecf20Sopenharmony_ci u32 changes); 14738c2ecf20Sopenharmony_ciint rt2x00mac_conf_tx(struct ieee80211_hw *hw, 14748c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, u16 queue, 14758c2ecf20Sopenharmony_ci const struct ieee80211_tx_queue_params *params); 14768c2ecf20Sopenharmony_civoid rt2x00mac_rfkill_poll(struct ieee80211_hw *hw); 14778c2ecf20Sopenharmony_civoid rt2x00mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 14788c2ecf20Sopenharmony_ci u32 queues, bool drop); 14798c2ecf20Sopenharmony_ciint rt2x00mac_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant); 14808c2ecf20Sopenharmony_ciint rt2x00mac_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant); 14818c2ecf20Sopenharmony_civoid rt2x00mac_get_ringparam(struct ieee80211_hw *hw, 14828c2ecf20Sopenharmony_ci u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max); 14838c2ecf20Sopenharmony_cibool rt2x00mac_tx_frames_pending(struct ieee80211_hw *hw); 14848c2ecf20Sopenharmony_ci 14858c2ecf20Sopenharmony_ci/* 14868c2ecf20Sopenharmony_ci * Driver allocation handlers. 14878c2ecf20Sopenharmony_ci */ 14888c2ecf20Sopenharmony_ciint rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev); 14898c2ecf20Sopenharmony_civoid rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev); 14908c2ecf20Sopenharmony_ci 14918c2ecf20Sopenharmony_ciint rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev); 14928c2ecf20Sopenharmony_ciint rt2x00lib_resume(struct rt2x00_dev *rt2x00dev); 14938c2ecf20Sopenharmony_ci 14948c2ecf20Sopenharmony_ci#endif /* RT2X00_H */ 1495