NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

WoWLAN - Linux

From Texas Instruments Wiki
Jump to: navigation, search

Introduction

Wake on Wireless is a feature to allow the system to go into a low-power state while the wireless NIC remains active and does varying things for the host, e.g. staying connected to an AP or searching for networks for more information refer to [1]

This page will discuss how to enable "Suspend Resume" WoW Mode with a WL18xx device and an AM335x host processor. With some extra work, the HW and SW modifications outlined below can also be performed on other host processors to enable WoW,

Mode of Operation

On Suspend state, the WL18xx chip will stay connected to WiFI network and will wait for specific "magic" frame on the WiFi media and only uppon receiving that frame, it will wake up the Host.

Two mode of operation are supported:

  • Suspend state: The chip will be held in shutdown mode, were the host disable the WLAN portion by keeping the WLAN_Enable signal OFF, in that mode the wl18xx consumes minimal current consumption.
  • WOWLAN state: The host is shutting down but the WLAN chip is being kept active (WLAN enable pin remains active). This allows the wl18xx firmware to remain active during suspend and if the system is configured to allow the WLAN interrupt to wakeup the host, it can trigger a system resume when a specific packet is recived by the wl18xx firmware.

Adding "Suspend Resume" WOW mode to AM335x EVM

In order to enable suspend resume in the PSP you will need to add the following:

  1. IRQ line - select GPIO that is capable waking up the host from suspend
  2. WLAN Enable - select GPIO that does not loose context, which upon proper pull up configuration it remains Active (“1”) during suspend mode
  3. SDIO MMC keep power – enable the SDIO to avoid re enumeration after resuming from suspend mode, since the assumption is that the SDIO continue to be in Active mode during Hosts Suspend mode.

EVM - Patch Description

The following hardware mods were done on the am335x-evm for supporting WOWLAN mode:

  • WLAN_IRQ: moved from GPIO3_17 to GPIO0_19 (for waking up SA from suspend on WOWLAN event)
  • WLAN_EN: moved from GPIO1_16 to GPIO3_16 as GPIO1_16 is losing context during suspend
  • Enable MMC_PM_KEEP_POWER for mmc2
  • Activate padmux external pull-up for keeping WLAN_EN pin high when the host is suspending

Suspend/Resume - WOWLAN (Wake on WLAN) mode

Before we enter suspend mode we need to declare which event triggers the wake up. In this example we will set the trigger to any which means any event (console activity, magic frame, etc) will wake up the board:

There are 2 option to resume from Suspend:

  1. Serial console activity or other configured wakeup sources (keypad, touchscreen) will trigger resume
  2. Send Magic frame from other Station to the Station that is in suspend mode


The Procedure will be as followes:

  • Connect station (EVM) to the AP.
  • Enter the EVM to suspend in WOWLAN mode. ( [any] or other pattern, examples below)  
iw phy0 wowlan enable any
  • Enter suspend mode
echo mem > /sys/power/state
  • Send ping to the device --> That ping will cause the first EVM to wake from suspend.

Commands ant expected output:

iw WoW commands:

phy <phyname> wowlan enable [any] [disconnect] [magic-packet] [gtk-rekey-failure] [eap-identity-request] [4way-handshake] [rfkill-release] [patterns <pattern>*]
phy <phyname> wowlan disable
phy <phyname> wowlan show


Enter to WoW Suspend mode, by calling the following command:

root@am37x-evm:/usr/bin# echo mem > /sys/power/state

Following is the screen shot shows how the Host is entering suspend mode, also the wl1271 is suspended

[16277.797393] PM: Syncing filesystems ... done.
[16277.929870] PM: Preparing system for mem sleep
[16277.934509] Freezing user space processes ... (elapsed 0.02 seconds) done.
[16277.963470] Freezing remaining freezable tasks ... (elapsed 0.02 seconds) done.
[16277.994689] PM: Entering mem sleep
[16277.998565] Suspending console(s) (use no_console_suspend to debug)
[16278.242462] PM: suspend of devices complete after 236.060 msecs
[16278.243408] PM: late suspend of devices complete after 0.945 msecs
[16279.748199] Successfully put all powerdomains to target state

Resume from Suspend by sending ping to it.
Following is the screen shot shows how the Host is resuming from suspend mode, also the wl1271 is reconnecting to the WiFi network (by the WPA supplicant) and traffic resumes.

[16279.748840] PM: early resume of devices complete after 0.518 msecs
[16279.749237] platform iva.0: omap_voltage_scale: Already at the requestedrate 800000000
[16279.749237] platform mpu.0: omap_voltage_scale: Already at the requestedrate 1000000000
[16280.107391] PM: resume of devices complete after 358.428 msecs
[16280.157989] PM: Finishing wakeup.
[16280.161499] Restarting tasks ... done.

Rx Filter Configuration

Once enabled, WoWLAN patterns are searched by the chip firmware in every incoming data packet. Once a pattern is detected the chip wakes up the host. To configure wowlan patterns you should use the iw utility. The patterns begin with an 802.3 (Ethernet) header with the correct src/dest MACs (i.e. it's NOT the actual 802.11 header which is transmitted in the air).

Rx filters can be enabled in suspend and in awake states.


The Pattern - 802.3 Mac Header:

Destination MAC Address   6 Bytes Source MAC Address          6 Bytes

  • EtherType                              2 Bytes
  • PayLoad                                 46-1500 Bytes
  • CRC                                        4 Bytes

Payload could be any upper layer protocol, for filter purposes we will only show IP header as when filtering other protocols there is no need to go in the MAC payload. i.e. when configuring a filter for ARP or EAPOL there is no need to configure pattern in the ARP/EAPOL header as you want to pass all of them.


IP filter This pattern if for a frame containing a ip packet:


AA:AA:AA:AA:AA:AA:BB:BB:BB:BB:BB:BB:CC:CC:DD:-:-:-:-:-:-:-:-:EE:-:-:FF:FF:FF:FF:GG:GG:GG:GG:HH:HH:II:II


A: Ethernet destination address

  1. B: Ethernet source address
  2. C: Ethernet protocol type
  3. D: IP header VER+Hlen, use: 0x45 ( 4 – is for ver 4, 5 is for len 20)
  4. E: IP protocol
  5. F: IP source address ( 192.168.0.4: C0:A8:00:2C )
  6. G: IP destination address ( 192.168.0.4: C0:A8:00:2C )
  7. H: Source port (1024: 04:00)
  8. I: Destination port (1024: 04:00)


Restrictions:

Only 7 patterns can be active at any time

  • Max size is 81 bytes
  • No more then 7 segments for each pattern, if pattern crosses layer header it counts as two segments (each segment has an overhead of 4 bytes)


Ethernet protocol type

Ethertype      Protocol
0x05DC         : IEEE 802.3 length
0x0600          : XEROX NS IDP
0x0661          : DLOG
0x0800          : IP, Internet Protocol
0x0801          : X.75 Internet
0x0806          : ARP, Address Resolution Protocol
0x0807          : XNS compatability
0x0808          : Frame Relay ARP
0x8035          : DRARP, Dynamic RARP.RARP, Reverse Address Resolution Protocol
0x80F3          : AARP, AppleTalk Address Resolution Protocol
0x888E          : EAPOL, EAP over LAN
0x8100          : EAPS, Ethernet Automatic Protection Switching
0x8137          : IPX, Internet Packet Exchange
0x814C         : SNMP, Simple Network Management Protocol
0x86DD        : IPv6, Internet Protocol version 6


IP protocols

Decimal Hex Keyword
0 0x04 IPv4
6 0x06 TCP
2 0x02 IGMP
17 0x11 UDP
41 0x29 IPv6


Examples

  • Wake up on any packet sent to MAC 00:44:44:44:44:44

    iw phy0 wowlan enable patterns 00:44:44:44:44:44


  • Wake up on any TCP packet sent to MAC 00:44:44:44:44:44 IP 192.168.1.4 from TCP port 5001

   iw phy0 wowlan enable patterns 00:44:44:44:44:44:-:-:-:-:-:-:08:00:45:-:-:-:-:-:-:-:-:06:-:-:-:-:-:-:c0:a8:01:04:13:89


  • Wake up on any EAPOL traffic directed at MAC 00:44:44:44:44:44

   iw phy0 wowlan enable patterns 00:44:44:44:44:44:-:-:-:-:-:-:88:8e


  • Wakeup on any unicast, broadcast and multicast

   iw phy0 wowlan enable patterns 00:44:44:44:44:44 ff:ff:ff:ff:ff:ff 01:00:5e


  • To set up several patterns

    iw phy0 wowlan enable patterns PATTERN1 PATTERN2 PATTERN3


  • To view the configured patterns:

    iw phy0 wowlan show


Couple of things about iw:

  • The ”:-:” indicate a wildcard byte which isn't matched
  • phy0 identifies the physical device. Best would be to verify what it is by using “iw list | grep Wiphy”



Important Note:

If you don't configure at all unicast pattern (which you probably should as you'd like to receive traffic intended for you) but more specific patterns it's important to include a pattern to capture EAPOLs as these are used for AP Group Rekey which occurs periodically. If these are missed then after a rekey event the station won't be able to receive multicast and broadcast traffic as it wouldn't have the right key to decrypt it (all of this is relevant only to WPA2 where there's rekey).


More on iw commands at wireless.kernel.org/en/users/Documentation/iw

HW modification for AM335x EVM

Engineering Change Order Request
Board Name: AM335x 15x15 Base Board Revision: B1 Project Name: Sitara

WOW support on Sitara platform (AM335x 15x15 Base Board)

Value Changes

  1. Component             Old Value                 New Value
    R221,
    R349,                      0R 0402                   N.C
    R328,                      RES-100004R
    Description: Remove Resistors (For WLAN_IRQ modification)

     2   R350,                      0R 0402                   N.C
          R347                       RES-100004R
          Description: Remove Resistors (For WLAN_EN modification)

Wire-ups/Cuts

  1.  Components Involved: TP31, R328 - Solder wire between TP31 and R328 (WLAN_IRQ)

      2.  Components Involved:  R350, R347 - Solder wire between R350 and R347 (WLAN_EN)