bcm43xx.h

来自「LINUX 2.6.17.4的源码」· C头文件 代码 · 共 938 行 · 第 1/2 页

H
938
字号
	s8 high;	u8 used:1;};#define BCM43xx_LO_COUNT	(14*4)struct bcm43xx_phyinfo {	/* Hardware Data */	u8 version;	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;};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 *rx_ring0;	struct bcm43xx_dmaring *rx_ring1; /* 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_id ID number */	u16 id;	/** core_rev revision number */	u8 rev;	/** Index number for _switch_core() */	u8 index;};/* 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 link_quality;	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;};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;	unsigned int mmio_len;	/* Do not use the lock directly. Use the bcm43xx_lock* helper	 * functions, to be MMIO-safe. */	spinlock_t _lock;	/* Driver status flags. */	u32 initialized:1,		/* init_board() succeed */	    was_initialized:1,		/* for PCI suspend/resume. */	    shutting_down:1,		/* free_board() in progress */	    __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. */	    powersaving:1,		/* TRUE if we are in PowerSaving mode. FALSE otherwise. */	    short_preamble:1,		/* TRUE, if short preamble is enabled. */	    firmware_norelease:1;	/* Do not release the firmware. Used on suspend. */	struct bcm43xx_stats stats;	/* Bus type we are connected to.	 * This is currently always BCM43xx_BUSTYPE_PCI	 */	u8 bustype;	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];	/* 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 ];	/* Index of the current 80211 core. If current_core is not	 * an 80211 core, this is -1.	 */	int current_80211_core_idx;	/* Number of available 80211 cores. */	int nr_80211_available;	u32 chipcommon_capabilities;	/* Reason code of the last interrupt. */	u32 irq_reason;	u32 dma_reason[4];	/* saved irq enable/disable state bitfield. */	u32 irq_savedstate;	/* Link Quality calculation context. */	struct bcm43xx_noise_calculation noisecalc;	/* 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 timer_list periodic_tasks;	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;	/* Firmware. */	const struct firmware *ucode;	const struct firmware *pcm;	const struct firmware *initvals0;	const struct firmware *initvals1;	/* Debugging stuff follows. */#ifdef CONFIG_BCM43XX_DEBUG	struct bcm43xx_dfsentry *dfsentry;#endif};/* bcm43xx_(un)lock() protect struct bcm43xx_private. * Note that _NO_ MMIO writes are allowed. If you want to * write to the device through MMIO in the critical section, use * the *_mmio lock functions. * MMIO read-access is allowed, though. */#define bcm43xx_lock(bcm, flags)	spin_lock_irqsave(&(bcm)->_lock, flags)#define bcm43xx_unlock(bcm, flags)	spin_unlock_irqrestore(&(bcm)->_lock, flags)/* bcm43xx_(un)lock_mmio() protect struct bcm43xx_private and MMIO. * MMIO write-access to the device is allowed. * All MMIO writes are flushed on unlock, so it is guaranteed to not * interfere with other threads writing MMIO registers. */#define bcm43xx_lock_mmio(bcm, flags)	bcm43xx_lock(bcm, flags)#define bcm43xx_unlock_mmio(bcm, flags)	do { mmiowb(); bcm43xx_unlock(bcm, flags); } while (0)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_pio * bcm43xx_current_pio(struct bcm43xx_private *bcm){	assert(bcm43xx_using_pio(bcm));	assert(bcm->current_80211_core_idx >= 0);	assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].pio);}static inlinestruct bcm43xx_dma * bcm43xx_current_dma(struct bcm43xx_private *bcm){	assert(!bcm43xx_using_pio(bcm));	assert(bcm->current_80211_core_idx >= 0);	assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].dma);}static inlinestruct bcm43xx_phyinfo * bcm43xx_current_phy(struct bcm43xx_private *bcm){	assert(bcm->current_80211_core_idx >= 0);	assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].phy);}static inlinestruct bcm43xx_radioinfo * bcm43xx_current_radio(struct bcm43xx_private *bcm){	assert(bcm->current_80211_core_idx >= 0);	assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].radio);}/* Are we running in init_board() context? */static inlineint bcm43xx_is_initializing(struct bcm43xx_private *bcm){	if (bcm->initialized)		return 0;	if (bcm->shutting_down)		return 0;	return 1;}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 + =
减小字号Ctrl + -
显示快捷键?