staging: vt6656: MACvSetKeyEntry create structure to write key

Create structure for wKeyCtl , pbyAddr and pbyKey

wKeyCtl(key_ctl) and pbyAddr(addr) form an union of 64 bits with swap
of two 32 bits. pbyKey(key) has a length of WLAN_KEY_LEN_CCMP(16)
bytes.

swap is needed because high order 32 bits needs to written out first.

pbyKey is memcpy on to key.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Malcolm Priestley 2014-05-25 21:36:29 +01:00 committed by Greg Kroah-Hartman
parent 5cb5bff703
commit 83bf96fe51
2 changed files with 25 additions and 43 deletions

View File

@ -125,60 +125,31 @@ void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx)
void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx,
u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey) u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey)
{ {
u8 *pbyKey; struct vnt_mac_set_key set_key;
u8 *pbyKey = (u8 *)pdwKey;
u16 wOffset; u16 wOffset;
u32 dwData1, dwData2;
int ii;
u8 pbyData[24];
if (pDevice->byLocalID <= MAC_REVISION_A1) if (pDevice->byLocalID <= MAC_REVISION_A1)
if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP) if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP)
return; return;
wOffset = MISCFIFO_KEYETRY0; wOffset = MISCFIFO_KEYETRY0;
wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
dwData1 = 0; set_key.u.write.key_ctl = cpu_to_le16(wKeyCtl);
dwData1 |= wKeyCtl; memcpy(set_key.u.write.addr, pbyAddr, ETH_ALEN);
dwData1 <<= 16;
dwData1 |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5));
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %X,"\ /* swap over swap[0] and swap[1] to get correct write order */
" KeyCtl:%X\n", wOffset, dwData1, wKeyCtl); swap(set_key.u.swap[0], set_key.u.swap[1]);
dwData2 = 0; memcpy(set_key.key, pbyKey, WLAN_KEY_LEN_CCMP);
dwData2 |= *(pbyAddr+3);
dwData2 <<= 8;
dwData2 |= *(pbyAddr+2);
dwData2 <<= 8;
dwData2 |= *(pbyAddr+1);
dwData2 <<= 8;
dwData2 |= *(pbyAddr+0);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %X\n", DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
wOffset, dwData2); "offset %d key ctl %d set key %24ph\n",
wOffset, wKeyCtl, (u8 *)&set_key);
pbyKey = (u8 *)pdwKey;
pbyData[0] = (u8)dwData1;
pbyData[1] = (u8)(dwData1>>8);
pbyData[2] = (u8)(dwData1>>16);
pbyData[3] = (u8)(dwData1>>24);
pbyData[4] = (u8)dwData2;
pbyData[5] = (u8)(dwData2>>8);
pbyData[6] = (u8)(dwData2>>16);
pbyData[7] = (u8)(dwData2>>24);
for (ii = 8; ii < 24; ii++)
pbyData[ii] = *pbyKey++;
CONTROLnsRequestOut(pDevice,
MESSAGE_TYPE_SETKEY,
wOffset,
(u16)uKeyIdx,
ARRAY_SIZE(pbyData),
pbyData
);
CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SETKEY, wOffset,
(u16)uKeyIdx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key);
} }
void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits) void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits)

View File

@ -403,6 +403,17 @@
#define MAC_REVISION_A0 0x00 #define MAC_REVISION_A0 0x00
#define MAC_REVISION_A1 0x01 #define MAC_REVISION_A1 0x01
struct vnt_mac_set_key {
union {
struct {
u8 addr[ETH_ALEN];
__le16 key_ctl;
} write __packed;
u32 swap[2];
} u;
u8 key[WLAN_KEY_LEN_CCMP];
} __packed;
void MACvWriteMultiAddr(struct vnt_private *, u64); void MACvWriteMultiAddr(struct vnt_private *, u64);
void MACbShutdown(struct vnt_private *); void MACbShutdown(struct vnt_private *);
void MACvSetBBType(struct vnt_private *, u8); void MACvSetBBType(struct vnt_private *, u8);