blob: af63c01ed9375d44a517764a11bb58d4dbc68d30 [file] [log] [blame]
Jeff Johnsone7245742012-09-05 17:12:55 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnsone7245742012-09-05 17:12:55 -07006#ifdef FEATURE_OEM_DATA_SUPPORT
7
8/*================================================================================
9 \file wlan_hdd_oemdata.c
10
11 \brief Linux Wireless Extensions for oem data req/rsp
12
13 $Id: wlan_hdd_oemdata.c,v 1.34 2010/04/15 01:49:23 -- VINAY
14
15 Copyright (C) Qualcomm Inc.
16
17================================================================================*/
18
19#include <linux/version.h>
20#include <linux/module.h>
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/wireless.h>
24#include <wlan_hdd_includes.h>
25#include <net/arp.h>
26
27/*---------------------------------------------------------------------------------------------
28
29 \brief hdd_OemDataReqCallback() -
30
31 This function also reports the results to the user space
32
33 \return - 0 for success, non zero for failure
34
35-----------------------------------------------------------------------------------------------*/
36static eHalStatus hdd_OemDataReqCallback(tHalHandle hHal,
37 void *pContext,
38 tANI_U32 oemDataReqID,
39 eOemDataReqStatus oemDataReqStatus)
40{
41 eHalStatus status = eHAL_STATUS_SUCCESS;
42 struct net_device *dev = (struct net_device *) pContext;
43 union iwreq_data wrqu;
44 char buffer[IW_CUSTOM_MAX+1];
45
46 memset(&wrqu, '\0', sizeof(wrqu));
47 memset(buffer, '\0', sizeof(buffer));
48
49 //now if the status is success, then send an event up
50 //so that the application can request for the data
51 //else no need to send the event up
52 if(oemDataReqStatus == eOEM_DATA_REQ_FAILURE)
53 {
54 snprintf(buffer, IW_CUSTOM_MAX, "QCOM: OEM-DATA-REQ-FAILED");
Arif Hussain6d2a3322013-11-17 19:50:10 -080055 hddLog(LOGW, "%s: oem data req %d failed", __func__, oemDataReqID);
Jeff Johnsone7245742012-09-05 17:12:55 -070056 }
57 else if(oemDataReqStatus == eOEM_DATA_REQ_INVALID_MODE)
58 {
59 snprintf(buffer, IW_CUSTOM_MAX, "QCOM: OEM-DATA-REQ-INVALID-MODE");
Arif Hussain6d2a3322013-11-17 19:50:10 -080060 hddLog(LOGW, "%s: oem data req %d failed because the driver is in invalid mode (IBSS|BTAMP|AP)", __func__, oemDataReqID);
Jeff Johnsone7245742012-09-05 17:12:55 -070061 }
62 else
63 {
64 snprintf(buffer, IW_CUSTOM_MAX, "QCOM: OEM-DATA-REQ-SUCCESS");
65 //everything went alright
66 }
67
68 wrqu.data.pointer = buffer;
69 wrqu.data.length = strlen(buffer);
70
71 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buffer);
72
73 return status;
74}
75
76/**--------------------------------------------------------------------------------------------
77
78 \brief iw_get_oem_data_rsp() -
79
80 This function gets the oem data response. This invokes
81 the respective sme functionality. Function for handling the oem data rsp
82 IOCTL
83
84 \param - dev - Pointer to the net device
85 - info - Pointer to the iw_oem_data_req
86 - wrqu - Pointer to the iwreq data
87 - extra - Pointer to the data
88
89 \return - 0 for success, non zero for failure
90
91-----------------------------------------------------------------------------------------------*/
92int iw_get_oem_data_rsp(
93 struct net_device *dev,
94 struct iw_request_info *info,
95 union iwreq_data *wrqu,
96 char *extra)
97{
98 eHalStatus status = eHAL_STATUS_SUCCESS;
99 struct iw_oem_data_rsp* pHddOemDataRsp;
100 tOemDataRsp* pSmeOemDataRsp;
101
102 hdd_adapter_t *pAdapter = (netdev_priv(dev));
103
Sameer Thalappil75ea31a2013-02-21 19:38:16 -0800104 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
105 {
106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
107 "%s:LOGP in Progress. Ignore!!!",__func__);
108 return -EBUSY;
109 }
110
Jeff Johnsone7245742012-09-05 17:12:55 -0700111 do
112 {
113 //get the oem data response from sme
114 status = sme_getOemDataRsp(WLAN_HDD_GET_HAL_CTX(pAdapter), &pSmeOemDataRsp);
115 if(status != eHAL_STATUS_SUCCESS)
116 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800117 hddLog(LOGE, "%s: failed in sme_getOemDataRsp", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700118 break;
119 }
120 else
121 {
122 if(pSmeOemDataRsp != NULL)
123 {
124 pHddOemDataRsp = (struct iw_oem_data_rsp*)(extra);
125 vos_mem_copy(pHddOemDataRsp->oemDataRsp, pSmeOemDataRsp->oemDataRsp, OEM_DATA_RSP_SIZE);
126 }
127 else
128 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800129 hddLog(LOGE, "%s: pSmeOemDataRsp = NULL", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700130 status = eHAL_STATUS_FAILURE;
131 break;
132 }
133 }
134 } while(0);
135
136 return eHAL_STATUS_SUCCESS;
137}
138
139/**--------------------------------------------------------------------------------------------
140
141 \brief iw_set_oem_data_req() -
142
143 This function sets the oem data req configuration. This invokes
144 the respective sme oem data req functionality. Function for
145 handling the set IOCTL for the oem data req configuration
146
147 \param - dev - Pointer to the net device
148 - info - Pointer to the iw_oem_data_req
149 - wrqu - Pointer to the iwreq data
150 - extra - Pointer to the data
151
152 \return - 0 for success, non zero for failure
153
154-----------------------------------------------------------------------------------------------*/
155int iw_set_oem_data_req(
156 struct net_device *dev,
157 struct iw_request_info *info,
158 union iwreq_data *wrqu,
159 char *extra)
160{
161 eHalStatus status = eHAL_STATUS_SUCCESS;
162 struct iw_oem_data_req *pOemDataReq = NULL;
163 tOemDataReqConfig oemDataReqConfig;
164
165 tANI_U32 oemDataReqID = 0;
166
167 hdd_adapter_t *pAdapter = (netdev_priv(dev));
168 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
169
Sameer Thalappil75ea31a2013-02-21 19:38:16 -0800170 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
171 {
172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
173 "%s:LOGP in Progress. Ignore!!!",__func__);
174 return -EBUSY;
175 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700176
177 do
178 {
179 if(NULL != wrqu->data.pointer)
180 {
181 pOemDataReq = (struct iw_oem_data_req *)wrqu->data.pointer;
182 }
183
184 if(pOemDataReq == NULL)
185 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800186 hddLog(LOGE, "in %s oemDataReq == NULL", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700187 status = eHAL_STATUS_FAILURE;
188 break;
189 }
190
191 vos_mem_zero(&oemDataReqConfig, sizeof(tOemDataReqConfig));
192
Yue Ma63993e32013-10-21 23:10:53 -0700193 if (copy_from_user((&oemDataReqConfig)->oemDataReq,
194 pOemDataReq->oemDataReq, OEM_DATA_REQ_SIZE))
195 {
196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
197 "%s: copy_from_user() failed!", __func__);
198 return -EFAULT;
199 }
200
Jeff Johnsone7245742012-09-05 17:12:55 -0700201 status = sme_OemDataReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
202 pAdapter->sessionId,
203 &oemDataReqConfig,
204 &oemDataReqID,
205 &hdd_OemDataReqCallback,
206 dev);
207
208 pwextBuf->oemDataReqID = oemDataReqID;
209 pwextBuf->oemDataReqInProgress = TRUE;
210
211 } while(0);
212
213 return status;
214}
215
216
217#endif