📄 bcm43xx.h
字号:
u8 et1macaddr[6]; u8 et0phyaddr:5; u8 et1phyaddr:5; u8 boardrev; u8 locale:4; u8 antennas_aphy:2; u8 antennas_bgphy:2; u16 pa0b0; u16 pa0b1; u16 pa0b2; u8 wl0gpio0; u8 wl0gpio1; u8 wl0gpio2; u8 wl0gpio3; u8 maxpower_aphy; u8 maxpower_bgphy; u16 pa1b0; u16 pa1b1; u16 pa1b2; u8 idle_tssi_tgt_aphy; u8 idle_tssi_tgt_bgphy; u16 boardflags; u16 antennagain_aphy; u16 antennagain_bgphy;};/* Value pair to measure the LocalOscillator. */struct bcm43xx_lopair { s8 low; s8 high; u8 used:1;};#define BCM43xx_LO_COUNT (14*4)struct bcm43xx_phyinfo { /* Hardware Data */ u8 analog; u8 type; u8 rev; u16 antenna_diversity; u16 savedpctlreg; u16 minlowsig[2]; u16 minlowsigpos[2]; u8 connected:1, calibrated:1, is_locked:1, /* used in bcm43xx_phy_{un}lock() */ dyn_tssi_tbl:1; /* used in bcm43xx_phy_init_tssi2dbm_table() */ /* LO Measurement Data. * Use bcm43xx_get_lopair() to get a value. */ struct bcm43xx_lopair *_lo_pairs; /* TSSI to dBm table in use */ const s8 *tssi2dbm; /* idle TSSI value */ s8 idle_tssi; /* Values from bcm43xx_calc_loopback_gain() */ u16 loopback_gain[2]; /* PHY lock for core.rev < 3 * This lock is only used by bcm43xx_phy_{un}lock() */ spinlock_t lock; /* Firmware. */ const struct firmware *ucode; const struct firmware *pcm; const struct firmware *initvals0; const struct firmware *initvals1;};struct bcm43xx_radioinfo { u16 manufact; u16 version; u8 revision; /* Desired TX power in dBm Q5.2 */ u16 txpower_desired; /* TX Power control values. */ union { /* B/G PHY */ struct { u16 baseband_atten; u16 radio_atten; u16 txctl1; u16 txctl2; }; /* A PHY */ struct { u16 txpwr_offset; }; }; /* 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 BCM43xx_INTERFSTACK_SIZE 26 u32 interfstack[BCM43xx_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; u8 initial_channel; u16 lofcal; u16 initval; u8 enabled:1; /* ACI (adjacent channel interference) flags. */ u8 aci_enable:1, aci_wlan_automatic:1, aci_hw_rssi:1;};/* Data structures for DMA transmission, per 80211 core. */struct bcm43xx_dma { struct bcm43xx_dmaring *tx_ring0; struct bcm43xx_dmaring *tx_ring1; struct bcm43xx_dmaring *tx_ring2; struct bcm43xx_dmaring *tx_ring3; struct bcm43xx_dmaring *tx_ring4; struct bcm43xx_dmaring *tx_ring5; struct bcm43xx_dmaring *rx_ring0; struct bcm43xx_dmaring *rx_ring3; /* only available on core.rev < 5 */};/* Data structures for PIO transmission, per 80211 core. */struct bcm43xx_pio { struct bcm43xx_pioqueue *queue0; struct bcm43xx_pioqueue *queue1; struct bcm43xx_pioqueue *queue2; struct bcm43xx_pioqueue *queue3;};#define BCM43xx_MAX_80211_CORES 2#ifdef CONFIG_BCM947XX#define core_offset(bcm) (bcm)->current_core_offset#else#define core_offset(bcm) 0#endif/* Generic information about a core. */struct bcm43xx_coreinfo { u8 available:1, enabled:1, initialized:1; /** core_rev revision number */ u8 rev; /** Index number for _switch_core() */ u8 index; /** core_id ID number */ u16 id; /** Core-specific data. */ void *priv;};/* Additional information for each 80211 core. */struct bcm43xx_coreinfo_80211 { /* PHY device. */ struct bcm43xx_phyinfo phy; /* Radio device. */ struct bcm43xx_radioinfo radio; union { /* DMA context. */ struct bcm43xx_dma dma; /* PIO context. */ struct bcm43xx_pio pio; };};/* Context information for a noise calculation (Link Quality). */struct bcm43xx_noise_calculation { struct bcm43xx_coreinfo *core_at_start; u8 channel_at_start; u8 calculation_running:1; u8 nr_samples; s8 samples[8][4];};struct bcm43xx_stats { u8 noise; struct iw_statistics wstats; /* Store the last TX/RX times here for updating the leds. */ unsigned long last_tx; unsigned long last_rx;};struct bcm43xx_key { u8 enabled:1; u8 algorithm;};/* Driver initialization status. */enum { BCM43xx_STAT_UNINIT, /* Uninitialized. */ BCM43xx_STAT_INITIALIZING, /* init_board() in progress. */ BCM43xx_STAT_INITIALIZED, /* Fully operational. */ BCM43xx_STAT_SHUTTINGDOWN, /* free_board() in progress. */ BCM43xx_STAT_RESTARTING, /* controller_restart() called. */};#define bcm43xx_status(bcm) atomic_read(&(bcm)->init_status)#define bcm43xx_set_status(bcm, stat) do { \ atomic_set(&(bcm)->init_status, (stat)); \ smp_wmb(); \ } while (0)/* *** THEORY OF LOCKING *** * * We have two different locks in the bcm43xx driver. * => bcm->mutex: General sleeping mutex. Protects struct bcm43xx_private * and the device registers. This mutex does _not_ protect * against concurrency from the IRQ handler. * => bcm->irq_lock: IRQ spinlock. Protects against IRQ handler concurrency. * * Please note that, if you only take the irq_lock, you are not protected * against concurrency from the periodic work handlers. * Most times you want to take _both_ locks. */struct bcm43xx_private { struct ieee80211_device *ieee; struct ieee80211softmac_device *softmac; struct net_device *net_dev; struct pci_dev *pci_dev; unsigned int irq; void __iomem *mmio_addr; spinlock_t irq_lock; struct mutex mutex; /* Driver initialization status BCM43xx_STAT_*** */ atomic_t init_status; u16 was_initialized:1, /* for PCI suspend/resume. */ __using_pio:1, /* Internal, use bcm43xx_using_pio(). */ bad_frames_preempt:1, /* Use "Bad Frames Preemption" (default off) */ reg124_set_0x4:1, /* Some variable to keep track of IRQ stuff. */ short_preamble:1, /* TRUE, if short preamble is enabled. */ firmware_norelease:1, /* Do not release the firmware. Used on suspend. */ radio_hw_enable:1; /* TRUE if radio is hardware enabled */ struct bcm43xx_stats stats; /* Bus type we are connected to. * This is currently always BCM43xx_BUSTYPE_PCI */ u8 bustype; u64 dma_mask; u16 board_vendor; u16 board_type; u16 board_revision; u16 chip_id; u8 chip_rev; u8 chip_package; struct bcm43xx_sprominfo sprom;#define BCM43xx_NR_LEDS 4 struct bcm43xx_led leds[BCM43xx_NR_LEDS]; spinlock_t leds_lock; /* The currently active core. */ struct bcm43xx_coreinfo *current_core;#ifdef CONFIG_BCM947XX /** current core memory offset */ u32 current_core_offset;#endif struct bcm43xx_coreinfo *active_80211_core; /* coreinfo structs for all possible cores follow. * Note that a core might not exist. * So check the coreinfo flags before using it. */ struct bcm43xx_coreinfo core_chipcommon; struct bcm43xx_coreinfo core_pci; struct bcm43xx_coreinfo core_80211[ BCM43xx_MAX_80211_CORES ]; /* Additional information, specific to the 80211 cores. */ struct bcm43xx_coreinfo_80211 core_80211_ext[ BCM43xx_MAX_80211_CORES ]; /* Number of available 80211 cores. */ int nr_80211_available; u32 chipcommon_capabilities; /* 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 bcm43xx_noise_calculation noisecalc; /* if > 0 MAC is suspended. if == 0 MAC is enabled. */ int mac_suspended; /* Threshold values. */ //TODO: The RTS thr has to be _used_. Currently, it is only set via WX. u32 rts_threshold; /* 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; /* Informational stuff. */ char nick[IW_ESSID_MAX_SIZE + 1]; /* encryption/decryption */ u16 security_offset; struct bcm43xx_key key[54]; u8 default_key_idx; /* Random Number Generator. */ struct hwrng rng; char rng_name[20 + 1]; /* Debugging stuff follows. */#ifdef CONFIG_BCM43XX_DEBUG struct bcm43xx_dfsentry *dfsentry;#endif};static inlinestruct bcm43xx_private * bcm43xx_priv(struct net_device *dev){ return ieee80211softmac_priv(dev);}struct device;static inlinestruct bcm43xx_private * dev_to_bcm(struct device *dev){ struct net_device *net_dev; struct bcm43xx_private *bcm; net_dev = dev_get_drvdata(dev); bcm = bcm43xx_priv(net_dev); return bcm;}/* Helper function, which returns a boolean. * TRUE, if PIO is used; FALSE, if DMA is used. */#if defined(CONFIG_BCM43XX_DMA) && defined(CONFIG_BCM43XX_PIO)static inlineint bcm43xx_using_pio(struct bcm43xx_private *bcm){ return bcm->__using_pio;}#elif defined(CONFIG_BCM43XX_DMA)static inlineint bcm43xx_using_pio(struct bcm43xx_private *bcm){ return 0;}#elif defined(CONFIG_BCM43XX_PIO)static inlineint bcm43xx_using_pio(struct bcm43xx_private *bcm){ return 1;}#else# error "Using neither DMA nor PIO? Confused..."#endif/* Helper functions to access data structures private to the 80211 cores. * Note that we _must_ have an 80211 core mapped when calling * any of these functions. */static inlinestruct bcm43xx_coreinfo_80211 *bcm43xx_current_80211_priv(struct bcm43xx_private *bcm){ assert(bcm->current_core->id == BCM43xx_COREID_80211); return bcm->current_core->priv;}static inlinestruct bcm43xx_pio * bcm43xx_current_pio(struct bcm43xx_private *bcm){ assert(bcm43xx_using_pio(bcm)); return &(bcm43xx_current_80211_priv(bcm)->pio);}static inlinestruct bcm43xx_dma * bcm43xx_current_dma(struct bcm43xx_private *bcm){ assert(!bcm43xx_using_pio(bcm)); return &(bcm43xx_current_80211_priv(bcm)->dma);}static inlinestruct bcm43xx_phyinfo * bcm43xx_current_phy(struct bcm43xx_private *bcm){ return &(bcm43xx_current_80211_priv(bcm)->phy);}static inlinestruct bcm43xx_radioinfo * bcm43xx_current_radio(struct bcm43xx_private *bcm){ return &(bcm43xx_current_80211_priv(bcm)->radio);}static inlinestruct bcm43xx_lopair * bcm43xx_get_lopair(struct bcm43xx_phyinfo *phy, u16 radio_attenuation, u16 baseband_attenuation){ return phy->_lo_pairs + (radio_attenuation + 14 * (baseband_attenuation / 2));}static inlineu16 bcm43xx_read16(struct bcm43xx_private *bcm, u16 offset){ return ioread16(bcm->mmio_addr + core_offset(bcm) + offset);}static inlinevoid bcm43xx_write16(struct bcm43xx_private *bcm, u16 offset, u16 value){ iowrite16(value, bcm->mmio_addr + core_offset(bcm) + offset);}static inlineu32 bcm43xx_read32(struct bcm43xx_private *bcm, u16 offset){ return ioread32(bcm->mmio_addr + core_offset(bcm) + offset);}static inlinevoid bcm43xx_write32(struct bcm43xx_private *bcm, u16 offset, u32 value){ iowrite32(value, bcm->mmio_addr + core_offset(bcm) + offset);}static inlineint bcm43xx_pci_read_config16(struct bcm43xx_private *bcm, int offset, u16 *value){ return pci_read_config_word(bcm->pci_dev, offset, value);}static inlineint bcm43xx_pci_read_config32(struct bcm43xx_private *bcm, int offset, u32 *value){ return pci_read_config_dword(bcm->pci_dev, offset, value);}static inlineint bcm43xx_pci_write_config16(struct bcm43xx_private *bcm, int offset, u16 value){ return pci_write_config_word(bcm->pci_dev, offset, value);}static inlineint bcm43xx_pci_write_config32(struct bcm43xx_private *bcm, int offset, u32 value){ return pci_write_config_dword(bcm->pci_dev, offset, value);}/** 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; \ })/** Helpers to print MAC addresses. */#define BCM43xx_MACFMT "%02x:%02x:%02x:%02x:%02x:%02x"#define BCM43xx_MACARG(x) ((u8*)(x))[0], ((u8*)(x))[1], \ ((u8*)(x))[2], ((u8*)(x))[3], \ ((u8*)(x))[4], ((u8*)(x))[5]#endif /* BCM43xx_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -