2015-02-01 12:00:10

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 1/6] staging: vt6655: move setting of PSTxDesc->buff_addr to vnt_tx_packet

Keep setting of this part of the structure with the others.

Only pTDInfo needs carried in the buffer structure.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6655/device_main.c | 2 ++
drivers/staging/vt6655/rxtx.c | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 58559fa..9a80144 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1217,6 +1217,8 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
head_td->m_td1TD1.wReqCount =
cpu_to_le16((u16)head_td->pTDInfo->dwReqCount);

+ head_td->buff_addr = cpu_to_le32(head_td->pTDInfo->skb_dma);
+
head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB;

if (dma_idx == TYPE_AC0DMA)
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 9cade85..07ce3fd 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -1207,7 +1207,6 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
ptdCurr->pTDInfo->dwReqCount = cbReqCount;
ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
- ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);

return cbHeaderLength;
}
--
2.1.0



2015-02-01 12:00:15

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 4/6] staging: vt6655: vnt_rx_data add track rsr and new_rsr errors

If not rsr & RSR_CRCOK report RX_FLAG_FAILED_FCS_CRC

If not rsr & (RSR_IVLDTYP | RSR_IVLDLEN) drop packet

If not NEWRSR_DECRYPTOK on new_rsr drop packet.

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

diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c
index 11cc090..3c5b87f 100644
--- a/drivers/staging/vt6655/dpc.c
+++ b/drivers/staging/vt6655/dpc.c
@@ -91,6 +91,8 @@ static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb,
new_rsr = skb_data + bytes_received - 3;
rssi = skb_data + bytes_received - 2;
rsr = skb_data + bytes_received - 1;
+ if (*rsr & (RSR_IVLDTYP | RSR_IVLDLEN))
+ return false;

RFvRSSITodBm(priv, *rssi, &rx_dbm);

@@ -106,6 +108,9 @@ static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb,
rx_status.flag = 0;
rx_status.freq = hw->conf.chandef.chan->center_freq;

+ if (!(*rsr & RSR_CRCOK))
+ rx_status.flag |= RX_FLAG_FAILED_FCS_CRC;
+
hdr = (struct ieee80211_hdr *)(skb->data);
fc = hdr->frame_control;

@@ -113,7 +118,11 @@ static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb,

if (ieee80211_has_protected(fc)) {
if (priv->byLocalID > REV_ID_VT3253_A1)
- rx_status.flag = RX_FLAG_DECRYPTED;
+ rx_status.flag |= RX_FLAG_DECRYPTED;
+
+ /* Drop packet */
+ if (!(*new_rsr & NEWRSR_DECRYPTOK))
+ return false;
}

memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
--
2.1.0


2015-02-01 12:00:13

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 3/6] staging: vt6655: Fix TD_FLAGS_NETIF_SKB only on TYPE_AC0DMA

Allow only TD_FLAGS_NETIF_SKB on ring buffer TYPE_AC0DMA for data
only transfers for correct reporting of tx rates.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6655/device_main.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 870cafd..4324282 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1234,12 +1234,13 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)

head_td->buff_addr = cpu_to_le32(head_td->pTDInfo->skb_dma);

- head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB;
+ if (dma_idx == TYPE_AC0DMA) {
+ head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB;

- if (dma_idx == TYPE_AC0DMA)
MACvTransmitAC0(priv->PortOffset);
- else
+ } else {
MACvTransmit0(priv->PortOffset);
+ }

spin_unlock_irqrestore(&priv->lock, flags);

--
2.1.0


2015-02-01 12:00:18

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 6/6] staging: vt6656: parse cts fall back out of vnt_fill_cts_head

Creating new function vnt_fill_cts_fb_head for the fall back rates.

The check for fb_option is now done in vnt_rxtx_cts.

This fixes checkpatch warning
WARNING: else is not generally useful after a break or return
559: FILE: drivers/staging/vt6656/rxtx.c:559:

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

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 3b90497..33baf26 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -518,60 +518,66 @@ static u16 vnt_rxtx_rts_a_fb_head(struct vnt_usb_send_context *tx_context,
return vnt_rxtx_datahead_a_fb(tx_context, &buf->data_head);
}

-static u16 vnt_fill_cts_head(struct vnt_usb_send_context *tx_context,
- union vnt_tx_data_head *head)
+static u16 vnt_fill_cts_fb_head(struct vnt_usb_send_context *tx_context,
+ union vnt_tx_data_head *head)
{
struct vnt_private *priv = tx_context->priv;
+ struct vnt_cts_fb *buf = &head->cts_g_fb;
u32 cts_frame_len = 14;
u16 current_rate = tx_context->tx_rate;

- if (tx_context->fb_option) {
- /* Auto Fall back */
- struct vnt_cts_fb *buf = &head->cts_g_fb;
- /* Get SignalField,ServiceField,Length */
- vnt_get_phy_field(priv, cts_frame_len,
- priv->top_cck_basic_rate, PK_TYPE_11B, &buf->b);
- buf->duration_ba =
- vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA,
- tx_context->pkt_type,
- current_rate);
- /* Get CTSDuration_ba_f0 */
- buf->cts_duration_ba_f0 =
- vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA_F0,
- tx_context->pkt_type,
- priv->tx_rate_fb0);
- /* Get CTSDuration_ba_f1 */
- buf->cts_duration_ba_f1 =
- vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA_F1,
- tx_context->pkt_type,
- priv->tx_rate_fb1);
- /* Get CTS Frame body */
- buf->data.duration = buf->duration_ba;
- buf->data.frame_control =
- cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
+ /* Get SignalField,ServiceField,Length */
+ vnt_get_phy_field(priv, cts_frame_len, priv->top_cck_basic_rate,
+ PK_TYPE_11B, &buf->b);

- ether_addr_copy(buf->data.ra, priv->current_net_addr);
+ buf->duration_ba =
+ vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA,
+ tx_context->pkt_type,
+ current_rate);
+ /* Get CTSDuration_ba_f0 */
+ buf->cts_duration_ba_f0 =
+ vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA_F0,
+ tx_context->pkt_type,
+ priv->tx_rate_fb0);
+ /* Get CTSDuration_ba_f1 */
+ buf->cts_duration_ba_f1 =
+ vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA_F1,
+ tx_context->pkt_type,
+ priv->tx_rate_fb1);
+ /* Get CTS Frame body */
+ buf->data.duration = buf->duration_ba;
+ buf->data.frame_control =
+ cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);

- return vnt_rxtx_datahead_g_fb(tx_context, &buf->data_head);
- } else {
- struct vnt_cts *buf = &head->cts_g;
- /* Get SignalField,ServiceField,Length */
- vnt_get_phy_field(priv, cts_frame_len,
- priv->top_cck_basic_rate, PK_TYPE_11B, &buf->b);
- /* Get CTSDuration_ba */
- buf->duration_ba =
- vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA,
- tx_context->pkt_type,
- current_rate);
- /*Get CTS Frame body*/
- buf->data.duration = buf->duration_ba;
- buf->data.frame_control =
- cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
+ ether_addr_copy(buf->data.ra, priv->current_net_addr);

- ether_addr_copy(buf->data.ra, priv->current_net_addr);
+ return vnt_rxtx_datahead_g_fb(tx_context, &buf->data_head);
+}

- return vnt_rxtx_datahead_g(tx_context, &buf->data_head);
- }
+static u16 vnt_fill_cts_head(struct vnt_usb_send_context *tx_context,
+ union vnt_tx_data_head *head)
+{
+ struct vnt_private *priv = tx_context->priv;
+ struct vnt_cts *buf = &head->cts_g;
+ u32 cts_frame_len = 14;
+ u16 current_rate = tx_context->tx_rate;
+
+ /* Get SignalField,ServiceField,Length */
+ vnt_get_phy_field(priv, cts_frame_len, priv->top_cck_basic_rate,
+ PK_TYPE_11B, &buf->b);
+ /* Get CTSDuration_ba */
+ buf->duration_ba =
+ vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA,
+ tx_context->pkt_type,
+ current_rate);
+ /*Get CTS Frame body*/
+ buf->data.duration = buf->duration_ba;
+ buf->data.frame_control =
+ cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
+
+ ether_addr_copy(buf->data.ra, priv->current_net_addr);
+
+ return vnt_rxtx_datahead_g(tx_context, &buf->data_head);
}

static u16 vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
@@ -628,6 +634,9 @@ static u16 vnt_rxtx_cts(struct vnt_usb_send_context *tx_context,
head = &tx_head->tx_cts.tx.mic.head;

/* Fill CTS */
+ if (tx_context->fb_option)
+ return vnt_fill_cts_fb_head(tx_context, head);
+
return vnt_fill_cts_head(tx_context, head);
}

--
2.1.0


2015-02-01 12:00:12

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 2/6] staging: vt6655: parse bb vga code out of device_intr.

