blob: e2b52084c1a99170169d65330fc168ead0640c1e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302 * Copyright (c) 2011-2015, 2016-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
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
49void lim_get_session_info(tpAniSirGlobal pMac, uint8_t *,
50 uint8_t *, uint16_t *);
51
52/* Byte String <--> uint16_t/uint32_t copy functions */
53static 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
64static 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
74static 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
87static 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
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053098/**
99 * lim_copy_u16_be()- This API copies a u16 value in buffer
100 * to network byte order
101 * @ptr: pointer to buffer
102 * @u16_val: value needs to be copied
103 *
104 * Return: None
105 */
106static inline void lim_copy_u16_be(uint8_t *ptr, uint16_t u16_val)
107{
108 ptr[0] = u16_val >> 8;
109 ptr[1] = u16_val & 0xff;
110}
111
112/**
113 * lim_copy_u16_be()- This API reads u16 value from network byte order buffer
114 * @ptr: pointer to buffer
115 *
116 * Return: 16bit value
117 */
118static inline uint16_t lim_get_u16_be(uint8_t *buf)
119{
120 return (buf[0] << 8) | buf[1];
121}
122
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +0530123tSirRetStatus lim_send_disassoc_frm_req_ser_des(tpAniSirGlobal mac_ctx,
124 struct sme_send_disassoc_frm_req *disassoc_frm_req,
125 uint8_t *buf);
126
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127#endif /* __LIM_SERDES_UTILS_H */