iPXE
Macros | Functions | Variables
ath9k_init.c File Reference
#include <ipxe/malloc.h>
#include <ipxe/pci_io.h>
#include <ipxe/pci.h>
#include <ipxe/ethernet.h>
#include "ath9k.h"

Go to the source code of this file.

Macros

#define CHAN2G(_freq, _idx)
 
#define CHAN5G(_freq, _idx)
 
#define SHPCHECK(__hw_rate, __flags)   ((__flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0)
 
#define RATE(_bitrate, _hw_rate, _flags)
 
#define DS2PHYS(_dd, _ds)   ((_dd)->dd_desc_paddr + ((char *)(_ds) - (char *)(_dd)->dd_desc))
 
#define ATH_DESC_4KB_BOUND_CHECK(_daddr)   ((((_daddr) & 0xFFF) > 0xF9F) ? 1 : 0)
 

Functions

 FILE_LICENCE (BSD2)
 
 FILE_SECBOOT (FORBIDDEN)
 
static void ath9k_deinit_softc (struct ath_softc *sc)
 
static void ath9k_iowrite32 (void *hw_priv, u32 val, u32 reg_offset)
 
static unsigned int ath9k_ioread32 (void *hw_priv, u32 reg_offset)
 
static unsigned int ath9k_reg_rmw (void *hw_priv, u32 reg_offset, u32 set, u32 clr)
 
int ath_descdma_setup (struct ath_softc *sc, struct ath_descdma *dd, struct list_head *head, const char *name, int nbuf, int ndesc, int is_tx)
 
void ath9k_init_crypto (struct ath_softc *sc)
 
static int ath9k_init_queues (struct ath_softc *sc)
 
static int ath9k_init_channels_rates (struct ath_softc *sc)
 
static void ath9k_init_misc (struct ath_softc *sc)
 
static int ath9k_init_softc (u16 devid, struct ath_softc *sc, u16 subsysid, const struct ath_bus_ops *bus_ops)
 
static void ath9k_init_band_txpower (struct ath_softc *sc, int band)
 
static void ath9k_init_txpower_limits (struct ath_softc *sc)
 
void ath9k_set_hw_capab (struct ath_softc *sc, struct net80211_device *dev __unused)
 
int ath9k_init_device (u16 devid, struct ath_softc *sc, u16 subsysid, const struct ath_bus_ops *bus_ops)
 
void ath9k_deinit_device (struct ath_softc *sc)
 
void ath_descdma_cleanup (struct ath_softc *sc __unused, struct ath_descdma *dd, struct list_head *head)
 

Variables

int is_ath9k_unloaded
 
static const struct net80211_channel ath9k_2ghz_chantable []
 
static const struct net80211_channel ath9k_5ghz_chantable []
 
static struct ath9k_legacy_rate ath9k_legacy_rates []
 

Macro Definition Documentation

◆ CHAN2G

#define CHAN2G (   _freq,
  _idx 
)
Value:
{ \
.band = NET80211_BAND_2GHZ, \
.center_freq = (_freq), \
.hw_value = (_idx), \
.maxpower = 20, \
}
#define NET80211_BAND_2GHZ
The 2.4 GHz ISM band, unlicensed in most countries.
Definition: net80211.h:45

Definition at line 33 of file ath9k_init.c.

◆ CHAN5G

#define CHAN5G (   _freq,
  _idx 
)
Value:
{ \
.band = NET80211_BAND_5GHZ, \
.center_freq = (_freq), \
.hw_value = (_idx), \
.maxpower = 20, \
}
#define NET80211_BAND_5GHZ
The band from 4.9 GHz to 5.7 GHz, which tends to be more restricted.
Definition: net80211.h:47

Definition at line 40 of file ath9k_init.c.

◆ SHPCHECK

#define SHPCHECK (   __hw_rate,
  __flags 
)    ((__flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0)

Definition at line 104 of file ath9k_init.c.

◆ RATE

#define RATE (   _bitrate,
  _hw_rate,
  _flags 
)
Value:
{ \
.bitrate = (_bitrate), \
.flags = (_flags), \
.hw_value = (_hw_rate), \
.hw_value_short = (SHPCHECK(_hw_rate, _flags)) \
}
uint8_t flags
Flags.
Definition: ena.h:18
#define SHPCHECK(__hw_rate, __flags)
Definition: ath9k_init.c:104

Definition at line 107 of file ath9k_init.c.

◆ DS2PHYS

#define DS2PHYS (   _dd,
  _ds 
)    ((_dd)->dd_desc_paddr + ((char *)(_ds) - (char *)(_dd)->dd_desc))

◆ ATH_DESC_4KB_BOUND_CHECK

#define ATH_DESC_4KB_BOUND_CHECK (   _daddr)    ((((_daddr) & 0xFFF) > 0xF9F) ? 1 : 0)

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( BSD2  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN  )

◆ ath9k_deinit_softc()

static void ath9k_deinit_softc ( struct ath_softc sc)
static

Definition at line 562 of file ath9k_init.c.

