[PATCH v2] staging: vt6656: Fix warning: unused variable vnt_frame_time

2020-05-27 Thread Malcolm Priestley
In commit 61bb798767e4
("staging: vt6656: vnt_get_rtscts_rsvtime_le replace with rts/cts duration.")
not quite all of the code was removed.

Remove unused vnt_frame_time variable.

Reported-by: kbuild test robot 
Signed-off-by: Malcolm Priestley 
---
v2 corrected the commit 

 drivers/staging/vt6656/rxtx.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 5530c06ffd40..5dd6b4d2bf20 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -39,10 +39,6 @@ static const u16 vnt_time_stampoff[2][MAX_RATE] = {
 #define DATADUR_B   10
 #define DATADUR_A   11
 
-static const u16 vnt_frame_time[MAX_RATE] = {
-   10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
-};
-
 static const u8 vnt_phy_signal[] = {
0x00,   /* RATE_1M  */
0x01,   /* RATE_2M  */
-- 
2.27.0.rc0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Fix warning: unused variable vnt_frame_time

2020-05-27 Thread Malcolm Priestley
In commit 3436accadc3f
("staging: vt6656: Move vnt_get_frame_time and vnt_get_phy_field to rxtx")
not quite all of the code was removed.

Remove unused vnt_frame_time variable.

Reported-by: kbuild test robot 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 5530c06ffd40..5dd6b4d2bf20 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -39,10 +39,6 @@ static const u16 vnt_time_stampoff[2][MAX_RATE] = {
 #define DATADUR_B   10
 #define DATADUR_A   11
 
-static const u16 vnt_frame_time[MAX_RATE] = {
-   10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
-};
-
 static const u8 vnt_phy_signal[] = {
0x00,   /* RATE_1M  */
0x01,   /* RATE_2M  */
-- 
2.27.0.rc0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: vt6656: Move vnt_tx_usb_header to vnt_tx_context

2020-05-27 Thread Malcolm Priestley
Move the USB element out of vnt_tx_packet and vnt_beacon_xmit to
vnt_tx_context with sk_buff passed in parameters with the data now
between skb->data and skb->len.

The vnt_tx_usb header is moved from vnt_tx_buffer to usbpipe.h with the
size added to extra_tx_headroom the largest possible size.

The CONTEXT enums types are aligned with usb ones and CONTEXT_MGMT_PACKET
is removed and is never be used.

The skb_push in vnt_tx_packet is now only ever used with
vnt_get_hdr_size with variables tx_bytes and tx_header_size removed.

buf_len in vnt_usb_send_context is no longer used and replaced with
urb->actual_length in vnt_tx_context_complete.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h   |  4 +---
 drivers/staging/vt6656/main_usb.c |  3 ++-
 drivers/staging/vt6656/rxtx.c | 30 +-
 drivers/staging/vt6656/rxtx.h |  7 ---
 drivers/staging/vt6656/usbpipe.c  | 21 +++--
 drivers/staging/vt6656/usbpipe.h  |  9 -
 6 files changed, 31 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index d89f564a13c4..947530fefe94 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -206,8 +206,7 @@ struct vnt_rsp_card_init {
  * Enum of context types for SendPacket
  */
 enum {
-   CONTEXT_DATA_PACKET = 1,
-   CONTEXT_MGMT_PACKET,
+   CONTEXT_DATA_PACKET = 0,
CONTEXT_BEACON_PACKET
 };
 
@@ -239,7 +238,6 @@ struct vnt_usb_send_context {
void *priv;
struct sk_buff *skb;
void *tx_buffer;
-   unsigned int buf_len;
u32 frame_len;
u16 tx_hdr_size;
u16 tx_rate;
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index c0169e32621b..8bf851c53f4e 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -1043,7 +1043,8 @@ vt6656_probe(struct usb_interface *intf, const struct 
usb_device_id *id)
ieee80211_hw_set(priv->hw, SUPPORTS_PS);
ieee80211_hw_set(priv->hw, PS_NULLFUNC_STACK);
 
-   priv->hw->extra_tx_headroom = sizeof(struct vnt_tx_buffer);
+   priv->hw->extra_tx_headroom =
+   sizeof(struct vnt_tx_buffer) + sizeof(struct vnt_tx_usb_header);
priv->hw->max_signal = 100;
 
SET_IEEE80211_DEV(priv->hw, >dev);
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 05b9a9ee0e33..5530c06ffd40 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -512,7 +512,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
struct vnt_tx_fifo_head *tx_buffer_head;
struct vnt_usb_send_context *tx_context;
unsigned long flags;
-   u16 tx_bytes, tx_header_size;
u8 pkt_type;
 
hdr = (struct ieee80211_hdr *)(skb->data);
@@ -557,21 +556,11 @@ int vnt_tx_packet(struct vnt_private *priv, struct 
sk_buff *skb)
return -ENOMEM;
}
 
-   tx_header_size = vnt_get_hdr_size(info);
-   tx_bytes = tx_header_size + skb->len;
-   tx_header_size += sizeof(struct vnt_tx_usb_header);
-
-   tx_buffer = skb_push(skb, tx_header_size);
+   tx_buffer = skb_push(skb, vnt_get_hdr_size(info));
+   tx_context->tx_buffer = tx_buffer;
tx_buffer_head = _buffer->fifo_head;
 
-   /* Fill USB header */
-   tx_buffer->usb.tx_byte_count = cpu_to_le16(tx_bytes);
-   tx_buffer->usb.pkt_no = tx_context->pkt_no;
-   tx_buffer->usb.type = 0x00;
-
tx_context->type = CONTEXT_DATA_PACKET;
-   tx_context->tx_buffer = skb->data;
-   tx_context->buf_len = skb->len;
 
/*Set fifo controls */
if (pkt_type == PK_TYPE_11A)
@@ -624,7 +613,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
spin_lock_irqsave(>lock, flags);
 
-   if (vnt_tx_context(priv, tx_context)) {
+   if (vnt_tx_context(priv, tx_context, skb)) {
dev_kfree_skb(tx_context->skb);
spin_unlock_irqrestore(>lock, flags);
return -EIO;
@@ -639,14 +628,13 @@ int vnt_tx_packet(struct vnt_private *priv, struct 
sk_buff *skb)
 
 static int vnt_beacon_xmit(struct vnt_private *priv, struct sk_buff *skb)
 {
-   struct vnt_tx_usb_header *usb;
struct vnt_tx_short_buf_head *short_head;
struct ieee80211_tx_info *info;
struct vnt_usb_send_context *context;
struct ieee80211_mgmt *mgmt_hdr;
unsigned long flags;
u32 frame_size = skb->len + 4;
-   u16 current_rate, count;
+   u16 current_rate;
 
spin_lock_irqsave(>lock, flags);
 
@@ -663,7 +651,6 @@ static int vnt_beacon_xmit(struct vnt_private *priv, struct 
sk_buff *skb)
 
mgmt_hdr = (struct ieee80211_mgmt *)skb->data;
short_head = skb_push(skb, sizeof(*short_head));
-   

[PATCH 1/2] staging: vt6656: vnt_tx_packet use skb_clone to preserve sk_buff.

2020-05-27 Thread Malcolm Priestley
The sk_buff needs to preserved for copying to various parts
of context and passing back to mac80211

clone sk_buff in context so to continue to writing to orginal
sk_buff data area to send in vnt_tx_context.

dev_kfree_skb the context on error or dev_kfree_skb the
orignal when done. The error handling continues as before.

Only one place in function needs to change from
ieee80211_get_hdrlen_from_skb to ieee80211_hdrlen(hdr) which
is already to pointing to correct position.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index a1b16ef9b27f..05b9a9ee0e33 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -545,13 +545,18 @@ int vnt_tx_packet(struct vnt_private *priv, struct 
sk_buff *skb)
return -ENOMEM;
}
 
-   tx_context->skb = skb;
tx_context->pkt_type = pkt_type;
tx_context->frame_len = skb->len + 4;
tx_context->tx_rate =  rate->hw_value;
 
spin_unlock_irqrestore(>lock, flags);
 
+   tx_context->skb = skb_clone(skb, GFP_ATOMIC);
+   if (!tx_context->skb) {
+   tx_context->in_use = false;
+   return -ENOMEM;
+   }
+
tx_header_size = vnt_get_hdr_size(info);
tx_bytes = tx_header_size + skb->len;
tx_header_size += sizeof(struct vnt_tx_usb_header);
@@ -565,12 +570,9 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
tx_buffer->usb.type = 0x00;
 
tx_context->type = CONTEXT_DATA_PACKET;
-   tx_context->tx_buffer = tx_buffer;
+   tx_context->tx_buffer = skb->data;
tx_context->buf_len = skb->len;
 
-   /* Return skb->data to mac80211 header */
-   skb_pull(skb, tx_header_size);
-
/*Set fifo controls */
if (pkt_type == PK_TYPE_11A)
tx_buffer_head->fifo_ctl = 0;
@@ -606,7 +608,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LHEAD);
 
tx_buffer_head->frag_ctl =
-   cpu_to_le16(ieee80211_get_hdrlen_from_skb(skb) << 10);
+   cpu_to_le16(ieee80211_hdrlen(hdr->frame_control) << 10);
 
if (info->control.hw_key)
tx_context->frame_len += info->control.hw_key->icv_len;
@@ -623,10 +625,13 @@ int vnt_tx_packet(struct vnt_private *priv, struct 
sk_buff *skb)
spin_lock_irqsave(>lock, flags);
 
if (vnt_tx_context(priv, tx_context)) {
+   dev_kfree_skb(tx_context->skb);
spin_unlock_irqrestore(>lock, flags);
return -EIO;
}
 
+   dev_kfree_skb(skb);
+
spin_unlock_irqrestore(>lock, flags);
 
return 0;
-- 
2.27.0.rc0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Fix vnt_tx_usb_header static checker warning

2020-05-23 Thread Malcolm Priestley
drivers/staging/vt6656/rxtx.c:729 vnt_beacon_xmit()
warn: struct type mismatch 'vnt_beacon_buffer vs vnt_tx_usb_header'

Since the only part of vnt_beacon_buffer is used remove and
replace it with vnt_tx_usb_header.

Fixes: 9deca1e3e2b6 ("staging: vt6656: vnt_beacon_xmit use extra_tx_headroom.")
Reported-by: Dan Carpenter 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 12 ++--
 drivers/staging/vt6656/rxtx.h |  5 -
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 9ee57f7c0c88..a1b16ef9b27f 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -634,7 +634,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
 static int vnt_beacon_xmit(struct vnt_private *priv, struct sk_buff *skb)
 {
-   struct vnt_beacon_buffer *beacon_buffer;
+   struct vnt_tx_usb_header *usb;
struct vnt_tx_short_buf_head *short_head;
struct ieee80211_tx_info *info;
struct vnt_usb_send_context *context;
@@ -701,13 +701,13 @@ static int vnt_beacon_xmit(struct vnt_private *priv, 
struct sk_buff *skb)
if (priv->seq_counter > 0x0fff)
priv->seq_counter = 0;
 
-   beacon_buffer = skb_push(skb, sizeof(struct vnt_tx_usb_header));
-   beacon_buffer->usb.tx_byte_count = cpu_to_le16(count);
-   beacon_buffer->usb.pkt_no = context->pkt_no;
-   beacon_buffer->usb.type = 0x01;
+   usb = skb_push(skb, sizeof(*usb));
+   usb->tx_byte_count = cpu_to_le16(count);
+   usb->pkt_no = context->pkt_no;
+   usb->type = 0x01;
 
context->type = CONTEXT_BEACON_PACKET;
-   context->tx_buffer = beacon_buffer;
+   context->tx_buffer = usb;
context->buf_len = skb->len;
 
spin_lock_irqsave(>lock, flags);
diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h
index fd64d0838e34..f3c7b99cda73 100644
--- a/drivers/staging/vt6656/rxtx.h
+++ b/drivers/staging/vt6656/rxtx.h
@@ -179,11 +179,6 @@ struct vnt_tx_short_buf_head {
__le16 time_stamp_off;
 } __packed;
 
-struct vnt_beacon_buffer {
-   struct vnt_tx_usb_header usb;
-   struct vnt_tx_short_buf_head short_head;
-} __packed;
-
 int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb);
 int vnt_beacon_make(struct vnt_private *priv, struct ieee80211_vif *vif);
 int vnt_beacon_enable(struct vnt_private *priv, struct ieee80211_vif *vif,
-- 
2.27.0.rc0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/10] staging: vt6656: move key frag controls to vnt_fill_txkey

2020-05-21 Thread Malcolm Priestley
vnt_fill_txkey now has access to tx_buffer move cipher frag controls

The icv_len is the only thing needed from hw_key in vnt_tx_packet.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 23 +--
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index bbe449af8acf..9ee57f7c0c88 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -323,10 +323,12 @@ static bool vnt_fill_txkey(struct vnt_tx_buffer 
*tx_buffer, struct sk_buff *skb)
   tx_key->key, WLAN_KEY_LEN_WEP40);
}
 
+   fifo->frag_ctl |= cpu_to_le16(FRAGCTL_LEGACY);
break;
case WLAN_CIPHER_SUITE_TKIP:
ieee80211_get_tkip_p2k(tx_key, skb, fifo->tx_key);
 
+   fifo->frag_ctl |= cpu_to_le16(FRAGCTL_TKIP);
break;
case WLAN_CIPHER_SUITE_CCMP:
if (info->control.use_cts_prot) {
@@ -369,6 +371,7 @@ static bool vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer, 
struct sk_buff *skb)
 
memcpy(fifo->tx_key, tx_key->key, WLAN_KEY_LEN_CCMP);
 
+   fifo->frag_ctl |= cpu_to_le16(FRAGCTL_AES);
return true;
default:
break;
@@ -504,7 +507,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_tx_rate *tx_rate = >control.rates[0];
struct ieee80211_rate *rate;
-   struct ieee80211_key_conf *tx_key;
struct ieee80211_hdr *hdr;
struct vnt_tx_buffer *tx_buffer;
struct vnt_tx_fifo_head *tx_buffer_head;
@@ -606,23 +608,8 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
tx_buffer_head->frag_ctl =
cpu_to_le16(ieee80211_get_hdrlen_from_skb(skb) << 10);
 
-   if (info->control.hw_key) {
-   tx_key = info->control.hw_key;
-   switch (info->control.hw_key->cipher) {
-   case WLAN_CIPHER_SUITE_WEP40:
-   case WLAN_CIPHER_SUITE_WEP104:
-   tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_LEGACY);
-   break;
-   case WLAN_CIPHER_SUITE_TKIP:
-   tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_TKIP);
-   break;
-   case WLAN_CIPHER_SUITE_CCMP:
-   tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_AES);
-   default:
-   break;
-   }
-   tx_context->frame_len += tx_key->icv_len;
-   }
+   if (info->control.hw_key)
+   tx_context->frame_len += info->control.hw_key->icv_len;
 
tx_buffer_head->current_rate = cpu_to_le16(rate->hw_value);
 
-- 
2.25.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/10] staging: vt6656: Move calling point of vnt_fill_txkey.

2020-05-21 Thread Malcolm Priestley
Change vnt_fill_txkey to return true if mic_hdr is needed and
change calling point at where it is to be placed.

tx_buffer is already in tx_context.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 191 +-
 1 file changed, 95 insertions(+), 96 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index a0672ca51138..bbe449af8acf 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -295,94 +295,8 @@ static void vnt_fill_cts_head(struct vnt_usb_send_context 
*tx_context,
vnt_rxtx_datahead_g(tx_context, >data_head);
 }
 
-static void vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
-union vnt_tx_head *tx_head)
-{
-   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
-   struct vnt_rrv_time_rts *buf = _head->tx_rts.rts;
-   union vnt_tx_data_head *head = _head->tx_rts.tx.head;
-
-   buf->rts_rrv_time_aa = vnt_get_rts_duration(tx_context);
-   buf->rts_rrv_time_ba = buf->rts_rrv_time_aa;
-   buf->rts_rrv_time_bb = buf->rts_rrv_time_aa;
-
-   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(tx_context);
-   buf->rrv_time_b = buf->rrv_time_a;
-
-   if (info->control.hw_key) {
-   if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP)
-   head = _head->tx_rts.tx.mic.head;
-   }
-
-   vnt_rxtx_rts_g_head(tx_context, >rts_g);
-}
-
-static void vnt_rxtx_cts(struct vnt_usb_send_context *tx_context,
-union vnt_tx_head *tx_head)
-{
-   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
-   struct vnt_rrv_time_cts *buf = _head->tx_cts.cts;
-   union vnt_tx_data_head *head = _head->tx_cts.tx.head;
-
-   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(tx_context);
-   buf->rrv_time_b = buf->rrv_time_a;
-
-   buf->cts_rrv_time_ba = vnt_get_cts_duration(tx_context);
-
-   if (info->control.hw_key) {
-   if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP)
-   head = _head->tx_cts.tx.mic.head;
-   }
-
-   vnt_fill_cts_head(tx_context, head);
-}
-
-static void vnt_rxtx_ab(struct vnt_usb_send_context *tx_context,
-   union vnt_tx_head *tx_head)
-{
-   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
-   struct vnt_rrv_time_ab *buf = _head->tx_ab.ab;
-   union vnt_tx_data_head *head = _head->tx_ab.tx.head;
-
-   buf->rrv_time = vnt_rxtx_rsvtime_le16(tx_context);
-
-   if (info->control.hw_key) {
-   if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP)
-   head = _head->tx_ab.tx.mic.head;
-   }
-
-   if (info->control.use_rts) {
-   buf->rts_rrv_time = vnt_get_rts_duration(tx_context);
-
-   vnt_rxtx_rts_ab_head(tx_context, >rts_ab);
-
-   return;
-   }
-
-   vnt_rxtx_datahead_ab(tx_context, >data_head_ab);
-}
-
-static void vnt_generate_tx_parameter(struct vnt_usb_send_context *tx_context,
- struct vnt_tx_buffer *tx_buffer)
-{
-   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
-
-   if (info->control.use_cts_prot) {
-   if (info->control.use_rts) {
-   vnt_rxtx_rts(tx_context, _buffer->tx_head);
-
-   return;
-   }
-
-   vnt_rxtx_cts(tx_context, _buffer->tx_head);
-
-   return;
-   }
-
-   vnt_rxtx_ab(tx_context, _buffer->tx_head);
-}
-
-static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer, struct sk_buff 
*skb)
+/* returns true if mic_hdr is needed */
+static bool vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer, struct sk_buff 
*skb)
 {
struct vnt_tx_fifo_head *fifo = _buffer->fifo_head;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -455,10 +369,101 @@ static void vnt_fill_txkey(struct vnt_tx_buffer 
*tx_buffer, struct sk_buff *skb)
 
memcpy(fifo->tx_key, tx_key->key, WLAN_KEY_LEN_CCMP);
 
-   break;
+   return true;
default:
break;
}
+
+   return false;
+}
+
+static void vnt_rxtx_rts(struct vnt_usb_send_context *tx_context)
+{
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
+   struct vnt_tx_buffer *tx_buffer = tx_context->tx_buffer;
+   union vnt_tx_head *tx_head = _buffer->tx_head;
+   struct vnt_rrv_time_rts *buf = _head->tx_rts.rts;
+   union vnt_tx_data_head *head = _head->tx_rts.tx.head;
+
+   buf->rts_rrv_time_aa = vnt_get_rts_duration(tx_context);
+   buf->rts_rrv_time_ba = buf->rts_rrv_time_aa;
+   buf->rts_rr

[PATCH 08/10] staging: vt6656: Move tx_key inside vnt_fill_txkey.

2020-05-21 Thread Malcolm Priestley
tx_key can be got directly from info.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index b9164142e2b5..a0672ca51138 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -382,12 +382,11 @@ static void vnt_generate_tx_parameter(struct 
vnt_usb_send_context *tx_context,
vnt_rxtx_ab(tx_context, _buffer->tx_head);
 }
 
-static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer,
-  struct ieee80211_key_conf *tx_key,
-  struct sk_buff *skb)
+static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer, struct sk_buff 
*skb)
 {
struct vnt_tx_fifo_head *fifo = _buffer->fifo_head;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+   struct ieee80211_key_conf *tx_key = info->control.hw_key;
struct vnt_mic_hdr *mic_hdr;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
u64 pn64;
@@ -629,7 +628,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
if (info->control.hw_key) {
tx_key = info->control.hw_key;
if (tx_key->keylen > 0)
-   vnt_fill_txkey(tx_buffer, tx_key, skb);
+   vnt_fill_txkey(tx_buffer, skb);
}
 
priv->seq_counter = (le16_to_cpu(hdr->seq_ctrl) &
-- 
2.25.1


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/10] staging: vt6656: move tx_body_size/payload_len to skb->len

2020-05-21 Thread Malcolm Priestley
both variables can be removed and replaced with skb->len.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 2d7a8fc70d92..b9164142e2b5 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -384,13 +384,14 @@ static void vnt_generate_tx_parameter(struct 
vnt_usb_send_context *tx_context,
 
 static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer,
   struct ieee80211_key_conf *tx_key,
-  struct sk_buff *skb, u16 payload_len)
+  struct sk_buff *skb)
 {
struct vnt_tx_fifo_head *fifo = _buffer->fifo_head;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct vnt_mic_hdr *mic_hdr;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
u64 pn64;
+   u16 payload_len = skb->len;
u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
 
/* strip header and icv len from payload */
@@ -505,7 +506,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
struct vnt_tx_fifo_head *tx_buffer_head;
struct vnt_usb_send_context *tx_context;
unsigned long flags;
-   u16 tx_bytes, tx_header_size, tx_body_size;
+   u16 tx_bytes, tx_header_size;
u8 pkt_type;
 
hdr = (struct ieee80211_hdr *)(skb->data);
@@ -546,8 +547,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
spin_unlock_irqrestore(>lock, flags);
 
tx_header_size = vnt_get_hdr_size(info);
-   tx_body_size = skb->len;
-   tx_bytes = tx_header_size + tx_body_size;
+   tx_bytes = tx_header_size + skb->len;
tx_header_size += sizeof(struct vnt_tx_usb_header);
 
tx_buffer = skb_push(skb, tx_header_size);
@@ -629,7 +629,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
if (info->control.hw_key) {
tx_key = info->control.hw_key;
if (tx_key->keylen > 0)
-   vnt_fill_txkey(tx_buffer, tx_key, skb, tx_body_size);
+   vnt_fill_txkey(tx_buffer, tx_key, skb);
}
 
priv->seq_counter = (le16_to_cpu(hdr->seq_ctrl) &
-- 
2.25.1


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/10] staging: vt6656: Move key_buffer inside vnt_fill_txkey.

2020-05-21 Thread Malcolm Priestley
Use vnt_tx_fifo_head to point directly at tx_key removing key_buffer.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 310d0eccebd1..2d7a8fc70d92 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -383,9 +383,10 @@ static void vnt_generate_tx_parameter(struct 
vnt_usb_send_context *tx_context,
 }
 
 static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer,
-  u8 *key_buffer, struct ieee80211_key_conf *tx_key,
+  struct ieee80211_key_conf *tx_key,
   struct sk_buff *skb, u16 payload_len)
 {
+   struct vnt_tx_fifo_head *fifo = _buffer->fifo_head;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct vnt_mic_hdr *mic_hdr;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
@@ -399,18 +400,18 @@ static void vnt_fill_txkey(struct vnt_tx_buffer 
*tx_buffer,
switch (tx_key->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
-   memcpy(key_buffer, iv, 3);
-   memcpy(key_buffer + 3, tx_key->key, tx_key->keylen);
+   memcpy(fifo->tx_key, iv, 3);
+   memcpy(fifo->tx_key + 3, tx_key->key, tx_key->keylen);
 
if (tx_key->keylen == WLAN_KEY_LEN_WEP40) {
-   memcpy(key_buffer + 8, iv, 3);
-   memcpy(key_buffer + 11,
+   memcpy(fifo->tx_key + 8, iv, 3);
+   memcpy(fifo->tx_key + 11,
   tx_key->key, WLAN_KEY_LEN_WEP40);
}
 
break;
case WLAN_CIPHER_SUITE_TKIP:
-   ieee80211_get_tkip_p2k(tx_key, skb, key_buffer);
+   ieee80211_get_tkip_p2k(tx_key, skb, fifo->tx_key);
 
break;
case WLAN_CIPHER_SUITE_CCMP:
@@ -452,7 +453,7 @@ static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer,
if (ieee80211_has_a4(hdr->frame_control))
ether_addr_copy(mic_hdr->addr4, hdr->addr4);
 
-   memcpy(key_buffer, tx_key->key, WLAN_KEY_LEN_CCMP);
+   memcpy(fifo->tx_key, tx_key->key, WLAN_KEY_LEN_CCMP);
 
break;
default:
@@ -628,8 +629,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
if (info->control.hw_key) {
tx_key = info->control.hw_key;
if (tx_key->keylen > 0)
-   vnt_fill_txkey(tx_buffer, tx_buffer_head->tx_key,
-  tx_key, skb, tx_body_size);
+   vnt_fill_txkey(tx_buffer, tx_key, skb, tx_body_size);
}
 
priv->seq_counter = (le16_to_cpu(hdr->seq_ctrl) &
-- 
2.25.1


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/10] staging: vt6656: rxtx use ieee80211_tx_info for rts/cts control

2020-05-21 Thread Malcolm Priestley
Use the control for rts/cts exhanges replacing need_rts and use_cts_prot for
packet type PK_TYPE_11GB / PK_TYPE_11GA

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index ea5bcc772668..310d0eccebd1 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -338,8 +338,7 @@ static void vnt_rxtx_cts(struct vnt_usb_send_context 
*tx_context,
 }
 
 static void vnt_rxtx_ab(struct vnt_usb_send_context *tx_context,
-   union vnt_tx_head *tx_head,
-   bool need_rts)
+   union vnt_tx_head *tx_head)
 {
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
struct vnt_rrv_time_ab *buf = _head->tx_ab.ab;
@@ -352,7 +351,7 @@ static void vnt_rxtx_ab(struct vnt_usb_send_context 
*tx_context,
head = _head->tx_ab.tx.mic.head;
}
 
-   if (need_rts) {
+   if (info->control.use_rts) {
buf->rts_rrv_time = vnt_get_rts_duration(tx_context);
 
vnt_rxtx_rts_ab_head(tx_context, >rts_ab);
@@ -364,12 +363,12 @@ static void vnt_rxtx_ab(struct vnt_usb_send_context 
*tx_context,
 }
 
 static void vnt_generate_tx_parameter(struct vnt_usb_send_context *tx_context,
- struct vnt_tx_buffer *tx_buffer,
- bool need_rts)
+ struct vnt_tx_buffer *tx_buffer)
 {
-   if (tx_context->pkt_type == PK_TYPE_11GB ||
-   tx_context->pkt_type == PK_TYPE_11GA) {
-   if (need_rts) {
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
+
+   if (info->control.use_cts_prot) {
+   if (info->control.use_rts) {
vnt_rxtx_rts(tx_context, _buffer->tx_head);
 
return;
@@ -380,7 +379,7 @@ static void vnt_generate_tx_parameter(struct 
vnt_usb_send_context *tx_context,
return;
}
 
-   vnt_rxtx_ab(tx_context, _buffer->tx_head, need_rts);
+   vnt_rxtx_ab(tx_context, _buffer->tx_head);
 }
 
 static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer,
@@ -507,7 +506,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
unsigned long flags;
u16 tx_bytes, tx_header_size, tx_body_size;
u8 pkt_type;
-   bool need_rts = false;
 
hdr = (struct ieee80211_hdr *)(skb->data);
 
@@ -594,10 +592,8 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
if (ieee80211_has_retry(hdr->frame_control))
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LRETRY);
 
-   if (tx_rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) {
-   need_rts = true;
+   if (info->control.use_rts)
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_RTS);
-   }
 
if (ieee80211_has_a4(hdr->frame_control))
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LHEAD);
@@ -625,7 +621,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
tx_buffer_head->current_rate = cpu_to_le16(rate->hw_value);
 
-   vnt_generate_tx_parameter(tx_context, tx_buffer, need_rts);
+   vnt_generate_tx_parameter(tx_context, tx_buffer);
 
tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG);
 
-- 
2.25.1


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/10] staging: vt6656: use ieee80211_tx_info to replace need_mic

2020-05-21 Thread Malcolm Priestley
Use the info->control.hw_key to replace need mic which is only
present when info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 39 +--
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 87fe7df07f03..ea5bcc772668 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -296,8 +296,9 @@ static void vnt_fill_cts_head(struct vnt_usb_send_context 
*tx_context,
 }
 
 static void vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
-union vnt_tx_head *tx_head, bool need_mic)
+union vnt_tx_head *tx_head)
 {
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
struct vnt_rrv_time_rts *buf = _head->tx_rts.rts;
union vnt_tx_data_head *head = _head->tx_rts.tx.head;
 
@@ -308,15 +309,18 @@ static void vnt_rxtx_rts(struct vnt_usb_send_context 
*tx_context,
buf->rrv_time_a = vnt_rxtx_rsvtime_le16(tx_context);
buf->rrv_time_b = buf->rrv_time_a;
 
-   if (need_mic)
-   head = _head->tx_rts.tx.mic.head;
+   if (info->control.hw_key) {
+   if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP)
+   head = _head->tx_rts.tx.mic.head;
+   }
 
vnt_rxtx_rts_g_head(tx_context, >rts_g);
 }
 
 static void vnt_rxtx_cts(struct vnt_usb_send_context *tx_context,
-union vnt_tx_head *tx_head, bool need_mic)
+union vnt_tx_head *tx_head)
 {
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
struct vnt_rrv_time_cts *buf = _head->tx_cts.cts;
union vnt_tx_data_head *head = _head->tx_cts.tx.head;
 
@@ -325,23 +329,28 @@ static void vnt_rxtx_cts(struct vnt_usb_send_context 
*tx_context,
 
buf->cts_rrv_time_ba = vnt_get_cts_duration(tx_context);
 
-   if (need_mic)
-   head = _head->tx_cts.tx.mic.head;
+   if (info->control.hw_key) {
+   if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP)
+   head = _head->tx_cts.tx.mic.head;
+   }
 
vnt_fill_cts_head(tx_context, head);
 }
 
 static void vnt_rxtx_ab(struct vnt_usb_send_context *tx_context,
union vnt_tx_head *tx_head,
-   bool need_rts, bool need_mic)
+   bool need_rts)
 {
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_context->skb);
struct vnt_rrv_time_ab *buf = _head->tx_ab.ab;
union vnt_tx_data_head *head = _head->tx_ab.tx.head;
 
