Lines Matching refs:ar
50 static void carl9170_dbg_message(struct ar9170 *ar, const char *buf, u32 len) in carl9170_dbg_message() argument
57 ar->fw.err_counter++; in carl9170_dbg_message()
58 if (ar->fw.err_counter > 3) { in carl9170_dbg_message()
65 ar->fw.bug_counter++; in carl9170_dbg_message()
71 wiphy_info(ar->hw->wiphy, "FW: %.*s\n", len, buf); in carl9170_dbg_message()
74 carl9170_restart(ar, reason); in carl9170_dbg_message()
77 static void carl9170_handle_ps(struct ar9170 *ar, struct carl9170_rsp *rsp) in carl9170_handle_ps() argument
85 if (ar->ps.state != new_ps) { in carl9170_handle_ps()
87 ar->ps.sleep_ms = jiffies_to_msecs(jiffies - in carl9170_handle_ps()
88 ar->ps.last_action); in carl9170_handle_ps()
91 ar->ps.last_action = jiffies; in carl9170_handle_ps()
93 ar->ps.state = new_ps; in carl9170_handle_ps()
97 static int carl9170_check_sequence(struct ar9170 *ar, unsigned int seq) in carl9170_check_sequence() argument
99 if (ar->cmd_seq < -1) in carl9170_check_sequence()
105 if (ar->cmd_seq < 0) in carl9170_check_sequence()
106 ar->cmd_seq = seq; in carl9170_check_sequence()
114 if (seq != ar->cmd_seq) { in carl9170_check_sequence()
117 count = (seq - ar->cmd_seq) % ar->fw.cmd_bufs; in carl9170_check_sequence()
119 wiphy_err(ar->hw->wiphy, "lost %d command responses/traps! " in carl9170_check_sequence()
120 "w:%d g:%d\n", count, ar->cmd_seq, seq); in carl9170_check_sequence()
122 carl9170_restart(ar, CARL9170_RR_LOST_RSP); in carl9170_check_sequence()
126 ar->cmd_seq = (ar->cmd_seq + 1) % ar->fw.cmd_bufs; in carl9170_check_sequence()
130 static void carl9170_cmd_callback(struct ar9170 *ar, u32 len, void *buffer) in carl9170_cmd_callback() argument
137 if (unlikely(ar->readlen != (len - 4))) { in carl9170_cmd_callback()
138 dev_warn(&ar->udev->dev, "received invalid command response:" in carl9170_cmd_callback()
139 "got %d, instead of %d\n", len - 4, ar->readlen); in carl9170_cmd_callback()
141 ar->cmd_buf, (ar->cmd.hdr.len + 4) & 0x3f); in carl9170_cmd_callback()
148 carl9170_restart(ar, CARL9170_RR_INVALID_RSP); in carl9170_cmd_callback()
151 spin_lock(&ar->cmd_lock); in carl9170_cmd_callback()
152 if (ar->readbuf) { in carl9170_cmd_callback()
154 memcpy(ar->readbuf, buffer + 4, len - 4); in carl9170_cmd_callback()
156 ar->readbuf = NULL; in carl9170_cmd_callback()
158 complete(&ar->cmd_wait); in carl9170_cmd_callback()
159 spin_unlock(&ar->cmd_lock); in carl9170_cmd_callback()
162 void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len) in carl9170_handle_command_response() argument
167 if (carl9170_check_sequence(ar, cmd->hdr.seq)) in carl9170_handle_command_response()
172 carl9170_cmd_callback(ar, len, buf); in carl9170_handle_command_response()
179 wiphy_err(ar->hw->wiphy, "FW: received over-/under" in carl9170_handle_command_response()
195 vif = carl9170_get_main_vif(ar); in carl9170_handle_command_response()
204 carl9170_handle_ps(ar, cmd); in carl9170_handle_command_response()
209 carl9170_update_beacon(ar, true); in carl9170_handle_command_response()
222 carl9170_tx_process_status(ar, cmd); in carl9170_handle_command_response()
242 carl9170_restart(ar, CARL9170_RR_WATCHDOG); in carl9170_handle_command_response()
247 carl9170_dbg_message(ar, (char *)buf + 4, len - 4); in carl9170_handle_command_response()
251 wiphy_dbg(ar->hw->wiphy, "FW: HD %d\n", len - 4); in carl9170_handle_command_response()
260 wiphy_info(ar->hw->wiphy, "FW: RADAR! Please report this " in carl9170_handle_command_response()
266 if (ar->wps.pbc) { in carl9170_handle_command_response()
270 if (state != ar->wps.pbc_state) { in carl9170_handle_command_response()
271 ar->wps.pbc_state = state; in carl9170_handle_command_response()
272 input_report_key(ar->wps.pbc, KEY_WPS_BUTTON, in carl9170_handle_command_response()
274 input_sync(ar->wps.pbc); in carl9170_handle_command_response()
281 complete(&ar->fw_boot_wait); in carl9170_handle_command_response()
285 wiphy_err(ar->hw->wiphy, "FW: received unhandled event %x\n", in carl9170_handle_command_response()
292 static int carl9170_rx_mac_status(struct ar9170 *ar, in carl9170_rx_mac_status() argument
305 if (!ar->sniffer_enabled) in carl9170_rx_mac_status()
310 if (!(ar->filter_state & FIF_PLCPFAIL)) in carl9170_rx_mac_status()
317 ar->tx_fcs_errors++; in carl9170_rx_mac_status()
319 if (!(ar->filter_state & FIF_FCSFAIL)) in carl9170_rx_mac_status()
335 if (error & AR9170_RX_ERROR_DECRYPT && !ar->sniffer_enabled) in carl9170_rx_mac_status()
349 wiphy_dbg(ar->hw->wiphy, "received frame with " in carl9170_rx_mac_status()
355 chan = ar->channel; in carl9170_rx_mac_status()
380 wiphy_err(ar->hw->wiphy, "invalid plcp cck " in carl9170_rx_mac_status()
417 wiphy_err(ar->hw->wiphy, "invalid plcp ofdm " in carl9170_rx_mac_status()
445 static void carl9170_rx_phy_status(struct ar9170 *ar, in carl9170_rx_phy_status() argument
462 status->signal = ar->noise[0] + phy->rssi_combined; in carl9170_rx_phy_status()
521 static void carl9170_ps_beacon(struct ar9170 *ar, void *data, unsigned int len) in carl9170_ps_beacon() argument
529 if (likely(!(ar->hw->conf.flags & IEEE80211_CONF_PS))) in carl9170_ps_beacon()
541 if (compare_ether_addr(hdr->addr3, ar->common.curbssid) || in carl9170_ps_beacon()
542 !ar->common.curaid) in carl9170_ps_beacon()
545 ar->ps.last_beacon = jiffies; in carl9170_ps_beacon()
557 if (!WARN_ON_ONCE(!ar->hw->conf.ps_dtim_period)) in carl9170_ps_beacon()
558 ar->ps.dtim_counter = (tim_ie->dtim_count - 1) % in carl9170_ps_beacon()
559 ar->hw->conf.ps_dtim_period; in carl9170_ps_beacon()
564 cam = ieee80211_check_tim(tim_ie, tim_len, ar->common.curaid); in carl9170_ps_beacon()
571 ar->ps.off_override &= ~PS_OFF_BCN; in carl9170_ps_beacon()
572 carl9170_ps_check(ar); in carl9170_ps_beacon()
575 ar->ps.off_override |= PS_OFF_BCN; in carl9170_ps_beacon()
579 static bool carl9170_ampdu_check(struct ar9170 *ar, u8 *buf, u8 ms) in carl9170_ampdu_check() argument
624 static void carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len) in carl9170_handle_mpdu() argument
634 if (!IS_STARTED(ar)) in carl9170_handle_mpdu()
658 memcpy(&ar->rx_plcp, (void *) buf, in carl9170_handle_mpdu()
664 ar->rx_has_plcp = true; in carl9170_handle_mpdu()
667 wiphy_err(ar->hw->wiphy, "plcp info " in carl9170_handle_mpdu()
687 wiphy_err(ar->hw->wiphy, "frame tail " in carl9170_handle_mpdu()
696 if (unlikely(!ar->rx_has_plcp)) { in carl9170_handle_mpdu()
700 wiphy_err(ar->hw->wiphy, "rx stream does not start " in carl9170_handle_mpdu()
706 head = &ar->rx_plcp; in carl9170_handle_mpdu()
730 if (unlikely(carl9170_rx_mac_status(ar, head, mac, &status))) in carl9170_handle_mpdu()
733 if (!carl9170_ampdu_check(ar, buf, mac_status)) in carl9170_handle_mpdu()
737 carl9170_rx_phy_status(ar, phy, &status); in carl9170_handle_mpdu()
739 carl9170_ps_beacon(ar, buf, mpdu_len); in carl9170_handle_mpdu()
746 ieee80211_rx(ar->hw, skb); in carl9170_handle_mpdu()
750 ar->rx_dropped++; in carl9170_handle_mpdu()
753 static void carl9170_rx_untie_cmds(struct ar9170 *ar, const u8 *respbuf, in carl9170_rx_untie_cmds() argument
766 carl9170_handle_command_response(ar, cmd, cmd->hdr.len + 4); in carl9170_rx_untie_cmds()
773 wiphy_err(ar->hw->wiphy, "malformed firmware trap:\n"); in carl9170_rx_untie_cmds()
779 static void __carl9170_rx(struct ar9170 *ar, u8 *buf, unsigned int len) in __carl9170_rx() argument
795 carl9170_rx_untie_cmds(ar, buf, len); in __carl9170_rx()
797 carl9170_handle_mpdu(ar, buf, len); in __carl9170_rx()
800 static void carl9170_rx_stream(struct ar9170 *ar, void *buf, unsigned int len) in carl9170_rx_stream() argument
822 if (!ar->rx_failover_missing) { in carl9170_rx_stream()
826 wiphy_err(ar->hw->wiphy, in carl9170_rx_stream()
830 __carl9170_rx(ar, tbuf, tlen); in carl9170_rx_stream()
834 if (ar->rx_failover_missing > tlen) { in carl9170_rx_stream()
836 wiphy_err(ar->hw->wiphy, in carl9170_rx_stream()
845 memcpy(skb_put(ar->rx_failover, tlen), tbuf, tlen); in carl9170_rx_stream()
846 ar->rx_failover_missing -= tlen; in carl9170_rx_stream()
848 if (ar->rx_failover_missing <= 0) { in carl9170_rx_stream()
857 ar->rx_failover_missing = 0; in carl9170_rx_stream()
858 carl9170_rx_stream(ar, ar->rx_failover->data, in carl9170_rx_stream()
859 ar->rx_failover->len); in carl9170_rx_stream()
861 skb_reset_tail_pointer(ar->rx_failover); in carl9170_rx_stream()
862 skb_trim(ar->rx_failover, 0); in carl9170_rx_stream()
870 if (ar->rx_failover_missing) { in carl9170_rx_stream()
873 wiphy_err(ar->hw->wiphy, "double rx " in carl9170_rx_stream()
887 memcpy(skb_put(ar->rx_failover, tlen), tbuf, tlen); in carl9170_rx_stream()
888 ar->rx_failover_missing = clen - tlen; in carl9170_rx_stream()
891 __carl9170_rx(ar, rx_stream->payload, clen); in carl9170_rx_stream()
899 wiphy_err(ar->hw->wiphy, "%d bytes of unprocessed " in carl9170_rx_stream()
909 wiphy_err(ar->hw->wiphy, "damaged RX stream data [want:%d, " in carl9170_rx_stream()
911 ar->rx_failover_missing); in carl9170_rx_stream()
913 if (ar->rx_failover_missing) in carl9170_rx_stream()
915 ar->rx_failover->data, in carl9170_rx_stream()
916 ar->rx_failover->len); in carl9170_rx_stream()
921 wiphy_err(ar->hw->wiphy, "please check your hardware and cables, if " in carl9170_rx_stream()
925 if (ar->rx_failover_missing) { in carl9170_rx_stream()
926 skb_reset_tail_pointer(ar->rx_failover); in carl9170_rx_stream()
927 skb_trim(ar->rx_failover, 0); in carl9170_rx_stream()
928 ar->rx_failover_missing = 0; in carl9170_rx_stream()
932 void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len) in carl9170_rx() argument
934 if (ar->fw.rx_stream) in carl9170_rx()
935 carl9170_rx_stream(ar, buf, len); in carl9170_rx()
937 __carl9170_rx(ar, buf, len); in carl9170_rx()