xref: /wlan-dirver/qca-wifi-host-cmn/target_if/son/src/target_if_son.c (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  *
6  * Permission to use, copy, modify, and/or distribute this software for
7  * any purpose with or without fee is hereby granted, provided that the
8  * above copyright notice and this permission notice appear in all
9  * copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  * PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 #include <target_if_son.h>
22 #include <target_if.h>
23 #include <wlan_lmac_if_def.h>
24 #include <wmi_unified_api.h>
25 #include <cdp_txrx_ctrl.h>
26 
27 #if defined(QCA_SUPPORT_SON)
28 
29 u_int32_t son_ol_get_peer_rate(struct wlan_objmgr_peer *peer, u_int8_t type)
30 {
31 	return ol_if_peer_get_rate(peer, type);
32 }
33 #else
34 
35 u_int32_t son_ol_get_peer_rate(struct wlan_objmgr_peer *peer, u_int8_t type)
36 {
37 	return 0;
38 }
39 #endif
40 
41 #if defined(QCA_SUPPORT_SON) || defined(WLAN_FEATURE_SON)
42 
43 QDF_STATUS son_ol_send_null(struct wlan_objmgr_pdev *pdev,
44 			 u_int8_t *macaddr,
45 			 struct wlan_objmgr_vdev *vdev)
46 {
47 	struct stats_request_params param = {0};
48 	struct wlan_objmgr_psoc *psoc = NULL;
49 	wmi_unified_t wmi_handle;
50 
51 	psoc = wlan_pdev_get_psoc(pdev);
52 	if (!psoc)
53 		return QDF_STATUS_E_FAILURE;
54 
55 	param.vdev_id = wlan_vdev_get_id(vdev);
56 	param.stats_id = WMI_HOST_REQUEST_INST_STAT;
57 
58 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
59 	if (!wmi_handle)
60 		return QDF_STATUS_E_FAILURE;
61 
62 	return wmi_unified_stats_request_send(wmi_handle, macaddr, &param);
63 }
64 
65 QDF_STATUS son_ol_peer_ext_stats_enable(struct wlan_objmgr_pdev *pdev,
66 					uint8_t *peer_addr,
67 					struct wlan_objmgr_vdev *vdev,
68 					uint32_t stats_count, uint32_t enable)
69 {
70 	struct peer_set_params param = {0};
71 	struct wlan_objmgr_psoc *psoc = NULL;
72 	struct target_psoc_info *tgt_hdl;
73 	target_resource_config *tgt_cfg;
74 	wmi_unified_t wmi_handle;
75 
76 	psoc = wlan_pdev_get_psoc(pdev);
77 	if (!psoc)
78 		return QDF_STATUS_E_INVAL;
79 
80 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
81 	if (!tgt_hdl)
82 		return QDF_STATUS_E_INVAL;
83 
84 	tgt_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
85 	if (!tgt_cfg)
86 		return QDF_STATUS_E_INVAL;
87 
88 	if (enable && stats_count >= tgt_cfg->max_peer_ext_stats)
89 		return QDF_STATUS_E_NOMEM;
90 
91 	wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
92 	if (!wmi_handle)
93 		return QDF_STATUS_E_INVAL;
94 
95 	param.param_id = WMI_HOST_PEER_EXT_STATS_ENABLE;
96 	param.vdev_id = wlan_vdev_get_id(vdev);
97 	param.param_value = enable;
98 
99 	return wmi_set_peer_param_send(wmi_handle, peer_addr, &param);
100 }
101 
102 void target_if_son_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
103 {
104 	/* wlan son related function handler */
105 	tx_ops->son_tx_ops.son_send_null = son_ol_send_null;
106 	tx_ops->son_tx_ops.get_peer_rate = son_ol_get_peer_rate;
107 	tx_ops->son_tx_ops.peer_ext_stats_enable = son_ol_peer_ext_stats_enable;
108 	return;
109 }
110 
111 #else
112 
113 void target_if_son_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
114 {
115 	return;
116 }
117 
118 QDF_STATUS son_ol_send_null(struct wlan_objmgr_pdev *pdev,
119 			    u_int8_t *macaddr,
120 			    struct wlan_objmgr_vdev *vdev)
121 {
122 	return QDF_STATUS_SUCCESS;
123 }
124 
125 #endif
126