iPXE
Macros | Functions | Variables
ath9k_main.c File Reference
#include <ipxe/io.h>
#include "ath9k.h"

Go to the source code of this file.

Macros

#define SCHED_INTR
 

Functions

static void ath9k_bss_info_changed (struct net80211_device *dev, u32 changed)
 
int ath9k_setpower (struct ath_softc *sc, enum ath9k_power_mode mode)
 
static void ath_start_ani (struct ath_common *common)
 
static void ath_update_survey_nf (struct ath_softc *sc, int channel)
 
static int ath_update_survey_stats (struct ath_softc *sc)
 
int ath_set_channel (struct ath_softc *sc, struct net80211_device *dev, struct ath9k_channel *hchan)
 
void ath_ani_calibrate (struct ath_softc *sc)
 
void ath_hw_check (struct ath_softc *sc)
 
static void ath_hw_pll_rx_hang_check (struct ath_softc *sc, u32 pll_sqsum)
 
void ath_hw_pll_work (struct ath_softc *sc)
 
void ath9k_tasklet (struct ath_softc *sc)
 
void ath_isr (struct net80211_device *dev)
 
void ath_radio_disable (struct ath_softc *sc, struct net80211_device *dev)
 
int ath_reset (struct ath_softc *sc, int retry_tx)
 
static int ath9k_start (struct net80211_device *dev)
 
static int ath9k_tx (struct net80211_device *dev, struct io_buffer *iob)
 
static void ath9k_stop (struct net80211_device *dev)
 
static int ath9k_config (struct net80211_device *dev, int changed)
 
static void ath9k_bss_iter (struct ath_softc *sc)
 
static void ath9k_config_bss (struct ath_softc *sc)
 
static void ath9k_poll (struct net80211_device *dev)
 
static void ath9k_irq (struct net80211_device *dev, int enable)
 

Variables

struct net80211_device_operations ath9k_ops
 

Macro Definition Documentation

◆ SCHED_INTR

#define SCHED_INTR
Value:
( \
ATH9K_INT_FATAL | \
ATH9K_INT_BB_WATCHDOG | \
ATH9K_INT_RXORN | \
ATH9K_INT_RXEOL | \
ATH9K_INT_RX | \
ATH9K_INT_RXLP | \
ATH9K_INT_RXHP | \
ATH9K_INT_TX | \
ATH9K_INT_BMISS | \
ATH9K_INT_CST | \
ATH9K_INT_TSFOOR | \
ATH9K_INT_GENTIMER)

Function Documentation

◆ ath9k_bss_info_changed()

static void ath9k_bss_info_changed ( struct net80211_device dev,
u32  changed 
)
static

Definition at line 854 of file ath9k_main.c.

856 {
857  struct ath_softc *sc = dev->priv;
858  struct ath_hw *ah = sc->sc_ah;
859  struct ath_common *common = ath9k_hw_common(ah);
860  int slottime;
861 
862  if (changed & NET80211_CFG_ASSOC) {
863  ath9k_config_bss(sc);
864 
865  DBG2("ath9k: BSSID: %pM aid: 0x%x\n",
866  common->curbssid, common->curaid);
867  }
868 
869  if (changed & NET80211_CFG_PHY_PARAMS) {
871  slottime = 9;
872  else
873  slottime = 20;
874  ah->slottime = slottime;
876 
877  DBG2("ath9k: BSS Changed PREAMBLE %d\n",
881  else
883 
884  DBG2("ath9k: BSS Changed CTS PROT %d\n",
887  (dev->channels + dev->channel)->band != NET80211_BAND_5GHZ)
889  else
891  }
892 }
Definition: hw.h:656
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
void ath9k_hw_init_global_settings(struct ath_hw *ah)
Definition: ath9k_hw.c:812
#define SC_OP_PREAMBLE_SHORT
Definition: ath9k.h:367
struct net80211_device * dev
Definition: ath9k.h:445
struct ath_hw * sc_ah
Definition: ath9k.h:454
#define NET80211_BAND_5GHZ
The band from 4.9 GHz to 5.7 GHz, which tends to be more restricted.
Definition: net80211.h:47
void * priv
Driver private data.
Definition: net80211.h:798
#define NET80211_PHY_USE_SHORT_PREAMBLE
Whether to use 802.11b short preamble operation.
Definition: net80211.h:260
#define NET80211_PHY_USE_PROTECTION
Whether to use RTS/CTS or CTS-to-self protection for transmissions.
Definition: net80211.h:251
#define NET80211_CFG_PHY_PARAMS
Low-level link parameters (short preamble, protection, etc) have changed.
Definition: net80211.h:90
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
struct ib_cm_common common
Definition: ib_mad.h:11
u32 sc_flags
Definition: ath9k.h:465
int phy_flags
Physical layer options.
Definition: net80211.h:983
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
uint8_t ah
Definition: registers.h:85
struct net80211_device * dev
Definition: ath.h:197
#define SC_OP_PROTECT_ENABLE
Definition: ath9k.h:368
#define NET80211_CFG_ASSOC
Association has been established with a new BSS (dev->bssid)
Definition: net80211.h:87
#define DBG2(...)
Definition: compiler.h:515
static void ath9k_config_bss(struct ath_softc *sc)
Definition: ath9k_main.c:825

References ah, ath9k_config_bss(), ath9k_hw_common(), ath9k_hw_init_global_settings(), net80211_device::channel, net80211_device::channels, common, DBG2, ath_common::dev, ath_softc::dev, NET80211_BAND_5GHZ, NET80211_CFG_ASSOC, NET80211_CFG_PHY_PARAMS, NET80211_PHY_USE_PROTECTION, NET80211_PHY_USE_SHORT_PREAMBLE, net80211_device::phy_flags, net80211_device::priv, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_PREAMBLE_SHORT, and SC_OP_PROTECT_ENABLE.

Referenced by ath9k_config().

◆ ath9k_setpower()

int ath9k_setpower ( struct ath_softc sc,
enum ath9k_power_mode  mode 
)

Definition at line 26 of file ath9k_main.c.

27 {
28  int ret;
29 
30  ret = ath9k_hw_setpower(sc->sc_ah, mode);
31 
32  return ret;
33 }
struct ath_hw * sc_ah
Definition: ath9k.h:454
int ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
Definition: ath9k_hw.c:1532

References ath9k_hw_setpower(), and ath_softc::sc_ah.

Referenced by ath_isr().

◆ ath_start_ani()

static void ath_start_ani ( struct ath_common common)
static

Definition at line 35 of file ath9k_main.c.

36 {
37  struct ath_hw *ah = common->ah;
38  unsigned long timestamp = ( currticks() * 1000 ) / TICKS_PER_SEC;
39  struct ath_softc *sc = (struct ath_softc *) common->priv;
40 
41  if (!(sc->sc_flags & SC_OP_ANI_RUN))
42  return;
43 
44  if (sc->sc_flags & SC_OP_OFFCHANNEL)
45  return;
46 
47  common->ani.longcal_timer = timestamp;
48  common->ani.shortcal_timer = timestamp;
49  common->ani.checkani_timer = timestamp;
50 
51  common->ani.timer = timestamp + ah->config.ani_poll_interval;
52 }
Definition: hw.h:656
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
#define SC_OP_ANI_RUN
Definition: ath9k.h:375
#define SC_OP_OFFCHANNEL
Definition: ath9k.h:366
__be64 timestamp
Definition: CIB_PRM.h:38
struct ib_cm_common common
Definition: ib_mad.h:11
u32 sc_flags
Definition: ath9k.h:465
uint8_t ah
Definition: registers.h:85
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
if(natsemi->flags &NATSEMI_64BIT) return 1

References ah, common, currticks(), if(), ath_softc::sc_flags, SC_OP_ANI_RUN, SC_OP_OFFCHANNEL, TICKS_PER_SEC, and timestamp.

Referenced by ath9k_bss_iter(), ath_reset(), and ath_set_channel().

◆ ath_update_survey_nf()

static void ath_update_survey_nf ( struct ath_softc sc,
int  channel 
)
static

Definition at line 54 of file ath9k_main.c.

55 {
56  struct ath_hw *ah = sc->sc_ah;
57  struct ath9k_channel *chan = &ah->channels[channel];
58  struct survey_info *survey = &sc->survey[channel];
59 
60  if (chan->noisefloor) {
61  survey->filled |= SURVEY_INFO_NOISE_DBM;
62  survey->noise = chan->noisefloor;
63  }
64 }
s8 noise
Definition: ath9k.h:417
Definition: hw.h:656
struct net80211_channel * chan
Definition: hw.h:347
struct ath_hw * sc_ah
Definition: ath9k.h:454
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
u32 filled
Definition: ath9k.h:416
s16 noisefloor
Definition: hw.h:352
struct survey_info survey[ATH9K_NUM_CHANNELS]
Definition: ath9k.h:451
uint8_t ah
Definition: registers.h:85

References ah, ath9k_channel::chan, channel, survey_info::filled, survey_info::noise, ath9k_channel::noisefloor, ath_softc::sc_ah, ath_softc::survey, and SURVEY_INFO_NOISE_DBM.

Referenced by ath9k_config(), and ath_update_survey_stats().

◆ ath_update_survey_stats()

static int ath_update_survey_stats ( struct ath_softc sc)
static

Definition at line 71 of file ath9k_main.c.

72 {
73  struct ath_hw *ah = sc->sc_ah;
75  int pos = ah->curchan - &ah->channels[0];
76  struct survey_info *survey = &sc->survey[pos];
77  struct ath_cycle_counters *cc = &common->cc_survey;
78  unsigned int div = common->clockrate * 1000;
79  int ret = 0;
80 
81  if (!ah->curchan)
82  return -1;
83 
84  if (ah->power_mode == ATH9K_PM_AWAKE)
86 
87  if (cc->cycles > 0) {
88  survey->filled |= SURVEY_INFO_CHANNEL_TIME |
92  survey->channel_time += cc->cycles / div;
93  survey->channel_time_busy += cc->rx_busy / div;
94  survey->channel_time_rx += cc->rx_frame / div;
95  survey->channel_time_tx += cc->tx_frame / div;
96  }
97 
98  if (cc->cycles < div)
99  return -1;
100 
101  if (cc->cycles > 0)
102  ret = cc->rx_busy * 100 / cc->cycles;
103 
104  memset(cc, 0, sizeof(*cc));
105 
106  ath_update_survey_nf(sc, pos);
107 
108  return ret;
109 }
Definition: hw.h:656
u64 channel_time
Definition: ath9k.h:411
u64 channel_time_rx
Definition: ath9k.h:414
static void ath_update_survey_nf(struct ath_softc *sc, int channel)
Definition: ath9k_main.c:54
u64 channel_time_busy
Definition: ath9k.h:412
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
struct ath_hw * sc_ah
Definition: ath9k.h:454
u32 filled
Definition: ath9k.h:416
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
struct ib_cm_common common
Definition: ib_mad.h:11
u64 channel_time_tx
Definition: ath9k.h:415
struct survey_info survey[ATH9K_NUM_CHANNELS]
Definition: ath9k.h:451
uint8_t ah
Definition: registers.h:85
void * memset(void *dest, int character, size_t len) __nonnull

References ah, ath9k_hw_common(), ATH9K_PM_AWAKE, ath_hw_cycle_counters_update(), ath_update_survey_nf(), survey_info::channel_time, survey_info::channel_time_busy, survey_info::channel_time_rx, survey_info::channel_time_tx, common, ath_cycle_counters::cycles, survey_info::filled, memset(), ath_cycle_counters::rx_busy, ath_cycle_counters::rx_frame, ath_softc::sc_ah, ath_softc::survey, SURVEY_INFO_CHANNEL_TIME, SURVEY_INFO_CHANNEL_TIME_BUSY, SURVEY_INFO_CHANNEL_TIME_RX, SURVEY_INFO_CHANNEL_TIME_TX, and ath_cycle_counters::tx_frame.

Referenced by ath9k_config(), ath_ani_calibrate(), and ath_hw_check().

◆ ath_set_channel()

int ath_set_channel ( struct ath_softc sc,
struct net80211_device dev,
struct ath9k_channel hchan 
)

Definition at line 116 of file ath9k_main.c.

118 {
119  struct ath_hw *ah = sc->sc_ah;
120  struct ath_common *common = ath9k_hw_common(ah);
121  int fastcc __unused = 1, stopped __unused;
122  struct net80211_channel *channel = dev->channels + dev->channel;
123  struct ath9k_hw_cal_data *caldata = NULL;
124  int r;
125 
126  if (sc->sc_flags & SC_OP_INVALID)
127  return -EIO;
128 
129  sc->hw_busy_count = 0;
130 
131  common->ani.timer = 0;
132  sc->tx_complete_work_timer = 0;
133  sc->hw_pll_work_timer = 0;
134 
135  /*
136  * This is only performed if the channel settings have
137  * actually changed.
138  *
139  * To switch channels clear any pending DMA operations;
140  * wait long enough for the RX fifo to drain, reset the
141  * hardware at the new frequency, and then re-enable
142  * the relevant bits of the h/w.
143  */
145  stopped = ath_drain_all_txq(sc, 0);
146 
147  if (!ath_stoprecv(sc))
148  stopped = 0;
149 
150  if (!ath9k_hw_check_alive(ah))
151  stopped = 0;
152 
153  /* XXX: do not flush receive queue here. We don't want
154  * to flush data frames already in queue because of
155  * changing channel. */
156 
157  if (!(sc->sc_flags & SC_OP_OFFCHANNEL))
158  caldata = &sc->caldata;
159 
160  DBG2("ath9k: "
161  "(%d MHz) -> (%d MHz)\n",
162  sc->sc_ah->curchan->channel,
163  channel->center_freq);
164 
165  r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
166  if (r) {
167  DBG("ath9k: "
168  "Unable to reset channel (%d MHz), reset status %d\n",
169  channel->center_freq, r);
170  goto ps_restore;
171  }
172 
173  if (ath_startrecv(sc) != 0) {
174  DBG("ath9k: Unable to restart recv logic\n");
175  r = -EIO;
176  goto ps_restore;
177  }
178 
180  sc->config.txpowlimit, &sc->curtxpow);
181  ath9k_hw_set_interrupts(ah, ah->imask);
182 
183  if (!(sc->sc_flags & (SC_OP_OFFCHANNEL))) {
184  sc->tx_complete_work(sc);
185  sc->hw_pll_work_timer = (currticks() * 1000 ) / TICKS_PER_SEC + 500;
187  }
188 
189  ps_restore:
190  return r;
191 }
u16 channel
Definition: hw.h:349
Definition: hw.h:656
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
unsigned long tx_complete_work_timer
Definition: ath9k.h:485
int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, struct ath9k_hw_cal_data *caldata, int bChannelChange)
Definition: ath9k_hw.c:1216
struct ath9k_channel * curchan
Definition: hw.h:665
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
static void ath_start_ani(struct ath_common *common)
Definition: ath9k_main.c:35
void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow, u16 new_txpow, u16 *txpower)
Definition: ath9k_common.c:61
int ath_drain_all_txq(struct ath_softc *sc, int retry_tx)
Definition: ath9k_xmit.c:216
#define SC_OP_OFFCHANNEL
Definition: ath9k.h:366
void(* tx_complete_work)(struct ath_softc *sc)
Definition: ath9k.h:484
struct ath_hw * sc_ah
Definition: ath9k.h:454
struct ath_config config
Definition: ath9k.h:474
void ath9k_hw_set_interrupts(struct ath_hw *ah, unsigned int ints)
Definition: ath9k_mac.c:641
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
void ath9k_hw_disable_interrupts(struct ath_hw *ah)
Definition: ath9k_mac.c:602
An 802.11 RF channel.
Definition: net80211.h:385
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
u16 curtxpow
Definition: ath9k.h:467
unsigned int hw_busy_count
Definition: ath9k.h:462
struct ib_cm_common common
Definition: ib_mad.h:11
u32 sc_flags
Definition: ath9k.h:465
#define SC_OP_INVALID
Definition: ath9k.h:362
unsigned long hw_pll_work_timer
Definition: ath9k.h:487
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
int ath_startrecv(struct ath_softc *sc)
Definition: ath9k_recv.c:194
struct ath9k_hw_cal_data caldata
Definition: ath9k.h:481
#define EIO
Input/output error.
Definition: errno.h:433
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
int ath9k_hw_check_alive(struct ath_hw *ah)
Definition: ath9k_hw.c:1189
u16 txpowlimit
Definition: ath9k.h:65
uint8_t ah
Definition: registers.h:85
int ath_stoprecv(struct ath_softc *sc)
Definition: ath9k_recv.c:222
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define DBG2(...)
Definition: compiler.h:515
static const uint8_t r[3][4]
MD4 shift amounts.
Definition: md4.c:54

