Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2004FSU CIS 5930 Internet Protocols1 Network Devices Reading: Chapter 5.

Similar presentations


Presentation on theme: "Fall 2004FSU CIS 5930 Internet Protocols1 Network Devices Reading: Chapter 5."— Presentation transcript:

1 Fall 2004FSU CIS 5930 Internet Protocols1 Network Devices Reading: Chapter 5

2 Fall 2004FSU CIS 5930 Internet Protocols2 Network devices Interface between network adapters and software protocols Asynchronous input/output point of protocol stack

3 Fall 2004FSU CIS 5930 Internet Protocols3 (Network) Hardware Properties I/O ports (base address) –Address of the hardware (in I/O address space) Interrupt ReQuest (IRQ) –Informing kernel something happens at hardware DMA channel –Direct Memory Access

4 Fall 2004FSU CIS 5930 Internet Protocols4 Network device interface Abstract from technical details of network adapters Uniform interface for access by protocol instances –dev.c (net/core/dev.c) Providing interface/functions for upper layer –net_device structure (include/linux/netdevice.h) Hiding specific details in network drivers –xxx_driver.c (drivers/net/xxx_driver.c) Implementation of specific network drivers

5 Fall 2004FSU CIS 5930 Internet Protocols5 Network device interface (Cont’d) driver.c net_tx net_interrupt net_rx skb net_start_xmit net_opennet_stop net_device dev.c netif_rx dev->hard_start_xmitdev->opendev->stop dev_queue_xmit dev_opendev_close Higher protocol instances Network devices (Adapter-independent) Network-devices interface Network driver (Adapter-specifics) Abstraction from Adapter specfics

6 Fall 2004FSU CIS 5930 Internet Protocols6 net_device structure Defined in include/linux/netdevice.h –Abtract from network adapter specifics –Containing network adapter information –Configuration data of the adapter –General fields of a network device –Hardware-specific fields –Data on physical layer –Data on network layer –Device-driver methods/functions

7 Fall 2004FSU CIS 5930 Internet Protocols7 General fields of a network device Name –For example, eth0, lo ifindex State –For example, if the adapter is up qdisc –Queue discipline –How packets are served And other fields

8 Fall 2004FSU CIS 5930 Internet Protocols8 Hardware-specific fields rmem_start, rmem_end, mem_start, mem_end –Memory for sending/receiving packets base_addr –I/O base address irq –Interrupt ReQuest DMA channel And other fields

9 Fall 2004FSU CIS 5930 Internet Protocols9 Data on physical layer hard_header_length –Layer-2 packet header length mtu –Maximum transfer unit addr_len, dev_addr[MAX_ADDR_LEN] –Layer-2 address length and address And other fields

10 Fall 2004FSU CIS 5930 Internet Protocols10 Data on network layer ip_ptr, ip6_ptr, etc –Corresponding layer-3 pointers family –Address family, e.g., AF_INET for IP pa_alen –Address length for the family, e.g, 4 for IP pa_addr, pa_mask –Address and mask And other fields

11 Fall 2004FSU CIS 5930 Internet Protocols11 Device-driver methods They are function pointers. Adapter drivers need to implement and map to them Initialization/activation/de-activation –init(), destructor(), open(), close() Transmission of data –hard_start_xmit() Control functions –do_ioctl(), set_config() Helpful functions –dard_header(), hard_header_parse(), etc Other functions

12 Fall 2004FSU CIS 5930 Internet Protocols12 Managing Network Devices dev_base name: eth0 state next priv net_device... Hardware MAC Layer Network layer local1 private driver structure name: eth1 state next priv net_device... Hardware MAC Layer Network layer local2 private driver structure net_device open stop hard_start_xmit... adapter_open() adapter_stop() adapter_start_xmit() open stop hard_start_xmit... adapter2_open() adapter2_stop() adapter2_start_xmit()

13 Fall 2004FSU CIS 5930 Internet Protocols13 Functions to manage devices Registering/unregistering devices Opening/closing devices Creating/finding devices Transmitting over devices Provided in the following two files –net/core/dev.c –drivers/net/net_init.c

14 Fall 2004FSU CIS 5930 Internet Protocols14 Registering/unregistering devices init_netdev(dev, sizeof_priv, mask, setup) init_etherdev(dev, priv_size) ether_setup(dev) register_netdevice(dev) unregister_netdevice(dev)

15 Fall 2004FSU CIS 5930 Internet Protocols15 Opening/closing devices dev_open(dev) dev_close(dev)

16 Fall 2004FSU CIS 5930 Internet Protocols16 Creating/finding devices dev_alloc_name(dev, name) dev_alloc(name, err) dev_get_by_name(name) dev_get(name) dev_getbyhwaddr(type, ha) dev_load(name)

17 Fall 2004FSU CIS 5930 Internet Protocols17 Transmitting over network devices dev_queue_xmit(skb)

18 Fall 2004FSU CIS 5930 Internet Protocols18 Network drivers They implement adapter specific functions –Initializing adapters –Opening and closing network adapters –Transmitting/receiving data –We use sample driver isa_skeleton.c to discuss functions (drivers/net/isa_skeleton.c)

19 Fall 2004FSU CIS 5930 Internet Protocols19 Initializing adapters net_init()/net_probe() –netcard_probe(dev) –netcard_probe1(dev, ioaddr) Helper functions to allocate system resources –Request_region(), release_region(), check_region() –Request_irq(), free_irq() –Request_dma(), free_dma()

20 Fall 2004FSU CIS 5930 Internet Protocols20 Opening/closing adapters net_open(dev) net_stop(dev)

21 Fall 2004FSU CIS 5930 Internet Protocols21 Transmitting data net_send_packet(skb, dev) net_interrupt(irq, dev_id, regs) –net_tx(dev) –net_rx(dev) dev.c driver.c net_interrupt netif_rx net_rxnet_tx Receiving a packet Completing A transmission process net_error Errow situation

22 Fall 2004FSU CIS 5930 Internet Protocols22 About the project Progress, problems encountered


Download ppt "Fall 2004FSU CIS 5930 Internet Protocols1 Network Devices Reading: Chapter 5."

Similar presentations


Ads by Google