563 {
564  int i = 0;
565 
566  for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
567  if (ATH_TXQ_SETUP(sc, i))
568  ath_tx_cleanupq(sc, &sc->tx.txq[i]);
569 
570  ath9k_hw_deinit(sc->sc_ah);
571 
572  free(sc->hwinfo);
573  sc->hwinfo = NULL;
574  free(sc->sc_ah);
575  sc->sc_ah = NULL;
576 }
void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq)
Definition: ath9k_xmit.c:257
#define ATH_TXQ_SETUP(sc, i)
Definition: ath9k.h:63
struct ath_txq txq[ATH9K_NUM_TX_QUEUES]
Definition: ath9k.h:286
struct ath_hw * sc_ah
Definition: ath9k.h:455
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
void ath9k_hw_deinit(struct ath_hw *ah)
Definition: ath9k_hw.c:852
#define ATH9K_NUM_TX_QUEUES
Definition: mac.h:581
struct ath_tx tx
Definition: ath9k.h:477
struct net80211_hw_info * hwinfo
Definition: ath9k.h:478
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References ath9k_hw_deinit(), ATH9K_NUM_TX_QUEUES, ath_tx_cleanupq(), ATH_TXQ_SETUP, free, ath_softc::hwinfo, NULL, ath_softc::sc_ah, ath_softc::tx, and ath_tx::txq.

Referenced by ath9k_deinit_device(), and ath9k_init_device().

◆ ath9k_iowrite32()

static void ath9k_iowrite32 ( void *  hw_priv,
u32  val,
u32  reg_offset 
)
static

Definition at line 137 of file ath9k_init.c.

138 {
139  struct ath_hw *ah = (struct ath_hw *) hw_priv;
140  struct ath_common *common = ath9k_hw_common(ah);
141  struct ath_softc *sc = (struct ath_softc *) common->priv;
142 
143  writel(val, sc->mem + reg_offset);
144 }
Definition: hw.h:657
void __asmcall int val
Definition: setjmp.h:12
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:870
struct ib_cm_common common
Definition: ib_mad.h:12
void * mem
Definition: ath9k.h:456
uint8_t ah
Definition: registers.h:85

References ah, ath9k_hw_common(), common, ath_softc::mem, val, and writel().

Referenced by ath9k_init_softc().

◆ ath9k_ioread32()

static unsigned int ath9k_ioread32 ( void *  hw_priv,
u32  reg_offset 
)
static

Definition at line 146 of file ath9k_init.c.

147 {
148  struct ath_hw *ah = (struct ath_hw *) hw_priv;
149  struct ath_common *common = ath9k_hw_common(ah);
150  struct ath_softc *sc = (struct ath_softc *) common->priv;
151  u32 val;
152 
153  val = readl(sc->mem + reg_offset);
154  return val;
155 }
Definition: hw.h:657
void __asmcall int val
Definition: setjmp.h:12
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:870
struct ib_cm_common common
Definition: ib_mad.h:12
void * mem
Definition: ath9k.h:456
uint8_t ah
Definition: registers.h:85
uint32_t u32
Definition: stdint.h:24

References ah, ath9k_hw_common(), common, ath_softc::mem, readl(), and val.

Referenced by ath9k_init_softc().

◆ ath9k_reg_rmw()

static unsigned int ath9k_reg_rmw ( void *  hw_priv,
u32  reg_offset,
u32  set,
u32  clr 
)
static

Definition at line 157 of file ath9k_init.c.

158 {
159  struct ath_hw *ah = (struct ath_hw *) hw_priv;
160  struct ath_common *common = ath9k_hw_common(ah);
161  struct ath_softc *sc = (struct ath_softc *) common->priv;
162  u32 val;
163 
164  val = readl(sc->mem + reg_offset);
165  val &= ~clr;
166  val |= set;
167  writel(val, sc->mem + reg_offset);
168 
169  return val;
170 }
Definition: hw.h:657
void __asmcall int val
Definition: setjmp.h:12
struct option_descriptor set[0]
Definition: nvo_cmd.c:112
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:870
struct ib_cm_common common
Definition: ib_mad.h:12
void * mem
Definition: ath9k.h:456
uint8_t ah
Definition: registers.h:85
uint32_t u32
Definition: stdint.h:24

References ah, ath9k_hw_common(), common, ath_softc::mem, readl(), set, val, and writel().

Referenced by ath9k_init_softc().

◆ ath_descdma_setup()

int ath_descdma_setup ( struct ath_softc sc,
struct ath_descdma dd,
struct list_head head,
const char *  name,
int  nbuf,
int  ndesc,
int  is_tx 
)

Definition at line 181 of file ath9k_init.c.