References __unused, ah, ath9k_cmn_update_txpow(), ath9k_hw_check_alive(), ath9k_hw_common(), ath9k_hw_disable_interrupts(), ath9k_hw_reset(), ath9k_hw_set_interrupts(), ath_drain_all_txq(), ath_start_ani(), ath_startrecv(), ath_stoprecv(), ath_softc::caldata, channel, ath9k_channel::channel, net80211_device::channel, net80211_device::channels, common, ath_softc::config, ath_hw::curchan, currticks(), ath_softc::curtxpow, DBG, DBG2, EIO, ath_softc::hw_busy_count, ath_softc::hw_pll_work_timer, NULL, r, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_INVALID, SC_OP_OFFCHANNEL, TICKS_PER_SEC, ath_softc::tx_complete_work, ath_softc::tx_complete_work_timer, and ath_config::txpowlimit.

Referenced by ath9k_config().

◆ ath_ani_calibrate()

void ath_ani_calibrate ( struct ath_softc sc)

Definition at line 200 of file ath9k_main.c.

201 {
202  struct ath_hw *ah = sc->sc_ah;
203  struct ath_common *common = ath9k_hw_common(ah);
204  int longcal = 0;
205  int shortcal = 0;
206  int aniflag = 0;
207  unsigned int timestamp = (currticks() * 1000 ) / TICKS_PER_SEC;
208  u32 cal_interval, short_cal_interval, long_cal_interval;
209 
210  if (ah->caldata && ah->caldata->nfcal_interference)
211  long_cal_interval = ATH_LONG_CALINTERVAL_INT;
212  else
213  long_cal_interval = ATH_LONG_CALINTERVAL;
214 
215  short_cal_interval = ATH_STA_SHORT_CALINTERVAL;
216 
217  /* Only calibrate if awake */
218  if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE)
219  goto set_timer;
220 
221  /* Long calibration runs independently of short calibration. */
222  if ((timestamp - common->ani.longcal_timer) >= long_cal_interval) {
223  longcal = 1;
224  DBG2("ath9k: longcal @%d\n", timestamp);
225  common->ani.longcal_timer = timestamp;
226  }
227 
228  /* Short calibration applies only while caldone is false */
229  if (!common->ani.caldone) {
230  if ((timestamp - common->ani.shortcal_timer) >= short_cal_interval) {
231  shortcal = 1;
232  DBG2("ath9k: "
233  "shortcal @%d\n", timestamp);
234  common->ani.shortcal_timer = timestamp;
235  common->ani.resetcal_timer = timestamp;
236  }
237  } else {
238  if ((timestamp - common->ani.resetcal_timer) >=
240  common->ani.caldone = ath9k_hw_reset_calvalid(ah);
241  if (common->ani.caldone)
242  common->ani.resetcal_timer = timestamp;
243  }
244  }
245 
246  /* Verify whether we must check ANI */
247  if ((timestamp - common->ani.checkani_timer) >=
248  ah->config.ani_poll_interval) {
249  aniflag = 1;
250  common->ani.checkani_timer = timestamp;
251  }
252 
253  /* Skip all processing if there's nothing to do. */
254  if (longcal || shortcal || aniflag) {
255  /* Call ANI routine if necessary */
256  if (aniflag) {
257  ath9k_hw_ani_monitor(ah, ah->curchan);
259  }
260 
261  /* Perform calibration if necessary */
262  if (longcal || shortcal) {
263  common->ani.caldone =
265  ah->curchan,
266  common->rx_chainmask,
267  longcal);
268  }
269  }
270 
271 set_timer:
272  /*
273  * Set timer interval based on previous results.
274  * The interval must be the shortest necessary to satisfy ANI,
275  * short calibration and long calibration.
276  */
277  cal_interval = ATH_LONG_CALINTERVAL;
278  if (sc->sc_ah->config.enable_ani)
279  cal_interval = min(cal_interval,
280  (u32)ah->config.ani_poll_interval);
281  if (!common->ani.caldone)
282  cal_interval = min(cal_interval, (u32)short_cal_interval);
283 
284  common->ani.timer = timestamp + cal_interval;
285 }
Definition: hw.h:656
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
u32 enable_ani
Definition: hw.h:231
#define ATH_STA_SHORT_CALINTERVAL
Definition: ath9k.h:334
#define ATH_RESTART_CALINTERVAL
Definition: ath9k.h:340
#define min(x, y)
Definition: ath.h:34
enum ath9k_power_mode power_mode
Definition: hw.h:691
void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan __unused)
Definition: ath9k_ani.c:597
int ath9k_hw_reset_calvalid(struct ath_hw *ah)
Definition: ath9k_calib.c:173
__be64 timestamp
Definition: CIB_PRM.h:38
struct ath_hw * sc_ah
Definition: ath9k.h:454
#define ATH_LONG_CALINTERVAL_INT
Definition: ath9k.h:338
struct ath9k_ops_config config
Definition: hw.h:662
static int ath_update_survey_stats(struct ath_softc *sc)
Definition: ath9k_main.c:71
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
static int ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, u8 rxchainmask, int longcal)
Definition: hw-ops.h:49
struct ib_cm_common common
Definition: ib_mad.h:11
#define ATH_LONG_CALINTERVAL
Definition: ath9k.h:339
uint8_t ah
Definition: registers.h:85
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
uint32_t u32
Definition: stdint.h:23
#define DBG2(...)
Definition: compiler.h:515

References ah, ath9k_hw_ani_monitor(), ath9k_hw_calibrate(), ath9k_hw_common(), ath9k_hw_reset_calvalid(), ATH9K_PM_AWAKE, ATH_LONG_CALINTERVAL, ATH_LONG_CALINTERVAL_INT, ATH_RESTART_CALINTERVAL, ATH_STA_SHORT_CALINTERVAL, ath_update_survey_stats(), common, ath_hw::config, currticks(), DBG2, ath9k_ops_config::enable_ani, min, ath_hw::power_mode, ath_softc::sc_ah, TICKS_PER_SEC, and timestamp.

Referenced by ath_isr().

◆ ath_hw_check()

void ath_hw_check ( struct ath_softc sc)

Definition at line 287 of file ath9k_main.c.

288 {
289  int busy;
290 
291  if (ath9k_hw_check_alive(sc->sc_ah))
292  goto out;
293 
294  busy = ath_update_survey_stats(sc);
295 
296  DBG("ath9k: Possible baseband hang, "
297  "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
298  if (busy >= 99) {
299  if (++sc->hw_busy_count >= 3)
300  ath_reset(sc, 1);
301  } else if (busy >= 0)
302  sc->hw_busy_count = 0;
303 
304 out:
305  return;
306 }
struct ath_hw * sc_ah
Definition: ath9k.h:454
__be32 out[4]
Definition: CIB_PRM.h:36
static int ath_update_survey_stats(struct ath_softc *sc)
Definition: ath9k_main.c:71
int ath_reset(struct ath_softc *sc, int retry_tx)
Definition: ath9k_main.c:511
unsigned int hw_busy_count
Definition: ath9k.h:462
int ath9k_hw_check_alive(struct ath_hw *ah)
Definition: ath9k_hw.c:1189
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References ath9k_hw_check_alive(), ath_reset(), ath_update_survey_stats(), DBG, ath_softc::hw_busy_count, out, and ath_softc::sc_ah.

◆ ath_hw_pll_rx_hang_check()

static void ath_hw_pll_rx_hang_check ( struct ath_softc sc,
u32  pll_sqsum 
)
static

Definition at line 308 of file ath9k_main.c.

309 {
310  static int count;
311 
312  if (pll_sqsum >= 0x40000) {
313  count++;
314  if (count == 3) {
315  /* Rx is hung for more than 500ms. Reset it */
316  DBG("ath9k: "
317  "Possible RX hang, resetting");
318  ath_reset(sc, 1);
319  count = 0;
320  }
321  } else
322  count = 0;
323 }
int ath_reset(struct ath_softc *sc, int retry_tx)
Definition: ath9k_main.c:511
uint16_t count
Number of entries.
Definition: ena.h:22
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References ath_reset(), count, and DBG.

Referenced by ath_hw_pll_work().

◆ ath_hw_pll_work()

void ath_hw_pll_work ( struct ath_softc sc)

Definition at line 325 of file ath9k_main.c.

326 {
327  u32 pll_sqsum;
328 
329  if (AR_SREV_9485(sc->sc_ah)) {
330  pll_sqsum = ar9003_get_pll_sqsum_dvc(sc->sc_ah);
331 
332  ath_hw_pll_rx_hang_check(sc, pll_sqsum);
333 
334  sc->hw_pll_work_timer = (currticks() * 1000 ) / TICKS_PER_SEC + 200;
335  }
336 }
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah)
Definition: ath9k_hw.c:609
#define AR_SREV_9485(_ah)
Definition: reg.h:867
static void ath_hw_pll_rx_hang_check(struct ath_softc *sc, u32 pll_sqsum)
Definition: ath9k_main.c:308
struct ath_hw * sc_ah
Definition: ath9k.h:454
unsigned long hw_pll_work_timer
Definition: ath9k.h:487
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
uint32_t u32
Definition: stdint.h:23

