3.2. mango_wlan Kernel Module

The mango_wlan kernel module is a Linux mac80211 driver for the Mango 802.11 MAC/PHY IP. The driver implements all required ops for the mac80211 API.

Supports:

  • Monitor mode (including control and management Rx) with Tx injection
  • STA client mode
  • AP mode
  • RTS/CTS (Request To Send / Clear To Send)
  • CTS-to-self
  • DSSS, NONHT, HTMF, VHT, and HE advertised rates in management frames
  • Virtual interfaces (up to 4)
  • Firmware-supported beaconing for tight TBTT timing
  • Custom statistics reporting through debugfs
  • Compatible with WPA2/WPA3 security (via kernel crypto subsystem)
  • Vendor-specific radiotap metadata for monitor mode receptions
  • Direct driver interaction via mango-wlan-nl netlink interface
  • Runtime parameter configuration via sysfs interface

MAC Interface

The mango_wlan module communicates with the MAC via a pair of message FIFOs with addresses and interrupt IDs defined in the device tree. These message FIFOs are used primarily for MAC/PHY configuration. Tx/Rx packets are handled by dedicated DMAs and do not transit the message FIFOs.

The mango_wlan exchanges atomic messages with the MAC for all interface configuration commands. The list of message IDs and formats varies between releases. It is essential the mango_wlan driver and MAC software versions match.

debugfs Statistics

Once the module is loaded, /sys/kernel/debug/ieee80211/mango-wlan-phy/netdev:<virtual interface> will be populated with a number of debugfs files. Most are automatically populated with data from the mac80211 framework. mango_wlan provides the following additional files:

stations/<station MAC address>/mango_wlan

This file provides Tx and Rx statistics about the link to a particular station. These statistics are organized according to PHY rate and MCS. It also provides statistics on the number of retries needed in each rate stage of the Minstel rate control algorithm.

mango_latency_debugfs

This file provides information about important system latencies measured by the driver and MAC at runtime.

Beacon Latency

When operating in AP mode, the MAC firmware handles periodic beaconing in order to abide by the strict Target Beacon Transmission Time (TBTT) requirements from the 802.11 specification, but mac80211 provides the payload of each beacon. To do this, the MAC firmware requests a new beacon payload from the driver. There is a tradeoff in the timing of this request. Too early and the beacon contents may represent stale state by the time it is actually transmitted. Too late and a beacon payload update may not occur in time for the TBTT. The default heuristic used by the mango_wlan driver is that beacon update triggers are sent \(2/3\) of the way through a beacon interval. A typical beacon interval is 100 TU, or 102,400 microseconds. In this case, we anticipate that a new beacon payload will be requested approximately 34,133 microseconds before the beacon must be sent.

An example output from mango_latency_debugfs confirms that beacon payload updates are occuring in a timely manner:

                mango_wlan Latency Statistics
----------------------------------------------------
Beacon Update Slack:
 Min: 23907 usec
 Avg: 34733 usec
 Max: 34754 usec
----------------------------------------------------

Sysfs Interface

The mango_wlan driver provides a sysfs interface at /sys/kernel/mango_wlan/ for runtime configuration and version information. The following parameters are available:

Version Information

version

A read-only parameter that displays the major and minor version number of the Mango WLAN system in decimal format (e.g., “3.2”).

driver_build

A read-only parameter that displays the timestamp when the driver was compiled.

driver_git_version

A read-only parameter that displays the git commit hash of the driver source code.

r5_0_build

A read-only parameter that displays the timestamp when the R5_0 firmware was compiled.

r5_0_git_version

A read-only parameter that displays the git commit hash of the R5_0 firmware source code.

r5_1_build

A read-only parameter that displays the timestamp when the R5_1 firmware was compiled.

r5_1_git_version

A read-only parameter that displays the git commit hash of the R5_1 firmware source code.

pl_build

A read-only parameter that displays the timestamp when the XSA file was built in Vivado.

Configuration Parameters

edca_param

Configure Enhanced Distributed Channel Access (EDCA) parameters for each access category queue. The interface accepts five space-separated values in the following format:

echo "<queue> <cwmin> <cwmax> <aifsn> <txop>" > /sys/kernel/mango_wlan/edca_param
Parameters:
  • queue: Access category queue selection (0-3)
  • cwmin: Minimum contention window exponent
  • cwmax: Maximum contention window exponent
  • aifsn: Arbitration Inter-Frame Space Number
  • txop: Transmission Opportunity limit

Example:

# Configure queue 0 with cwmin=4, cwmax=10, aifsn=3, txop=47
echo "0 4 10 3 47" > /sys/kernel/mango_wlan/edca_param

mac_param

A generic interface for sending configuration parameters to the MAC firmware. Accepts a variable number of space-separated values in decimal or hexadecimal format:

echo "<param1> <param2> ..." > /sys/kernel/mango_wlan/mac_param

Example:

# Force tune radio to channel 36
echo "0x00000001 36" > /sys/kernel/mango_wlan/mac_param

Note: The meaning and number of parameters depends on the specific MAC firmware configuration being targeted.

tx_injection_override

The tx_injection_override parameter allows runtime configuration of 802.11 transmission parameters for testing and fine-tuning purposes. It supports three types of overrides:


PHY Mode Override

Set PHY mode and related parameters:

echo "0 phy_mode=<mode> [parameters]" > /sys/kernel/mango_wlan/tx_injection_override

Supported PHY modes:

  • 0x0 (PHY_MODE_DSSS): No additional parameters
  • 0x1 (PHY_MODE_NONHT): No additional parameters
  • 0x2 (PHY_MODE_HTMF): Requires sgi parameter
  • 0x4 (PHY_MODE_VHT): Requires sgi parameter
  • 0x8 (PHY_MODE_HE): Requires multiple parameters:
    • guard_interval: Guard interval (8, 16, 32)
    • ltf_size: LTF training (1, 2, 4)
    • bss_color: BSS color (0-63)
    • txop: Transmission opportunity (0-127)
    • nominal_padding: Nominal padding (0, 8, 16)
    • ul: Uplink flag (0 or 1)

Examples:

# Set PHY_MODE_HTMF with SGI enabled
echo "0 phy_mode=0x2 sgi=1" > /sys/kernel/mango_wlan/tx_injection_override

# Set PHY_MODE_HE with specific parameters
echo "0 phy_mode=0x8 guard_interval=8 ltf_size=1 bss_color=2 txop=5 nominal_padding=0 ul=1" > /sys/kernel/mango_wlan/tx_injection_override

# Clear PHY mode override
echo "0 phy_mode=-1" > /sys/kernel/mango_wlan/tx_injection_override

MCS Override

Set Modulation and Coding Scheme:

echo "1 <mcs_value>" > /sys/kernel/mango_wlan/tx_injection_override

Examples:

# Set MCS to 5
echo "1 5" > /sys/kernel/mango_wlan/tx_injection_override

# Clear MCS override
echo "1 -1" > /sys/kernel/mango_wlan/tx_injection_override

Flags Override

Set transmission flags:

echo "2 <flags_value>" > /sys/kernel/mango_wlan/tx_injection_override

Examples:

# Set flags to 0x1A
echo "2 0x1A" > /sys/kernel/mango_wlan/tx_injection_override

# Clear flags override
echo "2 -1" > /sys/kernel/mango_wlan/tx_injection_override

Note: All numeric inputs accept both decimal and hexadecimal formats.