Lines Matching refs:wmi
91 struct wmi *ath9k_init_wmi(struct ath9k_htc_priv *priv) in ath9k_init_wmi()
93 struct wmi *wmi; in ath9k_init_wmi() local
95 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); in ath9k_init_wmi()
96 if (!wmi) in ath9k_init_wmi()
99 wmi->drv_priv = priv; in ath9k_init_wmi()
100 wmi->stopped = false; in ath9k_init_wmi()
101 skb_queue_head_init(&wmi->wmi_event_queue); in ath9k_init_wmi()
102 spin_lock_init(&wmi->wmi_lock); in ath9k_init_wmi()
103 spin_lock_init(&wmi->event_lock); in ath9k_init_wmi()
104 mutex_init(&wmi->op_mutex); in ath9k_init_wmi()
105 mutex_init(&wmi->multi_write_mutex); in ath9k_init_wmi()
106 mutex_init(&wmi->multi_rmw_mutex); in ath9k_init_wmi()
107 init_completion(&wmi->cmd_wait); in ath9k_init_wmi()
108 INIT_LIST_HEAD(&wmi->pending_tx_events); in ath9k_init_wmi()
109 tasklet_setup(&wmi->wmi_event_tasklet, ath9k_wmi_event_tasklet); in ath9k_init_wmi()
111 return wmi; in ath9k_init_wmi()
116 struct wmi *wmi = priv->wmi; in ath9k_stop_wmi() local
118 mutex_lock(&wmi->op_mutex); in ath9k_stop_wmi()
119 wmi->stopped = true; in ath9k_stop_wmi()
120 mutex_unlock(&wmi->op_mutex); in ath9k_stop_wmi()
125 kfree(priv->wmi); in ath9k_destroy_wmi()
132 tasklet_kill(&priv->wmi->wmi_event_tasklet); in ath9k_wmi_event_drain()
133 spin_lock_irqsave(&priv->wmi->wmi_lock, flags); in ath9k_wmi_event_drain()
134 __skb_queue_purge(&priv->wmi->wmi_event_queue); in ath9k_wmi_event_drain()
135 spin_unlock_irqrestore(&priv->wmi->wmi_lock, flags); in ath9k_wmi_event_drain()
140 struct wmi *wmi = from_tasklet(wmi, t, wmi_event_tasklet); in ath9k_wmi_event_tasklet() local
141 struct ath9k_htc_priv *priv = wmi->drv_priv; in ath9k_wmi_event_tasklet()
150 spin_lock_irqsave(&wmi->wmi_lock, flags); in ath9k_wmi_event_tasklet()
151 skb = __skb_dequeue(&wmi->wmi_event_queue); in ath9k_wmi_event_tasklet()
153 spin_unlock_irqrestore(&wmi->wmi_lock, flags); in ath9k_wmi_event_tasklet()
156 spin_unlock_irqrestore(&wmi->wmi_lock, flags); in ath9k_wmi_event_tasklet()
168 ieee80211_queue_work(wmi->drv_priv->hw, in ath9k_wmi_event_tasklet()
169 &wmi->drv_priv->fatal_work); in ath9k_wmi_event_tasklet()
203 static void ath9k_wmi_rsp_callback(struct wmi *wmi, struct sk_buff *skb) in ath9k_wmi_rsp_callback() argument
207 if (wmi->cmd_rsp_buf != NULL && wmi->cmd_rsp_len != 0) in ath9k_wmi_rsp_callback()
208 memcpy(wmi->cmd_rsp_buf, skb->data, wmi->cmd_rsp_len); in ath9k_wmi_rsp_callback()
210 complete(&wmi->cmd_wait); in ath9k_wmi_rsp_callback()
216 struct wmi *wmi = priv; in ath9k_wmi_ctrl_rx() local
221 if (unlikely(wmi->stopped)) in ath9k_wmi_ctrl_rx()
232 spin_lock_irqsave(&wmi->wmi_lock, flags); in ath9k_wmi_ctrl_rx()
233 __skb_queue_tail(&wmi->wmi_event_queue, skb); in ath9k_wmi_ctrl_rx()
234 spin_unlock_irqrestore(&wmi->wmi_lock, flags); in ath9k_wmi_ctrl_rx()
235 tasklet_schedule(&wmi->wmi_event_tasklet); in ath9k_wmi_ctrl_rx()
240 spin_lock_irqsave(&wmi->wmi_lock, flags); in ath9k_wmi_ctrl_rx()
241 if (be16_to_cpu(hdr->seq_no) != wmi->last_seq_id) { in ath9k_wmi_ctrl_rx()
242 spin_unlock_irqrestore(&wmi->wmi_lock, flags); in ath9k_wmi_ctrl_rx()
247 ath9k_wmi_rsp_callback(wmi, skb); in ath9k_wmi_ctrl_rx()
248 spin_unlock_irqrestore(&wmi->wmi_lock, flags); in ath9k_wmi_ctrl_rx()
260 int ath9k_wmi_connect(struct htc_target *htc, struct wmi *wmi, in ath9k_wmi_connect() argument
266 wmi->htc = htc; in ath9k_wmi_connect()
270 connect.ep_callbacks.priv = wmi; in ath9k_wmi_connect()
275 ret = htc_connect_service(htc, &connect, &wmi->ctrl_epid); in ath9k_wmi_connect()
279 *wmi_ctrl_epid = wmi->ctrl_epid; in ath9k_wmi_connect()
284 static int ath9k_wmi_cmd_issue(struct wmi *wmi, in ath9k_wmi_cmd_issue() argument
294 hdr->seq_no = cpu_to_be16(++wmi->tx_seq_id); in ath9k_wmi_cmd_issue()
296 spin_lock_irqsave(&wmi->wmi_lock, flags); in ath9k_wmi_cmd_issue()
299 wmi->cmd_rsp_buf = rsp_buf; in ath9k_wmi_cmd_issue()
300 wmi->cmd_rsp_len = rsp_len; in ath9k_wmi_cmd_issue()
302 wmi->last_seq_id = wmi->tx_seq_id; in ath9k_wmi_cmd_issue()
303 spin_unlock_irqrestore(&wmi->wmi_lock, flags); in ath9k_wmi_cmd_issue()
305 return htc_send_epid(wmi->htc, skb, wmi->ctrl_epid); in ath9k_wmi_cmd_issue()
308 int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id, in ath9k_wmi_cmd() argument
313 struct ath_hw *ah = wmi->drv_priv->ah; in ath9k_wmi_cmd()
334 mutex_lock(&wmi->op_mutex); in ath9k_wmi_cmd()
337 if (unlikely(wmi->stopped)) { in ath9k_wmi_cmd()
342 ret = ath9k_wmi_cmd_issue(wmi, skb, cmd_id, cmd_len, rsp_buf, rsp_len); in ath9k_wmi_cmd()
346 time_left = wait_for_completion_timeout(&wmi->cmd_wait, timeout); in ath9k_wmi_cmd()
350 spin_lock_irqsave(&wmi->wmi_lock, flags); in ath9k_wmi_cmd()
351 wmi->last_seq_id = 0; in ath9k_wmi_cmd()
352 spin_unlock_irqrestore(&wmi->wmi_lock, flags); in ath9k_wmi_cmd()
353 mutex_unlock(&wmi->op_mutex); in ath9k_wmi_cmd()
357 mutex_unlock(&wmi->op_mutex); in ath9k_wmi_cmd()
363 mutex_unlock(&wmi->op_mutex); in ath9k_wmi_cmd()