buf->rrv_time = vnt_rxtx_rsvtime_le16(tx_context);
 
-   if (need_mic)
-   head = _head->tx_ab.tx.mic.head;
+   if (info->control.hw_key) {
+   if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP)
+   head = _head->tx_ab.tx.mic.head;
+   }
 
if (need_rts) {
buf->rts_rrv_time = vnt_get_rts_duration(tx_context);
@@ -356,22 +365,22 @@ static void vnt_rxtx_ab(struct vnt_usb_send_context 
*tx_context,
 
 static void vnt_generate_tx_parameter(struct vnt_usb_send_context *tx_context,
  struct vnt_tx_buffer *tx_buffer,
- u32 need_mic, bool need_rts)
+ bool need_rts)
 {
if (tx_context->pkt_type == PK_TYPE_11GB ||
tx_context->pkt_type == PK_TYPE_11GA) {
if (need_rts) {
-   vnt_rxtx_rts(tx_context, _buffer->tx_head, need_mic);
+   vnt_rxtx_rts(tx_context, _buffer->tx_head);
 
return;
}
 
-   vnt_rxtx_cts(tx_context, _buffer->tx_head, need_mic);
+   vnt_rxtx_cts(tx_context, _buffer->tx_head);
 
return;
}
 
-   vnt_rxtx_ab(tx_context, _buffer->tx_head, need_rts, need_mic);
+   vnt_rxtx_ab(tx_context, _buffer->tx_head, need_rts);
 }
 
 static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer,
@@ -499,7 +508,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
u16 tx_bytes, tx_header_size, tx_body_size;
u8 pkt_type;
bool need_rts = false;
-   bool need_mic = false;
 
hdr = (struct ieee80211_hdr *)(skb->data);
 
@@ -609,7 +617,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
break;
case WLAN_CIPHER_SUITE_CCMP:
tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_AES);
-   need_mic = true;
default:
break;
}
@@ -618,7 +625,7 @@ i

[PATCH 03/10] staging: vt6656: Move vnt_mic_hdr pointers to vnt_fill_txkey

2020-05-21 Thread Malcolm Priestley
mic_hdr has three possible locations ieee80211_tx_info can controls
these with control.use_cts_prot for rts or cts exchange or otherwise
the rts/data position.

Removing double pointer.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 37 ++-
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 24acc2de0fb9..87fe7df07f03 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -356,40 +356,30 @@ static void vnt_rxtx_ab(struct vnt_usb_send_context 
*tx_context,
 
 static void vnt_generate_tx_parameter(struct vnt_usb_send_context *tx_context,
  struct vnt_tx_buffer *tx_buffer,
- struct vnt_mic_hdr **mic_hdr,
  u32 need_mic, bool need_rts)
 {
if (tx_context->pkt_type == PK_TYPE_11GB ||
tx_context->pkt_type == PK_TYPE_11GA) {
if (need_rts) {
-   if (need_mic)
-   *mic_hdr =
-   _buffer->tx_head.tx_rts.tx.mic.hdr;
-
vnt_rxtx_rts(tx_context, _buffer->tx_head, need_mic);
 
return;
}
 
-   if (need_mic)
-   *mic_hdr = _buffer->tx_head.tx_cts.tx.mic.hdr;
-
vnt_rxtx_cts(tx_context, _buffer->tx_head, need_mic);
 
return;
}
 
-   if (need_mic)
-   *mic_hdr = _buffer->tx_head.tx_ab.tx.mic.hdr;
-
vnt_rxtx_ab(tx_context, _buffer->tx_head, need_rts, need_mic);
 }
 
-static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
+static void vnt_fill_txkey(struct vnt_tx_buffer *tx_buffer,
   u8 *key_buffer, struct ieee80211_key_conf *tx_key,
-  struct sk_buff *skb, u16 payload_len,
-  struct vnt_mic_hdr *mic_hdr)
+  struct sk_buff *skb, u16 payload_len)
 {
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+   struct vnt_mic_hdr *mic_hdr;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
u64 pn64;
u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
@@ -416,9 +406,14 @@ static void vnt_fill_txkey(struct vnt_usb_send_context 
*tx_context,
 
break;
case WLAN_CIPHER_SUITE_CCMP:
-
-   if (!mic_hdr)
-   return;
+   if (info->control.use_cts_prot) {
+   if (info->control.use_rts)
+   mic_hdr = _buffer->tx_head.tx_rts.tx.mic.hdr;
+   else
+   mic_hdr = _buffer->tx_head.tx_cts.tx.mic.hdr;
+   } else {
+   mic_hdr = _buffer->tx_head.tx_ab.tx.mic.hdr;
+   }
 
mic_hdr->id = 0x59;
mic_hdr->payload_len = cpu_to_be16(payload_len);
@@ -497,7 +492,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
struct ieee80211_rate *rate;
struct ieee80211_key_conf *tx_key;
struct ieee80211_hdr *hdr;
-   struct vnt_mic_hdr *mic_hdr = NULL;
struct vnt_tx_buffer *tx_buffer;
struct vnt_tx_fifo_head *tx_buffer_head;
struct vnt_usb_send_context *tx_context;
@@ -624,16 +618,15 @@ int vnt_tx_packet(struct vnt_private *priv, struct 
sk_buff *skb)
 
tx_buffer_head->current_rate = cpu_to_le16(rate->hw_value);
 
-   vnt_generate_tx_parameter(tx_context, tx_buffer, _hdr,
- need_mic, need_rts);
+   vnt_generate_tx_parameter(tx_context, tx_buffer, need_mic, need_rts);
 
tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG);
 
if (info->control.hw_key) {
tx_key = info->control.hw_key;
if (tx_key->keylen > 0)
-   vnt_fill_txkey(tx_context, tx_buffer_head->tx_key,
-  tx_key, skb, tx_body_size, mic_hdr);
+   vnt_fill_txkey(tx_buffer, tx_buffer_head->tx_key,
+  tx_key, skb, tx_body_size);
}
 
priv->seq_counter = (le16_to_cpu(hdr->seq_ctrl) &
-- 
2.25.1


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/10] staging: vt6656: rxtx remove unused need_ack

2020-05-21 Thread Malcolm Priestley
need_ack is no longer used by driver remove it.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h | 1 -
 drivers/staging/vt6656/rxtx.c   | 5 +
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 0486aabba061..d89f564a13c4 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -246,7 +246,6 @@ struct vnt_usb_send_context {
u8 type;
u8 pkt_no;
u8 pkt_type;
-   u8 need_ack;
bool in_use;
 };
 
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index a47f42bedfa9..24acc2de0fb9 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -539,7 +539,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
tx_context->skb = skb;
tx_context->pkt_type = pkt_type;
-   tx_context->need_ack = false;
tx_context->frame_len = skb->len + 4;
tx_context->tx_rate =  rate->hw_value;
 
@@ -587,10 +586,8 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us);
}
 
-   if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
+   if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_NEEDACK);
-   tx_context->need_ack = true;
-   }
 
if (ieee80211_has_retry(hdr->frame_control))
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LRETRY);
-- 
2.25.1


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/10] staging: vt6656: remove ieee80211_hdr from vnt_usb_send_context.

2020-05-21 Thread Malcolm Priestley
It is only used in one place were it can be pointed to at skb->data.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h | 1 -
 drivers/staging/vt6656/rxtx.c   | 5 +
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index d1b19dcaf991..0486aabba061 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -238,7 +238,6 @@ struct vnt_rcb {
 struct vnt_usb_send_context {
void *priv;
struct sk_buff *skb;
-   struct ieee80211_hdr *hdr;
void *tx_buffer;
unsigned int buf_len;
u32 frame_len;
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 8f9904c8045c..a47f42bedfa9 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -73,8 +73,6 @@ static struct vnt_usb_send_context
context = priv->tx_context[ii];
if (!context->in_use) {
context->in_use = true;
-   context->hdr = NULL;
-
return context;
}
}
@@ -392,7 +390,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context 
*tx_context,
   struct sk_buff *skb, u16 payload_len,
   struct vnt_mic_hdr *mic_hdr)
 {
-   struct ieee80211_hdr *hdr = tx_context->hdr;
+   struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
u64 pn64;
u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
 
@@ -544,7 +542,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
tx_context->need_ack = false;
tx_context->frame_len = skb->len + 4;
tx_context->tx_rate =  rate->hw_value;
-   tx_context->hdr = hdr;
 
spin_unlock_irqrestore(>lock, flags);
 
-- 
2.25.1


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/4] staging: vt6656: vnt_beacon_xmit use extra_tx_headroom.

2020-05-18 Thread Malcolm Priestley




On 18/05/2020 13:39, Dan Carpenter wrote:

On Sat, May 16, 2020 at 11:39:34AM +0100, Malcolm Priestley wrote:

Create room for vnt_tx_short_buf_head in sk_buff and vnt_tx_usb_header.

The struct ieee80211_mgmt is not longer in the header and is at
the initial skb->data point.


I feel like the SubmittingPatches guidelines on verb tenses and not
saying "this patch" or "I" has got everyone so worried that it's like
playing Taboo.  Do you mean that the struct moved before or after we
aply *this patch*?
The struct has not moved, before skb->data was copied on to the address 
along with the rest of frame.


So now struct needs to be at skb->data.



Signed-off-by: Malcolm Priestley 


I can't understand the point of this patch at all.  Is it a fix or a
clean up?  If I had to guess from the subjec, I would say it's a
performance improvement but I don't know.
Well there is a performance improvement as there is only one buffer 
instead of two.


Mainly to bring into line with other drivers in the mac80211 tree there
is no need for a secondary buffer in driver.

Regards

Malcolm

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging: vt6656: use usb_anchor for tx queue.

2020-05-16 Thread Malcolm Priestley
Use usb_anchor to track tx submitted urbs and initialize the
urb as needed in vnt_tx_context.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h   |  2 +-
 drivers/staging/vt6656/main_usb.c | 18 --
 drivers/staging/vt6656/usbpipe.c  | 14 --
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 08294b21c4e9..d1b19dcaf991 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -238,7 +238,6 @@ struct vnt_rcb {
 struct vnt_usb_send_context {
void *priv;
struct sk_buff *skb;
-   struct urb *urb;
struct ieee80211_hdr *hdr;
void *tx_buffer;
unsigned int buf_len;
@@ -292,6 +291,7 @@ struct vnt_private {
 
/* Variables to track resources for the BULK Out Pipe */
struct vnt_usb_send_context *tx_context[CB_MAX_TX_DESC];
+   struct usb_anchor tx_submitted;
u32 num_tx_context;
 
/* Variables to track resources for the Interrupt In Pipe */
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 930ee424ecdf..c0169e32621b 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -445,17 +445,13 @@ static void vnt_free_tx_bufs(struct vnt_private *priv)
struct vnt_usb_send_context *tx_context;
int ii;
 
+   usb_kill_anchored_urbs(>tx_submitted);
+
for (ii = 0; ii < priv->num_tx_context; ii++) {
tx_context = priv->tx_context[ii];
if (!tx_context)
continue;
 
-   /* deallocate URBs */
-   if (tx_context->urb) {
-   usb_kill_urb(tx_context->urb);
-   usb_free_urb(tx_context->urb);
-   }
-
kfree(tx_context);
}
 }
@@ -496,6 +492,8 @@ static int vnt_alloc_bufs(struct vnt_private *priv)
struct vnt_rcb *rcb;
int ii;
 
+   init_usb_anchor(>tx_submitted);
+
for (ii = 0; ii < priv->num_tx_context; ii++) {
tx_context = kmalloc(sizeof(*tx_context), GFP_KERNEL);
if (!tx_context) {
@@ -506,14 +504,6 @@ static int vnt_alloc_bufs(struct vnt_private *priv)
priv->tx_context[ii] = tx_context;
tx_context->priv = priv;
tx_context->pkt_no = ii;
-
-   /* allocate URBs */
-   tx_context->urb = usb_alloc_urb(0, GFP_KERNEL);
-   if (!tx_context->urb) {
-   ret = -ENOMEM;
-   goto free_tx;
-   }
-
tx_context->in_use = false;
}
 
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 43f1ef32a9ce..2164f45e13ab 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -456,7 +456,7 @@ int vnt_tx_context(struct vnt_private *priv,
   struct vnt_usb_send_context *context)
 {
int status;
-   struct urb *urb = context->urb;
+   struct urb *urb;
 
if (test_bit(DEVICE_FLAGS_DISCONNECTED, >flags)) {
context->in_use = false;
@@ -468,6 +468,12 @@ int vnt_tx_context(struct vnt_private *priv,
return -E2BIG;
}
 
+   urb = usb_alloc_urb(0, GFP_ATOMIC);
+   if (!urb) {
+   context->in_use = false;
+   return -ENOMEM;
+   }
+
usb_fill_bulk_urb(urb,
  priv->usb,
  usb_sndbulkpipe(priv->usb, 3),
@@ -476,12 +482,16 @@ int vnt_tx_context(struct vnt_private *priv,
  vnt_tx_context_complete,
  context);
 
+   usb_anchor_urb(urb, >tx_submitted);
+
status = usb_submit_urb(urb, GFP_ATOMIC);
if (status) {
dev_dbg(>usb->dev, "Submit Tx URB failed %d\n", status);
-
+   usb_unanchor_urb(urb);
context->in_use = false;
}
 
+   usb_free_urb(urb);
+
return status;
 }
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging: vt6656: vnt_usb_send_context remove variable data.

2020-05-16 Thread Malcolm Priestley
A limit is also placed in vnt_tx_context of MAX_TOTAL_SIZE_WITH_ALL_HEADERS
limiting size.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h  | 1 -
 drivers/staging/vt6656/rxtx.c| 3 ---
 drivers/staging/vt6656/usbpipe.c | 5 +
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 074b98dfac91..08294b21c4e9 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -250,7 +250,6 @@ struct vnt_usb_send_context {
u8 pkt_type;
u8 need_ack;
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 cf194c95df03..8f9904c8045c 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -73,9 +73,6 @@ static struct vnt_usb_send_context
context = priv->tx_context[ii];
if (!context->in_use) {
context->in_use = true;
-   memset(context->data, 0,
-  MAX_TOTAL_SIZE_WITH_ALL_HEADERS);
-
context->hdr = NULL;
 
return context;
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 904645fa0eb0..43f1ef32a9ce 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -463,6 +463,11 @@ int vnt_tx_context(struct vnt_private *priv,
return -ENODEV;
}
 
+   if (context->buf_len > MAX_TOTAL_SIZE_WITH_ALL_HEADERS) {
+   context->in_use = false;
+   return -E2BIG;
+   }
+
usb_fill_bulk_urb(urb,
  priv->usb,
  usb_sndbulkpipe(priv->usb, 3),
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] staging: vt6656: vnt_beacon_xmit use extra_tx_headroom.

2020-05-16 Thread Malcolm Priestley
Create room for vnt_tx_short_buf_head in sk_buff and vnt_tx_usb_header.

The struct ieee80211_mgmt is not longer in the header and is at
the initial skb->data point.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 22 +-
 drivers/staging/vt6656/rxtx.h |  5 +
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 792833f8192a..cf194c95df03 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -684,8 +684,9 @@ static int vnt_beacon_xmit(struct vnt_private *priv, struct 
sk_buff *skb)
 
spin_unlock_irqrestore(>lock, flags);
 
-   beacon_buffer = (struct vnt_beacon_buffer *)>data[0];
-   short_head = _buffer->short_head;
+   mgmt_hdr = (struct ieee80211_mgmt *)skb->data;
+   short_head = skb_push(skb, sizeof(*short_head));
+   count = skb->len;
 
if (priv->bb_type == BB_TYPE_11A) {
current_rate = RATE_6M;
@@ -710,10 +711,6 @@ static int vnt_beacon_xmit(struct vnt_private *priv, 
struct sk_buff *skb)
vnt_time_stamp_off(priv, current_rate);
}
 
-   /* Generate Beacon Header */
-   mgmt_hdr = _buffer->mgmt_hdr;
-   memcpy(mgmt_hdr, skb->data, skb->len);
-
/* Get Duration */
short_head->duration = mgmt_hdr->duration;
 
@@ -732,15 +729,14 @@ static int vnt_beacon_xmit(struct vnt_private *priv, 
struct sk_buff *skb)
if (priv->seq_counter > 0x0fff)
priv->seq_counter = 0;
 
-   count = sizeof(struct vnt_tx_short_buf_head) + skb->len;
-
-   beacon_buffer->tx_byte_count = cpu_to_le16(count);
-   beacon_buffer->pkt_no = context->pkt_no;
-   beacon_buffer->type = 0x01;
+   beacon_buffer = skb_push(skb, sizeof(struct vnt_tx_usb_header));
+   beacon_buffer->usb.tx_byte_count = cpu_to_le16(count);
+   beacon_buffer->usb.pkt_no = context->pkt_no;
+   beacon_buffer->usb.type = 0x01;
 
context->type = CONTEXT_BEACON_PACKET;
-   context->tx_buffer = >data;
-   context->buf_len = count + 4; /* USB header */
+   context->tx_buffer = beacon_buffer;
+   context->buf_len = skb->len;
 
spin_lock_irqsave(>lock, flags);
 
diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h
index 819b45394673..fd64d0838e34 100644
--- a/drivers/staging/vt6656/rxtx.h
+++ b/drivers/staging/vt6656/rxtx.h
@@ -180,11 +180,8 @@ struct vnt_tx_short_buf_head {
 } __packed;
 
 struct vnt_beacon_buffer {
-   u8 type;
-   u8 pkt_no;
-   __le16 tx_byte_count;
+   struct vnt_tx_usb_header usb;
struct vnt_tx_short_buf_head short_head;
-   struct ieee80211_mgmt mgmt_hdr;
 } __packed;
 
 int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb);
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] staging: vt6656: Use sk_buff buffer for tx header

2020-05-16 Thread Malcolm Priestley
mac80211 can provide space for the driver to put a tx header on
the skb buffer instead coping the entire frame on to a local
buffer with the header.

To use this extra_tx_headroom must be set in mac80211 with the largest
possible header which is struct vnt_tx_buffer.

The driver has 8 possible combinations of tx header size which
are found in vnt_get_hdr_size replacing vnt_mac_hdr_pos.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h   |  1 +
 drivers/staging/vt6656/main_usb.c |  1 +
 drivers/staging/vt6656/rxtx.c | 91 ++-
 drivers/staging/vt6656/rxtx.h |  8 ++-
 drivers/staging/vt6656/usbpipe.c  |  2 +-
 5 files changed, 61 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index d19d802b5d4f..074b98dfac91 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -240,6 +240,7 @@ struct vnt_usb_send_context {
struct sk_buff *skb;
struct urb *urb;
struct ieee80211_hdr *hdr;
+   void *tx_buffer;
unsigned int buf_len;
u32 frame_len;
u16 tx_hdr_size;
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index b5790d4d7152..930ee424ecdf 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -1053,6 +1053,7 @@ vt6656_probe(struct usb_interface *intf, const struct 
usb_device_id *id)
ieee80211_hw_set(priv->hw, SUPPORTS_PS);
ieee80211_hw_set(priv->hw, PS_NULLFUNC_STACK);
 
+   priv->hw->extra_tx_headroom = sizeof(struct vnt_tx_buffer);
priv->hw->max_signal = 100;
 
SET_IEEE80211_DEV(priv->hw, >dev);
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 8348ffe6ebfa..792833f8192a 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -188,19 +188,6 @@ static __le16 vnt_get_cts_duration(struct 
vnt_usb_send_context *context)
context->frame_len, info);
 }
 
-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 void vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
struct vnt_tx_datahead_g *buf)
 {
@@ -221,8 +208,6 @@ static void vnt_rxtx_datahead_g(struct vnt_usb_send_context 
*tx_context,
buf->time_stamp_off_a = vnt_time_stamp_off(priv, rate);
buf->time_stamp_off_b = vnt_time_stamp_off(priv,
   priv->top_cck_basic_rate);
-
-   tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, >hdr);
 }
 
 static void vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,
@@ -241,8 +226,6 @@ static void vnt_rxtx_datahead_ab(struct 
vnt_usb_send_context *tx_context,
/* Get Duration and TimeStampOff */
buf->duration = hdr->duration_id;
buf->time_stamp_off = vnt_time_stamp_off(priv, rate);
-
-   tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, >hdr);
 }
 
 static void vnt_fill_ieee80211_rts(struct vnt_usb_send_context *tx_context,
@@ -479,6 +462,39 @@ static void vnt_fill_txkey(struct vnt_usb_send_context 
*tx_context,
}
 }
 
+static u16 vnt_get_hdr_size(struct ieee80211_tx_info *info)
+{
+   u16 size = sizeof(struct vnt_tx_datahead_ab);
+
+   if (info->control.use_cts_prot) {
+   if (info->control.use_rts)
+   size = sizeof(struct vnt_rts_g);
+   else
+   size = sizeof(struct vnt_cts);
+   } else if (info->control.use_rts) {
+   size = sizeof(struct vnt_rts_ab);
+   }
+
+   if (info->control.hw_key) {
+   if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP)
+   size += sizeof(struct vnt_mic_hdr);
+   }
+
+   /* Get rrv_time header */
+   if (info->control.use_cts_prot) {
+   if (info->control.use_rts)
+   size += sizeof(struct vnt_rrv_time_rts);
+   else
+   size += sizeof(struct vnt_rrv_time_cts);
+   } else {
+   size += sizeof(struct vnt_rrv_time_ab);
+   }
+
+   size += sizeof(struct vnt_tx_fifo_head);
+
+   return size;
+}
+
 int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 {
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -531,12 +547,29 @@ int vnt_tx_packet(struct vnt_private *priv, struct 
sk_buff *skb)
tx_context->need_ack = false;
tx_context->frame_

[PATCH 6/6] staging: vt6656: remove difs / sifs adjustments.

2020-05-05 Thread Malcolm Priestley
Now mac89211 is doing frame timing in rxtx these vendor adjustments need
to be removed.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/card.c | 32 
 1 file changed, 32 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 3cb97c4daeb8..10f3dfda83b5 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -149,38 +149,6 @@ int vnt_update_ifs(struct vnt_private *priv)
 
priv->eifs = C_EIFS;
 
-   switch (priv->rf_type) {
-   case RF_VT3226D0:
-   if (priv->bb_type != BB_TYPE_11B) {
-   priv->sifs -= 1;
-   priv->difs -= 1;
-   break;
-   }
-   /* fall through */
-   case RF_AIROHA7230:
-   case RF_AL2230:
-   case RF_AL2230S:
-   if (priv->bb_type != BB_TYPE_11B)
-   break;
-   /* fall through */
-   case RF_RFMD2959:
-   case RF_VT3226:
-   case RF_VT3342A0:
-   priv->sifs -= 3;
-   priv->difs -= 3;
-   break;
-   case RF_MAXIM2829:
-   if (priv->bb_type == BB_TYPE_11A) {
-   priv->sifs -= 5;
-   priv->difs -= 5;
-   } else {
-   priv->sifs -= 2;
-   priv->difs -= 2;
-   }
-
-   break;
-   }
-
data[0] = (u8)priv->sifs;
data[1] = (u8)priv->difs;
data[2] = (u8)priv->eifs;
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/6] staging: vt6656: vnt_get_rtscts_rsvtime_le replace with rts/cts duration.

2020-05-05 Thread Malcolm Priestley
rsvtime is the time needed in firmware to process the received
frame time in firmware so they can be the same as vnt_get_rts_duration
or vnt_get_cts_duration where appropriate.

The rts_rrv_time are now all the same timing in vnt_rxtx_rts.

So vnt_get_rtscts_rsvtime_le and and vnt_get_frame_time are no longer
required.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 113 ++
 1 file changed, 5 insertions(+), 108 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 47da9dabb133..8348ffe6ebfa 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -13,7 +13,6 @@
  *
  * Functions:
  *  vnt_generate_tx_parameter - Generate tx dma required parameter.
- *  vnt_get_rtscts_rsvtime_le- get rts/cts reserved time
  *  vnt_get_rsvtime- get frame reserved time
  *  vnt_fill_cts_head- fulfill CTS ctl header
  *
@@ -92,37 +91,6 @@ static struct vnt_usb_send_context
return NULL;
 }
 
-/* Frame time for Tx */
-static unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
-  unsigned int frame_length, u16 tx_rate)
-{
-   unsigned int frame_time;
-   unsigned int preamble;
-   unsigned int rate;
-
-   if (tx_rate > RATE_54M)
-   return 0;
-
-   rate = (unsigned int)vnt_frame_time[tx_rate];
-
-   if (tx_rate <= RATE_11M) {
-   if (preamble_type == PREAMBLE_SHORT)
-   preamble = 96;
-   else
-   preamble = 192;
-
-   frame_time = DIV_ROUND_UP(frame_length * 80, rate);
-   return preamble + frame_time;
-   }
-
-   frame_time = DIV_ROUND_UP(frame_length * 8 + 22, rate);
-   frame_time = frame_time * 4;
-
-   if (pkt_type != PK_TYPE_11A)
-   frame_time += 6;
-   return 20 + frame_time;
-}
-
 /* Get Length, Service, and Signal fields of Phy for Tx */
 static void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
  u16 tx_rate, u8 pkt_type,
@@ -202,59 +170,6 @@ static __le16 vnt_rxtx_rsvtime_le16(struct 
vnt_usb_send_context *context)
 rate);
 }
 
