Network Device Drivers
Upcoming SlideShare
Loading in...5
×
 

Network Device Drivers

on

  • 1,443 views

 

Statistics

Views

Total Views
1,443
Views on SlideShare
1,434
Embed Views
9

Actions

Likes
1
Downloads
29
Comments
0

1 Embed 9

http://www.slideshare.net 9

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Network Device Drivers Network Device Drivers Presentation Transcript

  • Network Device Drivers vivekian@cs.uh.edu
  • Outline ● Brief look at Device Drivers ● Network Device Drivers ● Network Devices ● Madwifi Architecture ● Device Initialization ● Device Registration ● Opening and Closing a device ● Transmission of packets ● receiving packets ● IOCTL implementation
  • Brief look at Device Drivers ● Abstract the hardware ● Provide Mechanism, Not Policy ● e.g. Compare X Server to KDE ● Linux has 3 types of devices – char – block – network
  • Why are Network DD different ? ● It is similar to a block device – register with the kernel ● “Everything is a file” -- not applicable ● Asynchronous packet reception from outside ● Also needed for administrative purposes, the API is hence different
  • Higher protocols Uniform interface for Abstract the tech access to properties of a upper network adapter protocol instances Network Device Interface Network Driver (Adapter Specific)
  • Network Devices ● Represented by a struct net_device – General Fields (name,index,state) – Hardware specific fields (irq,memory addresses of buffers) – Data on the physical layer (mtu,hdr length, watchdog_timer) – Data on the network layer (protocol family) – Device Driver Methods (init,open,hard_start_xmit,get_stats,do_ioctl)
  • Network Devices <---> Device Drivers ● Network devices abstract the Device drivers by providing a uniform interface ● This is done with the help of function pointers ● E.g. Upper layers would call the standard function hard_start_xmit () – dev->hard_start_xmit = ieee80211_hardstart; Device Net Driver Device Function Function
  • MadWifi ● Partial open source Linux device driver for WLAN chipsets from Atheros ● Allows much more tweaking – good from a research POV ● Operation Modes supported – Station – Access Point – Ad hoc – Ahdemo – BSS mode – Monitor – WDS
  • Madwifi Architecture Implements the interface to the network device More Generic Code net80211 module Callbacks for the net80211 module and access hw Ath module through HAL Closed Source API from the HW for the device driver HAL
  • Device Initialization ● Search for the matching network adapter – Discover the I/O port – First 3 bytes of a MAC address identify the manufacturer ● Find the IRQ and DMA channels and reserve them ● Initialize driver specific methods dev->get_stats = ieee80211_getstats; dev->open = ieee80211_open; dev->stop = ieee80211_stop; dev->hard_start_xmit = ieee80211_hardstart;
  • Device Registration ● Kernel maintains a Linked List for all the registered network devices – dev_base ● register_netdevice () is used to add a new network device dev_base eth1 eth0
  • Opening and Closing ● Admins use ifconfig – ifconfig eth0 up – ifconfig eth0 down ● A device can only be opened once it has been registered ● ifconfig uses ioctl () to pass the appropriate flags for opening and closing devices.
  • Madwifi Implementation ● Madwifi seems to have equivalent init() and open() functions int ieee80211_open(struct net_device *dev) {         return ieee80211_init(dev, 0); } For new cards open reserves the DMA and IRQ lines since they  are not fixed
  • Transmission of Data Packets ● The net device interface function is hard_start_xmit () ● Packet data is copied to the buffer location of the network adapter and the time is marked        ath_hal_txstart(ah, txq­>axq_qnum); ath module code                 sc­>sc_dev­>trans_start = jiffies; ● In most cases, it is checked if there is space on the buffer location and netif_queue_stopped (dev) is called. ● However Madwifi doesnt seem to be using it. Perhaps the HAL takes care of it.
  • receiving packets Acknowledgment of tx receiving error interrupt
  • receiving packets ● Network Adapter interrupts the system processor ● Memory is allocated by using dev_alloc_skb () ● Try to learn the protocol type                   skb­>protocol = eth_type_trans(skb, dev) ● Place the socket buffer in the input queue ● update the last received packet time netif_rx(skb);                 dev­>last_rx = jiffies;
  • IOCTL implementation static int ieee80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {         struct ieee80211vap *vap = dev­>priv;         u_int unit;         switch (cmd) {         case SIOCG80211STATS:                 return copy_to_user(ifr­>ifr_data, &vap­>iv_stats,                         sizeof (vap­>iv_stats)) ? ­EFAULT : 0;         case SIOC80211IFDESTROY:                 if (!capable(CAP_NET_ADMIN))                         return ­EPERM;                 ieee80211_stop(vap­>iv_dev);    /* force state before cleanup */                 unit = vap­>iv_unit;                 vap­>iv_ic­>ic_vap_delete(vap);                 return 0;      
  • References ● Linux Device Drivers Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman ● The Linux Networking Architecture ● Understanding Linux Networking Internals ● http://madwifi.org ● Madwifi Source Code