event.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * This file is part of wl12xx
  3. *
  4. * Copyright (C) 2012 Texas Instruments. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #include "event.h"
  22. #include "scan.h"
  23. #include "../wlcore/cmd.h"
  24. #include "../wlcore/debug.h"
  25. int wl18xx_wait_for_event(struct wl1271 *wl, enum wlcore_wait_event event,
  26. bool *timeout)
  27. {
  28. u32 local_event;
  29. switch (event) {
  30. case WLCORE_EVENT_PEER_REMOVE_COMPLETE:
  31. local_event = PEER_REMOVE_COMPLETE_EVENT_ID;
  32. break;
  33. case WLCORE_EVENT_DFS_CONFIG_COMPLETE:
  34. local_event = DFS_CHANNELS_CONFIG_COMPLETE_EVENT;
  35. break;
  36. default:
  37. /* event not implemented */
  38. return 0;
  39. }
  40. return wlcore_cmd_wait_for_event_or_timeout(wl, local_event, timeout);
  41. }
  42. int wl18xx_process_mailbox_events(struct wl1271 *wl)
  43. {
  44. struct wl18xx_event_mailbox *mbox = wl->mbox;
  45. u32 vector;
  46. vector = le32_to_cpu(mbox->events_vector);
  47. wl1271_debug(DEBUG_EVENT, "MBOX vector: 0x%x", vector);
  48. if (vector & SCAN_COMPLETE_EVENT_ID) {
  49. wl1271_debug(DEBUG_EVENT, "scan results: %d",
  50. mbox->number_of_scan_results);
  51. if (wl->scan_wlvif)
  52. wl18xx_scan_completed(wl, wl->scan_wlvif);
  53. }
  54. if (vector & PERIODIC_SCAN_REPORT_EVENT_ID) {
  55. wl1271_debug(DEBUG_EVENT,
  56. "PERIODIC_SCAN_REPORT_EVENT (results %d)",
  57. mbox->number_of_sched_scan_results);
  58. wlcore_scan_sched_scan_results(wl);
  59. }
  60. if (vector & PERIODIC_SCAN_COMPLETE_EVENT_ID)
  61. wlcore_event_sched_scan_completed(wl, 1);
  62. if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID)
  63. wlcore_event_rssi_trigger(wl, mbox->rssi_snr_trigger_metric);
  64. if (vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID)
  65. wlcore_event_ba_rx_constraint(wl,
  66. le16_to_cpu(mbox->rx_ba_role_id_bitmap),
  67. le16_to_cpu(mbox->rx_ba_allowed_bitmap));
  68. if (vector & BSS_LOSS_EVENT_ID)
  69. wlcore_event_beacon_loss(wl,
  70. le16_to_cpu(mbox->bss_loss_bitmap));
  71. if (vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID)
  72. wlcore_event_channel_switch(wl,
  73. le16_to_cpu(mbox->channel_switch_role_id_bitmap),
  74. true);
  75. if (vector & DUMMY_PACKET_EVENT_ID)
  76. wlcore_event_dummy_packet(wl);
  77. /*
  78. * "TX retries exceeded" has a different meaning according to mode.
  79. * In AP mode the offending station is disconnected.
  80. */
  81. if (vector & MAX_TX_FAILURE_EVENT_ID)
  82. wlcore_event_max_tx_failure(wl,
  83. le32_to_cpu(mbox->tx_retry_exceeded_bitmap));
  84. if (vector & INACTIVE_STA_EVENT_ID)
  85. wlcore_event_inactive_sta(wl,
  86. le32_to_cpu(mbox->inactive_sta_bitmap));
  87. if (vector & REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID)
  88. wlcore_event_roc_complete(wl);
  89. return 0;
  90. }