1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
3*5113495bSYour Name *
4*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for any
5*5113495bSYour Name * purpose with or without fee is hereby granted, provided that the above
6*5113495bSYour Name * copyright notice and this permission notice appear in all copies.
7*5113495bSYour Name *
8*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*5113495bSYour Name * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*5113495bSYour Name * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*5113495bSYour Name * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*5113495bSYour Name * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*5113495bSYour Name * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*5113495bSYour Name * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*5113495bSYour Name */
16*5113495bSYour Name
17*5113495bSYour Name /*
18*5113495bSYour Name * DOC: wlan_hdd_afc.c
19*5113495bSYour Name *
20*5113495bSYour Name * This file has the AFC osif interface with linux kernel.
21*5113495bSYour Name */
22*5113495bSYour Name
23*5113495bSYour Name #include <wlan_hdd_afc.h>
24*5113495bSYour Name #include <osif_psoc_sync.h>
25*5113495bSYour Name #include <wlan_cfg80211_afc.h>
26*5113495bSYour Name #include <wlan_hdd_main.h>
27*5113495bSYour Name #include <pld_common.h>
28*5113495bSYour Name #include <wlan_afc_ucfg_api.h>
29*5113495bSYour Name
wlan_hdd_vendor_afc_response(struct wiphy * wiphy,struct wireless_dev * wdev,const void * data,int data_len)30*5113495bSYour Name int wlan_hdd_vendor_afc_response(struct wiphy *wiphy,
31*5113495bSYour Name struct wireless_dev *wdev,
32*5113495bSYour Name const void *data,
33*5113495bSYour Name int data_len)
34*5113495bSYour Name {
35*5113495bSYour Name struct osif_psoc_sync *psoc_sync;
36*5113495bSYour Name struct hdd_context *hdd_ctx;
37*5113495bSYour Name int ret;
38*5113495bSYour Name
39*5113495bSYour Name hdd_enter();
40*5113495bSYour Name
41*5113495bSYour Name ret = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync);
42*5113495bSYour Name if (ret)
43*5113495bSYour Name return ret;
44*5113495bSYour Name
45*5113495bSYour Name hdd_ctx = wiphy_priv(wiphy);
46*5113495bSYour Name
47*5113495bSYour Name if (!hdd_ctx->psoc) {
48*5113495bSYour Name osif_err("psoc is null");
49*5113495bSYour Name ret = -EINVAL;
50*5113495bSYour Name goto sync_stop;
51*5113495bSYour Name }
52*5113495bSYour Name
53*5113495bSYour Name if (!hdd_ctx->pdev) {
54*5113495bSYour Name osif_err("pdev is null");
55*5113495bSYour Name ret = -EINVAL;
56*5113495bSYour Name goto sync_stop;
57*5113495bSYour Name }
58*5113495bSYour Name
59*5113495bSYour Name ret = wlan_cfg80211_vendor_afc_response(hdd_ctx->psoc,
60*5113495bSYour Name hdd_ctx->pdev,
61*5113495bSYour Name data,
62*5113495bSYour Name data_len);
63*5113495bSYour Name sync_stop:
64*5113495bSYour Name osif_psoc_sync_op_stop(psoc_sync);
65*5113495bSYour Name
66*5113495bSYour Name hdd_exit();
67*5113495bSYour Name
68*5113495bSYour Name return ret;
69*5113495bSYour Name }
70*5113495bSYour Name
71*5113495bSYour Name /**
72*5113495bSYour Name * wlan_hdd_send_response_to_afcmem() - Callback function register to AFC
73*5113495bSYour Name * common component.
74*5113495bSYour Name * @psoc: Pointer to PSOC object
75*5113495bSYour Name * @pdev: Pointer to PDEV object
76*5113495bSYour Name * @data: Pointer to AFC response data pass to target
77*5113495bSYour Name * @len: Length of AFC response data pass to target
78*5113495bSYour Name *
79*5113495bSYour Name * Return: 0 if success, otherwise error code
80*5113495bSYour Name */
wlan_hdd_send_response_to_afcmem(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_pdev * pdev,struct wlan_afc_host_resp * data,uint32_t len)81*5113495bSYour Name static int wlan_hdd_send_response_to_afcmem(struct wlan_objmgr_psoc *psoc,
82*5113495bSYour Name struct wlan_objmgr_pdev *pdev,
83*5113495bSYour Name struct wlan_afc_host_resp *data,
84*5113495bSYour Name uint32_t len)
85*5113495bSYour Name {
86*5113495bSYour Name qdf_device_t qdf_dev;
87*5113495bSYour Name int pdev_id;
88*5113495bSYour Name const uint8_t *afcdb = (const uint8_t *)data;
89*5113495bSYour Name
90*5113495bSYour Name qdf_dev = wlan_psoc_get_qdf_dev(psoc);
91*5113495bSYour Name if (!qdf_dev) {
92*5113495bSYour Name osif_err("Invalid qdf dev");
93*5113495bSYour Name return -EINVAL;
94*5113495bSYour Name }
95*5113495bSYour Name
96*5113495bSYour Name pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
97*5113495bSYour Name
98*5113495bSYour Name return pld_send_buffer_to_afcmem(qdf_dev->dev,
99*5113495bSYour Name afcdb,
100*5113495bSYour Name len,
101*5113495bSYour Name pdev_id);
102*5113495bSYour Name }
103*5113495bSYour Name
wlan_hdd_register_afc_pld_cb(struct wlan_objmgr_psoc * psoc)104*5113495bSYour Name void wlan_hdd_register_afc_pld_cb(struct wlan_objmgr_psoc *psoc)
105*5113495bSYour Name {
106*5113495bSYour Name ucfg_afc_register_data_send_cb(psoc, wlan_hdd_send_response_to_afcmem);
107*5113495bSYour Name }
108