2014-05-31 12:35:56

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 1/4] staging: vt6656: rxtx move vnt_usb_send_context into tx structure.

Replacing struct vnt_private.

Where struct vnt_private is needed pointer to priv is added.

This allows to move tx signaling into vnt_usb_send_context.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/rxtx.c | 108 +++++++++++++++++++++++++-----------------
1 file changed, 64 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 704f4d3..fa04894 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -96,7 +96,7 @@ static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum,

static struct vnt_usb_send_context *s_vGetFreeContext(struct vnt_private *);

-static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
+static u16 s_vGenerateTxParameter(struct vnt_usb_send_context *tx_context,
u8 byPktType, u16 wCurrentRate, struct vnt_tx_buffer *tx_buffer,
struct vnt_mic_hdr **mic_hdr, u32 need_mic, u32 cbFrameSize,
int bNeedACK, struct ethhdr *psEthHeader, bool need_rts);
@@ -119,11 +119,11 @@ static unsigned int s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType,
static __le16 s_uGetRTSCTSRsvTime(struct vnt_private *priv,
u8 rsv_type, u8 pkt_type, u32 frame_length, u16 current_rate);

-static u16 s_vFillCTSHead(struct vnt_private *pDevice,
+static u16 s_vFillCTSHead(struct vnt_usb_send_context *tx_context,
u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength,
int bNeedAck, u16 wCurrentRate, u8 byFBOption);

-static u16 s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType,
+static u16 s_vFillRTSHead(struct vnt_usb_send_context *tx_context, u8 byPktType,
union vnt_tx_data_head *head, u32 cbFrameLength, int bNeedAck,
struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption);

@@ -470,9 +470,13 @@ static __le16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType,
return cpu_to_le16((u16)uDurTime);
}