184 {
185 #define DS2PHYS(_dd, _ds) \
186  ((_dd)->dd_desc_paddr + ((char *)(_ds) - (char *)(_dd)->dd_desc))
187 #define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF9F) ? 1 : 0)
188  u8 *ds;
189  struct ath_buf *bf;
190  int i, bsize, error, desc_len;
191 
192  DBG2("ath9k: %s DMA: %d buffers %d desc/buf\n",
193  name, nbuf, ndesc);
194 
196 
197  if (is_tx)
198  desc_len = sc->sc_ah->caps.tx_desc_len;
199  else
200  desc_len = sizeof(struct ath_desc);
201 
202  /* ath_desc must be a multiple of DWORDs */
203  if ((desc_len % 4) != 0) {
204  DBG("ath9k: ath_desc not DWORD aligned\n");
205  error = -ENOMEM;
206  goto fail;
207  }
208 
209  dd->dd_desc_len = desc_len * nbuf * ndesc;
210 
211  /*
212  * Need additional DMA memory because we can't use
213  * descriptors that cross the 4K page boundary.
214  * However, iPXE only utilizes 16 buffers, which
215  * will never make up more than half of one page,
216  * so we will only ever skip 1 descriptor, if that.
217  */
219  u32 ndesc_skipped = 1;
220  u32 dma_len;
221 
222  dma_len = ndesc_skipped * desc_len;
223  dd->dd_desc_len += dma_len;
224  }
225 
226  /* allocate descriptors */
227  dd->dd_desc = malloc_phys(dd->dd_desc_len, 16);
228  if (dd->dd_desc == NULL) {
229  error = -ENOMEM;
230  goto fail;
231  }
232  dd->dd_desc_paddr = virt_to_bus(dd->dd_desc);
233  ds = (u8 *) dd->dd_desc;
234  DBG2("ath9k: %s DMA map: %p (%d) -> %llx (%d)\n",
235  name, ds, (u32) dd->dd_desc_len,
236  ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len);
237 
238  /* allocate buffers */
239  bsize = sizeof(struct ath_buf) * nbuf;
240  bf = zalloc(bsize);
241  if (bf == NULL) {
242  error = -ENOMEM;
243  goto fail2;
244  }
245  dd->dd_bufptr = bf;
246 
247  for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) {
248  bf->bf_desc = ds;
249  bf->bf_daddr = DS2PHYS(dd, ds);
250 
251  if (!(sc->sc_ah->caps.hw_caps &
253  /*
254  * Skip descriptor addresses which can cause 4KB
255  * boundary crossing (addr + length) with a 32 dword
256  * descriptor fetch.
257  */
258  while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) {
259  ds += (desc_len * ndesc);
260  bf->bf_desc = ds;
261  bf->bf_daddr = DS2PHYS(dd, ds);
262  }
263  }
264  list_add_tail(&bf->list, head);
265  }
266  return 0;
267 fail2:
268  free_phys(dd->dd_desc, dd->dd_desc_len);
269 fail:
270  memset(dd, 0, sizeof(*dd));
271  return error;
272 #undef ATH_DESC_4KB_BOUND_CHECK
273 #undef DS2PHYS
274 }
const char * name
Definition: ath9k_hw.c:1986
void * bf_desc
Definition: ath9k.h:226
struct arbelprm_completion_with_error error
Definition: arbel.h:12
#define DS2PHYS(_dd, _ds)
uint8_t head
Head number.
Definition: int13.h:34
Definition: mac.h:241
#define ito64(x)
Definition: ath9k.h:38
#define ATH_DESC_4KB_BOUND_CHECK(_daddr)
#define ENOMEM
Not enough space.
Definition: errno.h:535
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:184
struct ath_hw * sc_ah
Definition: ath9k.h:455
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:94
#define u32
Definition: vga.h:21
Definition: ath9k.h:220
u32 dd_desc_paddr
Definition: ath9k.h:108
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:662
uint32_t ds
Definition: librm.h:140
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:46
struct ath9k_hw_capabilities caps
Definition: hw.h:664
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:723
u32 dd_desc_len
Definition: ath9k.h:109
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
uint8_t u8
Definition: stdint.h:20
uint32_t u32
Definition: stdint.h:24
struct ath_buf * dd_bufptr
Definition: ath9k.h:110
void * dd_desc
Definition: ath9k.h:107
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.c:707
#define DBG2(...)
Definition: compiler.h:515
void * memset(void *dest, int character, size_t len) __nonnull

References ATH9K_HW_CAP_4KB_SPLITTRANS, ATH_DESC_4KB_BOUND_CHECK, ath_buf::bf_desc, ath_hw::caps, DBG, DBG2, ath_descdma::dd_bufptr, ath_descdma::dd_desc, ath_descdma::dd_desc_len, ath_descdma::dd_desc_paddr, ds, DS2PHYS, ENOMEM, error, free_phys(), head, ath9k_hw_capabilities::hw_caps, INIT_LIST_HEAD, ito64, list_add_tail, malloc_phys(), memset(), name, NULL, ath_softc::sc_ah, ath9k_hw_capabilities::tx_desc_len, u32, virt_to_bus(), and zalloc().

Referenced by ath_rx_init(), and ath_tx_init().

◆ ath9k_init_crypto()

void ath9k_init_crypto ( struct ath_softc sc)

Definition at line 276 of file ath9k_init.c.

277 {
278  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
279  unsigned int i = 0;
280 
281  /* Get the hardware key cache size. */
282  common->keymax = AR_KEYTABLE_SIZE;
283 
284  /*
285  * Reset the key cache since some parts do not
286  * reset the contents on initial power up.
287  */
288  for (i = 0; i < common->keymax; i++)
289  ath_hw_keyreset(common, (u16) i);
290 
291  /*
292  * Check whether the separate key cache entries
293  * are required to handle both tx+rx MIC keys.
294  * With split mic keys the number of stations is limited
295  * to 27 otherwise 59.
296  */
298  common->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED;
299 }
uint16_t u16
Definition: stdint.h:22
int ath_hw_keyreset(struct ath_common *common, u16 entry)
Definition: ath_key.c:43
#define AR_PCU_MIC_NEW_LOC_ENA
Definition: reg.h:1643
#define AR_KEYTABLE_SIZE
Definition: hw.h:149
u32 misc_mode
Definition: hw.h:750
struct ath_hw * sc_ah
Definition: ath9k.h:455
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:870
struct ib_cm_common common
Definition: ib_mad.h:12