-static __le16 vnt_get_rtscts_rsvtime_le(struct vnt_private *priv, u8 rsv_type,
-   u8 pkt_type, u32 frame_length,
-   u16 current_rate)
-{
-   u32 rrv_time, rts_time, cts_time, ack_time, data_time;
-
-   rrv_time = 0;
-   rts_time = 0;
-   cts_time = 0;
-   ack_time = 0;
-
-   data_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
-  frame_length, current_rate);
-
-   if (rsv_type == 0) {
-   rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 20, priv->top_cck_basic_rate);
-   ack_time = vnt_get_frame_time(priv->preamble_type,
- pkt_type, 14,
- priv->top_cck_basic_rate);
-   cts_time = ack_time;
-
-   } else if (rsv_type == 1) {
-   rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 20, priv->top_cck_basic_rate);
-   cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_cck_basic_rate);
-   ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_ofdm_basic_rate);
-   } else if (rsv_type == 2) {
-   rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 20, priv->top_ofdm_basic_rate);
-   ack_time = vnt_get_frame_time(priv->preamble_type,
- pkt_type, 14,
- priv->top_ofdm_basic_rate);
-   cts_time = ack_time;
-
-   } else if (rsv_type == 3) {
-   cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_cck_basic_rate);
-   ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_ofdm_basic_rate);
-
-   rrv_time = cts_time + ack_time + data_time + 2 * priv->sifs;
-
-   return cpu_to_le16((u16)rrv_time);
-   }
-
-   rrv_time = rts_time + cts_time + ack_time + data_time + 3 * priv->sifs;
-
-   return cpu_to_le16((u16)rrv_time);
-}
-
 static __le16 vnt_get_rts_duration(struct vnt_usb_send_context *context)
 {
struct vnt_private *priv = context->priv;
@@ -405,18 +320,12 @@ static 

[PATCH 4/6] staging: vt6656: Split RTS and CTS Duration functions

2020-05-05 Thread Malcolm Priestley
split vnt_get_rtscts_duration_le into vnt_get_rts_duration and
vnt_get_cts_duration.

The duration's are all the same in vnt_rxtx_rts_g_head.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 56 ++-
 1 file changed, 16 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 27069ac60b15..47da9dabb133 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -13,7 +13,6 @@
  *
  * Functions:
  *  vnt_generate_tx_parameter - Generate tx dma required parameter.
- *  vnt_get_rtscts_duration_le- get rtx/cts required duration
  *  vnt_get_rtscts_rsvtime_le- get rts/cts reserved time
  *  vnt_get_rsvtime- get frame reserved time
  *  vnt_fill_cts_head- fulfill CTS ctl header
@@ -38,10 +37,6 @@ static const u16 vnt_time_stampoff[2][MAX_RATE] = {
{384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23},
 };
 
-#define RTSDUR_BB   0
-#define RTSDUR_BA   1
-#define RTSDUR_AA   2
-#define CTSDUR_BA   3
 #define DATADUR_B   10
 #define DATADUR_A   11
 
@@ -260,27 +255,22 @@ static __le16 vnt_get_rtscts_rsvtime_le(struct 
vnt_private *priv, u8 rsv_type,
return cpu_to_le16((u16)rrv_time);
 }
 
-static __le16 vnt_get_rtscts_duration_le(struct vnt_usb_send_context *context,
-u8 dur_type, u8 pkt_type, u16 rate)
+static __le16 vnt_get_rts_duration(struct vnt_usb_send_context *context)
 {
struct vnt_private *priv = context->priv;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
 
-   switch (dur_type) {
-   /* fall through */
-   case RTSDUR_BB:
-   case RTSDUR_BA:
-   case RTSDUR_AA:
-   return ieee80211_rts_duration(priv->hw, priv->vif,
- context->frame_len, info);
-   case CTSDUR_BA:
-   return ieee80211_ctstoself_duration(priv->hw, priv->vif,
-   context->frame_len, info);
-   default:
-   break;
-   }
+   return ieee80211_rts_duration(priv->hw, priv->vif,
+ context->frame_len, info);
+}
 
-   return cpu_to_le16(0);
+static __le16 vnt_get_cts_duration(struct vnt_usb_send_context *context)
+{
+   struct vnt_private *priv = context->priv;
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
+
+   return ieee80211_ctstoself_duration(priv->hw, priv->vif,
+   context->frame_len, info);
 }
 
 static u16 vnt_mac_hdr_pos(struct vnt_usb_send_context *tx_context,
@@ -359,22 +349,15 @@ static void vnt_rxtx_rts_g_head(struct 
vnt_usb_send_context *tx_context,
 {
struct vnt_private *priv = tx_context->priv;
u16 rts_frame_len = 20;
-   u16 current_rate = tx_context->tx_rate;
 
vnt_get_phy_field(priv, rts_frame_len, priv->top_cck_basic_rate,
  PK_TYPE_11B, >b);
vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
  tx_context->pkt_type, >a);
 
-   buf->duration_bb = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BB,
- PK_TYPE_11B,
- priv->top_cck_basic_rate);
-   buf->duration_aa = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
- tx_context->pkt_type,
- current_rate);
-   buf->duration_ba = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA,
- tx_context->pkt_type,
- current_rate);
+   buf->duration_bb = vnt_get_rts_duration(tx_context);
+   buf->duration_aa = buf->duration_bb;
+   buf->duration_ba = buf->duration_bb;
 
vnt_fill_ieee80211_rts(tx_context, >data, buf->duration_aa);
 
@@ -385,15 +368,12 @@ static void vnt_rxtx_rts_ab_head(struct 
vnt_usb_send_context *tx_context,
 struct vnt_rts_ab *buf)
 {
struct vnt_private *priv = tx_context->priv;
-   u16 current_rate = tx_context->tx_rate;
u16 rts_frame_len = 20;
 
vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
  tx_context->pkt_type, >ab);
 
-   buf->duration = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
-  tx_context->pkt_type,
-  current_rate);
+   buf->duration = vnt_get_rts_duration(tx_context);
 
vnt_fill_ieee80211_rts(tx_context, >data, buf->duration);
 
@@ -406

[PATCH 3/6] staging: vt6656: vnt_get_rtscts_duration_le use ieee80211_ctstoself_duration

2020-05-05 Thread Malcolm Priestley
use the mac80211 ieee80211_ctstoself_duration for CTS to self frames.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 32 +++-
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 48fe16c27d3f..27069ac60b15 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -195,27 +195,6 @@ static __le16 vnt_time_stamp_off(struct vnt_private *priv, 
u16 rate)
[rate % MAX_RATE]);
 }
 
-static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 pkt_type,
-  u32 frame_length, u16 rate, int need_ack)
-{
-   u32 data_time, ack_time;
-
-   data_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
-  frame_length, rate);
-
-   if (pkt_type == PK_TYPE_11B)
-   ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14,
- (u16)priv->top_cck_basic_rate);
-   else
-   ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14,
- (u16)priv->top_ofdm_basic_rate);
-
-   if (need_ack)
-   return data_time + priv->sifs + ack_time;
-
-   return data_time;
-}
-
 static __le16 vnt_rxtx_rsvtime_le16(struct vnt_usb_send_context *context)
 {
struct vnt_private *priv = context->priv;
@@ -285,9 +264,6 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
 u8 dur_type, u8 pkt_type, u16 rate)
 {
struct vnt_private *priv = context->priv;
-   u32 dur_time = 0;
-   u32 frame_length = context->frame_len;
-   u8 need_ack = context->need_ack;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
 
switch (dur_type) {
@@ -298,15 +274,13 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
return ieee80211_rts_duration(priv->hw, priv->vif,
  context->frame_len, info);
case CTSDUR_BA:
-   dur_time = priv->sifs + vnt_get_rsvtime(priv,
-   pkt_type, frame_length, rate, need_ack);
-   break;
-
+   return ieee80211_ctstoself_duration(priv->hw, priv->vif,
+   context->frame_len, info);
default:
break;
}
 
-   return cpu_to_le16((u16)dur_time);
+   return cpu_to_le16(0);
 }
 
 static u16 vnt_mac_hdr_pos(struct vnt_usb_send_context *tx_context,
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/6] staging: vt6656: vnt_get_rtscts_duration_le use ieee80211_rts_duration

2020-05-05 Thread Malcolm Priestley
use the mac80211 ieee80211_rts_duration for RTS frames.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 20 +---
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 6724b213a723..48fe16c27d3f 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -285,28 +285,18 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
 u8 dur_type, u8 pkt_type, u16 rate)
 {
struct vnt_private *priv = context->priv;
-   u32 cts_time = 0, dur_time = 0;
+   u32 dur_time = 0;
u32 frame_length = context->frame_len;
u8 need_ack = context->need_ack;
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
 
switch (dur_type) {
+   /* fall through */
case RTSDUR_BB:
case RTSDUR_BA:
-   cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_cck_basic_rate);
-   dur_time = cts_time + 2 * priv->sifs +
-   vnt_get_rsvtime(priv, pkt_type,
-   frame_length, rate, need_ack);
-   break;
-
case RTSDUR_AA:
-   cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_ofdm_basic_rate);
-   dur_time = cts_time + 2 * priv->sifs +
-   vnt_get_rsvtime(priv, pkt_type,
-   frame_length, rate, need_ack);
-   break;
-
+   return ieee80211_rts_duration(priv->hw, priv->vif,
+ context->frame_len, info);
case CTSDUR_BA:
dur_time = priv->sifs + vnt_get_rsvtime(priv,
pkt_type, frame_length, rate, need_ack);
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/6] staging: vt6656: vnt_rxtx_rsvtime_le16 to use ieee80211_generic_frame_duration.

2020-05-05 Thread Malcolm Priestley
ieee80211_generic_frame_duration is the mac80211 equivalent to
vnt_get_rsvtime use this to get our frame time.

There is a change where there is rrv_time_a and rrv_time_b
the frame duration is always the same so both are equal.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 32 ++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 68be0fa7b201..6724b213a723 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -216,11 +216,16 @@ static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 
pkt_type,
return data_time;
 }
 
-static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type,
-   u32 frame_length, u16 rate, int need_ack)
+static __le16 vnt_rxtx_rsvtime_le16(struct vnt_usb_send_context *context)
 {
-   return cpu_to_le16((u16)vnt_get_rsvtime(priv, pkt_type,
-   frame_length, rate, need_ack));
+   struct vnt_private *priv = context->priv;
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
+   struct ieee80211_rate *rate = ieee80211_get_tx_rate(priv->hw, info);
+
+   return ieee80211_generic_frame_duration(priv->hw,
+info->control.vif, info->band,
+context->frame_len,
+rate);
 }
 
 static __le16 vnt_get_rtscts_rsvtime_le(struct vnt_private *priv, u8 rsv_type,
@@ -465,7 +470,6 @@ static void vnt_rxtx_rts(struct vnt_usb_send_context 
*tx_context,
union vnt_tx_data_head *head = _head->tx_rts.tx.head;
u32 frame_len = tx_context->frame_len;
u16 current_rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
 
buf->rts_rrv_time_aa = vnt_get_rtscts_rsvtime_le(priv, 2,
tx_context->pkt_type, frame_len, current_rate);
@@ -474,11 +478,8 @@ static void vnt_rxtx_rts(struct vnt_usb_send_context 
*tx_context,
buf->rts_rrv_time_bb = vnt_get_rtscts_rsvtime_le(priv, 0,
tx_context->pkt_type, frame_len, current_rate);
 
-   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
-   frame_len, current_rate,
-   need_ack);
-   buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B, frame_len,
-   priv->top_cck_basic_rate, need_ack);
+   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(tx_context);
+   buf->rrv_time_b = buf->rrv_time_a;
 
if (need_mic)
head = _head->tx_rts.tx.mic.head;
@@ -494,12 +495,9 @@ static void vnt_rxtx_cts(struct vnt_usb_send_context 
*tx_context,
union vnt_tx_data_head *head = _head->tx_cts.tx.head;
u32 frame_len = tx_context->frame_len;
u16 current_rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
 
-   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
-   frame_len, current_rate, need_ack);
-   buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B,
-   frame_len, priv->top_cck_basic_rate, need_ack);
+   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(tx_context);
+   buf->rrv_time_b = buf->rrv_time_a;
 
buf->cts_rrv_time_ba = vnt_get_rtscts_rsvtime_le(priv, 3,
tx_context->pkt_type, frame_len, current_rate);
@@ -519,10 +517,8 @@ static void vnt_rxtx_ab(struct vnt_usb_send_context 
*tx_context,
union vnt_tx_data_head *head = _head->tx_ab.tx.head;
u32 frame_len = tx_context->frame_len;
u16 current_rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
 
-   buf->rrv_time = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
- frame_len, current_rate, 
need_ack);
+   buf->rrv_time = vnt_rxtx_rsvtime_le16(tx_context);
 
if (need_mic)
head = _head->tx_ab.tx.mic.head;
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH ] staging: vt6656: refactor power save operation

2020-05-02 Thread Malcolm Priestley
Drop this patch v2 sent corrected TTBT.

Regards


Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: vt6656: refactor power save operation

2020-05-02 Thread Malcolm Priestley
At present the power save wake uses the listening interval and
the slow path to wake up.

The following using a beacon interval of 100 and
listen interval of 5.

The TBTT set at 100 wake-up sequence;
100 TBTT wake-up set to listen interval.
200 TBTT
300 TBTT
400 TBTT --> call vnt_next_tbtt_wakeup on slow path
Beacon heard and passed through at the approx 500 interval.
500 TBTT
600 TBTT wake-up set to listen interval

The TBTT set at 500 wake-up sequence and always listen flagged on;
100 No TBTT
200 No TBTT
300 No TBTT
400 No TBTT
500 TBTT - beacon heard and passed through
600 No TBTT

A further enhancement because the TBTT is more precise
the dtim_period can be used instead.

When Power save is off the TBTT continues to run at the listen
interval but all the other beacons are passed.

The code in vnt_int_process_data is no longer required. 

Signed-off-by: Malcolm Priestley 
---
v2 Corrected TTBT to TBTT
 
 drivers/staging/vt6656/device.h   |  2 --
 drivers/staging/vt6656/main_usb.c | 11 +--
 drivers/staging/vt6656/power.c| 12 ++--
 drivers/staging/vt6656/usbpipe.c  | 13 -
 4 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 4d596853a3ee..d19d802b5d4f 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -383,8 +383,6 @@ struct vnt_private {
u8 bb_pre_ed_rssi;
u8 bb_pre_ed_index;
 
-   u16 wake_up_count;
-
/* command timer */
struct delayed_work run_command_work;
 
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 7db1e044ad26..b5790d4d7152 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -824,10 +824,17 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_BEACON_INFO) &&
priv->op_mode != NL80211_IFTYPE_AP) {
if (conf->assoc && conf->beacon_rate) {
+   u16 ps_beacon_int = conf->beacon_int;
+
+   if (conf->dtim_period)
+   ps_beacon_int *= conf->dtim_period;
+   else if (hw->conf.listen_interval)
+   ps_beacon_int *= hw->conf.listen_interval;
+
vnt_mac_reg_bits_on(priv, MAC_REG_TFTCTL,
TFTCTL_TSFCNTREN);
 
-   vnt_mac_set_beacon_interval(priv, conf->beacon_int);
+   vnt_mac_set_beacon_interval(priv, ps_beacon_int);
 
vnt_reset_next_tbtt(priv, conf->beacon_int);
 
@@ -835,7 +842,7 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
   conf->sync_tsf, priv->current_tsf);
 
vnt_update_next_tbtt(priv,
-conf->sync_tsf, conf->beacon_int);
+conf->sync_tsf, ps_beacon_int);
} else {
vnt_clear_current_tsf(priv);
 
diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c
index d160a0773943..2f49c870272a 100644
--- a/drivers/staging/vt6656/power.c
+++ b/drivers/staging/vt6656/power.c
@@ -63,16 +63,8 @@ void vnt_enable_power_saving(struct vnt_private *priv, u16 
listen_interval)
 */
vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_GO2DOZE);
 
-   if (listen_interval >= 2) {
-   /* clear always listen beacon */
-   vnt_mac_reg_bits_off(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
-
-   /* first time set listen next beacon */
-   vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_LNBCN);
-   } else {
-   /* always listen beacon */
-   vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
-   }
+   /* always listen beacon */
+   vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
 
dev_dbg(>usb->dev,  "PS:Power Saving Mode Enable...\n");
 }
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index e8efdeadb1a7..5603f3cbb33c 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -202,19 +202,6 @@ static void vnt_int_process_data(struct vnt_private *priv)
if (int_data->isr0 & ISR_BNTX && priv->op_mode == NL80211_IFTYPE_AP)
vnt_schedule_command(priv, WLAN_CMD_BECON_SEND);
 
-   if (int_data->isr0 & ISR_TBTT &&
-   priv->hw->conf.flags & IEEE80211_CONF_PS) {
-   if (!priv->wake_up_count)
-   priv->wake_up_count = priv->hw->conf.listen_interval;
-
-   if (priv->wake_up_count)
-   --priv->wake_up_count;
-
- 

[PATCH ] staging: vt6656: refactor power save operation

2020-05-02 Thread Malcolm Priestley
At present the power save wake uses the listening interval and
the slow path to wake up.

The following using a beacon interval of 100 and
listen interval of 5.

The TBTT set at 100 wake-up sequence;
100 TTBT wake-up set to listen interval.
200 TTBT
300 TTBT
400 TTBT --> call vnt_next_tbtt_wakeup on slow path
Beacon heard and passed through at the approx 500 interval.
500 TTBT
600 TTBT wakeup set to listen interval

The TTBT set at 500 wake-up sequence and always listen flagged on;
100 No TTBT
200 No TTBT
300 No TTBT
400 No TTBT
500 TTBT - beacon heard and passed through
600 No TTBT

A further enhancement because the TTBT is more precise
the dtim_period can be used instead.

When Power save is off the TTBT continues to run at the listen
interval but all the other beacons are passed.

The code in vnt_int_process_data is no longer required. 

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h   |  2 --
 drivers/staging/vt6656/main_usb.c | 11 +--
 drivers/staging/vt6656/power.c| 12 ++--
 drivers/staging/vt6656/usbpipe.c  | 13 -
 4 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 4d596853a3ee..d19d802b5d4f 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -383,8 +383,6 @@ struct vnt_private {
u8 bb_pre_ed_rssi;
u8 bb_pre_ed_index;
 
-   u16 wake_up_count;
-
/* command timer */
struct delayed_work run_command_work;
 
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 7db1e044ad26..b5790d4d7152 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -824,10 +824,17 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_BEACON_INFO) &&
priv->op_mode != NL80211_IFTYPE_AP) {
if (conf->assoc && conf->beacon_rate) {
+   u16 ps_beacon_int = conf->beacon_int;
+
+   if (conf->dtim_period)
+   ps_beacon_int *= conf->dtim_period;
+   else if (hw->conf.listen_interval)
+   ps_beacon_int *= hw->conf.listen_interval;
+
vnt_mac_reg_bits_on(priv, MAC_REG_TFTCTL,
TFTCTL_TSFCNTREN);
 
-   vnt_mac_set_beacon_interval(priv, conf->beacon_int);
+   vnt_mac_set_beacon_interval(priv, ps_beacon_int);
 
vnt_reset_next_tbtt(priv, conf->beacon_int);
 
@@ -835,7 +842,7 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
   conf->sync_tsf, priv->current_tsf);
 
vnt_update_next_tbtt(priv,
-conf->sync_tsf, conf->beacon_int);
+conf->sync_tsf, ps_beacon_int);
} else {
vnt_clear_current_tsf(priv);
 
diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c
index d160a0773943..2f49c870272a 100644
--- a/drivers/staging/vt6656/power.c
+++ b/drivers/staging/vt6656/power.c
@@ -63,16 +63,8 @@ void vnt_enable_power_saving(struct vnt_private *priv, u16 
listen_interval)
 */
vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_GO2DOZE);
 
-   if (listen_interval >= 2) {
-   /* clear always listen beacon */
-   vnt_mac_reg_bits_off(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
-
-   /* first time set listen next beacon */
-   vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_LNBCN);
-   } else {
-   /* always listen beacon */
-   vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
-   }
+   /* always listen beacon */
+   vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
 
dev_dbg(>usb->dev,  "PS:Power Saving Mode Enable...\n");
 }
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index e8efdeadb1a7..5603f3cbb33c 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -202,19 +202,6 @@ static void vnt_int_process_data(struct vnt_private *priv)
if (int_data->isr0 & ISR_BNTX && priv->op_mode == NL80211_IFTYPE_AP)
vnt_schedule_command(priv, WLAN_CMD_BECON_SEND);
 
-   if (int_data->isr0 & ISR_TBTT &&
-   priv->hw->conf.flags & IEEE80211_CONF_PS) {
-   if (!priv->wake_up_count)
-   priv->wake_up_count = priv->hw->conf.listen_interval;
-
-   if (priv->wake_up_count)
-   --priv->wake_up_count;
-
-   /* Turn on wa

[PATCH] staging: vt6656: Return on isr0 when zero.

2020-05-01 Thread Malcolm Priestley
When isr0 is zero there is nothing more todo so return and
pull following code in.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/usbpipe.c | 47 
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 91b62c3dff7b..e8efdeadb1a7 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -196,32 +196,31 @@ static void vnt_int_process_data(struct vnt_private *priv)
if (int_data->tsr3 & TSR_VALID)
vnt_int_report_rate(priv, int_data->pkt3, int_data->tsr3);
 
-   if (int_data->isr0 != 0) {
-   if (int_data->isr0 & ISR_BNTX &&
-   priv->op_mode == NL80211_IFTYPE_AP)
-   vnt_schedule_command(priv, WLAN_CMD_BECON_SEND);
-
-   if (int_data->isr0 & ISR_TBTT &&
-   priv->hw->conf.flags & IEEE80211_CONF_PS) {
-   if (!priv->wake_up_count)
-   priv->wake_up_count =
-   priv->hw->conf.listen_interval;
-
-   if (priv->wake_up_count)
-   --priv->wake_up_count;
-
-   /* Turn on wake up to listen next beacon */
-   if (priv->wake_up_count == 1)
-   vnt_schedule_command(priv,
-WLAN_CMD_TBTT_WAKEUP);
-   }
-   priv->current_tsf = le64_to_cpu(int_data->tsf);
+   if (!int_data->isr0)
+   return;
+
+   if (int_data->isr0 & ISR_BNTX && priv->op_mode == NL80211_IFTYPE_AP)
+   vnt_schedule_command(priv, WLAN_CMD_BECON_SEND);
+
+   if (int_data->isr0 & ISR_TBTT &&
+   priv->hw->conf.flags & IEEE80211_CONF_PS) {
+   if (!priv->wake_up_count)
+   priv->wake_up_count = priv->hw->conf.listen_interval;
 
-   low_stats->dot11RTSSuccessCount += int_data->rts_success;
-   low_stats->dot11RTSFailureCount += int_data->rts_fail;
-   low_stats->dot11ACKFailureCount += int_data->ack_fail;
-   low_stats->dot11FCSErrorCount += int_data->fcs_err;
+   if (priv->wake_up_count)
+   --priv->wake_up_count;
+
+   /* Turn on wake up to listen next beacon */
+   if (priv->wake_up_count == 1)
+   vnt_schedule_command(priv, WLAN_CMD_TBTT_WAKEUP);
}
+
+   priv->current_tsf = le64_to_cpu(int_data->tsf);
+
+   low_stats->dot11RTSSuccessCount += int_data->rts_success;
+   low_stats->dot11RTSFailureCount += int_data->rts_fail;
+   low_stats->dot11ACKFailureCount += int_data->ack_fail;
+   low_stats->dot11FCSErrorCount += int_data->fcs_err;
 }
 
 static void vnt_start_interrupt_urb_complete(struct urb *urb)
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


PATCH] staging: vt6656: use struct wiphy retry short and long settings.

2020-04-29 Thread Malcolm Priestley
Remove driver options for short and long retry and use the ones
set by user in wiphy.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h   | 3 ---
 drivers/staging/vt6656/main_usb.c | 8 ++--
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index d1c6e9594a19..d19d802b5d4f 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -351,9 +351,6 @@ struct vnt_private {
u16 tx_rate_fb0;
u16 tx_rate_fb1;
 
-   u8 short_retry_limit;
-   u8 long_retry_limit;
-
enum nl80211_iftype op_mode;
 
int short_slot_time;
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index b1a7a6709ca7..03873a877d9a 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -59,8 +59,6 @@ MODULE_PARM_DESC(tx_buffers, "Number of receive usb tx 
buffers");
 
 #define RTS_THRESH_DEF 2347
 #define FRAG_THRESH_DEF 2346
-#define SHORT_RETRY_DEF 8
-#define LONG_RETRY_DEF 4
 
 /* BasebandType[] baseband type selected
  * 0: indicate 802.11a type
@@ -93,8 +91,6 @@ static void vnt_set_options(struct vnt_private *priv)
else
priv->num_rcb = vnt_rx_buffers;
 
-   priv->short_retry_limit = SHORT_RETRY_DEF;
-   priv->long_retry_limit = LONG_RETRY_DEF;
priv->op_mode = NL80211_IFTYPE_UNSPECIFIED;
priv->bb_type = BBP_TYPE_DEF;
priv->packet_type = priv->bb_type;
@@ -223,8 +219,8 @@ static int vnt_init_registers(struct vnt_private *priv)
init_cmd->exist_sw_net_addr = priv->exist_sw_net_addr;
for (ii = 0; ii < ARRAY_SIZE(init_cmd->sw_net_addr); ii++)
init_cmd->sw_net_addr[ii] = priv->current_net_addr[ii];
-   init_cmd->short_retry_limit = priv->short_retry_limit;
-   init_cmd->long_retry_limit = priv->long_retry_limit;
+   init_cmd->short_retry_limit = priv->hw->wiphy->retry_short;
+   init_cmd->long_retry_limit = priv->hw->wiphy->retry_long;
 
/* issue card_init command to device */
ret = vnt_control_out(priv, MESSAGE_TYPE_CARDINIT, 0, 0,
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: vt6656: return all key calls to mac80211 stack.

2020-04-29 Thread Malcolm Priestley
vnt_mac_set_keyentry can return USB calls so return them to
mac80211.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/key.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index de54cc3ff95a..c66cb53cfc09 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -91,9 +91,8 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 
*mac_addr,
key->key[15] |= 0x80;
}
 
-   vnt_mac_set_keyentry(priv, key_mode, entry, key_inx, bssid, key->key);
-
-   return 0;
+   return vnt_mac_set_keyentry(priv, key_mode, entry,
+   key_inx, bssid, key->key);
 }
 
 int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
@@ -102,7 +101,6 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
struct vnt_private *priv = hw->priv;
u8 *mac_addr = NULL;
u8 key_dec_mode = 0;
-   int ret = 0;
 
if (sta)
mac_addr = >addr[0];
@@ -115,7 +113,9 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
 
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
 
-   return ret;
+   return vnt_set_keymode(hw, mac_addr, key, VNT_KEY_DEFAULTKEY,
+  KEY_CTL_WEP);
+
case WLAN_CIPHER_SUITE_TKIP:
key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
@@ -136,11 +136,9 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
}
 
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
-   vnt_set_keymode(hw, mac_addr, key, VNT_KEY_PAIRWISE,
-   key_dec_mode);
-   else
-   vnt_set_keymode(hw, mac_addr, key,
-   VNT_KEY_GROUP_ADDRESS, key_dec_mode);
+   return vnt_set_keymode(hw, mac_addr, key, VNT_KEY_PAIRWISE,
+  key_dec_mode);
 
-   return 0;
+   return vnt_set_keymode(hw, mac_addr, key,
+   VNT_KEY_GROUP_ADDRESS, key_dec_mode);
 }
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: vt6656 remove vnt_mac_disable_keyentry calls

2020-04-29 Thread Malcolm Priestley
It is not necessary to disable all the keys mac80211 will
have removed any existing keys that were used.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/key.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index 47338077c033..de54cc3ff95a 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -102,22 +102,14 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
struct vnt_private *priv = hw->priv;
u8 *mac_addr = NULL;
u8 key_dec_mode = 0;
-   int ret = 0, u;
+   int ret = 0;
 
if (sta)
mac_addr = >addr[0];
 
switch (key->cipher) {
-   case 0:
-   for (u = 0 ; u < MAX_KEY_TABLE; u++)
-   vnt_mac_disable_keyentry(priv, u);
-   return ret;
-
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
-   for (u = 0; u < MAX_KEY_TABLE; u++)
-   vnt_mac_disable_keyentry(priv, u);
-
vnt_set_keymode(hw, mac_addr, key, VNT_KEY_DEFAULTKEY,
KEY_CTL_WEP);
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: vt6656: vnt_set_keymode simplify key modes.

2020-04-29 Thread Malcolm Priestley
Unused macros and onfly_latch are removed and others contain
to actual key_type value is or-ed with key_mode.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/key.c | 25 +
 drivers/staging/vt6656/key.h | 13 +++--
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index ac3b188984d0..47338077c033 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -35,7 +35,7 @@ int vnt_key_init_table(struct vnt_private *priv)
 
 static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr,
   struct ieee80211_key_conf *key, u32 key_type,
-  u32 mode, bool onfly_latch)
+  u32 mode)
 {
struct vnt_private *priv = hw->priv;
u8 broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
@@ -68,17 +68,11 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 
*mac_addr,
entry = MAX_KEY_TABLE - 1;
key->hw_key_idx = entry;
/* fall through */
-   case VNT_KEY_ALLGROUP:
-   key_mode |= VNT_KEY_ALLGROUP;
-   if (onfly_latch)
-   key_mode |= VNT_KEY_ONFLY_ALL;
-   /* fall through */
case VNT_KEY_GROUP_ADDRESS:
-   key_mode |= mode;
-   /* fall through */
+   key_mode = mode | (mode << 4);
+   break;
case VNT_KEY_GROUP:
-   key_mode |= (mode << 4);
-   key_mode |= VNT_KEY_GROUP;
+   key_mode = mode << 4;
break;
case  VNT_KEY_PAIRWISE:
key_mode |= mode;
@@ -88,8 +82,7 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 
*mac_addr,
return -EINVAL;
}
 
-   if (onfly_latch)
-   key_mode |= VNT_KEY_ONFLY;
+   key_mode |= key_type;
 
if (mode == KEY_CTL_WEP) {
if (key->keylen == WLAN_KEY_LEN_WEP40)
@@ -126,7 +119,7 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
vnt_mac_disable_keyentry(priv, u);
 
vnt_set_keymode(hw, mac_addr, key, VNT_KEY_DEFAULTKEY,
-   KEY_CTL_WEP, true);
+   KEY_CTL_WEP);
 
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
 
@@ -152,10 +145,10 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
 
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
vnt_set_keymode(hw, mac_addr, key, VNT_KEY_PAIRWISE,
-   key_dec_mode, true);
+   key_dec_mode);
else
-   vnt_set_keymode(hw, mac_addr, key, VNT_KEY_GROUP_ADDRESS,
-   key_dec_mode, true);
+   vnt_set_keymode(hw, mac_addr, key,
+   VNT_KEY_GROUP_ADDRESS, key_dec_mode);
 
return 0;
 }
