Diversity using an external antenna switch
The following discussion is relevant for pre-11n (non-MIMO) chips. Chips after the AR5416 implement a different set of diversity behaviour.
The pre-11n (well, pre-MIMO) devices use an external antenna switch to implement TX/RX control and (for earlier parts) external RX attenuation stages. As part of this, there is a set of switch table entries which control a set of output control pins. These pins are card specific; the NIC EEPROM contents include the antenna switch table state.
To control diversity, there's two sets of switch table entries - one for antenna switch table 1 and a second for antenna switch table 2. The format of the switch table registers is chip specific and the bits themselves are card specific (ie, how the antenna switch and attenuation stages are wired up.)
What about fast diversity?
When receiving, the hardware will default to receiving on the antenna in DEFANT.
If configured and if there's enough time to try the alternate antenna, it will. This is known as "fast diversity."
"Enough time" has to do with the length of the 802.11 frame pre-amble and how long the baseband takes to accurately estimate the signal size. This is configured by the AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV bit in AR_PHY_CCK_DETECT - if it's 1, then RX fast diversity is enabled.
There's a handful of parameters which control the signal size thresholds for determining whether to use the default or the other antenna configuration. There's also an enable/disable bit for whether to do antenna diversity if the signal is weak.
When is it used?
There's a few different places where the antenna selection and diversity logic kicks in:
- There's a default antenna configuration used when listening for incoming frames ("DEFANT");
- Either use the default antenna when transmitting, or use the transmit antenna in the key cache;
- Whether to transmit RTS frames on the default antenna ("DEFANT") or on the antenna selected by each TX descriptor.
There are 4 bits in the TX descriptor (the AntModeXmit field) which controls antenna selection. This controls either normal antenna diversity (by selecting antenna 1 or antenna 2) or, if sectored antenna configuration is enabled, it writes those bits directly to the external antenna control pins.
If configured, the hardware will update the DEFANT field (default antenna) with the last received antenna selection.
If the received frame MAC address matches a keycache entry, the hardware will then store receive antenna in the keycache. It can then optionally used this when transmitting a frame to the same destination.
All of this behaviour is configurable via various bits in the MAC.