References AR_KEYTABLE_SIZE, AR_PCU_MIC_NEW_LOC_ENA, ath9k_hw_common(), ATH_CRYPT_CAP_MIC_COMBINED, ath_hw_keyreset(), common, ath_hw::misc_mode, and ath_softc::sc_ah.

Referenced by ath9k_init_softc().

◆ ath9k_init_queues()

static int ath9k_init_queues ( struct ath_softc sc)
static

Definition at line 301 of file ath9k_init.c.

302 {
303  int i = 0;
304 
305  for (i = 0; i < WME_NUM_AC; i++) {
306  sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i);
307  sc->tx.txq_map[i]->mac80211_qnum = i;
308  }
309  return 0;
310 }
int mac80211_qnum
Definition: ath9k.h:182
struct ath_tx tx
Definition: ath9k.h:477
#define WME_NUM_AC
Definition: common.h:36
struct ath_txq * txq_map[WME_NUM_AC]
Definition: ath9k.h:288
struct ath_txq * ath_txq_setup(struct ath_softc *sc, int qtype, int subtype)
Definition: ath9k_xmit.c:108

References ATH9K_TX_QUEUE_DATA, ath_txq_setup(), ath_txq::mac80211_qnum, ath_softc::tx, ath_tx::txq_map, and WME_NUM_AC.

Referenced by ath9k_init_softc().

◆ ath9k_init_channels_rates()

static int ath9k_init_channels_rates ( struct ath_softc sc)
static

Definition at line 312 of file ath9k_init.c.

313 {
314  unsigned int i;
315 
317 
318  if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) {
320 
322 
323  for (i = 0; i < ARRAY_SIZE(ath9k_legacy_rates); i++)
326  }
327 
328  if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) {
330 
332 
333  for (i = 4; i < ARRAY_SIZE(ath9k_legacy_rates); i++)
336  }
337  return 0;
338 }
struct net80211_channel channels[NET80211_MAX_CHANNELS]
List of RF channels supported by the card.
Definition: net80211.h:498
static const struct net80211_channel ath9k_2ghz_chantable[]
Definition: ath9k_init.c:51
static const struct net80211_channel ath9k_5ghz_chantable[]
Definition: ath9k_init.c:72
#define NET80211_BAND_2GHZ
The 2.4 GHz ISM band, unlicensed in most countries.
Definition: net80211.h:45
u16 rates[NET80211_NR_BANDS][NET80211_MAX_RATES]
List of transmission rates supported by the card, indexed by band.
Definition: net80211.h:508
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct ath_hw * sc_ah
Definition: ath9k.h:455
int nr_rates[NET80211_NR_BANDS]
Number of supported rates, indexed by band.
Definition: net80211.h:511
#define NET80211_BAND_5GHZ
The band from 4.9 GHz to 5.7 GHz, which tends to be more restricted.
Definition: net80211.h:47
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
struct net80211_hw_info * hwinfo
Definition: ath9k.h:478
static struct ath9k_legacy_rate ath9k_legacy_rates[]
Definition: ath9k_init.c:114
struct ath9k_hw_capabilities caps
Definition: hw.h:664
int nr_channels
Number of supported channels.
Definition: net80211.h:501
struct ath9k_legacy_rate rates[NET80211_MAX_RATES]
Definition: ath9k.h:479

References ARRAY_SIZE, ath9k_2ghz_chantable, ath9k_5ghz_chantable, ATH9K_HW_CAP_2GHZ, ATH9K_HW_CAP_5GHZ, ath9k_legacy_rates, ath9k_legacy_rate::bitrate, ath_hw::caps, net80211_hw_info::channels, ath9k_hw_capabilities::hw_caps, ath_softc::hwinfo, memcpy(), NET80211_BAND_2GHZ, NET80211_BAND_5GHZ, net80211_hw_info::nr_channels, net80211_hw_info::nr_rates, ath_softc::rates, net80211_hw_info::rates, and ath_softc::sc_ah.

Referenced by ath9k_init_softc().

◆ ath9k_init_misc()

static void ath9k_init_misc ( struct ath_softc sc)
static

Definition at line 340 of file ath9k_init.c.

341 {
342  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
343 
344  common->ani.timer = 0;
345 
347 
348  common->tx_chainmask = sc->sc_ah->caps.tx_chainmask;
349  common->rx_chainmask = sc->sc_ah->caps.rx_chainmask;
350 
353 
354  memcpy(common->bssidmask, eth_broadcast, ETH_ALEN);
355 }
u32 ath9k_hw_getdefantenna(struct ath_hw *ah)
Definition: ath9k_hw.c:1868
uint8_t eth_broadcast[ETH_ALEN]
Ethernet broadcast MAC address.
Definition: ethernet.c:48
#define ATH_TXPOWER_MAX
Definition: ath9k.h:360
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct ath_hw * sc_ah
Definition: ath9k.h:455
struct ath_config config
Definition: ath9k.h:475
u8 defant
Definition: ath9k.h:298
struct ath_rx rx
Definition: ath9k.h:476
static void ath9k_hw_set_diversity(struct ath_hw *ah, int value)
Definition: hw-ops.h:242
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:870
#define ETH_ALEN
Definition: if_ether.h:9
struct ib_cm_common common
Definition: ib_mad.h:12
struct ath9k_hw_capabilities caps
Definition: hw.h:664
u16 txpowlimit
Definition: ath9k.h:66

