1c50a2825SEliad Peller /* 2c50a2825SEliad Peller * This file is part of wl12xx 3c50a2825SEliad Peller * 4c50a2825SEliad Peller * Copyright (C) 2012 Texas Instruments. All rights reserved. 5c50a2825SEliad Peller * 6c50a2825SEliad Peller * This program is free software; you can redistribute it and/or 7c50a2825SEliad Peller * modify it under the terms of the GNU General Public License 8c50a2825SEliad Peller * version 2 as published by the Free Software Foundation. 9c50a2825SEliad Peller * 10c50a2825SEliad Peller * This program is distributed in the hope that it will be useful, but 11c50a2825SEliad Peller * WITHOUT ANY WARRANTY; without even the implied warranty of 12c50a2825SEliad Peller * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13c50a2825SEliad Peller * General Public License for more details. 14c50a2825SEliad Peller * 15c50a2825SEliad Peller * You should have received a copy of the GNU General Public License 16c50a2825SEliad Peller * along with this program; if not, write to the Free Software 17c50a2825SEliad Peller * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18c50a2825SEliad Peller * 02110-1301 USA 19c50a2825SEliad Peller * 20c50a2825SEliad Peller */ 21c50a2825SEliad Peller 22c50a2825SEliad Peller #include "event.h" 23c50a2825SEliad Peller #include "scan.h" 24c50a2825SEliad Peller #include "../wlcore/cmd.h" 25c50a2825SEliad Peller #include "../wlcore/debug.h" 26c50a2825SEliad Peller 27c50a2825SEliad Peller int wl12xx_wait_for_event(struct wl1271 *wl, enum wlcore_wait_event event, 28c50a2825SEliad Peller bool *timeout) 29c50a2825SEliad Peller { 30c50a2825SEliad Peller u32 local_event; 31c50a2825SEliad Peller 32c50a2825SEliad Peller switch (event) { 33c50a2825SEliad Peller case WLCORE_EVENT_ROLE_STOP_COMPLETE: 34c50a2825SEliad Peller local_event = ROLE_STOP_COMPLETE_EVENT_ID; 35c50a2825SEliad Peller break; 36c50a2825SEliad Peller 37c50a2825SEliad Peller case WLCORE_EVENT_PEER_REMOVE_COMPLETE: 38c50a2825SEliad Peller local_event = PEER_REMOVE_COMPLETE_EVENT_ID; 39c50a2825SEliad Peller break; 40c50a2825SEliad Peller 41c50a2825SEliad Peller default: 42c50a2825SEliad Peller /* event not implemented */ 43c50a2825SEliad Peller return 0; 44c50a2825SEliad Peller } 45c50a2825SEliad Peller return wlcore_cmd_wait_for_event_or_timeout(wl, local_event, timeout); 46c50a2825SEliad Peller } 47c50a2825SEliad Peller 48c50a2825SEliad Peller int wl12xx_process_mailbox_events(struct wl1271 *wl) 49c50a2825SEliad Peller { 50c50a2825SEliad Peller struct wl12xx_event_mailbox *mbox = wl->mbox; 51c50a2825SEliad Peller u32 vector; 52c50a2825SEliad Peller 53c50a2825SEliad Peller 54c50a2825SEliad Peller vector = le32_to_cpu(mbox->events_vector); 55c50a2825SEliad Peller vector &= ~(le32_to_cpu(mbox->events_mask)); 56c50a2825SEliad Peller 57c50a2825SEliad Peller wl1271_debug(DEBUG_EVENT, "MBOX vector: 0x%x", vector); 58c50a2825SEliad Peller 59c50a2825SEliad Peller if (vector & SCAN_COMPLETE_EVENT_ID) { 60c50a2825SEliad Peller wl1271_debug(DEBUG_EVENT, "status: 0x%x", 61c50a2825SEliad Peller mbox->scheduled_scan_status); 62c50a2825SEliad Peller 63c50a2825SEliad Peller if (wl->scan_wlvif) 64c50a2825SEliad Peller wl12xx_scan_completed(wl, wl->scan_wlvif); 65c50a2825SEliad Peller } 66c50a2825SEliad Peller 67c50a2825SEliad Peller if (vector & PERIODIC_SCAN_REPORT_EVENT_ID) 68c50a2825SEliad Peller wlcore_event_sched_scan_report(wl, 69c50a2825SEliad Peller mbox->scheduled_scan_status); 70c50a2825SEliad Peller 71c50a2825SEliad Peller if (vector & PERIODIC_SCAN_COMPLETE_EVENT_ID) 72c50a2825SEliad Peller wlcore_event_sched_scan_completed(wl, 73c50a2825SEliad Peller mbox->scheduled_scan_status); 74c50a2825SEliad Peller if (vector & SOFT_GEMINI_SENSE_EVENT_ID) 75c50a2825SEliad Peller wlcore_event_soft_gemini_sense(wl, 76c50a2825SEliad Peller mbox->soft_gemini_sense_info); 77c50a2825SEliad Peller 78c50a2825SEliad Peller if (vector & BSS_LOSE_EVENT_ID) 79c50a2825SEliad Peller wlcore_event_beacon_loss(wl, 0xff); 80c50a2825SEliad Peller 81c50a2825SEliad Peller if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) 82c50a2825SEliad Peller wlcore_event_rssi_trigger(wl, mbox->rssi_snr_trigger_metric); 83c50a2825SEliad Peller 84c50a2825SEliad Peller if (vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID) 85c50a2825SEliad Peller wlcore_event_ba_rx_constraint(wl, 86c50a2825SEliad Peller BIT(mbox->role_id), 87c50a2825SEliad Peller mbox->rx_ba_allowed); 88c50a2825SEliad Peller 89c50a2825SEliad Peller if (vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID) 90c50a2825SEliad Peller wlcore_event_channel_switch(wl, 0xff, 91c50a2825SEliad Peller mbox->channel_switch_status); 92c50a2825SEliad Peller 93c50a2825SEliad Peller if (vector & DUMMY_PACKET_EVENT_ID) 94c50a2825SEliad Peller wlcore_event_dummy_packet(wl); 95c50a2825SEliad Peller 96c50a2825SEliad Peller /* 97c50a2825SEliad Peller * "TX retries exceeded" has a different meaning according to mode. 98c50a2825SEliad Peller * In AP mode the offending station is disconnected. 99c50a2825SEliad Peller */ 100c50a2825SEliad Peller if (vector & MAX_TX_RETRY_EVENT_ID) 101c50a2825SEliad Peller wlcore_event_max_tx_failure(wl, 102c50a2825SEliad Peller le16_to_cpu(mbox->sta_tx_retry_exceeded)); 103c50a2825SEliad Peller 104c50a2825SEliad Peller if (vector & INACTIVE_STA_EVENT_ID) 105c50a2825SEliad Peller wlcore_event_inactive_sta(wl, 106c50a2825SEliad Peller le16_to_cpu(mbox->sta_aging_status)); 107c50a2825SEliad Peller 108c50a2825SEliad Peller if (vector & REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID) 109c50a2825SEliad Peller wlcore_event_roc_complete(wl); 110c50a2825SEliad Peller 111c50a2825SEliad Peller return 0; 112c50a2825SEliad Peller } 113