xref: /wlan-driver/qca-wifi-host-cmn/target_if/son/src/target_if_son.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
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 
son_ol_get_peer_rate(struct wlan_objmgr_peer * peer,u_int8_t type)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 
son_ol_get_peer_rate(struct wlan_objmgr_peer * peer,u_int8_t type)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 
son_ol_send_null(struct wlan_objmgr_pdev * pdev,u_int8_t * macaddr,struct wlan_objmgr_vdev * vdev)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 #if defined(WMI_NON_TLV_SUPPORT) || defined(WMI_TLV_AND_NON_TLV_SUPPORT)
son_ol_peer_ext_stats_enable(struct wlan_objmgr_pdev * pdev,uint8_t * peer_addr,struct wlan_objmgr_vdev * vdev,uint32_t stats_count,uint32_t enable)66 QDF_STATUS son_ol_peer_ext_stats_enable(struct wlan_objmgr_pdev *pdev,
67 					uint8_t *peer_addr,
68 					struct wlan_objmgr_vdev *vdev,
69 					uint32_t stats_count, uint32_t enable)
70 {
71 	struct peer_set_params param = {0};
72 	struct wlan_objmgr_psoc *psoc = NULL;
73 	struct target_psoc_info *tgt_hdl;
74 	target_resource_config *tgt_cfg;
75 	wmi_unified_t wmi_handle;
76 
77 	psoc = wlan_pdev_get_psoc(pdev);
78 	if (!psoc)
79 		return QDF_STATUS_E_INVAL;
80 
81 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
82 	if (!tgt_hdl)
83 		return QDF_STATUS_E_INVAL;
84 
85 	tgt_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
86 	if (!tgt_cfg)
87 		return QDF_STATUS_E_INVAL;
88 
89 	if (enable && stats_count >= tgt_cfg->max_peer_ext_stats)
90 		return QDF_STATUS_E_NOMEM;
91 
92 	wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
93 	if (!wmi_handle)
94 		return QDF_STATUS_E_INVAL;
95 
96 	param.param_id = WMI_HOST_PEER_EXT_STATS_ENABLE;
97 	param.vdev_id = wlan_vdev_get_id(vdev);
98 	param.param_value = enable;
99 
100 	return wmi_set_peer_param_send(wmi_handle, peer_addr, &param);
101 }
102 #endif
103 
target_if_son_register_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)104 void target_if_son_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
105 {
106 	/* wlan son related function handler */
107 	tx_ops->son_tx_ops.son_send_null = son_ol_send_null;
108 	tx_ops->son_tx_ops.get_peer_rate = son_ol_get_peer_rate;
109 	tx_ops->son_tx_ops.peer_ext_stats_enable = son_ol_peer_ext_stats_enable;
110 	return;
111 }
112 
113 #else
114 
target_if_son_register_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)115 void target_if_son_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
116 {
117 	return;
118 }
119 
son_ol_send_null(struct wlan_objmgr_pdev * pdev,u_int8_t * macaddr,struct wlan_objmgr_vdev * vdev)120 QDF_STATUS son_ol_send_null(struct wlan_objmgr_pdev *pdev,
121 			    u_int8_t *macaddr,
122 			    struct wlan_objmgr_vdev *vdev)
123 {
124 	return QDF_STATUS_SUCCESS;
125 }
126 
127 #endif
128