diff --git a/drivers/staging/vt6656/key.h b/drivers/staging/vt6656/key.h
index 918c07cf86cd..1f3449e66143 100644
--- a/drivers/staging/vt6656/key.h
+++ b/drivers/staging/vt6656/key.h
@@ -25,13 +25,14 @@
 #define KEY_CTL_TKIP0x02
 #define KEY_CTL_CCMP0x03
 
-#define VNT_KEY_DEFAULTKEY 0x1
-#define VNT_KEY_GROUP_ADDRESS  0x2
-#define VNT_KEY_ALLGROUP   0x4
-#define VNT_KEY_GROUP  0x40
-#define VNT_KEY_PAIRWISE   0x00
-#define VNT_KEY_ONFLY  0x8000
 #define VNT_KEY_ONFLY_ALL  0x4000
+#define VNT_KEY_ONFLY  0x8000
+#define VNT_KEY_ALLGROUP   0x04
+#define VNT_KEY_GROUP  0x40
+#define VNT_KEY_PAIRWISE   VNT_KEY_ONFLY
+#define VNT_KEY_GROUP_ADDRESS  (VNT_KEY_ALLGROUP | VNT_KEY_GROUP)
+#define VNT_KEY_DEFAULTKEY (VNT_KEY_GROUP_ADDRESS | VNT_KEY_ONFLY |\
+   VNT_KEY_ONFLY_ALL)
 
 int vnt_key_init_table(struct vnt_private *priv);
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: vt6656: rxtx: remove duration_id and void returns.

2020-04-25 Thread Malcolm Priestley
duration_id is not used by driver anymore so remove the returns
and set all functions in patch to void.

Signed-off-by: Malcolm Priestley 
---
v1 had missing returns in vnt_generate_tx_parameter and vnt_rxtx_ab

 drivers/staging/vt6656/rxtx.c | 84 +--
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 335ef4fd104f..a4235652cbff 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -327,8 +327,8 @@ static u16 vnt_mac_hdr_pos(struct vnt_usb_send_context 
*tx_context,
return (u16)(hdr_pos - head);
 }
 
-static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
-  struct vnt_tx_datahead_g *buf)
+static void vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
+   struct vnt_tx_datahead_g *buf)
 {
struct vnt_private *priv = tx_context->priv;
struct ieee80211_hdr *hdr =
@@ -349,12 +349,10 @@ static u16 vnt_rxtx_datahead_g(struct 
vnt_usb_send_context *tx_context,
   priv->top_cck_basic_rate);
 
tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, >hdr);
-
-   return le16_to_cpu(buf->duration_a);
 }
 
-static u16 vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,
-   struct vnt_tx_datahead_ab *buf)
+static void vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,
+struct vnt_tx_datahead_ab *buf)
 {
struct vnt_private *priv = tx_context->priv;
struct ieee80211_hdr *hdr =
@@ -371,12 +369,10 @@ 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, >hdr);
-
-   return le16_to_cpu(buf->duration);
 }
 
-static int vnt_fill_ieee80211_rts(struct vnt_usb_send_context *tx_context,
- struct ieee80211_rts *rts, __le16 duration)
+static void vnt_fill_ieee80211_rts(struct vnt_usb_send_context *tx_context,
+  struct ieee80211_rts *rts, __le16 duration)
 {
struct ieee80211_hdr *hdr =
(struct ieee80211_hdr *)tx_context->skb->data;
@@ -387,12 +383,10 @@ static int vnt_fill_ieee80211_rts(struct 
vnt_usb_send_context *tx_context,
 
ether_addr_copy(rts->ra, hdr->addr1);
ether_addr_copy(rts->ta, hdr->addr2);
-
-   return 0;
 }
 
-static u16 vnt_rxtx_rts_g_head(struct vnt_usb_send_context *tx_context,
-  struct vnt_rts_g *buf)
+static void vnt_rxtx_rts_g_head(struct vnt_usb_send_context *tx_context,
+   struct vnt_rts_g *buf)
 {
struct vnt_private *priv = tx_context->priv;
u16 rts_frame_len = 20;
@@ -415,11 +409,11 @@ static u16 vnt_rxtx_rts_g_head(struct 
vnt_usb_send_context *tx_context,
 
vnt_fill_ieee80211_rts(tx_context, >data, buf->duration_aa);
 
-   return vnt_rxtx_datahead_g(tx_context, >data_head);
+   vnt_rxtx_datahead_g(tx_context, >data_head);
 }
 
-static u16 vnt_rxtx_rts_ab_head(struct vnt_usb_send_context *tx_context,
-   struct vnt_rts_ab *buf)
+static void vnt_rxtx_rts_ab_head(struct vnt_usb_send_context *tx_context,
+struct vnt_rts_ab *buf)
 {
struct vnt_private *priv = tx_context->priv;
u16 current_rate = tx_context->tx_rate;
@@ -434,11 +428,11 @@ static u16 vnt_rxtx_rts_ab_head(struct 
vnt_usb_send_context *tx_context,
 
vnt_fill_ieee80211_rts(tx_context, >data, buf->duration);
 
-   return vnt_rxtx_datahead_ab(tx_context, >data_head);
+   vnt_rxtx_datahead_ab(tx_context, >data_head);
 }
 
-static u16 vnt_fill_cts_head(struct vnt_usb_send_context *tx_context,
-union vnt_tx_data_head *head)
+static void 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 = >cts_g;
@@ -460,11 +454,11 @@ static u16 vnt_fill_cts_head(struct vnt_usb_send_context 
*tx_context,
 
ether_addr_copy(buf->data.ra, priv->current_net_addr);
 
-   return vnt_rxtx_datahead_g(tx_context, >data_head);
+   vnt_rxtx_datahead_g(tx_context, >data_head);
 }
 
-static u16 vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
-   union vnt_tx_head *tx_head, bool need_mic)
+static void vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
+union vnt_tx_head *tx_head, bool need_mic)
 {
struct vnt_private *priv = tx_context->priv;
struct vnt_rrv_time_rts *buf = _he

Re: [PATCH] staging: vt6656: rxtx: remove duration_id and void returns.

2020-04-25 Thread Malcolm Priestley
Drop this patch there is a mistake in it.

Regards

Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: vt6656: Remove preamble_type setting from vnt_tx_packet.

2020-04-23 Thread Malcolm Priestley
preamble_type is set in vnt_bss_info_changed no need to set it
here.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 7e15534e52ff..f56a2b02fe36 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -729,11 +729,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
if (ieee80211_has_retry(hdr->frame_control))
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LRETRY);
 
-   if (tx_rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
-   priv->preamble_type = PREAMBLE_SHORT;
-   else
-   priv->preamble_type = PREAMBLE_LONG;
-
if (tx_rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) {
need_rts = true;
tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_RTS);
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: vt6656: Remove set short time in vnt_init_registers.

2020-04-23 Thread Malcolm Priestley
The short time is set in vnt_bss_info_changed no need to set it
here.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 4bca0b99cf45..c0545932866c 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -401,19 +401,6 @@ static int vnt_init_registers(struct vnt_private *priv)
dev_dbg(>usb->dev, "Network address = %pM\n",
priv->current_net_addr);
 
-   /*
-* set BB and packet type at the same time
-* set Short Slot Time, xIFS, and RSPINF
-*/
-   if (priv->bb_type == BB_TYPE_11A)
-   priv->short_slot_time = true;
-   else
-   priv->short_slot_time = false;
-
-   ret = vnt_set_short_slot_time(priv);
-   if (ret)
-   goto end;
-
priv->radio_ctl = priv->eeprom[EEP_OFS_RADIOCTL];
 
if ((priv->radio_ctl & EEP_RADIOCTL_ENABLE) != 0) {
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: rxtx: remove duration_id and void returns.

2020-04-23 Thread Malcolm Priestley
duration_id is not used by driver anymore so remove the returns
and set all functions in path to void.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 78 ---
 1 file changed, 36 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 335ef4fd104f..7e15534e52ff 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -327,8 +327,8 @@ static u16 vnt_mac_hdr_pos(struct vnt_usb_send_context 
*tx_context,
return (u16)(hdr_pos - head);
 }
 
-static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
-  struct vnt_tx_datahead_g *buf)
+static void vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
+   struct vnt_tx_datahead_g *buf)
 {
struct vnt_private *priv = tx_context->priv;
struct ieee80211_hdr *hdr =
@@ -349,12 +349,10 @@ static u16 vnt_rxtx_datahead_g(struct 
vnt_usb_send_context *tx_context,
   priv->top_cck_basic_rate);
 
tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, >hdr);
-
-   return le16_to_cpu(buf->duration_a);
 }
 
-static u16 vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,
-   struct vnt_tx_datahead_ab *buf)
+static void vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,
+struct vnt_tx_datahead_ab *buf)
 {
struct vnt_private *priv = tx_context->priv;
struct ieee80211_hdr *hdr =
@@ -371,12 +369,10 @@ 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, >hdr);
-
-   return le16_to_cpu(buf->duration);
 }
 
-static int vnt_fill_ieee80211_rts(struct vnt_usb_send_context *tx_context,
- struct ieee80211_rts *rts, __le16 duration)
+static void vnt_fill_ieee80211_rts(struct vnt_usb_send_context *tx_context,
+  struct ieee80211_rts *rts, __le16 duration)
 {
struct ieee80211_hdr *hdr =
(struct ieee80211_hdr *)tx_context->skb->data;
@@ -387,12 +383,10 @@ static int vnt_fill_ieee80211_rts(struct 
vnt_usb_send_context *tx_context,
 
ether_addr_copy(rts->ra, hdr->addr1);
ether_addr_copy(rts->ta, hdr->addr2);
-
-   return 0;
 }
 
-static u16 vnt_rxtx_rts_g_head(struct vnt_usb_send_context *tx_context,
-  struct vnt_rts_g *buf)
+static void vnt_rxtx_rts_g_head(struct vnt_usb_send_context *tx_context,
+   struct vnt_rts_g *buf)
 {
struct vnt_private *priv = tx_context->priv;
u16 rts_frame_len = 20;
@@ -415,11 +409,11 @@ static u16 vnt_rxtx_rts_g_head(struct 
vnt_usb_send_context *tx_context,
 
vnt_fill_ieee80211_rts(tx_context, >data, buf->duration_aa);
 
-   return vnt_rxtx_datahead_g(tx_context, >data_head);
+   vnt_rxtx_datahead_g(tx_context, >data_head);
 }
 
-static u16 vnt_rxtx_rts_ab_head(struct vnt_usb_send_context *tx_context,
-   struct vnt_rts_ab *buf)
+static void vnt_rxtx_rts_ab_head(struct vnt_usb_send_context *tx_context,
+struct vnt_rts_ab *buf)
 {
struct vnt_private *priv = tx_context->priv;
u16 current_rate = tx_context->tx_rate;
@@ -434,11 +428,11 @@ static u16 vnt_rxtx_rts_ab_head(struct 
vnt_usb_send_context *tx_context,
 
vnt_fill_ieee80211_rts(tx_context, >data, buf->duration);
 
-   return vnt_rxtx_datahead_ab(tx_context, >data_head);
+   vnt_rxtx_datahead_ab(tx_context, >data_head);
 }
 
-static u16 vnt_fill_cts_head(struct vnt_usb_send_context *tx_context,
-union vnt_tx_data_head *head)
+static void 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 = >cts_g;
@@ -460,11 +454,11 @@ static u16 vnt_fill_cts_head(struct vnt_usb_send_context 
*tx_context,
 
ether_addr_copy(buf->data.ra, priv->current_net_addr);
 
-   return vnt_rxtx_datahead_g(tx_context, >data_head);
+   vnt_rxtx_datahead_g(tx_context, >data_head);
 }
 
-static u16 vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
-   union vnt_tx_head *tx_head, bool need_mic)
+static void vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
+union vnt_tx_head *tx_head, bool need_mic)
 {
struct vnt_private *priv = tx_context->priv;
struct vnt_rrv_time_rts *buf = _head->tx_rts.rts;
@@ -489,11 +483,11 @@ static u16 vnt_rxtx_rts(struct 

Re: [PATCH] staging: vt6656: Refactor the vnt_ofdm_min_rate function

2020-04-19 Thread Malcolm Priestley

Hi all

On 19/04/2020 18:55, Stefano Brivio wrote:

Hi Oscar,

On Sat, 18 Apr 2020 15:45:53 +0200
Oscar Carter  wrote:


Replace the for loop by a ternary operator whose condition is an AND
bitmask against the priv->basic_rates variable.

The purpose of the for loop was to check if any of bits from RATE_54M to
RATE_6M was set, but it's not necessary to check every individual bit.
The same result can be achieved using only one single mask which
comprises all the commented bits.





-int vnt_ofdm_min_rate(struct vnt_private *priv)
+bool vnt_ofdm_min_rate(struct vnt_private *priv)
  {
-   int ii;
-
-   for (ii = RATE_54M; ii >= RATE_6M; ii--) {
-   if ((priv->basic_rates) & ((u16)BIT(ii)))
-   return true;
-   }
-
-   return false;
+   return priv->basic_rates & GENMASK(RATE_54M, RATE_6M) ? true : false;


priv->basic_rates & GENMASK(RATE_54M, RATE_6M) is already true if
non-zero and false otherwise. Note that I haven't checked if the
rest is correct.


Yes only 1 or more needs to be true and it is false when none present.

I have run-time checked the patch and it does function as before.

Regards

Malcolm.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Move vnt_get_frame_time and vnt_get_phy_field to rxtx

2020-04-19 Thread Malcolm Priestley
These functions are only used by rxtx so move them and their arrays
used with them abbreviating the function description.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/baseband.c | 139 --
 drivers/staging/vt6656/baseband.h |  13 ---
 drivers/staging/vt6656/rxtx.c | 111 
 drivers/staging/vt6656/rxtx.h |   7 ++
 4 files changed, 118 insertions(+), 152 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index d21a9cf0afe5..e7000bba644a 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -112,10 +112,6 @@ static u8 vnt_vt3184_vt3226d0[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  /* 0xff */
 };
 
-static const u16 vnt_frame_time[MAX_RATE] = {
-   10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
-};
-
 struct vnt_threshold {
u8 bb_pre_ed_rssi;
u8 cr_201;
@@ -196,141 +192,6 @@ static const struct vnt_threshold vt3342_vnt_threshold[] 
= {
{41, 0xff, 0x00}
 };
 
-static const u8 vnt_phy_signal[] = {
-   0x00,   /* RATE_1M  */
-   0x01,   /* RATE_2M  */
-   0x02,   /* RATE_5M  */
-   0x03,   /* RATE_11M */
-   0x8b,   /* RATE_6M  */
-   0x8f,   /* RATE_9M  */
-   0x8a,   /* RATE_12M */
-   0x8e,   /* RATE_18M */
-   0x89,   /* RATE_24M */
-   0x8d,   /* RATE_36M */
-   0x88,   /* RATE_48M */
-   0x8c/* RATE_54M */
-};
-
-/*
- * Description: Calculate data frame transmitting time
- *
- * Parameters:
- *  In:
- * preamble_type   - Preamble Type
- * pkt_type- PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA
- * frame_length- Baseband Type
- * tx_rate - Tx Rate
- *  Out:
- *
- * Return Value: FrameTime
- *
- */
-unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
-   unsigned int frame_length, u16 tx_rate)
-{
-   unsigned int frame_time;
-   unsigned int preamble;
-   unsigned int rate;
-
-   if (tx_rate > RATE_54M)
-   return 0;
-
-   rate = (unsigned int)vnt_frame_time[tx_rate];
-
-   if (tx_rate <= RATE_11M) {
-   if (preamble_type == PREAMBLE_SHORT)
-   preamble = 96;
-   else
-   preamble = 192;
-
-   frame_time = DIV_ROUND_UP(frame_length * 80, rate);
-   return preamble + frame_time;
-   }
-
-   frame_time = DIV_ROUND_UP(frame_length * 8 + 22, rate);
-   frame_time = frame_time * 4;
-
-   if (pkt_type != PK_TYPE_11A)
-   frame_time += 6;
-   return 20 + frame_time;
-}
-
-/*
- * Description: Calculate Length, Service, and Signal fields of Phy for Tx
- *
- * Parameters:
- *  In:
- *  priv - Device Structure
- *  frame_length   - Tx Frame Length
- *  tx_rate   - Tx Rate
- *  Out:
- * struct vnt_phy_field *phy
- * - pointer to Phy Length field
- * - pointer to Phy Service field
- * - pointer to Phy Signal field
- *
- * Return Value: none
- *
- */
-void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
-  u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy)
-{
-   u32 bit_count;
-   u32 count = 0;
-   u32 tmp;
-   int ext_bit;
-   int i;
-   u8 mask = 0;
-   u8 preamble_type = priv->preamble_type;
-
-   bit_count = frame_length * 8;
-   ext_bit = false;
-
-   switch (tx_rate) {
-   case RATE_1M:
-   count = bit_count;
-   break;
-   case RATE_2M:
-   count = bit_count / 2;
-   break;
-   case RATE_5M:
-   count = DIV_ROUND_UP(bit_count * 10, 55);
-   break;
-   case RATE_11M:
-   count = bit_count / 11;
-   tmp = count * 11;
-
-   if (tmp != bit_count) {
-   count++;
-
-   if ((bit_count - tmp) <= 3)
-   ext_bit = true;
-   }
-
-   break;
-   }
-
-   if (tx_rate > RATE_11M) {
-   if (pkt_type == PK_TYPE_11A)
-   mask = BIT(4);
-   } else if (tx_rate > RATE_1M) {
-   if (preamble_type == PREAMBLE_SHORT)
-   mask = BIT(3);
-   }
-
-   i = tx_rate > RATE_54M ? RATE_54M : tx_rate;
-   phy->signal = vnt_phy_signal[i] | mask;
-   phy->service = 0x00;
-
-   if (pkt_type == PK_TYPE_11B) {
-   if (ext_bit)
-   phy->service |= 0x80;
-   phy->len = cpu_to_le16((u16)count);
-   } else {
-   phy->len = cpu_to_le16((u16)frame_length);
-   }
-}
-
 /*
  * Description: Set Antenna mode
  *
diff --git a/drivers/staging/vt6656/baseband.h 
b/drivers/staging/vt6656/baseband.h
index dc42aa6ae1d9..ee7325d942fe

[PATCH] staging: vt6656: call vnt_update_pre_ed_threshold from vnt_config.

2020-04-19 Thread Malcolm Priestley
vnt_update_pre_ed_threshold needs to be updated more often so
call from vnt_config where it updated on any of config changes.

It must have maximum sensitivity when the device is off channel
or idle.

Remove all the other calls in scanning and bss.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 28 ++--
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 3268d86fe93b..4bca0b99cf45 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -763,6 +763,12 @@ static int vnt_config(struct ieee80211_hw *hw, u32 changed)
if (changed & IEEE80211_CONF_CHANGE_POWER)
vnt_rf_setpower(priv, conf->chandef.chan);
 
+   if (conf->flags & (IEEE80211_CONF_OFFCHANNEL | IEEE80211_CONF_IDLE))
+   /* Set max sensitivity*/
+   vnt_update_pre_ed_threshold(priv, true);
+   else
+   vnt_update_pre_ed_threshold(priv, false);
+
return 0;
 }
 
@@ -810,7 +816,6 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
 
vnt_set_short_slot_time(priv);
vnt_set_vga_gain_offset(priv, priv->bb_vga[0]);
-   vnt_update_pre_ed_threshold(priv, false);
}
 
if (changed & (BSS_CHANGED_BASIC_RATES | BSS_CHANGED_ERP_PREAMBLE |
@@ -937,25 +942,6 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
return 0;
 }
 
-static void vnt_sw_scan_start(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- const u8 *addr)
-{
-   struct vnt_private *priv = hw->priv;
-
-   /* Set max sensitivity*/
-   vnt_update_pre_ed_threshold(priv, true);
-}
-
-static void vnt_sw_scan_complete(struct ieee80211_hw *hw,
-struct ieee80211_vif *vif)
-{
-   struct vnt_private *priv = hw->priv;
-
-   /* Return sensitivity to channel level*/
-   vnt_update_pre_ed_threshold(priv, false);
-}
-
 static int vnt_get_stats(struct ieee80211_hw *hw,
 struct ieee80211_low_level_stats *stats)
 {
@@ -1001,8 +987,6 @@ static const struct ieee80211_ops vnt_mac_ops = {
.prepare_multicast  = vnt_prepare_multicast,
.configure_filter   = vnt_configure,
.set_key= vnt_set_key,
-   .sw_scan_start  = vnt_sw_scan_start,
-   .sw_scan_complete   = vnt_sw_scan_complete,
.get_stats  = vnt_get_stats,
.get_tsf= vnt_get_tsf,
.set_tsf= vnt_set_tsf,
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Move firmware functions into main_usb.

2020-04-19 Thread Malcolm Priestley
The firmware function are not that complicated so
move them into main_usb as static functions in callers
visibility

Firmware definitions moved to device.h and MODULE_FIRMWARE
move to below module_usb_driver.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/Makefile   |   3 +-
 drivers/staging/vt6656/device.h   |   4 ++
 drivers/staging/vt6656/firmware.c | 106 --
 drivers/staging/vt6656/firmware.h |  25 ---
 drivers/staging/vt6656/main_usb.c |  81 ++-
 5 files changed, 85 insertions(+), 134 deletions(-)
 delete mode 100644 drivers/staging/vt6656/firmware.c
 delete mode 100644 drivers/staging/vt6656/firmware.h

diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile
index 375f54e9f58b..a0f3862dea75 100644
--- a/drivers/staging/vt6656/Makefile
+++ b/drivers/staging/vt6656/Makefile
@@ -13,7 +13,6 @@ vt6656_stage-y += main_usb.o \
key.o \
rf.o \
usbpipe.o \
-   channel.o \
-   firmware.o
+   channel.o
 
 obj-$(CONFIG_VT6656) +=vt6656_stage.o
diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 1630d2163a23..613062ad0122 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -73,6 +73,10 @@
 
 #define DEVICE_VERSION "mac80211"
 
+#define FIRMWARE_VERSION   0x133   /* version 1.51 */
+#define FIRMWARE_NAME  "vntwusb.fw"
+#define FIRMWARE_CHUNK_SIZE0x400
+
 #define CONFIG_PATH"/etc/vntconfiguration.dat"
 
 #define MAX_UINTS  8
diff --git a/drivers/staging/vt6656/firmware.c 
b/drivers/staging/vt6656/firmware.c
deleted file mode 100644
index 70358d427211..
--- a/drivers/staging/vt6656/firmware.c
+++ /dev/null
@@ -1,106 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * File: baseband.c
- *
- * Purpose: Implement functions to access baseband
- *
- * Author: Yiching Chen
- *
- * Date: May 20, 2004
- *
- * Functions:
- *
- * Revision History:
- *
- */
-
-#include 
-#include "firmware.h"
-#include "usbpipe.h"
-
-#define FIRMWARE_VERSION   0x133   /* version 1.51 */
-#define FIRMWARE_NAME  "vntwusb.fw"
-
-#define FIRMWARE_CHUNK_SIZE0x400
-
-int vnt_download_firmware(struct vnt_private *priv)
-{
-   struct device *dev = >usb->dev;
-   const struct firmware *fw;
-   u16 length;
-   int ii;
-   int ret = 0;
-
-   dev_dbg(dev, ">Download firmware\n");
-
-   ret = request_firmware(, FIRMWARE_NAME, dev);
-   if (ret) {
-   dev_err(dev, "firmware file %s request failed (%d)\n",
-   FIRMWARE_NAME, ret);
-   goto end;
-   }
-
-   for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) {
-   length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
-
-   ret = vnt_control_out(priv, 0, 0x1200 + ii, 0x, length,
- fw->data + ii);
-   if (ret)
-   goto free_fw;
-
-   dev_dbg(dev, "Download firmware...%d %zu\n", ii, fw->size);
-   }
-
-free_fw:
-   release_firmware(fw);
-end:
-   return ret;
-}
-MODULE_FIRMWARE(FIRMWARE_NAME);
-
-int vnt_firmware_branch_to_sram(struct vnt_private *priv)
-{
-   dev_dbg(>usb->dev, ">Branch to Sram\n");
-
-   return vnt_control_out(priv, 1, 0x1200, 0x, 0, NULL);
-}
-
-int vnt_check_firmware_version(struct vnt_private *priv)
-{
-   int ret = 0;
-
-   ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0,
-MESSAGE_REQUEST_VERSION, 2,
-(u8 *)>firmware_version);
-   if (ret) {
-   dev_dbg(>usb->dev,
-   "Could not get firmware version: %d.\n", ret);
-   goto end;
-   }
-
-   dev_dbg(>usb->dev, "Firmware Version [%04x]\n",
-   priv->firmware_version);
-
-   if (priv->firmware_version == 0x) {
-   dev_dbg(>usb->dev, "In Loader.\n");
-   ret = -EINVAL;
-   goto end;
-   }
-
-   if (priv->firmware_version < FIRMWARE_VERSION) {
-   /* branch to loader for download new firmware */
-   ret = vnt_firmware_branch_to_sram(priv);
-   if (ret) {
-   dev_dbg(>usb->dev,
-   "Could not branch to SRAM: %d.\n", ret);
-   } else {
-   ret = -EINVAL;
-   }
-   }
-
-end:
-

Re: [PATCH 2/2] staging: vt6656: Fix functions' documentation

2020-04-19 Thread Malcolm Priestley



On 19/04/2020 08:47, Oscar Carter wrote:
> On Sat, Apr 18, 2020 at 07:05:53PM +0100, Malcolm Priestley wrote:
>> Actually I don't really think the function descriptions are needed at all the
>> names of the functions are enough.
>>
> Then, it would be better leave the documentation as it was before or remove 
> it?
> 

I would remove them all except for comments inside functions.

Regards

Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Fix pairwise key entry save.

2020-04-18 Thread Malcolm Priestley
The problem is that the group key was saved as VNT_KEY_DEFAULTKEY
was over written by the VNT_KEY_GROUP_ADDRESS index.

mac80211 could not clear the mac_addr in the default key.

The VNT_KEY_DEFAULTKEY is not necesscary so remove it and set as
VNT_KEY_GROUP_ADDRESS.

mac80211 can clear any key using vnt_mac_disable_keyentry.
 
Fixes: f9ef05ce13e4 ("staging: vt6656: Fix pairwise key for non station modes")
Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/key.c  | 14 +++---
 drivers/staging/vt6656/main_usb.c |  6 +-
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index 41b73f9670e2..ac3b188984d0 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -83,9 +83,6 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 
*mac_addr,
case  VNT_KEY_PAIRWISE:
key_mode |= mode;
key_inx = 4;
-   /* Don't save entry for pairwise key for station mode */
-   if (priv->op_mode == NL80211_IFTYPE_STATION)
-   clear_bit(entry, >key_entry_inuse);
break;
default:
return -EINVAL;
@@ -109,7 +106,6 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 
*mac_addr,
 int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
 struct ieee80211_vif *vif, struct ieee80211_key_conf *key)
 {
-   struct ieee80211_bss_conf *conf = >bss_conf;
struct vnt_private *priv = hw->priv;
u8 *mac_addr = NULL;
u8 key_dec_mode = 0;
@@ -154,16 +150,12 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
return -EOPNOTSUPP;
}
 
-   if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
+   if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
vnt_set_keymode(hw, mac_addr, key, VNT_KEY_PAIRWISE,
key_dec_mode, true);
-   } else {
-   vnt_set_keymode(hw, mac_addr, key, VNT_KEY_DEFAULTKEY,
+   else
+   vnt_set_keymode(hw, mac_addr, key, VNT_KEY_GROUP_ADDRESS,
key_dec_mode, true);
 
-   vnt_set_keymode(hw, (u8 *)conf->bssid, key,
-   VNT_KEY_GROUP_ADDRESS, key_dec_mode, true);
-   }
-
return 0;
 }
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 85d4133315b1..b9e809ccd264 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -847,8 +847,12 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
case SET_KEY:
return vnt_set_keys(hw, sta, vif, key);
case DISABLE_KEY:
-   if (test_bit(key->hw_key_idx, >key_entry_inuse))
+   if (test_bit(key->hw_key_idx, >key_entry_inuse)) {
clear_bit(key->hw_key_idx, >key_entry_inuse);
+
+   vnt_mac_disable_keyentry(priv, key->hw_key_idx);
+   }
+
default:
break;
}
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] staging: vt6656: Fix functions' documentation

2020-04-18 Thread Malcolm Priestley
Actually I don't really think the function descriptions are needed at all the
names of the functions are enough.

card.c needs to be removed the bss callers to baseband.c, the tbtt's to power.c
and the rest to mac.c

Regards

Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH ] staging: vt6656: Fix calling conditions of vnt_set_bss_mode

2020-04-18 Thread Malcolm Priestley
Sorry this was sent twice gmail reported the first one failed.

Regards

Maloclm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH ] staging: vt6656: Fix calling conditions of vnt_set_bss_mode

2020-04-18 Thread Malcolm Priestley
vnt_set_bss_mode needs to be called on all changes to BSS_CHANGED_BASIC_RATES,
BSS_CHANGED_ERP_PREAMBLE and BSS_CHANGED_ERP_SLOT

