iPXE
Data Structures | Defines | Enumerations | Functions
ath.h File Reference
#include <unistd.h>
#include <ipxe/net80211.h>

Go to the source code of this file.

Data Structures

struct  ath_ani
struct  ath_cycle_counters
struct  reg_dmn_pair_mapping
struct  ath_regulatory
struct  ath_keyval
struct  ath_ops
 struct ath_ops - Register read/write operations More...
struct  ath_common

Defines

#define DIV_ROUND_UP(n, d)   (((n) + (d) - 1) / (d))
#define BITS_PER_BYTE   8
#define BITS_TO_LONGS(nr)   DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
#define BIT(nr)   (1UL << (nr))
#define min(x, y)
#define max(x, y)
#define abs(x)
#define ___constant_swab16(x)
#define ___constant_swab32(x)
#define __swab16(x)   ___constant_swab16(x)
#define __swab32(x)   ___constant_swab32(x)
#define swab16   __swab16
#define swab32   __swab32
#define ATH_KEYMAX   128 /* max key cache size we handle */

Enumerations

enum  ath_device_state { ATH_HW_UNAVAILABLE, ATH_HW_INITIALIZED }
enum  ath_bus_type { ATH_PCI, ATH_AHB, ATH_USB }
enum  ath_crypt_caps { ATH_CRYPT_CAP_CIPHER_AESCCM = BIT(0), ATH_CRYPT_CAP_MIC_COMBINED = BIT(1) }
enum  ath_cipher {
  ATH_CIPHER_WEP = 0, ATH_CIPHER_AES_OCB = 1, ATH_CIPHER_AES_CCM = 2, ATH_CIPHER_CKIP = 3,
  ATH_CIPHER_TKIP = 4, ATH_CIPHER_CLR = 5, ATH_CIPHER_MIC = 127
}

Functions

 FILE_LICENCE (BSD2)
static int32_t sign_extend32 (uint32_t value, int index)
static u16 __get_unaligned_le16 (const u8 *p)
static u32 __get_unaligned_le32 (const u8 *p)
static u16 get_unaligned_le16 (const void *p)
static u32 get_unaligned_le32 (const void *p)
void ath_hw_setbssidmask (struct ath_common *common)
 ath_hw_set_bssid_mask - filter out bssids we listen
int ath_hw_keyreset (struct ath_common *common, u16 entry)
void ath_hw_cycle_counters_update (struct ath_common *common)
 ath_hw_cycle_counters_update - common function to update cycle counters
int32_t ath_hw_get_listen_time (struct ath_common *common)

Define Documentation

#define DIV_ROUND_UP (   n,
 
)    (((n) + (d) - 1) / (d))

Definition at line 29 of file ath.h.

Referenced by ath9k_hw_computetxtime().

#define BITS_PER_BYTE   8

Definition at line 30 of file ath.h.

#define BITS_TO_LONGS (   nr)    DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))

Definition at line 31 of file ath.h.

#define BIT (   nr)    (1UL << (nr))
#define min (   x,
 
)
#define max (   x,
 
)
#define abs (   x)
Value:
({                                      \
                long ret;                               \
                if (sizeof(x) == sizeof(long)) {        \
                        long __x = (x);                 \
                        ret = (__x < 0) ? -__x : __x;   \
                } else {                                \
                        int __x = (x);                  \
                        ret = (__x < 0) ? -__x : __x;   \
                }                                       \
                ret;                                    \
        })

Definition at line 44 of file ath.h.

Referenced by ar5008_hw_spur_mitigate(), ar9002_hw_spur_mitigate(), ar9003_hw_detect_outlier(), ar9003_hw_find_mag_approx(), ar9003_hw_spur_mitigate_ofdm(), ath9k_hw_ar9300_set_txpower(), and png_paeth_predictor().

#define ___constant_swab16 (   x)
Value:
((uint16_t)(                    \
        (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) |            \
        (((uint16_t)(x) & (uint16_t)0xff00U) >> 8)))

Definition at line 56 of file ath.h.

