[PATCH] staging:r8188eu: avoid skb_clone for amsdu to msdu conversion

2020-04-18 Thread Ivan Safonov
skb clones use same data buffer, so tail of one skb is corrupted by beginning 
of next skb.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index d4278361e002..a036ef104198 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -1525,21 +1525,14 @@ static int amsdu_to_msdu(struct adapter *padapter, 
struct recv_frame *prframe)
 
/* Allocate new skb for releasing to upper layer */
sub_skb = dev_alloc_skb(nSubframe_Length + 12);
-   if (sub_skb) {
-   skb_reserve(sub_skb, 12);
-   skb_put_data(sub_skb, pdata, nSubframe_Length);
-   } else {
-   sub_skb = skb_clone(prframe->pkt, GFP_ATOMIC);
-   if (sub_skb) {
-   sub_skb->data = pdata;
-   sub_skb->len = nSubframe_Length;
-   skb_set_tail_pointer(sub_skb, nSubframe_Length);
-   } else {
-   DBG_88E("skb_clone() Fail!!! , 
nr_subframes=%d\n", nr_subframes);
-   break;
-   }
+   if (!sub_skb) {
+   DBG_88E("dev_alloc_skb() Fail!!! , nr_subframes=%d\n", 
nr_subframes);
+   break;
}
 
+   skb_reserve(sub_skb, 12);
+   skb_put_data(sub_skb, pdata, nSubframe_Length);
+
subframes[nr_subframes++] = sub_skb;
 
if (nr_subframes >= MAX_SUBFRAME_COUNT) {
-- 
2.24.1

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


[PATCH 0/2] staging: vt6656: Check the return value of vnt_control_out_* calls

2020-04-18 Thread Oscar Carter
This patch series checks the return value of vnt_control_out_* function
calls.

The first patch checks the return value and when necessary modify the
function prototype to be able to return the new checked error code.

The second patch replaces the documentation of functions that their
prototype has changed by the kernel-doc style, fixing the parameters and
return value.

Oscar Carter (2):
  staging: vt6656: Check the return value of vnt_control_out_* calls
  staging: vt6656: Fix functions' documentation

 drivers/staging/vt6656/baseband.c |  35 +++---
 drivers/staging/vt6656/baseband.h |   4 +-
 drivers/staging/vt6656/card.c | 198 +++---
 drivers/staging/vt6656/card.h |  18 +--
 drivers/staging/vt6656/mac.c  | 143 ++---
 drivers/staging/vt6656/mac.h  |  26 ++--
 drivers/staging/vt6656/power.c|  24 ++--
 drivers/staging/vt6656/power.h|   2 +-
 8 files changed, 217 insertions(+), 233 deletions(-)

--
2.20.1

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


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

2020-04-18 Thread Oscar Carter
Replace the functions' documentation by the kernel-doc style fixing the
parameters and return value.

Signed-off-by: Oscar Carter 
---
 drivers/staging/vt6656/card.c  | 101 +++--
 drivers/staging/vt6656/mac.c   |  67 --
 drivers/staging/vt6656/power.c |  12 ++--
 3 files changed, 61 insertions(+), 119 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 99ad56b7617d..51acf2212577 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -46,15 +46,12 @@ static const u16 cw_rxbcntsf_off[MAX_RATE] = {
192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3
 };

-/*
- * Description: Set NIC media channel
+/**
+ * vnt_set_channel - Set NIC media channel.
+ * @priv: The adapter to be set.
+ * @connection_channel: The channel to be set.
  *
- * Parameters:
- *  In:
- *  pDevice - The adapter to be set
- *  connection_channel  - Channel to be set
- *  Out:
- *  none
+ * Return: 0 if successful, or a negative error code on failure.
  */
 int vnt_set_channel(struct vnt_private *priv, u32 connection_channel)
 {
@@ -99,19 +96,13 @@ static const u8 vnt_rspinf_gb_table[] = {
0x0e, 0x8d, 0x0a, 0x88, 0x0a, 0x8c, 0x0a, 0x8c, 0x0a
 };

-/*
- * Description: Set RSPINF
- *
- * Parameters:
- *  In:
- *  pDevice - The adapter to be set
- *  Out:
- *  none
- *
- * Return Value: None.
+/**
+ * vnt_set_rspinf - Set RSPINF.
+ * @priv: The adapter to be set.
+ * @bb_type: The base band type.
  *
+ * Return: 0 if successful, or a negative error code on failure.
  */
-
 int vnt_set_rspinf(struct vnt_private *priv, u8 bb_type)
 {
const u8 *data;
@@ -145,17 +136,11 @@ int vnt_set_rspinf(struct vnt_private *priv, u8 bb_type)
   MESSAGE_REQUEST_MACREG, len, data);
 }

-/*
- * Description: Update IFS
- *
- * Parameters:
- *  In:
- * priv - The adapter to be set
- * Out:
- * none
- *
- * Return Value: None.
+/**
+ * vnt_update_ifs - Update IFS.
+ * @priv: The adapter to be set.
  *
+ * Return: 0 if successful, or a negative error code on failure.
  */
 int vnt_update_ifs(struct vnt_private *priv)
 {
@@ -300,20 +285,14 @@ u64 vnt_get_tsf_offset(u8 rx_rate, u64 tsf1, u64 tsf2)
return tsf1 - tsf2 - (u64)cw_rxbcntsf_off[rx_rate % MAX_RATE];
 }

-/*
- * Description: Sync. TSF counter to BSS
- *  Get TSF offset and write to HW
- *
- * Parameters:
- *  In:
- *  priv   - The adapter to be sync.
- *  time_stamp - Rx BCN's TSF
- *  local_tsf  - Local TSF
- *  Out:
- *  none
- *
- * Return Value: none
+/**
+ * vnt_adjust_tsf - Sync TSF counter to BSS. Get TSF offset and write to HW.
+ * @priv: The adapter to be set.
+ * @rx_rate: The Rx rate.
+ * @time_stamp: The Rx BCN's TSF.
+ * @local_tsf: The local TSF.
  *
+ * Return: 0 if successful, or a negative error code on failure.
  */
 int vnt_adjust_tsf(struct vnt_private *priv, u8 rx_rate,
   u64 time_stamp, u64 local_tsf)
@@ -408,19 +387,13 @@ u64 vnt_get_next_tbtt(u64 tsf, u16 beacon_interval)
return tsf;
 }

-/*
- * Description: Set NIC TSF counter for first Beacon time
- *  Get NEXTTBTT from adjusted TSF and Beacon Interval
- *
- * Parameters:
- *  In:
- *  dwIoBase- IO Base
- * beacon_interval - Beacon Interval
- *  Out:
- *  none
- *
- * Return Value: none
+/**
+ * vnt_reset_next_tbtt - Set NIC TSF counter for first beacon time. Get
+ *  NEXTTBTT from adjusted TSF and beacon interval.
+ * @priv: The adapter to be set.
+ * @beacon_interval: The beacon interval.
  *
+ * Return: 0 if successful, or a negative error code on failure.
  */
 int vnt_reset_next_tbtt(struct vnt_private *priv, u16 beacon_interval)
 {
@@ -444,20 +417,14 @@ int vnt_reset_next_tbtt(struct vnt_private *priv, u16 
beacon_interval)
   MESSAGE_REQUEST_TBTT, 0, 8, data);
 }

-/*
- * Description: Sync NIC TSF counter for Beacon time
- *  Get NEXTTBTT and write to HW
- *
- * Parameters:
- *  In:
- * priv- The adapter to be set
- *  tsf- Current TSF counter
- *  beacon_interval - Beacon Interval
- *  Out:
- *  none
- *
- * Return Value: none
+/**
+ * vnt_update_next_tbtt - Sync NIC TSF counter for beacon time. Get NEXTTBTT
+ *   and write to HW.
+ * @priv: The adapter to be set.
+ * @tsf: The current TSF counter.
+ * @beacon_interval: The beacon interval.
  *
+ * Return: 0 if successful, or a negative error code on failure.
  */
 int vnt_update_next_tbtt(struct vnt_private *priv, u64 tsf,
 u16 beacon_interval)
diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c
index 639172fad0f3..c4b541178109 100644
--- a/drivers/staging/vt6656/mac.c
+++ b/drivers/staging/vt6656/mac.c
@@ -22,18 +22,12 @@
 #include "mac.h"
 #include "usbpipe.h"

-/*
- * Description:
- *  Write

[PATCH 1/2] staging: vt6656: Check the return value of vnt_control_out_* calls

2020-04-18 Thread Oscar Carter
Check the return value of vnt_control_out_* function calls. When
necessary modify the function prototype to be able to return the new
checked error code.

It's safe to modify all the function prototypes without fix the call
because the only change is the return value from void to int. If before
the call didn't check the return value, now neither.

Signed-off-by: Oscar Carter 
---
 drivers/staging/vt6656/baseband.c | 35 ++-
 drivers/staging/vt6656/baseband.h |  4 +-
 drivers/staging/vt6656/card.c | 97 ---
 drivers/staging/vt6656/card.h | 18 +++---
 drivers/staging/vt6656/mac.c  | 76 
 drivers/staging/vt6656/mac.h  | 26 -
 drivers/staging/vt6656/power.c| 12 +++-
 drivers/staging/vt6656/power.h|  2 +-
 8 files changed, 156 insertions(+), 114 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index e0352405e4cf..91cf00615ef3 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -23,6 +23,7 @@
  */

 #include 
+#include 
 #include 
 #include "mac.h"
 #include "baseband.h"
@@ -559,21 +560,22 @@ int vnt_set_short_slot_time(struct vnt_private *priv)

ret = vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga);
if (ret)
-   goto end;
+   return ret;

