xref: /wlan-dirver/qca-wifi-host-cmn/umac/dcs/dispatcher/src/wlan_dcs_ucfg_api.c (revision 6d768494e5ce14eb1603a695c86739d12ecc6ec2)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
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 /**
18  * DOC: This file has the dcs dispatcher API implementation which is exposed
19  * to outside of dcs component.
20  */
21 
22 #include "wlan_dcs_ucfg_api.h"
23 #include "../../core/src/wlan_dcs.h"
24 
25 void ucfg_dcs_register_cb(
26 			struct wlan_objmgr_psoc *psoc,
27 			dcs_callback cbk,
28 			void *arg)
29 {
30 	struct dcs_psoc_priv_obj *dcs_psoc_priv;
31 
32 	dcs_psoc_priv = wlan_objmgr_psoc_get_comp_private_obj(
33 							psoc,
34 							WLAN_UMAC_COMP_DCS);
35 	if (!dcs_psoc_priv) {
36 		dcs_err("dcs psoc private object is null");
37 		return;
38 	}
39 
40 	dcs_psoc_priv->dcs_cbk.cbk = cbk;
41 	dcs_psoc_priv->dcs_cbk.arg = arg;
42 }
43 
44 QDF_STATUS
45 ucfg_wlan_dcs_cmd(struct wlan_objmgr_psoc *psoc,
46 		  uint32_t pdev_id,
47 		  bool is_host_pdev_id)
48 {
49 	return wlan_dcs_cmd_send(psoc, pdev_id, is_host_pdev_id);
50 }
51 
52 void ucfg_config_dcs_enable(struct wlan_objmgr_psoc *psoc,
53 			    uint32_t pdev_id,
54 			    uint8_t interference_type)
55 {
56 	struct dcs_pdev_priv_obj *dcs_pdev_priv;
57 
58 	dcs_pdev_priv = wlan_dcs_get_pdev_private_obj(psoc, pdev_id);
59 	if (!dcs_pdev_priv) {
60 		dcs_err("dcs pdev private object is null");
61 		return;
62 	}
63 
64 	dcs_pdev_priv->dcs_host_params.dcs_enable |= interference_type;
65 }
66 
67 void ucfg_config_dcs_disable(struct wlan_objmgr_psoc *psoc,
68 			     uint32_t pdev_id,
69 			     uint8_t interference_type)
70 {
71 	struct dcs_pdev_priv_obj *dcs_pdev_priv;
72 
73 	dcs_pdev_priv = wlan_dcs_get_pdev_private_obj(psoc, pdev_id);
74 	if (!dcs_pdev_priv) {
75 		dcs_err("dcs pdev private object is null");
76 		return;
77 	}
78 
79 	dcs_pdev_priv->dcs_host_params.dcs_enable &= (~interference_type);
80 }
81 
82 uint8_t ucfg_get_dcs_enable(struct wlan_objmgr_psoc *psoc, uint32_t pdev_id)
83 {
84 	struct dcs_pdev_priv_obj *dcs_pdev_priv;
85 
86 	dcs_pdev_priv = wlan_dcs_get_pdev_private_obj(psoc, pdev_id);
87 	if (!dcs_pdev_priv) {
88 		dcs_err("dcs pdev private object is null");
89 		return 0;
90 	}
91 
92 	return dcs_pdev_priv->dcs_host_params.dcs_enable;
93 }
94