#define ___constant_swab32 (   x)
Value:
((uint32_t)(                    \
        (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |      \
        (((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |      \
        (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >>  8) |      \
        (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))

Definition at line 59 of file ath.h.

#define __swab16 (   x)    ___constant_swab16(x)

Definition at line 64 of file ath.h.

#define __swab32 (   x)    ___constant_swab32(x)

Definition at line 65 of file ath.h.

#define swab16   __swab16
#define swab32   __swab32
#define ATH_KEYMAX   128 /* max key cache size we handle */

Definition at line 101 of file ath.h.


Enumeration Type Documentation

Enumerator:
ATH_HW_UNAVAILABLE 
ATH_HW_INITIALIZED 

Definition at line 119 of file ath.h.

Enumerator:
ATH_PCI 
ATH_AHB 
ATH_USB 

Definition at line 124 of file ath.h.

Enumerator:
ATH_CRYPT_CAP_CIPHER_AESCCM 
ATH_CRYPT_CAP_MIC_COMBINED 

Definition at line 147 of file ath.h.

enum ath_cipher
Enumerator:
ATH_CIPHER_WEP 
ATH_CIPHER_AES_OCB 
ATH_CIPHER_AES_CCM 
ATH_CIPHER_CKIP 
ATH_CIPHER_TKIP 
ATH_CIPHER_CLR 
ATH_CIPHER_MIC 

Definition at line 163 of file ath.h.


Function Documentation

FILE_LICENCE ( BSD2  )
static int32_t sign_extend32 ( uint32_t  value,
int  index 
) [inline, static]

Definition at line 69 of file ath.h.

References index.

Referenced by ar5008_hw_do_getnf(), ar9002_hw_do_getnf(), and ar9003_hw_do_getnf().

{
        uint8_t shift = 31 - index;
        return (int32_t)(value << shift) >> shift;
}
static u16 __get_unaligned_le16 ( const u8 p) [inline, static]

Definition at line 75 of file ath.h.

Referenced by get_unaligned_le16().

{
        return p[0] | p[1] << 8;
}
static u32 __get_unaligned_le32 ( const u8 p) [inline, static]

Definition at line 79 of file ath.h.

Referenced by get_unaligned_le32().

{
        return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
}
static u16 get_unaligned_le16 ( const void *  p) [inline, static]

Definition at line 83 of file ath.h.

References __get_unaligned_le16().

Referenced by ath9k_hw_reset(), ath9k_hw_write_associd(), and ath_hw_setbssidmask().

{
        return __get_unaligned_le16((const u8 *)p);
}
static u32 get_unaligned_le32 ( const void *  p) [inline, static]

Definition at line 87 of file ath.h.

References __get_unaligned_le32().

Referenced by ath9k_hw_reset(), ath9k_hw_write_associd(), and ath_hw_setbssidmask().

{
        return __get_unaligned_le32((const u8 *)p);
}
void ath_hw_setbssidmask ( struct ath_common common)

ath_hw_set_bssid_mask - filter out bssids we listen

: the ath_common struct for the device.

BSSID masking is a method used by AR5212 and newer hardware to inform PCU which bits of the interface's MAC address should be looked at when trying to decide which packets to ACK. In station mode and AP mode with a single BSS every bit matters since we lock to only one BSS. In AP mode with multiple BSSes (virtual interfaces) not every bit matters because hw must accept frames for all BSSes and so we tweak some bits of our mac address in order to have multiple BSSes.

NOTE: This is a simple filter and does *not* filter out all relevant frames. Some frames that are not for us might get ACKed from us by PCU because they just match the mask.

When handling multiple BSSes you can get the BSSID mask by computing the set of ~ ( MAC XOR BSSID ) for all bssids we handle.

When you do this you are essentially computing the common bits of all your BSSes. Later it is assumed the hardware will "and" (&) the BSSID mask with the MAC address to obtain the relevant bits and compare the result with (frame's BSSID & mask) to see if they match.

Simple example: on your card you have have two BSSes you have created with BSSID-01 and BSSID-02. Lets assume BSSID-01 will not use the MAC address. There is another BSSID-03 but you are not part of it. For simplicity's sake, assuming only 4 bits for a mac address and for BSSIDs you can then have:

\ MAC: 0001 | BSSID-01: 0100 | --> Belongs to us BSSID-02: 1001 | / ------------------- BSSID-03: 0110 | --> External -------------------

Our bssid_mask would then be:

On loop iteration for BSSID-01: ~(0001 ^ 0100) -> ~(0101) -> 1010 bssid_mask = 1010

On loop iteration for BSSID-02: bssid_mask &= ~(0001 ^ 1001) bssid_mask = (1010) & ~(0001 ^ 1001) bssid_mask = (1010) & ~(1000) bssid_mask = (1010) & (0111) bssid_mask = 0010

A bssid_mask of 0010 means "only pay attention to the second least significant bit". This is because its the only bit common amongst the MAC and all BSSIDs we support. To findout what the real common bit is we can simply "&" the bssid_mask now with any BSSID we have or our MAC address (we assume the hardware uses the MAC address).

Now, suppose there's an incoming frame for BSSID-03:

IFRAME-01: 0110

An easy eye-inspeciton of this already should tell you that this frame will not pass our check. This is because the bssid_mask tells the hardware to only look at the second least significant bit and the common bit amongst the MAC and BSSIDs is 0, this frame has the 2nd LSB as 1, which does not match 0.

So with IFRAME-01 we *assume* the hardware will do:

allow = (IFRAME-01 & bssid_mask) == (bssid_mask & MAC) ? 1 : 0; --> allow = (0110 & 0010) == (0010 & 0001) ? 1 : 0; --> allow = (0010) == 0000 ? 1 : 0; --> allow = 0

Lets now test a frame that should work:

IFRAME-02: 0001 (we should allow)

allow = (IFRAME-02 & bssid_mask) == (bssid_mask & MAC) ? 1 : 0; --> allow = (0001 & 0010) == (0010 & 0001) ? 1 :0; --> allow = (0000) == (0000) --> allow = 1

Other examples:

IFRAME-03: 0100 --> allowed IFRAME-04: 1001 --> allowed IFRAME-05: 1101 --> allowed but its not for us!!!

Definition at line 120 of file ath_hw.c.

References ah, ath_common::ah, AR_BSSMSKL, AR_BSSMSKU, ath_common::bssidmask, get_unaligned_le16(), get_unaligned_le32(), and REG_WRITE.

Referenced by ath9k_hw_reset(), and ath_opmode_init().

{
        void *ah = common->ah;

        REG_WRITE(ah, get_unaligned_le32(common->bssidmask), AR_BSSMSKL);
        REG_WRITE(ah, get_unaligned_le16(common->bssidmask + 4), AR_BSSMSKU);
}
int ath_hw_keyreset ( struct ath_common common,
u16  entry 
)
void ath_hw_cycle_counters_update ( struct ath_common common)

ath_hw_cycle_counters_update - common function to update cycle counters

: the ath_common struct for the device.

This function is used to update all cycle counters in one place. It has to be called while holding common->cc_lock!

Definition at line 137 of file ath_hw.c.

References ah, ath_common::ah, AR_CCCNT, AR_MIBC, AR_MIBC_FMC, AR_RCCNT, AR_RFCNT, AR_TFCNT, ath_common::cc_ani, ath_common::cc_survey, ath_cycle_counters::cycles, REG_READ, REG_WRITE, rx, ath_cycle_counters::rx_busy, ath_cycle_counters::rx_frame, tx, and ath_cycle_counters::tx_frame.

Referenced by ath9k_hw_ani_read_counters(), and ath_update_survey_stats().

{
        u32 cycles, busy, rx, tx;
        void *ah = common->ah;

        /* freeze */
        REG_WRITE(ah, AR_MIBC_FMC, AR_MIBC);

        /* read */
        cycles = REG_READ(ah, AR_CCCNT);
        busy = REG_READ(ah, AR_RCCNT);
        rx = REG_READ(ah, AR_RFCNT);
        tx = REG_READ(ah, AR_TFCNT);

        /* clear */
        REG_WRITE(ah, 0, AR_CCCNT);
        REG_WRITE(ah, 0, AR_RFCNT);
        REG_WRITE(ah, 0, AR_RCCNT);
        REG_WRITE(ah, 0, AR_TFCNT);

        /* unfreeze */
        REG_WRITE(ah, 0, AR_MIBC);

        /* update all cycle counters here */
        common->cc_ani.cycles += cycles;
        common->cc_ani.rx_busy += busy;
        common->cc_ani.rx_frame += rx;
        common->cc_ani.tx_frame += tx;

        common->cc_survey.cycles += cycles;
        common->cc_survey.rx_busy += busy;
        common->cc_survey.rx_frame += rx;
        common->cc_survey.tx_frame += tx;
}

Definition at line 172 of file ath_hw.c.

References ath_common::cc_ani, ath_common::clockrate, ath_cycle_counters::cycles, memset(), ath_cycle_counters::rx_frame, and ath_cycle_counters::tx_frame.

Referenced by ath9k_hw_ani_read_counters().

{
        struct ath_cycle_counters *cc = &common->cc_ani;
        int32_t listen_time;

        listen_time = (cc->cycles - cc->rx_frame - cc->tx_frame) /
                      (common->clockrate * 1000);

        memset(cc, 0, sizeof(*cc));

        return listen_time;
}