blob: 3604b754c83df20932f791fe0a85ced4f1263e1b [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Anurag Chouhance0dc992016-02-16 18:18:03 +05302 * Copyright (c) 2014-2016 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
Anurag Chouhance0dc992016-02-16 18:18:03 +053028#if !defined(__CDS_UTILS_H)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080029#define __CDS_UTILS_H
30
31/**=========================================================================
32
33 \file cds_utils.h
34
35 \brief Connectivity driver services (CDS) utility APIs
36
37 Various utility functions
38
39 ========================================================================*/
40
41/*--------------------------------------------------------------------------
42 Include Files
43 ------------------------------------------------------------------------*/
44#include <cdf_types.h>
45#include <cdf_status.h>
Anurag Chouhance0dc992016-02-16 18:18:03 +053046#include <qdf_status.h>
47#include <qdf_event.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "ani_global.h"
49
50/*--------------------------------------------------------------------------
51 Preprocessor definitions and constants
52 ------------------------------------------------------------------------*/
53#define CDS_DIGEST_SHA1_SIZE (20)
54#define CDS_DIGEST_MD5_SIZE (16)
55#define CDS_BAND_2GHZ (1)
56#define CDS_BAND_5GHZ (2)
57
58#define CDS_24_GHZ_BASE_FREQ (2407)
59#define CDS_5_GHZ_BASE_FREQ (5000)
60#define CDS_24_GHZ_CHANNEL_14 (14)
61#define CDS_24_GHZ_CHANNEL_15 (15)
62#define CDS_24_GHZ_CHANNEL_27 (27)
63#define CDS_5_GHZ_CHANNEL_170 (170)
64#define CDS_CHAN_SPACING_5MHZ (5)
65#define CDS_CHAN_SPACING_20MHZ (20)
66#define CDS_CHAN_14_FREQ (2484)
67#define CDS_CHAN_15_FREQ (2512)
68#define CDS_CHAN_170_FREQ (5852)
69
70#define cds_log(level, args...) CDF_TRACE(CDF_MODULE_ID_CDF, level, ## args)
71#define cds_logfl(level, format, args...) cds_log(level, FL(format), ## args)
72
73#define cds_alert(format, args...) \
74 cds_logfl(CDF_TRACE_LEVEL_FATAL, format, ## args)
75#define cds_err(format, args...) \
76 cds_logfl(CDF_TRACE_LEVEL_ERROR, format, ## args)
77#define cds_warn(format, args...) \
78 cds_logfl(CDF_TRACE_LEVEL_WARN, format, ## args)
79#define cds_notice(format, args...) \
80 cds_logfl(CDF_TRACE_LEVEL_INFO, format, ## args)
81#define cds_info(format, args...) \
82 cds_logfl(CDF_TRACE_LEVEL_INFO_HIGH, format, ## args)
83#define cds_debug(format, args...) \
84 cds_logfl(CDF_TRACE_LEVEL_DEBUG, format, ## args)
85/*--------------------------------------------------------------------------
86 Type declarations
87 ------------------------------------------------------------------------*/
88
89/*-------------------------------------------------------------------------
90 Function declarations and documenation
91 ------------------------------------------------------------------------*/
92
93CDF_STATUS cds_crypto_init(uint32_t *phCryptProv);
94
95CDF_STATUS cds_crypto_deinit(uint32_t hCryptProv);
96
97/**
98 * cds_rand_get_bytes
99
100 * FUNCTION:
101 * Returns cryptographically secure pseudo-random bytes.
102 *
103 *
104 * @param pbBuf - the caller allocated location where the bytes should be copied
105 * @param numBytes the number of bytes that should be generated and
106 * copied
107 *
108 * @return CDF_STATUS_SUCCSS if the operation succeeds
109 */
110CDF_STATUS cds_rand_get_bytes(uint32_t handle, uint8_t *pbBuf,
111 uint32_t numBytes);
112
113/**
114 * cds_sha1_hmac_str
115 *
116 * FUNCTION:
117 * Generate the HMAC-SHA1 of a string given a key.
118 *
119 * LOGIC:
120 * Standard HMAC processing from RFC 2104. The code is provided in the
121 * appendix of the RFC.
122 *
123 * ASSUMPTIONS:
124 * The RFC is correct.
125 *
126 * @param text text to be hashed
127 * @param textLen length of text
128 * @param key key to use for HMAC
129 * @param keyLen length of key
130 * @param digest holds resultant SHA1 HMAC (20B)
131 *
132 * @return CDF_STATUS_SUCCSS if the operation succeeds
133 *
134 */
135CDF_STATUS cds_sha1_hmac_str(uint32_t cryptHandle, /* Handle */
Anurag Chouhance0dc992016-02-16 18:18:03 +0530136 uint8_t *text, /* pointer to data stream */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 uint32_t textLen, /* length of data stream */
Anurag Chouhance0dc992016-02-16 18:18:03 +0530138 uint8_t *key, /* pointer to authentication key */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 uint32_t keyLen, /* length of authentication key */
140 uint8_t digest[CDS_DIGEST_SHA1_SIZE]); /* caller digest to be filled in */
141
142/**
143 * cds_md5_hmac_str
144 *
145 * FUNCTION:
146 * Generate the HMAC-MD5 of a string given a key.
147 *
148 * LOGIC:
149 * Standard HMAC processing from RFC 2104. The code is provided in the
150 * appendix of the RFC.
151 *
152 * ASSUMPTIONS:
153 * The RFC is correct.
154 *
155 * @param text text to be hashed
156 * @param textLen length of text
157 * @param key key to use for HMAC
158 * @param keyLen length of key
159 * @param digest holds resultant MD5 HMAC (16B)
160 *
161 * @return CDF_STATUS_SUCCSS if the operation succeeds
162 *
163 */
164CDF_STATUS cds_md5_hmac_str(uint32_t cryptHandle, /* Handle */
Anurag Chouhance0dc992016-02-16 18:18:03 +0530165 uint8_t *text, /* pointer to data stream */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 uint32_t textLen, /* length of data stream */
Anurag Chouhance0dc992016-02-16 18:18:03 +0530167 uint8_t *key, /* pointer to authentication key */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 uint32_t keyLen, /* length of authentication key */
169 uint8_t digest[CDS_DIGEST_MD5_SIZE]); /* caller digest to be filled in */
170
171CDF_STATUS cds_encrypt_aes(uint32_t cryptHandle, /* Handle */
172 uint8_t *pText, /* pointer to data stream */
173 uint8_t *Encrypted, uint8_t *pKey); /* pointer to authentication key */
174
175CDF_STATUS cds_decrypt_aes(uint32_t cryptHandle, /* Handle */
176 uint8_t *pText, /* pointer to data stream */
177 uint8_t *pDecrypted, uint8_t *pKey); /* pointer to authentication key */
178
179uint32_t cds_chan_to_freq(uint8_t chan);
180uint8_t cds_freq_to_chan(uint32_t freq);
181uint8_t cds_chan_to_band(uint32_t chan);
182#ifdef WLAN_FEATURE_11W
183bool cds_is_mmie_valid(uint8_t *key, uint8_t *ipn,
184 uint8_t *frm, uint8_t *efrm);
185bool cds_attach_mmie(uint8_t *igtk, uint8_t *ipn, uint16_t key_id,
186 uint8_t *frm, uint8_t *efrm, uint16_t frmLen);
187uint8_t cds_get_mmie_size(void);
188#endif /* WLAN_FEATURE_11W */
189CDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal pMac);
190#endif /* #if !defined __CDS_UTILS_H */