blob: 1eb61ef921281586ac5031caa8b28f53719637a9 [file] [log] [blame]
Jeff Johnsone7245742012-09-05 17:12:55 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnsone7245742012-09-05 17:12:55 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42#ifdef FEATURE_OEM_DATA_SUPPORT
43
44/*================================================================================
45 \file wlan_hdd_oemdata.c
46
47 \brief Linux Wireless Extensions for oem data req/rsp
48
49 $Id: wlan_hdd_oemdata.c,v 1.34 2010/04/15 01:49:23 -- VINAY
50
51 Copyright (C) Qualcomm Inc.
52
53================================================================================*/
54
55#include <linux/version.h>
56#include <linux/module.h>
57#include <linux/kernel.h>
58#include <linux/init.h>
59#include <linux/wireless.h>
60#include <wlan_hdd_includes.h>
61#include <net/arp.h>
62
63/*---------------------------------------------------------------------------------------------
64
65 \brief hdd_OemDataReqCallback() -
66
67 This function also reports the results to the user space
68
69 \return - 0 for success, non zero for failure
70
71-----------------------------------------------------------------------------------------------*/
72static eHalStatus hdd_OemDataReqCallback(tHalHandle hHal,
73 void *pContext,
74 tANI_U32 oemDataReqID,
75 eOemDataReqStatus oemDataReqStatus)
76{
77 eHalStatus status = eHAL_STATUS_SUCCESS;
78 struct net_device *dev = (struct net_device *) pContext;
79 union iwreq_data wrqu;
80 char buffer[IW_CUSTOM_MAX+1];
81
82 memset(&wrqu, '\0', sizeof(wrqu));
83 memset(buffer, '\0', sizeof(buffer));
84
85 //now if the status is success, then send an event up
86 //so that the application can request for the data
87 //else no need to send the event up
88 if(oemDataReqStatus == eOEM_DATA_REQ_FAILURE)
89 {
90 snprintf(buffer, IW_CUSTOM_MAX, "QCOM: OEM-DATA-REQ-FAILED");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070091 hddLog(LOGW, "%s: oem data req %d failed\n", __func__, oemDataReqID);
Jeff Johnsone7245742012-09-05 17:12:55 -070092 }
93 else if(oemDataReqStatus == eOEM_DATA_REQ_INVALID_MODE)
94 {
95 snprintf(buffer, IW_CUSTOM_MAX, "QCOM: OEM-DATA-REQ-INVALID-MODE");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070096 hddLog(LOGW, "%s: oem data req %d failed because the driver is in invalid mode (IBSS|BTAMP|AP)\n", __func__, oemDataReqID);
Jeff Johnsone7245742012-09-05 17:12:55 -070097 }
98 else
99 {
100 snprintf(buffer, IW_CUSTOM_MAX, "QCOM: OEM-DATA-REQ-SUCCESS");
101 //everything went alright
102 }
103
104 wrqu.data.pointer = buffer;
105 wrqu.data.length = strlen(buffer);
106
107 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buffer);
108
109 return status;
110}
111
112/**--------------------------------------------------------------------------------------------
113
114 \brief iw_get_oem_data_rsp() -
115
116 This function gets the oem data response. This invokes
117 the respective sme functionality. Function for handling the oem data rsp
118 IOCTL
119
120 \param - dev - Pointer to the net device
121 - info - Pointer to the iw_oem_data_req
122 - wrqu - Pointer to the iwreq data
123 - extra - Pointer to the data
124
125 \return - 0 for success, non zero for failure
126
127-----------------------------------------------------------------------------------------------*/
128int iw_get_oem_data_rsp(
129 struct net_device *dev,
130 struct iw_request_info *info,
131 union iwreq_data *wrqu,
132 char *extra)
133{
134 eHalStatus status = eHAL_STATUS_SUCCESS;
135 struct iw_oem_data_rsp* pHddOemDataRsp;
136 tOemDataRsp* pSmeOemDataRsp;
137
138 hdd_adapter_t *pAdapter = (netdev_priv(dev));
139
Sameer Thalappil75ea31a2013-02-21 19:38:16 -0800140 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
141 {
142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
143 "%s:LOGP in Progress. Ignore!!!",__func__);
144 return -EBUSY;
145 }
146
Jeff Johnsone7245742012-09-05 17:12:55 -0700147 do
148 {
149 //get the oem data response from sme
150 status = sme_getOemDataRsp(WLAN_HDD_GET_HAL_CTX(pAdapter), &pSmeOemDataRsp);
151 if(status != eHAL_STATUS_SUCCESS)
152 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700153 hddLog(LOGE, "%s: failed in sme_getOemDataRsp\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700154 break;
155 }
156 else
157 {
158 if(pSmeOemDataRsp != NULL)
159 {
160 pHddOemDataRsp = (struct iw_oem_data_rsp*)(extra);
161 vos_mem_copy(pHddOemDataRsp->oemDataRsp, pSmeOemDataRsp->oemDataRsp, OEM_DATA_RSP_SIZE);
162 }
163 else
164 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700165 hddLog(LOGE, "%s: pSmeOemDataRsp = NULL\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700166 status = eHAL_STATUS_FAILURE;
167 break;
168 }
169 }
170 } while(0);
171
172 return eHAL_STATUS_SUCCESS;
173}
174
175/**--------------------------------------------------------------------------------------------
176
177 \brief iw_set_oem_data_req() -
178
179 This function sets the oem data req configuration. This invokes
180 the respective sme oem data req functionality. Function for
181 handling the set IOCTL for the oem data req configuration
182
183 \param - dev - Pointer to the net device
184 - info - Pointer to the iw_oem_data_req
185 - wrqu - Pointer to the iwreq data
186 - extra - Pointer to the data
187
188 \return - 0 for success, non zero for failure
189
190-----------------------------------------------------------------------------------------------*/
191int iw_set_oem_data_req(
192 struct net_device *dev,
193 struct iw_request_info *info,
194 union iwreq_data *wrqu,
195 char *extra)
196{
197 eHalStatus status = eHAL_STATUS_SUCCESS;
198 struct iw_oem_data_req *pOemDataReq = NULL;
199 tOemDataReqConfig oemDataReqConfig;
200
201 tANI_U32 oemDataReqID = 0;
202
203 hdd_adapter_t *pAdapter = (netdev_priv(dev));
204 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
205
Sameer Thalappil75ea31a2013-02-21 19:38:16 -0800206 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
207 {
208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
209 "%s:LOGP in Progress. Ignore!!!",__func__);
210 return -EBUSY;
211 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700212
213 do
214 {
215 if(NULL != wrqu->data.pointer)
216 {
217 pOemDataReq = (struct iw_oem_data_req *)wrqu->data.pointer;
218 }
219
220 if(pOemDataReq == NULL)
221 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700222 hddLog(LOGE, "in %s oemDataReq == NULL\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700223 status = eHAL_STATUS_FAILURE;
224 break;
225 }
226
227 vos_mem_zero(&oemDataReqConfig, sizeof(tOemDataReqConfig));
228
Yue Ma63993e32013-10-21 23:10:53 -0700229 if (copy_from_user((&oemDataReqConfig)->oemDataReq,
230 pOemDataReq->oemDataReq, OEM_DATA_REQ_SIZE))
231 {
232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
233 "%s: copy_from_user() failed!", __func__);
234 return -EFAULT;
235 }
236
Jeff Johnsone7245742012-09-05 17:12:55 -0700237 status = sme_OemDataReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
238 pAdapter->sessionId,
239 &oemDataReqConfig,
240 &oemDataReqID,
241 &hdd_OemDataReqCallback,
242 dev);
243
244 pwextBuf->oemDataReqID = oemDataReqID;
245 pwextBuf->oemDataReqInProgress = TRUE;
246
247 } while(0);
248
249 return status;
250}
251
252
253#endif