Linux的WIFI架构,Linux Wireless架构总结

本文详细介绍了Linux中基于USB接口的无线网络适配器驱动的工作原理,包括注册驱动、枚举过程、接口回调函数、数据接收和发送流程,以及INET初始化。重点探讨了ath9k_htc驱动如何与mac80211、cfg80211和net_device进行交互,涉及struct ieee80211_hw、struct ieee80211_ops和struct cfg80211_ops等关键结构体。
摘要由CSDN通过智能技术生成

1、无线网络驱动(ath9k_htc)

ath9k_htc是一个基于USB接口的SoftMAC无线网络适配器。为了其驱动能正常工作,首先必须调用usb_register来注册驱动定义的usb_driver,以借助USB Core的力量来处理与USB协议相关的事件。其代码如下:

staticstructusb_driver ath9k_hif_usb_driver = {

.name = KBUILD_MODNAME,

.probe = ath9k_hif_usb_probe,

.disconnect = ath9k_hif_usb_disconnect,

#ifdef CONFIG_PM

.suspend = ath9k_hif_usb_suspend,

.resume = ath9k_hif_usb_resume,

.reset_resume = ath9k_hif_usb_resume,

#endif

.id_table = ath9k_hif_usb_ids,

.soft_unbind = 1,

};

2. 关键

1) struct ieee80211_hw: 它包含802.11 PHY的配置和硬件信息

c31d037867328c40478604173d35529d.png

2.1 各层间关键数据接口

121d89732085d2952d7bba012e2e301a.png

3、USB无线适配器枚举过程

当此基于USB接口的无线网络适配器被枚举时,ath9k_hif_usb_probe将被调用。其调用流程如下图所示:

cf0d20f4f336e3bb1b338304ad4620f3.png

3.1 struct ieee80211_ops 实例 ath9k_htc_ops(驱动实现)

ath9k_htc_ops: mac80211通过这些回调函数回调driver的处理函数。ath9k_htc为了接受mac80211的管理,它必须首先向mac80211注册,以申明自己的存在,从而可以接受mac80211的调用。

structieee80211_ops ath9k_htc_ops = {

.tx                 = ath9k_htc_tx,  // 发送mac80211要求发送的帧

.start              = ath9k_htc_start, // 第一个被attach到此硬件的net_device被enable之前被调用,之后,可以接收帧数据

.stop               = ath9k_htc_stop,  // 最后一个被attach到此硬件的net_device被disable之后被调用,之后,不可以接收帧数据

.add_interface      = ath9k_htc_add_interface, // 当一个被attach到此硬件的net_device被enable时被调用

.remove_interface   = ath9k_htc_remove_interface, // 通知driver一个接口将要going down

.config             = ath9k_htc_config,           // mac802.11调用它修改硬件配置

.configure_filter   = ath9k_htc_configure_filter, // 配置设备的接收过滤器

.sta_add            = ath9k_htc_sta_add,

.sta_remove         = ath9k_htc_sta_remove,

.conf_tx            = ath9k_htc_conf_tx,

.bss_info_changed   = ath9k_htc_bss_info_changed,

.set_key            = ath9k_htc_set_key,

.get_tsf            = ath9k_htc_get_tsf,

.set_tsf            = ath9k_htc_set_tsf,

.reset_tsf          = ath9k_htc_reset_tsf,

.ampdu_action       = ath9k_htc_ampdu_action,

.sw_scan_start      = ath9k_htc_sw_scan_start,

.sw_scan_complete   = ath9k_htc_sw_scan_complete,

.set_rts_threshold  = ath9k_htc_set_rts_threshold,

.rfkill_poll        = ath9k_htc_rfkill_poll_state,

.set_coverage_class = ath9k_htc_set_coverage_class,

.set_bitrate_mask   = ath9k_htc_set_bitrate_mask,

};

3.2 struct cfg80211_ops 实例 mac80211_config_ops(mac80211实现)

cfg80211_ops定义了无线配置的操作,在它的增加虚拟接口(ieee80211_add_iface)中,它将创建并注册net_device。在mac80211中,其定义如下所示:

structcfg80211_ops mac80211_config_ops = {

.add_virtual_intf = ieee80211_add_iface, //使用给定的名字创建一个"虚拟接口",在wiphy的命名空间中创建net_device并返回

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值