xref: /wlan-driver/qcacld-3.0/components/target_if/pmo/src/target_if_pmo_pkt_filter.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 /**
19  * DOC: target_if_pmo_pkt_filter.c
20  *
21  * Target interface file for pmo component to
22  * send packet filter related cmd and process event.
23  */
24 
25 #include "target_if.h"
26 #include "target_if_pmo.h"
27 #include "wmi_unified_pmo_api.h"
28 #include "wlan_pmo_pkt_filter_public_struct.h"
29 
target_if_pmo_send_pkt_filter_req(struct wlan_objmgr_vdev * vdev,struct pmo_rcv_pkt_fltr_cfg * rcv_filter_param)30 QDF_STATUS target_if_pmo_send_pkt_filter_req(struct wlan_objmgr_vdev *vdev,
31 			struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param)
32 {
33 	uint8_t vdev_id;
34 	struct wlan_objmgr_psoc *psoc;
35 	QDF_STATUS status;
36 	wmi_unified_t wmi_handle;
37 
38 	if (!vdev) {
39 		target_if_err("vdev ptr passed is NULL");
40 		return QDF_STATUS_E_INVAL;
41 	}
42 
43 	psoc = wlan_vdev_get_psoc(vdev);
44 	vdev_id = wlan_vdev_get_id(vdev);
45 	if (!psoc) {
46 		target_if_err("psoc handle is NULL");
47 		return QDF_STATUS_E_INVAL;
48 	}
49 
50 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
51 	if (!wmi_handle) {
52 		target_if_err("Invalid wmi handle");
53 		return QDF_STATUS_E_INVAL;
54 	}
55 
56 	/* send the command along with data */
57 	status = wmi_unified_config_packet_filter_cmd(wmi_handle, vdev_id,
58 			rcv_filter_param,
59 			rcv_filter_param->filter_id, true);
60 	if (status) {
61 		target_if_err("Failed to send pkt_filter cmd");
62 		return QDF_STATUS_E_INVAL;
63 	}
64 
65 	/* Enable packet filter */
66 	status = wmi_unified_enable_disable_packet_filter_cmd(wmi_handle,
67 							      vdev_id, true);
68 	if (status)
69 		target_if_err("Failed to send packet filter wmi cmd to fw");
70 
71 	return status;
72 }
73 
target_if_pmo_clear_pkt_filter_req(struct wlan_objmgr_vdev * vdev,struct pmo_rcv_pkt_fltr_clear_param * rcv_clear_param)74 QDF_STATUS target_if_pmo_clear_pkt_filter_req(struct wlan_objmgr_vdev *vdev,
75 			struct pmo_rcv_pkt_fltr_clear_param *rcv_clear_param)
76 {
77 	uint8_t vdev_id;
78 	struct wlan_objmgr_psoc *psoc;
79 	QDF_STATUS status;
80 	wmi_unified_t wmi_handle;
81 
82 	if (!vdev) {
83 		target_if_err("vdev ptr passed is NULL");
84 		return QDF_STATUS_E_INVAL;
85 	}
86 
87 	psoc = wlan_vdev_get_psoc(vdev);
88 	vdev_id = wlan_vdev_get_id(vdev);
89 	if (!psoc) {
90 		target_if_err("psoc handle is NULL");
91 		return QDF_STATUS_E_INVAL;
92 	}
93 
94 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
95 	if (!wmi_handle) {
96 		target_if_err("Invalid wmi handle");
97 		return QDF_STATUS_E_INVAL;
98 	}
99 
100 	/* send the command along with data */
101 	status = wmi_unified_config_packet_filter_cmd(wmi_handle, vdev_id, NULL,
102 					rcv_clear_param->filter_id, false);
103 
104 	if (status)
105 		target_if_err("Failed to clear filter cmd");
106 
107 	return status;
108 }
109