1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2022 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: target_if_twt_evt.c
19*5113495bSYour Name * This file contains twt component's target related function definitions
20*5113495bSYour Name */
21*5113495bSYour Name #include <target_if_twt.h>
22*5113495bSYour Name #include <target_if_twt_evt.h>
23*5113495bSYour Name #include <target_if_ext_twt.h>
24*5113495bSYour Name #include "twt/core/src/wlan_twt_priv.h"
25*5113495bSYour Name #include <wlan_twt_api.h>
26*5113495bSYour Name #include <wmi_unified_twt_api.h>
27*5113495bSYour Name
28*5113495bSYour Name int
target_if_twt_en_complete_event_handler(ol_scn_t scn,uint8_t * data,uint32_t datalen)29*5113495bSYour Name target_if_twt_en_complete_event_handler(ol_scn_t scn,
30*5113495bSYour Name uint8_t *data, uint32_t datalen)
31*5113495bSYour Name {
32*5113495bSYour Name wmi_unified_t wmi_handle;
33*5113495bSYour Name struct wlan_objmgr_psoc *psoc;
34*5113495bSYour Name struct wlan_lmac_if_rx_ops *rx_ops;
35*5113495bSYour Name struct wlan_lmac_if_twt_rx_ops *twt_rx_ops;
36*5113495bSYour Name struct twt_enable_complete_event_param event;
37*5113495bSYour Name QDF_STATUS status;
38*5113495bSYour Name
39*5113495bSYour Name TARGET_IF_ENTER();
40*5113495bSYour Name
41*5113495bSYour Name if (!scn || !data) {
42*5113495bSYour Name target_if_err("scn: 0x%pK, data: 0x%pK", scn, data);
43*5113495bSYour Name return -EINVAL;
44*5113495bSYour Name }
45*5113495bSYour Name
46*5113495bSYour Name psoc = target_if_get_psoc_from_scn_hdl(scn);
47*5113495bSYour Name if (!psoc) {
48*5113495bSYour Name target_if_err("psoc is null");
49*5113495bSYour Name return -EINVAL;
50*5113495bSYour Name }
51*5113495bSYour Name
52*5113495bSYour Name rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
53*5113495bSYour Name if (!rx_ops) {
54*5113495bSYour Name target_if_err("rx_ops is NULL");
55*5113495bSYour Name return -EINVAL;
56*5113495bSYour Name }
57*5113495bSYour Name twt_rx_ops = &rx_ops->twt_rx_ops;
58*5113495bSYour Name if (!twt_rx_ops || !twt_rx_ops->twt_enable_comp_cb) {
59*5113495bSYour Name target_if_err("TWT rx_ops comp_cb is NULL");
60*5113495bSYour Name return -EINVAL;
61*5113495bSYour Name }
62*5113495bSYour Name
63*5113495bSYour Name wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
64*5113495bSYour Name if (!wmi_handle) {
65*5113495bSYour Name target_if_err("wmi_handle is null");
66*5113495bSYour Name return -EINVAL;
67*5113495bSYour Name }
68*5113495bSYour Name
69*5113495bSYour Name status = wmi_extract_twt_enable_comp_event(wmi_handle, data, &event);
70*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
71*5113495bSYour Name target_if_err("TWT enable extract event failed(status=%d)",
72*5113495bSYour Name status);
73*5113495bSYour Name goto end;
74*5113495bSYour Name }
75*5113495bSYour Name
76*5113495bSYour Name status = twt_rx_ops->twt_enable_comp_cb(psoc, &event);
77*5113495bSYour Name
78*5113495bSYour Name end:
79*5113495bSYour Name return qdf_status_to_os_return(status);
80*5113495bSYour Name }
81*5113495bSYour Name
82*5113495bSYour Name int
target_if_twt_disable_comp_event_handler(ol_scn_t scn,uint8_t * data,uint32_t datalen)83*5113495bSYour Name target_if_twt_disable_comp_event_handler(ol_scn_t scn,
84*5113495bSYour Name uint8_t *data, uint32_t datalen)
85*5113495bSYour Name {
86*5113495bSYour Name wmi_unified_t wmi_handle;
87*5113495bSYour Name struct wlan_objmgr_psoc *psoc;
88*5113495bSYour Name struct wlan_lmac_if_rx_ops *rx_ops;
89*5113495bSYour Name struct wlan_lmac_if_twt_rx_ops *twt_rx_ops;
90*5113495bSYour Name struct twt_disable_complete_event_param event;
91*5113495bSYour Name QDF_STATUS status;
92*5113495bSYour Name
93*5113495bSYour Name TARGET_IF_ENTER();
94*5113495bSYour Name
95*5113495bSYour Name if (!scn || !data) {
96*5113495bSYour Name target_if_err("scn: 0x%pK, data: 0x%pK", scn, data);
97*5113495bSYour Name return -EINVAL;
98*5113495bSYour Name }
99*5113495bSYour Name
100*5113495bSYour Name psoc = target_if_get_psoc_from_scn_hdl(scn);
101*5113495bSYour Name if (!psoc) {
102*5113495bSYour Name target_if_err("psoc is null");
103*5113495bSYour Name return -EINVAL;
104*5113495bSYour Name }
105*5113495bSYour Name
106*5113495bSYour Name rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
107*5113495bSYour Name if (!rx_ops) {
108*5113495bSYour Name target_if_err("rx_ops is NULL");
109*5113495bSYour Name return -EINVAL;
110*5113495bSYour Name }
111*5113495bSYour Name twt_rx_ops = &rx_ops->twt_rx_ops;
112*5113495bSYour Name if (!twt_rx_ops || !twt_rx_ops->twt_disable_comp_cb) {
113*5113495bSYour Name target_if_err("TWT rx_ops comp_cb is NULL");
114*5113495bSYour Name return -EINVAL;
115*5113495bSYour Name }
116*5113495bSYour Name
117*5113495bSYour Name wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
118*5113495bSYour Name if (!wmi_handle) {
119*5113495bSYour Name target_if_err("wmi_handle is null");
120*5113495bSYour Name return -EINVAL;
121*5113495bSYour Name }
122*5113495bSYour Name
123*5113495bSYour Name status = wmi_extract_twt_disable_comp_event(wmi_handle, data, &event);
124*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
125*5113495bSYour Name target_if_err("TWT disable extract event failed(status=%d)",
126*5113495bSYour Name status);
127*5113495bSYour Name goto end;
128*5113495bSYour Name }
129*5113495bSYour Name
130*5113495bSYour Name status = twt_rx_ops->twt_disable_comp_cb(psoc, &event);
131*5113495bSYour Name
132*5113495bSYour Name end:
133*5113495bSYour Name return qdf_status_to_os_return(status);
134*5113495bSYour Name }
135*5113495bSYour Name
136