Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 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 | |
| 17 | #ifndef __RSI_COMMON_H__ |
| 18 | #define __RSI_COMMON_H__ |
| 19 | |
| 20 | #include <linux/kthread.h> |
| 21 | |
| 22 | #define EVENT_WAIT_FOREVER 0 |
Prameela Rani Garnepudi | 5578b1f | 2017-05-16 15:31:17 +0530 | [diff] [blame] | 23 | #define FIRMWARE_RSI9113 "rs9113_wlan_qspi.rps" |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 24 | #define QUEUE_NOT_FULL 1 |
| 25 | #define QUEUE_FULL 0 |
| 26 | |
| 27 | static inline int rsi_init_event(struct rsi_event *pevent) |
| 28 | { |
| 29 | atomic_set(&pevent->event_condition, 1); |
| 30 | init_waitqueue_head(&pevent->event_queue); |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | static inline int rsi_wait_event(struct rsi_event *event, u32 timeout) |
| 35 | { |
| 36 | int status = 0; |
| 37 | |
| 38 | if (!timeout) |
| 39 | status = wait_event_interruptible(event->event_queue, |
| 40 | (atomic_read(&event->event_condition) == 0)); |
| 41 | else |
| 42 | status = wait_event_interruptible_timeout(event->event_queue, |
| 43 | (atomic_read(&event->event_condition) == 0), |
| 44 | timeout); |
| 45 | return status; |
| 46 | } |
| 47 | |
| 48 | static inline void rsi_set_event(struct rsi_event *event) |
| 49 | { |
| 50 | atomic_set(&event->event_condition, 0); |
| 51 | wake_up_interruptible(&event->event_queue); |
| 52 | } |
| 53 | |
| 54 | static inline void rsi_reset_event(struct rsi_event *event) |
| 55 | { |
| 56 | atomic_set(&event->event_condition, 1); |
| 57 | } |
| 58 | |
| 59 | static inline int rsi_create_kthread(struct rsi_common *common, |
| 60 | struct rsi_thread *thread, |
| 61 | void *func_ptr, |
| 62 | u8 *name) |
| 63 | { |
| 64 | init_completion(&thread->completion); |
Siva Rebbagondla | 716b840 | 2018-02-27 19:56:16 +0530 | [diff] [blame] | 65 | atomic_set(&thread->thread_done, 0); |
Kees Cook | d6755bd | 2014-05-22 11:48:41 -0700 | [diff] [blame] | 66 | thread->task = kthread_run(func_ptr, common, "%s", name); |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 67 | if (IS_ERR(thread->task)) |
| 68 | return (int)PTR_ERR(thread->task); |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static inline int rsi_kill_thread(struct rsi_thread *handle) |
| 74 | { |
| 75 | atomic_inc(&handle->thread_done); |
| 76 | rsi_set_event(&handle->event); |
| 77 | |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 78 | return kthread_stop(handle->task); |
| 79 | } |
| 80 | |
| 81 | void rsi_mac80211_detach(struct rsi_hw *hw); |
Prameela Rani Garnepudi | df77191 | 2017-08-30 15:08:23 +0530 | [diff] [blame] | 82 | u16 rsi_get_connected_channel(struct ieee80211_vif *vif); |
Prameela Rani Garnepudi | 898b255 | 2018-02-27 19:56:17 +0530 | [diff] [blame] | 83 | struct rsi_hw *rsi_91x_init(u16 oper_mode); |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 84 | void rsi_91x_deinit(struct rsi_hw *adapter); |
Prameela Rani Garnepudi | 1100f81 | 2018-02-27 19:56:11 +0530 | [diff] [blame] | 85 | int rsi_read_pkt(struct rsi_common *common, u8 *rx_pkt, s32 rcv_pkt_len); |
Amitkumar Karwar | e6b3b2e | 2017-11-01 17:42:45 +0530 | [diff] [blame] | 86 | #ifdef CONFIG_PM |
Karun Eagalapati | f3ac4e7 | 2017-10-27 16:55:55 +0530 | [diff] [blame] | 87 | int rsi_config_wowlan(struct rsi_hw *adapter, struct cfg80211_wowlan *wowlan); |
Amitkumar Karwar | e6b3b2e | 2017-11-01 17:42:45 +0530 | [diff] [blame] | 88 | #endif |
Prameela Rani Garnepudi | 19844c0 | 2017-08-16 18:43:14 +0530 | [diff] [blame] | 89 | struct rsi_sta *rsi_find_sta(struct rsi_common *common, u8 *mac_addr); |
Prameela Rani Garnepudi | df77191 | 2017-08-30 15:08:23 +0530 | [diff] [blame] | 90 | struct ieee80211_vif *rsi_get_vif(struct rsi_hw *adapter, u8 *mac); |
Kees Cook | dfefb9f | 2017-10-24 02:29:09 -0700 | [diff] [blame] | 91 | void rsi_roc_timeout(struct timer_list *t); |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 92 | #endif |