iPXE
ath.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2009 Atheros Communications Inc.
3 *
4 * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
5 * Original from Linux kernel 3.0.1
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef ATH_H
21#define ATH_H
22
23FILE_LICENCE ( BSD2 );
24FILE_SECBOOT ( FORBIDDEN );
25
26#include <unistd.h>
27#include <string.h>
28#include <ipxe/net80211.h>
29
30/* This block of functions are from kernel.h v3.0.1 */
31#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
32#define BITS_PER_BYTE 8
33#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
34#define BIT(nr) (1UL << (nr))
35
36#define min(x, y) ({ \
37 typeof(x) _min1 = (x); \
38 typeof(y) _min2 = (y); \
39 (void) (&_min1 == &_min2); \
40 _min1 < _min2 ? _min1 : _min2; })
41#define max(x, y) ({ \
42 typeof(x) _max1 = (x); \
43 typeof(y) _max2 = (y); \
44 (void) (&_max1 == &_max2); \
45 _max1 > _max2 ? _max1 : _max2; })
46#define abs(x) ({ \
47 long ret; \
48 if (sizeof(x) == sizeof(long)) { \
49 long __x = (x); \
50 ret = (__x < 0) ? -__x : __x; \
51 } else { \
52 int __x = (x); \
53 ret = (__x < 0) ? -__x : __x; \
54 } \
55 ret; \
56 })
57
58#define ___constant_swab16(x) ((uint16_t)( \
59 (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \
60 (((uint16_t)(x) & (uint16_t)0xff00U) >> 8)))
61#define ___constant_swab32(x) ((uint32_t)( \
62 (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
63 (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
64 (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
65 (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
66#define __swab16(x) ___constant_swab16(x)
67#define __swab32(x) ___constant_swab32(x)
68#define swab16 __swab16
69#define swab32 __swab32
70
72{
73 uint8_t shift = 31 - index;
74 return (int32_t)(value << shift) >> shift;
75}
76
77static inline u16 __get_unaligned_le16(const u8 *p)
78{
79 return p[0] | p[1] << 8;
80}
81static inline u32 __get_unaligned_le32(const u8 *p)
82{
83 return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
84}
85static inline u16 get_unaligned_le16(const void *p)
86{
87 return __get_unaligned_le16((const u8 *)p);
88}
89static inline u32 get_unaligned_le32(const void *p)
90{
91 return __get_unaligned_le32((const u8 *)p);
92}
93/* End Kernel Block */
94
95/*
96 * The key cache is used for h/w cipher state and also for
97 * tracking station state such as the current tx antenna.
98 * We also setup a mapping table between key cache slot indices
99 * and station state to short-circuit node lookups on rx.
100 * Different parts have different size key caches. We handle
101 * up to ATH_KEYMAX entries (could dynamically allocate state).
102 */
103#define ATH_KEYMAX 128 /* max key cache size we handle */
104
105struct ath_ani {
107 unsigned int longcal_timer;
108 unsigned int shortcal_timer;
109 unsigned int resetcal_timer;
110 unsigned int checkani_timer;
111 int timer;
112};
113
120
125
131
137
148
153
158 u8 kv_val[16]; /* TK */
159 u8 kv_mic[8]; /* Michael MIC key */
160 u8 kv_txmic[8]; /* Michael MIC TX key (used only if the hardware
161 * supports both MIC keys in the same key cache entry;
162 * in that case, kv_mic is the RX key) */
163};
164
174
175/**
176 * struct ath_ops - Register read/write operations
177 *
178 * @read: Register read
179 * @multi_read: Multiple register read
180 * @write: Register write
181 * @enable_write_buffer: Enable multiple register writes
182 * @write_flush: flush buffered register writes and disable buffering
183 */
184struct ath_ops {
185 unsigned int (*read)(void *, u32 reg_offset);
186 void (*multi_read)(void *, u32 *addr, u32 *val, u16 count);
187 void (*write)(void *, u32 val, u32 reg_offset);
188 void (*enable_write_buffer)(void *);
189 void (*write_flush) (void *);
190 u32 (*rmw)(void *, u32 reg_offset, u32 set, u32 clr);
191};
192
193struct ath_common;
194struct ath_bus_ops;
195
230
232int ath_hw_keyreset(struct ath_common *common, u16 entry);
235
236#endif /* ATH_H */
pseudo_bit_t value[0x00020]
Definition arbel.h:2
signed short int16_t
Definition stdint.h:16
unsigned int uint32_t
Definition stdint.h:12
signed int int32_t
Definition stdint.h:17
unsigned char uint8_t
Definition stdint.h:10
long index
Definition bigint.h:65
ath_bus_type
Definition ath.h:126
@ ATH_USB
Definition ath.h:129
@ ATH_AHB
Definition ath.h:128
@ ATH_PCI
Definition ath.h:127
int32_t ath_hw_get_listen_time(struct ath_common *common)
Definition ath_hw.c:174
static int32_t sign_extend32(uint32_t value, int index)
Definition ath.h:71
#define BIT(nr)
Definition ath.h:34
static u16 get_unaligned_le16(const void *p)
Definition ath.h:85
static u32 __get_unaligned_le32(const u8 *p)
Definition ath.h:81
ath_cipher
Definition ath.h:165
@ ATH_CIPHER_TKIP
Definition ath.h:170
@ ATH_CIPHER_CLR
Definition ath.h:171
@ ATH_CIPHER_AES_OCB
Definition ath.h:167
@ ATH_CIPHER_AES_CCM
Definition ath.h:168
@ ATH_CIPHER_WEP
Definition ath.h:166
@ ATH_CIPHER_CKIP
Definition ath.h:169
@ ATH_CIPHER_MIC
Definition ath.h:172
static u32 get_unaligned_le32(const void *p)
Definition ath.h:89
int ath_hw_keyreset(struct ath_common *common, u16 entry)
Definition ath_key.c:43
static u16 __get_unaligned_le16(const u8 *p)
Definition ath.h:77
void ath_hw_cycle_counters_update(struct ath_common *common)
ath_hw_cycle_counters_update - common function to update cycle counters
Definition ath_hw.c:139
ath_device_state
Definition ath.h:121
@ ATH_HW_INITIALIZED
Definition ath.h:123
@ ATH_HW_UNAVAILABLE
Definition ath.h:122
void ath_hw_setbssidmask(struct ath_common *common)
ath_hw_set_bssid_mask - filter out bssids we listen
Definition ath_hw.c:122
ath_crypt_caps
Definition ath.h:149
@ ATH_CRYPT_CAP_MIC_COMBINED
Definition ath.h:151
@ ATH_CRYPT_CAP_CIPHER_AESCCM
Definition ath.h:150
uint32_t addr
Buffer address.
Definition dwmac.h:9
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
struct ib_cm_common common
Definition ib_mad.h:0
#define ETH_ALEN
Definition if_ether.h:9
#define u8
Definition igbvf_osdep.h:40
void __asmcall int val
Definition setjmp.h:12
String functions.
The iPXE 802.11 MAC layer.
struct option_descriptor set[0]
Definition nvo_cmd.c:112
Definition ath.h:105
int caldone
Definition ath.h:106
unsigned int resetcal_timer
Definition ath.h:109
unsigned int checkani_timer
Definition ath.h:110
int timer
Definition ath.h:111
unsigned int shortcal_timer
Definition ath.h:108
unsigned int longcal_timer
Definition ath.h:107
struct ath_cycle_counters cc_ani
Definition ath.h:221
unsigned int clockrate
Definition ath.h:219
int debug_mask
Definition ath.h:200
u16 curaid
Definition ath.h:206
void * priv
Definition ath.h:198
struct ath_ani ani
Definition ath.h:203
struct ath_regulatory regulatory
Definition ath.h:224
void * ah
Definition ath.h:197
struct ath_cycle_counters cc_survey
Definition ath.h:222
u32 keymax
Definition ath.h:216
u8 macaddr[ETH_ALEN]
Definition ath.h:207
u8 rx_chainmask
Definition ath.h:212
u8 curbssid[ETH_ALEN]
Definition ath.h:208
enum ath_crypt_caps crypt_caps
Definition ath.h:217
u8 bssidmask[ETH_ALEN]
Definition ath.h:209
enum ath_device_state state
Definition ath.h:201
const struct ath_ops * ops
Definition ath.h:225
u8 tx_chainmask
Definition ath.h:211
int btcoex_enabled
Definition ath.h:228
u16 cachelsz
Definition ath.h:205
u32 rx_bufsize
Definition ath.h:214
const struct ath_bus_ops * bus_ops
Definition ath.h:226
struct net80211_device * dev
Definition ath.h:199
u8 kv_type
Definition ath.h:155
u8 kv_mic[8]
Definition ath.h:159
u8 kv_pad
Definition ath.h:156
u8 kv_val[16]
Definition ath.h:158
u8 kv_txmic[8]
Definition ath.h:160
u16 kv_len
Definition ath.h:157
struct ath_ops - Register read/write operations
Definition ath.h:184
void(* multi_read)(void *, u32 *addr, u32 *val, u16 count)
Definition ath.h:186
unsigned int(* read)(void *, u32 reg_offset)
Definition ath.h:185
void(* write_flush)(void *)
Definition ath.h:189
void(* write)(void *, u32 val, u32 reg_offset)
Definition ath.h:187
u32(* rmw)(void *, u32 reg_offset, u32 set, u32 clr)
Definition ath.h:190
void(* enable_write_buffer)(void *)
Definition ath.h:188
u16 max_power_level
Definition ath.h:141
u16 country_code
Definition ath.h:140
u32 tp_scale
Definition ath.h:142
int16_t power_limit
Definition ath.h:145
u16 current_rd_ext
Definition ath.h:144
char alpha2[2]
Definition ath.h:139
struct reg_dmn_pair_mapping * regpair
Definition ath.h:146
u16 current_rd
Definition ath.h:143
Structure encapsulating the complete state of an 802.11 device.
Definition net80211.h:787
#define u16
Definition vga.h:20
#define u32
Definition vga.h:21