1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2021-2022, 2024 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name *
5*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name * above copyright notice and this permission notice appear in all
8*5113495bSYour Name * copies.
9*5113495bSYour Name *
10*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name */
19*5113495bSYour Name
20*5113495bSYour Name /**
21*5113495bSYour Name * DOC: This file contains P2P public API's exposed.
22*5113495bSYour Name */
23*5113495bSYour Name
24*5113495bSYour Name #include "wlan_p2p_api.h"
25*5113495bSYour Name #include <wlan_objmgr_psoc_obj.h>
26*5113495bSYour Name #include "wlan_p2p_public_struct.h"
27*5113495bSYour Name #include "../../core/src/wlan_p2p_main.h"
28*5113495bSYour Name #include "../../core/src/wlan_p2p_roc.h"
29*5113495bSYour Name #include <cds_utils.h>
30*5113495bSYour Name #include "wlan_scan_api.h"
31*5113495bSYour Name #include "../../core/src/wlan_p2p_off_chan_tx.h"
32*5113495bSYour Name
wlan_p2p_check_oui_and_force_1x1(uint8_t * assoc_ie,uint32_t assoc_ie_len)33*5113495bSYour Name bool wlan_p2p_check_oui_and_force_1x1(uint8_t *assoc_ie, uint32_t assoc_ie_len)
34*5113495bSYour Name {
35*5113495bSYour Name if (!assoc_ie || !assoc_ie_len)
36*5113495bSYour Name return false;
37*5113495bSYour Name
38*5113495bSYour Name return p2p_check_oui_and_force_1x1(assoc_ie, assoc_ie_len);
39*5113495bSYour Name }
40*5113495bSYour Name
wlan_p2p_cleanup_roc_by_vdev(struct wlan_objmgr_vdev * vdev,bool sync)41*5113495bSYour Name QDF_STATUS wlan_p2p_cleanup_roc_by_vdev(struct wlan_objmgr_vdev *vdev,
42*5113495bSYour Name bool sync)
43*5113495bSYour Name {
44*5113495bSYour Name struct p2p_soc_priv_obj *p2p_soc_obj;
45*5113495bSYour Name struct wlan_objmgr_psoc *psoc;
46*5113495bSYour Name
47*5113495bSYour Name p2p_debug("vdev:%pK", vdev);
48*5113495bSYour Name
49*5113495bSYour Name if (!vdev) {
50*5113495bSYour Name p2p_debug("null vdev");
51*5113495bSYour Name return QDF_STATUS_E_INVAL;
52*5113495bSYour Name }
53*5113495bSYour Name
54*5113495bSYour Name psoc = wlan_vdev_get_psoc(vdev);
55*5113495bSYour Name if (!psoc) {
56*5113495bSYour Name p2p_err("null psoc");
57*5113495bSYour Name return QDF_STATUS_E_INVAL;
58*5113495bSYour Name }
59*5113495bSYour Name
60*5113495bSYour Name p2p_soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
61*5113495bSYour Name WLAN_UMAC_COMP_P2P);
62*5113495bSYour Name if (!p2p_soc_obj) {
63*5113495bSYour Name p2p_err("p2p soc context is NULL");
64*5113495bSYour Name return QDF_STATUS_E_FAILURE;
65*5113495bSYour Name }
66*5113495bSYour Name
67*5113495bSYour Name return p2p_cleanup_roc(p2p_soc_obj, vdev, sync);
68*5113495bSYour Name }
69*5113495bSYour Name
wlan_p2p_status_connect(struct wlan_objmgr_vdev * vdev)70*5113495bSYour Name QDF_STATUS wlan_p2p_status_connect(struct wlan_objmgr_vdev *vdev)
71*5113495bSYour Name {
72*5113495bSYour Name if (!vdev) {
73*5113495bSYour Name p2p_err("vdev is NULL");
74*5113495bSYour Name return QDF_STATUS_E_INVAL;
75*5113495bSYour Name }
76*5113495bSYour Name
77*5113495bSYour Name return p2p_status_connect(vdev);
78*5113495bSYour Name }
79*5113495bSYour Name
80*5113495bSYour Name bool
wlan_p2p_is_action_frame_of_p2p_type(uint8_t * data_buf,uint32_t length)81*5113495bSYour Name wlan_p2p_is_action_frame_of_p2p_type(uint8_t *data_buf,
82*5113495bSYour Name uint32_t length)
83*5113495bSYour Name {
84*5113495bSYour Name return p2p_is_action_frame_of_p2p_type(data_buf, length);
85*5113495bSYour Name }
86*5113495bSYour Name
87*5113495bSYour Name #ifdef WLAN_FEATURE_P2P_P2P_STA
88*5113495bSYour Name QDF_STATUS
wlan_p2p_check_and_force_scc_go_plus_go(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_vdev * vdev)89*5113495bSYour Name wlan_p2p_check_and_force_scc_go_plus_go(struct wlan_objmgr_psoc *psoc,
90*5113495bSYour Name struct wlan_objmgr_vdev *vdev)
91*5113495bSYour Name {
92*5113495bSYour Name if (!vdev) {
93*5113495bSYour Name p2p_err("vdev is NULL");
94*5113495bSYour Name return QDF_STATUS_E_INVAL;
95*5113495bSYour Name }
96*5113495bSYour Name
97*5113495bSYour Name return p2p_check_and_force_scc_go_plus_go(psoc, vdev);
98*5113495bSYour Name }
99*5113495bSYour Name #endif
100*5113495bSYour Name
wlan_p2p_abort_vdev_scan(struct wlan_objmgr_pdev * pdev,void * object,void * arg)101*5113495bSYour Name static void wlan_p2p_abort_vdev_scan(struct wlan_objmgr_pdev *pdev,
102*5113495bSYour Name void *object, void *arg)
103*5113495bSYour Name {
104*5113495bSYour Name struct wlan_objmgr_vdev *vdev = (struct wlan_objmgr_vdev *)object;
105*5113495bSYour Name struct scan_cancel_request *req;
106*5113495bSYour Name struct p2p_soc_priv_obj *p2p_soc_obj;
107*5113495bSYour Name QDF_STATUS status;
108*5113495bSYour Name
109*5113495bSYour Name if (wlan_vdev_mlme_get_opmode(vdev) != QDF_P2P_DEVICE_MODE)
110*5113495bSYour Name return;
111*5113495bSYour Name
112*5113495bSYour Name p2p_soc_obj =
113*5113495bSYour Name wlan_objmgr_psoc_get_comp_private_obj(wlan_vdev_get_psoc(vdev),
114*5113495bSYour Name WLAN_UMAC_COMP_P2P);
115*5113495bSYour Name if (!p2p_soc_obj) {
116*5113495bSYour Name p2p_err("P2P soc object is NULL");
117*5113495bSYour Name return;
118*5113495bSYour Name }
119*5113495bSYour Name
120*5113495bSYour Name req = qdf_mem_malloc(sizeof(*req));
121*5113495bSYour Name if (!req)
122*5113495bSYour Name return;
123*5113495bSYour Name
124*5113495bSYour Name req->vdev = vdev;
125*5113495bSYour Name req->cancel_req.requester = p2p_soc_obj->scan_req_id;
126*5113495bSYour Name req->cancel_req.scan_id = INVALID_SCAN_ID;
127*5113495bSYour Name req->cancel_req.vdev_id = wlan_vdev_get_id(vdev);
128*5113495bSYour Name req->cancel_req.req_type = WLAN_SCAN_CANCEL_VDEV_ALL;
129*5113495bSYour Name
130*5113495bSYour Name qdf_mtrace(QDF_MODULE_ID_P2P, QDF_MODULE_ID_SCAN,
131*5113495bSYour Name req->cancel_req.req_type,
132*5113495bSYour Name req->cancel_req.vdev_id,
133*5113495bSYour Name req->cancel_req.scan_id);
134*5113495bSYour Name status = wlan_scan_cancel(req);
135*5113495bSYour Name
136*5113495bSYour Name p2p_debug("abort scan, scan req id:%d, scan id:%d, status:%d",
137*5113495bSYour Name req->cancel_req.requester,
138*5113495bSYour Name req->cancel_req.scan_id, status);
139*5113495bSYour Name }
140*5113495bSYour Name
wlan_p2p_abort_scan(struct wlan_objmgr_pdev * pdev)141*5113495bSYour Name QDF_STATUS wlan_p2p_abort_scan(struct wlan_objmgr_pdev *pdev)
142*5113495bSYour Name {
143*5113495bSYour Name return wlan_objmgr_pdev_iterate_obj_list(pdev,
144*5113495bSYour Name WLAN_VDEV_OP,
145*5113495bSYour Name wlan_p2p_abort_vdev_scan,
146*5113495bSYour Name NULL, 0, WLAN_P2P_ID);
147*5113495bSYour Name }
148