There is so many structures in the Linux wireless driver mac80211. Things like struct net_device
, struct ieee80211_hw
, struct ieee80211_vif
and struct ieee80211_local
and so on. So many structures that I don't understand what information they contain and when them were initialized.
How can I learn about them and the whole architecture of wireless drivers?
mac80211 is a framework which driver developers can use to write drivers for SoftMAC wireless devices. SoftMAC devices allow for a finer control of the hardware, allowing for 802.11 frame management to be done in software for them, for both parsing and generation of 802.11 wireless frames.
About Wireless and Network Drivers: Wireless and network drivers are software programs installed on your hard disk that allow your operating system to communicate with your wireless and network adapters. Wireless and network driver problems usually occur due to missing, outdated, or corrupt drivers.
You may want to check out Johannes Berg's (mac80211 maintainer) slides here.
They may be somewhat outdated but should give you a place to start.
A high level description of the Linux WiFi kernel stack:
netif_rx()
). From there the net core will pass it through the TCP/IP stack code and will queue it on the relevant sockets from which the userspace process will read it. On the Tx path packets will be sent from the netdev core to the wireless driver using the ndo_start_xmit()
callback. The driver registers (like other netdevices such as an ethernet driver) a set of operations callbacks by using the struct net_device_ops
.nl80211
(see include/uapi/linux/nl80211.h
). You can send commands and get events in response.nl80211
command it gets initially handled by cfg80211
kernel module (it's code is under net/wireless
and the handlers are in net/wireless/nl80211.c
).
cfg80211
will usually call a lower level driver. In case of Full MAC hardware the specific HW driver is right below cfg80211. The driver below cfg80211
registers a set of ops with cfg80211
by using cfg80211_ops struct
. For example see brcmfmac driver (drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
)mac80211
which is a kernel module implementing the 802.11 MAC layer. In this case cfg80211
will talk to mac80211
which will in turn use the hardware specific lower level driver. An example of this is iwlwifi (For Intel chips).mac80211
registers itself with cfg80211
by using the cfg80211_ops
(see net/mac80211/cfg.c
). The specific HW driver registers itself with mac80211
by using the ieee80211_ops struct
(for example drivers/net/wireless/iwlwifi/mvm/mac80211.c
).ieee80211_allow_hw()
usually after probing the HW. ieee80211_alloc_hw()
gets the size of private data struct used by the HW driver. It in turns calls cfg80211 wiphy_new()
which does the actual allocation of space sufficient for the wiphy struct, the ieee80211_local struct
(which is used by mac80211
) and the HW driver private data (the layering is seen in ieee80211_alloc_hw
code).
ieee80211_hw
is an embedded struct within ieee80211_local
which is "visible" to the the HW driver. All of these (wiphy
, ieee80211_local
, ieee80211_hw
) represent a single physical device connected.ifconfig
. Each such virtual interface is represented by an ieee80211_vif
. This struct also contains at the end private structs accessed by the HW driver. Multiple interfaces can be used to run something like a station on wlan0 and an AP on wlan1 (this is possible depending on the HW capabilities).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With