Page MenuHomeFreeBSD

net80211: add initial README.md and PROTOCOL.md
ClosedPublic

Authored by adrian on Fri, May 1, 6:53 PM.
Referenced Files
F157901425: D56760.id177514.diff
Tue, May 26, 8:01 AM
Unknown Object (File)
Mon, May 25, 9:38 PM
Unknown Object (File)
Mon, May 25, 7:23 PM
Unknown Object (File)
Mon, May 25, 5:08 PM
Unknown Object (File)
Mon, May 25, 1:30 AM
Unknown Object (File)
Sun, May 24, 10:34 PM
Unknown Object (File)
Sun, May 24, 5:25 PM
Unknown Object (File)
Sun, May 24, 11:49 AM

Details

Summary

Flesh out a work in progress overview and protocol overview document
for net80211.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 72935
Build 69818: arc lint + arc unit

Event Timeline

adrian requested review of this revision.Fri, May 1, 6:53 PM
bz requested changes to this revision.Fri, May 1, 8:12 PM
bz added a subscriber: bz.

I stopped reading. I do not understand the PROTOCOL file for most of it. If you want an overview of the specification go and read a summary of the specification but that doesn't need to be in our tree.

The README really is at least a 70% copy of what's somehow still in our man pages without a single reference to them. I'd rather have us fix the man pages and link to them than have another duplicate copy in a 3rd markup format here.

sys/net80211/PROTOCOL.md
8

None. You need an account in all cases. And it's 802.11-2024 by now.

21

802.11be, well, given you use "devices", it's 802.11bn but not to be outdated you better just say "and the latest generation devices"

This revision now requires changes to proceed.Fri, May 1, 8:12 PM

Consider an implementation from someone who has no knowledge of the stack. It appears as a giant wall of text. Where do you start? What's the equivalent of main() and how do the handlers interoperate?
I would benefit from a walkthrough of how the driver works:

  • Step 1 - Hardware initialization and buffer allocation
  • Step 2 - Creating a VAP layer
  • Step 3 - Powering on
  • Step 4 - State change
  • Step 4 - Enabling the device to receive frames
  • Step 5 - Processing frames

The interplay of the various handlers (_attach, _parent, _start, _transmit, _raw_xmit, _stop, etc) would be useful. I personally find the naming behind of _start a little confusing (seems to be more about the transmission of queued buffers). The crypto layers and key management.
What things go into the VAP layer versus the raw IC layer?

Also common idioms, such as the ring buffer, rxeof versus simple Rx, how partial frames are stored in an mbuf and processed.
A template driver would be good (I have this code: https://github.com/khanzf/i3e_driver). I also have sample dtrace scripts that might help with debugging.
On the theme of sample drivers, suggesting sample implementations from each driver to see a real-world example that keeps things simple to illustrate the point. Meaning, rtwn might not be the best, but rsu might be simpler/better.

Add some more transmit datapath overview documentation.

finish my first pass at the transmit path overview

next up, receive

add some receive documentation

sys/net80211/DATAPATH_RECEIVE.md
44

I believe there is also validation that the rssi and nf are above a certain level.

The ieee80211_add_rx_params would be good to mention here. I was having association rejected for this reason at one point.

Could he mistaken...

131

We could put what are those parameters and what are they used for?

sys/net80211/DATAPATH_TRANSMIT.md
271

Very useful to me personally. Thank you!!

372

Replace "actually" with "specifically", unless I am mistaken.

sys/net80211/PROTOCOL.md
18

This raises the question of where to doesn't meet the spec and why.

sys/net80211/README.md
23

There are some basic requirements, no?

38

"This allows a single physical card to connect to multiple networks simultaneously by virtualizing the physical layer" or whatever more precise language

sys/net80211/DATAPATH_TRANSMIT.md
310

Unnecessary detail.

sys/net80211/DATAPATH_RECEIVE.md
73

This may be a me-thing because I have not gotten this far yet, but I do not know what the decap function does.

131

"Such as rssi, nf, timestamp".

This revision was not accepted when it landed; it landed in state Needs Review.Mon, May 25, 1:34 AM
This revision was automatically updated to reflect the committed changes.
sys/net80211/README.md
132

FreeBSD WiFi drivers share a similar basic layout.

Probe

The goal of this stage is to determine if the driver is applicable to the device. The common idiom is to use drivername_probe(). The bus will provide the vendor and product ID to determine and it is very unlikely that the driver will need to interact with the device.

    1. Attachment - At this stage, the driver will perform the following actions:
  • Read basic information from the device, such specific version, MAC address or specific capabilities.
    • Load firmware
    • Configure device interaction operations, such as read/write to registers (necessary to change device state)
    • For PCI: Configure DMA
  • For USB: Configure Endpoints
    • Initialize state variables and buffers (ie, Tx/Rx buffers)
  • Create mutexes
    • Tell net80211 layer that it exists

Note, this state does not "start" the device beyond what is needed to configure the device and make it ready for operations

By convention, this function is named DRIVERNAME_attach.

VAP Management

This is handled by two handlers:

  • ic->ic_vap_create
  • ic->ic_vap_delete

These functions are used to create or delete a VAP, such as by running ifconfig wlan create wlandev rtwn or ifconfig wlan0 destroy. The driver will allocate or assign device-specific information necessary to manage multiple VAPs.

Device State Change

net80211 has XXX state changes, which changes whether the state is.

  • IEEE80211_S_INIT
  • IEEE80211_S_SCAN - This state will change the device into a state to accept arbitrary beacon frames to identify local access points. Depending on the device, this may require changing the device state to accept arbitrary frames.
  • IEEE80211_S_AUTH - This state is when the device is attempting to authenticate to an access point, but has not yet attempted to associate with it.
  • IEEE80211_S_ASSOC - This state is when the station is performing association negotiation with an access point after successful authentication.
  • IEEE80211_S_CAC -
  • IEEE80211_S_RUN - This state is executed when a device has
  • IEEE80211_S_CSA - Channel State Announcement is is triggered when an AP changes the channel.
  • IEEE80211_S_SLEEP - Executed when the driver is requested to put the device in a sleep state.

By convention, these functions follow the naming convention DRIVERNAME_newstate().

Init and Stop

The initialization function, typically with the naming convention DRIVERNAME_init, is used to turn the device on and notify the hardware to send new frames, either as USB URBs or DMA writes in PCI. By convention DRIVERNAME_init. The device driver should set a running variable or bit to true and, when true, allow new data traffic to be sent.

Similarly, the stop method is used to stop the interface from an active state of sending new frames to the operating system. This might require telling the device to stop sending new frames, changing the power state, and clearing buffers. Note, this is not the same as shutting down the device power. By convention, this is named DRIVERNAME_stop.

Detachment

The detachment phase is called when the device is hardware removed, such as a USB unplug, or the kernel module is unloaded. The intention, where possible, is to leave the device in a working state ready for re-initialization as needed.

The driver should power down the device, flush and free all buffers, delete the driver mutex and return.

By convention, this function is named DRIVERNAME_detach.