blob: 49099450ce5c22535709cd790ab978876c620a48 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2014-2015 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
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#if !defined(__CDF_TYPES_H)
29#define __CDF_TYPES_H
30/**
31 * DOC: cdf_types.h
32 *
33 * Connectivity driver framework (CDF) basic type definitions
34 */
35
36/* Include Files */
37#include "i_cdf_types.h"
38#include <string.h>
39
40/* Preprocessor definitions and constants */
41
42/**
43 * CDF_MAX - get maximum of two values
44 * @_x: 1st arguement
45 * @_y: 2nd arguement
46 */
47#define CDF_MAX(_x, _y) (((_x) > (_y)) ? (_x) : (_y))
48
49/**
50 * CDF_MIN - get minimum of two values
51 * @_x: 1st arguement
52 * @_y: 2nd arguement
53 */
54#define CDF_MIN(_x, _y) (((_x) < (_y)) ? (_x) : (_y))
55
56/**
57 * CDF_SWAP_U16 - swap input u16 value
58 * @_x: variable to swap
59 */
60#define CDF_SWAP_U16(_x) \
61 ((((_x) << 8) & 0xFF00) | (((_x) >> 8) & 0x00FF))
62
63/**
64 * CDF_SWAP_U32 - swap input u32 value
65 * @_x: variable to swap
66 */
67#define CDF_SWAP_U32(_x) \
68 (((((_x) << 24) & 0xFF000000) | (((_x) >> 24) & 0x000000FF)) | \
69 ((((_x) << 8) & 0x00FF0000) | (((_x) >> 8) & 0x0000FF00)))
70
71#define CDF_TICKS_PER_SECOND (1000)
72
73/**
74 * CDF_ARRAY_SIZE - get array size
75 * @_arr: array variable name
76 */
77#define CDF_ARRAY_SIZE(_arr) (sizeof(_arr) / sizeof((_arr)[0]))
78
79/* endian operations for Big Endian and Small Endian modes */
80#ifdef ANI_LITTLE_BYTE_ENDIAN
81
82#define cdf_be16_to_cpu(_x) CDF_SWAP_U16(_x)
83
84#endif
85
86#ifdef ANI_BIG_BYTE_ENDIAN
87
88#define cdf_be16_to_cpu(_x) (_x)
89
90#endif
91
92#ifndef __ahdecl
93#ifdef __i386__
94#define __ahdecl __attribute__((regparm(0)))
95#else
96#define __ahdecl
97#endif
98#endif
99
100#define CDF_OS_MAX_SCATTER __CDF_OS_MAX_SCATTER
101
102/**
103 * @brief denotes structure is packed.
104 */
105#define cdf_packed __cdf_packed
106
107/**
108 * typedef cdf_handle_t - handles opaque to each other
109 */
110typedef void *cdf_handle_t;
111
112/**
113 * typedef cdf_device_t - Platform/bus generic handle.
114 * Used for bus specific functions.
115 */
116typedef __cdf_device_t cdf_device_t;
117
118/**
119 * typedef cdf_size_t - size of an object
120 */
121typedef __cdf_size_t cdf_size_t;
122
123/**
124 * typedef cdf_dma_map_t - DMA mapping object.
125 */
126typedef __cdf_dma_map_t cdf_dma_map_t;
127
128/**
129 * tyepdef cdf_dma_addr_t - DMA address.
130 */
131typedef __cdf_dma_addr_t cdf_dma_addr_t;
132
133/**
134 * tyepdef cdf_dma_context_t - DMA context.
135 */
136typedef __cdf_dma_context_t cdf_dma_context_t;
137
138
139#define cdf_iomem_t __cdf_iomem_t;
140/**
141 * typedef enum CDF_TIMER_TYPE - CDF timer type
142 * @CDF_TIMER_TYPE_SW: Deferrable SW timer it will not cause CPU to wake up
143 * on expiry
144 * @CDF_TIMER_TYPE_WAKE_APPS: Non deferrable timer which will cause CPU to
145 * wake up on expiry
146 */
147typedef enum {
148 CDF_TIMER_TYPE_SW,
149 CDF_TIMER_TYPE_WAKE_APPS
150} CDF_TIMER_TYPE;
151
152/**
153 * tyepdef cdf_resource_type_t - hw resources
154 *
155 * @CDF_RESOURCE_TYPE_MEM: memory resource
156 * @CDF_RESOURCE_TYPE_IO: io resource
157 *
158 * Define the hw resources the OS has allocated for the device
159 * Note that start defines a mapped area.
160 */
161typedef enum {
162 CDF_RESOURCE_TYPE_MEM,
163 CDF_RESOURCE_TYPE_IO,
164} cdf_resource_type_t;
165
166/**
167 * tyepdef cdf_resource_t - representation of a h/w resource.
168 *
169 * @start: start
170 * @end: end
171 * @type: resource type
172 */
173typedef struct {
174 uint64_t start;
175 uint64_t end;
176 cdf_resource_type_t type;
177} cdf_resource_t;
178
179/**
180 * typedef cdf_dma_dir_t - DMA directions
181 *
182 * @CDF_DMA_BIDIRECTIONAL: bidirectional data
183 * @CDF_DMA_TO_DEVICE: data going from device to memory
184 * @CDF_DMA_FROM_DEVICE: data going from memory to device
185 */
186typedef enum {
187 CDF_DMA_BIDIRECTIONAL = __CDF_DMA_BIDIRECTIONAL,
188 CDF_DMA_TO_DEVICE = __CDF_DMA_TO_DEVICE,
189 CDF_DMA_FROM_DEVICE = __CDF_DMA_FROM_DEVICE,
190} cdf_dma_dir_t;
191
192/* work queue(kernel thread)/DPC function callback */
193typedef void (*cdf_defer_fn_t)(void *);
194
195/* Prototype of the critical region function that is to be
196 * executed with spinlock held and interrupt disalbed
197 */
198typedef bool (*cdf_irqlocked_func_t)(void *);
199
200/* Prototype of timer function */
201typedef void (*cdf_softirq_timer_func_t)(void *);
202
203#define cdf_print __cdf_print
204#define cdf_vprint __cdf_vprint
205#define cdf_snprint __cdf_snprint
206
207#define cdf_offsetof(type, field) offsetof(type, field)
208
209/**
210 * typedef CDF_MODULE_ID - CDF Module IDs
211 *
212 * @CDF_MODULE_ID_TLSHIM: TLSHIM module ID
213 * @CDF_MODULE_ID_WMI: WMI module ID
214 * @CDF_MODULE_ID_HTT: HTT module ID
215 * @CDF_MODULE_ID_RSV4: Reserved
216 * @CDF_MODULE_ID_HDD: HDD module ID
217 * @CDF_MODULE_ID_SME: SME module ID
218 * @CDF_MODULE_ID_PE: PE module ID
219 * @CDF_MODULE_ID_WMA: WMA module ID
220 * @CDF_MODULE_ID_SYS: SYS module ID
221 * @CDF_MODULE_ID_CDF: CDF module ID
222 * @CDF_MODULE_ID_SAP: SAP module ID
223 * @CDF_MODULE_ID_HDD_SOFTAP: HDD SAP module ID
224 * @CDF_MODULE_ID_HDD_DATA: HDD DATA module ID
225 * @CDF_MODULE_ID_HDD_SAP_DATA: HDD SAP DATA module ID
226 * @CDF_MODULE_ID_HIF: HIF module ID
227 * @CDF_MODULE_ID_HTC: HTC module ID
228 * @CDF_MODULE_ID_TXRX: TXRX module ID
229 * @CDF_MODULE_ID_CDF_DEVICE: CDF DEVICE module ID
230 * @CDF_MODULE_ID_CFG: CFG module ID
231 * @CDF_MODULE_ID_BMI: BMI module ID
232 * @CDF_MODULE_ID_EPPING: EPPING module ID
233 * @CDF_MODULE_ID_MAX: Max place holder module ID
234 *
235 * These are generic IDs that identify the various modules in the software
236 * system
237 * 0 is unused for historical purposes
238 * 3 & 4 are unused for historical purposes
239 */
240typedef enum {
241 CDF_MODULE_ID_TLSHIM = 1,
242 CDF_MODULE_ID_WMI = 2,
243 CDF_MODULE_ID_HTT = 3,
244 CDF_MODULE_ID_RSV4 = 4,
245 CDF_MODULE_ID_HDD = 5,
246 CDF_MODULE_ID_SME = 6,
247 CDF_MODULE_ID_PE = 7,
248 CDF_MODULE_ID_WMA = 8,
249 CDF_MODULE_ID_SYS = 9,
250 CDF_MODULE_ID_CDF = 10,
251 CDF_MODULE_ID_SAP = 11,
252 CDF_MODULE_ID_HDD_SOFTAP = 12,
253 CDF_MODULE_ID_HDD_DATA = 14,
254 CDF_MODULE_ID_HDD_SAP_DATA = 15,
255
256 CDF_MODULE_ID_HIF = 16,
257 CDF_MODULE_ID_HTC = 17,
258 CDF_MODULE_ID_TXRX = 18,
259 CDF_MODULE_ID_CDF_DEVICE = 19,
260 CDF_MODULE_ID_CFG = 20,
261 CDF_MODULE_ID_BMI = 21,
262 CDF_MODULE_ID_EPPING = 22,
263
264 CDF_MODULE_ID_MAX
265} CDF_MODULE_ID;
266
267/**
268 * typedef enum tCDF_CON_MODE - Concurrency role.
269 *
270 * @CDF_STA_MODE: STA mode
271 * @CDF_SAP_MODE: SAP mode
272 * @CDF_P2P_CLIENT_MODE: P2P client mode
273 * @CDF_P2P_GO_MODE: P2P GO mode
274 * @CDF_FTM_MODE: FTM mode
275 * @CDF_IBSS_MODE: IBSS mode
276 * @CDF_P2P_DEVICE_MODE: P2P device mode
277 * @CDF_EPPING_MODE: EPPING device mode
278 * @CDF_OCB_MODE: OCB device mode
279 * @CDF_MAX_NO_OF_MODE: Max place holder
280 *
281 * These are generic IDs that identify the various roles
282 * in the software system
283 */
284typedef enum {
285 CDF_STA_MODE = 0,
286 CDF_SAP_MODE = 1,
287 CDF_P2P_CLIENT_MODE,
288 CDF_P2P_GO_MODE,
289 CDF_FTM_MODE = 5,
290 CDF_IBSS_MODE,
291 CDF_P2P_DEVICE_MODE,
292 CDF_EPPING_MODE,
293 CDF_OCB_MODE,
294 CDF_MAX_NO_OF_MODE
295} tCDF_CON_MODE;
296
297#ifdef WLAN_OPEN_P2P_INTERFACE
298/* This should match with WLAN_MAX_INTERFACES */
299#define CDF_MAX_CONCURRENCY_PERSONA (4)
300#else
301#define CDF_MAX_CONCURRENCY_PERSONA (3)
302#endif
303
304#define CDF_STA_MASK (1 << CDF_STA_MODE)
305#define CDF_SAP_MASK (1 << CDF_SAP_MODE)
306#define CDF_P2P_CLIENT_MASK (1 << CDF_P2P_CLIENT_MODE)
307#define CDF_P2P_GO_MASK (1 << CDF_P2P_GO_MODE)
308
309#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
310typedef enum {
311 CDF_MCC_TO_SCC_SWITCH_DISABLE = 0,
312 CDF_MCC_TO_SCC_SWITCH_ENABLE,
313 CDF_MCC_TO_SCC_SWITCH_FORCE,
314 CDF_MCC_TO_SCC_SWITCH_MAX
315} tCDF_MCC_TO_SCC_SWITCH_MODE;
316#endif
317
318#if !defined(NULL)
319#ifdef __cplusplus
320#define NULL 0
321#else
322#define NULL ((void *)0)
323#endif
324#endif
325
326/* 'Time' type */
327typedef unsigned long v_TIME_t;
328
329/* typedef for CDF Context... */
330typedef void *v_CONTEXT_t;
331
332#define CDF_MAC_ADDR_SIZE (6)
333
334/**
335 * struct cdf_mac_addr - mac address array
336 * @bytes: MAC address bytes
337 */
338struct cdf_mac_addr {
339 uint8_t bytes[CDF_MAC_ADDR_SIZE];
340};
341
342/* This macro is used to initialize a CDF MacAddress to the broadcast
343 * MacAddress. It is used like this...
344 * struct cdf_mac_addr macAddress = CDF_MAC_ADDR_BROADCAST_INITIALIZER
345 */
346#define CDF_MAC_ADDR_BROADCAST_INITIALIZER { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }
347
348/* This macro is used to initialize a CDF MacAddress to zero
349 * It is used like this...
350 * struct cdf_mac_addr macAddress = CDF_MAC_ADDR_ZERO_INITIALIZER
351 */
352#define CDF_MAC_ADDR_ZERO_INITIALIZER { { 0, 0, 0, 0, 0, 0 } }
353
354#define CDF_IPV4_ADDR_SIZE (4)
355
356/**
357 * struct cdf_tso_frag_t - fragments of a single TCP segment
358 * @paddr_low_32: Lower 32 bits of the buffer pointer
359 * @paddr_upper_16: upper 16 bits of the buffer pointer
360 * @length: length of the buffer
361 * @vaddr: virtual address
362 *
363 * This structure holds the fragments of a single TCP segment of a
364 * given jumbo TSO network buffer
365 */
366struct cdf_tso_frag_t {
367 uint32_t paddr_low_32;
368 uint32_t paddr_upper_16:16,
369 length:16;
370 unsigned char *vaddr;
371};
372
373#define FRAG_NUM_MAX 6
374
375/**
376 * struct cdf_tso_flags_t - TSO specific flags
377 * @tso_enable: Enable transmit segmentation offload
378 * @tcp_flags_mask: Tcp_flag is inserted into the header based
379 * on the mask
380 * @l2_len: L2 length for the msdu
381 * @ip_len: IP length for the msdu
382 * @tcp_seq_num: TCP sequence number
383 * @ip_id: IP identification number
384 *
385 * This structure holds the TSO specific flags extracted from the TSO network
386 * buffer for a given TCP segment
387 */
388struct cdf_tso_flags_t {
389 u_int32_t tso_enable:1,
390 reserved_0a:6,
391 fin:1,
392 syn:1,
393 rst:1,
394 psh:1,
395 ack:1,
396 urg:1,
397 ece:1,
398 cwr:1,
399 ns:1,
400 tcp_flags_mask:9,
401 reserved_0b:7;
402/* ------------------------------------------------------------------- */
403
404 u_int32_t l2_len:16,
405 ip_len:16;
406/* ------------------------------------------------------------------- */
407
408 u_int32_t tcp_seq_num;
409/* ------------------------------------------------------------------- */
410
411 u_int32_t ip_id:16,
412 ipv4_checksum_en:1,
413 udp_ipv4_checksum_en:1,
414 udp_ipv6_checksum_en:1,
415 tcp_ipv4_checksum_en:1,
416 tcp_ipv6_checksum_en:1,
417 partial_checksum_en:1,
418 reserved_3a:10;
419/* ------------------------------------------------------------------- */
420
421 u_int32_t checksum_offset:14,
422 reserved_4a:2,
423 payload_start_offset:14,
424 reserved_4b:2;
425/* ------------------------------------------------------------------- */
426
427 u_int32_t payload_end_offset:14,
428 reserved_5:18;
429};
430
431/**
432 * struct cdf_tso_seg_t - single TSO segment
433 * @tso_flags: TSO flags
434 * @num_frags: number of fragments
435 * @tso_frags: array holding the fragments
436 *
437 * This structure holds the information of a single TSO segment of a jumbo
438 * TSO network buffer
439 */
440struct cdf_tso_seg_t {
441 struct cdf_tso_flags_t tso_flags;
442/* ------------------------------------------------------------------- */
443 uint32_t num_frags;
444 struct cdf_tso_frag_t tso_frags[FRAG_NUM_MAX];
445};
446
447struct cdf_tso_seg_elem_t {
448 struct cdf_tso_seg_t seg;
449 struct cdf_tso_seg_elem_t *next;
450};
451
452/**
453 * struct cdf_tso_info_t - TSO information extracted
454 * @is_tso: is this is a TSO frame
455 * @num_segs: number of segments
456 * @total_len: total length of the packet
457 * @tso_seg_list: list of TSO segments for this jumbo packet
458 * @curr_seg: segment that is currently being processed
459 *
460 * This structure holds the TSO information extracted after parsing the TSO
461 * jumbo network buffer. It contains a chain of the TSO segments belonging to
462 * the jumbo packet
463 */
464struct cdf_tso_info_t {
465 uint8_t is_tso;
466 uint32_t num_segs;
467 uint32_t total_len;
468 struct cdf_tso_seg_elem_t *tso_seg_list;
469 struct cdf_tso_seg_elem_t *curr_seg;
470};
471
472/**
473 * Used to set classify bit in CE desc.
474 */
475#define CDF_CE_TX_CLASSIFY_BIT_S 5
476
477/**
478 * 2 bits starting at bit 6 in CE desc.
479 */
480#define CDF_CE_TX_PKT_TYPE_BIT_S 6
481
482/**
483 * 12 bits --> 16-27, in the CE desciptor, the length of HTT/HTC descriptor
484 */
485#define CDF_CE_TX_PKT_OFFSET_BIT_S 16
486
487/**
488 * Mask for packet offset in the CE descriptor.
489 */
490#define CDF_CE_TX_PKT_OFFSET_BIT_M 0x0fff0000
491
492#endif /* if !defined __CDF_TYPES_H */