References ath9k_hw_common(), ath9k_hw_getdefantenna(), ath9k_hw_set_diversity(), ATH_TXPOWER_MAX, ath_hw::caps, common, ath_softc::config, ath_rx::defant, ETH_ALEN, eth_broadcast, memcpy(), ath_softc::rx, ath9k_hw_capabilities::rx_chainmask, ath_softc::sc_ah, ath9k_hw_capabilities::tx_chainmask, and ath_config::txpowlimit.

Referenced by ath9k_init_softc().

◆ ath9k_init_softc()

static int ath9k_init_softc ( u16  devid,
struct ath_softc sc,
u16  subsysid,
const struct ath_bus_ops bus_ops 
)
static

Definition at line 357 of file ath9k_init.c.

359 {
360  struct ath_hw *ah = NULL;
361  struct ath_common *common;
362  int ret = 0, i;
363  int csz = 0;
364 
365  ah = zalloc(sizeof(struct ath_hw));
366  if (!ah)
367  return -ENOMEM;
368 
369  ah->dev = sc->dev;
370  ah->hw_version.devid = devid;
371  ah->hw_version.subsysid = subsysid;
372  ah->reg_ops.read = ath9k_ioread32;
373  ah->reg_ops.write = ath9k_iowrite32;
374  ah->reg_ops.rmw = ath9k_reg_rmw;
375  sc->sc_ah = ah;
376 
377  sc->hwinfo = zalloc(sizeof(*sc->hwinfo));
378  if (!sc->hwinfo) {
379  DBG("ath9k: cannot allocate 802.11 hardware info structure\n");
380  return -ENOMEM;
381  }
382 
383  ah->ah_flags |= AH_USE_EEPROM;
384  sc->sc_ah->led_pin = -1;
385 
387  common->ops = &ah->reg_ops;
388  common->bus_ops = bus_ops;
389  common->ah = ah;
390  common->dev = sc->dev;
391  common->priv = sc;
392 
393  sc->intr_tq = ath9k_tasklet;
394 
395  /*
396  * Cache line size is used to size and align various
397  * structures used to communicate with the hardware.
398  */
399  ath_read_cachesize(common, &csz);
400  common->cachelsz = csz << 2; /* convert to bytes */
401 
402  /* Initializes the hardware for all supported chipsets */
403  ret = ath9k_hw_init(ah);
404  if (ret)
405  goto err_hw;
406 
407  memcpy(sc->hwinfo->hwaddr, common->macaddr, ETH_ALEN);
408 
409  ret = ath9k_init_queues(sc);
410  if (ret)
411  goto err_queues;
412 
413  ret = ath9k_init_channels_rates(sc);
414  if (ret)
415  goto err_btcoex;
416 
417  ath9k_init_crypto(sc);
418  ath9k_init_misc(sc);
419 
420  return 0;
421 
422 err_btcoex:
423  for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
424  if (ATH_TXQ_SETUP(sc, i))
425  ath_tx_cleanupq(sc, &sc->tx.txq[i]);
426 err_queues:
428 err_hw:
429  free(sc->hwinfo);
430  sc->hwinfo = NULL;
431 
432  free(ah);
433  sc->sc_ah = NULL;
434 
435  return ret;
436 }
Definition: hw.h:657
void ath9k_init_crypto(struct ath_softc *sc)
Definition: ath9k_init.c:276
void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq)
Definition: ath9k_xmit.c:257
void ath9k_tasklet(struct ath_softc *sc)
Definition: ath9k_main.c:341
#define ATH_TXQ_SETUP(sc, i)
Definition: ath9k.h:63
struct ath_txq txq[ATH9K_NUM_TX_QUEUES]
Definition: ath9k.h:286
static unsigned int ath9k_reg_rmw(void *hw_priv, u32 reg_offset, u32 set, u32 clr)
Definition: ath9k_init.c:157
static void ath9k_init_misc(struct ath_softc *sc)
Definition: ath9k_init.c:340
struct net80211_device * dev
Definition: ath9k.h:446
#define ENOMEM
Not enough space.
Definition: errno.h:535
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void ath_read_cachesize(struct ath_common *common, int *csz)
Definition: ath9k.h:496
#define AH_USE_EEPROM
Definition: hw.h:654
u8 hwaddr[ETH_ALEN]
Default hardware MAC address.
Definition: net80211.h:447
struct ath_hw * sc_ah
Definition: ath9k.h:455
const struct ath_bus_ops * bus_ops
Definition: ath.h:226
static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset)
Definition: ath9k_init.c:137
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
void ath9k_hw_deinit(struct ath_hw *ah)
Definition: ath9k_hw.c:852
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:662
#define ATH9K_NUM_TX_QUEUES
Definition: mac.h:581
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:870
struct ath_tx tx
Definition: ath9k.h:477
struct net80211_hw_info * hwinfo
Definition: ath9k.h:478
#define ETH_ALEN
Definition: if_ether.h:9
struct ib_cm_common common
Definition: ib_mad.h:12
static int ath9k_init_channels_rates(struct ath_softc *sc)
Definition: ath9k_init.c:312
int ath9k_hw_init(struct ath_hw *ah)
Definition: ath9k_hw.c:571
int led_pin
Definition: hw.h:796
void(* intr_tq)(struct ath_softc *sc)
Definition: ath9k.h:454
uint8_t ah
Definition: registers.h:85
static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset)
Definition: ath9k_init.c:146
static int ath9k_init_queues(struct ath_softc *sc)
Definition: ath9k_init.c:301
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References ah, AH_USE_EEPROM, ath9k_hw_common(), ath9k_hw_deinit(), ath9k_hw_init(), ath9k_init_channels_rates(), ath9k_init_crypto(), ath9k_init_misc(), ath9k_init_queues(), ath9k_ioread32(), ath9k_iowrite32(), ATH9K_NUM_TX_QUEUES, ath9k_reg_rmw(), ath9k_tasklet(), ath_read_cachesize(), ath_tx_cleanupq(), ATH_TXQ_SETUP, ath_common::bus_ops, common, DBG, ath_softc::dev, ENOMEM, ETH_ALEN, free, net80211_hw_info::hwaddr, ath_softc::hwinfo, ath_softc::intr_tq, ath_hw::led_pin, memcpy(), NULL, ath_softc::sc_ah, ath_softc::tx, ath_tx::txq, and zalloc().

