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