Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2011-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 | /* |
| 29 | * |
| 30 | * This file lim_ser_des_utils.h contains the utility definitions |
| 31 | * LIM uses while processing messages from upper layer software |
| 32 | * modules |
| 33 | * Author: Chandra Modumudi |
| 34 | * Date: 10/20/02 |
| 35 | * History:- |
| 36 | * Date Modified by Modification Information |
| 37 | * -------------------------------------------------------------------- |
| 38 | */ |
| 39 | #ifndef __LIM_SERDES_UTILS_H |
| 40 | #define __LIM_SERDES_UTILS_H |
| 41 | |
| 42 | #include "sir_api.h" |
| 43 | #include "ani_system_defs.h" |
| 44 | #include "sir_mac_prot_def.h" |
| 45 | #include "utils_api.h" |
| 46 | #include "lim_types.h" |
| 47 | #include "lim_prop_exts_utils.h" |
| 48 | |
| 49 | void lim_get_session_info(tpAniSirGlobal pMac, uint8_t *, |
| 50 | uint8_t *, uint16_t *); |
| 51 | |
| 52 | /* Byte String <--> uint16_t/uint32_t copy functions */ |
| 53 | static inline void lim_copy_u16(uint8_t *ptr, uint16_t u16Val) |
| 54 | { |
| 55 | #if ((defined(ANI_OS_TYPE_QNX) && defined(ANI_LITTLE_BYTE_ENDIAN)) || \ |
| 56 | (defined(ANI_OS_TYPE_ANDROID) && defined(ANI_LITTLE_BYTE_ENDIAN))) |
| 57 | *ptr++ = (uint8_t) (u16Val & 0xff); |
| 58 | *ptr = (uint8_t) ((u16Val >> 8) & 0xff); |
| 59 | #else |
| 60 | #error "Unknown combination of OS Type and endianess" |
| 61 | #endif |
| 62 | } |
| 63 | |
| 64 | static inline uint16_t lim_get_u16(uint8_t *ptr) |
| 65 | { |
| 66 | #if ((defined(ANI_OS_TYPE_QNX) && defined(ANI_LITTLE_BYTE_ENDIAN)) || \ |
| 67 | (defined(ANI_OS_TYPE_ANDROID) && defined(ANI_LITTLE_BYTE_ENDIAN))) |
| 68 | return ((uint16_t) (*(ptr + 1) << 8)) | ((uint16_t) (*ptr)); |
| 69 | #else |
| 70 | #error "Unknown combination of OS Type and endianess" |
| 71 | #endif |
| 72 | } |
| 73 | |
| 74 | static inline void lim_copy_u32(uint8_t *ptr, uint32_t u32Val) |
| 75 | { |
| 76 | #if ((defined(ANI_OS_TYPE_QNX) && defined(ANI_LITTLE_BYTE_ENDIAN)) || \ |
| 77 | (defined(ANI_OS_TYPE_ANDROID) && defined(ANI_LITTLE_BYTE_ENDIAN))) |
| 78 | *ptr++ = (uint8_t) (u32Val & 0xff); |
| 79 | *ptr++ = (uint8_t) ((u32Val >> 8) & 0xff); |
| 80 | *ptr++ = (uint8_t) ((u32Val >> 16) & 0xff); |
| 81 | *ptr = (uint8_t) ((u32Val >> 24) & 0xff); |
| 82 | #else |
| 83 | #error "Unknown combination of OS Type and endianess" |
| 84 | #endif |
| 85 | } |
| 86 | |
| 87 | static inline uint32_t lim_get_u32(uint8_t *ptr) |
| 88 | { |
| 89 | #if ((defined(ANI_OS_TYPE_QNX) && defined(ANI_LITTLE_BYTE_ENDIAN)) || \ |
| 90 | (defined(ANI_OS_TYPE_ANDROID) && defined(ANI_LITTLE_BYTE_ENDIAN))) |
| 91 | return ((*(ptr + 3) << 24) | |
| 92 | (*(ptr + 2) << 16) | (*(ptr + 1) << 8) | (*(ptr))); |
| 93 | #else |
| 94 | #error "Unknown combination of OS Type and endianess" |
| 95 | #endif |
| 96 | } |
| 97 | |
| 98 | #endif /* __LIM_SERDES_UTILS_H */ |