References ar9003_get_pll_sqsum_dvc(), AR_SREV_9485, ath_hw_pll_rx_hang_check(), currticks(), ath_softc::hw_pll_work_timer, ath_softc::sc_ah, and TICKS_PER_SEC.

Referenced by ath9k_init_device().

◆ ath9k_tasklet()

void ath9k_tasklet ( struct ath_softc sc)

Definition at line 339 of file ath9k_main.c.

340 {
341  struct ath_hw *ah = sc->sc_ah;
342 
343  u32 status = sc->intrstatus;
344  u32 rxmask;
345 
346  if ((status & ATH9K_INT_FATAL) ||
348  ath_reset(sc, 1);
349  return;
350  }
351 
353 
354  if (status & rxmask) {
355  ath_rx_tasklet(sc, 0, 0);
356  }
357 
358  if (status & ATH9K_INT_TX) {
359  ath_tx_tasklet(sc);
360  }
361 
362  /* re-enable hardware interrupt */
364 }
Definition: hw.h:656
void ath9k_hw_enable_interrupts(struct ath_hw *ah)
Definition: ath9k_mac.c:616
int ath_rx_tasklet(struct ath_softc *sc, int flush, int hp)
Definition: ath9k_recv.c:430
void ath_tx_tasklet(struct ath_softc *sc)
Definition: ath9k_xmit.c:771
uint8_t status
Status.
Definition: ena.h:16
struct ath_hw * sc_ah
Definition: ath9k.h:454
int ath_reset(struct ath_softc *sc, int retry_tx)
Definition: ath9k_main.c:511
u32 intrstatus
Definition: ath9k.h:464
uint8_t ah
Definition: registers.h:85
uint32_t u32
Definition: stdint.h:23

References ah, ath9k_hw_enable_interrupts(), ATH9K_INT_BB_WATCHDOG, ATH9K_INT_FATAL, ATH9K_INT_RX, ATH9K_INT_RXEOL, ATH9K_INT_RXORN, ATH9K_INT_TX, ath_reset(), ath_rx_tasklet(), ath_tx_tasklet(), ath_softc::intrstatus, ath_softc::sc_ah, and status.

Referenced by ath9k_init_softc().

◆ ath_isr()

void ath_isr ( struct net80211_device dev)

Definition at line 366 of file ath9k_main.c.

367 {
368 #define SCHED_INTR ( \
369  ATH9K_INT_FATAL | \
370  ATH9K_INT_BB_WATCHDOG | \
371  ATH9K_INT_RXORN | \
372  ATH9K_INT_RXEOL | \
373  ATH9K_INT_RX | \
374  ATH9K_INT_RXLP | \
375  ATH9K_INT_RXHP | \
376  ATH9K_INT_TX | \
377  ATH9K_INT_BMISS | \
378  ATH9K_INT_CST | \
379  ATH9K_INT_TSFOOR | \
380  ATH9K_INT_GENTIMER)
381 
382  struct ath_softc *sc = dev->priv;
383  struct ath_hw *ah = sc->sc_ah;
384  struct ath_common *common = ath9k_hw_common(ah);
385  enum ath9k_int status;
386  unsigned long timestamp = (currticks() * 1000 ) / TICKS_PER_SEC;
387  int sched = 0;
388 
389  /*
390  * The hardware is not ready/present, don't
391  * touch anything. Note this can happen early
392  * on if the IRQ is shared.
393  */
394  if (sc->sc_flags & SC_OP_INVALID)
395  return;
396 
397 
398  /* Check calibration */
399  if(timestamp >= (unsigned int)common->ani.timer && common->ani.timer)
400  ath_ani_calibrate(sc);
401 
402  /* Check tx_complete_work */
403  if(timestamp >= (unsigned int)sc->tx_complete_work_timer && sc->tx_complete_work_timer)
404  sc->tx_complete_work(sc);
405 
406  /* Check hw_pll_work */
407  if(timestamp >= (unsigned int)sc->hw_pll_work_timer && sc->hw_pll_work_timer)
408  sc->hw_pll_work(sc);
409 
410  /* shared irq, not for us */
411 
412  if (!ath9k_hw_intrpend(ah))
413  return;
414 
415  /*
416  * Figure out the reason(s) for the interrupt. Note
417  * that the hal returns a pseudo-ISR that may include
418  * bits we haven't explicitly enabled so we mask the
419  * value to insure we only process bits we requested.
420  */
421  ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
422  status &= ah->imask; /* discard unasked-for bits */
423 
424  /*
425  * If there are no status bits set, then this interrupt was not
426  * for me (should have been caught above).
427  */
428  if (!status)
429  return;
430 
431  /* Cache the status */
432  sc->intrstatus = status;
433 
434  if (status & SCHED_INTR)
435  sched = 1;
436 
437  /*
438  * If a FATAL or RXORN interrupt is received, we have to reset the
439  * chip immediately.
440  */
442  goto chip_reset;
443 
444  if (status & ATH9K_INT_TXURN)
446 
447  if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
448  if (status & ATH9K_INT_TIM_TIMER) {
449  if (sc->ps_idle)
450  goto chip_reset;
451  /* Clear RxAbort bit so that we can
452  * receive frames */
454  ath9k_hw_setrxabort(sc->sc_ah, 0);
456  }
457 
458 chip_reset:
459 
460  if (sched) {
461  /* turn off every interrupt */
463  sc->intr_tq(sc);
464  }
465 
466  return;
467 
468 #undef SCHED_INTR
469 }
static int ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked)
Definition: hw-ops.h:57
Definition: hw.h:656
int ath9k_hw_setrxabort(struct ath_hw *ah, int set)
Definition: ath9k_mac.c:490
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
unsigned long tx_complete_work_timer
Definition: ath9k.h:485
int ps_idle
Definition: ath9k.h:469
u16 ps_flags
Definition: ath9k.h:466
ath9k_int
Definition: hw.h:251
int ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode)
Definition: ath9k_main.c:26
uint8_t status
Status.
Definition: ena.h:16
struct net80211_device * dev
Definition: ath9k.h:445
void(* tx_complete_work)(struct ath_softc *sc)
Definition: ath9k.h:484
void ath_ani_calibrate(struct ath_softc *sc)
Definition: ath9k_main.c:200
__be64 timestamp
Definition: CIB_PRM.h:38
struct ath_hw * sc_ah
Definition: ath9k.h:454
#define SCHED_INTR
int ath9k_hw_intrpend(struct ath_hw *ah)
Definition: ath9k_mac.c:583
void(* hw_pll_work)(struct ath_softc *sc)
Definition: ath9k.h:486
void ath9k_hw_disable_interrupts(struct ath_hw *ah)
Definition: ath9k_mac.c:602
void * priv
Driver private data.
Definition: net80211.h:798
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
int ath9k_hw_updatetxtriglevel(struct ath_hw *ah, int bIncTrigLevel)
ath9k_hw_updatetxtriglevel - adjusts the frame trigger level
Definition: ath9k_mac.c:101
struct ib_cm_common common
Definition: ib_mad.h:11
u32 sc_flags
Definition: ath9k.h:465
#define SC_OP_INVALID
Definition: ath9k.h:362
unsigned long hw_pll_work_timer
Definition: ath9k.h:487
#define PS_WAIT_FOR_BEACON
Definition: ath9k.h:380
u32 intrstatus
Definition: ath9k.h:464
void(* intr_tq)(struct ath_softc *sc)
Definition: ath9k.h:453
uint8_t ah
Definition: registers.h:85
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42

