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