xref: /wlan-driver/qcacld-3.0/components/spatial_reuse/dispatcher/src/spatial_reuse_api.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
3*5113495bSYour Name  *
4*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for any
5*5113495bSYour Name  * purpose with or without fee is hereby granted, provided that the above
6*5113495bSYour Name  * copyright notice and this permission notice appear in all copies.
7*5113495bSYour Name 
8*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*5113495bSYour Name  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*5113495bSYour Name  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*5113495bSYour Name  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*5113495bSYour Name  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*5113495bSYour Name  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*5113495bSYour Name  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*5113495bSYour Name  */
16*5113495bSYour Name 
17*5113495bSYour Name /**
18*5113495bSYour Name  * DOC: contains interface prototypes for spatial_reuse api
19*5113495bSYour Name  */
20*5113495bSYour Name #include <spatial_reuse_api.h>
21*5113495bSYour Name #include <target_if_spatial_reuse.h>
22*5113495bSYour Name 
23*5113495bSYour Name struct sr_cb {
24*5113495bSYour Name 	sr_osif_event_cb send_osif_event;
25*5113495bSYour Name } sr_cb;
26*5113495bSYour Name 
wlan_spatial_reuse_config_set(struct wlan_objmgr_vdev * vdev,uint8_t sr_ctrl,uint8_t non_srg_max_pd_offset)27*5113495bSYour Name QDF_STATUS wlan_spatial_reuse_config_set(struct wlan_objmgr_vdev *vdev,
28*5113495bSYour Name 					 uint8_t sr_ctrl,
29*5113495bSYour Name 					 uint8_t non_srg_max_pd_offset)
30*5113495bSYour Name {
31*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
32*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc = wlan_vdev_get_psoc(vdev);
33*5113495bSYour Name 
34*5113495bSYour Name 	if (!psoc)
35*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
36*5113495bSYour Name 
37*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
38*5113495bSYour Name 	if (!tx_ops)
39*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
40*5113495bSYour Name 
41*5113495bSYour Name 	if (tx_ops->spatial_reuse_tx_ops.send_cfg)
42*5113495bSYour Name 		return tx_ops->spatial_reuse_tx_ops.send_cfg(vdev, sr_ctrl,
43*5113495bSYour Name 							non_srg_max_pd_offset);
44*5113495bSYour Name 
45*5113495bSYour Name 	return QDF_STATUS_E_NULL_VALUE;
46*5113495bSYour Name }
47*5113495bSYour Name 
wlan_spatial_reuse_he_siga_val15_allowed_set(struct wlan_objmgr_vdev * vdev,bool he_siga_va15_allowed)48*5113495bSYour Name QDF_STATUS wlan_spatial_reuse_he_siga_val15_allowed_set(
49*5113495bSYour Name 					struct wlan_objmgr_vdev *vdev,
50*5113495bSYour Name 					bool he_siga_va15_allowed)
51*5113495bSYour Name {
52*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
53*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc = wlan_vdev_get_psoc(vdev);
54*5113495bSYour Name 
55*5113495bSYour Name 	if (!psoc)
56*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
57*5113495bSYour Name 
58*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
59*5113495bSYour Name 	if (!tx_ops)
60*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
61*5113495bSYour Name 
62*5113495bSYour Name 	if (tx_ops->spatial_reuse_tx_ops.send_sr_prohibit_cfg)
63*5113495bSYour Name 		return tx_ops->spatial_reuse_tx_ops.send_sr_prohibit_cfg(
64*5113495bSYour Name 							vdev,
65*5113495bSYour Name 							he_siga_va15_allowed);
66*5113495bSYour Name 	return QDF_STATUS_E_NULL_VALUE;
67*5113495bSYour Name }
68*5113495bSYour Name 
69*5113495bSYour Name QDF_STATUS
wlan_sr_setup_req(struct wlan_objmgr_vdev * vdev,struct wlan_objmgr_pdev * pdev,bool is_sr_enable,int32_t srg_pd_threshold,int32_t non_srg_pd_threshold)70*5113495bSYour Name wlan_sr_setup_req(struct wlan_objmgr_vdev *vdev, struct wlan_objmgr_pdev *pdev,
71*5113495bSYour Name 		  bool is_sr_enable, int32_t srg_pd_threshold,
72*5113495bSYour Name 		  int32_t non_srg_pd_threshold) {
73*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
74*5113495bSYour Name 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
75*5113495bSYour Name 
76*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(wlan_pdev_get_psoc(pdev));
77*5113495bSYour Name 	if (tx_ops &&
78*5113495bSYour Name 	    tx_ops->spatial_reuse_tx_ops.target_if_set_sr_enable_disable) {
79*5113495bSYour Name 		status =
80*5113495bSYour Name 		tx_ops->spatial_reuse_tx_ops.target_if_set_sr_enable_disable(
81*5113495bSYour Name 					vdev, pdev, is_sr_enable,
82*5113495bSYour Name 					srg_pd_threshold, non_srg_pd_threshold);
83*5113495bSYour Name 		return status;
84*5113495bSYour Name 	}
85*5113495bSYour Name 	return status;
86*5113495bSYour Name }
87*5113495bSYour Name 
wlan_sr_register_callback(struct wlan_objmgr_psoc * psoc,sr_osif_event_cb cb)88*5113495bSYour Name void wlan_sr_register_callback(struct wlan_objmgr_psoc *psoc,
89*5113495bSYour Name 			       sr_osif_event_cb cb)
90*5113495bSYour Name {
91*5113495bSYour Name 	if (!psoc)
92*5113495bSYour Name 		return;
93*5113495bSYour Name 	sr_cb.send_osif_event = cb;
94*5113495bSYour Name }
95*5113495bSYour Name 
wlan_spatial_reuse_osif_event(struct wlan_objmgr_vdev * vdev,enum sr_osif_operation sr_osif_oper,enum sr_osif_reason_code sr_osif_rc)96*5113495bSYour Name void wlan_spatial_reuse_osif_event(struct wlan_objmgr_vdev *vdev,
97*5113495bSYour Name 				   enum sr_osif_operation sr_osif_oper,
98*5113495bSYour Name 				   enum sr_osif_reason_code sr_osif_rc)
99*5113495bSYour Name {
100*5113495bSYour Name 	if (sr_cb.send_osif_event)
101*5113495bSYour Name 		sr_cb.send_osif_event(vdev, sr_osif_oper, sr_osif_rc);
102*5113495bSYour Name }
103