1 /*
2 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 /**
18 * DOC: target_if_twt_cmd.c
19 * This file contains twt component's target related function definitions
20 */
21 #include <target_if_twt.h>
22 #include <target_if_twt_cmd.h>
23 #include <target_if_ext_twt.h>
24 #include "twt/core/src/wlan_twt_common.h"
25
26 QDF_STATUS
target_if_twt_enable_req(struct wlan_objmgr_psoc * psoc,struct twt_enable_param * req)27 target_if_twt_enable_req(struct wlan_objmgr_psoc *psoc,
28 struct twt_enable_param *req)
29 {
30 QDF_STATUS ret;
31 struct wmi_unified *wmi_handle;
32 struct wlan_objmgr_pdev *pdev;
33
34 if (!psoc) {
35 target_if_err("null psoc");
36 return QDF_STATUS_E_FAILURE;
37 }
38
39 pdev = wlan_objmgr_get_pdev_by_id(psoc, req->pdev_id,
40 WLAN_TWT_ID);
41 if (!pdev) {
42 target_if_err("null pdev");
43 return QDF_STATUS_E_FAILURE;
44 }
45
46 wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
47 if (!wmi_handle) {
48 target_if_err("null wmi handle");
49 wlan_objmgr_pdev_release_ref(pdev, WLAN_TWT_ID);
50 return QDF_STATUS_E_FAILURE;
51 }
52
53 ret = wmi_unified_twt_enable_cmd(wmi_handle, req);
54 if (QDF_IS_STATUS_ERROR(ret))
55 target_if_err("Failed to enable TWT(ret=%d)", ret);
56
57 wlan_objmgr_pdev_release_ref(pdev, WLAN_TWT_ID);
58
59 return ret;
60 }
61
62 QDF_STATUS
target_if_twt_disable_req(struct wlan_objmgr_psoc * psoc,struct twt_disable_param * req)63 target_if_twt_disable_req(struct wlan_objmgr_psoc *psoc,
64 struct twt_disable_param *req)
65 {
66 QDF_STATUS ret;
67 struct wmi_unified *wmi_handle;
68 struct wlan_objmgr_pdev *pdev;
69
70 if (!psoc) {
71 target_if_err("null psoc");
72 return QDF_STATUS_E_FAILURE;
73 }
74
75 pdev = wlan_objmgr_get_pdev_by_id(psoc, req->pdev_id,
76 WLAN_TWT_ID);
77 if (!pdev) {
78 target_if_err("null pdev");
79 return QDF_STATUS_E_FAILURE;
80 }
81
82 wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
83 if (!wmi_handle) {
84 target_if_err("null wmi handle");
85 wlan_objmgr_pdev_release_ref(pdev, WLAN_TWT_ID);
86 return QDF_STATUS_E_FAILURE;
87 }
88
89 ret = wmi_unified_twt_disable_cmd(wmi_handle, req);
90 if (QDF_IS_STATUS_ERROR(ret))
91 target_if_err("Failed to disable TWT(ret=%d)", ret);
92
93 wlan_objmgr_pdev_release_ref(pdev, WLAN_TWT_ID);
94
95 return ret;
96 }
97
98