xref: /wlan-driver/qcacld-3.0/components/coex/dispatcher/src/wlan_coex_tgt_api.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
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 /*
19  * DOC: contains coex south bound interface definitions
20  */
21 
22 #include <wlan_coex_main.h>
23 #include <wlan_coex_tgt_api.h>
24 #include <wlan_lmac_if_def.h>
25 #include "wlan_objmgr_pdev_obj.h"
26 
27 static inline struct wlan_lmac_if_coex_tx_ops *
wlan_psoc_get_coex_txops(struct wlan_objmgr_psoc * psoc)28 wlan_psoc_get_coex_txops(struct wlan_objmgr_psoc *psoc)
29 {
30 	struct wlan_lmac_if_tx_ops *tx_ops;
31 
32 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
33 	if (!tx_ops) {
34 		coex_err("tx_ops is NULL");
35 		return NULL;
36 	}
37 
38 	return &tx_ops->coex_ops;
39 }
40 
41 static inline struct wlan_lmac_if_coex_tx_ops *
wlan_vdev_get_coex_txops(struct wlan_objmgr_vdev * vdev)42 wlan_vdev_get_coex_txops(struct wlan_objmgr_vdev *vdev)
43 {
44 	struct wlan_objmgr_psoc *psoc;
45 
46 	psoc = wlan_vdev_get_psoc(vdev);
47 	if (!psoc) {
48 		coex_err("NULL psoc");
49 		return NULL;
50 	}
51 
52 	return wlan_psoc_get_coex_txops(psoc);
53 }
54 
55 QDF_STATUS
tgt_send_coex_config(struct wlan_objmgr_vdev * vdev,struct coex_config_params * param)56 tgt_send_coex_config(struct wlan_objmgr_vdev *vdev,
57 		     struct coex_config_params *param)
58 {
59 	struct wlan_lmac_if_coex_tx_ops *coex_ops;
60 	struct wlan_objmgr_psoc *psoc;
61 	struct wlan_objmgr_pdev *pdev;
62 
63 	if (!vdev) {
64 		coex_err("NULL vdev");
65 		return QDF_STATUS_E_NULL_VALUE;
66 	}
67 
68 	psoc = wlan_vdev_get_psoc(vdev);
69 	if (!psoc) {
70 		coex_err("NULL psoc");
71 		return QDF_STATUS_E_NULL_VALUE;
72 	}
73 
74 	pdev = wlan_vdev_get_pdev(vdev);
75 	if (!pdev) {
76 		coex_err("NULL pdev");
77 		return QDF_STATUS_E_NULL_VALUE;
78 	}
79 
80 	coex_ops = wlan_psoc_get_coex_txops(psoc);
81 	if (coex_ops && coex_ops->coex_config_send)
82 		return coex_ops->coex_config_send(pdev, param);
83 
84 	return QDF_STATUS_SUCCESS;
85 }
86 
87 QDF_STATUS
tgt_send_coex_multi_config(struct wlan_objmgr_vdev * vdev,struct coex_multi_config * param)88 tgt_send_coex_multi_config(struct wlan_objmgr_vdev *vdev,
89 			   struct coex_multi_config *param)
90 {
91 	struct wlan_lmac_if_coex_tx_ops *coex_ops;
92 	struct wlan_objmgr_psoc *psoc;
93 	struct wlan_objmgr_pdev *pdev;
94 
95 	if (!vdev) {
96 		coex_err("NULL vdev");
97 		return QDF_STATUS_E_NULL_VALUE;
98 	}
99 
100 	psoc = wlan_vdev_get_psoc(vdev);
101 	if (!psoc) {
102 		coex_err("NULL psoc");
103 		return QDF_STATUS_E_NULL_VALUE;
104 	}
105 
106 	pdev = wlan_vdev_get_pdev(vdev);
107 	if (!pdev) {
108 		coex_err("NULL pdev");
109 		return QDF_STATUS_E_NULL_VALUE;
110 	}
111 
112 	coex_ops = wlan_psoc_get_coex_txops(psoc);
113 	if (coex_ops && coex_ops->coex_multi_config_send)
114 		return coex_ops->coex_multi_config_send(pdev, param);
115 
116 	return QDF_STATUS_SUCCESS;
117 }
118 
119 bool
tgt_get_coex_multi_config_support(struct wlan_objmgr_psoc * psoc)120 tgt_get_coex_multi_config_support(struct wlan_objmgr_psoc *psoc)
121 {
122 	struct wlan_lmac_if_coex_tx_ops *coex_ops;
123 
124 	coex_ops = wlan_psoc_get_coex_txops(psoc);
125 	if (coex_ops && coex_ops->coex_get_multi_config_support)
126 		return coex_ops->coex_get_multi_config_support(psoc);
127 
128 	return false;
129 }
130 
131 #ifdef WLAN_FEATURE_DBAM_CONFIG
132 QDF_STATUS
tgt_send_dbam_config(struct wlan_objmgr_vdev * vdev,struct coex_dbam_config_params * param)133 tgt_send_dbam_config(struct wlan_objmgr_vdev *vdev,
134 		     struct coex_dbam_config_params *param)
135 {
136 	struct wlan_lmac_if_dbam_tx_ops *dbam_tx_ops;
137 	struct wlan_objmgr_psoc *psoc;
138 
139 	psoc = wlan_vdev_get_psoc(vdev);
140 	if (!psoc) {
141 		coex_err("NULL psoc");
142 		return QDF_STATUS_E_NULL_VALUE;
143 	}
144 
145 	dbam_tx_ops = wlan_psoc_get_dbam_tx_ops(psoc);
146 	if (dbam_tx_ops && dbam_tx_ops->set_dbam_config)
147 		return dbam_tx_ops->set_dbam_config(psoc, param);
148 
149 	return QDF_STATUS_SUCCESS;
150 }
151 #endif
152