References ah, ATH9K_HW_CAP_AUTOSLEEP, ath9k_hw_common(), ath9k_hw_disable_interrupts(), ath9k_hw_getisr(), ath9k_hw_intrpend(), ath9k_hw_setrxabort(), ath9k_hw_updatetxtriglevel(), ATH9K_INT_FATAL, ATH9K_INT_RXORN, ATH9K_INT_TIM_TIMER, ATH9K_INT_TXURN, ATH9K_PM_AWAKE, ath9k_setpower(), ath_ani_calibrate(), common, currticks(), ath_softc::dev, ath_softc::hw_pll_work, ath_softc::hw_pll_work_timer, ath_softc::intr_tq, ath_softc::intrstatus, net80211_device::priv, ath_softc::ps_flags, ath_softc::ps_idle, PS_WAIT_FOR_BEACON, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_INVALID, SCHED_INTR, status, TICKS_PER_SEC, timestamp, ath_softc::tx_complete_work, and ath_softc::tx_complete_work_timer.

Referenced by ath9k_poll().

◆ ath_radio_disable()

void ath_radio_disable ( struct ath_softc sc,
struct net80211_device dev 
)

Definition at line 471 of file ath9k_main.c.

472 {
473  struct ath_hw *ah = sc->sc_ah;
474  struct net80211_channel *channel = dev->channels + dev->channel;
475  int r;
476 
477  sc->hw_pll_work_timer = 0;
478 
479  /*
480  * Keep the LED on when the radio is disabled
481  * during idle unassociated state.
482  */
483  if (!sc->ps_idle) {
484  ath9k_hw_set_gpio(ah, ah->led_pin, 1);
485  ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
486  }
487 
488  /* Disable interrupts */
490 
491  ath_drain_all_txq(sc, 0); /* clear pending tx frames */
492 
493  ath_stoprecv(sc); /* turn off frame recv */
494  ath_flushrecv(sc); /* flush recv queue */
495 
496  if (!ah->curchan)
497  ah->curchan = ath9k_cmn_get_curchannel(dev, ah);
498 
499  r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, 0);
500  if (r) {
501  DBG("ath9k: "
502  "Unable to reset channel (%d MHz), reset status %d\n",
503  channel->center_freq, r);
504  }
505 
507 
509 }
Definition: hw.h:656
int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, struct ath9k_hw_cal_data *caldata, int bChannelChange)
Definition: ath9k_hw.c:1216
int ps_idle
Definition: ath9k.h:469
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
static void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off)
Definition: hw-ops.h:26
int ath_drain_all_txq(struct ath_softc *sc, int retry_tx)
Definition: ath9k_xmit.c:216
struct ath_hw * sc_ah
Definition: ath9k.h:454
void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val)
Definition: ath9k_hw.c:1850
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
struct ath9k_channel * ath9k_cmn_get_curchannel(struct net80211_device *dev, struct ath_hw *ah)
Definition: ath9k_common.c:47
int ath9k_hw_phy_disable(struct ath_hw *ah)
Definition: ath9k_hw.c:1916
void ath9k_hw_disable_interrupts(struct ath_hw *ah)
Definition: ath9k_mac.c:602
void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio)
Definition: ath9k_hw.c:1783
An 802.11 RF channel.
Definition: net80211.h:385
unsigned long hw_pll_work_timer
Definition: ath9k.h:487
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
void ath_flushrecv(struct ath_softc *sc)
Definition: ath9k_recv.c:242
uint8_t ah
Definition: registers.h:85
int ath_stoprecv(struct ath_softc *sc)
Definition: ath9k_recv.c:222
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static const uint8_t r[3][4]
MD4 shift amounts.
Definition: md4.c:54

References ah, ath9k_cmn_get_curchannel(), ath9k_hw_cfg_gpio_input(), ath9k_hw_configpcipowersave(), ath9k_hw_disable_interrupts(), ath9k_hw_phy_disable(), ath9k_hw_reset(), ath9k_hw_set_gpio(), ath_drain_all_txq(), ath_flushrecv(), ath_stoprecv(), channel, net80211_device::channel, net80211_device::channels, DBG, ath_softc::hw_pll_work_timer, ath_softc::ps_idle, r, and ath_softc::sc_ah.

Referenced by ath9k_stop().

◆ ath_reset()

int ath_reset ( struct ath_softc sc,
int  retry_tx 
)

Definition at line 511 of file ath9k_main.c.

512 {
513  struct ath_hw *ah = sc->sc_ah;
514  struct ath_common *common = ath9k_hw_common(ah);
515  int r;
516 
517  sc->hw_busy_count = 0;
518 
519  /* Stop ANI */
520  common->ani.timer = 0;
521 
523  ath_drain_all_txq(sc, retry_tx);
524 
525  ath_stoprecv(sc);
526  ath_flushrecv(sc);
527 
528  r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, 0);
529  if (r)
530  DBG("ath9k: "
531  "Unable to reset hardware; reset status %d\n", r);
532 
533  if (ath_startrecv(sc) != 0)
534  DBG("ath9k: Unable to start recv logic\n");
535 
536  /*
537  * We may be doing a reset in response to a request
538  * that changes the channel so update any state that
539  * might change as a result.
540  */
542  sc->config.txpowlimit, &sc->curtxpow);
543 
544  ath9k_hw_set_interrupts(ah, ah->imask);
545 
546  if (retry_tx) {
547  int i;
548  for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
549  if (ATH_TXQ_SETUP(sc, i)) {
550  ath_txq_schedule(sc, &sc->tx.txq[i]);
551  }
552  }
553  }
554 
555  /* Start ANI */
557 
558  return r;
559 }
Definition: hw.h:656
int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, struct ath9k_hw_cal_data *caldata, int bChannelChange)
Definition: ath9k_hw.c:1216
struct ath9k_channel * curchan
Definition: hw.h:665
#define ATH_TXQ_SETUP(sc, i)
Definition: ath9k.h:62
static void ath_start_ani(struct ath_common *common)
Definition: ath9k_main.c:35
struct ath_txq txq[ATH9K_NUM_TX_QUEUES]
Definition: ath9k.h:285
void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow, u16 new_txpow, u16 *txpower)
Definition: ath9k_common.c:61
int ath_drain_all_txq(struct ath_softc *sc, int retry_tx)
Definition: ath9k_xmit.c:216
void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
struct ath_hw * sc_ah
Definition: ath9k.h:454
struct ath_config config
Definition: ath9k.h:474
void ath9k_hw_set_interrupts(struct ath_hw *ah, unsigned int ints)
Definition: ath9k_mac.c:641
void ath9k_hw_disable_interrupts(struct ath_hw *ah)
Definition: ath9k_mac.c:602
#define ATH9K_NUM_TX_QUEUES
Definition: mac.h:580
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
u16 curtxpow
Definition: ath9k.h:467
struct ath_tx tx
Definition: ath9k.h:476
unsigned int hw_busy_count
Definition: ath9k.h:462
struct ib_cm_common common
Definition: ib_mad.h:11
int ath_startrecv(struct ath_softc *sc)
Definition: ath9k_recv.c:194
void ath_flushrecv(struct ath_softc *sc)
Definition: ath9k_recv.c:242
u16 txpowlimit
Definition: ath9k.h:65
uint8_t ah
Definition: registers.h:85
int ath_stoprecv(struct ath_softc *sc)
Definition: ath9k_recv.c:222
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static const uint8_t r[3][4]
MD4 shift amounts.
Definition: md4.c:54

References ah, ath9k_cmn_update_txpow(), ath9k_hw_common(), ath9k_hw_disable_interrupts(), ath9k_hw_reset(), ath9k_hw_set_interrupts(), ATH9K_NUM_TX_QUEUES, ath_drain_all_txq(), ath_flushrecv(), ath_start_ani(), ath_startrecv(), ath_stoprecv(), ath_txq_schedule(), ATH_TXQ_SETUP, common, ath_softc::config, ath_hw::curchan, ath_softc::curtxpow, DBG, ath_softc::hw_busy_count, r, ath_softc::sc_ah, ath_softc::tx, ath_config::txpowlimit, and ath_tx::txq.

