staging: vt6656: refactor power save operation
authorMalcolm Priestley <tvboxspy@gmail.com>
Sat, 2 May 2020 11:20:13 +0000 (12:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 May 2020 10:28:00 +0000 (12:28 +0200)
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 <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/5a188bd8-7049-8063-f24d-96768ce9a6ed@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6656/device.h
drivers/staging/vt6656/main_usb.c
drivers/staging/vt6656/power.c
drivers/staging/vt6656/usbpipe.c

index 4d596853a3eeae7695f813e8938ebf6a1e57a989..d19d802b5d4f8edfe532c38529e78055943f5f47 100644 (file)
@@ -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;
 
index 7db1e044ad2667248af3bc25278dddf88c32b5c5..b5790d4d71521e83592b5a8fa014e34baf7bdc5e 100644 (file)
@@ -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);
 
index d160a07739435b79a9552f31d02d6f619bf9b41f..2f49c870272ae3272716930ddaa101312b341e08 100644 (file)
@@ -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(&priv->usb->dev,  "PS:Power Saving Mode Enable...\n");
 }
index e8efdeadb1a76d6b48926f13a20f7f937709881e..5603f3cbb33c749944db09da0ebddcdb4ec7bfd6 100644 (file)
@@ -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 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;