Referenced by ath9k_init_device().

◆ ath9k_init_band_txpower()

static void ath9k_init_band_txpower ( struct ath_softc sc,
int  band 
)
static

Definition at line 438 of file ath9k_init.c.

439 {
440  struct net80211_channel *chan;
441  struct ath_hw *ah = sc->sc_ah;
443  int i;
444 
445  for (i = 0; i < sc->hwinfo->nr_channels; i++) {
446  chan = &sc->hwinfo->channels[i];
447  if(chan->band != band)
448  continue;
449  ah->curchan = &ah->channels[chan->hw_value];
451  chan->maxpower = reg->max_power_level / 2;
452  }
453 }
Definition: hw.h:657
struct net80211_channel channels[NET80211_MAX_CHANNELS]
List of RF channels supported by the card.
Definition: net80211.h:498
static unsigned int unsigned int reg
Definition: myson.h:162
u16 hw_value
Hardware channel value.
Definition: net80211.h:414
u8 maxpower
Maximum allowable transmit power, in dBm.
Definition: net80211.h:425
struct ath_hw * sc_ah
Definition: ath9k.h:455
static struct ath_regulatory * ath9k_hw_regulatory(struct ath_hw *ah)
Definition: hw.h:875
u8 band
The band with which this channel is associated.
Definition: net80211.h:388
An 802.11 RF channel.
Definition: net80211.h:385
struct net80211_hw_info * hwinfo
Definition: ath9k.h:478
void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, int test)
Definition: ath9k_hw.c:1939
int nr_channels
Number of supported channels.
Definition: net80211.h:501
uint8_t ah
Definition: registers.h:85
#define MAX_RATE_POWER
Definition: hw.h:145

References ah, ath9k_hw_regulatory(), ath9k_hw_set_txpowerlimit(), net80211_channel::band, net80211_hw_info::channels, net80211_channel::hw_value, ath_softc::hwinfo, MAX_RATE_POWER, net80211_channel::maxpower, net80211_hw_info::nr_channels, reg, and ath_softc::sc_ah.

Referenced by ath9k_init_txpower_limits().

◆ ath9k_init_txpower_limits()

static void ath9k_init_txpower_limits ( struct ath_softc sc)
static

Definition at line 455 of file ath9k_init.c.

456 {
457  struct ath_hw *ah = sc->sc_ah;
458  struct ath9k_channel *curchan = ah->curchan;
459 
460  if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
462  if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
464 
465  ah->curchan = curchan;
466 }
Definition: hw.h:657
#define NET80211_BAND_2GHZ
The 2.4 GHz ISM band, unlicensed in most countries.
Definition: net80211.h:45
struct ath_hw * sc_ah
Definition: ath9k.h:455
#define NET80211_BAND_5GHZ
The band from 4.9 GHz to 5.7 GHz, which tends to be more restricted.
Definition: net80211.h:47
uint8_t ah
Definition: registers.h:85
static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
Definition: ath9k_init.c:438

References ah, ATH9K_HW_CAP_2GHZ, ATH9K_HW_CAP_5GHZ, ath9k_init_band_txpower(), NET80211_BAND_2GHZ, NET80211_BAND_5GHZ, and ath_softc::sc_ah.

Referenced by ath9k_init_device().

◆ ath9k_set_hw_capab()

void ath9k_set_hw_capab ( struct ath_softc sc,
struct net80211_device *dev  __unused 
)

Definition at line 468 of file ath9k_init.c.

469 {
470  sc->hwinfo->flags = NET80211_HW_RX_HAS_FCS;
471  sc->hwinfo->signal_type = NET80211_SIGNAL_DB;
472  sc->hwinfo->signal_max = 40; /* 35dB should give perfect 54Mbps */
473  sc->hwinfo->channel_change_time = 5000;
474 
475  if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
476  {
479  }
480  if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
481  {
483  sc->hwinfo->modes |= NET80211_MODE_A;
484  }
485 }
int modes
A bitwise OR of the 802.11x modes supported by this device.
Definition: net80211.h:450
enum net80211_hw_info::@641 flags
A set of flags indicating peculiarities of this device.
unsigned signal_max
Maximum signal in arbitrary cases.
Definition: net80211.h:495
#define NET80211_BAND_BIT_5GHZ
Bitmask for the 5GHz band.
Definition: net80211.h:54
enum net80211_hw_info::@642 signal_type
Signal strength information that can be provided by the device.
struct ath_hw * sc_ah
Definition: ath9k.h:455
struct net80211_hw_info * hwinfo
Definition: ath9k.h:478
#define NET80211_MODE_B
802.11b: 1-11 Mbps operation using DSSS/CCK signaling on the 2.4GHz band
Definition: net80211.h:66
struct ath9k_hw_capabilities caps
Definition: hw.h:664
#define NET80211_BAND_BIT_2GHZ
Bitmask for the 2GHz band.
Definition: net80211.h:52
int bands
A bitwise OR of the bands on which this device can communicate.
Definition: net80211.h:453
unsigned channel_change_time
Estimate of the time required to change channels, in microseconds.
Definition: net80211.h:518
#define NET80211_MODE_G
802.11g: 54 Mbps operation using ERP/OFDM signaling on the 2.4GHz band
Definition: net80211.h:69
#define NET80211_MODE_A
802.11a: 54 Mbps operation using OFDM signaling on the 5GHz band
Definition: net80211.h:63