Referenced by ath9k_tasklet(), ath_hw_check(), ath_hw_pll_rx_hang_check(), and ath_tx_complete_poll_work().

◆ ath9k_start()

static int ath9k_start ( struct net80211_device dev)
static

Definition at line 565 of file ath9k_main.c.

566 {
567  struct ath_softc *sc = dev->priv;
568  struct ath_hw *ah = sc->sc_ah;
569  struct ath_common *common = ath9k_hw_common(ah);
570  struct net80211_channel *curchan = dev->channels + dev->channel;
571  struct ath9k_channel *init_channel;
572  int r;
573 
574  DBG("ath9k: "
575  "Starting driver with initial channel: %d MHz\n",
576  curchan->center_freq);
577 
578  /* setup initial channel */
579  sc->chan_idx = curchan->hw_value;
580 
581  init_channel = ath9k_cmn_get_curchannel(dev, ah);
582 
583  /* Reset SERDES registers */
585 
586  /*
587  * The basic interface to setting the hardware in a good
588  * state is ``reset''. On return the hardware is known to
589  * be powered up and with interrupts disabled. This must
590  * be followed by initialization of the appropriate bits
591  * and then setup of the interrupt mask.
592  */
593  r = ath9k_hw_reset(ah, init_channel, ah->caldata, 0);
594  if (r) {
595  DBG("ath9k: "
596  "Unable to reset hardware; reset status %d (freq %d MHz)\n",
597  r, curchan->center_freq);
598  goto mutex_unlock;
599  }
600 
601  /*
602  * This is needed only to setup initial state
603  * but it's best done after a reset.
604  */
606  sc->config.txpowlimit, &sc->curtxpow);
607 
608  /*
609  * Setup the hardware after reset:
610  * The receive engine is set going.
611  * Frame transmit is handled entirely
612  * in the frame output path; there's nothing to do
613  * here except setup the interrupt mask.
614  */
615  if (ath_startrecv(sc) != 0) {
616  DBG("ath9k: Unable to start recv logic\n");
617  r = -EIO;
618  goto mutex_unlock;
619  }
620 
621  /* Setup our intr mask. */
622  ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL |
625 
626  ah->imask |= ATH9K_INT_RX;
627 
628  sc->sc_flags &= ~SC_OP_INVALID;
629  sc->sc_ah->is_monitoring = 0;
630 
631  ath9k_hw_set_interrupts(ah, ah->imask);
632 
633  sc->tx_complete_work(sc);
634 
635  if (ah->caps.pcie_lcr_extsync_en && common->bus_ops->extn_synch_en)
636  common->bus_ops->extn_synch_en(common);
637 
638 mutex_unlock:
639  return r;
640 }
Definition: hw.h:656
int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, struct ath9k_hw_cal_data *caldata, int bChannelChange)
Definition: ath9k_hw.c:1216
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
int is_monitoring
Definition: hw.h:677
void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow, u16 new_txpow, u16 *txpower)
Definition: ath9k_common.c:61
static void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off)
Definition: hw-ops.h:26
struct net80211_device * dev
Definition: ath9k.h:445
u16 hw_value
Hardware channel value.
Definition: net80211.h:414
void(* tx_complete_work)(struct ath_softc *sc)
Definition: ath9k.h:484
struct ath_hw * sc_ah
Definition: ath9k.h:454
struct ath_config config
Definition: ath9k.h:474
void ath9k_hw_set_interrupts(struct ath_hw *ah, unsigned int ints)
Definition: ath9k_mac.c:641
struct ath9k_channel * ath9k_cmn_get_curchannel(struct net80211_device *dev, struct ath_hw *ah)
Definition: ath9k_common.c:47
void * priv
Driver private data.
Definition: net80211.h:798
u16 center_freq
The center frequency for this channel.
Definition: net80211.h:411
An 802.11 RF channel.
Definition: net80211.h:385
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
u16 curtxpow
Definition: ath9k.h:467
struct ib_cm_common common
Definition: ib_mad.h:11
u32 sc_flags
Definition: ath9k.h:465
#define SC_OP_INVALID
Definition: ath9k.h:362
int ath_startrecv(struct ath_softc *sc)
Definition: ath9k_recv.c:194
#define EIO
Input/output error.
Definition: errno.h:433
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
u16 txpowlimit
Definition: ath9k.h:65
uint8_t ah
Definition: registers.h:85
int chan_idx
Definition: ath9k.h:448
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static const uint8_t r[3][4]
MD4 shift amounts.
Definition: md4.c:54

References ah, ath9k_cmn_get_curchannel(), ath9k_cmn_update_txpow(), ath9k_hw_common(), ath9k_hw_configpcipowersave(), ath9k_hw_reset(), ath9k_hw_set_interrupts(), ATH9K_INT_FATAL, ATH9K_INT_GLOBAL, ATH9K_INT_RX, ATH9K_INT_RXEOL, ATH9K_INT_RXORN, ATH9K_INT_TX, ath_startrecv(), net80211_channel::center_freq, ath_softc::chan_idx, net80211_device::channel, net80211_device::channels, common, ath_softc::config, ath_softc::curtxpow, DBG, ath_softc::dev, EIO, net80211_channel::hw_value, ath_hw::is_monitoring, net80211_device::priv, r, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_INVALID, ath_softc::tx_complete_work, and ath_config::txpowlimit.

◆ ath9k_tx()

static int ath9k_tx ( struct net80211_device dev,
struct io_buffer iob 
)
static

Definition at line 642 of file ath9k_main.c.

643 {
644  struct ath_softc *sc = dev->priv;
645  struct ath_tx_control txctl;
646  int ret = 0;
647 
648  memset(&txctl, 0, sizeof(struct ath_tx_control));
649  txctl.txq = sc->tx.txq_map[0];
650 
651  DBGIO("ath9k: transmitting packet, iob: %p\n", iob);
652 
653  ret = ath_tx_start(dev, iob, &txctl);
654  if (ret) {
655  DBG("ath9k: TX failed\n");
656  goto exit;
657  }
658 
659  return ret;
660 exit:
661  free_iob(iob);
662  return ret;
663 }
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
int ath_tx_start(struct net80211_device *dev, struct io_buffer *iob, struct ath_tx_control *txctl)
Definition: ath9k_xmit.c:569
struct net80211_device * dev
Definition: ath9k.h:445
#define DBGIO(...)
Definition: compiler.h:549
void * priv
Driver private data.
Definition: net80211.h:798
struct ath_tx tx
Definition: ath9k.h:476
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
struct ath_txq * txq_map[WME_NUM_AC]
Definition: ath9k.h:287
void * memset(void *dest, int character, size_t len) __nonnull

References ath_tx_start(), DBG, DBGIO, ath_softc::dev, free_iob(), memset(), net80211_device::priv, ath_softc::tx, ath_tx_control::txq, and ath_tx::txq_map.

◆ ath9k_stop()

static void ath9k_stop ( struct net80211_device dev)
static

Definition at line 665 of file ath9k_main.c.

