xref: /linux/drivers/net/wireless/ath/ath10k/wmi-ops.h (revision 2ba9268dd603d23e17643437b2246acb6844953b)
1 /*
2  * Copyright (c) 2005-2011 Atheros Communications Inc.
3  * Copyright (c) 2011-2014 Qualcomm Atheros, Inc.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _WMI_OPS_H_
19 #define _WMI_OPS_H_
20 
21 struct ath10k;
22 struct sk_buff;
23 
24 struct wmi_ops {
25 	void (*rx)(struct ath10k *ar, struct sk_buff *skb);
26 	void (*map_svc)(const __le32 *in, unsigned long *out, size_t len);
27 
28 	int (*pull_scan)(struct ath10k *ar, struct sk_buff *skb,
29 			 struct wmi_scan_ev_arg *arg);
30 	int (*pull_mgmt_rx)(struct ath10k *ar, struct sk_buff *skb,
31 			    struct wmi_mgmt_rx_ev_arg *arg);
32 	int (*pull_ch_info)(struct ath10k *ar, struct sk_buff *skb,
33 			    struct wmi_ch_info_ev_arg *arg);
34 	int (*pull_vdev_start)(struct ath10k *ar, struct sk_buff *skb,
35 			       struct wmi_vdev_start_ev_arg *arg);
36 	int (*pull_peer_kick)(struct ath10k *ar, struct sk_buff *skb,
37 			      struct wmi_peer_kick_ev_arg *arg);
38 	int (*pull_swba)(struct ath10k *ar, struct sk_buff *skb,
39 			 struct wmi_swba_ev_arg *arg);
40 	int (*pull_phyerr)(struct ath10k *ar, struct sk_buff *skb,
41 			   struct wmi_phyerr_ev_arg *arg);
42 	int (*pull_svc_rdy)(struct ath10k *ar, struct sk_buff *skb,
43 			    struct wmi_svc_rdy_ev_arg *arg);
44 	int (*pull_rdy)(struct ath10k *ar, struct sk_buff *skb,
45 			struct wmi_rdy_ev_arg *arg);
46 	int (*pull_fw_stats)(struct ath10k *ar, struct sk_buff *skb,
47 			     struct ath10k_fw_stats *stats);
48 
49 	struct sk_buff *(*gen_pdev_suspend)(struct ath10k *ar, u32 suspend_opt);
50 	struct sk_buff *(*gen_pdev_resume)(struct ath10k *ar);
51 	struct sk_buff *(*gen_pdev_set_rd)(struct ath10k *ar, u16 rd, u16 rd2g,
52 					   u16 rd5g, u16 ctl2g, u16 ctl5g,
53 					   enum wmi_dfs_region dfs_reg);
54 	struct sk_buff *(*gen_pdev_set_param)(struct ath10k *ar, u32 id,
55 					      u32 value);
56 	struct sk_buff *(*gen_init)(struct ath10k *ar);
57 	struct sk_buff *(*gen_start_scan)(struct ath10k *ar,
58 					  const struct wmi_start_scan_arg *arg);
59 	struct sk_buff *(*gen_stop_scan)(struct ath10k *ar,
60 					 const struct wmi_stop_scan_arg *arg);
61 	struct sk_buff *(*gen_vdev_create)(struct ath10k *ar, u32 vdev_id,
62 					   enum wmi_vdev_type type,
63 					   enum wmi_vdev_subtype subtype,
64 					   const u8 macaddr[ETH_ALEN]);
65 	struct sk_buff *(*gen_vdev_delete)(struct ath10k *ar, u32 vdev_id);
66 	struct sk_buff *(*gen_vdev_start)(struct ath10k *ar,
67 					  const struct wmi_vdev_start_request_arg *arg,
68 					  bool restart);
69 	struct sk_buff *(*gen_vdev_stop)(struct ath10k *ar, u32 vdev_id);
70 	struct sk_buff *(*gen_vdev_up)(struct ath10k *ar, u32 vdev_id, u32 aid,
71 				       const u8 *bssid);
72 	struct sk_buff *(*gen_vdev_down)(struct ath10k *ar, u32 vdev_id);
73 	struct sk_buff *(*gen_vdev_set_param)(struct ath10k *ar, u32 vdev_id,
74 					      u32 param_id, u32 param_value);
75 	struct sk_buff *(*gen_vdev_install_key)(struct ath10k *ar,
76 						const struct wmi_vdev_install_key_arg *arg);
77 	struct sk_buff *(*gen_vdev_spectral_conf)(struct ath10k *ar,
78 						  const struct wmi_vdev_spectral_conf_arg *arg);
79 	struct sk_buff *(*gen_vdev_spectral_enable)(struct ath10k *ar, u32 vdev_id,
80 						    u32 trigger, u32 enable);
81 	struct sk_buff *(*gen_vdev_wmm_conf)(struct ath10k *ar, u32 vdev_id,
82 					     const struct wmi_wmm_params_all_arg *arg);
83 	struct sk_buff *(*gen_peer_create)(struct ath10k *ar, u32 vdev_id,
84 					   const u8 peer_addr[ETH_ALEN]);
85 	struct sk_buff *(*gen_peer_delete)(struct ath10k *ar, u32 vdev_id,
86 					   const u8 peer_addr[ETH_ALEN]);
87 	struct sk_buff *(*gen_peer_flush)(struct ath10k *ar, u32 vdev_id,
88 					  const u8 peer_addr[ETH_ALEN],
89 					  u32 tid_bitmap);
90 	struct sk_buff *(*gen_peer_set_param)(struct ath10k *ar, u32 vdev_id,
91 					      const u8 *peer_addr,
92 					      enum wmi_peer_param param_id,
93 					      u32 param_value);
94 	struct sk_buff *(*gen_peer_assoc)(struct ath10k *ar,
95 					  const struct wmi_peer_assoc_complete_arg *arg);
96 	struct sk_buff *(*gen_set_psmode)(struct ath10k *ar, u32 vdev_id,
97 					  enum wmi_sta_ps_mode psmode);
98 	struct sk_buff *(*gen_set_sta_ps)(struct ath10k *ar, u32 vdev_id,
99 					  enum wmi_sta_powersave_param param_id,
100 					  u32 value);
101 	struct sk_buff *(*gen_set_ap_ps)(struct ath10k *ar, u32 vdev_id,
102 					 const u8 *mac,
103 					 enum wmi_ap_ps_peer_param param_id,
104 					 u32 value);
105 	struct sk_buff *(*gen_scan_chan_list)(struct ath10k *ar,
106 					      const struct wmi_scan_chan_list_arg *arg);
107 	struct sk_buff *(*gen_beacon_dma)(struct ath10k *ar, u32 vdev_id,
108 					  const void *bcn, size_t bcn_len,
109 					  u32 bcn_paddr, bool dtim_zero,
110 					  bool deliver_cab);
111 	struct sk_buff *(*gen_pdev_set_wmm)(struct ath10k *ar,
112 					    const struct wmi_wmm_params_all_arg *arg);
113 	struct sk_buff *(*gen_request_stats)(struct ath10k *ar,
114 					     enum wmi_stats_id stats_id);
115 	struct sk_buff *(*gen_force_fw_hang)(struct ath10k *ar,
116 					     enum wmi_force_fw_hang_type type,
117 					     u32 delay_ms);
118 	struct sk_buff *(*gen_mgmt_tx)(struct ath10k *ar, struct sk_buff *skb);
119 	struct sk_buff *(*gen_dbglog_cfg)(struct ath10k *ar, u32 module_enable,
120 					  u32 log_level);
121 	struct sk_buff *(*gen_pktlog_enable)(struct ath10k *ar, u32 filter);
122 	struct sk_buff *(*gen_pktlog_disable)(struct ath10k *ar);
123 	struct sk_buff *(*gen_pdev_set_quiet_mode)(struct ath10k *ar,
124 						   u32 period, u32 duration,
125 						   u32 next_offset,
126 						   u32 enabled);
127 	struct sk_buff *(*gen_pdev_get_temperature)(struct ath10k *ar);
128 	struct sk_buff *(*gen_addba_clear_resp)(struct ath10k *ar, u32 vdev_id,
129 						const u8 *mac);
130 	struct sk_buff *(*gen_addba_send)(struct ath10k *ar, u32 vdev_id,
131 					  const u8 *mac, u32 tid, u32 buf_size);
132 	struct sk_buff *(*gen_addba_set_resp)(struct ath10k *ar, u32 vdev_id,
133 					      const u8 *mac, u32 tid,
134 					      u32 status);
135 	struct sk_buff *(*gen_delba_send)(struct ath10k *ar, u32 vdev_id,
136 					  const u8 *mac, u32 tid, u32 initiator,
137 					  u32 reason);
138 	struct sk_buff *(*gen_bcn_tmpl)(struct ath10k *ar, u32 vdev_id,
139 					u32 tim_ie_offset, struct sk_buff *bcn,
140 					u32 prb_caps, u32 prb_erp,
141 					void *prb_ies, size_t prb_ies_len);
142 	struct sk_buff *(*gen_prb_tmpl)(struct ath10k *ar, u32 vdev_id,
143 					struct sk_buff *bcn);
144 	struct sk_buff *(*gen_p2p_go_bcn_ie)(struct ath10k *ar, u32 vdev_id,
145 					     const u8 *p2p_ie);
146 	struct sk_buff *(*gen_vdev_sta_uapsd)(struct ath10k *ar, u32 vdev_id,
147 					      const u8 peer_addr[ETH_ALEN],
148 					      const struct wmi_sta_uapsd_auto_trig_arg *args,
149 					      u32 num_ac);
150 	struct sk_buff *(*gen_sta_keepalive)(struct ath10k *ar,
151 					     const struct wmi_sta_keepalive_arg *arg);
152 };
153 
154 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
155 
156 static inline int
157 ath10k_wmi_rx(struct ath10k *ar, struct sk_buff *skb)
158 {
159 	if (WARN_ON_ONCE(!ar->wmi.ops->rx))
160 		return -EOPNOTSUPP;
161 
162 	ar->wmi.ops->rx(ar, skb);
163 	return 0;
164 }
165 
166 static inline int
167 ath10k_wmi_map_svc(struct ath10k *ar, const __le32 *in, unsigned long *out,
168 		   size_t len)
169 {
170 	if (!ar->wmi.ops->map_svc)
171 		return -EOPNOTSUPP;
172 
173 	ar->wmi.ops->map_svc(in, out, len);
174 	return 0;
175 }
176 
177 static inline int
178 ath10k_wmi_pull_scan(struct ath10k *ar, struct sk_buff *skb,
179 		     struct wmi_scan_ev_arg *arg)
180 {
181 	if (!ar->wmi.ops->pull_scan)
182 		return -EOPNOTSUPP;
183 
184 	return ar->wmi.ops->pull_scan(ar, skb, arg);
185 }
186 
187 static inline int
188 ath10k_wmi_pull_mgmt_rx(struct ath10k *ar, struct sk_buff *skb,
189 			struct wmi_mgmt_rx_ev_arg *arg)
190 {
191 	if (!ar->wmi.ops->pull_mgmt_rx)
192 		return -EOPNOTSUPP;
193 
194 	return ar->wmi.ops->pull_mgmt_rx(ar, skb, arg);
195 }
196 
197 static inline int
198 ath10k_wmi_pull_ch_info(struct ath10k *ar, struct sk_buff *skb,
199 			struct wmi_ch_info_ev_arg *arg)
200 {
201 	if (!ar->wmi.ops->pull_ch_info)
202 		return -EOPNOTSUPP;
203 
204 	return ar->wmi.ops->pull_ch_info(ar, skb, arg);
205 }
206 
207 static inline int
208 ath10k_wmi_pull_vdev_start(struct ath10k *ar, struct sk_buff *skb,
209 			   struct wmi_vdev_start_ev_arg *arg)
210 {
211 	if (!ar->wmi.ops->pull_vdev_start)
212 		return -EOPNOTSUPP;
213 
214 	return ar->wmi.ops->pull_vdev_start(ar, skb, arg);
215 }
216 
217 static inline int
218 ath10k_wmi_pull_peer_kick(struct ath10k *ar, struct sk_buff *skb,
219 			  struct wmi_peer_kick_ev_arg *arg)
220 {
221 	if (!ar->wmi.ops->pull_peer_kick)
222 		return -EOPNOTSUPP;
223 
224 	return ar->wmi.ops->pull_peer_kick(ar, skb, arg);
225 }
226 
227 static inline int
228 ath10k_wmi_pull_swba(struct ath10k *ar, struct sk_buff *skb,
229 		     struct wmi_swba_ev_arg *arg)
230 {
231 	if (!ar->wmi.ops->pull_swba)
232 		return -EOPNOTSUPP;
233 
234 	return ar->wmi.ops->pull_swba(ar, skb, arg);
235 }
236 
237 static inline int
238 ath10k_wmi_pull_phyerr(struct ath10k *ar, struct sk_buff *skb,
239 		       struct wmi_phyerr_ev_arg *arg)
240 {
241 	if (!ar->wmi.ops->pull_phyerr)
242 		return -EOPNOTSUPP;
243 
244 	return ar->wmi.ops->pull_phyerr(ar, skb, arg);
245 }
246 
247 static inline int
248 ath10k_wmi_pull_svc_rdy(struct ath10k *ar, struct sk_buff *skb,
249 			struct wmi_svc_rdy_ev_arg *arg)
250 {
251 	if (!ar->wmi.ops->pull_svc_rdy)
252 		return -EOPNOTSUPP;
253 
254 	return ar->wmi.ops->pull_svc_rdy(ar, skb, arg);
255 }
256 
257 static inline int
258 ath10k_wmi_pull_rdy(struct ath10k *ar, struct sk_buff *skb,
259 		    struct wmi_rdy_ev_arg *arg)
260 {
261 	if (!ar->wmi.ops->pull_rdy)
262 		return -EOPNOTSUPP;
263 
264 	return ar->wmi.ops->pull_rdy(ar, skb, arg);
265 }
266 
267 static inline int
268 ath10k_wmi_pull_fw_stats(struct ath10k *ar, struct sk_buff *skb,
269 			 struct ath10k_fw_stats *stats)
270 {
271 	if (!ar->wmi.ops->pull_fw_stats)
272 		return -EOPNOTSUPP;
273 
274 	return ar->wmi.ops->pull_fw_stats(ar, skb, stats);
275 }
276 
277 static inline int
278 ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
279 {
280 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(msdu);
281 	struct sk_buff *skb;
282 	int ret;
283 
284 	if (!ar->wmi.ops->gen_mgmt_tx)
285 		return -EOPNOTSUPP;
286 
287 	skb = ar->wmi.ops->gen_mgmt_tx(ar, msdu);
288 	if (IS_ERR(skb))
289 		return PTR_ERR(skb);
290 
291 	ret = ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->mgmt_tx_cmdid);
292 	if (ret)
293 		return ret;
294 
295 	/* FIXME There's no ACK event for Management Tx. This probably
296 	 * shouldn't be called here either. */
297 	info->flags |= IEEE80211_TX_STAT_ACK;
298 	ieee80211_tx_status_irqsafe(ar->hw, msdu);
299 
300 	return 0;
301 }
302 
303 static inline int
304 ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
305 			      u16 ctl2g, u16 ctl5g,
306 			      enum wmi_dfs_region dfs_reg)
307 {
308 	struct sk_buff *skb;
309 
310 	if (!ar->wmi.ops->gen_pdev_set_rd)
311 		return -EOPNOTSUPP;
312 
313 	skb = ar->wmi.ops->gen_pdev_set_rd(ar, rd, rd2g, rd5g, ctl2g, ctl5g,
314 					   dfs_reg);
315 	if (IS_ERR(skb))
316 		return PTR_ERR(skb);
317 
318 	return ath10k_wmi_cmd_send(ar, skb,
319 				   ar->wmi.cmd->pdev_set_regdomain_cmdid);
320 }
321 
322 static inline int
323 ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt)
324 {
325 	struct sk_buff *skb;
326 
327 	if (!ar->wmi.ops->gen_pdev_suspend)
328 		return -EOPNOTSUPP;
329 
330 	skb = ar->wmi.ops->gen_pdev_suspend(ar, suspend_opt);
331 	if (IS_ERR(skb))
332 		return PTR_ERR(skb);
333 
334 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_suspend_cmdid);
335 }
336 
337 static inline int
338 ath10k_wmi_pdev_resume_target(struct ath10k *ar)
339 {
340 	struct sk_buff *skb;
341 
342 	if (!ar->wmi.ops->gen_pdev_resume)
343 		return -EOPNOTSUPP;
344 
345 	skb = ar->wmi.ops->gen_pdev_resume(ar);
346 	if (IS_ERR(skb))
347 		return PTR_ERR(skb);
348 
349 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_resume_cmdid);
350 }
351 
352 static inline int
353 ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
354 {
355 	struct sk_buff *skb;
356 
357 	if (!ar->wmi.ops->gen_pdev_set_param)
358 		return -EOPNOTSUPP;
359 
360 	skb = ar->wmi.ops->gen_pdev_set_param(ar, id, value);
361 	if (IS_ERR(skb))
362 		return PTR_ERR(skb);
363 
364 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_set_param_cmdid);
365 }
366 
367 static inline int
368 ath10k_wmi_cmd_init(struct ath10k *ar)
369 {
370 	struct sk_buff *skb;
371 
372 	if (!ar->wmi.ops->gen_init)
373 		return -EOPNOTSUPP;
374 
375 	skb = ar->wmi.ops->gen_init(ar);
376 	if (IS_ERR(skb))
377 		return PTR_ERR(skb);
378 
379 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->init_cmdid);
380 }
381 
382 static inline int
383 ath10k_wmi_start_scan(struct ath10k *ar,
384 		      const struct wmi_start_scan_arg *arg)
385 {
386 	struct sk_buff *skb;
387 
388 	if (!ar->wmi.ops->gen_start_scan)
389 		return -EOPNOTSUPP;
390 
391 	skb = ar->wmi.ops->gen_start_scan(ar, arg);
392 	if (IS_ERR(skb))
393 		return PTR_ERR(skb);
394 
395 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->start_scan_cmdid);
396 }
397 
398 static inline int
399 ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg)
400 {
401 	struct sk_buff *skb;
402 
403 	if (!ar->wmi.ops->gen_stop_scan)
404 		return -EOPNOTSUPP;
405 
406 	skb = ar->wmi.ops->gen_stop_scan(ar, arg);
407 	if (IS_ERR(skb))
408 		return PTR_ERR(skb);
409 
410 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->stop_scan_cmdid);
411 }
412 
413 static inline int
414 ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id,
415 		       enum wmi_vdev_type type,
416 		       enum wmi_vdev_subtype subtype,
417 		       const u8 macaddr[ETH_ALEN])
418 {
419 	struct sk_buff *skb;
420 
421 	if (!ar->wmi.ops->gen_vdev_create)
422 		return -EOPNOTSUPP;
423 
424 	skb = ar->wmi.ops->gen_vdev_create(ar, vdev_id, type, subtype, macaddr);
425 	if (IS_ERR(skb))
426 		return PTR_ERR(skb);
427 
428 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_create_cmdid);
429 }
430 
431 static inline int
432 ath10k_wmi_vdev_delete(struct ath10k *ar, u32 vdev_id)
433 {
434 	struct sk_buff *skb;
435 
436 	if (!ar->wmi.ops->gen_vdev_delete)
437 		return -EOPNOTSUPP;
438 
439 	skb = ar->wmi.ops->gen_vdev_delete(ar, vdev_id);
440 	if (IS_ERR(skb))
441 		return PTR_ERR(skb);
442 
443 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_delete_cmdid);
444 }
445 
446 static inline int
447 ath10k_wmi_vdev_start(struct ath10k *ar,
448 		      const struct wmi_vdev_start_request_arg *arg)
449 {
450 	struct sk_buff *skb;
451 
452 	if (!ar->wmi.ops->gen_vdev_start)
453 		return -EOPNOTSUPP;
454 
455 	skb = ar->wmi.ops->gen_vdev_start(ar, arg, false);
456 	if (IS_ERR(skb))
457 		return PTR_ERR(skb);
458 
459 	return ath10k_wmi_cmd_send(ar, skb,
460 				   ar->wmi.cmd->vdev_start_request_cmdid);
461 }
462 
463 static inline int
464 ath10k_wmi_vdev_restart(struct ath10k *ar,
465 			const struct wmi_vdev_start_request_arg *arg)
466 {
467 	struct sk_buff *skb;
468 
469 	if (!ar->wmi.ops->gen_vdev_start)
470 		return -EOPNOTSUPP;
471 
472 	skb = ar->wmi.ops->gen_vdev_start(ar, arg, true);
473 	if (IS_ERR(skb))
474 		return PTR_ERR(skb);
475 
476 	return ath10k_wmi_cmd_send(ar, skb,
477 				   ar->wmi.cmd->vdev_restart_request_cmdid);
478 }
479 
480 static inline int
481 ath10k_wmi_vdev_stop(struct ath10k *ar, u32 vdev_id)
482 {
483 	struct sk_buff *skb;
484 
485 	if (!ar->wmi.ops->gen_vdev_stop)
486 		return -EOPNOTSUPP;
487 
488 	skb = ar->wmi.ops->gen_vdev_stop(ar, vdev_id);
489 	if (IS_ERR(skb))
490 		return PTR_ERR(skb);
491 
492 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_stop_cmdid);
493 }
494 
495 static inline int
496 ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid)
497 {
498 	struct sk_buff *skb;
499 
500 	if (!ar->wmi.ops->gen_vdev_up)
501 		return -EOPNOTSUPP;
502 
503 	skb = ar->wmi.ops->gen_vdev_up(ar, vdev_id, aid, bssid);
504 	if (IS_ERR(skb))
505 		return PTR_ERR(skb);
506 
507 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_up_cmdid);
508 }
509 
510 static inline int
511 ath10k_wmi_vdev_down(struct ath10k *ar, u32 vdev_id)
512 {
513 	struct sk_buff *skb;
514 
515 	if (!ar->wmi.ops->gen_vdev_down)
516 		return -EOPNOTSUPP;
517 
518 	skb = ar->wmi.ops->gen_vdev_down(ar, vdev_id);
519 	if (IS_ERR(skb))
520 		return PTR_ERR(skb);
521 
522 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_down_cmdid);
523 }
524 
525 static inline int
526 ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id, u32 param_id,
527 			  u32 param_value)
528 {
529 	struct sk_buff *skb;
530 
531 	if (!ar->wmi.ops->gen_vdev_set_param)
532 		return -EOPNOTSUPP;
533 
534 	skb = ar->wmi.ops->gen_vdev_set_param(ar, vdev_id, param_id,
535 					      param_value);
536 	if (IS_ERR(skb))
537 		return PTR_ERR(skb);
538 
539 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_set_param_cmdid);
540 }
541 
542 static inline int
543 ath10k_wmi_vdev_install_key(struct ath10k *ar,
544 			    const struct wmi_vdev_install_key_arg *arg)
545 {
546 	struct sk_buff *skb;
547 
548 	if (!ar->wmi.ops->gen_vdev_install_key)
549 		return -EOPNOTSUPP;
550 
551 	skb = ar->wmi.ops->gen_vdev_install_key(ar, arg);
552 	if (IS_ERR(skb))
553 		return PTR_ERR(skb);
554 
555 	return ath10k_wmi_cmd_send(ar, skb,
556 				   ar->wmi.cmd->vdev_install_key_cmdid);
557 }
558 
559 static inline int
560 ath10k_wmi_vdev_spectral_conf(struct ath10k *ar,
561 			      const struct wmi_vdev_spectral_conf_arg *arg)
562 {
563 	struct sk_buff *skb;
564 	u32 cmd_id;
565 
566 	skb = ar->wmi.ops->gen_vdev_spectral_conf(ar, arg);
567 	if (IS_ERR(skb))
568 		return PTR_ERR(skb);
569 
570 	cmd_id = ar->wmi.cmd->vdev_spectral_scan_configure_cmdid;
571 	return ath10k_wmi_cmd_send(ar, skb, cmd_id);
572 }
573 
574 static inline int
575 ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger,
576 				u32 enable)
577 {
578 	struct sk_buff *skb;
579 	u32 cmd_id;
580 
581 	skb = ar->wmi.ops->gen_vdev_spectral_enable(ar, vdev_id, trigger,
582 						    enable);
583 	if (IS_ERR(skb))
584 		return PTR_ERR(skb);
585 
586 	cmd_id = ar->wmi.cmd->vdev_spectral_scan_enable_cmdid;
587 	return ath10k_wmi_cmd_send(ar, skb, cmd_id);
588 }
589 
590 static inline int
591 ath10k_wmi_vdev_sta_uapsd(struct ath10k *ar, u32 vdev_id,
592 			  const u8 peer_addr[ETH_ALEN],
593 			  const struct wmi_sta_uapsd_auto_trig_arg *args,
594 			  u32 num_ac)
595 {
596 	struct sk_buff *skb;
597 	u32 cmd_id;
598 
599 	if (!ar->wmi.ops->gen_vdev_sta_uapsd)
600 		return -EOPNOTSUPP;
601 
602 	skb = ar->wmi.ops->gen_vdev_sta_uapsd(ar, vdev_id, peer_addr, args,
603 					      num_ac);
604 	if (IS_ERR(skb))
605 		return PTR_ERR(skb);
606 
607 	cmd_id = ar->wmi.cmd->sta_uapsd_auto_trig_cmdid;
608 	return ath10k_wmi_cmd_send(ar, skb, cmd_id);
609 }
610 
611 static inline int
612 ath10k_wmi_vdev_wmm_conf(struct ath10k *ar, u32 vdev_id,
613 			 const struct wmi_wmm_params_all_arg *arg)
614 {
615 	struct sk_buff *skb;
616 	u32 cmd_id;
617 
618 	skb = ar->wmi.ops->gen_vdev_wmm_conf(ar, vdev_id, arg);
619 	if (IS_ERR(skb))
620 		return PTR_ERR(skb);
621 
622 	cmd_id = ar->wmi.cmd->vdev_set_wmm_params_cmdid;
623 	return ath10k_wmi_cmd_send(ar, skb, cmd_id);
624 }
625 
626 static inline int
627 ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id,
628 		       const u8 peer_addr[ETH_ALEN])
629 {
630 	struct sk_buff *skb;
631 
632 	if (!ar->wmi.ops->gen_peer_create)
633 		return -EOPNOTSUPP;
634 
635 	skb = ar->wmi.ops->gen_peer_create(ar, vdev_id, peer_addr);
636 	if (IS_ERR(skb))
637 		return PTR_ERR(skb);
638 
639 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_create_cmdid);
640 }
641 
642 static inline int
643 ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id,
644 		       const u8 peer_addr[ETH_ALEN])
645 {
646 	struct sk_buff *skb;
647 
648 	if (!ar->wmi.ops->gen_peer_delete)
649 		return -EOPNOTSUPP;
650 
651 	skb = ar->wmi.ops->gen_peer_delete(ar, vdev_id, peer_addr);
652 	if (IS_ERR(skb))
653 		return PTR_ERR(skb);
654 
655 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_delete_cmdid);
656 }
657 
658 static inline int
659 ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id,
660 		      const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
661 {
662 	struct sk_buff *skb;
663 
664 	if (!ar->wmi.ops->gen_peer_flush)
665 		return -EOPNOTSUPP;
666 
667 	skb = ar->wmi.ops->gen_peer_flush(ar, vdev_id, peer_addr, tid_bitmap);
668 	if (IS_ERR(skb))
669 		return PTR_ERR(skb);
670 
671 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_flush_tids_cmdid);
672 }
673 
674 static inline int
675 ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id, const u8 *peer_addr,
676 			  enum wmi_peer_param param_id, u32 param_value)
677 {
678 	struct sk_buff *skb;
679 
680 	if (!ar->wmi.ops->gen_peer_set_param)
681 		return -EOPNOTSUPP;
682 
683 	skb = ar->wmi.ops->gen_peer_set_param(ar, vdev_id, peer_addr, param_id,
684 					      param_value);
685 	if (IS_ERR(skb))
686 		return PTR_ERR(skb);
687 
688 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_set_param_cmdid);
689 }
690 
691 static inline int
692 ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
693 		      enum wmi_sta_ps_mode psmode)
694 {
695 	struct sk_buff *skb;
696 
697 	if (!ar->wmi.ops->gen_set_psmode)
698 		return -EOPNOTSUPP;
699 
700 	skb = ar->wmi.ops->gen_set_psmode(ar, vdev_id, psmode);
701 	if (IS_ERR(skb))
702 		return PTR_ERR(skb);
703 
704 	return ath10k_wmi_cmd_send(ar, skb,
705 				   ar->wmi.cmd->sta_powersave_mode_cmdid);
706 }
707 
708 static inline int
709 ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
710 			    enum wmi_sta_powersave_param param_id, u32 value)
711 {
712 	struct sk_buff *skb;
713 
714 	if (!ar->wmi.ops->gen_set_sta_ps)
715 		return -EOPNOTSUPP;
716 
717 	skb = ar->wmi.ops->gen_set_sta_ps(ar, vdev_id, param_id, value);
718 	if (IS_ERR(skb))
719 		return PTR_ERR(skb);
720 
721 	return ath10k_wmi_cmd_send(ar, skb,
722 				   ar->wmi.cmd->sta_powersave_param_cmdid);
723 }
724 
725 static inline int
726 ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
727 			   enum wmi_ap_ps_peer_param param_id, u32 value)
728 {
729 	struct sk_buff *skb;
730 
731 	if (!ar->wmi.ops->gen_set_ap_ps)
732 		return -EOPNOTSUPP;
733 
734 	skb = ar->wmi.ops->gen_set_ap_ps(ar, vdev_id, mac, param_id, value);
735 	if (IS_ERR(skb))
736 		return PTR_ERR(skb);
737 
738 	return ath10k_wmi_cmd_send(ar, skb,
739 				   ar->wmi.cmd->ap_ps_peer_param_cmdid);
740 }
741 
742 static inline int
743 ath10k_wmi_scan_chan_list(struct ath10k *ar,
744 			  const struct wmi_scan_chan_list_arg *arg)
745 {
746 	struct sk_buff *skb;
747 
748 	if (!ar->wmi.ops->gen_scan_chan_list)
749 		return -EOPNOTSUPP;
750 
751 	skb = ar->wmi.ops->gen_scan_chan_list(ar, arg);
752 	if (IS_ERR(skb))
753 		return PTR_ERR(skb);
754 
755 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->scan_chan_list_cmdid);
756 }
757 
758 static inline int
759 ath10k_wmi_peer_assoc(struct ath10k *ar,
760 		      const struct wmi_peer_assoc_complete_arg *arg)
761 {
762 	struct sk_buff *skb;
763 
764 	if (!ar->wmi.ops->gen_peer_assoc)
765 		return -EOPNOTSUPP;
766 
767 	skb = ar->wmi.ops->gen_peer_assoc(ar, arg);
768 	if (IS_ERR(skb))
769 		return PTR_ERR(skb);
770 
771 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_assoc_cmdid);
772 }
773 
774 static inline int
775 ath10k_wmi_beacon_send_ref_nowait(struct ath10k *ar, u32 vdev_id,
776 				  const void *bcn, size_t bcn_len,
777 				  u32 bcn_paddr, bool dtim_zero,
778 				  bool deliver_cab)
779 {
780 	struct sk_buff *skb;
781 	int ret;
782 
783 	if (!ar->wmi.ops->gen_beacon_dma)
784 		return -EOPNOTSUPP;
785 
786 	skb = ar->wmi.ops->gen_beacon_dma(ar, vdev_id, bcn, bcn_len, bcn_paddr,
787 					  dtim_zero, deliver_cab);
788 	if (IS_ERR(skb))
789 		return PTR_ERR(skb);
790 
791 	ret = ath10k_wmi_cmd_send_nowait(ar, skb,
792 					 ar->wmi.cmd->pdev_send_bcn_cmdid);
793 	if (ret) {
794 		dev_kfree_skb(skb);
795 		return ret;
796 	}
797 
798 	return 0;
799 }
800 
801 static inline int
802 ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar,
803 			       const struct wmi_wmm_params_all_arg *arg)
804 {
805 	struct sk_buff *skb;
806 
807 	if (!ar->wmi.ops->gen_pdev_set_wmm)
808 		return -EOPNOTSUPP;
809 
810 	skb = ar->wmi.ops->gen_pdev_set_wmm(ar, arg);
811 	if (IS_ERR(skb))
812 		return PTR_ERR(skb);
813 
814 	return ath10k_wmi_cmd_send(ar, skb,
815 				   ar->wmi.cmd->pdev_set_wmm_params_cmdid);
816 }
817 
818 static inline int
819 ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id)
820 {
821 	struct sk_buff *skb;
822 
823 	if (!ar->wmi.ops->gen_request_stats)
824 		return -EOPNOTSUPP;
825 
826 	skb = ar->wmi.ops->gen_request_stats(ar, stats_id);
827 	if (IS_ERR(skb))
828 		return PTR_ERR(skb);
829 
830 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->request_stats_cmdid);
831 }
832 
833 static inline int
834 ath10k_wmi_force_fw_hang(struct ath10k *ar,
835 			 enum wmi_force_fw_hang_type type, u32 delay_ms)
836 {
837 	struct sk_buff *skb;
838 
839 	if (!ar->wmi.ops->gen_force_fw_hang)
840 		return -EOPNOTSUPP;
841 
842 	skb = ar->wmi.ops->gen_force_fw_hang(ar, type, delay_ms);
843 	if (IS_ERR(skb))
844 		return PTR_ERR(skb);
845 
846 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
847 }
848 
849 static inline int
850 ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable, u32 log_level)
851 {
852 	struct sk_buff *skb;
853 
854 	if (!ar->wmi.ops->gen_dbglog_cfg)
855 		return -EOPNOTSUPP;
856 
857 	skb = ar->wmi.ops->gen_dbglog_cfg(ar, module_enable, log_level);
858 	if (IS_ERR(skb))
859 		return PTR_ERR(skb);
860 
861 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->dbglog_cfg_cmdid);
862 }
863 
864 static inline int
865 ath10k_wmi_pdev_pktlog_enable(struct ath10k *ar, u32 filter)
866 {
867 	struct sk_buff *skb;
868 
869 	if (!ar->wmi.ops->gen_pktlog_enable)
870 		return -EOPNOTSUPP;
871 
872 	skb = ar->wmi.ops->gen_pktlog_enable(ar, filter);
873 	if (IS_ERR(skb))
874 		return PTR_ERR(skb);
875 
876 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_pktlog_enable_cmdid);
877 }
878 
879 static inline int
880 ath10k_wmi_pdev_pktlog_disable(struct ath10k *ar)
881 {
882 	struct sk_buff *skb;
883 
884 	if (!ar->wmi.ops->gen_pktlog_disable)
885 		return -EOPNOTSUPP;
886 
887 	skb = ar->wmi.ops->gen_pktlog_disable(ar);
888 	if (IS_ERR(skb))
889 		return PTR_ERR(skb);
890 
891 	return ath10k_wmi_cmd_send(ar, skb,
892 				   ar->wmi.cmd->pdev_pktlog_disable_cmdid);
893 }
894 
895 static inline int
896 ath10k_wmi_pdev_set_quiet_mode(struct ath10k *ar, u32 period, u32 duration,
897 			       u32 next_offset, u32 enabled)
898 {
899 	struct sk_buff *skb;
900 
901 	if (!ar->wmi.ops->gen_pdev_set_quiet_mode)
902 		return -EOPNOTSUPP;
903 
904 	skb = ar->wmi.ops->gen_pdev_set_quiet_mode(ar, period, duration,
905 						   next_offset, enabled);
906 	if (IS_ERR(skb))
907 		return PTR_ERR(skb);
908 
909 	return ath10k_wmi_cmd_send(ar, skb,
910 				   ar->wmi.cmd->pdev_set_quiet_mode_cmdid);
911 }
912 
913 static inline int
914 ath10k_wmi_pdev_get_temperature(struct ath10k *ar)
915 {
916 	struct sk_buff *skb;
917 
918 	if (!ar->wmi.ops->gen_pdev_get_temperature)
919 		return -EOPNOTSUPP;
920 
921 	skb = ar->wmi.ops->gen_pdev_get_temperature(ar);
922 	if (IS_ERR(skb))
923 		return PTR_ERR(skb);
924 
925 	return ath10k_wmi_cmd_send(ar, skb,
926 				   ar->wmi.cmd->pdev_get_temperature_cmdid);
927 }
928 
929 static inline int
930 ath10k_wmi_addba_clear_resp(struct ath10k *ar, u32 vdev_id, const u8 *mac)
931 {
932 	struct sk_buff *skb;
933 
934 	if (!ar->wmi.ops->gen_addba_clear_resp)
935 		return -EOPNOTSUPP;
936 
937 	skb = ar->wmi.ops->gen_addba_clear_resp(ar, vdev_id, mac);
938 	if (IS_ERR(skb))
939 		return PTR_ERR(skb);
940 
941 	return ath10k_wmi_cmd_send(ar, skb,
942 				   ar->wmi.cmd->addba_clear_resp_cmdid);
943 }
944 
945 static inline int
946 ath10k_wmi_addba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
947 		      u32 tid, u32 buf_size)
948 {
949 	struct sk_buff *skb;
950 
951 	if (!ar->wmi.ops->gen_addba_send)
952 		return -EOPNOTSUPP;
953 
954 	skb = ar->wmi.ops->gen_addba_send(ar, vdev_id, mac, tid, buf_size);
955 	if (IS_ERR(skb))
956 		return PTR_ERR(skb);
957 
958 	return ath10k_wmi_cmd_send(ar, skb,
959 				   ar->wmi.cmd->addba_send_cmdid);
960 }
961 
962 static inline int
963 ath10k_wmi_addba_set_resp(struct ath10k *ar, u32 vdev_id, const u8 *mac,
964 			  u32 tid, u32 status)
965 {
966 	struct sk_buff *skb;
967 
968 	if (!ar->wmi.ops->gen_addba_set_resp)
969 		return -EOPNOTSUPP;
970 
971 	skb = ar->wmi.ops->gen_addba_set_resp(ar, vdev_id, mac, tid, status);
972 	if (IS_ERR(skb))
973 		return PTR_ERR(skb);
974 
975 	return ath10k_wmi_cmd_send(ar, skb,
976 				   ar->wmi.cmd->addba_set_resp_cmdid);
977 }
978 
979 static inline int
980 ath10k_wmi_delba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
981 		      u32 tid, u32 initiator, u32 reason)
982 {
983 	struct sk_buff *skb;
984 
985 	if (!ar->wmi.ops->gen_delba_send)
986 		return -EOPNOTSUPP;
987 
988 	skb = ar->wmi.ops->gen_delba_send(ar, vdev_id, mac, tid, initiator,
989 					  reason);
990 	if (IS_ERR(skb))
991 		return PTR_ERR(skb);
992 
993 	return ath10k_wmi_cmd_send(ar, skb,
994 				   ar->wmi.cmd->delba_send_cmdid);
995 }
996 
997 static inline int
998 ath10k_wmi_bcn_tmpl(struct ath10k *ar, u32 vdev_id, u32 tim_ie_offset,
999 		    struct sk_buff *bcn, u32 prb_caps, u32 prb_erp,
1000 		    void *prb_ies, size_t prb_ies_len)
1001 {
1002 	struct sk_buff *skb;
1003 
1004 	if (!ar->wmi.ops->gen_bcn_tmpl)
1005 		return -EOPNOTSUPP;
1006 
1007 	skb = ar->wmi.ops->gen_bcn_tmpl(ar, vdev_id, tim_ie_offset, bcn,
1008 					prb_caps, prb_erp, prb_ies,
1009 					prb_ies_len);
1010 	if (IS_ERR(skb))
1011 		return PTR_ERR(skb);
1012 
1013 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->bcn_tmpl_cmdid);
1014 }
1015 
1016 static inline int
1017 ath10k_wmi_prb_tmpl(struct ath10k *ar, u32 vdev_id, struct sk_buff *prb)
1018 {
1019 	struct sk_buff *skb;
1020 
1021 	if (!ar->wmi.ops->gen_prb_tmpl)
1022 		return -EOPNOTSUPP;
1023 
1024 	skb = ar->wmi.ops->gen_prb_tmpl(ar, vdev_id, prb);
1025 	if (IS_ERR(skb))
1026 		return PTR_ERR(skb);
1027 
1028 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->prb_tmpl_cmdid);
1029 }
1030 
1031 static inline int
1032 ath10k_wmi_p2p_go_bcn_ie(struct ath10k *ar, u32 vdev_id, const u8 *p2p_ie)
1033 {
1034 	struct sk_buff *skb;
1035 
1036 	if (!ar->wmi.ops->gen_p2p_go_bcn_ie)
1037 		return -EOPNOTSUPP;
1038 
1039 	skb = ar->wmi.ops->gen_p2p_go_bcn_ie(ar, vdev_id, p2p_ie);
1040 	if (IS_ERR(skb))
1041 		return PTR_ERR(skb);
1042 
1043 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->p2p_go_set_beacon_ie);
1044 }
1045 
1046 static inline int
1047 ath10k_wmi_sta_keepalive(struct ath10k *ar,
1048 			 const struct wmi_sta_keepalive_arg *arg)
1049 {
1050 	struct sk_buff *skb;
1051 	u32 cmd_id;
1052 
1053 	if (!ar->wmi.ops->gen_sta_keepalive)
1054 		return -EOPNOTSUPP;
1055 
1056 	skb = ar->wmi.ops->gen_sta_keepalive(ar, arg);
1057 	if (IS_ERR(skb))
1058 		return PTR_ERR(skb);
1059 
1060 	cmd_id = ar->wmi.cmd->sta_keepalive_cmd;
1061 	return ath10k_wmi_cmd_send(ar, skb, cmd_id);
1062 }
1063 
1064 #endif
1065