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 #define SIZEOF_UINT16 2 27 #define SIZEOF_UINT32 4 28 #define SIZEOF_UINT64 8 29 30 #define SIZEOF_SIGNAL_HEADER 6 31 #define SIZEOF_DATAREF 4 32 33 34 /* 35 * Macro to retrieve the signal ID from a wire-format signal. 36 */ 37 #define GET_SIGNAL_ID(_buf) CSR_GET_UINT16_FROM_LITTLE_ENDIAN((_buf)) 38 39 /* 40 * Macros to retrieve and set the DATAREF fields in a packed (i.e. wire-format) 41 * HIP signal. 42 */ 43 #define GET_PACKED_DATAREF_SLOT(_buf, _ref) \ 44 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0)) 45 46 #define GET_PACKED_DATAREF_LEN(_buf, _ref) \ 47 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2)) 48 49 #define SET_PACKED_DATAREF_SLOT(_buf, _ref, _slot) \ 50 CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_slot), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0)) 51 52 #define SET_PACKED_DATAREF_LEN(_buf, _ref, _len) \ 53 CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_len), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2)) 54 55 #define GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(_buf) \ 56 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8)) 57 58 #define GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(_buf) \ 59 CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 4)) 60 61 #define GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(_buf) \ 62 CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8)) 63 64 #define GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(_buf) \ 65 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 2)) 66 67 68 s32 get_packed_struct_size(const u8 *buf); 69 CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig); 70 CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len); 71 72 #endif /* __CSR_WIFI_HIP_CONVERSIONS_H__ */ 73 74