mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-23 09:42:19 +03:00
rtl8822ce: Porting Base driver from K5.10
Porting Base K5.10 driver to K5.15 Version: v5.9.0.3e_nv-1-gdafe03f15.20220505_COEX20200103-1717 Bug 3750163 Change-Id: I5c46db2976addff08a73bd31dafd84c093702545 Signed-off-by: Revanth Kumar Uppala <ruppala@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2814761 GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com> Reviewed-by: Narayan Reddy <narayanr@nvidia.com> Reviewed-by: Sushil Kumar Singh <sushilkumars@nvidia.com> Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
729793fc3b
commit
599d993c3d
9
drivers/net/wireless/realtek/rtl8822ce/Kconfig
Normal file
9
drivers/net/wireless/realtek/rtl8822ce/Kconfig
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
config RTL8822CE
|
||||||
|
tristate "Realtek 8822C PCIE WiFi"
|
||||||
|
depends on PCI
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
This module adds support for RTL8822CE chipset
|
||||||
|
|
||||||
|
This driver module will be called rtl8822ce
|
||||||
|
Use m if unsure
|
||||||
2469
drivers/net/wireless/realtek/rtl8822ce/Makefile
Normal file
2469
drivers/net/wireless/realtek/rtl8822ce/Makefile
Normal file
File diff suppressed because it is too large
Load Diff
211
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-ccm.c
Normal file
211
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-ccm.c
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
* Counter with CBC-MAC (CCM) with AES
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010-2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
#include "aes_wrap.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void xor_aes_block(u8 *dst, const u8 *src)
|
||||||
|
{
|
||||||
|
u32 *d = (u32 *) dst;
|
||||||
|
u32 *s = (u32 *) src;
|
||||||
|
*d++ ^= *s++;
|
||||||
|
*d++ ^= *s++;
|
||||||
|
*d++ ^= *s++;
|
||||||
|
*d++ ^= *s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_ccm_auth_start(void *aes, size_t M, size_t L, const u8 *nonce,
|
||||||
|
const u8 *aad, size_t aad_len, size_t plain_len,
|
||||||
|
u8 *x)
|
||||||
|
{
|
||||||
|
u8 aad_buf[2 * AES_BLOCK_SIZE];
|
||||||
|
u8 b[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
/* Authentication */
|
||||||
|
/* B_0: Flags | Nonce N | l(m) */
|
||||||
|
b[0] = aad_len ? 0x40 : 0 /* Adata */;
|
||||||
|
b[0] |= (((M - 2) / 2) /* M' */ << 3);
|
||||||
|
b[0] |= (L - 1) /* L' */;
|
||||||
|
os_memcpy(&b[1], nonce, 15 - L);
|
||||||
|
WPA_PUT_BE16(&b[AES_BLOCK_SIZE - L], plain_len);
|
||||||
|
|
||||||
|
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM B_0", b, AES_BLOCK_SIZE);
|
||||||
|
aes_encrypt(aes, b, x); /* X_1 = E(K, B_0) */
|
||||||
|
|
||||||
|
if (!aad_len)
|
||||||
|
return;
|
||||||
|
|
||||||
|
WPA_PUT_BE16(aad_buf, aad_len);
|
||||||
|
os_memcpy(aad_buf + 2, aad, aad_len);
|
||||||
|
os_memset(aad_buf + 2 + aad_len, 0, sizeof(aad_buf) - 2 - aad_len);
|
||||||
|
|
||||||
|
xor_aes_block(aad_buf, x);
|
||||||
|
aes_encrypt(aes, aad_buf, x); /* X_2 = E(K, X_1 XOR B_1) */
|
||||||
|
|
||||||
|
if (aad_len > AES_BLOCK_SIZE - 2) {
|
||||||
|
xor_aes_block(&aad_buf[AES_BLOCK_SIZE], x);
|
||||||
|
/* X_3 = E(K, X_2 XOR B_2) */
|
||||||
|
aes_encrypt(aes, &aad_buf[AES_BLOCK_SIZE], x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_ccm_auth(void *aes, const u8 *data, size_t len, u8 *x)
|
||||||
|
{
|
||||||
|
size_t last = len % AES_BLOCK_SIZE;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < len / AES_BLOCK_SIZE; i++) {
|
||||||
|
/* X_i+1 = E(K, X_i XOR B_i) */
|
||||||
|
xor_aes_block(x, data);
|
||||||
|
data += AES_BLOCK_SIZE;
|
||||||
|
aes_encrypt(aes, x, x);
|
||||||
|
}
|
||||||
|
if (last) {
|
||||||
|
/* XOR zero-padded last block */
|
||||||
|
for (i = 0; i < last; i++)
|
||||||
|
x[i] ^= *data++;
|
||||||
|
aes_encrypt(aes, x, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_ccm_encr_start(size_t L, const u8 *nonce, u8 *a)
|
||||||
|
{
|
||||||
|
/* A_i = Flags | Nonce N | Counter i */
|
||||||
|
a[0] = L - 1; /* Flags = L' */
|
||||||
|
os_memcpy(&a[1], nonce, 15 - L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_ccm_encr(void *aes, size_t L, const u8 *in, size_t len, u8 *out,
|
||||||
|
u8 *a)
|
||||||
|
{
|
||||||
|
size_t last = len % AES_BLOCK_SIZE;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
/* crypt = msg XOR (S_1 | S_2 | ... | S_n) */
|
||||||
|
for (i = 1; i <= len / AES_BLOCK_SIZE; i++) {
|
||||||
|
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
|
||||||
|
/* S_i = E(K, A_i) */
|
||||||
|
aes_encrypt(aes, a, out);
|
||||||
|
xor_aes_block(out, in);
|
||||||
|
out += AES_BLOCK_SIZE;
|
||||||
|
in += AES_BLOCK_SIZE;
|
||||||
|
}
|
||||||
|
if (last) {
|
||||||
|
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
|
||||||
|
aes_encrypt(aes, a, out);
|
||||||
|
/* XOR zero-padded last block */
|
||||||
|
for (i = 0; i < last; i++)
|
||||||
|
*out++ ^= *in++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_ccm_encr_auth(void *aes, size_t M, u8 *x, u8 *a, u8 *auth)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
u8 tmp[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", x, M);
|
||||||
|
/* U = T XOR S_0; S_0 = E(K, A_0) */
|
||||||
|
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0);
|
||||||
|
aes_encrypt(aes, a, tmp);
|
||||||
|
for (i = 0; i < M; i++)
|
||||||
|
auth[i] = x[i] ^ tmp[i];
|
||||||
|
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_ccm_decr_auth(void *aes, size_t M, u8 *a, const u8 *auth, u8 *t)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
u8 tmp[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M);
|
||||||
|
/* U = T XOR S_0; S_0 = E(K, A_0) */
|
||||||
|
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0);
|
||||||
|
aes_encrypt(aes, a, tmp);
|
||||||
|
for (i = 0; i < M; i++)
|
||||||
|
t[i] = auth[i] ^ tmp[i];
|
||||||
|
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", t, M);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* AES-CCM with fixed L=2 and aad_len <= 30 assumption */
|
||||||
|
int aes_ccm_ae(const u8 *key, size_t key_len, const u8 *nonce,
|
||||||
|
size_t M, const u8 *plain, size_t plain_len,
|
||||||
|
const u8 *aad, size_t aad_len, u8 *crypt, u8 *auth)
|
||||||
|
{
|
||||||
|
const size_t L = 2;
|
||||||
|
void *aes;
|
||||||
|
u8 x[AES_BLOCK_SIZE], a[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
if (aad_len > 30 || M > AES_BLOCK_SIZE)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
aes = aes_encrypt_init(key, key_len);
|
||||||
|
if (aes == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
aes_ccm_auth_start(aes, M, L, nonce, aad, aad_len, plain_len, x);
|
||||||
|
aes_ccm_auth(aes, plain, plain_len, x);
|
||||||
|
|
||||||
|
/* Encryption */
|
||||||
|
aes_ccm_encr_start(L, nonce, a);
|
||||||
|
aes_ccm_encr(aes, L, plain, plain_len, crypt, a);
|
||||||
|
aes_ccm_encr_auth(aes, M, x, a, auth);
|
||||||
|
|
||||||
|
aes_encrypt_deinit(aes);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* AES-CCM with fixed L=2 and aad_len <= 30 assumption */
|
||||||
|
int aes_ccm_ad(const u8 *key, size_t key_len, const u8 *nonce,
|
||||||
|
size_t M, const u8 *crypt, size_t crypt_len,
|
||||||
|
const u8 *aad, size_t aad_len, const u8 *auth, u8 *plain)
|
||||||
|
{
|
||||||
|
const size_t L = 2;
|
||||||
|
void *aes;
|
||||||
|
u8 x[AES_BLOCK_SIZE], a[AES_BLOCK_SIZE];
|
||||||
|
u8 t[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
if (aad_len > 30 || M > AES_BLOCK_SIZE)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
aes = aes_encrypt_init(key, key_len);
|
||||||
|
if (aes == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Decryption */
|
||||||
|
aes_ccm_encr_start(L, nonce, a);
|
||||||
|
aes_ccm_decr_auth(aes, M, a, auth, t);
|
||||||
|
|
||||||
|
/* plaintext = msg XOR (S_1 | S_2 | ... | S_n) */
|
||||||
|
aes_ccm_encr(aes, L, crypt, crypt_len, plain, a);
|
||||||
|
|
||||||
|
aes_ccm_auth_start(aes, M, L, nonce, aad, aad_len, crypt_len, x);
|
||||||
|
aes_ccm_auth(aes, plain, crypt_len, x);
|
||||||
|
|
||||||
|
aes_encrypt_deinit(aes);
|
||||||
|
|
||||||
|
if (os_memcmp_const(x, t, M) != 0) {
|
||||||
|
wpa_printf(_MSG_EXCESSIVE_, "CCM: Auth mismatch");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
70
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-ctr.c
Normal file
70
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-ctr.c
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* AES-128/192/256 CTR
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
#include "aes_wrap.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes_ctr_encrypt - AES-128/192/256 CTR mode encryption
|
||||||
|
* @key: Key for encryption (key_len bytes)
|
||||||
|
* @key_len: Length of the key (16, 24, or 32 bytes)
|
||||||
|
* @nonce: Nonce for counter mode (16 bytes)
|
||||||
|
* @data: Data to encrypt in-place
|
||||||
|
* @data_len: Length of data in bytes
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*/
|
||||||
|
int aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
|
||||||
|
u8 *data, size_t data_len)
|
||||||
|
{
|
||||||
|
void *ctx;
|
||||||
|
size_t j, len, left = data_len;
|
||||||
|
int i;
|
||||||
|
u8 *pos = data;
|
||||||
|
u8 counter[AES_BLOCK_SIZE], buf[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
ctx = aes_encrypt_init(key, key_len);
|
||||||
|
if (ctx == NULL)
|
||||||
|
return -1;
|
||||||
|
os_memcpy(counter, nonce, AES_BLOCK_SIZE);
|
||||||
|
|
||||||
|
while (left > 0) {
|
||||||
|
aes_encrypt(ctx, counter, buf);
|
||||||
|
|
||||||
|
len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE;
|
||||||
|
for (j = 0; j < len; j++)
|
||||||
|
pos[j] ^= buf[j];
|
||||||
|
pos += len;
|
||||||
|
left -= len;
|
||||||
|
|
||||||
|
for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) {
|
||||||
|
counter[i]++;
|
||||||
|
if (counter[i])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aes_encrypt_deinit(ctx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes_128_ctr_encrypt - AES-128 CTR mode encryption
|
||||||
|
* @key: Key for encryption (key_len bytes)
|
||||||
|
* @nonce: Nonce for counter mode (16 bytes)
|
||||||
|
* @data: Data to encrypt in-place
|
||||||
|
* @data_len: Length of data in bytes
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*/
|
||||||
|
int aes_128_ctr_encrypt(const u8 *key, const u8 *nonce,
|
||||||
|
u8 *data, size_t data_len)
|
||||||
|
{
|
||||||
|
return aes_ctr_encrypt(key, 16, nonce, data, data_len);
|
||||||
|
}
|
||||||
326
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-gcm.c
Normal file
326
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-gcm.c
Normal file
@@ -0,0 +1,326 @@
|
|||||||
|
/*
|
||||||
|
* Galois/Counter Mode (GCM) and GMAC with AES
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
#include "aes_wrap.h"
|
||||||
|
|
||||||
|
static void inc32(u8 *block)
|
||||||
|
{
|
||||||
|
u32 val;
|
||||||
|
val = WPA_GET_BE32(block + AES_BLOCK_SIZE - 4);
|
||||||
|
val++;
|
||||||
|
WPA_PUT_BE32(block + AES_BLOCK_SIZE - 4, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void xor_block(u8 *dst, const u8 *src)
|
||||||
|
{
|
||||||
|
u32 *d = (u32 *) dst;
|
||||||
|
u32 *s = (u32 *) src;
|
||||||
|
*d++ ^= *s++;
|
||||||
|
*d++ ^= *s++;
|
||||||
|
*d++ ^= *s++;
|
||||||
|
*d++ ^= *s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void shift_right_block(u8 *v)
|
||||||
|
{
|
||||||
|
u32 val;
|
||||||
|
|
||||||
|
val = WPA_GET_BE32(v + 12);
|
||||||
|
val >>= 1;
|
||||||
|
if (v[11] & 0x01)
|
||||||
|
val |= 0x80000000;
|
||||||
|
WPA_PUT_BE32(v + 12, val);
|
||||||
|
|
||||||
|
val = WPA_GET_BE32(v + 8);
|
||||||
|
val >>= 1;
|
||||||
|
if (v[7] & 0x01)
|
||||||
|
val |= 0x80000000;
|
||||||
|
WPA_PUT_BE32(v + 8, val);
|
||||||
|
|
||||||
|
val = WPA_GET_BE32(v + 4);
|
||||||
|
val >>= 1;
|
||||||
|
if (v[3] & 0x01)
|
||||||
|
val |= 0x80000000;
|
||||||
|
WPA_PUT_BE32(v + 4, val);
|
||||||
|
|
||||||
|
val = WPA_GET_BE32(v);
|
||||||
|
val >>= 1;
|
||||||
|
WPA_PUT_BE32(v, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Multiplication in GF(2^128) */
|
||||||
|
static void gf_mult(const u8 *x, const u8 *y, u8 *z)
|
||||||
|
{
|
||||||
|
u8 v[16];
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
os_memset(z, 0, 16); /* Z_0 = 0^128 */
|
||||||
|
os_memcpy(v, y, 16); /* V_0 = Y */
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
for (j = 0; j < 8; j++) {
|
||||||
|
if (x[i] & BIT(7 - j)) {
|
||||||
|
/* Z_(i + 1) = Z_i XOR V_i */
|
||||||
|
xor_block(z, v);
|
||||||
|
} else {
|
||||||
|
/* Z_(i + 1) = Z_i */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v[15] & 0x01) {
|
||||||
|
/* V_(i + 1) = (V_i >> 1) XOR R */
|
||||||
|
shift_right_block(v);
|
||||||
|
/* R = 11100001 || 0^120 */
|
||||||
|
v[0] ^= 0xe1;
|
||||||
|
} else {
|
||||||
|
/* V_(i + 1) = V_i >> 1 */
|
||||||
|
shift_right_block(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ghash_start(u8 *y)
|
||||||
|
{
|
||||||
|
/* Y_0 = 0^128 */
|
||||||
|
os_memset(y, 0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ghash(const u8 *h, const u8 *x, size_t xlen, u8 *y)
|
||||||
|
{
|
||||||
|
size_t m, i;
|
||||||
|
const u8 *xpos = x;
|
||||||
|
u8 tmp[16];
|
||||||
|
|
||||||
|
m = xlen / 16;
|
||||||
|
|
||||||
|
for (i = 0; i < m; i++) {
|
||||||
|
/* Y_i = (Y^(i-1) XOR X_i) dot H */
|
||||||
|
xor_block(y, xpos);
|
||||||
|
xpos += 16;
|
||||||
|
|
||||||
|
/* dot operation:
|
||||||
|
* multiplication operation for binary Galois (finite) field of
|
||||||
|
* 2^128 elements */
|
||||||
|
gf_mult(y, h, tmp);
|
||||||
|
os_memcpy(y, tmp, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x + xlen > xpos) {
|
||||||
|
/* Add zero padded last block */
|
||||||
|
size_t last = x + xlen - xpos;
|
||||||
|
os_memcpy(tmp, xpos, last);
|
||||||
|
os_memset(tmp + last, 0, sizeof(tmp) - last);
|
||||||
|
|
||||||
|
/* Y_i = (Y^(i-1) XOR X_i) dot H */
|
||||||
|
xor_block(y, tmp);
|
||||||
|
|
||||||
|
/* dot operation:
|
||||||
|
* multiplication operation for binary Galois (finite) field of
|
||||||
|
* 2^128 elements */
|
||||||
|
gf_mult(y, h, tmp);
|
||||||
|
os_memcpy(y, tmp, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return Y_m */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_gctr(void *aes, const u8 *icb, const u8 *x, size_t xlen, u8 *y)
|
||||||
|
{
|
||||||
|
size_t i, n, last;
|
||||||
|
u8 cb[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE];
|
||||||
|
const u8 *xpos = x;
|
||||||
|
u8 *ypos = y;
|
||||||
|
|
||||||
|
if (xlen == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
n = xlen / 16;
|
||||||
|
|
||||||
|
os_memcpy(cb, icb, AES_BLOCK_SIZE);
|
||||||
|
/* Full blocks */
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
aes_encrypt(aes, cb, ypos);
|
||||||
|
xor_block(ypos, xpos);
|
||||||
|
xpos += AES_BLOCK_SIZE;
|
||||||
|
ypos += AES_BLOCK_SIZE;
|
||||||
|
inc32(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
last = x + xlen - xpos;
|
||||||
|
if (last) {
|
||||||
|
/* Last, partial block */
|
||||||
|
aes_encrypt(aes, cb, tmp);
|
||||||
|
for (i = 0; i < last; i++)
|
||||||
|
*ypos++ = *xpos++ ^ tmp[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void * aes_gcm_init_hash_subkey(const u8 *key, size_t key_len, u8 *H)
|
||||||
|
{
|
||||||
|
void *aes;
|
||||||
|
|
||||||
|
aes = aes_encrypt_init(key, key_len);
|
||||||
|
if (aes == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Generate hash subkey H = AES_K(0^128) */
|
||||||
|
os_memset(H, 0, AES_BLOCK_SIZE);
|
||||||
|
aes_encrypt(aes, H, H);
|
||||||
|
wpa_hexdump_key(_MSG_EXCESSIVE_, "Hash subkey H for GHASH",
|
||||||
|
H, AES_BLOCK_SIZE);
|
||||||
|
return aes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_gcm_prepare_j0(const u8 *iv, size_t iv_len, const u8 *H, u8 *J0)
|
||||||
|
{
|
||||||
|
u8 len_buf[16];
|
||||||
|
|
||||||
|
if (iv_len == 12) {
|
||||||
|
/* Prepare block J_0 = IV || 0^31 || 1 [len(IV) = 96] */
|
||||||
|
os_memcpy(J0, iv, iv_len);
|
||||||
|
os_memset(J0 + iv_len, 0, AES_BLOCK_SIZE - iv_len);
|
||||||
|
J0[AES_BLOCK_SIZE - 1] = 0x01;
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* s = 128 * ceil(len(IV)/128) - len(IV)
|
||||||
|
* J_0 = GHASH_H(IV || 0^(s+64) || [len(IV)]_64)
|
||||||
|
*/
|
||||||
|
ghash_start(J0);
|
||||||
|
ghash(H, iv, iv_len, J0);
|
||||||
|
WPA_PUT_BE64(len_buf, 0);
|
||||||
|
WPA_PUT_BE64(len_buf + 8, iv_len * 8);
|
||||||
|
ghash(H, len_buf, sizeof(len_buf), J0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_gcm_gctr(void *aes, const u8 *J0, const u8 *in, size_t len,
|
||||||
|
u8 *out)
|
||||||
|
{
|
||||||
|
u8 J0inc[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
os_memcpy(J0inc, J0, AES_BLOCK_SIZE);
|
||||||
|
inc32(J0inc);
|
||||||
|
aes_gctr(aes, J0inc, in, len, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void aes_gcm_ghash(const u8 *H, const u8 *aad, size_t aad_len,
|
||||||
|
const u8 *crypt, size_t crypt_len, u8 *S)
|
||||||
|
{
|
||||||
|
u8 len_buf[16];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* u = 128 * ceil[len(C)/128] - len(C)
|
||||||
|
* v = 128 * ceil[len(A)/128] - len(A)
|
||||||
|
* S = GHASH_H(A || 0^v || C || 0^u || [len(A)]64 || [len(C)]64)
|
||||||
|
* (i.e., zero padded to block size A || C and lengths of each in bits)
|
||||||
|
*/
|
||||||
|
ghash_start(S);
|
||||||
|
ghash(H, aad, aad_len, S);
|
||||||
|
ghash(H, crypt, crypt_len, S);
|
||||||
|
WPA_PUT_BE64(len_buf, aad_len * 8);
|
||||||
|
WPA_PUT_BE64(len_buf + 8, crypt_len * 8);
|
||||||
|
ghash(H, len_buf, sizeof(len_buf), S);
|
||||||
|
|
||||||
|
wpa_hexdump_key(_MSG_EXCESSIVE_, "S = GHASH_H(...)", S, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes_gcm_ae - GCM-AE_K(IV, P, A)
|
||||||
|
*/
|
||||||
|
int aes_gcm_ae(const u8 *key, size_t key_len, const u8 *iv, size_t iv_len,
|
||||||
|
const u8 *plain, size_t plain_len,
|
||||||
|
const u8 *aad, size_t aad_len, u8 *crypt, u8 *tag)
|
||||||
|
{
|
||||||
|
u8 H[AES_BLOCK_SIZE];
|
||||||
|
u8 J0[AES_BLOCK_SIZE];
|
||||||
|
u8 S[16];
|
||||||
|
void *aes;
|
||||||
|
|
||||||
|
aes = aes_gcm_init_hash_subkey(key, key_len, H);
|
||||||
|
if (aes == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
aes_gcm_prepare_j0(iv, iv_len, H, J0);
|
||||||
|
|
||||||
|
/* C = GCTR_K(inc_32(J_0), P) */
|
||||||
|
aes_gcm_gctr(aes, J0, plain, plain_len, crypt);
|
||||||
|
|
||||||
|
aes_gcm_ghash(H, aad, aad_len, crypt, plain_len, S);
|
||||||
|
|
||||||
|
/* T = MSB_t(GCTR_K(J_0, S)) */
|
||||||
|
aes_gctr(aes, J0, S, sizeof(S), tag);
|
||||||
|
|
||||||
|
/* Return (C, T) */
|
||||||
|
|
||||||
|
aes_encrypt_deinit(aes);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes_gcm_ad - GCM-AD_K(IV, C, A, T)
|
||||||
|
*/
|
||||||
|
int aes_gcm_ad(const u8 *key, size_t key_len, const u8 *iv, size_t iv_len,
|
||||||
|
const u8 *crypt, size_t crypt_len,
|
||||||
|
const u8 *aad, size_t aad_len, const u8 *tag, u8 *plain)
|
||||||
|
{
|
||||||
|
u8 H[AES_BLOCK_SIZE];
|
||||||
|
u8 J0[AES_BLOCK_SIZE];
|
||||||
|
u8 S[16], T[16];
|
||||||
|
void *aes;
|
||||||
|
|
||||||
|
aes = aes_gcm_init_hash_subkey(key, key_len, H);
|
||||||
|
if (aes == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
aes_gcm_prepare_j0(iv, iv_len, H, J0);
|
||||||
|
|
||||||
|
/* P = GCTR_K(inc_32(J_0), C) */
|
||||||
|
aes_gcm_gctr(aes, J0, crypt, crypt_len, plain);
|
||||||
|
|
||||||
|
aes_gcm_ghash(H, aad, aad_len, crypt, crypt_len, S);
|
||||||
|
|
||||||
|
/* T' = MSB_t(GCTR_K(J_0, S)) */
|
||||||
|
aes_gctr(aes, J0, S, sizeof(S), T);
|
||||||
|
|
||||||
|
aes_encrypt_deinit(aes);
|
||||||
|
|
||||||
|
if (os_memcmp_const(tag, T, 16) != 0) {
|
||||||
|
wpa_printf(_MSG_EXCESSIVE_, "GCM: Tag mismatch");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int aes_gmac(const u8 *key, size_t key_len, const u8 *iv, size_t iv_len,
|
||||||
|
const u8 *aad, size_t aad_len, u8 *tag)
|
||||||
|
{
|
||||||
|
return aes_gcm_ae(key, key_len, iv, iv_len, NULL, 0, aad, aad_len, NULL,
|
||||||
|
tag);
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* AES (Rijndael) cipher - encrypt
|
||||||
|
*
|
||||||
|
* Modifications to public domain implementation:
|
||||||
|
* - cleanup
|
||||||
|
* - use C pre-processor to make it easier to change S table access
|
||||||
|
* - added option (AES_SMALL_TABLES) for reducing code size by about 8 kB at
|
||||||
|
* cost of reduced throughput (quite small difference on Pentium 4,
|
||||||
|
* 10-25% when using -O1 or -O2 optimization)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes_i.h"
|
||||||
|
|
||||||
|
static void rijndaelEncrypt(const u32 rk[], int Nr, const u8 pt[16], u8 ct[16])
|
||||||
|
{
|
||||||
|
u32 s0, s1, s2, s3, t0, t1, t2, t3;
|
||||||
|
#ifndef FULL_UNROLL
|
||||||
|
int r;
|
||||||
|
#endif /* ?FULL_UNROLL */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* map byte array block to cipher state
|
||||||
|
* and add initial round key:
|
||||||
|
*/
|
||||||
|
s0 = GETU32(pt ) ^ rk[0];
|
||||||
|
s1 = GETU32(pt + 4) ^ rk[1];
|
||||||
|
s2 = GETU32(pt + 8) ^ rk[2];
|
||||||
|
s3 = GETU32(pt + 12) ^ rk[3];
|
||||||
|
|
||||||
|
#define ROUND(i,d,s) \
|
||||||
|
d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
|
||||||
|
d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
|
||||||
|
d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
|
||||||
|
d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
|
||||||
|
|
||||||
|
#ifdef FULL_UNROLL
|
||||||
|
|
||||||
|
ROUND(1,t,s);
|
||||||
|
ROUND(2,s,t);
|
||||||
|
ROUND(3,t,s);
|
||||||
|
ROUND(4,s,t);
|
||||||
|
ROUND(5,t,s);
|
||||||
|
ROUND(6,s,t);
|
||||||
|
ROUND(7,t,s);
|
||||||
|
ROUND(8,s,t);
|
||||||
|
ROUND(9,t,s);
|
||||||
|
if (Nr > 10) {
|
||||||
|
ROUND(10,s,t);
|
||||||
|
ROUND(11,t,s);
|
||||||
|
if (Nr > 12) {
|
||||||
|
ROUND(12,s,t);
|
||||||
|
ROUND(13,t,s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rk += Nr << 2;
|
||||||
|
|
||||||
|
#else /* !FULL_UNROLL */
|
||||||
|
|
||||||
|
/* Nr - 1 full rounds: */
|
||||||
|
r = Nr >> 1;
|
||||||
|
for (;;) {
|
||||||
|
ROUND(1,t,s);
|
||||||
|
rk += 8;
|
||||||
|
if (--r == 0)
|
||||||
|
break;
|
||||||
|
ROUND(0,s,t);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ?FULL_UNROLL */
|
||||||
|
|
||||||
|
#undef ROUND
|
||||||
|
|
||||||
|
/*
|
||||||
|
* apply last round and
|
||||||
|
* map cipher state to byte array block:
|
||||||
|
*/
|
||||||
|
s0 = TE41(t0) ^ TE42(t1) ^ TE43(t2) ^ TE44(t3) ^ rk[0];
|
||||||
|
PUTU32(ct , s0);
|
||||||
|
s1 = TE41(t1) ^ TE42(t2) ^ TE43(t3) ^ TE44(t0) ^ rk[1];
|
||||||
|
PUTU32(ct + 4, s1);
|
||||||
|
s2 = TE41(t2) ^ TE42(t3) ^ TE43(t0) ^ TE44(t1) ^ rk[2];
|
||||||
|
PUTU32(ct + 8, s2);
|
||||||
|
s3 = TE41(t3) ^ TE42(t0) ^ TE43(t1) ^ TE44(t2) ^ rk[3];
|
||||||
|
PUTU32(ct + 12, s3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void * aes_encrypt_init(const u8 *key, size_t len)
|
||||||
|
{
|
||||||
|
u32 *rk;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (TEST_FAIL())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
rk = os_malloc(AES_PRIV_SIZE);
|
||||||
|
if (rk == NULL)
|
||||||
|
return NULL;
|
||||||
|
res = rijndaelKeySetupEnc(rk, key, len * 8);
|
||||||
|
if (res < 0) {
|
||||||
|
rtw_mfree(rk, AES_PRIV_SIZE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
rk[AES_PRIV_NR_POS] = res;
|
||||||
|
return rk;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt)
|
||||||
|
{
|
||||||
|
u32 *rk = ctx;
|
||||||
|
rijndaelEncrypt(ctx, rk[AES_PRIV_NR_POS], plain, crypt);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void aes_encrypt_deinit(void *ctx)
|
||||||
|
{
|
||||||
|
os_memset(ctx, 0, AES_PRIV_SIZE);
|
||||||
|
rtw_mfree(ctx, AES_PRIV_SIZE);
|
||||||
|
}
|
||||||
@@ -0,0 +1,843 @@
|
|||||||
|
/*
|
||||||
|
* AES (Rijndael) cipher
|
||||||
|
*
|
||||||
|
* Modifications to public domain implementation:
|
||||||
|
* - cleanup
|
||||||
|
* - use C pre-processor to make it easier to change S table access
|
||||||
|
* - added option (AES_SMALL_TABLES) for reducing code size by about 8 kB at
|
||||||
|
* cost of reduced throughput (quite small difference on Pentium 4,
|
||||||
|
* 10-25% when using -O1 or -O2 optimization)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes_i.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rijndael-alg-fst.c
|
||||||
|
*
|
||||||
|
* @version 3.0 (December 2000)
|
||||||
|
*
|
||||||
|
* Optimised ANSI C code for the Rijndael cipher (now AES)
|
||||||
|
*
|
||||||
|
* @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
|
||||||
|
* @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
|
||||||
|
* @author Paulo Barreto <paulo.barreto@terra.com.br>
|
||||||
|
*
|
||||||
|
* This code is hereby placed in the public domain.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
|
||||||
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Te0[x] = S [x].[02, 01, 01, 03];
|
||||||
|
Te1[x] = S [x].[03, 02, 01, 01];
|
||||||
|
Te2[x] = S [x].[01, 03, 02, 01];
|
||||||
|
Te3[x] = S [x].[01, 01, 03, 02];
|
||||||
|
Te4[x] = S [x].[01, 01, 01, 01];
|
||||||
|
|
||||||
|
Td0[x] = Si[x].[0e, 09, 0d, 0b];
|
||||||
|
Td1[x] = Si[x].[0b, 0e, 09, 0d];
|
||||||
|
Td2[x] = Si[x].[0d, 0b, 0e, 09];
|
||||||
|
Td3[x] = Si[x].[09, 0d, 0b, 0e];
|
||||||
|
Td4[x] = Si[x].[01, 01, 01, 01];
|
||||||
|
*/
|
||||||
|
|
||||||
|
const u32 Te0[256] = {
|
||||||
|
0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
|
||||||
|
0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
|
||||||
|
0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
|
||||||
|
0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
|
||||||
|
0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
|
||||||
|
0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
|
||||||
|
0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
|
||||||
|
0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
|
||||||
|
0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
|
||||||
|
0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
|
||||||
|
0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
|
||||||
|
0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
|
||||||
|
0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
|
||||||
|
0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
|
||||||
|
0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
|
||||||
|
0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
|
||||||
|
0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
|
||||||
|
0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
|
||||||
|
0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
|
||||||
|
0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
|
||||||
|
0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
|
||||||
|
0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
|
||||||
|
0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
|
||||||
|
0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
|
||||||
|
0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
|
||||||
|
0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
|
||||||
|
0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
|
||||||
|
0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
|
||||||
|
0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
|
||||||
|
0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
|
||||||
|
0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
|
||||||
|
0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
|
||||||
|
0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
|
||||||
|
0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
|
||||||
|
0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
|
||||||
|
0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
|
||||||
|
0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
|
||||||
|
0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
|
||||||
|
0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
|
||||||
|
0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
|
||||||
|
0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
|
||||||
|
0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
|
||||||
|
0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
|
||||||
|
0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
|
||||||
|
0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
|
||||||
|
0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
|
||||||
|
0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
|
||||||
|
0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
|
||||||
|
0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
|
||||||
|
0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
|
||||||
|
0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
|
||||||
|
0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
|
||||||
|
0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
|
||||||
|
0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
|
||||||
|
0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
|
||||||
|
0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
|
||||||
|
0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
|
||||||
|
0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
|
||||||
|
0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
|
||||||
|
0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
|
||||||
|
0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
|
||||||
|
0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
|
||||||
|
0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
|
||||||
|
0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
|
||||||
|
};
|
||||||
|
#ifndef AES_SMALL_TABLES
|
||||||
|
const u32 Te1[256] = {
|
||||||
|
0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
|
||||||
|
0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
|
||||||
|
0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
|
||||||
|
0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
|
||||||
|
0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
|
||||||
|
0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
|
||||||
|
0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
|
||||||
|
0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
|
||||||
|
0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
|
||||||
|
0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
|
||||||
|
0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
|
||||||
|
0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
|
||||||
|
0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
|
||||||
|
0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
|
||||||
|
0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
|
||||||
|
0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
|
||||||
|
0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
|
||||||
|
0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
|
||||||
|
0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
|
||||||
|
0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
|
||||||
|
0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
|
||||||
|
0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
|
||||||
|
0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
|
||||||
|
0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
|
||||||
|
0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
|
||||||
|
0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
|
||||||
|
0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
|
||||||
|
0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
|
||||||
|
0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
|
||||||
|
0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
|
||||||
|
0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
|
||||||
|
0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
|
||||||
|
0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
|
||||||
|
0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
|
||||||
|
0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
|
||||||
|
0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
|
||||||
|
0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
|
||||||
|
0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
|
||||||
|
0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
|
||||||
|
0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
|
||||||
|
0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
|
||||||
|
0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
|
||||||
|
0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
|
||||||
|
0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
|
||||||
|
0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
|
||||||
|
0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
|
||||||
|
0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
|
||||||
|
0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
|
||||||
|
0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
|
||||||
|
0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
|
||||||
|
0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
|
||||||
|
0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
|
||||||
|
0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
|
||||||
|
0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
|
||||||
|
0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
|
||||||
|
0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
|
||||||
|
0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
|
||||||
|
0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
|
||||||
|
0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
|
||||||
|
0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
|
||||||
|
0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
|
||||||
|
0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
|
||||||
|
0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
|
||||||
|
0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
|
||||||
|
};
|
||||||
|
const u32 Te2[256] = {
|
||||||
|
0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
|
||||||
|
0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
|
||||||
|
0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
|
||||||
|
0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
|
||||||
|
0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
|
||||||
|
0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
|
||||||
|
0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
|
||||||
|
0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
|
||||||
|
0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
|
||||||
|
0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
|
||||||
|
0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
|
||||||
|
0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
|
||||||
|
0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
|
||||||
|
0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
|
||||||
|
0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
|
||||||
|
0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
|
||||||
|
0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
|
||||||
|
0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
|
||||||
|
0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
|
||||||
|
0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
|
||||||
|
0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
|
||||||
|
0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
|
||||||
|
0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
|
||||||
|
0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
|
||||||
|
0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
|
||||||
|
0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
|
||||||
|
0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
|
||||||
|
0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
|
||||||
|
0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
|
||||||
|
0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
|
||||||
|
0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
|
||||||
|
0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
|
||||||
|
0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
|
||||||
|
0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
|
||||||
|
0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
|
||||||
|
0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
|
||||||
|
0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
|
||||||
|
0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
|
||||||
|
0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
|
||||||
|
0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
|
||||||
|
0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
|
||||||
|
0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
|
||||||
|
0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
|
||||||
|
0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
|
||||||
|
0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
|
||||||
|
0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
|
||||||
|
0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
|
||||||
|
0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
|
||||||
|
0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
|
||||||
|
0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
|
||||||
|
0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
|
||||||
|
0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
|
||||||
|
0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
|
||||||
|
0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
|
||||||
|
0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
|
||||||
|
0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
|
||||||
|
0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
|
||||||
|
0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
|
||||||
|
0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
|
||||||
|
0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
|
||||||
|
0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
|
||||||
|
0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
|
||||||
|
0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
|
||||||
|
0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
|
||||||
|
};
|
||||||
|
const u32 Te3[256] = {
|
||||||
|
|
||||||
|
0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
|
||||||
|
0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
|
||||||
|
0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
|
||||||
|
0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
|
||||||
|
0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
|
||||||
|
0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
|
||||||
|
0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
|
||||||
|
0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
|
||||||
|
0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
|
||||||
|
0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
|
||||||
|
0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
|
||||||
|
0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
|
||||||
|
0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
|
||||||
|
0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
|
||||||
|
0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
|
||||||
|
0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
|
||||||
|
0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
|
||||||
|
0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
|
||||||
|
0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
|
||||||
|
0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
|
||||||
|
0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
|
||||||
|
0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
|
||||||
|
0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
|
||||||
|
0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
|
||||||
|
0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
|
||||||
|
0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
|
||||||
|
0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
|
||||||
|
0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
|
||||||
|
0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
|
||||||
|
0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
|
||||||
|
0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
|
||||||
|
0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
|
||||||
|
0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
|
||||||
|
0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
|
||||||
|
0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
|
||||||
|
0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
|
||||||
|
0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
|
||||||
|
0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
|
||||||
|
0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
|
||||||
|
0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
|
||||||
|
0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
|
||||||
|
0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
|
||||||
|
0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
|
||||||
|
0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
|
||||||
|
0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
|
||||||
|
0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
|
||||||
|
0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
|
||||||
|
0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
|
||||||
|
0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
|
||||||
|
0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
|
||||||
|
0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
|
||||||
|
0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
|
||||||
|
0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
|
||||||
|
0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
|
||||||
|
0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
|
||||||
|
0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
|
||||||
|
0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
|
||||||
|
0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
|
||||||
|
0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
|
||||||
|
0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
|
||||||
|
0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
|
||||||
|
0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
|
||||||
|
0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
|
||||||
|
0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
|
||||||
|
};
|
||||||
|
const u32 Te4[256] = {
|
||||||
|
0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
|
||||||
|
0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
|
||||||
|
0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
|
||||||
|
0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
|
||||||
|
0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
|
||||||
|
0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
|
||||||
|
0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
|
||||||
|
0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
|
||||||
|
0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
|
||||||
|
0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
|
||||||
|
0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
|
||||||
|
0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
|
||||||
|
0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
|
||||||
|
0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
|
||||||
|
0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
|
||||||
|
0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
|
||||||
|
0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
|
||||||
|
0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
|
||||||
|
0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
|
||||||
|
0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
|
||||||
|
0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
|
||||||
|
0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
|
||||||
|
0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
|
||||||
|
0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
|
||||||
|
0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
|
||||||
|
0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
|
||||||
|
0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
|
||||||
|
0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
|
||||||
|
0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
|
||||||
|
0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
|
||||||
|
0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
|
||||||
|
0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
|
||||||
|
0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
|
||||||
|
0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
|
||||||
|
0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
|
||||||
|
0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
|
||||||
|
0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
|
||||||
|
0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
|
||||||
|
0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
|
||||||
|
0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
|
||||||
|
0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
|
||||||
|
0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
|
||||||
|
0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
|
||||||
|
0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
|
||||||
|
0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
|
||||||
|
0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
|
||||||
|
0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
|
||||||
|
0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
|
||||||
|
0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
|
||||||
|
0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
|
||||||
|
0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
|
||||||
|
0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
|
||||||
|
0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
|
||||||
|
0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
|
||||||
|
0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
|
||||||
|
0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
|
||||||
|
0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
|
||||||
|
0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
|
||||||
|
0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
|
||||||
|
0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
|
||||||
|
0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
|
||||||
|
0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
|
||||||
|
0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
|
||||||
|
0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
|
||||||
|
};
|
||||||
|
#endif /* AES_SMALL_TABLES */
|
||||||
|
const u32 Td0[256] = {
|
||||||
|
0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
|
||||||
|
0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
|
||||||
|
0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
|
||||||
|
0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
|
||||||
|
0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
|
||||||
|
0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
|
||||||
|
0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
|
||||||
|
0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
|
||||||
|
0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
|
||||||
|
0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
|
||||||
|
0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
|
||||||
|
0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
|
||||||
|
0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
|
||||||
|
0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
|
||||||
|
0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
|
||||||
|
0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
|
||||||
|
0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
|
||||||
|
0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
|
||||||
|
0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
|
||||||
|
0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
|
||||||
|
0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
|
||||||
|
0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
|
||||||
|
0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
|
||||||
|
0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
|
||||||
|
0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
|
||||||
|
0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
|
||||||
|
0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
|
||||||
|
0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
|
||||||
|
0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
|
||||||
|
0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
|
||||||
|
0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
|
||||||
|
0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
|
||||||
|
0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
|
||||||
|
0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
|
||||||
|
0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
|
||||||
|
0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
|
||||||
|
0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
|
||||||
|
0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
|
||||||
|
0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
|
||||||
|
0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
|
||||||
|
0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
|
||||||
|
0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
|
||||||
|
0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
|
||||||
|
0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
|
||||||
|
0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
|
||||||
|
0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
|
||||||
|
0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
|
||||||
|
0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
|
||||||
|
0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
|
||||||
|
0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
|
||||||
|
0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
|
||||||
|
0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
|
||||||
|
0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
|
||||||
|
0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
|
||||||
|
0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
|
||||||
|
0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
|
||||||
|
0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
|
||||||
|
0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
|
||||||
|
0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
|
||||||
|
0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
|
||||||
|
0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
|
||||||
|
0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
|
||||||
|
0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
|
||||||
|
0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
|
||||||
|
};
|
||||||
|
#ifndef AES_SMALL_TABLES
|
||||||
|
const u32 Td1[256] = {
|
||||||
|
0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
|
||||||
|
0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
|
||||||
|
0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
|
||||||
|
0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
|
||||||
|
0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
|
||||||
|
0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
|
||||||
|
0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
|
||||||
|
0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
|
||||||
|
0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
|
||||||
|
0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
|
||||||
|
0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
|
||||||
|
0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
|
||||||
|
0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
|
||||||
|
0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
|
||||||
|
0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
|
||||||
|
0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
|
||||||
|
0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
|
||||||
|
0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
|
||||||
|
0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
|
||||||
|
0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
|
||||||
|
0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
|
||||||
|
0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
|
||||||
|
0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
|
||||||
|
0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
|
||||||
|
0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
|
||||||
|
0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
|
||||||
|
0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
|
||||||
|
0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
|
||||||
|
0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
|
||||||
|
0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
|
||||||
|
0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
|
||||||
|
0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
|
||||||
|
0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
|
||||||
|
0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
|
||||||
|
0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
|
||||||
|
0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
|
||||||
|
0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
|
||||||
|
0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
|
||||||
|
0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
|
||||||
|
0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
|
||||||
|
0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
|
||||||
|
0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
|
||||||
|
0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
|
||||||
|
0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
|
||||||
|
0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
|
||||||
|
0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
|
||||||
|
0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
|
||||||
|
0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
|
||||||
|
0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
|
||||||
|
0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
|
||||||
|
0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
|
||||||
|
0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
|
||||||
|
0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
|
||||||
|
0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
|
||||||
|
0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
|
||||||
|
0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
|
||||||
|
0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
|
||||||
|
0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
|
||||||
|
0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
|
||||||
|
0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
|
||||||
|
0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
|
||||||
|
0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
|
||||||
|
0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
|
||||||
|
0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
|
||||||
|
};
|
||||||
|
const u32 Td2[256] = {
|
||||||
|
0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
|
||||||
|
0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
|
||||||
|
0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
|
||||||
|
0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
|
||||||
|
0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
|
||||||
|
0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
|
||||||
|
0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
|
||||||
|
0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
|
||||||
|
0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
|
||||||
|
0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
|
||||||
|
0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
|
||||||
|
0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
|
||||||
|
0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
|
||||||
|
0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
|
||||||
|
0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
|
||||||
|
0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
|
||||||
|
0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
|
||||||
|
0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
|
||||||
|
0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
|
||||||
|
0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
|
||||||
|
|
||||||
|
0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
|
||||||
|
0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
|
||||||
|
0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
|
||||||
|
0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
|
||||||
|
0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
|
||||||
|
0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
|
||||||
|
0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
|
||||||
|
0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
|
||||||
|
0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
|
||||||
|
0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
|
||||||
|
0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
|
||||||
|
0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
|
||||||
|
0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
|
||||||
|
0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
|
||||||
|
0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
|
||||||
|
0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
|
||||||
|
0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
|
||||||
|
0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
|
||||||
|
0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
|
||||||
|
0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
|
||||||
|
0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
|
||||||
|
0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
|
||||||
|
0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
|
||||||
|
0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
|
||||||
|
0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
|
||||||
|
0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
|
||||||
|
0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
|
||||||
|
0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
|
||||||
|
0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
|
||||||
|
0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
|
||||||
|
0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
|
||||||
|
0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
|
||||||
|
0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
|
||||||
|
0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
|
||||||
|
0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
|
||||||
|
0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
|
||||||
|
0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
|
||||||
|
0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
|
||||||
|
0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
|
||||||
|
0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
|
||||||
|
0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
|
||||||
|
0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
|
||||||
|
0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
|
||||||
|
0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
|
||||||
|
};
|
||||||
|
const u32 Td3[256] = {
|
||||||
|
0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
|
||||||
|
0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
|
||||||
|
0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
|
||||||
|
0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
|
||||||
|
0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
|
||||||
|
0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
|
||||||
|
0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
|
||||||
|
0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
|
||||||
|
0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
|
||||||
|
0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
|
||||||
|
0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
|
||||||
|
0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
|
||||||
|
0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
|
||||||
|
0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
|
||||||
|
0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
|
||||||
|
0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
|
||||||
|
0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
|
||||||
|
0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
|
||||||
|
0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
|
||||||
|
0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
|
||||||
|
0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
|
||||||
|
0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
|
||||||
|
0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
|
||||||
|
0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
|
||||||
|
0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
|
||||||
|
0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
|
||||||
|
0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
|
||||||
|
0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
|
||||||
|
0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
|
||||||
|
0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
|
||||||
|
0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
|
||||||
|
0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
|
||||||
|
0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
|
||||||
|
0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
|
||||||
|
0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
|
||||||
|
0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
|
||||||
|
0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
|
||||||
|
0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
|
||||||
|
0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
|
||||||
|
0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
|
||||||
|
0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
|
||||||
|
0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
|
||||||
|
0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
|
||||||
|
0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
|
||||||
|
0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
|
||||||
|
0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
|
||||||
|
0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
|
||||||
|
0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
|
||||||
|
0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
|
||||||
|
0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
|
||||||
|
0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
|
||||||
|
0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
|
||||||
|
0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
|
||||||
|
0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
|
||||||
|
0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
|
||||||
|
0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
|
||||||
|
0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
|
||||||
|
0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
|
||||||
|
0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
|
||||||
|
0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
|
||||||
|
0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
|
||||||
|
0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
|
||||||
|
0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
|
||||||
|
0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
|
||||||
|
};
|
||||||
|
const u32 Td4[256] = {
|
||||||
|
0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
|
||||||
|
0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
|
||||||
|
0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
|
||||||
|
0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
|
||||||
|
0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
|
||||||
|
0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
|
||||||
|
0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
|
||||||
|
0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
|
||||||
|
0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
|
||||||
|
0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
|
||||||
|
0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
|
||||||
|
0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
|
||||||
|
0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
|
||||||
|
0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
|
||||||
|
0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
|
||||||
|
0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
|
||||||
|
0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
|
||||||
|
0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
|
||||||
|
0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
|
||||||
|
0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
|
||||||
|
0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
|
||||||
|
0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
|
||||||
|
0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
|
||||||
|
0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
|
||||||
|
0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
|
||||||
|
0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
|
||||||
|
0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
|
||||||
|
0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
|
||||||
|
0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
|
||||||
|
0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
|
||||||
|
0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
|
||||||
|
0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
|
||||||
|
0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
|
||||||
|
0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
|
||||||
|
0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
|
||||||
|
0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
|
||||||
|
0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
|
||||||
|
0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
|
||||||
|
0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
|
||||||
|
0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
|
||||||
|
0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
|
||||||
|
0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
|
||||||
|
0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
|
||||||
|
0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
|
||||||
|
0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
|
||||||
|
0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
|
||||||
|
0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
|
||||||
|
0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
|
||||||
|
0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
|
||||||
|
0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
|
||||||
|
0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
|
||||||
|
0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
|
||||||
|
0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
|
||||||
|
0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
|
||||||
|
0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
|
||||||
|
0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
|
||||||
|
0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
|
||||||
|
0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
|
||||||
|
0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
|
||||||
|
0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
|
||||||
|
0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
|
||||||
|
0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
|
||||||
|
0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
|
||||||
|
0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
|
||||||
|
};
|
||||||
|
const u32 rcon[] = {
|
||||||
|
0x01000000, 0x02000000, 0x04000000, 0x08000000,
|
||||||
|
0x10000000, 0x20000000, 0x40000000, 0x80000000,
|
||||||
|
0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
|
||||||
|
};
|
||||||
|
#else /* AES_SMALL_TABLES */
|
||||||
|
const u8 Td4s[256] = {
|
||||||
|
0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U,
|
||||||
|
0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU,
|
||||||
|
0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U,
|
||||||
|
0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU,
|
||||||
|
0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU,
|
||||||
|
0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU,
|
||||||
|
0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U,
|
||||||
|
0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U,
|
||||||
|
0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U,
|
||||||
|
0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U,
|
||||||
|
0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU,
|
||||||
|
0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U,
|
||||||
|
0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU,
|
||||||
|
0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U,
|
||||||
|
0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U,
|
||||||
|
0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU,
|
||||||
|
0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU,
|
||||||
|
0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U,
|
||||||
|
0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U,
|
||||||
|
0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU,
|
||||||
|
0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U,
|
||||||
|
0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU,
|
||||||
|
0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U,
|
||||||
|
0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U,
|
||||||
|
0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U,
|
||||||
|
0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU,
|
||||||
|
0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU,
|
||||||
|
0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU,
|
||||||
|
0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U,
|
||||||
|
0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U,
|
||||||
|
0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U,
|
||||||
|
0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU,
|
||||||
|
};
|
||||||
|
const u8 rcons[] = {
|
||||||
|
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36
|
||||||
|
/* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
|
||||||
|
};
|
||||||
|
#endif /* AES_SMALL_TABLES */
|
||||||
|
/**
|
||||||
|
* Expand the cipher key into the encryption key schedule.
|
||||||
|
*
|
||||||
|
* @return the number of rounds for the given cipher key size.
|
||||||
|
*/
|
||||||
|
int rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
u32 temp;
|
||||||
|
|
||||||
|
rk[0] = GETU32(cipherKey );
|
||||||
|
rk[1] = GETU32(cipherKey + 4);
|
||||||
|
rk[2] = GETU32(cipherKey + 8);
|
||||||
|
rk[3] = GETU32(cipherKey + 12);
|
||||||
|
|
||||||
|
if (keyBits == 128) {
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
temp = rk[3];
|
||||||
|
rk[4] = rk[0] ^ TE421(temp) ^ TE432(temp) ^
|
||||||
|
TE443(temp) ^ TE414(temp) ^ RCON(i);
|
||||||
|
rk[5] = rk[1] ^ rk[4];
|
||||||
|
rk[6] = rk[2] ^ rk[5];
|
||||||
|
rk[7] = rk[3] ^ rk[6];
|
||||||
|
rk += 4;
|
||||||
|
}
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
rk[4] = GETU32(cipherKey + 16);
|
||||||
|
rk[5] = GETU32(cipherKey + 20);
|
||||||
|
|
||||||
|
if (keyBits == 192) {
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
temp = rk[5];
|
||||||
|
rk[6] = rk[0] ^ TE421(temp) ^ TE432(temp) ^
|
||||||
|
TE443(temp) ^ TE414(temp) ^ RCON(i);
|
||||||
|
rk[7] = rk[1] ^ rk[6];
|
||||||
|
rk[8] = rk[2] ^ rk[7];
|
||||||
|
rk[9] = rk[3] ^ rk[8];
|
||||||
|
if (i == 7)
|
||||||
|
return 12;
|
||||||
|
rk[10] = rk[4] ^ rk[9];
|
||||||
|
rk[11] = rk[5] ^ rk[10];
|
||||||
|
rk += 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rk[6] = GETU32(cipherKey + 24);
|
||||||
|
rk[7] = GETU32(cipherKey + 28);
|
||||||
|
|
||||||
|
if (keyBits == 256) {
|
||||||
|
for (i = 0; i < 7; i++) {
|
||||||
|
temp = rk[7];
|
||||||
|
rk[8] = rk[0] ^ TE421(temp) ^ TE432(temp) ^
|
||||||
|
TE443(temp) ^ TE414(temp) ^ RCON(i);
|
||||||
|
rk[9] = rk[1] ^ rk[8];
|
||||||
|
rk[10] = rk[2] ^ rk[9];
|
||||||
|
rk[11] = rk[3] ^ rk[10];
|
||||||
|
if (i == 6)
|
||||||
|
return 14;
|
||||||
|
temp = rk[11];
|
||||||
|
rk[12] = rk[4] ^ TE411(temp) ^ TE422(temp) ^
|
||||||
|
TE433(temp) ^ TE444(temp);
|
||||||
|
rk[13] = rk[5] ^ rk[12];
|
||||||
|
rk[14] = rk[6] ^ rk[13];
|
||||||
|
rk[15] = rk[7] ^ rk[14];
|
||||||
|
rk += 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
172
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-omac1.c
Normal file
172
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-omac1.c
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* One-key CBC MAC (OMAC1) hash with AES
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
#include "aes_wrap.h"
|
||||||
|
|
||||||
|
static void gf_mulx(u8 *pad)
|
||||||
|
{
|
||||||
|
int i, carry;
|
||||||
|
|
||||||
|
carry = pad[0] & 0x80;
|
||||||
|
for (i = 0; i < AES_BLOCK_SIZE - 1; i++)
|
||||||
|
pad[i] = (pad[i] << 1) | (pad[i + 1] >> 7);
|
||||||
|
pad[AES_BLOCK_SIZE - 1] <<= 1;
|
||||||
|
if (carry)
|
||||||
|
pad[AES_BLOCK_SIZE - 1] ^= 0x87;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omac1_aes_vector - One-Key CBC MAC (OMAC1) hash with AES
|
||||||
|
* @key: Key for the hash operation
|
||||||
|
* @key_len: Key length in octets
|
||||||
|
* @num_elem: Number of elements in the data vector
|
||||||
|
* @addr: Pointers to the data areas
|
||||||
|
* @len: Lengths of the data blocks
|
||||||
|
* @mac: Buffer for MAC (128 bits, i.e., 16 bytes)
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*
|
||||||
|
* This is a mode for using block cipher (AES in this case) for authentication.
|
||||||
|
* OMAC1 was standardized with the name CMAC by NIST in a Special Publication
|
||||||
|
* (SP) 800-38B.
|
||||||
|
*/
|
||||||
|
int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem,
|
||||||
|
const u8 *addr[], const size_t *len, u8 *mac)
|
||||||
|
{
|
||||||
|
void *ctx;
|
||||||
|
u8 cbc[AES_BLOCK_SIZE], pad[AES_BLOCK_SIZE];
|
||||||
|
const u8 *pos, *end;
|
||||||
|
size_t i, e, left, total_len;
|
||||||
|
|
||||||
|
if (TEST_FAIL())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ctx = aes_encrypt_init(key, key_len);
|
||||||
|
if (ctx == NULL)
|
||||||
|
return -1;
|
||||||
|
os_memset(cbc, 0, AES_BLOCK_SIZE);
|
||||||
|
|
||||||
|
total_len = 0;
|
||||||
|
for (e = 0; e < num_elem; e++)
|
||||||
|
total_len += len[e];
|
||||||
|
left = total_len;
|
||||||
|
|
||||||
|
e = 0;
|
||||||
|
pos = addr[0];
|
||||||
|
end = pos + len[0];
|
||||||
|
|
||||||
|
while (left >= AES_BLOCK_SIZE) {
|
||||||
|
for (i = 0; i < AES_BLOCK_SIZE; i++) {
|
||||||
|
cbc[i] ^= *pos++;
|
||||||
|
if (pos >= end) {
|
||||||
|
/*
|
||||||
|
* Stop if there are no more bytes to process
|
||||||
|
* since there are no more entries in the array.
|
||||||
|
*/
|
||||||
|
if (i + 1 == AES_BLOCK_SIZE &&
|
||||||
|
left == AES_BLOCK_SIZE)
|
||||||
|
break;
|
||||||
|
e++;
|
||||||
|
pos = addr[e];
|
||||||
|
end = pos + len[e];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (left > AES_BLOCK_SIZE)
|
||||||
|
aes_encrypt(ctx, cbc, cbc);
|
||||||
|
left -= AES_BLOCK_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_memset(pad, 0, AES_BLOCK_SIZE);
|
||||||
|
aes_encrypt(ctx, pad, pad);
|
||||||
|
gf_mulx(pad);
|
||||||
|
|
||||||
|
if (left || total_len == 0) {
|
||||||
|
for (i = 0; i < left; i++) {
|
||||||
|
cbc[i] ^= *pos++;
|
||||||
|
if (pos >= end) {
|
||||||
|
/*
|
||||||
|
* Stop if there are no more bytes to process
|
||||||
|
* since there are no more entries in the array.
|
||||||
|
*/
|
||||||
|
if (i + 1 == left)
|
||||||
|
break;
|
||||||
|
e++;
|
||||||
|
pos = addr[e];
|
||||||
|
end = pos + len[e];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cbc[left] ^= 0x80;
|
||||||
|
gf_mulx(pad);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < AES_BLOCK_SIZE; i++)
|
||||||
|
pad[i] ^= cbc[i];
|
||||||
|
aes_encrypt(ctx, pad, mac);
|
||||||
|
aes_encrypt_deinit(ctx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omac1_aes_128_vector - One-Key CBC MAC (OMAC1) hash with AES-128
|
||||||
|
* @key: 128-bit key for the hash operation
|
||||||
|
* @num_elem: Number of elements in the data vector
|
||||||
|
* @addr: Pointers to the data areas
|
||||||
|
* @len: Lengths of the data blocks
|
||||||
|
* @mac: Buffer for MAC (128 bits, i.e., 16 bytes)
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*
|
||||||
|
* This is a mode for using block cipher (AES in this case) for authentication.
|
||||||
|
* OMAC1 was standardized with the name CMAC by NIST in a Special Publication
|
||||||
|
* (SP) 800-38B.
|
||||||
|
*/
|
||||||
|
int omac1_aes_128_vector(const u8 *key, size_t num_elem,
|
||||||
|
const u8 *addr[], const size_t *len, u8 *mac)
|
||||||
|
{
|
||||||
|
return omac1_aes_vector(key, 16, num_elem, addr, len, mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omac1_aes_128 - One-Key CBC MAC (OMAC1) hash with AES-128 (aka AES-CMAC)
|
||||||
|
* @key: 128-bit key for the hash operation
|
||||||
|
* @data: Data buffer for which a MAC is determined
|
||||||
|
* @data_len: Length of data buffer in bytes
|
||||||
|
* @mac: Buffer for MAC (128 bits, i.e., 16 bytes)
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*
|
||||||
|
* This is a mode for using block cipher (AES in this case) for authentication.
|
||||||
|
* OMAC1 was standardized with the name CMAC by NIST in a Special Publication
|
||||||
|
* (SP) 800-38B.
|
||||||
|
*/
|
||||||
|
int omac1_aes_128(const u8 *key, const u8 *data, size_t data_len, u8 *mac)
|
||||||
|
{
|
||||||
|
return omac1_aes_128_vector(key, 1, &data, &data_len, mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omac1_aes_256 - One-Key CBC MAC (OMAC1) hash with AES-256 (aka AES-CMAC)
|
||||||
|
* @key: 256-bit key for the hash operation
|
||||||
|
* @data: Data buffer for which a MAC is determined
|
||||||
|
* @data_len: Length of data buffer in bytes
|
||||||
|
* @mac: Buffer for MAC (128 bits, i.e., 16 bytes)
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*
|
||||||
|
* This is a mode for using block cipher (AES in this case) for authentication.
|
||||||
|
* OMAC1 was standardized with the name CMAC by NIST in a Special Publication
|
||||||
|
* (SP) 800-38B.
|
||||||
|
*/
|
||||||
|
int omac1_aes_256(const u8 *key, const u8 *data, size_t data_len, u8 *mac)
|
||||||
|
{
|
||||||
|
return omac1_aes_vector(key, 32, 1, &data, &data_len, mac);
|
||||||
|
}
|
||||||
207
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-siv.c
Normal file
207
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes-siv.c
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
* AES SIV (RFC 5297)
|
||||||
|
* Copyright (c) 2013 Cozybit, Inc.
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
#include "aes_wrap.h"
|
||||||
|
#include "aes_siv.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const u8 zero[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
|
||||||
|
static void dbl(u8 *pad)
|
||||||
|
{
|
||||||
|
int i, carry;
|
||||||
|
|
||||||
|
carry = pad[0] & 0x80;
|
||||||
|
for (i = 0; i < AES_BLOCK_SIZE - 1; i++)
|
||||||
|
pad[i] = (pad[i] << 1) | (pad[i + 1] >> 7);
|
||||||
|
pad[AES_BLOCK_SIZE - 1] <<= 1;
|
||||||
|
if (carry)
|
||||||
|
pad[AES_BLOCK_SIZE - 1] ^= 0x87;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void xor(u8 *a, const u8 *b)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < AES_BLOCK_SIZE; i++)
|
||||||
|
*a++ ^= *b++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void xorend(u8 *a, int alen, const u8 *b, int blen)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (alen < blen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < blen; i++)
|
||||||
|
a[alen - blen + i] ^= b[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void pad_block(u8 *pad, const u8 *addr, size_t len)
|
||||||
|
{
|
||||||
|
os_memset(pad, 0, AES_BLOCK_SIZE);
|
||||||
|
os_memcpy(pad, addr, len);
|
||||||
|
|
||||||
|
if (len < AES_BLOCK_SIZE)
|
||||||
|
pad[len] = 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int aes_s2v(const u8 *key, size_t key_len,
|
||||||
|
size_t num_elem, const u8 *addr[], size_t *len, u8 *mac)
|
||||||
|
{
|
||||||
|
u8 tmp[AES_BLOCK_SIZE], tmp2[AES_BLOCK_SIZE];
|
||||||
|
u8 *buf = NULL;
|
||||||
|
int ret;
|
||||||
|
size_t i;
|
||||||
|
const u8 *data[1];
|
||||||
|
size_t data_len[1];
|
||||||
|
|
||||||
|
if (!num_elem) {
|
||||||
|
os_memcpy(tmp, zero, sizeof(zero));
|
||||||
|
tmp[AES_BLOCK_SIZE - 1] = 1;
|
||||||
|
data[0] = tmp;
|
||||||
|
data_len[0] = sizeof(tmp);
|
||||||
|
return omac1_aes_vector(key, key_len, 1, data, data_len, mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
data[0] = zero;
|
||||||
|
data_len[0] = sizeof(zero);
|
||||||
|
ret = omac1_aes_vector(key, key_len, 1, data, data_len, tmp);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
for (i = 0; i < num_elem - 1; i++) {
|
||||||
|
ret = omac1_aes_vector(key, key_len, 1, &addr[i], &len[i],
|
||||||
|
tmp2);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
dbl(tmp);
|
||||||
|
xor(tmp, tmp2);
|
||||||
|
}
|
||||||
|
if (len[i] >= AES_BLOCK_SIZE) {
|
||||||
|
buf = os_memdup(addr[i], len[i]);
|
||||||
|
if (!buf)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
xorend(buf, len[i], tmp, AES_BLOCK_SIZE);
|
||||||
|
data[0] = buf;
|
||||||
|
ret = omac1_aes_vector(key, key_len, 1, data, &len[i], mac);
|
||||||
|
bin_clear_free(buf, len[i]);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbl(tmp);
|
||||||
|
pad_block(tmp2, addr[i], len[i]);
|
||||||
|
xor(tmp, tmp2);
|
||||||
|
|
||||||
|
data[0] = tmp;
|
||||||
|
data_len[0] = sizeof(tmp);
|
||||||
|
return omac1_aes_vector(key, key_len, 1, data, data_len, mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int aes_siv_encrypt(const u8 *key, size_t key_len,
|
||||||
|
const u8 *pw, size_t pwlen,
|
||||||
|
size_t num_elem, const u8 *addr[], const size_t *len,
|
||||||
|
u8 *out)
|
||||||
|
{
|
||||||
|
const u8 *_addr[6];
|
||||||
|
size_t _len[6];
|
||||||
|
const u8 *k1, *k2;
|
||||||
|
u8 v[AES_BLOCK_SIZE];
|
||||||
|
size_t i;
|
||||||
|
u8 *iv, *crypt_pw;
|
||||||
|
|
||||||
|
if (num_elem > ARRAY_SIZE(_addr) - 1 ||
|
||||||
|
(key_len != 32 && key_len != 48 && key_len != 64))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
key_len /= 2;
|
||||||
|
k1 = key;
|
||||||
|
k2 = key + key_len;
|
||||||
|
|
||||||
|
for (i = 0; i < num_elem; i++) {
|
||||||
|
_addr[i] = addr[i];
|
||||||
|
_len[i] = len[i];
|
||||||
|
}
|
||||||
|
_addr[num_elem] = pw;
|
||||||
|
_len[num_elem] = pwlen;
|
||||||
|
|
||||||
|
if (aes_s2v(k1, key_len, num_elem + 1, _addr, _len, v))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
iv = out;
|
||||||
|
crypt_pw = out + AES_BLOCK_SIZE;
|
||||||
|
|
||||||
|
os_memcpy(iv, v, AES_BLOCK_SIZE);
|
||||||
|
os_memcpy(crypt_pw, pw, pwlen);
|
||||||
|
|
||||||
|
/* zero out 63rd and 31st bits of ctr (from right) */
|
||||||
|
v[8] &= 0x7f;
|
||||||
|
v[12] &= 0x7f;
|
||||||
|
return aes_ctr_encrypt(k2, key_len, v, crypt_pw, pwlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int aes_siv_decrypt(const u8 *key, size_t key_len,
|
||||||
|
const u8 *iv_crypt, size_t iv_c_len,
|
||||||
|
size_t num_elem, const u8 *addr[], const size_t *len,
|
||||||
|
u8 *out)
|
||||||
|
{
|
||||||
|
const u8 *_addr[6];
|
||||||
|
size_t _len[6];
|
||||||
|
const u8 *k1, *k2;
|
||||||
|
size_t crypt_len;
|
||||||
|
size_t i;
|
||||||
|
int ret;
|
||||||
|
u8 iv[AES_BLOCK_SIZE];
|
||||||
|
u8 check[AES_BLOCK_SIZE];
|
||||||
|
|
||||||
|
if (iv_c_len < AES_BLOCK_SIZE || num_elem > ARRAY_SIZE(_addr) - 1 ||
|
||||||
|
(key_len != 32 && key_len != 48 && key_len != 64))
|
||||||
|
return -1;
|
||||||
|
crypt_len = iv_c_len - AES_BLOCK_SIZE;
|
||||||
|
key_len /= 2;
|
||||||
|
k1 = key;
|
||||||
|
k2 = key + key_len;
|
||||||
|
|
||||||
|
for (i = 0; i < num_elem; i++) {
|
||||||
|
_addr[i] = addr[i];
|
||||||
|
_len[i] = len[i];
|
||||||
|
}
|
||||||
|
_addr[num_elem] = out;
|
||||||
|
_len[num_elem] = crypt_len;
|
||||||
|
|
||||||
|
os_memcpy(iv, iv_crypt, AES_BLOCK_SIZE);
|
||||||
|
os_memcpy(out, iv_crypt + AES_BLOCK_SIZE, crypt_len);
|
||||||
|
|
||||||
|
iv[8] &= 0x7f;
|
||||||
|
iv[12] &= 0x7f;
|
||||||
|
|
||||||
|
ret = aes_ctr_encrypt(k2, key_len, iv, out, crypt_len);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = aes_s2v(k1, key_len, num_elem + 1, _addr, _len, check);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
if (os_memcmp(check, iv_crypt, AES_BLOCK_SIZE) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
21
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes.h
Normal file
21
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* AES functions
|
||||||
|
* Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AES_H
|
||||||
|
#define AES_H
|
||||||
|
|
||||||
|
#define AES_BLOCK_SIZE 16
|
||||||
|
|
||||||
|
void * aes_encrypt_init(const u8 *key, size_t len);
|
||||||
|
int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
|
||||||
|
void aes_encrypt_deinit(void *ctx);
|
||||||
|
void * aes_decrypt_init(const u8 *key, size_t len);
|
||||||
|
int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
|
||||||
|
void aes_decrypt_deinit(void *ctx);
|
||||||
|
|
||||||
|
#endif /* AES_H */
|
||||||
125
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes_i.h
Normal file
125
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes_i.h
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* AES (Rijndael) cipher
|
||||||
|
* Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AES_I_H
|
||||||
|
#define AES_I_H
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
|
||||||
|
/* #define FULL_UNROLL */
|
||||||
|
#define AES_SMALL_TABLES
|
||||||
|
|
||||||
|
extern const u32 Te0[256];
|
||||||
|
extern const u32 Te1[256];
|
||||||
|
extern const u32 Te2[256];
|
||||||
|
extern const u32 Te3[256];
|
||||||
|
extern const u32 Te4[256];
|
||||||
|
extern const u32 Td0[256];
|
||||||
|
extern const u32 Td1[256];
|
||||||
|
extern const u32 Td2[256];
|
||||||
|
extern const u32 Td3[256];
|
||||||
|
extern const u32 Td4[256];
|
||||||
|
extern const u32 rcon[10];
|
||||||
|
extern const u8 Td4s[256];
|
||||||
|
extern const u8 rcons[10];
|
||||||
|
|
||||||
|
#ifndef AES_SMALL_TABLES
|
||||||
|
|
||||||
|
#define RCON(i) rcon[(i)]
|
||||||
|
|
||||||
|
#define TE0(i) Te0[((i) >> 24) & 0xff]
|
||||||
|
#define TE1(i) Te1[((i) >> 16) & 0xff]
|
||||||
|
#define TE2(i) Te2[((i) >> 8) & 0xff]
|
||||||
|
#define TE3(i) Te3[(i) & 0xff]
|
||||||
|
#define TE41(i) (Te4[((i) >> 24) & 0xff] & 0xff000000)
|
||||||
|
#define TE42(i) (Te4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||||
|
#define TE43(i) (Te4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||||
|
#define TE44(i) (Te4[(i) & 0xff] & 0x000000ff)
|
||||||
|
#define TE421(i) (Te4[((i) >> 16) & 0xff] & 0xff000000)
|
||||||
|
#define TE432(i) (Te4[((i) >> 8) & 0xff] & 0x00ff0000)
|
||||||
|
#define TE443(i) (Te4[(i) & 0xff] & 0x0000ff00)
|
||||||
|
#define TE414(i) (Te4[((i) >> 24) & 0xff] & 0x000000ff)
|
||||||
|
#define TE411(i) (Te4[((i) >> 24) & 0xff] & 0xff000000)
|
||||||
|
#define TE422(i) (Te4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||||
|
#define TE433(i) (Te4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||||
|
#define TE444(i) (Te4[(i) & 0xff] & 0x000000ff)
|
||||||
|
#define TE4(i) (Te4[(i)] & 0x000000ff)
|
||||||
|
|
||||||
|
#define TD0(i) Td0[((i) >> 24) & 0xff]
|
||||||
|
#define TD1(i) Td1[((i) >> 16) & 0xff]
|
||||||
|
#define TD2(i) Td2[((i) >> 8) & 0xff]
|
||||||
|
#define TD3(i) Td3[(i) & 0xff]
|
||||||
|
#define TD41(i) (Td4[((i) >> 24) & 0xff] & 0xff000000)
|
||||||
|
#define TD42(i) (Td4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||||
|
#define TD43(i) (Td4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||||
|
#define TD44(i) (Td4[(i) & 0xff] & 0x000000ff)
|
||||||
|
#define TD0_(i) Td0[(i) & 0xff]
|
||||||
|
#define TD1_(i) Td1[(i) & 0xff]
|
||||||
|
#define TD2_(i) Td2[(i) & 0xff]
|
||||||
|
#define TD3_(i) Td3[(i) & 0xff]
|
||||||
|
|
||||||
|
#else /* AES_SMALL_TABLES */
|
||||||
|
|
||||||
|
#define RCON(i) (rcons[(i)] << 24)
|
||||||
|
|
||||||
|
static inline u32 rotr(u32 val, int bits)
|
||||||
|
{
|
||||||
|
return (val >> bits) | (val << (32 - bits));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TE0(i) Te0[((i) >> 24) & 0xff]
|
||||||
|
#define TE1(i) rotr(Te0[((i) >> 16) & 0xff], 8)
|
||||||
|
#define TE2(i) rotr(Te0[((i) >> 8) & 0xff], 16)
|
||||||
|
#define TE3(i) rotr(Te0[(i) & 0xff], 24)
|
||||||
|
#define TE41(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
|
||||||
|
#define TE42(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||||
|
#define TE43(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||||
|
#define TE44(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
|
||||||
|
#define TE421(i) ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000)
|
||||||
|
#define TE432(i) (Te0[((i) >> 8) & 0xff] & 0x00ff0000)
|
||||||
|
#define TE443(i) (Te0[(i) & 0xff] & 0x0000ff00)
|
||||||
|
#define TE414(i) ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff)
|
||||||
|
#define TE411(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
|
||||||
|
#define TE422(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||||
|
#define TE433(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||||
|
#define TE444(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
|
||||||
|
#define TE4(i) ((Te0[(i)] >> 8) & 0x000000ff)
|
||||||
|
|
||||||
|
#define TD0(i) Td0[((i) >> 24) & 0xff]
|
||||||
|
#define TD1(i) rotr(Td0[((i) >> 16) & 0xff], 8)
|
||||||
|
#define TD2(i) rotr(Td0[((i) >> 8) & 0xff], 16)
|
||||||
|
#define TD3(i) rotr(Td0[(i) & 0xff], 24)
|
||||||
|
#define TD41(i) (Td4s[((i) >> 24) & 0xff] << 24)
|
||||||
|
#define TD42(i) (Td4s[((i) >> 16) & 0xff] << 16)
|
||||||
|
#define TD43(i) (Td4s[((i) >> 8) & 0xff] << 8)
|
||||||
|
#define TD44(i) (Td4s[(i) & 0xff])
|
||||||
|
#define TD0_(i) Td0[(i) & 0xff]
|
||||||
|
#define TD1_(i) rotr(Td0[(i) & 0xff], 8)
|
||||||
|
#define TD2_(i) rotr(Td0[(i) & 0xff], 16)
|
||||||
|
#define TD3_(i) rotr(Td0[(i) & 0xff], 24)
|
||||||
|
|
||||||
|
#endif /* AES_SMALL_TABLES */
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
|
||||||
|
#define GETU32(p) SWAP(*((u32 *)(p)))
|
||||||
|
#define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
|
||||||
|
#else
|
||||||
|
#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
|
||||||
|
((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
|
||||||
|
#define PUTU32(ct, st) { \
|
||||||
|
(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \
|
||||||
|
(ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define AES_PRIV_SIZE (4 * 4 * 15 + 4)
|
||||||
|
#define AES_PRIV_NR_POS (4 * 15)
|
||||||
|
|
||||||
|
int rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits);
|
||||||
|
|
||||||
|
#endif /* AES_I_H */
|
||||||
21
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes_siv.h
Normal file
21
drivers/net/wireless/realtek/rtl8822ce/core/crypto/aes_siv.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* AES SIV (RFC 5297)
|
||||||
|
* Copyright (c) 2013 Cozybit, Inc.
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AES_SIV_H
|
||||||
|
#define AES_SIV_H
|
||||||
|
|
||||||
|
int aes_siv_encrypt(const u8 *key, size_t key_len,
|
||||||
|
const u8 *pw, size_t pwlen,
|
||||||
|
size_t num_elem, const u8 *addr[], const size_t *len,
|
||||||
|
u8 *out);
|
||||||
|
int aes_siv_decrypt(const u8 *key, size_t key_len,
|
||||||
|
const u8 *iv_crypt, size_t iv_c_len,
|
||||||
|
size_t num_elem, const u8 *addr[], const size_t *len,
|
||||||
|
u8 *out);
|
||||||
|
|
||||||
|
#endif /* AES_SIV_H */
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* AES-based functions
|
||||||
|
*
|
||||||
|
* - AES Key Wrap Algorithm (RFC3394)
|
||||||
|
* - One-Key CBC MAC (OMAC1) hash with AES-128 and AES-256
|
||||||
|
* - AES-128/192/256 CTR mode encryption
|
||||||
|
* - AES-128 EAX mode encryption/decryption
|
||||||
|
* - AES-128 CBC
|
||||||
|
* - AES-GCM
|
||||||
|
* - AES-CCM
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AES_WRAP_H
|
||||||
|
#define AES_WRAP_H
|
||||||
|
|
||||||
|
int __must_check aes_wrap(const u8 *kek, size_t kek_len, int n, const u8 *plain,
|
||||||
|
u8 *cipher);
|
||||||
|
int __must_check aes_unwrap(const u8 *kek, size_t kek_len, int n,
|
||||||
|
const u8 *cipher, u8 *plain);
|
||||||
|
int __must_check omac1_aes_vector(const u8 *key, size_t key_len,
|
||||||
|
size_t num_elem, const u8 *addr[],
|
||||||
|
const size_t *len, u8 *mac);
|
||||||
|
int __must_check omac1_aes_128_vector(const u8 *key, size_t num_elem,
|
||||||
|
const u8 *addr[], const size_t *len,
|
||||||
|
u8 *mac);
|
||||||
|
int __must_check omac1_aes_128(const u8 *key, const u8 *data, size_t data_len,
|
||||||
|
u8 *mac);
|
||||||
|
int __must_check omac1_aes_256(const u8 *key, const u8 *data, size_t data_len,
|
||||||
|
u8 *mac);
|
||||||
|
int __must_check aes_128_encrypt_block(const u8 *key, const u8 *in, u8 *out);
|
||||||
|
int __must_check aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
|
||||||
|
u8 *data, size_t data_len);
|
||||||
|
int __must_check aes_128_ctr_encrypt(const u8 *key, const u8 *nonce,
|
||||||
|
u8 *data, size_t data_len);
|
||||||
|
int __must_check aes_128_eax_encrypt(const u8 *key,
|
||||||
|
const u8 *nonce, size_t nonce_len,
|
||||||
|
const u8 *hdr, size_t hdr_len,
|
||||||
|
u8 *data, size_t data_len, u8 *tag);
|
||||||
|
int __must_check aes_128_eax_decrypt(const u8 *key,
|
||||||
|
const u8 *nonce, size_t nonce_len,
|
||||||
|
const u8 *hdr, size_t hdr_len,
|
||||||
|
u8 *data, size_t data_len, const u8 *tag);
|
||||||
|
int __must_check aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data,
|
||||||
|
size_t data_len);
|
||||||
|
int __must_check aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data,
|
||||||
|
size_t data_len);
|
||||||
|
int __must_check aes_gcm_ae(const u8 *key, size_t key_len,
|
||||||
|
const u8 *iv, size_t iv_len,
|
||||||
|
const u8 *plain, size_t plain_len,
|
||||||
|
const u8 *aad, size_t aad_len,
|
||||||
|
u8 *crypt, u8 *tag);
|
||||||
|
int __must_check aes_gcm_ad(const u8 *key, size_t key_len,
|
||||||
|
const u8 *iv, size_t iv_len,
|
||||||
|
const u8 *crypt, size_t crypt_len,
|
||||||
|
const u8 *aad, size_t aad_len, const u8 *tag,
|
||||||
|
u8 *plain);
|
||||||
|
int __must_check aes_gmac(const u8 *key, size_t key_len,
|
||||||
|
const u8 *iv, size_t iv_len,
|
||||||
|
const u8 *aad, size_t aad_len, u8 *tag);
|
||||||
|
int __must_check aes_ccm_ae(const u8 *key, size_t key_len, const u8 *nonce,
|
||||||
|
size_t M, const u8 *plain, size_t plain_len,
|
||||||
|
const u8 *aad, size_t aad_len, u8 *crypt, u8 *auth);
|
||||||
|
int __must_check aes_ccm_ad(const u8 *key, size_t key_len, const u8 *nonce,
|
||||||
|
size_t M, const u8 *crypt, size_t crypt_len,
|
||||||
|
const u8 *aad, size_t aad_len, const u8 *auth,
|
||||||
|
u8 *plain);
|
||||||
|
|
||||||
|
#endif /* AES_WRAP_H */
|
||||||
384
drivers/net/wireless/realtek/rtl8822ce/core/crypto/ccmp.c
Normal file
384
drivers/net/wireless/realtek/rtl8822ce/core/crypto/ccmp.c
Normal file
@@ -0,0 +1,384 @@
|
|||||||
|
/*
|
||||||
|
* CTR with CBC-MAC Protocol (CCMP)
|
||||||
|
* Copyright (c) 2010-2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
#include "aes_wrap.h"
|
||||||
|
#include "wlancrypto_wrap.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void ccmp_aad_nonce(const struct ieee80211_hdr *hdr, const u8 *data,
|
||||||
|
u8 *aad, size_t *aad_len, u8 *nonce)
|
||||||
|
{
|
||||||
|
u16 fc, stype, seq;
|
||||||
|
int qos = 0, addr4 = 0;
|
||||||
|
u8 *pos;
|
||||||
|
|
||||||
|
nonce[0] = 0;
|
||||||
|
|
||||||
|
fc = le_to_host16(hdr->frame_control);
|
||||||
|
stype = WLAN_FC_GET_STYPE(fc);
|
||||||
|
if ((fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) ==
|
||||||
|
(WLAN_FC_TODS | WLAN_FC_FROMDS))
|
||||||
|
addr4 = 1;
|
||||||
|
|
||||||
|
if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA) {
|
||||||
|
fc &= ~0x0070; /* Mask subtype bits */
|
||||||
|
if (stype & WLAN_FC_STYPE_QOS_DATA) {
|
||||||
|
const u8 *qc;
|
||||||
|
qos = 1;
|
||||||
|
fc &= ~WLAN_FC_ORDER;
|
||||||
|
qc = (const u8 *)hdr + 24;
|
||||||
|
if (addr4)
|
||||||
|
qc += ETH_ALEN;
|
||||||
|
nonce[0] = qc[0] & 0x0f;
|
||||||
|
}
|
||||||
|
} else if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT)
|
||||||
|
nonce[0] |= 0x10; /* Management */
|
||||||
|
|
||||||
|
fc &= ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT | WLAN_FC_MOREDATA);
|
||||||
|
fc |= WLAN_FC_ISWEP;
|
||||||
|
WPA_PUT_LE16(aad, fc);
|
||||||
|
pos = aad + 2;
|
||||||
|
os_memcpy(pos, GetAddr1Ptr((u8 *)hdr), 3 * ETH_ALEN);
|
||||||
|
pos += 3 * ETH_ALEN;
|
||||||
|
seq = le_to_host16(hdr->seq_ctrl);
|
||||||
|
seq &= ~0xfff0; /* Mask Seq#; do not modify Frag# */
|
||||||
|
WPA_PUT_LE16(pos, seq);
|
||||||
|
pos += 2;
|
||||||
|
|
||||||
|
os_memcpy(pos, (u8 *)hdr + 24, addr4 * ETH_ALEN + qos * 2);
|
||||||
|
pos += addr4 * ETH_ALEN;
|
||||||
|
if (qos) {
|
||||||
|
pos[0] &= ~0x70;
|
||||||
|
if (1 /* FIX: either device has SPP A-MSDU Capab = 0 */)
|
||||||
|
pos[0] &= ~0x80;
|
||||||
|
pos++;
|
||||||
|
*pos++ = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
*aad_len = pos - aad;
|
||||||
|
|
||||||
|
os_memcpy(nonce + 1, hdr->addr2, ETH_ALEN);
|
||||||
|
nonce[7] = data[7]; /* PN5 */
|
||||||
|
nonce[8] = data[6]; /* PN4 */
|
||||||
|
nonce[9] = data[5]; /* PN3 */
|
||||||
|
nonce[10] = data[4]; /* PN2 */
|
||||||
|
nonce[11] = data[1]; /* PN1 */
|
||||||
|
nonce[12] = data[0]; /* PN0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ccmp_aad_nonce_pv1(const u8 *hdr, const u8 *a1, const u8 *a2,
|
||||||
|
const u8 *a3, const u8 *pn,
|
||||||
|
u8 *aad, size_t *aad_len, u8 *nonce)
|
||||||
|
{
|
||||||
|
u16 fc, type;
|
||||||
|
u8 *pos;
|
||||||
|
|
||||||
|
nonce[0] = BIT(5); /* PV1 */
|
||||||
|
/* TODO: Priority for QMF; 0 is used for Data frames */
|
||||||
|
|
||||||
|
fc = WPA_GET_LE16(hdr);
|
||||||
|
type = (fc & (BIT(2) | BIT(3) | BIT(4))) >> 2;
|
||||||
|
|
||||||
|
if (type == 1)
|
||||||
|
nonce[0] |= 0x10; /* Management */
|
||||||
|
|
||||||
|
fc &= ~(BIT(10) | BIT(11) | BIT(13) | BIT(14) | BIT(15));
|
||||||
|
fc |= BIT(12);
|
||||||
|
WPA_PUT_LE16(aad, fc);
|
||||||
|
pos = aad + 2;
|
||||||
|
if (type == 0 || type == 3) {
|
||||||
|
const u8 *sc;
|
||||||
|
|
||||||
|
os_memcpy(pos, a1, ETH_ALEN);
|
||||||
|
pos += ETH_ALEN;
|
||||||
|
os_memcpy(pos, a2, ETH_ALEN);
|
||||||
|
pos += ETH_ALEN;
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
/* Either A1 or A2 contains SID */
|
||||||
|
sc = hdr + 2 + 2 + ETH_ALEN;
|
||||||
|
} else {
|
||||||
|
/* Both A1 and A2 contain full addresses */
|
||||||
|
sc = hdr + 2 + 2 * ETH_ALEN;
|
||||||
|
}
|
||||||
|
/* SC with Sequence Number subfield (bits 4-15 of the Sequence
|
||||||
|
* Control field) masked to 0. */
|
||||||
|
*pos++ = *sc & 0x0f;
|
||||||
|
*pos++ = 0;
|
||||||
|
|
||||||
|
if (a3) {
|
||||||
|
os_memcpy(pos, a3, ETH_ALEN);
|
||||||
|
pos += ETH_ALEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*aad_len = pos - aad;
|
||||||
|
|
||||||
|
os_memcpy(nonce + 1, a2, ETH_ALEN);
|
||||||
|
nonce[7] = pn[5]; /* PN5 */
|
||||||
|
nonce[8] = pn[4]; /* PN4 */
|
||||||
|
nonce[9] = pn[3]; /* PN3 */
|
||||||
|
nonce[10] = pn[2]; /* PN2 */
|
||||||
|
nonce[11] = pn[1]; /* PN1 */
|
||||||
|
nonce[12] = pn[0]; /* PN0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u8 * ccmp_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
|
||||||
|
const u8 *data, size_t data_len, size_t *decrypted_len)
|
||||||
|
{
|
||||||
|
u8 aad[30], nonce[13];
|
||||||
|
size_t aad_len;
|
||||||
|
size_t mlen;
|
||||||
|
u8 *plain;
|
||||||
|
|
||||||
|
if (data_len < 8 + 8)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
plain = os_malloc(data_len + AES_BLOCK_SIZE);
|
||||||
|
if (plain == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
mlen = data_len - 8 - 8;
|
||||||
|
|
||||||
|
os_memset(aad, 0, sizeof(aad));
|
||||||
|
ccmp_aad_nonce(hdr, data, aad, &aad_len, nonce);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP AAD", aad, aad_len);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP nonce", nonce, 13);
|
||||||
|
|
||||||
|
if (aes_ccm_ad(tk, 16, nonce, 8, data + 8, mlen, aad, aad_len,
|
||||||
|
data + 8 + mlen, plain) < 0) {
|
||||||
|
u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
|
||||||
|
wpa_printf(_MSG_INFO_, "Invalid CCMP MIC in frame: A1=" MACSTR
|
||||||
|
" A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
|
||||||
|
MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
|
||||||
|
MAC2STR(hdr->addr3),
|
||||||
|
WLAN_GET_SEQ_SEQ(seq_ctrl),
|
||||||
|
WLAN_GET_SEQ_FRAG(seq_ctrl));
|
||||||
|
rtw_mfree(plain, data_len + AES_BLOCK_SIZE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP decrypted", plain, mlen);
|
||||||
|
|
||||||
|
*decrypted_len = mlen;
|
||||||
|
return plain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ccmp_get_pn(u8 *pn, const u8 *data)
|
||||||
|
{
|
||||||
|
pn[0] = data[7]; /* PN5 */
|
||||||
|
pn[1] = data[6]; /* PN4 */
|
||||||
|
pn[2] = data[5]; /* PN3 */
|
||||||
|
pn[3] = data[4]; /* PN2 */
|
||||||
|
pn[4] = data[1]; /* PN1 */
|
||||||
|
pn[5] = data[0]; /* PN0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u8 * ccmp_encrypt(const u8 *tk, u8 *frame, size_t len, size_t hdrlen, u8 *qos,
|
||||||
|
u8 *pn, int keyid, size_t *encrypted_len)
|
||||||
|
{
|
||||||
|
u8 aad[30], nonce[13];
|
||||||
|
size_t aad_len, plen;
|
||||||
|
u8 *crypt, *pos, *pdata;
|
||||||
|
struct ieee80211_hdr *hdr;
|
||||||
|
|
||||||
|
if (len < hdrlen || hdrlen < 24)
|
||||||
|
return NULL;
|
||||||
|
plen = len - hdrlen;
|
||||||
|
|
||||||
|
crypt = os_malloc(hdrlen + 8 + plen + 8 + AES_BLOCK_SIZE);
|
||||||
|
if (crypt == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (pn == NULL) {
|
||||||
|
os_memcpy(crypt, frame, hdrlen + 8);
|
||||||
|
hdr = (struct ieee80211_hdr *) crypt;
|
||||||
|
hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
|
||||||
|
pos = crypt + hdrlen + 8;
|
||||||
|
pdata = frame + hdrlen + 8;
|
||||||
|
} else {
|
||||||
|
os_memcpy(crypt, frame, hdrlen);
|
||||||
|
hdr = (struct ieee80211_hdr *) crypt;
|
||||||
|
hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
|
||||||
|
pos = crypt + hdrlen;
|
||||||
|
*pos++ = pn[5]; /* PN0 */
|
||||||
|
*pos++ = pn[4]; /* PN1 */
|
||||||
|
*pos++ = 0x00; /* Rsvd */
|
||||||
|
*pos++ = 0x20 | (keyid << 6);
|
||||||
|
*pos++ = pn[3]; /* PN2 */
|
||||||
|
*pos++ = pn[2]; /* PN3 */
|
||||||
|
*pos++ = pn[1]; /* PN4 */
|
||||||
|
*pos++ = pn[0]; /* PN5 */
|
||||||
|
pdata = frame + hdrlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_memset(aad, 0, sizeof(aad));
|
||||||
|
ccmp_aad_nonce(hdr, crypt + hdrlen, aad, &aad_len, nonce);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP AAD", aad, aad_len);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP nonce", nonce, 13);
|
||||||
|
|
||||||
|
if (aes_ccm_ae(tk, 16, nonce, 8, pdata, plen, aad, aad_len,
|
||||||
|
pos, pos + plen) < 0) {
|
||||||
|
rtw_mfree(crypt, hdrlen + 8 + plen + 8 + AES_BLOCK_SIZE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP encrypted", crypt + hdrlen + 8, plen);
|
||||||
|
|
||||||
|
*encrypted_len = hdrlen + 8 + plen + 8;
|
||||||
|
|
||||||
|
return crypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u8 * ccmp_encrypt_pv1(const u8 *tk, const u8 *a1, const u8 *a2, const u8 *a3,
|
||||||
|
const u8 *frame, size_t len,
|
||||||
|
size_t hdrlen, const u8 *pn, int keyid,
|
||||||
|
size_t *encrypted_len)
|
||||||
|
{
|
||||||
|
u8 aad[24], nonce[13];
|
||||||
|
size_t aad_len, plen;
|
||||||
|
u8 *crypt, *pos;
|
||||||
|
struct ieee80211_hdr *hdr;
|
||||||
|
|
||||||
|
if (len < hdrlen || hdrlen < 12)
|
||||||
|
return NULL;
|
||||||
|
plen = len - hdrlen;
|
||||||
|
|
||||||
|
crypt = os_malloc(hdrlen + plen + 8 + AES_BLOCK_SIZE);
|
||||||
|
if (crypt == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
os_memcpy(crypt, frame, hdrlen);
|
||||||
|
hdr = (struct ieee80211_hdr *) crypt;
|
||||||
|
hdr->frame_control |= host_to_le16(BIT(12)); /* Protected Frame */
|
||||||
|
pos = crypt + hdrlen;
|
||||||
|
|
||||||
|
os_memset(aad, 0, sizeof(aad));
|
||||||
|
ccmp_aad_nonce_pv1(crypt, a1, a2, a3, pn, aad, &aad_len, nonce);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP AAD", aad, aad_len);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP nonce", nonce, sizeof(nonce));
|
||||||
|
|
||||||
|
if (aes_ccm_ae(tk, 16, nonce, 8, frame + hdrlen, plen, aad, aad_len,
|
||||||
|
pos, pos + plen) < 0) {
|
||||||
|
rtw_mfree(crypt, hdrlen + plen + 8 + AES_BLOCK_SIZE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP encrypted", crypt + hdrlen, plen);
|
||||||
|
|
||||||
|
*encrypted_len = hdrlen + plen + 8;
|
||||||
|
|
||||||
|
return crypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u8 * ccmp_256_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
|
||||||
|
const u8 *data, size_t data_len, size_t *decrypted_len)
|
||||||
|
{
|
||||||
|
u8 aad[30], nonce[13];
|
||||||
|
size_t aad_len;
|
||||||
|
size_t mlen;
|
||||||
|
u8 *plain;
|
||||||
|
|
||||||
|
if (data_len < 8 + 16)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
plain = os_malloc(data_len + AES_BLOCK_SIZE);
|
||||||
|
if (plain == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
mlen = data_len - 8 - 16;
|
||||||
|
|
||||||
|
os_memset(aad, 0, sizeof(aad));
|
||||||
|
ccmp_aad_nonce(hdr, data, aad, &aad_len, nonce);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 AAD", aad, aad_len);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 nonce", nonce, 13);
|
||||||
|
|
||||||
|
if (aes_ccm_ad(tk, 32, nonce, 16, data + 8, mlen, aad, aad_len,
|
||||||
|
data + 8 + mlen, plain) < 0) {
|
||||||
|
u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
|
||||||
|
wpa_printf(_MSG_INFO_, "Invalid CCMP-256 MIC in frame: A1=" MACSTR
|
||||||
|
" A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
|
||||||
|
MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
|
||||||
|
MAC2STR(hdr->addr3),
|
||||||
|
WLAN_GET_SEQ_SEQ(seq_ctrl),
|
||||||
|
WLAN_GET_SEQ_FRAG(seq_ctrl));
|
||||||
|
rtw_mfree(plain, data_len + AES_BLOCK_SIZE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 decrypted", plain, mlen);
|
||||||
|
|
||||||
|
*decrypted_len = mlen;
|
||||||
|
return plain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u8 * ccmp_256_encrypt(const u8 *tk, u8 *frame, size_t len, size_t hdrlen,
|
||||||
|
u8 *qos, u8 *pn, int keyid, size_t *encrypted_len)
|
||||||
|
{
|
||||||
|
u8 aad[30], nonce[13];
|
||||||
|
size_t aad_len, plen;
|
||||||
|
u8 *crypt, *pos, *pdata;
|
||||||
|
struct ieee80211_hdr *hdr;
|
||||||
|
|
||||||
|
if (len < hdrlen || hdrlen < 24)
|
||||||
|
return NULL;
|
||||||
|
plen = len - hdrlen;
|
||||||
|
|
||||||
|
crypt = os_malloc(hdrlen + 8 + plen + 16 + AES_BLOCK_SIZE);
|
||||||
|
if (crypt == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (pn == NULL) {
|
||||||
|
os_memcpy(crypt, frame, hdrlen + 8);
|
||||||
|
hdr = (struct ieee80211_hdr *) crypt;
|
||||||
|
hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
|
||||||
|
pos = crypt + hdrlen + 8;
|
||||||
|
pdata = frame + hdrlen + 8;
|
||||||
|
} else {
|
||||||
|
os_memcpy(crypt, frame, hdrlen);
|
||||||
|
hdr = (struct ieee80211_hdr *) crypt;
|
||||||
|
hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
|
||||||
|
pos = crypt + hdrlen;
|
||||||
|
*pos++ = pn[5]; /* PN0 */
|
||||||
|
*pos++ = pn[4]; /* PN1 */
|
||||||
|
*pos++ = 0x00; /* Rsvd */
|
||||||
|
*pos++ = 0x20 | (keyid << 6);
|
||||||
|
*pos++ = pn[3]; /* PN2 */
|
||||||
|
*pos++ = pn[2]; /* PN3 */
|
||||||
|
*pos++ = pn[1]; /* PN4 */
|
||||||
|
*pos++ = pn[0]; /* PN5 */
|
||||||
|
pdata = frame + hdrlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_memset(aad, 0, sizeof(aad));
|
||||||
|
ccmp_aad_nonce(hdr, crypt + hdrlen, aad, &aad_len, nonce);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 AAD", aad, aad_len);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 nonce", nonce, 13);
|
||||||
|
|
||||||
|
if (aes_ccm_ae(tk, 32, nonce, 16, pdata, plen, aad, aad_len,
|
||||||
|
pos, pos + plen) < 0) {
|
||||||
|
rtw_mfree(crypt, hdrlen + 8 + plen + 16 + AES_BLOCK_SIZE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 encrypted", crypt + hdrlen + 8,
|
||||||
|
plen);
|
||||||
|
|
||||||
|
*encrypted_len = hdrlen + 8 + plen + 16;
|
||||||
|
|
||||||
|
return crypt;
|
||||||
|
}
|
||||||
193
drivers/net/wireless/realtek/rtl8822ce/core/crypto/gcmp.c
Normal file
193
drivers/net/wireless/realtek/rtl8822ce/core/crypto/gcmp.c
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
/*
|
||||||
|
* GCM with GMAC Protocol (GCMP)
|
||||||
|
* Copyright (c) 2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
#include "aes_wrap.h"
|
||||||
|
#include "wlancrypto_wrap.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void gcmp_aad_nonce(const struct ieee80211_hdr *hdr, const u8 *data,
|
||||||
|
u8 *aad, size_t *aad_len, u8 *nonce)
|
||||||
|
{
|
||||||
|
u16 fc, stype, seq;
|
||||||
|
int qos = 0, addr4 = 0;
|
||||||
|
u8 *pos;
|
||||||
|
|
||||||
|
fc = le_to_host16(hdr->frame_control);
|
||||||
|
stype = WLAN_FC_GET_STYPE(fc);
|
||||||
|
if ((fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) ==
|
||||||
|
(WLAN_FC_TODS | WLAN_FC_FROMDS))
|
||||||
|
addr4 = 1;
|
||||||
|
|
||||||
|
if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA) {
|
||||||
|
fc &= ~0x0070; /* Mask subtype bits */
|
||||||
|
if (stype & WLAN_FC_STYPE_QOS_DATA) {
|
||||||
|
const u8 *qc;
|
||||||
|
qos = 1;
|
||||||
|
fc &= ~WLAN_FC_ORDER;
|
||||||
|
qc = (const u8 *)hdr + 24;
|
||||||
|
if (addr4)
|
||||||
|
qc += ETH_ALEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fc &= ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT | WLAN_FC_MOREDATA);
|
||||||
|
WPA_PUT_LE16(aad, fc);
|
||||||
|
pos = aad + 2;
|
||||||
|
os_memcpy(pos, GetAddr1Ptr((u8 *)hdr), 3 * ETH_ALEN);
|
||||||
|
pos += 3 * ETH_ALEN;
|
||||||
|
seq = le_to_host16(hdr->seq_ctrl);
|
||||||
|
seq &= ~0xfff0; /* Mask Seq#; do not modify Frag# */
|
||||||
|
WPA_PUT_LE16(pos, seq);
|
||||||
|
pos += 2;
|
||||||
|
|
||||||
|
wpa_printf(_MSG_INFO_, "pos - aad = %u, qos(%d)\n", (pos - aad), qos);
|
||||||
|
|
||||||
|
os_memcpy(pos, (u8 *)hdr + 24, addr4 * ETH_ALEN + qos * 2);
|
||||||
|
pos += addr4 * ETH_ALEN;
|
||||||
|
if (qos) {
|
||||||
|
pos[0] &= ~0x70;
|
||||||
|
if (1 /* FIX: either device has SPP A-MSDU Capab = 0 */)
|
||||||
|
pos[0] &= ~0x80;
|
||||||
|
pos++;
|
||||||
|
*pos++ = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
wpa_printf(_MSG_INFO_, "pos - aad = %u\n", (pos - aad));
|
||||||
|
*aad_len = pos - aad;
|
||||||
|
|
||||||
|
os_memcpy(nonce, hdr->addr2, ETH_ALEN);
|
||||||
|
nonce[6] = data[7]; /* PN5 */
|
||||||
|
nonce[7] = data[6]; /* PN4 */
|
||||||
|
nonce[8] = data[5]; /* PN3 */
|
||||||
|
nonce[9] = data[4]; /* PN2 */
|
||||||
|
nonce[10] = data[1]; /* PN1 */
|
||||||
|
nonce[11] = data[0]; /* PN0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gcmp_decrypt -
|
||||||
|
* @tk: the temporal key
|
||||||
|
* @tk_len: length of @tk
|
||||||
|
* @hdr: the mac header
|
||||||
|
* @data: payload after mac header (PN + enc_data + MIC)
|
||||||
|
* @data_len: length of @data (PN + enc_data + MIC)
|
||||||
|
* @decrypted_len: length of the data decrypted
|
||||||
|
*/
|
||||||
|
u8 * gcmp_decrypt(const u8 *tk, size_t tk_len, const struct ieee80211_hdr *hdr,
|
||||||
|
const u8 *data, size_t data_len, size_t *decrypted_len)
|
||||||
|
{
|
||||||
|
u8 aad[30], nonce[12], *plain;
|
||||||
|
size_t aad_len, mlen;
|
||||||
|
const u8 *m;
|
||||||
|
|
||||||
|
if (data_len < 8 + 16)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
plain = os_malloc(data_len + AES_BLOCK_SIZE);
|
||||||
|
if (plain == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
m = data + 8;
|
||||||
|
mlen = data_len - 8 - 16;
|
||||||
|
|
||||||
|
os_memset(aad, 0, sizeof(aad));
|
||||||
|
gcmp_aad_nonce(hdr, data, aad, &aad_len, nonce);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "GCMP AAD", aad, aad_len);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "GCMP nonce", nonce, sizeof(nonce));
|
||||||
|
|
||||||
|
if (aes_gcm_ad(tk, tk_len, nonce, sizeof(nonce), m, mlen, aad, aad_len,
|
||||||
|
m + mlen, plain) < 0) {
|
||||||
|
u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
|
||||||
|
wpa_printf(_MSG_INFO_, "Invalid GCMP frame: A1=" MACSTR
|
||||||
|
" A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
|
||||||
|
MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
|
||||||
|
MAC2STR(hdr->addr3),
|
||||||
|
WLAN_GET_SEQ_SEQ(seq_ctrl),
|
||||||
|
WLAN_GET_SEQ_FRAG(seq_ctrl));
|
||||||
|
rtw_mfree(plain, data_len + AES_BLOCK_SIZE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*decrypted_len = mlen;
|
||||||
|
return plain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gcmp_encrypt -
|
||||||
|
* @tk: the temporal key
|
||||||
|
* @tk_len: length of @tk
|
||||||
|
* @frame: the point to mac header, the frame including mac header and payload,
|
||||||
|
* if @pn is NULL, then the frame including pn
|
||||||
|
* @len: length of @frame
|
||||||
|
* length = mac header + payload
|
||||||
|
* @hdrlen: length of the mac header
|
||||||
|
* @qos: pointer to the QOS field of the frame
|
||||||
|
* @pn: packet number
|
||||||
|
* @keyid: key id
|
||||||
|
* @encrypted_len: length of the encrypted frame
|
||||||
|
* including mac header, pn, payload and MIC
|
||||||
|
*/
|
||||||
|
u8 * gcmp_encrypt(const u8 *tk, size_t tk_len, const u8 *frame, size_t len,
|
||||||
|
size_t hdrlen, const u8 *qos,
|
||||||
|
const u8 *pn, int keyid, size_t *encrypted_len)
|
||||||
|
{
|
||||||
|
u8 aad[30], nonce[12], *crypt, *pos;
|
||||||
|
const u8 *pdata;
|
||||||
|
size_t aad_len, plen;
|
||||||
|
struct ieee80211_hdr *hdr;
|
||||||
|
|
||||||
|
if (len < hdrlen || hdrlen < 24)
|
||||||
|
return NULL;
|
||||||
|
plen = len - hdrlen;
|
||||||
|
|
||||||
|
crypt = os_malloc(hdrlen + 8 + plen + 16 + AES_BLOCK_SIZE);
|
||||||
|
if (crypt == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (pn == NULL) {
|
||||||
|
os_memcpy(crypt, frame, hdrlen + 8);
|
||||||
|
hdr = (struct ieee80211_hdr *)crypt;
|
||||||
|
pos = crypt + hdrlen + 8;
|
||||||
|
pdata = frame + hdrlen + 8;
|
||||||
|
} else {
|
||||||
|
os_memcpy(crypt, frame, hdrlen);
|
||||||
|
hdr = (struct ieee80211_hdr *)crypt;
|
||||||
|
pos = crypt + hdrlen;
|
||||||
|
|
||||||
|
*pos++ = pn[5]; /* PN0 */
|
||||||
|
*pos++ = pn[4]; /* PN1 */
|
||||||
|
*pos++ = 0x00; /* Rsvd */
|
||||||
|
*pos++ = 0x20 | (keyid << 6);
|
||||||
|
*pos++ = pn[3]; /* PN2 */
|
||||||
|
*pos++ = pn[2]; /* PN3 */
|
||||||
|
*pos++ = pn[1]; /* PN4 */
|
||||||
|
*pos++ = pn[0]; /* PN5 */
|
||||||
|
pdata = frame + hdrlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_memset(aad, 0, sizeof(aad));
|
||||||
|
gcmp_aad_nonce(hdr, crypt + hdrlen, aad, &aad_len, nonce);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "GCMP AAD", aad, aad_len);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "GCMP nonce", nonce, sizeof(nonce));
|
||||||
|
|
||||||
|
if (aes_gcm_ae(tk, tk_len, nonce, sizeof(nonce), pdata, plen,
|
||||||
|
aad, aad_len, pos, pos + plen) < 0) {
|
||||||
|
rtw_mfree(crypt, hdrlen + 8 + plen + 16 + AES_BLOCK_SIZE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "GCMP MIC", pos + plen, 16);
|
||||||
|
wpa_hexdump(_MSG_EXCESSIVE_, "GCMP encrypted", pos, plen);
|
||||||
|
|
||||||
|
*encrypted_len = hdrlen + 8 + plen + 16;
|
||||||
|
|
||||||
|
return crypt;
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#ifndef DEBUG_CRYPTO
|
||||||
|
#define DEBUG_CRYPTO 0
|
||||||
|
#endif /* DEBUG_CRYTO */
|
||||||
|
|
||||||
|
int os_memcmp(const void *s1, const void *s2, size_t n)
|
||||||
|
{
|
||||||
|
return _rtw_memcmp2(s1, s2, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
int os_memcmp_const(const void *a, const void *b, size_t len)
|
||||||
|
{
|
||||||
|
const u8 *aa = a;
|
||||||
|
const u8 *bb = b;
|
||||||
|
size_t i;
|
||||||
|
u8 res;
|
||||||
|
|
||||||
|
for (res = 0, i = 0; i < len; i++)
|
||||||
|
res |= aa[i] ^ bb[i];
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* os_memdup(const void *src, u32 sz)
|
||||||
|
{
|
||||||
|
void *r = rtw_malloc(sz);
|
||||||
|
|
||||||
|
if (r && src)
|
||||||
|
_rtw_memcpy(r, src, sz);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t os_strlen(const char *s)
|
||||||
|
{
|
||||||
|
const char *p = s;
|
||||||
|
while (*p)
|
||||||
|
p++;
|
||||||
|
return p - s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void forced_memzero(void *ptr, size_t len)
|
||||||
|
{
|
||||||
|
_rtw_memset(ptr, 0, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bin_clear_free(void *bin, size_t len)
|
||||||
|
{
|
||||||
|
if (bin) {
|
||||||
|
forced_memzero(bin, len);
|
||||||
|
rtw_mfree(bin, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wpa_printf(int level, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
#if DEBUG_CRYPTO
|
||||||
|
#define MSG_LEN 100
|
||||||
|
va_list args;
|
||||||
|
u8 buf[MSG_LEN] = { 0 };
|
||||||
|
int err;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
err = vsnprintf(buf, MSG_LEN, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
RTW_INFO("%s", buf);
|
||||||
|
#undef MSG_LEN
|
||||||
|
#endif /* DEBUG_CRYPTO */
|
||||||
|
}
|
||||||
|
|
||||||
|
void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
|
||||||
|
{
|
||||||
|
#if DEBUG_CRYPTO
|
||||||
|
RTW_INFO_DUMP((u8 *)title, buf, len);
|
||||||
|
#endif /* DEBUG_CRYPTO */
|
||||||
|
}
|
||||||
|
|
||||||
|
void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len)
|
||||||
|
{
|
||||||
|
#if DEBUG_CRYPTO
|
||||||
|
RTW_INFO_DUMP((u8 *)title, buf, len);
|
||||||
|
#endif /* DEBUG_CRYPTO */
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
#ifndef RTW_CRYTO_WRAP_H
|
||||||
|
#define RTW_CRYTO_WRAP_H
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
#define TEST_FAIL() 0
|
||||||
|
|
||||||
|
#define os_memset _rtw_memset
|
||||||
|
#define os_memcpy _rtw_memcpy
|
||||||
|
#define os_malloc rtw_malloc
|
||||||
|
|
||||||
|
#define le_to_host16 le16_to_cpu
|
||||||
|
#define host_to_le16 cpu_to_le16
|
||||||
|
|
||||||
|
#define WPA_PUT_LE16 RTW_PUT_LE16
|
||||||
|
#define WPA_GET_LE16 RTW_GET_LE16
|
||||||
|
#define WPA_PUT_LE32 RTW_PUT_LE32
|
||||||
|
#define WPA_GET_LE32 RTW_GET_LE32
|
||||||
|
#define WPA_PUT_LE64 RTW_PUT_LE64
|
||||||
|
#define WPA_GET_LE64 RTW_GET_LE64
|
||||||
|
#define WPA_PUT_BE16 RTW_PUT_BE16
|
||||||
|
#define WPA_GET_BE16 RTW_GET_BE16
|
||||||
|
#define WPA_PUT_BE32 RTW_PUT_BE32
|
||||||
|
#define WPA_GET_BE32 RTW_GET_BE32
|
||||||
|
#define WPA_PUT_BE64 RTW_PUT_BE64
|
||||||
|
#define WPA_GET_BE64 RTW_GET_BE64
|
||||||
|
|
||||||
|
#ifndef MAC2STR
|
||||||
|
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||||
|
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WLAN_FC_PVER 0x0003
|
||||||
|
#define WLAN_FC_TODS 0x0100
|
||||||
|
#define WLAN_FC_FROMDS 0x0200
|
||||||
|
#define WLAN_FC_MOREFRAG 0x0400
|
||||||
|
#define WLAN_FC_RETRY 0x0800
|
||||||
|
#define WLAN_FC_PWRMGT 0x1000
|
||||||
|
#define WLAN_FC_MOREDATA 0x2000
|
||||||
|
#define WLAN_FC_ISWEP 0x4000
|
||||||
|
#define WLAN_FC_ORDER 0x8000
|
||||||
|
|
||||||
|
#define WLAN_FC_TYPE_DATA RTW_IEEE80211_FTYPE_DATA
|
||||||
|
#define WLAN_FC_TYPE_MGMT RTW_IEEE80211_FTYPE_MGMT
|
||||||
|
|
||||||
|
#define WLAN_FC_STYPE_QOS_DATA RTW_IEEE80211_STYPE_QOS_DATA
|
||||||
|
|
||||||
|
enum {
|
||||||
|
_MSG_EXCESSIVE_, _MSG_MSGDUMP_, _MSG_DEBUG_, _MSG_INFO_, _MSG_WARNING_, _MSG_ERROR_
|
||||||
|
};
|
||||||
|
|
||||||
|
int os_memcmp(const void *s1, const void *s2, size_t n);
|
||||||
|
int os_memcmp_const(const void *a, const void *b, size_t len);
|
||||||
|
void* os_memdup(const void *src, u32 sz);
|
||||||
|
size_t os_strlen(const char *s);
|
||||||
|
|
||||||
|
void forced_memzero(void *ptr, size_t len);
|
||||||
|
void bin_clear_free(void *bin, size_t len);
|
||||||
|
|
||||||
|
void wpa_printf(int level, const char *fmt, ...);
|
||||||
|
void wpa_hexdump(int level, const char *title, const void *buf, size_t len);
|
||||||
|
void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len);
|
||||||
|
|
||||||
|
#endif /* RTW_CRYTO_WRAP_H */
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
/*
|
||||||
|
* SHA-256 hash implementation and interface functions
|
||||||
|
* Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
//#include "common.h"
|
||||||
|
#include "sha256.h"
|
||||||
|
#include "sha256_i.h"
|
||||||
|
//#include "crypto.h"
|
||||||
|
#include "wlancrypto_wrap.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sha256_vector - SHA256 hash for data vector
|
||||||
|
* @num_elem: Number of elements in the data vector
|
||||||
|
* @addr: Pointers to the data areas
|
||||||
|
* @len: Lengths of the data blocks
|
||||||
|
* @mac: Buffer for the hash
|
||||||
|
* Returns: 0 on success, -1 of failure
|
||||||
|
*/
|
||||||
|
int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||||
|
u8 *mac)
|
||||||
|
{
|
||||||
|
struct _sha256_state ctx;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (TEST_FAIL())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
_sha256_init(&ctx);
|
||||||
|
for (i = 0; i < num_elem; i++)
|
||||||
|
if (sha256_process(&ctx, addr[i], len[i]))
|
||||||
|
return -1;
|
||||||
|
if (sha256_done(&ctx, mac))
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ===== start - public domain SHA256 implementation ===== */
|
||||||
|
|
||||||
|
/* This is based on SHA256 implementation in LibTomCrypt that was released into
|
||||||
|
* public domain by Tom St Denis. */
|
||||||
|
|
||||||
|
/* the K array */
|
||||||
|
static const unsigned long K[64] = {
|
||||||
|
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
|
||||||
|
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
|
||||||
|
0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
|
||||||
|
0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
|
||||||
|
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
|
||||||
|
0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
|
||||||
|
0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
|
||||||
|
0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
|
||||||
|
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
|
||||||
|
0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
|
||||||
|
0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
|
||||||
|
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
|
||||||
|
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Various logical functions */
|
||||||
|
#define RORc(x, y) \
|
||||||
|
( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
|
||||||
|
((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
|
||||||
|
#define Ch(x,y,z) (z ^ (x & (y ^ z)))
|
||||||
|
#define Maj(x,y,z) (((x | y) & z) | (x & y))
|
||||||
|
#define S(x, n) RORc((x), (n))
|
||||||
|
#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n))
|
||||||
|
#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22))
|
||||||
|
#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25))
|
||||||
|
#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3))
|
||||||
|
#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10))
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* compress 512-bits */
|
||||||
|
static int sha256_compress(struct _sha256_state *md, unsigned char *buf)
|
||||||
|
{
|
||||||
|
u32 S[8], W[64], t0, t1;
|
||||||
|
u32 t;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* copy state into S */
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
S[i] = md->state[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy the state into 512-bits into W[0..15] */
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
W[i] = WPA_GET_BE32(buf + (4 * i));
|
||||||
|
|
||||||
|
/* fill W[16..63] */
|
||||||
|
for (i = 16; i < 64; i++) {
|
||||||
|
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
|
||||||
|
W[i - 16];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compress */
|
||||||
|
#define RND(a,b,c,d,e,f,g,h,i) \
|
||||||
|
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
|
||||||
|
t1 = Sigma0(a) + Maj(a, b, c); \
|
||||||
|
d += t0; \
|
||||||
|
h = t0 + t1;
|
||||||
|
|
||||||
|
for (i = 0; i < 64; ++i) {
|
||||||
|
RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
|
||||||
|
t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
|
||||||
|
S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* feedback */
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
md->state[i] = md->state[i] + S[i];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize the hash state */
|
||||||
|
void _sha256_init(struct _sha256_state *md)
|
||||||
|
{
|
||||||
|
md->curlen = 0;
|
||||||
|
md->length = 0;
|
||||||
|
md->state[0] = 0x6A09E667UL;
|
||||||
|
md->state[1] = 0xBB67AE85UL;
|
||||||
|
md->state[2] = 0x3C6EF372UL;
|
||||||
|
md->state[3] = 0xA54FF53AUL;
|
||||||
|
md->state[4] = 0x510E527FUL;
|
||||||
|
md->state[5] = 0x9B05688CUL;
|
||||||
|
md->state[6] = 0x1F83D9ABUL;
|
||||||
|
md->state[7] = 0x5BE0CD19UL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Process a block of memory though the hash
|
||||||
|
@param md The hash state
|
||||||
|
@param in The data to hash
|
||||||
|
@param inlen The length of the data (octets)
|
||||||
|
@return CRYPT_OK if successful
|
||||||
|
*/
|
||||||
|
int sha256_process(struct _sha256_state *md, const unsigned char *in,
|
||||||
|
unsigned long inlen)
|
||||||
|
{
|
||||||
|
unsigned long n;
|
||||||
|
|
||||||
|
if (md->curlen >= sizeof(md->buf))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
while (inlen > 0) {
|
||||||
|
if (md->curlen == 0 && inlen >= SHA256_BLOCK_SIZE) {
|
||||||
|
if (sha256_compress(md, (unsigned char *) in) < 0)
|
||||||
|
return -1;
|
||||||
|
md->length += SHA256_BLOCK_SIZE * 8;
|
||||||
|
in += SHA256_BLOCK_SIZE;
|
||||||
|
inlen -= SHA256_BLOCK_SIZE;
|
||||||
|
} else {
|
||||||
|
n = MIN(inlen, (SHA256_BLOCK_SIZE - md->curlen));
|
||||||
|
os_memcpy(md->buf + md->curlen, in, n);
|
||||||
|
md->curlen += n;
|
||||||
|
in += n;
|
||||||
|
inlen -= n;
|
||||||
|
if (md->curlen == SHA256_BLOCK_SIZE) {
|
||||||
|
if (sha256_compress(md, md->buf) < 0)
|
||||||
|
return -1;
|
||||||
|
md->length += 8 * SHA256_BLOCK_SIZE;
|
||||||
|
md->curlen = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Terminate the hash to get the digest
|
||||||
|
@param md The hash state
|
||||||
|
@param out [out] The destination of the hash (32 bytes)
|
||||||
|
@return CRYPT_OK if successful
|
||||||
|
*/
|
||||||
|
int sha256_done(struct _sha256_state *md, unsigned char *out)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (md->curlen >= sizeof(md->buf))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* increase the length of the message */
|
||||||
|
md->length += md->curlen * 8;
|
||||||
|
|
||||||
|
/* append the '1' bit */
|
||||||
|
md->buf[md->curlen++] = (unsigned char) 0x80;
|
||||||
|
|
||||||
|
/* if the length is currently above 56 bytes we append zeros
|
||||||
|
* then compress. Then we can fall back to padding zeros and length
|
||||||
|
* encoding like normal.
|
||||||
|
*/
|
||||||
|
if (md->curlen > 56) {
|
||||||
|
while (md->curlen < SHA256_BLOCK_SIZE) {
|
||||||
|
md->buf[md->curlen++] = (unsigned char) 0;
|
||||||
|
}
|
||||||
|
sha256_compress(md, md->buf);
|
||||||
|
md->curlen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pad up to 56 bytes of zeroes */
|
||||||
|
while (md->curlen < 56) {
|
||||||
|
md->buf[md->curlen++] = (unsigned char) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* store length */
|
||||||
|
WPA_PUT_BE64(md->buf + 56, md->length);
|
||||||
|
sha256_compress(md, md->buf);
|
||||||
|
|
||||||
|
/* copy output */
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
WPA_PUT_BE32(out + (4 * i), md->state[i]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== end - public domain SHA256 implementation ===== */
|
||||||
109
drivers/net/wireless/realtek/rtl8822ce/core/crypto/sha256-prf.c
Normal file
109
drivers/net/wireless/realtek/rtl8822ce/core/crypto/sha256-prf.c
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* SHA256-based PRF (IEEE 802.11r)
|
||||||
|
* Copyright (c) 2003-2016, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
//#include "common.h"
|
||||||
|
#include "sha256.h"
|
||||||
|
//#include "crypto.h"
|
||||||
|
#include "wlancrypto_wrap.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sha256_prf - SHA256-based Pseudo-Random Function (IEEE 802.11r, 8.5.1.5.2)
|
||||||
|
* @key: Key for PRF
|
||||||
|
* @key_len: Length of the key in bytes
|
||||||
|
* @label: A unique label for each purpose of the PRF
|
||||||
|
* @data: Extra data to bind into the key
|
||||||
|
* @data_len: Length of the data
|
||||||
|
* @buf: Buffer for the generated pseudo-random key
|
||||||
|
* @buf_len: Number of bytes of key to generate
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*
|
||||||
|
* This function is used to derive new, cryptographically separate keys from a
|
||||||
|
* given key.
|
||||||
|
*/
|
||||||
|
int sha256_prf(const u8 *key, size_t key_len, const char *label,
|
||||||
|
const u8 *data, size_t data_len, u8 *buf, size_t buf_len)
|
||||||
|
{
|
||||||
|
return sha256_prf_bits(key, key_len, label, data, data_len, buf,
|
||||||
|
buf_len * 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sha256_prf_bits - IEEE Std 802.11-2012, 11.6.1.7.2 Key derivation function
|
||||||
|
* @key: Key for KDF
|
||||||
|
* @key_len: Length of the key in bytes
|
||||||
|
* @label: A unique label for each purpose of the PRF
|
||||||
|
* @data: Extra data to bind into the key
|
||||||
|
* @data_len: Length of the data
|
||||||
|
* @buf: Buffer for the generated pseudo-random key
|
||||||
|
* @buf_len: Number of bits of key to generate
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*
|
||||||
|
* This function is used to derive new, cryptographically separate keys from a
|
||||||
|
* given key. If the requested buf_len is not divisible by eight, the least
|
||||||
|
* significant 1-7 bits of the last octet in the output are not part of the
|
||||||
|
* requested output.
|
||||||
|
*/
|
||||||
|
int sha256_prf_bits(const u8 *key, size_t key_len, const char *label,
|
||||||
|
const u8 *data, size_t data_len, u8 *buf,
|
||||||
|
size_t buf_len_bits)
|
||||||
|
{
|
||||||
|
u16 counter = 1;
|
||||||
|
size_t pos, plen;
|
||||||
|
u8 hash[SHA256_MAC_LEN];
|
||||||
|
const u8 *addr[4];
|
||||||
|
size_t len[4];
|
||||||
|
u8 counter_le[2], length_le[2];
|
||||||
|
size_t buf_len = (buf_len_bits + 7) / 8;
|
||||||
|
|
||||||
|
addr[0] = counter_le;
|
||||||
|
len[0] = 2;
|
||||||
|
addr[1] = (u8 *) label;
|
||||||
|
len[1] = os_strlen(label);
|
||||||
|
addr[2] = data;
|
||||||
|
len[2] = data_len;
|
||||||
|
addr[3] = length_le;
|
||||||
|
len[3] = sizeof(length_le);
|
||||||
|
|
||||||
|
WPA_PUT_LE16(length_le, buf_len_bits);
|
||||||
|
pos = 0;
|
||||||
|
while (pos < buf_len) {
|
||||||
|
plen = buf_len - pos;
|
||||||
|
WPA_PUT_LE16(counter_le, counter);
|
||||||
|
if (plen >= SHA256_MAC_LEN) {
|
||||||
|
if (hmac_sha256_vector(key, key_len, 4, addr, len,
|
||||||
|
&buf[pos]) < 0)
|
||||||
|
return -1;
|
||||||
|
pos += SHA256_MAC_LEN;
|
||||||
|
} else {
|
||||||
|
if (hmac_sha256_vector(key, key_len, 4, addr, len,
|
||||||
|
hash) < 0)
|
||||||
|
return -1;
|
||||||
|
os_memcpy(&buf[pos], hash, plen);
|
||||||
|
pos += plen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mask out unused bits in the last octet if it does not use all the
|
||||||
|
* bits.
|
||||||
|
*/
|
||||||
|
if (buf_len_bits % 8) {
|
||||||
|
u8 mask = 0xff << (8 - buf_len_bits % 8);
|
||||||
|
buf[pos - 1] &= mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
forced_memzero(hash, sizeof(hash));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
104
drivers/net/wireless/realtek/rtl8822ce/core/crypto/sha256.c
Normal file
104
drivers/net/wireless/realtek/rtl8822ce/core/crypto/sha256.c
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* SHA-256 hash implementation and interface functions
|
||||||
|
* Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtw_crypto_wrap.h"
|
||||||
|
|
||||||
|
#include "sha256.h"
|
||||||
|
//#include "crypto.h"
|
||||||
|
#include "wlancrypto_wrap.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hmac_sha256_vector - HMAC-SHA256 over data vector (RFC 2104)
|
||||||
|
* @key: Key for HMAC operations
|
||||||
|
* @key_len: Length of the key in bytes
|
||||||
|
* @num_elem: Number of elements in the data vector
|
||||||
|
* @addr: Pointers to the data areas
|
||||||
|
* @len: Lengths of the data blocks
|
||||||
|
* @mac: Buffer for the hash (32 bytes)
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*/
|
||||||
|
int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem,
|
||||||
|
const u8 *addr[], const size_t *len, u8 *mac)
|
||||||
|
{
|
||||||
|
unsigned char k_pad[64]; /* padding - key XORd with ipad/opad */
|
||||||
|
unsigned char tk[32];
|
||||||
|
const u8 *_addr[6];
|
||||||
|
size_t _len[6], i;
|
||||||
|
|
||||||
|
if (num_elem > 5) {
|
||||||
|
/*
|
||||||
|
* Fixed limit on the number of fragments to avoid having to
|
||||||
|
* allocate memory (which could fail).
|
||||||
|
*/
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if key is longer than 64 bytes reset it to key = SHA256(key) */
|
||||||
|
if (key_len > 64) {
|
||||||
|
if (sha256_vector(1, &key, &key_len, tk) < 0)
|
||||||
|
return -1;
|
||||||
|
key = tk;
|
||||||
|
key_len = 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the HMAC_SHA256 transform looks like:
|
||||||
|
*
|
||||||
|
* SHA256(K XOR opad, SHA256(K XOR ipad, text))
|
||||||
|
*
|
||||||
|
* where K is an n byte key
|
||||||
|
* ipad is the byte 0x36 repeated 64 times
|
||||||
|
* opad is the byte 0x5c repeated 64 times
|
||||||
|
* and text is the data being protected */
|
||||||
|
|
||||||
|
/* start out by storing key in ipad */
|
||||||
|
os_memset(k_pad, 0, sizeof(k_pad));
|
||||||
|
os_memcpy(k_pad, key, key_len);
|
||||||
|
/* XOR key with ipad values */
|
||||||
|
for (i = 0; i < 64; i++)
|
||||||
|
k_pad[i] ^= 0x36;
|
||||||
|
|
||||||
|
/* perform inner SHA256 */
|
||||||
|
_addr[0] = k_pad;
|
||||||
|
_len[0] = 64;
|
||||||
|
for (i = 0; i < num_elem; i++) {
|
||||||
|
_addr[i + 1] = addr[i];
|
||||||
|
_len[i + 1] = len[i];
|
||||||
|
}
|
||||||
|
if (sha256_vector(1 + num_elem, _addr, _len, mac) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
os_memset(k_pad, 0, sizeof(k_pad));
|
||||||
|
os_memcpy(k_pad, key, key_len);
|
||||||
|
/* XOR key with opad values */
|
||||||
|
for (i = 0; i < 64; i++)
|
||||||
|
k_pad[i] ^= 0x5c;
|
||||||
|
|
||||||
|
/* perform outer SHA256 */
|
||||||
|
_addr[0] = k_pad;
|
||||||
|
_len[0] = 64;
|
||||||
|
_addr[1] = mac;
|
||||||
|
_len[1] = SHA256_MAC_LEN;
|
||||||
|
return sha256_vector(2, _addr, _len, mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hmac_sha256 - HMAC-SHA256 over data buffer (RFC 2104)
|
||||||
|
* @key: Key for HMAC operations
|
||||||
|
* @key_len: Length of the key in bytes
|
||||||
|
* @data: Pointers to the data area
|
||||||
|
* @data_len: Length of the data area
|
||||||
|
* @mac: Buffer for the hash (32 bytes)
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*/
|
||||||
|
int hmac_sha256(const u8 *key, size_t key_len, const u8 *data,
|
||||||
|
size_t data_len, u8 *mac)
|
||||||
|
{
|
||||||
|
return hmac_sha256_vector(key, key_len, 1, &data, &data_len, mac);
|
||||||
|
}
|
||||||
30
drivers/net/wireless/realtek/rtl8822ce/core/crypto/sha256.h
Normal file
30
drivers/net/wireless/realtek/rtl8822ce/core/crypto/sha256.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* SHA256 hash implementation and interface functions
|
||||||
|
* Copyright (c) 2003-2016, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SHA256_H
|
||||||
|
#define SHA256_H
|
||||||
|
|
||||||
|
#define SHA256_MAC_LEN 32
|
||||||
|
|
||||||
|
int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem,
|
||||||
|
const u8 *addr[], const size_t *len, u8 *mac);
|
||||||
|
int hmac_sha256(const u8 *key, size_t key_len, const u8 *data,
|
||||||
|
size_t data_len, u8 *mac);
|
||||||
|
int sha256_prf(const u8 *key, size_t key_len, const char *label,
|
||||||
|
const u8 *data, size_t data_len, u8 *buf, size_t buf_len);
|
||||||
|
int sha256_prf_bits(const u8 *key, size_t key_len, const char *label,
|
||||||
|
const u8 *data, size_t data_len, u8 *buf,
|
||||||
|
size_t buf_len_bits);
|
||||||
|
void tls_prf_sha256(const u8 *secret, size_t secret_len,
|
||||||
|
const char *label, const u8 *seed, size_t seed_len,
|
||||||
|
u8 *out, size_t outlen);
|
||||||
|
int hmac_sha256_kdf(const u8 *secret, size_t secret_len,
|
||||||
|
const char *label, const u8 *seed, size_t seed_len,
|
||||||
|
u8 *out, size_t outlen);
|
||||||
|
|
||||||
|
#endif /* SHA256_H */
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* SHA-256 internal definitions
|
||||||
|
* Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SHA256_I_H
|
||||||
|
#define SHA256_I_H
|
||||||
|
|
||||||
|
#define SHA256_BLOCK_SIZE 64
|
||||||
|
|
||||||
|
struct _sha256_state {
|
||||||
|
u64 length;
|
||||||
|
u32 state[8], curlen;
|
||||||
|
u8 buf[SHA256_BLOCK_SIZE];
|
||||||
|
};
|
||||||
|
|
||||||
|
void _sha256_init(struct _sha256_state *md);
|
||||||
|
int sha256_process(struct _sha256_state *md, const unsigned char *in,
|
||||||
|
unsigned long inlen);
|
||||||
|
int sha256_done(struct _sha256_state *md, unsigned char *out);
|
||||||
|
|
||||||
|
#endif /* SHA256_I_H */
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* wlantest - IEEE 802.11 protocol monitoring and testing tool
|
||||||
|
* Copyright (c) 2010-2013, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WLANCRYPTO_WRAP_H
|
||||||
|
#define WLANCRYPTO_WRAP_H
|
||||||
|
|
||||||
|
int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||||
|
u8 *mac);
|
||||||
|
|
||||||
|
u8* ccmp_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
|
||||||
|
const u8 *data, size_t data_len, size_t *decrypted_len);
|
||||||
|
u8* ccmp_encrypt(const u8 *tk, u8 *frame, size_t len, size_t hdrlen, u8 *qos,
|
||||||
|
u8 *pn, int keyid, size_t *encrypted_len);
|
||||||
|
u8* ccmp_encrypt_pv1(const u8 *tk, const u8 *a1, const u8 *a2, const u8 *a3,
|
||||||
|
const u8 *frame, size_t len,
|
||||||
|
size_t hdrlen, const u8 *pn, int keyid,
|
||||||
|
size_t *encrypted_len);
|
||||||
|
u8* ccmp_256_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
|
||||||
|
const u8 *data, size_t data_len, size_t *decrypted_len);
|
||||||
|
u8* ccmp_256_encrypt(const u8 *tk, u8 *frame, size_t len, size_t hdrlen,
|
||||||
|
u8 *qos, u8 *pn, int keyid, size_t *encrypted_len);
|
||||||
|
|
||||||
|
u8* gcmp_decrypt(const u8 *tk, size_t tk_len, const struct ieee80211_hdr *hdr,
|
||||||
|
const u8 *data, size_t data_len, size_t *decrypted_len);
|
||||||
|
u8* gcmp_encrypt(const u8 *tk, size_t tk_len, const u8 *frame, size_t len,
|
||||||
|
size_t hdrlen, const u8 *qos,
|
||||||
|
const u8 *pn, int keyid, size_t *encrypted_len);
|
||||||
|
|
||||||
|
#endif /* WLANCRYPTO_WRAP_H */
|
||||||
3550
drivers/net/wireless/realtek/rtl8822ce/core/efuse/rtw_efuse.c
Normal file
3550
drivers/net/wireless/realtek/rtl8822ce/core/efuse/rtw_efuse.c
Normal file
File diff suppressed because it is too large
Load Diff
4386
drivers/net/wireless/realtek/rtl8822ce/core/mesh/rtw_mesh.c
Normal file
4386
drivers/net/wireless/realtek/rtl8822ce/core/mesh/rtw_mesh.c
Normal file
File diff suppressed because it is too large
Load Diff
536
drivers/net/wireless/realtek/rtl8822ce/core/mesh/rtw_mesh.h
Normal file
536
drivers/net/wireless/realtek/rtl8822ce/core/mesh/rtw_mesh.h
Normal file
@@ -0,0 +1,536 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __RTW_MESH_H_
|
||||||
|
#define __RTW_MESH_H_
|
||||||
|
|
||||||
|
#ifndef CONFIG_AP_MODE
|
||||||
|
#error "CONFIG_RTW_MESH can't be enabled when CONFIG_AP_MODE is not defined\n"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RTW_MESH_TTL 31
|
||||||
|
#define RTW_MESH_PERR_MIN_INT 100
|
||||||
|
#define RTW_MESH_DEFAULT_ELEMENT_TTL 31
|
||||||
|
#define RTW_MESH_RANN_INTERVAL 5000
|
||||||
|
#define RTW_MESH_PATH_TO_ROOT_TIMEOUT 6000
|
||||||
|
#define RTW_MESH_DIAM_TRAVERSAL_TIME 50
|
||||||
|
#define RTW_MESH_PATH_TIMEOUT 5000
|
||||||
|
#define RTW_MESH_PREQ_MIN_INT 10
|
||||||
|
#define RTW_MESH_MAX_PREQ_RETRIES 4
|
||||||
|
#define RTW_MESH_MIN_DISCOVERY_TIMEOUT (2 * RTW_MESH_DIAM_TRAVERSAL_TIME)
|
||||||
|
#define RTW_MESH_ROOT_CONFIRMATION_INTERVAL 2000
|
||||||
|
#define RTW_MESH_PATH_REFRESH_TIME 1000
|
||||||
|
#define RTW_MESH_ROOT_INTERVAL 5000
|
||||||
|
|
||||||
|
#define RTW_MESH_SANE_METRIC_DELTA 100
|
||||||
|
#define RTW_MESH_MAX_ROOT_ADD_CHK_CNT 2
|
||||||
|
|
||||||
|
#define RTW_MESH_PLINK_UNKNOWN 0
|
||||||
|
#define RTW_MESH_PLINK_LISTEN 1
|
||||||
|
#define RTW_MESH_PLINK_OPN_SNT 2
|
||||||
|
#define RTW_MESH_PLINK_OPN_RCVD 3
|
||||||
|
#define RTW_MESH_PLINK_CNF_RCVD 4
|
||||||
|
#define RTW_MESH_PLINK_ESTAB 5
|
||||||
|
#define RTW_MESH_PLINK_HOLDING 6
|
||||||
|
#define RTW_MESH_PLINK_BLOCKED 7
|
||||||
|
|
||||||
|
extern const char *_rtw_mesh_plink_str[];
|
||||||
|
#define rtw_mesh_plink_str(s) ((s <= RTW_MESH_PLINK_BLOCKED) ? _rtw_mesh_plink_str[s] : _rtw_mesh_plink_str[RTW_MESH_PLINK_UNKNOWN])
|
||||||
|
|
||||||
|
#define RTW_MESH_PS_UNKNOWN 0
|
||||||
|
#define RTW_MESH_PS_ACTIVE 1
|
||||||
|
#define RTW_MESH_PS_LSLEEP 2
|
||||||
|
#define RTW_MESH_PS_DSLEEP 3
|
||||||
|
|
||||||
|
extern const char *_rtw_mesh_ps_str[];
|
||||||
|
#define rtw_mesh_ps_str(mps) ((mps <= RTW_MESH_PS_DSLEEP) ? _rtw_mesh_ps_str[mps] : _rtw_mesh_ps_str[RTW_MESH_PS_UNKNOWN])
|
||||||
|
|
||||||
|
#define GET_MESH_CONF_ELE_PATH_SEL_PROTO_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 0, 0, 8)
|
||||||
|
#define GET_MESH_CONF_ELE_PATH_SEL_METRIC_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 1, 0, 8)
|
||||||
|
#define GET_MESH_CONF_ELE_CONGEST_CTRL_MODE_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 2, 0, 8)
|
||||||
|
#define GET_MESH_CONF_ELE_SYNC_METHOD_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 3, 0, 8)
|
||||||
|
#define GET_MESH_CONF_ELE_AUTH_PROTO_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 4, 0, 8)
|
||||||
|
|
||||||
|
#define GET_MESH_CONF_ELE_MESH_FORMATION(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 0, 8)
|
||||||
|
#define GET_MESH_CONF_ELE_CTO_MGATE(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 0, 1)
|
||||||
|
#define GET_MESH_CONF_ELE_NUM_OF_PEERINGS(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 1, 6)
|
||||||
|
#define GET_MESH_CONF_ELE_CTO_AS(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 7, 1)
|
||||||
|
|
||||||
|
#define GET_MESH_CONF_ELE_MESH_CAP(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 0, 8)
|
||||||
|
#define GET_MESH_CONF_ELE_ACCEPT_PEERINGS(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 0, 1)
|
||||||
|
#define GET_MESH_CONF_ELE_MCCA_SUP(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 1, 1)
|
||||||
|
#define GET_MESH_CONF_ELE_MCCA_EN(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 2, 1)
|
||||||
|
#define GET_MESH_CONF_ELE_FORWARDING(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 3, 1)
|
||||||
|
#define GET_MESH_CONF_ELE_MBCA_EN(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 4, 1)
|
||||||
|
#define GET_MESH_CONF_ELE_TBTT_ADJ(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 5, 1)
|
||||||
|
#define GET_MESH_CONF_ELE_PS_LEVEL(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 6, 1)
|
||||||
|
|
||||||
|
#define SET_MESH_CONF_ELE_PATH_SEL_PROTO_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 0, 0, 8, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_PATH_SEL_METRIC_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 1, 0, 8, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_CONGEST_CTRL_MODE_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 2, 0, 8, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_SYNC_METHOD_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 3, 0, 8, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_AUTH_PROTO_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 4, 0, 8, _val)
|
||||||
|
|
||||||
|
#define SET_MESH_CONF_ELE_CTO_MGATE(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 0, 1, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_NUM_OF_PEERINGS(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 1, 6, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_CTO_AS(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 7, 1, _val)
|
||||||
|
|
||||||
|
#define SET_MESH_CONF_ELE_ACCEPT_PEERINGS(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 0, 1, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_MCCA_SUP(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 1, 1, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_MCCA_EN(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 2, 1, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_FORWARDING(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 3, 1, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_MBCA_EN(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 4, 1, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_TBTT_ADJ(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 5, 1, _val)
|
||||||
|
#define SET_MESH_CONF_ELE_PS_LEVEL(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 6, 1, _val)
|
||||||
|
|
||||||
|
/* Mesh flags */
|
||||||
|
#define MESH_FLAGS_AE 0x3 /* mask */
|
||||||
|
#define MESH_FLAGS_AE_A4 0x1
|
||||||
|
#define MESH_FLAGS_AE_A5_A6 0x2
|
||||||
|
|
||||||
|
/* Max number of paths */
|
||||||
|
#define RTW_MESH_MAX_PATHS 1024
|
||||||
|
|
||||||
|
#define RTW_PREQ_Q_F_START 0x1
|
||||||
|
#define RTW_PREQ_Q_F_REFRESH 0x2
|
||||||
|
#define RTW_PREQ_Q_F_CHK 0x4
|
||||||
|
#define RTW_PREQ_Q_F_PEER_AKA 0x8
|
||||||
|
#define RTW_PREQ_Q_F_BCAST_PREQ 0x10 /* force path_dicover using broadcast */
|
||||||
|
struct rtw_mesh_preq_queue {
|
||||||
|
_list list;
|
||||||
|
u8 dst[ETH_ALEN];
|
||||||
|
u8 flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const u8 ae_to_mesh_ctrl_len[];
|
||||||
|
|
||||||
|
enum mesh_frame_type {
|
||||||
|
MESH_UCAST_DATA = 0x0,
|
||||||
|
MESH_BMCAST_DATA = 0x1,
|
||||||
|
MESH_UCAST_PX_DATA = 0x2,
|
||||||
|
MESH_BMCAST_PX_DATA = 0x3,
|
||||||
|
MESH_MHOP_UCAST_ACT = 0x4,
|
||||||
|
MESH_MHOP_BMCAST_ACT = 0x5,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum mpath_sel_frame_type {
|
||||||
|
MPATH_PREQ = 0,
|
||||||
|
MPATH_PREP,
|
||||||
|
MPATH_PERR,
|
||||||
|
MPATH_RANN
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum rtw_mesh_deferred_task_flags - mesh deferred tasks
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @RTW_MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
|
||||||
|
* @RTW_MESH_WORK_ROOT: the mesh root station needs to send a frame
|
||||||
|
* @RTW_MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
|
||||||
|
* mesh nodes
|
||||||
|
* @RTW_MESH_WORK_MBSS_CHANGED: rebuild beacon and notify driver of BSS changes
|
||||||
|
*/
|
||||||
|
enum rtw_mesh_deferred_task_flags {
|
||||||
|
RTW_MESH_WORK_HOUSEKEEPING,
|
||||||
|
RTW_MESH_WORK_ROOT,
|
||||||
|
RTW_MESH_WORK_DRIFT_ADJUST,
|
||||||
|
RTW_MESH_WORK_MBSS_CHANGED,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RTW_MESH_MAX_PEER_CANDIDATES 15 /* aid consideration */
|
||||||
|
#define RTW_MESH_MAX_PEER_LINKS 8
|
||||||
|
#define RTW_MESH_PEER_LINK_TIMEOUT 20
|
||||||
|
|
||||||
|
#define RTW_MESH_PEER_CONF_DISABLED 0 /* special time value means no confirmation ongoing */
|
||||||
|
#if CONFIG_RTW_MESH_PEER_BLACKLIST
|
||||||
|
#define IS_PEER_CONF_DISABLED(plink) ((plink)->peer_conf_end_time == RTW_MESH_PEER_CONF_DISABLED)
|
||||||
|
#define IS_PEER_CONF_TIMEOUT(plink)(!IS_PEER_CONF_DISABLED(plink) && rtw_time_after(rtw_get_current_time(), (plink)->peer_conf_end_time))
|
||||||
|
#define SET_PEER_CONF_DISABLED(plink) (plink)->peer_conf_end_time = RTW_MESH_PEER_CONF_DISABLED
|
||||||
|
#define SET_PEER_CONF_END_TIME(plink, timeout_ms) \
|
||||||
|
do { \
|
||||||
|
(plink)->peer_conf_end_time = rtw_get_current_time() + rtw_ms_to_systime(timeout_ms); \
|
||||||
|
if ((plink)->peer_conf_end_time == RTW_MESH_PEER_CONF_DISABLED) \
|
||||||
|
(plink)->peer_conf_end_time++; \
|
||||||
|
} while (0)
|
||||||
|
#else
|
||||||
|
#define IS_PEER_CONF_DISABLED(plink) 1
|
||||||
|
#define IS_PEER_CONF_TIMEOUT(plink) 0
|
||||||
|
#define SET_PEER_CONF_DISABLED(plink) do {} while (0)
|
||||||
|
#define SET_PEER_CONF_END_TIME(plink, timeout_ms) do {} while (0)
|
||||||
|
#endif /* CONFIG_RTW_MESH_PEER_BLACKLIST */
|
||||||
|
|
||||||
|
#define RTW_MESH_CTO_MGATE_CONF_DISABLED 0 /* special time value means no confirmation ongoing */
|
||||||
|
#if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
|
||||||
|
#define IS_CTO_MGATE_CONF_DISABLED(plink) ((plink)->cto_mgate_conf_end_time == RTW_MESH_CTO_MGATE_CONF_DISABLED)
|
||||||
|
#define IS_CTO_MGATE_CONF_TIMEOUT(plink)(!IS_CTO_MGATE_CONF_DISABLED(plink) && rtw_time_after(rtw_get_current_time(), (plink)->cto_mgate_conf_end_time))
|
||||||
|
#define SET_CTO_MGATE_CONF_DISABLED(plink) (plink)->cto_mgate_conf_end_time = RTW_MESH_CTO_MGATE_CONF_DISABLED
|
||||||
|
#define SET_CTO_MGATE_CONF_END_TIME(plink, timeout_ms) \
|
||||||
|
do { \
|
||||||
|
(plink)->cto_mgate_conf_end_time = rtw_get_current_time() + rtw_ms_to_systime(timeout_ms); \
|
||||||
|
if ((plink)->cto_mgate_conf_end_time == RTW_MESH_CTO_MGATE_CONF_DISABLED) \
|
||||||
|
(plink)->cto_mgate_conf_end_time++; \
|
||||||
|
} while (0)
|
||||||
|
#else
|
||||||
|
#define IS_CTO_MGATE_CONF_DISABLED(plink) 1
|
||||||
|
#define IS_CTO_MGATE_CONF_TIMEOUT(plink) 0
|
||||||
|
#define SET_CTO_MGATE_CONF_DISABLED(plink) do {} while (0)
|
||||||
|
#define SET_CTO_MGATE_CONF_END_TIME(plink, timeout_ms) do {} while (0)
|
||||||
|
#endif /* CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST */
|
||||||
|
|
||||||
|
struct mesh_plink_ent {
|
||||||
|
u8 valid;
|
||||||
|
u8 addr[ETH_ALEN];
|
||||||
|
u8 plink_state;
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_MESH_AEK
|
||||||
|
u8 aek_valid;
|
||||||
|
u8 aek[32];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
u16 llid;
|
||||||
|
u16 plid;
|
||||||
|
#ifndef CONFIG_RTW_MESH_DRIVER_AID
|
||||||
|
u16 aid; /* aid assigned from upper layer */
|
||||||
|
#endif
|
||||||
|
u16 peer_aid; /* aid assigned from peer */
|
||||||
|
|
||||||
|
u8 chosen_pmk[16];
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_MESH_AEK
|
||||||
|
u8 sel_pcs[4];
|
||||||
|
u8 l_nonce[32];
|
||||||
|
u8 p_nonce[32];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_MESH_DRIVER_AID
|
||||||
|
u8 *tx_conf_ies;
|
||||||
|
u16 tx_conf_ies_len;
|
||||||
|
#endif
|
||||||
|
u8 *rx_conf_ies;
|
||||||
|
u16 rx_conf_ies_len;
|
||||||
|
|
||||||
|
struct wlan_network *scanned;
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_PEER_BLACKLIST
|
||||||
|
systime peer_conf_end_time;
|
||||||
|
#endif
|
||||||
|
#if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
|
||||||
|
systime cto_mgate_conf_end_time;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_MESH_AEK
|
||||||
|
#define MESH_PLINK_AEK_VALID(ent) ent->aek_valid
|
||||||
|
#else
|
||||||
|
#define MESH_PLINK_AEK_VALID(ent) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct mesh_plink_pool {
|
||||||
|
_lock lock;
|
||||||
|
u8 num; /* current ent being used */
|
||||||
|
struct mesh_plink_ent ent[RTW_MESH_MAX_PEER_CANDIDATES];
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_ACNODE_PREVENT
|
||||||
|
u8 acnode_rsvd;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_PEER_BLACKLIST
|
||||||
|
_queue peer_blacklist;
|
||||||
|
#endif
|
||||||
|
#if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
|
||||||
|
_queue cto_mgate_blacklist;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mesh_peer_sel_policy {
|
||||||
|
u32 scanr_exp_ms;
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_ACNODE_PREVENT
|
||||||
|
u8 acnode_prevent;
|
||||||
|
u32 acnode_conf_timeout_ms;
|
||||||
|
u32 acnode_notify_timeout_ms;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_OFFCH_CAND
|
||||||
|
u8 offch_cand;
|
||||||
|
u32 offch_find_int_ms; /* 0 means no offch find triggerred by driver self*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_PEER_BLACKLIST
|
||||||
|
u32 peer_conf_timeout_ms;
|
||||||
|
u32 peer_blacklist_timeout_ms;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
|
||||||
|
u8 cto_mgate_require;
|
||||||
|
u32 cto_mgate_conf_timeout_ms;
|
||||||
|
u32 cto_mgate_blacklist_timeout_ms;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/* b2u flags */
|
||||||
|
#define RTW_MESH_B2U_ALL BIT0
|
||||||
|
#define RTW_MESH_B2U_GA_UCAST BIT1 /* Group addressed unicast frame, forward only */
|
||||||
|
#define RTW_MESH_B2U_BCAST BIT2
|
||||||
|
#define RTW_MESH_B2U_IP_MCAST BIT3
|
||||||
|
|
||||||
|
#define rtw_msrc_b2u_policy_chk(flags, mda) ( \
|
||||||
|
(flags & RTW_MESH_B2U_ALL) \
|
||||||
|
|| ((flags & RTW_MESH_B2U_BCAST) && is_broadcast_mac_addr(mda)) \
|
||||||
|
|| ((flags & RTW_MESH_B2U_IP_MCAST) && (IP_MCAST_MAC(mda) || ICMPV6_MCAST_MAC(mda))) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define rtw_mfwd_b2u_policy_chk(flags, mda, ucst) ( \
|
||||||
|
(flags & RTW_MESH_B2U_ALL) \
|
||||||
|
|| ((flags & RTW_MESH_B2U_GA_UCAST) && ucst) \
|
||||||
|
|| ((flags & RTW_MESH_B2U_BCAST) && is_broadcast_mac_addr(mda)) \
|
||||||
|
|| ((flags & RTW_MESH_B2U_IP_MCAST) && (IP_MCAST_MAC(mda) || ICMPV6_MCAST_MAC(mda))) \
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @sane_metric_delta: Controlling if trigger additional path check mechanism
|
||||||
|
* @max_root_add_chk_cnt: The retry cnt to send additional root confirmation
|
||||||
|
* PREQ through old(last) path
|
||||||
|
*/
|
||||||
|
struct rtw_mesh_cfg {
|
||||||
|
u8 max_peer_links; /* peering limit */
|
||||||
|
u32 plink_timeout; /* seconds */
|
||||||
|
|
||||||
|
u8 dot11MeshTTL;
|
||||||
|
u8 element_ttl;
|
||||||
|
u32 path_refresh_time;
|
||||||
|
u16 dot11MeshHWMPpreqMinInterval;
|
||||||
|
u16 dot11MeshHWMPnetDiameterTraversalTime;
|
||||||
|
u32 dot11MeshHWMPactivePathTimeout;
|
||||||
|
u8 dot11MeshHWMPmaxPREQretries;
|
||||||
|
u16 min_discovery_timeout;
|
||||||
|
u16 dot11MeshHWMPconfirmationInterval;
|
||||||
|
u16 dot11MeshHWMPperrMinInterval;
|
||||||
|
u8 dot11MeshHWMPRootMode;
|
||||||
|
BOOLEAN dot11MeshForwarding;
|
||||||
|
s32 rssi_threshold; /* in dBm, 0: no specified */
|
||||||
|
u16 dot11MeshHWMPRannInterval;
|
||||||
|
BOOLEAN dot11MeshGateAnnouncementProtocol;
|
||||||
|
u32 dot11MeshHWMPactivePathToRootTimeout;
|
||||||
|
u16 dot11MeshHWMProotInterval;
|
||||||
|
u8 path_gate_timeout_factor;
|
||||||
|
#ifdef CONFIG_RTW_MESH_ADD_ROOT_CHK
|
||||||
|
u16 sane_metric_delta;
|
||||||
|
u8 max_root_add_chk_cnt;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct mesh_peer_sel_policy peer_sel_policy;
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_DATA_BMC_TO_UC
|
||||||
|
u8 b2u_flags_msrc;
|
||||||
|
u8 b2u_flags_mfwd;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rtw_mesh_stats {
|
||||||
|
u32 fwded_mcast; /* Mesh forwarded multicast frames */
|
||||||
|
u32 fwded_unicast; /* Mesh forwarded unicast frames */
|
||||||
|
u32 fwded_frames; /* Mesh total forwarded frames */
|
||||||
|
u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
|
||||||
|
u32 dropped_frames_no_route; /* Not transmitted, no route found */
|
||||||
|
u32 dropped_frames_congestion;/* Not forwarded due to congestion */
|
||||||
|
u32 dropped_frames_duplicate;
|
||||||
|
|
||||||
|
u32 mrc_del_qlen; /* MRC entry deleted cause by queue length limit */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rtw_mrc;
|
||||||
|
|
||||||
|
struct rtw_mesh_info {
|
||||||
|
u8 mesh_id[NDIS_802_11_LENGTH_SSID];
|
||||||
|
size_t mesh_id_len;
|
||||||
|
/* Active Path Selection Protocol Identifier */
|
||||||
|
u8 mesh_pp_id;
|
||||||
|
/* Active Path Selection Metric Identifier */
|
||||||
|
u8 mesh_pm_id;
|
||||||
|
/* Congestion Control Mode Identifier */
|
||||||
|
u8 mesh_cc_id;
|
||||||
|
/* Synchronization Protocol Identifier */
|
||||||
|
u8 mesh_sp_id;
|
||||||
|
/* Authentication Protocol Identifier */
|
||||||
|
u8 mesh_auth_id;
|
||||||
|
|
||||||
|
struct mesh_plink_pool plink_ctl;
|
||||||
|
|
||||||
|
u32 mesh_seqnum;
|
||||||
|
/* MSTA's own hwmp sequence number */
|
||||||
|
u32 sn;
|
||||||
|
systime last_preq;
|
||||||
|
systime last_sn_update;
|
||||||
|
systime next_perr;
|
||||||
|
/* Last used Path Discovery ID */
|
||||||
|
u32 preq_id;
|
||||||
|
|
||||||
|
ATOMIC_T mpaths;
|
||||||
|
struct rtw_mesh_table *mesh_paths;
|
||||||
|
struct rtw_mesh_table *mpp_paths;
|
||||||
|
int mesh_paths_generation;
|
||||||
|
int mpp_paths_generation;
|
||||||
|
|
||||||
|
int num_gates;
|
||||||
|
struct rtw_mesh_path *max_addr_gate;
|
||||||
|
bool max_addr_gate_is_larger_than_self;
|
||||||
|
|
||||||
|
struct rtw_mesh_stats mshstats;
|
||||||
|
|
||||||
|
_queue mpath_tx_queue;
|
||||||
|
u32 mpath_tx_queue_len;
|
||||||
|
_tasklet mpath_tx_tasklet;
|
||||||
|
|
||||||
|
struct rtw_mrc *mrc;
|
||||||
|
|
||||||
|
_lock mesh_preq_queue_lock;
|
||||||
|
struct rtw_mesh_preq_queue preq_queue;
|
||||||
|
int preq_queue_len;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const char *_action_self_protected_str[];
|
||||||
|
#define action_self_protected_str(action) ((action < RTW_ACT_SELF_PROTECTED_NUM) ? _action_self_protected_str[action] : _action_self_protected_str[0])
|
||||||
|
|
||||||
|
u8 *rtw_set_ie_mesh_id(u8 *buf, u32 *buf_len, const char *mesh_id, u8 id_len);
|
||||||
|
u8 *rtw_set_ie_mesh_config(u8 *buf, u32 *buf_len
|
||||||
|
, u8 path_sel_proto, u8 path_sel_metric, u8 congest_ctl_mode, u8 sync_method, u8 auth_proto
|
||||||
|
, u8 num_of_peerings, bool cto_mgate, bool cto_as
|
||||||
|
, bool accept_peerings, bool mcca_sup, bool mcca_en, bool forwarding
|
||||||
|
, bool mbca_en, bool tbtt_adj, bool ps_level);
|
||||||
|
|
||||||
|
int rtw_bss_is_same_mbss(WLAN_BSSID_EX *a, WLAN_BSSID_EX *b);
|
||||||
|
int rtw_bss_is_candidate_mesh_peer(_adapter *adapter, WLAN_BSSID_EX *target, u8 ch, u8 add_peer);
|
||||||
|
|
||||||
|
void rtw_chk_candidate_peer_notify(_adapter *adapter, struct wlan_network *scanned);
|
||||||
|
|
||||||
|
void rtw_mesh_peer_status_chk(_adapter *adapter);
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_ACNODE_PREVENT
|
||||||
|
void rtw_mesh_update_scanned_acnode_status(_adapter *adapter, struct wlan_network *scanned);
|
||||||
|
bool rtw_mesh_scanned_is_acnode_confirmed(_adapter *adapter, struct wlan_network *scanned);
|
||||||
|
bool rtw_mesh_acnode_prevent_allow_sacrifice(_adapter *adapter);
|
||||||
|
struct sta_info *rtw_mesh_acnode_prevent_pick_sacrifice(_adapter *adapter);
|
||||||
|
void dump_mesh_acnode_prevent_settings(void *sel, _adapter *adapter);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_OFFCH_CAND
|
||||||
|
u8 rtw_mesh_offch_candidate_accepted(_adapter *adapter);
|
||||||
|
u8 rtw_mesh_select_operating_ch(_adapter *adapter);
|
||||||
|
void dump_mesh_offch_cand_settings(void *sel, _adapter *adapter);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_PEER_BLACKLIST
|
||||||
|
int rtw_mesh_peer_blacklist_add(_adapter *adapter, const u8 *addr);
|
||||||
|
int rtw_mesh_peer_blacklist_del(_adapter *adapter, const u8 *addr);
|
||||||
|
int rtw_mesh_peer_blacklist_search(_adapter *adapter, const u8 *addr);
|
||||||
|
void rtw_mesh_peer_blacklist_flush(_adapter *adapter);
|
||||||
|
void dump_mesh_peer_blacklist(void *sel, _adapter *adapter);
|
||||||
|
void dump_mesh_peer_blacklist_settings(void *sel, _adapter *adapter);
|
||||||
|
#endif
|
||||||
|
#if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
|
||||||
|
u8 rtw_mesh_cto_mgate_required(_adapter *adapter);
|
||||||
|
u8 rtw_mesh_cto_mgate_network_filter(_adapter *adapter, struct wlan_network *scanned);
|
||||||
|
int rtw_mesh_cto_mgate_blacklist_add(_adapter *adapter, const u8 *addr);
|
||||||
|
int rtw_mesh_cto_mgate_blacklist_del(_adapter *adapter, const u8 *addr);
|
||||||
|
int rtw_mesh_cto_mgate_blacklist_search(_adapter *adapter, const u8 *addr);
|
||||||
|
void rtw_mesh_cto_mgate_blacklist_flush(_adapter *adapter);
|
||||||
|
void dump_mesh_cto_mgate_blacklist(void *sel, _adapter *adapter);
|
||||||
|
void dump_mesh_cto_mgate_blacklist_settings(void *sel, _adapter *adapter);
|
||||||
|
#endif
|
||||||
|
void dump_mesh_peer_sel_policy(void *sel, _adapter *adapter);
|
||||||
|
void dump_mesh_networks(void *sel, _adapter *adapter);
|
||||||
|
|
||||||
|
void rtw_mesh_adjust_chbw(u8 req_ch, u8 *req_bw, u8 *req_offset);
|
||||||
|
|
||||||
|
void rtw_mesh_sae_check_frames(_adapter *adapter, const u8 *buf, u32 len, u8 tx, u16 alg, u16 seq, u16 status);
|
||||||
|
int rtw_mesh_check_frames_tx(_adapter *adapter, const u8 **buf, size_t *len);
|
||||||
|
int rtw_mesh_check_frames_rx(_adapter *adapter, const u8 *buf, size_t len);
|
||||||
|
|
||||||
|
int rtw_mesh_on_auth(_adapter *adapter, union recv_frame *rframe);
|
||||||
|
unsigned int on_action_self_protected(_adapter *adapter, union recv_frame *rframe);
|
||||||
|
|
||||||
|
bool rtw_mesh_update_bss_peering_status(_adapter *adapter, WLAN_BSSID_EX *bss);
|
||||||
|
bool rtw_mesh_update_bss_formation_info(_adapter *adapter, WLAN_BSSID_EX *bss);
|
||||||
|
bool rtw_mesh_update_bss_forwarding_state(_adapter *adapter, WLAN_BSSID_EX *bss);
|
||||||
|
|
||||||
|
struct mesh_plink_ent *_rtw_mesh_plink_get(_adapter *adapter, const u8 *hwaddr);
|
||||||
|
struct mesh_plink_ent *rtw_mesh_plink_get(_adapter *adapter, const u8 *hwaddr);
|
||||||
|
struct mesh_plink_ent *rtw_mesh_plink_get_no_estab_by_idx(_adapter *adapter, u8 idx);
|
||||||
|
int _rtw_mesh_plink_add(_adapter *adapter, const u8 *hwaddr);
|
||||||
|
int rtw_mesh_plink_add(_adapter *adapter, const u8 *hwaddr);
|
||||||
|
int rtw_mesh_plink_set_state(_adapter *adapter, const u8 *hwaddr, u8 state);
|
||||||
|
#ifdef CONFIG_RTW_MESH_AEK
|
||||||
|
int rtw_mesh_plink_set_aek(_adapter *adapter, const u8 *hwaddr, const u8 *aek);
|
||||||
|
#endif
|
||||||
|
#if CONFIG_RTW_MESH_PEER_BLACKLIST
|
||||||
|
int rtw_mesh_plink_set_peer_conf_timeout(_adapter *adapter, const u8 *hwaddr);
|
||||||
|
#endif
|
||||||
|
void _rtw_mesh_plink_del_ent(_adapter *adapter, struct mesh_plink_ent *ent);
|
||||||
|
int rtw_mesh_plink_del(_adapter *adapter, const u8 *hwaddr);
|
||||||
|
void rtw_mesh_plink_ctl_init(_adapter *adapter);
|
||||||
|
void rtw_mesh_plink_ctl_deinit(_adapter *adapter);
|
||||||
|
void dump_mesh_plink_ctl(void *sel, _adapter *adapter);
|
||||||
|
|
||||||
|
u8 rtw_mesh_set_plink_state_cmd(_adapter *adapter, const u8 *mac, u8 plink_state);
|
||||||
|
|
||||||
|
void _rtw_mesh_expire_peer_ent(_adapter *adapter, struct mesh_plink_ent *plink);
|
||||||
|
void rtw_mesh_expire_peer(_adapter *adapter, const u8 *peer_addr);
|
||||||
|
u8 rtw_mesh_ps_annc(_adapter *adapter, u8 ps);
|
||||||
|
|
||||||
|
unsigned int on_action_mesh(_adapter *adapter, union recv_frame *rframe);
|
||||||
|
|
||||||
|
void rtw_mesh_cfg_init(_adapter *adapter);
|
||||||
|
void rtw_mesh_cfg_init_max_peer_links(_adapter *adapter, u8 stack_conf);
|
||||||
|
void rtw_mesh_cfg_init_plink_timeout(_adapter *adapter, u32 stack_conf);
|
||||||
|
void rtw_mesh_init_mesh_info(_adapter *adapter);
|
||||||
|
void rtw_mesh_deinit_mesh_info(_adapter *adapter);
|
||||||
|
|
||||||
|
#if CONFIG_RTW_MESH_DATA_BMC_TO_UC
|
||||||
|
void dump_mesh_b2u_flags(void *sel, _adapter *adapter);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int rtw_mesh_addr_resolve(_adapter *adapter, struct xmit_frame *xframe, _pkt *pkt, _list *b2u_list);
|
||||||
|
|
||||||
|
s8 rtw_mesh_tx_set_whdr_mctrl_len(u8 mesh_frame_mode, struct pkt_attrib *attrib);
|
||||||
|
void rtw_mesh_tx_build_mctrl(_adapter *adapter, struct pkt_attrib *attrib, u8 *buf);
|
||||||
|
u8 rtw_mesh_tx_build_whdr(_adapter *adapter, struct pkt_attrib *attrib
|
||||||
|
, u16 *fctrl, struct rtw_ieee80211_hdr *whdr);
|
||||||
|
|
||||||
|
int rtw_mesh_rx_data_validate_hdr(_adapter *adapter, union recv_frame *rframe, struct sta_info **sta);
|
||||||
|
int rtw_mesh_rx_data_validate_mctrl(_adapter *adapter, union recv_frame *rframe
|
||||||
|
, const struct rtw_ieee80211s_hdr *mctrl, const u8 *mda, const u8 *msa
|
||||||
|
, u8 *mctrl_len, const u8 **da, const u8 **sa);
|
||||||
|
int rtw_mesh_rx_validate_mctrl_non_amsdu(_adapter *adapter, union recv_frame *rframe);
|
||||||
|
|
||||||
|
int rtw_mesh_rx_msdu_act_check(union recv_frame *rframe
|
||||||
|
, const u8 *mda, const u8 *msa
|
||||||
|
, const u8 *da, const u8 *sa
|
||||||
|
, struct rtw_ieee80211s_hdr *mctrl
|
||||||
|
, struct xmit_frame **fwd_frame, _list *b2u_list);
|
||||||
|
|
||||||
|
void dump_mesh_stats(void *sel, _adapter *adapter);
|
||||||
|
|
||||||
|
#if defined(PLATFORM_LINUX) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32))
|
||||||
|
#define rtw_lockdep_assert_held(l) lockdep_assert_held(l)
|
||||||
|
#define rtw_lockdep_is_held(l) lockdep_is_held(l)
|
||||||
|
#else
|
||||||
|
#error "TBD\n"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "rtw_mesh_pathtbl.h"
|
||||||
|
#include "rtw_mesh_hwmp.h"
|
||||||
|
#endif /* __RTW_MESH_H_ */
|
||||||
|
|
||||||
1674
drivers/net/wireless/realtek/rtl8822ce/core/mesh/rtw_mesh_hwmp.c
Normal file
1674
drivers/net/wireless/realtek/rtl8822ce/core/mesh/rtw_mesh_hwmp.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __RTW_MESH_HWMP_H_
|
||||||
|
#define __RTW_MESH_HWMP_H_
|
||||||
|
|
||||||
|
#ifndef DBG_RTW_HWMP
|
||||||
|
#define DBG_RTW_HWMP 0
|
||||||
|
#endif
|
||||||
|
#if DBG_RTW_HWMP
|
||||||
|
#define RTW_HWMP_DBG(fmt, arg...) RTW_PRINT(fmt, ##arg)
|
||||||
|
#else
|
||||||
|
#define RTW_HWMP_DBG(fmt, arg...) RTW_DBG(fmt, ##arg)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INFO_RTW_HWMP
|
||||||
|
#define INFO_RTW_HWMP 0
|
||||||
|
#endif
|
||||||
|
#if INFO_RTW_HWMP
|
||||||
|
#define RTW_HWMP_INFO(fmt, arg...) RTW_PRINT(fmt, ##arg)
|
||||||
|
#else
|
||||||
|
#define RTW_HWMP_INFO(fmt, arg...) RTW_INFO(fmt, ##arg)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void rtw_ewma_err_rate_init(struct rtw_ewma_err_rate *e);
|
||||||
|
unsigned long rtw_ewma_err_rate_read(struct rtw_ewma_err_rate *e);
|
||||||
|
void rtw_ewma_err_rate_add(struct rtw_ewma_err_rate *e, unsigned long val);
|
||||||
|
int rtw_mesh_path_error_tx(_adapter *adapter,
|
||||||
|
u8 ttl, const u8 *target, u32 target_sn,
|
||||||
|
u16 target_rcode, const u8 *ra);
|
||||||
|
void rtw_ieee80211s_update_metric(_adapter *adapter, u8 mac_id,
|
||||||
|
u8 per, u8 rate,
|
||||||
|
u8 bw, u8 total_pkt);
|
||||||
|
void rtw_mesh_rx_path_sel_frame(_adapter *adapter, union recv_frame *rframe);
|
||||||
|
void rtw_mesh_queue_preq(struct rtw_mesh_path *mpath, u8 flags);
|
||||||
|
void rtw_mesh_path_start_discovery(_adapter *adapter);
|
||||||
|
void rtw_mesh_path_timer(void *ctx);
|
||||||
|
void rtw_mesh_path_tx_root_frame(_adapter *adapter);
|
||||||
|
void rtw_mesh_work_hdl(_workitem *work);
|
||||||
|
void rtw_ieee80211_mesh_path_timer(void *ctx);
|
||||||
|
void rtw_ieee80211_mesh_path_root_timer(void *ctx);
|
||||||
|
BOOLEAN rtw_ieee80211_mesh_root_setup(_adapter *adapter);
|
||||||
|
void rtw_mesh_work(_workitem *work);
|
||||||
|
void rtw_mesh_atlm_param_req_timer(void *ctx);
|
||||||
|
|
||||||
|
#endif /* __RTW_MESH_HWMP_H_ */
|
||||||
|
|
||||||
|
|
||||||
1242
drivers/net/wireless/realtek/rtl8822ce/core/mesh/rtw_mesh_pathtbl.c
Normal file
1242
drivers/net/wireless/realtek/rtl8822ce/core/mesh/rtw_mesh_pathtbl.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,211 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __RTW_MESH_PATHTBL_H_
|
||||||
|
#define __RTW_MESH_PATHTBL_H_
|
||||||
|
|
||||||
|
#ifndef DBG_RTW_MPATH
|
||||||
|
#define DBG_RTW_MPATH 1
|
||||||
|
#endif
|
||||||
|
#if DBG_RTW_MPATH
|
||||||
|
#define RTW_MPATH_DBG(fmt, arg...) RTW_PRINT(fmt, ##arg)
|
||||||
|
#else
|
||||||
|
#define RTW_MPATH_DBG(fmt, arg...) do {} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum rtw_mesh_path_flags - mesh path flags
|
||||||
|
*
|
||||||
|
* @RTW_MESH_PATH_ACTIVE: the mesh path can be used for forwarding
|
||||||
|
* @RTW_MESH_PATH_RESOLVING: the discovery process is running for this mesh path
|
||||||
|
* @RTW_MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence
|
||||||
|
* number
|
||||||
|
* @RTW_MESH_PATH_FIXED: the mesh path has been manually set and should not be
|
||||||
|
* modified
|
||||||
|
* @RTW_MESH_PATH_RESOLVED: the mesh path can has been resolved
|
||||||
|
* @RTW_MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination
|
||||||
|
* already queued up, waiting for the discovery process to start.
|
||||||
|
* @RTW_MESH_PATH_DELETED: the mesh path has been deleted and should no longer
|
||||||
|
* be used
|
||||||
|
* @RTW_MESH_PATH_ROOT_ADD_CHK: root additional check in root mode.
|
||||||
|
* With this flag, It will try the last used rann_snd_addr
|
||||||
|
* @RTW_MESH_PATH_PEER_AKA: only used toward a peer, only used in active keep
|
||||||
|
* alive mechanism. PREQ's da = path dst
|
||||||
|
* @RTW_MESH_PATH_BCAST_PREQ: for re-checking next hop resolve toward root.
|
||||||
|
* Use it to force path_discover sending broadcast PREQ for root.
|
||||||
|
*
|
||||||
|
* RTW_MESH_PATH_RESOLVED is used by the mesh path timer to
|
||||||
|
* decide when to stop or cancel the mesh path discovery.
|
||||||
|
*/
|
||||||
|
enum rtw_mesh_path_flags {
|
||||||
|
RTW_MESH_PATH_ACTIVE = BIT(0),
|
||||||
|
RTW_MESH_PATH_RESOLVING = BIT(1),
|
||||||
|
RTW_MESH_PATH_SN_VALID = BIT(2),
|
||||||
|
RTW_MESH_PATH_FIXED = BIT(3),
|
||||||
|
RTW_MESH_PATH_RESOLVED = BIT(4),
|
||||||
|
RTW_MESH_PATH_REQ_QUEUED = BIT(5),
|
||||||
|
RTW_MESH_PATH_DELETED = BIT(6),
|
||||||
|
RTW_MESH_PATH_ROOT_ADD_CHK = BIT(7),
|
||||||
|
RTW_MESH_PATH_PEER_AKA = BIT(8),
|
||||||
|
RTW_MESH_PATH_BCAST_PREQ = BIT(9),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct rtw_mesh_path - mesh path structure
|
||||||
|
*
|
||||||
|
* @dst: mesh path destination mac address
|
||||||
|
* @mpp: mesh proxy mac address
|
||||||
|
* @rhash: rhashtable list pointer
|
||||||
|
* @gate_list: list pointer for known gates list
|
||||||
|
* @sdata: mesh subif
|
||||||
|
* @next_hop: mesh neighbor to which frames for this destination will be
|
||||||
|
* forwarded
|
||||||
|
* @timer: mesh path discovery timer
|
||||||
|
* @frame_queue: pending queue for frames sent to this destination while the
|
||||||
|
* path is unresolved
|
||||||
|
* @rcu: rcu head for freeing mesh path
|
||||||
|
* @sn: target sequence number
|
||||||
|
* @metric: current metric to this destination
|
||||||
|
* @hop_count: hops to destination
|
||||||
|
* @exp_time: in jiffies, when the path will expire or when it expired
|
||||||
|
* @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
|
||||||
|
* retry
|
||||||
|
* @discovery_retries: number of discovery retries
|
||||||
|
* @flags: mesh path flags, as specified on &enum rtw_mesh_path_flags
|
||||||
|
* @state_lock: mesh path state lock used to protect changes to the
|
||||||
|
* mpath itself. No need to take this lock when adding or removing
|
||||||
|
* an mpath to a hash bucket on a path table.
|
||||||
|
* @rann_snd_addr: the RANN sender address
|
||||||
|
* @rann_metric: the aggregated path metric towards the root node
|
||||||
|
* @last_preq_to_root: Timestamp of last PREQ sent to root
|
||||||
|
* @is_root: the destination station of this path is a root node
|
||||||
|
* @is_gate: the destination station of this path is a mesh gate
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* The dst address is unique in the mesh path table. Since the mesh_path is
|
||||||
|
* protected by RCU, deleting the next_hop STA must remove / substitute the
|
||||||
|
* mesh_path structure and wait until that is no longer reachable before
|
||||||
|
* destroying the STA completely.
|
||||||
|
*/
|
||||||
|
struct rtw_mesh_path {
|
||||||
|
u8 dst[ETH_ALEN];
|
||||||
|
u8 mpp[ETH_ALEN]; /* used for MPP or MAP */
|
||||||
|
rtw_rhash_head rhash;
|
||||||
|
rtw_hlist_node gate_list;
|
||||||
|
_adapter *adapter;
|
||||||
|
struct sta_info __rcu *next_hop;
|
||||||
|
_timer timer;
|
||||||
|
_queue frame_queue;
|
||||||
|
u32 frame_queue_len;
|
||||||
|
rtw_rcu_head rcu;
|
||||||
|
u32 sn;
|
||||||
|
u32 metric;
|
||||||
|
u8 hop_count;
|
||||||
|
systime exp_time;
|
||||||
|
systime discovery_timeout;
|
||||||
|
systime gate_timeout;
|
||||||
|
u32 gate_ann_int; /* gate announce interval */
|
||||||
|
u8 discovery_retries;
|
||||||
|
enum rtw_mesh_path_flags flags;
|
||||||
|
_lock state_lock;
|
||||||
|
u8 rann_snd_addr[ETH_ALEN];
|
||||||
|
#ifdef CONFIG_RTW_MESH_ADD_ROOT_CHK
|
||||||
|
u8 add_chk_rann_snd_addr[ETH_ALEN];
|
||||||
|
#endif
|
||||||
|
u32 rann_metric;
|
||||||
|
unsigned long last_preq_to_root;
|
||||||
|
bool is_root;
|
||||||
|
bool is_gate;
|
||||||
|
bool gate_asked;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct rtw_mesh_table
|
||||||
|
*
|
||||||
|
* @known_gates: list of known mesh gates and their mpaths by the station. The
|
||||||
|
* gate's mpath may or may not be resolved and active.
|
||||||
|
* @gates_lock: protects updates to known_gates
|
||||||
|
* @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr
|
||||||
|
* @entries: number of entries in the table
|
||||||
|
*/
|
||||||
|
struct rtw_mesh_table {
|
||||||
|
rtw_hlist_head known_gates;
|
||||||
|
_lock gates_lock;
|
||||||
|
rtw_rhashtable rhead;
|
||||||
|
ATOMIC_T entries;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RTW_MESH_PATH_EXPIRE (600 * HZ)
|
||||||
|
|
||||||
|
/* Maximum number of paths per interface */
|
||||||
|
#define RTW_MESH_MAX_MPATHS 1024
|
||||||
|
|
||||||
|
/* Number of frames buffered per destination for unresolved destinations */
|
||||||
|
#define RTW_MESH_FRAME_QUEUE_LEN 10
|
||||||
|
|
||||||
|
int rtw_mesh_nexthop_lookup(_adapter *adapter,
|
||||||
|
const u8 *mda, const u8 *msa, u8 *ra);
|
||||||
|
int rtw_mesh_nexthop_resolve(_adapter *adapter,
|
||||||
|
struct xmit_frame *xframe);
|
||||||
|
|
||||||
|
struct rtw_mesh_path *rtw_mesh_path_lookup(_adapter *adapter,
|
||||||
|
const u8 *dst);
|
||||||
|
struct rtw_mesh_path *rtw_mpp_path_lookup(_adapter *adapter,
|
||||||
|
const u8 *dst);
|
||||||
|
int rtw_mpp_path_add(_adapter *adapter,
|
||||||
|
const u8 *dst, const u8 *mpp);
|
||||||
|
void dump_mpp(void *sel, _adapter *adapter);
|
||||||
|
|
||||||
|
struct rtw_mesh_path *
|
||||||
|
rtw_mesh_path_lookup_by_idx(_adapter *adapter, int idx);
|
||||||
|
void dump_mpath(void *sel, _adapter *adapter);
|
||||||
|
|
||||||
|
struct rtw_mesh_path *
|
||||||
|
rtw_mpp_path_lookup_by_idx(_adapter *adapter, int idx);
|
||||||
|
void rtw_mesh_path_fix_nexthop(struct rtw_mesh_path *mpath, struct sta_info *next_hop);
|
||||||
|
void rtw_mesh_path_expire(_adapter *adapter);
|
||||||
|
|
||||||
|
struct rtw_mesh_path *
|
||||||
|
rtw_mesh_path_add(_adapter *adapter, const u8 *dst);
|
||||||
|
|
||||||
|
int rtw_mesh_path_add_gate(struct rtw_mesh_path *mpath);
|
||||||
|
void rtw_mesh_gate_del(struct rtw_mesh_table *tbl, struct rtw_mesh_path *mpath);
|
||||||
|
bool rtw_mesh_gate_search(struct rtw_mesh_table *tbl, const u8 *addr);
|
||||||
|
int rtw_mesh_path_send_to_gates(struct rtw_mesh_path *mpath);
|
||||||
|
int rtw_mesh_gate_num(_adapter *adapter);
|
||||||
|
bool rtw_mesh_is_primary_gate(_adapter *adapter);
|
||||||
|
void dump_known_gates(void *sel, _adapter *adapter);
|
||||||
|
|
||||||
|
void rtw_mesh_plink_broken(struct sta_info *sta);
|
||||||
|
|
||||||
|
void rtw_mesh_path_assign_nexthop(struct rtw_mesh_path *mpath, struct sta_info *sta);
|
||||||
|
void rtw_mesh_path_flush_pending(struct rtw_mesh_path *mpath);
|
||||||
|
void rtw_mesh_path_tx_pending(struct rtw_mesh_path *mpath);
|
||||||
|
int rtw_mesh_pathtbl_init(_adapter *adapter);
|
||||||
|
void rtw_mesh_pathtbl_unregister(_adapter *adapter);
|
||||||
|
int rtw_mesh_path_del(_adapter *adapter, const u8 *addr);
|
||||||
|
|
||||||
|
void rtw_mesh_path_flush_by_nexthop(struct sta_info *sta);
|
||||||
|
void rtw_mesh_path_discard_frame(_adapter *adapter,
|
||||||
|
struct xmit_frame *xframe);
|
||||||
|
|
||||||
|
static inline void rtw_mesh_path_activate(struct rtw_mesh_path *mpath)
|
||||||
|
{
|
||||||
|
mpath->flags |= RTW_MESH_PATH_ACTIVE | RTW_MESH_PATH_RESOLVED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_mesh_path_flush_by_iface(_adapter *adapter);
|
||||||
|
|
||||||
|
#endif /* __RTW_MESH_PATHTBL_H_ */
|
||||||
|
|
||||||
@@ -0,0 +1,615 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#define _RTW_RADIOTAP_C_
|
||||||
|
|
||||||
|
#ifdef CONFIG_WIFI_MONITOR
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
|
||||||
|
#define CHAN2FREQ(a) ((a < 14) ? (2407+5*a) : (5000+5*a))
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0))
|
||||||
|
#define IEEE80211_RADIOTAP_ZERO_LEN_PSDU 26
|
||||||
|
#define IEEE80211_RADIOTAP_LSIG 27
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0))
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP 22
|
||||||
|
/* For IEEE80211_RADIOTAP_TIMESTAMP */
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MASK 0x000F
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MS 0x0000
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US 0x0001
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_UNIT_NS 0x0003
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_SPOS_MASK 0x00F0
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_SPOS_BEGIN_MDPU 0x0000
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_MPDU 0x0010
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_PPDU 0x0020
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ 0x0030
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_SPOS_UNKNOWN 0x00F0
|
||||||
|
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_FLAG_64BIT 0x00
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_FLAG_32BIT 0x01
|
||||||
|
#define IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY 0x02
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0))
|
||||||
|
/* for IEEE80211_RADIOTAP_CHANNEL */
|
||||||
|
#define IEEE80211_CHAN_GSM 0x1000 /* GSM (900 MHz) */
|
||||||
|
#define IEEE80211_CHAN_STURBO 0x2000 /* Static Turbo */
|
||||||
|
#define IEEE80211_CHAN_HALF 0x4000 /* Half channel (10 MHz wide) */
|
||||||
|
#define IEEE80211_CHAN_QUARTER 0x8000 /* Quarter channel (5 MHz wide) */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0))
|
||||||
|
#define IEEE80211_RADIOTAP_VHT 21
|
||||||
|
/* For IEEE80211_RADIOTAP_VHT */
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_STBC 0x0001
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA 0x0002
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_GI 0x0004
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS 0x0008
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM 0x0010
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED 0x0020
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH 0x0040
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID 0x0080
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID 0x0100
|
||||||
|
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_FLAG_STBC 0x01
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA 0x02
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_FLAG_SGI 0x04
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9 0x08
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM 0x10
|
||||||
|
#define IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED 0x20
|
||||||
|
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0))
|
||||||
|
#define IEEE80211_RADIOTAP_CODING_LDPC_USER0 0x01
|
||||||
|
#define IEEE80211_RADIOTAP_CODING_LDPC_USER1 0x02
|
||||||
|
#define IEEE80211_RADIOTAP_CODING_LDPC_USER2 0x04
|
||||||
|
#define IEEE80211_RADIOTAP_CODING_LDPC_USER3 0x08
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0))
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_STATUS 20
|
||||||
|
/* For IEEE80211_RADIOTAP_AMPDU_STATUS */
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020
|
||||||
|
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0))
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_EOF 0x0040
|
||||||
|
#define IEEE80211_RADIOTAP_AMPDU_EOF_KNOWN 0x0080
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39))
|
||||||
|
#define IEEE80211_RADIOTAP_MCS 19
|
||||||
|
/* For IEEE80211_RADIOTAP_MCS */
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10
|
||||||
|
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_BW_20 0
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_BW_40 1
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_BW_20L 2
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_BW_20U 3
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_SGI 0x04
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
|
||||||
|
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0))
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_HAVE_STBC 0x20
|
||||||
|
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_STBC_1 1
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_STBC_2 2
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_STBC_3 3
|
||||||
|
#define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34))
|
||||||
|
#define IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE 29
|
||||||
|
#define IEEE80211_RADIOTAP_VENDOR_NAMESPACE 30
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30))
|
||||||
|
#define IEEE80211_RADIOTAP_F_BADFCS 0x40
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline void _rtw_radiotap_fill_flags(struct rx_pkt_attrib *a, u8 *flags)
|
||||||
|
{
|
||||||
|
struct moinfo *moif = (struct moinfo *)&a->moif;
|
||||||
|
|
||||||
|
if (0)
|
||||||
|
*flags |= IEEE80211_RADIOTAP_F_CFP;
|
||||||
|
|
||||||
|
if (0)
|
||||||
|
*flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
|
||||||
|
|
||||||
|
if ((a->encrypt == 1) || (a->encrypt == 5))
|
||||||
|
*flags |= IEEE80211_RADIOTAP_F_WEP;
|
||||||
|
|
||||||
|
if (a->mfrag)
|
||||||
|
*flags |= IEEE80211_RADIOTAP_F_FRAG;
|
||||||
|
|
||||||
|
if (1)
|
||||||
|
*flags |= IEEE80211_RADIOTAP_F_FCS;
|
||||||
|
|
||||||
|
if (0)
|
||||||
|
*flags |= IEEE80211_RADIOTAP_F_DATAPAD;
|
||||||
|
|
||||||
|
if (a->crc_err)
|
||||||
|
*flags |= IEEE80211_RADIOTAP_F_BADFCS;
|
||||||
|
|
||||||
|
/* Currently unspecified but used
|
||||||
|
for short guard interval (HT) */
|
||||||
|
if (moif->u.snif_info.sgi || a->sgi)
|
||||||
|
*flags |= 0x80;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sint rtw_fill_radiotap_hdr(_adapter *padapter, struct rx_pkt_attrib *a, u8 *buf)
|
||||||
|
{
|
||||||
|
#define RTAP_HDR_MAX 64
|
||||||
|
|
||||||
|
sint ret = _SUCCESS;
|
||||||
|
struct moinfo *moif = (struct moinfo *)&a->moif;
|
||||||
|
|
||||||
|
u8 rx_cnt = 0;
|
||||||
|
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
u8 tmp_8bit = 0;
|
||||||
|
u16 tmp_16bit = 0;
|
||||||
|
u32 tmp_32bit = 0;
|
||||||
|
u64 tmp_64bit = 0;
|
||||||
|
|
||||||
|
_pkt *pskb = NULL;
|
||||||
|
|
||||||
|
struct ieee80211_radiotap_header *rtap_hdr = NULL;
|
||||||
|
u8 *ptr = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
radiotap length (include header 8)
|
||||||
|
11G length: 36 (0x0040002f)
|
||||||
|
11N length:
|
||||||
|
11AC length: 60 (0x0070002b)
|
||||||
|
*/
|
||||||
|
u8 hdr_buf[RTAP_HDR_MAX] = { 0 };
|
||||||
|
u16 rt_len = 8;
|
||||||
|
|
||||||
|
/* create header */
|
||||||
|
rtap_hdr = (struct ieee80211_radiotap_header *)&hdr_buf[0];
|
||||||
|
rtap_hdr->it_version = PKTHDR_RADIOTAP_VERSION;
|
||||||
|
|
||||||
|
/* each antenna information */
|
||||||
|
rx_cnt = rf_type_to_rf_rx_cnt(pHalData->rf_type);
|
||||||
|
#if 0
|
||||||
|
if (rx_cnt > 1) {
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE) |
|
||||||
|
BIT(IEEE80211_RADIOTAP_EXT);
|
||||||
|
|
||||||
|
for (i = 1; i < rx_cnt; i++) {
|
||||||
|
tmp_32bit = (BIT(IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
|
||||||
|
BIT(IEEE80211_RADIOTAP_LOCK_QUALITY) |
|
||||||
|
BIT(IEEE80211_RADIOTAP_ANTENNA) |
|
||||||
|
BIT(IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE) |
|
||||||
|
BIT(IEEE80211_RADIOTAP_EXT));
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_32bit, 4);
|
||||||
|
rt_len += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp_32bit = (BIT(IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
|
||||||
|
BIT(IEEE80211_RADIOTAP_LOCK_QUALITY) |
|
||||||
|
BIT(IEEE80211_RADIOTAP_ANTENNA));
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_32bit, 4);
|
||||||
|
rt_len += 4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* tsft, Required Alignment: 8 bytes */
|
||||||
|
if (0) { //(a->free_cnt) {
|
||||||
|
/* TSFT + free_cnt */
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_TSFT);
|
||||||
|
if (!IS_ALIGNED(rt_len, 8))
|
||||||
|
rt_len = ((rt_len + 7) & 0xFFF8); /* Alignment */
|
||||||
|
|
||||||
|
tmp_64bit = cpu_to_le64(a->free_cnt);
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_64bit, 8);
|
||||||
|
rt_len += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flags */
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_FLAGS);
|
||||||
|
_rtw_radiotap_fill_flags(a, &hdr_buf[rt_len]);
|
||||||
|
rt_len += 1;
|
||||||
|
|
||||||
|
/* rate */
|
||||||
|
if (a->data_rate <= DESC_RATE54M) {
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_RATE);
|
||||||
|
hdr_buf[rt_len] = hw_rate_to_m_rate(a->data_rate);
|
||||||
|
rt_len += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* channel & flags, Required Alignment: 2 bytes */
|
||||||
|
if (1) {
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_CHANNEL);
|
||||||
|
rt_len += (rt_len % 2); /* Alignment */
|
||||||
|
|
||||||
|
tmp_16bit = CHAN2FREQ(rtw_get_oper_ch(padapter));
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
|
||||||
|
rt_len += 2;
|
||||||
|
|
||||||
|
/* channel flags */
|
||||||
|
tmp_16bit = 0;
|
||||||
|
if (pHalData->current_band_type == 0)
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_CHAN_2GHZ);
|
||||||
|
else
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_CHAN_5GHZ);
|
||||||
|
|
||||||
|
if (a->data_rate <= DESC_RATE11M) {
|
||||||
|
/* CCK */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_CHAN_CCK);
|
||||||
|
} else {
|
||||||
|
/* OFDM */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_CHAN_OFDM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rtw_get_oper_bw(padapter) == CHANNEL_WIDTH_10) {
|
||||||
|
/* 10Mhz Channel Width */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_CHAN_HALF);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rtw_get_oper_bw(padapter) == CHANNEL_WIDTH_5) {
|
||||||
|
/* 5Mhz Channel Width */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_CHAN_QUARTER);
|
||||||
|
}
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
|
||||||
|
rt_len += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* dBm Antenna Signal */
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_DBM_ANTSIGNAL);
|
||||||
|
hdr_buf[rt_len] = a->phy_info.recv_signal_power;
|
||||||
|
rt_len += 1;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* dBm Antenna Noise */
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_DBM_ANTNOISE);
|
||||||
|
hdr_buf[rt_len] = 0;
|
||||||
|
rt_len += 1;
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
/* Signal Quality, Required Alignment: 2 bytes */
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_LOCK_QUALITY);
|
||||||
|
if (!IS_ALIGNED(rt_len, 2))
|
||||||
|
rt_len++;
|
||||||
|
hdr_buf[rt_len] = a->phy_info.signal_quality;
|
||||||
|
rt_len += 2;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Antenna */
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_ANTENNA);
|
||||||
|
hdr_buf[rt_len] = 0; /* pHalData->rf_type; */
|
||||||
|
rt_len += 1;
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
/* RX flags, Required Alignment: 2 bytes */
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_RX_FLAGS);
|
||||||
|
tmp_16bit = 0;
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
|
||||||
|
rt_len += 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* MCS information, Required Alignment: 1 bytes */
|
||||||
|
if (a->data_rate >= DESC_RATEMCS0 && a->data_rate <= DESC_RATEMCS31) {
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_MCS);
|
||||||
|
/* Structure u8 known, u8 flags, u8 mcs */
|
||||||
|
|
||||||
|
/* known.bandwidth */
|
||||||
|
hdr_buf[rt_len] |= IEEE80211_RADIOTAP_MCS_HAVE_BW;
|
||||||
|
if (moif->u.snif_info.ofdm_bw)
|
||||||
|
hdr_buf[rt_len + 1] |= IEEE80211_RADIOTAP_MCS_BW_40;
|
||||||
|
if (a->bw == CHANNEL_WIDTH_40)
|
||||||
|
hdr_buf[rt_len + 1] |= IEEE80211_RADIOTAP_MCS_BW_40;
|
||||||
|
else
|
||||||
|
hdr_buf[rt_len + 1] |= IEEE80211_RADIOTAP_MCS_BW_20;
|
||||||
|
|
||||||
|
|
||||||
|
/* known.guard interval */
|
||||||
|
hdr_buf[rt_len] |= IEEE80211_RADIOTAP_MCS_HAVE_GI;
|
||||||
|
if (moif->u.snif_info.sgi) {
|
||||||
|
hdr_buf[rt_len + 1] |= IEEE80211_RADIOTAP_MCS_SGI;
|
||||||
|
} else {
|
||||||
|
hdr_buf[rt_len + 1] |= ((a->sgi & 0x01) << 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FEC Type */
|
||||||
|
hdr_buf[rt_len] |= IEEE80211_RADIOTAP_MCS_HAVE_FEC;
|
||||||
|
if (moif->u.snif_info.ldpc) {
|
||||||
|
hdr_buf[rt_len + 1] |= ((moif->u.snif_info.ldpc & 0x01) << 4);
|
||||||
|
} else {
|
||||||
|
hdr_buf[rt_len + 1] |= ((a->ldpc & 0x01) << 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* STBC */
|
||||||
|
hdr_buf[rt_len] |= IEEE80211_RADIOTAP_MCS_HAVE_STBC;
|
||||||
|
if (moif->u.snif_info.stbc) {
|
||||||
|
hdr_buf[rt_len + 1] |= ((moif->u.snif_info.stbc & 0x03) << 5);
|
||||||
|
} else {
|
||||||
|
hdr_buf[rt_len + 1] |= ((a->stbc & 0x03) << 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* known.MCS index */
|
||||||
|
hdr_buf[rt_len] |= IEEE80211_RADIOTAP_MCS_HAVE_MCS;
|
||||||
|
|
||||||
|
/* u8 mcs */
|
||||||
|
hdr_buf[rt_len + 2] = a->data_rate - DESC_RATEMCS0;
|
||||||
|
|
||||||
|
rt_len += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* AMPDU, Required Alignment: 4 bytes */
|
||||||
|
if (a->ampdu) {
|
||||||
|
static u32 ref_num = 0x10000000;
|
||||||
|
static u8 ppdu_cnt = 0;
|
||||||
|
|
||||||
|
/* Structure u32 reference number, u16 flags, u8 delimiter CRC value, u8 reserved */
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_AMPDU_STATUS);
|
||||||
|
if (!IS_ALIGNED(rt_len, 4))
|
||||||
|
rt_len = ((rt_len + 3) & 0xFFFC); /* Alignment */
|
||||||
|
|
||||||
|
/* u32 reference number */
|
||||||
|
if (a->ppdu_cnt != ppdu_cnt) {
|
||||||
|
ppdu_cnt = a->ppdu_cnt;
|
||||||
|
ref_num += 1;
|
||||||
|
}
|
||||||
|
tmp_32bit = cpu_to_le32(ref_num);
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_32bit, 4);
|
||||||
|
rt_len += 4;
|
||||||
|
|
||||||
|
/* u16 flags */
|
||||||
|
tmp_16bit = 0;
|
||||||
|
if (0) {
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN);
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0) {
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_IS_LAST);
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0) {
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR);
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a->ampdu_eof) {
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_EOF_KNOWN);
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_EOF);
|
||||||
|
}
|
||||||
|
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
|
||||||
|
rt_len += 2;
|
||||||
|
|
||||||
|
/* u8 delimiter CRC value, u8 reserved */
|
||||||
|
rt_len += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* VHT, Required Alignment: 2 bytes */
|
||||||
|
if (a->data_rate >= DESC_RATEVHTSS1MCS0 && a->data_rate <= DESC_RATEVHTSS4MCS9) {
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_VHT);
|
||||||
|
|
||||||
|
rt_len += (rt_len % 2); /* Alignment */
|
||||||
|
|
||||||
|
/* Structure
|
||||||
|
u16 known, u8 flags, u8 bandwidth, u8 mcs_nss[4],
|
||||||
|
u8 coding, u8 group_id, u16 partial_aid */
|
||||||
|
|
||||||
|
tmp_16bit = 0;
|
||||||
|
|
||||||
|
/* STBC */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_STBC);
|
||||||
|
if (moif->u.snif_info.stbc) {
|
||||||
|
hdr_buf[rt_len + 2] |= IEEE80211_RADIOTAP_VHT_FLAG_STBC;
|
||||||
|
} else {
|
||||||
|
hdr_buf[rt_len + 2] |= (a->stbc & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TXOP_PS_NOT_ALLOWED */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA);
|
||||||
|
if (moif->u.snif_info.vht_txop_not_allow) {
|
||||||
|
hdr_buf[rt_len + 2] |= IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Guard interval */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_GI);
|
||||||
|
if (moif->u.snif_info.sgi) {
|
||||||
|
hdr_buf[rt_len + 2] |= IEEE80211_RADIOTAP_VHT_FLAG_SGI;
|
||||||
|
} else {
|
||||||
|
hdr_buf[rt_len + 2] |= ((a->sgi & 0x01) << 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Short GI NSYM */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS);
|
||||||
|
if (moif->u.snif_info.vht_nsym_dis) {
|
||||||
|
hdr_buf[rt_len + 2] |= IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* LDPC extra OFDM symbol */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM);
|
||||||
|
if (moif->u.snif_info.vht_ldpc_extra) {
|
||||||
|
hdr_buf[rt_len + 2] |= IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM;
|
||||||
|
} else {
|
||||||
|
hdr_buf[rt_len + 2] |= ((a->ldpc & 0x01) << 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Short GI NSYM */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED);
|
||||||
|
if (moif->u.snif_info.vht_beamformed) {
|
||||||
|
hdr_buf[rt_len + 2] |= IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* know.Bandwidth */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH);
|
||||||
|
|
||||||
|
/* Group ID */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID);
|
||||||
|
|
||||||
|
/* Partial AID */
|
||||||
|
tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID);
|
||||||
|
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
|
||||||
|
rt_len += 3;
|
||||||
|
|
||||||
|
/* u8 bandwidth */
|
||||||
|
if (moif->u.snif_info.ofdm_bw)
|
||||||
|
tmp_8bit = moif->u.snif_info.ofdm_bw;
|
||||||
|
else
|
||||||
|
tmp_8bit = a->bw;
|
||||||
|
|
||||||
|
switch (tmp_8bit) {
|
||||||
|
case CHANNEL_WIDTH_20:
|
||||||
|
hdr_buf[rt_len] |= 0;
|
||||||
|
break;
|
||||||
|
case CHANNEL_WIDTH_40:
|
||||||
|
hdr_buf[rt_len] |= 1;
|
||||||
|
break;
|
||||||
|
case CHANNEL_WIDTH_80:
|
||||||
|
hdr_buf[rt_len] |= 4;
|
||||||
|
break;
|
||||||
|
case CHANNEL_WIDTH_160:
|
||||||
|
hdr_buf[rt_len] |= 11;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
hdr_buf[rt_len] |= 0;
|
||||||
|
}
|
||||||
|
rt_len += 1;
|
||||||
|
|
||||||
|
/* u8 mcs_nss[4] */
|
||||||
|
if ((DESC_RATEVHTSS1MCS0 <= a->data_rate) &&
|
||||||
|
(a->data_rate <= DESC_RATEVHTSS4MCS9)) {
|
||||||
|
/* User 0 */
|
||||||
|
/* MCS */
|
||||||
|
hdr_buf[rt_len] = ((a->data_rate - DESC_RATEVHTSS1MCS0) % 10) << 4;
|
||||||
|
/* NSS */
|
||||||
|
hdr_buf[rt_len] |= (((a->data_rate - DESC_RATEVHTSS1MCS0) / 10) + 1);
|
||||||
|
}
|
||||||
|
rt_len += 4;
|
||||||
|
|
||||||
|
/* u8 coding, phystat? */
|
||||||
|
hdr_buf[rt_len] = 0;
|
||||||
|
rt_len += 1;
|
||||||
|
|
||||||
|
/* u8 group_id */
|
||||||
|
hdr_buf[rt_len] = moif->u.snif_info.vht_group_id;
|
||||||
|
rt_len += 1;
|
||||||
|
|
||||||
|
/* u16 partial_aid */
|
||||||
|
tmp_16bit = cpu_to_le16(moif->u.snif_info.vht_nsts_aid);
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
|
||||||
|
rt_len += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* frame timestamp, Required Alignment: 8 bytes */
|
||||||
|
if (0) { //(a->free_cnt) {
|
||||||
|
rtap_hdr->it_present |= BIT(IEEE80211_RADIOTAP_TIMESTAMP);
|
||||||
|
if (!IS_ALIGNED(rt_len, 8))
|
||||||
|
rt_len = ((rt_len + 7) & 0xFFF8); /* Alignment */
|
||||||
|
|
||||||
|
/* u64 timestamp */
|
||||||
|
tmp_64bit = cpu_to_le64(a->free_cnt);
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_64bit, 8);
|
||||||
|
rt_len += 8;
|
||||||
|
|
||||||
|
/* u16 accuracy */
|
||||||
|
tmp_16bit = cpu_to_le16(22);
|
||||||
|
_rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
|
||||||
|
rt_len += 2;
|
||||||
|
|
||||||
|
/* u8 unit/position */
|
||||||
|
hdr_buf[rt_len] |= IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;
|
||||||
|
rt_len += 1;
|
||||||
|
|
||||||
|
/* u8 flags */
|
||||||
|
hdr_buf[rt_len] |= IEEE80211_RADIOTAP_TIMESTAMP_FLAG_32BIT;
|
||||||
|
hdr_buf[rt_len] |= IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY;
|
||||||
|
rt_len += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* each antenna information */
|
||||||
|
#if 0
|
||||||
|
if (rx_cnt > 1) {
|
||||||
|
for (i = 0; i <= rx_cnt; i++) {
|
||||||
|
/* dBm Antenna Signal */
|
||||||
|
hdr_buf[rt_len] = a->phy_info.rx_mimo_signal_strength[i];
|
||||||
|
rt_len += 1;
|
||||||
|
|
||||||
|
/* Signal Quality */
|
||||||
|
if (!IS_ALIGNED(rt_len, 2))
|
||||||
|
rt_len++;
|
||||||
|
hdr_buf[rt_len] = cpu_to_le16(a->phy_info.rx_mimo_signal_quality[i]);
|
||||||
|
rt_len += 2;
|
||||||
|
|
||||||
|
/* Antenna */
|
||||||
|
hdr_buf[rt_len] = i; /* pHalData->rf_type; */
|
||||||
|
rt_len += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* push to skb */
|
||||||
|
pskb = (_pkt *)buf;
|
||||||
|
if (skb_headroom(pskb) < rt_len) {
|
||||||
|
RTW_INFO("%s:%d %s headroom is too small.\n", __FILE__, __LINE__, __func__);
|
||||||
|
ret = _FAIL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = skb_push(pskb, rt_len);
|
||||||
|
if (ptr) {
|
||||||
|
rtap_hdr->it_len = cpu_to_le16(rt_len);
|
||||||
|
rtap_hdr->it_present = cpu_to_le32(rtap_hdr->it_present);
|
||||||
|
memcpy(ptr, rtap_hdr, rt_len);
|
||||||
|
} else
|
||||||
|
ret = _FAIL;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void rx_query_moinfo(struct rx_pkt_attrib *a, u8 *desc)
|
||||||
|
{
|
||||||
|
switch (a->drvinfo_sz) {
|
||||||
|
case 40:
|
||||||
|
_rtw_memcpy(a->moif, &desc[32], 8);
|
||||||
|
break;
|
||||||
|
case 48:
|
||||||
|
_rtw_memcpy(a->moif, &desc[32], 12);
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
/* passthrough */
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_WIFI_MONITOR */
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __RTW_RADIOTAP_H_
|
||||||
|
#define __RTW_RADIOTAP_H_
|
||||||
|
|
||||||
|
struct mon_reg_backup {
|
||||||
|
/* flags */
|
||||||
|
u8 known_rcr:1;
|
||||||
|
u8 known_drvinfo:1;
|
||||||
|
u8 known_rxfilter:1;
|
||||||
|
u8 known_misc0:1;
|
||||||
|
/* data */
|
||||||
|
u8 drvinfo;
|
||||||
|
u16 rxfilter0;
|
||||||
|
u16 rxfilter1;
|
||||||
|
u16 rxfilter2;
|
||||||
|
u32 rcr;
|
||||||
|
u32 misc0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct moinfo {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
u32 sgi:1;
|
||||||
|
u32 ldpc:1;
|
||||||
|
u32 stbc:2;
|
||||||
|
u32 not_sounding:1;
|
||||||
|
u32 ofdm_bw:2;
|
||||||
|
u32 vht_group_id:2;
|
||||||
|
u32 vht_nsts_aid:12;
|
||||||
|
u32 vht_txop_not_allow:1;
|
||||||
|
u32 vht_nsym_dis:1;
|
||||||
|
u32 vht_ldpc_extra:1;
|
||||||
|
u32 vht_su_mcs:12;
|
||||||
|
u32 vht_beamformed:1;
|
||||||
|
}snif_info;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u32 A;
|
||||||
|
u32 B;
|
||||||
|
u32 C;
|
||||||
|
}plcp_info;
|
||||||
|
}u;
|
||||||
|
};
|
||||||
|
|
||||||
|
sint rtw_fill_radiotap_hdr(_adapter *padapter, struct rx_pkt_attrib *a, u8 *buf);
|
||||||
|
|
||||||
|
void rx_query_moinfo(struct rx_pkt_attrib *a, u8 *desc);
|
||||||
|
|
||||||
|
#endif /* __RTW_RADIOTAP_H_ */
|
||||||
|
|
||||||
5542
drivers/net/wireless/realtek/rtl8822ce/core/rtw_ap.c
Normal file
5542
drivers/net/wireless/realtek/rtl8822ce/core/rtw_ap.c
Normal file
File diff suppressed because it is too large
Load Diff
2121
drivers/net/wireless/realtek/rtl8822ce/core/rtw_beamforming.c
Normal file
2121
drivers/net/wireless/realtek/rtl8822ce/core/rtw_beamforming.c
Normal file
File diff suppressed because it is too large
Load Diff
1581
drivers/net/wireless/realtek/rtl8822ce/core/rtw_br_ext.c
Normal file
1581
drivers/net/wireless/realtek/rtl8822ce/core/rtw_br_ext.c
Normal file
File diff suppressed because it is too large
Load Diff
1575
drivers/net/wireless/realtek/rtl8822ce/core/rtw_bt_mp.c
Normal file
1575
drivers/net/wireless/realtek/rtl8822ce/core/rtw_bt_mp.c
Normal file
File diff suppressed because it is too large
Load Diff
1806
drivers/net/wireless/realtek/rtl8822ce/core/rtw_btcoex.c
Normal file
1806
drivers/net/wireless/realtek/rtl8822ce/core/rtw_btcoex.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2013 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_btcoex_wifionly.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
|
||||||
|
void rtw_btcoex_wifionly_switchband_notify(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
hal_btcoex_wifionly_switchband_notify(padapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_btcoex_wifionly_scan_notify(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
hal_btcoex_wifionly_scan_notify(padapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_btcoex_wifionly_connect_notify(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
hal_btcoex_wifionly_connect_notify(padapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_btcoex_wifionly_hw_config(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
hal_btcoex_wifionly_hw_config(padapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_btcoex_wifionly_initialize(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
hal_btcoex_wifionly_initlizevariables(padapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_btcoex_wifionly_AntInfoSetting(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
hal_btcoex_wifionly_AntInfoSetting(padapter);
|
||||||
|
}
|
||||||
525
drivers/net/wireless/realtek/rtl8822ce/core/rtw_chplan.c
Normal file
525
drivers/net/wireless/realtek/rtl8822ce/core/rtw_chplan.c
Normal file
@@ -0,0 +1,525 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2018 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#define _RTW_CHPLAN_C_
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
#define RTW_DOMAIN_MAP_VER "43e"
|
||||||
|
#define RTW_COUNTRY_MAP_VER "25"
|
||||||
|
|
||||||
|
#define RTW_RD_2G_MAX 13
|
||||||
|
#define RTW_RD_5G_MAX 73
|
||||||
|
|
||||||
|
struct ch_list_t {
|
||||||
|
u8 *len_ch;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CH_LIST_ENT(_len, arg...) \
|
||||||
|
{.len_ch = (u8[_len + 1]) {_len, ##arg}, }
|
||||||
|
|
||||||
|
#define CH_LIST_LEN(_ch_list) (_ch_list.len_ch[0])
|
||||||
|
#define CH_LIST_CH(_ch_list, _i) (_ch_list.len_ch[_i + 1])
|
||||||
|
|
||||||
|
struct chplan_ent_t {
|
||||||
|
u8 rd_2g;
|
||||||
|
#if CONFIG_IEEE80211_BAND_5GHZ
|
||||||
|
u8 rd_5g;
|
||||||
|
#endif
|
||||||
|
u8 regd; /* value of REGULATION_TXPWR_LMT */
|
||||||
|
};
|
||||||
|
|
||||||
|
#if CONFIG_IEEE80211_BAND_5GHZ
|
||||||
|
#define CHPLAN_ENT(i2g, i5g, regd) {i2g, i5g, regd}
|
||||||
|
#else
|
||||||
|
#define CHPLAN_ENT(i2g, i5g, regd) {i2g, regd}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static u8 rtw_hex_setting_buf[RTW_HEXFILE_LEN];
|
||||||
|
static struct ch_list_t RTW_ChannelPlan2G[RTW_RD_2G_MAX];
|
||||||
|
|
||||||
|
#ifdef CONFIG_IEEE80211_BAND_5GHZ
|
||||||
|
static struct ch_list_t RTW_ChannelPlan5G[RTW_RD_5G_MAX];
|
||||||
|
#endif /* CONFIG_IEEE80211_BAND_5GHZ */
|
||||||
|
|
||||||
|
static struct chplan_ent_t RTW_ChannelPlanMap[RTW_CHPLAN_HEXFILE_MAX];
|
||||||
|
static struct country_chplan country_chplan_map[238];
|
||||||
|
int rtw_get_channel_plan_from_file(const char *path)
|
||||||
|
{
|
||||||
|
u32 len, idx;
|
||||||
|
u32 i = 0, j = 0;
|
||||||
|
u8 sec_1, sec_2;
|
||||||
|
u16 sec_3, chksum;
|
||||||
|
|
||||||
|
len = rtw_retrieve_from_file(path, rtw_hex_setting_buf, RTW_HEXFILE_LEN);
|
||||||
|
if (len > RTW_HEXFILE_LEN) {
|
||||||
|
RTW_WARN("channel plan hexfile oversize\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (len == 0) {
|
||||||
|
RTW_WARN("read channel plan hexfile fail\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
chksum = *(u16 *)(rtw_hex_setting_buf);
|
||||||
|
if (rtw_calc_crc(rtw_hex_setting_buf + 2, len - 2) != chksum) {
|
||||||
|
RTW_WARN("read channel plan fail(tainted)\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sec_1 = rtw_hex_setting_buf[2];
|
||||||
|
sec_2 = sec_1 + rtw_hex_setting_buf[3];
|
||||||
|
sec_3 = sec_2 + rtw_hex_setting_buf[4];
|
||||||
|
i += 5;
|
||||||
|
while (i < len) {
|
||||||
|
if (j < sec_1) {
|
||||||
|
RTW_ChannelPlan2G[j].len_ch = rtw_hex_setting_buf + i;
|
||||||
|
i += (rtw_hex_setting_buf[i] + 1);
|
||||||
|
} else if (j >= sec_1 && j < sec_2) {
|
||||||
|
idx = j - sec_1;
|
||||||
|
RTW_ChannelPlan5G[idx].len_ch = rtw_hex_setting_buf + i;
|
||||||
|
i += (rtw_hex_setting_buf[i] + 1);
|
||||||
|
} else if (j >= sec_2 && j < sec_3) {
|
||||||
|
if (i + 2 >= len)
|
||||||
|
return -1;
|
||||||
|
idx = j - sec_2;
|
||||||
|
RTW_ChannelPlanMap[idx].rd_2g =
|
||||||
|
*(rtw_hex_setting_buf + i);
|
||||||
|
RTW_ChannelPlanMap[idx].rd_5g =
|
||||||
|
*(rtw_hex_setting_buf + i + 1);
|
||||||
|
RTW_ChannelPlanMap[idx].regd =
|
||||||
|
*(rtw_hex_setting_buf + i + 2);
|
||||||
|
i += 3;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_chplan_get_default_regd(u8 id)
|
||||||
|
{
|
||||||
|
u8 regd;
|
||||||
|
|
||||||
|
regd = RTW_ChannelPlanMap[id].regd;
|
||||||
|
|
||||||
|
return regd;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rtw_chplan_is_empty(u8 id)
|
||||||
|
{
|
||||||
|
struct chplan_ent_t *chplan_map;
|
||||||
|
|
||||||
|
chplan_map = &RTW_ChannelPlanMap[id];
|
||||||
|
|
||||||
|
if (chplan_map->rd_2g == 8
|
||||||
|
#if CONFIG_IEEE80211_BAND_5GHZ
|
||||||
|
&& chplan_map->rd_5g == 0
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
return _TRUE;
|
||||||
|
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rtw_regsty_is_excl_chs(struct registry_priv *regsty, u8 ch)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_CHANNEL_NUM; i++) {
|
||||||
|
if (regsty->excl_chs[i] == 0)
|
||||||
|
break;
|
||||||
|
if (regsty->excl_chs[i] == ch)
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static u8 rtw_rd_5g_band1_passive(u8 rtw_rd_5g)
|
||||||
|
{
|
||||||
|
u8 passive = 0;
|
||||||
|
|
||||||
|
switch (rtw_rd_5g) {
|
||||||
|
case 41:
|
||||||
|
case 44:
|
||||||
|
case 45:
|
||||||
|
case 46:
|
||||||
|
case 52:
|
||||||
|
case 55:
|
||||||
|
case 59:
|
||||||
|
case 60:
|
||||||
|
case 63:
|
||||||
|
case 64:
|
||||||
|
case 65:
|
||||||
|
case 66:
|
||||||
|
case 67:
|
||||||
|
passive = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
return passive;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static u8 rtw_rd_5g_band4_passive(u8 rtw_rd_5g)
|
||||||
|
{
|
||||||
|
u8 passive = 0;
|
||||||
|
|
||||||
|
switch (rtw_rd_5g) {
|
||||||
|
case 37:
|
||||||
|
case 38:
|
||||||
|
case 45:
|
||||||
|
case 46:
|
||||||
|
case 52:
|
||||||
|
case 61:
|
||||||
|
case 63:
|
||||||
|
case 64:
|
||||||
|
case 65:
|
||||||
|
case 66:
|
||||||
|
case 67:
|
||||||
|
passive = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
return passive;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 init_channel_set(_adapter *padapter, u8 ChannelPlan, RT_CHANNEL_INFO *channel_set)
|
||||||
|
{
|
||||||
|
struct registry_priv *regsty = adapter_to_regsty(padapter);
|
||||||
|
u8 index, chanset_size = 0;
|
||||||
|
u8 b5GBand = _FALSE, b2_4GBand = _FALSE;
|
||||||
|
u8 rd_2g = 0, rd_5g = 0;
|
||||||
|
#ifdef CONFIG_DFS_MASTER
|
||||||
|
int i;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!rtw_is_channel_plan_valid(ChannelPlan)) {
|
||||||
|
RTW_ERR("ChannelPlan ID 0x%02X error !!!!!\n", ChannelPlan);
|
||||||
|
return chanset_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
_rtw_memset(channel_set, 0, sizeof(RT_CHANNEL_INFO) * MAX_CHANNEL_NUM);
|
||||||
|
|
||||||
|
if (IsSupported24G(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_2G))
|
||||||
|
b2_4GBand = _TRUE;
|
||||||
|
|
||||||
|
if (is_supported_5g(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_5G))
|
||||||
|
b5GBand = _TRUE;
|
||||||
|
|
||||||
|
if (b2_4GBand == _FALSE && b5GBand == _FALSE) {
|
||||||
|
RTW_WARN("HW band_cap has no intersection with SW wireless_mode setting\n");
|
||||||
|
return chanset_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b2_4GBand) {
|
||||||
|
rd_2g = RTW_ChannelPlanMap[ChannelPlan].rd_2g;
|
||||||
|
|
||||||
|
for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan2G[rd_2g]); index++) {
|
||||||
|
if (rtw_regsty_is_excl_chs(regsty, CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index)) == _TRUE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (chanset_size >= MAX_CHANNEL_NUM) {
|
||||||
|
RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel_set[chanset_size].ChannelNum = CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index);
|
||||||
|
|
||||||
|
if (ChannelPlan == RTW_CHPLAN_GLOBAL_DOAMIN
|
||||||
|
|| rd_2g == 5
|
||||||
|
) {
|
||||||
|
/* Channel 1~11 is active, and 12~14 is passive */
|
||||||
|
if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11)
|
||||||
|
channel_set[chanset_size].ScanType = SCAN_ACTIVE;
|
||||||
|
else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14))
|
||||||
|
channel_set[chanset_size].ScanType = SCAN_PASSIVE;
|
||||||
|
} else if (ChannelPlan == RTW_CHPLAN_WORLD_WIDE_13
|
||||||
|
|| ChannelPlan == RTW_CHPLAN_WORLD_WIDE_5G
|
||||||
|
|| rd_2g == 0
|
||||||
|
) {
|
||||||
|
/* channel 12~13, passive scan */
|
||||||
|
if (channel_set[chanset_size].ChannelNum <= 11)
|
||||||
|
channel_set[chanset_size].ScanType = SCAN_ACTIVE;
|
||||||
|
else
|
||||||
|
channel_set[chanset_size].ScanType = SCAN_PASSIVE;
|
||||||
|
} else
|
||||||
|
channel_set[chanset_size].ScanType = SCAN_ACTIVE;
|
||||||
|
|
||||||
|
chanset_size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_IEEE80211_BAND_5GHZ
|
||||||
|
if (b5GBand) {
|
||||||
|
rd_5g = RTW_ChannelPlanMap[ChannelPlan].rd_5g;
|
||||||
|
|
||||||
|
for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan5G[rd_5g]); index++) {
|
||||||
|
if (rtw_regsty_is_excl_chs(regsty, CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index)) == _TRUE)
|
||||||
|
continue;
|
||||||
|
#if !CONFIG_DFS
|
||||||
|
if (rtw_is_dfs_ch(CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index)))
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (chanset_size >= MAX_CHANNEL_NUM) {
|
||||||
|
RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel_set[chanset_size].ChannelNum = CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index);
|
||||||
|
|
||||||
|
if ((ChannelPlan == RTW_CHPLAN_WORLD_WIDE_5G) /* all channels passive */
|
||||||
|
|| (rtw_is_5g_band1(channel_set[chanset_size].ChannelNum)
|
||||||
|
&& rtw_rd_5g_band1_passive(rd_5g)) /* band1 passive */
|
||||||
|
|| (rtw_is_5g_band4(channel_set[chanset_size].ChannelNum)
|
||||||
|
&& rtw_rd_5g_band4_passive(rd_5g)) /* band4 passive */
|
||||||
|
|| (rtw_is_dfs_ch(channel_set[chanset_size].ChannelNum)) /* DFS channel(band2, 3) passive */
|
||||||
|
)
|
||||||
|
channel_set[chanset_size].ScanType = SCAN_PASSIVE;
|
||||||
|
else
|
||||||
|
channel_set[chanset_size].ScanType = SCAN_ACTIVE;
|
||||||
|
|
||||||
|
chanset_size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DFS_MASTER
|
||||||
|
for (i = 0; i < chanset_size; i++)
|
||||||
|
channel_set[i].non_ocp_end_time = rtw_get_current_time();
|
||||||
|
#endif
|
||||||
|
#endif /* CONFIG_IEEE80211_BAND_5GHZ */
|
||||||
|
|
||||||
|
if (chanset_size)
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, ch num:%d\n"
|
||||||
|
, FUNC_ADPT_ARG(padapter), ChannelPlan, chanset_size);
|
||||||
|
else
|
||||||
|
RTW_WARN(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, final chset has no channel\n"
|
||||||
|
, FUNC_ADPT_ARG(padapter), ChannelPlan);
|
||||||
|
|
||||||
|
return chanset_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_80211AC_VHT
|
||||||
|
#define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val) , .en_11ac = (_val)
|
||||||
|
#else
|
||||||
|
#define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if RTW_DEF_MODULE_REGULATORY_CERT
|
||||||
|
#define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val) , .def_module_flags = (_val)
|
||||||
|
#else
|
||||||
|
#define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* has def_module_flags specified, used by common map and HAL dfference map */
|
||||||
|
#define COUNTRY_CHPLAN_ENT(_alpha2, _chplan, _en_11ac, _def_module_flags) \
|
||||||
|
{.alpha2 = (_alpha2), .chplan = (_chplan) \
|
||||||
|
COUNTRY_CHPLAN_ASSIGN_EN_11AC(_en_11ac) \
|
||||||
|
COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_def_module_flags) \
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
|
||||||
|
|
||||||
|
#include "../platform/custom_country_chplan.h"
|
||||||
|
|
||||||
|
#elif RTW_DEF_MODULE_REGULATORY_CERT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rtw_def_module_get_chplan_from_country -
|
||||||
|
* @country_code: string of country code
|
||||||
|
* @return:
|
||||||
|
* Return NULL for case referring to common map
|
||||||
|
*/
|
||||||
|
static const struct country_chplan *rtw_def_module_get_chplan_from_country(const char *country_code)
|
||||||
|
{
|
||||||
|
const struct country_chplan *ent = NULL;
|
||||||
|
const struct country_chplan *hal_map = NULL;
|
||||||
|
u16 hal_map_sz = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* TODO: runtime selection for multi driver */
|
||||||
|
#if (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AE_HMC_M2)
|
||||||
|
hal_map = RTL8821AE_HMC_M2_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8821AE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AU)
|
||||||
|
hal_map = RTL8821AU_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8821AU_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AENF_NGFF)
|
||||||
|
hal_map = RTL8812AENF_NGFF_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8812AENF_NGFF_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AEBT_HMC)
|
||||||
|
hal_map = RTL8812AEBT_HMC_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8812AEBT_HMC_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8188EE_HMC_M2)
|
||||||
|
hal_map = RTL8188EE_HMC_M2_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8188EE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BE_HMC_M2)
|
||||||
|
hal_map = RTL8723BE_HMC_M2_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8723BE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BS_NGFF1216)
|
||||||
|
hal_map = RTL8723BS_NGFF1216_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8723BS_NGFF1216_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8192EEBT_HMC_M2)
|
||||||
|
hal_map = RTL8192EEBT_HMC_M2_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8192EEBT_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723DE_NGFF1630)
|
||||||
|
hal_map = RTL8723DE_NGFF1630_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8723DE_NGFF1630_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8822BE)
|
||||||
|
hal_map = RTL8822BE_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8822BE_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821CE)
|
||||||
|
hal_map = RTL8821CE_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8821CE_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8822CE)
|
||||||
|
hal_map = RTL8822CE_country_chplan_exc_map;
|
||||||
|
hal_map_sz = sizeof(RTL8822CE_country_chplan_exc_map) / sizeof(struct country_chplan);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (hal_map == NULL || hal_map_sz == 0)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
for (i = 0; i < hal_map_sz; i++) {
|
||||||
|
if (strncmp(country_code, hal_map[i].alpha2, 2) == 0) {
|
||||||
|
ent = &hal_map[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return ent;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP or RTW_DEF_MODULE_REGULATORY_CERT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rtw_get_chplan_from_country -
|
||||||
|
* @country_code: string of country code
|
||||||
|
*
|
||||||
|
* Return pointer of struct country_chplan entry or NULL when unsupported country_code is given
|
||||||
|
*/
|
||||||
|
const struct country_chplan *rtw_get_chplan_from_country(const char *country_code)
|
||||||
|
{
|
||||||
|
#if RTW_DEF_MODULE_REGULATORY_CERT
|
||||||
|
const struct country_chplan *exc_ent = NULL;
|
||||||
|
#endif
|
||||||
|
const struct country_chplan *ent = NULL;
|
||||||
|
const struct country_chplan *map = NULL;
|
||||||
|
u16 map_sz = 0;
|
||||||
|
char code[2];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
code[0] = alpha_to_upper(country_code[0]);
|
||||||
|
code[1] = alpha_to_upper(country_code[1]);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
|
||||||
|
map = CUSTOMIZED_country_chplan_map;
|
||||||
|
map_sz = sizeof(CUSTOMIZED_country_chplan_map) / sizeof(struct country_chplan);
|
||||||
|
#else
|
||||||
|
#if RTW_DEF_MODULE_REGULATORY_CERT
|
||||||
|
exc_ent = rtw_def_module_get_chplan_from_country(code);
|
||||||
|
#endif
|
||||||
|
map = country_chplan_map;
|
||||||
|
map_sz = sizeof(country_chplan_map) / sizeof(struct country_chplan);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0; i < map_sz; i++) {
|
||||||
|
if (strncmp(code, map[i].alpha2, 2) == 0) {
|
||||||
|
ent = &map[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if RTW_DEF_MODULE_REGULATORY_CERT
|
||||||
|
if (!ent || !(COUNTRY_CHPLAN_DEF_MODULE_FALGS(ent) & RTW_DEF_MODULE_REGULATORY_CERT))
|
||||||
|
exc_ent = ent = NULL;
|
||||||
|
if (exc_ent)
|
||||||
|
ent = exc_ent;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump_country_chplan(void *sel, const struct country_chplan *ent)
|
||||||
|
{
|
||||||
|
RTW_PRINT_SEL(sel, "\"%c%c\", 0x%02X%s\n"
|
||||||
|
, ent->alpha2[0], ent->alpha2[1], ent->chplan
|
||||||
|
, COUNTRY_CHPLAN_EN_11AC(ent) ? " ac" : ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump_country_chplan_map(void *sel)
|
||||||
|
{
|
||||||
|
const struct country_chplan *ent;
|
||||||
|
u8 code[2];
|
||||||
|
|
||||||
|
#if RTW_DEF_MODULE_REGULATORY_CERT
|
||||||
|
RTW_PRINT_SEL(sel, "RTW_DEF_MODULE_REGULATORY_CERT:0x%x\n", RTW_DEF_MODULE_REGULATORY_CERT);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
|
||||||
|
RTW_PRINT_SEL(sel, "CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (code[0] = 'A'; code[0] <= 'Z'; code[0]++) {
|
||||||
|
for (code[1] = 'A'; code[1] <= 'Z'; code[1]++) {
|
||||||
|
ent = rtw_get_chplan_from_country(code);
|
||||||
|
if (!ent)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dump_country_chplan(sel, ent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump_chplan_id_list(void *sel)
|
||||||
|
{
|
||||||
|
u8 first = 1;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < RTW_CHPLAN_MAX; i++) {
|
||||||
|
if (!rtw_is_channel_plan_valid(i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
RTW_PRINT_SEL(sel, "0x%02X ", i);
|
||||||
|
first = 0;
|
||||||
|
} else
|
||||||
|
_RTW_PRINT_SEL(sel, "0x%02X ", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "0x7F\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump_chplan_test(void *sel)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
/* check invalid channel */
|
||||||
|
for (i = 0; i < RTW_RD_2G_MAX; i++) {
|
||||||
|
for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan2G[i]); j++) {
|
||||||
|
if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan2G[i], j)) == 0)
|
||||||
|
RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan2G[i], j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_IEEE80211_BAND_5GHZ
|
||||||
|
for (i = 0; i < RTW_RD_5G_MAX; i++) {
|
||||||
|
for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan5G[i]); j++) {
|
||||||
|
if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan5G[i], j)) == 0)
|
||||||
|
RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan5G[i], j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump_chplan_ver(void *sel)
|
||||||
|
{
|
||||||
|
RTW_PRINT_SEL(sel, "%s-%s\n", RTW_DOMAIN_MAP_VER, RTW_COUNTRY_MAP_VER);
|
||||||
|
}
|
||||||
194
drivers/net/wireless/realtek/rtl8822ce/core/rtw_chplan.h
Normal file
194
drivers/net/wireless/realtek/rtl8822ce/core/rtw_chplan.h
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2018 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __RTW_CHPLAN_H__
|
||||||
|
#define __RTW_CHPLAN_H__
|
||||||
|
|
||||||
|
enum rtw_chplan_id {
|
||||||
|
/* ===== 0x00 ~ 0x1F, legacy channel plan ===== */
|
||||||
|
RTW_CHPLAN_FCC = 0x00,
|
||||||
|
RTW_CHPLAN_IC = 0x01,
|
||||||
|
RTW_CHPLAN_ETSI = 0x02,
|
||||||
|
RTW_CHPLAN_SPAIN = 0x03,
|
||||||
|
RTW_CHPLAN_FRANCE = 0x04,
|
||||||
|
RTW_CHPLAN_MKK = 0x05,
|
||||||
|
RTW_CHPLAN_MKK1 = 0x06,
|
||||||
|
RTW_CHPLAN_ISRAEL = 0x07,
|
||||||
|
RTW_CHPLAN_TELEC = 0x08,
|
||||||
|
RTW_CHPLAN_GLOBAL_DOAMIN = 0x09,
|
||||||
|
RTW_CHPLAN_WORLD_WIDE_13 = 0x0A,
|
||||||
|
RTW_CHPLAN_TAIWAN = 0x0B,
|
||||||
|
RTW_CHPLAN_CHINA = 0x0C,
|
||||||
|
RTW_CHPLAN_SINGAPORE_INDIA_MEXICO = 0x0D,
|
||||||
|
RTW_CHPLAN_KOREA = 0x0E,
|
||||||
|
RTW_CHPLAN_TURKEY = 0x0F,
|
||||||
|
RTW_CHPLAN_JAPAN = 0x10,
|
||||||
|
RTW_CHPLAN_FCC_NO_DFS = 0x11,
|
||||||
|
RTW_CHPLAN_JAPAN_NO_DFS = 0x12,
|
||||||
|
RTW_CHPLAN_WORLD_WIDE_5G = 0x13,
|
||||||
|
RTW_CHPLAN_TAIWAN_NO_DFS = 0x14,
|
||||||
|
|
||||||
|
/* ===== 0x20 ~ 0x7F, new channel plan ===== */
|
||||||
|
RTW_CHPLAN_WORLD_NULL = 0x20,
|
||||||
|
RTW_CHPLAN_ETSI1_NULL = 0x21,
|
||||||
|
RTW_CHPLAN_FCC1_NULL = 0x22,
|
||||||
|
RTW_CHPLAN_MKK1_NULL = 0x23,
|
||||||
|
RTW_CHPLAN_ETSI2_NULL = 0x24,
|
||||||
|
RTW_CHPLAN_FCC1_FCC1 = 0x25,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI1 = 0x26,
|
||||||
|
RTW_CHPLAN_MKK1_MKK1 = 0x27,
|
||||||
|
RTW_CHPLAN_WORLD_KCC1 = 0x28,
|
||||||
|
RTW_CHPLAN_WORLD_FCC2 = 0x29,
|
||||||
|
RTW_CHPLAN_FCC2_NULL = 0x2A,
|
||||||
|
RTW_CHPLAN_IC1_IC2 = 0x2B,
|
||||||
|
RTW_CHPLAN_MKK2_NULL = 0x2C,
|
||||||
|
RTW_CHPLAN_WORLD_CHILE1= 0x2D,
|
||||||
|
RTW_CHPLAN_WORLD1_WORLD1 = 0x2E,
|
||||||
|
RTW_CHPLAN_WORLD_CHILE2 = 0x2F,
|
||||||
|
RTW_CHPLAN_WORLD_FCC3 = 0x30,
|
||||||
|
RTW_CHPLAN_WORLD_FCC4 = 0x31,
|
||||||
|
RTW_CHPLAN_WORLD_FCC5 = 0x32,
|
||||||
|
RTW_CHPLAN_WORLD_FCC6 = 0x33,
|
||||||
|
RTW_CHPLAN_FCC1_FCC7 = 0x34,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI2 = 0x35,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI3 = 0x36,
|
||||||
|
RTW_CHPLAN_MKK1_MKK2 = 0x37,
|
||||||
|
RTW_CHPLAN_MKK1_MKK3 = 0x38,
|
||||||
|
RTW_CHPLAN_FCC1_NCC1 = 0x39,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI1 = 0x3A,
|
||||||
|
RTW_CHPLAN_ETSI1_ACMA1 = 0x3B,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI6 = 0x3C,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI12 = 0x3D,
|
||||||
|
RTW_CHPLAN_KCC1_KCC2 = 0x3E,
|
||||||
|
RTW_CHPLAN_FCC1_FCC11 = 0x3F,
|
||||||
|
RTW_CHPLAN_FCC1_NCC2 = 0x40,
|
||||||
|
RTW_CHPLAN_GLOBAL_NULL = 0x41,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI4 = 0x42,
|
||||||
|
RTW_CHPLAN_FCC1_FCC2 = 0x43,
|
||||||
|
RTW_CHPLAN_FCC1_NCC3 = 0x44,
|
||||||
|
RTW_CHPLAN_WORLD_ACMA1 = 0x45,
|
||||||
|
RTW_CHPLAN_FCC1_FCC8 = 0x46,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI6 = 0x47,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI7 = 0x48,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI8 = 0x49,
|
||||||
|
RTW_CHPLAN_IC2_IC2 = 0x4A,
|
||||||
|
RTW_CHPLAN_KCC1_KCC3 = 0x4B,
|
||||||
|
RTW_CHPLAN_FCC1_FCC15 = 0x4C,
|
||||||
|
RTW_CHPLAN_FCC2_MEX1 = 0x4D,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI22 = 0x4E,
|
||||||
|
RTW_CHPLAN_NULL_MKK9 = 0x4F,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI9 = 0x50,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI10 = 0x51,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI11 = 0x52,
|
||||||
|
RTW_CHPLAN_FCC1_NCC4 = 0x53,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI12 = 0x54,
|
||||||
|
RTW_CHPLAN_FCC1_FCC9 = 0x55,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI13 = 0x56,
|
||||||
|
RTW_CHPLAN_FCC1_FCC10 = 0x57,
|
||||||
|
RTW_CHPLAN_MKK2_MKK4 = 0x58,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI14 = 0x59,
|
||||||
|
RTW_CHPLAN_NULL_FCC19 = 0x5A,
|
||||||
|
RTW_CHPLAN_NULL_FCC20 = 0x5B,
|
||||||
|
RTW_CHPLAN_NULL_FCC21 = 0x5C,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI23 = 0x5D,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI2 = 0x5E,
|
||||||
|
RTW_CHPLAN_FCC1_FCC5 = 0x60,
|
||||||
|
RTW_CHPLAN_FCC2_FCC7 = 0x61,
|
||||||
|
RTW_CHPLAN_FCC2_FCC1 = 0x62,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI15 = 0x63,
|
||||||
|
RTW_CHPLAN_MKK2_MKK5 = 0x64,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI16 = 0x65,
|
||||||
|
RTW_CHPLAN_FCC1_FCC14 = 0x66,
|
||||||
|
RTW_CHPLAN_FCC1_FCC12 = 0x67,
|
||||||
|
RTW_CHPLAN_FCC2_FCC14 = 0x68,
|
||||||
|
RTW_CHPLAN_FCC2_FCC12 = 0x69,
|
||||||
|
RTW_CHPLAN_ETSI1_ETSI17 = 0x6A,
|
||||||
|
RTW_CHPLAN_WORLD_FCC16 = 0x6B,
|
||||||
|
RTW_CHPLAN_WORLD_FCC13 = 0x6C,
|
||||||
|
RTW_CHPLAN_FCC2_FCC15 = 0x6D,
|
||||||
|
RTW_CHPLAN_WORLD_FCC12 = 0x6E,
|
||||||
|
RTW_CHPLAN_NULL_ETSI8 = 0x6F,
|
||||||
|
RTW_CHPLAN_NULL_ETSI18 = 0x70,
|
||||||
|
RTW_CHPLAN_NULL_ETSI17 = 0x71,
|
||||||
|
RTW_CHPLAN_NULL_ETSI19 = 0x72,
|
||||||
|
RTW_CHPLAN_WORLD_FCC7 = 0x73,
|
||||||
|
RTW_CHPLAN_FCC2_FCC17 = 0x74,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI20 = 0x75,
|
||||||
|
RTW_CHPLAN_FCC2_FCC11 = 0x76,
|
||||||
|
RTW_CHPLAN_WORLD_ETSI21 = 0x77,
|
||||||
|
RTW_CHPLAN_FCC1_FCC18 = 0x78,
|
||||||
|
RTW_CHPLAN_MKK2_MKK1 = 0x79,
|
||||||
|
|
||||||
|
RTW_CHPLAN_MAX,
|
||||||
|
RTW_CHPLAN_REALTEK_DEFINE = 0x7F,
|
||||||
|
RTW_CHPLAN_HEXFILE_MAX,
|
||||||
|
RTW_CHPLAN_UNSPECIFIED = 0xFF,
|
||||||
|
};
|
||||||
|
|
||||||
|
int rtw_get_channel_plan_from_file(const char *path);
|
||||||
|
u8 rtw_chplan_get_default_regd(u8 id);
|
||||||
|
bool rtw_chplan_is_empty(u8 id);
|
||||||
|
#define rtw_is_channel_plan_valid(chplan) (((chplan) < RTW_CHPLAN_MAX || (chplan) == RTW_CHPLAN_REALTEK_DEFINE) && !rtw_chplan_is_empty(chplan))
|
||||||
|
#define rtw_is_legacy_channel_plan(chplan) ((chplan) < 0x20)
|
||||||
|
|
||||||
|
struct _RT_CHANNEL_INFO;
|
||||||
|
u8 init_channel_set(_adapter *padapter, u8 ChannelPlan, struct _RT_CHANNEL_INFO *channel_set);
|
||||||
|
|
||||||
|
#define IS_ALPHA2_NO_SPECIFIED(_alpha2) ((*((u16 *)(_alpha2))) == 0xFFFF)
|
||||||
|
|
||||||
|
#define RTW_MODULE_RTL8821AE_HMC_M2 BIT0 /* RTL8821AE(HMC + M.2) */
|
||||||
|
#define RTW_MODULE_RTL8821AU BIT1 /* RTL8821AU */
|
||||||
|
#define RTW_MODULE_RTL8812AENF_NGFF BIT2 /* RTL8812AENF(8812AE+8761)_NGFF */
|
||||||
|
#define RTW_MODULE_RTL8812AEBT_HMC BIT3 /* RTL8812AEBT(8812AE+8761)_HMC */
|
||||||
|
#define RTW_MODULE_RTL8188EE_HMC_M2 BIT4 /* RTL8188EE(HMC + M.2) */
|
||||||
|
#define RTW_MODULE_RTL8723BE_HMC_M2 BIT5 /* RTL8723BE(HMC + M.2) */
|
||||||
|
#define RTW_MODULE_RTL8723BS_NGFF1216 BIT6 /* RTL8723BS(NGFF1216) */
|
||||||
|
#define RTW_MODULE_RTL8192EEBT_HMC_M2 BIT7 /* RTL8192EEBT(8192EE+8761AU)_(HMC + M.2) */
|
||||||
|
#define RTW_MODULE_RTL8723DE_NGFF1630 BIT8 /* RTL8723DE(NGFF1630) */
|
||||||
|
#define RTW_MODULE_RTL8822BE BIT9 /* RTL8822BE */
|
||||||
|
#define RTW_MODULE_RTL8821CE BIT10 /* RTL8821CE */
|
||||||
|
#define RTW_MODULE_RTL8822CE BIT11 /* RTL8822CE */
|
||||||
|
|
||||||
|
struct country_chplan {
|
||||||
|
char alpha2[2];
|
||||||
|
u8 chplan;
|
||||||
|
#ifdef CONFIG_80211AC_VHT
|
||||||
|
u8 en_11ac;
|
||||||
|
#endif
|
||||||
|
#if RTW_DEF_MODULE_REGULATORY_CERT
|
||||||
|
u16 def_module_flags; /* RTW_MODULE_RTLXXX */
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_80211AC_VHT
|
||||||
|
#define COUNTRY_CHPLAN_EN_11AC(_ent) ((_ent)->en_11ac)
|
||||||
|
#else
|
||||||
|
#define COUNTRY_CHPLAN_EN_11AC(_ent) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if RTW_DEF_MODULE_REGULATORY_CERT
|
||||||
|
#define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) ((_ent)->def_module_flags)
|
||||||
|
#else
|
||||||
|
#define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const struct country_chplan *rtw_get_chplan_from_country(const char *country_code);
|
||||||
|
|
||||||
|
void dump_country_chplan(void *sel, const struct country_chplan *ent);
|
||||||
|
void dump_country_chplan_map(void *sel);
|
||||||
|
void dump_chplan_id_list(void *sel);
|
||||||
|
void dump_chplan_test(void *sel);
|
||||||
|
void dump_chplan_ver(void *sel);
|
||||||
|
|
||||||
|
#endif /* __RTW_CHPLAN_H__ */
|
||||||
5564
drivers/net/wireless/realtek/rtl8822ce/core/rtw_cmd.c
Normal file
5564
drivers/net/wireless/realtek/rtl8822ce/core/rtw_cmd.c
Normal file
File diff suppressed because it is too large
Load Diff
7560
drivers/net/wireless/realtek/rtl8822ce/core/rtw_debug.c
Normal file
7560
drivers/net/wireless/realtek/rtl8822ce/core/rtw_debug.c
Normal file
File diff suppressed because it is too large
Load Diff
329
drivers/net/wireless/realtek/rtl8822ce/core/rtw_eeprom.c
Normal file
329
drivers/net/wireless/realtek/rtl8822ce/core/rtw_eeprom.c
Normal file
@@ -0,0 +1,329 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#define _RTW_EEPROM_C_
|
||||||
|
|
||||||
|
#include <drv_conf.h>
|
||||||
|
#include <osdep_service.h>
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
void up_clk(_adapter *padapter, u16 *x)
|
||||||
|
{
|
||||||
|
*x = *x | _EESK;
|
||||||
|
rtw_write8(padapter, EE_9346CR, (u8)*x);
|
||||||
|
rtw_udelay_os(CLOCK_RATE);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void down_clk(_adapter *padapter, u16 *x)
|
||||||
|
{
|
||||||
|
*x = *x & ~_EESK;
|
||||||
|
rtw_write8(padapter, EE_9346CR, (u8)*x);
|
||||||
|
rtw_udelay_os(CLOCK_RATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void shift_out_bits(_adapter *padapter, u16 data, u16 count)
|
||||||
|
{
|
||||||
|
u16 x, mask;
|
||||||
|
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
mask = 0x01 << (count - 1);
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
|
||||||
|
x &= ~(_EEDO | _EEDI);
|
||||||
|
|
||||||
|
do {
|
||||||
|
x &= ~_EEDI;
|
||||||
|
if (data & mask)
|
||||||
|
x |= _EEDI;
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
rtw_write8(padapter, EE_9346CR, (u8)x);
|
||||||
|
rtw_udelay_os(CLOCK_RATE);
|
||||||
|
up_clk(padapter, &x);
|
||||||
|
down_clk(padapter, &x);
|
||||||
|
mask = mask >> 1;
|
||||||
|
} while (mask);
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
x &= ~_EEDI;
|
||||||
|
rtw_write8(padapter, EE_9346CR, (u8)x);
|
||||||
|
out:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 shift_in_bits(_adapter *padapter)
|
||||||
|
{
|
||||||
|
u16 x, d = 0, i;
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
|
||||||
|
x &= ~(_EEDO | _EEDI);
|
||||||
|
d = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
d = d << 1;
|
||||||
|
up_clk(padapter, &x);
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
|
||||||
|
x &= ~(_EEDI);
|
||||||
|
if (x & _EEDO)
|
||||||
|
d |= 1;
|
||||||
|
|
||||||
|
down_clk(padapter, &x);
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void standby(_adapter *padapter)
|
||||||
|
{
|
||||||
|
u8 x;
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
|
||||||
|
x &= ~(_EECS | _EESK);
|
||||||
|
rtw_write8(padapter, EE_9346CR, x);
|
||||||
|
|
||||||
|
rtw_udelay_os(CLOCK_RATE);
|
||||||
|
x |= _EECS;
|
||||||
|
rtw_write8(padapter, EE_9346CR, x);
|
||||||
|
rtw_udelay_os(CLOCK_RATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 wait_eeprom_cmd_done(_adapter *padapter)
|
||||||
|
{
|
||||||
|
u8 x;
|
||||||
|
u16 i, res = _FALSE;
|
||||||
|
standby(padapter);
|
||||||
|
for (i = 0; i < 200; i++) {
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
if (x & _EEDO) {
|
||||||
|
res = _TRUE;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
rtw_udelay_os(CLOCK_RATE);
|
||||||
|
}
|
||||||
|
exit:
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void eeprom_clean(_adapter *padapter)
|
||||||
|
{
|
||||||
|
u16 x;
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
x &= ~(_EECS | _EEDI);
|
||||||
|
rtw_write8(padapter, EE_9346CR, (u8)x);
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
up_clk(padapter, &x);
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
down_clk(padapter, &x);
|
||||||
|
out:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void eeprom_write16(_adapter *padapter, u16 reg, u16 data)
|
||||||
|
{
|
||||||
|
u8 x;
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
|
||||||
|
x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
|
||||||
|
x |= _EEM1 | _EECS;
|
||||||
|
rtw_write8(padapter, EE_9346CR, x);
|
||||||
|
|
||||||
|
shift_out_bits(padapter, EEPROM_EWEN_OPCODE, 5);
|
||||||
|
|
||||||
|
if (padapter->EepromAddressSize == 8) /* CF+ and SDIO */
|
||||||
|
shift_out_bits(padapter, 0, 6);
|
||||||
|
else /* USB */
|
||||||
|
shift_out_bits(padapter, 0, 4);
|
||||||
|
|
||||||
|
standby(padapter);
|
||||||
|
|
||||||
|
/* Commented out by rcnjko, 2004.0
|
||||||
|
* Erase this particular word. Write the erase opcode and register
|
||||||
|
* number in that order. The opcode is 3bits in length; reg is 6 bits long. */
|
||||||
|
/* shift_out_bits(Adapter, EEPROM_ERASE_OPCODE, 3);
|
||||||
|
* shift_out_bits(Adapter, reg, Adapter->EepromAddressSize);
|
||||||
|
*
|
||||||
|
* if (wait_eeprom_cmd_done(Adapter ) == FALSE)
|
||||||
|
* {
|
||||||
|
* return;
|
||||||
|
* } */
|
||||||
|
|
||||||
|
|
||||||
|
standby(padapter);
|
||||||
|
|
||||||
|
/* write the new word to the EEPROM */
|
||||||
|
|
||||||
|
/* send the write opcode the EEPORM */
|
||||||
|
shift_out_bits(padapter, EEPROM_WRITE_OPCODE, 3);
|
||||||
|
|
||||||
|
/* select which word in the EEPROM that we are writing to. */
|
||||||
|
shift_out_bits(padapter, reg, padapter->EepromAddressSize);
|
||||||
|
|
||||||
|
/* write the data to the selected EEPROM word. */
|
||||||
|
shift_out_bits(padapter, data, 16);
|
||||||
|
|
||||||
|
if (wait_eeprom_cmd_done(padapter) == _FALSE)
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
standby(padapter);
|
||||||
|
|
||||||
|
shift_out_bits(padapter, EEPROM_EWDS_OPCODE, 5);
|
||||||
|
shift_out_bits(padapter, reg, 4);
|
||||||
|
|
||||||
|
eeprom_clean(padapter);
|
||||||
|
exit:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 eeprom_read16(_adapter *padapter, u16 reg) /* ReadEEprom */
|
||||||
|
{
|
||||||
|
|
||||||
|
u16 x;
|
||||||
|
u16 data = 0;
|
||||||
|
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
/* select EEPROM, reset bits, set _EECS */
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
|
||||||
|
x |= _EEM1 | _EECS;
|
||||||
|
rtw_write8(padapter, EE_9346CR, (unsigned char)x);
|
||||||
|
|
||||||
|
/* write the read opcode and register number in that order */
|
||||||
|
/* The opcode is 3bits in length, reg is 6 bits long */
|
||||||
|
shift_out_bits(padapter, EEPROM_READ_OPCODE, 3);
|
||||||
|
shift_out_bits(padapter, reg, padapter->EepromAddressSize);
|
||||||
|
|
||||||
|
/* Now read the data (16 bits) in from the selected EEPROM word */
|
||||||
|
data = shift_in_bits(padapter);
|
||||||
|
|
||||||
|
eeprom_clean(padapter);
|
||||||
|
out:
|
||||||
|
|
||||||
|
return data;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* From even offset */
|
||||||
|
void eeprom_read_sz(_adapter *padapter, u16 reg, u8 *data, u32 sz)
|
||||||
|
{
|
||||||
|
|
||||||
|
u16 x, data16;
|
||||||
|
u32 i;
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
/* select EEPROM, reset bits, set _EECS */
|
||||||
|
x = rtw_read8(padapter, EE_9346CR);
|
||||||
|
|
||||||
|
if (rtw_is_surprise_removed(padapter)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
|
||||||
|
x |= _EEM1 | _EECS;
|
||||||
|
rtw_write8(padapter, EE_9346CR, (unsigned char)x);
|
||||||
|
|
||||||
|
/* write the read opcode and register number in that order */
|
||||||
|
/* The opcode is 3bits in length, reg is 6 bits long */
|
||||||
|
shift_out_bits(padapter, EEPROM_READ_OPCODE, 3);
|
||||||
|
shift_out_bits(padapter, reg, padapter->EepromAddressSize);
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < sz; i += 2) {
|
||||||
|
data16 = shift_in_bits(padapter);
|
||||||
|
data[i] = data16 & 0xff;
|
||||||
|
data[i + 1] = data16 >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
eeprom_clean(padapter);
|
||||||
|
out:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* addr_off : address offset of the entry in eeprom (not the tuple number of eeprom (reg); that is addr_off !=reg) */
|
||||||
|
u8 eeprom_read(_adapter *padapter, u32 addr_off, u8 sz, u8 *rbuf)
|
||||||
|
{
|
||||||
|
u8 quotient, remainder, addr_2align_odd;
|
||||||
|
u16 reg, stmp , i = 0, idx = 0;
|
||||||
|
reg = (u16)(addr_off >> 1);
|
||||||
|
addr_2align_odd = (u8)(addr_off & 0x1);
|
||||||
|
|
||||||
|
if (addr_2align_odd) { /* read that start at high part: e.g 1,3,5,7,9,... */
|
||||||
|
stmp = eeprom_read16(padapter, reg);
|
||||||
|
rbuf[idx++] = (u8)((stmp >> 8) & 0xff); /* return hogh-part of the short */
|
||||||
|
reg++;
|
||||||
|
sz--;
|
||||||
|
}
|
||||||
|
|
||||||
|
quotient = sz >> 1;
|
||||||
|
remainder = sz & 0x1;
|
||||||
|
|
||||||
|
for (i = 0 ; i < quotient; i++) {
|
||||||
|
stmp = eeprom_read16(padapter, reg + i);
|
||||||
|
rbuf[idx++] = (u8)(stmp & 0xff);
|
||||||
|
rbuf[idx++] = (u8)((stmp >> 8) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
reg = reg + i;
|
||||||
|
if (remainder) { /* end of read at lower part of short : 0,2,4,6,... */
|
||||||
|
stmp = eeprom_read16(padapter, reg);
|
||||||
|
rbuf[idx] = (u8)(stmp & 0xff);
|
||||||
|
}
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void read_eeprom_content(_adapter *padapter)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
3072
drivers/net/wireless/realtek/rtl8822ce/core/rtw_ieee80211.c
Normal file
3072
drivers/net/wireless/realtek/rtl8822ce/core/rtw_ieee80211.c
Normal file
File diff suppressed because it is too large
Load Diff
952
drivers/net/wireless/realtek/rtl8822ce/core/rtw_io.c
Normal file
952
drivers/net/wireless/realtek/rtl8822ce/core/rtw_io.c
Normal file
@@ -0,0 +1,952 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
|
||||||
|
The purpose of rtw_io.c
|
||||||
|
|
||||||
|
a. provides the API
|
||||||
|
|
||||||
|
b. provides the protocol engine
|
||||||
|
|
||||||
|
c. provides the software interface between caller and the hardware interface
|
||||||
|
|
||||||
|
|
||||||
|
Compiler Flag Option:
|
||||||
|
|
||||||
|
1. CONFIG_SDIO_HCI:
|
||||||
|
a. USE_SYNC_IRP: Only sync operations are provided.
|
||||||
|
b. USE_ASYNC_IRP:Both sync/async operations are provided.
|
||||||
|
|
||||||
|
2. CONFIG_USB_HCI:
|
||||||
|
a. USE_ASYNC_IRP: Both sync/async operations are provided.
|
||||||
|
|
||||||
|
3. CONFIG_CFIO_HCI:
|
||||||
|
b. USE_SYNC_IRP: Only sync operations are provided.
|
||||||
|
|
||||||
|
|
||||||
|
Only sync read/rtw_write_mem operations are provided.
|
||||||
|
|
||||||
|
jackson@realtek.com.tw
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _RTW_IO_C_
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
|
||||||
|
#if defined(CONFIG_SDIO_HCI) || defined(CONFIG_PLATFORM_RTL8197D)
|
||||||
|
#define rtw_le16_to_cpu(val) val
|
||||||
|
#define rtw_le32_to_cpu(val) val
|
||||||
|
#define rtw_cpu_to_le16(val) val
|
||||||
|
#define rtw_cpu_to_le32(val) val
|
||||||
|
#else
|
||||||
|
#define rtw_le16_to_cpu(val) le16_to_cpu(val)
|
||||||
|
#define rtw_le32_to_cpu(val) le32_to_cpu(val)
|
||||||
|
#define rtw_cpu_to_le16(val) cpu_to_le16(val)
|
||||||
|
#define rtw_cpu_to_le32(val) cpu_to_le32(val)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
u8 _rtw_read8(_adapter *adapter, u32 addr)
|
||||||
|
{
|
||||||
|
u8 r_val;
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
u8(*_read8)(struct intf_hdl *pintfhdl, u32 addr);
|
||||||
|
_read8 = pintfhdl->io_ops._read8;
|
||||||
|
|
||||||
|
r_val = _read8(pintfhdl, addr);
|
||||||
|
return r_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 _rtw_read16(_adapter *adapter, u32 addr)
|
||||||
|
{
|
||||||
|
u16 r_val;
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
u16(*_read16)(struct intf_hdl *pintfhdl, u32 addr);
|
||||||
|
_read16 = pintfhdl->io_ops._read16;
|
||||||
|
|
||||||
|
r_val = _read16(pintfhdl, addr);
|
||||||
|
return rtw_le16_to_cpu(r_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 _rtw_read32(_adapter *adapter, u32 addr)
|
||||||
|
{
|
||||||
|
u32 r_val;
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
u32(*_read32)(struct intf_hdl *pintfhdl, u32 addr);
|
||||||
|
_read32 = pintfhdl->io_ops._read32;
|
||||||
|
|
||||||
|
r_val = _read32(pintfhdl, addr);
|
||||||
|
return rtw_le32_to_cpu(r_val);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtw_write8(_adapter *adapter, u32 addr, u8 val)
|
||||||
|
{
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
|
||||||
|
int ret;
|
||||||
|
_write8 = pintfhdl->io_ops._write8;
|
||||||
|
|
||||||
|
ret = _write8(pintfhdl, addr, val);
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
int _rtw_write16(_adapter *adapter, u32 addr, u16 val)
|
||||||
|
{
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
|
||||||
|
int ret;
|
||||||
|
_write16 = pintfhdl->io_ops._write16;
|
||||||
|
|
||||||
|
val = rtw_cpu_to_le16(val);
|
||||||
|
ret = _write16(pintfhdl, addr, val);
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
int _rtw_write32(_adapter *adapter, u32 addr, u32 val)
|
||||||
|
{
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
|
||||||
|
int ret;
|
||||||
|
_write32 = pintfhdl->io_ops._write32;
|
||||||
|
|
||||||
|
val = rtw_cpu_to_le32(val);
|
||||||
|
ret = _write32(pintfhdl, addr, val);
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtw_writeN(_adapter *adapter, u32 addr , u32 length , u8 *pdata)
|
||||||
|
{
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_priv->intf));
|
||||||
|
int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata);
|
||||||
|
int ret;
|
||||||
|
_writeN = pintfhdl->io_ops._writeN;
|
||||||
|
|
||||||
|
ret = _writeN(pintfhdl, addr, length, pdata);
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SDIO_HCI
|
||||||
|
u8 _rtw_sd_f0_read8(_adapter *adapter, u32 addr)
|
||||||
|
{
|
||||||
|
u8 r_val = 0x00;
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
u8(*_sd_f0_read8)(struct intf_hdl *pintfhdl, u32 addr);
|
||||||
|
|
||||||
|
_sd_f0_read8 = pintfhdl->io_ops._sd_f0_read8;
|
||||||
|
|
||||||
|
if (_sd_f0_read8)
|
||||||
|
r_val = _sd_f0_read8(pintfhdl, addr);
|
||||||
|
else
|
||||||
|
RTW_WARN(FUNC_ADPT_FMT" _sd_f0_read8 callback is NULL\n", FUNC_ADPT_ARG(adapter));
|
||||||
|
|
||||||
|
return r_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SDIO_INDIRECT_ACCESS
|
||||||
|
u8 _rtw_sd_iread8(_adapter *adapter, u32 addr)
|
||||||
|
{
|
||||||
|
u8 r_val = 0x00;
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
u8(*_sd_iread8)(struct intf_hdl *pintfhdl, u32 addr);
|
||||||
|
|
||||||
|
_sd_iread8 = pintfhdl->io_ops._sd_iread8;
|
||||||
|
|
||||||
|
if (_sd_iread8)
|
||||||
|
r_val = _sd_iread8(pintfhdl, addr);
|
||||||
|
else
|
||||||
|
RTW_ERR(FUNC_ADPT_FMT" _sd_iread8 callback is NULL\n", FUNC_ADPT_ARG(adapter));
|
||||||
|
|
||||||
|
return r_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 _rtw_sd_iread16(_adapter *adapter, u32 addr)
|
||||||
|
{
|
||||||
|
u16 r_val = 0x00;
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
u16(*_sd_iread16)(struct intf_hdl *pintfhdl, u32 addr);
|
||||||
|
|
||||||
|
_sd_iread16 = pintfhdl->io_ops._sd_iread16;
|
||||||
|
|
||||||
|
if (_sd_iread16)
|
||||||
|
r_val = _sd_iread16(pintfhdl, addr);
|
||||||
|
else
|
||||||
|
RTW_ERR(FUNC_ADPT_FMT" _sd_iread16 callback is NULL\n", FUNC_ADPT_ARG(adapter));
|
||||||
|
|
||||||
|
return r_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 _rtw_sd_iread32(_adapter *adapter, u32 addr)
|
||||||
|
{
|
||||||
|
u32 r_val = 0x00;
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
u32(*_sd_iread32)(struct intf_hdl *pintfhdl, u32 addr);
|
||||||
|
|
||||||
|
_sd_iread32 = pintfhdl->io_ops._sd_iread32;
|
||||||
|
|
||||||
|
if (_sd_iread32)
|
||||||
|
r_val = _sd_iread32(pintfhdl, addr);
|
||||||
|
else
|
||||||
|
RTW_ERR(FUNC_ADPT_FMT" _sd_iread32 callback is NULL\n", FUNC_ADPT_ARG(adapter));
|
||||||
|
|
||||||
|
return r_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtw_sd_iwrite8(_adapter *adapter, u32 addr, u8 val)
|
||||||
|
{
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_sd_iwrite8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
_sd_iwrite8 = pintfhdl->io_ops._sd_iwrite8;
|
||||||
|
|
||||||
|
if (_sd_iwrite8)
|
||||||
|
ret = _sd_iwrite8(pintfhdl, addr, val);
|
||||||
|
else
|
||||||
|
RTW_ERR(FUNC_ADPT_FMT" _sd_iwrite8 callback is NULL\n", FUNC_ADPT_ARG(adapter));
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtw_sd_iwrite16(_adapter *adapter, u32 addr, u16 val)
|
||||||
|
{
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_sd_iwrite16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
_sd_iwrite16 = pintfhdl->io_ops._sd_iwrite16;
|
||||||
|
|
||||||
|
if (_sd_iwrite16)
|
||||||
|
ret = _sd_iwrite16(pintfhdl, addr, val);
|
||||||
|
else
|
||||||
|
RTW_ERR(FUNC_ADPT_FMT" _sd_iwrite16 callback is NULL\n", FUNC_ADPT_ARG(adapter));
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
int _rtw_sd_iwrite32(_adapter *adapter, u32 addr, u32 val)
|
||||||
|
{
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_sd_iwrite32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
_sd_iwrite32 = pintfhdl->io_ops._sd_iwrite32;
|
||||||
|
|
||||||
|
if (_sd_iwrite32)
|
||||||
|
ret = _sd_iwrite32(pintfhdl, addr, val);
|
||||||
|
else
|
||||||
|
RTW_ERR(FUNC_ADPT_FMT" _sd_iwrite32 callback is NULL\n", FUNC_ADPT_ARG(adapter));
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_SDIO_INDIRECT_ACCESS */
|
||||||
|
|
||||||
|
#endif /* CONFIG_SDIO_HCI */
|
||||||
|
|
||||||
|
int _rtw_write8_async(_adapter *adapter, u32 addr, u8 val)
|
||||||
|
{
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
|
||||||
|
int ret;
|
||||||
|
_write8_async = pintfhdl->io_ops._write8_async;
|
||||||
|
|
||||||
|
ret = _write8_async(pintfhdl, addr, val);
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
int _rtw_write16_async(_adapter *adapter, u32 addr, u16 val)
|
||||||
|
{
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
|
||||||
|
int ret;
|
||||||
|
_write16_async = pintfhdl->io_ops._write16_async;
|
||||||
|
val = rtw_cpu_to_le16(val);
|
||||||
|
ret = _write16_async(pintfhdl, addr, val);
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
int _rtw_write32_async(_adapter *adapter, u32 addr, u32 val)
|
||||||
|
{
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
|
||||||
|
int ret;
|
||||||
|
_write32_async = pintfhdl->io_ops._write32_async;
|
||||||
|
val = rtw_cpu_to_le32(val);
|
||||||
|
ret = _write32_async(pintfhdl, addr, val);
|
||||||
|
|
||||||
|
return RTW_STATUS_CODE(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _rtw_read_mem(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
|
||||||
|
{
|
||||||
|
void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
|
||||||
|
|
||||||
|
if (RTW_CANNOT_RUN(adapter)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_read_mem = pintfhdl->io_ops._read_mem;
|
||||||
|
|
||||||
|
_read_mem(pintfhdl, addr, cnt, pmem);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void _rtw_write_mem(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
|
||||||
|
{
|
||||||
|
void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
|
||||||
|
|
||||||
|
_write_mem = pintfhdl->io_ops._write_mem;
|
||||||
|
|
||||||
|
_write_mem(pintfhdl, addr, cnt, pmem);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void _rtw_read_port(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
|
||||||
|
{
|
||||||
|
u32(*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
|
||||||
|
|
||||||
|
if (RTW_CANNOT_RUN(adapter)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_read_port = pintfhdl->io_ops._read_port;
|
||||||
|
|
||||||
|
_read_port(pintfhdl, addr, cnt, pmem);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void _rtw_read_port_cancel(_adapter *adapter)
|
||||||
|
{
|
||||||
|
void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
|
||||||
|
_read_port_cancel = pintfhdl->io_ops._read_port_cancel;
|
||||||
|
|
||||||
|
RTW_DISABLE_FUNC(adapter, DF_RX_BIT);
|
||||||
|
|
||||||
|
if (_read_port_cancel)
|
||||||
|
_read_port_cancel(pintfhdl);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 _rtw_write_port(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
|
||||||
|
{
|
||||||
|
u32(*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
|
||||||
|
/* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
u32 ret = _SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
_write_port = pintfhdl->io_ops._write_port;
|
||||||
|
|
||||||
|
ret = _write_port(pintfhdl, addr, cnt, pmem);
|
||||||
|
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 _rtw_write_port_and_wait(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem, int timeout_ms)
|
||||||
|
{
|
||||||
|
int ret = _SUCCESS;
|
||||||
|
struct xmit_buf *pxmitbuf = (struct xmit_buf *)pmem;
|
||||||
|
struct submit_ctx sctx;
|
||||||
|
|
||||||
|
rtw_sctx_init(&sctx, timeout_ms);
|
||||||
|
pxmitbuf->sctx = &sctx;
|
||||||
|
|
||||||
|
ret = _rtw_write_port(adapter, addr, cnt, pmem);
|
||||||
|
|
||||||
|
if (ret == _SUCCESS) {
|
||||||
|
ret = rtw_sctx_wait(&sctx, __func__);
|
||||||
|
|
||||||
|
if (ret != _SUCCESS)
|
||||||
|
pxmitbuf->sctx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _rtw_write_port_cancel(_adapter *adapter)
|
||||||
|
{
|
||||||
|
void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
|
||||||
|
struct io_priv *pio_priv = &adapter->iopriv;
|
||||||
|
struct intf_hdl *pintfhdl = &(pio_priv->intf);
|
||||||
|
|
||||||
|
_write_port_cancel = pintfhdl->io_ops._write_port_cancel;
|
||||||
|
|
||||||
|
RTW_DISABLE_FUNC(adapter, DF_TX_BIT);
|
||||||
|
|
||||||
|
if (_write_port_cancel)
|
||||||
|
_write_port_cancel(pintfhdl);
|
||||||
|
}
|
||||||
|
int rtw_init_io_priv(_adapter *padapter, void (*set_intf_ops)(_adapter *padapter, struct _io_ops *pops))
|
||||||
|
{
|
||||||
|
struct io_priv *piopriv = &padapter->iopriv;
|
||||||
|
struct intf_hdl *pintf = &piopriv->intf;
|
||||||
|
|
||||||
|
if (set_intf_ops == NULL)
|
||||||
|
return _FAIL;
|
||||||
|
|
||||||
|
piopriv->padapter = padapter;
|
||||||
|
pintf->padapter = padapter;
|
||||||
|
pintf->pintf_dev = adapter_to_dvobj(padapter);
|
||||||
|
|
||||||
|
set_intf_ops(padapter, &pintf->io_ops);
|
||||||
|
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increase and check if the continual_io_error of this @param dvobjprive is larger than MAX_CONTINUAL_IO_ERR
|
||||||
|
* @return _TRUE:
|
||||||
|
* @return _FALSE:
|
||||||
|
*/
|
||||||
|
int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj)
|
||||||
|
{
|
||||||
|
int ret = _FALSE;
|
||||||
|
int value;
|
||||||
|
|
||||||
|
value = ATOMIC_INC_RETURN(&dvobj->continual_io_error);
|
||||||
|
if (value > MAX_CONTINUAL_IO_ERR) {
|
||||||
|
RTW_INFO("[dvobj:%p][ERROR] continual_io_error:%d > %d\n", dvobj, value, MAX_CONTINUAL_IO_ERR);
|
||||||
|
ret = _TRUE;
|
||||||
|
} else {
|
||||||
|
/* RTW_INFO("[dvobj:%p] continual_io_error:%d\n", dvobj, value); */
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the continual_io_error of this @param dvobjprive to 0
|
||||||
|
*/
|
||||||
|
void rtw_reset_continual_io_error(struct dvobj_priv *dvobj)
|
||||||
|
{
|
||||||
|
ATOMIC_SET(&dvobj->continual_io_error, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DBG_IO
|
||||||
|
#define RTW_IO_SNIFF_TYPE_RANGE 0 /* specific address range is accessed */
|
||||||
|
#define RTW_IO_SNIFF_TYPE_VALUE 1 /* value match for sniffed range */
|
||||||
|
|
||||||
|
struct rtw_io_sniff_ent {
|
||||||
|
u8 chip;
|
||||||
|
u8 hci;
|
||||||
|
u32 addr;
|
||||||
|
u8 type;
|
||||||
|
union {
|
||||||
|
u32 end_addr;
|
||||||
|
struct {
|
||||||
|
u32 mask;
|
||||||
|
u32 val;
|
||||||
|
bool equal;
|
||||||
|
} vm; /* value match */
|
||||||
|
} u;
|
||||||
|
bool trace;
|
||||||
|
char *tag;
|
||||||
|
bool (*assert_protsel)(_adapter *adapter, u32 addr, u8 len);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RTW_IO_SNIFF_RANGE_ENT(_chip, _hci, _addr, _end_addr, _trace, _tag) \
|
||||||
|
{.chip = _chip, .hci = _hci, .addr = _addr, .u.end_addr = _end_addr, .trace = _trace, .tag = _tag, .type = RTW_IO_SNIFF_TYPE_RANGE,}
|
||||||
|
|
||||||
|
#define RTW_IO_SNIFF_RANGE_PROT_ENT(_chip, _hci, _addr, _end_addr, _assert_protsel, _tag) \
|
||||||
|
{.chip = _chip, .hci = _hci, .addr = _addr, .u.end_addr = _end_addr, .trace = 1, .assert_protsel = _assert_protsel, .tag = _tag, .type = RTW_IO_SNIFF_TYPE_RANGE,}
|
||||||
|
|
||||||
|
#define RTW_IO_SNIFF_VALUE_ENT(_chip, _hci, _addr, _mask, _val, _equal, _trace, _tag) \
|
||||||
|
{.chip = _chip, .hci = _hci, .addr = _addr, .u.vm.mask = _mask, .u.vm.val = _val, .u.vm.equal = _equal, .trace = _trace, .tag = _tag, .type = RTW_IO_SNIFF_TYPE_VALUE,}
|
||||||
|
|
||||||
|
/* part or all sniffed range is enabled (not all 0) */
|
||||||
|
#define RTW_IO_SNIFF_EN_ENT(_chip, _hci, _addr, _mask, _trace, _tag) \
|
||||||
|
{.chip = _chip, .hci = _hci, .addr = _addr, .u.vm.mask = _mask, .u.vm.val = 0, .u.vm.equal = 0, .trace = _trace, .tag = _tag, .type = RTW_IO_SNIFF_TYPE_VALUE,}
|
||||||
|
|
||||||
|
/* part or all sniffed range is disabled (not all 1) */
|
||||||
|
#define RTW_IO_SNIFF_DIS_ENT(_chip, _hci, _addr, _mask, _trace, _tag) \
|
||||||
|
{.chip = _chip, .hci = _hci, .addr = _addr, .u.vm.mask = _mask, .u.vm.val = 0xFFFFFFFF, .u.vm.equal = 0, .trace = _trace, .tag = _tag, .type = RTW_IO_SNIFF_TYPE_VALUE,}
|
||||||
|
|
||||||
|
const struct rtw_io_sniff_ent read_sniff[] = {
|
||||||
|
#ifdef DBG_IO_HCI_EN_CHK
|
||||||
|
RTW_IO_SNIFF_EN_ENT(MAX_CHIP_TYPE, RTW_SDIO, 0x02, 0x1FC, 1, "SDIO 0x02[8:2] not all 0"),
|
||||||
|
RTW_IO_SNIFF_EN_ENT(MAX_CHIP_TYPE, RTW_USB, 0x02, 0x1E0, 1, "USB 0x02[8:5] not all 0"),
|
||||||
|
RTW_IO_SNIFF_EN_ENT(MAX_CHIP_TYPE, RTW_PCIE, 0x02, 0x01C, 1, "PCI 0x02[4:2] not all 0"),
|
||||||
|
#endif
|
||||||
|
#ifdef DBG_IO_SNIFF_EXAMPLE
|
||||||
|
RTW_IO_SNIFF_RANGE_ENT(MAX_CHIP_TYPE, 0, 0x522, 0x522, 0, "read TXPAUSE"),
|
||||||
|
RTW_IO_SNIFF_DIS_ENT(MAX_CHIP_TYPE, 0, 0x02, 0x3, 0, "0x02[1:0] not all 1"),
|
||||||
|
#endif
|
||||||
|
#ifdef DBG_IO_PROT_SEL
|
||||||
|
RTW_IO_SNIFF_RANGE_PROT_ENT(MAX_CHIP_TYPE, 0, 0x1501, 0x1513, rtw_assert_protsel_port, "protsel port"),
|
||||||
|
RTW_IO_SNIFF_RANGE_PROT_ENT(MAX_CHIP_TYPE, 0, 0x153a, 0x153b, rtw_assert_protsel_atimdtim, "protsel atimdtim"),
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
const int read_sniff_num = sizeof(read_sniff) / sizeof(struct rtw_io_sniff_ent);
|
||||||
|
|
||||||
|
const struct rtw_io_sniff_ent write_sniff[] = {
|
||||||
|
#ifdef DBG_IO_HCI_EN_CHK
|
||||||
|
RTW_IO_SNIFF_EN_ENT(MAX_CHIP_TYPE, RTW_SDIO, 0x02, 0x1FC, 1, "SDIO 0x02[8:2] not all 0"),
|
||||||
|
RTW_IO_SNIFF_EN_ENT(MAX_CHIP_TYPE, RTW_USB, 0x02, 0x1E0, 1, "USB 0x02[8:5] not all 0"),
|
||||||
|
RTW_IO_SNIFF_EN_ENT(MAX_CHIP_TYPE, RTW_PCIE, 0x02, 0x01C, 1, "PCI 0x02[4:2] not all 0"),
|
||||||
|
#endif
|
||||||
|
#ifdef DBG_IO_8822C_1TX_PATH_EN
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x1a04, 0xc0000000, 0x02, 1, 0, "write tx_path_en_cck A enabled"),
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x1a04, 0xc0000000, 0x01, 1, 0, "write tx_path_en_cck B enabled"),
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x1a04, 0xc0000000, 0x03, 1, 1, "write tx_path_en_cck AB enabled"),
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x820, 0x03, 0x01, 1, 0, "write tx_path_en_ofdm_1sts A enabled"),
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x820, 0x03, 0x02, 1, 0, "write tx_path_en_ofdm_1sts B enabled"),
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x820, 0x03, 0x03, 1, 1, "write tx_path_en_ofdm_1sts AB enabled"),
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x820, 0x30, 0x01, 1, 0, "write tx_path_en_ofdm_2sts A enabled"),
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x820, 0x30, 0x02, 1, 0, "write tx_path_en_ofdm_2sts B enabled"),
|
||||||
|
RTW_IO_SNIFF_VALUE_ENT(RTL8822C, 0, 0x820, 0x30, 0x03, 1, 1, "write tx_path_en_ofdm_2sts AB enabled"),
|
||||||
|
#endif
|
||||||
|
#ifdef DBG_IO_SNIFF_EXAMPLE
|
||||||
|
RTW_IO_SNIFF_RANGE_ENT(MAX_CHIP_TYPE, 0, 0x522, 0x522, 0, "write TXPAUSE"),
|
||||||
|
RTW_IO_SNIFF_DIS_ENT(MAX_CHIP_TYPE, 0, 0x02, 0x3, 0, "0x02[1:0] not all 1"),
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
const int write_sniff_num = sizeof(write_sniff) / sizeof(struct rtw_io_sniff_ent);
|
||||||
|
|
||||||
|
static bool match_io_sniff_ranges(_adapter *adapter
|
||||||
|
, const struct rtw_io_sniff_ent *sniff, int i, u32 addr, u16 len)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* check if IO range after sniff end address */
|
||||||
|
if (addr > sniff->u.end_addr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (sniff->assert_protsel &&
|
||||||
|
sniff->assert_protsel(adapter, addr, len))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool match_io_sniff_value(_adapter *adapter
|
||||||
|
, const struct rtw_io_sniff_ent *sniff, int i, u32 addr, u8 len, u32 val)
|
||||||
|
{
|
||||||
|
u8 sniff_len;
|
||||||
|
s8 mask_shift;
|
||||||
|
u32 mask;
|
||||||
|
s8 value_shift;
|
||||||
|
u32 value;
|
||||||
|
bool ret = 0;
|
||||||
|
|
||||||
|
/* check if IO range after sniff end address */
|
||||||
|
sniff_len = 4;
|
||||||
|
while (!(sniff->u.vm.mask & (0xFF << ((sniff_len - 1) * 8)))) {
|
||||||
|
sniff_len--;
|
||||||
|
if (sniff_len == 0)
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (sniff->addr + sniff_len <= addr)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
/* align to IO addr */
|
||||||
|
mask_shift = (sniff->addr - addr) * 8;
|
||||||
|
value_shift = mask_shift + bitshift(sniff->u.vm.mask);
|
||||||
|
if (mask_shift > 0)
|
||||||
|
mask = sniff->u.vm.mask << mask_shift;
|
||||||
|
else if (mask_shift < 0)
|
||||||
|
mask = sniff->u.vm.mask >> -mask_shift;
|
||||||
|
else
|
||||||
|
mask = sniff->u.vm.mask;
|
||||||
|
|
||||||
|
if (value_shift > 0)
|
||||||
|
value = sniff->u.vm.val << value_shift;
|
||||||
|
else if (mask_shift < 0)
|
||||||
|
value = sniff->u.vm.val >> -value_shift;
|
||||||
|
else
|
||||||
|
value = sniff->u.vm.val;
|
||||||
|
|
||||||
|
if ((sniff->u.vm.equal && (mask & val) == (mask & value))
|
||||||
|
|| (!sniff->u.vm.equal && (mask & val) != (mask & value))
|
||||||
|
) {
|
||||||
|
ret = 1;
|
||||||
|
if (0)
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT" addr:0x%x len:%u val:0x%x (i:%d sniff_len:%u m_shift:%d mask:0x%x v_shifd:%d value:0x%x equal:%d)\n"
|
||||||
|
, FUNC_ADPT_ARG(adapter), addr, len, val, i, sniff_len, mask_shift, mask, value_shift, value, sniff->u.vm.equal);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool match_io_sniff(_adapter *adapter
|
||||||
|
, const struct rtw_io_sniff_ent *sniff, int i, u32 addr, u8 len, u32 val)
|
||||||
|
{
|
||||||
|
bool ret = 0;
|
||||||
|
|
||||||
|
if (sniff->chip != MAX_CHIP_TYPE
|
||||||
|
&& sniff->chip != rtw_get_chip_type(adapter))
|
||||||
|
goto exit;
|
||||||
|
if (sniff->hci
|
||||||
|
&& !(sniff->hci & rtw_get_intf_type(adapter)))
|
||||||
|
goto exit;
|
||||||
|
if (sniff->addr >= addr + len) /* IO range below sniff start address */
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
switch (sniff->type) {
|
||||||
|
case RTW_IO_SNIFF_TYPE_RANGE:
|
||||||
|
ret = match_io_sniff_ranges(adapter, sniff, i, addr, len);
|
||||||
|
break;
|
||||||
|
case RTW_IO_SNIFF_TYPE_VALUE:
|
||||||
|
if (len == 1 || len == 2 || len == 4)
|
||||||
|
ret = match_io_sniff_value(adapter, sniff, i, addr, len, val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rtw_warn_on(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 match_read_sniff(_adapter *adapter, u32 addr, u16 len, u32 val)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
bool trace = 0;
|
||||||
|
u32 match = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < read_sniff_num; i++) {
|
||||||
|
if (match_io_sniff(adapter, &read_sniff[i], i, addr, len, val)) {
|
||||||
|
match++;
|
||||||
|
trace |= read_sniff[i].trace;
|
||||||
|
if (read_sniff[i].tag)
|
||||||
|
RTW_INFO("DBG_IO TAG %s\n", read_sniff[i].tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rtw_warn_on(trace);
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 match_write_sniff(_adapter *adapter, u32 addr, u16 len, u32 val)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
bool trace = 0;
|
||||||
|
u32 match = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < write_sniff_num; i++) {
|
||||||
|
if (match_io_sniff(adapter, &write_sniff[i], i, addr, len, val)) {
|
||||||
|
match++;
|
||||||
|
trace |= write_sniff[i].trace;
|
||||||
|
if (write_sniff[i].tag)
|
||||||
|
RTW_INFO("DBG_IO TAG %s\n", write_sniff[i].tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rtw_warn_on(trace);
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct rf_sniff_ent {
|
||||||
|
u8 path;
|
||||||
|
u16 reg;
|
||||||
|
u32 mask;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rf_sniff_ent rf_read_sniff_ranges[] = {
|
||||||
|
/* example for all path addr 0x55 with all RF Reg mask */
|
||||||
|
/* {MAX_RF_PATH, 0x55, bRFRegOffsetMask}, */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rf_sniff_ent rf_write_sniff_ranges[] = {
|
||||||
|
/* example for all path addr 0x55 with all RF Reg mask */
|
||||||
|
/* {MAX_RF_PATH, 0x55, bRFRegOffsetMask}, */
|
||||||
|
};
|
||||||
|
|
||||||
|
int rf_read_sniff_num = sizeof(rf_read_sniff_ranges) / sizeof(struct rf_sniff_ent);
|
||||||
|
int rf_write_sniff_num = sizeof(rf_write_sniff_ranges) / sizeof(struct rf_sniff_ent);
|
||||||
|
|
||||||
|
bool match_rf_read_sniff_ranges(_adapter *adapter, u8 path, u32 addr, u32 mask)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < rf_read_sniff_num; i++) {
|
||||||
|
if (rf_read_sniff_ranges[i].path == MAX_RF_PATH || rf_read_sniff_ranges[i].path == path)
|
||||||
|
if (addr == rf_read_sniff_ranges[i].reg && (mask & rf_read_sniff_ranges[i].mask))
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool match_rf_write_sniff_ranges(_adapter *adapter, u8 path, u32 addr, u32 mask)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < rf_write_sniff_num; i++) {
|
||||||
|
if (rf_write_sniff_ranges[i].path == MAX_RF_PATH || rf_write_sniff_ranges[i].path == path)
|
||||||
|
if (addr == rf_write_sniff_ranges[i].reg && (mask & rf_write_sniff_ranges[i].mask))
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_rtw_reg_read_monitor(_adapter *adapter, u32 addr, u32 len, u32 val, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_read_sniff(adapter, addr, len, val)) {
|
||||||
|
switch (len) {
|
||||||
|
case 1:
|
||||||
|
RTW_INFO("DBG_IO %s:%d read8(0x%04x) return 0x%02x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
RTW_INFO("DBG_IO %s:%d read16(0x%04x) return 0x%04x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
RTW_INFO("DBG_IO %s:%d read32(0x%04x) return 0x%08x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
RTW_INFO("DBG_IO %s:%d readN(0x%04x, %u)\n"
|
||||||
|
, caller, line, addr, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_rtw_reg_write_monitor(_adapter *adapter, u32 addr, u32 len, u32 val, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(adapter, addr, len, val)) {
|
||||||
|
switch (len) {
|
||||||
|
case 1:
|
||||||
|
RTW_INFO("DBG_IO %s:%d write8(0x%04x, 0x%02x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
RTW_INFO("DBG_IO %s:%d write16(0x%04x, 0x%04x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
RTW_INFO("DBG_IO %s:%d write32(0x%04x, 0x%08x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_writeN(0x%04x, %u)\n"
|
||||||
|
, caller, line, addr, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 dbg_rtw_read8(_adapter *adapter, u32 addr, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
u8 val = _rtw_read8(adapter, addr);
|
||||||
|
|
||||||
|
if (match_read_sniff(adapter, addr, 1, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_read8(0x%04x) return 0x%02x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 dbg_rtw_read16(_adapter *adapter, u32 addr, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
u16 val = _rtw_read16(adapter, addr);
|
||||||
|
|
||||||
|
if (match_read_sniff(adapter, addr, 2, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_read16(0x%04x) return 0x%04x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 dbg_rtw_read32(_adapter *adapter, u32 addr, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
u32 val = _rtw_read32(adapter, addr);
|
||||||
|
|
||||||
|
if (match_read_sniff(adapter, addr, 4, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_read32(0x%04x) return 0x%08x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbg_rtw_write8(_adapter *adapter, u32 addr, u8 val, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(adapter, addr, 1, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_write8(0x%04x, 0x%02x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_write8(adapter, addr, val);
|
||||||
|
}
|
||||||
|
int dbg_rtw_write16(_adapter *adapter, u32 addr, u16 val, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(adapter, addr, 2, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_write16(0x%04x, 0x%04x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_write16(adapter, addr, val);
|
||||||
|
}
|
||||||
|
int dbg_rtw_write32(_adapter *adapter, u32 addr, u32 val, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(adapter, addr, 4, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_write32(0x%04x, 0x%08x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_write32(adapter, addr, val);
|
||||||
|
}
|
||||||
|
int dbg_rtw_writeN(_adapter *adapter, u32 addr , u32 length , u8 *data, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(adapter, addr, length, 0)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_writeN(0x%04x, %u)\n"
|
||||||
|
, caller, line, addr, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_writeN(adapter, addr, length, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SDIO_HCI
|
||||||
|
u8 dbg_rtw_sd_f0_read8(_adapter *adapter, u32 addr, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
u8 val = _rtw_sd_f0_read8(adapter, addr);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (match_read_sniff(adapter, addr, 1, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_sd_f0_read8(0x%04x) return 0x%02x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SDIO_INDIRECT_ACCESS
|
||||||
|
u8 dbg_rtw_sd_iread8(_adapter *adapter, u32 addr, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
u8 val = rtw_sd_iread8(adapter, addr);
|
||||||
|
|
||||||
|
if (match_read_sniff(adapter, addr, 1, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_sd_iread8(0x%04x) return 0x%02x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 dbg_rtw_sd_iread16(_adapter *adapter, u32 addr, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
u16 val = _rtw_sd_iread16(adapter, addr);
|
||||||
|
|
||||||
|
if (match_read_sniff(adapter, addr, 2, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_sd_iread16(0x%04x) return 0x%04x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 dbg_rtw_sd_iread32(_adapter *adapter, u32 addr, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
u32 val = _rtw_sd_iread32(adapter, addr);
|
||||||
|
|
||||||
|
if (match_read_sniff(adapter, addr, 4, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_sd_iread32(0x%04x) return 0x%08x\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbg_rtw_sd_iwrite8(_adapter *adapter, u32 addr, u8 val, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(adapter, addr, 1, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_sd_iwrite8(0x%04x, 0x%02x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_sd_iwrite8(adapter, addr, val);
|
||||||
|
}
|
||||||
|
int dbg_rtw_sd_iwrite16(_adapter *adapter, u32 addr, u16 val, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(adapter, addr, 2, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_sd_iwrite16(0x%04x, 0x%04x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_sd_iwrite16(adapter, addr, val);
|
||||||
|
}
|
||||||
|
int dbg_rtw_sd_iwrite32(_adapter *adapter, u32 addr, u32 val, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(adapter, addr, 4, val)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d rtw_sd_iwrite32(0x%04x, 0x%08x)\n"
|
||||||
|
, caller, line, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_sd_iwrite32(adapter, addr, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_SDIO_INDIRECT_ACCESS */
|
||||||
|
|
||||||
|
#endif /* CONFIG_SDIO_HCI */
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#define _RTW_IOCTL_QUERY_C_
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
|
||||||
923
drivers/net/wireless/realtek/rtl8822ce/core/rtw_ioctl_set.c
Normal file
923
drivers/net/wireless/realtek/rtl8822ce/core/rtw_ioctl_set.c
Normal file
@@ -0,0 +1,923 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2019 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#define _RTW_IOCTL_SET_C_
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern void indicate_wx_scan_complete_event(_adapter *padapter);
|
||||||
|
|
||||||
|
#define IS_MAC_ADDRESS_BROADCAST(addr) \
|
||||||
|
(\
|
||||||
|
((addr[0] == 0xff) && (addr[1] == 0xff) && \
|
||||||
|
(addr[2] == 0xff) && (addr[3] == 0xff) && \
|
||||||
|
(addr[4] == 0xff) && (addr[5] == 0xff)) ? _TRUE : _FALSE \
|
||||||
|
)
|
||||||
|
|
||||||
|
u8 rtw_validate_bssid(u8 *bssid)
|
||||||
|
{
|
||||||
|
u8 ret = _TRUE;
|
||||||
|
|
||||||
|
if (is_zero_mac_addr(bssid)
|
||||||
|
|| is_broadcast_mac_addr(bssid)
|
||||||
|
|| is_multicast_mac_addr(bssid)
|
||||||
|
)
|
||||||
|
ret = _FALSE;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_validate_ssid(NDIS_802_11_SSID *ssid)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_VALIDATE_SSID
|
||||||
|
u8 i;
|
||||||
|
#endif
|
||||||
|
u8 ret = _TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
if (ssid->SsidLength > 32) {
|
||||||
|
ret = _FALSE;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_VALIDATE_SSID
|
||||||
|
for (i = 0; i < ssid->SsidLength; i++) {
|
||||||
|
/* wifi, printable ascii code must be supported */
|
||||||
|
if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e))) {
|
||||||
|
ret = _FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_VALIDATE_SSID */
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_do_join(_adapter *padapter);
|
||||||
|
u8 rtw_do_join(_adapter *padapter)
|
||||||
|
{
|
||||||
|
_irqL irqL;
|
||||||
|
_list *plist, *phead;
|
||||||
|
u8 *pibss = NULL;
|
||||||
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
||||||
|
struct sitesurvey_parm parm;
|
||||||
|
_queue *queue = &(pmlmepriv->scanned_queue);
|
||||||
|
u8 ret = _SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
||||||
|
phead = get_list_head(queue);
|
||||||
|
plist = get_next(phead);
|
||||||
|
|
||||||
|
|
||||||
|
pmlmepriv->cur_network.join_res = -2;
|
||||||
|
|
||||||
|
set_fwstate(pmlmepriv, WIFI_UNDER_LINKING);
|
||||||
|
|
||||||
|
pmlmepriv->pscanned = plist;
|
||||||
|
|
||||||
|
pmlmepriv->to_join = _TRUE;
|
||||||
|
|
||||||
|
rtw_init_sitesurvey_parm(padapter, &parm);
|
||||||
|
_rtw_memcpy(&parm.ssid[0], &pmlmepriv->assoc_ssid, sizeof(NDIS_802_11_SSID));
|
||||||
|
parm.ssid_num = 1;
|
||||||
|
|
||||||
|
if (pmlmepriv->assoc_ch) {
|
||||||
|
parm.ch_num = 1;
|
||||||
|
parm.ch[0].hw_value = pmlmepriv->assoc_ch;
|
||||||
|
parm.ch[0].flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_rtw_queue_empty(queue) == _TRUE) {
|
||||||
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
||||||
|
_clr_fwstate_(pmlmepriv, WIFI_UNDER_LINKING);
|
||||||
|
|
||||||
|
/* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */
|
||||||
|
/* we try to issue sitesurvey firstly */
|
||||||
|
|
||||||
|
if (pmlmepriv->LinkDetectInfo.bBusyTraffic == _FALSE
|
||||||
|
|| rtw_to_roam(padapter) > 0
|
||||||
|
) {
|
||||||
|
u8 ssc_chk = rtw_sitesurvey_condition_check(padapter, _FALSE);
|
||||||
|
|
||||||
|
if ((ssc_chk == SS_ALLOW) || (ssc_chk == SS_DENY_BUSY_TRAFFIC) ){
|
||||||
|
/* submit site_survey_cmd */
|
||||||
|
ret = rtw_sitesurvey_cmd(padapter, &parm);
|
||||||
|
if (_SUCCESS != ret)
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
} else {
|
||||||
|
/*if (ssc_chk == SS_DENY_BUDDY_UNDER_SURVEY)*/
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
ret = _FAIL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
ret = _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
} else {
|
||||||
|
int select_ret;
|
||||||
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
||||||
|
select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv);
|
||||||
|
if (select_ret == _SUCCESS) {
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
_set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
|
||||||
|
} else {
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE) {
|
||||||
|
/* submit createbss_cmd to change to a ADHOC_MASTER */
|
||||||
|
|
||||||
|
/* pmlmepriv->lock has been acquired by caller... */
|
||||||
|
WLAN_BSSID_EX *pdev_network = &(padapter->registrypriv.dev_network);
|
||||||
|
|
||||||
|
/*pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;*/
|
||||||
|
init_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
|
||||||
|
|
||||||
|
pibss = padapter->registrypriv.dev_network.MacAddress;
|
||||||
|
|
||||||
|
_rtw_memset(&pdev_network->Ssid, 0, sizeof(NDIS_802_11_SSID));
|
||||||
|
_rtw_memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(NDIS_802_11_SSID));
|
||||||
|
|
||||||
|
rtw_update_registrypriv_dev_network(padapter);
|
||||||
|
|
||||||
|
rtw_generate_random_ibss(pibss);
|
||||||
|
|
||||||
|
if (rtw_create_ibss_cmd(padapter, 0) != _SUCCESS) {
|
||||||
|
ret = _FALSE;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/* can't associate ; reset under-linking */
|
||||||
|
_clr_fwstate_(pmlmepriv, WIFI_UNDER_LINKING);
|
||||||
|
|
||||||
|
/* when set_ssid/set_bssid for rtw_do_join(), but there are no desired bss in scanning queue */
|
||||||
|
/* we try to issue sitesurvey firstly */
|
||||||
|
if (pmlmepriv->LinkDetectInfo.bBusyTraffic == _FALSE
|
||||||
|
|| rtw_to_roam(padapter) > 0
|
||||||
|
) {
|
||||||
|
u8 ssc_chk = rtw_sitesurvey_condition_check(padapter, _FALSE);
|
||||||
|
|
||||||
|
if ((ssc_chk == SS_ALLOW) || (ssc_chk == SS_DENY_BUSY_TRAFFIC)){
|
||||||
|
/* RTW_INFO(("rtw_do_join() when no desired bss in scanning queue\n"); */
|
||||||
|
ret = rtw_sitesurvey_cmd(padapter, &parm);
|
||||||
|
if (_SUCCESS != ret)
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
} else {
|
||||||
|
/*if (ssc_chk == SS_DENY_BUDDY_UNDER_SURVEY) {
|
||||||
|
} else {*/
|
||||||
|
ret = _FAIL;
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = _FAIL;
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_set_802_11_bssid(_adapter *padapter, u8 *bssid)
|
||||||
|
{
|
||||||
|
_irqL irqL;
|
||||||
|
u8 status = _SUCCESS;
|
||||||
|
|
||||||
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
|
|
||||||
|
|
||||||
|
RTW_PRINT("set bssid:%pM\n", bssid);
|
||||||
|
|
||||||
|
if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) ||
|
||||||
|
(bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF && bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) {
|
||||||
|
status = _FAIL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
|
||||||
|
RTW_INFO("Set BSSID under fw_state=0x%08x\n", get_fwstate(pmlmepriv));
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_SURVEY) == _TRUE)
|
||||||
|
goto handle_tkip_countermeasure;
|
||||||
|
else if (check_fwstate(pmlmepriv, WIFI_UNDER_LINKING) == _TRUE)
|
||||||
|
goto release_mlme_lock;
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_ADHOC_MASTER_STATE) == _TRUE) {
|
||||||
|
|
||||||
|
if (_rtw_memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN) == _TRUE) {
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _FALSE)
|
||||||
|
goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
|
||||||
|
} else {
|
||||||
|
|
||||||
|
rtw_disassoc_cmd(padapter, 0, 0);
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE)
|
||||||
|
rtw_indicate_disconnect(padapter, 0, _FALSE);
|
||||||
|
|
||||||
|
rtw_free_assoc_resources_cmd(padapter, _TRUE, 0);
|
||||||
|
|
||||||
|
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE)) {
|
||||||
|
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
|
||||||
|
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_tkip_countermeasure:
|
||||||
|
if (rtw_handle_tkip_countermeasure(padapter, __func__) == _FAIL) {
|
||||||
|
status = _FAIL;
|
||||||
|
goto release_mlme_lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
_rtw_memset(&pmlmepriv->assoc_ssid, 0, sizeof(NDIS_802_11_SSID));
|
||||||
|
_rtw_memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN);
|
||||||
|
pmlmepriv->assoc_ch = 0;
|
||||||
|
pmlmepriv->assoc_by_bssid = _TRUE;
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_SURVEY) == _TRUE)
|
||||||
|
pmlmepriv->to_join = _TRUE;
|
||||||
|
else
|
||||||
|
status = rtw_do_join(padapter);
|
||||||
|
|
||||||
|
release_mlme_lock:
|
||||||
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_set_802_11_ssid(_adapter *padapter, NDIS_802_11_SSID *ssid)
|
||||||
|
{
|
||||||
|
_irqL irqL;
|
||||||
|
u8 status = _SUCCESS;
|
||||||
|
|
||||||
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
|
struct wlan_network *pnetwork = &pmlmepriv->cur_network;
|
||||||
|
|
||||||
|
|
||||||
|
RTW_PRINT("set ssid [%s] fw_state=0x%08x\n",
|
||||||
|
ssid->Ssid, get_fwstate(pmlmepriv));
|
||||||
|
|
||||||
|
if (!rtw_is_hw_init_completed(padapter)) {
|
||||||
|
status = _FAIL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
RTW_INFO("Set SSID under fw_state=0x%08x\n", get_fwstate(pmlmepriv));
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_SURVEY) == _TRUE)
|
||||||
|
goto handle_tkip_countermeasure;
|
||||||
|
else if (check_fwstate(pmlmepriv, WIFI_UNDER_LINKING) == _TRUE)
|
||||||
|
goto release_mlme_lock;
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_ADHOC_MASTER_STATE) == _TRUE) {
|
||||||
|
|
||||||
|
if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&
|
||||||
|
(_rtw_memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength) == _TRUE)) {
|
||||||
|
if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _FALSE)) {
|
||||||
|
|
||||||
|
if (rtw_is_same_ibss(padapter, pnetwork) == _FALSE) {
|
||||||
|
/* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */
|
||||||
|
rtw_disassoc_cmd(padapter, 0, 0);
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE)
|
||||||
|
rtw_indicate_disconnect(padapter, 0, _FALSE);
|
||||||
|
|
||||||
|
rtw_free_assoc_resources_cmd(padapter, _TRUE, 0);
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) {
|
||||||
|
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
|
||||||
|
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_LPS
|
||||||
|
else
|
||||||
|
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 0);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
|
||||||
|
rtw_disassoc_cmd(padapter, 0, 0);
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE)
|
||||||
|
rtw_indicate_disconnect(padapter, 0, _FALSE);
|
||||||
|
|
||||||
|
rtw_free_assoc_resources_cmd(padapter, _TRUE, 0);
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) {
|
||||||
|
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
|
||||||
|
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_tkip_countermeasure:
|
||||||
|
if (rtw_handle_tkip_countermeasure(padapter, __func__) == _FAIL) {
|
||||||
|
status = _FAIL;
|
||||||
|
goto release_mlme_lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rtw_validate_ssid(ssid) == _FALSE) {
|
||||||
|
status = _FAIL;
|
||||||
|
goto release_mlme_lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
_rtw_memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(NDIS_802_11_SSID));
|
||||||
|
pmlmepriv->assoc_ch = 0;
|
||||||
|
pmlmepriv->assoc_by_bssid = _FALSE;
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_SURVEY) == _TRUE)
|
||||||
|
pmlmepriv->to_join = _TRUE;
|
||||||
|
else
|
||||||
|
status = rtw_do_join(padapter);
|
||||||
|
|
||||||
|
release_mlme_lock:
|
||||||
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
|
|
||||||
|
return status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_set_802_11_connect(_adapter *padapter,
|
||||||
|
u8 *bssid, NDIS_802_11_SSID *ssid, u16 ch)
|
||||||
|
{
|
||||||
|
_irqL irqL;
|
||||||
|
u8 status = _SUCCESS;
|
||||||
|
bool bssid_valid = _TRUE;
|
||||||
|
bool ssid_valid = _TRUE;
|
||||||
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
|
|
||||||
|
|
||||||
|
if (!ssid || rtw_validate_ssid(ssid) == _FALSE)
|
||||||
|
ssid_valid = _FALSE;
|
||||||
|
|
||||||
|
if (!bssid || rtw_validate_bssid(bssid) == _FALSE)
|
||||||
|
bssid_valid = _FALSE;
|
||||||
|
|
||||||
|
if (ssid_valid == _FALSE && bssid_valid == _FALSE) {
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT" ssid:%p, ssid_valid:%d, bssid:%p, bssid_valid:%d\n",
|
||||||
|
FUNC_ADPT_ARG(padapter), ssid, ssid_valid, bssid, bssid_valid);
|
||||||
|
status = _FAIL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rtw_is_hw_init_completed(padapter)) {
|
||||||
|
status = _FAIL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
RTW_PRINT(FUNC_ADPT_FMT" fw_state=0x%08x\n",
|
||||||
|
FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_SURVEY) == _TRUE)
|
||||||
|
goto handle_tkip_countermeasure;
|
||||||
|
else if (check_fwstate(pmlmepriv, WIFI_UNDER_LINKING) == _TRUE)
|
||||||
|
goto release_mlme_lock;
|
||||||
|
|
||||||
|
handle_tkip_countermeasure:
|
||||||
|
if (rtw_handle_tkip_countermeasure(padapter, __func__) == _FAIL) {
|
||||||
|
status = _FAIL;
|
||||||
|
goto release_mlme_lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssid && ssid_valid)
|
||||||
|
_rtw_memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(NDIS_802_11_SSID));
|
||||||
|
else
|
||||||
|
_rtw_memset(&pmlmepriv->assoc_ssid, 0, sizeof(NDIS_802_11_SSID));
|
||||||
|
|
||||||
|
if (bssid && bssid_valid) {
|
||||||
|
_rtw_memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN);
|
||||||
|
pmlmepriv->assoc_by_bssid = _TRUE;
|
||||||
|
} else
|
||||||
|
pmlmepriv->assoc_by_bssid = _FALSE;
|
||||||
|
|
||||||
|
pmlmepriv->assoc_ch = ch;
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_SURVEY) == _TRUE)
|
||||||
|
pmlmepriv->to_join = _TRUE;
|
||||||
|
else
|
||||||
|
status = rtw_do_join(padapter);
|
||||||
|
|
||||||
|
release_mlme_lock:
|
||||||
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_set_802_11_infrastructure_mode(_adapter *padapter,
|
||||||
|
NDIS_802_11_NETWORK_INFRASTRUCTURE networktype, u8 flags)
|
||||||
|
{
|
||||||
|
_irqL irqL;
|
||||||
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
|
struct wlan_network *cur_network = &pmlmepriv->cur_network;
|
||||||
|
NDIS_802_11_NETWORK_INFRASTRUCTURE *pold_state = &(cur_network->network.InfrastructureMode);
|
||||||
|
u8 ap2sta_mode = _FALSE;
|
||||||
|
u8 ret = _TRUE;
|
||||||
|
u8 is_linked = _FALSE, is_adhoc_master = _FALSE;
|
||||||
|
|
||||||
|
if (*pold_state != networktype) {
|
||||||
|
/* RTW_INFO("change mode, old_mode=%d, new_mode=%d, fw_state=0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */
|
||||||
|
|
||||||
|
if (*pold_state == Ndis802_11APMode
|
||||||
|
|| *pold_state == Ndis802_11_mesh
|
||||||
|
) {
|
||||||
|
/* change to other mode from Ndis802_11APMode/Ndis802_11_mesh */
|
||||||
|
cur_network->join_res = -1;
|
||||||
|
ap2sta_mode = _TRUE;
|
||||||
|
#ifdef CONFIG_NATIVEAP_MLME
|
||||||
|
stop_ap_mode(padapter);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
is_linked = check_fwstate(pmlmepriv, WIFI_ASOC_STATE);
|
||||||
|
is_adhoc_master = check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
|
||||||
|
|
||||||
|
/* flags = 0, means enqueue cmd and no wait */
|
||||||
|
if (flags != 0)
|
||||||
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
if ((is_linked == _TRUE) || (*pold_state == Ndis802_11IBSS))
|
||||||
|
rtw_disassoc_cmd(padapter, 0, flags);
|
||||||
|
|
||||||
|
if ((is_linked == _TRUE) ||
|
||||||
|
(is_adhoc_master == _TRUE))
|
||||||
|
rtw_free_assoc_resources_cmd(padapter, _TRUE, flags);
|
||||||
|
|
||||||
|
if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) {
|
||||||
|
if (is_linked == _TRUE) {
|
||||||
|
rtw_indicate_disconnect(padapter, 0, _FALSE); /*will clr Linked_state; before this function, we must have checked whether issue dis-assoc_cmd or not*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flags = 0, means enqueue cmd and no wait */
|
||||||
|
if (flags != 0)
|
||||||
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
*pold_state = networktype;
|
||||||
|
|
||||||
|
_clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE);
|
||||||
|
|
||||||
|
switch (networktype) {
|
||||||
|
case Ndis802_11IBSS:
|
||||||
|
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ndis802_11Infrastructure:
|
||||||
|
set_fwstate(pmlmepriv, WIFI_STATION_STATE);
|
||||||
|
|
||||||
|
if (ap2sta_mode)
|
||||||
|
rtw_init_bcmc_stainfo(padapter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ndis802_11APMode:
|
||||||
|
set_fwstate(pmlmepriv, WIFI_AP_STATE);
|
||||||
|
#ifdef CONFIG_NATIVEAP_MLME
|
||||||
|
start_ap_mode(padapter);
|
||||||
|
/* rtw_indicate_connect(padapter); */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_MESH
|
||||||
|
case Ndis802_11_mesh:
|
||||||
|
set_fwstate(pmlmepriv, WIFI_MESH_STATE);
|
||||||
|
start_ap_mode(padapter);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case Ndis802_11AutoUnknown:
|
||||||
|
case Ndis802_11InfrastructureMax:
|
||||||
|
break;
|
||||||
|
#ifdef CONFIG_WIFI_MONITOR
|
||||||
|
case Ndis802_11Monitor:
|
||||||
|
set_fwstate(pmlmepriv, WIFI_MONITOR_STATE);
|
||||||
|
break;
|
||||||
|
#endif /* CONFIG_WIFI_MONITOR */
|
||||||
|
default:
|
||||||
|
ret = _FALSE;
|
||||||
|
rtw_warn_on(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* SecClearAllKeys(adapter); */
|
||||||
|
|
||||||
|
|
||||||
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u8 rtw_set_802_11_disassociate(_adapter *padapter)
|
||||||
|
{
|
||||||
|
_irqL irqL;
|
||||||
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
|
|
||||||
|
|
||||||
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE) {
|
||||||
|
|
||||||
|
rtw_disassoc_cmd(padapter, 0, 0);
|
||||||
|
rtw_indicate_disconnect(padapter, 0, _FALSE);
|
||||||
|
/* modify for CONFIG_IEEE80211W, none 11w can use it */
|
||||||
|
rtw_free_assoc_resources_cmd(padapter, _TRUE, 0);
|
||||||
|
if (_FAIL == rtw_pwr_wakeup(padapter))
|
||||||
|
RTW_INFO("%s(): rtw_pwr_wakeup fail !!!\n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
u8 rtw_set_802_11_bssid_list_scan(_adapter *padapter, struct sitesurvey_parm *pparm)
|
||||||
|
{
|
||||||
|
_irqL irqL;
|
||||||
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
|
u8 res = _TRUE;
|
||||||
|
|
||||||
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
res = rtw_sitesurvey_cmd(padapter, pparm);
|
||||||
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
u8 rtw_set_802_11_bssid_list_scan(_adapter *padapter, struct sitesurvey_parm *pparm)
|
||||||
|
{
|
||||||
|
_irqL irqL;
|
||||||
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
|
u8 res = _TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (padapter == NULL) {
|
||||||
|
res = _FALSE;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!rtw_is_hw_init_completed(padapter)) {
|
||||||
|
res = _FALSE;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((check_fwstate(pmlmepriv, WIFI_UNDER_SURVEY | WIFI_UNDER_LINKING) == _TRUE) ||
|
||||||
|
(pmlmepriv->LinkDetectInfo.bBusyTraffic == _TRUE)) {
|
||||||
|
/* Scan or linking is in progress, do nothing. */
|
||||||
|
res = _TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (rtw_is_scan_deny(padapter)) {
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT": scan deny\n", FUNC_ADPT_ARG(padapter));
|
||||||
|
indicate_wx_scan_complete_event(padapter);
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
|
||||||
|
res = rtw_sitesurvey_cmd(padapter, pparm);
|
||||||
|
|
||||||
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
||||||
|
}
|
||||||
|
exit:
|
||||||
|
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_ACS
|
||||||
|
u8 rtw_set_acs_sitesurvey(_adapter *adapter)
|
||||||
|
{
|
||||||
|
struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter);
|
||||||
|
struct sitesurvey_parm parm;
|
||||||
|
u8 uch;
|
||||||
|
u8 ch_num = 0;
|
||||||
|
int i;
|
||||||
|
BAND_TYPE band;
|
||||||
|
u8 (*center_chs_num)(u8) = NULL;
|
||||||
|
u8 (*center_chs)(u8, u8) = NULL;
|
||||||
|
u8 ret = _FAIL;
|
||||||
|
|
||||||
|
if (!rtw_mi_get_ch_setting_union(adapter, &uch, NULL, NULL))
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
_rtw_memset(&parm, 0, sizeof(struct sitesurvey_parm));
|
||||||
|
parm.scan_mode = SCAN_PASSIVE;
|
||||||
|
parm.bw = CHANNEL_WIDTH_20;
|
||||||
|
parm.acs = 1;
|
||||||
|
|
||||||
|
for (band = BAND_ON_2_4G; band < BAND_MAX; band++) {
|
||||||
|
if (band == BAND_ON_2_4G) {
|
||||||
|
center_chs_num = center_chs_2g_num;
|
||||||
|
center_chs = center_chs_2g;
|
||||||
|
} else
|
||||||
|
#ifdef CONFIG_IEEE80211_BAND_5GHZ
|
||||||
|
if (band == BAND_ON_5G) {
|
||||||
|
center_chs_num = center_chs_5g_num;
|
||||||
|
center_chs = center_chs_5g;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
center_chs_num = NULL;
|
||||||
|
center_chs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!center_chs_num || !center_chs)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (rfctl->ch_sel_within_same_band) {
|
||||||
|
if (rtw_is_2g_ch(uch) && band != BAND_ON_2_4G)
|
||||||
|
continue;
|
||||||
|
#ifdef CONFIG_IEEE80211_BAND_5GHZ
|
||||||
|
if (rtw_is_5g_ch(uch) && band != BAND_ON_5G)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ch_num = center_chs_num(CHANNEL_WIDTH_20);
|
||||||
|
for (i = 0; i < ch_num && parm.ch_num < RTW_CHANNEL_SCAN_AMOUNT; i++) {
|
||||||
|
parm.ch[parm.ch_num].hw_value = center_chs(CHANNEL_WIDTH_20, i);
|
||||||
|
parm.ch[parm.ch_num].flags = RTW_IEEE80211_CHAN_PASSIVE_SCAN;
|
||||||
|
parm.ch_num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = rtw_set_802_11_bssid_list_scan(adapter, &parm);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_RTW_ACS */
|
||||||
|
|
||||||
|
u8 rtw_set_802_11_authentication_mode(_adapter *padapter, NDIS_802_11_AUTHENTICATION_MODE authmode)
|
||||||
|
{
|
||||||
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||||
|
int res;
|
||||||
|
u8 ret;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
psecuritypriv->ndisauthtype = authmode;
|
||||||
|
|
||||||
|
|
||||||
|
if (psecuritypriv->ndisauthtype > 3)
|
||||||
|
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
|
||||||
|
|
||||||
|
#ifdef CONFIG_WAPI_SUPPORT
|
||||||
|
if (psecuritypriv->ndisauthtype == 6)
|
||||||
|
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_WAPI;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
res = rtw_set_auth(padapter, psecuritypriv);
|
||||||
|
|
||||||
|
if (res == _SUCCESS)
|
||||||
|
ret = _TRUE;
|
||||||
|
else
|
||||||
|
ret = _FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_set_802_11_add_wep(_adapter *padapter, NDIS_802_11_WEP *wep)
|
||||||
|
{
|
||||||
|
|
||||||
|
u8 bdefaultkey;
|
||||||
|
u8 btransmitkey;
|
||||||
|
sint keyid, res;
|
||||||
|
struct security_priv *psecuritypriv = &(padapter->securitypriv);
|
||||||
|
u8 ret = _SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? _FALSE : _TRUE; /* for ??? */
|
||||||
|
btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? _TRUE : _FALSE; /* for ??? */
|
||||||
|
keyid = wep->KeyIndex & 0x3fffffff;
|
||||||
|
|
||||||
|
if (keyid >= 4) {
|
||||||
|
ret = _FALSE;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (wep->KeyLength) {
|
||||||
|
case 5:
|
||||||
|
psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_rtw_memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength);
|
||||||
|
|
||||||
|
psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength;
|
||||||
|
|
||||||
|
psecuritypriv->dot11PrivacyKeyIndex = keyid;
|
||||||
|
|
||||||
|
|
||||||
|
res = rtw_set_key(padapter, psecuritypriv, keyid, 1, _TRUE);
|
||||||
|
|
||||||
|
if (res == _FAIL)
|
||||||
|
ret = _FALSE;
|
||||||
|
exit:
|
||||||
|
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rtw_get_cur_max_rate -
|
||||||
|
* @adapter: pointer to _adapter structure
|
||||||
|
*
|
||||||
|
* Return 0 or 100Kbps
|
||||||
|
*/
|
||||||
|
u16 rtw_get_cur_max_rate(_adapter *adapter)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
int i = 0;
|
||||||
|
u16 rate = 0, max_rate = 0;
|
||||||
|
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
||||||
|
WLAN_BSSID_EX *pcur_bss = &pmlmepriv->cur_network.network;
|
||||||
|
int sta_bssrate_len = 0;
|
||||||
|
unsigned char sta_bssrate[NumRates];
|
||||||
|
struct sta_info *psta = NULL;
|
||||||
|
u8 short_GI = 0;
|
||||||
|
|
||||||
|
#ifdef CONFIG_MP_INCLUDED
|
||||||
|
if (adapter->registrypriv.mp_mode == 1) {
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == _TRUE)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((check_fwstate(pmlmepriv, WIFI_ASOC_STATE) != _TRUE)
|
||||||
|
&& (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) != _TRUE))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
psta = rtw_get_stainfo(&adapter->stapriv, get_bssid(pmlmepriv));
|
||||||
|
if (psta == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
short_GI = query_ra_short_GI(psta, rtw_get_tx_bw_mode(adapter, psta));
|
||||||
|
|
||||||
|
#ifdef CONFIG_80211N_HT
|
||||||
|
if (is_supported_ht(psta->wireless_mode)) {
|
||||||
|
max_rate = rtw_ht_mcs_rate((psta->cmn.bw_mode == CHANNEL_WIDTH_40) ? 1 : 0
|
||||||
|
, short_GI
|
||||||
|
, psta->htpriv.ht_cap.supp_mcs_set
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_80211AC_VHT
|
||||||
|
else if (is_supported_vht(psta->wireless_mode))
|
||||||
|
max_rate = ((rtw_vht_mcs_to_data_rate(psta->cmn.bw_mode, short_GI, pmlmepriv->vhtpriv.vht_highest_rate) + 1) >> 1) * 10;
|
||||||
|
#endif /* CONFIG_80211AC_VHT */
|
||||||
|
else
|
||||||
|
#endif /* CONFIG_80211N_HT */
|
||||||
|
{
|
||||||
|
/*station mode show :station && ap support rate; softap :show ap support rate*/
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE)
|
||||||
|
get_rate_set(adapter, sta_bssrate, &sta_bssrate_len);/*get sta rate and length*/
|
||||||
|
|
||||||
|
|
||||||
|
while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) {
|
||||||
|
rate = pcur_bss->SupportedRates[i] & 0x7F;/*AP support rates*/
|
||||||
|
/*RTW_INFO("%s rate=%02X \n", __func__, rate);*/
|
||||||
|
|
||||||
|
/*check STA support rate or not */
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) {
|
||||||
|
for (j = 0; j < sta_bssrate_len; j++) {
|
||||||
|
/* Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP */
|
||||||
|
if ((rate | IEEE80211_BASIC_RATE_MASK)
|
||||||
|
== (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK)) {
|
||||||
|
if (rate > max_rate) {
|
||||||
|
max_rate = rate;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (rate > max_rate)
|
||||||
|
max_rate = rate;
|
||||||
|
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
max_rate = max_rate * 10 / 2;
|
||||||
|
}
|
||||||
|
return max_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rtw_set_scan_mode -
|
||||||
|
* @adapter: pointer to _adapter structure
|
||||||
|
* @scan_mode:
|
||||||
|
*
|
||||||
|
* Return _SUCCESS or _FAIL
|
||||||
|
*/
|
||||||
|
int rtw_set_scan_mode(_adapter *adapter, RT_SCAN_TYPE scan_mode)
|
||||||
|
{
|
||||||
|
if (scan_mode != SCAN_ACTIVE && scan_mode != SCAN_PASSIVE)
|
||||||
|
return _FAIL;
|
||||||
|
|
||||||
|
adapter->mlmepriv.scan_mode = scan_mode;
|
||||||
|
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rtw_set_channel_plan -
|
||||||
|
* @adapter: pointer to _adapter structure
|
||||||
|
* @channel_plan:
|
||||||
|
*
|
||||||
|
* Return _SUCCESS or _FAIL
|
||||||
|
*/
|
||||||
|
int rtw_set_channel_plan(_adapter *adapter, u8 channel_plan)
|
||||||
|
{
|
||||||
|
/* handle by cmd_thread to sync with scan operation */
|
||||||
|
return rtw_set_chplan_cmd(adapter, RTW_CMDF_WAIT_ACK, channel_plan, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rtw_set_country -
|
||||||
|
* @adapter: pointer to _adapter structure
|
||||||
|
* @country_code: string of country code
|
||||||
|
*
|
||||||
|
* Return _SUCCESS or _FAIL
|
||||||
|
*/
|
||||||
|
int rtw_set_country(_adapter *adapter, const char *country_code)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_RTW_IOCTL_SET_COUNTRY
|
||||||
|
return rtw_set_country_cmd(adapter, RTW_CMDF_WAIT_ACK, country_code, 1);
|
||||||
|
#else
|
||||||
|
RTW_INFO("%s(): not applied\n", __func__);
|
||||||
|
return _SUCCESS;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rtw_set_band -
|
||||||
|
* @adapter: pointer to _adapter structure
|
||||||
|
* @band: band to set
|
||||||
|
*
|
||||||
|
* Return _SUCCESS or _FAIL
|
||||||
|
*/
|
||||||
|
int rtw_set_band(_adapter *adapter, u8 band)
|
||||||
|
{
|
||||||
|
if (rtw_band_valid(band)) {
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT" band:%d\n", FUNC_ADPT_ARG(adapter), band);
|
||||||
|
adapter->setband = band;
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
RTW_PRINT(FUNC_ADPT_FMT" band:%d fail\n", FUNC_ADPT_ARG(adapter), band);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
388
drivers/net/wireless/realtek/rtl8822ce/core/rtw_iol.c
Normal file
388
drivers/net/wireless/realtek/rtl8822ce/core/rtw_iol.c
Normal file
@@ -0,0 +1,388 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_IOL
|
||||||
|
struct xmit_frame *rtw_IOL_accquire_xmit_frame(ADAPTER *adapter)
|
||||||
|
{
|
||||||
|
struct xmit_frame *xmit_frame;
|
||||||
|
struct xmit_buf *xmitbuf;
|
||||||
|
struct pkt_attrib *pattrib;
|
||||||
|
struct xmit_priv *pxmitpriv = &(adapter->xmitpriv);
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
xmit_frame = rtw_alloc_xmitframe(pxmitpriv);
|
||||||
|
if (xmit_frame == NULL) {
|
||||||
|
RTW_INFO("%s rtw_alloc_xmitframe return null\n", __FUNCTION__);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmitbuf = rtw_alloc_xmitbuf(pxmitpriv);
|
||||||
|
if (xmitbuf == NULL) {
|
||||||
|
RTW_INFO("%s rtw_alloc_xmitbuf return null\n", __FUNCTION__);
|
||||||
|
rtw_free_xmitframe(pxmitpriv, xmit_frame);
|
||||||
|
xmit_frame = NULL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmit_frame->frame_tag = MGNT_FRAMETAG;
|
||||||
|
xmit_frame->pxmitbuf = xmitbuf;
|
||||||
|
xmit_frame->buf_addr = xmitbuf->pbuf;
|
||||||
|
xmitbuf->priv_data = xmit_frame;
|
||||||
|
|
||||||
|
pattrib = &xmit_frame->attrib;
|
||||||
|
update_mgntframe_attrib(adapter, pattrib);
|
||||||
|
pattrib->qsel = QSLT_BEACON;/* Beacon */
|
||||||
|
pattrib->subtype = WIFI_BEACON;
|
||||||
|
pattrib->pktlen = pattrib->last_txcmdsz = 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
xmit_frame = alloc_mgtxmitframe(pxmitpriv);
|
||||||
|
if (xmit_frame == NULL)
|
||||||
|
RTW_INFO("%s alloc_mgtxmitframe return null\n", __FUNCTION__);
|
||||||
|
else {
|
||||||
|
pattrib = &xmit_frame->attrib;
|
||||||
|
update_mgntframe_attrib(adapter, pattrib);
|
||||||
|
pattrib->qsel = QSLT_BEACON;
|
||||||
|
pattrib->pktlen = pattrib->last_txcmdsz = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return xmit_frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len)
|
||||||
|
{
|
||||||
|
struct pkt_attrib *pattrib = &xmit_frame->attrib;
|
||||||
|
u16 buf_offset;
|
||||||
|
u32 ori_len;
|
||||||
|
|
||||||
|
buf_offset = TXDESC_OFFSET;
|
||||||
|
ori_len = buf_offset + pattrib->pktlen;
|
||||||
|
|
||||||
|
/* check if the io_buf can accommodate new cmds */
|
||||||
|
if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ) {
|
||||||
|
RTW_INFO("%s %u is large than MAX_XMITBUF_SZ:%u, can't accommodate new cmds\n", __FUNCTION__
|
||||||
|
, ori_len + cmd_len + 8, MAX_XMITBUF_SZ);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_rtw_memcpy(xmit_frame->buf_addr + buf_offset + pattrib->pktlen, IOL_cmds, cmd_len);
|
||||||
|
pattrib->pktlen += cmd_len;
|
||||||
|
pattrib->last_txcmdsz += cmd_len;
|
||||||
|
|
||||||
|
/* RTW_INFO("%s ori:%u + cmd_len:%u = %u\n", __FUNCTION__, ori_len, cmd_len, buf_offset+pattrib->pktlen); */
|
||||||
|
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rtw_IOL_applied(ADAPTER *adapter)
|
||||||
|
{
|
||||||
|
if (1 == adapter->registrypriv.fw_iol)
|
||||||
|
return _TRUE;
|
||||||
|
|
||||||
|
#ifdef CONFIG_USB_HCI
|
||||||
|
if ((2 == adapter->registrypriv.fw_iol) && (IS_FULL_SPEED_USB(adapter)))
|
||||||
|
return _TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtw_IOL_exec_cmds_sync(ADAPTER *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt)
|
||||||
|
{
|
||||||
|
return rtw_hal_iol_cmd(adapter, xmit_frame, max_wating_ms, bndy_cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_IOL_NEW_GENERATION
|
||||||
|
int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary)
|
||||||
|
{
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, u8 mask)
|
||||||
|
{
|
||||||
|
struct ioreg_cfg cmd = {8, IOREG_CMD_WB_REG, 0x0, 0x0, 0x0};
|
||||||
|
|
||||||
|
/* RTW_PUT_LE16((u8*)&cmd.address, addr); */
|
||||||
|
/* RTW_PUT_LE32((u8*)&cmd.value, (u32)value); */
|
||||||
|
cmd.address = cpu_to_le16(addr);
|
||||||
|
cmd.data = cpu_to_le32(value);
|
||||||
|
|
||||||
|
if (mask != 0xFF) {
|
||||||
|
cmd.length = 12;
|
||||||
|
/* RTW_PUT_LE32((u8*)&cmd.mask, (u32)mask); */
|
||||||
|
cmd.mask = cpu_to_le32(mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RTW_INFO("%s addr:0x%04x,value:0x%08x,mask:0x%08x\n", __FUNCTION__, addr,value,mask); */
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
|
||||||
|
|
||||||
|
}
|
||||||
|
int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, u16 mask)
|
||||||
|
{
|
||||||
|
struct ioreg_cfg cmd = {8, IOREG_CMD_WW_REG, 0x0, 0x0, 0x0};
|
||||||
|
|
||||||
|
/* RTW_PUT_LE16((u8*)&cmd.address, addr); */
|
||||||
|
/* RTW_PUT_LE32((u8*)&cmd.value, (u32)value); */
|
||||||
|
cmd.address = cpu_to_le16(addr);
|
||||||
|
cmd.data = cpu_to_le32(value);
|
||||||
|
|
||||||
|
if (mask != 0xFFFF) {
|
||||||
|
cmd.length = 12;
|
||||||
|
/* RTW_PUT_LE32((u8*)&cmd.mask, (u32)mask); */
|
||||||
|
cmd.mask = cpu_to_le32(mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RTW_INFO("%s addr:0x%04x,value:0x%08x,mask:0x%08x\n", __FUNCTION__, addr,value,mask); */
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
|
||||||
|
|
||||||
|
}
|
||||||
|
int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, u32 mask)
|
||||||
|
{
|
||||||
|
struct ioreg_cfg cmd = {8, IOREG_CMD_WD_REG, 0x0, 0x0, 0x0};
|
||||||
|
|
||||||
|
/* RTW_PUT_LE16((u8*)&cmd.address, addr); */
|
||||||
|
/* RTW_PUT_LE32((u8*)&cmd.value, (u32)value); */
|
||||||
|
cmd.address = cpu_to_le16(addr);
|
||||||
|
cmd.data = cpu_to_le32(value);
|
||||||
|
|
||||||
|
if (mask != 0xFFFFFFFF) {
|
||||||
|
cmd.length = 12;
|
||||||
|
/* RTW_PUT_LE32((u8*)&cmd.mask, (u32)mask); */
|
||||||
|
cmd.mask = cpu_to_le32(mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RTW_INFO("%s addr:0x%04x,value:0x%08x,mask:0x%08x\n", __FU2NCTION__, addr,value,mask); */
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, u32 value, u32 mask)
|
||||||
|
{
|
||||||
|
struct ioreg_cfg cmd = {8, IOREG_CMD_W_RF, 0x0, 0x0, 0x0};
|
||||||
|
|
||||||
|
/* RTW_PUT_LE16((u8*)&cmd.address, addr); */
|
||||||
|
/* RTW_PUT_LE32((u8*)&cmd.value, (u32)value); */
|
||||||
|
cmd.address = (rf_path << 8) | ((addr) & 0xFF);
|
||||||
|
cmd.data = cpu_to_le32(value);
|
||||||
|
|
||||||
|
if (mask != 0x000FFFFF) {
|
||||||
|
cmd.length = 12;
|
||||||
|
/* RTW_PUT_LE32((u8*)&cmd.mask, (u32)mask); */
|
||||||
|
cmd.mask = cpu_to_le32(mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RTW_INFO("%s rf_path:0x%02x addr:0x%04x,value:0x%08x,mask:0x%08x\n", __FU2NCTION__,rf_path, addr,value,mask); */
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us)
|
||||||
|
{
|
||||||
|
struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0};
|
||||||
|
/* RTW_PUT_LE16((u8*)&cmd.address, us); */
|
||||||
|
cmd.address = cpu_to_le16(us);
|
||||||
|
|
||||||
|
/* RTW_INFO("%s %u\n", __FUNCTION__, us); */
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms)
|
||||||
|
{
|
||||||
|
struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0};
|
||||||
|
|
||||||
|
/* RTW_PUT_LE16((u8*)&cmd.address, ms); */
|
||||||
|
cmd.address = cpu_to_le16(ms);
|
||||||
|
|
||||||
|
/* RTW_INFO("%s %u\n", __FUNCTION__, ms); */
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
|
||||||
|
}
|
||||||
|
int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame)
|
||||||
|
{
|
||||||
|
struct ioreg_cfg cmd = {4, IOREG_CMD_END, 0xFFFF, 0xFF, 0x0};
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame)
|
||||||
|
{
|
||||||
|
u8 is_cmd_bndy = _FALSE;
|
||||||
|
if (((pxmit_frame->attrib.pktlen + 32) % 256) + 8 >= 256) {
|
||||||
|
rtw_IOL_append_END_cmd(pxmit_frame);
|
||||||
|
pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen + 32) / 256) + 1) * 256);
|
||||||
|
|
||||||
|
/* printk("==> %s, pktlen(%d)\n",__FUNCTION__,pxmit_frame->attrib.pktlen); */
|
||||||
|
pxmit_frame->attrib.last_txcmdsz = pxmit_frame->attrib.pktlen;
|
||||||
|
is_cmd_bndy = _TRUE;
|
||||||
|
}
|
||||||
|
return is_cmd_bndy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_IOL_cmd_buf_dump(ADAPTER *Adapter, int buf_len, u8 *pbuf)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j = 1;
|
||||||
|
|
||||||
|
printk("###### %s ######\n", __FUNCTION__);
|
||||||
|
for (i = 0; i < buf_len; i++) {
|
||||||
|
printk("%02x-", *(pbuf + i));
|
||||||
|
|
||||||
|
if (j % 32 == 0)
|
||||||
|
printk("\n");
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
printk("============= ioreg_cmd len = %d ===============\n", buf_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else /* CONFIG_IOL_NEW_GENERATION */
|
||||||
|
int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary)
|
||||||
|
{
|
||||||
|
IOL_CMD cmd = {0x0, IOL_CMD_LLT, 0x0, 0x0};
|
||||||
|
|
||||||
|
RTW_PUT_BE32((u8 *)&cmd.value, (u32)page_boundary);
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value)
|
||||||
|
{
|
||||||
|
IOL_CMD cmd = {0x0, IOL_CMD_WB_REG, 0x0, 0x0};
|
||||||
|
|
||||||
|
RTW_PUT_BE16((u8 *)&cmd.address, (u16)addr);
|
||||||
|
RTW_PUT_BE32((u8 *)&cmd.value, (u32)value);
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value)
|
||||||
|
{
|
||||||
|
IOL_CMD cmd = {0x0, IOL_CMD_WW_REG, 0x0, 0x0};
|
||||||
|
|
||||||
|
RTW_PUT_BE16((u8 *)&cmd.address, (u16)addr);
|
||||||
|
RTW_PUT_BE32((u8 *)&cmd.value, (u32)value);
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value)
|
||||||
|
{
|
||||||
|
IOL_CMD cmd = {0x0, IOL_CMD_WD_REG, 0x0, 0x0};
|
||||||
|
u8 *pos = (u8 *)&cmd;
|
||||||
|
|
||||||
|
RTW_PUT_BE16((u8 *)&cmd.address, (u16)addr);
|
||||||
|
RTW_PUT_BE32((u8 *)&cmd.value, (u32)value);
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DBG_IO
|
||||||
|
int dbg_rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(xmit_frame->padapter, addr, 1, value)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d IOL_WB(0x%04x, 0x%02x)\n"
|
||||||
|
, caller, line, addr, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_IOL_append_WB_cmd(xmit_frame, addr, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbg_rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(xmit_frame->padapter, addr, 2, value)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d IOL_WW(0x%04x, 0x%04x)\n"
|
||||||
|
, caller, line, addr, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_IOL_append_WW_cmd(xmit_frame, addr, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbg_rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, const char *caller, const int line)
|
||||||
|
{
|
||||||
|
if (match_write_sniff(xmit_frame->padapter, addr, 4, value)) {
|
||||||
|
RTW_INFO("DBG_IO %s:%d IOL_WD(0x%04x, 0x%08x)\n"
|
||||||
|
, caller, line, addr, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _rtw_IOL_append_WD_cmd(xmit_frame, addr, value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us)
|
||||||
|
{
|
||||||
|
IOL_CMD cmd = {0x0, IOL_CMD_DELAY_US, 0x0, 0x0};
|
||||||
|
|
||||||
|
RTW_PUT_BE32((u8 *)&cmd.value, (u32)us);
|
||||||
|
|
||||||
|
/* RTW_INFO("%s %u\n", __FUNCTION__, us); */
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms)
|
||||||
|
{
|
||||||
|
IOL_CMD cmd = {0x0, IOL_CMD_DELAY_MS, 0x0, 0x0};
|
||||||
|
|
||||||
|
RTW_PUT_BE32((u8 *)&cmd.value, (u32)ms);
|
||||||
|
|
||||||
|
/* RTW_INFO("%s %u\n", __FUNCTION__, ms); */
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame)
|
||||||
|
{
|
||||||
|
IOL_CMD end_cmd = {0x0, IOL_CMD_END, 0x0, 0x0};
|
||||||
|
|
||||||
|
|
||||||
|
return rtw_IOL_append_cmds(xmit_frame, (u8 *)&end_cmd, 8);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtw_IOL_exec_cmd_array_sync(PADAPTER adapter, u8 *IOL_cmds, u32 cmd_num, u32 max_wating_ms)
|
||||||
|
{
|
||||||
|
struct xmit_frame *xmit_frame;
|
||||||
|
|
||||||
|
xmit_frame = rtw_IOL_accquire_xmit_frame(adapter);
|
||||||
|
if (xmit_frame == NULL)
|
||||||
|
return _FAIL;
|
||||||
|
|
||||||
|
if (rtw_IOL_append_cmds(xmit_frame, IOL_cmds, cmd_num << 3) == _FAIL)
|
||||||
|
return _FAIL;
|
||||||
|
|
||||||
|
return rtw_IOL_exec_cmds_sync(adapter, xmit_frame, max_wating_ms, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtw_IOL_exec_empty_cmds_sync(ADAPTER *adapter, u32 max_wating_ms)
|
||||||
|
{
|
||||||
|
IOL_CMD end_cmd = {0x0, IOL_CMD_END, 0x0, 0x0};
|
||||||
|
return rtw_IOL_exec_cmd_array_sync(adapter, (u8 *)&end_cmd, 1, max_wating_ms);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_IOL_NEW_GENERATION */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CONFIG_IOL */
|
||||||
128
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mem.c
Normal file
128
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mem.c
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <rtw_mem.h>
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_DESCRIPTION("Realtek Wireless Lan Driver");
|
||||||
|
MODULE_AUTHOR("Realtek Semiconductor Corp.");
|
||||||
|
MODULE_VERSION("DRIVERVERSION");
|
||||||
|
|
||||||
|
struct sk_buff_head rtk_skb_mem_q;
|
||||||
|
struct u8 *rtk_buf_mem[NR_RECVBUFF];
|
||||||
|
|
||||||
|
struct u8 *rtw_get_buf_premem(int index)
|
||||||
|
{
|
||||||
|
printk("%s, rtk_buf_mem index : %d\n", __func__, index);
|
||||||
|
return rtk_buf_mem[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 rtw_rtkm_get_buff_size(void)
|
||||||
|
{
|
||||||
|
return MAX_RTKM_RECVBUF_SZ;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(rtw_rtkm_get_buff_size);
|
||||||
|
|
||||||
|
u8 rtw_rtkm_get_nr_recv_skb(void)
|
||||||
|
{
|
||||||
|
return MAX_RTKM_NR_PREALLOC_RECV_SKB;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(rtw_rtkm_get_nr_recv_skb);
|
||||||
|
|
||||||
|
struct sk_buff *rtw_alloc_skb_premem(u16 in_size)
|
||||||
|
{
|
||||||
|
struct sk_buff *skb = NULL;
|
||||||
|
|
||||||
|
if (in_size > MAX_RTKM_RECVBUF_SZ) {
|
||||||
|
pr_info("warning %s: driver buffer size(%d) > rtkm buffer size(%d)\n", __func__, in_size, MAX_RTKM_RECVBUF_SZ);
|
||||||
|
WARN_ON(1);
|
||||||
|
return skb;
|
||||||
|
}
|
||||||
|
|
||||||
|
skb = skb_dequeue(&rtk_skb_mem_q);
|
||||||
|
|
||||||
|
printk("%s, rtk_skb_mem_q len : %d\n", __func__, skb_queue_len(&rtk_skb_mem_q));
|
||||||
|
|
||||||
|
return skb;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(rtw_alloc_skb_premem);
|
||||||
|
|
||||||
|
int rtw_free_skb_premem(struct sk_buff *pskb)
|
||||||
|
{
|
||||||
|
if (!pskb)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (skb_queue_len(&rtk_skb_mem_q) >= MAX_RTKM_NR_PREALLOC_RECV_SKB)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
skb_queue_tail(&rtk_skb_mem_q, pskb);
|
||||||
|
|
||||||
|
printk("%s, rtk_skb_mem_q len : %d\n", __func__, skb_queue_len(&rtk_skb_mem_q));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(rtw_free_skb_premem);
|
||||||
|
|
||||||
|
static int __init rtw_mem_init(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
SIZE_PTR tmpaddr = 0;
|
||||||
|
SIZE_PTR alignment = 0;
|
||||||
|
struct sk_buff *pskb = NULL;
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
pr_info("MAX_RTKM_NR_PREALLOC_RECV_SKB: %d\n", MAX_RTKM_NR_PREALLOC_RECV_SKB);
|
||||||
|
pr_info("MAX_RTKM_RECVBUF_SZ: %d\n", MAX_RTKM_RECVBUF_SZ);
|
||||||
|
|
||||||
|
#ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
|
||||||
|
for (i = 0; i < NR_RECVBUFF; i++)
|
||||||
|
rtk_buf_mem[i] = usb_buffer_alloc(dev, size, (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL), dma);
|
||||||
|
#endif /* CONFIG_USE_USB_BUFFER_ALLOC_RX */
|
||||||
|
|
||||||
|
skb_queue_head_init(&rtk_skb_mem_q);
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_RTKM_NR_PREALLOC_RECV_SKB; i++) {
|
||||||
|
pskb = __dev_alloc_skb(MAX_RTKM_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
|
||||||
|
if (pskb) {
|
||||||
|
tmpaddr = (SIZE_PTR)pskb->data;
|
||||||
|
alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
|
||||||
|
skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment));
|
||||||
|
|
||||||
|
skb_queue_tail(&rtk_skb_mem_q, pskb);
|
||||||
|
} else
|
||||||
|
printk("%s, alloc skb memory fail!\n", __func__);
|
||||||
|
|
||||||
|
pskb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk("%s, rtk_skb_mem_q len : %d\n", __func__, skb_queue_len(&rtk_skb_mem_q));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __exit rtw_mem_exit(void)
|
||||||
|
{
|
||||||
|
if (skb_queue_len(&rtk_skb_mem_q))
|
||||||
|
printk("%s, rtk_skb_mem_q len : %d\n", __func__, skb_queue_len(&rtk_skb_mem_q));
|
||||||
|
|
||||||
|
skb_queue_purge(&rtk_skb_mem_q);
|
||||||
|
|
||||||
|
printk("%s\n", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
module_init(rtw_mem_init);
|
||||||
|
module_exit(rtw_mem_exit);
|
||||||
1550
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mi.c
Normal file
1550
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mi.c
Normal file
File diff suppressed because it is too large
Load Diff
5325
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mlme.c
Normal file
5325
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mlme.c
Normal file
File diff suppressed because it is too large
Load Diff
17318
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mlme_ext.c
Normal file
17318
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mlme_ext.c
Normal file
File diff suppressed because it is too large
Load Diff
3971
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mp.c
Normal file
3971
drivers/net/wireless/realtek/rtl8822ce/core/rtw_mp.c
Normal file
File diff suppressed because it is too large
Load Diff
601
drivers/net/wireless/realtek/rtl8822ce/core/rtw_odm.c
Normal file
601
drivers/net/wireless/realtek/rtl8822ce/core/rtw_odm.c
Normal file
@@ -0,0 +1,601 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2013 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <rtw_odm.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
|
||||||
|
u32 rtw_phydm_ability_ops(_adapter *adapter, HAL_PHYDM_OPS ops, u32 ability)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(adapter);
|
||||||
|
struct dm_struct *podmpriv = &pHalData->odmpriv;
|
||||||
|
u32 result = 0;
|
||||||
|
|
||||||
|
switch (ops) {
|
||||||
|
case HAL_PHYDM_DIS_ALL_FUNC:
|
||||||
|
podmpriv->support_ability = DYNAMIC_FUNC_DISABLE;
|
||||||
|
halrf_cmn_info_set(podmpriv, HALRF_CMNINFO_ABILITY, DYNAMIC_FUNC_DISABLE);
|
||||||
|
break;
|
||||||
|
case HAL_PHYDM_FUNC_SET:
|
||||||
|
podmpriv->support_ability |= ability;
|
||||||
|
break;
|
||||||
|
case HAL_PHYDM_FUNC_CLR:
|
||||||
|
podmpriv->support_ability &= ~(ability);
|
||||||
|
break;
|
||||||
|
case HAL_PHYDM_ABILITY_BK:
|
||||||
|
/* dm flag backup*/
|
||||||
|
podmpriv->bk_support_ability = podmpriv->support_ability;
|
||||||
|
pHalData->bk_rf_ability = halrf_cmn_info_get(podmpriv, HALRF_CMNINFO_ABILITY);
|
||||||
|
break;
|
||||||
|
case HAL_PHYDM_ABILITY_RESTORE:
|
||||||
|
/* restore dm flag */
|
||||||
|
podmpriv->support_ability = podmpriv->bk_support_ability;
|
||||||
|
halrf_cmn_info_set(podmpriv, HALRF_CMNINFO_ABILITY, pHalData->bk_rf_ability);
|
||||||
|
break;
|
||||||
|
case HAL_PHYDM_ABILITY_SET:
|
||||||
|
podmpriv->support_ability = ability;
|
||||||
|
break;
|
||||||
|
case HAL_PHYDM_ABILITY_GET:
|
||||||
|
result = podmpriv->support_ability;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set ODM_CMNINFO_IC_TYPE based on chip_type */
|
||||||
|
void rtw_odm_init_ic_type(_adapter *adapter)
|
||||||
|
{
|
||||||
|
struct dm_struct *odm = adapter_to_phydm(adapter);
|
||||||
|
u32 ic_type = chip_type_to_odm_ic_type(rtw_get_chip_type(adapter));
|
||||||
|
|
||||||
|
rtw_warn_on(!ic_type);
|
||||||
|
|
||||||
|
odm_cmn_info_init(odm, ODM_CMNINFO_IC_TYPE, ic_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_odm_adaptivity_ver_msg(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
RTW_PRINT_SEL(sel, "ADAPTIVITY_VERSION "ADAPTIVITY_VERSION"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTW_ADAPTIVITY_EN_DISABLE 0
|
||||||
|
#define RTW_ADAPTIVITY_EN_ENABLE 1
|
||||||
|
|
||||||
|
void rtw_odm_adaptivity_en_msg(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
struct registry_priv *regsty = &adapter->registrypriv;
|
||||||
|
|
||||||
|
RTW_PRINT_SEL(sel, "RTW_ADAPTIVITY_EN_");
|
||||||
|
|
||||||
|
if (regsty->adaptivity_en == RTW_ADAPTIVITY_EN_DISABLE)
|
||||||
|
_RTW_PRINT_SEL(sel, "DISABLE\n");
|
||||||
|
else if (regsty->adaptivity_en == RTW_ADAPTIVITY_EN_ENABLE)
|
||||||
|
_RTW_PRINT_SEL(sel, "ENABLE\n");
|
||||||
|
else
|
||||||
|
_RTW_PRINT_SEL(sel, "INVALID\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTW_ADAPTIVITY_MODE_NORMAL 0
|
||||||
|
#define RTW_ADAPTIVITY_MODE_CARRIER_SENSE 1
|
||||||
|
|
||||||
|
void rtw_odm_adaptivity_mode_msg(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
struct registry_priv *regsty = &adapter->registrypriv;
|
||||||
|
|
||||||
|
RTW_PRINT_SEL(sel, "RTW_ADAPTIVITY_MODE_");
|
||||||
|
|
||||||
|
if (regsty->adaptivity_mode == RTW_ADAPTIVITY_MODE_NORMAL)
|
||||||
|
_RTW_PRINT_SEL(sel, "NORMAL\n");
|
||||||
|
else if (regsty->adaptivity_mode == RTW_ADAPTIVITY_MODE_CARRIER_SENSE)
|
||||||
|
_RTW_PRINT_SEL(sel, "CARRIER_SENSE\n");
|
||||||
|
else
|
||||||
|
_RTW_PRINT_SEL(sel, "INVALID\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_odm_adaptivity_config_msg(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
rtw_odm_adaptivity_ver_msg(sel, adapter);
|
||||||
|
rtw_odm_adaptivity_en_msg(sel, adapter);
|
||||||
|
rtw_odm_adaptivity_mode_msg(sel, adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rtw_odm_adaptivity_needed(_adapter *adapter)
|
||||||
|
{
|
||||||
|
struct registry_priv *regsty = &adapter->registrypriv;
|
||||||
|
bool ret = _FALSE;
|
||||||
|
|
||||||
|
if (regsty->adaptivity_en == RTW_ADAPTIVITY_EN_ENABLE)
|
||||||
|
ret = _TRUE;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_odm_adaptivity_parm_msg(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
struct dm_struct *odm = adapter_to_phydm(adapter);
|
||||||
|
|
||||||
|
rtw_odm_adaptivity_config_msg(sel, adapter);
|
||||||
|
|
||||||
|
RTW_PRINT_SEL(sel, "%10s %16s\n"
|
||||||
|
, "th_l2h_ini", "th_edcca_hl_diff");
|
||||||
|
RTW_PRINT_SEL(sel, "0x%-8x %-16d\n"
|
||||||
|
, (u8)odm->th_l2h_ini
|
||||||
|
, odm->th_edcca_hl_diff
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_odm_adaptivity_parm_set(_adapter *adapter, s8 th_l2h_ini, s8 th_edcca_hl_diff)
|
||||||
|
{
|
||||||
|
struct dm_struct *odm = adapter_to_phydm(adapter);
|
||||||
|
|
||||||
|
odm->th_l2h_ini = th_l2h_ini;
|
||||||
|
odm->th_edcca_hl_diff = th_edcca_hl_diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_odm_get_perpkt_rssi(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
struct dm_struct *odm = adapter_to_phydm(adapter);
|
||||||
|
|
||||||
|
RTW_PRINT_SEL(sel, "rx_rate = %s, rssi_a = %d(%%), rssi_b = %d(%%)\n",
|
||||||
|
HDATA_RATE(odm->rx_rate), odm->rssi_a, odm->rssi_b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rtw_odm_acquirespinlock(_adapter *adapter, enum rt_spinlock_type type)
|
||||||
|
{
|
||||||
|
PHAL_DATA_TYPE pHalData = GET_HAL_DATA(adapter);
|
||||||
|
_irqL irqL;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case RT_IQK_SPINLOCK:
|
||||||
|
_enter_critical_bh(&pHalData->IQKSpinLock, &irqL);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_odm_releasespinlock(_adapter *adapter, enum rt_spinlock_type type)
|
||||||
|
{
|
||||||
|
PHAL_DATA_TYPE pHalData = GET_HAL_DATA(adapter);
|
||||||
|
_irqL irqL;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case RT_IQK_SPINLOCK:
|
||||||
|
_exit_critical_bh(&pHalData->IQKSpinLock, &irqL);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u8 rtw_odm_get_dfs_domain(struct dvobj_priv *dvobj)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_DFS_MASTER
|
||||||
|
struct dm_struct *pDM_Odm = dvobj_to_phydm(dvobj);
|
||||||
|
|
||||||
|
return pDM_Odm->dfs_region_domain;
|
||||||
|
#else
|
||||||
|
return PHYDM_DFS_DOMAIN_UNKNOWN;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u8 rtw_odm_dfs_domain_unknown(struct dvobj_priv *dvobj)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_DFS_MASTER
|
||||||
|
return rtw_odm_get_dfs_domain(dvobj) == PHYDM_DFS_DOMAIN_UNKNOWN;
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DFS_MASTER
|
||||||
|
inline void rtw_odm_radar_detect_reset(_adapter *adapter)
|
||||||
|
{
|
||||||
|
phydm_radar_detect_reset(adapter_to_phydm(adapter));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void rtw_odm_radar_detect_disable(_adapter *adapter)
|
||||||
|
{
|
||||||
|
phydm_radar_detect_disable(adapter_to_phydm(adapter));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* called after ch, bw is set */
|
||||||
|
inline void rtw_odm_radar_detect_enable(_adapter *adapter)
|
||||||
|
{
|
||||||
|
phydm_radar_detect_enable(adapter_to_phydm(adapter));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline BOOLEAN rtw_odm_radar_detect(_adapter *adapter)
|
||||||
|
{
|
||||||
|
return phydm_radar_detect(adapter_to_phydm(adapter));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u8 rtw_odm_radar_detect_polling_int_ms(struct dvobj_priv *dvobj)
|
||||||
|
{
|
||||||
|
return phydm_dfs_polling_time(dvobj_to_phydm(dvobj));
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_DFS_MASTER */
|
||||||
|
|
||||||
|
void rtw_odm_parse_rx_phy_status_chinfo(union recv_frame *rframe, u8 *phys)
|
||||||
|
{
|
||||||
|
#ifndef DBG_RX_PHYSTATUS_CHINFO
|
||||||
|
#define DBG_RX_PHYSTATUS_CHINFO 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (ODM_PHY_STATUS_NEW_TYPE_SUPPORT == 1)
|
||||||
|
_adapter *adapter = rframe->u.hdr.adapter;
|
||||||
|
struct dm_struct *phydm = adapter_to_phydm(adapter);
|
||||||
|
struct rx_pkt_attrib *attrib = &rframe->u.hdr.attrib;
|
||||||
|
u8 *wlanhdr = get_recvframe_data(rframe);
|
||||||
|
|
||||||
|
if (phydm->support_ic_type & PHYSTS_2ND_TYPE_IC) {
|
||||||
|
/*
|
||||||
|
* 8723D:
|
||||||
|
* type_0(CCK)
|
||||||
|
* l_rxsc
|
||||||
|
* is filled with primary channel SC, not real rxsc.
|
||||||
|
* 0:LSC, 1:USC
|
||||||
|
* type_1(OFDM)
|
||||||
|
* rf_mode
|
||||||
|
* RF bandwidth when RX
|
||||||
|
* l_rxsc(legacy), ht_rxsc
|
||||||
|
* see below RXSC N-series
|
||||||
|
* type_2(Not used)
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* 8821C, 8822B:
|
||||||
|
* type_0(CCK)
|
||||||
|
* l_rxsc
|
||||||
|
* is filled with primary channel SC, not real rxsc.
|
||||||
|
* 0:LSC, 1:USC
|
||||||
|
* type_1(OFDM)
|
||||||
|
* rf_mode
|
||||||
|
* RF bandwidth when RX
|
||||||
|
* l_rxsc(legacy), ht_rxsc
|
||||||
|
* see below RXSC AC-series
|
||||||
|
* type_2(Not used)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ((*phys & 0xf) == 0) {
|
||||||
|
struct phy_sts_rpt_jgr2_type0 *phys_t0 = (struct phy_sts_rpt_jgr2_type0 *)phys;
|
||||||
|
|
||||||
|
if (DBG_RX_PHYSTATUS_CHINFO) {
|
||||||
|
RTW_PRINT("phys_t%u ta="MAC_FMT" %s, %s(band:%u, ch:%u, l_rxsc:%u)\n"
|
||||||
|
, *phys & 0xf
|
||||||
|
, MAC_ARG(get_ta(wlanhdr))
|
||||||
|
, is_broadcast_mac_addr(get_ra(wlanhdr)) ? "BC" : is_multicast_mac_addr(get_ra(wlanhdr)) ? "MC" : "UC"
|
||||||
|
, HDATA_RATE(attrib->data_rate)
|
||||||
|
, phys_t0->band, phys_t0->channel, phys_t0->rxsc
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ((*phys & 0xf) == 1) {
|
||||||
|
struct phy_sts_rpt_jgr2_type1 *phys_t1 = (struct phy_sts_rpt_jgr2_type1 *)phys;
|
||||||
|
u8 rxsc = (attrib->data_rate > DESC_RATE11M && attrib->data_rate < DESC_RATEMCS0) ? phys_t1->l_rxsc : phys_t1->ht_rxsc;
|
||||||
|
u8 pkt_cch = 0;
|
||||||
|
u8 pkt_bw = CHANNEL_WIDTH_20;
|
||||||
|
|
||||||
|
#if ODM_IC_11N_SERIES_SUPPORT
|
||||||
|
if (phydm->support_ic_type & ODM_IC_11N_SERIES) {
|
||||||
|
/* RXSC N-series */
|
||||||
|
#define RXSC_DUP 0
|
||||||
|
#define RXSC_LSC 1
|
||||||
|
#define RXSC_USC 2
|
||||||
|
#define RXSC_40M 3
|
||||||
|
|
||||||
|
static const s8 cch_offset_by_rxsc[4] = {0, -2, 2, 0};
|
||||||
|
|
||||||
|
if (phys_t1->rf_mode == 0) {
|
||||||
|
pkt_cch = phys_t1->channel;
|
||||||
|
pkt_bw = CHANNEL_WIDTH_20;
|
||||||
|
} else if (phys_t1->rf_mode == 1) {
|
||||||
|
if (rxsc == RXSC_LSC || rxsc == RXSC_USC) {
|
||||||
|
pkt_cch = phys_t1->channel + cch_offset_by_rxsc[rxsc];
|
||||||
|
pkt_bw = CHANNEL_WIDTH_20;
|
||||||
|
} else if (rxsc == RXSC_40M) {
|
||||||
|
pkt_cch = phys_t1->channel;
|
||||||
|
pkt_bw = CHANNEL_WIDTH_40;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
rtw_warn_on(1);
|
||||||
|
|
||||||
|
goto type1_end;
|
||||||
|
}
|
||||||
|
#endif /* ODM_IC_11N_SERIES_SUPPORT */
|
||||||
|
|
||||||
|
#if ODM_IC_11AC_SERIES_SUPPORT
|
||||||
|
if (phydm->support_ic_type & ODM_IC_11AC_SERIES) {
|
||||||
|
/* RXSC AC-series */
|
||||||
|
#define RXSC_DUP 0 /* 0: RX from all SC of current rf_mode */
|
||||||
|
|
||||||
|
#define RXSC_LL20M_OF_160M 8 /* 1~8: RX from 20MHz SC */
|
||||||
|
#define RXSC_L20M_OF_160M 6
|
||||||
|
#define RXSC_L20M_OF_80M 4
|
||||||
|
#define RXSC_L20M_OF_40M 2
|
||||||
|
#define RXSC_U20M_OF_40M 1
|
||||||
|
#define RXSC_U20M_OF_80M 3
|
||||||
|
#define RXSC_U20M_OF_160M 5
|
||||||
|
#define RXSC_UU20M_OF_160M 7
|
||||||
|
|
||||||
|
#define RXSC_L40M_OF_160M 12 /* 9~12: RX from 40MHz SC */
|
||||||
|
#define RXSC_L40M_OF_80M 10
|
||||||
|
#define RXSC_U40M_OF_80M 9
|
||||||
|
#define RXSC_U40M_OF_160M 11
|
||||||
|
|
||||||
|
#define RXSC_L80M_OF_160M 14 /* 13~14: RX from 80MHz SC */
|
||||||
|
#define RXSC_U80M_OF_160M 13
|
||||||
|
|
||||||
|
static const s8 cch_offset_by_rxsc[15] = {0, 2, -2, 6, -6, 10, -10, 14, -14, 4, -4, 12, -12, 8, -8};
|
||||||
|
|
||||||
|
if (phys_t1->rf_mode == 0) {
|
||||||
|
/* RF 20MHz */
|
||||||
|
pkt_cch = phys_t1->channel;
|
||||||
|
pkt_bw = CHANNEL_WIDTH_20;
|
||||||
|
goto type1_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rxsc == 0) {
|
||||||
|
/* RF and RX with same BW */
|
||||||
|
if (attrib->data_rate >= DESC_RATEMCS0) {
|
||||||
|
pkt_cch = phys_t1->channel;
|
||||||
|
pkt_bw = phys_t1->rf_mode;
|
||||||
|
}
|
||||||
|
goto type1_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((phys_t1->rf_mode == 1 && rxsc >= 1 && rxsc <= 2) /* RF 40MHz, RX 20MHz */
|
||||||
|
|| (phys_t1->rf_mode == 2 && rxsc >= 1 && rxsc <= 4) /* RF 80MHz, RX 20MHz */
|
||||||
|
|| (phys_t1->rf_mode == 3 && rxsc >= 1 && rxsc <= 8) /* RF 160MHz, RX 20MHz */
|
||||||
|
) {
|
||||||
|
pkt_cch = phys_t1->channel + cch_offset_by_rxsc[rxsc];
|
||||||
|
pkt_bw = CHANNEL_WIDTH_20;
|
||||||
|
} else if ((phys_t1->rf_mode == 2 && rxsc >= 9 && rxsc <= 10) /* RF 80MHz, RX 40MHz */
|
||||||
|
|| (phys_t1->rf_mode == 3 && rxsc >= 9 && rxsc <= 12) /* RF 160MHz, RX 40MHz */
|
||||||
|
) {
|
||||||
|
if (attrib->data_rate >= DESC_RATEMCS0) {
|
||||||
|
pkt_cch = phys_t1->channel + cch_offset_by_rxsc[rxsc];
|
||||||
|
pkt_bw = CHANNEL_WIDTH_40;
|
||||||
|
}
|
||||||
|
} else if ((phys_t1->rf_mode == 3 && rxsc >= 13 && rxsc <= 14) /* RF 160MHz, RX 80MHz */
|
||||||
|
) {
|
||||||
|
if (attrib->data_rate >= DESC_RATEMCS0) {
|
||||||
|
pkt_cch = phys_t1->channel + cch_offset_by_rxsc[rxsc];
|
||||||
|
pkt_bw = CHANNEL_WIDTH_80;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
rtw_warn_on(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif /* ODM_IC_11AC_SERIES_SUPPORT */
|
||||||
|
|
||||||
|
type1_end:
|
||||||
|
if (DBG_RX_PHYSTATUS_CHINFO) {
|
||||||
|
RTW_PRINT("phys_t%u ta="MAC_FMT" %s, %s(band:%u, ch:%u, rf_mode:%u, l_rxsc:%u, ht_rxsc:%u) => %u,%u\n"
|
||||||
|
, *phys & 0xf
|
||||||
|
, MAC_ARG(get_ta(wlanhdr))
|
||||||
|
, is_broadcast_mac_addr(get_ra(wlanhdr)) ? "BC" : is_multicast_mac_addr(get_ra(wlanhdr)) ? "MC" : "UC"
|
||||||
|
, HDATA_RATE(attrib->data_rate)
|
||||||
|
, phys_t1->band, phys_t1->channel, phys_t1->rf_mode, phys_t1->l_rxsc, phys_t1->ht_rxsc
|
||||||
|
, pkt_cch, pkt_bw
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* for now, only return cneter channel of 20MHz packet */
|
||||||
|
if (pkt_cch && pkt_bw == CHANNEL_WIDTH_20)
|
||||||
|
attrib->ch = pkt_cch;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
struct phy_sts_rpt_jgr2_type2 *phys_t2 = (struct phy_sts_rpt_jgr2_type2 *)phys;
|
||||||
|
|
||||||
|
if (DBG_RX_PHYSTATUS_CHINFO) {
|
||||||
|
RTW_PRINT("phys_t%u ta="MAC_FMT" %s, %s(band:%u, ch:%u, l_rxsc:%u, ht_rxsc:%u)\n"
|
||||||
|
, *phys & 0xf
|
||||||
|
, MAC_ARG(get_ta(wlanhdr))
|
||||||
|
, is_broadcast_mac_addr(get_ra(wlanhdr)) ? "BC" : is_multicast_mac_addr(get_ra(wlanhdr)) ? "MC" : "UC"
|
||||||
|
, HDATA_RATE(attrib->data_rate)
|
||||||
|
, phys_t2->band, phys_t2->channel, phys_t2->l_rxsc, phys_t2->ht_rxsc
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* (ODM_PHY_STATUS_NEW_TYPE_SUPPORT == 1) */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8822C) && defined(CONFIG_LPS_PG)
|
||||||
|
void
|
||||||
|
debug_DACK(
|
||||||
|
struct dm_struct *dm
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//P_PHYDM_FUNC dm;
|
||||||
|
//dm = &(SysMib.ODM.Phydm);
|
||||||
|
//PIQK_OFFLOAD_PARM pIQK_info;
|
||||||
|
//pIQK_info= &(SysMib.ODM.IQKParm);
|
||||||
|
u8 i;
|
||||||
|
u32 temp1, temp2, temp3;
|
||||||
|
|
||||||
|
temp1 = odm_get_bb_reg(dm, 0x1860, bMaskDWord);
|
||||||
|
temp2 = odm_get_bb_reg(dm, 0x4160, bMaskDWord);
|
||||||
|
temp3 = odm_get_bb_reg(dm, 0x9b4, bMaskDWord);
|
||||||
|
|
||||||
|
odm_set_bb_reg(dm, 0x9b4, bMaskDWord, 0xdb66db00);
|
||||||
|
|
||||||
|
//pathA
|
||||||
|
odm_set_bb_reg(dm, 0x1830, BIT(30), 0x0);
|
||||||
|
odm_set_bb_reg(dm, 0x1860, 0xfc000000, 0x3c);
|
||||||
|
|
||||||
|
RTW_INFO("path A i\n");
|
||||||
|
//i
|
||||||
|
for (i = 0; i < 0xf; i++) {
|
||||||
|
odm_set_bb_reg(dm, 0x18b0, 0xf0000000, i);
|
||||||
|
RTW_INFO("[0][0][%d] = 0x%08x\n", i, (u16)odm_get_bb_reg(dm,0x2810,0x7fc0000));
|
||||||
|
//pIQK_info->msbk_d[0][0][i] = (u16)odm_get_bb_reg(dm,0x2810,0x7fc0000);
|
||||||
|
}
|
||||||
|
RTW_INFO("path A q\n");
|
||||||
|
//q
|
||||||
|
for (i = 0; i < 0xf; i++) {
|
||||||
|
odm_set_bb_reg(dm, 0x18cc, 0xf0000000, i);
|
||||||
|
RTW_INFO("[0][1][%d] = 0x%08x\n", i, (u16)odm_get_bb_reg(dm,0x283c,0x7fc0000));
|
||||||
|
//pIQK_info->msbk_d[0][1][i] = (u16)odm_get_bb_reg(dm,0x283c,0x7fc0000);
|
||||||
|
}
|
||||||
|
//pathB
|
||||||
|
odm_set_bb_reg(dm, 0x4130, BIT(30), 0x0);
|
||||||
|
odm_set_bb_reg(dm, 0x4160, 0xfc000000, 0x3c);
|
||||||
|
|
||||||
|
RTW_INFO("\npath B i\n");
|
||||||
|
//i
|
||||||
|
for (i = 0; i < 0xf; i++) {
|
||||||
|
odm_set_bb_reg(dm, 0x41b0, 0xf0000000, i);
|
||||||
|
RTW_INFO("[1][0][%d] = 0x%08x\n", i, (u16)odm_get_bb_reg(dm,0x4510,0x7fc0000));
|
||||||
|
//pIQK_info->msbk_d[1][0][i] = (u16)odm_get_bb_reg(dm,0x2810,0x7fc0000);
|
||||||
|
}
|
||||||
|
RTW_INFO("path B q\n");
|
||||||
|
//q
|
||||||
|
for (i = 0; i < 0xf; i++) {
|
||||||
|
odm_set_bb_reg(dm, 0x41cc, 0xf0000000, i);
|
||||||
|
RTW_INFO("[1][1][%d] = 0x%08x\n", i, (u16)odm_get_bb_reg(dm,0x453c,0x7fc0000));
|
||||||
|
//pIQK_info->msbk_d[1][1][i] = (u16)odm_get_bb_reg(dm,0x283c,0x7fc0000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//restore to normal
|
||||||
|
odm_set_bb_reg(dm, 0x1830, BIT(30), 0x1);
|
||||||
|
odm_set_bb_reg(dm, 0x4130, BIT(30), 0x1);
|
||||||
|
odm_set_bb_reg(dm, 0x1860, bMaskDWord, temp1);
|
||||||
|
odm_set_bb_reg(dm, 0x4160, bMaskDWord, temp2);
|
||||||
|
odm_set_bb_reg(dm, 0x9b4, bMaskDWord, temp3);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
debug_IQK(
|
||||||
|
struct dm_struct *dm,
|
||||||
|
IN u8 idx,
|
||||||
|
IN u8 path
|
||||||
|
)
|
||||||
|
{
|
||||||
|
u8 i, ch;
|
||||||
|
u32 tmp;
|
||||||
|
u32 bit_mask_20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
|
||||||
|
|
||||||
|
RTW_INFO("idx = %d, path = %d\n", idx, path);
|
||||||
|
|
||||||
|
odm_set_bb_reg(dm, 0x1b00, MASKDWORD, 0x8 | path << 1);
|
||||||
|
|
||||||
|
if (idx == TX_IQK) {//TXCFIR
|
||||||
|
odm_set_bb_reg(dm, R_0x1b20, BIT(31) | BIT(30), 0x3);
|
||||||
|
} else {//RXCFIR
|
||||||
|
odm_set_bb_reg(dm, R_0x1b20, BIT(31) | BIT(30), 0x1);
|
||||||
|
}
|
||||||
|
odm_set_bb_reg(dm, R_0x1bd4, BIT(21), 0x1);
|
||||||
|
odm_set_bb_reg(dm, R_0x1bd4, bit_mask_20_16, 0x10);
|
||||||
|
for (i = 0; i <= 16; i++) {
|
||||||
|
odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0xe0000001 | i << 2);
|
||||||
|
tmp = odm_get_bb_reg(dm, R_0x1bfc, MASKDWORD);
|
||||||
|
RTW_INFO("iqk_cfir_real[%d][%d][%d] = 0x%x\n", path, idx, i, ((tmp & 0x0fff0000) >> 16));
|
||||||
|
//iqk_info->iqk_cfir_real[ch][path][idx][i] =
|
||||||
|
// (tmp & 0x0fff0000) >> 16;
|
||||||
|
RTW_INFO("iqk_cfir_imag[%d][%d][%d] = 0x%x\n", path, idx, i, (tmp & 0x0fff));
|
||||||
|
//iqk_info->iqk_cfir_imag[ch][path][idx][i] = tmp & 0x0fff;
|
||||||
|
}
|
||||||
|
odm_set_bb_reg(dm, R_0x1b20, BIT(31) | BIT(30), 0x0);
|
||||||
|
//odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0x0);
|
||||||
|
}
|
||||||
|
|
||||||
|
__odm_func__ void
|
||||||
|
debug_information_8822c(
|
||||||
|
struct dm_struct *dm)
|
||||||
|
{
|
||||||
|
struct dm_dpk_info *dpk_info = &dm->dpk_info;
|
||||||
|
|
||||||
|
u32 reg_rf18;
|
||||||
|
|
||||||
|
if (odm_get_bb_reg(dm, R_0x1e7c, BIT(30)))
|
||||||
|
dpk_info->is_tssi_mode = true;
|
||||||
|
else
|
||||||
|
dpk_info->is_tssi_mode = false;
|
||||||
|
|
||||||
|
reg_rf18 = odm_get_rf_reg(dm, RF_PATH_A, RF_0x18, RFREG_MASK);
|
||||||
|
|
||||||
|
dpk_info->dpk_band = (u8)((reg_rf18 & BIT(16)) >> 16); /*0/1:G/A*/
|
||||||
|
dpk_info->dpk_ch = (u8)reg_rf18 & 0xff;
|
||||||
|
dpk_info->dpk_bw = (u8)((reg_rf18 & 0x3000) >> 12); /*3/2/1:20/40/80*/
|
||||||
|
|
||||||
|
RTW_INFO("[DPK] TSSI/ Band/ CH/ BW = %d / %s / %d / %s\n",
|
||||||
|
dpk_info->is_tssi_mode, dpk_info->dpk_band == 0 ? "2G" : "5G",
|
||||||
|
dpk_info->dpk_ch,
|
||||||
|
dpk_info->dpk_bw == 3 ? "20M" : (dpk_info->dpk_bw == 2 ? "40M" : "80M"));
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void _dpk_get_coef_8822c(void *dm_void, u8 path);
|
||||||
|
|
||||||
|
__odm_func__ void
|
||||||
|
debug_reload_data_8822c(
|
||||||
|
void *dm_void)
|
||||||
|
{
|
||||||
|
struct dm_struct *dm = (struct dm_struct *)dm_void;
|
||||||
|
struct dm_dpk_info *dpk_info = &dm->dpk_info;
|
||||||
|
|
||||||
|
u8 path;
|
||||||
|
u32 u32tmp;
|
||||||
|
|
||||||
|
debug_information_8822c(dm);
|
||||||
|
|
||||||
|
for (path = 0; path < DPK_RF_PATH_NUM_8822C; path++) {
|
||||||
|
|
||||||
|
RTW_INFO("[DPK] Reload path: 0x%x\n", path);
|
||||||
|
|
||||||
|
odm_set_bb_reg(dm, R_0x1b00, MASKDWORD, 0x8 | (path << 1));
|
||||||
|
|
||||||
|
/*txagc bnd*/
|
||||||
|
if (dpk_info->dpk_band == 0x0)
|
||||||
|
u32tmp = odm_get_bb_reg(dm, R_0x1b60, MASKDWORD);
|
||||||
|
else
|
||||||
|
u32tmp = odm_get_bb_reg(dm, R_0x1b60, MASKDWORD);
|
||||||
|
|
||||||
|
RTW_INFO("[DPK] txagc bnd = 0x%08x\n", u32tmp);
|
||||||
|
|
||||||
|
u32tmp = odm_get_bb_reg(dm, R_0x1b64, MASKBYTE3);
|
||||||
|
RTW_INFO("[DPK] dpk_txagc = 0x%08x\n", u32tmp);
|
||||||
|
|
||||||
|
//debug_coef_write_8822c(dm, path, dpk_info->dpk_path_ok & BIT(path) >> path);
|
||||||
|
_dpk_get_coef_8822c(dm, path);
|
||||||
|
|
||||||
|
//debug_one_shot_8822c(dm, path, DPK_ON);
|
||||||
|
|
||||||
|
odm_set_bb_reg(dm, R_0x1b00, 0x0000000f, 0xc);
|
||||||
|
|
||||||
|
if (path == RF_PATH_A)
|
||||||
|
u32tmp = odm_get_bb_reg(dm, R_0x1b04, 0x0fffffff);
|
||||||
|
else
|
||||||
|
u32tmp = odm_get_bb_reg(dm, R_0x1b5c, 0x0fffffff);
|
||||||
|
|
||||||
|
RTW_INFO("[DPK] dpk_gs = 0x%08x\n", u32tmp);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void odm_lps_pg_debug_8822c(void *dm_void)
|
||||||
|
{
|
||||||
|
struct dm_struct *dm = (struct dm_struct *)dm_void;
|
||||||
|
|
||||||
|
debug_DACK(dm);
|
||||||
|
debug_IQK(dm, TX_IQK, RF_PATH_A);
|
||||||
|
debug_IQK(dm, RX_IQK, RF_PATH_A);
|
||||||
|
debug_IQK(dm, TX_IQK, RF_PATH_B);
|
||||||
|
debug_IQK(dm, RX_IQK, RF_PATH_B);
|
||||||
|
debug_reload_data_8822c(dm);
|
||||||
|
}
|
||||||
|
#endif /* defined(CONFIG_RTL8822C) && defined(CONFIG_LPS_PG) */
|
||||||
|
|
||||||
5431
drivers/net/wireless/realtek/rtl8822ce/core/rtw_p2p.c
Normal file
5431
drivers/net/wireless/realtek/rtl8822ce/core/rtw_p2p.c
Normal file
File diff suppressed because it is too large
Load Diff
2825
drivers/net/wireless/realtek/rtl8822ce/core/rtw_pwrctrl.c
Normal file
2825
drivers/net/wireless/realtek/rtl8822ce/core/rtw_pwrctrl.c
Normal file
File diff suppressed because it is too large
Load Diff
4884
drivers/net/wireless/realtek/rtl8822ce/core/rtw_recv.c
Normal file
4884
drivers/net/wireless/realtek/rtl8822ce/core/rtw_recv.c
Normal file
File diff suppressed because it is too large
Load Diff
1627
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rf.c
Normal file
1627
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rf.c
Normal file
File diff suppressed because it is too large
Load Diff
2460
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rm.c
Normal file
2460
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rm.c
Normal file
File diff suppressed because it is too large
Load Diff
1015
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rm_fsm.c
Normal file
1015
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rm_fsm.c
Normal file
File diff suppressed because it is too large
Load Diff
434
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rm_util.c
Normal file
434
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rm_util.c
Normal file
@@ -0,0 +1,434 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2019 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
#ifdef CONFIG_RTW_80211K
|
||||||
|
#include "rtw_rm_fsm.h"
|
||||||
|
#include "rtw_rm_util.h"
|
||||||
|
|
||||||
|
/* 802.11-2012 Table E-1 Operationg classes in United States */
|
||||||
|
static RT_OPERATING_CLASS RTW_OP_CLASS_US[] = {
|
||||||
|
/* 0, OP_CLASS_NULL */ { 0, 0, {}},
|
||||||
|
/* 1, OP_CLASS_1 */ {115, 4, {36, 40, 44, 48}},
|
||||||
|
/* 2, OP_CLASS_2 */ {118, 4, {52, 56, 60, 64}},
|
||||||
|
/* 3, OP_CLASS_3 */ {124, 4, {149, 153, 157, 161}},
|
||||||
|
/* 4, OP_CLASS_4 */ {121, 11, {100, 104, 108, 112, 116, 120, 124,
|
||||||
|
128, 132, 136, 140}},
|
||||||
|
/* 5, OP_CLASS_5 */ {125, 5, {149, 153, 157, 161, 165}},
|
||||||
|
/* 6, OP_CLASS_12 */ { 81, 11, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}
|
||||||
|
};
|
||||||
|
|
||||||
|
u8 rm_get_ch_set(
|
||||||
|
struct rtw_ieee80211_channel *pch_set, u8 op_class, u8 ch_num)
|
||||||
|
{
|
||||||
|
int i,j,sz;
|
||||||
|
u8 ch_amount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
sz = sizeof(RTW_OP_CLASS_US)/sizeof(struct _RT_OPERATING_CLASS);
|
||||||
|
|
||||||
|
if (ch_num != 0) {
|
||||||
|
pch_set[0].hw_value = ch_num;
|
||||||
|
ch_amount = 1;
|
||||||
|
RTW_INFO("RM: meas_ch->hw_value = %u\n", pch_set->hw_value);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < sz; i++) {
|
||||||
|
|
||||||
|
if (RTW_OP_CLASS_US[i].global_op_class == op_class) {
|
||||||
|
|
||||||
|
for (j = 0; j < RTW_OP_CLASS_US[i].Len; j++) {
|
||||||
|
pch_set[j].hw_value =
|
||||||
|
RTW_OP_CLASS_US[i].Channel[j];
|
||||||
|
RTW_INFO("RM: meas_ch[%d].hw_value = %u\n",
|
||||||
|
j, pch_set[j].hw_value);
|
||||||
|
}
|
||||||
|
ch_amount = RTW_OP_CLASS_US[i].Len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done:
|
||||||
|
return ch_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rm_get_oper_class_via_ch(u8 ch)
|
||||||
|
{
|
||||||
|
int i,j,sz;
|
||||||
|
|
||||||
|
|
||||||
|
sz = sizeof(RTW_OP_CLASS_US)/sizeof(struct _RT_OPERATING_CLASS);
|
||||||
|
|
||||||
|
for (i = 0; i < sz; i++) {
|
||||||
|
for (j = 0; j < RTW_OP_CLASS_US[i].Len; j++) {
|
||||||
|
if ( ch == RTW_OP_CLASS_US[i].Channel[j]) {
|
||||||
|
RTW_INFO("RM: ch %u in oper_calss %u\n",
|
||||||
|
ch, RTW_OP_CLASS_US[i].global_op_class);
|
||||||
|
return RTW_OP_CLASS_US[i].global_op_class;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_wildcard_bssid(u8 *bssid)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
u8 val8 = 0xff;
|
||||||
|
|
||||||
|
|
||||||
|
for (i=0;i<6;i++)
|
||||||
|
val8 &= bssid[i];
|
||||||
|
|
||||||
|
if (val8 == 0xff)
|
||||||
|
return _SUCCESS;
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 translate_dbm_to_rcpi(s8 SignalPower)
|
||||||
|
{
|
||||||
|
/* RCPI = Int{(Power in dBm + 110)*2} for 0dBm > Power > -110dBm
|
||||||
|
* 0 : power <= -110.0 dBm
|
||||||
|
* 1 : power = -109.5 dBm
|
||||||
|
* 2 : power = -109.0 dBm
|
||||||
|
*/
|
||||||
|
return (SignalPower + 110)*2;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 translate_percentage_to_rcpi(u32 SignalStrengthIndex)
|
||||||
|
{
|
||||||
|
/* Translate to dBm (x=y-100) */
|
||||||
|
return translate_dbm_to_rcpi(SignalStrengthIndex - 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rm_get_bcn_rcpi(struct rm_obj *prm, struct wlan_network *pnetwork)
|
||||||
|
{
|
||||||
|
return translate_percentage_to_rcpi(
|
||||||
|
pnetwork->network.PhyInfo.SignalStrength);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rm_get_frame_rsni(struct rm_obj *prm, union recv_frame *pframe)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
u8 val8, snr, rx_num;
|
||||||
|
struct hal_spec_t *hal_spec = GET_HAL_SPEC(prm->psta->padapter);
|
||||||
|
|
||||||
|
if (IS_CCK_RATE((hw_rate_to_m_rate(pframe->u.hdr.attrib.data_rate))))
|
||||||
|
val8 = 255;
|
||||||
|
else {
|
||||||
|
snr = rx_num = 0;
|
||||||
|
for (i = 0; i < hal_spec->rf_reg_path_num; i++) {
|
||||||
|
if (GET_HAL_RX_PATH_BMP(prm->psta->padapter) & BIT(i)) {
|
||||||
|
snr += pframe->u.hdr.attrib.phy_info.rx_snr[i];
|
||||||
|
rx_num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
snr = snr / rx_num;
|
||||||
|
val8 = (u8)(snr + 10)*2;
|
||||||
|
}
|
||||||
|
return val8;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rm_get_bcn_rsni(struct rm_obj *prm, struct wlan_network *pnetwork)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
u8 val8, snr, rx_num;
|
||||||
|
struct hal_spec_t *hal_spec = GET_HAL_SPEC(prm->psta->padapter);
|
||||||
|
|
||||||
|
if (pnetwork->network.PhyInfo.is_cck_rate) {
|
||||||
|
/* current HW doesn't have CCK RSNI */
|
||||||
|
/* 255 indicates RSNI is unavailable */
|
||||||
|
val8 = 255;
|
||||||
|
} else {
|
||||||
|
snr = rx_num = 0;
|
||||||
|
for (i = 0; i < hal_spec->rf_reg_path_num; i++) {
|
||||||
|
if (GET_HAL_RX_PATH_BMP(prm->psta->padapter) & BIT(i)) {
|
||||||
|
snr += pnetwork->network.PhyInfo.rx_snr[i];
|
||||||
|
rx_num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
snr = snr / rx_num;
|
||||||
|
val8 = (u8)(snr + 10)*2;
|
||||||
|
}
|
||||||
|
return val8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* output: pwr (unit dBm) */
|
||||||
|
int rm_get_tx_power(PADAPTER adapter, enum rf_path path, enum MGN_RATE rate, s8 *pwr)
|
||||||
|
{
|
||||||
|
struct hal_spec_t *hal_spec = GET_HAL_SPEC(adapter);
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
int tx_num, band, bw, ch, n, rs;
|
||||||
|
u8 base;
|
||||||
|
s8 limt_offset = 127; /* max value of s8 */
|
||||||
|
s8 rate_offset;
|
||||||
|
s8 powr_offset;
|
||||||
|
int rate_pos;
|
||||||
|
|
||||||
|
|
||||||
|
band = hal_data->current_band_type;
|
||||||
|
bw = hal_data->current_channel_bw;
|
||||||
|
ch = hal_data->current_channel;
|
||||||
|
|
||||||
|
if (!HAL_SPEC_CHK_RF_PATH(hal_spec, band, path))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (HAL_IsLegalChannel(adapter, ch) == _FALSE) {
|
||||||
|
RTW_INFO("Illegal channel!!\n");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pwr = phy_get_tx_power_final_absolute_value(adapter, path, rate, bw, ch);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rm_get_rx_sensitivity(PADAPTER adapter, enum channel_width bw, enum MGN_RATE rate, s8 *pwr)
|
||||||
|
{
|
||||||
|
s8 rx_sensitivity = -110;
|
||||||
|
|
||||||
|
switch(rate) {
|
||||||
|
case MGN_1M:
|
||||||
|
rx_sensitivity= -101;
|
||||||
|
break;
|
||||||
|
case MGN_2M:
|
||||||
|
rx_sensitivity= -98;
|
||||||
|
break;
|
||||||
|
case MGN_5_5M:
|
||||||
|
rx_sensitivity= -92;
|
||||||
|
break;
|
||||||
|
case MGN_11M:
|
||||||
|
rx_sensitivity= -89;
|
||||||
|
break;
|
||||||
|
case MGN_6M:
|
||||||
|
case MGN_9M:
|
||||||
|
case MGN_12M:
|
||||||
|
rx_sensitivity = -92;
|
||||||
|
break;
|
||||||
|
case MGN_18M:
|
||||||
|
rx_sensitivity = -90;
|
||||||
|
break;
|
||||||
|
case MGN_24M:
|
||||||
|
rx_sensitivity = -88;
|
||||||
|
break;
|
||||||
|
case MGN_36M:
|
||||||
|
rx_sensitivity = -84;
|
||||||
|
break;
|
||||||
|
case MGN_48M:
|
||||||
|
rx_sensitivity = -79;
|
||||||
|
break;
|
||||||
|
case MGN_54M:
|
||||||
|
rx_sensitivity = -78;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_MCS0:
|
||||||
|
case MGN_MCS8:
|
||||||
|
case MGN_MCS16:
|
||||||
|
case MGN_MCS24:
|
||||||
|
case MGN_VHT1SS_MCS0:
|
||||||
|
case MGN_VHT2SS_MCS0:
|
||||||
|
case MGN_VHT3SS_MCS0:
|
||||||
|
case MGN_VHT4SS_MCS0:
|
||||||
|
/* BW20 BPSK 1/2 */
|
||||||
|
rx_sensitivity = -82;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_MCS1:
|
||||||
|
case MGN_MCS9:
|
||||||
|
case MGN_MCS17:
|
||||||
|
case MGN_MCS25:
|
||||||
|
case MGN_VHT1SS_MCS1:
|
||||||
|
case MGN_VHT2SS_MCS1:
|
||||||
|
case MGN_VHT3SS_MCS1:
|
||||||
|
case MGN_VHT4SS_MCS1:
|
||||||
|
/* BW20 QPSK 1/2 */
|
||||||
|
rx_sensitivity = -79;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_MCS2:
|
||||||
|
case MGN_MCS10:
|
||||||
|
case MGN_MCS18:
|
||||||
|
case MGN_MCS26:
|
||||||
|
case MGN_VHT1SS_MCS2:
|
||||||
|
case MGN_VHT2SS_MCS2:
|
||||||
|
case MGN_VHT3SS_MCS2:
|
||||||
|
case MGN_VHT4SS_MCS2:
|
||||||
|
/* BW20 QPSK 3/4 */
|
||||||
|
rx_sensitivity = -77;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_MCS3:
|
||||||
|
case MGN_MCS11:
|
||||||
|
case MGN_MCS19:
|
||||||
|
case MGN_MCS27:
|
||||||
|
case MGN_VHT1SS_MCS3:
|
||||||
|
case MGN_VHT2SS_MCS3:
|
||||||
|
case MGN_VHT3SS_MCS3:
|
||||||
|
case MGN_VHT4SS_MCS3:
|
||||||
|
/* BW20 16-QAM 1/2 */
|
||||||
|
rx_sensitivity = -74;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_MCS4:
|
||||||
|
case MGN_MCS12:
|
||||||
|
case MGN_MCS20:
|
||||||
|
case MGN_MCS28:
|
||||||
|
case MGN_VHT1SS_MCS4:
|
||||||
|
case MGN_VHT2SS_MCS4:
|
||||||
|
case MGN_VHT3SS_MCS4:
|
||||||
|
case MGN_VHT4SS_MCS4:
|
||||||
|
/* BW20 16-QAM 3/4 */
|
||||||
|
rx_sensitivity = -70;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_MCS5:
|
||||||
|
case MGN_MCS13:
|
||||||
|
case MGN_MCS21:
|
||||||
|
case MGN_MCS29:
|
||||||
|
case MGN_VHT1SS_MCS5:
|
||||||
|
case MGN_VHT2SS_MCS5:
|
||||||
|
case MGN_VHT3SS_MCS5:
|
||||||
|
case MGN_VHT4SS_MCS5:
|
||||||
|
/* BW20 64-QAM 2/3 */
|
||||||
|
rx_sensitivity = -66;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_MCS6:
|
||||||
|
case MGN_MCS14:
|
||||||
|
case MGN_MCS22:
|
||||||
|
case MGN_MCS30:
|
||||||
|
case MGN_VHT1SS_MCS6:
|
||||||
|
case MGN_VHT2SS_MCS6:
|
||||||
|
case MGN_VHT3SS_MCS6:
|
||||||
|
case MGN_VHT4SS_MCS6:
|
||||||
|
/* BW20 64-QAM 3/4 */
|
||||||
|
rx_sensitivity = -65;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_MCS7:
|
||||||
|
case MGN_MCS15:
|
||||||
|
case MGN_MCS23:
|
||||||
|
case MGN_MCS31:
|
||||||
|
case MGN_VHT1SS_MCS7:
|
||||||
|
case MGN_VHT2SS_MCS7:
|
||||||
|
case MGN_VHT3SS_MCS7:
|
||||||
|
case MGN_VHT4SS_MCS7:
|
||||||
|
/* BW20 64-QAM 5/6 */
|
||||||
|
rx_sensitivity = -64;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_VHT1SS_MCS8:
|
||||||
|
case MGN_VHT2SS_MCS8:
|
||||||
|
case MGN_VHT3SS_MCS8:
|
||||||
|
case MGN_VHT4SS_MCS8:
|
||||||
|
/* BW20 256-QAM 3/4 */
|
||||||
|
rx_sensitivity = -59;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MGN_VHT1SS_MCS9:
|
||||||
|
case MGN_VHT2SS_MCS9:
|
||||||
|
case MGN_VHT3SS_MCS9:
|
||||||
|
case MGN_VHT4SS_MCS9:
|
||||||
|
/* BW20 256-QAM 5/6 */
|
||||||
|
rx_sensitivity = -57;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(bw) {
|
||||||
|
case CHANNEL_WIDTH_20:
|
||||||
|
break;
|
||||||
|
case CHANNEL_WIDTH_40:
|
||||||
|
rx_sensitivity -= 3;
|
||||||
|
break;
|
||||||
|
case CHANNEL_WIDTH_80:
|
||||||
|
rx_sensitivity -= 6;
|
||||||
|
break;
|
||||||
|
case CHANNEL_WIDTH_160:
|
||||||
|
rx_sensitivity -= 9;
|
||||||
|
break;
|
||||||
|
case CHANNEL_WIDTH_5:
|
||||||
|
case CHANNEL_WIDTH_10:
|
||||||
|
case CHANNEL_WIDTH_80_80:
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*pwr = rx_sensitivity;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* output: path_a max tx power in dBm */
|
||||||
|
int rm_get_path_a_max_tx_power(_adapter *adapter, s8 *path_a)
|
||||||
|
{
|
||||||
|
struct hal_spec_t *hal_spec = GET_HAL_SPEC(adapter);
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
int path, tx_num, band, bw, ch, n, rs;
|
||||||
|
u8 rate_num;
|
||||||
|
s8 max_pwr[RF_PATH_MAX], pwr;
|
||||||
|
|
||||||
|
|
||||||
|
band = hal_data->current_band_type;
|
||||||
|
bw = hal_data->current_channel_bw;
|
||||||
|
ch = hal_data->current_channel;
|
||||||
|
|
||||||
|
for (path = 0; path < RF_PATH_MAX; path++) {
|
||||||
|
if (!HAL_SPEC_CHK_RF_PATH(hal_spec, band, path))
|
||||||
|
break;
|
||||||
|
|
||||||
|
max_pwr[path] = -127; /* min value of s8 */
|
||||||
|
#if (RM_MORE_DBG_MSG)
|
||||||
|
RTW_INFO("RM: [%s][%c]\n", band_str(band), rf_path_char(path));
|
||||||
|
#endif
|
||||||
|
for (rs = 0; rs < RATE_SECTION_NUM; rs++) {
|
||||||
|
tx_num = rate_section_to_tx_num(rs);
|
||||||
|
|
||||||
|
if (tx_num >= hal_spec->tx_nss_num)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (band == BAND_ON_5G && IS_CCK_RATE_SECTION(rs))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (IS_VHT_RATE_SECTION(rs) && !IS_HARDWARE_TYPE_JAGUAR_ALL(adapter))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
rate_num = rate_section_rate_num(rs);
|
||||||
|
|
||||||
|
/* get power by rate in db */
|
||||||
|
for (n = rate_num - 1; n >= 0; n--) {
|
||||||
|
pwr = phy_get_tx_power_final_absolute_value(adapter, path, rates_by_sections[rs].rates[n], bw, ch);
|
||||||
|
max_pwr[path] = MAX(max_pwr[path], pwr);
|
||||||
|
#if (RM_MORE_DBG_MSG)
|
||||||
|
RTW_INFO("RM: %9s = %2d\n",
|
||||||
|
MGN_RATE_STR(rates_by_sections[rs].rates[n]), pwr);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if (RM_MORE_DBG_MSG)
|
||||||
|
RTW_INFO("RM: path_a max_pwr=%ddBm\n", max_pwr[0]);
|
||||||
|
#endif
|
||||||
|
*path_a = max_pwr[0];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_RTW_80211K */
|
||||||
583
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rson.c
Normal file
583
drivers/net/wireless/realtek/rtl8822ce/core/rtw_rson.c
Normal file
@@ -0,0 +1,583 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2011 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#define _RTW_RSON_C_
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_REPEATER_SON
|
||||||
|
|
||||||
|
/******** Custommize Part ***********************/
|
||||||
|
|
||||||
|
unsigned char RTW_RSON_OUI[] = {0xFA, 0xFA, 0xFA};
|
||||||
|
#define RSON_SCORE_DIFF_TH 8
|
||||||
|
|
||||||
|
/*
|
||||||
|
Calculate the corresponding score.
|
||||||
|
*/
|
||||||
|
inline u8 rtw_cal_rson_score(struct rtw_rson_struct *cand_rson_data, NDIS_802_11_RSSI Rssi)
|
||||||
|
{
|
||||||
|
if ((cand_rson_data->hopcnt == RTW_RSON_HC_NOTREADY)
|
||||||
|
|| (cand_rson_data->connectible == RTW_RSON_DENYCONNECT))
|
||||||
|
return RTW_RSON_SCORE_NOTCNNT;
|
||||||
|
|
||||||
|
return RTW_RSON_SCORE_MAX - (cand_rson_data->hopcnt * 10) + (Rssi/10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
static u8 rtw_rson_block_bssid_idx = 0;
|
||||||
|
u8 rtw_rson_block_bssid[10][6] = {
|
||||||
|
/*{0x02, 0xE0, 0x4C, 0x07, 0xC3, 0xF6}*/
|
||||||
|
};
|
||||||
|
|
||||||
|
/* fake root, regard a real AP as a SO root */
|
||||||
|
static u8 rtw_rson_root_bssid_idx = 0;
|
||||||
|
u8 rtw_rson_root_bssid[10][6] = {
|
||||||
|
/*{0x1c, 0x5f, 0x2b, 0x5a, 0x60, 0x24}*/
|
||||||
|
};
|
||||||
|
|
||||||
|
int is_match_bssid(u8 *mac, u8 bssid_array[][6], int num)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < num; i++)
|
||||||
|
if (_rtw_memcmp(mac, bssid_array[i], 6) == _TRUE)
|
||||||
|
return _TRUE;
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_rtw_rson_data(struct dvobj_priv *dvobj)
|
||||||
|
{
|
||||||
|
/*Aries todo. if pdvobj->rson_data.ver == 1 */
|
||||||
|
dvobj->rson_data.ver = RTW_RSON_VER;
|
||||||
|
dvobj->rson_data.id = CONFIG_RTW_REPEATER_SON_ID;
|
||||||
|
#ifdef CONFIG_RTW_REPEATER_SON_ROOT
|
||||||
|
dvobj->rson_data.hopcnt = RTW_RSON_HC_ROOT;
|
||||||
|
dvobj->rson_data.connectible = RTW_RSON_ALLOWCONNECT;
|
||||||
|
#else
|
||||||
|
dvobj->rson_data.hopcnt = RTW_RSON_HC_NOTREADY;
|
||||||
|
dvobj->rson_data.connectible = RTW_RSON_DENYCONNECT;
|
||||||
|
#endif
|
||||||
|
dvobj->rson_data.loading = 0;
|
||||||
|
_rtw_memset(dvobj->rson_data.res, 0xAA, sizeof(dvobj->rson_data.res));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_rson_get_property_str(_adapter *padapter, char *rson_data_str)
|
||||||
|
{
|
||||||
|
struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
|
||||||
|
|
||||||
|
sprintf(rson_data_str, "version : \t%d\nid : \t\t%08x\nhop count : \t%d\nconnectible : \t%s\nloading : \t%d\nreserve : \t%16ph\n",
|
||||||
|
pdvobj->rson_data.ver,
|
||||||
|
pdvobj->rson_data.id,
|
||||||
|
pdvobj->rson_data.hopcnt,
|
||||||
|
pdvobj->rson_data.connectible ? "connectable":"unconnectable",
|
||||||
|
pdvobj->rson_data.loading,
|
||||||
|
pdvobj->rson_data.res);
|
||||||
|
}
|
||||||
|
|
||||||
|
int str2hexbuf(char *str, u8 *hexbuf, int len)
|
||||||
|
{
|
||||||
|
u8 *p;
|
||||||
|
int i, slen, idx = 0;
|
||||||
|
|
||||||
|
p = (unsigned char *)str;
|
||||||
|
if ((*p != '0') || (*(p+1) != 'x'))
|
||||||
|
return _FALSE;
|
||||||
|
slen = strlen(str);
|
||||||
|
if (slen > (len*2) + 2)
|
||||||
|
return _FALSE;
|
||||||
|
p += 2;
|
||||||
|
for (i = 0 ; i < len; i++, idx = idx+2) {
|
||||||
|
hexbuf[i] = key_2char2num(p[idx], p[idx + 1]);
|
||||||
|
if (slen <= idx+2)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtw_rson_set_property(_adapter *padapter, char *field, char *value)
|
||||||
|
{
|
||||||
|
struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
|
||||||
|
int num = 0;
|
||||||
|
|
||||||
|
if (_rtw_memcmp(field, (u8 *)"ver", 3) == _TRUE)
|
||||||
|
pdvobj->rson_data.ver = rtw_atoi(value);
|
||||||
|
else if (_rtw_memcmp(field, (u8 *)"id", 2) == _TRUE)
|
||||||
|
num = sscanf(value, "%08x", &(pdvobj->rson_data.id));
|
||||||
|
else if (_rtw_memcmp(field, (u8 *)"hc", 2) == _TRUE)
|
||||||
|
num = sscanf(value, "%hhu", &(pdvobj->rson_data.hopcnt));
|
||||||
|
else if (_rtw_memcmp(field, (u8 *)"cnt", 3) == _TRUE)
|
||||||
|
num = sscanf(value, "%hhu", &(pdvobj->rson_data.connectible));
|
||||||
|
else if (_rtw_memcmp(field, (u8 *)"loading", 2) == _TRUE)
|
||||||
|
num = sscanf(value, "%hhu", &(pdvobj->rson_data.loading));
|
||||||
|
else if (_rtw_memcmp(field, (u8 *)"res", 2) == _TRUE) {
|
||||||
|
str2hexbuf(value, pdvobj->rson_data.res, 16);
|
||||||
|
return 1;
|
||||||
|
} else
|
||||||
|
return _FALSE;
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
return : TRUE -- competitor is taking advantage than condidate
|
||||||
|
FALSE -- we should continue keeping candidate
|
||||||
|
*/
|
||||||
|
int rtw_rson_choose(struct wlan_network **candidate, struct wlan_network *competitor)
|
||||||
|
{
|
||||||
|
s16 comp_score = 0, cand_score = 0;
|
||||||
|
struct rtw_rson_struct rson_cand, rson_comp;
|
||||||
|
|
||||||
|
if (is_match_bssid(competitor->network.MacAddress, rtw_rson_block_bssid, rtw_rson_block_bssid_idx) == _TRUE)
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
if ((competitor == NULL)
|
||||||
|
|| (rtw_get_rson_struct(&(competitor->network), &rson_comp) != _TRUE)
|
||||||
|
|| (rson_comp.id != CONFIG_RTW_REPEATER_SON_ID))
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
comp_score = rtw_cal_rson_score(&rson_comp, competitor->network.Rssi);
|
||||||
|
if (comp_score == RTW_RSON_SCORE_NOTCNNT)
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
if (*candidate == NULL)
|
||||||
|
return _TRUE;
|
||||||
|
if (rtw_get_rson_struct(&((*candidate)->network), &rson_cand) != _TRUE)
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
cand_score = rtw_cal_rson_score(&rson_cand, (*candidate)->network.Rssi);
|
||||||
|
RTW_INFO("%s: competitor_score=%d, candidate_score=%d\n", __func__, comp_score, cand_score);
|
||||||
|
if (comp_score - cand_score > RSON_SCORE_DIFF_TH)
|
||||||
|
return _TRUE;
|
||||||
|
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u8 rtw_rson_varify_ie(u8 *p)
|
||||||
|
{
|
||||||
|
u8 *ptr = NULL;
|
||||||
|
u8 ver;
|
||||||
|
u32 id;
|
||||||
|
u8 hopcnt;
|
||||||
|
u8 allcnnt;
|
||||||
|
|
||||||
|
ptr = p + 2 + sizeof(RTW_RSON_OUI);
|
||||||
|
ver = *ptr;
|
||||||
|
|
||||||
|
/* for (ver == 1) */
|
||||||
|
if (ver != 1)
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Parsing RTK self-organization vendor IE
|
||||||
|
*/
|
||||||
|
int rtw_get_rson_struct(WLAN_BSSID_EX *bssid, struct rtw_rson_struct *rson_data)
|
||||||
|
{
|
||||||
|
sint limit = 0;
|
||||||
|
u32 len;
|
||||||
|
u8 *p;
|
||||||
|
|
||||||
|
if ((rson_data == NULL) || (bssid == NULL))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* Default */
|
||||||
|
rson_data->id = 0;
|
||||||
|
rson_data->ver = 0;
|
||||||
|
rson_data->hopcnt = 0;
|
||||||
|
rson_data->connectible = 0;
|
||||||
|
rson_data->loading = 0;
|
||||||
|
/* fake root */
|
||||||
|
if (is_match_bssid(bssid->MacAddress, rtw_rson_root_bssid, rtw_rson_root_bssid_idx) == _TRUE) {
|
||||||
|
rson_data->id = CONFIG_RTW_REPEATER_SON_ID;
|
||||||
|
rson_data->ver = RTW_RSON_VER;
|
||||||
|
rson_data->hopcnt = RTW_RSON_HC_ROOT;
|
||||||
|
rson_data->connectible = RTW_RSON_ALLOWCONNECT;
|
||||||
|
rson_data->loading = 0;
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
limit = bssid->IELength - _BEACON_IE_OFFSET_;
|
||||||
|
|
||||||
|
for (p = bssid->IEs + _BEACON_IE_OFFSET_; ; p += (len + 2)) {
|
||||||
|
p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &len, limit);
|
||||||
|
limit -= len;
|
||||||
|
if ((p == NULL) || (len == 0))
|
||||||
|
break;
|
||||||
|
if (p && (_rtw_memcmp(p + 2, RTW_RSON_OUI, sizeof(RTW_RSON_OUI)) == _TRUE)
|
||||||
|
&& rtw_rson_varify_ie(p)) {
|
||||||
|
p = p + 2 + sizeof(RTW_RSON_OUI);
|
||||||
|
rson_data->ver = *p;
|
||||||
|
/* for (ver == 1) */
|
||||||
|
p = p + 1;
|
||||||
|
rson_data->id = le32_to_cpup((__le32 *)p);
|
||||||
|
p = p + 4;
|
||||||
|
rson_data->hopcnt = *p;
|
||||||
|
p = p + 1;
|
||||||
|
rson_data->connectible = *p;
|
||||||
|
p = p + 1;
|
||||||
|
rson_data->loading = *p;
|
||||||
|
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -EBADMSG;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 rtw_rson_append_ie(_adapter *padapter, unsigned char *pframe, u32 *len)
|
||||||
|
{
|
||||||
|
u8 *ptr, *ori, ie_len = 0;
|
||||||
|
struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
|
||||||
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
||||||
|
/* static int iii = 0;*/
|
||||||
|
|
||||||
|
if ((!pdvobj) || (!pframe))
|
||||||
|
return 0;
|
||||||
|
ptr = ori = pframe;
|
||||||
|
*ptr++ = _VENDOR_SPECIFIC_IE_;
|
||||||
|
*ptr++ = ie_len = sizeof(RTW_RSON_OUI)+sizeof(pdvobj->rson_data);
|
||||||
|
_rtw_memcpy(ptr, RTW_RSON_OUI, sizeof(RTW_RSON_OUI));
|
||||||
|
ptr = ptr + sizeof(RTW_RSON_OUI);
|
||||||
|
*ptr++ = pdvobj->rson_data.ver;
|
||||||
|
*(s32 *)ptr = cpu_to_le32(pdvobj->rson_data.id);
|
||||||
|
ptr = ptr + sizeof(pdvobj->rson_data.id);
|
||||||
|
*ptr++ = pdvobj->rson_data.hopcnt;
|
||||||
|
*ptr++ = pdvobj->rson_data.connectible;
|
||||||
|
*ptr++ = pdvobj->rson_data.loading;
|
||||||
|
_rtw_memcpy(ptr, pdvobj->rson_data.res, sizeof(pdvobj->rson_data.res));
|
||||||
|
pframe = ptr;
|
||||||
|
/*
|
||||||
|
iii = iii % 20;
|
||||||
|
if (iii++ == 0)
|
||||||
|
RTW_INFO("%s : RTW RSON IE : %20ph\n", __func__, ori);
|
||||||
|
*/
|
||||||
|
*len += (ie_len+2);
|
||||||
|
return ie_len;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_rson_do_disconnect(_adapter *padapter)
|
||||||
|
{
|
||||||
|
struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
|
||||||
|
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
|
||||||
|
#ifndef CONFIG_RTW_REPEATER_SON_ROOT
|
||||||
|
pdvobj->rson_data.ver = RTW_RSON_VER;
|
||||||
|
pdvobj->rson_data.id = CONFIG_RTW_REPEATER_SON_ID;
|
||||||
|
pdvobj->rson_data.hopcnt = RTW_RSON_HC_NOTREADY;
|
||||||
|
pdvobj->rson_data.connectible = RTW_RSON_DENYCONNECT;
|
||||||
|
pdvobj->rson_data.loading = 0;
|
||||||
|
rtw_mi_tx_beacon_hdl(padapter);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_rson_join_done(_adapter *padapter)
|
||||||
|
{
|
||||||
|
struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
|
||||||
|
WLAN_BSSID_EX *cur_network = NULL;
|
||||||
|
struct rtw_rson_struct rson_data;
|
||||||
|
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
|
||||||
|
if (!padapter->mlmepriv.cur_network_scanned)
|
||||||
|
return;
|
||||||
|
cur_network = &(padapter->mlmepriv.cur_network_scanned->network);
|
||||||
|
if (rtw_get_rson_struct(cur_network, &rson_data) != _TRUE) {
|
||||||
|
RTW_ERR("%s: try to join a improper network(%s)\n", __func__, cur_network->Ssid.Ssid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef CONFIG_RTW_REPEATER_SON_ROOT
|
||||||
|
/* update rson_data */
|
||||||
|
pdvobj->rson_data.ver = RTW_RSON_VER;
|
||||||
|
pdvobj->rson_data.id = rson_data.id;
|
||||||
|
pdvobj->rson_data.hopcnt = rson_data.hopcnt + 1;
|
||||||
|
pdvobj->rson_data.connectible = RTW_RSON_ALLOWCONNECT;
|
||||||
|
pdvobj->rson_data.loading = 0;
|
||||||
|
rtw_mi_tx_beacon_hdl(padapter);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtw_rson_isupdate_roamcan(struct mlme_priv *mlme
|
||||||
|
, struct wlan_network **candidate, struct wlan_network *competitor)
|
||||||
|
{
|
||||||
|
struct rtw_rson_struct rson_cand, rson_comp, rson_curr;
|
||||||
|
s16 comp_score, cand_score, curr_score;
|
||||||
|
|
||||||
|
if ((competitor == NULL)
|
||||||
|
|| (rtw_get_rson_struct(&(competitor->network), &rson_comp) != _TRUE)
|
||||||
|
|| (rson_comp.id != CONFIG_RTW_REPEATER_SON_ID))
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
if (is_match_bssid(competitor->network.MacAddress, rtw_rson_block_bssid, rtw_rson_block_bssid_idx) == _TRUE)
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
if ((!mlme->cur_network_scanned)
|
||||||
|
|| (mlme->cur_network_scanned == competitor)
|
||||||
|
|| (rtw_get_rson_struct(&(mlme->cur_network_scanned->network), &rson_curr)) != _TRUE)
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
if (rtw_get_passing_time_ms((u32)competitor->last_scanned) >= mlme->roam_scanr_exp_ms)
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
comp_score = rtw_cal_rson_score(&rson_comp, competitor->network.Rssi);
|
||||||
|
curr_score = rtw_cal_rson_score(&rson_curr, mlme->cur_network_scanned->network.Rssi);
|
||||||
|
if (comp_score - curr_score < RSON_SCORE_DIFF_TH)
|
||||||
|
return _FALSE;
|
||||||
|
|
||||||
|
if (*candidate == NULL)
|
||||||
|
return _TRUE;
|
||||||
|
|
||||||
|
if (rtw_get_rson_struct(&((*candidate)->network), &rson_cand) != _TRUE) {
|
||||||
|
RTW_ERR("%s : Unable to get rson_struct from candidate(%s -- " MAC_FMT")\n",
|
||||||
|
__func__, (*candidate)->network.Ssid.Ssid, MAC_ARG((*candidate)->network.MacAddress));
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
cand_score = rtw_cal_rson_score(&rson_cand, (*candidate)->network.Rssi);
|
||||||
|
RTW_DBG("comp_score=%d , cand_score=%d , curr_score=%d\n", comp_score, cand_score, curr_score);
|
||||||
|
if (cand_score < comp_score)
|
||||||
|
return _TRUE;
|
||||||
|
|
||||||
|
#if 0 /* Handle 11R protocol */
|
||||||
|
#ifdef CONFIG_RTW_80211R
|
||||||
|
if (rtw_chk_ft_flags(adapter, RTW_FT_SUPPORTED)) {
|
||||||
|
ptmp = rtw_get_ie(&competitor->network.IEs[12], _MDIE_, &mdie_len, competitor->network.IELength-12);
|
||||||
|
if (ptmp) {
|
||||||
|
if (!_rtw_memcmp(&pftpriv->mdid, ptmp+2, 2))
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
/*The candidate don't support over-the-DS*/
|
||||||
|
if (rtw_chk_ft_flags(adapter, RTW_FT_STA_OVER_DS_SUPPORTED)) {
|
||||||
|
if ((rtw_chk_ft_flags(adapter, RTW_FT_OVER_DS_SUPPORTED) && !(*(ptmp+4) & 0x01)) ||
|
||||||
|
(!rtw_chk_ft_flags(adapter, RTW_FT_OVER_DS_SUPPORTED) && (*(ptmp+4) & 0x01))) {
|
||||||
|
RTW_INFO("FT: ignore the candidate(" MAC_FMT ") for over-the-DS\n", MAC_ARG(competitor->network.MacAddress));
|
||||||
|
rtw_clr_ft_flags(adapter, RTW_FT_OVER_DS_SUPPORTED);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_rson_show_survey_info(struct seq_file *m, _list *plist, _list *phead)
|
||||||
|
{
|
||||||
|
struct wlan_network *pnetwork = NULL;
|
||||||
|
struct rtw_rson_struct rson_data;
|
||||||
|
s16 rson_score;
|
||||||
|
u16 index = 0;
|
||||||
|
|
||||||
|
RTW_PRINT_SEL(m, "%5s %-17s %3s %5s %14s %10s %-3s %5s %32s\n", "index", "bssid", "ch", "id", "hop_cnt", "loading", "RSSI", "score", "ssid");
|
||||||
|
while (1) {
|
||||||
|
if (rtw_end_of_queue_search(phead, plist) == _TRUE)
|
||||||
|
break;
|
||||||
|
|
||||||
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
||||||
|
if (!pnetwork)
|
||||||
|
break;
|
||||||
|
|
||||||
|
_rtw_memset(&rson_data, 0, sizeof(rson_data));
|
||||||
|
rson_score = 0;
|
||||||
|
if (rtw_get_rson_struct(&(pnetwork->network), &rson_data) == _TRUE)
|
||||||
|
rson_score = rtw_cal_rson_score(&rson_data, pnetwork->network.Rssi);
|
||||||
|
RTW_PRINT_SEL(m, "%5d "MAC_FMT" %3d 0x%08x %6d %10d %6d %6d %32s\n",
|
||||||
|
++index,
|
||||||
|
MAC_ARG(pnetwork->network.MacAddress),
|
||||||
|
pnetwork->network.Configuration.DSConfig,
|
||||||
|
rson_data.id,
|
||||||
|
rson_data.hopcnt,
|
||||||
|
rson_data.loading,
|
||||||
|
(int)pnetwork->network.Rssi,
|
||||||
|
rson_score,
|
||||||
|
pnetwork->network.Ssid.Ssid);
|
||||||
|
plist = get_next(plist);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Description : As a AP role, We need to check the qualify of associating STA.
|
||||||
|
We also need to check if we are ready to be associated.
|
||||||
|
|
||||||
|
return : TRUE -- AP REJECT this STA
|
||||||
|
FALSE -- AP ACCEPT this STA
|
||||||
|
*/
|
||||||
|
u8 rtw_rson_ap_check_sta(_adapter *padapter, u8 *pframe, uint pkt_len, unsigned short ie_offset)
|
||||||
|
{
|
||||||
|
struct wlan_network *pnetwork = NULL;
|
||||||
|
struct rtw_rson_struct rson_target;
|
||||||
|
struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
|
||||||
|
int len = 0;
|
||||||
|
u8 ret = _FALSE;
|
||||||
|
u8 *p;
|
||||||
|
|
||||||
|
#ifndef CONFIG_RTW_REPEATER_SON_ROOT
|
||||||
|
_rtw_memset(&rson_target, 0, sizeof(rson_target));
|
||||||
|
for (p = pframe + WLAN_HDR_A3_LEN + ie_offset; ; p += (len + 2)) {
|
||||||
|
p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &len, pkt_len - WLAN_HDR_A3_LEN - ie_offset);
|
||||||
|
|
||||||
|
if ((p == NULL) || (len == 0))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (p && (_rtw_memcmp(p + 2, RTW_RSON_OUI, sizeof(RTW_RSON_OUI)) == _TRUE)
|
||||||
|
&& rtw_rson_varify_ie(p)) {
|
||||||
|
p = p + 2 + sizeof(RTW_RSON_OUI);
|
||||||
|
rson_target.ver = *p;
|
||||||
|
/* for (ver == 1) */
|
||||||
|
p = p + 1;
|
||||||
|
rson_target.id = le32_to_cpup((__le32 *)p);
|
||||||
|
p = p + 4;
|
||||||
|
rson_target.hopcnt = *p;
|
||||||
|
p = p + 1;
|
||||||
|
rson_target.connectible = *p;
|
||||||
|
p = p + 1;
|
||||||
|
rson_target.loading = *p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rson_target.id == 0) /* Normal STA, not a RSON STA */
|
||||||
|
ret = _FALSE;
|
||||||
|
else if (rson_target.id != pdvobj->rson_data.id) {
|
||||||
|
ret = _TRUE;
|
||||||
|
RTW_INFO("%s : Reject AssoReq because RSON ID not match, STA=%08x, our=%08x\n",
|
||||||
|
__func__, rson_target.id, pdvobj->rson_data.id);
|
||||||
|
} else if ((pdvobj->rson_data.hopcnt == RTW_RSON_HC_NOTREADY)
|
||||||
|
|| (pdvobj->rson_data.connectible == RTW_RSON_DENYCONNECT)) {
|
||||||
|
ret = _TRUE;
|
||||||
|
RTW_INFO("%s : Reject AssoReq becuase our hopcnt=%d or connectbile=%d\n",
|
||||||
|
__func__, pdvobj->rson_data.hopcnt, pdvobj->rson_data.connectible);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_rson_scan_wk_cmd(_adapter *padapter, int op)
|
||||||
|
{
|
||||||
|
struct cmd_obj *ph2c;
|
||||||
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
||||||
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||||
|
u8 *extra_cmd_buf;
|
||||||
|
u8 res = _SUCCESS;
|
||||||
|
|
||||||
|
ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
|
||||||
|
if (ph2c == NULL) {
|
||||||
|
res = _FAIL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
|
||||||
|
if (pdrvextra_cmd_parm == NULL) {
|
||||||
|
rtw_mfree((u8 *)ph2c, sizeof(struct cmd_obj));
|
||||||
|
res = _FAIL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
pdrvextra_cmd_parm->ec_id = RSON_SCAN_WK_CID;
|
||||||
|
pdrvextra_cmd_parm->type = op;
|
||||||
|
pdrvextra_cmd_parm->size = 0;
|
||||||
|
pdrvextra_cmd_parm->pbuf = NULL;
|
||||||
|
|
||||||
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, CMD_SET_DRV_EXTRA);
|
||||||
|
|
||||||
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_rson_scan_cmd_hdl(_adapter *padapter, int op)
|
||||||
|
{
|
||||||
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||||
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
||||||
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
|
u8 val8;
|
||||||
|
|
||||||
|
if (mlmeext_chk_scan_state(pmlmeext, SCAN_DISABLE) != _TRUE)
|
||||||
|
return;
|
||||||
|
if (op == RSON_SCAN_PROCESS) {
|
||||||
|
padapter->rtw_rson_scanstage = RSON_SCAN_PROCESS;
|
||||||
|
val8 = 0x1e;
|
||||||
|
rtw_hal_set_odm_var(padapter, HAL_ODM_INITIAL_GAIN, &val8, _FALSE);
|
||||||
|
val8 = 1;
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8));
|
||||||
|
issue_probereq(padapter, NULL, NULL);
|
||||||
|
/* stop rson_scan after 100ms */
|
||||||
|
_set_timer(&(pmlmeext->rson_scan_timer), 100);
|
||||||
|
} else if (op == RSON_SCAN_DISABLE) {
|
||||||
|
padapter->rtw_rson_scanstage = RSON_SCAN_DISABLE;
|
||||||
|
val8 = 0;
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8));
|
||||||
|
val8 = 0xff;
|
||||||
|
rtw_hal_set_odm_var(padapter, HAL_ODM_INITIAL_GAIN, &val8, _FALSE);
|
||||||
|
/* report_surveydone_event(padapter);*/
|
||||||
|
if (pmlmepriv->to_join == _TRUE) {
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) != _TRUE) {
|
||||||
|
int s_ret;
|
||||||
|
|
||||||
|
set_fwstate(pmlmepriv, WIFI_UNDER_LINKING);
|
||||||
|
pmlmepriv->to_join = _FALSE;
|
||||||
|
s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv);
|
||||||
|
if (s_ret == _SUCCESS)
|
||||||
|
_set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
|
||||||
|
else if (s_ret == 2) {
|
||||||
|
_clr_fwstate_(pmlmepriv, WIFI_UNDER_LINKING);
|
||||||
|
rtw_indicate_connect(padapter);
|
||||||
|
} else {
|
||||||
|
RTW_INFO("try_to_join, but select scanning queue fail, to_roam:%d\n", rtw_to_roam(padapter));
|
||||||
|
if (rtw_to_roam(padapter) != 0) {
|
||||||
|
if (rtw_dec_to_roam(padapter) == 0) {
|
||||||
|
rtw_set_to_roam(padapter, 0);
|
||||||
|
rtw_free_assoc_resources(padapter, _TRUE);
|
||||||
|
rtw_indicate_disconnect(padapter, 0, _FALSE);
|
||||||
|
} else
|
||||||
|
pmlmepriv->to_join = _TRUE;
|
||||||
|
} else
|
||||||
|
rtw_indicate_disconnect(padapter, 0, _FALSE);
|
||||||
|
_clr_fwstate_(pmlmepriv, WIFI_UNDER_LINKING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rtw_chk_roam_flags(padapter, RTW_ROAM_ACTIVE)) {
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
|
||||||
|
&& check_fwstate(pmlmepriv, WIFI_ASOC_STATE)) {
|
||||||
|
if (rtw_select_roaming_candidate(pmlmepriv) == _SUCCESS) {
|
||||||
|
#ifdef CONFIG_RTW_80211R
|
||||||
|
if (rtw_chk_ft_flags(padapter, RTW_FT_OVER_DS_SUPPORTED)) {
|
||||||
|
start_clnt_ft_action(adapter, (u8 *)pmlmepriv->roam_network->network.MacAddress);
|
||||||
|
} else {
|
||||||
|
/*wait a little time to retrieve packets buffered in the current ap while scan*/
|
||||||
|
_set_timer(&pmlmeext->ft_roam_timer, 30);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
receive_disconnect(padapter, pmlmepriv->cur_network.network.MacAddress
|
||||||
|
, WLAN_REASON_ACTIVE_ROAM, _FALSE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
issue_action_BSSCoexistPacket(padapter);
|
||||||
|
issue_action_BSSCoexistPacket(padapter);
|
||||||
|
issue_action_BSSCoexistPacket(padapter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RTW_ERR("%s : improper parameter -- op = %d\n", __func__, op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_RTW_REPEATER_SON */
|
||||||
157
drivers/net/wireless/realtek/rtl8822ce/core/rtw_sdio.c
Normal file
157
drivers/net/wireless/realtek/rtl8822ce/core/rtw_sdio.c
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2015 - 2019 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#define _RTW_SDIO_C_
|
||||||
|
|
||||||
|
#include <drv_types.h> /* struct dvobj_priv and etc. */
|
||||||
|
#include <drv_types_sdio.h> /* RTW_SDIO_ADDR_CMD52_GEN */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description:
|
||||||
|
* Use SDIO cmd52 or cmd53 to read/write data
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* d pointer of device object(struct dvobj_priv)
|
||||||
|
* addr SDIO address, 17 bits
|
||||||
|
* buf buffer for I/O
|
||||||
|
* len length
|
||||||
|
* write 0:read, 1:write
|
||||||
|
* cmd52 0:cmd52, 1:cmd53
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* _SUCCESS I/O ok.
|
||||||
|
* _FAIL I/O fail.
|
||||||
|
*/
|
||||||
|
static u8 sdio_io(struct dvobj_priv *d, u32 addr, void *buf, size_t len, u8 write, u8 cmd52)
|
||||||
|
{
|
||||||
|
#ifdef DBG_SDIO
|
||||||
|
#if (DBG_SDIO >= 3)
|
||||||
|
struct sdio_data *sdio;
|
||||||
|
#endif /* DBG_SDIO >= 3 */
|
||||||
|
#endif /* DBG_SDIO */
|
||||||
|
u32 addr_drv; /* address with driver defined bit */
|
||||||
|
int err;
|
||||||
|
u8 retry = 0;
|
||||||
|
u8 stop_retry = _FALSE; /* flag for stopping retry or not */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DBG_SDIO
|
||||||
|
#if (DBG_SDIO >= 3)
|
||||||
|
sdio = &d->intf_data;
|
||||||
|
#endif /* DBG_SDIO >= 3 */
|
||||||
|
#endif /* DBG_SDIO */
|
||||||
|
|
||||||
|
if (rtw_is_surprise_removed(dvobj_get_primary_adapter(d))) {
|
||||||
|
RTW_ERR("%s: bSurpriseRemoved, skip %s 0x%05x, %zu bytes\n",
|
||||||
|
__FUNCTION__, write?"write":"read", addr, len);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr_drv = addr;
|
||||||
|
if (cmd52)
|
||||||
|
addr_drv = RTW_SDIO_ADDR_CMD52_GEN(addr_drv);
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (write)
|
||||||
|
err = d->intf_ops->write(d, addr_drv, buf, len, 0);
|
||||||
|
else
|
||||||
|
err = d->intf_ops->read(d, addr_drv, buf, len, 0);
|
||||||
|
if (!err) {
|
||||||
|
if (retry) {
|
||||||
|
RTW_INFO("%s: Retry %s OK! addr=0x%05x %zu bytes, retry=%u,%u\n",
|
||||||
|
__FUNCTION__, write?"write":"read",
|
||||||
|
addr, len, retry, ATOMIC_READ(&d->continual_io_error));
|
||||||
|
RTW_INFO_DUMP("Data: ", buf, len);
|
||||||
|
}
|
||||||
|
rtw_reset_continual_io_error(d);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
RTW_ERR("%s: %s FAIL! error(%d) addr=0x%05x %zu bytes, retry=%u,%u\n",
|
||||||
|
__FUNCTION__, write?"write":"read", err, addr, len,
|
||||||
|
retry, ATOMIC_READ(&d->continual_io_error));
|
||||||
|
|
||||||
|
#ifdef DBG_SDIO
|
||||||
|
#if (DBG_SDIO >= 3)
|
||||||
|
if (sdio->dbg_enable) {
|
||||||
|
if (sdio->err_test && sdio->err_test_triggered)
|
||||||
|
sdio->err_test = 0;
|
||||||
|
|
||||||
|
if (sdio->err_stop) {
|
||||||
|
RTW_ERR("%s: I/O error! Set surprise remove flag ON!\n",
|
||||||
|
__FUNCTION__);
|
||||||
|
rtw_set_surprise_removed(dvobj_get_primary_adapter(d));
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* DBG_SDIO >= 3 */
|
||||||
|
#endif /* DBG_SDIO */
|
||||||
|
|
||||||
|
retry++;
|
||||||
|
stop_retry = rtw_inc_and_chk_continual_io_error(d);
|
||||||
|
if ((err == -1) || (stop_retry == _TRUE) || (retry > SD_IO_TRY_CNT)) {
|
||||||
|
/* critical error, unrecoverable */
|
||||||
|
RTW_ERR("%s: Fatal error! Set surprise remove flag ON! (retry=%u,%u)\n",
|
||||||
|
__FUNCTION__, retry, ATOMIC_READ(&d->continual_io_error));
|
||||||
|
rtw_set_surprise_removed(dvobj_get_primary_adapter(d));
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WLAN IOREG or SDIO Local */
|
||||||
|
if ((addr & 0x10000) || !(addr & 0xE000)) {
|
||||||
|
RTW_WARN("%s: Retry %s addr=0x%05x %zu bytes, retry=%u,%u\n",
|
||||||
|
__FUNCTION__, write?"write":"read", addr, len,
|
||||||
|
retry, ATOMIC_READ(&d->continual_io_error));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return _FAIL;
|
||||||
|
} while (1);
|
||||||
|
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_sdio_read_cmd52(struct dvobj_priv *d, u32 addr, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return sdio_io(d, addr, buf, len, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_sdio_read_cmd53(struct dvobj_priv *d, u32 addr, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return sdio_io(d, addr, buf, len, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_sdio_write_cmd52(struct dvobj_priv *d, u32 addr, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return sdio_io(d, addr, buf, len, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_sdio_write_cmd53(struct dvobj_priv *d, u32 addr, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return sdio_io(d, addr, buf, len, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_sdio_f0_read(struct dvobj_priv *d, u32 addr, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
u8 ret;
|
||||||
|
|
||||||
|
|
||||||
|
ret = _SUCCESS;
|
||||||
|
addr = RTW_SDIO_ADDR_F0_GEN(addr);
|
||||||
|
|
||||||
|
err = d->intf_ops->read(d, addr, buf, len, 0);
|
||||||
|
if (err)
|
||||||
|
ret = _FAIL;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
2884
drivers/net/wireless/realtek/rtl8822ce/core/rtw_security.c
Normal file
2884
drivers/net/wireless/realtek/rtl8822ce/core/rtw_security.c
Normal file
File diff suppressed because it is too large
Load Diff
316
drivers/net/wireless/realtek/rtl8822ce/core/rtw_sreset.c
Normal file
316
drivers/net/wireless/realtek/rtl8822ce/core/rtw_sreset.c
Normal file
@@ -0,0 +1,316 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
#include <rtw_sreset.h>
|
||||||
|
|
||||||
|
void sreset_init_value(_adapter *padapter)
|
||||||
|
{
|
||||||
|
#if defined(DBG_CONFIG_ERROR_DETECT)
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
struct sreset_priv *psrtpriv = &pHalData->srestpriv;
|
||||||
|
|
||||||
|
_rtw_mutex_init(&psrtpriv->silentreset_mutex);
|
||||||
|
psrtpriv->silent_reset_inprogress = _FALSE;
|
||||||
|
psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS;
|
||||||
|
psrtpriv->last_tx_time = 0;
|
||||||
|
psrtpriv->last_tx_complete_time = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void sreset_reset_value(_adapter *padapter)
|
||||||
|
{
|
||||||
|
#if defined(DBG_CONFIG_ERROR_DETECT)
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
struct sreset_priv *psrtpriv = &pHalData->srestpriv;
|
||||||
|
|
||||||
|
psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS;
|
||||||
|
psrtpriv->last_tx_time = 0;
|
||||||
|
psrtpriv->last_tx_complete_time = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 sreset_get_wifi_status(_adapter *padapter)
|
||||||
|
{
|
||||||
|
#if defined(DBG_CONFIG_ERROR_DETECT)
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
struct sreset_priv *psrtpriv = &pHalData->srestpriv;
|
||||||
|
u8 status = WIFI_STATUS_SUCCESS;
|
||||||
|
u32 val32 = 0;
|
||||||
|
|
||||||
|
if (psrtpriv->silent_reset_inprogress == _TRUE)
|
||||||
|
return status;
|
||||||
|
val32 = rtw_read32(padapter, REG_TXDMA_STATUS);
|
||||||
|
if (val32 == 0xeaeaeaea)
|
||||||
|
psrtpriv->Wifi_Error_Status = WIFI_IF_NOT_EXIST;
|
||||||
|
else if (val32 != 0) {
|
||||||
|
RTW_INFO("txdmastatu(%x)\n", val32);
|
||||||
|
psrtpriv->Wifi_Error_Status = WIFI_MAC_TXDMA_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WIFI_STATUS_SUCCESS != psrtpriv->Wifi_Error_Status) {
|
||||||
|
RTW_INFO("==>%s error_status(0x%x)\n", __FUNCTION__, psrtpriv->Wifi_Error_Status);
|
||||||
|
status = (psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL | USB_WRITE_PORT_FAIL)));
|
||||||
|
}
|
||||||
|
RTW_INFO("==> %s wifi_status(0x%x)\n", __FUNCTION__, status);
|
||||||
|
|
||||||
|
/* status restore */
|
||||||
|
psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
#else
|
||||||
|
return WIFI_STATUS_SUCCESS;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void sreset_set_wifi_error_status(_adapter *padapter, u32 status)
|
||||||
|
{
|
||||||
|
#if defined(DBG_CONFIG_ERROR_DETECT)
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
pHalData->srestpriv.Wifi_Error_Status = status;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void sreset_set_trigger_point(_adapter *padapter, s32 tgp)
|
||||||
|
{
|
||||||
|
#if defined(DBG_CONFIG_ERROR_DETECT)
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
pHalData->srestpriv.dbg_trigger_point = tgp;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sreset_inprogress(_adapter *padapter)
|
||||||
|
{
|
||||||
|
#if defined(DBG_CONFIG_ERROR_RESET)
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
return pHalData->srestpriv.silent_reset_inprogress;
|
||||||
|
#else
|
||||||
|
return _FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void sreset_restore_security_station(_adapter *padapter)
|
||||||
|
{
|
||||||
|
struct mlme_priv *mlmepriv = &padapter->mlmepriv;
|
||||||
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||||
|
struct sta_info *psta;
|
||||||
|
struct mlme_ext_info *pmlmeinfo = &padapter->mlmeextpriv.mlmext_info;
|
||||||
|
|
||||||
|
{
|
||||||
|
u8 val8;
|
||||||
|
|
||||||
|
if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) {
|
||||||
|
val8 = 0xcc;
|
||||||
|
#ifdef CONFIG_WAPI_SUPPORT
|
||||||
|
} else if (padapter->wapiInfo.bWapiEnable && pmlmeinfo->auth_algo == dot11AuthAlgrthm_WAPI) {
|
||||||
|
/* Disable TxUseDefaultKey, RxUseDefaultKey, RxBroadcastUseDefaultKey. */
|
||||||
|
val8 = 0x4c;
|
||||||
|
#endif
|
||||||
|
} else
|
||||||
|
val8 = 0xcf;
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) ||
|
||||||
|
(padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) {
|
||||||
|
psta = rtw_get_stainfo(pstapriv, get_bssid(mlmepriv));
|
||||||
|
if (psta == NULL) {
|
||||||
|
/* DEBUG_ERR( ("Set wpa_set_encryption: Obtain Sta_info fail\n")); */
|
||||||
|
} else {
|
||||||
|
/* pairwise key */
|
||||||
|
rtw_setstakey_cmd(padapter, psta, UNICAST_KEY, _FALSE);
|
||||||
|
/* group key */
|
||||||
|
rtw_set_key(padapter, &padapter->securitypriv, padapter->securitypriv.dot118021XGrpKeyid, 0, _FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sreset_restore_network_station(_adapter *padapter)
|
||||||
|
{
|
||||||
|
struct mlme_priv *mlmepriv = &padapter->mlmepriv;
|
||||||
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
||||||
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
||||||
|
u8 doiqk = _FALSE;
|
||||||
|
|
||||||
|
rtw_setopmode_cmd(padapter, Ndis802_11Infrastructure, RTW_CMDF_DIRECTLY);
|
||||||
|
|
||||||
|
{
|
||||||
|
u8 threshold;
|
||||||
|
#ifdef CONFIG_USB_HCI
|
||||||
|
/* TH=1 => means that invalidate usb rx aggregation */
|
||||||
|
/* TH=0 => means that validate usb rx aggregation, use init value. */
|
||||||
|
#ifdef CONFIG_80211N_HT
|
||||||
|
if (mlmepriv->htpriv.ht_option) {
|
||||||
|
if (padapter->registrypriv.wifi_spec == 1)
|
||||||
|
threshold = 1;
|
||||||
|
else
|
||||||
|
threshold = 0;
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold));
|
||||||
|
} else {
|
||||||
|
threshold = 1;
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold));
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_80211N_HT */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
doiqk = _TRUE;
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_DO_IQK , &doiqk);
|
||||||
|
|
||||||
|
set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
|
||||||
|
|
||||||
|
doiqk = _FALSE;
|
||||||
|
rtw_hal_set_hwreg(padapter , HW_VAR_DO_IQK , &doiqk);
|
||||||
|
/* disable dynamic functions, such as high power, DIG */
|
||||||
|
/*rtw_phydm_func_disable_all(padapter);*/
|
||||||
|
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress);
|
||||||
|
|
||||||
|
{
|
||||||
|
u8 join_type = 0;
|
||||||
|
|
||||||
|
rtw_hal_rcr_set_chk_bssid(padapter, MLME_STA_CONNECTING);
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
|
||||||
|
|
||||||
|
rtw_btcoex_connect_notify(padapter, join_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
Set_MSR(padapter, (pmlmeinfo->state & 0x3));
|
||||||
|
|
||||||
|
mlmeext_joinbss_event_callback(padapter, 1);
|
||||||
|
/* restore Sequence No. */
|
||||||
|
rtw_hal_set_hwreg(padapter, HW_VAR_RESTORE_HW_SEQ, 0);
|
||||||
|
|
||||||
|
sreset_restore_security_station(padapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sreset_restore_network_status(_adapter *padapter)
|
||||||
|
{
|
||||||
|
struct mlme_priv *mlmepriv = &padapter->mlmepriv;
|
||||||
|
|
||||||
|
if (check_fwstate(mlmepriv, WIFI_STATION_STATE)) {
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv));
|
||||||
|
sreset_restore_network_station(padapter);
|
||||||
|
} else if (MLME_IS_AP(padapter) || MLME_IS_MESH(padapter)) {
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT" %s\n", FUNC_ADPT_ARG(padapter), MLME_IS_AP(padapter) ? "AP" : "MESH");
|
||||||
|
rtw_ap_restore_network(padapter);
|
||||||
|
} else if (check_fwstate(mlmepriv, WIFI_ADHOC_STATE))
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv));
|
||||||
|
else
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT" fwstate:0x%08x - ???\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv));
|
||||||
|
}
|
||||||
|
|
||||||
|
void sreset_stop_adapter(_adapter *padapter)
|
||||||
|
{
|
||||||
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
||||||
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||||
|
|
||||||
|
if (padapter == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
|
||||||
|
|
||||||
|
rtw_netif_stop_queue(padapter->pnetdev);
|
||||||
|
|
||||||
|
rtw_cancel_all_timer(padapter);
|
||||||
|
|
||||||
|
/* TODO: OS and HCI independent */
|
||||||
|
#if defined(PLATFORM_LINUX) && defined(CONFIG_USB_HCI)
|
||||||
|
tasklet_kill(&pxmitpriv->xmit_tasklet);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_SURVEY))
|
||||||
|
rtw_scan_abort(padapter);
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_LINKING)) {
|
||||||
|
rtw_set_to_roam(padapter, 0);
|
||||||
|
rtw_join_timeout_handler(padapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void sreset_start_adapter(_adapter *padapter)
|
||||||
|
{
|
||||||
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
||||||
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||||
|
|
||||||
|
if (padapter == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
|
||||||
|
|
||||||
|
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE))
|
||||||
|
sreset_restore_network_status(padapter);
|
||||||
|
|
||||||
|
/* TODO: OS and HCI independent */
|
||||||
|
#if defined(PLATFORM_LINUX) && defined(CONFIG_USB_HCI)
|
||||||
|
tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (is_primary_adapter(padapter))
|
||||||
|
_set_timer(&adapter_to_dvobj(padapter)->dynamic_chk_timer, 2000);
|
||||||
|
|
||||||
|
rtw_netif_wake_queue(padapter->pnetdev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sreset_reset(_adapter *padapter)
|
||||||
|
{
|
||||||
|
#ifdef DBG_CONFIG_ERROR_RESET
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
struct sreset_priv *psrtpriv = &pHalData->srestpriv;
|
||||||
|
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
|
||||||
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
||||||
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||||
|
_irqL irqL;
|
||||||
|
systime start = rtw_get_current_time();
|
||||||
|
struct dvobj_priv *psdpriv = padapter->dvobj;
|
||||||
|
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
|
||||||
|
|
||||||
|
RTW_INFO("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_LPS
|
||||||
|
rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "SRESET");
|
||||||
|
#endif/* #ifdef CONFIG_LPS */
|
||||||
|
|
||||||
|
_enter_pwrlock(&pwrpriv->lock);
|
||||||
|
|
||||||
|
psrtpriv->silent_reset_inprogress = _TRUE;
|
||||||
|
pwrpriv->change_rfpwrstate = rf_off;
|
||||||
|
|
||||||
|
rtw_mi_sreset_adapter_hdl(padapter, _FALSE);/*sreset_stop_adapter*/
|
||||||
|
#ifdef CONFIG_IPS
|
||||||
|
_ips_enter(padapter);
|
||||||
|
_ips_leave(padapter);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CONCURRENT_MODE
|
||||||
|
rtw_mi_ap_info_restore(padapter);
|
||||||
|
#endif
|
||||||
|
rtw_mi_sreset_adapter_hdl(padapter, _TRUE);/*sreset_start_adapter*/
|
||||||
|
|
||||||
|
psrtpriv->silent_reset_inprogress = _FALSE;
|
||||||
|
|
||||||
|
_exit_pwrlock(&pwrpriv->lock);
|
||||||
|
|
||||||
|
RTW_INFO("%s done in %d ms\n", __FUNCTION__, rtw_get_passing_time_ms(start));
|
||||||
|
pdbgpriv->dbg_sreset_cnt++;
|
||||||
|
|
||||||
|
psrtpriv->self_dect_fw = _FALSE;
|
||||||
|
psrtpriv->rx_cnt = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
1366
drivers/net/wireless/realtek/rtl8822ce/core/rtw_sta_mgt.c
Normal file
1366
drivers/net/wireless/realtek/rtl8822ce/core/rtw_sta_mgt.c
Normal file
File diff suppressed because it is too large
Load Diff
296
drivers/net/wireless/realtek/rtl8822ce/core/rtw_swcrypto.c
Normal file
296
drivers/net/wireless/realtek/rtl8822ce/core/rtw_swcrypto.c
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
#include <aes.h>
|
||||||
|
#include <aes_siv.h>
|
||||||
|
#include <aes_wrap.h>
|
||||||
|
#include <sha256.h>
|
||||||
|
#include <wlancrypto_wrap.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rtw_ccmp_encrypt -
|
||||||
|
* @key: the temporal key
|
||||||
|
* @hdrlen: mac header length
|
||||||
|
* @frame: the frame including the mac header, pn and payload
|
||||||
|
* @plen: payload length, i.e., length of the plain text, without PN and MIC
|
||||||
|
*/
|
||||||
|
int _rtw_ccmp_encrypt(u8 *key, u32 key_len, uint hdrlen, u8 *frame, uint plen)
|
||||||
|
{
|
||||||
|
u8 *enc = NULL;
|
||||||
|
size_t enc_len = 0;
|
||||||
|
|
||||||
|
if (key_len == 16) { /* 128 bits */
|
||||||
|
enc = ccmp_encrypt(key,
|
||||||
|
frame,
|
||||||
|
hdrlen + plen,
|
||||||
|
hdrlen,
|
||||||
|
(hdrlen == 26) ? (frame + hdrlen - 2) : NULL,
|
||||||
|
NULL, 0, &enc_len);
|
||||||
|
} else if (key_len == 32) { /* 256 bits */
|
||||||
|
enc = ccmp_256_encrypt(key,
|
||||||
|
frame,
|
||||||
|
hdrlen + plen,
|
||||||
|
hdrlen,
|
||||||
|
(hdrlen == 26) ? (frame + hdrlen - 2) : NULL,
|
||||||
|
NULL, 0, &enc_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enc == NULL) {
|
||||||
|
RTW_INFO("Failed to encrypt CCMP(%u) frame", key_len);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy @enc back to @frame and free @enc */
|
||||||
|
_rtw_memcpy(frame, enc, enc_len);
|
||||||
|
rtw_mfree(enc, enc_len + AES_BLOCK_SIZE);
|
||||||
|
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rtw_ccmp_decrypt -
|
||||||
|
* @key: the temporal key
|
||||||
|
* @hdrlen: length of the mac header
|
||||||
|
* @frame: the raw frame (@hdrlen + PN + enc_data + MIC)
|
||||||
|
* @plen: length of the frame (@hdrlen + PN + enc_data + MIC)
|
||||||
|
*/
|
||||||
|
int _rtw_ccmp_decrypt(u8 *key, u32 key_len, uint hdrlen, u8 *frame,
|
||||||
|
uint plen)
|
||||||
|
{
|
||||||
|
u8 *plain = NULL;
|
||||||
|
size_t plain_len = 0;
|
||||||
|
const struct ieee80211_hdr *hdr;
|
||||||
|
|
||||||
|
hdr = (const struct ieee80211_hdr *)frame;
|
||||||
|
|
||||||
|
if (key_len == 16) { /* 128 bits */
|
||||||
|
plain = ccmp_decrypt(key,
|
||||||
|
hdr,
|
||||||
|
frame + hdrlen, /* PN + enc_data + MIC */
|
||||||
|
plen - hdrlen, /* PN + enc_data + MIC */
|
||||||
|
&plain_len);
|
||||||
|
} else if (key_len == 32) { /* 256 bits */
|
||||||
|
plain = ccmp_256_decrypt(key,
|
||||||
|
hdr,
|
||||||
|
frame + hdrlen, /* PN + enc_data + MIC */
|
||||||
|
plen - hdrlen, /* PN + enc_data + MIC */
|
||||||
|
&plain_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plain == NULL) {
|
||||||
|
RTW_INFO("Failed to decrypt CCMP(%u) frame", key_len);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy @plain back to @frame and free @plain */
|
||||||
|
_rtw_memcpy(frame + hdrlen + 8, plain, plain_len);
|
||||||
|
rtw_mfree(plain, plen - hdrlen + AES_BLOCK_SIZE);
|
||||||
|
|
||||||
|
RTW_DBG_DUMP("ccmp_decrypt(): decrypted frame\n",
|
||||||
|
frame, hdrlen + 8 + plen);
|
||||||
|
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_MESH_AEK
|
||||||
|
/* wrapper to ase_siv_encrypt and aes_siv_decrypt */
|
||||||
|
int _aes_siv_encrypt(const u8 *key, size_t key_len,
|
||||||
|
const u8 *pw, size_t pwlen,
|
||||||
|
size_t num_elem, const u8 *addr[], const size_t *len, u8 *out)
|
||||||
|
{
|
||||||
|
return aes_siv_encrypt(key, key_len, pw, pwlen, num_elem, addr, len, out);
|
||||||
|
}
|
||||||
|
int _aes_siv_decrypt(const u8 *key, size_t key_len,
|
||||||
|
const u8 *iv_crypt, size_t iv_c_len,
|
||||||
|
size_t num_elem, const u8 *addr[], const size_t *len, u8 *out)
|
||||||
|
{
|
||||||
|
return aes_siv_decrypt(key, key_len, iv_crypt, iv_c_len, num_elem, addr, len, out);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _rtw_gcmp_encrypt -
|
||||||
|
* @key: the temporal key
|
||||||
|
* @hdrlen: mac header length
|
||||||
|
* @frame: the frame including the mac header, pn and payload
|
||||||
|
* @plen: payload length, i.e., length of the plain text, without PN and MIC
|
||||||
|
*/
|
||||||
|
int _rtw_gcmp_encrypt(u8 *key, u32 key_len, uint hdrlen, u8 *frame, uint plen)
|
||||||
|
{
|
||||||
|
u8 *enc = NULL;
|
||||||
|
size_t enc_len = 0;
|
||||||
|
|
||||||
|
enc = gcmp_encrypt(key, key_len,
|
||||||
|
frame,
|
||||||
|
hdrlen + plen,
|
||||||
|
hdrlen,
|
||||||
|
(hdrlen == 26) ? (frame + hdrlen - 2) : NULL,
|
||||||
|
NULL, 0, &enc_len);
|
||||||
|
if (enc == NULL) {
|
||||||
|
RTW_INFO("Failed to encrypt GCMP frame");
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy @enc back to @frame and free @enc */
|
||||||
|
_rtw_memcpy(frame, enc, enc_len);
|
||||||
|
rtw_mfree(enc, enc_len + AES_BLOCK_SIZE);
|
||||||
|
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _rtw_gcmp_decrypt -
|
||||||
|
* @key: the temporal key
|
||||||
|
* @hdrlen: length of the mac header
|
||||||
|
* @frame: the raw frame (@hdrlen + PN + enc_data + MIC)
|
||||||
|
* @plen: length of the frame (@hdrlen + PN + enc_data + MIC)
|
||||||
|
*/
|
||||||
|
int _rtw_gcmp_decrypt(u8 *key, u32 key_len, uint hdrlen, u8 *frame, uint plen)
|
||||||
|
{
|
||||||
|
u8 *plain = NULL;
|
||||||
|
size_t plain_len = 0;
|
||||||
|
const struct ieee80211_hdr *hdr;
|
||||||
|
|
||||||
|
hdr = (const struct ieee80211_hdr *)frame;
|
||||||
|
|
||||||
|
plain = gcmp_decrypt(key, key_len,
|
||||||
|
hdr,
|
||||||
|
frame + hdrlen, /* PN + enc_data + MIC */
|
||||||
|
plen - hdrlen, /* PN + enc_data + MIC */
|
||||||
|
&plain_len);
|
||||||
|
|
||||||
|
if (plain == NULL) {
|
||||||
|
RTW_INFO("Failed to decrypt GCMP(%u) frame", key_len);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy @plain back to @frame and free @plain */
|
||||||
|
_rtw_memcpy(frame + hdrlen + 8, plain, plain_len);
|
||||||
|
rtw_mfree(plain, plen - hdrlen + AES_BLOCK_SIZE);
|
||||||
|
|
||||||
|
RTW_DBG_DUMP("gcmp_decipher(): decrypted frame\n",
|
||||||
|
frame, hdrlen + 8 + plen);
|
||||||
|
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CONFIG_IEEE80211W) | defined(CONFIG_TDLS)
|
||||||
|
u8 _bip_ccmp_protect(const u8 *key, size_t key_len,
|
||||||
|
const u8 *data, size_t data_len, u8 *mic)
|
||||||
|
{
|
||||||
|
u8 res = _SUCCESS;
|
||||||
|
|
||||||
|
if (key_len == 16) {
|
||||||
|
if (omac1_aes_128(key, data, data_len, mic)) {
|
||||||
|
res = _FAIL;
|
||||||
|
RTW_ERR("%s : omac1_aes_128 fail!", __func__);
|
||||||
|
}
|
||||||
|
} else if (key_len == 32) {
|
||||||
|
if (omac1_aes_256(key, data, data_len, mic)) {
|
||||||
|
res = _FAIL;
|
||||||
|
RTW_ERR("%s : omac1_aes_256 fail!", __func__);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RTW_ERR("%s : key_len not match!", __func__);
|
||||||
|
res = _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u8 _bip_gcmp_protect(u8 *whdr_pos, size_t len,
|
||||||
|
const u8 *key, size_t key_len,
|
||||||
|
const u8 *data, size_t data_len, u8 *mic)
|
||||||
|
{
|
||||||
|
u8 res = _SUCCESS;
|
||||||
|
u32 mic_len = 16;
|
||||||
|
u8 nonce[12], *npos;
|
||||||
|
const u8 *gcmp_ipn;
|
||||||
|
|
||||||
|
gcmp_ipn = whdr_pos + len - mic_len - 6;
|
||||||
|
|
||||||
|
/* Nonce: A2 | IPN */
|
||||||
|
_rtw_memcpy(nonce, get_addr2_ptr(whdr_pos), ETH_ALEN);
|
||||||
|
npos = nonce + ETH_ALEN;
|
||||||
|
*npos++ = gcmp_ipn[5];
|
||||||
|
*npos++ = gcmp_ipn[4];
|
||||||
|
*npos++ = gcmp_ipn[3];
|
||||||
|
*npos++ = gcmp_ipn[2];
|
||||||
|
*npos++ = gcmp_ipn[1];
|
||||||
|
*npos++ = gcmp_ipn[0];
|
||||||
|
|
||||||
|
if (aes_gmac(key, key_len, nonce, sizeof(nonce),
|
||||||
|
data, data_len, mic)) {
|
||||||
|
res = _FAIL;
|
||||||
|
RTW_ERR("%s : aes_gmac fail!", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_IEEE80211W */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_TDLS
|
||||||
|
void _tdls_generate_tpk(void *sta, const u8 *own_addr, const u8 *bssid)
|
||||||
|
{
|
||||||
|
struct sta_info *psta = (struct sta_info *)sta;
|
||||||
|
u8 *SNonce = psta->SNonce;
|
||||||
|
u8 *ANonce = psta->ANonce;
|
||||||
|
|
||||||
|
u8 key_input[SHA256_MAC_LEN];
|
||||||
|
const u8 *nonce[2];
|
||||||
|
size_t len[2];
|
||||||
|
u8 data[3 * ETH_ALEN];
|
||||||
|
|
||||||
|
/* IEEE Std 802.11z-2010 8.5.9.1:
|
||||||
|
* TPK-Key-Input = SHA-256(min(SNonce, ANonce) || max(SNonce, ANonce))
|
||||||
|
*/
|
||||||
|
len[0] = 32;
|
||||||
|
len[1] = 32;
|
||||||
|
if (_rtw_memcmp2(SNonce, ANonce, 32) < 0) {
|
||||||
|
nonce[0] = SNonce;
|
||||||
|
nonce[1] = ANonce;
|
||||||
|
} else {
|
||||||
|
nonce[0] = ANonce;
|
||||||
|
nonce[1] = SNonce;
|
||||||
|
}
|
||||||
|
|
||||||
|
sha256_vector(2, nonce, len, key_input);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TPK = KDF-Hash-Length(TPK-Key-Input, "TDLS PMK",
|
||||||
|
* min(MAC_I, MAC_R) || max(MAC_I, MAC_R) || BSSID)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (_rtw_memcmp2(own_addr, psta->cmn.mac_addr, ETH_ALEN) < 0) {
|
||||||
|
_rtw_memcpy(data, own_addr, ETH_ALEN);
|
||||||
|
_rtw_memcpy(data + ETH_ALEN, psta->cmn.mac_addr, ETH_ALEN);
|
||||||
|
} else {
|
||||||
|
_rtw_memcpy(data, psta->cmn.mac_addr, ETH_ALEN);
|
||||||
|
_rtw_memcpy(data + ETH_ALEN, own_addr, ETH_ALEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
_rtw_memcpy(data + 2 * ETH_ALEN, bssid, ETH_ALEN);
|
||||||
|
|
||||||
|
sha256_prf(key_input, SHA256_MAC_LEN, "TDLS PMK", data, sizeof(data), (u8 *)&psta->tpk, sizeof(psta->tpk));
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_TDLS */
|
||||||
3507
drivers/net/wireless/realtek/rtl8822ce/core/rtw_tdls.c
Normal file
3507
drivers/net/wireless/realtek/rtl8822ce/core/rtw_tdls.c
Normal file
File diff suppressed because it is too large
Load Diff
1134
drivers/net/wireless/realtek/rtl8822ce/core/rtw_vht.c
Normal file
1134
drivers/net/wireless/realtek/rtl8822ce/core/rtw_vht.c
Normal file
File diff suppressed because it is too large
Load Diff
1320
drivers/net/wireless/realtek/rtl8822ce/core/rtw_wapi.c
Normal file
1320
drivers/net/wireless/realtek/rtl8822ce/core/rtw_wapi.c
Normal file
File diff suppressed because it is too large
Load Diff
922
drivers/net/wireless/realtek/rtl8822ce/core/rtw_wapi_sms4.c
Normal file
922
drivers/net/wireless/realtek/rtl8822ce/core/rtw_wapi_sms4.c
Normal file
@@ -0,0 +1,922 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifdef CONFIG_WAPI_SUPPORT
|
||||||
|
|
||||||
|
#include <linux/unistd.h>
|
||||||
|
#include <linux/etherdevice.h>
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <rtw_wapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_WAPI_SW_SMS4
|
||||||
|
|
||||||
|
#define WAPI_LITTLE_ENDIAN
|
||||||
|
/* #define BIG_ENDIAN */
|
||||||
|
#define ENCRYPT 0
|
||||||
|
#define DECRYPT 1
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************
|
||||||
|
**********************************************************/
|
||||||
|
const u8 Sbox[256] = {
|
||||||
|
0xd6, 0x90, 0xe9, 0xfe, 0xcc, 0xe1, 0x3d, 0xb7, 0x16, 0xb6, 0x14, 0xc2, 0x28, 0xfb, 0x2c, 0x05,
|
||||||
|
0x2b, 0x67, 0x9a, 0x76, 0x2a, 0xbe, 0x04, 0xc3, 0xaa, 0x44, 0x13, 0x26, 0x49, 0x86, 0x06, 0x99,
|
||||||
|
0x9c, 0x42, 0x50, 0xf4, 0x91, 0xef, 0x98, 0x7a, 0x33, 0x54, 0x0b, 0x43, 0xed, 0xcf, 0xac, 0x62,
|
||||||
|
0xe4, 0xb3, 0x1c, 0xa9, 0xc9, 0x08, 0xe8, 0x95, 0x80, 0xdf, 0x94, 0xfa, 0x75, 0x8f, 0x3f, 0xa6,
|
||||||
|
0x47, 0x07, 0xa7, 0xfc, 0xf3, 0x73, 0x17, 0xba, 0x83, 0x59, 0x3c, 0x19, 0xe6, 0x85, 0x4f, 0xa8,
|
||||||
|
0x68, 0x6b, 0x81, 0xb2, 0x71, 0x64, 0xda, 0x8b, 0xf8, 0xeb, 0x0f, 0x4b, 0x70, 0x56, 0x9d, 0x35,
|
||||||
|
0x1e, 0x24, 0x0e, 0x5e, 0x63, 0x58, 0xd1, 0xa2, 0x25, 0x22, 0x7c, 0x3b, 0x01, 0x21, 0x78, 0x87,
|
||||||
|
0xd4, 0x00, 0x46, 0x57, 0x9f, 0xd3, 0x27, 0x52, 0x4c, 0x36, 0x02, 0xe7, 0xa0, 0xc4, 0xc8, 0x9e,
|
||||||
|
0xea, 0xbf, 0x8a, 0xd2, 0x40, 0xc7, 0x38, 0xb5, 0xa3, 0xf7, 0xf2, 0xce, 0xf9, 0x61, 0x15, 0xa1,
|
||||||
|
0xe0, 0xae, 0x5d, 0xa4, 0x9b, 0x34, 0x1a, 0x55, 0xad, 0x93, 0x32, 0x30, 0xf5, 0x8c, 0xb1, 0xe3,
|
||||||
|
0x1d, 0xf6, 0xe2, 0x2e, 0x82, 0x66, 0xca, 0x60, 0xc0, 0x29, 0x23, 0xab, 0x0d, 0x53, 0x4e, 0x6f,
|
||||||
|
0xd5, 0xdb, 0x37, 0x45, 0xde, 0xfd, 0x8e, 0x2f, 0x03, 0xff, 0x6a, 0x72, 0x6d, 0x6c, 0x5b, 0x51,
|
||||||
|
0x8d, 0x1b, 0xaf, 0x92, 0xbb, 0xdd, 0xbc, 0x7f, 0x11, 0xd9, 0x5c, 0x41, 0x1f, 0x10, 0x5a, 0xd8,
|
||||||
|
0x0a, 0xc1, 0x31, 0x88, 0xa5, 0xcd, 0x7b, 0xbd, 0x2d, 0x74, 0xd0, 0x12, 0xb8, 0xe5, 0xb4, 0xb0,
|
||||||
|
0x89, 0x69, 0x97, 0x4a, 0x0c, 0x96, 0x77, 0x7e, 0x65, 0xb9, 0xf1, 0x09, 0xc5, 0x6e, 0xc6, 0x84,
|
||||||
|
0x18, 0xf0, 0x7d, 0xec, 0x3a, 0xdc, 0x4d, 0x20, 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48
|
||||||
|
};
|
||||||
|
|
||||||
|
const u32 CK[32] = {
|
||||||
|
0x00070e15, 0x1c232a31, 0x383f464d, 0x545b6269,
|
||||||
|
0x70777e85, 0x8c939aa1, 0xa8afb6bd, 0xc4cbd2d9,
|
||||||
|
0xe0e7eef5, 0xfc030a11, 0x181f262d, 0x343b4249,
|
||||||
|
0x50575e65, 0x6c737a81, 0x888f969d, 0xa4abb2b9,
|
||||||
|
0xc0c7ced5, 0xdce3eaf1, 0xf8ff060d, 0x141b2229,
|
||||||
|
0x30373e45, 0x4c535a61, 0x686f767d, 0x848b9299,
|
||||||
|
0xa0a7aeb5, 0xbcc3cad1, 0xd8dfe6ed, 0xf4fb0209,
|
||||||
|
0x10171e25, 0x2c333a41, 0x484f565d, 0x646b7279
|
||||||
|
};
|
||||||
|
|
||||||
|
#define Rotl(_x, _y) (((_x) << (_y)) | ((_x) >> (32 - (_y))))
|
||||||
|
|
||||||
|
#define ByteSub(_A) (Sbox[(_A) >> 24 & 0xFF] << 24 | \
|
||||||
|
Sbox[(_A) >> 16 & 0xFF] << 16 | \
|
||||||
|
Sbox[(_A) >> 8 & 0xFF] << 8 | \
|
||||||
|
Sbox[(_A) & 0xFF])
|
||||||
|
|
||||||
|
#define L1(_B) ((_B) ^ Rotl(_B, 2) ^ Rotl(_B, 10) ^ Rotl(_B, 18) ^ Rotl(_B, 24))
|
||||||
|
#define L2(_B) ((_B) ^ Rotl(_B, 13) ^ Rotl(_B, 23))
|
||||||
|
|
||||||
|
static void
|
||||||
|
xor_block(void *dst, void *src1, void *src2)
|
||||||
|
/* 128-bit xor: *dst = *src1 xor *src2. Pointers must be 32-bit aligned */
|
||||||
|
{
|
||||||
|
((u32 *)dst)[0] = ((u32 *)src1)[0] ^ ((u32 *)src2)[0];
|
||||||
|
((u32 *)dst)[1] = ((u32 *)src1)[1] ^ ((u32 *)src2)[1];
|
||||||
|
((u32 *)dst)[2] = ((u32 *)src1)[2] ^ ((u32 *)src2)[2];
|
||||||
|
((u32 *)dst)[3] = ((u32 *)src1)[3] ^ ((u32 *)src2)[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SMS4Crypt(u8 *Input, u8 *Output, u32 *rk)
|
||||||
|
{
|
||||||
|
u32 r, mid, x0, x1, x2, x3, *p;
|
||||||
|
p = (u32 *)Input;
|
||||||
|
x0 = p[0];
|
||||||
|
x1 = p[1];
|
||||||
|
x2 = p[2];
|
||||||
|
x3 = p[3];
|
||||||
|
#ifdef WAPI_LITTLE_ENDIAN
|
||||||
|
x0 = Rotl(x0, 16);
|
||||||
|
x0 = ((x0 & 0x00FF00FF) << 8) | ((x0 & 0xFF00FF00) >> 8);
|
||||||
|
x1 = Rotl(x1, 16);
|
||||||
|
x1 = ((x1 & 0x00FF00FF) << 8) | ((x1 & 0xFF00FF00) >> 8);
|
||||||
|
x2 = Rotl(x2, 16);
|
||||||
|
x2 = ((x2 & 0x00FF00FF) << 8) | ((x2 & 0xFF00FF00) >> 8);
|
||||||
|
x3 = Rotl(x3, 16);
|
||||||
|
x3 = ((x3 & 0x00FF00FF) << 8) | ((x3 & 0xFF00FF00) >> 8);
|
||||||
|
#endif
|
||||||
|
for (r = 0; r < 32; r += 4) {
|
||||||
|
mid = x1 ^ x2 ^ x3 ^ rk[r + 0];
|
||||||
|
mid = ByteSub(mid);
|
||||||
|
x0 ^= L1(mid);
|
||||||
|
mid = x2 ^ x3 ^ x0 ^ rk[r + 1];
|
||||||
|
mid = ByteSub(mid);
|
||||||
|
x1 ^= L1(mid);
|
||||||
|
mid = x3 ^ x0 ^ x1 ^ rk[r + 2];
|
||||||
|
mid = ByteSub(mid);
|
||||||
|
x2 ^= L1(mid);
|
||||||
|
mid = x0 ^ x1 ^ x2 ^ rk[r + 3];
|
||||||
|
mid = ByteSub(mid);
|
||||||
|
x3 ^= L1(mid);
|
||||||
|
}
|
||||||
|
#ifdef WAPI_LITTLE_ENDIAN
|
||||||
|
x0 = Rotl(x0, 16);
|
||||||
|
x0 = ((x0 & 0x00FF00FF) << 8) | ((x0 & 0xFF00FF00) >> 8);
|
||||||
|
x1 = Rotl(x1, 16);
|
||||||
|
x1 = ((x1 & 0x00FF00FF) << 8) | ((x1 & 0xFF00FF00) >> 8);
|
||||||
|
x2 = Rotl(x2, 16);
|
||||||
|
x2 = ((x2 & 0x00FF00FF) << 8) | ((x2 & 0xFF00FF00) >> 8);
|
||||||
|
x3 = Rotl(x3, 16);
|
||||||
|
x3 = ((x3 & 0x00FF00FF) << 8) | ((x3 & 0xFF00FF00) >> 8);
|
||||||
|
#endif
|
||||||
|
p = (u32 *)Output;
|
||||||
|
p[0] = x3;
|
||||||
|
p[1] = x2;
|
||||||
|
p[2] = x1;
|
||||||
|
p[3] = x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SMS4KeyExt(u8 *Key, u32 *rk, u32 CryptFlag)
|
||||||
|
{
|
||||||
|
u32 r, mid, x0, x1, x2, x3, *p;
|
||||||
|
|
||||||
|
p = (u32 *)Key;
|
||||||
|
x0 = p[0];
|
||||||
|
x1 = p[1];
|
||||||
|
x2 = p[2];
|
||||||
|
x3 = p[3];
|
||||||
|
#ifdef WAPI_LITTLE_ENDIAN
|
||||||
|
x0 = Rotl(x0, 16);
|
||||||
|
x0 = ((x0 & 0xFF00FF) << 8) | ((x0 & 0xFF00FF00) >> 8);
|
||||||
|
x1 = Rotl(x1, 16);
|
||||||
|
x1 = ((x1 & 0xFF00FF) << 8) | ((x1 & 0xFF00FF00) >> 8);
|
||||||
|
x2 = Rotl(x2, 16);
|
||||||
|
x2 = ((x2 & 0xFF00FF) << 8) | ((x2 & 0xFF00FF00) >> 8);
|
||||||
|
x3 = Rotl(x3, 16);
|
||||||
|
x3 = ((x3 & 0xFF00FF) << 8) | ((x3 & 0xFF00FF00) >> 8);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
x0 ^= 0xa3b1bac6;
|
||||||
|
x1 ^= 0x56aa3350;
|
||||||
|
x2 ^= 0x677d9197;
|
||||||
|
x3 ^= 0xb27022dc;
|
||||||
|
for (r = 0; r < 32; r += 4) {
|
||||||
|
mid = x1 ^ x2 ^ x3 ^ CK[r + 0];
|
||||||
|
mid = ByteSub(mid);
|
||||||
|
rk[r + 0] = x0 ^= L2(mid);
|
||||||
|
mid = x2 ^ x3 ^ x0 ^ CK[r + 1];
|
||||||
|
mid = ByteSub(mid);
|
||||||
|
rk[r + 1] = x1 ^= L2(mid);
|
||||||
|
mid = x3 ^ x0 ^ x1 ^ CK[r + 2];
|
||||||
|
mid = ByteSub(mid);
|
||||||
|
rk[r + 2] = x2 ^= L2(mid);
|
||||||
|
mid = x0 ^ x1 ^ x2 ^ CK[r + 3];
|
||||||
|
mid = ByteSub(mid);
|
||||||
|
rk[r + 3] = x3 ^= L2(mid);
|
||||||
|
}
|
||||||
|
if (CryptFlag == DECRYPT) {
|
||||||
|
for (r = 0; r < 16; r++)
|
||||||
|
mid = rk[r], rk[r] = rk[31 - r], rk[31 - r] = mid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WapiSMS4Cryption(u8 *Key, u8 *IV, u8 *Input, u16 InputLength,
|
||||||
|
u8 *Output, u16 *OutputLength, u32 CryptFlag)
|
||||||
|
{
|
||||||
|
u32 blockNum, i, j, rk[32];
|
||||||
|
u16 remainder;
|
||||||
|
u8 blockIn[16], blockOut[16], tempIV[16], k;
|
||||||
|
|
||||||
|
*OutputLength = 0;
|
||||||
|
remainder = InputLength & 0x0F;
|
||||||
|
blockNum = InputLength >> 4;
|
||||||
|
if (remainder != 0)
|
||||||
|
blockNum++;
|
||||||
|
else
|
||||||
|
remainder = 16;
|
||||||
|
|
||||||
|
for (k = 0; k < 16; k++)
|
||||||
|
tempIV[k] = IV[15 - k];
|
||||||
|
|
||||||
|
memcpy(blockIn, tempIV, 16);
|
||||||
|
|
||||||
|
SMS4KeyExt((u8 *)Key, rk, CryptFlag);
|
||||||
|
|
||||||
|
for (i = 0; i < blockNum - 1; i++) {
|
||||||
|
SMS4Crypt((u8 *)blockIn, blockOut, rk);
|
||||||
|
xor_block(&Output[i * 16], &Input[i * 16], blockOut);
|
||||||
|
memcpy(blockIn, blockOut, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
*OutputLength = i * 16;
|
||||||
|
|
||||||
|
SMS4Crypt((u8 *)blockIn, blockOut, rk);
|
||||||
|
|
||||||
|
for (j = 0; j < remainder; j++)
|
||||||
|
Output[i * 16 + j] = Input[i * 16 + j] ^ blockOut[j];
|
||||||
|
*OutputLength += remainder;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WapiSMS4Encryption(u8 *Key, u8 *IV, u8 *Input, u16 InputLength,
|
||||||
|
u8 *Output, u16 *OutputLength)
|
||||||
|
{
|
||||||
|
|
||||||
|
WapiSMS4Cryption(Key, IV, Input, InputLength, Output, OutputLength, ENCRYPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WapiSMS4Decryption(u8 *Key, u8 *IV, u8 *Input, u16 InputLength,
|
||||||
|
u8 *Output, u16 *OutputLength)
|
||||||
|
{
|
||||||
|
/* OFB mode: is also ENCRYPT flag */
|
||||||
|
WapiSMS4Cryption(Key, IV, Input, InputLength, Output, OutputLength, ENCRYPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WapiSMS4CalculateMic(u8 *Key, u8 *IV, u8 *Input1, u8 Input1Length,
|
||||||
|
u8 *Input2, u16 Input2Length, u8 *Output, u8 *OutputLength)
|
||||||
|
{
|
||||||
|
u32 blockNum, i, remainder, rk[32];
|
||||||
|
u8 BlockIn[16], BlockOut[16], TempBlock[16], tempIV[16], k;
|
||||||
|
|
||||||
|
*OutputLength = 0;
|
||||||
|
remainder = Input1Length & 0x0F;
|
||||||
|
blockNum = Input1Length >> 4;
|
||||||
|
|
||||||
|
for (k = 0; k < 16; k++)
|
||||||
|
tempIV[k] = IV[15 - k];
|
||||||
|
|
||||||
|
memcpy(BlockIn, tempIV, 16);
|
||||||
|
|
||||||
|
SMS4KeyExt((u8 *)Key, rk, ENCRYPT);
|
||||||
|
|
||||||
|
SMS4Crypt((u8 *)BlockIn, BlockOut, rk);
|
||||||
|
|
||||||
|
for (i = 0; i < blockNum; i++) {
|
||||||
|
xor_block(BlockIn, (Input1 + i * 16), BlockOut);
|
||||||
|
SMS4Crypt((u8 *)BlockIn, BlockOut, rk);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainder != 0) {
|
||||||
|
memset(TempBlock, 0, 16);
|
||||||
|
memcpy(TempBlock, (Input1 + blockNum * 16), remainder);
|
||||||
|
|
||||||
|
xor_block(BlockIn, TempBlock, BlockOut);
|
||||||
|
SMS4Crypt((u8 *)BlockIn, BlockOut, rk);
|
||||||
|
}
|
||||||
|
|
||||||
|
remainder = Input2Length & 0x0F;
|
||||||
|
blockNum = Input2Length >> 4;
|
||||||
|
|
||||||
|
for (i = 0; i < blockNum; i++) {
|
||||||
|
xor_block(BlockIn, (Input2 + i * 16), BlockOut);
|
||||||
|
SMS4Crypt((u8 *)BlockIn, BlockOut, rk);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainder != 0) {
|
||||||
|
memset(TempBlock, 0, 16);
|
||||||
|
memcpy(TempBlock, (Input2 + blockNum * 16), remainder);
|
||||||
|
|
||||||
|
xor_block(BlockIn, TempBlock, BlockOut);
|
||||||
|
SMS4Crypt((u8 *)BlockIn, BlockOut, rk);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(Output, BlockOut, 16);
|
||||||
|
*OutputLength = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SecCalculateMicSMS4(
|
||||||
|
u8 KeyIdx,
|
||||||
|
u8 *MicKey,
|
||||||
|
u8 *pHeader,
|
||||||
|
u8 *pData,
|
||||||
|
u16 DataLen,
|
||||||
|
u8 *MicBuffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
struct ieee80211_hdr_3addr_qos *header;
|
||||||
|
u8 TempBuf[34], TempLen = 32, MicLen, QosOffset, *IV;
|
||||||
|
u16 *pTemp, fc;
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_TX | WAPI_RX, "=========>%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
header = (struct ieee80211_hdr_3addr_qos *)pHeader;
|
||||||
|
memset(TempBuf, 0, 34);
|
||||||
|
memcpy(TempBuf, pHeader, 2); /* FrameCtrl */
|
||||||
|
pTemp = (u16 *)TempBuf;
|
||||||
|
*pTemp &= 0xc78f; /* bit4,5,6,11,12,13 */
|
||||||
|
|
||||||
|
memcpy((TempBuf + 2), (pHeader + 4), 12); /* Addr1, Addr2 */
|
||||||
|
memcpy((TempBuf + 14), (pHeader + 22), 2); /* SeqCtrl */
|
||||||
|
pTemp = (u16 *)(TempBuf + 14);
|
||||||
|
*pTemp &= 0x000f;
|
||||||
|
|
||||||
|
memcpy((TempBuf + 16), (pHeader + 16), 6); /* Addr3 */
|
||||||
|
|
||||||
|
fc = le16_to_cpu(header->frame_ctl);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (GetFrDs((u16 *)&fc) && GetToDs((u16 *)&fc)) {
|
||||||
|
memcpy((TempBuf + 22), (pHeader + 24), 6);
|
||||||
|
QosOffset = 30;
|
||||||
|
} else {
|
||||||
|
memset((TempBuf + 22), 0, 6);
|
||||||
|
QosOffset = 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fc & 0x0088) == 0x0088) {
|
||||||
|
memcpy((TempBuf + 28), (pHeader + QosOffset), 2);
|
||||||
|
TempLen += 2;
|
||||||
|
/* IV = pHeader + QosOffset + 2 + SNAP_SIZE + sizeof(u16) + 2; */
|
||||||
|
IV = pHeader + QosOffset + 2 + 2;
|
||||||
|
} else {
|
||||||
|
IV = pHeader + QosOffset + 2;
|
||||||
|
/* IV = pHeader + QosOffset + SNAP_SIZE + sizeof(u16) + 2; */
|
||||||
|
}
|
||||||
|
|
||||||
|
TempBuf[TempLen - 1] = (u8)(DataLen & 0xff);
|
||||||
|
TempBuf[TempLen - 2] = (u8)((DataLen & 0xff00) >> 8);
|
||||||
|
TempBuf[TempLen - 4] = KeyIdx;
|
||||||
|
|
||||||
|
WAPI_DATA(WAPI_TX, "CalculateMic - KEY", MicKey, 16);
|
||||||
|
WAPI_DATA(WAPI_TX, "CalculateMic - IV", IV, 16);
|
||||||
|
WAPI_DATA(WAPI_TX, "CalculateMic - TempBuf", TempBuf, TempLen);
|
||||||
|
WAPI_DATA(WAPI_TX, "CalculateMic - pData", pData, DataLen);
|
||||||
|
|
||||||
|
WapiSMS4CalculateMic(MicKey, IV, TempBuf, TempLen,
|
||||||
|
pData, DataLen, MicBuffer, &MicLen);
|
||||||
|
|
||||||
|
if (MicLen != 16)
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: MIC Length Error!!\n", __FUNCTION__);
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_TX | WAPI_RX, "<=========%s\n", __FUNCTION__);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* AddCount: 1 or 2.
|
||||||
|
* If overflow, return 1,
|
||||||
|
* else return 0.
|
||||||
|
*/
|
||||||
|
u8 WapiIncreasePN(u8 *PN, u8 AddCount)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
|
||||||
|
if (NULL == PN)
|
||||||
|
return 1;
|
||||||
|
/* YJ,test,091102 */
|
||||||
|
/*
|
||||||
|
if(AddCount == 2){
|
||||||
|
RTW_INFO("############################%s(): PN[0]=0x%x\n", __FUNCTION__, PN[0]);
|
||||||
|
if(PN[0] == 0x48){
|
||||||
|
PN[0] += AddCount;
|
||||||
|
return 1;
|
||||||
|
}else{
|
||||||
|
PN[0] += AddCount;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/* YJ,test,091102,end */
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
if (PN[i] + AddCount <= 0xff) {
|
||||||
|
PN[i] += AddCount;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
PN[i] += AddCount;
|
||||||
|
AddCount = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WapiGetLastRxUnicastPNForQoSData(
|
||||||
|
u8 UserPriority,
|
||||||
|
PRT_WAPI_STA_INFO pWapiStaInfo,
|
||||||
|
u8 *PNOut
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WAPI_TRACE(WAPI_RX, "===========> %s\n", __FUNCTION__);
|
||||||
|
switch (UserPriority) {
|
||||||
|
case 0:
|
||||||
|
case 3:
|
||||||
|
memcpy(PNOut, pWapiStaInfo->lastRxUnicastPNBEQueue, 16);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
memcpy(PNOut, pWapiStaInfo->lastRxUnicastPNBKQueue, 16);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
memcpy(PNOut, pWapiStaInfo->lastRxUnicastPNVIQueue, 16);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
memcpy(PNOut, pWapiStaInfo->lastRxUnicastPNVOQueue, 16);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Unknown TID\n", __FUNCTION__);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
WAPI_TRACE(WAPI_RX, "<=========== %s\n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WapiSetLastRxUnicastPNForQoSData(
|
||||||
|
u8 UserPriority,
|
||||||
|
u8 *PNIn,
|
||||||
|
PRT_WAPI_STA_INFO pWapiStaInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WAPI_TRACE(WAPI_RX, "===========> %s\n", __FUNCTION__);
|
||||||
|
switch (UserPriority) {
|
||||||
|
case 0:
|
||||||
|
case 3:
|
||||||
|
memcpy(pWapiStaInfo->lastRxUnicastPNBEQueue, PNIn, 16);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
memcpy(pWapiStaInfo->lastRxUnicastPNBKQueue, PNIn, 16);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
memcpy(pWapiStaInfo->lastRxUnicastPNVIQueue, PNIn, 16);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
memcpy(pWapiStaInfo->lastRxUnicastPNVOQueue, PNIn, 16);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Unknown TID\n", __FUNCTION__);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
WAPI_TRACE(WAPI_RX, "<=========== %s\n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
FALSE not RX-Reorder
|
||||||
|
TRUE do RX Reorder
|
||||||
|
add to support WAPI to N-mode
|
||||||
|
*****************************************************************************/
|
||||||
|
u8 WapiCheckPnInSwDecrypt(
|
||||||
|
_adapter *padapter,
|
||||||
|
struct sk_buff *pskb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
u8 ret = false;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
struct ieee80211_hdr_3addr_qos *header;
|
||||||
|
u16 fc;
|
||||||
|
u8 *pDaddr, *pTaddr, *pRaddr;
|
||||||
|
|
||||||
|
header = (struct ieee80211_hdr_3addr_qos *)pskb->data;
|
||||||
|
pTaddr = header->addr2;
|
||||||
|
pRaddr = header->addr1;
|
||||||
|
fc = le16_to_cpu(header->frame_ctl);
|
||||||
|
|
||||||
|
if (GetToDs(&fc))
|
||||||
|
pDaddr = header->addr3;
|
||||||
|
else
|
||||||
|
pDaddr = header->addr1;
|
||||||
|
|
||||||
|
if ((_rtw_memcmp(pRaddr, padapter->pnetdev->dev_addr, ETH_ALEN) == 0)
|
||||||
|
&& !(pDaddr)
|
||||||
|
&& (GetFrameType(&fc) == WIFI_QOS_DATA_TYPE))
|
||||||
|
/* && ieee->pHTInfo->bCurrentHTSupport && */
|
||||||
|
/* ieee->pHTInfo->bCurRxReorderEnable) */
|
||||||
|
ret = false;
|
||||||
|
else
|
||||||
|
ret = true;
|
||||||
|
#endif
|
||||||
|
WAPI_TRACE(WAPI_RX, "%s: return %d\n", __FUNCTION__, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SecSMS4HeaderFillIV(_adapter *padapter, u8 *pxmitframe)
|
||||||
|
{
|
||||||
|
struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
|
||||||
|
u8 *frame = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET;
|
||||||
|
u8 *pSecHeader = NULL, *pos = NULL, *pRA = NULL;
|
||||||
|
u8 bPNOverflow = false, bFindMatchPeer = false, hdr_len = 0;
|
||||||
|
PWLAN_HEADER_WAPI_EXTENSION pWapiExt = NULL;
|
||||||
|
PRT_WAPI_T pWapiInfo = &padapter->wapiInfo;
|
||||||
|
PRT_WAPI_STA_INFO pWapiSta = NULL;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_TX, "=========>%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
#if 0
|
||||||
|
hdr_len = sMacHdrLng;
|
||||||
|
if (GetFrameType(pskb->data) == WIFI_QOS_DATA_TYPE)
|
||||||
|
hdr_len += 2;
|
||||||
|
/* hdr_len += SNAP_SIZE + sizeof(u16); */
|
||||||
|
|
||||||
|
pos = skb_push(pskb, padapter->wapiInfo.extra_prefix_len);
|
||||||
|
memmove(pos, pos + padapter->wapiInfo.extra_prefix_len, hdr_len);
|
||||||
|
|
||||||
|
pSecHeader = pskb->data + hdr_len;
|
||||||
|
pWapiExt = (PWLAN_HEADER_WAPI_EXTENSION)pSecHeader;
|
||||||
|
pRA = pskb->data + 4;
|
||||||
|
|
||||||
|
WAPI_DATA(WAPI_TX, "FillIV - Before Fill IV", pskb->data, pskb->len);
|
||||||
|
|
||||||
|
/* Address 1 is always receiver's address */
|
||||||
|
if (IS_MCAST(pRA)) {
|
||||||
|
if (!pWapiInfo->wapiTxMsk.bTxEnable) {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: bTxEnable = 0!!\n", __FUNCTION__);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
if (pWapiInfo->wapiTxMsk.keyId <= 1) {
|
||||||
|
pWapiExt->KeyIdx = pWapiInfo->wapiTxMsk.keyId;
|
||||||
|
pWapiExt->Reserved = 0;
|
||||||
|
bPNOverflow = WapiIncreasePN(pWapiInfo->lastTxMulticastPN, 1);
|
||||||
|
memcpy(pWapiExt->PN, pWapiInfo->lastTxMulticastPN, 16);
|
||||||
|
if (bPNOverflow) {
|
||||||
|
/* Update MSK Notification. */
|
||||||
|
WAPI_TRACE(WAPI_ERR, "===============>%s():multicast PN overflow\n", __FUNCTION__);
|
||||||
|
rtw_wapi_app_event_handler(padapter, NULL, 0, pRA, false, false, true, 0, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Invalid Wapi Multicast KeyIdx!!\n", __FUNCTION__);
|
||||||
|
ret = -3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) {
|
||||||
|
if (!memcmp(pWapiSta->PeerMacAddr, pRA, 6)) {
|
||||||
|
bFindMatchPeer = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bFindMatchPeer) {
|
||||||
|
if ((!pWapiSta->wapiUskUpdate.bTxEnable) && (!pWapiSta->wapiUsk.bTxEnable)) {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: bTxEnable = 0!!\n", __FUNCTION__);
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
if (pWapiSta->wapiUsk.keyId <= 1) {
|
||||||
|
if (pWapiSta->wapiUskUpdate.bTxEnable)
|
||||||
|
pWapiExt->KeyIdx = pWapiSta->wapiUskUpdate.keyId;
|
||||||
|
else
|
||||||
|
pWapiExt->KeyIdx = pWapiSta->wapiUsk.keyId;
|
||||||
|
|
||||||
|
pWapiExt->Reserved = 0;
|
||||||
|
bPNOverflow = WapiIncreasePN(pWapiSta->lastTxUnicastPN, 2);
|
||||||
|
memcpy(pWapiExt->PN, pWapiSta->lastTxUnicastPN, 16);
|
||||||
|
if (bPNOverflow) {
|
||||||
|
/* Update USK Notification. */
|
||||||
|
WAPI_TRACE(WAPI_ERR, "===============>%s():unicast PN overflow\n", __FUNCTION__);
|
||||||
|
rtw_wapi_app_event_handler(padapter, NULL, 0, pWapiSta->PeerMacAddr, false, true, false, 0, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Invalid Wapi Unicast KeyIdx!!\n", __FUNCTION__);
|
||||||
|
ret = -5;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Can not find Peer Sta "MAC_FMT"!!\n", __FUNCTION__, MAC_ARG(pRA));
|
||||||
|
ret = -6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WAPI_DATA(WAPI_TX, "FillIV - After Fill IV", pskb->data, pskb->len);
|
||||||
|
WAPI_TRACE(WAPI_TX, "<=========%s\n", __FUNCTION__);
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WAPI SW Enc: must have done Coalesce! */
|
||||||
|
void SecSWSMS4Encryption(
|
||||||
|
_adapter *padapter,
|
||||||
|
u8 *pxmitframe
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PRT_WAPI_T pWapiInfo = &padapter->wapiInfo;
|
||||||
|
PRT_WAPI_STA_INFO pWapiSta = NULL;
|
||||||
|
u8 *pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_SIZE;
|
||||||
|
struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
|
||||||
|
|
||||||
|
u8 *SecPtr = NULL, *pRA, *pMicKey = NULL, *pDataKey = NULL, *pIV = NULL;
|
||||||
|
u8 IVOffset, DataOffset, bFindMatchPeer = false, KeyIdx = 0, MicBuffer[16];
|
||||||
|
u16 OutputLength;
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_TX, "=========>%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_TX, "hdrlen: %d\n", pattrib->hdrlen);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
DataOffset = pattrib->hdrlen + pattrib->iv_len;
|
||||||
|
|
||||||
|
pRA = pframe + 4;
|
||||||
|
|
||||||
|
|
||||||
|
if (IS_MCAST(pRA)) {
|
||||||
|
KeyIdx = pWapiInfo->wapiTxMsk.keyId;
|
||||||
|
pIV = pWapiInfo->lastTxMulticastPN;
|
||||||
|
pMicKey = pWapiInfo->wapiTxMsk.micKey;
|
||||||
|
pDataKey = pWapiInfo->wapiTxMsk.dataKey;
|
||||||
|
} else {
|
||||||
|
if (!list_empty(&(pWapiInfo->wapiSTAUsedList))) {
|
||||||
|
list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) {
|
||||||
|
if (0 == memcmp(pWapiSta->PeerMacAddr, pRA, 6)) {
|
||||||
|
bFindMatchPeer = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bFindMatchPeer) {
|
||||||
|
if (pWapiSta->wapiUskUpdate.bTxEnable) {
|
||||||
|
KeyIdx = pWapiSta->wapiUskUpdate.keyId;
|
||||||
|
WAPI_TRACE(WAPI_TX, "%s(): Use update USK!! KeyIdx=%d\n", __FUNCTION__, KeyIdx);
|
||||||
|
pIV = pWapiSta->lastTxUnicastPN;
|
||||||
|
pMicKey = pWapiSta->wapiUskUpdate.micKey;
|
||||||
|
pDataKey = pWapiSta->wapiUskUpdate.dataKey;
|
||||||
|
} else {
|
||||||
|
KeyIdx = pWapiSta->wapiUsk.keyId;
|
||||||
|
WAPI_TRACE(WAPI_TX, "%s(): Use USK!! KeyIdx=%d\n", __FUNCTION__, KeyIdx);
|
||||||
|
pIV = pWapiSta->lastTxUnicastPN;
|
||||||
|
pMicKey = pWapiSta->wapiUsk.micKey;
|
||||||
|
pDataKey = pWapiSta->wapiUsk.dataKey;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Can not find Peer Sta!!\n", __FUNCTION__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: wapiSTAUsedList is empty!!\n", __FUNCTION__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SecPtr = pframe;
|
||||||
|
SecCalculateMicSMS4(KeyIdx, pMicKey, SecPtr, (SecPtr + DataOffset), pattrib->pktlen, MicBuffer);
|
||||||
|
|
||||||
|
WAPI_DATA(WAPI_TX, "Encryption - MIC", MicBuffer, padapter->wapiInfo.extra_postfix_len);
|
||||||
|
|
||||||
|
memcpy(pframe + pattrib->hdrlen + pattrib->iv_len + pattrib->pktlen - pattrib->icv_len,
|
||||||
|
(u8 *)MicBuffer,
|
||||||
|
padapter->wapiInfo.extra_postfix_len
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
WapiSMS4Encryption(pDataKey, pIV, (SecPtr + DataOffset), pattrib->pktlen + pattrib->icv_len, (SecPtr + DataOffset), &OutputLength);
|
||||||
|
|
||||||
|
WAPI_DATA(WAPI_TX, "Encryption - After SMS4 encryption", pframe, pattrib->hdrlen + pattrib->iv_len + pattrib->pktlen);
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_TX, "<=========%s\n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 SecSWSMS4Decryption(
|
||||||
|
_adapter *padapter,
|
||||||
|
u8 *precv_frame,
|
||||||
|
struct recv_priv *precv_priv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PRT_WAPI_T pWapiInfo = &padapter->wapiInfo;
|
||||||
|
struct recv_frame_hdr *precv_hdr;
|
||||||
|
PRT_WAPI_STA_INFO pWapiSta = NULL;
|
||||||
|
u8 IVOffset, DataOffset, bFindMatchPeer = false, bUseUpdatedKey = false;
|
||||||
|
u8 KeyIdx, MicBuffer[16], lastRxPNforQoS[16];
|
||||||
|
u8 *pRA, *pTA, *pMicKey, *pDataKey, *pLastRxPN, *pRecvPN, *pSecData, *pRecvMic, *pos;
|
||||||
|
u8 TID = 0;
|
||||||
|
u16 OutputLength, DataLen;
|
||||||
|
u8 bQosData;
|
||||||
|
struct sk_buff *pskb;
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_RX, "=========>%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
precv_hdr = &((union recv_frame *)precv_frame)->u.hdr;
|
||||||
|
pskb = (struct sk_buff *)(precv_hdr->rx_data);
|
||||||
|
precv_hdr->bWapiCheckPNInDecrypt = WapiCheckPnInSwDecrypt(padapter, pskb);
|
||||||
|
WAPI_TRACE(WAPI_RX, "=========>%s: check PN %d\n", __FUNCTION__, precv_hdr->bWapiCheckPNInDecrypt);
|
||||||
|
WAPI_DATA(WAPI_RX, "Decryption - Before decryption", pskb->data, pskb->len);
|
||||||
|
|
||||||
|
IVOffset = sMacHdrLng;
|
||||||
|
bQosData = GetFrameType(pskb->data) == WIFI_QOS_DATA_TYPE;
|
||||||
|
if (bQosData)
|
||||||
|
IVOffset += 2;
|
||||||
|
|
||||||
|
/* if(GetHTC()) */
|
||||||
|
/* IVOffset += 4; */
|
||||||
|
|
||||||
|
/* IVOffset += SNAP_SIZE + sizeof(u16); */
|
||||||
|
|
||||||
|
DataOffset = IVOffset + padapter->wapiInfo.extra_prefix_len;
|
||||||
|
|
||||||
|
pRA = pskb->data + 4;
|
||||||
|
pTA = pskb->data + 10;
|
||||||
|
KeyIdx = *(pskb->data + IVOffset);
|
||||||
|
pRecvPN = pskb->data + IVOffset + 2;
|
||||||
|
pSecData = pskb->data + DataOffset;
|
||||||
|
DataLen = pskb->len - DataOffset;
|
||||||
|
pRecvMic = pskb->data + pskb->len - padapter->wapiInfo.extra_postfix_len;
|
||||||
|
TID = GetTid(pskb->data);
|
||||||
|
|
||||||
|
if (!list_empty(&(pWapiInfo->wapiSTAUsedList))) {
|
||||||
|
list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) {
|
||||||
|
if (0 == memcmp(pWapiSta->PeerMacAddr, pTA, 6)) {
|
||||||
|
bFindMatchPeer = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bFindMatchPeer) {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Can not find Peer Sta "MAC_FMT" for Key Info!!!\n", __FUNCTION__, MAC_ARG(pTA));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_MCAST(pRA)) {
|
||||||
|
WAPI_TRACE(WAPI_RX, "%s: Multicast decryption !!!\n", __FUNCTION__);
|
||||||
|
if (pWapiSta->wapiMsk.keyId == KeyIdx && pWapiSta->wapiMsk.bSet) {
|
||||||
|
pLastRxPN = pWapiSta->lastRxMulticastPN;
|
||||||
|
if (!WapiComparePN(pRecvPN, pLastRxPN)) {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: MSK PN is not larger than last, Dropped!!!\n", __FUNCTION__);
|
||||||
|
WAPI_DATA(WAPI_ERR, "pRecvPN:", pRecvPN, 16);
|
||||||
|
WAPI_DATA(WAPI_ERR, "pLastRxPN:", pLastRxPN, 16);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(pLastRxPN, pRecvPN, 16);
|
||||||
|
pMicKey = pWapiSta->wapiMsk.micKey;
|
||||||
|
pDataKey = pWapiSta->wapiMsk.dataKey;
|
||||||
|
} else if (pWapiSta->wapiMskUpdate.keyId == KeyIdx && pWapiSta->wapiMskUpdate.bSet) {
|
||||||
|
WAPI_TRACE(WAPI_RX, "%s: Use Updated MSK for Decryption !!!\n", __FUNCTION__);
|
||||||
|
bUseUpdatedKey = true;
|
||||||
|
memcpy(pWapiSta->lastRxMulticastPN, pRecvPN, 16);
|
||||||
|
pMicKey = pWapiSta->wapiMskUpdate.micKey;
|
||||||
|
pDataKey = pWapiSta->wapiMskUpdate.dataKey;
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Can not find MSK with matched KeyIdx(%d), Dropped !!!\n", __FUNCTION__, KeyIdx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_RX, "%s: Unicast decryption !!!\n", __FUNCTION__);
|
||||||
|
if (pWapiSta->wapiUsk.keyId == KeyIdx && pWapiSta->wapiUsk.bSet) {
|
||||||
|
WAPI_TRACE(WAPI_RX, "%s: Use USK for Decryption!!!\n", __FUNCTION__);
|
||||||
|
if (precv_hdr->bWapiCheckPNInDecrypt) {
|
||||||
|
if (GetFrameType(pskb->data) == WIFI_QOS_DATA_TYPE) {
|
||||||
|
WapiGetLastRxUnicastPNForQoSData(TID, pWapiSta, lastRxPNforQoS);
|
||||||
|
pLastRxPN = lastRxPNforQoS;
|
||||||
|
} else
|
||||||
|
pLastRxPN = pWapiSta->lastRxUnicastPN;
|
||||||
|
if (!WapiComparePN(pRecvPN, pLastRxPN))
|
||||||
|
return false;
|
||||||
|
if (bQosData)
|
||||||
|
WapiSetLastRxUnicastPNForQoSData(TID, pRecvPN, pWapiSta);
|
||||||
|
else
|
||||||
|
memcpy(pWapiSta->lastRxUnicastPN, pRecvPN, 16);
|
||||||
|
} else
|
||||||
|
memcpy(precv_hdr->WapiTempPN, pRecvPN, 16);
|
||||||
|
|
||||||
|
if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) {
|
||||||
|
if ((pRecvPN[0] & 0x1) == 0) {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Rx USK PN is not odd when Infra STA mode, Dropped !!!\n", __FUNCTION__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pMicKey = pWapiSta->wapiUsk.micKey;
|
||||||
|
pDataKey = pWapiSta->wapiUsk.dataKey;
|
||||||
|
} else if (pWapiSta->wapiUskUpdate.keyId == KeyIdx && pWapiSta->wapiUskUpdate.bSet) {
|
||||||
|
WAPI_TRACE(WAPI_RX, "%s: Use Updated USK for Decryption!!!\n", __FUNCTION__);
|
||||||
|
if (pWapiSta->bAuthenticatorInUpdata)
|
||||||
|
bUseUpdatedKey = true;
|
||||||
|
else
|
||||||
|
bUseUpdatedKey = false;
|
||||||
|
|
||||||
|
if (bQosData)
|
||||||
|
WapiSetLastRxUnicastPNForQoSData(TID, pRecvPN, pWapiSta);
|
||||||
|
else
|
||||||
|
memcpy(pWapiSta->lastRxUnicastPN, pRecvPN, 16);
|
||||||
|
pMicKey = pWapiSta->wapiUskUpdate.micKey;
|
||||||
|
pDataKey = pWapiSta->wapiUskUpdate.dataKey;
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: No valid USK!!!KeyIdx=%d pWapiSta->wapiUsk.keyId=%d pWapiSta->wapiUskUpdate.keyId=%d\n", __FUNCTION__, KeyIdx, pWapiSta->wapiUsk.keyId,
|
||||||
|
pWapiSta->wapiUskUpdate.keyId);
|
||||||
|
/* dump_buf(pskb->data,pskb->len); */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WAPI_DATA(WAPI_RX, "Decryption - DataKey", pDataKey, 16);
|
||||||
|
WAPI_DATA(WAPI_RX, "Decryption - IV", pRecvPN, 16);
|
||||||
|
WapiSMS4Decryption(pDataKey, pRecvPN, pSecData, DataLen, pSecData, &OutputLength);
|
||||||
|
|
||||||
|
if (OutputLength != DataLen)
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Output Length Error!!!!\n", __FUNCTION__);
|
||||||
|
|
||||||
|
WAPI_DATA(WAPI_RX, "Decryption - After decryption", pskb->data, pskb->len);
|
||||||
|
|
||||||
|
DataLen -= padapter->wapiInfo.extra_postfix_len;
|
||||||
|
|
||||||
|
SecCalculateMicSMS4(KeyIdx, pMicKey, pskb->data, pSecData, DataLen, MicBuffer);
|
||||||
|
|
||||||
|
WAPI_DATA(WAPI_RX, "Decryption - MIC received", pRecvMic, SMS4_MIC_LEN);
|
||||||
|
WAPI_DATA(WAPI_RX, "Decryption - MIC calculated", MicBuffer, SMS4_MIC_LEN);
|
||||||
|
|
||||||
|
if (0 == memcmp(MicBuffer, pRecvMic, padapter->wapiInfo.extra_postfix_len)) {
|
||||||
|
WAPI_TRACE(WAPI_RX, "%s: Check MIC OK!!\n", __FUNCTION__);
|
||||||
|
if (bUseUpdatedKey) {
|
||||||
|
/* delete the old key */
|
||||||
|
if (IS_MCAST(pRA)) {
|
||||||
|
WAPI_TRACE(WAPI_API, "%s(): AE use new update MSK!!\n", __FUNCTION__);
|
||||||
|
pWapiSta->wapiMsk.keyId = pWapiSta->wapiMskUpdate.keyId;
|
||||||
|
memcpy(pWapiSta->wapiMsk.dataKey, pWapiSta->wapiMskUpdate.dataKey, 16);
|
||||||
|
memcpy(pWapiSta->wapiMsk.micKey, pWapiSta->wapiMskUpdate.micKey, 16);
|
||||||
|
pWapiSta->wapiMskUpdate.bTxEnable = pWapiSta->wapiMskUpdate.bSet = false;
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_API, "%s(): AE use new update USK!!\n", __FUNCTION__);
|
||||||
|
pWapiSta->wapiUsk.keyId = pWapiSta->wapiUskUpdate.keyId;
|
||||||
|
memcpy(pWapiSta->wapiUsk.dataKey, pWapiSta->wapiUskUpdate.dataKey, 16);
|
||||||
|
memcpy(pWapiSta->wapiUsk.micKey, pWapiSta->wapiUskUpdate.micKey, 16);
|
||||||
|
pWapiSta->wapiUskUpdate.bTxEnable = pWapiSta->wapiUskUpdate.bSet = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s: Check MIC Error, Dropped !!!!\n", __FUNCTION__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = pskb->data;
|
||||||
|
memmove(pos + padapter->wapiInfo.extra_prefix_len, pos, IVOffset);
|
||||||
|
skb_pull(pskb, padapter->wapiInfo.extra_prefix_len);
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_RX, "<=========%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 rtw_sms4_encrypt(_adapter *padapter, u8 *pxmitframe)
|
||||||
|
{
|
||||||
|
|
||||||
|
u8 *pframe;
|
||||||
|
u32 res = _SUCCESS;
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_TX, "=========>%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
if ((!padapter->WapiSupport) || (!padapter->wapiInfo.bWapiEnable)) {
|
||||||
|
WAPI_TRACE(WAPI_TX, "<========== %s, WAPI not supported or enabled!\n", __FUNCTION__);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
|
||||||
|
return _FAIL;
|
||||||
|
|
||||||
|
pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET;
|
||||||
|
|
||||||
|
SecSWSMS4Encryption(padapter, pxmitframe);
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_TX, "<=========%s\n", __FUNCTION__);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 rtw_sms4_decrypt(_adapter *padapter, u8 *precvframe)
|
||||||
|
{
|
||||||
|
u8 *pframe;
|
||||||
|
u32 res = _SUCCESS;
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_RX, "=========>%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
if ((!padapter->WapiSupport) || (!padapter->wapiInfo.bWapiEnable)) {
|
||||||
|
WAPI_TRACE(WAPI_RX, "<========== %s, WAPI not supported or enabled!\n", __FUNCTION__);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* drop packet when hw decrypt fail
|
||||||
|
* return tempraily */
|
||||||
|
return _FAIL;
|
||||||
|
|
||||||
|
/* pframe=(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data; */
|
||||||
|
|
||||||
|
if (false == SecSWSMS4Decryption(padapter, precvframe, &padapter->recvpriv)) {
|
||||||
|
WAPI_TRACE(WAPI_ERR, "%s():SMS4 decrypt frame error\n", __FUNCTION__);
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WAPI_TRACE(WAPI_RX, "<=========%s\n", __FUNCTION__);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
u32 rtw_sms4_encrypt(_adapter *padapter, u8 *pxmitframe)
|
||||||
|
{
|
||||||
|
WAPI_TRACE(WAPI_TX, "=========>Dummy %s\n", __FUNCTION__);
|
||||||
|
WAPI_TRACE(WAPI_TX, "<=========Dummy %s\n", __FUNCTION__);
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 rtw_sms4_decrypt(_adapter *padapter, u8 *precvframe)
|
||||||
|
{
|
||||||
|
WAPI_TRACE(WAPI_RX, "=========>Dummy %s\n", __FUNCTION__);
|
||||||
|
WAPI_TRACE(WAPI_RX, "<=========Dummy %s\n", __FUNCTION__);
|
||||||
|
return _SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
5117
drivers/net/wireless/realtek/rtl8822ce/core/rtw_wlan_util.c
Normal file
5117
drivers/net/wireless/realtek/rtl8822ce/core/rtw_wlan_util.c
Normal file
File diff suppressed because it is too large
Load Diff
6292
drivers/net/wireless/realtek/rtl8822ce/core/rtw_xmit.c
Normal file
6292
drivers/net/wireless/realtek/rtl8822ce/core/rtw_xmit.c
Normal file
File diff suppressed because it is too large
Load Diff
185
drivers/net/wireless/realtek/rtl8822ce/hal/HalPwrSeqCmd.c
Normal file
185
drivers/net/wireless/realtek/rtl8822ce/hal/HalPwrSeqCmd.c
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*++
|
||||||
|
Copyright (c) Realtek Semiconductor Corp. All rights reserved.
|
||||||
|
|
||||||
|
Module Name:
|
||||||
|
HalPwrSeqCmd.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
Implement HW Power sequence configuration CMD handling routine for Realtek devices.
|
||||||
|
|
||||||
|
Major Change History:
|
||||||
|
When Who What
|
||||||
|
---------- --------------- -------------------------------
|
||||||
|
2011-10-26 Lucas Modify to be compatible with SD4-CE driver.
|
||||||
|
2011-07-07 Roger Create.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
#include <HalPwrSeqCmd.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description:
|
||||||
|
* This routine deal with the Power Configuration CMDs parsing for RTL8723/RTL8188E Series IC.
|
||||||
|
*
|
||||||
|
* Assumption:
|
||||||
|
* We should follow specific format which was released from HW SD.
|
||||||
|
*
|
||||||
|
* 2011.07.07, added by Roger.
|
||||||
|
* */
|
||||||
|
u8 HalPwrSeqCmdParsing(
|
||||||
|
PADAPTER padapter,
|
||||||
|
u8 CutVersion,
|
||||||
|
u8 FabVersion,
|
||||||
|
u8 InterfaceType,
|
||||||
|
WLAN_PWR_CFG PwrSeqCmd[])
|
||||||
|
{
|
||||||
|
WLAN_PWR_CFG PwrCfgCmd = {0};
|
||||||
|
u8 bPollingBit = _FALSE;
|
||||||
|
u8 bHWICSupport = _FALSE;
|
||||||
|
u32 AryIdx = 0;
|
||||||
|
u8 value = 0;
|
||||||
|
u32 offset = 0;
|
||||||
|
u8 flag = 0;
|
||||||
|
u32 pollingCount = 0; /* polling autoload done. */
|
||||||
|
u32 maxPollingCnt = 5000;
|
||||||
|
|
||||||
|
do {
|
||||||
|
PwrCfgCmd = PwrSeqCmd[AryIdx];
|
||||||
|
|
||||||
|
|
||||||
|
/* 2 Only Handle the command whose FAB, CUT, and Interface are matched */
|
||||||
|
if ((GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) &&
|
||||||
|
(GET_PWR_CFG_CUT_MASK(PwrCfgCmd) & CutVersion) &&
|
||||||
|
(GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType)) {
|
||||||
|
switch (GET_PWR_CFG_CMD(PwrCfgCmd)) {
|
||||||
|
case PWR_CMD_READ:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PWR_CMD_WRITE:
|
||||||
|
offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SDIO_HCI
|
||||||
|
/* */
|
||||||
|
/* <Roger_Notes> We should deal with interface specific address mapping for some interfaces, e.g., SDIO interface */
|
||||||
|
/* 2011.07.07. */
|
||||||
|
/* */
|
||||||
|
if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) {
|
||||||
|
/* Read Back SDIO Local value */
|
||||||
|
value = SdioLocalCmd52Read1Byte(padapter, offset);
|
||||||
|
|
||||||
|
value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd));
|
||||||
|
value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd));
|
||||||
|
|
||||||
|
/* Write Back SDIO Local value */
|
||||||
|
SdioLocalCmd52Write1Byte(padapter, offset, value);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_GSPI_HCI
|
||||||
|
if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO)
|
||||||
|
offset = SPI_LOCAL_OFFSET | offset;
|
||||||
|
#endif
|
||||||
|
/* Read the value from system register */
|
||||||
|
value = rtw_read8(padapter, offset);
|
||||||
|
|
||||||
|
value = value & (~(GET_PWR_CFG_MASK(PwrCfgCmd)));
|
||||||
|
value = value | (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd));
|
||||||
|
|
||||||
|
/* Write the value back to sytem register */
|
||||||
|
rtw_write8(padapter, offset, value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PWR_CMD_POLLING:
|
||||||
|
|
||||||
|
bPollingBit = _FALSE;
|
||||||
|
offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
|
||||||
|
|
||||||
|
rtw_hal_get_hwreg(padapter, HW_VAR_PWR_CMD, &bHWICSupport);
|
||||||
|
if (bHWICSupport && offset == 0x06) {
|
||||||
|
flag = 0;
|
||||||
|
maxPollingCnt = 100000;
|
||||||
|
} else
|
||||||
|
maxPollingCnt = 5000;
|
||||||
|
|
||||||
|
#ifdef CONFIG_GSPI_HCI
|
||||||
|
if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO)
|
||||||
|
offset = SPI_LOCAL_OFFSET | offset;
|
||||||
|
#endif
|
||||||
|
do {
|
||||||
|
#ifdef CONFIG_SDIO_HCI
|
||||||
|
if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO)
|
||||||
|
value = SdioLocalCmd52Read1Byte(padapter, offset);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
value = rtw_read8(padapter, offset);
|
||||||
|
|
||||||
|
value = value & GET_PWR_CFG_MASK(PwrCfgCmd);
|
||||||
|
if (value == (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd)))
|
||||||
|
bPollingBit = _TRUE;
|
||||||
|
else
|
||||||
|
rtw_udelay_os(10);
|
||||||
|
|
||||||
|
if (pollingCount++ > maxPollingCnt) {
|
||||||
|
RTW_ERR("HalPwrSeqCmdParsing: Fail to polling Offset[%#x]=%02x\n", offset, value);
|
||||||
|
|
||||||
|
/* For PCIE + USB package poll power bit timeout issue only modify 8821AE and 8723BE */
|
||||||
|
if (bHWICSupport && offset == 0x06 && flag == 0) {
|
||||||
|
|
||||||
|
RTW_ERR("[WARNING] PCIE polling(0x%X) timeout(%d), Toggle 0x04[3] and try again.\n", offset, maxPollingCnt);
|
||||||
|
if (IS_HARDWARE_TYPE_8723DE(padapter))
|
||||||
|
PlatformEFIOWrite1Byte(padapter, 0x40, (PlatformEFIORead1Byte(padapter, 0x40)) & (~BIT3));
|
||||||
|
|
||||||
|
PlatformEFIOWrite1Byte(padapter, 0x04, PlatformEFIORead1Byte(padapter, 0x04) | BIT3);
|
||||||
|
PlatformEFIOWrite1Byte(padapter, 0x04, PlatformEFIORead1Byte(padapter, 0x04) & ~BIT3);
|
||||||
|
|
||||||
|
if (IS_HARDWARE_TYPE_8723DE(padapter))
|
||||||
|
PlatformEFIOWrite1Byte(padapter, 0x40, PlatformEFIORead1Byte(padapter, 0x40)|BIT3);
|
||||||
|
|
||||||
|
/* Retry Polling Process one more time */
|
||||||
|
pollingCount = 0;
|
||||||
|
flag = 1;
|
||||||
|
} else {
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (!bPollingBit);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PWR_CMD_DELAY:
|
||||||
|
if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US)
|
||||||
|
rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd));
|
||||||
|
else
|
||||||
|
rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd) * 1000);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PWR_CMD_END:
|
||||||
|
/* When this command is parsed, end the process */
|
||||||
|
return _TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AryIdx++;/* Add Array Index */
|
||||||
|
} while (1);
|
||||||
|
|
||||||
|
return _TRUE;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __BTC_BASIC_TYPES_H__
|
||||||
|
#define __BTC_BASIC_TYPES_H__
|
||||||
|
|
||||||
|
#define IN
|
||||||
|
#define OUT
|
||||||
|
#define VOID void
|
||||||
|
typedef void *PVOID;
|
||||||
|
|
||||||
|
#define u1Byte u8
|
||||||
|
#define pu1Byte u8*
|
||||||
|
|
||||||
|
#define u2Byte u16
|
||||||
|
#define pu2Byte u16*
|
||||||
|
|
||||||
|
#define u4Byte u32
|
||||||
|
#define pu4Byte u32*
|
||||||
|
|
||||||
|
#define u8Byte u64
|
||||||
|
#define pu8Byte u64*
|
||||||
|
|
||||||
|
#define s1Byte s8
|
||||||
|
#define ps1Byte s8*
|
||||||
|
|
||||||
|
#define s2Byte s16
|
||||||
|
#define ps2Byte s16*
|
||||||
|
|
||||||
|
#define s4Byte s32
|
||||||
|
#define ps4Byte s32*
|
||||||
|
|
||||||
|
#define s8Byte s64
|
||||||
|
#define ps8Byte s64*
|
||||||
|
|
||||||
|
#define UCHAR u8
|
||||||
|
#define USHORT u16
|
||||||
|
#define UINT u32
|
||||||
|
#define ULONG u32
|
||||||
|
#define PULONG u32*
|
||||||
|
|
||||||
|
#endif /* __BTC_BASIC_TYPES_H__ */
|
||||||
556
drivers/net/wireless/realtek/rtl8822ce/hal/btc/halbtc8822c.c
Normal file
556
drivers/net/wireless/realtek/rtl8822ce/hal/btc/halbtc8822c.c
Normal file
@@ -0,0 +1,556 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "mp_precomp.h"
|
||||||
|
|
||||||
|
#if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
|
||||||
|
|
||||||
|
static u8 *trace_buf = &gl_btc_trace_buf[0];
|
||||||
|
|
||||||
|
static const u32 bt_desired_ver_8822c = 0x17;
|
||||||
|
|
||||||
|
/* rssi express in percentage % (dbm = % - 100) */
|
||||||
|
static const u8 wl_rssi_step_8822c[] = {60, 50, 44, 30};
|
||||||
|
static const u8 bt_rssi_step_8822c[] = {8, 15, 20, 25};
|
||||||
|
|
||||||
|
/* Shared-Antenna Coex Table */
|
||||||
|
static const struct btc_coex_table_para table_sant_8822c[] = {
|
||||||
|
{0xffffffff, 0xffffffff}, /*case-0*/
|
||||||
|
{0x55555555, 0x55555555},
|
||||||
|
{0x66555555, 0x66555555},
|
||||||
|
{0xaaaaaaaa, 0xaaaaaaaa},
|
||||||
|
{0x5a5a5a5a, 0x5a5a5a5a},
|
||||||
|
{0xfafafafa, 0xfafafafa}, /*case-5*/
|
||||||
|
{0x6a5a5555, 0xaaaaaaaa},
|
||||||
|
{0x6a5a56aa, 0x6a5a56aa},
|
||||||
|
{0x6a5a5a5a, 0x6a5a5a5a},
|
||||||
|
{0x66555555, 0x5a5a5a5a},
|
||||||
|
{0x66555555, 0x6a5a5a5a}, /*case-10*/
|
||||||
|
{0x66555555, 0x6a5a5aaa},
|
||||||
|
{0x66555555, 0x5a5a5aaa},
|
||||||
|
{0x66555555, 0x6aaa5aaa},
|
||||||
|
{0x66555555, 0xaaaa5aaa},
|
||||||
|
{0x66555555, 0xaaaaaaaa}, /*case-15*/
|
||||||
|
{0xffff55ff, 0xfafafafa},
|
||||||
|
{0xffff55ff, 0x6afa5afa},
|
||||||
|
{0xaaffffaa, 0xfafafafa},
|
||||||
|
{0xaa5555aa, 0x5a5a5a5a},
|
||||||
|
{0xaa5555aa, 0x6a5a5a5a}, /*case-20*/
|
||||||
|
{0xaa5555aa, 0xaaaaaaaa},
|
||||||
|
{0xffffffff, 0x5a5a5a5a},
|
||||||
|
{0xffffffff, 0x5a5a5a5a},
|
||||||
|
{0xffffffff, 0x55555555},
|
||||||
|
{0xffffffff, 0x5a5a5aaa}, /*case-25*/
|
||||||
|
{0x55555555, 0x5a5a5a5a},
|
||||||
|
{0x55555555, 0xaaaaaaaa},
|
||||||
|
{0x55555555, 0x6a5a6a5a},
|
||||||
|
{0x66556655, 0x66556655},
|
||||||
|
{0x66556aaa, 0x6a5a6aaa}, /*case-30*/
|
||||||
|
{0xffffffff, 0x5aaa5aaa},
|
||||||
|
{0x56555555, 0x5a5a5aaa},
|
||||||
|
{0xdaffdaff, 0xdaffdaff} };
|
||||||
|
|
||||||
|
/* Non-Shared-Antenna Coex Table */
|
||||||
|
static const struct btc_coex_table_para table_nsant_8822c[] = {
|
||||||
|
{0xffffffff, 0xffffffff}, /*case-100*/
|
||||||
|
{0x55555555, 0x55555555},
|
||||||
|
{0x66555555, 0x66555555},
|
||||||
|
{0xaaaaaaaa, 0xaaaaaaaa},
|
||||||
|
{0x5a5a5a5a, 0x5a5a5a5a},
|
||||||
|
{0xfafafafa, 0xfafafafa}, /*case-105*/
|
||||||
|
{0x5afa5afa, 0x5afa5afa},
|
||||||
|
{0x55555555, 0xfafafafa},
|
||||||
|
{0x66555555, 0xfafafafa},
|
||||||
|
{0x66555555, 0x5a5a5a5a},
|
||||||
|
{0x66555555, 0x6a5a5a5a}, /*case-110*/
|
||||||
|
{0x66555555, 0xaaaaaaaa},
|
||||||
|
{0xffff55ff, 0xfafafafa},
|
||||||
|
{0xffff55ff, 0x5afa5afa},
|
||||||
|
{0xffff55ff, 0xaaaaaaaa},
|
||||||
|
{0xffff55ff, 0xffff55ff}, /*case-115*/
|
||||||
|
{0xaaffffaa, 0x5afa5afa},
|
||||||
|
{0xaaffffaa, 0xaaaaaaaa},
|
||||||
|
{0xffffffff, 0xfafafafa},
|
||||||
|
{0xffffffff, 0x5afa5afa},
|
||||||
|
{0xffffffff, 0xaaaaaaaa},/*case-120*/
|
||||||
|
{0x55ff55ff, 0x5afa5afa},
|
||||||
|
{0x55ff55ff, 0xaaaaaaaa},
|
||||||
|
{0x55ff55ff, 0x55ff55ff} };
|
||||||
|
|
||||||
|
/* Shared-Antenna TDMA*/
|
||||||
|
static const struct btc_tdma_para tdma_sant_8822c[] = {
|
||||||
|
{ {0x00, 0x00, 0x00, 0x00, 0x00} }, /*case-0*/
|
||||||
|
{ {0x61, 0x45, 0x03, 0x11, 0x11} }, /*case-1*/
|
||||||
|
{ {0x61, 0x3a, 0x03, 0x11, 0x11} },
|
||||||
|
{ {0x61, 0x30, 0x03, 0x11, 0x11} },
|
||||||
|
{ {0x61, 0x20, 0x03, 0x11, 0x11} },
|
||||||
|
{ {0x61, 0x10, 0x03, 0x11, 0x11} }, /*case-5*/
|
||||||
|
{ {0x61, 0x45, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x61, 0x3a, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x61, 0x30, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x61, 0x20, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x61, 0x10, 0x03, 0x11, 0x10} }, /*case-10*/
|
||||||
|
{ {0x61, 0x08, 0x03, 0x11, 0x14} },
|
||||||
|
{ {0x61, 0x08, 0x03, 0x10, 0x14} },
|
||||||
|
{ {0x51, 0x08, 0x03, 0x10, 0x54} },
|
||||||
|
{ {0x51, 0x08, 0x03, 0x10, 0x55} },
|
||||||
|
{ {0x51, 0x08, 0x07, 0x10, 0x54} }, /*case-15*/
|
||||||
|
{ {0x51, 0x45, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x3a, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x30, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x20, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x10, 0x03, 0x10, 0x50} }, /*case-20*/
|
||||||
|
{ {0x51, 0x4a, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x0c, 0x03, 0x10, 0x54} },
|
||||||
|
{ {0x55, 0x08, 0x03, 0x10, 0x54} },
|
||||||
|
{ {0x65, 0x10, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x51, 0x10, 0x03, 0x10, 0x51} }, /*case-25*/
|
||||||
|
{ {0x51, 0x08, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x61, 0x08, 0x03, 0x11, 0x11} } };
|
||||||
|
|
||||||
|
|
||||||
|
/* Non-Shared-Antenna TDMA*/
|
||||||
|
static const struct btc_tdma_para tdma_nsant_8822c[] = {
|
||||||
|
{ {0x00, 0x00, 0x00, 0x00, 0x00} }, /*case-100*/
|
||||||
|
{ {0x61, 0x45, 0x03, 0x11, 0x11} }, /*case-101*/
|
||||||
|
{ {0x61, 0x3a, 0x03, 0x11, 0x11} },
|
||||||
|
{ {0x61, 0x30, 0x03, 0x11, 0x11} },
|
||||||
|
{ {0x61, 0x20, 0x03, 0x11, 0x11} },
|
||||||
|
{ {0x61, 0x10, 0x03, 0x11, 0x11} }, /*case-105*/
|
||||||
|
{ {0x61, 0x45, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x61, 0x3a, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x61, 0x30, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x61, 0x20, 0x03, 0x11, 0x10} },
|
||||||
|
{ {0x61, 0x10, 0x03, 0x11, 0x10} }, /*case-110*/
|
||||||
|
{ {0x61, 0x08, 0x03, 0x11, 0x14} },
|
||||||
|
{ {0x61, 0x08, 0x03, 0x10, 0x14} },
|
||||||
|
{ {0x51, 0x08, 0x03, 0x10, 0x54} },
|
||||||
|
{ {0x51, 0x08, 0x03, 0x10, 0x55} },
|
||||||
|
{ {0x51, 0x08, 0x07, 0x10, 0x54} }, /*case-115*/
|
||||||
|
{ {0x51, 0x45, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x3a, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x30, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x20, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x51, 0x10, 0x03, 0x10, 0x50} }, /*case-120*/
|
||||||
|
{ {0x51, 0x08, 0x03, 0x10, 0x50} },
|
||||||
|
{ {0x61, 0x30, 0x03, 0x10, 0x11} },
|
||||||
|
{ {0x61, 0x08, 0x03, 0x10, 0x11} },
|
||||||
|
{ {0x61, 0x08, 0x07, 0x10, 0x14} },
|
||||||
|
{ {0x61, 0x08, 0x03, 0x10, 0x10} } }; /*case-125*/
|
||||||
|
|
||||||
|
/* wl_tx_dec_power, bt_tx_dec_power, wl_rx_gain, bt_rx_lna_constrain */
|
||||||
|
static const struct btc_rf_para rf_para_tx_8822c[] = {
|
||||||
|
{0, 0, FALSE, 7}, /* for normal */
|
||||||
|
{0, 16, FALSE, 7}, /* for WL-CPT */
|
||||||
|
{16, 4, TRUE, 4},
|
||||||
|
{15, 5, TRUE, 4},
|
||||||
|
{7, 8, TRUE, 4},
|
||||||
|
{6, 10, TRUE, 4} };
|
||||||
|
|
||||||
|
static const struct btc_rf_para rf_para_rx_8822c[] = {
|
||||||
|
{0, 0, FALSE, 7}, /* for normal */
|
||||||
|
{0, 16, FALSE, 7}, /* for WL-CPT */
|
||||||
|
{14, 5, TRUE, 5},
|
||||||
|
{13, 6, TRUE, 5},
|
||||||
|
{6, 9, TRUE, 5},
|
||||||
|
{4, 11, TRUE, 5} };
|
||||||
|
|
||||||
|
const struct btc_5g_afh_map afh_5g_8822c[] = { {0, 0, 0} };
|
||||||
|
|
||||||
|
const struct btc_chip_para btc_chip_para_8822c = {
|
||||||
|
"8822c", /*.chip_name */
|
||||||
|
20200103, /*.para_ver_date */
|
||||||
|
0x17, /*.para_ver */
|
||||||
|
0x17, /* bt_desired_ver */
|
||||||
|
TRUE, /* scbd_support */
|
||||||
|
TRUE, /* mailbox_support*/
|
||||||
|
TRUE, /* lte_indirect_access */
|
||||||
|
TRUE, /* new_scbd10_def */
|
||||||
|
BTC_INDIRECT_1700, /* indirect_type */
|
||||||
|
BTC_PSTDMA_FORCE_LPSOFF, /* pstdma_type */
|
||||||
|
BTC_BTRSSI_DBM, /* bt_rssi_type */
|
||||||
|
15, /*.ant_isolation */
|
||||||
|
2, /*.rssi_tolerance */
|
||||||
|
2, /* rx_path_num */
|
||||||
|
ARRAY_SIZE(wl_rssi_step_8822c), /*.wl_rssi_step_num */
|
||||||
|
wl_rssi_step_8822c, /*.wl_rssi_step */
|
||||||
|
ARRAY_SIZE(bt_rssi_step_8822c), /*.bt_rssi_step_num */
|
||||||
|
bt_rssi_step_8822c, /*.bt_rssi_step */
|
||||||
|
ARRAY_SIZE(table_sant_8822c), /*.table_sant_num */
|
||||||
|
table_sant_8822c, /*.table_sant = */
|
||||||
|
ARRAY_SIZE(table_nsant_8822c), /*.table_nsant_num */
|
||||||
|
table_nsant_8822c, /*.table_nsant = */
|
||||||
|
ARRAY_SIZE(tdma_sant_8822c), /*.tdma_sant_num */
|
||||||
|
tdma_sant_8822c, /*.tdma_sant = */
|
||||||
|
ARRAY_SIZE(tdma_nsant_8822c), /*.tdma_nsant_num */
|
||||||
|
tdma_nsant_8822c, /*.tdma_nsant */
|
||||||
|
ARRAY_SIZE(rf_para_tx_8822c), /* wl_rf_para_tx_num */
|
||||||
|
rf_para_tx_8822c, /* wl_rf_para_tx */
|
||||||
|
rf_para_rx_8822c, /* wl_rf_para_rx */
|
||||||
|
0x24, /*.bt_afh_span_bw20 */
|
||||||
|
0x36, /*.bt_afh_span_bw40 */
|
||||||
|
ARRAY_SIZE(afh_5g_8822c), /*.afh_5g_num */
|
||||||
|
afh_5g_8822c, /*.afh_5g */
|
||||||
|
halbtc8822c_chip_setup /* chip_setup function */
|
||||||
|
};
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_init(struct btc_coexist *btc)
|
||||||
|
{
|
||||||
|
u8 u8tmp = 0;
|
||||||
|
|
||||||
|
/* enable TBTT nterrupt */
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x550, 0x8, 0x1);
|
||||||
|
|
||||||
|
/* BT report packet sample rate */
|
||||||
|
/* 0x790[5:0]=0x5 */
|
||||||
|
btc->btc_write_1byte(btc, 0x790, 0x5);
|
||||||
|
|
||||||
|
/* Enable BT counter statistics */
|
||||||
|
btc->btc_write_1byte(btc, 0x778, 0x1);
|
||||||
|
|
||||||
|
/* Enable PTA (3-wire function form BT side) */
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x40, 0x20, 0x1);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x41, 0x02, 0x1);
|
||||||
|
|
||||||
|
/* Enable PTA (tx/rx signal form WiFi side) */
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x4c6, BIT(4), 0x1);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x4c6, BIT(5), 0x0);
|
||||||
|
/*GNT_BT=1 while select both */
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x763, BIT(4), 0x1);
|
||||||
|
|
||||||
|
/* BT_CCA = ~GNT_WL_BB, (not or GNT_BT_BB, LTE_Rx */
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x4fc, 0x3, 0x0);
|
||||||
|
|
||||||
|
/* To avoid RF parameter error */
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_B, 0x1, 0xfffff, 0x40000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_ant_switch(struct btc_coexist *btc)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_gnt_fix(struct btc_coexist *btc)
|
||||||
|
{
|
||||||
|
struct btc_coex_sta *coex_sta = &btc->coex_sta;
|
||||||
|
struct btc_wifi_link_info_ext *link_info_ext = &btc->wifi_link_info_ext;
|
||||||
|
u32 val = 0x40000;
|
||||||
|
|
||||||
|
/* Because WL-S1 5G RF TRX mask affect by GNT_BT
|
||||||
|
* Set debug mode on: GNT_BT=0, GNT_WL=1, BT at BTG
|
||||||
|
*/
|
||||||
|
if (coex_sta->kt_ver == 0 &&
|
||||||
|
coex_sta->wl_coex_mode == BTC_WLINK_5G)
|
||||||
|
val = 0x40021;
|
||||||
|
else if (coex_sta->coex_freerun) /* WL S1 force to GNT_WL=1, GNT_BT=0 */
|
||||||
|
val = 0x40021;
|
||||||
|
else
|
||||||
|
val = 0x40000;
|
||||||
|
|
||||||
|
if (btc->board_info.btdm_ant_num == 1) /* BT at S1 for 2-Ant */
|
||||||
|
val = val | BIT(13);
|
||||||
|
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_B, 0x1, 0xfffff, val);
|
||||||
|
|
||||||
|
/* Because WL-S0 2G RF TRX can't masked by GNT_BT
|
||||||
|
* enable "WLS0 BB chage RF mode if GNT_BT = 1" for shared-antenna type
|
||||||
|
* disable:0x1860[3] = 1, enable:0x1860[3] = 0
|
||||||
|
*
|
||||||
|
* enable "AFE DAC off if GNT_WL = 0"
|
||||||
|
* disable 0x1c30[22] = 0,
|
||||||
|
* enable: 0x1c30[22] = 1, 0x1c38[12] = 0, 0x1c38[28] = 1
|
||||||
|
*/
|
||||||
|
if (coex_sta->wl_coex_mode == BTC_WLINK_2GFREE) {
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1c32, BIT(6), 0);
|
||||||
|
} else {
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1c32, BIT(6), 1);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1c39, BIT(4), 0);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1c3b, BIT(4), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* disable WLS1 BB chage RF mode if GNT_BT
|
||||||
|
* since RF TRx mask can do it
|
||||||
|
*/
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x4160, BIT(3), 1);
|
||||||
|
|
||||||
|
/* for kt_ver >= 3: 0x1860[3] = 0
|
||||||
|
* always set "WLS0 BB chage RF mode if GNT_WL = 0"
|
||||||
|
* But the BB DAC will be turned off by GNT_BT = 1
|
||||||
|
* 0x1ca7[3] = 1, "don't off BB DAC if GNT_BT = 1"
|
||||||
|
*/
|
||||||
|
if (coex_sta->wl_coex_mode == BTC_WLINK_2GFREE) {
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1860, BIT(3), 1);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1ca7, BIT(3), 1);
|
||||||
|
} else if (coex_sta->wl_coex_mode == BTC_WLINK_5G ||
|
||||||
|
link_info_ext->is_all_under_5g) {
|
||||||
|
if (coex_sta->kt_ver >= 3) {
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1860, BIT(3), 0);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1ca7, BIT(3), 1);
|
||||||
|
} else {
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1860, BIT(3), 1);
|
||||||
|
}
|
||||||
|
} else if (btc->board_info.btdm_ant_num == 2 ||
|
||||||
|
coex_sta->wl_coex_mode == BTC_WLINK_25GMPORT) {
|
||||||
|
/* non-shared-antenna or MCC-2band */
|
||||||
|
if (coex_sta->kt_ver >= 3) {
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1860, BIT(3), 0);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1ca7, BIT(3), 1);
|
||||||
|
} else {
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1860, BIT(3), 1);
|
||||||
|
}
|
||||||
|
} else { /* shared-antenna */
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1860, BIT(3), 0);
|
||||||
|
if (coex_sta->kt_ver >= 3)
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x1ca7, BIT(3), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_gnt_debug(struct btc_coexist *btc)
|
||||||
|
{
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x66, BIT(4), 0);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x67, BIT(0), 0);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x42, BIT(3), 0);
|
||||||
|
btc->btc_write_1byte_bitmask(btc, 0x65, BIT(7), 0);
|
||||||
|
/* btc->btc_write_1byte_bitmask(btc, 0x73, BIT(3), 0); */
|
||||||
|
}
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_rfe_type(struct btc_coexist *btc)
|
||||||
|
{
|
||||||
|
struct btc_coex_sta *coex_sta = &btc->coex_sta;
|
||||||
|
struct btc_rfe_type *rfe_type = &btc->rfe_type;
|
||||||
|
struct btc_board_info *board_info = &btc->board_info;
|
||||||
|
|
||||||
|
rfe_type->rfe_module_type = board_info->rfe_type;
|
||||||
|
rfe_type->ant_switch_polarity = 0;
|
||||||
|
rfe_type->ant_switch_exist = FALSE;
|
||||||
|
rfe_type->ant_switch_with_bt = FALSE;
|
||||||
|
rfe_type->ant_switch_type = BTC_SWITCH_NONE;
|
||||||
|
rfe_type->ant_switch_diversity = FALSE;
|
||||||
|
|
||||||
|
rfe_type->band_switch_exist = FALSE;
|
||||||
|
rfe_type->band_switch_type = 0;
|
||||||
|
rfe_type->band_switch_polarity = 0;
|
||||||
|
|
||||||
|
if (btc->board_info.btdm_ant_num == 1)
|
||||||
|
rfe_type->wlg_at_btg = TRUE;
|
||||||
|
else
|
||||||
|
rfe_type->wlg_at_btg = FALSE;
|
||||||
|
|
||||||
|
coex_sta->rf4ce_en = FALSE;
|
||||||
|
|
||||||
|
/* Disable LTE Coex Function in WiFi side */
|
||||||
|
btc->btc_write_linderct(btc, 0x38, BIT(7), 0);
|
||||||
|
|
||||||
|
/* BTC_CTT_WL_VS_LTE */
|
||||||
|
btc->btc_write_linderct(btc, 0xa0, 0xffff, 0xffff);
|
||||||
|
|
||||||
|
/* BTC_CTT_BT_VS_LTE */
|
||||||
|
btc->btc_write_linderct(btc, 0xa4, 0xffff, 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_coexinfo_hw(struct btc_coexist *btc)
|
||||||
|
{
|
||||||
|
u8 *cli_buf = btc->cli_buf, u8tmp[4];
|
||||||
|
u16 u16tmp[4];
|
||||||
|
u32 u32tmp[4];
|
||||||
|
boolean lte_coex_on = FALSE;
|
||||||
|
|
||||||
|
u32tmp[0] = btc->btc_read_linderct(btc, 0x38);
|
||||||
|
u32tmp[1] = btc->btc_read_linderct(btc, 0x54);
|
||||||
|
u8tmp[0] = btc->btc_read_1byte(btc, 0x73);
|
||||||
|
lte_coex_on = ((u32tmp[0] & BIT(7)) >> 7) ? TRUE : FALSE;
|
||||||
|
|
||||||
|
CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s",
|
||||||
|
"LTE Coex/Path Owner", ((lte_coex_on) ? "On" : "Off"),
|
||||||
|
((u8tmp[0] & BIT(2)) ? "WL" : "BT"));
|
||||||
|
CL_PRINTF(cli_buf);
|
||||||
|
|
||||||
|
CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
|
||||||
|
"\r\n %-35s = RF:%s_BB:%s/ RF:%s_BB:%s/ %s",
|
||||||
|
"GNT_WL_Ctrl/GNT_BT_Ctrl/Dbg",
|
||||||
|
((u32tmp[0] & BIT(12)) ? "SW" : "HW"),
|
||||||
|
((u32tmp[0] & BIT(8)) ? "SW" : "HW"),
|
||||||
|
((u32tmp[0] & BIT(14)) ? "SW" : "HW"),
|
||||||
|
((u32tmp[0] & BIT(10)) ? "SW" : "HW"),
|
||||||
|
((u8tmp[0] & BIT(3)) ? "On" : "Off"));
|
||||||
|
CL_PRINTF(cli_buf);
|
||||||
|
|
||||||
|
CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
|
||||||
|
"GNT_WL/GNT_BT", (int)((u32tmp[1] & BIT(2)) >> 2),
|
||||||
|
(int)((u32tmp[1] & BIT(3)) >> 3));
|
||||||
|
CL_PRINTF(cli_buf);
|
||||||
|
|
||||||
|
u32tmp[0] = btc->btc_read_4byte(btc, 0x1c38);
|
||||||
|
u8tmp[0] = btc->btc_read_1byte(btc, 0x1860);
|
||||||
|
u8tmp[1] = btc->btc_read_1byte(btc, 0x4160);
|
||||||
|
u8tmp[2] = btc->btc_read_1byte(btc, 0x1c32);
|
||||||
|
CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
|
||||||
|
"\r\n %-35s = %d/ %d/ %d/ %d",
|
||||||
|
"1860[3]/4160[3]/1c30[22]/1c38[28]",
|
||||||
|
(int)((u8tmp[0] & BIT(3)) >> 3),
|
||||||
|
(int)((u8tmp[1] & BIT(3)) >> 3),
|
||||||
|
(int)((u8tmp[2] & BIT(6)) >> 6),
|
||||||
|
(int)((u32tmp[0] & BIT(28)) >> 28));
|
||||||
|
CL_PRINTF(cli_buf);
|
||||||
|
|
||||||
|
u32tmp[0] = btc->btc_read_4byte(btc, 0x430);
|
||||||
|
u32tmp[1] = btc->btc_read_4byte(btc, 0x434);
|
||||||
|
u16tmp[0] = btc->btc_read_2byte(btc, 0x42a);
|
||||||
|
u16tmp[1] = btc->btc_read_1byte(btc, 0x454);
|
||||||
|
u8tmp[0] = btc->btc_read_1byte(btc, 0x426);
|
||||||
|
u8tmp[1] = btc->btc_read_1byte(btc, 0x45e);
|
||||||
|
CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
|
||||||
|
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x/ 0x%x/ 0x%x",
|
||||||
|
"430/434/42a/426/45e[3]/454",
|
||||||
|
u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0],
|
||||||
|
(int)((u8tmp[1] & BIT(3)) >> 3), u16tmp[1]);
|
||||||
|
CL_PRINTF(cli_buf);
|
||||||
|
|
||||||
|
u32tmp[0] = btc->btc_read_4byte(btc, 0x4c);
|
||||||
|
u8tmp[2] = btc->btc_read_1byte(btc, 0x64);
|
||||||
|
u8tmp[0] = btc->btc_read_1byte(btc, 0x4c6);
|
||||||
|
u8tmp[1] = btc->btc_read_1byte(btc, 0x40);
|
||||||
|
|
||||||
|
CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
|
||||||
|
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x/ 0x%x",
|
||||||
|
"4c[24:23]/64[0]/4c6[4]/40[5]/RF_0x1",
|
||||||
|
(int)(u32tmp[0] & (BIT(24) | BIT(23))) >> 23, u8tmp[2] & 0x1,
|
||||||
|
(int)((u8tmp[0] & BIT(4)) >> 4),
|
||||||
|
(int)((u8tmp[1] & BIT(5)) >> 5),
|
||||||
|
(int)(btc->btc_get_rf_reg(btc, BTC_RF_B, 0x1, 0xfffff)));
|
||||||
|
CL_PRINTF(cli_buf);
|
||||||
|
|
||||||
|
u32tmp[0] = btc->btc_read_4byte(btc, 0x550);
|
||||||
|
u8tmp[0] = btc->btc_read_1byte(btc, 0x522);
|
||||||
|
u8tmp[1] = btc->btc_read_1byte(btc, 0x953);
|
||||||
|
u8tmp[2] = btc->btc_read_1byte(btc, 0xc50);
|
||||||
|
|
||||||
|
CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
|
||||||
|
"\r\n %-35s = 0x%x/ 0x%x/ %s/ 0x%x",
|
||||||
|
"550/522/4-RxAGC/c50", u32tmp[0], u8tmp[0],
|
||||||
|
(u8tmp[1] & 0x2) ? "On" : "Off", u8tmp[2]);
|
||||||
|
CL_PRINTF(cli_buf);
|
||||||
|
|
||||||
|
u8tmp[0] = btc->btc_read_1byte(btc, 0xf8e);
|
||||||
|
u8tmp[1] = btc->btc_read_1byte(btc, 0xf8f);
|
||||||
|
u8tmp[2] = btc->btc_read_1byte(btc, 0xd14);
|
||||||
|
u8tmp[3] = btc->btc_read_1byte(btc, 0xd54);
|
||||||
|
|
||||||
|
CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
|
||||||
|
"EVM_A/ EVM_B/ SNR_A/ SNR_B",
|
||||||
|
(u8tmp[0] > 127 ? u8tmp[0] - 256 : u8tmp[0]),
|
||||||
|
(u8tmp[1] > 127 ? u8tmp[1] - 256 : u8tmp[1]),
|
||||||
|
(u8tmp[2] > 127 ? u8tmp[2] - 256 : u8tmp[2]),
|
||||||
|
(u8tmp[3] > 127 ? u8tmp[3] - 256 : u8tmp[3]));
|
||||||
|
CL_PRINTF(cli_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_wl_tx_power(struct btc_coexist *btc)
|
||||||
|
{
|
||||||
|
struct btc_coex_dm *coex_dm = &btc->coex_dm;
|
||||||
|
|
||||||
|
btc->btc_reduce_wl_tx_power(btc, coex_dm->cur_wl_pwr_lvl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_wl_rx_gain(struct btc_coexist *btc)
|
||||||
|
{
|
||||||
|
struct btc_coex_dm *coex_dm = &btc->coex_dm;
|
||||||
|
struct btc_wifi_link_info_ext *link_info_ext = &btc->wifi_link_info_ext;
|
||||||
|
u8 i;
|
||||||
|
|
||||||
|
/* WL Rx Low gain on */
|
||||||
|
static const u32 wl_rx_gain_on_HT20[] = {0x00000000};
|
||||||
|
static const u32 wl_rx_gain_on_HT40[] = {0x00000000};
|
||||||
|
|
||||||
|
/* WL Rx Low gain off */
|
||||||
|
static const u32 wl_rx_gain_off_HT20[] = {0x00000000};
|
||||||
|
static const u32 wl_rx_gain_off_HT40[] = {0x00000000};
|
||||||
|
|
||||||
|
u32 *wl_rx_gain_on, *wl_rx_gain_off;
|
||||||
|
|
||||||
|
if (coex_dm->cur_wl_rx_low_gain_en) {
|
||||||
|
BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
|
||||||
|
"[BTCoex], Hi-Li Table On!\n");
|
||||||
|
BTC_TRACE(trace_buf);
|
||||||
|
#if 0
|
||||||
|
if (link_info_ext->wifi_bw == BTC_WIFI_BW_HT40)
|
||||||
|
wl_rx_gain_on = wl_rx_gain_on_HT40;
|
||||||
|
else
|
||||||
|
wl_rx_gain_on = wl_rx_gain_on_HT20;
|
||||||
|
for (i = 0; i < ARRAY_SIZE(wl_rx_gain_on); i++)
|
||||||
|
btc->btc_write_4byte(btc, 0x1d90, wl_rx_gain_on[i]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* set Rx filter corner RCK offset */
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_A, 0xde, 0xfffff, 0x22);
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_A, 0x1d, 0xfffff, 0x36);
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_B, 0xde, 0xfffff, 0x22);
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_B, 0x1d, 0xfffff, 0x36);
|
||||||
|
} else {
|
||||||
|
BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
|
||||||
|
"[BTCoex], Hi-Li Table Off!\n");
|
||||||
|
BTC_TRACE(trace_buf);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (link_info_ext->wifi_bw == BTC_WIFI_BW_HT40)
|
||||||
|
wl_rx_gain_off = wl_rx_gain_off_HT40;
|
||||||
|
else
|
||||||
|
wl_rx_gain_off = wl_rx_gain_off_HT20;
|
||||||
|
for (i = 0; i < ARRAY_SIZE(wl_rx_gain_off); i++)
|
||||||
|
btc->btc_write_4byte(btc, 0x1d90, wl_rx_gain_off[i]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* set Rx filter corner RCK offset */
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_A, 0xde, 0xfffff, 0x20);
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_A, 0x1d, 0xfffff, 0x0);
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_B, 0xde, 0xfffff, 0x20);
|
||||||
|
btc->btc_set_rf_reg(btc, BTC_RF_B, 0x1d, 0xfffff, 0x0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void halbtc8822c_cfg_wlan_act_ips(struct btc_coexist *btc)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void halbtc8822c_chip_setup(struct btc_coexist *btc, u8 type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case BTC_CSETUP_INIT_HW:
|
||||||
|
halbtc8822c_cfg_init(btc);
|
||||||
|
break;
|
||||||
|
case BTC_CSETUP_ANT_SWITCH:
|
||||||
|
halbtc8822c_cfg_ant_switch(btc);
|
||||||
|
break;
|
||||||
|
case BTC_CSETUP_GNT_FIX:
|
||||||
|
halbtc8822c_cfg_gnt_fix(btc);
|
||||||
|
break;
|
||||||
|
case BTC_CSETUP_GNT_DEBUG:
|
||||||
|
halbtc8822c_cfg_gnt_debug(btc);
|
||||||
|
break;
|
||||||
|
case BTC_CSETUP_RFE_TYPE:
|
||||||
|
halbtc8822c_cfg_rfe_type(btc);
|
||||||
|
break;
|
||||||
|
case BTC_CSETUP_COEXINFO_HW:
|
||||||
|
halbtc8822c_cfg_coexinfo_hw(btc);
|
||||||
|
break;
|
||||||
|
case BTC_CSETUP_WL_TX_POWER:
|
||||||
|
halbtc8822c_cfg_wl_tx_power(btc);
|
||||||
|
break;
|
||||||
|
case BTC_CSETUP_WL_RX_GAIN:
|
||||||
|
halbtc8822c_cfg_wl_rx_gain(btc);
|
||||||
|
break;
|
||||||
|
case BTC_CSETUP_WLAN_ACT_IPS:
|
||||||
|
halbtc8822c_cfg_wlan_act_ips(btc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
27
drivers/net/wireless/realtek/rtl8822ce/hal/btc/halbtc8822c.h
Normal file
27
drivers/net/wireless/realtek/rtl8822ce/hal/btc/halbtc8822c.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
extern const struct btc_chip_para btc_chip_para_8822c;
|
||||||
|
void halbtc8822c_chip_setup(struct btc_coexist *btc, u8 type);
|
||||||
|
void halbtc8822c_cfg_init(struct btc_coexist *btc);
|
||||||
|
void halbtc8822c_cfg_ant_switch(struct btc_coexist *btc);
|
||||||
|
void halbtc8822c_cfg_gnt_debug(struct btc_coexist *btc);
|
||||||
|
void halbtc8822c_cfg_fre_type(struct btc_coexist *btc);
|
||||||
|
void halbtc8822c_cfg_coexinfo_hw(struct btc_coexist *btc);
|
||||||
|
void halbtc8822c_cfg_wl_tx_power(struct btc_coexist *btc);
|
||||||
|
void halbtc8822c_cfg_wl_rx_gain(struct btc_coexist *btc);
|
||||||
|
void halbtc8822c_cfg_wlan_act_ips(struct btc_coexist *btc);
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include "mp_precomp.h"
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
ex_hal8822c_wifi_only_hw_config(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
halwifionly_phy_set_bb_reg(pwifionlycfg, 0x70, 0xff000000, 0x0e);
|
||||||
|
/*gnt_wl=1 , gnt_bt=0*/
|
||||||
|
halwifionly_phy_set_bb_reg(pwifionlycfg, 0x1704, 0xffffffff, 0x7700);
|
||||||
|
halwifionly_phy_set_bb_reg(pwifionlycfg, 0x1700, 0xffffffff, 0xc00f0038);
|
||||||
|
|
||||||
|
halwifionly_phy_set_bb_reg(pwifionlycfg, 0x6c0, 0xffffffff, 0xaaaaaaaa);
|
||||||
|
halwifionly_phy_set_bb_reg(pwifionlycfg, 0x6c4, 0xffffffff, 0xaaaaaaaa);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
ex_hal8822c_wifi_only_scannotify(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg,
|
||||||
|
IN u1Byte is_5g
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
ex_hal8822c_wifi_only_switchbandnotify(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg,
|
||||||
|
IN u1Byte is_5g
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
ex_hal8822c_wifi_only_connectnotify(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg,
|
||||||
|
IN u1Byte is_5g
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
hal8822c_wifi_only_switch_antenna(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg,
|
||||||
|
IN u1Byte is_5g
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __INC_HAL8822CWIFIONLYHWCFG_H
|
||||||
|
#define __INC_HAL8822CWIFIONLYHWCFG_H
|
||||||
|
|
||||||
|
VOID
|
||||||
|
ex_hal8822c_wifi_only_hw_config(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg
|
||||||
|
);
|
||||||
|
VOID
|
||||||
|
ex_hal8822c_wifi_only_scannotify(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg,
|
||||||
|
IN u1Byte is_5g
|
||||||
|
);
|
||||||
|
VOID
|
||||||
|
ex_hal8822c_wifi_only_switchbandnotify(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg,
|
||||||
|
IN u1Byte is_5g
|
||||||
|
);
|
||||||
|
VOID
|
||||||
|
ex_hal8822c_wifi_only_connectnotify(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg,
|
||||||
|
IN u1Byte is_5g
|
||||||
|
);
|
||||||
|
VOID
|
||||||
|
hal8822c_wifi_only_switch_antenna(
|
||||||
|
IN struct wifi_only_cfg *pwifionlycfg,
|
||||||
|
IN u1Byte is_5g
|
||||||
|
);
|
||||||
|
#endif
|
||||||
5078
drivers/net/wireless/realtek/rtl8822ce/hal/btc/halbtccommon.c
Normal file
5078
drivers/net/wireless/realtek/rtl8822ce/hal/btc/halbtccommon.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,82 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
|
||||||
|
|
||||||
|
/* *******************************************
|
||||||
|
* The following is interface which will notify coex module.
|
||||||
|
* ********************************************/
|
||||||
|
void rtw_btc_ex_power_on_setting(struct btc_coexist *btc);
|
||||||
|
void rtw_btc_ex_pre_load_firmware(struct btc_coexist *btc);
|
||||||
|
void rtw_btc_ex_init_hw_config(struct btc_coexist *btc, boolean wifi_only);
|
||||||
|
void rtw_btc_ex_init_coex_dm(struct btc_coexist *btc);
|
||||||
|
void rtw_btc_ex_ips_notify(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_lps_notify(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_scan_notify(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_scan_notify_without_bt(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_switchband_notify(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_switchband_notify_without_bt(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_connect_notify(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_media_status_notify(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_specific_packet_notify(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_bt_info_notify(struct btc_coexist *btc, u8 *tmp_buf, u8 length);
|
||||||
|
void rtw_btc_ex_wl_fwdbginfo_notify(struct btc_coexist *btc, u8 *tmp_buf,
|
||||||
|
u8 length);
|
||||||
|
void rtw_btc_ex_rx_rate_change_notify(struct btc_coexist *btc,
|
||||||
|
BOOLEAN is_data_frame,
|
||||||
|
u8 btc_rate_id);
|
||||||
|
void rtw_btc_ex_tx_rate_change_notify(struct btc_coexist *btc, u8 tx_rate,
|
||||||
|
u8 tx_retry_ratio, u8 macid);
|
||||||
|
void rtw_btc_ex_rf_status_notify(struct btc_coexist *btc, u8 type);
|
||||||
|
void rtw_btc_ex_halt_notify(struct btc_coexist *btc);
|
||||||
|
void rtw_btc_ex_pnp_notify(struct btc_coexist *btc, u8 pnp_state);
|
||||||
|
void rtw_btc_ex_coex_dm_reset(struct btc_coexist *btc);
|
||||||
|
void rtw_btc_ex_periodical(struct btc_coexist *btc);
|
||||||
|
void rtw_btc_ex_timerup_notify(struct btc_coexist *btc, u32 type);
|
||||||
|
void rtw_btc_ex_wl_status_change_notify(struct btc_coexist *btc, u32 type);
|
||||||
|
void rtw_btc_ex_display_simple_coex_info(struct btc_coexist *btc);
|
||||||
|
void rtw_btc_ex_display_coex_info(struct btc_coexist *btc);
|
||||||
|
void rtw_btc_ex_dbg_control(struct btc_coexist *btc, u8 op_code, u8 op_len,
|
||||||
|
u8 *pdata);
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define rtw_btc_ex_power_on_setting(btc)
|
||||||
|
#define rtw_btc_ex_pre_load_firmware(btc)
|
||||||
|
#define rtw_btc_ex_init_hw_config(btc, wifi_only)
|
||||||
|
#define rtw_btc_ex_init_coex_dm(btc)
|
||||||
|
#define rtw_btc_ex_ips_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_lps_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_scan_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_scan_notify_without_bt(btc, type)
|
||||||
|
#define rtw_btc_ex_switchband_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_switchband_notify_without_bt(btc, type)
|
||||||
|
#define rtw_btc_ex_connect_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_media_status_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_specific_packet_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_bt_info_notify(btc, tmp_buf, length)
|
||||||
|
#define rtw_btc_ex_wl_fwdbginfo_notify(btc, tmp_buf, length)
|
||||||
|
#define rtw_btc_ex_rx_rate_change_notify(btc, is_data_frame, btc_rate_id)
|
||||||
|
#define rtw_btc_ex_tx_rate_change_notify(btcoexist, tx_rate, tx_retry_ratio, \
|
||||||
|
macid)
|
||||||
|
#define rtw_btc_ex_rf_status_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_halt_notify(btc)
|
||||||
|
#define rtw_btc_ex_pnp_notify(btc, pnp_state)
|
||||||
|
#define rtw_btc_ex_coex_dm_reset(btc)
|
||||||
|
#define rtw_btc_ex_periodical(btc)
|
||||||
|
#define rtw_btc_ex_timerup_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_wl_status_change_notify(btc, type)
|
||||||
|
#define rtw_btc_ex_display_coex_info(btc)
|
||||||
|
#define rtw_btc_ex_dbg_control(btc, op_code, op_len, pdata)
|
||||||
|
#endif
|
||||||
2105
drivers/net/wireless/realtek/rtl8822ce/hal/btc/halbtcoutsrc.h
Normal file
2105
drivers/net/wireless/realtek/rtl8822ce/hal/btc/halbtcoutsrc.h
Normal file
File diff suppressed because it is too large
Load Diff
159
drivers/net/wireless/realtek/rtl8822ce/hal/btc/mp_precomp.h
Normal file
159
drivers/net/wireless/realtek/rtl8822ce/hal/btc/mp_precomp.h
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2013 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __MP_PRECOMP_H__
|
||||||
|
#define __MP_PRECOMP_H__
|
||||||
|
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
#include "btc_basic_types.h"
|
||||||
|
|
||||||
|
#define BT_TMP_BUF_SIZE 100
|
||||||
|
|
||||||
|
#ifdef PLATFORM_LINUX
|
||||||
|
#define rsprintf snprintf
|
||||||
|
#define rstrncat(dst, src, src_size) strncat(dst, src, src_size)
|
||||||
|
#elif defined(PLATFORM_WINDOWS)
|
||||||
|
#define rsprintf sprintf_s
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DCMD_Printf DBG_BT_INFO
|
||||||
|
|
||||||
|
#define delay_ms(ms) rtw_mdelay_os(ms)
|
||||||
|
|
||||||
|
#ifdef bEnable
|
||||||
|
#undef bEnable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WPP_SOFTWARE_TRACE 0
|
||||||
|
|
||||||
|
typedef enum _BTC_MSG_COMP_TYPE {
|
||||||
|
COMP_COEX = 0,
|
||||||
|
COMP_MAX
|
||||||
|
} BTC_MSG_COMP_TYPE;
|
||||||
|
extern u4Byte GLBtcDbgType[];
|
||||||
|
|
||||||
|
#define DBG_OFF 0
|
||||||
|
#define DBG_SEC 1
|
||||||
|
#define DBG_SERIOUS 2
|
||||||
|
#define DBG_WARNING 3
|
||||||
|
#define DBG_LOUD 4
|
||||||
|
#define DBG_TRACE 5
|
||||||
|
|
||||||
|
#ifdef CONFIG_BT_COEXIST
|
||||||
|
#define BT_SUPPORT 1
|
||||||
|
#define COEX_SUPPORT 1
|
||||||
|
#define HS_SUPPORT 1
|
||||||
|
#else
|
||||||
|
#define BT_SUPPORT 0
|
||||||
|
#define COEX_SUPPORT 0
|
||||||
|
#define HS_SUPPORT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* for wifi only mode */
|
||||||
|
#include "hal_btcoex_wifionly.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_BT_COEXIST
|
||||||
|
#define BTC_BTINFO_LENGTH_MAX 10
|
||||||
|
|
||||||
|
struct wifi_only_cfg;
|
||||||
|
struct btc_coexist;
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8192E
|
||||||
|
#include "halbtc8192e1ant.h"
|
||||||
|
#include "halbtc8192e2ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8723B
|
||||||
|
#include "halbtc8723bwifionly.h"
|
||||||
|
#include "halbtc8723b1ant.h"
|
||||||
|
#include "halbtc8723b2ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8812A
|
||||||
|
#include "halbtc8812a1ant.h"
|
||||||
|
#include "halbtc8812a2ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8821A
|
||||||
|
#include "halbtc8821a1ant.h"
|
||||||
|
#include "halbtc8821a2ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8703B
|
||||||
|
#include "halbtc8703b1ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8723D
|
||||||
|
#include "halbtc8723d1ant.h"
|
||||||
|
#include "halbtc8723d2ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822B
|
||||||
|
#include "halbtc8822bwifionly.h"
|
||||||
|
#include "halbtc8822b1ant.h"
|
||||||
|
#include "halbtc8822b2ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8821C
|
||||||
|
#include "halbtc8821cwifionly.h"
|
||||||
|
#include "halbtc8821c1ant.h"
|
||||||
|
#include "halbtc8821c2ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8814A
|
||||||
|
#include "halbtc8814a2ant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
|
||||||
|
#include "halbtccommon.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822C
|
||||||
|
#include "halbtc8822cwifionly.h"
|
||||||
|
#include "halbtc8822c.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8192F
|
||||||
|
#include "halbtc8192f.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "halbtcoutsrc.h"
|
||||||
|
|
||||||
|
#else /* CONFIG_BT_COEXIST */
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8723B
|
||||||
|
#include "halbtc8723bwifionly.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822B
|
||||||
|
#include "halbtc8822bwifionly.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8821C
|
||||||
|
#include "halbtc8821cwifionly.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822C
|
||||||
|
#include "halbtc8822cwifionly.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8814B
|
||||||
|
#include "halbtc8814bwifionly.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_BT_COEXIST */
|
||||||
|
|
||||||
|
#endif /* __MP_PRECOMP_H__ */
|
||||||
181
drivers/net/wireless/realtek/rtl8822ce/hal/efuse/efuse_mask.h
Normal file
181
drivers/net/wireless/realtek/rtl8822ce/hal/efuse/efuse_mask.h
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_USB_HCI
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8188E)
|
||||||
|
#include "rtl8188e/HalEfuseMask8188E_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8812A)
|
||||||
|
#include "rtl8812a/HalEfuseMask8812A_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8821A)
|
||||||
|
#include "rtl8812a/HalEfuseMask8821A_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8192E)
|
||||||
|
#include "rtl8192e/HalEfuseMask8192E_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8723B)
|
||||||
|
#include "rtl8723b/HalEfuseMask8723B_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8814A)
|
||||||
|
#include "rtl8814a/HalEfuseMask8814A_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8703B)
|
||||||
|
#include "rtl8703b/HalEfuseMask8703B_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8723D)
|
||||||
|
#include "rtl8723d/HalEfuseMask8723D_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8188F)
|
||||||
|
#include "rtl8188f/HalEfuseMask8188F_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8188GTV)
|
||||||
|
#include "rtl8188gtv/HalEfuseMask8188GTV_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8822B)
|
||||||
|
#include "rtl8822b/HalEfuseMask8822B_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8821C)
|
||||||
|
#include "rtl8821c/HalEfuseMask8821C_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8710B)
|
||||||
|
#include "rtl8710b/HalEfuseMask8710B_USB.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8192F)
|
||||||
|
#include "rtl8192f/HalEfuseMask8192F_USB.h"
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_RTL8822C)
|
||||||
|
#include "rtl8822c/HalEfuseMask8822C_USB.h"
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_RTL8814B)
|
||||||
|
#include "rtl8814b/HalEfuseMask8814B_USB.h"
|
||||||
|
#endif
|
||||||
|
#endif /*CONFIG_USB_HCI*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PCI_HCI
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8188E)
|
||||||
|
#include "rtl8188e/HalEfuseMask8188E_PCIE.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8812A)
|
||||||
|
#include "rtl8812a/HalEfuseMask8812A_PCIE.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8821A)
|
||||||
|
#include "rtl8812a/HalEfuseMask8821A_PCIE.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8192E)
|
||||||
|
#include "rtl8192e/HalEfuseMask8192E_PCIE.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8723B)
|
||||||
|
#include "rtl8723b/HalEfuseMask8723B_PCIE.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8814A)
|
||||||
|
#include "rtl8814a/HalEfuseMask8814A_PCIE.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8703B)
|
||||||
|
#include "rtl8703b/HalEfuseMask8703B_PCIE.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8822B)
|
||||||
|
#include "rtl8822b/HalEfuseMask8822B_PCIE.h"
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_RTL8723D)
|
||||||
|
#include "rtl8723d/HalEfuseMask8723D_PCIE.h"
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_RTL8821C)
|
||||||
|
#include "rtl8821c/HalEfuseMask8821C_PCIE.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8192F)
|
||||||
|
#include "rtl8192f/HalEfuseMask8192F_PCIE.h"
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_RTL8822C)
|
||||||
|
#include "rtl8822c/HalEfuseMask8822C_PCIE.h"
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_RTL8814B)
|
||||||
|
#include "rtl8814b/HalEfuseMask8814B_PCIE.h"
|
||||||
|
#endif
|
||||||
|
#endif /*CONFIG_PCI_HCI*/
|
||||||
|
#ifdef CONFIG_SDIO_HCI
|
||||||
|
#if defined(CONFIG_RTL8723B)
|
||||||
|
#include "rtl8723b/HalEfuseMask8723B_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8188E)
|
||||||
|
#include "rtl8188e/HalEfuseMask8188E_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8703B)
|
||||||
|
#include "rtl8703b/HalEfuseMask8703B_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8188F)
|
||||||
|
#include "rtl8188f/HalEfuseMask8188F_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8188GTV)
|
||||||
|
#include "rtl8188gtv/HalEfuseMask8188GTV_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8723D)
|
||||||
|
#include "rtl8723d/HalEfuseMask8723D_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8192E)
|
||||||
|
#include "rtl8192e/HalEfuseMask8192E_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8821A)
|
||||||
|
#include "rtl8812a/HalEfuseMask8821A_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8821C)
|
||||||
|
#include "rtl8821c/HalEfuseMask8821C_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8822B)
|
||||||
|
#include "rtl8822b/HalEfuseMask8822B_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8192F)
|
||||||
|
#include "rtl8192f/HalEfuseMask8192F_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTL8822C)
|
||||||
|
#include "rtl8822c/HalEfuseMask8822C_SDIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*CONFIG_SDIO_HCI*/
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2015 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
#include "HalEfuseMask8822C_PCIE.h"
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* MPCIE.TXT
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
u8 Array_MP_8822C_MPCIE_BT[] = {
|
||||||
|
0x00,
|
||||||
|
0x41,
|
||||||
|
0x00,
|
||||||
|
0x70,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x02,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x08,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0xCF,
|
||||||
|
0xFF,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
u8 Array_MP_8822C_MPCIE[] = {
|
||||||
|
0xFF,
|
||||||
|
0xF7,
|
||||||
|
0xEF,
|
||||||
|
0xDE,
|
||||||
|
0xFC,
|
||||||
|
0xFB,
|
||||||
|
0x10,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x03,
|
||||||
|
0xF7,
|
||||||
|
0xD7,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x71,
|
||||||
|
0xF1,
|
||||||
|
0xFF,
|
||||||
|
0xFF,
|
||||||
|
0x7E,
|
||||||
|
0xFC,
|
||||||
|
0xFF,
|
||||||
|
0xF1,
|
||||||
|
0x00,
|
||||||
|
0xD0,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* BT eFuse Maks */
|
||||||
|
u16 EFUSE_GetBTArrayLen_MP_8822C_MPCIE(void)
|
||||||
|
{
|
||||||
|
return sizeof(Array_MP_8822C_MPCIE_BT) / sizeof(u8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EFUSE_GetBTMaskArray_MP_8822C_MPCIE(u8 *Array)
|
||||||
|
{
|
||||||
|
u16 len = EFUSE_GetBTArrayLen_MP_8822C_MPCIE(), i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
|
Array[i] = Array_MP_8822C_MPCIE_BT[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsBTAddressMasked_MP_8822C_MPCIE(u16 Offset)
|
||||||
|
{
|
||||||
|
int r = Offset / 16;
|
||||||
|
int c = (Offset % 16) / 2;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (c < 4) /*Upper double word*/
|
||||||
|
result = (Array_MP_8822C_MPCIE_BT[r] & (0x10 << c));
|
||||||
|
else
|
||||||
|
result = (Array_MP_8822C_MPCIE_BT[r] & (0x01 << (c - 4)));
|
||||||
|
|
||||||
|
return (result > 0) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WiFi eFuse Maks */
|
||||||
|
u16 EFUSE_GetArrayLen_MP_8822C_MPCIE(void)
|
||||||
|
{
|
||||||
|
return sizeof(Array_MP_8822C_MPCIE) / sizeof(u8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EFUSE_GetMaskArray_MP_8822C_MPCIE(u8 *Array)
|
||||||
|
{
|
||||||
|
u16 len = EFUSE_GetArrayLen_MP_8822C_MPCIE(), i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
|
Array[i] = Array_MP_8822C_MPCIE[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsAddressMasked_MP_8822C_MPCIE(u16 Offset)
|
||||||
|
{
|
||||||
|
int r = Offset / 16;
|
||||||
|
int c = (Offset % 16) / 2;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (c < 4) /*Upper double word*/
|
||||||
|
result = (Array_MP_8822C_MPCIE[r] & (0x10 << c));
|
||||||
|
else
|
||||||
|
result = (Array_MP_8822C_MPCIE[r] & (0x01 << (c - 4)));
|
||||||
|
|
||||||
|
return (result > 0) ? 0 : 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2015 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* MPCIE.TXT
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
u16 EFUSE_GetArrayLen_MP_8822C_MPCIE(void);
|
||||||
|
|
||||||
|
void EFUSE_GetMaskArray_MP_8822C_MPCIE(u8 *Array);
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsAddressMasked_MP_8822C_MPCIE(u16 Offset);
|
||||||
|
|
||||||
|
u16 EFUSE_GetBTArrayLen_MP_8822C_MPCIE(void);
|
||||||
|
|
||||||
|
void EFUSE_GetBTMaskArray_MP_8822C_MPCIE(u8 *Array);
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsBTAddressMasked_MP_8822C_MPCIE(u16 Offset);
|
||||||
|
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2015 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
#include "HalEfuseMask8822C_SDIO.h"
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* MSDIO.TXT
|
||||||
|
******************************************************************************/
|
||||||
|
u8 Array_MP_8822C_MSDIO_BT[] = {
|
||||||
|
0x00,
|
||||||
|
0x41,
|
||||||
|
0x00,
|
||||||
|
0x70,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x02,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x08,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0xCF,
|
||||||
|
0xFF,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
u8 Array_MP_8822C_MSDIO[] = {
|
||||||
|
0xFF,
|
||||||
|
0xF7,
|
||||||
|
0xEF,
|
||||||
|
0xDE,
|
||||||
|
0xFC,
|
||||||
|
0xFB,
|
||||||
|
0x10,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x03,
|
||||||
|
0xF7,
|
||||||
|
0xD7,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x71,
|
||||||
|
0xF1,
|
||||||
|
0x76,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x0E,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* BT eFuse Mask */
|
||||||
|
u16 EFUSE_GetBTArrayLen_MP_8822C_MSDIO(void)
|
||||||
|
{
|
||||||
|
return sizeof(Array_MP_8822C_MSDIO_BT) / sizeof(u8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EFUSE_GetBTMaskArray_MP_8822C_MSDIO(u8 *Array)
|
||||||
|
{
|
||||||
|
u16 len = EFUSE_GetBTArrayLen_MP_8822C_MSDIO(), i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
|
Array[i] = Array_MP_8822C_MSDIO_BT[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsBTAddressMasked_MP_8822C_MSDIO(u16 Offset)
|
||||||
|
{
|
||||||
|
int r = Offset / 16;
|
||||||
|
int c = (Offset % 16) / 2;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (c < 4) /*Upper double word*/
|
||||||
|
result = (Array_MP_8822C_MSDIO_BT[r] & (0x10 << c));
|
||||||
|
else
|
||||||
|
result = (Array_MP_8822C_MSDIO_BT[r] & (0x01 << (c - 4)));
|
||||||
|
|
||||||
|
return (result > 0) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WiFi eFuse Mask */
|
||||||
|
u16 EFUSE_GetArrayLen_MP_8822C_MSDIO(void)
|
||||||
|
{
|
||||||
|
return sizeof(Array_MP_8822C_MSDIO) / sizeof(u8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EFUSE_GetMaskArray_MP_8822C_MSDIO(u8 *Array)
|
||||||
|
{
|
||||||
|
u16 len = EFUSE_GetArrayLen_MP_8822C_MSDIO(), i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
|
Array[i] = Array_MP_8822C_MSDIO[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsAddressMasked_MP_8822C_MSDIO(u16 Offset)
|
||||||
|
{
|
||||||
|
int r = Offset / 16;
|
||||||
|
int c = (Offset % 16) / 2;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (c < 4) /*Upper double word*/
|
||||||
|
result = (Array_MP_8822C_MSDIO[r] & (0x10 << c));
|
||||||
|
else
|
||||||
|
result = (Array_MP_8822C_MSDIO[r] & (0x01 << (c - 4)));
|
||||||
|
|
||||||
|
return (result > 0) ? 0 : 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2015 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* MSDIO.TXT
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
u16 EFUSE_GetArrayLen_MP_8822C_MSDIO(void);
|
||||||
|
|
||||||
|
void EFUSE_GetMaskArray_MP_8822C_MSDIO(u8 *Array);
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsAddressMasked_MP_8822C_MSDIO(u16 Offset);
|
||||||
|
|
||||||
|
u16 EFUSE_GetBTArrayLen_MP_8822C_MSDIO(void);
|
||||||
|
|
||||||
|
void EFUSE_GetBTMaskArray_MP_8822C_MSDIO(u8 *Array);
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsBTAddressMasked_MP_8822C_MSDIO(u16 Offset);
|
||||||
|
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2015 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <drv_types.h>
|
||||||
|
|
||||||
|
#include "HalEfuseMask8822C_USB.h"
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* MUSB.TXT
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
u8 Array_MP_8822C_MUSB_BT[] = {
|
||||||
|
0x00,
|
||||||
|
0x41,
|
||||||
|
0x00,
|
||||||
|
0x70,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x02,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x08,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0xCF,
|
||||||
|
0xFF,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
u8 Array_MP_8822C_MUSB[] = {
|
||||||
|
0xFF,
|
||||||
|
0xF7,
|
||||||
|
0xEF,
|
||||||
|
0xDE,
|
||||||
|
0xFC,
|
||||||
|
0xFB,
|
||||||
|
0x10,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x03,
|
||||||
|
0xF7,
|
||||||
|
0xD7,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x71,
|
||||||
|
0xF1,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0xFF,
|
||||||
|
0xFF,
|
||||||
|
0xFF,
|
||||||
|
0xFF,
|
||||||
|
0xD0,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* BT eFuse Mask */
|
||||||
|
|
||||||
|
u16 EFUSE_GetBTArrayLen_MP_8822C_MUSB(void)
|
||||||
|
{
|
||||||
|
return sizeof(Array_MP_8822C_MUSB_BT) / sizeof(u8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EFUSE_GetBTMaskArray_MP_8822C_MUSB(u8 *Array)
|
||||||
|
{
|
||||||
|
u16 len = EFUSE_GetBTArrayLen_MP_8822C_MUSB(), i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
|
Array[i] = Array_MP_8822C_MUSB_BT[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsBTAddressMasked_MP_8822C_MUSB(u16 Offset)
|
||||||
|
{
|
||||||
|
int r = Offset / 16;
|
||||||
|
int c = (Offset % 16) / 2;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (c < 4) /*Upper double word*/
|
||||||
|
result = (Array_MP_8822C_MUSB_BT[r] & (0x10 << c));
|
||||||
|
else
|
||||||
|
result = (Array_MP_8822C_MUSB_BT[r] & (0x01 << (c - 4)));
|
||||||
|
|
||||||
|
return (result > 0) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* WiFi eFuse Mask */
|
||||||
|
u16 EFUSE_GetArrayLen_MP_8822C_MUSB(void)
|
||||||
|
{
|
||||||
|
return sizeof(Array_MP_8822C_MUSB) / sizeof(u8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EFUSE_GetMaskArray_MP_8822C_MUSB(u8 *Array)
|
||||||
|
{
|
||||||
|
u16 len = EFUSE_GetArrayLen_MP_8822C_MUSB(), i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
|
Array[i] = Array_MP_8822C_MUSB[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsAddressMasked_MP_8822C_MUSB(u16 Offset)
|
||||||
|
{
|
||||||
|
int r = Offset / 16;
|
||||||
|
int c = (Offset % 16) / 2;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (c < 4) /*Upper double word*/
|
||||||
|
result = (Array_MP_8822C_MUSB[r] & (0x10 << c));
|
||||||
|
else
|
||||||
|
result = (Array_MP_8822C_MUSB[r] & (0x01 << (c - 4)));
|
||||||
|
|
||||||
|
return (result > 0) ? 0 : 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2015 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* MUSB.TXT
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
u16 EFUSE_GetArrayLen_MP_8822C_MUSB(void);
|
||||||
|
|
||||||
|
void EFUSE_GetMaskArray_MP_8822C_MUSB(u8 *Array);
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsAddressMasked_MP_8822C_MUSB(u16 Offset);
|
||||||
|
|
||||||
|
u16 EFUSE_GetBTArrayLen_MP_8822C_MUSB(void);
|
||||||
|
|
||||||
|
void EFUSE_GetBTMaskArray_MP_8822C_MUSB(u8 *Array);
|
||||||
|
|
||||||
|
BOOLEAN EFUSE_IsBTAddressMasked_MP_8822C_MUSB(u16 Offset);
|
||||||
|
|
||||||
6543
drivers/net/wireless/realtek/rtl8822ce/hal/hal_btcoex.c
Normal file
6543
drivers/net/wireless/realtek/rtl8822ce/hal/hal_btcoex.c
Normal file
File diff suppressed because it is too large
Load Diff
264
drivers/net/wireless/realtek/rtl8822ce/hal/hal_btcoex_wifionly.c
Normal file
264
drivers/net/wireless/realtek/rtl8822ce/hal/hal_btcoex_wifionly.c
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2016 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <hal_btcoex_wifionly.h>
|
||||||
|
|
||||||
|
#if (CONFIG_BTCOEX_SUPPORT_WIFI_ONLY_CFG == 1)
|
||||||
|
|
||||||
|
#include "btc/mp_precomp.h"
|
||||||
|
|
||||||
|
struct wifi_only_cfg GLBtCoexistWifiOnly;
|
||||||
|
|
||||||
|
void halwifionly_write1byte(void *pwifionlyContext, u32 RegAddr, u8 Data)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
rtw_write8(Adapter, RegAddr, Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halwifionly_write2byte(void *pwifionlyContext, u32 RegAddr, u16 Data)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
rtw_write16(Adapter, RegAddr, Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halwifionly_write4byte(void *pwifionlyContext, u32 RegAddr, u32 Data)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
rtw_write32(Adapter, RegAddr, Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 halwifionly_read1byte(void *pwifionlyContext, u32 RegAddr)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
return rtw_read8(Adapter, RegAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 halwifionly_read2byte(void * pwifionlyContext, u32 RegAddr)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
return rtw_read16(Adapter, RegAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 halwifionly_read4byte(void *pwifionlyContext, u32 RegAddr)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
return rtw_read32(Adapter, RegAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halwifionly_bitmaskwrite1byte(void *pwifionlyContext, u32 regAddr, u8 bitMask, u8 data)
|
||||||
|
{
|
||||||
|
u8 originalValue, bitShift = 0;
|
||||||
|
u8 i;
|
||||||
|
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
if (bitMask != 0xff) {
|
||||||
|
originalValue = rtw_read8(Adapter, regAddr);
|
||||||
|
for (i = 0; i <= 7; i++) {
|
||||||
|
if ((bitMask >> i) & 0x1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bitShift = i;
|
||||||
|
data = ((originalValue) & (~bitMask)) | (((data << bitShift)) & bitMask);
|
||||||
|
}
|
||||||
|
rtw_write8(Adapter, regAddr, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halwifionly_phy_set_rf_reg(void *pwifionlyContext, enum rf_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
phy_set_rf_reg(Adapter, eRFPath, RegAddr, BitMask, Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void halwifionly_phy_set_bb_reg(void *pwifionlyContext, u32 RegAddr, u32 BitMask, u32 Data)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = (struct wifi_only_cfg *)pwifionlyContext;
|
||||||
|
PADAPTER Adapter = pwifionlycfg->Adapter;
|
||||||
|
|
||||||
|
phy_set_bb_reg(Adapter, RegAddr, BitMask, Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_btcoex_wifionly_switchband_notify(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
u8 is_5g = _FALSE;
|
||||||
|
|
||||||
|
if (pHalData->current_band_type == BAND_ON_5G)
|
||||||
|
is_5g = _TRUE;
|
||||||
|
|
||||||
|
if (IS_HARDWARE_TYPE_8822B(padapter)) {
|
||||||
|
#ifdef CONFIG_RTL8822B
|
||||||
|
ex_hal8822b_wifi_only_switchbandnotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8821C
|
||||||
|
else if (IS_HARDWARE_TYPE_8821C(padapter))
|
||||||
|
ex_hal8821c_wifi_only_switchbandnotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822C
|
||||||
|
else if (IS_HARDWARE_TYPE_8822C(padapter))
|
||||||
|
ex_hal8822c_wifi_only_switchbandnotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8814B
|
||||||
|
else if (IS_HARDWARE_TYPE_8814B(padapter))
|
||||||
|
ex_hal8814b_wifi_only_switchbandnotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_btcoex_wifionly_scan_notify(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
u8 is_5g = _FALSE;
|
||||||
|
|
||||||
|
if (pHalData->current_band_type == BAND_ON_5G)
|
||||||
|
is_5g = _TRUE;
|
||||||
|
|
||||||
|
if (IS_HARDWARE_TYPE_8822B(padapter)) {
|
||||||
|
#ifdef CONFIG_RTL8822B
|
||||||
|
ex_hal8822b_wifi_only_scannotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8821C
|
||||||
|
else if (IS_HARDWARE_TYPE_8821C(padapter))
|
||||||
|
ex_hal8821c_wifi_only_scannotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822C
|
||||||
|
else if (IS_HARDWARE_TYPE_8822C(padapter))
|
||||||
|
ex_hal8822c_wifi_only_scannotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8814B
|
||||||
|
else if (IS_HARDWARE_TYPE_8814B(padapter))
|
||||||
|
ex_hal8814b_wifi_only_scannotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_btcoex_wifionly_connect_notify(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
u8 is_5g = _FALSE;
|
||||||
|
|
||||||
|
if (pHalData->current_band_type == BAND_ON_5G)
|
||||||
|
is_5g = _TRUE;
|
||||||
|
|
||||||
|
if (IS_HARDWARE_TYPE_8822B(padapter)) {
|
||||||
|
#ifdef CONFIG_RTL8822B
|
||||||
|
ex_hal8822b_wifi_only_connectnotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8821C
|
||||||
|
else if (IS_HARDWARE_TYPE_8821C(padapter))
|
||||||
|
ex_hal8821c_wifi_only_connectnotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822C
|
||||||
|
else if (IS_HARDWARE_TYPE_8822C(padapter))
|
||||||
|
ex_hal8822c_wifi_only_connectnotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8814B
|
||||||
|
else if (IS_HARDWARE_TYPE_8814B(padapter))
|
||||||
|
ex_hal8814b_wifi_only_connectnotify(&GLBtCoexistWifiOnly, is_5g);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_btcoex_wifionly_hw_config(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = &GLBtCoexistWifiOnly;
|
||||||
|
|
||||||
|
if (IS_HARDWARE_TYPE_8723B(padapter)) {
|
||||||
|
#ifdef CONFIG_RTL8723B
|
||||||
|
ex_hal8723b_wifi_only_hw_config(pwifionlycfg);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822B
|
||||||
|
else if (IS_HARDWARE_TYPE_8822B(padapter))
|
||||||
|
ex_hal8822b_wifi_only_hw_config(pwifionlycfg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8821C
|
||||||
|
else if (IS_HARDWARE_TYPE_8821C(padapter))
|
||||||
|
ex_hal8821c_wifi_only_hw_config(pwifionlycfg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8822C
|
||||||
|
else if (IS_HARDWARE_TYPE_8822C(padapter))
|
||||||
|
ex_hal8822c_wifi_only_hw_config(pwifionlycfg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTL8814B
|
||||||
|
else if (IS_HARDWARE_TYPE_8814B(padapter))
|
||||||
|
ex_hal8814b_wifi_only_hw_config(pwifionlycfg);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_btcoex_wifionly_initlizevariables(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = &GLBtCoexistWifiOnly;
|
||||||
|
struct wifi_only_haldata *pwifionly_haldata = &pwifionlycfg->haldata_info;
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
|
||||||
|
_rtw_memset(&GLBtCoexistWifiOnly, 0, sizeof(GLBtCoexistWifiOnly));
|
||||||
|
|
||||||
|
pwifionlycfg->Adapter = padapter;
|
||||||
|
|
||||||
|
#ifdef CONFIG_PCI_HCI
|
||||||
|
pwifionlycfg->chip_interface = WIFIONLY_INTF_PCI;
|
||||||
|
#elif defined(CONFIG_USB_HCI)
|
||||||
|
pwifionlycfg->chip_interface = WIFIONLY_INTF_USB;
|
||||||
|
#elif defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
|
||||||
|
pwifionlycfg->chip_interface = WIFIONLY_INTF_SDIO;
|
||||||
|
#else
|
||||||
|
pwifionlycfg->chip_interface = WIFIONLY_INTF_UNKNOWN;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pwifionly_haldata->customer_id = CUSTOMER_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_btcoex_wifionly_AntInfoSetting(PADAPTER padapter)
|
||||||
|
{
|
||||||
|
struct wifi_only_cfg *pwifionlycfg = &GLBtCoexistWifiOnly;
|
||||||
|
struct wifi_only_haldata *pwifionly_haldata = &pwifionlycfg->haldata_info;
|
||||||
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
||||||
|
|
||||||
|
pwifionly_haldata->efuse_pg_antnum = pHalData->EEPROMBluetoothAntNum;
|
||||||
|
pwifionly_haldata->efuse_pg_antpath = pHalData->ant_path;
|
||||||
|
pwifionly_haldata->rfe_type = pHalData->rfe_type;
|
||||||
|
pwifionly_haldata->ant_div_cfg = pHalData->AntDivCfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
15632
drivers/net/wireless/realtek/rtl8822ce/hal/hal_com.c
Normal file
15632
drivers/net/wireless/realtek/rtl8822ce/hal/hal_com.c
Normal file
File diff suppressed because it is too large
Load Diff
140
drivers/net/wireless/realtek/rtl8822ce/hal/hal_com_c2h.h
Normal file
140
drivers/net/wireless/realtek/rtl8822ce/hal/hal_com_c2h.h
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __COMMON_C2H_H__
|
||||||
|
#define __COMMON_C2H_H__
|
||||||
|
|
||||||
|
#define C2H_TYPE_REG 0
|
||||||
|
#define C2H_TYPE_PKT 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* C2H event format:
|
||||||
|
* Fields TRIGGER PAYLOAD SEQ PLEN ID
|
||||||
|
* BITS [127:120] [119:16] [15:8] [7:4] [3:0]
|
||||||
|
*/
|
||||||
|
#define C2H_ID(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)), 0, 4)
|
||||||
|
#define C2H_PLEN(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)), 4, 4)
|
||||||
|
#define C2H_SEQ(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 1, 0, 8)
|
||||||
|
#define C2H_PAYLOAD(_c2h) (((u8*)(_c2h)) + 2)
|
||||||
|
|
||||||
|
#define SET_C2H_ID(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 0, 4, _val)
|
||||||
|
#define SET_C2H_PLEN(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 4, 4, _val)
|
||||||
|
#define SET_C2H_SEQ(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 1 , 0, 8, _val)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* C2H event format:
|
||||||
|
* Fields TRIGGER PLEN PAYLOAD SEQ ID
|
||||||
|
* BITS [127:120] [119:112] [111:16] [15:8] [7:0]
|
||||||
|
*/
|
||||||
|
#define C2H_ID_88XX(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)), 0, 8)
|
||||||
|
#define C2H_SEQ_88XX(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 1, 0, 8)
|
||||||
|
#define C2H_PAYLOAD_88XX(_c2h) (((u8*)(_c2h)) + 2)
|
||||||
|
#define C2H_PLEN_88XX(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 14, 0, 8)
|
||||||
|
#define C2H_TRIGGER_88XX(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 15, 0, 8)
|
||||||
|
|
||||||
|
#define SET_C2H_ID_88XX(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 0, 8, _val)
|
||||||
|
#define SET_C2H_SEQ_88XX(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 1, 0, 8, _val)
|
||||||
|
#define SET_C2H_PLEN_88XX(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 14, 0, 8, _val)
|
||||||
|
|
||||||
|
typedef enum _C2H_EVT {
|
||||||
|
C2H_DBG = 0x00,
|
||||||
|
C2H_LB = 0x01,
|
||||||
|
C2H_TXBF = 0x02,
|
||||||
|
C2H_CCX_TX_RPT = 0x03,
|
||||||
|
C2H_AP_REQ_TXRPT = 0x04,
|
||||||
|
C2H_FW_SCAN_COMPLETE = 0x7,
|
||||||
|
C2H_BT_INFO = 0x09,
|
||||||
|
C2H_BT_MP_INFO = 0x0B,
|
||||||
|
C2H_RA_RPT = 0x0C,
|
||||||
|
C2H_SPC_STAT = 0x0D,
|
||||||
|
C2H_RA_PARA_RPT = 0x0E,
|
||||||
|
C2H_FW_CHNL_SWITCH_COMPLETE = 0x10,
|
||||||
|
C2H_IQK_FINISH = 0x11,
|
||||||
|
C2H_MAILBOX_STATUS = 0x15,
|
||||||
|
C2H_P2P_RPORT = 0x16,
|
||||||
|
C2H_MCC = 0x17,
|
||||||
|
C2H_MAC_HIDDEN_RPT = 0x19,
|
||||||
|
C2H_MAC_HIDDEN_RPT_2 = 0x1A,
|
||||||
|
C2H_BCN_EARLY_RPT = 0x1E,
|
||||||
|
C2H_DEFEATURE_DBG = 0x22,
|
||||||
|
C2H_CUSTOMER_STR_RPT = 0x24,
|
||||||
|
C2H_CUSTOMER_STR_RPT_2 = 0x25,
|
||||||
|
C2H_WLAN_INFO = 0x27,
|
||||||
|
#ifdef RTW_PER_CMD_SUPPORT_FW
|
||||||
|
C2H_PER_RATE_RPT = 0x2c,
|
||||||
|
#endif
|
||||||
|
C2H_LPS_STATUS_RPT = 0x32,
|
||||||
|
C2H_SET_TXPWR_FINISH = 0x70,
|
||||||
|
C2H_DEFEATURE_RSVD = 0xFD,
|
||||||
|
C2H_EXTEND = 0xff,
|
||||||
|
} C2H_EVT;
|
||||||
|
|
||||||
|
typedef enum _EXTEND_C2H_EVT {
|
||||||
|
EXTEND_C2H_DBG_PRINT = 0
|
||||||
|
} EXTEND_C2H_EVT;
|
||||||
|
|
||||||
|
#define C2H_REG_LEN 16
|
||||||
|
|
||||||
|
/* C2H_IQK_FINISH, 0x11 */
|
||||||
|
#define IQK_OFFLOAD_LEN 1
|
||||||
|
void c2h_iqk_offload(_adapter *adapter, u8 *data, u8 len);
|
||||||
|
int c2h_iqk_offload_wait(_adapter *adapter, u32 timeout_ms);
|
||||||
|
#define rtl8812_iqk_wait c2h_iqk_offload_wait /* TODO: remove this after phydm call c2h_iqk_offload_wait instead */
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_MAC_HIDDEN_RPT
|
||||||
|
/* C2H_MAC_HIDDEN_RPT, 0x19 */
|
||||||
|
#define MAC_HIDDEN_RPT_LEN 8
|
||||||
|
int c2h_mac_hidden_rpt_hdl(_adapter *adapter, u8 *data, u8 len);
|
||||||
|
|
||||||
|
/* C2H_MAC_HIDDEN_RPT_2, 0x1A */
|
||||||
|
#define MAC_HIDDEN_RPT_2_LEN 5
|
||||||
|
int c2h_mac_hidden_rpt_2_hdl(_adapter *adapter, u8 *data, u8 len);
|
||||||
|
int hal_read_mac_hidden_rpt(_adapter *adapter);
|
||||||
|
#else
|
||||||
|
#define hal_read_mac_hidden_rpt(adapter) _SUCCESS
|
||||||
|
#endif /* CONFIG_RTW_MAC_HIDDEN_RPT */
|
||||||
|
|
||||||
|
/* C2H_DEFEATURE_DBG, 0x22 */
|
||||||
|
#define DEFEATURE_DBG_LEN 1
|
||||||
|
int c2h_defeature_dbg_hdl(_adapter *adapter, u8 *data, u8 len);
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_CUSTOMER_STR
|
||||||
|
/* C2H_CUSTOMER_STR_RPT, 0x24 */
|
||||||
|
#define CUSTOMER_STR_RPT_LEN 8
|
||||||
|
int c2h_customer_str_rpt_hdl(_adapter *adapter, u8 *data, u8 len);
|
||||||
|
|
||||||
|
/* C2H_CUSTOMER_STR_RPT_2, 0x25 */
|
||||||
|
#define CUSTOMER_STR_RPT_2_LEN 8
|
||||||
|
int c2h_customer_str_rpt_2_hdl(_adapter *adapter, u8 *data, u8 len);
|
||||||
|
#endif /* CONFIG_RTW_CUSTOMER_STR */
|
||||||
|
|
||||||
|
#ifdef RTW_PER_CMD_SUPPORT_FW
|
||||||
|
/* C2H_PER_RATE_RPT, 0x2c */
|
||||||
|
int c2h_per_rate_rpt_hdl(_adapter *adapter, u8 *data, u8 len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_LPS_ACK
|
||||||
|
/* C2H_LPS_STATUS_RPT, 0x32 */
|
||||||
|
#define LPS_STATUS_RPT_LEN 2
|
||||||
|
int c2h_lps_status_rpt(PADAPTER adapter, u8 *data, u8 len);
|
||||||
|
#endif /* CONFIG_LPS_ACK */
|
||||||
|
|
||||||
|
#ifdef CONFIG_FW_OFFLOAD_SET_TXPWR_IDX
|
||||||
|
/* C2H_SET_TXPWR_FINISH, 0x70 */
|
||||||
|
#define SET_TXPWR_FINISH_LEN 1
|
||||||
|
void c2h_txpwr_idx_offload_done(_adapter *adapter, u8 *data, u8 len);
|
||||||
|
int c2h_txpwr_idx_offload_wait(_adapter *adapter);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __COMMON_C2H_H__ */
|
||||||
6129
drivers/net/wireless/realtek/rtl8822ce/hal/hal_com_phycfg.c
Normal file
6129
drivers/net/wireless/realtek/rtl8822ce/hal/hal_com_phycfg.c
Normal file
File diff suppressed because it is too large
Load Diff
1861
drivers/net/wireless/realtek/rtl8822ce/hal/hal_dm.c
Normal file
1861
drivers/net/wireless/realtek/rtl8822ce/hal/hal_dm.c
Normal file
File diff suppressed because it is too large
Load Diff
118
drivers/net/wireless/realtek/rtl8822ce/hal/hal_dm.h
Normal file
118
drivers/net/wireless/realtek/rtl8822ce/hal/hal_dm.h
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __HAL_DM_H__
|
||||||
|
#define __HAL_DM_H__
|
||||||
|
|
||||||
|
#define adapter_to_phydm(adapter) (&(GET_HAL_DATA(adapter)->odmpriv))
|
||||||
|
#define dvobj_to_phydm(dvobj) adapter_to_phydm(dvobj_get_primary_adapter(dvobj))
|
||||||
|
#ifdef CONFIG_TDMADIG
|
||||||
|
void rtw_phydm_tdmadig(_adapter *adapter, u8 state);
|
||||||
|
#endif
|
||||||
|
void rtw_phydm_priv_init(_adapter *adapter);
|
||||||
|
void Init_ODM_ComInfo(_adapter *adapter);
|
||||||
|
void rtw_phydm_init(_adapter *adapter);
|
||||||
|
|
||||||
|
void rtw_hal_turbo_edca(_adapter *adapter);
|
||||||
|
u8 rtw_phydm_is_iqk_in_progress(_adapter *adapter);
|
||||||
|
|
||||||
|
void GetHalODMVar(
|
||||||
|
PADAPTER Adapter,
|
||||||
|
HAL_ODM_VARIABLE eVariable,
|
||||||
|
void *pValue1,
|
||||||
|
void *pValue2);
|
||||||
|
void SetHalODMVar(
|
||||||
|
PADAPTER Adapter,
|
||||||
|
HAL_ODM_VARIABLE eVariable,
|
||||||
|
void *pValue1,
|
||||||
|
BOOLEAN bSet);
|
||||||
|
|
||||||
|
void rtw_phydm_ra_registed(_adapter *adapter, struct sta_info *psta);
|
||||||
|
|
||||||
|
#ifdef CONFIG_DYNAMIC_SOML
|
||||||
|
void rtw_dyn_soml_byte_update(_adapter *adapter, u8 data_rate, u32 size);
|
||||||
|
void rtw_dyn_soml_para_set(_adapter *adapter, u8 train_num, u8 intvl,
|
||||||
|
u8 period, u8 delay);
|
||||||
|
void rtw_dyn_soml_config(_adapter *adapter);
|
||||||
|
#endif
|
||||||
|
void rtw_phydm_set_rrsr(_adapter *adapter, u32 rrsr_value, bool write_rrsr);
|
||||||
|
void rtw_phydm_dyn_rrsr_en(_adapter *adapter, bool en_rrsr);
|
||||||
|
void rtw_phydm_watchdog(_adapter *adapter, bool in_lps);
|
||||||
|
|
||||||
|
void rtw_hal_update_iqk_fw_offload_cap(_adapter *adapter);
|
||||||
|
void dump_sta_info(void *sel, struct sta_info *psta);
|
||||||
|
void dump_sta_traffic(void *sel, _adapter *adapter, struct sta_info *psta);
|
||||||
|
|
||||||
|
#ifdef CONFIG_DBG_RF_CAL
|
||||||
|
void rtw_hal_iqk_test(_adapter *adapter, bool recovery, bool clear, bool segment);
|
||||||
|
void rtw_hal_lck_test(_adapter *adapter);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
s8 rtw_dm_get_min_rssi(_adapter *adapter);
|
||||||
|
s8 rtw_phydm_get_min_rssi(_adapter *adapter);
|
||||||
|
u8 rtw_phydm_get_cur_igi(_adapter *adapter);
|
||||||
|
bool rtw_phydm_get_edcca_flag(_adapter *adapter);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_LPS_LCLK_WD_TIMER
|
||||||
|
extern void phydm_rssi_monitor_check(void *p_dm_void);
|
||||||
|
|
||||||
|
void rtw_phydm_wd_lps_lclk_hdl(_adapter *adapter);
|
||||||
|
void rtw_phydm_watchdog_in_lps_lclk(_adapter *adapter);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_TDMADIG
|
||||||
|
enum rtw_tdmadig_state{
|
||||||
|
TDMADIG_INIT,
|
||||||
|
TDMADIG_NON_INIT,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
enum phy_cnt {
|
||||||
|
FA_OFDM,
|
||||||
|
FA_CCK,
|
||||||
|
FA_TOTAL,
|
||||||
|
CCA_OFDM,
|
||||||
|
CCA_CCK,
|
||||||
|
CCA_ALL,
|
||||||
|
CRC32_OK_VHT,
|
||||||
|
CRC32_OK_HT,
|
||||||
|
CRC32_OK_LEGACY,
|
||||||
|
CRC32_OK_CCK,
|
||||||
|
CRC32_ERROR_VHT,
|
||||||
|
CRC32_ERROR_HT,
|
||||||
|
CRC32_ERROR_LEGACY,
|
||||||
|
CRC32_ERROR_CCK,
|
||||||
|
};
|
||||||
|
u32 rtw_phydm_get_phy_cnt(_adapter *adapter, enum phy_cnt cnt);
|
||||||
|
#if ((RTL8822B_SUPPORT == 1) || (RTL8821C_SUPPORT == 1) || (RTL8814B_SUPPORT == 1) || (RTL8822C_SUPPORT == 1))
|
||||||
|
void rtw_phydm_iqk_trigger(_adapter *adapter);
|
||||||
|
#endif
|
||||||
|
void rtw_phydm_read_efuse(_adapter *adapter);
|
||||||
|
bool rtw_phydm_set_crystal_cap(_adapter *adapter, u8 crystal_cap);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SUPPORT_DYNAMIC_TXPWR
|
||||||
|
void rtw_phydm_set_dyntxpwr(_adapter *adapter, u8 *desc, u8 mac_id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_LPS_PG
|
||||||
|
void rtw_phydm_lps_pg_hdl(_adapter *adapter, struct sta_info *sta, bool in_lpspg);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_LPS_PWR_TRACKING
|
||||||
|
void rtw_phydm_pwr_tracking_directly(_adapter *adapter);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CTRL_TXSS_BY_TP
|
||||||
|
void rtw_phydm_trx_cfg(_adapter *adapter, bool tx_1ss);
|
||||||
|
#endif
|
||||||
|
int rtw_phydm_rfe_ctrl_gpio(_adapter *adapter, u8 gpio_num);
|
||||||
|
#endif /* __HAL_DM_H__ */
|
||||||
554
drivers/net/wireless/realtek/rtl8822ce/hal/hal_dm_acs.c
Normal file
554
drivers/net/wireless/realtek/rtl8822ce/hal/hal_dm_acs.c
Normal file
@@ -0,0 +1,554 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2014 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <drv_types.h>
|
||||||
|
#include <hal_data.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTW_ACS) || defined(CONFIG_BACKGROUND_NOISE_MONITOR)
|
||||||
|
static void _rtw_bss_nums_count(_adapter *adapter, u8 *pbss_nums)
|
||||||
|
{
|
||||||
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
||||||
|
_queue *queue = &(pmlmepriv->scanned_queue);
|
||||||
|
struct wlan_network *pnetwork = NULL;
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
|
||||||
|
_list *plist, *phead;
|
||||||
|
_irqL irqL;
|
||||||
|
int chan_idx = -1;
|
||||||
|
|
||||||
|
if (pbss_nums == NULL) {
|
||||||
|
RTW_ERR("%s pbss_nums is null pointer\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_rtw_memset(pbss_nums, 0, MAX_CHANNEL_NUM);
|
||||||
|
|
||||||
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
||||||
|
phead = get_list_head(queue);
|
||||||
|
plist = get_next(phead);
|
||||||
|
while (1) {
|
||||||
|
if (rtw_end_of_queue_search(phead, plist) == _TRUE)
|
||||||
|
break;
|
||||||
|
|
||||||
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
||||||
|
if (!pnetwork)
|
||||||
|
break;
|
||||||
|
chan_idx = rtw_chset_search_ch(adapter_to_chset(adapter), pnetwork->network.Configuration.DSConfig);
|
||||||
|
if ((chan_idx == -1) || (chan_idx >= MAX_CHANNEL_NUM)) {
|
||||||
|
RTW_ERR("%s can't get chan_idx(CH:%d)\n",
|
||||||
|
__func__, pnetwork->network.Configuration.DSConfig);
|
||||||
|
chan_idx = 0;
|
||||||
|
}
|
||||||
|
/*if (pnetwork->network.Reserved[0] != BSS_TYPE_PROB_REQ)*/
|
||||||
|
|
||||||
|
pbss_nums[chan_idx]++;
|
||||||
|
|
||||||
|
plist = get_next(plist);
|
||||||
|
}
|
||||||
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 rtw_get_ch_num_by_idx(_adapter *adapter, u8 idx)
|
||||||
|
{
|
||||||
|
struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter);
|
||||||
|
RT_CHANNEL_INFO *pch_set = rfctl->channel_set;
|
||||||
|
u8 max_chan_nums = rfctl->max_chan_nums;
|
||||||
|
|
||||||
|
if (idx >= max_chan_nums)
|
||||||
|
return 0;
|
||||||
|
return pch_set[idx].ChannelNum;
|
||||||
|
}
|
||||||
|
#endif /*defined(CONFIG_RTW_ACS) || defined(CONFIG_BACKGROUND_NOISE_MONITOR)*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_ACS
|
||||||
|
void rtw_acs_version_dump(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
_RTW_PRINT_SEL(sel, "RTK_ACS VER_%d\n", RTK_ACS_VERSION);
|
||||||
|
}
|
||||||
|
u8 rtw_phydm_clm_ratio(_adapter *adapter)
|
||||||
|
{
|
||||||
|
struct dm_struct *phydm = adapter_to_phydm(adapter);
|
||||||
|
|
||||||
|
return phydm_cmn_info_query(phydm, (enum phydm_info_query) PHYDM_INFO_CLM_RATIO);
|
||||||
|
}
|
||||||
|
u8 rtw_phydm_nhm_ratio(_adapter *adapter)
|
||||||
|
{
|
||||||
|
struct dm_struct *phydm = adapter_to_phydm(adapter);
|
||||||
|
|
||||||
|
return phydm_cmn_info_query(phydm, (enum phydm_info_query) PHYDM_INFO_NHM_RATIO);
|
||||||
|
}
|
||||||
|
void rtw_acs_reset(_adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct auto_chan_sel *pacs = &hal_data->acs;
|
||||||
|
|
||||||
|
_rtw_memset(pacs, 0, sizeof(struct auto_chan_sel));
|
||||||
|
#ifdef CONFIG_RTW_ACS_DBG
|
||||||
|
rtw_acs_adv_reset(adapter);
|
||||||
|
#endif /*CONFIG_RTW_ACS_DBG*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_ACS_DBG
|
||||||
|
u8 rtw_is_acs_igi_valid(_adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct auto_chan_sel *pacs = &hal_data->acs;
|
||||||
|
|
||||||
|
if ((pacs->igi) && ((pacs->igi >= 0x1E) || (pacs->igi < 0x60)))
|
||||||
|
return _TRUE;
|
||||||
|
|
||||||
|
return _FALSE;
|
||||||
|
}
|
||||||
|
void rtw_acs_adv_setting(_adapter *adapter, RT_SCAN_TYPE scan_type, u16 scan_time, u8 igi, u8 bw)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct auto_chan_sel *pacs = &hal_data->acs;
|
||||||
|
struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
|
||||||
|
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
|
||||||
|
|
||||||
|
pacs->scan_type = scan_type;
|
||||||
|
pacs->scan_time = scan_time;
|
||||||
|
pacs->igi = igi;
|
||||||
|
pacs->bw = bw;
|
||||||
|
RTW_INFO("[ACS] ADV setting - scan_type:%c, ch_ms:%d(ms), igi:0x%02x, bw:%d\n",
|
||||||
|
pacs->scan_type ? 'A' : 'P', pacs->scan_time, pacs->igi, pacs->bw);
|
||||||
|
}
|
||||||
|
void rtw_acs_adv_reset(_adapter *adapter)
|
||||||
|
{
|
||||||
|
rtw_acs_adv_setting(adapter, SCAN_ACTIVE, 0, 0, 0);
|
||||||
|
}
|
||||||
|
#endif /*CONFIG_RTW_ACS_DBG*/
|
||||||
|
|
||||||
|
void rtw_acs_trigger(_adapter *adapter, u16 scan_time_ms, u8 scan_chan, enum NHM_PID pid)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct dm_struct *phydm = adapter_to_phydm(adapter);
|
||||||
|
#if (RTK_ACS_VERSION == 3)
|
||||||
|
struct clm_para_info clm_para;
|
||||||
|
struct nhm_para_info nhm_para;
|
||||||
|
struct env_trig_rpt trig_rpt;
|
||||||
|
|
||||||
|
scan_time_ms -= 10;
|
||||||
|
|
||||||
|
init_acs_clm(clm_para, scan_time_ms);
|
||||||
|
|
||||||
|
if (pid == NHM_PID_IEEE_11K_HIGH)
|
||||||
|
init_11K_high_nhm(nhm_para, scan_time_ms);
|
||||||
|
else if (pid == NHM_PID_IEEE_11K_LOW)
|
||||||
|
init_11K_low_nhm(nhm_para, scan_time_ms);
|
||||||
|
else
|
||||||
|
init_acs_nhm(nhm_para, scan_time_ms);
|
||||||
|
|
||||||
|
hal_data->acs.trig_rst = phydm_env_mntr_trigger(phydm, &nhm_para, &clm_para, &trig_rpt);
|
||||||
|
if (hal_data->acs.trig_rst == (NHM_SUCCESS | CLM_SUCCESS)) {
|
||||||
|
hal_data->acs.trig_rpt.clm_rpt_stamp = trig_rpt.clm_rpt_stamp;
|
||||||
|
hal_data->acs.trig_rpt.nhm_rpt_stamp = trig_rpt.nhm_rpt_stamp;
|
||||||
|
/*RTW_INFO("[ACS] trigger success (rst = 0x%02x, clm_stamp:%d, nhm_stamp:%d)\n",
|
||||||
|
hal_data->acs.trig_rst, hal_data->acs.trig_rpt.clm_rpt_stamp, hal_data->acs.trig_rpt.nhm_rpt_stamp);*/
|
||||||
|
} else
|
||||||
|
RTW_ERR("[ACS] trigger failed (rst = 0x%02x)\n", hal_data->acs.trig_rst);
|
||||||
|
#else
|
||||||
|
phydm_ccx_monitor_trigger(phydm, scan_time_ms);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
hal_data->acs.trigger_ch = scan_chan;
|
||||||
|
hal_data->acs.triggered = _TRUE;
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_ACS_DBG
|
||||||
|
RTW_INFO("[ACS] Trigger CH:%d, Times:%d\n", hal_data->acs.trigger_ch, scan_time_ms);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void rtw_acs_get_rst(_adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct dm_struct *phydm = adapter_to_phydm(adapter);
|
||||||
|
int chan_idx = -1;
|
||||||
|
u8 cur_chan = hal_data->acs.trigger_ch;
|
||||||
|
|
||||||
|
if (cur_chan == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!hal_data->acs.triggered)
|
||||||
|
return;
|
||||||
|
|
||||||
|
chan_idx = rtw_chset_search_ch(adapter_to_chset(adapter), cur_chan);
|
||||||
|
if ((chan_idx == -1) || (chan_idx >= MAX_CHANNEL_NUM)) {
|
||||||
|
RTW_ERR("[ACS] %s can't get chan_idx(CH:%d)\n", __func__, cur_chan);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if (RTK_ACS_VERSION == 3)
|
||||||
|
if (!(hal_data->acs.trig_rst == (NHM_SUCCESS | CLM_SUCCESS))) {
|
||||||
|
RTW_ERR("[ACS] get_rst return, due to acs trigger failed\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct env_mntr_rpt rpt = {0};
|
||||||
|
u8 rst;
|
||||||
|
|
||||||
|
rst = phydm_env_mntr_result(phydm, &rpt);
|
||||||
|
if ((rst == (NHM_SUCCESS | CLM_SUCCESS)) &&
|
||||||
|
(rpt.clm_rpt_stamp == hal_data->acs.trig_rpt.clm_rpt_stamp) &&
|
||||||
|
(rpt.nhm_rpt_stamp == hal_data->acs.trig_rpt.nhm_rpt_stamp)){
|
||||||
|
hal_data->acs.clm_ratio[chan_idx] = rpt.clm_ratio;
|
||||||
|
hal_data->acs.nhm_ratio[chan_idx] = rpt.nhm_ratio;
|
||||||
|
_rtw_memcpy(&hal_data->acs.nhm[chan_idx][0], rpt.nhm_result, NHM_RPT_NUM);
|
||||||
|
|
||||||
|
/*RTW_INFO("[ACS] get_rst success (rst = 0x%02x, clm_stamp:%d:%d, nhm_stamp:%d:%d)\n",
|
||||||
|
rst,
|
||||||
|
hal_data->acs.trig_rpt.clm_rpt_stamp, rpt.clm_rpt_stamp,
|
||||||
|
hal_data->acs.trig_rpt.nhm_rpt_stamp, rpt.nhm_rpt_stamp);*/
|
||||||
|
} else {
|
||||||
|
RTW_ERR("[ACS] get_rst failed (rst = 0x%02x, clm_stamp:%d:%d, nhm_stamp:%d:%d)\n",
|
||||||
|
rst,
|
||||||
|
hal_data->acs.trig_rpt.clm_rpt_stamp, rpt.clm_rpt_stamp,
|
||||||
|
hal_data->acs.trig_rpt.nhm_rpt_stamp, rpt.nhm_rpt_stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
phydm_ccx_monitor_result(phydm);
|
||||||
|
|
||||||
|
hal_data->acs.clm_ratio[chan_idx] = rtw_phydm_clm_ratio(adapter);
|
||||||
|
hal_data->acs.nhm_ratio[chan_idx] = rtw_phydm_nhm_ratio(adapter);
|
||||||
|
#endif
|
||||||
|
hal_data->acs.triggered = _FALSE;
|
||||||
|
#ifdef CONFIG_RTW_ACS_DBG
|
||||||
|
RTW_INFO("[ACS] Result CH:%d, CLM:%d NHM:%d\n",
|
||||||
|
cur_chan, hal_data->acs.clm_ratio[chan_idx], hal_data->acs.nhm_ratio[chan_idx]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void _rtw_phydm_acs_select_best_chan(_adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter);
|
||||||
|
u8 ch_idx;
|
||||||
|
u8 ch_idx_24g = 0xFF, ch_idx_5g = 0xFF;
|
||||||
|
u8 min_itf_24g = 0xFF, min_itf_5g = 0xFF;
|
||||||
|
u8 *pbss_nums = hal_data->acs.bss_nums;
|
||||||
|
u8 *pclm_ratio = hal_data->acs.clm_ratio;
|
||||||
|
u8 *pnhm_ratio = hal_data->acs.nhm_ratio;
|
||||||
|
u8 *pinterference_time = hal_data->acs.interference_time;
|
||||||
|
u8 max_chan_nums = rfctl->max_chan_nums;
|
||||||
|
|
||||||
|
for (ch_idx = 0; ch_idx < max_chan_nums; ch_idx++) {
|
||||||
|
if (pbss_nums[ch_idx])
|
||||||
|
pinterference_time[ch_idx] = (pclm_ratio[ch_idx] / 2) + pnhm_ratio[ch_idx];
|
||||||
|
else
|
||||||
|
pinterference_time[ch_idx] = pclm_ratio[ch_idx] + pnhm_ratio[ch_idx];
|
||||||
|
|
||||||
|
if (rtw_get_ch_num_by_idx(adapter, ch_idx) < 14) {
|
||||||
|
if (pinterference_time[ch_idx] < min_itf_24g) {
|
||||||
|
min_itf_24g = pinterference_time[ch_idx];
|
||||||
|
ch_idx_24g = ch_idx;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (pinterference_time[ch_idx] < min_itf_5g) {
|
||||||
|
min_itf_5g = pinterference_time[ch_idx];
|
||||||
|
ch_idx_5g = ch_idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ch_idx_24g != 0xFF)
|
||||||
|
hal_data->acs.best_chan_24g = rtw_get_ch_num_by_idx(adapter, ch_idx_24g);
|
||||||
|
|
||||||
|
if (ch_idx_5g != 0xFF)
|
||||||
|
hal_data->acs.best_chan_5g = rtw_get_ch_num_by_idx(adapter, ch_idx_5g);
|
||||||
|
|
||||||
|
hal_data->acs.trigger_ch = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_acs_info_dump(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter);
|
||||||
|
u8 max_chan_nums = rfctl->max_chan_nums;
|
||||||
|
u8 ch_idx, ch_num;
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "========== ACS (VER-%d) ==========\n", RTK_ACS_VERSION);
|
||||||
|
_RTW_PRINT_SEL(sel, "Best 24G Channel:%d\n", hal_data->acs.best_chan_24g);
|
||||||
|
_RTW_PRINT_SEL(sel, "Best 5G Channel:%d\n\n", hal_data->acs.best_chan_5g);
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_ACS_DBG
|
||||||
|
_RTW_PRINT_SEL(sel, "Advanced setting - scan_type:%c, ch_ms:%d(ms), igi:0x%02x, bw:%d\n",
|
||||||
|
hal_data->acs.scan_type ? 'A' : 'P', hal_data->acs.scan_time, hal_data->acs.igi, hal_data->acs.bw);
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "BW 20MHz\n");
|
||||||
|
_RTW_PRINT_SEL(sel, "%5s %3s %3s %3s(%%) %3s(%%) %3s\n",
|
||||||
|
"Index", "CH", "BSS", "CLM", "NHM", "ITF");
|
||||||
|
|
||||||
|
for (ch_idx = 0; ch_idx < max_chan_nums; ch_idx++) {
|
||||||
|
ch_num = rtw_get_ch_num_by_idx(adapter, ch_idx);
|
||||||
|
_RTW_PRINT_SEL(sel, "%5d %3d %3d %6d %6d %3d\n",
|
||||||
|
ch_idx, ch_num, hal_data->acs.bss_nums[ch_idx],
|
||||||
|
hal_data->acs.clm_ratio[ch_idx],
|
||||||
|
hal_data->acs.nhm_ratio[ch_idx],
|
||||||
|
hal_data->acs.interference_time[ch_idx]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void rtw_acs_select_best_chan(_adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
|
||||||
|
_rtw_bss_nums_count(adapter, hal_data->acs.bss_nums);
|
||||||
|
_rtw_phydm_acs_select_best_chan(adapter);
|
||||||
|
rtw_acs_info_dump(RTW_DBGDUMP, adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_acs_start(_adapter *adapter)
|
||||||
|
{
|
||||||
|
rtw_acs_reset(adapter);
|
||||||
|
if (GET_ACS_STATE(adapter) != ACS_ENABLE)
|
||||||
|
SET_ACS_STATE(adapter, ACS_ENABLE);
|
||||||
|
}
|
||||||
|
void rtw_acs_stop(_adapter *adapter)
|
||||||
|
{
|
||||||
|
SET_ACS_STATE(adapter, ACS_DISABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u8 rtw_acs_get_clm_ratio_by_ch_num(_adapter *adapter, u8 chan)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
int chan_idx = -1;
|
||||||
|
|
||||||
|
chan_idx = rtw_chset_search_ch(adapter_to_chset(adapter), chan);
|
||||||
|
if ((chan_idx == -1) || (chan_idx >= MAX_CHANNEL_NUM)) {
|
||||||
|
RTW_ERR("[ACS] Get CLM fail, can't get chan_idx(CH:%d)\n", chan);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hal_data->acs.clm_ratio[chan_idx];
|
||||||
|
}
|
||||||
|
u8 rtw_acs_get_clm_ratio_by_ch_idx(_adapter *adapter, u8 ch_idx)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
|
||||||
|
if (ch_idx >= MAX_CHANNEL_NUM) {
|
||||||
|
RTW_ERR("%s [ACS] ch_idx(%d) is invalid\n", __func__, ch_idx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hal_data->acs.clm_ratio[ch_idx];
|
||||||
|
}
|
||||||
|
u8 rtw_acs_get_nhm_ratio_by_ch_num(_adapter *adapter, u8 chan)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
int chan_idx = -1;
|
||||||
|
|
||||||
|
chan_idx = rtw_chset_search_ch(adapter_to_chset(adapter), chan);
|
||||||
|
if ((chan_idx == -1) || (chan_idx >= MAX_CHANNEL_NUM)) {
|
||||||
|
RTW_ERR("[ACS] Get NHM fail, can't get chan_idx(CH:%d)\n", chan);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hal_data->acs.nhm_ratio[chan_idx];
|
||||||
|
}
|
||||||
|
u8 rtw_acs_get_num_ratio_by_ch_idx(_adapter *adapter, u8 ch_idx)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
|
||||||
|
if (ch_idx >= MAX_CHANNEL_NUM) {
|
||||||
|
RTW_ERR("%s [ACS] ch_idx(%d) is invalid\n", __func__, ch_idx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hal_data->acs.nhm_ratio[ch_idx];
|
||||||
|
}
|
||||||
|
void rtw_acs_chan_info_dump(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter);
|
||||||
|
u8 max_chan_nums = rfctl->max_chan_nums;
|
||||||
|
u8 ch_idx, ch_num;
|
||||||
|
u8 utilization;
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "BW 20MHz\n");
|
||||||
|
_RTW_PRINT_SEL(sel, "%5s %3s %7s(%%) %12s(%%) %11s(%%) %9s(%%) %8s(%%)\n",
|
||||||
|
"Index", "CH", "Quality", "Availability", "Utilization",
|
||||||
|
"WIFI Util", "Interference Util");
|
||||||
|
|
||||||
|
for (ch_idx = 0; ch_idx < max_chan_nums; ch_idx++) {
|
||||||
|
ch_num = rtw_get_ch_num_by_idx(adapter, ch_idx);
|
||||||
|
utilization = hal_data->acs.clm_ratio[ch_idx] + hal_data->acs.nhm_ratio[ch_idx];
|
||||||
|
_RTW_PRINT_SEL(sel, "%5d %3d %7d %12d %12d %12d %12d\n",
|
||||||
|
ch_idx, ch_num,
|
||||||
|
(100-hal_data->acs.interference_time[ch_idx]),
|
||||||
|
(100-utilization),
|
||||||
|
utilization,
|
||||||
|
hal_data->acs.clm_ratio[ch_idx],
|
||||||
|
hal_data->acs.nhm_ratio[ch_idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void rtw_acs_current_info_dump(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
u8 ch, cen_ch, bw, offset;
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "========== ACS (VER-%d) ==========\n", RTK_ACS_VERSION);
|
||||||
|
|
||||||
|
ch = rtw_get_oper_ch(adapter);
|
||||||
|
bw = rtw_get_oper_bw(adapter);
|
||||||
|
offset = rtw_get_oper_choffset(adapter);
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "Current Channel:%d\n", ch);
|
||||||
|
if ((bw == CHANNEL_WIDTH_80) ||(bw == CHANNEL_WIDTH_40)) {
|
||||||
|
cen_ch = rtw_get_center_ch(ch, bw, offset);
|
||||||
|
_RTW_PRINT_SEL(sel, "Center Channel:%d\n", cen_ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "Current BW %s\n", ch_width_str(bw));
|
||||||
|
if (0)
|
||||||
|
_RTW_PRINT_SEL(sel, "Current IGI 0x%02x\n", rtw_phydm_get_cur_igi(adapter));
|
||||||
|
_RTW_PRINT_SEL(sel, "CLM:%d, NHM:%d\n\n",
|
||||||
|
hal_data->acs.cur_ch_clm_ratio, hal_data->acs.cur_ch_nhm_ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_acs_update_current_info(_adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
|
||||||
|
hal_data->acs.cur_ch_clm_ratio = rtw_phydm_clm_ratio(adapter);
|
||||||
|
hal_data->acs.cur_ch_nhm_ratio = rtw_phydm_nhm_ratio(adapter);
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_ACS_DBG
|
||||||
|
rtw_acs_current_info_dump(RTW_DBGDUMP, adapter);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif /*CONFIG_RTW_ACS*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_BACKGROUND_NOISE_MONITOR
|
||||||
|
void rtw_noise_monitor_version_dump(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
_RTW_PRINT_SEL(sel, "RTK_NOISE_MONITOR VER_%d\n", RTK_NOISE_MONITOR_VERSION);
|
||||||
|
}
|
||||||
|
void rtw_nm_enable(_adapter *adapter)
|
||||||
|
{
|
||||||
|
SET_NM_STATE(adapter, NM_ENABLE);
|
||||||
|
}
|
||||||
|
void rtw_nm_disable(_adapter *adapter)
|
||||||
|
{
|
||||||
|
SET_NM_STATE(adapter, NM_DISABLE);
|
||||||
|
}
|
||||||
|
void rtw_noise_info_dump(void *sel, _adapter *adapter)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter);
|
||||||
|
u8 max_chan_nums = rfctl->max_chan_nums;
|
||||||
|
u8 ch_idx, ch_num;
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "========== NM (VER-%d) ==========\n", RTK_NOISE_MONITOR_VERSION);
|
||||||
|
|
||||||
|
_RTW_PRINT_SEL(sel, "%5s %3s %3s %10s", "Index", "CH", "BSS", "Noise(dBm)\n");
|
||||||
|
|
||||||
|
_rtw_bss_nums_count(adapter, hal_data->nm.bss_nums);
|
||||||
|
|
||||||
|
for (ch_idx = 0; ch_idx < max_chan_nums; ch_idx++) {
|
||||||
|
ch_num = rtw_get_ch_num_by_idx(adapter, ch_idx);
|
||||||
|
_RTW_PRINT_SEL(sel, "%5d %3d %3d %10d\n",
|
||||||
|
ch_idx, ch_num, hal_data->nm.bss_nums[ch_idx],
|
||||||
|
hal_data->nm.noise[ch_idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw_noise_measure(_adapter *adapter, u8 chan, u8 is_pause_dig, u8 igi_value, u32 max_time)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
struct dm_struct *phydm = &hal_data->odmpriv;
|
||||||
|
int chan_idx = -1;
|
||||||
|
s16 noise = 0;
|
||||||
|
|
||||||
|
#ifdef DBG_NOISE_MONITOR
|
||||||
|
RTW_INFO("[NM] chan(%d)-PauseDIG:%s, IGIValue:0x%02x, max_time:%d (ms)\n",
|
||||||
|
chan, (is_pause_dig) ? "Y" : "N", igi_value, max_time);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
chan_idx = rtw_chset_search_ch(adapter_to_chset(adapter), chan);
|
||||||
|
if ((chan_idx == -1) || (chan_idx >= MAX_CHANNEL_NUM)) {
|
||||||
|
RTW_ERR("[NM] Get noise fail, can't get chan_idx(CH:%d)\n", chan);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
noise = odm_inband_noise_monitor(phydm, is_pause_dig, igi_value, max_time); /*dBm*/
|
||||||
|
|
||||||
|
hal_data->nm.noise[chan_idx] = noise;
|
||||||
|
|
||||||
|
#ifdef DBG_NOISE_MONITOR
|
||||||
|
RTW_INFO("[NM] %s chan_%d, noise = %d (dBm)\n", __func__, chan, hal_data->nm.noise[chan_idx]);
|
||||||
|
|
||||||
|
RTW_INFO("[NM] noise_a = %d, noise_b = %d noise_all:%d\n",
|
||||||
|
phydm->noise_level.noise[RF_PATH_A],
|
||||||
|
phydm->noise_level.noise[RF_PATH_B],
|
||||||
|
phydm->noise_level.noise_all);
|
||||||
|
#endif /*DBG_NOISE_MONITOR*/
|
||||||
|
}
|
||||||
|
|
||||||
|
s16 rtw_noise_query_by_chan_num(_adapter *adapter, u8 chan)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
s16 noise = 0;
|
||||||
|
int chan_idx = -1;
|
||||||
|
|
||||||
|
chan_idx = rtw_chset_search_ch(adapter_to_chset(adapter), chan);
|
||||||
|
if ((chan_idx == -1) || (chan_idx >= MAX_CHANNEL_NUM)) {
|
||||||
|
RTW_ERR("[NM] Get noise fail, can't get chan_idx(CH:%d)\n", chan);
|
||||||
|
return noise;
|
||||||
|
}
|
||||||
|
noise = hal_data->nm.noise[chan_idx];
|
||||||
|
|
||||||
|
#ifdef DBG_NOISE_MONITOR
|
||||||
|
RTW_INFO("[NM] %s chan_%d, noise = %d (dBm)\n", __func__, chan, noise);
|
||||||
|
#endif/*DBG_NOISE_MONITOR*/
|
||||||
|
return noise;
|
||||||
|
}
|
||||||
|
s16 rtw_noise_query_by_chan_idx(_adapter *adapter, u8 ch_idx)
|
||||||
|
{
|
||||||
|
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);
|
||||||
|
s16 noise = 0;
|
||||||
|
|
||||||
|
if (ch_idx >= MAX_CHANNEL_NUM) {
|
||||||
|
RTW_ERR("[NM] %s ch_idx(%d) is invalid\n", __func__, ch_idx);
|
||||||
|
return noise;
|
||||||
|
}
|
||||||
|
noise = hal_data->nm.noise[ch_idx];
|
||||||
|
|
||||||
|
#ifdef DBG_NOISE_MONITOR
|
||||||
|
RTW_INFO("[NM] %s ch_idx %d, noise = %d (dBm)\n", __func__, ch_idx, noise);
|
||||||
|
#endif/*DBG_NOISE_MONITOR*/
|
||||||
|
return noise;
|
||||||
|
}
|
||||||
|
|
||||||
|
s16 rtw_noise_measure_curchan(_adapter *padapter)
|
||||||
|
{
|
||||||
|
s16 noise = 0;
|
||||||
|
u8 igi_value = 0x1E;
|
||||||
|
u32 max_time = 100;/* ms */
|
||||||
|
u8 is_pause_dig = _TRUE;
|
||||||
|
u8 cur_chan = rtw_get_oper_ch(padapter);
|
||||||
|
|
||||||
|
if (rtw_linked_check(padapter) == _FALSE)
|
||||||
|
return noise;
|
||||||
|
|
||||||
|
rtw_ps_deny(padapter, PS_DENY_IOCTL);
|
||||||
|
LeaveAllPowerSaveModeDirect(padapter);
|
||||||
|
rtw_noise_measure(padapter, cur_chan, is_pause_dig, igi_value, max_time);
|
||||||
|
noise = rtw_noise_query_by_chan_num(padapter, cur_chan);
|
||||||
|
rtw_ps_deny_cancel(padapter, PS_DENY_IOCTL);
|
||||||
|
|
||||||
|
return noise;
|
||||||
|
}
|
||||||
|
#endif /*CONFIG_BACKGROUND_NOISE_MONITOR*/
|
||||||
|
|
||||||
167
drivers/net/wireless/realtek/rtl8822ce/hal/hal_dm_acs.h
Normal file
167
drivers/net/wireless/realtek/rtl8822ce/hal/hal_dm_acs.h
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __HAL_DM_ACS_H__
|
||||||
|
#define __HAL_DM_ACS_H__
|
||||||
|
#ifdef CONFIG_RTW_ACS
|
||||||
|
#define RTK_ACS_VERSION 3
|
||||||
|
|
||||||
|
#if (RTK_ACS_VERSION == 3)
|
||||||
|
enum NHM_PID {
|
||||||
|
NHM_PID_ACS,
|
||||||
|
NHM_PID_IEEE_11K_HIGH,
|
||||||
|
NHM_PID_IEEE_11K_LOW,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define init_clm_param(clm, app, lv, time) \
|
||||||
|
do {\
|
||||||
|
clm.clm_app = app;\
|
||||||
|
clm.clm_lv = lv;\
|
||||||
|
clm.mntr_time = time;\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define init_nhm_param(nhm, txon, cca, cnt_opt, app, lv, time) \
|
||||||
|
do {\
|
||||||
|
nhm.incld_txon = txon;\
|
||||||
|
nhm.incld_cca = cca;\
|
||||||
|
nhm.div_opt = cnt_opt;\
|
||||||
|
nhm.nhm_app = app;\
|
||||||
|
nhm.nhm_lv = lv;\
|
||||||
|
nhm.mntr_time = time;\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
#define init_acs_clm(clm, time) \
|
||||||
|
init_clm_param(clm, CLM_ACS, CLM_LV_2, time)
|
||||||
|
|
||||||
|
#define init_acs_nhm(nhm, time) \
|
||||||
|
init_nhm_param(nhm, NHM_EXCLUDE_TXON, NHM_EXCLUDE_CCA, NHM_CNT_ALL, NHM_ACS, NHM_LV_2, time)
|
||||||
|
|
||||||
|
#define init_11K_high_nhm(nhm, time) \
|
||||||
|
init_nhm_param(nhm, NHM_EXCLUDE_TXON, NHM_EXCLUDE_CCA, NHM_CNT_ALL, IEEE_11K_HIGH, NHM_LV_2, time)
|
||||||
|
|
||||||
|
#define init_11K_low_nhm(nhm, time) \
|
||||||
|
init_nhm_param(nhm, NHM_EXCLUDE_TXON, NHM_EXCLUDE_CCA, NHM_CNT_ALL, IEEE_11K_LOW, NHM_LV_2, time)
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*(RTK_ACS_VERSION == 3)*/
|
||||||
|
void rtw_acs_version_dump(void *sel, _adapter *adapter);
|
||||||
|
extern void phydm_ccx_monitor_trigger(void *p_dm_void, u16 monitor_time);
|
||||||
|
extern void phydm_ccx_monitor_result(void *p_dm_void);
|
||||||
|
|
||||||
|
#define GET_ACS_STATE(padapter) (ATOMIC_READ(&GET_HAL_DATA(padapter)->acs.state))
|
||||||
|
#define SET_ACS_STATE(padapter, set_state) (ATOMIC_SET(&GET_HAL_DATA(padapter)->acs.state, set_state))
|
||||||
|
#define IS_ACS_ENABLE(padapter) ((GET_ACS_STATE(padapter) == ACS_ENABLE) ? _TRUE : _FALSE)
|
||||||
|
|
||||||
|
enum ACS_STATE {
|
||||||
|
ACS_DISABLE,
|
||||||
|
ACS_ENABLE,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ACS_BW_20M BIT(0)
|
||||||
|
#define ACS_BW_40M BIT(1)
|
||||||
|
#define ACS_BW_80M BIT(2)
|
||||||
|
#define ACS_BW_160M BIT(3)
|
||||||
|
|
||||||
|
struct auto_chan_sel {
|
||||||
|
ATOMIC_T state;
|
||||||
|
u8 trigger_ch;
|
||||||
|
bool triggered;
|
||||||
|
u8 clm_ratio[MAX_CHANNEL_NUM];
|
||||||
|
u8 nhm_ratio[MAX_CHANNEL_NUM];
|
||||||
|
#if (RTK_ACS_VERSION == 3)
|
||||||
|
u8 nhm[MAX_CHANNEL_NUM][NHM_RPT_NUM];
|
||||||
|
#endif
|
||||||
|
u8 bss_nums[MAX_CHANNEL_NUM];
|
||||||
|
u8 interference_time[MAX_CHANNEL_NUM];
|
||||||
|
u8 cur_ch_clm_ratio;
|
||||||
|
u8 cur_ch_nhm_ratio;
|
||||||
|
u8 best_chan_5g;
|
||||||
|
u8 best_chan_24g;
|
||||||
|
|
||||||
|
#if (RTK_ACS_VERSION == 3)
|
||||||
|
u8 trig_rst;
|
||||||
|
struct env_trig_rpt trig_rpt;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_ACS_DBG
|
||||||
|
RT_SCAN_TYPE scan_type;
|
||||||
|
u16 scan_time;
|
||||||
|
u8 igi;
|
||||||
|
u8 bw;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#define rtw_acs_get_best_chan_24g(adapter) (GET_HAL_DATA(adapter)->acs.best_chan_24g)
|
||||||
|
#define rtw_acs_get_best_chan_5g(adapter) (GET_HAL_DATA(adapter)->acs.best_chan_5g)
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTW_ACS_DBG
|
||||||
|
#define rtw_is_acs_passiv_scan(adapter) (((GET_HAL_DATA(adapter)->acs.scan_type) == SCAN_PASSIVE) ? _TRUE : _FALSE)
|
||||||
|
|
||||||
|
#define rtw_acs_get_adv_st(adapter) (GET_HAL_DATA(adapter)->acs.scan_time)
|
||||||
|
#define rtw_is_acs_st_valid(adapter) ((GET_HAL_DATA(adapter)->acs.scan_time) ? _TRUE : _FALSE)
|
||||||
|
|
||||||
|
#define rtw_acs_get_adv_igi(adapter) (GET_HAL_DATA(adapter)->acs.igi)
|
||||||
|
u8 rtw_is_acs_igi_valid(_adapter *adapter);
|
||||||
|
|
||||||
|
#define rtw_acs_get_adv_bw(adapter) (GET_HAL_DATA(adapter)->acs.bw)
|
||||||
|
|
||||||
|
void rtw_acs_adv_setting(_adapter *adapter, RT_SCAN_TYPE scan_type, u16 scan_time, u8 igi, u8 bw);
|
||||||
|
void rtw_acs_adv_reset(_adapter *adapter);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
u8 rtw_acs_get_clm_ratio_by_ch_num(_adapter *adapter, u8 chan);
|
||||||
|
u8 rtw_acs_get_clm_ratio_by_ch_idx(_adapter *adapter, u8 ch_idx);
|
||||||
|
u8 rtw_acs_get_nhm_ratio_by_ch_num(_adapter *adapter, u8 chan);
|
||||||
|
u8 rtw_acs_get_num_ratio_by_ch_idx(_adapter *adapter, u8 ch_idx);
|
||||||
|
|
||||||
|
void rtw_acs_reset(_adapter *adapter);
|
||||||
|
void rtw_acs_trigger(_adapter *adapter, u16 scan_time_ms, u8 scan_chan, enum NHM_PID pid);
|
||||||
|
void rtw_acs_get_rst(_adapter *adapter);
|
||||||
|
void rtw_acs_select_best_chan(_adapter *adapter);
|
||||||
|
void rtw_acs_info_dump(void *sel, _adapter *adapter);
|
||||||
|
void rtw_acs_update_current_info(_adapter *adapter);
|
||||||
|
void rtw_acs_chan_info_dump(void *sel, _adapter *adapter);
|
||||||
|
void rtw_acs_current_info_dump(void *sel, _adapter *adapter);
|
||||||
|
|
||||||
|
void rtw_acs_start(_adapter *adapter);
|
||||||
|
void rtw_acs_stop(_adapter *adapter);
|
||||||
|
|
||||||
|
#endif /*CONFIG_RTW_ACS*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_BACKGROUND_NOISE_MONITOR
|
||||||
|
#define RTK_NOISE_MONITOR_VERSION 3
|
||||||
|
#define GET_NM_STATE(padapter) (ATOMIC_READ(&GET_HAL_DATA(padapter)->nm.state))
|
||||||
|
#define SET_NM_STATE(padapter, set_state) (ATOMIC_SET(&GET_HAL_DATA(padapter)->nm.state, set_state))
|
||||||
|
#define IS_NM_ENABLE(padapter) ((GET_NM_STATE(padapter) == NM_ENABLE) ? _TRUE : _FALSE)
|
||||||
|
|
||||||
|
enum NM_STATE {
|
||||||
|
NM_DISABLE,
|
||||||
|
NM_ENABLE,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct noise_monitor {
|
||||||
|
ATOMIC_T state;
|
||||||
|
s16 noise[MAX_CHANNEL_NUM];
|
||||||
|
u8 bss_nums[MAX_CHANNEL_NUM];
|
||||||
|
};
|
||||||
|
void rtw_nm_enable(_adapter *adapter);
|
||||||
|
void rtw_nm_disable(_adapter *adapter);
|
||||||
|
void rtw_noise_measure(_adapter *adapter, u8 chan, u8 is_pause_dig, u8 igi_value, u32 max_time);
|
||||||
|
s16 rtw_noise_query_by_chan_num(_adapter *adapter, u8 chan);
|
||||||
|
s16 rtw_noise_query_by_chan_idx(_adapter *adapter, u8 ch_idx);
|
||||||
|
s16 rtw_noise_measure_curchan(_adapter *padapter);
|
||||||
|
void rtw_noise_info_dump(void *sel, _adapter *adapter);
|
||||||
|
#endif
|
||||||
|
#endif /* __HAL_DM_ACS_H__ */
|
||||||
5901
drivers/net/wireless/realtek/rtl8822ce/hal/hal_halmac.c
Normal file
5901
drivers/net/wireless/realtek/rtl8822ce/hal/hal_halmac.c
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user