Chinaunix首页 | 论坛 | 博客
  • 博客访问: 31200
  • 博文数量: 11
  • 博客积分: 1420
  • 博客等级: 上尉
  • 技术积分: 155
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-13 11:49
文章分类
文章存档

2011年(1)

2008年(10)

我的朋友

分类: LINUX

2008-04-17 09:24:46

//hardware:wireless chip ar9132
  // software: "LSDK-WLAN-ap81fus-7.1.2.32.tgz" supported by atheros
  //20080303 init
  一, 关键结构体变量
  ath_ar_ops
  net80211_ops
  ar5416hal
  
  (struct ath_softc_net80211)->sc_ops = ath_ar_ops (struct ath_ops)
  (struct ath_softc)->sc_ieee_ops = net80211_ops (struct ieee80211_ops)
  二, 关键的文件
  if_ath_ahb.c
  ath_linux.c
  if_ath.c
  ath_main.c
  三, 关键函数:
  1 init_ath_ahb (if_ath_ahb.c)
  --1--> init_ahb (if_ath_ahb.c)
   --1.1-->init_ath_wmac (if_ath_ahb.c,创建 net_device: dev)
   --1.1.0--> dev->irq = get_wmac_irq (get the mac)
   --1.1.1-->__ath_attach (ath_linux.c,创建scn,point,register the net_devivce)
   --1.1.1.1-->ath_attach (if_ath.c, scn 填充)
   --1.1.1.1.1-->ath_dev_attach (ath_main.c scn->sc_ops=ath_ar_ops,sc->sc_ieee_ops=net80211_ops)
   --1.1.1.1.2-->_ath_hal_attach
   --1.1.1.1.3-->ieee80211_ifattach
   --1.1.1.2--> scn->sc_ops->tx_init (ath_ar_ops->ath_rx_init)
   --1.1.1.3--> scn->sc_ops->rx_init
   --1.1.1.4--> request_irq (very important,irq function:ath_isr, request the irq,got in init_ath_wmac)
   --1.1.1.5--> register_netdev (very important ,add the dev)
   --1.1.1.6--> ath_iw_attach
   --1.1.1.7--> register_simple_config_callback (for WPS)
  
  
  
  extend functions:
  2 ath_isr
  --2.0-->scn->sc_ops->isr (ath_intr)
  -- 2.1-->intr_tq( ath_tasklet)
   --2.1.1-->scn->sc_ops->handle_intr (ath_handle_intr)
   --2.1.1.1-->ath_handle_rx_intr
   --2.1.1.2-->ath_handle_tx_intr
   --2.1.1.2.1-->ath_tx_tasklet(ath_xmit.c)
  
  
  //receive
  3 ath_handle_intr
  --3.1 --> ath_handle_rx_intr
   --3.1.1--> ath_rx_tasklet
   --3.1.1.1-->ath_rx_indicate (Pass frames up to the stack.)
   --3.1.1.1.0-->sc->sc_ieee_ops->rx_indicate (ath_net80211_rx of struct net80211_ops)
   --3.1.1.1.0.1->ath_net80211_input
   --3.1.1.1.0.1.1-->ieee80211_input
   --3.1.1.1.0.1.1.1--> ic->ic_recv_mgmt(ieee80211_recv_mgmt)
   --3.1.1.1.0.1.1.2--> ieee80211_deliver_data
   --3.1.1.1.0.1.1.1.1-->vlan_hwaccel_receive_skb or netif_rx
   --3.1.1.1.1-->ath_rx_requeue
   --3.1.1.1.1.1-->TAILQ_INSERT_TAIL (add to the tail of the buf list)
  
  
  
  --netif_rx(skb)
  //send
  
  4 ath_netdev_hardstart (dev->hard_start_xmit,set in __ath_attach,ath_linux.c)
  --4.1-->ath_tx_send
   --4.1.1-->scn->sc_ops->tx (ath_tx_start)
   --4.1.1.1--> wbuf_map_sg
   --4.1.1.1.1-->__wbuf_map_sg
   --4.1.1.1.1.1-->wbuf_start_dma (ath_wbuf.c)
   --4.1.1.1.1.1.1-->ath_tx_start_dma (here,josn added smart antenna)
  
  5 ieee80211_ioctl_create_vap (iwconfig call ath0)
  --5.1 get lan unit id
  --5.2 ic->ic_vap_create (ath_vap_create)
   --5.2.1-->scn->sc_ops->add_interface(ath_vap_attach)
   --5.2.2-->ieee80211_vap_setup
   --5.2.2.1--> ieee80211_crypto_vattach
   --5.2.2.2--> ieee80211_proto_vattach
  
   --5.2.2.3.1--> vap->iv_newstate = ieee80211_newstate
   --5.2.2.3--> ieee80211_ioctl_vattach
  
  6
   ieee80211_proto_attach
   --5.2.2.2.1--> ic->ic_recv_mgmt = ieee80211_recv_mgmt
  ieee80211_input-->ic->ic_recv_mgmt(ieee80211_recv_mgmt)-->ieee80211_auth_open
  -->ieee80211_new_state-->vap->iv_newstate(vap, nstate, arg);
  
  四, 发送包时函数调用过程
  ath_netdev_hardstart -> ath_tx_send -> ath_tx_start -> ath_tx_start_dma
  
  
  五, 结构体
  (struct net_device)->priv = struct ath_softc_net80211 变量名简称scn
  (struct ath_softc_net80211)->sc_dev = struct ath_softc 变量名简称sc
  
  
  (struct ath_node_net80211)->an_sta = struct ath_node 变量名简称an
  (struct ath_node_net80211)->an_node = struct ieee80211_node 变量名简称ni




发送包时函数调用过程应该比前面的复杂。
    应该是驱动先注册hard_start_xmit(分别在vap和wifi),然后在系统需要发送数据时,先调用vap的hard_start_xmit,直到发送出去为止。
    1 ath_vap_create(register in ath_attach) --> ieee80211_vap_setup--> dev->hard_start_xmit = ieee80211_hardstart(REGISTER vap's hard_start_xmit)
    2 __ath_attach -->dev->hard_start_xmit = ath_netdev_hardstart(REGISTER wifi's hard_start_xmit)
    3 dev_queue_xmit(such as called by prism2_sta_send_mgmt in hostap) -->dev->hard_start_xmit(ieee80211_hardstart)-->skb->dev = parent, dev_queue_xmit-->dev->hard_start_xmit(ath_netdev_hardstart)--> ath_tx_send --> ath_tx_start --> ath_tx_start_dma



//20080312
  //关于 crypt
  //wep for example
  ath_netdev_hardstart (dev->hard_start_xmit,set in __ath_attach,ath_linux.c)
  1.1-->ath_tx_send
  1.1.1-->ath_tx_prepare
  1.1.1.1-->ieee80211_crypto_encap
  1.1.1.1.1-->cip->ic_encap (wep_encap,registered in linux/net80211/ieee80211_crypto_wep.c)
  1.1.1.1.1.1-->wep_encrypt
阅读(2120) | 评论(2) | 转发(0) |
0

上一篇:没有了

下一篇:看ioctl 调用过程

给主人留下些什么吧!~~

ak7562008-11-05 17:50:04

楼主的LSDK-WLAN-ap81fus-7.1.2.32.tgz驱动程序能共享出来么?我用madwifi的不稳定,想看看你这个。

chinaunix网友2008-07-21 08:50:08

我也在看linux网络驱动和madwifi,有空交流.