Reordering the code and reversing the priv->byBBVGANew verses
priv->byBBVGACurrent check and using dev_dbg for pr_debug.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6655/device_main.c | 93 +++++++++++++++++++++---------------
1 file changed, 54 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 9a80144..870cafd 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1008,6 +1008,58 @@ static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc)
pTDInfo->byFlags = 0;
}

+static void vnt_check_bb_vga(struct vnt_private *priv)
+{
+ long dbm;
+ int i;
+
+ if (!priv->bUpdateBBVGA)
+ return;
+
+ if (priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
+ return;
+
+ if (!(priv->vif->bss_conf.assoc && priv->uCurrRSSI))
+ return;
+
+ RFvRSSITodBm(priv, (u8)priv->uCurrRSSI, &dbm);
+
+ for (i = 0; i < BB_VGA_LEVEL; i++) {
+ if (dbm < priv->ldBmThreshold[i]) {
+ priv->byBBVGANew = priv->abyBBVGA[i];
+ break;
+ }
+ }
+
+ if (priv->byBBVGANew == priv->byBBVGACurrent) {
+ priv->uBBVGADiffCount = 1;
+ return;
+ }
+
+ priv->uBBVGADiffCount++;
+
+ if (priv->uBBVGADiffCount == 1) {
+ /* first VGA diff gain */
+ BBvSetVGAGainOffset(priv, priv->byBBVGANew);
+
+ dev_dbg(&priv->pcid->dev,
+ "First RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
+ (int)dbm, priv->byBBVGANew,
+ priv->byBBVGACurrent,
+ (int)priv->uBBVGADiffCount);
+ }
+
+ if (priv->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) {
+ dev_dbg(&priv->pcid->dev,
+ "RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
+ (int)dbm, priv->byBBVGANew,
+ priv->byBBVGACurrent,
+ (int)priv->uBBVGADiffCount);
+
+ BBvSetVGAGainOffset(priv, priv->byBBVGANew);
+ }
+}
+
static irqreturn_t device_intr(int irq, void *dev_instance)
{
struct vnt_private *pDevice = dev_instance;
@@ -1015,7 +1067,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance)
unsigned long dwMIBCounter = 0;
unsigned char byOrgPageSel = 0;
int handled = 0;
- int ii = 0;
unsigned long flags;

MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
@@ -1059,44 +1110,8 @@ static irqreturn_t device_intr(int irq, void *dev_instance)

if (pDevice->dwIsr & ISR_TBTT) {
if (pDevice->vif &&
- pDevice->op_mode != NL80211_IFTYPE_ADHOC) {
- if (pDevice->bUpdateBBVGA &&
- !(pDevice->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) &&
- pDevice->vif->bss_conf.assoc &&
- pDevice->uCurrRSSI) {
- long ldBm;
-
- RFvRSSITodBm(pDevice, (unsigned char) pDevice->uCurrRSSI, &ldBm);
- for (ii = 0; ii < BB_VGA_LEVEL; ii++) {
- if (ldBm < pDevice->ldBmThreshold[ii]) {
- pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
- break;
- }
- }
- if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
- pDevice->uBBVGADiffCount++;
- if (pDevice->uBBVGADiffCount == 1) {
- // first VGA diff gain
- BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
- pr_debug("First RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
- (int)ldBm,
- pDevice->byBBVGANew,
- pDevice->byBBVGACurrent,
- (int)pDevice->uBBVGADiffCount);
- }
- if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) {
- pr_debug("RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
- (int)ldBm,
- pDevice->byBBVGANew,
- pDevice->byBBVGACurrent,
- (int)pDevice->uBBVGADiffCount);
- BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
- }
- } else {
- pDevice->uBBVGADiffCount = 1;
- }
- }
- }
+ pDevice->op_mode != NL80211_IFTYPE_ADHOC)
+ vnt_check_bb_vga(pDevice);

pDevice->bBeaconSent = false;
if (pDevice->bEnablePSMode)
--
2.1.0


2015-02-01 12:00:16

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 5/6] staging: vt6656: vnt_fill_cts_head remove unneeded NULL check.

union vnt_tx_data_head is nolonger detached from main
vnt_tx_buffer structure so this check is unnecessary.

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

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index b74f672..3b90497 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -525,9 +525,6 @@ static u16 vnt_fill_cts_head(struct vnt_usb_send_context *tx_context,
u32 cts_frame_len = 14;
u16 current_rate = tx_context->tx_rate;

- if (!head)
- return 0;
-
if (tx_context->fb_option) {
/* Auto Fall back */
struct vnt_cts_fb *buf = &head->cts_g_fb;
--
2.1.0