Remove all other calls and vnt_update_ifs which is called in vnt_set_bss_mode.

Fixes an issue that preamble mode is not being updated correctly.

Fixes: c12603576e06 ("staging: vt6656: Only call vnt_set_bss_mode on basic 
rates change.")
Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index fcd0fe5e6d72..85d4133315b1 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -625,8 +625,6 @@ static int vnt_add_interface(struct ieee80211_hw *hw, 
struct ieee80211_vif *vif)
 
priv->op_mode = vif->type;
 
-   vnt_set_bss_mode(priv);
-
/* LED blink on TX */
vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_INTER);
 
@@ -706,7 +704,6 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
priv->basic_rates = conf->basic_rates;
 
vnt_update_top_rates(priv);
-   vnt_set_bss_mode(priv);
 
dev_dbg(>usb->dev, "basic rates %x\n", conf->basic_rates);
}
@@ -735,11 +732,14 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
priv->short_slot_time = false;
 
vnt_set_short_slot_time(priv);
-   vnt_update_ifs(priv);
vnt_set_vga_gain_offset(priv, priv->bb_vga[0]);
vnt_update_pre_ed_threshold(priv, false);
}
 
+   if (changed & (BSS_CHANGED_BASIC_RATES | BSS_CHANGED_ERP_PREAMBLE |
+  BSS_CHANGED_ERP_SLOT))
+   vnt_set_bss_mode(priv);
+
if (changed & (BSS_CHANGED_TXPOWER | BSS_CHANGED_BANDWIDTH))
vnt_rf_setpower(priv, conf->chandef.chan);
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH ] staging: vt6656: Fix calling conditions of vnt_set_bss_mode

2020-04-18 Thread Malcolm Priestley
vnt_set_bss_mode needs to be called on all changes to BSS_CHANGED_BASIC_RATES,
BSS_CHANGED_ERP_PREAMBLE and BSS_CHANGED_ERP_SLOT

Remove all other calls and vnt_update_ifs which is called in vnt_set_bss_mode.

Fixes an issue that preamble mode is not being updated correctly.

Fixes: c12603576e06 ("staging: vt6656: Only call vnt_set_bss_mode on basic 
rates change.")
Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index fcd0fe5e6d72..85d4133315b1 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -625,8 +625,6 @@ static int vnt_add_interface(struct ieee80211_hw *hw, 
struct ieee80211_vif *vif)
 
priv->op_mode = vif->type;
 
-   vnt_set_bss_mode(priv);
-
/* LED blink on TX */
vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_INTER);
 
@@ -706,7 +704,6 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
priv->basic_rates = conf->basic_rates;
 
vnt_update_top_rates(priv);
-   vnt_set_bss_mode(priv);
 
dev_dbg(>usb->dev, "basic rates %x\n", conf->basic_rates);
}
@@ -735,11 +732,14 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
priv->short_slot_time = false;
 
vnt_set_short_slot_time(priv);
-   vnt_update_ifs(priv);
vnt_set_vga_gain_offset(priv, priv->bb_vga[0]);
vnt_update_pre_ed_threshold(priv, false);
}
 
+   if (changed & (BSS_CHANGED_BASIC_RATES | BSS_CHANGED_ERP_PREAMBLE |
+  BSS_CHANGED_ERP_SLOT))
+   vnt_set_bss_mode(priv);
+
if (changed & (BSS_CHANGED_TXPOWER | BSS_CHANGED_BANDWIDTH))
vnt_rf_setpower(priv, conf->chandef.chan);
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Fix drivers TBTT timing counter.

2020-04-18 Thread Malcolm Priestley
The drivers TBTT counter is not synchronized with mac80211 timestamp.

Reorder the functions and use vnt_update_next_tbtt to do the final
synchronize.

Fixes: c15158797df6 ("staging: vt6656: implement TSF counter")
Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index b2729d5eadfb..4213679345eb 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -762,12 +762,15 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
vnt_mac_reg_bits_on(priv, MAC_REG_TFTCTL,
TFTCTL_TSFCNTREN);
 
-   vnt_adjust_tsf(priv, conf->beacon_rate->hw_value,
-  conf->sync_tsf, priv->current_tsf);
-
vnt_mac_set_beacon_interval(priv, conf->beacon_int);
 
vnt_reset_next_tbtt(priv, conf->beacon_int);
+
+   vnt_adjust_tsf(priv, conf->beacon_rate->hw_value,
+  conf->sync_tsf, priv->current_tsf);
+
+   vnt_update_next_tbtt(priv,
+conf->sync_tsf, conf->beacon_int);
} else {
vnt_clear_current_tsf(priv);
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Don't set RCR_MULTICAST or RCR_BROADCAST by default.

2020-04-18 Thread Malcolm Priestley
mac80211/users control whether multicast is on or off don't enable it by 
default.

Fixes an issue when multicast/broadcast is always on allowing other beacons 
through
in power save.

Fixes: db8f37fa3355 ("staging: vt6656: mac80211 conversion: main_usb add 
functions...")
Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 3c76d3cb5bbe..b2729d5eadfb 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -801,15 +801,11 @@ static void vnt_configure(struct ieee80211_hw *hw,
 {
struct vnt_private *priv = hw->priv;
u8 rx_mode = 0;
-   int rc;
 
*total_flags &= FIF_ALLMULTI | FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC;
 
-   rc = vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_RCR,
-   MESSAGE_REQUEST_MACREG, sizeof(u8), _mode);
-
-   if (!rc)
-   rx_mode = RCR_MULTICAST | RCR_BROADCAST;
+   vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_RCR,
+  MESSAGE_REQUEST_MACREG, sizeof(u8), _mode);
 
dev_dbg(>usb->dev, "rx mode in = %x\n", rx_mode);
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Power save stop wake_up_count wrap around.

2020-04-14 Thread Malcolm Priestley
conf.listen_interval can sometimes be zero causing wake_up_count
to wrap around up to many beacons too late causing
CTRL-EVENT-BEACON-LOSS as in.

wpa_supplicant[795]: message repeated 45 times: [..CTRL-EVENT-BEACON-LOSS ]

Fixes: 43c93d9bf5e2 ("staging: vt6656: implement power saving code.")
Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/usbpipe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index eae211e5860f..91b62c3dff7b 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -207,7 +207,8 @@ static void vnt_int_process_data(struct vnt_private *priv)
priv->wake_up_count =
priv->hw->conf.listen_interval;
 
-   --priv->wake_up_count;
+   if (priv->wake_up_count)
+   --priv->wake_up_count;
 
/* Turn on wake up to listen next beacon */
if (priv->wake_up_count == 1)
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vt6656: formulate rspinf values into tables

2020-04-12 Thread Malcolm Priestley
Drop this patch v2 sent

Regards

Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: vt6656: formulate rspinf values into tables

2020-04-12 Thread Malcolm Priestley
Four tables can be extracted from RSPINF_A_* based on BB_TYPE_11A or
else being GB rates.

Preamble short or long tables from fixed size len of 14 for RSPINF_B rates.

Remove function vnt_calculate_ofdm_rate and replace with the tables
calling RSPINF_A and RSPINF_B separately.

Signed-off-by: Malcolm Priestley 
---
v1 has error in vnt_rspinf_a_table.

 drivers/staging/vt6656/card.c | 196 +++---
 1 file changed, 40 insertions(+), 156 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 82c775bd20d2..dedb343f3ef3 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -74,99 +74,25 @@ void vnt_set_channel(struct vnt_private *priv, u32 
connection_channel)
   (u8)(connection_channel | 0x80));
 }
 
-/*
- * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
- *
- * Parameters:
- * In:
- * rate- Tx Rate
- * bb_type - Tx Packet type
- * Out:
- * tx_rate - pointer to RSPINF TxRate field
- * rsv_time- pointer to RSPINF RsvTime field
- *
- * Return Value: none
- *
- */
-static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type,
-   u8 *tx_rate, u8 *rsv_time)
-{
-   switch (rate) {
-   case RATE_6M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9b;
-   *rsv_time = 24;
-   } else {
-   *tx_rate = 0x8b;
-   *rsv_time = 30;
-   }
-   break;
-   case RATE_9M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9f;
-   *rsv_time = 16;
-   } else {
-   *tx_rate = 0x8f;
-   *rsv_time = 22;
-   }
-   break;
-   case RATE_12M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9a;
-   *rsv_time = 12;
-   } else {
-   *tx_rate = 0x8a;
-   *rsv_time = 18;
-   }
-   break;
-   case RATE_18M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9e;
-   *rsv_time = 8;
-   } else {
-   *tx_rate = 0x8e;
-   *rsv_time = 14;
-   }
-   break;
-   case RATE_36M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9d;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x8d;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_48M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x98;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x88;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_54M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9c;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x8c;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_24M:
-   default:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x99;
-   *rsv_time = 8;
-   } else {
-   *tx_rate = 0x89;
-   *rsv_time = 14;
-   }
-   break;
-   }
-}
+static const u8 vnt_rspinf_b_short_table[] = {
+   0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x09, 0x00,
+   0x15, 0x00, 0x0a, 0x00, 0x0b, 0x00, 0x0b, 0x80
+};
+
+static const u8 vnt_rspinf_b_long_table[] = {
+   0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00,
+   0x15, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x03, 0x80
+};
+
+static const u8 vnt_rspinf_a_table[] = {
+   0x9b, 0x18, 0x9f, 0x10, 0x9a, 0x0a, 0x9e, 0x08, 0x99,
+   0x08, 0x9d, 0x04, 0x98, 0x04, 0x9c, 0x04, 0x9c, 0x04
+};
+
+static const u8 vnt_rspinf_gb_table[] = {
+   0x8b, 0x1e, 0x8f, 0x16, 0x8a, 0x12, 0x8e, 0x0e, 0x89,
+   0x0e, 0x8d, 0x0a, 0x88, 0x0a, 0x8c, 0x0a, 0x8c, 0x0a
+};
 
 /*
  * Description: Set RSPINF
@@ -183,74 +109,32 @@ static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type,
 
 void vnt_set_rspinf(struct vnt_private *priv, u8 bb_type)
 {
-   struct vnt_phy_field phy[4];
-   u8 tx_rate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */
-   u8 rsv_time[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
-   u8 data[34];
-   int i;
-
-   /*RSPINF_b_1*/
-   vnt_get_phy_field(priv, 14, RATE_1M, PK_TYPE_11B, [0]);
-
-   /*RSPINF_b_2*/
-   vnt_get_phy_field(priv, 14, RATE_2M, PK_TYPE_11B, [1]);
-
-   /*RSPINF_b_5*/
-   vnt_get_phy_field(priv, 14, RATE_5M, PK_TYPE_11B, [2

[PATCH] staging: vt6656: formulate rspinf values into tables

2020-04-11 Thread Malcolm Priestley
Four tables can be extracted from RSPINF_A_* based on BB_TYPE_11A or
else being GB rates.

Preamble short or long tables from fixed size len of 14 for RSPINF_B rates.

Remove function vnt_calculate_ofdm_rate and replace with the tables
calling RSPINF_A and RSPINF_B separately.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/card.c | 196 +++---
 1 file changed, 40 insertions(+), 156 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 82c775bd20d2..dedb343f3ef3 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -74,99 +74,25 @@ void vnt_set_channel(struct vnt_private *priv, u32 
connection_channel)
   (u8)(connection_channel | 0x80));
 }
 
-/*
- * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
- *
- * Parameters:
- * In:
- * rate- Tx Rate
- * bb_type - Tx Packet type
- * Out:
- * tx_rate - pointer to RSPINF TxRate field
- * rsv_time- pointer to RSPINF RsvTime field
- *
- * Return Value: none
- *
- */
-static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type,
-   u8 *tx_rate, u8 *rsv_time)
-{
-   switch (rate) {
-   case RATE_6M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9b;
-   *rsv_time = 24;
-   } else {
-   *tx_rate = 0x8b;
-   *rsv_time = 30;
-   }
-   break;
-   case RATE_9M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9f;
-   *rsv_time = 16;
-   } else {
-   *tx_rate = 0x8f;
-   *rsv_time = 22;
-   }
-   break;
-   case RATE_12M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9a;
-   *rsv_time = 12;
-   } else {
-   *tx_rate = 0x8a;
-   *rsv_time = 18;
-   }
-   break;
-   case RATE_18M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9e;
-   *rsv_time = 8;
-   } else {
-   *tx_rate = 0x8e;
-   *rsv_time = 14;
-   }
-   break;
-   case RATE_36M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9d;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x8d;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_48M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x98;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x88;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_54M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9c;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x8c;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_24M:
-   default:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x99;
-   *rsv_time = 8;
-   } else {
-   *tx_rate = 0x89;
-   *rsv_time = 14;
-   }
-   break;
-   }
-}
+static const u8 vnt_rspinf_b_short_table[] = {
+   0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x09, 0x00,
+   0x15, 0x00, 0x0a, 0x00, 0x0b, 0x00, 0x0b, 0x80
+};
+
+static const u8 vnt_rspinf_b_long_table[] = {
+   0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00,
+   0x15, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x03, 0x80
+};
+
+static const u8 vnt_rspinf_a_table[] = {
+   0x9b, 0x1e, 0x9f, 0x16, 0x9a, 0x12, 0x9e, 0x0e, 0x99,
+   0x0e, 0x9d, 0x0a, 0x98, 0x0a, 0x9c, 0x0a, 0x9c, 0x0a
+};
+
+static const u8 vnt_rspinf_gb_table[] = {
+   0x8b, 0x1e, 0x8f, 0x16, 0x8a, 0x12, 0x8e, 0x0e, 0x89,
+   0x0e, 0x8d, 0x0a, 0x88, 0x0a, 0x8c, 0x0a, 0x8c, 0x0a
+};
 
 /*
  * Description: Set RSPINF
@@ -183,74 +109,32 @@ static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type,
 
 void vnt_set_rspinf(struct vnt_private *priv, u8 bb_type)
 {
-   struct vnt_phy_field phy[4];
-   u8 tx_rate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */
-   u8 rsv_time[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
-   u8 data[34];
-   int i;
-
-   /*RSPINF_b_1*/
-   vnt_get_phy_field(priv, 14, RATE_1M, PK_TYPE_11B, [0]);
-
-   /*RSPINF_b_2*/
-   vnt_get_phy_field(priv, 14, RATE_2M, PK_TYPE_11B, [1]);
-
-   /*RSPINF_b_5*/
-   vnt_get_phy_field(priv, 14, RATE_5M, PK_TYPE_11B, [2]);
-
-   /*RSPINF_b_11

Re: [PATCH 1/2] staging: vt6656: Refactor the assignment of the phy->signal variable

2020-04-10 Thread Malcolm Priestley




On 10/04/2020 16:59, Oscar Carter wrote:

On Fri, Apr 10, 2020 at 04:37:59PM +0100, Malcolm Priestley wrote:



On 10/04/2020 12:28, Oscar Carter wrote:

Create a constant array with the values of the "phy->signal" for every
rate. Remove all "phy->signal" assignments inside the switch statement
and replace these with a single reading from the new vnt_phy_signal
array.

Signed-off-by: Oscar Carter 
---
   drivers/staging/vt6656/baseband.c | 101 +++---
   1 file changed, 21 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index a19a563d8bcc..47f93bf6e07b 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -115,6 +115,21 @@ static const u16 vnt_frame_time[MAX_RATE] = {
10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
   };


Actually you don't need the second values


Great.


+static const u8 vnt_phy_signal[][2] = {
+   {0x00, 0x00},   /* RATE_1M  */

The driver would never attempt use preamble at this rate
so it's safe to include in with the next 3 rates

Sorry got this wrong the driver is trying to do preamble (short)
at this rate and it is not working.

So don't apply it to RATE_1M rate.

Regards

Malcolm


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] staging: vt6656: Refactor the assignment of the phy->signal variable

2020-04-10 Thread Malcolm Priestley




On 10/04/2020 12:28, Oscar Carter wrote:

Create a constant array with the values of the "phy->signal" for every
rate. Remove all "phy->signal" assignments inside the switch statement
and replace these with a single reading from the new vnt_phy_signal
array.

Signed-off-by: Oscar Carter 
---
  drivers/staging/vt6656/baseband.c | 101 +++---
  1 file changed, 21 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index a19a563d8bcc..47f93bf6e07b 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -115,6 +115,21 @@ static const u16 vnt_frame_time[MAX_RATE] = {
10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
  };


Actually you don't need the second values


+static const u8 vnt_phy_signal[][2] = {
+   {0x00, 0x00},   /* RATE_1M  */

The driver would never attempt use preamble at this rate
so it's safe to include in with the next 3 rates


+   {0x01, 0x09},   /* RATE_2M  */
+   {0x02, 0x0a},   /* RATE_5M  */
+   {0x03, 0x0b},   /* RATE_11M */

just |= BIT(3) for preamble.


+   {0x8b, 0x9b},   /* RATE_6M  */
+   {0x8f, 0x9f},   /* RATE_9M  */
+   {0x8a, 0x9a},   /* RATE_12M */
+   {0x8e, 0x9e},   /* RATE_18M */
+   {0x89, 0x99},   /* RATE_24M */
+   {0x8d, 0x9d},   /* RATE_36M */
+   {0x88, 0x98},   /* RATE_48M */
+   {0x8c, 0x9c}/* RATE_54M */


Again just |= BIT(4) for PK_TYPE_11A

Regards

Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2 v2] staging: vt6656: rxtx remove rate change and current_rate.

2020-04-06 Thread Malcolm Priestley
There is no longer any need to change power in vnt_tx_packet.

Remove current_rate in vnt_tx_packet and struct vnt_private as
it is no longer used elsewhere.

Signed-off-by: Malcolm Priestley 
---
v2
Patch 1 had wrong array.

 drivers/staging/vt6656/device.h |  1 -
 drivers/staging/vt6656/rxtx.c   | 15 ---
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index e6ee9411f080..41226cd599c6 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -344,7 +344,6 @@ struct vnt_private {
u8 ofdm_pwr_tbl[14];
u8 ofdm_a_pwr_tbl[42];
 
-   u16 current_rate;
u16 tx_rate_fb0;
u16 tx_rate_fb1;
 
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 9439d190f431..8363d54cd821 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -547,7 +547,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
struct vnt_tx_fifo_head *tx_buffer_head;
struct vnt_usb_send_context *tx_context;
unsigned long flags;
-   u16 tx_bytes, tx_header_size, tx_body_size, current_rate, duration_id;
+   u16 tx_bytes, tx_header_size, tx_body_size, duration_id;
u8 pkt_type;
bool need_rts = false;
bool need_mic = false;
@@ -556,14 +556,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
rate = ieee80211_get_tx_rate(priv->hw, info);
 
-   current_rate = rate->hw_value;
-   if (priv->current_rate != current_rate &&
-   !(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
-   priv->current_rate = current_rate;
-   vnt_schedule_command(priv, WLAN_CMD_SETPOWER);
-   }
-
-   if (current_rate > RATE_11M) {
+   if (rate->hw_value > RATE_11M) {
if (info->band == NL80211_BAND_5GHZ) {
pkt_type = PK_TYPE_11A;
} else {
@@ -593,7 +586,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
tx_context->pkt_type = pkt_type;
tx_context->need_ack = false;
tx_context->frame_len = skb->len + 4;
-   tx_context->tx_rate = current_rate;
+   tx_context->tx_rate =  rate->hw_value;
 
spin_unlock_irqrestore(>lock, flags);
 
@@ -666,7 +659,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
tx_context->frame_len += tx_key->icv_len;
}
 
-   tx_buffer_head->current_rate = cpu_to_le16(current_rate);
+   tx_buffer_head->current_rate = cpu_to_le16(rate->hw_value);
 
duration_id = vnt_generate_tx_parameter(tx_context, tx_buffer, _hdr,
need_mic, need_rts);
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2 v2] staging: vt6556: vnt_rf_setpower convert to use ieee80211_channel.

2020-04-06 Thread Malcolm Priestley
ieee80211_channel contains all the necessary information to change
power according to tx mode required.

vnt_rf_setpower is moved and so that vnt_rf_set_txpower the only
caller becomes static.

Signed-off-by: Malcolm Priestley 
---
v2
ARRAY_SIZE(priv->ofdm_pwr_tbl) pointing to wrong array.

 drivers/staging/vt6656/main_usb.c | 16 ++-
 drivers/staging/vt6656/rf.c   | 79 +++
 drivers/staging/vt6656/rf.h   |  3 +-
 drivers/staging/vt6656/wcmd.c |  3 +-
 4 files changed, 43 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index dd89f98cc18c..3c76d3cb5bbe 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -685,15 +685,8 @@ static int vnt_config(struct ieee80211_hw *hw, u32 changed)
priv->bb_type = BB_TYPE_11G;
}
 
-   if (changed & IEEE80211_CONF_CHANGE_POWER) {
-   if (priv->bb_type == BB_TYPE_11B)
-   priv->current_rate = RATE_1M;
-   else
-   priv->current_rate = RATE_54M;
-
-   vnt_rf_setpower(priv, priv->current_rate,
-   conf->chandef.chan->hw_value);
-   }
+   if (changed & IEEE80211_CONF_CHANGE_POWER)
+   vnt_rf_setpower(priv, conf->chandef.chan);
 
return 0;
 }
@@ -747,9 +740,8 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
vnt_update_pre_ed_threshold(priv, false);
}
 
-   if (changed & BSS_CHANGED_TXPOWER)
-   vnt_rf_setpower(priv, priv->current_rate,
-   conf->chandef.chan->hw_value);
+   if (changed & (BSS_CHANGED_TXPOWER | BSS_CHANGED_BANDWIDTH))
+   vnt_rf_setpower(priv, conf->chandef.chan);
 
if (changed & BSS_CHANGED_BEACON_ENABLED) {
dev_dbg(>usb->dev,
diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c
index 4f9aba0f21b0..633e2b9aca7a 100644
--- a/drivers/staging/vt6656/rf.c
+++ b/drivers/staging/vt6656/rf.c
@@ -537,42 +537,6 @@ int vnt_rf_write_embedded(struct vnt_private *priv, u32 
data)
return true;
 }
 
-/* Set Tx power by rate and channel number */
-int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel)
-{
-   u8 power = priv->cck_pwr;
-
-   if (channel == 0)
-   return -EINVAL;
-
-   switch (rate) {
-   case RATE_1M:
-   case RATE_2M:
-   case RATE_5M:
-   case RATE_11M:
-   channel--;
-
-   if (channel < sizeof(priv->cck_pwr_tbl))
-   power = priv->cck_pwr_tbl[channel];
-   break;
-   case RATE_6M:
-   case RATE_9M:
-   case RATE_12M:
-   case RATE_18M:
-   case RATE_24M:
-   case RATE_36M:
-   case RATE_48M:
-   case RATE_54M:
-   if (channel > CB_MAX_CHANNEL_24G)
-   power = priv->ofdm_a_pwr_tbl[channel - 15];
-   else
-   power = priv->ofdm_pwr_tbl[channel - 1];
-   break;
-   }
-
-   return vnt_rf_set_txpower(priv, power, rate);
-}
-
 static u8 vnt_rf_addpower(struct vnt_private *priv)
 {
s32 rssi = -priv->current_rssi;
@@ -600,7 +564,8 @@ static u8 vnt_rf_addpower(struct vnt_private *priv)
 }
 
 /* Set Tx power by power level and rate */
-int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate)
+static int vnt_rf_set_txpower(struct vnt_private *priv, u8 power,
+ struct ieee80211_channel *ch)
 {
u32 power_setting = 0;
int ret = true;
@@ -620,7 +585,7 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, 
u32 rate)
 
ret &= vnt_rf_write_embedded(priv, power_setting);
 
-   if (rate <= RATE_11M)
+   if (ch->flags & IEEE80211_CHAN_NO_OFDM)
ret &= vnt_rf_write_embedded(priv, 0x0001b400);
else
ret &= vnt_rf_write_embedded(priv, 0x0005a400);
@@ -630,7 +595,7 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, 
u32 rate)
 
ret &= vnt_rf_write_embedded(priv, power_setting);
 
-   if (rate <= RATE_11M) {
+   if (ch->flags & IEEE80211_CHAN_NO_OFDM) {
ret &= vnt_rf_write_embedded(priv, 0x040c1400);
ret &= vnt_rf_write_embedded(priv, 0x00299b00);
} else {
@@ -640,7 +605,7 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, 
u32 rate)
break;
 
case RF_AIROHA7230:
-   if (rate <= RATE_11M)
+   if (ch->flags & IEEE80211_CHAN_NO_OFDM)
ret &= vnt_rf_write_embedded(priv, 0x111bb900);
else
  

Re: [PATCH 1/2] staging: vt6556: vnt_rf_setpower convert to use ieee80211_channel.

2020-04-06 Thread Malcolm Priestley
Drop these patches I have just noticed a mistake.

Regards

Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: vt6656: rxtx remove rate change and current_rate.

2020-04-06 Thread Malcolm Priestley
There is no longer any need to change power in vnt_tx_packet.

Remove current_rate in vnt_tx_packet and struct vnt_private as
it is no longer used elsewhere.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h |  1 -
 drivers/staging/vt6656/rxtx.c   | 15 ---
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index e6ee9411f080..41226cd599c6 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -344,7 +344,6 @@ struct vnt_private {
u8 ofdm_pwr_tbl[14];
u8 ofdm_a_pwr_tbl[42];
 
-   u16 current_rate;
u16 tx_rate_fb0;
u16 tx_rate_fb1;
 
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 9439d190f431..8363d54cd821 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -547,7 +547,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
struct vnt_tx_fifo_head *tx_buffer_head;
struct vnt_usb_send_context *tx_context;
unsigned long flags;
-   u16 tx_bytes, tx_header_size, tx_body_size, current_rate, duration_id;
+   u16 tx_bytes, tx_header_size, tx_body_size, duration_id;
u8 pkt_type;
bool need_rts = false;
bool need_mic = false;
@@ -556,14 +556,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
rate = ieee80211_get_tx_rate(priv->hw, info);
 
-   current_rate = rate->hw_value;
-   if (priv->current_rate != current_rate &&
-   !(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
-   priv->current_rate = current_rate;
-   vnt_schedule_command(priv, WLAN_CMD_SETPOWER);
-   }
-
-   if (current_rate > RATE_11M) {
+   if (rate->hw_value > RATE_11M) {
if (info->band == NL80211_BAND_5GHZ) {
pkt_type = PK_TYPE_11A;
} else {
@@ -593,7 +586,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
tx_context->pkt_type = pkt_type;
tx_context->need_ack = false;
tx_context->frame_len = skb->len + 4;
-   tx_context->tx_rate = current_rate;
+   tx_context->tx_rate =  rate->hw_value;
 
spin_unlock_irqrestore(>lock, flags);
 
@@ -666,7 +659,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
tx_context->frame_len += tx_key->icv_len;
}
 
-   tx_buffer_head->current_rate = cpu_to_le16(current_rate);
+   tx_buffer_head->current_rate = cpu_to_le16(rate->hw_value);
 
duration_id = vnt_generate_tx_parameter(tx_context, tx_buffer, _hdr,
need_mic, need_rts);
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: vt6556: vnt_rf_setpower convert to use ieee80211_channel.

2020-04-06 Thread Malcolm Priestley
ieee80211_channel contains all the necessary information to change
power according to tx mode required.

vnt_rf_setpower is moved and so that vnt_rf_set_txpower the only
caller becomes static.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 16 ++-
 drivers/staging/vt6656/rf.c   | 79 +++
 drivers/staging/vt6656/rf.h   |  3 +-
 drivers/staging/vt6656/wcmd.c |  3 +-
 4 files changed, 43 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index dd89f98cc18c..3c76d3cb5bbe 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -685,15 +685,8 @@ static int vnt_config(struct ieee80211_hw *hw, u32 changed)
priv->bb_type = BB_TYPE_11G;
}
 
-   if (changed & IEEE80211_CONF_CHANGE_POWER) {
-   if (priv->bb_type == BB_TYPE_11B)
-   priv->current_rate = RATE_1M;
-   else
-   priv->current_rate = RATE_54M;
-
-   vnt_rf_setpower(priv, priv->current_rate,
-   conf->chandef.chan->hw_value);
-   }
+   if (changed & IEEE80211_CONF_CHANGE_POWER)
+   vnt_rf_setpower(priv, conf->chandef.chan);
 
return 0;
 }
@@ -747,9 +740,8 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
vnt_update_pre_ed_threshold(priv, false);
}
 
-   if (changed & BSS_CHANGED_TXPOWER)
-   vnt_rf_setpower(priv, priv->current_rate,
-   conf->chandef.chan->hw_value);
+   if (changed & (BSS_CHANGED_TXPOWER | BSS_CHANGED_BANDWIDTH))
+   vnt_rf_setpower(priv, conf->chandef.chan);
 
if (changed & BSS_CHANGED_BEACON_ENABLED) {
dev_dbg(>usb->dev,
diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c
index 4f9aba0f21b0..633e2b9aca7a 100644
--- a/drivers/staging/vt6656/rf.c
+++ b/drivers/staging/vt6656/rf.c
@@ -537,42 +537,6 @@ int vnt_rf_write_embedded(struct vnt_private *priv, u32 
data)
return true;
 }
 
-/* Set Tx power by rate and channel number */
-int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel)
-{
-   u8 power = priv->cck_pwr;
-
-   if (channel == 0)
-   return -EINVAL;
-
-   switch (rate) {
-   case RATE_1M:
-   case RATE_2M:
-   case RATE_5M:
-   case RATE_11M:
-   channel--;
-
-   if (channel < sizeof(priv->cck_pwr_tbl))
-   power = priv->cck_pwr_tbl[channel];
-   break;
-   case RATE_6M:
-   case RATE_9M:
-   case RATE_12M:
-   case RATE_18M:
-   case RATE_24M:
-   case RATE_36M:
-   case RATE_48M:
-   case RATE_54M:
-   if (channel > CB_MAX_CHANNEL_24G)
-   power = priv->ofdm_a_pwr_tbl[channel - 15];
-   else
-   power = priv->ofdm_pwr_tbl[channel - 1];
-   break;
-   }
-
-   return vnt_rf_set_txpower(priv, power, rate);
-}
-
 static u8 vnt_rf_addpower(struct vnt_private *priv)
 {
s32 rssi = -priv->current_rssi;
@@ -600,7 +564,8 @@ static u8 vnt_rf_addpower(struct vnt_private *priv)
 }
 
 /* Set Tx power by power level and rate */
-int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate)
+static int vnt_rf_set_txpower(struct vnt_private *priv, u8 power,
+ struct ieee80211_channel *ch)
 {
u32 power_setting = 0;
int ret = true;
@@ -620,7 +585,7 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, 
u32 rate)
 
ret &= vnt_rf_write_embedded(priv, power_setting);
 
-   if (rate <= RATE_11M)
+   if (ch->flags & IEEE80211_CHAN_NO_OFDM)
ret &= vnt_rf_write_embedded(priv, 0x0001b400);
else
ret &= vnt_rf_write_embedded(priv, 0x0005a400);
@@ -630,7 +595,7 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, 
u32 rate)
 
