2012-06-19 17:15:42 -06:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
(c) Cambridge Silicon Radio Limited 2011
|
|
|
|
All rights reserved and confidential information of CSR
|
|
|
|
|
|
|
|
Refer to LICENSE.txt included with this source for details
|
|
|
|
on the license terms.
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
2012-07-20 17:41:09 -06:00
|
|
|
#include <linux/slab.h>
|
2012-07-20 16:14:52 -06:00
|
|
|
#include "csr_macro.h"
|
2012-06-19 17:15:42 -06:00
|
|
|
#include "csr_msgconv.h"
|
|
|
|
#include "csr_wifi_msgconv.h"
|
|
|
|
#include "csr_wifi_lib.h"
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 13:05:42 -06:00
|
|
|
u32 val;
|
2012-06-19 17:15:42 -06:00
|
|
|
|
|
|
|
val = ((buffer[(*offset) + 2] << 16) |
|
|
|
|
(buffer[(*offset) + 1] << 8) |
|
|
|
|
(buffer[(*offset)]));
|
|
|
|
|
|
|
|
*offset += 3;
|
|
|
|
*v = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Big endian :e.g WSC, TCLAS */
|
2012-07-20 13:27:19 -06:00
|
|
|
void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 13:00:10 -06:00
|
|
|
u16 val;
|
2012-06-19 17:15:42 -06:00
|
|
|
|
|
|
|
val = (buffer[(*offset)] << 8) | (buffer[(*offset) + 1]);
|
|
|
|
*offset += 2;
|
|
|
|
|
|
|
|
*v = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 13:05:42 -06:00
|
|
|
u32 val;
|
2012-06-19 17:15:42 -06:00
|
|
|
|
|
|
|
val = ((buffer[(*offset)] << 16) |
|
|
|
|
(buffer[(*offset) + 1] << 8) |
|
|
|
|
(buffer[(*offset) + 2]));
|
|
|
|
|
|
|
|
*offset += 3;
|
|
|
|
*v = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 13:05:42 -06:00
|
|
|
u32 val;
|
2012-06-19 17:15:42 -06:00
|
|
|
|
|
|
|
val = ((buffer[(*offset)] << 24) |
|
|
|
|
(buffer[(*offset) + 1] << 16) |
|
|
|
|
(buffer[(*offset) + 2] << 8) |
|
|
|
|
(buffer[(*offset) + 3]));
|
|
|
|
|
|
|
|
*offset += 4;
|
|
|
|
*v = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void CsrUint24Ser(u8 *ptr, size_t *len, u32 v)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 12:51:01 -06:00
|
|
|
ptr[(*len) + 2] = (u8)((v & 0x00ff0000) >> 16);
|
|
|
|
ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8);
|
|
|
|
ptr[(*len)] = (u8)((v & 0x000000ff));
|
2012-06-19 17:15:42 -06:00
|
|
|
|
|
|
|
*len += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Big endian :e.g WSC, TCLAS */
|
2012-07-20 13:27:19 -06:00
|
|
|
void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 12:51:01 -06:00
|
|
|
ptr[(*len)] = (u8)((v & 0xff00) >> 8);
|
|
|
|
ptr[(*len) + 1] = (u8)((v & 0x00ff));
|
2012-06-19 17:15:42 -06:00
|
|
|
|
|
|
|
*len += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 12:51:01 -06:00
|
|
|
ptr[(*len)] = (u8)((v & 0xff000000) >> 24);
|
|
|
|
ptr[(*len) + 1] = (u8)((v & 0x00ff0000) >> 16);
|
|
|
|
ptr[(*len) + 2] = (u8)((v & 0x0000ff00) >> 8);
|
|
|
|
ptr[(*len) + 3] = (u8)((v & 0x000000ff));
|
2012-06-19 17:15:42 -06:00
|
|
|
|
|
|
|
*len += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 12:51:01 -06:00
|
|
|
ptr[(*len)] = (u8)((v & 0x00ff0000) >> 16);
|
|
|
|
ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8);
|
|
|
|
ptr[(*len) + 2] = (u8)((v & 0x000000ff));
|
2012-06-19 17:15:42 -06:00
|
|
|
|
|
|
|
*len += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t CsrWifiEventSizeof(void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventSizeof);
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
CsrWifiFsmEvent *primitive = (CsrWifiFsmEvent *)msg;
|
|
|
|
*len = 0;
|
|
|
|
CsrUint16Ser(ptr, len, primitive->type);
|
|
|
|
return(ptr);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventSer);
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void* CsrWifiEventDes(u8 *buffer, size_t length)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 17:41:09 -06:00
|
|
|
CsrWifiFsmEvent *primitive = kmalloc(sizeof(CsrWifiFsmEvent), GFP_KERNEL);
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t offset = 0;
|
2012-06-19 17:15:42 -06:00
|
|
|
CsrUint16Des(&primitive->type, buffer, &offset);
|
|
|
|
|
|
|
|
return primitive;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventDes);
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t CsrWifiEventCsrUint8Sizeof(void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Sizeof);
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
CsrWifiEventCsrUint8 *primitive = (CsrWifiEventCsrUint8 *)msg;
|
|
|
|
*len = 0;
|
|
|
|
CsrUint16Ser(ptr, len, primitive->common.type);
|
|
|
|
CsrUint8Ser(ptr, len, primitive->value);
|
|
|
|
return(ptr);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Ser);
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 17:41:09 -06:00
|
|
|
CsrWifiEventCsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint8), GFP_KERNEL);
|
2012-06-19 17:15:42 -06:00
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t offset = 0;
|
2012-06-19 17:15:42 -06:00
|
|
|
CsrUint16Des(&primitive->common.type, buffer, &offset);
|
|
|
|
CsrUint8Des(&primitive->value, buffer, &offset);
|
|
|
|
|
|
|
|
return primitive;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Des);
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t CsrWifiEventCsrUint16Sizeof(void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Sizeof);
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
CsrWifiEventCsrUint16 *primitive = (CsrWifiEventCsrUint16 *)msg;
|
|
|
|
*len = 0;
|
|
|
|
CsrUint16Ser(ptr, len, primitive->common.type);
|
|
|
|
CsrUint16Ser(ptr, len, primitive->value);
|
|
|
|
return(ptr);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Ser);
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 17:41:09 -06:00
|
|
|
CsrWifiEventCsrUint16 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16), GFP_KERNEL);
|
2012-06-19 17:15:42 -06:00
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t offset = 0;
|
2012-06-19 17:15:42 -06:00
|
|
|
CsrUint16Des(&primitive->common.type, buffer, &offset);
|
|
|
|
CsrUint16Des(&primitive->value, buffer, &offset);
|
|
|
|
|
|
|
|
return primitive;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Des);
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t CsrWifiEventCsrUint32Sizeof(void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Sizeof);
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
CsrWifiEventCsrUint32 *primitive = (CsrWifiEventCsrUint32 *)msg;
|
|
|
|
*len = 0;
|
|
|
|
CsrUint16Ser(ptr, len, primitive->common.type);
|
|
|
|
CsrUint32Ser(ptr, len, primitive->value);
|
|
|
|
return(ptr);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Ser);
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 17:41:09 -06:00
|
|
|
CsrWifiEventCsrUint32 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint32), GFP_KERNEL);
|
2012-06-19 17:15:42 -06:00
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t offset = 0;
|
2012-06-19 17:15:42 -06:00
|
|
|
CsrUint16Des(&primitive->common.type, buffer, &offset);
|
|
|
|
CsrUint32Des(&primitive->value, buffer, &offset);
|
|
|
|
|
|
|
|
return primitive;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Des);
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Sizeof);
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
|
|
|
CsrWifiEventCsrUint16CsrUint8 *primitive = (CsrWifiEventCsrUint16CsrUint8 *)msg;
|
|
|
|
*len = 0;
|
|
|
|
CsrUint16Ser(ptr, len, primitive->common.type);
|
|
|
|
CsrUint16Ser(ptr, len, primitive->value16);
|
|
|
|
CsrUint8Ser(ptr, len, primitive->value8);
|
|
|
|
return(ptr);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Ser);
|
|
|
|
|
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 17:41:09 -06:00
|
|
|
CsrWifiEventCsrUint16CsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16CsrUint8), GFP_KERNEL);
|
2012-06-19 17:15:42 -06:00
|
|
|
|
2012-07-20 13:27:19 -06:00
|
|
|
size_t offset = 0;
|
2012-06-19 17:15:42 -06:00
|
|
|
CsrUint16Des(&primitive->common.type, buffer, &offset);
|
|
|
|
CsrUint16Des(&primitive->value16, buffer, &offset);
|
|
|
|
CsrUint8Des(&primitive->value8, buffer, &offset);
|
|
|
|
|
|
|
|
return primitive;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Des);
|
|
|
|
|
|
|
|
|