📄 b43legacy.h
字号:
/* 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]; /* LO Measurement Data. * Use b43legacy_get_lopair() to get a value. */ struct b43legacy_lopair *_lo_pairs; /* TSSI to dBm table in use */ const s8 *tssi2dbm; /* idle TSSI value */ s8 idle_tssi; /* Target idle TSSI */ int tgt_idle_tssi; /* Current idle TSSI */ int cur_idle_tssi; /* LocalOscillator control values. */ struct b43legacy_txpower_lo_control *lo_control; /* Values from b43legacy_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 b43legacy_phy_{un}lock() */ spinlock_t lock; /* Desired TX power level (in dBm). This is set by the user and * adjusted in b43legacy_phy_xmitpower(). */ u8 power_level; /* Values from b43legacy_calc_loopback_gain() */ u16 loopback_gain[2]; /* TX Power control values. */ /* B/G PHY */ struct { /* Current Radio Attenuation for TXpower recalculation. */ u16 rfatt; /* Current Baseband Attenuation for TXpower recalculation. */ u16 bbatt; /* Current TXpower control value for TXpower recalculation. */ u16 txctl1; u16 txctl2; }; /* A PHY */ struct { u16 txpwr_offset; };#ifdef CONFIG_B43LEGACY_DEBUG bool manual_txpower_control; /* Manual TX-power control enabled? */#endif /* 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 B43legacy_INTERFSTACK_SIZE 26 u32 interfstack[B43legacy_INTERFSTACK_SIZE]; /* 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;};/* Data structures for DMA transmission, per 80211 core. */struct b43legacy_dma { struct b43legacy_dmaring *tx_ring0; struct b43legacy_dmaring *tx_ring1; struct b43legacy_dmaring *tx_ring2; struct b43legacy_dmaring *tx_ring3; struct b43legacy_dmaring *tx_ring4; struct b43legacy_dmaring *tx_ring5; struct b43legacy_dmaring *rx_ring0; struct b43legacy_dmaring *rx_ring3; /* only on core.rev < 5 */};/* Data structures for PIO transmission, per 80211 core. */struct b43legacy_pio { struct b43legacy_pioqueue *queue0; struct b43legacy_pioqueue *queue1; struct b43legacy_pioqueue *queue2; struct b43legacy_pioqueue *queue3;};/* Context information for a noise calculation (Link Quality). */struct b43legacy_noise_calculation { u8 channel_at_start; bool calculation_running; u8 nr_samples; s8 samples[8][4];};struct b43legacy_stats { u8 link_noise; /* Store the last TX/RX times here for updating the leds. */ unsigned long last_tx; unsigned long last_rx;};struct b43legacy_key { void *keyconf; bool enabled; u8 algorithm;};struct b43legacy_wldev;/* Data structure for the WLAN parts (802.11 cores) of the b43legacy chip. */struct b43legacy_wl { /* Pointer to the active wireless device on this chip */ struct b43legacy_wldev *current_dev; /* Pointer to the ieee80211 hardware data structure */ struct ieee80211_hw *hw; spinlock_t irq_lock; /* locks IRQ */ struct mutex mutex; /* locks wireless core state */ spinlock_t leds_lock; /* lock for leds */ /* 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; /* MAC address (can be NULL). */ u8 mac_addr[ETH_ALEN]; /* Current BSSID (can be NULL). */ 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]; /* 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 b43legacy_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 { B43legacy_STAT_UNINIT = 0, /* Uninitialized. */ B43legacy_STAT_INITIALIZED = 1, /* Initialized, not yet started. */ B43legacy_STAT_STARTED = 2, /* Up and running. */};#define b43legacy_status(wldev) atomic_read(&(wldev)->__init_status)#define b43legacy_set_status(wldev, stat) do { \ atomic_set(&(wldev)->__init_status, (stat)); \ smp_wmb(); \ } while (0)/* *** --- HOW LOCKING WORKS IN B43legacy --- *** * * 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 b43legacy_wldev { struct ssb_device *dev; struct b43legacy_wl *wl; /* The device initialization status. * Use b43legacy_status() to query. */ atomic_t __init_status; /* Saved init status for handling suspend. */ int suspend_init_status; bool __using_pio; /* Using pio rather than dma. */ bool bad_frames_preempt;/* Use "Bad Frames Preemption". */ bool reg124_set_0x4; /* Variable to keep track of IRQ. */ bool short_preamble; /* TRUE if using short preamble. */ bool short_slot; /* TRUE if using short slot timing. */ bool radio_hw_enable; /* State of radio hardware enable bit. */ /* PHY/Radio device. */ struct b43legacy_phy phy; union { /* DMA engines. */ struct b43legacy_dma dma; /* PIO engines. */ struct b43legacy_pio pio; }; /* Various statistics about the physical device. */ struct b43legacy_stats stats;#define B43legacy_NR_LEDS 4 struct b43legacy_led leds[B43legacy_NR_LEDS]; /* 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 b43legacy_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 b43legacy_key key[58]; /* Cached beacon template while uploading the template. */ struct sk_buff *cached_beacon; /* Firmware data */ struct b43legacy_firmware fw; /* Devicelist in struct b43legacy_wl (all 802.11 cores) */ struct list_head list; /* Debugging stuff follows. */#ifdef CONFIG_B43LEGACY_DEBUG struct b43legacy_dfsentry *dfsentry;#endif};static inlinestruct b43legacy_wl *hw_to_b43legacy_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_B43LEGACY_DMA) && defined(CONFIG_B43LEGACY_PIO)static inlineint b43legacy_using_pio(struct b43legacy_wldev *dev){ return dev->__using_pio;}#elif defined(CONFIG_B43LEGACY_DMA)static inlineint b43legacy_using_pio(struct b43legacy_wldev *dev){ return 0;}#elif defined(CONFIG_B43LEGACY_PIO)static inlineint b43legacy_using_pio(struct b43legacy_wldev *dev){ return 1;}#else# error "Using neither DMA nor PIO? Confused..."#endifstatic inlinestruct b43legacy_wldev *dev_to_b43legacy_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 inlineint b43legacy_is_mode(struct b43legacy_wl *wl, int type){ return (wl->operating && wl->if_type == type);}static inlinebool is_bcm_board_vendor(struct b43legacy_wldev *dev){ return (dev->dev->bus->boardinfo.vendor == PCI_VENDOR_ID_BROADCOM);}static inlineu16 b43legacy_read16(struct b43legacy_wldev *dev, u16 offset){ return ssb_read16(dev->dev, offset);}static inlinevoid b43legacy_write16(struct b43legacy_wldev *dev, u16 offset, u16 value){ ssb_write16(dev->dev, offset, value);}static inlineu32 b43legacy_read32(struct b43legacy_wldev *dev, u16 offset){ return ssb_read32(dev->dev, offset);}static inlinevoid b43legacy_write32(struct b43legacy_wldev *dev, u16 offset, u32 value){ ssb_write32(dev->dev, offset, value);}static inlinestruct b43legacy_lopair *b43legacy_get_lopair(struct b43legacy_phy *phy, u16 radio_attenuation, u16 baseband_attenuation){ return phy->_lo_pairs + (radio_attenuation + 14 * (baseband_attenuation / 2));}/* Message printing */void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...) __attribute__((format(printf, 2, 3)));void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...) __attribute__((format(printf, 2, 3)));void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...) __attribute__((format(printf, 2, 3)));#if B43legacy_DEBUGvoid b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...) __attribute__((format(printf, 2, 3)));#else /* DEBUG */# define b43legacydbg(wl, fmt...) do { /* nothing */ } while (0)#endif /* DEBUG *//** 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; \ })/* Macros for printing a value in Q5.2 format */#define Q52_FMT "%u.%u"#define Q52_ARG(q52) ((q52) / 4), (((q52) & 3) * 100 / 4)#endif /* B43legacy_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -