]> Pileus Git - ~andy/linux/blob - drivers/staging/csr/csr_wifi_hip_conversions.h
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[~andy/linux] / drivers / staging / csr / csr_wifi_hip_conversions.h
1 /*****************************************************************************
2
3             (c) Cambridge Silicon Radio Limited 2011
4             All rights reserved and confidential information of CSR
5
6             Refer to LICENSE.txt included with this source for details
7             on the license terms.
8
9 *****************************************************************************/
10
11 /*
12  * ---------------------------------------------------------------------------
13  *
14  * FILE: csr_wifi_hip_conversions.h
15  *
16  * PURPOSE:
17  *      This header file provides the macros for converting to and from
18  *      wire format.
19  *      These macros *MUST* work for little-endian AND big-endian hosts.
20  *
21  * ---------------------------------------------------------------------------
22  */
23 #ifndef __CSR_WIFI_HIP_CONVERSIONS_H__
24 #define __CSR_WIFI_HIP_CONVERSIONS_H__
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #define SIZEOF_UINT16           2
31 #define SIZEOF_UINT32           4
32 #define SIZEOF_UINT64           8
33
34 #define SIZEOF_SIGNAL_HEADER    6
35 #define SIZEOF_DATAREF          4
36
37
38 /*
39  * Macro to retrieve the signal ID from a wire-format signal.
40  */
41 #define GET_SIGNAL_ID(_buf)     CSR_GET_UINT16_FROM_LITTLE_ENDIAN((_buf))
42
43 /*
44  * Macros to retrieve and set the DATAREF fields in a packed (i.e. wire-format)
45  * HIP signal.
46  */
47 #define GET_PACKED_DATAREF_SLOT(_buf, _ref)                             \
48     CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
49
50 #define GET_PACKED_DATAREF_LEN(_buf, _ref)                              \
51     CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
52
53 #define SET_PACKED_DATAREF_SLOT(_buf, _ref, _slot)                      \
54     CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_slot), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
55
56 #define SET_PACKED_DATAREF_LEN(_buf, _ref, _len)                        \
57     CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_len), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
58
59 #define GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(_buf)              \
60     CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
61
62 #define GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(_buf)                     \
63     CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 4))
64
65 #define GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(_buf)                     \
66     CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
67
68 #define GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(_buf)                     \
69     CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 2))
70
71
72 s32 get_packed_struct_size(const u8 *buf);
73 CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig);
74 CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len);
75
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif /* __CSR_WIFI_HIP_CONVERSIONS_H__ */
81