📄 b43.h
字号:
__be16 offset_size; union { __be16 d16; __be32 d32; } data __attribute__((__packed__));} __attribute__((__packed__));#define B43_PHYMODE(phytype) (1 << (phytype))#define B43_PHYMODE_A B43_PHYMODE(B43_PHYTYPE_A)#define B43_PHYMODE_B B43_PHYMODE(B43_PHYTYPE_B)#define B43_PHYMODE_G B43_PHYMODE(B43_PHYTYPE_G)struct b43_phy { /* Possible PHYMODEs on this PHY */ u8 possible_phymodes; /* GMODE bit enabled? */ bool gmode; /* Possible ieee80211 subsystem hwmodes for this PHY. * Which mode is selected, depends on thr GMODE enabled bit */#define B43_MAX_PHYHWMODES 2 struct ieee80211_hw_mode hwmodes[B43_MAX_PHYHWMODES]; /* Analog Type */ u8 analog; /* B43_PHYTYPE_ */ u8 type; /* PHY revision number. */ u8 rev; /* Radio versioning */ u16 radio_manuf; /* Radio manufacturer */ u16 radio_ver; /* Radio version */ u8 radio_rev; /* Radio revision */ bool locked; /* Only used in b43_phy_{un}lock() */ bool dyn_tssi_tbl; /* tssi2dbm is kmalloc()ed. */ /* ACI (adjacent channel interference) flags. */ bool aci_enable; bool aci_wlan_automatic; bool aci_hw_rssi; /* Radio switched on/off */ bool radio_on; struct { /* Values saved when turning the radio off. * They are needed when turning it on again. */ bool valid; u16 rfover; u16 rfoverval; } radio_off_context; u16 minlowsig[2]; u16 minlowsigpos[2]; /* TSSI to dBm table in use */ const s8 *tssi2dbm; /* Target idle TSSI */ int tgt_idle_tssi; /* Current idle TSSI */ int cur_idle_tssi; /* LocalOscillator control values. */ struct b43_txpower_lo_control *lo_control; /* Values from b43_calc_loopback_gain() */ s16 max_lb_gain; /* Maximum Loopback gain in hdB */ s16 trsw_rx_gain; /* TRSW RX gain in hdB */ s16 lna_lod_gain; /* LNA lod */ s16 lna_gain; /* LNA */ s16 pga_gain; /* PGA */ /* PHY lock for core.rev < 3 * This lock is only used by b43_phy_{un}lock() */ spinlock_t lock; /* Desired TX power level (in dBm). * This is set by the user and adjusted in b43_phy_xmitpower(). */ u8 power_level; /* A-PHY TX Power control value. */ u16 txpwr_offset; /* Current TX power level attenuation control values */ struct b43_bbatt bbatt; struct b43_rfatt rfatt; u8 tx_control; /* B43_TXCTL_XXX */#ifdef CONFIG_B43_DEBUG bool manual_txpower_control; /* Manual TX-power control enabled? */#endif /* Hardware Power Control enabled? */ bool hardware_power_control; /* Current Interference Mitigation mode */ int interfmode; /* Stack of saved values from the Interference Mitigation code. * Each value in the stack is layed out as follows: * bit 0-11: offset * bit 12-15: register ID * bit 16-32: value * register ID is: 0x1 PHY, 0x2 Radio, 0x3 ILT */#define B43_INTERFSTACK_SIZE 26 u32 interfstack[B43_INTERFSTACK_SIZE]; //FIXME: use a data structure /* Saved values from the NRSSI Slope calculation */ s16 nrssi[2]; s32 nrssislope; /* In memory nrssi lookup table. */ s8 nrssi_lt[64]; /* current channel */ u8 channel; u16 lofcal; u16 initval; //FIXME rename?};/* Data structures for DMA transmission, per 80211 core. */struct b43_dma { struct b43_dmaring *tx_ring0; struct b43_dmaring *tx_ring1; struct b43_dmaring *tx_ring2; struct b43_dmaring *tx_ring3; struct b43_dmaring *tx_ring4; struct b43_dmaring *tx_ring5; struct b43_dmaring *rx_ring0; struct b43_dmaring *rx_ring3; /* only available on core.rev < 5 */};/* Data structures for PIO transmission, per 80211 core. */struct b43_pio { struct b43_pioqueue *queue0; struct b43_pioqueue *queue1; struct b43_pioqueue *queue2; struct b43_pioqueue *queue3;};/* Context information for a noise calculation (Link Quality). */struct b43_noise_calculation { u8 channel_at_start; bool calculation_running; u8 nr_samples; s8 samples[8][4];};struct b43_stats { u8 link_noise; /* Store the last TX/RX times here for updating the leds. */ unsigned long last_tx; unsigned long last_rx;};struct b43_key { /* If keyconf is NULL, this key is disabled. * keyconf is a cookie. Don't derefenrence it outside of the set_key * path, because b43 doesn't own it. */ struct ieee80211_key_conf *keyconf; u8 algorithm;};struct b43_wldev;/* Data structure for the WLAN parts (802.11 cores) of the b43 chip. */struct b43_wl { /* Pointer to the active wireless device on this chip */ struct b43_wldev *current_dev; /* Pointer to the ieee80211 hardware data structure */ struct ieee80211_hw *hw; spinlock_t irq_lock; struct mutex mutex; spinlock_t leds_lock; /* We can only have one operating interface (802.11 core) * at a time. General information about this interface follows. */ /* Opaque ID of the operating interface from the ieee80211 * subsystem. Do not modify. */ int if_id; /* The MAC address of the operating interface. */ u8 mac_addr[ETH_ALEN]; /* Current BSSID */ u8 bssid[ETH_ALEN]; /* Interface type. (IEEE80211_IF_TYPE_XXX) */ int if_type; /* Is the card operating in AP, STA or IBSS mode? */ bool operating; /* filter flags */ unsigned int filter_flags; /* Stats about the wireless interface */ struct ieee80211_low_level_stats ieee_stats; struct hwrng rng; u8 rng_initialized; char rng_name[30 + 1]; /* The RF-kill button */ struct b43_rfkill rfkill; /* List of all wireless devices on this chip */ struct list_head devlist; u8 nr_devs;};/* Pointers to the firmware data and meta information about it. */struct b43_firmware { /* Microcode */ const struct firmware *ucode; /* PCM code */ const struct firmware *pcm; /* Initial MMIO values for the firmware */ const struct firmware *initvals; /* Initial MMIO values for the firmware, band-specific */ const struct firmware *initvals_band; /* Firmware revision */ u16 rev; /* Firmware patchlevel */ u16 patch;};/* Device (802.11 core) initialization status. */enum { B43_STAT_UNINIT = 0, /* Uninitialized. */ B43_STAT_INITIALIZED = 1, /* Initialized, but not started, yet. */ B43_STAT_STARTED = 2, /* Up and running. */};#define b43_status(wldev) atomic_read(&(wldev)->__init_status)#define b43_set_status(wldev, stat) do { \ atomic_set(&(wldev)->__init_status, (stat)); \ smp_wmb(); \ } while (0)/* XXX--- HOW LOCKING WORKS IN B43 ---XXX * * You should always acquire both, wl->mutex and wl->irq_lock unless: * - You don't need to acquire wl->irq_lock, if the interface is stopped. * - You don't need to acquire wl->mutex in the IRQ handler, IRQ tasklet * and packet TX path (and _ONLY_ there.) *//* Data structure for one wireless device (802.11 core) */struct b43_wldev { struct ssb_device *dev; struct b43_wl *wl; /* The device initialization status. * Use b43_status() to query. */ atomic_t __init_status; /* Saved init status for handling suspend. */ int suspend_init_status; bool __using_pio; /* Internal, use b43_using_pio(). */ bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */ bool reg124_set_0x4; /* Some variable to keep track of IRQ stuff. */ bool short_preamble; /* TRUE, if short preamble is enabled. */ bool short_slot; /* TRUE, if short slot timing is enabled. */ bool radio_hw_enable; /* saved state of radio hardware enabled state */ /* PHY/Radio device. */ struct b43_phy phy; union { /* DMA engines. */ struct b43_dma dma; /* PIO engines. */ struct b43_pio pio; }; /* Various statistics about the physical device. */ struct b43_stats stats; /* The device LEDs. */ struct b43_led led_tx; struct b43_led led_rx; struct b43_led led_assoc; struct b43_led led_radio; /* Reason code of the last interrupt. */ u32 irq_reason; u32 dma_reason[6]; /* saved irq enable/disable state bitfield. */ u32 irq_savedstate; /* Link Quality calculation context. */ struct b43_noise_calculation noisecalc; /* if > 0 MAC is suspended. if == 0 MAC is enabled. */ int mac_suspended; /* Interrupt Service Routine tasklet (bottom-half) */ struct tasklet_struct isr_tasklet; /* Periodic tasks */ struct delayed_work periodic_work; unsigned int periodic_state; struct work_struct restart_work; /* encryption/decryption */ u16 ktp; /* Key table pointer */ u8 max_nr_keys; struct b43_key key[58]; /* Cached beacon template while uploading the template. */ struct sk_buff *cached_beacon; /* Firmware data */ struct b43_firmware fw; /* Devicelist in struct b43_wl (all 802.11 cores) */ struct list_head list; /* Debugging stuff follows. */#ifdef CONFIG_B43_DEBUG struct b43_dfsentry *dfsentry;#endif};static inline struct b43_wl *hw_to_b43_wl(struct ieee80211_hw *hw){ return hw->priv;}/* Helper function, which returns a boolean. * TRUE, if PIO is used; FALSE, if DMA is used. */#if defined(CONFIG_B43_DMA) && defined(CONFIG_B43_PIO)static inline int b43_using_pio(struct b43_wldev *dev){ return dev->__using_pio;}#elif defined(CONFIG_B43_DMA)static inline int b43_using_pio(struct b43_wldev *dev){ return 0;}#elif defined(CONFIG_B43_PIO)static inline int b43_using_pio(struct b43_wldev *dev){ return 1;}#else# error "Using neither DMA nor PIO? Confused..."#endifstatic inline struct b43_wldev *dev_to_b43_wldev(struct device *dev){ struct ssb_device *ssb_dev = dev_to_ssb_dev(dev); return ssb_get_drvdata(ssb_dev);}/* Is the device operating in a specified mode (IEEE80211_IF_TYPE_XXX). */static inline int b43_is_mode(struct b43_wl *wl, int type){ return (wl->operating && wl->if_type == type);}static inline u16 b43_read16(struct b43_wldev *dev, u16 offset){ return ssb_read16(dev->dev, offset);}static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value){ ssb_write16(dev->dev, offset, value);}static inline u32 b43_read32(struct b43_wldev *dev, u16 offset){ return ssb_read32(dev->dev, offset);}static inline void b43_write32(struct b43_wldev *dev, u16 offset, u32 value){ ssb_write32(dev->dev, offset, value);}/* Message printing */void b43info(struct b43_wl *wl, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));void b43err(struct b43_wl *wl, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));void b43warn(struct b43_wl *wl, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));#if B43_DEBUGvoid b43dbg(struct b43_wl *wl, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));#else /* DEBUG */# define b43dbg(wl, fmt...) do { /* nothing */ } while (0)#endif /* DEBUG *//* A WARN_ON variant that vanishes when b43 debugging is disabled. * This _also_ evaluates the arg with debugging disabled. */#if B43_DEBUG# define B43_WARN_ON(x) WARN_ON(x)#elsestatic inline bool __b43_warn_on_dummy(bool x) { return x; }# define B43_WARN_ON(x) __b43_warn_on_dummy(unlikely(!!(x)))#endif/** Limit a value between two limits */#ifdef limit_value# undef limit_value#endif#define limit_value(value, min, max) \ ({ \ typeof(value) __value = (value); \ typeof(value) __min = (min); \ typeof(value) __max = (max); \ if (__value < __min) \ __value = __min; \ else if (__value > __max) \ __value = __max; \ __value; \ })/* Convert an integer to a Q5.2 value */#define INT_TO_Q52(i) ((i) << 2)/* Convert a Q5.2 value to an integer (precision loss!) */#define Q52_TO_INT(q52) ((q52) >> 2)/* Macros for printing a value in Q5.2 format */#define Q52_FMT "%u.%u"#define Q52_ARG(q52) Q52_TO_INT(q52), ((((q52) & 0x3) * 100) / 4)#endif /* B43_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -