SMPS missing from OpenWrt

During the platform bringup of IPQ807x, we noticed with @robimarko that apparently Openwrt completely lacks SMPS support. To be more precise, mac80211.sh is missing the checks and configuration of SMPS, so hostapd is not configured as well.

As this is a generic 802.11 feature and not platform-specific, I decided to open a separate thread for it.

SMPS is a power save feature that disables all but one of the radio chains of a Wifi radio. There are two versions: dynamic and static SMPS.

The capability is being advertised by the wireless driver based on the radio capability:

                Capabilities: 0x19e7
                        RX LDPC
                        HT20/HT40
                        Dynamic SM Power Save  <--- this is it
                        RX HT20 SGI
                        RX HT40 SGI
                        TX STBC
                        RX STBC 1-stream
                        Max AMSDU length: 7935 bytes
                        DSSS/CCK HT40

Feature bits involved:

||NL80211_FEATURE_STATIC_SMPS|||= 1 << 24,|
||NL80211_FEATURE_DYNAMIC_SMPS|||= 1 << 25,|

As it is relatively straight forward to implement this feature in mac80211.sh and populate it to hostapd, hopefully someone a bit more experienced than I am, can pick this up and make it a reality for the whole of Openwrt.

BTW, dug this old commit to drop SMPS from config
https://patchwork.ozlabs.org/project/openwrt/patch/1422681681-32395-1-git-send-email-hancockrwd@gmail.com/

It also looks like Hostapd gets SMPS info directly from the HT capabilities set by the driver.
So it should work automatically as it checks the nl80211 feature bits when starting the AP and then uses dynamic if available, then checks for static and uses that.

So it should just work, you could check with wireshark for the advertising bits to make sure.
There isn't even a hostapd config flag to set SMPS manually