rsi_common.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Copyright (c) 2014 Redpine Signals Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __RSI_COMMON_H__
  17. #define __RSI_COMMON_H__
  18. #include <linux/kthread.h>
  19. #define EVENT_WAIT_FOREVER 0
  20. #define FIRMWARE_RSI9113 "rs9113_wlan_qspi.rps"
  21. #define QUEUE_NOT_FULL 1
  22. #define QUEUE_FULL 0
  23. static inline int rsi_init_event(struct rsi_event *pevent)
  24. {
  25. atomic_set(&pevent->event_condition, 1);
  26. init_waitqueue_head(&pevent->event_queue);
  27. return 0;
  28. }
  29. static inline int rsi_wait_event(struct rsi_event *event, u32 timeout)
  30. {
  31. int status = 0;
  32. if (!timeout)
  33. status = wait_event_interruptible(event->event_queue,
  34. (atomic_read(&event->event_condition) == 0));
  35. else
  36. status = wait_event_interruptible_timeout(event->event_queue,
  37. (atomic_read(&event->event_condition) == 0),
  38. timeout);
  39. return status;
  40. }
  41. static inline void rsi_set_event(struct rsi_event *event)
  42. {
  43. atomic_set(&event->event_condition, 0);
  44. wake_up_interruptible(&event->event_queue);
  45. }
  46. static inline void rsi_reset_event(struct rsi_event *event)
  47. {
  48. atomic_set(&event->event_condition, 1);
  49. }
  50. static inline int rsi_create_kthread(struct rsi_common *common,
  51. struct rsi_thread *thread,
  52. void *func_ptr,
  53. u8 *name)
  54. {
  55. init_completion(&thread->completion);
  56. atomic_set(&thread->thread_done, 0);
  57. thread->task = kthread_run(func_ptr, common, "%s", name);
  58. if (IS_ERR(thread->task))
  59. return (int)PTR_ERR(thread->task);
  60. return 0;
  61. }
  62. static inline int rsi_kill_thread(struct rsi_thread *handle)
  63. {
  64. atomic_inc(&handle->thread_done);
  65. rsi_set_event(&handle->event);
  66. return kthread_stop(handle->task);
  67. }
  68. void rsi_mac80211_detach(struct rsi_hw *hw);
  69. u16 rsi_get_connected_channel(struct ieee80211_vif *vif);
  70. struct rsi_hw *rsi_91x_init(u16 oper_mode);
  71. void rsi_91x_deinit(struct rsi_hw *adapter);
  72. int rsi_read_pkt(struct rsi_common *common, u8 *rx_pkt, s32 rcv_pkt_len);
  73. #ifdef CONFIG_PM
  74. int rsi_config_wowlan(struct rsi_hw *adapter, struct cfg80211_wowlan *wowlan);
  75. #endif
  76. struct rsi_sta *rsi_find_sta(struct rsi_common *common, u8 *mac_addr);
  77. struct ieee80211_vif *rsi_get_vif(struct rsi_hw *adapter, u8 *mac);
  78. void rsi_roc_timeout(struct timer_list *t);
  79. #endif