References ATH9K_HW_CAP_2GHZ, ATH9K_HW_CAP_5GHZ, net80211_hw_info::bands, ath_hw::caps, net80211_hw_info::channel_change_time, net80211_hw_info::flags, ath9k_hw_capabilities::hw_caps, ath_softc::hwinfo, net80211_hw_info::modes, NET80211_BAND_BIT_2GHZ, NET80211_BAND_BIT_5GHZ, NET80211_MODE_A, NET80211_MODE_B, NET80211_MODE_G, ath_softc::sc_ah, net80211_hw_info::signal_max, and net80211_hw_info::signal_type.

Referenced by ath9k_init_device().

◆ ath9k_init_device()

int ath9k_init_device ( u16  devid,
struct ath_softc sc,
u16  subsysid,
const struct ath_bus_ops bus_ops 
)

Definition at line 487 of file ath9k_init.c.

489 {
490  struct net80211_device *dev = sc->dev;
491  /*struct ath_common *common;
492  struct ath_hw *ah;*/
493  int error = 0;
494  /*struct ath_regulatory *reg;*/
495 
496  /* Bring up device */
497  error = ath9k_init_softc(devid, sc, subsysid, bus_ops);
498  if (error != 0)
499  goto error_init;
500 
501  /*ah = sc->sc_ah;
502  common = ath9k_hw_common(ah);*/
503  ath9k_set_hw_capab(sc, dev);
504  /* TODO Cottsay: reg */
505  /* Initialize regulatory */
506  /*error = ath_regd_init(&common->regulatory, sc->dev->wiphy,
507  ath9k_reg_notifier);
508  if (error)
509  goto error_regd;
510 
511  reg = &common->regulatory;*/
512 
513  /* Setup TX DMA */
514  error = ath_tx_init(sc, ATH_TXBUF);
515  if (error != 0)
516  goto error_tx;
517 
518  /* Setup RX DMA */
519  error = ath_rx_init(sc, ATH_RXBUF);
520  if (error != 0)
521  goto error_rx;
522 
524 
525  /* Register with mac80211 */
526  error = net80211_register(dev, &ath9k_ops, sc->hwinfo);
527  if (error)
528  goto error_register;
529 
530  /* TODO Cottsay: reg */
531  /* Handle world regulatory */
532  /*if (!ath_is_world_regd(reg)) {
533  error = regulatory_hint(hw->wiphy, reg->alpha2);
534  if (error)
535  goto error_world;
536  }*/
537 
540 
541  /* TODO Cottsay: rfkill */
542  /*ath_start_rfkill_poll(sc);*/
543 
544  return 0;
545 
546 //error_world:
547 // net80211_unregister(dev);
548 error_register:
549  ath_rx_cleanup(sc);
550 error_rx:
551  ath_tx_cleanup(sc);
552 error_tx:
553  ath9k_deinit_softc(sc);
554 error_init:
555  return error;
556 }
#define ATH_TXBUF
Definition: base.h:54
#define ATH_RXBUF
Definition: base.h:53
struct arbelprm_completion_with_error error
Definition: arbel.h:12
void ath9k_set_hw_capab(struct ath_softc *sc, struct net80211_device *dev __unused)
Definition: ath9k_init.c:468
void ath_tx_cleanup(struct ath_softc *sc)
Definition: ath9k_xmit.c:811
static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, const struct ath_bus_ops *bus_ops)
Definition: ath9k_init.c:357
struct net80211_device * dev
Definition: ath9k.h:446
struct net80211_device_operations ath9k_ops
Definition: ath9k_main.c:911
void(* hw_pll_work)(struct ath_softc *sc)
Definition: ath9k.h:487
int last_rssi
Definition: ath9k.h:483
#define ATH_RSSI_DUMMY_MARKER
Definition: common.h:38
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
struct net80211_hw_info * hwinfo
Definition: ath9k.h:478
void ath_rx_cleanup(struct ath_softc *sc)
Definition: ath9k_recv.c:144
int ath_tx_init(struct ath_softc *sc, int nbufs)
Definition: ath9k_xmit.c:790
void ath_hw_pll_work(struct ath_softc *sc)
Definition: ath9k_main.c:327
static void ath9k_deinit_softc(struct ath_softc *sc)
Definition: ath9k_init.c:562
int ath_rx_init(struct ath_softc *sc, int nbufs)
Definition: ath9k_recv.c:99
int net80211_register(struct net80211_device *dev, struct net80211_device_operations *ops, struct net80211_hw_info *hw)
Register 802.11 device with network stack.
Definition: net80211.c:792
static void ath9k_init_txpower_limits(struct ath_softc *sc)
Definition: ath9k_init.c:455

