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 
23 FILE_LICENCE ( BSD2 );
24 FILE_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 
77 static inline u16 __get_unaligned_le16(const u8 *p)
78 {
79  return p[0] | p[1] << 8;
80 }
81 static inline u32 __get_unaligned_le32(const u8 *p)
82 {
83  return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
84 }
85 static inline u16 get_unaligned_le16(const void *p)
86 {
87  return __get_unaligned_le16((const u8 *)p);
88 }
89 static 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 
105 struct ath_ani {
106  int caldone;
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 
119 };
120 
124 };
125 
130 };
131 
136 };
137 
139  char alpha2[2];
147 };
148 
152 };
153 
154 struct ath_keyval {
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 
173 };
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  */
184 struct 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 
193 struct ath_common;
194 struct ath_bus_ops;
195 
196 struct ath_common {
197  void *ah;
198  void *priv;
202 
203  struct ath_ani ani;
204 
210 
213 
215 
218 
219  unsigned int clockrate;
220 
223 
225  const struct ath_ops *ops;
226  const struct ath_bus_ops *bus_ops;
227 
229 };
230 
232 int ath_hw_keyreset(struct ath_common *common, u16 entry);
235 
236 #endif /* ATH_H */
u8 kv_txmic[8]
Definition: ath.h:160
uint16_t u16
Definition: stdint.h:22
int ath_hw_keyreset(struct ath_common *common, u16 entry)
Definition: ath_key.c:43
void(* write)(void *, u32 val, u32 reg_offset)
Definition: ath.h:187
struct ath_regulatory regulatory
Definition: ath.h:224
u16 cachelsz
Definition: ath.h:205
struct reg_dmn_pair_mapping * regpair
Definition: ath.h:146
u8 kv_mic[8]
Definition: ath.h:159
void __asmcall int val
Definition: setjmp.h:12
void(* multi_read)(void *, u32 *addr, u32 *val, u16 count)
Definition: ath.h:186
struct option_descriptor set[0]
Definition: nvo_cmd.c:112
ath_bus_type
Definition: ath.h:126
int btcoex_enabled
Definition: ath.h:228
static u32 __get_unaligned_le32(const u8 *p)
Definition: ath.h:81
static int32_t sign_extend32(uint32_t value, int index)
Definition: ath.h:71
unsigned int checkani_timer
Definition: ath.h:110
void ath_hw_setbssidmask(struct ath_common *common)
ath_hw_set_bssid_mask - filter out bssids we listen
Definition: ath_hw.c:122
Definition: ath.h:127
enum ath_crypt_caps crypt_caps
Definition: ath.h:217
u16 country_code
Definition: ath.h:140
long index
Definition: bigint.h:65
u16 kv_len
Definition: ath.h:157
struct ath_ops - Register read/write operations
Definition: ath.h:184
Definition: ath.h:128
static u32 get_unaligned_le32(const void *p)
Definition: ath.h:89
Definition: ath.h:129
ath_device_state
Definition: ath.h:121
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
u16 current_rd_ext
Definition: ath.h:144
const struct ath_ops * ops
Definition: ath.h:225
int caldone
Definition: ath.h:106
u8 kv_pad
Definition: ath.h:156
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define u32
Definition: vga.h:21
enum ath_device_state state
Definition: ath.h:201
unsigned int longcal_timer
Definition: ath.h:107
static unsigned int count
Number of entries.
Definition: dwmac.h:225
u16 current_rd
Definition: ath.h:143
int16_t power_limit
Definition: ath.h:145
const struct ath_bus_ops * bus_ops
Definition: ath.h:226
int timer
Definition: ath.h:111
static u16 get_unaligned_le16(const void *p)
Definition: ath.h:85
void * ah
Definition: ath.h:197
FILE_SECBOOT(FORBIDDEN)
The iPXE 802.11 MAC layer.
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
unsigned int resetcal_timer
Definition: ath.h:109
uint32_t addr
Buffer address.
Definition: dwmac.h:20
char alpha2[2]
Definition: ath.h:139
u8 tx_chainmask
Definition: ath.h:211
u32(* rmw)(void *, u32 reg_offset, u32 set, u32 clr)
Definition: ath.h:190
unsigned char uint8_t
Definition: stdint.h:10
ath_crypt_caps
Definition: ath.h:149
#define ETH_ALEN
Definition: if_ether.h:9
u32 keymax
Definition: ath.h:216
unsigned int uint32_t
Definition: stdint.h:12
struct ib_cm_common common
Definition: ib_mad.h:12
static u16 __get_unaligned_le16(const u8 *p)
Definition: ath.h:77
u16 curaid
Definition: ath.h:206
u8 rx_chainmask
Definition: ath.h:212
struct ath_cycle_counters cc_ani
Definition: ath.h:221
u8 curbssid[ETH_ALEN]
Definition: ath.h:208
int32_t ath_hw_get_listen_time(struct ath_common *common)
Definition: ath_hw.c:174
void(* write_flush)(void *)
Definition: ath.h:189
#define BIT(nr)
Definition: ath.h:34
FILE_LICENCE(BSD2)
signed int int32_t
Definition: stdint.h:17
u8 kv_type
Definition: ath.h:155
unsigned int clockrate
Definition: ath.h:219
struct ath_ani ani
Definition: ath.h:203
ath_cipher
Definition: ath.h:165
Definition: ath.h:105
struct ath_cycle_counters cc_survey
Definition: ath.h:222
int debug_mask
Definition: ath.h:200
void(* enable_write_buffer)(void *)
Definition: ath.h:188
u8 bssidmask[ETH_ALEN]
Definition: ath.h:209
struct net80211_device * dev
Definition: ath.h:199
signed short int16_t
Definition: stdint.h:16
unsigned int shortcal_timer
Definition: ath.h:108
unsigned int(* read)(void *, u32 reg_offset)
Definition: ath.h:185
u8 macaddr[ETH_ALEN]
Definition: ath.h:207
u8 kv_val[16]
Definition: ath.h:158
void * priv
Definition: ath.h:198
String functions.
u32 rx_bufsize
Definition: ath.h:214
uint8_t u8
Definition: stdint.h:20
u16 max_power_level
Definition: ath.h:141
uint32_t u32
Definition: stdint.h:24
u32 tp_scale
Definition: ath.h:142