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 #include <wlan_iot_sim_utils_api.h>
18 #include <qdf_module.h>
19 #include "../../core/iot_sim_cmn_api_i.h"
20 #include <wlan_iot_sim_tgt_api.h>
21 #include <wlan_objmgr_pdev_obj.h>
22 #include <wlan_objmgr_vdev_obj.h>
23
24 #define IEEE80211_FRAME_BODY_OFFSET 0x18
25
iot_sim_cmd_handler(struct wlan_objmgr_vdev * vdev,qdf_nbuf_t nbuf,struct beacon_tmpl_params * bcn_param,bool tx,struct mgmt_rx_event_params * param)26 QDF_STATUS iot_sim_cmd_handler(struct wlan_objmgr_vdev *vdev, qdf_nbuf_t nbuf,
27 struct beacon_tmpl_params *bcn_param, bool tx,
28 struct mgmt_rx_event_params *param)
29 {
30 struct wlan_objmgr_pdev *pdev = vdev->vdev_objmgr.wlan_pdev;
31
32 return iot_sim_frame_update(pdev, nbuf, bcn_param, tx, param);
33 }
34
iot_sim_register_callbacks(struct wlan_objmgr_pdev * pdev,struct iot_sim_cbacks * cb)35 QDF_STATUS iot_sim_register_callbacks(struct wlan_objmgr_pdev *pdev,
36 struct iot_sim_cbacks *cb)
37 {
38 struct iot_sim_context *isc = NULL;
39
40 isc = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_IOT_SIM_COMP);
41 if (!isc)
42 return QDF_STATUS_E_NULL_VALUE;
43
44 isc->iot_sim_update_beacon_trigger = cb->update_beacon_trigger;
45
46 return QDF_STATUS_SUCCESS;
47 }
48
49 QDF_STATUS
wlan_iot_sim_init(void)50 wlan_iot_sim_init(void)
51 {
52 if (wlan_objmgr_register_pdev_create_handler(
53 WLAN_IOT_SIM_COMP,
54 wlan_iot_sim_pdev_obj_create_handler,
55 NULL) !=
56 QDF_STATUS_SUCCESS) {
57 return QDF_STATUS_E_FAILURE;
58 }
59 if (wlan_objmgr_register_pdev_destroy_handler(
60 WLAN_IOT_SIM_COMP,
61 wlan_iot_sim_pdev_obj_destroy_handler,
62 NULL) !=
63 QDF_STATUS_SUCCESS) {
64 return QDF_STATUS_E_FAILURE;
65 }
66
67 return QDF_STATUS_SUCCESS;
68 }
69
70 QDF_STATUS
wlan_iot_sim_deinit(void)71 wlan_iot_sim_deinit(void)
72 {
73 if (wlan_objmgr_unregister_pdev_create_handler(
74 WLAN_IOT_SIM_COMP,
75 wlan_iot_sim_pdev_obj_create_handler,
76 NULL) !=
77 QDF_STATUS_SUCCESS) {
78 return QDF_STATUS_E_FAILURE;
79 }
80 if (wlan_objmgr_unregister_pdev_destroy_handler(
81 WLAN_IOT_SIM_COMP,
82 wlan_iot_sim_pdev_obj_destroy_handler,
83 NULL) !=
84 QDF_STATUS_SUCCESS) {
85 return QDF_STATUS_E_FAILURE;
86 }
87
88 return QDF_STATUS_SUCCESS;
89 }
90
wlan_lmac_if_iot_sim_register_rx_ops(struct wlan_lmac_if_rx_ops * rx_ops)91 void wlan_lmac_if_iot_sim_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops)
92 {
93 struct wlan_lmac_if_iot_sim_rx_ops *iot_sim_ops =
94 &rx_ops->iot_sim_rx_ops;
95
96 iot_sim_ops->iot_sim_cmd_handler = iot_sim_cmd_handler;
97 iot_sim_ops->iot_sim_register_cb = iot_sim_register_callbacks;
98
99 }
100