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 
25 #include <unistd.h>
26 #include <string.h>
27 #include <ipxe/net80211.h>
28 
29 /* This block of functions are from kernel.h v3.0.1 */
30 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
31 #define BITS_PER_BYTE 8
32 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
33 #define BIT(nr) (1UL << (nr))
34 
35 #define min(x, y) ({ \
36  typeof(x) _min1 = (x); \
37  typeof(y) _min2 = (y); \
38  (void) (&_min1 == &_min2); \
39  _min1 < _min2 ? _min1 : _min2; })
40 #define max(x, y) ({ \
41  typeof(x) _max1 = (x); \
42  typeof(y) _max2 = (y); \
43  (void) (&_max1 == &_max2); \
44  _max1 > _max2 ? _max1 : _max2; })
45 #define abs(x) ({ \
46  long ret; \
47  if (sizeof(x) == sizeof(long)) { \
48  long __x = (x); \
49  ret = (__x < 0) ? -__x : __x; \
50  } else { \
51  int __x = (x); \
52  ret = (__x < 0) ? -__x : __x; \
53  } \
54  ret; \
55  })
56 
57 #define ___constant_swab16(x) ((uint16_t)( \
58  (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \
59  (((uint16_t)(x) & (uint16_t)0xff00U) >> 8)))
60 #define ___constant_swab32(x) ((uint32_t)( \
61  (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
62  (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
63  (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
64  (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
65 #define __swab16(x) ___constant_swab16(x)
66 #define __swab32(x) ___constant_swab32(x)
67 #define swab16 __swab16
68 #define swab32 __swab32
69 
71 {
72  uint8_t shift = 31 - index;
73  return (int32_t)(value << shift) >> shift;
74 }
75 
76 static inline u16 __get_unaligned_le16(const u8 *p)
77 {
78  return p[0] | p[1] << 8;
79 }
80 static inline u32 __get_unaligned_le32(const u8 *p)
81 {
82  return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
83 }
84 static inline u16 get_unaligned_le16(const void *p)
85 {
86  return __get_unaligned_le16((const u8 *)p);
87 }
88 static inline u32 get_unaligned_le32(const void *p)
89 {
90  return __get_unaligned_le32((const u8 *)p);
91 }
92 /* End Kernel Block */
93 
94 /*
95  * The key cache is used for h/w cipher state and also for
96  * tracking station state such as the current tx antenna.
97  * We also setup a mapping table between key cache slot indices
98  * and station state to short-circuit node lookups on rx.
99  * Different parts have different size key caches. We handle
100  * up to ATH_KEYMAX entries (could dynamically allocate state).
101  */
102 #define ATH_KEYMAX 128 /* max key cache size we handle */
103 
104 struct ath_ani {
105  int caldone;
106  unsigned int longcal_timer;
107  unsigned int shortcal_timer;
108  unsigned int resetcal_timer;
109  unsigned int checkani_timer;
110  int timer;
111 };
112 
118 };
119 
123 };
124 
129 };
130 
135 };
136 
138  char alpha2[2];
146 };
147 
151 };
152 
153 struct ath_keyval {
157  u8 kv_val[16]; /* TK */
158  u8 kv_mic[8]; /* Michael MIC key */
159  u8 kv_txmic[8]; /* Michael MIC TX key (used only if the hardware
160  * supports both MIC keys in the same key cache entry;
161  * in that case, kv_mic is the RX key) */
162 };
163 
172 };
173 
174 /**
175  * struct ath_ops - Register read/write operations
176  *
177  * @read: Register read
178  * @multi_read: Multiple register read
179  * @write: Register write
180  * @enable_write_buffer: Enable multiple register writes
181  * @write_flush: flush buffered register writes and disable buffering
182  */
183 struct ath_ops {
184  unsigned int (*read)(void *, u32 reg_offset);
185  void (*multi_read)(void *, u32 *addr, u32 *val, u16 count);
186  void (*write)(void *, u32 val, u32 reg_offset);
187  void (*enable_write_buffer)(void *);
188  void (*write_flush) (void *);
189  u32 (*rmw)(void *, u32 reg_offset, u32 set, u32 clr);
190 };
191 
192 struct ath_common;
193 struct ath_bus_ops;
194 
195 struct ath_common {
196  void *ah;
197  void *priv;
201 
202  struct ath_ani ani;
203 
209 
212 
214 
217 
218  unsigned int clockrate;
219 
222 
224  const struct ath_ops *ops;
225  const struct ath_bus_ops *bus_ops;
226 
228 };
229 
231 int ath_hw_keyreset(struct ath_common *common, u16 entry);
234 
235 #endif /* ATH_H */
u8 kv_txmic[8]
Definition: ath.h:159
uint16_t u16
Definition: stdint.h:21
int ath_hw_keyreset(struct ath_common *common, u16 entry)
Definition: ath_key.c:41
void(* write)(void *, u32 val, u32 reg_offset)
Definition: ath.h:186
struct ath_regulatory regulatory
Definition: ath.h:223
u16 cachelsz
Definition: ath.h:204
struct reg_dmn_pair_mapping * regpair
Definition: ath.h:145
u8 kv_mic[8]
Definition: ath.h:158
void __asmcall int val
Definition: setjmp.h:12
void(* multi_read)(void *, u32 *addr, u32 *val, u16 count)
Definition: ath.h:185
struct option_descriptor set[0]
Definition: nvo_cmd.c:111
ath_bus_type
Definition: ath.h:125
int btcoex_enabled
Definition: ath.h:227
static u32 __get_unaligned_le32(const u8 *p)
Definition: ath.h:80
static int32_t sign_extend32(uint32_t value, int index)
Definition: ath.h:70
unsigned int checkani_timer
Definition: ath.h:109
void ath_hw_setbssidmask(struct ath_common *common)
ath_hw_set_bssid_mask - filter out bssids we listen
Definition: ath_hw.c:120
Definition: ath.h:126
enum ath_crypt_caps crypt_caps
Definition: ath.h:216
u16 country_code
Definition: ath.h:139
long index
Definition: bigint.h:62
u16 kv_len
Definition: ath.h:156
struct ath_ops - Register read/write operations
Definition: ath.h:183
Definition: ath.h:127
static u32 get_unaligned_le32(const void *p)
Definition: ath.h:88
Definition: ath.h:128
ath_device_state
Definition: ath.h:120
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:137
u16 current_rd_ext
Definition: ath.h:143
const struct ath_ops * ops
Definition: ath.h:224
int caldone
Definition: ath.h:105
u8 kv_pad
Definition: ath.h:155
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define u32
Definition: vga.h:21
enum ath_device_state state
Definition: ath.h:200
unsigned int longcal_timer
Definition: ath.h:106
static unsigned int count
Number of entries.
Definition: dwmac.h:225
u16 current_rd
Definition: ath.h:142
int16_t power_limit
Definition: ath.h:144
const struct ath_bus_ops * bus_ops
Definition: ath.h:225
int timer
Definition: ath.h:110
static u16 get_unaligned_le16(const void *p)
Definition: ath.h:84
void * ah
Definition: ath.h:196
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:108
uint32_t addr
Buffer address.
Definition: dwmac.h:20
char alpha2[2]
Definition: ath.h:138
u8 tx_chainmask
Definition: ath.h:210
u32(* rmw)(void *, u32 reg_offset, u32 set, u32 clr)
Definition: ath.h:189
unsigned char uint8_t
Definition: stdint.h:10
ath_crypt_caps
Definition: ath.h:148
#define ETH_ALEN
Definition: if_ether.h:8
u32 keymax
Definition: ath.h:215
unsigned int uint32_t
Definition: stdint.h:12
struct ib_cm_common common
Definition: ib_mad.h:11
static u16 __get_unaligned_le16(const u8 *p)
Definition: ath.h:76
u16 curaid
Definition: ath.h:205
u8 rx_chainmask
Definition: ath.h:211
struct ath_cycle_counters cc_ani
Definition: ath.h:220
u8 curbssid[ETH_ALEN]
Definition: ath.h:207
int32_t ath_hw_get_listen_time(struct ath_common *common)
Definition: ath_hw.c:172
void(* write_flush)(void *)
Definition: ath.h:188
#define BIT(nr)
Definition: ath.h:33
FILE_LICENCE(BSD2)
signed int int32_t
Definition: stdint.h:17
u8 kv_type
Definition: ath.h:154
unsigned int clockrate
Definition: ath.h:218
struct ath_ani ani
Definition: ath.h:202
ath_cipher
Definition: ath.h:164
Definition: ath.h:104
struct ath_cycle_counters cc_survey
Definition: ath.h:221
int debug_mask
Definition: ath.h:199
void(* enable_write_buffer)(void *)
Definition: ath.h:187
u8 bssidmask[ETH_ALEN]
Definition: ath.h:208
struct net80211_device * dev
Definition: ath.h:198
signed short int16_t
Definition: stdint.h:16
unsigned int shortcal_timer
Definition: ath.h:107
unsigned int(* read)(void *, u32 reg_offset)
Definition: ath.h:184
u8 macaddr[ETH_ALEN]
Definition: ath.h:206
u8 kv_val[16]
Definition: ath.h:157
void * priv
Definition: ath.h:197
String functions.
u32 rx_bufsize
Definition: ath.h:213
uint8_t u8
Definition: stdint.h:19
u16 max_power_level
Definition: ath.h:140
uint32_t u32
Definition: stdint.h:23
u32 tp_scale
Definition: ath.h:141