xref: /wlan-driver/qcacld-3.0/components/target_if/wfa_config/src/target_if_wfa_testcmd.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. 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: This file contains definitions for target_if wfa send test cmd.
19  */
20 
21 #include "qdf_types.h"
22 #include "target_if_wfa_testcmd.h"
23 #include "target_if.h"
24 #include "wlan_mlme_dbg.h"
25 #include "wlan_mlme_api.h"
26 #include "wlan_mlme_main.h"
27 
28 static struct wmi_unified
target_if_wfa_get_wmi_handle_from_vdev(struct wlan_objmgr_vdev * vdev)29 *target_if_wfa_get_wmi_handle_from_vdev(struct wlan_objmgr_vdev *vdev)
30 {
31 	struct wlan_objmgr_pdev *pdev;
32 	struct wmi_unified *wmi_handle;
33 
34 	pdev = wlan_vdev_get_pdev(vdev);
35 	if (!pdev) {
36 		target_if_err("PDEV is NULL");
37 		return NULL;
38 	}
39 
40 	wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
41 	if (!wmi_handle) {
42 		target_if_err("wmi_handle is null");
43 		return NULL;
44 	}
45 
46 	return wmi_handle;
47 }
48 
49 /**
50  * target_if_wfa_send_cmd() - Send WFA test cmd to WMI
51  * @vdev: VDEV object pointer
52  * @wfa_test:  Pointer to WFA test params
53  *
54  * Return: QDF_STATUS
55  */
56 static QDF_STATUS
target_if_wfa_send_cmd(struct wlan_objmgr_vdev * vdev,struct set_wfatest_params * wfa_test)57 target_if_wfa_send_cmd(struct wlan_objmgr_vdev *vdev,
58 		       struct set_wfatest_params *wfa_test)
59 {
60 	wmi_unified_t wmi_handle;
61 
62 	wmi_handle = target_if_wfa_get_wmi_handle_from_vdev(vdev);
63 	if (!wmi_handle)
64 		return QDF_STATUS_E_FAILURE;
65 
66 	return wmi_unified_wfa_test_cmd(wmi_handle, wfa_test);
67 }
68 
69 QDF_STATUS
target_if_wfatestcmd_register_tx_ops(struct wlan_wfa_cmd_tx_ops * tx_ops)70 target_if_wfatestcmd_register_tx_ops(struct wlan_wfa_cmd_tx_ops *tx_ops)
71 {
72 	if (!tx_ops) {
73 		target_if_err("target if tx ops is NULL!");
74 		return QDF_STATUS_E_INVAL;
75 	}
76 
77 	tx_ops->send_wfa_test_cmd = target_if_wfa_send_cmd;
78 
79 	return QDF_STATUS_SUCCESS;
80 }
81