666 {
667  struct ath_softc *sc = dev->priv;
668  struct ath_hw *ah = sc->sc_ah;
669 
670  sc->tx_complete_work_timer = 0;
671  sc->hw_pll_work_timer = 0;
672 
673  if (sc->sc_flags & SC_OP_INVALID) {
674  DBG("ath9k: Device not present\n");
675  return;
676  }
677 
678  /* prevent tasklets to enable interrupts once we disable them */
679  ah->imask &= ~ATH9K_INT_GLOBAL;
680 
681  /* make sure h/w will not generate any interrupt
682  * before setting the invalid flag. */
684 
685  if (!(sc->sc_flags & SC_OP_INVALID)) {
686  ath_drain_all_txq(sc, 0);
687  ath_stoprecv(sc);
689  } else
690  sc->rx.rxlink = NULL;
691 
692  if (sc->rx.frag) {
693  free_iob(sc->rx.frag);
694  sc->rx.frag = NULL;
695  }
696 
697  /* disable HAL and put h/w to sleep */
700 
701  ath_radio_disable(sc, dev);
702 
703  sc->sc_flags |= SC_OP_INVALID;
704 
705  DBG("ath9k: Driver halt\n");
706 }
int ath9k_hw_disable(struct ath_hw *ah)
Definition: ath9k_hw.c:1925
Definition: hw.h:656
unsigned long tx_complete_work_timer
Definition: ath9k.h:485
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
static void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off)
Definition: hw-ops.h:26
int ath_drain_all_txq(struct ath_softc *sc, int retry_tx)
Definition: ath9k_xmit.c:216
struct net80211_device * dev
Definition: ath9k.h:445
struct ath_hw * sc_ah
Definition: ath9k.h:454
void ath_radio_disable(struct ath_softc *sc, struct net80211_device *dev)
Definition: ath9k_main.c:471
int ath9k_hw_phy_disable(struct ath_hw *ah)
Definition: ath9k_hw.c:1916
void ath9k_hw_disable_interrupts(struct ath_hw *ah)
Definition: ath9k_mac.c:602
void * priv
Driver private data.
Definition: net80211.h:798
struct ath_rx rx
Definition: ath9k.h:475
struct io_buffer * frag
Definition: ath9k.h:306
u32 * rxlink
Definition: ath9k.h:299
u32 sc_flags
Definition: ath9k.h:465
#define SC_OP_INVALID
Definition: ath9k.h:362
unsigned long hw_pll_work_timer
Definition: ath9k.h:487
struct net80211_device * dev
Definition: hw.h:659
uint8_t ah
Definition: registers.h:85
int ath_stoprecv(struct ath_softc *sc)
Definition: ath9k_recv.c:222
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References ah, ath9k_hw_configpcipowersave(), ath9k_hw_disable(), ath9k_hw_disable_interrupts(), ath9k_hw_phy_disable(), ATH9K_INT_GLOBAL, ath_drain_all_txq(), ath_radio_disable(), ath_stoprecv(), DBG, ath_softc::dev, ath_hw::dev, ath_rx::frag, free_iob(), ath_softc::hw_pll_work_timer, NULL, net80211_device::priv, ath_softc::rx, ath_rx::rxlink, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_INVALID, and ath_softc::tx_complete_work_timer.

◆ ath9k_config()

static int ath9k_config ( struct net80211_device dev,
int  changed 
)
static

Definition at line 708 of file ath9k_main.c.

709 {
710  struct ath_softc *sc = dev->priv;
711  struct ath_hw *ah = sc->sc_ah;
712 
713  if ((changed & NET80211_CFG_RATE) ||
714  (changed & NET80211_CFG_PHY_PARAMS)) {
716  u16 rate = dev->rates[dev->rate];
717  u16 slowrate = dev->rates[dev->rtscts_rate];
718  int i;
719 
720  for (i = 0; i < NET80211_MAX_RATES; i++) {
721  if (sc->rates[i].bitrate == rate &&
722  (sc->rates[i].flags & spmbl))
723  sc->hw_rix = i;
724 
725  if (sc->rates[i].bitrate == slowrate &&
726  (sc->rates[i].flags & spmbl))
727  sc->hw_rix = i;
728  }
729  }
730 
731  ath9k_bss_info_changed(dev, changed);
732 
733  if (changed & NET80211_CFG_CHANNEL) {
734  struct net80211_channel *curchan = dev->channels + dev->channel;
735  int pos = curchan->hw_value;
736  int old_pos = -1;
737 
738  if (ah->curchan)
739  old_pos = ah->curchan - &ah->channels[0];
740 
741  sc->sc_flags &= ~SC_OP_OFFCHANNEL;
742 
743  DBG2("ath9k: "
744  "Set channel: %d MHz\n",
745  curchan->center_freq);
746 
748  curchan);
749 
750  /* update survey stats for the old channel before switching */
752 
753  /*
754  * If the operating channel changes, change the survey in-use flags
755  * along with it.
756  * Reset the survey data for the new channel, unless we're switching
757  * back to the operating channel from an off-channel operation.
758  */
759  if (sc->cur_survey != &sc->survey[pos]) {
760 
761  if (sc->cur_survey)
763 
764  sc->cur_survey = &sc->survey[pos];
765 
766  memset(sc->cur_survey, 0, sizeof(struct survey_info));
768  } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
769  memset(&sc->survey[pos], 0, sizeof(struct survey_info));
770  }
771 
772  if (ath_set_channel(sc, dev, &sc->sc_ah->channels[pos]) < 0) {
773  DBG("ath9k: Unable to set channel\n");
774  return -EINVAL;
775  }
776 
777  /*
778  * The most recent snapshot of channel->noisefloor for the old
779  * channel is only available after the hardware reset. Copy it to
780  * the survey stats now.
781  */
782  if (old_pos >= 0)
783  ath_update_survey_nf(sc, old_pos);
784  }
785 
786  if (changed & NET80211_CFG_CHANNEL) {
787  DBG2("ath9k: "
788  "Set power: %d\n", (dev->channels + dev->channel)->maxpower);
789  sc->config.txpowlimit = 2 * (dev->channels + dev->channel)->maxpower;
791  sc->config.txpowlimit, &sc->curtxpow);
792  }
793 
794  return 0;
795 }
uint16_t u16
Definition: stdint.h:21
#define EINVAL
Invalid argument.
Definition: errno.h:428
Definition: hw.h:656
struct survey_info * cur_survey
Definition: ath9k.h:450
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
u8 rtscts_rate
The rate to use for RTS/CTS transmissions.
Definition: net80211.h:831
static void ath_update_survey_nf(struct ath_softc *sc, int channel)
Definition: ath9k_main.c:54
void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow, u16 new_txpow, u16 *txpower)
Definition: ath9k_common.c:61
#define SC_OP_PREAMBLE_SHORT
Definition: ath9k.h:367
struct net80211_device * dev
Definition: ath9k.h:445
#define SC_OP_OFFCHANNEL
Definition: ath9k.h:366
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:454
struct ath_config config
Definition: ath9k.h:474
void * priv
Driver private data.
Definition: net80211.h:798
u32 filled
Definition: ath9k.h:416
static int ath_update_survey_stats(struct ath_softc *sc)
Definition: ath9k_main.c:71
u16 center_freq
The center frequency for this channel.
Definition: net80211.h:411
void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, struct net80211_channel *chan)
Definition: ath9k_common.c:29
#define NET80211_CFG_PHY_PARAMS
Low-level link parameters (short preamble, protection, etc) have changed.
Definition: net80211.h:90
An 802.11 RF channel.
Definition: net80211.h:385
int hw_rix
Definition: ath9k.h:479
u16 curtxpow
Definition: ath9k.h:467
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
Definition: net80211.h:818
u32 sc_flags
Definition: ath9k.h:465
struct net80211_device * dev
Definition: hw.h:659
#define NET80211_MAX_RATES
The maximum number of TX rates we allow to be configured simultaneously.
Definition: net80211.h:272
int ath_set_channel(struct ath_softc *sc, struct net80211_device *dev, struct ath9k_channel *hchan)
Definition: ath9k_main.c:116
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
#define NET80211_CFG_RATE
Requested transmission rate (dev->rate) has changed.
Definition: net80211.h:84
struct survey_info survey[ATH9K_NUM_CHANNELS]
Definition: ath9k.h:451
u16 txpowlimit
Definition: ath9k.h:65
uint8_t ah
Definition: registers.h:85
#define NET80211_CFG_CHANNEL
Channel choice (dev->channel) or regulatory parameters have changed.
Definition: net80211.h:81
struct ath9k_legacy_rate rates[NET80211_MAX_RATES]
Definition: ath9k.h:478
struct ath9k_channel channels[ATH9K_NUM_CHANNELS]
Definition: hw.h:664
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static void ath9k_bss_info_changed(struct net80211_device *dev, u32 changed)
Definition: ath9k_main.c:854
u8 rate
The rate currently in use, as an index into the rates array.
Definition: net80211.h:824
#define DBG2(...)
Definition: compiler.h:515
if(natsemi->flags &NATSEMI_64BIT) return 1
void * memset(void *dest, int character, size_t len) __nonnull