References ath9k_deinit_softc(), ath9k_init_softc(), ath9k_init_txpower_limits(), ath9k_ops, ath9k_set_hw_capab(), ath_hw_pll_work(), ATH_RSSI_DUMMY_MARKER, ath_rx_cleanup(), ath_rx_init(), ATH_RXBUF, ath_tx_cleanup(), ath_tx_init(), ATH_TXBUF, ath_softc::dev, error, ath_softc::hw_pll_work, ath_softc::hwinfo, ath_softc::last_rssi, and net80211_register().

Referenced by ath_pci_probe().

◆ ath9k_deinit_device()

void ath9k_deinit_device ( struct ath_softc sc)

Definition at line 578 of file ath9k_init.c.

579 {
580  struct net80211_device *dev = sc->dev;
581 
582  net80211_unregister(dev);
583  ath_rx_cleanup(sc);
584  ath_tx_cleanup(sc);
585  ath9k_deinit_softc(sc);
586 }
void net80211_unregister(struct net80211_device *dev)
Unregister 802.11 device from network stack.
Definition: net80211.c:825
void ath_tx_cleanup(struct ath_softc *sc)
Definition: ath9k_xmit.c:811
struct net80211_device * dev
Definition: ath9k.h:446
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
void ath_rx_cleanup(struct ath_softc *sc)
Definition: ath9k_recv.c:144
static void ath9k_deinit_softc(struct ath_softc *sc)
Definition: ath9k_init.c:562

References ath9k_deinit_softc(), ath_rx_cleanup(), ath_tx_cleanup(), ath_softc::dev, and net80211_unregister().

Referenced by ath_pci_remove().

◆ ath_descdma_cleanup()

void ath_descdma_cleanup ( struct ath_softc *sc  __unused,
struct ath_descdma dd,
struct list_head head 
)

Definition at line 588 of file ath9k_init.c.

591 {
592  free_phys(dd->dd_desc, dd->dd_desc_len);
593 
595  free(dd->dd_bufptr);
596  memset(dd, 0, sizeof(*dd));
597 }
uint8_t head
Head number.
Definition: int13.h:34
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:46
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:723
u32 dd_desc_len
Definition: ath9k.h:109
struct ath_buf * dd_bufptr
Definition: ath9k.h:110
void * dd_desc
Definition: ath9k.h:107
void * memset(void *dest, int character, size_t len) __nonnull

References ath_descdma::dd_bufptr, ath_descdma::dd_desc, ath_descdma::dd_desc_len, free, free_phys(), head, INIT_LIST_HEAD, and memset().

Variable Documentation

◆ is_ath9k_unloaded

int is_ath9k_unloaded

Definition at line 30 of file ath9k_init.c.

Referenced by ath_pci_remove().

◆ ath9k_2ghz_chantable

const struct net80211_channel ath9k_2ghz_chantable[]
static
Initial value:
= {
CHAN2G(2412, 0),
CHAN2G(2417, 1),
CHAN2G(2422, 2),
CHAN2G(2427, 3),
CHAN2G(2432, 4),
CHAN2G(2437, 5),
CHAN2G(2442, 6),
CHAN2G(2447, 7),
CHAN2G(2452, 8),
CHAN2G(2457, 9),
CHAN2G(2462, 10),
CHAN2G(2467, 11),
CHAN2G(2472, 12),
CHAN2G(2484, 13),
}
#define CHAN2G(_freq, _idx)
Definition: ath9k_init.c:33

Definition at line 51 of file ath9k_init.c.

Referenced by ath9k_init_channels_rates().

◆ ath9k_5ghz_chantable

const struct net80211_channel ath9k_5ghz_chantable[]
static
Initial value:
= {
CHAN5G(5180, 14),
CHAN5G(5200, 15),
CHAN5G(5220, 16),
CHAN5G(5240, 17),
CHAN5G(5260, 18),
CHAN5G(5280, 19),
CHAN5G(5300, 20),
CHAN5G(5320, 21),
CHAN5G(5500, 22),
CHAN5G(5520, 23),
CHAN5G(5540, 24),
CHAN5G(5560, 25),
CHAN5G(5580, 26),
CHAN5G(5600, 27),
CHAN5G(5620, 28),
CHAN5G(5640, 29),
CHAN5G(5660, 30),
CHAN5G(5680, 31),
CHAN5G(5700, 32),
CHAN5G(5745, 33),
CHAN5G(5765, 34),
CHAN5G(5785, 35),
CHAN5G(5805, 36),
CHAN5G(5825, 37),
}
#define CHAN5G(_freq, _idx)
Definition: ath9k_init.c:40

Definition at line 72 of file ath9k_init.c.

Referenced by ath9k_init_channels_rates().

◆ ath9k_legacy_rates

struct ath9k_legacy_rate ath9k_legacy_rates[]
static
Initial value:
= {
RATE(10, 0x1b, 0),
RATE(60, 0x0b, 0),
RATE(90, 0x0f, 0),
RATE(120, 0x0a, 0),
RATE(180, 0x0e, 0),
RATE(240, 0x09, 0),
RATE(360, 0x0d, 0),
RATE(480, 0x08, 0),
RATE(540, 0x0c, 0),
}
#define RATE(_bitrate, _hw_rate, _flags)
Definition: ath9k_init.c:107

Definition at line 114 of file ath9k_init.c.

Referenced by ath9k_init_channels_rates().