Lines Matching refs:ar
49 static void carl9170_dbg_message(struct ar9170 *ar, const char *buf, u32 len) in carl9170_dbg_message() argument
56 ar->fw.err_counter++; in carl9170_dbg_message()
57 if (ar->fw.err_counter > 3) { in carl9170_dbg_message()
64 ar->fw.bug_counter++; in carl9170_dbg_message()
70 wiphy_info(ar->hw->wiphy, "FW: %.*s\n", len, buf); in carl9170_dbg_message()
73 carl9170_restart(ar, reason); in carl9170_dbg_message()
76 static void carl9170_handle_ps(struct ar9170 *ar, struct carl9170_rsp *rsp) in carl9170_handle_ps() argument
84 if (ar->ps.state != new_ps) { in carl9170_handle_ps()
86 ar->ps.sleep_ms = jiffies_to_msecs(jiffies - in carl9170_handle_ps()
87 ar->ps.last_action); in carl9170_handle_ps()
90 ar->ps.last_action = jiffies; in carl9170_handle_ps()
92 ar->ps.state = new_ps; in carl9170_handle_ps()
96 static int carl9170_check_sequence(struct ar9170 *ar, unsigned int seq) in carl9170_check_sequence() argument
98 if (ar->cmd_seq < -1) in carl9170_check_sequence()
104 if (ar->cmd_seq < 0) in carl9170_check_sequence()
105 ar->cmd_seq = seq; in carl9170_check_sequence()
113 if (seq != ar->cmd_seq) { in carl9170_check_sequence()
116 count = (seq - ar->cmd_seq) % ar->fw.cmd_bufs; in carl9170_check_sequence()
118 wiphy_err(ar->hw->wiphy, "lost %d command responses/traps! " in carl9170_check_sequence()
119 "w:%d g:%d\n", count, ar->cmd_seq, seq); in carl9170_check_sequence()
121 carl9170_restart(ar, CARL9170_RR_LOST_RSP); in carl9170_check_sequence()
125 ar->cmd_seq = (ar->cmd_seq + 1) % ar->fw.cmd_bufs; in carl9170_check_sequence()
129 static void carl9170_cmd_callback(struct ar9170 *ar, u32 len, void *buffer) in carl9170_cmd_callback() argument
136 if (unlikely(ar->readlen != (len - 4))) { in carl9170_cmd_callback()
137 dev_warn(&ar->udev->dev, "received invalid command response:" in carl9170_cmd_callback()
138 "got %d, instead of %d\n", len - 4, ar->readlen); in carl9170_cmd_callback()
140 ar->cmd_buf, (ar->cmd.hdr.len + 4) & 0x3f); in carl9170_cmd_callback()
147 carl9170_restart(ar, CARL9170_RR_INVALID_RSP); in carl9170_cmd_callback()
150 spin_lock(&ar->cmd_lock); in carl9170_cmd_callback()
151 if (ar->readbuf) { in carl9170_cmd_callback()
153 memcpy(ar->readbuf, buffer + 4, len - 4); in carl9170_cmd_callback()
155 ar->readbuf = NULL; in carl9170_cmd_callback()
157 complete(&ar->cmd_wait); in carl9170_cmd_callback()
158 spin_unlock(&ar->cmd_lock); in carl9170_cmd_callback()
161 void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len) in carl9170_handle_command_response() argument
168 carl9170_cmd_callback(ar, len, buf); in carl9170_handle_command_response()
175 wiphy_err(ar->hw->wiphy, "FW: received over-/under" in carl9170_handle_command_response()
191 vif = carl9170_get_main_vif(ar); in carl9170_handle_command_response()
200 carl9170_handle_ps(ar, cmd); in carl9170_handle_command_response()
206 carl9170_update_beacon(ar, true); in carl9170_handle_command_response()
219 carl9170_tx_process_status(ar, cmd); in carl9170_handle_command_response()
239 carl9170_restart(ar, CARL9170_RR_WATCHDOG); in carl9170_handle_command_response()
244 carl9170_dbg_message(ar, (char *)buf + 4, len - 4); in carl9170_handle_command_response()
248 wiphy_dbg(ar->hw->wiphy, "FW: HD %d\n", len - 4); in carl9170_handle_command_response()
257 wiphy_info(ar->hw->wiphy, "FW: RADAR! Please report this " in carl9170_handle_command_response()
263 if (ar->wps.pbc) { in carl9170_handle_command_response()
267 if (state != ar->wps.pbc_state) { in carl9170_handle_command_response()
268 ar->wps.pbc_state = state; in carl9170_handle_command_response()
269 input_report_key(ar->wps.pbc, KEY_WPS_BUTTON, in carl9170_handle_command_response()
271 input_sync(ar->wps.pbc); in carl9170_handle_command_response()
278 complete(&ar->fw_boot_wait); in carl9170_handle_command_response()
282 wiphy_err(ar->hw->wiphy, "FW: received unhandled event %x\n", in carl9170_handle_command_response()
289 static int carl9170_rx_mac_status(struct ar9170 *ar, in carl9170_rx_mac_status() argument
302 if (!ar->sniffer_enabled) in carl9170_rx_mac_status()
307 if (!(ar->filter_state & FIF_PLCPFAIL)) in carl9170_rx_mac_status()
314 ar->tx_fcs_errors++; in carl9170_rx_mac_status()
316 if (!(ar->filter_state & FIF_FCSFAIL)) in carl9170_rx_mac_status()
332 if (error & AR9170_RX_ERROR_DECRYPT && !ar->sniffer_enabled) in carl9170_rx_mac_status()
346 wiphy_dbg(ar->hw->wiphy, "received frame with " in carl9170_rx_mac_status()
352 chan = ar->channel; in carl9170_rx_mac_status()
377 wiphy_err(ar->hw->wiphy, "invalid plcp cck " in carl9170_rx_mac_status()
414 wiphy_err(ar->hw->wiphy, "invalid plcp ofdm " in carl9170_rx_mac_status()
442 static void carl9170_rx_phy_status(struct ar9170 *ar, in carl9170_rx_phy_status() argument
459 status->signal = ar->noise[0] + phy->rssi_combined; in carl9170_rx_phy_status()
518 static void carl9170_ps_beacon(struct ar9170 *ar, void *data, unsigned int len) in carl9170_ps_beacon() argument
522 struct ath_common *common = &ar->common; in carl9170_ps_beacon()
527 if (likely(!(ar->hw->conf.flags & IEEE80211_CONF_PS))) in carl9170_ps_beacon()
539 ar->ps.last_beacon = jiffies; in carl9170_ps_beacon()
551 if (!WARN_ON_ONCE(!ar->hw->conf.ps_dtim_period)) in carl9170_ps_beacon()
552 ar->ps.dtim_counter = (tim_ie->dtim_count - 1) % in carl9170_ps_beacon()
553 ar->hw->conf.ps_dtim_period; in carl9170_ps_beacon()
558 cam = ieee80211_check_tim(tim_ie, tim_len, ar->common.curaid); in carl9170_ps_beacon()
565 ar->ps.off_override &= ~PS_OFF_BCN; in carl9170_ps_beacon()
566 carl9170_ps_check(ar); in carl9170_ps_beacon()
569 ar->ps.off_override |= PS_OFF_BCN; in carl9170_ps_beacon()
573 static void carl9170_ba_check(struct ar9170 *ar, void *data, unsigned int len) in carl9170_ba_check() argument
590 list_for_each_entry_rcu(entry, &ar->bar_list[queue], list) { in carl9170_ba_check()
608 spin_lock_bh(&ar->bar_list_lock[queue]); in carl9170_ba_check()
610 spin_unlock_bh(&ar->bar_list_lock[queue]); in carl9170_ba_check()
620 static bool carl9170_ampdu_check(struct ar9170 *ar, u8 *buf, u8 ms, in carl9170_ampdu_check() argument
635 rx_status->ampdu_reference = ar->ampdu_ref; in carl9170_ampdu_check()
659 static int carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len, in carl9170_handle_mpdu() argument
675 carl9170_ps_beacon(ar, buf, len); in carl9170_handle_mpdu()
677 carl9170_ba_check(ar, buf, len); in carl9170_handle_mpdu()
684 ieee80211_rx(ar->hw, skb); in carl9170_handle_mpdu()
697 static void carl9170_rx_untie_data(struct ar9170 *ar, u8 *buf, int len) in carl9170_rx_untie_data() argument
706 if (!IS_STARTED(ar)) in carl9170_rx_untie_data()
720 ar->ampdu_ref++; in carl9170_rx_untie_data()
733 memcpy(&ar->rx_plcp, (void *) buf, in carl9170_rx_untie_data()
739 ar->rx_has_plcp = true; in carl9170_rx_untie_data()
742 wiphy_err(ar->hw->wiphy, "plcp info " in carl9170_rx_untie_data()
763 wiphy_err(ar->hw->wiphy, "frame tail " in carl9170_rx_untie_data()
772 if (unlikely(!ar->rx_has_plcp)) { in carl9170_rx_untie_data()
776 wiphy_err(ar->hw->wiphy, "rx stream does not start " in carl9170_rx_untie_data()
782 head = &ar->rx_plcp; in carl9170_rx_untie_data()
805 if (unlikely(carl9170_rx_mac_status(ar, head, mac, &status))) in carl9170_rx_untie_data()
808 if (!carl9170_ampdu_check(ar, buf, mac_status, &status)) in carl9170_rx_untie_data()
812 carl9170_rx_phy_status(ar, phy, &status); in carl9170_rx_untie_data()
816 if (carl9170_handle_mpdu(ar, buf, mpdu_len, &status)) in carl9170_rx_untie_data()
821 ar->rx_dropped++; in carl9170_rx_untie_data()
824 static void carl9170_rx_untie_cmds(struct ar9170 *ar, const u8 *respbuf, in carl9170_rx_untie_cmds() argument
837 if (carl9170_check_sequence(ar, cmd->hdr.seq)) in carl9170_rx_untie_cmds()
840 carl9170_handle_command_response(ar, cmd, cmd->hdr.len + 4); in carl9170_rx_untie_cmds()
847 wiphy_err(ar->hw->wiphy, "malformed firmware trap:\n"); in carl9170_rx_untie_cmds()
853 static void __carl9170_rx(struct ar9170 *ar, u8 *buf, unsigned int len) in __carl9170_rx() argument
869 carl9170_rx_untie_cmds(ar, buf, len); in __carl9170_rx()
871 carl9170_rx_untie_data(ar, buf, len); in __carl9170_rx()
874 static void carl9170_rx_stream(struct ar9170 *ar, void *buf, unsigned int len) in carl9170_rx_stream() argument
896 if (!ar->rx_failover_missing) { in carl9170_rx_stream()
900 wiphy_err(ar->hw->wiphy, in carl9170_rx_stream()
904 __carl9170_rx(ar, tbuf, tlen); in carl9170_rx_stream()
908 if (ar->rx_failover_missing > tlen) { in carl9170_rx_stream()
910 wiphy_err(ar->hw->wiphy, in carl9170_rx_stream()
919 memcpy(skb_put(ar->rx_failover, tlen), tbuf, tlen); in carl9170_rx_stream()
920 ar->rx_failover_missing -= tlen; in carl9170_rx_stream()
922 if (ar->rx_failover_missing <= 0) { in carl9170_rx_stream()
931 ar->rx_failover_missing = 0; in carl9170_rx_stream()
932 carl9170_rx_stream(ar, ar->rx_failover->data, in carl9170_rx_stream()
933 ar->rx_failover->len); in carl9170_rx_stream()
935 skb_reset_tail_pointer(ar->rx_failover); in carl9170_rx_stream()
936 skb_trim(ar->rx_failover, 0); in carl9170_rx_stream()
944 if (ar->rx_failover_missing) { in carl9170_rx_stream()
947 wiphy_err(ar->hw->wiphy, "double rx " in carl9170_rx_stream()
961 memcpy(skb_put(ar->rx_failover, tlen), tbuf, tlen); in carl9170_rx_stream()
962 ar->rx_failover_missing = clen - tlen; in carl9170_rx_stream()
965 __carl9170_rx(ar, rx_stream->payload, clen); in carl9170_rx_stream()
973 wiphy_err(ar->hw->wiphy, "%d bytes of unprocessed " in carl9170_rx_stream()
983 wiphy_err(ar->hw->wiphy, "damaged RX stream data [want:%d, " in carl9170_rx_stream()
985 ar->rx_failover_missing); in carl9170_rx_stream()
987 if (ar->rx_failover_missing) in carl9170_rx_stream()
989 ar->rx_failover->data, in carl9170_rx_stream()
990 ar->rx_failover->len); in carl9170_rx_stream()
995 wiphy_err(ar->hw->wiphy, "please check your hardware and cables, if " in carl9170_rx_stream()
999 if (ar->rx_failover_missing) { in carl9170_rx_stream()
1000 skb_reset_tail_pointer(ar->rx_failover); in carl9170_rx_stream()
1001 skb_trim(ar->rx_failover, 0); in carl9170_rx_stream()
1002 ar->rx_failover_missing = 0; in carl9170_rx_stream()
1006 void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len) in carl9170_rx() argument
1008 if (ar->fw.rx_stream) in carl9170_rx()
1009 carl9170_rx_stream(ar, buf, len); in carl9170_rx()
1011 __carl9170_rx(ar, buf, len); in carl9170_rx()