blob: 71a3d3c474efc084638140ba7b320f7a139c63ea [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -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 Johnson295189b2012-06-20 16:38:30 -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#ifndef WLAN_HDD_FTM_H
43#define WLAN_HDD_FTM_H
44#include "vos_status.h"
45#include "vos_mq.h"
46#include "vos_api.h"
47#include "msg.h"
48#include "halTypes.h"
49#include "vos_types.h"
50#include <wlan_ptt_sock_svc.h>
51
52#define WLAN_FTM_SUCCESS 0
53#define WLAN_FTM_FAILURE 1
54
55#define WLAN_FTM_START 1
56#define WLAN_FTM_STOP 2
57#define WLAN_FTM_CMD 3
58
59
60#define WLAN_FTM_PHY_CMD 100
61#define SIR_HAL_FTM_CMD 10
62#define QUALCOMM_MODULE_TYPE 2
63#define WLAN_FTM_COMMAND_TIME_OUT 1000
64#define PHYDBG_PREAMBLE_NOT_SUPPORTED 0xFF
65/* Private ioctls and their sub-ioctls */
66#define WLAN_FTM_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
67#define WE_FTM_ON_OFF 1
68#define WE_TX_PKT_GEN 2
69#define WE_SET_TX_IFS 3
70#define WE_SET_TX_PKT_CNT 4
71#define WE_SET_TX_PKT_LEN 5
72#define WE_SET_CHANNEL 6
73#define WE_SET_TX_POWER 7
74#define WE_CLEAR_RX_PKT_CNT 8
75#define WE_RX 9
76#define WE_ENABLE_CHAIN 10
77
78/* Private ioctls and their sub-ioctls */
79#define WLAN_FTM_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
80#define WE_GET_CHANNEL 1
81#define WE_GET_TX_POWER 2
82#define WE_GET_RX_PKT_CNT 3
83
84/* Private ioctls and their sub-ioctls */
85#define WLAN_FTM_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
86
87/* Private ioctls and their sub-ioctls */
88#define WLAN_FTM_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
89#define WE_SET_MAC_ADDRESS 1
90#define WE_SET_TX_RATE 2
91
92/* Private ioctls and their sub-ioctls */
93#define WLAN_FTM_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
94#define WE_SET_WLAN_DBG 1
95
96/* Private ioctls and their sub-ioctls */
97#define WLAN_FTM_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
98#define WE_GET_MAC_ADDRESS 1
99#define WE_GET_TX_RATE 2
100#define WE_GET_FTM_VERSION 3
101#define WE_GET_FTM_STATUS 4
102#define WE_GET_RX_RSSI 5
103
104/* Private ioctls and their sub-ioctls */
105#define WLAN_FTM_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
106#define WE_SET_NV_DEFAULTS 1
107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#define WE_FTM_MAX_STR_LEN 1024
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
Prasanna Kumarf6c94ae2013-04-11 20:05:21 -0700110#define MAX_NV_TABLE_SIZE 40000
Jeff Johnson295189b2012-06-20 16:38:30 -0700111
112typedef enum {
113 WLAN_FTM_CMD_START = 1,
114 WLAN_FTM_CMD_STOP,
115 WLAN_FTM_CMD_CMD
116} wlan_hdd_ftm_cmds;
117typedef struct ftm_hdr_s {
118 v_U16_t cmd_id;
119 v_U16_t data_len;
120 v_U16_t respPktSize;
121} ftm_hdr_t;
122
123/* The request buffer of FTM which contains a byte of command and the request */
124typedef struct wlan_hdd_ftm_payload_s {
125 v_U16_t ftm_cmd_type;
126 v_U8_t pFtmCmd[1];
127}wlan_hdd_ftm_payload;
128#define SIZE_OF_FTM_DIAG_HEADER_LEN 12
129/* the FTM command/response structure */
130typedef struct wlan_hdd_ftm_request_s
131{
132 v_U8_t cmd_code;
133 v_U8_t sub_sys_id;
134 v_U16_t mode_id;
135 ftm_hdr_t ftm_hdr;
136 v_U16_t module_type;
137 wlan_hdd_ftm_payload ftmpkt;
138}wlan_hdd_ftm_request_t;
139
140typedef struct wlan_hdd_ftm_response_s
141{
142 v_U8_t cmd_code;
143 v_U8_t sub_sys_id;
144 v_U16_t mode_id;
145 ftm_hdr_t ftm_hdr;
146 v_U16_t ftm_err_code;
147 wlan_hdd_ftm_payload ftmpkt;
148}wlan_hdd_ftm_response_t;
149
150typedef enum {
151 WLAN_FTM_INITIALIZED,
152 WLAN_FTM_STOPPED,
153 WLAN_FTM_STARTED,
154} wlan_hdd_ftm_state;
155typedef struct wlan_hdd_ftm_status_s
156{
157 v_U8_t ftm_state;
158 wlan_hdd_ftm_request_t *pRequestBuf;
159 wlan_hdd_ftm_response_t *pResponseBuf;
160 tAniNlHdr *wnl;
161 /**vos event */
162 vos_event_t ftm_vos_event;
163
164 /** completion variable for ftm command to complete*/
165 struct completion ftm_comp_var;
166 v_BOOL_t IsCmdPending;
167 v_BOOL_t cmd_iwpriv;
168
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 /** Large size of NV Table Handle **/
170 eNvTable processingNVTable;
171 v_U32_t targetNVTableSize;
172 v_U8_t *targetNVTablePointer;
173 v_U32_t processedNVTableSize;
174 v_U8_t *tempNVTableBuffer;
Jeff Johnson295189b2012-06-20 16:38:30 -0700175
176} wlan_hdd_ftm_status_t;
177typedef struct ftm_msg_s
178{
179 /* This field can be used as sequence
180 number/dialogue token for matching request/response */
181 v_U16_t type;
182
183 /* This guy carries the command buffer along with command id */
184 void *cmd_ptr;
185 v_U32_t bodyval;
186} ftm_msg_t;
187typedef struct ftm_rsp_msg_s
188{
189 v_U16_t msgId;
190 v_U16_t msgBodyLength;
191 v_U32_t respStatus;
192 v_U8_t *msgResponse;
193} ftm_rsp_msg_t;
194
195typedef struct rateIndex2Preamble
196{
197 v_U16_t rate_index;
198 v_U16_t Preamble;
199} rateIndex2Preamble_t;
200typedef struct freq_chan_s
201{
202 v_U16_t freq;
203 v_U16_t chan;
204} freq_chan_t;
205
206typedef struct rateStr2rateIndex_s
207{
208 v_U16_t rate_index;
209 char rate_str[30];
210} rateStr2rateIndex_t;
211
212
213#define FTM_SWAP16(A) ((((tANI_U16)(A) & 0xff00) >> 8) | \
214 (((tANI_U16)(A) & 0x00ff) << 8) \
215 )
216#define PTT_HEADER_LENGTH 8
217
218#define FTM_VOS_EVENT_WAIT_TIME 10000
219
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800220#define SIZE_OF_TABLE(a) (sizeof(a) / sizeof(a[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700221
222int wlan_hdd_ftm_open(hdd_context_t *pHddCtx);
223void wlan_hdd_process_ftm_cmd (hdd_context_t *pHddCtx,tAniNlHdr *wnl);
224int wlan_hdd_ftm_close(hdd_context_t *pHddCtx);
225
226#endif