Wi-Fi Power Saving

Introduction

The Wi-Fi STA power-saving modes defined in the IEEE 802.11 specification include the following key features:

  • Enter doze state when no data is being sent or received.

  • enter awake state for receiving AP beacon frame

  • Utilizes beacon TIM (Traffic Indication Map) for data management

During the station’s sleep period, it cannot receive any data frames. Therefore, the AP must buffer any pending frames, and the STA must periodically wake up to check for beacon frames.

The Wi-Fi timeline of power-saving mode is illustrated below:

../../_images/wifi_timeline_of_power_saving.svg

Based on the above standard IEEE 802.11 power saving mechanism, the Ameba SoC provides three Wi-Fi power-saving modes:

Mode

Full name

Description

IPS

Inactive Power Save

Implements a complete power-down state when not connected.

LPS

Legacy Power Save

Switches between awake and doze states under Wi-Fi connection, periodically turns the transceiver on or off for power saving.

WoWLAN

Wake on Wireless LAN

Allows the SoC system to enter Sleep Mode while maintaining Wi-Fi connectivity.

The system can be woken up by unicast packets, broadcast/multicast packets (optional), or AP disconnect event.

IPS Mode

The IPS (Inactive Power Save) mode is specifically designed for scenarios where the device is not connected to a Wi-Fi network. It enables the device to enter a sleep state during periods of inactivity, thereby significantly extending battery life.

IPS generally supports two distinct sleep level:

  • Wi-Fi Power Off: In this state, the Wi-Fi module is completely powered down to achieve maximum power savings.

  • Power Gating (PG) Mode: This state utilizes power gating techniques, which allows for a much faster exit from IPS mode upon wakeup.

Programming Interface

Ameba Wi-Fi controls the IPS behavior using the wifi_set_ips_internal() function and a set of related parameters. The IPS control flow is depicted below:

../../_images/ips_flow.svg
RTL8721Dx:

Parameter

Type

Value

Description

Default

ips_enable

u8

0/1

Disable/Enable IPS

1

ips_level

u8

RTW_IPS_WIFI_OFF

Wi-Fi power off in IPS

RTW_IPS_WIFI_OFF

RTW_IPS_WIFI_PG

Wi-Fi power gating in IPS

ips_ctrl_by_usr

u8

0

Enable/Disable IPS via API

0

1

Enter/Exit IPS mode via API

Refer to the table below for the behavior of each combination:

ips_enable

ips_ctrl_by_usr

wifi_set_ips_internal

Behavior

0

0

Y

Dynamically enables/disables IPS.

  • IPS is disabled by default.

0

1

Y

IPS is disabled.

0

X

N

IPS is disabled.

1

0

Y

Dynamically enables/disables IPS.

  • IPS is enabled by default.

1

1

Y

Dynamically enter/exit IPS mode.

  • Calling wifi_set_ips_inetrnal() allows for a quick exit from IPS mode.

1

X

N

IPS is enabled.

  • System enters the configured power-saving level based on periodic Wi-Fi state monitoring.

LPS Mode

The core idea of LPS (Legacy Power Save) mode is to allow a client station (STA) to enter a low-power sleep state while associated with an Access Point (AP) but with no active data traffic. During this sleep period, the AP buffers any incoming downstream data intended for the STA, thus conserving the STA’s power.

An STA operating in LPS mode must periodically wake up to listen for beacon frames broadcast by the AP. By examining the Traffic Indication Map (TIM) element within these beacons, the STA can determine if the AP has buffered data for it. If the TIM indicates that data is pending, the STA will remain awake to communicate with the AP and retrieve the buffered frames. Otherwise, it can return to sleep until the next scheduled wakeup.

../../_images/lps.svg

Parameter

Type

Value

Description

Default

lps_enable

u8

0 / 1

Disable/Enable LPS

1

lps_listen_interval

u8

0

Wakes up at each Target Beacon Transmission Time (TBTT) to receive the beacon frame.

0

> 0

Configure the interval for receiving beacon frames, unit: 102.4ms (TBTT interval)

WoWLAN Mode

Under WoWLAN (Wake on Wireless LAN), the whole SoC enters Low-Power Sleep Mode when the system is idle, while Wi-Fi keeps the established connection alive. WoWLAN is built on top of LPS and reuses exactly the same beacon-listening mechanism as LPS Mode. The difference between the two is:

  • LPS: Only the Wi-Fi RF sleeps during the beacon intervals.

  • WoWLAN: On top of that, the whole SoC is powered off / clock-gated. Most of the Wi-Fi subsystem modules (RF, BB, and part of the MAC) are powered off / clock-gated, and only a small amount of logic keeps running on the 32K clock.

WoWLAN Overall Flow

On a dual-core (AP + NP) architecture, the sleep and wake-up coordination flow of WoWLAN is illustrated below:

../../_images/rtos_ipc_wowlan.svg
  • NP: Runs the Wi-Fi driver, responsible for maintaining the connection, parsing received packets, and deciding whether the AP needs to be woken up.

  • AP: Runs the application and the protocol stack (such as lwIP), handling the business logic.

WoWLAN Entry Flow

  1. The application releases the OS wakelock to enter WoWLAN mode in one of the following two ways:

    • Execute the AT+TICKPS=R command

      AT+TICKPS=TYPE,PG     # Optional, set the sleep type to PG (default) or CG
      AT+TICKPS=R           # Release the OS wakelock, allowing the system to enter sleep
      
    • Call pmu_release_wakelock()

  2. The AP transitions from Active to Idle and passes the wakelock check in the idle task.

  3. The AP sends a tickless IPC message to the NP, and then enters WFE.

  4. After receiving the IPC message, the NP gates the AP’s clock (AP CG) and releases its own wakelock.

  5. After the NP transitions from Active to Idle, it enters sleep. If the sleep type is PG, the PMC also powers off the AP.

  6. Wi-Fi wakes up periodically as configured to receive Beacons, thus maintaining the Wi-Fi connection.

WoWLAN Wake-up Flow

Wi-Fi Wake-up

By default, the SDK configures the Wi-Fi interrupt WIFI_FISR_FESR_IRQ as the wake-up source of the NP. While the system is asleep, the NP resumes after the Wi-Fi RX interrupt is triggered, parses the received packet, and decides whether the AP needs to be woken up:

  • If not needed (for example, the packet can be handled by Wi-Fi itself), the NP goes back to sleep after processing, and the AP stays asleep unaffected.

  • If needed, the NP resumes the AP and the Wi-Fi driver. After the AP resumes, it learns via the IPC interrupt that the wake-up reason is Wi-Fi, and continues to process the business logic.

The reasons that can wake up the AP and the Wi-Fi driver fall into the following categories:

Category

Description

Wi-Fi decides to disconnect

After consecutive Beacon losses, Null Data is sent to probe the AP; consecutive
missing ACKs indicate a disconnection, triggering a wake-up for reconnection.

Link teardown frame

A Deauth / Disassoc frame is received from the AP.

Unicast packet received

A unicast data / management frame is received (TCP, UDP, ICMP, ARP, EAPOL-Key, Action, etc.).

Broadcast/multicast packet received

This category of wake-up can be toggled via the wowlan_rx_bcmc_dis parameter.

AP Wake-up

Wake-up sources such as GPIO and AON Timer can be configured for the AP separately. Refer to Developer Configuration of Low Power for the configuration method. When such an event occurs, the PMC first wakes up the NP, which then restores the AP’s clock.

After wake-up, there is no need to re-initialize the protocol stack. The established TCP/UDP connections and sockets are all preserved, and the application thread can directly send and receive data.