blob: 8255b8f45830db8f0e782fed3b16592b76bffb1c [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
140 do
141 {
142 //get the oem data response from sme
143 status = sme_getOemDataRsp(WLAN_HDD_GET_HAL_CTX(pAdapter), &pSmeOemDataRsp);
144 if(status != eHAL_STATUS_SUCCESS)
145 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700146 hddLog(LOGE, "%s: failed in sme_getOemDataRsp\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700147 break;
148 }
149 else
150 {
151 if(pSmeOemDataRsp != NULL)
152 {
153 pHddOemDataRsp = (struct iw_oem_data_rsp*)(extra);
154 vos_mem_copy(pHddOemDataRsp->oemDataRsp, pSmeOemDataRsp->oemDataRsp, OEM_DATA_RSP_SIZE);
155 }
156 else
157 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700158 hddLog(LOGE, "%s: pSmeOemDataRsp = NULL\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700159 status = eHAL_STATUS_FAILURE;
160 break;
161 }
162 }
163 } while(0);
164
165 return eHAL_STATUS_SUCCESS;
166}
167
168/**--------------------------------------------------------------------------------------------
169
170 \brief iw_set_oem_data_req() -
171
172 This function sets the oem data req configuration. This invokes
173 the respective sme oem data req functionality. Function for
174 handling the set IOCTL for the oem data req configuration
175
176 \param - dev - Pointer to the net device
177 - info - Pointer to the iw_oem_data_req
178 - wrqu - Pointer to the iwreq data
179 - extra - Pointer to the data
180
181 \return - 0 for success, non zero for failure
182
183-----------------------------------------------------------------------------------------------*/
184int iw_set_oem_data_req(
185 struct net_device *dev,
186 struct iw_request_info *info,
187 union iwreq_data *wrqu,
188 char *extra)
189{
190 eHalStatus status = eHAL_STATUS_SUCCESS;
191 struct iw_oem_data_req *pOemDataReq = NULL;
192 tOemDataReqConfig oemDataReqConfig;
193
194 tANI_U32 oemDataReqID = 0;
195
196 hdd_adapter_t *pAdapter = (netdev_priv(dev));
197 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
198
199
200 do
201 {
202 if(NULL != wrqu->data.pointer)
203 {
204 pOemDataReq = (struct iw_oem_data_req *)wrqu->data.pointer;
205 }
206
207 if(pOemDataReq == NULL)
208 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700209 hddLog(LOGE, "in %s oemDataReq == NULL\n", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700210 status = eHAL_STATUS_FAILURE;
211 break;
212 }
213
214 vos_mem_zero(&oemDataReqConfig, sizeof(tOemDataReqConfig));
215
216 vos_mem_copy((&oemDataReqConfig)->oemDataReq, pOemDataReq->oemDataReq, OEM_DATA_REQ_SIZE);
217
218 status = sme_OemDataReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
219 pAdapter->sessionId,
220 &oemDataReqConfig,
221 &oemDataReqID,
222 &hdd_OemDataReqCallback,
223 dev);
224
225 pwextBuf->oemDataReqID = oemDataReqID;
226 pwextBuf->oemDataReqInProgress = TRUE;
227
228 } while(0);
229
230 return status;
231}
232
233
234#endif