if (bb_vga == priv->bb_vga[0])
priv->bb_rx_conf |= 0x20;

-   ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a,
-priv->bb_rx_conf);
-
-end:
-   return ret;
+   return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a,
+ priv->bb_rx_conf);
 }

-void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
+int vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
 {
-   vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data);
+   int ret;
+
+   ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data);
+   if (ret)
+   return ret;

/* patch for 3253B0 Baseband with Cardbus module */
if (priv->short_slot_time)
@@ -581,7 +583,8 @@ void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 
data)
else
priv->bb_rx_conf |= 0x20; /* 0010  */

-   vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->bb_rx_conf);
+   return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a,
+ priv->bb_rx_conf);
 }

 /*
@@ -622,12 +625,13 @@ int vnt_exit_deep_sleep(struct vnt_private *priv)
return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);
 }

-void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning)
+int vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning)
 {
const struct vnt_threshold *threshold = NULL;
u8 length;
u8 cr_201, cr_206;
u8 ed_inx = priv->bb_pre_ed_index;
+   int ret;

switch (priv->rf_type) {
case RF_AL2230:
@@ -650,7 +654,7 @@ void vnt_update_pre_ed_threshold(struct vnt_private *priv, 
int scanning)
}

if (!threshold)
-   return;
+   return -EINVAL;

for (ed_inx = scanning ? 0 : length - 1; ed_inx > 0; ed_inx--) {
if (priv->bb_pre_ed_rssi <= threshold[ed_inx].bb_pre_ed_rssi)
@@ -661,14 +665,17 @@ void vnt_update_pre_ed_threshold(struct vnt_private 
*priv, int scanning)
cr_206 = threshold[ed_inx].cr_206;

if (ed_inx == priv->bb_pre_ed_index && !scanning)
-   return;
+   return 0;

priv->bb_pre_ed_index = ed_inx;

dev_dbg(&priv->usb->dev, "%s bb_pre_ed_rssi %d\n",
__func__, priv->bb_pre_ed_rssi);

-   vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201);
-   vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206);
+   ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201);
+   if (ret)
+   return ret;
+
+   return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206);
 }

diff --git a/drivers/staging/vt6656/baseband.h 
b/drivers/staging/vt6656/baseband.h
index dc42aa6ae1d9..8739988bf9e8 100644
--- a/drivers/staging/vt6656/baseband.h
+++ b/drivers/staging/vt6656/baseband.h
@@ -80,11 +80,11 @@ void vnt_get_phy_field(struct vnt_private *priv, u32 
frame_length,
   u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy);

 int vnt_set_short_slot_time(struct vnt_private *priv);
-void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data);
+int vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data);
 int vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode);
 int vnt_vt3184_init(struct vnt_private *priv);
 int vnt_set_deep_sleep(struct vnt_private *priv);
 int vnt_exit_deep_sleep(struct vnt_private *priv);
-void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning);

[PATCH] staging: vt6656: Refactor the vnt_ofdm_min_rate function

2020-04-18 Thread Oscar Carter
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.

This way avoid the iteration over an unnecessary for loop.

Also change the return type to bool because it's the type that this
function returns.

Signed-off-by: Oscar Carter 
---
 drivers/staging/vt6656/card.c | 11 ++-
 drivers/staging/vt6656/card.h |  2 +-
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 9bd37e57c727..adaf93cf653a 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -248,16 +248,9 @@ void vnt_update_top_rates(struct vnt_private *priv)
priv->top_cck_basic_rate = top_cck;
 }

-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;
 }

 u8 vnt_get_pkt_type(struct vnt_private *priv)
diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h
index 75cd340c0cce..eaa15d0c291a 100644
--- a/drivers/staging/vt6656/card.h
+++ b/drivers/staging/vt6656/card.h
@@ -29,7 +29,7 @@ void vnt_set_channel(struct vnt_private *priv, u32 
connection_channel);
 void vnt_set_rspinf(struct vnt_private *priv, u8 bb_type);
 void vnt_update_ifs(struct vnt_private *priv);
 void vnt_update_top_rates(struct vnt_private *priv);
-int vnt_ofdm_min_rate(struct vnt_private *priv);
+bool vnt_ofdm_min_rate(struct vnt_private *priv);
 void vnt_adjust_tsf(struct vnt_private *priv, u8 rx_rate,
u64 time_stamp, u64 local_tsf);
 bool vnt_get_current_tsf(struct vnt_private *priv, u64 *current_tsf);
--
2.20.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), &rx_mode);
-
-   if (!rc)
-   rx_mode = RCR_MULTICAST | RCR_BROADCAST;
+   vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_RCR,
+  MESSAGE_REQUEST_MACREG, sizeof(u8), &rx_mode);
 
dev_dbg(&priv->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: 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: 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(&priv->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(&priv->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


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


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


[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, &priv->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 = &vif->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, &priv->key_entry_inuse))
+   if (test_bit(key->hw_key_idx, &priv->key_entry_inuse)) {
clear_bit(key->hw_key_idx, &priv->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