ret &= vnt_rf_write_embedded(priv, power_setting);
 
-   if (rate <= RATE_11M) {
+   if (ch->flags & IEEE80211_CHAN_NO_OFDM) {
ret &= vnt_rf_write_embedded(priv, 0x040c1400);
ret &= vnt_rf_write_embedded(priv, 0x00299b00);
} else {
@@ -640,7 +605,7 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, 
u32 rate)
break;
 
case RF_AIROHA7230:
-   if (rate <= RATE_11M)
+   if (ch->flags & IEEE80211_CHAN_NO_OFDM)
ret &= vnt_rf_write_embedded(priv, 0x111bb900);
else
ret &= vnt_rf_write_embedded(priv, 0x

[PATCH 2/2] staging: vt6656: set all cck rates to default.

2020-04-02 Thread Malcolm Priestley
mac80211 rate control decides which cck rates to use so all of
them should be set enabled at the appropriate bit rate.

This means vnt_get_cck_rate is no longer required.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/card.c | 38 ---
 1 file changed, 4 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 4abbe9b30b65..97e1538a528e 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -74,32 +74,6 @@ void vnt_set_channel(struct vnt_private *priv, u32 
connection_channel)
   (u8)(connection_channel | 0x80));
 }
 
-/*
- * Description: Get CCK mode basic rate
- *
- * Parameters:
- *  In:
- *  priv   - The adapter to be set
- *  rate_idx   - Receiving data rate
- *  Out:
- *  none
- *
- * Return Value: response Control frame rate
- *
- */
-static u16 vnt_get_cck_rate(struct vnt_private *priv, u16 rate_idx)
-{
-   u16 ui = rate_idx;
-
-   while (ui > RATE_1M) {
-   if (priv->basic_rates & (1 << ui))
-   return ui;
-   ui--;
-   }
-
-   return RATE_1M;
-}
-
 /*
  * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
  *
@@ -216,20 +190,16 @@ void vnt_set_rspinf(struct vnt_private *priv, u8 bb_type)
int i;
 
/*RSPINF_b_1*/
-   vnt_get_phy_field(priv, 14, vnt_get_cck_rate(priv, RATE_1M),
- PK_TYPE_11B, [0]);
+   vnt_get_phy_field(priv, 14, RATE_1M, PK_TYPE_11B, [0]);
 
/*RSPINF_b_2*/
-   vnt_get_phy_field(priv, 14, vnt_get_cck_rate(priv, RATE_2M),
- PK_TYPE_11B, [1]);
+   vnt_get_phy_field(priv, 14, RATE_2M, PK_TYPE_11B, [1]);
 
/*RSPINF_b_5*/
-   vnt_get_phy_field(priv, 14, vnt_get_cck_rate(priv, RATE_5M),
- PK_TYPE_11B, [2]);
+   vnt_get_phy_field(priv, 14, RATE_5M, PK_TYPE_11B, [2]);
 
/*RSPINF_b_11*/
-   vnt_get_phy_field(priv, 14, vnt_get_cck_rate(priv, RATE_11M),
- PK_TYPE_11B, [3]);
+   vnt_get_phy_field(priv, 14, RATE_11M, PK_TYPE_11B, [3]);
 
/*RSPINF_a_6*/
vnt_calculate_ofdm_rate(RATE_6M, bb_type, _rate[0], _time[0]);
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: vt6656: set all ofdm rates to default

2020-04-02 Thread Malcolm Priestley
mac80211 rate control decides which odfm rates to use so all of
them should be set enabled at the appropriate bit rate.

This means vnt_get_ofdm_rate is no longer required.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/card.c | 54 +++
 1 file changed, 4 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index dc3ab10eb630..4abbe9b30b65 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -100,48 +100,6 @@ static u16 vnt_get_cck_rate(struct vnt_private *priv, u16 
rate_idx)
return RATE_1M;
 }
 
-/*
- * Description: Get OFDM mode basic rate
- *
- * Parameters:
- *  In:
- *  priv   - The adapter to be set
- *  rate_idx   - Receiving data rate
- *  Out:
- *  none
- *
- * Return Value: response Control frame rate
- *
- */
-static u16 vnt_get_ofdm_rate(struct vnt_private *priv, u16 rate_idx)
-{
-   u16 ui = rate_idx;
-
-   dev_dbg(>usb->dev, "%s basic rate: %d\n",
-   __func__,  priv->basic_rates);
-
-   if (!vnt_ofdm_min_rate(priv)) {
-   dev_dbg(>usb->dev, "%s (NO OFDM) %d\n",
-   __func__, rate_idx);
-   if (rate_idx > RATE_24M)
-   rate_idx = RATE_24M;
-   return rate_idx;
-   }
-
-   while (ui > RATE_11M) {
-   if (priv->basic_rates & (1 << ui)) {
-   dev_dbg(>usb->dev, "%s rate: %d\n",
-   __func__, ui);
-   return ui;
-   }
-   ui--;
-   }
-
-   dev_dbg(>usb->dev, "%s basic rate: 24M\n", __func__);
-
-   return RATE_24M;
-}
-
 /*
  * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
  *
@@ -289,20 +247,16 @@ void vnt_set_rspinf(struct vnt_private *priv, u8 bb_type)
vnt_calculate_ofdm_rate(RATE_24M, bb_type, _rate[4], _time[4]);
 
/*RSPINF_a_36*/
-   vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_36M),
-   bb_type, _rate[5], _time[5]);
+   vnt_calculate_ofdm_rate(RATE_36M, bb_type, _rate[5], _time[5]);
 
/*RSPINF_a_48*/
-   vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_48M),
-   bb_type, _rate[6], _time[6]);
+   vnt_calculate_ofdm_rate(RATE_48M, bb_type, _rate[6], _time[6]);
 
/*RSPINF_a_54*/
-   vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_54M),
-   bb_type, _rate[7], _time[7]);
+   vnt_calculate_ofdm_rate(RATE_54M, bb_type, _rate[7], _time[7]);
 
/*RSPINF_a_72*/
-   vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_54M),
-   bb_type, _rate[8], _time[8]);
+   vnt_calculate_ofdm_rate(RATE_54M, bb_type, _rate[8], _time[8]);
 
put_unaligned(phy[0].len, (u16 *)[0]);
data[2] = phy[0].signal;
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: replace al2230_power_table array with formula.

2020-04-02 Thread Malcolm Priestley
The power table can replaced with calculation 0x0404090 | (power << 12)
removing array and length macro.

variable power never goes beyond the maximum setting.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rf.c | 79 ++---
 1 file changed, 4 insertions(+), 75 deletions(-)

diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c
index 43237b7e1dbe..4f9aba0f21b0 100644
--- a/drivers/staging/vt6656/rf.c
+++ b/drivers/staging/vt6656/rf.c
@@ -27,7 +27,6 @@
 #include "usbpipe.h"
 
 #define CB_AL2230_INIT_SEQ15
-#define AL2230_PWR_IDX_LEN64
 
 #define CB_AL7230_INIT_SEQ16
 #define AL7230_PWR_IDX_LEN64
@@ -518,74 +517,6 @@ static u8 vt3342_channel_table1[CB_MAX_CHANNEL][3] = {
{0x03, 0x00, 0x04}
 };
 
-/* Power Table */
-static const u32 al2230_power_table[AL2230_PWR_IDX_LEN] = {
-   0x04040900,
-   0x04041900,
-   0x04042900,
-   0x04043900,
-   0x04044900,
-   0x04045900,
-   0x04046900,
-   0x04047900,
-   0x04048900,
-   0x04049900,
-   0x0404a900,
-   0x0404b900,
-   0x0404c900,
-   0x0404d900,
-   0x0404e900,
-   0x0404f900,
-   0x04050900,
-   0x04051900,
-   0x04052900,
-   0x04053900,
-   0x04054900,
-   0x04055900,
-   0x04056900,
-   0x04057900,
-   0x04058900,
-   0x04059900,
-   0x0405a900,
-   0x0405b900,
-   0x0405c900,
-   0x0405d900,
-   0x0405e900,
-   0x0405f900,
-   0x04060900,
-   0x04061900,
-   0x04062900,
-   0x04063900,
-   0x04064900,
-   0x04065900,
-   0x04066900,
-   0x04067900,
-   0x04068900,
-   0x04069900,
-   0x0406a900,
-   0x0406b900,
-   0x0406c900,
-   0x0406d900,
-   0x0406e900,
-   0x0406f900,
-   0x04070900,
-   0x04071900,
-   0x04072900,
-   0x04073900,
-   0x04074900,
-   0x04075900,
-   0x04076900,
-   0x04077900,
-   0x04078900,
-   0x04079900,
-   0x0407a900,
-   0x0407b900,
-   0x0407c900,
-   0x0407d900,
-   0x0407e900,
-   0x0407f900
-};
-
 /*
  * Description: Write to IF/RF, by embedded programming
  */
@@ -685,10 +616,9 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, 
u32 rate)
 
switch (priv->rf_type) {
case RF_AL2230:
-   if (power >= AL2230_PWR_IDX_LEN)
-   return false;
+   power_setting = 0x0404090 | (power << 12);
 
-   ret &= vnt_rf_write_embedded(priv, al2230_power_table[power]);
+   ret &= vnt_rf_write_embedded(priv, power_setting);
 
if (rate <= RATE_11M)
ret &= vnt_rf_write_embedded(priv, 0x0001b400);
@@ -696,10 +626,9 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, 
u32 rate)
ret &= vnt_rf_write_embedded(priv, 0x0005a400);
break;
case RF_AL2230S:
-   if (power >= AL2230_PWR_IDX_LEN)
-   return false;
+   power_setting = 0x0404090 | (power << 12);
 
-   ret &= vnt_rf_write_embedded(priv, al2230_power_table[power]);
+   ret &= vnt_rf_write_embedded(priv, power_setting);
 
if (rate <= RATE_11M) {
ret &= vnt_rf_write_embedded(priv, 0x040c1400);
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vt6656: Use defines in vnt_mac_reg_bits_* functions

2020-04-02 Thread Malcolm Priestley




On 02/04/2020 10:19, Quentin Deslandes wrote:

On 04/01/20 18:55:38, Oscar Carter wrote:

On Tue, Mar 31, 2020 at 01:29:06PM +0300, Dan Carpenter wrote:

On Sat, Mar 28, 2020 at 10:54:33AM +0100, Oscar Carter wrote:

Define the necessary bits in the CHANNEL, PAPEDELAY and GPIOCTL0
registers to can use them in the calls to vnt_mac_reg_bits_on and
vnt_mac_reg_bits_off functions. In this way, avoid the use of BIT()
macros and clarify the code.

Fixes: 3017e587e368 ("staging: vt6656: Use BIT() macro in vnt_mac_reg_bits_* 
functions")
Suggested-by: Dan Carpenter 
Signed-off-by: Oscar Carter 
---
  drivers/staging/vt6656/baseband.c |  6 --
  drivers/staging/vt6656/card.c |  3 +--
  drivers/staging/vt6656/mac.h  | 12 
  drivers/staging/vt6656/main_usb.c |  2 +-
  4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index a19a563d8bcc..dd3c3bf5e8b5 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -442,7 +442,8 @@ int vnt_vt3184_init(struct vnt_private *priv)
if (ret)
goto end;

-   ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, BIT(0));
+   ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY,
+ PAPEDELAY_B0);


This doesn't clarify anything.  It makes it less clear because someone
would assume B0 means something but it's just hiding a magic number
behind a meaningless define.  B0 means BIT(0) which means nothing.  So
now we have to jump through two hoops to find out that we don't know
anything.


I created this names due to the lack of information about the hardware. I
searched but I did not find anything.


Just leave it as-is.  Same for the rest.

Ok.



There problem is a hardware spec which explains what this stuff is.


It's possible to find a datasheet of this hardware to make this modification
accordingly to the correct bit names of registers ?


I haven't found any so far, if your researches are luckier than mine, I
would be interested too. Even getting your hands on the actual device is
complicated.


All I can tell you is it related to command above it MAC_REG_ITRTMSET 
without it the device will not associate with access point is probably 
TX timing/power rated.


Other bits in MAC_REG_PAPEDELAY are related to LED function and defined 
in LEDSTS_* in mac.h.


I think it is some kind of enable so something like ITRTMSET_ENABLE 
would do.


Regards

Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Outreachy kernel] [PATCH v4] staging: vt6656: add error code handling to unused variable

2020-03-30 Thread Malcolm Priestley

On 30/03/2020 18:14, Stefano Brivio wrote:

On Mon, 30 Mar 2020 09:45:30 -0700
"John B. Wyatt IV"  wrote:


Add error code handling to unused 'ret' variable that was never used.
Return an error code from functions called within vnt_radio_power_on.

Issue reported by coccinelle (coccicheck).

Suggested-by: Quentin Deslandes 
Suggested-by: Stefano Brivio 
Suggested-by: Julia Lawall 
Reviewed-by: Quentin Deslandes 
Signed-off-by: John B. Wyatt IV 
---
v4: Move Suggested-by: Julia Lawall above seperator line.


Actually, as Julia didn't suggest this patch, the place where you had
this in v3 was the right one.

---snip
  
  	switch (priv->rf_type) {

case RF_AL2230:
@@ -734,14 +738,14 @@ int vnt_radio_power_on(struct vnt_private *priv)
case RF_VT3226:
case RF_VT3226D0:
case RF_VT3342A0:
-   vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL,
-   (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
+   ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL,
+(SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));



Another thing that should be considered in this function is to restore
the previous hardware state on failures, but I think the way you're
handling this is possibly the safest, without hardware to test on.


This section of hardware is controlled by mac80211 as is most of the driver.

Users can turn the wireless off then on again to try again but to date 
this is not known to fail with the hardware I have used.


No problems with hardware with this patch.

Tested-by: Malcolm Priestley 



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vt6656: Use BIT_ULL() macro instead of bit shift operation

2020-03-08 Thread Malcolm Priestley
>>>   */
>>>  #undef __NO_VERSION__
>>>
>>> +#include 
>>>  #include 
>>>  #include 
>>>  #include "device.h"
>>> @@ -802,8 +803,7 @@ static u64 vnt_prepare_multicast(struct ieee80211_hw 
>>> *hw,
>>>
>>> netdev_hw_addr_list_for_each(ha, mc_list) {
>>> bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
>>> -
>>> -   mc_filter |= 1ULL << (bit_nr & 0x3f);
>>> +   mc_filter |= BIT_ULL(bit_nr);
>>
>> Are you sure this does the same thing?  You are not masking off bit_nr
>> anymore, why not?
> 
> My reasons are exposed below:
> 
> The ether_crc function returns an u32 type (unsigned of 32 bits). Then the 
> right
> shift operand discards the 26 lsb bits (the bits shifted off the right side 
> are
> discarded). The 6 msb bits of the u32 returned by the ether_crc function are
> positioned in bit 5 to bit 0 of the variable bit_nr. Due to the right shift
> happens over an unsigned type, the 26 new bits added on the left side will be 
> 0.
> 
> In summary, after the right bit shift operation we obtain in the variable 
> bit_nr
> (unsigned of 32 bits) the value represented by the 6 msb bits of the value
> returned by the ether_crc function. So, only the 6 lsb bits of the variable
> bit_nr are important. The 26 msb bits of this variable are 0.
> 
> In this situation, the "and" operation with the mask 0x3f (mask of 6 lsb bits)
> is unnecessary due to its purpose is to reset (set to 0 value) the 26 msb bits
> that are yet 0.

The mask is only there out of legacy originally it was 31(0x1f) and the
bit_nr spread across two mc_filter u32 arrays.

The mask is not needed now it is u64.

The patch is fine.

Regards

Malcolm


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: vt6656: struct vnt_rcb remove unused in_use.

2020-03-04 Thread Malcolm Priestley
The variable merely toggles true to false and is unused.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h   |  1 -
 drivers/staging/vt6656/main_usb.c |  3 ---
 drivers/staging/vt6656/usbpipe.c  | 16 +++-
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index e94df4685b25..98793e15e80f 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -227,7 +227,6 @@ struct vnt_rcb {
void *priv;
struct urb *urb;
struct sk_buff *skb;
-   int in_use;
 };
 
 /* used to track bulk out irps */
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 41edadc74389..56f81785a118 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -478,9 +478,6 @@ static int vnt_alloc_bufs(struct vnt_private *priv)
ret = -ENOMEM;
goto free_rx_tx;
}
-
-   rcb->in_use = false;
-
/* submit rx urb */
ret = vnt_submit_rx_urb(priv, rcb);
if (ret)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index fd2c9d9d6eb4..eae211e5860f 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -393,10 +393,8 @@ static void vnt_submit_rx_urb_complete(struct urb *urb)
if (urb->actual_length) {
if (vnt_rx_data(priv, rcb, urb->actual_length)) {
rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
-   if (!rcb->skb) {
-   rcb->in_use = false;
+   if (!rcb->skb)
return;
-   }
} else {
skb_push(rcb->skb, skb_headroom(rcb->skb));
skb_trim(rcb->skb, 0);
@@ -406,11 +404,8 @@ static void vnt_submit_rx_urb_complete(struct urb *urb)
   skb_tailroom(rcb->skb));
}
 
-   if (usb_submit_urb(urb, GFP_ATOMIC)) {
+   if (usb_submit_urb(urb, GFP_ATOMIC))
dev_dbg(>usb->dev, "Failed to re submit rx skb\n");
-
-   rcb->in_use = false;
-   }
 }
 
 int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
@@ -433,13 +428,8 @@ int vnt_submit_rx_urb(struct vnt_private *priv, struct 
vnt_rcb *rcb)
  rcb);
 
ret = usb_submit_urb(urb, GFP_ATOMIC);
-   if (ret) {
+   if (ret)
dev_dbg(>usb->dev, "Submit Rx URB failed %d\n", ret);
-   goto end;
-   }
-
-   rcb->in_use = true;
-
 end:
return ret;
 }
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: vt6656: Remove vnt_interrupt_buffer in_use flag.

2020-03-04 Thread Malcolm Priestley
mac80211 is the only user of in_use to start it and should
not be true when so.

So internal toggling of this variable is not relevant.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h  |  1 -
 drivers/staging/vt6656/usbpipe.c | 28 +++-
 2 files changed, 3 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 5c9991415432..e94df4685b25 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -253,7 +253,6 @@ struct vnt_usb_send_context {
  */
 struct vnt_interrupt_buffer {
u8 *data_buf;
-   bool in_use;
 };
 
 /* flags for options */
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index b9e79755e7fa..fd2c9d9d6eb4 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -221,8 +221,6 @@ static void vnt_int_process_data(struct vnt_private *priv)
low_stats->dot11ACKFailureCount += int_data->ack_fail;
low_stats->dot11FCSErrorCount += int_data->fcs_err;
}
-
-   priv->int_buf.in_use = false;
 }
 
 static void vnt_start_interrupt_urb_complete(struct urb *urb)
@@ -237,25 +235,19 @@ static void vnt_start_interrupt_urb_complete(struct urb 
*urb)
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
-   priv->int_buf.in_use = false;
return;
default:
break;
}
 
-   if (status) {
-   priv->int_buf.in_use = false;
-
+   if (status)
dev_dbg(>usb->dev, "%s status = %d\n", __func__, status);
-   } else {
+   else
vnt_int_process_data(priv);
-   }
 
status = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC);
if (status)
dev_dbg(>usb->dev, "Submit int URB failed %d\n", status);
-   else
-   priv->int_buf.in_use = true;
 }
 
 int vnt_start_interrupt_urb(struct vnt_private *priv)
@@ -264,13 +256,6 @@ int vnt_start_interrupt_urb(struct vnt_private *priv)
 
dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
 
-   if (priv->int_buf.in_use) {
-   ret = -EBUSY;
-   goto err;
-   }
-
-   priv->int_buf.in_use = true;
-
usb_fill_int_urb(priv->interrupt_urb,
 priv->usb,
 usb_rcvintpipe(priv->usb, 1),
@@ -281,16 +266,9 @@ int vnt_start_interrupt_urb(struct vnt_private *priv)
 priv->int_interval);
 
ret = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC);
-   if (ret) {
+   if (ret)
dev_dbg(>usb->dev, "Submit int URB failed %d\n", ret);
-   goto err_submit;
-   }
-
-   return 0;
 
-err_submit:
-   priv->int_buf.in_use = false;
-err:
return ret;
 }
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Move vnt_rx_data to usbpipe.c

2020-03-03 Thread Malcolm Priestley
vnt_rx_data is a USB function and vnt_submit_rx_urb_complete is
the only caller therefore removing dpc.c/h files and becoming
static.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/Makefile   |   1 -
 drivers/staging/vt6656/dpc.c  | 124 --
 drivers/staging/vt6656/dpc.h  |  24 --
 drivers/staging/vt6656/main_usb.c |   1 -
 drivers/staging/vt6656/usbpipe.c  | 102 +++-
 5 files changed, 101 insertions(+), 151 deletions(-)
 delete mode 100644 drivers/staging/vt6656/dpc.c
 delete mode 100644 drivers/staging/vt6656/dpc.h

diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile
index 60a41fe62bed..375f54e9f58b 100644
--- a/drivers/staging/vt6656/Makefile
+++ b/drivers/staging/vt6656/Makefile
@@ -9,7 +9,6 @@ vt6656_stage-y +=   main_usb.o \
baseband.o \
wcmd.o\
rxtx.o \
-   dpc.o \
power.o \
key.o \
rf.o \
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
deleted file mode 100644
index a0b60e7d1086..
--- a/drivers/staging/vt6656/dpc.c
+++ /dev/null
@@ -1,124 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * File: dpc.c
- *
- * Purpose: handle dpc rx functions
- *
- * Author: Lyndon Chen
- *
- * Date: May 20, 2003
- *
- * Functions:
- *
- * Revision History:
- *
- */
-
-#include "dpc.h"
-#include "device.h"
-#include "mac.h"
-#include "baseband.h"
-#include "rf.h"
-
-int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb *ptr_rcb,
-   unsigned long bytes_received)
-{
-   struct ieee80211_hw *hw = priv->hw;
-   struct ieee80211_supported_band *sband;
-   struct sk_buff *skb;
-   struct ieee80211_rx_status *rx_status;
-   struct vnt_rx_header *head;
-   struct vnt_rx_tail *tail;
-   u32 frame_size;
-   int ii;
-   u16 rx_bitrate, pay_load_with_padding;
-   u8 rate_idx = 0;
-   long rx_dbm;
-
-   skb = ptr_rcb->skb;
-   rx_status = IEEE80211_SKB_RXCB(skb);
-
-   /* [31:16]RcvByteCount ( not include 4-byte Status ) */
-   head = (struct vnt_rx_header *)skb->data;
-   frame_size = head->wbk_status >> 16;
-   frame_size += 4;
-
-   if (bytes_received != frame_size) {
-   dev_dbg(>usb->dev, "--- WRONG Length 1\n");
-   return false;
-   }
-
-   if ((bytes_received > 2372) || (bytes_received <= 40)) {
-   /* Frame Size error drop this packet.*/
-   dev_dbg(>usb->dev, "-- WRONG Length 2\n");
-   return false;
-   }
-
-   /* real Frame Size = USBframe_size -4WbkStatus - 4RxStatus */
-   /* -8TSF - 4RSR - 4SQ3 - ?Padding */
-
-   /* if SQ3 the range is 24~27, if no SQ3 the range is 20~23 */
-
-   /*Fix hardware bug => PLCP_Length error */
-   if (((bytes_received - head->pay_load_len) > 27) ||
-   ((bytes_received - head->pay_load_len) < 24) ||
-   (bytes_received < head->pay_load_len)) {
-   dev_dbg(>usb->dev, "Wrong PLCP Length %x\n",
-   head->pay_load_len);
-   return false;
-   }
-
-   sband = hw->wiphy->bands[hw->conf.chandef.chan->band];
-   rx_bitrate = head->rx_rate * 5; /* rx_rate * 5 */
-
-   for (ii = 0; ii < sband->n_bitrates; ii++) {
-   if (sband->bitrates[ii].bitrate == rx_bitrate) {
-   rate_idx = ii;
-   break;
-   }
-   }
-
-   if (ii == sband->n_bitrates) {
-   dev_dbg(>usb->dev, "Wrong Rx Bit Rate %d\n", rx_bitrate);
-   return false;
-   }
-
-   pay_load_with_padding = ((head->pay_load_len / 4) +
-   ((head->pay_load_len % 4) ? 1 : 0)) * 4;
-
-   tail = (struct vnt_rx_tail *)(skb->data +
- sizeof(*head) + pay_load_with_padding);
-   priv->tsf_time = le64_to_cpu(tail->tsf_time);
-
-   if (tail->rsr & (RSR_IVLDTYP | RSR_IVLDLEN))
-   return false;
-
-   vnt_rf_rssi_to_dbm(priv, tail->rssi, _dbm);
-
-   priv->bb_pre_ed_rssi = (u8)-rx_dbm + 1;
-   priv->current_rssi = priv->bb_pre_ed_rssi;
-
-   skb_pull(skb, sizeof(*head));
-   skb_trim(skb, head->pay_load_len);
-
-   rx_status->mactime = priv->tsf_time;
-   rx_status->band = hw->conf.chandef.chan->band;
-   rx_status->signal = rx_dbm;
-   rx_status->flag = 0;
-   rx_status->freq = hw->conf.chandef.chan->center_freq;
-
-   if (!(t

[PATCH 3/3] staging: vt6656: Delete int.c/h file and move functions to usbpipe

2020-03-02 Thread Malcolm Priestley
Move functions vnt_int_process_data and vnt_int_report_rate to
usbpipe.c and vnt_interrupt_data to usbpipe.h

These form part of the USB structure.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/Makefile   |   3 +-
 drivers/staging/vt6656/int.c  | 110 --
 drivers/staging/vt6656/int.h  |  46 -
 drivers/staging/vt6656/main_usb.c |   1 -
 drivers/staging/vt6656/usbpipe.c  |  88 +++-
 drivers/staging/vt6656/usbpipe.h  |  23 +++
 6 files changed, 111 insertions(+), 160 deletions(-)
 delete mode 100644 drivers/staging/vt6656/int.c
 delete mode 100644 drivers/staging/vt6656/int.h

diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile
index b64c0d87f612..60a41fe62bed 100644
--- a/drivers/staging/vt6656/Makefile
+++ b/drivers/staging/vt6656/Makefile
@@ -15,7 +15,6 @@ vt6656_stage-y += main_usb.o \
rf.o \
usbpipe.o \
channel.o \
-   firmware.o \
-   int.o
+   firmware.o
 
 obj-$(CONFIG_VT6656) +=vt6656_stage.o
diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
deleted file mode 100644
index 139be3f845c3..
--- a/drivers/staging/vt6656/int.c
+++ /dev/null
@@ -1,110 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * File: int.c
- *
- * Purpose: Handle USB interrupt endpoint
- *
- * Author: Jerry Chen
- *
- * Date: Apr. 2, 2004
- *
- * Functions:
- *
- * Revision History:
- *  04-02-2004 Jerry Chen:  Initial release
- *
- */
-
-#include "int.h"
-#include "mac.h"
-#include "power.h"
-#include "usbpipe.h"
-
-static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr)
-{
-   struct vnt_usb_send_context *context;
-   struct ieee80211_tx_info *info;
-   u8 tx_retry = (tsr & 0xf0) >> 4;
-   s8 idx;
-
-   if (pkt_no >= priv->num_tx_context)
-   return -EINVAL;
-
-   context = priv->tx_context[pkt_no];
-
-   if (!context->skb)
-   return -EINVAL;
-
-   info = IEEE80211_SKB_CB(context->skb);
-   idx = info->control.rates[0].idx;
-
-   ieee80211_tx_info_clear_status(info);
-
-   info->status.rates[0].count = tx_retry;
-
-   if (!(tsr & TSR_TMO)) {
-   info->status.rates[0].idx = idx;
-
-   if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
-   info->flags |= IEEE80211_TX_STAT_ACK;
-   }
-
-   ieee80211_tx_status_irqsafe(priv->hw, context->skb);
-
-   context->in_use = false;
-
-   return 0;
-}
-
-void vnt_int_process_data(struct vnt_private *priv)
-{
-   struct vnt_interrupt_data *int_data;
-   struct ieee80211_low_level_stats *low_stats = >low_stats;
-
-   dev_dbg(>usb->dev, ">s_nsInterruptProcessData\n");
-
-   int_data = (struct vnt_interrupt_data *)priv->int_buf.data_buf;
-
-   if (int_data->tsr0 & TSR_VALID)
-   vnt_int_report_rate(priv, int_data->pkt0, int_data->tsr0);
-
-   if (int_data->tsr1 & TSR_VALID)
-   vnt_int_report_rate(priv, int_data->pkt1, int_data->tsr1);
-
-   if (int_data->tsr2 & TSR_VALID)
-   vnt_int_report_rate(priv, int_data->pkt2, int_data->tsr2);
-
-   if (int_data->tsr3 & TSR_VALID)
-   vnt_int_report_rate(priv, int_data->pkt3, int_data->tsr3);
-
-   if (int_data->isr0 != 0) {
-   if (int_data->isr0 & ISR_BNTX &&
-   priv->op_mode == NL80211_IFTYPE_AP)
-   vnt_schedule_command(priv, WLAN_CMD_BECON_SEND);
-
-   if (int_data->isr0 & ISR_TBTT &&
-   priv->hw->conf.flags & IEEE80211_CONF_PS) {
-   if (!priv->wake_up_count)
-   priv->wake_up_count =
-   priv->hw->conf.listen_interval;
-
-   --priv->wake_up_count;
-
-   /* Turn on wake up to listen next beacon */
-   if (priv->wake_up_count == 1)
-   vnt_schedule_command(priv,
-WLAN_CMD_TBTT_WAKEUP);
-   }
-   priv->current_tsf = le64_to_cpu(int_data->tsf);
-
-   low_stats->dot11RTSSuccessCount += int_data->rts_success;
-   low_stats->dot11RTSFailureCount += int_data->rts_fail;
-   low_stats->dot11ACKFailureCount += int_data->ack_fail;
-   low_stats->dot11FCSErrorCount += int_data->fcs_err;
-   }
-
- 

PATCH 2/3] staging: vt6656: Remove function vnt_int_process_data.

2020-03-02 Thread Malcolm Priestley
call vnt_start_interrupt_urb directly from vnt_start.

Move debug message to vnt_start_interrupt_urb.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/int.c  | 11 ---
 drivers/staging/vt6656/int.h  |  1 -
 drivers/staging/vt6656/main_usb.c |  2 +-
 drivers/staging/vt6656/usbpipe.c  |  2 ++
 4 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index fcf92cd1234b..139be3f845c3 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -23,17 +23,6 @@
 #include "power.h"
 #include "usbpipe.h"
 
-int vnt_int_start_interrupt(struct vnt_private *priv)
-{
-   int ret = 0;
-
-   dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
-
-   ret = vnt_start_interrupt_urb(priv);
-
-   return ret;
-}
-
 static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr)
 {
struct vnt_usb_send_context *context;
diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h
index 8a6d60569ceb..0b7473a7f190 100644
--- a/drivers/staging/vt6656/int.h
+++ b/drivers/staging/vt6656/int.h
@@ -41,7 +41,6 @@ struct vnt_interrupt_data {
u8 sw[2];
 } __packed;
 
-int vnt_int_start_interrupt(struct vnt_private *priv);
 void vnt_int_process_data(struct vnt_private *priv);
 
 #endif /* __INT_H__ */
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 9135aad0863d..a22f88b1f5e9 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -549,7 +549,7 @@ static int vnt_start(struct ieee80211_hw *hw)
 
priv->int_interval = 1;  /* bInterval is set to 1 */
 
-   ret = vnt_int_start_interrupt(priv);
+   ret = vnt_start_interrupt_urb(priv);
if (ret)
goto free_all;
 
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index e93c2175543f..0e29dc2f4b0d 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -176,6 +176,8 @@ int vnt_start_interrupt_urb(struct vnt_private *priv)
 {
int ret = 0;
 
+   dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
+
if (priv->int_buf.in_use) {
ret = -EBUSY;
goto err;
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: vt6656: vnt_int_start_interrupt remove spin lock.

2020-03-02 Thread Malcolm Priestley
This formed part of the legacy driver and potentially multi
users.

The driver now has only one user mac80211 remove this lock.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/int.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index 3fa61c368464..fcf92cd1234b 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -26,16 +26,11 @@
 int vnt_int_start_interrupt(struct vnt_private *priv)
 {
int ret = 0;
-   unsigned long flags;
 
dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
 
-   spin_lock_irqsave(>lock, flags);
-
ret = vnt_start_interrupt_urb(priv);
 
-   spin_unlock_irqrestore(>lock, flags);
-
return ret;
 }
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: vt6656: vnt_vt3184_init remove stack copy to array.

2020-02-29 Thread Malcolm Priestley
use u8 pointer addr directly and remove stack array.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/baseband.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index 48a624bf00c0..74b620b4261e 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -367,7 +367,6 @@ int vnt_vt3184_init(struct vnt_private *priv)
int ret = 0;
u16 length;
u8 *addr;
-   u8 array[256];
u8 data;
 
ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_EEPROM,
@@ -437,10 +436,8 @@ int vnt_vt3184_init(struct vnt_private *priv)
goto end;
}
 
-   memcpy(array, addr, length);
-
ret = vnt_control_out_blocks(priv, VNT_REG_BLOCK_SIZE,
-MESSAGE_REQUEST_BBREG, length, array);
+MESSAGE_REQUEST_BBREG, length, addr);
if (ret)
goto end;
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: vt6656: use vnt_vt3184_agc array directly

2020-02-29 Thread Malcolm Priestley
vnt_vt3184_agc is always the same regardless of rf type
so use the array directly removing from stack buffer.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/baseband.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index f18e059ce66b..48a624bf00c0 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -367,8 +367,6 @@ int vnt_vt3184_init(struct vnt_private *priv)
int ret = 0;
u16 length;
u8 *addr;
-   u8 *agc;
-   u16 length_agc;
u8 array[256];
u8 data;
 
@@ -386,8 +384,6 @@ int vnt_vt3184_init(struct vnt_private *priv)
priv->bb_rx_conf = vnt_vt3184_al2230[10];
length = sizeof(vnt_vt3184_al2230);
addr = vnt_vt3184_al2230;
-   agc = vnt_vt3184_agc;
-   length_agc = sizeof(vnt_vt3184_agc);
 
priv->bb_vga[0] = 0x1C;
priv->bb_vga[1] = 0x10;
@@ -398,8 +394,6 @@ int vnt_vt3184_init(struct vnt_private *priv)
priv->bb_rx_conf = vnt_vt3184_al2230[10];
length = sizeof(vnt_vt3184_al2230);
addr = vnt_vt3184_al2230;
-   agc = vnt_vt3184_agc;
-   length_agc = sizeof(vnt_vt3184_agc);
 
addr[0xd7] = 0x06;
 
@@ -413,8 +407,6 @@ int vnt_vt3184_init(struct vnt_private *priv)
priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
length = sizeof(vnt_vt3184_vt3226d0);
addr = vnt_vt3184_vt3226d0;
-   agc = vnt_vt3184_agc;
-   length_agc = sizeof(vnt_vt3184_agc);
 
priv->bb_vga[0] = 0x20;
priv->bb_vga[1] = 0x10;
@@ -430,8 +422,6 @@ int vnt_vt3184_init(struct vnt_private *priv)
priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
length = sizeof(vnt_vt3184_vt3226d0);
addr = vnt_vt3184_vt3226d0;
-   agc = vnt_vt3184_agc;
-   length_agc = sizeof(vnt_vt3184_agc);
 
priv->bb_vga[0] = 0x20;
priv->bb_vga[1] = 0x10;
@@ -454,10 +444,9 @@ int vnt_vt3184_init(struct vnt_private *priv)
if (ret)
goto end;
 
-   memcpy(array, agc, length_agc);
-
ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
- MESSAGE_REQUEST_BBAGC, length_agc, array);
+ MESSAGE_REQUEST_BBAGC,
+ sizeof(vnt_vt3184_agc), vnt_vt3184_agc);
if (ret)
goto end;
 
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Remove STATUS enums from TX path

2020-02-29 Thread Malcolm Priestley
Returning standard error code or status variable.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h  | 9 -
 drivers/staging/vt6656/rxtx.c| 4 ++--
 drivers/staging/vt6656/usbpipe.c | 5 ++---
 3 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index da868adba7c9..5c9991415432 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -256,15 +256,6 @@ struct vnt_interrupt_buffer {
bool in_use;
 };
 
-/*++ NDIS related */
-
-enum {
-   STATUS_SUCCESS = 0,
-   STATUS_FAILURE,
-   STATUS_RESOURCES,
-   STATUS_PENDING,
-};
-
 /* flags for options */
 #define DEVICE_FLAGS_UNPLUG0
 #define DEVICE_FLAGS_DISCONNECTED  1
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 1003808ac4ad..9439d190f431 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -704,7 +704,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
spin_lock_irqsave(>lock, flags);
 