References ah, ath9k_bss_info_changed(), ath9k_cmn_update_ichannel(), ath9k_cmn_update_txpow(), ath_set_channel(), ath_update_survey_nf(), ath_update_survey_stats(), ath9k_legacy_rate::bitrate, net80211_channel::center_freq, net80211_device::channel, ath_hw::channels, net80211_device::channels, ath_softc::config, ath_softc::cur_survey, ath_softc::curtxpow, DBG, DBG2, ath_softc::dev, ath_hw::dev, EINVAL, survey_info::filled, ath9k_legacy_rate::flags, ath_softc::hw_rix, net80211_channel::hw_value, IEEE80211_TX_RC_USE_SHORT_PREAMBLE, if(), net80211_channel::maxpower, memset(), NET80211_CFG_CHANNEL, NET80211_CFG_PHY_PARAMS, NET80211_CFG_RATE, NET80211_MAX_RATES, net80211_device::priv, net80211_device::rate, ath_softc::rates, net80211_device::rates, net80211_device::rtscts_rate, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_OFFCHANNEL, SC_OP_PREAMBLE_SHORT, ath_softc::survey, SURVEY_INFO_IN_USE, and ath_config::txpowlimit.

◆ ath9k_bss_iter()

static void ath9k_bss_iter ( struct ath_softc sc)
static

Definition at line 797 of file ath9k_main.c.

798 {
799  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
800 
801  if (common->dev->state & NET80211_ASSOCIATED) {
803  memcpy(common->curbssid, common->dev->bssid, ETH_ALEN);
804  common->curaid = common->dev->aid;
806  DBG("ath9k: "
807  "Bss Info ASSOC %d, bssid: %pM\n",
808  common->dev->aid, common->curbssid);
809 
810  /*
811  * Request a re-configuration of Beacon related timers
812  * on the receipt of the first Beacon frame (i.e.,
813  * after time sync with the AP).
814  */
816  /* Reset rssi stats */
819 
820  sc->sc_flags |= SC_OP_ANI_RUN;
822  }
823 }
void ath9k_hw_write_associd(struct ath_hw *ah)
Definition: ath9k_hw.c:1964
#define SC_OP_PRIM_STA_VIF
Definition: ath9k.h:377
u16 ps_flags
Definition: ath9k.h:466
u32 avgbrssi
Definition: ani.h:158
#define PS_BEACON_SYNC
Definition: ath9k.h:384
#define SC_OP_ANI_RUN
Definition: ath9k.h:375
static void ath_start_ani(struct ath_common *common)
Definition: ath9k_main.c:35
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct ar5416Stats stats
Definition: hw.h:695
struct ath_hw * sc_ah
Definition: ath9k.h:454
int last_rssi
Definition: ath9k.h:482
#define ATH_RSSI_DUMMY_MARKER
Definition: common.h:37
#define NET80211_ASSOCIATED
Whether we have successfully associated with the network.
Definition: net80211.h:201
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
#define ETH_ALEN
Definition: if_ether.h:8
struct ib_cm_common common
Definition: ib_mad.h:11
u32 sc_flags
Definition: ath9k.h:465
#define PS_WAIT_FOR_BEACON
Definition: ath9k.h:380
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References ath9k_hw_common(), ath9k_hw_write_associd(), ATH_RSSI_DUMMY_MARKER, ath_start_ani(), ar5416Stats::avgbrssi, common, DBG, ETH_ALEN, ath_softc::last_rssi, memcpy(), NET80211_ASSOCIATED, PS_BEACON_SYNC, ath_softc::ps_flags, PS_WAIT_FOR_BEACON, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_ANI_RUN, SC_OP_PRIM_STA_VIF, and ath_hw::stats.

Referenced by ath9k_config_bss().

◆ ath9k_config_bss()

static void ath9k_config_bss ( struct ath_softc sc)
static

Definition at line 825 of file ath9k_main.c.

826 {
827  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
828  struct net80211_device *dev = common->dev;
829 
830  /* Reconfigure bss info */
831  if (!(dev->state & NET80211_ASSOCIATED)) {
832  DBG2("ath9k: "
833  "ath9k: Bss Info DISASSOC %d, bssid %pM\n",
834  common->curaid, common->curbssid);
836  memset(common->curbssid, 0, ETH_ALEN);
837  common->curaid = 0;
838  }
839 
840  ath9k_bss_iter(sc);
841 
842  /*
843  * None of station vifs are associated.
844  * Clear bssid & aid
845  */
846  if (!(sc->sc_flags & SC_OP_PRIM_STA_VIF)) {
848  /* Stop ANI */
849  sc->sc_flags &= ~SC_OP_ANI_RUN;
850  common->ani.timer = 0;
851  }
852 }
void ath9k_hw_write_associd(struct ath_hw *ah)
Definition: ath9k_hw.c:1964
#define SC_OP_PRIM_STA_VIF
Definition: ath9k.h:377
#define SC_OP_ANI_RUN
Definition: ath9k.h:375
struct ath_hw * sc_ah
Definition: ath9k.h:454
#define NET80211_ASSOCIATED
Whether we have successfully associated with the network.
Definition: net80211.h:201
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
#define ETH_ALEN
Definition: if_ether.h:8
struct ib_cm_common common
Definition: ib_mad.h:11
u32 sc_flags
Definition: ath9k.h:465
static void ath9k_bss_iter(struct ath_softc *sc)
Definition: ath9k_main.c:797
u16 state
State of our association to the network.
Definition: net80211.h:921
#define SC_OP_BEACONS
Definition: ath9k.h:363
#define DBG2(...)
Definition: compiler.h:515
void * memset(void *dest, int character, size_t len) __nonnull

References ath9k_bss_iter(), ath9k_hw_common(), ath9k_hw_write_associd(), common, DBG2, ETH_ALEN, memset(), NET80211_ASSOCIATED, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_ANI_RUN, SC_OP_BEACONS, SC_OP_PRIM_STA_VIF, and net80211_device::state.

Referenced by ath9k_bss_info_changed().

◆ ath9k_poll()

static void ath9k_poll ( struct net80211_device dev)
static

Definition at line 894 of file ath9k_main.c.

895 {
896  ath_isr(dev);
897 }
void ath_isr(struct net80211_device *dev)
Definition: ath9k_main.c:366

References ath_isr(), and ath_common::dev.

◆ ath9k_irq()

static void ath9k_irq ( struct net80211_device dev,
int  enable 
)
static

Definition at line 899 of file ath9k_main.c.

900 {
901  struct ath_softc *sc = dev->priv;
902  struct ath_hw *ah = sc->sc_ah;
903 
904  ah->ah_ier = enable ? AR_IER_ENABLE : AR_IER_DISABLE;
905 
906  ath9k_hw_set_interrupts(ah, ah->imask);
907 }
Definition: hw.h:656
#define AR_IER_ENABLE
Definition: reg.h:55
struct net80211_device * dev
Definition: ath9k.h:445
struct ath_hw * sc_ah
Definition: ath9k.h:454
void ath9k_hw_set_interrupts(struct ath_hw *ah, unsigned int ints)
Definition: ath9k_mac.c:641
void * priv
Driver private data.
Definition: net80211.h:798
#define AR_IER_DISABLE
Definition: reg.h:56
uint8_t ah
Definition: registers.h:85

References ah, AR_IER_DISABLE, AR_IER_ENABLE, ath9k_hw_set_interrupts(), ath_softc::dev, net80211_device::priv, and ath_softc::sc_ah.

Variable Documentation

◆ ath9k_ops

struct net80211_device_operations ath9k_ops
Initial value:
= {
.transmit = ath9k_tx,
.open = ath9k_start,
.close = ath9k_stop,
.config = ath9k_config,
.poll = ath9k_poll,
.irq = ath9k_irq,
}
static int ath9k_start(struct net80211_device *dev)
Definition: ath9k_main.c:565
static void ath9k_irq(struct net80211_device *dev, int enable)
Definition: ath9k_main.c:899
static void ath9k_poll(struct net80211_device *dev)
Definition: ath9k_main.c:894
static int ath9k_config(struct net80211_device *dev, int changed)
Definition: ath9k_main.c:708
static int ath9k_tx(struct net80211_device *dev, struct io_buffer *iob)
Definition: ath9k_main.c:642
static void ath9k_stop(struct net80211_device *dev)
Definition: ath9k_main.c:665

Definition at line 909 of file ath9k_main.c.

Referenced by ath9k_init_device().