-static u16 vnt_rxtx_datahead_g(struct vnt_private *priv, u8 pkt_type, u16 rate,
- struct vnt_tx_datahead_g *buf, u32 frame_len, int need_ack)
+static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
+ u8 pkt_type, u16 rate, struct vnt_tx_datahead_g *buf,
+ u32 frame_len, int need_ack)
{
+
+ struct vnt_private *priv = tx_context->priv;
+
/* Get SignalField,ServiceField,Length */
BBvCalculateParameter(priv, frame_len, rate, pkt_type, &buf->a);
BBvCalculateParameter(priv, frame_len, priv->byTopCCKBasicRate,
@@ -489,10 +493,12 @@ static u16 vnt_rxtx_datahead_g(struct vnt_private *priv, u8 pkt_type, u16 rate,
return le16_to_cpu(buf->duration_a);
}

-static u16 vnt_rxtx_datahead_g_fb(struct vnt_private *priv, u8 pkt_type,
- u16 rate, struct vnt_tx_datahead_g_fb *buf,
+static u16 vnt_rxtx_datahead_g_fb(struct vnt_usb_send_context *tx_context,
+ u8 pkt_type, u16 rate, struct vnt_tx_datahead_g_fb *buf,
u32 frame_len, int need_ack)
{
+ struct vnt_private *priv = tx_context->priv;
+
/* Get SignalField,ServiceField,Length */
BBvCalculateParameter(priv, frame_len, rate, pkt_type, &buf->a);

@@ -513,10 +519,12 @@ static u16 vnt_rxtx_datahead_g_fb(struct vnt_private *priv, u8 pkt_type,
return le16_to_cpu(buf->duration_a);
}

-static u16 vnt_rxtx_datahead_a_fb(struct vnt_private *priv, u8 pkt_type,
- u16 rate, struct vnt_tx_datahead_a_fb *buf,
+static u16 vnt_rxtx_datahead_a_fb(struct vnt_usb_send_context *tx_context,
+ u8 pkt_type, u16 rate, struct vnt_tx_datahead_a_fb *buf,
u32 frame_len, int need_ack)
{
+ struct vnt_private *priv = tx_context->priv;
+
/* Get SignalField,ServiceField,Length */
BBvCalculateParameter(priv, frame_len, rate, pkt_type, &buf->a);
/* Get Duration and TimeStampOff */
@@ -530,10 +538,12 @@ static u16 vnt_rxtx_datahead_a_fb(struct vnt_private *priv, u8 pkt_type,
return le16_to_cpu(buf->duration);
}

-static u16 vnt_rxtx_datahead_ab(struct vnt_private *priv, u8 pkt_type,
- u16 rate, struct vnt_tx_datahead_ab *buf,
+static u16 vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,
+ u8 pkt_type, u16 rate, struct vnt_tx_datahead_ab *buf,
u32 frame_len, int need_ack)
{
+ struct vnt_private *priv = tx_context->priv;
+
/* Get SignalField,ServiceField,Length */
BBvCalculateParameter(priv, frame_len, rate, pkt_type, &buf->ab);
/* Get Duration and TimeStampOff */
@@ -566,11 +576,12 @@ static int vnt_fill_ieee80211_rts(struct vnt_private *priv,
return 0;
}

-static u16 vnt_rxtx_rts_g_head(struct vnt_private *priv,
+static u16 vnt_rxtx_rts_g_head(struct vnt_usb_send_context *tx_context,
struct vnt_rts_g *buf, struct ethhdr *eth_hdr,
u8 pkt_type, u32 frame_len, int need_ack,
u16 current_rate, u8 fb_option)
{
+ struct vnt_private *priv = tx_context->priv;
u16 rts_frame_len = 20;

BBvCalculateParameter(priv, rts_frame_len, priv->byTopCCKBasicRate,
@@ -587,15 +598,16 @@ static u16 vnt_rxtx_rts_g_head(struct vnt_private *priv,

vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->duration_aa);

- return vnt_rxtx_datahead_g(priv, pkt_type, current_rate,
+ return vnt_rxtx_datahead_g(tx_context, pkt_type, current_rate,
&buf->data_head, frame_len, need_ack);
}

-static u16 vnt_rxtx_rts_g_fb_head(struct vnt_private *priv,
+static u16 vnt_rxtx_rts_g_fb_head(struct vnt_usb_send_context *tx_context,
struct vnt_rts_g_fb *buf, struct ethhdr *eth_hdr,
u8 pkt_type, u32 frame_len, int need_ack,
u16 current_rate, u8 fb_option)
{
+ struct vnt_private *priv = tx_context->priv;
u16 rts_frame_len = 20;

BBvCalculateParameter(priv, rts_frame_len, priv->byTopCCKBasicRate,
@@ -623,15 +635,16 @@ static u16 vnt_rxtx_rts_g_fb_head(struct vnt_private *priv,

vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->duration_aa);

- return vnt_rxtx_datahead_g_fb(priv, pkt_type, current_rate,
+ return vnt_rxtx_datahead_g_fb(tx_context, pkt_type, current_rate,
&buf->data_head, frame_len, need_ack);
}

-static u16 vnt_rxtx_rts_ab_head(struct vnt_private *priv,
+static u16 vnt_rxtx_rts_ab_head(struct vnt_usb_send_context *tx_context,
struct vnt_rts_ab *buf, struct ethhdr *eth_hdr,
u8 pkt_type, u32 frame_len, int need_ack,
u16 current_rate, u8 fb_option)
{
+ struct vnt_private *priv = tx_context->priv;
u16 rts_frame_len = 20;

BBvCalculateParameter(priv, rts_frame_len,
@@ -642,15 +655,16 @@ static u16 vnt_rxtx_rts_ab_head(struct vnt_private *priv,

vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->duration);

- return vnt_rxtx_datahead_ab(priv, pkt_type, current_rate,
+ return vnt_rxtx_datahead_ab(tx_context, pkt_type, current_rate,
&buf->data_head, frame_len, need_ack);
}

-static u16 vnt_rxtx_rts_a_fb_head(struct vnt_private *priv,
+static u16 vnt_rxtx_rts_a_fb_head(struct vnt_usb_send_context *tx_context,
struct vnt_rts_a_fb *buf, struct ethhdr *eth_hdr,
u8 pkt_type, u32 frame_len, int need_ack,
u16 current_rate, u8 fb_option)
{
+ struct vnt_private *priv = tx_context->priv;
u16 rts_frame_len = 20;

BBvCalculateParameter(priv, rts_frame_len,
@@ -667,11 +681,11 @@ static u16 vnt_rxtx_rts_a_fb_head(struct vnt_private *priv,

vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->duration);

- return vnt_rxtx_datahead_a_fb(priv, pkt_type, current_rate,
+ return vnt_rxtx_datahead_a_fb(tx_context, pkt_type, current_rate,
&buf->data_head, frame_len, need_ack);
}

-static u16 s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType,
+static u16 s_vFillRTSHead(struct vnt_usb_send_context *tx_context, u8 byPktType,
union vnt_tx_data_head *head, u32 cbFrameLength, int bNeedAck,
struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption)
{
@@ -688,23 +702,25 @@ static u16 s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType,
case PK_TYPE_11GB:
case PK_TYPE_11GA:
if (byFBOption == AUTO_FB_NONE)
- return vnt_rxtx_rts_g_head(pDevice, &head->rts_g,
+ return vnt_rxtx_rts_g_head(tx_context, &head->rts_g,
psEthHeader, byPktType, cbFrameLength,
bNeedAck, wCurrentRate, byFBOption);
else
- return vnt_rxtx_rts_g_fb_head(pDevice, &head->rts_g_fb,
- psEthHeader, byPktType, cbFrameLength,
- bNeedAck, wCurrentRate, byFBOption);
+ return vnt_rxtx_rts_g_fb_head(tx_context,
+ &head->rts_g_fb, psEthHeader, byPktType,
+ cbFrameLength, bNeedAck, wCurrentRate,
+ byFBOption);
break;
case PK_TYPE_11A:
if (byFBOption) {
- return vnt_rxtx_rts_a_fb_head(pDevice, &head->rts_a_fb,
- psEthHeader, byPktType, cbFrameLength,
- bNeedAck, wCurrentRate, byFBOption);
+ return vnt_rxtx_rts_a_fb_head(tx_context,
+ &head->rts_a_fb, psEthHeader, byPktType,
+ cbFrameLength, bNeedAck, wCurrentRate,
+ byFBOption);
break;
}
case PK_TYPE_11B:
- return vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab,
+ return vnt_rxtx_rts_ab_head(tx_context, &head->rts_ab,
psEthHeader, byPktType, cbFrameLength,
bNeedAck, wCurrentRate, byFBOption);
}
@@ -712,10 +728,11 @@ static u16 s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType,
return 0;
}

-static u16 s_vFillCTSHead(struct vnt_private *pDevice,
+static u16 s_vFillCTSHead(struct vnt_usb_send_context *tx_context,
u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength,
int bNeedAck, u16 wCurrentRate, u8 byFBOption)
{
+ struct vnt_private *pDevice = tx_context->priv;
u32 uCTSFrameLen = 14;

if (!head)
@@ -745,8 +762,9 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice,

memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN);

- return vnt_rxtx_datahead_g_fb(pDevice, byPktType, wCurrentRate,
- &pBuf->data_head, cbFrameLength, bNeedAck);
+ return vnt_rxtx_datahead_g_fb(tx_context, byPktType,
+ wCurrentRate, &pBuf->data_head, cbFrameLength,
+ bNeedAck);
} else {
struct vnt_cts *pBuf = &head->cts_g;
/* Get SignalField,ServiceField,Length */
@@ -763,7 +781,7 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice,

memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN);

- return vnt_rxtx_datahead_g(pDevice, byPktType, wCurrentRate,
+ return vnt_rxtx_datahead_g(tx_context, byPktType, wCurrentRate,
&pBuf->data_head, cbFrameLength, bNeedAck);
}

@@ -792,11 +810,12 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice,
*
-*/

-static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
+static u16 s_vGenerateTxParameter(struct vnt_usb_send_context *tx_context,
u8 byPktType, u16 wCurrentRate, struct vnt_tx_buffer *tx_buffer,
struct vnt_mic_hdr **mic_hdr, u32 need_mic, u32 cbFrameSize,
int bNeedACK, struct ethhdr *psEthHeader, bool need_rts)
{
+ struct vnt_private *pDevice = tx_context->priv;
struct vnt_tx_fifo_head *pFifoHead = &tx_buffer->fifo_head;
union vnt_tx_data_head *head = NULL;
u16 wFifoCtl;
@@ -837,7 +856,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
}

/* Fill RTS */
- return s_vFillRTSHead(pDevice, byPktType, head,
+ return s_vFillRTSHead(tx_context, byPktType, head,
cbFrameSize, bNeedACK, psEthHeader,
wCurrentRate, byFBOption);

@@ -863,7 +882,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
}

/* Fill CTS */
- return s_vFillCTSHead(pDevice, byPktType,
+ return s_vFillCTSHead(tx_context, byPktType,
head, cbFrameSize, bNeedACK, wCurrentRate,
byFBOption);
}
@@ -886,7 +905,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
byPktType, cbFrameSize, wCurrentRate, bNeedACK);

/* Fill RTS */
- return s_vFillRTSHead(pDevice, byPktType, head,
+ return s_vFillRTSHead(tx_context, byPktType, head,
cbFrameSize, bNeedACK, psEthHeader,
wCurrentRate, byFBOption);
} else {
@@ -897,7 +916,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
PK_TYPE_11A, cbFrameSize,
wCurrentRate, bNeedACK);

- return vnt_rxtx_datahead_a_fb(pDevice, byPktType,
+ return vnt_rxtx_datahead_a_fb(tx_context, byPktType,
wCurrentRate, &head->data_head_a_fb,
cbFrameSize, bNeedACK);
}
@@ -921,7 +940,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
bNeedACK);

/* Fill RTS */
- return s_vFillRTSHead(pDevice, byPktType, head,
+ return s_vFillRTSHead(tx_context, byPktType, head,
cbFrameSize,
bNeedACK, psEthHeader, wCurrentRate, byFBOption);
} else {
@@ -932,7 +951,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
PK_TYPE_11B, cbFrameSize,
wCurrentRate, bNeedACK);

- return vnt_rxtx_datahead_ab(pDevice, byPktType,
+ return vnt_rxtx_datahead_ab(tx_context, byPktType,
wCurrentRate, &head->data_head_ab,
cbFrameSize, bNeedACK);
}
@@ -946,12 +965,13 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
unsigned int cbFragmentSize,//Hdr+payoad+FCS
*/

-static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType,
- struct vnt_tx_buffer *tx_buffer, int bNeedEncryption,
+static int s_bPacketToWirelessUsb(struct vnt_usb_send_context *tx_context,
+ u8 byPktType, struct vnt_tx_buffer *tx_buffer, int bNeedEncryption,
u32 uSkbPacketLen, struct ethhdr *psEthHeader,
u8 *pPacket, PSKeyItem pTransmitKey, u32 uNodeIndex, u16 wCurrentRate,
u32 *pcbHeaderLen, u32 *pcbTotalLen)
{
+ struct vnt_private *pDevice = tx_context->priv;
struct vnt_tx_fifo_head *pTxBufHead = &tx_buffer->fifo_head;
u32 cbFrameSize, cbFrameBodySize;
u32 cb802_1_H_len;
@@ -1146,7 +1166,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType,
//pTxBufHead = (PSTxBufHead) &(pTxBufHead->adwTxKey[0]);

/* Fill FIFO, RrvTime, RTS and CTS */
- uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate,
+ uDuration = s_vGenerateTxParameter(tx_context, byPktType, wCurrentRate,
tx_buffer, &pMICHDR, cbMICHDR,
cbFrameSize, bNeedACK, psEthHeader, bRTS);

@@ -1518,7 +1538,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
pTxBufHead->wFragCtl |= (u16)FRAGCTL_NONFRAG;

/* Fill FIFO,RrvTime,RTS,and CTS */
- uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate,
+ uDuration = s_vGenerateTxParameter(pContext, byPktType, wCurrentRate,
pTX_Buffer, &pMICHDR, 0,
cbFrameSize, bNeedACK, &sEthHeader, false);

@@ -2020,7 +2040,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb)

pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0];

- fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType,
+ fConvertedPacket = s_bPacketToWirelessUsb(pContext, byPktType,
pTX_Buffer, bNeedEncryption,
skb->len, &pDevice->sTxEthHeader,
(u8 *)skb->data, pTransmitKey, uNodeIndex,
--
1.9.1



2014-05-31 12:35:55

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 2/4] staging: vt6656: rxtx add mac header to vnt_tx_datahead_* structures

Add vnt_mac_hdr_pos to set mac header pointer and the calculate header size.

Pass ieee80211 hdr pointer and tx_hdr_size in vnt_usb_send_context.

Remove old pointer arithmetic and attach pMACHeader to hdr.

cbHeaderLength/cbHeaderSize now uses the value of tx_hdr_size.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 2 +
drivers/staging/vt6656/rxtx.c | 122 ++++++++++++++++------------------------
drivers/staging/vt6656/rxtx.h | 4 ++
3 files changed, 55 insertions(+), 73 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 5b64ca7..11b863d 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -241,7 +241,9 @@ struct vnt_usb_send_context {
void *priv;
struct sk_buff *skb;
struct urb *urb;
+ struct ieee80211_hdr *hdr;
unsigned int buf_len;
+ u16 tx_hdr_size;
u8 type;
bool in_use;
unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS];
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index fa04894..e4cc1ff 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -102,8 +102,9 @@ static u16 s_vGenerateTxParameter(struct vnt_usb_send_context *tx_context,
int bNeedACK, struct ethhdr *psEthHeader, bool need_rts);

static void s_vGenerateMACHeader(struct vnt_private *pDevice,
- u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader,
- int bNeedEncrypt, u16 wFragType, u32 uFragIdx);
+ struct ieee80211_hdr *pMACHeader, u16 wDuration,
+ struct ethhdr *psEthHeader, int bNeedEncrypt, u16 wFragType,
+ u32 uFragIdx);

static void s_vFillTxKey(struct vnt_private *pDevice,
struct vnt_tx_fifo_head *fifo_head, u8 *pbyIVHead,
@@ -151,6 +152,9 @@ static struct vnt_usb_send_context
context->in_use = true;
memset(context->data, 0,
MAX_TOTAL_SIZE_WITH_ALL_HEADERS);
+
+ context->hdr = NULL;
+
return context;
}
}
@@ -470,6 +474,19 @@ static __le16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType,
return cpu_to_le16((u16)uDurTime);
}

+static u16 vnt_mac_hdr_pos(struct vnt_usb_send_context *tx_context,
+ struct ieee80211_hdr *hdr)
+{
+ u8 *head = tx_context->data + offsetof(struct vnt_tx_buffer, fifo_head);
+ u8 *hdr_pos = (u8 *)hdr;
+
+ tx_context->hdr = hdr;
+ if (!tx_context->hdr)
+ return 0;
+
+ return (u16)(hdr_pos - head);
+}
+
static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
u8 pkt_type, u16 rate, struct vnt_tx_datahead_g *buf,
u32 frame_len, int need_ack)
@@ -490,6 +507,8 @@ static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
buf->time_stamp_off_b = vnt_time_stamp_off(priv,
priv->byTopCCKBasicRate);

+ tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
+
return le16_to_cpu(buf->duration_a);
}

@@ -516,6 +535,8 @@ static u16 vnt_rxtx_datahead_g_fb(struct vnt_usb_send_context *tx_context,
buf->time_stamp_off_b = vnt_time_stamp_off(priv,
priv->byTopCCKBasicRate);

+ tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
+
return le16_to_cpu(buf->duration_a);
}

@@ -535,6 +556,8 @@ static u16 vnt_rxtx_datahead_a_fb(struct vnt_usb_send_context *tx_context,

buf->time_stamp_off = vnt_time_stamp_off(priv, rate);

+ tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
+
return le16_to_cpu(buf->duration);
}

@@ -551,6 +574,8 @@ static u16 vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,

buf->time_stamp_off = vnt_time_stamp_off(priv, rate);

+ tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
+
return le16_to_cpu(buf->duration);
}

@@ -979,7 +1004,7 @@ static int s_bPacketToWirelessUsb(struct vnt_usb_send_context *tx_context,
u32 cbFCSlen = 4, cbMICHDR = 0;
int bNeedACK;
bool bRTS = false;
- u8 *pbyType, *pbyMacHdr, *pbyIVHead, *pbyPayloadHead, *pbyTxBufferAddr;
+ u8 *pbyType, *pbyMacHdr, *pbyIVHead, *pbyPayloadHead;
u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
u8 abySNAP_Bridgetunnel[ETH_ALEN]
= {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
@@ -987,7 +1012,6 @@ static int s_bPacketToWirelessUsb(struct vnt_usb_send_context *tx_context,
u32 cbHeaderLength = 0, uPadding = 0;
struct vnt_mic_hdr *pMICHDR;
u8 byFBOption = AUTO_FB_NONE, byFragType;
- u16 wTxBufSize;
u32 dwMICKey0, dwMICKey1, dwMIC_Priority;
u32 *pdwMIC_L, *pdwMIC_R;
int bSoftWEP = false;
@@ -1106,58 +1130,6 @@ static int s_bPacketToWirelessUsb(struct vnt_usb_send_context *tx_context,
pTxBufHead->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY);
}

- pbyTxBufferAddr = (u8 *) &(pTxBufHead->adwTxKey[0]);
- wTxBufSize = sizeof(struct vnt_tx_fifo_head);
-
- if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet
- if (byFBOption == AUTO_FB_NONE) {
- if (bRTS == true) {//RTS_need
- cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) +
- cbMICHDR + sizeof(struct vnt_rts_g);
- }
- else { //RTS_needless
- cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) +
- cbMICHDR + sizeof(struct vnt_cts);
- }
- } else {
- // Auto Fall Back
- if (bRTS == true) {//RTS_need
- cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) +
- cbMICHDR + sizeof(struct vnt_rts_g_fb);
- }
- else if (bRTS == false) { //RTS_needless
- cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) +
- cbMICHDR + sizeof(struct vnt_cts_fb);
- }
- } // Auto Fall Back
- }
- else {//802.11a/b packet
- if (byFBOption == AUTO_FB_NONE) {
- if (bRTS == true) {//RTS_need
- cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
- cbMICHDR + sizeof(struct vnt_rts_ab);
- }
- else if (bRTS == false) { //RTS_needless, no MICHDR
- cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
- cbMICHDR + sizeof(struct vnt_tx_datahead_ab);
- }
- } else {
- // Auto Fall Back
- if (bRTS == true) {//RTS_need
- cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
- cbMICHDR + sizeof(struct vnt_rts_a_fb);
- }
- else if (bRTS == false) { //RTS_needless
- cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
- cbMICHDR + sizeof(struct vnt_tx_datahead_a_fb);
- }
- } // Auto Fall Back
- }
-
- pbyMacHdr = (u8 *)(pbyTxBufferAddr + cbHeaderLength);
- pbyIVHead = (u8 *)(pbyMacHdr + cbMACHdLen + uPadding);
- pbyPayloadHead = (u8 *)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen);
-
//=========================
// No Fragmentation
//=========================
@@ -1170,9 +1142,17 @@ static int s_bPacketToWirelessUsb(struct vnt_usb_send_context *tx_context,
tx_buffer, &pMICHDR, cbMICHDR,
cbFrameSize, bNeedACK, psEthHeader, bRTS);

- // Generate TX MAC Header
- s_vGenerateMACHeader(pDevice, pbyMacHdr, (u16)uDuration, psEthHeader, bNeedEncryption,
- byFragType, 0);
+ cbHeaderLength = tx_context->tx_hdr_size;
+ if (!cbHeaderLength)
+ return false;
+
+ pbyMacHdr = (u8 *)tx_context->hdr;
+ pbyIVHead = (u8 *)(pbyMacHdr + cbMACHdLen + uPadding);
+ pbyPayloadHead = (u8 *)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen);
+
+ /* Generate TX MAC Header */
+ s_vGenerateMACHeader(pDevice, tx_context->hdr, (u16)uDuration,
+ psEthHeader, bNeedEncryption, byFragType, 0);

if (bNeedEncryption == true) {
//Fill TXKEY
@@ -1298,10 +1278,10 @@ static int s_bPacketToWirelessUsb(struct vnt_usb_send_context *tx_context,
-*/

static void s_vGenerateMACHeader(struct vnt_private *pDevice,
- u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader,
- int bNeedEncrypt, u16 wFragType, u32 uFragIdx)
+ struct ieee80211_hdr *pMACHeader, u16 wDuration,
+ struct ethhdr *psEthHeader, int bNeedEncrypt, u16 wFragType,
+ u32 uFragIdx)
{
- struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyBufferAddr;

pMACHeader->frame_control = TYPE_802_11_DATA;

@@ -1516,16 +1496,6 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
}
//the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()

- //Set RrvTime/RTS/CTS Buffer
- if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet
- cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) +
- sizeof(struct vnt_cts);
- }
- else { // 802.11a/b packet
- cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
- sizeof(struct vnt_tx_datahead_ab);
- }
-
memcpy(&(sEthHeader.h_dest[0]),
&(pPacket->p80211Header->sA3.abyAddr1[0]),
ETH_ALEN);
@@ -1542,7 +1512,13 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
pTX_Buffer, &pMICHDR, 0,
cbFrameSize, bNeedACK, &sEthHeader, false);

- pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize);
+ cbHeaderSize = pContext->tx_hdr_size;
+ if (!cbHeaderSize) {
+ pContext->in_use = false;
+ return CMD_STATUS_RESOURCES;
+ }
+
+ pMACHeader = pContext->hdr;

cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize;

diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h
index 6db3337..30e1437 100644
--- a/drivers/staging/vt6656/rxtx.h
+++ b/drivers/staging/vt6656/rxtx.h
@@ -81,6 +81,7 @@ struct vnt_tx_datahead_g {
__le16 duration_a;
__le16 time_stamp_off_b;
__le16 time_stamp_off_a;
+ struct ieee80211_hdr hdr;
} __packed;

struct vnt_tx_datahead_g_fb {
@@ -92,12 +93,14 @@ struct vnt_tx_datahead_g_fb {
__le16 duration_a_f1;
__le16 time_stamp_off_b;
__le16 time_stamp_off_a;
+ struct ieee80211_hdr hdr;
} __packed;

struct vnt_tx_datahead_ab {
struct vnt_phy_field ab;
__le16 duration;
__le16 time_stamp_off;
+ struct ieee80211_hdr hdr;
} __packed;

struct vnt_tx_datahead_a_fb {
@@ -106,6 +109,7 @@ struct vnt_tx_datahead_a_fb {
__le16 time_stamp_off;
__le16 duration_f0;
__le16 duration_f1;
+ struct ieee80211_hdr hdr;
} __packed;

/* RTS buffer header */
--
1.9.1


2014-05-31 12:35:58

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 4/4] staging: vt6656: rxtx replace adwTxKey[4]

Replace with tx_key with size of WLAN_KEY_LEN_CCMP(16)

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/rxtx.c | 4 ++--
drivers/staging/vt6656/rxtx.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 26cc57e..22cb642 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -182,7 +182,7 @@ static void s_vFillTxKey(struct vnt_usb_send_context *tx_context,
{
struct vnt_private *pDevice = tx_context->priv;
struct ieee80211_hdr *pMACHeader = tx_context->hdr;
- u8 *pbyBuf = (u8 *)&fifo_head->adwTxKey[0];
+ u8 *pbyBuf = fifo_head->tx_key;
__le32 *pdwIV = (__le32 *)pbyIVHead;
__le32 *pdwExtIV = (__le32 *)((u8 *)pbyIVHead + 4);
__le32 rev_iv_counter;
@@ -1404,7 +1404,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0];
cbFrameBodySize = pPacket->cbPayloadLen;
pTxBufHead = &pTX_Buffer->fifo_head;
- pbyTxBufferAddr = (u8 *)&pTxBufHead->adwTxKey[0];
+ pbyTxBufferAddr = (u8 *)pTxBufHead;
wTxBufSize = sizeof(struct vnt_tx_fifo_head);


diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h
index 30e1437..95a4e2c 100644
--- a/drivers/staging/vt6656/rxtx.h
+++ b/drivers/staging/vt6656/rxtx.h
@@ -219,7 +219,7 @@ union vnt_tx_head {
};

struct vnt_tx_fifo_head {
- u32 adwTxKey[4];
+ u8 tx_key[WLAN_KEY_LEN_CCMP];
u16 wFIFOCtl;
__le16 time_stamp;
u16 wFragCtl;
--
1.9.1


2014-05-31 12:35:57

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 3/4] staging: vt6656: rxtx s_vFillTxKey use vnt_usb_send_context

Use struct vnt_usb_send_context to get mac header and
priv pointers

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/rxtx.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index e4cc1ff..26cc57e 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -106,10 +106,9 @@ static void s_vGenerateMACHeader(struct vnt_private *pDevice,
struct ethhdr *psEthHeader, int bNeedEncrypt, u16 wFragType,
u32 uFragIdx);

-static void s_vFillTxKey(struct vnt_private *pDevice,
+static void s_vFillTxKey(struct vnt_usb_send_context *tx_context,
struct vnt_tx_fifo_head *fifo_head, u8 *pbyIVHead,
- PSKeyItem pTransmitKey, u8 *pbyHdrBuf, u16 wPayloadLen,
- struct vnt_mic_hdr *mic_hdr);
+ PSKeyItem pTransmitKey, u16 wPayloadLen, struct vnt_mic_hdr *mic_hdr);

static void s_vSWencryption(struct vnt_private *pDevice,
PSKeyItem pTransmitKey, u8 *pbyPayloadHead, u16 wPayloadSize);
@@ -177,15 +176,15 @@ static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum,
stats->tx_bytes += wPktLength;
}

-static void s_vFillTxKey(struct vnt_private *pDevice,
+static void s_vFillTxKey(struct vnt_usb_send_context *tx_context,
struct vnt_tx_fifo_head *fifo_head, u8 *pbyIVHead,
- PSKeyItem pTransmitKey, u8 *pbyHdrBuf, u16 wPayloadLen,
- struct vnt_mic_hdr *mic_hdr)
+ PSKeyItem pTransmitKey, u16 wPayloadLen, struct vnt_mic_hdr *mic_hdr)
{
+ struct vnt_private *pDevice = tx_context->priv;
+ struct ieee80211_hdr *pMACHeader = tx_context->hdr;
u8 *pbyBuf = (u8 *)&fifo_head->adwTxKey[0];
__le32 *pdwIV = (__le32 *)pbyIVHead;
__le32 *pdwExtIV = (__le32 *)((u8 *)pbyIVHead + 4);
- struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf;
__le32 rev_iv_counter;

/* Fill TXKEY */
@@ -1156,8 +1155,8 @@ static int s_bPacketToWirelessUsb(struct vnt_usb_send_context *tx_context,

if (bNeedEncryption == true) {
//Fill TXKEY
- s_vFillTxKey(pDevice, pTxBufHead, pbyIVHead, pTransmitKey,
- pbyMacHdr, (u16)cbFrameBodySize, pMICHDR);
+ s_vFillTxKey(tx_context, pTxBufHead, pbyIVHead, pTransmitKey,
+ (u16)cbFrameBodySize, pMICHDR);
}

/* 802.1H */
@@ -1556,8 +1555,8 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
}
} while(false);
//Fill TXKEY
- s_vFillTxKey(pDevice, pTxBufHead, pbyIVHead, pTransmitKey,
- (u8 *)pMACHeader, (u16)cbFrameBodySize, NULL);
+ s_vFillTxKey(pContext, pTxBufHead, pbyIVHead, pTransmitKey,
+ (u16)cbFrameBodySize, NULL);

memcpy(pMACHeader, pPacket->p80211Header, cbMacHdLen);
memcpy(pbyPayloadHead, ((u8 *)(pPacket->p80211Header) + cbMacHdLen),
--
1.9.1