-   if (vnt_tx_context(priv, tx_context) != STATUS_PENDING) {
+   if (vnt_tx_context(priv, tx_context)) {
spin_unlock_irqrestore(>lock, flags);
return -EIO;
}
@@ -797,7 +797,7 @@ static int vnt_beacon_xmit(struct vnt_private *priv, struct 
sk_buff *skb)
 
spin_lock_irqsave(>lock, flags);
 
-   if (vnt_tx_context(priv, context) != STATUS_PENDING)
+   if (vnt_tx_context(priv, context))
ieee80211_free_txskb(priv->hw, context->skb);
 
spin_unlock_irqrestore(>lock, flags);
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 7bfccc48a366..e93c2175543f 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -317,7 +317,7 @@ int vnt_tx_context(struct vnt_private *priv,
 
if (test_bit(DEVICE_FLAGS_DISCONNECTED, >flags)) {
context->in_use = false;
-   return STATUS_RESOURCES;
+   return -ENODEV;
}
 
usb_fill_bulk_urb(urb,
@@ -333,8 +333,7 @@ int vnt_tx_context(struct vnt_private *priv,
dev_dbg(>usb->dev, "Submit Tx URB failed %d\n", status);
 
context->in_use = false;
-   return STATUS_FAILURE;
}
 
-   return STATUS_PENDING;
+   return status;
 }
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Use mac80211 duration for tx headers

2020-02-27 Thread Malcolm Priestley
mac80211 already provides the correct duration simply
copy it to the tx headers removing the need for driver
to find it with vnt_get_duration_le.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 57 +--
 1 file changed, 8 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 74c1062dbaaa..1003808ac4ad 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -13,7 +13,6 @@
  *
  * Functions:
  *  vnt_generate_tx_parameter - Generate tx dma required parameter.
- *  vnt_get_duration_le - get tx data required duration
  *  vnt_get_rtscts_duration_le- get rtx/cts required duration
  *  vnt_get_rtscts_rsvtime_le- get rts/cts reserved time
  *  vnt_get_rsvtime- get frame reserved time
@@ -166,27 +165,6 @@ static __le16 vnt_get_rtscts_rsvtime_le(struct vnt_private 
*priv, u8 rsv_type,
return cpu_to_le16((u16)rrv_time);
 }
 
-static __le16 vnt_get_duration_le(struct vnt_private *priv, u8 pkt_type,
- int need_ack)
-{
-   u32 ack_time = 0;
-
-   if (need_ack) {
-   if (pkt_type == PK_TYPE_11B)
-   ack_time = vnt_get_frame_time(priv->preamble_type,
- pkt_type, 14,
- priv->top_cck_basic_rate);
-   else
-   ack_time = vnt_get_frame_time(priv->preamble_type,
- pkt_type, 14,
- 
priv->top_ofdm_basic_rate);
-
-   return cpu_to_le16((u16)(priv->sifs + ack_time));
-   }
-
-   return 0;
-}
-
 static __le16 vnt_get_rtscts_duration_le(struct vnt_usb_send_context *context,
 u8 dur_type, u8 pkt_type, u16 rate)
 {
@@ -246,7 +224,6 @@ static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context 
*tx_context,
(struct ieee80211_hdr *)tx_context->skb->data;
u32 frame_len = tx_context->frame_len;
u16 rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
 
/* Get SignalField,ServiceField,Length */
vnt_get_phy_field(priv, frame_len, rate, tx_context->pkt_type, >a);
@@ -254,16 +231,8 @@ static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context 
*tx_context,
  PK_TYPE_11B, >b);
 
/* Get Duration and TimeStamp */
-   if (ieee80211_is_nullfunc(hdr->frame_control)) {
-   buf->duration_a = hdr->duration_id;
-   buf->duration_b = hdr->duration_id;
-   } else {
-   buf->duration_a = vnt_get_duration_le(priv,
-   tx_context->pkt_type, need_ack);
-   buf->duration_b = vnt_get_duration_le(priv,
- PK_TYPE_11B, need_ack);
-   }
-
+   buf->duration_a = hdr->duration_id;
+   buf->duration_b = hdr->duration_id;
buf->time_stamp_off_a = vnt_time_stamp_off(priv, rate);
buf->time_stamp_off_b = vnt_time_stamp_off(priv,
   priv->top_cck_basic_rate);
@@ -281,20 +250,13 @@ static u16 vnt_rxtx_datahead_ab(struct 
vnt_usb_send_context *tx_context,
(struct ieee80211_hdr *)tx_context->skb->data;
u32 frame_len = tx_context->frame_len;
u16 rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
 
/* Get SignalField,ServiceField,Length */
vnt_get_phy_field(priv, frame_len, rate,
  tx_context->pkt_type, >ab);
 
/* Get Duration and TimeStampOff */
-   if (ieee80211_is_nullfunc(hdr->frame_control)) {
-   buf->duration = hdr->duration_id;
-   } else {
-   buf->duration = vnt_get_duration_le(priv, tx_context->pkt_type,
-   need_ack);
-   }
-
+   buf->duration = hdr->duration_id;
buf->time_stamp_off = vnt_time_stamp_off(priv, rate);
 
tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, >hdr);
@@ -721,8 +683,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
memcpy(tx_context->hdr, skb->data, tx_body_size);
 
-   hdr->duration_id = cpu_to_le16(duration_id);
-
if (info->control.hw_key) {
tx_key = info->control.hw_key;
if (tx_key->keylen > 0)
@@ -788,9 +748,7 @@ static int vnt_beacon_xmit(struct vnt_private *priv, struct 
sk_buff *skb)
vnt_get_phy_field(priv, frame_size, current_rate,

Re: [PATCH 1/2] staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi.

2020-02-04 Thread Malcolm Priestley
On 03/02/2020 09:42, Dan Carpenter wrote:
> On Sun, Feb 02, 2020 at 12:27:25PM +0000, Malcolm Priestley wrote:
>> bb_pre_ed_rssi is an u8 rx_dm always returns negative signed
>> values add minus operator to always yield positive.
>>
>> fixes issue where rx sensitivity is always set to maximum because
>> the unsigned numbers were always greater then 100.
>>
>> Cc: stable 
>> ---
...

>>  drivers/staging/vt6656/dpc.c | 2 +-
> 
> It appears that the vt6655 driver has the same issue.

In the vt6655 it is not used.

Regards


Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/2] staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi.

2020-02-04 Thread Malcolm Priestley
bb_pre_ed_rssi is an u8 rx_dm always returns negative signed
values add minus operator to always yield positive.

fixes issue where rx sensitivity is always set to maximum because
the unsigned numbers were always greater then 100.

Fixes: 63b9907f58f1 ("staging: vt6656: mac80211 conversion: create rx 
function.")
Cc: stable 
Signed-off-by: Malcolm Priestley 
---
Added fixes tag

 drivers/staging/vt6656/dpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 821aae8ca402..a0b60e7d1086 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -98,7 +98,7 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
 
vnt_rf_rssi_to_dbm(priv, tail->rssi, _dbm);
 
-   priv->bb_pre_ed_rssi = (u8)rx_dbm + 1;
+   priv->bb_pre_ed_rssi = (u8)-rx_dbm + 1;
priv->current_rssi = priv->bb_pre_ed_rssi;
 
skb_pull(skb, sizeof(*head));
-- 
2.25.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: vt6656: Remove fall back functions and headers.

2020-02-02 Thread Malcolm Priestley
Fall back is no longer used in driver so remove all
functions and headers.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h |   1 -
 drivers/staging/vt6656/rxtx.c   | 206 
 drivers/staging/vt6656/rxtx.h   |  60 --
 3 files changed, 267 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index fe6c11266123..da868adba7c9 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -244,7 +244,6 @@ struct vnt_usb_send_context {
u8 pkt_no;
u8 pkt_type;
u8 need_ack;
-   u8 fb_option;
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 0fabeb396563..74c1062dbaaa 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -39,30 +39,12 @@ static const u16 vnt_time_stampoff[2][MAX_RATE] = {
{384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23},
 };
 
-static const u16 vnt_fb_opt0[2][5] = {
-   {RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, /* fallback_rate0 */
-   {RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, /* fallback_rate1 */
-};
-
-static const u16 vnt_fb_opt1[2][5] = {
-   {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, /* fallback_rate0 */
-   {RATE_6M,  RATE_6M,  RATE_12M, RATE_12M, RATE_18M}, /* fallback_rate1 */
-};
-
 #define RTSDUR_BB   0
 #define RTSDUR_BA   1
 #define RTSDUR_AA   2
 #define CTSDUR_BA   3
-#define RTSDUR_BA_F04
-#define RTSDUR_AA_F05
-#define RTSDUR_BA_F16
-#define RTSDUR_AA_F17
-#define CTSDUR_BA_F08
-#define CTSDUR_BA_F19
 #define DATADUR_B   10
 #define DATADUR_A   11
-#define DATADUR_A_F012
-#define DATADUR_A_F113
 
 static struct vnt_usb_send_context
*vnt_get_free_context(struct vnt_private *priv)
@@ -216,8 +198,6 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
switch (dur_type) {
case RTSDUR_BB:
case RTSDUR_BA:
-   case RTSDUR_BA_F0:
-   case RTSDUR_BA_F1:
cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
  14, priv->top_cck_basic_rate);
dur_time = cts_time + 2 * priv->sifs +
@@ -226,8 +206,6 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
break;
 
case RTSDUR_AA:
-   case RTSDUR_AA_F0:
-   case RTSDUR_AA_F1:
cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
  14, priv->top_ofdm_basic_rate);
dur_time = cts_time + 2 * priv->sifs +
@@ -236,8 +214,6 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
break;
 
case CTSDUR_BA:
-   case CTSDUR_BA_F0:
-   case CTSDUR_BA_F1:
dur_time = priv->sifs + vnt_get_rsvtime(priv,
pkt_type, frame_length, rate, need_ack);
break;
@@ -297,63 +273,6 @@ static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context 
*tx_context,
return le16_to_cpu(buf->duration_a);
 }
 
-static u16 vnt_rxtx_datahead_g_fb(struct vnt_usb_send_context *tx_context,
- struct vnt_tx_datahead_g_fb *buf)
-{
-   struct vnt_private *priv = tx_context->priv;
-   u32 frame_len = tx_context->frame_len;
-   u16 rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
-
-   /* Get SignalField,ServiceField,Length */
-   vnt_get_phy_field(priv, frame_len, rate, tx_context->pkt_type, >a);
-
-   vnt_get_phy_field(priv, frame_len, priv->top_cck_basic_rate,
- PK_TYPE_11B, >b);
-
-   /* Get Duration and TimeStamp */
-   buf->duration_a = vnt_get_duration_le(priv, tx_context->pkt_type,
- need_ack);
-   buf->duration_b = vnt_get_duration_le(priv, PK_TYPE_11B, need_ack);
-
-   buf->duration_a_f0 = vnt_get_duration_le(priv, tx_context->pkt_type,
-need_ack);
-   buf->duration_a_f1 = vnt_get_duration_le(priv, tx_context->pkt_type,
-need_ack);
-
-   buf->time_stamp_off_a = vnt_time_stamp_off(priv, rate);
-   buf->time_stamp_off_b = vnt_time_stamp_off(priv,
-  priv->top_cck_basic_rate);
-
-   tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, >hdr);
-
-   return le16_to_cpu(buf->duration_a);
-}
-
-static u16 vnt_rxtx_datahead_a_fb(struct vnt_usb_send_context *tx_context,
- struct vnt_tx_datahead_a_fb *buf)
-{
-   struct vnt_privat

[PATCH 1/2] staging: vt6656: Disable and remove fall back rates from driver.

2020-02-02 Thread Malcolm Priestley
The fall back rates are not properly implemented in driver and
form part of the legacy driver.

mac80211 has no indication that this is happening and it
does appear the driver does function considerably better
without them so remove them.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/int.c  | 38 ---
 drivers/staging/vt6656/main_usb.c |  4 
 drivers/staging/vt6656/rxtx.c | 29 +--
 3 files changed, 1 insertion(+), 70 deletions(-)

diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index af215860be4c..3fa61c368464 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -23,22 +23,6 @@
 #include "power.h"
 #include "usbpipe.h"
 
-static const u8 fallback_rate0[5][5] = {
-   {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
-   {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
-   {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M},
-   {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M},
-   {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M}
-};
-
-static const u8 fallback_rate1[5][5] = {
-   {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M},
-   {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M},
-   {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M},
-   {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M},
-   {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
-};
-
 int vnt_int_start_interrupt(struct vnt_private *priv)
 {
int ret = 0;
@@ -59,7 +43,6 @@ static int vnt_int_report_rate(struct vnt_private *priv, u8 
pkt_no, u8 tsr)
 {
struct vnt_usb_send_context *context;
struct ieee80211_tx_info *info;
-   struct ieee80211_rate *rate;
u8 tx_retry = (tsr & 0xf0) >> 4;
s8 idx;
 
@@ -74,27 +57,6 @@ static int vnt_int_report_rate(struct vnt_private *priv, u8 
pkt_no, u8 tsr)
info = IEEE80211_SKB_CB(context->skb);
idx = info->control.rates[0].idx;
 
-   if (context->fb_option && !(tsr & (TSR_TMO | TSR_RETRYTMO))) {
-   u8 tx_rate;
-   u8 retry = tx_retry;
-
-   rate = ieee80211_get_tx_rate(priv->hw, info);
-   tx_rate = rate->hw_value - RATE_18M;
-
-   if (retry > 4)
-   retry = 4;
-
-   if (context->fb_option == AUTO_FB_0)
-   tx_rate = fallback_rate0[tx_rate][retry];
-   else if (context->fb_option == AUTO_FB_1)
-   tx_rate = fallback_rate1[tx_rate][retry];
-
-   if (info->band == NL80211_BAND_5GHZ)
-   idx = tx_rate - RATE_6M;
-   else
-   idx = tx_rate;
-   }
-
ieee80211_tx_info_clear_status(info);
 
info->status.rates[0].count = tx_retry;
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 6e5963adb501..9135aad0863d 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -99,7 +99,6 @@ static void vnt_set_options(struct vnt_private *priv)
priv->op_mode = NL80211_IFTYPE_UNSPECIFIED;
priv->bb_type = BBP_TYPE_DEF;
priv->packet_type = priv->bb_type;
-   priv->auto_fb_ctrl = AUTO_FB_0;
priv->preamble_type = 0;
priv->exist_sw_net_addr = false;
 }
@@ -261,9 +260,6 @@ static int vnt_init_registers(struct vnt_private *priv)
if (ret)
goto end;
 
-   /* get Auto Fall Back type */
-   priv->auto_fb_ctrl = AUTO_FB_0;
-
/* default Auto Mode */
priv->bb_type = BB_TYPE_11G;
 
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 29caba728906..0fabeb396563 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -792,7 +792,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
struct vnt_usb_send_context *tx_context;
unsigned long flags;
u16 tx_bytes, tx_header_size, tx_body_size, current_rate, duration_id;
-   u8 pkt_type, fb_option = AUTO_FB_NONE;
+   u8 pkt_type;
bool need_rts = false;
bool need_mic = false;
 
@@ -912,33 +912,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff 
*skb)
 
tx_buffer_head->current_rate = cpu_to_le16(current_rate);
 
-   /* legacy rates TODO use ieee80211_tx_rate */
-   if (current_rate >= RATE_18M && ieee80211_is_data(hdr->frame_control)) {
-   if (priv->auto_fb_ctrl == AUTO_FB_0) {
-   tx_buffer_head->fifo_ctl |=
-   cpu_to_le16(FIFOCTL_AUTO_FB_0);
-
-   priv->tx_rate_fb0 =
-   vnt_fb_opt0[FB_RATE0][current_rate - RATE_18M];
-   priv->tx_rate_fb1 =
-  

[PATCH 2/2] staging: vt6656: Fix return for unsupported cipher modes.

2020-02-02 Thread Malcolm Priestley
mac80211 expect to see -EOPNOTSUPP on unsupported ciphers so
these can be done on stack.

correct all the returns to do this.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/key.c  | 5 -
 drivers/staging/vt6656/main_usb.c | 4 +---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index dcd933a6b66e..41b73f9670e2 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -144,11 +144,14 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
break;
case WLAN_CIPHER_SUITE_CCMP:
if (priv->local_id <= MAC_REVISION_A1)
-   return -EINVAL;
+   return -EOPNOTSUPP;
 
key_dec_mode = KEY_CTL_CCMP;
 
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
+   break;
+   default:
+   return -EOPNOTSUPP;
}
 
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 5e48b3ddb94c..6e5963adb501 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -862,9 +862,7 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
 
switch (cmd) {
case SET_KEY:
-   if (vnt_set_keys(hw, sta, vif, key))
-   return -EOPNOTSUPP;
-   break;
+   return vnt_set_keys(hw, sta, vif, key);
case DISABLE_KEY:
if (test_bit(key->hw_key_idx, >key_entry_inuse))
clear_bit(key->hw_key_idx, >key_entry_inuse);
-- 
2.25.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi.

2020-02-02 Thread Malcolm Priestley
bb_pre_ed_rssi is an u8 rx_dm always returns negative signed
values add minus operator to always yield positive.

fixes issue where rx sensitivity is always set to maximum because
the unsigned numbers were always greater then 100.

Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/dpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 821aae8ca402..a0b60e7d1086 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -98,7 +98,7 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
 
vnt_rf_rssi_to_dbm(priv, tail->rssi, _dbm);
 
-   priv->bb_pre_ed_rssi = (u8)rx_dbm + 1;
+   priv->bb_pre_ed_rssi = (u8)-rx_dbm + 1;
priv->current_rssi = priv->bb_pre_ed_rssi;
 
skb_pull(skb, sizeof(*head));
-- 
2.25.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging: vt6656: Just check NEWRSR_DECRYPTOK for RX_FLAG_DECRYPTED.

2020-01-19 Thread Malcolm Priestley
At present the driver does a number of checks for RX_FLAG_DECRYPTED.

Remove all these and just pass check NEWRSR_DECRYPTOK mac80211
will handle the processing of the sk_buff and dispose of it.

This means that mac80211 can do unsupported encryption modes
on stack.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/dpc.c | 18 ++
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 981de5687341..821aae8ca402 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -30,10 +30,8 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
struct ieee80211_supported_band *sband;
struct sk_buff *skb;
struct ieee80211_rx_status *rx_status;
-   struct ieee80211_hdr *hdr;
struct vnt_rx_header *head;
struct vnt_rx_tail *tail;
-   __le16 fc;
u32 frame_size;
int ii;
u16 rx_bitrate, pay_load_with_padding;
@@ -115,22 +113,10 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
if (!(tail->rsr & RSR_CRCOK))
rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
 
-   hdr = (struct ieee80211_hdr *)(skb->data);
-   fc = hdr->frame_control;
-
rx_status->rate_idx = rate_idx;
 
-   if (ieee80211_has_protected(fc)) {
-   if (priv->local_id > REV_ID_VT3253_A1) {
-   rx_status->flag |= RX_FLAG_DECRYPTED;
-
-   /* Drop packet */
-   if (!(tail->new_rsr & NEWRSR_DECRYPTOK)) {
-   dev_kfree_skb(skb);
-   return true;
-   }
-   }
-   }
+   if (tail->new_rsr & NEWRSR_DECRYPTOK)
+   rx_status->flag |= RX_FLAG_DECRYPTED;
 
ieee80211_rx_irqsafe(priv->hw, skb);
 
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/5] staging: vt6656: Remove memory buffer from vnt_download_firmware.

2020-01-19 Thread Malcolm Priestley
The memory buffer is being done twice here as vnt_control_out passes
it straight to kmemdup.

Remove buffer and add const to the variable in vnt_control_out to pass
the pointer to it.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/firmware.c | 14 ++
 drivers/staging/vt6656/usbpipe.c  |  2 +-
 drivers/staging/vt6656/usbpipe.h  |  2 +-
 3 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vt6656/firmware.c 
b/drivers/staging/vt6656/firmware.c
index 60a00af250bf..70358d427211 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -30,7 +30,6 @@ int vnt_download_firmware(struct vnt_private *priv)
 {
struct device *dev = >usb->dev;
const struct firmware *fw;
-   void *buffer = NULL;
u16 length;
int ii;
int ret = 0;
@@ -44,26 +43,17 @@ int vnt_download_firmware(struct vnt_private *priv)
goto end;
}
 
-   buffer = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL);
-   if (!buffer) {
-   ret = -ENOMEM;
-   goto free_fw;
-   }
-
for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) {
length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
-   memcpy(buffer, fw->data + ii, length);
 
ret = vnt_control_out(priv, 0, 0x1200 + ii, 0x, length,
- buffer);
+ fw->data + ii);
if (ret)
-   goto free_buffer;
+   goto free_fw;
 
dev_dbg(dev, "Download firmware...%d %zu\n", ii, fw->size);
}
 
-free_buffer:
-   kfree(buffer);
 free_fw:
release_firmware(fw);
 end:
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index d977d4777e4f..7bfccc48a366 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -34,7 +34,7 @@
 #define USB_CTL_WAIT   500 /* ms */
 
 int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
-   u16 index, u16 length, u8 *buffer)
+   u16 index, u16 length, const u8 *buffer)
 {
int ret = 0;
u8 *usb_buffer;
diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h
index b65d9c01a211..4e3341bc3221 100644
--- a/drivers/staging/vt6656/usbpipe.h
+++ b/drivers/staging/vt6656/usbpipe.h
@@ -21,7 +21,7 @@
 #define VNT_REG_BLOCK_SIZE 64
 
 int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
-   u16 index, u16 length, u8 *buffer);
+   u16 index, u16 length, const u8 *buffer);
 int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
   u16 index, u16 length,  u8 *buffer);
 
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/5] staging: vt6656: Use vnt_rx_tail struct for tail variables.

2020-01-19 Thread Malcolm Priestley
Place tsf_time, sq, new_rsr, rssi, rsr and sq3 packed in the structure.

Unused variables are removed along with skb_data and structure is
placed beyond vnt_rx_header + pay_load_with_padding on skb->data.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h |  9 +
 drivers/staging/vt6656/dpc.c| 33 -
 2 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 84d170420c8a..fe6c11266123 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -213,6 +213,15 @@ struct vnt_rx_header {
u16 pay_load_len;
 } __packed;
 
+struct vnt_rx_tail {
+   __le64 tsf_time;
+   u8 sq;
+   u8 new_rsr;
+   u8 rssi;
+   u8 rsr;
+   u8 sq_3;
+} __packed;
+
 /* RCB (Receive Control Block) */
 struct vnt_rcb {
void *priv;
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 8fbb911144c6..981de5687341 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -32,13 +32,10 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
struct ieee80211_rx_status *rx_status;
struct ieee80211_hdr *hdr;
struct vnt_rx_header *head;
+   struct vnt_rx_tail *tail;
__le16 fc;
-   u8 *rsr, *new_rsr, *rssi;
-   __le64 *tsf_time;
u32 frame_size;
int ii;
-   u8 *sq, *sq_3;
-   u8 *skb_data;
u16 rx_bitrate, pay_load_with_padding;
u8 rate_idx = 0;
long rx_dbm;
@@ -62,8 +59,6 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
return false;
}
 
-   skb_data = (u8 *)skb->data;
-
/* real Frame Size = USBframe_size -4WbkStatus - 4RxStatus */
/* -8TSF - 4RSR - 4SQ3 - ?Padding */
 
@@ -96,26 +91,14 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
pay_load_with_padding = ((head->pay_load_len / 4) +
((head->pay_load_len % 4) ? 1 : 0)) * 4;
 
-   tsf_time = (__le64 *)(skb_data + 8 + pay_load_with_padding);
-
-   priv->tsf_time = le64_to_cpu(*tsf_time);
-
-   if (priv->bb_type == BB_TYPE_11G) {
-   sq_3 = skb_data + 8 + pay_load_with_padding + 12;
-   sq = sq_3;
-   } else {
-   sq = skb_data + 8 + pay_load_with_padding + 8;
-   sq_3 = sq;
-   }
-
-   new_rsr = skb_data + 8 + pay_load_with_padding + 9;
-   rssi = skb_data + 8 + pay_load_with_padding + 10;
+   tail = (struct vnt_rx_tail *)(skb->data +
+ sizeof(*head) + pay_load_with_padding);
+   priv->tsf_time = le64_to_cpu(tail->tsf_time);
 
-   rsr = skb_data + 8 + pay_load_with_padding + 11;
-   if (*rsr & (RSR_IVLDTYP | RSR_IVLDLEN))
+   if (tail->rsr & (RSR_IVLDTYP | RSR_IVLDLEN))
return false;
 
-   vnt_rf_rssi_to_dbm(priv, *rssi, _dbm);
+   vnt_rf_rssi_to_dbm(priv, tail->rssi, _dbm);
 
priv->bb_pre_ed_rssi = (u8)rx_dbm + 1;
priv->current_rssi = priv->bb_pre_ed_rssi;
@@ -129,7 +112,7 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
rx_status->flag = 0;
rx_status->freq = hw->conf.chandef.chan->center_freq;
 
-   if (!(*rsr & RSR_CRCOK))
+   if (!(tail->rsr & RSR_CRCOK))
rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
 
hdr = (struct ieee80211_hdr *)(skb->data);
@@ -142,7 +125,7 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
rx_status->flag |= RX_FLAG_DECRYPTED;
 
/* Drop packet */
-   if (!(*new_rsr & NEWRSR_DECRYPTOK)) {
+   if (!(tail->new_rsr & NEWRSR_DECRYPTOK)) {
dev_kfree_skb(skb);
return true;
}
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/5] staging: vt6656: create vnt rx header for sk_buff.

2020-01-19 Thread Malcolm Priestley
vnt_rx_header contains the structure of the original variables
wbk_status, rx_sts, rx_rate and pay_load_len packed.

Replace all the old variables for the ones in this.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h |  7 +++
 drivers/staging/vt6656/dpc.c| 29 -
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 2f6567d92b83..84d170420c8a 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -206,6 +206,13 @@ enum {
CONTEXT_BEACON_PACKET
 };
 
+struct vnt_rx_header {
+   u32 wbk_status;
+   u8 rx_sts;
+   u8 rx_rate;
+   u16 pay_load_len;
+} __packed;
+
 /* RCB (Receive Control Block) */
 struct vnt_rcb {
void *priv;
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index a55e2f6b09e3..8fbb911144c6 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -31,15 +31,14 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
struct sk_buff *skb;
struct ieee80211_rx_status *rx_status;
struct ieee80211_hdr *hdr;
+   struct vnt_rx_header *head;
__le16 fc;
u8 *rsr, *new_rsr, *rssi;
__le64 *tsf_time;
u32 frame_size;
int ii;
u8 *sq, *sq_3;
-   u32 wbk_status;
u8 *skb_data;
-   u16 *pay_load_len;
u16 rx_bitrate, pay_load_with_padding;
u8 rate_idx = 0;
long rx_dbm;
@@ -48,8 +47,8 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
rx_status = IEEE80211_SKB_RXCB(skb);
 
/* [31:16]RcvByteCount ( not include 4-byte Status ) */
-   wbk_status = *((u32 *)(skb->data));
-   frame_size = wbk_status >> 16;
+   head = (struct vnt_rx_header *)skb->data;
+   frame_size = head->wbk_status >> 16;
frame_size += 4;
 
if (bytes_received != frame_size) {
@@ -70,19 +69,17 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
 
/* if SQ3 the range is 24~27, if no SQ3 the range is 20~23 */
 
-   pay_load_len = (u16 *)(skb_data + 6);
-
/*Fix hardware bug => PLCP_Length error */
-   if (((bytes_received - (*pay_load_len)) > 27) ||
-   ((bytes_received - (*pay_load_len)) < 24) ||
-   (bytes_received < (*pay_load_len))) {
+   if (((bytes_received - head->pay_load_len) > 27) ||
+   ((bytes_received - head->pay_load_len) < 24) ||
+   (bytes_received < head->pay_load_len)) {
dev_dbg(>usb->dev, "Wrong PLCP Length %x\n",
-   *pay_load_len);
+   head->pay_load_len);
return false;
}
 
sband = hw->wiphy->bands[hw->conf.chandef.chan->band];
-   rx_bitrate = *(skb_data + 5) * 5; /* rx_rate * 5 */
+   rx_bitrate = head->rx_rate * 5; /* rx_rate * 5 */
 
for (ii = 0; ii < sband->n_bitrates; ii++) {
if (sband->bitrates[ii].bitrate == rx_bitrate) {
@@ -96,8 +93,8 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
return false;
}
 
-   pay_load_with_padding = ((*pay_load_len / 4) +
-   ((*pay_load_len % 4) ? 1 : 0)) * 4;
+   pay_load_with_padding = ((head->pay_load_len / 4) +
+   ((head->pay_load_len % 4) ? 1 : 0)) * 4;
 
tsf_time = (__le64 *)(skb_data + 8 + pay_load_with_padding);
 
@@ -118,15 +115,13 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
if (*rsr & (RSR_IVLDTYP | RSR_IVLDLEN))
return false;
 
-   frame_size = *pay_load_len;
-
vnt_rf_rssi_to_dbm(priv, *rssi, _dbm);
 
priv->bb_pre_ed_rssi = (u8)rx_dbm + 1;
priv->current_rssi = priv->bb_pre_ed_rssi;
 
-   skb_pull(skb, 8);
-   skb_trim(skb, frame_size);
+   skb_pull(skb, sizeof(*head));
+   skb_trim(skb, head->pay_load_len);
 
rx_status->mactime = priv->tsf_time;
rx_status->band = hw->conf.chandef.chan->band;
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/5] staging: vt6656: Simplify RX finding bit rates

2020-01-19 Thread Malcolm Priestley
The bit rate can be found by multiplying the rate value by 5.

Use rx_bitrate to compared to sband bitrates removing the need
to find it by hw_value.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h |  1 -
 drivers/staging/vt6656/dpc.c| 21 ++---
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index e2fabe818b19..2f6567d92b83 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -264,7 +264,6 @@ struct vnt_private {
struct usb_interface *intf;
 
u64 tsf_time;
-   u8 rx_rate;
 
u32 rx_buf_sz;
int mc_list_count;
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 2bcb29b11883..a55e2f6b09e3 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -35,14 +35,13 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
u8 *rsr, *new_rsr, *rssi;
__le64 *tsf_time;
u32 frame_size;
-   int ii, r;
-   u8 *rx_rate, *sq, *sq_3;
+   int ii;
+   u8 *sq, *sq_3;
u32 wbk_status;
u8 *skb_data;
u16 *pay_load_len;
-   u16 pay_load_with_padding;
+   u16 rx_bitrate, pay_load_with_padding;
u8 rate_idx = 0;
-   u8 rate[MAX_RATE] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
long rx_dbm;
 
skb = ptr_rcb->skb;
@@ -66,8 +65,6 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
 
skb_data = (u8 *)skb->data;
 
-   rx_rate = skb_data + 5;
-
/* real Frame Size = USBframe_size -4WbkStatus - 4RxStatus */
/* -8TSF - 4RSR - 4SQ3 - ?Padding */
 
@@ -85,23 +82,17 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
}
 
sband = hw->wiphy->bands[hw->conf.chandef.chan->band];
-
-   for (r = RATE_1M; r < MAX_RATE; r++) {
-   if (*rx_rate == rate[r])
-   break;
-   }
-
-   priv->rx_rate = r;
+   rx_bitrate = *(skb_data + 5) * 5; /* rx_rate * 5 */
 
for (ii = 0; ii < sband->n_bitrates; ii++) {
-   if (sband->bitrates[ii].hw_value == r) {
+   if (sband->bitrates[ii].bitrate == rx_bitrate) {
rate_idx = ii;
break;
}
}
 
if (ii == sband->n_bitrates) {
-   dev_dbg(>usb->dev, "Wrong RxRate %x\n", *rx_rate);
+   dev_dbg(>usb->dev, "Wrong Rx Bit Rate %d\n", rx_bitrate);
return false;
}
 
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/5] staging: vt6656: Fix non zero logical return of, usb_control_msg

2020-01-08 Thread Malcolm Priestley
On 06/01/2020 21:45, Quentin Deslandes wrote:
> On 01/03/20 13:58:08, Dan Carpenter wrote:
>> On Fri, Dec 20, 2019 at 09:14:59PM +, Malcolm Priestley wrote:
>>> Starting with commit 59608cb1de1856
>>> ("staging: vt6656: clean function's error path in usbpipe.c")
>>> the usb control functions have returned errors throughout driver
>>> with only logical variable checking.
>>
>> Use the Fixes tag for this.
>>
>> Fixes: 59608cb1de18 ("staging: vt6656: clean function's error path in 
>> usbpipe.c")
>>
>> 12 digits to the hash.  Add Quentin to the CC list.
>>
>>>
>>> However, usb_control_msg return the amount of bytes transferred
>>> this means that normal operation causes errors.
>>>
>>> Correct the return function so only return zero when transfer
>>> is successful.
>>>
>>> Cc: stable  # v5.3+
>>> Signed-off-by: Malcolm Priestley 
>>> ---
>>>  drivers/staging/vt6656/usbpipe.c | 8 ++--
>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/staging/vt6656/usbpipe.c 
>>> b/drivers/staging/vt6656/usbpipe.c
>>> index d3304df6bd53..488ebd98773d 100644
>>> --- a/drivers/staging/vt6656/usbpipe.c
>>> +++ b/drivers/staging/vt6656/usbpipe.c
>>> @@ -59,7 +59,9 @@ int vnt_control_out(struct vnt_private *priv, u8 request, 
>>> u16 value,
>>>  
>>> kfree(usb_buffer);
>>>  
>>> -   if (ret >= 0 && ret < (int)length)
>>> +   if (ret == (int)length)
>>
>> No need for this cast (no need in the original either).
>>
>>> +   ret = 0;
>>> +   else
>>> ret = -EIO;
>>
>> It would be better to preserve the error codes from usb_control_msg().
>>
>>  if (ret == length)
>>  ret = 0;
>>  else if (ret >= 0)
>>  ret = -EIO;
>>
>> regards,
>> dan carpenter
>>
> 
> Thanks for CC.
> 
> Nice catch. Dan is right, we should forward any error code from
> usb_control_msg().

This is already in linux-next.

So I will do a fix up patch by the end of this cycle.

Regards


Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging: vt6656: Fix false Tx excessive retries reporting.

2020-01-08 Thread Malcolm Priestley
The driver reporting  IEEE80211_TX_STAT_ACK is not being handled
correctly. The driver should only report on TSR_TMO flag is not
set indicating no transmission errors and when not IEEE80211_TX_CTL_NO_ACK
is being requested.

Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/int.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index f40947955675..af215860be4c 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -99,9 +99,11 @@ static int vnt_int_report_rate(struct vnt_private *priv, u8 
pkt_no, u8 tsr)
 
info->status.rates[0].count = tx_retry;
 
-   if (!(tsr & (TSR_TMO | TSR_RETRYTMO))) {
+   if (!(tsr & TSR_TMO)) {
info->status.rates[0].idx = idx;
-   info->flags |= IEEE80211_TX_STAT_ACK;
+
+   if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
+   info->flags |= IEEE80211_TX_STAT_ACK;
}
 
ieee80211_tx_status_irqsafe(priv->hw, context->skb);
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] staging: vt6656: use NULLFUCTION stack on mac80211

2020-01-08 Thread Malcolm Priestley
It appears that the drivers does not go into power save correctly the
NULL data packets are not being transmitted because it not enabled
in mac80211.

The driver needs to capture ieee80211_is_nullfunc headers and
copy the duration_id to it's own duration data header.

Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c |  1 +
 drivers/staging/vt6656/rxtx.c | 14 +-
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 9cb924c54571..5e48b3ddb94c 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -1015,6 +1015,7 @@ vt6656_probe(struct usb_interface *intf, const struct 
usb_device_id *id)
ieee80211_hw_set(priv->hw, RX_INCLUDES_FCS);
ieee80211_hw_set(priv->hw, REPORTS_TX_ACK_STATUS);
ieee80211_hw_set(priv->hw, SUPPORTS_PS);
+   ieee80211_hw_set(priv->hw, PS_NULLFUNC_STACK);
 
priv->hw->max_signal = 100;
 
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 39b557511b24..29caba728906 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -278,11 +278,9 @@ static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context 
*tx_context,
  PK_TYPE_11B, >b);
 
/* Get Duration and TimeStamp */
-   if (ieee80211_is_pspoll(hdr->frame_control)) {
-   __le16 dur = cpu_to_le16(priv->current_aid | BIT(14) | BIT(15));
-
-   buf->duration_a = dur;
-   buf->duration_b = dur;
+   if (ieee80211_is_nullfunc(hdr->frame_control)) {
+   buf->duration_a = hdr->duration_id;
+   buf->duration_b = hdr->duration_id;
} else {
buf->duration_a = vnt_get_duration_le(priv,
tx_context->pkt_type, need_ack);
@@ -371,10 +369,8 @@ static u16 vnt_rxtx_datahead_ab(struct 
vnt_usb_send_context *tx_context,
  tx_context->pkt_type, >ab);
 
/* Get Duration and TimeStampOff */
-   if (ieee80211_is_pspoll(hdr->frame_control)) {
-   __le16 dur = cpu_to_le16(priv->current_aid | BIT(14) | BIT(15));
-
-   buf->duration = dur;
+   if (ieee80211_is_nullfunc(hdr->frame_control)) {
+   buf->duration = hdr->duration_id;
} else {
buf->duration = vnt_get_duration_le(priv, tx_context->pkt_type,
need_ack);
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging: vt6656: Move ieee80211_rx_status off stack.

2020-01-08 Thread Malcolm Priestley


ieee80211_rx_status off stack to IEEE80211_SKB_RXCB (skb->cb)
removing the need to copy on to it.

skb->cb is always present as a clean buffer so simply fill
it in.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/dpc.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 3b94e80f1d5e..2bcb29b11883 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -29,7 +29,7 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
struct ieee80211_hw *hw = priv->hw;
struct ieee80211_supported_band *sband;
struct sk_buff *skb;
-   struct ieee80211_rx_status rx_status = { 0 };
+   struct ieee80211_rx_status *rx_status;
struct ieee80211_hdr *hdr;
__le16 fc;
u8 *rsr, *new_rsr, *rssi;
@@ -46,6 +46,7 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
long rx_dbm;
 
skb = ptr_rcb->skb;
+   rx_status = IEEE80211_SKB_RXCB(skb);
 
/* [31:16]RcvByteCount ( not include 4-byte Status ) */
wbk_status = *((u32 *)(skb->data));
@@ -136,23 +137,23 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
skb_pull(skb, 8);
skb_trim(skb, frame_size);
 
-   rx_status.mactime = priv->tsf_time;
-   rx_status.band = hw->conf.chandef.chan->band;
-   rx_status.signal = rx_dbm;
-   rx_status.flag = 0;
-   rx_status.freq = hw->conf.chandef.chan->center_freq;
+   rx_status->mactime = priv->tsf_time;
+   rx_status->band = hw->conf.chandef.chan->band;
+   rx_status->signal = rx_dbm;
+   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;
+   rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
 
hdr = (struct ieee80211_hdr *)(skb->data);
fc = hdr->frame_control;
 
-   rx_status.rate_idx = rate_idx;
+   rx_status->rate_idx = rate_idx;
 
if (ieee80211_has_protected(fc)) {
if (priv->local_id > REV_ID_VT3253_A1) {
-   rx_status.flag |= RX_FLAG_DECRYPTED;
+   rx_status->flag |= RX_FLAG_DECRYPTED;
 
/* Drop packet */
if (!(*new_rsr & NEWRSR_DECRYPTOK)) {
@@ -162,8 +163,6 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb 
*ptr_rcb,
}
}
 
-   memcpy(IEEE80211_SKB_RXCB(skb), _status, sizeof(rx_status));
-
ieee80211_rx_irqsafe(priv->hw, skb);
 
return true;
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] staging: vt6656: correct packet types for CTS protect, mode.

2020-01-08 Thread Malcolm Priestley


It appears that the driver still transmits in CTS protect mode even
though it is not enabled in mac80211.

That is both packet types PK_TYPE_11GA and PK_TYPE_11GB both use CTS protect.
The only difference between them GA does not use B rates.

Find if only B rate in GB or GA in protect mode otherwise transmit packets
as PK_TYPE_11A.

Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h |  2 ++
 drivers/staging/vt6656/rxtx.c   | 12 
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 50e1c8918040..e2fabe818b19 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -52,6 +52,8 @@
 #define RATE_AUTO  12
 
 #define MAX_RATE   12
+#define VNT_B_RATES(BIT(RATE_1M) | BIT(RATE_2M) |\
+   BIT(RATE_5M) | BIT(RATE_11M))
 
 /*
  * device specific
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index f9020a4f7bbf..39b557511b24 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -815,10 +815,14 @@ int vnt_tx_packet(struct vnt_private *priv, struct 
sk_buff *skb)
if (info->band == NL80211_BAND_5GHZ) {
pkt_type = PK_TYPE_11A;
} else {
-   if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
-   pkt_type = PK_TYPE_11GB;
-   else
-   pkt_type = PK_TYPE_11GA;
+   if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
+   if (priv->basic_rates & VNT_B_RATES)
+   pkt_type = PK_TYPE_11GB;
+   else
+   pkt_type = PK_TYPE_11GA;
+   } else {
+   pkt_type = PK_TYPE_11A;
+   }
}
} else {
pkt_type = PK_TYPE_11B;
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/5] staging: vt6656: set usb_set_intfdata on driver fail.

2019-12-20 Thread Malcolm Priestley
intfdata will contain stale pointer when the device is detached after
failed initialization when referenced in vt6656_disconnect

Provide driver access to it here and NULL it.

Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h   | 1 +
 drivers/staging/vt6656/main_usb.c | 1 +
 drivers/staging/vt6656/wcmd.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 6074ceda78bf..50e1c8918040 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -259,6 +259,7 @@ struct vnt_private {
u8 mac_hw;
/* netdev */
struct usb_device *usb;
+   struct usb_interface *intf;
 
u64 tsf_time;
u8 rx_rate;
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 4a5d741f94f5..9cb924c54571 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -992,6 +992,7 @@ vt6656_probe(struct usb_interface *intf, const struct 
usb_device_id *id)
priv = hw->priv;
priv->hw = hw;
priv->usb = udev;
+   priv->intf = intf;
 
vnt_set_options(priv);
 
diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index 3eb2f11a5de1..2c5250ca2801 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -99,6 +99,7 @@ void vnt_run_command(struct work_struct *work)
if (vnt_init(priv)) {
/* If fail all ends TODO retry */
dev_err(>usb->dev, "failed to start\n");
+   usb_set_intfdata(priv->intf, NULL);
ieee80211_free_hw(priv->hw);
return;
}
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging: vt6656: remove bool from vnt_radio_power_on ret

2019-12-20 Thread Malcolm Priestley
The driver uses logical only error checking a bool true would flag error.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 56cd77fd9ea0..7958fc165462 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -719,7 +719,7 @@ int vnt_radio_power_off(struct vnt_private *priv)
  */
 int vnt_radio_power_on(struct vnt_private *priv)
 {
-   int ret = true;
+   int ret = 0;
 
vnt_exit_deep_sleep(priv);
 
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/5] staging: vt6656: limit reg output to block size

2019-12-20 Thread Malcolm Priestley
vnt_control_out appears to fail when BBREG is greater than 64 writes.

Create new function that will relay an array in no larger than
the indicated block size.

It appears that this command has always failed but was ignored by
driver until the introduction of error checking.

Cc: stable  # v5.3+
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/baseband.c |  4 ++--
 drivers/staging/vt6656/usbpipe.c  | 17 +
 drivers/staging/vt6656/usbpipe.h  |  5 +
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index 8d19ae71e7cc..4e651b698617 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -449,8 +449,8 @@ int vnt_vt3184_init(struct vnt_private *priv)
 
memcpy(array, addr, length);
 
-   ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
- MESSAGE_REQUEST_BBREG, length, array);
+   ret = vnt_control_out_blocks(priv, VNT_REG_BLOCK_SIZE,
+MESSAGE_REQUEST_BBREG, length, array);
if (ret)
goto end;
 
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 488ebd98773d..d977d4777e4f 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -76,6 +76,23 @@ int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 
reg_off, u8 data)
   reg_off, reg, sizeof(u8), );
 }
 
+int vnt_control_out_blocks(struct vnt_private *priv,
+  u16 block, u8 reg, u16 length, u8 *data)
+{
+   int ret = 0, i;
+
+   for (i = 0; i < length; i += block) {
+   u16 len = min_t(int, length - i, block);
+
+   ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE,
+ i, reg, len, data + i);
+   if (ret)
+   goto end;
+   }
+end:
+   return ret;
+}
+
 int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
   u16 index, u16 length, u8 *buffer)
 {
diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h
index 95147ec7b96a..b65d9c01a211 100644
--- a/drivers/staging/vt6656/usbpipe.h
+++ b/drivers/staging/vt6656/usbpipe.h
@@ -18,6 +18,8 @@
 
 #include "device.h"
 
+#define VNT_REG_BLOCK_SIZE 64
+
 int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
u16 index, u16 length, u8 *buffer);
 int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
@@ -26,6 +28,9 @@ int vnt_control_in(struct vnt_private *priv, u8 request, u16 
value,
 int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 ref_off, u8 data);
 int vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data);
 
+int vnt_control_out_blocks(struct vnt_private *priv,
+  u16 block, u8 reg, u16 len, u8 *data);
+
 int vnt_start_interrupt_urb(struct vnt_private *priv);
 int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb);
 int vnt_tx_context(struct vnt_private *priv,
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/5] staging: vt6656: correct return of vnt_init_registers.

2019-12-20 Thread Malcolm Priestley
The driver standard error returns remove bool false conditions.

Cc: stable  # v5.3+
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 4ac85ecb0921..4a5d741f94f5 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -949,7 +949,7 @@ static const struct ieee80211_ops vnt_mac_ops = {
 
 int vnt_init(struct vnt_private *priv)
 {
-   if (!(vnt_init_registers(priv)))
+   if (vnt_init_registers(priv))
return -EAGAIN;
 
SET_IEEE80211_PERM_ADDR(priv->hw, priv->permanent_net_addr);
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/5] staging: vt6656: Fix non zero logical return of, usb_control_msg

2019-12-20 Thread Malcolm Priestley
Starting with commit 59608cb1de1856
("staging: vt6656: clean function's error path in usbpipe.c")
the usb control functions have returned errors throughout driver
with only logical variable checking.

However, usb_control_msg return the amount of bytes transferred
this means that normal operation causes errors.

Correct the return function so only return zero when transfer
is successful.

Cc: stable  # v5.3+
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/usbpipe.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index d3304df6bd53..488ebd98773d 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -59,7 +59,9 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 
value,
 
kfree(usb_buffer);
 
-   if (ret >= 0 && ret < (int)length)
+   if (ret == (int)length)
+   ret = 0;
+   else
ret = -EIO;
 
 end_unlock:
@@ -103,7 +105,9 @@ int vnt_control_in(struct vnt_private *priv, u8 request, 
u16 value,
 
kfree(usb_buffer);
 
-   if (ret >= 0 && ret < (int)length)
+   if (ret == (int)length)
+   ret = 0;
+   else
ret = -EIO;
 
 end_unlock:
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6655: Remove vif check from vnt_interrupt

2019-03-27 Thread Malcolm Priestley
A check for vif is made in vnt_interrupt_work.

There is a small chance of leaving interrupt disabled while vif
is NULL and the work hasn't been scheduled.

Signed-off-by: Malcolm Priestley 
CC: sta...@vger.kernel.org # v4.2+
---
 drivers/staging/vt6655/device_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index 83f1a1cf9182..c6bb4aaf9bd0 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1137,8 +1137,7 @@ static irqreturn_t vnt_interrupt(int irq,  void *arg)
 {
struct vnt_private *priv = arg;
 
-   if (priv->vif)
-   schedule_work(>interrupt_work);
+   schedule_work(>interrupt_work);
 
MACvIntDisable(priv->PortOffset);
 
-- 
2.20.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   >