xref: /wlan-dirver/qca-wifi-host-cmn/target_if/spatial_reuse/src/target_if_spatial_reuse.c (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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_spatial_reuse.h>
21 #include <wlan_lmac_if_def.h>
22 #include <wmi_unified_api.h>
23 #include <target_if_vdev_mgr_tx_ops.h>
24 
25 static QDF_STATUS spatial_reuse_send_cfg(struct wlan_objmgr_vdev *vdev,
26 					 uint8_t sr_ctrl,
27 					 uint8_t non_srg_max_pd_offset)
28 {
29 	struct pdev_params pparam;
30 	wmi_unified_t wmi_handle;
31 
32 	wmi_handle = target_if_vdev_mgr_wmi_handle_get(vdev);
33 	if (!wmi_handle) {
34 		mlme_err("Failed to get WMI handle!");
35 		return QDF_STATUS_E_INVAL;
36 	}
37 
38 	qdf_mem_zero(&pparam, sizeof(pparam));
39 	pparam.param_id = WMI_PDEV_PARAM_SET_CMD_OBSS_PD_THRESHOLD;
40 	if (!(sr_ctrl & NON_SRG_PD_SR_DISALLOWED) &&
41 	    (sr_ctrl & NON_SRG_OFFSET_PRESENT)) {
42 		QDF_SET_BITS(pparam.param_value, NON_SRG_SPR_ENABLE_POS,
43 			     NON_SRG_SPR_ENABLE_SIZE, NON_SRG_SPR_ENABLE);
44 		QDF_SET_BITS(pparam.param_value, NON_SRG_PARAM_VAL_DBM_POS,
45 			     NON_SRG_PARAM_VAL_DBM_SIZE,
46 			     NON_SRG_PARAM_VAL_DBM_UNIT);
47 		QDF_SET_BITS(pparam.param_value, NON_SRG_MAX_PD_OFFSET_POS,
48 			     NON_SRG_MAX_PD_OFFSET_SIZE,
49 			     non_srg_max_pd_offset);
50 	}
51 
52 	return wmi_unified_pdev_param_send(wmi_handle, &pparam,
53 					   WILDCARD_PDEV_ID);
54 }
55 
56 void target_if_spatial_reuse_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
57 {
58 	tx_ops->spatial_reuse_tx_ops.send_cfg = spatial_reuse_send_cfg;
59 }
60 
61